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

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.4-dev+374e0d6
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
@@ -1226,7 +1226,7 @@ globalThis.qwikOptimizer = function(module) {
1226
1226
  }
1227
1227
  var QWIK_BINDING_MAP = {};
1228
1228
  var versions = {
1229
- qwik: "2.0.0-alpha.3-dev+418fd6d"
1229
+ qwik: "2.0.0-alpha.4-dev+374e0d6"
1230
1230
  };
1231
1231
  async function getSystem() {
1232
1232
  const sysEnv = getEnv();
@@ -1534,7 +1534,7 @@ globalThis.qwikOptimizer = function(module) {
1534
1534
  }
1535
1535
  return canonPath(bundle.fileName);
1536
1536
  };
1537
- const qrlNames = new Set([ ...segments.map((h2 => h2.name)) ]);
1537
+ const qrlNames = new Set([ ...segments.map((h => h.name)) ]);
1538
1538
  for (const outputBundle of Object.values(outputBundles)) {
1539
1539
  if ("chunk" !== outputBundle.type) {
1540
1540
  continue;
@@ -2244,7 +2244,7 @@ globalThis.qwikOptimizer = function(module) {
2244
2244
  const generateManifest = async () => {
2245
2245
  const optimizer2 = getOptimizer();
2246
2246
  const path = optimizer2.sys.path;
2247
- const segments = Array.from(clientResults.values()).flatMap((r => r.modules)).map((mod => mod.segment)).filter((h2 => !!h2));
2247
+ const segments = Array.from(clientResults.values()).flatMap((r => r.modules)).map((mod => mod.segment)).filter((h => !!h));
2248
2248
  const manifest = generateManifestFromBundles(path, segments, injections, rollupBundle, opts, debug);
2249
2249
  for (const symbol of Object.values(manifest.symbols)) {
2250
2250
  symbol.origin && (symbol.origin = normalizePath(symbol.origin));
@@ -2744,7 +2744,7 @@ globalThis.qwikOptimizer = function(module) {
2744
2744
  return `Img${toPascalCase(value)}`;
2745
2745
  }
2746
2746
  function toPascalCase(string) {
2747
- 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()));
2747
+ 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()));
2748
2748
  }
2749
2749
  var FORCE_COLOR;
2750
2750
  var NODE_DISABLE_COLORS;
@@ -2802,7 +2802,7 @@ globalThis.qwikOptimizer = function(module) {
2802
2802
  var qSerialize = false !== globalThis.qSerialize;
2803
2803
  var qDynamicPlatform = false !== globalThis.qDynamicPlatform;
2804
2804
  var qTest = true === globalThis.qTest;
2805
- var qRuntimeQrl = true === globalThis.qRuntimeQrl;
2805
+ globalThis.qRuntimeQrl;
2806
2806
  var seal = obj => {
2807
2807
  qDev && Object.seal(obj);
2808
2808
  };
@@ -2823,7 +2823,7 @@ globalThis.qwikOptimizer = function(module) {
2823
2823
  };
2824
2824
  var createAndLogError = (asyncThrow, message, ...optionalParams) => {
2825
2825
  const err = message instanceof Error ? message : new Error(message);
2826
- console.error("%cQWIK ERROR", STYLE, err.message, ...optionalParams, err.stack);
2826
+ !qTest && console.error("%cQWIK ERROR", STYLE, err.message, ...optionalParams, err.stack);
2827
2827
  asyncThrow && !qTest && setTimeout((() => {
2828
2828
  throw err;
2829
2829
  }), 0);
@@ -2872,26 +2872,20 @@ globalThis.qwikOptimizer = function(module) {
2872
2872
  }
2873
2873
  var codeToText = (code, ...parts) => {
2874
2874
  if (qDev) {
2875
- 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" ];
2875
+ 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", "The 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}}", "The value of the textarea must be a string", "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" ];
2876
2876
  let text = MAP[code] ?? "";
2877
2877
  parts.length && (text = text.replaceAll(/{{(\d+)}}/g, ((_, index) => {
2878
2878
  let v = parts[index];
2879
2879
  v && "object" === typeof v && v.constructor === Object && (v = JSON.stringify(v).slice(0, 50));
2880
2880
  return v;
2881
2881
  })));
2882
- return `Code(${code}): ${text}`;
2882
+ return `Code(Q${code}): ${text}`;
2883
2883
  }
2884
- return `Code(${code}) https://github.com/QwikDev/qwik/blob/main/packages/qwik/src/core/error/error.ts#L${8 + code}`;
2884
+ return `Code(Q${code}) https://github.com/QwikDev/qwik/blob/main/packages/qwik/src/core/error/error.ts#L${8 + code}`;
2885
2885
  };
2886
- var QError_stringifyClassOrStyle = 0;
2887
- var QError_verifySerializable = 3;
2888
- var QError_qrlIsNotFunction = 10;
2889
- var QError_useInvokeContext = 20;
2890
- var QError_qrlMissingContainer = 30;
2891
- var QError_qrlMissingChunk = 31;
2892
- var qError = (code, ...parts) => {
2893
- const text = codeToText(code, ...parts);
2894
- return logErrorAndStop(text, ...parts);
2886
+ var qError = (code, errorMessageArgs = []) => {
2887
+ const text = codeToText(code, ...errorMessageArgs);
2888
+ return logErrorAndStop(text, ...errorMessageArgs);
2895
2889
  };
2896
2890
  var createPlatform = () => ({
2897
2891
  isServer: isServer,
@@ -2905,10 +2899,10 @@ globalThis.qwikOptimizer = function(module) {
2905
2899
  }
2906
2900
  }
2907
2901
  if (!url) {
2908
- throw qError(QError_qrlMissingChunk, symbolName);
2902
+ throw qError(31, [ symbolName ]);
2909
2903
  }
2910
2904
  if (!containerEl) {
2911
- throw qError(QError_qrlMissingContainer, url, symbolName);
2905
+ throw qError(30, [ url, symbolName ]);
2912
2906
  }
2913
2907
  const urlDoc = toUrl(containerEl.ownerDocument, containerEl, url).toString();
2914
2908
  const urlCopy = new URL(urlDoc);
@@ -2955,7 +2949,7 @@ globalThis.qwikOptimizer = function(module) {
2955
2949
  var maybeThen = (valueOrPromise, thenFn) => isPromise(valueOrPromise) ? valueOrPromise.then(thenFn, shouldNotError) : thenFn(valueOrPromise);
2956
2950
  var maybeThenPassError = (valueOrPromise, thenFn) => isPromise(valueOrPromise) ? valueOrPromise.then(thenFn) : thenFn(valueOrPromise);
2957
2951
  var shouldNotError = reason => {
2958
- throwErrorAndStop("QWIK ERROR:", reason);
2952
+ throwErrorAndStop(reason);
2959
2953
  };
2960
2954
  var delay = timeout => new Promise((resolve => {
2961
2955
  setTimeout(resolve, timeout);
@@ -2979,25 +2973,6 @@ globalThis.qwikOptimizer = function(module) {
2979
2973
  var isString = v => "string" === typeof v;
2980
2974
  var isFunction = v => "function" === typeof v;
2981
2975
  var isDev2 = true;
2982
- var runtimeSymbolId = 0;
2983
- var $2 = expression => {
2984
- if (!qRuntimeQrl && qDev) {
2985
- throw new Error("Optimizer should replace all usages of $() with some special syntax. If you need to create a QRL manually, use inlinedQrl() instead.");
2986
- }
2987
- return createQRL(null, "s" + runtimeSymbolId++, expression, null, null, null, null);
2988
- };
2989
- var dollar = $2;
2990
- var eventQrl = qrl2 => qrl2;
2991
- var EMPTY_ARRAY = [];
2992
- var EMPTY_OBJ = {};
2993
- Object.freeze(EMPTY_ARRAY);
2994
- Object.freeze(EMPTY_OBJ);
2995
- Symbol("proxy target");
2996
- Symbol("proxy flags");
2997
- Symbol("proxy manager");
2998
- var _CONST_PROPS = Symbol("CONST");
2999
- var _VAR_PROPS = Symbol("VAR");
3000
- Symbol("IMMUTABLE");
3001
2976
  var DEBUG_TYPE = "q:type";
3002
2977
  var START = "";
3003
2978
  var END = "";
@@ -3048,6 +3023,7 @@ globalThis.qwikOptimizer = function(module) {
3048
3023
  var ELEMENT_PROPS = "q:props";
3049
3024
  var ELEMENT_SEQ = "q:seq";
3050
3025
  var ELEMENT_SEQ_IDX = "q:seqIdx";
3026
+ var Q_PREFIX = "q:";
3051
3027
  var NON_SERIALIZABLE_MARKER_PREFIX = ":";
3052
3028
  var USE_ON_LOCAL = NON_SERIALIZABLE_MARKER_PREFIX + "on";
3053
3029
  var USE_ON_LOCAL_SEQ_IDX = NON_SERIALIZABLE_MARKER_PREFIX + "onIdx";
@@ -3058,32 +3034,16 @@ globalThis.qwikOptimizer = function(module) {
3058
3034
  }
3059
3035
  globalThis.QWIK_DOM_VERSION;
3060
3036
  var isQrl = value => "function" === typeof value && "function" === typeof value.getSymbol;
3061
- var useSequentialScope = () => {
3062
- const iCtx = useInvokeContext();
3063
- const hostElement = iCtx.$hostElement$;
3064
- const host = hostElement;
3065
- let seq = iCtx.$container$.getHostProp(host, ELEMENT_SEQ);
3066
- if (null === seq) {
3067
- seq = [];
3068
- iCtx.$container$.setHostProp(host, ELEMENT_SEQ, seq);
3069
- }
3070
- let seqIdx = iCtx.$container$.getHostProp(host, ELEMENT_SEQ_IDX);
3071
- null === seqIdx && (seqIdx = 0);
3072
- iCtx.$container$.setHostProp(host, ELEMENT_SEQ_IDX, seqIdx + 1);
3073
- while (seq.length <= seqIdx) {
3074
- seq.push(void 0);
3075
- }
3076
- const set = value => {
3077
- qDev && qSerialize && verifySerializable(value);
3078
- return seq[seqIdx] = value;
3079
- };
3080
- return {
3081
- val: seq[seqIdx],
3082
- set: set,
3083
- i: seqIdx,
3084
- iCtx: iCtx
3085
- };
3086
- };
3037
+ var EMPTY_ARRAY = [];
3038
+ var EMPTY_OBJ = {};
3039
+ Object.freeze(EMPTY_ARRAY);
3040
+ Object.freeze(EMPTY_OBJ);
3041
+ var Slot = props => _jsxSorted(Virtual, null, {
3042
+ [QSlotS]: ""
3043
+ }, props.children, 0, props.name ?? "");
3044
+ var SkipRender = Symbol("skip render");
3045
+ var SSRRaw = () => null;
3046
+ var SSRComment = () => null;
3087
3047
  var isJsxPropertyAnEventName = name => (name.startsWith("on") || name.startsWith("window:on") || name.startsWith("document:on")) && name.endsWith("$");
3088
3048
  var isHtmlAttributeAnEventName = name => name.startsWith("on:") || name.startsWith("on-window:") || name.startsWith("on-document:");
3089
3049
  var getEventNameFromJsxProp = name => {
@@ -3135,486 +3095,303 @@ globalThis.qwikOptimizer = function(module) {
3135
3095
  function isPreventDefault(key) {
3136
3096
  return key.startsWith("preventdefault:");
3137
3097
  }
3138
- var createContextId = name => {
3139
- assertTrue(/^[\w/.-]+$/.test(name), "Context name must only contain A-Z,a-z,0-9, _", name);
3140
- return Object.freeze({
3141
- id: fromCamelToKebabCase(name)
3142
- });
3098
+ 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" ]);
3099
+ var isUnitlessNumber = name => unitlessNumbers.has(name);
3100
+ var serializeClass = obj => {
3101
+ if (!obj) {
3102
+ return "";
3103
+ }
3104
+ if (isString(obj)) {
3105
+ return obj.trim();
3106
+ }
3107
+ const classes = [];
3108
+ if (isArray(obj)) {
3109
+ for (const o of obj) {
3110
+ const classList = serializeClass(o);
3111
+ classList && classes.push(classList);
3112
+ }
3113
+ } else {
3114
+ for (const [key, value] of Object.entries(obj)) {
3115
+ value && classes.push(key.trim());
3116
+ }
3117
+ }
3118
+ return classes.join(" ");
3143
3119
  };
3144
- var ERROR_CONTEXT = createContextId("qk-error");
3145
- var isRecoverable = err => {
3146
- if (err && err instanceof Error && "plugin" in err) {
3147
- return false;
3120
+ var fromCamelToKebabCaseWithDash = text => text.replace(/([A-Z])/g, "-$1").toLowerCase();
3121
+ var stringifyStyle = obj => {
3122
+ if (null == obj) {
3123
+ return "";
3148
3124
  }
3149
- return true;
3125
+ if ("object" == typeof obj) {
3126
+ if (isArray(obj)) {
3127
+ throw qError(0, [ obj, "style" ]);
3128
+ }
3129
+ {
3130
+ const chunks = [];
3131
+ for (const key in obj) {
3132
+ if (Object.prototype.hasOwnProperty.call(obj, key)) {
3133
+ const value = obj[key];
3134
+ null != value && "function" !== typeof value && (key.startsWith("--") ? chunks.push(key + ":" + value) : chunks.push(fromCamelToKebabCaseWithDash(key) + ":" + setValueForStyle(key, value)));
3135
+ }
3136
+ }
3137
+ return chunks.join(";");
3138
+ }
3139
+ }
3140
+ return String(obj);
3150
3141
  };
3151
- function isSlotProp(prop) {
3152
- return !prop.startsWith("q:") && !prop.startsWith(NON_SERIALIZABLE_MARKER_PREFIX);
3153
- }
3154
- function isParentSlotProp(prop) {
3155
- return prop.startsWith(QSlotParent);
3142
+ var serializeBooleanOrNumberAttribute = value => null != value ? String(value) : null;
3143
+ function serializeAttribute(key, value, styleScopedId) {
3144
+ if (isClassAttr(key)) {
3145
+ const serializedClass = serializeClass(value);
3146
+ value = styleScopedId ? styleScopedId + (serializedClass.length ? " " + serializedClass : serializedClass) : serializedClass;
3147
+ } else {
3148
+ "style" === key ? value = stringifyStyle(value) : isEnumeratedBooleanAttribute(key) || "number" === typeof value ? value = serializeBooleanOrNumberAttribute(value) : false === value || null == value ? value = null : true === value && isPreventDefault(key) && (value = "");
3149
+ }
3150
+ return value;
3156
3151
  }
3157
- var Subscriber = class {
3158
- $effectDependencies$=null;
3159
- };
3160
- function isSubscriber(value) {
3161
- return value instanceof Subscriber || value instanceof WrappedSignal;
3152
+ function isEnumeratedBooleanAttribute(key) {
3153
+ return isAriaAttribute(key) || [ "spellcheck", "draggable", "contenteditable" ].includes(key);
3162
3154
  }
3163
- function clearVNodeEffectDependencies(value) {
3164
- const effects = vnode_getProp(value, QSubscribers, null);
3165
- if (!effects) {
3166
- return;
3167
- }
3168
- for (let i = effects.length - 1; i >= 0; i--) {
3169
- const subscriber = effects[i];
3170
- const subscriptionRemoved = clearEffects(subscriber, value);
3171
- subscriptionRemoved && effects.splice(i, 1);
3155
+ var setValueForStyle = (styleName, value) => {
3156
+ if ("number" === typeof value && 0 !== value && !isUnitlessNumber(styleName)) {
3157
+ return value + "px";
3172
3158
  }
3159
+ return value;
3160
+ };
3161
+ function isAriaAttribute(prop) {
3162
+ return prop.startsWith("aria-");
3173
3163
  }
3174
- function clearSubscriberEffectDependencies(value) {
3175
- if (value.$effectDependencies$) {
3176
- for (let i = value.$effectDependencies$.length - 1; i >= 0; i--) {
3177
- const subscriber = value.$effectDependencies$[i];
3178
- const subscriptionRemoved = clearEffects(subscriber, value);
3179
- subscriptionRemoved && value.$effectDependencies$.splice(i, 1);
3164
+ var styleContent = styleId => ComponentStylesPrefixContent + styleId;
3165
+ function hasClassAttr(props) {
3166
+ for (const key in props) {
3167
+ if (Object.prototype.hasOwnProperty.call(props, key) && isClassAttr(key)) {
3168
+ return true;
3180
3169
  }
3181
3170
  }
3171
+ return false;
3182
3172
  }
3183
- function clearEffects(subscriber, value) {
3184
- if (!isSignal(subscriber)) {
3185
- return false;
3186
- }
3187
- const effectSubscriptions = subscriber.$effects$;
3188
- if (!effectSubscriptions) {
3189
- return false;
3190
- }
3191
- let subscriptionRemoved = false;
3192
- for (let i = effectSubscriptions.length - 1; i >= 0; i--) {
3193
- const effect = effectSubscriptions[i];
3194
- if (effect[0] === value) {
3195
- effectSubscriptions.splice(i, 1);
3196
- subscriptionRemoved = true;
3197
- }
3198
- }
3199
- return subscriptionRemoved;
3173
+ function isClassAttr(key) {
3174
+ return "class" === key || "className" === key;
3200
3175
  }
3201
- var NEEDS_COMPUTATION = Symbol("invalid");
3202
- var DEBUG = false;
3203
- var log = (...args) => console.log("SIGNAL", ...args.map(qwikDebugToString));
3204
- var throwIfQRLNotResolved = qrl2 => {
3205
- const resolved = qrl2.resolved;
3206
- if (!resolved) {
3207
- throw qrl2.resolve();
3176
+ function convertScopedStyleIdsToArray(scopedStyleIds) {
3177
+ return (null == scopedStyleIds ? void 0 : scopedStyleIds.split(" ")) ?? null;
3178
+ }
3179
+ function convertStyleIdsToString(scopedStyleIds) {
3180
+ return Array.from(scopedStyleIds).join(" ");
3181
+ }
3182
+ var addComponentStylePrefix = styleId => {
3183
+ if (styleId) {
3184
+ let idx = 0;
3185
+ do {
3186
+ styleId = styleId.substring(0, idx) + styleContent(styleId.substring(idx));
3187
+ } while (0 !== (idx = styleId.indexOf(" ", idx) + 1));
3208
3188
  }
3189
+ return styleId || null;
3209
3190
  };
3210
- var isSignal = value => value instanceof Signal;
3211
- var EffectData = class {
3212
- data;
3213
- constructor(data) {
3214
- this.data = data;
3191
+ var DEBUG = false;
3192
+ var log = (...args) => console.log("STORE", ...args.map(qwikDebugToString));
3193
+ var STORE_TARGET = Symbol("store.target");
3194
+ var STORE_HANDLER = Symbol("store.handler");
3195
+ var STORE_ARRAY_PROP = Symbol("store.array");
3196
+ var getStoreHandler = value => value[STORE_HANDLER];
3197
+ var getStoreTarget = value => (null == value ? void 0 : value[STORE_TARGET]) || null;
3198
+ var unwrapStore = value => getStoreTarget(value) || value;
3199
+ var isStore = value => STORE_TARGET in value;
3200
+ function createStore(container, obj, flags) {
3201
+ return new Proxy(obj, new StoreHandler(flags, container || null));
3202
+ }
3203
+ var getOrCreateStore = (obj, flags, container) => {
3204
+ if (isSerializableObject(obj) && container) {
3205
+ let store = container.$storeProxyMap$.get(obj);
3206
+ if (!store) {
3207
+ store = createStore(container, obj, flags);
3208
+ container.$storeProxyMap$.set(obj, store);
3209
+ }
3210
+ return store;
3215
3211
  }
3212
+ return obj;
3216
3213
  };
3217
- var Signal = class {
3218
- $untrackedValue$;
3219
- $effects$=null;
3220
- $container$=null;
3221
- constructor(container, value) {
3222
- this.$container$ = container;
3223
- this.$untrackedValue$ = value;
3224
- DEBUG && log("new", this);
3225
- }
3226
- get untrackedValue() {
3227
- return this.$untrackedValue$;
3214
+ var StoreHandler = class {
3215
+ constructor($flags$, $container$) {
3216
+ this.$flags$ = $flags$;
3217
+ this.$container$ = $container$;
3228
3218
  }
3229
- set untrackedValue(value) {
3230
- this.$untrackedValue$ = value;
3219
+ $effects$=null;
3220
+ toString() {
3221
+ return "[Store]";
3231
3222
  }
3232
- get value() {
3223
+ get(target, prop) {
3224
+ if ("symbol" === typeof prop) {
3225
+ if (prop === STORE_TARGET) {
3226
+ return target;
3227
+ }
3228
+ if (prop === STORE_HANDLER) {
3229
+ return this;
3230
+ }
3231
+ return target[prop];
3232
+ }
3233
3233
  const ctx = tryGetInvokeContext();
3234
+ const value = target[prop];
3234
3235
  if (ctx) {
3235
3236
  if (null === this.$container$) {
3236
3237
  if (!ctx.$container$) {
3237
- return this.untrackedValue;
3238
+ return value;
3238
3239
  }
3239
3240
  this.$container$ = ctx.$container$;
3240
3241
  } else {
3241
3242
  assertTrue(!ctx.$container$ || ctx.$container$ === this.$container$, "Do not use signals across containers");
3242
3243
  }
3243
3244
  const effectSubscriber = ctx.$effectSubscriber$;
3244
- if (effectSubscriber) {
3245
- const effects = this.$effects$ ||= [];
3246
- ensureContainsEffect(effects, effectSubscriber);
3247
- ensureContains(effectSubscriber, this);
3248
- isSubscriber(this) && ensureEffectContainsSubscriber(effectSubscriber[0], this, this.$container$);
3249
- DEBUG && log("read->sub", pad("\n" + this.toString(), " "));
3250
- }
3245
+ effectSubscriber && addEffect(target, Array.isArray(target) ? STORE_ARRAY_PROP : prop, this, effectSubscriber);
3251
3246
  }
3252
- return this.untrackedValue;
3253
- }
3254
- set value(value) {
3255
- if (value !== this.$untrackedValue$) {
3256
- DEBUG && log("Signal.set", this.$untrackedValue$, "->", value, pad("\n" + this.toString(), " "));
3257
- this.$untrackedValue$ = value;
3258
- triggerEffects(this.$container$, this, this.$effects$);
3247
+ if ("toString" === prop && value === Object.prototype.toString) {
3248
+ return this.toString;
3259
3249
  }
3250
+ const flags = this.$flags$;
3251
+ if (1 & flags && "object" === typeof value && null !== value && !Object.isFrozen(value) && !isStore(value) && !Object.isFrozen(target)) {
3252
+ return getOrCreateStore(value, this.$flags$, this.$container$);
3253
+ }
3254
+ return value;
3260
3255
  }
3261
- valueOf() {
3262
- if (qDev) {
3263
- return throwErrorAndStop("Cannot coerce a Signal, use `.value` instead");
3256
+ set(target, prop, value) {
3257
+ target = unwrapDeserializerProxy(target);
3258
+ if ("symbol" === typeof prop) {
3259
+ target[prop] = value;
3260
+ return true;
3261
+ }
3262
+ const newValue = 1 & this.$flags$ ? unwrapStore(value) : value;
3263
+ if (prop in target) {
3264
+ const oldValue = target[prop];
3265
+ if (newValue !== oldValue) {
3266
+ DEBUG && log("Store.set", oldValue, "->", newValue, pad("\n" + this.toString(), " "));
3267
+ setNewValueAndTriggerEffects(prop, newValue, target, this);
3268
+ }
3269
+ } else {
3270
+ DEBUG && log("Store.set", "create property", newValue, pad("\n" + this.toString(), " "));
3271
+ setNewValueAndTriggerEffects(prop, newValue, target, this);
3264
3272
  }
3273
+ return true;
3265
3274
  }
3266
- toString() {
3267
- var _a;
3268
- return `[${this.constructor.name}${this.$invalid$ ? " INVALID" : ""} ${String(this.$untrackedValue$)}]` + ((null == (_a = this.$effects$) ? void 0 : _a.map((e => "\n -> " + pad(qwikDebugToString(e[0]), " "))).join("\n")) || "");
3275
+ deleteProperty(target, prop) {
3276
+ if ("string" != typeof prop || !delete target[prop]) {
3277
+ return false;
3278
+ }
3279
+ triggerEffects(this.$container$, this, getEffects(target, prop, this.$effects$));
3280
+ return true;
3269
3281
  }
3270
- toJSON() {
3271
- return {
3272
- value: this.$untrackedValue$
3273
- };
3274
- }
3275
- };
3276
- var ensureContains = (array, value) => {
3277
- const isMissing = -1 === array.indexOf(value);
3278
- isMissing && array.push(value);
3279
- };
3280
- var ensureContainsEffect = (array, effectSubscriptions) => {
3281
- for (let i = 0; i < array.length; i++) {
3282
- const existingEffect = array[i];
3283
- if (existingEffect[0] === effectSubscriptions[0] && existingEffect[1] === effectSubscriptions[1]) {
3284
- return;
3285
- }
3286
- }
3287
- array.push(effectSubscriptions);
3288
- };
3289
- var ensureEffectContainsSubscriber = (effect, subscriber, container) => {
3290
- if (isSubscriber(effect)) {
3291
- effect.$effectDependencies$ ||= [];
3292
- if (subscriberExistInSubscribers(effect.$effectDependencies$, subscriber)) {
3293
- return;
3294
- }
3295
- effect.$effectDependencies$.push(subscriber);
3296
- } else if (vnode_isVNode(effect) && vnode_isVirtualVNode(effect)) {
3297
- let subscribers = vnode_getProp(effect, QSubscribers, container ? container.$getObjectById$ : null);
3298
- subscribers ||= [];
3299
- if (subscriberExistInSubscribers(subscribers, subscriber)) {
3300
- return;
3301
- }
3302
- subscribers.push(subscriber);
3303
- vnode_setProp(effect, QSubscribers, subscribers);
3304
- } else if (isSSRNode(effect)) {
3305
- let subscribers = effect.getProp(QSubscribers);
3306
- subscribers ||= [];
3307
- if (subscriberExistInSubscribers(subscribers, subscriber)) {
3308
- return;
3309
- }
3310
- subscribers.push(subscriber);
3311
- effect.setProp(QSubscribers, subscribers);
3312
- }
3313
- };
3314
- var isSSRNode = effect => "setProp" in effect && "getProp" in effect && "removeProp" in effect && "id" in effect;
3315
- var subscriberExistInSubscribers = (subscribers, subscriber) => {
3316
- for (let i = 0; i < subscribers.length; i++) {
3317
- if (subscribers[i] === subscriber) {
3282
+ has(target, prop) {
3283
+ if (prop === STORE_TARGET) {
3318
3284
  return true;
3319
3285
  }
3320
- }
3321
- return false;
3322
- };
3323
- var triggerEffects = (container, signal, effects) => {
3324
- if (effects) {
3325
- const scheduleEffect = effectSubscriptions => {
3326
- const effect = effectSubscriptions[0];
3327
- const property = effectSubscriptions[1];
3328
- assertDefined(container, "Container must be defined.");
3329
- if (isTask(effect)) {
3330
- effect.$flags$ |= 8;
3331
- DEBUG && log("schedule.effect.task", pad("\n" + String(effect), " "));
3332
- let choreType = 3;
3333
- 1 & effect.$flags$ ? choreType = 64 : 4 & effect.$flags$ && (choreType = 2);
3334
- container.$scheduler$(choreType, effect);
3335
- } else if (effect instanceof Signal) {
3336
- effect instanceof ComputedSignal && (effect.$computeQrl$.resolved || container.$scheduler$(1, null, effect.$computeQrl$));
3337
- try {
3338
- retryOnPromise((() => effect.$invalidate$()));
3339
- } catch (e) {
3340
- logError(e);
3341
- }
3342
- } else if (":" === property) {
3343
- const host = effect;
3344
- const qrl2 = container.getHostProp(host, OnRenderProp);
3345
- assertDefined(qrl2, "Component must have QRL");
3346
- const props = container.getHostProp(host, ELEMENT_PROPS);
3347
- container.$scheduler$(7, host, qrl2, props);
3348
- } else if ("." === property) {
3349
- const host = effect;
3350
- const target = host;
3351
- container.$scheduler$(4, host, target, signal);
3352
- } else {
3353
- const host = effect;
3354
- let effectData = effectSubscriptions[2];
3355
- if (effectData instanceof EffectData) {
3356
- const data = effectData.data;
3357
- const payload = {
3358
- ...data,
3359
- $value$: signal
3360
- };
3361
- container.$scheduler$(5, host, property, payload);
3362
- }
3286
+ if ("string" === typeof prop) {
3287
+ const ctx = tryGetInvokeContext();
3288
+ if (ctx) {
3289
+ const effectSubscriber = ctx.$effectSubscriber$;
3290
+ effectSubscriber && addEffect(target, Array.isArray(target) ? STORE_ARRAY_PROP : prop, this, effectSubscriber);
3363
3291
  }
3364
- };
3365
- effects.forEach(scheduleEffect);
3366
- }
3367
- DEBUG && log("done scheduling");
3368
- };
3369
- var ComputedSignal = class extends Signal {
3370
- $computeQrl$;
3371
- $invalid$=true;
3372
- constructor(container, fn) {
3373
- super(container, NEEDS_COMPUTATION);
3374
- this.$computeQrl$ = fn;
3375
- }
3376
- $invalidate$() {
3377
- var _a;
3378
- this.$invalid$ = true;
3379
- if (!(null == (_a = this.$effects$) ? void 0 : _a.length)) {
3380
- return;
3381
3292
  }
3382
- this.$computeIfNeeded$() && triggerEffects(this.$container$, this, this.$effects$);
3383
- }
3384
- force() {
3385
- this.$invalid$ = true;
3386
- triggerEffects(this.$container$, this, this.$effects$);
3387
- }
3388
- get untrackedValue() {
3389
- this.$computeIfNeeded$();
3390
- assertFalse(this.$untrackedValue$ === NEEDS_COMPUTATION, "Invalid state");
3391
- return this.$untrackedValue$;
3293
+ return Object.prototype.hasOwnProperty.call(target, prop);
3392
3294
  }
3393
- $computeIfNeeded$() {
3394
- if (!this.$invalid$) {
3395
- return false;
3396
- }
3397
- const computeQrl = this.$computeQrl$;
3398
- throwIfQRLNotResolved(computeQrl);
3295
+ ownKeys(target) {
3399
3296
  const ctx = tryGetInvokeContext();
3400
- const previousEffectSubscription = null == ctx ? void 0 : ctx.$effectSubscriber$;
3401
- ctx && (ctx.$effectSubscriber$ = [ this, "." ]);
3402
- try {
3403
- const untrackedValue = computeQrl.getFn(ctx)();
3404
- isPromise(untrackedValue) && throwErrorAndStop(`useComputedSignal$ QRL ${computeQrl.dev ? `${computeQrl.dev.file} ` : ""}${computeQrl.$hash$} returned a Promise`);
3405
- DEBUG && log("Signal.$compute$", untrackedValue);
3406
- this.$invalid$ = false;
3407
- const didChange = untrackedValue !== this.$untrackedValue$;
3408
- didChange && (this.$untrackedValue$ = untrackedValue);
3409
- return didChange;
3410
- } finally {
3411
- ctx && (ctx.$effectSubscriber$ = previousEffectSubscription);
3412
- }
3413
- }
3414
- get value() {
3415
- return super.value;
3297
+ const effectSubscriber = null == ctx ? void 0 : ctx.$effectSubscriber$;
3298
+ effectSubscriber && addEffect(target, STORE_ARRAY_PROP, this, effectSubscriber);
3299
+ return Reflect.ownKeys(target);
3416
3300
  }
3417
- set value(_) {
3418
- throwErrorAndStop("ComputedSignal is read-only");
3301
+ getOwnPropertyDescriptor(target, prop) {
3302
+ if (Array.isArray(target) || "symbol" === typeof prop) {
3303
+ return Object.getOwnPropertyDescriptor(target, prop);
3304
+ }
3305
+ return {
3306
+ enumerable: true,
3307
+ configurable: true
3308
+ };
3419
3309
  }
3420
3310
  };
3421
- var WrappedSignal = class extends Signal {
3422
- $args$;
3423
- $func$;
3424
- $funcStr$;
3425
- $invalid$=true;
3426
- $effectDependencies$=null;
3427
- constructor(container, fn, args, fnStr) {
3428
- super(container, NEEDS_COMPUTATION);
3429
- this.$args$ = args;
3430
- this.$func$ = fn;
3431
- this.$funcStr$ = fnStr;
3432
- }
3433
- $invalidate$() {
3434
- var _a;
3435
- this.$invalid$ = true;
3436
- if (!(null == (_a = this.$effects$) ? void 0 : _a.length)) {
3437
- return;
3438
- }
3439
- this.$computeIfNeeded$() && triggerEffects(this.$container$, this, this.$effects$);
3311
+ function addEffect(target, prop, store, effectSubscriber) {
3312
+ const effectsMap = store.$effects$ ||= {};
3313
+ const effects = Object.prototype.hasOwnProperty.call(effectsMap, prop) && effectsMap[prop] || (effectsMap[prop] = []);
3314
+ ensureContainsEffect(effects, effectSubscriber);
3315
+ ensureContains(effectSubscriber, target);
3316
+ DEBUG && log("sub", pad("\n" + store.$effects$.toString(), " "));
3317
+ }
3318
+ function setNewValueAndTriggerEffects(prop, value, target, currentStore) {
3319
+ target[prop] = value;
3320
+ triggerEffects(currentStore.$container$, currentStore, getEffects(target, prop, currentStore.$effects$));
3321
+ }
3322
+ function getEffects(target, prop, storeEffects) {
3323
+ let effectsToTrigger = storeEffects ? Array.isArray(target) ? Object.values(storeEffects).flatMap((effects => effects)) : storeEffects[prop] : null;
3324
+ const storeArrayValue = null == storeEffects ? void 0 : storeEffects[STORE_ARRAY_PROP];
3325
+ if (storeArrayValue) {
3326
+ effectsToTrigger ||= [];
3327
+ effectsToTrigger.push(...storeArrayValue);
3440
3328
  }
3441
- force() {
3442
- this.$invalid$ = true;
3443
- triggerEffects(this.$container$, this, this.$effects$);
3329
+ return effectsToTrigger;
3330
+ }
3331
+ var Subscriber = class {
3332
+ $effectDependencies$=null;
3333
+ };
3334
+ function isSubscriber(value) {
3335
+ return value instanceof Subscriber || value instanceof WrappedSignal;
3336
+ }
3337
+ function clearVNodeEffectDependencies(container, value) {
3338
+ vnode_isElementVNode(value) && ensureMaterialized(value);
3339
+ const effects = vnode_getProp(value, QSubscribers, container.$getObjectById$);
3340
+ if (!effects) {
3341
+ return;
3444
3342
  }
3445
- get untrackedValue() {
3446
- this.$computeIfNeeded$();
3447
- assertFalse(this.$untrackedValue$ === NEEDS_COMPUTATION, "Invalid state");
3448
- return this.$untrackedValue$;
3343
+ for (let i = effects.length - 1; i >= 0; i--) {
3344
+ const subscriber = effects[i];
3345
+ const subscriptionRemoved = clearEffects(subscriber, value);
3346
+ subscriptionRemoved && effects.splice(i, 1);
3449
3347
  }
3450
- $computeIfNeeded$() {
3451
- if (!this.$invalid$) {
3452
- return false;
3348
+ }
3349
+ function clearSubscriberEffectDependencies(value) {
3350
+ if (value.$effectDependencies$) {
3351
+ for (let i = value.$effectDependencies$.length - 1; i >= 0; i--) {
3352
+ const subscriber = value.$effectDependencies$[i];
3353
+ const subscriptionRemoved = clearEffects(subscriber, value);
3354
+ subscriptionRemoved && value.$effectDependencies$.splice(i, 1);
3453
3355
  }
3454
- const untrackedValue = trackSignal((() => this.$func$(...this.$args$)), this, ".", this.$container$);
3455
- const didChange = untrackedValue !== this.$untrackedValue$;
3456
- didChange && (this.$untrackedValue$ = untrackedValue);
3457
- return didChange;
3458
3356
  }
3459
- get value() {
3460
- return super.value;
3357
+ }
3358
+ function clearEffects(subscriber, value) {
3359
+ if (!isSignal(subscriber)) {
3360
+ return false;
3461
3361
  }
3462
- set value(_) {
3463
- throwErrorAndStop("WrappedSignal is read-only");
3362
+ const effectSubscriptions = subscriber.$effects$;
3363
+ const hostElement = subscriber.$hostElement$;
3364
+ hostElement && hostElement === value && (subscriber.$hostElement$ = null);
3365
+ let subscriptionRemoved = false;
3366
+ if (effectSubscriptions) {
3367
+ for (let i = effectSubscriptions.length - 1; i >= 0; i--) {
3368
+ const effect = effectSubscriptions[i];
3369
+ if (effect[0] === value) {
3370
+ effectSubscriptions.splice(i, 1);
3371
+ subscriptionRemoved = true;
3372
+ }
3373
+ }
3464
3374
  }
3465
- };
3466
- var DEBUG2 = false;
3467
- var log2 = (...args) => console.log("STORE", ...args.map(qwikDebugToString));
3468
- var STORE_TARGET = Symbol("store.target");
3469
- var STORE_HANDLER = Symbol("store.handler");
3470
- var STORE_ARRAY_PROP = Symbol("store.array");
3471
- var getStoreHandler = value => value[STORE_HANDLER];
3472
- var getStoreTarget = value => (null == value ? void 0 : value[STORE_TARGET]) || null;
3473
- var unwrapStore = value => getStoreTarget(value) || value;
3474
- var isStore = value => STORE_TARGET in value;
3475
- function createStore(container, obj, flags) {
3476
- return new Proxy(obj, new StoreHandler(flags, container || null));
3477
- }
3478
- var getOrCreateStore = (obj, flags, container) => {
3479
- if (isSerializableObject(obj) && container) {
3480
- let store = container.$storeProxyMap$.get(obj);
3481
- if (!store) {
3482
- store = createStore(container, obj, flags);
3483
- container.$storeProxyMap$.set(obj, store);
3375
+ const args = subscriber.$args$;
3376
+ if (args) {
3377
+ for (let i = args.length - 1; i >= 0; i--) {
3378
+ clearEffects(args[i], subscriber);
3484
3379
  }
3485
- return store;
3486
3380
  }
3487
- return obj;
3488
- };
3489
- var StoreHandler = class {
3490
- constructor($flags$, $container$) {
3491
- this.$flags$ = $flags$;
3492
- this.$container$ = $container$;
3493
- }
3494
- $effects$=null;
3495
- toString() {
3496
- return "[Store]";
3497
- }
3498
- get(target, prop) {
3499
- if ("symbol" === typeof prop) {
3500
- if (prop === STORE_TARGET) {
3501
- return target;
3502
- }
3503
- if (prop === STORE_HANDLER) {
3504
- return this;
3505
- }
3506
- return target[prop];
3507
- }
3508
- const ctx = tryGetInvokeContext();
3509
- const value = target[prop];
3510
- if (ctx) {
3511
- if (null === this.$container$) {
3512
- if (!ctx.$container$) {
3513
- return value;
3514
- }
3515
- this.$container$ = ctx.$container$;
3516
- } else {
3517
- assertTrue(!ctx.$container$ || ctx.$container$ === this.$container$, "Do not use signals across containers");
3518
- }
3519
- const effectSubscriber = ctx.$effectSubscriber$;
3520
- effectSubscriber && addEffect(target, Array.isArray(target) ? STORE_ARRAY_PROP : prop, this, effectSubscriber);
3521
- }
3522
- if ("toString" === prop && value === Object.prototype.toString) {
3523
- return this.toString;
3524
- }
3525
- const flags = this.$flags$;
3526
- if (1 & flags && "object" === typeof value && null !== value && !Object.isFrozen(value) && !isStore(value) && !Object.isFrozen(target)) {
3527
- return getOrCreateStore(value, this.$flags$, this.$container$);
3528
- }
3529
- return value;
3530
- }
3531
- set(target, prop, value) {
3532
- target = unwrapDeserializerProxy(target);
3533
- if ("symbol" === typeof prop) {
3534
- target[prop] = value;
3535
- return true;
3536
- }
3537
- const newValue = 1 & this.$flags$ ? unwrapStore(value) : value;
3538
- if (prop in target) {
3539
- const oldValue = target[prop];
3540
- if (newValue !== oldValue) {
3541
- DEBUG2 && log2("Store.set", oldValue, "->", newValue, pad("\n" + this.toString(), " "));
3542
- setNewValueAndTriggerEffects(prop, newValue, target, this);
3543
- }
3544
- } else {
3545
- DEBUG2 && log2("Store.set", "create property", newValue, pad("\n" + this.toString(), " "));
3546
- setNewValueAndTriggerEffects(prop, newValue, target, this);
3547
- }
3548
- return true;
3549
- }
3550
- deleteProperty(target, prop) {
3551
- if ("string" != typeof prop || !delete target[prop]) {
3552
- return false;
3553
- }
3554
- triggerEffects(this.$container$, this, getEffects(target, prop, this.$effects$));
3555
- return true;
3556
- }
3557
- has(target, prop) {
3558
- if (prop === STORE_TARGET) {
3559
- return true;
3560
- }
3561
- if ("string" === typeof prop) {
3562
- const ctx = tryGetInvokeContext();
3563
- if (ctx) {
3564
- const effectSubscriber = ctx.$effectSubscriber$;
3565
- effectSubscriber && addEffect(target, Array.isArray(target) ? STORE_ARRAY_PROP : prop, this, effectSubscriber);
3566
- }
3567
- }
3568
- return Object.prototype.hasOwnProperty.call(target, prop);
3569
- }
3570
- ownKeys(target) {
3571
- const ctx = tryGetInvokeContext();
3572
- const effectSubscriber = null == ctx ? void 0 : ctx.$effectSubscriber$;
3573
- effectSubscriber && addEffect(target, STORE_ARRAY_PROP, this, effectSubscriber);
3574
- return Reflect.ownKeys(target);
3575
- }
3576
- getOwnPropertyDescriptor(target, prop) {
3577
- if (Array.isArray(target) || "symbol" === typeof prop) {
3578
- return Object.getOwnPropertyDescriptor(target, prop);
3579
- }
3580
- return {
3581
- enumerable: true,
3582
- configurable: true
3583
- };
3584
- }
3585
- };
3586
- function addEffect(target, prop, store, effectSubscriber) {
3587
- const effectsMap = store.$effects$ ||= {};
3588
- const effects = Object.prototype.hasOwnProperty.call(effectsMap, prop) && effectsMap[prop] || (effectsMap[prop] = []);
3589
- ensureContainsEffect(effects, effectSubscriber);
3590
- ensureContains(effectSubscriber, target);
3591
- DEBUG2 && log2("sub", pad("\n" + store.$effects$.toString(), " "));
3592
- }
3593
- function setNewValueAndTriggerEffects(prop, value, target, currentStore) {
3594
- target[prop] = value;
3595
- triggerEffects(currentStore.$container$, currentStore, getEffects(target, prop, currentStore.$effects$));
3596
- }
3597
- function getEffects(target, prop, storeEffects) {
3598
- let effectsToTrigger = storeEffects ? Array.isArray(target) ? Object.values(storeEffects).flatMap((effects => effects)) : storeEffects[prop] : null;
3599
- const storeArrayValue = null == storeEffects ? void 0 : storeEffects[STORE_ARRAY_PROP];
3600
- if (storeArrayValue) {
3601
- effectsToTrigger ||= [];
3602
- effectsToTrigger.push(...storeArrayValue);
3603
- }
3604
- return effectsToTrigger;
3605
- }
3606
- var _createResourceReturn = opts => {
3607
- const resource = {
3608
- __brand: "resource",
3609
- value: void 0,
3610
- loading: !isServerPlatform(),
3611
- _resolved: void 0,
3612
- _error: void 0,
3613
- _state: "pending",
3614
- _timeout: (null == opts ? void 0 : opts.timeout) ?? -1,
3615
- _cache: 0
3616
- };
3617
- return resource;
3381
+ return subscriptionRemoved;
3382
+ }
3383
+ var _createResourceReturn = opts => {
3384
+ const resource = {
3385
+ __brand: "resource",
3386
+ value: void 0,
3387
+ loading: !isServerPlatform(),
3388
+ _resolved: void 0,
3389
+ _error: void 0,
3390
+ _state: "pending",
3391
+ _timeout: (null == opts ? void 0 : opts.timeout) ?? -1,
3392
+ _cache: 0
3393
+ };
3394
+ return resource;
3618
3395
  };
3619
3396
  var createResourceReturn = (container, opts, initialPromise) => {
3620
3397
  const result = _createResourceReturn(opts);
@@ -3721,105 +3498,6 @@ globalThis.qwikOptimizer = function(module) {
3721
3498
  return promise;
3722
3499
  };
3723
3500
  var ignoreErrorToPreventNodeFromCrashing = err => {};
3724
- var Slot = props => _jsxSorted(Virtual, null, {
3725
- [QSlotS]: ""
3726
- }, props.children, 0, props.name ?? "");
3727
- var SkipRender = Symbol("skip render");
3728
- var SSRRaw = () => null;
3729
- var SSRComment = () => null;
3730
- 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" ]);
3731
- var isUnitlessNumber = name => unitlessNumbers.has(name);
3732
- var serializeClass = obj => {
3733
- if (!obj) {
3734
- return "";
3735
- }
3736
- if (isString(obj)) {
3737
- return obj.trim();
3738
- }
3739
- const classes = [];
3740
- if (isArray(obj)) {
3741
- for (const o of obj) {
3742
- const classList = serializeClass(o);
3743
- classList && classes.push(classList);
3744
- }
3745
- } else {
3746
- for (const [key, value] of Object.entries(obj)) {
3747
- value && classes.push(key.trim());
3748
- }
3749
- }
3750
- return classes.join(" ");
3751
- };
3752
- var fromCamelToKebabCaseWithDash = text => text.replace(/([A-Z])/g, "-$1").toLowerCase();
3753
- var stringifyStyle = obj => {
3754
- if (null == obj) {
3755
- return "";
3756
- }
3757
- if ("object" == typeof obj) {
3758
- if (isArray(obj)) {
3759
- throw qError(QError_stringifyClassOrStyle, obj, "style");
3760
- }
3761
- {
3762
- const chunks = [];
3763
- for (const key in obj) {
3764
- if (Object.prototype.hasOwnProperty.call(obj, key)) {
3765
- const value = obj[key];
3766
- null != value && "function" !== typeof value && (key.startsWith("--") ? chunks.push(key + ":" + value) : chunks.push(fromCamelToKebabCaseWithDash(key) + ":" + setValueForStyle(key, value)));
3767
- }
3768
- }
3769
- return chunks.join(";");
3770
- }
3771
- }
3772
- return String(obj);
3773
- };
3774
- var serializeBooleanOrNumberAttribute = value => null != value ? String(value) : null;
3775
- function serializeAttribute(key, value, styleScopedId) {
3776
- if (isClassAttr(key)) {
3777
- const serializedClass = serializeClass(value);
3778
- value = styleScopedId ? styleScopedId + (serializedClass.length ? " " + serializedClass : serializedClass) : serializedClass;
3779
- } else {
3780
- "style" === key ? value = stringifyStyle(value) : isEnumeratedBooleanAttribute(key) || "number" === typeof value ? value = serializeBooleanOrNumberAttribute(value) : false === value || null == value ? value = null : true === value && isPreventDefault(key) && (value = "");
3781
- }
3782
- return value;
3783
- }
3784
- function isEnumeratedBooleanAttribute(key) {
3785
- return isAriaAttribute(key) || [ "spellcheck", "draggable", "contenteditable" ].includes(key);
3786
- }
3787
- var setValueForStyle = (styleName, value) => {
3788
- if ("number" === typeof value && 0 !== value && !isUnitlessNumber(styleName)) {
3789
- return value + "px";
3790
- }
3791
- return value;
3792
- };
3793
- function isAriaAttribute(prop) {
3794
- return prop.startsWith("aria-");
3795
- }
3796
- var styleContent = styleId => ComponentStylesPrefixContent + styleId;
3797
- function hasClassAttr(props) {
3798
- for (const key in props) {
3799
- if (Object.prototype.hasOwnProperty.call(props, key) && isClassAttr(key)) {
3800
- return true;
3801
- }
3802
- }
3803
- return false;
3804
- }
3805
- function isClassAttr(key) {
3806
- return "class" === key || "className" === key;
3807
- }
3808
- function convertScopedStyleIdsToArray(scopedStyleIds) {
3809
- return (null == scopedStyleIds ? void 0 : scopedStyleIds.split(" ")) ?? null;
3810
- }
3811
- function convertStyleIdsToString(scopedStyleIds) {
3812
- return Array.from(scopedStyleIds).join(" ");
3813
- }
3814
- var addComponentStylePrefix = styleId => {
3815
- if (styleId) {
3816
- let idx = 0;
3817
- do {
3818
- styleId = styleId.substring(0, idx) + styleContent(styleId.substring(idx));
3819
- } while (0 !== (idx = styleId.indexOf(" ", idx) + 1));
3820
- }
3821
- return styleId || null;
3822
- };
3823
3501
  var isForeignObjectElement = elementName => "foreignobject" === elementName.toLowerCase();
3824
3502
  var isSvgElement = elementName => "svg" === elementName || isForeignObjectElement(elementName);
3825
3503
  var isMathElement = elementName => "math" === elementName;
@@ -3992,7 +3670,7 @@ globalThis.qwikOptimizer = function(module) {
3992
3670
  container.setHostProp(renderHost, USE_ON_LOCAL_SEQ_IDX, null);
3993
3671
  container.getHostProp(renderHost, ELEMENT_PROPS) !== props && container.setHostProp(renderHost, ELEMENT_PROPS, props);
3994
3672
  }
3995
- vnode_isVNode(renderHost) && clearVNodeEffectDependencies(renderHost);
3673
+ vnode_isVNode(renderHost) && clearVNodeEffectDependencies(container, renderHost);
3996
3674
  return componentFn(props);
3997
3675
  }), (jsx2 => {
3998
3676
  const useOnEvents = container.getHostProp(renderHost, USE_ON_LOCAL);
@@ -4077,6 +3755,12 @@ globalThis.qwikOptimizer = function(module) {
4077
3755
  }
4078
3756
  return null;
4079
3757
  }
3758
+ function isSlotProp(prop) {
3759
+ return !prop.startsWith("q:") && !prop.startsWith(NON_SERIALIZABLE_MARKER_PREFIX);
3760
+ }
3761
+ function isParentSlotProp(prop) {
3762
+ return prop.startsWith(QSlotParent);
3763
+ }
4080
3764
  function escapeHTML(html) {
4081
3765
  let escapedHTML = "";
4082
3766
  const length = html.length;
@@ -4136,9 +3820,9 @@ globalThis.qwikOptimizer = function(module) {
4136
3820
  if (Array.isArray(jsxValue)) {
4137
3821
  descend(jsxValue, false);
4138
3822
  } else if (isSignal(jsxValue)) {
4139
- vCurrent && clearVNodeEffectDependencies(vCurrent);
3823
+ vCurrent && clearVNodeEffectDependencies(container, vCurrent);
4140
3824
  expectVirtual("S", null);
4141
- descend(trackSignal((() => jsxValue.value), vNewNode || vCurrent, ".", container), true);
3825
+ descend(trackSignalAndAssignHost(jsxValue, vNewNode || vCurrent, ".", container), true);
4142
3826
  } else if (isPromise(jsxValue)) {
4143
3827
  expectVirtual("A", null);
4144
3828
  asyncQueue.push(jsxValue, vNewNode || vCurrent);
@@ -4335,7 +4019,7 @@ globalThis.qwikOptimizer = function(module) {
4335
4019
  if (constProps && "object" == typeof constProps && "name" in constProps) {
4336
4020
  const constValue = constProps.name;
4337
4021
  if (vHost && constValue instanceof WrappedSignal) {
4338
- return trackSignal((() => constValue.value), vHost, ":", container);
4022
+ return trackSignalAndAssignHost(constValue, vHost, ":", container);
4339
4023
  }
4340
4024
  }
4341
4025
  return directGetPropsProxyProp(jsxNode2, "name") || QDefaultSlot;
@@ -4409,11 +4093,11 @@ globalThis.qwikOptimizer = function(module) {
4409
4093
  }
4410
4094
  }
4411
4095
  if (isSignal(value)) {
4412
- const signalData = new EffectData({
4096
+ const signalData = new EffectPropData({
4413
4097
  $scopedStyleIdPrefix$: scopedStyleIdPrefix,
4414
4098
  $isConst$: true
4415
4099
  });
4416
- value = trackSignal((() => value.value), vNewNode, key2, container, signalData);
4100
+ value = trackSignalAndAssignHost(value, vNewNode, key2, container, signalData);
4417
4101
  }
4418
4102
  if (key2 === dangerouslySetInnerHTML) {
4419
4103
  element.innerHTML = value;
@@ -4422,7 +4106,9 @@ globalThis.qwikOptimizer = function(module) {
4422
4106
  }
4423
4107
  if ("textarea" === elementName && "value" === key2) {
4424
4108
  if ("string" !== typeof value) {
4425
- isDev && throwErrorAndStop("The value of the textarea must be a string");
4109
+ if (isDev) {
4110
+ throw qError(40);
4111
+ }
4426
4112
  continue;
4427
4113
  }
4428
4114
  element.value = escapeHTML(value);
@@ -4475,9 +4161,9 @@ globalThis.qwikOptimizer = function(module) {
4475
4161
  const eventProp = ":" + scope.substring(1) + ":" + eventName;
4476
4162
  const qrls = [ vnode_getProp(vNode, eventProp, null), vnode_getProp(vNode, HANDLER_PREFIX + eventProp, null) ];
4477
4163
  let returnValue = false;
4478
- qrls.flat(2).forEach((qrl2 => {
4479
- if (qrl2) {
4480
- const value = qrl2(event, element);
4164
+ qrls.flat(2).forEach((qrl => {
4165
+ if (qrl) {
4166
+ const value = qrl(event, element);
4481
4167
  returnValue = returnValue || true === value;
4482
4168
  }
4483
4169
  }));
@@ -4526,7 +4212,7 @@ globalThis.qwikOptimizer = function(module) {
4526
4212
  eventName && registerQwikLoaderEvent(eventName);
4527
4213
  };
4528
4214
  while (null !== srcKey || null !== dstKey) {
4529
- if ((null == dstKey ? void 0 : dstKey.startsWith(HANDLER_PREFIX)) || dstKey == ELEMENT_KEY) {
4215
+ if ((null == dstKey ? void 0 : dstKey.startsWith(HANDLER_PREFIX)) || (null == dstKey ? void 0 : dstKey.startsWith(Q_PREFIX))) {
4530
4216
  dstIdx++;
4531
4217
  dstKey = dstIdx < dstLength ? dstAttrs[dstIdx++] : null;
4532
4218
  } else if (null == srcKey) {
@@ -4680,7 +4366,7 @@ globalThis.qwikOptimizer = function(module) {
4680
4366
  }
4681
4367
  }
4682
4368
  function insertNewComponent(host, componentQRL, jsxProps) {
4683
- host && clearVNodeEffectDependencies(host);
4369
+ host && clearVNodeEffectDependencies(container, host);
4684
4370
  vnode_insertBefore(journal, vParent, vNewNode = vnode_newVirtual(), vCurrent && getInsertBefore());
4685
4371
  const jsxNode2 = jsxValue;
4686
4372
  isDev && vnode_setProp(vNewNode, DEBUG_TYPE, "C");
@@ -4719,16 +4405,16 @@ globalThis.qwikOptimizer = function(module) {
4719
4405
  if (null == vNode) {
4720
4406
  return null;
4721
4407
  }
4722
- const qrl2 = vnode_getProp(vNode, OnRenderProp, getObject);
4723
- return qrl2 ? qrl2.$hash$ : null;
4408
+ const qrl = vnode_getProp(vNode, OnRenderProp, getObject);
4409
+ return qrl ? qrl.$hash$ : null;
4724
4410
  }
4725
4411
  function Projection() {}
4726
4412
  function propsDiffer(src, dst) {
4727
4413
  if (!src || !dst) {
4728
4414
  return true;
4729
4415
  }
4730
- let srcKeys = removeChildrenKey(Object.keys(src));
4731
- let dstKeys = removeChildrenKey(Object.keys(dst));
4416
+ let srcKeys = removePropsKeys(Object.keys(src), [ "children", QSubscribers ]);
4417
+ let dstKeys = removePropsKeys(Object.keys(dst), [ "children", QSubscribers ]);
4732
4418
  if (srcKeys.length !== dstKeys.length) {
4733
4419
  return true;
4734
4420
  }
@@ -4743,9 +4429,12 @@ globalThis.qwikOptimizer = function(module) {
4743
4429
  }
4744
4430
  return false;
4745
4431
  }
4746
- function removeChildrenKey(keys2) {
4747
- const childrenIdx = keys2.indexOf("children");
4748
- -1 !== childrenIdx && keys2.splice(childrenIdx, 1);
4432
+ function removePropsKeys(keys2, propKeys) {
4433
+ for (let i = propKeys.length - 1; i >= 0; i--) {
4434
+ const propKey = propKeys[i];
4435
+ const propIdx = keys2.indexOf(propKey);
4436
+ -1 !== propIdx && keys2.splice(propIdx, 1);
4437
+ }
4749
4438
  return keys2;
4750
4439
  }
4751
4440
  function cleanup(container, vNode) {
@@ -4757,9 +4446,9 @@ globalThis.qwikOptimizer = function(module) {
4757
4446
  do {
4758
4447
  const type = vCursor[0];
4759
4448
  if (3 & type) {
4449
+ clearVNodeEffectDependencies(container, vCursor);
4450
+ markVNodeAsDeleted(vCursor);
4760
4451
  if (2 & type) {
4761
- clearVNodeEffectDependencies(vCursor);
4762
- markVNodeAsDeleted(vCursor);
4763
4452
  const seq = container.getHostProp(vCursor, ELEMENT_SEQ);
4764
4453
  if (seq) {
4765
4454
  for (let i = 0; i < seq.length; i++) {
@@ -4767,7 +4456,7 @@ globalThis.qwikOptimizer = function(module) {
4767
4456
  if (isTask(obj)) {
4768
4457
  const task = obj;
4769
4458
  clearSubscriberEffectDependencies(task);
4770
- 1 & task.$flags$ ? container.$scheduler$(80, task) : cleanupTask(task);
4459
+ 1 & task.$flags$ ? container.$scheduler$(48, task) : cleanupTask(task);
4771
4460
  }
4772
4461
  }
4773
4462
  }
@@ -4846,18 +4535,15 @@ globalThis.qwikOptimizer = function(module) {
4846
4535
  }
4847
4536
  var HANDLER_PREFIX = ":";
4848
4537
  var count = 0;
4849
- var implicit$FirstArg = fn => function(first, ...rest) {
4850
- return fn.call(null, dollar(first), ...rest);
4851
- };
4852
- var DEBUG3 = false;
4538
+ var DEBUG2 = false;
4853
4539
  var createScheduler = (container, scheduleDrain, journalFlush) => {
4854
4540
  const choreQueue = [];
4855
4541
  let currentChore = null;
4856
4542
  let journalFlushScheduled = false;
4857
4543
  return schedule;
4858
4544
  function schedule(type, hostOrTask = null, targetOrQrl = null, payload = null) {
4859
- const runLater = 127 !== type && 16 !== type && 6 !== type;
4860
- const isTask2 = 3 === type || 64 === type || 2 === type || 80 === type;
4545
+ const runLater = 255 !== type && 6 !== type;
4546
+ const isTask2 = 3 === type || 32 === type || 2 === type || 48 === type;
4861
4547
  isTask2 && (hostOrTask.$flags$ |= 8);
4862
4548
  let chore = {
4863
4549
  $type$: type,
@@ -4871,11 +4557,11 @@ globalThis.qwikOptimizer = function(module) {
4871
4557
  $executed$: false
4872
4558
  };
4873
4559
  chore.$promise$ = new Promise((resolve => chore.$resolve$ = resolve));
4874
- DEBUG3 && debugTrace("schedule", chore, currentChore, choreQueue);
4560
+ DEBUG2 && debugTrace("schedule", chore, currentChore, choreQueue);
4875
4561
  chore = sortedInsert(choreQueue, chore);
4876
4562
  if (!journalFlushScheduled && runLater) {
4877
4563
  journalFlushScheduled = true;
4878
- schedule(48);
4564
+ schedule(16);
4879
4565
  scheduleDrain();
4880
4566
  }
4881
4567
  return runLater ? chore.$promise$ : drainUpTo(chore);
@@ -4897,8 +4583,8 @@ globalThis.qwikOptimizer = function(module) {
4897
4583
  break;
4898
4584
  }
4899
4585
  const isDeletedVNode = vNodeAlreadyDeleted(nextChore);
4900
- if (isDeletedVNode && 80 !== nextChore.$type$) {
4901
- DEBUG3 && debugTrace("skip chore", nextChore, currentChore, choreQueue);
4586
+ if (isDeletedVNode && 48 !== nextChore.$type$) {
4587
+ DEBUG2 && debugTrace("skip chore", nextChore, currentChore, choreQueue);
4902
4588
  continue;
4903
4589
  }
4904
4590
  const returnValue = executeChore(nextChore);
@@ -4910,13 +4596,14 @@ globalThis.qwikOptimizer = function(module) {
4910
4596
  return runUptoChore.$returnValue$;
4911
4597
  }
4912
4598
  function executeChore(chore) {
4599
+ var _a;
4913
4600
  const host = chore.$host$;
4914
- DEBUG3 && debugTrace("execute", chore, currentChore, choreQueue);
4601
+ DEBUG2 && debugTrace("execute", chore, currentChore, choreQueue);
4915
4602
  assertEqual(currentChore, null, "Chore already running.");
4916
4603
  currentChore = chore;
4917
4604
  let returnValue = null;
4918
4605
  switch (chore.$type$) {
4919
- case 48:
4606
+ case 16:
4920
4607
  returnValue = journalFlush();
4921
4608
  journalFlushScheduled = false;
4922
4609
  break;
@@ -4941,11 +4628,11 @@ globalThis.qwikOptimizer = function(module) {
4941
4628
  returnValue = runTask(chore.$payload$, container, host);
4942
4629
  break;
4943
4630
 
4944
- case 64:
4631
+ case 32:
4945
4632
  returnValue = runTask(chore.$payload$, container, host);
4946
4633
  break;
4947
4634
 
4948
- case 80:
4635
+ case 48:
4949
4636
  const task = chore.$payload$;
4950
4637
  cleanupTask(task);
4951
4638
  break;
@@ -4980,13 +4667,27 @@ globalThis.qwikOptimizer = function(module) {
4980
4667
  returnValue = target.resolved ? null : target.resolve();
4981
4668
  break;
4982
4669
  }
4670
+
4671
+ case 8:
4672
+ {
4673
+ const target = chore.$target$;
4674
+ const forceRunEffects = target.$forceRunEffects$;
4675
+ target.$forceRunEffects$ = false;
4676
+ if (!(null == (_a = target.$effects$) ? void 0 : _a.length)) {
4677
+ break;
4678
+ }
4679
+ returnValue = retryOnPromise((() => {
4680
+ (target.$computeIfNeeded$() || forceRunEffects) && triggerEffects(container, target, target.$effects$);
4681
+ }));
4682
+ break;
4683
+ }
4983
4684
  }
4984
4685
  return maybeThenPassError(returnValue, (value => {
4985
- var _a;
4986
- DEBUG3 && debugTrace("execute.DONE", null, currentChore, choreQueue);
4686
+ var _a2;
4687
+ DEBUG2 && debugTrace("execute.DONE", null, currentChore, choreQueue);
4987
4688
  if (currentChore) {
4988
4689
  currentChore.$executed$ = true;
4989
- null == (_a = currentChore.$resolve$) || _a.call(currentChore, value);
4690
+ null == (_a2 = currentChore.$resolve$) || _a2.call(currentChore, value);
4990
4691
  }
4991
4692
  currentChore = null;
4992
4693
  return chore.$returnValue$ = value;
@@ -5001,17 +4702,19 @@ globalThis.qwikOptimizer = function(module) {
5001
4702
  return !!(chore.$host$ && vnode_isVNode(chore.$host$) && 32 & chore.$host$[0]);
5002
4703
  }
5003
4704
  function choreComparator(a, b, shouldThrowOnHostMismatch) {
5004
- const macroTypeDiff = (112 & a.$type$) - (112 & b.$type$);
4705
+ const macroTypeDiff = (240 & a.$type$) - (240 & b.$type$);
5005
4706
  if (0 !== macroTypeDiff) {
5006
4707
  return macroTypeDiff;
5007
4708
  }
5008
- if (48 !== a.$type$) {
4709
+ if (16 !== a.$type$) {
5009
4710
  const aHost = a.$host$;
5010
4711
  const bHost = b.$host$;
5011
4712
  if (aHost !== bHost && null !== aHost && null !== bHost) {
5012
4713
  if (!vnode_isVNode(aHost) || !vnode_isVNode(bHost)) {
5013
4714
  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()}`;
5014
- shouldThrowOnHostMismatch && throwErrorAndStop(errorMessage);
4715
+ if (shouldThrowOnHostMismatch) {
4716
+ throw qError(45, [ errorMessage ]);
4717
+ }
5015
4718
  logWarn(errorMessage);
5016
4719
  return null;
5017
4720
  }
@@ -5030,7 +4733,7 @@ globalThis.qwikOptimizer = function(module) {
5030
4733
  if (0 !== idxDiff) {
5031
4734
  return idxDiff;
5032
4735
  }
5033
- if (a.$target$ !== b.$target$ && (1 === a.$type$ && 1 === b.$type$ || 5 === a.$type$ && 5 === b.$type$)) {
4736
+ if (a.$target$ !== b.$target$ && (1 === a.$type$ && 1 === b.$type$ || 5 === a.$type$ && 5 === b.$type$ || 8 === a.$type$ && 8 === b.$type$)) {
5034
4737
  return 1;
5035
4738
  }
5036
4739
  }
@@ -5074,11 +4777,11 @@ globalThis.qwikOptimizer = function(module) {
5074
4777
  5: "NODE_PROP",
5075
4778
  7: "COMPONENT",
5076
4779
  6: "COMPONENT_SSR",
5077
- 48: "JOURNAL_FLUSH",
5078
- 64: "VISIBLE",
5079
- 80: "CLEANUP_VISIBLE",
5080
- 127: "WAIT_FOR_ALL",
5081
- 16: "WAIT_FOR_COMPONENTS"
4780
+ 8: "RECOMPUTE_SIGNAL",
4781
+ 16: "JOURNAL_FLUSH",
4782
+ 32: "VISIBLE",
4783
+ 48: "CLEANUP_VISIBLE",
4784
+ 255: "WAIT_FOR_ALL"
5082
4785
  }[chore.$type$] || "UNKNOWN: " + chore.$type$;
5083
4786
  const host = String(chore.$host$).replaceAll(/\n.*/gim, "");
5084
4787
  const qrlTarget = null == (_a = chore.$target$) ? void 0 : _a.$symbol$;
@@ -5093,606 +4796,524 @@ globalThis.qwikOptimizer = function(module) {
5093
4796
  }));
5094
4797
  console.log(lines.join("\n ") + "\n");
5095
4798
  }
5096
- var version = "2.0.0-alpha.3-dev+418fd6d";
5097
- var _SharedContainer = class {
5098
- $version$;
5099
- $scheduler$;
5100
- $storeProxyMap$;
5101
- $locale$;
5102
- $getObjectById$;
5103
- $serverData$;
5104
- $currentUniqueId$=0;
5105
- $instanceHash$=null;
5106
- constructor(scheduleDrain, journalFlush, serverData, locale) {
5107
- this.$serverData$ = serverData;
5108
- this.$locale$ = locale;
5109
- this.$version$ = version;
5110
- this.$storeProxyMap$ = new WeakMap;
5111
- this.$getObjectById$ = _id => {
5112
- throw Error("Not implemented");
5113
- };
5114
- this.$scheduler$ = createScheduler(this, scheduleDrain, journalFlush);
5115
- }
5116
- trackSignalValue(signal, subscriber, property, data) {
5117
- return trackSignal((() => signal.value), subscriber, property, this, data);
5118
- }
5119
- serializationCtxFactory(NodeConstructor, DomRefConstructor, symbolToChunkResolver, writer, prepVNodeData) {
5120
- return createSerializationContext(NodeConstructor, DomRefConstructor, symbolToChunkResolver, this.getHostProp.bind(this), this.setHostProp.bind(this), this.$storeProxyMap$, writer, prepVNodeData);
5121
- }
5122
- };
5123
- var VNodeDataSeparator = {
5124
- REFERENCE_CH: "~",
5125
- REFERENCE: 126,
5126
- ADVANCE_1_CH: "!",
5127
- ADVANCE_1: 33,
5128
- ADVANCE_2_CH: '"',
5129
- ADVANCE_2: 34,
5130
- ADVANCE_4_CH: "#",
5131
- ADVANCE_4: 35,
5132
- ADVANCE_8_CH: "$",
5133
- ADVANCE_8: 36,
5134
- ADVANCE_16_CH: "%",
5135
- ADVANCE_16: 37,
5136
- ADVANCE_32_CH: "&",
5137
- ADVANCE_32: 38,
5138
- ADVANCE_64_CH: "'",
5139
- ADVANCE_64: 39,
5140
- ADVANCE_128_CH: "(",
5141
- ADVANCE_128: 40,
5142
- ADVANCE_256_CH: ")",
5143
- ADVANCE_256: 41,
5144
- ADVANCE_512_CH: "*",
5145
- ADVANCE_512: 42,
5146
- ADVANCE_1024_CH: "+",
5147
- ADVANCE_1024: 43,
5148
- ADVANCE_2048_CH: ",",
5149
- ADVANCE_2048: 44,
5150
- ADVANCE_4096_CH: "-",
5151
- ADVANCE_4096: 45,
5152
- ADVANCE_8192_CH: ".",
5153
- ADVANCE_8192: 46
5154
- };
5155
- var VNodeDataChar = {
5156
- OPEN: 123,
5157
- OPEN_CHAR: "{",
5158
- CLOSE: 125,
5159
- CLOSE_CHAR: "}",
5160
- SCOPED_STYLE: 59,
5161
- SCOPED_STYLE_CHAR: ";",
5162
- RENDER_FN: 60,
5163
- RENDER_FN_CHAR: "<",
5164
- ID: 61,
5165
- ID_CHAR: "=",
5166
- PROPS: 62,
5167
- PROPS_CHAR: ">",
5168
- SLOT_REF: 63,
5169
- SLOT_REF_CHAR: "?",
5170
- KEY: 64,
5171
- KEY_CHAR: "@",
5172
- SEQ: 91,
5173
- SEQ_CHAR: "[",
5174
- DON_T_USE: 93,
5175
- DON_T_USE_CHAR: "\\",
5176
- CONTEXT: 93,
5177
- CONTEXT_CHAR: "]",
5178
- SEQ_IDX: 94,
5179
- SEQ_IDX_CHAR: "^",
5180
- SEPARATOR: 124,
5181
- SEPARATOR_CHAR: "|",
5182
- SLOT: 126,
5183
- SLOT_CHAR: "~"
5184
- };
5185
- function processVNodeData(document2) {
5186
- const Q_CONTAINER = "q:container";
5187
- const Q_CONTAINER_END = "/" + Q_CONTAINER;
5188
- const Q_PROPS_SEPARATOR2 = ":";
5189
- const Q_SHADOW_ROOT = "q:shadowroot";
5190
- const Q_IGNORE = "q:ignore";
5191
- const Q_IGNORE_END = "/" + Q_IGNORE;
5192
- const Q_CONTAINER_ISLAND = "q:container-island";
5193
- const Q_CONTAINER_ISLAND_END = "/" + Q_CONTAINER_ISLAND;
5194
- const qDocument = document2;
5195
- const vNodeDataMap = qDocument.qVNodeData || (qDocument.qVNodeData = new WeakMap);
5196
- const prototype = document2.body;
5197
- const getter = (prototype2, name) => {
5198
- var _a;
5199
- let getter2;
5200
- while (prototype2 && !(getter2 = null == (_a = Object.getOwnPropertyDescriptor(prototype2, name)) ? void 0 : _a.get)) {
5201
- prototype2 = Object.getPrototypeOf(prototype2);
5202
- }
5203
- return getter2 || function() {
5204
- return this[name];
5205
- };
5206
- };
5207
- const getAttribute = prototype.getAttribute;
5208
- const hasAttribute = prototype.hasAttribute;
5209
- const getNodeType = getter(prototype, "nodeType");
5210
- const attachVnodeDataAndRefs = element => {
5211
- Array.from(element.querySelectorAll('script[type="qwik/vnode"]')).forEach((script => {
5212
- script.setAttribute("type", "x-qwik/vnode");
5213
- const qContainerElement = script.closest("[q\\:container]");
5214
- qContainerElement.qVnodeData = script.textContent;
5215
- qContainerElement.qVNodeRefs = new Map;
5216
- }));
5217
- element.querySelectorAll("[q\\:shadowroot]").forEach((parent => {
5218
- const shadowRoot = parent.shadowRoot;
5219
- shadowRoot && attachVnodeDataAndRefs(shadowRoot);
5220
- }));
5221
- };
5222
- attachVnodeDataAndRefs(document2);
5223
- let NodeType;
5224
- (NodeType2 => {
5225
- NodeType2[NodeType2.CONTAINER_MASK = 1] = "CONTAINER_MASK";
5226
- NodeType2[NodeType2.ELEMENT = 2] = "ELEMENT";
5227
- NodeType2[NodeType2.ELEMENT_CONTAINER = 3] = "ELEMENT_CONTAINER";
5228
- NodeType2[NodeType2.ELEMENT_SHADOW_ROOT = 6] = "ELEMENT_SHADOW_ROOT";
5229
- NodeType2[NodeType2.COMMENT_SKIP_START = 5] = "COMMENT_SKIP_START";
5230
- NodeType2[NodeType2.COMMENT_SKIP_END = 8] = "COMMENT_SKIP_END";
5231
- NodeType2[NodeType2.COMMENT_IGNORE_START = 16] = "COMMENT_IGNORE_START";
5232
- NodeType2[NodeType2.COMMENT_IGNORE_END = 32] = "COMMENT_IGNORE_END";
5233
- NodeType2[NodeType2.COMMENT_ISLAND_START = 65] = "COMMENT_ISLAND_START";
5234
- NodeType2[NodeType2.COMMENT_ISLAND_END = 128] = "COMMENT_ISLAND_END";
5235
- NodeType2[NodeType2.OTHER = 0] = "OTHER";
5236
- })(NodeType || (NodeType = {}));
5237
- const getFastNodeType = node => {
5238
- const nodeType = getNodeType.call(node);
5239
- if (1 === nodeType) {
5240
- const qContainer = getAttribute.call(node, Q_CONTAINER);
5241
- if (null === qContainer) {
5242
- if (hasAttribute.call(node, Q_SHADOW_ROOT)) {
5243
- return 6;
5244
- }
5245
- const isQElement = hasAttribute.call(node, Q_PROPS_SEPARATOR2);
5246
- return isQElement ? 2 : 0;
5247
- }
5248
- return 3;
5249
- }
5250
- if (8 === nodeType) {
5251
- const nodeValue = node.nodeValue || "";
5252
- if (nodeValue.startsWith(Q_CONTAINER_ISLAND)) {
5253
- return 65;
5254
- }
5255
- if (nodeValue.startsWith(Q_IGNORE)) {
5256
- return 16;
5257
- }
5258
- if (nodeValue.startsWith(Q_CONTAINER)) {
5259
- return 5;
5260
- }
5261
- if (nodeValue.startsWith(Q_CONTAINER_ISLAND_END)) {
5262
- return 128;
5263
- }
5264
- if (nodeValue.startsWith(Q_IGNORE_END)) {
5265
- return 32;
5266
- }
5267
- if (nodeValue.startsWith(Q_CONTAINER_END)) {
5268
- return 8;
4799
+ var runTask = (task, container, host) => {
4800
+ task.$flags$ &= -9;
4801
+ cleanupTask(task);
4802
+ const iCtx = newInvokeContext(container.$locale$, host, void 0, TaskEvent);
4803
+ iCtx.$container$ = container;
4804
+ const taskFn = task.$qrl$.getFn(iCtx, (() => clearSubscriberEffectDependencies(task)));
4805
+ const track = (obj, prop) => {
4806
+ const ctx = newInvokeContext();
4807
+ ctx.$effectSubscriber$ = [ task, ":" ];
4808
+ ctx.$container$ = container;
4809
+ return invoke(ctx, (() => {
4810
+ if (isFunction(obj)) {
4811
+ return obj();
5269
4812
  }
5270
- }
5271
- return 0;
4813
+ return prop ? obj[prop] : isSignal(obj) ? obj.value : obj;
4814
+ }));
5272
4815
  };
5273
- const isSeparator = ch => VNodeDataSeparator.ADVANCE_1 <= ch && ch <= VNodeDataSeparator.ADVANCE_8192;
5274
- const findVDataSectionEnd = (vData, start, end) => {
5275
- let depth = 0;
5276
- while (true) {
5277
- if (!(start < end)) {
5278
- break;
5279
- }
5280
- {
5281
- const ch = vData.charCodeAt(start);
5282
- if (0 === depth && isSeparator(ch)) {
5283
- break;
5284
- }
5285
- ch === VNodeDataChar.OPEN ? depth++ : ch === VNodeDataChar.CLOSE && depth--;
5286
- start++;
4816
+ const handleError = reason => container.handleError(reason, host);
4817
+ let cleanupFns = null;
4818
+ const cleanup2 = fn => {
4819
+ if ("function" == typeof fn) {
4820
+ if (!cleanupFns) {
4821
+ cleanupFns = [];
4822
+ task.$destroy$ = noSerialize((() => {
4823
+ task.$destroy$ = null;
4824
+ cleanupFns.forEach((fn2 => {
4825
+ try {
4826
+ fn2();
4827
+ } catch (err) {
4828
+ handleError(err);
4829
+ }
4830
+ }));
4831
+ }));
5287
4832
  }
4833
+ cleanupFns.push(fn);
5288
4834
  }
5289
- return start;
5290
4835
  };
5291
- const nextSibling = node => {
5292
- while (node && (node = node.nextSibling) && 0 === getFastNodeType(node)) {}
5293
- return node;
5294
- };
5295
- const firstChild = node => {
5296
- while (node && (node = node.firstChild) && 0 === getFastNodeType(node)) {}
5297
- return node;
5298
- };
5299
- const walkContainer = (walker2, containerNode, node, exitNode, vData, qVNodeRefs, prefix) => {
5300
- const vData_length = vData.length;
5301
- let elementIdx = 0;
5302
- let vNodeElementIndex = -1;
5303
- let vData_start = 0;
5304
- let vData_end = 0;
5305
- let ch = 0;
5306
- let needsToStoreRef = -1;
5307
- let nextNode = null;
5308
- const howManyElementsToSkip = () => {
5309
- let elementsToSkip = 0;
5310
- while (isSeparator(ch = vData.charCodeAt(vData_start))) {
5311
- elementsToSkip += 1 << ch - VNodeDataSeparator.ADVANCE_1;
5312
- vData_start++;
5313
- if (vData_start >= vData_length) {
5314
- break;
5315
- }
5316
- }
5317
- return elementsToSkip;
5318
- };
5319
- do {
5320
- if (node === exitNode) {
5321
- return;
5322
- }
5323
- nextNode = null;
5324
- const nodeType = node == containerNode ? 2 : getFastNodeType(node);
5325
- if (3 === nodeType) {
5326
- const container = node;
5327
- let cursor = node;
5328
- while (cursor && !(nextNode = nextSibling(cursor))) {
5329
- cursor = cursor.parentNode;
5330
- }
5331
- walkContainer(walker2, container, node, nextNode, container.qVnodeData || "", container.qVNodeRefs, prefix + " ");
5332
- } else if (16 === nodeType) {
5333
- let islandNode = node;
5334
- do {
5335
- islandNode = walker2.nextNode();
5336
- if (!islandNode) {
5337
- throw new Error(`Island inside \x3c!--${null == node ? void 0 : node.nodeValue}--\x3e not found!`);
5338
- }
5339
- } while (65 !== getFastNodeType(islandNode));
5340
- nextNode = null;
5341
- } else if (128 === nodeType) {
5342
- nextNode = node;
5343
- do {
5344
- nextNode = walker2.nextNode();
5345
- if (!nextNode) {
5346
- throw new Error("Ignore block not closed!");
5347
- }
5348
- } while (32 !== getFastNodeType(nextNode));
5349
- nextNode = null;
5350
- } else if (5 === nodeType) {
5351
- nextNode = node;
5352
- do {
5353
- nextNode = nextSibling(nextNode);
5354
- if (!nextNode) {
5355
- throw new Error(`\x3c!--${null == node ? void 0 : node.nodeValue}--\x3e not closed!`);
5356
- }
5357
- } while (8 !== getFastNodeType(nextNode));
5358
- walkContainer(walker2, node, node, nextNode, "", null, prefix + " ");
5359
- } else if (6 === nodeType) {
5360
- nextNode = nextSibling(node);
5361
- const shadowRootContainer = node;
5362
- const shadowRoot = null == shadowRootContainer ? void 0 : shadowRootContainer.shadowRoot;
5363
- shadowRoot && walkContainer(document2.createTreeWalker(shadowRoot, 129), null, firstChild(shadowRoot), null, "", null, prefix + " ");
5364
- }
5365
- if (2 === (2 & nodeType)) {
5366
- if (vNodeElementIndex < elementIdx) {
5367
- -1 === vNodeElementIndex && (vNodeElementIndex = 0);
5368
- vData_start = vData_end;
5369
- if (vData_start < vData_length) {
5370
- vNodeElementIndex += howManyElementsToSkip();
5371
- const shouldStoreRef = ch === VNodeDataSeparator.REFERENCE;
5372
- if (shouldStoreRef) {
5373
- needsToStoreRef = vNodeElementIndex;
5374
- vData_start++;
5375
- ch = vData_start < vData_length ? vData.charCodeAt(vData_end) : VNodeDataSeparator.ADVANCE_1;
5376
- }
5377
- vData_end = findVDataSectionEnd(vData, vData_start, vData_length);
5378
- } else {
5379
- vNodeElementIndex = Number.MAX_SAFE_INTEGER;
5380
- }
5381
- }
5382
- if (elementIdx === vNodeElementIndex) {
5383
- needsToStoreRef === elementIdx && qVNodeRefs.set(elementIdx, node);
5384
- const instructions = vData.substring(vData_start, vData_end);
5385
- vNodeDataMap.set(node, instructions);
5386
- }
5387
- elementIdx++;
5388
- }
5389
- } while (node = nextNode || walker2.nextNode());
4836
+ const taskApi = {
4837
+ track: track,
4838
+ cleanup: cleanup2
5390
4839
  };
5391
- const walker = document2.createTreeWalker(document2, 129);
5392
- walkContainer(walker, null, walker.firstChild(), null, "", null, "");
5393
- }
5394
- function getDomContainer(element) {
5395
- const qContainerElement = _getQContainerElement(element);
5396
- qContainerElement || throwErrorAndStop("Unable to find q:container.");
5397
- return getDomContainerFromQContainerElement(qContainerElement);
5398
- }
5399
- function getDomContainerFromQContainerElement(qContainerElement) {
5400
- const qElement = qContainerElement;
5401
- let container = qElement.qContainer;
5402
- if (!container) {
5403
- container = new DomContainer(qElement);
5404
- const containerAttributes = {};
5405
- if (qElement) {
5406
- const attrs = qElement.attributes;
5407
- if (attrs) {
5408
- for (let index = 0; index < attrs.length; index++) {
5409
- const attr = attrs[index];
5410
- if (attr.name === Q_PROPS_SEPARATOR) {
5411
- continue;
5412
- }
5413
- containerAttributes[attr.name] = attr.value;
5414
- }
5415
- }
4840
+ const result = safeCall((() => taskFn(taskApi)), cleanup2, (err => isPromise(err) ? err.then((() => runTask(task, container, host))) : handleError(err)));
4841
+ return result;
4842
+ };
4843
+ var cleanupTask = task => {
4844
+ const destroy = task.$destroy$;
4845
+ if (destroy) {
4846
+ task.$destroy$ = null;
4847
+ try {
4848
+ destroy();
4849
+ } catch (err) {
4850
+ logError(err);
5416
4851
  }
5417
- container.$serverData$ = {
5418
- containerAttributes: containerAttributes
5419
- };
5420
- qElement.setAttribute(QContainerAttr, "resumed");
5421
- qElement.qContainer = container;
5422
4852
  }
5423
- return container;
5424
- }
5425
- function _getQContainerElement(element) {
5426
- const qContainerElement = Array.isArray(element) ? vnode_getDomParent(element) : element;
5427
- return qContainerElement.closest(QContainerSelector);
5428
- }
5429
- var isDomContainer = container => container instanceof DomContainer;
5430
- var DomContainer = class extends _SharedContainer {
5431
- element;
5432
- qContainer;
5433
- qBase;
5434
- qManifestHash;
5435
- rootVNode;
5436
- document;
5437
- $journal$;
5438
- renderDone=null;
5439
- $rawStateData$;
5440
- $storeProxyMap$=new WeakMap;
5441
- $qFuncs$;
5442
- $instanceHash$;
5443
- stateData;
5444
- $styleIds$=null;
5445
- $vnodeLocate$=id => vnode_locate(this.rootVNode, id);
5446
- $renderCount$=0;
5447
- constructor(element) {
5448
- super((() => this.scheduleRender()), (() => vnode_applyJournal(this.$journal$)), {}, element.getAttribute("q:locale"));
5449
- this.qContainer = element.getAttribute(QContainerAttr);
5450
- this.qContainer || throwErrorAndStop("Element must have 'q:container' attribute.");
5451
- this.$journal$ = [ 3, element.ownerDocument ];
5452
- this.document = element.ownerDocument;
5453
- this.element = element;
5454
- this.qBase = element.getAttribute(QBaseAttr);
5455
- this.$instanceHash$ = element.getAttribute(QInstanceAttr);
5456
- this.qManifestHash = element.getAttribute("q:manifest-hash");
5457
- this.rootVNode = vnode_newUnMaterializedElement(this.element);
5458
- this.$rawStateData$ = null;
5459
- this.stateData = null;
5460
- const document2 = this.element.ownerDocument;
5461
- document2.qVNodeData || processVNodeData(document2);
5462
- this.$rawStateData$ = [];
5463
- this.stateData = [];
5464
- const qwikStates = element.querySelectorAll('script[type="qwik/state"]');
5465
- if (0 !== qwikStates.length) {
5466
- const lastState = qwikStates[qwikStates.length - 1];
5467
- this.$rawStateData$ = JSON.parse(lastState.textContent);
5468
- this.stateData = wrapDeserializerProxy(this, this.$rawStateData$);
5469
- }
5470
- this.$qFuncs$ = getQFuncs(document2, this.$instanceHash$) || EMPTY_ARRAY;
4853
+ };
4854
+ var Task = class extends Subscriber {
4855
+ constructor($flags$, $index$, $el$, $qrl$, $state$, $destroy$) {
4856
+ super();
4857
+ this.$flags$ = $flags$;
4858
+ this.$index$ = $index$;
4859
+ this.$el$ = $el$;
4860
+ this.$qrl$ = $qrl$;
4861
+ this.$state$ = $state$;
4862
+ this.$destroy$ = $destroy$;
4863
+ }
4864
+ };
4865
+ var isTask = value => value instanceof Task;
4866
+ var NEEDS_COMPUTATION = Symbol("invalid");
4867
+ var DEBUG3 = false;
4868
+ var log2 = (...args) => console.log("SIGNAL", ...args.map(qwikDebugToString));
4869
+ var throwIfQRLNotResolved = qrl => {
4870
+ const resolved = qrl.resolved;
4871
+ if (!resolved) {
4872
+ throw qrl.resolve();
5471
4873
  }
5472
- $setRawState$(id, vParent) {
5473
- this.stateData[id] = vParent;
4874
+ };
4875
+ var isSignal = value => value instanceof Signal;
4876
+ var EffectPropData = class {
4877
+ data;
4878
+ constructor(data) {
4879
+ this.data = data;
5474
4880
  }
5475
- parseQRL(qrl2) {
5476
- return inflateQRL(this, parseQRL(qrl2));
4881
+ };
4882
+ var Signal = class {
4883
+ $untrackedValue$;
4884
+ $effects$=null;
4885
+ $container$=null;
4886
+ constructor(container, value) {
4887
+ this.$container$ = container;
4888
+ this.$untrackedValue$ = value;
4889
+ DEBUG3 && log2("new", this);
5477
4890
  }
5478
- handleError(err, host) {
5479
- if (qDev) {
5480
- if ("undefined" !== typeof document) {
5481
- const vHost = host;
5482
- const errorDiv = document.createElement("errored-host");
5483
- err && err instanceof Error && (errorDiv.props = {
5484
- error: err
5485
- });
5486
- errorDiv.setAttribute("q:key", "_error_");
5487
- const journal = [];
5488
- vnode_getDOMChildNodes(journal, vHost).forEach((child => errorDiv.appendChild(child)));
5489
- const vErrorDiv = vnode_newElement(errorDiv, "error-host");
5490
- vnode_insertBefore(journal, vHost, vErrorDiv, null);
5491
- vnode_applyJournal(journal);
4891
+ get untrackedValue() {
4892
+ return this.$untrackedValue$;
4893
+ }
4894
+ set untrackedValue(value) {
4895
+ this.$untrackedValue$ = value;
4896
+ }
4897
+ get value() {
4898
+ const ctx = tryGetInvokeContext();
4899
+ if (ctx) {
4900
+ if (null === this.$container$) {
4901
+ if (!ctx.$container$) {
4902
+ return this.untrackedValue;
4903
+ }
4904
+ this.$container$ = ctx.$container$;
4905
+ } else {
4906
+ assertTrue(!ctx.$container$ || ctx.$container$ === this.$container$, "Do not use signals across containers");
5492
4907
  }
5493
- err && err instanceof Error && ("hostElement" in err || (err.hostElement = host));
5494
- if (!isRecoverable(err)) {
5495
- throw err;
4908
+ const effectSubscriber = ctx.$effectSubscriber$;
4909
+ if (effectSubscriber) {
4910
+ const effects = this.$effects$ ||= [];
4911
+ ensureContainsEffect(effects, effectSubscriber);
4912
+ ensureContains(effectSubscriber, this);
4913
+ isSubscriber(this) && ensureEffectContainsSubscriber(effectSubscriber[0], this, this.$container$);
4914
+ DEBUG3 && log2("read->sub", pad("\n" + this.toString(), " "));
5496
4915
  }
5497
4916
  }
5498
- const errorStore = this.resolveContext(host, ERROR_CONTEXT);
5499
- if (!errorStore) {
5500
- throw err;
4917
+ return this.untrackedValue;
4918
+ }
4919
+ set value(value) {
4920
+ if (value !== this.$untrackedValue$) {
4921
+ DEBUG3 && log2("Signal.set", this.$untrackedValue$, "->", value, pad("\n" + this.toString(), " "));
4922
+ this.$untrackedValue$ = value;
4923
+ triggerEffects(this.$container$, this, this.$effects$);
5501
4924
  }
5502
- errorStore.error = err;
5503
4925
  }
5504
- setContext(host, context, value) {
5505
- let ctx = this.getHostProp(host, QCtxAttr);
5506
- ctx || this.setHostProp(host, QCtxAttr, ctx = []);
5507
- mapArray_set(ctx, context.id, value, 0);
4926
+ valueOf() {
4927
+ if (qDev) {
4928
+ throw qError(46);
4929
+ }
5508
4930
  }
5509
- resolveContext(host, contextId) {
5510
- while (host) {
5511
- const ctx = this.getHostProp(host, QCtxAttr);
5512
- if (ctx) {
5513
- const value = mapArray_get(ctx, contextId.id, 0);
5514
- if (value) {
5515
- return value;
5516
- }
5517
- }
5518
- host = this.getParentHost(host);
4931
+ toString() {
4932
+ var _a;
4933
+ return `[${this.constructor.name}${this.$invalid$ ? " INVALID" : ""} ${String(this.$untrackedValue$)}]` + ((null == (_a = this.$effects$) ? void 0 : _a.map((e => "\n -> " + pad(qwikDebugToString(e[0]), " "))).join("\n")) || "");
4934
+ }
4935
+ toJSON() {
4936
+ return {
4937
+ value: this.$untrackedValue$
4938
+ };
4939
+ }
4940
+ };
4941
+ var ensureContains = (array, value) => {
4942
+ const isMissing = -1 === array.indexOf(value);
4943
+ isMissing && array.push(value);
4944
+ };
4945
+ var ensureContainsEffect = (array, effectSubscriptions) => {
4946
+ for (let i = 0; i < array.length; i++) {
4947
+ const existingEffect = array[i];
4948
+ if (existingEffect[0] === effectSubscriptions[0] && existingEffect[1] === effectSubscriptions[1]) {
4949
+ return;
5519
4950
  }
5520
- return;
5521
4951
  }
5522
- getParentHost(host) {
5523
- let vNode = vnode_getParent(host);
5524
- while (vNode) {
5525
- if (vnode_isVirtualVNode(vNode)) {
5526
- if (null !== vnode_getProp(vNode, OnRenderProp, null)) {
5527
- return vNode;
5528
- }
5529
- const parent = vnode_getProp(vNode, QSlotParent, this.$vnodeLocate$);
5530
- if (parent) {
5531
- vNode = parent;
5532
- continue;
4952
+ array.push(effectSubscriptions);
4953
+ };
4954
+ var ensureEffectContainsSubscriber = (effect, subscriber, container) => {
4955
+ if (isSubscriber(effect)) {
4956
+ effect.$effectDependencies$ ||= [];
4957
+ if (subscriberExistInSubscribers(effect.$effectDependencies$, subscriber)) {
4958
+ return;
4959
+ }
4960
+ effect.$effectDependencies$.push(subscriber);
4961
+ } else if (vnode_isVNode(effect) && !vnode_isTextVNode(effect)) {
4962
+ let subscribers = vnode_getProp(effect, QSubscribers, container ? container.$getObjectById$ : null);
4963
+ subscribers ||= [];
4964
+ if (subscriberExistInSubscribers(subscribers, subscriber)) {
4965
+ return;
4966
+ }
4967
+ subscribers.push(subscriber);
4968
+ vnode_setProp(effect, QSubscribers, subscribers);
4969
+ } else if (isSSRNode(effect)) {
4970
+ let subscribers = effect.getProp(QSubscribers);
4971
+ subscribers ||= [];
4972
+ if (subscriberExistInSubscribers(subscribers, subscriber)) {
4973
+ return;
4974
+ }
4975
+ subscribers.push(subscriber);
4976
+ effect.setProp(QSubscribers, subscribers);
4977
+ }
4978
+ };
4979
+ var isSSRNode = effect => "setProp" in effect && "getProp" in effect && "removeProp" in effect && "id" in effect;
4980
+ var subscriberExistInSubscribers = (subscribers, subscriber) => {
4981
+ for (let i = 0; i < subscribers.length; i++) {
4982
+ if (subscribers[i] === subscriber) {
4983
+ return true;
4984
+ }
4985
+ }
4986
+ return false;
4987
+ };
4988
+ var triggerEffects = (container, signal, effects) => {
4989
+ if (effects) {
4990
+ const scheduleEffect = effectSubscriptions => {
4991
+ const effect = effectSubscriptions[0];
4992
+ const property = effectSubscriptions[1];
4993
+ assertDefined(container, "Container must be defined.");
4994
+ if (isTask(effect)) {
4995
+ effect.$flags$ |= 8;
4996
+ DEBUG3 && log2("schedule.effect.task", pad("\n" + String(effect), " "));
4997
+ let choreType = 3;
4998
+ 1 & effect.$flags$ ? choreType = 32 : 4 & effect.$flags$ && (choreType = 2);
4999
+ container.$scheduler$(choreType, effect);
5000
+ } else if (effect instanceof Signal) {
5001
+ effect instanceof ComputedSignal && (effect.$computeQrl$.resolved || container.$scheduler$(1, null, effect.$computeQrl$));
5002
+ effect.$invalidate$();
5003
+ } else if (":" === property) {
5004
+ const host = effect;
5005
+ const qrl = container.getHostProp(host, OnRenderProp);
5006
+ assertDefined(qrl, "Component must have QRL");
5007
+ const props = container.getHostProp(host, ELEMENT_PROPS);
5008
+ container.$scheduler$(7, host, qrl, props);
5009
+ } else if ("." === property) {
5010
+ const host = effect;
5011
+ const target = host;
5012
+ container.$scheduler$(4, host, target, signal);
5013
+ } else {
5014
+ const host = effect;
5015
+ const effectData = effectSubscriptions[2];
5016
+ if (effectData instanceof EffectPropData) {
5017
+ const data = effectData.data;
5018
+ const payload = {
5019
+ ...data,
5020
+ $value$: signal
5021
+ };
5022
+ container.$scheduler$(5, host, property, payload);
5533
5023
  }
5534
5024
  }
5535
- vNode = vnode_getParent(vNode);
5025
+ };
5026
+ effects.forEach(scheduleEffect);
5027
+ }
5028
+ DEBUG3 && log2("done scheduling");
5029
+ };
5030
+ var ComputedSignal = class extends Signal {
5031
+ $computeQrl$;
5032
+ $invalid$=true;
5033
+ $forceRunEffects$=false;
5034
+ constructor(container, fn) {
5035
+ super(container, NEEDS_COMPUTATION);
5036
+ this.$computeQrl$ = fn;
5037
+ }
5038
+ $invalidate$() {
5039
+ var _a;
5040
+ this.$invalid$ = true;
5041
+ this.$forceRunEffects$ = false;
5042
+ null == (_a = this.$container$) || _a.$scheduler$(8, null, this);
5043
+ }
5044
+ force() {
5045
+ this.$invalid$ = true;
5046
+ this.$forceRunEffects$ = false;
5047
+ triggerEffects(this.$container$, this, this.$effects$);
5048
+ }
5049
+ get untrackedValue() {
5050
+ const didChange = this.$computeIfNeeded$();
5051
+ didChange && (this.$forceRunEffects$ = didChange);
5052
+ assertFalse(this.$untrackedValue$ === NEEDS_COMPUTATION, "Invalid state");
5053
+ return this.$untrackedValue$;
5054
+ }
5055
+ $computeIfNeeded$() {
5056
+ if (!this.$invalid$) {
5057
+ return false;
5536
5058
  }
5537
- return null;
5059
+ const computeQrl = this.$computeQrl$;
5060
+ throwIfQRLNotResolved(computeQrl);
5061
+ const ctx = tryGetInvokeContext();
5062
+ const previousEffectSubscription = null == ctx ? void 0 : ctx.$effectSubscriber$;
5063
+ ctx && (ctx.$effectSubscriber$ = [ this, "." ]);
5064
+ try {
5065
+ const untrackedValue = computeQrl.getFn(ctx)();
5066
+ if (isPromise(untrackedValue)) {
5067
+ throw qError(47, [ computeQrl.dev ? computeQrl.dev.file : "", computeQrl.$hash$ ]);
5068
+ }
5069
+ DEBUG3 && log2("Signal.$compute$", untrackedValue);
5070
+ this.$invalid$ = false;
5071
+ const didChange = untrackedValue !== this.$untrackedValue$;
5072
+ didChange && (this.$untrackedValue$ = untrackedValue);
5073
+ return didChange;
5074
+ } finally {
5075
+ ctx && (ctx.$effectSubscriber$ = previousEffectSubscription);
5076
+ }
5077
+ }
5078
+ get value() {
5079
+ return super.value;
5080
+ }
5081
+ set value(_) {
5082
+ throw qError(48);
5083
+ }
5084
+ };
5085
+ var WrappedSignal = class extends Signal {
5086
+ $args$;
5087
+ $func$;
5088
+ $funcStr$;
5089
+ $invalid$=true;
5090
+ $effectDependencies$=null;
5091
+ $hostElement$=null;
5092
+ $forceRunEffects$=false;
5093
+ constructor(container, fn, args, fnStr) {
5094
+ super(container, NEEDS_COMPUTATION);
5095
+ this.$args$ = args;
5096
+ this.$func$ = fn;
5097
+ this.$funcStr$ = fnStr;
5098
+ }
5099
+ $invalidate$() {
5100
+ var _a;
5101
+ this.$invalid$ = true;
5102
+ this.$forceRunEffects$ = false;
5103
+ null == (_a = this.$container$) || _a.$scheduler$(8, this.$hostElement$, this);
5104
+ }
5105
+ force() {
5106
+ this.$invalid$ = true;
5107
+ this.$forceRunEffects$ = false;
5108
+ triggerEffects(this.$container$, this, this.$effects$);
5109
+ }
5110
+ get untrackedValue() {
5111
+ const didChange = this.$computeIfNeeded$();
5112
+ didChange && (this.$forceRunEffects$ = didChange);
5113
+ assertFalse(this.$untrackedValue$ === NEEDS_COMPUTATION, "Invalid state");
5114
+ return this.$untrackedValue$;
5115
+ }
5116
+ $computeIfNeeded$() {
5117
+ if (!this.$invalid$) {
5118
+ return false;
5119
+ }
5120
+ const untrackedValue = trackSignal((() => this.$func$(...this.$args$)), this, ".", this.$container$);
5121
+ const didChange = untrackedValue !== this.$untrackedValue$;
5122
+ didChange && (this.$untrackedValue$ = untrackedValue);
5123
+ return didChange;
5538
5124
  }
5539
- setHostProp(host, name, value) {
5540
- const vNode = host;
5541
- vnode_setProp(vNode, name, value);
5125
+ get value() {
5126
+ return super.value;
5542
5127
  }
5543
- getHostProp(host, name) {
5544
- const vNode = host;
5545
- let getObjectById = null;
5546
- switch (name) {
5547
- case ELEMENT_SEQ:
5548
- case ELEMENT_PROPS:
5549
- case OnRenderProp:
5550
- case QCtxAttr:
5551
- case QSubscribers:
5552
- getObjectById = this.$getObjectById$;
5553
- break;
5554
-
5555
- case ELEMENT_SEQ_IDX:
5556
- case USE_ON_LOCAL_SEQ_IDX:
5557
- getObjectById = parseInt;
5558
- break;
5559
- }
5560
- return vnode_getProp(vNode, name, getObjectById);
5128
+ set value(_) {
5129
+ throw qError(49);
5561
5130
  }
5562
- scheduleRender() {
5563
- this.$renderCount$++;
5564
- this.renderDone ||= getPlatform().nextTick((() => this.processChores()));
5565
- return this.renderDone;
5131
+ };
5132
+ var version = "2.0.0-alpha.4-dev+374e0d6";
5133
+ var _SharedContainer = class {
5134
+ $version$;
5135
+ $scheduler$;
5136
+ $storeProxyMap$;
5137
+ $locale$;
5138
+ $getObjectById$;
5139
+ $serverData$;
5140
+ $currentUniqueId$=0;
5141
+ $instanceHash$=null;
5142
+ constructor(scheduleDrain, journalFlush, serverData, locale) {
5143
+ this.$serverData$ = serverData;
5144
+ this.$locale$ = locale;
5145
+ this.$version$ = version;
5146
+ this.$storeProxyMap$ = new WeakMap;
5147
+ this.$getObjectById$ = _id => {
5148
+ throw Error("Not implemented");
5149
+ };
5150
+ this.$scheduler$ = createScheduler(this, scheduleDrain, journalFlush);
5566
5151
  }
5567
- processChores() {
5568
- let renderCount = this.$renderCount$;
5569
- const result = this.$scheduler$(127);
5570
- if (isPromise(result)) {
5571
- return result.then((async () => {
5572
- while (renderCount !== this.$renderCount$) {
5573
- renderCount = this.$renderCount$;
5574
- await this.$scheduler$(127);
5575
- }
5576
- this.renderDone = null;
5577
- }));
5152
+ trackSignalValue(signal, subscriber, property, data) {
5153
+ return trackSignalAndAssignHost(signal, subscriber, property, this, data);
5154
+ }
5155
+ serializationCtxFactory(NodeConstructor, DomRefConstructor, symbolToChunkResolver, writer, prepVNodeData) {
5156
+ return createSerializationContext(NodeConstructor, DomRefConstructor, symbolToChunkResolver, this.getHostProp.bind(this), this.setHostProp.bind(this), this.$storeProxyMap$, writer, prepVNodeData);
5157
+ }
5158
+ };
5159
+ Symbol("proxy target");
5160
+ Symbol("proxy flags");
5161
+ Symbol("proxy manager");
5162
+ var _CONST_PROPS = Symbol("CONST");
5163
+ var _VAR_PROPS = Symbol("VAR");
5164
+ Symbol("IMMUTABLE");
5165
+ var componentQrl = componentQrl2 => {
5166
+ function QwikComponent(props, key, flags = 0) {
5167
+ assertQrl(componentQrl2);
5168
+ assertNumber(flags, "The Qwik Component was not invoked correctly");
5169
+ const hash = qTest ? "sX" : componentQrl2.$hash$.slice(0, 4);
5170
+ const finalKey = hash + ":" + (key || "");
5171
+ const InnerCmp = () => {};
5172
+ InnerCmp[SERIALIZABLE_STATE] = [ componentQrl2 ];
5173
+ return _jsxSplit(InnerCmp, props, null, props.children, flags, finalKey);
5174
+ }
5175
+ QwikComponent[SERIALIZABLE_STATE] = [ componentQrl2 ];
5176
+ return QwikComponent;
5177
+ };
5178
+ var SERIALIZABLE_STATE = Symbol("serializable-data");
5179
+ var isQwikComponent = component => "function" == typeof component && void 0 !== component[SERIALIZABLE_STATE];
5180
+ var _jsxSorted = (type, varProps, constProps, children, flags, key, dev) => {
5181
+ const processed = null == key ? null : String(key);
5182
+ const node = new JSXNodeImpl(type, varProps || {}, constProps || null, children, flags, processed);
5183
+ qDev && dev && (node.dev = {
5184
+ stack: (new Error).stack,
5185
+ ...dev
5186
+ });
5187
+ seal(node);
5188
+ return node;
5189
+ };
5190
+ var _jsxSplit = (type, varProps, constProps, children, flags, key, dev) => {
5191
+ let sortedProps;
5192
+ sortedProps = varProps ? Object.fromEntries(untrack((() => Object.entries(varProps))).filter((entry => {
5193
+ const attr = entry[0];
5194
+ if ("children" === attr) {
5195
+ children ??= entry[1];
5196
+ return false;
5578
5197
  }
5579
- if (renderCount !== this.$renderCount$) {
5580
- this.processChores();
5581
- return;
5198
+ if ("key" === attr) {
5199
+ key = entry[1];
5200
+ return false;
5582
5201
  }
5583
- this.renderDone = null;
5202
+ return !constProps || !(attr in constProps) || /^on[A-Z].*\$$/.test(attr);
5203
+ })).sort((([a], [b]) => a < b ? -1 : 1))) : "string" === typeof type ? EMPTY_OBJ : {};
5204
+ if (constProps && "children" in constProps) {
5205
+ children = constProps.children;
5206
+ constProps.children = void 0;
5584
5207
  }
5585
- ensureProjectionResolved(vNode) {
5586
- if (0 === (16 & vNode[0])) {
5587
- vNode[0] |= 16;
5588
- for (let i = vnode_getPropStartIndex(vNode); i < vNode.length; i += 2) {
5589
- const prop = vNode[i];
5590
- if (isSlotProp(prop)) {
5591
- const value = vNode[i + 1];
5592
- "string" == typeof value && (vNode[i + 1] = this.$vnodeLocate$(value));
5593
- }
5208
+ return _jsxSorted(type, sortedProps, constProps, children, flags, key, dev);
5209
+ };
5210
+ var isPropsProxy = obj => obj && void 0 !== obj[_VAR_PROPS];
5211
+ var JSXNodeImpl = class {
5212
+ constructor(type, varProps, constProps, children, flags, key = null) {
5213
+ this.type = type;
5214
+ this.varProps = varProps;
5215
+ this.constProps = constProps;
5216
+ this.children = children;
5217
+ this.flags = flags;
5218
+ this.key = key;
5219
+ if (qDev) {
5220
+ if ("object" !== typeof varProps) {
5221
+ throw new Error("JSXNodeImpl: varProps must be objects: " + JSON.stringify(varProps));
5222
+ }
5223
+ if ("object" !== typeof constProps) {
5224
+ throw new Error("JSXNodeImpl: constProps must be objects: " + JSON.stringify(constProps));
5594
5225
  }
5595
5226
  }
5596
5227
  }
5597
- $getObjectById$=id => {
5598
- "string" === typeof id && (id = parseFloat(id));
5599
- assertTrue(id < this.$rawStateData$.length / 2, `Invalid reference: ${id} >= ${this.$rawStateData$.length / 2}`);
5600
- return this.stateData[id];
5601
- };
5602
- getSyncFn(id) {
5603
- const fn = this.$qFuncs$[id];
5604
- assertTrue("function" === typeof fn, "Invalid reference: " + id);
5605
- return fn;
5228
+ dev;
5229
+ _proxy=null;
5230
+ get props() {
5231
+ this._proxy || (this._proxy = createPropsProxy(this.varProps, this.constProps, this.children));
5232
+ return this._proxy;
5606
5233
  }
5607
- $appendStyle$(content, styleId, host, scoped) {
5608
- if (scoped) {
5609
- const scopedStyleIdsString = this.getHostProp(host, QScopedStyle);
5610
- const scopedStyleIds = new Set(convertScopedStyleIdsToArray(scopedStyleIdsString));
5611
- scopedStyleIds.add(styleId);
5612
- this.setHostProp(host, QScopedStyle, convertStyleIdsToString(scopedStyleIds));
5613
- }
5614
- if (null == this.$styleIds$) {
5615
- this.$styleIds$ = new Set;
5616
- this.element.querySelectorAll(QStyleSelector).forEach((style => {
5617
- this.$styleIds$.add(style.getAttribute(QStyle));
5618
- }));
5234
+ };
5235
+ var Virtual = props => props.children;
5236
+ var isJSXNode = n => {
5237
+ if (qDev) {
5238
+ if (n instanceof JSXNodeImpl) {
5239
+ return true;
5619
5240
  }
5620
- if (!this.$styleIds$.has(styleId)) {
5621
- this.$styleIds$.add(styleId);
5622
- const styleElement = this.document.createElement("style");
5623
- styleElement.setAttribute(QStyle, styleId);
5624
- styleElement.textContent = content;
5625
- this.$journal$.push(5, this.document.head, null, styleElement);
5241
+ if (isObject(n) && "key" in n && "props" in n && "type" in n) {
5242
+ logWarn('Duplicate implementations of "JSXNode" found');
5243
+ return true;
5626
5244
  }
5245
+ return false;
5627
5246
  }
5247
+ return n instanceof JSXNodeImpl;
5628
5248
  };
5629
- var runTask = (task, container, host) => {
5630
- task.$flags$ &= -9;
5631
- cleanupTask(task);
5632
- const iCtx = newInvokeContext(container.$locale$, host, void 0, TaskEvent);
5633
- iCtx.$container$ = container;
5634
- const taskFn = task.$qrl$.getFn(iCtx, (() => clearSubscriberEffectDependencies(task)));
5635
- const track = (obj, prop) => {
5636
- const ctx = newInvokeContext();
5637
- ctx.$effectSubscriber$ = [ task, ":" ];
5638
- ctx.$container$ = container;
5639
- return invoke(ctx, (() => {
5640
- if (isFunction(obj)) {
5641
- return obj();
5642
- }
5643
- return prop ? obj[prop] : isSignal(obj) ? obj.value : obj;
5644
- }));
5645
- };
5646
- const handleError = reason => container.handleError(reason, host);
5647
- let cleanupFns = null;
5648
- const cleanup2 = fn => {
5649
- if ("function" == typeof fn) {
5650
- if (!cleanupFns) {
5651
- cleanupFns = [];
5652
- task.$destroy$ = noSerialize((() => {
5653
- task.$destroy$ = null;
5654
- cleanupFns.forEach((fn2 => {
5655
- try {
5656
- fn2();
5657
- } catch (err) {
5658
- handleError(err);
5659
- }
5660
- }));
5661
- }));
5662
- }
5663
- cleanupFns.push(fn);
5249
+ var Fragment = props => props.children;
5250
+ function createPropsProxy(varProps, constProps, children) {
5251
+ return new Proxy({}, new PropsProxyHandler(varProps, constProps, children));
5252
+ }
5253
+ var PropsProxyHandler = class {
5254
+ constructor($varProps$, $constProps$, $children$) {
5255
+ this.$varProps$ = $varProps$;
5256
+ this.$constProps$ = $constProps$;
5257
+ this.$children$ = $children$;
5258
+ }
5259
+ get(_, prop) {
5260
+ if (prop === _CONST_PROPS) {
5261
+ return this.$constProps$;
5664
5262
  }
5665
- };
5666
- const taskApi = {
5667
- track: track,
5668
- cleanup: cleanup2
5669
- };
5670
- const result = safeCall((() => taskFn(taskApi)), cleanup2, (err => isPromise(err) ? err.then((() => runTask(task, container, host))) : handleError(err)));
5671
- return result;
5672
- };
5673
- var cleanupTask = task => {
5674
- const destroy = task.$destroy$;
5675
- if (destroy) {
5676
- task.$destroy$ = null;
5677
- try {
5678
- destroy();
5679
- } catch (err) {
5680
- logError(err);
5263
+ if (prop === _VAR_PROPS) {
5264
+ return this.$varProps$;
5265
+ }
5266
+ if (null != this.$children$ && "children" === prop) {
5267
+ return this.$children$;
5268
+ }
5269
+ const value = this.$constProps$ && prop in this.$constProps$ ? this.$constProps$[prop] : this.$varProps$[prop];
5270
+ return value instanceof WrappedSignal ? value.value : value;
5271
+ }
5272
+ set(_, prop, value) {
5273
+ if (prop === _CONST_PROPS) {
5274
+ this.$constProps$ = value;
5275
+ return true;
5276
+ }
5277
+ if (prop === _VAR_PROPS) {
5278
+ this.$varProps$ = value;
5279
+ return true;
5681
5280
  }
5281
+ this.$constProps$ && prop in this.$constProps$ ? this.$constProps$[prop] = value : this.$varProps$[prop] = value;
5282
+ return true;
5682
5283
  }
5683
- };
5684
- var Task2 = class extends Subscriber {
5685
- constructor($flags$, $index$, $el$, $qrl$, $state$, $destroy$) {
5686
- super();
5687
- this.$flags$ = $flags$;
5688
- this.$index$ = $index$;
5689
- this.$el$ = $el$;
5690
- this.$qrl$ = $qrl$;
5691
- this.$state$ = $state$;
5692
- this.$destroy$ = $destroy$;
5284
+ deleteProperty(_, prop) {
5285
+ if ("string" !== typeof prop) {
5286
+ return false;
5287
+ }
5288
+ let didDelete = delete this.$varProps$[prop];
5289
+ this.$constProps$ && (didDelete = delete this.$constProps$[prop] || didDelete);
5290
+ null != this.$children$ && "children" === prop && (this.$children$ = null);
5291
+ return didDelete;
5292
+ }
5293
+ has(_, prop) {
5294
+ const hasProp = "children" === prop && null != this.$children$ || prop === _CONST_PROPS || prop === _VAR_PROPS || prop in this.$varProps$ || !!this.$constProps$ && prop in this.$constProps$;
5295
+ return hasProp;
5296
+ }
5297
+ getOwnPropertyDescriptor(target, p) {
5298
+ const value = "children" === p && null != this.$children$ ? this.$children$ : this.$constProps$ && p in this.$constProps$ ? this.$constProps$[p] : this.$varProps$[p];
5299
+ return {
5300
+ configurable: true,
5301
+ enumerable: true,
5302
+ value: value
5303
+ };
5304
+ }
5305
+ ownKeys() {
5306
+ const out = Object.keys(this.$varProps$);
5307
+ null != this.$children$ && -1 === out.indexOf("children") && out.push("children");
5308
+ if (this.$constProps$) {
5309
+ for (const key in this.$constProps$) {
5310
+ -1 === out.indexOf(key) && out.push(key);
5311
+ }
5312
+ }
5313
+ return out;
5693
5314
  }
5694
5315
  };
5695
- var isTask = value => value instanceof Task2;
5316
+ var directGetPropsProxyProp = (jsx2, prop) => jsx2.constProps && prop in jsx2.constProps ? jsx2.constProps[prop] : jsx2.varProps[prop];
5696
5317
  var stringifyPath = [];
5697
5318
  function qwikDebugToString(value) {
5698
5319
  if (null === value) {
@@ -5763,6 +5384,70 @@ globalThis.qwikOptimizer = function(module) {
5763
5384
  }
5764
5385
  return String(value);
5765
5386
  };
5387
+ var VNodeDataSeparator = {
5388
+ REFERENCE_CH: "~",
5389
+ REFERENCE: 126,
5390
+ ADVANCE_1_CH: "!",
5391
+ ADVANCE_1: 33,
5392
+ ADVANCE_2_CH: '"',
5393
+ ADVANCE_2: 34,
5394
+ ADVANCE_4_CH: "#",
5395
+ ADVANCE_4: 35,
5396
+ ADVANCE_8_CH: "$",
5397
+ ADVANCE_8: 36,
5398
+ ADVANCE_16_CH: "%",
5399
+ ADVANCE_16: 37,
5400
+ ADVANCE_32_CH: "&",
5401
+ ADVANCE_32: 38,
5402
+ ADVANCE_64_CH: "'",
5403
+ ADVANCE_64: 39,
5404
+ ADVANCE_128_CH: "(",
5405
+ ADVANCE_128: 40,
5406
+ ADVANCE_256_CH: ")",
5407
+ ADVANCE_256: 41,
5408
+ ADVANCE_512_CH: "*",
5409
+ ADVANCE_512: 42,
5410
+ ADVANCE_1024_CH: "+",
5411
+ ADVANCE_1024: 43,
5412
+ ADVANCE_2048_CH: ",",
5413
+ ADVANCE_2048: 44,
5414
+ ADVANCE_4096_CH: "-",
5415
+ ADVANCE_4096: 45,
5416
+ ADVANCE_8192_CH: ".",
5417
+ ADVANCE_8192: 46
5418
+ };
5419
+ var VNodeDataChar = {
5420
+ OPEN: 123,
5421
+ OPEN_CHAR: "{",
5422
+ CLOSE: 125,
5423
+ CLOSE_CHAR: "}",
5424
+ SCOPED_STYLE: 59,
5425
+ SCOPED_STYLE_CHAR: ";",
5426
+ RENDER_FN: 60,
5427
+ RENDER_FN_CHAR: "<",
5428
+ ID: 61,
5429
+ ID_CHAR: "=",
5430
+ PROPS: 62,
5431
+ PROPS_CHAR: ">",
5432
+ SLOT_REF: 63,
5433
+ SLOT_REF_CHAR: "?",
5434
+ KEY: 64,
5435
+ KEY_CHAR: "@",
5436
+ SEQ: 91,
5437
+ SEQ_CHAR: "[",
5438
+ DON_T_USE: 92,
5439
+ DON_T_USE_CHAR: "\\",
5440
+ CONTEXT: 93,
5441
+ CONTEXT_CHAR: "]",
5442
+ SEQ_IDX: 94,
5443
+ SEQ_IDX_CHAR: "^",
5444
+ SUBS: 96,
5445
+ SUBS_CHAR: "`",
5446
+ SEPARATOR: 124,
5447
+ SEPARATOR_CHAR: "|",
5448
+ SLOT: 126,
5449
+ SLOT_CHAR: "~"
5450
+ };
5766
5451
  var vnode_newElement = (element, elementName) => {
5767
5452
  assertEqual(fastNodeType(element), 1, "Expecting element node.");
5768
5453
  const vnode = VNodeArray.createElement(-247, null, null, null, null, null, element, elementName);
@@ -6296,9 +5981,28 @@ globalThis.qwikOptimizer = function(module) {
6296
5981
  const element = vNode[6];
6297
5982
  const firstChild = fastFirstChild(element);
6298
5983
  const vNodeData = null == (_b = null == (_a = element.ownerDocument) ? void 0 : _a.qVNodeData) ? void 0 : _b.get(element);
6299
- const vFirstChild = vNodeData ? materializeFromVNodeData(vNode, vNodeData, element, firstChild) : materializeFromDOM(vNode, firstChild);
5984
+ const vFirstChild = materialize(vNode, element, firstChild, vNodeData);
6300
5985
  return vFirstChild;
6301
5986
  };
5987
+ var materialize = (vNode, element, firstChild, vNodeData) => {
5988
+ if (vNodeData) {
5989
+ if (vNodeData.charCodeAt(0) === VNodeDataChar.SEPARATOR) {
5990
+ const elementVNodeDataStartIdx = 1;
5991
+ let elementVNodeDataEndIdx = 1;
5992
+ while (vNodeData.charCodeAt(elementVNodeDataEndIdx) !== VNodeDataChar.SEPARATOR) {
5993
+ elementVNodeDataEndIdx++;
5994
+ }
5995
+ const elementVNodeData = vNodeData.substring(elementVNodeDataStartIdx, elementVNodeDataEndIdx);
5996
+ vNodeData = vNodeData.substring(elementVNodeDataEndIdx + 1);
5997
+ const vFirstChild = materializeFromDOM(vNode, firstChild, elementVNodeData);
5998
+ if (!vNodeData) {
5999
+ return vFirstChild;
6000
+ }
6001
+ }
6002
+ return materializeFromVNodeData(vNode, vNodeData, element, firstChild);
6003
+ }
6004
+ return materializeFromDOM(vNode, firstChild);
6005
+ };
6302
6006
  var ensureMaterialized = vnode => {
6303
6007
  const vParent = ensureElementVNode(vnode);
6304
6008
  let vFirstChild = vParent[4];
@@ -6371,693 +6075,965 @@ globalThis.qwikOptimizer = function(module) {
6371
6075
  }
6372
6076
  node = nextNode;
6373
6077
  }
6374
- return null;
6375
- }
6376
- var _fastParentNode = null;
6377
- var fastParentNode = node => {
6378
- _fastParentNode || (_fastParentNode = fastGetter(node, "parentNode"));
6379
- return _fastParentNode.call(node);
6078
+ return null;
6079
+ }
6080
+ var _fastParentNode = null;
6081
+ var fastParentNode = node => {
6082
+ _fastParentNode || (_fastParentNode = fastGetter(node, "parentNode"));
6083
+ return _fastParentNode.call(node);
6084
+ };
6085
+ var _fastFirstChild = null;
6086
+ var fastFirstChild = node => {
6087
+ _fastFirstChild || (_fastFirstChild = fastGetter(node, "firstChild"));
6088
+ node = node && _fastFirstChild.call(node);
6089
+ while (node && !fastIsTextOrElement(node)) {
6090
+ node = fastNextSibling(node);
6091
+ }
6092
+ return node;
6093
+ };
6094
+ var fastGetter = (prototype, name) => {
6095
+ var _a;
6096
+ let getter;
6097
+ while (prototype && !(getter = null == (_a = Object.getOwnPropertyDescriptor(prototype, name)) ? void 0 : _a.get)) {
6098
+ prototype = Object.getPrototypeOf(prototype);
6099
+ }
6100
+ return getter || function() {
6101
+ return this[name];
6102
+ };
6103
+ };
6104
+ var isQStyleElement = node => isElement(node) && "STYLE" === node.nodeName && (node.hasAttribute(QScopedStyle) || node.hasAttribute(QStyle));
6105
+ var materializeFromDOM = (vParent, firstChild, vData) => {
6106
+ let vFirstChild = null;
6107
+ const skipStyleElements = () => {
6108
+ while (isQStyleElement(child)) {
6109
+ child = fastNextSibling(child);
6110
+ }
6111
+ };
6112
+ let child = firstChild;
6113
+ skipStyleElements();
6114
+ let vChild = null;
6115
+ while (child) {
6116
+ const nodeType = fastNodeType(child);
6117
+ let vNextChild = null;
6118
+ 3 === nodeType ? vNextChild = vnode_newText(child, child.textContent ?? void 0) : 1 === nodeType && (vNextChild = vnode_newUnMaterializedElement(child));
6119
+ if (vNextChild) {
6120
+ vNextChild[1] = vParent;
6121
+ vChild && (vChild[3] = vNextChild);
6122
+ vNextChild[2] = vChild;
6123
+ vChild = vNextChild;
6124
+ }
6125
+ vFirstChild || (vParent[4] = vFirstChild = vChild);
6126
+ child = fastNextSibling(child);
6127
+ skipStyleElements();
6128
+ }
6129
+ vParent[5] = vChild || null;
6130
+ vParent[4] = vFirstChild;
6131
+ if (vData) {
6132
+ let container = null;
6133
+ processVNodeData(vData, ((peek, consumeValue) => {
6134
+ if (peek() === VNodeDataChar.ID) {
6135
+ container || (container = getDomContainer(vParent[6]));
6136
+ const id = consumeValue();
6137
+ container.$setRawState$(parseInt(id), vParent);
6138
+ isDev && vnode_setAttr(null, vParent, ELEMENT_ID, id);
6139
+ } else {
6140
+ peek() === VNodeDataChar.SUBS ? vnode_setProp(vParent, QSubscribers, consumeValue()) : consumeValue();
6141
+ }
6142
+ }));
6143
+ }
6144
+ return vFirstChild;
6145
+ };
6146
+ var processVNodeData = (vData, callback) => {
6147
+ let nextToConsumeIdx = 0;
6148
+ let ch = 0;
6149
+ let peekCh = 0;
6150
+ const peek = () => 0 !== peekCh ? peekCh : peekCh = nextToConsumeIdx < vData.length ? vData.charCodeAt(nextToConsumeIdx) : 0;
6151
+ const consume = () => {
6152
+ ch = peek();
6153
+ peekCh = 0;
6154
+ nextToConsumeIdx++;
6155
+ return ch;
6156
+ };
6157
+ const consumeValue = () => {
6158
+ consume();
6159
+ const start = nextToConsumeIdx;
6160
+ while (peek() <= 58 && 0 !== peekCh || 95 === peekCh || peekCh >= 65 && peekCh <= 90 || peekCh >= 97 && peekCh <= 122) {
6161
+ consume();
6162
+ }
6163
+ return vData.substring(start, nextToConsumeIdx);
6164
+ };
6165
+ while (0 !== peek()) {
6166
+ callback(peek, consumeValue, consume, nextToConsumeIdx);
6167
+ }
6168
+ };
6169
+ var vnode_getNextSibling = vnode => vnode[3];
6170
+ var vnode_getPreviousSibling = vnode => vnode[2];
6171
+ var vnode_getAttrKeys = vnode => {
6172
+ const type = vnode[0];
6173
+ if (0 !== (3 & type)) {
6174
+ vnode_ensureElementInflated(vnode);
6175
+ const keys2 = [];
6176
+ for (let i = vnode_getPropStartIndex(vnode); i < vnode.length; i += 2) {
6177
+ const key = vnode[i];
6178
+ key.startsWith(Q_PROPS_SEPARATOR) || keys2.push(key);
6179
+ }
6180
+ return keys2;
6181
+ }
6182
+ return [];
6183
+ };
6184
+ var vnode_setAttr = (journal, vnode, key, value) => {
6185
+ const type = vnode[0];
6186
+ if (0 !== (3 & type)) {
6187
+ vnode_ensureElementInflated(vnode);
6188
+ const idx = mapApp_findIndx(vnode, key, vnode_getPropStartIndex(vnode));
6189
+ if (idx >= 0) {
6190
+ if (vnode[idx + 1] != value && 0 !== (1 & type)) {
6191
+ const element = vnode[6];
6192
+ journal && journal.push(2, element, key, value);
6193
+ }
6194
+ null == value ? vnode.splice(idx, 2) : vnode[idx + 1] = value;
6195
+ } else if (null != value) {
6196
+ vnode.splice(~idx, 0, key, value);
6197
+ if (0 !== (1 & type)) {
6198
+ const element = vnode[6];
6199
+ journal && journal.push(2, element, key, value);
6200
+ }
6201
+ }
6202
+ }
6203
+ };
6204
+ var vnode_getAttr = (vnode, key) => {
6205
+ const type = vnode[0];
6206
+ if (0 !== (3 & type)) {
6207
+ vnode_ensureElementInflated(vnode);
6208
+ return mapArray_get(vnode, key, vnode_getPropStartIndex(vnode));
6209
+ }
6210
+ return null;
6211
+ };
6212
+ var vnode_getProp = (vnode, key, getObject) => {
6213
+ const type = vnode[0];
6214
+ if (0 !== (3 & type)) {
6215
+ 1 & type && vnode_ensureElementInflated(vnode);
6216
+ const idx = mapApp_findIndx(vnode, key, vnode_getPropStartIndex(vnode));
6217
+ if (idx >= 0) {
6218
+ let value = vnode[idx + 1];
6219
+ "string" === typeof value && getObject && (vnode[idx + 1] = value = getObject(value));
6220
+ return value;
6221
+ }
6222
+ }
6223
+ return null;
6224
+ };
6225
+ var vnode_setProp = (vnode, key, value) => {
6226
+ ensureElementOrVirtualVNode(vnode);
6227
+ const idx = mapApp_findIndx(vnode, key, vnode_getPropStartIndex(vnode));
6228
+ idx >= 0 ? vnode[idx + 1] = value : null != value && vnode.splice(~idx, 0, key, value);
6229
+ };
6230
+ var vnode_getPropStartIndex = vnode => {
6231
+ const type = 7 & vnode[0];
6232
+ if (1 === type) {
6233
+ return 8;
6234
+ }
6235
+ if (2 === type) {
6236
+ return 6;
6237
+ }
6238
+ throw qError(43, [ type ]);
6380
6239
  };
6381
- var _fastFirstChild = null;
6382
- var fastFirstChild = node => {
6383
- _fastFirstChild || (_fastFirstChild = fastGetter(node, "firstChild"));
6384
- node = node && _fastFirstChild.call(node);
6385
- while (node && !fastIsTextOrElement(node)) {
6386
- node = fastNextSibling(node);
6240
+ var vnode_getParent = vnode => vnode[1] || null;
6241
+ var vnode_getNode = vnode => {
6242
+ if (null === vnode || vnode_isVirtualVNode(vnode)) {
6243
+ return null;
6387
6244
  }
6388
- return node;
6245
+ if (vnode_isElementVNode(vnode)) {
6246
+ return vnode[6];
6247
+ }
6248
+ assertTrue(vnode_isTextVNode(vnode), "Expecting Text Node.");
6249
+ return vnode[4];
6389
6250
  };
6390
- var fastGetter = (prototype, name) => {
6251
+ function vnode_toString(depth = 10, offset = "", materialize2 = false, siblings = false) {
6391
6252
  var _a;
6392
- let getter;
6393
- while (prototype && !(getter = null == (_a = Object.getOwnPropertyDescriptor(prototype, name)) ? void 0 : _a.get)) {
6394
- prototype = Object.getPrototypeOf(prototype);
6253
+ let vnode = this;
6254
+ if (0 === depth) {
6255
+ return "...";
6395
6256
  }
6396
- return getter || function() {
6397
- return this[name];
6398
- };
6399
- };
6400
- var isQStyleElement = node => isElement(node) && "STYLE" === node.nodeName && (node.hasAttribute(QScopedStyle) || node.hasAttribute(QStyle));
6401
- var materializeFromDOM = (vParent, firstChild) => {
6402
- let vFirstChild = null;
6403
- const skipStyleElements = () => {
6404
- while (isQStyleElement(child)) {
6405
- child = fastNextSibling(child);
6257
+ if (null === vnode) {
6258
+ return "null";
6259
+ }
6260
+ if (void 0 === vnode) {
6261
+ return "undefined";
6262
+ }
6263
+ const strings = [];
6264
+ do {
6265
+ if (vnode_isTextVNode(vnode)) {
6266
+ strings.push(qwikDebugToString(vnode_getText(vnode)));
6267
+ } else if (vnode_isVirtualVNode(vnode)) {
6268
+ const idx = vnode[0] >>> 8;
6269
+ const attrs = [ "[" + String(idx) + "]" ];
6270
+ vnode_getAttrKeys(vnode).forEach((key => {
6271
+ if (key !== DEBUG_TYPE) {
6272
+ const value = vnode_getAttr(vnode, key);
6273
+ attrs.push(" " + key + "=" + qwikDebugToString(value));
6274
+ }
6275
+ }));
6276
+ const name = VirtualTypeName[vnode_getAttr(vnode, DEBUG_TYPE) || "V"] || VirtualTypeName.V;
6277
+ strings.push("<" + name + attrs.join("") + ">");
6278
+ const child = vnode_getFirstChild(vnode);
6279
+ child && strings.push(" " + vnode_toString.call(child, depth - 1, offset + " ", true, true));
6280
+ strings.push("</" + name + ">");
6281
+ } else if (vnode_isElementVNode(vnode)) {
6282
+ const tag = vnode_getElementName(vnode);
6283
+ const attrs = [];
6284
+ const keys2 = vnode_getAttrKeys(vnode);
6285
+ keys2.forEach((key => {
6286
+ const value = vnode_getAttr(vnode, key);
6287
+ attrs.push(" " + key + "=" + qwikDebugToString(value));
6288
+ }));
6289
+ const node = vnode_getNode(vnode);
6290
+ if (node) {
6291
+ const vnodeData = null == (_a = node.ownerDocument.qVNodeData) ? void 0 : _a.get(node);
6292
+ vnodeData && attrs.push(" q:vnodeData=" + qwikDebugToString(vnodeData));
6293
+ }
6294
+ const domAttrs = node.attributes;
6295
+ for (let i = 0; i < domAttrs.length; i++) {
6296
+ const attr = domAttrs[i];
6297
+ -1 === keys2.indexOf(attr.name) && attrs.push(" " + attr.name + (attr.value ? "=" + qwikDebugToString(attr.value) : ""));
6298
+ }
6299
+ strings.push("<" + tag + attrs.join("") + ">");
6300
+ if (vnode_isMaterialized(vnode) || materialize2) {
6301
+ const child = vnode_getFirstChild(vnode);
6302
+ child && strings.push(" " + vnode_toString.call(child, depth - 1, offset + " ", true, true));
6303
+ } else {
6304
+ strings.push(" \x3c!-- not materialized --!>");
6305
+ }
6306
+ strings.push("</" + tag + ">");
6406
6307
  }
6308
+ vnode = siblings && vnode_getNextSibling(vnode) || null;
6309
+ } while (vnode);
6310
+ return strings.join("\n" + offset);
6311
+ }
6312
+ var isNumber = ch => 48 <= ch && ch <= 57;
6313
+ var isLowercase = ch => 97 <= ch && ch <= 122;
6314
+ var stack = [];
6315
+ function materializeFromVNodeData(vParent, vData, element, child) {
6316
+ let idx = 0;
6317
+ let vFirst = null;
6318
+ let vLast = null;
6319
+ let previousTextNode = null;
6320
+ const addVNode = node => {
6321
+ node[0] = 255 & node[0] | idx << 8;
6322
+ idx++;
6323
+ vLast && (vLast[3] = node);
6324
+ node[2] = vLast;
6325
+ node[1] = vParent;
6326
+ vFirst || (vParent[4] = vFirst = node);
6327
+ vLast = node;
6407
6328
  };
6408
- let child = firstChild;
6409
- skipStyleElements();
6410
- let vChild = null;
6411
- while (child) {
6412
- const nodeType = fastNodeType(child);
6413
- let vNextChild = null;
6414
- 3 === nodeType ? vNextChild = vnode_newText(child, child.textContent ?? void 0) : 1 === nodeType && (vNextChild = vnode_newUnMaterializedElement(child));
6415
- if (vNextChild) {
6416
- vNextChild[1] = vParent;
6417
- vChild && (vChild[3] = vNextChild);
6418
- vNextChild[2] = vChild;
6419
- vChild = vNextChild;
6329
+ let textIdx = 0;
6330
+ let combinedText = null;
6331
+ let container = null;
6332
+ processVNodeData(vData, ((peek, consumeValue, consume, nextToConsumeIdx) => {
6333
+ if (isNumber(peek())) {
6334
+ while (!isElement(child)) {
6335
+ child = fastNextSibling(child);
6336
+ if (!child) {
6337
+ throw qError(44, [ vData, peek(), nextToConsumeIdx ]);
6338
+ }
6339
+ }
6340
+ while (isQStyleElement(child)) {
6341
+ child = fastNextSibling(child);
6342
+ }
6343
+ combinedText = null;
6344
+ previousTextNode = null;
6345
+ let value = 0;
6346
+ while (isNumber(peek())) {
6347
+ value *= 10;
6348
+ value += consume() - 48;
6349
+ }
6350
+ while (value--) {
6351
+ addVNode(vnode_newUnMaterializedElement(child));
6352
+ child = fastNextSibling(child);
6353
+ }
6354
+ } else if (peek() === VNodeDataChar.SCOPED_STYLE) {
6355
+ vnode_setAttr(null, vParent, QScopedStyle, consumeValue());
6356
+ } else if (peek() === VNodeDataChar.RENDER_FN) {
6357
+ vnode_setAttr(null, vParent, OnRenderProp, consumeValue());
6358
+ } else if (peek() === VNodeDataChar.ID) {
6359
+ container || (container = getDomContainer(element));
6360
+ const id = consumeValue();
6361
+ container.$setRawState$(parseInt(id), vParent);
6362
+ isDev && vnode_setAttr(null, vParent, ELEMENT_ID, id);
6363
+ } else if (peek() === VNodeDataChar.PROPS) {
6364
+ vnode_setAttr(null, vParent, ELEMENT_PROPS, consumeValue());
6365
+ } else if (peek() === VNodeDataChar.SLOT_REF) {
6366
+ vnode_setAttr(null, vParent, QSlotRef, consumeValue());
6367
+ } else if (peek() === VNodeDataChar.KEY) {
6368
+ vnode_setAttr(null, vParent, ELEMENT_KEY, consumeValue());
6369
+ } else if (peek() === VNodeDataChar.SEQ) {
6370
+ vnode_setAttr(null, vParent, ELEMENT_SEQ, consumeValue());
6371
+ } else if (peek() === VNodeDataChar.SEQ_IDX) {
6372
+ vnode_setAttr(null, vParent, ELEMENT_SEQ_IDX, consumeValue());
6373
+ } else if (peek() === VNodeDataChar.SUBS) {
6374
+ vnode_setProp(vParent, QSubscribers, consumeValue());
6375
+ } else if (peek() === VNodeDataChar.CONTEXT) {
6376
+ vnode_setAttr(null, vParent, QCtxAttr, consumeValue());
6377
+ } else if (peek() === VNodeDataChar.OPEN) {
6378
+ consume();
6379
+ addVNode(vnode_newVirtual());
6380
+ stack.push(vParent, vFirst, vLast, previousTextNode, idx);
6381
+ idx = 0;
6382
+ vParent = vLast;
6383
+ vFirst = vLast = null;
6384
+ } else if (peek() === VNodeDataChar.SEPARATOR) {
6385
+ const key = consumeValue();
6386
+ const value = consumeValue();
6387
+ vnode_setAttr(null, vParent, key, value);
6388
+ } else if (peek() === VNodeDataChar.CLOSE) {
6389
+ consume();
6390
+ vParent[5] = vLast;
6391
+ idx = stack.pop();
6392
+ previousTextNode = stack.pop();
6393
+ vLast = stack.pop();
6394
+ vFirst = stack.pop();
6395
+ vParent = stack.pop();
6396
+ } else if (peek() === VNodeDataChar.SLOT) {
6397
+ vnode_setAttr(null, vParent, QSlot, consumeValue());
6398
+ } else {
6399
+ const textNode = child && 3 === fastNodeType(child) ? child : null;
6400
+ if (null === combinedText) {
6401
+ combinedText = textNode ? textNode.nodeValue : null;
6402
+ textIdx = 0;
6403
+ }
6404
+ let length = 0;
6405
+ while (isLowercase(peek())) {
6406
+ length += consume() - 97;
6407
+ length *= 26;
6408
+ }
6409
+ length += consume() - 65;
6410
+ const text = null === combinedText ? "" : combinedText.substring(textIdx, textIdx + length);
6411
+ addVNode(previousTextNode = vnode_newSharedText(previousTextNode, textNode, text));
6412
+ textIdx += length;
6420
6413
  }
6421
- vFirstChild || (vParent[4] = vFirstChild = vChild);
6422
- child = fastNextSibling(child);
6423
- skipStyleElements();
6414
+ }));
6415
+ vParent[5] = vLast;
6416
+ return vFirst;
6417
+ }
6418
+ var vnode_getType = vnode => {
6419
+ const type = vnode[0];
6420
+ if (1 & type) {
6421
+ return 1;
6424
6422
  }
6425
- vParent[5] = vChild || null;
6426
- vParent[4] = vFirstChild;
6427
- return vFirstChild;
6423
+ if (2 & type) {
6424
+ return 11;
6425
+ }
6426
+ if (4 & type) {
6427
+ return 3;
6428
+ }
6429
+ throw qError(43, [ type ]);
6428
6430
  };
6429
- var vnode_getNextSibling = vnode => vnode[3];
6430
- var vnode_getPreviousSibling = vnode => vnode[2];
6431
- var vnode_getAttrKeys = vnode => {
6432
- const type = vnode[0];
6433
- if (0 !== (3 & type)) {
6434
- vnode_ensureElementInflated(vnode);
6435
- const keys2 = [];
6436
- for (let i = vnode_getPropStartIndex(vnode); i < vnode.length; i += 2) {
6437
- const key = vnode[i];
6438
- key.startsWith(Q_PROPS_SEPARATOR) || keys2.push(key);
6431
+ var isElement = node => node && "object" == typeof node && 1 === fastNodeType(node);
6432
+ var aPath = [];
6433
+ var bPath = [];
6434
+ var vnode_documentPosition = (a, b) => {
6435
+ if (a === b) {
6436
+ return 0;
6437
+ }
6438
+ let aDepth = -1;
6439
+ let bDepth = -1;
6440
+ while (a) {
6441
+ a = (aPath[++aDepth] = a)[1];
6442
+ }
6443
+ while (b) {
6444
+ b = (bPath[++bDepth] = b)[1];
6445
+ }
6446
+ while (aDepth >= 0 && bDepth >= 0) {
6447
+ a = aPath[aDepth];
6448
+ b = bPath[bDepth];
6449
+ if (a !== b) {
6450
+ let cursor = b;
6451
+ do {
6452
+ cursor = vnode_getNextSibling(cursor);
6453
+ if (cursor === a) {
6454
+ return 1;
6455
+ }
6456
+ } while (cursor);
6457
+ cursor = b;
6458
+ do {
6459
+ cursor = vnode_getPreviousSibling(cursor);
6460
+ if (cursor === a) {
6461
+ return -1;
6462
+ }
6463
+ } while (cursor);
6464
+ return 1;
6439
6465
  }
6440
- return keys2;
6466
+ aDepth--;
6467
+ bDepth--;
6441
6468
  }
6442
- return [];
6469
+ return aDepth < bDepth ? -1 : 1;
6443
6470
  };
6444
- var vnode_setAttr = (journal, vnode, key, value) => {
6445
- const type = vnode[0];
6446
- if (0 !== (3 & type)) {
6447
- vnode_ensureElementInflated(vnode);
6448
- const idx = mapApp_findIndx(vnode, key, vnode_getPropStartIndex(vnode));
6449
- if (idx >= 0) {
6450
- if (vnode[idx + 1] != value && 0 !== (1 & type)) {
6451
- const element = vnode[6];
6452
- journal && journal.push(2, element, key, value);
6453
- }
6454
- null == value ? vnode.splice(idx, 2) : vnode[idx + 1] = value;
6455
- } else if (null != value) {
6456
- vnode.splice(~idx, 0, key, value);
6457
- if (0 !== (1 & type)) {
6458
- const element = vnode[6];
6459
- journal && journal.push(2, element, key, value);
6460
- }
6471
+ var vnode_getProjectionParentComponent = (vHost, rootVNode) => {
6472
+ let projectionDepth = 1;
6473
+ while (projectionDepth--) {
6474
+ while (vHost && (!vnode_isVirtualVNode(vHost) || null === vnode_getProp(vHost, OnRenderProp, null))) {
6475
+ const qSlotParentProp = vnode_getProp(vHost, QSlotParent, null);
6476
+ const qSlotParent = qSlotParentProp && ("string" === typeof qSlotParentProp ? vnode_locate(rootVNode, qSlotParentProp) : qSlotParentProp);
6477
+ const vProjectionParent = vnode_isVirtualVNode(vHost) && qSlotParent;
6478
+ vProjectionParent && projectionDepth++;
6479
+ vHost = vProjectionParent || vnode_getParent(vHost);
6461
6480
  }
6481
+ projectionDepth > 0 && (vHost = vnode_getParent(vHost));
6462
6482
  }
6483
+ return vHost;
6463
6484
  };
6464
- var vnode_getAttr = (vnode, key) => {
6465
- const type = vnode[0];
6466
- if (0 !== (3 & type)) {
6467
- vnode_ensureElementInflated(vnode);
6468
- return mapArray_get(vnode, key, vnode_getPropStartIndex(vnode));
6485
+ var VNodeArray = class VNode extends Array {
6486
+ static createElement(flags, parent, previousSibling, nextSibling, firstChild, lastChild, element, elementName) {
6487
+ const vnode = new VNode(flags, parent, previousSibling, nextSibling);
6488
+ vnode.push(firstChild, lastChild, element, elementName);
6489
+ return vnode;
6469
6490
  }
6470
- return null;
6471
- };
6472
- var vnode_getProp = (vnode, key, getObject) => {
6473
- const type = vnode[0];
6474
- if (0 !== (3 & type)) {
6475
- 1 & type && vnode_ensureElementInflated(vnode);
6476
- const idx = mapApp_findIndx(vnode, key, vnode_getPropStartIndex(vnode));
6477
- if (idx >= 0) {
6478
- let value = vnode[idx + 1];
6479
- "string" === typeof value && getObject && (vnode[idx + 1] = value = getObject(value));
6480
- return value;
6481
- }
6491
+ static createText(flags, parent, previousSibling, nextSibling, textNode, text) {
6492
+ const vnode = new VNode(flags, parent, previousSibling, nextSibling);
6493
+ vnode.push(textNode, text);
6494
+ return vnode;
6482
6495
  }
6483
- return null;
6484
- };
6485
- var vnode_setProp = (vnode, key, value) => {
6486
- ensureElementOrVirtualVNode(vnode);
6487
- const idx = mapApp_findIndx(vnode, key, vnode_getPropStartIndex(vnode));
6488
- idx >= 0 ? vnode[idx + 1] = value : null != value && vnode.splice(~idx, 0, key, value);
6489
- };
6490
- var vnode_getPropStartIndex = vnode => {
6491
- const type = 7 & vnode[0];
6492
- if (1 === type) {
6493
- return 8;
6496
+ static createVirtual(flags, parent, previousSibling, nextSibling, firstChild, lastChild) {
6497
+ const vnode = new VNode(flags, parent, previousSibling, nextSibling);
6498
+ vnode.push(firstChild, lastChild);
6499
+ return vnode;
6494
6500
  }
6495
- if (2 === type) {
6496
- return 6;
6501
+ constructor(flags, parent, previousSibling, nextSibling) {
6502
+ super();
6503
+ this.push(flags, parent, previousSibling, nextSibling);
6504
+ isDev && (this.toString = vnode_toString);
6497
6505
  }
6498
- throw throwErrorAndStop("Invalid vnode type.");
6499
6506
  };
6500
- var vnode_getParent = vnode => vnode[1] || null;
6501
- var vnode_getNode = vnode => {
6502
- if (null === vnode || vnode_isVirtualVNode(vnode)) {
6503
- return null;
6504
- }
6505
- if (vnode_isElementVNode(vnode)) {
6506
- return vnode[6];
6507
+ var _context;
6508
+ var tryGetInvokeContext = () => {
6509
+ if (!_context) {
6510
+ const context = "undefined" !== typeof document && document && document.__q_context__;
6511
+ if (!context) {
6512
+ return;
6513
+ }
6514
+ if (isArray(context)) {
6515
+ return document.__q_context__ = newInvokeContextFromTuple(context);
6516
+ }
6517
+ return context;
6507
6518
  }
6508
- assertTrue(vnode_isTextVNode(vnode), "Expecting Text Node.");
6509
- return vnode[4];
6519
+ return _context;
6510
6520
  };
6511
- function vnode_toString(depth = 10, offset = "", materialize = false, siblings = false) {
6512
- var _a;
6513
- let vnode = this;
6514
- if (0 === depth) {
6515
- return "...";
6521
+ function invoke(context, fn, ...args) {
6522
+ return invokeApply.call(this, context, fn, args);
6523
+ }
6524
+ function invokeApply(context, fn, args) {
6525
+ const previousContext = _context;
6526
+ let returnValue;
6527
+ try {
6528
+ _context = context;
6529
+ returnValue = fn.apply(this, args);
6530
+ } finally {
6531
+ _context = previousContext;
6516
6532
  }
6517
- if (null === vnode) {
6518
- return "null";
6533
+ return returnValue;
6534
+ }
6535
+ var newInvokeContextFromTuple = ([element, event, url]) => {
6536
+ const container = element.closest(QContainerSelector);
6537
+ const locale = (null == container ? void 0 : container.getAttribute(QLocaleAttr)) || void 0;
6538
+ locale && setLocale(locale);
6539
+ return newInvokeContext(locale, void 0, element, event, url);
6540
+ };
6541
+ var newInvokeContext = (locale, hostElement, element, event, url) => {
6542
+ const $locale$ = locale || ("object" === typeof event && event && "locale" in event ? event.locale : void 0);
6543
+ const ctx = {
6544
+ $url$: url,
6545
+ $i$: 0,
6546
+ $hostElement$: hostElement,
6547
+ $element$: element,
6548
+ $event$: event,
6549
+ $qrl$: void 0,
6550
+ $effectSubscriber$: void 0,
6551
+ $locale$: $locale$,
6552
+ $container$: void 0
6553
+ };
6554
+ seal(ctx);
6555
+ return ctx;
6556
+ };
6557
+ var untrack = fn => invoke(void 0, fn);
6558
+ var trackInvocation = newInvokeContext(void 0, void 0, void 0, RenderEvent);
6559
+ var trackSignal = (fn, subscriber, property, container, data) => {
6560
+ const previousSubscriber = trackInvocation.$effectSubscriber$;
6561
+ const previousContainer = trackInvocation.$container$;
6562
+ try {
6563
+ trackInvocation.$effectSubscriber$ = [ subscriber, property ];
6564
+ data && trackInvocation.$effectSubscriber$.push(data);
6565
+ trackInvocation.$container$ = container;
6566
+ return invoke(trackInvocation, fn);
6567
+ } finally {
6568
+ trackInvocation.$effectSubscriber$ = previousSubscriber;
6569
+ trackInvocation.$container$ = previousContainer;
6519
6570
  }
6520
- if (void 0 === vnode) {
6521
- return "undefined";
6571
+ };
6572
+ var trackSignalAndAssignHost = (value, host, property, container, data) => {
6573
+ value instanceof WrappedSignal && value.$hostElement$ !== host && host && (value.$hostElement$ = host);
6574
+ return trackSignal((() => value.value), host, property, container, data);
6575
+ };
6576
+ var createContextId = name => {
6577
+ assertTrue(/^[\w/.-]+$/.test(name), "Context name must only contain A-Z,a-z,0-9, _", name);
6578
+ return Object.freeze({
6579
+ id: fromCamelToKebabCase(name)
6580
+ });
6581
+ };
6582
+ var ERROR_CONTEXT = createContextId("qk-error");
6583
+ var isRecoverable = err => {
6584
+ if (err && err instanceof Error && "plugin" in err) {
6585
+ return false;
6522
6586
  }
6523
- const strings = [];
6524
- do {
6525
- if (vnode_isTextVNode(vnode)) {
6526
- strings.push(qwikDebugToString(vnode_getText(vnode)));
6527
- } else if (vnode_isVirtualVNode(vnode)) {
6528
- const idx = vnode[0] >>> 8;
6529
- const attrs = [ "[" + String(idx) + "]" ];
6530
- vnode_getAttrKeys(vnode).forEach((key => {
6531
- if (key !== DEBUG_TYPE) {
6532
- const value = vnode_getAttr(vnode, key);
6533
- attrs.push(" " + key + "=" + qwikDebugToString(value));
6534
- }
6535
- }));
6536
- const name = VirtualTypeName[vnode_getAttr(vnode, DEBUG_TYPE) || "V"] || VirtualTypeName.V;
6537
- strings.push("<" + name + attrs.join("") + ">");
6538
- const child = vnode_getFirstChild(vnode);
6539
- child && strings.push(" " + vnode_toString.call(child, depth - 1, offset + " ", true, true));
6540
- strings.push("</" + name + ">");
6541
- } else if (vnode_isElementVNode(vnode)) {
6542
- const tag = vnode_getElementName(vnode);
6543
- const attrs = [];
6544
- const keys2 = vnode_getAttrKeys(vnode);
6545
- keys2.forEach((key => {
6546
- const value = vnode_getAttr(vnode, key);
6547
- attrs.push(" " + key + "=" + qwikDebugToString(value));
6548
- }));
6549
- const node = vnode_getNode(vnode);
6550
- if (node) {
6551
- const vnodeData = null == (_a = node.ownerDocument.qVNodeData) ? void 0 : _a.get(node);
6552
- vnodeData && attrs.push(" q:vnodeData=" + qwikDebugToString(vnodeData));
6587
+ return true;
6588
+ };
6589
+ function processVNodeData2(document2) {
6590
+ const Q_CONTAINER = "q:container";
6591
+ const Q_CONTAINER_END = "/" + Q_CONTAINER;
6592
+ const Q_PROPS_SEPARATOR2 = ":";
6593
+ const Q_SHADOW_ROOT = "q:shadowroot";
6594
+ const Q_IGNORE = "q:ignore";
6595
+ const Q_IGNORE_END = "/" + Q_IGNORE;
6596
+ const Q_CONTAINER_ISLAND = "q:container-island";
6597
+ const Q_CONTAINER_ISLAND_END = "/" + Q_CONTAINER_ISLAND;
6598
+ const qDocument = document2;
6599
+ const vNodeDataMap = qDocument.qVNodeData || (qDocument.qVNodeData = new WeakMap);
6600
+ const prototype = document2.body;
6601
+ const getter = (prototype2, name) => {
6602
+ var _a;
6603
+ let getter2;
6604
+ while (prototype2 && !(getter2 = null == (_a = Object.getOwnPropertyDescriptor(prototype2, name)) ? void 0 : _a.get)) {
6605
+ prototype2 = Object.getPrototypeOf(prototype2);
6606
+ }
6607
+ return getter2 || function() {
6608
+ return this[name];
6609
+ };
6610
+ };
6611
+ const getAttribute = prototype.getAttribute;
6612
+ const hasAttribute = prototype.hasAttribute;
6613
+ const getNodeType = getter(prototype, "nodeType");
6614
+ const attachVnodeDataAndRefs = element => {
6615
+ Array.from(element.querySelectorAll('script[type="qwik/vnode"]')).forEach((script => {
6616
+ script.setAttribute("type", "x-qwik/vnode");
6617
+ const qContainerElement = script.closest("[q\\:container]");
6618
+ qContainerElement.qVnodeData = script.textContent;
6619
+ qContainerElement.qVNodeRefs = new Map;
6620
+ }));
6621
+ element.querySelectorAll("[q\\:shadowroot]").forEach((parent => {
6622
+ const shadowRoot = parent.shadowRoot;
6623
+ shadowRoot && attachVnodeDataAndRefs(shadowRoot);
6624
+ }));
6625
+ };
6626
+ attachVnodeDataAndRefs(document2);
6627
+ let NodeType;
6628
+ (NodeType2 => {
6629
+ NodeType2[NodeType2.CONTAINER_MASK = 1] = "CONTAINER_MASK";
6630
+ NodeType2[NodeType2.ELEMENT = 2] = "ELEMENT";
6631
+ NodeType2[NodeType2.ELEMENT_CONTAINER = 3] = "ELEMENT_CONTAINER";
6632
+ NodeType2[NodeType2.ELEMENT_SHADOW_ROOT = 6] = "ELEMENT_SHADOW_ROOT";
6633
+ NodeType2[NodeType2.COMMENT_SKIP_START = 5] = "COMMENT_SKIP_START";
6634
+ NodeType2[NodeType2.COMMENT_SKIP_END = 8] = "COMMENT_SKIP_END";
6635
+ NodeType2[NodeType2.COMMENT_IGNORE_START = 16] = "COMMENT_IGNORE_START";
6636
+ NodeType2[NodeType2.COMMENT_IGNORE_END = 32] = "COMMENT_IGNORE_END";
6637
+ NodeType2[NodeType2.COMMENT_ISLAND_START = 65] = "COMMENT_ISLAND_START";
6638
+ NodeType2[NodeType2.COMMENT_ISLAND_END = 128] = "COMMENT_ISLAND_END";
6639
+ NodeType2[NodeType2.OTHER = 0] = "OTHER";
6640
+ })(NodeType || (NodeType = {}));
6641
+ const getFastNodeType = node => {
6642
+ const nodeType = getNodeType.call(node);
6643
+ if (1 === nodeType) {
6644
+ const qContainer = getAttribute.call(node, Q_CONTAINER);
6645
+ if (null === qContainer) {
6646
+ if (hasAttribute.call(node, Q_SHADOW_ROOT)) {
6647
+ return 6;
6648
+ }
6649
+ const isQElement = hasAttribute.call(node, Q_PROPS_SEPARATOR2);
6650
+ return isQElement ? 2 : 0;
6553
6651
  }
6554
- const domAttrs = node.attributes;
6555
- for (let i = 0; i < domAttrs.length; i++) {
6556
- const attr = domAttrs[i];
6557
- -1 === keys2.indexOf(attr.name) && attrs.push(" " + attr.name + (attr.value ? "=" + qwikDebugToString(attr.value) : ""));
6652
+ return 3;
6653
+ }
6654
+ if (8 === nodeType) {
6655
+ const nodeValue = node.nodeValue || "";
6656
+ if (nodeValue.startsWith(Q_CONTAINER_ISLAND)) {
6657
+ return 65;
6558
6658
  }
6559
- strings.push("<" + tag + attrs.join("") + ">");
6560
- if (vnode_isMaterialized(vnode) || materialize) {
6561
- const child = vnode_getFirstChild(vnode);
6562
- child && strings.push(" " + vnode_toString.call(child, depth - 1, offset + " ", true, true));
6563
- } else {
6564
- strings.push(" \x3c!-- not materialized --!>");
6659
+ if (nodeValue.startsWith(Q_IGNORE)) {
6660
+ return 16;
6661
+ }
6662
+ if (nodeValue.startsWith(Q_CONTAINER)) {
6663
+ return 5;
6664
+ }
6665
+ if (nodeValue.startsWith(Q_CONTAINER_ISLAND_END)) {
6666
+ return 128;
6667
+ }
6668
+ if (nodeValue.startsWith(Q_IGNORE_END)) {
6669
+ return 32;
6670
+ }
6671
+ if (nodeValue.startsWith(Q_CONTAINER_END)) {
6672
+ return 8;
6565
6673
  }
6566
- strings.push("</" + tag + ">");
6567
- }
6568
- vnode = siblings && vnode_getNextSibling(vnode) || null;
6569
- } while (vnode);
6570
- return strings.join("\n" + offset);
6571
- }
6572
- var isNumber = ch => 48 <= ch && ch <= 57;
6573
- var isLowercase = ch => 97 <= ch && ch <= 122;
6574
- var stack = [];
6575
- function materializeFromVNodeData(vParent, vData, element, child) {
6576
- let idx = 0;
6577
- let nextToConsumeIdx = 0;
6578
- let vFirst = null;
6579
- let vLast = null;
6580
- let previousTextNode = null;
6581
- let ch = 0;
6582
- let peekCh = 0;
6583
- const peek = () => 0 !== peekCh ? peekCh : peekCh = nextToConsumeIdx < vData.length ? vData.charCodeAt(nextToConsumeIdx) : 0;
6584
- const consume = () => {
6585
- ch = peek();
6586
- peekCh = 0;
6587
- nextToConsumeIdx++;
6588
- return ch;
6589
- };
6590
- const addVNode = node => {
6591
- node[0] = 255 & node[0] | idx << 8;
6592
- idx++;
6593
- vLast && (vLast[3] = node);
6594
- node[2] = vLast;
6595
- node[1] = vParent;
6596
- vFirst || (vParent[4] = vFirst = node);
6597
- vLast = node;
6598
- };
6599
- const consumeValue = () => {
6600
- consume();
6601
- const start = nextToConsumeIdx;
6602
- while (peek() <= 58 && 0 !== peekCh || 95 === peekCh || peekCh >= 65 && peekCh <= 90 || peekCh >= 97 && peekCh <= 122) {
6603
- consume();
6604
6674
  }
6605
- return vData.substring(start, nextToConsumeIdx);
6675
+ return 0;
6606
6676
  };
6607
- let textIdx = 0;
6608
- let combinedText = null;
6609
- let container = null;
6610
- while (0 !== peek()) {
6611
- if (isNumber(peek())) {
6612
- while (!isElement(child)) {
6613
- child = fastNextSibling(child);
6614
- child || throwErrorAndStop("Materialize error: missing element: " + vData + " " + peek() + " " + nextToConsumeIdx);
6677
+ const isSeparator = ch => VNodeDataSeparator.ADVANCE_1 <= ch && ch <= VNodeDataSeparator.ADVANCE_8192;
6678
+ const findVDataSectionEnd = (vData, start, end) => {
6679
+ let depth = 0;
6680
+ while (true) {
6681
+ if (!(start < end)) {
6682
+ break;
6615
6683
  }
6616
- while (isQStyleElement(child)) {
6617
- child = fastNextSibling(child);
6684
+ {
6685
+ const ch = vData.charCodeAt(start);
6686
+ if (0 === depth && isSeparator(ch)) {
6687
+ break;
6688
+ }
6689
+ ch === VNodeDataChar.OPEN ? depth++ : ch === VNodeDataChar.CLOSE && depth--;
6690
+ start++;
6618
6691
  }
6619
- combinedText = null;
6620
- previousTextNode = null;
6621
- let value = 0;
6622
- while (isNumber(peek())) {
6623
- value *= 10;
6624
- value += consume() - 48;
6692
+ }
6693
+ return start;
6694
+ };
6695
+ const nextSibling = node => {
6696
+ while (node && (node = node.nextSibling) && 0 === getFastNodeType(node)) {}
6697
+ return node;
6698
+ };
6699
+ const firstChild = node => {
6700
+ while (node && (node = node.firstChild) && 0 === getFastNodeType(node)) {}
6701
+ return node;
6702
+ };
6703
+ const walkContainer = (walker2, containerNode, node, exitNode, vData, qVNodeRefs, prefix) => {
6704
+ const vData_length = vData.length;
6705
+ let elementIdx = 0;
6706
+ let vNodeElementIndex = -1;
6707
+ let vData_start = 0;
6708
+ let vData_end = 0;
6709
+ let ch = 0;
6710
+ let needsToStoreRef = -1;
6711
+ let nextNode = null;
6712
+ const howManyElementsToSkip = () => {
6713
+ let elementsToSkip = 0;
6714
+ while (isSeparator(ch = vData.charCodeAt(vData_start))) {
6715
+ elementsToSkip += 1 << ch - VNodeDataSeparator.ADVANCE_1;
6716
+ vData_start++;
6717
+ if (vData_start >= vData_length) {
6718
+ break;
6719
+ }
6625
6720
  }
6626
- while (value--) {
6627
- addVNode(vnode_newUnMaterializedElement(child));
6628
- child = fastNextSibling(child);
6721
+ return elementsToSkip;
6722
+ };
6723
+ do {
6724
+ if (node === exitNode) {
6725
+ return;
6629
6726
  }
6630
- } else if (peek() === VNodeDataChar.SCOPED_STYLE) {
6631
- vnode_setAttr(null, vParent, QScopedStyle, consumeValue());
6632
- } else if (peek() === VNodeDataChar.RENDER_FN) {
6633
- vnode_setAttr(null, vParent, OnRenderProp, consumeValue());
6634
- } else if (peek() === VNodeDataChar.ID) {
6635
- container || (container = getDomContainer(element));
6636
- const id = consumeValue();
6637
- container.$setRawState$(parseInt(id), vParent);
6638
- isDev && vnode_setAttr(null, vParent, ELEMENT_ID, id);
6639
- } else if (peek() === VNodeDataChar.PROPS) {
6640
- vnode_setAttr(null, vParent, ELEMENT_PROPS, consumeValue());
6641
- } else if (peek() === VNodeDataChar.SLOT_REF) {
6642
- vnode_setAttr(null, vParent, QSlotRef, consumeValue());
6643
- } else if (peek() === VNodeDataChar.KEY) {
6644
- vnode_setAttr(null, vParent, ELEMENT_KEY, consumeValue());
6645
- } else if (peek() === VNodeDataChar.SEQ) {
6646
- vnode_setAttr(null, vParent, ELEMENT_SEQ, consumeValue());
6647
- } else if (peek() === VNodeDataChar.SEQ_IDX) {
6648
- vnode_setAttr(null, vParent, ELEMENT_SEQ_IDX, consumeValue());
6649
- } else if (peek() === VNodeDataChar.CONTEXT) {
6650
- vnode_setAttr(null, vParent, QCtxAttr, consumeValue());
6651
- } else if (peek() === VNodeDataChar.OPEN) {
6652
- consume();
6653
- addVNode(vnode_newVirtual());
6654
- stack.push(vParent, vFirst, vLast, previousTextNode, idx);
6655
- idx = 0;
6656
- vParent = vLast;
6657
- vFirst = vLast = null;
6658
- } else if (peek() === VNodeDataChar.SEPARATOR) {
6659
- const key = consumeValue();
6660
- const value = consumeValue();
6661
- vnode_setAttr(null, vParent, key, value);
6662
- } else if (peek() === VNodeDataChar.CLOSE) {
6663
- consume();
6664
- vParent[5] = vLast;
6665
- idx = stack.pop();
6666
- previousTextNode = stack.pop();
6667
- vLast = stack.pop();
6668
- vFirst = stack.pop();
6669
- vParent = stack.pop();
6670
- } else if (peek() === VNodeDataChar.SLOT) {
6671
- vnode_setAttr(null, vParent, QSlot, consumeValue());
6672
- } else {
6673
- const textNode = child && 3 === fastNodeType(child) ? child : null;
6674
- if (null === combinedText) {
6675
- combinedText = textNode ? textNode.nodeValue : null;
6676
- textIdx = 0;
6727
+ nextNode = null;
6728
+ const nodeType = node == containerNode ? 2 : getFastNodeType(node);
6729
+ if (3 === nodeType) {
6730
+ const container = node;
6731
+ let cursor = node;
6732
+ while (cursor && !(nextNode = nextSibling(cursor))) {
6733
+ cursor = cursor.parentNode;
6734
+ }
6735
+ walkContainer(walker2, container, node, nextNode, container.qVnodeData || "", container.qVNodeRefs, prefix + " ");
6736
+ } else if (16 === nodeType) {
6737
+ let islandNode = node;
6738
+ do {
6739
+ islandNode = walker2.nextNode();
6740
+ if (!islandNode) {
6741
+ throw new Error(`Island inside \x3c!--${null == node ? void 0 : node.nodeValue}--\x3e not found!`);
6742
+ }
6743
+ } while (65 !== getFastNodeType(islandNode));
6744
+ nextNode = null;
6745
+ } else if (128 === nodeType) {
6746
+ nextNode = node;
6747
+ do {
6748
+ nextNode = walker2.nextNode();
6749
+ if (!nextNode) {
6750
+ throw new Error("Ignore block not closed!");
6751
+ }
6752
+ } while (32 !== getFastNodeType(nextNode));
6753
+ nextNode = null;
6754
+ } else if (5 === nodeType) {
6755
+ nextNode = node;
6756
+ do {
6757
+ nextNode = nextSibling(nextNode);
6758
+ if (!nextNode) {
6759
+ throw new Error(`\x3c!--${null == node ? void 0 : node.nodeValue}--\x3e not closed!`);
6760
+ }
6761
+ } while (8 !== getFastNodeType(nextNode));
6762
+ walkContainer(walker2, node, node, nextNode, "", null, prefix + " ");
6763
+ } else if (6 === nodeType) {
6764
+ nextNode = nextSibling(node);
6765
+ const shadowRootContainer = node;
6766
+ const shadowRoot = null == shadowRootContainer ? void 0 : shadowRootContainer.shadowRoot;
6767
+ shadowRoot && walkContainer(document2.createTreeWalker(shadowRoot, 129), null, firstChild(shadowRoot), null, "", null, prefix + " ");
6677
6768
  }
6678
- let length = 0;
6679
- while (isLowercase(peek())) {
6680
- length += consume() - 97;
6681
- length *= 26;
6769
+ if (2 === (2 & nodeType)) {
6770
+ if (vNodeElementIndex < elementIdx) {
6771
+ -1 === vNodeElementIndex && (vNodeElementIndex = 0);
6772
+ vData_start = vData_end;
6773
+ if (vData_start < vData_length) {
6774
+ vNodeElementIndex += howManyElementsToSkip();
6775
+ const shouldStoreRef = ch === VNodeDataSeparator.REFERENCE;
6776
+ if (shouldStoreRef) {
6777
+ needsToStoreRef = vNodeElementIndex;
6778
+ vData_start++;
6779
+ ch = vData_start < vData_length ? vData.charCodeAt(vData_end) : VNodeDataSeparator.ADVANCE_1;
6780
+ }
6781
+ vData_end = findVDataSectionEnd(vData, vData_start, vData_length);
6782
+ } else {
6783
+ vNodeElementIndex = Number.MAX_SAFE_INTEGER;
6784
+ }
6785
+ }
6786
+ if (elementIdx === vNodeElementIndex) {
6787
+ needsToStoreRef === elementIdx && qVNodeRefs.set(elementIdx, node);
6788
+ const instructions = vData.substring(vData_start, vData_end);
6789
+ vNodeDataMap.set(node, instructions);
6790
+ }
6791
+ elementIdx++;
6682
6792
  }
6683
- length += consume() - 65;
6684
- const text = null === combinedText ? "" : combinedText.substring(textIdx, textIdx + length);
6685
- addVNode(previousTextNode = vnode_newSharedText(previousTextNode, textNode, text));
6686
- textIdx += length;
6687
- }
6688
- }
6689
- vParent[5] = vLast;
6690
- return vFirst;
6793
+ } while (node = nextNode || walker2.nextNode());
6794
+ };
6795
+ const walker = document2.createTreeWalker(document2, 129);
6796
+ walkContainer(walker, null, walker.firstChild(), null, "", null, "");
6691
6797
  }
6692
- var vnode_getType = vnode => {
6693
- const type = vnode[0];
6694
- if (1 & type) {
6695
- return 1;
6696
- }
6697
- if (2 & type) {
6698
- return 11;
6699
- }
6700
- if (4 & type) {
6701
- return 3;
6702
- }
6703
- throw throwErrorAndStop("Unknown vnode type: " + type);
6704
- };
6705
- var isElement = node => node && "object" == typeof node && 1 === fastNodeType(node);
6706
- var aPath = [];
6707
- var bPath = [];
6708
- var vnode_documentPosition = (a, b) => {
6709
- if (a === b) {
6710
- return 0;
6711
- }
6712
- let aDepth = -1;
6713
- let bDepth = -1;
6714
- while (a) {
6715
- a = (aPath[++aDepth] = a)[1];
6716
- }
6717
- while (b) {
6718
- b = (bPath[++bDepth] = b)[1];
6798
+ function getDomContainer(element) {
6799
+ const qContainerElement = _getQContainerElement(element);
6800
+ if (!qContainerElement) {
6801
+ throw qError(41);
6719
6802
  }
6720
- while (aDepth >= 0 && bDepth >= 0) {
6721
- a = aPath[aDepth];
6722
- b = bPath[bDepth];
6723
- if (a !== b) {
6724
- let cursor = b;
6725
- do {
6726
- cursor = vnode_getNextSibling(cursor);
6727
- if (cursor === a) {
6728
- return 1;
6729
- }
6730
- } while (cursor);
6731
- cursor = b;
6732
- do {
6733
- cursor = vnode_getPreviousSibling(cursor);
6734
- if (cursor === a) {
6735
- return -1;
6803
+ return getDomContainerFromQContainerElement(qContainerElement);
6804
+ }
6805
+ function getDomContainerFromQContainerElement(qContainerElement) {
6806
+ const qElement = qContainerElement;
6807
+ let container = qElement.qContainer;
6808
+ if (!container) {
6809
+ container = new DomContainer(qElement);
6810
+ const containerAttributes = {};
6811
+ if (qElement) {
6812
+ const attrs = qElement.attributes;
6813
+ if (attrs) {
6814
+ for (let index = 0; index < attrs.length; index++) {
6815
+ const attr = attrs[index];
6816
+ if (attr.name === Q_PROPS_SEPARATOR) {
6817
+ continue;
6818
+ }
6819
+ containerAttributes[attr.name] = attr.value;
6736
6820
  }
6737
- } while (cursor);
6738
- return 1;
6739
- }
6740
- aDepth--;
6741
- bDepth--;
6742
- }
6743
- return aDepth < bDepth ? -1 : 1;
6744
- };
6745
- var vnode_getProjectionParentComponent = (vHost, rootVNode) => {
6746
- let projectionDepth = 1;
6747
- while (projectionDepth--) {
6748
- while (vHost && (!vnode_isVirtualVNode(vHost) || null === vnode_getProp(vHost, OnRenderProp, null))) {
6749
- const qSlotParentProp = vnode_getProp(vHost, QSlotParent, null);
6750
- const qSlotParent = qSlotParentProp && ("string" === typeof qSlotParentProp ? vnode_locate(rootVNode, qSlotParentProp) : qSlotParentProp);
6751
- const vProjectionParent = vnode_isVirtualVNode(vHost) && qSlotParent;
6752
- vProjectionParent && projectionDepth++;
6753
- vHost = vProjectionParent || vnode_getParent(vHost);
6754
- }
6755
- projectionDepth > 0 && (vHost = vnode_getParent(vHost));
6756
- }
6757
- return vHost;
6758
- };
6759
- var VNodeArray = class VNode extends Array {
6760
- static createElement(flags, parent, previousSibling, nextSibling, firstChild, lastChild, element, elementName) {
6761
- const vnode = new VNode(flags, parent, previousSibling, nextSibling);
6762
- vnode.push(firstChild, lastChild, element, elementName);
6763
- return vnode;
6764
- }
6765
- static createText(flags, parent, previousSibling, nextSibling, textNode, text) {
6766
- const vnode = new VNode(flags, parent, previousSibling, nextSibling);
6767
- vnode.push(textNode, text);
6768
- return vnode;
6769
- }
6770
- static createVirtual(flags, parent, previousSibling, nextSibling, firstChild, lastChild) {
6771
- const vnode = new VNode(flags, parent, previousSibling, nextSibling);
6772
- vnode.push(firstChild, lastChild);
6773
- return vnode;
6774
- }
6775
- constructor(flags, parent, previousSibling, nextSibling) {
6776
- super();
6777
- this.push(flags, parent, previousSibling, nextSibling);
6778
- isDev && (this.toString = vnode_toString);
6779
- }
6780
- };
6781
- var _context;
6782
- var tryGetInvokeContext = () => {
6783
- if (!_context) {
6784
- const context = "undefined" !== typeof document && document && document.__q_context__;
6785
- if (!context) {
6786
- return;
6787
- }
6788
- if (isArray(context)) {
6789
- return document.__q_context__ = newInvokeContextFromTuple(context);
6821
+ }
6790
6822
  }
6791
- return context;
6792
- }
6793
- return _context;
6794
- };
6795
- var useInvokeContext = () => {
6796
- const ctx = tryGetInvokeContext();
6797
- if (!ctx || ctx.$event$ !== RenderEvent) {
6798
- throw qError(QError_useInvokeContext);
6823
+ container.$serverData$ = {
6824
+ containerAttributes: containerAttributes
6825
+ };
6826
+ qElement.setAttribute(QContainerAttr, "resumed");
6827
+ qElement.qContainer = container;
6799
6828
  }
6800
- assertDefined(ctx.$hostElement$, "invoke: $hostElement$ must be defined", ctx);
6801
- assertDefined(ctx.$effectSubscriber$, "invoke: $effectSubscriber$ must be defined", ctx);
6802
- return ctx;
6803
- };
6804
- function invoke(context, fn, ...args) {
6805
- return invokeApply.call(this, context, fn, args);
6829
+ return container;
6806
6830
  }
6807
- function invokeApply(context, fn, args) {
6808
- const previousContext = _context;
6809
- let returnValue;
6810
- try {
6811
- _context = context;
6812
- returnValue = fn.apply(this, args);
6813
- } finally {
6814
- _context = previousContext;
6815
- }
6816
- return returnValue;
6831
+ function _getQContainerElement(element) {
6832
+ const qContainerElement = Array.isArray(element) ? vnode_getDomParent(element) : element;
6833
+ return qContainerElement.closest(QContainerSelector);
6817
6834
  }
6818
- var newInvokeContextFromTuple = ([element, event, url]) => {
6819
- const container = element.closest(QContainerSelector);
6820
- const locale = (null == container ? void 0 : container.getAttribute(QLocaleAttr)) || void 0;
6821
- locale && setLocale(locale);
6822
- return newInvokeContext(locale, void 0, element, event, url);
6823
- };
6824
- var newInvokeContext = (locale, hostElement, element, event, url) => {
6825
- const $locale$ = locale || ("object" === typeof event && event && "locale" in event ? event.locale : void 0);
6826
- const ctx = {
6827
- $url$: url,
6828
- $i$: 0,
6829
- $hostElement$: hostElement,
6830
- $element$: element,
6831
- $event$: event,
6832
- $qrl$: void 0,
6833
- $effectSubscriber$: void 0,
6834
- $locale$: $locale$,
6835
- $container$: void 0
6836
- };
6837
- seal(ctx);
6838
- return ctx;
6839
- };
6840
- var untrack = fn => invoke(void 0, fn);
6841
- var trackInvocation = newInvokeContext(void 0, void 0, void 0, RenderEvent);
6842
- var trackSignal = (fn, subscriber, property, container, data) => {
6843
- const previousSubscriber = trackInvocation.$effectSubscriber$;
6844
- const previousContainer = trackInvocation.$container$;
6845
- try {
6846
- trackInvocation.$effectSubscriber$ = [ subscriber, property ];
6847
- data && trackInvocation.$effectSubscriber$.push(data);
6848
- trackInvocation.$container$ = container;
6849
- return invoke(trackInvocation, fn);
6850
- } finally {
6851
- trackInvocation.$effectSubscriber$ = previousSubscriber;
6852
- trackInvocation.$container$ = previousContainer;
6853
- }
6854
- };
6855
- var _jsxSorted = (type, varProps, constProps, children, flags, key, dev) => {
6856
- const processed = null == key ? null : String(key);
6857
- const node = new JSXNodeImpl(type, varProps || {}, constProps || null, children, flags, processed);
6858
- qDev && dev && (node.dev = {
6859
- stack: (new Error).stack,
6860
- ...dev
6861
- });
6862
- seal(node);
6863
- return node;
6864
- };
6865
- var _jsxSplit = (type, varProps, constProps, children, flags, key, dev) => {
6866
- let sortedProps;
6867
- sortedProps = varProps ? Object.fromEntries(untrack((() => Object.entries(varProps))).filter((entry => {
6868
- const attr = entry[0];
6869
- if ("children" === attr) {
6870
- children ??= entry[1];
6871
- return false;
6835
+ var isDomContainer = container => container instanceof DomContainer;
6836
+ var DomContainer = class extends _SharedContainer {
6837
+ element;
6838
+ qContainer;
6839
+ qBase;
6840
+ qManifestHash;
6841
+ rootVNode;
6842
+ document;
6843
+ $journal$;
6844
+ renderDone=null;
6845
+ $rawStateData$;
6846
+ $storeProxyMap$=new WeakMap;
6847
+ $qFuncs$;
6848
+ $instanceHash$;
6849
+ stateData;
6850
+ $styleIds$=null;
6851
+ $vnodeLocate$=id => vnode_locate(this.rootVNode, id);
6852
+ $renderCount$=0;
6853
+ constructor(element) {
6854
+ super((() => this.scheduleRender()), (() => vnode_applyJournal(this.$journal$)), {}, element.getAttribute("q:locale"));
6855
+ this.qContainer = element.getAttribute(QContainerAttr);
6856
+ if (!this.qContainer) {
6857
+ throw qError(42);
6872
6858
  }
6873
- if ("key" === attr) {
6874
- key = entry[1];
6875
- return false;
6859
+ this.$journal$ = [ 3, element.ownerDocument ];
6860
+ this.document = element.ownerDocument;
6861
+ this.element = element;
6862
+ this.qBase = element.getAttribute(QBaseAttr);
6863
+ this.$instanceHash$ = element.getAttribute(QInstanceAttr);
6864
+ this.qManifestHash = element.getAttribute("q:manifest-hash");
6865
+ this.rootVNode = vnode_newUnMaterializedElement(this.element);
6866
+ this.$rawStateData$ = null;
6867
+ this.stateData = null;
6868
+ const document2 = this.element.ownerDocument;
6869
+ document2.qVNodeData || processVNodeData2(document2);
6870
+ this.$rawStateData$ = [];
6871
+ this.stateData = [];
6872
+ const qwikStates = element.querySelectorAll('script[type="qwik/state"]');
6873
+ if (0 !== qwikStates.length) {
6874
+ const lastState = qwikStates[qwikStates.length - 1];
6875
+ this.$rawStateData$ = JSON.parse(lastState.textContent);
6876
+ this.stateData = wrapDeserializerProxy(this, this.$rawStateData$);
6876
6877
  }
6877
- return !constProps || !(attr in constProps) || /^on[A-Z].*\$$/.test(attr);
6878
- })).sort((([a], [b]) => a < b ? -1 : 1))) : "string" === typeof type ? EMPTY_OBJ : {};
6879
- if (constProps && "children" in constProps) {
6880
- children = constProps.children;
6881
- constProps.children = void 0;
6878
+ this.$qFuncs$ = getQFuncs(document2, this.$instanceHash$) || EMPTY_ARRAY;
6882
6879
  }
6883
- return _jsxSorted(type, sortedProps, constProps, children, flags, key, dev);
6884
- };
6885
- var isPropsProxy = obj => obj && void 0 !== obj[_VAR_PROPS];
6886
- var JSXNodeImpl = class {
6887
- constructor(type, varProps, constProps, children, flags, key = null) {
6888
- this.type = type;
6889
- this.varProps = varProps;
6890
- this.constProps = constProps;
6891
- this.children = children;
6892
- this.flags = flags;
6893
- this.key = key;
6880
+ $setRawState$(id, vParent) {
6881
+ this.stateData[id] = vParent;
6882
+ }
6883
+ parseQRL(qrl) {
6884
+ return inflateQRL(this, parseQRL(qrl));
6885
+ }
6886
+ handleError(err, host) {
6894
6887
  if (qDev) {
6895
- if ("object" !== typeof varProps) {
6896
- throw new Error("JSXNodeImpl: varProps must be objects: " + JSON.stringify(varProps));
6888
+ if ("undefined" !== typeof document) {
6889
+ const vHost = host;
6890
+ const errorDiv = document.createElement("errored-host");
6891
+ err && err instanceof Error && (errorDiv.props = {
6892
+ error: err
6893
+ });
6894
+ errorDiv.setAttribute("q:key", "_error_");
6895
+ const journal = [];
6896
+ vnode_getDOMChildNodes(journal, vHost).forEach((child => errorDiv.appendChild(child)));
6897
+ const vErrorDiv = vnode_newElement(errorDiv, "error-host");
6898
+ vnode_insertBefore(journal, vHost, vErrorDiv, null);
6899
+ vnode_applyJournal(journal);
6897
6900
  }
6898
- if ("object" !== typeof constProps) {
6899
- throw new Error("JSXNodeImpl: constProps must be objects: " + JSON.stringify(constProps));
6901
+ err && err instanceof Error && ("hostElement" in err || (err.hostElement = host));
6902
+ if (!isRecoverable(err)) {
6903
+ throw err;
6900
6904
  }
6901
6905
  }
6906
+ const errorStore = this.resolveContext(host, ERROR_CONTEXT);
6907
+ if (!errorStore) {
6908
+ throw err;
6909
+ }
6910
+ errorStore.error = err;
6902
6911
  }
6903
- dev;
6904
- _proxy=null;
6905
- get props() {
6906
- this._proxy || (this._proxy = createPropsProxy(this.varProps, this.constProps, this.children));
6907
- return this._proxy;
6912
+ setContext(host, context, value) {
6913
+ let ctx = this.getHostProp(host, QCtxAttr);
6914
+ ctx || this.setHostProp(host, QCtxAttr, ctx = []);
6915
+ mapArray_set(ctx, context.id, value, 0);
6908
6916
  }
6909
- };
6910
- var Virtual = props => props.children;
6911
- var isJSXNode = n => {
6912
- if (qDev) {
6913
- if (n instanceof JSXNodeImpl) {
6914
- return true;
6917
+ resolveContext(host, contextId) {
6918
+ while (host) {
6919
+ const ctx = this.getHostProp(host, QCtxAttr);
6920
+ if (ctx) {
6921
+ const value = mapArray_get(ctx, contextId.id, 0);
6922
+ if (value) {
6923
+ return value;
6924
+ }
6925
+ }
6926
+ host = this.getParentHost(host);
6915
6927
  }
6916
- if (isObject(n) && "key" in n && "props" in n && "type" in n) {
6917
- logWarn('Duplicate implementations of "JSXNode" found');
6918
- return true;
6928
+ return;
6929
+ }
6930
+ getParentHost(host) {
6931
+ let vNode = vnode_getParent(host);
6932
+ while (vNode) {
6933
+ if (vnode_isVirtualVNode(vNode)) {
6934
+ if (null !== vnode_getProp(vNode, OnRenderProp, null)) {
6935
+ return vNode;
6936
+ }
6937
+ const parent = vnode_getProp(vNode, QSlotParent, this.$vnodeLocate$);
6938
+ if (parent) {
6939
+ vNode = parent;
6940
+ continue;
6941
+ }
6942
+ }
6943
+ vNode = vnode_getParent(vNode);
6919
6944
  }
6920
- return false;
6945
+ return null;
6921
6946
  }
6922
- return n instanceof JSXNodeImpl;
6923
- };
6924
- var Fragment = props => props.children;
6925
- function createPropsProxy(varProps, constProps, children) {
6926
- return new Proxy({}, new PropsProxyHandler(varProps, constProps, children));
6927
- }
6928
- var PropsProxyHandler = class {
6929
- constructor($varProps$, $constProps$, $children$) {
6930
- this.$varProps$ = $varProps$;
6931
- this.$constProps$ = $constProps$;
6932
- this.$children$ = $children$;
6947
+ setHostProp(host, name, value) {
6948
+ const vNode = host;
6949
+ vnode_setProp(vNode, name, value);
6933
6950
  }
6934
- get(_, prop) {
6935
- if (prop === _CONST_PROPS) {
6936
- return this.$constProps$;
6937
- }
6938
- if (prop === _VAR_PROPS) {
6939
- return this.$varProps$;
6940
- }
6941
- if (null != this.$children$ && "children" === prop) {
6942
- return this.$children$;
6951
+ getHostProp(host, name) {
6952
+ const vNode = host;
6953
+ let getObjectById = null;
6954
+ switch (name) {
6955
+ case ELEMENT_SEQ:
6956
+ case ELEMENT_PROPS:
6957
+ case OnRenderProp:
6958
+ case QCtxAttr:
6959
+ case QSubscribers:
6960
+ getObjectById = this.$getObjectById$;
6961
+ break;
6962
+
6963
+ case ELEMENT_SEQ_IDX:
6964
+ case USE_ON_LOCAL_SEQ_IDX:
6965
+ getObjectById = parseInt;
6966
+ break;
6943
6967
  }
6944
- const value = this.$constProps$ && prop in this.$constProps$ ? this.$constProps$[prop] : this.$varProps$[prop];
6945
- return value instanceof WrappedSignal ? value.value : value;
6968
+ return vnode_getProp(vNode, name, getObjectById);
6946
6969
  }
6947
- set(_, prop, value) {
6948
- if (prop === _CONST_PROPS) {
6949
- this.$constProps$ = value;
6950
- return true;
6970
+ scheduleRender() {
6971
+ this.$renderCount$++;
6972
+ this.renderDone ||= getPlatform().nextTick((() => this.processChores()));
6973
+ return this.renderDone;
6974
+ }
6975
+ processChores() {
6976
+ let renderCount = this.$renderCount$;
6977
+ const result = this.$scheduler$(255);
6978
+ if (isPromise(result)) {
6979
+ return result.then((async () => {
6980
+ while (renderCount !== this.$renderCount$) {
6981
+ renderCount = this.$renderCount$;
6982
+ await this.$scheduler$(255);
6983
+ }
6984
+ this.renderDone = null;
6985
+ }));
6951
6986
  }
6952
- if (prop === _VAR_PROPS) {
6953
- this.$varProps$ = value;
6954
- return true;
6987
+ if (renderCount !== this.$renderCount$) {
6988
+ this.processChores();
6989
+ return;
6955
6990
  }
6956
- this.$constProps$ && prop in this.$constProps$ ? this.$constProps$[prop] = value : this.$varProps$[prop] = value;
6957
- return true;
6991
+ this.renderDone = null;
6958
6992
  }
6959
- deleteProperty(_, prop) {
6960
- if ("string" !== typeof prop) {
6961
- return false;
6993
+ ensureProjectionResolved(vNode) {
6994
+ if (0 === (16 & vNode[0])) {
6995
+ vNode[0] |= 16;
6996
+ for (let i = vnode_getPropStartIndex(vNode); i < vNode.length; i += 2) {
6997
+ const prop = vNode[i];
6998
+ if (isSlotProp(prop)) {
6999
+ const value = vNode[i + 1];
7000
+ "string" == typeof value && (vNode[i + 1] = this.$vnodeLocate$(value));
7001
+ }
7002
+ }
6962
7003
  }
6963
- let didDelete = delete this.$varProps$[prop];
6964
- this.$constProps$ && (didDelete = delete this.$constProps$[prop] || didDelete);
6965
- null != this.$children$ && "children" === prop && (this.$children$ = null);
6966
- return didDelete;
6967
- }
6968
- has(_, prop) {
6969
- const hasProp = "children" === prop && null != this.$children$ || prop === _CONST_PROPS || prop === _VAR_PROPS || prop in this.$varProps$ || !!this.$constProps$ && prop in this.$constProps$;
6970
- return hasProp;
6971
7004
  }
6972
- getOwnPropertyDescriptor(target, p) {
6973
- const value = "children" === p && null != this.$children$ ? this.$children$ : this.$constProps$ && p in this.$constProps$ ? this.$constProps$[p] : this.$varProps$[p];
6974
- return {
6975
- configurable: true,
6976
- enumerable: true,
6977
- value: value
6978
- };
7005
+ $getObjectById$=id => {
7006
+ "string" === typeof id && (id = parseFloat(id));
7007
+ assertTrue(id < this.$rawStateData$.length / 2, `Invalid reference: ${id} >= ${this.$rawStateData$.length / 2}`);
7008
+ return this.stateData[id];
7009
+ };
7010
+ getSyncFn(id) {
7011
+ const fn = this.$qFuncs$[id];
7012
+ assertTrue("function" === typeof fn, "Invalid reference: " + id);
7013
+ return fn;
6979
7014
  }
6980
- ownKeys() {
6981
- const out = Object.keys(this.$varProps$);
6982
- null != this.$children$ && -1 === out.indexOf("children") && out.push("children");
6983
- if (this.$constProps$) {
6984
- for (const key in this.$constProps$) {
6985
- -1 === out.indexOf(key) && out.push(key);
6986
- }
7015
+ $appendStyle$(content, styleId, host, scoped) {
7016
+ if (scoped) {
7017
+ const scopedStyleIdsString = this.getHostProp(host, QScopedStyle);
7018
+ const scopedStyleIds = new Set(convertScopedStyleIdsToArray(scopedStyleIdsString));
7019
+ scopedStyleIds.add(styleId);
7020
+ this.setHostProp(host, QScopedStyle, convertStyleIdsToString(scopedStyleIds));
7021
+ }
7022
+ if (null == this.$styleIds$) {
7023
+ this.$styleIds$ = new Set;
7024
+ this.element.querySelectorAll(QStyleSelector).forEach((style => {
7025
+ this.$styleIds$.add(style.getAttribute(QStyle));
7026
+ }));
7027
+ }
7028
+ if (!this.$styleIds$.has(styleId)) {
7029
+ this.$styleIds$.add(styleId);
7030
+ const styleElement = this.document.createElement("style");
7031
+ styleElement.setAttribute(QStyle, styleId);
7032
+ styleElement.textContent = content;
7033
+ this.$journal$.push(5, this.document.head, null, styleElement);
6987
7034
  }
6988
- return out;
6989
- }
6990
- };
6991
- var directGetPropsProxyProp = (jsx2, prop) => jsx2.constProps && prop in jsx2.constProps ? jsx2.constProps[prop] : jsx2.varProps[prop];
6992
- var componentQrl = componentQrl2 => {
6993
- function QwikComponent(props, key, flags = 0) {
6994
- assertQrl(componentQrl2);
6995
- assertNumber(flags, "The Qwik Component was not invoked correctly");
6996
- const hash = qTest ? "sX" : componentQrl2.$hash$.slice(0, 4);
6997
- const finalKey = hash + ":" + (key || "");
6998
- const InnerCmp = () => {};
6999
- InnerCmp[SERIALIZABLE_STATE] = [ componentQrl2 ];
7000
- return _jsxSplit(InnerCmp, props, null, props.children, flags, finalKey);
7001
7035
  }
7002
- QwikComponent[SERIALIZABLE_STATE] = [ componentQrl2 ];
7003
- return QwikComponent;
7004
7036
  };
7005
- var SERIALIZABLE_STATE = Symbol("serializable-data");
7006
- var isQwikComponent = component => "function" == typeof component && void 0 !== component[SERIALIZABLE_STATE];
7007
- implicit$FirstArg(eventQrl);
7008
- var rule = 0;
7009
- var elementClassIdSelector = 1;
7010
- var starSelector = 2;
7011
- var pseudoClassWithSelector = 3;
7012
- var pseudoClass = 4;
7013
- var pseudoGlobal = 5;
7014
- var pseudoElement = 6;
7015
- var attrSelector = 7;
7016
- var inertParenthesis = 8;
7017
- var inertBlock = 9;
7018
- var atRuleSelector = 10;
7019
- var atRuleBlock = 11;
7020
- var atRuleInert = 12;
7021
- var body = 13;
7022
- var stringSingle = 14;
7023
- var stringDouble = 15;
7024
- var commentMultiline = 16;
7025
- var EXIT = 17;
7026
- var EXIT_INSERT_SCOPE = 18;
7027
- var ANY = 0;
7028
- var IDENT = 1;
7029
- var NOT_IDENT = 2;
7030
- var WHITESPACE = 3;
7031
- var DOUBLE_QUOTE = 34;
7032
- var HASH = 35;
7033
- var SINGLE_QUOTE = 39;
7034
- var OPEN_PARENTHESIS = 40;
7035
- var CLOSE_PARENTHESIS = 41;
7036
- var STAR = 42;
7037
- var DOT = 46;
7038
- var FORWARD_SLASH = 47;
7039
- var COLON = 58;
7040
- var SEMICOLON = 59;
7041
- var AT = 64;
7042
- var OPEN_BRACKET = 91;
7043
- var CLOSE_BRACKET = 93;
7044
- var OPEN_BRACE = 123;
7045
- var CLOSE_BRACE = 125;
7046
- var STRINGS_COMMENTS = (() => [ [ ANY, SINGLE_QUOTE, stringSingle ], [ ANY, DOUBLE_QUOTE, stringDouble ], [ ANY, FORWARD_SLASH, commentMultiline, "*" ] ])();
7047
- var useComputedQrl = qrl2 => {
7048
- const {val: val, set: set} = useSequentialScope();
7049
- if (val) {
7050
- return val;
7051
- }
7052
- assertQrl(qrl2);
7053
- const signal = new ComputedSignal(null, qrl2);
7054
- set(signal);
7055
- throwIfQRLNotResolved(qrl2);
7056
- return signal;
7057
- };
7058
- implicit$FirstArg(useComputedQrl);
7059
- Number.MAX_SAFE_INTEGER;
7060
- Number.MAX_SAFE_INTEGER;
7061
7037
  var deserializedProxyMap = new WeakMap;
7062
7038
  var unwrapDeserializerProxy = value => {
7063
7039
  const unwrapped = "object" === typeof value && null !== value && value[SERIALIZER_PROXY_UNWRAP];
@@ -7232,7 +7208,8 @@ globalThis.qwikOptimizer = function(module) {
7232
7208
  signal.$args$ = d[1];
7233
7209
  signal.$effectDependencies$ = d[2];
7234
7210
  signal.$untrackedValue$ = d[3];
7235
- signal.$effects$ = d.slice(4);
7211
+ signal.$hostElement$ = d[4];
7212
+ signal.$effects$ = d.slice(5);
7236
7213
  break;
7237
7214
  }
7238
7215
 
@@ -7338,12 +7315,13 @@ globalThis.qwikOptimizer = function(module) {
7338
7315
  case 30:
7339
7316
  {
7340
7317
  const effectData = target;
7341
- effectData.data = data[0];
7318
+ effectData.data.$scopedStyleIdPrefix$ = data[0];
7319
+ effectData.data.$isConst$ = data[1];
7342
7320
  break;
7343
7321
  }
7344
7322
 
7345
7323
  default:
7346
- return throwErrorAndStop("Not implemented");
7324
+ throw qError(33, [ typeId ]);
7347
7325
  }
7348
7326
  };
7349
7327
  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 ];
@@ -7368,11 +7346,11 @@ globalThis.qwikOptimizer = function(module) {
7368
7346
  return {};
7369
7347
 
7370
7348
  case 18:
7371
- const qrl2 = container.$getObjectById$(value);
7372
- return parseQRL(qrl2);
7349
+ const qrl = container.$getObjectById$(value);
7350
+ return parseQRL(qrl);
7373
7351
 
7374
7352
  case 19:
7375
- return new Task2(-1, -1, null, null, null, null);
7353
+ return new Task(-1, -1, null, null, null, null);
7376
7354
 
7377
7355
  case 20:
7378
7356
  {
@@ -7460,26 +7438,29 @@ globalThis.qwikOptimizer = function(module) {
7460
7438
  return vnodeOrDocument;
7461
7439
  }
7462
7440
  const vNode = retrieveVNodeOrDocument(container, value);
7463
- return vnode_isVNode(vNode) ? vnode_getNode(vNode) : throwErrorAndStop("expected vnode for ref prop, but got " + typeof vNode);
7441
+ if (vnode_isVNode(vNode)) {
7442
+ return vnode_getNode(vNode);
7443
+ }
7444
+ throw qError(34, [ typeof vNode ]);
7464
7445
 
7465
7446
  case 30:
7466
- return new EffectData(null);
7447
+ return new EffectPropData({});
7467
7448
 
7468
7449
  default:
7469
- return throwErrorAndStop("unknown allocate type: " + typeId);
7450
+ throw qError(35, [ typeId ]);
7470
7451
  }
7471
7452
  };
7472
7453
  function retrieveVNodeOrDocument(container, value) {
7473
7454
  var _a;
7474
7455
  return value ? container.rootVNode ? vnode_locate(container.rootVNode, value) : void 0 : null == (_a = container.element) ? void 0 : _a.ownerDocument;
7475
7456
  }
7476
- function parseQRL(qrl2) {
7477
- const hashIdx = qrl2.indexOf("#");
7478
- const captureStart = qrl2.indexOf("[", hashIdx);
7479
- const captureEnd = qrl2.indexOf("]", captureStart);
7480
- const chunk = hashIdx > -1 ? qrl2.slice(0, hashIdx) : qrl2.slice(0, captureStart);
7481
- const symbol = captureStart > -1 ? qrl2.slice(hashIdx + 1, captureStart) : qrl2.slice(hashIdx + 1);
7482
- const captureIds = captureStart > -1 && captureEnd > -1 ? qrl2.slice(captureStart + 1, captureEnd).split(" ").filter((v => v.length)).map((s => parseInt(s, 10))) : null;
7457
+ function parseQRL(qrl) {
7458
+ const hashIdx = qrl.indexOf("#");
7459
+ const captureStart = qrl.indexOf("[", hashIdx);
7460
+ const captureEnd = qrl.indexOf("]", captureStart);
7461
+ const chunk = hashIdx > -1 ? qrl.slice(0, hashIdx) : qrl.slice(0, captureStart);
7462
+ const symbol = captureStart > -1 ? qrl.slice(hashIdx + 1, captureStart) : qrl.slice(hashIdx + 1);
7463
+ const captureIds = captureStart > -1 && captureEnd > -1 ? qrl.slice(captureStart + 1, captureEnd).split(" ").filter((v => v.length)).map((s => parseInt(s, 10))) : null;
7483
7464
  let qrlRef = null;
7484
7465
  if (isDev2 && chunk === QRL_RUNTIME_CHUNK) {
7485
7466
  const backChannel = globalThis[QRL_RUNTIME_CHUNK];
@@ -7488,11 +7469,11 @@ globalThis.qwikOptimizer = function(module) {
7488
7469
  }
7489
7470
  return createQRL(chunk, symbol, qrlRef, null, captureIds, null, null);
7490
7471
  }
7491
- function inflateQRL(container, qrl2) {
7492
- const captureIds = qrl2.$capture$;
7493
- qrl2.$captureRef$ = captureIds ? captureIds.map((id => container.$getObjectById$(id))) : null;
7494
- container.element && qrl2.$setContainer$(container.element);
7495
- return qrl2;
7472
+ function inflateQRL(container, qrl) {
7473
+ const captureIds = qrl.$capture$;
7474
+ qrl.$captureRef$ = captureIds ? captureIds.map((id => container.$getObjectById$(id))) : null;
7475
+ container.element && qrl.$setContainer$(container.element);
7476
+ return qrl;
7496
7477
  }
7497
7478
  var isDomRef = obj => false;
7498
7479
  var createSerializationContext = (NodeConstructor, DomRefConstructor, symbolToChunkResolver, getProp, setProp, storeProxyMap, writer, prepVNodeData) => {
@@ -7538,7 +7519,7 @@ globalThis.qwikOptimizer = function(module) {
7538
7519
  $getRootId$: obj => {
7539
7520
  const id = map.get(obj);
7540
7521
  if (!id || -1 === id) {
7541
- return throwErrorAndStop("Missing root id for: ", obj);
7522
+ throw qError(36, [ obj ]);
7542
7523
  }
7543
7524
  return id;
7544
7525
  },
@@ -7581,8 +7562,8 @@ globalThis.qwikOptimizer = function(module) {
7581
7562
  if (isQrl2(obj)) {
7582
7563
  obj.$captureRef$ && discoveredValues.push(...obj.$captureRef$);
7583
7564
  } else if (isQwikComponent(obj)) {
7584
- const [qrl2] = obj[SERIALIZABLE_STATE];
7585
- discoveredValues.push(qrl2);
7565
+ const [qrl] = obj[SERIALIZABLE_STATE];
7566
+ discoveredValues.push(qrl);
7586
7567
  }
7587
7568
  } 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) {
7588
7569
  discoveredValues.push(...Object.values(obj));
@@ -7608,13 +7589,19 @@ globalThis.qwikOptimizer = function(module) {
7608
7589
  if (obj instanceof WrappedSignal) {
7609
7590
  obj.$effectDependencies$ && discoveredValues.push(...obj.$effectDependencies$);
7610
7591
  obj.$args$ && discoveredValues.push(...obj.$args$);
7592
+ obj.$hostElement$ && discoveredValues.push(obj.$hostElement$);
7611
7593
  } else {
7612
7594
  obj instanceof ComputedSignal && discoveredValues.push(obj.$computeQrl$);
7613
7595
  }
7614
- } else if (obj instanceof Task2) {
7596
+ } else if (obj instanceof Task) {
7615
7597
  discoveredValues.push(obj.$el$, obj.$qrl$, obj.$state$, obj.$effectDependencies$);
7616
7598
  } else if (isSsrNode(obj)) {
7617
- discoveredValues.push(obj.vnodeData);
7599
+ discoverValuesForVNodeData(obj.vnodeData, discoveredValues);
7600
+ if (obj.childrenVNodeData && obj.childrenVNodeData.length) {
7601
+ for (const data of obj.childrenVNodeData) {
7602
+ discoverValuesForVNodeData(data, discoveredValues);
7603
+ }
7604
+ }
7618
7605
  } else if (isDomRef(obj)) {
7619
7606
  discoveredValues.push(obj.$ssrNode$.id);
7620
7607
  } else if (isJSXNode(obj)) {
@@ -7634,11 +7621,11 @@ globalThis.qwikOptimizer = function(module) {
7634
7621
  discoveredValues.push(error);
7635
7622
  }));
7636
7623
  promises.push(obj);
7637
- } else if (obj instanceof EffectData) {
7624
+ } else if (obj instanceof EffectPropData) {
7638
7625
  discoveredValues.push(obj.data);
7639
7626
  } else {
7640
7627
  if (!isObjectLiteral(obj)) {
7641
- return throwErrorAndStop("Unknown type: " + obj);
7628
+ throw qError(37, [ obj ]);
7642
7629
  }
7643
7630
  Object.entries(obj).forEach((([key, value]) => {
7644
7631
  discoveredValues.push(key, value);
@@ -7667,6 +7654,20 @@ globalThis.qwikOptimizer = function(module) {
7667
7654
  } while (discoveredValues.length);
7668
7655
  }
7669
7656
  };
7657
+ var isSsrAttrs = value => Array.isArray(value) && value.length > 0;
7658
+ var discoverValuesForVNodeData = (vnodeData, discoveredValues) => {
7659
+ for (const value of vnodeData) {
7660
+ if (isSsrAttrs(value)) {
7661
+ for (let i = 1; i < value.length; i += 2) {
7662
+ if (value[i - 1] === ELEMENT_KEY) {
7663
+ continue;
7664
+ }
7665
+ const attrValue = value[i];
7666
+ discoveredValues.push(attrValue);
7667
+ }
7668
+ }
7669
+ }
7670
+ };
7670
7671
  var promiseResults = new WeakMap;
7671
7672
  function serialize(serializationContext) {
7672
7673
  const {$writer$: $writer$, $isSsrNode$: $isSsrNode$, $isDomRef$: $isDomRef$, $setProp$: $setProp$, $storeProxyMap$: $storeProxyMap$} = serializationContext;
@@ -7711,13 +7712,13 @@ globalThis.qwikOptimizer = function(module) {
7711
7712
  } else if (value === Fragment) {
7712
7713
  output(1, 9);
7713
7714
  } else if (isQrl2(value)) {
7714
- const qrl2 = qrlToString(serializationContext, value);
7715
- const id = serializationContext.$addRoot$(qrl2);
7715
+ const qrl = qrlToString(serializationContext, value);
7716
+ const id = serializationContext.$addRoot$(qrl);
7716
7717
  output(18, id);
7717
7718
  } else if (isQwikComponent(value)) {
7718
- const [qrl2] = value[SERIALIZABLE_STATE];
7719
- serializationContext.$renderSymbols$.add(qrl2.$symbol$);
7720
- output(21, [ qrl2 ]);
7719
+ const [qrl] = value[SERIALIZABLE_STATE];
7720
+ serializationContext.$renderSymbols$.add(qrl.$symbol$);
7721
+ output(21, [ qrl ]);
7721
7722
  } else {
7722
7723
  console.error("Cannot serialize function (ignoring for now): " + value.toString());
7723
7724
  output(1, 0);
@@ -7741,8 +7742,13 @@ globalThis.qwikOptimizer = function(module) {
7741
7742
  const seen = depth > 1 && serializationContext.$wasSeen$(value);
7742
7743
  "number" === typeof seen && seen >= 0 ? output(0, seen) : output(3, value);
7743
7744
  }
7745
+ } else if ("undefined" === typeof value) {
7746
+ output(1, 0);
7744
7747
  } else {
7745
- "undefined" === typeof value ? output(1, 0) : value === NEEDS_COMPUTATION ? output(1, 7) : throwErrorAndStop("Unknown type: " + typeof value);
7748
+ if (value !== NEEDS_COMPUTATION) {
7749
+ throw qError(37, [ typeof value ]);
7750
+ }
7751
+ output(1, 7);
7746
7752
  }
7747
7753
  };
7748
7754
  const writeObjectValue = (value, idx) => {
@@ -7760,14 +7766,14 @@ globalThis.qwikOptimizer = function(module) {
7760
7766
  const constProps = value[_CONST_PROPS];
7761
7767
  const out = constProps ? [ varProps, constProps ] : Object.keys(varProps).length ? [ varProps ] : 0;
7762
7768
  output(29, out);
7763
- } else if (value instanceof EffectData) {
7764
- output(30, [ value.data ]);
7769
+ } else if (value instanceof EffectPropData) {
7770
+ output(30, [ value.data.$scopedStyleIdPrefix$, value.data.$isConst$ ]);
7765
7771
  } else if (isStore(value)) {
7766
7772
  if (isResource(value)) {
7767
7773
  serializationContext.$resources$.add(value);
7768
7774
  const res = promiseResults.get(value.value);
7769
7775
  if (!res) {
7770
- return throwErrorAndStop("Unvisited Resource");
7776
+ throw qError(38, [ "resource" ]);
7771
7777
  }
7772
7778
  output(20, [ ...res, getStoreHandler(value).$effects$ ]);
7773
7779
  } else {
@@ -7802,12 +7808,12 @@ globalThis.qwikOptimizer = function(module) {
7802
7808
  output(13, out);
7803
7809
  }
7804
7810
  } else if ($isDomRef$(value)) {
7805
- value.$ssrNode$.vnodeData[0] |= 8;
7811
+ value.$ssrNode$.vnodeData[0] |= 16;
7806
7812
  output(9, value.$ssrNode$.id);
7807
7813
  } else if (value instanceof Signal) {
7808
7814
  const v = value instanceof ComputedSignal && (value.$invalid$ || fastSkipSerialize(value.$untrackedValue$)) ? NEEDS_COMPUTATION : value.$untrackedValue$;
7809
7815
  if (value instanceof WrappedSignal) {
7810
- output(23, [ ...serializeWrappingFn(serializationContext, value), value.$effectDependencies$, v, ...value.$effects$ || [] ]);
7816
+ output(23, [ ...serializeWrappingFn(serializationContext, value), value.$effectDependencies$, v, value.$hostElement$, ...value.$effects$ || [] ]);
7811
7817
  } else if (value instanceof ComputedSignal) {
7812
7818
  const out = [ value.$computeQrl$, value.$effects$ ];
7813
7819
  v !== NEEDS_COMPUTATION && out.push(v);
@@ -7834,11 +7840,11 @@ globalThis.qwikOptimizer = function(module) {
7834
7840
  const vNodeData = value.vnodeData;
7835
7841
  if (vNodeData) {
7836
7842
  null == (_a = serializationContext.$prepVNodeData$) || _a.call(serializationContext, vNodeData);
7837
- vNodeData[0] |= 8;
7843
+ vNodeData[0] |= 16;
7838
7844
  }
7839
7845
  if (value.childrenVNodeData) {
7840
7846
  for (const vNodeData2 of value.childrenVNodeData) {
7841
- vNodeData2[0] |= 8;
7847
+ vNodeData2[0] |= 16;
7842
7848
  }
7843
7849
  }
7844
7850
  } else {
@@ -7863,7 +7869,7 @@ globalThis.qwikOptimizer = function(module) {
7863
7869
  output(16, combined);
7864
7870
  } else if (isJSXNode(value)) {
7865
7871
  output(28, [ value.type, value.varProps, value.constProps, value.children, value.flags, value.key ]);
7866
- } else if (value instanceof Task2) {
7872
+ } else if (value instanceof Task) {
7867
7873
  const out = [ value.$qrl$, value.$flags$, value.$index$, value.$el$, value.$effectDependencies$, value.$state$ ];
7868
7874
  while (null == out[out.length - 1]) {
7869
7875
  out.pop();
@@ -7872,12 +7878,12 @@ globalThis.qwikOptimizer = function(module) {
7872
7878
  } else if (isPromise(value)) {
7873
7879
  const res = promiseResults.get(value);
7874
7880
  if (!res) {
7875
- return throwErrorAndStop("Unvisited Promise");
7881
+ throw qError(38, [ "promise" ]);
7876
7882
  }
7877
7883
  output(14, res);
7878
7884
  } else {
7879
7885
  if (!(value instanceof Uint8Array)) {
7880
- return throwErrorAndStop("implement");
7886
+ throw qError(37, [ typeof value ]);
7881
7887
  }
7882
7888
  {
7883
7889
  let buf = "";
@@ -7922,7 +7928,9 @@ globalThis.qwikOptimizer = function(module) {
7922
7928
  backChannel.set(value.$symbol$, value._devOnlySymbolRef);
7923
7929
  chunk || (chunk = QRL_RUNTIME_CHUNK);
7924
7930
  }
7925
- chunk || throwErrorAndStop("Missing chunk for: " + value.$symbol$);
7931
+ if (!chunk) {
7932
+ throw qError(31, [ value.$symbol$ ]);
7933
+ }
7926
7934
  chunk.startsWith("./") && (chunk = chunk.slice(2));
7927
7935
  }
7928
7936
  let qrlStringInline = `${chunk}#${symbol}`;
@@ -7956,7 +7964,7 @@ globalThis.qwikOptimizer = function(module) {
7956
7964
  function isResource(value) {
7957
7965
  return "__brand" in value && "resource" === value.__brand;
7958
7966
  }
7959
- var frameworkType = obj => "object" === typeof obj && null !== obj && (obj instanceof Signal || obj instanceof Task2 || isJSXNode(obj)) || isQrl2(obj);
7967
+ var frameworkType = obj => "object" === typeof obj && null !== obj && (obj instanceof Signal || obj instanceof Task || isJSXNode(obj)) || isQrl2(obj);
7960
7968
  var canSerialize = value => {
7961
7969
  if (null == value || "string" === typeof value || "number" === typeof value || "boolean" === typeof value || "bigint" === typeof value) {
7962
7970
  return true;
@@ -8061,7 +8069,7 @@ globalThis.qwikOptimizer = function(module) {
8061
8069
  let expectIndex = 0;
8062
8070
  unwrapped.forEach(((v, i) => {
8063
8071
  if (i !== expectIndex) {
8064
- throw qError(QError_verifySerializable, unwrapped);
8072
+ throw qError(3, [ unwrapped ]);
8065
8073
  }
8066
8074
  _verifySerializable(v, seen, ctx + "[" + i + "]");
8067
8075
  expectIndex = i + 1;
@@ -8090,8 +8098,7 @@ globalThis.qwikOptimizer = function(module) {
8090
8098
  const fnName = value.name;
8091
8099
  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.`;
8092
8100
  }
8093
- console.error("Trying to serialize", value);
8094
- throwErrorAndStop(message);
8101
+ throw qError(3, [ message ]);
8095
8102
  }
8096
8103
  return value;
8097
8104
  };
@@ -8117,7 +8124,7 @@ globalThis.qwikOptimizer = function(module) {
8117
8124
  }
8118
8125
  }
8119
8126
  let _containerEl;
8120
- const qrl2 = async function(...args) {
8127
+ const qrl = async function(...args) {
8121
8128
  const boundedFn = bindFnToContext.call(this, tryGetInvokeContext());
8122
8129
  const result = await boundedFn(...args);
8123
8130
  return result;
@@ -8129,7 +8136,7 @@ globalThis.qwikOptimizer = function(module) {
8129
8136
  function bindFnToContext(currentCtx, beforeFn) {
8130
8137
  return (...args) => maybeThen(resolveLazy(), (fn => {
8131
8138
  if (!isFunction(fn)) {
8132
- throw qError(QError_qrlIsNotFunction);
8139
+ throw qError(10);
8133
8140
  }
8134
8141
  if (beforeFn && false === beforeFn()) {
8135
8142
  return;
@@ -8137,7 +8144,7 @@ globalThis.qwikOptimizer = function(module) {
8137
8144
  const context = createOrReuseInvocationContext(currentCtx);
8138
8145
  const prevQrl = context.$qrl$;
8139
8146
  const prevEvent = context.$event$;
8140
- context.$qrl$ = qrl2;
8147
+ context.$qrl$ = qrl;
8141
8148
  context.$event$ ||= this;
8142
8149
  try {
8143
8150
  return invoke.call(this, context, fn, ...args);
@@ -8158,7 +8165,7 @@ globalThis.qwikOptimizer = function(module) {
8158
8165
  return fn.apply(this, args);
8159
8166
  }
8160
8167
  context = newInvokeContext();
8161
- context.$qrl$ = qrl2;
8168
+ context.$qrl$ = qrl;
8162
8169
  context.$event$ = this;
8163
8170
  return invoke.call(this, context, fn, ...args);
8164
8171
  };
@@ -8173,15 +8180,15 @@ globalThis.qwikOptimizer = function(module) {
8173
8180
  const hash2 = _containerEl.getAttribute(QInstanceAttr);
8174
8181
  const doc = _containerEl.ownerDocument;
8175
8182
  const qFuncs = getQFuncs(doc, hash2);
8176
- return qrl2.resolved = symbolRef = qFuncs[Number(symbol)];
8183
+ return qrl.resolved = symbolRef = qFuncs[Number(symbol)];
8177
8184
  }
8178
8185
  const start = now();
8179
8186
  const ctx = tryGetInvokeContext();
8180
8187
  if (null !== symbolFn) {
8181
- symbolRef = symbolFn().then((module2 => qrl2.resolved = symbolRef = wrapFn(module2[symbol])));
8188
+ symbolRef = symbolFn().then((module2 => qrl.resolved = symbolRef = wrapFn(module2[symbol])));
8182
8189
  } else {
8183
8190
  const imported = getPlatform().importSymbol(_containerEl, chunk, symbol);
8184
- symbolRef = maybeThen(imported, (ref => qrl2.resolved = symbolRef = wrapFn(ref)));
8191
+ symbolRef = maybeThen(imported, (ref => qrl.resolved = symbolRef = wrapFn(ref)));
8185
8192
  }
8186
8193
  "object" === typeof symbolRef && isPromise(symbolRef) && symbolRef.then((() => emitUsedSymbol(symbol, null == ctx ? void 0 : ctx.$element$, start)), (err => {
8187
8194
  console.error(`qrl ${symbol} failed to load`, err);
@@ -8193,7 +8200,7 @@ globalThis.qwikOptimizer = function(module) {
8193
8200
  const createOrReuseInvocationContext = invoke2 => null == invoke2 ? newInvokeContext() : isArray(invoke2) ? newInvokeContextFromTuple(invoke2) : invoke2;
8194
8201
  const resolvedSymbol = refSymbol ?? symbol;
8195
8202
  const hash = getSymbolHash(resolvedSymbol);
8196
- Object.assign(qrl2, {
8203
+ Object.assign(qrl, {
8197
8204
  getSymbol: () => resolvedSymbol,
8198
8205
  getHash: () => hash,
8199
8206
  getCaptured: () => captureRef,
@@ -8210,12 +8217,12 @@ globalThis.qwikOptimizer = function(module) {
8210
8217
  dev: null,
8211
8218
  resolved: void 0
8212
8219
  });
8213
- symbolRef && (symbolRef = maybeThen(symbolRef, (resolved => qrl2.resolved = symbolRef = wrapFn(resolved))));
8214
- isDev && Object.defineProperty(qrl2, "_devOnlySymbolRef", {
8220
+ symbolRef && (symbolRef = maybeThen(symbolRef, (resolved => qrl.resolved = symbolRef = wrapFn(resolved))));
8221
+ isDev && Object.defineProperty(qrl, "_devOnlySymbolRef", {
8215
8222
  get: () => symbolRef
8216
8223
  });
8217
- qDev && seal(qrl2);
8218
- return qrl2;
8224
+ qDev && seal(qrl);
8225
+ return qrl;
8219
8226
  };
8220
8227
  var getSymbolHash = symbolName => {
8221
8228
  const index = symbolName.lastIndexOf("_");
@@ -8224,8 +8231,8 @@ globalThis.qwikOptimizer = function(module) {
8224
8231
  }
8225
8232
  return symbolName;
8226
8233
  };
8227
- function assertQrl(qrl2) {
8228
- if (qDev && !isQrl2(qrl2)) {
8234
+ function assertQrl(qrl) {
8235
+ if (qDev && !isQrl2(qrl)) {
8229
8236
  throw new Error("Not a QRL");
8230
8237
  }
8231
8238
  }
@@ -8329,8 +8336,8 @@ globalThis.qwikOptimizer = function(module) {
8329
8336
  }
8330
8337
  const firstInput = opts.input && Object.values(opts.input)[0];
8331
8338
  const ssrModule = await server.ssrLoadModule(firstInput);
8332
- const render2 = ssrModule.default ?? ssrModule.render;
8333
- if ("function" === typeof render2) {
8339
+ const render = ssrModule.default ?? ssrModule.render;
8340
+ if ("function" === typeof render) {
8334
8341
  const manifest = {
8335
8342
  manifestHash: "",
8336
8343
  symbols: {},
@@ -8379,7 +8386,7 @@ globalThis.qwikOptimizer = function(module) {
8379
8386
  res.setHeader("Access-Control-Allow-Origin", "*");
8380
8387
  res.setHeader("X-Powered-By", "Qwik Vite Dev Server");
8381
8388
  res.writeHead(status);
8382
- const result = await render2(renderOpts);
8389
+ const result = await render(renderOpts);
8383
8390
  Array.from(server.moduleGraph.fileToModulesMap.entries()).forEach((entry => {
8384
8391
  entry[1].forEach((v => {
8385
8392
  const {pathId: pathId, query: query} = parseId(v.url);