parse.ts
11 documented symbols. Read the signatures first, then expand each item for parameters, return types, and examples.
11
symbols
10
functions
1
modules
10
parameters
9
returns
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.
Signature
export async function extractIslandInfo(html: string): Promise<IslandInfo[]>
Parameters
-
htmlstring
Returns
Promise<IslandInfo[]>
fnfindComponentElement(children: Element["children"]): Element | nullFind the component element inside <Island>.
Find the component element inside <Island>.
Signature
function findComponentElement(children: Element["children"]): Element | null
Parameters
-
childrenElement["children"]
Returns
Element | null
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.
Signature
export function generateHydrationScript(components: string[]): string
Parameters
-
componentsstring[]
Returns
string
fngetAttribute(el: Element, name: string): string | undefinedGet element attribute value.
Get element attribute value.
Signature
function getAttribute(el: Element, name: string): string | undefined
Parameters
-
elElement -
namestring
Returns
string | undefined
fngetComponentName(el: Element): stringGet component name from child element.
Get component name from child element.
Signature
function getComponentName(el: Element): string
Parameters
-
elElement
Returns
string
fnhasIslands(html: string): booleanCheck if HTML contains any Island components.
Check if HTML contains any Island components.
Signature
export function hasIslands(html: string): boolean
Parameters
-
htmlstring
Returns
boolean
moduleparseIsland Parser Detects <Island> components in HTML and transforms them into hydration-ready elements with data attribute…
Island Parser
Detects <Island> components in HTML and transforms them into hydration-ready elements with data attributes.
fnparseProps(el: Element): Record<string, unknown>Parse JSX-style props from attributes.
Parse JSX-style props from attributes.
Signature
function parseProps(el: Element): Record<string, unknown>
Parameters
-
elElement
Returns
Record<string, unknown>
fnrehypeIslands(collectedIslands: IslandInfo[])Rehype plugin to transform Island components.
Rehype plugin to transform Island components.
Signature
function rehypeIslands(collectedIslands: IslandInfo[])
Parameters
-
collectedIslandsIslandInfo[]
fnresetIslandCounter(): voidReset island counter (for testing).
Reset island counter (for testing).
Signature
export function resetIslandCounter(): void
Returns
void
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>
Signature
export async function transformIslands(html: string): Promise<ParseIslandsResult>
Parameters
-
htmlstring
Returns
Promise<ParseIslandsResult>