@qwik.dev/core 2.0.0-alpha.6 → 2.0.0-alpha.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/bindings/qwik.darwin-arm64.node +0 -0
  2. package/bindings/qwik.darwin-x64.node +0 -0
  3. package/bindings/qwik.linux-x64-gnu.node +0 -0
  4. package/bindings/qwik.win32-x64-msvc.node +0 -0
  5. package/bindings/qwik_wasm_bg.wasm +0 -0
  6. package/dist/build/package.json +1 -1
  7. package/dist/cli.cjs +65 -42
  8. package/dist/core-internal.d.ts +77 -76
  9. package/dist/core.cjs +1498 -1323
  10. package/dist/core.cjs.map +1 -1
  11. package/dist/core.min.mjs +1 -1
  12. package/dist/core.mjs +1496 -1323
  13. package/dist/core.mjs.map +1 -1
  14. package/dist/core.prod.cjs +884 -782
  15. package/dist/core.prod.mjs +1006 -867
  16. package/dist/insights/index.qwik.cjs +3652 -154
  17. package/dist/insights/index.qwik.mjs +3652 -154
  18. package/dist/loader/index.cjs +2 -2
  19. package/dist/loader/index.mjs +2 -2
  20. package/dist/loader/package.json +1 -1
  21. package/dist/optimizer.cjs +210 -5714
  22. package/dist/optimizer.mjs +191 -6037
  23. package/dist/prefetch/package.json +1 -1
  24. package/dist/qwikloader.debug.js +12 -15
  25. package/dist/qwikloader.js +2 -2
  26. package/dist/server.cjs +762 -7127
  27. package/dist/server.mjs +778 -7121
  28. package/dist/starters/adapters/fastify/src/plugins/fastify-qwik.ts +2 -0
  29. package/dist/starters/features/cypress/package.json +1 -1
  30. package/dist/starters/features/drizzle/drizzle/schema.ts +6 -18
  31. package/dist/starters/features/drizzle/drizzle.config.ts +5 -4
  32. package/dist/starters/features/drizzle/package.json +14 -11
  33. package/dist/starters/features/pandacss/package.json +1 -1
  34. package/dist/starters/features/partytown/package.json +1 -1
  35. package/dist/starters/features/postcss/package.json +1 -1
  36. package/dist/starters/features/prisma/package.json +1 -1
  37. package/dist/starters/features/react/package.json +1 -1
  38. package/dist/starters/features/storybook/package.json +1 -1
  39. package/dist/starters/features/styled-vanilla-extract/package.json +2 -1
  40. package/dist/starters/features/tailwind/package.json +15 -9
  41. package/dist/starters/features/tailwind/src/global.css +1 -7
  42. package/dist/starters/features/turso/package.json +1 -1
  43. package/dist/starters/features/vitest/package.json +1 -1
  44. package/dist/testing/index.cjs +1265 -1124
  45. package/dist/testing/index.mjs +1271 -1124
  46. package/dist/testing/package.json +1 -1
  47. package/handlers.mjs +9 -0
  48. package/package.json +6 -4
  49. package/public.d.ts +2 -0
  50. package/dist/starters/features/tailwind/.vscode/settings.json +0 -3
  51. package/dist/starters/features/tailwind/postcss.config.cjs +0 -6
  52. package/dist/starters/features/tailwind/tailwind.config.js +0 -8
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * @qwik.dev/core/testing 2.0.0-alpha.6-dev+d848ba5
3
+ * @qwik.dev/core/testing 2.0.0-alpha.7-dev+a26598a
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
@@ -22151,7 +22151,7 @@ var seal = (obj) => {
22151
22151
  };
22152
22152
 
22153
22153
  // packages/qwik/src/core/shared/qrl/qrl-class.ts
22154
- import { isDev as isDev7 } from "@qwik.dev/core/build";
22154
+ import { isDev as isDev8 } from "@qwik.dev/core/build";
22155
22155
 
22156
22156
  // packages/qwik/src/core/shared/utils/log.ts
22157
22157
  var STYLE = qDev ? `background: #564CE0; color: white; padding: 2px 3px; border-radius: 2px; font-size: 0.8em;` : "";
@@ -22231,10 +22231,10 @@ var codeToText = (code2, ...parts) => {
22231
22231
  const MAP = [
22232
22232
  "Error while serializing class or style attributes",
22233
22233
  // 0
22234
- "",
22235
- // 1 unused
22236
- "",
22237
- // 2 unused
22234
+ "Scheduler not found",
22235
+ // 1
22236
+ "track() received object, without prop to track",
22237
+ // 2
22238
22238
  "Only primitive and object literals can be serialized. {{0}}",
22239
22239
  // 3
22240
22240
  "",
@@ -22321,17 +22321,15 @@ See https://qwik.dev/docs/components/tasks/#use-method-rules`,
22321
22321
  "Materialize error: missing element: {{0}} {{1}} {{2}}",
22322
22322
  // 44
22323
22323
  "Cannot coerce a Signal, use `.value` instead",
22324
- // 46
22324
+ // 45
22325
22325
  "useComputedSignal$ QRL {{0}} {{1}} returned a Promise",
22326
- // 47
22326
+ // 46
22327
22327
  "ComputedSignal is read-only",
22328
- // 48
22328
+ // 47
22329
22329
  "WrappedSignal is read-only",
22330
- // 49
22331
- "SsrError: Promises not expected here.",
22332
- // 50
22330
+ // 48
22333
22331
  "Attribute value is unsafe for SSR"
22334
- // 51
22332
+ // 49
22335
22333
  ];
22336
22334
  let text = MAP[code2] ?? "";
22337
22335
  if (parts.length) {
@@ -22356,6 +22354,30 @@ var qError = (code2, errorMessageArgs = []) => {
22356
22354
  // packages/qwik/src/core/shared/platform/platform.ts
22357
22355
  import { isServer } from "@qwik.dev/core/build";
22358
22356
 
22357
+ // packages/qwik/src/core/shared/qrl/qrl-utils.ts
22358
+ import { isDev } from "@qwik.dev/core/build";
22359
+ var SYNC_QRL = "<sync>";
22360
+ var isSyncQrl = (value) => {
22361
+ return isQrl(value) && value.$symbol$ == SYNC_QRL;
22362
+ };
22363
+ var isQrl = (value) => {
22364
+ return typeof value === "function" && typeof value.getSymbol === "function";
22365
+ };
22366
+ function assertQrl(qrl2) {
22367
+ if (isDev) {
22368
+ if (!isQrl(qrl2)) {
22369
+ throw new Error("Not a QRL");
22370
+ }
22371
+ }
22372
+ }
22373
+ var getSymbolHash = (symbolName) => {
22374
+ const index = symbolName.lastIndexOf("_");
22375
+ if (index > -1) {
22376
+ return symbolName.slice(index + 1);
22377
+ }
22378
+ return symbolName;
22379
+ };
22380
+
22359
22381
  // packages/qwik/src/core/shared/types.ts
22360
22382
  var DEBUG_TYPE = "q:type";
22361
22383
  var START = "\x1B[34m";
@@ -22400,7 +22422,7 @@ var VirtualTypeName = {
22400
22422
 
22401
22423
  // packages/qwik/src/core/shared/utils/markers.ts
22402
22424
  var OnRenderProp = "q:renderFn";
22403
- var ComponentStylesPrefixContent = "\u2B50\uFE0F";
22425
+ var ComponentStylesPrefixContent = "\u26A1\uFE0F";
22404
22426
  var QSlot = "q:slot";
22405
22427
  var QSlotParent = ":";
22406
22428
  var QSlotRef = "q:sref";
@@ -22411,7 +22433,7 @@ var QStyleSSelector = "style[q\\:sstyle]";
22411
22433
  var QStylesAllSelector = QStyleSelector + "," + QStyleSSelector;
22412
22434
  var QScopedStyle = "q:sstyle";
22413
22435
  var QCtxAttr = "q:ctx";
22414
- var QSubscribers = "q:subs";
22436
+ var QBackRefs = "q:brefs";
22415
22437
  var QFuncsPrefix = "qFuncs_";
22416
22438
  var getQFuncs = (document2, hash3) => {
22417
22439
  return document2[QFuncsPrefix + hash3] || [];
@@ -22547,9 +22569,6 @@ var safeCall = (call, thenFn, rejectFn) => {
22547
22569
  var maybeThen = (valueOrPromise, thenFn) => {
22548
22570
  return isPromise(valueOrPromise) ? valueOrPromise.then(thenFn, shouldNotError) : thenFn(valueOrPromise);
22549
22571
  };
22550
- var maybeThenPassError = (valueOrPromise, thenFn) => {
22551
- return isPromise(valueOrPromise) ? valueOrPromise.then(thenFn) : thenFn(valueOrPromise);
22552
- };
22553
22572
  var shouldNotError = (reason) => {
22554
22573
  throwErrorAndStop(reason);
22555
22574
  };
@@ -22595,7 +22614,7 @@ var isFunction = (v) => {
22595
22614
  };
22596
22615
 
22597
22616
  // packages/qwik/src/build/index.dev.ts
22598
- var isDev = true;
22617
+ var isDev2 = true;
22599
22618
 
22600
22619
  // packages/qwik/src/core/use/use-locale.ts
22601
22620
  var _locale = void 0;
@@ -22604,7 +22623,7 @@ function setLocale(locale) {
22604
22623
  }
22605
22624
 
22606
22625
  // packages/qwik/src/core/client/vnode.ts
22607
- import { isDev as isDev6 } from "@qwik.dev/core/build";
22626
+ import { isDev as isDev7 } from "@qwik.dev/core/build";
22608
22627
 
22609
22628
  // packages/qwik/src/server/utils.ts
22610
22629
  function createTimer() {
@@ -22637,7 +22656,7 @@ var versions = {
22637
22656
  };
22638
22657
 
22639
22658
  // packages/qwik/src/server/prefetch-strategy.ts
22640
- import { isDev as isDev2 } from "@qwik.dev/core/build";
22659
+ import { isDev as isDev3 } from "@qwik.dev/core/build";
22641
22660
  function getPrefetchResources(qrls, opts, resolvedManifest) {
22642
22661
  if (!resolvedManifest) {
22643
22662
  return [];
@@ -22675,7 +22694,7 @@ function getAutoPrefetch(qrls, resolvedManifest, buildBase) {
22675
22694
  return prefetchResources;
22676
22695
  }
22677
22696
  function addBundle(manifest, urls, prefetchResources, buildBase, bundleFileName) {
22678
- const url = isDev2 ? bundleFileName : buildBase + bundleFileName;
22697
+ const url = isDev3 ? bundleFileName : buildBase + bundleFileName;
22679
22698
  let prefetchResource = urls.get(url);
22680
22699
  if (!prefetchResource) {
22681
22700
  prefetchResource = {
@@ -22694,7 +22713,7 @@ function addBundle(manifest, urls, prefetchResources, buildBase, bundleFileName)
22694
22713
  }
22695
22714
  prefetchResources.push(prefetchResource);
22696
22715
  }
22697
- var isQrl = (value) => {
22716
+ var isQrl2 = (value) => {
22698
22717
  return typeof value === "function" && typeof value.getSymbol === "function";
22699
22718
  };
22700
22719
 
@@ -22706,12 +22725,9 @@ Object.freeze(EMPTY_OBJ);
22706
22725
 
22707
22726
  // packages/qwik/src/core/shared/qrl/qrl.ts
22708
22727
  var inlinedQrl = (symbol, symbolName, lexicalScopeCapture = EMPTY_ARRAY) => {
22709
- return createQRL(null, symbolName, symbol, null, null, lexicalScopeCapture, null);
22728
+ return createQRL(null, symbolName, symbol, null, null, lexicalScopeCapture);
22710
22729
  };
22711
22730
 
22712
- // packages/qwik/src/core/ssr/ssr-render-jsx.ts
22713
- import { isDev as isDev5 } from "@qwik.dev/core/build";
22714
-
22715
22731
  // packages/qwik/src/core/shared/jsx/slot.public.ts
22716
22732
  var Slot = (props) => {
22717
22733
  return _jsxSorted(Virtual, null, { [QSlotS]: "" }, props.children, 0, props.name ?? "");
@@ -22798,6 +22814,49 @@ function isPreventDefault(key) {
22798
22814
  return key.startsWith("preventdefault:");
22799
22815
  }
22800
22816
 
22817
+ // packages/qwik/src/core/shared/utils/jsx-filename.ts
22818
+ function getFileLocationFromJsx(jsxDev) {
22819
+ if (!jsxDev) {
22820
+ return null;
22821
+ }
22822
+ const sanitizedFileName = jsxDev.fileName?.replace(/\\/g, "/");
22823
+ if (sanitizedFileName) {
22824
+ return `${sanitizedFileName}:${jsxDev.lineNumber}:${jsxDev.columnNumber}`;
22825
+ }
22826
+ return null;
22827
+ }
22828
+
22829
+ // packages/qwik/src/core/shared/utils/scoped-styles.ts
22830
+ var styleContent = (styleId) => {
22831
+ return ComponentStylesPrefixContent + styleId;
22832
+ };
22833
+ function hasClassAttr(props) {
22834
+ for (const key in props) {
22835
+ if (Object.prototype.hasOwnProperty.call(props, key) && isClassAttr(key)) {
22836
+ return true;
22837
+ }
22838
+ }
22839
+ return false;
22840
+ }
22841
+ function isClassAttr(key) {
22842
+ return key === "class" || key === "className";
22843
+ }
22844
+ function convertScopedStyleIdsToArray(scopedStyleIds) {
22845
+ return scopedStyleIds?.split(" ") ?? null;
22846
+ }
22847
+ function convertStyleIdsToString(scopedStyleIds) {
22848
+ return Array.from(scopedStyleIds).join(" ");
22849
+ }
22850
+ var addComponentStylePrefix = (styleId) => {
22851
+ if (styleId) {
22852
+ let idx = 0;
22853
+ do {
22854
+ styleId = styleId.substring(0, idx) + styleContent(styleId.substring(idx));
22855
+ } while ((idx = styleId.indexOf(" ", idx) + 1) !== 0);
22856
+ }
22857
+ return styleId || null;
22858
+ };
22859
+
22801
22860
  // packages/qwik/src/core/shared/utils/unitless_number.ts
22802
22861
  var unitlessNumbers = /* @__PURE__ */ new Set([
22803
22862
  "animationIterationCount",
@@ -22935,37 +22994,6 @@ var setValueForStyle = (styleName, value) => {
22935
22994
  function isAriaAttribute(prop) {
22936
22995
  return prop.startsWith("aria-");
22937
22996
  }
22938
- var styleContent = (styleId) => {
22939
- return ComponentStylesPrefixContent + styleId;
22940
- };
22941
-
22942
- // packages/qwik/src/core/shared/utils/scoped-styles.ts
22943
- function hasClassAttr(props) {
22944
- for (const key in props) {
22945
- if (Object.prototype.hasOwnProperty.call(props, key) && isClassAttr(key)) {
22946
- return true;
22947
- }
22948
- }
22949
- return false;
22950
- }
22951
- function isClassAttr(key) {
22952
- return key === "class" || key === "className";
22953
- }
22954
- function convertScopedStyleIdsToArray(scopedStyleIds) {
22955
- return scopedStyleIds?.split(" ") ?? null;
22956
- }
22957
- function convertStyleIdsToString(scopedStyleIds) {
22958
- return Array.from(scopedStyleIds).join(" ");
22959
- }
22960
- var addComponentStylePrefix = (styleId) => {
22961
- if (styleId) {
22962
- let idx = 0;
22963
- do {
22964
- styleId = styleId.substring(0, idx) + styleContent(styleId.substring(idx));
22965
- } while ((idx = styleId.indexOf(" ", idx) + 1) !== 0);
22966
- }
22967
- return styleId || null;
22968
- };
22969
22997
 
22970
22998
  // packages/qwik/src/core/signal/store.ts
22971
22999
  var DEBUG = false;
@@ -23101,8 +23129,12 @@ var StoreHandler = class {
23101
23129
  return Reflect.ownKeys(target);
23102
23130
  }
23103
23131
  getOwnPropertyDescriptor(target, prop) {
23132
+ const descriptor = Reflect.getOwnPropertyDescriptor(target, prop);
23104
23133
  if (Array.isArray(target) || typeof prop === "symbol") {
23105
- return Object.getOwnPropertyDescriptor(target, prop);
23134
+ return descriptor;
23135
+ }
23136
+ if (descriptor && !descriptor.configurable) {
23137
+ return descriptor;
23106
23138
  }
23107
23139
  return {
23108
23140
  enumerable: true,
@@ -23110,17 +23142,17 @@ var StoreHandler = class {
23110
23142
  };
23111
23143
  }
23112
23144
  };
23113
- function addEffect(target, prop, store, effectSubscriber) {
23114
- const effectsMap = store.$effects$ || (store.$effects$ = {});
23115
- const effects = Object.prototype.hasOwnProperty.call(effectsMap, prop) && effectsMap[prop] || (effectsMap[prop] = []);
23116
- ensureContainsEffect(effects, effectSubscriber);
23117
- ensureContains(effectSubscriber, target);
23118
- ensureEffectContainsSubscriber(
23119
- effectSubscriber[0 /* EFFECT */],
23120
- target,
23121
- store.$container$
23122
- );
23123
- DEBUG && log("sub", pad("\n" + store.$effects$.toString(), " "));
23145
+ function addEffect(target, prop, store, effectSubscription) {
23146
+ const effectsMap = store.$effects$ || (store.$effects$ = /* @__PURE__ */ new Map());
23147
+ let effects = effectsMap.get(prop);
23148
+ if (!effects) {
23149
+ effects = /* @__PURE__ */ new Set();
23150
+ effectsMap.set(prop, effects);
23151
+ }
23152
+ ensureContainsSubscription(effects, effectSubscription);
23153
+ ensureContainsBackRef(effectSubscription, target);
23154
+ addQrlToSerializationCtx(effectSubscription, store.$container$);
23155
+ DEBUG && log("sub", pad("\n" + store.$effects$?.entries.toString(), " "));
23124
23156
  }
23125
23157
  function setNewValueAndTriggerEffects(prop, value, target, currentStore) {
23126
23158
  target[prop] = value;
@@ -23131,14 +23163,90 @@ function setNewValueAndTriggerEffects(prop, value, target, currentStore) {
23131
23163
  );
23132
23164
  }
23133
23165
  function getEffects(target, prop, storeEffects) {
23134
- let effectsToTrigger = storeEffects ? Array.isArray(target) ? Object.values(storeEffects).flatMap((effects) => effects) : storeEffects[prop] : null;
23135
- const storeArrayValue = storeEffects?.[STORE_ARRAY_PROP];
23166
+ let effectsToTrigger;
23167
+ if (storeEffects) {
23168
+ if (Array.isArray(target)) {
23169
+ for (const effects of storeEffects.values()) {
23170
+ effectsToTrigger || (effectsToTrigger = /* @__PURE__ */ new Set());
23171
+ for (const effect of effects) {
23172
+ effectsToTrigger.add(effect);
23173
+ }
23174
+ }
23175
+ } else {
23176
+ effectsToTrigger = storeEffects.get(prop);
23177
+ }
23178
+ }
23179
+ const storeArrayValue = storeEffects?.get(STORE_ARRAY_PROP);
23136
23180
  if (storeArrayValue) {
23137
- effectsToTrigger || (effectsToTrigger = []);
23138
- effectsToTrigger.push(...storeArrayValue);
23181
+ effectsToTrigger || (effectsToTrigger = /* @__PURE__ */ new Set());
23182
+ for (const effect of storeArrayValue) {
23183
+ effectsToTrigger.add(effect);
23184
+ }
23185
+ }
23186
+ return effectsToTrigger || null;
23187
+ }
23188
+
23189
+ // packages/qwik/src/core/signal/flags.ts
23190
+ var NEEDS_COMPUTATION = Symbol("invalid");
23191
+ var _EFFECT_BACK_REF = Symbol("backRef");
23192
+
23193
+ // packages/qwik/src/core/signal/signal-cleanup.ts
23194
+ var _a;
23195
+ _a = _EFFECT_BACK_REF;
23196
+ var BackRef = class {
23197
+ constructor() {
23198
+ __publicField(this, _a, null);
23199
+ }
23200
+ };
23201
+ function clearAllEffects(container, consumer) {
23202
+ if (vnode_isVNode(consumer) && vnode_isElementVNode(consumer)) {
23203
+ ensureMaterialized(consumer);
23204
+ }
23205
+ const effects = consumer[_EFFECT_BACK_REF];
23206
+ if (!effects) {
23207
+ return;
23208
+ }
23209
+ for (const [, effect] of effects) {
23210
+ const backRefs = effect[2 /* BACK_REF */];
23211
+ if (!backRefs) {
23212
+ return;
23213
+ }
23214
+ for (const producer of backRefs) {
23215
+ if (producer instanceof Signal) {
23216
+ clearSignal(container, producer, effect);
23217
+ } else if (container.$storeProxyMap$.has(producer)) {
23218
+ const target = container.$storeProxyMap$.get(producer);
23219
+ const storeHandler = getStoreHandler(target);
23220
+ clearStore(storeHandler, effect);
23221
+ }
23222
+ }
23223
+ }
23224
+ }
23225
+ function clearSignal(container, producer, effect) {
23226
+ const effects = producer.$effects$;
23227
+ if (effects) {
23228
+ effects.delete(effect);
23229
+ }
23230
+ if (producer instanceof WrappedSignal) {
23231
+ producer.$hostElement$ = null;
23232
+ clearAllEffects(container, producer);
23139
23233
  }
23140
- return effectsToTrigger;
23141
23234
  }
23235
+ function clearStore(producer, effect) {
23236
+ const effects = producer?.$effects$;
23237
+ if (effects) {
23238
+ for (const propEffects of effects.values()) {
23239
+ propEffects.delete(effect);
23240
+ }
23241
+ }
23242
+ }
23243
+
23244
+ // packages/qwik/src/core/shared/qrl/implicit_dollar.ts
23245
+ var implicit$FirstArg = (fn) => {
23246
+ return function(first, ...rest) {
23247
+ return fn.call(null, dollar(first), ...rest);
23248
+ };
23249
+ };
23142
23250
 
23143
23251
  // packages/qwik/src/core/use/use-sequential-scope.ts
23144
23252
  var useSequentialScope = () => {
@@ -23172,173 +23280,41 @@ var useSequentialScope = () => {
23172
23280
  };
23173
23281
  };
23174
23282
 
23175
- // packages/qwik/src/core/signal/signal-subscriber.ts
23176
- var Subscriber = class {
23177
- constructor() {
23178
- __publicField(this, "$effectDependencies$", null);
23179
- }
23180
- };
23181
- function isSubscriber(value) {
23182
- return value instanceof Subscriber || value instanceof WrappedSignal;
23183
- }
23184
- function clearVNodeEffectDependencies(container, value) {
23185
- if (vnode_isElementVNode(value)) {
23186
- ensureMaterialized(value);
23187
- }
23188
- const effects = vnode_getProp(value, QSubscribers, container.$getObjectById$);
23189
- if (!effects) {
23190
- return;
23191
- }
23192
- for (let i = effects.length - 1; i >= 0; i--) {
23193
- const subscriber = effects[i];
23194
- clearEffects(subscriber, value, effects, i, container);
23195
- }
23196
- if (effects.length === 0) {
23197
- vnode_setProp(value, QSubscribers, null);
23198
- }
23199
- }
23200
- function clearSubscriberEffectDependencies(container, value) {
23201
- if (value.$effectDependencies$) {
23202
- for (let i = value.$effectDependencies$.length - 1; i >= 0; i--) {
23203
- const subscriber = value.$effectDependencies$[i];
23204
- clearEffects(subscriber, value, value.$effectDependencies$, i, container);
23205
- }
23206
- if (value.$effectDependencies$.length === 0) {
23207
- value.$effectDependencies$ = null;
23208
- }
23209
- }
23210
- }
23211
- function clearEffects(subscriber, value, effectArray, indexToRemove, container) {
23212
- let subscriptionRemoved = false;
23213
- const seenSet = /* @__PURE__ */ new Set();
23214
- if (subscriber instanceof WrappedSignal) {
23215
- subscriptionRemoved = clearSignalEffects(subscriber, value, seenSet);
23216
- } else if (container.$storeProxyMap$.has(subscriber)) {
23217
- const store = container.$storeProxyMap$.get(subscriber);
23218
- const handler = getStoreHandler(store);
23219
- subscriptionRemoved = clearStoreEffects(handler, value);
23220
- }
23221
- if (subscriptionRemoved) {
23222
- effectArray.splice(indexToRemove, 1);
23223
- }
23224
- }
23225
- function clearSignalEffects(subscriber, value, seenSet) {
23226
- const effectSubscriptions = subscriber.$effects$;
23227
- let subscriptionRemoved = false;
23228
- if (effectSubscriptions) {
23229
- for (let i = effectSubscriptions.length - 1; i >= 0; i--) {
23230
- const effect = effectSubscriptions[i];
23231
- if (effect[0 /* EFFECT */] === value) {
23232
- effectSubscriptions.splice(i, 1);
23233
- subscriptionRemoved = true;
23234
- }
23235
- }
23236
- }
23237
- if (subscriber instanceof WrappedSignal) {
23238
- const hostElement = subscriber.$hostElement$;
23239
- if (hostElement && hostElement === value) {
23240
- subscriber.$hostElement$ = null;
23241
- }
23242
- const args = subscriber.$args$;
23243
- if (args) {
23244
- clearArgsEffects(args, subscriber, seenSet);
23283
+ // packages/qwik/src/core/signal/subscriber.ts
23284
+ import { isServer as isServer3 } from "@qwik.dev/core/build";
23285
+ function getSubscriber(effect, prop, data) {
23286
+ if (!effect[_EFFECT_BACK_REF]) {
23287
+ if (isServer3 && isSsrNode(effect)) {
23288
+ effect.setProp(QBackRefs, /* @__PURE__ */ new Map());
23289
+ } else {
23290
+ effect[_EFFECT_BACK_REF] = /* @__PURE__ */ new Map();
23245
23291
  }
23246
23292
  }
23247
- return subscriptionRemoved;
23248
- }
23249
- function clearStoreEffects(storeHandler, value) {
23250
- const effectSubscriptions = storeHandler.$effects$;
23251
- if (!effectSubscriptions) {
23252
- return false;
23253
- }
23254
- let subscriptionRemoved = false;
23255
- for (const key in effectSubscriptions) {
23256
- const effects = effectSubscriptions[key];
23257
- for (let i = effects.length - 1; i >= 0; i--) {
23258
- const effect = effects[i];
23259
- if (effect[0 /* EFFECT */] === value) {
23260
- effects.splice(i, 1);
23261
- subscriptionRemoved = true;
23262
- }
23263
- }
23264
- if (effects.length === 0) {
23265
- delete effectSubscriptions[key];
23266
- }
23293
+ const subMap = effect[_EFFECT_BACK_REF];
23294
+ let sub = subMap.get(prop);
23295
+ if (!sub) {
23296
+ sub = [effect, prop];
23297
+ subMap.set(prop, sub);
23267
23298
  }
23268
- return subscriptionRemoved;
23269
- }
23270
- function clearArgsEffects(args, subscriber, seenSet) {
23271
- for (let i = args.length - 1; i >= 0; i--) {
23272
- const arg = args[i];
23273
- clearArgEffect(arg, subscriber, seenSet);
23299
+ if (data) {
23300
+ sub[3 /* DATA */] = data;
23274
23301
  }
23302
+ return sub;
23275
23303
  }
23276
- function clearArgEffect(arg, subscriber, seenSet) {
23277
- if (seenSet.has(arg)) {
23278
- return;
23279
- }
23280
- seenSet.add(arg);
23281
- if (isSignal(arg)) {
23282
- clearSignalEffects(arg, subscriber, seenSet);
23283
- } else if (typeof arg === "object" && arg !== null) {
23284
- if (isStore(arg)) {
23285
- clearStoreEffects(getStoreHandler(arg), subscriber);
23286
- } else if (isPropsProxy(arg)) {
23287
- const constProps = arg[_CONST_PROPS];
23288
- const varProps = arg[_VAR_PROPS];
23289
- if (constProps) {
23290
- for (const key in constProps) {
23291
- clearArgEffect(constProps[key], subscriber, seenSet);
23292
- }
23293
- }
23294
- for (const key in varProps) {
23295
- clearArgEffect(varProps[key], subscriber, seenSet);
23296
- }
23297
- } else {
23298
- for (const key in arg) {
23299
- clearArgEffect(arg[key], subscriber, seenSet);
23300
- }
23301
- }
23302
- } else if (Array.isArray(arg)) {
23303
- clearArgsEffects(arg, subscriber, seenSet);
23304
- } else {
23305
- }
23304
+ function isSsrNode(value) {
23305
+ return "__brand__" in value && "currentComponentNode" in value;
23306
23306
  }
23307
23307
 
23308
- // packages/qwik/src/core/use/use-resource.ts
23309
- var _createResourceReturn = (opts) => {
23310
- const resource = {
23311
- __brand: "resource",
23312
- value: void 0,
23313
- loading: isServerPlatform() ? false : true,
23314
- _resolved: void 0,
23315
- _error: void 0,
23316
- _state: "pending",
23317
- _timeout: opts?.timeout ?? -1,
23318
- _cache: 0
23319
- };
23320
- return resource;
23321
- };
23322
- var createResourceReturn = (container, opts, initialPromise) => {
23323
- const result = _createResourceReturn(opts);
23324
- result.value = initialPromise;
23325
- return createStore(container, result, 1 /* RECURSIVE */);
23326
- };
23327
- var runResource = (task, container, host) => {
23308
+ // packages/qwik/src/core/use/use-task.ts
23309
+ var runTask = (task, container, host) => {
23328
23310
  task.$flags$ &= ~8 /* DIRTY */;
23329
23311
  cleanupTask(task);
23330
- const iCtx = newInvokeContext(container.$locale$, host, void 0, ResourceEvent);
23312
+ const iCtx = newInvokeContext(container.$locale$, host, void 0, TaskEvent);
23331
23313
  iCtx.$container$ = container;
23332
- const taskFn = task.$qrl$.getFn(iCtx, () => clearSubscriberEffectDependencies(container, task));
23333
- const resource = task.$state$;
23334
- assertDefined(
23335
- resource,
23336
- 'useResource: when running a resource, "task.resource" must be a defined.',
23337
- task
23338
- );
23314
+ const taskFn = task.$qrl$.getFn(iCtx, () => clearAllEffects(container, task));
23339
23315
  const track = (obj, prop) => {
23340
23316
  const ctx = newInvokeContext();
23341
- ctx.$effectSubscriber$ = [task, ":" /* COMPONENT */];
23317
+ ctx.$effectSubscriber$ = getSubscriber(task, ":" /* COMPONENT */);
23342
23318
  ctx.$container$ = container;
23343
23319
  return invoke(ctx, () => {
23344
23320
  if (isFunction(obj)) {
@@ -23349,127 +23325,143 @@ var runResource = (task, container, host) => {
23349
23325
  } else if (isSignal(obj)) {
23350
23326
  return obj.value;
23351
23327
  } else {
23352
- return obj;
23328
+ throw qError(2 /* trackObjectWithoutProp */);
23353
23329
  }
23354
23330
  });
23355
23331
  };
23356
23332
  const handleError = (reason) => container.handleError(reason, host);
23357
- const cleanups = [];
23358
- task.$destroy$ = noSerialize(() => {
23359
- cleanups.forEach((fn) => {
23360
- try {
23361
- fn();
23362
- } catch (err) {
23363
- handleError(err);
23333
+ let cleanupFns = null;
23334
+ const cleanup2 = (fn) => {
23335
+ if (typeof fn == "function") {
23336
+ if (!cleanupFns) {
23337
+ cleanupFns = [];
23338
+ task.$destroy$ = noSerialize(() => {
23339
+ task.$destroy$ = null;
23340
+ cleanupFns.forEach((fn2) => {
23341
+ try {
23342
+ fn2();
23343
+ } catch (err) {
23344
+ handleError(err);
23345
+ }
23346
+ });
23347
+ });
23364
23348
  }
23365
- });
23366
- done = true;
23367
- });
23368
- const resourceTarget = unwrapStore(resource);
23369
- const opts = {
23370
- track,
23371
- cleanup(fn) {
23372
- if (typeof fn === "function") {
23373
- cleanups.push(fn);
23374
- }
23375
- },
23376
- cache(policy) {
23377
- let milliseconds = 0;
23378
- if (policy === "immutable") {
23379
- milliseconds = Infinity;
23380
- } else {
23381
- milliseconds = policy;
23382
- }
23383
- resource._cache = milliseconds;
23384
- },
23385
- previous: resourceTarget._resolved
23386
- };
23387
- let resolve;
23388
- let reject;
23389
- let done = false;
23390
- const setState = (resolved, value) => {
23391
- if (!done) {
23392
- done = true;
23393
- if (resolved) {
23394
- done = true;
23395
- resource.loading = false;
23396
- resource._state = "resolved";
23397
- resource._resolved = value;
23398
- resource._error = void 0;
23399
- resolve(value);
23400
- } else {
23401
- done = true;
23402
- resource.loading = false;
23403
- resource._state = "rejected";
23404
- resource._error = value;
23405
- reject(value);
23406
- }
23407
- return true;
23349
+ cleanupFns.push(fn);
23408
23350
  }
23409
- return false;
23410
23351
  };
23411
- cleanups.push(() => {
23412
- if (untrack(() => resource.loading) === true) {
23413
- const value = untrack(() => resource._resolved);
23414
- setState(true, value);
23415
- }
23416
- });
23417
- invoke(iCtx, () => {
23418
- resource._state = "pending";
23419
- resource.loading = !isServerPlatform();
23420
- const promise2 = resource.value = new Promise((r, re) => {
23421
- resolve = r;
23422
- reject = re;
23423
- });
23424
- promise2.catch(ignoreErrorToPreventNodeFromCrashing);
23425
- });
23426
- const promise = safeCall(
23427
- () => Promise.resolve(taskFn(opts)),
23428
- (value) => {
23429
- setState(true, value);
23430
- },
23352
+ const taskApi = { track, cleanup: cleanup2 };
23353
+ const result = safeCall(
23354
+ () => taskFn(taskApi),
23355
+ cleanup2,
23431
23356
  (err) => {
23432
23357
  if (isPromise(err)) {
23433
- return err.then(() => runResource(task, container, host));
23358
+ return err.then(() => runTask(task, container, host));
23434
23359
  } else {
23435
- setState(false, err);
23360
+ throw err;
23436
23361
  }
23437
23362
  }
23438
23363
  );
23439
- const timeout = resourceTarget._timeout;
23440
- if (timeout > 0) {
23441
- return Promise.race([
23442
- promise,
23443
- delay(timeout).then(() => {
23444
- if (setState(false, new Error("timeout"))) {
23445
- cleanupTask(task);
23446
- }
23447
- })
23448
- ]);
23364
+ return result;
23365
+ };
23366
+ var cleanupTask = (task) => {
23367
+ const destroy = task.$destroy$;
23368
+ if (destroy) {
23369
+ task.$destroy$ = null;
23370
+ try {
23371
+ destroy();
23372
+ } catch (err) {
23373
+ logError(err);
23374
+ }
23449
23375
  }
23450
- return promise;
23451
23376
  };
23452
- var ignoreErrorToPreventNodeFromCrashing = (err) => {
23377
+ var Task = class extends BackRef {
23378
+ constructor($flags$, $index$, $el$, $qrl$, $state$, $destroy$) {
23379
+ super();
23380
+ this.$flags$ = $flags$;
23381
+ this.$index$ = $index$;
23382
+ this.$el$ = $el$;
23383
+ this.$qrl$ = $qrl$;
23384
+ this.$state$ = $state$;
23385
+ this.$destroy$ = $destroy$;
23386
+ }
23387
+ };
23388
+ var isTask = (value) => {
23389
+ return value instanceof Task;
23453
23390
  };
23454
23391
 
23455
23392
  // packages/qwik/src/core/client/vnode-diff.ts
23456
- import { isDev as isDev4 } from "@qwik.dev/core/build";
23393
+ import { isDev as isDev6 } from "@qwik.dev/core/build";
23394
+
23395
+ // packages/qwik/src/core/client/util-mapArray.ts
23396
+ var mapApp_findIndx = (elementVNode, key, start) => {
23397
+ assertTrue(start % 2 === 0, "Expecting even number.");
23398
+ let bottom = start >> 1;
23399
+ let top = elementVNode.length - 2 >> 1;
23400
+ while (bottom <= top) {
23401
+ const mid = bottom + (top - bottom >> 1);
23402
+ const midKey = elementVNode[mid << 1];
23403
+ if (midKey === key) {
23404
+ return mid << 1;
23405
+ }
23406
+ if (midKey < key) {
23407
+ bottom = mid + 1;
23408
+ } else {
23409
+ top = mid - 1;
23410
+ }
23411
+ }
23412
+ return bottom << 1 ^ -1;
23413
+ };
23414
+ var mapArray_set = (elementVNode, key, value, start) => {
23415
+ const indx = mapApp_findIndx(elementVNode, key, start);
23416
+ if (indx >= 0) {
23417
+ if (value == null) {
23418
+ elementVNode.splice(indx, 2);
23419
+ } else {
23420
+ elementVNode[indx + 1] = value;
23421
+ }
23422
+ } else if (value != null) {
23423
+ elementVNode.splice(indx ^ -1, 0, key, value);
23424
+ }
23425
+ };
23426
+ var mapApp_remove = (elementVNode, key, start) => {
23427
+ const indx = mapApp_findIndx(elementVNode, key, start);
23428
+ let value = null;
23429
+ if (indx >= 0) {
23430
+ value = elementVNode[indx + 1];
23431
+ elementVNode.splice(indx, 2);
23432
+ return value;
23433
+ }
23434
+ return value;
23435
+ };
23436
+ var mapArray_get = (elementVNode, key, start) => {
23437
+ const indx = mapApp_findIndx(elementVNode, key, start);
23438
+ if (indx >= 0) {
23439
+ return elementVNode[indx + 1];
23440
+ } else {
23441
+ return null;
23442
+ }
23443
+ };
23457
23444
 
23458
23445
  // packages/qwik/src/core/client/vnode-namespace.ts
23459
- var isForeignObjectElement = (elementName) => elementName.toLowerCase() === "foreignobject";
23446
+ import { isDev as isDev4 } from "@qwik.dev/core/build";
23447
+ var isForeignObjectElement = (elementName) => {
23448
+ return isDev4 ? elementName.toLowerCase() === "foreignobject" : elementName === "foreignObject";
23449
+ };
23460
23450
  var isSvgElement = (elementName) => elementName === "svg" || isForeignObjectElement(elementName);
23461
23451
  var isMathElement = (elementName) => elementName === "math";
23462
23452
  var vnode_isDefaultNamespace = (vnode) => {
23463
23453
  const flags = vnode[0 /* flags */];
23464
23454
  return (flags & 192 /* NAMESPACE_MASK */) === 0;
23465
23455
  };
23466
- var vnode_getElementNamespaceFlags = (elementName) => {
23467
- if (isSvgElement(elementName)) {
23468
- return 64 /* NS_svg */;
23469
- } else if (isMathElement(elementName)) {
23470
- return 128 /* NS_math */;
23471
- } else {
23472
- return 0 /* NS_html */;
23456
+ var vnode_getElementNamespaceFlags = (element) => {
23457
+ const namespace = fastNamespaceURI(element);
23458
+ switch (namespace) {
23459
+ case SVG_NS:
23460
+ return 64 /* NS_svg */;
23461
+ case MATH_NS:
23462
+ return 128 /* NS_math */;
23463
+ default:
23464
+ return 0 /* NS_html */;
23473
23465
  }
23474
23466
  };
23475
23467
  function vnode_getDomChildrenWithCorrectNamespacesToInsert(journal, domParentVNode, newChild) {
@@ -23625,21 +23617,28 @@ function getNewElementNamespaceData(domParentVNode, tagOrVNode) {
23625
23617
  }
23626
23618
 
23627
23619
  // packages/qwik/src/core/shared/component-execution.ts
23628
- import { isDev as isDev3 } from "@qwik.dev/core/build";
23620
+ import { isDev as isDev5 } from "@qwik.dev/core/build";
23629
23621
  var executeComponent = (container, renderHost, subscriptionHost, componentQRL, props) => {
23630
- const iCtx = newInvokeContext(container.$locale$, subscriptionHost, void 0, RenderEvent);
23631
- iCtx.$effectSubscriber$ = [subscriptionHost, ":" /* COMPONENT */];
23632
- iCtx.$container$ = container;
23622
+ const iCtx = newInvokeContext(
23623
+ container.$locale$,
23624
+ subscriptionHost || void 0,
23625
+ void 0,
23626
+ RenderEvent
23627
+ );
23628
+ if (subscriptionHost) {
23629
+ iCtx.$effectSubscriber$ = getSubscriber(subscriptionHost, ":" /* COMPONENT */);
23630
+ iCtx.$container$ = container;
23631
+ }
23633
23632
  let componentFn;
23634
23633
  container.ensureProjectionResolved(renderHost);
23635
23634
  let isInlineComponent = false;
23636
23635
  if (componentQRL === null) {
23637
- componentQRL = componentQRL || container.getHostProp(renderHost, OnRenderProp);
23636
+ componentQRL = container.getHostProp(renderHost, OnRenderProp);
23638
23637
  assertDefined(componentQRL, "No Component found at this location");
23639
23638
  }
23640
- if (isQrl2(componentQRL)) {
23639
+ if (isQrl(componentQRL)) {
23641
23640
  props = props || container.getHostProp(renderHost, ELEMENT_PROPS) || EMPTY_OBJ;
23642
- if (props && props.children) {
23641
+ if (props.children) {
23643
23642
  delete props.children;
23644
23643
  }
23645
23644
  componentFn = componentQRL.getFn(iCtx);
@@ -23656,19 +23655,17 @@ var executeComponent = (container, renderHost, subscriptionHost, componentQRL, p
23656
23655
  if (!isInlineComponent) {
23657
23656
  container.setHostProp(renderHost, ELEMENT_SEQ_IDX, null);
23658
23657
  container.setHostProp(renderHost, USE_ON_LOCAL_SEQ_IDX, null);
23659
- if (container.getHostProp(renderHost, ELEMENT_PROPS) !== props) {
23660
- container.setHostProp(renderHost, ELEMENT_PROPS, props);
23661
- }
23658
+ container.setHostProp(renderHost, ELEMENT_PROPS, props);
23662
23659
  }
23663
23660
  if (vnode_isVNode(renderHost)) {
23664
- clearVNodeEffectDependencies(container, renderHost);
23661
+ clearAllEffects(container, renderHost);
23665
23662
  }
23666
23663
  return componentFn(props);
23667
23664
  },
23668
23665
  (jsx4) => {
23669
23666
  const useOnEvents = container.getHostProp(renderHost, USE_ON_LOCAL);
23670
23667
  if (useOnEvents) {
23671
- return maybeThen(addUseOnEvents(jsx4, useOnEvents), () => jsx4);
23668
+ return addUseOnEvents(jsx4, useOnEvents);
23672
23669
  }
23673
23670
  return jsx4;
23674
23671
  },
@@ -23686,6 +23683,7 @@ var executeComponent = (container, renderHost, subscriptionHost, componentQRL, p
23686
23683
  };
23687
23684
  function addUseOnEvents(jsx4, useOnEvents) {
23688
23685
  const jsxElement = findFirstStringJSX(jsx4);
23686
+ let jsxResult = jsx4;
23689
23687
  return maybeThen(jsxElement, (jsxElement2) => {
23690
23688
  let isInvisibleComponent = false;
23691
23689
  if (!jsxElement2) {
@@ -23695,16 +23693,18 @@ function addUseOnEvents(jsx4, useOnEvents) {
23695
23693
  if (Object.prototype.hasOwnProperty.call(useOnEvents, key)) {
23696
23694
  if (isInvisibleComponent) {
23697
23695
  if (key === "onQvisible$") {
23698
- jsxElement2 = addScriptNodeForInvisibleComponents(jsx4);
23699
- if (jsxElement2) {
23700
- addUseOnEvent(jsxElement2, "document:onQinit$", useOnEvents[key]);
23696
+ const [jsxElement3, jsx5] = addScriptNodeForInvisibleComponents(jsxResult);
23697
+ jsxResult = jsx5;
23698
+ if (jsxElement3) {
23699
+ addUseOnEvent(jsxElement3, "document:onQinit$", useOnEvents[key]);
23701
23700
  }
23702
23701
  } else if (key.startsWith("document:") || key.startsWith("window:")) {
23703
- jsxElement2 = addScriptNodeForInvisibleComponents(jsx4);
23704
- if (jsxElement2) {
23705
- addUseOnEvent(jsxElement2, key, useOnEvents[key]);
23702
+ const [jsxElement3, jsx5] = addScriptNodeForInvisibleComponents(jsxResult);
23703
+ jsxResult = jsx5;
23704
+ if (jsxElement3) {
23705
+ addUseOnEvent(jsxElement3, key, useOnEvents[key]);
23706
23706
  }
23707
- } else if (isDev3) {
23707
+ } else if (isDev5) {
23708
23708
  logWarn(
23709
23709
  'You are trying to add an event "' + key + '" using `useOn` hook, but a node to which you can add an event is not found. Please make sure that the component has a valid element node. '
23710
23710
  );
@@ -23714,7 +23714,7 @@ function addUseOnEvents(jsx4, useOnEvents) {
23714
23714
  }
23715
23715
  }
23716
23716
  }
23717
- return jsxElement2;
23717
+ return jsxResult;
23718
23718
  });
23719
23719
  }
23720
23720
  function addUseOnEvent(jsxElement, key, value) {
@@ -23765,6 +23765,9 @@ function addScriptNodeForInvisibleComponents(jsx4) {
23765
23765
  null,
23766
23766
  3
23767
23767
  );
23768
+ if (jsx4.type === Slot) {
23769
+ return [jsxElement, _jsxSorted(Fragment, null, null, [jsx4, jsxElement], 0, null)];
23770
+ }
23768
23771
  if (jsx4.children == null) {
23769
23772
  jsx4.children = jsxElement;
23770
23773
  } else if (Array.isArray(jsx4.children)) {
@@ -23772,13 +23775,19 @@ function addScriptNodeForInvisibleComponents(jsx4) {
23772
23775
  } else {
23773
23776
  jsx4.children = [jsx4.children, jsxElement];
23774
23777
  }
23775
- return jsxElement;
23778
+ return [jsxElement, jsx4];
23776
23779
  } else if (Array.isArray(jsx4) && jsx4.length) {
23777
- return addScriptNodeForInvisibleComponents(jsx4[0]);
23780
+ const [jsxElement, _] = addScriptNodeForInvisibleComponents(jsx4[0]);
23781
+ return [jsxElement, jsx4];
23778
23782
  }
23779
- return null;
23783
+ return [null, null];
23780
23784
  }
23781
23785
 
23786
+ // packages/qwik/src/core/shared/utils/constants.ts
23787
+ var _CONST_PROPS = Symbol("CONST");
23788
+ var _VAR_PROPS = Symbol("VAR");
23789
+ var _IMMUTABLE = Symbol("IMMUTABLE");
23790
+
23782
23791
  // packages/qwik/src/core/shared/utils/prop.ts
23783
23792
  function isSlotProp(prop) {
23784
23793
  return !prop.startsWith("q:") && !prop.startsWith(NON_SERIALIZABLE_MARKER_PREFIX);
@@ -23817,18 +23826,6 @@ function escapeHTML(html) {
23817
23826
  }
23818
23827
  }
23819
23828
 
23820
- // packages/qwik/src/core/shared/utils/jsx-filename.ts
23821
- function getFileLocationFromJsx(jsxDev) {
23822
- if (!jsxDev) {
23823
- return null;
23824
- }
23825
- const sanitizedFileName = jsxDev.fileName?.replace(/\\/g, "/");
23826
- if (sanitizedFileName) {
23827
- return `${sanitizedFileName}:${jsxDev.lineNumber}:${jsxDev.columnNumber}`;
23828
- }
23829
- return null;
23830
- }
23831
-
23832
23829
  // packages/qwik/src/core/client/vnode-diff.ts
23833
23830
  var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
23834
23831
  let journal = container.$journal$;
@@ -23865,7 +23862,7 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
23865
23862
  descend(jsxValue, false);
23866
23863
  } else if (isSignal(jsxValue)) {
23867
23864
  if (vCurrent) {
23868
- clearVNodeEffectDependencies(container, vCurrent);
23865
+ clearAllEffects(container, vCurrent);
23869
23866
  }
23870
23867
  expectVirtual("S" /* WrappedSignal */, null);
23871
23868
  descend(
@@ -24022,8 +24019,9 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
24022
24019
  };
24023
24020
  const projections = [];
24024
24021
  if (host) {
24025
- for (let i = vnode_getPropStartIndex(host); i < host.length; i = i + 2) {
24026
- const prop = host[i];
24022
+ const props = vnode_getProps(host);
24023
+ for (let i = 0; i < props.length; i = i + 2) {
24024
+ const prop = props[i];
24027
24025
  if (isSlotProp(prop)) {
24028
24026
  const slotName = prop;
24029
24027
  projections.push(slotName);
@@ -24067,8 +24065,8 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
24067
24065
  );
24068
24066
  if (vCurrent == null) {
24069
24067
  vNewNode = vnode_newVirtual();
24070
- isDev4 && vnode_setProp(vNewNode, DEBUG_TYPE, "P" /* Projection */);
24071
- isDev4 && vnode_setProp(vNewNode, "q:code", "expectProjection");
24068
+ isDev6 && vnode_setProp(vNewNode, DEBUG_TYPE, "P" /* Projection */);
24069
+ isDev6 && vnode_setProp(vNewNode, "q:code", "expectProjection");
24072
24070
  vnode_setProp(vNewNode, QSlot, slotName);
24073
24071
  vnode_setProp(vNewNode, QSlotParent, vParent);
24074
24072
  vnode_setProp(vParent, slotName, vNewNode);
@@ -24094,8 +24092,8 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
24094
24092
  );
24095
24093
  vnode_setProp(vNewNode, QSlot, slotNameKey);
24096
24094
  vHost && vnode_setProp(vHost, slotNameKey, vNewNode);
24097
- isDev4 && vnode_setProp(vNewNode, DEBUG_TYPE, "P" /* Projection */);
24098
- isDev4 && vnode_setProp(vNewNode, "q:code", "expectSlot" + count++);
24095
+ isDev6 && vnode_setProp(vNewNode, DEBUG_TYPE, "P" /* Projection */);
24096
+ isDev6 && vnode_setProp(vNewNode, "q:code", "expectSlot" + count++);
24099
24097
  return false;
24100
24098
  } else if (vProjectedNode === vCurrent) {
24101
24099
  } else {
@@ -24107,8 +24105,8 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
24107
24105
  );
24108
24106
  vnode_setProp(vNewNode, QSlot, slotNameKey);
24109
24107
  vHost && vnode_setProp(vHost, slotNameKey, vNewNode);
24110
- isDev4 && vnode_setProp(vNewNode, DEBUG_TYPE, "P" /* Projection */);
24111
- isDev4 && vnode_setProp(vNewNode, "q:code", "expectSlot" + count++);
24108
+ isDev6 && vnode_setProp(vNewNode, DEBUG_TYPE, "P" /* Projection */);
24109
+ isDev6 && vnode_setProp(vNewNode, "q:code", "expectSlot" + count++);
24112
24110
  }
24113
24111
  return true;
24114
24112
  }
@@ -24179,14 +24177,20 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
24179
24177
  if (isJsxPropertyAnEventName(key2)) {
24180
24178
  const eventName = getEventNameFromJsxProp(key2);
24181
24179
  const scope = getEventNameScopeFromJsxProp(key2);
24182
- vnode_setProp(
24183
- vNewNode,
24184
- HANDLER_PREFIX + ":" + scope + ":" + eventName,
24185
- value
24186
- );
24187
24180
  if (eventName) {
24181
+ vnode_setProp(
24182
+ vNewNode,
24183
+ HANDLER_PREFIX + ":" + scope + ":" + eventName,
24184
+ value
24185
+ );
24188
24186
  registerQwikLoaderEvent(eventName);
24189
24187
  }
24188
+ if (scope) {
24189
+ const htmlEvent = convertEventNameFromJsxPropToHtmlAttr(key2);
24190
+ if (htmlEvent) {
24191
+ vnode_setAttr(journal, vNewNode, htmlEvent, "");
24192
+ }
24193
+ }
24190
24194
  needsQDispatchEventPatch = true;
24191
24195
  continue;
24192
24196
  }
@@ -24197,12 +24201,14 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
24197
24201
  } else if (typeof value === "function") {
24198
24202
  value(element);
24199
24203
  continue;
24204
+ } else if (value == null) {
24205
+ continue;
24200
24206
  } else {
24201
24207
  throw qError(32 /* invalidRefValue */, [currentFile]);
24202
24208
  }
24203
24209
  }
24204
24210
  if (isSignal(value)) {
24205
- const signalData = new EffectPropData({
24211
+ const signalData = new SubscriptionData({
24206
24212
  $scopedStyleIdPrefix$: scopedStyleIdPrefix,
24207
24213
  $isConst$: true
24208
24214
  });
@@ -24221,7 +24227,7 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
24221
24227
  }
24222
24228
  if (elementName === "textarea" && key2 === "value") {
24223
24229
  if (value && typeof value !== "string") {
24224
- if (isDev4) {
24230
+ if (isDev6) {
24225
24231
  throw qError(40 /* wrongTextareaValue */, [currentFile, value]);
24226
24232
  }
24227
24233
  continue;
@@ -24302,7 +24308,12 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
24302
24308
  let returnValue = false;
24303
24309
  qrls.flat(2).forEach((qrl2) => {
24304
24310
  if (qrl2) {
24305
- const value = qrl2(event, element);
24311
+ const value = container.$scheduler$(
24312
+ 2 /* RUN_QRL */,
24313
+ vNode,
24314
+ qrl2,
24315
+ [event, element]
24316
+ );
24306
24317
  returnValue = returnValue || value === true;
24307
24318
  }
24308
24319
  });
@@ -24313,10 +24324,10 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
24313
24324
  }
24314
24325
  function setBulkProps(vnode, srcAttrs, currentFile) {
24315
24326
  vnode_ensureElementInflated(vnode);
24316
- const dstAttrs = vnode;
24327
+ const dstAttrs = vnode_getProps(vnode);
24317
24328
  let srcIdx = 0;
24318
24329
  const srcLength = srcAttrs.length;
24319
- let dstIdx = 8 /* PROPS_OFFSET */;
24330
+ let dstIdx = 0;
24320
24331
  let dstLength = dstAttrs.length;
24321
24332
  let srcKey = srcIdx < srcLength ? srcAttrs[srcIdx++] : null;
24322
24333
  let dstKey = dstIdx < dstLength ? dstAttrs[dstIdx++] : null;
@@ -24334,12 +24345,14 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
24334
24345
  } else if (typeof value === "function") {
24335
24346
  value(element);
24336
24347
  return;
24348
+ } else if (value == null) {
24349
+ return;
24337
24350
  } else {
24338
24351
  throw qError(32 /* invalidRefValue */, [currentFile]);
24339
24352
  }
24340
24353
  }
24341
24354
  if (isSignal(value)) {
24342
- const signalData = new EffectPropData({
24355
+ const signalData = new SubscriptionData({
24343
24356
  $scopedStyleIdPrefix$: scopedStyleIdPrefix,
24344
24357
  $isConst$: false
24345
24358
  });
@@ -24352,17 +24365,17 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
24352
24365
  };
24353
24366
  const recordJsxEvent = (key, value) => {
24354
24367
  const eventName = getEventNameFromJsxProp(key);
24368
+ const scope = getEventNameScopeFromJsxProp(key);
24355
24369
  if (eventName) {
24356
- const scope = getEventNameScopeFromJsxProp(key);
24357
24370
  record(":" + scope + ":" + eventName, value);
24358
- }
24359
- const htmlEvent = convertEventNameFromJsxPropToHtmlAttr(key);
24360
- if (htmlEvent) {
24361
- record(htmlEvent, "");
24362
- }
24363
- if (eventName) {
24364
24371
  registerQwikLoaderEvent(eventName);
24365
24372
  }
24373
+ if (scope) {
24374
+ const htmlEvent = convertEventNameFromJsxPropToHtmlAttr(key);
24375
+ if (htmlEvent) {
24376
+ record(htmlEvent, "");
24377
+ }
24378
+ }
24366
24379
  };
24367
24380
  while (srcKey !== null || dstKey !== null) {
24368
24381
  if (dstKey?.startsWith(HANDLER_PREFIX) || dstKey?.startsWith(Q_PREFIX)) {
@@ -24478,7 +24491,7 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
24478
24491
  vCurrent && getInsertBefore()
24479
24492
  );
24480
24493
  vnode_setProp(vNewNode, ELEMENT_KEY, jsxKey);
24481
- isDev4 && vnode_setProp(vNewNode || vCurrent, DEBUG_TYPE, type);
24494
+ isDev6 && vnode_setProp(vNewNode || vCurrent, DEBUG_TYPE, type);
24482
24495
  }
24483
24496
  function expectComponent(component) {
24484
24497
  const componentMeta = component[SERIALIZABLE_STATE];
@@ -24506,9 +24519,6 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
24506
24519
  } else if (!hashesAreEqual) {
24507
24520
  insertNewComponent(host, componentQRL, jsxProps);
24508
24521
  if (vNewNode) {
24509
- if (host) {
24510
- vNewNode[0 /* flags */] = host[0 /* flags */];
24511
- }
24512
24522
  host = vNewNode;
24513
24523
  shouldRender = true;
24514
24524
  }
@@ -24518,7 +24528,7 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
24518
24528
  shouldRender = shouldRender || propsDiffer(jsxProps, vNodeProps);
24519
24529
  if (shouldRender) {
24520
24530
  host[0 /* flags */] &= ~32 /* Deleted */;
24521
- container.$scheduler$(7 /* COMPONENT */, host, componentQRL, jsxProps);
24531
+ container.$scheduler$(6 /* COMPONENT */, host, componentQRL, jsxProps);
24522
24532
  }
24523
24533
  }
24524
24534
  descendContentToProject(jsxNode2.children, host);
@@ -24553,7 +24563,7 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
24553
24563
  }
24554
24564
  function insertNewComponent(host, componentQRL, jsxProps) {
24555
24565
  if (host) {
24556
- clearVNodeEffectDependencies(container, host);
24566
+ clearAllEffects(container, host);
24557
24567
  }
24558
24568
  vnode_insertBefore(
24559
24569
  journal,
@@ -24562,7 +24572,7 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
24562
24572
  vCurrent && getInsertBefore()
24563
24573
  );
24564
24574
  const jsxNode2 = jsxValue;
24565
- isDev4 && vnode_setProp(vNewNode, DEBUG_TYPE, "C" /* Component */);
24575
+ isDev6 && vnode_setProp(vNewNode, DEBUG_TYPE, "C" /* Component */);
24566
24576
  container.setHostProp(vNewNode, OnRenderProp, componentQRL);
24567
24577
  container.setHostProp(vNewNode, ELEMENT_PROPS, jsxProps);
24568
24578
  container.setHostProp(vNewNode, ELEMENT_KEY, jsxNode2.key);
@@ -24575,7 +24585,7 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
24575
24585
  vCurrent && getInsertBefore()
24576
24586
  );
24577
24587
  const jsxNode2 = jsxValue;
24578
- isDev4 && vnode_setProp(vNewNode, DEBUG_TYPE, "I" /* InlineComponent */);
24588
+ isDev6 && vnode_setProp(vNewNode, DEBUG_TYPE, "I" /* InlineComponent */);
24579
24589
  vnode_setProp(vNewNode, ELEMENT_PROPS, jsxNode2.props);
24580
24590
  if (jsxNode2.key) {
24581
24591
  vnode_setProp(vNewNode, ELEMENT_KEY, jsxNode2.key);
@@ -24619,8 +24629,8 @@ function propsDiffer(src, dst) {
24619
24629
  if (!src || !dst) {
24620
24630
  return true;
24621
24631
  }
24622
- let srcKeys = removePropsKeys(Object.keys(src), ["children", QSubscribers]);
24623
- let dstKeys = removePropsKeys(Object.keys(dst), ["children", QSubscribers]);
24632
+ let srcKeys = removePropsKeys(Object.keys(src), ["children", QBackRefs]);
24633
+ let dstKeys = removePropsKeys(Object.keys(dst), ["children", QBackRefs]);
24624
24634
  if (srcKeys.length !== dstKeys.length) {
24625
24635
  return true;
24626
24636
  }
@@ -24654,7 +24664,7 @@ function cleanup(container, vNode) {
24654
24664
  do {
24655
24665
  const type = vCursor[0 /* flags */];
24656
24666
  if (type & 3 /* ELEMENT_OR_VIRTUAL_MASK */) {
24657
- clearVNodeEffectDependencies(container, vCursor);
24667
+ clearAllEffects(container, vCursor);
24658
24668
  markVNodeAsDeleted(vCursor);
24659
24669
  if (type & 2 /* Virtual */) {
24660
24670
  const seq = container.getHostProp(vCursor, ELEMENT_SEQ);
@@ -24663,7 +24673,7 @@ function cleanup(container, vNode) {
24663
24673
  const obj = seq[i];
24664
24674
  if (isTask(obj)) {
24665
24675
  const task = obj;
24666
- clearSubscriberEffectDependencies(container, task);
24676
+ clearAllEffects(container, task);
24667
24677
  if (task.$flags$ & 1 /* VISIBLE_TASK */) {
24668
24678
  container.$scheduler$(48 /* CLEANUP_VISIBLE */, task);
24669
24679
  } else {
@@ -24675,8 +24685,8 @@ function cleanup(container, vNode) {
24675
24685
  }
24676
24686
  const isComponent = type & 2 /* Virtual */ && vnode_getProp(vCursor, OnRenderProp, null) !== null;
24677
24687
  if (isComponent) {
24678
- const attrs = vCursor;
24679
- for (let i = 6 /* PROPS_OFFSET */; i < attrs.length; i = i + 2) {
24688
+ const attrs = vnode_getProps(vCursor);
24689
+ for (let i = 0; i < attrs.length; i = i + 2) {
24680
24690
  const key = attrs[i];
24681
24691
  if (!isParentSlotProp(key) && isSlotProp(key)) {
24682
24692
  const value = attrs[i + 1];
@@ -24748,58 +24758,198 @@ function markVNodeAsDeleted(vCursor) {
24748
24758
  var HANDLER_PREFIX = ":";
24749
24759
  var count = 0;
24750
24760
 
24751
- // packages/qwik/src/core/shared/qrl/implicit_dollar.ts
24752
- var implicit$FirstArg = (fn) => {
24753
- return function(first, ...rest) {
24754
- return fn.call(null, dollar(first), ...rest);
24761
+ // packages/qwik/src/core/use/use-resource.ts
24762
+ var _createResourceReturn = (opts) => {
24763
+ const resource = {
24764
+ __brand: "resource",
24765
+ value: void 0,
24766
+ loading: isServerPlatform() ? false : true,
24767
+ _resolved: void 0,
24768
+ _error: void 0,
24769
+ _state: "pending",
24770
+ _timeout: opts?.timeout ?? -1,
24771
+ _cache: 0
24755
24772
  };
24773
+ return resource;
24756
24774
  };
24757
-
24758
- // packages/qwik/src/core/shared/scheduler-document-position.ts
24759
- var aVNodePath = [];
24760
- var bVNodePath = [];
24761
- var vnode_documentPosition = (a, b, rootVNode) => {
24762
- if (a === b) {
24763
- return 0;
24764
- }
24765
- let aDepth = -1;
24766
- let bDepth = -1;
24767
- while (a) {
24768
- const vNode = aVNodePath[++aDepth] = a;
24769
- a = vNode[1 /* parent */] || rootVNode && vnode_getProp(a, QSlotParent, (id) => vnode_locate(rootVNode, id));
24770
- }
24771
- while (b) {
24772
- const vNode = bVNodePath[++bDepth] = b;
24773
- b = vNode[1 /* parent */] || rootVNode && vnode_getProp(b, QSlotParent, (id) => vnode_locate(rootVNode, id));
24774
- }
24775
- while (aDepth >= 0 && bDepth >= 0) {
24776
- a = aVNodePath[aDepth];
24777
- b = bVNodePath[bDepth];
24778
- if (a === b) {
24779
- aDepth--;
24780
- bDepth--;
24781
- } else {
24782
- let cursor = b;
24783
- do {
24784
- cursor = vnode_getNextSibling(cursor);
24785
- if (cursor === a) {
24786
- return 1;
24787
- }
24788
- } while (cursor);
24789
- cursor = b;
24790
- do {
24791
- cursor = vnode_getPreviousSibling(cursor);
24792
- if (cursor === a) {
24793
- return -1;
24794
- }
24795
- } while (cursor);
24796
- if (rootVNode && vnode_getProp(b, QSlotParent, (id) => vnode_locate(rootVNode, id))) {
24797
- return -1;
24798
- }
24799
- return 1;
24800
- }
24801
- }
24802
- return aDepth < bDepth ? -1 : 1;
24775
+ var createResourceReturn = (container, opts, initialPromise) => {
24776
+ const result = _createResourceReturn(opts);
24777
+ result.value = initialPromise;
24778
+ return createStore(container, result, 1 /* RECURSIVE */);
24779
+ };
24780
+ var runResource = (task, container, host) => {
24781
+ task.$flags$ &= ~8 /* DIRTY */;
24782
+ cleanupTask(task);
24783
+ const iCtx = newInvokeContext(container.$locale$, host, void 0, ResourceEvent);
24784
+ iCtx.$container$ = container;
24785
+ const taskFn = task.$qrl$.getFn(iCtx, () => clearAllEffects(container, task));
24786
+ const resource = task.$state$;
24787
+ assertDefined(
24788
+ resource,
24789
+ 'useResource: when running a resource, "task.resource" must be a defined.',
24790
+ task
24791
+ );
24792
+ const track = (obj, prop) => {
24793
+ const ctx = newInvokeContext();
24794
+ ctx.$effectSubscriber$ = getSubscriber(task, ":" /* COMPONENT */);
24795
+ ctx.$container$ = container;
24796
+ return invoke(ctx, () => {
24797
+ if (isFunction(obj)) {
24798
+ return obj();
24799
+ }
24800
+ if (prop) {
24801
+ return obj[prop];
24802
+ } else if (isSignal(obj)) {
24803
+ return obj.value;
24804
+ } else {
24805
+ return obj;
24806
+ }
24807
+ });
24808
+ };
24809
+ const handleError = (reason) => container.handleError(reason, host);
24810
+ const cleanups = [];
24811
+ task.$destroy$ = noSerialize(() => {
24812
+ cleanups.forEach((fn) => {
24813
+ try {
24814
+ fn();
24815
+ } catch (err) {
24816
+ handleError(err);
24817
+ }
24818
+ });
24819
+ done = true;
24820
+ });
24821
+ const resourceTarget = unwrapStore(resource);
24822
+ const opts = {
24823
+ track,
24824
+ cleanup(fn) {
24825
+ if (typeof fn === "function") {
24826
+ cleanups.push(fn);
24827
+ }
24828
+ },
24829
+ cache(policy) {
24830
+ let milliseconds = 0;
24831
+ if (policy === "immutable") {
24832
+ milliseconds = Infinity;
24833
+ } else {
24834
+ milliseconds = policy;
24835
+ }
24836
+ resource._cache = milliseconds;
24837
+ },
24838
+ previous: resourceTarget._resolved
24839
+ };
24840
+ let resolve;
24841
+ let reject;
24842
+ let done = false;
24843
+ const setState = (resolved, value) => {
24844
+ if (!done) {
24845
+ done = true;
24846
+ if (resolved) {
24847
+ done = true;
24848
+ resource.loading = false;
24849
+ resource._state = "resolved";
24850
+ resource._resolved = value;
24851
+ resource._error = void 0;
24852
+ resolve(value);
24853
+ } else {
24854
+ done = true;
24855
+ resource.loading = false;
24856
+ resource._state = "rejected";
24857
+ resource._error = value;
24858
+ reject(value);
24859
+ }
24860
+ return true;
24861
+ }
24862
+ return false;
24863
+ };
24864
+ cleanups.push(() => {
24865
+ if (untrack(() => resource.loading) === true) {
24866
+ const value = untrack(() => resource._resolved);
24867
+ setState(true, value);
24868
+ }
24869
+ });
24870
+ invoke(iCtx, () => {
24871
+ resource._state = "pending";
24872
+ resource.loading = !isServerPlatform();
24873
+ const promise2 = resource.value = new Promise((r, re) => {
24874
+ resolve = r;
24875
+ reject = re;
24876
+ });
24877
+ promise2.catch(ignoreErrorToPreventNodeFromCrashing);
24878
+ });
24879
+ const promise = safeCall(
24880
+ () => Promise.resolve(taskFn(opts)),
24881
+ (value) => {
24882
+ setState(true, value);
24883
+ },
24884
+ (err) => {
24885
+ if (isPromise(err)) {
24886
+ return err.then(() => runResource(task, container, host));
24887
+ } else {
24888
+ setState(false, err);
24889
+ }
24890
+ }
24891
+ );
24892
+ const timeout = resourceTarget._timeout;
24893
+ if (timeout > 0) {
24894
+ return Promise.race([
24895
+ promise,
24896
+ delay(timeout).then(() => {
24897
+ if (setState(false, new Error("timeout"))) {
24898
+ cleanupTask(task);
24899
+ }
24900
+ })
24901
+ ]);
24902
+ }
24903
+ return promise;
24904
+ };
24905
+ var ignoreErrorToPreventNodeFromCrashing = (err) => {
24906
+ };
24907
+
24908
+ // packages/qwik/src/core/shared/scheduler-document-position.ts
24909
+ var aVNodePath = [];
24910
+ var bVNodePath = [];
24911
+ var vnode_documentPosition = (a, b, rootVNode) => {
24912
+ if (a === b) {
24913
+ return 0;
24914
+ }
24915
+ let aDepth = -1;
24916
+ let bDepth = -1;
24917
+ while (a) {
24918
+ const vNode = aVNodePath[++aDepth] = a;
24919
+ a = vNode[1 /* parent */] || rootVNode && vnode_getProp(a, QSlotParent, (id) => vnode_locate(rootVNode, id));
24920
+ }
24921
+ while (b) {
24922
+ const vNode = bVNodePath[++bDepth] = b;
24923
+ b = vNode[1 /* parent */] || rootVNode && vnode_getProp(b, QSlotParent, (id) => vnode_locate(rootVNode, id));
24924
+ }
24925
+ while (aDepth >= 0 && bDepth >= 0) {
24926
+ a = aVNodePath[aDepth];
24927
+ b = bVNodePath[bDepth];
24928
+ if (a === b) {
24929
+ aDepth--;
24930
+ bDepth--;
24931
+ } else {
24932
+ let cursor = b;
24933
+ do {
24934
+ cursor = vnode_getNextSibling(cursor);
24935
+ if (cursor === a) {
24936
+ return 1;
24937
+ }
24938
+ } while (cursor);
24939
+ cursor = b;
24940
+ do {
24941
+ cursor = vnode_getPreviousSibling(cursor);
24942
+ if (cursor === a) {
24943
+ return -1;
24944
+ }
24945
+ } while (cursor);
24946
+ if (rootVNode && vnode_getProp(b, QSlotParent, (id) => vnode_locate(rootVNode, id))) {
24947
+ return -1;
24948
+ }
24949
+ return 1;
24950
+ }
24951
+ }
24952
+ return aDepth < bDepth ? -1 : 1;
24803
24953
  };
24804
24954
  var aSsrNodePath = [];
24805
24955
  var bSsrNodePath = [];
@@ -24832,14 +24982,30 @@ var ssrNodeDocumentPosition = (a, b) => {
24832
24982
 
24833
24983
  // packages/qwik/src/core/shared/scheduler.ts
24834
24984
  var DEBUG2 = false;
24985
+ var getPromise = (chore) => chore.$promise$ || (chore.$promise$ = new Promise((resolve) => {
24986
+ chore.$resolve$ = resolve;
24987
+ }));
24835
24988
  var createScheduler = (container, scheduleDrain, journalFlush) => {
24836
24989
  const choreQueue = [];
24990
+ const qrlRuns = [];
24837
24991
  let currentChore = null;
24838
- let journalFlushScheduled = false;
24992
+ let drainScheduled = false;
24839
24993
  return schedule;
24840
24994
  function schedule(type, hostOrTask = null, targetOrQrl = null, payload = null) {
24841
- const runLater = type !== 255 /* WAIT_FOR_ALL */ && type !== 6 /* COMPONENT_SSR */;
24842
- const isTask2 = type === 3 /* TASK */ || type === 32 /* VISIBLE */ || type === 2 /* RESOURCE */ || type === 48 /* CLEANUP_VISIBLE */;
24995
+ const isServer4 = !isDomContainer(container);
24996
+ const isComponentSsr = isServer4 && type === 6 /* COMPONENT */;
24997
+ const runLater = type !== 255 /* WAIT_FOR_ALL */ && !isComponentSsr && type !== 2 /* RUN_QRL */;
24998
+ const isTask2 = type === 3 /* TASK */ || type === 32 /* VISIBLE */ || type === 48 /* CLEANUP_VISIBLE */;
24999
+ const isClientOnly = type === 16 /* JOURNAL_FLUSH */ || type === 4 /* NODE_DIFF */ || type === 5 /* NODE_PROP */;
25000
+ if (isServer4 && isClientOnly) {
25001
+ DEBUG2 && debugTrace(
25002
+ `skip client chore ${debugChoreTypeToString(type)}`,
25003
+ null,
25004
+ currentChore,
25005
+ choreQueue
25006
+ );
25007
+ return;
25008
+ }
24843
25009
  if (isTask2) {
24844
25010
  hostOrTask.$flags$ |= 8 /* DIRTY */;
24845
25011
  }
@@ -24854,179 +25020,226 @@ var createScheduler = (container, scheduleDrain, journalFlush) => {
24854
25020
  $returnValue$: null,
24855
25021
  $executed$: false
24856
25022
  };
24857
- chore.$promise$ = new Promise((resolve) => chore.$resolve$ = resolve);
24858
- DEBUG2 && debugTrace("schedule", chore, currentChore, choreQueue);
24859
25023
  chore = sortedInsert(choreQueue, chore, container.rootVNode || null);
24860
- if (!journalFlushScheduled && runLater) {
24861
- journalFlushScheduled = true;
25024
+ DEBUG2 && debugTrace("schedule", chore, currentChore, choreQueue);
25025
+ if (!drainScheduled && runLater) {
25026
+ drainScheduled = true;
24862
25027
  schedule(16 /* JOURNAL_FLUSH */);
24863
- scheduleDrain();
25028
+ scheduleDrain()?.catch?.(() => {
25029
+ });
24864
25030
  }
24865
25031
  if (runLater) {
24866
- return chore.$promise$;
25032
+ return getPromise(chore);
24867
25033
  } else {
24868
- return drainUpTo(chore, container.rootVNode || null);
25034
+ return drainUpTo(chore, isServer4);
24869
25035
  }
24870
25036
  }
24871
- function drainUpTo(runUptoChore, rootVNode) {
24872
- if (runUptoChore.$executed$) {
24873
- return runUptoChore.$returnValue$;
24874
- }
24875
- if (currentChore) {
24876
- return runUptoChore.$promise$;
24877
- }
25037
+ function drainUpTo(runUptoChore, isServer4) {
25038
+ let maxRetries = 5e3;
24878
25039
  while (choreQueue.length) {
24879
- const nextChore = choreQueue.shift();
24880
- const order = choreComparator(nextChore, runUptoChore, rootVNode);
24881
- if (order === null) {
24882
- continue;
25040
+ if (maxRetries-- < 0) {
25041
+ throw new Error("drainUpTo: max retries reached");
24883
25042
  }
24884
- if (order > 0) {
24885
- break;
25043
+ if (currentChore) {
25044
+ return getPromise(currentChore).then(() => drainUpTo(runUptoChore, isServer4)).catch((e) => {
25045
+ container.handleError(e, currentChore?.$host$);
25046
+ });
25047
+ }
25048
+ const nextChore = choreQueue[0];
25049
+ if (nextChore.$executed$) {
25050
+ choreQueue.shift();
25051
+ if (nextChore === runUptoChore) {
25052
+ break;
25053
+ }
25054
+ continue;
24886
25055
  }
24887
- const isDeletedVNode = vNodeAlreadyDeleted(nextChore);
24888
- if (isDeletedVNode && // we need to process cleanup tasks for deleted nodes
25056
+ if (vNodeAlreadyDeleted(nextChore) && // we need to process cleanup tasks for deleted nodes
24889
25057
  nextChore.$type$ !== 48 /* CLEANUP_VISIBLE */) {
24890
25058
  DEBUG2 && debugTrace("skip chore", nextChore, currentChore, choreQueue);
25059
+ choreQueue.shift();
24891
25060
  continue;
24892
25061
  }
24893
- const returnValue = executeChore(nextChore);
24894
- if (isPromise(returnValue)) {
24895
- const promise = returnValue.then(() => drainUpTo(runUptoChore, rootVNode));
24896
- return promise;
24897
- }
25062
+ executeChore(nextChore, isServer4);
24898
25063
  }
24899
25064
  return runUptoChore.$returnValue$;
24900
25065
  }
24901
- function executeChore(chore) {
25066
+ function executeChore(chore, isServer4) {
24902
25067
  const host = chore.$host$;
24903
25068
  DEBUG2 && debugTrace("execute", chore, currentChore, choreQueue);
24904
25069
  assertEqual(currentChore, null, "Chore already running.");
24905
25070
  currentChore = chore;
24906
25071
  let returnValue = null;
24907
- switch (chore.$type$) {
24908
- case 16 /* JOURNAL_FLUSH */:
24909
- returnValue = journalFlush();
24910
- journalFlushScheduled = false;
24911
- break;
24912
- case 7 /* COMPONENT */:
24913
- case 6 /* COMPONENT_SSR */:
24914
- returnValue = safeCall(
24915
- () => executeComponent(
24916
- container,
24917
- host,
24918
- host,
24919
- chore.$target$,
24920
- chore.$payload$
24921
- ),
24922
- (jsx5) => {
24923
- if (chore.$type$ === 7 /* COMPONENT */) {
24924
- const styleScopedId = container.getHostProp(host, QScopedStyle);
24925
- return retryOnPromise(
24926
- () => vnode_diff(
24927
- container,
24928
- jsx5,
24929
- host,
24930
- addComponentStylePrefix(styleScopedId)
24931
- )
24932
- );
25072
+ try {
25073
+ switch (chore.$type$) {
25074
+ case 255 /* WAIT_FOR_ALL */:
25075
+ {
25076
+ if (isServer4) {
25077
+ drainScheduled = false;
25078
+ }
25079
+ }
25080
+ break;
25081
+ case 16 /* JOURNAL_FLUSH */:
25082
+ {
25083
+ returnValue = journalFlush();
25084
+ drainScheduled = false;
25085
+ }
25086
+ break;
25087
+ case 6 /* COMPONENT */:
25088
+ {
25089
+ returnValue = safeCall(
25090
+ () => executeComponent(
25091
+ container,
25092
+ host,
25093
+ host,
25094
+ chore.$target$,
25095
+ chore.$payload$
25096
+ ),
25097
+ (jsx4) => {
25098
+ if (isServer4) {
25099
+ return jsx4;
25100
+ } else {
25101
+ const styleScopedId = container.getHostProp(host, QScopedStyle);
25102
+ return retryOnPromise(
25103
+ () => vnode_diff(
25104
+ container,
25105
+ jsx4,
25106
+ host,
25107
+ addComponentStylePrefix(styleScopedId)
25108
+ )
25109
+ );
25110
+ }
25111
+ },
25112
+ (err) => container.handleError(err, host)
25113
+ );
25114
+ }
25115
+ break;
25116
+ case 2 /* RUN_QRL */:
25117
+ {
25118
+ const fn = chore.$target$.getFn();
25119
+ const result = retryOnPromise(() => fn(...chore.$payload$));
25120
+ if (isPromise(result)) {
25121
+ const handled = result.finally(() => {
25122
+ qrlRuns.splice(qrlRuns.indexOf(handled), 1);
25123
+ }).catch((error) => {
25124
+ container.handleError(error, chore.$host$);
25125
+ });
25126
+ qrlRuns.push(handled);
25127
+ DEBUG2 && debugTrace("execute.DONE (but still running)", chore, currentChore, choreQueue);
25128
+ chore.$returnValue$ = handled;
25129
+ chore.$resolve$?.(handled);
25130
+ currentChore = null;
25131
+ chore.$executed$ = true;
25132
+ return;
25133
+ }
25134
+ returnValue = null;
25135
+ }
25136
+ break;
25137
+ case 3 /* TASK */:
25138
+ case 32 /* VISIBLE */:
25139
+ {
25140
+ const payload = chore.$payload$;
25141
+ if (payload.$flags$ & 4 /* RESOURCE */) {
25142
+ const result = runResource(payload, container, host);
25143
+ returnValue = isServer4 ? result : null;
24933
25144
  } else {
24934
- return jsx5;
25145
+ returnValue = runTask(payload, container, host);
24935
25146
  }
24936
- },
24937
- (err) => container.handleError(err, host)
24938
- );
24939
- break;
24940
- case 2 /* RESOURCE */:
24941
- const result = runResource(chore.$payload$, container, host);
24942
- returnValue = isDomContainer(container) ? null : result;
24943
- break;
24944
- case 3 /* TASK */:
24945
- returnValue = runTask(chore.$payload$, container, host);
24946
- break;
24947
- case 32 /* VISIBLE */:
24948
- returnValue = runTask(chore.$payload$, container, host);
24949
- break;
24950
- case 48 /* CLEANUP_VISIBLE */:
24951
- const task = chore.$payload$;
24952
- cleanupTask(task);
24953
- break;
24954
- case 4 /* NODE_DIFF */:
24955
- const parentVirtualNode = chore.$target$;
24956
- let jsx4 = chore.$payload$;
24957
- if (isSignal(jsx4)) {
24958
- jsx4 = jsx4.value;
24959
- }
24960
- returnValue = retryOnPromise(
24961
- () => vnode_diff(container, jsx4, parentVirtualNode, null)
24962
- );
24963
- break;
24964
- case 5 /* NODE_PROP */:
24965
- const virtualNode = chore.$host$;
24966
- const payload = chore.$payload$;
24967
- let value = payload.$value$;
24968
- if (isSignal(value)) {
24969
- value = value.value;
24970
- }
24971
- const isConst = payload.$isConst$;
24972
- const journal = container.$journal$;
24973
- const property = chore.$idx$;
24974
- const serializedValue = serializeAttribute(property, value, payload.$scopedStyleIdPrefix$);
24975
- if (isConst) {
24976
- const element = virtualNode[6 /* element */];
24977
- journal.push(2 /* SetAttribute */, element, property, serializedValue);
24978
- } else {
24979
- vnode_setAttr(journal, virtualNode, property, serializedValue);
24980
- }
24981
- break;
24982
- case 1 /* QRL_RESOLVE */: {
24983
- const target = chore.$target$;
24984
- returnValue = !target.resolved ? target.resolve() : null;
24985
- break;
24986
- }
24987
- case 8 /* RECOMPUTE_AND_SCHEDULE_EFFECTS */: {
24988
- const target = chore.$target$;
24989
- const forceRunEffects = target.$forceRunEffects$;
24990
- target.$forceRunEffects$ = false;
24991
- if (!target.$effects$?.length) {
25147
+ }
25148
+ break;
25149
+ case 48 /* CLEANUP_VISIBLE */:
25150
+ {
25151
+ const task = chore.$payload$;
25152
+ cleanupTask(task);
25153
+ }
25154
+ break;
25155
+ case 4 /* NODE_DIFF */:
25156
+ {
25157
+ const parentVirtualNode = chore.$target$;
25158
+ let jsx4 = chore.$payload$;
25159
+ if (isSignal(jsx4)) {
25160
+ jsx4 = jsx4.value;
25161
+ }
25162
+ returnValue = retryOnPromise(
25163
+ () => vnode_diff(container, jsx4, parentVirtualNode, null)
25164
+ );
25165
+ }
25166
+ break;
25167
+ case 5 /* NODE_PROP */:
25168
+ {
25169
+ const virtualNode = chore.$host$;
25170
+ const payload = chore.$payload$;
25171
+ let value = payload.$value$;
25172
+ if (isSignal(value)) {
25173
+ value = value.value;
25174
+ }
25175
+ const isConst = payload.$isConst$;
25176
+ const journal = container.$journal$;
25177
+ const property = chore.$idx$;
25178
+ const serializedValue = serializeAttribute(
25179
+ property,
25180
+ value,
25181
+ payload.$scopedStyleIdPrefix$
25182
+ );
25183
+ if (isConst) {
25184
+ const element = virtualNode[6 /* element */];
25185
+ journal.push(2 /* SetAttribute */, element, property, serializedValue);
25186
+ } else {
25187
+ vnode_setAttr(journal, virtualNode, property, serializedValue);
25188
+ }
25189
+ }
25190
+ break;
25191
+ case 1 /* QRL_RESOLVE */: {
25192
+ {
25193
+ const target = chore.$target$;
25194
+ returnValue = !target.resolved ? target.resolve() : null;
25195
+ }
24992
25196
  break;
24993
25197
  }
24994
- returnValue = retryOnPromise(() => {
24995
- if (target.$computeIfNeeded$() || forceRunEffects) {
24996
- triggerEffects(container, target, target.$effects$);
25198
+ case 7 /* RECOMPUTE_AND_SCHEDULE_EFFECTS */: {
25199
+ {
25200
+ const target = chore.$target$;
25201
+ const forceRunEffects = target.$forceRunEffects$;
25202
+ target.$forceRunEffects$ = false;
25203
+ if (!target.$effects$?.size) {
25204
+ break;
25205
+ }
25206
+ returnValue = retryOnPromise(() => {
25207
+ if (target.$computeIfNeeded$() || forceRunEffects) {
25208
+ triggerEffects(container, target, target.$effects$);
25209
+ }
25210
+ });
24997
25211
  }
24998
- });
24999
- break;
25212
+ break;
25213
+ }
25000
25214
  }
25215
+ } catch (e) {
25216
+ returnValue = Promise.reject(e);
25001
25217
  }
25002
- return maybeThenPassError(returnValue, (value) => {
25003
- DEBUG2 && debugTrace("execute.DONE", null, currentChore, choreQueue);
25004
- if (currentChore) {
25005
- currentChore.$executed$ = true;
25006
- currentChore.$resolve$?.(value);
25007
- }
25218
+ const after = (value, error) => {
25008
25219
  currentChore = null;
25009
- return chore.$returnValue$ = value;
25010
- });
25011
- }
25012
- };
25013
- var toNumber = (value) => {
25014
- return typeof value === "number" ? value : -1;
25015
- };
25016
- var choreUpdate = (existing, newChore) => {
25017
- if (existing.$type$ === 4 /* NODE_DIFF */) {
25018
- existing.$payload$ = newChore.$payload$;
25019
- }
25020
- };
25021
- function vNodeAlreadyDeleted(chore) {
25022
- return !!(chore.$host$ && vnode_isVNode(chore.$host$) && chore.$host$[0 /* flags */] & 32 /* Deleted */);
25023
- }
25024
- function choreComparator(a, b, rootVNode) {
25025
- const macroTypeDiff = (a.$type$ & 240 /* MACRO */) - (b.$type$ & 240 /* MACRO */);
25026
- if (macroTypeDiff !== 0) {
25027
- return macroTypeDiff;
25220
+ chore.$executed$ = true;
25221
+ if (error) {
25222
+ DEBUG2 && debugTrace("execute.ERROR", chore, currentChore, choreQueue);
25223
+ container.handleError(error, host);
25224
+ } else {
25225
+ chore.$returnValue$ = value;
25226
+ DEBUG2 && debugTrace("execute.DONE", chore, currentChore, choreQueue);
25227
+ chore.$resolve$?.(value);
25228
+ }
25229
+ };
25230
+ if (isPromise(returnValue)) {
25231
+ chore.$promise$ = returnValue.then(after, (error) => after(void 0, error));
25232
+ chore.$resolve$?.(chore.$promise$);
25233
+ chore.$resolve$ = void 0;
25234
+ } else {
25235
+ after(returnValue);
25236
+ }
25028
25237
  }
25029
- if (a.$type$ !== 16 /* JOURNAL_FLUSH */) {
25238
+ function choreComparator(a, b, rootVNode) {
25239
+ const macroTypeDiff = (a.$type$ & 240 /* MACRO */) - (b.$type$ & 240 /* MACRO */);
25240
+ if (macroTypeDiff !== 0) {
25241
+ return macroTypeDiff;
25242
+ }
25030
25243
  const aHost = a.$host$;
25031
25244
  const bHost = b.$host$;
25032
25245
  if (aHost !== bHost && aHost !== null && bHost !== null) {
@@ -25036,6 +25249,8 @@ function choreComparator(a, b, rootVNode) {
25036
25249
  return hostDiff;
25037
25250
  }
25038
25251
  } else {
25252
+ assertFalse(vnode_isVNode(aHost), "expected aHost to be SSRNode but it is a VNode");
25253
+ assertFalse(vnode_isVNode(bHost), "expected bHost to be SSRNode but it is a VNode");
25039
25254
  const errorMessage = `SERVER: during HTML streaming, re-running tasks on a different host is not allowed.
25040
25255
  You are attempting to change a state that has already been streamed to the client.
25041
25256
  This can lead to inconsistencies between Server-Side Rendering (SSR) and Client-Side Rendering (CSR).
@@ -25055,165 +25270,89 @@ function choreComparator(a, b, rootVNode) {
25055
25270
  if (idxDiff !== 0) {
25056
25271
  return idxDiff;
25057
25272
  }
25058
- if (a.$target$ !== b.$target$ && (a.$type$ === 1 /* QRL_RESOLVE */ && b.$type$ === 1 /* QRL_RESOLVE */ || a.$type$ === 5 /* NODE_PROP */ && b.$type$ === 5 /* NODE_PROP */ || a.$type$ === 8 /* RECOMPUTE_AND_SCHEDULE_EFFECTS */ && b.$type$ === 8 /* RECOMPUTE_AND_SCHEDULE_EFFECTS */)) {
25273
+ if (a.$target$ !== b.$target$ || a.$payload$ !== b.$payload$) {
25059
25274
  return 1;
25060
25275
  }
25061
- }
25062
- return 0;
25063
- }
25064
- function sortedFindIndex(sortedArray, value, rootVNode) {
25065
- let bottom = 0;
25066
- let top = sortedArray.length;
25067
- while (bottom < top) {
25068
- const middle = bottom + (top - bottom >> 1);
25069
- const midChore = sortedArray[middle];
25070
- const comp = choreComparator(value, midChore, rootVNode);
25071
- if (comp < 0) {
25072
- top = middle;
25073
- } else if (comp > 0) {
25074
- bottom = middle + 1;
25075
- } else {
25076
- return middle;
25276
+ if (b === currentChore) {
25277
+ return 1;
25077
25278
  }
25279
+ return 0;
25078
25280
  }
25079
- return ~bottom;
25080
- }
25081
- function sortedInsert(sortedArray, value, rootVNode) {
25082
- const idx = sortedFindIndex(sortedArray, value, rootVNode);
25083
- if (idx < 0) {
25084
- sortedArray.splice(~idx, 0, value);
25085
- return value;
25086
- }
25087
- const existing = sortedArray[idx];
25088
- choreUpdate(existing, value);
25089
- return existing;
25090
- }
25091
- function debugChoreToString(chore) {
25092
- const type = {
25093
- [1 /* QRL_RESOLVE */]: "QRL_RESOLVE",
25094
- [2 /* RESOURCE */]: "RESOURCE",
25095
- [3 /* TASK */]: "TASK",
25096
- [4 /* NODE_DIFF */]: "NODE_DIFF",
25097
- [5 /* NODE_PROP */]: "NODE_PROP",
25098
- [7 /* COMPONENT */]: "COMPONENT",
25099
- [6 /* COMPONENT_SSR */]: "COMPONENT_SSR",
25100
- [8 /* RECOMPUTE_AND_SCHEDULE_EFFECTS */]: "RECOMPUTE_SIGNAL",
25101
- [16 /* JOURNAL_FLUSH */]: "JOURNAL_FLUSH",
25102
- [32 /* VISIBLE */]: "VISIBLE",
25103
- [48 /* CLEANUP_VISIBLE */]: "CLEANUP_VISIBLE",
25104
- [255 /* WAIT_FOR_ALL */]: "WAIT_FOR_ALL"
25105
- }[chore.$type$] || "UNKNOWN: " + chore.$type$;
25106
- const host = String(chore.$host$).replaceAll(/\n.*/gim, "");
25107
- const qrlTarget = chore.$target$?.$symbol$;
25108
- return `Chore(${type} ${chore.$type$ === 1 /* QRL_RESOLVE */ ? qrlTarget : host} ${chore.$idx$})`;
25109
- }
25110
- function debugTrace(action, arg, currentChore, queue) {
25111
- const lines = ["Scheduler: " + action];
25112
- if (arg) {
25113
- lines.push(
25114
- " arg: " + ("$type$" in arg ? debugChoreToString(arg) : String(arg).replaceAll(/\n.*/gim, ""))
25115
- );
25116
- }
25117
- if (currentChore) {
25118
- lines.push("running: " + debugChoreToString(currentChore));
25119
- }
25120
- if (queue) {
25121
- queue.forEach((chore, idx) => {
25122
- lines.push((idx == 0 ? " queue: " : " ") + debugChoreToString(chore));
25123
- });
25124
- }
25125
- console.log(lines.join("\n ") + "\n");
25126
- }
25127
-
25128
- // packages/qwik/src/core/use/use-task.ts
25129
- var runTask = (task, container, host) => {
25130
- task.$flags$ &= ~8 /* DIRTY */;
25131
- cleanupTask(task);
25132
- const iCtx = newInvokeContext(container.$locale$, host, void 0, TaskEvent);
25133
- iCtx.$container$ = container;
25134
- const taskFn = task.$qrl$.getFn(
25135
- iCtx,
25136
- () => clearSubscriberEffectDependencies(container, task)
25137
- );
25138
- const track = (obj, prop) => {
25139
- const ctx = newInvokeContext();
25140
- ctx.$effectSubscriber$ = [task, ":" /* COMPONENT */];
25141
- ctx.$container$ = container;
25142
- return invoke(ctx, () => {
25143
- if (isFunction(obj)) {
25144
- return obj();
25145
- }
25146
- if (prop) {
25147
- return obj[prop];
25148
- } else if (isSignal(obj)) {
25149
- return obj.value;
25281
+ function sortedFindIndex(sortedArray, value, rootVNode) {
25282
+ let bottom = 0;
25283
+ let top = sortedArray.length;
25284
+ while (bottom < top) {
25285
+ const middle = bottom + (top - bottom >> 1);
25286
+ const midChore = sortedArray[middle];
25287
+ const comp = choreComparator(value, midChore, rootVNode);
25288
+ if (comp < 0) {
25289
+ top = middle;
25290
+ } else if (comp > 0) {
25291
+ bottom = middle + 1;
25150
25292
  } else {
25151
- return obj;
25293
+ return middle;
25152
25294
  }
25153
- });
25154
- };
25155
- const handleError = (reason) => container.handleError(reason, host);
25156
- let cleanupFns = null;
25157
- const cleanup2 = (fn) => {
25158
- if (typeof fn == "function") {
25159
- if (!cleanupFns) {
25160
- cleanupFns = [];
25161
- task.$destroy$ = noSerialize(() => {
25162
- task.$destroy$ = null;
25163
- cleanupFns.forEach((fn2) => {
25164
- try {
25165
- fn2();
25166
- } catch (err) {
25167
- handleError(err);
25168
- }
25169
- });
25170
- });
25171
- }
25172
- cleanupFns.push(fn);
25173
25295
  }
25174
- };
25175
- const taskApi = { track, cleanup: cleanup2 };
25176
- const result = safeCall(
25177
- () => taskFn(taskApi),
25178
- cleanup2,
25179
- (err) => {
25180
- if (isPromise(err)) {
25181
- return err.then(() => runTask(task, container, host));
25182
- } else {
25183
- return handleError(err);
25184
- }
25296
+ return ~bottom;
25297
+ }
25298
+ function sortedInsert(sortedArray, value, rootVNode) {
25299
+ const idx = sortedFindIndex(sortedArray, value, rootVNode);
25300
+ if (idx < 0) {
25301
+ sortedArray.splice(~idx, 0, value);
25302
+ return value;
25185
25303
  }
25186
- );
25187
- return result;
25188
- };
25189
- var cleanupTask = (task) => {
25190
- const destroy = task.$destroy$;
25191
- if (destroy) {
25192
- task.$destroy$ = null;
25193
- try {
25194
- destroy();
25195
- } catch (err) {
25196
- logError(err);
25304
+ const existing = sortedArray[idx];
25305
+ if (existing.$type$ === 4 /* NODE_DIFF */) {
25306
+ existing.$payload$ = value.$payload$;
25307
+ }
25308
+ if (existing.$executed$) {
25309
+ existing.$executed$ = false;
25197
25310
  }
25311
+ return existing;
25198
25312
  }
25199
25313
  };
25200
- var Task = class extends Subscriber {
25201
- constructor($flags$, $index$, $el$, $qrl$, $state$, $destroy$) {
25202
- super();
25203
- this.$flags$ = $flags$;
25204
- this.$index$ = $index$;
25205
- this.$el$ = $el$;
25206
- this.$qrl$ = $qrl$;
25207
- this.$state$ = $state$;
25208
- this.$destroy$ = $destroy$;
25209
- }
25210
- };
25211
- var isTask = (value) => {
25212
- return value instanceof Task;
25314
+ var toNumber = (value) => {
25315
+ return typeof value === "number" ? value : -1;
25213
25316
  };
25214
-
25215
- // packages/qwik/src/core/signal/flags.ts
25216
- var NEEDS_COMPUTATION = Symbol("invalid");
25317
+ function vNodeAlreadyDeleted(chore) {
25318
+ return !!(chore.$host$ && vnode_isVNode(chore.$host$) && chore.$host$[0 /* flags */] & 32 /* Deleted */);
25319
+ }
25320
+ function debugChoreTypeToString(type) {
25321
+ return {
25322
+ [1 /* QRL_RESOLVE */]: "QRL_RESOLVE",
25323
+ [2 /* RUN_QRL */]: "RUN_QRL",
25324
+ [3 /* TASK */]: "TASK",
25325
+ [4 /* NODE_DIFF */]: "NODE_DIFF",
25326
+ [5 /* NODE_PROP */]: "NODE_PROP",
25327
+ [6 /* COMPONENT */]: "COMPONENT",
25328
+ [7 /* RECOMPUTE_AND_SCHEDULE_EFFECTS */]: "RECOMPUTE_SIGNAL",
25329
+ [16 /* JOURNAL_FLUSH */]: "JOURNAL_FLUSH",
25330
+ [32 /* VISIBLE */]: "VISIBLE",
25331
+ [48 /* CLEANUP_VISIBLE */]: "CLEANUP_VISIBLE",
25332
+ [255 /* WAIT_FOR_ALL */]: "WAIT_FOR_ALL"
25333
+ }[type] || "UNKNOWN: " + type;
25334
+ }
25335
+ function debugChoreToString(chore) {
25336
+ const type = debugChoreTypeToString(chore.$type$);
25337
+ const host = String(chore.$host$).replaceAll(/\n.*/gim, "");
25338
+ const qrlTarget = chore.$target$?.$symbol$;
25339
+ return `Chore(${type} ${chore.$type$ === 1 /* QRL_RESOLVE */ || chore.$type$ === 2 /* RUN_QRL */ ? qrlTarget : host} ${chore.$idx$})`;
25340
+ }
25341
+ function debugTrace(action, arg, currentChore, queue) {
25342
+ const lines = ["===========================\nScheduler: " + action];
25343
+ if (arg && !("$type$" in arg)) {
25344
+ lines.push(" arg: " + String(arg).replaceAll(/\n.*/gim, ""));
25345
+ }
25346
+ if (queue) {
25347
+ queue.forEach((chore) => {
25348
+ const active = chore === arg ? ">>>" : " ";
25349
+ lines.push(
25350
+ ` ${active} > ` + (chore === currentChore ? "[running] " : "") + debugChoreToString(chore)
25351
+ );
25352
+ });
25353
+ }
25354
+ console.log(lines.join("\n") + "\n");
25355
+ }
25217
25356
 
25218
25357
  // packages/qwik/src/core/signal/signal.ts
25219
25358
  var DEBUG3 = false;
@@ -25227,7 +25366,7 @@ var throwIfQRLNotResolved = (qrl2) => {
25227
25366
  var isSignal = (value) => {
25228
25367
  return value instanceof Signal;
25229
25368
  };
25230
- var EffectPropData = class {
25369
+ var SubscriptionData = class {
25231
25370
  constructor(data) {
25232
25371
  __publicField(this, "data");
25233
25372
  this.data = data;
@@ -25266,16 +25405,10 @@ var Signal = class {
25266
25405
  }
25267
25406
  const effectSubscriber = ctx.$effectSubscriber$;
25268
25407
  if (effectSubscriber) {
25269
- const effects = this.$effects$ || (this.$effects$ = []);
25270
- ensureContainsEffect(effects, effectSubscriber);
25271
- ensureContains(effectSubscriber, this);
25272
- if (isSubscriber(this)) {
25273
- ensureEffectContainsSubscriber(
25274
- effectSubscriber[0 /* EFFECT */],
25275
- this,
25276
- this.$container$
25277
- );
25278
- }
25408
+ const effects = this.$effects$ || (this.$effects$ = /* @__PURE__ */ new Set());
25409
+ ensureContainsSubscription(effects, effectSubscriber);
25410
+ ensureContainsBackRef(effectSubscriber, this);
25411
+ addQrlToSerializationCtx(effectSubscriber, this.$container$);
25279
25412
  DEBUG3 && log2("read->sub", pad("\n" + this.toString(), " "));
25280
25413
  }
25281
25414
  }
@@ -25295,114 +25428,86 @@ var Signal = class {
25295
25428
  }
25296
25429
  }
25297
25430
  toString() {
25298
- return `[${this.constructor.name}${this.$invalid$ ? " INVALID" : ""} ${String(this.$untrackedValue$)}]` + (this.$effects$?.map((e) => "\n -> " + pad(qwikDebugToString(e[0]), " ")).join("\n") || "");
25431
+ return `[${this.constructor.name}${this.$invalid$ ? " INVALID" : ""} ${String(this.$untrackedValue$)}]` + (Array.from(this.$effects$ || []).map((e) => "\n -> " + pad(qwikDebugToString(e[0]), " ")).join("\n") || "");
25299
25432
  }
25300
25433
  toJSON() {
25301
25434
  return { value: this.$untrackedValue$ };
25302
25435
  }
25303
25436
  };
25304
- var ensureContains = (array, value) => {
25305
- const isMissing = array.indexOf(value) === -1;
25306
- if (isMissing) {
25307
- array.push(value);
25308
- }
25309
- };
25310
- var ensureContainsEffect = (array, effectSubscriptions) => {
25311
- for (let i = 0; i < array.length; i++) {
25312
- const existingEffect = array[i];
25313
- if (existingEffect[0] === effectSubscriptions[0] && existingEffect[1] === effectSubscriptions[1]) {
25314
- return;
25315
- }
25316
- }
25317
- array.push(effectSubscriptions);
25318
- };
25319
- var ensureEffectContainsSubscriber = (effect, subscriber, container) => {
25320
- if (isSubscriber(effect)) {
25321
- effect.$effectDependencies$ || (effect.$effectDependencies$ = []);
25322
- if (subscriberExistInSubscribers(effect.$effectDependencies$, subscriber)) {
25323
- return;
25324
- }
25325
- effect.$effectDependencies$.push(subscriber);
25326
- } else if (vnode_isVNode(effect) && !vnode_isTextVNode(effect)) {
25327
- let subscribers = vnode_getProp(
25328
- effect,
25329
- QSubscribers,
25330
- container ? container.$getObjectById$ : null
25331
- );
25332
- subscribers || (subscribers = []);
25333
- if (subscriberExistInSubscribers(subscribers, subscriber)) {
25334
- return;
25335
- }
25336
- subscribers.push(subscriber);
25337
- vnode_setProp(effect, QSubscribers, subscribers);
25338
- } else if (isSSRNode(effect)) {
25339
- let subscribers = effect.getProp(QSubscribers);
25340
- subscribers || (subscribers = []);
25341
- if (subscriberExistInSubscribers(subscribers, subscriber)) {
25342
- return;
25343
- }
25344
- subscribers.push(subscriber);
25345
- effect.setProp(QSubscribers, subscribers);
25346
- }
25437
+ var ensureContainsSubscription = (array, effectSubscription) => {
25438
+ array.add(effectSubscription);
25347
25439
  };
25348
- var isSSRNode = (effect) => {
25349
- return "setProp" in effect && "getProp" in effect && "removeProp" in effect && "id" in effect;
25440
+ var ensureContainsBackRef = (array, value) => {
25441
+ var _a3;
25442
+ array[_a3 = 2 /* BACK_REF */] || (array[_a3] = /* @__PURE__ */ new Set());
25443
+ array[2 /* BACK_REF */].add(value);
25350
25444
  };
25351
- var subscriberExistInSubscribers = (subscribers, subscriber) => {
25352
- for (let i = 0; i < subscribers.length; i++) {
25353
- if (subscribers[i] === subscriber) {
25354
- return true;
25445
+ var addQrlToSerializationCtx = (effectSubscriber, container) => {
25446
+ if (!!container && !isDomContainer(container)) {
25447
+ const effect = effectSubscriber[0 /* CONSUMER */];
25448
+ const property = effectSubscriber[1 /* PROPERTY */];
25449
+ let qrl2 = null;
25450
+ if (isTask(effect)) {
25451
+ qrl2 = effect.$qrl$;
25452
+ } else if (effect instanceof ComputedSignal) {
25453
+ qrl2 = effect.$computeQrl$;
25454
+ } else if (property === ":" /* COMPONENT */) {
25455
+ qrl2 = container.getHostProp(effect, OnRenderProp);
25456
+ }
25457
+ if (qrl2) {
25458
+ container.serializationCtx.$eventQrls$.add(qrl2);
25355
25459
  }
25356
25460
  }
25357
- return false;
25358
25461
  };
25359
25462
  var triggerEffects = (container, signal, effects) => {
25463
+ const isBrowser2 = isDomContainer(container);
25360
25464
  if (effects) {
25361
- const scheduleEffect = (effectSubscriptions) => {
25362
- const effect = effectSubscriptions[0 /* EFFECT */];
25363
- const property = effectSubscriptions[1 /* PROPERTY */];
25465
+ const scheduleEffect = (effectSubscription) => {
25466
+ const consumer = effectSubscription[0 /* CONSUMER */];
25467
+ const property = effectSubscription[1 /* PROPERTY */];
25364
25468
  assertDefined(container, "Container must be defined.");
25365
- if (isTask(effect)) {
25366
- effect.$flags$ |= 8 /* DIRTY */;
25367
- DEBUG3 && log2("schedule.effect.task", pad("\n" + String(effect), " "));
25469
+ if (isTask(consumer)) {
25470
+ consumer.$flags$ |= 8 /* DIRTY */;
25471
+ DEBUG3 && log2("schedule.consumer.task", pad("\n" + String(consumer), " "));
25368
25472
  let choreType = 3 /* TASK */;
25369
- if (effect.$flags$ & 1 /* VISIBLE_TASK */) {
25473
+ if (consumer.$flags$ & 1 /* VISIBLE_TASK */) {
25370
25474
  choreType = 32 /* VISIBLE */;
25371
- } else if (effect.$flags$ & 4 /* RESOURCE */) {
25372
- choreType = 2 /* RESOURCE */;
25373
25475
  }
25374
- container.$scheduler$(choreType, effect);
25375
- } else if (effect instanceof Signal) {
25376
- if (effect instanceof ComputedSignal) {
25377
- if (!effect.$computeQrl$.resolved) {
25378
- container.$scheduler$(1 /* QRL_RESOLVE */, null, effect.$computeQrl$);
25476
+ container.$scheduler$(choreType, consumer);
25477
+ } else if (consumer instanceof Signal) {
25478
+ if (consumer instanceof ComputedSignal) {
25479
+ if (!consumer.$computeQrl$.resolved) {
25480
+ container.$scheduler$(1 /* QRL_RESOLVE */, null, consumer.$computeQrl$);
25379
25481
  }
25380
25482
  }
25381
- effect.$invalidate$();
25483
+ consumer.$invalidate$();
25382
25484
  } else if (property === ":" /* COMPONENT */) {
25383
- const host = effect;
25485
+ const host = consumer;
25384
25486
  const qrl2 = container.getHostProp(host, OnRenderProp);
25385
25487
  assertDefined(qrl2, "Component must have QRL");
25386
25488
  const props = container.getHostProp(host, ELEMENT_PROPS);
25387
- container.$scheduler$(7 /* COMPONENT */, host, qrl2, props);
25388
- } else if (property === "." /* VNODE */) {
25389
- const host = effect;
25390
- const target = host;
25391
- container.$scheduler$(4 /* NODE_DIFF */, host, target, signal);
25392
- } else {
25393
- const host = effect;
25394
- const effectData = effectSubscriptions[2 /* FIRST_BACK_REF_OR_DATA */];
25395
- if (effectData instanceof EffectPropData) {
25396
- const data = effectData.data;
25397
- const payload = {
25398
- ...data,
25399
- $value$: signal
25400
- };
25401
- container.$scheduler$(5 /* NODE_PROP */, host, property, payload);
25489
+ container.$scheduler$(6 /* COMPONENT */, host, qrl2, props);
25490
+ } else if (isBrowser2) {
25491
+ if (property === "." /* VNODE */) {
25492
+ const host = consumer;
25493
+ container.$scheduler$(4 /* NODE_DIFF */, host, host, signal);
25494
+ } else {
25495
+ const host = consumer;
25496
+ const effectData = effectSubscription[3 /* DATA */];
25497
+ if (effectData instanceof SubscriptionData) {
25498
+ const data = effectData.data;
25499
+ const payload = {
25500
+ ...data,
25501
+ $value$: signal
25502
+ };
25503
+ container.$scheduler$(5 /* NODE_PROP */, host, property, payload);
25504
+ }
25402
25505
  }
25403
25506
  }
25404
25507
  };
25405
- effects.forEach(scheduleEffect);
25508
+ for (const effect of effects) {
25509
+ scheduleEffect(effect);
25510
+ }
25406
25511
  }
25407
25512
  DEBUG3 && log2("done scheduling");
25408
25513
  };
@@ -25425,7 +25530,7 @@ var ComputedSignal = class extends Signal {
25425
25530
  $invalidate$() {
25426
25531
  this.$invalid$ = true;
25427
25532
  this.$forceRunEffects$ = false;
25428
- this.$container$?.$scheduler$(8 /* RECOMPUTE_AND_SCHEDULE_EFFECTS */, null, this);
25533
+ this.$container$?.$scheduler$(7 /* RECOMPUTE_AND_SCHEDULE_EFFECTS */, null, this);
25429
25534
  }
25430
25535
  /**
25431
25536
  * Use this to force running subscribers, for example when the calculated value has mutated but
@@ -25452,7 +25557,7 @@ var ComputedSignal = class extends Signal {
25452
25557
  throwIfQRLNotResolved(computeQrl);
25453
25558
  const ctx = tryGetInvokeContext();
25454
25559
  const previousEffectSubscription = ctx?.$effectSubscriber$;
25455
- ctx && (ctx.$effectSubscriber$ = [this, "." /* VNODE */]);
25560
+ ctx && (ctx.$effectSubscriber$ = getSubscriber(this, "." /* VNODE */));
25456
25561
  try {
25457
25562
  const untrackedValue = computeQrl.getFn(ctx)();
25458
25563
  if (isPromise(untrackedValue)) {
@@ -25482,7 +25587,8 @@ var ComputedSignal = class extends Signal {
25482
25587
  throw qError(47 /* computedReadOnly */);
25483
25588
  }
25484
25589
  };
25485
- var WrappedSignal = class extends Signal {
25590
+ var _a2, _b;
25591
+ var WrappedSignal = class extends (_b = Signal, _a2 = _EFFECT_BACK_REF, _b) {
25486
25592
  constructor(container, fn, args, fnStr) {
25487
25593
  super(container, NEEDS_COMPUTATION);
25488
25594
  __publicField(this, "$args$");
@@ -25491,9 +25597,9 @@ var WrappedSignal = class extends Signal {
25491
25597
  // We need a separate flag to know when the computation needs running because
25492
25598
  // we need the old value to know if effects need running after computation
25493
25599
  __publicField(this, "$invalid$", true);
25494
- __publicField(this, "$effectDependencies$", null);
25495
25600
  __publicField(this, "$hostElement$", null);
25496
25601
  __publicField(this, "$forceRunEffects$", false);
25602
+ __publicField(this, _a2, null);
25497
25603
  this.$args$ = args;
25498
25604
  this.$func$ = fn;
25499
25605
  this.$funcStr$ = fnStr;
@@ -25502,7 +25608,7 @@ var WrappedSignal = class extends Signal {
25502
25608
  this.$invalid$ = true;
25503
25609
  this.$forceRunEffects$ = false;
25504
25610
  this.$container$?.$scheduler$(
25505
- 8 /* RECOMPUTE_AND_SCHEDULE_EFFECTS */,
25611
+ 7 /* RECOMPUTE_AND_SCHEDULE_EFFECTS */,
25506
25612
  this.$hostElement$,
25507
25613
  this
25508
25614
  );
@@ -25591,16 +25697,6 @@ var _SharedContainer = class {
25591
25697
  }
25592
25698
  };
25593
25699
 
25594
- // packages/qwik/src/core/shared/utils/constants.ts
25595
- var QObjectRecursive = 1 << 0;
25596
- var QObjectImmutable = 1 << 1;
25597
- var QObjectTargetSymbol = Symbol("proxy target");
25598
- var QObjectFlagsSymbol = Symbol("proxy flags");
25599
- var QObjectManagerSymbol = Symbol("proxy manager");
25600
- var _CONST_PROPS = Symbol("CONST");
25601
- var _VAR_PROPS = Symbol("VAR");
25602
- var _IMMUTABLE = Symbol("IMMUTABLE");
25603
-
25604
25700
  // packages/qwik/src/core/shared-types.ts
25605
25701
  function isStringifiable(value) {
25606
25702
  return value === null || typeof value === "string" || typeof value === "number" || typeof value === "boolean";
@@ -25792,7 +25888,7 @@ function qwikDebugToString(value) {
25792
25888
  return String(value);
25793
25889
  } else if (isTask(value)) {
25794
25890
  return `Task(${qwikDebugToString(value.$qrl$)})`;
25795
- } else if (isQrl(value)) {
25891
+ } else if (isQrl2(value)) {
25796
25892
  return `Qrl(${value.$symbol$})`;
25797
25893
  } else if (typeof value === "object" || typeof value === "function") {
25798
25894
  if (stringifyPath.includes(value)) {
@@ -26121,13 +26217,13 @@ var VNodeDataChar = {
26121
26217
  /* **** */
26122
26218
  "^"
26123
26219
  ),
26124
- SUBS: (
26125
- /* *************** */
26220
+ BACK_REFS: (
26221
+ /* ********** */
26126
26222
  96
26127
26223
  ),
26128
- // '`' - `q:subs' - Effect dependencies/subscriptions
26129
- SUBS_CHAR: (
26130
- /* ******* */
26224
+ // '`' - `q:brefs' - Effect dependencies/subscriptions
26225
+ BACK_REFS_CHAR: (
26226
+ /* ** */
26131
26227
  "`"
26132
26228
  ),
26133
26229
  SEPARATOR: (
@@ -26150,6 +26246,14 @@ var VNodeDataChar = {
26150
26246
  )
26151
26247
  };
26152
26248
 
26249
+ // packages/qwik/src/core/shared/utils/maps.ts
26250
+ var mergeMaps = (map1, map2) => {
26251
+ for (const [k, v] of map2) {
26252
+ map1.set(k, v);
26253
+ }
26254
+ return map1;
26255
+ };
26256
+
26153
26257
  // packages/qwik/src/core/client/vnode.ts
26154
26258
  var vnode_newElement = (element, elementName) => {
26155
26259
  assertEqual(fastNodeType(element), 1, "Expecting element node.");
@@ -26311,6 +26415,7 @@ var vnode_ensureElementInflated = (vnode) => {
26311
26415
  elementVNode[0 /* flags */] ^= 8 /* Inflated */;
26312
26416
  const element = elementVNode[6 /* element */];
26313
26417
  const attributes = element.attributes;
26418
+ const props = vnode_getProps(elementVNode);
26314
26419
  for (let idx = 0; idx < attributes.length; idx++) {
26315
26420
  const attr = attributes[idx];
26316
26421
  const key = attr.name;
@@ -26318,23 +26423,13 @@ var vnode_ensureElementInflated = (vnode) => {
26318
26423
  break;
26319
26424
  } else if (key.startsWith(QContainerAttr)) {
26320
26425
  if (attr.value === "html" /* HTML */) {
26321
- mapArray_set(
26322
- elementVNode,
26323
- dangerouslySetInnerHTML,
26324
- element.innerHTML,
26325
- 8 /* PROPS_OFFSET */
26326
- );
26426
+ mapArray_set(props, dangerouslySetInnerHTML, element.innerHTML, 0);
26327
26427
  } else if (attr.value === "text" /* TEXT */ && "value" in element) {
26328
- mapArray_set(
26329
- elementVNode,
26330
- "value",
26331
- element.value,
26332
- 8 /* PROPS_OFFSET */
26333
- );
26428
+ mapArray_set(props, "value", element.value, 0);
26334
26429
  }
26335
26430
  } else if (!key.startsWith("on:")) {
26336
26431
  const value = attr.value;
26337
- mapArray_set(elementVNode, key, value, 8 /* PROPS_OFFSET */);
26432
+ mapArray_set(props, key, value, 0);
26338
26433
  }
26339
26434
  }
26340
26435
  }
@@ -26662,59 +26757,14 @@ var vnode_applyJournal = (journal) => {
26662
26757
  }
26663
26758
  journal.length = 0;
26664
26759
  };
26665
- var mapApp_findIndx = (elementVNode, key, start) => {
26666
- assertTrue(start % 2 === 0, "Expecting even number.");
26667
- let bottom = start >> 1;
26668
- let top = elementVNode.length - 2 >> 1;
26669
- while (bottom <= top) {
26670
- const mid = bottom + (top - bottom >> 1);
26671
- const midKey = elementVNode[mid << 1];
26672
- if (midKey === key) {
26673
- return mid << 1;
26674
- }
26675
- if (midKey < key) {
26676
- bottom = mid + 1;
26677
- } else {
26678
- top = mid - 1;
26679
- }
26680
- }
26681
- return bottom << 1 ^ -1;
26682
- };
26683
- var mapArray_set = (elementVNode, key, value, start) => {
26684
- const indx = mapApp_findIndx(elementVNode, key, start);
26685
- if (indx >= 0) {
26686
- if (value == null) {
26687
- elementVNode.splice(indx, 2);
26688
- } else {
26689
- elementVNode[indx + 1] = value;
26690
- }
26691
- } else if (value != null) {
26692
- elementVNode.splice(indx ^ -1, 0, key, value);
26693
- }
26694
- };
26695
- var mapApp_remove = (elementVNode, key, start) => {
26696
- const indx = mapApp_findIndx(elementVNode, key, start);
26697
- let value = null;
26698
- if (indx >= 0) {
26699
- value = elementVNode[indx + 1];
26700
- elementVNode.splice(indx, 2);
26701
- return value;
26702
- }
26703
- return value;
26704
- };
26705
- var mapArray_get = (elementVNode, key, start) => {
26706
- const indx = mapApp_findIndx(elementVNode, key, start);
26707
- if (indx >= 0) {
26708
- return elementVNode[indx + 1];
26709
- } else {
26710
- return null;
26711
- }
26712
- };
26713
26760
  var vnode_insertBefore = (journal, parent, newChild, insertBefore) => {
26714
26761
  ensureElementOrVirtualVNode(parent);
26715
26762
  if (vnode_isElementVNode(parent)) {
26716
26763
  ensureMaterialized(parent);
26717
26764
  }
26765
+ if (newChild === insertBefore) {
26766
+ insertBefore = null;
26767
+ }
26718
26768
  let adjustedInsertBefore = null;
26719
26769
  if (insertBefore == null) {
26720
26770
  if (vnode_isVirtualVNode(parent)) {
@@ -26817,8 +26867,10 @@ var vnode_getElementName = (vnode) => {
26817
26867
  const elementVNode = ensureElementVNode(vnode);
26818
26868
  let elementName = elementVNode[7 /* elementName */];
26819
26869
  if (elementName === void 0) {
26820
- elementName = elementVNode[7 /* elementName */] = elementVNode[6 /* element */].nodeName.toLowerCase();
26821
- elementVNode[0 /* flags */] |= vnode_getElementNamespaceFlags(elementName);
26870
+ const element = elementVNode[6 /* element */];
26871
+ const nodeName = isDev7 ? fastNodeName(element).toLowerCase() : fastNodeName(element);
26872
+ elementName = elementVNode[7 /* elementName */] = nodeName;
26873
+ elementVNode[0 /* flags */] |= vnode_getElementNamespaceFlags(element);
26822
26874
  }
26823
26875
  return elementName;
26824
26876
  };
@@ -26984,6 +27036,20 @@ var fastFirstChild = (node) => {
26984
27036
  }
26985
27037
  return node;
26986
27038
  };
27039
+ var _fastNamespaceURI = null;
27040
+ var fastNamespaceURI = (element) => {
27041
+ if (!_fastNamespaceURI) {
27042
+ _fastNamespaceURI = fastGetter(element, "namespaceURI");
27043
+ }
27044
+ return _fastNamespaceURI.call(element);
27045
+ };
27046
+ var _fastNodeName = null;
27047
+ var fastNodeName = (element) => {
27048
+ if (!_fastNodeName) {
27049
+ _fastNodeName = fastGetter(element, "nodeName");
27050
+ }
27051
+ return _fastNodeName.call(element);
27052
+ };
26987
27053
  var fastGetter = (prototype, name) => {
26988
27054
  let getter;
26989
27055
  while (prototype && !(getter = Object.getOwnPropertyDescriptor(prototype, name)?.get)) {
@@ -27039,9 +27105,12 @@ var materializeFromDOM = (vParent, firstChild, vData) => {
27039
27105
  }
27040
27106
  const id = consumeValue();
27041
27107
  container.$setRawState$(parseInt(id), vParent);
27042
- isDev6 && vnode_setAttr(null, vParent, ELEMENT_ID, id);
27043
- } else if (peek() === VNodeDataChar.SUBS) {
27044
- vnode_setProp(vParent, QSubscribers, consumeValue());
27108
+ isDev7 && vnode_setAttr(null, vParent, ELEMENT_ID, id);
27109
+ } else if (peek() === VNodeDataChar.BACK_REFS) {
27110
+ if (!container) {
27111
+ container = getDomContainer(vParent[6 /* element */]);
27112
+ }
27113
+ setEffectBackRefFromVNodeData(vParent, consumeValue(), container);
27045
27114
  } else {
27046
27115
  consumeValue();
27047
27116
  }
@@ -27049,6 +27118,17 @@ var materializeFromDOM = (vParent, firstChild, vData) => {
27049
27118
  }
27050
27119
  return vFirstChild;
27051
27120
  };
27121
+ function setEffectBackRefFromVNodeData(vParent, value, container) {
27122
+ const deserializedSubMap = container.$getObjectById$(value);
27123
+ if (!vParent[_EFFECT_BACK_REF]) {
27124
+ Object.defineProperty(vParent, _EFFECT_BACK_REF, {
27125
+ value: deserializedSubMap
27126
+ });
27127
+ } else {
27128
+ const subMap = vParent[_EFFECT_BACK_REF];
27129
+ mergeMaps(subMap, deserializedSubMap);
27130
+ }
27131
+ }
27052
27132
  var processVNodeData = (vData, callback) => {
27053
27133
  let nextToConsumeIdx = 0;
27054
27134
  let ch = 0;
@@ -27089,8 +27169,9 @@ var vnode_getAttrKeys = (vnode) => {
27089
27169
  if ((type & 3 /* ELEMENT_OR_VIRTUAL_MASK */) !== 0) {
27090
27170
  vnode_ensureElementInflated(vnode);
27091
27171
  const keys = [];
27092
- for (let i = vnode_getPropStartIndex(vnode); i < vnode.length; i = i + 2) {
27093
- const key = vnode[i];
27172
+ const props = vnode_getProps(vnode);
27173
+ for (let i = 0; i < props.length; i = i + 2) {
27174
+ const key = props[i];
27094
27175
  if (!key.startsWith(Q_PROPS_SEPARATOR)) {
27095
27176
  keys.push(key);
27096
27177
  }
@@ -27103,19 +27184,20 @@ var vnode_setAttr = (journal, vnode, key, value) => {
27103
27184
  const type = vnode[0 /* flags */];
27104
27185
  if ((type & 3 /* ELEMENT_OR_VIRTUAL_MASK */) !== 0) {
27105
27186
  vnode_ensureElementInflated(vnode);
27106
- const idx = mapApp_findIndx(vnode, key, vnode_getPropStartIndex(vnode));
27187
+ const props = vnode_getProps(vnode);
27188
+ const idx = mapApp_findIndx(props, key, 0);
27107
27189
  if (idx >= 0) {
27108
- if (vnode[idx + 1] != value && (type & 1 /* Element */) !== 0) {
27190
+ if (props[idx + 1] != value && (type & 1 /* Element */) !== 0) {
27109
27191
  const element = vnode[6 /* element */];
27110
27192
  journal && journal.push(2 /* SetAttribute */, element, key, value);
27111
27193
  }
27112
27194
  if (value == null) {
27113
- vnode.splice(idx, 2);
27195
+ props.splice(idx, 2);
27114
27196
  } else {
27115
- vnode[idx + 1] = value;
27197
+ props[idx + 1] = value;
27116
27198
  }
27117
27199
  } else if (value != null) {
27118
- vnode.splice(idx ^ -1, 0, key, value);
27200
+ props.splice(idx ^ -1, 0, key, value);
27119
27201
  if ((type & 1 /* Element */) !== 0) {
27120
27202
  const element = vnode[6 /* element */];
27121
27203
  journal && journal.push(2 /* SetAttribute */, element, key, value);
@@ -27127,7 +27209,8 @@ var vnode_getAttr = (vnode, key) => {
27127
27209
  const type = vnode[0 /* flags */];
27128
27210
  if ((type & 3 /* ELEMENT_OR_VIRTUAL_MASK */) !== 0) {
27129
27211
  vnode_ensureElementInflated(vnode);
27130
- return mapArray_get(vnode, key, vnode_getPropStartIndex(vnode));
27212
+ const props = vnode_getProps(vnode);
27213
+ return mapArray_get(props, key, 0);
27131
27214
  }
27132
27215
  return null;
27133
27216
  };
@@ -27135,11 +27218,12 @@ var vnode_getProp = (vnode, key, getObject) => {
27135
27218
  const type = vnode[0 /* flags */];
27136
27219
  if ((type & 3 /* ELEMENT_OR_VIRTUAL_MASK */) !== 0) {
27137
27220
  type & 1 /* Element */ && vnode_ensureElementInflated(vnode);
27138
- const idx = mapApp_findIndx(vnode, key, vnode_getPropStartIndex(vnode));
27221
+ const props = vnode_getProps(vnode);
27222
+ const idx = mapApp_findIndx(props, key, 0);
27139
27223
  if (idx >= 0) {
27140
- let value = vnode[idx + 1];
27224
+ let value = props[idx + 1];
27141
27225
  if (typeof value === "string" && getObject) {
27142
- vnode[idx + 1] = value = getObject(value);
27226
+ props[idx + 1] = value = getObject(value);
27143
27227
  }
27144
27228
  return value;
27145
27229
  }
@@ -27148,11 +27232,12 @@ var vnode_getProp = (vnode, key, getObject) => {
27148
27232
  };
27149
27233
  var vnode_setProp = (vnode, key, value) => {
27150
27234
  ensureElementOrVirtualVNode(vnode);
27151
- const idx = mapApp_findIndx(vnode, key, vnode_getPropStartIndex(vnode));
27235
+ const props = vnode_getProps(vnode);
27236
+ const idx = mapApp_findIndx(props, key, 0);
27152
27237
  if (idx >= 0) {
27153
- vnode[idx + 1] = value;
27238
+ props[idx + 1] = value;
27154
27239
  } else if (value != null) {
27155
- vnode.splice(idx ^ -1, 0, key, value);
27240
+ props.splice(idx ^ -1, 0, key, value);
27156
27241
  }
27157
27242
  };
27158
27243
  var vnode_getPropStartIndex = (vnode) => {
@@ -27164,6 +27249,9 @@ var vnode_getPropStartIndex = (vnode) => {
27164
27249
  }
27165
27250
  throw qError(43 /* invalidVNodeType */, [type]);
27166
27251
  };
27252
+ var vnode_getProps = (vnode) => {
27253
+ return vnode[vnode_getPropStartIndex(vnode)];
27254
+ };
27167
27255
  var vnode_getParent = (vnode) => {
27168
27256
  return vnode[1 /* parent */] || null;
27169
27257
  };
@@ -27301,7 +27389,7 @@ function materializeFromVNodeData(vParent, vData, element, child) {
27301
27389
  }
27302
27390
  const id = consumeValue();
27303
27391
  container.$setRawState$(parseInt(id), vParent);
27304
- isDev6 && vnode_setAttr(null, vParent, ELEMENT_ID, id);
27392
+ isDev7 && vnode_setAttr(null, vParent, ELEMENT_ID, id);
27305
27393
  } else if (peek() === VNodeDataChar.PROPS) {
27306
27394
  vnode_setAttr(null, vParent, ELEMENT_PROPS, consumeValue());
27307
27395
  } else if (peek() === VNodeDataChar.SLOT_REF) {
@@ -27312,8 +27400,11 @@ function materializeFromVNodeData(vParent, vData, element, child) {
27312
27400
  vnode_setAttr(null, vParent, ELEMENT_SEQ, consumeValue());
27313
27401
  } else if (peek() === VNodeDataChar.SEQ_IDX) {
27314
27402
  vnode_setAttr(null, vParent, ELEMENT_SEQ_IDX, consumeValue());
27315
- } else if (peek() === VNodeDataChar.SUBS) {
27316
- vnode_setProp(vParent, QSubscribers, consumeValue());
27403
+ } else if (peek() === VNodeDataChar.BACK_REFS) {
27404
+ if (!container) {
27405
+ container = getDomContainer(element);
27406
+ }
27407
+ setEffectBackRefFromVNodeData(vParent, consumeValue(), container);
27317
27408
  } else if (peek() === VNodeDataChar.CONTEXT) {
27318
27409
  vnode_setAttr(null, vParent, QCtxAttr, consumeValue());
27319
27410
  } else if (peek() === VNodeDataChar.OPEN) {
@@ -27396,24 +27487,38 @@ var vnode_getProjectionParentComponent = (vHost, rootVNode) => {
27396
27487
  };
27397
27488
  var VNodeArray = class VNode extends Array {
27398
27489
  static createElement(flags, parent, previousSibling, nextSibling, firstChild, lastChild, element, elementName) {
27399
- const vnode = new VNode(flags, parent, previousSibling, nextSibling);
27400
- vnode.push(firstChild, lastChild, element, elementName);
27490
+ const vnode = new VNode(
27491
+ flags,
27492
+ parent,
27493
+ previousSibling,
27494
+ nextSibling,
27495
+ firstChild,
27496
+ lastChild,
27497
+ element,
27498
+ elementName,
27499
+ []
27500
+ );
27401
27501
  return vnode;
27402
27502
  }
27403
27503
  static createText(flags, parent, previousSibling, nextSibling, textNode, text) {
27404
- const vnode = new VNode(flags, parent, previousSibling, nextSibling);
27405
- vnode.push(textNode, text);
27504
+ const vnode = new VNode(flags, parent, previousSibling, nextSibling, textNode, text);
27406
27505
  return vnode;
27407
27506
  }
27408
27507
  static createVirtual(flags, parent, previousSibling, nextSibling, firstChild, lastChild) {
27409
- const vnode = new VNode(flags, parent, previousSibling, nextSibling);
27410
- vnode.push(firstChild, lastChild);
27508
+ const vnode = new VNode(
27509
+ flags,
27510
+ parent,
27511
+ previousSibling,
27512
+ nextSibling,
27513
+ firstChild,
27514
+ lastChild,
27515
+ []
27516
+ );
27411
27517
  return vnode;
27412
27518
  }
27413
- constructor(flags, parent, previousSibling, nextSibling) {
27414
- super();
27415
- this.push(flags, parent, previousSibling, nextSibling);
27416
- if (isDev6) {
27519
+ constructor(flags, parent, previousSibling, nextSibling, ...rest) {
27520
+ super(flags, parent, previousSibling, nextSibling, ...rest);
27521
+ if (isDev7) {
27417
27522
  this.toString = vnode_toString;
27418
27523
  }
27419
27524
  }
@@ -27458,10 +27563,12 @@ function invokeApply(context, fn, args) {
27458
27563
  return returnValue;
27459
27564
  }
27460
27565
  var newInvokeContextFromTuple = ([element, event, url]) => {
27461
- const container = element.closest(QContainerSelector);
27566
+ const domContainer = getDomContainer(element);
27567
+ const container = domContainer.element;
27568
+ const vNode = container ? vnode_locate(domContainer.rootVNode, element) : void 0;
27462
27569
  const locale = container?.getAttribute(QLocaleAttr) || void 0;
27463
27570
  locale && setLocale(locale);
27464
- return newInvokeContext(locale, void 0, element, event, url);
27571
+ return newInvokeContext(locale, vNode, element, event, url);
27465
27572
  };
27466
27573
  var newInvokeContext = (locale, hostElement, element, event, url) => {
27467
27574
  const $locale$ = locale || (typeof event === "object" && event && "locale" in event ? event.locale : void 0);
@@ -27492,10 +27599,7 @@ var trackSignal = (fn, subscriber, property, container, data) => {
27492
27599
  const previousSubscriber = trackInvocation.$effectSubscriber$;
27493
27600
  const previousContainer = trackInvocation.$container$;
27494
27601
  try {
27495
- trackInvocation.$effectSubscriber$ = [subscriber, property];
27496
- if (data) {
27497
- trackInvocation.$effectSubscriber$.push(data);
27498
- }
27602
+ trackInvocation.$effectSubscriber$ = getSubscriber(subscriber, property, data);
27499
27603
  trackInvocation.$container$ = container;
27500
27604
  return invoke(trackInvocation, fn);
27501
27605
  } finally {
@@ -27856,9 +27960,9 @@ var DomContainer = class extends _SharedContainer {
27856
27960
  __publicField(this, "$storeProxyMap$", /* @__PURE__ */ new WeakMap());
27857
27961
  __publicField(this, "$qFuncs$");
27858
27962
  __publicField(this, "$instanceHash$");
27859
- __publicField(this, "stateData");
27963
+ __publicField(this, "vNodeLocate", (id) => vnode_locate(this.rootVNode, id));
27964
+ __publicField(this, "$stateData$");
27860
27965
  __publicField(this, "$styleIds$", null);
27861
- __publicField(this, "$vnodeLocate$", (id) => vnode_locate(this.rootVNode, id));
27862
27966
  __publicField(this, "$renderCount$", 0);
27863
27967
  __publicField(this, "$getObjectById$", (id) => {
27864
27968
  if (typeof id === "string") {
@@ -27868,7 +27972,7 @@ var DomContainer = class extends _SharedContainer {
27868
27972
  id < this.$rawStateData$.length / 2,
27869
27973
  `Invalid reference: ${id} >= ${this.$rawStateData$.length / 2}`
27870
27974
  );
27871
- return this.stateData[id];
27975
+ return this.$stateData$[id];
27872
27976
  });
27873
27977
  this.qContainer = element.getAttribute(QContainerAttr);
27874
27978
  if (!this.qContainer) {
@@ -27890,29 +27994,29 @@ var DomContainer = class extends _SharedContainer {
27890
27994
  this.qManifestHash = element.getAttribute("q:manifest-hash");
27891
27995
  this.rootVNode = vnode_newUnMaterializedElement(this.element);
27892
27996
  this.$rawStateData$ = null;
27893
- this.stateData = null;
27997
+ this.$stateData$ = null;
27894
27998
  const document2 = this.element.ownerDocument;
27895
27999
  if (!document2.qVNodeData) {
27896
28000
  processVNodeData2(document2);
27897
28001
  }
27898
28002
  this.$rawStateData$ = [];
27899
- this.stateData = [];
28003
+ this.$stateData$ = [];
27900
28004
  const qwikStates = element.querySelectorAll('script[type="qwik/state"]');
27901
28005
  if (qwikStates.length !== 0) {
27902
28006
  const lastState = qwikStates[qwikStates.length - 1];
27903
28007
  this.$rawStateData$ = JSON.parse(lastState.textContent);
27904
- this.stateData = wrapDeserializerProxy(this, this.$rawStateData$);
28008
+ this.$stateData$ = wrapDeserializerProxy(this, this.$rawStateData$);
27905
28009
  }
27906
28010
  this.$qFuncs$ = getQFuncs(document2, this.$instanceHash$) || EMPTY_ARRAY;
27907
28011
  }
27908
28012
  $setRawState$(id, vParent) {
27909
- this.stateData[id] = vParent;
28013
+ this.$stateData$[id] = vParent;
27910
28014
  }
27911
28015
  parseQRL(qrl2) {
27912
28016
  return inflateQRL(this, parseQRL(qrl2));
27913
28017
  }
27914
28018
  handleError(err, host) {
27915
- if (qDev) {
28019
+ if (qDev && host) {
27916
28020
  if (typeof document !== "undefined") {
27917
28021
  const vHost = host;
27918
28022
  const errorDiv = document.createElement("errored-host");
@@ -27935,7 +28039,7 @@ var DomContainer = class extends _SharedContainer {
27935
28039
  throw err;
27936
28040
  }
27937
28041
  }
27938
- const errorStore = this.resolveContext(host, ERROR_CONTEXT);
28042
+ const errorStore = host && this.resolveContext(host, ERROR_CONTEXT);
27939
28043
  if (!errorStore) {
27940
28044
  throw err;
27941
28045
  }
@@ -27969,7 +28073,7 @@ var DomContainer = class extends _SharedContainer {
27969
28073
  return vNode;
27970
28074
  }
27971
28075
  vNode = vnode_getParent(vNode) || // If virtual node, than it could be a slot so we need to read its parent.
27972
- vnode_getProp(vNode, QSlotParent, this.$vnodeLocate$);
28076
+ vnode_getProp(vNode, QSlotParent, this.vNodeLocate);
27973
28077
  } else {
27974
28078
  vNode = vnode_getParent(vNode);
27975
28079
  }
@@ -27988,7 +28092,7 @@ var DomContainer = class extends _SharedContainer {
27988
28092
  case ELEMENT_PROPS:
27989
28093
  case OnRenderProp:
27990
28094
  case QCtxAttr:
27991
- case QSubscribers:
28095
+ case QBackRefs:
27992
28096
  getObjectById = this.$getObjectById$;
27993
28097
  break;
27994
28098
  case ELEMENT_SEQ_IDX:
@@ -28001,7 +28105,9 @@ var DomContainer = class extends _SharedContainer {
28001
28105
  scheduleRender() {
28002
28106
  this.$renderCount$++;
28003
28107
  this.renderDone || (this.renderDone = getPlatform().nextTick(() => this.processChores()));
28004
- return this.renderDone;
28108
+ return this.renderDone.finally(
28109
+ () => emitEvent("qrender", { instanceHash: this.$instanceHash$, renderCount: this.$renderCount$ })
28110
+ );
28005
28111
  }
28006
28112
  processChores() {
28007
28113
  let renderCount = this.$renderCount$;
@@ -28024,12 +28130,13 @@ var DomContainer = class extends _SharedContainer {
28024
28130
  ensureProjectionResolved(vNode) {
28025
28131
  if ((vNode[0 /* flags */] & 16 /* Resolved */) === 0) {
28026
28132
  vNode[0 /* flags */] |= 16 /* Resolved */;
28027
- for (let i = vnode_getPropStartIndex(vNode); i < vNode.length; i = i + 2) {
28028
- const prop = vNode[i];
28133
+ const props = vnode_getProps(vNode);
28134
+ for (let i = 0; i < props.length; i = i + 2) {
28135
+ const prop = props[i];
28029
28136
  if (isSlotProp(prop)) {
28030
- const value = vNode[i + 1];
28137
+ const value = props[i + 1];
28031
28138
  if (typeof value == "string") {
28032
- vNode[i + 1] = this.$vnodeLocate$(value);
28139
+ props[i + 1] = this.vNodeLocate(value);
28033
28140
  }
28034
28141
  }
28035
28142
  }
@@ -28096,8 +28203,7 @@ var DeserializationHandler = class {
28096
28203
  }
28097
28204
  const i = typeof property === "number" ? property : typeof property === "string" ? parseInt(property, 10) : NaN;
28098
28205
  if (Number.isNaN(i) || i < 0 || i >= this.$length$) {
28099
- const out = Reflect.get(target, property, receiver);
28100
- return out;
28206
+ return Reflect.get(target, property, receiver);
28101
28207
  }
28102
28208
  const idx = i * 2;
28103
28209
  const typeId = this.$data$[idx];
@@ -28194,7 +28300,7 @@ var inflate = (container, target, typeId, data) => {
28194
28300
  task.$flags$ = v[1];
28195
28301
  task.$index$ = v[2];
28196
28302
  task.$el$ = v[3];
28197
- task.$effectDependencies$ = v[4];
28303
+ task[_EFFECT_BACK_REF] = v[4];
28198
28304
  task.$state$ = v[5];
28199
28305
  break;
28200
28306
  case 20 /* Resource */:
@@ -28216,12 +28322,9 @@ var inflate = (container, target, typeId, data) => {
28216
28322
  break;
28217
28323
  case 25 /* Store */:
28218
28324
  case 26 /* StoreArray */: {
28219
- const [value, flags, effects2, storeEffect] = data;
28325
+ const [value, flags, effects2] = data;
28220
28326
  const store = getOrCreateStore(value, flags, container);
28221
28327
  const storeHandler = getStoreHandler(store);
28222
- if (storeEffect) {
28223
- effects2[STORE_ARRAY_PROP] = storeEffect;
28224
- }
28225
28328
  storeHandler.$effects$ = effects2;
28226
28329
  target = store;
28227
28330
  break;
@@ -28230,7 +28333,7 @@ var inflate = (container, target, typeId, data) => {
28230
28333
  const signal = target;
28231
28334
  const d = data;
28232
28335
  signal.$untrackedValue$ = d[0];
28233
- signal.$effects$ = d.slice(1);
28336
+ signal.$effects$ = new Set(d.slice(1));
28234
28337
  break;
28235
28338
  }
28236
28339
  case 23 /* WrappedSignal */: {
@@ -28238,10 +28341,10 @@ var inflate = (container, target, typeId, data) => {
28238
28341
  const d = data;
28239
28342
  signal.$func$ = container.getSyncFn(d[0]);
28240
28343
  signal.$args$ = d[1];
28241
- signal.$effectDependencies$ = d[2];
28344
+ signal[_EFFECT_BACK_REF] = d[2];
28242
28345
  signal.$untrackedValue$ = d[3];
28243
28346
  signal.$hostElement$ = d[4];
28244
- signal.$effects$ = d.slice(5);
28347
+ signal.$effects$ = new Set(d.slice(5));
28245
28348
  break;
28246
28349
  }
28247
28350
  case 24 /* ComputedSignal */: {
@@ -28355,6 +28458,7 @@ var _constants = [
28355
28458
  EMPTY_ARRAY,
28356
28459
  EMPTY_OBJ,
28357
28460
  NEEDS_COMPUTATION,
28461
+ STORE_ARRAY_PROP,
28358
28462
  Slot,
28359
28463
  Fragment,
28360
28464
  NaN,
@@ -28373,6 +28477,7 @@ var _constantNames = [
28373
28477
  "EMPTY_ARRAY",
28374
28478
  "EMPTY_OBJ",
28375
28479
  "NEEDS_COMPUTATION",
28480
+ "STORE_ARRAY_PROP",
28376
28481
  "Slot",
28377
28482
  "Fragment",
28378
28483
  "NaN",
@@ -28454,6 +28559,8 @@ var allocate = (container, typeId, value) => {
28454
28559
  reject = rej;
28455
28560
  });
28456
28561
  resolvers.set(promise, [resolve, reject]);
28562
+ promise.catch(() => {
28563
+ });
28457
28564
  return promise;
28458
28565
  case 17 /* Uint8Array */:
28459
28566
  const encodedLength = value.length;
@@ -28463,12 +28570,9 @@ var allocate = (container, typeId, value) => {
28463
28570
  return new Uint8Array(decodedLength);
28464
28571
  case 29 /* PropsProxy */:
28465
28572
  return createPropsProxy(null, null);
28466
- case 9 /* RefVNode */:
28467
28573
  case 8 /* VNode */:
28468
- const vnodeOrDocument = retrieveVNodeOrDocument(container, value);
28469
- if (typeId === 8 /* VNode */) {
28470
- return vnodeOrDocument;
28471
- }
28574
+ return retrieveVNodeOrDocument(container, value);
28575
+ case 9 /* RefVNode */:
28472
28576
  const vNode = retrieveVNodeOrDocument(container, value);
28473
28577
  if (vnode_isVNode(vNode)) {
28474
28578
  return vnode_getNode(vNode);
@@ -28476,7 +28580,7 @@ var allocate = (container, typeId, value) => {
28476
28580
  throw qError(34 /* serializeErrorExpectedVNode */, [typeof vNode]);
28477
28581
  }
28478
28582
  case 30 /* EffectData */:
28479
- return new EffectPropData({});
28583
+ return new SubscriptionData({});
28480
28584
  default:
28481
28585
  throw qError(35 /* serializeErrorCannotAllocate */, [typeId]);
28482
28586
  }
@@ -28492,12 +28596,12 @@ function parseQRL(qrl2) {
28492
28596
  const symbol = captureStart > -1 ? qrl2.slice(hashIdx + 1, captureStart) : qrl2.slice(hashIdx + 1);
28493
28597
  const captureIds = captureStart > -1 && captureEnd > -1 ? qrl2.slice(captureStart + 1, captureEnd).split(" ").filter((v) => v.length).map((s) => parseInt(s, 10)) : null;
28494
28598
  let qrlRef = null;
28495
- if (isDev && chunk === QRL_RUNTIME_CHUNK) {
28599
+ if (isDev2 && chunk === QRL_RUNTIME_CHUNK) {
28496
28600
  const backChannel = globalThis[QRL_RUNTIME_CHUNK];
28497
28601
  assertDefined(backChannel, "Missing QRL_RUNTIME_CHUNK");
28498
28602
  qrlRef = backChannel.get(symbol);
28499
28603
  }
28500
- return createQRL(chunk, symbol, qrlRef, null, captureIds, null, null);
28604
+ return createQRL(chunk, symbol, qrlRef, null, captureIds, null);
28501
28605
  }
28502
28606
  function inflateQRL(container, qrl2) {
28503
28607
  const captureIds = qrl2.$capture$;
@@ -28531,13 +28635,13 @@ var createSerializationContext = (NodeConstructor, DomRefConstructor, symbolToCh
28531
28635
  }
28532
28636
  return id;
28533
28637
  };
28534
- const isSsrNode = NodeConstructor ? (obj) => obj instanceof NodeConstructor : () => false;
28638
+ const isSsrNode2 = NodeConstructor ? (obj) => obj instanceof NodeConstructor : () => false;
28535
28639
  isDomRef = DomRefConstructor ? (obj) => obj instanceof DomRefConstructor : () => false;
28536
28640
  return {
28537
28641
  $serialize$() {
28538
28642
  serialize(this);
28539
28643
  },
28540
- $isSsrNode$: isSsrNode,
28644
+ $isSsrNode$: isSsrNode2,
28541
28645
  $isDomRef$: isDomRef,
28542
28646
  $symbolToChunkResolver$: symbolToChunkResolver,
28543
28647
  $wasSeen$,
@@ -28593,7 +28697,7 @@ var createSerializationContext = (NodeConstructor, DomRefConstructor, symbolToCh
28593
28697
  const promises = [];
28594
28698
  const visit = (obj) => {
28595
28699
  if (typeof obj === "function") {
28596
- if (isQrl2(obj)) {
28700
+ if (isQrl(obj)) {
28597
28701
  if (obj.$captureRef$) {
28598
28702
  discoveredValues.push(...obj.$captureRef$);
28599
28703
  }
@@ -28603,7 +28707,7 @@ var createSerializationContext = (NodeConstructor, DomRefConstructor, symbolToCh
28603
28707
  }
28604
28708
  } else if (
28605
28709
  // skip as these are primitives
28606
- typeof obj !== "object" || obj === null || obj instanceof URL || obj instanceof Date || obj instanceof RegExp || obj instanceof Uint8Array || obj instanceof URLSearchParams || typeof FormData !== "undefined" && obj instanceof FormData || // Ignore the no serialize objects
28710
+ typeof obj !== "object" || obj === null || obj instanceof URL || obj instanceof Date || obj instanceof RegExp || obj instanceof Uint8Array || obj instanceof URLSearchParams || vnode_isVNode(obj) || typeof FormData !== "undefined" && obj instanceof FormData || // Ignore the no serialize objects
28607
28711
  fastSkipSerialize(obj)
28608
28712
  ) {
28609
28713
  } else if (obj instanceof Error) {
@@ -28611,8 +28715,7 @@ var createSerializationContext = (NodeConstructor, DomRefConstructor, symbolToCh
28611
28715
  } else if (isStore(obj)) {
28612
28716
  const target = getStoreTarget(obj);
28613
28717
  const effects = getStoreHandler(obj).$effects$;
28614
- const storeEffect = effects?.[STORE_ARRAY_PROP] ?? null;
28615
- discoveredValues.push(target, effects, storeEffect);
28718
+ discoveredValues.push(target, effects);
28616
28719
  for (const prop in target) {
28617
28720
  const propValue = target[prop];
28618
28721
  if (storeProxyMap.has(propValue)) {
@@ -28634,9 +28737,7 @@ var createSerializationContext = (NodeConstructor, DomRefConstructor, symbolToCh
28634
28737
  discoveredValues.push(...obj.$effects$);
28635
28738
  }
28636
28739
  if (obj instanceof WrappedSignal) {
28637
- if (obj.$effectDependencies$) {
28638
- discoveredValues.push(...obj.$effectDependencies$);
28639
- }
28740
+ discoverEffectBackRefs(obj[_EFFECT_BACK_REF], discoveredValues);
28640
28741
  if (obj.$args$) {
28641
28742
  discoveredValues.push(...obj.$args$);
28642
28743
  }
@@ -28647,8 +28748,9 @@ var createSerializationContext = (NodeConstructor, DomRefConstructor, symbolToCh
28647
28748
  discoveredValues.push(obj.$computeQrl$);
28648
28749
  }
28649
28750
  } else if (obj instanceof Task) {
28650
- discoveredValues.push(obj.$el$, obj.$qrl$, obj.$state$, obj.$effectDependencies$);
28651
- } else if (isSsrNode(obj)) {
28751
+ discoveredValues.push(obj.$el$, obj.$qrl$, obj.$state$);
28752
+ discoverEffectBackRefs(obj[_EFFECT_BACK_REF], discoveredValues);
28753
+ } else if (isSsrNode2(obj)) {
28652
28754
  discoverValuesForVNodeData(obj.vnodeData, discoveredValues);
28653
28755
  if (obj.childrenVNodeData && obj.childrenVNodeData.length) {
28654
28756
  for (const data of obj.childrenVNodeData) {
@@ -28661,7 +28763,7 @@ var createSerializationContext = (NodeConstructor, DomRefConstructor, symbolToCh
28661
28763
  discoveredValues.push(obj.type, obj.props, obj.constProps, obj.children);
28662
28764
  } else if (Array.isArray(obj)) {
28663
28765
  discoveredValues.push(...obj);
28664
- } else if (isQrl2(obj)) {
28766
+ } else if (isQrl(obj)) {
28665
28767
  obj.$captureRef$ && obj.$captureRef$.length && discoveredValues.push(...obj.$captureRef$);
28666
28768
  } else if (isPropsProxy(obj)) {
28667
28769
  discoveredValues.push(obj[_VAR_PROPS], obj[_CONST_PROPS]);
@@ -28677,7 +28779,7 @@ var createSerializationContext = (NodeConstructor, DomRefConstructor, symbolToCh
28677
28779
  }
28678
28780
  );
28679
28781
  promises.push(obj);
28680
- } else if (obj instanceof EffectPropData) {
28782
+ } else if (obj instanceof SubscriptionData) {
28681
28783
  discoveredValues.push(obj.data);
28682
28784
  } else if (isObjectLiteral(obj)) {
28683
28785
  Object.entries(obj).forEach(([key, value]) => {
@@ -28714,15 +28816,30 @@ var discoverValuesForVNodeData = (vnodeData, discoveredValues) => {
28714
28816
  for (const value of vnodeData) {
28715
28817
  if (isSsrAttrs(value)) {
28716
28818
  for (let i = 1; i < value.length; i += 2) {
28717
- if (value[i - 1] === ELEMENT_KEY) {
28819
+ const attrValue = value[i];
28820
+ if (typeof attrValue === "string") {
28718
28821
  continue;
28719
28822
  }
28720
- const attrValue = value[i];
28721
28823
  discoveredValues.push(attrValue);
28722
28824
  }
28723
28825
  }
28724
28826
  }
28725
28827
  };
28828
+ var discoverEffectBackRefs = (effectsBackRefs, discoveredValues) => {
28829
+ if (effectsBackRefs) {
28830
+ let hasBackRefs = false;
28831
+ for (const [, effect] of effectsBackRefs) {
28832
+ const backRefs = effect[2 /* BACK_REF */];
28833
+ if (backRefs) {
28834
+ hasBackRefs = true;
28835
+ break;
28836
+ }
28837
+ }
28838
+ if (hasBackRefs) {
28839
+ discoveredValues.push(effectsBackRefs);
28840
+ }
28841
+ }
28842
+ };
28726
28843
  var promiseResults = /* @__PURE__ */ new WeakMap();
28727
28844
  function serialize(serializationContext) {
28728
28845
  const { $writer$, $isSsrNode$, $isDomRef$, $setProp$, $storeProxyMap$ } = serializationContext;
@@ -28771,10 +28888,10 @@ function serialize(serializationContext) {
28771
28888
  output(1 /* Constant */, value ? 2 /* True */ : 3 /* False */);
28772
28889
  } else if (typeof value === "function") {
28773
28890
  if (value === Slot) {
28774
- output(1 /* Constant */, 8 /* Slot */);
28891
+ output(1 /* Constant */, 9 /* Slot */);
28775
28892
  } else if (value === Fragment) {
28776
- output(1 /* Constant */, 9 /* Fragment */);
28777
- } else if (isQrl2(value)) {
28893
+ output(1 /* Constant */, 10 /* Fragment */);
28894
+ } else if (isQrl(value)) {
28778
28895
  const qrl2 = qrlToString(serializationContext, value);
28779
28896
  const id = serializationContext.$addRoot$(qrl2);
28780
28897
  output(18 /* QRL */, id);
@@ -28788,18 +28905,18 @@ function serialize(serializationContext) {
28788
28905
  }
28789
28906
  } else if (typeof value === "number") {
28790
28907
  if (Number.isNaN(value)) {
28791
- output(1 /* Constant */, 10 /* NaN */);
28908
+ output(1 /* Constant */, 11 /* NaN */);
28792
28909
  } else if (!Number.isFinite(value)) {
28793
28910
  output(
28794
28911
  1 /* Constant */,
28795
- value < 0 ? 12 /* NegativeInfinity */ : 11 /* PositiveInfinity */
28912
+ value < 0 ? 13 /* NegativeInfinity */ : 12 /* PositiveInfinity */
28796
28913
  );
28797
28914
  } else if (value === Number.MAX_SAFE_INTEGER) {
28798
- output(1 /* Constant */, 13 /* MaxSafeInt */);
28915
+ output(1 /* Constant */, 14 /* MaxSafeInt */);
28799
28916
  } else if (value === Number.MAX_SAFE_INTEGER - 1) {
28800
- output(1 /* Constant */, 14 /* AlmostMaxSafeInt */);
28917
+ output(1 /* Constant */, 15 /* AlmostMaxSafeInt */);
28801
28918
  } else if (value === Number.MIN_SAFE_INTEGER) {
28802
- output(1 /* Constant */, 15 /* MinSafeInt */);
28919
+ output(1 /* Constant */, 16 /* MinSafeInt */);
28803
28920
  } else {
28804
28921
  output(2 /* Number */, value);
28805
28922
  }
@@ -28832,6 +28949,8 @@ function serialize(serializationContext) {
28832
28949
  output(1 /* Constant */, 0 /* Undefined */);
28833
28950
  } else if (value === NEEDS_COMPUTATION) {
28834
28951
  output(1 /* Constant */, 7 /* NEEDS_COMPUTATION */);
28952
+ } else if (value === STORE_ARRAY_PROP) {
28953
+ output(1 /* Constant */, 8 /* STORE_ARRAY_PROP */);
28835
28954
  } else {
28836
28955
  throw qError(37 /* serializeErrorUnknownType */, [typeof value]);
28837
28956
  }
@@ -28850,7 +28969,7 @@ function serialize(serializationContext) {
28850
28969
  const constProps = value[_CONST_PROPS];
28851
28970
  const out = constProps ? [varProps, constProps] : Object.keys(varProps).length ? [varProps] : 0;
28852
28971
  output(29 /* PropsProxy */, out);
28853
- } else if (value instanceof EffectPropData) {
28972
+ } else if (value instanceof SubscriptionData) {
28854
28973
  output(30 /* EffectData */, [value.data.$scopedStyleIdPrefix$, value.data.$isConst$]);
28855
28974
  } else if (isStore(value)) {
28856
28975
  if (isResource(value)) {
@@ -28865,7 +28984,6 @@ function serialize(serializationContext) {
28865
28984
  const storeTarget = getStoreTarget(value);
28866
28985
  const flags = storeHandler.$flags$;
28867
28986
  const effects = storeHandler.$effects$;
28868
- const storeEffect = effects?.[STORE_ARRAY_PROP] ?? null;
28869
28987
  const innerStores = [];
28870
28988
  for (const prop in storeTarget) {
28871
28989
  const propValue = storeTarget[prop];
@@ -28875,7 +28993,7 @@ function serialize(serializationContext) {
28875
28993
  serializationContext.$addRoot$(innerStore);
28876
28994
  }
28877
28995
  }
28878
- const out = [storeTarget, flags, effects, storeEffect, ...innerStores];
28996
+ const out = [storeTarget, flags, effects, ...innerStores];
28879
28997
  while (out[out.length - 1] == null) {
28880
28998
  out.pop();
28881
28999
  }
@@ -28901,7 +29019,7 @@ function serialize(serializationContext) {
28901
29019
  if (value instanceof WrappedSignal) {
28902
29020
  output(23 /* WrappedSignal */, [
28903
29021
  ...serializeWrappingFn(serializationContext, value),
28904
- value.$effectDependencies$,
29022
+ filterEffectBackRefs(value[_EFFECT_BACK_REF]),
28905
29023
  v,
28906
29024
  value.$hostElement$,
28907
29025
  ...value.$effects$ || []
@@ -28931,7 +29049,7 @@ function serialize(serializationContext) {
28931
29049
  if (extraProps.length) {
28932
29050
  out.push(extraProps);
28933
29051
  }
28934
- if (isDev) {
29052
+ if (isDev2) {
28935
29053
  out.push(value.stack);
28936
29054
  }
28937
29055
  output(12 /* Error */, out);
@@ -28988,7 +29106,7 @@ function serialize(serializationContext) {
28988
29106
  value.$flags$,
28989
29107
  value.$index$,
28990
29108
  value.$el$,
28991
- value.$effectDependencies$,
29109
+ value[_EFFECT_BACK_REF],
28992
29110
  value.$state$
28993
29111
  ];
28994
29112
  while (out[out.length - 1] == null) {
@@ -29008,12 +29126,26 @@ function serialize(serializationContext) {
29008
29126
  }
29009
29127
  const out = btoa(buf).replace(/=+$/, "");
29010
29128
  output(17 /* Uint8Array */, out);
29129
+ } else if (vnode_isVNode(value)) {
29130
+ output(1 /* Constant */, 0 /* Undefined */);
29011
29131
  } else {
29012
29132
  throw qError(37 /* serializeErrorUnknownType */, [typeof value]);
29013
29133
  }
29014
29134
  };
29015
29135
  writeValue(serializationContext.$roots$, -1);
29016
29136
  }
29137
+ function filterEffectBackRefs(effectBackRef) {
29138
+ let effectBackRefToSerialize = null;
29139
+ if (effectBackRef) {
29140
+ for (const [effectProp, effect] of effectBackRef) {
29141
+ if (effect[2 /* BACK_REF */]) {
29142
+ effectBackRefToSerialize || (effectBackRefToSerialize = /* @__PURE__ */ new Map());
29143
+ effectBackRefToSerialize.set(effectProp, effect);
29144
+ }
29145
+ }
29146
+ }
29147
+ return effectBackRefToSerialize;
29148
+ }
29017
29149
  function serializeWrappingFn(serializationContext, value) {
29018
29150
  if (value.$funcStr$ && value.$funcStr$[0] === "{") {
29019
29151
  value.$funcStr$ = `(${value.$funcStr$})`;
@@ -29028,15 +29160,12 @@ function serializeWrappingFn(serializationContext, value) {
29028
29160
  function qrlToString(serializationContext, value) {
29029
29161
  let symbol = value.$symbol$;
29030
29162
  let chunk = value.$chunk$;
29031
- const refSymbol = value.$refSymbol$ ?? symbol;
29032
29163
  const platform = getPlatform();
29033
29164
  if (platform) {
29034
- const result = platform.chunkForSymbol(refSymbol, chunk, value.dev?.file);
29165
+ const result = platform.chunkForSymbol(symbol, chunk, value.dev?.file);
29035
29166
  if (result) {
29036
29167
  chunk = result[1];
29037
- if (!value.$refSymbol$) {
29038
- symbol = result[0];
29039
- }
29168
+ symbol = result[0];
29040
29169
  }
29041
29170
  }
29042
29171
  const isSync = isSyncQrl(value);
@@ -29044,7 +29173,7 @@ function qrlToString(serializationContext, value) {
29044
29173
  if (!chunk) {
29045
29174
  chunk = serializationContext.$symbolToChunkResolver$(value.$hash$);
29046
29175
  }
29047
- if (isDev) {
29176
+ if (isDev2) {
29048
29177
  let backChannel = globalThis[QRL_RUNTIME_CHUNK];
29049
29178
  if (!backChannel) {
29050
29179
  backChannel = globalThis[QRL_RUNTIME_CHUNK] = /* @__PURE__ */ new Map();
@@ -29110,26 +29239,33 @@ function isResource(value) {
29110
29239
  return "__brand" in value && value.__brand === "resource";
29111
29240
  }
29112
29241
  var frameworkType = (obj) => {
29113
- return typeof obj === "object" && obj !== null && (obj instanceof Signal || obj instanceof Task || isJSXNode(obj)) || isQrl2(obj);
29242
+ return typeof obj === "object" && obj !== null && (obj instanceof Signal || obj instanceof Task || isJSXNode(obj)) || isQrl(obj);
29114
29243
  };
29115
- var canSerialize = (value) => {
29244
+ var canSerialize = (value, seen = /* @__PURE__ */ new WeakSet()) => {
29116
29245
  if (value == null || typeof value === "string" || typeof value === "number" || typeof value === "boolean" || typeof value === "bigint") {
29117
29246
  return true;
29118
29247
  } else if (typeof value === "object") {
29248
+ if (seen.has(value)) {
29249
+ return true;
29250
+ }
29251
+ seen.add(value);
29119
29252
  const proto = Object.getPrototypeOf(value);
29120
29253
  if (isStore(value)) {
29121
29254
  value = getStoreTarget(value);
29122
29255
  }
29123
29256
  if (proto == Object.prototype) {
29124
29257
  for (const key in value) {
29125
- if (!canSerialize(untrack(() => value[key]))) {
29258
+ if (!canSerialize(
29259
+ untrack(() => value[key]),
29260
+ seen
29261
+ )) {
29126
29262
  return false;
29127
29263
  }
29128
29264
  }
29129
29265
  return true;
29130
29266
  } else if (proto == Array.prototype) {
29131
29267
  for (let i = 0; i < value.length; i++) {
29132
- if (!canSerialize(value[i])) {
29268
+ if (!canSerialize(value[i], seen)) {
29133
29269
  return false;
29134
29270
  }
29135
29271
  }
@@ -29164,7 +29300,7 @@ var canSerialize = (value) => {
29164
29300
  return true;
29165
29301
  }
29166
29302
  } else if (typeof value === "function") {
29167
- if (isQrl2(value) || isQwikComponent(value)) {
29303
+ if (isQrl(value) || isQwikComponent(value)) {
29168
29304
  return true;
29169
29305
  }
29170
29306
  }
@@ -29282,7 +29418,7 @@ var constantToName = (code2) => {
29282
29418
 
29283
29419
  // packages/qwik/src/core/shared/utils/serialize-utils.ts
29284
29420
  var verifySerializable = (value, preMessage) => {
29285
- const seen = /* @__PURE__ */ new Set();
29421
+ const seen = /* @__PURE__ */ new WeakSet();
29286
29422
  return _verifySerializable(value, seen, "_", preMessage);
29287
29423
  };
29288
29424
  var _verifySerializable = (value, seen, ctx, preMessage) => {
@@ -29291,10 +29427,12 @@ var _verifySerializable = (value, seen, ctx, preMessage) => {
29291
29427
  return value;
29292
29428
  }
29293
29429
  if (shouldSerialize(unwrapped)) {
29294
- if (seen.has(unwrapped)) {
29295
- return value;
29430
+ if (typeof unwrapped === "object") {
29431
+ if (seen.has(unwrapped)) {
29432
+ return value;
29433
+ }
29434
+ seen.add(unwrapped);
29296
29435
  }
29297
- seen.add(unwrapped);
29298
29436
  if (isSignal(unwrapped)) {
29299
29437
  return value;
29300
29438
  }
@@ -29376,14 +29514,7 @@ var noSerialize = (input) => {
29376
29514
  };
29377
29515
 
29378
29516
  // packages/qwik/src/core/shared/qrl/qrl-class.ts
29379
- var isQrl2 = (value) => {
29380
- return typeof value === "function" && typeof value.getSymbol === "function";
29381
- };
29382
- var SYNC_QRL = "<sync>";
29383
- var isSyncQrl = (value) => {
29384
- return isQrl2(value) && value.$symbol$ == SYNC_QRL;
29385
- };
29386
- var createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef, refSymbol) => {
29517
+ var createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef) => {
29387
29518
  if (qDev && qSerialize) {
29388
29519
  if (captureRef) {
29389
29520
  for (const item of captureRef) {
@@ -29404,9 +29535,14 @@ var createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef, refSym
29404
29535
  return _containerEl;
29405
29536
  };
29406
29537
  function bindFnToContext(currentCtx, beforeFn) {
29407
- return (...args) => maybeThen(resolveLazy(), (fn) => {
29408
- if (!isFunction(fn)) {
29409
- throw qError(10 /* qrlIsNotFunction */);
29538
+ const bound = (...args) => {
29539
+ if (!qrl2.resolved) {
29540
+ return qrl2.resolve().then((fn) => {
29541
+ if (!isFunction(fn)) {
29542
+ throw qError(10 /* qrlIsNotFunction */);
29543
+ }
29544
+ return bound(...args);
29545
+ });
29410
29546
  }
29411
29547
  if (beforeFn && beforeFn() === false) {
29412
29548
  return;
@@ -29417,12 +29553,13 @@ var createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef, refSym
29417
29553
  context.$qrl$ = qrl2;
29418
29554
  context.$event$ || (context.$event$ = this);
29419
29555
  try {
29420
- return invoke.call(this, context, fn, ...args);
29556
+ return invoke.call(this, context, symbolRef, ...args);
29421
29557
  } finally {
29422
29558
  context.$qrl$ = prevQrl;
29423
29559
  context.$event$ = prevEvent;
29424
29560
  }
29425
- });
29561
+ };
29562
+ return bound;
29426
29563
  }
29427
29564
  const resolveLazy = (containerEl) => {
29428
29565
  return symbolRef !== null ? symbolRef : resolve(containerEl);
@@ -29434,7 +29571,16 @@ var createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef, refSym
29434
29571
  return function(...args) {
29435
29572
  let context = tryGetInvokeContext();
29436
29573
  if (context) {
29437
- return fn.apply(this, args);
29574
+ if (context.$qrl$?.$symbol$ === qrl2.$symbol$) {
29575
+ return fn.apply(this, args);
29576
+ }
29577
+ const prevQrl = context.$qrl$;
29578
+ context.$qrl$ = qrl2;
29579
+ try {
29580
+ return fn.apply(this, args);
29581
+ } finally {
29582
+ context.$qrl$ = prevQrl;
29583
+ }
29438
29584
  }
29439
29585
  context = newInvokeContext();
29440
29586
  context.$qrl$ = qrl2;
@@ -29459,10 +29605,12 @@ var createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef, refSym
29459
29605
  const start = now();
29460
29606
  const ctx = tryGetInvokeContext();
29461
29607
  if (symbolFn !== null) {
29462
- symbolRef = symbolFn().then((module) => qrl2.resolved = symbolRef = wrapFn(module[symbol]));
29608
+ symbolRef = symbolFn().then(
29609
+ (module) => qrl2.resolved = wrapFn(symbolRef = module[symbol])
29610
+ );
29463
29611
  } else {
29464
29612
  const imported = getPlatform().importSymbol(_containerEl, chunk, symbol);
29465
- symbolRef = maybeThen(imported, (ref) => qrl2.resolved = symbolRef = wrapFn(ref));
29613
+ symbolRef = maybeThen(imported, (ref) => qrl2.resolved = wrapFn(symbolRef = ref));
29466
29614
  }
29467
29615
  if (typeof symbolRef === "object" && isPromise(symbolRef)) {
29468
29616
  symbolRef.then(
@@ -29485,10 +29633,9 @@ var createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef, refSym
29485
29633
  return invoke2;
29486
29634
  }
29487
29635
  };
29488
- const resolvedSymbol = refSymbol ?? symbol;
29489
- const hash3 = getSymbolHash(resolvedSymbol);
29636
+ const hash3 = getSymbolHash(symbol);
29490
29637
  Object.assign(qrl2, {
29491
- getSymbol: () => resolvedSymbol,
29638
+ getSymbol: () => symbol,
29492
29639
  getHash: () => hash3,
29493
29640
  getCaptured: () => captureRef,
29494
29641
  resolve,
@@ -29496,7 +29643,6 @@ var createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef, refSym
29496
29643
  $setContainer$: setContainer,
29497
29644
  $chunk$: chunk,
29498
29645
  $symbol$: symbol,
29499
- $refSymbol$: refSymbol,
29500
29646
  $hash$: hash3,
29501
29647
  getFn: bindFnToContext,
29502
29648
  $capture$: capture,
@@ -29505,9 +29651,9 @@ var createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef, refSym
29505
29651
  resolved: void 0
29506
29652
  });
29507
29653
  if (symbolRef) {
29508
- symbolRef = maybeThen(symbolRef, (resolved) => qrl2.resolved = symbolRef = wrapFn(resolved));
29654
+ symbolRef = maybeThen(symbolRef, (resolved) => qrl2.resolved = wrapFn(symbolRef = resolved));
29509
29655
  }
29510
- if (isDev7) {
29656
+ if (isDev8) {
29511
29657
  Object.defineProperty(qrl2, "_devOnlySymbolRef", {
29512
29658
  get() {
29513
29659
  return symbolRef;
@@ -29519,20 +29665,6 @@ var createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef, refSym
29519
29665
  }
29520
29666
  return qrl2;
29521
29667
  };
29522
- var getSymbolHash = (symbolName) => {
29523
- const index = symbolName.lastIndexOf("_");
29524
- if (index > -1) {
29525
- return symbolName.slice(index + 1);
29526
- }
29527
- return symbolName;
29528
- };
29529
- function assertQrl(qrl2) {
29530
- if (qDev) {
29531
- if (!isQrl2(qrl2)) {
29532
- throw new Error("Not a QRL");
29533
- }
29534
- }
29535
- }
29536
29668
  var EMITTED = /* @__PURE__ */ new Set();
29537
29669
  var emitUsedSymbol = (symbol, element, reqTime) => {
29538
29670
  if (!EMITTED.has(symbol)) {
@@ -29572,7 +29704,7 @@ var $ = (expression) => {
29572
29704
  "Optimizer should replace all usages of $() with some special syntax. If you need to create a QRL manually, use inlinedQrl() instead."
29573
29705
  );
29574
29706
  }
29575
- return createQRL(null, "s" + runtimeSymbolId++, expression, null, null, null, null);
29707
+ return createQRL(null, "s" + runtimeSymbolId++, expression, null, null, null);
29576
29708
  };
29577
29709
  var dollar = $;
29578
29710
  var eventQrl = (qrl2) => {
@@ -29599,9 +29731,6 @@ var isQwikComponent = (component) => {
29599
29731
  return typeof component == "function" && component[SERIALIZABLE_STATE] !== void 0;
29600
29732
  };
29601
29733
 
29602
- // packages/qwik/src/core/index.ts
29603
- import { isBrowser as isBrowser2, isDev as isDev9, isServer as isServer3 } from "@qwik.dev/core/build";
29604
-
29605
29734
  // packages/qwik/src/core/shared/qrl/qrl.public.dollar.ts
29606
29735
  var event$ = implicit$FirstArg(eventQrl);
29607
29736
 
@@ -29788,9 +29917,6 @@ var useComputedQrl = (qrl2) => {
29788
29917
  // packages/qwik/src/core/use/use-computed-dollar.ts
29789
29918
  var useComputed$ = implicit$FirstArg(useComputedQrl);
29790
29919
 
29791
- // packages/qwik/src/core/shared/prefetch-service-worker/prefetch.ts
29792
- import { isDev as isDev8 } from "@qwik.dev/core/build";
29793
-
29794
29920
  // packages/qwik/src/testing/vdom-diff.unit-util.ts
29795
29921
  import { expect } from "vitest";
29796
29922
  import { format } from "prettier";
@@ -29903,7 +30029,7 @@ expect.extend({
29903
30029
  };
29904
30030
  }
29905
30031
  });
29906
- var ignoredAttributes = [QSubscribers, ELEMENT_ID, "", Q_PROPS_SEPARATOR];
30032
+ var ignoredAttributes = [QBackRefs, ELEMENT_ID, "", Q_PROPS_SEPARATOR];
29907
30033
  function getContainerElement(vNode) {
29908
30034
  let maybeParent;
29909
30035
  do {
@@ -30331,7 +30457,6 @@ function attrsEqual(expectedValue, receivedValue) {
30331
30457
  }
30332
30458
 
30333
30459
  // packages/qwik/src/testing/element-fixture.ts
30334
- import { vi } from "vitest";
30335
30460
  import { getDomContainer as getDomContainer2 } from "../core.mjs";
30336
30461
 
30337
30462
  // packages/qwik/src/testing/platform.ts
@@ -30509,7 +30634,6 @@ var dispatch = async (element, attrName, event, scope) => {
30509
30634
  const isDocumentOrWindow = isDocumentOrWindowEvent(event.type);
30510
30635
  const preventAttributeName = PREVENT_DEFAULT + (isDocumentOrWindow ? event.type.substring(1) : event.type);
30511
30636
  const stopPropagationName = STOP_PROPAGATION + event.type;
30512
- const collectListeners = [];
30513
30637
  while (element) {
30514
30638
  const preventDefault = element.hasAttribute(preventAttributeName);
30515
30639
  const stopPropagation = element.hasAttribute(stopPropagationName);
@@ -30526,15 +30650,21 @@ var dispatch = async (element, attrName, event, scope) => {
30526
30650
  } else if (element.hasAttribute(attrName)) {
30527
30651
  const container = getDomContainer2(element);
30528
30652
  const qrl2 = element.getAttribute(attrName);
30529
- qrl2.split("\n").map((qrl3) => container.parseQRL(qrl3.trim())).map((qrl3) => qrl3(event, element));
30653
+ const ctx = newInvokeContextFromTuple([element, event]);
30654
+ try {
30655
+ await Promise.all(
30656
+ qrl2.split("\n").map((qrl3) => container.parseQRL(qrl3.trim())).map((qrl3) => {
30657
+ return invokeApply(ctx, qrl3, [event, element]);
30658
+ })
30659
+ );
30660
+ } catch (error) {
30661
+ console.error("!!! qrl error", qrl2, error);
30662
+ throw error;
30663
+ }
30530
30664
  return;
30531
30665
  }
30532
30666
  element = element.parentElement;
30533
30667
  }
30534
- for (let i = 0; i < collectListeners.length; i++) {
30535
- const { element: element2, qrl: qrl2 } = collectListeners[i];
30536
- await qrl2.getFn([element2, event], () => element2.isConnected)(event, element2);
30537
- }
30538
30668
  };
30539
30669
 
30540
30670
  // packages/qwik/src/testing/library.ts
@@ -30579,7 +30709,21 @@ import { expect as expect2 } from "vitest";
30579
30709
 
30580
30710
  // packages/qwik/src/server/platform.ts
30581
30711
  import { setPlatform as setPlatform2 } from "../core.mjs";
30582
- var SYNC_QRL2 = "<sync>";
30712
+
30713
+ // packages/qwik/src/optimizer/src/versions.ts
30714
+ var versions2 = {
30715
+ qwik: globalThis.QWIK_VERSION
30716
+ };
30717
+
30718
+ // packages/qwik/src/optimizer/src/manifest.ts
30719
+ function getValidManifest(manifest) {
30720
+ if (manifest != null && manifest.mapping != null && typeof manifest.mapping === "object" && manifest.symbols != null && typeof manifest.symbols === "object" && manifest.bundles != null && typeof manifest.bundles === "object") {
30721
+ return manifest;
30722
+ }
30723
+ return void 0;
30724
+ }
30725
+
30726
+ // packages/qwik/src/server/platform.ts
30583
30727
  function createPlatform3(opts, resolvedManifest) {
30584
30728
  const mapper = resolvedManifest?.mapper;
30585
30729
  const mapperFn = opts.symbolMapper ? opts.symbolMapper : (symbolName, _chunk, parent) => {
@@ -30587,7 +30731,7 @@ function createPlatform3(opts, resolvedManifest) {
30587
30731
  const hash3 = getSymbolHash2(symbolName);
30588
30732
  const result = mapper[hash3];
30589
30733
  if (!result) {
30590
- if (hash3 === SYNC_QRL2) {
30734
+ if (hash3 === SYNC_QRL) {
30591
30735
  return [hash3, ""];
30592
30736
  }
30593
30737
  const isRegistered = globalThis.__qwik_reg_symbols?.has(hash3);
@@ -30649,19 +30793,6 @@ var getSymbolHash2 = (symbolName) => {
30649
30793
  return symbolName;
30650
30794
  };
30651
30795
 
30652
- // packages/qwik/src/optimizer/src/versions.ts
30653
- var versions2 = {
30654
- qwik: globalThis.QWIK_VERSION
30655
- };
30656
-
30657
- // packages/qwik/src/optimizer/src/manifest.ts
30658
- function getValidManifest(manifest) {
30659
- if (manifest != null && manifest.mapping != null && typeof manifest.mapping === "object" && manifest.symbols != null && typeof manifest.symbols === "object" && manifest.bundles != null && typeof manifest.bundles === "object") {
30660
- return manifest;
30661
- }
30662
- return void 0;
30663
- }
30664
-
30665
30796
  // packages/qwik/src/server/ssr-container.ts
30666
30797
  import {
30667
30798
  _EffectData as EffectData,
@@ -30671,7 +30802,7 @@ import {
30671
30802
  _walkJSX as _walkJSX2,
30672
30803
  isSignal as isSignal3
30673
30804
  } from "../core.mjs";
30674
- import { isDev as isDev11 } from "@qwik.dev/core/build";
30805
+ import { isDev as isDev10 } from "@qwik.dev/core/build";
30675
30806
 
30676
30807
  // packages/qwik/src/server/prefetch-utils.ts
30677
30808
  function workerFetchScript() {
@@ -30689,7 +30820,8 @@ function prefetchUrlsEventScript(base, prefetchResources) {
30689
30820
  bundles: flattenPrefetchResources(prefetchResources).map((u) => u.split("/").pop())
30690
30821
  };
30691
30822
  const args = JSON.stringify(["prefetch", base, ...data.bundles]);
30692
- return `(window.qwikPrefetchSW||(window.qwikPrefetchSW=[])).push(${args});`;
30823
+ return `document.dispatchEvent(new CustomEvent("qprefetch",{detail:${JSON.stringify(data)}}));
30824
+ (window.qwikPrefetchSW||(window.qwikPrefetchSW=[])).push(${args});`;
30693
30825
  }
30694
30826
  function flattenPrefetchResources(prefetchResources) {
30695
30827
  const urls = [];
@@ -30847,8 +30979,12 @@ var PrefetchImplementationDefault = {
30847
30979
  };
30848
30980
 
30849
30981
  // packages/qwik/src/server/ssr-node.ts
30850
- import { _isJSXNode as isJSXNode2, _EMPTY_ARRAY } from "../core.mjs";
30851
- import { isDev as isDev10 } from "@qwik.dev/core/build";
30982
+ import {
30983
+ _isJSXNode as isJSXNode2,
30984
+ _EMPTY_ARRAY,
30985
+ _EFFECT_BACK_REF as _EFFECT_BACK_REF2
30986
+ } from "../core.mjs";
30987
+ import { isDev as isDev9 } from "@qwik.dev/core/build";
30852
30988
  var SsrNode = class {
30853
30989
  constructor(currentComponentNode, nodeType, id, attrs, cleanupQueue, vnodeData) {
30854
30990
  this.attrs = attrs;
@@ -30871,10 +31007,13 @@ var SsrNode = class {
30871
31007
  this.currentComponentNode?.addChildVNodeData(this.vnodeData);
30872
31008
  this.nodeType = nodeType;
30873
31009
  this.id = id;
30874
- if (isDev10 && id.indexOf("undefined") != -1) {
31010
+ if (isDev9 && id.indexOf("undefined") != -1) {
30875
31011
  throw new Error(`Invalid SSR node id: ${id}`);
30876
31012
  }
30877
31013
  }
31014
+ get [_EFFECT_BACK_REF2]() {
31015
+ return this.getProp(QBackRefs);
31016
+ }
30878
31017
  setProp(name, value) {
30879
31018
  if (this.attrs === _EMPTY_ARRAY) {
30880
31019
  this.attrs = [];
@@ -31417,7 +31556,13 @@ var EMPTY_OBJ2 = {};
31417
31556
  var SSRContainer = class extends _SharedContainer2 {
31418
31557
  constructor(opts) {
31419
31558
  super(
31420
- () => null,
31559
+ () => {
31560
+ try {
31561
+ return this.$scheduler$(255 /* WAIT_FOR_ALL */);
31562
+ } catch (e) {
31563
+ this.handleError(e, null);
31564
+ }
31565
+ },
31421
31566
  () => null,
31422
31567
  opts.renderOptions.serverData ?? EMPTY_OBJ2,
31423
31568
  opts.locale
@@ -31485,15 +31630,14 @@ var SSRContainer = class extends _SharedContainer2 {
31485
31630
  this.renderOptions = opts.renderOptions;
31486
31631
  this.$processInjectionsFromManifest$();
31487
31632
  }
31488
- ensureProjectionResolved(host) {
31633
+ ensureProjectionResolved(_host) {
31489
31634
  }
31490
- handleError(err, $host$) {
31635
+ handleError(err, _$host$) {
31491
31636
  throw err;
31492
31637
  }
31493
31638
  async render(jsx4) {
31494
31639
  this.openContainer();
31495
31640
  await _walkJSX2(this, jsx4, {
31496
- allowPromises: true,
31497
31641
  currentStyleScoped: null,
31498
31642
  parentComponentFrame: this.getComponentFrame()
31499
31643
  });
@@ -31547,7 +31691,7 @@ var SSRContainer = class extends _SharedContainer2 {
31547
31691
  containerAttributes[QContainerAttr] = "paused" /* PAUSED */;
31548
31692
  containerAttributes[QRuntimeAttr] = "2";
31549
31693
  containerAttributes[QVersionAttr] = this.$version$ ?? "dev";
31550
- containerAttributes[QRenderAttr] = (qRender ? qRender + "-" : "") + (isDev11 ? "ssr-dev" : "ssr");
31694
+ containerAttributes[QRenderAttr] = (qRender ? qRender + "-" : "") + (isDev10 ? "ssr-dev" : "ssr");
31551
31695
  containerAttributes[QBaseAttr] = this.buildBase || "";
31552
31696
  containerAttributes[QLocaleAttr] = this.$locale$;
31553
31697
  containerAttributes[QManifestHashAttr] = this.resolvedManifest.manifest.manifestHash;
@@ -31582,7 +31726,7 @@ var SSRContainer = class extends _SharedContainer2 {
31582
31726
  innerHTML = this.writeAttrs(elementName, varAttrs, false, currentFile);
31583
31727
  }
31584
31728
  this.write(" " + Q_PROPS_SEPARATOR);
31585
- isDev11 && this.write('=""');
31729
+ isDev10 && this.write('=""');
31586
31730
  if (constAttrs && constAttrs.length) {
31587
31731
  innerHTML = this.writeAttrs(elementName, constAttrs, true, currentFile) || innerHTML;
31588
31732
  }
@@ -31903,8 +32047,8 @@ var SSRContainer = class extends _SharedContainer2 {
31903
32047
  case ELEMENT_SEQ_IDX:
31904
32048
  write(VNodeDataChar.SEQ_IDX_CHAR);
31905
32049
  break;
31906
- case QSubscribers:
31907
- write(VNodeDataChar.SUBS_CHAR);
32050
+ case QBackRefs:
32051
+ write(VNodeDataChar.BACK_REFS_CHAR);
31908
32052
  break;
31909
32053
  // Skipping `\` character for now because it is used for escaping.
31910
32054
  case QCtxAttr:
@@ -32101,7 +32245,7 @@ var SSRContainer = class extends _SharedContainer2 {
32101
32245
  }
32102
32246
  this.unclaimedProjectionComponentFrameQueue.shift();
32103
32247
  this.openFragment(
32104
- isDev11 ? [DEBUG_TYPE, "P" /* Projection */, QSlotParent, ssrComponentNode.id] : [QSlotParent, ssrComponentNode.id]
32248
+ isDev10 ? [DEBUG_TYPE, "P" /* Projection */, QSlotParent, ssrComponentNode.id] : [QSlotParent, ssrComponentNode.id]
32105
32249
  );
32106
32250
  const lastNode = this.getLastNode();
32107
32251
  if (lastNode.vnodeData) {
@@ -32109,7 +32253,6 @@ var SSRContainer = class extends _SharedContainer2 {
32109
32253
  }
32110
32254
  ssrComponentNode?.setProp(value, lastNode.id);
32111
32255
  await _walkJSX2(this, children, {
32112
- allowPromises: true,
32113
32256
  currentStyleScoped: scopedStyleId,
32114
32257
  parentComponentFrame: null
32115
32258
  });
@@ -32151,7 +32294,7 @@ var SSRContainer = class extends _SharedContainer2 {
32151
32294
  }
32152
32295
  createAndPushFrame(elementName, depthFirstElementIdx, currentFile) {
32153
32296
  let tagNesting = 10 /* ANYTHING */;
32154
- if (isDev11) {
32297
+ if (isDev10) {
32155
32298
  if (!this.currentElementFrame) {
32156
32299
  tagNesting = initialTag(elementName);
32157
32300
  } else {
@@ -32227,8 +32370,8 @@ var SSRContainer = class extends _SharedContainer2 {
32227
32370
  let value = attrs[i];
32228
32371
  let styleScopedId = null;
32229
32372
  if (isSSRUnsafeAttr(key)) {
32230
- if (isDev11) {
32231
- throw qError(50 /* unsafeAttr */);
32373
+ if (isDev10) {
32374
+ throw qError(49 /* unsafeAttr */);
32232
32375
  }
32233
32376
  continue;
32234
32377
  }
@@ -32245,6 +32388,8 @@ var SSRContainer = class extends _SharedContainer2 {
32245
32388
  } else if (typeof value === "function") {
32246
32389
  value(new DomRef(lastNode));
32247
32390
  continue;
32391
+ } else if (value == null) {
32392
+ continue;
32248
32393
  } else {
32249
32394
  throw qError(32 /* invalidRefValue */, [currentFile]);
32250
32395
  }
@@ -32267,7 +32412,7 @@ var SSRContainer = class extends _SharedContainer2 {
32267
32412
  }
32268
32413
  if (tag === "textarea" && key === "value") {
32269
32414
  if (value && typeof value !== "string") {
32270
- if (isDev11) {
32415
+ if (isDev10) {
32271
32416
  throw qError(40 /* wrongTextareaValue */, [currentFile, value]);
32272
32417
  }
32273
32418
  continue;
@@ -32610,7 +32755,7 @@ async function ssrRenderToDom(jsx4, opts = {}) {
32610
32755
  let child = firstContainerChild;
32611
32756
  let insertBefore = null;
32612
32757
  while (child) {
32613
- if (vnode_isElementVNode(child) && (vnode_getElementName(child) === "script" && vnode_getAttr(child, "type") === "qwik/state" || vnode_getElementName(child) === "q:template")) {
32758
+ if (vnode_isElementVNode(child) && (vnode_getElementName(child) === "script" && (vnode_getAttr(child, "type") === "qwik/state" || vnode_getAttr(child, "id") === "qwikloader") || vnode_getElementName(child) === "q:template")) {
32614
32759
  insertBefore = child;
32615
32760
  break;
32616
32761
  }
@@ -32670,14 +32815,16 @@ function renderStyles(getStyles) {
32670
32815
  console.log(START2 + key + ": " + END2 + value);
32671
32816
  });
32672
32817
  }
32673
- async function rerenderComponent(element) {
32818
+ async function rerenderComponent(element, flush) {
32674
32819
  const container = _getDomContainer(element);
32675
32820
  const vElement = vnode_locate(container.rootVNode, element);
32676
32821
  const host = getHostVNode(vElement);
32677
32822
  const qrl2 = container.getHostProp(host, OnRenderProp);
32678
32823
  const props = container.getHostProp(host, ELEMENT_PROPS);
32679
- await container.$scheduler$(7 /* COMPONENT */, host, qrl2, props);
32680
- await getTestPlatform().flush();
32824
+ container.$scheduler$(6 /* COMPONENT */, host, qrl2, props);
32825
+ if (flush) {
32826
+ await getTestPlatform().flush();
32827
+ }
32681
32828
  }
32682
32829
  function getHostVNode(vElement) {
32683
32830
  while (vElement != null) {