@qwik.dev/core 2.0.0-alpha.3 → 2.0.0-alpha.5

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.
@@ -1,19 +1,18 @@
1
1
  /**
2
2
  * @license
3
- * @qwik.dev/core 2.0.0-alpha.3-dev+418fd6d
3
+ * @qwik.dev/core 2.0.0-alpha.5-dev+cb53bbd
4
4
  * Copyright QwikDev. All Rights Reserved.
5
5
  * Use of this source code is governed by an MIT-style license that can be
6
6
  * found in the LICENSE file at https://github.com/QwikDev/qwik/blob/main/LICENSE
7
7
  */
8
8
  !function(global, factory) {
9
- "object" == typeof exports && "undefined" != typeof module ? factory(exports, require("@qwik.dev/core/build"), require("@qwik.dev/core")) : "function" == typeof define && define.amd ? define([ "exports", "@qwik.dev/core/build", "@qwik.dev/core" ], factory) : factory((global = "undefined" != typeof globalThis ? globalThis : global || self).qwikCore = {}, global.qwikBuild);
9
+ "object" == typeof exports && "undefined" != typeof module ? factory(exports, require("@qwik.dev/core/build")) : "function" == typeof define && define.amd ? define([ "exports", "@qwik.dev/core/build" ], factory) : factory((global = "undefined" != typeof globalThis ? globalThis : global || self).qwikCore = {}, global.qwikBuild);
10
10
  }(this, (function(exports, build) {
11
11
  "use strict";
12
12
  const qDev = !1;
13
13
  const seal = () => {
14
14
  qDev;
15
15
  };
16
- const logError = (message, ...optionalParams) => createAndLogError(!1, message, ...optionalParams);
17
16
  const throwErrorAndStop = (message, ...optionalParams) => {
18
17
  throw createAndLogError(!1, message, ...optionalParams);
19
18
  };
@@ -39,9 +38,40 @@
39
38
  function assertFalse() {
40
39
  qDev;
41
40
  }
42
- const qError = (code, ...parts) => {
43
- const text = (code => `Code(${code}) https://github.com/QwikDev/qwik/blob/main/packages/qwik/src/core/error/error.ts#L${8 + code}`)(code, ...parts);
44
- return ((message, ...optionalParams) => createAndLogError(!0, message, ...optionalParams))(text, ...parts);
41
+ var QError;
42
+ !function(QError) {
43
+ QError[QError.stringifyClassOrStyle = 0] = "stringifyClassOrStyle", QError[QError.UNUSED_1 = 1] = "UNUSED_1",
44
+ QError[QError.UNUSED_2 = 2] = "UNUSED_2", QError[QError.verifySerializable = 3] = "verifySerializable",
45
+ QError[QError.UNUSED_4 = 4] = "UNUSED_4", QError[QError.cannotRenderOverExistingContainer = 5] = "cannotRenderOverExistingContainer",
46
+ QError[QError.UNUSED_6 = 6] = "UNUSED_6", QError[QError.UNUSED_7 = 7] = "UNUSED_7",
47
+ QError[QError.UNUSED_8 = 8] = "UNUSED_8", QError[QError.UNUSED_9 = 9] = "UNUSED_9",
48
+ QError[QError.qrlIsNotFunction = 10] = "qrlIsNotFunction", QError[QError.dynamicImportFailed = 11] = "dynamicImportFailed",
49
+ QError[QError.unknownTypeArgument = 12] = "unknownTypeArgument", QError[QError.notFoundContext = 13] = "notFoundContext",
50
+ QError[QError.useMethodOutsideContext = 14] = "useMethodOutsideContext", QError[QError.UNUSED_15 = 15] = "UNUSED_15",
51
+ QError[QError.UNUSED_16 = 16] = "UNUSED_16", QError[QError.UNUSED_17 = 17] = "UNUSED_17",
52
+ QError[QError.UNUSED_18 = 18] = "UNUSED_18", QError[QError.UNUSED_19 = 19] = "UNUSED_19",
53
+ QError[QError.useInvokeContext = 20] = "useInvokeContext", QError[QError.UNUSED_21 = 21] = "UNUSED_21",
54
+ QError[QError.UNUSED_22 = 22] = "UNUSED_22", QError[QError.UNUSED_23 = 23] = "UNUSED_23",
55
+ QError[QError.UNUSED_24 = 24] = "UNUSED_24", QError[QError.UNUSED_25 = 25] = "UNUSED_25",
56
+ QError[QError.UNUSED_26 = 26] = "UNUSED_26", QError[QError.UNUSED_27 = 27] = "UNUSED_27",
57
+ QError[QError.invalidContext = 28] = "invalidContext", QError[QError.tagError = 29] = "tagError",
58
+ QError[QError.qrlMissingContainer = 30] = "qrlMissingContainer", QError[QError.qrlMissingChunk = 31] = "qrlMissingChunk",
59
+ QError[QError.invalidRefValue = 32] = "invalidRefValue", QError[QError.serializeErrorNotImplemented = 33] = "serializeErrorNotImplemented",
60
+ QError[QError.serializeErrorExpectedVNode = 34] = "serializeErrorExpectedVNode",
61
+ QError[QError.serializeErrorCannotAllocate = 35] = "serializeErrorCannotAllocate",
62
+ QError[QError.serializeErrorMissingRootId = 36] = "serializeErrorMissingRootId",
63
+ QError[QError.serializeErrorUnknownType = 37] = "serializeErrorUnknownType", QError[QError.serializeErrorUnvisited = 38] = "serializeErrorUnvisited",
64
+ QError[QError.serializeErrorMissingChunk = 39] = "serializeErrorMissingChunk", QError[QError.wrongTextareaValue = 40] = "wrongTextareaValue",
65
+ QError[QError.containerNotFound = 41] = "containerNotFound", QError[QError.elementWithoutContainer = 42] = "elementWithoutContainer",
66
+ QError[QError.invalidVNodeType = 43] = "invalidVNodeType", QError[QError.materializeVNodeDataError = 44] = "materializeVNodeDataError",
67
+ QError[QError.serverHostMismatch = 45] = "serverHostMismatch", QError[QError.cannotCoerceSignal = 46] = "cannotCoerceSignal",
68
+ QError[QError.computedNotSync = 47] = "computedNotSync", QError[QError.computedReadOnly = 48] = "computedReadOnly",
69
+ QError[QError.wrappedReadOnly = 49] = "wrappedReadOnly", QError[QError.promisesNotExpected = 50] = "promisesNotExpected",
70
+ QError[QError.unsafeAttr = 51] = "unsafeAttr";
71
+ }(QError || (QError = {}));
72
+ const qError = (code, errorMessageArgs = []) => {
73
+ const text = (code => `Code(Q${code}) https://github.com/QwikDev/qwik/blob/main/packages/qwik/src/core/error/error.ts#L${8 + code}`)(code, ...errorMessageArgs);
74
+ return ((message, ...optionalParams) => createAndLogError(!0, message, ...optionalParams))(text, ...errorMessageArgs);
45
75
  };
46
76
  const createPlatform = () => ({
47
77
  isServer: build.isServer,
@@ -54,10 +84,10 @@
54
84
  }
55
85
  }
56
86
  if (!url) {
57
- throw qError(31, symbolName);
87
+ throw qError(QError.qrlMissingChunk, [ symbolName ]);
58
88
  }
59
89
  if (!containerEl) {
60
- throw qError(30, url, symbolName);
90
+ throw qError(QError.qrlMissingContainer, [ url, symbolName ]);
61
91
  }
62
92
  const urlDoc = toUrl(containerEl.ownerDocument, containerEl, url).toString();
63
93
  const urlCopy = new URL(urlDoc);
@@ -97,7 +127,7 @@
97
127
  };
98
128
  const maybeThen = (valueOrPromise, thenFn) => isPromise(valueOrPromise) ? valueOrPromise.then(thenFn, shouldNotError) : thenFn(valueOrPromise);
99
129
  const shouldNotError = reason => {
100
- throwErrorAndStop("QWIK ERROR:", reason);
130
+ throwErrorAndStop(reason);
101
131
  };
102
132
  const delay = timeout => new Promise((resolve => {
103
133
  setTimeout(resolve, timeout);
@@ -120,6 +150,92 @@
120
150
  const isArray = v => Array.isArray(v);
121
151
  const isString = v => "string" == typeof v;
122
152
  const isFunction = v => "function" == typeof v;
153
+ var VNodeDataFlag;
154
+ !function(VNodeDataFlag) {
155
+ VNodeDataFlag[VNodeDataFlag.NONE = 0] = "NONE", VNodeDataFlag[VNodeDataFlag.TEXT_DATA = 1] = "TEXT_DATA",
156
+ VNodeDataFlag[VNodeDataFlag.VIRTUAL_NODE = 2] = "VIRTUAL_NODE", VNodeDataFlag[VNodeDataFlag.ELEMENT_NODE = 4] = "ELEMENT_NODE",
157
+ VNodeDataFlag[VNodeDataFlag.REFERENCE = 8] = "REFERENCE", VNodeDataFlag[VNodeDataFlag.SERIALIZE = 16] = "SERIALIZE";
158
+ }(VNodeDataFlag || (VNodeDataFlag = {}));
159
+ var VirtualType;
160
+ !function(VirtualType) {
161
+ VirtualType.Virtual = "V", VirtualType.Fragment = "F", VirtualType.WrappedSignal = "S",
162
+ VirtualType.Awaited = "A", VirtualType.Component = "C", VirtualType.InlineComponent = "I",
163
+ VirtualType.Projection = "P";
164
+ }(VirtualType || (VirtualType = {}));
165
+ const VirtualTypeName = {
166
+ [VirtualType.Virtual]: "Virtual",
167
+ [VirtualType.Fragment]: "Fragment",
168
+ [VirtualType.WrappedSignal]: "Signal",
169
+ [VirtualType.Awaited]: "Awaited",
170
+ [VirtualType.Component]: "Component",
171
+ [VirtualType.InlineComponent]: "InlineComponent",
172
+ [VirtualType.Projection]: "Projection"
173
+ };
174
+ var QContainerValue;
175
+ !function(QContainerValue) {
176
+ QContainerValue.PAUSED = "paused", QContainerValue.RESUMED = "resumed", QContainerValue.HTML = "html",
177
+ QContainerValue.TEXT = "text";
178
+ }(QContainerValue || (QContainerValue = {}));
179
+ const QSlot = "q:slot";
180
+ const QSlotS = "q:s";
181
+ const getQFuncs = (document, hash) => document["qFuncs_" + hash] || [];
182
+ const QContainerSelector = "[q\\:container]:not([q\\:container=" + QContainerValue.HTML + "]):not([q\\:container=" + QContainerValue.TEXT + "])";
183
+ const HTML_NS = "http://www.w3.org/1999/xhtml";
184
+ const SVG_NS = "http://www.w3.org/2000/svg";
185
+ const MATH_NS = "http://www.w3.org/1998/Math/MathML";
186
+ let _locale;
187
+ const EMPTY_ARRAY = [];
188
+ const EMPTY_OBJ = {};
189
+ Object.freeze(EMPTY_ARRAY), Object.freeze(EMPTY_OBJ);
190
+ const EXTRACT_IMPORT_PATH = /\(\s*(['"])([^\1]+)\1\s*\)/;
191
+ const EXTRACT_SELF_IMPORT = /Promise\s*\.\s*resolve/;
192
+ const EXTRACT_FILE_NAME = /[\\/(]([\w\d.\-_]+\.(js|ts)x?):/;
193
+ const announcedQRL = /*#__PURE__*/ new Set;
194
+ const qrl = (chunkOrFn, symbol, lexicalScopeCapture = EMPTY_ARRAY, stackOffset = 0) => {
195
+ let chunk = null;
196
+ let symbolFn = null;
197
+ if (isFunction(chunkOrFn)) {
198
+ symbolFn = chunkOrFn;
199
+ {
200
+ let match;
201
+ const srcCode = String(chunkOrFn);
202
+ if ((match = srcCode.match(EXTRACT_IMPORT_PATH)) && match[2]) {
203
+ chunk = match[2];
204
+ } else {
205
+ if (!(match = srcCode.match(EXTRACT_SELF_IMPORT))) {
206
+ throw qError(QError.dynamicImportFailed, [ srcCode ]);
207
+ }
208
+ {
209
+ const ref = "QWIK-SELF";
210
+ const frames = new Error(ref).stack.split("\n");
211
+ const start = frames.findIndex((f => f.includes(ref)));
212
+ match = frames[start + 2 + stackOffset].match(EXTRACT_FILE_NAME), chunk = match ? match[1] : "main";
213
+ }
214
+ }
215
+ }
216
+ } else {
217
+ if (!isString(chunkOrFn)) {
218
+ throw qError(QError.unknownTypeArgument, [ chunkOrFn ]);
219
+ }
220
+ chunk = chunkOrFn;
221
+ }
222
+ return announcedQRL.has(symbol) || (announcedQRL.add(symbol), emitEvent("qprefetch", {
223
+ symbols: [ getSymbolHash(symbol) ],
224
+ bundles: chunk && [ chunk ]
225
+ })), createQRL(chunk, symbol, null, symbolFn, null, lexicalScopeCapture, null);
226
+ };
227
+ const inlinedQrl = (symbol, symbolName, lexicalScopeCapture = EMPTY_ARRAY) => createQRL(null, symbolName, symbol, null, null, lexicalScopeCapture, null);
228
+ const _noopQrl = (symbolName, lexicalScopeCapture = EMPTY_ARRAY) => createQRL(null, symbolName, null, null, null, lexicalScopeCapture, null);
229
+ const Slot = props => _jsxSorted(Virtual, null, {
230
+ [QSlotS]: ""
231
+ }, props.children, 0, props.name ?? "");
232
+ const SkipRender = Symbol("skip render");
233
+ const SSRRaw = () => null;
234
+ const SSRComment = () => null;
235
+ const SSRStream = (props, key) => jsx(RenderOnce, {
236
+ children: jsx(InternalSSRStream, props)
237
+ }, key);
238
+ const InternalSSRStream = () => null;
123
239
  const isJsxPropertyAnEventName = name => (name.startsWith("on") || name.startsWith("window:on") || name.startsWith("document:on")) && name.endsWith("$");
124
240
  const isHtmlAttributeAnEventName = name => name.startsWith("on:") || name.startsWith("on-window:") || name.startsWith("on-document:");
125
241
  const getEventNameFromJsxProp = name => {
@@ -164,26 +280,6 @@
164
280
  function isPreventDefault(key) {
165
281
  return key.startsWith("preventdefault:");
166
282
  }
167
- function hasClassAttr(props) {
168
- for (const key in props) {
169
- if (Object.prototype.hasOwnProperty.call(props, key) && isClassAttr(key)) {
170
- return !0;
171
- }
172
- }
173
- return !1;
174
- }
175
- function isClassAttr(key) {
176
- return "class" === key || "className" === key;
177
- }
178
- const addComponentStylePrefix = styleId => {
179
- if (styleId) {
180
- let idx = 0;
181
- do {
182
- styleId = styleId.substring(0, idx) + styleContent(styleId.substring(idx));
183
- } while (0 !== (idx = styleId.indexOf(" ", idx) + 1));
184
- }
185
- return styleId || null;
186
- };
187
283
  const unitlessNumbers = new Set([ "animationIterationCount", "aspectRatio", "borderImageOutset", "borderImageSlice", "borderImageWidth", "boxFlex", "boxFlexGroup", "boxOrdinalGroup", "columnCount", "columns", "flex", "flexGrow", "flexShrink", "gridArea", "gridRow", "gridRowEnd", "gridRowStart", "gridColumn", "gridColumnEnd", "gridColumnStart", "fontWeight", "lineClamp", "lineHeight", "opacity", "order", "orphans", "scale", "tabSize", "widows", "zIndex", "zoom", "MozAnimationIterationCount", "MozBoxFlex", "msFlex", "msFlexPositive", "WebkitAnimationIterationCount", "WebkitBoxFlex", "WebkitBoxOrdinalGroup", "WebkitColumnCount", "WebkitColumns", "WebkitFlex", "WebkitFlexGrow", "WebkitFlexShrink", "WebkitLineClamp" ]);
188
284
  const hashCode = (text, hash = 0) => {
189
285
  for (let i = 0; i < text.length; i++) {
@@ -191,33 +287,6 @@
191
287
  }
192
288
  return Number(Math.abs(hash)).toString(36);
193
289
  };
194
- var VirtualType;
195
- !function(VirtualType) {
196
- VirtualType.Virtual = "V", VirtualType.Fragment = "F", VirtualType.WrappedSignal = "S",
197
- VirtualType.Awaited = "A", VirtualType.Component = "C", VirtualType.InlineComponent = "I",
198
- VirtualType.Projection = "P";
199
- }(VirtualType || (VirtualType = {}));
200
- const VirtualTypeName = {
201
- [VirtualType.Virtual]: "Virtual",
202
- [VirtualType.Fragment]: "Fragment",
203
- [VirtualType.WrappedSignal]: "Signal",
204
- [VirtualType.Awaited]: "Awaited",
205
- [VirtualType.Component]: "Component",
206
- [VirtualType.InlineComponent]: "InlineComponent",
207
- [VirtualType.Projection]: "Projection"
208
- };
209
- var QContainerValue;
210
- !function(QContainerValue) {
211
- QContainerValue.PAUSED = "paused", QContainerValue.RESUMED = "resumed", QContainerValue.HTML = "html",
212
- QContainerValue.TEXT = "text";
213
- }(QContainerValue || (QContainerValue = {}));
214
- const QSlot = "q:slot";
215
- const QSlotS = "q:s";
216
- const getQFuncs = (document, hash) => document["qFuncs_" + hash] || [];
217
- const QContainerSelector = "[q\\:container]:not([q\\:container=" + QContainerValue.HTML + "]):not([q\\:container=" + QContainerValue.TEXT + "])";
218
- const HTML_NS = "http://www.w3.org/1999/xhtml";
219
- const SVG_NS = "http://www.w3.org/2000/svg";
220
- const MATH_NS = "http://www.w3.org/1998/Math/MathML";
221
290
  const serializeClass = obj => {
222
291
  if (!obj) {
223
292
  return "";
@@ -249,7 +318,7 @@
249
318
  }
250
319
  if ("object" == typeof obj) {
251
320
  if (isArray(obj)) {
252
- throw qError(0, obj, "style");
321
+ throw qError(QError.stringifyClassOrStyle, [ obj, "style" ]);
253
322
  }
254
323
  {
255
324
  const chunks = [];
@@ -272,678 +341,325 @@
272
341
  }
273
342
  const setValueForStyle = (styleName, value) => "number" != typeof value || 0 === value || unitlessNumbers.has(styleName) ? value : value + "px";
274
343
  const styleContent = styleId => "⭐️" + styleId;
275
- const EMPTY_ARRAY = [];
276
- const EMPTY_OBJ = {};
277
- Object.freeze(EMPTY_ARRAY), Object.freeze(EMPTY_OBJ);
278
- const EXTRACT_IMPORT_PATH = /\(\s*(['"])([^\1]+)\1\s*\)/;
279
- const EXTRACT_SELF_IMPORT = /Promise\s*\.\s*resolve/;
280
- const EXTRACT_FILE_NAME = /[\\/(]([\w\d.\-_]+\.(js|ts)x?):/;
281
- const announcedQRL = /*#__PURE__*/ new Set;
282
- const qrl = (chunkOrFn, symbol, lexicalScopeCapture = EMPTY_ARRAY, stackOffset = 0) => {
283
- let chunk = null;
284
- let symbolFn = null;
285
- if (isFunction(chunkOrFn)) {
286
- symbolFn = chunkOrFn;
287
- {
288
- let match;
289
- const srcCode = String(chunkOrFn);
290
- if ((match = srcCode.match(EXTRACT_IMPORT_PATH)) && match[2]) {
291
- chunk = match[2];
292
- } else {
293
- if (!(match = srcCode.match(EXTRACT_SELF_IMPORT))) {
294
- throw qError(11, srcCode);
295
- }
296
- {
297
- const ref = "QWIK-SELF";
298
- const frames = new Error(ref).stack.split("\n");
299
- const start = frames.findIndex((f => f.includes(ref)));
300
- match = frames[start + 2 + stackOffset].match(EXTRACT_FILE_NAME), chunk = match ? match[1] : "main";
301
- }
302
- }
303
- }
304
- } else {
305
- if (!isString(chunkOrFn)) {
306
- throw qError(12, chunkOrFn);
344
+ function hasClassAttr(props) {
345
+ for (const key in props) {
346
+ if (Object.prototype.hasOwnProperty.call(props, key) && isClassAttr(key)) {
347
+ return !0;
307
348
  }
308
- chunk = chunkOrFn;
309
- }
310
- return announcedQRL.has(symbol) || (announcedQRL.add(symbol), emitEvent("qprefetch", {
311
- symbols: [ getSymbolHash(symbol) ],
312
- bundles: chunk && [ chunk ]
313
- })), createQRL(chunk, symbol, null, symbolFn, null, lexicalScopeCapture, null);
314
- };
315
- const inlinedQrl = (symbol, symbolName, lexicalScopeCapture = EMPTY_ARRAY) => createQRL(null, symbolName, symbol, null, null, lexicalScopeCapture, null);
316
- const _noopQrl = (symbolName, lexicalScopeCapture = EMPTY_ARRAY) => createQRL(null, symbolName, null, null, null, lexicalScopeCapture, null);
317
- const Slot = props => _jsxSorted(Virtual, null, {
318
- [QSlotS]: ""
319
- }, props.children, 0, props.name ?? "");
320
- const SkipRender = Symbol("skip render");
321
- const SSRRaw = () => null;
322
- const SSRComment = () => null;
323
- const SSRStream = (props, key) => jsx(RenderOnce, {
324
- children: jsx(InternalSSRStream, props)
325
- }, key);
326
- const InternalSSRStream = () => null;
327
- let _locale;
328
- const useSequentialScope = () => {
329
- const iCtx = useInvokeContext();
330
- const host = iCtx.$hostElement$;
331
- let seq = iCtx.$container$.getHostProp(host, "q:seq");
332
- null === seq && (seq = [], iCtx.$container$.setHostProp(host, "q:seq", seq));
333
- let seqIdx = iCtx.$container$.getHostProp(host, "q:seqIdx");
334
- for (null === seqIdx && (seqIdx = 0), iCtx.$container$.setHostProp(host, "q:seqIdx", seqIdx + 1); seq.length <= seqIdx; ) {
335
- seq.push(void 0);
336
349
  }
337
- return {
338
- val: seq[seqIdx],
339
- set: value => seq[seqIdx] = value,
340
- i: seqIdx,
341
- iCtx
342
- };
343
- };
344
- const createContextId = name => (assertTrue(/^[\w/.-]+$/.test(name)), /*#__PURE__*/ Object.freeze({
345
- id: fromCamelToKebabCase(name)
346
- }));
347
- const useContextProvider = (context, newValue) => {
348
- const {val, set, iCtx} = useSequentialScope();
349
- void 0 === val && (iCtx.$container$.setContext(iCtx.$hostElement$, context, newValue),
350
- set(1));
351
- };
352
- const ERROR_CONTEXT = /*#__PURE__*/ createContextId("qk-error");
353
- function isSlotProp(prop) {
354
- return !prop.startsWith("q:") && !prop.startsWith(":");
355
- }
356
- class Subscriber {
357
- $effectDependencies$=null;
358
- }
359
- function isSubscriber(value) {
360
- return value instanceof Subscriber || value instanceof WrappedSignal;
350
+ return !1;
361
351
  }
362
- function clearVNodeEffectDependencies(value) {
363
- const effects = vnode_getProp(value, "q:subs", null);
364
- if (effects) {
365
- for (let i = effects.length - 1; i >= 0; i--) {
366
- clearEffects(effects[i], value) && effects.splice(i, 1);
367
- }
368
- }
352
+ function isClassAttr(key) {
353
+ return "class" === key || "className" === key;
369
354
  }
370
- function clearSubscriberEffectDependencies(value) {
371
- if (value.$effectDependencies$) {
372
- for (let i = value.$effectDependencies$.length - 1; i >= 0; i--) {
373
- clearEffects(value.$effectDependencies$[i], value) && value.$effectDependencies$.splice(i, 1);
374
- }
355
+ const addComponentStylePrefix = styleId => {
356
+ if (styleId) {
357
+ let idx = 0;
358
+ do {
359
+ styleId = styleId.substring(0, idx) + styleContent(styleId.substring(idx));
360
+ } while (0 !== (idx = styleId.indexOf(" ", idx) + 1));
375
361
  }
362
+ return styleId || null;
363
+ };
364
+ const STORE_TARGET = Symbol("store.target");
365
+ const STORE_HANDLER = Symbol("store.handler");
366
+ const STORE_ARRAY_PROP = Symbol("store.array");
367
+ var StoreFlags;
368
+ !function(StoreFlags) {
369
+ StoreFlags[StoreFlags.NONE = 0] = "NONE", StoreFlags[StoreFlags.RECURSIVE = 1] = "RECURSIVE",
370
+ StoreFlags[StoreFlags.IMMUTABLE = 2] = "IMMUTABLE";
371
+ }(StoreFlags || (StoreFlags = {}));
372
+ const getStoreHandler = value => value[STORE_HANDLER];
373
+ const getStoreTarget = value => value?.[STORE_TARGET] || null;
374
+ const unwrapStore = value => getStoreTarget(value) || value;
375
+ const isStore = value => STORE_TARGET in value;
376
+ function createStore(container, obj, flags) {
377
+ return new Proxy(obj, new StoreHandler(flags, container || null));
376
378
  }
377
- function clearEffects(subscriber, value) {
378
- if (!isSignal(subscriber)) {
379
- return !1;
380
- }
381
- const effectSubscriptions = subscriber.$effects$;
382
- if (!effectSubscriptions) {
383
- return !1;
384
- }
385
- let subscriptionRemoved = !1;
386
- for (let i = effectSubscriptions.length - 1; i >= 0; i--) {
387
- effectSubscriptions[i][EffectSubscriptionsProp.EFFECT] === value && (effectSubscriptions.splice(i, 1),
388
- subscriptionRemoved = !0);
389
- }
390
- return subscriptionRemoved;
391
- }
392
- const NEEDS_COMPUTATION = Symbol("invalid");
393
- const throwIfQRLNotResolved = qrl => {
394
- if (!qrl.resolved) {
395
- throw qrl.resolve();
379
+ const getOrCreateStore = (obj, flags, container) => {
380
+ if (isSerializableObject(obj) && container) {
381
+ let store = container.$storeProxyMap$.get(obj);
382
+ return store || (store = createStore(container, obj, flags), container.$storeProxyMap$.set(obj, store)),
383
+ store;
396
384
  }
385
+ return obj;
397
386
  };
398
- const isSignal = value => value instanceof Signal;
399
- class EffectData {
400
- data;
401
- constructor(data) {
402
- this.data = data;
403
- }
404
- }
405
- var EffectSubscriptionsProp;
406
- var EffectProperty;
407
- !function(EffectSubscriptionsProp) {
408
- EffectSubscriptionsProp[EffectSubscriptionsProp.EFFECT = 0] = "EFFECT", EffectSubscriptionsProp[EffectSubscriptionsProp.PROPERTY = 1] = "PROPERTY",
409
- EffectSubscriptionsProp[EffectSubscriptionsProp.FIRST_BACK_REF_OR_DATA = 2] = "FIRST_BACK_REF_OR_DATA";
410
- }(EffectSubscriptionsProp || (EffectSubscriptionsProp = {})), function(EffectProperty) {
411
- EffectProperty.COMPONENT = ":", EffectProperty.VNODE = ".";
412
- }(EffectProperty || (EffectProperty = {}));
413
- class Signal {
414
- $untrackedValue$;
387
+ class StoreHandler {
388
+ $flags$;
389
+ $container$;
415
390
  $effects$=null;
416
- $container$=null;
417
- constructor(container, value) {
418
- this.$container$ = container, this.$untrackedValue$ = value;
419
- }
420
- get untrackedValue() {
421
- return this.$untrackedValue$;
391
+ constructor($flags$, $container$) {
392
+ this.$flags$ = $flags$, this.$container$ = $container$;
422
393
  }
423
- set untrackedValue(value) {
424
- this.$untrackedValue$ = value;
394
+ toString() {
395
+ return "[Store]";
425
396
  }
426
- get value() {
397
+ get(target, prop) {
398
+ if ("symbol" == typeof prop) {
399
+ return prop === STORE_TARGET ? target : prop === STORE_HANDLER ? this : target[prop];
400
+ }
427
401
  const ctx = tryGetInvokeContext();
402
+ const value = target[prop];
428
403
  if (ctx) {
429
404
  if (null === this.$container$) {
430
405
  if (!ctx.$container$) {
431
- return this.untrackedValue;
406
+ return value;
432
407
  }
433
408
  this.$container$ = ctx.$container$;
434
409
  } else {
435
410
  assertTrue();
436
411
  }
437
412
  const effectSubscriber = ctx.$effectSubscriber$;
438
- if (effectSubscriber) {
439
- const effects = this.$effects$ ||= [];
440
- ensureContainsEffect(effects, effectSubscriber), ensureContains(effectSubscriber, this),
441
- isSubscriber(this) && ensureEffectContainsSubscriber(effectSubscriber[EffectSubscriptionsProp.EFFECT], this, this.$container$);
442
- }
413
+ effectSubscriber && addEffect(target, Array.isArray(target) ? STORE_ARRAY_PROP : prop, this, effectSubscriber);
443
414
  }
444
- return this.untrackedValue;
415
+ if ("toString" === prop && value === Object.prototype.toString) {
416
+ return this.toString;
417
+ }
418
+ return this.$flags$ & StoreFlags.RECURSIVE && "object" == typeof value && null !== value && !Object.isFrozen(value) && !isStore(value) && !Object.isFrozen(target) ? getOrCreateStore(value, this.$flags$, this.$container$) : value;
445
419
  }
446
- set value(value) {
447
- value !== this.$untrackedValue$ && (this.$untrackedValue$ = value, triggerEffects(this.$container$, this, this.$effects$));
420
+ set(target, prop, value) {
421
+ if ("symbol" == typeof prop) {
422
+ return target[prop] = value, !0;
423
+ }
424
+ const newValue = this.$flags$ & StoreFlags.RECURSIVE ? unwrapStore(value) : value;
425
+ if (prop in target) {
426
+ newValue !== target[prop] && setNewValueAndTriggerEffects(prop, newValue, target, this);
427
+ } else {
428
+ setNewValueAndTriggerEffects(prop, newValue, target, this);
429
+ }
430
+ return !0;
448
431
  }
449
- valueOf() {
450
- qDev;
432
+ deleteProperty(target, prop) {
433
+ return "string" == typeof prop && delete target[prop] && (triggerEffects(this.$container$, this, getEffects(target, prop, this.$effects$)),
434
+ !0);
451
435
  }
452
- toString() {
453
- return `[${this.constructor.name}${this.$invalid$ ? " INVALID" : ""} ${String(this.$untrackedValue$)}]` + (this.$effects$?.map((e => "\n -> " + pad(qwikDebugToString(e[0]), " "))).join("\n") || "");
436
+ has(target, prop) {
437
+ if (prop === STORE_TARGET) {
438
+ return !0;
439
+ }
440
+ if ("string" == typeof prop) {
441
+ const ctx = tryGetInvokeContext();
442
+ if (ctx) {
443
+ const effectSubscriber = ctx.$effectSubscriber$;
444
+ effectSubscriber && addEffect(target, Array.isArray(target) ? STORE_ARRAY_PROP : prop, this, effectSubscriber);
445
+ }
446
+ }
447
+ return Object.prototype.hasOwnProperty.call(target, prop);
454
448
  }
455
- toJSON() {
456
- return {
457
- value: this.$untrackedValue$
449
+ ownKeys(target) {
450
+ const ctx = tryGetInvokeContext();
451
+ const effectSubscriber = ctx?.$effectSubscriber$;
452
+ return effectSubscriber && addEffect(target, STORE_ARRAY_PROP, this, effectSubscriber),
453
+ Reflect.ownKeys(target);
454
+ }
455
+ getOwnPropertyDescriptor(target, prop) {
456
+ return Array.isArray(target) || "symbol" == typeof prop ? Object.getOwnPropertyDescriptor(target, prop) : {
457
+ enumerable: !0,
458
+ configurable: !0
458
459
  };
459
460
  }
460
461
  }
461
- const ensureContains = (array, value) => {
462
- -1 === array.indexOf(value) && array.push(value);
463
- };
464
- const ensureContainsEffect = (array, effectSubscriptions) => {
465
- for (let i = 0; i < array.length; i++) {
466
- const existingEffect = array[i];
467
- if (existingEffect[0] === effectSubscriptions[0] && existingEffect[1] === effectSubscriptions[1]) {
468
- return;
469
- }
462
+ function addEffect(target, prop, store, effectSubscriber) {
463
+ const effectsMap = store.$effects$ ||= {};
464
+ const effects = Object.prototype.hasOwnProperty.call(effectsMap, prop) && effectsMap[prop] || (effectsMap[prop] = []);
465
+ ensureContainsEffect(effects, effectSubscriber), ensureContains(effectSubscriber, target),
466
+ ensureEffectContainsSubscriber(effectSubscriber[EffectSubscriptionsProp.EFFECT], target, store.$container$);
467
+ }
468
+ function setNewValueAndTriggerEffects(prop, value, target, currentStore) {
469
+ target[prop] = value, triggerEffects(currentStore.$container$, currentStore, getEffects(target, prop, currentStore.$effects$));
470
+ }
471
+ function getEffects(target, prop, storeEffects) {
472
+ let effectsToTrigger = storeEffects ? Array.isArray(target) ? Object.values(storeEffects).flatMap((effects => effects)) : storeEffects[prop] : null;
473
+ const storeArrayValue = storeEffects?.[STORE_ARRAY_PROP];
474
+ return storeArrayValue && (effectsToTrigger ||= [], effectsToTrigger.push(...storeArrayValue)),
475
+ effectsToTrigger;
476
+ }
477
+ const useSequentialScope = () => {
478
+ const iCtx = useInvokeContext();
479
+ const host = iCtx.$hostElement$;
480
+ let seq = iCtx.$container$.getHostProp(host, "q:seq");
481
+ null === seq && (seq = [], iCtx.$container$.setHostProp(host, "q:seq", seq));
482
+ let seqIdx = iCtx.$container$.getHostProp(host, "q:seqIdx");
483
+ for (null === seqIdx && (seqIdx = 0), iCtx.$container$.setHostProp(host, "q:seqIdx", seqIdx + 1); seq.length <= seqIdx; ) {
484
+ seq.push(void 0);
470
485
  }
471
- array.push(effectSubscriptions);
486
+ return {
487
+ val: seq[seqIdx],
488
+ set: value => seq[seqIdx] = value,
489
+ i: seqIdx,
490
+ iCtx
491
+ };
472
492
  };
473
- const ensureEffectContainsSubscriber = (effect, subscriber, container) => {
474
- if (isSubscriber(effect)) {
475
- if (effect.$effectDependencies$ ||= [], subscriberExistInSubscribers(effect.$effectDependencies$, subscriber)) {
476
- return;
477
- }
478
- effect.$effectDependencies$.push(subscriber);
479
- } else if (vnode_isVNode(effect) && vnode_isVirtualVNode(effect)) {
480
- let subscribers = vnode_getProp(effect, "q:subs", container ? container.$getObjectById$ : null);
481
- if (subscribers ||= [], subscriberExistInSubscribers(subscribers, subscriber)) {
482
- return;
483
- }
484
- subscribers.push(subscriber), vnode_setProp(effect, "q:subs", subscribers);
485
- } else if (isSSRNode(effect)) {
486
- let subscribers = effect.getProp("q:subs");
487
- if (subscribers ||= [], subscriberExistInSubscribers(subscribers, subscriber)) {
488
- return;
493
+ class Subscriber {
494
+ $effectDependencies$=null;
495
+ }
496
+ function isSubscriber(value) {
497
+ return value instanceof Subscriber || value instanceof WrappedSignal;
498
+ }
499
+ function clearVNodeEffectDependencies(container, value) {
500
+ vnode_isElementVNode(value) && ensureMaterialized(value);
501
+ const effects = vnode_getProp(value, "q:subs", container.$getObjectById$);
502
+ if (effects) {
503
+ for (let i = effects.length - 1; i >= 0; i--) {
504
+ clearEffects(effects[i], value, effects, i, container);
489
505
  }
490
- subscribers.push(subscriber), effect.setProp("q:subs", subscribers);
506
+ 0 === effects.length && vnode_setProp(value, "q:subs", null);
491
507
  }
492
- };
493
- const isSSRNode = effect => "setProp" in effect && "getProp" in effect && "removeProp" in effect && "id" in effect;
494
- const subscriberExistInSubscribers = (subscribers, subscriber) => {
495
- for (let i = 0; i < subscribers.length; i++) {
496
- if (subscribers[i] === subscriber) {
497
- return !0;
508
+ }
509
+ function clearSubscriberEffectDependencies(container, value) {
510
+ if (value.$effectDependencies$) {
511
+ for (let i = value.$effectDependencies$.length - 1; i >= 0; i--) {
512
+ clearEffects(value.$effectDependencies$[i], value, value.$effectDependencies$, i, container);
498
513
  }
514
+ 0 === value.$effectDependencies$.length && (value.$effectDependencies$ = null);
499
515
  }
500
- return !1;
501
- };
502
- const triggerEffects = (container, signal, effects) => {
503
- if (effects) {
504
- const scheduleEffect = effectSubscriptions => {
505
- const effect = effectSubscriptions[EffectSubscriptionsProp.EFFECT];
506
- const property = effectSubscriptions[EffectSubscriptionsProp.PROPERTY];
507
- if (assertDefined(), isTask(effect)) {
508
- effect.$flags$ |= TaskFlags.DIRTY;
509
- let choreType = ChoreType.TASK;
510
- effect.$flags$ & TaskFlags.VISIBLE_TASK ? choreType = ChoreType.VISIBLE : effect.$flags$ & TaskFlags.RESOURCE && (choreType = ChoreType.RESOURCE),
511
- container.$scheduler$(choreType, effect);
512
- } else if (effect instanceof Signal) {
513
- effect instanceof ComputedSignal && (effect.$computeQrl$.resolved || container.$scheduler$(ChoreType.QRL_RESOLVE, null, effect.$computeQrl$));
514
- try {
515
- retryOnPromise((() => effect.$invalidate$()));
516
- } catch (e) {
517
- logError(e);
518
- }
519
- } else if (property === EffectProperty.COMPONENT) {
520
- const host = effect;
521
- const qrl = container.getHostProp(host, "q:renderFn");
522
- assertDefined();
523
- const props = container.getHostProp(host, "q:props");
524
- container.$scheduler$(ChoreType.COMPONENT, host, qrl, props);
525
- } else if (property === EffectProperty.VNODE) {
526
- container.$scheduler$(ChoreType.NODE_DIFF, effect, effect, signal);
527
- } else {
528
- let effectData = effectSubscriptions[EffectSubscriptionsProp.FIRST_BACK_REF_OR_DATA];
529
- if (effectData instanceof EffectData) {
530
- const payload = {
531
- ...effectData.data,
532
- $value$: signal
533
- };
534
- container.$scheduler$(ChoreType.NODE_PROP, effect, property, payload);
535
- }
536
- }
537
- };
538
- effects.forEach(scheduleEffect);
539
- }
540
- };
541
- class ComputedSignal extends Signal {
542
- $computeQrl$;
543
- $invalid$=!0;
544
- constructor(container, fn) {
545
- super(container, NEEDS_COMPUTATION), this.$computeQrl$ = fn;
546
- }
547
- $invalidate$() {
548
- this.$invalid$ = !0, this.$effects$?.length && this.$computeIfNeeded$() && triggerEffects(this.$container$, this, this.$effects$);
516
+ }
517
+ function clearEffects(subscriber, value, effectArray, indexToRemove, container) {
518
+ let subscriptionRemoved = !1;
519
+ const seenSet = new Set;
520
+ if (subscriber instanceof WrappedSignal) {
521
+ subscriptionRemoved = clearSignalEffects(subscriber, value, seenSet);
522
+ } else if (container.$storeProxyMap$.has(subscriber)) {
523
+ const store = container.$storeProxyMap$.get(subscriber);
524
+ subscriptionRemoved = clearStoreEffects(getStoreHandler(store), value);
525
+ }
526
+ subscriptionRemoved && effectArray.splice(indexToRemove, 1);
527
+ }
528
+ function clearSignalEffects(subscriber, value, seenSet) {
529
+ const effectSubscriptions = subscriber.$effects$;
530
+ let subscriptionRemoved = !1;
531
+ if (effectSubscriptions) {
532
+ for (let i = effectSubscriptions.length - 1; i >= 0; i--) {
533
+ effectSubscriptions[i][EffectSubscriptionsProp.EFFECT] === value && (effectSubscriptions.splice(i, 1),
534
+ subscriptionRemoved = !0);
535
+ }
549
536
  }
550
- force() {
551
- this.$invalid$ = !0, triggerEffects(this.$container$, this, this.$effects$);
537
+ if (subscriber instanceof WrappedSignal) {
538
+ const hostElement = subscriber.$hostElement$;
539
+ hostElement && hostElement === value && (subscriber.$hostElement$ = null);
540
+ const args = subscriber.$args$;
541
+ args && clearArgsEffects(args, subscriber, seenSet);
552
542
  }
553
- get untrackedValue() {
554
- return this.$computeIfNeeded$(), assertFalse(), this.$untrackedValue$;
543
+ return subscriptionRemoved;
544
+ }
545
+ function clearStoreEffects(storeHandler, value) {
546
+ const effectSubscriptions = storeHandler.$effects$;
547
+ if (!effectSubscriptions) {
548
+ return !1;
555
549
  }
556
- $computeIfNeeded$() {
557
- if (!this.$invalid$) {
558
- return !1;
559
- }
560
- const computeQrl = this.$computeQrl$;
561
- throwIfQRLNotResolved(computeQrl);
562
- const ctx = tryGetInvokeContext();
563
- const previousEffectSubscription = ctx?.$effectSubscriber$;
564
- ctx && (ctx.$effectSubscriber$ = [ this, EffectProperty.VNODE ]);
565
- try {
566
- const untrackedValue = computeQrl.getFn(ctx)();
567
- isPromise(untrackedValue) && throwErrorAndStop(`useComputedSignal$ QRL ${computeQrl.dev ? `${computeQrl.dev.file} ` : ""}${computeQrl.$hash$} returned a Promise`),
568
- this.$invalid$ = !1;
569
- const didChange = untrackedValue !== this.$untrackedValue$;
570
- return didChange && (this.$untrackedValue$ = untrackedValue), didChange;
571
- } finally {
572
- ctx && (ctx.$effectSubscriber$ = previousEffectSubscription);
550
+ let subscriptionRemoved = !1;
551
+ for (const key in effectSubscriptions) {
552
+ const effects = effectSubscriptions[key];
553
+ for (let i = effects.length - 1; i >= 0; i--) {
554
+ effects[i][EffectSubscriptionsProp.EFFECT] === value && (effects.splice(i, 1), subscriptionRemoved = !0);
573
555
  }
556
+ 0 === effects.length && delete effectSubscriptions[key];
574
557
  }
575
- get value() {
576
- return super.value;
577
- }
578
- set value(_) {
579
- throwErrorAndStop("ComputedSignal is read-only");
558
+ return subscriptionRemoved;
559
+ }
560
+ function clearArgsEffects(args, subscriber, seenSet) {
561
+ for (let i = args.length - 1; i >= 0; i--) {
562
+ clearArgEffect(args[i], subscriber, seenSet);
580
563
  }
581
564
  }
582
- class WrappedSignal extends Signal {
583
- $args$;
584
- $func$;
585
- $funcStr$;
586
- $invalid$=!0;
587
- $effectDependencies$=null;
588
- constructor(container, fn, args, fnStr) {
589
- super(container, NEEDS_COMPUTATION), this.$args$ = args, this.$func$ = fn, this.$funcStr$ = fnStr;
590
- }
591
- $invalidate$() {
592
- this.$invalid$ = !0, this.$effects$?.length && this.$computeIfNeeded$() && triggerEffects(this.$container$, this, this.$effects$);
593
- }
594
- force() {
595
- this.$invalid$ = !0, triggerEffects(this.$container$, this, this.$effects$);
596
- }
597
- get untrackedValue() {
598
- return this.$computeIfNeeded$(), assertFalse(), this.$untrackedValue$;
599
- }
600
- $computeIfNeeded$() {
601
- if (!this.$invalid$) {
602
- return !1;
565
+ function clearArgEffect(arg, subscriber, seenSet) {
566
+ if (!seenSet.has(arg)) {
567
+ if (seenSet.add(arg), isSignal(arg)) {
568
+ clearSignalEffects(arg, subscriber, seenSet);
569
+ } else if ("object" == typeof arg && null !== arg) {
570
+ if (isStore(arg)) {
571
+ clearStoreEffects(getStoreHandler(arg), subscriber);
572
+ } else {
573
+ for (const key in arg) {
574
+ clearArgEffect(arg[key], subscriber, seenSet);
575
+ }
576
+ }
577
+ } else {
578
+ Array.isArray(arg) && clearArgsEffects(arg, subscriber, seenSet);
603
579
  }
604
- const untrackedValue = trackSignal((() => this.$func$(...this.$args$)), this, EffectProperty.VNODE, this.$container$);
605
- const didChange = untrackedValue !== this.$untrackedValue$;
606
- return didChange && (this.$untrackedValue$ = untrackedValue), didChange;
607
- }
608
- get value() {
609
- return super.value;
610
- }
611
- set value(_) {
612
- throwErrorAndStop("WrappedSignal is read-only");
613
580
  }
614
581
  }
615
- const implicit$FirstArg = fn => function(first, ...rest) {
616
- return fn.call(null, dollar(first), ...rest);
617
- };
618
- const createSignal = value => new Signal(null, value);
619
- const createComputedQrl = qrl => (throwIfQRLNotResolved(qrl), new ComputedSignal(null, qrl));
620
- const createComputed$ = /*#__PURE__*/ implicit$FirstArg(createComputedQrl);
621
- const useLexicalScope = () => {
622
- const context = getInvokeContext();
623
- let qrl = context.$qrl$;
624
- if (qrl) {
625
- assertQrl(qrl), assertDefined();
626
- } else {
627
- const el = context.$element$;
628
- assertDefined();
629
- const containerElement = _getQContainerElement(el);
630
- assertDefined();
631
- qrl = getDomContainer(containerElement).parseQRL(decodeURIComponent(String(context.$url$)));
632
- }
633
- return qrl.$captureRef$;
634
- };
635
- const useOn = (event, eventQrl) => {
636
- _useOn(createEventName(event, void 0), eventQrl);
637
- };
638
- const useOnDocument = (event, eventQrl) => {
639
- _useOn(createEventName(event, "document"), eventQrl);
640
- };
641
- const createEventName = (event, eventType) => {
642
- const prefix = void 0 !== eventType ? eventType + ":" : "";
643
- const map = name => prefix + "on" + name.charAt(0).toUpperCase() + name.substring(1) + "$";
644
- return Array.isArray(event) ? event.map(map) : map(event);
645
- };
646
- const _useOn = (eventName, eventQrl) => {
647
- const {isAdded, addEvent} = useOnEventsSequentialScope();
648
- isAdded || eventQrl && (Array.isArray(eventName) ? eventName.forEach((event => addEvent(event, eventQrl))) : addEvent(eventName, eventQrl));
649
- };
650
- const useOnEventsSequentialScope = () => {
651
- const iCtx = useInvokeContext();
652
- const host = iCtx.$hostElement$;
653
- let onMap = iCtx.$container$.getHostProp(host, ":on");
654
- null === onMap && (onMap = {}, iCtx.$container$.setHostProp(host, ":on", onMap));
655
- let seqIdx = iCtx.$container$.getHostProp(host, ":onIdx");
656
- null === seqIdx && (seqIdx = 0), iCtx.$container$.setHostProp(host, ":onIdx", seqIdx + 1);
657
- let addedFlags = iCtx.$container$.getHostProp(host, ":onFlags");
658
- for (null === addedFlags && (addedFlags = [], iCtx.$container$.setHostProp(host, ":onFlags", addedFlags)); addedFlags.length <= seqIdx; ) {
659
- addedFlags.push(!1);
582
+ const useResourceQrl = (qrl, opts) => {
583
+ const {val, set, i, iCtx} = useSequentialScope();
584
+ if (null != val) {
585
+ return val;
660
586
  }
661
- return {
662
- isAdded: addedFlags[seqIdx],
663
- addEvent: (eventName, eventQrl) => {
664
- addedFlags[seqIdx] = !0;
665
- let events = onMap[eventName];
666
- events || (onMap[eventName] = events = []), events.push(eventQrl);
667
- }
668
- };
587
+ assertQrl(qrl);
588
+ const container = iCtx.$container$;
589
+ const resource = createResourceReturn(container, opts);
590
+ const task = new Task(TaskFlags.DIRTY | TaskFlags.RESOURCE, i, iCtx.$hostElement$, qrl, resource, null);
591
+ return runResource(task, container, iCtx.$hostElement$), set(resource), resource;
669
592
  };
670
- var TaskFlags;
671
- !function(TaskFlags) {
672
- TaskFlags[TaskFlags.VISIBLE_TASK = 1] = "VISIBLE_TASK", TaskFlags[TaskFlags.TASK = 2] = "TASK",
673
- TaskFlags[TaskFlags.RESOURCE = 4] = "RESOURCE", TaskFlags[TaskFlags.DIRTY = 8] = "DIRTY";
674
- }(TaskFlags || (TaskFlags = {}));
675
- const useTaskQrl = (qrl, opts) => {
676
- const {val, set, iCtx, i} = useSequentialScope();
677
- if (val) {
678
- return;
679
- }
680
- assertQrl(qrl), set(1);
681
- const host = iCtx.$hostElement$;
682
- const task = new Task(TaskFlags.DIRTY | TaskFlags.TASK, i, iCtx.$hostElement$, qrl, void 0, null);
683
- set(task);
684
- const result = runTask(task, iCtx.$container$, host);
685
- if (isPromise(result)) {
686
- throw result;
687
- }
688
- qrl.$resolveLazy$(iCtx.$element$), isServerPlatform() && useRunTask(task, opts?.eagerness);
593
+ const createResourceReturn = (container, opts, initialPromise) => {
594
+ const result = (opts => ({
595
+ __brand: "resource",
596
+ value: void 0,
597
+ loading: !isServerPlatform(),
598
+ _resolved: void 0,
599
+ _error: void 0,
600
+ _state: "pending",
601
+ _timeout: opts?.timeout ?? -1,
602
+ _cache: 0
603
+ }))(opts);
604
+ return result.value = initialPromise, createStore(container, result, StoreFlags.RECURSIVE);
689
605
  };
690
- const runTask = (task, container, host) => {
606
+ const isResourceReturn = obj => isObject(obj) && "resource" === (getStoreTarget(obj) || obj).__brand;
607
+ const runResource = (task, container, host) => {
691
608
  task.$flags$ &= ~TaskFlags.DIRTY, cleanupTask(task);
692
- const iCtx = newInvokeContext(container.$locale$, host, void 0, "qTask");
609
+ const iCtx = newInvokeContext(container.$locale$, host, void 0, "qResource");
693
610
  iCtx.$container$ = container;
694
- const taskFn = task.$qrl$.getFn(iCtx, (() => clearSubscriberEffectDependencies(task)));
695
- const handleError = reason => container.handleError(reason, host);
696
- let cleanupFns = null;
697
- const cleanup = fn => {
698
- "function" == typeof fn && (cleanupFns || (cleanupFns = [], task.$destroy$ = noSerialize((() => {
699
- task.$destroy$ = null, cleanupFns.forEach((fn => {
700
- try {
701
- fn();
702
- } catch (err) {
703
- handleError(err);
704
- }
705
- }));
706
- }))), cleanupFns.push(fn));
707
- };
708
- const taskApi = {
611
+ const taskFn = task.$qrl$.getFn(iCtx, (() => clearSubscriberEffectDependencies(container, task)));
612
+ const resource = task.$state$;
613
+ assertDefined();
614
+ const cleanups = [];
615
+ task.$destroy$ = noSerialize((() => {
616
+ cleanups.forEach((fn => {
617
+ try {
618
+ fn();
619
+ } catch (err) {
620
+ container.handleError(err, host);
621
+ }
622
+ })), done = !0;
623
+ }));
624
+ const resourceTarget = unwrapStore(resource);
625
+ const opts = {
709
626
  track: (obj, prop) => {
710
627
  const ctx = newInvokeContext();
711
628
  return ctx.$effectSubscriber$ = [ task, EffectProperty.COMPONENT ], ctx.$container$ = container,
712
629
  invoke(ctx, (() => isFunction(obj) ? obj() : prop ? obj[prop] : isSignal(obj) ? obj.value : obj));
713
630
  },
714
- cleanup
631
+ cleanup(fn) {
632
+ "function" == typeof fn && cleanups.push(fn);
633
+ },
634
+ cache(policy) {
635
+ let milliseconds = 0;
636
+ milliseconds = "immutable" === policy ? 1 / 0 : policy, resource._cache = milliseconds;
637
+ },
638
+ previous: resourceTarget._resolved
715
639
  };
716
- return safeCall((() => taskFn(taskApi)), cleanup, (err => isPromise(err) ? err.then((() => runTask(task, container, host))) : handleError(err)));
717
- };
718
- const cleanupTask = task => {
719
- const destroy = task.$destroy$;
720
- if (destroy) {
721
- task.$destroy$ = null;
722
- try {
723
- destroy();
724
- } catch (err) {
725
- logError(err);
640
+ let resolve;
641
+ let reject;
642
+ let done = !1;
643
+ const setState = (resolved, value) => !done && (done = !0, resolved ? (done = !0,
644
+ resource.loading = !1, resource._state = "resolved", resource._resolved = value,
645
+ resource._error = void 0, resolve(value)) : (done = !0, resource.loading = !1, resource._state = "rejected",
646
+ resource._error = value, reject(value)), !0);
647
+ cleanups.push((() => {
648
+ if (!0 === untrack((() => resource.loading))) {
649
+ const value = untrack((() => resource._resolved));
650
+ setState(!0, value);
726
651
  }
727
- }
728
- };
729
- const useRunTask = (task, eagerness) => {
730
- "visible" === eagerness || "intersection-observer" === eagerness ? useOn("qvisible", getTaskHandlerQrl(task)) : "load" === eagerness || "document-ready" === eagerness ? useOnDocument("qinit", getTaskHandlerQrl(task)) : "idle" !== eagerness && "document-idle" !== eagerness || useOnDocument("qidle", getTaskHandlerQrl(task));
731
- };
732
- const getTaskHandlerQrl = task => {
733
- const taskQrl = task.$qrl$;
734
- const taskHandler = createQRL(taskQrl.$chunk$, "_hW", _hW, null, null, [ task ], taskQrl.$symbol$);
735
- return taskQrl.dev && (taskHandler.dev = taskQrl.dev), taskHandler;
736
- };
737
- class Task extends Subscriber {
738
- $flags$;
739
- $index$;
740
- $el$;
741
- $qrl$;
742
- $state$;
743
- $destroy$;
744
- constructor($flags$, $index$, $el$, $qrl$, $state$, $destroy$) {
745
- super(), this.$flags$ = $flags$, this.$index$ = $index$, this.$el$ = $el$, this.$qrl$ = $qrl$,
746
- this.$state$ = $state$, this.$destroy$ = $destroy$;
747
- }
748
- }
749
- const isTask = value => value instanceof Task;
750
- const _hW = () => {
751
- const [task] = useLexicalScope();
752
- getDomContainer(task.$el$).$scheduler$(task.$flags$ & TaskFlags.VISIBLE_TASK ? ChoreType.VISIBLE : ChoreType.TASK, task);
753
- };
754
- const STORE_TARGET = Symbol("store.target");
755
- const STORE_HANDLER = Symbol("store.handler");
756
- const STORE_ARRAY_PROP = Symbol("store.array");
757
- var StoreFlags;
758
- !function(StoreFlags) {
759
- StoreFlags[StoreFlags.NONE = 0] = "NONE", StoreFlags[StoreFlags.RECURSIVE = 1] = "RECURSIVE",
760
- StoreFlags[StoreFlags.IMMUTABLE = 2] = "IMMUTABLE";
761
- }(StoreFlags || (StoreFlags = {}));
762
- const getStoreHandler = value => value[STORE_HANDLER];
763
- const getStoreTarget = value => value?.[STORE_TARGET] || null;
764
- const unwrapStore = value => getStoreTarget(value) || value;
765
- const isStore = value => STORE_TARGET in value;
766
- function createStore(container, obj, flags) {
767
- return new Proxy(obj, new StoreHandler(flags, container || null));
768
- }
769
- const getOrCreateStore = (obj, flags, container) => {
770
- if (isSerializableObject(obj) && container) {
771
- let store = container.$storeProxyMap$.get(obj);
772
- return store || (store = createStore(container, obj, flags), container.$storeProxyMap$.set(obj, store)),
773
- store;
774
- }
775
- return obj;
776
- };
777
- class StoreHandler {
778
- $flags$;
779
- $container$;
780
- $effects$=null;
781
- constructor($flags$, $container$) {
782
- this.$flags$ = $flags$, this.$container$ = $container$;
783
- }
784
- toString() {
785
- return "[Store]";
786
- }
787
- get(target, prop) {
788
- if ("symbol" == typeof prop) {
789
- return prop === STORE_TARGET ? target : prop === STORE_HANDLER ? this : target[prop];
790
- }
791
- const ctx = tryGetInvokeContext();
792
- const value = target[prop];
793
- if (ctx) {
794
- if (null === this.$container$) {
795
- if (!ctx.$container$) {
796
- return value;
797
- }
798
- this.$container$ = ctx.$container$;
799
- } else {
800
- assertTrue();
801
- }
802
- const effectSubscriber = ctx.$effectSubscriber$;
803
- effectSubscriber && addEffect(target, Array.isArray(target) ? STORE_ARRAY_PROP : prop, this, effectSubscriber);
804
- }
805
- if ("toString" === prop && value === Object.prototype.toString) {
806
- return this.toString;
807
- }
808
- return this.$flags$ & StoreFlags.RECURSIVE && "object" == typeof value && null !== value && !Object.isFrozen(value) && !isStore(value) && !Object.isFrozen(target) ? getOrCreateStore(value, this.$flags$, this.$container$) : value;
809
- }
810
- set(target, prop, value) {
811
- if (target = unwrapDeserializerProxy(target), "symbol" == typeof prop) {
812
- return target[prop] = value, !0;
813
- }
814
- const newValue = this.$flags$ & StoreFlags.RECURSIVE ? unwrapStore(value) : value;
815
- if (prop in target) {
816
- newValue !== target[prop] && setNewValueAndTriggerEffects(prop, newValue, target, this);
817
- } else {
818
- setNewValueAndTriggerEffects(prop, newValue, target, this);
819
- }
820
- return !0;
821
- }
822
- deleteProperty(target, prop) {
823
- return "string" == typeof prop && delete target[prop] && (triggerEffects(this.$container$, this, getEffects(target, prop, this.$effects$)),
824
- !0);
825
- }
826
- has(target, prop) {
827
- if (prop === STORE_TARGET) {
828
- return !0;
829
- }
830
- if ("string" == typeof prop) {
831
- const ctx = tryGetInvokeContext();
832
- if (ctx) {
833
- const effectSubscriber = ctx.$effectSubscriber$;
834
- effectSubscriber && addEffect(target, Array.isArray(target) ? STORE_ARRAY_PROP : prop, this, effectSubscriber);
835
- }
836
- }
837
- return Object.prototype.hasOwnProperty.call(target, prop);
838
- }
839
- ownKeys(target) {
840
- const ctx = tryGetInvokeContext();
841
- const effectSubscriber = ctx?.$effectSubscriber$;
842
- return effectSubscriber && addEffect(target, STORE_ARRAY_PROP, this, effectSubscriber),
843
- Reflect.ownKeys(target);
844
- }
845
- getOwnPropertyDescriptor(target, prop) {
846
- return Array.isArray(target) || "symbol" == typeof prop ? Object.getOwnPropertyDescriptor(target, prop) : {
847
- enumerable: !0,
848
- configurable: !0
849
- };
850
- }
851
- }
852
- function addEffect(target, prop, store, effectSubscriber) {
853
- const effectsMap = store.$effects$ ||= {};
854
- const effects = Object.prototype.hasOwnProperty.call(effectsMap, prop) && effectsMap[prop] || (effectsMap[prop] = []);
855
- ensureContainsEffect(effects, effectSubscriber), ensureContains(effectSubscriber, target);
856
- }
857
- function setNewValueAndTriggerEffects(prop, value, target, currentStore) {
858
- target[prop] = value, triggerEffects(currentStore.$container$, currentStore, getEffects(target, prop, currentStore.$effects$));
859
- }
860
- function getEffects(target, prop, storeEffects) {
861
- let effectsToTrigger = storeEffects ? Array.isArray(target) ? Object.values(storeEffects).flatMap((effects => effects)) : storeEffects[prop] : null;
862
- const storeArrayValue = storeEffects?.[STORE_ARRAY_PROP];
863
- return storeArrayValue && (effectsToTrigger ||= [], effectsToTrigger.push(...storeArrayValue)),
864
- effectsToTrigger;
865
- }
866
- const useResourceQrl = (qrl, opts) => {
867
- const {val, set, i, iCtx} = useSequentialScope();
868
- if (null != val) {
869
- return val;
870
- }
871
- assertQrl(qrl);
872
- const container = iCtx.$container$;
873
- const resource = createResourceReturn(container, opts);
874
- const task = new Task(TaskFlags.DIRTY | TaskFlags.RESOURCE, i, iCtx.$hostElement$, qrl, resource, null);
875
- return runResource(task, container, iCtx.$hostElement$), set(resource), resource;
876
- };
877
- const createResourceReturn = (container, opts, initialPromise) => {
878
- const result = (opts => ({
879
- __brand: "resource",
880
- value: void 0,
881
- loading: !isServerPlatform(),
882
- _resolved: void 0,
883
- _error: void 0,
884
- _state: "pending",
885
- _timeout: opts?.timeout ?? -1,
886
- _cache: 0
887
- }))(opts);
888
- return result.value = initialPromise, createStore(container, result, StoreFlags.RECURSIVE);
889
- };
890
- const isResourceReturn = obj => isObject(obj) && "resource" === (getStoreTarget(obj) || obj).__brand;
891
- const runResource = (task, container, host) => {
892
- task.$flags$ &= ~TaskFlags.DIRTY, cleanupTask(task);
893
- const iCtx = newInvokeContext(container.$locale$, host, void 0, "qResource");
894
- iCtx.$container$ = container;
895
- const taskFn = task.$qrl$.getFn(iCtx, (() => clearSubscriberEffectDependencies(task)));
896
- const resource = task.$state$;
897
- assertDefined();
898
- const cleanups = [];
899
- task.$destroy$ = noSerialize((() => {
900
- cleanups.forEach((fn => {
901
- try {
902
- fn();
903
- } catch (err) {
904
- container.handleError(err, host);
905
- }
906
- })), done = !0;
907
- }));
908
- const resourceTarget = unwrapStore(resource);
909
- const opts = {
910
- track: (obj, prop) => {
911
- const ctx = newInvokeContext();
912
- return ctx.$effectSubscriber$ = [ task, EffectProperty.COMPONENT ], ctx.$container$ = container,
913
- invoke(ctx, (() => isFunction(obj) ? obj() : prop ? obj[prop] : isSignal(obj) ? obj.value : obj));
914
- },
915
- cleanup(fn) {
916
- "function" == typeof fn && cleanups.push(fn);
917
- },
918
- cache(policy) {
919
- let milliseconds = 0;
920
- milliseconds = "immutable" === policy ? 1 / 0 : policy, resource._cache = milliseconds;
921
- },
922
- previous: resourceTarget._resolved
923
- };
924
- let resolve;
925
- let reject;
926
- let done = !1;
927
- const setState = (resolved, value) => !done && (done = !0, resolved ? (done = !0,
928
- resource.loading = !1, resource._state = "resolved", resource._resolved = value,
929
- resource._error = void 0, resolve(value)) : (done = !0, resource.loading = !1, resource._state = "rejected",
930
- resource._error = value, reject(value)), !0);
931
- cleanups.push((() => {
932
- if (!0 === untrack((() => resource.loading))) {
933
- const value = untrack((() => resource._resolved));
934
- setState(!0, value);
935
- }
936
- })), invoke(iCtx, (() => {
937
- resource._state = "pending", resource.loading = !isServerPlatform();
938
- (resource.value = new Promise(((r, re) => {
939
- resolve = r, reject = re;
940
- }))).catch(ignoreErrorToPreventNodeFromCrashing);
941
- }));
942
- const promise = safeCall((() => Promise.resolve(taskFn(opts))), (value => {
943
- setState(!0, value);
944
- }), (err => {
945
- if (isPromise(err)) {
946
- return err.then((() => runResource(task, container, host)));
652
+ })), invoke(iCtx, (() => {
653
+ resource._state = "pending", resource.loading = !isServerPlatform();
654
+ (resource.value = new Promise(((r, re) => {
655
+ resolve = r, reject = re;
656
+ }))).catch(ignoreErrorToPreventNodeFromCrashing);
657
+ }));
658
+ const promise = safeCall((() => Promise.resolve(taskFn(opts))), (value => {
659
+ setState(!0, value);
660
+ }), (err => {
661
+ if (isPromise(err)) {
662
+ return err.then((() => runResource(task, container, host)));
947
663
  }
948
664
  setState(!1, err);
949
665
  }));
@@ -1083,6 +799,41 @@
1083
799
  elementNamespaceFlag
1084
800
  };
1085
801
  }
802
+ const useOn = (event, eventQrl) => {
803
+ _useOn(createEventName(event, void 0), eventQrl);
804
+ };
805
+ const useOnDocument = (event, eventQrl) => {
806
+ _useOn(createEventName(event, "document"), eventQrl);
807
+ };
808
+ const createEventName = (event, eventType) => {
809
+ const prefix = void 0 !== eventType ? eventType + ":" : "";
810
+ const map = name => prefix + "on" + name.charAt(0).toUpperCase() + name.substring(1) + "$";
811
+ return Array.isArray(event) ? event.map(map) : map(event);
812
+ };
813
+ const _useOn = (eventName, eventQrl) => {
814
+ const {isAdded, addEvent} = useOnEventsSequentialScope();
815
+ isAdded || eventQrl && (Array.isArray(eventName) ? eventName.forEach((event => addEvent(event, eventQrl))) : addEvent(eventName, eventQrl));
816
+ };
817
+ const useOnEventsSequentialScope = () => {
818
+ const iCtx = useInvokeContext();
819
+ const host = iCtx.$hostElement$;
820
+ let onMap = iCtx.$container$.getHostProp(host, ":on");
821
+ null === onMap && (onMap = {}, iCtx.$container$.setHostProp(host, ":on", onMap));
822
+ let seqIdx = iCtx.$container$.getHostProp(host, ":onIdx");
823
+ null === seqIdx && (seqIdx = 0), iCtx.$container$.setHostProp(host, ":onIdx", seqIdx + 1);
824
+ let addedFlags = iCtx.$container$.getHostProp(host, ":onFlags");
825
+ for (null === addedFlags && (addedFlags = [], iCtx.$container$.setHostProp(host, ":onFlags", addedFlags)); addedFlags.length <= seqIdx; ) {
826
+ addedFlags.push(!1);
827
+ }
828
+ return {
829
+ isAdded: addedFlags[seqIdx],
830
+ addEvent: (eventName, eventQrl) => {
831
+ addedFlags[seqIdx] = !0;
832
+ let events = onMap[eventName];
833
+ events || (onMap[eventName] = events = []), events.push(eventQrl);
834
+ }
835
+ };
836
+ };
1086
837
  const executeComponent = (container, renderHost, subscriptionHost, componentQRL, props) => {
1087
838
  const iCtx = newInvokeContext(container.$locale$, subscriptionHost, void 0, "qRender");
1088
839
  let componentFn;
@@ -1103,7 +854,8 @@
1103
854
  }
1104
855
  const executeComponentWithPromiseExceptionRetry = (retryCount = 0) => safeCall((() => (isInlineComponent || (container.setHostProp(renderHost, "q:seqIdx", null),
1105
856
  container.setHostProp(renderHost, ":onIdx", null), container.getHostProp(renderHost, "q:props") !== props && container.setHostProp(renderHost, "q:props", props)),
1106
- vnode_isVNode(renderHost) && clearVNodeEffectDependencies(renderHost), componentFn(props))), (jsx => {
857
+ vnode_isVNode(renderHost) && clearVNodeEffectDependencies(container, renderHost),
858
+ componentFn(props))), (jsx => {
1107
859
  const useOnEvents = container.getHostProp(renderHost, ":on");
1108
860
  return useOnEvents ? maybeThen(function(jsx, useOnEvents) {
1109
861
  const jsxElement = findFirstStringJSX(jsx);
@@ -1164,6 +916,9 @@
1164
916
  }
1165
917
  return Array.isArray(jsx) && jsx.length ? addScriptNodeForInvisibleComponents(jsx[0]) : null;
1166
918
  }
919
+ function isSlotProp(prop) {
920
+ return !prop.startsWith("q:") && !prop.startsWith(":");
921
+ }
1167
922
  function escapeHTML(html) {
1168
923
  let escapedHTML = "";
1169
924
  const length = html.length;
@@ -1189,6 +944,13 @@
1189
944
  }
1190
945
  return 0 === lastIdx ? html : escapedHTML + html.substring(lastIdx);
1191
946
  }
947
+ function getFileLocationFromJsx(jsxDev) {
948
+ if (!jsxDev) {
949
+ return null;
950
+ }
951
+ const sanitizedFileName = jsxDev.fileName?.replace(/\\/g, "/");
952
+ return sanitizedFileName ? `${sanitizedFileName}:${jsxDev.lineNumber}:${jsxDev.columnNumber}` : null;
953
+ }
1192
954
  const vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
1193
955
  let journal = container.$journal$;
1194
956
  const stack = [];
@@ -1226,8 +988,8 @@
1226
988
  if (Array.isArray(jsxValue)) {
1227
989
  descend(jsxValue, !1);
1228
990
  } else if (isSignal(jsxValue)) {
1229
- vCurrent && clearVNodeEffectDependencies(vCurrent), expectVirtual(VirtualType.WrappedSignal, null),
1230
- descend(trackSignal((() => jsxValue.value), vNewNode || vCurrent, EffectProperty.VNODE, container), !0);
991
+ vCurrent && clearVNodeEffectDependencies(container, vCurrent), expectVirtual(VirtualType.WrappedSignal, null),
992
+ descend(trackSignalAndAssignHost(jsxValue, vNewNode || vCurrent, EffectProperty.VNODE, container), !0);
1231
993
  } else if (isPromise(jsxValue)) {
1232
994
  expectVirtual(VirtualType.Awaited, null), asyncQueue.push(jsxValue, vNewNode || vCurrent);
1233
995
  } else if (isJSXNode(jsxValue)) {
@@ -1320,7 +1082,7 @@
1320
1082
  if (constProps && "object" == typeof constProps && "name" in constProps) {
1321
1083
  const constValue = constProps.name;
1322
1084
  if (vHost && constValue instanceof WrappedSignal) {
1323
- return trackSignal((() => constValue.value), vHost, EffectProperty.COMPONENT, container);
1085
+ return trackSignalAndAssignHost(constValue, vHost, EffectProperty.COMPONENT, container);
1324
1086
  }
1325
1087
  }
1326
1088
  return directGetPropsProxyProp(jsxNode, "name") || "";
@@ -1349,7 +1111,7 @@
1349
1111
  advanceToNextSibling(), vnode_remove(journal, vParent, toRemove, !0);
1350
1112
  }
1351
1113
  }
1352
- function createNewElement(jsx, elementName) {
1114
+ function createNewElement(jsx, elementName, currentFile) {
1353
1115
  const element = function(elementName) {
1354
1116
  const domParentVNode = vnode_getDomParentVNode(vParent);
1355
1117
  const {elementNamespace, elementNamespaceFlag} = getNewElementNamespaceData(domParentVNode, elementName);
@@ -1377,23 +1139,26 @@
1377
1139
  value(element);
1378
1140
  continue;
1379
1141
  }
1142
+ throw qError(QError.invalidRefValue, [ currentFile ]);
1380
1143
  }
1381
1144
  if (isSignal(value)) {
1382
- const signalData = new EffectData({
1145
+ const signalData = new EffectPropData({
1383
1146
  $scopedStyleIdPrefix$: scopedStyleIdPrefix,
1384
1147
  $isConst$: !0
1385
1148
  });
1386
- value = trackSignal((() => value.value), vNewNode, key, container, signalData);
1149
+ value = trackSignalAndAssignHost(value, vNewNode, key, container, signalData);
1387
1150
  }
1388
1151
  if ("dangerouslySetInnerHTML" !== key) {
1389
1152
  if ("textarea" !== elementName || "value" !== key) {
1390
1153
  value = serializeAttribute(key, value, scopedStyleIdPrefix), null != value && element.setAttribute(key, String(value));
1391
1154
  } else {
1392
- if ("string" != typeof value) {
1393
- build.isDev && throwErrorAndStop("The value of the textarea must be a string");
1155
+ if (value && "string" != typeof value) {
1156
+ if (build.isDev) {
1157
+ throw qError(QError.wrongTextareaValue, [ currentFile, value ]);
1158
+ }
1394
1159
  continue;
1395
1160
  }
1396
- element.value = escapeHTML(value);
1161
+ element.value = escapeHTML(value || "");
1397
1162
  }
1398
1163
  } else {
1399
1164
  element.innerHTML = value, element.setAttribute("q:container", QContainerValue.HTML);
@@ -1410,17 +1175,19 @@
1410
1175
  const isSameElementName = vCurrent && vnode_isElementVNode(vCurrent) && elementName === vnode_getElementName(vCurrent);
1411
1176
  const jsxKey = jsx.key;
1412
1177
  let needsQDispatchEventPatch = !1;
1178
+ const currentFile = getFileLocationFromJsx(jsx.dev);
1413
1179
  isSameElementName && jsxKey === getKey(vCurrent) || (vNewNode = retrieveChildWithKey(elementName, jsxKey),
1414
- null === vNewNode ? needsQDispatchEventPatch = createNewElement(jsx, elementName) : vnode_insertBefore(journal, vParent, vNewNode, vCurrent));
1180
+ null === vNewNode ? needsQDispatchEventPatch = createNewElement(jsx, elementName) : (vnode_insertBefore(journal, vParent, vNewNode, vCurrent),
1181
+ vCurrent = vNewNode, vNewNode = null, null !== vSiblings && (vSiblingsIdx -= SiblingsArray.Size)));
1415
1182
  const jsxAttrs = [];
1416
1183
  const props = jsx.varProps;
1417
1184
  for (const key in props) {
1418
- let value = props[key];
1419
- value = serializeAttribute(key, value, scopedStyleIdPrefix), null != value && mapArray_set(jsxAttrs, key, value, 0);
1185
+ const value = props[key];
1186
+ null != value && mapArray_set(jsxAttrs, key, value, 0);
1420
1187
  }
1421
1188
  null !== jsxKey && mapArray_set(jsxAttrs, "q:key", jsxKey, 0);
1422
1189
  const vNode = vNewNode || vCurrent;
1423
- if (needsQDispatchEventPatch = function(vnode, srcAttrs) {
1190
+ if (needsQDispatchEventPatch = function(vnode, srcAttrs, currentFile) {
1424
1191
  vnode_ensureElementInflated(vnode);
1425
1192
  const dstAttrs = vnode;
1426
1193
  let srcIdx = 0;
@@ -1442,8 +1209,16 @@
1442
1209
  if ("function" == typeof value) {
1443
1210
  return void value(element);
1444
1211
  }
1212
+ throw qError(QError.invalidRefValue, [ currentFile ]);
1213
+ }
1214
+ if (isSignal(value)) {
1215
+ const signalData = new EffectPropData({
1216
+ $scopedStyleIdPrefix$: scopedStyleIdPrefix,
1217
+ $isConst$: !1
1218
+ });
1219
+ value = trackSignalAndAssignHost(value, vnode, key, container, signalData);
1445
1220
  }
1446
- isSignal(value) && (value = untrack((() => value.value))), vnode_setAttr(journal, vnode, key, value),
1221
+ vnode_setAttr(journal, vnode, key, serializeAttribute(key, value, scopedStyleIdPrefix)),
1447
1222
  null === value && (dstLength = dstAttrs.length);
1448
1223
  }
1449
1224
  };
@@ -1457,14 +1232,14 @@
1457
1232
  htmlEvent && record(htmlEvent, ""), eventName && registerQwikLoaderEvent(eventName);
1458
1233
  };
1459
1234
  for (;null !== srcKey || null !== dstKey; ) {
1460
- if (dstKey?.startsWith(HANDLER_PREFIX) || "q:key" == dstKey) {
1235
+ if (dstKey?.startsWith(HANDLER_PREFIX) || dstKey?.startsWith("q:")) {
1461
1236
  dstIdx++, dstKey = dstIdx < dstLength ? dstAttrs[dstIdx++] : null;
1462
1237
  } else if (null == srcKey) {
1463
1238
  dstKey && isHtmlAttributeAnEventName(dstKey) ? (patchEventDispatch = !0, dstIdx++) : (record(dstKey, null),
1464
1239
  dstIdx--), dstKey = dstIdx < dstLength ? dstAttrs[dstIdx++] : null;
1465
1240
  } else if (null == dstKey) {
1466
1241
  isJsxPropertyAnEventName(srcKey) ? (patchEventDispatch = !0, recordJsxEvent(srcKey, srcAttrs[srcIdx])) : record(srcKey, srcAttrs[srcIdx]),
1467
- srcIdx++, srcKey = srcIdx < srcLength ? srcAttrs[srcIdx++] : null;
1242
+ srcIdx++, srcKey = srcIdx < srcLength ? srcAttrs[srcIdx++] : null, dstIdx++, dstKey = dstIdx < dstLength ? dstAttrs[dstIdx++] : null;
1468
1243
  } else if (srcKey == dstKey) {
1469
1244
  const srcValue = srcAttrs[srcIdx++];
1470
1245
  srcValue !== dstAttrs[dstIdx++] && record(dstKey, srcValue), srcKey = srcIdx < srcLength ? srcAttrs[srcIdx++] : null,
@@ -1477,7 +1252,7 @@
1477
1252
  }
1478
1253
  }
1479
1254
  return patchEventDispatch;
1480
- }(vNode, jsxAttrs) || needsQDispatchEventPatch, needsQDispatchEventPatch) {
1255
+ }(vNode, jsxAttrs, currentFile) || needsQDispatchEventPatch, needsQDispatchEventPatch) {
1481
1256
  const element = vnode_getNode(vNode);
1482
1257
  element.qDispatchEvent || (element.qDispatchEvent = (event, scope) => {
1483
1258
  const eventName = event.type;
@@ -1521,7 +1296,7 @@
1521
1296
  function expectVirtual(type, jsxKey) {
1522
1297
  vCurrent && vnode_isVirtualVNode(vCurrent) && getKey(vCurrent) === jsxKey || (null === jsxKey || (vNewNode = retrieveChildWithKey(null, jsxKey),
1523
1298
  null == vNewNode) ? (vnode_insertBefore(journal, vParent, vNewNode = vnode_newVirtual(), vCurrent && getInsertBefore()),
1524
- vnode_setProp(vNewNode, "q:key", jsxKey), build.isDev && vnode_setProp(vNewNode || vCurrent, "q:type", type)) : vnode_insertBefore(journal, vParent, vNewNode = vnode_newVirtual(), vCurrent && getInsertBefore()));
1299
+ vnode_setProp(vNewNode, "q:key", jsxKey), build.isDev && vnode_setProp(vNewNode || vCurrent, "q:type", type)) : vnode_insertBefore(journal, vParent, vNewNode, vCurrent && getInsertBefore()));
1525
1300
  }
1526
1301
  function expectComponent(component) {
1527
1302
  const componentMeta = component[SERIALIZABLE_STATE];
@@ -1543,8 +1318,8 @@
1543
1318
  if (!src || !dst) {
1544
1319
  return !0;
1545
1320
  }
1546
- let srcKeys = removeChildrenKey(Object.keys(src));
1547
- let dstKeys = removeChildrenKey(Object.keys(dst));
1321
+ let srcKeys = removePropsKeys(Object.keys(src), [ "children", "q:subs" ]);
1322
+ let dstKeys = removePropsKeys(Object.keys(dst), [ "children", "q:subs" ]);
1548
1323
  if (srcKeys.length !== dstKeys.length) {
1549
1324
  return !0;
1550
1325
  }
@@ -1607,7 +1382,7 @@
1607
1382
  }
1608
1383
  }
1609
1384
  function insertNewComponent(host, componentQRL, jsxProps) {
1610
- host && clearVNodeEffectDependencies(host), vnode_insertBefore(journal, vParent, vNewNode = vnode_newVirtual(), vCurrent && getInsertBefore());
1385
+ host && clearVNodeEffectDependencies(container, host), vnode_insertBefore(journal, vParent, vNewNode = vnode_newVirtual(), vCurrent && getInsertBefore());
1611
1386
  const jsxNode = jsxValue;
1612
1387
  build.isDev && vnode_setProp(vNewNode, "q:type", VirtualType.Component), container.setHostProp(vNewNode, "q:renderFn", componentQRL),
1613
1388
  container.setHostProp(vNewNode, "q:props", jsxProps), container.setHostProp(vNewNode, "q:key", jsxNode.key);
@@ -1632,9 +1407,12 @@
1632
1407
  return qrl ? qrl.$hash$ : null;
1633
1408
  }
1634
1409
  function Projection() {}
1635
- function removeChildrenKey(keys) {
1636
- const childrenIdx = keys.indexOf("children");
1637
- return -1 !== childrenIdx && keys.splice(childrenIdx, 1), keys;
1410
+ function removePropsKeys(keys, propKeys) {
1411
+ for (let i = propKeys.length - 1; i >= 0; i--) {
1412
+ const propIdx = keys.indexOf(propKeys[i]);
1413
+ -1 !== propIdx && keys.splice(propIdx, 1);
1414
+ }
1415
+ return keys;
1638
1416
  }
1639
1417
  function cleanup(container, vNode) {
1640
1418
  let vCursor = vNode;
@@ -1645,15 +1423,15 @@
1645
1423
  for (;;) {
1646
1424
  const type = vCursor[VNodeProps.flags];
1647
1425
  if (type & VNodeFlags.ELEMENT_OR_VIRTUAL_MASK) {
1648
- if (type & VNodeFlags.Virtual) {
1649
- clearVNodeEffectDependencies(vCursor), markVNodeAsDeleted(vCursor);
1426
+ if (clearVNodeEffectDependencies(container, vCursor), markVNodeAsDeleted(vCursor),
1427
+ type & VNodeFlags.Virtual) {
1650
1428
  const seq = container.getHostProp(vCursor, "q:seq");
1651
1429
  if (seq) {
1652
1430
  for (let i = 0; i < seq.length; i++) {
1653
1431
  const obj = seq[i];
1654
1432
  if (isTask(obj)) {
1655
1433
  const task = obj;
1656
- clearSubscriberEffectDependencies(task), task.$flags$ & TaskFlags.VISIBLE_TASK ? container.$scheduler$(ChoreType.CLEANUP_VISIBLE, task) : cleanupTask(task);
1434
+ clearSubscriberEffectDependencies(container, task), task.$flags$ & TaskFlags.VISIBLE_TASK ? container.$scheduler$(ChoreType.CLEANUP_VISIBLE, task) : cleanupTask(task);
1657
1435
  }
1658
1436
  }
1659
1437
  }
@@ -1727,26 +1505,33 @@
1727
1505
  const HANDLER_PREFIX = ":";
1728
1506
  let count = 0;
1729
1507
  var SiblingsArray;
1730
- var ChoreType;
1731
1508
  !function(SiblingsArray) {
1732
1509
  SiblingsArray[SiblingsArray.Name = 0] = "Name", SiblingsArray[SiblingsArray.Key = 1] = "Key",
1733
1510
  SiblingsArray[SiblingsArray.VNode = 2] = "VNode", SiblingsArray[SiblingsArray.Size = 3] = "Size",
1734
1511
  SiblingsArray[SiblingsArray.NextVNode = 5] = "NextVNode";
1735
- }(SiblingsArray || (SiblingsArray = {})), function(ChoreType) {
1736
- ChoreType[ChoreType.MACRO = 112] = "MACRO", ChoreType[ChoreType.MICRO = 15] = "MICRO",
1512
+ }(SiblingsArray || (SiblingsArray = {}));
1513
+ const implicit$FirstArg = fn => function(first, ...rest) {
1514
+ return fn.call(null, dollar(first), ...rest);
1515
+ };
1516
+ const createSignal = value => new Signal(null, value);
1517
+ const createComputedQrl = qrl => (throwIfQRLNotResolved(qrl), new ComputedSignal(null, qrl));
1518
+ const createComputed$ = /*#__PURE__*/ implicit$FirstArg(createComputedQrl);
1519
+ var ChoreType;
1520
+ !function(ChoreType) {
1521
+ ChoreType[ChoreType.MACRO = 240] = "MACRO", ChoreType[ChoreType.MICRO = 15] = "MICRO",
1737
1522
  ChoreType[ChoreType.QRL_RESOLVE = 1] = "QRL_RESOLVE", ChoreType[ChoreType.RESOURCE = 2] = "RESOURCE",
1738
1523
  ChoreType[ChoreType.TASK = 3] = "TASK", ChoreType[ChoreType.NODE_DIFF = 4] = "NODE_DIFF",
1739
1524
  ChoreType[ChoreType.NODE_PROP = 5] = "NODE_PROP", ChoreType[ChoreType.COMPONENT_SSR = 6] = "COMPONENT_SSR",
1740
- ChoreType[ChoreType.COMPONENT = 7] = "COMPONENT", ChoreType[ChoreType.WAIT_FOR_COMPONENTS = 16] = "WAIT_FOR_COMPONENTS",
1741
- ChoreType[ChoreType.JOURNAL_FLUSH = 48] = "JOURNAL_FLUSH", ChoreType[ChoreType.VISIBLE = 64] = "VISIBLE",
1742
- ChoreType[ChoreType.CLEANUP_VISIBLE = 80] = "CLEANUP_VISIBLE", ChoreType[ChoreType.WAIT_FOR_ALL = 127] = "WAIT_FOR_ALL";
1525
+ ChoreType[ChoreType.COMPONENT = 7] = "COMPONENT", ChoreType[ChoreType.RECOMPUTE_AND_SCHEDULE_EFFECTS = 8] = "RECOMPUTE_AND_SCHEDULE_EFFECTS",
1526
+ ChoreType[ChoreType.JOURNAL_FLUSH = 16] = "JOURNAL_FLUSH", ChoreType[ChoreType.VISIBLE = 32] = "VISIBLE",
1527
+ ChoreType[ChoreType.CLEANUP_VISIBLE = 48] = "CLEANUP_VISIBLE", ChoreType[ChoreType.WAIT_FOR_ALL = 255] = "WAIT_FOR_ALL";
1743
1528
  }(ChoreType || (ChoreType = {}));
1744
1529
  const createScheduler = (container, scheduleDrain, journalFlush) => {
1745
1530
  const choreQueue = [];
1746
1531
  let currentChore = null;
1747
1532
  let journalFlushScheduled = !1;
1748
1533
  return function schedule(type, hostOrTask = null, targetOrQrl = null, payload = null) {
1749
- const runLater = type !== ChoreType.WAIT_FOR_ALL && type !== ChoreType.WAIT_FOR_COMPONENTS && type !== ChoreType.COMPONENT_SSR;
1534
+ const runLater = type !== ChoreType.WAIT_FOR_ALL && type !== ChoreType.COMPONENT_SSR;
1750
1535
  const isTask = type === ChoreType.TASK || type === ChoreType.VISIBLE || type === ChoreType.RESOURCE || type === ChoreType.CLEANUP_VISIBLE;
1751
1536
  isTask && (hostOrTask.$flags$ |= TaskFlags.DIRTY);
1752
1537
  let chore = {
@@ -1760,13 +1545,13 @@
1760
1545
  $returnValue$: null,
1761
1546
  $executed$: !1
1762
1547
  };
1763
- chore.$promise$ = new Promise((resolve => chore.$resolve$ = resolve)), chore = function(sortedArray, value) {
1764
- const idx = function(sortedArray, value) {
1548
+ chore.$promise$ = new Promise((resolve => chore.$resolve$ = resolve)), chore = function(sortedArray, value, rootVNode) {
1549
+ const idx = function(sortedArray, value, rootVNode) {
1765
1550
  let bottom = 0;
1766
1551
  let top = sortedArray.length;
1767
1552
  for (;bottom < top; ) {
1768
1553
  const middle = bottom + (top - bottom >> 1);
1769
- const comp = choreComparator(value, sortedArray[middle], !0);
1554
+ const comp = choreComparator(value, sortedArray[middle], rootVNode, !0);
1770
1555
  if (comp < 0) {
1771
1556
  top = middle;
1772
1557
  } else {
@@ -1777,17 +1562,17 @@
1777
1562
  }
1778
1563
  }
1779
1564
  return ~bottom;
1780
- }(sortedArray, value);
1565
+ }(sortedArray, value, rootVNode);
1781
1566
  if (idx < 0) {
1782
1567
  return sortedArray.splice(~idx, 0, value), value;
1783
1568
  }
1784
1569
  const existing = sortedArray[idx];
1785
1570
  return choreUpdate(existing, value), existing;
1786
- }(choreQueue, chore), !journalFlushScheduled && runLater && (journalFlushScheduled = !0,
1571
+ }(choreQueue, chore, container.rootVNode || null), !journalFlushScheduled && runLater && (journalFlushScheduled = !0,
1787
1572
  schedule(ChoreType.JOURNAL_FLUSH), scheduleDrain());
1788
- return runLater ? chore.$promise$ : drainUpTo(chore);
1573
+ return runLater ? chore.$promise$ : drainUpTo(chore, container.rootVNode || null);
1789
1574
  };
1790
- function drainUpTo(runUptoChore) {
1575
+ function drainUpTo(runUptoChore, rootVNode) {
1791
1576
  if (runUptoChore.$executed$) {
1792
1577
  return runUptoChore.$returnValue$;
1793
1578
  }
@@ -1796,7 +1581,7 @@
1796
1581
  }
1797
1582
  for (;choreQueue.length; ) {
1798
1583
  const nextChore = choreQueue.shift();
1799
- const order = choreComparator(nextChore, runUptoChore, !1);
1584
+ const order = choreComparator(nextChore, runUptoChore, rootVNode, !1);
1800
1585
  if (null === order) {
1801
1586
  continue;
1802
1587
  }
@@ -1808,7 +1593,7 @@
1808
1593
  }
1809
1594
  const returnValue = executeChore(nextChore);
1810
1595
  if (isPromise(returnValue)) {
1811
- return returnValue.then((() => drainUpTo(runUptoChore)));
1596
+ return returnValue.then((() => drainUpTo(runUptoChore, rootVNode)));
1812
1597
  }
1813
1598
  }
1814
1599
  var chore;
@@ -1876,6 +1661,19 @@
1876
1661
  returnValue = target.resolved ? null : target.resolve();
1877
1662
  break;
1878
1663
  }
1664
+
1665
+ case ChoreType.RECOMPUTE_AND_SCHEDULE_EFFECTS:
1666
+ {
1667
+ const target = chore.$target$;
1668
+ const forceRunEffects = target.$forceRunEffects$;
1669
+ if (target.$forceRunEffects$ = !1, !target.$effects$?.length) {
1670
+ break;
1671
+ }
1672
+ returnValue = retryOnPromise((() => {
1673
+ (target.$computeIfNeeded$() || forceRunEffects) && triggerEffects(container, target, target.$effects$);
1674
+ }));
1675
+ break;
1676
+ }
1879
1677
  }
1880
1678
  return thenFn = value => (currentChore && (currentChore.$executed$ = !0, currentChore.$resolve$?.(value)),
1881
1679
  currentChore = null, chore.$returnValue$ = value), isPromise(valueOrPromise = returnValue) ? valueOrPromise.then(thenFn) : thenFn(valueOrPromise);
@@ -1886,7 +1684,7 @@
1886
1684
  const choreUpdate = (existing, newChore) => {
1887
1685
  existing.$type$ === ChoreType.NODE_DIFF && (existing.$payload$ = newChore.$payload$);
1888
1686
  };
1889
- function choreComparator(a, b, shouldThrowOnHostMismatch) {
1687
+ function choreComparator(a, b, rootVNode, shouldThrowOnHostMismatch) {
1890
1688
  const macroTypeDiff = (a.$type$ & ChoreType.MACRO) - (b.$type$ & ChoreType.MACRO);
1891
1689
  if (0 !== macroTypeDiff) {
1892
1690
  return macroTypeDiff;
@@ -1897,11 +1695,13 @@
1897
1695
  if (aHost !== bHost && null !== aHost && null !== bHost) {
1898
1696
  if (!vnode_isVNode(aHost) || !vnode_isVNode(bHost)) {
1899
1697
  const errorMessage = `SERVER: during HTML streaming, re-running tasks on a different host is not allowed.\n You are attempting to change a state that has already been streamed to the client.\n This can lead to inconsistencies between Server-Side Rendering (SSR) and Client-Side Rendering (CSR).\n Problematic Node: ${aHost.toString()}`;
1900
- return shouldThrowOnHostMismatch && throwErrorAndStop(errorMessage), logWarn(errorMessage),
1901
- null;
1698
+ if (shouldThrowOnHostMismatch) {
1699
+ throw qError(QError.serverHostMismatch, [ errorMessage ]);
1700
+ }
1701
+ return logWarn(errorMessage), null;
1902
1702
  }
1903
1703
  {
1904
- const hostDiff = vnode_documentPosition(aHost, bHost);
1704
+ const hostDiff = vnode_documentPosition(aHost, bHost, rootVNode);
1905
1705
  if (0 !== hostDiff) {
1906
1706
  return hostDiff;
1907
1707
  }
@@ -1915,456 +1715,338 @@
1915
1715
  if (0 !== idxDiff) {
1916
1716
  return idxDiff;
1917
1717
  }
1918
- if (a.$target$ !== b.$target$ && (a.$type$ === ChoreType.QRL_RESOLVE && b.$type$ === ChoreType.QRL_RESOLVE || a.$type$ === ChoreType.NODE_PROP && b.$type$ === ChoreType.NODE_PROP)) {
1718
+ if (a.$target$ !== b.$target$ && (a.$type$ === ChoreType.QRL_RESOLVE && b.$type$ === ChoreType.QRL_RESOLVE || a.$type$ === ChoreType.NODE_PROP && b.$type$ === ChoreType.NODE_PROP || a.$type$ === ChoreType.RECOMPUTE_AND_SCHEDULE_EFFECTS && b.$type$ === ChoreType.RECOMPUTE_AND_SCHEDULE_EFFECTS)) {
1919
1719
  return 1;
1920
1720
  }
1921
1721
  }
1922
1722
  return 0;
1923
1723
  }
1924
- const version = "2.0.0-alpha.3-dev+418fd6d";
1925
- class _SharedContainer {
1926
- $version$;
1927
- $scheduler$;
1928
- $storeProxyMap$;
1929
- $locale$;
1930
- $getObjectById$;
1931
- $serverData$;
1932
- $currentUniqueId$=0;
1933
- $instanceHash$=null;
1934
- constructor(scheduleDrain, journalFlush, serverData, locale) {
1935
- this.$serverData$ = serverData, this.$locale$ = locale, this.$version$ = version,
1936
- this.$storeProxyMap$ = new WeakMap, this.$getObjectById$ = () => {
1937
- throw Error("Not implemented");
1938
- }, this.$scheduler$ = createScheduler(this, scheduleDrain, journalFlush);
1724
+ const useLexicalScope = () => {
1725
+ const context = getInvokeContext();
1726
+ let qrl = context.$qrl$;
1727
+ if (qrl) {
1728
+ assertQrl(qrl), assertDefined();
1729
+ } else {
1730
+ const el = context.$element$;
1731
+ assertDefined();
1732
+ const containerElement = _getQContainerElement(el);
1733
+ assertDefined();
1734
+ qrl = getDomContainer(containerElement).parseQRL(decodeURIComponent(String(context.$url$)));
1939
1735
  }
1940
- trackSignalValue(signal, subscriber, property, data) {
1941
- return trackSignal((() => signal.value), subscriber, property, this, data);
1736
+ return qrl.$captureRef$;
1737
+ };
1738
+ var TaskFlags;
1739
+ !function(TaskFlags) {
1740
+ TaskFlags[TaskFlags.VISIBLE_TASK = 1] = "VISIBLE_TASK", TaskFlags[TaskFlags.TASK = 2] = "TASK",
1741
+ TaskFlags[TaskFlags.RESOURCE = 4] = "RESOURCE", TaskFlags[TaskFlags.DIRTY = 8] = "DIRTY";
1742
+ }(TaskFlags || (TaskFlags = {}));
1743
+ const useTaskQrl = (qrl, opts) => {
1744
+ const {val, set, iCtx, i} = useSequentialScope();
1745
+ if (val) {
1746
+ return;
1942
1747
  }
1943
- serializationCtxFactory(NodeConstructor, DomRefConstructor, symbolToChunkResolver, writer, prepVNodeData) {
1944
- return createSerializationContext(NodeConstructor, DomRefConstructor, symbolToChunkResolver, this.getHostProp.bind(this), this.setHostProp.bind(this), this.$storeProxyMap$, writer, prepVNodeData);
1748
+ assertQrl(qrl), set(1);
1749
+ const host = iCtx.$hostElement$;
1750
+ const task = new Task(TaskFlags.DIRTY | TaskFlags.TASK, i, iCtx.$hostElement$, qrl, void 0, null);
1751
+ set(task);
1752
+ const result = runTask(task, iCtx.$container$, host);
1753
+ if (isPromise(result)) {
1754
+ throw result;
1755
+ }
1756
+ qrl.$resolveLazy$(iCtx.$element$), isServerPlatform() && useRunTask(task, opts?.eagerness);
1757
+ };
1758
+ const runTask = (task, container, host) => {
1759
+ task.$flags$ &= ~TaskFlags.DIRTY, cleanupTask(task);
1760
+ const iCtx = newInvokeContext(container.$locale$, host, void 0, "qTask");
1761
+ iCtx.$container$ = container;
1762
+ const taskFn = task.$qrl$.getFn(iCtx, (() => clearSubscriberEffectDependencies(container, task)));
1763
+ const handleError = reason => container.handleError(reason, host);
1764
+ let cleanupFns = null;
1765
+ const cleanup = fn => {
1766
+ "function" == typeof fn && (cleanupFns || (cleanupFns = [], task.$destroy$ = noSerialize((() => {
1767
+ task.$destroy$ = null, cleanupFns.forEach((fn => {
1768
+ try {
1769
+ fn();
1770
+ } catch (err) {
1771
+ handleError(err);
1772
+ }
1773
+ }));
1774
+ }))), cleanupFns.push(fn));
1775
+ };
1776
+ const taskApi = {
1777
+ track: (obj, prop) => {
1778
+ const ctx = newInvokeContext();
1779
+ return ctx.$effectSubscriber$ = [ task, EffectProperty.COMPONENT ], ctx.$container$ = container,
1780
+ invoke(ctx, (() => isFunction(obj) ? obj() : prop ? obj[prop] : isSignal(obj) ? obj.value : obj));
1781
+ },
1782
+ cleanup
1783
+ };
1784
+ return safeCall((() => taskFn(taskApi)), cleanup, (err => isPromise(err) ? err.then((() => runTask(task, container, host))) : handleError(err)));
1785
+ };
1786
+ const cleanupTask = task => {
1787
+ const destroy = task.$destroy$;
1788
+ if (destroy) {
1789
+ task.$destroy$ = null;
1790
+ try {
1791
+ destroy();
1792
+ } catch (err) {
1793
+ ((message, ...optionalParams) => {
1794
+ createAndLogError(!1, message, ...optionalParams);
1795
+ })(err);
1796
+ }
1797
+ }
1798
+ };
1799
+ const useRunTask = (task, eagerness) => {
1800
+ "visible" === eagerness || "intersection-observer" === eagerness ? useOn("qvisible", getTaskHandlerQrl(task)) : "load" === eagerness || "document-ready" === eagerness ? useOnDocument("qinit", getTaskHandlerQrl(task)) : "idle" !== eagerness && "document-idle" !== eagerness || useOnDocument("qidle", getTaskHandlerQrl(task));
1801
+ };
1802
+ const getTaskHandlerQrl = task => {
1803
+ const taskQrl = task.$qrl$;
1804
+ const taskHandler = createQRL(taskQrl.$chunk$, "_hW", _hW, null, null, [ task ], taskQrl.$symbol$);
1805
+ return taskQrl.dev && (taskHandler.dev = taskQrl.dev), taskHandler;
1806
+ };
1807
+ class Task extends Subscriber {
1808
+ $flags$;
1809
+ $index$;
1810
+ $el$;
1811
+ $qrl$;
1812
+ $state$;
1813
+ $destroy$;
1814
+ constructor($flags$, $index$, $el$, $qrl$, $state$, $destroy$) {
1815
+ super(), this.$flags$ = $flags$, this.$index$ = $index$, this.$el$ = $el$, this.$qrl$ = $qrl$,
1816
+ this.$state$ = $state$, this.$destroy$ = $destroy$;
1945
1817
  }
1946
1818
  }
1947
- const VNodeDataSeparator_REFERENCE = 126, VNodeDataSeparator_ADVANCE_1 = 33, VNodeDataSeparator_ADVANCE_8192 = 46;
1948
- const VNodeDataChar_OPEN = 123, VNodeDataChar_CLOSE = 125, VNodeDataChar_SCOPED_STYLE = 59, VNodeDataChar_RENDER_FN = 60, VNodeDataChar_ID = 61, VNodeDataChar_PROPS = 62, VNodeDataChar_SLOT_REF = 63, VNodeDataChar_KEY = 64, VNodeDataChar_SEQ = 91, VNodeDataChar_CONTEXT = 93, VNodeDataChar_SEQ_IDX = 94, VNodeDataChar_SEPARATOR = 124, VNodeDataChar_SLOT = 126;
1949
- function getDomContainer(element) {
1950
- const qContainerElement = _getQContainerElement(element);
1951
- return qContainerElement || throwErrorAndStop("Unable to find q:container."), getDomContainerFromQContainerElement(qContainerElement);
1819
+ const isTask = value => value instanceof Task;
1820
+ const _hW = () => {
1821
+ const [task] = useLexicalScope();
1822
+ getDomContainer(task.$el$).$scheduler$(task.$flags$ & TaskFlags.VISIBLE_TASK ? ChoreType.VISIBLE : ChoreType.TASK, task);
1823
+ };
1824
+ const NEEDS_COMPUTATION = Symbol("invalid");
1825
+ const throwIfQRLNotResolved = qrl => {
1826
+ if (!qrl.resolved) {
1827
+ throw qrl.resolve();
1828
+ }
1829
+ };
1830
+ const isSignal = value => value instanceof Signal;
1831
+ class EffectPropData {
1832
+ data;
1833
+ constructor(data) {
1834
+ this.data = data;
1835
+ }
1952
1836
  }
1953
- function getDomContainerFromQContainerElement(qContainerElement) {
1954
- const qElement = qContainerElement;
1955
- let container = qElement.qContainer;
1956
- if (!container) {
1957
- container = new DomContainer(qElement);
1958
- const containerAttributes = {};
1959
- if (qElement) {
1960
- const attrs = qElement.attributes;
1961
- if (attrs) {
1962
- for (let index = 0; index < attrs.length; index++) {
1963
- const attr = attrs[index];
1964
- ":" !== attr.name && (containerAttributes[attr.name] = attr.value);
1837
+ var EffectSubscriptionsProp;
1838
+ var EffectProperty;
1839
+ !function(EffectSubscriptionsProp) {
1840
+ EffectSubscriptionsProp[EffectSubscriptionsProp.EFFECT = 0] = "EFFECT", EffectSubscriptionsProp[EffectSubscriptionsProp.PROPERTY = 1] = "PROPERTY",
1841
+ EffectSubscriptionsProp[EffectSubscriptionsProp.FIRST_BACK_REF_OR_DATA = 2] = "FIRST_BACK_REF_OR_DATA";
1842
+ }(EffectSubscriptionsProp || (EffectSubscriptionsProp = {})), function(EffectProperty) {
1843
+ EffectProperty.COMPONENT = ":", EffectProperty.VNODE = ".";
1844
+ }(EffectProperty || (EffectProperty = {}));
1845
+ class Signal {
1846
+ $untrackedValue$;
1847
+ $effects$=null;
1848
+ $container$=null;
1849
+ constructor(container, value) {
1850
+ this.$container$ = container, this.$untrackedValue$ = value;
1851
+ }
1852
+ get untrackedValue() {
1853
+ return this.$untrackedValue$;
1854
+ }
1855
+ set untrackedValue(value) {
1856
+ this.$untrackedValue$ = value;
1857
+ }
1858
+ get value() {
1859
+ const ctx = tryGetInvokeContext();
1860
+ if (ctx) {
1861
+ if (null === this.$container$) {
1862
+ if (!ctx.$container$) {
1863
+ return this.untrackedValue;
1965
1864
  }
1865
+ this.$container$ = ctx.$container$;
1866
+ } else {
1867
+ assertTrue();
1868
+ }
1869
+ const effectSubscriber = ctx.$effectSubscriber$;
1870
+ if (effectSubscriber) {
1871
+ const effects = this.$effects$ ||= [];
1872
+ ensureContainsEffect(effects, effectSubscriber), ensureContains(effectSubscriber, this),
1873
+ isSubscriber(this) && ensureEffectContainsSubscriber(effectSubscriber[EffectSubscriptionsProp.EFFECT], this, this.$container$);
1966
1874
  }
1967
1875
  }
1968
- container.$serverData$ = {
1969
- containerAttributes
1970
- }, qElement.setAttribute("q:container", QContainerValue.RESUMED), qElement.qContainer = container;
1876
+ return this.untrackedValue;
1877
+ }
1878
+ set value(value) {
1879
+ value !== this.$untrackedValue$ && (this.$untrackedValue$ = value, triggerEffects(this.$container$, this, this.$effects$));
1880
+ }
1881
+ valueOf() {
1882
+ qDev;
1883
+ }
1884
+ toString() {
1885
+ return `[${this.constructor.name}${this.$invalid$ ? " INVALID" : ""} ${String(this.$untrackedValue$)}]` + (this.$effects$?.map((e => "\n -> " + pad(qwikDebugToString(e[0]), " "))).join("\n") || "");
1886
+ }
1887
+ toJSON() {
1888
+ return {
1889
+ value: this.$untrackedValue$
1890
+ };
1971
1891
  }
1972
- return container;
1973
- }
1974
- function _getQContainerElement(element) {
1975
- return (Array.isArray(element) ? vnode_getDomParent(element) : element).closest(QContainerSelector);
1976
1892
  }
1977
- const isDomContainer = container => container instanceof DomContainer;
1978
- class DomContainer extends _SharedContainer {
1979
- element;
1980
- qContainer;
1981
- qBase;
1982
- qManifestHash;
1983
- rootVNode;
1984
- document;
1985
- $journal$;
1986
- renderDone=null;
1987
- $rawStateData$;
1988
- $storeProxyMap$=new WeakMap;
1989
- $qFuncs$;
1990
- $instanceHash$;
1991
- stateData;
1992
- $styleIds$=null;
1993
- $vnodeLocate$=id => vnode_locate(this.rootVNode, id);
1994
- $renderCount$=0;
1995
- constructor(element) {
1996
- super((() => this.scheduleRender()), (() => vnode_applyJournal(this.$journal$)), {}, element.getAttribute("q:locale")),
1997
- this.qContainer = element.getAttribute("q:container"), this.qContainer || throwErrorAndStop("Element must have 'q:container' attribute."),
1998
- this.$journal$ = [ VNodeJournalOpCode.HoistStyles, element.ownerDocument ], this.document = element.ownerDocument,
1999
- this.element = element, this.qBase = element.getAttribute("q:base"), this.$instanceHash$ = element.getAttribute("q:instance"),
2000
- this.qManifestHash = element.getAttribute("q:manifest-hash"), this.rootVNode = vnode_newUnMaterializedElement(this.element),
2001
- this.$rawStateData$ = null, this.stateData = null;
2002
- const document = this.element.ownerDocument;
2003
- document.qVNodeData || function(document) {
2004
- const vNodeDataMap = document.qVNodeData || (document.qVNodeData = new WeakMap);
2005
- const prototype = document.body;
2006
- const getAttribute = prototype.getAttribute;
2007
- const hasAttribute = prototype.hasAttribute;
2008
- const getNodeType = ((prototype, name) => {
2009
- let getter;
2010
- for (;prototype && !(getter = Object.getOwnPropertyDescriptor(prototype, name)?.get); ) {
2011
- prototype = Object.getPrototypeOf(prototype);
1893
+ const ensureContains = (array, value) => {
1894
+ -1 === array.indexOf(value) && array.push(value);
1895
+ };
1896
+ const ensureContainsEffect = (array, effectSubscriptions) => {
1897
+ for (let i = 0; i < array.length; i++) {
1898
+ const existingEffect = array[i];
1899
+ if (existingEffect[0] === effectSubscriptions[0] && existingEffect[1] === effectSubscriptions[1]) {
1900
+ return;
1901
+ }
1902
+ }
1903
+ array.push(effectSubscriptions);
1904
+ };
1905
+ const ensureEffectContainsSubscriber = (effect, subscriber, container) => {
1906
+ if (isSubscriber(effect)) {
1907
+ if (effect.$effectDependencies$ ||= [], subscriberExistInSubscribers(effect.$effectDependencies$, subscriber)) {
1908
+ return;
1909
+ }
1910
+ effect.$effectDependencies$.push(subscriber);
1911
+ } else if (vnode_isVNode(effect) && !vnode_isTextVNode(effect)) {
1912
+ let subscribers = vnode_getProp(effect, "q:subs", container ? container.$getObjectById$ : null);
1913
+ if (subscribers ||= [], subscriberExistInSubscribers(subscribers, subscriber)) {
1914
+ return;
1915
+ }
1916
+ subscribers.push(subscriber), vnode_setProp(effect, "q:subs", subscribers);
1917
+ } else if (isSSRNode(effect)) {
1918
+ let subscribers = effect.getProp("q:subs");
1919
+ if (subscribers ||= [], subscriberExistInSubscribers(subscribers, subscriber)) {
1920
+ return;
1921
+ }
1922
+ subscribers.push(subscriber), effect.setProp("q:subs", subscribers);
1923
+ }
1924
+ };
1925
+ const isSSRNode = effect => "setProp" in effect && "getProp" in effect && "removeProp" in effect && "id" in effect;
1926
+ const subscriberExistInSubscribers = (subscribers, subscriber) => {
1927
+ for (let i = 0; i < subscribers.length; i++) {
1928
+ if (subscribers[i] === subscriber) {
1929
+ return !0;
1930
+ }
1931
+ }
1932
+ return !1;
1933
+ };
1934
+ const triggerEffects = (container, signal, effects) => {
1935
+ if (effects) {
1936
+ const scheduleEffect = effectSubscriptions => {
1937
+ const effect = effectSubscriptions[EffectSubscriptionsProp.EFFECT];
1938
+ const property = effectSubscriptions[EffectSubscriptionsProp.PROPERTY];
1939
+ if (assertDefined(), isTask(effect)) {
1940
+ effect.$flags$ |= TaskFlags.DIRTY;
1941
+ let choreType = ChoreType.TASK;
1942
+ effect.$flags$ & TaskFlags.VISIBLE_TASK ? choreType = ChoreType.VISIBLE : effect.$flags$ & TaskFlags.RESOURCE && (choreType = ChoreType.RESOURCE),
1943
+ container.$scheduler$(choreType, effect);
1944
+ } else if (effect instanceof Signal) {
1945
+ effect instanceof ComputedSignal && (effect.$computeQrl$.resolved || container.$scheduler$(ChoreType.QRL_RESOLVE, null, effect.$computeQrl$)),
1946
+ effect.$invalidate$();
1947
+ } else if (property === EffectProperty.COMPONENT) {
1948
+ const host = effect;
1949
+ const qrl = container.getHostProp(host, "q:renderFn");
1950
+ assertDefined();
1951
+ const props = container.getHostProp(host, "q:props");
1952
+ container.$scheduler$(ChoreType.COMPONENT, host, qrl, props);
1953
+ } else if (property === EffectProperty.VNODE) {
1954
+ container.$scheduler$(ChoreType.NODE_DIFF, effect, effect, signal);
1955
+ } else {
1956
+ const effectData = effectSubscriptions[EffectSubscriptionsProp.FIRST_BACK_REF_OR_DATA];
1957
+ if (effectData instanceof EffectPropData) {
1958
+ const payload = {
1959
+ ...effectData.data,
1960
+ $value$: signal
1961
+ };
1962
+ container.$scheduler$(ChoreType.NODE_PROP, effect, property, payload);
2012
1963
  }
2013
- return getter || function() {
2014
- return this[name];
2015
- };
2016
- })(prototype, "nodeType");
2017
- const attachVnodeDataAndRefs = element => {
2018
- Array.from(element.querySelectorAll('script[type="qwik/vnode"]')).forEach((script => {
2019
- script.setAttribute("type", "x-qwik/vnode");
2020
- const qContainerElement = script.closest("[q\\:container]");
2021
- qContainerElement.qVnodeData = script.textContent, qContainerElement.qVNodeRefs = new Map;
2022
- })), element.querySelectorAll("[q\\:shadowroot]").forEach((parent => {
2023
- const shadowRoot = parent.shadowRoot;
2024
- shadowRoot && attachVnodeDataAndRefs(shadowRoot);
2025
- }));
2026
- };
2027
- let NodeType;
2028
- attachVnodeDataAndRefs(document), function(NodeType) {
2029
- NodeType[NodeType.CONTAINER_MASK = 1] = "CONTAINER_MASK", NodeType[NodeType.ELEMENT = 2] = "ELEMENT",
2030
- NodeType[NodeType.ELEMENT_CONTAINER = 3] = "ELEMENT_CONTAINER", NodeType[NodeType.ELEMENT_SHADOW_ROOT = 6] = "ELEMENT_SHADOW_ROOT",
2031
- NodeType[NodeType.COMMENT_SKIP_START = 5] = "COMMENT_SKIP_START", NodeType[NodeType.COMMENT_SKIP_END = 8] = "COMMENT_SKIP_END",
2032
- NodeType[NodeType.COMMENT_IGNORE_START = 16] = "COMMENT_IGNORE_START", NodeType[NodeType.COMMENT_IGNORE_END = 32] = "COMMENT_IGNORE_END",
2033
- NodeType[NodeType.COMMENT_ISLAND_START = 65] = "COMMENT_ISLAND_START", NodeType[NodeType.COMMENT_ISLAND_END = 128] = "COMMENT_ISLAND_END",
2034
- NodeType[NodeType.OTHER = 0] = "OTHER";
2035
- }(NodeType || (NodeType = {}));
2036
- const getFastNodeType = node => {
2037
- const nodeType = getNodeType.call(node);
2038
- if (1 === nodeType) {
2039
- return null === getAttribute.call(node, "q:container") ? hasAttribute.call(node, "q:shadowroot") ? NodeType.ELEMENT_SHADOW_ROOT : hasAttribute.call(node, ":") ? NodeType.ELEMENT : NodeType.OTHER : NodeType.ELEMENT_CONTAINER;
2040
- }
2041
- if (8 === nodeType) {
2042
- const nodeValue = node.nodeValue || "";
2043
- if (nodeValue.startsWith("q:container-island")) {
2044
- return NodeType.COMMENT_ISLAND_START;
2045
- }
2046
- if (nodeValue.startsWith("q:ignore")) {
2047
- return NodeType.COMMENT_IGNORE_START;
2048
- }
2049
- if (nodeValue.startsWith("q:container")) {
2050
- return NodeType.COMMENT_SKIP_START;
2051
- }
2052
- if (nodeValue.startsWith("/q:container-island")) {
2053
- return NodeType.COMMENT_ISLAND_END;
2054
- }
2055
- if (nodeValue.startsWith("/q:ignore")) {
2056
- return NodeType.COMMENT_IGNORE_END;
2057
- }
2058
- if (nodeValue.startsWith("/q:container")) {
2059
- return NodeType.COMMENT_SKIP_END;
2060
- }
2061
- }
2062
- return NodeType.OTHER;
2063
- };
2064
- const isSeparator = ch => VNodeDataSeparator_ADVANCE_1 <= ch && ch <= VNodeDataSeparator_ADVANCE_8192;
2065
- const findVDataSectionEnd = (vData, start, end) => {
2066
- let depth = 0;
2067
- for (;start < end; ) {
2068
- const ch = vData.charCodeAt(start);
2069
- if (0 === depth && isSeparator(ch)) {
2070
- break;
2071
- }
2072
- ch === VNodeDataChar_OPEN ? depth++ : ch === VNodeDataChar_CLOSE && depth--, start++;
2073
- }
2074
- return start;
2075
- };
2076
- const nextSibling = node => {
2077
- for (;node && (node = node.nextSibling) && getFastNodeType(node) === NodeType.OTHER; ) {}
2078
- return node;
2079
- };
2080
- const firstChild = node => {
2081
- for (;node && (node = node.firstChild) && getFastNodeType(node) === NodeType.OTHER; ) {}
2082
- return node;
2083
- };
2084
- const walkContainer = (walker, containerNode, node, exitNode, vData, qVNodeRefs) => {
2085
- const vData_length = vData.length;
2086
- let elementIdx = 0;
2087
- let vNodeElementIndex = -1;
2088
- let vData_start = 0;
2089
- let vData_end = 0;
2090
- let ch = 0;
2091
- let needsToStoreRef = -1;
2092
- let nextNode = null;
2093
- const howManyElementsToSkip = () => {
2094
- let elementsToSkip = 0;
2095
- for (;isSeparator(ch = vData.charCodeAt(vData_start)) && (elementsToSkip += 1 << ch - VNodeDataSeparator_ADVANCE_1,
2096
- vData_start++, !(vData_start >= vData_length)); ) {}
2097
- return elementsToSkip;
2098
- };
2099
- do {
2100
- if (node === exitNode) {
2101
- return;
2102
- }
2103
- nextNode = null;
2104
- const nodeType = node == containerNode ? NodeType.ELEMENT : getFastNodeType(node);
2105
- if (nodeType === NodeType.ELEMENT_CONTAINER) {
2106
- const container = node;
2107
- let cursor = node;
2108
- for (;cursor && !(nextNode = nextSibling(cursor)); ) {
2109
- cursor = cursor.parentNode;
2110
- }
2111
- walkContainer(walker, container, node, nextNode, container.qVnodeData || "", container.qVNodeRefs);
2112
- } else if (nodeType === NodeType.COMMENT_IGNORE_START) {
2113
- let islandNode = node;
2114
- do {
2115
- if (islandNode = walker.nextNode(), !islandNode) {
2116
- throw new Error(`Island inside \x3c!--${node?.nodeValue}--\x3e not found!`);
2117
- }
2118
- } while (getFastNodeType(islandNode) !== NodeType.COMMENT_ISLAND_START);
2119
- nextNode = null;
2120
- } else if (nodeType === NodeType.COMMENT_ISLAND_END) {
2121
- nextNode = node;
2122
- do {
2123
- if (nextNode = walker.nextNode(), !nextNode) {
2124
- throw new Error("Ignore block not closed!");
2125
- }
2126
- } while (getFastNodeType(nextNode) !== NodeType.COMMENT_IGNORE_END);
2127
- nextNode = null;
2128
- } else if (nodeType === NodeType.COMMENT_SKIP_START) {
2129
- nextNode = node;
2130
- do {
2131
- if (nextNode = nextSibling(nextNode), !nextNode) {
2132
- throw new Error(`\x3c!--${node?.nodeValue}--\x3e not closed!`);
2133
- }
2134
- } while (getFastNodeType(nextNode) !== NodeType.COMMENT_SKIP_END);
2135
- walkContainer(walker, node, node, nextNode, "", null);
2136
- } else if (nodeType === NodeType.ELEMENT_SHADOW_ROOT) {
2137
- nextNode = nextSibling(node);
2138
- const shadowRootContainer = node;
2139
- const shadowRoot = shadowRootContainer?.shadowRoot;
2140
- shadowRoot && walkContainer(document.createTreeWalker(shadowRoot, 129), null, firstChild(shadowRoot), null, "", null);
2141
- }
2142
- if ((nodeType & NodeType.ELEMENT) === NodeType.ELEMENT) {
2143
- if (vNodeElementIndex < elementIdx && (-1 === vNodeElementIndex && (vNodeElementIndex = 0),
2144
- vData_start = vData_end, vData_start < vData_length ? (vNodeElementIndex += howManyElementsToSkip(),
2145
- ch === VNodeDataSeparator_REFERENCE && (needsToStoreRef = vNodeElementIndex, vData_start++,
2146
- ch = vData_start < vData_length ? vData.charCodeAt(vData_end) : VNodeDataSeparator_ADVANCE_1),
2147
- vData_end = findVDataSectionEnd(vData, vData_start, vData_length)) : vNodeElementIndex = Number.MAX_SAFE_INTEGER),
2148
- elementIdx === vNodeElementIndex) {
2149
- needsToStoreRef === elementIdx && qVNodeRefs.set(elementIdx, node);
2150
- const instructions = vData.substring(vData_start, vData_end);
2151
- vNodeDataMap.set(node, instructions);
2152
- }
2153
- elementIdx++;
2154
- }
2155
- } while (node = nextNode || walker.nextNode());
2156
- };
2157
- const walker = document.createTreeWalker(document, 129);
2158
- walkContainer(walker, null, walker.firstChild(), null, "", null);
2159
- }(document), this.$rawStateData$ = [], this.stateData = [];
2160
- const qwikStates = element.querySelectorAll('script[type="qwik/state"]');
2161
- if (0 !== qwikStates.length) {
2162
- this.$rawStateData$ = JSON.parse(qwikStates[qwikStates.length - 1].textContent),
2163
- this.stateData = wrapDeserializerProxy(this, this.$rawStateData$);
2164
- }
2165
- this.$qFuncs$ = getQFuncs(document, this.$instanceHash$) || EMPTY_ARRAY;
1964
+ }
1965
+ };
1966
+ effects.forEach(scheduleEffect);
2166
1967
  }
2167
- $setRawState$(id, vParent) {
2168
- this.stateData[id] = vParent;
1968
+ };
1969
+ class ComputedSignal extends Signal {
1970
+ $computeQrl$;
1971
+ $invalid$=!0;
1972
+ $forceRunEffects$=!1;
1973
+ constructor(container, fn) {
1974
+ super(container, NEEDS_COMPUTATION), this.$computeQrl$ = fn;
2169
1975
  }
2170
- parseQRL(qrl) {
2171
- return inflateQRL(this, parseQRL(qrl));
1976
+ $invalidate$() {
1977
+ this.$invalid$ = !0, this.$forceRunEffects$ = !1, this.$container$?.$scheduler$(ChoreType.RECOMPUTE_AND_SCHEDULE_EFFECTS, null, this);
2172
1978
  }
2173
- handleError(err, host) {
2174
- const errorStore = this.resolveContext(host, ERROR_CONTEXT);
2175
- if (!errorStore) {
2176
- throw err;
2177
- }
2178
- errorStore.error = err;
1979
+ force() {
1980
+ this.$invalid$ = !0, this.$forceRunEffects$ = !1, triggerEffects(this.$container$, this, this.$effects$);
2179
1981
  }
2180
- setContext(host, context, value) {
2181
- let ctx = this.getHostProp(host, "q:ctx");
2182
- ctx || this.setHostProp(host, "q:ctx", ctx = []), mapArray_set(ctx, context.id, value, 0);
1982
+ get untrackedValue() {
1983
+ const didChange = this.$computeIfNeeded$();
1984
+ return didChange && (this.$forceRunEffects$ = didChange), assertFalse(), this.$untrackedValue$;
2183
1985
  }
2184
- resolveContext(host, contextId) {
2185
- for (;host; ) {
2186
- const ctx = this.getHostProp(host, "q:ctx");
2187
- if (ctx) {
2188
- const value = mapArray_get(ctx, contextId.id, 0);
2189
- if (value) {
2190
- return value;
2191
- }
2192
- }
2193
- host = this.getParentHost(host);
1986
+ $computeIfNeeded$() {
1987
+ if (!this.$invalid$) {
1988
+ return !1;
2194
1989
  }
2195
- }
2196
- getParentHost(host) {
2197
- let vNode = vnode_getParent(host);
2198
- for (;vNode; ) {
2199
- if (vnode_isVirtualVNode(vNode)) {
2200
- if (null !== vnode_getProp(vNode, "q:renderFn", null)) {
2201
- return vNode;
2202
- }
2203
- const parent = vnode_getProp(vNode, ":", this.$vnodeLocate$);
2204
- if (parent) {
2205
- vNode = parent;
2206
- continue;
2207
- }
1990
+ const computeQrl = this.$computeQrl$;
1991
+ throwIfQRLNotResolved(computeQrl);
1992
+ const ctx = tryGetInvokeContext();
1993
+ const previousEffectSubscription = ctx?.$effectSubscriber$;
1994
+ ctx && (ctx.$effectSubscriber$ = [ this, EffectProperty.VNODE ]);
1995
+ try {
1996
+ const untrackedValue = computeQrl.getFn(ctx)();
1997
+ if (isPromise(untrackedValue)) {
1998
+ throw qError(QError.computedNotSync, [ computeQrl.dev ? computeQrl.dev.file : "", computeQrl.$hash$ ]);
2208
1999
  }
2209
- vNode = vnode_getParent(vNode);
2000
+ this.$invalid$ = !1;
2001
+ const didChange = untrackedValue !== this.$untrackedValue$;
2002
+ return didChange && (this.$untrackedValue$ = untrackedValue), didChange;
2003
+ } finally {
2004
+ ctx && (ctx.$effectSubscriber$ = previousEffectSubscription);
2210
2005
  }
2211
- return null;
2212
2006
  }
2213
- setHostProp(host, name, value) {
2214
- vnode_setProp(host, name, value);
2007
+ get value() {
2008
+ return super.value;
2215
2009
  }
2216
- getHostProp(host, name) {
2217
- const vNode = host;
2218
- let getObjectById = null;
2219
- switch (name) {
2220
- case "q:seq":
2221
- case "q:props":
2222
- case "q:renderFn":
2223
- case "q:ctx":
2224
- case "q:subs":
2225
- getObjectById = this.$getObjectById$;
2226
- break;
2227
-
2228
- case "q:seqIdx":
2229
- case ":onIdx":
2230
- getObjectById = parseInt;
2231
- }
2232
- return vnode_getProp(vNode, name, getObjectById);
2010
+ set value(_) {
2011
+ throw qError(QError.computedReadOnly);
2233
2012
  }
2234
- scheduleRender() {
2235
- return this.$renderCount$++, this.renderDone ||= getPlatform().nextTick((() => this.processChores())),
2236
- this.renderDone;
2013
+ }
2014
+ class WrappedSignal extends Signal {
2015
+ $args$;
2016
+ $func$;
2017
+ $funcStr$;
2018
+ $invalid$=!0;
2019
+ $effectDependencies$=null;
2020
+ $hostElement$=null;
2021
+ $forceRunEffects$=!1;
2022
+ constructor(container, fn, args, fnStr) {
2023
+ super(container, NEEDS_COMPUTATION), this.$args$ = args, this.$func$ = fn, this.$funcStr$ = fnStr;
2237
2024
  }
2238
- processChores() {
2239
- let renderCount = this.$renderCount$;
2240
- const result = this.$scheduler$(ChoreType.WAIT_FOR_ALL);
2241
- if (isPromise(result)) {
2242
- return result.then((async () => {
2243
- for (;renderCount !== this.$renderCount$; ) {
2244
- renderCount = this.$renderCount$, await this.$scheduler$(ChoreType.WAIT_FOR_ALL);
2245
- }
2246
- this.renderDone = null;
2247
- }));
2248
- }
2249
- renderCount === this.$renderCount$ ? this.renderDone = null : this.processChores();
2250
- }
2251
- ensureProjectionResolved(vNode) {
2252
- if (!(vNode[VNodeProps.flags] & VNodeFlags.Resolved)) {
2253
- vNode[VNodeProps.flags] |= VNodeFlags.Resolved;
2254
- for (let i = vnode_getPropStartIndex(vNode); i < vNode.length; i += 2) {
2255
- if (isSlotProp(vNode[i])) {
2256
- const value = vNode[i + 1];
2257
- "string" == typeof value && (vNode[i + 1] = this.$vnodeLocate$(value));
2258
- }
2259
- }
2260
- }
2025
+ $invalidate$() {
2026
+ this.$invalid$ = !0, this.$forceRunEffects$ = !1, this.$container$?.$scheduler$(ChoreType.RECOMPUTE_AND_SCHEDULE_EFFECTS, this.$hostElement$, this);
2261
2027
  }
2262
- $getObjectById$=id => ("string" == typeof id && (id = parseFloat(id)), assertTrue(),
2263
- this.stateData[id]);
2264
- getSyncFn(id) {
2265
- const fn = this.$qFuncs$[id];
2266
- return assertTrue(), fn;
2028
+ force() {
2029
+ this.$invalid$ = !0, this.$forceRunEffects$ = !1, triggerEffects(this.$container$, this, this.$effects$);
2267
2030
  }
2268
- $appendStyle$(content, styleId, host, scoped) {
2269
- if (scoped) {
2270
- const scopedStyleIdsString = this.getHostProp(host, "q:sstyle");
2271
- const scopedStyleIds = new Set(function(scopedStyleIds) {
2272
- return scopedStyleIds?.split(" ") ?? null;
2273
- }(scopedStyleIdsString));
2274
- scopedStyleIds.add(styleId), this.setHostProp(host, "q:sstyle", function(scopedStyleIds) {
2275
- return Array.from(scopedStyleIds).join(" ");
2276
- }(scopedStyleIds));
2277
- }
2278
- if (null == this.$styleIds$ && (this.$styleIds$ = new Set, this.element.querySelectorAll("style[q\\:style]").forEach((style => {
2279
- this.$styleIds$.add(style.getAttribute("q:style"));
2280
- }))), !this.$styleIds$.has(styleId)) {
2281
- this.$styleIds$.add(styleId);
2282
- const styleElement = this.document.createElement("style");
2283
- styleElement.setAttribute("q:style", styleId), styleElement.textContent = content,
2284
- this.$journal$.push(VNodeJournalOpCode.Insert, this.document.head, null, styleElement);
2285
- }
2031
+ get untrackedValue() {
2032
+ const didChange = this.$computeIfNeeded$();
2033
+ return didChange && (this.$forceRunEffects$ = didChange), assertFalse(), this.$untrackedValue$;
2286
2034
  }
2287
- }
2288
- let _context;
2289
- const tryGetInvokeContext = () => {
2290
- if (!_context) {
2291
- const context = "undefined" != typeof document && document && document.__q_context__;
2292
- if (!context) {
2293
- return;
2035
+ $computeIfNeeded$() {
2036
+ if (!this.$invalid$) {
2037
+ return !1;
2294
2038
  }
2295
- return isArray(context) ? document.__q_context__ = newInvokeContextFromTuple(context) : context;
2296
- }
2297
- return _context;
2298
- };
2299
- const getInvokeContext = () => {
2300
- const ctx = tryGetInvokeContext();
2301
- if (!ctx) {
2302
- throw qError(14);
2303
- }
2304
- return ctx;
2305
- };
2306
- const useInvokeContext = () => {
2307
- const ctx = tryGetInvokeContext();
2308
- if (!ctx || "qRender" !== ctx.$event$) {
2309
- throw qError(20);
2039
+ const untrackedValue = trackSignal((() => this.$func$(...this.$args$)), this, EffectProperty.VNODE, this.$container$);
2040
+ const didChange = untrackedValue !== this.$untrackedValue$;
2041
+ return didChange && (this.$untrackedValue$ = untrackedValue), didChange;
2310
2042
  }
2311
- return assertDefined(), assertDefined(), ctx;
2312
- };
2313
- function useBindInvokeContext(fn) {
2314
- if (null == fn) {
2315
- return fn;
2043
+ get value() {
2044
+ return super.value;
2316
2045
  }
2317
- const ctx = getInvokeContext();
2318
- return function(...args) {
2319
- return invokeApply.call(this, ctx, fn, args);
2320
- };
2321
- }
2322
- function invoke(context, fn, ...args) {
2323
- return invokeApply.call(this, context, fn, args);
2324
- }
2325
- function invokeApply(context, fn, args) {
2326
- const previousContext = _context;
2327
- let returnValue;
2328
- try {
2329
- _context = context, returnValue = fn.apply(this, args);
2330
- } finally {
2331
- _context = previousContext;
2046
+ set value(_) {
2047
+ throw qError(QError.wrappedReadOnly);
2332
2048
  }
2333
- return returnValue;
2334
2049
  }
2335
- const newInvokeContextFromTuple = ([element, event, url]) => {
2336
- const container = element.closest(QContainerSelector);
2337
- const locale = container?.getAttribute("q:locale") || void 0;
2338
- return locale && function(locale) {
2339
- _locale = locale;
2340
- }(locale), newInvokeContext(locale, void 0, element, event, url);
2341
- };
2342
- const newInvokeContext = (locale, hostElement, element, event, url) => {
2343
- const ctx = {
2344
- $url$: url,
2345
- $i$: 0,
2346
- $hostElement$: hostElement,
2347
- $element$: element,
2348
- $event$: event,
2349
- $qrl$: void 0,
2350
- $effectSubscriber$: void 0,
2351
- $locale$: locale || ("object" == typeof event && event && "locale" in event ? event.locale : void 0),
2352
- $container$: void 0
2353
- };
2354
- return seal(), ctx;
2355
- };
2356
- const untrack = fn => invoke(void 0, fn);
2357
- const trackInvocation = /*#__PURE__*/ newInvokeContext(void 0, void 0, void 0, "qRender");
2358
- const trackSignal = (fn, subscriber, property, container, data) => {
2359
- const previousSubscriber = trackInvocation.$effectSubscriber$;
2360
- const previousContainer = trackInvocation.$container$;
2361
- try {
2362
- return trackInvocation.$effectSubscriber$ = [ subscriber, property ], data && trackInvocation.$effectSubscriber$.push(data),
2363
- trackInvocation.$container$ = container, invoke(trackInvocation, fn);
2364
- } finally {
2365
- trackInvocation.$effectSubscriber$ = previousSubscriber, trackInvocation.$container$ = previousContainer;
2366
- }
2367
- };
2368
2050
  class ParentComponentData {
2369
2051
  $scopedStyle$;
2370
2052
  $componentFrame$;
@@ -2395,11 +2077,17 @@
2395
2077
  });
2396
2078
  } else {
2397
2079
  if (value === Promise) {
2398
- return options.allowPromises ? void stack.pop().then(resolveValue, rejectDrain) : throwErrorAndStop("Promises not expected here.");
2080
+ if (!options.allowPromises) {
2081
+ throw qError(QError.promisesNotExpected);
2082
+ }
2083
+ return void stack.pop().then(resolveValue, rejectDrain);
2399
2084
  }
2400
2085
  const waitOn = value.apply(ssr);
2401
2086
  if (waitOn) {
2402
- return options.allowPromises ? void waitOn.then(drain, rejectDrain) : throwErrorAndStop("Promises not expected here.");
2087
+ if (!options.allowPromises) {
2088
+ throw qError(QError.promisesNotExpected);
2089
+ }
2090
+ return void waitOn.then(drain, rejectDrain);
2403
2091
  }
2404
2092
  }
2405
2093
  }
@@ -2424,7 +2112,7 @@
2424
2112
  } else if (isSignal(value)) {
2425
2113
  ssr.openFragment(build.isDev ? [ "q:type", VirtualType.WrappedSignal ] : EMPTY_ARRAY);
2426
2114
  const signalNode = ssr.getLastNode();
2427
- enqueue(ssr.closeFragment), enqueue(trackSignal((() => value.value), signalNode, EffectProperty.VNODE, ssr));
2115
+ enqueue(ssr.closeFragment), enqueue(trackSignalAndAssignHost(value, signalNode, EffectProperty.VNODE, ssr));
2428
2116
  } else if (isPromise(value)) {
2429
2117
  ssr.openFragment(build.isDev ? [ "q:type", VirtualType.Awaited ] : EMPTY_ARRAY),
2430
2118
  enqueue(ssr.closeFragment), enqueue(value), enqueue(Promise), enqueue((() => ssr.commentNode("qkssr-f")));
@@ -2450,13 +2138,7 @@
2450
2138
  jsx.constProps.class = "");
2451
2139
  }(jsx, options.styleScoped);
2452
2140
  let qwikInspectorAttrValue = null;
2453
- build.isDev && jsx.dev && "head" !== jsx.type && (qwikInspectorAttrValue = function(jsxDev) {
2454
- const sanitizedFileName = jsxDev.fileName?.replace(/\\/g, "/");
2455
- if (sanitizedFileName) {
2456
- return `${sanitizedFileName}:${jsxDev.lineNumber}:${jsxDev.columnNumber}`;
2457
- }
2458
- return null;
2459
- }(jsx.dev));
2141
+ build.isDev && jsx.dev && "head" !== jsx.type && (qwikInspectorAttrValue = getFileLocationFromJsx(jsx.dev));
2460
2142
  const innerHTML = ssr.openElement(type, toSsrAttrs(jsx.varProps, jsx.constProps, ssr.serializationCtx, !0, options.styleScoped, jsx.key), function(constProps, varProps, serializationCtx, styleScopedId) {
2461
2143
  return toSsrAttrs(constProps, varProps, serializationCtx, !1, styleScopedId);
2462
2144
  }(jsx.constProps, jsx.varProps, ssr.serializationCtx, options.styleScoped), qwikInspectorAttrValue);
@@ -2483,7 +2165,7 @@
2483
2165
  if (constProps && "object" == typeof constProps && "name" in constProps) {
2484
2166
  const constValue = constProps.name;
2485
2167
  if (constValue instanceof WrappedSignal) {
2486
- return trackSignal((() => constValue.value), host, EffectProperty.COMPONENT, ssr);
2168
+ return trackSignalAndAssignHost(constValue, host, EffectProperty.COMPONENT, ssr);
2487
2169
  }
2488
2170
  }
2489
2171
  return directGetPropsProxyProp(jsx, "name") || "";
@@ -2617,6 +2299,29 @@
2617
2299
  const eventName = key.substring(15);
2618
2300
  eventName && serializationCtx.$eventNames$.add(eventName);
2619
2301
  }
2302
+ const version = "2.0.0-alpha.5-dev+cb53bbd";
2303
+ class _SharedContainer {
2304
+ $version$;
2305
+ $scheduler$;
2306
+ $storeProxyMap$;
2307
+ $locale$;
2308
+ $getObjectById$;
2309
+ $serverData$;
2310
+ $currentUniqueId$=0;
2311
+ $instanceHash$=null;
2312
+ constructor(scheduleDrain, journalFlush, serverData, locale) {
2313
+ this.$serverData$ = serverData, this.$locale$ = locale, this.$version$ = version,
2314
+ this.$storeProxyMap$ = new WeakMap, this.$getObjectById$ = () => {
2315
+ throw Error("Not implemented");
2316
+ }, this.$scheduler$ = createScheduler(this, scheduleDrain, journalFlush);
2317
+ }
2318
+ trackSignalValue(signal, subscriber, property, data) {
2319
+ return trackSignalAndAssignHost(signal, subscriber, property, this, data);
2320
+ }
2321
+ serializationCtxFactory(NodeConstructor, DomRefConstructor, symbolToChunkResolver, writer, prepVNodeData) {
2322
+ return createSerializationContext(NodeConstructor, DomRefConstructor, symbolToChunkResolver, this.getHostProp.bind(this), this.setHostProp.bind(this), this.$storeProxyMap$, writer, prepVNodeData);
2323
+ }
2324
+ }
2620
2325
  const _CONST_PROPS = Symbol("CONST");
2621
2326
  const _VAR_PROPS = Symbol("VAR");
2622
2327
  const _IMMUTABLE = Symbol("IMMUTABLE");
@@ -2823,6 +2528,8 @@
2823
2528
  }
2824
2529
  return String(value);
2825
2530
  };
2531
+ const VNodeDataSeparator_REFERENCE = 126, VNodeDataSeparator_ADVANCE_1 = 33, VNodeDataSeparator_ADVANCE_8192 = 46;
2532
+ const VNodeDataChar_OPEN = 123, VNodeDataChar_CLOSE = 125, VNodeDataChar_SCOPED_STYLE = 59, VNodeDataChar_RENDER_FN = 60, VNodeDataChar_ID = 61, VNodeDataChar_PROPS = 62, VNodeDataChar_SLOT_REF = 63, VNodeDataChar_KEY = 64, VNodeDataChar_SEQ = 91, VNodeDataChar_CONTEXT = 93, VNodeDataChar_SEQ_IDX = 94, VNodeDataChar_SUBS = 96, VNodeDataChar_SEPARATOR = 124, VNodeDataChar_SLOT = 126;
2826
2533
  var VNodeJournalOpCode;
2827
2534
  !function(VNodeJournalOpCode) {
2828
2535
  VNodeJournalOpCode[VNodeJournalOpCode.SetText = 1] = "SetText", VNodeJournalOpCode[VNodeJournalOpCode.SetAttribute = 2] = "SetAttribute",
@@ -2841,12 +2548,6 @@
2841
2548
  return assertTrue(vnode_isElementVNode(vnode)), assertFalse(vnode_isTextVNode(vnode)),
2842
2549
  assertFalse(vnode_isVirtualVNode(vnode)), vnode;
2843
2550
  };
2844
- const vnode_newSharedText = (previousTextNode, sharedTextNode, textContent) => {
2845
- sharedTextNode && assertEqual(fastNodeType(sharedTextNode));
2846
- const vnode = VNodeArray.createText(VNodeFlags.Text | -1 << VNodeFlagsIndex.shift, null, previousTextNode, null, sharedTextNode, textContent);
2847
- return assertFalse(vnode_isElementVNode(vnode)), assertTrue(vnode_isTextVNode(vnode)),
2848
- assertFalse(vnode_isVirtualVNode(vnode)), vnode;
2849
- };
2850
2551
  const vnode_newText = (textNode, textContent) => {
2851
2552
  const vnode = VNodeArray.createText(VNodeFlags.Text | VNodeFlags.Inflated | -1 << VNodeFlagsIndex.shift, null, null, null, textNode, textContent);
2852
2553
  return assertEqual(fastNodeType(textNode)), assertFalse(vnode_isElementVNode(vnode)),
@@ -3289,107 +2990,118 @@
3289
2990
  let vFirstChild = vnode[ElementVNodeProps.firstChild];
3290
2991
  return void 0 === vFirstChild && (vFirstChild = ensureMaterialized(vnode)), vFirstChild;
3291
2992
  };
3292
- const vnode_materialize = vNode => {
3293
- const element = vNode[ElementVNodeProps.element];
3294
- const firstChild = fastFirstChild(element);
3295
- const vNodeData = element.ownerDocument?.qVNodeData?.get(element);
3296
- const vFirstChild = vNodeData ? function(vParent, vData, element, child) {
3297
- let idx = 0;
3298
- let nextToConsumeIdx = 0;
3299
- let vFirst = null;
3300
- let vLast = null;
3301
- let previousTextNode = null;
3302
- let ch = 0;
3303
- let peekCh = 0;
3304
- const peek = () => 0 !== peekCh ? peekCh : peekCh = nextToConsumeIdx < vData.length ? vData.charCodeAt(nextToConsumeIdx) : 0;
3305
- const consume = () => (ch = peek(), peekCh = 0, nextToConsumeIdx++, ch);
3306
- const addVNode = node => {
3307
- node[VNodeProps.flags] = node[VNodeProps.flags] & VNodeFlagsIndex.negated_mask | idx << VNodeFlagsIndex.shift,
3308
- idx++, vLast && (vLast[VNodeProps.nextSibling] = node), node[VNodeProps.previousSibling] = vLast,
3309
- node[VNodeProps.parent] = vParent, vFirst || (vParent[ElementVNodeProps.firstChild] = vFirst = node),
3310
- vLast = node;
3311
- };
3312
- const consumeValue = () => {
3313
- consume();
3314
- const start = nextToConsumeIdx;
3315
- for (;peek() <= 58 && 0 !== peekCh || 95 === peekCh || peekCh >= 65 && peekCh <= 90 || peekCh >= 97 && peekCh <= 122; ) {
3316
- consume();
2993
+ const materialize = (vNode, element, firstChild, vNodeData) => {
2994
+ if (vNodeData) {
2995
+ if (vNodeData.charCodeAt(0) === VNodeDataChar_SEPARATOR) {
2996
+ const elementVNodeDataStartIdx = 1;
2997
+ let elementVNodeDataEndIdx = 1;
2998
+ for (;vNodeData.charCodeAt(elementVNodeDataEndIdx) !== VNodeDataChar_SEPARATOR; ) {
2999
+ elementVNodeDataEndIdx++;
3317
3000
  }
3318
- return vData.substring(start, nextToConsumeIdx);
3319
- };
3320
- let textIdx = 0;
3321
- let combinedText = null;
3322
- let container = null;
3323
- for (;0 !== peek(); ) {
3324
- if (isNumber(peek())) {
3325
- for (;!isElement(child); ) {
3326
- (child = fastNextSibling(child)) || throwErrorAndStop("Materialize error: missing element: " + vData + " " + peek() + " " + nextToConsumeIdx);
3327
- }
3328
- for (;isQStyleElement(child); ) {
3329
- child = fastNextSibling(child);
3330
- }
3331
- combinedText = null, previousTextNode = null;
3332
- let value = 0;
3333
- for (;isNumber(peek()); ) {
3334
- value *= 10, value += consume() - 48;
3335
- }
3336
- for (;value--; ) {
3337
- addVNode(vnode_newUnMaterializedElement(child)), child = fastNextSibling(child);
3338
- }
3339
- } else if (peek() === VNodeDataChar_SCOPED_STYLE) {
3340
- vnode_setAttr(null, vParent, "q:sstyle", consumeValue());
3341
- } else if (peek() === VNodeDataChar_RENDER_FN) {
3342
- vnode_setAttr(null, vParent, "q:renderFn", consumeValue());
3343
- } else if (peek() === VNodeDataChar_ID) {
3344
- container || (container = getDomContainer(element));
3345
- const id = consumeValue();
3346
- container.$setRawState$(parseInt(id), vParent), build.isDev && vnode_setAttr(null, vParent, "q:id", id);
3347
- } else if (peek() === VNodeDataChar_PROPS) {
3348
- vnode_setAttr(null, vParent, "q:props", consumeValue());
3349
- } else if (peek() === VNodeDataChar_SLOT_REF) {
3350
- vnode_setAttr(null, vParent, "q:sref", consumeValue());
3351
- } else if (peek() === VNodeDataChar_KEY) {
3352
- vnode_setAttr(null, vParent, "q:key", consumeValue());
3353
- } else if (peek() === VNodeDataChar_SEQ) {
3354
- vnode_setAttr(null, vParent, "q:seq", consumeValue());
3355
- } else if (peek() === VNodeDataChar_SEQ_IDX) {
3356
- vnode_setAttr(null, vParent, "q:seqIdx", consumeValue());
3357
- } else if (peek() === VNodeDataChar_CONTEXT) {
3358
- vnode_setAttr(null, vParent, "q:ctx", consumeValue());
3359
- } else if (peek() === VNodeDataChar_OPEN) {
3360
- consume(), addVNode(vnode_newVirtual()), stack.push(vParent, vFirst, vLast, previousTextNode, idx),
3361
- idx = 0, vParent = vLast, vFirst = vLast = null;
3362
- } else if (peek() === VNodeDataChar_SEPARATOR) {
3363
- const key = consumeValue();
3364
- const value = consumeValue();
3365
- vnode_setAttr(null, vParent, key, value);
3366
- } else if (peek() === VNodeDataChar_CLOSE) {
3367
- consume(), vParent[ElementVNodeProps.lastChild] = vLast, idx = stack.pop(), previousTextNode = stack.pop(),
3368
- vLast = stack.pop(), vFirst = stack.pop(), vParent = stack.pop();
3369
- } else if (peek() === VNodeDataChar_SLOT) {
3370
- vnode_setAttr(null, vParent, QSlot, consumeValue());
3371
- } else {
3372
- const textNode = child && 3 === fastNodeType(child) ? child : null;
3373
- null === combinedText && (combinedText = textNode ? textNode.nodeValue : null, textIdx = 0);
3374
- let length = 0;
3375
- for (;isLowercase(peek()); ) {
3376
- length += consume() - 97, length *= 26;
3377
- }
3378
- length += consume() - 65;
3379
- const text = null === combinedText ? "" : combinedText.substring(textIdx, textIdx + length);
3380
- addVNode(previousTextNode = vnode_newSharedText(previousTextNode, textNode, text)),
3381
- textIdx += length;
3001
+ const elementVNodeData = vNodeData.substring(elementVNodeDataStartIdx, elementVNodeDataEndIdx);
3002
+ vNodeData = vNodeData.substring(elementVNodeDataEndIdx + 1);
3003
+ const vFirstChild = materializeFromDOM(vNode, firstChild, elementVNodeData);
3004
+ if (!vNodeData) {
3005
+ return vFirstChild;
3382
3006
  }
3383
3007
  }
3384
- return vParent[ElementVNodeProps.lastChild] = vLast, vFirst;
3385
- }(vNode, vNodeData, element, firstChild) : materializeFromDOM(vNode, firstChild);
3386
- return vFirstChild;
3008
+ return function(vParent, vData, element, child) {
3009
+ let idx = 0;
3010
+ let vFirst = null;
3011
+ let vLast = null;
3012
+ let previousTextNode = null;
3013
+ const addVNode = node => {
3014
+ node[VNodeProps.flags] = node[VNodeProps.flags] & VNodeFlagsIndex.negated_mask | idx << VNodeFlagsIndex.shift,
3015
+ idx++, vLast && (vLast[VNodeProps.nextSibling] = node), node[VNodeProps.previousSibling] = vLast,
3016
+ node[VNodeProps.parent] = vParent, vFirst || (vParent[ElementVNodeProps.firstChild] = vFirst = node),
3017
+ vLast = node;
3018
+ };
3019
+ let textIdx = 0;
3020
+ let combinedText = null;
3021
+ let container = null;
3022
+ return processVNodeData$1(vData, ((peek, consumeValue, consume, nextToConsumeIdx) => {
3023
+ if (isNumber(peek())) {
3024
+ for (;!isElement(child); ) {
3025
+ if (!(child = fastNextSibling(child))) {
3026
+ throw qError(QError.materializeVNodeDataError, [ vData, peek(), nextToConsumeIdx ]);
3027
+ }
3028
+ }
3029
+ for (;isQStyleElement(child); ) {
3030
+ child = fastNextSibling(child);
3031
+ }
3032
+ combinedText = null, previousTextNode = null;
3033
+ let value = 0;
3034
+ for (;isNumber(peek()); ) {
3035
+ value *= 10, value += consume() - 48;
3036
+ }
3037
+ for (;value--; ) {
3038
+ addVNode(vnode_newUnMaterializedElement(child)), child = fastNextSibling(child);
3039
+ }
3040
+ } else if (peek() === VNodeDataChar_SCOPED_STYLE) {
3041
+ vnode_setAttr(null, vParent, "q:sstyle", consumeValue());
3042
+ } else if (peek() === VNodeDataChar_RENDER_FN) {
3043
+ vnode_setAttr(null, vParent, "q:renderFn", consumeValue());
3044
+ } else if (peek() === VNodeDataChar_ID) {
3045
+ container || (container = getDomContainer(element));
3046
+ const id = consumeValue();
3047
+ container.$setRawState$(parseInt(id), vParent), build.isDev && vnode_setAttr(null, vParent, "q:id", id);
3048
+ } else if (peek() === VNodeDataChar_PROPS) {
3049
+ vnode_setAttr(null, vParent, "q:props", consumeValue());
3050
+ } else if (peek() === VNodeDataChar_SLOT_REF) {
3051
+ vnode_setAttr(null, vParent, "q:sref", consumeValue());
3052
+ } else if (peek() === VNodeDataChar_KEY) {
3053
+ vnode_setAttr(null, vParent, "q:key", consumeValue());
3054
+ } else if (peek() === VNodeDataChar_SEQ) {
3055
+ vnode_setAttr(null, vParent, "q:seq", consumeValue());
3056
+ } else if (peek() === VNodeDataChar_SEQ_IDX) {
3057
+ vnode_setAttr(null, vParent, "q:seqIdx", consumeValue());
3058
+ } else if (peek() === VNodeDataChar_SUBS) {
3059
+ vnode_setProp(vParent, "q:subs", consumeValue());
3060
+ } else if (peek() === VNodeDataChar_CONTEXT) {
3061
+ vnode_setAttr(null, vParent, "q:ctx", consumeValue());
3062
+ } else if (peek() === VNodeDataChar_OPEN) {
3063
+ consume(), addVNode(vnode_newVirtual()), stack.push(vParent, vFirst, vLast, previousTextNode, idx),
3064
+ idx = 0, vParent = vLast, vFirst = vLast = null;
3065
+ } else if (peek() === VNodeDataChar_SEPARATOR) {
3066
+ const key = consumeValue();
3067
+ const value = consumeValue();
3068
+ vnode_setAttr(null, vParent, key, value);
3069
+ } else if (peek() === VNodeDataChar_CLOSE) {
3070
+ consume(), vParent[ElementVNodeProps.lastChild] = vLast, idx = stack.pop(), previousTextNode = stack.pop(),
3071
+ vLast = stack.pop(), vFirst = stack.pop(), vParent = stack.pop();
3072
+ } else if (peek() === VNodeDataChar_SLOT) {
3073
+ vnode_setAttr(null, vParent, QSlot, consumeValue());
3074
+ } else {
3075
+ const textNode = child && 3 === fastNodeType(child) ? child : null;
3076
+ null === combinedText && (combinedText = textNode ? textNode.nodeValue : null, textIdx = 0);
3077
+ let length = 0;
3078
+ for (;isLowercase(peek()); ) {
3079
+ length += consume() - 97, length *= 26;
3080
+ }
3081
+ length += consume() - 65;
3082
+ const text = null === combinedText ? "" : combinedText.substring(textIdx, textIdx + length);
3083
+ addVNode(previousTextNode = ((previousTextNode, sharedTextNode, textContent) => {
3084
+ sharedTextNode && assertEqual(fastNodeType(sharedTextNode));
3085
+ const vnode = VNodeArray.createText(VNodeFlags.Text | -1 << VNodeFlagsIndex.shift, null, previousTextNode, null, sharedTextNode, textContent);
3086
+ return assertFalse(vnode_isElementVNode(vnode)), assertTrue(vnode_isTextVNode(vnode)),
3087
+ assertFalse(vnode_isVirtualVNode(vnode)), vnode;
3088
+ })(previousTextNode, textNode, text)), textIdx += length;
3089
+ }
3090
+ })), vParent[ElementVNodeProps.lastChild] = vLast, vFirst;
3091
+ }(vNode, vNodeData, element, firstChild);
3092
+ }
3093
+ return materializeFromDOM(vNode, firstChild);
3387
3094
  };
3388
3095
  const ensureMaterialized = vnode => {
3389
3096
  const vParent = ensureElementVNode(vnode);
3390
3097
  let vFirstChild = vParent[ElementVNodeProps.firstChild];
3391
3098
  if (void 0 === vFirstChild) {
3392
- vFirstChild = vParent[VNodeProps.parent] && shouldIgnoreChildren(vParent[ElementVNodeProps.element]) ? vParent[ElementVNodeProps.firstChild] = vParent[ElementVNodeProps.lastChild] = null : vnode_materialize(vParent);
3099
+ vFirstChild = vParent[VNodeProps.parent] && shouldIgnoreChildren(vParent[ElementVNodeProps.element]) ? vParent[ElementVNodeProps.firstChild] = vParent[ElementVNodeProps.lastChild] = null : (vNode => {
3100
+ const element = vNode[ElementVNodeProps.element];
3101
+ const firstChild = fastFirstChild(element);
3102
+ const vNodeData = element.ownerDocument?.qVNodeData?.get(element);
3103
+ return materialize(vNode, element, firstChild, vNodeData);
3104
+ })(vParent);
3393
3105
  }
3394
3106
  return assertTrue(), assertTrue(), vFirstChild;
3395
3107
  };
@@ -3458,7 +3170,7 @@
3458
3170
  };
3459
3171
  };
3460
3172
  const isQStyleElement = node => isElement(node) && "STYLE" === node.nodeName && (node.hasAttribute("q:sstyle") || node.hasAttribute("q:style"));
3461
- const materializeFromDOM = (vParent, firstChild) => {
3173
+ const materializeFromDOM = (vParent, firstChild, vData) => {
3462
3174
  let vFirstChild = null;
3463
3175
  const skipStyleElements = () => {
3464
3176
  for (;isQStyleElement(child); ) {
@@ -3476,8 +3188,38 @@
3476
3188
  vNextChild[VNodeProps.previousSibling] = vChild, vChild = vNextChild), vFirstChild || (vParent[ElementVNodeProps.firstChild] = vFirstChild = vChild),
3477
3189
  child = fastNextSibling(child), skipStyleElements();
3478
3190
  }
3479
- return vParent[ElementVNodeProps.lastChild] = vChild || null, vParent[ElementVNodeProps.firstChild] = vFirstChild,
3480
- vFirstChild;
3191
+ if (vParent[ElementVNodeProps.lastChild] = vChild || null, vParent[ElementVNodeProps.firstChild] = vFirstChild,
3192
+ vData) {
3193
+ let container = null;
3194
+ processVNodeData$1(vData, ((peek, consumeValue) => {
3195
+ if (peek() === VNodeDataChar_ID) {
3196
+ container || (container = getDomContainer(vParent[ElementVNodeProps.element]));
3197
+ const id = consumeValue();
3198
+ container.$setRawState$(parseInt(id), vParent), build.isDev && vnode_setAttr(null, vParent, "q:id", id);
3199
+ } else {
3200
+ peek() === VNodeDataChar_SUBS ? vnode_setProp(vParent, "q:subs", consumeValue()) : consumeValue();
3201
+ }
3202
+ }));
3203
+ }
3204
+ return vFirstChild;
3205
+ };
3206
+ const processVNodeData$1 = (vData, callback) => {
3207
+ let nextToConsumeIdx = 0;
3208
+ let ch = 0;
3209
+ let peekCh = 0;
3210
+ const peek = () => 0 !== peekCh ? peekCh : peekCh = nextToConsumeIdx < vData.length ? vData.charCodeAt(nextToConsumeIdx) : 0;
3211
+ const consume = () => (ch = peek(), peekCh = 0, nextToConsumeIdx++, ch);
3212
+ const consumeValue = () => {
3213
+ consume();
3214
+ const start = nextToConsumeIdx;
3215
+ for (;peek() <= 58 && 0 !== peekCh || 95 === peekCh || peekCh >= 65 && peekCh <= 90 || peekCh >= 97 && peekCh <= 122; ) {
3216
+ consume();
3217
+ }
3218
+ return vData.substring(start, nextToConsumeIdx);
3219
+ };
3220
+ for (;0 !== peek(); ) {
3221
+ callback(peek, consumeValue, consume, nextToConsumeIdx);
3222
+ }
3481
3223
  };
3482
3224
  const vnode_getNextSibling = vnode => vnode[VNodeProps.nextSibling];
3483
3225
  const vnode_getAttrKeys = vnode => {
@@ -3535,12 +3277,12 @@
3535
3277
  if (type === VNodeFlags.Virtual) {
3536
3278
  return VirtualVNodeProps.PROPS_OFFSET;
3537
3279
  }
3538
- throw throwErrorAndStop("Invalid vnode type.");
3280
+ throw qError(QError.invalidVNodeType, [ type ]);
3539
3281
  };
3540
3282
  const vnode_getParent = vnode => vnode[VNodeProps.parent] || null;
3541
3283
  const vnode_getNode = vnode => null === vnode || vnode_isVirtualVNode(vnode) ? null : vnode_isElementVNode(vnode) ? vnode[ElementVNodeProps.element] : (assertTrue(vnode_isTextVNode(vnode)),
3542
3284
  vnode[TextVNodeProps.node]);
3543
- function vnode_toString(depth = 10, offset = "", materialize = !1, siblings = !1) {
3285
+ function vnode_toString(depth = 20, offset = "", materialize = !1, siblings = !1) {
3544
3286
  let vnode = this;
3545
3287
  if (0 === depth) {
3546
3288
  return "...";
@@ -3612,89 +3354,505 @@
3612
3354
  if (type & VNodeFlags.Text) {
3613
3355
  return 3;
3614
3356
  }
3615
- throw throwErrorAndStop("Unknown vnode type: " + type);
3357
+ throw qError(QError.invalidVNodeType, [ type ]);
3616
3358
  };
3617
3359
  const isElement = node => node && "object" == typeof node && 1 === fastNodeType(node);
3618
3360
  const aPath = [];
3619
3361
  const bPath = [];
3620
- const vnode_documentPosition = (a, b) => {
3362
+ const vnode_documentPosition = (a, b, rootVNode) => {
3621
3363
  if (a === b) {
3622
3364
  return 0;
3623
3365
  }
3624
3366
  let aDepth = -1;
3625
3367
  let bDepth = -1;
3626
3368
  for (;a; ) {
3627
- a = (aPath[++aDepth] = a)[VNodeProps.parent];
3369
+ a = (aPath[++aDepth] = a)[VNodeProps.parent] || rootVNode && vnode_getProp(a, ":", (id => vnode_locate(rootVNode, id)));
3628
3370
  }
3629
3371
  for (;b; ) {
3630
- b = (bPath[++bDepth] = b)[VNodeProps.parent];
3372
+ b = (bPath[++bDepth] = b)[VNodeProps.parent] || rootVNode && vnode_getProp(b, ":", (id => vnode_locate(rootVNode, id)));
3373
+ }
3374
+ for (;aDepth >= 0 && bDepth >= 0; ) {
3375
+ if ((a = aPath[aDepth]) !== (b = bPath[bDepth])) {
3376
+ let cursor = b;
3377
+ do {
3378
+ if (cursor = vnode_getNextSibling(cursor), cursor === a) {
3379
+ return 1;
3380
+ }
3381
+ } while (cursor);
3382
+ cursor = b;
3383
+ do {
3384
+ if (cursor = cursor[VNodeProps.previousSibling], cursor === a) {
3385
+ return -1;
3386
+ }
3387
+ } while (cursor);
3388
+ return rootVNode && vnode_getProp(b, ":", (id => vnode_locate(rootVNode, id))) ? -1 : 1;
3389
+ }
3390
+ aDepth--, bDepth--;
3391
+ }
3392
+ return aDepth < bDepth ? -1 : 1;
3393
+ };
3394
+ const vnode_getProjectionParentComponent = (vHost, rootVNode) => {
3395
+ let projectionDepth = 1;
3396
+ for (;projectionDepth--; ) {
3397
+ for (;vHost && (!vnode_isVirtualVNode(vHost) || null === vnode_getProp(vHost, "q:renderFn", null)); ) {
3398
+ const qSlotParent = vnode_getProp(vHost, ":", (id => vnode_locate(rootVNode, id)));
3399
+ const vProjectionParent = vnode_isVirtualVNode(vHost) && qSlotParent;
3400
+ vProjectionParent && projectionDepth++, vHost = vProjectionParent || vnode_getParent(vHost);
3401
+ }
3402
+ projectionDepth > 0 && (vHost = vnode_getParent(vHost));
3403
+ }
3404
+ return vHost;
3405
+ };
3406
+ const VNodeArray = class VNode extends Array {
3407
+ static createElement(flags, parent, previousSibling, nextSibling, firstChild, lastChild, element, elementName) {
3408
+ const vnode = new VNode(flags, parent, previousSibling, nextSibling);
3409
+ return vnode.push(firstChild, lastChild, element, elementName), vnode;
3410
+ }
3411
+ static createText(flags, parent, previousSibling, nextSibling, textNode, text) {
3412
+ const vnode = new VNode(flags, parent, previousSibling, nextSibling);
3413
+ return vnode.push(textNode, text), vnode;
3414
+ }
3415
+ static createVirtual(flags, parent, previousSibling, nextSibling, firstChild, lastChild) {
3416
+ const vnode = new VNode(flags, parent, previousSibling, nextSibling);
3417
+ return vnode.push(firstChild, lastChild), vnode;
3418
+ }
3419
+ constructor(flags, parent, previousSibling, nextSibling) {
3420
+ super(), this.push(flags, parent, previousSibling, nextSibling), build.isDev && (this.toString = vnode_toString);
3421
+ }
3422
+ };
3423
+ let _context;
3424
+ const tryGetInvokeContext = () => {
3425
+ if (!_context) {
3426
+ const context = "undefined" != typeof document && document && document.__q_context__;
3427
+ if (!context) {
3428
+ return;
3429
+ }
3430
+ return isArray(context) ? document.__q_context__ = newInvokeContextFromTuple(context) : context;
3431
+ }
3432
+ return _context;
3433
+ };
3434
+ const getInvokeContext = () => {
3435
+ const ctx = tryGetInvokeContext();
3436
+ if (!ctx) {
3437
+ throw qError(QError.useMethodOutsideContext);
3438
+ }
3439
+ return ctx;
3440
+ };
3441
+ const useInvokeContext = () => {
3442
+ const ctx = tryGetInvokeContext();
3443
+ if (!ctx || "qRender" !== ctx.$event$) {
3444
+ throw qError(QError.useInvokeContext);
3445
+ }
3446
+ return assertDefined(), assertDefined(), ctx;
3447
+ };
3448
+ function useBindInvokeContext(fn) {
3449
+ if (null == fn) {
3450
+ return fn;
3451
+ }
3452
+ const ctx = getInvokeContext();
3453
+ return function(...args) {
3454
+ return invokeApply.call(this, ctx, fn, args);
3455
+ };
3456
+ }
3457
+ function invoke(context, fn, ...args) {
3458
+ return invokeApply.call(this, context, fn, args);
3459
+ }
3460
+ function invokeApply(context, fn, args) {
3461
+ const previousContext = _context;
3462
+ let returnValue;
3463
+ try {
3464
+ _context = context, returnValue = fn.apply(this, args);
3465
+ } finally {
3466
+ _context = previousContext;
3467
+ }
3468
+ return returnValue;
3469
+ }
3470
+ const newInvokeContextFromTuple = ([element, event, url]) => {
3471
+ const container = element.closest(QContainerSelector);
3472
+ const locale = container?.getAttribute("q:locale") || void 0;
3473
+ return locale && function(locale) {
3474
+ _locale = locale;
3475
+ }(locale), newInvokeContext(locale, void 0, element, event, url);
3476
+ };
3477
+ const newInvokeContext = (locale, hostElement, element, event, url) => {
3478
+ const ctx = {
3479
+ $url$: url,
3480
+ $i$: 0,
3481
+ $hostElement$: hostElement,
3482
+ $element$: element,
3483
+ $event$: event,
3484
+ $qrl$: void 0,
3485
+ $effectSubscriber$: void 0,
3486
+ $locale$: locale || ("object" == typeof event && event && "locale" in event ? event.locale : void 0),
3487
+ $container$: void 0
3488
+ };
3489
+ return seal(), ctx;
3490
+ };
3491
+ const untrack = fn => invoke(void 0, fn);
3492
+ const trackInvocation = /*#__PURE__*/ newInvokeContext(void 0, void 0, void 0, "qRender");
3493
+ const trackSignal = (fn, subscriber, property, container, data) => {
3494
+ const previousSubscriber = trackInvocation.$effectSubscriber$;
3495
+ const previousContainer = trackInvocation.$container$;
3496
+ try {
3497
+ return trackInvocation.$effectSubscriber$ = [ subscriber, property ], data && trackInvocation.$effectSubscriber$.push(data),
3498
+ trackInvocation.$container$ = container, invoke(trackInvocation, fn);
3499
+ } finally {
3500
+ trackInvocation.$effectSubscriber$ = previousSubscriber, trackInvocation.$container$ = previousContainer;
3501
+ }
3502
+ };
3503
+ const trackSignalAndAssignHost = (value, host, property, container, data) => (value instanceof WrappedSignal && value.$hostElement$ !== host && host && (value.$hostElement$ = host),
3504
+ trackSignal((() => value.value), host, property, container, data));
3505
+ const createContextId = name => (assertTrue(/^[\w/.-]+$/.test(name)), /*#__PURE__*/ Object.freeze({
3506
+ id: fromCamelToKebabCase(name)
3507
+ }));
3508
+ const useContextProvider = (context, newValue) => {
3509
+ const {val, set, iCtx} = useSequentialScope();
3510
+ void 0 === val && (iCtx.$container$.setContext(iCtx.$hostElement$, context, newValue),
3511
+ set(1));
3512
+ };
3513
+ const ERROR_CONTEXT = /*#__PURE__*/ createContextId("qk-error");
3514
+ function getDomContainer(element) {
3515
+ const qContainerElement = _getQContainerElement(element);
3516
+ if (!qContainerElement) {
3517
+ throw qError(QError.containerNotFound);
3518
+ }
3519
+ return getDomContainerFromQContainerElement(qContainerElement);
3520
+ }
3521
+ function getDomContainerFromQContainerElement(qContainerElement) {
3522
+ const qElement = qContainerElement;
3523
+ let container = qElement.qContainer;
3524
+ if (!container) {
3525
+ container = new DomContainer(qElement);
3526
+ const containerAttributes = {};
3527
+ if (qElement) {
3528
+ const attrs = qElement.attributes;
3529
+ if (attrs) {
3530
+ for (let index = 0; index < attrs.length; index++) {
3531
+ const attr = attrs[index];
3532
+ ":" !== attr.name && (containerAttributes[attr.name] = attr.value);
3533
+ }
3534
+ }
3535
+ }
3536
+ container.$serverData$ = {
3537
+ containerAttributes
3538
+ }, qElement.setAttribute("q:container", QContainerValue.RESUMED), qElement.qContainer = container;
3539
+ }
3540
+ return container;
3541
+ }
3542
+ function _getQContainerElement(element) {
3543
+ return (Array.isArray(element) ? vnode_getDomParent(element) : element).closest(QContainerSelector);
3544
+ }
3545
+ const isDomContainer = container => container instanceof DomContainer;
3546
+ class DomContainer extends _SharedContainer {
3547
+ element;
3548
+ qContainer;
3549
+ qBase;
3550
+ qManifestHash;
3551
+ rootVNode;
3552
+ document;
3553
+ $journal$;
3554
+ renderDone=null;
3555
+ $rawStateData$;
3556
+ $storeProxyMap$=new WeakMap;
3557
+ $qFuncs$;
3558
+ $instanceHash$;
3559
+ stateData;
3560
+ $styleIds$=null;
3561
+ $vnodeLocate$=id => vnode_locate(this.rootVNode, id);
3562
+ $renderCount$=0;
3563
+ constructor(element) {
3564
+ if (super((() => this.scheduleRender()), (() => vnode_applyJournal(this.$journal$)), {}, element.getAttribute("q:locale")),
3565
+ this.qContainer = element.getAttribute("q:container"), !this.qContainer) {
3566
+ throw qError(QError.elementWithoutContainer);
3567
+ }
3568
+ this.$journal$ = [ VNodeJournalOpCode.HoistStyles, element.ownerDocument ], this.document = element.ownerDocument,
3569
+ this.element = element, this.qBase = element.getAttribute("q:base"), this.$instanceHash$ = element.getAttribute("q:instance"),
3570
+ this.qManifestHash = element.getAttribute("q:manifest-hash"), this.rootVNode = vnode_newUnMaterializedElement(this.element),
3571
+ this.$rawStateData$ = null, this.stateData = null;
3572
+ const document = this.element.ownerDocument;
3573
+ document.qVNodeData || function(document) {
3574
+ const vNodeDataMap = document.qVNodeData || (document.qVNodeData = new WeakMap);
3575
+ const prototype = document.body;
3576
+ const getAttribute = prototype.getAttribute;
3577
+ const hasAttribute = prototype.hasAttribute;
3578
+ const getNodeType = ((prototype, name) => {
3579
+ let getter;
3580
+ for (;prototype && !(getter = Object.getOwnPropertyDescriptor(prototype, name)?.get); ) {
3581
+ prototype = Object.getPrototypeOf(prototype);
3582
+ }
3583
+ return getter || function() {
3584
+ return this[name];
3585
+ };
3586
+ })(prototype, "nodeType");
3587
+ const attachVnodeDataAndRefs = element => {
3588
+ Array.from(element.querySelectorAll('script[type="qwik/vnode"]')).forEach((script => {
3589
+ script.setAttribute("type", "x-qwik/vnode");
3590
+ const qContainerElement = script.closest("[q\\:container]");
3591
+ qContainerElement.qVnodeData = script.textContent, qContainerElement.qVNodeRefs = new Map;
3592
+ })), element.querySelectorAll("[q\\:shadowroot]").forEach((parent => {
3593
+ const shadowRoot = parent.shadowRoot;
3594
+ shadowRoot && attachVnodeDataAndRefs(shadowRoot);
3595
+ }));
3596
+ };
3597
+ let NodeType;
3598
+ attachVnodeDataAndRefs(document), function(NodeType) {
3599
+ NodeType[NodeType.CONTAINER_MASK = 1] = "CONTAINER_MASK", NodeType[NodeType.ELEMENT = 2] = "ELEMENT",
3600
+ NodeType[NodeType.ELEMENT_CONTAINER = 3] = "ELEMENT_CONTAINER", NodeType[NodeType.ELEMENT_SHADOW_ROOT = 6] = "ELEMENT_SHADOW_ROOT",
3601
+ NodeType[NodeType.COMMENT_SKIP_START = 5] = "COMMENT_SKIP_START", NodeType[NodeType.COMMENT_SKIP_END = 8] = "COMMENT_SKIP_END",
3602
+ NodeType[NodeType.COMMENT_IGNORE_START = 16] = "COMMENT_IGNORE_START", NodeType[NodeType.COMMENT_IGNORE_END = 32] = "COMMENT_IGNORE_END",
3603
+ NodeType[NodeType.COMMENT_ISLAND_START = 65] = "COMMENT_ISLAND_START", NodeType[NodeType.COMMENT_ISLAND_END = 128] = "COMMENT_ISLAND_END",
3604
+ NodeType[NodeType.OTHER = 0] = "OTHER";
3605
+ }(NodeType || (NodeType = {}));
3606
+ const getFastNodeType = node => {
3607
+ const nodeType = getNodeType.call(node);
3608
+ if (1 === nodeType) {
3609
+ return null === getAttribute.call(node, "q:container") ? hasAttribute.call(node, "q:shadowroot") ? NodeType.ELEMENT_SHADOW_ROOT : hasAttribute.call(node, ":") ? NodeType.ELEMENT : NodeType.OTHER : NodeType.ELEMENT_CONTAINER;
3610
+ }
3611
+ if (8 === nodeType) {
3612
+ const nodeValue = node.nodeValue || "";
3613
+ if (nodeValue.startsWith("q:container-island")) {
3614
+ return NodeType.COMMENT_ISLAND_START;
3615
+ }
3616
+ if (nodeValue.startsWith("q:ignore")) {
3617
+ return NodeType.COMMENT_IGNORE_START;
3618
+ }
3619
+ if (nodeValue.startsWith("q:container")) {
3620
+ return NodeType.COMMENT_SKIP_START;
3621
+ }
3622
+ if (nodeValue.startsWith("/q:container-island")) {
3623
+ return NodeType.COMMENT_ISLAND_END;
3624
+ }
3625
+ if (nodeValue.startsWith("/q:ignore")) {
3626
+ return NodeType.COMMENT_IGNORE_END;
3627
+ }
3628
+ if (nodeValue.startsWith("/q:container")) {
3629
+ return NodeType.COMMENT_SKIP_END;
3630
+ }
3631
+ }
3632
+ return NodeType.OTHER;
3633
+ };
3634
+ const isSeparator = ch => VNodeDataSeparator_ADVANCE_1 <= ch && ch <= VNodeDataSeparator_ADVANCE_8192;
3635
+ const findVDataSectionEnd = (vData, start, end) => {
3636
+ let depth = 0;
3637
+ for (;start < end; ) {
3638
+ const ch = vData.charCodeAt(start);
3639
+ if (0 === depth && isSeparator(ch)) {
3640
+ break;
3641
+ }
3642
+ ch === VNodeDataChar_OPEN ? depth++ : ch === VNodeDataChar_CLOSE && depth--, start++;
3643
+ }
3644
+ return start;
3645
+ };
3646
+ const nextSibling = node => {
3647
+ for (;node && (node = node.nextSibling) && getFastNodeType(node) === NodeType.OTHER; ) {}
3648
+ return node;
3649
+ };
3650
+ const firstChild = node => {
3651
+ for (;node && (node = node.firstChild) && getFastNodeType(node) === NodeType.OTHER; ) {}
3652
+ return node;
3653
+ };
3654
+ const walkContainer = (walker, containerNode, node, exitNode, vData, qVNodeRefs) => {
3655
+ const vData_length = vData.length;
3656
+ let elementIdx = 0;
3657
+ let vNodeElementIndex = -1;
3658
+ let vData_start = 0;
3659
+ let vData_end = 0;
3660
+ let ch = 0;
3661
+ let needsToStoreRef = -1;
3662
+ let nextNode = null;
3663
+ const howManyElementsToSkip = () => {
3664
+ let elementsToSkip = 0;
3665
+ for (;isSeparator(ch = vData.charCodeAt(vData_start)) && (elementsToSkip += 1 << ch - VNodeDataSeparator_ADVANCE_1,
3666
+ vData_start++, !(vData_start >= vData_length)); ) {}
3667
+ return elementsToSkip;
3668
+ };
3669
+ do {
3670
+ if (node === exitNode) {
3671
+ return;
3672
+ }
3673
+ nextNode = null;
3674
+ const nodeType = node == containerNode ? NodeType.ELEMENT : getFastNodeType(node);
3675
+ if (nodeType === NodeType.ELEMENT_CONTAINER) {
3676
+ const container = node;
3677
+ let cursor = node;
3678
+ for (;cursor && !(nextNode = nextSibling(cursor)); ) {
3679
+ cursor = cursor.parentNode;
3680
+ }
3681
+ walkContainer(walker, container, node, nextNode, container.qVnodeData || "", container.qVNodeRefs);
3682
+ } else if (nodeType === NodeType.COMMENT_IGNORE_START) {
3683
+ let islandNode = node;
3684
+ do {
3685
+ if (islandNode = walker.nextNode(), !islandNode) {
3686
+ throw new Error(`Island inside \x3c!--${node?.nodeValue}--\x3e not found!`);
3687
+ }
3688
+ } while (getFastNodeType(islandNode) !== NodeType.COMMENT_ISLAND_START);
3689
+ nextNode = null;
3690
+ } else if (nodeType === NodeType.COMMENT_ISLAND_END) {
3691
+ nextNode = node;
3692
+ do {
3693
+ if (nextNode = walker.nextNode(), !nextNode) {
3694
+ throw new Error("Ignore block not closed!");
3695
+ }
3696
+ } while (getFastNodeType(nextNode) !== NodeType.COMMENT_IGNORE_END);
3697
+ nextNode = null;
3698
+ } else if (nodeType === NodeType.COMMENT_SKIP_START) {
3699
+ nextNode = node;
3700
+ do {
3701
+ if (nextNode = nextSibling(nextNode), !nextNode) {
3702
+ throw new Error(`\x3c!--${node?.nodeValue}--\x3e not closed!`);
3703
+ }
3704
+ } while (getFastNodeType(nextNode) !== NodeType.COMMENT_SKIP_END);
3705
+ walkContainer(walker, node, node, nextNode, "", null);
3706
+ } else if (nodeType === NodeType.ELEMENT_SHADOW_ROOT) {
3707
+ nextNode = nextSibling(node);
3708
+ const shadowRootContainer = node;
3709
+ const shadowRoot = shadowRootContainer?.shadowRoot;
3710
+ shadowRoot && walkContainer(document.createTreeWalker(shadowRoot, 129), null, firstChild(shadowRoot), null, "", null);
3711
+ }
3712
+ if ((nodeType & NodeType.ELEMENT) === NodeType.ELEMENT) {
3713
+ if (vNodeElementIndex < elementIdx && (-1 === vNodeElementIndex && (vNodeElementIndex = 0),
3714
+ vData_start = vData_end, vData_start < vData_length ? (vNodeElementIndex += howManyElementsToSkip(),
3715
+ ch === VNodeDataSeparator_REFERENCE && (needsToStoreRef = vNodeElementIndex, vData_start++,
3716
+ ch = vData_start < vData_length ? vData.charCodeAt(vData_end) : VNodeDataSeparator_ADVANCE_1),
3717
+ vData_end = findVDataSectionEnd(vData, vData_start, vData_length)) : vNodeElementIndex = Number.MAX_SAFE_INTEGER),
3718
+ elementIdx === vNodeElementIndex) {
3719
+ needsToStoreRef === elementIdx && qVNodeRefs.set(elementIdx, node);
3720
+ const instructions = vData.substring(vData_start, vData_end);
3721
+ vNodeDataMap.set(node, instructions);
3722
+ }
3723
+ elementIdx++;
3724
+ }
3725
+ } while (node = nextNode || walker.nextNode());
3726
+ };
3727
+ const walker = document.createTreeWalker(document, 129);
3728
+ walkContainer(walker, null, walker.firstChild(), null, "", null);
3729
+ }(document), this.$rawStateData$ = [], this.stateData = [];
3730
+ const qwikStates = element.querySelectorAll('script[type="qwik/state"]');
3731
+ if (0 !== qwikStates.length) {
3732
+ this.$rawStateData$ = JSON.parse(qwikStates[qwikStates.length - 1].textContent),
3733
+ this.stateData = wrapDeserializerProxy(this, this.$rawStateData$);
3734
+ }
3735
+ this.$qFuncs$ = getQFuncs(document, this.$instanceHash$) || EMPTY_ARRAY;
3736
+ }
3737
+ $setRawState$(id, vParent) {
3738
+ this.stateData[id] = vParent;
3739
+ }
3740
+ parseQRL(qrl) {
3741
+ return inflateQRL(this, parseQRL(qrl));
3742
+ }
3743
+ handleError(err, host) {
3744
+ const errorStore = this.resolveContext(host, ERROR_CONTEXT);
3745
+ if (!errorStore) {
3746
+ throw err;
3747
+ }
3748
+ errorStore.error = err;
3749
+ }
3750
+ setContext(host, context, value) {
3751
+ let ctx = this.getHostProp(host, "q:ctx");
3752
+ ctx || this.setHostProp(host, "q:ctx", ctx = []), mapArray_set(ctx, context.id, value, 0);
3631
3753
  }
3632
- for (;aDepth >= 0 && bDepth >= 0; ) {
3633
- if ((a = aPath[aDepth]) !== (b = bPath[bDepth])) {
3634
- let cursor = b;
3635
- do {
3636
- if (cursor = vnode_getNextSibling(cursor), cursor === a) {
3637
- return 1;
3754
+ resolveContext(host, contextId) {
3755
+ for (;host; ) {
3756
+ const ctx = this.getHostProp(host, "q:ctx");
3757
+ if (ctx) {
3758
+ const value = mapArray_get(ctx, contextId.id, 0);
3759
+ if (value) {
3760
+ return value;
3638
3761
  }
3639
- } while (cursor);
3640
- cursor = b;
3641
- do {
3642
- if (cursor = cursor[VNodeProps.previousSibling], cursor === a) {
3643
- return -1;
3762
+ }
3763
+ host = this.getParentHost(host);
3764
+ }
3765
+ }
3766
+ getParentHost(host) {
3767
+ let vNode = vnode_getParent(host);
3768
+ for (;vNode; ) {
3769
+ if (vnode_isVirtualVNode(vNode)) {
3770
+ if (null !== vnode_getProp(vNode, "q:renderFn", null)) {
3771
+ return vNode;
3644
3772
  }
3645
- } while (cursor);
3646
- return 1;
3773
+ vNode = vnode_getParent(vNode) || vnode_getProp(vNode, ":", this.$vnodeLocate$);
3774
+ } else {
3775
+ vNode = vnode_getParent(vNode);
3776
+ }
3647
3777
  }
3648
- aDepth--, bDepth--;
3778
+ return null;
3649
3779
  }
3650
- return aDepth < bDepth ? -1 : 1;
3651
- };
3652
- const vnode_getProjectionParentComponent = (vHost, rootVNode) => {
3653
- let projectionDepth = 1;
3654
- for (;projectionDepth--; ) {
3655
- for (;vHost && (!vnode_isVirtualVNode(vHost) || null === vnode_getProp(vHost, "q:renderFn", null)); ) {
3656
- const qSlotParentProp = vnode_getProp(vHost, ":", null);
3657
- const qSlotParent = qSlotParentProp && ("string" == typeof qSlotParentProp ? vnode_locate(rootVNode, qSlotParentProp) : qSlotParentProp);
3658
- const vProjectionParent = vnode_isVirtualVNode(vHost) && qSlotParent;
3659
- vProjectionParent && projectionDepth++, vHost = vProjectionParent || vnode_getParent(vHost);
3780
+ setHostProp(host, name, value) {
3781
+ vnode_setProp(host, name, value);
3782
+ }
3783
+ getHostProp(host, name) {
3784
+ const vNode = host;
3785
+ let getObjectById = null;
3786
+ switch (name) {
3787
+ case "q:seq":
3788
+ case "q:props":
3789
+ case "q:renderFn":
3790
+ case "q:ctx":
3791
+ case "q:subs":
3792
+ getObjectById = this.$getObjectById$;
3793
+ break;
3794
+
3795
+ case "q:seqIdx":
3796
+ case ":onIdx":
3797
+ getObjectById = parseInt;
3660
3798
  }
3661
- projectionDepth > 0 && (vHost = vnode_getParent(vHost));
3799
+ return vnode_getProp(vNode, name, getObjectById);
3662
3800
  }
3663
- return vHost;
3664
- };
3665
- const VNodeArray = class VNode extends Array {
3666
- static createElement(flags, parent, previousSibling, nextSibling, firstChild, lastChild, element, elementName) {
3667
- const vnode = new VNode(flags, parent, previousSibling, nextSibling);
3668
- return vnode.push(firstChild, lastChild, element, elementName), vnode;
3801
+ scheduleRender() {
3802
+ return this.$renderCount$++, this.renderDone ||= getPlatform().nextTick((() => this.processChores())),
3803
+ this.renderDone;
3669
3804
  }
3670
- static createText(flags, parent, previousSibling, nextSibling, textNode, text) {
3671
- const vnode = new VNode(flags, parent, previousSibling, nextSibling);
3672
- return vnode.push(textNode, text), vnode;
3805
+ processChores() {
3806
+ let renderCount = this.$renderCount$;
3807
+ const result = this.$scheduler$(ChoreType.WAIT_FOR_ALL);
3808
+ if (isPromise(result)) {
3809
+ return result.then((async () => {
3810
+ for (;renderCount !== this.$renderCount$; ) {
3811
+ renderCount = this.$renderCount$, await this.$scheduler$(ChoreType.WAIT_FOR_ALL);
3812
+ }
3813
+ this.renderDone = null;
3814
+ }));
3815
+ }
3816
+ renderCount === this.$renderCount$ ? this.renderDone = null : this.processChores();
3673
3817
  }
3674
- static createVirtual(flags, parent, previousSibling, nextSibling, firstChild, lastChild) {
3675
- const vnode = new VNode(flags, parent, previousSibling, nextSibling);
3676
- return vnode.push(firstChild, lastChild), vnode;
3818
+ ensureProjectionResolved(vNode) {
3819
+ if (!(vNode[VNodeProps.flags] & VNodeFlags.Resolved)) {
3820
+ vNode[VNodeProps.flags] |= VNodeFlags.Resolved;
3821
+ for (let i = vnode_getPropStartIndex(vNode); i < vNode.length; i += 2) {
3822
+ if (isSlotProp(vNode[i])) {
3823
+ const value = vNode[i + 1];
3824
+ "string" == typeof value && (vNode[i + 1] = this.$vnodeLocate$(value));
3825
+ }
3826
+ }
3827
+ }
3677
3828
  }
3678
- constructor(flags, parent, previousSibling, nextSibling) {
3679
- super(), this.push(flags, parent, previousSibling, nextSibling), build.isDev && (this.toString = vnode_toString);
3829
+ $getObjectById$=id => ("string" == typeof id && (id = parseFloat(id)), assertTrue(),
3830
+ this.stateData[id]);
3831
+ getSyncFn(id) {
3832
+ const fn = this.$qFuncs$[id];
3833
+ return assertTrue(), fn;
3680
3834
  }
3681
- };
3682
- var ExperimentalFeatures;
3683
- var VNodeDataFlag;
3684
- !function(ExperimentalFeatures) {
3685
- ExperimentalFeatures.preventNavigate = "preventNavigate", ExperimentalFeatures.valibot = "valibot",
3686
- ExperimentalFeatures.noSPA = "noSPA", ExperimentalFeatures.webWorker = "webWorker",
3687
- ExperimentalFeatures.insights = "insights";
3688
- }(ExperimentalFeatures || (ExperimentalFeatures = {})), function(VNodeDataFlag) {
3689
- VNodeDataFlag[VNodeDataFlag.NONE = 0] = "NONE", VNodeDataFlag[VNodeDataFlag.TEXT_DATA = 1] = "TEXT_DATA",
3690
- VNodeDataFlag[VNodeDataFlag.VIRTUAL_NODE = 2] = "VIRTUAL_NODE", VNodeDataFlag[VNodeDataFlag.REFERENCE = 4] = "REFERENCE",
3691
- VNodeDataFlag[VNodeDataFlag.SERIALIZE = 8] = "SERIALIZE";
3692
- }(VNodeDataFlag || (VNodeDataFlag = {}));
3835
+ $appendStyle$(content, styleId, host, scoped) {
3836
+ if (scoped) {
3837
+ const scopedStyleIdsString = this.getHostProp(host, "q:sstyle");
3838
+ const scopedStyleIds = new Set(function(scopedStyleIds) {
3839
+ return scopedStyleIds?.split(" ") ?? null;
3840
+ }(scopedStyleIdsString));
3841
+ scopedStyleIds.add(styleId), this.setHostProp(host, "q:sstyle", function(scopedStyleIds) {
3842
+ return Array.from(scopedStyleIds).join(" ");
3843
+ }(scopedStyleIds));
3844
+ }
3845
+ if (null == this.$styleIds$ && (this.$styleIds$ = new Set, this.element.querySelectorAll("style[q\\:style]").forEach((style => {
3846
+ this.$styleIds$.add(style.getAttribute("q:style"));
3847
+ }))), !this.$styleIds$.has(styleId)) {
3848
+ this.$styleIds$.add(styleId);
3849
+ const styleElement = this.document.createElement("style");
3850
+ styleElement.setAttribute("q:style", styleId), styleElement.textContent = content,
3851
+ this.$journal$.push(VNodeJournalOpCode.Insert, this.document.head, null, styleElement);
3852
+ }
3853
+ }
3854
+ }
3693
3855
  const deserializedProxyMap = new WeakMap;
3694
- const unwrapDeserializerProxy = value => {
3695
- const unwrapped = "object" == typeof value && null !== value && value[SERIALIZER_PROXY_UNWRAP];
3696
- return unwrapped || value;
3697
- };
3698
3856
  const SERIALIZER_PROXY_UNWRAP = Symbol("UNWRAP");
3699
3857
  const wrapDeserializerProxy = (container, data) => {
3700
3858
  if (!Array.isArray(data) || vnode_isVNode(data) || "object" == typeof (value = data) && null !== value && SERIALIZER_PROXY_UNWRAP in value) {
@@ -3730,9 +3888,10 @@
3730
3888
  return value;
3731
3889
  }
3732
3890
  const container = this.$container$;
3733
- const propValue = allocate(container, typeId, value);
3734
- return Reflect.set(target, property, propValue), this.$data$[idx] = void 0, this.$data$[idx + 1] = propValue,
3735
- typeId >= TypeIds.Error && inflate(container, propValue, typeId, value), propValue;
3891
+ let propValue = allocate(container, typeId, value);
3892
+ return typeId >= TypeIds.Error && (propValue = inflate(container, propValue, typeId, value)),
3893
+ Reflect.set(target, property, propValue), this.$data$[idx] = void 0, this.$data$[idx + 1] = propValue,
3894
+ propValue;
3736
3895
  }
3737
3896
  has(target, property) {
3738
3897
  return property === SERIALIZER_PROXY_UNWRAP || Object.prototype.hasOwnProperty.call(target, property);
@@ -3752,183 +3911,189 @@
3752
3911
  }
3753
3912
  const resolvers = new WeakMap;
3754
3913
  const inflate = (container, target, typeId, data) => {
3755
- if (void 0 !== typeId) {
3756
- switch (typeId !== TypeIds.Object && Array.isArray(data) && (data = ((container, data) => {
3757
- const out = Array(data.length / 2);
3758
- for (let i = 0; i < data.length; i += 2) {
3759
- out[i / 2] = deserializeData(container, data[i], data[i + 1]);
3760
- }
3761
- return out;
3762
- })(container, data)), typeId) {
3763
- case TypeIds.Object:
3764
- for (let i = 0; i < data.length; i += 4) {
3765
- const key = deserializeData(container, data[i], data[i + 1]);
3766
- const valType = data[i + 2];
3767
- const valData = data[i + 3];
3768
- valType === TypeIds.RootRef || valType >= TypeIds.Error ? Object.defineProperty(target, key, {
3769
- get() {
3770
- const value = deserializeData(container, valType, valData);
3771
- return target[key] = value, value;
3772
- },
3773
- set(value) {
3774
- Object.defineProperty(target, key, {
3775
- value,
3776
- writable: !0,
3777
- enumerable: !0,
3778
- configurable: !0
3779
- });
3780
- },
3781
- enumerable: !0,
3782
- configurable: !0
3783
- }) : target[key] = deserializeData(container, valType, valData);
3784
- }
3785
- break;
3786
-
3787
- case TypeIds.QRL:
3788
- inflateQRL(container, target);
3789
- break;
3914
+ if (void 0 === typeId) {
3915
+ return target;
3916
+ }
3917
+ switch (typeId !== TypeIds.Object && Array.isArray(data) && (data = ((container, data) => {
3918
+ const out = Array(data.length / 2);
3919
+ for (let i = 0; i < data.length; i += 2) {
3920
+ out[i / 2] = deserializeData(container, data[i], data[i + 1]);
3921
+ }
3922
+ return out;
3923
+ })(container, data)), typeId) {
3924
+ case TypeIds.Object:
3925
+ for (let i = 0; i < data.length; i += 4) {
3926
+ const key = deserializeData(container, data[i], data[i + 1]);
3927
+ const valType = data[i + 2];
3928
+ const valData = data[i + 3];
3929
+ valType === TypeIds.RootRef || valType >= TypeIds.Error ? Object.defineProperty(target, key, {
3930
+ get() {
3931
+ const value = deserializeData(container, valType, valData);
3932
+ return target[key] = value, value;
3933
+ },
3934
+ set(value) {
3935
+ Object.defineProperty(target, key, {
3936
+ value,
3937
+ writable: !0,
3938
+ enumerable: !0,
3939
+ configurable: !0
3940
+ });
3941
+ },
3942
+ enumerable: !0,
3943
+ configurable: !0
3944
+ }) : target[key] = deserializeData(container, valType, valData);
3945
+ }
3946
+ break;
3790
3947
 
3791
- case TypeIds.Task:
3792
- const task = target;
3793
- const v = data;
3794
- task.$qrl$ = inflateQRL(container, v[0]), task.$flags$ = v[1], task.$index$ = v[2],
3795
- task.$el$ = v[3], task.$effectDependencies$ = v[4], task.$state$ = v[5];
3796
- break;
3948
+ case TypeIds.QRL:
3949
+ inflateQRL(container, target);
3950
+ break;
3797
3951
 
3798
- case TypeIds.Resource:
3799
- const [resolved, result, effects] = data;
3800
- const resource = target;
3801
- resolved ? (resource.value = Promise.resolve(result), resource._resolved = result,
3802
- resource._state = "resolved") : (resource.value = Promise.reject(result), resource._error = result,
3803
- resource._state = "rejected"), getStoreHandler(target).$effects$ = effects;
3804
- break;
3952
+ case TypeIds.Task:
3953
+ const task = target;
3954
+ const v = data;
3955
+ task.$qrl$ = inflateQRL(container, v[0]), task.$flags$ = v[1], task.$index$ = v[2],
3956
+ task.$el$ = v[3], task.$effectDependencies$ = v[4], task.$state$ = v[5];
3957
+ break;
3805
3958
 
3806
- case TypeIds.Component:
3807
- target[SERIALIZABLE_STATE][0] = data[0];
3808
- break;
3959
+ case TypeIds.Resource:
3960
+ const [resolved, result, effects] = data;
3961
+ const resource = target;
3962
+ resolved ? (resource.value = Promise.resolve(result), resource._resolved = result,
3963
+ resource._state = "resolved") : (resource.value = Promise.reject(result), resource._error = result,
3964
+ resource._state = "rejected"), getStoreHandler(target).$effects$ = effects;
3965
+ break;
3809
3966
 
3810
- case TypeIds.Store:
3811
- case TypeIds.StoreArray:
3812
- {
3813
- const [value, flags, effects, storeEffect] = data;
3814
- const handler = getStoreHandler(target);
3815
- handler.$flags$ = flags, Object.assign(getStoreTarget(target), value), storeEffect && (effects[STORE_ARRAY_PROP] = storeEffect),
3816
- handler.$effects$ = effects, container.$storeProxyMap$.set(value, target);
3817
- break;
3818
- }
3967
+ case TypeIds.Component:
3968
+ target[SERIALIZABLE_STATE][0] = data[0];
3969
+ break;
3819
3970
 
3820
- case TypeIds.Signal:
3821
- {
3822
- const signal = target;
3823
- const d = data;
3824
- signal.$untrackedValue$ = d[0], signal.$effects$ = d.slice(1);
3825
- break;
3826
- }
3971
+ case TypeIds.Store:
3972
+ case TypeIds.StoreArray:
3973
+ {
3974
+ const [value, flags, effects, storeEffect] = data;
3975
+ const store = getOrCreateStore(value, flags, container);
3976
+ const storeHandler = getStoreHandler(store);
3977
+ storeEffect && (effects[STORE_ARRAY_PROP] = storeEffect), storeHandler.$effects$ = effects,
3978
+ target = store;
3979
+ break;
3980
+ }
3827
3981
 
3828
- case TypeIds.WrappedSignal:
3829
- {
3830
- const signal = target;
3831
- const d = data;
3832
- signal.$func$ = container.getSyncFn(d[0]), signal.$args$ = d[1], signal.$effectDependencies$ = d[2],
3833
- signal.$untrackedValue$ = d[3], signal.$effects$ = d.slice(4);
3834
- break;
3835
- }
3982
+ case TypeIds.Signal:
3983
+ {
3984
+ const signal = target;
3985
+ const d = data;
3986
+ signal.$untrackedValue$ = d[0], signal.$effects$ = d.slice(1);
3987
+ break;
3988
+ }
3836
3989
 
3837
- case TypeIds.ComputedSignal:
3838
- {
3839
- const computed = target;
3840
- const d = data;
3841
- computed.$computeQrl$ = d[0], computed.$effects$ = d[1], 3 === d.length ? computed.$untrackedValue$ = d[2] : (computed.$invalid$ = !0,
3842
- computed.$computeQrl$.resolve(), container.$scheduler$?.(ChoreType.QRL_RESOLVE, null, computed.$computeQrl$));
3843
- break;
3844
- }
3990
+ case TypeIds.WrappedSignal:
3991
+ {
3992
+ const signal = target;
3993
+ const d = data;
3994
+ signal.$func$ = container.getSyncFn(d[0]), signal.$args$ = d[1], signal.$effectDependencies$ = d[2],
3995
+ signal.$untrackedValue$ = d[3], signal.$hostElement$ = d[4], signal.$effects$ = d.slice(5);
3996
+ break;
3997
+ }
3845
3998
 
3846
- case TypeIds.Error:
3847
- {
3848
- const d = data;
3849
- target.message = d[0];
3850
- const second = d[1];
3851
- if (second && Array.isArray(second)) {
3852
- for (let i = 0; i < second.length; i++) {
3853
- target[second[i++]] = d[i];
3854
- }
3855
- target.stack = d[2];
3856
- } else {
3857
- target.stack = second;
3858
- }
3859
- break;
3860
- }
3999
+ case TypeIds.ComputedSignal:
4000
+ {
4001
+ const computed = target;
4002
+ const d = data;
4003
+ computed.$computeQrl$ = d[0], computed.$effects$ = d[1], 3 === d.length ? computed.$untrackedValue$ = d[2] : (computed.$invalid$ = !0,
4004
+ computed.$computeQrl$.resolve(), container.$scheduler$?.(ChoreType.QRL_RESOLVE, null, computed.$computeQrl$));
4005
+ break;
4006
+ }
3861
4007
 
3862
- case TypeIds.FormData:
3863
- {
3864
- const formData = target;
3865
- const d = data;
3866
- for (let i = 0; i < d.length; i++) {
3867
- formData.append(d[i++], d[i]);
4008
+ case TypeIds.Error:
4009
+ {
4010
+ const d = data;
4011
+ target.message = d[0];
4012
+ const second = d[1];
4013
+ if (second && Array.isArray(second)) {
4014
+ for (let i = 0; i < second.length; i++) {
4015
+ target[second[i++]] = d[i];
3868
4016
  }
3869
- break;
3870
- }
3871
-
3872
- case TypeIds.JSXNode:
3873
- {
3874
- const jsx = target;
3875
- const [type, varProps, constProps, children, flags, key] = data;
3876
- jsx.type = type, jsx.varProps = varProps, jsx.constProps = constProps, jsx.children = children,
3877
- jsx.flags = flags, jsx.key = key;
3878
- break;
4017
+ target.stack = d[2];
4018
+ } else {
4019
+ target.stack = second;
3879
4020
  }
4021
+ break;
4022
+ }
3880
4023
 
3881
- case TypeIds.Set:
3882
- {
3883
- const set = target;
3884
- const d = data;
3885
- for (let i = 0; i < d.length; i++) {
3886
- set.add(d[i]);
3887
- }
3888
- break;
4024
+ case TypeIds.FormData:
4025
+ {
4026
+ const formData = target;
4027
+ const d = data;
4028
+ for (let i = 0; i < d.length; i++) {
4029
+ formData.append(d[i++], d[i]);
3889
4030
  }
4031
+ break;
4032
+ }
3890
4033
 
3891
- case TypeIds.Map:
3892
- {
3893
- const map = target;
3894
- const d = data;
3895
- for (let i = 0; i < d.length; i++) {
3896
- map.set(d[i++], d[i]);
3897
- }
3898
- break;
3899
- }
4034
+ case TypeIds.JSXNode:
4035
+ {
4036
+ const jsx = target;
4037
+ const [type, varProps, constProps, children, flags, key] = data;
4038
+ jsx.type = type, jsx.varProps = varProps, jsx.constProps = constProps, jsx.children = children,
4039
+ jsx.flags = flags, jsx.key = key;
4040
+ break;
4041
+ }
3900
4042
 
3901
- case TypeIds.Promise:
3902
- {
3903
- const promise = target;
3904
- const [resolved, result] = data;
3905
- const [resolve, reject] = resolvers.get(promise);
3906
- resolved ? resolve(result) : reject(result);
3907
- break;
4043
+ case TypeIds.Set:
4044
+ {
4045
+ const set = target;
4046
+ const d = data;
4047
+ for (let i = 0; i < d.length; i++) {
4048
+ set.add(d[i]);
3908
4049
  }
4050
+ break;
4051
+ }
3909
4052
 
3910
- case TypeIds.Uint8Array:
3911
- const bytes = target;
3912
- const buf = atob(data);
3913
- let i = 0;
3914
- for (const s of buf) {
3915
- bytes[i++] = s.charCodeAt(0);
4053
+ case TypeIds.Map:
4054
+ {
4055
+ const map = target;
4056
+ const d = data;
4057
+ for (let i = 0; i < d.length; i++) {
4058
+ map.set(d[i++], d[i]);
3916
4059
  }
3917
4060
  break;
4061
+ }
3918
4062
 
3919
- case TypeIds.PropsProxy:
3920
- const propsProxy = target;
3921
- propsProxy[_VAR_PROPS] = 0 === data ? {} : data[0], propsProxy[_CONST_PROPS] = data[1];
4063
+ case TypeIds.Promise:
4064
+ {
4065
+ const promise = target;
4066
+ const [resolved, result] = data;
4067
+ const [resolve, reject] = resolvers.get(promise);
4068
+ resolved ? resolve(result) : reject(result);
3922
4069
  break;
4070
+ }
3923
4071
 
3924
- case TypeIds.EffectData:
3925
- target.data = data[0];
3926
- break;
4072
+ case TypeIds.Uint8Array:
4073
+ const bytes = target;
4074
+ const buf = atob(data);
4075
+ let i = 0;
4076
+ for (const s of buf) {
4077
+ bytes[i++] = s.charCodeAt(0);
4078
+ }
4079
+ break;
4080
+
4081
+ case TypeIds.PropsProxy:
4082
+ const propsProxy = target;
4083
+ propsProxy[_VAR_PROPS] = 0 === data ? {} : data[0], propsProxy[_CONST_PROPS] = data[1];
4084
+ break;
3927
4085
 
3928
- default:
3929
- return throwErrorAndStop("Not implemented");
4086
+ case TypeIds.EffectData:
4087
+ {
4088
+ const effectData = target;
4089
+ effectData.data.$scopedStyleIdPrefix$ = data[0], effectData.data.$isConst$ = data[1];
4090
+ break;
3930
4091
  }
4092
+
4093
+ default:
4094
+ throw qError(QError.serializeErrorNotImplemented, [ typeId ]);
3931
4095
  }
4096
+ return target;
3932
4097
  };
3933
4098
  const _constants = [ void 0, null, !0, !1, "", EMPTY_ARRAY, EMPTY_OBJ, NEEDS_COMPUTATION, Slot, Fragment, NaN, 1 / 0, -1 / 0, Number.MAX_SAFE_INTEGER, Number.MAX_SAFE_INTEGER - 1, Number.MIN_SAFE_INTEGER ];
3934
4099
  const allocate = (container, typeId, value) => {
@@ -3989,10 +4154,8 @@
3989
4154
  return new ComputedSignal(container, null);
3990
4155
 
3991
4156
  case TypeIds.Store:
3992
- return createStore(container, {}, 0);
3993
-
3994
4157
  case TypeIds.StoreArray:
3995
- return createStore(container, [], 0);
4158
+ return null;
3996
4159
 
3997
4160
  case TypeIds.URLSearchParams:
3998
4161
  return new URLSearchParams(value);
@@ -4038,13 +4201,16 @@
4038
4201
  return vnodeOrDocument;
4039
4202
  }
4040
4203
  const vNode = retrieveVNodeOrDocument(container, value);
4041
- return vnode_isVNode(vNode) ? vnode_getNode(vNode) : throwErrorAndStop("expected vnode for ref prop, but got " + typeof vNode);
4204
+ if (vnode_isVNode(vNode)) {
4205
+ return vnode_getNode(vNode);
4206
+ }
4207
+ throw qError(QError.serializeErrorExpectedVNode, [ typeof vNode ]);
4042
4208
 
4043
4209
  case TypeIds.EffectData:
4044
- return new EffectData(null);
4210
+ return new EffectPropData({});
4045
4211
 
4046
4212
  default:
4047
- return throwErrorAndStop("unknown allocate type: " + typeId);
4213
+ throw qError(QError.serializeErrorCannotAllocate, [ typeId ]);
4048
4214
  }
4049
4215
  };
4050
4216
  function retrieveVNodeOrDocument(container, value) {
@@ -4153,8 +4319,13 @@
4153
4319
  const seen = depth > 1 && serializationContext.$wasSeen$(value);
4154
4320
  "number" == typeof seen && seen >= 0 ? output(TypeIds.RootRef, seen) : output(TypeIds.String, value);
4155
4321
  }
4322
+ } else if (void 0 === value) {
4323
+ output(TypeIds.Constant, Constants.Undefined);
4156
4324
  } else {
4157
- void 0 === value ? output(TypeIds.Constant, Constants.Undefined) : value === NEEDS_COMPUTATION ? output(TypeIds.Constant, Constants.NEEDS_COMPUTATION) : throwErrorAndStop("Unknown type: " + typeof value);
4325
+ if (value !== NEEDS_COMPUTATION) {
4326
+ throw qError(QError.serializeErrorUnknownType, [ typeof value ]);
4327
+ }
4328
+ output(TypeIds.Constant, Constants.NEEDS_COMPUTATION);
4158
4329
  }
4159
4330
  };
4160
4331
  const writeObjectValue = (value, idx) => {
@@ -4170,8 +4341,8 @@
4170
4341
  const constProps = value[_CONST_PROPS];
4171
4342
  const out = constProps ? [ varProps, constProps ] : Object.keys(varProps).length ? [ varProps ] : 0;
4172
4343
  output(TypeIds.PropsProxy, out);
4173
- } else if (value instanceof EffectData) {
4174
- output(TypeIds.EffectData, [ value.data ]);
4344
+ } else if (value instanceof EffectPropData) {
4345
+ output(TypeIds.EffectData, [ value.data.$scopedStyleIdPrefix$, value.data.$isConst$ ]);
4175
4346
  } else if (isStore(value)) {
4176
4347
  if (function(value) {
4177
4348
  return "__brand" in value && "resource" === value.__brand;
@@ -4179,7 +4350,7 @@
4179
4350
  serializationContext.$resources$.add(value);
4180
4351
  const res = promiseResults.get(value.value);
4181
4352
  if (!res) {
4182
- return throwErrorAndStop("Unvisited Resource");
4353
+ throw qError(QError.serializeErrorUnvisited, [ "resource" ]);
4183
4354
  }
4184
4355
  output(TypeIds.Resource, [ ...res, getStoreHandler(value).$effects$ ]);
4185
4356
  } else {
@@ -4217,7 +4388,7 @@
4217
4388
  } else if (value instanceof Signal) {
4218
4389
  const v = value instanceof ComputedSignal && (value.$invalid$ || fastSkipSerialize(value.$untrackedValue$)) ? NEEDS_COMPUTATION : value.$untrackedValue$;
4219
4390
  if (value instanceof WrappedSignal) {
4220
- output(TypeIds.WrappedSignal, [ ...serializeWrappingFn(serializationContext, value), value.$effectDependencies$, v, ...value.$effects$ || [] ]);
4391
+ output(TypeIds.WrappedSignal, [ ...serializeWrappingFn(serializationContext, value), value.$effectDependencies$, v, value.$hostElement$, ...value.$effects$ || [] ]);
4221
4392
  } else if (value instanceof ComputedSignal) {
4222
4393
  const out = [ value.$computeQrl$, value.$effects$ ];
4223
4394
  v !== NEEDS_COMPUTATION && out.push(v), output(TypeIds.ComputedSignal, out);
@@ -4273,12 +4444,12 @@
4273
4444
  } else if (isPromise(value)) {
4274
4445
  const res = promiseResults.get(value);
4275
4446
  if (!res) {
4276
- return throwErrorAndStop("Unvisited Promise");
4447
+ throw qError(QError.serializeErrorUnvisited, [ "promise" ]);
4277
4448
  }
4278
4449
  output(TypeIds.Promise, res);
4279
4450
  } else {
4280
4451
  if (!(value instanceof Uint8Array)) {
4281
- return throwErrorAndStop("implement");
4452
+ throw qError(QError.serializeErrorUnknownType, [ typeof value ]);
4282
4453
  }
4283
4454
  {
4284
4455
  let buf = "";
@@ -4306,7 +4477,10 @@
4306
4477
  $addRoot$,
4307
4478
  $getRootId$: obj => {
4308
4479
  const id = map.get(obj);
4309
- return id && -1 !== id ? id : throwErrorAndStop("Missing root id for: ", obj);
4480
+ if (!id || -1 === id) {
4481
+ throw qError(QError.serializeErrorMissingRootId, [ obj ]);
4482
+ }
4483
+ return id;
4310
4484
  },
4311
4485
  $syncFns$: syncFns,
4312
4486
  $addSyncFn$: (funcStr, argCount, fn) => {
@@ -4358,11 +4532,15 @@
4358
4532
  const v = obj instanceof WrappedSignal ? obj.untrackedValue : obj instanceof ComputedSignal && (obj.$invalid$ || fastSkipSerialize(obj)) ? NEEDS_COMPUTATION : obj.$untrackedValue$;
4359
4533
  v !== NEEDS_COMPUTATION && discoveredValues.push(v), obj.$effects$ && discoveredValues.push(...obj.$effects$),
4360
4534
  obj instanceof WrappedSignal ? (obj.$effectDependencies$ && discoveredValues.push(...obj.$effectDependencies$),
4361
- obj.$args$ && discoveredValues.push(...obj.$args$)) : obj instanceof ComputedSignal && discoveredValues.push(obj.$computeQrl$);
4535
+ obj.$args$ && discoveredValues.push(...obj.$args$), obj.$hostElement$ && discoveredValues.push(obj.$hostElement$)) : obj instanceof ComputedSignal && discoveredValues.push(obj.$computeQrl$);
4362
4536
  } else if (obj instanceof Task) {
4363
4537
  discoveredValues.push(obj.$el$, obj.$qrl$, obj.$state$, obj.$effectDependencies$);
4364
4538
  } else if (isSsrNode(obj)) {
4365
- discoveredValues.push(obj.vnodeData);
4539
+ if (discoverValuesForVNodeData(obj.vnodeData, discoveredValues), obj.childrenVNodeData && obj.childrenVNodeData.length) {
4540
+ for (const data of obj.childrenVNodeData) {
4541
+ discoverValuesForVNodeData(data, discoveredValues);
4542
+ }
4543
+ }
4366
4544
  } else if (isDomRef(obj)) {
4367
4545
  discoveredValues.push(obj.$ssrNode$.id);
4368
4546
  } else if (isJSXNode(obj)) {
@@ -4379,11 +4557,11 @@
4379
4557
  }), (error => {
4380
4558
  promiseResults.set(obj, [ !1, error ]), discoveredValues.push(error);
4381
4559
  })), promises.push(obj);
4382
- } else if (obj instanceof EffectData) {
4560
+ } else if (obj instanceof EffectPropData) {
4383
4561
  discoveredValues.push(obj.data);
4384
4562
  } else {
4385
4563
  if (!isObjectLiteral(obj)) {
4386
- return throwErrorAndStop("Unknown type: " + obj);
4564
+ throw qError(QError.serializeErrorUnknownType, [ obj ]);
4387
4565
  }
4388
4566
  Object.entries(obj).forEach((([key, value]) => {
4389
4567
  discoveredValues.push(key, value);
@@ -4415,6 +4593,19 @@
4415
4593
  $prepVNodeData$: prepVNodeData
4416
4594
  };
4417
4595
  };
4596
+ const isSsrAttrs = value => Array.isArray(value) && value.length > 0;
4597
+ const discoverValuesForVNodeData = (vnodeData, discoveredValues) => {
4598
+ for (const value of vnodeData) {
4599
+ if (isSsrAttrs(value)) {
4600
+ for (let i = 1; i < value.length; i += 2) {
4601
+ if ("q:key" === value[i - 1]) {
4602
+ continue;
4603
+ }
4604
+ discoveredValues.push(value[i]);
4605
+ }
4606
+ }
4607
+ }
4608
+ };
4418
4609
  const promiseResults = new WeakMap;
4419
4610
  function serializeWrappingFn(serializationContext, value) {
4420
4611
  value.$funcStr$ && "{" === value.$funcStr$[0] && (value.$funcStr$ = `(${value.$funcStr$})`);
@@ -4438,7 +4629,10 @@
4438
4629
  backChannel || (backChannel = globalThis[QRL_RUNTIME_CHUNK] = new Map), backChannel.set(value.$symbol$, value._devOnlySymbolRef),
4439
4630
  chunk || (chunk = QRL_RUNTIME_CHUNK);
4440
4631
  }
4441
- chunk || throwErrorAndStop("Missing chunk for: " + value.$symbol$), chunk.startsWith("./") && (chunk = chunk.slice(2));
4632
+ if (!chunk) {
4633
+ throw qError(QError.qrlMissingChunk, [ value.$symbol$ ]);
4634
+ }
4635
+ chunk.startsWith("./") && (chunk = chunk.slice(2));
4442
4636
  }
4443
4637
  let qrlStringInline = `${chunk}#${symbol}`;
4444
4638
  if (Array.isArray(value.$captureRef$) && value.$captureRef$.length > 0) {
@@ -4452,13 +4646,13 @@
4452
4646
  }
4453
4647
  return qrlStringInline;
4454
4648
  }
4455
- function deserializeData(container, typeId, propValue) {
4649
+ function deserializeData(container, typeId, value) {
4456
4650
  if (void 0 === typeId) {
4457
- return propValue;
4651
+ return value;
4458
4652
  }
4459
- const value = allocate(container, typeId, propValue);
4460
- return typeId >= TypeIds.Error && inflate(container, value, typeId, propValue),
4461
- value;
4653
+ let propValue = allocate(container, typeId, value);
4654
+ return typeId >= TypeIds.Error && (propValue = inflate(container, propValue, typeId, value)),
4655
+ propValue;
4462
4656
  }
4463
4657
  function _createDeserializeContainer(stateData, element) {
4464
4658
  let state;
@@ -4610,7 +4804,7 @@
4610
4804
  let expectIndex = 0;
4611
4805
  return unwrapped.forEach(((v, i) => {
4612
4806
  if (i !== expectIndex) {
4613
- throw qError(3, unwrapped);
4807
+ throw qError(QError.verifySerializable, [ unwrapped ]);
4614
4808
  }
4615
4809
  _verifySerializable(v, seen, ctx + "[" + i + "]"), expectIndex = i + 1;
4616
4810
  })), value;
@@ -4636,7 +4830,7 @@
4636
4830
  const fnName = value.name;
4637
4831
  message += ` because it's a function named "${fnName}". You might need to convert it to a QRL using $(fn):\n\nconst ${fnName} = $(${String(value)});\n\nPlease check out https://qwik.dev/docs/advanced/qrl/ for more information.`;
4638
4832
  }
4639
- console.error("Trying to serialize", value), throwErrorAndStop(message);
4833
+ throw qError(QError.verifySerializable, [ message ]);
4640
4834
  }
4641
4835
  return value;
4642
4836
  };
@@ -4657,7 +4851,7 @@
4657
4851
  function bindFnToContext(currentCtx, beforeFn) {
4658
4852
  return (...args) => maybeThen(resolveLazy(), (fn => {
4659
4853
  if (!isFunction(fn)) {
4660
- throw qError(10);
4854
+ throw qError(QError.qrlIsNotFunction);
4661
4855
  }
4662
4856
  if (beforeFn && !1 === beforeFn()) {
4663
4857
  return;
@@ -4958,7 +5152,22 @@
4958
5152
  onReady = () => q.forEach(q.push = v => sw.active.postMessage(v)), sw.installing ? sw.installing.addEventListener("statechange", (e => "activated" == e.target.state && onReady())) : onReady();
4959
5153
  })), v && q.push([ "verbose" ]), document.addEventListener("qprefetch", (e => e.detail.bundles && q.push([ "prefetch", b, ...e.detail.bundles ])));
4960
5154
  }).toString();
4961
- exports.$ = $, exports.Fragment = Fragment, exports.PrefetchGraph = (opts = {}) => {
5155
+ Object.defineProperty(exports, "isBrowser", {
5156
+ enumerable: !0,
5157
+ get: function() {
5158
+ return build.isBrowser;
5159
+ }
5160
+ }), Object.defineProperty(exports, "isDev", {
5161
+ enumerable: !0,
5162
+ get: function() {
5163
+ return build.isDev;
5164
+ }
5165
+ }), Object.defineProperty(exports, "isServer", {
5166
+ enumerable: !0,
5167
+ get: function() {
5168
+ return build.isServer;
5169
+ }
5170
+ }), exports.$ = $, exports.Fragment = Fragment, exports.PrefetchGraph = (opts = {}) => {
4962
5171
  const isTest = (void 0).TEST;
4963
5172
  if (build.isDev && !isTest) {
4964
5173
  return _jsxSorted("script", null, {
@@ -5009,7 +5218,18 @@
5009
5218
  if (isResourceReturn(resource)) {
5010
5219
  if (!isServerPlatform()) {
5011
5220
  const state = resource._state;
5012
- return "pending" === state && props.onPending ? Promise.resolve(props.onPending()) : "rejected" === state && props.onRejected ? Promise.resolve(resource._error).then(props.onRejected) : Promise.resolve(untrack((() => resource._resolved))).then(props.onResolved);
5221
+ if ("pending" === state && props.onPending) {
5222
+ return Promise.resolve().then(useBindInvokeContext(props.onPending));
5223
+ }
5224
+ if ("rejected" === state && props.onRejected) {
5225
+ return Promise.resolve(resource._error).then(useBindInvokeContext(props.onRejected));
5226
+ }
5227
+ {
5228
+ const resolvedValue = untrack((() => resource._resolved));
5229
+ if (void 0 !== resolvedValue) {
5230
+ return Promise.resolve(resolvedValue).then(useBindInvokeContext(props.onResolved));
5231
+ }
5232
+ }
5013
5233
  }
5014
5234
  return resource.value.then(useBindInvokeContext(props.onResolved), useBindInvokeContext(props.onRejected));
5015
5235
  }
@@ -5020,7 +5240,7 @@
5020
5240
  }), props.children, jsx(SSRComment, {
5021
5241
  data: "qkssr-po"
5022
5242
  }) ], exports.SkipRender = SkipRender, exports.Slot = Slot, exports._CONST_PROPS = _CONST_PROPS,
5023
- exports._DomContainer = DomContainer, exports._EMPTY_ARRAY = EMPTY_ARRAY, exports._EffectData = EffectData,
5243
+ exports._DomContainer = DomContainer, exports._EMPTY_ARRAY = EMPTY_ARRAY, exports._EffectData = EffectPropData,
5024
5244
  exports._IMMUTABLE = _IMMUTABLE, exports._SharedContainer = _SharedContainer, exports._VAR_PROPS = _VAR_PROPS,
5025
5245
  exports._deserialize = function(rawStateData, element) {
5026
5246
  if (null == rawStateData) {
@@ -5163,7 +5383,7 @@
5163
5383
  if (void 0 !== defaultValue) {
5164
5384
  return set(defaultValue);
5165
5385
  }
5166
- throw qError(13, context.id);
5386
+ throw qError(QError.notFoundContext, [ context.id ]);
5167
5387
  }, exports.useContextProvider = useContextProvider, exports.useErrorBoundary = () => {
5168
5388
  const store = useStore({
5169
5389
  error: void 0