@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
@@ -22166,7 +22166,7 @@ var seal = (obj) => {
22166
22166
  };
22167
22167
 
22168
22168
  // packages/qwik/src/core/shared/qrl/qrl-class.ts
22169
- var import_build8 = require("@qwik.dev/core/build");
22169
+ var import_build10 = require("@qwik.dev/core/build");
22170
22170
 
22171
22171
  // packages/qwik/src/core/shared/utils/log.ts
22172
22172
  var STYLE = qDev ? `background: #564CE0; color: white; padding: 2px 3px; border-radius: 2px; font-size: 0.8em;` : "";
@@ -22246,10 +22246,10 @@ var codeToText = (code2, ...parts) => {
22246
22246
  const MAP = [
22247
22247
  "Error while serializing class or style attributes",
22248
22248
  // 0
22249
- "",
22250
- // 1 unused
22251
- "",
22252
- // 2 unused
22249
+ "Scheduler not found",
22250
+ // 1
22251
+ "track() received object, without prop to track",
22252
+ // 2
22253
22253
  "Only primitive and object literals can be serialized. {{0}}",
22254
22254
  // 3
22255
22255
  "",
@@ -22336,17 +22336,15 @@ See https://qwik.dev/docs/components/tasks/#use-method-rules`,
22336
22336
  "Materialize error: missing element: {{0}} {{1}} {{2}}",
22337
22337
  // 44
22338
22338
  "Cannot coerce a Signal, use `.value` instead",
22339
- // 46
22339
+ // 45
22340
22340
  "useComputedSignal$ QRL {{0}} {{1}} returned a Promise",
22341
- // 47
22341
+ // 46
22342
22342
  "ComputedSignal is read-only",
22343
- // 48
22343
+ // 47
22344
22344
  "WrappedSignal is read-only",
22345
- // 49
22346
- "SsrError: Promises not expected here.",
22347
- // 50
22345
+ // 48
22348
22346
  "Attribute value is unsafe for SSR"
22349
- // 51
22347
+ // 49
22350
22348
  ];
22351
22349
  let text = MAP[code2] ?? "";
22352
22350
  if (parts.length) {
@@ -22369,7 +22367,31 @@ var qError = (code2, errorMessageArgs = []) => {
22369
22367
  };
22370
22368
 
22371
22369
  // packages/qwik/src/core/shared/platform/platform.ts
22370
+ var import_build2 = require("@qwik.dev/core/build");
22371
+
22372
+ // packages/qwik/src/core/shared/qrl/qrl-utils.ts
22372
22373
  var import_build = require("@qwik.dev/core/build");
22374
+ var SYNC_QRL = "<sync>";
22375
+ var isSyncQrl = (value) => {
22376
+ return isQrl(value) && value.$symbol$ == SYNC_QRL;
22377
+ };
22378
+ var isQrl = (value) => {
22379
+ return typeof value === "function" && typeof value.getSymbol === "function";
22380
+ };
22381
+ function assertQrl(qrl2) {
22382
+ if (import_build.isDev) {
22383
+ if (!isQrl(qrl2)) {
22384
+ throw new Error("Not a QRL");
22385
+ }
22386
+ }
22387
+ }
22388
+ var getSymbolHash = (symbolName) => {
22389
+ const index = symbolName.lastIndexOf("_");
22390
+ if (index > -1) {
22391
+ return symbolName.slice(index + 1);
22392
+ }
22393
+ return symbolName;
22394
+ };
22373
22395
 
22374
22396
  // packages/qwik/src/core/shared/types.ts
22375
22397
  var DEBUG_TYPE = "q:type";
@@ -22415,7 +22437,7 @@ var VirtualTypeName = {
22415
22437
 
22416
22438
  // packages/qwik/src/core/shared/utils/markers.ts
22417
22439
  var OnRenderProp = "q:renderFn";
22418
- var ComponentStylesPrefixContent = "\u2B50\uFE0F";
22440
+ var ComponentStylesPrefixContent = "\u26A1\uFE0F";
22419
22441
  var QSlot = "q:slot";
22420
22442
  var QSlotParent = ":";
22421
22443
  var QSlotRef = "q:sref";
@@ -22426,7 +22448,7 @@ var QStyleSSelector = "style[q\\:sstyle]";
22426
22448
  var QStylesAllSelector = QStyleSelector + "," + QStyleSSelector;
22427
22449
  var QScopedStyle = "q:sstyle";
22428
22450
  var QCtxAttr = "q:ctx";
22429
- var QSubscribers = "q:subs";
22451
+ var QBackRefs = "q:brefs";
22430
22452
  var QFuncsPrefix = "qFuncs_";
22431
22453
  var getQFuncs = (document2, hash3) => {
22432
22454
  return document2[QFuncsPrefix + hash3] || [];
@@ -22472,10 +22494,10 @@ var dangerouslySetInnerHTML = "dangerouslySetInnerHTML";
22472
22494
  // packages/qwik/src/core/shared/platform/platform.ts
22473
22495
  var createPlatform = () => {
22474
22496
  return {
22475
- isServer: import_build.isServer,
22497
+ isServer: import_build2.isServer,
22476
22498
  importSymbol(containerEl, url, symbolName) {
22477
22499
  var _a;
22478
- if (import_build.isServer) {
22500
+ if (import_build2.isServer) {
22479
22501
  const hash3 = getSymbolHash(symbolName);
22480
22502
  const regSym = (_a = globalThis.__qwik_reg_symbols) == null ? void 0 : _a.get(hash3);
22481
22503
  if (regSym) {
@@ -22563,9 +22585,6 @@ var safeCall = (call, thenFn, rejectFn) => {
22563
22585
  var maybeThen = (valueOrPromise, thenFn) => {
22564
22586
  return isPromise(valueOrPromise) ? valueOrPromise.then(thenFn, shouldNotError) : thenFn(valueOrPromise);
22565
22587
  };
22566
- var maybeThenPassError = (valueOrPromise, thenFn) => {
22567
- return isPromise(valueOrPromise) ? valueOrPromise.then(thenFn) : thenFn(valueOrPromise);
22568
- };
22569
22588
  var shouldNotError = (reason) => {
22570
22589
  throwErrorAndStop(reason);
22571
22590
  };
@@ -22611,7 +22630,7 @@ var isFunction = (v) => {
22611
22630
  };
22612
22631
 
22613
22632
  // packages/qwik/src/build/index.dev.ts
22614
- var isDev = true;
22633
+ var isDev2 = true;
22615
22634
 
22616
22635
  // packages/qwik/src/core/use/use-locale.ts
22617
22636
  var _locale = void 0;
@@ -22620,7 +22639,7 @@ function setLocale(locale) {
22620
22639
  }
22621
22640
 
22622
22641
  // packages/qwik/src/core/client/vnode.ts
22623
- var import_build6 = require("@qwik.dev/core/build");
22642
+ var import_build8 = require("@qwik.dev/core/build");
22624
22643
 
22625
22644
  // packages/qwik/src/server/utils.ts
22626
22645
  var import_meta = {};
@@ -22654,7 +22673,7 @@ var versions = {
22654
22673
  };
22655
22674
 
22656
22675
  // packages/qwik/src/server/prefetch-strategy.ts
22657
- var import_build2 = require("@qwik.dev/core/build");
22676
+ var import_build3 = require("@qwik.dev/core/build");
22658
22677
  function getPrefetchResources(qrls, opts, resolvedManifest) {
22659
22678
  if (!resolvedManifest) {
22660
22679
  return [];
@@ -22692,7 +22711,7 @@ function getAutoPrefetch(qrls, resolvedManifest, buildBase) {
22692
22711
  return prefetchResources;
22693
22712
  }
22694
22713
  function addBundle(manifest, urls, prefetchResources, buildBase, bundleFileName) {
22695
- const url = import_build2.isDev ? bundleFileName : buildBase + bundleFileName;
22714
+ const url = import_build3.isDev ? bundleFileName : buildBase + bundleFileName;
22696
22715
  let prefetchResource = urls.get(url);
22697
22716
  if (!prefetchResource) {
22698
22717
  prefetchResource = {
@@ -22711,7 +22730,7 @@ function addBundle(manifest, urls, prefetchResources, buildBase, bundleFileName)
22711
22730
  }
22712
22731
  prefetchResources.push(prefetchResource);
22713
22732
  }
22714
- var isQrl = (value) => {
22733
+ var isQrl2 = (value) => {
22715
22734
  return typeof value === "function" && typeof value.getSymbol === "function";
22716
22735
  };
22717
22736
 
@@ -22723,12 +22742,9 @@ Object.freeze(EMPTY_OBJ);
22723
22742
 
22724
22743
  // packages/qwik/src/core/shared/qrl/qrl.ts
22725
22744
  var inlinedQrl = (symbol, symbolName, lexicalScopeCapture = EMPTY_ARRAY) => {
22726
- return createQRL(null, symbolName, symbol, null, null, lexicalScopeCapture, null);
22745
+ return createQRL(null, symbolName, symbol, null, null, lexicalScopeCapture);
22727
22746
  };
22728
22747
 
22729
- // packages/qwik/src/core/ssr/ssr-render-jsx.ts
22730
- var import_build5 = require("@qwik.dev/core/build");
22731
-
22732
22748
  // packages/qwik/src/core/shared/jsx/slot.public.ts
22733
22749
  var Slot = (props) => {
22734
22750
  return _jsxSorted(Virtual, null, { [QSlotS]: "" }, props.children, 0, props.name ?? "");
@@ -22815,6 +22831,50 @@ function isPreventDefault(key) {
22815
22831
  return key.startsWith("preventdefault:");
22816
22832
  }
22817
22833
 
22834
+ // packages/qwik/src/core/shared/utils/jsx-filename.ts
22835
+ function getFileLocationFromJsx(jsxDev) {
22836
+ var _a;
22837
+ if (!jsxDev) {
22838
+ return null;
22839
+ }
22840
+ const sanitizedFileName = (_a = jsxDev.fileName) == null ? void 0 : _a.replace(/\\/g, "/");
22841
+ if (sanitizedFileName) {
22842
+ return `${sanitizedFileName}:${jsxDev.lineNumber}:${jsxDev.columnNumber}`;
22843
+ }
22844
+ return null;
22845
+ }
22846
+
22847
+ // packages/qwik/src/core/shared/utils/scoped-styles.ts
22848
+ var styleContent = (styleId) => {
22849
+ return ComponentStylesPrefixContent + styleId;
22850
+ };
22851
+ function hasClassAttr(props) {
22852
+ for (const key in props) {
22853
+ if (Object.prototype.hasOwnProperty.call(props, key) && isClassAttr(key)) {
22854
+ return true;
22855
+ }
22856
+ }
22857
+ return false;
22858
+ }
22859
+ function isClassAttr(key) {
22860
+ return key === "class" || key === "className";
22861
+ }
22862
+ function convertScopedStyleIdsToArray(scopedStyleIds) {
22863
+ return (scopedStyleIds == null ? void 0 : scopedStyleIds.split(" ")) ?? null;
22864
+ }
22865
+ function convertStyleIdsToString(scopedStyleIds) {
22866
+ return Array.from(scopedStyleIds).join(" ");
22867
+ }
22868
+ var addComponentStylePrefix = (styleId) => {
22869
+ if (styleId) {
22870
+ let idx = 0;
22871
+ do {
22872
+ styleId = styleId.substring(0, idx) + styleContent(styleId.substring(idx));
22873
+ } while ((idx = styleId.indexOf(" ", idx) + 1) !== 0);
22874
+ }
22875
+ return styleId || null;
22876
+ };
22877
+
22818
22878
  // packages/qwik/src/core/shared/utils/unitless_number.ts
22819
22879
  var unitlessNumbers = /* @__PURE__ */ new Set([
22820
22880
  "animationIterationCount",
@@ -22952,37 +23012,6 @@ var setValueForStyle = (styleName, value) => {
22952
23012
  function isAriaAttribute(prop) {
22953
23013
  return prop.startsWith("aria-");
22954
23014
  }
22955
- var styleContent = (styleId) => {
22956
- return ComponentStylesPrefixContent + styleId;
22957
- };
22958
-
22959
- // packages/qwik/src/core/shared/utils/scoped-styles.ts
22960
- function hasClassAttr(props) {
22961
- for (const key in props) {
22962
- if (Object.prototype.hasOwnProperty.call(props, key) && isClassAttr(key)) {
22963
- return true;
22964
- }
22965
- }
22966
- return false;
22967
- }
22968
- function isClassAttr(key) {
22969
- return key === "class" || key === "className";
22970
- }
22971
- function convertScopedStyleIdsToArray(scopedStyleIds) {
22972
- return (scopedStyleIds == null ? void 0 : scopedStyleIds.split(" ")) ?? null;
22973
- }
22974
- function convertStyleIdsToString(scopedStyleIds) {
22975
- return Array.from(scopedStyleIds).join(" ");
22976
- }
22977
- var addComponentStylePrefix = (styleId) => {
22978
- if (styleId) {
22979
- let idx = 0;
22980
- do {
22981
- styleId = styleId.substring(0, idx) + styleContent(styleId.substring(idx));
22982
- } while ((idx = styleId.indexOf(" ", idx) + 1) !== 0);
22983
- }
22984
- return styleId || null;
22985
- };
22986
23015
 
22987
23016
  // packages/qwik/src/core/signal/store.ts
22988
23017
  var DEBUG = false;
@@ -23118,8 +23147,12 @@ var StoreHandler = class {
23118
23147
  return Reflect.ownKeys(target);
23119
23148
  }
23120
23149
  getOwnPropertyDescriptor(target, prop) {
23150
+ const descriptor = Reflect.getOwnPropertyDescriptor(target, prop);
23121
23151
  if (Array.isArray(target) || typeof prop === "symbol") {
23122
- return Object.getOwnPropertyDescriptor(target, prop);
23152
+ return descriptor;
23153
+ }
23154
+ if (descriptor && !descriptor.configurable) {
23155
+ return descriptor;
23123
23156
  }
23124
23157
  return {
23125
23158
  enumerable: true,
@@ -23127,17 +23160,18 @@ var StoreHandler = class {
23127
23160
  };
23128
23161
  }
23129
23162
  };
23130
- function addEffect(target, prop, store, effectSubscriber) {
23131
- const effectsMap = store.$effects$ ||= {};
23132
- const effects = Object.prototype.hasOwnProperty.call(effectsMap, prop) && effectsMap[prop] || (effectsMap[prop] = []);
23133
- ensureContainsEffect(effects, effectSubscriber);
23134
- ensureContains(effectSubscriber, target);
23135
- ensureEffectContainsSubscriber(
23136
- effectSubscriber[0 /* EFFECT */],
23137
- target,
23138
- store.$container$
23139
- );
23140
- DEBUG && log("sub", pad("\n" + store.$effects$.toString(), " "));
23163
+ function addEffect(target, prop, store, effectSubscription) {
23164
+ var _a;
23165
+ const effectsMap = store.$effects$ ||= /* @__PURE__ */ new Map();
23166
+ let effects = effectsMap.get(prop);
23167
+ if (!effects) {
23168
+ effects = /* @__PURE__ */ new Set();
23169
+ effectsMap.set(prop, effects);
23170
+ }
23171
+ ensureContainsSubscription(effects, effectSubscription);
23172
+ ensureContainsBackRef(effectSubscription, target);
23173
+ addQrlToSerializationCtx(effectSubscription, store.$container$);
23174
+ DEBUG && log("sub", pad("\n" + ((_a = store.$effects$) == null ? void 0 : _a.entries.toString()), " "));
23141
23175
  }
23142
23176
  function setNewValueAndTriggerEffects(prop, value, target, currentStore) {
23143
23177
  target[prop] = value;
@@ -23148,15 +23182,87 @@ function setNewValueAndTriggerEffects(prop, value, target, currentStore) {
23148
23182
  );
23149
23183
  }
23150
23184
  function getEffects(target, prop, storeEffects) {
23151
- let effectsToTrigger = storeEffects ? Array.isArray(target) ? Object.values(storeEffects).flatMap((effects) => effects) : storeEffects[prop] : null;
23152
- const storeArrayValue = storeEffects == null ? void 0 : storeEffects[STORE_ARRAY_PROP];
23185
+ let effectsToTrigger;
23186
+ if (storeEffects) {
23187
+ if (Array.isArray(target)) {
23188
+ for (const effects of storeEffects.values()) {
23189
+ effectsToTrigger ||= /* @__PURE__ */ new Set();
23190
+ for (const effect of effects) {
23191
+ effectsToTrigger.add(effect);
23192
+ }
23193
+ }
23194
+ } else {
23195
+ effectsToTrigger = storeEffects.get(prop);
23196
+ }
23197
+ }
23198
+ const storeArrayValue = storeEffects == null ? void 0 : storeEffects.get(STORE_ARRAY_PROP);
23153
23199
  if (storeArrayValue) {
23154
- effectsToTrigger ||= [];
23155
- effectsToTrigger.push(...storeArrayValue);
23200
+ effectsToTrigger ||= /* @__PURE__ */ new Set();
23201
+ for (const effect of storeArrayValue) {
23202
+ effectsToTrigger.add(effect);
23203
+ }
23204
+ }
23205
+ return effectsToTrigger || null;
23206
+ }
23207
+
23208
+ // packages/qwik/src/core/signal/flags.ts
23209
+ var NEEDS_COMPUTATION = Symbol("invalid");
23210
+ var _EFFECT_BACK_REF = Symbol("backRef");
23211
+
23212
+ // packages/qwik/src/core/signal/signal-cleanup.ts
23213
+ var BackRef = class {
23214
+ [_EFFECT_BACK_REF] = null;
23215
+ };
23216
+ function clearAllEffects(container, consumer) {
23217
+ if (vnode_isVNode(consumer) && vnode_isElementVNode(consumer)) {
23218
+ ensureMaterialized(consumer);
23219
+ }
23220
+ const effects = consumer[_EFFECT_BACK_REF];
23221
+ if (!effects) {
23222
+ return;
23223
+ }
23224
+ for (const [, effect] of effects) {
23225
+ const backRefs = effect[2 /* BACK_REF */];
23226
+ if (!backRefs) {
23227
+ return;
23228
+ }
23229
+ for (const producer of backRefs) {
23230
+ if (producer instanceof Signal) {
23231
+ clearSignal(container, producer, effect);
23232
+ } else if (container.$storeProxyMap$.has(producer)) {
23233
+ const target = container.$storeProxyMap$.get(producer);
23234
+ const storeHandler = getStoreHandler(target);
23235
+ clearStore(storeHandler, effect);
23236
+ }
23237
+ }
23238
+ }
23239
+ }
23240
+ function clearSignal(container, producer, effect) {
23241
+ const effects = producer.$effects$;
23242
+ if (effects) {
23243
+ effects.delete(effect);
23244
+ }
23245
+ if (producer instanceof WrappedSignal) {
23246
+ producer.$hostElement$ = null;
23247
+ clearAllEffects(container, producer);
23248
+ }
23249
+ }
23250
+ function clearStore(producer, effect) {
23251
+ const effects = producer == null ? void 0 : producer.$effects$;
23252
+ if (effects) {
23253
+ for (const propEffects of effects.values()) {
23254
+ propEffects.delete(effect);
23255
+ }
23156
23256
  }
23157
- return effectsToTrigger;
23158
23257
  }
23159
23258
 
23259
+ // packages/qwik/src/core/shared/qrl/implicit_dollar.ts
23260
+ var implicit$FirstArg = (fn) => {
23261
+ return function(first, ...rest) {
23262
+ return fn.call(null, dollar(first), ...rest);
23263
+ };
23264
+ };
23265
+
23160
23266
  // packages/qwik/src/core/use/use-sequential-scope.ts
23161
23267
  var useSequentialScope = () => {
23162
23268
  const iCtx = useInvokeContext();
@@ -23189,171 +23295,41 @@ var useSequentialScope = () => {
23189
23295
  };
23190
23296
  };
23191
23297
 
23192
- // packages/qwik/src/core/signal/signal-subscriber.ts
23193
- var Subscriber = class {
23194
- $effectDependencies$ = null;
23195
- };
23196
- function isSubscriber(value) {
23197
- return value instanceof Subscriber || value instanceof WrappedSignal;
23198
- }
23199
- function clearVNodeEffectDependencies(container, value) {
23200
- if (vnode_isElementVNode(value)) {
23201
- ensureMaterialized(value);
23202
- }
23203
- const effects = vnode_getProp(value, QSubscribers, container.$getObjectById$);
23204
- if (!effects) {
23205
- return;
23206
- }
23207
- for (let i = effects.length - 1; i >= 0; i--) {
23208
- const subscriber = effects[i];
23209
- clearEffects(subscriber, value, effects, i, container);
23210
- }
23211
- if (effects.length === 0) {
23212
- vnode_setProp(value, QSubscribers, null);
23213
- }
23214
- }
23215
- function clearSubscriberEffectDependencies(container, value) {
23216
- if (value.$effectDependencies$) {
23217
- for (let i = value.$effectDependencies$.length - 1; i >= 0; i--) {
23218
- const subscriber = value.$effectDependencies$[i];
23219
- clearEffects(subscriber, value, value.$effectDependencies$, i, container);
23220
- }
23221
- if (value.$effectDependencies$.length === 0) {
23222
- value.$effectDependencies$ = null;
23223
- }
23224
- }
23225
- }
23226
- function clearEffects(subscriber, value, effectArray, indexToRemove, container) {
23227
- let subscriptionRemoved = false;
23228
- const seenSet = /* @__PURE__ */ new Set();
23229
- if (subscriber instanceof WrappedSignal) {
23230
- subscriptionRemoved = clearSignalEffects(subscriber, value, seenSet);
23231
- } else if (container.$storeProxyMap$.has(subscriber)) {
23232
- const store = container.$storeProxyMap$.get(subscriber);
23233
- const handler = getStoreHandler(store);
23234
- subscriptionRemoved = clearStoreEffects(handler, value);
23235
- }
23236
- if (subscriptionRemoved) {
23237
- effectArray.splice(indexToRemove, 1);
23238
- }
23239
- }
23240
- function clearSignalEffects(subscriber, value, seenSet) {
23241
- const effectSubscriptions = subscriber.$effects$;
23242
- let subscriptionRemoved = false;
23243
- if (effectSubscriptions) {
23244
- for (let i = effectSubscriptions.length - 1; i >= 0; i--) {
23245
- const effect = effectSubscriptions[i];
23246
- if (effect[0 /* EFFECT */] === value) {
23247
- effectSubscriptions.splice(i, 1);
23248
- subscriptionRemoved = true;
23249
- }
23250
- }
23251
- }
23252
- if (subscriber instanceof WrappedSignal) {
23253
- const hostElement = subscriber.$hostElement$;
23254
- if (hostElement && hostElement === value) {
23255
- subscriber.$hostElement$ = null;
23256
- }
23257
- const args = subscriber.$args$;
23258
- if (args) {
23259
- clearArgsEffects(args, subscriber, seenSet);
23298
+ // packages/qwik/src/core/signal/subscriber.ts
23299
+ var import_build4 = require("@qwik.dev/core/build");
23300
+ function getSubscriber(effect, prop, data) {
23301
+ if (!effect[_EFFECT_BACK_REF]) {
23302
+ if (import_build4.isServer && isSsrNode(effect)) {
23303
+ effect.setProp(QBackRefs, /* @__PURE__ */ new Map());
23304
+ } else {
23305
+ effect[_EFFECT_BACK_REF] = /* @__PURE__ */ new Map();
23260
23306
  }
23261
23307
  }
23262
- return subscriptionRemoved;
23263
- }
23264
- function clearStoreEffects(storeHandler, value) {
23265
- const effectSubscriptions = storeHandler.$effects$;
23266
- if (!effectSubscriptions) {
23267
- return false;
23268
- }
23269
- let subscriptionRemoved = false;
23270
- for (const key in effectSubscriptions) {
23271
- const effects = effectSubscriptions[key];
23272
- for (let i = effects.length - 1; i >= 0; i--) {
23273
- const effect = effects[i];
23274
- if (effect[0 /* EFFECT */] === value) {
23275
- effects.splice(i, 1);
23276
- subscriptionRemoved = true;
23277
- }
23278
- }
23279
- if (effects.length === 0) {
23280
- delete effectSubscriptions[key];
23281
- }
23308
+ const subMap = effect[_EFFECT_BACK_REF];
23309
+ let sub = subMap.get(prop);
23310
+ if (!sub) {
23311
+ sub = [effect, prop];
23312
+ subMap.set(prop, sub);
23282
23313
  }
23283
- return subscriptionRemoved;
23284
- }
23285
- function clearArgsEffects(args, subscriber, seenSet) {
23286
- for (let i = args.length - 1; i >= 0; i--) {
23287
- const arg = args[i];
23288
- clearArgEffect(arg, subscriber, seenSet);
23314
+ if (data) {
23315
+ sub[3 /* DATA */] = data;
23289
23316
  }
23317
+ return sub;
23290
23318
  }
23291
- function clearArgEffect(arg, subscriber, seenSet) {
23292
- if (seenSet.has(arg)) {
23293
- return;
23294
- }
23295
- seenSet.add(arg);
23296
- if (isSignal(arg)) {
23297
- clearSignalEffects(arg, subscriber, seenSet);
23298
- } else if (typeof arg === "object" && arg !== null) {
23299
- if (isStore(arg)) {
23300
- clearStoreEffects(getStoreHandler(arg), subscriber);
23301
- } else if (isPropsProxy(arg)) {
23302
- const constProps = arg[_CONST_PROPS];
23303
- const varProps = arg[_VAR_PROPS];
23304
- if (constProps) {
23305
- for (const key in constProps) {
23306
- clearArgEffect(constProps[key], subscriber, seenSet);
23307
- }
23308
- }
23309
- for (const key in varProps) {
23310
- clearArgEffect(varProps[key], subscriber, seenSet);
23311
- }
23312
- } else {
23313
- for (const key in arg) {
23314
- clearArgEffect(arg[key], subscriber, seenSet);
23315
- }
23316
- }
23317
- } else if (Array.isArray(arg)) {
23318
- clearArgsEffects(arg, subscriber, seenSet);
23319
- } else {
23320
- }
23319
+ function isSsrNode(value) {
23320
+ return "__brand__" in value && "currentComponentNode" in value;
23321
23321
  }
23322
23322
 
23323
- // packages/qwik/src/core/use/use-resource.ts
23324
- var _createResourceReturn = (opts) => {
23325
- const resource = {
23326
- __brand: "resource",
23327
- value: void 0,
23328
- loading: isServerPlatform() ? false : true,
23329
- _resolved: void 0,
23330
- _error: void 0,
23331
- _state: "pending",
23332
- _timeout: (opts == null ? void 0 : opts.timeout) ?? -1,
23333
- _cache: 0
23334
- };
23335
- return resource;
23336
- };
23337
- var createResourceReturn = (container, opts, initialPromise) => {
23338
- const result = _createResourceReturn(opts);
23339
- result.value = initialPromise;
23340
- return createStore(container, result, 1 /* RECURSIVE */);
23341
- };
23342
- var runResource = (task, container, host) => {
23323
+ // packages/qwik/src/core/use/use-task.ts
23324
+ var runTask = (task, container, host) => {
23343
23325
  task.$flags$ &= ~8 /* DIRTY */;
23344
23326
  cleanupTask(task);
23345
- const iCtx = newInvokeContext(container.$locale$, host, void 0, ResourceEvent);
23327
+ const iCtx = newInvokeContext(container.$locale$, host, void 0, TaskEvent);
23346
23328
  iCtx.$container$ = container;
23347
- const taskFn = task.$qrl$.getFn(iCtx, () => clearSubscriberEffectDependencies(container, task));
23348
- const resource = task.$state$;
23349
- assertDefined(
23350
- resource,
23351
- 'useResource: when running a resource, "task.resource" must be a defined.',
23352
- task
23353
- );
23329
+ const taskFn = task.$qrl$.getFn(iCtx, () => clearAllEffects(container, task));
23354
23330
  const track = (obj, prop) => {
23355
23331
  const ctx = newInvokeContext();
23356
- ctx.$effectSubscriber$ = [task, ":" /* COMPONENT */];
23332
+ ctx.$effectSubscriber$ = getSubscriber(task, ":" /* COMPONENT */);
23357
23333
  ctx.$container$ = container;
23358
23334
  return invoke(ctx, () => {
23359
23335
  if (isFunction(obj)) {
@@ -23364,127 +23340,143 @@ var runResource = (task, container, host) => {
23364
23340
  } else if (isSignal(obj)) {
23365
23341
  return obj.value;
23366
23342
  } else {
23367
- return obj;
23343
+ throw qError(2 /* trackObjectWithoutProp */);
23368
23344
  }
23369
23345
  });
23370
23346
  };
23371
23347
  const handleError = (reason) => container.handleError(reason, host);
23372
- const cleanups = [];
23373
- task.$destroy$ = noSerialize(() => {
23374
- cleanups.forEach((fn) => {
23375
- try {
23376
- fn();
23377
- } catch (err) {
23378
- handleError(err);
23348
+ let cleanupFns = null;
23349
+ const cleanup2 = (fn) => {
23350
+ if (typeof fn == "function") {
23351
+ if (!cleanupFns) {
23352
+ cleanupFns = [];
23353
+ task.$destroy$ = noSerialize(() => {
23354
+ task.$destroy$ = null;
23355
+ cleanupFns.forEach((fn2) => {
23356
+ try {
23357
+ fn2();
23358
+ } catch (err) {
23359
+ handleError(err);
23360
+ }
23361
+ });
23362
+ });
23379
23363
  }
23380
- });
23381
- done = true;
23382
- });
23383
- const resourceTarget = unwrapStore(resource);
23384
- const opts = {
23385
- track,
23386
- cleanup(fn) {
23387
- if (typeof fn === "function") {
23388
- cleanups.push(fn);
23389
- }
23390
- },
23391
- cache(policy) {
23392
- let milliseconds = 0;
23393
- if (policy === "immutable") {
23394
- milliseconds = Infinity;
23395
- } else {
23396
- milliseconds = policy;
23397
- }
23398
- resource._cache = milliseconds;
23399
- },
23400
- previous: resourceTarget._resolved
23401
- };
23402
- let resolve;
23403
- let reject;
23404
- let done = false;
23405
- const setState = (resolved, value) => {
23406
- if (!done) {
23407
- done = true;
23408
- if (resolved) {
23409
- done = true;
23410
- resource.loading = false;
23411
- resource._state = "resolved";
23412
- resource._resolved = value;
23413
- resource._error = void 0;
23414
- resolve(value);
23415
- } else {
23416
- done = true;
23417
- resource.loading = false;
23418
- resource._state = "rejected";
23419
- resource._error = value;
23420
- reject(value);
23421
- }
23422
- return true;
23364
+ cleanupFns.push(fn);
23423
23365
  }
23424
- return false;
23425
23366
  };
23426
- cleanups.push(() => {
23427
- if (untrack(() => resource.loading) === true) {
23428
- const value = untrack(() => resource._resolved);
23429
- setState(true, value);
23430
- }
23431
- });
23432
- invoke(iCtx, () => {
23433
- resource._state = "pending";
23434
- resource.loading = !isServerPlatform();
23435
- const promise2 = resource.value = new Promise((r, re) => {
23436
- resolve = r;
23437
- reject = re;
23438
- });
23439
- promise2.catch(ignoreErrorToPreventNodeFromCrashing);
23440
- });
23441
- const promise = safeCall(
23442
- () => Promise.resolve(taskFn(opts)),
23443
- (value) => {
23444
- setState(true, value);
23445
- },
23367
+ const taskApi = { track, cleanup: cleanup2 };
23368
+ const result = safeCall(
23369
+ () => taskFn(taskApi),
23370
+ cleanup2,
23446
23371
  (err) => {
23447
23372
  if (isPromise(err)) {
23448
- return err.then(() => runResource(task, container, host));
23373
+ return err.then(() => runTask(task, container, host));
23449
23374
  } else {
23450
- setState(false, err);
23375
+ throw err;
23451
23376
  }
23452
23377
  }
23453
23378
  );
23454
- const timeout = resourceTarget._timeout;
23455
- if (timeout > 0) {
23456
- return Promise.race([
23457
- promise,
23458
- delay(timeout).then(() => {
23459
- if (setState(false, new Error("timeout"))) {
23460
- cleanupTask(task);
23461
- }
23462
- })
23463
- ]);
23379
+ return result;
23380
+ };
23381
+ var cleanupTask = (task) => {
23382
+ const destroy = task.$destroy$;
23383
+ if (destroy) {
23384
+ task.$destroy$ = null;
23385
+ try {
23386
+ destroy();
23387
+ } catch (err) {
23388
+ logError(err);
23389
+ }
23464
23390
  }
23465
- return promise;
23466
23391
  };
23467
- var ignoreErrorToPreventNodeFromCrashing = (err) => {
23392
+ var Task = class extends BackRef {
23393
+ constructor($flags$, $index$, $el$, $qrl$, $state$, $destroy$) {
23394
+ super();
23395
+ this.$flags$ = $flags$;
23396
+ this.$index$ = $index$;
23397
+ this.$el$ = $el$;
23398
+ this.$qrl$ = $qrl$;
23399
+ this.$state$ = $state$;
23400
+ this.$destroy$ = $destroy$;
23401
+ }
23402
+ };
23403
+ var isTask = (value) => {
23404
+ return value instanceof Task;
23468
23405
  };
23469
23406
 
23470
23407
  // packages/qwik/src/core/client/vnode-diff.ts
23471
- var import_build4 = require("@qwik.dev/core/build");
23408
+ var import_build7 = require("@qwik.dev/core/build");
23409
+
23410
+ // packages/qwik/src/core/client/util-mapArray.ts
23411
+ var mapApp_findIndx = (elementVNode, key, start) => {
23412
+ assertTrue(start % 2 === 0, "Expecting even number.");
23413
+ let bottom = start >> 1;
23414
+ let top = elementVNode.length - 2 >> 1;
23415
+ while (bottom <= top) {
23416
+ const mid = bottom + (top - bottom >> 1);
23417
+ const midKey = elementVNode[mid << 1];
23418
+ if (midKey === key) {
23419
+ return mid << 1;
23420
+ }
23421
+ if (midKey < key) {
23422
+ bottom = mid + 1;
23423
+ } else {
23424
+ top = mid - 1;
23425
+ }
23426
+ }
23427
+ return bottom << 1 ^ -1;
23428
+ };
23429
+ var mapArray_set = (elementVNode, key, value, start) => {
23430
+ const indx = mapApp_findIndx(elementVNode, key, start);
23431
+ if (indx >= 0) {
23432
+ if (value == null) {
23433
+ elementVNode.splice(indx, 2);
23434
+ } else {
23435
+ elementVNode[indx + 1] = value;
23436
+ }
23437
+ } else if (value != null) {
23438
+ elementVNode.splice(indx ^ -1, 0, key, value);
23439
+ }
23440
+ };
23441
+ var mapApp_remove = (elementVNode, key, start) => {
23442
+ const indx = mapApp_findIndx(elementVNode, key, start);
23443
+ let value = null;
23444
+ if (indx >= 0) {
23445
+ value = elementVNode[indx + 1];
23446
+ elementVNode.splice(indx, 2);
23447
+ return value;
23448
+ }
23449
+ return value;
23450
+ };
23451
+ var mapArray_get = (elementVNode, key, start) => {
23452
+ const indx = mapApp_findIndx(elementVNode, key, start);
23453
+ if (indx >= 0) {
23454
+ return elementVNode[indx + 1];
23455
+ } else {
23456
+ return null;
23457
+ }
23458
+ };
23472
23459
 
23473
23460
  // packages/qwik/src/core/client/vnode-namespace.ts
23474
- var isForeignObjectElement = (elementName) => elementName.toLowerCase() === "foreignobject";
23461
+ var import_build5 = require("@qwik.dev/core/build");
23462
+ var isForeignObjectElement = (elementName) => {
23463
+ return import_build5.isDev ? elementName.toLowerCase() === "foreignobject" : elementName === "foreignObject";
23464
+ };
23475
23465
  var isSvgElement = (elementName) => elementName === "svg" || isForeignObjectElement(elementName);
23476
23466
  var isMathElement = (elementName) => elementName === "math";
23477
23467
  var vnode_isDefaultNamespace = (vnode) => {
23478
23468
  const flags = vnode[0 /* flags */];
23479
23469
  return (flags & 192 /* NAMESPACE_MASK */) === 0;
23480
23470
  };
23481
- var vnode_getElementNamespaceFlags = (elementName) => {
23482
- if (isSvgElement(elementName)) {
23483
- return 64 /* NS_svg */;
23484
- } else if (isMathElement(elementName)) {
23485
- return 128 /* NS_math */;
23486
- } else {
23487
- return 0 /* NS_html */;
23471
+ var vnode_getElementNamespaceFlags = (element) => {
23472
+ const namespace = fastNamespaceURI(element);
23473
+ switch (namespace) {
23474
+ case SVG_NS:
23475
+ return 64 /* NS_svg */;
23476
+ case MATH_NS:
23477
+ return 128 /* NS_math */;
23478
+ default:
23479
+ return 0 /* NS_html */;
23488
23480
  }
23489
23481
  };
23490
23482
  function vnode_getDomChildrenWithCorrectNamespacesToInsert(journal, domParentVNode, newChild) {
@@ -23640,21 +23632,28 @@ function getNewElementNamespaceData(domParentVNode, tagOrVNode) {
23640
23632
  }
23641
23633
 
23642
23634
  // packages/qwik/src/core/shared/component-execution.ts
23643
- var import_build3 = require("@qwik.dev/core/build");
23635
+ var import_build6 = require("@qwik.dev/core/build");
23644
23636
  var executeComponent = (container, renderHost, subscriptionHost, componentQRL, props) => {
23645
- const iCtx = newInvokeContext(container.$locale$, subscriptionHost, void 0, RenderEvent);
23646
- iCtx.$effectSubscriber$ = [subscriptionHost, ":" /* COMPONENT */];
23647
- iCtx.$container$ = container;
23637
+ const iCtx = newInvokeContext(
23638
+ container.$locale$,
23639
+ subscriptionHost || void 0,
23640
+ void 0,
23641
+ RenderEvent
23642
+ );
23643
+ if (subscriptionHost) {
23644
+ iCtx.$effectSubscriber$ = getSubscriber(subscriptionHost, ":" /* COMPONENT */);
23645
+ iCtx.$container$ = container;
23646
+ }
23648
23647
  let componentFn;
23649
23648
  container.ensureProjectionResolved(renderHost);
23650
23649
  let isInlineComponent = false;
23651
23650
  if (componentQRL === null) {
23652
- componentQRL = componentQRL || container.getHostProp(renderHost, OnRenderProp);
23651
+ componentQRL = container.getHostProp(renderHost, OnRenderProp);
23653
23652
  assertDefined(componentQRL, "No Component found at this location");
23654
23653
  }
23655
- if (isQrl2(componentQRL)) {
23654
+ if (isQrl(componentQRL)) {
23656
23655
  props = props || container.getHostProp(renderHost, ELEMENT_PROPS) || EMPTY_OBJ;
23657
- if (props && props.children) {
23656
+ if (props.children) {
23658
23657
  delete props.children;
23659
23658
  }
23660
23659
  componentFn = componentQRL.getFn(iCtx);
@@ -23671,19 +23670,17 @@ var executeComponent = (container, renderHost, subscriptionHost, componentQRL, p
23671
23670
  if (!isInlineComponent) {
23672
23671
  container.setHostProp(renderHost, ELEMENT_SEQ_IDX, null);
23673
23672
  container.setHostProp(renderHost, USE_ON_LOCAL_SEQ_IDX, null);
23674
- if (container.getHostProp(renderHost, ELEMENT_PROPS) !== props) {
23675
- container.setHostProp(renderHost, ELEMENT_PROPS, props);
23676
- }
23673
+ container.setHostProp(renderHost, ELEMENT_PROPS, props);
23677
23674
  }
23678
23675
  if (vnode_isVNode(renderHost)) {
23679
- clearVNodeEffectDependencies(container, renderHost);
23676
+ clearAllEffects(container, renderHost);
23680
23677
  }
23681
23678
  return componentFn(props);
23682
23679
  },
23683
23680
  (jsx4) => {
23684
23681
  const useOnEvents = container.getHostProp(renderHost, USE_ON_LOCAL);
23685
23682
  if (useOnEvents) {
23686
- return maybeThen(addUseOnEvents(jsx4, useOnEvents), () => jsx4);
23683
+ return addUseOnEvents(jsx4, useOnEvents);
23687
23684
  }
23688
23685
  return jsx4;
23689
23686
  },
@@ -23701,6 +23698,7 @@ var executeComponent = (container, renderHost, subscriptionHost, componentQRL, p
23701
23698
  };
23702
23699
  function addUseOnEvents(jsx4, useOnEvents) {
23703
23700
  const jsxElement = findFirstStringJSX(jsx4);
23701
+ let jsxResult = jsx4;
23704
23702
  return maybeThen(jsxElement, (jsxElement2) => {
23705
23703
  let isInvisibleComponent = false;
23706
23704
  if (!jsxElement2) {
@@ -23710,16 +23708,18 @@ function addUseOnEvents(jsx4, useOnEvents) {
23710
23708
  if (Object.prototype.hasOwnProperty.call(useOnEvents, key)) {
23711
23709
  if (isInvisibleComponent) {
23712
23710
  if (key === "onQvisible$") {
23713
- jsxElement2 = addScriptNodeForInvisibleComponents(jsx4);
23714
- if (jsxElement2) {
23715
- addUseOnEvent(jsxElement2, "document:onQinit$", useOnEvents[key]);
23711
+ const [jsxElement3, jsx5] = addScriptNodeForInvisibleComponents(jsxResult);
23712
+ jsxResult = jsx5;
23713
+ if (jsxElement3) {
23714
+ addUseOnEvent(jsxElement3, "document:onQinit$", useOnEvents[key]);
23716
23715
  }
23717
23716
  } else if (key.startsWith("document:") || key.startsWith("window:")) {
23718
- jsxElement2 = addScriptNodeForInvisibleComponents(jsx4);
23719
- if (jsxElement2) {
23720
- addUseOnEvent(jsxElement2, key, useOnEvents[key]);
23717
+ const [jsxElement3, jsx5] = addScriptNodeForInvisibleComponents(jsxResult);
23718
+ jsxResult = jsx5;
23719
+ if (jsxElement3) {
23720
+ addUseOnEvent(jsxElement3, key, useOnEvents[key]);
23721
23721
  }
23722
- } else if (import_build3.isDev) {
23722
+ } else if (import_build6.isDev) {
23723
23723
  logWarn(
23724
23724
  '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. '
23725
23725
  );
@@ -23729,7 +23729,7 @@ function addUseOnEvents(jsx4, useOnEvents) {
23729
23729
  }
23730
23730
  }
23731
23731
  }
23732
- return jsxElement2;
23732
+ return jsxResult;
23733
23733
  });
23734
23734
  }
23735
23735
  function addUseOnEvent(jsxElement, key, value) {
@@ -23780,6 +23780,9 @@ function addScriptNodeForInvisibleComponents(jsx4) {
23780
23780
  null,
23781
23781
  3
23782
23782
  );
23783
+ if (jsx4.type === Slot) {
23784
+ return [jsxElement, _jsxSorted(Fragment, null, null, [jsx4, jsxElement], 0, null)];
23785
+ }
23783
23786
  if (jsx4.children == null) {
23784
23787
  jsx4.children = jsxElement;
23785
23788
  } else if (Array.isArray(jsx4.children)) {
@@ -23787,13 +23790,19 @@ function addScriptNodeForInvisibleComponents(jsx4) {
23787
23790
  } else {
23788
23791
  jsx4.children = [jsx4.children, jsxElement];
23789
23792
  }
23790
- return jsxElement;
23793
+ return [jsxElement, jsx4];
23791
23794
  } else if (Array.isArray(jsx4) && jsx4.length) {
23792
- return addScriptNodeForInvisibleComponents(jsx4[0]);
23795
+ const [jsxElement, _] = addScriptNodeForInvisibleComponents(jsx4[0]);
23796
+ return [jsxElement, jsx4];
23793
23797
  }
23794
- return null;
23798
+ return [null, null];
23795
23799
  }
23796
23800
 
23801
+ // packages/qwik/src/core/shared/utils/constants.ts
23802
+ var _CONST_PROPS = Symbol("CONST");
23803
+ var _VAR_PROPS = Symbol("VAR");
23804
+ var _IMMUTABLE = Symbol("IMMUTABLE");
23805
+
23797
23806
  // packages/qwik/src/core/shared/utils/prop.ts
23798
23807
  function isSlotProp(prop) {
23799
23808
  return !prop.startsWith("q:") && !prop.startsWith(NON_SERIALIZABLE_MARKER_PREFIX);
@@ -23832,19 +23841,6 @@ function escapeHTML(html) {
23832
23841
  }
23833
23842
  }
23834
23843
 
23835
- // packages/qwik/src/core/shared/utils/jsx-filename.ts
23836
- function getFileLocationFromJsx(jsxDev) {
23837
- var _a;
23838
- if (!jsxDev) {
23839
- return null;
23840
- }
23841
- const sanitizedFileName = (_a = jsxDev.fileName) == null ? void 0 : _a.replace(/\\/g, "/");
23842
- if (sanitizedFileName) {
23843
- return `${sanitizedFileName}:${jsxDev.lineNumber}:${jsxDev.columnNumber}`;
23844
- }
23845
- return null;
23846
- }
23847
-
23848
23844
  // packages/qwik/src/core/client/vnode-diff.ts
23849
23845
  var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
23850
23846
  let journal = container.$journal$;
@@ -23881,7 +23877,7 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
23881
23877
  descend(jsxValue, false);
23882
23878
  } else if (isSignal(jsxValue)) {
23883
23879
  if (vCurrent) {
23884
- clearVNodeEffectDependencies(container, vCurrent);
23880
+ clearAllEffects(container, vCurrent);
23885
23881
  }
23886
23882
  expectVirtual("S" /* WrappedSignal */, null);
23887
23883
  descend(
@@ -24038,8 +24034,9 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
24038
24034
  };
24039
24035
  const projections = [];
24040
24036
  if (host) {
24041
- for (let i = vnode_getPropStartIndex(host); i < host.length; i = i + 2) {
24042
- const prop = host[i];
24037
+ const props = vnode_getProps(host);
24038
+ for (let i = 0; i < props.length; i = i + 2) {
24039
+ const prop = props[i];
24043
24040
  if (isSlotProp(prop)) {
24044
24041
  const slotName = prop;
24045
24042
  projections.push(slotName);
@@ -24083,8 +24080,8 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
24083
24080
  );
24084
24081
  if (vCurrent == null) {
24085
24082
  vNewNode = vnode_newVirtual();
24086
- import_build4.isDev && vnode_setProp(vNewNode, DEBUG_TYPE, "P" /* Projection */);
24087
- import_build4.isDev && vnode_setProp(vNewNode, "q:code", "expectProjection");
24083
+ import_build7.isDev && vnode_setProp(vNewNode, DEBUG_TYPE, "P" /* Projection */);
24084
+ import_build7.isDev && vnode_setProp(vNewNode, "q:code", "expectProjection");
24088
24085
  vnode_setProp(vNewNode, QSlot, slotName);
24089
24086
  vnode_setProp(vNewNode, QSlotParent, vParent);
24090
24087
  vnode_setProp(vParent, slotName, vNewNode);
@@ -24110,8 +24107,8 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
24110
24107
  );
24111
24108
  vnode_setProp(vNewNode, QSlot, slotNameKey);
24112
24109
  vHost && vnode_setProp(vHost, slotNameKey, vNewNode);
24113
- import_build4.isDev && vnode_setProp(vNewNode, DEBUG_TYPE, "P" /* Projection */);
24114
- import_build4.isDev && vnode_setProp(vNewNode, "q:code", "expectSlot" + count++);
24110
+ import_build7.isDev && vnode_setProp(vNewNode, DEBUG_TYPE, "P" /* Projection */);
24111
+ import_build7.isDev && vnode_setProp(vNewNode, "q:code", "expectSlot" + count++);
24115
24112
  return false;
24116
24113
  } else if (vProjectedNode === vCurrent) {
24117
24114
  } else {
@@ -24123,8 +24120,8 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
24123
24120
  );
24124
24121
  vnode_setProp(vNewNode, QSlot, slotNameKey);
24125
24122
  vHost && vnode_setProp(vHost, slotNameKey, vNewNode);
24126
- import_build4.isDev && vnode_setProp(vNewNode, DEBUG_TYPE, "P" /* Projection */);
24127
- import_build4.isDev && vnode_setProp(vNewNode, "q:code", "expectSlot" + count++);
24123
+ import_build7.isDev && vnode_setProp(vNewNode, DEBUG_TYPE, "P" /* Projection */);
24124
+ import_build7.isDev && vnode_setProp(vNewNode, "q:code", "expectSlot" + count++);
24128
24125
  }
24129
24126
  return true;
24130
24127
  }
@@ -24195,14 +24192,20 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
24195
24192
  if (isJsxPropertyAnEventName(key2)) {
24196
24193
  const eventName = getEventNameFromJsxProp(key2);
24197
24194
  const scope = getEventNameScopeFromJsxProp(key2);
24198
- vnode_setProp(
24199
- vNewNode,
24200
- HANDLER_PREFIX + ":" + scope + ":" + eventName,
24201
- value
24202
- );
24203
24195
  if (eventName) {
24196
+ vnode_setProp(
24197
+ vNewNode,
24198
+ HANDLER_PREFIX + ":" + scope + ":" + eventName,
24199
+ value
24200
+ );
24204
24201
  registerQwikLoaderEvent(eventName);
24205
24202
  }
24203
+ if (scope) {
24204
+ const htmlEvent = convertEventNameFromJsxPropToHtmlAttr(key2);
24205
+ if (htmlEvent) {
24206
+ vnode_setAttr(journal, vNewNode, htmlEvent, "");
24207
+ }
24208
+ }
24206
24209
  needsQDispatchEventPatch = true;
24207
24210
  continue;
24208
24211
  }
@@ -24213,12 +24216,14 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
24213
24216
  } else if (typeof value === "function") {
24214
24217
  value(element);
24215
24218
  continue;
24219
+ } else if (value == null) {
24220
+ continue;
24216
24221
  } else {
24217
24222
  throw qError(32 /* invalidRefValue */, [currentFile]);
24218
24223
  }
24219
24224
  }
24220
24225
  if (isSignal(value)) {
24221
- const signalData = new EffectPropData({
24226
+ const signalData = new SubscriptionData({
24222
24227
  $scopedStyleIdPrefix$: scopedStyleIdPrefix,
24223
24228
  $isConst$: true
24224
24229
  });
@@ -24237,7 +24242,7 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
24237
24242
  }
24238
24243
  if (elementName === "textarea" && key2 === "value") {
24239
24244
  if (value && typeof value !== "string") {
24240
- if (import_build4.isDev) {
24245
+ if (import_build7.isDev) {
24241
24246
  throw qError(40 /* wrongTextareaValue */, [currentFile, value]);
24242
24247
  }
24243
24248
  continue;
@@ -24318,7 +24323,12 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
24318
24323
  let returnValue = false;
24319
24324
  qrls.flat(2).forEach((qrl2) => {
24320
24325
  if (qrl2) {
24321
- const value = qrl2(event, element);
24326
+ const value = container.$scheduler$(
24327
+ 2 /* RUN_QRL */,
24328
+ vNode,
24329
+ qrl2,
24330
+ [event, element]
24331
+ );
24322
24332
  returnValue = returnValue || value === true;
24323
24333
  }
24324
24334
  });
@@ -24329,10 +24339,10 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
24329
24339
  }
24330
24340
  function setBulkProps(vnode, srcAttrs, currentFile) {
24331
24341
  vnode_ensureElementInflated(vnode);
24332
- const dstAttrs = vnode;
24342
+ const dstAttrs = vnode_getProps(vnode);
24333
24343
  let srcIdx = 0;
24334
24344
  const srcLength = srcAttrs.length;
24335
- let dstIdx = 8 /* PROPS_OFFSET */;
24345
+ let dstIdx = 0;
24336
24346
  let dstLength = dstAttrs.length;
24337
24347
  let srcKey = srcIdx < srcLength ? srcAttrs[srcIdx++] : null;
24338
24348
  let dstKey = dstIdx < dstLength ? dstAttrs[dstIdx++] : null;
@@ -24350,12 +24360,14 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
24350
24360
  } else if (typeof value === "function") {
24351
24361
  value(element);
24352
24362
  return;
24363
+ } else if (value == null) {
24364
+ return;
24353
24365
  } else {
24354
24366
  throw qError(32 /* invalidRefValue */, [currentFile]);
24355
24367
  }
24356
24368
  }
24357
24369
  if (isSignal(value)) {
24358
- const signalData = new EffectPropData({
24370
+ const signalData = new SubscriptionData({
24359
24371
  $scopedStyleIdPrefix$: scopedStyleIdPrefix,
24360
24372
  $isConst$: false
24361
24373
  });
@@ -24368,17 +24380,17 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
24368
24380
  };
24369
24381
  const recordJsxEvent = (key, value) => {
24370
24382
  const eventName = getEventNameFromJsxProp(key);
24383
+ const scope = getEventNameScopeFromJsxProp(key);
24371
24384
  if (eventName) {
24372
- const scope = getEventNameScopeFromJsxProp(key);
24373
24385
  record(":" + scope + ":" + eventName, value);
24374
- }
24375
- const htmlEvent = convertEventNameFromJsxPropToHtmlAttr(key);
24376
- if (htmlEvent) {
24377
- record(htmlEvent, "");
24378
- }
24379
- if (eventName) {
24380
24386
  registerQwikLoaderEvent(eventName);
24381
24387
  }
24388
+ if (scope) {
24389
+ const htmlEvent = convertEventNameFromJsxPropToHtmlAttr(key);
24390
+ if (htmlEvent) {
24391
+ record(htmlEvent, "");
24392
+ }
24393
+ }
24382
24394
  };
24383
24395
  while (srcKey !== null || dstKey !== null) {
24384
24396
  if ((dstKey == null ? void 0 : dstKey.startsWith(HANDLER_PREFIX)) || (dstKey == null ? void 0 : dstKey.startsWith(Q_PREFIX))) {
@@ -24494,7 +24506,7 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
24494
24506
  vCurrent && getInsertBefore()
24495
24507
  );
24496
24508
  vnode_setProp(vNewNode, ELEMENT_KEY, jsxKey);
24497
- import_build4.isDev && vnode_setProp(vNewNode || vCurrent, DEBUG_TYPE, type);
24509
+ import_build7.isDev && vnode_setProp(vNewNode || vCurrent, DEBUG_TYPE, type);
24498
24510
  }
24499
24511
  function expectComponent(component) {
24500
24512
  const componentMeta = component[SERIALIZABLE_STATE];
@@ -24522,9 +24534,6 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
24522
24534
  } else if (!hashesAreEqual) {
24523
24535
  insertNewComponent(host, componentQRL, jsxProps);
24524
24536
  if (vNewNode) {
24525
- if (host) {
24526
- vNewNode[0 /* flags */] = host[0 /* flags */];
24527
- }
24528
24537
  host = vNewNode;
24529
24538
  shouldRender = true;
24530
24539
  }
@@ -24534,7 +24543,7 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
24534
24543
  shouldRender = shouldRender || propsDiffer(jsxProps, vNodeProps);
24535
24544
  if (shouldRender) {
24536
24545
  host[0 /* flags */] &= ~32 /* Deleted */;
24537
- container.$scheduler$(7 /* COMPONENT */, host, componentQRL, jsxProps);
24546
+ container.$scheduler$(6 /* COMPONENT */, host, componentQRL, jsxProps);
24538
24547
  }
24539
24548
  }
24540
24549
  descendContentToProject(jsxNode2.children, host);
@@ -24569,7 +24578,7 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
24569
24578
  }
24570
24579
  function insertNewComponent(host, componentQRL, jsxProps) {
24571
24580
  if (host) {
24572
- clearVNodeEffectDependencies(container, host);
24581
+ clearAllEffects(container, host);
24573
24582
  }
24574
24583
  vnode_insertBefore(
24575
24584
  journal,
@@ -24578,7 +24587,7 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
24578
24587
  vCurrent && getInsertBefore()
24579
24588
  );
24580
24589
  const jsxNode2 = jsxValue;
24581
- import_build4.isDev && vnode_setProp(vNewNode, DEBUG_TYPE, "C" /* Component */);
24590
+ import_build7.isDev && vnode_setProp(vNewNode, DEBUG_TYPE, "C" /* Component */);
24582
24591
  container.setHostProp(vNewNode, OnRenderProp, componentQRL);
24583
24592
  container.setHostProp(vNewNode, ELEMENT_PROPS, jsxProps);
24584
24593
  container.setHostProp(vNewNode, ELEMENT_KEY, jsxNode2.key);
@@ -24591,7 +24600,7 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
24591
24600
  vCurrent && getInsertBefore()
24592
24601
  );
24593
24602
  const jsxNode2 = jsxValue;
24594
- import_build4.isDev && vnode_setProp(vNewNode, DEBUG_TYPE, "I" /* InlineComponent */);
24603
+ import_build7.isDev && vnode_setProp(vNewNode, DEBUG_TYPE, "I" /* InlineComponent */);
24595
24604
  vnode_setProp(vNewNode, ELEMENT_PROPS, jsxNode2.props);
24596
24605
  if (jsxNode2.key) {
24597
24606
  vnode_setProp(vNewNode, ELEMENT_KEY, jsxNode2.key);
@@ -24635,8 +24644,8 @@ function propsDiffer(src, dst) {
24635
24644
  if (!src || !dst) {
24636
24645
  return true;
24637
24646
  }
24638
- let srcKeys = removePropsKeys(Object.keys(src), ["children", QSubscribers]);
24639
- let dstKeys = removePropsKeys(Object.keys(dst), ["children", QSubscribers]);
24647
+ let srcKeys = removePropsKeys(Object.keys(src), ["children", QBackRefs]);
24648
+ let dstKeys = removePropsKeys(Object.keys(dst), ["children", QBackRefs]);
24640
24649
  if (srcKeys.length !== dstKeys.length) {
24641
24650
  return true;
24642
24651
  }
@@ -24670,7 +24679,7 @@ function cleanup(container, vNode) {
24670
24679
  do {
24671
24680
  const type = vCursor[0 /* flags */];
24672
24681
  if (type & 3 /* ELEMENT_OR_VIRTUAL_MASK */) {
24673
- clearVNodeEffectDependencies(container, vCursor);
24682
+ clearAllEffects(container, vCursor);
24674
24683
  markVNodeAsDeleted(vCursor);
24675
24684
  if (type & 2 /* Virtual */) {
24676
24685
  const seq = container.getHostProp(vCursor, ELEMENT_SEQ);
@@ -24679,7 +24688,7 @@ function cleanup(container, vNode) {
24679
24688
  const obj = seq[i];
24680
24689
  if (isTask(obj)) {
24681
24690
  const task = obj;
24682
- clearSubscriberEffectDependencies(container, task);
24691
+ clearAllEffects(container, task);
24683
24692
  if (task.$flags$ & 1 /* VISIBLE_TASK */) {
24684
24693
  container.$scheduler$(48 /* CLEANUP_VISIBLE */, task);
24685
24694
  } else {
@@ -24691,8 +24700,8 @@ function cleanup(container, vNode) {
24691
24700
  }
24692
24701
  const isComponent = type & 2 /* Virtual */ && vnode_getProp(vCursor, OnRenderProp, null) !== null;
24693
24702
  if (isComponent) {
24694
- const attrs = vCursor;
24695
- for (let i = 6 /* PROPS_OFFSET */; i < attrs.length; i = i + 2) {
24703
+ const attrs = vnode_getProps(vCursor);
24704
+ for (let i = 0; i < attrs.length; i = i + 2) {
24696
24705
  const key = attrs[i];
24697
24706
  if (!isParentSlotProp(key) && isSlotProp(key)) {
24698
24707
  const value = attrs[i + 1];
@@ -24764,57 +24773,197 @@ function markVNodeAsDeleted(vCursor) {
24764
24773
  var HANDLER_PREFIX = ":";
24765
24774
  var count = 0;
24766
24775
 
24767
- // packages/qwik/src/core/shared/qrl/implicit_dollar.ts
24768
- var implicit$FirstArg = (fn) => {
24769
- return function(first, ...rest) {
24770
- return fn.call(null, dollar(first), ...rest);
24776
+ // packages/qwik/src/core/use/use-resource.ts
24777
+ var _createResourceReturn = (opts) => {
24778
+ const resource = {
24779
+ __brand: "resource",
24780
+ value: void 0,
24781
+ loading: isServerPlatform() ? false : true,
24782
+ _resolved: void 0,
24783
+ _error: void 0,
24784
+ _state: "pending",
24785
+ _timeout: (opts == null ? void 0 : opts.timeout) ?? -1,
24786
+ _cache: 0
24771
24787
  };
24788
+ return resource;
24772
24789
  };
24773
-
24774
- // packages/qwik/src/core/shared/scheduler-document-position.ts
24775
- var aVNodePath = [];
24776
- var bVNodePath = [];
24777
- var vnode_documentPosition = (a, b, rootVNode) => {
24778
- if (a === b) {
24779
- return 0;
24780
- }
24781
- let aDepth = -1;
24782
- let bDepth = -1;
24783
- while (a) {
24784
- const vNode = aVNodePath[++aDepth] = a;
24785
- a = vNode[1 /* parent */] || rootVNode && vnode_getProp(a, QSlotParent, (id) => vnode_locate(rootVNode, id));
24786
- }
24787
- while (b) {
24788
- const vNode = bVNodePath[++bDepth] = b;
24789
- b = vNode[1 /* parent */] || rootVNode && vnode_getProp(b, QSlotParent, (id) => vnode_locate(rootVNode, id));
24790
- }
24791
- while (aDepth >= 0 && bDepth >= 0) {
24792
- a = aVNodePath[aDepth];
24793
- b = bVNodePath[bDepth];
24794
- if (a === b) {
24795
- aDepth--;
24796
- bDepth--;
24797
- } else {
24798
- let cursor = b;
24799
- do {
24800
- cursor = vnode_getNextSibling(cursor);
24801
- if (cursor === a) {
24802
- return 1;
24803
- }
24804
- } while (cursor);
24805
- cursor = b;
24806
- do {
24807
- cursor = vnode_getPreviousSibling(cursor);
24808
- if (cursor === a) {
24809
- return -1;
24810
- }
24811
- } while (cursor);
24812
- if (rootVNode && vnode_getProp(b, QSlotParent, (id) => vnode_locate(rootVNode, id))) {
24813
- return -1;
24814
- }
24815
- return 1;
24816
- }
24817
- }
24790
+ var createResourceReturn = (container, opts, initialPromise) => {
24791
+ const result = _createResourceReturn(opts);
24792
+ result.value = initialPromise;
24793
+ return createStore(container, result, 1 /* RECURSIVE */);
24794
+ };
24795
+ var runResource = (task, container, host) => {
24796
+ task.$flags$ &= ~8 /* DIRTY */;
24797
+ cleanupTask(task);
24798
+ const iCtx = newInvokeContext(container.$locale$, host, void 0, ResourceEvent);
24799
+ iCtx.$container$ = container;
24800
+ const taskFn = task.$qrl$.getFn(iCtx, () => clearAllEffects(container, task));
24801
+ const resource = task.$state$;
24802
+ assertDefined(
24803
+ resource,
24804
+ 'useResource: when running a resource, "task.resource" must be a defined.',
24805
+ task
24806
+ );
24807
+ const track = (obj, prop) => {
24808
+ const ctx = newInvokeContext();
24809
+ ctx.$effectSubscriber$ = getSubscriber(task, ":" /* COMPONENT */);
24810
+ ctx.$container$ = container;
24811
+ return invoke(ctx, () => {
24812
+ if (isFunction(obj)) {
24813
+ return obj();
24814
+ }
24815
+ if (prop) {
24816
+ return obj[prop];
24817
+ } else if (isSignal(obj)) {
24818
+ return obj.value;
24819
+ } else {
24820
+ return obj;
24821
+ }
24822
+ });
24823
+ };
24824
+ const handleError = (reason) => container.handleError(reason, host);
24825
+ const cleanups = [];
24826
+ task.$destroy$ = noSerialize(() => {
24827
+ cleanups.forEach((fn) => {
24828
+ try {
24829
+ fn();
24830
+ } catch (err) {
24831
+ handleError(err);
24832
+ }
24833
+ });
24834
+ done = true;
24835
+ });
24836
+ const resourceTarget = unwrapStore(resource);
24837
+ const opts = {
24838
+ track,
24839
+ cleanup(fn) {
24840
+ if (typeof fn === "function") {
24841
+ cleanups.push(fn);
24842
+ }
24843
+ },
24844
+ cache(policy) {
24845
+ let milliseconds = 0;
24846
+ if (policy === "immutable") {
24847
+ milliseconds = Infinity;
24848
+ } else {
24849
+ milliseconds = policy;
24850
+ }
24851
+ resource._cache = milliseconds;
24852
+ },
24853
+ previous: resourceTarget._resolved
24854
+ };
24855
+ let resolve;
24856
+ let reject;
24857
+ let done = false;
24858
+ const setState = (resolved, value) => {
24859
+ if (!done) {
24860
+ done = true;
24861
+ if (resolved) {
24862
+ done = true;
24863
+ resource.loading = false;
24864
+ resource._state = "resolved";
24865
+ resource._resolved = value;
24866
+ resource._error = void 0;
24867
+ resolve(value);
24868
+ } else {
24869
+ done = true;
24870
+ resource.loading = false;
24871
+ resource._state = "rejected";
24872
+ resource._error = value;
24873
+ reject(value);
24874
+ }
24875
+ return true;
24876
+ }
24877
+ return false;
24878
+ };
24879
+ cleanups.push(() => {
24880
+ if (untrack(() => resource.loading) === true) {
24881
+ const value = untrack(() => resource._resolved);
24882
+ setState(true, value);
24883
+ }
24884
+ });
24885
+ invoke(iCtx, () => {
24886
+ resource._state = "pending";
24887
+ resource.loading = !isServerPlatform();
24888
+ const promise2 = resource.value = new Promise((r, re) => {
24889
+ resolve = r;
24890
+ reject = re;
24891
+ });
24892
+ promise2.catch(ignoreErrorToPreventNodeFromCrashing);
24893
+ });
24894
+ const promise = safeCall(
24895
+ () => Promise.resolve(taskFn(opts)),
24896
+ (value) => {
24897
+ setState(true, value);
24898
+ },
24899
+ (err) => {
24900
+ if (isPromise(err)) {
24901
+ return err.then(() => runResource(task, container, host));
24902
+ } else {
24903
+ setState(false, err);
24904
+ }
24905
+ }
24906
+ );
24907
+ const timeout = resourceTarget._timeout;
24908
+ if (timeout > 0) {
24909
+ return Promise.race([
24910
+ promise,
24911
+ delay(timeout).then(() => {
24912
+ if (setState(false, new Error("timeout"))) {
24913
+ cleanupTask(task);
24914
+ }
24915
+ })
24916
+ ]);
24917
+ }
24918
+ return promise;
24919
+ };
24920
+ var ignoreErrorToPreventNodeFromCrashing = (err) => {
24921
+ };
24922
+
24923
+ // packages/qwik/src/core/shared/scheduler-document-position.ts
24924
+ var aVNodePath = [];
24925
+ var bVNodePath = [];
24926
+ var vnode_documentPosition = (a, b, rootVNode) => {
24927
+ if (a === b) {
24928
+ return 0;
24929
+ }
24930
+ let aDepth = -1;
24931
+ let bDepth = -1;
24932
+ while (a) {
24933
+ const vNode = aVNodePath[++aDepth] = a;
24934
+ a = vNode[1 /* parent */] || rootVNode && vnode_getProp(a, QSlotParent, (id) => vnode_locate(rootVNode, id));
24935
+ }
24936
+ while (b) {
24937
+ const vNode = bVNodePath[++bDepth] = b;
24938
+ b = vNode[1 /* parent */] || rootVNode && vnode_getProp(b, QSlotParent, (id) => vnode_locate(rootVNode, id));
24939
+ }
24940
+ while (aDepth >= 0 && bDepth >= 0) {
24941
+ a = aVNodePath[aDepth];
24942
+ b = bVNodePath[bDepth];
24943
+ if (a === b) {
24944
+ aDepth--;
24945
+ bDepth--;
24946
+ } else {
24947
+ let cursor = b;
24948
+ do {
24949
+ cursor = vnode_getNextSibling(cursor);
24950
+ if (cursor === a) {
24951
+ return 1;
24952
+ }
24953
+ } while (cursor);
24954
+ cursor = b;
24955
+ do {
24956
+ cursor = vnode_getPreviousSibling(cursor);
24957
+ if (cursor === a) {
24958
+ return -1;
24959
+ }
24960
+ } while (cursor);
24961
+ if (rootVNode && vnode_getProp(b, QSlotParent, (id) => vnode_locate(rootVNode, id))) {
24962
+ return -1;
24963
+ }
24964
+ return 1;
24965
+ }
24966
+ }
24818
24967
  return aDepth < bDepth ? -1 : 1;
24819
24968
  };
24820
24969
  var aSsrNodePath = [];
@@ -24848,14 +24997,31 @@ var ssrNodeDocumentPosition = (a, b) => {
24848
24997
 
24849
24998
  // packages/qwik/src/core/shared/scheduler.ts
24850
24999
  var DEBUG2 = false;
25000
+ var getPromise = (chore) => chore.$promise$ ||= new Promise((resolve) => {
25001
+ chore.$resolve$ = resolve;
25002
+ });
24851
25003
  var createScheduler = (container, scheduleDrain, journalFlush) => {
24852
25004
  const choreQueue = [];
25005
+ const qrlRuns = [];
24853
25006
  let currentChore = null;
24854
- let journalFlushScheduled = false;
25007
+ let drainScheduled = false;
24855
25008
  return schedule;
24856
25009
  function schedule(type, hostOrTask = null, targetOrQrl = null, payload = null) {
24857
- const runLater = type !== 255 /* WAIT_FOR_ALL */ && type !== 6 /* COMPONENT_SSR */;
24858
- const isTask2 = type === 3 /* TASK */ || type === 32 /* VISIBLE */ || type === 2 /* RESOURCE */ || type === 48 /* CLEANUP_VISIBLE */;
25010
+ var _a, _b;
25011
+ const isServer4 = !isDomContainer(container);
25012
+ const isComponentSsr = isServer4 && type === 6 /* COMPONENT */;
25013
+ const runLater = type !== 255 /* WAIT_FOR_ALL */ && !isComponentSsr && type !== 2 /* RUN_QRL */;
25014
+ const isTask2 = type === 3 /* TASK */ || type === 32 /* VISIBLE */ || type === 48 /* CLEANUP_VISIBLE */;
25015
+ const isClientOnly = type === 16 /* JOURNAL_FLUSH */ || type === 4 /* NODE_DIFF */ || type === 5 /* NODE_PROP */;
25016
+ if (isServer4 && isClientOnly) {
25017
+ DEBUG2 && debugTrace(
25018
+ `skip client chore ${debugChoreTypeToString(type)}`,
25019
+ null,
25020
+ currentChore,
25021
+ choreQueue
25022
+ );
25023
+ return;
25024
+ }
24859
25025
  if (isTask2) {
24860
25026
  hostOrTask.$flags$ |= 8 /* DIRTY */;
24861
25027
  }
@@ -24870,181 +25036,228 @@ var createScheduler = (container, scheduleDrain, journalFlush) => {
24870
25036
  $returnValue$: null,
24871
25037
  $executed$: false
24872
25038
  };
24873
- chore.$promise$ = new Promise((resolve) => chore.$resolve$ = resolve);
24874
- DEBUG2 && debugTrace("schedule", chore, currentChore, choreQueue);
24875
25039
  chore = sortedInsert(choreQueue, chore, container.rootVNode || null);
24876
- if (!journalFlushScheduled && runLater) {
24877
- journalFlushScheduled = true;
25040
+ DEBUG2 && debugTrace("schedule", chore, currentChore, choreQueue);
25041
+ if (!drainScheduled && runLater) {
25042
+ drainScheduled = true;
24878
25043
  schedule(16 /* JOURNAL_FLUSH */);
24879
- scheduleDrain();
25044
+ (_b = (_a = scheduleDrain()) == null ? void 0 : _a.catch) == null ? void 0 : _b.call(_a, () => {
25045
+ });
24880
25046
  }
24881
25047
  if (runLater) {
24882
- return chore.$promise$;
25048
+ return getPromise(chore);
24883
25049
  } else {
24884
- return drainUpTo(chore, container.rootVNode || null);
25050
+ return drainUpTo(chore, isServer4);
24885
25051
  }
24886
25052
  }
24887
- function drainUpTo(runUptoChore, rootVNode) {
24888
- if (runUptoChore.$executed$) {
24889
- return runUptoChore.$returnValue$;
24890
- }
24891
- if (currentChore) {
24892
- return runUptoChore.$promise$;
24893
- }
25053
+ function drainUpTo(runUptoChore, isServer4) {
25054
+ let maxRetries = 5e3;
24894
25055
  while (choreQueue.length) {
24895
- const nextChore = choreQueue.shift();
24896
- const order = choreComparator(nextChore, runUptoChore, rootVNode);
24897
- if (order === null) {
24898
- continue;
25056
+ if (maxRetries-- < 0) {
25057
+ throw new Error("drainUpTo: max retries reached");
24899
25058
  }
24900
- if (order > 0) {
24901
- break;
25059
+ if (currentChore) {
25060
+ return getPromise(currentChore).then(() => drainUpTo(runUptoChore, isServer4)).catch((e) => {
25061
+ container.handleError(e, currentChore == null ? void 0 : currentChore.$host$);
25062
+ });
24902
25063
  }
24903
- const isDeletedVNode = vNodeAlreadyDeleted(nextChore);
24904
- if (isDeletedVNode && // we need to process cleanup tasks for deleted nodes
25064
+ const nextChore = choreQueue[0];
25065
+ if (nextChore.$executed$) {
25066
+ choreQueue.shift();
25067
+ if (nextChore === runUptoChore) {
25068
+ break;
25069
+ }
25070
+ continue;
25071
+ }
25072
+ if (vNodeAlreadyDeleted(nextChore) && // we need to process cleanup tasks for deleted nodes
24905
25073
  nextChore.$type$ !== 48 /* CLEANUP_VISIBLE */) {
24906
25074
  DEBUG2 && debugTrace("skip chore", nextChore, currentChore, choreQueue);
25075
+ choreQueue.shift();
24907
25076
  continue;
24908
25077
  }
24909
- const returnValue = executeChore(nextChore);
24910
- if (isPromise(returnValue)) {
24911
- const promise = returnValue.then(() => drainUpTo(runUptoChore, rootVNode));
24912
- return promise;
24913
- }
25078
+ executeChore(nextChore, isServer4);
24914
25079
  }
24915
25080
  return runUptoChore.$returnValue$;
24916
25081
  }
24917
- function executeChore(chore) {
24918
- var _a;
25082
+ function executeChore(chore, isServer4) {
25083
+ var _a, _b, _c;
24919
25084
  const host = chore.$host$;
24920
25085
  DEBUG2 && debugTrace("execute", chore, currentChore, choreQueue);
24921
25086
  assertEqual(currentChore, null, "Chore already running.");
24922
25087
  currentChore = chore;
24923
25088
  let returnValue = null;
24924
- switch (chore.$type$) {
24925
- case 16 /* JOURNAL_FLUSH */:
24926
- returnValue = journalFlush();
24927
- journalFlushScheduled = false;
24928
- break;
24929
- case 7 /* COMPONENT */:
24930
- case 6 /* COMPONENT_SSR */:
24931
- returnValue = safeCall(
24932
- () => executeComponent(
24933
- container,
24934
- host,
24935
- host,
24936
- chore.$target$,
24937
- chore.$payload$
24938
- ),
24939
- (jsx5) => {
24940
- if (chore.$type$ === 7 /* COMPONENT */) {
24941
- const styleScopedId = container.getHostProp(host, QScopedStyle);
24942
- return retryOnPromise(
24943
- () => vnode_diff(
24944
- container,
24945
- jsx5,
24946
- host,
24947
- addComponentStylePrefix(styleScopedId)
24948
- )
24949
- );
25089
+ try {
25090
+ switch (chore.$type$) {
25091
+ case 255 /* WAIT_FOR_ALL */:
25092
+ {
25093
+ if (isServer4) {
25094
+ drainScheduled = false;
25095
+ }
25096
+ }
25097
+ break;
25098
+ case 16 /* JOURNAL_FLUSH */:
25099
+ {
25100
+ returnValue = journalFlush();
25101
+ drainScheduled = false;
25102
+ }
25103
+ break;
25104
+ case 6 /* COMPONENT */:
25105
+ {
25106
+ returnValue = safeCall(
25107
+ () => executeComponent(
25108
+ container,
25109
+ host,
25110
+ host,
25111
+ chore.$target$,
25112
+ chore.$payload$
25113
+ ),
25114
+ (jsx4) => {
25115
+ if (isServer4) {
25116
+ return jsx4;
25117
+ } else {
25118
+ const styleScopedId = container.getHostProp(host, QScopedStyle);
25119
+ return retryOnPromise(
25120
+ () => vnode_diff(
25121
+ container,
25122
+ jsx4,
25123
+ host,
25124
+ addComponentStylePrefix(styleScopedId)
25125
+ )
25126
+ );
25127
+ }
25128
+ },
25129
+ (err) => container.handleError(err, host)
25130
+ );
25131
+ }
25132
+ break;
25133
+ case 2 /* RUN_QRL */:
25134
+ {
25135
+ const fn = chore.$target$.getFn();
25136
+ const result = retryOnPromise(() => fn(...chore.$payload$));
25137
+ if (isPromise(result)) {
25138
+ const handled = result.finally(() => {
25139
+ qrlRuns.splice(qrlRuns.indexOf(handled), 1);
25140
+ }).catch((error) => {
25141
+ container.handleError(error, chore.$host$);
25142
+ });
25143
+ qrlRuns.push(handled);
25144
+ DEBUG2 && debugTrace("execute.DONE (but still running)", chore, currentChore, choreQueue);
25145
+ chore.$returnValue$ = handled;
25146
+ (_a = chore.$resolve$) == null ? void 0 : _a.call(chore, handled);
25147
+ currentChore = null;
25148
+ chore.$executed$ = true;
25149
+ return;
25150
+ }
25151
+ returnValue = null;
25152
+ }
25153
+ break;
25154
+ case 3 /* TASK */:
25155
+ case 32 /* VISIBLE */:
25156
+ {
25157
+ const payload = chore.$payload$;
25158
+ if (payload.$flags$ & 4 /* RESOURCE */) {
25159
+ const result = runResource(payload, container, host);
25160
+ returnValue = isServer4 ? result : null;
24950
25161
  } else {
24951
- return jsx5;
25162
+ returnValue = runTask(payload, container, host);
24952
25163
  }
24953
- },
24954
- (err) => container.handleError(err, host)
24955
- );
24956
- break;
24957
- case 2 /* RESOURCE */:
24958
- const result = runResource(chore.$payload$, container, host);
24959
- returnValue = isDomContainer(container) ? null : result;
24960
- break;
24961
- case 3 /* TASK */:
24962
- returnValue = runTask(chore.$payload$, container, host);
24963
- break;
24964
- case 32 /* VISIBLE */:
24965
- returnValue = runTask(chore.$payload$, container, host);
24966
- break;
24967
- case 48 /* CLEANUP_VISIBLE */:
24968
- const task = chore.$payload$;
24969
- cleanupTask(task);
24970
- break;
24971
- case 4 /* NODE_DIFF */:
24972
- const parentVirtualNode = chore.$target$;
24973
- let jsx4 = chore.$payload$;
24974
- if (isSignal(jsx4)) {
24975
- jsx4 = jsx4.value;
24976
- }
24977
- returnValue = retryOnPromise(
24978
- () => vnode_diff(container, jsx4, parentVirtualNode, null)
24979
- );
24980
- break;
24981
- case 5 /* NODE_PROP */:
24982
- const virtualNode = chore.$host$;
24983
- const payload = chore.$payload$;
24984
- let value = payload.$value$;
24985
- if (isSignal(value)) {
24986
- value = value.value;
24987
- }
24988
- const isConst = payload.$isConst$;
24989
- const journal = container.$journal$;
24990
- const property = chore.$idx$;
24991
- const serializedValue = serializeAttribute(property, value, payload.$scopedStyleIdPrefix$);
24992
- if (isConst) {
24993
- const element = virtualNode[6 /* element */];
24994
- journal.push(2 /* SetAttribute */, element, property, serializedValue);
24995
- } else {
24996
- vnode_setAttr(journal, virtualNode, property, serializedValue);
24997
- }
24998
- break;
24999
- case 1 /* QRL_RESOLVE */: {
25000
- const target = chore.$target$;
25001
- returnValue = !target.resolved ? target.resolve() : null;
25002
- break;
25003
- }
25004
- case 8 /* RECOMPUTE_AND_SCHEDULE_EFFECTS */: {
25005
- const target = chore.$target$;
25006
- const forceRunEffects = target.$forceRunEffects$;
25007
- target.$forceRunEffects$ = false;
25008
- if (!((_a = target.$effects$) == null ? void 0 : _a.length)) {
25164
+ }
25165
+ break;
25166
+ case 48 /* CLEANUP_VISIBLE */:
25167
+ {
25168
+ const task = chore.$payload$;
25169
+ cleanupTask(task);
25170
+ }
25171
+ break;
25172
+ case 4 /* NODE_DIFF */:
25173
+ {
25174
+ const parentVirtualNode = chore.$target$;
25175
+ let jsx4 = chore.$payload$;
25176
+ if (isSignal(jsx4)) {
25177
+ jsx4 = jsx4.value;
25178
+ }
25179
+ returnValue = retryOnPromise(
25180
+ () => vnode_diff(container, jsx4, parentVirtualNode, null)
25181
+ );
25182
+ }
25183
+ break;
25184
+ case 5 /* NODE_PROP */:
25185
+ {
25186
+ const virtualNode = chore.$host$;
25187
+ const payload = chore.$payload$;
25188
+ let value = payload.$value$;
25189
+ if (isSignal(value)) {
25190
+ value = value.value;
25191
+ }
25192
+ const isConst = payload.$isConst$;
25193
+ const journal = container.$journal$;
25194
+ const property = chore.$idx$;
25195
+ const serializedValue = serializeAttribute(
25196
+ property,
25197
+ value,
25198
+ payload.$scopedStyleIdPrefix$
25199
+ );
25200
+ if (isConst) {
25201
+ const element = virtualNode[6 /* element */];
25202
+ journal.push(2 /* SetAttribute */, element, property, serializedValue);
25203
+ } else {
25204
+ vnode_setAttr(journal, virtualNode, property, serializedValue);
25205
+ }
25206
+ }
25207
+ break;
25208
+ case 1 /* QRL_RESOLVE */: {
25209
+ {
25210
+ const target = chore.$target$;
25211
+ returnValue = !target.resolved ? target.resolve() : null;
25212
+ }
25009
25213
  break;
25010
25214
  }
25011
- returnValue = retryOnPromise(() => {
25012
- if (target.$computeIfNeeded$() || forceRunEffects) {
25013
- triggerEffects(container, target, target.$effects$);
25215
+ case 7 /* RECOMPUTE_AND_SCHEDULE_EFFECTS */: {
25216
+ {
25217
+ const target = chore.$target$;
25218
+ const forceRunEffects = target.$forceRunEffects$;
25219
+ target.$forceRunEffects$ = false;
25220
+ if (!((_b = target.$effects$) == null ? void 0 : _b.size)) {
25221
+ break;
25222
+ }
25223
+ returnValue = retryOnPromise(() => {
25224
+ if (target.$computeIfNeeded$() || forceRunEffects) {
25225
+ triggerEffects(container, target, target.$effects$);
25226
+ }
25227
+ });
25014
25228
  }
25015
- });
25016
- break;
25229
+ break;
25230
+ }
25017
25231
  }
25232
+ } catch (e) {
25233
+ returnValue = Promise.reject(e);
25018
25234
  }
25019
- return maybeThenPassError(returnValue, (value) => {
25235
+ const after = (value, error) => {
25020
25236
  var _a2;
25021
- DEBUG2 && debugTrace("execute.DONE", null, currentChore, choreQueue);
25022
- if (currentChore) {
25023
- currentChore.$executed$ = true;
25024
- (_a2 = currentChore.$resolve$) == null ? void 0 : _a2.call(currentChore, value);
25025
- }
25026
25237
  currentChore = null;
25027
- return chore.$returnValue$ = value;
25028
- });
25029
- }
25030
- };
25031
- var toNumber = (value) => {
25032
- return typeof value === "number" ? value : -1;
25033
- };
25034
- var choreUpdate = (existing, newChore) => {
25035
- if (existing.$type$ === 4 /* NODE_DIFF */) {
25036
- existing.$payload$ = newChore.$payload$;
25037
- }
25038
- };
25039
- function vNodeAlreadyDeleted(chore) {
25040
- return !!(chore.$host$ && vnode_isVNode(chore.$host$) && chore.$host$[0 /* flags */] & 32 /* Deleted */);
25041
- }
25042
- function choreComparator(a, b, rootVNode) {
25043
- const macroTypeDiff = (a.$type$ & 240 /* MACRO */) - (b.$type$ & 240 /* MACRO */);
25044
- if (macroTypeDiff !== 0) {
25045
- return macroTypeDiff;
25238
+ chore.$executed$ = true;
25239
+ if (error) {
25240
+ DEBUG2 && debugTrace("execute.ERROR", chore, currentChore, choreQueue);
25241
+ container.handleError(error, host);
25242
+ } else {
25243
+ chore.$returnValue$ = value;
25244
+ DEBUG2 && debugTrace("execute.DONE", chore, currentChore, choreQueue);
25245
+ (_a2 = chore.$resolve$) == null ? void 0 : _a2.call(chore, value);
25246
+ }
25247
+ };
25248
+ if (isPromise(returnValue)) {
25249
+ chore.$promise$ = returnValue.then(after, (error) => after(void 0, error));
25250
+ (_c = chore.$resolve$) == null ? void 0 : _c.call(chore, chore.$promise$);
25251
+ chore.$resolve$ = void 0;
25252
+ } else {
25253
+ after(returnValue);
25254
+ }
25046
25255
  }
25047
- if (a.$type$ !== 16 /* JOURNAL_FLUSH */) {
25256
+ function choreComparator(a, b, rootVNode) {
25257
+ const macroTypeDiff = (a.$type$ & 240 /* MACRO */) - (b.$type$ & 240 /* MACRO */);
25258
+ if (macroTypeDiff !== 0) {
25259
+ return macroTypeDiff;
25260
+ }
25048
25261
  const aHost = a.$host$;
25049
25262
  const bHost = b.$host$;
25050
25263
  if (aHost !== bHost && aHost !== null && bHost !== null) {
@@ -25054,6 +25267,8 @@ function choreComparator(a, b, rootVNode) {
25054
25267
  return hostDiff;
25055
25268
  }
25056
25269
  } else {
25270
+ assertFalse(vnode_isVNode(aHost), "expected aHost to be SSRNode but it is a VNode");
25271
+ assertFalse(vnode_isVNode(bHost), "expected bHost to be SSRNode but it is a VNode");
25057
25272
  const errorMessage = `SERVER: during HTML streaming, re-running tasks on a different host is not allowed.
25058
25273
  You are attempting to change a state that has already been streamed to the client.
25059
25274
  This can lead to inconsistencies between Server-Side Rendering (SSR) and Client-Side Rendering (CSR).
@@ -25073,166 +25288,90 @@ function choreComparator(a, b, rootVNode) {
25073
25288
  if (idxDiff !== 0) {
25074
25289
  return idxDiff;
25075
25290
  }
25076
- 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 */)) {
25291
+ if (a.$target$ !== b.$target$ || a.$payload$ !== b.$payload$) {
25077
25292
  return 1;
25078
25293
  }
25079
- }
25080
- return 0;
25081
- }
25082
- function sortedFindIndex(sortedArray, value, rootVNode) {
25083
- let bottom = 0;
25084
- let top = sortedArray.length;
25085
- while (bottom < top) {
25086
- const middle = bottom + (top - bottom >> 1);
25087
- const midChore = sortedArray[middle];
25088
- const comp = choreComparator(value, midChore, rootVNode);
25089
- if (comp < 0) {
25090
- top = middle;
25091
- } else if (comp > 0) {
25092
- bottom = middle + 1;
25093
- } else {
25094
- return middle;
25294
+ if (b === currentChore) {
25295
+ return 1;
25095
25296
  }
25297
+ return 0;
25096
25298
  }
25097
- return ~bottom;
25098
- }
25099
- function sortedInsert(sortedArray, value, rootVNode) {
25100
- const idx = sortedFindIndex(sortedArray, value, rootVNode);
25101
- if (idx < 0) {
25102
- sortedArray.splice(~idx, 0, value);
25103
- return value;
25104
- }
25105
- const existing = sortedArray[idx];
25106
- choreUpdate(existing, value);
25107
- return existing;
25108
- }
25109
- function debugChoreToString(chore) {
25110
- var _a;
25111
- const type = {
25112
- [1 /* QRL_RESOLVE */]: "QRL_RESOLVE",
25113
- [2 /* RESOURCE */]: "RESOURCE",
25114
- [3 /* TASK */]: "TASK",
25115
- [4 /* NODE_DIFF */]: "NODE_DIFF",
25116
- [5 /* NODE_PROP */]: "NODE_PROP",
25117
- [7 /* COMPONENT */]: "COMPONENT",
25118
- [6 /* COMPONENT_SSR */]: "COMPONENT_SSR",
25119
- [8 /* RECOMPUTE_AND_SCHEDULE_EFFECTS */]: "RECOMPUTE_SIGNAL",
25120
- [16 /* JOURNAL_FLUSH */]: "JOURNAL_FLUSH",
25121
- [32 /* VISIBLE */]: "VISIBLE",
25122
- [48 /* CLEANUP_VISIBLE */]: "CLEANUP_VISIBLE",
25123
- [255 /* WAIT_FOR_ALL */]: "WAIT_FOR_ALL"
25124
- }[chore.$type$] || "UNKNOWN: " + chore.$type$;
25125
- const host = String(chore.$host$).replaceAll(/\n.*/gim, "");
25126
- const qrlTarget = (_a = chore.$target$) == null ? void 0 : _a.$symbol$;
25127
- return `Chore(${type} ${chore.$type$ === 1 /* QRL_RESOLVE */ ? qrlTarget : host} ${chore.$idx$})`;
25128
- }
25129
- function debugTrace(action, arg, currentChore, queue) {
25130
- const lines = ["Scheduler: " + action];
25131
- if (arg) {
25132
- lines.push(
25133
- " arg: " + ("$type$" in arg ? debugChoreToString(arg) : String(arg).replaceAll(/\n.*/gim, ""))
25134
- );
25135
- }
25136
- if (currentChore) {
25137
- lines.push("running: " + debugChoreToString(currentChore));
25138
- }
25139
- if (queue) {
25140
- queue.forEach((chore, idx) => {
25141
- lines.push((idx == 0 ? " queue: " : " ") + debugChoreToString(chore));
25142
- });
25143
- }
25144
- console.log(lines.join("\n ") + "\n");
25145
- }
25146
-
25147
- // packages/qwik/src/core/use/use-task.ts
25148
- var runTask = (task, container, host) => {
25149
- task.$flags$ &= ~8 /* DIRTY */;
25150
- cleanupTask(task);
25151
- const iCtx = newInvokeContext(container.$locale$, host, void 0, TaskEvent);
25152
- iCtx.$container$ = container;
25153
- const taskFn = task.$qrl$.getFn(
25154
- iCtx,
25155
- () => clearSubscriberEffectDependencies(container, task)
25156
- );
25157
- const track = (obj, prop) => {
25158
- const ctx = newInvokeContext();
25159
- ctx.$effectSubscriber$ = [task, ":" /* COMPONENT */];
25160
- ctx.$container$ = container;
25161
- return invoke(ctx, () => {
25162
- if (isFunction(obj)) {
25163
- return obj();
25164
- }
25165
- if (prop) {
25166
- return obj[prop];
25167
- } else if (isSignal(obj)) {
25168
- return obj.value;
25169
- } else {
25170
- return obj;
25171
- }
25172
- });
25173
- };
25174
- const handleError = (reason) => container.handleError(reason, host);
25175
- let cleanupFns = null;
25176
- const cleanup2 = (fn) => {
25177
- if (typeof fn == "function") {
25178
- if (!cleanupFns) {
25179
- cleanupFns = [];
25180
- task.$destroy$ = noSerialize(() => {
25181
- task.$destroy$ = null;
25182
- cleanupFns.forEach((fn2) => {
25183
- try {
25184
- fn2();
25185
- } catch (err) {
25186
- handleError(err);
25187
- }
25188
- });
25189
- });
25190
- }
25191
- cleanupFns.push(fn);
25192
- }
25193
- };
25194
- const taskApi = { track, cleanup: cleanup2 };
25195
- const result = safeCall(
25196
- () => taskFn(taskApi),
25197
- cleanup2,
25198
- (err) => {
25199
- if (isPromise(err)) {
25200
- return err.then(() => runTask(task, container, host));
25299
+ function sortedFindIndex(sortedArray, value, rootVNode) {
25300
+ let bottom = 0;
25301
+ let top = sortedArray.length;
25302
+ while (bottom < top) {
25303
+ const middle = bottom + (top - bottom >> 1);
25304
+ const midChore = sortedArray[middle];
25305
+ const comp = choreComparator(value, midChore, rootVNode);
25306
+ if (comp < 0) {
25307
+ top = middle;
25308
+ } else if (comp > 0) {
25309
+ bottom = middle + 1;
25201
25310
  } else {
25202
- return handleError(err);
25203
- }
25204
- }
25205
- );
25206
- return result;
25207
- };
25208
- var cleanupTask = (task) => {
25209
- const destroy = task.$destroy$;
25210
- if (destroy) {
25211
- task.$destroy$ = null;
25212
- try {
25213
- destroy();
25214
- } catch (err) {
25215
- logError(err);
25216
- }
25217
- }
25218
- };
25219
- var Task = class extends Subscriber {
25220
- constructor($flags$, $index$, $el$, $qrl$, $state$, $destroy$) {
25221
- super();
25222
- this.$flags$ = $flags$;
25223
- this.$index$ = $index$;
25224
- this.$el$ = $el$;
25225
- this.$qrl$ = $qrl$;
25226
- this.$state$ = $state$;
25227
- this.$destroy$ = $destroy$;
25311
+ return middle;
25312
+ }
25313
+ }
25314
+ return ~bottom;
25315
+ }
25316
+ function sortedInsert(sortedArray, value, rootVNode) {
25317
+ const idx = sortedFindIndex(sortedArray, value, rootVNode);
25318
+ if (idx < 0) {
25319
+ sortedArray.splice(~idx, 0, value);
25320
+ return value;
25321
+ }
25322
+ const existing = sortedArray[idx];
25323
+ if (existing.$type$ === 4 /* NODE_DIFF */) {
25324
+ existing.$payload$ = value.$payload$;
25325
+ }
25326
+ if (existing.$executed$) {
25327
+ existing.$executed$ = false;
25328
+ }
25329
+ return existing;
25228
25330
  }
25229
25331
  };
25230
- var isTask = (value) => {
25231
- return value instanceof Task;
25332
+ var toNumber = (value) => {
25333
+ return typeof value === "number" ? value : -1;
25232
25334
  };
25233
-
25234
- // packages/qwik/src/core/signal/flags.ts
25235
- var NEEDS_COMPUTATION = Symbol("invalid");
25335
+ function vNodeAlreadyDeleted(chore) {
25336
+ return !!(chore.$host$ && vnode_isVNode(chore.$host$) && chore.$host$[0 /* flags */] & 32 /* Deleted */);
25337
+ }
25338
+ function debugChoreTypeToString(type) {
25339
+ return {
25340
+ [1 /* QRL_RESOLVE */]: "QRL_RESOLVE",
25341
+ [2 /* RUN_QRL */]: "RUN_QRL",
25342
+ [3 /* TASK */]: "TASK",
25343
+ [4 /* NODE_DIFF */]: "NODE_DIFF",
25344
+ [5 /* NODE_PROP */]: "NODE_PROP",
25345
+ [6 /* COMPONENT */]: "COMPONENT",
25346
+ [7 /* RECOMPUTE_AND_SCHEDULE_EFFECTS */]: "RECOMPUTE_SIGNAL",
25347
+ [16 /* JOURNAL_FLUSH */]: "JOURNAL_FLUSH",
25348
+ [32 /* VISIBLE */]: "VISIBLE",
25349
+ [48 /* CLEANUP_VISIBLE */]: "CLEANUP_VISIBLE",
25350
+ [255 /* WAIT_FOR_ALL */]: "WAIT_FOR_ALL"
25351
+ }[type] || "UNKNOWN: " + type;
25352
+ }
25353
+ function debugChoreToString(chore) {
25354
+ var _a;
25355
+ const type = debugChoreTypeToString(chore.$type$);
25356
+ const host = String(chore.$host$).replaceAll(/\n.*/gim, "");
25357
+ const qrlTarget = (_a = chore.$target$) == null ? void 0 : _a.$symbol$;
25358
+ return `Chore(${type} ${chore.$type$ === 1 /* QRL_RESOLVE */ || chore.$type$ === 2 /* RUN_QRL */ ? qrlTarget : host} ${chore.$idx$})`;
25359
+ }
25360
+ function debugTrace(action, arg, currentChore, queue) {
25361
+ const lines = ["===========================\nScheduler: " + action];
25362
+ if (arg && !("$type$" in arg)) {
25363
+ lines.push(" arg: " + String(arg).replaceAll(/\n.*/gim, ""));
25364
+ }
25365
+ if (queue) {
25366
+ queue.forEach((chore) => {
25367
+ const active = chore === arg ? ">>>" : " ";
25368
+ lines.push(
25369
+ ` ${active} > ` + (chore === currentChore ? "[running] " : "") + debugChoreToString(chore)
25370
+ );
25371
+ });
25372
+ }
25373
+ console.log(lines.join("\n") + "\n");
25374
+ }
25236
25375
 
25237
25376
  // packages/qwik/src/core/signal/signal.ts
25238
25377
  var DEBUG3 = false;
@@ -25246,7 +25385,7 @@ var throwIfQRLNotResolved = (qrl2) => {
25246
25385
  var isSignal = (value) => {
25247
25386
  return value instanceof Signal;
25248
25387
  };
25249
- var EffectPropData = class {
25388
+ var SubscriptionData = class {
25250
25389
  data;
25251
25390
  constructor(data) {
25252
25391
  this.data = data;
@@ -25285,16 +25424,10 @@ var Signal = class {
25285
25424
  }
25286
25425
  const effectSubscriber = ctx.$effectSubscriber$;
25287
25426
  if (effectSubscriber) {
25288
- const effects = this.$effects$ ||= [];
25289
- ensureContainsEffect(effects, effectSubscriber);
25290
- ensureContains(effectSubscriber, this);
25291
- if (isSubscriber(this)) {
25292
- ensureEffectContainsSubscriber(
25293
- effectSubscriber[0 /* EFFECT */],
25294
- this,
25295
- this.$container$
25296
- );
25297
- }
25427
+ const effects = this.$effects$ ||= /* @__PURE__ */ new Set();
25428
+ ensureContainsSubscription(effects, effectSubscriber);
25429
+ ensureContainsBackRef(effectSubscriber, this);
25430
+ addQrlToSerializationCtx(effectSubscriber, this.$container$);
25298
25431
  DEBUG3 && log2("read->sub", pad("\n" + this.toString(), " "));
25299
25432
  }
25300
25433
  }
@@ -25314,115 +25447,85 @@ var Signal = class {
25314
25447
  }
25315
25448
  }
25316
25449
  toString() {
25317
- var _a;
25318
- return `[${this.constructor.name}${this.$invalid$ ? " INVALID" : ""} ${String(this.$untrackedValue$)}]` + (((_a = this.$effects$) == null ? void 0 : _a.map((e) => "\n -> " + pad(qwikDebugToString(e[0]), " ")).join("\n")) || "");
25450
+ return `[${this.constructor.name}${this.$invalid$ ? " INVALID" : ""} ${String(this.$untrackedValue$)}]` + (Array.from(this.$effects$ || []).map((e) => "\n -> " + pad(qwikDebugToString(e[0]), " ")).join("\n") || "");
25319
25451
  }
25320
25452
  toJSON() {
25321
25453
  return { value: this.$untrackedValue$ };
25322
25454
  }
25323
25455
  };
25324
- var ensureContains = (array, value) => {
25325
- const isMissing = array.indexOf(value) === -1;
25326
- if (isMissing) {
25327
- array.push(value);
25328
- }
25329
- };
25330
- var ensureContainsEffect = (array, effectSubscriptions) => {
25331
- for (let i = 0; i < array.length; i++) {
25332
- const existingEffect = array[i];
25333
- if (existingEffect[0] === effectSubscriptions[0] && existingEffect[1] === effectSubscriptions[1]) {
25334
- return;
25335
- }
25336
- }
25337
- array.push(effectSubscriptions);
25338
- };
25339
- var ensureEffectContainsSubscriber = (effect, subscriber, container) => {
25340
- if (isSubscriber(effect)) {
25341
- effect.$effectDependencies$ ||= [];
25342
- if (subscriberExistInSubscribers(effect.$effectDependencies$, subscriber)) {
25343
- return;
25344
- }
25345
- effect.$effectDependencies$.push(subscriber);
25346
- } else if (vnode_isVNode(effect) && !vnode_isTextVNode(effect)) {
25347
- let subscribers = vnode_getProp(
25348
- effect,
25349
- QSubscribers,
25350
- container ? container.$getObjectById$ : null
25351
- );
25352
- subscribers ||= [];
25353
- if (subscriberExistInSubscribers(subscribers, subscriber)) {
25354
- return;
25355
- }
25356
- subscribers.push(subscriber);
25357
- vnode_setProp(effect, QSubscribers, subscribers);
25358
- } else if (isSSRNode(effect)) {
25359
- let subscribers = effect.getProp(QSubscribers);
25360
- subscribers ||= [];
25361
- if (subscriberExistInSubscribers(subscribers, subscriber)) {
25362
- return;
25363
- }
25364
- subscribers.push(subscriber);
25365
- effect.setProp(QSubscribers, subscribers);
25366
- }
25456
+ var ensureContainsSubscription = (array, effectSubscription) => {
25457
+ array.add(effectSubscription);
25367
25458
  };
25368
- var isSSRNode = (effect) => {
25369
- return "setProp" in effect && "getProp" in effect && "removeProp" in effect && "id" in effect;
25459
+ var ensureContainsBackRef = (array, value) => {
25460
+ array[2 /* BACK_REF */] ||= /* @__PURE__ */ new Set();
25461
+ array[2 /* BACK_REF */].add(value);
25370
25462
  };
25371
- var subscriberExistInSubscribers = (subscribers, subscriber) => {
25372
- for (let i = 0; i < subscribers.length; i++) {
25373
- if (subscribers[i] === subscriber) {
25374
- return true;
25463
+ var addQrlToSerializationCtx = (effectSubscriber, container) => {
25464
+ if (!!container && !isDomContainer(container)) {
25465
+ const effect = effectSubscriber[0 /* CONSUMER */];
25466
+ const property = effectSubscriber[1 /* PROPERTY */];
25467
+ let qrl2 = null;
25468
+ if (isTask(effect)) {
25469
+ qrl2 = effect.$qrl$;
25470
+ } else if (effect instanceof ComputedSignal) {
25471
+ qrl2 = effect.$computeQrl$;
25472
+ } else if (property === ":" /* COMPONENT */) {
25473
+ qrl2 = container.getHostProp(effect, OnRenderProp);
25474
+ }
25475
+ if (qrl2) {
25476
+ container.serializationCtx.$eventQrls$.add(qrl2);
25375
25477
  }
25376
25478
  }
25377
- return false;
25378
25479
  };
25379
25480
  var triggerEffects = (container, signal, effects) => {
25481
+ const isBrowser2 = isDomContainer(container);
25380
25482
  if (effects) {
25381
- const scheduleEffect = (effectSubscriptions) => {
25382
- const effect = effectSubscriptions[0 /* EFFECT */];
25383
- const property = effectSubscriptions[1 /* PROPERTY */];
25483
+ const scheduleEffect = (effectSubscription) => {
25484
+ const consumer = effectSubscription[0 /* CONSUMER */];
25485
+ const property = effectSubscription[1 /* PROPERTY */];
25384
25486
  assertDefined(container, "Container must be defined.");
25385
- if (isTask(effect)) {
25386
- effect.$flags$ |= 8 /* DIRTY */;
25387
- DEBUG3 && log2("schedule.effect.task", pad("\n" + String(effect), " "));
25487
+ if (isTask(consumer)) {
25488
+ consumer.$flags$ |= 8 /* DIRTY */;
25489
+ DEBUG3 && log2("schedule.consumer.task", pad("\n" + String(consumer), " "));
25388
25490
  let choreType = 3 /* TASK */;
25389
- if (effect.$flags$ & 1 /* VISIBLE_TASK */) {
25491
+ if (consumer.$flags$ & 1 /* VISIBLE_TASK */) {
25390
25492
  choreType = 32 /* VISIBLE */;
25391
- } else if (effect.$flags$ & 4 /* RESOURCE */) {
25392
- choreType = 2 /* RESOURCE */;
25393
25493
  }
25394
- container.$scheduler$(choreType, effect);
25395
- } else if (effect instanceof Signal) {
25396
- if (effect instanceof ComputedSignal) {
25397
- if (!effect.$computeQrl$.resolved) {
25398
- container.$scheduler$(1 /* QRL_RESOLVE */, null, effect.$computeQrl$);
25494
+ container.$scheduler$(choreType, consumer);
25495
+ } else if (consumer instanceof Signal) {
25496
+ if (consumer instanceof ComputedSignal) {
25497
+ if (!consumer.$computeQrl$.resolved) {
25498
+ container.$scheduler$(1 /* QRL_RESOLVE */, null, consumer.$computeQrl$);
25399
25499
  }
25400
25500
  }
25401
- effect.$invalidate$();
25501
+ consumer.$invalidate$();
25402
25502
  } else if (property === ":" /* COMPONENT */) {
25403
- const host = effect;
25503
+ const host = consumer;
25404
25504
  const qrl2 = container.getHostProp(host, OnRenderProp);
25405
25505
  assertDefined(qrl2, "Component must have QRL");
25406
25506
  const props = container.getHostProp(host, ELEMENT_PROPS);
25407
- container.$scheduler$(7 /* COMPONENT */, host, qrl2, props);
25408
- } else if (property === "." /* VNODE */) {
25409
- const host = effect;
25410
- const target = host;
25411
- container.$scheduler$(4 /* NODE_DIFF */, host, target, signal);
25412
- } else {
25413
- const host = effect;
25414
- const effectData = effectSubscriptions[2 /* FIRST_BACK_REF_OR_DATA */];
25415
- if (effectData instanceof EffectPropData) {
25416
- const data = effectData.data;
25417
- const payload = {
25418
- ...data,
25419
- $value$: signal
25420
- };
25421
- container.$scheduler$(5 /* NODE_PROP */, host, property, payload);
25507
+ container.$scheduler$(6 /* COMPONENT */, host, qrl2, props);
25508
+ } else if (isBrowser2) {
25509
+ if (property === "." /* VNODE */) {
25510
+ const host = consumer;
25511
+ container.$scheduler$(4 /* NODE_DIFF */, host, host, signal);
25512
+ } else {
25513
+ const host = consumer;
25514
+ const effectData = effectSubscription[3 /* DATA */];
25515
+ if (effectData instanceof SubscriptionData) {
25516
+ const data = effectData.data;
25517
+ const payload = {
25518
+ ...data,
25519
+ $value$: signal
25520
+ };
25521
+ container.$scheduler$(5 /* NODE_PROP */, host, property, payload);
25522
+ }
25422
25523
  }
25423
25524
  }
25424
25525
  };
25425
- effects.forEach(scheduleEffect);
25526
+ for (const effect of effects) {
25527
+ scheduleEffect(effect);
25528
+ }
25426
25529
  }
25427
25530
  DEBUG3 && log2("done scheduling");
25428
25531
  };
@@ -25446,7 +25549,7 @@ var ComputedSignal = class extends Signal {
25446
25549
  var _a;
25447
25550
  this.$invalid$ = true;
25448
25551
  this.$forceRunEffects$ = false;
25449
- (_a = this.$container$) == null ? void 0 : _a.$scheduler$(8 /* RECOMPUTE_AND_SCHEDULE_EFFECTS */, null, this);
25552
+ (_a = this.$container$) == null ? void 0 : _a.$scheduler$(7 /* RECOMPUTE_AND_SCHEDULE_EFFECTS */, null, this);
25450
25553
  }
25451
25554
  /**
25452
25555
  * Use this to force running subscribers, for example when the calculated value has mutated but
@@ -25473,7 +25576,7 @@ var ComputedSignal = class extends Signal {
25473
25576
  throwIfQRLNotResolved(computeQrl);
25474
25577
  const ctx = tryGetInvokeContext();
25475
25578
  const previousEffectSubscription = ctx == null ? void 0 : ctx.$effectSubscriber$;
25476
- ctx && (ctx.$effectSubscriber$ = [this, "." /* VNODE */]);
25579
+ ctx && (ctx.$effectSubscriber$ = getSubscriber(this, "." /* VNODE */));
25477
25580
  try {
25478
25581
  const untrackedValue = computeQrl.getFn(ctx)();
25479
25582
  if (isPromise(untrackedValue)) {
@@ -25510,9 +25613,9 @@ var WrappedSignal = class extends Signal {
25510
25613
  // We need a separate flag to know when the computation needs running because
25511
25614
  // we need the old value to know if effects need running after computation
25512
25615
  $invalid$ = true;
25513
- $effectDependencies$ = null;
25514
25616
  $hostElement$ = null;
25515
25617
  $forceRunEffects$ = false;
25618
+ [_EFFECT_BACK_REF] = null;
25516
25619
  constructor(container, fn, args, fnStr) {
25517
25620
  super(container, NEEDS_COMPUTATION);
25518
25621
  this.$args$ = args;
@@ -25524,7 +25627,7 @@ var WrappedSignal = class extends Signal {
25524
25627
  this.$invalid$ = true;
25525
25628
  this.$forceRunEffects$ = false;
25526
25629
  (_a = this.$container$) == null ? void 0 : _a.$scheduler$(
25527
- 8 /* RECOMPUTE_AND_SCHEDULE_EFFECTS */,
25630
+ 7 /* RECOMPUTE_AND_SCHEDULE_EFFECTS */,
25528
25631
  this.$hostElement$,
25529
25632
  this
25530
25633
  );
@@ -25613,16 +25716,6 @@ var _SharedContainer = class {
25613
25716
  }
25614
25717
  };
25615
25718
 
25616
- // packages/qwik/src/core/shared/utils/constants.ts
25617
- var QObjectRecursive = 1 << 0;
25618
- var QObjectImmutable = 1 << 1;
25619
- var QObjectTargetSymbol = Symbol("proxy target");
25620
- var QObjectFlagsSymbol = Symbol("proxy flags");
25621
- var QObjectManagerSymbol = Symbol("proxy manager");
25622
- var _CONST_PROPS = Symbol("CONST");
25623
- var _VAR_PROPS = Symbol("VAR");
25624
- var _IMMUTABLE = Symbol("IMMUTABLE");
25625
-
25626
25719
  // packages/qwik/src/core/shared-types.ts
25627
25720
  function isStringifiable(value) {
25628
25721
  return value === null || typeof value === "string" || typeof value === "number" || typeof value === "boolean";
@@ -25814,7 +25907,7 @@ function qwikDebugToString(value) {
25814
25907
  return String(value);
25815
25908
  } else if (isTask(value)) {
25816
25909
  return `Task(${qwikDebugToString(value.$qrl$)})`;
25817
- } else if (isQrl(value)) {
25910
+ } else if (isQrl2(value)) {
25818
25911
  return `Qrl(${value.$symbol$})`;
25819
25912
  } else if (typeof value === "object" || typeof value === "function") {
25820
25913
  if (stringifyPath.includes(value)) {
@@ -26143,13 +26236,13 @@ var VNodeDataChar = {
26143
26236
  /* **** */
26144
26237
  "^"
26145
26238
  ),
26146
- SUBS: (
26147
- /* *************** */
26239
+ BACK_REFS: (
26240
+ /* ********** */
26148
26241
  96
26149
26242
  ),
26150
- // '`' - `q:subs' - Effect dependencies/subscriptions
26151
- SUBS_CHAR: (
26152
- /* ******* */
26243
+ // '`' - `q:brefs' - Effect dependencies/subscriptions
26244
+ BACK_REFS_CHAR: (
26245
+ /* ** */
26153
26246
  "`"
26154
26247
  ),
26155
26248
  SEPARATOR: (
@@ -26172,6 +26265,14 @@ var VNodeDataChar = {
26172
26265
  )
26173
26266
  };
26174
26267
 
26268
+ // packages/qwik/src/core/shared/utils/maps.ts
26269
+ var mergeMaps = (map1, map2) => {
26270
+ for (const [k, v] of map2) {
26271
+ map1.set(k, v);
26272
+ }
26273
+ return map1;
26274
+ };
26275
+
26175
26276
  // packages/qwik/src/core/client/vnode.ts
26176
26277
  var vnode_newElement = (element, elementName) => {
26177
26278
  assertEqual(fastNodeType(element), 1, "Expecting element node.");
@@ -26333,6 +26434,7 @@ var vnode_ensureElementInflated = (vnode) => {
26333
26434
  elementVNode[0 /* flags */] ^= 8 /* Inflated */;
26334
26435
  const element = elementVNode[6 /* element */];
26335
26436
  const attributes = element.attributes;
26437
+ const props = vnode_getProps(elementVNode);
26336
26438
  for (let idx = 0; idx < attributes.length; idx++) {
26337
26439
  const attr = attributes[idx];
26338
26440
  const key = attr.name;
@@ -26340,23 +26442,13 @@ var vnode_ensureElementInflated = (vnode) => {
26340
26442
  break;
26341
26443
  } else if (key.startsWith(QContainerAttr)) {
26342
26444
  if (attr.value === "html" /* HTML */) {
26343
- mapArray_set(
26344
- elementVNode,
26345
- dangerouslySetInnerHTML,
26346
- element.innerHTML,
26347
- 8 /* PROPS_OFFSET */
26348
- );
26445
+ mapArray_set(props, dangerouslySetInnerHTML, element.innerHTML, 0);
26349
26446
  } else if (attr.value === "text" /* TEXT */ && "value" in element) {
26350
- mapArray_set(
26351
- elementVNode,
26352
- "value",
26353
- element.value,
26354
- 8 /* PROPS_OFFSET */
26355
- );
26447
+ mapArray_set(props, "value", element.value, 0);
26356
26448
  }
26357
26449
  } else if (!key.startsWith("on:")) {
26358
26450
  const value = attr.value;
26359
- mapArray_set(elementVNode, key, value, 8 /* PROPS_OFFSET */);
26451
+ mapArray_set(props, key, value, 0);
26360
26452
  }
26361
26453
  }
26362
26454
  }
@@ -26685,59 +26777,14 @@ var vnode_applyJournal = (journal) => {
26685
26777
  }
26686
26778
  journal.length = 0;
26687
26779
  };
26688
- var mapApp_findIndx = (elementVNode, key, start) => {
26689
- assertTrue(start % 2 === 0, "Expecting even number.");
26690
- let bottom = start >> 1;
26691
- let top = elementVNode.length - 2 >> 1;
26692
- while (bottom <= top) {
26693
- const mid = bottom + (top - bottom >> 1);
26694
- const midKey = elementVNode[mid << 1];
26695
- if (midKey === key) {
26696
- return mid << 1;
26697
- }
26698
- if (midKey < key) {
26699
- bottom = mid + 1;
26700
- } else {
26701
- top = mid - 1;
26702
- }
26703
- }
26704
- return bottom << 1 ^ -1;
26705
- };
26706
- var mapArray_set = (elementVNode, key, value, start) => {
26707
- const indx = mapApp_findIndx(elementVNode, key, start);
26708
- if (indx >= 0) {
26709
- if (value == null) {
26710
- elementVNode.splice(indx, 2);
26711
- } else {
26712
- elementVNode[indx + 1] = value;
26713
- }
26714
- } else if (value != null) {
26715
- elementVNode.splice(indx ^ -1, 0, key, value);
26716
- }
26717
- };
26718
- var mapApp_remove = (elementVNode, key, start) => {
26719
- const indx = mapApp_findIndx(elementVNode, key, start);
26720
- let value = null;
26721
- if (indx >= 0) {
26722
- value = elementVNode[indx + 1];
26723
- elementVNode.splice(indx, 2);
26724
- return value;
26725
- }
26726
- return value;
26727
- };
26728
- var mapArray_get = (elementVNode, key, start) => {
26729
- const indx = mapApp_findIndx(elementVNode, key, start);
26730
- if (indx >= 0) {
26731
- return elementVNode[indx + 1];
26732
- } else {
26733
- return null;
26734
- }
26735
- };
26736
26780
  var vnode_insertBefore = (journal, parent, newChild, insertBefore) => {
26737
26781
  ensureElementOrVirtualVNode(parent);
26738
26782
  if (vnode_isElementVNode(parent)) {
26739
26783
  ensureMaterialized(parent);
26740
26784
  }
26785
+ if (newChild === insertBefore) {
26786
+ insertBefore = null;
26787
+ }
26741
26788
  let adjustedInsertBefore = null;
26742
26789
  if (insertBefore == null) {
26743
26790
  if (vnode_isVirtualVNode(parent)) {
@@ -26840,8 +26887,10 @@ var vnode_getElementName = (vnode) => {
26840
26887
  const elementVNode = ensureElementVNode(vnode);
26841
26888
  let elementName = elementVNode[7 /* elementName */];
26842
26889
  if (elementName === void 0) {
26843
- elementName = elementVNode[7 /* elementName */] = elementVNode[6 /* element */].nodeName.toLowerCase();
26844
- elementVNode[0 /* flags */] |= vnode_getElementNamespaceFlags(elementName);
26890
+ const element = elementVNode[6 /* element */];
26891
+ const nodeName = import_build8.isDev ? fastNodeName(element).toLowerCase() : fastNodeName(element);
26892
+ elementName = elementVNode[7 /* elementName */] = nodeName;
26893
+ elementVNode[0 /* flags */] |= vnode_getElementNamespaceFlags(element);
26845
26894
  }
26846
26895
  return elementName;
26847
26896
  };
@@ -27010,6 +27059,20 @@ var fastFirstChild = (node) => {
27010
27059
  }
27011
27060
  return node;
27012
27061
  };
27062
+ var _fastNamespaceURI = null;
27063
+ var fastNamespaceURI = (element) => {
27064
+ if (!_fastNamespaceURI) {
27065
+ _fastNamespaceURI = fastGetter(element, "namespaceURI");
27066
+ }
27067
+ return _fastNamespaceURI.call(element);
27068
+ };
27069
+ var _fastNodeName = null;
27070
+ var fastNodeName = (element) => {
27071
+ if (!_fastNodeName) {
27072
+ _fastNodeName = fastGetter(element, "nodeName");
27073
+ }
27074
+ return _fastNodeName.call(element);
27075
+ };
27013
27076
  var fastGetter = (prototype, name) => {
27014
27077
  var _a;
27015
27078
  let getter;
@@ -27066,9 +27129,12 @@ var materializeFromDOM = (vParent, firstChild, vData) => {
27066
27129
  }
27067
27130
  const id = consumeValue();
27068
27131
  container.$setRawState$(parseInt(id), vParent);
27069
- import_build6.isDev && vnode_setAttr(null, vParent, ELEMENT_ID, id);
27070
- } else if (peek() === VNodeDataChar.SUBS) {
27071
- vnode_setProp(vParent, QSubscribers, consumeValue());
27132
+ import_build8.isDev && vnode_setAttr(null, vParent, ELEMENT_ID, id);
27133
+ } else if (peek() === VNodeDataChar.BACK_REFS) {
27134
+ if (!container) {
27135
+ container = getDomContainer(vParent[6 /* element */]);
27136
+ }
27137
+ setEffectBackRefFromVNodeData(vParent, consumeValue(), container);
27072
27138
  } else {
27073
27139
  consumeValue();
27074
27140
  }
@@ -27076,6 +27142,17 @@ var materializeFromDOM = (vParent, firstChild, vData) => {
27076
27142
  }
27077
27143
  return vFirstChild;
27078
27144
  };
27145
+ function setEffectBackRefFromVNodeData(vParent, value, container) {
27146
+ const deserializedSubMap = container.$getObjectById$(value);
27147
+ if (!vParent[_EFFECT_BACK_REF]) {
27148
+ Object.defineProperty(vParent, _EFFECT_BACK_REF, {
27149
+ value: deserializedSubMap
27150
+ });
27151
+ } else {
27152
+ const subMap = vParent[_EFFECT_BACK_REF];
27153
+ mergeMaps(subMap, deserializedSubMap);
27154
+ }
27155
+ }
27079
27156
  var processVNodeData = (vData, callback) => {
27080
27157
  let nextToConsumeIdx = 0;
27081
27158
  let ch = 0;
@@ -27116,8 +27193,9 @@ var vnode_getAttrKeys = (vnode) => {
27116
27193
  if ((type & 3 /* ELEMENT_OR_VIRTUAL_MASK */) !== 0) {
27117
27194
  vnode_ensureElementInflated(vnode);
27118
27195
  const keys = [];
27119
- for (let i = vnode_getPropStartIndex(vnode); i < vnode.length; i = i + 2) {
27120
- const key = vnode[i];
27196
+ const props = vnode_getProps(vnode);
27197
+ for (let i = 0; i < props.length; i = i + 2) {
27198
+ const key = props[i];
27121
27199
  if (!key.startsWith(Q_PROPS_SEPARATOR)) {
27122
27200
  keys.push(key);
27123
27201
  }
@@ -27130,19 +27208,20 @@ var vnode_setAttr = (journal, vnode, key, value) => {
27130
27208
  const type = vnode[0 /* flags */];
27131
27209
  if ((type & 3 /* ELEMENT_OR_VIRTUAL_MASK */) !== 0) {
27132
27210
  vnode_ensureElementInflated(vnode);
27133
- const idx = mapApp_findIndx(vnode, key, vnode_getPropStartIndex(vnode));
27211
+ const props = vnode_getProps(vnode);
27212
+ const idx = mapApp_findIndx(props, key, 0);
27134
27213
  if (idx >= 0) {
27135
- if (vnode[idx + 1] != value && (type & 1 /* Element */) !== 0) {
27214
+ if (props[idx + 1] != value && (type & 1 /* Element */) !== 0) {
27136
27215
  const element = vnode[6 /* element */];
27137
27216
  journal && journal.push(2 /* SetAttribute */, element, key, value);
27138
27217
  }
27139
27218
  if (value == null) {
27140
- vnode.splice(idx, 2);
27219
+ props.splice(idx, 2);
27141
27220
  } else {
27142
- vnode[idx + 1] = value;
27221
+ props[idx + 1] = value;
27143
27222
  }
27144
27223
  } else if (value != null) {
27145
- vnode.splice(idx ^ -1, 0, key, value);
27224
+ props.splice(idx ^ -1, 0, key, value);
27146
27225
  if ((type & 1 /* Element */) !== 0) {
27147
27226
  const element = vnode[6 /* element */];
27148
27227
  journal && journal.push(2 /* SetAttribute */, element, key, value);
@@ -27154,7 +27233,8 @@ var vnode_getAttr = (vnode, key) => {
27154
27233
  const type = vnode[0 /* flags */];
27155
27234
  if ((type & 3 /* ELEMENT_OR_VIRTUAL_MASK */) !== 0) {
27156
27235
  vnode_ensureElementInflated(vnode);
27157
- return mapArray_get(vnode, key, vnode_getPropStartIndex(vnode));
27236
+ const props = vnode_getProps(vnode);
27237
+ return mapArray_get(props, key, 0);
27158
27238
  }
27159
27239
  return null;
27160
27240
  };
@@ -27162,11 +27242,12 @@ var vnode_getProp = (vnode, key, getObject) => {
27162
27242
  const type = vnode[0 /* flags */];
27163
27243
  if ((type & 3 /* ELEMENT_OR_VIRTUAL_MASK */) !== 0) {
27164
27244
  type & 1 /* Element */ && vnode_ensureElementInflated(vnode);
27165
- const idx = mapApp_findIndx(vnode, key, vnode_getPropStartIndex(vnode));
27245
+ const props = vnode_getProps(vnode);
27246
+ const idx = mapApp_findIndx(props, key, 0);
27166
27247
  if (idx >= 0) {
27167
- let value = vnode[idx + 1];
27248
+ let value = props[idx + 1];
27168
27249
  if (typeof value === "string" && getObject) {
27169
- vnode[idx + 1] = value = getObject(value);
27250
+ props[idx + 1] = value = getObject(value);
27170
27251
  }
27171
27252
  return value;
27172
27253
  }
@@ -27175,11 +27256,12 @@ var vnode_getProp = (vnode, key, getObject) => {
27175
27256
  };
27176
27257
  var vnode_setProp = (vnode, key, value) => {
27177
27258
  ensureElementOrVirtualVNode(vnode);
27178
- const idx = mapApp_findIndx(vnode, key, vnode_getPropStartIndex(vnode));
27259
+ const props = vnode_getProps(vnode);
27260
+ const idx = mapApp_findIndx(props, key, 0);
27179
27261
  if (idx >= 0) {
27180
- vnode[idx + 1] = value;
27262
+ props[idx + 1] = value;
27181
27263
  } else if (value != null) {
27182
- vnode.splice(idx ^ -1, 0, key, value);
27264
+ props.splice(idx ^ -1, 0, key, value);
27183
27265
  }
27184
27266
  };
27185
27267
  var vnode_getPropStartIndex = (vnode) => {
@@ -27191,6 +27273,9 @@ var vnode_getPropStartIndex = (vnode) => {
27191
27273
  }
27192
27274
  throw qError(43 /* invalidVNodeType */, [type]);
27193
27275
  };
27276
+ var vnode_getProps = (vnode) => {
27277
+ return vnode[vnode_getPropStartIndex(vnode)];
27278
+ };
27194
27279
  var vnode_getParent = (vnode) => {
27195
27280
  return vnode[1 /* parent */] || null;
27196
27281
  };
@@ -27329,7 +27414,7 @@ function materializeFromVNodeData(vParent, vData, element, child) {
27329
27414
  }
27330
27415
  const id = consumeValue();
27331
27416
  container.$setRawState$(parseInt(id), vParent);
27332
- import_build6.isDev && vnode_setAttr(null, vParent, ELEMENT_ID, id);
27417
+ import_build8.isDev && vnode_setAttr(null, vParent, ELEMENT_ID, id);
27333
27418
  } else if (peek() === VNodeDataChar.PROPS) {
27334
27419
  vnode_setAttr(null, vParent, ELEMENT_PROPS, consumeValue());
27335
27420
  } else if (peek() === VNodeDataChar.SLOT_REF) {
@@ -27340,8 +27425,11 @@ function materializeFromVNodeData(vParent, vData, element, child) {
27340
27425
  vnode_setAttr(null, vParent, ELEMENT_SEQ, consumeValue());
27341
27426
  } else if (peek() === VNodeDataChar.SEQ_IDX) {
27342
27427
  vnode_setAttr(null, vParent, ELEMENT_SEQ_IDX, consumeValue());
27343
- } else if (peek() === VNodeDataChar.SUBS) {
27344
- vnode_setProp(vParent, QSubscribers, consumeValue());
27428
+ } else if (peek() === VNodeDataChar.BACK_REFS) {
27429
+ if (!container) {
27430
+ container = getDomContainer(element);
27431
+ }
27432
+ setEffectBackRefFromVNodeData(vParent, consumeValue(), container);
27345
27433
  } else if (peek() === VNodeDataChar.CONTEXT) {
27346
27434
  vnode_setAttr(null, vParent, QCtxAttr, consumeValue());
27347
27435
  } else if (peek() === VNodeDataChar.OPEN) {
@@ -27424,24 +27512,38 @@ var vnode_getProjectionParentComponent = (vHost, rootVNode) => {
27424
27512
  };
27425
27513
  var VNodeArray = class VNode extends Array {
27426
27514
  static createElement(flags, parent, previousSibling, nextSibling, firstChild, lastChild, element, elementName) {
27427
- const vnode = new VNode(flags, parent, previousSibling, nextSibling);
27428
- vnode.push(firstChild, lastChild, element, elementName);
27515
+ const vnode = new VNode(
27516
+ flags,
27517
+ parent,
27518
+ previousSibling,
27519
+ nextSibling,
27520
+ firstChild,
27521
+ lastChild,
27522
+ element,
27523
+ elementName,
27524
+ []
27525
+ );
27429
27526
  return vnode;
27430
27527
  }
27431
27528
  static createText(flags, parent, previousSibling, nextSibling, textNode, text) {
27432
- const vnode = new VNode(flags, parent, previousSibling, nextSibling);
27433
- vnode.push(textNode, text);
27529
+ const vnode = new VNode(flags, parent, previousSibling, nextSibling, textNode, text);
27434
27530
  return vnode;
27435
27531
  }
27436
27532
  static createVirtual(flags, parent, previousSibling, nextSibling, firstChild, lastChild) {
27437
- const vnode = new VNode(flags, parent, previousSibling, nextSibling);
27438
- vnode.push(firstChild, lastChild);
27533
+ const vnode = new VNode(
27534
+ flags,
27535
+ parent,
27536
+ previousSibling,
27537
+ nextSibling,
27538
+ firstChild,
27539
+ lastChild,
27540
+ []
27541
+ );
27439
27542
  return vnode;
27440
27543
  }
27441
- constructor(flags, parent, previousSibling, nextSibling) {
27442
- super();
27443
- this.push(flags, parent, previousSibling, nextSibling);
27444
- if (import_build6.isDev) {
27544
+ constructor(flags, parent, previousSibling, nextSibling, ...rest) {
27545
+ super(flags, parent, previousSibling, nextSibling, ...rest);
27546
+ if (import_build8.isDev) {
27445
27547
  this.toString = vnode_toString;
27446
27548
  }
27447
27549
  }
@@ -27486,10 +27588,12 @@ function invokeApply(context, fn, args) {
27486
27588
  return returnValue;
27487
27589
  }
27488
27590
  var newInvokeContextFromTuple = ([element, event, url]) => {
27489
- const container = element.closest(QContainerSelector);
27591
+ const domContainer = getDomContainer(element);
27592
+ const container = domContainer.element;
27593
+ const vNode = container ? vnode_locate(domContainer.rootVNode, element) : void 0;
27490
27594
  const locale = (container == null ? void 0 : container.getAttribute(QLocaleAttr)) || void 0;
27491
27595
  locale && setLocale(locale);
27492
- return newInvokeContext(locale, void 0, element, event, url);
27596
+ return newInvokeContext(locale, vNode, element, event, url);
27493
27597
  };
27494
27598
  var newInvokeContext = (locale, hostElement, element, event, url) => {
27495
27599
  const $locale$ = locale || (typeof event === "object" && event && "locale" in event ? event.locale : void 0);
@@ -27520,10 +27624,7 @@ var trackSignal = (fn, subscriber, property, container, data) => {
27520
27624
  const previousSubscriber = trackInvocation.$effectSubscriber$;
27521
27625
  const previousContainer = trackInvocation.$container$;
27522
27626
  try {
27523
- trackInvocation.$effectSubscriber$ = [subscriber, property];
27524
- if (data) {
27525
- trackInvocation.$effectSubscriber$.push(data);
27526
- }
27627
+ trackInvocation.$effectSubscriber$ = getSubscriber(subscriber, property, data);
27527
27628
  trackInvocation.$container$ = container;
27528
27629
  return invoke(trackInvocation, fn);
27529
27630
  } finally {
@@ -27878,9 +27979,9 @@ var DomContainer = class extends _SharedContainer {
27878
27979
  $storeProxyMap$ = /* @__PURE__ */ new WeakMap();
27879
27980
  $qFuncs$;
27880
27981
  $instanceHash$;
27881
- stateData;
27982
+ vNodeLocate = (id) => vnode_locate(this.rootVNode, id);
27983
+ $stateData$;
27882
27984
  $styleIds$ = null;
27883
- $vnodeLocate$ = (id) => vnode_locate(this.rootVNode, id);
27884
27985
  $renderCount$ = 0;
27885
27986
  constructor(element) {
27886
27987
  super(
@@ -27909,29 +28010,29 @@ var DomContainer = class extends _SharedContainer {
27909
28010
  this.qManifestHash = element.getAttribute("q:manifest-hash");
27910
28011
  this.rootVNode = vnode_newUnMaterializedElement(this.element);
27911
28012
  this.$rawStateData$ = null;
27912
- this.stateData = null;
28013
+ this.$stateData$ = null;
27913
28014
  const document2 = this.element.ownerDocument;
27914
28015
  if (!document2.qVNodeData) {
27915
28016
  processVNodeData2(document2);
27916
28017
  }
27917
28018
  this.$rawStateData$ = [];
27918
- this.stateData = [];
28019
+ this.$stateData$ = [];
27919
28020
  const qwikStates = element.querySelectorAll('script[type="qwik/state"]');
27920
28021
  if (qwikStates.length !== 0) {
27921
28022
  const lastState = qwikStates[qwikStates.length - 1];
27922
28023
  this.$rawStateData$ = JSON.parse(lastState.textContent);
27923
- this.stateData = wrapDeserializerProxy(this, this.$rawStateData$);
28024
+ this.$stateData$ = wrapDeserializerProxy(this, this.$rawStateData$);
27924
28025
  }
27925
28026
  this.$qFuncs$ = getQFuncs(document2, this.$instanceHash$) || EMPTY_ARRAY;
27926
28027
  }
27927
28028
  $setRawState$(id, vParent) {
27928
- this.stateData[id] = vParent;
28029
+ this.$stateData$[id] = vParent;
27929
28030
  }
27930
28031
  parseQRL(qrl2) {
27931
28032
  return inflateQRL(this, parseQRL(qrl2));
27932
28033
  }
27933
28034
  handleError(err, host) {
27934
- if (qDev) {
28035
+ if (qDev && host) {
27935
28036
  if (typeof document !== "undefined") {
27936
28037
  const vHost = host;
27937
28038
  const errorDiv = document.createElement("errored-host");
@@ -27954,7 +28055,7 @@ var DomContainer = class extends _SharedContainer {
27954
28055
  throw err;
27955
28056
  }
27956
28057
  }
27957
- const errorStore = this.resolveContext(host, ERROR_CONTEXT);
28058
+ const errorStore = host && this.resolveContext(host, ERROR_CONTEXT);
27958
28059
  if (!errorStore) {
27959
28060
  throw err;
27960
28061
  }
@@ -27988,7 +28089,7 @@ var DomContainer = class extends _SharedContainer {
27988
28089
  return vNode;
27989
28090
  }
27990
28091
  vNode = vnode_getParent(vNode) || // If virtual node, than it could be a slot so we need to read its parent.
27991
- vnode_getProp(vNode, QSlotParent, this.$vnodeLocate$);
28092
+ vnode_getProp(vNode, QSlotParent, this.vNodeLocate);
27992
28093
  } else {
27993
28094
  vNode = vnode_getParent(vNode);
27994
28095
  }
@@ -28007,7 +28108,7 @@ var DomContainer = class extends _SharedContainer {
28007
28108
  case ELEMENT_PROPS:
28008
28109
  case OnRenderProp:
28009
28110
  case QCtxAttr:
28010
- case QSubscribers:
28111
+ case QBackRefs:
28011
28112
  getObjectById = this.$getObjectById$;
28012
28113
  break;
28013
28114
  case ELEMENT_SEQ_IDX:
@@ -28020,7 +28121,9 @@ var DomContainer = class extends _SharedContainer {
28020
28121
  scheduleRender() {
28021
28122
  this.$renderCount$++;
28022
28123
  this.renderDone ||= getPlatform().nextTick(() => this.processChores());
28023
- return this.renderDone;
28124
+ return this.renderDone.finally(
28125
+ () => emitEvent("qrender", { instanceHash: this.$instanceHash$, renderCount: this.$renderCount$ })
28126
+ );
28024
28127
  }
28025
28128
  processChores() {
28026
28129
  let renderCount = this.$renderCount$;
@@ -28043,12 +28146,13 @@ var DomContainer = class extends _SharedContainer {
28043
28146
  ensureProjectionResolved(vNode) {
28044
28147
  if ((vNode[0 /* flags */] & 16 /* Resolved */) === 0) {
28045
28148
  vNode[0 /* flags */] |= 16 /* Resolved */;
28046
- for (let i = vnode_getPropStartIndex(vNode); i < vNode.length; i = i + 2) {
28047
- const prop = vNode[i];
28149
+ const props = vnode_getProps(vNode);
28150
+ for (let i = 0; i < props.length; i = i + 2) {
28151
+ const prop = props[i];
28048
28152
  if (isSlotProp(prop)) {
28049
- const value = vNode[i + 1];
28153
+ const value = props[i + 1];
28050
28154
  if (typeof value == "string") {
28051
- vNode[i + 1] = this.$vnodeLocate$(value);
28155
+ props[i + 1] = this.vNodeLocate(value);
28052
28156
  }
28053
28157
  }
28054
28158
  }
@@ -28062,7 +28166,7 @@ var DomContainer = class extends _SharedContainer {
28062
28166
  id < this.$rawStateData$.length / 2,
28063
28167
  `Invalid reference: ${id} >= ${this.$rawStateData$.length / 2}`
28064
28168
  );
28065
- return this.stateData[id];
28169
+ return this.$stateData$[id];
28066
28170
  };
28067
28171
  getSyncFn(id) {
28068
28172
  const fn = this.$qFuncs$[id];
@@ -28125,8 +28229,7 @@ var DeserializationHandler = class {
28125
28229
  }
28126
28230
  const i = typeof property === "number" ? property : typeof property === "string" ? parseInt(property, 10) : NaN;
28127
28231
  if (Number.isNaN(i) || i < 0 || i >= this.$length$) {
28128
- const out = Reflect.get(target, property, receiver);
28129
- return out;
28232
+ return Reflect.get(target, property, receiver);
28130
28233
  }
28131
28234
  const idx = i * 2;
28132
28235
  const typeId = this.$data$[idx];
@@ -28224,7 +28327,7 @@ var inflate = (container, target, typeId, data) => {
28224
28327
  task.$flags$ = v[1];
28225
28328
  task.$index$ = v[2];
28226
28329
  task.$el$ = v[3];
28227
- task.$effectDependencies$ = v[4];
28330
+ task[_EFFECT_BACK_REF] = v[4];
28228
28331
  task.$state$ = v[5];
28229
28332
  break;
28230
28333
  case 20 /* Resource */:
@@ -28246,12 +28349,9 @@ var inflate = (container, target, typeId, data) => {
28246
28349
  break;
28247
28350
  case 25 /* Store */:
28248
28351
  case 26 /* StoreArray */: {
28249
- const [value, flags, effects2, storeEffect] = data;
28352
+ const [value, flags, effects2] = data;
28250
28353
  const store = getOrCreateStore(value, flags, container);
28251
28354
  const storeHandler = getStoreHandler(store);
28252
- if (storeEffect) {
28253
- effects2[STORE_ARRAY_PROP] = storeEffect;
28254
- }
28255
28355
  storeHandler.$effects$ = effects2;
28256
28356
  target = store;
28257
28357
  break;
@@ -28260,7 +28360,7 @@ var inflate = (container, target, typeId, data) => {
28260
28360
  const signal = target;
28261
28361
  const d = data;
28262
28362
  signal.$untrackedValue$ = d[0];
28263
- signal.$effects$ = d.slice(1);
28363
+ signal.$effects$ = new Set(d.slice(1));
28264
28364
  break;
28265
28365
  }
28266
28366
  case 23 /* WrappedSignal */: {
@@ -28268,10 +28368,10 @@ var inflate = (container, target, typeId, data) => {
28268
28368
  const d = data;
28269
28369
  signal.$func$ = container.getSyncFn(d[0]);
28270
28370
  signal.$args$ = d[1];
28271
- signal.$effectDependencies$ = d[2];
28371
+ signal[_EFFECT_BACK_REF] = d[2];
28272
28372
  signal.$untrackedValue$ = d[3];
28273
28373
  signal.$hostElement$ = d[4];
28274
- signal.$effects$ = d.slice(5);
28374
+ signal.$effects$ = new Set(d.slice(5));
28275
28375
  break;
28276
28376
  }
28277
28377
  case 24 /* ComputedSignal */: {
@@ -28386,6 +28486,7 @@ var _constants = [
28386
28486
  EMPTY_ARRAY,
28387
28487
  EMPTY_OBJ,
28388
28488
  NEEDS_COMPUTATION,
28489
+ STORE_ARRAY_PROP,
28389
28490
  Slot,
28390
28491
  Fragment,
28391
28492
  NaN,
@@ -28404,6 +28505,7 @@ var _constantNames = [
28404
28505
  "EMPTY_ARRAY",
28405
28506
  "EMPTY_OBJ",
28406
28507
  "NEEDS_COMPUTATION",
28508
+ "STORE_ARRAY_PROP",
28407
28509
  "Slot",
28408
28510
  "Fragment",
28409
28511
  "NaN",
@@ -28485,6 +28587,8 @@ var allocate = (container, typeId, value) => {
28485
28587
  reject = rej;
28486
28588
  });
28487
28589
  resolvers.set(promise, [resolve, reject]);
28590
+ promise.catch(() => {
28591
+ });
28488
28592
  return promise;
28489
28593
  case 17 /* Uint8Array */:
28490
28594
  const encodedLength = value.length;
@@ -28494,12 +28598,9 @@ var allocate = (container, typeId, value) => {
28494
28598
  return new Uint8Array(decodedLength);
28495
28599
  case 29 /* PropsProxy */:
28496
28600
  return createPropsProxy(null, null);
28497
- case 9 /* RefVNode */:
28498
28601
  case 8 /* VNode */:
28499
- const vnodeOrDocument = retrieveVNodeOrDocument(container, value);
28500
- if (typeId === 8 /* VNode */) {
28501
- return vnodeOrDocument;
28502
- }
28602
+ return retrieveVNodeOrDocument(container, value);
28603
+ case 9 /* RefVNode */:
28503
28604
  const vNode = retrieveVNodeOrDocument(container, value);
28504
28605
  if (vnode_isVNode(vNode)) {
28505
28606
  return vnode_getNode(vNode);
@@ -28507,7 +28608,7 @@ var allocate = (container, typeId, value) => {
28507
28608
  throw qError(34 /* serializeErrorExpectedVNode */, [typeof vNode]);
28508
28609
  }
28509
28610
  case 30 /* EffectData */:
28510
- return new EffectPropData({});
28611
+ return new SubscriptionData({});
28511
28612
  default:
28512
28613
  throw qError(35 /* serializeErrorCannotAllocate */, [typeId]);
28513
28614
  }
@@ -28524,12 +28625,12 @@ function parseQRL(qrl2) {
28524
28625
  const symbol = captureStart > -1 ? qrl2.slice(hashIdx + 1, captureStart) : qrl2.slice(hashIdx + 1);
28525
28626
  const captureIds = captureStart > -1 && captureEnd > -1 ? qrl2.slice(captureStart + 1, captureEnd).split(" ").filter((v) => v.length).map((s) => parseInt(s, 10)) : null;
28526
28627
  let qrlRef = null;
28527
- if (isDev && chunk === QRL_RUNTIME_CHUNK) {
28628
+ if (isDev2 && chunk === QRL_RUNTIME_CHUNK) {
28528
28629
  const backChannel = globalThis[QRL_RUNTIME_CHUNK];
28529
28630
  assertDefined(backChannel, "Missing QRL_RUNTIME_CHUNK");
28530
28631
  qrlRef = backChannel.get(symbol);
28531
28632
  }
28532
- return createQRL(chunk, symbol, qrlRef, null, captureIds, null, null);
28633
+ return createQRL(chunk, symbol, qrlRef, null, captureIds, null);
28533
28634
  }
28534
28635
  function inflateQRL(container, qrl2) {
28535
28636
  const captureIds = qrl2.$capture$;
@@ -28563,13 +28664,13 @@ var createSerializationContext = (NodeConstructor, DomRefConstructor, symbolToCh
28563
28664
  }
28564
28665
  return id;
28565
28666
  };
28566
- const isSsrNode = NodeConstructor ? (obj) => obj instanceof NodeConstructor : () => false;
28667
+ const isSsrNode2 = NodeConstructor ? (obj) => obj instanceof NodeConstructor : () => false;
28567
28668
  isDomRef = DomRefConstructor ? (obj) => obj instanceof DomRefConstructor : () => false;
28568
28669
  return {
28569
28670
  $serialize$() {
28570
28671
  serialize(this);
28571
28672
  },
28572
- $isSsrNode$: isSsrNode,
28673
+ $isSsrNode$: isSsrNode2,
28573
28674
  $isDomRef$: isDomRef,
28574
28675
  $symbolToChunkResolver$: symbolToChunkResolver,
28575
28676
  $wasSeen$,
@@ -28625,7 +28726,7 @@ var createSerializationContext = (NodeConstructor, DomRefConstructor, symbolToCh
28625
28726
  const promises = [];
28626
28727
  const visit = (obj) => {
28627
28728
  if (typeof obj === "function") {
28628
- if (isQrl2(obj)) {
28729
+ if (isQrl(obj)) {
28629
28730
  if (obj.$captureRef$) {
28630
28731
  discoveredValues.push(...obj.$captureRef$);
28631
28732
  }
@@ -28635,7 +28736,7 @@ var createSerializationContext = (NodeConstructor, DomRefConstructor, symbolToCh
28635
28736
  }
28636
28737
  } else if (
28637
28738
  // skip as these are primitives
28638
- 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
28739
+ 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
28639
28740
  fastSkipSerialize(obj)
28640
28741
  ) {
28641
28742
  } else if (obj instanceof Error) {
@@ -28643,8 +28744,7 @@ var createSerializationContext = (NodeConstructor, DomRefConstructor, symbolToCh
28643
28744
  } else if (isStore(obj)) {
28644
28745
  const target = getStoreTarget(obj);
28645
28746
  const effects = getStoreHandler(obj).$effects$;
28646
- const storeEffect = (effects == null ? void 0 : effects[STORE_ARRAY_PROP]) ?? null;
28647
- discoveredValues.push(target, effects, storeEffect);
28747
+ discoveredValues.push(target, effects);
28648
28748
  for (const prop in target) {
28649
28749
  const propValue = target[prop];
28650
28750
  if (storeProxyMap.has(propValue)) {
@@ -28666,9 +28766,7 @@ var createSerializationContext = (NodeConstructor, DomRefConstructor, symbolToCh
28666
28766
  discoveredValues.push(...obj.$effects$);
28667
28767
  }
28668
28768
  if (obj instanceof WrappedSignal) {
28669
- if (obj.$effectDependencies$) {
28670
- discoveredValues.push(...obj.$effectDependencies$);
28671
- }
28769
+ discoverEffectBackRefs(obj[_EFFECT_BACK_REF], discoveredValues);
28672
28770
  if (obj.$args$) {
28673
28771
  discoveredValues.push(...obj.$args$);
28674
28772
  }
@@ -28679,8 +28777,9 @@ var createSerializationContext = (NodeConstructor, DomRefConstructor, symbolToCh
28679
28777
  discoveredValues.push(obj.$computeQrl$);
28680
28778
  }
28681
28779
  } else if (obj instanceof Task) {
28682
- discoveredValues.push(obj.$el$, obj.$qrl$, obj.$state$, obj.$effectDependencies$);
28683
- } else if (isSsrNode(obj)) {
28780
+ discoveredValues.push(obj.$el$, obj.$qrl$, obj.$state$);
28781
+ discoverEffectBackRefs(obj[_EFFECT_BACK_REF], discoveredValues);
28782
+ } else if (isSsrNode2(obj)) {
28684
28783
  discoverValuesForVNodeData(obj.vnodeData, discoveredValues);
28685
28784
  if (obj.childrenVNodeData && obj.childrenVNodeData.length) {
28686
28785
  for (const data of obj.childrenVNodeData) {
@@ -28693,7 +28792,7 @@ var createSerializationContext = (NodeConstructor, DomRefConstructor, symbolToCh
28693
28792
  discoveredValues.push(obj.type, obj.props, obj.constProps, obj.children);
28694
28793
  } else if (Array.isArray(obj)) {
28695
28794
  discoveredValues.push(...obj);
28696
- } else if (isQrl2(obj)) {
28795
+ } else if (isQrl(obj)) {
28697
28796
  obj.$captureRef$ && obj.$captureRef$.length && discoveredValues.push(...obj.$captureRef$);
28698
28797
  } else if (isPropsProxy(obj)) {
28699
28798
  discoveredValues.push(obj[_VAR_PROPS], obj[_CONST_PROPS]);
@@ -28709,7 +28808,7 @@ var createSerializationContext = (NodeConstructor, DomRefConstructor, symbolToCh
28709
28808
  }
28710
28809
  );
28711
28810
  promises.push(obj);
28712
- } else if (obj instanceof EffectPropData) {
28811
+ } else if (obj instanceof SubscriptionData) {
28713
28812
  discoveredValues.push(obj.data);
28714
28813
  } else if (isObjectLiteral(obj)) {
28715
28814
  Object.entries(obj).forEach(([key, value]) => {
@@ -28746,15 +28845,30 @@ var discoverValuesForVNodeData = (vnodeData, discoveredValues) => {
28746
28845
  for (const value of vnodeData) {
28747
28846
  if (isSsrAttrs(value)) {
28748
28847
  for (let i = 1; i < value.length; i += 2) {
28749
- if (value[i - 1] === ELEMENT_KEY) {
28848
+ const attrValue = value[i];
28849
+ if (typeof attrValue === "string") {
28750
28850
  continue;
28751
28851
  }
28752
- const attrValue = value[i];
28753
28852
  discoveredValues.push(attrValue);
28754
28853
  }
28755
28854
  }
28756
28855
  }
28757
28856
  };
28857
+ var discoverEffectBackRefs = (effectsBackRefs, discoveredValues) => {
28858
+ if (effectsBackRefs) {
28859
+ let hasBackRefs = false;
28860
+ for (const [, effect] of effectsBackRefs) {
28861
+ const backRefs = effect[2 /* BACK_REF */];
28862
+ if (backRefs) {
28863
+ hasBackRefs = true;
28864
+ break;
28865
+ }
28866
+ }
28867
+ if (hasBackRefs) {
28868
+ discoveredValues.push(effectsBackRefs);
28869
+ }
28870
+ }
28871
+ };
28758
28872
  var promiseResults = /* @__PURE__ */ new WeakMap();
28759
28873
  function serialize(serializationContext) {
28760
28874
  const { $writer$, $isSsrNode$, $isDomRef$, $setProp$, $storeProxyMap$ } = serializationContext;
@@ -28803,10 +28917,10 @@ function serialize(serializationContext) {
28803
28917
  output(1 /* Constant */, value ? 2 /* True */ : 3 /* False */);
28804
28918
  } else if (typeof value === "function") {
28805
28919
  if (value === Slot) {
28806
- output(1 /* Constant */, 8 /* Slot */);
28920
+ output(1 /* Constant */, 9 /* Slot */);
28807
28921
  } else if (value === Fragment) {
28808
- output(1 /* Constant */, 9 /* Fragment */);
28809
- } else if (isQrl2(value)) {
28922
+ output(1 /* Constant */, 10 /* Fragment */);
28923
+ } else if (isQrl(value)) {
28810
28924
  const qrl2 = qrlToString(serializationContext, value);
28811
28925
  const id = serializationContext.$addRoot$(qrl2);
28812
28926
  output(18 /* QRL */, id);
@@ -28820,18 +28934,18 @@ function serialize(serializationContext) {
28820
28934
  }
28821
28935
  } else if (typeof value === "number") {
28822
28936
  if (Number.isNaN(value)) {
28823
- output(1 /* Constant */, 10 /* NaN */);
28937
+ output(1 /* Constant */, 11 /* NaN */);
28824
28938
  } else if (!Number.isFinite(value)) {
28825
28939
  output(
28826
28940
  1 /* Constant */,
28827
- value < 0 ? 12 /* NegativeInfinity */ : 11 /* PositiveInfinity */
28941
+ value < 0 ? 13 /* NegativeInfinity */ : 12 /* PositiveInfinity */
28828
28942
  );
28829
28943
  } else if (value === Number.MAX_SAFE_INTEGER) {
28830
- output(1 /* Constant */, 13 /* MaxSafeInt */);
28944
+ output(1 /* Constant */, 14 /* MaxSafeInt */);
28831
28945
  } else if (value === Number.MAX_SAFE_INTEGER - 1) {
28832
- output(1 /* Constant */, 14 /* AlmostMaxSafeInt */);
28946
+ output(1 /* Constant */, 15 /* AlmostMaxSafeInt */);
28833
28947
  } else if (value === Number.MIN_SAFE_INTEGER) {
28834
- output(1 /* Constant */, 15 /* MinSafeInt */);
28948
+ output(1 /* Constant */, 16 /* MinSafeInt */);
28835
28949
  } else {
28836
28950
  output(2 /* Number */, value);
28837
28951
  }
@@ -28864,6 +28978,8 @@ function serialize(serializationContext) {
28864
28978
  output(1 /* Constant */, 0 /* Undefined */);
28865
28979
  } else if (value === NEEDS_COMPUTATION) {
28866
28980
  output(1 /* Constant */, 7 /* NEEDS_COMPUTATION */);
28981
+ } else if (value === STORE_ARRAY_PROP) {
28982
+ output(1 /* Constant */, 8 /* STORE_ARRAY_PROP */);
28867
28983
  } else {
28868
28984
  throw qError(37 /* serializeErrorUnknownType */, [typeof value]);
28869
28985
  }
@@ -28883,7 +28999,7 @@ function serialize(serializationContext) {
28883
28999
  const constProps = value[_CONST_PROPS];
28884
29000
  const out = constProps ? [varProps, constProps] : Object.keys(varProps).length ? [varProps] : 0;
28885
29001
  output(29 /* PropsProxy */, out);
28886
- } else if (value instanceof EffectPropData) {
29002
+ } else if (value instanceof SubscriptionData) {
28887
29003
  output(30 /* EffectData */, [value.data.$scopedStyleIdPrefix$, value.data.$isConst$]);
28888
29004
  } else if (isStore(value)) {
28889
29005
  if (isResource(value)) {
@@ -28898,7 +29014,6 @@ function serialize(serializationContext) {
28898
29014
  const storeTarget = getStoreTarget(value);
28899
29015
  const flags = storeHandler.$flags$;
28900
29016
  const effects = storeHandler.$effects$;
28901
- const storeEffect = (effects == null ? void 0 : effects[STORE_ARRAY_PROP]) ?? null;
28902
29017
  const innerStores = [];
28903
29018
  for (const prop in storeTarget) {
28904
29019
  const propValue = storeTarget[prop];
@@ -28908,7 +29023,7 @@ function serialize(serializationContext) {
28908
29023
  serializationContext.$addRoot$(innerStore);
28909
29024
  }
28910
29025
  }
28911
- const out = [storeTarget, flags, effects, storeEffect, ...innerStores];
29026
+ const out = [storeTarget, flags, effects, ...innerStores];
28912
29027
  while (out[out.length - 1] == null) {
28913
29028
  out.pop();
28914
29029
  }
@@ -28934,7 +29049,7 @@ function serialize(serializationContext) {
28934
29049
  if (value instanceof WrappedSignal) {
28935
29050
  output(23 /* WrappedSignal */, [
28936
29051
  ...serializeWrappingFn(serializationContext, value),
28937
- value.$effectDependencies$,
29052
+ filterEffectBackRefs(value[_EFFECT_BACK_REF]),
28938
29053
  v,
28939
29054
  value.$hostElement$,
28940
29055
  ...value.$effects$ || []
@@ -28964,7 +29079,7 @@ function serialize(serializationContext) {
28964
29079
  if (extraProps.length) {
28965
29080
  out.push(extraProps);
28966
29081
  }
28967
- if (isDev) {
29082
+ if (isDev2) {
28968
29083
  out.push(value.stack);
28969
29084
  }
28970
29085
  output(12 /* Error */, out);
@@ -29021,7 +29136,7 @@ function serialize(serializationContext) {
29021
29136
  value.$flags$,
29022
29137
  value.$index$,
29023
29138
  value.$el$,
29024
- value.$effectDependencies$,
29139
+ value[_EFFECT_BACK_REF],
29025
29140
  value.$state$
29026
29141
  ];
29027
29142
  while (out[out.length - 1] == null) {
@@ -29041,12 +29156,26 @@ function serialize(serializationContext) {
29041
29156
  }
29042
29157
  const out = btoa(buf).replace(/=+$/, "");
29043
29158
  output(17 /* Uint8Array */, out);
29159
+ } else if (vnode_isVNode(value)) {
29160
+ output(1 /* Constant */, 0 /* Undefined */);
29044
29161
  } else {
29045
29162
  throw qError(37 /* serializeErrorUnknownType */, [typeof value]);
29046
29163
  }
29047
29164
  };
29048
29165
  writeValue(serializationContext.$roots$, -1);
29049
29166
  }
29167
+ function filterEffectBackRefs(effectBackRef) {
29168
+ let effectBackRefToSerialize = null;
29169
+ if (effectBackRef) {
29170
+ for (const [effectProp, effect] of effectBackRef) {
29171
+ if (effect[2 /* BACK_REF */]) {
29172
+ effectBackRefToSerialize ||= /* @__PURE__ */ new Map();
29173
+ effectBackRefToSerialize.set(effectProp, effect);
29174
+ }
29175
+ }
29176
+ }
29177
+ return effectBackRefToSerialize;
29178
+ }
29050
29179
  function serializeWrappingFn(serializationContext, value) {
29051
29180
  if (value.$funcStr$ && value.$funcStr$[0] === "{") {
29052
29181
  value.$funcStr$ = `(${value.$funcStr$})`;
@@ -29062,15 +29191,12 @@ function qrlToString(serializationContext, value) {
29062
29191
  var _a;
29063
29192
  let symbol = value.$symbol$;
29064
29193
  let chunk = value.$chunk$;
29065
- const refSymbol = value.$refSymbol$ ?? symbol;
29066
29194
  const platform = getPlatform();
29067
29195
  if (platform) {
29068
- const result = platform.chunkForSymbol(refSymbol, chunk, (_a = value.dev) == null ? void 0 : _a.file);
29196
+ const result = platform.chunkForSymbol(symbol, chunk, (_a = value.dev) == null ? void 0 : _a.file);
29069
29197
  if (result) {
29070
29198
  chunk = result[1];
29071
- if (!value.$refSymbol$) {
29072
- symbol = result[0];
29073
- }
29199
+ symbol = result[0];
29074
29200
  }
29075
29201
  }
29076
29202
  const isSync = isSyncQrl(value);
@@ -29078,7 +29204,7 @@ function qrlToString(serializationContext, value) {
29078
29204
  if (!chunk) {
29079
29205
  chunk = serializationContext.$symbolToChunkResolver$(value.$hash$);
29080
29206
  }
29081
- if (isDev) {
29207
+ if (isDev2) {
29082
29208
  let backChannel = globalThis[QRL_RUNTIME_CHUNK];
29083
29209
  if (!backChannel) {
29084
29210
  backChannel = globalThis[QRL_RUNTIME_CHUNK] = /* @__PURE__ */ new Map();
@@ -29144,26 +29270,33 @@ function isResource(value) {
29144
29270
  return "__brand" in value && value.__brand === "resource";
29145
29271
  }
29146
29272
  var frameworkType = (obj) => {
29147
- return typeof obj === "object" && obj !== null && (obj instanceof Signal || obj instanceof Task || isJSXNode(obj)) || isQrl2(obj);
29273
+ return typeof obj === "object" && obj !== null && (obj instanceof Signal || obj instanceof Task || isJSXNode(obj)) || isQrl(obj);
29148
29274
  };
29149
- var canSerialize = (value) => {
29275
+ var canSerialize = (value, seen = /* @__PURE__ */ new WeakSet()) => {
29150
29276
  if (value == null || typeof value === "string" || typeof value === "number" || typeof value === "boolean" || typeof value === "bigint") {
29151
29277
  return true;
29152
29278
  } else if (typeof value === "object") {
29279
+ if (seen.has(value)) {
29280
+ return true;
29281
+ }
29282
+ seen.add(value);
29153
29283
  const proto = Object.getPrototypeOf(value);
29154
29284
  if (isStore(value)) {
29155
29285
  value = getStoreTarget(value);
29156
29286
  }
29157
29287
  if (proto == Object.prototype) {
29158
29288
  for (const key in value) {
29159
- if (!canSerialize(untrack(() => value[key]))) {
29289
+ if (!canSerialize(
29290
+ untrack(() => value[key]),
29291
+ seen
29292
+ )) {
29160
29293
  return false;
29161
29294
  }
29162
29295
  }
29163
29296
  return true;
29164
29297
  } else if (proto == Array.prototype) {
29165
29298
  for (let i = 0; i < value.length; i++) {
29166
- if (!canSerialize(value[i])) {
29299
+ if (!canSerialize(value[i], seen)) {
29167
29300
  return false;
29168
29301
  }
29169
29302
  }
@@ -29198,7 +29331,7 @@ var canSerialize = (value) => {
29198
29331
  return true;
29199
29332
  }
29200
29333
  } else if (typeof value === "function") {
29201
- if (isQrl2(value) || isQwikComponent(value)) {
29334
+ if (isQrl(value) || isQwikComponent(value)) {
29202
29335
  return true;
29203
29336
  }
29204
29337
  }
@@ -29316,7 +29449,7 @@ var constantToName = (code2) => {
29316
29449
 
29317
29450
  // packages/qwik/src/core/shared/utils/serialize-utils.ts
29318
29451
  var verifySerializable = (value, preMessage) => {
29319
- const seen = /* @__PURE__ */ new Set();
29452
+ const seen = /* @__PURE__ */ new WeakSet();
29320
29453
  return _verifySerializable(value, seen, "_", preMessage);
29321
29454
  };
29322
29455
  var _verifySerializable = (value, seen, ctx, preMessage) => {
@@ -29325,10 +29458,12 @@ var _verifySerializable = (value, seen, ctx, preMessage) => {
29325
29458
  return value;
29326
29459
  }
29327
29460
  if (shouldSerialize(unwrapped)) {
29328
- if (seen.has(unwrapped)) {
29329
- return value;
29461
+ if (typeof unwrapped === "object") {
29462
+ if (seen.has(unwrapped)) {
29463
+ return value;
29464
+ }
29465
+ seen.add(unwrapped);
29330
29466
  }
29331
- seen.add(unwrapped);
29332
29467
  if (isSignal(unwrapped)) {
29333
29468
  return value;
29334
29469
  }
@@ -29410,14 +29545,7 @@ var noSerialize = (input) => {
29410
29545
  };
29411
29546
 
29412
29547
  // packages/qwik/src/core/shared/qrl/qrl-class.ts
29413
- var isQrl2 = (value) => {
29414
- return typeof value === "function" && typeof value.getSymbol === "function";
29415
- };
29416
- var SYNC_QRL = "<sync>";
29417
- var isSyncQrl = (value) => {
29418
- return isQrl2(value) && value.$symbol$ == SYNC_QRL;
29419
- };
29420
- var createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef, refSymbol) => {
29548
+ var createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef) => {
29421
29549
  if (qDev && qSerialize) {
29422
29550
  if (captureRef) {
29423
29551
  for (const item of captureRef) {
@@ -29438,9 +29566,14 @@ var createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef, refSym
29438
29566
  return _containerEl;
29439
29567
  };
29440
29568
  function bindFnToContext(currentCtx, beforeFn) {
29441
- return (...args) => maybeThen(resolveLazy(), (fn) => {
29442
- if (!isFunction(fn)) {
29443
- throw qError(10 /* qrlIsNotFunction */);
29569
+ const bound = (...args) => {
29570
+ if (!qrl2.resolved) {
29571
+ return qrl2.resolve().then((fn) => {
29572
+ if (!isFunction(fn)) {
29573
+ throw qError(10 /* qrlIsNotFunction */);
29574
+ }
29575
+ return bound(...args);
29576
+ });
29444
29577
  }
29445
29578
  if (beforeFn && beforeFn() === false) {
29446
29579
  return;
@@ -29451,12 +29584,13 @@ var createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef, refSym
29451
29584
  context.$qrl$ = qrl2;
29452
29585
  context.$event$ ||= this;
29453
29586
  try {
29454
- return invoke.call(this, context, fn, ...args);
29587
+ return invoke.call(this, context, symbolRef, ...args);
29455
29588
  } finally {
29456
29589
  context.$qrl$ = prevQrl;
29457
29590
  context.$event$ = prevEvent;
29458
29591
  }
29459
- });
29592
+ };
29593
+ return bound;
29460
29594
  }
29461
29595
  const resolveLazy = (containerEl) => {
29462
29596
  return symbolRef !== null ? symbolRef : resolve(containerEl);
@@ -29466,9 +29600,19 @@ var createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef, refSym
29466
29600
  return fn;
29467
29601
  }
29468
29602
  return function(...args) {
29603
+ var _a;
29469
29604
  let context = tryGetInvokeContext();
29470
29605
  if (context) {
29471
- return fn.apply(this, args);
29606
+ if (((_a = context.$qrl$) == null ? void 0 : _a.$symbol$) === qrl2.$symbol$) {
29607
+ return fn.apply(this, args);
29608
+ }
29609
+ const prevQrl = context.$qrl$;
29610
+ context.$qrl$ = qrl2;
29611
+ try {
29612
+ return fn.apply(this, args);
29613
+ } finally {
29614
+ context.$qrl$ = prevQrl;
29615
+ }
29472
29616
  }
29473
29617
  context = newInvokeContext();
29474
29618
  context.$qrl$ = qrl2;
@@ -29493,10 +29637,12 @@ var createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef, refSym
29493
29637
  const start = now();
29494
29638
  const ctx = tryGetInvokeContext();
29495
29639
  if (symbolFn !== null) {
29496
- symbolRef = symbolFn().then((module2) => qrl2.resolved = symbolRef = wrapFn(module2[symbol]));
29640
+ symbolRef = symbolFn().then(
29641
+ (module2) => qrl2.resolved = wrapFn(symbolRef = module2[symbol])
29642
+ );
29497
29643
  } else {
29498
29644
  const imported = getPlatform().importSymbol(_containerEl, chunk, symbol);
29499
- symbolRef = maybeThen(imported, (ref) => qrl2.resolved = symbolRef = wrapFn(ref));
29645
+ symbolRef = maybeThen(imported, (ref) => qrl2.resolved = wrapFn(symbolRef = ref));
29500
29646
  }
29501
29647
  if (typeof symbolRef === "object" && isPromise(symbolRef)) {
29502
29648
  symbolRef.then(
@@ -29519,10 +29665,9 @@ var createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef, refSym
29519
29665
  return invoke2;
29520
29666
  }
29521
29667
  };
29522
- const resolvedSymbol = refSymbol ?? symbol;
29523
- const hash3 = getSymbolHash(resolvedSymbol);
29668
+ const hash3 = getSymbolHash(symbol);
29524
29669
  Object.assign(qrl2, {
29525
- getSymbol: () => resolvedSymbol,
29670
+ getSymbol: () => symbol,
29526
29671
  getHash: () => hash3,
29527
29672
  getCaptured: () => captureRef,
29528
29673
  resolve,
@@ -29530,7 +29675,6 @@ var createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef, refSym
29530
29675
  $setContainer$: setContainer,
29531
29676
  $chunk$: chunk,
29532
29677
  $symbol$: symbol,
29533
- $refSymbol$: refSymbol,
29534
29678
  $hash$: hash3,
29535
29679
  getFn: bindFnToContext,
29536
29680
  $capture$: capture,
@@ -29539,9 +29683,9 @@ var createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef, refSym
29539
29683
  resolved: void 0
29540
29684
  });
29541
29685
  if (symbolRef) {
29542
- symbolRef = maybeThen(symbolRef, (resolved) => qrl2.resolved = symbolRef = wrapFn(resolved));
29686
+ symbolRef = maybeThen(symbolRef, (resolved) => qrl2.resolved = wrapFn(symbolRef = resolved));
29543
29687
  }
29544
- if (import_build8.isDev) {
29688
+ if (import_build10.isDev) {
29545
29689
  Object.defineProperty(qrl2, "_devOnlySymbolRef", {
29546
29690
  get() {
29547
29691
  return symbolRef;
@@ -29553,20 +29697,6 @@ var createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef, refSym
29553
29697
  }
29554
29698
  return qrl2;
29555
29699
  };
29556
- var getSymbolHash = (symbolName) => {
29557
- const index = symbolName.lastIndexOf("_");
29558
- if (index > -1) {
29559
- return symbolName.slice(index + 1);
29560
- }
29561
- return symbolName;
29562
- };
29563
- function assertQrl(qrl2) {
29564
- if (qDev) {
29565
- if (!isQrl2(qrl2)) {
29566
- throw new Error("Not a QRL");
29567
- }
29568
- }
29569
- }
29570
29700
  var EMITTED = /* @__PURE__ */ new Set();
29571
29701
  var emitUsedSymbol = (symbol, element, reqTime) => {
29572
29702
  if (!EMITTED.has(symbol)) {
@@ -29606,7 +29736,7 @@ var $ = (expression) => {
29606
29736
  "Optimizer should replace all usages of $() with some special syntax. If you need to create a QRL manually, use inlinedQrl() instead."
29607
29737
  );
29608
29738
  }
29609
- return createQRL(null, "s" + runtimeSymbolId++, expression, null, null, null, null);
29739
+ return createQRL(null, "s" + runtimeSymbolId++, expression, null, null, null);
29610
29740
  };
29611
29741
  var dollar = $;
29612
29742
  var eventQrl = (qrl2) => {
@@ -29633,9 +29763,6 @@ var isQwikComponent = (component) => {
29633
29763
  return typeof component == "function" && component[SERIALIZABLE_STATE] !== void 0;
29634
29764
  };
29635
29765
 
29636
- // packages/qwik/src/core/index.ts
29637
- var import_build10 = require("@qwik.dev/core/build");
29638
-
29639
29766
  // packages/qwik/src/core/shared/qrl/qrl.public.dollar.ts
29640
29767
  var event$ = implicit$FirstArg(eventQrl);
29641
29768
 
@@ -29822,9 +29949,6 @@ var useComputedQrl = (qrl2) => {
29822
29949
  // packages/qwik/src/core/use/use-computed-dollar.ts
29823
29950
  var useComputed$ = implicit$FirstArg(useComputedQrl);
29824
29951
 
29825
- // packages/qwik/src/core/shared/prefetch-service-worker/prefetch.ts
29826
- var import_build9 = require("@qwik.dev/core/build");
29827
-
29828
29952
  // packages/qwik/src/testing/vdom-diff.unit-util.ts
29829
29953
  var import_vitest = require("vitest");
29830
29954
  var import_prettier = require("prettier");
@@ -29937,7 +30061,7 @@ import_vitest.expect.extend({
29937
30061
  };
29938
30062
  }
29939
30063
  });
29940
- var ignoredAttributes = [QSubscribers, ELEMENT_ID, "", Q_PROPS_SEPARATOR];
30064
+ var ignoredAttributes = [QBackRefs, ELEMENT_ID, "", Q_PROPS_SEPARATOR];
29941
30065
  function getContainerElement(vNode) {
29942
30066
  let maybeParent;
29943
30067
  do {
@@ -30366,7 +30490,6 @@ function attrsEqual(expectedValue, receivedValue) {
30366
30490
  }
30367
30491
 
30368
30492
  // packages/qwik/src/testing/element-fixture.ts
30369
- var import_vitest2 = require("vitest");
30370
30493
  var import_core2 = require("../core.cjs");
30371
30494
 
30372
30495
  // packages/qwik/src/testing/platform.ts
@@ -30544,7 +30667,6 @@ var dispatch = async (element, attrName, event, scope) => {
30544
30667
  const isDocumentOrWindow = isDocumentOrWindowEvent(event.type);
30545
30668
  const preventAttributeName = PREVENT_DEFAULT + (isDocumentOrWindow ? event.type.substring(1) : event.type);
30546
30669
  const stopPropagationName = STOP_PROPAGATION + event.type;
30547
- const collectListeners = [];
30548
30670
  while (element) {
30549
30671
  const preventDefault = element.hasAttribute(preventAttributeName);
30550
30672
  const stopPropagation = element.hasAttribute(stopPropagationName);
@@ -30561,15 +30683,21 @@ var dispatch = async (element, attrName, event, scope) => {
30561
30683
  } else if (element.hasAttribute(attrName)) {
30562
30684
  const container = (0, import_core2.getDomContainer)(element);
30563
30685
  const qrl2 = element.getAttribute(attrName);
30564
- qrl2.split("\n").map((qrl3) => container.parseQRL(qrl3.trim())).map((qrl3) => qrl3(event, element));
30686
+ const ctx = newInvokeContextFromTuple([element, event]);
30687
+ try {
30688
+ await Promise.all(
30689
+ qrl2.split("\n").map((qrl3) => container.parseQRL(qrl3.trim())).map((qrl3) => {
30690
+ return invokeApply(ctx, qrl3, [event, element]);
30691
+ })
30692
+ );
30693
+ } catch (error) {
30694
+ console.error("!!! qrl error", qrl2, error);
30695
+ throw error;
30696
+ }
30565
30697
  return;
30566
30698
  }
30567
30699
  element = element.parentElement;
30568
30700
  }
30569
- for (let i = 0; i < collectListeners.length; i++) {
30570
- const { element: element2, qrl: qrl2 } = collectListeners[i];
30571
- await qrl2.getFn([element2, event], () => element2.isConnected)(event, element2);
30572
- }
30573
30701
  };
30574
30702
 
30575
30703
  // packages/qwik/src/testing/library.ts
@@ -30596,20 +30724,34 @@ var getQwik = async () => {
30596
30724
  };
30597
30725
 
30598
30726
  // packages/qwik/src/testing/expect-dom.tsx
30599
- var import_vitest3 = require("vitest");
30727
+ var import_vitest2 = require("vitest");
30600
30728
  var import_prettier2 = require("prettier");
30601
30729
  async function expectDOM(actual, expected) {
30602
30730
  const options = { parser: "html", htmlWhitespaceSensitivity: "ignore" };
30603
- import_vitest3.assert.equal(await (0, import_prettier2.format)(actual.outerHTML, options), await (0, import_prettier2.format)(expected, options));
30731
+ import_vitest2.assert.equal(await (0, import_prettier2.format)(actual.outerHTML, options), await (0, import_prettier2.format)(expected, options));
30604
30732
  }
30605
30733
 
30606
30734
  // packages/qwik/src/testing/rendering.unit-util.tsx
30607
30735
  var import_core8 = require("../core.cjs");
30608
- var import_vitest4 = require("vitest");
30736
+ var import_vitest3 = require("vitest");
30609
30737
 
30610
30738
  // packages/qwik/src/server/platform.ts
30611
30739
  var import_core3 = require("../core.cjs");
30612
- var SYNC_QRL2 = "<sync>";
30740
+
30741
+ // packages/qwik/src/optimizer/src/versions.ts
30742
+ var versions2 = {
30743
+ qwik: globalThis.QWIK_VERSION
30744
+ };
30745
+
30746
+ // packages/qwik/src/optimizer/src/manifest.ts
30747
+ function getValidManifest(manifest) {
30748
+ if (manifest != null && manifest.mapping != null && typeof manifest.mapping === "object" && manifest.symbols != null && typeof manifest.symbols === "object" && manifest.bundles != null && typeof manifest.bundles === "object") {
30749
+ return manifest;
30750
+ }
30751
+ return void 0;
30752
+ }
30753
+
30754
+ // packages/qwik/src/server/platform.ts
30613
30755
  function createPlatform3(opts, resolvedManifest) {
30614
30756
  const mapper = resolvedManifest == null ? void 0 : resolvedManifest.mapper;
30615
30757
  const mapperFn = opts.symbolMapper ? opts.symbolMapper : (symbolName, _chunk, parent) => {
@@ -30618,7 +30760,7 @@ function createPlatform3(opts, resolvedManifest) {
30618
30760
  const hash3 = getSymbolHash2(symbolName);
30619
30761
  const result = mapper[hash3];
30620
30762
  if (!result) {
30621
- if (hash3 === SYNC_QRL2) {
30763
+ if (hash3 === SYNC_QRL) {
30622
30764
  return [hash3, ""];
30623
30765
  }
30624
30766
  const isRegistered = (_a = globalThis.__qwik_reg_symbols) == null ? void 0 : _a.has(hash3);
@@ -30681,19 +30823,6 @@ var getSymbolHash2 = (symbolName) => {
30681
30823
  return symbolName;
30682
30824
  };
30683
30825
 
30684
- // packages/qwik/src/optimizer/src/versions.ts
30685
- var versions2 = {
30686
- qwik: globalThis.QWIK_VERSION
30687
- };
30688
-
30689
- // packages/qwik/src/optimizer/src/manifest.ts
30690
- function getValidManifest(manifest) {
30691
- if (manifest != null && manifest.mapping != null && typeof manifest.mapping === "object" && manifest.symbols != null && typeof manifest.symbols === "object" && manifest.bundles != null && typeof manifest.bundles === "object") {
30692
- return manifest;
30693
- }
30694
- return void 0;
30695
- }
30696
-
30697
30826
  // packages/qwik/src/server/ssr-container.ts
30698
30827
  var import_core6 = require("../core.cjs");
30699
30828
  var import_build12 = require("@qwik.dev/core/build");
@@ -30714,7 +30843,8 @@ function prefetchUrlsEventScript(base, prefetchResources) {
30714
30843
  bundles: flattenPrefetchResources(prefetchResources).map((u) => u.split("/").pop())
30715
30844
  };
30716
30845
  const args = JSON.stringify(["prefetch", base, ...data.bundles]);
30717
- return `(window.qwikPrefetchSW||(window.qwikPrefetchSW=[])).push(${args});`;
30846
+ return `document.dispatchEvent(new CustomEvent("qprefetch",{detail:${JSON.stringify(data)}}));
30847
+ (window.qwikPrefetchSW||(window.qwikPrefetchSW=[])).push(${args});`;
30718
30848
  }
30719
30849
  function flattenPrefetchResources(prefetchResources) {
30720
30850
  const urls = [];
@@ -30905,6 +31035,9 @@ var SsrNode = class {
30905
31035
  locals = null;
30906
31036
  currentComponentNode;
30907
31037
  childrenVNodeData = null;
31038
+ get [import_core4._EFFECT_BACK_REF]() {
31039
+ return this.getProp(QBackRefs);
31040
+ }
30908
31041
  setProp(name, value) {
30909
31042
  if (this.attrs === import_core4._EMPTY_ARRAY) {
30910
31043
  this.attrs = [];
@@ -31483,7 +31616,13 @@ var SSRContainer = class extends import_core6._SharedContainer {
31483
31616
  $noMoreRoots$ = false;
31484
31617
  constructor(opts) {
31485
31618
  super(
31486
- () => null,
31619
+ () => {
31620
+ try {
31621
+ return this.$scheduler$(255 /* WAIT_FOR_ALL */);
31622
+ } catch (e) {
31623
+ this.handleError(e, null);
31624
+ }
31625
+ },
31487
31626
  () => null,
31488
31627
  opts.renderOptions.serverData ?? EMPTY_OBJ2,
31489
31628
  opts.locale
@@ -31509,15 +31648,14 @@ var SSRContainer = class extends import_core6._SharedContainer {
31509
31648
  this.renderOptions = opts.renderOptions;
31510
31649
  this.$processInjectionsFromManifest$();
31511
31650
  }
31512
- ensureProjectionResolved(host) {
31651
+ ensureProjectionResolved(_host) {
31513
31652
  }
31514
- handleError(err, $host$) {
31653
+ handleError(err, _$host$) {
31515
31654
  throw err;
31516
31655
  }
31517
31656
  async render(jsx4) {
31518
31657
  this.openContainer();
31519
31658
  await (0, import_core6._walkJSX)(this, jsx4, {
31520
- allowPromises: true,
31521
31659
  currentStyleScoped: null,
31522
31660
  parentComponentFrame: this.getComponentFrame()
31523
31661
  });
@@ -31931,8 +32069,8 @@ var SSRContainer = class extends import_core6._SharedContainer {
31931
32069
  case ELEMENT_SEQ_IDX:
31932
32070
  write(VNodeDataChar.SEQ_IDX_CHAR);
31933
32071
  break;
31934
- case QSubscribers:
31935
- write(VNodeDataChar.SUBS_CHAR);
32072
+ case QBackRefs:
32073
+ write(VNodeDataChar.BACK_REFS_CHAR);
31936
32074
  break;
31937
32075
  // Skipping `\` character for now because it is used for escaping.
31938
32076
  case QCtxAttr:
@@ -32142,7 +32280,6 @@ var SSRContainer = class extends import_core6._SharedContainer {
32142
32280
  }
32143
32281
  ssrComponentNode == null ? void 0 : ssrComponentNode.setProp(value, lastNode.id);
32144
32282
  await (0, import_core6._walkJSX)(this, children, {
32145
- allowPromises: true,
32146
32283
  currentStyleScoped: scopedStyleId,
32147
32284
  parentComponentFrame: null
32148
32285
  });
@@ -32261,7 +32398,7 @@ var SSRContainer = class extends import_core6._SharedContainer {
32261
32398
  let styleScopedId = null;
32262
32399
  if (isSSRUnsafeAttr(key)) {
32263
32400
  if (import_build12.isDev) {
32264
- throw qError(50 /* unsafeAttr */);
32401
+ throw qError(49 /* unsafeAttr */);
32265
32402
  }
32266
32403
  continue;
32267
32404
  }
@@ -32278,6 +32415,8 @@ var SSRContainer = class extends import_core6._SharedContainer {
32278
32415
  } else if (typeof value === "function") {
32279
32416
  value(new DomRef(lastNode));
32280
32417
  continue;
32418
+ } else if (value == null) {
32419
+ continue;
32281
32420
  } else {
32282
32421
  throw qError(32 /* invalidRefValue */, [currentFile]);
32283
32422
  }
@@ -32601,7 +32740,7 @@ async function ssrRenderToDom(jsx4, opts = {}) {
32601
32740
  const platform = getPlatform();
32602
32741
  try {
32603
32742
  const jsxToRender = opts.raw ? jsx4 : [
32604
- /* @__PURE__ */ (0, import_core7.jsx)("head", { children: /* @__PURE__ */ (0, import_core7.jsx)("title", { children: import_vitest4.expect.getState().testPath }) }),
32743
+ /* @__PURE__ */ (0, import_core7.jsx)("head", { children: /* @__PURE__ */ (0, import_core7.jsx)("title", { children: import_vitest3.expect.getState().testPath }) }),
32605
32744
  /* @__PURE__ */ (0, import_core7.jsx)("body", { children: jsx4 })
32606
32745
  ];
32607
32746
  const result = await renderToString(jsxToRender);
@@ -32646,7 +32785,7 @@ async function ssrRenderToDom(jsx4, opts = {}) {
32646
32785
  let child = firstContainerChild;
32647
32786
  let insertBefore = null;
32648
32787
  while (child) {
32649
- if (vnode_isElementVNode(child) && (vnode_getElementName(child) === "script" && vnode_getAttr(child, "type") === "qwik/state" || vnode_getElementName(child) === "q:template")) {
32788
+ if (vnode_isElementVNode(child) && (vnode_getElementName(child) === "script" && (vnode_getAttr(child, "type") === "qwik/state" || vnode_getAttr(child, "id") === "qwikloader") || vnode_getElementName(child) === "q:template")) {
32650
32789
  insertBefore = child;
32651
32790
  break;
32652
32791
  }
@@ -32706,14 +32845,16 @@ function renderStyles(getStyles) {
32706
32845
  console.log(START2 + key + ": " + END2 + value);
32707
32846
  });
32708
32847
  }
32709
- async function rerenderComponent(element) {
32848
+ async function rerenderComponent(element, flush) {
32710
32849
  const container = (0, import_core8._getDomContainer)(element);
32711
32850
  const vElement = vnode_locate(container.rootVNode, element);
32712
32851
  const host = getHostVNode(vElement);
32713
32852
  const qrl2 = container.getHostProp(host, OnRenderProp);
32714
32853
  const props = container.getHostProp(host, ELEMENT_PROPS);
32715
- await container.$scheduler$(7 /* COMPONENT */, host, qrl2, props);
32716
- await getTestPlatform().flush();
32854
+ container.$scheduler$(6 /* COMPONENT */, host, qrl2, props);
32855
+ if (flush) {
32856
+ await getTestPlatform().flush();
32857
+ }
32717
32858
  }
32718
32859
  function getHostVNode(vElement) {
32719
32860
  while (vElement != null) {