fibrae 0.3.1 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/dist/cli/vite-plugin.js +39 -0
  2. package/dist/cli/vite-plugin.js.map +1 -1
  3. package/dist/core.js +37 -10
  4. package/dist/core.js.map +1 -1
  5. package/dist/dom.d.ts +9 -0
  6. package/dist/dom.js +30 -4
  7. package/dist/dom.js.map +1 -1
  8. package/dist/fiber-commit.d.ts +2 -0
  9. package/dist/fiber-commit.js +171 -36
  10. package/dist/fiber-commit.js.map +1 -1
  11. package/dist/fiber-render.js +13 -27
  12. package/dist/fiber-render.js.map +1 -1
  13. package/dist/fiber-update.d.ts +1 -1
  14. package/dist/fiber-update.js +26 -11
  15. package/dist/fiber-update.js.map +1 -1
  16. package/dist/h.d.ts +65 -10
  17. package/dist/h.js +98 -22
  18. package/dist/h.js.map +1 -1
  19. package/dist/head.d.ts +64 -0
  20. package/dist/head.js +257 -0
  21. package/dist/head.js.map +1 -0
  22. package/dist/hydration-dev.d.ts +24 -0
  23. package/dist/hydration-dev.js +138 -0
  24. package/dist/hydration-dev.js.map +1 -0
  25. package/dist/index.d.ts +4 -1
  26. package/dist/index.js +2 -1
  27. package/dist/index.js.map +1 -1
  28. package/dist/jsx-runtime/index.d.ts +174 -9
  29. package/dist/jsx-runtime/index.js +2 -0
  30. package/dist/jsx-runtime/index.js.map +1 -1
  31. package/dist/mdx/index.d.ts +4 -4
  32. package/dist/mdx/index.js +1 -1
  33. package/dist/mdx/index.js.map +1 -1
  34. package/dist/mdx/parse.d.ts +1 -1
  35. package/dist/mdx/parse.js.map +1 -1
  36. package/dist/mdx/render.d.ts +6 -5
  37. package/dist/mdx/render.js +62 -64
  38. package/dist/mdx/render.js.map +1 -1
  39. package/dist/router/Link.js +7 -1
  40. package/dist/router/Link.js.map +1 -1
  41. package/dist/router/Navigator.d.ts +24 -0
  42. package/dist/router/Navigator.js +24 -0
  43. package/dist/router/Navigator.js.map +1 -1
  44. package/dist/router/RouterOutlet.js +28 -5
  45. package/dist/router/RouterOutlet.js.map +1 -1
  46. package/dist/router/index.d.ts +5 -1
  47. package/dist/router/index.js +3 -1
  48. package/dist/router/index.js.map +1 -1
  49. package/dist/server.js +7 -3
  50. package/dist/server.js.map +1 -1
  51. package/dist/shared.d.ts +34 -4
  52. package/dist/shared.js +12 -2
  53. package/dist/shared.js.map +1 -1
  54. package/dist/tracking.d.ts +3 -2
  55. package/dist/tracking.js +4 -1
  56. package/dist/tracking.js.map +1 -1
  57. package/dist/transition.d.ts +51 -0
  58. package/dist/transition.js +46 -0
  59. package/dist/transition.js.map +1 -0
  60. package/package.json +2 -2
@@ -7,9 +7,10 @@ export type JSXType = typeof Fragment | ((props: object) => VElement | Stream.St
7
7
  export type PropsWithChildren<T = object> = T & {
8
8
  children?: VChild;
9
9
  };
10
- export declare function jsx(type: JSXType, props: PropsWithChildren<{
11
- [key: string]: unknown;
12
- }> | null, ...children: VChild[]): VElement;
10
+ export declare function jsx<E, R>(type: (props: Record<string, unknown>) => Effect.Effect<VElement, E, R>, props: Record<string, unknown> | null, ...children: VChild[]): Effect.Effect<VElement, E, R>;
11
+ export declare function jsx<E, R>(type: (props: Record<string, unknown>) => Stream.Stream<VElement, E, R>, props: Record<string, unknown> | null, ...children: VChild[]): Stream.Stream<VElement, E, R>;
12
+ export declare function jsx(type: (props: Record<string, unknown>) => VNode, props: Record<string, unknown> | null, ...children: VChild[]): VElement;
13
+ export declare function jsx(type: string | typeof Fragment, props: Record<string, unknown> | null, ...children: VChild[]): VElement;
13
14
  export declare const jsxs: typeof jsx;
14
15
  export declare const jsxDEV: typeof jsx;
15
16
  export declare const h: typeof jsx;
@@ -168,7 +169,12 @@ type NarrowedEventNames = keyof NarrowedEventHandlers<HTMLElement>;
168
169
  * typed event handlers, and narrowed form-element events.
169
170
  * Narrowed events override the generic ones to avoid union parameter types.
170
171
  */
171
- type HTMLElementProps<E extends HTMLElement> = BaseHTMLProps & Omit<EventHandlerProps, NarrowedEventNames> & NarrowedEventHandlers<E>;
172
+ type HTMLElementProps<E extends HTMLElement> = Omit<BaseHTMLProps, "ref"> & Omit<EventHandlerProps, NarrowedEventNames> & NarrowedEventHandlers<E> & {
173
+ /** Ref narrowed to the specific element type */
174
+ ref?: ((el: E) => void) | {
175
+ current: E | null;
176
+ };
177
+ };
172
178
  /**
173
179
  * Element-specific attribute types for elements with unique properties.
174
180
  */
@@ -269,6 +275,135 @@ type LinkElementAttrs = {
269
275
  as?: string;
270
276
  sizes?: string;
271
277
  };
278
+ type MediaAttrs = {
279
+ src?: string;
280
+ controls?: boolean;
281
+ autoplay?: boolean;
282
+ loop?: boolean;
283
+ muted?: boolean;
284
+ preload?: "none" | "metadata" | "auto" | "";
285
+ crossOrigin?: string;
286
+ };
287
+ type VideoAttrs = MediaAttrs & {
288
+ width?: string | number;
289
+ height?: string | number;
290
+ poster?: string;
291
+ playsInline?: boolean;
292
+ disablePictureInPicture?: boolean;
293
+ };
294
+ type SourceAttrs = {
295
+ src?: string;
296
+ srcset?: string;
297
+ type?: string;
298
+ media?: string;
299
+ sizes?: string;
300
+ width?: string | number;
301
+ height?: string | number;
302
+ };
303
+ type TrackAttrs = {
304
+ src?: string;
305
+ kind?: "subtitles" | "captions" | "descriptions" | "chapters" | "metadata";
306
+ srclang?: string;
307
+ label?: string;
308
+ default?: boolean;
309
+ };
310
+ type CanvasAttrs = {
311
+ width?: string | number;
312
+ height?: string | number;
313
+ };
314
+ type IframeAttrs = {
315
+ src?: string;
316
+ srcdoc?: string;
317
+ name?: string;
318
+ width?: string | number;
319
+ height?: string | number;
320
+ sandbox?: string;
321
+ allow?: string;
322
+ allowFullscreen?: boolean;
323
+ loading?: "lazy" | "eager";
324
+ referrerPolicy?: string;
325
+ };
326
+ type EmbedAttrs = {
327
+ src?: string;
328
+ type?: string;
329
+ width?: string | number;
330
+ height?: string | number;
331
+ };
332
+ type ObjectAttrs = {
333
+ data?: string;
334
+ type?: string;
335
+ width?: string | number;
336
+ height?: string | number;
337
+ name?: string;
338
+ };
339
+ type DialogAttrs = {
340
+ open?: boolean;
341
+ };
342
+ type DetailsAttrs = {
343
+ open?: boolean;
344
+ name?: string;
345
+ };
346
+ type TableAttrs = {
347
+ cellPadding?: string | number;
348
+ cellSpacing?: string | number;
349
+ };
350
+ type TdThAttrs = {
351
+ colSpan?: number;
352
+ rowSpan?: number;
353
+ headers?: string;
354
+ scope?: string;
355
+ };
356
+ type ColAttrs = {
357
+ span?: number;
358
+ };
359
+ type MeterAttrs = {
360
+ value?: number;
361
+ min?: number;
362
+ max?: number;
363
+ low?: number;
364
+ high?: number;
365
+ optimum?: number;
366
+ };
367
+ type ProgressAttrs = {
368
+ value?: number;
369
+ max?: number;
370
+ };
371
+ type OutputAttrs = {
372
+ htmlFor?: string;
373
+ for?: string;
374
+ name?: string;
375
+ form?: string;
376
+ };
377
+ type TimeAttrs = {
378
+ dateTime?: string;
379
+ };
380
+ type DataAttrs = {
381
+ value?: string;
382
+ };
383
+ type FieldsetAttrs = {
384
+ disabled?: boolean;
385
+ name?: string;
386
+ form?: string;
387
+ };
388
+ type OptgroupAttrs = {
389
+ disabled?: boolean;
390
+ label?: string;
391
+ };
392
+ type MapAttrs = {
393
+ name?: string;
394
+ };
395
+ type AreaAttrs = {
396
+ alt?: string;
397
+ coords?: string;
398
+ download?: string | boolean;
399
+ href?: string;
400
+ shape?: string;
401
+ target?: string;
402
+ rel?: string;
403
+ };
404
+ type SlotAttrs = {
405
+ name?: string;
406
+ };
272
407
  /**
273
408
  * Map of elements that need extra attribute types beyond the base.
274
409
  */
@@ -277,14 +412,39 @@ type SpecificElements = {
277
412
  select: HTMLElementProps<HTMLSelectElement> & SelectAttrs;
278
413
  textarea: HTMLElementProps<HTMLTextAreaElement> & TextareaAttrs;
279
414
  option: HTMLElementProps<HTMLOptionElement> & OptionAttrs;
280
- a: HTMLElementProps<HTMLAnchorElement> & AnchorAttrs;
281
- img: HTMLElementProps<HTMLImageElement> & ImgAttrs;
282
- form: HTMLElementProps<HTMLFormElement> & FormAttrs;
415
+ optgroup: HTMLElementProps<HTMLOptGroupElement> & OptgroupAttrs;
416
+ fieldset: HTMLElementProps<HTMLFieldSetElement> & FieldsetAttrs;
417
+ output: HTMLElementProps<HTMLOutputElement> & OutputAttrs;
283
418
  button: HTMLElementProps<HTMLButtonElement> & ButtonAttrs;
284
419
  label: HTMLElementProps<HTMLLabelElement> & LabelAttrs;
420
+ form: HTMLElementProps<HTMLFormElement> & FormAttrs;
421
+ a: HTMLElementProps<HTMLAnchorElement> & AnchorAttrs;
422
+ area: HTMLElementProps<HTMLAreaElement> & AreaAttrs;
423
+ audio: HTMLElementProps<HTMLAudioElement> & MediaAttrs;
424
+ video: HTMLElementProps<HTMLVideoElement> & VideoAttrs;
425
+ source: HTMLElementProps<HTMLSourceElement> & SourceAttrs;
426
+ track: HTMLElementProps<HTMLTrackElement> & TrackAttrs;
427
+ img: HTMLElementProps<HTMLImageElement> & ImgAttrs;
428
+ canvas: HTMLElementProps<HTMLCanvasElement> & CanvasAttrs;
429
+ iframe: HTMLElementProps<HTMLIFrameElement> & IframeAttrs;
430
+ embed: HTMLElementProps<HTMLEmbedElement> & EmbedAttrs;
431
+ object: HTMLElementProps<HTMLObjectElement> & ObjectAttrs;
285
432
  meta: HTMLElementProps<HTMLMetaElement> & MetaAttrs;
286
433
  script: HTMLElementProps<HTMLScriptElement> & ScriptAttrs;
287
434
  link: HTMLElementProps<HTMLLinkElement> & LinkElementAttrs;
435
+ dialog: HTMLElementProps<HTMLDialogElement> & DialogAttrs;
436
+ details: HTMLElementProps<HTMLDetailsElement> & DetailsAttrs;
437
+ slot: HTMLElementProps<HTMLSlotElement> & SlotAttrs;
438
+ table: HTMLElementProps<HTMLTableElement> & TableAttrs;
439
+ td: HTMLElementProps<HTMLTableCellElement> & TdThAttrs;
440
+ th: HTMLElementProps<HTMLTableCellElement> & TdThAttrs;
441
+ col: HTMLElementProps<HTMLTableColElement> & ColAttrs;
442
+ colgroup: HTMLElementProps<HTMLTableColElement> & ColAttrs;
443
+ meter: HTMLElementProps<HTMLMeterElement> & MeterAttrs;
444
+ progress: HTMLElementProps<HTMLProgressElement> & ProgressAttrs;
445
+ time: HTMLElementProps<HTMLTimeElement> & TimeAttrs;
446
+ data: HTMLElementProps<HTMLDataElement> & DataAttrs;
447
+ map: HTMLElementProps<HTMLMapElement> & MapAttrs;
288
448
  };
289
449
  /**
290
450
  * All remaining HTML elements get base props + typed events.
@@ -369,7 +529,12 @@ type BaseSVGProps = {
369
529
  * SVG element props = common SVG attributes + event handlers.
370
530
  * All SVG elements share the same prop type — no per-element specialization needed.
371
531
  */
372
- type SVGElementProps = BaseSVGProps & EventHandlerProps;
532
+ type SVGElementProps<E extends SVGElement = SVGElement> = Omit<BaseSVGProps, "ref"> & EventHandlerProps & {
533
+ /** Ref narrowed to the specific SVG element type */
534
+ ref?: ((el: E) => void) | {
535
+ current: E | null;
536
+ };
537
+ };
373
538
  /**
374
539
  * SVG elements derived from SVGElementTagNameMap.
375
540
  * Excludes keys that overlap with HTMLElementTagNameMap (a, script, style, title)
@@ -377,7 +542,7 @@ type SVGElementProps = BaseSVGProps & EventHandlerProps;
377
542
  * JSX users expect in practice.
378
543
  */
379
544
  type SVGElements = {
380
- [K in Exclude<keyof SVGElementTagNameMap, keyof HTMLElementTagNameMap>]: SVGElementProps;
545
+ [K in Exclude<keyof SVGElementTagNameMap, keyof HTMLElementTagNameMap>]: SVGElementProps<SVGElementTagNameMap[K]>;
381
546
  };
382
547
  declare global {
383
548
  namespace JSX {
@@ -26,6 +26,8 @@ function normalizeChild(child) {
26
26
  // Assume it's an already properly shaped VElement
27
27
  return child;
28
28
  }
29
+ // --- Implementation (return type is VElement at runtime; overloads provide
30
+ // type-level Effect/Stream propagation for the checker) ---
29
31
  export function jsx(type, props, ...children) {
30
32
  const normalizedProps = props ?? {};
31
33
  let finalChildren = [];
@@ -1 +1 @@
1
- {"version":3,"file":"index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B;KACF,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,IAAI,GAAG,GAAG,CAAC;AAExB,+DAA+D;AAC/D,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAC;AAE1B,oDAAoD;AACpD,MAAM,CAAC,MAAM,CAAC,GAAG,GAAG,CAAC"}
@@ -55,9 +55,9 @@ declare const MdxHighlighter_base: Context.TagClass<MdxHighlighter, "fibrae/MdxH
55
55
  */
56
56
  export declare class MdxHighlighter extends MdxHighlighter_base {
57
57
  /** Create a highlighter from a highlight function */
58
- static readonly make: (highlight: (code: string, lang: string, meta?: string | undefined) => VElement) => Layer.Layer<MdxHighlighter, never, never>;
58
+ static readonly make: (highlight: (code: string, lang: string, meta?: string | undefined) => Effect.Effect<VElement, unknown, unknown> | VElement) => Layer.Layer<MdxHighlighter, never, never>;
59
59
  }
60
- declare const MDXComponents_base: Context.TagClass<MDXComponents, "fibrae/MDXComponents", Partial<Record<string, (props: Record<string, unknown>) => VElement>>>;
60
+ declare const MDXComponents_base: Context.TagClass<MDXComponents, "fibrae/MDXComponents", Partial<Record<string, (props: Record<string, unknown>) => Effect.Effect<VElement, unknown, unknown> | VElement>>>;
61
61
  /**
62
62
  * Optional service for injecting default component overrides into MDX rendering.
63
63
  *
@@ -83,7 +83,7 @@ declare const MDXComponents_base: Context.TagClass<MDXComponents, "fibrae/MDXCom
83
83
  */
84
84
  export declare class MDXComponents extends MDXComponents_base {
85
85
  /** Create a Layer providing component overrides */
86
- static readonly make: (components: Partial<Record<string, (props: Record<string, unknown>) => VElement>>) => Layer.Layer<MDXComponents, never, never>;
86
+ static readonly make: (components: Partial<Record<string, (props: Record<string, unknown>) => Effect.Effect<VElement, unknown, unknown> | VElement>>) => Layer.Layer<MDXComponents, never, never>;
87
87
  }
88
88
  export interface MDXProps {
89
89
  readonly content: string;
@@ -122,4 +122,4 @@ export interface MDXProps {
122
122
  * render(<App />, root).pipe(Effect.provide(MdxLive))
123
123
  * ```
124
124
  */
125
- export declare const MDX: ({ content, components }: MDXProps) => Effect.Effect<VElement, never, never>;
125
+ export declare const MDX: ({ content, components }: MDXProps) => Effect.Effect<VElement, unknown, unknown>;
package/dist/mdx/index.js CHANGED
@@ -132,6 +132,6 @@ export const MDX = ({ content, components }) => Effect.gen(function* () {
132
132
  // Merge: props override service-level defaults
133
133
  const merged = { ...serviceComponents, ...components };
134
134
  const parsed = processor.parse(content);
135
- return parsed.render(merged, Option.getOrUndefined(highlighterOption));
135
+ return yield* parsed.render(merged, Option.getOrUndefined(highlighterOption));
136
136
  });
137
137
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/mdx/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAGvC,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAIvD,gFAAgF;AAChF,aAAa;AACb,gFAAgF;AAEhF,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAUhF,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGtD,gFAAgF;AAChF,uBAAuB;AACvB,gFAAgF;AAEhF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,OAAO,YAAa,SAAQ,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAC,EAGjE;IACD,0DAA0D;IAC1D,MAAM,CAAU,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,YAAY,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;IAE3E,2DAA2D;IAC3D,M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AM,iBAAiB,GAAG,KAAK,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,cAAc,CAAC,CAAC;IACtE,MAAM,iBAAiB,GAAG,KAAK,CAAC,CAAC,IAAI,CACnC,MAAM,CAAC,aAAa,CAAC,aAAa,CAAC,EACnC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,GAAkB,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CACxD,CAAC;IAEF,+CAA+C;IAC/C,MAAM,MAAM,GAAkB,EAAE,GAAG,iBAAiB,EAAE,GAAG,UAAU,EAAE,CAAC;IAEtE,MAAM,MAAM,GAAG,SAAS,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACxC,OAAO,KAAK,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,cAAc,CAAC,iBAAiB,CAAC,CAAC,CAAC;AAChF,CAAC,CAAC,CAAC"}
@@ -9,7 +9,7 @@ export interface MdxHeading {
9
9
  export interface ParsedMdx {
10
10
  readonly frontmatter: Record<string, unknown>;
11
11
  readonly headings: ReadonlyArray<MdxHeading>;
12
- readonly render: (components?: MdxComponents, highlighter?: MdxHighlighterShape) => VElement;
12
+ readonly render: (components?: MdxComponents, highlighter?: MdxHighlighterShape) => Effect.Effect<VElement, unknown, unknown>;
13
13
  }
14
14
  export type PluginTuple = readonly [plugin: any, ...options: any[]];
15
15
  export type Plugin = PluginTuple | ((...args: any[]) => any);
@@ -1 +1 @@
1
- {"version":3,"file":"parse.js","sourceRoot":"","sources":["../../src/mdx/parse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,WAAW,MAAM,cAAc,CAAC;AACvC,OAAO,SAAS,MAAM,YAAY,CAAC;AACnC,OAAO,iBAAiB,MAAM,oBAAoB,CAAC;AACnD,OAAO,SAAS,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,KAAK,IAAI,SAAS,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W,GAAG,kBAAkB,CAAC,OAAO,CAAC,CAAC;YAChD,MAAM,QAAQ,GAAG,eAAe,CAAC,OAAO,CAAC,CAAC;YAE1C,qEAAqE;YACrE,MAAM,aAAa,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;YAEvD,IAAI,SAAS,EAAE,CAAC;gBACd,MAAM,QAAQ,GAAG,aAAoC,CAAC;gBACtD,OAAO;oBACL,WAAW;oBACX,QAAQ;oBACR,MAAM,EAAE,CAAC,UAA0B,EAAE,WAAiC,EAAE,EAAE,CACxE,UAAU,CAAC,QAAQ,EAAE,UAAU,EAAE,WAAW,CAAC;iBAChD,CAAC;YACJ,CAAC;YAED,MAAM,WAAW,GAAG,SAAS,CAAC,aAAqB,CAAC,CAAC;YACrD,OAAO;gBACL,WAAW;gBACX,QAAQ;gBACR,MAAM,EAAE,CAAC,UAA0B,EAAE,WAAiC,EAAE,EAAE,CACxE,WAAW,CAAC,WAAW,EAAE,UAAU,EAAE,WAAW,CAAC;aACpD,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC,CAAC,CAAC"}
@@ -1,11 +1,12 @@
1
+ import * as Effect from "effect/Effect";
1
2
  import type { VElement } from "../shared.js";
2
3
  import type { Root } from "mdast";
3
4
  import type { Root as HastRoot } from "hast";
4
- /** Map of element names to component overrides */
5
- export type MdxComponents = Partial<Record<string, (props: Record<string, unknown>) => VElement>>;
5
+ /** Map of element names to component overrides (may return VElement or Effect<VElement>) */
6
+ export type MdxComponents = Partial<Record<string, (props: Record<string, unknown>) => VElement | Effect.Effect<VElement, unknown, unknown>>>;
6
7
  /** Shape of a highlighter — matches MdxHighlighter service interface */
7
8
  export interface MdxHighlighterShape {
8
- readonly highlight: (code: string, lang: string, meta?: string) => VElement;
9
+ readonly highlight: (code: string, lang: string, meta?: string) => VElement | Effect.Effect<VElement, unknown, unknown>;
9
10
  }
10
11
  /**
11
12
  * Render a pre-parsed MDAST tree to a fibrae VElement.
@@ -13,11 +14,11 @@ export interface MdxHighlighterShape {
13
14
  * Use this when you have already called `parseMdx` (e.g. in an SSG loader)
14
15
  * and want to render the tree with component overrides.
15
16
  */
16
- export declare const renderMdast: (tree: Root, components?: Partial<Record<string, (props: Record<string, unknown>) => VElement>>, highlighter?: MdxHighlighterShape | undefined) => VElement;
17
+ export declare const renderMdast: (tree: Root, components?: Partial<Record<string, (props: Record<string, unknown>) => Effect.Effect<VElement, unknown, unknown> | VElement>>, highlighter?: MdxHighlighterShape | undefined) => Effect.Effect<VElement, unknown, unknown>;
17
18
  /**
18
19
  * Render a pre-parsed HAST tree to a fibrae VElement.
19
20
  *
20
21
  * Used automatically when the processor was configured with rehype plugins.
21
22
  * Can also be called directly if you have a HAST tree from another source.
22
23
  */
23
- export declare const renderHast: (tree: HastRoot, components?: Partial<Record<string, (props: Record<string, unknown>) => VElement>>, highlighter?: MdxHighlighterShape | undefined) => VElement;
24
+ export declare const renderHast: (tree: HastRoot, components?: Partial<Record<string, (props: Record<string, unknown>) => Effect.Effect<VElement, unknown, unknown> | VElement>>, highlighter?: MdxHighlighterShape | undefined) => Effect.Effect<VElement, unknown, unknown>;
@@ -1,5 +1,22 @@
1
+ import * as Effect from "effect/Effect";
1
2
  import { h, createTextElement } from "../h.js";
2
3
  import { getTextContent, slugify } from "./parse.js";
4
+ // =============================================================================
5
+ // Helpers
6
+ // =============================================================================
7
+ /** Normalize a value that may be VElement or Effect<VElement> into Effect<VElement> */
8
+ const normalizeToEffect = (value) => Effect.isEffect(value) ? value : Effect.succeed(value);
9
+ /**
10
+ * Resolve a component override or fall back to a plain HTML tag.
11
+ * Returns Effect because overrides may return Effect<VElement>.
12
+ */
13
+ const resolve = (components, tag, props, children) => {
14
+ const override = components[tag];
15
+ if (override) {
16
+ return normalizeToEffect(override({ ...props, children: children ?? [] }));
17
+ }
18
+ return Effect.succeed(h(tag, props, children ?? []));
19
+ };
3
20
  /** Convert MDX JSX attributes to a props object */
4
21
  const mdxAttrsToProps = (attrs) => {
5
22
  const props = {};
@@ -22,33 +39,25 @@ const renderMdxJsx = (node, components, highlighter) => {
22
39
  const name = node.name;
23
40
  if (!name) {
24
41
  // Fragment: <>{children}</>
25
- return h("FRAGMENT", {}, renderChildren(node.children, components, highlighter));
42
+ return Effect.map(renderChildren(node.children, components, highlighter), (children) => h("FRAGMENT", {}, children));
26
43
  }
27
44
  const props = mdxAttrsToProps(node.attributes);
28
- const children = renderChildren(node.children, components, highlighter);
29
- // Look up component override, fall back to HTML tag for lowercase names
30
- const type = components[name] ?? name;
31
- return h(type, props, children);
45
+ return Effect.flatMap(renderChildren(node.children, components, highlighter), (children) => resolve(components, name, props, children));
32
46
  };
33
47
  // =============================================================================
34
48
  // MDAST Rendering
35
49
  // =============================================================================
36
- const renderChildren = (children, components, highlighter) => children.reduce((acc, child) => {
37
- const el = renderNode(child, components, highlighter);
38
- if (el !== null)
39
- acc.push(el);
40
- return acc;
41
- }, []);
50
+ const renderChildren = (children, components, highlighter) => Effect.map(Effect.forEach(children, (child) => renderNode(child, components, highlighter)), (results) => results.filter((el) => el !== null));
42
51
  const renderHeading = (node, components, highlighter) => {
43
52
  const tag = `h${node.depth}`;
44
53
  const text = getTextContent(node);
45
54
  const slug = slugify(text);
46
- return h((components[tag] ?? tag), { id: slug }, renderChildren(node.children, components, highlighter));
55
+ return Effect.map(renderChildren(node.children, components, highlighter), (children) => h((components[tag] ?? tag), { id: slug }, children));
47
56
  };
48
57
  const renderCodeBlock = (node, components, highlighter) => {
49
58
  // User component overrides take priority over highlighter
50
59
  if (!components["pre"] && !components["code"] && highlighter && node.lang) {
51
- return highlighter.highlight(node.value, node.lang, node.meta ?? undefined);
60
+ return normalizeToEffect(highlighter.highlight(node.value, node.lang, node.meta ?? undefined));
52
61
  }
53
62
  const codeProps = {};
54
63
  if (node.lang) {
@@ -57,44 +66,41 @@ const renderCodeBlock = (node, components, highlighter) => {
57
66
  }
58
67
  if (node.meta)
59
68
  codeProps["data-meta"] = node.meta;
60
- const codeEl = h((components["code"] ?? "code"), codeProps, [
61
- createTextElement(node.value),
62
- ]);
63
- return h((components["pre"] ?? "pre"), {}, [codeEl]);
69
+ return Effect.flatMap(resolve(components, "code", codeProps, [createTextElement(node.value)]), (codeEl) => resolve(components, "pre", {}, [codeEl]));
64
70
  };
65
71
  const renderList = (node, components, highlighter) => {
66
72
  const tag = node.ordered ? "ol" : "ul";
67
73
  const props = {};
68
74
  if (node.ordered && node.start != null && node.start !== 1)
69
75
  props.start = node.start;
70
- return h((components[tag] ?? tag), props, renderChildren(node.children, components, highlighter));
76
+ return Effect.flatMap(renderChildren(node.children, components, highlighter), (children) => resolve(components, tag, props, children));
71
77
  };
72
- const renderListItem = (node, components, highlighter) => {
73
- const children = renderChildren(node.children, components, highlighter);
78
+ const renderListItem = (node, components, highlighter) => Effect.flatMap(renderChildren(node.children, components, highlighter), (children) => {
74
79
  if (node.checked != null) {
75
80
  const checkbox = h("input", { type: "checkbox", checked: node.checked, disabled: true });
76
- return h((components["li"] ?? "li"), { class: "task-list-item" }, [
77
- checkbox,
78
- ...children,
79
- ]);
81
+ return resolve(components, "li", { class: "task-list-item" }, [checkbox, ...children]);
80
82
  }
81
- return h((components["li"] ?? "li"), {}, children);
82
- };
83
+ return resolve(components, "li", {}, children);
84
+ });
83
85
  const renderTable = (node, components, highlighter) => {
84
86
  const [headerRow, ...bodyRows] = node.children;
85
- const thead = h("thead", {}, [renderTableRow(headerRow, components, true, highlighter)]);
86
- const children = [thead];
87
- if (bodyRows.length > 0) {
88
- children.push(h("tbody", {}, bodyRows.map((row) => renderTableRow(row, components, false, highlighter))));
89
- }
90
- return h((components["table"] ?? "table"), {}, children);
87
+ return Effect.flatMap(renderTableRow(headerRow, components, true, highlighter), (theadRow) => {
88
+ const thead = h("thead", {}, [theadRow]);
89
+ if (bodyRows.length === 0) {
90
+ return resolve(components, "table", {}, [thead]);
91
+ }
92
+ return Effect.flatMap(Effect.forEach(bodyRows, (row) => renderTableRow(row, components, false, highlighter)), (tbodyRows) => {
93
+ const tbody = h("tbody", {}, tbodyRows);
94
+ return resolve(components, "table", {}, [thead, tbody]);
95
+ });
96
+ });
91
97
  };
92
- const renderTableRow = (node, components, isHeader, highlighter) => h((components["tr"] ?? "tr"), {}, node.children.map((cell) => renderTableCell(cell, components, isHeader, highlighter)));
98
+ const renderTableRow = (node, components, isHeader, highlighter) => Effect.flatMap(Effect.forEach(node.children, (cell) => renderTableCell(cell, components, isHeader, highlighter)), (cells) => resolve(components, "tr", {}, cells));
93
99
  const renderTableCell = (node, components, isHeader, highlighter) => {
94
100
  const tag = isHeader ? "th" : "td";
95
- return h((components[tag] ?? tag), {}, renderChildren(node.children, components, highlighter));
101
+ return Effect.map(renderChildren(node.children, components, highlighter), (children) => h((components[tag] ?? tag), {}, children));
96
102
  };
97
- const inline = (tag, children, components, highlighter) => h((components[tag] ?? tag), {}, renderChildren(children, components, highlighter));
103
+ const inline = (tag, children, components, highlighter) => Effect.map(renderChildren(children, components, highlighter), (resolved) => h((components[tag] ?? tag), {}, resolved));
98
104
  // =============================================================================
99
105
  // MDAST main dispatch
100
106
  // =============================================================================
@@ -103,9 +109,9 @@ const renderNode = (node, components, highlighter) => {
103
109
  case "heading":
104
110
  return renderHeading(node, components, highlighter);
105
111
  case "paragraph":
106
- return h((components["p"] ?? "p"), {}, renderChildren(node.children, components, highlighter));
112
+ return Effect.flatMap(renderChildren(node.children, components, highlighter), (children) => resolve(components, "p", {}, children));
107
113
  case "text":
108
- return createTextElement(node.value);
114
+ return Effect.succeed(createTextElement(node.value));
109
115
  case "emphasis":
110
116
  return inline("em", node.children, components, highlighter);
111
117
  case "strong":
@@ -117,29 +123,27 @@ const renderNode = (node, components, highlighter) => {
117
123
  const props = { href: n.url };
118
124
  if (n.title)
119
125
  props.title = n.title;
120
- return h((components["a"] ?? "a"), props, renderChildren(n.children, components, highlighter));
126
+ return Effect.flatMap(renderChildren(n.children, components, highlighter), (children) => resolve(components, "a", props, children));
121
127
  }
122
128
  case "image": {
123
129
  const n = node;
124
130
  const props = { src: n.url, alt: n.alt ?? "" };
125
131
  if (n.title)
126
132
  props.title = n.title;
127
- return h((components["img"] ?? "img"), props);
133
+ return resolve(components, "img", props);
128
134
  }
129
135
  case "code":
130
136
  return renderCodeBlock(node, components, highlighter);
131
137
  case "inlineCode":
132
- return h((components["code"] ?? "code"), {}, [
133
- createTextElement(node.value),
134
- ]);
138
+ return resolve(components, "code", {}, [createTextElement(node.value)]);
135
139
  case "blockquote":
136
- return h((components["blockquote"] ?? "blockquote"), {}, renderChildren(node.children, components, highlighter));
140
+ return Effect.flatMap(renderChildren(node.children, components, highlighter), (children) => resolve(components, "blockquote", {}, children));
137
141
  case "list":
138
142
  return renderList(node, components, highlighter);
139
143
  case "listItem":
140
144
  return renderListItem(node, components, highlighter);
141
145
  case "thematicBreak":
142
- return h((components["hr"] ?? "hr"), {});
146
+ return resolve(components, "hr", {});
143
147
  case "table":
144
148
  return renderTable(node, components, highlighter);
145
149
  case "tableRow":
@@ -147,9 +151,9 @@ const renderNode = (node, components, highlighter) => {
147
151
  case "tableCell":
148
152
  return renderTableCell(node, components, false, highlighter);
149
153
  case "html":
150
- return h("span", { dangerouslySetInnerHTML: node.value });
154
+ return Effect.succeed(h("span", { dangerouslySetInnerHTML: node.value }));
151
155
  case "break":
152
- return h((components["br"] ?? "br"), {});
156
+ return resolve(components, "br", {});
153
157
  case "mdxJsxFlowElement":
154
158
  case "mdxJsxTextElement":
155
159
  return renderMdxJsx(node, components, highlighter);
@@ -157,23 +161,23 @@ const renderNode = (node, components, highlighter) => {
157
161
  case "mdxTextExpression":
158
162
  case "mdxjsEsm":
159
163
  // JS expressions and import/export — skip (would require eval)
160
- return null;
164
+ return Effect.succeed(null);
161
165
  case "yaml":
162
166
  case "definition":
163
167
  case "footnoteDefinition":
164
168
  case "footnoteReference":
165
169
  case "linkReference":
166
170
  case "imageReference":
167
- return null;
171
+ return Effect.succeed(null);
168
172
  default: {
169
173
  // Custom node types from remark plugins (e.g. math, inlineMath)
170
174
  // Type-erasure boundary: remark plugins can add arbitrary node types not in RootContent
171
175
  const unknownNode = node;
172
176
  const customComponent = components[unknownNode.type];
173
177
  if (customComponent) {
174
- return customComponent(node);
178
+ return normalizeToEffect(customComponent(node));
175
179
  }
176
- return null;
180
+ return Effect.succeed(null);
177
181
  }
178
182
  }
179
183
  };
@@ -183,7 +187,7 @@ const renderNode = (node, components, highlighter) => {
183
187
  * Use this when you have already called `parseMdx` (e.g. in an SSG loader)
184
188
  * and want to render the tree with component overrides.
185
189
  */
186
- export const renderMdast = (tree, components = {}, highlighter) => h("FRAGMENT", {}, renderChildren(tree.children, components, highlighter));
190
+ export const renderMdast = (tree, components = {}, highlighter) => Effect.map(renderChildren(tree.children, components, highlighter), (children) => h("FRAGMENT", {}, children));
187
191
  // =============================================================================
188
192
  // HAST Rendering
189
193
  // =============================================================================
@@ -213,24 +217,19 @@ const detectCodeBlock = (node) => {
213
217
  : undefined;
214
218
  return { code, lang, meta };
215
219
  };
216
- const renderHastChildren = (children, components, highlighter) => children.reduce((acc, child) => {
217
- const el = renderHastNode(child, components, highlighter);
218
- if (el !== null)
219
- acc.push(el);
220
- return acc;
221
- }, []);
220
+ const renderHastChildren = (children, components, highlighter) => Effect.map(Effect.forEach(children, (child) => renderHastNode(child, components, highlighter)), (results) => results.filter((el) => el !== null));
222
221
  const renderHastNode = (node, components, highlighter) => {
223
222
  switch (node.type) {
224
223
  case "text":
225
- return createTextElement(node.value);
224
+ return Effect.succeed(createTextElement(node.value));
226
225
  case "comment":
227
- return null;
226
+ return Effect.succeed(null);
228
227
  case "element": {
229
228
  // Code block highlighting — user overrides take priority
230
229
  if (!components["pre"] && !components["code"] && highlighter) {
231
230
  const codeBlock = detectCodeBlock(node);
232
231
  if (codeBlock) {
233
- return highlighter.highlight(codeBlock.code, codeBlock.lang, codeBlock.meta);
232
+ return normalizeToEffect(highlighter.highlight(codeBlock.code, codeBlock.lang, codeBlock.meta));
234
233
  }
235
234
  }
236
235
  const tag = node.tagName;
@@ -246,11 +245,10 @@ const renderHastNode = (node, components, highlighter) => {
246
245
  }
247
246
  }
248
247
  }
249
- const children = renderHastChildren(node.children, components, highlighter);
250
- return h((components[tag] ?? tag), props, children);
248
+ return Effect.map(renderHastChildren(node.children, components, highlighter), (children) => h((components[tag] ?? tag), props, children));
251
249
  }
252
250
  default:
253
- return null;
251
+ return Effect.succeed(null);
254
252
  }
255
253
  };
256
254
  /**
@@ -259,5 +257,5 @@ const renderHastNode = (node, components, highlighter) => {
259
257
  * Used automatically when the processor was configured with rehype plugins.
260
258
  * Can also be called directly if you have a HAST tree from another source.
261
259
  */
262
- export const renderHast = (tree, components = {}, highlighter) => h("FRAGMENT", {}, renderHastChildren(tree.children, components, highlighter));
260
+ export const renderHast = (tree, components = {}, highlighter) => Effect.map(renderHastChildren(tree.children, components, highlighter), (children) => h("FRAGMENT", {}, children));
263
261
  //# sourceMappingURL=render.js.map