@qwik.dev/core 2.0.0-alpha.2 → 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.2-dev+58b6f8d
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.2-dev+58b6f8d"
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);
@@ -4265,34 +3949,35 @@ globalThis.qwikOptimizer = function(module) {
4265
3949
  return peekNextSibling();
4266
3950
  }
4267
3951
  function descendContentToProject(children, host) {
4268
- Array.isArray(children) || (children = [ children ]);
4269
- if (children.length) {
4270
- const createProjectionJSXNode = slotName => new JSXNodeImpl(Projection, EMPTY_OBJ, null, [], 0, slotName);
4271
- const projections = [];
4272
- if (host) {
4273
- for (let i = vnode_getPropStartIndex(host); i < host.length; i += 2) {
4274
- const prop = host[i];
4275
- if (isSlotProp(prop)) {
4276
- const slotName = prop;
4277
- projections.push(slotName);
4278
- projections.push(createProjectionJSXNode(slotName));
4279
- }
3952
+ const projectionChildren = Array.isArray(children) ? children : [ children ];
3953
+ const createProjectionJSXNode = slotName => new JSXNodeImpl(Projection, EMPTY_OBJ, null, [], 0, slotName);
3954
+ const projections = [];
3955
+ if (host) {
3956
+ for (let i = vnode_getPropStartIndex(host); i < host.length; i += 2) {
3957
+ const prop = host[i];
3958
+ if (isSlotProp(prop)) {
3959
+ const slotName = prop;
3960
+ projections.push(slotName);
3961
+ projections.push(createProjectionJSXNode(slotName));
4280
3962
  }
4281
3963
  }
4282
- for (let i = 0; i < children.length; i++) {
4283
- const child = children[i];
4284
- const slotName = String(isJSXNode(child) && directGetPropsProxyProp(child, QSlot) || QDefaultSlot);
4285
- const idx = mapApp_findIndx(projections, slotName, 0);
4286
- let jsxBucket;
4287
- idx >= 0 ? jsxBucket = projections[idx + 1] : projections.splice(~idx, 0, slotName, jsxBucket = createProjectionJSXNode(slotName));
4288
- const removeProjection = false === child;
4289
- removeProjection || jsxBucket.children.push(child);
4290
- }
4291
- for (let i = projections.length - 2; i >= 0; i -= 2) {
4292
- projections.splice(i, 1);
4293
- }
4294
- descend(projections, true);
4295
3964
  }
3965
+ if (0 === projections.length && null == children) {
3966
+ return;
3967
+ }
3968
+ for (let i = 0; i < projectionChildren.length; i++) {
3969
+ const child = projectionChildren[i];
3970
+ const slotName = String(isJSXNode(child) && directGetPropsProxyProp(child, QSlot) || QDefaultSlot);
3971
+ const idx = mapApp_findIndx(projections, slotName, 0);
3972
+ let jsxBucket;
3973
+ idx >= 0 ? jsxBucket = projections[idx + 1] : projections.splice(~idx, 0, slotName, jsxBucket = createProjectionJSXNode(slotName));
3974
+ const removeProjection = false === child;
3975
+ removeProjection || jsxBucket.children.push(child);
3976
+ }
3977
+ for (let i = projections.length - 2; i >= 0; i -= 2) {
3978
+ projections.splice(i, 1);
3979
+ }
3980
+ descend(projections, true);
4296
3981
  }
4297
3982
  function expectProjection() {
4298
3983
  const jsxNode2 = jsxValue;
@@ -4334,7 +4019,7 @@ globalThis.qwikOptimizer = function(module) {
4334
4019
  if (constProps && "object" == typeof constProps && "name" in constProps) {
4335
4020
  const constValue = constProps.name;
4336
4021
  if (vHost && constValue instanceof WrappedSignal) {
4337
- return trackSignal((() => constValue.value), vHost, ":", container);
4022
+ return trackSignalAndAssignHost(constValue, vHost, ":", container);
4338
4023
  }
4339
4024
  }
4340
4025
  return directGetPropsProxyProp(jsxNode2, "name") || QDefaultSlot;
@@ -4408,11 +4093,11 @@ globalThis.qwikOptimizer = function(module) {
4408
4093
  }
4409
4094
  }
4410
4095
  if (isSignal(value)) {
4411
- const signalData = new EffectData({
4096
+ const signalData = new EffectPropData({
4412
4097
  $scopedStyleIdPrefix$: scopedStyleIdPrefix,
4413
4098
  $isConst$: true
4414
4099
  });
4415
- value = trackSignal((() => value.value), vNewNode, key2, container, signalData);
4100
+ value = trackSignalAndAssignHost(value, vNewNode, key2, container, signalData);
4416
4101
  }
4417
4102
  if (key2 === dangerouslySetInnerHTML) {
4418
4103
  element.innerHTML = value;
@@ -4421,7 +4106,9 @@ globalThis.qwikOptimizer = function(module) {
4421
4106
  }
4422
4107
  if ("textarea" === elementName && "value" === key2) {
4423
4108
  if ("string" !== typeof value) {
4424
- isDev && throwErrorAndStop("The value of the textarea must be a string");
4109
+ if (isDev) {
4110
+ throw qError(40);
4111
+ }
4425
4112
  continue;
4426
4113
  }
4427
4114
  element.value = escapeHTML(value);
@@ -4474,9 +4161,9 @@ globalThis.qwikOptimizer = function(module) {
4474
4161
  const eventProp = ":" + scope.substring(1) + ":" + eventName;
4475
4162
  const qrls = [ vnode_getProp(vNode, eventProp, null), vnode_getProp(vNode, HANDLER_PREFIX + eventProp, null) ];
4476
4163
  let returnValue = false;
4477
- qrls.flat(2).forEach((qrl2 => {
4478
- if (qrl2) {
4479
- const value = qrl2(event, element);
4164
+ qrls.flat(2).forEach((qrl => {
4165
+ if (qrl) {
4166
+ const value = qrl(event, element);
4480
4167
  returnValue = returnValue || true === value;
4481
4168
  }
4482
4169
  }));
@@ -4525,7 +4212,7 @@ globalThis.qwikOptimizer = function(module) {
4525
4212
  eventName && registerQwikLoaderEvent(eventName);
4526
4213
  };
4527
4214
  while (null !== srcKey || null !== dstKey) {
4528
- 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))) {
4529
4216
  dstIdx++;
4530
4217
  dstKey = dstIdx < dstLength ? dstAttrs[dstIdx++] : null;
4531
4218
  } else if (null == srcKey) {
@@ -4658,7 +4345,7 @@ globalThis.qwikOptimizer = function(module) {
4658
4345
  container.$scheduler$(7, host, componentQRL, jsxProps);
4659
4346
  }
4660
4347
  }
4661
- null != jsxNode2.children && descendContentToProject(jsxNode2.children, host);
4348
+ descendContentToProject(jsxNode2.children, host);
4662
4349
  } else {
4663
4350
  const lookupKey = jsxNode2.key;
4664
4351
  const vNodeLookupKey = getKey(host);
@@ -4679,7 +4366,7 @@ globalThis.qwikOptimizer = function(module) {
4679
4366
  }
4680
4367
  }
4681
4368
  function insertNewComponent(host, componentQRL, jsxProps) {
4682
- host && clearVNodeEffectDependencies(host);
4369
+ host && clearVNodeEffectDependencies(container, host);
4683
4370
  vnode_insertBefore(journal, vParent, vNewNode = vnode_newVirtual(), vCurrent && getInsertBefore());
4684
4371
  const jsxNode2 = jsxValue;
4685
4372
  isDev && vnode_setProp(vNewNode, DEBUG_TYPE, "C");
@@ -4718,16 +4405,16 @@ globalThis.qwikOptimizer = function(module) {
4718
4405
  if (null == vNode) {
4719
4406
  return null;
4720
4407
  }
4721
- const qrl2 = vnode_getProp(vNode, OnRenderProp, getObject);
4722
- return qrl2 ? qrl2.$hash$ : null;
4408
+ const qrl = vnode_getProp(vNode, OnRenderProp, getObject);
4409
+ return qrl ? qrl.$hash$ : null;
4723
4410
  }
4724
4411
  function Projection() {}
4725
4412
  function propsDiffer(src, dst) {
4726
4413
  if (!src || !dst) {
4727
4414
  return true;
4728
4415
  }
4729
- let srcKeys = removeChildrenKey(Object.keys(src));
4730
- let dstKeys = removeChildrenKey(Object.keys(dst));
4416
+ let srcKeys = removePropsKeys(Object.keys(src), [ "children", QSubscribers ]);
4417
+ let dstKeys = removePropsKeys(Object.keys(dst), [ "children", QSubscribers ]);
4731
4418
  if (srcKeys.length !== dstKeys.length) {
4732
4419
  return true;
4733
4420
  }
@@ -4742,9 +4429,12 @@ globalThis.qwikOptimizer = function(module) {
4742
4429
  }
4743
4430
  return false;
4744
4431
  }
4745
- function removeChildrenKey(keys2) {
4746
- const childrenIdx = keys2.indexOf("children");
4747
- -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
+ }
4748
4438
  return keys2;
4749
4439
  }
4750
4440
  function cleanup(container, vNode) {
@@ -4756,9 +4446,9 @@ globalThis.qwikOptimizer = function(module) {
4756
4446
  do {
4757
4447
  const type = vCursor[0];
4758
4448
  if (3 & type) {
4449
+ clearVNodeEffectDependencies(container, vCursor);
4450
+ markVNodeAsDeleted(vCursor);
4759
4451
  if (2 & type) {
4760
- clearVNodeEffectDependencies(vCursor);
4761
- markVNodeAsDeleted(vCursor);
4762
4452
  const seq = container.getHostProp(vCursor, ELEMENT_SEQ);
4763
4453
  if (seq) {
4764
4454
  for (let i = 0; i < seq.length; i++) {
@@ -4766,7 +4456,7 @@ globalThis.qwikOptimizer = function(module) {
4766
4456
  if (isTask(obj)) {
4767
4457
  const task = obj;
4768
4458
  clearSubscriberEffectDependencies(task);
4769
- 1 & task.$flags$ ? container.$scheduler$(80, task) : cleanupTask(task);
4459
+ 1 & task.$flags$ ? container.$scheduler$(48, task) : cleanupTask(task);
4770
4460
  }
4771
4461
  }
4772
4462
  }
@@ -4845,18 +4535,15 @@ globalThis.qwikOptimizer = function(module) {
4845
4535
  }
4846
4536
  var HANDLER_PREFIX = ":";
4847
4537
  var count = 0;
4848
- var implicit$FirstArg = fn => function(first, ...rest) {
4849
- return fn.call(null, dollar(first), ...rest);
4850
- };
4851
- var DEBUG3 = false;
4538
+ var DEBUG2 = false;
4852
4539
  var createScheduler = (container, scheduleDrain, journalFlush) => {
4853
4540
  const choreQueue = [];
4854
4541
  let currentChore = null;
4855
4542
  let journalFlushScheduled = false;
4856
4543
  return schedule;
4857
4544
  function schedule(type, hostOrTask = null, targetOrQrl = null, payload = null) {
4858
- const runLater = 127 !== type && 16 !== type && 6 !== type;
4859
- 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;
4860
4547
  isTask2 && (hostOrTask.$flags$ |= 8);
4861
4548
  let chore = {
4862
4549
  $type$: type,
@@ -4870,11 +4557,11 @@ globalThis.qwikOptimizer = function(module) {
4870
4557
  $executed$: false
4871
4558
  };
4872
4559
  chore.$promise$ = new Promise((resolve => chore.$resolve$ = resolve));
4873
- DEBUG3 && debugTrace("schedule", chore, currentChore, choreQueue);
4560
+ DEBUG2 && debugTrace("schedule", chore, currentChore, choreQueue);
4874
4561
  chore = sortedInsert(choreQueue, chore);
4875
4562
  if (!journalFlushScheduled && runLater) {
4876
4563
  journalFlushScheduled = true;
4877
- schedule(48);
4564
+ schedule(16);
4878
4565
  scheduleDrain();
4879
4566
  }
4880
4567
  return runLater ? chore.$promise$ : drainUpTo(chore);
@@ -4896,8 +4583,8 @@ globalThis.qwikOptimizer = function(module) {
4896
4583
  break;
4897
4584
  }
4898
4585
  const isDeletedVNode = vNodeAlreadyDeleted(nextChore);
4899
- if (isDeletedVNode && 80 !== nextChore.$type$) {
4900
- DEBUG3 && debugTrace("skip chore", nextChore, currentChore, choreQueue);
4586
+ if (isDeletedVNode && 48 !== nextChore.$type$) {
4587
+ DEBUG2 && debugTrace("skip chore", nextChore, currentChore, choreQueue);
4901
4588
  continue;
4902
4589
  }
4903
4590
  const returnValue = executeChore(nextChore);
@@ -4909,20 +4596,27 @@ globalThis.qwikOptimizer = function(module) {
4909
4596
  return runUptoChore.$returnValue$;
4910
4597
  }
4911
4598
  function executeChore(chore) {
4599
+ var _a;
4912
4600
  const host = chore.$host$;
4913
- DEBUG3 && debugTrace("execute", chore, currentChore, choreQueue);
4601
+ DEBUG2 && debugTrace("execute", chore, currentChore, choreQueue);
4914
4602
  assertEqual(currentChore, null, "Chore already running.");
4915
4603
  currentChore = chore;
4916
4604
  let returnValue = null;
4917
4605
  switch (chore.$type$) {
4918
- case 48:
4606
+ case 16:
4919
4607
  returnValue = journalFlush();
4920
4608
  journalFlushScheduled = false;
4921
4609
  break;
4922
4610
 
4923
4611
  case 7:
4924
4612
  case 6:
4925
- returnValue = safeCall((() => executeComponent(container, host, host, chore.$target$, chore.$payload$)), (jsx3 => 7 === chore.$type$ ? maybeThen(container.processJsx(host, jsx3), (() => jsx3)) : jsx3), (err => container.handleError(err, host)));
4613
+ returnValue = safeCall((() => executeComponent(container, host, host, chore.$target$, chore.$payload$)), (jsx3 => {
4614
+ if (7 === chore.$type$) {
4615
+ const styleScopedId = container.getHostProp(host, QScopedStyle);
4616
+ return vnode_diff(container, jsx3, host, addComponentStylePrefix(styleScopedId));
4617
+ }
4618
+ return jsx3;
4619
+ }), (err => container.handleError(err, host)));
4926
4620
  break;
4927
4621
 
4928
4622
  case 2:
@@ -4934,11 +4628,11 @@ globalThis.qwikOptimizer = function(module) {
4934
4628
  returnValue = runTask(chore.$payload$, container, host);
4935
4629
  break;
4936
4630
 
4937
- case 64:
4631
+ case 32:
4938
4632
  returnValue = runTask(chore.$payload$, container, host);
4939
4633
  break;
4940
4634
 
4941
- case 80:
4635
+ case 48:
4942
4636
  const task = chore.$payload$;
4943
4637
  cleanupTask(task);
4944
4638
  break;
@@ -4973,14 +4667,28 @@ globalThis.qwikOptimizer = function(module) {
4973
4667
  returnValue = target.resolved ? null : target.resolve();
4974
4668
  break;
4975
4669
  }
4976
- }
4977
- return maybeThenPassError(returnValue, (value => {
4978
- var _a;
4979
- DEBUG3 && debugTrace("execute.DONE", null, currentChore, choreQueue);
4980
- if (currentChore) {
4981
- currentChore.$executed$ = true;
4982
- null == (_a = currentChore.$resolve$) || _a.call(currentChore, value);
4983
- }
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
+ }
4684
+ }
4685
+ return maybeThenPassError(returnValue, (value => {
4686
+ var _a2;
4687
+ DEBUG2 && debugTrace("execute.DONE", null, currentChore, choreQueue);
4688
+ if (currentChore) {
4689
+ currentChore.$executed$ = true;
4690
+ null == (_a2 = currentChore.$resolve$) || _a2.call(currentChore, value);
4691
+ }
4984
4692
  currentChore = null;
4985
4693
  return chore.$returnValue$ = value;
4986
4694
  }));
@@ -4994,17 +4702,19 @@ globalThis.qwikOptimizer = function(module) {
4994
4702
  return !!(chore.$host$ && vnode_isVNode(chore.$host$) && 32 & chore.$host$[0]);
4995
4703
  }
4996
4704
  function choreComparator(a, b, shouldThrowOnHostMismatch) {
4997
- const macroTypeDiff = (112 & a.$type$) - (112 & b.$type$);
4705
+ const macroTypeDiff = (240 & a.$type$) - (240 & b.$type$);
4998
4706
  if (0 !== macroTypeDiff) {
4999
4707
  return macroTypeDiff;
5000
4708
  }
5001
- if (48 !== a.$type$) {
4709
+ if (16 !== a.$type$) {
5002
4710
  const aHost = a.$host$;
5003
4711
  const bHost = b.$host$;
5004
4712
  if (aHost !== bHost && null !== aHost && null !== bHost) {
5005
4713
  if (!vnode_isVNode(aHost) || !vnode_isVNode(bHost)) {
5006
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()}`;
5007
- shouldThrowOnHostMismatch && throwErrorAndStop(errorMessage);
4715
+ if (shouldThrowOnHostMismatch) {
4716
+ throw qError(45, [ errorMessage ]);
4717
+ }
5008
4718
  logWarn(errorMessage);
5009
4719
  return null;
5010
4720
  }
@@ -5023,7 +4733,7 @@ globalThis.qwikOptimizer = function(module) {
5023
4733
  if (0 !== idxDiff) {
5024
4734
  return idxDiff;
5025
4735
  }
5026
- 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$)) {
5027
4737
  return 1;
5028
4738
  }
5029
4739
  }
@@ -5067,11 +4777,11 @@ globalThis.qwikOptimizer = function(module) {
5067
4777
  5: "NODE_PROP",
5068
4778
  7: "COMPONENT",
5069
4779
  6: "COMPONENT_SSR",
5070
- 48: "JOURNAL_FLUSH",
5071
- 64: "VISIBLE",
5072
- 80: "CLEANUP_VISIBLE",
5073
- 127: "WAIT_FOR_ALL",
5074
- 16: "WAIT_FOR_COMPONENTS"
4780
+ 8: "RECOMPUTE_SIGNAL",
4781
+ 16: "JOURNAL_FLUSH",
4782
+ 32: "VISIBLE",
4783
+ 48: "CLEANUP_VISIBLE",
4784
+ 255: "WAIT_FOR_ALL"
5075
4785
  }[chore.$type$] || "UNKNOWN: " + chore.$type$;
5076
4786
  const host = String(chore.$host$).replaceAll(/\n.*/gim, "");
5077
4787
  const qrlTarget = null == (_a = chore.$target$) ? void 0 : _a.$symbol$;
@@ -5086,610 +4796,524 @@ globalThis.qwikOptimizer = function(module) {
5086
4796
  }));
5087
4797
  console.log(lines.join("\n ") + "\n");
5088
4798
  }
5089
- var version = "2.0.0-alpha.2-dev+58b6f8d";
5090
- var _SharedContainer = class {
5091
- $version$;
5092
- $scheduler$;
5093
- $storeProxyMap$;
5094
- $locale$;
5095
- $getObjectById$;
5096
- $serverData$;
5097
- $currentUniqueId$=0;
5098
- $instanceHash$=null;
5099
- constructor(scheduleDrain, journalFlush, serverData, locale) {
5100
- this.$serverData$ = serverData;
5101
- this.$locale$ = locale;
5102
- this.$version$ = version;
5103
- this.$storeProxyMap$ = new WeakMap;
5104
- this.$getObjectById$ = _id => {
5105
- throw Error("Not implemented");
5106
- };
5107
- this.$scheduler$ = createScheduler(this, scheduleDrain, journalFlush);
5108
- }
5109
- trackSignalValue(signal, subscriber, property, data) {
5110
- return trackSignal((() => signal.value), subscriber, property, this, data);
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();
4812
+ }
4813
+ return prop ? obj[prop] : isSignal(obj) ? obj.value : obj;
4814
+ }));
4815
+ };
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
+ }));
4832
+ }
4833
+ cleanupFns.push(fn);
4834
+ }
4835
+ };
4836
+ const taskApi = {
4837
+ track: track,
4838
+ cleanup: cleanup2
4839
+ };
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);
4851
+ }
5111
4852
  }
5112
- serializationCtxFactory(NodeConstructor, DomRefConstructor, symbolToChunkResolver, writer, prepVNodeData) {
5113
- return createSerializationContext(NodeConstructor, DomRefConstructor, symbolToChunkResolver, this.getHostProp.bind(this), this.setHostProp.bind(this), this.$storeProxyMap$, writer, prepVNodeData);
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$;
5114
4863
  }
5115
4864
  };
5116
- var VNodeDataSeparator = {
5117
- REFERENCE_CH: "~",
5118
- REFERENCE: 126,
5119
- ADVANCE_1_CH: "!",
5120
- ADVANCE_1: 33,
5121
- ADVANCE_2_CH: '"',
5122
- ADVANCE_2: 34,
5123
- ADVANCE_4_CH: "#",
5124
- ADVANCE_4: 35,
5125
- ADVANCE_8_CH: "$",
5126
- ADVANCE_8: 36,
5127
- ADVANCE_16_CH: "%",
5128
- ADVANCE_16: 37,
5129
- ADVANCE_32_CH: "&",
5130
- ADVANCE_32: 38,
5131
- ADVANCE_64_CH: "'",
5132
- ADVANCE_64: 39,
5133
- ADVANCE_128_CH: "(",
5134
- ADVANCE_128: 40,
5135
- ADVANCE_256_CH: ")",
5136
- ADVANCE_256: 41,
5137
- ADVANCE_512_CH: "*",
5138
- ADVANCE_512: 42,
5139
- ADVANCE_1024_CH: "+",
5140
- ADVANCE_1024: 43,
5141
- ADVANCE_2048_CH: ",",
5142
- ADVANCE_2048: 44,
5143
- ADVANCE_4096_CH: "-",
5144
- ADVANCE_4096: 45,
5145
- ADVANCE_8192_CH: ".",
5146
- ADVANCE_8192: 46
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();
4873
+ }
5147
4874
  };
5148
- var VNodeDataChar = {
5149
- OPEN: 123,
5150
- OPEN_CHAR: "{",
5151
- CLOSE: 125,
5152
- CLOSE_CHAR: "}",
5153
- SCOPED_STYLE: 59,
5154
- SCOPED_STYLE_CHAR: ";",
5155
- RENDER_FN: 60,
5156
- RENDER_FN_CHAR: "<",
5157
- ID: 61,
5158
- ID_CHAR: "=",
5159
- PROPS: 62,
5160
- PROPS_CHAR: ">",
5161
- SLOT_REF: 63,
5162
- SLOT_REF_CHAR: "?",
5163
- KEY: 64,
5164
- KEY_CHAR: "@",
5165
- SEQ: 91,
5166
- SEQ_CHAR: "[",
5167
- DON_T_USE: 93,
5168
- DON_T_USE_CHAR: "\\",
5169
- CONTEXT: 93,
5170
- CONTEXT_CHAR: "]",
5171
- SEQ_IDX: 94,
5172
- SEQ_IDX_CHAR: "^",
5173
- SEPARATOR: 124,
5174
- SEPARATOR_CHAR: "|",
5175
- SLOT: 126,
5176
- SLOT_CHAR: "~"
4875
+ var isSignal = value => value instanceof Signal;
4876
+ var EffectPropData = class {
4877
+ data;
4878
+ constructor(data) {
4879
+ this.data = data;
4880
+ }
5177
4881
  };
5178
- function processVNodeData(document2) {
5179
- const Q_CONTAINER = "q:container";
5180
- const Q_CONTAINER_END = "/" + Q_CONTAINER;
5181
- const Q_PROPS_SEPARATOR2 = ":";
5182
- const Q_SHADOW_ROOT = "q:shadowroot";
5183
- const Q_IGNORE = "q:ignore";
5184
- const Q_IGNORE_END = "/" + Q_IGNORE;
5185
- const Q_CONTAINER_ISLAND = "q:container-island";
5186
- const Q_CONTAINER_ISLAND_END = "/" + Q_CONTAINER_ISLAND;
5187
- const qDocument = document2;
5188
- const vNodeDataMap = qDocument.qVNodeData || (qDocument.qVNodeData = new WeakMap);
5189
- const prototype = document2.body;
5190
- const getter = (prototype2, name) => {
5191
- var _a;
5192
- let getter2;
5193
- while (prototype2 && !(getter2 = null == (_a = Object.getOwnPropertyDescriptor(prototype2, name)) ? void 0 : _a.get)) {
5194
- prototype2 = Object.getPrototypeOf(prototype2);
5195
- }
5196
- return getter2 || function() {
5197
- return this[name];
5198
- };
5199
- };
5200
- const getAttribute = prototype.getAttribute;
5201
- const hasAttribute = prototype.hasAttribute;
5202
- const getNodeType = getter(prototype, "nodeType");
5203
- const attachVnodeDataAndRefs = element => {
5204
- Array.from(element.querySelectorAll('script[type="qwik/vnode"]')).forEach((script => {
5205
- script.setAttribute("type", "x-qwik/vnode");
5206
- const qContainerElement = script.closest("[q\\:container]");
5207
- qContainerElement.qVnodeData = script.textContent;
5208
- qContainerElement.qVNodeRefs = new Map;
5209
- }));
5210
- element.querySelectorAll("[q\\:shadowroot]").forEach((parent => {
5211
- const shadowRoot = parent.shadowRoot;
5212
- shadowRoot && attachVnodeDataAndRefs(shadowRoot);
5213
- }));
5214
- };
5215
- attachVnodeDataAndRefs(document2);
5216
- let NodeType;
5217
- (NodeType2 => {
5218
- NodeType2[NodeType2.CONTAINER_MASK = 1] = "CONTAINER_MASK";
5219
- NodeType2[NodeType2.ELEMENT = 2] = "ELEMENT";
5220
- NodeType2[NodeType2.ELEMENT_CONTAINER = 3] = "ELEMENT_CONTAINER";
5221
- NodeType2[NodeType2.ELEMENT_SHADOW_ROOT = 6] = "ELEMENT_SHADOW_ROOT";
5222
- NodeType2[NodeType2.COMMENT_SKIP_START = 5] = "COMMENT_SKIP_START";
5223
- NodeType2[NodeType2.COMMENT_SKIP_END = 8] = "COMMENT_SKIP_END";
5224
- NodeType2[NodeType2.COMMENT_IGNORE_START = 16] = "COMMENT_IGNORE_START";
5225
- NodeType2[NodeType2.COMMENT_IGNORE_END = 32] = "COMMENT_IGNORE_END";
5226
- NodeType2[NodeType2.COMMENT_ISLAND_START = 65] = "COMMENT_ISLAND_START";
5227
- NodeType2[NodeType2.COMMENT_ISLAND_END = 128] = "COMMENT_ISLAND_END";
5228
- NodeType2[NodeType2.OTHER = 0] = "OTHER";
5229
- })(NodeType || (NodeType = {}));
5230
- const getFastNodeType = node => {
5231
- const nodeType = getNodeType.call(node);
5232
- if (1 === nodeType) {
5233
- const qContainer = getAttribute.call(node, Q_CONTAINER);
5234
- if (null === qContainer) {
5235
- if (hasAttribute.call(node, Q_SHADOW_ROOT)) {
5236
- return 6;
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);
4890
+ }
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;
5237
4903
  }
5238
- const isQElement = hasAttribute.call(node, Q_PROPS_SEPARATOR2);
5239
- return isQElement ? 2 : 0;
5240
- }
5241
- return 3;
5242
- }
5243
- if (8 === nodeType) {
5244
- const nodeValue = node.nodeValue || "";
5245
- if (nodeValue.startsWith(Q_CONTAINER_ISLAND)) {
5246
- return 65;
4904
+ this.$container$ = ctx.$container$;
4905
+ } else {
4906
+ assertTrue(!ctx.$container$ || ctx.$container$ === this.$container$, "Do not use signals across containers");
5247
4907
  }
5248
- if (nodeValue.startsWith(Q_IGNORE)) {
5249
- return 16;
5250
- }
5251
- if (nodeValue.startsWith(Q_CONTAINER)) {
5252
- return 5;
5253
- }
5254
- if (nodeValue.startsWith(Q_CONTAINER_ISLAND_END)) {
5255
- return 128;
5256
- }
5257
- if (nodeValue.startsWith(Q_IGNORE_END)) {
5258
- return 32;
5259
- }
5260
- if (nodeValue.startsWith(Q_CONTAINER_END)) {
5261
- return 8;
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(), " "));
5262
4915
  }
5263
4916
  }
5264
- return 0;
5265
- };
5266
- const isSeparator = ch => VNodeDataSeparator.ADVANCE_1 <= ch && ch <= VNodeDataSeparator.ADVANCE_8192;
5267
- const findVDataSectionEnd = (vData, start, end) => {
5268
- let depth = 0;
5269
- while (true) {
5270
- if (!(start < end)) {
5271
- break;
5272
- }
5273
- {
5274
- const ch = vData.charCodeAt(start);
5275
- if (0 === depth && isSeparator(ch)) {
5276
- break;
5277
- }
5278
- ch === VNodeDataChar.OPEN ? depth++ : ch === VNodeDataChar.CLOSE && depth--;
5279
- start++;
5280
- }
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$);
5281
4924
  }
5282
- return start;
5283
- };
5284
- const nextSibling = node => {
5285
- while (node && (node = node.nextSibling) && 0 === getFastNodeType(node)) {}
5286
- return node;
5287
- };
5288
- const firstChild = node => {
5289
- while (node && (node = node.firstChild) && 0 === getFastNodeType(node)) {}
5290
- return node;
5291
- };
5292
- const walkContainer = (walker2, containerNode, node, exitNode, vData, qVNodeRefs, prefix) => {
5293
- const vData_length = vData.length;
5294
- let elementIdx = 0;
5295
- let vNodeElementIndex = -1;
5296
- let vData_start = 0;
5297
- let vData_end = 0;
5298
- let ch = 0;
5299
- let needsToStoreRef = -1;
5300
- let nextNode = null;
5301
- const howManyElementsToSkip = () => {
5302
- let elementsToSkip = 0;
5303
- while (isSeparator(ch = vData.charCodeAt(vData_start))) {
5304
- elementsToSkip += 1 << ch - VNodeDataSeparator.ADVANCE_1;
5305
- vData_start++;
5306
- if (vData_start >= vData_length) {
5307
- break;
5308
- }
5309
- }
5310
- return elementsToSkip;
4925
+ }
4926
+ valueOf() {
4927
+ if (qDev) {
4928
+ throw qError(46);
4929
+ }
4930
+ }
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$
5311
4938
  };
5312
- do {
5313
- if (node === exitNode) {
5314
- return;
5315
- }
5316
- nextNode = null;
5317
- const nodeType = node == containerNode ? 2 : getFastNodeType(node);
5318
- if (3 === nodeType) {
5319
- const container = node;
5320
- let cursor = node;
5321
- while (cursor && !(nextNode = nextSibling(cursor))) {
5322
- cursor = cursor.parentNode;
5323
- }
5324
- walkContainer(walker2, container, node, nextNode, container.qVnodeData || "", container.qVNodeRefs, prefix + " ");
5325
- } else if (16 === nodeType) {
5326
- let islandNode = node;
5327
- do {
5328
- islandNode = walker2.nextNode();
5329
- if (!islandNode) {
5330
- throw new Error(`Island inside \x3c!--${null == node ? void 0 : node.nodeValue}--\x3e not found!`);
5331
- }
5332
- } while (65 !== getFastNodeType(islandNode));
5333
- nextNode = null;
5334
- } else if (128 === nodeType) {
5335
- nextNode = node;
5336
- do {
5337
- nextNode = walker2.nextNode();
5338
- if (!nextNode) {
5339
- throw new Error("Ignore block not closed!");
5340
- }
5341
- } while (32 !== getFastNodeType(nextNode));
5342
- nextNode = null;
5343
- } else if (5 === nodeType) {
5344
- nextNode = node;
5345
- do {
5346
- nextNode = nextSibling(nextNode);
5347
- if (!nextNode) {
5348
- throw new Error(`\x3c!--${null == node ? void 0 : node.nodeValue}--\x3e not closed!`);
5349
- }
5350
- } while (8 !== getFastNodeType(nextNode));
5351
- walkContainer(walker2, node, node, nextNode, "", null, prefix + " ");
5352
- } else if (6 === nodeType) {
5353
- nextNode = nextSibling(node);
5354
- const shadowRootContainer = node;
5355
- const shadowRoot = null == shadowRootContainer ? void 0 : shadowRootContainer.shadowRoot;
5356
- shadowRoot && walkContainer(document2.createTreeWalker(shadowRoot, 129), null, firstChild(shadowRoot), null, "", null, prefix + " ");
5357
- }
5358
- if (2 === (2 & nodeType)) {
5359
- if (vNodeElementIndex < elementIdx) {
5360
- -1 === vNodeElementIndex && (vNodeElementIndex = 0);
5361
- vData_start = vData_end;
5362
- if (vData_start < vData_length) {
5363
- vNodeElementIndex += howManyElementsToSkip();
5364
- const shouldStoreRef = ch === VNodeDataSeparator.REFERENCE;
5365
- if (shouldStoreRef) {
5366
- needsToStoreRef = vNodeElementIndex;
5367
- vData_start++;
5368
- ch = vData_start < vData_length ? vData.charCodeAt(vData_end) : VNodeDataSeparator.ADVANCE_1;
5369
- }
5370
- vData_end = findVDataSectionEnd(vData, vData_start, vData_length);
5371
- } else {
5372
- vNodeElementIndex = Number.MAX_SAFE_INTEGER;
5373
- }
5374
- }
5375
- if (elementIdx === vNodeElementIndex) {
5376
- needsToStoreRef === elementIdx && qVNodeRefs.set(elementIdx, node);
5377
- const instructions = vData.substring(vData_start, vData_end);
5378
- vNodeDataMap.set(node, instructions);
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;
4950
+ }
4951
+ }
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);
5379
5023
  }
5380
- elementIdx++;
5381
5024
  }
5382
- } while (node = nextNode || walker2.nextNode());
5383
- };
5384
- const walker = document2.createTreeWalker(document2, 129);
5385
- walkContainer(walker, null, walker.firstChild(), null, "", null, "");
5386
- }
5387
- function getDomContainer(element) {
5388
- const qContainerElement = _getQContainerElement(element);
5389
- qContainerElement || throwErrorAndStop("Unable to find q:container.");
5390
- return getDomContainerFromQContainerElement(qContainerElement);
5391
- }
5392
- function getDomContainerFromQContainerElement(qContainerElement) {
5393
- const qElement = qContainerElement;
5394
- let container = qElement.qContainer;
5395
- if (!container) {
5396
- container = new DomContainer(qElement);
5397
- const containerAttributes = {};
5398
- if (qElement) {
5399
- const attrs = qElement.attributes;
5400
- if (attrs) {
5401
- for (let index = 0; index < attrs.length; index++) {
5402
- const attr = attrs[index];
5403
- if (attr.name === Q_PROPS_SEPARATOR) {
5404
- continue;
5405
- }
5406
- containerAttributes[attr.name] = attr.value;
5407
- }
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;
5058
+ }
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$ ]);
5408
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);
5409
5076
  }
5410
- container.$serverData$ = {
5411
- containerAttributes: containerAttributes
5412
- };
5413
- qElement.setAttribute(QContainerAttr, "resumed");
5414
- qElement.qContainer = container;
5415
5077
  }
5416
- return container;
5417
- }
5418
- function _getQContainerElement(element) {
5419
- const qContainerElement = Array.isArray(element) ? vnode_getDomParent(element) : element;
5420
- return qContainerElement.closest(QContainerSelector);
5421
- }
5422
- var isDomContainer = container => container instanceof DomContainer;
5423
- var DomContainer = class extends _SharedContainer {
5424
- element;
5425
- qContainer;
5426
- qBase;
5427
- qManifestHash;
5428
- rootVNode;
5429
- document;
5430
- $journal$;
5431
- renderDone=null;
5432
- $rawStateData$;
5433
- $storeProxyMap$=new WeakMap;
5434
- $qFuncs$;
5435
- $instanceHash$;
5436
- stateData;
5437
- $styleIds$=null;
5438
- $vnodeLocate$=id => vnode_locate(this.rootVNode, id);
5439
- $renderCount$=0;
5440
- constructor(element) {
5441
- super((() => this.scheduleRender()), (() => vnode_applyJournal(this.$journal$)), {}, element.getAttribute("q:locale"));
5442
- this.qContainer = element.getAttribute(QContainerAttr);
5443
- this.qContainer || throwErrorAndStop("Element must have 'q:container' attribute.");
5444
- this.$journal$ = [ 3, element.ownerDocument ];
5445
- this.document = element.ownerDocument;
5446
- this.element = element;
5447
- this.qBase = element.getAttribute(QBaseAttr);
5448
- this.$instanceHash$ = element.getAttribute(QInstanceAttr);
5449
- this.qManifestHash = element.getAttribute("q:manifest-hash");
5450
- this.rootVNode = vnode_newUnMaterializedElement(this.element);
5451
- this.$rawStateData$ = null;
5452
- this.stateData = null;
5453
- const document2 = this.element.ownerDocument;
5454
- document2.qVNodeData || processVNodeData(document2);
5455
- this.$rawStateData$ = [];
5456
- this.stateData = [];
5457
- const qwikStates = element.querySelectorAll('script[type="qwik/state"]');
5458
- if (0 !== qwikStates.length) {
5459
- const lastState = qwikStates[qwikStates.length - 1];
5460
- this.$rawStateData$ = JSON.parse(lastState.textContent);
5461
- this.stateData = wrapDeserializerProxy(this, this.$rawStateData$);
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;
5462
5119
  }
5463
- this.$qFuncs$ = getQFuncs(document2, this.$instanceHash$) || EMPTY_ARRAY;
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;
5464
5124
  }
5465
- $setRawState$(id, vParent) {
5466
- this.stateData[id] = vParent;
5125
+ get value() {
5126
+ return super.value;
5127
+ }
5128
+ set value(_) {
5129
+ throw qError(49);
5130
+ }
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);
5467
5151
  }
5468
- parseQRL(qrl2) {
5469
- return inflateQRL(this, parseQRL(qrl2));
5152
+ trackSignalValue(signal, subscriber, property, data) {
5153
+ return trackSignalAndAssignHost(signal, subscriber, property, this, data);
5470
5154
  }
5471
- processJsx(host, jsx2) {
5472
- const styleScopedId = this.getHostProp(host, QScopedStyle);
5473
- return vnode_diff(this, jsx2, host, addComponentStylePrefix(styleScopedId));
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);
5474
5157
  }
5475
- handleError(err, host) {
5476
- if (qDev) {
5477
- if ("undefined" !== typeof document) {
5478
- const vHost = host;
5479
- const errorDiv = document.createElement("errored-host");
5480
- err && err instanceof Error && (errorDiv.props = {
5481
- error: err
5482
- });
5483
- errorDiv.setAttribute("q:key", "_error_");
5484
- const journal = [];
5485
- vnode_getDOMChildNodes(journal, vHost).forEach((child => errorDiv.appendChild(child)));
5486
- const vErrorDiv = vnode_newElement(errorDiv, "error-host");
5487
- vnode_insertBefore(journal, vHost, vErrorDiv, null);
5488
- vnode_applyJournal(journal);
5489
- }
5490
- err && err instanceof Error && ("hostElement" in err || (err.hostElement = host));
5491
- if (!isRecoverable(err)) {
5492
- throw err;
5493
- }
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;
5494
5197
  }
5495
- const errorStore = this.resolveContext(host, ERROR_CONTEXT);
5496
- if (!errorStore) {
5497
- throw err;
5198
+ if ("key" === attr) {
5199
+ key = entry[1];
5200
+ return false;
5498
5201
  }
5499
- errorStore.error = err;
5500
- }
5501
- setContext(host, context, value) {
5502
- let ctx = this.getHostProp(host, QCtxAttr);
5503
- ctx || this.setHostProp(host, QCtxAttr, ctx = []);
5504
- mapArray_set(ctx, context.id, value, 0);
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;
5505
5207
  }
5506
- resolveContext(host, contextId) {
5507
- while (host) {
5508
- const ctx = this.getHostProp(host, QCtxAttr);
5509
- if (ctx) {
5510
- const value = mapArray_get(ctx, contextId.id, 0);
5511
- if (value) {
5512
- return value;
5513
- }
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));
5514
5222
  }
5515
- host = this.getParentHost(host);
5516
- }
5517
- return;
5518
- }
5519
- getParentHost(host) {
5520
- let vNode = vnode_getParent(host);
5521
- while (vNode) {
5522
- if (vnode_isVirtualVNode(vNode)) {
5523
- if (null !== vnode_getProp(vNode, OnRenderProp, null)) {
5524
- return vNode;
5525
- }
5526
- const parent = vnode_getProp(vNode, QSlotParent, this.$vnodeLocate$);
5527
- if (parent) {
5528
- vNode = parent;
5529
- continue;
5530
- }
5223
+ if ("object" !== typeof constProps) {
5224
+ throw new Error("JSXNodeImpl: constProps must be objects: " + JSON.stringify(constProps));
5531
5225
  }
5532
- vNode = vnode_getParent(vNode);
5533
- }
5534
- return null;
5535
- }
5536
- setHostProp(host, name, value) {
5537
- const vNode = host;
5538
- vnode_setProp(vNode, name, value);
5539
- }
5540
- getHostProp(host, name) {
5541
- const vNode = host;
5542
- let getObjectById = null;
5543
- switch (name) {
5544
- case ELEMENT_SEQ:
5545
- case ELEMENT_PROPS:
5546
- case OnRenderProp:
5547
- case QCtxAttr:
5548
- case QSubscribers:
5549
- getObjectById = this.$getObjectById$;
5550
- break;
5551
-
5552
- case ELEMENT_SEQ_IDX:
5553
- case USE_ON_LOCAL_SEQ_IDX:
5554
- getObjectById = parseInt;
5555
- break;
5556
5226
  }
5557
- return vnode_getProp(vNode, name, getObjectById);
5558
5227
  }
5559
- scheduleRender() {
5560
- this.$renderCount$++;
5561
- this.renderDone ||= getPlatform().nextTick((() => this.processChores()));
5562
- return this.renderDone;
5228
+ dev;
5229
+ _proxy=null;
5230
+ get props() {
5231
+ this._proxy || (this._proxy = createPropsProxy(this.varProps, this.constProps, this.children));
5232
+ return this._proxy;
5563
5233
  }
5564
- processChores() {
5565
- let renderCount = this.$renderCount$;
5566
- const result = this.$scheduler$(127);
5567
- if (isPromise(result)) {
5568
- return result.then((async () => {
5569
- while (renderCount !== this.$renderCount$) {
5570
- renderCount = this.$renderCount$;
5571
- await this.$scheduler$(127);
5572
- }
5573
- this.renderDone = null;
5574
- }));
5575
- }
5576
- if (renderCount !== this.$renderCount$) {
5577
- this.processChores();
5578
- return;
5234
+ };
5235
+ var Virtual = props => props.children;
5236
+ var isJSXNode = n => {
5237
+ if (qDev) {
5238
+ if (n instanceof JSXNodeImpl) {
5239
+ return true;
5579
5240
  }
5580
- this.renderDone = null;
5581
- }
5582
- ensureProjectionResolved(vNode) {
5583
- if (0 === (16 & vNode[0])) {
5584
- vNode[0] |= 16;
5585
- for (let i = vnode_getPropStartIndex(vNode); i < vNode.length; i += 2) {
5586
- const prop = vNode[i];
5587
- if (isSlotProp(prop)) {
5588
- const value = vNode[i + 1];
5589
- "string" == typeof value && (vNode[i + 1] = this.$vnodeLocate$(value));
5590
- }
5591
- }
5241
+ if (isObject(n) && "key" in n && "props" in n && "type" in n) {
5242
+ logWarn('Duplicate implementations of "JSXNode" found');
5243
+ return true;
5592
5244
  }
5245
+ return false;
5593
5246
  }
5594
- $getObjectById$=id => {
5595
- "string" === typeof id && (id = parseFloat(id));
5596
- assertTrue(id < this.$rawStateData$.length / 2, `Invalid reference: ${id} >= ${this.$rawStateData$.length / 2}`);
5597
- return this.stateData[id];
5598
- };
5599
- getSyncFn(id) {
5600
- const fn = this.$qFuncs$[id];
5601
- assertTrue("function" === typeof fn, "Invalid reference: " + id);
5602
- return fn;
5247
+ return n instanceof JSXNodeImpl;
5248
+ };
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$;
5603
5258
  }
5604
- $appendStyle$(content, styleId, host, scoped) {
5605
- if (scoped) {
5606
- const scopedStyleIdsString = this.getHostProp(host, QScopedStyle);
5607
- const scopedStyleIds = new Set(convertScopedStyleIdsToArray(scopedStyleIdsString));
5608
- scopedStyleIds.add(styleId);
5609
- this.setHostProp(host, QScopedStyle, convertStyleIdsToString(scopedStyleIds));
5259
+ get(_, prop) {
5260
+ if (prop === _CONST_PROPS) {
5261
+ return this.$constProps$;
5610
5262
  }
5611
- if (null == this.$styleIds$) {
5612
- this.$styleIds$ = new Set;
5613
- this.element.querySelectorAll(QStyleSelector).forEach((style => {
5614
- this.$styleIds$.add(style.getAttribute(QStyle));
5615
- }));
5263
+ if (prop === _VAR_PROPS) {
5264
+ return this.$varProps$;
5616
5265
  }
5617
- if (!this.$styleIds$.has(styleId)) {
5618
- this.$styleIds$.add(styleId);
5619
- const styleElement = this.document.createElement("style");
5620
- styleElement.setAttribute(QStyle, styleId);
5621
- styleElement.textContent = content;
5622
- this.$journal$.push(5, this.document.head, null, styleElement);
5266
+ if (null != this.$children$ && "children" === prop) {
5267
+ return this.$children$;
5623
5268
  }
5269
+ const value = this.$constProps$ && prop in this.$constProps$ ? this.$constProps$[prop] : this.$varProps$[prop];
5270
+ return value instanceof WrappedSignal ? value.value : value;
5624
5271
  }
5625
- };
5626
- var runTask = (task, container, host) => {
5627
- task.$flags$ &= -9;
5628
- cleanupTask(task);
5629
- const iCtx = newInvokeContext(container.$locale$, host, void 0, TaskEvent);
5630
- iCtx.$container$ = container;
5631
- const taskFn = task.$qrl$.getFn(iCtx, (() => clearSubscriberEffectDependencies(task)));
5632
- const track = (obj, prop) => {
5633
- const ctx = newInvokeContext();
5634
- ctx.$effectSubscriber$ = [ task, ":" ];
5635
- ctx.$container$ = container;
5636
- return invoke(ctx, (() => {
5637
- if (isFunction(obj)) {
5638
- return obj();
5639
- }
5640
- return prop ? obj[prop] : isSignal(obj) ? obj.value : obj;
5641
- }));
5642
- };
5643
- const handleError = reason => container.handleError(reason, host);
5644
- let cleanupFns = null;
5645
- const cleanup2 = fn => {
5646
- if ("function" == typeof fn) {
5647
- if (!cleanupFns) {
5648
- cleanupFns = [];
5649
- task.$destroy$ = noSerialize((() => {
5650
- task.$destroy$ = null;
5651
- cleanupFns.forEach((fn2 => {
5652
- try {
5653
- fn2();
5654
- } catch (err) {
5655
- handleError(err);
5656
- }
5657
- }));
5658
- }));
5659
- }
5660
- cleanupFns.push(fn);
5272
+ set(_, prop, value) {
5273
+ if (prop === _CONST_PROPS) {
5274
+ this.$constProps$ = value;
5275
+ return true;
5661
5276
  }
5662
- };
5663
- const taskApi = {
5664
- track: track,
5665
- cleanup: cleanup2
5666
- };
5667
- const result = safeCall((() => taskFn(taskApi)), cleanup2, (err => isPromise(err) ? err.then((() => runTask(task, container, host))) : handleError(err)));
5668
- return result;
5669
- };
5670
- var cleanupTask = task => {
5671
- const destroy = task.$destroy$;
5672
- if (destroy) {
5673
- task.$destroy$ = null;
5674
- try {
5675
- destroy();
5676
- } catch (err) {
5677
- logError(err);
5277
+ if (prop === _VAR_PROPS) {
5278
+ this.$varProps$ = value;
5279
+ return true;
5678
5280
  }
5281
+ this.$constProps$ && prop in this.$constProps$ ? this.$constProps$[prop] = value : this.$varProps$[prop] = value;
5282
+ return true;
5679
5283
  }
5680
- };
5681
- var Task2 = class extends Subscriber {
5682
- constructor($flags$, $index$, $el$, $qrl$, $state$, $destroy$) {
5683
- super();
5684
- this.$flags$ = $flags$;
5685
- this.$index$ = $index$;
5686
- this.$el$ = $el$;
5687
- this.$qrl$ = $qrl$;
5688
- this.$state$ = $state$;
5689
- 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;
5690
5314
  }
5691
5315
  };
5692
- var isTask = value => value instanceof Task2;
5316
+ var directGetPropsProxyProp = (jsx2, prop) => jsx2.constProps && prop in jsx2.constProps ? jsx2.constProps[prop] : jsx2.varProps[prop];
5693
5317
  var stringifyPath = [];
5694
5318
  function qwikDebugToString(value) {
5695
5319
  if (null === value) {
@@ -5760,6 +5384,70 @@ globalThis.qwikOptimizer = function(module) {
5760
5384
  }
5761
5385
  return String(value);
5762
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
+ };
5763
5451
  var vnode_newElement = (element, elementName) => {
5764
5452
  assertEqual(fastNodeType(element), 1, "Expecting element node.");
5765
5453
  const vnode = VNodeArray.createElement(-247, null, null, null, null, null, element, elementName);
@@ -6293,9 +5981,28 @@ globalThis.qwikOptimizer = function(module) {
6293
5981
  const element = vNode[6];
6294
5982
  const firstChild = fastFirstChild(element);
6295
5983
  const vNodeData = null == (_b = null == (_a = element.ownerDocument) ? void 0 : _a.qVNodeData) ? void 0 : _b.get(element);
6296
- const vFirstChild = vNodeData ? materializeFromVNodeData(vNode, vNodeData, element, firstChild) : materializeFromDOM(vNode, firstChild);
5984
+ const vFirstChild = materialize(vNode, element, firstChild, vNodeData);
6297
5985
  return vFirstChild;
6298
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
+ };
6299
6006
  var ensureMaterialized = vnode => {
6300
6007
  const vParent = ensureElementVNode(vnode);
6301
6008
  let vFirstChild = vParent[4];
@@ -6368,693 +6075,965 @@ globalThis.qwikOptimizer = function(module) {
6368
6075
  }
6369
6076
  node = nextNode;
6370
6077
  }
6371
- return null;
6372
- }
6373
- var _fastParentNode = null;
6374
- var fastParentNode = node => {
6375
- _fastParentNode || (_fastParentNode = fastGetter(node, "parentNode"));
6376
- 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 ]);
6377
6239
  };
6378
- var _fastFirstChild = null;
6379
- var fastFirstChild = node => {
6380
- _fastFirstChild || (_fastFirstChild = fastGetter(node, "firstChild"));
6381
- node = node && _fastFirstChild.call(node);
6382
- while (node && !fastIsTextOrElement(node)) {
6383
- 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;
6384
6244
  }
6385
- return node;
6245
+ if (vnode_isElementVNode(vnode)) {
6246
+ return vnode[6];
6247
+ }
6248
+ assertTrue(vnode_isTextVNode(vnode), "Expecting Text Node.");
6249
+ return vnode[4];
6386
6250
  };
6387
- var fastGetter = (prototype, name) => {
6251
+ function vnode_toString(depth = 10, offset = "", materialize2 = false, siblings = false) {
6388
6252
  var _a;
6389
- let getter;
6390
- while (prototype && !(getter = null == (_a = Object.getOwnPropertyDescriptor(prototype, name)) ? void 0 : _a.get)) {
6391
- prototype = Object.getPrototypeOf(prototype);
6253
+ let vnode = this;
6254
+ if (0 === depth) {
6255
+ return "...";
6392
6256
  }
6393
- return getter || function() {
6394
- return this[name];
6395
- };
6396
- };
6397
- var isQStyleElement = node => isElement(node) && "STYLE" === node.nodeName && (node.hasAttribute(QScopedStyle) || node.hasAttribute(QStyle));
6398
- var materializeFromDOM = (vParent, firstChild) => {
6399
- let vFirstChild = null;
6400
- const skipStyleElements = () => {
6401
- while (isQStyleElement(child)) {
6402
- 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 + ">");
6403
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;
6404
6328
  };
6405
- let child = firstChild;
6406
- skipStyleElements();
6407
- let vChild = null;
6408
- while (child) {
6409
- const nodeType = fastNodeType(child);
6410
- let vNextChild = null;
6411
- 3 === nodeType ? vNextChild = vnode_newText(child, child.textContent ?? void 0) : 1 === nodeType && (vNextChild = vnode_newUnMaterializedElement(child));
6412
- if (vNextChild) {
6413
- vNextChild[1] = vParent;
6414
- vChild && (vChild[3] = vNextChild);
6415
- vNextChild[2] = vChild;
6416
- 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;
6417
6413
  }
6418
- vFirstChild || (vParent[4] = vFirstChild = vChild);
6419
- child = fastNextSibling(child);
6420
- 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;
6421
6422
  }
6422
- vParent[5] = vChild || null;
6423
- vParent[4] = vFirstChild;
6424
- return vFirstChild;
6423
+ if (2 & type) {
6424
+ return 11;
6425
+ }
6426
+ if (4 & type) {
6427
+ return 3;
6428
+ }
6429
+ throw qError(43, [ type ]);
6425
6430
  };
6426
- var vnode_getNextSibling = vnode => vnode[3];
6427
- var vnode_getPreviousSibling = vnode => vnode[2];
6428
- var vnode_getAttrKeys = vnode => {
6429
- const type = vnode[0];
6430
- if (0 !== (3 & type)) {
6431
- vnode_ensureElementInflated(vnode);
6432
- const keys2 = [];
6433
- for (let i = vnode_getPropStartIndex(vnode); i < vnode.length; i += 2) {
6434
- const key = vnode[i];
6435
- 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;
6436
6465
  }
6437
- return keys2;
6466
+ aDepth--;
6467
+ bDepth--;
6438
6468
  }
6439
- return [];
6469
+ return aDepth < bDepth ? -1 : 1;
6440
6470
  };
6441
- var vnode_setAttr = (journal, vnode, key, value) => {
6442
- const type = vnode[0];
6443
- if (0 !== (3 & type)) {
6444
- vnode_ensureElementInflated(vnode);
6445
- const idx = mapApp_findIndx(vnode, key, vnode_getPropStartIndex(vnode));
6446
- if (idx >= 0) {
6447
- if (vnode[idx + 1] != value && 0 !== (1 & type)) {
6448
- const element = vnode[6];
6449
- journal && journal.push(2, element, key, value);
6450
- }
6451
- null == value ? vnode.splice(idx, 2) : vnode[idx + 1] = value;
6452
- } else if (null != value) {
6453
- vnode.splice(~idx, 0, key, value);
6454
- if (0 !== (1 & type)) {
6455
- const element = vnode[6];
6456
- journal && journal.push(2, element, key, value);
6457
- }
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);
6458
6480
  }
6481
+ projectionDepth > 0 && (vHost = vnode_getParent(vHost));
6459
6482
  }
6483
+ return vHost;
6460
6484
  };
6461
- var vnode_getAttr = (vnode, key) => {
6462
- const type = vnode[0];
6463
- if (0 !== (3 & type)) {
6464
- vnode_ensureElementInflated(vnode);
6465
- 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;
6466
6490
  }
6467
- return null;
6468
- };
6469
- var vnode_getProp = (vnode, key, getObject) => {
6470
- const type = vnode[0];
6471
- if (0 !== (3 & type)) {
6472
- 1 & type && vnode_ensureElementInflated(vnode);
6473
- const idx = mapApp_findIndx(vnode, key, vnode_getPropStartIndex(vnode));
6474
- if (idx >= 0) {
6475
- let value = vnode[idx + 1];
6476
- "string" === typeof value && getObject && (vnode[idx + 1] = value = getObject(value));
6477
- return value;
6478
- }
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;
6479
6495
  }
6480
- return null;
6481
- };
6482
- var vnode_setProp = (vnode, key, value) => {
6483
- ensureElementOrVirtualVNode(vnode);
6484
- const idx = mapApp_findIndx(vnode, key, vnode_getPropStartIndex(vnode));
6485
- idx >= 0 ? vnode[idx + 1] = value : null != value && vnode.splice(~idx, 0, key, value);
6486
- };
6487
- var vnode_getPropStartIndex = vnode => {
6488
- const type = 7 & vnode[0];
6489
- if (1 === type) {
6490
- 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;
6491
6500
  }
6492
- if (2 === type) {
6493
- return 6;
6501
+ constructor(flags, parent, previousSibling, nextSibling) {
6502
+ super();
6503
+ this.push(flags, parent, previousSibling, nextSibling);
6504
+ isDev && (this.toString = vnode_toString);
6494
6505
  }
6495
- throw throwErrorAndStop("Invalid vnode type.");
6496
6506
  };
6497
- var vnode_getParent = vnode => vnode[1] || null;
6498
- var vnode_getNode = vnode => {
6499
- if (null === vnode || vnode_isVirtualVNode(vnode)) {
6500
- return null;
6501
- }
6502
- if (vnode_isElementVNode(vnode)) {
6503
- 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;
6504
6518
  }
6505
- assertTrue(vnode_isTextVNode(vnode), "Expecting Text Node.");
6506
- return vnode[4];
6519
+ return _context;
6507
6520
  };
6508
- function vnode_toString(depth = 10, offset = "", materialize = false, siblings = false) {
6509
- var _a;
6510
- let vnode = this;
6511
- if (0 === depth) {
6512
- 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;
6513
6532
  }
6514
- if (null === vnode) {
6515
- 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;
6516
6570
  }
6517
- if (void 0 === vnode) {
6518
- 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;
6519
6586
  }
6520
- const strings = [];
6521
- do {
6522
- if (vnode_isTextVNode(vnode)) {
6523
- strings.push(qwikDebugToString(vnode_getText(vnode)));
6524
- } else if (vnode_isVirtualVNode(vnode)) {
6525
- const idx = vnode[0] >>> 8;
6526
- const attrs = [ "[" + String(idx) + "]" ];
6527
- vnode_getAttrKeys(vnode).forEach((key => {
6528
- if (key !== DEBUG_TYPE) {
6529
- const value = vnode_getAttr(vnode, key);
6530
- attrs.push(" " + key + "=" + qwikDebugToString(value));
6531
- }
6532
- }));
6533
- const name = VirtualTypeName[vnode_getAttr(vnode, DEBUG_TYPE) || "V"] || VirtualTypeName.V;
6534
- strings.push("<" + name + attrs.join("") + ">");
6535
- const child = vnode_getFirstChild(vnode);
6536
- child && strings.push(" " + vnode_toString.call(child, depth - 1, offset + " ", true, true));
6537
- strings.push("</" + name + ">");
6538
- } else if (vnode_isElementVNode(vnode)) {
6539
- const tag = vnode_getElementName(vnode);
6540
- const attrs = [];
6541
- const keys2 = vnode_getAttrKeys(vnode);
6542
- keys2.forEach((key => {
6543
- const value = vnode_getAttr(vnode, key);
6544
- attrs.push(" " + key + "=" + qwikDebugToString(value));
6545
- }));
6546
- const node = vnode_getNode(vnode);
6547
- if (node) {
6548
- const vnodeData = null == (_a = node.ownerDocument.qVNodeData) ? void 0 : _a.get(node);
6549
- 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;
6550
6651
  }
6551
- const domAttrs = node.attributes;
6552
- for (let i = 0; i < domAttrs.length; i++) {
6553
- const attr = domAttrs[i];
6554
- -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;
6555
6658
  }
6556
- strings.push("<" + tag + attrs.join("") + ">");
6557
- if (vnode_isMaterialized(vnode) || materialize) {
6558
- const child = vnode_getFirstChild(vnode);
6559
- child && strings.push(" " + vnode_toString.call(child, depth - 1, offset + " ", true, true));
6560
- } else {
6561
- 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;
6562
6673
  }
6563
- strings.push("</" + tag + ">");
6564
- }
6565
- vnode = siblings && vnode_getNextSibling(vnode) || null;
6566
- } while (vnode);
6567
- return strings.join("\n" + offset);
6568
- }
6569
- var isNumber = ch => 48 <= ch && ch <= 57;
6570
- var isLowercase = ch => 97 <= ch && ch <= 122;
6571
- var stack = [];
6572
- function materializeFromVNodeData(vParent, vData, element, child) {
6573
- let idx = 0;
6574
- let nextToConsumeIdx = 0;
6575
- let vFirst = null;
6576
- let vLast = null;
6577
- let previousTextNode = null;
6578
- let ch = 0;
6579
- let peekCh = 0;
6580
- const peek = () => 0 !== peekCh ? peekCh : peekCh = nextToConsumeIdx < vData.length ? vData.charCodeAt(nextToConsumeIdx) : 0;
6581
- const consume = () => {
6582
- ch = peek();
6583
- peekCh = 0;
6584
- nextToConsumeIdx++;
6585
- return ch;
6586
- };
6587
- const addVNode = node => {
6588
- node[0] = 255 & node[0] | idx << 8;
6589
- idx++;
6590
- vLast && (vLast[3] = node);
6591
- node[2] = vLast;
6592
- node[1] = vParent;
6593
- vFirst || (vParent[4] = vFirst = node);
6594
- vLast = node;
6595
- };
6596
- const consumeValue = () => {
6597
- consume();
6598
- const start = nextToConsumeIdx;
6599
- while (peek() <= 58 && 0 !== peekCh || 95 === peekCh || peekCh >= 65 && peekCh <= 90 || peekCh >= 97 && peekCh <= 122) {
6600
- consume();
6601
6674
  }
6602
- return vData.substring(start, nextToConsumeIdx);
6675
+ return 0;
6603
6676
  };
6604
- let textIdx = 0;
6605
- let combinedText = null;
6606
- let container = null;
6607
- while (0 !== peek()) {
6608
- if (isNumber(peek())) {
6609
- while (!isElement(child)) {
6610
- child = fastNextSibling(child);
6611
- 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;
6612
6683
  }
6613
- while (isQStyleElement(child)) {
6614
- 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++;
6615
6691
  }
6616
- combinedText = null;
6617
- previousTextNode = null;
6618
- let value = 0;
6619
- while (isNumber(peek())) {
6620
- value *= 10;
6621
- 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
+ }
6622
6720
  }
6623
- while (value--) {
6624
- addVNode(vnode_newUnMaterializedElement(child));
6625
- child = fastNextSibling(child);
6721
+ return elementsToSkip;
6722
+ };
6723
+ do {
6724
+ if (node === exitNode) {
6725
+ return;
6626
6726
  }
6627
- } else if (peek() === VNodeDataChar.SCOPED_STYLE) {
6628
- vnode_setAttr(null, vParent, QScopedStyle, consumeValue());
6629
- } else if (peek() === VNodeDataChar.RENDER_FN) {
6630
- vnode_setAttr(null, vParent, OnRenderProp, consumeValue());
6631
- } else if (peek() === VNodeDataChar.ID) {
6632
- container || (container = getDomContainer(element));
6633
- const id = consumeValue();
6634
- container.$setRawState$(parseInt(id), vParent);
6635
- isDev && vnode_setAttr(null, vParent, ELEMENT_ID, id);
6636
- } else if (peek() === VNodeDataChar.PROPS) {
6637
- vnode_setAttr(null, vParent, ELEMENT_PROPS, consumeValue());
6638
- } else if (peek() === VNodeDataChar.SLOT_REF) {
6639
- vnode_setAttr(null, vParent, QSlotRef, consumeValue());
6640
- } else if (peek() === VNodeDataChar.KEY) {
6641
- vnode_setAttr(null, vParent, ELEMENT_KEY, consumeValue());
6642
- } else if (peek() === VNodeDataChar.SEQ) {
6643
- vnode_setAttr(null, vParent, ELEMENT_SEQ, consumeValue());
6644
- } else if (peek() === VNodeDataChar.SEQ_IDX) {
6645
- vnode_setAttr(null, vParent, ELEMENT_SEQ_IDX, consumeValue());
6646
- } else if (peek() === VNodeDataChar.CONTEXT) {
6647
- vnode_setAttr(null, vParent, QCtxAttr, consumeValue());
6648
- } else if (peek() === VNodeDataChar.OPEN) {
6649
- consume();
6650
- addVNode(vnode_newVirtual());
6651
- stack.push(vParent, vFirst, vLast, previousTextNode, idx);
6652
- idx = 0;
6653
- vParent = vLast;
6654
- vFirst = vLast = null;
6655
- } else if (peek() === VNodeDataChar.SEPARATOR) {
6656
- const key = consumeValue();
6657
- const value = consumeValue();
6658
- vnode_setAttr(null, vParent, key, value);
6659
- } else if (peek() === VNodeDataChar.CLOSE) {
6660
- consume();
6661
- vParent[5] = vLast;
6662
- idx = stack.pop();
6663
- previousTextNode = stack.pop();
6664
- vLast = stack.pop();
6665
- vFirst = stack.pop();
6666
- vParent = stack.pop();
6667
- } else if (peek() === VNodeDataChar.SLOT) {
6668
- vnode_setAttr(null, vParent, QSlot, consumeValue());
6669
- } else {
6670
- const textNode = child && 3 === fastNodeType(child) ? child : null;
6671
- if (null === combinedText) {
6672
- combinedText = textNode ? textNode.nodeValue : null;
6673
- 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 + " ");
6674
6768
  }
6675
- let length = 0;
6676
- while (isLowercase(peek())) {
6677
- length += consume() - 97;
6678
- 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++;
6679
6792
  }
6680
- length += consume() - 65;
6681
- const text = null === combinedText ? "" : combinedText.substring(textIdx, textIdx + length);
6682
- addVNode(previousTextNode = vnode_newSharedText(previousTextNode, textNode, text));
6683
- textIdx += length;
6684
- }
6685
- }
6686
- vParent[5] = vLast;
6687
- return vFirst;
6793
+ } while (node = nextNode || walker2.nextNode());
6794
+ };
6795
+ const walker = document2.createTreeWalker(document2, 129);
6796
+ walkContainer(walker, null, walker.firstChild(), null, "", null, "");
6688
6797
  }
6689
- var vnode_getType = vnode => {
6690
- const type = vnode[0];
6691
- if (1 & type) {
6692
- return 1;
6693
- }
6694
- if (2 & type) {
6695
- return 11;
6696
- }
6697
- if (4 & type) {
6698
- return 3;
6699
- }
6700
- throw throwErrorAndStop("Unknown vnode type: " + type);
6701
- };
6702
- var isElement = node => node && "object" == typeof node && 1 === fastNodeType(node);
6703
- var aPath = [];
6704
- var bPath = [];
6705
- var vnode_documentPosition = (a, b) => {
6706
- if (a === b) {
6707
- return 0;
6708
- }
6709
- let aDepth = -1;
6710
- let bDepth = -1;
6711
- while (a) {
6712
- a = (aPath[++aDepth] = a)[1];
6713
- }
6714
- while (b) {
6715
- b = (bPath[++bDepth] = b)[1];
6798
+ function getDomContainer(element) {
6799
+ const qContainerElement = _getQContainerElement(element);
6800
+ if (!qContainerElement) {
6801
+ throw qError(41);
6716
6802
  }
6717
- while (aDepth >= 0 && bDepth >= 0) {
6718
- a = aPath[aDepth];
6719
- b = bPath[bDepth];
6720
- if (a !== b) {
6721
- let cursor = b;
6722
- do {
6723
- cursor = vnode_getNextSibling(cursor);
6724
- if (cursor === a) {
6725
- return 1;
6726
- }
6727
- } while (cursor);
6728
- cursor = b;
6729
- do {
6730
- cursor = vnode_getPreviousSibling(cursor);
6731
- if (cursor === a) {
6732
- 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;
6733
6820
  }
6734
- } while (cursor);
6735
- return 1;
6736
- }
6737
- aDepth--;
6738
- bDepth--;
6739
- }
6740
- return aDepth < bDepth ? -1 : 1;
6741
- };
6742
- var vnode_getProjectionParentComponent = (vHost, rootVNode) => {
6743
- let projectionDepth = 1;
6744
- while (projectionDepth--) {
6745
- while (vHost && (!vnode_isVirtualVNode(vHost) || null === vnode_getProp(vHost, OnRenderProp, null))) {
6746
- const qSlotParentProp = vnode_getProp(vHost, QSlotParent, null);
6747
- const qSlotParent = qSlotParentProp && ("string" === typeof qSlotParentProp ? vnode_locate(rootVNode, qSlotParentProp) : qSlotParentProp);
6748
- const vProjectionParent = vnode_isVirtualVNode(vHost) && qSlotParent;
6749
- vProjectionParent && projectionDepth++;
6750
- vHost = vProjectionParent || vnode_getParent(vHost);
6751
- }
6752
- projectionDepth > 0 && (vHost = vnode_getParent(vHost));
6753
- }
6754
- return vHost;
6755
- };
6756
- var VNodeArray = class VNode extends Array {
6757
- static createElement(flags, parent, previousSibling, nextSibling, firstChild, lastChild, element, elementName) {
6758
- const vnode = new VNode(flags, parent, previousSibling, nextSibling);
6759
- vnode.push(firstChild, lastChild, element, elementName);
6760
- return vnode;
6761
- }
6762
- static createText(flags, parent, previousSibling, nextSibling, textNode, text) {
6763
- const vnode = new VNode(flags, parent, previousSibling, nextSibling);
6764
- vnode.push(textNode, text);
6765
- return vnode;
6766
- }
6767
- static createVirtual(flags, parent, previousSibling, nextSibling, firstChild, lastChild) {
6768
- const vnode = new VNode(flags, parent, previousSibling, nextSibling);
6769
- vnode.push(firstChild, lastChild);
6770
- return vnode;
6771
- }
6772
- constructor(flags, parent, previousSibling, nextSibling) {
6773
- super();
6774
- this.push(flags, parent, previousSibling, nextSibling);
6775
- isDev && (this.toString = vnode_toString);
6776
- }
6777
- };
6778
- var _context;
6779
- var tryGetInvokeContext = () => {
6780
- if (!_context) {
6781
- const context = "undefined" !== typeof document && document && document.__q_context__;
6782
- if (!context) {
6783
- return;
6784
- }
6785
- if (isArray(context)) {
6786
- return document.__q_context__ = newInvokeContextFromTuple(context);
6821
+ }
6787
6822
  }
6788
- return context;
6789
- }
6790
- return _context;
6791
- };
6792
- var useInvokeContext = () => {
6793
- const ctx = tryGetInvokeContext();
6794
- if (!ctx || ctx.$event$ !== RenderEvent) {
6795
- throw qError(QError_useInvokeContext);
6823
+ container.$serverData$ = {
6824
+ containerAttributes: containerAttributes
6825
+ };
6826
+ qElement.setAttribute(QContainerAttr, "resumed");
6827
+ qElement.qContainer = container;
6796
6828
  }
6797
- assertDefined(ctx.$hostElement$, "invoke: $hostElement$ must be defined", ctx);
6798
- assertDefined(ctx.$effectSubscriber$, "invoke: $effectSubscriber$ must be defined", ctx);
6799
- return ctx;
6800
- };
6801
- function invoke(context, fn, ...args) {
6802
- return invokeApply.call(this, context, fn, args);
6829
+ return container;
6803
6830
  }
6804
- function invokeApply(context, fn, args) {
6805
- const previousContext = _context;
6806
- let returnValue;
6807
- try {
6808
- _context = context;
6809
- returnValue = fn.apply(this, args);
6810
- } finally {
6811
- _context = previousContext;
6812
- }
6813
- return returnValue;
6831
+ function _getQContainerElement(element) {
6832
+ const qContainerElement = Array.isArray(element) ? vnode_getDomParent(element) : element;
6833
+ return qContainerElement.closest(QContainerSelector);
6814
6834
  }
6815
- var newInvokeContextFromTuple = ([element, event, url]) => {
6816
- const container = element.closest(QContainerSelector);
6817
- const locale = (null == container ? void 0 : container.getAttribute(QLocaleAttr)) || void 0;
6818
- locale && setLocale(locale);
6819
- return newInvokeContext(locale, void 0, element, event, url);
6820
- };
6821
- var newInvokeContext = (locale, hostElement, element, event, url) => {
6822
- const $locale$ = locale || ("object" === typeof event && event && "locale" in event ? event.locale : void 0);
6823
- const ctx = {
6824
- $url$: url,
6825
- $i$: 0,
6826
- $hostElement$: hostElement,
6827
- $element$: element,
6828
- $event$: event,
6829
- $qrl$: void 0,
6830
- $effectSubscriber$: void 0,
6831
- $locale$: $locale$,
6832
- $container$: void 0
6833
- };
6834
- seal(ctx);
6835
- return ctx;
6836
- };
6837
- var untrack = fn => invoke(void 0, fn);
6838
- var trackInvocation = newInvokeContext(void 0, void 0, void 0, RenderEvent);
6839
- var trackSignal = (fn, subscriber, property, container, data) => {
6840
- const previousSubscriber = trackInvocation.$effectSubscriber$;
6841
- const previousContainer = trackInvocation.$container$;
6842
- try {
6843
- trackInvocation.$effectSubscriber$ = [ subscriber, property ];
6844
- data && trackInvocation.$effectSubscriber$.push(data);
6845
- trackInvocation.$container$ = container;
6846
- return invoke(trackInvocation, fn);
6847
- } finally {
6848
- trackInvocation.$effectSubscriber$ = previousSubscriber;
6849
- trackInvocation.$container$ = previousContainer;
6850
- }
6851
- };
6852
- var _jsxSorted = (type, varProps, constProps, children, flags, key, dev) => {
6853
- const processed = null == key ? null : String(key);
6854
- const node = new JSXNodeImpl(type, varProps || {}, constProps || null, children, flags, processed);
6855
- qDev && dev && (node.dev = {
6856
- stack: (new Error).stack,
6857
- ...dev
6858
- });
6859
- seal(node);
6860
- return node;
6861
- };
6862
- var _jsxSplit = (type, varProps, constProps, children, flags, key, dev) => {
6863
- let sortedProps;
6864
- sortedProps = varProps ? Object.fromEntries(untrack((() => Object.entries(varProps))).filter((entry => {
6865
- const attr = entry[0];
6866
- if ("children" === attr) {
6867
- children ??= entry[1];
6868
- return false;
6869
- }
6870
- if ("key" === attr) {
6871
- key = entry[1];
6872
- 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);
6873
6858
  }
6874
- return !constProps || !(attr in constProps) || /^on[A-Z].*\$$/.test(attr);
6875
- })).sort((([a], [b]) => a < b ? -1 : 1))) : "string" === typeof type ? EMPTY_OBJ : {};
6876
- if (constProps && "children" in constProps) {
6877
- children = constProps.children;
6878
- constProps.children = void 0;
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$);
6877
+ }
6878
+ this.$qFuncs$ = getQFuncs(document2, this.$instanceHash$) || EMPTY_ARRAY;
6879
6879
  }
6880
- return _jsxSorted(type, sortedProps, constProps, children, flags, key, dev);
6881
- };
6882
- var isPropsProxy = obj => obj && void 0 !== obj[_VAR_PROPS];
6883
- var JSXNodeImpl = class {
6884
- constructor(type, varProps, constProps, children, flags, key = null) {
6885
- this.type = type;
6886
- this.varProps = varProps;
6887
- this.constProps = constProps;
6888
- this.children = children;
6889
- this.flags = flags;
6890
- 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) {
6891
6887
  if (qDev) {
6892
- if ("object" !== typeof varProps) {
6893
- 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);
6894
6900
  }
6895
- if ("object" !== typeof constProps) {
6896
- 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;
6897
6904
  }
6898
6905
  }
6906
+ const errorStore = this.resolveContext(host, ERROR_CONTEXT);
6907
+ if (!errorStore) {
6908
+ throw err;
6909
+ }
6910
+ errorStore.error = err;
6899
6911
  }
6900
- dev;
6901
- _proxy=null;
6902
- get props() {
6903
- this._proxy || (this._proxy = createPropsProxy(this.varProps, this.constProps, this.children));
6904
- 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);
6905
6916
  }
6906
- };
6907
- var Virtual = props => props.children;
6908
- var isJSXNode = n => {
6909
- if (qDev) {
6910
- if (n instanceof JSXNodeImpl) {
6911
- 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);
6912
6927
  }
6913
- if (isObject(n) && "key" in n && "props" in n && "type" in n) {
6914
- logWarn('Duplicate implementations of "JSXNode" found');
6915
- 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);
6916
6944
  }
6917
- return false;
6945
+ return null;
6918
6946
  }
6919
- return n instanceof JSXNodeImpl;
6920
- };
6921
- var Fragment = props => props.children;
6922
- function createPropsProxy(varProps, constProps, children) {
6923
- return new Proxy({}, new PropsProxyHandler(varProps, constProps, children));
6924
- }
6925
- var PropsProxyHandler = class {
6926
- constructor($varProps$, $constProps$, $children$) {
6927
- this.$varProps$ = $varProps$;
6928
- this.$constProps$ = $constProps$;
6929
- this.$children$ = $children$;
6947
+ setHostProp(host, name, value) {
6948
+ const vNode = host;
6949
+ vnode_setProp(vNode, name, value);
6930
6950
  }
6931
- get(_, prop) {
6932
- if (prop === _CONST_PROPS) {
6933
- return this.$constProps$;
6934
- }
6935
- if (prop === _VAR_PROPS) {
6936
- return this.$varProps$;
6937
- }
6938
- if (null != this.$children$ && "children" === prop) {
6939
- 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;
6940
6967
  }
6941
- const value = this.$constProps$ && prop in this.$constProps$ ? this.$constProps$[prop] : this.$varProps$[prop];
6942
- return value instanceof WrappedSignal ? value.value : value;
6968
+ return vnode_getProp(vNode, name, getObjectById);
6943
6969
  }
6944
- set(_, prop, value) {
6945
- if (prop === _CONST_PROPS) {
6946
- this.$constProps$ = value;
6947
- 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
+ }));
6948
6986
  }
6949
- if (prop === _VAR_PROPS) {
6950
- this.$varProps$ = value;
6951
- return true;
6987
+ if (renderCount !== this.$renderCount$) {
6988
+ this.processChores();
6989
+ return;
6952
6990
  }
6953
- this.$constProps$ && prop in this.$constProps$ ? this.$constProps$[prop] = value : this.$varProps$[prop] = value;
6954
- return true;
6991
+ this.renderDone = null;
6955
6992
  }
6956
- deleteProperty(_, prop) {
6957
- if ("string" !== typeof prop) {
6958
- 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
+ }
6959
7003
  }
6960
- let didDelete = delete this.$varProps$[prop];
6961
- this.$constProps$ && (didDelete = delete this.$constProps$[prop] || didDelete);
6962
- null != this.$children$ && "children" === prop && (this.$children$ = null);
6963
- return didDelete;
6964
- }
6965
- has(_, prop) {
6966
- const hasProp = "children" === prop && null != this.$children$ || prop === _CONST_PROPS || prop === _VAR_PROPS || prop in this.$varProps$ || !!this.$constProps$ && prop in this.$constProps$;
6967
- return hasProp;
6968
7004
  }
6969
- getOwnPropertyDescriptor(target, p) {
6970
- const value = "children" === p && null != this.$children$ ? this.$children$ : this.$constProps$ && p in this.$constProps$ ? this.$constProps$[p] : this.$varProps$[p];
6971
- return {
6972
- configurable: true,
6973
- enumerable: true,
6974
- value: value
6975
- };
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;
6976
7014
  }
6977
- ownKeys() {
6978
- const out = Object.keys(this.$varProps$);
6979
- null != this.$children$ && -1 === out.indexOf("children") && out.push("children");
6980
- if (this.$constProps$) {
6981
- for (const key in this.$constProps$) {
6982
- -1 === out.indexOf(key) && out.push(key);
6983
- }
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);
6984
7034
  }
6985
- return out;
6986
- }
6987
- };
6988
- var directGetPropsProxyProp = (jsx2, prop) => jsx2.constProps && prop in jsx2.constProps ? jsx2.constProps[prop] : jsx2.varProps[prop];
6989
- var componentQrl = componentQrl2 => {
6990
- function QwikComponent(props, key, flags = 0) {
6991
- assertQrl(componentQrl2);
6992
- assertNumber(flags, "The Qwik Component was not invoked correctly");
6993
- const hash = qTest ? "sX" : componentQrl2.$hash$.slice(0, 4);
6994
- const finalKey = hash + ":" + (key || "");
6995
- const InnerCmp = () => {};
6996
- InnerCmp[SERIALIZABLE_STATE] = [ componentQrl2 ];
6997
- return _jsxSplit(InnerCmp, props, null, props.children, flags, finalKey);
6998
7035
  }
6999
- QwikComponent[SERIALIZABLE_STATE] = [ componentQrl2 ];
7000
- return QwikComponent;
7001
7036
  };
7002
- var SERIALIZABLE_STATE = Symbol("serializable-data");
7003
- var isQwikComponent = component => "function" == typeof component && void 0 !== component[SERIALIZABLE_STATE];
7004
- implicit$FirstArg(eventQrl);
7005
- var rule = 0;
7006
- var elementClassIdSelector = 1;
7007
- var starSelector = 2;
7008
- var pseudoClassWithSelector = 3;
7009
- var pseudoClass = 4;
7010
- var pseudoGlobal = 5;
7011
- var pseudoElement = 6;
7012
- var attrSelector = 7;
7013
- var inertParenthesis = 8;
7014
- var inertBlock = 9;
7015
- var atRuleSelector = 10;
7016
- var atRuleBlock = 11;
7017
- var atRuleInert = 12;
7018
- var body = 13;
7019
- var stringSingle = 14;
7020
- var stringDouble = 15;
7021
- var commentMultiline = 16;
7022
- var EXIT = 17;
7023
- var EXIT_INSERT_SCOPE = 18;
7024
- var ANY = 0;
7025
- var IDENT = 1;
7026
- var NOT_IDENT = 2;
7027
- var WHITESPACE = 3;
7028
- var DOUBLE_QUOTE = 34;
7029
- var HASH = 35;
7030
- var SINGLE_QUOTE = 39;
7031
- var OPEN_PARENTHESIS = 40;
7032
- var CLOSE_PARENTHESIS = 41;
7033
- var STAR = 42;
7034
- var DOT = 46;
7035
- var FORWARD_SLASH = 47;
7036
- var COLON = 58;
7037
- var SEMICOLON = 59;
7038
- var AT = 64;
7039
- var OPEN_BRACKET = 91;
7040
- var CLOSE_BRACKET = 93;
7041
- var OPEN_BRACE = 123;
7042
- var CLOSE_BRACE = 125;
7043
- var STRINGS_COMMENTS = (() => [ [ ANY, SINGLE_QUOTE, stringSingle ], [ ANY, DOUBLE_QUOTE, stringDouble ], [ ANY, FORWARD_SLASH, commentMultiline, "*" ] ])();
7044
- var useComputedQrl = qrl2 => {
7045
- const {val: val, set: set} = useSequentialScope();
7046
- if (val) {
7047
- return val;
7048
- }
7049
- assertQrl(qrl2);
7050
- const signal = new ComputedSignal(null, qrl2);
7051
- set(signal);
7052
- throwIfQRLNotResolved(qrl2);
7053
- return signal;
7054
- };
7055
- implicit$FirstArg(useComputedQrl);
7056
- Number.MAX_SAFE_INTEGER;
7057
- Number.MAX_SAFE_INTEGER;
7058
7037
  var deserializedProxyMap = new WeakMap;
7059
7038
  var unwrapDeserializerProxy = value => {
7060
7039
  const unwrapped = "object" === typeof value && null !== value && value[SERIALIZER_PROXY_UNWRAP];
@@ -7146,7 +7125,11 @@ globalThis.qwikOptimizer = function(module) {
7146
7125
  const valType = data[i2 + 2];
7147
7126
  const valData = data[i2 + 3];
7148
7127
  0 === valType || valType >= 12 ? Object.defineProperty(target, key, {
7149
- get: () => deserializeData(container, valType, valData),
7128
+ get() {
7129
+ const value = deserializeData(container, valType, valData);
7130
+ target[key] = value;
7131
+ return value;
7132
+ },
7150
7133
  set(value) {
7151
7134
  Object.defineProperty(target, key, {
7152
7135
  value: value,
@@ -7225,7 +7208,8 @@ globalThis.qwikOptimizer = function(module) {
7225
7208
  signal.$args$ = d[1];
7226
7209
  signal.$effectDependencies$ = d[2];
7227
7210
  signal.$untrackedValue$ = d[3];
7228
- signal.$effects$ = d.slice(4);
7211
+ signal.$hostElement$ = d[4];
7212
+ signal.$effects$ = d.slice(5);
7229
7213
  break;
7230
7214
  }
7231
7215
 
@@ -7331,12 +7315,13 @@ globalThis.qwikOptimizer = function(module) {
7331
7315
  case 30:
7332
7316
  {
7333
7317
  const effectData = target;
7334
- effectData.data = data[0];
7318
+ effectData.data.$scopedStyleIdPrefix$ = data[0];
7319
+ effectData.data.$isConst$ = data[1];
7335
7320
  break;
7336
7321
  }
7337
7322
 
7338
7323
  default:
7339
- return throwErrorAndStop("Not implemented");
7324
+ throw qError(33, [ typeId ]);
7340
7325
  }
7341
7326
  };
7342
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 ];
@@ -7361,11 +7346,11 @@ globalThis.qwikOptimizer = function(module) {
7361
7346
  return {};
7362
7347
 
7363
7348
  case 18:
7364
- const qrl2 = container.$getObjectById$(value);
7365
- return parseQRL(qrl2);
7349
+ const qrl = container.$getObjectById$(value);
7350
+ return parseQRL(qrl);
7366
7351
 
7367
7352
  case 19:
7368
- return new Task2(-1, -1, null, null, null, null);
7353
+ return new Task(-1, -1, null, null, null, null);
7369
7354
 
7370
7355
  case 20:
7371
7356
  {
@@ -7453,26 +7438,29 @@ globalThis.qwikOptimizer = function(module) {
7453
7438
  return vnodeOrDocument;
7454
7439
  }
7455
7440
  const vNode = retrieveVNodeOrDocument(container, value);
7456
- 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 ]);
7457
7445
 
7458
7446
  case 30:
7459
- return new EffectData(null);
7447
+ return new EffectPropData({});
7460
7448
 
7461
7449
  default:
7462
- return throwErrorAndStop("unknown allocate type: " + typeId);
7450
+ throw qError(35, [ typeId ]);
7463
7451
  }
7464
7452
  };
7465
7453
  function retrieveVNodeOrDocument(container, value) {
7466
7454
  var _a;
7467
7455
  return value ? container.rootVNode ? vnode_locate(container.rootVNode, value) : void 0 : null == (_a = container.element) ? void 0 : _a.ownerDocument;
7468
7456
  }
7469
- function parseQRL(qrl2) {
7470
- const hashIdx = qrl2.indexOf("#");
7471
- const captureStart = qrl2.indexOf("[", hashIdx);
7472
- const captureEnd = qrl2.indexOf("]", captureStart);
7473
- const chunk = hashIdx > -1 ? qrl2.slice(0, hashIdx) : qrl2.slice(0, captureStart);
7474
- const symbol = captureStart > -1 ? qrl2.slice(hashIdx + 1, captureStart) : qrl2.slice(hashIdx + 1);
7475
- 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;
7476
7464
  let qrlRef = null;
7477
7465
  if (isDev2 && chunk === QRL_RUNTIME_CHUNK) {
7478
7466
  const backChannel = globalThis[QRL_RUNTIME_CHUNK];
@@ -7481,12 +7469,13 @@ globalThis.qwikOptimizer = function(module) {
7481
7469
  }
7482
7470
  return createQRL(chunk, symbol, qrlRef, null, captureIds, null, null);
7483
7471
  }
7484
- function inflateQRL(container, qrl2) {
7485
- const captureIds = qrl2.$capture$;
7486
- qrl2.$captureRef$ = captureIds ? captureIds.map((id => container.$getObjectById$(id))) : null;
7487
- container.element && qrl2.$setContainer$(container.element);
7488
- 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;
7489
7477
  }
7478
+ var isDomRef = obj => false;
7490
7479
  var createSerializationContext = (NodeConstructor, DomRefConstructor, symbolToChunkResolver, getProp, setProp, storeProxyMap, writer, prepVNodeData) => {
7491
7480
  if (!writer) {
7492
7481
  const buffer = [];
@@ -7511,7 +7500,7 @@ globalThis.qwikOptimizer = function(module) {
7511
7500
  return id;
7512
7501
  };
7513
7502
  const isSsrNode = NodeConstructor ? obj => obj instanceof NodeConstructor : () => false;
7514
- const isDomRef = DomRefConstructor ? obj => obj instanceof DomRefConstructor : () => false;
7503
+ isDomRef = DomRefConstructor ? obj => obj instanceof DomRefConstructor : () => false;
7515
7504
  return {
7516
7505
  $serialize$() {
7517
7506
  serialize(this);
@@ -7530,7 +7519,7 @@ globalThis.qwikOptimizer = function(module) {
7530
7519
  $getRootId$: obj => {
7531
7520
  const id = map.get(obj);
7532
7521
  if (!id || -1 === id) {
7533
- return throwErrorAndStop("Missing root id for: ", obj);
7522
+ throw qError(36, [ obj ]);
7534
7523
  }
7535
7524
  return id;
7536
7525
  },
@@ -7573,8 +7562,8 @@ globalThis.qwikOptimizer = function(module) {
7573
7562
  if (isQrl2(obj)) {
7574
7563
  obj.$captureRef$ && discoveredValues.push(...obj.$captureRef$);
7575
7564
  } else if (isQwikComponent(obj)) {
7576
- const [qrl2] = obj[SERIALIZABLE_STATE];
7577
- discoveredValues.push(qrl2);
7565
+ const [qrl] = obj[SERIALIZABLE_STATE];
7566
+ discoveredValues.push(qrl);
7578
7567
  }
7579
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) {
7580
7569
  discoveredValues.push(...Object.values(obj));
@@ -7600,15 +7589,21 @@ globalThis.qwikOptimizer = function(module) {
7600
7589
  if (obj instanceof WrappedSignal) {
7601
7590
  obj.$effectDependencies$ && discoveredValues.push(...obj.$effectDependencies$);
7602
7591
  obj.$args$ && discoveredValues.push(...obj.$args$);
7592
+ obj.$hostElement$ && discoveredValues.push(obj.$hostElement$);
7603
7593
  } else {
7604
7594
  obj instanceof ComputedSignal && discoveredValues.push(obj.$computeQrl$);
7605
7595
  }
7606
- } else if (obj instanceof Task2) {
7596
+ } else if (obj instanceof Task) {
7607
7597
  discoveredValues.push(obj.$el$, obj.$qrl$, obj.$state$, obj.$effectDependencies$);
7608
7598
  } else if (isSsrNode(obj)) {
7609
- 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
+ }
7610
7605
  } else if (isDomRef(obj)) {
7611
- discoveredValues.push(obj.id);
7606
+ discoveredValues.push(obj.$ssrNode$.id);
7612
7607
  } else if (isJSXNode(obj)) {
7613
7608
  discoveredValues.push(obj.type, obj.props, obj.constProps, obj.children);
7614
7609
  } else if (Array.isArray(obj)) {
@@ -7626,11 +7621,11 @@ globalThis.qwikOptimizer = function(module) {
7626
7621
  discoveredValues.push(error);
7627
7622
  }));
7628
7623
  promises.push(obj);
7629
- } else if (obj instanceof EffectData) {
7624
+ } else if (obj instanceof EffectPropData) {
7630
7625
  discoveredValues.push(obj.data);
7631
7626
  } else {
7632
7627
  if (!isObjectLiteral(obj)) {
7633
- return throwErrorAndStop("Unknown type: " + obj);
7628
+ throw qError(37, [ obj ]);
7634
7629
  }
7635
7630
  Object.entries(obj).forEach((([key, value]) => {
7636
7631
  discoveredValues.push(key, value);
@@ -7659,6 +7654,20 @@ globalThis.qwikOptimizer = function(module) {
7659
7654
  } while (discoveredValues.length);
7660
7655
  }
7661
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
+ };
7662
7671
  var promiseResults = new WeakMap;
7663
7672
  function serialize(serializationContext) {
7664
7673
  const {$writer$: $writer$, $isSsrNode$: $isSsrNode$, $isDomRef$: $isDomRef$, $setProp$: $setProp$, $storeProxyMap$: $storeProxyMap$} = serializationContext;
@@ -7703,13 +7712,13 @@ globalThis.qwikOptimizer = function(module) {
7703
7712
  } else if (value === Fragment) {
7704
7713
  output(1, 9);
7705
7714
  } else if (isQrl2(value)) {
7706
- const qrl2 = qrlToString(serializationContext, value);
7707
- const id = serializationContext.$addRoot$(qrl2);
7715
+ const qrl = qrlToString(serializationContext, value);
7716
+ const id = serializationContext.$addRoot$(qrl);
7708
7717
  output(18, id);
7709
7718
  } else if (isQwikComponent(value)) {
7710
- const [qrl2] = value[SERIALIZABLE_STATE];
7711
- serializationContext.$renderSymbols$.add(qrl2.$symbol$);
7712
- output(21, [ qrl2 ]);
7719
+ const [qrl] = value[SERIALIZABLE_STATE];
7720
+ serializationContext.$renderSymbols$.add(qrl.$symbol$);
7721
+ output(21, [ qrl ]);
7713
7722
  } else {
7714
7723
  console.error("Cannot serialize function (ignoring for now): " + value.toString());
7715
7724
  output(1, 0);
@@ -7733,8 +7742,13 @@ globalThis.qwikOptimizer = function(module) {
7733
7742
  const seen = depth > 1 && serializationContext.$wasSeen$(value);
7734
7743
  "number" === typeof seen && seen >= 0 ? output(0, seen) : output(3, value);
7735
7744
  }
7745
+ } else if ("undefined" === typeof value) {
7746
+ output(1, 0);
7736
7747
  } else {
7737
- "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);
7738
7752
  }
7739
7753
  };
7740
7754
  const writeObjectValue = (value, idx) => {
@@ -7752,14 +7766,14 @@ globalThis.qwikOptimizer = function(module) {
7752
7766
  const constProps = value[_CONST_PROPS];
7753
7767
  const out = constProps ? [ varProps, constProps ] : Object.keys(varProps).length ? [ varProps ] : 0;
7754
7768
  output(29, out);
7755
- } else if (value instanceof EffectData) {
7756
- output(30, [ value.data ]);
7769
+ } else if (value instanceof EffectPropData) {
7770
+ output(30, [ value.data.$scopedStyleIdPrefix$, value.data.$isConst$ ]);
7757
7771
  } else if (isStore(value)) {
7758
7772
  if (isResource(value)) {
7759
7773
  serializationContext.$resources$.add(value);
7760
7774
  const res = promiseResults.get(value.value);
7761
7775
  if (!res) {
7762
- return throwErrorAndStop("Unvisited Resource");
7776
+ throw qError(38, [ "resource" ]);
7763
7777
  }
7764
7778
  output(20, [ ...res, getStoreHandler(value).$effects$ ]);
7765
7779
  } else {
@@ -7794,11 +7808,12 @@ globalThis.qwikOptimizer = function(module) {
7794
7808
  output(13, out);
7795
7809
  }
7796
7810
  } else if ($isDomRef$(value)) {
7797
- output(9, value.id);
7811
+ value.$ssrNode$.vnodeData[0] |= 16;
7812
+ output(9, value.$ssrNode$.id);
7798
7813
  } else if (value instanceof Signal) {
7799
7814
  const v = value instanceof ComputedSignal && (value.$invalid$ || fastSkipSerialize(value.$untrackedValue$)) ? NEEDS_COMPUTATION : value.$untrackedValue$;
7800
7815
  if (value instanceof WrappedSignal) {
7801
- output(23, [ ...serializeWrappingFn(serializationContext, value), value.$effectDependencies$, v, ...value.$effects$ || [] ]);
7816
+ output(23, [ ...serializeWrappingFn(serializationContext, value), value.$effectDependencies$, v, value.$hostElement$, ...value.$effects$ || [] ]);
7802
7817
  } else if (value instanceof ComputedSignal) {
7803
7818
  const out = [ value.$computeQrl$, value.$effects$ ];
7804
7819
  v !== NEEDS_COMPUTATION && out.push(v);
@@ -7825,11 +7840,11 @@ globalThis.qwikOptimizer = function(module) {
7825
7840
  const vNodeData = value.vnodeData;
7826
7841
  if (vNodeData) {
7827
7842
  null == (_a = serializationContext.$prepVNodeData$) || _a.call(serializationContext, vNodeData);
7828
- vNodeData[0] |= 8;
7843
+ vNodeData[0] |= 16;
7829
7844
  }
7830
7845
  if (value.childrenVNodeData) {
7831
7846
  for (const vNodeData2 of value.childrenVNodeData) {
7832
- vNodeData2[0] |= 8;
7847
+ vNodeData2[0] |= 16;
7833
7848
  }
7834
7849
  }
7835
7850
  } else {
@@ -7854,7 +7869,7 @@ globalThis.qwikOptimizer = function(module) {
7854
7869
  output(16, combined);
7855
7870
  } else if (isJSXNode(value)) {
7856
7871
  output(28, [ value.type, value.varProps, value.constProps, value.children, value.flags, value.key ]);
7857
- } else if (value instanceof Task2) {
7872
+ } else if (value instanceof Task) {
7858
7873
  const out = [ value.$qrl$, value.$flags$, value.$index$, value.$el$, value.$effectDependencies$, value.$state$ ];
7859
7874
  while (null == out[out.length - 1]) {
7860
7875
  out.pop();
@@ -7863,12 +7878,12 @@ globalThis.qwikOptimizer = function(module) {
7863
7878
  } else if (isPromise(value)) {
7864
7879
  const res = promiseResults.get(value);
7865
7880
  if (!res) {
7866
- return throwErrorAndStop("Unvisited Promise");
7881
+ throw qError(38, [ "promise" ]);
7867
7882
  }
7868
7883
  output(14, res);
7869
7884
  } else {
7870
7885
  if (!(value instanceof Uint8Array)) {
7871
- return throwErrorAndStop("implement");
7886
+ throw qError(37, [ typeof value ]);
7872
7887
  }
7873
7888
  {
7874
7889
  let buf = "";
@@ -7913,7 +7928,9 @@ globalThis.qwikOptimizer = function(module) {
7913
7928
  backChannel.set(value.$symbol$, value._devOnlySymbolRef);
7914
7929
  chunk || (chunk = QRL_RUNTIME_CHUNK);
7915
7930
  }
7916
- chunk || throwErrorAndStop("Missing chunk for: " + value.$symbol$);
7931
+ if (!chunk) {
7932
+ throw qError(31, [ value.$symbol$ ]);
7933
+ }
7917
7934
  chunk.startsWith("./") && (chunk = chunk.slice(2));
7918
7935
  }
7919
7936
  let qrlStringInline = `${chunk}#${symbol}`;
@@ -7947,7 +7964,7 @@ globalThis.qwikOptimizer = function(module) {
7947
7964
  function isResource(value) {
7948
7965
  return "__brand" in value && "resource" === value.__brand;
7949
7966
  }
7950
- 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);
7951
7968
  var canSerialize = value => {
7952
7969
  if (null == value || "string" === typeof value || "number" === typeof value || "boolean" === typeof value || "bigint" === typeof value) {
7953
7970
  return true;
@@ -8010,6 +8027,9 @@ globalThis.qwikOptimizer = function(module) {
8010
8027
  if (value instanceof Uint8Array) {
8011
8028
  return true;
8012
8029
  }
8030
+ if (null == isDomRef ? void 0 : isDomRef(value)) {
8031
+ return true;
8032
+ }
8013
8033
  } else if ("function" === typeof value && (isQrl2(value) || isQwikComponent(value))) {
8014
8034
  return true;
8015
8035
  }
@@ -8049,7 +8069,7 @@ globalThis.qwikOptimizer = function(module) {
8049
8069
  let expectIndex = 0;
8050
8070
  unwrapped.forEach(((v, i) => {
8051
8071
  if (i !== expectIndex) {
8052
- throw qError(QError_verifySerializable, unwrapped);
8072
+ throw qError(3, [ unwrapped ]);
8053
8073
  }
8054
8074
  _verifySerializable(v, seen, ctx + "[" + i + "]");
8055
8075
  expectIndex = i + 1;
@@ -8078,8 +8098,7 @@ globalThis.qwikOptimizer = function(module) {
8078
8098
  const fnName = value.name;
8079
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.`;
8080
8100
  }
8081
- console.error("Trying to serialize", value);
8082
- throwErrorAndStop(message);
8101
+ throw qError(3, [ message ]);
8083
8102
  }
8084
8103
  return value;
8085
8104
  };
@@ -8105,7 +8124,7 @@ globalThis.qwikOptimizer = function(module) {
8105
8124
  }
8106
8125
  }
8107
8126
  let _containerEl;
8108
- const qrl2 = async function(...args) {
8127
+ const qrl = async function(...args) {
8109
8128
  const boundedFn = bindFnToContext.call(this, tryGetInvokeContext());
8110
8129
  const result = await boundedFn(...args);
8111
8130
  return result;
@@ -8117,7 +8136,7 @@ globalThis.qwikOptimizer = function(module) {
8117
8136
  function bindFnToContext(currentCtx, beforeFn) {
8118
8137
  return (...args) => maybeThen(resolveLazy(), (fn => {
8119
8138
  if (!isFunction(fn)) {
8120
- throw qError(QError_qrlIsNotFunction);
8139
+ throw qError(10);
8121
8140
  }
8122
8141
  if (beforeFn && false === beforeFn()) {
8123
8142
  return;
@@ -8125,7 +8144,7 @@ globalThis.qwikOptimizer = function(module) {
8125
8144
  const context = createOrReuseInvocationContext(currentCtx);
8126
8145
  const prevQrl = context.$qrl$;
8127
8146
  const prevEvent = context.$event$;
8128
- context.$qrl$ = qrl2;
8147
+ context.$qrl$ = qrl;
8129
8148
  context.$event$ ||= this;
8130
8149
  try {
8131
8150
  return invoke.call(this, context, fn, ...args);
@@ -8146,7 +8165,7 @@ globalThis.qwikOptimizer = function(module) {
8146
8165
  return fn.apply(this, args);
8147
8166
  }
8148
8167
  context = newInvokeContext();
8149
- context.$qrl$ = qrl2;
8168
+ context.$qrl$ = qrl;
8150
8169
  context.$event$ = this;
8151
8170
  return invoke.call(this, context, fn, ...args);
8152
8171
  };
@@ -8161,15 +8180,15 @@ globalThis.qwikOptimizer = function(module) {
8161
8180
  const hash2 = _containerEl.getAttribute(QInstanceAttr);
8162
8181
  const doc = _containerEl.ownerDocument;
8163
8182
  const qFuncs = getQFuncs(doc, hash2);
8164
- return qrl2.resolved = symbolRef = qFuncs[Number(symbol)];
8183
+ return qrl.resolved = symbolRef = qFuncs[Number(symbol)];
8165
8184
  }
8166
8185
  const start = now();
8167
8186
  const ctx = tryGetInvokeContext();
8168
8187
  if (null !== symbolFn) {
8169
- symbolRef = symbolFn().then((module2 => qrl2.resolved = symbolRef = wrapFn(module2[symbol])));
8188
+ symbolRef = symbolFn().then((module2 => qrl.resolved = symbolRef = wrapFn(module2[symbol])));
8170
8189
  } else {
8171
8190
  const imported = getPlatform().importSymbol(_containerEl, chunk, symbol);
8172
- symbolRef = maybeThen(imported, (ref => qrl2.resolved = symbolRef = wrapFn(ref)));
8191
+ symbolRef = maybeThen(imported, (ref => qrl.resolved = symbolRef = wrapFn(ref)));
8173
8192
  }
8174
8193
  "object" === typeof symbolRef && isPromise(symbolRef) && symbolRef.then((() => emitUsedSymbol(symbol, null == ctx ? void 0 : ctx.$element$, start)), (err => {
8175
8194
  console.error(`qrl ${symbol} failed to load`, err);
@@ -8181,7 +8200,7 @@ globalThis.qwikOptimizer = function(module) {
8181
8200
  const createOrReuseInvocationContext = invoke2 => null == invoke2 ? newInvokeContext() : isArray(invoke2) ? newInvokeContextFromTuple(invoke2) : invoke2;
8182
8201
  const resolvedSymbol = refSymbol ?? symbol;
8183
8202
  const hash = getSymbolHash(resolvedSymbol);
8184
- Object.assign(qrl2, {
8203
+ Object.assign(qrl, {
8185
8204
  getSymbol: () => resolvedSymbol,
8186
8205
  getHash: () => hash,
8187
8206
  getCaptured: () => captureRef,
@@ -8198,12 +8217,12 @@ globalThis.qwikOptimizer = function(module) {
8198
8217
  dev: null,
8199
8218
  resolved: void 0
8200
8219
  });
8201
- symbolRef && (symbolRef = maybeThen(symbolRef, (resolved => qrl2.resolved = symbolRef = wrapFn(resolved))));
8202
- isDev && Object.defineProperty(qrl2, "_devOnlySymbolRef", {
8220
+ symbolRef && (symbolRef = maybeThen(symbolRef, (resolved => qrl.resolved = symbolRef = wrapFn(resolved))));
8221
+ isDev && Object.defineProperty(qrl, "_devOnlySymbolRef", {
8203
8222
  get: () => symbolRef
8204
8223
  });
8205
- qDev && seal(qrl2);
8206
- return qrl2;
8224
+ qDev && seal(qrl);
8225
+ return qrl;
8207
8226
  };
8208
8227
  var getSymbolHash = symbolName => {
8209
8228
  const index = symbolName.lastIndexOf("_");
@@ -8212,8 +8231,8 @@ globalThis.qwikOptimizer = function(module) {
8212
8231
  }
8213
8232
  return symbolName;
8214
8233
  };
8215
- function assertQrl(qrl2) {
8216
- if (qDev && !isQrl2(qrl2)) {
8234
+ function assertQrl(qrl) {
8235
+ if (qDev && !isQrl2(qrl)) {
8217
8236
  throw new Error("Not a QRL");
8218
8237
  }
8219
8238
  }
@@ -8317,8 +8336,8 @@ globalThis.qwikOptimizer = function(module) {
8317
8336
  }
8318
8337
  const firstInput = opts.input && Object.values(opts.input)[0];
8319
8338
  const ssrModule = await server.ssrLoadModule(firstInput);
8320
- const render2 = ssrModule.default ?? ssrModule.render;
8321
- if ("function" === typeof render2) {
8339
+ const render = ssrModule.default ?? ssrModule.render;
8340
+ if ("function" === typeof render) {
8322
8341
  const manifest = {
8323
8342
  manifestHash: "",
8324
8343
  symbols: {},
@@ -8367,7 +8386,7 @@ globalThis.qwikOptimizer = function(module) {
8367
8386
  res.setHeader("Access-Control-Allow-Origin", "*");
8368
8387
  res.setHeader("X-Powered-By", "Qwik Vite Dev Server");
8369
8388
  res.writeHead(status);
8370
- const result = await render2(renderOpts);
8389
+ const result = await render(renderOpts);
8371
8390
  Array.from(server.moduleGraph.fileToModulesMap.entries()).forEach((entry => {
8372
8391
  entry[1].forEach((v => {
8373
8392
  const {pathId: pathId, query: query} = parseId(v.url);