@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,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * @qwik.dev/core/optimizer 2.0.0-alpha.3-dev+418fd6d
3
+ * @qwik.dev/core/optimizer 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
@@ -1260,7 +1260,7 @@ function createPath(opts = {}) {
1260
1260
  var QWIK_BINDING_MAP = {};
1261
1261
 
1262
1262
  var versions = {
1263
- qwik: "2.0.0-alpha.3-dev+418fd6d"
1263
+ qwik: "2.0.0-alpha.5-dev+cb53bbd"
1264
1264
  };
1265
1265
 
1266
1266
  async function getSystem() {
@@ -1541,7 +1541,7 @@ function generateManifestFromBundles(path, segments, injections, outputBundles,
1541
1541
  }
1542
1542
  return canonPath(bundle.fileName);
1543
1543
  };
1544
- const qrlNames = new Set([ ...segments.map((h2 => h2.name)) ]);
1544
+ const qrlNames = new Set([ ...segments.map((h => h.name)) ]);
1545
1545
  for (const outputBundle of Object.values(outputBundles)) {
1546
1546
  if ("chunk" !== outputBundle.type) {
1547
1547
  continue;
@@ -2265,7 +2265,7 @@ function createPlugin(optimizerOptions = {}) {
2265
2265
  const generateManifest = async () => {
2266
2266
  const optimizer2 = getOptimizer();
2267
2267
  const path = optimizer2.sys.path;
2268
- const segments = Array.from(clientResults.values()).flatMap((r => r.modules)).map((mod => mod.segment)).filter((h2 => !!h2));
2268
+ const segments = Array.from(clientResults.values()).flatMap((r => r.modules)).map((mod => mod.segment)).filter((h => !!h));
2269
2269
  const manifest = generateManifestFromBundles(path, segments, injections, rollupBundle, opts, debug);
2270
2270
  for (const symbol of Object.values(manifest.symbols)) {
2271
2271
  symbol.origin && (symbol.origin = normalizePath(symbol.origin));
@@ -2812,7 +2812,7 @@ function imgImportName(value) {
2812
2812
  }
2813
2813
 
2814
2814
  function toPascalCase(string) {
2815
- return `${string}`.toLowerCase().replace(new RegExp(/[-_]+/, "g"), " ").replace(new RegExp(/[^\w\s]/, "g"), "").replace(new RegExp(/\s+(.)(\w*)/, "g"), (($1, $22, $3) => `${$22.toUpperCase() + $3}`)).replace(new RegExp(/\w/), (s => s.toUpperCase()));
2815
+ return `${string}`.toLowerCase().replace(new RegExp(/[-_]+/, "g"), " ").replace(new RegExp(/[^\w\s]/, "g"), "").replace(new RegExp(/\s+(.)(\w*)/, "g"), (($1, $2, $3) => `${$2.toUpperCase() + $3}`)).replace(new RegExp(/\w/), (s => s.toUpperCase()));
2816
2816
  }
2817
2817
 
2818
2818
  var FORCE_COLOR;
@@ -2941,7 +2941,7 @@ var logWarn = (message, ...optionalParams) => {
2941
2941
 
2942
2942
  var createAndLogError = (asyncThrow, message, ...optionalParams) => {
2943
2943
  const err = message instanceof Error ? message : new Error(message);
2944
- console.error("%cQWIK ERROR", STYLE, err.message, ...optionalParams, err.stack);
2944
+ !qTest && console.error("%cQWIK ERROR", STYLE, err.message, ...optionalParams, err.stack);
2945
2945
  asyncThrow && !qTest && setTimeout((() => {
2946
2946
  throw err;
2947
2947
  }), 0);
@@ -2997,33 +2997,21 @@ function assertNumber(value1, text, ...parts) {
2997
2997
 
2998
2998
  var codeToText = (code, ...parts) => {
2999
2999
  if (qDev) {
3000
- const MAP = [ "Error while serializing class or style attributes", "Can not serialize a HTML Node that is not an Element", "Runtime but no instance found on element.", "Only primitive and object literals can be serialized", "Crash while rendering", "You can render over a existing q:container. Skipping render().", "Set property {{0}}", "Only function's and 'string's are supported.", "Only objects can be wrapped in 'QObject'", "Only objects literals can be wrapped in 'QObject'", "QRL is not a function", "Dynamic import not found", "Unknown type argument", "Actual value for useContext({{0}}) can not be found, make sure some ancestor component has set a value using useContextProvider(). In the browser make sure that the context was used during SSR so its state was serialized.", "Invoking 'use*()' method outside of invocation context.", "Cant access renderCtx for existing context", "Cant access document for existing context", "props are immutable", "<div> component can only be used at the root of a Qwik component$()", "Props are immutable by default.", "Calling a 'use*()' method outside 'component$(() => { HERE })' is not allowed. 'use*()' methods provide hooks to the 'component$' state and lifecycle, ie 'use' hooks can only be called synchronously within the 'component$' function or another 'use' method.\nSee https://qwik.dev/docs/components/tasks/#use-method-rules", "Container is already paused. Skipping", "", "When rendering directly on top of Document, the root node must be a <html>", "A <html> node must have 2 children. The first one <head> and the second one a <body>", 'Invalid JSXNode type "{{0}}". It must be either a function or a string. Found:', "Tracking value changes can only be done to useStore() objects and component props", "Missing Object ID for captured object", 'The provided Context reference "{{0}}" is not a valid context created by createContextId()', "<html> is the root container, it can not be rendered inside a component", "QRLs can not be resolved because it does not have an attached container. This means that the QRL does not know where it belongs inside the DOM, so it cant dynamically import() from a relative path.", "QRLs can not be dynamically resolved, because it does not have a chunk path", "The JSX ref attribute must be a Signal" ];
3000
+ const MAP = [ "Error while serializing class or style attributes", "", "", "Only primitive and object literals can be serialized. {{0}}", "", "You can render over a existing q:container. Skipping render().", "", "", "", "", "QRL is not a function", "Dynamic import not found", "Unknown type argument", "Actual value for useContext({{0}}) can not be found, make sure some ancestor component has set a value using useContextProvider(). In the browser make sure that the context was used during SSR so its state was serialized.", "Invoking 'use*()' method outside of invocation context.", "", "", "", "", "", "Calling a 'use*()' method outside 'component$(() => { HERE })' is not allowed. 'use*()' methods provide hooks to the 'component$' state and lifecycle, ie 'use' hooks can only be called synchronously within the 'component$' function or another 'use' method.\nSee https://qwik.dev/docs/components/tasks/#use-method-rules", "", "", "", "", "", "", "", 'The provided Context reference "{{0}}" is not a valid context created by createContextId()', "SsrError(tag): {{0}}", "QRLs can not be resolved because it does not have an attached container. This means that the QRL does not know where it belongs inside the DOM, so it cant dynamically import() from a relative path.", "QRLs can not be dynamically resolved, because it does not have a chunk path", "{{0}}\nThe JSX ref attribute must be a Signal", "Serialization Error: Deserialization of data type {{0}} is not implemented", "Serialization Error: Expected vnode for ref prop, but got {{0}}", "Serialization Error: Cannot allocate data type {{0}}", "Serialization Error: Missing root id for {{0}}", "Serialization Error: Serialization of data type {{0}} is not implemented", "Serialization Error: Unvisited {{0}}", "Serialization Error: Missing QRL chunk for {{0}}", "{{0}}\nThe value of the textarea must be a string found {{1}}", "Unable to find q:container", "Element must have 'q:container' attribute.", "Unknown vnode type {{0}}.", "Materialize error: missing element: {{0}} {{1}} {{2}}", "SsrError: {{0}}", "Cannot coerce a Signal, use `.value` instead", "useComputedSignal$ QRL {{0}} {{1}} returned a Promise", "ComputedSignal is read-only", "WrappedSignal is read-only", "SsrError: Promises not expected here.", "Attribute value is unsafe for SSR" ];
3001
3001
  let text = MAP[code] ?? "";
3002
3002
  parts.length && (text = text.replaceAll(/{{(\d+)}}/g, ((_, index) => {
3003
3003
  let v = parts[index];
3004
3004
  v && "object" === typeof v && v.constructor === Object && (v = JSON.stringify(v).slice(0, 50));
3005
3005
  return v;
3006
3006
  })));
3007
- return `Code(${code}): ${text}`;
3007
+ return `Code(Q${code}): ${text}`;
3008
3008
  }
3009
- return `Code(${code}) https://github.com/QwikDev/qwik/blob/main/packages/qwik/src/core/error/error.ts#L${8 + code}`;
3009
+ return `Code(Q${code}) https://github.com/QwikDev/qwik/blob/main/packages/qwik/src/core/error/error.ts#L${8 + code}`;
3010
3010
  };
3011
3011
 
3012
- var QError_stringifyClassOrStyle = 0;
3013
-
3014
- var QError_verifySerializable = 3;
3015
-
3016
- var QError_qrlIsNotFunction = 10;
3017
-
3018
- var QError_useInvokeContext = 20;
3019
-
3020
- var QError_qrlMissingContainer = 30;
3021
-
3022
- var QError_qrlMissingChunk = 31;
3023
-
3024
- var qError = (code, ...parts) => {
3025
- const text = codeToText(code, ...parts);
3026
- return logErrorAndStop(text, ...parts);
3012
+ var qError = (code, errorMessageArgs = []) => {
3013
+ const text = codeToText(code, ...errorMessageArgs);
3014
+ return logErrorAndStop(text, ...errorMessageArgs);
3027
3015
  };
3028
3016
 
3029
3017
  var createPlatform = () => ({
@@ -3037,10 +3025,10 @@ var createPlatform = () => ({
3037
3025
  }
3038
3026
  }
3039
3027
  if (!url) {
3040
- throw qError(QError_qrlMissingChunk, symbolName);
3028
+ throw qError(31, [ symbolName ]);
3041
3029
  }
3042
3030
  if (!containerEl) {
3043
- throw qError(QError_qrlMissingContainer, url, symbolName);
3031
+ throw qError(30, [ url, symbolName ]);
3044
3032
  }
3045
3033
  const urlDoc = toUrl(containerEl.ownerDocument, containerEl, url).toString();
3046
3034
  const urlCopy = new URL(urlDoc);
@@ -3098,7 +3086,7 @@ var maybeThen = (valueOrPromise, thenFn) => isPromise(valueOrPromise) ? valueOrP
3098
3086
  var maybeThenPassError = (valueOrPromise, thenFn) => isPromise(valueOrPromise) ? valueOrPromise.then(thenFn) : thenFn(valueOrPromise);
3099
3087
 
3100
3088
  var shouldNotError = reason => {
3101
- throwErrorAndStop("QWIK ERROR:", reason);
3089
+ throwErrorAndStop(reason);
3102
3090
  };
3103
3091
 
3104
3092
  var delay = timeout => new Promise((resolve => {
@@ -3131,43 +3119,6 @@ var isFunction = v => "function" === typeof v;
3131
3119
 
3132
3120
  var isDev2 = true;
3133
3121
 
3134
- var runtimeSymbolId = 0;
3135
-
3136
- var $2 = expression => {
3137
- if (!qRuntimeQrl && qDev) {
3138
- throw new Error("Optimizer should replace all usages of $() with some special syntax. If you need to create a QRL manually, use inlinedQrl() instead.");
3139
- }
3140
- return createQRL(null, "s" + runtimeSymbolId++, expression, null, null, null, null);
3141
- };
3142
-
3143
- var dollar = $2;
3144
-
3145
- var eventQrl = qrl2 => qrl2;
3146
-
3147
- var EMPTY_ARRAY = [];
3148
-
3149
- var EMPTY_OBJ = {};
3150
-
3151
- Object.freeze(EMPTY_ARRAY);
3152
-
3153
- Object.freeze(EMPTY_OBJ);
3154
-
3155
- var QObjectRecursive = 1;
3156
-
3157
- var QObjectImmutable = 2;
3158
-
3159
- var QObjectTargetSymbol = Symbol("proxy target");
3160
-
3161
- var QObjectFlagsSymbol = Symbol("proxy flags");
3162
-
3163
- var QObjectManagerSymbol = Symbol("proxy manager");
3164
-
3165
- var _CONST_PROPS = Symbol("CONST");
3166
-
3167
- var _VAR_PROPS = Symbol("VAR");
3168
-
3169
- var _IMMUTABLE = Symbol("IMMUTABLE");
3170
-
3171
3122
  var DEBUG_TYPE = "q:type";
3172
3123
 
3173
3124
  var START = "";
@@ -3260,6 +3211,8 @@ var ELEMENT_SEQ = "q:seq";
3260
3211
 
3261
3212
  var ELEMENT_SEQ_IDX = "q:seqIdx";
3262
3213
 
3214
+ var Q_PREFIX = "q:";
3215
+
3263
3216
  var NON_SERIALIZABLE_MARKER_PREFIX = ":";
3264
3217
 
3265
3218
  var USE_ON_LOCAL = NON_SERIALIZABLE_MARKER_PREFIX + "on";
@@ -3279,38 +3232,29 @@ function setLocale(locale) {
3279
3232
  }
3280
3233
 
3281
3234
  var versions3 = {
3282
- qwik: "2.0.0-alpha.3-dev+418fd6d",
3235
+ qwik: "2.0.0-alpha.5-dev+cb53bbd",
3283
3236
  qwikDom: globalThis.QWIK_DOM_VERSION
3284
3237
  };
3285
3238
 
3286
3239
  var isQrl = value => "function" === typeof value && "function" === typeof value.getSymbol;
3287
3240
 
3288
- var useSequentialScope = () => {
3289
- const iCtx = useInvokeContext();
3290
- const hostElement = iCtx.$hostElement$;
3291
- const host = hostElement;
3292
- let seq = iCtx.$container$.getHostProp(host, ELEMENT_SEQ);
3293
- if (null === seq) {
3294
- seq = [];
3295
- iCtx.$container$.setHostProp(host, ELEMENT_SEQ, seq);
3296
- }
3297
- let seqIdx = iCtx.$container$.getHostProp(host, ELEMENT_SEQ_IDX);
3298
- null === seqIdx && (seqIdx = 0);
3299
- iCtx.$container$.setHostProp(host, ELEMENT_SEQ_IDX, seqIdx + 1);
3300
- while (seq.length <= seqIdx) {
3301
- seq.push(void 0);
3302
- }
3303
- const set = value => {
3304
- qDev && qSerialize && verifySerializable(value);
3305
- return seq[seqIdx] = value;
3306
- };
3307
- return {
3308
- val: seq[seqIdx],
3309
- set: set,
3310
- i: seqIdx,
3311
- iCtx: iCtx
3312
- };
3313
- };
3241
+ var EMPTY_ARRAY = [];
3242
+
3243
+ var EMPTY_OBJ = {};
3244
+
3245
+ Object.freeze(EMPTY_ARRAY);
3246
+
3247
+ Object.freeze(EMPTY_OBJ);
3248
+
3249
+ var Slot = props => _jsxSorted(Virtual, null, {
3250
+ [QSlotS]: ""
3251
+ }, props.children, 0, props.name ?? "");
3252
+
3253
+ var SkipRender = Symbol("skip render");
3254
+
3255
+ var SSRRaw = () => null;
3256
+
3257
+ var SSRComment = () => null;
3314
3258
 
3315
3259
  var isJsxPropertyAnEventName = name => (name.startsWith("on") || name.startsWith("window:on") || name.startsWith("document:on")) && name.endsWith("$");
3316
3260
 
@@ -3371,511 +3315,382 @@ function isPreventDefault(key) {
3371
3315
  return key.startsWith("preventdefault:");
3372
3316
  }
3373
3317
 
3374
- var createContextId = name => {
3375
- assertTrue(/^[\w/.-]+$/.test(name), "Context name must only contain A-Z,a-z,0-9, _", name);
3376
- return Object.freeze({
3377
- id: fromCamelToKebabCase(name)
3378
- });
3318
+ var 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" ]);
3319
+
3320
+ var isUnitlessNumber = name => unitlessNumbers.has(name);
3321
+
3322
+ var serializeClass = obj => {
3323
+ if (!obj) {
3324
+ return "";
3325
+ }
3326
+ if (isString(obj)) {
3327
+ return obj.trim();
3328
+ }
3329
+ const classes = [];
3330
+ if (isArray(obj)) {
3331
+ for (const o of obj) {
3332
+ const classList = serializeClass(o);
3333
+ classList && classes.push(classList);
3334
+ }
3335
+ } else {
3336
+ for (const [key, value] of Object.entries(obj)) {
3337
+ value && classes.push(key.trim());
3338
+ }
3339
+ }
3340
+ return classes.join(" ");
3379
3341
  };
3380
3342
 
3381
- var ERROR_CONTEXT = createContextId("qk-error");
3343
+ var fromCamelToKebabCaseWithDash = text => text.replace(/([A-Z])/g, "-$1").toLowerCase();
3382
3344
 
3383
- var isRecoverable = err => {
3384
- if (err && err instanceof Error && "plugin" in err) {
3385
- return false;
3345
+ var stringifyStyle = obj => {
3346
+ if (null == obj) {
3347
+ return "";
3386
3348
  }
3387
- return true;
3349
+ if ("object" == typeof obj) {
3350
+ if (isArray(obj)) {
3351
+ throw qError(0, [ obj, "style" ]);
3352
+ }
3353
+ {
3354
+ const chunks = [];
3355
+ for (const key in obj) {
3356
+ if (Object.prototype.hasOwnProperty.call(obj, key)) {
3357
+ const value = obj[key];
3358
+ null != value && "function" !== typeof value && (key.startsWith("--") ? chunks.push(key + ":" + value) : chunks.push(fromCamelToKebabCaseWithDash(key) + ":" + setValueForStyle(key, value)));
3359
+ }
3360
+ }
3361
+ return chunks.join(";");
3362
+ }
3363
+ }
3364
+ return String(obj);
3388
3365
  };
3389
3366
 
3390
- function isSlotProp(prop) {
3391
- return !prop.startsWith("q:") && !prop.startsWith(NON_SERIALIZABLE_MARKER_PREFIX);
3367
+ var serializeBooleanOrNumberAttribute = value => null != value ? String(value) : null;
3368
+
3369
+ function serializeAttribute(key, value, styleScopedId) {
3370
+ if (isClassAttr(key)) {
3371
+ const serializedClass = serializeClass(value);
3372
+ value = styleScopedId ? styleScopedId + (serializedClass.length ? " " + serializedClass : serializedClass) : serializedClass;
3373
+ } else {
3374
+ "style" === key ? value = stringifyStyle(value) : isEnumeratedBooleanAttribute(key) || "number" === typeof value ? value = serializeBooleanOrNumberAttribute(value) : false === value || null == value ? value = null : true === value && isPreventDefault(key) && (value = "");
3375
+ }
3376
+ return value;
3392
3377
  }
3393
3378
 
3394
- function isParentSlotProp(prop) {
3395
- return prop.startsWith(QSlotParent);
3379
+ function isEnumeratedBooleanAttribute(key) {
3380
+ return isAriaAttribute(key) || [ "spellcheck", "draggable", "contenteditable" ].includes(key);
3396
3381
  }
3397
3382
 
3398
- var Subscriber = class {
3399
- constructor() {
3400
- __publicField(this, "$effectDependencies$", null);
3383
+ var setValueForStyle = (styleName, value) => {
3384
+ if ("number" === typeof value && 0 !== value && !isUnitlessNumber(styleName)) {
3385
+ return value + "px";
3401
3386
  }
3387
+ return value;
3402
3388
  };
3403
3389
 
3404
- function isSubscriber(value) {
3405
- return value instanceof Subscriber || value instanceof WrappedSignal;
3390
+ function isAriaAttribute(prop) {
3391
+ return prop.startsWith("aria-");
3406
3392
  }
3407
3393
 
3408
- function clearVNodeEffectDependencies(value) {
3409
- const effects = vnode_getProp(value, QSubscribers, null);
3410
- if (!effects) {
3411
- return;
3412
- }
3413
- for (let i = effects.length - 1; i >= 0; i--) {
3414
- const subscriber = effects[i];
3415
- const subscriptionRemoved = clearEffects(subscriber, value);
3416
- subscriptionRemoved && effects.splice(i, 1);
3417
- }
3418
- }
3394
+ var styleContent = styleId => ComponentStylesPrefixContent + styleId;
3419
3395
 
3420
- function clearSubscriberEffectDependencies(value) {
3421
- if (value.$effectDependencies$) {
3422
- for (let i = value.$effectDependencies$.length - 1; i >= 0; i--) {
3423
- const subscriber = value.$effectDependencies$[i];
3424
- const subscriptionRemoved = clearEffects(subscriber, value);
3425
- subscriptionRemoved && value.$effectDependencies$.splice(i, 1);
3396
+ function hasClassAttr(props) {
3397
+ for (const key in props) {
3398
+ if (Object.prototype.hasOwnProperty.call(props, key) && isClassAttr(key)) {
3399
+ return true;
3426
3400
  }
3427
3401
  }
3402
+ return false;
3428
3403
  }
3429
3404
 
3430
- function clearEffects(subscriber, value) {
3431
- if (!isSignal(subscriber)) {
3432
- return false;
3433
- }
3434
- const effectSubscriptions = subscriber.$effects$;
3435
- if (!effectSubscriptions) {
3436
- return false;
3437
- }
3438
- let subscriptionRemoved = false;
3439
- for (let i = effectSubscriptions.length - 1; i >= 0; i--) {
3440
- const effect = effectSubscriptions[i];
3441
- if (effect[0] === value) {
3442
- effectSubscriptions.splice(i, 1);
3443
- subscriptionRemoved = true;
3444
- }
3445
- }
3446
- return subscriptionRemoved;
3405
+ function isClassAttr(key) {
3406
+ return "class" === key || "className" === key;
3447
3407
  }
3448
3408
 
3449
- var NEEDS_COMPUTATION = Symbol("invalid");
3450
-
3451
- var DEBUG = false;
3409
+ function convertScopedStyleIdsToArray(scopedStyleIds) {
3410
+ return scopedStyleIds?.split(" ") ?? null;
3411
+ }
3452
3412
 
3453
- var log = (...args) => console.log("SIGNAL", ...args.map(qwikDebugToString));
3413
+ function convertStyleIdsToString(scopedStyleIds) {
3414
+ return Array.from(scopedStyleIds).join(" ");
3415
+ }
3454
3416
 
3455
- var throwIfQRLNotResolved = qrl2 => {
3456
- const resolved = qrl2.resolved;
3457
- if (!resolved) {
3458
- throw qrl2.resolve();
3417
+ var addComponentStylePrefix = styleId => {
3418
+ if (styleId) {
3419
+ let idx = 0;
3420
+ do {
3421
+ styleId = styleId.substring(0, idx) + styleContent(styleId.substring(idx));
3422
+ } while (0 !== (idx = styleId.indexOf(" ", idx) + 1));
3459
3423
  }
3424
+ return styleId || null;
3460
3425
  };
3461
3426
 
3462
- var isSignal = value => value instanceof Signal;
3427
+ var DEBUG = false;
3463
3428
 
3464
- var EffectData = class {
3465
- constructor(data) {
3466
- __publicField(this, "data");
3467
- this.data = data;
3429
+ var log = (...args) => console.log("STORE", ...args.map(qwikDebugToString));
3430
+
3431
+ var STORE_TARGET = Symbol("store.target");
3432
+
3433
+ var STORE_HANDLER = Symbol("store.handler");
3434
+
3435
+ var STORE_ARRAY_PROP = Symbol("store.array");
3436
+
3437
+ var getStoreHandler = value => value[STORE_HANDLER];
3438
+
3439
+ var getStoreTarget = value => value?.[STORE_TARGET] || null;
3440
+
3441
+ var unwrapStore = value => getStoreTarget(value) || value;
3442
+
3443
+ var isStore = value => STORE_TARGET in value;
3444
+
3445
+ function createStore(container, obj, flags) {
3446
+ return new Proxy(obj, new StoreHandler(flags, container || null));
3447
+ }
3448
+
3449
+ var getOrCreateStore = (obj, flags, container) => {
3450
+ if (isSerializableObject(obj) && container) {
3451
+ let store = container.$storeProxyMap$.get(obj);
3452
+ if (!store) {
3453
+ store = createStore(container, obj, flags);
3454
+ container.$storeProxyMap$.set(obj, store);
3455
+ }
3456
+ return store;
3468
3457
  }
3458
+ return obj;
3469
3459
  };
3470
3460
 
3471
- var Signal = class {
3472
- constructor(container, value) {
3473
- __publicField(this, "$untrackedValue$");
3461
+ var StoreHandler = class {
3462
+ constructor($flags$, $container$) {
3463
+ this.$flags$ = $flags$;
3464
+ this.$container$ = $container$;
3474
3465
  __publicField(this, "$effects$", null);
3475
- __publicField(this, "$container$", null);
3476
- this.$container$ = container;
3477
- this.$untrackedValue$ = value;
3478
- DEBUG && log("new", this);
3479
- }
3480
- get untrackedValue() {
3481
- return this.$untrackedValue$;
3482
3466
  }
3483
- set untrackedValue(value) {
3484
- this.$untrackedValue$ = value;
3467
+ toString() {
3468
+ return "[Store]";
3485
3469
  }
3486
- get value() {
3470
+ get(target, prop) {
3471
+ if ("symbol" === typeof prop) {
3472
+ if (prop === STORE_TARGET) {
3473
+ return target;
3474
+ }
3475
+ if (prop === STORE_HANDLER) {
3476
+ return this;
3477
+ }
3478
+ return target[prop];
3479
+ }
3487
3480
  const ctx = tryGetInvokeContext();
3481
+ const value = target[prop];
3488
3482
  if (ctx) {
3489
3483
  if (null === this.$container$) {
3490
3484
  if (!ctx.$container$) {
3491
- return this.untrackedValue;
3485
+ return value;
3492
3486
  }
3493
3487
  this.$container$ = ctx.$container$;
3494
3488
  } else {
3495
3489
  assertTrue(!ctx.$container$ || ctx.$container$ === this.$container$, "Do not use signals across containers");
3496
3490
  }
3497
3491
  const effectSubscriber = ctx.$effectSubscriber$;
3498
- if (effectSubscriber) {
3499
- const effects = this.$effects$ || (this.$effects$ = []);
3500
- ensureContainsEffect(effects, effectSubscriber);
3501
- ensureContains(effectSubscriber, this);
3502
- isSubscriber(this) && ensureEffectContainsSubscriber(effectSubscriber[0], this, this.$container$);
3503
- DEBUG && log("read->sub", pad("\n" + this.toString(), " "));
3504
- }
3492
+ effectSubscriber && addEffect(target, Array.isArray(target) ? STORE_ARRAY_PROP : prop, this, effectSubscriber);
3505
3493
  }
3506
- return this.untrackedValue;
3507
- }
3508
- set value(value) {
3509
- if (value !== this.$untrackedValue$) {
3510
- DEBUG && log("Signal.set", this.$untrackedValue$, "->", value, pad("\n" + this.toString(), " "));
3511
- this.$untrackedValue$ = value;
3512
- triggerEffects(this.$container$, this, this.$effects$);
3494
+ if ("toString" === prop && value === Object.prototype.toString) {
3495
+ return this.toString;
3496
+ }
3497
+ const flags = this.$flags$;
3498
+ if (1 & flags && "object" === typeof value && null !== value && !Object.isFrozen(value) && !isStore(value) && !Object.isFrozen(target)) {
3499
+ return getOrCreateStore(value, this.$flags$, this.$container$);
3513
3500
  }
3501
+ return value;
3514
3502
  }
3515
- valueOf() {
3516
- if (qDev) {
3517
- return throwErrorAndStop("Cannot coerce a Signal, use `.value` instead");
3503
+ set(target, prop, value) {
3504
+ if ("symbol" === typeof prop) {
3505
+ target[prop] = value;
3506
+ return true;
3518
3507
  }
3508
+ const newValue = 1 & this.$flags$ ? unwrapStore(value) : value;
3509
+ if (prop in target) {
3510
+ const oldValue = target[prop];
3511
+ if (newValue !== oldValue) {
3512
+ DEBUG && log("Store.set", oldValue, "->", newValue, pad("\n" + this.toString(), " "));
3513
+ setNewValueAndTriggerEffects(prop, newValue, target, this);
3514
+ }
3515
+ } else {
3516
+ DEBUG && log("Store.set", "create property", newValue, pad("\n" + this.toString(), " "));
3517
+ setNewValueAndTriggerEffects(prop, newValue, target, this);
3518
+ }
3519
+ return true;
3519
3520
  }
3520
- toString() {
3521
- return `[${this.constructor.name}${this.$invalid$ ? " INVALID" : ""} ${String(this.$untrackedValue$)}]` + (this.$effects$?.map((e => "\n -> " + pad(qwikDebugToString(e[0]), " "))).join("\n") || "");
3521
+ deleteProperty(target, prop) {
3522
+ if ("string" != typeof prop || !delete target[prop]) {
3523
+ return false;
3524
+ }
3525
+ triggerEffects(this.$container$, this, getEffects(target, prop, this.$effects$));
3526
+ return true;
3522
3527
  }
3523
- toJSON() {
3528
+ has(target, prop) {
3529
+ if (prop === STORE_TARGET) {
3530
+ return true;
3531
+ }
3532
+ if ("string" === typeof prop) {
3533
+ const ctx = tryGetInvokeContext();
3534
+ if (ctx) {
3535
+ const effectSubscriber = ctx.$effectSubscriber$;
3536
+ effectSubscriber && addEffect(target, Array.isArray(target) ? STORE_ARRAY_PROP : prop, this, effectSubscriber);
3537
+ }
3538
+ }
3539
+ return Object.prototype.hasOwnProperty.call(target, prop);
3540
+ }
3541
+ ownKeys(target) {
3542
+ const ctx = tryGetInvokeContext();
3543
+ const effectSubscriber = ctx?.$effectSubscriber$;
3544
+ effectSubscriber && addEffect(target, STORE_ARRAY_PROP, this, effectSubscriber);
3545
+ return Reflect.ownKeys(target);
3546
+ }
3547
+ getOwnPropertyDescriptor(target, prop) {
3548
+ if (Array.isArray(target) || "symbol" === typeof prop) {
3549
+ return Object.getOwnPropertyDescriptor(target, prop);
3550
+ }
3524
3551
  return {
3525
- value: this.$untrackedValue$
3552
+ enumerable: true,
3553
+ configurable: true
3526
3554
  };
3527
3555
  }
3528
3556
  };
3529
3557
 
3530
- var ensureContains = (array, value) => {
3531
- const isMissing = -1 === array.indexOf(value);
3532
- isMissing && array.push(value);
3533
- };
3558
+ function addEffect(target, prop, store, effectSubscriber) {
3559
+ const effectsMap = store.$effects$ || (store.$effects$ = {});
3560
+ const effects = Object.prototype.hasOwnProperty.call(effectsMap, prop) && effectsMap[prop] || (effectsMap[prop] = []);
3561
+ ensureContainsEffect(effects, effectSubscriber);
3562
+ ensureContains(effectSubscriber, target);
3563
+ ensureEffectContainsSubscriber(effectSubscriber[0], target, store.$container$);
3564
+ DEBUG && log("sub", pad("\n" + store.$effects$.toString(), " "));
3565
+ }
3534
3566
 
3535
- var ensureContainsEffect = (array, effectSubscriptions) => {
3536
- for (let i = 0; i < array.length; i++) {
3537
- const existingEffect = array[i];
3538
- if (existingEffect[0] === effectSubscriptions[0] && existingEffect[1] === effectSubscriptions[1]) {
3539
- return;
3540
- }
3567
+ function setNewValueAndTriggerEffects(prop, value, target, currentStore) {
3568
+ target[prop] = value;
3569
+ triggerEffects(currentStore.$container$, currentStore, getEffects(target, prop, currentStore.$effects$));
3570
+ }
3571
+
3572
+ function getEffects(target, prop, storeEffects) {
3573
+ let effectsToTrigger = storeEffects ? Array.isArray(target) ? Object.values(storeEffects).flatMap((effects => effects)) : storeEffects[prop] : null;
3574
+ const storeArrayValue = storeEffects?.[STORE_ARRAY_PROP];
3575
+ if (storeArrayValue) {
3576
+ effectsToTrigger || (effectsToTrigger = []);
3577
+ effectsToTrigger.push(...storeArrayValue);
3541
3578
  }
3542
- array.push(effectSubscriptions);
3543
- };
3579
+ return effectsToTrigger;
3580
+ }
3544
3581
 
3545
- var ensureEffectContainsSubscriber = (effect, subscriber, container) => {
3546
- if (isSubscriber(effect)) {
3547
- effect.$effectDependencies$ || (effect.$effectDependencies$ = []);
3548
- if (subscriberExistInSubscribers(effect.$effectDependencies$, subscriber)) {
3549
- return;
3550
- }
3551
- effect.$effectDependencies$.push(subscriber);
3552
- } else if (vnode_isVNode(effect) && vnode_isVirtualVNode(effect)) {
3553
- let subscribers = vnode_getProp(effect, QSubscribers, container ? container.$getObjectById$ : null);
3554
- subscribers || (subscribers = []);
3555
- if (subscriberExistInSubscribers(subscribers, subscriber)) {
3556
- return;
3557
- }
3558
- subscribers.push(subscriber);
3559
- vnode_setProp(effect, QSubscribers, subscribers);
3560
- } else if (isSSRNode(effect)) {
3561
- let subscribers = effect.getProp(QSubscribers);
3562
- subscribers || (subscribers = []);
3563
- if (subscriberExistInSubscribers(subscribers, subscriber)) {
3564
- return;
3565
- }
3566
- subscribers.push(subscriber);
3567
- effect.setProp(QSubscribers, subscribers);
3582
+ var Subscriber = class {
3583
+ constructor() {
3584
+ __publicField(this, "$effectDependencies$", null);
3568
3585
  }
3569
3586
  };
3570
3587
 
3571
- var isSSRNode = effect => "setProp" in effect && "getProp" in effect && "removeProp" in effect && "id" in effect;
3588
+ function isSubscriber(value) {
3589
+ return value instanceof Subscriber || value instanceof WrappedSignal;
3590
+ }
3572
3591
 
3573
- var subscriberExistInSubscribers = (subscribers, subscriber) => {
3574
- for (let i = 0; i < subscribers.length; i++) {
3575
- if (subscribers[i] === subscriber) {
3576
- return true;
3577
- }
3592
+ function clearVNodeEffectDependencies(container, value) {
3593
+ vnode_isElementVNode(value) && ensureMaterialized(value);
3594
+ const effects = vnode_getProp(value, QSubscribers, container.$getObjectById$);
3595
+ if (!effects) {
3596
+ return;
3578
3597
  }
3579
- return false;
3580
- };
3581
-
3582
- var triggerEffects = (container, signal, effects) => {
3583
- if (effects) {
3584
- const scheduleEffect = effectSubscriptions => {
3585
- const effect = effectSubscriptions[0];
3586
- const property = effectSubscriptions[1];
3587
- assertDefined(container, "Container must be defined.");
3588
- if (isTask(effect)) {
3589
- effect.$flags$ |= 8;
3590
- DEBUG && log("schedule.effect.task", pad("\n" + String(effect), " "));
3591
- let choreType = 3;
3592
- 1 & effect.$flags$ ? choreType = 64 : 4 & effect.$flags$ && (choreType = 2);
3593
- container.$scheduler$(choreType, effect);
3594
- } else if (effect instanceof Signal) {
3595
- effect instanceof ComputedSignal && (effect.$computeQrl$.resolved || container.$scheduler$(1, null, effect.$computeQrl$));
3596
- try {
3597
- retryOnPromise((() => effect.$invalidate$()));
3598
- } catch (e) {
3599
- logError(e);
3600
- }
3601
- } else if (":" === property) {
3602
- const host = effect;
3603
- const qrl2 = container.getHostProp(host, OnRenderProp);
3604
- assertDefined(qrl2, "Component must have QRL");
3605
- const props = container.getHostProp(host, ELEMENT_PROPS);
3606
- container.$scheduler$(7, host, qrl2, props);
3607
- } else if ("." === property) {
3608
- const host = effect;
3609
- const target = host;
3610
- container.$scheduler$(4, host, target, signal);
3611
- } else {
3612
- const host = effect;
3613
- let effectData = effectSubscriptions[2];
3614
- if (effectData instanceof EffectData) {
3615
- const data = effectData.data;
3616
- const payload = {
3617
- ...data,
3618
- $value$: signal
3619
- };
3620
- container.$scheduler$(5, host, property, payload);
3621
- }
3622
- }
3623
- };
3624
- effects.forEach(scheduleEffect);
3598
+ for (let i = effects.length - 1; i >= 0; i--) {
3599
+ const subscriber = effects[i];
3600
+ clearEffects(subscriber, value, effects, i, container);
3625
3601
  }
3626
- DEBUG && log("done scheduling");
3627
- };
3602
+ 0 === effects.length && vnode_setProp(value, QSubscribers, null);
3603
+ }
3628
3604
 
3629
- var ComputedSignal = class extends Signal {
3630
- constructor(container, fn) {
3631
- super(container, NEEDS_COMPUTATION);
3632
- __publicField(this, "$computeQrl$");
3633
- __publicField(this, "$invalid$", true);
3634
- this.$computeQrl$ = fn;
3605
+ function clearSubscriberEffectDependencies(container, value) {
3606
+ if (value.$effectDependencies$) {
3607
+ for (let i = value.$effectDependencies$.length - 1; i >= 0; i--) {
3608
+ const subscriber = value.$effectDependencies$[i];
3609
+ clearEffects(subscriber, value, value.$effectDependencies$, i, container);
3610
+ }
3611
+ 0 === value.$effectDependencies$.length && (value.$effectDependencies$ = null);
3635
3612
  }
3636
- $invalidate$() {
3637
- this.$invalid$ = true;
3638
- if (!this.$effects$?.length) {
3639
- return;
3613
+ }
3614
+
3615
+ function clearEffects(subscriber, value, effectArray, indexToRemove, container) {
3616
+ let subscriptionRemoved = false;
3617
+ const seenSet = new Set;
3618
+ if (subscriber instanceof WrappedSignal) {
3619
+ subscriptionRemoved = clearSignalEffects(subscriber, value, seenSet);
3620
+ } else if (container.$storeProxyMap$.has(subscriber)) {
3621
+ const store = container.$storeProxyMap$.get(subscriber);
3622
+ const handler = getStoreHandler(store);
3623
+ subscriptionRemoved = clearStoreEffects(handler, value);
3624
+ }
3625
+ subscriptionRemoved && effectArray.splice(indexToRemove, 1);
3626
+ }
3627
+
3628
+ function clearSignalEffects(subscriber, value, seenSet) {
3629
+ const effectSubscriptions = subscriber.$effects$;
3630
+ let subscriptionRemoved = false;
3631
+ if (effectSubscriptions) {
3632
+ for (let i = effectSubscriptions.length - 1; i >= 0; i--) {
3633
+ const effect = effectSubscriptions[i];
3634
+ if (effect[0] === value) {
3635
+ effectSubscriptions.splice(i, 1);
3636
+ subscriptionRemoved = true;
3637
+ }
3640
3638
  }
3641
- this.$computeIfNeeded$() && triggerEffects(this.$container$, this, this.$effects$);
3642
3639
  }
3643
- force() {
3644
- this.$invalid$ = true;
3645
- triggerEffects(this.$container$, this, this.$effects$);
3640
+ if (subscriber instanceof WrappedSignal) {
3641
+ const hostElement = subscriber.$hostElement$;
3642
+ hostElement && hostElement === value && (subscriber.$hostElement$ = null);
3643
+ const args = subscriber.$args$;
3644
+ args && clearArgsEffects(args, subscriber, seenSet);
3646
3645
  }
3647
- get untrackedValue() {
3648
- this.$computeIfNeeded$();
3649
- assertFalse(this.$untrackedValue$ === NEEDS_COMPUTATION, "Invalid state");
3650
- return this.$untrackedValue$;
3646
+ return subscriptionRemoved;
3647
+ }
3648
+
3649
+ function clearStoreEffects(storeHandler, value) {
3650
+ const effectSubscriptions = storeHandler.$effects$;
3651
+ if (!effectSubscriptions) {
3652
+ return false;
3651
3653
  }
3652
- $computeIfNeeded$() {
3653
- if (!this.$invalid$) {
3654
- return false;
3655
- }
3656
- const computeQrl = this.$computeQrl$;
3657
- throwIfQRLNotResolved(computeQrl);
3658
- const ctx = tryGetInvokeContext();
3659
- const previousEffectSubscription = ctx?.$effectSubscriber$;
3660
- ctx && (ctx.$effectSubscriber$ = [ this, "." ]);
3661
- try {
3662
- const untrackedValue = computeQrl.getFn(ctx)();
3663
- isPromise(untrackedValue) && throwErrorAndStop(`useComputedSignal$ QRL ${computeQrl.dev ? `${computeQrl.dev.file} ` : ""}${computeQrl.$hash$} returned a Promise`);
3664
- DEBUG && log("Signal.$compute$", untrackedValue);
3665
- this.$invalid$ = false;
3666
- const didChange = untrackedValue !== this.$untrackedValue$;
3667
- didChange && (this.$untrackedValue$ = untrackedValue);
3668
- return didChange;
3669
- } finally {
3670
- ctx && (ctx.$effectSubscriber$ = previousEffectSubscription);
3654
+ let subscriptionRemoved = false;
3655
+ for (const key in effectSubscriptions) {
3656
+ const effects = effectSubscriptions[key];
3657
+ for (let i = effects.length - 1; i >= 0; i--) {
3658
+ const effect = effects[i];
3659
+ if (effect[0] === value) {
3660
+ effects.splice(i, 1);
3661
+ subscriptionRemoved = true;
3662
+ }
3671
3663
  }
3664
+ 0 === effects.length && delete effectSubscriptions[key];
3672
3665
  }
3673
- get value() {
3674
- return super.value;
3675
- }
3676
- set value(_) {
3677
- throwErrorAndStop("ComputedSignal is read-only");
3666
+ return subscriptionRemoved;
3667
+ }
3668
+
3669
+ function clearArgsEffects(args, subscriber, seenSet) {
3670
+ for (let i = args.length - 1; i >= 0; i--) {
3671
+ const arg = args[i];
3672
+ clearArgEffect(arg, subscriber, seenSet);
3678
3673
  }
3679
- };
3674
+ }
3680
3675
 
3681
- var WrappedSignal = class extends Signal {
3682
- constructor(container, fn, args, fnStr) {
3683
- super(container, NEEDS_COMPUTATION);
3684
- __publicField(this, "$args$");
3685
- __publicField(this, "$func$");
3686
- __publicField(this, "$funcStr$");
3687
- __publicField(this, "$invalid$", true);
3688
- __publicField(this, "$effectDependencies$", null);
3689
- this.$args$ = args;
3690
- this.$func$ = fn;
3691
- this.$funcStr$ = fnStr;
3676
+ function clearArgEffect(arg, subscriber, seenSet) {
3677
+ if (seenSet.has(arg)) {
3678
+ return;
3692
3679
  }
3693
- $invalidate$() {
3694
- this.$invalid$ = true;
3695
- if (!this.$effects$?.length) {
3696
- return;
3680
+ seenSet.add(arg);
3681
+ if (isSignal(arg)) {
3682
+ clearSignalEffects(arg, subscriber, seenSet);
3683
+ } else if ("object" === typeof arg && null !== arg) {
3684
+ if (isStore(arg)) {
3685
+ clearStoreEffects(getStoreHandler(arg), subscriber);
3686
+ } else {
3687
+ for (const key in arg) {
3688
+ clearArgEffect(arg[key], subscriber, seenSet);
3689
+ }
3697
3690
  }
3698
- this.$computeIfNeeded$() && triggerEffects(this.$container$, this, this.$effects$);
3699
- }
3700
- force() {
3701
- this.$invalid$ = true;
3702
- triggerEffects(this.$container$, this, this.$effects$);
3703
- }
3704
- get untrackedValue() {
3705
- this.$computeIfNeeded$();
3706
- assertFalse(this.$untrackedValue$ === NEEDS_COMPUTATION, "Invalid state");
3707
- return this.$untrackedValue$;
3691
+ } else {
3692
+ Array.isArray(arg) && clearArgsEffects(arg, subscriber, seenSet);
3708
3693
  }
3709
- $computeIfNeeded$() {
3710
- if (!this.$invalid$) {
3711
- return false;
3712
- }
3713
- const untrackedValue = trackSignal((() => this.$func$(...this.$args$)), this, ".", this.$container$);
3714
- const didChange = untrackedValue !== this.$untrackedValue$;
3715
- didChange && (this.$untrackedValue$ = untrackedValue);
3716
- return didChange;
3717
- }
3718
- get value() {
3719
- return super.value;
3720
- }
3721
- set value(_) {
3722
- throwErrorAndStop("WrappedSignal is read-only");
3723
- }
3724
- };
3725
-
3726
- var DEBUG2 = false;
3727
-
3728
- var log2 = (...args) => console.log("STORE", ...args.map(qwikDebugToString));
3729
-
3730
- var STORE_TARGET = Symbol("store.target");
3731
-
3732
- var STORE_HANDLER = Symbol("store.handler");
3733
-
3734
- var STORE_ARRAY_PROP = Symbol("store.array");
3735
-
3736
- var getStoreHandler = value => value[STORE_HANDLER];
3737
-
3738
- var getStoreTarget = value => value?.[STORE_TARGET] || null;
3739
-
3740
- var unwrapStore = value => getStoreTarget(value) || value;
3741
-
3742
- var isStore = value => STORE_TARGET in value;
3743
-
3744
- function createStore(container, obj, flags) {
3745
- return new Proxy(obj, new StoreHandler(flags, container || null));
3746
- }
3747
-
3748
- var getOrCreateStore = (obj, flags, container) => {
3749
- if (isSerializableObject(obj) && container) {
3750
- let store = container.$storeProxyMap$.get(obj);
3751
- if (!store) {
3752
- store = createStore(container, obj, flags);
3753
- container.$storeProxyMap$.set(obj, store);
3754
- }
3755
- return store;
3756
- }
3757
- return obj;
3758
- };
3759
-
3760
- var StoreHandler = class {
3761
- constructor($flags$, $container$) {
3762
- this.$flags$ = $flags$;
3763
- this.$container$ = $container$;
3764
- __publicField(this, "$effects$", null);
3765
- }
3766
- toString() {
3767
- return "[Store]";
3768
- }
3769
- get(target, prop) {
3770
- if ("symbol" === typeof prop) {
3771
- if (prop === STORE_TARGET) {
3772
- return target;
3773
- }
3774
- if (prop === STORE_HANDLER) {
3775
- return this;
3776
- }
3777
- return target[prop];
3778
- }
3779
- const ctx = tryGetInvokeContext();
3780
- const value = target[prop];
3781
- if (ctx) {
3782
- if (null === this.$container$) {
3783
- if (!ctx.$container$) {
3784
- return value;
3785
- }
3786
- this.$container$ = ctx.$container$;
3787
- } else {
3788
- assertTrue(!ctx.$container$ || ctx.$container$ === this.$container$, "Do not use signals across containers");
3789
- }
3790
- const effectSubscriber = ctx.$effectSubscriber$;
3791
- effectSubscriber && addEffect(target, Array.isArray(target) ? STORE_ARRAY_PROP : prop, this, effectSubscriber);
3792
- }
3793
- if ("toString" === prop && value === Object.prototype.toString) {
3794
- return this.toString;
3795
- }
3796
- const flags = this.$flags$;
3797
- if (1 & flags && "object" === typeof value && null !== value && !Object.isFrozen(value) && !isStore(value) && !Object.isFrozen(target)) {
3798
- return getOrCreateStore(value, this.$flags$, this.$container$);
3799
- }
3800
- return value;
3801
- }
3802
- set(target, prop, value) {
3803
- target = unwrapDeserializerProxy(target);
3804
- if ("symbol" === typeof prop) {
3805
- target[prop] = value;
3806
- return true;
3807
- }
3808
- const newValue = 1 & this.$flags$ ? unwrapStore(value) : value;
3809
- if (prop in target) {
3810
- const oldValue = target[prop];
3811
- if (newValue !== oldValue) {
3812
- DEBUG2 && log2("Store.set", oldValue, "->", newValue, pad("\n" + this.toString(), " "));
3813
- setNewValueAndTriggerEffects(prop, newValue, target, this);
3814
- }
3815
- } else {
3816
- DEBUG2 && log2("Store.set", "create property", newValue, pad("\n" + this.toString(), " "));
3817
- setNewValueAndTriggerEffects(prop, newValue, target, this);
3818
- }
3819
- return true;
3820
- }
3821
- deleteProperty(target, prop) {
3822
- if ("string" != typeof prop || !delete target[prop]) {
3823
- return false;
3824
- }
3825
- triggerEffects(this.$container$, this, getEffects(target, prop, this.$effects$));
3826
- return true;
3827
- }
3828
- has(target, prop) {
3829
- if (prop === STORE_TARGET) {
3830
- return true;
3831
- }
3832
- if ("string" === typeof prop) {
3833
- const ctx = tryGetInvokeContext();
3834
- if (ctx) {
3835
- const effectSubscriber = ctx.$effectSubscriber$;
3836
- effectSubscriber && addEffect(target, Array.isArray(target) ? STORE_ARRAY_PROP : prop, this, effectSubscriber);
3837
- }
3838
- }
3839
- return Object.prototype.hasOwnProperty.call(target, prop);
3840
- }
3841
- ownKeys(target) {
3842
- const ctx = tryGetInvokeContext();
3843
- const effectSubscriber = ctx?.$effectSubscriber$;
3844
- effectSubscriber && addEffect(target, STORE_ARRAY_PROP, this, effectSubscriber);
3845
- return Reflect.ownKeys(target);
3846
- }
3847
- getOwnPropertyDescriptor(target, prop) {
3848
- if (Array.isArray(target) || "symbol" === typeof prop) {
3849
- return Object.getOwnPropertyDescriptor(target, prop);
3850
- }
3851
- return {
3852
- enumerable: true,
3853
- configurable: true
3854
- };
3855
- }
3856
- };
3857
-
3858
- function addEffect(target, prop, store, effectSubscriber) {
3859
- const effectsMap = store.$effects$ || (store.$effects$ = {});
3860
- const effects = Object.prototype.hasOwnProperty.call(effectsMap, prop) && effectsMap[prop] || (effectsMap[prop] = []);
3861
- ensureContainsEffect(effects, effectSubscriber);
3862
- ensureContains(effectSubscriber, target);
3863
- DEBUG2 && log2("sub", pad("\n" + store.$effects$.toString(), " "));
3864
- }
3865
-
3866
- function setNewValueAndTriggerEffects(prop, value, target, currentStore) {
3867
- target[prop] = value;
3868
- triggerEffects(currentStore.$container$, currentStore, getEffects(target, prop, currentStore.$effects$));
3869
- }
3870
-
3871
- function getEffects(target, prop, storeEffects) {
3872
- let effectsToTrigger = storeEffects ? Array.isArray(target) ? Object.values(storeEffects).flatMap((effects => effects)) : storeEffects[prop] : null;
3873
- const storeArrayValue = storeEffects?.[STORE_ARRAY_PROP];
3874
- if (storeArrayValue) {
3875
- effectsToTrigger || (effectsToTrigger = []);
3876
- effectsToTrigger.push(...storeArrayValue);
3877
- }
3878
- return effectsToTrigger;
3879
3694
  }
3880
3695
 
3881
3696
  var _createResourceReturn = opts => {
@@ -3903,7 +3718,7 @@ var runResource = (task, container, host) => {
3903
3718
  cleanupTask(task);
3904
3719
  const iCtx = newInvokeContext(container.$locale$, host, void 0, ResourceEvent);
3905
3720
  iCtx.$container$ = container;
3906
- const taskFn = task.$qrl$.getFn(iCtx, (() => clearSubscriberEffectDependencies(task)));
3721
+ const taskFn = task.$qrl$.getFn(iCtx, (() => clearSubscriberEffectDependencies(container, task)));
3907
3722
  const resource = task.$state$;
3908
3723
  assertDefined(resource, 'useResource: when running a resource, "task.resource" must be a defined.', task);
3909
3724
  const track = (obj, prop) => {
@@ -4000,175 +3815,56 @@ var runResource = (task, container, host) => {
4000
3815
 
4001
3816
  var ignoreErrorToPreventNodeFromCrashing = err => {};
4002
3817
 
4003
- var Slot = props => _jsxSorted(Virtual, null, {
4004
- [QSlotS]: ""
4005
- }, props.children, 0, props.name ?? "");
4006
-
4007
- var SkipRender = Symbol("skip render");
3818
+ var isForeignObjectElement = elementName => "foreignobject" === elementName.toLowerCase();
4008
3819
 
4009
- var SSRRaw = () => null;
3820
+ var isSvgElement = elementName => "svg" === elementName || isForeignObjectElement(elementName);
4010
3821
 
4011
- var SSRComment = () => null;
3822
+ var isMathElement = elementName => "math" === elementName;
4012
3823
 
4013
- var 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" ]);
3824
+ var vnode_isDefaultNamespace = vnode => {
3825
+ const flags = vnode[0];
3826
+ return 0 === (192 & flags);
3827
+ };
4014
3828
 
4015
- var isUnitlessNumber = name => unitlessNumbers.has(name);
3829
+ var vnode_getElementNamespaceFlags = elementName => isSvgElement(elementName) ? 64 : isMathElement(elementName) ? 128 : 0;
4016
3830
 
4017
- var serializeClass = obj => {
4018
- if (!obj) {
4019
- return "";
4020
- }
4021
- if (isString(obj)) {
4022
- return obj.trim();
4023
- }
4024
- const classes = [];
4025
- if (isArray(obj)) {
4026
- for (const o of obj) {
4027
- const classList = serializeClass(o);
4028
- classList && classes.push(classList);
4029
- }
3831
+ function vnode_getDomChildrenWithCorrectNamespacesToInsert(journal, domParentVNode, newChild) {
3832
+ const {elementNamespace: elementNamespace, elementNamespaceFlag: elementNamespaceFlag} = getNewElementNamespaceData(domParentVNode, newChild);
3833
+ let domChildren = [];
3834
+ if (elementNamespace === HTML_NS) {
3835
+ domChildren = vnode_getDOMChildNodes(journal, newChild);
4030
3836
  } else {
4031
- for (const [key, value] of Object.entries(obj)) {
4032
- value && classes.push(key.trim());
3837
+ const children = vnode_getDOMChildNodes(journal, newChild, true);
3838
+ for (let i = 0; i < children.length; i++) {
3839
+ const childVNode = children[i];
3840
+ if (vnode_isTextVNode(childVNode)) {
3841
+ domChildren.push(childVNode[4]);
3842
+ continue;
3843
+ }
3844
+ if ((192 & childVNode[0]) === (192 & domParentVNode[0])) {
3845
+ domChildren.push(childVNode[6]);
3846
+ continue;
3847
+ }
3848
+ const newChildElement = vnode_cloneElementWithNamespace(childVNode, domParentVNode, elementNamespace, elementNamespaceFlag);
3849
+ newChildElement && domChildren.push(newChildElement);
4033
3850
  }
4034
3851
  }
4035
- return classes.join(" ");
4036
- };
4037
-
4038
- var fromCamelToKebabCaseWithDash = text => text.replace(/([A-Z])/g, "-$1").toLowerCase();
3852
+ return domChildren;
3853
+ }
4039
3854
 
4040
- var stringifyStyle = obj => {
4041
- if (null == obj) {
4042
- return "";
4043
- }
4044
- if ("object" == typeof obj) {
4045
- if (isArray(obj)) {
4046
- throw qError(QError_stringifyClassOrStyle, obj, "style");
4047
- }
4048
- {
4049
- const chunks = [];
4050
- for (const key in obj) {
4051
- if (Object.prototype.hasOwnProperty.call(obj, key)) {
4052
- const value = obj[key];
4053
- null != value && "function" !== typeof value && (key.startsWith("--") ? chunks.push(key + ":" + value) : chunks.push(fromCamelToKebabCaseWithDash(key) + ":" + setValueForStyle(key, value)));
4054
- }
4055
- }
4056
- return chunks.join(";");
3855
+ function cloneElementWithNamespace(element, elementName, namespace) {
3856
+ const newElement = element.ownerDocument.createElementNS(namespace, elementName);
3857
+ const attributes = element.attributes;
3858
+ for (const attribute of attributes) {
3859
+ const name = attribute.name;
3860
+ const value = attribute.value;
3861
+ if (!name || name === Q_PROPS_SEPARATOR) {
3862
+ continue;
4057
3863
  }
3864
+ newElement.setAttribute(name, value);
4058
3865
  }
4059
- return String(obj);
4060
- };
4061
-
4062
- var serializeBooleanOrNumberAttribute = value => null != value ? String(value) : null;
4063
-
4064
- function serializeAttribute(key, value, styleScopedId) {
4065
- if (isClassAttr(key)) {
4066
- const serializedClass = serializeClass(value);
4067
- value = styleScopedId ? styleScopedId + (serializedClass.length ? " " + serializedClass : serializedClass) : serializedClass;
4068
- } else {
4069
- "style" === key ? value = stringifyStyle(value) : isEnumeratedBooleanAttribute(key) || "number" === typeof value ? value = serializeBooleanOrNumberAttribute(value) : false === value || null == value ? value = null : true === value && isPreventDefault(key) && (value = "");
4070
- }
4071
- return value;
4072
- }
4073
-
4074
- function isEnumeratedBooleanAttribute(key) {
4075
- return isAriaAttribute(key) || [ "spellcheck", "draggable", "contenteditable" ].includes(key);
4076
- }
4077
-
4078
- var setValueForStyle = (styleName, value) => {
4079
- if ("number" === typeof value && 0 !== value && !isUnitlessNumber(styleName)) {
4080
- return value + "px";
4081
- }
4082
- return value;
4083
- };
4084
-
4085
- function isAriaAttribute(prop) {
4086
- return prop.startsWith("aria-");
4087
- }
4088
-
4089
- var styleContent = styleId => ComponentStylesPrefixContent + styleId;
4090
-
4091
- function hasClassAttr(props) {
4092
- for (const key in props) {
4093
- if (Object.prototype.hasOwnProperty.call(props, key) && isClassAttr(key)) {
4094
- return true;
4095
- }
4096
- }
4097
- return false;
4098
- }
4099
-
4100
- function isClassAttr(key) {
4101
- return "class" === key || "className" === key;
4102
- }
4103
-
4104
- function convertScopedStyleIdsToArray(scopedStyleIds) {
4105
- return scopedStyleIds?.split(" ") ?? null;
4106
- }
4107
-
4108
- function convertStyleIdsToString(scopedStyleIds) {
4109
- return Array.from(scopedStyleIds).join(" ");
4110
- }
4111
-
4112
- var addComponentStylePrefix = styleId => {
4113
- if (styleId) {
4114
- let idx = 0;
4115
- do {
4116
- styleId = styleId.substring(0, idx) + styleContent(styleId.substring(idx));
4117
- } while (0 !== (idx = styleId.indexOf(" ", idx) + 1));
4118
- }
4119
- return styleId || null;
4120
- };
4121
-
4122
- var isForeignObjectElement = elementName => "foreignobject" === elementName.toLowerCase();
4123
-
4124
- var isSvgElement = elementName => "svg" === elementName || isForeignObjectElement(elementName);
4125
-
4126
- var isMathElement = elementName => "math" === elementName;
4127
-
4128
- var vnode_isDefaultNamespace = vnode => {
4129
- const flags = vnode[0];
4130
- return 0 === (192 & flags);
4131
- };
4132
-
4133
- var vnode_getElementNamespaceFlags = elementName => isSvgElement(elementName) ? 64 : isMathElement(elementName) ? 128 : 0;
4134
-
4135
- function vnode_getDomChildrenWithCorrectNamespacesToInsert(journal, domParentVNode, newChild) {
4136
- const {elementNamespace: elementNamespace, elementNamespaceFlag: elementNamespaceFlag} = getNewElementNamespaceData(domParentVNode, newChild);
4137
- let domChildren = [];
4138
- if (elementNamespace === HTML_NS) {
4139
- domChildren = vnode_getDOMChildNodes(journal, newChild);
4140
- } else {
4141
- const children = vnode_getDOMChildNodes(journal, newChild, true);
4142
- for (let i = 0; i < children.length; i++) {
4143
- const childVNode = children[i];
4144
- if (vnode_isTextVNode(childVNode)) {
4145
- domChildren.push(childVNode[4]);
4146
- continue;
4147
- }
4148
- if ((192 & childVNode[0]) === (192 & domParentVNode[0])) {
4149
- domChildren.push(childVNode[6]);
4150
- continue;
4151
- }
4152
- const newChildElement = vnode_cloneElementWithNamespace(childVNode, domParentVNode, elementNamespace, elementNamespaceFlag);
4153
- newChildElement && domChildren.push(newChildElement);
4154
- }
4155
- }
4156
- return domChildren;
4157
- }
4158
-
4159
- function cloneElementWithNamespace(element, elementName, namespace) {
4160
- const newElement = element.ownerDocument.createElementNS(namespace, elementName);
4161
- const attributes = element.attributes;
4162
- for (const attribute of attributes) {
4163
- const name = attribute.name;
4164
- const value = attribute.value;
4165
- if (!name || name === Q_PROPS_SEPARATOR) {
4166
- continue;
4167
- }
4168
- newElement.setAttribute(name, value);
4169
- }
4170
- return newElement;
4171
- }
3866
+ return newElement;
3867
+ }
4172
3868
 
4173
3869
  function vnode_cloneElementWithNamespace(elementVNode, parentVNode, namespace, namespaceFlag) {
4174
3870
  ensureElementVNode(elementVNode);
@@ -4302,7 +3998,7 @@ var executeComponent = (container, renderHost, subscriptionHost, componentQRL, p
4302
3998
  container.setHostProp(renderHost, USE_ON_LOCAL_SEQ_IDX, null);
4303
3999
  container.getHostProp(renderHost, ELEMENT_PROPS) !== props && container.setHostProp(renderHost, ELEMENT_PROPS, props);
4304
4000
  }
4305
- vnode_isVNode(renderHost) && clearVNodeEffectDependencies(renderHost);
4001
+ vnode_isVNode(renderHost) && clearVNodeEffectDependencies(container, renderHost);
4306
4002
  return componentFn(props);
4307
4003
  }), (jsx2 => {
4308
4004
  const useOnEvents = container.getHostProp(renderHost, USE_ON_LOCAL);
@@ -4392,6 +4088,14 @@ function addScriptNodeForInvisibleComponents(jsx2) {
4392
4088
  return null;
4393
4089
  }
4394
4090
 
4091
+ function isSlotProp(prop) {
4092
+ return !prop.startsWith("q:") && !prop.startsWith(NON_SERIALIZABLE_MARKER_PREFIX);
4093
+ }
4094
+
4095
+ function isParentSlotProp(prop) {
4096
+ return prop.startsWith(QSlotParent);
4097
+ }
4098
+
4395
4099
  function escapeHTML(html) {
4396
4100
  let escapedHTML = "";
4397
4101
  const length = html.length;
@@ -4418,6 +4122,17 @@ function escapeHTML(html) {
4418
4122
  return 0 === lastIdx ? html : escapedHTML + html.substring(lastIdx);
4419
4123
  }
4420
4124
 
4125
+ function getFileLocationFromJsx(jsxDev) {
4126
+ if (!jsxDev) {
4127
+ return null;
4128
+ }
4129
+ const sanitizedFileName = jsxDev.fileName?.replace(/\\/g, "/");
4130
+ if (sanitizedFileName) {
4131
+ return `${sanitizedFileName}:${jsxDev.lineNumber}:${jsxDev.columnNumber}`;
4132
+ }
4133
+ return null;
4134
+ }
4135
+
4421
4136
  var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
4422
4137
  let journal = container.$journal$;
4423
4138
  const stack2 = [];
@@ -4452,9 +4167,9 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
4452
4167
  if (Array.isArray(jsxValue)) {
4453
4168
  descend(jsxValue, false);
4454
4169
  } else if (isSignal(jsxValue)) {
4455
- vCurrent && clearVNodeEffectDependencies(vCurrent);
4170
+ vCurrent && clearVNodeEffectDependencies(container, vCurrent);
4456
4171
  expectVirtual("S", null);
4457
- descend(trackSignal((() => jsxValue.value), vNewNode || vCurrent, ".", container), true);
4172
+ descend(trackSignalAndAssignHost(jsxValue, vNewNode || vCurrent, ".", container), true);
4458
4173
  } else if (isPromise(jsxValue)) {
4459
4174
  expectVirtual("A", null);
4460
4175
  asyncQueue.push(jsxValue, vNewNode || vCurrent);
@@ -4651,7 +4366,7 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
4651
4366
  if (constProps && "object" == typeof constProps && "name" in constProps) {
4652
4367
  const constValue = constProps.name;
4653
4368
  if (vHost && constValue instanceof WrappedSignal) {
4654
- return trackSignal((() => constValue.value), vHost, ":", container);
4369
+ return trackSignalAndAssignHost(constValue, vHost, ":", container);
4655
4370
  }
4656
4371
  }
4657
4372
  return directGetPropsProxyProp(jsxNode2, "name") || QDefaultSlot;
@@ -4699,7 +4414,7 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
4699
4414
  vnode_remove(journal, vParent, toRemove, true);
4700
4415
  }
4701
4416
  }
4702
- function createNewElement(jsx2, elementName) {
4417
+ function createNewElement(jsx2, elementName, currentFile) {
4703
4418
  const element = createElementWithNamespace(elementName);
4704
4419
  const {constProps: constProps} = jsx2;
4705
4420
  let needsQDispatchEventPatch = false;
@@ -4723,13 +4438,14 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
4723
4438
  value(element);
4724
4439
  continue;
4725
4440
  }
4441
+ throw qError(32, [ currentFile ]);
4726
4442
  }
4727
4443
  if (isSignal(value)) {
4728
- const signalData = new EffectData({
4444
+ const signalData = new EffectPropData({
4729
4445
  $scopedStyleIdPrefix$: scopedStyleIdPrefix,
4730
4446
  $isConst$: true
4731
4447
  });
4732
- value = trackSignal((() => value.value), vNewNode, key2, container, signalData);
4448
+ value = trackSignalAndAssignHost(value, vNewNode, key2, container, signalData);
4733
4449
  }
4734
4450
  if (key2 === dangerouslySetInnerHTML) {
4735
4451
  element.innerHTML = value;
@@ -4737,11 +4453,13 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
4737
4453
  continue;
4738
4454
  }
4739
4455
  if ("textarea" === elementName && "value" === key2) {
4740
- if ("string" !== typeof value) {
4741
- isDev && throwErrorAndStop("The value of the textarea must be a string");
4456
+ if (value && "string" !== typeof value) {
4457
+ if (isDev) {
4458
+ throw qError(40, [ currentFile, value ]);
4459
+ }
4742
4460
  continue;
4743
4461
  }
4744
- element.value = escapeHTML(value);
4462
+ element.value = escapeHTML(value || "");
4745
4463
  continue;
4746
4464
  }
4747
4465
  value = serializeAttribute(key2, value, scopedStyleIdPrefix);
@@ -4770,20 +4488,27 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
4770
4488
  const isSameElementName = vCurrent && vnode_isElementVNode(vCurrent) && elementName === vnode_getElementName(vCurrent);
4771
4489
  const jsxKey = jsx2.key;
4772
4490
  let needsQDispatchEventPatch = false;
4491
+ const currentFile = getFileLocationFromJsx(jsx2.dev);
4773
4492
  if (!isSameElementName || jsxKey !== getKey(vCurrent)) {
4774
4493
  vNewNode = retrieveChildWithKey(elementName, jsxKey);
4775
- null === vNewNode ? needsQDispatchEventPatch = createNewElement(jsx2, elementName) : vnode_insertBefore(journal, vParent, vNewNode, vCurrent);
4494
+ if (null === vNewNode) {
4495
+ needsQDispatchEventPatch = createNewElement(jsx2, elementName);
4496
+ } else {
4497
+ vnode_insertBefore(journal, vParent, vNewNode, vCurrent);
4498
+ vCurrent = vNewNode;
4499
+ vNewNode = null;
4500
+ null !== vSiblings && (vSiblingsIdx -= 3);
4501
+ }
4776
4502
  }
4777
4503
  const jsxAttrs = [];
4778
4504
  const props = jsx2.varProps;
4779
4505
  for (const key in props) {
4780
- let value = props[key];
4781
- value = serializeAttribute(key, value, scopedStyleIdPrefix);
4506
+ const value = props[key];
4782
4507
  null != value && mapArray_set(jsxAttrs, key, value, 0);
4783
4508
  }
4784
4509
  null !== jsxKey && mapArray_set(jsxAttrs, ELEMENT_KEY, jsxKey, 0);
4785
4510
  const vNode = vNewNode || vCurrent;
4786
- needsQDispatchEventPatch = setBulkProps(vNode, jsxAttrs) || needsQDispatchEventPatch;
4511
+ needsQDispatchEventPatch = setBulkProps(vNode, jsxAttrs, currentFile) || needsQDispatchEventPatch;
4787
4512
  if (needsQDispatchEventPatch) {
4788
4513
  const element = vnode_getNode(vNode);
4789
4514
  element.qDispatchEvent || (element.qDispatchEvent = (event, scope) => {
@@ -4791,9 +4516,9 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
4791
4516
  const eventProp = ":" + scope.substring(1) + ":" + eventName;
4792
4517
  const qrls = [ vnode_getProp(vNode, eventProp, null), vnode_getProp(vNode, HANDLER_PREFIX + eventProp, null) ];
4793
4518
  let returnValue = false;
4794
- qrls.flat(2).forEach((qrl2 => {
4795
- if (qrl2) {
4796
- const value = qrl2(event, element);
4519
+ qrls.flat(2).forEach((qrl => {
4520
+ if (qrl) {
4521
+ const value = qrl(event, element);
4797
4522
  returnValue = returnValue || true === value;
4798
4523
  }
4799
4524
  }));
@@ -4801,7 +4526,7 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
4801
4526
  });
4802
4527
  }
4803
4528
  }
4804
- function setBulkProps(vnode, srcAttrs) {
4529
+ function setBulkProps(vnode, srcAttrs, currentFile) {
4805
4530
  vnode_ensureElementInflated(vnode);
4806
4531
  const dstAttrs = vnode;
4807
4532
  let srcIdx = 0;
@@ -4826,9 +4551,16 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
4826
4551
  value(element);
4827
4552
  return;
4828
4553
  }
4554
+ throw qError(32, [ currentFile ]);
4829
4555
  }
4830
- isSignal(value) && (value = untrack((() => value.value)));
4831
- vnode_setAttr(journal, vnode, key, value);
4556
+ if (isSignal(value)) {
4557
+ const signalData = new EffectPropData({
4558
+ $scopedStyleIdPrefix$: scopedStyleIdPrefix,
4559
+ $isConst$: false
4560
+ });
4561
+ value = trackSignalAndAssignHost(value, vnode, key, container, signalData);
4562
+ }
4563
+ vnode_setAttr(journal, vnode, key, serializeAttribute(key, value, scopedStyleIdPrefix));
4832
4564
  null === value && (dstLength = dstAttrs.length);
4833
4565
  };
4834
4566
  const recordJsxEvent = (key, value) => {
@@ -4842,7 +4574,7 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
4842
4574
  eventName && registerQwikLoaderEvent(eventName);
4843
4575
  };
4844
4576
  while (null !== srcKey || null !== dstKey) {
4845
- if (dstKey?.startsWith(HANDLER_PREFIX) || dstKey == ELEMENT_KEY) {
4577
+ if (dstKey?.startsWith(HANDLER_PREFIX) || dstKey?.startsWith(Q_PREFIX)) {
4846
4578
  dstIdx++;
4847
4579
  dstKey = dstIdx < dstLength ? dstAttrs[dstIdx++] : null;
4848
4580
  } else if (null == srcKey) {
@@ -4864,6 +4596,8 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
4864
4596
  }
4865
4597
  srcIdx++;
4866
4598
  srcKey = srcIdx < srcLength ? srcAttrs[srcIdx++] : null;
4599
+ dstIdx++;
4600
+ dstKey = dstIdx < dstLength ? dstAttrs[dstIdx++] : null;
4867
4601
  } else if (srcKey == dstKey) {
4868
4602
  const srcValue = srcAttrs[srcIdx++];
4869
4603
  const dstValue = dstAttrs[dstIdx++];
@@ -4930,7 +4664,7 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
4930
4664
  if (null !== jsxKey) {
4931
4665
  vNewNode = retrieveChildWithKey(null, jsxKey);
4932
4666
  if (null != vNewNode) {
4933
- vnode_insertBefore(journal, vParent, vNewNode = vnode_newVirtual(), vCurrent && getInsertBefore());
4667
+ vnode_insertBefore(journal, vParent, vNewNode, vCurrent && getInsertBefore());
4934
4668
  return;
4935
4669
  }
4936
4670
  }
@@ -4996,7 +4730,7 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
4996
4730
  }
4997
4731
  }
4998
4732
  function insertNewComponent(host, componentQRL, jsxProps) {
4999
- host && clearVNodeEffectDependencies(host);
4733
+ host && clearVNodeEffectDependencies(container, host);
5000
4734
  vnode_insertBefore(journal, vParent, vNewNode = vnode_newVirtual(), vCurrent && getInsertBefore());
5001
4735
  const jsxNode2 = jsxValue;
5002
4736
  isDev && vnode_setProp(vNewNode, DEBUG_TYPE, "C");
@@ -5037,8 +4771,8 @@ function getComponentHash(vNode, getObject) {
5037
4771
  if (null == vNode) {
5038
4772
  return null;
5039
4773
  }
5040
- const qrl2 = vnode_getProp(vNode, OnRenderProp, getObject);
5041
- return qrl2 ? qrl2.$hash$ : null;
4774
+ const qrl = vnode_getProp(vNode, OnRenderProp, getObject);
4775
+ return qrl ? qrl.$hash$ : null;
5042
4776
  }
5043
4777
 
5044
4778
  function Projection() {}
@@ -5047,8 +4781,8 @@ function propsDiffer(src, dst) {
5047
4781
  if (!src || !dst) {
5048
4782
  return true;
5049
4783
  }
5050
- let srcKeys = removeChildrenKey(Object.keys(src));
5051
- let dstKeys = removeChildrenKey(Object.keys(dst));
4784
+ let srcKeys = removePropsKeys(Object.keys(src), [ "children", QSubscribers ]);
4785
+ let dstKeys = removePropsKeys(Object.keys(dst), [ "children", QSubscribers ]);
5052
4786
  if (srcKeys.length !== dstKeys.length) {
5053
4787
  return true;
5054
4788
  }
@@ -5064,9 +4798,12 @@ function propsDiffer(src, dst) {
5064
4798
  return false;
5065
4799
  }
5066
4800
 
5067
- function removeChildrenKey(keys2) {
5068
- const childrenIdx = keys2.indexOf("children");
5069
- -1 !== childrenIdx && keys2.splice(childrenIdx, 1);
4801
+ function removePropsKeys(keys2, propKeys) {
4802
+ for (let i = propKeys.length - 1; i >= 0; i--) {
4803
+ const propKey = propKeys[i];
4804
+ const propIdx = keys2.indexOf(propKey);
4805
+ -1 !== propIdx && keys2.splice(propIdx, 1);
4806
+ }
5070
4807
  return keys2;
5071
4808
  }
5072
4809
 
@@ -5079,17 +4816,17 @@ function cleanup(container, vNode) {
5079
4816
  do {
5080
4817
  const type = vCursor[0];
5081
4818
  if (3 & type) {
4819
+ clearVNodeEffectDependencies(container, vCursor);
4820
+ markVNodeAsDeleted(vCursor);
5082
4821
  if (2 & type) {
5083
- clearVNodeEffectDependencies(vCursor);
5084
- markVNodeAsDeleted(vCursor);
5085
4822
  const seq = container.getHostProp(vCursor, ELEMENT_SEQ);
5086
4823
  if (seq) {
5087
4824
  for (let i = 0; i < seq.length; i++) {
5088
4825
  const obj = seq[i];
5089
4826
  if (isTask(obj)) {
5090
4827
  const task = obj;
5091
- clearSubscriberEffectDependencies(task);
5092
- 1 & task.$flags$ ? container.$scheduler$(80, task) : cleanupTask(task);
4828
+ clearSubscriberEffectDependencies(container, task);
4829
+ 1 & task.$flags$ ? container.$scheduler$(48, task) : cleanupTask(task);
5093
4830
  }
5094
4831
  }
5095
4832
  }
@@ -5173,11 +4910,7 @@ var HANDLER_PREFIX = ":";
5173
4910
 
5174
4911
  var count = 0;
5175
4912
 
5176
- var implicit$FirstArg = fn => function(first, ...rest) {
5177
- return fn.call(null, dollar(first), ...rest);
5178
- };
5179
-
5180
- var DEBUG3 = false;
4913
+ var DEBUG2 = false;
5181
4914
 
5182
4915
  var createScheduler = (container, scheduleDrain, journalFlush) => {
5183
4916
  const choreQueue = [];
@@ -5185,8 +4918,8 @@ var createScheduler = (container, scheduleDrain, journalFlush) => {
5185
4918
  let journalFlushScheduled = false;
5186
4919
  return schedule;
5187
4920
  function schedule(type, hostOrTask = null, targetOrQrl = null, payload = null) {
5188
- const runLater = 127 !== type && 16 !== type && 6 !== type;
5189
- const isTask2 = 3 === type || 64 === type || 2 === type || 80 === type;
4921
+ const runLater = 255 !== type && 6 !== type;
4922
+ const isTask2 = 3 === type || 32 === type || 2 === type || 48 === type;
5190
4923
  isTask2 && (hostOrTask.$flags$ |= 8);
5191
4924
  let chore = {
5192
4925
  $type$: type,
@@ -5200,16 +4933,16 @@ var createScheduler = (container, scheduleDrain, journalFlush) => {
5200
4933
  $executed$: false
5201
4934
  };
5202
4935
  chore.$promise$ = new Promise((resolve => chore.$resolve$ = resolve));
5203
- DEBUG3 && debugTrace("schedule", chore, currentChore, choreQueue);
5204
- chore = sortedInsert(choreQueue, chore);
4936
+ DEBUG2 && debugTrace("schedule", chore, currentChore, choreQueue);
4937
+ chore = sortedInsert(choreQueue, chore, container.rootVNode || null);
5205
4938
  if (!journalFlushScheduled && runLater) {
5206
4939
  journalFlushScheduled = true;
5207
- schedule(48);
4940
+ schedule(16);
5208
4941
  scheduleDrain();
5209
4942
  }
5210
- return runLater ? chore.$promise$ : drainUpTo(chore);
4943
+ return runLater ? chore.$promise$ : drainUpTo(chore, container.rootVNode || null);
5211
4944
  }
5212
- function drainUpTo(runUptoChore) {
4945
+ function drainUpTo(runUptoChore, rootVNode) {
5213
4946
  if (runUptoChore.$executed$) {
5214
4947
  return runUptoChore.$returnValue$;
5215
4948
  }
@@ -5218,7 +4951,7 @@ var createScheduler = (container, scheduleDrain, journalFlush) => {
5218
4951
  }
5219
4952
  while (choreQueue.length) {
5220
4953
  const nextChore = choreQueue.shift();
5221
- const order = choreComparator(nextChore, runUptoChore, false);
4954
+ const order = choreComparator(nextChore, runUptoChore, rootVNode, false);
5222
4955
  if (null === order) {
5223
4956
  continue;
5224
4957
  }
@@ -5226,13 +4959,13 @@ var createScheduler = (container, scheduleDrain, journalFlush) => {
5226
4959
  break;
5227
4960
  }
5228
4961
  const isDeletedVNode = vNodeAlreadyDeleted(nextChore);
5229
- if (isDeletedVNode && 80 !== nextChore.$type$) {
5230
- DEBUG3 && debugTrace("skip chore", nextChore, currentChore, choreQueue);
4962
+ if (isDeletedVNode && 48 !== nextChore.$type$) {
4963
+ DEBUG2 && debugTrace("skip chore", nextChore, currentChore, choreQueue);
5231
4964
  continue;
5232
4965
  }
5233
4966
  const returnValue = executeChore(nextChore);
5234
4967
  if (isPromise(returnValue)) {
5235
- const promise = returnValue.then((() => drainUpTo(runUptoChore)));
4968
+ const promise = returnValue.then((() => drainUpTo(runUptoChore, rootVNode)));
5236
4969
  return promise;
5237
4970
  }
5238
4971
  }
@@ -5240,12 +4973,12 @@ var createScheduler = (container, scheduleDrain, journalFlush) => {
5240
4973
  }
5241
4974
  function executeChore(chore) {
5242
4975
  const host = chore.$host$;
5243
- DEBUG3 && debugTrace("execute", chore, currentChore, choreQueue);
4976
+ DEBUG2 && debugTrace("execute", chore, currentChore, choreQueue);
5244
4977
  assertEqual(currentChore, null, "Chore already running.");
5245
4978
  currentChore = chore;
5246
4979
  let returnValue = null;
5247
4980
  switch (chore.$type$) {
5248
- case 48:
4981
+ case 16:
5249
4982
  returnValue = journalFlush();
5250
4983
  journalFlushScheduled = false;
5251
4984
  break;
@@ -5270,11 +5003,11 @@ var createScheduler = (container, scheduleDrain, journalFlush) => {
5270
5003
  returnValue = runTask(chore.$payload$, container, host);
5271
5004
  break;
5272
5005
 
5273
- case 64:
5006
+ case 32:
5274
5007
  returnValue = runTask(chore.$payload$, container, host);
5275
5008
  break;
5276
5009
 
5277
- case 80:
5010
+ case 48:
5278
5011
  const task = chore.$payload$;
5279
5012
  cleanupTask(task);
5280
5013
  break;
@@ -5309,9 +5042,23 @@ var createScheduler = (container, scheduleDrain, journalFlush) => {
5309
5042
  returnValue = target.resolved ? null : target.resolve();
5310
5043
  break;
5311
5044
  }
5045
+
5046
+ case 8:
5047
+ {
5048
+ const target = chore.$target$;
5049
+ const forceRunEffects = target.$forceRunEffects$;
5050
+ target.$forceRunEffects$ = false;
5051
+ if (!target.$effects$?.length) {
5052
+ break;
5053
+ }
5054
+ returnValue = retryOnPromise((() => {
5055
+ (target.$computeIfNeeded$() || forceRunEffects) && triggerEffects(container, target, target.$effects$);
5056
+ }));
5057
+ break;
5058
+ }
5312
5059
  }
5313
5060
  return maybeThenPassError(returnValue, (value => {
5314
- DEBUG3 && debugTrace("execute.DONE", null, currentChore, choreQueue);
5061
+ DEBUG2 && debugTrace("execute.DONE", null, currentChore, choreQueue);
5315
5062
  if (currentChore) {
5316
5063
  currentChore.$executed$ = true;
5317
5064
  currentChore.$resolve$?.(value);
@@ -5332,23 +5079,25 @@ function vNodeAlreadyDeleted(chore) {
5332
5079
  return !!(chore.$host$ && vnode_isVNode(chore.$host$) && 32 & chore.$host$[0]);
5333
5080
  }
5334
5081
 
5335
- function choreComparator(a, b, shouldThrowOnHostMismatch) {
5336
- const macroTypeDiff = (112 & a.$type$) - (112 & b.$type$);
5082
+ function choreComparator(a, b, rootVNode, shouldThrowOnHostMismatch) {
5083
+ const macroTypeDiff = (240 & a.$type$) - (240 & b.$type$);
5337
5084
  if (0 !== macroTypeDiff) {
5338
5085
  return macroTypeDiff;
5339
5086
  }
5340
- if (48 !== a.$type$) {
5087
+ if (16 !== a.$type$) {
5341
5088
  const aHost = a.$host$;
5342
5089
  const bHost = b.$host$;
5343
5090
  if (aHost !== bHost && null !== aHost && null !== bHost) {
5344
5091
  if (!vnode_isVNode(aHost) || !vnode_isVNode(bHost)) {
5345
5092
  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()}`;
5346
- shouldThrowOnHostMismatch && throwErrorAndStop(errorMessage);
5093
+ if (shouldThrowOnHostMismatch) {
5094
+ throw qError(45, [ errorMessage ]);
5095
+ }
5347
5096
  logWarn(errorMessage);
5348
5097
  return null;
5349
5098
  }
5350
5099
  {
5351
- const hostDiff = vnode_documentPosition(aHost, bHost);
5100
+ const hostDiff = vnode_documentPosition(aHost, bHost, rootVNode);
5352
5101
  if (0 !== hostDiff) {
5353
5102
  return hostDiff;
5354
5103
  }
@@ -5362,20 +5111,20 @@ function choreComparator(a, b, shouldThrowOnHostMismatch) {
5362
5111
  if (0 !== idxDiff) {
5363
5112
  return idxDiff;
5364
5113
  }
5365
- if (a.$target$ !== b.$target$ && (1 === a.$type$ && 1 === b.$type$ || 5 === a.$type$ && 5 === b.$type$)) {
5114
+ if (a.$target$ !== b.$target$ && (1 === a.$type$ && 1 === b.$type$ || 5 === a.$type$ && 5 === b.$type$ || 8 === a.$type$ && 8 === b.$type$)) {
5366
5115
  return 1;
5367
5116
  }
5368
5117
  }
5369
5118
  return 0;
5370
5119
  }
5371
5120
 
5372
- function sortedFindIndex(sortedArray, value) {
5121
+ function sortedFindIndex(sortedArray, value, rootVNode) {
5373
5122
  let bottom = 0;
5374
5123
  let top = sortedArray.length;
5375
5124
  while (bottom < top) {
5376
5125
  const middle = bottom + (top - bottom >> 1);
5377
5126
  const midChore = sortedArray[middle];
5378
- const comp = choreComparator(value, midChore, true);
5127
+ const comp = choreComparator(value, midChore, rootVNode, true);
5379
5128
  if (comp < 0) {
5380
5129
  top = middle;
5381
5130
  } else {
@@ -5388,8 +5137,8 @@ function sortedFindIndex(sortedArray, value) {
5388
5137
  return ~bottom;
5389
5138
  }
5390
5139
 
5391
- function sortedInsert(sortedArray, value) {
5392
- const idx = sortedFindIndex(sortedArray, value);
5140
+ function sortedInsert(sortedArray, value, rootVNode) {
5141
+ const idx = sortedFindIndex(sortedArray, value, rootVNode);
5393
5142
  if (idx < 0) {
5394
5143
  sortedArray.splice(~idx, 0, value);
5395
5144
  return value;
@@ -5408,11 +5157,11 @@ function debugChoreToString(chore) {
5408
5157
  5: "NODE_PROP",
5409
5158
  7: "COMPONENT",
5410
5159
  6: "COMPONENT_SSR",
5411
- 48: "JOURNAL_FLUSH",
5412
- 64: "VISIBLE",
5413
- 80: "CLEANUP_VISIBLE",
5414
- 127: "WAIT_FOR_ALL",
5415
- 16: "WAIT_FOR_COMPONENTS"
5160
+ 8: "RECOMPUTE_SIGNAL",
5161
+ 16: "JOURNAL_FLUSH",
5162
+ 32: "VISIBLE",
5163
+ 48: "CLEANUP_VISIBLE",
5164
+ 255: "WAIT_FOR_ALL"
5416
5165
  }[chore.$type$] || "UNKNOWN: " + chore.$type$;
5417
5166
  const host = String(chore.$host$).replaceAll(/\n.*/gim, "");
5418
5167
  const qrlTarget = chore.$target$?.$symbol$;
@@ -5429,618 +5178,564 @@ function debugTrace(action, arg, currentChore, queue) {
5429
5178
  console.log(lines.join("\n ") + "\n");
5430
5179
  }
5431
5180
 
5432
- var version = "2.0.0-alpha.3-dev+418fd6d";
5181
+ var runTask = (task, container, host) => {
5182
+ task.$flags$ &= -9;
5183
+ cleanupTask(task);
5184
+ const iCtx = newInvokeContext(container.$locale$, host, void 0, TaskEvent);
5185
+ iCtx.$container$ = container;
5186
+ const taskFn = task.$qrl$.getFn(iCtx, (() => clearSubscriberEffectDependencies(container, task)));
5187
+ const track = (obj, prop) => {
5188
+ const ctx = newInvokeContext();
5189
+ ctx.$effectSubscriber$ = [ task, ":" ];
5190
+ ctx.$container$ = container;
5191
+ return invoke(ctx, (() => {
5192
+ if (isFunction(obj)) {
5193
+ return obj();
5194
+ }
5195
+ return prop ? obj[prop] : isSignal(obj) ? obj.value : obj;
5196
+ }));
5197
+ };
5198
+ const handleError = reason => container.handleError(reason, host);
5199
+ let cleanupFns = null;
5200
+ const cleanup2 = fn => {
5201
+ if ("function" == typeof fn) {
5202
+ if (!cleanupFns) {
5203
+ cleanupFns = [];
5204
+ task.$destroy$ = noSerialize((() => {
5205
+ task.$destroy$ = null;
5206
+ cleanupFns.forEach((fn2 => {
5207
+ try {
5208
+ fn2();
5209
+ } catch (err) {
5210
+ handleError(err);
5211
+ }
5212
+ }));
5213
+ }));
5214
+ }
5215
+ cleanupFns.push(fn);
5216
+ }
5217
+ };
5218
+ const taskApi = {
5219
+ track: track,
5220
+ cleanup: cleanup2
5221
+ };
5222
+ const result = safeCall((() => taskFn(taskApi)), cleanup2, (err => isPromise(err) ? err.then((() => runTask(task, container, host))) : handleError(err)));
5223
+ return result;
5224
+ };
5433
5225
 
5434
- var _SharedContainer = class {
5435
- constructor(scheduleDrain, journalFlush, serverData, locale) {
5436
- __publicField(this, "$version$");
5437
- __publicField(this, "$scheduler$");
5438
- __publicField(this, "$storeProxyMap$");
5439
- __publicField(this, "$locale$");
5440
- __publicField(this, "$getObjectById$");
5441
- __publicField(this, "$serverData$");
5442
- __publicField(this, "$currentUniqueId$", 0);
5443
- __publicField(this, "$instanceHash$", null);
5444
- this.$serverData$ = serverData;
5445
- this.$locale$ = locale;
5446
- this.$version$ = version;
5447
- this.$storeProxyMap$ = new WeakMap;
5448
- this.$getObjectById$ = _id => {
5449
- throw Error("Not implemented");
5450
- };
5451
- this.$scheduler$ = createScheduler(this, scheduleDrain, journalFlush);
5452
- }
5453
- trackSignalValue(signal, subscriber, property, data) {
5454
- return trackSignal((() => signal.value), subscriber, property, this, data);
5455
- }
5456
- serializationCtxFactory(NodeConstructor, DomRefConstructor, symbolToChunkResolver, writer, prepVNodeData) {
5457
- return createSerializationContext(NodeConstructor, DomRefConstructor, symbolToChunkResolver, this.getHostProp.bind(this), this.setHostProp.bind(this), this.$storeProxyMap$, writer, prepVNodeData);
5226
+ var cleanupTask = task => {
5227
+ const destroy = task.$destroy$;
5228
+ if (destroy) {
5229
+ task.$destroy$ = null;
5230
+ try {
5231
+ destroy();
5232
+ } catch (err) {
5233
+ logError(err);
5234
+ }
5458
5235
  }
5459
5236
  };
5460
5237
 
5461
- var VNodeDataSeparator = {
5462
- REFERENCE_CH: "~",
5463
- REFERENCE: 126,
5464
- ADVANCE_1_CH: "!",
5465
- ADVANCE_1: 33,
5466
- ADVANCE_2_CH: '"',
5467
- ADVANCE_2: 34,
5468
- ADVANCE_4_CH: "#",
5469
- ADVANCE_4: 35,
5470
- ADVANCE_8_CH: "$",
5471
- ADVANCE_8: 36,
5472
- ADVANCE_16_CH: "%",
5473
- ADVANCE_16: 37,
5474
- ADVANCE_32_CH: "&",
5475
- ADVANCE_32: 38,
5476
- ADVANCE_64_CH: "'",
5477
- ADVANCE_64: 39,
5478
- ADVANCE_128_CH: "(",
5479
- ADVANCE_128: 40,
5480
- ADVANCE_256_CH: ")",
5481
- ADVANCE_256: 41,
5482
- ADVANCE_512_CH: "*",
5483
- ADVANCE_512: 42,
5484
- ADVANCE_1024_CH: "+",
5485
- ADVANCE_1024: 43,
5486
- ADVANCE_2048_CH: ",",
5487
- ADVANCE_2048: 44,
5488
- ADVANCE_4096_CH: "-",
5489
- ADVANCE_4096: 45,
5490
- ADVANCE_8192_CH: ".",
5491
- ADVANCE_8192: 46
5238
+ var Task = class extends Subscriber {
5239
+ constructor($flags$, $index$, $el$, $qrl$, $state$, $destroy$) {
5240
+ super();
5241
+ this.$flags$ = $flags$;
5242
+ this.$index$ = $index$;
5243
+ this.$el$ = $el$;
5244
+ this.$qrl$ = $qrl$;
5245
+ this.$state$ = $state$;
5246
+ this.$destroy$ = $destroy$;
5247
+ }
5492
5248
  };
5493
5249
 
5494
- var VNodeDataChar = {
5495
- OPEN: 123,
5496
- OPEN_CHAR: "{",
5497
- CLOSE: 125,
5498
- CLOSE_CHAR: "}",
5499
- SCOPED_STYLE: 59,
5500
- SCOPED_STYLE_CHAR: ";",
5501
- RENDER_FN: 60,
5502
- RENDER_FN_CHAR: "<",
5503
- ID: 61,
5504
- ID_CHAR: "=",
5505
- PROPS: 62,
5506
- PROPS_CHAR: ">",
5507
- SLOT_REF: 63,
5508
- SLOT_REF_CHAR: "?",
5509
- KEY: 64,
5510
- KEY_CHAR: "@",
5511
- SEQ: 91,
5512
- SEQ_CHAR: "[",
5513
- DON_T_USE: 93,
5514
- DON_T_USE_CHAR: "\\",
5515
- CONTEXT: 93,
5516
- CONTEXT_CHAR: "]",
5517
- SEQ_IDX: 94,
5518
- SEQ_IDX_CHAR: "^",
5519
- SEPARATOR: 124,
5520
- SEPARATOR_CHAR: "|",
5521
- SLOT: 126,
5522
- SLOT_CHAR: "~"
5250
+ var isTask = value => value instanceof Task;
5251
+
5252
+ var NEEDS_COMPUTATION = Symbol("invalid");
5253
+
5254
+ var DEBUG3 = false;
5255
+
5256
+ var log2 = (...args) => console.log("SIGNAL", ...args.map(qwikDebugToString));
5257
+
5258
+ var throwIfQRLNotResolved = qrl => {
5259
+ const resolved = qrl.resolved;
5260
+ if (!resolved) {
5261
+ throw qrl.resolve();
5262
+ }
5523
5263
  };
5524
5264
 
5525
- function processVNodeData(document2) {
5526
- const Q_CONTAINER = "q:container";
5527
- const Q_CONTAINER_END = "/" + Q_CONTAINER;
5528
- const Q_PROPS_SEPARATOR2 = ":";
5529
- const Q_SHADOW_ROOT = "q:shadowroot";
5530
- const Q_IGNORE = "q:ignore";
5531
- const Q_IGNORE_END = "/" + Q_IGNORE;
5532
- const Q_CONTAINER_ISLAND = "q:container-island";
5533
- const Q_CONTAINER_ISLAND_END = "/" + Q_CONTAINER_ISLAND;
5534
- const qDocument = document2;
5535
- const vNodeDataMap = qDocument.qVNodeData || (qDocument.qVNodeData = new WeakMap);
5536
- const prototype = document2.body;
5537
- const getter = (prototype2, name) => {
5538
- let getter2;
5539
- while (prototype2 && !(getter2 = Object.getOwnPropertyDescriptor(prototype2, name)?.get)) {
5540
- prototype2 = Object.getPrototypeOf(prototype2);
5541
- }
5542
- return getter2 || function() {
5543
- return this[name];
5544
- };
5545
- };
5546
- const getAttribute = prototype.getAttribute;
5547
- const hasAttribute = prototype.hasAttribute;
5548
- const getNodeType = getter(prototype, "nodeType");
5549
- const attachVnodeDataAndRefs = element => {
5550
- Array.from(element.querySelectorAll('script[type="qwik/vnode"]')).forEach((script => {
5551
- script.setAttribute("type", "x-qwik/vnode");
5552
- const qContainerElement = script.closest("[q\\:container]");
5553
- qContainerElement.qVnodeData = script.textContent;
5554
- qContainerElement.qVNodeRefs = new Map;
5555
- }));
5556
- element.querySelectorAll("[q\\:shadowroot]").forEach((parent => {
5557
- const shadowRoot = parent.shadowRoot;
5558
- shadowRoot && attachVnodeDataAndRefs(shadowRoot);
5559
- }));
5560
- };
5561
- attachVnodeDataAndRefs(document2);
5562
- let NodeType;
5563
- (NodeType2 => {
5564
- NodeType2[NodeType2.CONTAINER_MASK = 1] = "CONTAINER_MASK";
5565
- NodeType2[NodeType2.ELEMENT = 2] = "ELEMENT";
5566
- NodeType2[NodeType2.ELEMENT_CONTAINER = 3] = "ELEMENT_CONTAINER";
5567
- NodeType2[NodeType2.ELEMENT_SHADOW_ROOT = 6] = "ELEMENT_SHADOW_ROOT";
5568
- NodeType2[NodeType2.COMMENT_SKIP_START = 5] = "COMMENT_SKIP_START";
5569
- NodeType2[NodeType2.COMMENT_SKIP_END = 8] = "COMMENT_SKIP_END";
5570
- NodeType2[NodeType2.COMMENT_IGNORE_START = 16] = "COMMENT_IGNORE_START";
5571
- NodeType2[NodeType2.COMMENT_IGNORE_END = 32] = "COMMENT_IGNORE_END";
5572
- NodeType2[NodeType2.COMMENT_ISLAND_START = 65] = "COMMENT_ISLAND_START";
5573
- NodeType2[NodeType2.COMMENT_ISLAND_END = 128] = "COMMENT_ISLAND_END";
5574
- NodeType2[NodeType2.OTHER = 0] = "OTHER";
5575
- })(NodeType || (NodeType = {}));
5576
- const getFastNodeType = node => {
5577
- const nodeType = getNodeType.call(node);
5578
- if (1 === nodeType) {
5579
- const qContainer = getAttribute.call(node, Q_CONTAINER);
5580
- if (null === qContainer) {
5581
- if (hasAttribute.call(node, Q_SHADOW_ROOT)) {
5582
- return 6;
5265
+ var isSignal = value => value instanceof Signal;
5266
+
5267
+ var EffectPropData = class {
5268
+ constructor(data) {
5269
+ __publicField(this, "data");
5270
+ this.data = data;
5271
+ }
5272
+ };
5273
+
5274
+ var Signal = class {
5275
+ constructor(container, value) {
5276
+ __publicField(this, "$untrackedValue$");
5277
+ __publicField(this, "$effects$", null);
5278
+ __publicField(this, "$container$", null);
5279
+ this.$container$ = container;
5280
+ this.$untrackedValue$ = value;
5281
+ DEBUG3 && log2("new", this);
5282
+ }
5283
+ get untrackedValue() {
5284
+ return this.$untrackedValue$;
5285
+ }
5286
+ set untrackedValue(value) {
5287
+ this.$untrackedValue$ = value;
5288
+ }
5289
+ get value() {
5290
+ const ctx = tryGetInvokeContext();
5291
+ if (ctx) {
5292
+ if (null === this.$container$) {
5293
+ if (!ctx.$container$) {
5294
+ return this.untrackedValue;
5583
5295
  }
5584
- const isQElement = hasAttribute.call(node, Q_PROPS_SEPARATOR2);
5585
- return isQElement ? 2 : 0;
5586
- }
5587
- return 3;
5588
- }
5589
- if (8 === nodeType) {
5590
- const nodeValue = node.nodeValue || "";
5591
- if (nodeValue.startsWith(Q_CONTAINER_ISLAND)) {
5592
- return 65;
5593
- }
5594
- if (nodeValue.startsWith(Q_IGNORE)) {
5595
- return 16;
5596
- }
5597
- if (nodeValue.startsWith(Q_CONTAINER)) {
5598
- return 5;
5599
- }
5600
- if (nodeValue.startsWith(Q_CONTAINER_ISLAND_END)) {
5601
- return 128;
5602
- }
5603
- if (nodeValue.startsWith(Q_IGNORE_END)) {
5604
- return 32;
5296
+ this.$container$ = ctx.$container$;
5297
+ } else {
5298
+ assertTrue(!ctx.$container$ || ctx.$container$ === this.$container$, "Do not use signals across containers");
5605
5299
  }
5606
- if (nodeValue.startsWith(Q_CONTAINER_END)) {
5607
- return 8;
5300
+ const effectSubscriber = ctx.$effectSubscriber$;
5301
+ if (effectSubscriber) {
5302
+ const effects = this.$effects$ || (this.$effects$ = []);
5303
+ ensureContainsEffect(effects, effectSubscriber);
5304
+ ensureContains(effectSubscriber, this);
5305
+ isSubscriber(this) && ensureEffectContainsSubscriber(effectSubscriber[0], this, this.$container$);
5306
+ DEBUG3 && log2("read->sub", pad("\n" + this.toString(), " "));
5608
5307
  }
5609
5308
  }
5610
- return 0;
5611
- };
5612
- const isSeparator = ch => VNodeDataSeparator.ADVANCE_1 <= ch && ch <= VNodeDataSeparator.ADVANCE_8192;
5613
- const findVDataSectionEnd = (vData, start, end) => {
5614
- let depth = 0;
5615
- while (true) {
5616
- if (!(start < end)) {
5617
- break;
5618
- }
5619
- {
5620
- const ch = vData.charCodeAt(start);
5621
- if (0 === depth && isSeparator(ch)) {
5622
- break;
5623
- }
5624
- ch === VNodeDataChar.OPEN ? depth++ : ch === VNodeDataChar.CLOSE && depth--;
5625
- start++;
5626
- }
5309
+ return this.untrackedValue;
5310
+ }
5311
+ set value(value) {
5312
+ if (value !== this.$untrackedValue$) {
5313
+ DEBUG3 && log2("Signal.set", this.$untrackedValue$, "->", value, pad("\n" + this.toString(), " "));
5314
+ this.$untrackedValue$ = value;
5315
+ triggerEffects(this.$container$, this, this.$effects$);
5627
5316
  }
5628
- return start;
5629
- };
5630
- const nextSibling = node => {
5631
- while (node && (node = node.nextSibling) && 0 === getFastNodeType(node)) {}
5632
- return node;
5633
- };
5634
- const firstChild = node => {
5635
- while (node && (node = node.firstChild) && 0 === getFastNodeType(node)) {}
5636
- return node;
5637
- };
5638
- const walkContainer = (walker2, containerNode, node, exitNode, vData, qVNodeRefs, prefix) => {
5639
- const vData_length = vData.length;
5640
- let elementIdx = 0;
5641
- let vNodeElementIndex = -1;
5642
- let vData_start = 0;
5643
- let vData_end = 0;
5644
- let ch = 0;
5645
- let needsToStoreRef = -1;
5646
- let nextNode = null;
5647
- const howManyElementsToSkip = () => {
5648
- let elementsToSkip = 0;
5649
- while (isSeparator(ch = vData.charCodeAt(vData_start))) {
5650
- elementsToSkip += 1 << ch - VNodeDataSeparator.ADVANCE_1;
5651
- vData_start++;
5652
- if (vData_start >= vData_length) {
5653
- break;
5654
- }
5655
- }
5656
- return elementsToSkip;
5317
+ }
5318
+ valueOf() {
5319
+ if (qDev) {
5320
+ throw qError(46);
5321
+ }
5322
+ }
5323
+ toString() {
5324
+ return `[${this.constructor.name}${this.$invalid$ ? " INVALID" : ""} ${String(this.$untrackedValue$)}]` + (this.$effects$?.map((e => "\n -> " + pad(qwikDebugToString(e[0]), " "))).join("\n") || "");
5325
+ }
5326
+ toJSON() {
5327
+ return {
5328
+ value: this.$untrackedValue$
5657
5329
  };
5658
- do {
5659
- if (node === exitNode) {
5660
- return;
5661
- }
5662
- nextNode = null;
5663
- const nodeType = node == containerNode ? 2 : getFastNodeType(node);
5664
- if (3 === nodeType) {
5665
- const container = node;
5666
- let cursor = node;
5667
- while (cursor && !(nextNode = nextSibling(cursor))) {
5668
- cursor = cursor.parentNode;
5330
+ }
5331
+ };
5332
+
5333
+ var ensureContains = (array, value) => {
5334
+ const isMissing = -1 === array.indexOf(value);
5335
+ isMissing && array.push(value);
5336
+ };
5337
+
5338
+ var ensureContainsEffect = (array, effectSubscriptions) => {
5339
+ for (let i = 0; i < array.length; i++) {
5340
+ const existingEffect = array[i];
5341
+ if (existingEffect[0] === effectSubscriptions[0] && existingEffect[1] === effectSubscriptions[1]) {
5342
+ return;
5343
+ }
5344
+ }
5345
+ array.push(effectSubscriptions);
5346
+ };
5347
+
5348
+ var ensureEffectContainsSubscriber = (effect, subscriber, container) => {
5349
+ if (isSubscriber(effect)) {
5350
+ effect.$effectDependencies$ || (effect.$effectDependencies$ = []);
5351
+ if (subscriberExistInSubscribers(effect.$effectDependencies$, subscriber)) {
5352
+ return;
5353
+ }
5354
+ effect.$effectDependencies$.push(subscriber);
5355
+ } else if (vnode_isVNode(effect) && !vnode_isTextVNode(effect)) {
5356
+ let subscribers = vnode_getProp(effect, QSubscribers, container ? container.$getObjectById$ : null);
5357
+ subscribers || (subscribers = []);
5358
+ if (subscriberExistInSubscribers(subscribers, subscriber)) {
5359
+ return;
5360
+ }
5361
+ subscribers.push(subscriber);
5362
+ vnode_setProp(effect, QSubscribers, subscribers);
5363
+ } else if (isSSRNode(effect)) {
5364
+ let subscribers = effect.getProp(QSubscribers);
5365
+ subscribers || (subscribers = []);
5366
+ if (subscriberExistInSubscribers(subscribers, subscriber)) {
5367
+ return;
5368
+ }
5369
+ subscribers.push(subscriber);
5370
+ effect.setProp(QSubscribers, subscribers);
5371
+ }
5372
+ };
5373
+
5374
+ var isSSRNode = effect => "setProp" in effect && "getProp" in effect && "removeProp" in effect && "id" in effect;
5375
+
5376
+ var subscriberExistInSubscribers = (subscribers, subscriber) => {
5377
+ for (let i = 0; i < subscribers.length; i++) {
5378
+ if (subscribers[i] === subscriber) {
5379
+ return true;
5380
+ }
5381
+ }
5382
+ return false;
5383
+ };
5384
+
5385
+ var triggerEffects = (container, signal, effects) => {
5386
+ if (effects) {
5387
+ const scheduleEffect = effectSubscriptions => {
5388
+ const effect = effectSubscriptions[0];
5389
+ const property = effectSubscriptions[1];
5390
+ assertDefined(container, "Container must be defined.");
5391
+ if (isTask(effect)) {
5392
+ effect.$flags$ |= 8;
5393
+ DEBUG3 && log2("schedule.effect.task", pad("\n" + String(effect), " "));
5394
+ let choreType = 3;
5395
+ 1 & effect.$flags$ ? choreType = 32 : 4 & effect.$flags$ && (choreType = 2);
5396
+ container.$scheduler$(choreType, effect);
5397
+ } else if (effect instanceof Signal) {
5398
+ effect instanceof ComputedSignal && (effect.$computeQrl$.resolved || container.$scheduler$(1, null, effect.$computeQrl$));
5399
+ effect.$invalidate$();
5400
+ } else if (":" === property) {
5401
+ const host = effect;
5402
+ const qrl = container.getHostProp(host, OnRenderProp);
5403
+ assertDefined(qrl, "Component must have QRL");
5404
+ const props = container.getHostProp(host, ELEMENT_PROPS);
5405
+ container.$scheduler$(7, host, qrl, props);
5406
+ } else if ("." === property) {
5407
+ const host = effect;
5408
+ const target = host;
5409
+ container.$scheduler$(4, host, target, signal);
5410
+ } else {
5411
+ const host = effect;
5412
+ const effectData = effectSubscriptions[2];
5413
+ if (effectData instanceof EffectPropData) {
5414
+ const data = effectData.data;
5415
+ const payload = {
5416
+ ...data,
5417
+ $value$: signal
5418
+ };
5419
+ container.$scheduler$(5, host, property, payload);
5669
5420
  }
5670
- walkContainer(walker2, container, node, nextNode, container.qVnodeData || "", container.qVNodeRefs, prefix + " ");
5671
- } else if (16 === nodeType) {
5672
- let islandNode = node;
5673
- do {
5674
- islandNode = walker2.nextNode();
5675
- if (!islandNode) {
5676
- throw new Error(`Island inside \x3c!--${node?.nodeValue}--\x3e not found!`);
5677
- }
5678
- } while (65 !== getFastNodeType(islandNode));
5679
- nextNode = null;
5680
- } else if (128 === nodeType) {
5681
- nextNode = node;
5682
- do {
5683
- nextNode = walker2.nextNode();
5684
- if (!nextNode) {
5685
- throw new Error("Ignore block not closed!");
5686
- }
5687
- } while (32 !== getFastNodeType(nextNode));
5688
- nextNode = null;
5689
- } else if (5 === nodeType) {
5690
- nextNode = node;
5691
- do {
5692
- nextNode = nextSibling(nextNode);
5693
- if (!nextNode) {
5694
- throw new Error(`\x3c!--${node?.nodeValue}--\x3e not closed!`);
5695
- }
5696
- } while (8 !== getFastNodeType(nextNode));
5697
- walkContainer(walker2, node, node, nextNode, "", null, prefix + " ");
5698
- } else if (6 === nodeType) {
5699
- nextNode = nextSibling(node);
5700
- const shadowRootContainer = node;
5701
- const shadowRoot = shadowRootContainer?.shadowRoot;
5702
- shadowRoot && walkContainer(document2.createTreeWalker(shadowRoot, 129), null, firstChild(shadowRoot), null, "", null, prefix + " ");
5703
5421
  }
5704
- if (2 === (2 & nodeType)) {
5705
- if (vNodeElementIndex < elementIdx) {
5706
- -1 === vNodeElementIndex && (vNodeElementIndex = 0);
5707
- vData_start = vData_end;
5708
- if (vData_start < vData_length) {
5709
- vNodeElementIndex += howManyElementsToSkip();
5710
- const shouldStoreRef = ch === VNodeDataSeparator.REFERENCE;
5711
- if (shouldStoreRef) {
5712
- needsToStoreRef = vNodeElementIndex;
5713
- vData_start++;
5714
- ch = vData_start < vData_length ? vData.charCodeAt(vData_end) : VNodeDataSeparator.ADVANCE_1;
5715
- }
5716
- vData_end = findVDataSectionEnd(vData, vData_start, vData_length);
5717
- } else {
5718
- vNodeElementIndex = Number.MAX_SAFE_INTEGER;
5719
- }
5720
- }
5721
- if (elementIdx === vNodeElementIndex) {
5722
- needsToStoreRef === elementIdx && qVNodeRefs.set(elementIdx, node);
5723
- const instructions = vData.substring(vData_start, vData_end);
5724
- vNodeDataMap.set(node, instructions);
5725
- }
5726
- elementIdx++;
5422
+ };
5423
+ effects.forEach(scheduleEffect);
5424
+ }
5425
+ DEBUG3 && log2("done scheduling");
5426
+ };
5427
+
5428
+ var ComputedSignal = class extends Signal {
5429
+ constructor(container, fn) {
5430
+ super(container, NEEDS_COMPUTATION);
5431
+ __publicField(this, "$computeQrl$");
5432
+ __publicField(this, "$invalid$", true);
5433
+ __publicField(this, "$forceRunEffects$", false);
5434
+ this.$computeQrl$ = fn;
5435
+ }
5436
+ $invalidate$() {
5437
+ this.$invalid$ = true;
5438
+ this.$forceRunEffects$ = false;
5439
+ this.$container$?.$scheduler$(8, null, this);
5440
+ }
5441
+ force() {
5442
+ this.$invalid$ = true;
5443
+ this.$forceRunEffects$ = false;
5444
+ triggerEffects(this.$container$, this, this.$effects$);
5445
+ }
5446
+ get untrackedValue() {
5447
+ const didChange = this.$computeIfNeeded$();
5448
+ didChange && (this.$forceRunEffects$ = didChange);
5449
+ assertFalse(this.$untrackedValue$ === NEEDS_COMPUTATION, "Invalid state");
5450
+ return this.$untrackedValue$;
5451
+ }
5452
+ $computeIfNeeded$() {
5453
+ if (!this.$invalid$) {
5454
+ return false;
5455
+ }
5456
+ const computeQrl = this.$computeQrl$;
5457
+ throwIfQRLNotResolved(computeQrl);
5458
+ const ctx = tryGetInvokeContext();
5459
+ const previousEffectSubscription = ctx?.$effectSubscriber$;
5460
+ ctx && (ctx.$effectSubscriber$ = [ this, "." ]);
5461
+ try {
5462
+ const untrackedValue = computeQrl.getFn(ctx)();
5463
+ if (isPromise(untrackedValue)) {
5464
+ throw qError(47, [ computeQrl.dev ? computeQrl.dev.file : "", computeQrl.$hash$ ]);
5727
5465
  }
5728
- } while (node = nextNode || walker2.nextNode());
5729
- };
5730
- const walker = document2.createTreeWalker(document2, 129);
5731
- walkContainer(walker, null, walker.firstChild(), null, "", null, "");
5732
- }
5466
+ DEBUG3 && log2("Signal.$compute$", untrackedValue);
5467
+ this.$invalid$ = false;
5468
+ const didChange = untrackedValue !== this.$untrackedValue$;
5469
+ didChange && (this.$untrackedValue$ = untrackedValue);
5470
+ return didChange;
5471
+ } finally {
5472
+ ctx && (ctx.$effectSubscriber$ = previousEffectSubscription);
5473
+ }
5474
+ }
5475
+ get value() {
5476
+ return super.value;
5477
+ }
5478
+ set value(_) {
5479
+ throw qError(48);
5480
+ }
5481
+ };
5482
+
5483
+ var WrappedSignal = class extends Signal {
5484
+ constructor(container, fn, args, fnStr) {
5485
+ super(container, NEEDS_COMPUTATION);
5486
+ __publicField(this, "$args$");
5487
+ __publicField(this, "$func$");
5488
+ __publicField(this, "$funcStr$");
5489
+ __publicField(this, "$invalid$", true);
5490
+ __publicField(this, "$effectDependencies$", null);
5491
+ __publicField(this, "$hostElement$", null);
5492
+ __publicField(this, "$forceRunEffects$", false);
5493
+ this.$args$ = args;
5494
+ this.$func$ = fn;
5495
+ this.$funcStr$ = fnStr;
5496
+ }
5497
+ $invalidate$() {
5498
+ this.$invalid$ = true;
5499
+ this.$forceRunEffects$ = false;
5500
+ this.$container$?.$scheduler$(8, this.$hostElement$, this);
5501
+ }
5502
+ force() {
5503
+ this.$invalid$ = true;
5504
+ this.$forceRunEffects$ = false;
5505
+ triggerEffects(this.$container$, this, this.$effects$);
5506
+ }
5507
+ get untrackedValue() {
5508
+ const didChange = this.$computeIfNeeded$();
5509
+ didChange && (this.$forceRunEffects$ = didChange);
5510
+ assertFalse(this.$untrackedValue$ === NEEDS_COMPUTATION, "Invalid state");
5511
+ return this.$untrackedValue$;
5512
+ }
5513
+ $computeIfNeeded$() {
5514
+ if (!this.$invalid$) {
5515
+ return false;
5516
+ }
5517
+ const untrackedValue = trackSignal((() => this.$func$(...this.$args$)), this, ".", this.$container$);
5518
+ const didChange = untrackedValue !== this.$untrackedValue$;
5519
+ didChange && (this.$untrackedValue$ = untrackedValue);
5520
+ return didChange;
5521
+ }
5522
+ get value() {
5523
+ return super.value;
5524
+ }
5525
+ set value(_) {
5526
+ throw qError(49);
5527
+ }
5528
+ };
5733
5529
 
5734
- function getDomContainer(element) {
5735
- const qContainerElement = _getQContainerElement(element);
5736
- qContainerElement || throwErrorAndStop("Unable to find q:container.");
5737
- return getDomContainerFromQContainerElement(qContainerElement);
5738
- }
5530
+ var version = "2.0.0-alpha.5-dev+cb53bbd";
5739
5531
 
5740
- function getDomContainerFromQContainerElement(qContainerElement) {
5741
- const qElement = qContainerElement;
5742
- let container = qElement.qContainer;
5743
- if (!container) {
5744
- container = new DomContainer(qElement);
5745
- const containerAttributes = {};
5746
- if (qElement) {
5747
- const attrs = qElement.attributes;
5748
- if (attrs) {
5749
- for (let index = 0; index < attrs.length; index++) {
5750
- const attr = attrs[index];
5751
- if (attr.name === Q_PROPS_SEPARATOR) {
5752
- continue;
5753
- }
5754
- containerAttributes[attr.name] = attr.value;
5755
- }
5756
- }
5757
- }
5758
- container.$serverData$ = {
5759
- containerAttributes: containerAttributes
5532
+ var _SharedContainer = class {
5533
+ constructor(scheduleDrain, journalFlush, serverData, locale) {
5534
+ __publicField(this, "$version$");
5535
+ __publicField(this, "$scheduler$");
5536
+ __publicField(this, "$storeProxyMap$");
5537
+ __publicField(this, "$locale$");
5538
+ __publicField(this, "$getObjectById$");
5539
+ __publicField(this, "$serverData$");
5540
+ __publicField(this, "$currentUniqueId$", 0);
5541
+ __publicField(this, "$instanceHash$", null);
5542
+ this.$serverData$ = serverData;
5543
+ this.$locale$ = locale;
5544
+ this.$version$ = version;
5545
+ this.$storeProxyMap$ = new WeakMap;
5546
+ this.$getObjectById$ = _id => {
5547
+ throw Error("Not implemented");
5760
5548
  };
5761
- qElement.setAttribute(QContainerAttr, "resumed");
5762
- qElement.qContainer = container;
5549
+ this.$scheduler$ = createScheduler(this, scheduleDrain, journalFlush);
5763
5550
  }
5764
- return container;
5765
- }
5551
+ trackSignalValue(signal, subscriber, property, data) {
5552
+ return trackSignalAndAssignHost(signal, subscriber, property, this, data);
5553
+ }
5554
+ serializationCtxFactory(NodeConstructor, DomRefConstructor, symbolToChunkResolver, writer, prepVNodeData) {
5555
+ return createSerializationContext(NodeConstructor, DomRefConstructor, symbolToChunkResolver, this.getHostProp.bind(this), this.setHostProp.bind(this), this.$storeProxyMap$, writer, prepVNodeData);
5556
+ }
5557
+ };
5766
5558
 
5767
- function _getQContainerElement(element) {
5768
- const qContainerElement = Array.isArray(element) ? vnode_getDomParent(element) : element;
5769
- return qContainerElement.closest(QContainerSelector);
5770
- }
5559
+ var QObjectRecursive = 1;
5771
5560
 
5772
- var isDomContainer = container => container instanceof DomContainer;
5561
+ var QObjectImmutable = 2;
5773
5562
 
5774
- var DomContainer = class extends _SharedContainer {
5775
- constructor(element) {
5776
- super((() => this.scheduleRender()), (() => vnode_applyJournal(this.$journal$)), {}, element.getAttribute("q:locale"));
5777
- __publicField(this, "element");
5778
- __publicField(this, "qContainer");
5779
- __publicField(this, "qBase");
5780
- __publicField(this, "qManifestHash");
5781
- __publicField(this, "rootVNode");
5782
- __publicField(this, "document");
5783
- __publicField(this, "$journal$");
5784
- __publicField(this, "renderDone", null);
5785
- __publicField(this, "$rawStateData$");
5786
- __publicField(this, "$storeProxyMap$", new WeakMap);
5787
- __publicField(this, "$qFuncs$");
5788
- __publicField(this, "$instanceHash$");
5789
- __publicField(this, "stateData");
5790
- __publicField(this, "$styleIds$", null);
5791
- __publicField(this, "$vnodeLocate$", (id => vnode_locate(this.rootVNode, id)));
5792
- __publicField(this, "$renderCount$", 0);
5793
- __publicField(this, "$getObjectById$", (id => {
5794
- "string" === typeof id && (id = parseFloat(id));
5795
- assertTrue(id < this.$rawStateData$.length / 2, `Invalid reference: ${id} >= ${this.$rawStateData$.length / 2}`);
5796
- return this.stateData[id];
5797
- }));
5798
- this.qContainer = element.getAttribute(QContainerAttr);
5799
- this.qContainer || throwErrorAndStop("Element must have 'q:container' attribute.");
5800
- this.$journal$ = [ 3, element.ownerDocument ];
5801
- this.document = element.ownerDocument;
5802
- this.element = element;
5803
- this.qBase = element.getAttribute(QBaseAttr);
5804
- this.$instanceHash$ = element.getAttribute(QInstanceAttr);
5805
- this.qManifestHash = element.getAttribute("q:manifest-hash");
5806
- this.rootVNode = vnode_newUnMaterializedElement(this.element);
5807
- this.$rawStateData$ = null;
5808
- this.stateData = null;
5809
- const document2 = this.element.ownerDocument;
5810
- document2.qVNodeData || processVNodeData(document2);
5811
- this.$rawStateData$ = [];
5812
- this.stateData = [];
5813
- const qwikStates = element.querySelectorAll('script[type="qwik/state"]');
5814
- if (0 !== qwikStates.length) {
5815
- const lastState = qwikStates[qwikStates.length - 1];
5816
- this.$rawStateData$ = JSON.parse(lastState.textContent);
5817
- this.stateData = wrapDeserializerProxy(this, this.$rawStateData$);
5818
- }
5819
- this.$qFuncs$ = getQFuncs(document2, this.$instanceHash$) || EMPTY_ARRAY;
5820
- }
5821
- $setRawState$(id, vParent) {
5822
- this.stateData[id] = vParent;
5823
- }
5824
- parseQRL(qrl2) {
5825
- return inflateQRL(this, parseQRL(qrl2));
5563
+ var QObjectTargetSymbol = Symbol("proxy target");
5564
+
5565
+ var QObjectFlagsSymbol = Symbol("proxy flags");
5566
+
5567
+ var QObjectManagerSymbol = Symbol("proxy manager");
5568
+
5569
+ var _CONST_PROPS = Symbol("CONST");
5570
+
5571
+ var _VAR_PROPS = Symbol("VAR");
5572
+
5573
+ var _IMMUTABLE = Symbol("IMMUTABLE");
5574
+
5575
+ var componentQrl = componentQrl2 => {
5576
+ function QwikComponent(props, key, flags = 0) {
5577
+ assertQrl(componentQrl2);
5578
+ assertNumber(flags, "The Qwik Component was not invoked correctly");
5579
+ const hash = qTest ? "sX" : componentQrl2.$hash$.slice(0, 4);
5580
+ const finalKey = hash + ":" + (key || "");
5581
+ const InnerCmp = () => {};
5582
+ InnerCmp[SERIALIZABLE_STATE] = [ componentQrl2 ];
5583
+ return _jsxSplit(InnerCmp, props, null, props.children, flags, finalKey);
5826
5584
  }
5827
- handleError(err, host) {
5828
- if (qDev) {
5829
- if ("undefined" !== typeof document) {
5830
- const vHost = host;
5831
- const errorDiv = document.createElement("errored-host");
5832
- err && err instanceof Error && (errorDiv.props = {
5833
- error: err
5834
- });
5835
- errorDiv.setAttribute("q:key", "_error_");
5836
- const journal = [];
5837
- vnode_getDOMChildNodes(journal, vHost).forEach((child => errorDiv.appendChild(child)));
5838
- const vErrorDiv = vnode_newElement(errorDiv, "error-host");
5839
- vnode_insertBefore(journal, vHost, vErrorDiv, null);
5840
- vnode_applyJournal(journal);
5841
- }
5842
- err && err instanceof Error && ("hostElement" in err || (err.hostElement = host));
5843
- if (!isRecoverable(err)) {
5844
- throw err;
5845
- }
5585
+ QwikComponent[SERIALIZABLE_STATE] = [ componentQrl2 ];
5586
+ return QwikComponent;
5587
+ };
5588
+
5589
+ var SERIALIZABLE_STATE = Symbol("serializable-data");
5590
+
5591
+ var isQwikComponent = component => "function" == typeof component && void 0 !== component[SERIALIZABLE_STATE];
5592
+
5593
+ var _jsxSorted = (type, varProps, constProps, children, flags, key, dev) => {
5594
+ const processed = null == key ? null : String(key);
5595
+ const node = new JSXNodeImpl(type, varProps || {}, constProps || null, children, flags, processed);
5596
+ qDev && dev && (node.dev = {
5597
+ stack: (new Error).stack,
5598
+ ...dev
5599
+ });
5600
+ seal(node);
5601
+ return node;
5602
+ };
5603
+
5604
+ var _jsxSplit = (type, varProps, constProps, children, flags, key, dev) => {
5605
+ let sortedProps;
5606
+ sortedProps = varProps ? Object.fromEntries(untrack((() => Object.entries(varProps))).filter((entry => {
5607
+ const attr = entry[0];
5608
+ if ("children" === attr) {
5609
+ children ?? (children = entry[1]);
5610
+ return false;
5846
5611
  }
5847
- const errorStore = this.resolveContext(host, ERROR_CONTEXT);
5848
- if (!errorStore) {
5849
- throw err;
5612
+ if ("key" === attr) {
5613
+ key = entry[1];
5614
+ return false;
5850
5615
  }
5851
- errorStore.error = err;
5852
- }
5853
- setContext(host, context, value) {
5854
- let ctx = this.getHostProp(host, QCtxAttr);
5855
- ctx || this.setHostProp(host, QCtxAttr, ctx = []);
5856
- mapArray_set(ctx, context.id, value, 0);
5616
+ return !constProps || !(attr in constProps) || /^on[A-Z].*\$$/.test(attr);
5617
+ })).sort((([a], [b]) => a < b ? -1 : 1))) : "string" === typeof type ? EMPTY_OBJ : {};
5618
+ if (constProps && "children" in constProps) {
5619
+ children = constProps.children;
5620
+ constProps.children = void 0;
5857
5621
  }
5858
- resolveContext(host, contextId) {
5859
- while (host) {
5860
- const ctx = this.getHostProp(host, QCtxAttr);
5861
- if (ctx) {
5862
- const value = mapArray_get(ctx, contextId.id, 0);
5863
- if (value) {
5864
- return value;
5865
- }
5622
+ return _jsxSorted(type, sortedProps, constProps, children, flags, key, dev);
5623
+ };
5624
+
5625
+ var isPropsProxy = obj => obj && void 0 !== obj[_VAR_PROPS];
5626
+
5627
+ var JSXNodeImpl = class {
5628
+ constructor(type, varProps, constProps, children, flags, key = null) {
5629
+ this.type = type;
5630
+ this.varProps = varProps;
5631
+ this.constProps = constProps;
5632
+ this.children = children;
5633
+ this.flags = flags;
5634
+ this.key = key;
5635
+ __publicField(this, "dev");
5636
+ __publicField(this, "_proxy", null);
5637
+ if (qDev) {
5638
+ if ("object" !== typeof varProps) {
5639
+ throw new Error("JSXNodeImpl: varProps must be objects: " + JSON.stringify(varProps));
5866
5640
  }
5867
- host = this.getParentHost(host);
5868
- }
5869
- return;
5870
- }
5871
- getParentHost(host) {
5872
- let vNode = vnode_getParent(host);
5873
- while (vNode) {
5874
- if (vnode_isVirtualVNode(vNode)) {
5875
- if (null !== vnode_getProp(vNode, OnRenderProp, null)) {
5876
- return vNode;
5877
- }
5878
- const parent = vnode_getProp(vNode, QSlotParent, this.$vnodeLocate$);
5879
- if (parent) {
5880
- vNode = parent;
5881
- continue;
5882
- }
5641
+ if ("object" !== typeof constProps) {
5642
+ throw new Error("JSXNodeImpl: constProps must be objects: " + JSON.stringify(constProps));
5883
5643
  }
5884
- vNode = vnode_getParent(vNode);
5885
5644
  }
5886
- return null;
5887
5645
  }
5888
- setHostProp(host, name, value) {
5889
- const vNode = host;
5890
- vnode_setProp(vNode, name, value);
5646
+ get props() {
5647
+ this._proxy || (this._proxy = createPropsProxy(this.varProps, this.constProps, this.children));
5648
+ return this._proxy;
5891
5649
  }
5892
- getHostProp(host, name) {
5893
- const vNode = host;
5894
- let getObjectById = null;
5895
- switch (name) {
5896
- case ELEMENT_SEQ:
5897
- case ELEMENT_PROPS:
5898
- case OnRenderProp:
5899
- case QCtxAttr:
5900
- case QSubscribers:
5901
- getObjectById = this.$getObjectById$;
5902
- break;
5650
+ };
5903
5651
 
5904
- case ELEMENT_SEQ_IDX:
5905
- case USE_ON_LOCAL_SEQ_IDX:
5906
- getObjectById = parseInt;
5907
- break;
5652
+ var Virtual = props => props.children;
5653
+
5654
+ var isJSXNode = n => {
5655
+ if (qDev) {
5656
+ if (n instanceof JSXNodeImpl) {
5657
+ return true;
5908
5658
  }
5909
- return vnode_getProp(vNode, name, getObjectById);
5659
+ if (isObject(n) && "key" in n && "props" in n && "type" in n) {
5660
+ logWarn('Duplicate implementations of "JSXNode" found');
5661
+ return true;
5662
+ }
5663
+ return false;
5910
5664
  }
5911
- scheduleRender() {
5912
- this.$renderCount$++;
5913
- this.renderDone || (this.renderDone = getPlatform().nextTick((() => this.processChores())));
5914
- return this.renderDone;
5665
+ return n instanceof JSXNodeImpl;
5666
+ };
5667
+
5668
+ var Fragment = props => props.children;
5669
+
5670
+ function createPropsProxy(varProps, constProps, children) {
5671
+ return new Proxy({}, new PropsProxyHandler(varProps, constProps, children));
5672
+ }
5673
+
5674
+ var PropsProxyHandler = class {
5675
+ constructor($varProps$, $constProps$, $children$) {
5676
+ this.$varProps$ = $varProps$;
5677
+ this.$constProps$ = $constProps$;
5678
+ this.$children$ = $children$;
5915
5679
  }
5916
- processChores() {
5917
- let renderCount = this.$renderCount$;
5918
- const result = this.$scheduler$(127);
5919
- if (isPromise(result)) {
5920
- return result.then((async () => {
5921
- while (renderCount !== this.$renderCount$) {
5922
- renderCount = this.$renderCount$;
5923
- await this.$scheduler$(127);
5924
- }
5925
- this.renderDone = null;
5926
- }));
5680
+ get(_, prop) {
5681
+ if (prop === _CONST_PROPS) {
5682
+ return this.$constProps$;
5927
5683
  }
5928
- if (renderCount !== this.$renderCount$) {
5929
- this.processChores();
5930
- return;
5684
+ if (prop === _VAR_PROPS) {
5685
+ return this.$varProps$;
5931
5686
  }
5932
- this.renderDone = null;
5933
- }
5934
- ensureProjectionResolved(vNode) {
5935
- if (0 === (16 & vNode[0])) {
5936
- vNode[0] |= 16;
5937
- for (let i = vnode_getPropStartIndex(vNode); i < vNode.length; i += 2) {
5938
- const prop = vNode[i];
5939
- if (isSlotProp(prop)) {
5940
- const value = vNode[i + 1];
5941
- "string" == typeof value && (vNode[i + 1] = this.$vnodeLocate$(value));
5942
- }
5943
- }
5687
+ if (null != this.$children$ && "children" === prop) {
5688
+ return this.$children$;
5944
5689
  }
5690
+ const value = this.$constProps$ && prop in this.$constProps$ ? this.$constProps$[prop] : this.$varProps$[prop];
5691
+ return value instanceof WrappedSignal ? value.value : value;
5945
5692
  }
5946
- getSyncFn(id) {
5947
- const fn = this.$qFuncs$[id];
5948
- assertTrue("function" === typeof fn, "Invalid reference: " + id);
5949
- return fn;
5950
- }
5951
- $appendStyle$(content, styleId, host, scoped) {
5952
- if (scoped) {
5953
- const scopedStyleIdsString = this.getHostProp(host, QScopedStyle);
5954
- const scopedStyleIds = new Set(convertScopedStyleIdsToArray(scopedStyleIdsString));
5955
- scopedStyleIds.add(styleId);
5956
- this.setHostProp(host, QScopedStyle, convertStyleIdsToString(scopedStyleIds));
5693
+ set(_, prop, value) {
5694
+ if (prop === _CONST_PROPS) {
5695
+ this.$constProps$ = value;
5696
+ return true;
5957
5697
  }
5958
- if (null == this.$styleIds$) {
5959
- this.$styleIds$ = new Set;
5960
- this.element.querySelectorAll(QStyleSelector).forEach((style => {
5961
- this.$styleIds$.add(style.getAttribute(QStyle));
5962
- }));
5698
+ if (prop === _VAR_PROPS) {
5699
+ this.$varProps$ = value;
5700
+ return true;
5963
5701
  }
5964
- if (!this.$styleIds$.has(styleId)) {
5965
- this.$styleIds$.add(styleId);
5966
- const styleElement = this.document.createElement("style");
5967
- styleElement.setAttribute(QStyle, styleId);
5968
- styleElement.textContent = content;
5969
- this.$journal$.push(5, this.document.head, null, styleElement);
5702
+ this.$constProps$ && prop in this.$constProps$ ? this.$constProps$[prop] = value : this.$varProps$[prop] = value;
5703
+ return true;
5704
+ }
5705
+ deleteProperty(_, prop) {
5706
+ if ("string" !== typeof prop) {
5707
+ return false;
5970
5708
  }
5709
+ let didDelete = delete this.$varProps$[prop];
5710
+ this.$constProps$ && (didDelete = delete this.$constProps$[prop] || didDelete);
5711
+ null != this.$children$ && "children" === prop && (this.$children$ = null);
5712
+ return didDelete;
5971
5713
  }
5972
- };
5973
-
5974
- var runTask = (task, container, host) => {
5975
- task.$flags$ &= -9;
5976
- cleanupTask(task);
5977
- const iCtx = newInvokeContext(container.$locale$, host, void 0, TaskEvent);
5978
- iCtx.$container$ = container;
5979
- const taskFn = task.$qrl$.getFn(iCtx, (() => clearSubscriberEffectDependencies(task)));
5980
- const track = (obj, prop) => {
5981
- const ctx = newInvokeContext();
5982
- ctx.$effectSubscriber$ = [ task, ":" ];
5983
- ctx.$container$ = container;
5984
- return invoke(ctx, (() => {
5985
- if (isFunction(obj)) {
5986
- return obj();
5987
- }
5988
- return prop ? obj[prop] : isSignal(obj) ? obj.value : obj;
5989
- }));
5990
- };
5991
- const handleError = reason => container.handleError(reason, host);
5992
- let cleanupFns = null;
5993
- const cleanup2 = fn => {
5994
- if ("function" == typeof fn) {
5995
- if (!cleanupFns) {
5996
- cleanupFns = [];
5997
- task.$destroy$ = noSerialize((() => {
5998
- task.$destroy$ = null;
5999
- cleanupFns.forEach((fn2 => {
6000
- try {
6001
- fn2();
6002
- } catch (err) {
6003
- handleError(err);
6004
- }
6005
- }));
6006
- }));
5714
+ has(_, prop) {
5715
+ const hasProp = "children" === prop && null != this.$children$ || prop === _CONST_PROPS || prop === _VAR_PROPS || prop in this.$varProps$ || !!this.$constProps$ && prop in this.$constProps$;
5716
+ return hasProp;
5717
+ }
5718
+ getOwnPropertyDescriptor(target, p) {
5719
+ const value = "children" === p && null != this.$children$ ? this.$children$ : this.$constProps$ && p in this.$constProps$ ? this.$constProps$[p] : this.$varProps$[p];
5720
+ return {
5721
+ configurable: true,
5722
+ enumerable: true,
5723
+ value: value
5724
+ };
5725
+ }
5726
+ ownKeys() {
5727
+ const out = Object.keys(this.$varProps$);
5728
+ null != this.$children$ && -1 === out.indexOf("children") && out.push("children");
5729
+ if (this.$constProps$) {
5730
+ for (const key in this.$constProps$) {
5731
+ -1 === out.indexOf(key) && out.push(key);
6007
5732
  }
6008
- cleanupFns.push(fn);
6009
- }
6010
- };
6011
- const taskApi = {
6012
- track: track,
6013
- cleanup: cleanup2
6014
- };
6015
- const result = safeCall((() => taskFn(taskApi)), cleanup2, (err => isPromise(err) ? err.then((() => runTask(task, container, host))) : handleError(err)));
6016
- return result;
6017
- };
6018
-
6019
- var cleanupTask = task => {
6020
- const destroy = task.$destroy$;
6021
- if (destroy) {
6022
- task.$destroy$ = null;
6023
- try {
6024
- destroy();
6025
- } catch (err) {
6026
- logError(err);
6027
5733
  }
5734
+ return out;
6028
5735
  }
6029
5736
  };
6030
5737
 
6031
- var Task2 = class extends Subscriber {
6032
- constructor($flags$, $index$, $el$, $qrl$, $state$, $destroy$) {
6033
- super();
6034
- this.$flags$ = $flags$;
6035
- this.$index$ = $index$;
6036
- this.$el$ = $el$;
6037
- this.$qrl$ = $qrl$;
6038
- this.$state$ = $state$;
6039
- this.$destroy$ = $destroy$;
6040
- }
6041
- };
6042
-
6043
- var isTask = value => value instanceof Task2;
5738
+ var directGetPropsProxyProp = (jsx2, prop) => jsx2.constProps && prop in jsx2.constProps ? jsx2.constProps[prop] : jsx2.varProps[prop];
6044
5739
 
6045
5740
  var stringifyPath = [];
6046
5741
 
@@ -6091,29 +5786,95 @@ function qwikDebugToString(value) {
6091
5786
 
6092
5787
  var pad = (text, prefix) => String(text).split("\n").map(((line, idx) => (idx ? prefix : "") + line)).join("\n");
6093
5788
 
6094
- var jsxToString = value => {
6095
- if (isJSXNode(value)) {
6096
- let type = value.type;
6097
- "function" === typeof type && (type = type.name || "Component");
6098
- let str = "<" + value.type;
6099
- if (value.props) {
6100
- for (const [key, val] of Object.entries(value.props)) {
6101
- str += " " + key + "=" + qwikDebugToString(val);
6102
- }
6103
- const children = value.children;
6104
- if (null != children) {
6105
- str += ">";
6106
- Array.isArray(children) ? children.forEach((child => {
6107
- str += jsxToString(child);
6108
- })) : str += jsxToString(children);
6109
- str += "</" + value.type + ">";
6110
- } else {
6111
- str += "/>";
6112
- }
6113
- }
6114
- return str;
6115
- }
6116
- return String(value);
5789
+ var jsxToString = value => {
5790
+ if (isJSXNode(value)) {
5791
+ let type = value.type;
5792
+ "function" === typeof type && (type = type.name || "Component");
5793
+ let str = "<" + value.type;
5794
+ if (value.props) {
5795
+ for (const [key, val] of Object.entries(value.props)) {
5796
+ str += " " + key + "=" + qwikDebugToString(val);
5797
+ }
5798
+ const children = value.children;
5799
+ if (null != children) {
5800
+ str += ">";
5801
+ Array.isArray(children) ? children.forEach((child => {
5802
+ str += jsxToString(child);
5803
+ })) : str += jsxToString(children);
5804
+ str += "</" + value.type + ">";
5805
+ } else {
5806
+ str += "/>";
5807
+ }
5808
+ }
5809
+ return str;
5810
+ }
5811
+ return String(value);
5812
+ };
5813
+
5814
+ var VNodeDataSeparator = {
5815
+ REFERENCE_CH: "~",
5816
+ REFERENCE: 126,
5817
+ ADVANCE_1_CH: "!",
5818
+ ADVANCE_1: 33,
5819
+ ADVANCE_2_CH: '"',
5820
+ ADVANCE_2: 34,
5821
+ ADVANCE_4_CH: "#",
5822
+ ADVANCE_4: 35,
5823
+ ADVANCE_8_CH: "$",
5824
+ ADVANCE_8: 36,
5825
+ ADVANCE_16_CH: "%",
5826
+ ADVANCE_16: 37,
5827
+ ADVANCE_32_CH: "&",
5828
+ ADVANCE_32: 38,
5829
+ ADVANCE_64_CH: "'",
5830
+ ADVANCE_64: 39,
5831
+ ADVANCE_128_CH: "(",
5832
+ ADVANCE_128: 40,
5833
+ ADVANCE_256_CH: ")",
5834
+ ADVANCE_256: 41,
5835
+ ADVANCE_512_CH: "*",
5836
+ ADVANCE_512: 42,
5837
+ ADVANCE_1024_CH: "+",
5838
+ ADVANCE_1024: 43,
5839
+ ADVANCE_2048_CH: ",",
5840
+ ADVANCE_2048: 44,
5841
+ ADVANCE_4096_CH: "-",
5842
+ ADVANCE_4096: 45,
5843
+ ADVANCE_8192_CH: ".",
5844
+ ADVANCE_8192: 46
5845
+ };
5846
+
5847
+ var VNodeDataChar = {
5848
+ OPEN: 123,
5849
+ OPEN_CHAR: "{",
5850
+ CLOSE: 125,
5851
+ CLOSE_CHAR: "}",
5852
+ SCOPED_STYLE: 59,
5853
+ SCOPED_STYLE_CHAR: ";",
5854
+ RENDER_FN: 60,
5855
+ RENDER_FN_CHAR: "<",
5856
+ ID: 61,
5857
+ ID_CHAR: "=",
5858
+ PROPS: 62,
5859
+ PROPS_CHAR: ">",
5860
+ SLOT_REF: 63,
5861
+ SLOT_REF_CHAR: "?",
5862
+ KEY: 64,
5863
+ KEY_CHAR: "@",
5864
+ SEQ: 91,
5865
+ SEQ_CHAR: "[",
5866
+ DON_T_USE: 92,
5867
+ DON_T_USE_CHAR: "\\",
5868
+ CONTEXT: 93,
5869
+ CONTEXT_CHAR: "]",
5870
+ SEQ_IDX: 94,
5871
+ SEQ_IDX_CHAR: "^",
5872
+ SUBS: 96,
5873
+ SUBS_CHAR: "`",
5874
+ SEPARATOR: 124,
5875
+ SEPARATOR_CHAR: "|",
5876
+ SLOT: 126,
5877
+ SLOT_CHAR: "~"
6117
5878
  };
6118
5879
 
6119
5880
  var vnode_newElement = (element, elementName) => {
@@ -6688,10 +6449,30 @@ var vnode_materialize = vNode => {
6688
6449
  const element = vNode[6];
6689
6450
  const firstChild = fastFirstChild(element);
6690
6451
  const vNodeData = element.ownerDocument?.qVNodeData?.get(element);
6691
- const vFirstChild = vNodeData ? materializeFromVNodeData(vNode, vNodeData, element, firstChild) : materializeFromDOM(vNode, firstChild);
6452
+ const vFirstChild = materialize(vNode, element, firstChild, vNodeData);
6692
6453
  return vFirstChild;
6693
6454
  };
6694
6455
 
6456
+ var materialize = (vNode, element, firstChild, vNodeData) => {
6457
+ if (vNodeData) {
6458
+ if (vNodeData.charCodeAt(0) === VNodeDataChar.SEPARATOR) {
6459
+ const elementVNodeDataStartIdx = 1;
6460
+ let elementVNodeDataEndIdx = 1;
6461
+ while (vNodeData.charCodeAt(elementVNodeDataEndIdx) !== VNodeDataChar.SEPARATOR) {
6462
+ elementVNodeDataEndIdx++;
6463
+ }
6464
+ const elementVNodeData = vNodeData.substring(elementVNodeDataStartIdx, elementVNodeDataEndIdx);
6465
+ vNodeData = vNodeData.substring(elementVNodeDataEndIdx + 1);
6466
+ const vFirstChild = materializeFromDOM(vNode, firstChild, elementVNodeData);
6467
+ if (!vNodeData) {
6468
+ return vFirstChild;
6469
+ }
6470
+ }
6471
+ return materializeFromVNodeData(vNode, vNodeData, element, firstChild);
6472
+ }
6473
+ return materializeFromDOM(vNode, firstChild);
6474
+ };
6475
+
6695
6476
  var ensureMaterialized = vnode => {
6696
6477
  const vParent = ensureElementVNode(vnode);
6697
6478
  let vFirstChild = vParent[4];
@@ -6803,7 +6584,7 @@ var fastGetter = (prototype, name) => {
6803
6584
 
6804
6585
  var isQStyleElement = node => isElement(node) && "STYLE" === node.nodeName && (node.hasAttribute(QScopedStyle) || node.hasAttribute(QStyle));
6805
6586
 
6806
- var materializeFromDOM = (vParent, firstChild) => {
6587
+ var materializeFromDOM = (vParent, firstChild, vData) => {
6807
6588
  let vFirstChild = null;
6808
6589
  const skipStyleElements = () => {
6809
6590
  while (isQStyleElement(child)) {
@@ -6829,9 +6610,46 @@ var materializeFromDOM = (vParent, firstChild) => {
6829
6610
  }
6830
6611
  vParent[5] = vChild || null;
6831
6612
  vParent[4] = vFirstChild;
6613
+ if (vData) {
6614
+ let container = null;
6615
+ processVNodeData(vData, ((peek, consumeValue) => {
6616
+ if (peek() === VNodeDataChar.ID) {
6617
+ container || (container = getDomContainer(vParent[6]));
6618
+ const id = consumeValue();
6619
+ container.$setRawState$(parseInt(id), vParent);
6620
+ isDev && vnode_setAttr(null, vParent, ELEMENT_ID, id);
6621
+ } else {
6622
+ peek() === VNodeDataChar.SUBS ? vnode_setProp(vParent, QSubscribers, consumeValue()) : consumeValue();
6623
+ }
6624
+ }));
6625
+ }
6832
6626
  return vFirstChild;
6833
6627
  };
6834
6628
 
6629
+ var processVNodeData = (vData, callback) => {
6630
+ let nextToConsumeIdx = 0;
6631
+ let ch = 0;
6632
+ let peekCh = 0;
6633
+ const peek = () => 0 !== peekCh ? peekCh : peekCh = nextToConsumeIdx < vData.length ? vData.charCodeAt(nextToConsumeIdx) : 0;
6634
+ const consume = () => {
6635
+ ch = peek();
6636
+ peekCh = 0;
6637
+ nextToConsumeIdx++;
6638
+ return ch;
6639
+ };
6640
+ const consumeValue = () => {
6641
+ consume();
6642
+ const start = nextToConsumeIdx;
6643
+ while (peek() <= 58 && 0 !== peekCh || 95 === peekCh || peekCh >= 65 && peekCh <= 90 || peekCh >= 97 && peekCh <= 122) {
6644
+ consume();
6645
+ }
6646
+ return vData.substring(start, nextToConsumeIdx);
6647
+ };
6648
+ while (0 !== peek()) {
6649
+ callback(peek, consumeValue, consume, nextToConsumeIdx);
6650
+ }
6651
+ };
6652
+
6835
6653
  var vnode_getNextSibling = vnode => vnode[3];
6836
6654
 
6837
6655
  var vnode_getPreviousSibling = vnode => vnode[2];
@@ -6908,7 +6726,7 @@ var vnode_getPropStartIndex = vnode => {
6908
6726
  if (2 === type) {
6909
6727
  return 6;
6910
6728
  }
6911
- throw throwErrorAndStop("Invalid vnode type.");
6729
+ throw qError(43, [ type ]);
6912
6730
  };
6913
6731
 
6914
6732
  var vnode_getParent = vnode => vnode[1] || null;
@@ -6924,7 +6742,7 @@ var vnode_getNode = vnode => {
6924
6742
  return vnode[4];
6925
6743
  };
6926
6744
 
6927
- function vnode_toString(depth = 10, offset = "", materialize = false, siblings = false) {
6745
+ function vnode_toString(depth = 20, offset = "", materialize2 = false, siblings = false) {
6928
6746
  let vnode = this;
6929
6747
  if (0 === depth) {
6930
6748
  return "...";
@@ -6972,7 +6790,7 @@ function vnode_toString(depth = 10, offset = "", materialize = false, siblings =
6972
6790
  -1 === keys2.indexOf(attr.name) && attrs.push(" " + attr.name + (attr.value ? "=" + qwikDebugToString(attr.value) : ""));
6973
6791
  }
6974
6792
  strings.push("<" + tag + attrs.join("") + ">");
6975
- if (vnode_isMaterialized(vnode) || materialize) {
6793
+ if (vnode_isMaterialized(vnode) || materialize2) {
6976
6794
  const child = vnode_getFirstChild(vnode);
6977
6795
  child && strings.push(" " + vnode_toString.call(child, depth - 1, offset + " ", true, true));
6978
6796
  } else {
@@ -6993,19 +6811,9 @@ var stack = [];
6993
6811
 
6994
6812
  function materializeFromVNodeData(vParent, vData, element, child) {
6995
6813
  let idx = 0;
6996
- let nextToConsumeIdx = 0;
6997
6814
  let vFirst = null;
6998
6815
  let vLast = null;
6999
6816
  let previousTextNode = null;
7000
- let ch = 0;
7001
- let peekCh = 0;
7002
- const peek = () => 0 !== peekCh ? peekCh : peekCh = nextToConsumeIdx < vData.length ? vData.charCodeAt(nextToConsumeIdx) : 0;
7003
- const consume = () => {
7004
- ch = peek();
7005
- peekCh = 0;
7006
- nextToConsumeIdx++;
7007
- return ch;
7008
- };
7009
6817
  const addVNode = node => {
7010
6818
  node[0] = 255 & node[0] | idx << 8;
7011
6819
  idx++;
@@ -7015,22 +6823,16 @@ function materializeFromVNodeData(vParent, vData, element, child) {
7015
6823
  vFirst || (vParent[4] = vFirst = node);
7016
6824
  vLast = node;
7017
6825
  };
7018
- const consumeValue = () => {
7019
- consume();
7020
- const start = nextToConsumeIdx;
7021
- while (peek() <= 58 && 0 !== peekCh || 95 === peekCh || peekCh >= 65 && peekCh <= 90 || peekCh >= 97 && peekCh <= 122) {
7022
- consume();
7023
- }
7024
- return vData.substring(start, nextToConsumeIdx);
7025
- };
7026
6826
  let textIdx = 0;
7027
6827
  let combinedText = null;
7028
6828
  let container = null;
7029
- while (0 !== peek()) {
6829
+ processVNodeData(vData, ((peek, consumeValue, consume, nextToConsumeIdx) => {
7030
6830
  if (isNumber(peek())) {
7031
6831
  while (!isElement(child)) {
7032
6832
  child = fastNextSibling(child);
7033
- child || throwErrorAndStop("Materialize error: missing element: " + vData + " " + peek() + " " + nextToConsumeIdx);
6833
+ if (!child) {
6834
+ throw qError(44, [ vData, peek(), nextToConsumeIdx ]);
6835
+ }
7034
6836
  }
7035
6837
  while (isQStyleElement(child)) {
7036
6838
  child = fastNextSibling(child);
@@ -7065,6 +6867,8 @@ function materializeFromVNodeData(vParent, vData, element, child) {
7065
6867
  vnode_setAttr(null, vParent, ELEMENT_SEQ, consumeValue());
7066
6868
  } else if (peek() === VNodeDataChar.SEQ_IDX) {
7067
6869
  vnode_setAttr(null, vParent, ELEMENT_SEQ_IDX, consumeValue());
6870
+ } else if (peek() === VNodeDataChar.SUBS) {
6871
+ vnode_setProp(vParent, QSubscribers, consumeValue());
7068
6872
  } else if (peek() === VNodeDataChar.CONTEXT) {
7069
6873
  vnode_setAttr(null, vParent, QCtxAttr, consumeValue());
7070
6874
  } else if (peek() === VNodeDataChar.OPEN) {
@@ -7104,7 +6908,7 @@ function materializeFromVNodeData(vParent, vData, element, child) {
7104
6908
  addVNode(previousTextNode = vnode_newSharedText(previousTextNode, textNode, text));
7105
6909
  textIdx += length;
7106
6910
  }
7107
- }
6911
+ }));
7108
6912
  vParent[5] = vLast;
7109
6913
  return vFirst;
7110
6914
  }
@@ -7120,447 +6924,642 @@ var vnode_getType = vnode => {
7120
6924
  if (4 & type) {
7121
6925
  return 3;
7122
6926
  }
7123
- throw throwErrorAndStop("Unknown vnode type: " + type);
6927
+ throw qError(43, [ type ]);
6928
+ };
6929
+
6930
+ var isElement = node => node && "object" == typeof node && 1 === fastNodeType(node);
6931
+
6932
+ var aPath = [];
6933
+
6934
+ var bPath = [];
6935
+
6936
+ var vnode_documentPosition = (a, b, rootVNode) => {
6937
+ if (a === b) {
6938
+ return 0;
6939
+ }
6940
+ let aDepth = -1;
6941
+ let bDepth = -1;
6942
+ while (a) {
6943
+ const vNode = aPath[++aDepth] = a;
6944
+ a = vNode[1] || rootVNode && vnode_getProp(a, QSlotParent, (id => vnode_locate(rootVNode, id)));
6945
+ }
6946
+ while (b) {
6947
+ const vNode = bPath[++bDepth] = b;
6948
+ b = vNode[1] || rootVNode && vnode_getProp(b, QSlotParent, (id => vnode_locate(rootVNode, id)));
6949
+ }
6950
+ while (aDepth >= 0 && bDepth >= 0) {
6951
+ a = aPath[aDepth];
6952
+ b = bPath[bDepth];
6953
+ if (a !== b) {
6954
+ let cursor = b;
6955
+ do {
6956
+ cursor = vnode_getNextSibling(cursor);
6957
+ if (cursor === a) {
6958
+ return 1;
6959
+ }
6960
+ } while (cursor);
6961
+ cursor = b;
6962
+ do {
6963
+ cursor = vnode_getPreviousSibling(cursor);
6964
+ if (cursor === a) {
6965
+ return -1;
6966
+ }
6967
+ } while (cursor);
6968
+ if (rootVNode && vnode_getProp(b, QSlotParent, (id => vnode_locate(rootVNode, id)))) {
6969
+ return -1;
6970
+ }
6971
+ return 1;
6972
+ }
6973
+ aDepth--;
6974
+ bDepth--;
6975
+ }
6976
+ return aDepth < bDepth ? -1 : 1;
6977
+ };
6978
+
6979
+ var vnode_getProjectionParentComponent = (vHost, rootVNode) => {
6980
+ let projectionDepth = 1;
6981
+ while (projectionDepth--) {
6982
+ while (vHost && (!vnode_isVirtualVNode(vHost) || null === vnode_getProp(vHost, OnRenderProp, null))) {
6983
+ const qSlotParent = vnode_getProp(vHost, QSlotParent, (id => vnode_locate(rootVNode, id)));
6984
+ const vProjectionParent = vnode_isVirtualVNode(vHost) && qSlotParent;
6985
+ vProjectionParent && projectionDepth++;
6986
+ vHost = vProjectionParent || vnode_getParent(vHost);
6987
+ }
6988
+ projectionDepth > 0 && (vHost = vnode_getParent(vHost));
6989
+ }
6990
+ return vHost;
6991
+ };
6992
+
6993
+ var VNodeArray = class VNode extends Array {
6994
+ static createElement(flags, parent, previousSibling, nextSibling, firstChild, lastChild, element, elementName) {
6995
+ const vnode = new VNode(flags, parent, previousSibling, nextSibling);
6996
+ vnode.push(firstChild, lastChild, element, elementName);
6997
+ return vnode;
6998
+ }
6999
+ static createText(flags, parent, previousSibling, nextSibling, textNode, text) {
7000
+ const vnode = new VNode(flags, parent, previousSibling, nextSibling);
7001
+ vnode.push(textNode, text);
7002
+ return vnode;
7003
+ }
7004
+ static createVirtual(flags, parent, previousSibling, nextSibling, firstChild, lastChild) {
7005
+ const vnode = new VNode(flags, parent, previousSibling, nextSibling);
7006
+ vnode.push(firstChild, lastChild);
7007
+ return vnode;
7008
+ }
7009
+ constructor(flags, parent, previousSibling, nextSibling) {
7010
+ super();
7011
+ this.push(flags, parent, previousSibling, nextSibling);
7012
+ isDev && (this.toString = vnode_toString);
7013
+ }
7014
+ };
7015
+
7016
+ var _context;
7017
+
7018
+ var tryGetInvokeContext = () => {
7019
+ if (!_context) {
7020
+ const context = "undefined" !== typeof document && document && document.__q_context__;
7021
+ if (!context) {
7022
+ return;
7023
+ }
7024
+ if (isArray(context)) {
7025
+ return document.__q_context__ = newInvokeContextFromTuple(context);
7026
+ }
7027
+ return context;
7028
+ }
7029
+ return _context;
7030
+ };
7031
+
7032
+ function invoke(context, fn, ...args) {
7033
+ return invokeApply.call(this, context, fn, args);
7034
+ }
7035
+
7036
+ function invokeApply(context, fn, args) {
7037
+ const previousContext = _context;
7038
+ let returnValue;
7039
+ try {
7040
+ _context = context;
7041
+ returnValue = fn.apply(this, args);
7042
+ } finally {
7043
+ _context = previousContext;
7044
+ }
7045
+ return returnValue;
7046
+ }
7047
+
7048
+ var newInvokeContextFromTuple = ([element, event, url]) => {
7049
+ const container = element.closest(QContainerSelector);
7050
+ const locale = container?.getAttribute(QLocaleAttr) || void 0;
7051
+ locale && setLocale(locale);
7052
+ return newInvokeContext(locale, void 0, element, event, url);
7053
+ };
7054
+
7055
+ var newInvokeContext = (locale, hostElement, element, event, url) => {
7056
+ const $locale$ = locale || ("object" === typeof event && event && "locale" in event ? event.locale : void 0);
7057
+ const ctx = {
7058
+ $url$: url,
7059
+ $i$: 0,
7060
+ $hostElement$: hostElement,
7061
+ $element$: element,
7062
+ $event$: event,
7063
+ $qrl$: void 0,
7064
+ $effectSubscriber$: void 0,
7065
+ $locale$: $locale$,
7066
+ $container$: void 0
7067
+ };
7068
+ seal(ctx);
7069
+ return ctx;
7070
+ };
7071
+
7072
+ var untrack = fn => invoke(void 0, fn);
7073
+
7074
+ var trackInvocation = newInvokeContext(void 0, void 0, void 0, RenderEvent);
7075
+
7076
+ var trackSignal = (fn, subscriber, property, container, data) => {
7077
+ const previousSubscriber = trackInvocation.$effectSubscriber$;
7078
+ const previousContainer = trackInvocation.$container$;
7079
+ try {
7080
+ trackInvocation.$effectSubscriber$ = [ subscriber, property ];
7081
+ data && trackInvocation.$effectSubscriber$.push(data);
7082
+ trackInvocation.$container$ = container;
7083
+ return invoke(trackInvocation, fn);
7084
+ } finally {
7085
+ trackInvocation.$effectSubscriber$ = previousSubscriber;
7086
+ trackInvocation.$container$ = previousContainer;
7087
+ }
7124
7088
  };
7125
7089
 
7126
- var isElement = node => node && "object" == typeof node && 1 === fastNodeType(node);
7090
+ var trackSignalAndAssignHost = (value, host, property, container, data) => {
7091
+ value instanceof WrappedSignal && value.$hostElement$ !== host && host && (value.$hostElement$ = host);
7092
+ return trackSignal((() => value.value), host, property, container, data);
7093
+ };
7127
7094
 
7128
- var aPath = [];
7095
+ var createContextId = name => {
7096
+ assertTrue(/^[\w/.-]+$/.test(name), "Context name must only contain A-Z,a-z,0-9, _", name);
7097
+ return Object.freeze({
7098
+ id: fromCamelToKebabCase(name)
7099
+ });
7100
+ };
7129
7101
 
7130
- var bPath = [];
7102
+ var ERROR_CONTEXT = createContextId("qk-error");
7131
7103
 
7132
- var vnode_documentPosition = (a, b) => {
7133
- if (a === b) {
7134
- return 0;
7135
- }
7136
- let aDepth = -1;
7137
- let bDepth = -1;
7138
- while (a) {
7139
- a = (aPath[++aDepth] = a)[1];
7140
- }
7141
- while (b) {
7142
- b = (bPath[++bDepth] = b)[1];
7143
- }
7144
- while (aDepth >= 0 && bDepth >= 0) {
7145
- a = aPath[aDepth];
7146
- b = bPath[bDepth];
7147
- if (a !== b) {
7148
- let cursor = b;
7149
- do {
7150
- cursor = vnode_getNextSibling(cursor);
7151
- if (cursor === a) {
7152
- return 1;
7153
- }
7154
- } while (cursor);
7155
- cursor = b;
7156
- do {
7157
- cursor = vnode_getPreviousSibling(cursor);
7158
- if (cursor === a) {
7159
- return -1;
7160
- }
7161
- } while (cursor);
7162
- return 1;
7163
- }
7164
- aDepth--;
7165
- bDepth--;
7104
+ var isRecoverable = err => {
7105
+ if (err && err instanceof Error && "plugin" in err) {
7106
+ return false;
7166
7107
  }
7167
- return aDepth < bDepth ? -1 : 1;
7108
+ return true;
7168
7109
  };
7169
7110
 
7170
- var vnode_getProjectionParentComponent = (vHost, rootVNode) => {
7171
- let projectionDepth = 1;
7172
- while (projectionDepth--) {
7173
- while (vHost && (!vnode_isVirtualVNode(vHost) || null === vnode_getProp(vHost, OnRenderProp, null))) {
7174
- const qSlotParentProp = vnode_getProp(vHost, QSlotParent, null);
7175
- const qSlotParent = qSlotParentProp && ("string" === typeof qSlotParentProp ? vnode_locate(rootVNode, qSlotParentProp) : qSlotParentProp);
7176
- const vProjectionParent = vnode_isVirtualVNode(vHost) && qSlotParent;
7177
- vProjectionParent && projectionDepth++;
7178
- vHost = vProjectionParent || vnode_getParent(vHost);
7111
+ function processVNodeData2(document2) {
7112
+ const Q_CONTAINER = "q:container";
7113
+ const Q_CONTAINER_END = "/" + Q_CONTAINER;
7114
+ const Q_PROPS_SEPARATOR2 = ":";
7115
+ const Q_SHADOW_ROOT = "q:shadowroot";
7116
+ const Q_IGNORE = "q:ignore";
7117
+ const Q_IGNORE_END = "/" + Q_IGNORE;
7118
+ const Q_CONTAINER_ISLAND = "q:container-island";
7119
+ const Q_CONTAINER_ISLAND_END = "/" + Q_CONTAINER_ISLAND;
7120
+ const qDocument = document2;
7121
+ const vNodeDataMap = qDocument.qVNodeData || (qDocument.qVNodeData = new WeakMap);
7122
+ const prototype = document2.body;
7123
+ const getter = (prototype2, name) => {
7124
+ let getter2;
7125
+ while (prototype2 && !(getter2 = Object.getOwnPropertyDescriptor(prototype2, name)?.get)) {
7126
+ prototype2 = Object.getPrototypeOf(prototype2);
7179
7127
  }
7180
- projectionDepth > 0 && (vHost = vnode_getParent(vHost));
7181
- }
7182
- return vHost;
7183
- };
7128
+ return getter2 || function() {
7129
+ return this[name];
7130
+ };
7131
+ };
7132
+ const getAttribute = prototype.getAttribute;
7133
+ const hasAttribute = prototype.hasAttribute;
7134
+ const getNodeType = getter(prototype, "nodeType");
7135
+ const attachVnodeDataAndRefs = element => {
7136
+ Array.from(element.querySelectorAll('script[type="qwik/vnode"]')).forEach((script => {
7137
+ script.setAttribute("type", "x-qwik/vnode");
7138
+ const qContainerElement = script.closest("[q\\:container]");
7139
+ qContainerElement.qVnodeData = script.textContent;
7140
+ qContainerElement.qVNodeRefs = new Map;
7141
+ }));
7142
+ element.querySelectorAll("[q\\:shadowroot]").forEach((parent => {
7143
+ const shadowRoot = parent.shadowRoot;
7144
+ shadowRoot && attachVnodeDataAndRefs(shadowRoot);
7145
+ }));
7146
+ };
7147
+ attachVnodeDataAndRefs(document2);
7148
+ let NodeType;
7149
+ (NodeType2 => {
7150
+ NodeType2[NodeType2.CONTAINER_MASK = 1] = "CONTAINER_MASK";
7151
+ NodeType2[NodeType2.ELEMENT = 2] = "ELEMENT";
7152
+ NodeType2[NodeType2.ELEMENT_CONTAINER = 3] = "ELEMENT_CONTAINER";
7153
+ NodeType2[NodeType2.ELEMENT_SHADOW_ROOT = 6] = "ELEMENT_SHADOW_ROOT";
7154
+ NodeType2[NodeType2.COMMENT_SKIP_START = 5] = "COMMENT_SKIP_START";
7155
+ NodeType2[NodeType2.COMMENT_SKIP_END = 8] = "COMMENT_SKIP_END";
7156
+ NodeType2[NodeType2.COMMENT_IGNORE_START = 16] = "COMMENT_IGNORE_START";
7157
+ NodeType2[NodeType2.COMMENT_IGNORE_END = 32] = "COMMENT_IGNORE_END";
7158
+ NodeType2[NodeType2.COMMENT_ISLAND_START = 65] = "COMMENT_ISLAND_START";
7159
+ NodeType2[NodeType2.COMMENT_ISLAND_END = 128] = "COMMENT_ISLAND_END";
7160
+ NodeType2[NodeType2.OTHER = 0] = "OTHER";
7161
+ })(NodeType || (NodeType = {}));
7162
+ const getFastNodeType = node => {
7163
+ const nodeType = getNodeType.call(node);
7164
+ if (1 === nodeType) {
7165
+ const qContainer = getAttribute.call(node, Q_CONTAINER);
7166
+ if (null === qContainer) {
7167
+ if (hasAttribute.call(node, Q_SHADOW_ROOT)) {
7168
+ return 6;
7169
+ }
7170
+ const isQElement = hasAttribute.call(node, Q_PROPS_SEPARATOR2);
7171
+ return isQElement ? 2 : 0;
7172
+ }
7173
+ return 3;
7174
+ }
7175
+ if (8 === nodeType) {
7176
+ const nodeValue = node.nodeValue || "";
7177
+ if (nodeValue.startsWith(Q_CONTAINER_ISLAND)) {
7178
+ return 65;
7179
+ }
7180
+ if (nodeValue.startsWith(Q_IGNORE)) {
7181
+ return 16;
7182
+ }
7183
+ if (nodeValue.startsWith(Q_CONTAINER)) {
7184
+ return 5;
7185
+ }
7186
+ if (nodeValue.startsWith(Q_CONTAINER_ISLAND_END)) {
7187
+ return 128;
7188
+ }
7189
+ if (nodeValue.startsWith(Q_IGNORE_END)) {
7190
+ return 32;
7191
+ }
7192
+ if (nodeValue.startsWith(Q_CONTAINER_END)) {
7193
+ return 8;
7194
+ }
7195
+ }
7196
+ return 0;
7197
+ };
7198
+ const isSeparator = ch => VNodeDataSeparator.ADVANCE_1 <= ch && ch <= VNodeDataSeparator.ADVANCE_8192;
7199
+ const findVDataSectionEnd = (vData, start, end) => {
7200
+ let depth = 0;
7201
+ while (true) {
7202
+ if (!(start < end)) {
7203
+ break;
7204
+ }
7205
+ {
7206
+ const ch = vData.charCodeAt(start);
7207
+ if (0 === depth && isSeparator(ch)) {
7208
+ break;
7209
+ }
7210
+ ch === VNodeDataChar.OPEN ? depth++ : ch === VNodeDataChar.CLOSE && depth--;
7211
+ start++;
7212
+ }
7213
+ }
7214
+ return start;
7215
+ };
7216
+ const nextSibling = node => {
7217
+ while (node && (node = node.nextSibling) && 0 === getFastNodeType(node)) {}
7218
+ return node;
7219
+ };
7220
+ const firstChild = node => {
7221
+ while (node && (node = node.firstChild) && 0 === getFastNodeType(node)) {}
7222
+ return node;
7223
+ };
7224
+ const walkContainer = (walker2, containerNode, node, exitNode, vData, qVNodeRefs, prefix) => {
7225
+ const vData_length = vData.length;
7226
+ let elementIdx = 0;
7227
+ let vNodeElementIndex = -1;
7228
+ let vData_start = 0;
7229
+ let vData_end = 0;
7230
+ let ch = 0;
7231
+ let needsToStoreRef = -1;
7232
+ let nextNode = null;
7233
+ const howManyElementsToSkip = () => {
7234
+ let elementsToSkip = 0;
7235
+ while (isSeparator(ch = vData.charCodeAt(vData_start))) {
7236
+ elementsToSkip += 1 << ch - VNodeDataSeparator.ADVANCE_1;
7237
+ vData_start++;
7238
+ if (vData_start >= vData_length) {
7239
+ break;
7240
+ }
7241
+ }
7242
+ return elementsToSkip;
7243
+ };
7244
+ do {
7245
+ if (node === exitNode) {
7246
+ return;
7247
+ }
7248
+ nextNode = null;
7249
+ const nodeType = node == containerNode ? 2 : getFastNodeType(node);
7250
+ if (3 === nodeType) {
7251
+ const container = node;
7252
+ let cursor = node;
7253
+ while (cursor && !(nextNode = nextSibling(cursor))) {
7254
+ cursor = cursor.parentNode;
7255
+ }
7256
+ walkContainer(walker2, container, node, nextNode, container.qVnodeData || "", container.qVNodeRefs, prefix + " ");
7257
+ } else if (16 === nodeType) {
7258
+ let islandNode = node;
7259
+ do {
7260
+ islandNode = walker2.nextNode();
7261
+ if (!islandNode) {
7262
+ throw new Error(`Island inside \x3c!--${node?.nodeValue}--\x3e not found!`);
7263
+ }
7264
+ } while (65 !== getFastNodeType(islandNode));
7265
+ nextNode = null;
7266
+ } else if (128 === nodeType) {
7267
+ nextNode = node;
7268
+ do {
7269
+ nextNode = walker2.nextNode();
7270
+ if (!nextNode) {
7271
+ throw new Error("Ignore block not closed!");
7272
+ }
7273
+ } while (32 !== getFastNodeType(nextNode));
7274
+ nextNode = null;
7275
+ } else if (5 === nodeType) {
7276
+ nextNode = node;
7277
+ do {
7278
+ nextNode = nextSibling(nextNode);
7279
+ if (!nextNode) {
7280
+ throw new Error(`\x3c!--${node?.nodeValue}--\x3e not closed!`);
7281
+ }
7282
+ } while (8 !== getFastNodeType(nextNode));
7283
+ walkContainer(walker2, node, node, nextNode, "", null, prefix + " ");
7284
+ } else if (6 === nodeType) {
7285
+ nextNode = nextSibling(node);
7286
+ const shadowRootContainer = node;
7287
+ const shadowRoot = shadowRootContainer?.shadowRoot;
7288
+ shadowRoot && walkContainer(document2.createTreeWalker(shadowRoot, 129), null, firstChild(shadowRoot), null, "", null, prefix + " ");
7289
+ }
7290
+ if (2 === (2 & nodeType)) {
7291
+ if (vNodeElementIndex < elementIdx) {
7292
+ -1 === vNodeElementIndex && (vNodeElementIndex = 0);
7293
+ vData_start = vData_end;
7294
+ if (vData_start < vData_length) {
7295
+ vNodeElementIndex += howManyElementsToSkip();
7296
+ const shouldStoreRef = ch === VNodeDataSeparator.REFERENCE;
7297
+ if (shouldStoreRef) {
7298
+ needsToStoreRef = vNodeElementIndex;
7299
+ vData_start++;
7300
+ ch = vData_start < vData_length ? vData.charCodeAt(vData_end) : VNodeDataSeparator.ADVANCE_1;
7301
+ }
7302
+ vData_end = findVDataSectionEnd(vData, vData_start, vData_length);
7303
+ } else {
7304
+ vNodeElementIndex = Number.MAX_SAFE_INTEGER;
7305
+ }
7306
+ }
7307
+ if (elementIdx === vNodeElementIndex) {
7308
+ needsToStoreRef === elementIdx && qVNodeRefs.set(elementIdx, node);
7309
+ const instructions = vData.substring(vData_start, vData_end);
7310
+ vNodeDataMap.set(node, instructions);
7311
+ }
7312
+ elementIdx++;
7313
+ }
7314
+ } while (node = nextNode || walker2.nextNode());
7315
+ };
7316
+ const walker = document2.createTreeWalker(document2, 129);
7317
+ walkContainer(walker, null, walker.firstChild(), null, "", null, "");
7318
+ }
7184
7319
 
7185
- var VNodeArray = class VNode extends Array {
7186
- static createElement(flags, parent, previousSibling, nextSibling, firstChild, lastChild, element, elementName) {
7187
- const vnode = new VNode(flags, parent, previousSibling, nextSibling);
7188
- vnode.push(firstChild, lastChild, element, elementName);
7189
- return vnode;
7190
- }
7191
- static createText(flags, parent, previousSibling, nextSibling, textNode, text) {
7192
- const vnode = new VNode(flags, parent, previousSibling, nextSibling);
7193
- vnode.push(textNode, text);
7194
- return vnode;
7195
- }
7196
- static createVirtual(flags, parent, previousSibling, nextSibling, firstChild, lastChild) {
7197
- const vnode = new VNode(flags, parent, previousSibling, nextSibling);
7198
- vnode.push(firstChild, lastChild);
7199
- return vnode;
7200
- }
7201
- constructor(flags, parent, previousSibling, nextSibling) {
7202
- super();
7203
- this.push(flags, parent, previousSibling, nextSibling);
7204
- isDev && (this.toString = vnode_toString);
7320
+ function getDomContainer(element) {
7321
+ const qContainerElement = _getQContainerElement(element);
7322
+ if (!qContainerElement) {
7323
+ throw qError(41);
7205
7324
  }
7206
- };
7207
-
7208
- var _context;
7325
+ return getDomContainerFromQContainerElement(qContainerElement);
7326
+ }
7209
7327
 
7210
- var tryGetInvokeContext = () => {
7211
- if (!_context) {
7212
- const context = "undefined" !== typeof document && document && document.__q_context__;
7213
- if (!context) {
7214
- return;
7215
- }
7216
- if (isArray(context)) {
7217
- return document.__q_context__ = newInvokeContextFromTuple(context);
7328
+ function getDomContainerFromQContainerElement(qContainerElement) {
7329
+ const qElement = qContainerElement;
7330
+ let container = qElement.qContainer;
7331
+ if (!container) {
7332
+ container = new DomContainer(qElement);
7333
+ const containerAttributes = {};
7334
+ if (qElement) {
7335
+ const attrs = qElement.attributes;
7336
+ if (attrs) {
7337
+ for (let index = 0; index < attrs.length; index++) {
7338
+ const attr = attrs[index];
7339
+ if (attr.name === Q_PROPS_SEPARATOR) {
7340
+ continue;
7341
+ }
7342
+ containerAttributes[attr.name] = attr.value;
7343
+ }
7344
+ }
7218
7345
  }
7219
- return context;
7220
- }
7221
- return _context;
7222
- };
7223
-
7224
- var useInvokeContext = () => {
7225
- const ctx = tryGetInvokeContext();
7226
- if (!ctx || ctx.$event$ !== RenderEvent) {
7227
- throw qError(QError_useInvokeContext);
7346
+ container.$serverData$ = {
7347
+ containerAttributes: containerAttributes
7348
+ };
7349
+ qElement.setAttribute(QContainerAttr, "resumed");
7350
+ qElement.qContainer = container;
7228
7351
  }
7229
- assertDefined(ctx.$hostElement$, "invoke: $hostElement$ must be defined", ctx);
7230
- assertDefined(ctx.$effectSubscriber$, "invoke: $effectSubscriber$ must be defined", ctx);
7231
- return ctx;
7232
- };
7233
-
7234
- function invoke(context, fn, ...args) {
7235
- return invokeApply.call(this, context, fn, args);
7352
+ return container;
7236
7353
  }
7237
7354
 
7238
- function invokeApply(context, fn, args) {
7239
- const previousContext = _context;
7240
- let returnValue;
7241
- try {
7242
- _context = context;
7243
- returnValue = fn.apply(this, args);
7244
- } finally {
7245
- _context = previousContext;
7246
- }
7247
- return returnValue;
7355
+ function _getQContainerElement(element) {
7356
+ const qContainerElement = Array.isArray(element) ? vnode_getDomParent(element) : element;
7357
+ return qContainerElement.closest(QContainerSelector);
7248
7358
  }
7249
7359
 
7250
- var newInvokeContextFromTuple = ([element, event, url]) => {
7251
- const container = element.closest(QContainerSelector);
7252
- const locale = container?.getAttribute(QLocaleAttr) || void 0;
7253
- locale && setLocale(locale);
7254
- return newInvokeContext(locale, void 0, element, event, url);
7255
- };
7256
-
7257
- var newInvokeContext = (locale, hostElement, element, event, url) => {
7258
- const $locale$ = locale || ("object" === typeof event && event && "locale" in event ? event.locale : void 0);
7259
- const ctx = {
7260
- $url$: url,
7261
- $i$: 0,
7262
- $hostElement$: hostElement,
7263
- $element$: element,
7264
- $event$: event,
7265
- $qrl$: void 0,
7266
- $effectSubscriber$: void 0,
7267
- $locale$: $locale$,
7268
- $container$: void 0
7269
- };
7270
- seal(ctx);
7271
- return ctx;
7272
- };
7273
-
7274
- var untrack = fn => invoke(void 0, fn);
7275
-
7276
- var trackInvocation = newInvokeContext(void 0, void 0, void 0, RenderEvent);
7277
-
7278
- var trackSignal = (fn, subscriber, property, container, data) => {
7279
- const previousSubscriber = trackInvocation.$effectSubscriber$;
7280
- const previousContainer = trackInvocation.$container$;
7281
- try {
7282
- trackInvocation.$effectSubscriber$ = [ subscriber, property ];
7283
- data && trackInvocation.$effectSubscriber$.push(data);
7284
- trackInvocation.$container$ = container;
7285
- return invoke(trackInvocation, fn);
7286
- } finally {
7287
- trackInvocation.$effectSubscriber$ = previousSubscriber;
7288
- trackInvocation.$container$ = previousContainer;
7289
- }
7290
- };
7291
-
7292
- var _jsxSorted = (type, varProps, constProps, children, flags, key, dev) => {
7293
- const processed = null == key ? null : String(key);
7294
- const node = new JSXNodeImpl(type, varProps || {}, constProps || null, children, flags, processed);
7295
- qDev && dev && (node.dev = {
7296
- stack: (new Error).stack,
7297
- ...dev
7298
- });
7299
- seal(node);
7300
- return node;
7301
- };
7360
+ var isDomContainer = container => container instanceof DomContainer;
7302
7361
 
7303
- var _jsxSplit = (type, varProps, constProps, children, flags, key, dev) => {
7304
- let sortedProps;
7305
- sortedProps = varProps ? Object.fromEntries(untrack((() => Object.entries(varProps))).filter((entry => {
7306
- const attr = entry[0];
7307
- if ("children" === attr) {
7308
- children ?? (children = entry[1]);
7309
- return false;
7362
+ var DomContainer = class extends _SharedContainer {
7363
+ constructor(element) {
7364
+ super((() => this.scheduleRender()), (() => vnode_applyJournal(this.$journal$)), {}, element.getAttribute("q:locale"));
7365
+ __publicField(this, "element");
7366
+ __publicField(this, "qContainer");
7367
+ __publicField(this, "qBase");
7368
+ __publicField(this, "qManifestHash");
7369
+ __publicField(this, "rootVNode");
7370
+ __publicField(this, "document");
7371
+ __publicField(this, "$journal$");
7372
+ __publicField(this, "renderDone", null);
7373
+ __publicField(this, "$rawStateData$");
7374
+ __publicField(this, "$storeProxyMap$", new WeakMap);
7375
+ __publicField(this, "$qFuncs$");
7376
+ __publicField(this, "$instanceHash$");
7377
+ __publicField(this, "stateData");
7378
+ __publicField(this, "$styleIds$", null);
7379
+ __publicField(this, "$vnodeLocate$", (id => vnode_locate(this.rootVNode, id)));
7380
+ __publicField(this, "$renderCount$", 0);
7381
+ __publicField(this, "$getObjectById$", (id => {
7382
+ "string" === typeof id && (id = parseFloat(id));
7383
+ assertTrue(id < this.$rawStateData$.length / 2, `Invalid reference: ${id} >= ${this.$rawStateData$.length / 2}`);
7384
+ return this.stateData[id];
7385
+ }));
7386
+ this.qContainer = element.getAttribute(QContainerAttr);
7387
+ if (!this.qContainer) {
7388
+ throw qError(42);
7310
7389
  }
7311
- if ("key" === attr) {
7312
- key = entry[1];
7313
- return false;
7390
+ this.$journal$ = [ 3, element.ownerDocument ];
7391
+ this.document = element.ownerDocument;
7392
+ this.element = element;
7393
+ this.qBase = element.getAttribute(QBaseAttr);
7394
+ this.$instanceHash$ = element.getAttribute(QInstanceAttr);
7395
+ this.qManifestHash = element.getAttribute("q:manifest-hash");
7396
+ this.rootVNode = vnode_newUnMaterializedElement(this.element);
7397
+ this.$rawStateData$ = null;
7398
+ this.stateData = null;
7399
+ const document2 = this.element.ownerDocument;
7400
+ document2.qVNodeData || processVNodeData2(document2);
7401
+ this.$rawStateData$ = [];
7402
+ this.stateData = [];
7403
+ const qwikStates = element.querySelectorAll('script[type="qwik/state"]');
7404
+ if (0 !== qwikStates.length) {
7405
+ const lastState = qwikStates[qwikStates.length - 1];
7406
+ this.$rawStateData$ = JSON.parse(lastState.textContent);
7407
+ this.stateData = wrapDeserializerProxy(this, this.$rawStateData$);
7314
7408
  }
7315
- return !constProps || !(attr in constProps) || /^on[A-Z].*\$$/.test(attr);
7316
- })).sort((([a], [b]) => a < b ? -1 : 1))) : "string" === typeof type ? EMPTY_OBJ : {};
7317
- if (constProps && "children" in constProps) {
7318
- children = constProps.children;
7319
- constProps.children = void 0;
7409
+ this.$qFuncs$ = getQFuncs(document2, this.$instanceHash$) || EMPTY_ARRAY;
7320
7410
  }
7321
- return _jsxSorted(type, sortedProps, constProps, children, flags, key, dev);
7322
- };
7323
-
7324
- var isPropsProxy = obj => obj && void 0 !== obj[_VAR_PROPS];
7325
-
7326
- var JSXNodeImpl = class {
7327
- constructor(type, varProps, constProps, children, flags, key = null) {
7328
- this.type = type;
7329
- this.varProps = varProps;
7330
- this.constProps = constProps;
7331
- this.children = children;
7332
- this.flags = flags;
7333
- this.key = key;
7334
- __publicField(this, "dev");
7335
- __publicField(this, "_proxy", null);
7336
- if (qDev) {
7337
- if ("object" !== typeof varProps) {
7338
- throw new Error("JSXNodeImpl: varProps must be objects: " + JSON.stringify(varProps));
7339
- }
7340
- if ("object" !== typeof constProps) {
7341
- throw new Error("JSXNodeImpl: constProps must be objects: " + JSON.stringify(constProps));
7342
- }
7343
- }
7411
+ $setRawState$(id, vParent) {
7412
+ this.stateData[id] = vParent;
7344
7413
  }
7345
- get props() {
7346
- this._proxy || (this._proxy = createPropsProxy(this.varProps, this.constProps, this.children));
7347
- return this._proxy;
7414
+ parseQRL(qrl) {
7415
+ return inflateQRL(this, parseQRL(qrl));
7348
7416
  }
7349
- };
7350
-
7351
- var Virtual = props => props.children;
7352
-
7353
- var isJSXNode = n => {
7354
- if (qDev) {
7355
- if (n instanceof JSXNodeImpl) {
7356
- return true;
7417
+ handleError(err, host) {
7418
+ if (qDev) {
7419
+ if ("undefined" !== typeof document) {
7420
+ const vHost = host;
7421
+ const errorDiv = document.createElement("errored-host");
7422
+ err && err instanceof Error && (errorDiv.props = {
7423
+ error: err
7424
+ });
7425
+ errorDiv.setAttribute("q:key", "_error_");
7426
+ const journal = [];
7427
+ vnode_getDOMChildNodes(journal, vHost).forEach((child => errorDiv.appendChild(child)));
7428
+ const vErrorDiv = vnode_newElement(errorDiv, "error-host");
7429
+ vnode_insertBefore(journal, vHost, vErrorDiv, null);
7430
+ vnode_applyJournal(journal);
7431
+ }
7432
+ err && err instanceof Error && ("hostElement" in err || (err.hostElement = host));
7433
+ if (!isRecoverable(err)) {
7434
+ throw err;
7435
+ }
7357
7436
  }
7358
- if (isObject(n) && "key" in n && "props" in n && "type" in n) {
7359
- logWarn('Duplicate implementations of "JSXNode" found');
7360
- return true;
7437
+ const errorStore = this.resolveContext(host, ERROR_CONTEXT);
7438
+ if (!errorStore) {
7439
+ throw err;
7361
7440
  }
7362
- return false;
7441
+ errorStore.error = err;
7363
7442
  }
7364
- return n instanceof JSXNodeImpl;
7365
- };
7366
-
7367
- var Fragment = props => props.children;
7368
-
7369
- function createPropsProxy(varProps, constProps, children) {
7370
- return new Proxy({}, new PropsProxyHandler(varProps, constProps, children));
7371
- }
7372
-
7373
- var PropsProxyHandler = class {
7374
- constructor($varProps$, $constProps$, $children$) {
7375
- this.$varProps$ = $varProps$;
7376
- this.$constProps$ = $constProps$;
7377
- this.$children$ = $children$;
7443
+ setContext(host, context, value) {
7444
+ let ctx = this.getHostProp(host, QCtxAttr);
7445
+ ctx || this.setHostProp(host, QCtxAttr, ctx = []);
7446
+ mapArray_set(ctx, context.id, value, 0);
7378
7447
  }
7379
- get(_, prop) {
7380
- if (prop === _CONST_PROPS) {
7381
- return this.$constProps$;
7382
- }
7383
- if (prop === _VAR_PROPS) {
7384
- return this.$varProps$;
7385
- }
7386
- if (null != this.$children$ && "children" === prop) {
7387
- return this.$children$;
7448
+ resolveContext(host, contextId) {
7449
+ while (host) {
7450
+ const ctx = this.getHostProp(host, QCtxAttr);
7451
+ if (ctx) {
7452
+ const value = mapArray_get(ctx, contextId.id, 0);
7453
+ if (value) {
7454
+ return value;
7455
+ }
7456
+ }
7457
+ host = this.getParentHost(host);
7388
7458
  }
7389
- const value = this.$constProps$ && prop in this.$constProps$ ? this.$constProps$[prop] : this.$varProps$[prop];
7390
- return value instanceof WrappedSignal ? value.value : value;
7459
+ return;
7391
7460
  }
7392
- set(_, prop, value) {
7393
- if (prop === _CONST_PROPS) {
7394
- this.$constProps$ = value;
7395
- return true;
7396
- }
7397
- if (prop === _VAR_PROPS) {
7398
- this.$varProps$ = value;
7399
- return true;
7461
+ getParentHost(host) {
7462
+ let vNode = vnode_getParent(host);
7463
+ while (vNode) {
7464
+ if (vnode_isVirtualVNode(vNode)) {
7465
+ if (null !== vnode_getProp(vNode, OnRenderProp, null)) {
7466
+ return vNode;
7467
+ }
7468
+ vNode = vnode_getParent(vNode) || vnode_getProp(vNode, QSlotParent, this.$vnodeLocate$);
7469
+ } else {
7470
+ vNode = vnode_getParent(vNode);
7471
+ }
7400
7472
  }
7401
- this.$constProps$ && prop in this.$constProps$ ? this.$constProps$[prop] = value : this.$varProps$[prop] = value;
7402
- return true;
7473
+ return null;
7403
7474
  }
7404
- deleteProperty(_, prop) {
7405
- if ("string" !== typeof prop) {
7406
- return false;
7475
+ setHostProp(host, name, value) {
7476
+ const vNode = host;
7477
+ vnode_setProp(vNode, name, value);
7478
+ }
7479
+ getHostProp(host, name) {
7480
+ const vNode = host;
7481
+ let getObjectById = null;
7482
+ switch (name) {
7483
+ case ELEMENT_SEQ:
7484
+ case ELEMENT_PROPS:
7485
+ case OnRenderProp:
7486
+ case QCtxAttr:
7487
+ case QSubscribers:
7488
+ getObjectById = this.$getObjectById$;
7489
+ break;
7490
+
7491
+ case ELEMENT_SEQ_IDX:
7492
+ case USE_ON_LOCAL_SEQ_IDX:
7493
+ getObjectById = parseInt;
7494
+ break;
7407
7495
  }
7408
- let didDelete = delete this.$varProps$[prop];
7409
- this.$constProps$ && (didDelete = delete this.$constProps$[prop] || didDelete);
7410
- null != this.$children$ && "children" === prop && (this.$children$ = null);
7411
- return didDelete;
7496
+ return vnode_getProp(vNode, name, getObjectById);
7412
7497
  }
7413
- has(_, prop) {
7414
- const hasProp = "children" === prop && null != this.$children$ || prop === _CONST_PROPS || prop === _VAR_PROPS || prop in this.$varProps$ || !!this.$constProps$ && prop in this.$constProps$;
7415
- return hasProp;
7498
+ scheduleRender() {
7499
+ this.$renderCount$++;
7500
+ this.renderDone || (this.renderDone = getPlatform().nextTick((() => this.processChores())));
7501
+ return this.renderDone;
7416
7502
  }
7417
- getOwnPropertyDescriptor(target, p) {
7418
- const value = "children" === p && null != this.$children$ ? this.$children$ : this.$constProps$ && p in this.$constProps$ ? this.$constProps$[p] : this.$varProps$[p];
7419
- return {
7420
- configurable: true,
7421
- enumerable: true,
7422
- value: value
7423
- };
7503
+ processChores() {
7504
+ let renderCount = this.$renderCount$;
7505
+ const result = this.$scheduler$(255);
7506
+ if (isPromise(result)) {
7507
+ return result.then((async () => {
7508
+ while (renderCount !== this.$renderCount$) {
7509
+ renderCount = this.$renderCount$;
7510
+ await this.$scheduler$(255);
7511
+ }
7512
+ this.renderDone = null;
7513
+ }));
7514
+ }
7515
+ if (renderCount !== this.$renderCount$) {
7516
+ this.processChores();
7517
+ return;
7518
+ }
7519
+ this.renderDone = null;
7424
7520
  }
7425
- ownKeys() {
7426
- const out = Object.keys(this.$varProps$);
7427
- null != this.$children$ && -1 === out.indexOf("children") && out.push("children");
7428
- if (this.$constProps$) {
7429
- for (const key in this.$constProps$) {
7430
- -1 === out.indexOf(key) && out.push(key);
7521
+ ensureProjectionResolved(vNode) {
7522
+ if (0 === (16 & vNode[0])) {
7523
+ vNode[0] |= 16;
7524
+ for (let i = vnode_getPropStartIndex(vNode); i < vNode.length; i += 2) {
7525
+ const prop = vNode[i];
7526
+ if (isSlotProp(prop)) {
7527
+ const value = vNode[i + 1];
7528
+ "string" == typeof value && (vNode[i + 1] = this.$vnodeLocate$(value));
7529
+ }
7431
7530
  }
7432
7531
  }
7433
- return out;
7434
7532
  }
7435
- };
7436
-
7437
- var directGetPropsProxyProp = (jsx2, prop) => jsx2.constProps && prop in jsx2.constProps ? jsx2.constProps[prop] : jsx2.varProps[prop];
7438
-
7439
- var componentQrl = componentQrl2 => {
7440
- function QwikComponent(props, key, flags = 0) {
7441
- assertQrl(componentQrl2);
7442
- assertNumber(flags, "The Qwik Component was not invoked correctly");
7443
- const hash = qTest ? "sX" : componentQrl2.$hash$.slice(0, 4);
7444
- const finalKey = hash + ":" + (key || "");
7445
- const InnerCmp = () => {};
7446
- InnerCmp[SERIALIZABLE_STATE] = [ componentQrl2 ];
7447
- return _jsxSplit(InnerCmp, props, null, props.children, flags, finalKey);
7533
+ getSyncFn(id) {
7534
+ const fn = this.$qFuncs$[id];
7535
+ assertTrue("function" === typeof fn, "Invalid reference: " + id);
7536
+ return fn;
7448
7537
  }
7449
- QwikComponent[SERIALIZABLE_STATE] = [ componentQrl2 ];
7450
- return QwikComponent;
7451
- };
7452
-
7453
- var SERIALIZABLE_STATE = Symbol("serializable-data");
7454
-
7455
- var isQwikComponent = component => "function" == typeof component && void 0 !== component[SERIALIZABLE_STATE];
7456
-
7457
- var event$ = implicit$FirstArg(eventQrl);
7458
-
7459
- var rule = 0;
7460
-
7461
- var elementClassIdSelector = 1;
7462
-
7463
- var starSelector = 2;
7464
-
7465
- var pseudoClassWithSelector = 3;
7466
-
7467
- var pseudoClass = 4;
7468
-
7469
- var pseudoGlobal = 5;
7470
-
7471
- var pseudoElement = 6;
7472
-
7473
- var attrSelector = 7;
7474
-
7475
- var inertParenthesis = 8;
7476
-
7477
- var inertBlock = 9;
7478
-
7479
- var atRuleSelector = 10;
7480
-
7481
- var atRuleBlock = 11;
7482
-
7483
- var atRuleInert = 12;
7484
-
7485
- var body = 13;
7486
-
7487
- var stringSingle = 14;
7488
-
7489
- var stringDouble = 15;
7490
-
7491
- var commentMultiline = 16;
7492
-
7493
- var EXIT = 17;
7494
-
7495
- var EXIT_INSERT_SCOPE = 18;
7496
-
7497
- var ANY = 0;
7498
-
7499
- var IDENT = 1;
7500
-
7501
- var NOT_IDENT = 2;
7502
-
7503
- var WHITESPACE = 3;
7504
-
7505
- var DOUBLE_QUOTE = 34;
7506
-
7507
- var HASH = 35;
7508
-
7509
- var SINGLE_QUOTE = 39;
7510
-
7511
- var OPEN_PARENTHESIS = 40;
7512
-
7513
- var CLOSE_PARENTHESIS = 41;
7514
-
7515
- var STAR = 42;
7516
-
7517
- var DOT = 46;
7518
-
7519
- var FORWARD_SLASH = 47;
7520
-
7521
- var COLON = 58;
7522
-
7523
- var SEMICOLON = 59;
7524
-
7525
- var AT = 64;
7526
-
7527
- var OPEN_BRACKET = 91;
7528
-
7529
- var CLOSE_BRACKET = 93;
7530
-
7531
- var OPEN_BRACE = 123;
7532
-
7533
- var CLOSE_BRACE = 125;
7534
-
7535
- var STRINGS_COMMENTS = (() => [ [ ANY, SINGLE_QUOTE, stringSingle ], [ ANY, DOUBLE_QUOTE, stringDouble ], [ ANY, FORWARD_SLASH, commentMultiline, "*" ] ])();
7536
-
7537
- var STATE_MACHINE = (() => [ [ [ ANY, STAR, starSelector ], [ ANY, OPEN_BRACKET, attrSelector ], [ ANY, COLON, pseudoElement, ":", "before", "after", "first-letter", "first-line" ], [ ANY, COLON, pseudoGlobal, "global" ], [ ANY, COLON, pseudoClassWithSelector, "has", "host-context", "not", "where", "is", "matches", "any" ], [ ANY, COLON, pseudoClass ], [ ANY, IDENT, elementClassIdSelector ], [ ANY, DOT, elementClassIdSelector ], [ ANY, HASH, elementClassIdSelector ], [ ANY, AT, atRuleSelector, "keyframe" ], [ ANY, AT, atRuleBlock, "media", "supports", "container" ], [ ANY, AT, atRuleInert ], [ ANY, OPEN_BRACE, body ], [ FORWARD_SLASH, STAR, commentMultiline ], [ ANY, SEMICOLON, EXIT ], [ ANY, CLOSE_BRACE, EXIT ], [ ANY, CLOSE_PARENTHESIS, EXIT ], ...STRINGS_COMMENTS ], [ [ ANY, NOT_IDENT, EXIT_INSERT_SCOPE ] ], [ [ ANY, NOT_IDENT, EXIT_INSERT_SCOPE ] ], [ [ ANY, OPEN_PARENTHESIS, rule ], [ ANY, NOT_IDENT, EXIT_INSERT_SCOPE ] ], [ [ ANY, OPEN_PARENTHESIS, inertParenthesis ], [ ANY, NOT_IDENT, EXIT_INSERT_SCOPE ] ], [ [ ANY, OPEN_PARENTHESIS, rule ], [ ANY, NOT_IDENT, EXIT ] ], [ [ ANY, NOT_IDENT, EXIT ] ], [ [ ANY, CLOSE_BRACKET, EXIT_INSERT_SCOPE ], [ ANY, SINGLE_QUOTE, stringSingle ], [ ANY, DOUBLE_QUOTE, stringDouble ] ], [ [ ANY, CLOSE_PARENTHESIS, EXIT ], ...STRINGS_COMMENTS ], [ [ ANY, CLOSE_BRACE, EXIT ], ...STRINGS_COMMENTS ], [ [ ANY, CLOSE_BRACE, EXIT ], [ WHITESPACE, IDENT, elementClassIdSelector ], [ ANY, COLON, pseudoGlobal, "global" ], [ ANY, OPEN_BRACE, body ], ...STRINGS_COMMENTS ], [ [ ANY, OPEN_BRACE, rule ], [ ANY, SEMICOLON, EXIT ], ...STRINGS_COMMENTS ], [ [ ANY, SEMICOLON, EXIT ], [ ANY, OPEN_BRACE, inertBlock ], ...STRINGS_COMMENTS ], [ [ ANY, CLOSE_BRACE, EXIT ], [ ANY, OPEN_BRACE, body ], [ ANY, OPEN_PARENTHESIS, inertParenthesis ], ...STRINGS_COMMENTS ], [ [ ANY, SINGLE_QUOTE, EXIT ] ], [ [ ANY, DOUBLE_QUOTE, EXIT ] ], [ [ STAR, FORWARD_SLASH, EXIT ] ] ])();
7538
-
7539
- var useComputedQrl = qrl2 => {
7540
- const {val: val, set: set} = useSequentialScope();
7541
- if (val) {
7542
- return val;
7538
+ $appendStyle$(content, styleId, host, scoped) {
7539
+ if (scoped) {
7540
+ const scopedStyleIdsString = this.getHostProp(host, QScopedStyle);
7541
+ const scopedStyleIds = new Set(convertScopedStyleIdsToArray(scopedStyleIdsString));
7542
+ scopedStyleIds.add(styleId);
7543
+ this.setHostProp(host, QScopedStyle, convertStyleIdsToString(scopedStyleIds));
7544
+ }
7545
+ if (null == this.$styleIds$) {
7546
+ this.$styleIds$ = new Set;
7547
+ this.element.querySelectorAll(QStyleSelector).forEach((style => {
7548
+ this.$styleIds$.add(style.getAttribute(QStyle));
7549
+ }));
7550
+ }
7551
+ if (!this.$styleIds$.has(styleId)) {
7552
+ this.$styleIds$.add(styleId);
7553
+ const styleElement = this.document.createElement("style");
7554
+ styleElement.setAttribute(QStyle, styleId);
7555
+ styleElement.textContent = content;
7556
+ this.$journal$.push(5, this.document.head, null, styleElement);
7557
+ }
7543
7558
  }
7544
- assertQrl(qrl2);
7545
- const signal = new ComputedSignal(null, qrl2);
7546
- set(signal);
7547
- throwIfQRLNotResolved(qrl2);
7548
- return signal;
7549
7559
  };
7550
7560
 
7551
- var useComputed$ = implicit$FirstArg(useComputedQrl);
7552
-
7553
- var OPEN_FRAGMENT = Number.MAX_SAFE_INTEGER;
7554
-
7555
- var CLOSE_FRAGMENT = Number.MAX_SAFE_INTEGER - 1;
7556
-
7557
7561
  var deserializedProxyMap = new WeakMap;
7558
7562
 
7559
- var unwrapDeserializerProxy = value => {
7560
- const unwrapped = "object" === typeof value && null !== value && value[SERIALIZER_PROXY_UNWRAP];
7561
- return unwrapped || value;
7562
- };
7563
-
7564
7563
  var isDeserializerProxy = value => "object" === typeof value && null !== value && SERIALIZER_PROXY_UNWRAP in value;
7565
7564
 
7566
7565
  var SERIALIZER_PROXY_UNWRAP = Symbol("UNWRAP");
@@ -7601,11 +7600,11 @@ var DeserializationHandler = class {
7601
7600
  return value;
7602
7601
  }
7603
7602
  const container = this.$container$;
7604
- const propValue = allocate(container, typeId, value);
7603
+ let propValue = allocate(container, typeId, value);
7604
+ typeId >= 12 && (propValue = inflate(container, propValue, typeId, value));
7605
7605
  Reflect.set(target, property, propValue);
7606
7606
  this.$data$[idx] = void 0;
7607
7607
  this.$data$[idx + 1] = propValue;
7608
- typeId >= 12 && inflate(container, propValue, typeId, value);
7609
7608
  return propValue;
7610
7609
  }
7611
7610
  has(target, property) {
@@ -7642,7 +7641,7 @@ var resolvers = new WeakMap;
7642
7641
 
7643
7642
  var inflate = (container, target, typeId, data) => {
7644
7643
  if (void 0 === typeId) {
7645
- return;
7644
+ return target;
7646
7645
  }
7647
7646
  13 !== typeId && Array.isArray(data) && (data = _eagerDeserializeArray(container, data));
7648
7647
  switch (typeId) {
@@ -7709,12 +7708,11 @@ var inflate = (container, target, typeId, data) => {
7709
7708
  case 26:
7710
7709
  {
7711
7710
  const [value, flags, effects2, storeEffect] = data;
7712
- const handler = getStoreHandler(target);
7713
- handler.$flags$ = flags;
7714
- Object.assign(getStoreTarget(target), value);
7711
+ const store = getOrCreateStore(value, flags, container);
7712
+ const storeHandler = getStoreHandler(store);
7715
7713
  storeEffect && (effects2[STORE_ARRAY_PROP] = storeEffect);
7716
- handler.$effects$ = effects2;
7717
- container.$storeProxyMap$.set(value, target);
7714
+ storeHandler.$effects$ = effects2;
7715
+ target = store;
7718
7716
  break;
7719
7717
  }
7720
7718
 
@@ -7735,7 +7733,8 @@ var inflate = (container, target, typeId, data) => {
7735
7733
  signal.$args$ = d[1];
7736
7734
  signal.$effectDependencies$ = d[2];
7737
7735
  signal.$untrackedValue$ = d[3];
7738
- signal.$effects$ = d.slice(4);
7736
+ signal.$hostElement$ = d[4];
7737
+ signal.$effects$ = d.slice(5);
7739
7738
  break;
7740
7739
  }
7741
7740
 
@@ -7841,13 +7840,15 @@ var inflate = (container, target, typeId, data) => {
7841
7840
  case 30:
7842
7841
  {
7843
7842
  const effectData = target;
7844
- effectData.data = data[0];
7843
+ effectData.data.$scopedStyleIdPrefix$ = data[0];
7844
+ effectData.data.$isConst$ = data[1];
7845
7845
  break;
7846
7846
  }
7847
7847
 
7848
7848
  default:
7849
- return throwErrorAndStop("Not implemented");
7849
+ throw qError(33, [ typeId ]);
7850
7850
  }
7851
+ return target;
7851
7852
  };
7852
7853
 
7853
7854
  var _constants = [ void 0, null, true, false, "", 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 ];
@@ -7873,11 +7874,11 @@ var allocate = (container, typeId, value) => {
7873
7874
  return {};
7874
7875
 
7875
7876
  case 18:
7876
- const qrl2 = container.$getObjectById$(value);
7877
- return parseQRL(qrl2);
7877
+ const qrl = container.$getObjectById$(value);
7878
+ return parseQRL(qrl);
7878
7879
 
7879
7880
  case 19:
7880
- return new Task2(-1, -1, null, null, null, null);
7881
+ return new Task(-1, -1, null, null, null, null);
7881
7882
 
7882
7883
  case 20:
7883
7884
  {
@@ -7912,10 +7913,8 @@ var allocate = (container, typeId, value) => {
7912
7913
  return new ComputedSignal(container, null);
7913
7914
 
7914
7915
  case 25:
7915
- return createStore(container, {}, 0);
7916
-
7917
7916
  case 26:
7918
- return createStore(container, [], 0);
7917
+ return null;
7919
7918
 
7920
7919
  case 11:
7921
7920
  return new URLSearchParams(value);
@@ -7965,13 +7964,16 @@ var allocate = (container, typeId, value) => {
7965
7964
  return vnodeOrDocument;
7966
7965
  }
7967
7966
  const vNode = retrieveVNodeOrDocument(container, value);
7968
- return vnode_isVNode(vNode) ? vnode_getNode(vNode) : throwErrorAndStop("expected vnode for ref prop, but got " + typeof vNode);
7967
+ if (vnode_isVNode(vNode)) {
7968
+ return vnode_getNode(vNode);
7969
+ }
7970
+ throw qError(34, [ typeof vNode ]);
7969
7971
 
7970
7972
  case 30:
7971
- return new EffectData(null);
7973
+ return new EffectPropData({});
7972
7974
 
7973
7975
  default:
7974
- return throwErrorAndStop("unknown allocate type: " + typeId);
7976
+ throw qError(35, [ typeId ]);
7975
7977
  }
7976
7978
  };
7977
7979
 
@@ -7979,13 +7981,13 @@ function retrieveVNodeOrDocument(container, value) {
7979
7981
  return value ? container.rootVNode ? vnode_locate(container.rootVNode, value) : void 0 : container.element?.ownerDocument;
7980
7982
  }
7981
7983
 
7982
- function parseQRL(qrl2) {
7983
- const hashIdx = qrl2.indexOf("#");
7984
- const captureStart = qrl2.indexOf("[", hashIdx);
7985
- const captureEnd = qrl2.indexOf("]", captureStart);
7986
- const chunk = hashIdx > -1 ? qrl2.slice(0, hashIdx) : qrl2.slice(0, captureStart);
7987
- const symbol = captureStart > -1 ? qrl2.slice(hashIdx + 1, captureStart) : qrl2.slice(hashIdx + 1);
7988
- const captureIds = captureStart > -1 && captureEnd > -1 ? qrl2.slice(captureStart + 1, captureEnd).split(" ").filter((v => v.length)).map((s => parseInt(s, 10))) : null;
7984
+ function parseQRL(qrl) {
7985
+ const hashIdx = qrl.indexOf("#");
7986
+ const captureStart = qrl.indexOf("[", hashIdx);
7987
+ const captureEnd = qrl.indexOf("]", captureStart);
7988
+ const chunk = hashIdx > -1 ? qrl.slice(0, hashIdx) : qrl.slice(0, captureStart);
7989
+ const symbol = captureStart > -1 ? qrl.slice(hashIdx + 1, captureStart) : qrl.slice(hashIdx + 1);
7990
+ const captureIds = captureStart > -1 && captureEnd > -1 ? qrl.slice(captureStart + 1, captureEnd).split(" ").filter((v => v.length)).map((s => parseInt(s, 10))) : null;
7989
7991
  let qrlRef = null;
7990
7992
  if (isDev2 && chunk === QRL_RUNTIME_CHUNK) {
7991
7993
  const backChannel = globalThis[QRL_RUNTIME_CHUNK];
@@ -7995,11 +7997,11 @@ function parseQRL(qrl2) {
7995
7997
  return createQRL(chunk, symbol, qrlRef, null, captureIds, null, null);
7996
7998
  }
7997
7999
 
7998
- function inflateQRL(container, qrl2) {
7999
- const captureIds = qrl2.$capture$;
8000
- qrl2.$captureRef$ = captureIds ? captureIds.map((id => container.$getObjectById$(id))) : null;
8001
- container.element && qrl2.$setContainer$(container.element);
8002
- return qrl2;
8000
+ function inflateQRL(container, qrl) {
8001
+ const captureIds = qrl.$capture$;
8002
+ qrl.$captureRef$ = captureIds ? captureIds.map((id => container.$getObjectById$(id))) : null;
8003
+ container.element && qrl.$setContainer$(container.element);
8004
+ return qrl;
8003
8005
  }
8004
8006
 
8005
8007
  var isDomRef = obj => false;
@@ -8047,7 +8049,7 @@ var createSerializationContext = (NodeConstructor, DomRefConstructor, symbolToCh
8047
8049
  $getRootId$: obj => {
8048
8050
  const id = map.get(obj);
8049
8051
  if (!id || -1 === id) {
8050
- return throwErrorAndStop("Missing root id for: ", obj);
8052
+ throw qError(36, [ obj ]);
8051
8053
  }
8052
8054
  return id;
8053
8055
  },
@@ -8090,8 +8092,8 @@ var createSerializationContext = (NodeConstructor, DomRefConstructor, symbolToCh
8090
8092
  if (isQrl2(obj)) {
8091
8093
  obj.$captureRef$ && discoveredValues.push(...obj.$captureRef$);
8092
8094
  } else if (isQwikComponent(obj)) {
8093
- const [qrl2] = obj[SERIALIZABLE_STATE];
8094
- discoveredValues.push(qrl2);
8095
+ const [qrl] = obj[SERIALIZABLE_STATE];
8096
+ discoveredValues.push(qrl);
8095
8097
  }
8096
8098
  } else if ("object" !== typeof obj || null === obj || obj instanceof URL || obj instanceof Date || obj instanceof RegExp || obj instanceof Uint8Array || obj instanceof URLSearchParams || "undefined" !== typeof FormData && obj instanceof FormData || fastSkipSerialize(obj)) {} else if (obj instanceof Error) {
8097
8099
  discoveredValues.push(...Object.values(obj));
@@ -8117,13 +8119,19 @@ var createSerializationContext = (NodeConstructor, DomRefConstructor, symbolToCh
8117
8119
  if (obj instanceof WrappedSignal) {
8118
8120
  obj.$effectDependencies$ && discoveredValues.push(...obj.$effectDependencies$);
8119
8121
  obj.$args$ && discoveredValues.push(...obj.$args$);
8122
+ obj.$hostElement$ && discoveredValues.push(obj.$hostElement$);
8120
8123
  } else {
8121
8124
  obj instanceof ComputedSignal && discoveredValues.push(obj.$computeQrl$);
8122
8125
  }
8123
- } else if (obj instanceof Task2) {
8126
+ } else if (obj instanceof Task) {
8124
8127
  discoveredValues.push(obj.$el$, obj.$qrl$, obj.$state$, obj.$effectDependencies$);
8125
8128
  } else if (isSsrNode(obj)) {
8126
- discoveredValues.push(obj.vnodeData);
8129
+ discoverValuesForVNodeData(obj.vnodeData, discoveredValues);
8130
+ if (obj.childrenVNodeData && obj.childrenVNodeData.length) {
8131
+ for (const data of obj.childrenVNodeData) {
8132
+ discoverValuesForVNodeData(data, discoveredValues);
8133
+ }
8134
+ }
8127
8135
  } else if (isDomRef(obj)) {
8128
8136
  discoveredValues.push(obj.$ssrNode$.id);
8129
8137
  } else if (isJSXNode(obj)) {
@@ -8143,11 +8151,11 @@ var createSerializationContext = (NodeConstructor, DomRefConstructor, symbolToCh
8143
8151
  discoveredValues.push(error);
8144
8152
  }));
8145
8153
  promises.push(obj);
8146
- } else if (obj instanceof EffectData) {
8154
+ } else if (obj instanceof EffectPropData) {
8147
8155
  discoveredValues.push(obj.data);
8148
8156
  } else {
8149
8157
  if (!isObjectLiteral(obj)) {
8150
- return throwErrorAndStop("Unknown type: " + obj);
8158
+ throw qError(37, [ obj ]);
8151
8159
  }
8152
8160
  Object.entries(obj).forEach((([key, value]) => {
8153
8161
  discoveredValues.push(key, value);
@@ -8177,6 +8185,22 @@ var createSerializationContext = (NodeConstructor, DomRefConstructor, symbolToCh
8177
8185
  }
8178
8186
  };
8179
8187
 
8188
+ var isSsrAttrs = value => Array.isArray(value) && value.length > 0;
8189
+
8190
+ var discoverValuesForVNodeData = (vnodeData, discoveredValues) => {
8191
+ for (const value of vnodeData) {
8192
+ if (isSsrAttrs(value)) {
8193
+ for (let i = 1; i < value.length; i += 2) {
8194
+ if (value[i - 1] === ELEMENT_KEY) {
8195
+ continue;
8196
+ }
8197
+ const attrValue = value[i];
8198
+ discoveredValues.push(attrValue);
8199
+ }
8200
+ }
8201
+ }
8202
+ };
8203
+
8180
8204
  var promiseResults = new WeakMap;
8181
8205
 
8182
8206
  function serialize(serializationContext) {
@@ -8222,13 +8246,13 @@ function serialize(serializationContext) {
8222
8246
  } else if (value === Fragment) {
8223
8247
  output(1, 9);
8224
8248
  } else if (isQrl2(value)) {
8225
- const qrl2 = qrlToString(serializationContext, value);
8226
- const id = serializationContext.$addRoot$(qrl2);
8249
+ const qrl = qrlToString(serializationContext, value);
8250
+ const id = serializationContext.$addRoot$(qrl);
8227
8251
  output(18, id);
8228
8252
  } else if (isQwikComponent(value)) {
8229
- const [qrl2] = value[SERIALIZABLE_STATE];
8230
- serializationContext.$renderSymbols$.add(qrl2.$symbol$);
8231
- output(21, [ qrl2 ]);
8253
+ const [qrl] = value[SERIALIZABLE_STATE];
8254
+ serializationContext.$renderSymbols$.add(qrl.$symbol$);
8255
+ output(21, [ qrl ]);
8232
8256
  } else {
8233
8257
  console.error("Cannot serialize function (ignoring for now): " + value.toString());
8234
8258
  output(1, 0);
@@ -8252,8 +8276,13 @@ function serialize(serializationContext) {
8252
8276
  const seen = depth > 1 && serializationContext.$wasSeen$(value);
8253
8277
  "number" === typeof seen && seen >= 0 ? output(0, seen) : output(3, value);
8254
8278
  }
8279
+ } else if ("undefined" === typeof value) {
8280
+ output(1, 0);
8255
8281
  } else {
8256
- "undefined" === typeof value ? output(1, 0) : value === NEEDS_COMPUTATION ? output(1, 7) : throwErrorAndStop("Unknown type: " + typeof value);
8282
+ if (value !== NEEDS_COMPUTATION) {
8283
+ throw qError(37, [ typeof value ]);
8284
+ }
8285
+ output(1, 7);
8257
8286
  }
8258
8287
  };
8259
8288
  const writeObjectValue = (value, idx) => {
@@ -8270,14 +8299,14 @@ function serialize(serializationContext) {
8270
8299
  const constProps = value[_CONST_PROPS];
8271
8300
  const out = constProps ? [ varProps, constProps ] : Object.keys(varProps).length ? [ varProps ] : 0;
8272
8301
  output(29, out);
8273
- } else if (value instanceof EffectData) {
8274
- output(30, [ value.data ]);
8302
+ } else if (value instanceof EffectPropData) {
8303
+ output(30, [ value.data.$scopedStyleIdPrefix$, value.data.$isConst$ ]);
8275
8304
  } else if (isStore(value)) {
8276
8305
  if (isResource(value)) {
8277
8306
  serializationContext.$resources$.add(value);
8278
8307
  const res = promiseResults.get(value.value);
8279
8308
  if (!res) {
8280
- return throwErrorAndStop("Unvisited Resource");
8309
+ throw qError(38, [ "resource" ]);
8281
8310
  }
8282
8311
  output(20, [ ...res, getStoreHandler(value).$effects$ ]);
8283
8312
  } else {
@@ -8312,12 +8341,12 @@ function serialize(serializationContext) {
8312
8341
  output(13, out);
8313
8342
  }
8314
8343
  } else if ($isDomRef$(value)) {
8315
- value.$ssrNode$.vnodeData[0] |= 8;
8344
+ value.$ssrNode$.vnodeData[0] |= 16;
8316
8345
  output(9, value.$ssrNode$.id);
8317
8346
  } else if (value instanceof Signal) {
8318
8347
  const v = value instanceof ComputedSignal && (value.$invalid$ || fastSkipSerialize(value.$untrackedValue$)) ? NEEDS_COMPUTATION : value.$untrackedValue$;
8319
8348
  if (value instanceof WrappedSignal) {
8320
- output(23, [ ...serializeWrappingFn(serializationContext, value), value.$effectDependencies$, v, ...value.$effects$ || [] ]);
8349
+ output(23, [ ...serializeWrappingFn(serializationContext, value), value.$effectDependencies$, v, value.$hostElement$, ...value.$effects$ || [] ]);
8321
8350
  } else if (value instanceof ComputedSignal) {
8322
8351
  const out = [ value.$computeQrl$, value.$effects$ ];
8323
8352
  v !== NEEDS_COMPUTATION && out.push(v);
@@ -8344,11 +8373,11 @@ function serialize(serializationContext) {
8344
8373
  const vNodeData = value.vnodeData;
8345
8374
  if (vNodeData) {
8346
8375
  serializationContext.$prepVNodeData$?.(vNodeData);
8347
- vNodeData[0] |= 8;
8376
+ vNodeData[0] |= 16;
8348
8377
  }
8349
8378
  if (value.childrenVNodeData) {
8350
8379
  for (const vNodeData2 of value.childrenVNodeData) {
8351
- vNodeData2[0] |= 8;
8380
+ vNodeData2[0] |= 16;
8352
8381
  }
8353
8382
  }
8354
8383
  } else {
@@ -8373,7 +8402,7 @@ function serialize(serializationContext) {
8373
8402
  output(16, combined);
8374
8403
  } else if (isJSXNode(value)) {
8375
8404
  output(28, [ value.type, value.varProps, value.constProps, value.children, value.flags, value.key ]);
8376
- } else if (value instanceof Task2) {
8405
+ } else if (value instanceof Task) {
8377
8406
  const out = [ value.$qrl$, value.$flags$, value.$index$, value.$el$, value.$effectDependencies$, value.$state$ ];
8378
8407
  while (null == out[out.length - 1]) {
8379
8408
  out.pop();
@@ -8382,12 +8411,12 @@ function serialize(serializationContext) {
8382
8411
  } else if (isPromise(value)) {
8383
8412
  const res = promiseResults.get(value);
8384
8413
  if (!res) {
8385
- return throwErrorAndStop("Unvisited Promise");
8414
+ throw qError(38, [ "promise" ]);
8386
8415
  }
8387
8416
  output(14, res);
8388
8417
  } else {
8389
8418
  if (!(value instanceof Uint8Array)) {
8390
- return throwErrorAndStop("implement");
8419
+ throw qError(37, [ typeof value ]);
8391
8420
  }
8392
8421
  {
8393
8422
  let buf = "";
@@ -8433,7 +8462,9 @@ function qrlToString(serializationContext, value) {
8433
8462
  backChannel.set(value.$symbol$, value._devOnlySymbolRef);
8434
8463
  chunk || (chunk = QRL_RUNTIME_CHUNK);
8435
8464
  }
8436
- chunk || throwErrorAndStop("Missing chunk for: " + value.$symbol$);
8465
+ if (!chunk) {
8466
+ throw qError(31, [ value.$symbol$ ]);
8467
+ }
8437
8468
  chunk.startsWith("./") && (chunk = chunk.slice(2));
8438
8469
  }
8439
8470
  let qrlStringInline = `${chunk}#${symbol}`;
@@ -8450,13 +8481,13 @@ function qrlToString(serializationContext, value) {
8450
8481
  return qrlStringInline;
8451
8482
  }
8452
8483
 
8453
- function deserializeData(container, typeId, propValue) {
8484
+ function deserializeData(container, typeId, value) {
8454
8485
  if (void 0 === typeId) {
8455
- return propValue;
8486
+ return value;
8456
8487
  }
8457
- const value = allocate(container, typeId, propValue);
8458
- typeId >= 12 && inflate(container, value, typeId, propValue);
8459
- return value;
8488
+ let propValue = allocate(container, typeId, value);
8489
+ typeId >= 12 && (propValue = inflate(container, propValue, typeId, value));
8490
+ return propValue;
8460
8491
  }
8461
8492
 
8462
8493
  function shouldTrackObj(obj) {
@@ -8472,7 +8503,7 @@ function isResource(value) {
8472
8503
  return "__brand" in value && "resource" === value.__brand;
8473
8504
  }
8474
8505
 
8475
- var frameworkType = obj => "object" === typeof obj && null !== obj && (obj instanceof Signal || obj instanceof Task2 || isJSXNode(obj)) || isQrl2(obj);
8506
+ var frameworkType = obj => "object" === typeof obj && null !== obj && (obj instanceof Signal || obj instanceof Task || isJSXNode(obj)) || isQrl2(obj);
8476
8507
 
8477
8508
  var canSerialize = value => {
8478
8509
  if (null == value || "string" === typeof value || "number" === typeof value || "boolean" === typeof value || "bigint" === typeof value) {
@@ -8581,7 +8612,7 @@ var _verifySerializable = (value, seen, ctx, preMessage) => {
8581
8612
  let expectIndex = 0;
8582
8613
  unwrapped.forEach(((v, i) => {
8583
8614
  if (i !== expectIndex) {
8584
- throw qError(QError_verifySerializable, unwrapped);
8615
+ throw qError(3, [ unwrapped ]);
8585
8616
  }
8586
8617
  _verifySerializable(v, seen, ctx + "[" + i + "]");
8587
8618
  expectIndex = i + 1;
@@ -8610,8 +8641,7 @@ var _verifySerializable = (value, seen, ctx, preMessage) => {
8610
8641
  const fnName = value.name;
8611
8642
  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.`;
8612
8643
  }
8613
- console.error("Trying to serialize", value);
8614
- throwErrorAndStop(message);
8644
+ throw qError(3, [ message ]);
8615
8645
  }
8616
8646
  return value;
8617
8647
  };
@@ -8645,7 +8675,7 @@ var createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef, refSym
8645
8675
  }
8646
8676
  }
8647
8677
  let _containerEl;
8648
- const qrl2 = async function(...args) {
8678
+ const qrl = async function(...args) {
8649
8679
  const boundedFn = bindFnToContext.call(this, tryGetInvokeContext());
8650
8680
  const result = await boundedFn(...args);
8651
8681
  return result;
@@ -8657,7 +8687,7 @@ var createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef, refSym
8657
8687
  function bindFnToContext(currentCtx, beforeFn) {
8658
8688
  return (...args) => maybeThen(resolveLazy(), (fn => {
8659
8689
  if (!isFunction(fn)) {
8660
- throw qError(QError_qrlIsNotFunction);
8690
+ throw qError(10);
8661
8691
  }
8662
8692
  if (beforeFn && false === beforeFn()) {
8663
8693
  return;
@@ -8665,7 +8695,7 @@ var createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef, refSym
8665
8695
  const context = createOrReuseInvocationContext(currentCtx);
8666
8696
  const prevQrl = context.$qrl$;
8667
8697
  const prevEvent = context.$event$;
8668
- context.$qrl$ = qrl2;
8698
+ context.$qrl$ = qrl;
8669
8699
  context.$event$ || (context.$event$ = this);
8670
8700
  try {
8671
8701
  return invoke.call(this, context, fn, ...args);
@@ -8686,7 +8716,7 @@ var createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef, refSym
8686
8716
  return fn.apply(this, args);
8687
8717
  }
8688
8718
  context = newInvokeContext();
8689
- context.$qrl$ = qrl2;
8719
+ context.$qrl$ = qrl;
8690
8720
  context.$event$ = this;
8691
8721
  return invoke.call(this, context, fn, ...args);
8692
8722
  };
@@ -8701,15 +8731,15 @@ var createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef, refSym
8701
8731
  const hash2 = _containerEl.getAttribute(QInstanceAttr);
8702
8732
  const doc = _containerEl.ownerDocument;
8703
8733
  const qFuncs = getQFuncs(doc, hash2);
8704
- return qrl2.resolved = symbolRef = qFuncs[Number(symbol)];
8734
+ return qrl.resolved = symbolRef = qFuncs[Number(symbol)];
8705
8735
  }
8706
8736
  const start = now();
8707
8737
  const ctx = tryGetInvokeContext();
8708
8738
  if (null !== symbolFn) {
8709
- symbolRef = symbolFn().then((module => qrl2.resolved = symbolRef = wrapFn(module[symbol])));
8739
+ symbolRef = symbolFn().then((module => qrl.resolved = symbolRef = wrapFn(module[symbol])));
8710
8740
  } else {
8711
8741
  const imported = getPlatform().importSymbol(_containerEl, chunk, symbol);
8712
- symbolRef = maybeThen(imported, (ref => qrl2.resolved = symbolRef = wrapFn(ref)));
8742
+ symbolRef = maybeThen(imported, (ref => qrl.resolved = symbolRef = wrapFn(ref)));
8713
8743
  }
8714
8744
  "object" === typeof symbolRef && isPromise(symbolRef) && symbolRef.then((() => emitUsedSymbol(symbol, ctx?.$element$, start)), (err => {
8715
8745
  console.error(`qrl ${symbol} failed to load`, err);
@@ -8721,7 +8751,7 @@ var createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef, refSym
8721
8751
  const createOrReuseInvocationContext = invoke2 => null == invoke2 ? newInvokeContext() : isArray(invoke2) ? newInvokeContextFromTuple(invoke2) : invoke2;
8722
8752
  const resolvedSymbol = refSymbol ?? symbol;
8723
8753
  const hash = getSymbolHash(resolvedSymbol);
8724
- Object.assign(qrl2, {
8754
+ Object.assign(qrl, {
8725
8755
  getSymbol: () => resolvedSymbol,
8726
8756
  getHash: () => hash,
8727
8757
  getCaptured: () => captureRef,
@@ -8738,12 +8768,12 @@ var createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef, refSym
8738
8768
  dev: null,
8739
8769
  resolved: void 0
8740
8770
  });
8741
- symbolRef && (symbolRef = maybeThen(symbolRef, (resolved => qrl2.resolved = symbolRef = wrapFn(resolved))));
8742
- isDev && Object.defineProperty(qrl2, "_devOnlySymbolRef", {
8771
+ symbolRef && (symbolRef = maybeThen(symbolRef, (resolved => qrl.resolved = symbolRef = wrapFn(resolved))));
8772
+ isDev && Object.defineProperty(qrl, "_devOnlySymbolRef", {
8743
8773
  get: () => symbolRef
8744
8774
  });
8745
- qDev && seal(qrl2);
8746
- return qrl2;
8775
+ qDev && seal(qrl);
8776
+ return qrl;
8747
8777
  };
8748
8778
 
8749
8779
  var getSymbolHash = symbolName => {
@@ -8754,8 +8784,8 @@ var getSymbolHash = symbolName => {
8754
8784
  return symbolName;
8755
8785
  };
8756
8786
 
8757
- function assertQrl(qrl2) {
8758
- if (qDev && !isQrl2(qrl2)) {
8787
+ function assertQrl(qrl) {
8788
+ if (qDev && !isQrl2(qrl)) {
8759
8789
  throw new Error("Not a QRL");
8760
8790
  }
8761
8791
  }
@@ -8872,8 +8902,8 @@ async function configureDevServer(base, server, opts, sys, path, isClientDevOnly
8872
8902
  }
8873
8903
  const firstInput = opts.input && Object.values(opts.input)[0];
8874
8904
  const ssrModule = await server.ssrLoadModule(firstInput);
8875
- const render2 = ssrModule.default ?? ssrModule.render;
8876
- if ("function" === typeof render2) {
8905
+ const render = ssrModule.default ?? ssrModule.render;
8906
+ if ("function" === typeof render) {
8877
8907
  const manifest = {
8878
8908
  manifestHash: "",
8879
8909
  symbols: {},
@@ -8921,7 +8951,7 @@ async function configureDevServer(base, server, opts, sys, path, isClientDevOnly
8921
8951
  res.setHeader("Access-Control-Allow-Origin", "*");
8922
8952
  res.setHeader("X-Powered-By", "Qwik Vite Dev Server");
8923
8953
  res.writeHead(status);
8924
- const result = await render2(renderOpts);
8954
+ const result = await render(renderOpts);
8925
8955
  Array.from(server.moduleGraph.fileToModulesMap.entries()).forEach((entry => {
8926
8956
  entry[1].forEach((v => {
8927
8957
  const {pathId: pathId, query: query} = parseId(v.url);