@askrjs/askr 0.2.4 → 0.3.1

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 (117) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/dist/access-CEA2pOry.js +1046 -0
  3. package/dist/actions/index.d.ts +16 -2
  4. package/dist/actions/index.js +5 -5
  5. package/dist/{activity-FirwPXA_.js → activity-oy2YFTFF.js} +10 -16
  6. package/dist/benchmark.js +8 -9
  7. package/dist/boot/index.d.ts +19 -9
  8. package/dist/boot/index.js +1 -1
  9. package/dist/{boot-tWyF6121.js → boot-DLplW9h4.js} +700 -441
  10. package/dist/capabilities-Bbf0mlp9.js +42 -0
  11. package/dist/components/index.d.ts +11 -8
  12. package/dist/components/index.js +1 -1
  13. package/dist/{compose-ref-Bfaf4kUC.js → compose-ref-v0qGlHoN.js} +7 -1
  14. package/dist/control/index.d.ts +20 -2
  15. package/dist/control/index.js +1 -1
  16. package/dist/{control-C-wSaq9V.js → control-BR_mrX__.js} +4 -4
  17. package/dist/core.d.ts +163 -0
  18. package/dist/csp-nonce-BfFWcd0w.js +173 -0
  19. package/dist/data/index.d.ts +74 -2
  20. package/dist/data/index.js +3 -3
  21. package/dist/{data-ghKopAbp.js → data-2edW0jhF.js} +108 -122
  22. package/dist/{data-runtime-7t_Y0iv3.js → data-runtime-CxoY98lX.js} +22 -15
  23. package/dist/{deferred-CxjWCkIn.js → deferred-CbgNhf67.js} +5 -5
  24. package/dist/dom-renderer.d.ts +77 -0
  25. package/dist/domains/actions.d.ts +70 -0
  26. package/dist/domains/component.d.ts +119 -0
  27. package/dist/domains/context.d.ts +73 -0
  28. package/dist/domains/control.d.ts +328 -0
  29. package/dist/domains/data.d.ts +461 -0
  30. package/dist/domains/diagnostics.d.ts +21 -0
  31. package/dist/domains/lifecycle.d.ts +112 -0
  32. package/dist/domains/refs.d.ts +18 -0
  33. package/dist/domains/renderer.d.ts +127 -0
  34. package/dist/domains/routing.d.ts +501 -0
  35. package/dist/domains/scheduler.d.ts +79 -0
  36. package/dist/domains/server.d.ts +112 -0
  37. package/dist/domains/state.d.ts +129 -0
  38. package/dist/domains/telemetry.d.ts +29 -0
  39. package/dist/eager-control.d.ts +8 -0
  40. package/dist/{effect-CNwstBBD.js → effect-C3Zsc1k6.js} +14 -41
  41. package/dist/{types-DWVrKn9N.d.ts → elements.d.ts} +79 -42
  42. package/dist/{for-internal-DyBHfKJA.js → for-state-BDykeOJL.js} +598 -494
  43. package/dist/foundations/icon/index.d.ts +67 -16
  44. package/dist/foundations/icon/index.js +1 -1
  45. package/dist/foundations/index.d.ts +26 -3
  46. package/dist/foundations/index.js +1 -1
  47. package/dist/foundations/interactions/index.d.ts +73 -34
  48. package/dist/foundations/interactions/index.js +1 -1
  49. package/dist/foundations/state/index.d.ts +12 -5
  50. package/dist/foundations/state/index.js +1 -1
  51. package/dist/foundations/structures/index.d.ts +44 -3
  52. package/dist/foundations/structures/index.js +1 -1
  53. package/dist/foundations/utilities/index.d.ts +34 -3
  54. package/dist/foundations/utilities/index.js +1 -1
  55. package/dist/fx/index.d.ts +72 -25
  56. package/dist/fx/index.js +8 -8
  57. package/dist/index.d.ts +121 -4
  58. package/dist/index.js +316 -47
  59. package/dist/{component-internal-C4hKKQBF.js → instance-VAFYVJOa.js} +495 -283
  60. package/dist/{interactions-D102JxBR.js → interactions-CTeACdT_.js} +1 -1
  61. package/dist/jsx-dev-runtime.d.ts +51 -11
  62. package/dist/jsx-globals.d.ts +2 -0
  63. package/dist/jsx-runtime-CPJXAOBF.js +43 -0
  64. package/dist/jsx-runtime.d.ts +17 -3
  65. package/dist/jsx-runtime.js +2 -42
  66. package/dist/jsx.d.ts +108 -0
  67. package/dist/{manifest-D6rfj_jC.js → manifest-D1P3UNWV.js} +4 -9
  68. package/dist/{navigate-ZZu1IV0B.js → navigate-prC5V8XV.js} +125 -472
  69. package/dist/{navigate-F4sHgWbw.d.ts → navigation.d.ts} +8 -8
  70. package/dist/{readable-Di1fzSwm.js → notify-DxxuDPeY.js} +96 -34
  71. package/dist/{query-registry-Bua3cDyb.js → query-registry-LrYpQsDJ.js} +1 -1
  72. package/dist/{compose-ref-DOJHoW5X.d.ts → refs.d.ts} +11 -7
  73. package/dist/{ssr-Doog-AfJ.js → render-resolved-BC0W7_5b.js} +165 -558
  74. package/dist/{renderer-Cl23O0hV.js → renderer-CT0HeY58.js} +6825 -5692
  75. package/dist/{resolution-ClD-K7Lz.js → resolution-3DskUkjG.js} +189 -180
  76. package/dist/{resource-operation-Vz1S5h2k.js → resource-18-sFRl9.js} +98 -58
  77. package/dist/resources/index.d.ts +64 -12
  78. package/dist/resources/index.js +214 -8
  79. package/dist/route-activity.d.ts +21 -0
  80. package/dist/{route-matching-Bo6UqG-5.js → route-matching-CUzZ31gT.js} +68 -82
  81. package/dist/router/index.d.ts +378 -79
  82. package/dist/router/index.js +9 -9
  83. package/dist/router-internal-7nuNEHfG.js +36 -0
  84. package/dist/scope-Cq_iYbTR.js +403 -0
  85. package/dist/{selector-CsKuomw0.js → selector-BSPVkjKP.js} +26 -27
  86. package/dist/{shared-CYBH3F8I.js → shared-kU8yvryp.js} +3 -6
  87. package/dist/{snapshot-source-BB42xgwb.js → snapshot-source-An4iKajG.js} +1 -1
  88. package/dist/ssg/index.d.ts +51 -15
  89. package/dist/ssg/index.js +269 -209
  90. package/dist/ssr/index.d.ts +121 -68
  91. package/dist/ssr/index.js +2 -1
  92. package/dist/ssr-CiNm6Vzl.js +393 -0
  93. package/dist/{ssr-DSHd_Q9K.js → ssr-EPjwJH5R.js} +5 -1
  94. package/dist/{state-BGJgYSyQ.js → state-BXJfudq1.js} +10 -15
  95. package/dist/{structures-DFyK5AdQ.js → structures-CjEzfj4h.js} +37 -57
  96. package/dist/{index-CTpMmzgN.d.ts → structures.d.ts} +57 -36
  97. package/dist/testing/index.d.ts +123 -24
  98. package/dist/testing/index.js +24 -61
  99. package/dist/timer-C7uqnJVt.js +85 -0
  100. package/dist/{index-B1gu0_m0.d.ts → utilities.d.ts} +24 -13
  101. package/dist/{verify-hydration-BZPJ_kYa.js → verify-hydration-ikaxotf7.js} +8 -5
  102. package/package.json +12 -14
  103. package/dist/access-BucjYZcX.js +0 -509
  104. package/dist/activity-DooIuxQO.d.ts +0 -14
  105. package/dist/benchmark.d.ts +0 -26
  106. package/dist/cleanup-TXSsApEl.js +0 -535
  107. package/dist/component-cleanup-jdbgjkT1.js +0 -143
  108. package/dist/component-scope-4I3yEMkb.js +0 -195
  109. package/dist/control-Cxag1yqV.d.ts +0 -8
  110. package/dist/csp-nonce-9NFUb7hJ.js +0 -72
  111. package/dist/css-BuPaTOfe.js +0 -70
  112. package/dist/fastlane-BKZduiBQ.js +0 -166
  113. package/dist/index-Dgjbo2gU.d.ts +0 -1456
  114. package/dist/jsx-runtime-Cg7GqY1S.d.ts +0 -2
  115. package/dist/jsx-runtime-gVIaTPw0.d.ts +0 -38
  116. package/dist/lifecycle-batch-63aXFf2S.js +0 -253
  117. package/dist/lifecycle-operations-Q0k3EFnG.js +0 -287
@@ -1,195 +0,0 @@
1
- //#region src/runtime/component-scope.ts
2
- let currentInstance = null;
3
- let currentPortalScope = null;
4
- let scopedAppRenderRuntime;
5
- let stateIndex = 0;
6
- let globalRenderCounter = 0;
7
- let renderScopedDepth = 0;
8
- let outerRenderScopedInstance = null;
9
- let outerRenderScopedPortalScope = null;
10
- let outerRenderScopedStateIndex = 0;
11
- function ensureAbortController(instance) {
12
- let controller = instance.abortController;
13
- if (!controller || controller.signal.aborted) {
14
- controller = new AbortController();
15
- instance.abortController = controller;
16
- }
17
- return controller;
18
- }
19
- function nextRenderToken() {
20
- return ++globalRenderCounter;
21
- }
22
- function captureScope() {
23
- return {
24
- instance: currentInstance,
25
- portalScope: currentPortalScope,
26
- stateIndex
27
- };
28
- }
29
- function restoreScope(snapshot) {
30
- currentInstance = snapshot.instance;
31
- currentPortalScope = snapshot.portalScope;
32
- stateIndex = snapshot.stateIndex;
33
- }
34
- function captureInstancePortalScope() {
35
- return {
36
- instance: currentInstance,
37
- portalScope: currentPortalScope
38
- };
39
- }
40
- function getCurrentComponentInstance() {
41
- return currentInstance;
42
- }
43
- function getCurrentInstance() {
44
- return currentInstance;
45
- }
46
- function getCurrentAppRenderRuntime() {
47
- let instance = currentInstance;
48
- while (instance) {
49
- if (instance._appRenderRuntime) return instance._appRenderRuntime;
50
- instance = instance.parentInstance;
51
- }
52
- return scopedAppRenderRuntime;
53
- }
54
- /** @internal Preserve root ownership without exposing component hook scope. */
55
- function withAppRenderRuntime(runtime, fn) {
56
- const previous = scopedAppRenderRuntime;
57
- scopedAppRenderRuntime = runtime;
58
- try {
59
- return fn();
60
- } finally {
61
- scopedAppRenderRuntime = previous;
62
- }
63
- }
64
- function setCurrentComponentInstance(instance) {
65
- currentInstance = instance;
66
- currentPortalScope = instance?.portalScope ?? null;
67
- }
68
- function getCurrentPortalScope() {
69
- return currentInstance?.portalScope ?? currentPortalScope;
70
- }
71
- function getSignalForInstance(instance) {
72
- return ensureAbortController(instance).signal;
73
- }
74
- /**
75
- * Get the abort signal for the current component.
76
- *
77
- * The signal is guaranteed to be aborted when:
78
- * - Component unmounts
79
- * - Navigation occurs (different route)
80
- * - Parent is destroyed
81
- */
82
- function getSignal() {
83
- if (!currentInstance) throw new Error("getSignal() can only be called during component render execution. Ensure you are calling this from inside your component function.");
84
- return getSignalForInstance(currentInstance);
85
- }
86
- function resetRenderState(instance) {
87
- instance.stateIndexCheck = -1;
88
- for (const state of instance.stateValues ?? []) if (state) state._hasBeenRead = false;
89
- instance._pendingReadSources = void 0;
90
- instance._pendingReadSourceVersions = void 0;
91
- }
92
- function beginRenderTracking(instance) {
93
- instance._currentRenderToken = nextRenderToken();
94
- instance._pendingReadSources = void 0;
95
- instance._pendingReadSourceVersions = void 0;
96
- }
97
- function clearRenderTracking(instance) {
98
- instance._pendingReadSources = void 0;
99
- instance._pendingReadSourceVersions = void 0;
100
- instance._currentRenderToken = void 0;
101
- }
102
- function captureInlineRenderTracking(instance) {
103
- return {
104
- currentRenderToken: instance._currentRenderToken,
105
- pendingReadSources: instance._pendingReadSources,
106
- pendingReadSourceVersions: instance._pendingReadSourceVersions
107
- };
108
- }
109
- function restoreInlineRenderTracking(instance, snapshot) {
110
- instance._currentRenderToken = snapshot.currentRenderToken;
111
- instance._pendingReadSources = snapshot.pendingReadSources;
112
- instance._pendingReadSourceVersions = snapshot.pendingReadSourceVersions;
113
- }
114
- function enterRenderScopedComponent(instance, startStateIndex) {
115
- let savedScope = null;
116
- if (renderScopedDepth === 0) {
117
- outerRenderScopedInstance = currentInstance;
118
- outerRenderScopedPortalScope = currentPortalScope;
119
- outerRenderScopedStateIndex = stateIndex;
120
- } else savedScope = captureScope();
121
- renderScopedDepth += 1;
122
- currentInstance = instance;
123
- currentPortalScope = instance.portalScope ?? (savedScope ? savedScope.portalScope : outerRenderScopedPortalScope);
124
- stateIndex = startStateIndex;
125
- return savedScope;
126
- }
127
- function restoreRenderScopedComponent(snapshot) {
128
- renderScopedDepth -= 1;
129
- if (snapshot) {
130
- restoreScope(snapshot);
131
- return;
132
- }
133
- currentInstance = outerRenderScopedInstance;
134
- currentPortalScope = outerRenderScopedPortalScope;
135
- stateIndex = outerRenderScopedStateIndex;
136
- outerRenderScopedInstance = null;
137
- outerRenderScopedPortalScope = null;
138
- outerRenderScopedStateIndex = 0;
139
- }
140
- function captureInlineComponentScope() {
141
- return captureInstancePortalScope();
142
- }
143
- function restoreInlineComponentScope(snapshot) {
144
- currentInstance = snapshot.instance;
145
- currentPortalScope = snapshot.portalScope;
146
- }
147
- function enterComponentExecutionScope(instance) {
148
- const savedPortalScope = currentPortalScope;
149
- currentInstance = instance;
150
- currentPortalScope = instance.portalScope ?? savedPortalScope;
151
- stateIndex = 0;
152
- return savedPortalScope;
153
- }
154
- function exitComponentExecutionScope(savedPortalScope) {
155
- currentInstance = null;
156
- currentPortalScope = savedPortalScope;
157
- }
158
- function enterDomCommitScope(instance) {
159
- const previousInstance = currentInstance;
160
- currentInstance = instance;
161
- return previousInstance;
162
- }
163
- function restoreDomCommitScope(previousInstance) {
164
- currentInstance = previousInstance;
165
- }
166
- function clearCurrentComponentScope() {
167
- const savedScope = captureScope();
168
- currentInstance = null;
169
- currentPortalScope = null;
170
- return savedScope;
171
- }
172
- function restoreCurrentComponentScope(snapshot) {
173
- restoreScope(snapshot);
174
- }
175
- function getNextStateIndex() {
176
- return stateIndex++;
177
- }
178
- function hookOrderGuidance(hookName) {
179
- return `The render-scoped hook sequence changed between renders. This can happen when ${hookName}() is called conditionally, or when a conditional subtree skips an outer control boundary through a plain if, ternary, && branch, or loop. Keep render-scoped hooks and their outer control boundaries unconditional. Use <Show> or <Case> with <Match> children for conditional branches, and <For> for changing collections.`;
180
- }
181
- function claimHookIndex(instance, hookName) {
182
- const index = getNextStateIndex();
183
- if (index < instance.stateIndexCheck) throw new Error(`Hook index violation: ${hookName}() call at index ${index}, but previously saw index ${instance.stateIndexCheck}. ` + hookOrderGuidance(hookName));
184
- instance.stateIndexCheck = index;
185
- const expectedStateIndices = instance.expectedStateIndices ??= [];
186
- if (instance.firstRenderComplete) {
187
- if (expectedStateIndices[index] !== index) throw new Error(`Hook order violation: ${hookName}() called at index ${index}, but this index was not in the first render's sequence [${expectedStateIndices.join(", ")}]. ` + hookOrderGuidance(hookName));
188
- } else expectedStateIndices.push(index);
189
- return index;
190
- }
191
- function getCurrentStateIndex() {
192
- return stateIndex;
193
- }
194
- //#endregion
195
- export { restoreRenderScopedComponent as C, restoreInlineRenderTracking as S, withAppRenderRuntime as T, getSignalForInstance as _, clearCurrentComponentScope as a, restoreDomCommitScope as b, enterDomCommitScope as c, getCurrentAppRenderRuntime as d, getCurrentComponentInstance as f, getSignal as g, getCurrentStateIndex as h, claimHookIndex as i, enterRenderScopedComponent as l, getCurrentPortalScope as m, captureInlineComponentScope as n, clearRenderTracking as o, getCurrentInstance as p, captureInlineRenderTracking as r, enterComponentExecutionScope as s, beginRenderTracking as t, exitComponentExecutionScope as u, resetRenderState as v, setCurrentComponentInstance as w, restoreInlineComponentScope as x, restoreCurrentComponentScope as y };
@@ -1,8 +0,0 @@
1
- import { s as Props } from "./types-DWVrKn9N.js";
2
- //#region src/common/control.d.ts
3
- declare const EAGER_CONTROL_PRIMITIVE: unique symbol;
4
- type EagerControlPrimitive<P extends Props = Props> = ((props: P) => unknown) & {
5
- [EAGER_CONTROL_PRIMITIVE]?: true;
6
- };
7
- //#endregion
8
- export { EagerControlPrimitive as t };
@@ -1,72 +0,0 @@
1
- import { b as readScope, m as defineScope } from "./component-internal-C4hKKQBF.js";
2
- //#region src/common/url.ts
3
- const SAFE_URL_SCHEMES = /* @__PURE__ */ new Set([
4
- "http",
5
- "https",
6
- "mailto",
7
- "sms",
8
- "tel"
9
- ]);
10
- const URL_SCHEME_RE = /^([a-z][a-z0-9+.-]*):/i;
11
- function isSafeHref(value) {
12
- const compact = value.trim().replace(/[\u0000-\u0020\u007f-\u009f]/g, "");
13
- const scheme = URL_SCHEME_RE.exec(compact)?.[1]?.toLowerCase();
14
- return scheme === void 0 || SAFE_URL_SCHEMES.has(scheme);
15
- }
16
- /**
17
- * Attribute names (lowercased) that can carry a browser-navigable/executable
18
- * URL and must be checked against isSafeHref. Shared between the client
19
- * renderer (renderer/attributes.ts) and SSR (ssr/attrs.ts) so their unsafe-
20
- * URL handling can't drift. Deliberately excludes `src`: it covers a much
21
- * wider range of legitimate non-navigable values (data: image URIs, blob:
22
- * URLs, etc.) where the same scheme allowlist would be overly aggressive.
23
- */
24
- const UNSAFE_URL_SCHEME_ATTRIBUTES = /* @__PURE__ */ new Set([
25
- "href",
26
- "formaction",
27
- "action",
28
- "xlink:href"
29
- ]);
30
- function isUnsafeUrlAttribute(key, value) {
31
- return UNSAFE_URL_SCHEME_ATTRIBUTES.has(key.toLowerCase()) && !isSafeHref(String(value));
32
- }
33
- //#endregion
34
- //#region src/common/router-internal.ts
35
- const ROUTE_ROOT_COMPONENT = Symbol.for("askr.route-root-component");
36
- //#endregion
37
- //#region src/csp-nonce.ts
38
- /** Lexical scope carrying the CSP nonce for the current render, if any. */
39
- const CspNonceScope = defineScope(void 0);
40
- /**
41
- * Read the CSP nonce for the current render from {@link CspNonceScope}.
42
- *
43
- * @returns The active nonce, or `undefined` when called outside of a
44
- * component render or when no nonce was configured.
45
- */
46
- function cspNonce() {
47
- try {
48
- return readScope(CspNonceScope);
49
- } catch (error) {
50
- if (error instanceof Error && error.message.startsWith("readScope() can only be called during component render")) return;
51
- throw error;
52
- }
53
- }
54
- function validateCspNonce(value) {
55
- if (value === void 0) return void 0;
56
- const invalid = () => {
57
- throw new TypeError("CSP nonce must be valid base64 or base64url encoding at least 16 bytes.");
58
- };
59
- if (value.length === 0 || !/^[A-Za-z0-9+/_-]+={0,2}$/.test(value) || value.length % 4 === 1 || /=/.test(value.slice(0, -2))) invalid();
60
- const unpadded = value.replace(/-/g, "+").replace(/_/g, "/").replace(/=+$/, "");
61
- const padded = unpadded.padEnd(Math.ceil(unpadded.length / 4) * 4, "=");
62
- let decoded = "";
63
- try {
64
- decoded = atob(padded);
65
- } catch {
66
- invalid();
67
- }
68
- if (decoded.length < 16) invalid();
69
- return value;
70
- }
71
- //#endregion
72
- export { isSafeHref as a, ROUTE_ROOT_COMPONENT as i, cspNonce as n, isUnsafeUrlAttribute as o, validateCspNonce as r, CspNonceScope as t };
@@ -1,70 +0,0 @@
1
- //#region src/common/attr-names.ts
2
- const PUBLIC_ATTRIBUTE_NAME_MAP = {
3
- className: "class",
4
- htmlFor: "for",
5
- strokeWidth: "stroke-width",
6
- strokeLinecap: "stroke-linecap",
7
- strokeLinejoin: "stroke-linejoin",
8
- fillRule: "fill-rule",
9
- clipRule: "clip-rule"
10
- };
11
- function getPublicAttributeName(propName) {
12
- return PUBLIC_ATTRIBUTE_NAME_MAP[propName] ?? propName;
13
- }
14
- //#endregion
15
- //#region src/common/css.ts
16
- const CSS_UNSAFE_RE = /[{}<>\\]/g;
17
- const CSS_URI_SCHEME_RE = /(?:^|[\s(,])([a-z][a-z0-9+.-]*):/i;
18
- const CSS_FUNCTION_NAME_RE = /([a-z-][a-z0-9-]*)\s*\(/gi;
19
- const CSS_ALLOWED_FUNCTIONS = /* @__PURE__ */ new Set([
20
- "var",
21
- "calc",
22
- "min",
23
- "max",
24
- "clamp",
25
- "rgb",
26
- "rgba",
27
- "hsl",
28
- "hsla",
29
- "lab",
30
- "lch",
31
- "oklab",
32
- "oklch",
33
- "color",
34
- "color-mix",
35
- "translate",
36
- "translatex",
37
- "translatey",
38
- "translatez",
39
- "scale",
40
- "scalex",
41
- "scaley",
42
- "scalez",
43
- "rotate",
44
- "rotatex",
45
- "rotatey",
46
- "rotatez",
47
- "skew",
48
- "skewx",
49
- "skewy",
50
- "matrix",
51
- "matrix3d",
52
- "linear-gradient",
53
- "radial-gradient",
54
- "conic-gradient",
55
- "repeating-linear-gradient",
56
- "repeating-radial-gradient",
57
- "repeating-conic-gradient",
58
- "cubic-bezier",
59
- "steps"
60
- ]);
61
- function sanitizeCssValue(value) {
62
- const str = String(value);
63
- if (CSS_URI_SCHEME_RE.test(str)) return "";
64
- if (str.includes("(")) {
65
- for (const match of str.matchAll(CSS_FUNCTION_NAME_RE)) if (!CSS_ALLOWED_FUNCTIONS.has(match[1].toLowerCase())) return "";
66
- }
67
- return str.replace(CSS_UNSAFE_RE, "");
68
- }
69
- //#endregion
70
- export { getPublicAttributeName as n, sanitizeCssValue as t };
@@ -1,166 +0,0 @@
1
- import { d as setRuntimeBulkCommitProbe, o as getRuntimeRenderer, u as runRuntimeWithSyncProgress, x as isDevelopmentEnvironment } from "./access-BucjYZcX.js";
2
- import { i as isFragmentType } from "./jsx-DRS-qjiN.js";
3
- import { i as finalizeReadableSubscriptions, l as notifyReadableReaders, o as markReactivePropsDirtySource, s as markReadableDerivedSubscribersDirty } from "./readable-Di1fzSwm.js";
4
- //#region src/runtime/dev-namespace.ts
5
- /**
6
- * Set a value in the dev namespace (no-op in production).
7
- */
8
- const setDevValue = () => {};
9
- /**
10
- * Increment a counter in the dev namespace (no-op in production).
11
- * Safely handles non-number values by resetting to 1.
12
- */
13
- const incDevCounter = () => {};
14
- //#endregion
15
- //#region src/runtime/fastlane.ts
16
- let _bulkCommitActive = false;
17
- let _bulkCommitDepth = 0;
18
- let _appliedParents = null;
19
- let _deferredReadableSources = null;
20
- function enterBulkCommit() {
21
- _bulkCommitDepth += 1;
22
- if (_bulkCommitDepth > 1) return;
23
- _bulkCommitActive = true;
24
- _appliedParents = /* @__PURE__ */ new WeakSet();
25
- _deferredReadableSources = /* @__PURE__ */ new Set();
26
- }
27
- function exitBulkCommit() {
28
- if (_bulkCommitDepth === 0) return;
29
- _bulkCommitDepth -= 1;
30
- if (_bulkCommitDepth > 0) return;
31
- _bulkCommitActive = false;
32
- const deferredReadableSources = _deferredReadableSources;
33
- _appliedParents = null;
34
- _deferredReadableSources = null;
35
- if (!deferredReadableSources) return;
36
- for (const source of deferredReadableSources) {
37
- markReadableDerivedSubscribersDirty(source);
38
- markReactivePropsDirtySource(source);
39
- notifyReadableReaders(source);
40
- }
41
- }
42
- function isBulkCommitActive() {
43
- return _bulkCommitActive;
44
- }
45
- function deferBulkCommitReadableNotification(source) {
46
- _deferredReadableSources?.add(source);
47
- }
48
- function markFastPathApplied(parent) {
49
- if (!_appliedParents) return;
50
- try {
51
- _appliedParents.add(parent);
52
- } catch (e) {}
53
- }
54
- function finalizeReadSubscriptions(instance) {
55
- finalizeReadableSubscriptions(instance);
56
- }
57
- /**
58
- * Attempt to execute a runtime fast-lane for a single component's synchronous
59
- * render result. Returns true if the fast-lane was used and commit was done.
60
- *
61
- * Preconditions (checked conservatively):
62
- * - The render result is an intrinsic element root with keyed children
63
- * - The renderer's fast-path heuristics indicate to use the fast-path
64
- * - No mount operations are pending on the component instance
65
- * - No child vnodes are component functions (avoid async/component mounts)
66
- */
67
- function unwrapFragmentForFastPath(vnode) {
68
- if (!vnode || typeof vnode !== "object" || !("type" in vnode)) return vnode;
69
- const v = vnode;
70
- if (isFragmentType(v.type)) {
71
- const children = v.props?.children ?? v.children;
72
- if (Array.isArray(children) && children.length > 0) {
73
- for (const child of children) if (child && typeof child === "object" && "type" in child) {
74
- if (typeof child.type === "string") return child;
75
- }
76
- }
77
- }
78
- return vnode;
79
- }
80
- function classifyUpdate(instance, result) {
81
- const unwrappedResult = unwrapFragmentForFastPath(result);
82
- if (!unwrappedResult || typeof unwrappedResult !== "object" || !("type" in unwrappedResult)) return {
83
- useFastPath: false,
84
- reason: "not-vnode"
85
- };
86
- const vnode = unwrappedResult;
87
- if (vnode == null || typeof vnode.type !== "string") return {
88
- useFastPath: false,
89
- reason: "not-intrinsic"
90
- };
91
- const parent = instance.target;
92
- if (!parent) return {
93
- useFastPath: false,
94
- reason: "no-root"
95
- };
96
- const firstChild = parent.children[0];
97
- if (!firstChild) return {
98
- useFastPath: false,
99
- reason: "no-first-child"
100
- };
101
- if (firstChild.tagName.toLowerCase() !== String(vnode.type).toLowerCase()) return {
102
- useFastPath: false,
103
- reason: "root-tag-mismatch"
104
- };
105
- const children = vnode.props?.children ?? vnode.children;
106
- if (!Array.isArray(children)) return {
107
- useFastPath: false,
108
- reason: "no-children-array"
109
- };
110
- for (const c of children) if (typeof c === "object" && c !== null && "type" in c && typeof c.type === "function") return {
111
- useFastPath: false,
112
- reason: "component-child-present"
113
- };
114
- if ((instance.mountOperations?.length ?? 0) > 0) return {
115
- useFastPath: false,
116
- reason: "pending-mounts"
117
- };
118
- if ((instance.commitOperations?.length ?? 0) > 0) return {
119
- useFastPath: false,
120
- reason: "pending-lifecycle-commits"
121
- };
122
- const renderer = getRuntimeRenderer();
123
- try {
124
- renderer.populateKeyMapForElement(firstChild);
125
- } catch {}
126
- const oldKeyMap = renderer.getKeyMapForElement(firstChild);
127
- const decision = renderer.isKeyedReorderFastPathEligible(firstChild, children, oldKeyMap);
128
- if (!decision.useFastPath || decision.totalKeyed < 128) return {
129
- ...decision,
130
- useFastPath: false,
131
- reason: "renderer-declined"
132
- };
133
- return {
134
- ...decision,
135
- useFastPath: true
136
- };
137
- }
138
- function commitReorderOnly(instance, result) {
139
- const renderer = getRuntimeRenderer();
140
- enterBulkCommit();
141
- try {
142
- runRuntimeWithSyncProgress(() => {
143
- renderer.evaluate(result, instance.target);
144
- try {
145
- finalizeReadSubscriptions(instance);
146
- } catch (e) {
147
- if (isDevelopmentEnvironment()) throw e;
148
- }
149
- });
150
- return true;
151
- } finally {
152
- exitBulkCommit();
153
- }
154
- }
155
- function tryRuntimeFastLaneSync(instance, result) {
156
- if (!classifyUpdate(instance, result).useFastPath) return false;
157
- try {
158
- return commitReorderOnly(instance, result);
159
- } catch (err) {
160
- if (isDevelopmentEnvironment()) throw err;
161
- return false;
162
- }
163
- }
164
- setRuntimeBulkCommitProbe(isBulkCommitActive);
165
- //#endregion
166
- export { incDevCounter as a, tryRuntimeFastLaneSync as i, isBulkCommitActive as n, setDevValue as o, markFastPathApplied as r, deferBulkCommitReadableNotification as t };