sibujs 3.4.0 → 4.0.0

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 (98) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +118 -15
  3. package/dist/browser.cjs +410 -101
  4. package/dist/browser.d.cts +50 -5
  5. package/dist/browser.d.ts +50 -5
  6. package/dist/browser.js +8 -6
  7. package/dist/build.cjs +777 -385
  8. package/dist/build.js +15 -15
  9. package/dist/cdn.global.js +11 -7
  10. package/dist/{chunk-JCO7AHNU.js → chunk-3EKJK5FZ.js} +73 -34
  11. package/dist/chunk-4MFZMLUU.js +147 -0
  12. package/dist/chunk-52XFPGSN.js +123 -0
  13. package/dist/chunk-5INI7D2L.js +194 -0
  14. package/dist/{chunk-OAVXAFAY.js → chunk-6LG2T7LO.js} +5 -5
  15. package/dist/{chunk-OOUQUCNN.js → chunk-ACBT6UZS.js} +57 -22
  16. package/dist/{chunk-F7HW2NI5.js → chunk-AW6HPJ3L.js} +1 -1
  17. package/dist/chunk-DHDZ7IVN.js +109 -0
  18. package/dist/{chunk-JNGGM2XE.js → chunk-DQVUBVNX.js} +16 -25
  19. package/dist/{chunk-AXFWGY32.js → chunk-DR7H6UGM.js} +232 -67
  20. package/dist/{chunk-WSGLJYFI.js → chunk-E62UADKL.js} +9 -3
  21. package/dist/{chunk-3Z2NGWQI.js → chunk-ES2GERY2.js} +1 -1
  22. package/dist/{chunk-S3V6ZXPI.js → chunk-EWEE7NBF.js} +115 -41
  23. package/dist/{chunk-3DVGCW7O.js → chunk-F64ZPCFE.js} +8 -8
  24. package/dist/{chunk-APFRCIRI.js → chunk-GCSGGA3Q.js} +295 -198
  25. package/dist/{chunk-EX77FXTT.js → chunk-HYCCIYNS.js} +228 -51
  26. package/dist/{chunk-ELXMRSVN.js → chunk-NF3LYCQH.js} +259 -124
  27. package/dist/chunk-O3QQ3XOL.js +61 -0
  28. package/dist/{chunk-BUKYCWHX.js → chunk-PBQEW5VW.js} +14 -10
  29. package/dist/{chunk-H5FI5WDP.js → chunk-RRIDJQ5C.js} +3 -3
  30. package/dist/{chunk-S3NFJO6L.js → chunk-TIRZCERI.js} +36 -5
  31. package/dist/{chunk-ODXVQ3CS.js → chunk-VFHIVEPF.js} +309 -188
  32. package/dist/chunk-VPP2FONR.js +142 -0
  33. package/dist/{chunk-KZBEVFXZ.js → chunk-W55YHPEP.js} +5 -3
  34. package/dist/{chunk-FKQG7FTY.js → chunk-WN6WDFCB.js} +4 -4
  35. package/dist/{chunk-CEBWDD63.js → chunk-WOOMUJFT.js} +228 -86
  36. package/dist/{chunk-ITWCTZYH.js → chunk-Z2CE42DB.js} +19 -25
  37. package/dist/{contracts-ey_Qh8ef.d.cts → contracts-Hg6ITAEF.d.cts} +6 -6
  38. package/dist/{contracts-ey_Qh8ef.d.ts → contracts-Hg6ITAEF.d.ts} +6 -6
  39. package/dist/{customElement-CPfIrbvg.d.ts → customElement-CKLoO63w.d.cts} +73 -11
  40. package/dist/{customElement-CPfIrbvg.d.cts → customElement-CKLoO63w.d.ts} +73 -11
  41. package/dist/data.cjs +483 -205
  42. package/dist/data.d.cts +139 -7
  43. package/dist/data.d.ts +139 -7
  44. package/dist/data.js +9 -9
  45. package/dist/devtools.cjs +222 -87
  46. package/dist/devtools.js +8 -8
  47. package/dist/dispose-4FZ6OFXR.js +19 -0
  48. package/dist/ecosystem.cjs +419 -175
  49. package/dist/ecosystem.js +11 -11
  50. package/dist/extras.cjs +1981 -765
  51. package/dist/extras.d.cts +7 -7
  52. package/dist/extras.d.ts +7 -7
  53. package/dist/extras.js +29 -26
  54. package/dist/index.cjs +784 -385
  55. package/dist/index.d.cts +299 -28
  56. package/dist/index.d.ts +299 -28
  57. package/dist/index.js +33 -18
  58. package/dist/motion.cjs +180 -50
  59. package/dist/motion.d.cts +26 -0
  60. package/dist/motion.d.ts +26 -0
  61. package/dist/motion.js +5 -5
  62. package/dist/patterns.cjs +437 -170
  63. package/dist/patterns.d.cts +60 -13
  64. package/dist/patterns.d.ts +60 -13
  65. package/dist/patterns.js +7 -7
  66. package/dist/performance.cjs +333 -148
  67. package/dist/performance.d.cts +55 -7
  68. package/dist/performance.d.ts +55 -7
  69. package/dist/performance.js +9 -9
  70. package/dist/plugins.cjs +1374 -576
  71. package/dist/plugins.d.cts +227 -9
  72. package/dist/plugins.d.ts +227 -9
  73. package/dist/plugins.js +613 -321
  74. package/dist/{ssr-D62yFwuw.d.cts → ssr-BiPRdZ6n.d.cts} +44 -15
  75. package/dist/{ssr-D62yFwuw.d.ts → ssr-BiPRdZ6n.d.ts} +44 -15
  76. package/dist/{ssr-2PPULEK2.js → ssr-JFP5535P.js} +5 -4
  77. package/dist/ssr.cjs +1104 -443
  78. package/dist/ssr.d.cts +230 -20
  79. package/dist/ssr.d.ts +230 -20
  80. package/dist/ssr.js +15 -12
  81. package/dist/{startup-0Qv6aosO.d.cts → startup-BMpaiMhP.d.cts} +1 -1
  82. package/dist/{startup-0Qv6aosO.d.ts → startup-BMpaiMhP.d.ts} +1 -1
  83. package/dist/testing.cjs +205 -63
  84. package/dist/testing.d.cts +1 -1
  85. package/dist/testing.d.ts +1 -1
  86. package/dist/testing.js +8 -10
  87. package/dist/ui.cjs +640 -199
  88. package/dist/ui.d.cts +2 -2
  89. package/dist/ui.d.ts +2 -2
  90. package/dist/ui.js +10 -10
  91. package/dist/widgets.cjs +207 -82
  92. package/dist/widgets.js +9 -9
  93. package/package.json +12 -7
  94. package/dist/chunk-5VGSK6D2.js +0 -80
  95. package/dist/chunk-COY6PUD2.js +0 -34
  96. package/dist/chunk-K35BAR4P.js +0 -96
  97. package/dist/chunk-L3GAGWCC.js +0 -111
  98. package/dist/chunk-RT3IYFN2.js +0 -38
@@ -29,12 +29,29 @@ interface HydrationMismatch {
29
29
  message: string;
30
30
  }
31
31
  /**
32
- * Hydrates a server-rendered DOM tree by attaching event listeners
33
- * and activating reactive bindings.
32
+ * Activates a server-rendered SibuJS application by building the live client
33
+ * tree and **replacing** the inert server-rendered subtree with it.
34
+ *
35
+ * SibuJS uses replacement hydration rather than DOM adoption: the server markup
36
+ * is discarded, not attached to. It is not the case that listeners and bindings
37
+ * are wired onto the existing server nodes — reactive bindings belong to the
38
+ * nodes `component()` produced, and adopting server nodes would leave the
39
+ * visible DOM permanently frozen.
40
+ *
41
+ * Consequences worth knowing before deploying SSR:
42
+ *
43
+ * - DOM node identity is not preserved.
44
+ * - Pre-hydration user input, checkbox state, and focus are discarded.
45
+ * - Conversely, partial-adoption mismatch bugs are avoided by this design —
46
+ * the client tree is always authoritative.
47
+ *
48
+ * Re-hydrating the same container disposes the previous client tree first.
34
49
  *
35
50
  * When `options.diagnostics` is true, the walker reports the first
36
51
  * server/client mismatch it finds. This is a dev-mode tool — pass
37
52
  * `diagnostics: false` (or omit it) in production.
53
+ *
54
+ * @see docs/architecture/hydration.md
38
55
  */
39
56
  declare function hydrate(component: () => HTMLElement, container: HTMLElement, options?: HydrateOptions): void;
40
57
  /**
@@ -58,10 +75,17 @@ type TrustedHTML = string & {
58
75
  */
59
76
  declare function trustHTML(html: string): TrustedHTML;
60
77
  /**
61
- * Detect `<meta http-equiv="refresh" content="0;url=javascript:...">`.
62
- * Returns true if the props describe a refresh directive whose URL uses
63
- * a dangerous protocol in which case the entire meta entry must be
64
- * dropped to avoid an XSS vector via the browser refresh mechanism.
78
+ * Should this meta entry be dropped entirely?
79
+ *
80
+ * Delegates to the SHARED meta-refresh policy. This used to be a private copy
81
+ * of four `includes()` checks that happened to match the client's private copy
82
+ * — two implementations of one rule, so a fix to either would silently diverge
83
+ * from the other. The exported name is kept for back-compat; the policy is no
84
+ * longer local.
85
+ *
86
+ * Returns true for a forbidden refresh directive AND for an entry carrying
87
+ * duplicate case-insensitive attribute names, since there the value validated
88
+ * would not be the value the browser ends up honouring.
65
89
  */
66
90
  declare function isDangerousMetaRefresh(metaProps: Record<string, string>): boolean;
67
91
  /**
@@ -100,19 +124,24 @@ declare function renderToStream(element: HTMLElement | DocumentFragment | Node):
100
124
  */
101
125
  declare function collectStream(stream: AsyncGenerator<string> | AsyncIterable<string>): Promise<string>;
102
126
  /**
103
- * Renders a component tree to a Web ReadableStream<string>.
104
- * Compatible with Node 18+, Deno, and edge runtimes.
127
+ * Renders a component tree to a Web `ReadableStream<string>`.
128
+ *
105
129
  * Uses pull-based backpressure — chunks are produced on demand.
130
+ *
131
+ * **Environment.** Supported on SibuJS's declared Node runtime (`>=22.3.0`) and
132
+ * on any other environment providing both the Web Streams API *and* a DOM
133
+ * implementation. Streaming SSR requires the same server DOM as every other
134
+ * SibuJS SSR API: this function takes real `Node` objects and walks them, so a
135
+ * DOM-less runtime cannot produce the input, let alone render it. Do not read
136
+ * "returns a Web stream" as "runs anywhere Web streams exist".
137
+ *
138
+ * **Semantics.** Suspense boundaries encountered during the walk are resolved
139
+ * as a batch before the affected chunk is emitted — the shell is not flushed
140
+ * ahead of individually-completing boundaries. See
141
+ * `docs/architecture/ssr.md` for the precise streaming and failure semantics.
106
142
  */
107
143
  declare function renderToReadableStream(element: HTMLElement | DocumentFragment | Node): ReadableStream<string>;
108
144
  declare function island(id: string, component: () => HTMLElement): HTMLElement;
109
- /**
110
- * Hydrate only elements marked as islands (`data-sibu-island`).
111
- * Non-island content keeps its server-rendered HTML untouched.
112
- *
113
- * Security: uses `hasOwnProperty.call` to guard against prototype-pollution
114
- * lookups (e.g. an island id of `__proto__` must not resolve to `Object.prototype`).
115
- */
116
145
  declare function hydrateIslands(container: HTMLElement, islands: Record<string, () => HTMLElement>): void;
117
146
  /**
118
147
  * Progressively hydrate islands only when they enter the viewport.
@@ -29,12 +29,29 @@ interface HydrationMismatch {
29
29
  message: string;
30
30
  }
31
31
  /**
32
- * Hydrates a server-rendered DOM tree by attaching event listeners
33
- * and activating reactive bindings.
32
+ * Activates a server-rendered SibuJS application by building the live client
33
+ * tree and **replacing** the inert server-rendered subtree with it.
34
+ *
35
+ * SibuJS uses replacement hydration rather than DOM adoption: the server markup
36
+ * is discarded, not attached to. It is not the case that listeners and bindings
37
+ * are wired onto the existing server nodes — reactive bindings belong to the
38
+ * nodes `component()` produced, and adopting server nodes would leave the
39
+ * visible DOM permanently frozen.
40
+ *
41
+ * Consequences worth knowing before deploying SSR:
42
+ *
43
+ * - DOM node identity is not preserved.
44
+ * - Pre-hydration user input, checkbox state, and focus are discarded.
45
+ * - Conversely, partial-adoption mismatch bugs are avoided by this design —
46
+ * the client tree is always authoritative.
47
+ *
48
+ * Re-hydrating the same container disposes the previous client tree first.
34
49
  *
35
50
  * When `options.diagnostics` is true, the walker reports the first
36
51
  * server/client mismatch it finds. This is a dev-mode tool — pass
37
52
  * `diagnostics: false` (or omit it) in production.
53
+ *
54
+ * @see docs/architecture/hydration.md
38
55
  */
39
56
  declare function hydrate(component: () => HTMLElement, container: HTMLElement, options?: HydrateOptions): void;
40
57
  /**
@@ -58,10 +75,17 @@ type TrustedHTML = string & {
58
75
  */
59
76
  declare function trustHTML(html: string): TrustedHTML;
60
77
  /**
61
- * Detect `<meta http-equiv="refresh" content="0;url=javascript:...">`.
62
- * Returns true if the props describe a refresh directive whose URL uses
63
- * a dangerous protocol in which case the entire meta entry must be
64
- * dropped to avoid an XSS vector via the browser refresh mechanism.
78
+ * Should this meta entry be dropped entirely?
79
+ *
80
+ * Delegates to the SHARED meta-refresh policy. This used to be a private copy
81
+ * of four `includes()` checks that happened to match the client's private copy
82
+ * — two implementations of one rule, so a fix to either would silently diverge
83
+ * from the other. The exported name is kept for back-compat; the policy is no
84
+ * longer local.
85
+ *
86
+ * Returns true for a forbidden refresh directive AND for an entry carrying
87
+ * duplicate case-insensitive attribute names, since there the value validated
88
+ * would not be the value the browser ends up honouring.
65
89
  */
66
90
  declare function isDangerousMetaRefresh(metaProps: Record<string, string>): boolean;
67
91
  /**
@@ -100,19 +124,24 @@ declare function renderToStream(element: HTMLElement | DocumentFragment | Node):
100
124
  */
101
125
  declare function collectStream(stream: AsyncGenerator<string> | AsyncIterable<string>): Promise<string>;
102
126
  /**
103
- * Renders a component tree to a Web ReadableStream<string>.
104
- * Compatible with Node 18+, Deno, and edge runtimes.
127
+ * Renders a component tree to a Web `ReadableStream<string>`.
128
+ *
105
129
  * Uses pull-based backpressure — chunks are produced on demand.
130
+ *
131
+ * **Environment.** Supported on SibuJS's declared Node runtime (`>=22.3.0`) and
132
+ * on any other environment providing both the Web Streams API *and* a DOM
133
+ * implementation. Streaming SSR requires the same server DOM as every other
134
+ * SibuJS SSR API: this function takes real `Node` objects and walks them, so a
135
+ * DOM-less runtime cannot produce the input, let alone render it. Do not read
136
+ * "returns a Web stream" as "runs anywhere Web streams exist".
137
+ *
138
+ * **Semantics.** Suspense boundaries encountered during the walk are resolved
139
+ * as a batch before the affected chunk is emitted — the shell is not flushed
140
+ * ahead of individually-completing boundaries. See
141
+ * `docs/architecture/ssr.md` for the precise streaming and failure semantics.
106
142
  */
107
143
  declare function renderToReadableStream(element: HTMLElement | DocumentFragment | Node): ReadableStream<string>;
108
144
  declare function island(id: string, component: () => HTMLElement): HTMLElement;
109
- /**
110
- * Hydrate only elements marked as islands (`data-sibu-island`).
111
- * Non-island content keeps its server-rendered HTML untouched.
112
- *
113
- * Security: uses `hasOwnProperty.call` to guard against prototype-pollution
114
- * lookups (e.g. an island id of `__proto__` must not resolve to `Object.prototype`).
115
- */
116
145
  declare function hydrateIslands(container: HTMLElement, islands: Record<string, () => HTMLElement>): void;
117
146
  /**
118
147
  * Progressively hydrate islands only when they enter the viewport.
@@ -17,10 +17,11 @@ import {
17
17
  ssrSuspense,
18
18
  suspenseSwapScript,
19
19
  trustHTML
20
- } from "./chunk-EX77FXTT.js";
21
- import "./chunk-L3GAGWCC.js";
22
- import "./chunk-S3NFJO6L.js";
23
- import "./chunk-COY6PUD2.js";
20
+ } from "./chunk-HYCCIYNS.js";
21
+ import "./chunk-5INI7D2L.js";
22
+ import "./chunk-TIRZCERI.js";
23
+ import "./chunk-DHDZ7IVN.js";
24
+ import "./chunk-VPP2FONR.js";
24
25
  export {
25
26
  collectStream,
26
27
  deserializeState,