sibujs 4.11.0 → 4.12.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 (79) hide show
  1. package/README.md +2 -2
  2. package/dist/browser.cjs +1 -1
  3. package/dist/browser.js +4 -4
  4. package/dist/build.cjs +19 -1
  5. package/dist/build.js +13 -12
  6. package/dist/cdn.dev.global.js +12 -12
  7. package/dist/cdn.full.dev.global.js +13 -13
  8. package/dist/cdn.full.global.js +12 -12
  9. package/dist/cdn.global.js +12 -12
  10. package/dist/{chunk-FC6KCJSA.js → chunk-2F4PSJ5Z.js} +162 -67
  11. package/dist/{chunk-R244COCR.js → chunk-653KGQS2.js} +3 -3
  12. package/dist/chunk-AM6DZLBM.js +181 -0
  13. package/dist/{chunk-ADWDDJ5M.js → chunk-B2Y5BJSP.js} +1 -1
  14. package/dist/{chunk-KREPZR2U.js → chunk-CI4W6XAU.js} +4 -4
  15. package/dist/{chunk-NBBFF5VA.js → chunk-DFZL3AX7.js} +6 -6
  16. package/dist/{chunk-OJV2RW4D.js → chunk-EMB5PG7V.js} +1 -1
  17. package/dist/{chunk-3ACAAQIN.js → chunk-F2UWOZ6J.js} +4 -0
  18. package/dist/{chunk-REOAVT2M.js → chunk-HXT2RNH5.js} +1 -1
  19. package/dist/{chunk-F6B5CKF7.js → chunk-IHA62NGJ.js} +1 -1
  20. package/dist/{chunk-VZDMHDVA.js → chunk-LEUEKK4G.js} +2 -2
  21. package/dist/{chunk-WQ7M57JJ.js → chunk-LXBMVGVB.js} +3 -3
  22. package/dist/{chunk-RRKGQKPU.js → chunk-LYTUTXQP.js} +4 -4
  23. package/dist/{chunk-5IODQRR3.js → chunk-NAVLCP4S.js} +4 -4
  24. package/dist/{chunk-YXJHLMRH.js → chunk-NB7TFSJE.js} +5 -5
  25. package/dist/{chunk-5G53CC6L.js → chunk-QLG5IK7F.js} +4 -4
  26. package/dist/{chunk-KFJUMC3Q.js → chunk-RK7EPQPG.js} +1 -1
  27. package/dist/{chunk-LQ2C44YH.js → chunk-T5O2CUHV.js} +1 -1
  28. package/dist/{chunk-CHQPJY47.js → chunk-WFRQ6D7H.js} +1 -1
  29. package/dist/{chunk-3Z7AEJMQ.js → chunk-WH4U2VUE.js} +5 -3
  30. package/dist/{chunk-HMOPAC2Z.js → chunk-XX4BRMWF.js} +15 -3
  31. package/dist/{chunk-7V7VFT7E.js → chunk-ZJCHY2IB.js} +1 -1
  32. package/dist/{chunk-MCPL5WKQ.js → chunk-ZPY2UAKM.js} +3 -3
  33. package/dist/{chunk-DEUONJYR.js → chunk-ZTYCCBU3.js} +19 -11
  34. package/dist/data.cjs +1 -1
  35. package/dist/data.js +5 -5
  36. package/dist/devtools.cjs +1 -1
  37. package/dist/devtools.js +4 -4
  38. package/dist/ecosystem.cjs +9 -1
  39. package/dist/ecosystem.d.cts +1 -1
  40. package/dist/ecosystem.d.ts +1 -1
  41. package/dist/ecosystem.js +8 -8
  42. package/dist/extras.cjs +368 -154
  43. package/dist/extras.d.cts +2 -2
  44. package/dist/extras.d.ts +2 -2
  45. package/dist/extras.js +23 -22
  46. package/dist/index.cjs +19 -1
  47. package/dist/index.d.cts +91 -90
  48. package/dist/index.d.ts +91 -90
  49. package/dist/index.js +13 -12
  50. package/dist/motion.cjs +1 -1
  51. package/dist/motion.js +3 -3
  52. package/dist/patterns.cjs +1 -1
  53. package/dist/patterns.js +5 -5
  54. package/dist/performance.cjs +1 -1
  55. package/dist/performance.d.cts +2 -2
  56. package/dist/performance.d.ts +2 -2
  57. package/dist/performance.js +7 -6
  58. package/dist/plugins.cjs +344 -109
  59. package/dist/plugins.d.cts +1 -1
  60. package/dist/plugins.d.ts +1 -1
  61. package/dist/plugins.js +15 -12
  62. package/dist/{ssr-C8hgIAw7.d.cts → ssr-Db0Sgdu3.d.cts} +7 -4
  63. package/dist/{ssr-C8hgIAw7.d.ts → ssr-Db0Sgdu3.d.ts} +7 -4
  64. package/dist/{ssr-5OWAH3U2.js → ssr-VBM6J5SJ.js} +4 -2
  65. package/dist/ssr.cjs +346 -128
  66. package/dist/ssr.d.cts +1 -1
  67. package/dist/ssr.d.ts +1 -1
  68. package/dist/ssr.js +10 -9
  69. package/dist/{tagFactory-BL2fymez.d.ts → tagFactory-Bnd_Nph9.d.ts} +1 -1
  70. package/dist/{tagFactory-8qL9LCIx.d.cts → tagFactory-DkytnJws.d.cts} +1 -1
  71. package/dist/testing.cjs +1 -1
  72. package/dist/testing.js +2 -2
  73. package/dist/ui.cjs +251 -24
  74. package/dist/ui.d.cts +111 -1
  75. package/dist/ui.d.ts +111 -1
  76. package/dist/ui.js +130 -8
  77. package/dist/widgets.cjs +1 -1
  78. package/dist/widgets.js +6 -6
  79. package/package.json +1 -1
package/dist/ui.d.ts CHANGED
@@ -180,6 +180,116 @@ interface DialogAriaHandle {
180
180
  */
181
181
  declare function createDialogAria(element: HTMLElement, options?: DialogAriaOptions): DialogAriaHandle;
182
182
 
183
+ /**
184
+ * The policy `embed()` enforces.
185
+ *
186
+ * Each entry of `allowedOrigins` is an absolute `https:` URL: an origin
187
+ * (`"https://www.youtube-nocookie.com"`) allows every path on it; an origin
188
+ * with a path (`"https://player.vimeo.com/video/"`) allows that path and what
189
+ * lies beneath it. Credentials, a query or a fragment in an entry are refused.
190
+ */
191
+ interface EmbedPolicy {
192
+ allowedOrigins: readonly string[];
193
+ }
194
+ /**
195
+ * Set the origins `embed()` may frame. Replaces the previous policy; the
196
+ * default allows nothing. Call it once at startup — on the server too, before
197
+ * rendering.
198
+ *
199
+ * Inside `runInSSRContext()` it sets the policy of THAT request only, so a
200
+ * multi-tenant server can configure each render without one request's
201
+ * allowlist reaching another's. Outside a request it sets the process-wide
202
+ * policy every request without its own falls back to.
203
+ *
204
+ * A frame is judged by the policy in force when `embed()` built it: a later
205
+ * `setEmbedPolicy()` changes neither its getter `src` checks nor how SSR
206
+ * serializes it.
207
+ *
208
+ * @throws TypeError for an entry that is not an absolute `https:` URL, or
209
+ * that carries credentials, a query or a fragment.
210
+ */
211
+ declare function setEmbedPolicy(policy: EmbedPolicy): void;
212
+ /**
213
+ * The sandbox `embed()` applies by default — the tokens a hosted video player
214
+ * needs and nothing more:
215
+ *
216
+ * - `allow-scripts`, `allow-same-origin`: the player runs and keeps its own
217
+ * storage. Safe together only because the frame is never same-origin with
218
+ * the page (see `resolveEmbedSrc`).
219
+ * - `allow-presentation`: casting to a second screen.
220
+ * - `allow-popups`, `allow-popups-to-escape-sandbox`: "watch on …" links
221
+ * open a normal tab instead of a crippled sandboxed one.
222
+ *
223
+ * Absent on purpose: `allow-top-navigation*` (the player cannot navigate the
224
+ * page), `allow-forms`, `allow-modals`, `allow-downloads`,
225
+ * `allow-pointer-lock`, `allow-storage-access-by-user-activation`.
226
+ */
227
+ declare const DEFAULT_EMBED_SANDBOX: readonly string[];
228
+
229
+ /** Props for {@link embed}. */
230
+ interface EmbedProps {
231
+ /**
232
+ * The player URL. Must be absolute `https:` and match the allowlist set with
233
+ * `setEmbedPolicy()`. A getter is re-checked on every change; a refused or
234
+ * `null` value leaves the frame without a `src`.
235
+ */
236
+ src: string | (() => string | null | undefined);
237
+ /** Accessible name of the frame. Required. */
238
+ title: string | (() => string);
239
+ /**
240
+ * Permissions-policy features, as in the `allow` attribute. Narrowed to the
241
+ * player features (`accelerometer`, `autoplay`, `clipboard-write`,
242
+ * `encrypted-media`, `fullscreen`, `gyroscope`, `picture-in-picture`,
243
+ * `web-share`). Default: `"encrypted-media; picture-in-picture; fullscreen"`.
244
+ * A feature is kept only when every declaration of it grants the frame's own
245
+ * origin (no allowlist, `'src'` or `*`); `fullscreen 'none'`, `'self'` or a
246
+ * list of other origins drops it instead of granting it.
247
+ */
248
+ allow?: string;
249
+ /**
250
+ * Sandbox tokens. May only REMOVE tokens from `DEFAULT_EMBED_SANDBOX`; other
251
+ * tokens are dropped. `""` applies every restriction.
252
+ */
253
+ sandbox?: string;
254
+ /** Default `"strict-origin-when-cross-origin"`; only stricter values are accepted. */
255
+ referrerpolicy?: "no-referrer" | "same-origin" | "strict-origin" | "strict-origin-when-cross-origin";
256
+ /** Default `"lazy"`. */
257
+ loading?: "lazy" | "eager";
258
+ /** A CSS ratio such as `"16 / 9"`. Sizes the frame to the container's width. */
259
+ aspectRatio?: string;
260
+ class?: string;
261
+ id?: string;
262
+ }
263
+ /**
264
+ * Embed a third-party player (YouTube, Vimeo, …) in an `<iframe>`.
265
+ *
266
+ * The tag factories, `svgElement()` and `DOMPool` refuse `iframe`; this is the
267
+ * one runtime door, and it only opens onto origins the application allowlisted
268
+ * with `setEmbedPolicy()`:
269
+ *
270
+ * - `src` must be absolute `https:` and match an allowlisted origin and path
271
+ * prefix. A value outside the allowlist — a getter's included — is omitted
272
+ * and reported with a development warning. `javascript:`, `data:` and
273
+ * `blob:` can never match; neither can the page's own origin.
274
+ * - `title` is required. `srcdoc` is never written.
275
+ * - Safe defaults: `loading="lazy"`, `referrerpolicy=
276
+ * "strict-origin-when-cross-origin"`, `sandbox` set to
277
+ * `DEFAULT_EMBED_SANDBOX` (written before `src`, so it applies to the first
278
+ * document), and `allow` limited to player features. `sandbox`,
279
+ * `referrerpolicy` and `allow` can only be narrowed.
280
+ * - `renderToString` serializes the frame under the same policy.
281
+ *
282
+ * @example
283
+ * ```ts
284
+ * import { embed, setEmbedPolicy } from "sibujs/ui";
285
+ * setEmbedPolicy({ allowedOrigins: ["https://www.youtube-nocookie.com/embed/"] });
286
+ * embed({ src: `https://www.youtube-nocookie.com/embed/${id}`, title: "Product tour", aspectRatio: "16 / 9" });
287
+ * ```
288
+ *
289
+ * @throws TypeError when `title` is missing or blank.
290
+ */
291
+ declare function embed(props: EmbedProps): HTMLIFrameElement;
292
+
183
293
  /**
184
294
  * lazyEffect creates an effect that only activates when the target element
185
295
  * becomes visible in the viewport (via IntersectionObserver). When the element
@@ -292,4 +402,4 @@ interface ScrollLockHandle {
292
402
  */
293
403
  declare function scrollLock(): ScrollLockHandle;
294
404
 
295
- export { type DialogAriaHandle, type DialogAriaOptions, type FocusManagerHandle, type FocusManagerOptions, type FormActionHandle, type FormActionState, type FormActionSubmit, type IntervalHandle, type ListboxHandle, type ListboxOptions, type ScrollLockHandle, type TimeoutHandle, createDialogAria, createFocusManager, createListbox, formAction, hover, interval, lazyEffect, scrollLock, timeout };
405
+ export { DEFAULT_EMBED_SANDBOX, type DialogAriaHandle, type DialogAriaOptions, type EmbedPolicy, type EmbedProps, type FocusManagerHandle, type FocusManagerOptions, type FormActionHandle, type FormActionState, type FormActionSubmit, type IntervalHandle, type ListboxHandle, type ListboxOptions, type ScrollLockHandle, type TimeoutHandle, createDialogAria, createFocusManager, createListbox, embed, formAction, hover, interval, lazyEffect, scrollLock, setEmbedPolicy, timeout };
package/dist/ui.js CHANGED
@@ -38,7 +38,7 @@ import {
38
38
  toast,
39
39
  withScopedStyle,
40
40
  zipMask
41
- } from "./chunk-NBBFF5VA.js";
41
+ } from "./chunk-DFZL3AX7.js";
42
42
  import {
43
43
  RenderProp,
44
44
  assertType,
@@ -55,27 +55,43 @@ import {
55
55
  withProps,
56
56
  withWrapper
57
57
  } from "./chunk-TUCPL2HB.js";
58
+ import {
59
+ DEFAULT_EMBED_REFERRER_POLICY,
60
+ DEFAULT_EMBED_SANDBOX,
61
+ currentEmbedAllowlist,
62
+ narrowEmbedAllow,
63
+ narrowEmbedReferrerPolicy,
64
+ narrowEmbedSandbox,
65
+ recordEmbedFrame,
66
+ resolveEmbedSrc,
67
+ setEmbedPolicy
68
+ } from "./chunk-AM6DZLBM.js";
58
69
  import {
59
70
  createId
60
- } from "./chunk-CHQPJY47.js";
61
- import "./chunk-HMOPAC2Z.js";
62
- import "./chunk-3ACAAQIN.js";
63
- import "./chunk-KFJUMC3Q.js";
71
+ } from "./chunk-WFRQ6D7H.js";
72
+ import {
73
+ noDocument
74
+ } from "./chunk-XX4BRMWF.js";
75
+ import "./chunk-F2UWOZ6J.js";
76
+ import "./chunk-RK7EPQPG.js";
64
77
  import {
65
78
  globalSingleton
66
79
  } from "./chunk-7ZHH77QA.js";
67
80
  import {
68
81
  effect
69
- } from "./chunk-OJV2RW4D.js";
82
+ } from "./chunk-EMB5PG7V.js";
70
83
  import "./chunk-EXXSN3BW.js";
71
84
  import "./chunk-7XHATCIH.js";
72
85
  import "./chunk-5HZXGZ6T.js";
73
86
  import {
74
87
  batch,
75
88
  signal
76
- } from "./chunk-F6B5CKF7.js";
77
- import "./chunk-ADWDDJ5M.js";
89
+ } from "./chunk-IHA62NGJ.js";
78
90
  import {
91
+ reactiveBinding
92
+ } from "./chunk-B2Y5BJSP.js";
93
+ import {
94
+ devWarnLazy,
79
95
  registerDisposer,
80
96
  unregisterDisposer
81
97
  } from "./chunk-NYNYSPK7.js";
@@ -331,6 +347,109 @@ function createDialogAria(element, options = {}) {
331
347
  return { titleId, descriptionId };
332
348
  }
333
349
 
350
+ // src/ui/embed.ts
351
+ var DEFAULT_ALLOW = "encrypted-media; picture-in-picture; fullscreen";
352
+ var RATIO = /^\d+(\.\d+)?(\s*\/\s*\d+(\.\d+)?)?$/;
353
+ var warnedEmbeds = /* @__PURE__ */ new Set();
354
+ function warnEmbed(key, message) {
355
+ devWarnLazy(() => {
356
+ if (warnedEmbeds.has(key) || warnedEmbeds.size >= 100) return "";
357
+ warnedEmbeds.add(key);
358
+ return message;
359
+ });
360
+ }
361
+ function embed(props) {
362
+ const { src, title } = props;
363
+ if (typeof title !== "function" && (typeof title !== "string" || !title.trim())) {
364
+ throw new TypeError("embed: `title` is required \u2014 it is the frame's accessible name.");
365
+ }
366
+ if (typeof document === "undefined") noDocument();
367
+ if ("srcdoc" in props) {
368
+ warnEmbed("srcdoc", "embed: `srcdoc` is never written \u2014 a frame's document must come from an allowlisted src.");
369
+ }
370
+ const el = document.createElement("iframe");
371
+ const allowed = currentEmbedAllowlist();
372
+ const sandbox = props.sandbox === void 0 ? DEFAULT_EMBED_SANDBOX.join(" ") : narrowEmbedSandbox(props.sandbox);
373
+ if (props.sandbox !== void 0 && sandbox !== props.sandbox.trim().toLowerCase().split(/\s+/).join(" ")) {
374
+ warnEmbed(
375
+ `sandbox|${props.sandbox}`,
376
+ `embed: sandbox "${props.sandbox}" was narrowed to "${sandbox}". A sandbox may only remove tokens from DEFAULT_EMBED_SANDBOX (${DEFAULT_EMBED_SANDBOX.join(" ")}).`
377
+ );
378
+ }
379
+ el.setAttribute("sandbox", sandbox);
380
+ const allowIn = props.allow ?? DEFAULT_ALLOW;
381
+ const allow = narrowEmbedAllow(allowIn);
382
+ const requested = allowIn.split(";").map((d) => d.trim().toLowerCase()).filter(Boolean).join("; ");
383
+ if (allow !== requested) {
384
+ warnEmbed(
385
+ `allow|${allowIn}`,
386
+ `embed: allow "${allowIn}" was narrowed to "${allow}" \u2014 only player features are delegated.`
387
+ );
388
+ }
389
+ if (allow) el.setAttribute("allow", allow);
390
+ if (allow.split("; ").includes("fullscreen")) el.setAttribute("allowfullscreen", "");
391
+ const referrer = narrowEmbedReferrerPolicy(props.referrerpolicy ?? DEFAULT_EMBED_REFERRER_POLICY);
392
+ if (props.referrerpolicy !== void 0 && referrer !== props.referrerpolicy) {
393
+ warnEmbed(
394
+ `referrer|${props.referrerpolicy}`,
395
+ `embed: referrerpolicy "${props.referrerpolicy}" is less strict than the default; using "${referrer}".`
396
+ );
397
+ }
398
+ el.setAttribute("referrerpolicy", referrer);
399
+ recordEmbedFrame(el, { allowed, sandbox, allow, referrer });
400
+ el.setAttribute("loading", props.loading === "eager" ? "eager" : "lazy");
401
+ if (props.aspectRatio !== void 0) {
402
+ if (RATIO.test(props.aspectRatio.trim())) {
403
+ el.style.setProperty("aspect-ratio", props.aspectRatio.trim());
404
+ el.style.setProperty("width", "100%");
405
+ el.style.setProperty("height", "auto");
406
+ el.style.setProperty("border", "0");
407
+ } else {
408
+ warnEmbed(
409
+ `ratio|${props.aspectRatio}`,
410
+ `embed: aspectRatio "${props.aspectRatio}" is not a ratio such as "16 / 9".`
411
+ );
412
+ }
413
+ }
414
+ if (typeof props.class === "string") el.setAttribute("class", props.class);
415
+ if (typeof props.id === "string") el.id = props.id;
416
+ if (typeof title === "function") {
417
+ registerDisposer(
418
+ el,
419
+ reactiveBinding(() => {
420
+ const value = String(title() ?? "");
421
+ if (value.trim()) el.setAttribute("title", value);
422
+ else warnEmbed("title", "embed: a `title` getter returned a blank value; the previous title is kept.");
423
+ }, el)
424
+ );
425
+ } else {
426
+ el.setAttribute("title", title);
427
+ }
428
+ const commitSrc = (value) => {
429
+ const safe = resolveEmbedSrc(value, allowed);
430
+ if (safe === null) {
431
+ el.removeAttribute("src");
432
+ if (value != null) {
433
+ warnEmbed(
434
+ `src|${String(value)}`,
435
+ `embed: refusing src "${String(value)}" \u2014 it is not an https: URL on an origin allowed by setEmbedPolicy().`
436
+ );
437
+ }
438
+ return;
439
+ }
440
+ if (el.getAttribute("src") !== safe) el.setAttribute("src", safe);
441
+ };
442
+ if (typeof src === "function") {
443
+ registerDisposer(
444
+ el,
445
+ reactiveBinding(() => commitSrc(src()), el)
446
+ );
447
+ } else {
448
+ commitSrc(src);
449
+ }
450
+ return el;
451
+ }
452
+
334
453
  // src/ui/lazyEffect.ts
335
454
  function lazyEffect(element, effectFn, options) {
336
455
  if (typeof IntersectionObserver === "undefined") {
@@ -514,6 +633,7 @@ function scrollLock() {
514
633
  return { lock, unlock };
515
634
  }
516
635
  export {
636
+ DEFAULT_EMBED_SANDBOX,
517
637
  FocusTrap,
518
638
  RenderProp,
519
639
  VirtualList,
@@ -540,6 +660,7 @@ export {
540
660
  defineStrictComponent,
541
661
  dialog,
542
662
  email,
663
+ embed,
543
664
  eventBus,
544
665
  focus,
545
666
  form,
@@ -563,6 +684,7 @@ export {
563
684
  required,
564
685
  scopedStyle,
565
686
  scrollLock,
687
+ setEmbedPolicy,
566
688
  ssnMask,
567
689
  svgElement,
568
690
  timeMask,
package/dist/widgets.cjs CHANGED
@@ -735,7 +735,7 @@ function forEachSubscriber(signal2, visit) {
735
735
  }
736
736
 
737
737
  // src/reactivity/track.ts
738
- var _runtimeVersion = true ? "4.11.0" : "dev";
738
+ var _runtimeVersion = true ? "4.12.0" : "dev";
739
739
  var REGISTRY_KEY = /* @__PURE__ */ Symbol.for("sibujs.reactive.v1");
740
740
  function resolveReactiveApi() {
741
741
  const g = globalThis;
package/dist/widgets.js CHANGED
@@ -8,14 +8,14 @@ import {
8
8
  select,
9
9
  tabs,
10
10
  tooltip
11
- } from "./chunk-RRKGQKPU.js";
12
- import "./chunk-REOAVT2M.js";
13
- import "./chunk-CHQPJY47.js";
14
- import "./chunk-KFJUMC3Q.js";
11
+ } from "./chunk-LYTUTXQP.js";
12
+ import "./chunk-HXT2RNH5.js";
13
+ import "./chunk-WFRQ6D7H.js";
14
+ import "./chunk-RK7EPQPG.js";
15
15
  import "./chunk-EXXSN3BW.js";
16
16
  import "./chunk-7XHATCIH.js";
17
- import "./chunk-F6B5CKF7.js";
18
- import "./chunk-ADWDDJ5M.js";
17
+ import "./chunk-IHA62NGJ.js";
18
+ import "./chunk-B2Y5BJSP.js";
19
19
  import "./chunk-NYNYSPK7.js";
20
20
  export {
21
21
  accordion,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sibujs",
3
- "version": "4.11.0",
3
+ "version": "4.12.0",
4
4
  "description": "A function-based frontend framework with fine-grained reactivity and no virtual DOM. Tag factories return live DOM nodes you can hold and mutate, signals update only what changed, and nothing needs a compiler — it runs from a script tag or a bundler.",
5
5
  "keywords": [
6
6
  "frontend",