@askrjs/askr 0.3.0 → 0.4.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 (123) hide show
  1. package/CHANGELOG.md +874 -0
  2. package/README.md +61 -29
  3. package/capabilities.json +19 -9
  4. package/dist/actions/index.js +56 -12
  5. package/dist/benchmark.js +10 -15
  6. package/dist/boot/index.d.ts +3 -2
  7. package/dist/boot/index.js +1 -1
  8. package/dist/boot-DaoTYoCw.js +3989 -0
  9. package/dist/browser-activity-CB8e-V4f.js +220 -0
  10. package/dist/components/index.d.ts +8 -1
  11. package/dist/components/index.js +1 -43
  12. package/dist/{aria-hKjThHcp.js → compose-ref-DWzdbxsD.js} +41 -4
  13. package/dist/control/index.d.ts +2 -0
  14. package/dist/control/index.js +1 -1
  15. package/dist/control-nfpT2fbK.js +209 -0
  16. package/dist/core.d.ts +5 -9
  17. package/dist/csp-nonce-DwGw1A6Q.js +35 -0
  18. package/dist/data/index.js +3 -3
  19. package/dist/{data-2edW0jhF.js → data-BCwClJiF.js} +283 -94
  20. package/dist/data-runtime-C1bFAlba.js +242 -0
  21. package/dist/{deferred-CbgNhf67.js → deferred-bEEHHvic.js} +42 -20
  22. package/dist/domains/actions.d.ts +8 -3
  23. package/dist/domains/component.d.ts +1 -107
  24. package/dist/domains/context.d.ts +0 -15
  25. package/dist/domains/control.d.ts +36 -249
  26. package/dist/domains/data.d.ts +31 -13
  27. package/dist/domains/diagnostics.d.ts +1 -2
  28. package/dist/domains/lifecycle.d.ts +2 -5
  29. package/dist/domains/refs.d.ts +0 -2
  30. package/dist/domains/routing.d.ts +43 -8
  31. package/dist/domains/scheduler.d.ts +1 -76
  32. package/dist/domains/server.d.ts +5 -2
  33. package/dist/domains/state.d.ts +2 -5
  34. package/dist/domains/telemetry.d.ts +0 -2
  35. package/dist/elements.d.ts +214 -51
  36. package/dist/error-boundary-Bpwofwps.js +293 -0
  37. package/dist/foundations/icon/index.d.ts +0 -58
  38. package/dist/foundations/icon/index.js +2 -2
  39. package/dist/foundations/index.js +2 -1
  40. package/dist/foundations/interactions/index.js +1 -1
  41. package/dist/foundations/state/index.d.ts +3 -3
  42. package/dist/foundations/state/index.js +5 -3
  43. package/dist/foundations/structures/index.js +2 -1
  44. package/dist/foundations/utilities/index.d.ts +2 -0
  45. package/dist/foundations/utilities/index.js +1 -2
  46. package/dist/fx/index.d.ts +31 -58
  47. package/dist/fx/index.js +313 -195
  48. package/dist/hooks-BimKStr4.js +202 -0
  49. package/dist/index.d.ts +11 -74
  50. package/dist/index.js +8 -447
  51. package/dist/instance-BAnfmXOR.js +988 -0
  52. package/dist/{interactions-CTeACdT_.js → interactions-D2BoREb-.js} +3 -2
  53. package/dist/jsx-dev-runtime.d.ts +41 -18
  54. package/dist/jsx-dev-runtime.js +1 -6
  55. package/dist/{jsx-runtime-CPJXAOBF.js → jsx-runtime-C4idqHY0.js} +18 -7
  56. package/dist/jsx-runtime.js +1 -1
  57. package/dist/jsx.d.ts +61 -37
  58. package/dist/{manifest-D1P3UNWV.js → manifest-CW9gyNBY.js} +3 -3
  59. package/dist/{navigate-prC5V8XV.js → navigate-CP_0Zy5U.js} +454 -87
  60. package/dist/navigation.d.ts +12 -3
  61. package/dist/peer-types.d.ts +8 -0
  62. package/dist/portal-DuOKfnLa.js +349 -0
  63. package/dist/promise-Dz8iIHAm.js +16 -0
  64. package/dist/query-registry-WMCN0BJL.js +320 -0
  65. package/dist/readable-DFWOsTac.js +21 -0
  66. package/dist/{render-context-B7ohlh6t.js → render-context-DGHnEveC.js} +27 -11
  67. package/dist/render-sync-IC5lMFpq.js +1240 -0
  68. package/dist/resolution-Cx82-xjW.js +1244 -0
  69. package/dist/resource-CLjB7RBQ.js +377 -0
  70. package/dist/resources/index.d.ts +21 -11
  71. package/dist/resources/index.js +45 -244
  72. package/dist/router/index.d.ts +14 -5
  73. package/dist/router/index.js +22 -53
  74. package/dist/scope-CwpVSHVf.js +55 -0
  75. package/dist/{shared-kU8yvryp.js → shared-O2ZnmYAf.js} +1 -7
  76. package/dist/{snapshot-source-An4iKajG.js → snapshot-Cjx4N988.js} +6 -1
  77. package/dist/ssg/index.d.ts +1 -2
  78. package/dist/ssg/index.js +5 -13
  79. package/dist/ssr/index.d.ts +26 -28
  80. package/dist/ssr/index.js +4 -4
  81. package/dist/{ssr-CiNm6Vzl.js → ssr-BJ8ug7zH.js} +133 -122
  82. package/dist/ssr-DoV-vJ-5.js +229 -0
  83. package/dist/state-DWO1KzkX.js +232 -0
  84. package/dist/structures-D4dDMqHX.js +231 -0
  85. package/dist/testing/index.d.ts +8 -4
  86. package/dist/testing/index.js +29 -34
  87. package/dist/url-CnbfpX0K.js +185 -0
  88. package/dist/utilities.d.ts +48 -2
  89. package/dist/verify-hydration-DpVaDnqz.js +152 -0
  90. package/package.json +19 -9
  91. package/dist/access-CEA2pOry.js +0 -1046
  92. package/dist/activity-oy2YFTFF.js +0 -201
  93. package/dist/boot-BMBMWUGI.js +0 -1084
  94. package/dist/capabilities-Bbf0mlp9.js +0 -42
  95. package/dist/compose-ref-v0qGlHoN.js +0 -26
  96. package/dist/control-BR_mrX__.js +0 -173
  97. package/dist/control-C-ApnFs1.js +0 -20
  98. package/dist/csp-nonce-BfFWcd0w.js +0 -173
  99. package/dist/data-runtime-CxoY98lX.js +0 -149
  100. package/dist/default-portal-runtime-DvMvWJVp.js +0 -20
  101. package/dist/dom-renderer.d.ts +0 -77
  102. package/dist/domains/renderer.d.ts +0 -127
  103. package/dist/eager-control.d.ts +0 -8
  104. package/dist/effect-C3Zsc1k6.js +0 -292
  105. package/dist/for-state-BDykeOJL.js +0 -1753
  106. package/dist/instance-VAFYVJOa.js +0 -1027
  107. package/dist/notify-DxxuDPeY.js +0 -266
  108. package/dist/portal-w3oQ6oQU.js +0 -29
  109. package/dist/query-registry-LrYpQsDJ.js +0 -83
  110. package/dist/render-resolved-BC0W7_5b.js +0 -1123
  111. package/dist/renderer-CT0HeY58.js +0 -8623
  112. package/dist/resolution-3DskUkjG.js +0 -577
  113. package/dist/resource-18-sFRl9.js +0 -344
  114. package/dist/route-matching-CUzZ31gT.js +0 -551
  115. package/dist/router-internal-7nuNEHfG.js +0 -36
  116. package/dist/scope-Cq_iYbTR.js +0 -403
  117. package/dist/selector-BSPVkjKP.js +0 -311
  118. package/dist/ssr-EPjwJH5R.js +0 -29
  119. package/dist/state-BXJfudq1.js +0 -91
  120. package/dist/structures-CjEzfj4h.js +0 -654
  121. package/dist/timer-C7uqnJVt.js +0 -85
  122. package/dist/verify-hydration-ikaxotf7.js +0 -27
  123. package/dist/vnode-D24p6IW2.js +0 -7
@@ -1,42 +0,0 @@
1
- import { O as ownCleanup, b as attachOwnership } from "./scope-Cq_iYbTR.js";
2
- //#region src/runtime/component/capabilities.ts
3
- /** Integrations may identify and attach to a lifetime without changing it. */
4
- function getComponentLifetimeIdentity(instance) {
5
- return instance.owner.identity;
6
- }
7
- function adoptComponentParent(instance, parent, lifetime = parent?.owner ?? null) {
8
- instance.parentInstance = parent;
9
- attachOwnership(instance.owner, lifetime ?? void 0);
10
- }
11
- function ownComponentCleanup(instance, cleanup) {
12
- ownCleanup(instance.owner, cleanup);
13
- }
14
- function isServerComponent(instance) {
15
- return instance.ssr === true;
16
- }
17
- /** All lifecycle primitives share the execution record's single slot store. */
18
- function getComponentLifecycleSlot(instance, index, kind, create, name = kind) {
19
- const slots = instance.lifecycleSlots ??= [];
20
- const existing = slots[index];
21
- if (existing) {
22
- if (existing.kind !== kind) throw new Error(`${name}() lifecycle order violation: slot ${index} already belongs to ${existing.kind}(). Keep lifecycle primitives in a stable top-level order.`);
23
- return existing;
24
- }
25
- const slot = create();
26
- slots[index] = slot;
27
- return slot;
28
- }
29
- /** Identity mutation stays with the execution record; renderers resolve keys. */
30
- function setComponentVNodeIdentity(instance, node, parent, resolveKey, wrapperDepth = 0, position) {
31
- adoptComponentParent(instance, parent);
32
- instance._vnodeOwner = typeof node === "object" && node !== null ? node : void 0;
33
- instance._vnodeParent = parent;
34
- instance._vnodeParentGeneration = parent?.owner.identity;
35
- const key = resolveKey(node);
36
- if (key === void 0) delete instance._vnodeKey;
37
- else instance._vnodeKey = key;
38
- instance._vnodePosition = position;
39
- instance._wrapperDepth = wrapperDepth;
40
- }
41
- //#endregion
42
- export { ownComponentCleanup as a, isServerComponent as i, getComponentLifecycleSlot as n, setComponentVNodeIdentity as o, getComponentLifetimeIdentity as r, adoptComponentParent as t };
@@ -1,26 +0,0 @@
1
- //#region src/foundations/utilities/compose-ref.ts
2
- /** Write `value` to a {@link Ref}, ignoring failures on readonly object refs. */
3
- function setRef(ref, value) {
4
- if (!ref) return;
5
- if (typeof ref === "function") {
6
- ref(value);
7
- return;
8
- }
9
- try {
10
- ref.current = value;
11
- } catch {}
12
- }
13
- /** Combine multiple refs into one callback ref that writes to all of them. */
14
- function composeRefs(...refs) {
15
- return (value) => {
16
- const errors = [];
17
- for (const ref of refs) try {
18
- setRef(ref, value);
19
- } catch (error) {
20
- errors.push(error);
21
- }
22
- if (errors.length > 0) throw new AggregateError(errors, "Composed ref callbacks failed");
23
- };
24
- }
25
- //#endregion
26
- export { setRef as n, composeRefs as t };
@@ -1,173 +0,0 @@
1
- import { w as isDevelopmentEnvironment } from "./access-CEA2pOry.js";
2
- import { i as markEagerControlPrimitive, t as __CONTROL_BOUNDARY__ } from "./control-C-ApnFs1.js";
3
- import { n as Fragment } from "./jsx-DRS-qjiN.js";
4
- import { m as createShowState, p as createCaseState, s as useForState } from "./for-state-BDykeOJL.js";
5
- import { t as createFineGrainedEffect } from "./effect-C3Zsc1k6.js";
6
- import { t as state } from "./state-BXJfudq1.js";
7
- //#region src/control/shared.ts
8
- function normalizeBoundaryChild(value) {
9
- if (Array.isArray(value)) {
10
- if (value.length === 0) return null;
11
- if (value.length === 1) return normalizeBoundaryChild(value[0]);
12
- return {
13
- type: Fragment,
14
- props: { children: value }
15
- };
16
- }
17
- return value ?? null;
18
- }
19
- function resolveMaybeAccessor(value) {
20
- return typeof value === "function" ? value() : value;
21
- }
22
- //#endregion
23
- //#region src/control/for.ts
24
- /**
25
- * Render a reactive list as keyed child scopes.
26
- *
27
- * The `children` callback receives a snapshot item during boundary
28
- * reconciliation. A plain closure read of parent state is therefore not a
29
- * dependency of an existing row. Use `selector(() => value())` for keyed
30
- * membership reads, or a function-valued prop when only a DOM property needs
31
- * to update. See the reactive control-flow guide for the supported patterns:
32
- * https://github.com/askrjs/askr/blob/main/docs/guides/control-flow.md
33
- */
34
- function resolveEach(each) {
35
- const resolved = typeof each === "function" ? each() : each;
36
- if (!Array.isArray(resolved)) throw new Error("For each must resolve to an array.");
37
- return resolved;
38
- }
39
- function resolveKeyFn(props) {
40
- if ("by" in props && typeof props.by === "function") return props.by;
41
- if ("byIndex" in props && props.byIndex === true) return (_item, index) => index;
42
- throw new Error("[askr] <For> requires a stable `by` key function. Use `byIndex` only as an explicit positional escape hatch.");
43
- }
44
- function createForBoundary(props) {
45
- if ("by" in props && typeof props.by === "function" && "byIndex" in props) throw new Error("[askr] <For> accepts either `by` or `byIndex`, not both.");
46
- const byFn = resolveKeyFn(props);
47
- const fallback = normalizeBoundaryChild(props.fallback);
48
- const forState = useForState(props.each, byFn, props.children, fallback);
49
- const computeItems = () => resolveEach(forState.eachSource);
50
- if (!forState._sourceEffect) {
51
- forState._suspendSourceCommit = true;
52
- forState._sourceEffect = createFineGrainedEffect({
53
- lane: "reactive",
54
- compute: computeItems,
55
- commit: (items) => {
56
- forState.currentItems = items;
57
- if (forState._suspendSourceCommit) return;
58
- forState._needsSourceReconcile = true;
59
- if (forState._enqueueBoundaryCommit) {
60
- forState._enqueueBoundaryCommit();
61
- return;
62
- }
63
- forState.parentInstance?._enqueueRun?.();
64
- }
65
- });
66
- forState._suspendSourceCommit = false;
67
- } else {
68
- forState._suspendSourceCommit = true;
69
- forState._sourceEffect.updateCompute(computeItems);
70
- forState._suspendSourceCommit = false;
71
- }
72
- return {
73
- type: __CONTROL_BOUNDARY__,
74
- _controlState: forState
75
- };
76
- }
77
- function ForPrimitive(props) {
78
- return createForBoundary(props);
79
- }
80
- /** Render a keyed or indexed list, reconciling items by key instead of position. */
81
- const For = markEagerControlPrimitive(ForPrimitive);
82
- //#endregion
83
- //#region src/control/show.ts
84
- function createTruthyRenderer(props) {
85
- if (typeof props.children === "function") return (value) => normalizeBoundaryChild(props.children(value));
86
- const staticChild = normalizeBoundaryChild(props.children);
87
- return () => staticChild;
88
- }
89
- function createFallbackRenderer(fallback) {
90
- const normalizedFallback = normalizeBoundaryChild(fallback);
91
- if (normalizedFallback == null || normalizedFallback === false) return null;
92
- return () => normalizedFallback;
93
- }
94
- function ShowPrimitive(props) {
95
- const selectedValue = resolveMaybeAccessor(props.when);
96
- const renderTruthy = createTruthyRenderer(props);
97
- const renderFallback = createFallbackRenderer(props.fallback);
98
- const showState = state(createShowState(selectedValue, renderTruthy, renderFallback))();
99
- showState.selectedValue = selectedValue;
100
- showState.renderTruthy = renderTruthy;
101
- showState.renderFallback = renderFallback;
102
- return {
103
- type: __CONTROL_BOUNDARY__,
104
- _controlState: showState
105
- };
106
- }
107
- /** Conditionally render children based on `when`, narrowing truthy values for the render function form. */
108
- const Show = markEagerControlPrimitive(ShowPrimitive);
109
- //#endregion
110
- //#region src/control/case.ts
111
- function flattenChildren(children) {
112
- if (!Array.isArray(children)) return children == null || children === false ? [] : [children];
113
- const result = [];
114
- for (const child of children) {
115
- if (Array.isArray(child)) {
116
- result.push(...flattenChildren(child));
117
- continue;
118
- }
119
- result.push(child);
120
- }
121
- return result;
122
- }
123
- /** Declares one branch of a {@link Case}; only valid as its direct child. */
124
- function Match(_props) {
125
- if (isDevelopmentEnvironment()) throw new Error("[askr] <Match> may only be used as a direct child of <Case>.");
126
- return null;
127
- }
128
- function createCaseFallbackRenderer(fallback) {
129
- const normalizedFallback = normalizeBoundaryChild(fallback);
130
- if (normalizedFallback == null || normalizedFallback === false) return null;
131
- return () => normalizedFallback;
132
- }
133
- function createMatchBranchKey(key, index) {
134
- if (key == null) return index;
135
- return `match:${index}:${typeof key}:${String(key)}`;
136
- }
137
- function readMatchBranches(children) {
138
- const branches = [];
139
- const flatChildren = flattenChildren(children);
140
- for (let index = 0; index < flatChildren.length; index += 1) {
141
- const child = flatChildren[index];
142
- if (child == null || child === false) continue;
143
- if (typeof child === "object" && child !== null && "type" in child && child.type === Match) {
144
- const element = child;
145
- const props = element.props ?? {};
146
- const key = createMatchBranchKey(element.key, index);
147
- const render = typeof props.children === "function" ? () => normalizeBoundaryChild(props.children()) : () => normalizeBoundaryChild(props.children);
148
- branches.push({
149
- key,
150
- render,
151
- when: props.when
152
- });
153
- continue;
154
- }
155
- if (isDevelopmentEnvironment()) throw new Error("[askr] <Case> only accepts <Match> children.");
156
- }
157
- return branches;
158
- }
159
- function CasePrimitive(props) {
160
- const matches = readMatchBranches(props.children);
161
- const fallback = createCaseFallbackRenderer(props.fallback);
162
- const caseState = state(createCaseState(matches, fallback))();
163
- caseState.matches = matches;
164
- caseState.fallback = fallback;
165
- return {
166
- type: __CONTROL_BOUNDARY__,
167
- _controlState: caseState
168
- };
169
- }
170
- /** Render the first matching {@link Match} child (by `when`), or `fallback` if none match. */
171
- const Case = markEagerControlPrimitive(CasePrimitive);
172
- //#endregion
173
- export { For as i, Match as n, Show as r, Case as t };
@@ -1,20 +0,0 @@
1
- //#region src/common/control.ts
2
- const __CONTROL_BOUNDARY__ = Symbol("__CONTROL_BOUNDARY__");
3
- const EAGER_CONTROL_PRIMITIVE = Symbol("__ASKR_EAGER_CONTROL_PRIMITIVE__");
4
- const TRANSPARENT_COMPONENT_RESULT = Symbol("__ASKR_TRANSPARENT_COMPONENT_RESULT__");
5
- function markEagerControlPrimitive(primitive) {
6
- primitive[EAGER_CONTROL_PRIMITIVE] = true;
7
- return primitive;
8
- }
9
- function isEagerControlPrimitive(value) {
10
- return typeof value === "function" && Boolean(value[EAGER_CONTROL_PRIMITIVE]);
11
- }
12
- function markTransparentComponentResult(component) {
13
- component[TRANSPARENT_COMPONENT_RESULT] = true;
14
- return component;
15
- }
16
- function hasTransparentComponentResult(value) {
17
- return typeof value === "function" && Boolean(value[TRANSPARENT_COMPONENT_RESULT]);
18
- }
19
- //#endregion
20
- export { markTransparentComponentResult as a, markEagerControlPrimitive as i, hasTransparentComponentResult as n, isEagerControlPrimitive as r, __CONTROL_BOUNDARY__ as t };
@@ -1,173 +0,0 @@
1
- import { m as defineScope, v as readScope } from "./instance-VAFYVJOa.js";
2
- //#region src/common/attr-names.ts
3
- /**
4
- * JSX prop name to rendered HTML attribute name.
5
- *
6
- * The DOM renderer additionally lowercases the result for non-SVG elements,
7
- * using the element's real namespace. SSR renders to text and has no element to
8
- * ask, so every camelCase attribute the public prop types declare is mapped
9
- * explicitly here — otherwise SSR emits `tabIndex` where the DOM renderer
10
- * writes `tabindex`. All of the entries below are HTML-only attribute names
11
- * that are lowercase in SVG too, so the mapping is namespace-independent.
12
- */
13
- const PUBLIC_ATTRIBUTE_NAME_MAP = {
14
- className: "class",
15
- htmlFor: "for",
16
- strokeWidth: "stroke-width",
17
- strokeLinecap: "stroke-linecap",
18
- strokeLinejoin: "stroke-linejoin",
19
- fillRule: "fill-rule",
20
- clipRule: "clip-rule",
21
- autoComplete: "autocomplete",
22
- colSpan: "colspan",
23
- contentEditable: "contenteditable",
24
- enterKeyHint: "enterkeyhint",
25
- inputMode: "inputmode",
26
- maxLength: "maxlength",
27
- minLength: "minlength",
28
- noValidate: "novalidate",
29
- readOnly: "readonly",
30
- rowSpan: "rowspan",
31
- spellCheck: "spellcheck",
32
- tabIndex: "tabindex"
33
- };
34
- function getPublicAttributeName(propName) {
35
- return PUBLIC_ATTRIBUTE_NAME_MAP[propName] ?? propName;
36
- }
37
- //#endregion
38
- //#region src/common/prop-classification.ts
39
- /**
40
- * The prop vocabulary shared by the DOM renderer and the SSR renderer.
41
- *
42
- * These questions — is this prop framework-internal, is it an ARIA attribute,
43
- * how is a style property named, does a `true` value render bare — were
44
- * previously answered separately on each side, and the answers had drifted.
45
- * Both renderers must agree for hydration to match, so the answers live here.
46
- */
47
- /** Props that are never rendered as attributes by either renderer. */
48
- function isSkippedProp(key) {
49
- return key === "children" || key === "imperativeChildren" || key === "key" || key === "ref";
50
- }
51
- /**
52
- * ARIA state attributes take the strings `"true"`/`"false"`, so unlike HTML
53
- * boolean attributes a `false` value is meaningful and must still be rendered.
54
- */
55
- function isAriaAttribute(key) {
56
- return key.length > 5 && key.slice(0, 5).toLowerCase() === "aria-";
57
- }
58
- /**
59
- * CSS custom properties are case-sensitive and must survive verbatim; every
60
- * other style property is camelCase in JSX and kebab-case in CSS.
61
- */
62
- function normalizeStylePropertyName(propertyName) {
63
- if (propertyName.startsWith("--")) return propertyName;
64
- return propertyName.replace(/[A-Z]/g, (char) => `-${char.toLowerCase()}`);
65
- }
66
- /**
67
- * HTML boolean content attributes: present means true, and the value is
68
- * ignored. A `true` prop renders these bare on both sides. Anything else —
69
- * `aria-*`, `data-*`, arbitrary attributes — renders the literal `"true"`,
70
- * because for those the value carries the meaning.
71
- */
72
- const BOOLEAN_HTML_ATTRIBUTES = new Set("allowfullscreen async autofocus autoplay checked controls default defer disabled formnovalidate inert ismap itemscope loop multiple muted nomodule novalidate open playsinline readonly required reversed selected".split(" "));
73
- /**
74
- * The attribute text for a prop value that is exactly `true`.
75
- *
76
- * Boolean attributes render bare (an empty value); everything else renders
77
- * `"true"` so ARIA state and `data-` payloads survive a round trip.
78
- */
79
- function booleanAttributeValue(attributeName) {
80
- return BOOLEAN_HTML_ATTRIBUTES.has(attributeName.toLowerCase()) ? "" : "true";
81
- }
82
- //#endregion
83
- //#region src/common/css.ts
84
- const CSS_UNSAFE_RE = /[{}<>\\]/g;
85
- const CSS_URI_SCHEME_RE = /(?:^|[\s(,])([a-z][a-z0-9+.-]*):/i;
86
- const CSS_FUNCTION_NAME_RE = /([a-z-][a-z0-9-]*)\s*\(/gi;
87
- const CSS_ALLOWED_FUNCTIONS = /* @__PURE__ */ new Set([
88
- "var",
89
- "calc",
90
- "min",
91
- "max",
92
- "clamp",
93
- "rgb",
94
- "rgba",
95
- "hsl",
96
- "hsla",
97
- "lab",
98
- "lch",
99
- "oklab",
100
- "oklch",
101
- "color",
102
- "color-mix",
103
- "translate",
104
- "translatex",
105
- "translatey",
106
- "translatez",
107
- "scale",
108
- "scalex",
109
- "scaley",
110
- "scalez",
111
- "rotate",
112
- "rotatex",
113
- "rotatey",
114
- "rotatez",
115
- "skew",
116
- "skewx",
117
- "skewy",
118
- "matrix",
119
- "matrix3d",
120
- "linear-gradient",
121
- "radial-gradient",
122
- "conic-gradient",
123
- "repeating-linear-gradient",
124
- "repeating-radial-gradient",
125
- "repeating-conic-gradient",
126
- "cubic-bezier",
127
- "steps"
128
- ]);
129
- function sanitizeCssValue(value) {
130
- const str = String(value);
131
- if (CSS_URI_SCHEME_RE.test(str)) return "";
132
- if (str.includes("(")) {
133
- for (const match of str.matchAll(CSS_FUNCTION_NAME_RE)) if (!CSS_ALLOWED_FUNCTIONS.has(match[1].toLowerCase())) return "";
134
- }
135
- return str.replace(CSS_UNSAFE_RE, "");
136
- }
137
- //#endregion
138
- //#region src/csp-nonce.ts
139
- /** Lexical scope carrying the CSP nonce for the current render, if any. */
140
- const CspNonceScope = defineScope(void 0);
141
- /**
142
- * Read the CSP nonce for the current render from {@link CspNonceScope}.
143
- *
144
- * @returns The active nonce, or `undefined` when called outside of a
145
- * component render or when no nonce was configured.
146
- */
147
- function cspNonce() {
148
- try {
149
- return readScope(CspNonceScope);
150
- } catch (error) {
151
- if (error instanceof Error && error.message.startsWith("readScope() can only be called during component render")) return;
152
- throw error;
153
- }
154
- }
155
- function validateCspNonce(value) {
156
- if (value === void 0) return void 0;
157
- const invalid = () => {
158
- throw new TypeError("CSP nonce must be valid base64 or base64url encoding at least 16 bytes.");
159
- };
160
- if (value.length === 0 || !/^[A-Za-z0-9+/_-]+={0,2}$/.test(value) || value.length % 4 === 1 || /=/.test(value.slice(0, -2))) invalid();
161
- const unpadded = value.replace(/-/g, "+").replace(/_/g, "/").replace(/=+$/, "");
162
- const padded = unpadded.padEnd(Math.ceil(unpadded.length / 4) * 4, "=");
163
- let decoded = "";
164
- try {
165
- decoded = atob(padded);
166
- } catch {
167
- invalid();
168
- }
169
- if (decoded.length < 16) invalid();
170
- return value;
171
- }
172
- //#endregion
173
- export { booleanAttributeValue as a, normalizeStylePropertyName as c, sanitizeCssValue as i, getPublicAttributeName as l, cspNonce as n, isAriaAttribute as o, validateCspNonce as r, isSkippedProp as s, CspNonceScope as t };
@@ -1,149 +0,0 @@
1
- import { d as getCurrentAppRenderRuntime, w as drainOwnedCleanup } from "./scope-Cq_iYbTR.js";
2
- import { a as ownComponentCleanup, r as getComponentLifetimeIdentity } from "./capabilities-Bbf0mlp9.js";
3
- import { n as getActiveRenderContext } from "./render-context-B7ohlh6t.js";
4
- //#region src/data/invalidation-listeners.ts
5
- const invalidationListeners = /* @__PURE__ */ new Set();
6
- const activeInvalidationPrefixes = [];
7
- const MAX_INVALIDATION_CASCADE_DEPTH = 100;
8
- function addInvalidationListener(listener) {
9
- invalidationListeners.add(listener);
10
- return () => {
11
- invalidationListeners.delete(listener);
12
- };
13
- }
14
- function emitInvalidation(event) {
15
- if (activeInvalidationPrefixes.includes(event.prefix)) throw new Error(`[Askr] Cyclic invalidation cascade detected for prefix ${JSON.stringify(event.prefix)}.`);
16
- if (activeInvalidationPrefixes.length >= MAX_INVALIDATION_CASCADE_DEPTH) throw new Error(`[Askr] Invalidation cascade exceeded ${MAX_INVALIDATION_CASCADE_DEPTH} nested events at prefix ${JSON.stringify(event.prefix)}.`);
17
- activeInvalidationPrefixes.push(event.prefix);
18
- try {
19
- for (const listener of invalidationListeners) listener(event);
20
- } finally {
21
- activeInvalidationPrefixes.pop();
22
- }
23
- }
24
- //#endregion
25
- //#region src/data/data-runtime.ts
26
- const dataRuntimeStates = /* @__PURE__ */ new WeakMap();
27
- const dataRuntimeByQueryCache = /* @__PURE__ */ new WeakMap();
28
- function createDataRuntimeState(queryCache, queryData, queryTestOverrides, mutationTestOverrides) {
29
- return {
30
- queryCache,
31
- queryData,
32
- querySlotsByGeneration: /* @__PURE__ */ new WeakMap(),
33
- mutationSlotsByGeneration: /* @__PURE__ */ new WeakMap(),
34
- queryCleanupRegistered: /* @__PURE__ */ new WeakSet(),
35
- mutationCleanupRegistered: /* @__PURE__ */ new WeakSet(),
36
- queryTestOverrides,
37
- mutationTestOverrides
38
- };
39
- }
40
- /** Create a new, isolated {@link DataRuntime} with its own query/mutation caches. */
41
- function createDataRuntime(options = {}) {
42
- const runtime = Object.freeze({
43
- queryCache: options.queryCache ?? /* @__PURE__ */ new Map(),
44
- queryData: options.queryData ?? /* @__PURE__ */ new Map(),
45
- queryTestOverrides: options.queryTestOverrides ?? /* @__PURE__ */ new Map(),
46
- mutationTestOverrides: options.mutationTestOverrides ?? /* @__PURE__ */ new Map()
47
- });
48
- dataRuntimeStates.set(runtime, createDataRuntimeState(runtime.queryCache, runtime.queryData, runtime.queryTestOverrides, runtime.mutationTestOverrides));
49
- dataRuntimeByQueryCache.set(runtime.queryCache, runtime);
50
- return runtime;
51
- }
52
- const defaultDataRuntime = createDataRuntime();
53
- /** Get the process-wide default {@link DataRuntime} used when none is provided explicitly. */
54
- function getDefaultDataRuntime() {
55
- return defaultDataRuntime;
56
- }
57
- function getDataRuntimeState(runtime) {
58
- const state = dataRuntimeStates.get(runtime);
59
- if (!state) throw new Error("[Askr] data runtime was not created by createDataRuntime().");
60
- return state;
61
- }
62
- function isDataRuntime(value) {
63
- return typeof value === "object" && value !== null && dataRuntimeStates.has(value);
64
- }
65
- function getDataRuntimeForQueryCache(queryCache) {
66
- let runtime = dataRuntimeByQueryCache.get(queryCache);
67
- if (!runtime) {
68
- runtime = createDataRuntime({ queryCache });
69
- dataRuntimeByQueryCache.set(queryCache, runtime);
70
- }
71
- return runtime;
72
- }
73
- function getActiveDataRuntime() {
74
- const ctx = getActiveRenderContext();
75
- if (isDataRuntime(ctx?.dataRuntime)) return ctx.dataRuntime;
76
- if (ctx?.queryCache) return getDataRuntimeForQueryCache(ctx.queryCache);
77
- const appRuntime = getCurrentAppRenderRuntime();
78
- if (appRuntime?.dataRuntime) return appRuntime.dataRuntime;
79
- return defaultDataRuntime;
80
- }
81
- function getActiveDataRuntimeState() {
82
- return getDataRuntimeState(getActiveDataRuntime());
83
- }
84
- function resolveDataRuntimeState(runtime) {
85
- return runtime ? getDataRuntimeState(runtime) : getActiveDataRuntimeState();
86
- }
87
- function getQuerySlotStore(runtimeState, instance) {
88
- const generation = getComponentLifetimeIdentity(instance);
89
- let store = runtimeState.querySlotsByGeneration.get(generation);
90
- if (!store) {
91
- store = /* @__PURE__ */ new Map();
92
- runtimeState.querySlotsByGeneration.set(generation, store);
93
- }
94
- return store;
95
- }
96
- function getMutationSlotStore(runtimeState, instance) {
97
- const generation = getComponentLifetimeIdentity(instance);
98
- let store = runtimeState.mutationSlotsByGeneration.get(generation);
99
- if (!store) {
100
- store = /* @__PURE__ */ new Map();
101
- runtimeState.mutationSlotsByGeneration.set(generation, store);
102
- }
103
- return store;
104
- }
105
- function ensureQueryCleanup(runtimeState, instance) {
106
- const generation = getComponentLifetimeIdentity(instance);
107
- if (runtimeState.queryCleanupRegistered.has(generation)) return;
108
- runtimeState.queryCleanupRegistered.add(generation);
109
- const slots = getQuerySlotStore(runtimeState, instance);
110
- ownComponentCleanup(instance, () => {
111
- try {
112
- drainOwnedCleanup(slots, ([hookIndex, slot]) => slot.cell.detach(generation, hookIndex));
113
- } finally {
114
- slots.clear();
115
- runtimeState.querySlotsByGeneration.delete(generation);
116
- runtimeState.queryCleanupRegistered.delete(generation);
117
- }
118
- });
119
- }
120
- function ensureMutationCleanup(runtimeState, instance) {
121
- const generation = getComponentLifetimeIdentity(instance);
122
- if (runtimeState.mutationCleanupRegistered.has(generation)) return;
123
- runtimeState.mutationCleanupRegistered.add(generation);
124
- const slots = getMutationSlotStore(runtimeState, instance);
125
- ownComponentCleanup(instance, () => {
126
- try {
127
- drainOwnedCleanup(slots.values(), (slot) => slot.cell.abort());
128
- } finally {
129
- slots.clear();
130
- runtimeState.mutationSlotsByGeneration.delete(generation);
131
- runtimeState.mutationCleanupRegistered.delete(generation);
132
- }
133
- });
134
- }
135
- function invalidateQueriesForRuntime(runtimeState, prefix, markPendingWrite) {
136
- emitInvalidation({
137
- prefix,
138
- markPendingWrite
139
- });
140
- for (const key of runtimeState.queryData.keys()) if (key.startsWith(prefix)) runtimeState.queryData.delete(key);
141
- const cache = runtimeState.queryCache;
142
- for (const [key, query] of cache) {
143
- if (!key.startsWith(prefix)) continue;
144
- if (markPendingWrite) query.markPendingWrite();
145
- query.invalidate();
146
- }
147
- }
148
- //#endregion
149
- export { getMutationSlotStore as a, resolveDataRuntimeState as c, getDefaultDataRuntime as i, addInvalidationListener as l, ensureMutationCleanup as n, getQuerySlotStore as o, ensureQueryCleanup as r, invalidateQueriesForRuntime as s, createDataRuntime as t };
@@ -1,20 +0,0 @@
1
- //#region src/common/default-portal-runtime.ts
2
- let defaultPortalRuntime = null;
3
- function InactiveDefaultPortalHost() {
4
- return null;
5
- }
6
- /** Register the optional portal capability when its public module is loaded. */
7
- function registerDefaultPortalRuntime(runtime) {
8
- defaultPortalRuntime = runtime;
9
- }
10
- function getDefaultPortalHost() {
11
- return defaultPortalRuntime?.host ?? InactiveDefaultPortalHost;
12
- }
13
- function clearRegisteredDefaultPortalForInstance(instance) {
14
- defaultPortalRuntime?.clearForInstance(instance);
15
- }
16
- function disposeRegisteredDefaultPortalScope(scope) {
17
- defaultPortalRuntime?.disposeScope(scope);
18
- }
19
- //#endregion
20
- export { registerDefaultPortalRuntime as i, disposeRegisteredDefaultPortalScope as n, getDefaultPortalHost as r, clearRegisteredDefaultPortalForInstance as t };
@@ -1,77 +0,0 @@
1
- import type {
2
- RuntimeRendererHost,
3
- RuntimeKeyedReorderDecision,
4
- } from './core.js';
5
-
6
- declare const ownerBrand: unique symbol;
7
- declare const scopeBrand: unique symbol;
8
- declare const sourceBrand: unique symbol;
9
- /** Opaque component identity scoped to one DOM renderer factory. */
10
- export interface DOMComponentOwner {
11
- readonly [ownerBrand]: never;
12
- }
13
- /** Opaque child scope identity scoped to one DOM renderer factory. */
14
- export interface DOMChildScope {
15
- readonly [scopeBrand]: never;
16
- }
17
- /** Opaque reactive source identity scoped to one DOM renderer factory. */
18
- export interface DOMReactiveSource {
19
- readonly [sourceBrand]: never;
20
- }
21
- /** Read-only boundary of rendered DOM output. */
22
- export interface DOMRendererRange {
23
- readonly start: Node;
24
- readonly end: Node;
25
- readonly single: boolean;
26
- }
27
- /** DOM evaluation and replacement operations. */
28
- export interface DOMRendererEvaluation {
29
- evaluate(
30
- node: unknown,
31
- target: Element | null,
32
- context?: object,
33
- retainedOwner?: DOMComponentOwner
34
- ): void;
35
- replaceComponentRange(
36
- owner: DOMComponentOwner,
37
- result: unknown,
38
- host: Element | Comment
39
- ): Node | null;
40
- }
41
- /** DOM lifetime cleanup operations. */
42
- export interface DOMRendererCleanup {
43
- cleanupInstancesUnder(node: Node): void;
44
- teardownNodeSubtree(root: Node): void;
45
- }
46
- /** Child scope boundary inspection. */
47
- export interface DOMRendererScopes {
48
- resolveChildScopeRange(scope: DOMChildScope): DOMRendererRange | null;
49
- }
50
- /** Keyed DOM reconciliation operations. */
51
- export interface DOMRendererKeys {
52
- populateKeyMapForElement(parent: Element): void;
53
- getKeyMapForElement(
54
- parent: Element
55
- ): Map<string | number, Element> | undefined;
56
- isKeyedReorderFastPathEligible(
57
- parent: Element,
58
- children: unknown[],
59
- oldKeyMap: Map<string | number, Element> | undefined
60
- ): RuntimeKeyedReorderDecision;
61
- }
62
- /** Reactive DOM invalidation operations. */
63
- export interface DOMRendererReactivity {
64
- markReactivePropsDirtySource(source: DOMReactiveSource): void;
65
- }
66
- /** Complete DOM extension roles. Delegate explicitly to the supplied native host. */
67
- export interface DOMRendererHost {
68
- evaluation: DOMRendererEvaluation;
69
- cleanup: DOMRendererCleanup;
70
- scopes: DOMRendererScopes;
71
- keys: DOMRendererKeys;
72
- reactivity: DOMRendererReactivity;
73
- }
74
- /** Construct a validated DOM adapter without installing it in a runtime. */
75
- export declare function createDOMRendererHost(
76
- configure: (native: DOMRendererHost) => DOMRendererHost
77
- ): RuntimeRendererHost;