parse.ts
10 documented symbols. Read the signatures first, then expand each item for parameters, return types, and examples.
Reference
fnextractIslandInfo(html: string): Promise<IslandInfo[]>Extract island info without transforming HTML. Useful for analysis/bundling pur…
Extract island info without transforming HTML. Useful for analysis/bundling purposes.
Parameters
-
htmlstring
Returns
Promise
fnfindComponentElement(children: Element["children"]): Element | nullFind the component element inside <Island>.
Find the component element inside <Island>.
Parameters
-
childrenunknown
Returns
Element | literal
fngenerateHydrationScript(components: string[]): stringGenerate client-side hydration script. This is a minimal script that imports an…
Generate client-side hydration script. This is a minimal script that imports and initializes islands.
Parameters
-
componentsstring[]
Returns
string
fngetAttribute(el: Element, name: string): string | undefinedGet element attribute value.
Get element attribute value.
Parameters
-
elElement -
namestring
Returns
string | undefined
fngetComponentName(el: Element): stringGet component name from child element.
fnhasIslands(html: string): booleanCheck if HTML contains any Island components.
fnparseProps(el: Element): Record<string, unknown>Parse JSX-style props from attributes.
fnrehypeIslands(collectedIslands: IslandInfo[])Rehype plugin to transform Island components.
fnresetIslandCounter(): voidReset island counter (for testing).
fntransformIslands(html: string): Promise<ParseIslandsResult>Transform Island components in HTML. Converts: ```html <Island load="visible">…
Transform Island components in HTML. Converts:
<Island load="visible">
<Counter initial={0} />
</Island>
To:
<div id="ox-island-0"
data-ox-island="Counter"
data-ox-load="visible"
data-ox-props='{"initial":0}'
class="ox-island">
<!-- fallback content -->
</div>
Parameters
-
htmlstring
Returns
Promise