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

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 +92 -78
  9. package/dist/core.cjs +1603 -1374
  10. package/dist/core.cjs.map +1 -1
  11. package/dist/core.min.mjs +1 -1
  12. package/dist/core.mjs +1600 -1374
  13. package/dist/core.mjs.map +1 -1
  14. package/dist/core.prod.cjs +963 -834
  15. package/dist/core.prod.mjs +1093 -927
  16. package/dist/insights/index.qwik.cjs +3679 -167
  17. package/dist/insights/index.qwik.mjs +3679 -167
  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 +228 -5715
  22. package/dist/optimizer.mjs +208 -6038
  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 +787 -7152
  27. package/dist/server.mjs +805 -7148
  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 +1341 -1180
  45. package/dist/testing/index.mjs +1354 -1186
  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.8-dev+66037b5
4
4
  * Copyright QwikDev. All Rights Reserved.
5
5
  * Use of this source code is governed by an MIT-style license that can be
6
6
  * found in the LICENSE file at https://github.com/QwikDev/qwik/blob/main/LICENSE
@@ -22151,7 +22151,7 @@ var seal = (obj) => {
22151
22151
  };
22152
22152
 
22153
22153
  // packages/qwik/src/core/shared/qrl/qrl-class.ts
22154
- import { isDev as isDev7 } from "@qwik.dev/core/build";
22154
+ import { isDev as isDev8 } from "@qwik.dev/core/build";
22155
22155
 
22156
22156
  // packages/qwik/src/core/shared/utils/log.ts
22157
22157
  var STYLE = qDev ? `background: #564CE0; color: white; padding: 2px 3px; border-radius: 2px; font-size: 0.8em;` : "";
@@ -22231,10 +22231,10 @@ var codeToText = (code2, ...parts) => {
22231
22231
  const MAP = [
22232
22232
  "Error while serializing class or style attributes",
22233
22233
  // 0
22234
- "",
22235
- // 1 unused
22236
- "",
22237
- // 2 unused
22234
+ "Scheduler not found",
22235
+ // 1
22236
+ "track() received object, without prop to track",
22237
+ // 2
22238
22238
  "Only primitive and object literals can be serialized. {{0}}",
22239
22239
  // 3
22240
22240
  "",
@@ -22321,17 +22321,15 @@ See https://qwik.dev/docs/components/tasks/#use-method-rules`,
22321
22321
  "Materialize error: missing element: {{0}} {{1}} {{2}}",
22322
22322
  // 44
22323
22323
  "Cannot coerce a Signal, use `.value` instead",
22324
- // 46
22324
+ // 45
22325
22325
  "useComputedSignal$ QRL {{0}} {{1}} returned a Promise",
22326
- // 47
22326
+ // 46
22327
22327
  "ComputedSignal is read-only",
22328
- // 48
22328
+ // 47
22329
22329
  "WrappedSignal is read-only",
22330
- // 49
22331
- "SsrError: Promises not expected here.",
22332
- // 50
22330
+ // 48
22333
22331
  "Attribute value is unsafe for SSR"
22334
- // 51
22332
+ // 49
22335
22333
  ];
22336
22334
  let text = MAP[code2] ?? "";
22337
22335
  if (parts.length) {
@@ -22356,6 +22354,30 @@ var qError = (code2, errorMessageArgs = []) => {
22356
22354
  // packages/qwik/src/core/shared/platform/platform.ts
22357
22355
  import { isServer } from "@qwik.dev/core/build";
22358
22356
 
22357
+ // packages/qwik/src/core/shared/qrl/qrl-utils.ts
22358
+ import { isDev } from "@qwik.dev/core/build";
22359
+ var SYNC_QRL = "<sync>";
22360
+ var isSyncQrl = (value) => {
22361
+ return isQrl(value) && value.$symbol$ == SYNC_QRL;
22362
+ };
22363
+ var isQrl = (value) => {
22364
+ return typeof value === "function" && typeof value.getSymbol === "function";
22365
+ };
22366
+ function assertQrl(qrl2) {
22367
+ if (isDev) {
22368
+ if (!isQrl(qrl2)) {
22369
+ throw new Error("Not a QRL");
22370
+ }
22371
+ }
22372
+ }
22373
+ var getSymbolHash = (symbolName) => {
22374
+ const index = symbolName.lastIndexOf("_");
22375
+ if (index > -1) {
22376
+ return symbolName.slice(index + 1);
22377
+ }
22378
+ return symbolName;
22379
+ };
22380
+
22359
22381
  // packages/qwik/src/core/shared/types.ts
22360
22382
  var DEBUG_TYPE = "q:type";
22361
22383
  var START = "\x1B[34m";
@@ -22400,10 +22422,9 @@ var VirtualTypeName = {
22400
22422
 
22401
22423
  // packages/qwik/src/core/shared/utils/markers.ts
22402
22424
  var OnRenderProp = "q:renderFn";
22403
- var ComponentStylesPrefixContent = "\u2B50\uFE0F";
22425
+ var ComponentStylesPrefixContent = "\u26A1\uFE0F";
22404
22426
  var QSlot = "q:slot";
22405
- var QSlotParent = ":";
22406
- var QSlotRef = "q:sref";
22427
+ var QSlotParent = "q:sparent";
22407
22428
  var QSlotS = "q:s";
22408
22429
  var QStyle = "q:style";
22409
22430
  var QStyleSelector = "style[q\\:style]";
@@ -22411,7 +22432,7 @@ var QStyleSSelector = "style[q\\:sstyle]";
22411
22432
  var QStylesAllSelector = QStyleSelector + "," + QStyleSSelector;
22412
22433
  var QScopedStyle = "q:sstyle";
22413
22434
  var QCtxAttr = "q:ctx";
22414
- var QSubscribers = "q:subs";
22435
+ var QBackRefs = "q:brefs";
22415
22436
  var QFuncsPrefix = "qFuncs_";
22416
22437
  var getQFuncs = (document2, hash3) => {
22417
22438
  return document2[QFuncsPrefix + hash3] || [];
@@ -22547,9 +22568,6 @@ var safeCall = (call, thenFn, rejectFn) => {
22547
22568
  var maybeThen = (valueOrPromise, thenFn) => {
22548
22569
  return isPromise(valueOrPromise) ? valueOrPromise.then(thenFn, shouldNotError) : thenFn(valueOrPromise);
22549
22570
  };
22550
- var maybeThenPassError = (valueOrPromise, thenFn) => {
22551
- return isPromise(valueOrPromise) ? valueOrPromise.then(thenFn) : thenFn(valueOrPromise);
22552
- };
22553
22571
  var shouldNotError = (reason) => {
22554
22572
  throwErrorAndStop(reason);
22555
22573
  };
@@ -22595,7 +22613,7 @@ var isFunction = (v) => {
22595
22613
  };
22596
22614
 
22597
22615
  // packages/qwik/src/build/index.dev.ts
22598
- var isDev = true;
22616
+ var isDev2 = true;
22599
22617
 
22600
22618
  // packages/qwik/src/core/use/use-locale.ts
22601
22619
  var _locale = void 0;
@@ -22604,7 +22622,7 @@ function setLocale(locale) {
22604
22622
  }
22605
22623
 
22606
22624
  // packages/qwik/src/core/client/vnode.ts
22607
- import { isDev as isDev6 } from "@qwik.dev/core/build";
22625
+ import { isDev as isDev7 } from "@qwik.dev/core/build";
22608
22626
 
22609
22627
  // packages/qwik/src/server/utils.ts
22610
22628
  function createTimer() {
@@ -22637,7 +22655,7 @@ var versions = {
22637
22655
  };
22638
22656
 
22639
22657
  // packages/qwik/src/server/prefetch-strategy.ts
22640
- import { isDev as isDev2 } from "@qwik.dev/core/build";
22658
+ import { isDev as isDev3 } from "@qwik.dev/core/build";
22641
22659
  function getPrefetchResources(qrls, opts, resolvedManifest) {
22642
22660
  if (!resolvedManifest) {
22643
22661
  return [];
@@ -22675,7 +22693,7 @@ function getAutoPrefetch(qrls, resolvedManifest, buildBase) {
22675
22693
  return prefetchResources;
22676
22694
  }
22677
22695
  function addBundle(manifest, urls, prefetchResources, buildBase, bundleFileName) {
22678
- const url = isDev2 ? bundleFileName : buildBase + bundleFileName;
22696
+ const url = isDev3 ? bundleFileName : buildBase + bundleFileName;
22679
22697
  let prefetchResource = urls.get(url);
22680
22698
  if (!prefetchResource) {
22681
22699
  prefetchResource = {
@@ -22694,7 +22712,7 @@ function addBundle(manifest, urls, prefetchResources, buildBase, bundleFileName)
22694
22712
  }
22695
22713
  prefetchResources.push(prefetchResource);
22696
22714
  }
22697
- var isQrl = (value) => {
22715
+ var isQrl2 = (value) => {
22698
22716
  return typeof value === "function" && typeof value.getSymbol === "function";
22699
22717
  };
22700
22718
 
@@ -22706,12 +22724,9 @@ Object.freeze(EMPTY_OBJ);
22706
22724
 
22707
22725
  // packages/qwik/src/core/shared/qrl/qrl.ts
22708
22726
  var inlinedQrl = (symbol, symbolName, lexicalScopeCapture = EMPTY_ARRAY) => {
22709
- return createQRL(null, symbolName, symbol, null, null, lexicalScopeCapture, null);
22727
+ return createQRL(null, symbolName, symbol, null, null, lexicalScopeCapture);
22710
22728
  };
22711
22729
 
22712
- // packages/qwik/src/core/ssr/ssr-render-jsx.ts
22713
- import { isDev as isDev5 } from "@qwik.dev/core/build";
22714
-
22715
22730
  // packages/qwik/src/core/shared/jsx/slot.public.ts
22716
22731
  var Slot = (props) => {
22717
22732
  return _jsxSorted(Virtual, null, { [QSlotS]: "" }, props.children, 0, props.name ?? "");
@@ -22798,6 +22813,49 @@ function isPreventDefault(key) {
22798
22813
  return key.startsWith("preventdefault:");
22799
22814
  }
22800
22815
 
22816
+ // packages/qwik/src/core/shared/utils/jsx-filename.ts
22817
+ function getFileLocationFromJsx(jsxDev) {
22818
+ if (!jsxDev) {
22819
+ return null;
22820
+ }
22821
+ const sanitizedFileName = jsxDev.fileName?.replace(/\\/g, "/");
22822
+ if (sanitizedFileName) {
22823
+ return `${sanitizedFileName}:${jsxDev.lineNumber}:${jsxDev.columnNumber}`;
22824
+ }
22825
+ return null;
22826
+ }
22827
+
22828
+ // packages/qwik/src/core/shared/utils/scoped-styles.ts
22829
+ var styleContent = (styleId) => {
22830
+ return ComponentStylesPrefixContent + styleId;
22831
+ };
22832
+ function hasClassAttr(props) {
22833
+ for (const key in props) {
22834
+ if (Object.prototype.hasOwnProperty.call(props, key) && isClassAttr(key)) {
22835
+ return true;
22836
+ }
22837
+ }
22838
+ return false;
22839
+ }
22840
+ function isClassAttr(key) {
22841
+ return key === "class" || key === "className";
22842
+ }
22843
+ function convertScopedStyleIdsToArray(scopedStyleIds) {
22844
+ return scopedStyleIds?.split(" ") ?? null;
22845
+ }
22846
+ function convertStyleIdsToString(scopedStyleIds) {
22847
+ return Array.from(scopedStyleIds).join(" ");
22848
+ }
22849
+ var addComponentStylePrefix = (styleId) => {
22850
+ if (styleId) {
22851
+ let idx = 0;
22852
+ do {
22853
+ styleId = styleId.substring(0, idx) + styleContent(styleId.substring(idx));
22854
+ } while ((idx = styleId.indexOf(" ", idx) + 1) !== 0);
22855
+ }
22856
+ return styleId || null;
22857
+ };
22858
+
22801
22859
  // packages/qwik/src/core/shared/utils/unitless_number.ts
22802
22860
  var unitlessNumbers = /* @__PURE__ */ new Set([
22803
22861
  "animationIterationCount",
@@ -22935,44 +22993,13 @@ var setValueForStyle = (styleName, value) => {
22935
22993
  function isAriaAttribute(prop) {
22936
22994
  return prop.startsWith("aria-");
22937
22995
  }
22938
- var styleContent = (styleId) => {
22939
- return ComponentStylesPrefixContent + styleId;
22940
- };
22941
-
22942
- // packages/qwik/src/core/shared/utils/scoped-styles.ts
22943
- function hasClassAttr(props) {
22944
- for (const key in props) {
22945
- if (Object.prototype.hasOwnProperty.call(props, key) && isClassAttr(key)) {
22946
- return true;
22947
- }
22948
- }
22949
- return false;
22950
- }
22951
- function isClassAttr(key) {
22952
- return key === "class" || key === "className";
22953
- }
22954
- function convertScopedStyleIdsToArray(scopedStyleIds) {
22955
- return scopedStyleIds?.split(" ") ?? null;
22956
- }
22957
- function convertStyleIdsToString(scopedStyleIds) {
22958
- return Array.from(scopedStyleIds).join(" ");
22959
- }
22960
- var addComponentStylePrefix = (styleId) => {
22961
- if (styleId) {
22962
- let idx = 0;
22963
- do {
22964
- styleId = styleId.substring(0, idx) + styleContent(styleId.substring(idx));
22965
- } while ((idx = styleId.indexOf(" ", idx) + 1) !== 0);
22966
- }
22967
- return styleId || null;
22968
- };
22969
22996
 
22970
22997
  // packages/qwik/src/core/signal/store.ts
22971
22998
  var DEBUG = false;
22972
22999
  var log = (...args) => console.log("STORE", ...args.map(qwikDebugToString));
22973
23000
  var STORE_TARGET = Symbol("store.target");
22974
23001
  var STORE_HANDLER = Symbol("store.handler");
22975
- var STORE_ARRAY_PROP = Symbol("store.array");
23002
+ var STORE_ALL_PROPS = Symbol("store.all");
22976
23003
  var getStoreHandler = (value) => {
22977
23004
  return value[STORE_HANDLER];
22978
23005
  };
@@ -23034,7 +23061,12 @@ var StoreHandler = class {
23034
23061
  }
23035
23062
  const effectSubscriber = ctx.$effectSubscriber$;
23036
23063
  if (effectSubscriber) {
23037
- addEffect(target, Array.isArray(target) ? STORE_ARRAY_PROP : prop, this, effectSubscriber);
23064
+ addStoreEffect(
23065
+ target,
23066
+ Array.isArray(target) ? STORE_ALL_PROPS : prop,
23067
+ this,
23068
+ effectSubscriber
23069
+ );
23038
23070
  }
23039
23071
  }
23040
23072
  if (prop === "toString" && value === Object.prototype.toString) {
@@ -23081,9 +23113,9 @@ var StoreHandler = class {
23081
23113
  if (ctx) {
23082
23114
  const effectSubscriber = ctx.$effectSubscriber$;
23083
23115
  if (effectSubscriber) {
23084
- addEffect(
23116
+ addStoreEffect(
23085
23117
  target,
23086
- Array.isArray(target) ? STORE_ARRAY_PROP : prop,
23118
+ Array.isArray(target) ? STORE_ALL_PROPS : prop,
23087
23119
  this,
23088
23120
  effectSubscriber
23089
23121
  );
@@ -23096,13 +23128,17 @@ var StoreHandler = class {
23096
23128
  const ctx = tryGetInvokeContext();
23097
23129
  const effectSubscriber = ctx?.$effectSubscriber$;
23098
23130
  if (effectSubscriber) {
23099
- addEffect(target, STORE_ARRAY_PROP, this, effectSubscriber);
23131
+ addStoreEffect(target, STORE_ALL_PROPS, this, effectSubscriber);
23100
23132
  }
23101
23133
  return Reflect.ownKeys(target);
23102
23134
  }
23103
23135
  getOwnPropertyDescriptor(target, prop) {
23136
+ const descriptor = Reflect.getOwnPropertyDescriptor(target, prop);
23104
23137
  if (Array.isArray(target) || typeof prop === "symbol") {
23105
- return Object.getOwnPropertyDescriptor(target, prop);
23138
+ return descriptor;
23139
+ }
23140
+ if (descriptor && !descriptor.configurable) {
23141
+ return descriptor;
23106
23142
  }
23107
23143
  return {
23108
23144
  enumerable: true,
@@ -23110,17 +23146,17 @@ var StoreHandler = class {
23110
23146
  };
23111
23147
  }
23112
23148
  };
23113
- function addEffect(target, prop, store, effectSubscriber) {
23114
- const effectsMap = store.$effects$ || (store.$effects$ = {});
23115
- const effects = Object.prototype.hasOwnProperty.call(effectsMap, prop) && effectsMap[prop] || (effectsMap[prop] = []);
23116
- ensureContainsEffect(effects, effectSubscriber);
23117
- ensureContains(effectSubscriber, target);
23118
- ensureEffectContainsSubscriber(
23119
- effectSubscriber[0 /* EFFECT */],
23120
- target,
23121
- store.$container$
23122
- );
23123
- DEBUG && log("sub", pad("\n" + store.$effects$.toString(), " "));
23149
+ function addStoreEffect(target, prop, store, effectSubscription) {
23150
+ const effectsMap = store.$effects$ || (store.$effects$ = /* @__PURE__ */ new Map());
23151
+ let effects = effectsMap.get(prop);
23152
+ if (!effects) {
23153
+ effects = /* @__PURE__ */ new Set();
23154
+ effectsMap.set(prop, effects);
23155
+ }
23156
+ ensureContainsSubscription(effects, effectSubscription);
23157
+ ensureContainsBackRef(effectSubscription, target);
23158
+ addQrlToSerializationCtx(effectSubscription, store.$container$);
23159
+ DEBUG && log("sub", pad("\n" + store.$effects$?.entries.toString(), " "));
23124
23160
  }
23125
23161
  function setNewValueAndTriggerEffects(prop, value, target, currentStore) {
23126
23162
  target[prop] = value;
@@ -23131,15 +23167,91 @@ function setNewValueAndTriggerEffects(prop, value, target, currentStore) {
23131
23167
  );
23132
23168
  }
23133
23169
  function getEffects(target, prop, storeEffects) {
23134
- let effectsToTrigger = storeEffects ? Array.isArray(target) ? Object.values(storeEffects).flatMap((effects) => effects) : storeEffects[prop] : null;
23135
- const storeArrayValue = storeEffects?.[STORE_ARRAY_PROP];
23170
+ let effectsToTrigger;
23171
+ if (storeEffects) {
23172
+ if (Array.isArray(target)) {
23173
+ for (const effects of storeEffects.values()) {
23174
+ effectsToTrigger || (effectsToTrigger = /* @__PURE__ */ new Set());
23175
+ for (const effect of effects) {
23176
+ effectsToTrigger.add(effect);
23177
+ }
23178
+ }
23179
+ } else {
23180
+ effectsToTrigger = storeEffects.get(prop);
23181
+ }
23182
+ }
23183
+ const storeArrayValue = storeEffects?.get(STORE_ALL_PROPS);
23136
23184
  if (storeArrayValue) {
23137
- effectsToTrigger || (effectsToTrigger = []);
23138
- effectsToTrigger.push(...storeArrayValue);
23185
+ effectsToTrigger || (effectsToTrigger = /* @__PURE__ */ new Set());
23186
+ for (const effect of storeArrayValue) {
23187
+ effectsToTrigger.add(effect);
23188
+ }
23189
+ }
23190
+ return effectsToTrigger || null;
23191
+ }
23192
+
23193
+ // packages/qwik/src/core/signal/flags.ts
23194
+ var NEEDS_COMPUTATION = Symbol("invalid");
23195
+ var _EFFECT_BACK_REF = Symbol("backRef");
23196
+
23197
+ // packages/qwik/src/core/signal/signal-cleanup.ts
23198
+ var _a;
23199
+ _a = _EFFECT_BACK_REF;
23200
+ var BackRef = class {
23201
+ constructor() {
23202
+ __publicField(this, _a, null);
23203
+ }
23204
+ };
23205
+ function clearAllEffects(container, consumer) {
23206
+ if (vnode_isVNode(consumer) && vnode_isElementVNode(consumer)) {
23207
+ ensureMaterialized(consumer);
23208
+ }
23209
+ const effects = consumer[_EFFECT_BACK_REF];
23210
+ if (!effects) {
23211
+ return;
23212
+ }
23213
+ for (const [, effect] of effects) {
23214
+ const backRefs = effect[2 /* BACK_REF */];
23215
+ if (!backRefs) {
23216
+ return;
23217
+ }
23218
+ for (const producer of backRefs) {
23219
+ if (producer instanceof Signal) {
23220
+ clearSignal(container, producer, effect);
23221
+ } else if (container.$storeProxyMap$.has(producer)) {
23222
+ const target = container.$storeProxyMap$.get(producer);
23223
+ const storeHandler = getStoreHandler(target);
23224
+ clearStore(storeHandler, effect);
23225
+ }
23226
+ }
23227
+ }
23228
+ }
23229
+ function clearSignal(container, producer, effect) {
23230
+ const effects = producer.$effects$;
23231
+ if (effects) {
23232
+ effects.delete(effect);
23233
+ }
23234
+ if (producer instanceof WrappedSignal) {
23235
+ producer.$hostElement$ = null;
23236
+ clearAllEffects(container, producer);
23237
+ }
23238
+ }
23239
+ function clearStore(producer, effect) {
23240
+ const effects = producer?.$effects$;
23241
+ if (effects) {
23242
+ for (const propEffects of effects.values()) {
23243
+ propEffects.delete(effect);
23244
+ }
23139
23245
  }
23140
- return effectsToTrigger;
23141
23246
  }
23142
23247
 
23248
+ // packages/qwik/src/core/shared/qrl/implicit_dollar.ts
23249
+ var implicit$FirstArg = (fn) => {
23250
+ return function(first, ...rest) {
23251
+ return fn.call(null, dollar(first), ...rest);
23252
+ };
23253
+ };
23254
+
23143
23255
  // packages/qwik/src/core/use/use-sequential-scope.ts
23144
23256
  var useSequentialScope = () => {
23145
23257
  const iCtx = useInvokeContext();
@@ -23172,173 +23284,41 @@ var useSequentialScope = () => {
23172
23284
  };
23173
23285
  };
23174
23286
 
23175
- // packages/qwik/src/core/signal/signal-subscriber.ts
23176
- var Subscriber = class {
23177
- constructor() {
23178
- __publicField(this, "$effectDependencies$", null);
23179
- }
23180
- };
23181
- function isSubscriber(value) {
23182
- return value instanceof Subscriber || value instanceof WrappedSignal;
23183
- }
23184
- function clearVNodeEffectDependencies(container, value) {
23185
- if (vnode_isElementVNode(value)) {
23186
- ensureMaterialized(value);
23187
- }
23188
- const effects = vnode_getProp(value, QSubscribers, container.$getObjectById$);
23189
- if (!effects) {
23190
- return;
23191
- }
23192
- for (let i = effects.length - 1; i >= 0; i--) {
23193
- const subscriber = effects[i];
23194
- clearEffects(subscriber, value, effects, i, container);
23195
- }
23196
- if (effects.length === 0) {
23197
- vnode_setProp(value, QSubscribers, null);
23198
- }
23199
- }
23200
- function clearSubscriberEffectDependencies(container, value) {
23201
- if (value.$effectDependencies$) {
23202
- for (let i = value.$effectDependencies$.length - 1; i >= 0; i--) {
23203
- const subscriber = value.$effectDependencies$[i];
23204
- clearEffects(subscriber, value, value.$effectDependencies$, i, container);
23205
- }
23206
- if (value.$effectDependencies$.length === 0) {
23207
- value.$effectDependencies$ = null;
23208
- }
23209
- }
23210
- }
23211
- function clearEffects(subscriber, value, effectArray, indexToRemove, container) {
23212
- let subscriptionRemoved = false;
23213
- const seenSet = /* @__PURE__ */ new Set();
23214
- if (subscriber instanceof WrappedSignal) {
23215
- subscriptionRemoved = clearSignalEffects(subscriber, value, seenSet);
23216
- } else if (container.$storeProxyMap$.has(subscriber)) {
23217
- const store = container.$storeProxyMap$.get(subscriber);
23218
- const handler = getStoreHandler(store);
23219
- subscriptionRemoved = clearStoreEffects(handler, value);
23220
- }
23221
- if (subscriptionRemoved) {
23222
- effectArray.splice(indexToRemove, 1);
23223
- }
23224
- }
23225
- function clearSignalEffects(subscriber, value, seenSet) {
23226
- const effectSubscriptions = subscriber.$effects$;
23227
- let subscriptionRemoved = false;
23228
- if (effectSubscriptions) {
23229
- for (let i = effectSubscriptions.length - 1; i >= 0; i--) {
23230
- const effect = effectSubscriptions[i];
23231
- if (effect[0 /* EFFECT */] === value) {
23232
- effectSubscriptions.splice(i, 1);
23233
- subscriptionRemoved = true;
23234
- }
23235
- }
23236
- }
23237
- if (subscriber instanceof WrappedSignal) {
23238
- const hostElement = subscriber.$hostElement$;
23239
- if (hostElement && hostElement === value) {
23240
- subscriber.$hostElement$ = null;
23241
- }
23242
- const args = subscriber.$args$;
23243
- if (args) {
23244
- clearArgsEffects(args, subscriber, seenSet);
23287
+ // packages/qwik/src/core/signal/subscriber.ts
23288
+ import { isServer as isServer3 } from "@qwik.dev/core/build";
23289
+ function getSubscriber(effect, prop, data) {
23290
+ if (!effect[_EFFECT_BACK_REF]) {
23291
+ if (isServer3 && isSsrNode(effect)) {
23292
+ effect.setProp(QBackRefs, /* @__PURE__ */ new Map());
23293
+ } else {
23294
+ effect[_EFFECT_BACK_REF] = /* @__PURE__ */ new Map();
23245
23295
  }
23246
23296
  }
23247
- return subscriptionRemoved;
23248
- }
23249
- function clearStoreEffects(storeHandler, value) {
23250
- const effectSubscriptions = storeHandler.$effects$;
23251
- if (!effectSubscriptions) {
23252
- return false;
23253
- }
23254
- let subscriptionRemoved = false;
23255
- for (const key in effectSubscriptions) {
23256
- const effects = effectSubscriptions[key];
23257
- for (let i = effects.length - 1; i >= 0; i--) {
23258
- const effect = effects[i];
23259
- if (effect[0 /* EFFECT */] === value) {
23260
- effects.splice(i, 1);
23261
- subscriptionRemoved = true;
23262
- }
23263
- }
23264
- if (effects.length === 0) {
23265
- delete effectSubscriptions[key];
23266
- }
23297
+ const subMap = effect[_EFFECT_BACK_REF];
23298
+ let sub = subMap.get(prop);
23299
+ if (!sub) {
23300
+ sub = [effect, prop];
23301
+ subMap.set(prop, sub);
23267
23302
  }
23268
- return subscriptionRemoved;
23269
- }
23270
- function clearArgsEffects(args, subscriber, seenSet) {
23271
- for (let i = args.length - 1; i >= 0; i--) {
23272
- const arg = args[i];
23273
- clearArgEffect(arg, subscriber, seenSet);
23303
+ if (data) {
23304
+ sub[3 /* DATA */] = data;
23274
23305
  }
23306
+ return sub;
23275
23307
  }
23276
- function clearArgEffect(arg, subscriber, seenSet) {
23277
- if (seenSet.has(arg)) {
23278
- return;
23279
- }
23280
- seenSet.add(arg);
23281
- if (isSignal(arg)) {
23282
- clearSignalEffects(arg, subscriber, seenSet);
23283
- } else if (typeof arg === "object" && arg !== null) {
23284
- if (isStore(arg)) {
23285
- clearStoreEffects(getStoreHandler(arg), subscriber);
23286
- } else if (isPropsProxy(arg)) {
23287
- const constProps = arg[_CONST_PROPS];
23288
- const varProps = arg[_VAR_PROPS];
23289
- if (constProps) {
23290
- for (const key in constProps) {
23291
- clearArgEffect(constProps[key], subscriber, seenSet);
23292
- }
23293
- }
23294
- for (const key in varProps) {
23295
- clearArgEffect(varProps[key], subscriber, seenSet);
23296
- }
23297
- } else {
23298
- for (const key in arg) {
23299
- clearArgEffect(arg[key], subscriber, seenSet);
23300
- }
23301
- }
23302
- } else if (Array.isArray(arg)) {
23303
- clearArgsEffects(arg, subscriber, seenSet);
23304
- } else {
23305
- }
23308
+ function isSsrNode(value) {
23309
+ return "__brand__" in value && "currentComponentNode" in value;
23306
23310
  }
23307
23311
 
23308
- // packages/qwik/src/core/use/use-resource.ts
23309
- var _createResourceReturn = (opts) => {
23310
- const resource = {
23311
- __brand: "resource",
23312
- value: void 0,
23313
- loading: isServerPlatform() ? false : true,
23314
- _resolved: void 0,
23315
- _error: void 0,
23316
- _state: "pending",
23317
- _timeout: opts?.timeout ?? -1,
23318
- _cache: 0
23319
- };
23320
- return resource;
23321
- };
23322
- var createResourceReturn = (container, opts, initialPromise) => {
23323
- const result = _createResourceReturn(opts);
23324
- result.value = initialPromise;
23325
- return createStore(container, result, 1 /* RECURSIVE */);
23326
- };
23327
- var runResource = (task, container, host) => {
23312
+ // packages/qwik/src/core/use/use-task.ts
23313
+ var runTask = (task, container, host) => {
23328
23314
  task.$flags$ &= ~8 /* DIRTY */;
23329
23315
  cleanupTask(task);
23330
- const iCtx = newInvokeContext(container.$locale$, host, void 0, ResourceEvent);
23316
+ const iCtx = newInvokeContext(container.$locale$, host, void 0, TaskEvent);
23331
23317
  iCtx.$container$ = container;
23332
- const taskFn = task.$qrl$.getFn(iCtx, () => clearSubscriberEffectDependencies(container, task));
23333
- const resource = task.$state$;
23334
- assertDefined(
23335
- resource,
23336
- 'useResource: when running a resource, "task.resource" must be a defined.',
23337
- task
23338
- );
23318
+ const taskFn = task.$qrl$.getFn(iCtx, () => clearAllEffects(container, task));
23339
23319
  const track = (obj, prop) => {
23340
23320
  const ctx = newInvokeContext();
23341
- ctx.$effectSubscriber$ = [task, ":" /* COMPONENT */];
23321
+ ctx.$effectSubscriber$ = getSubscriber(task, ":" /* COMPONENT */);
23342
23322
  ctx.$container$ = container;
23343
23323
  return invoke(ctx, () => {
23344
23324
  if (isFunction(obj)) {
@@ -23348,128 +23328,155 @@ var runResource = (task, container, host) => {
23348
23328
  return obj[prop];
23349
23329
  } else if (isSignal(obj)) {
23350
23330
  return obj.value;
23351
- } else {
23331
+ } else if (isStore(obj)) {
23332
+ addStoreEffect(
23333
+ getStoreTarget(obj),
23334
+ STORE_ALL_PROPS,
23335
+ getStoreHandler(obj),
23336
+ ctx.$effectSubscriber$
23337
+ );
23352
23338
  return obj;
23339
+ } else {
23340
+ throw qError(2 /* trackObjectWithoutProp */);
23353
23341
  }
23354
23342
  });
23355
23343
  };
23356
23344
  const handleError = (reason) => container.handleError(reason, host);
23357
- const cleanups = [];
23358
- task.$destroy$ = noSerialize(() => {
23359
- cleanups.forEach((fn) => {
23360
- try {
23361
- fn();
23362
- } catch (err) {
23363
- handleError(err);
23345
+ let cleanupFns = null;
23346
+ const cleanup2 = (fn) => {
23347
+ if (typeof fn == "function") {
23348
+ if (!cleanupFns) {
23349
+ cleanupFns = [];
23350
+ task.$destroy$ = noSerialize(() => {
23351
+ task.$destroy$ = null;
23352
+ cleanupFns.forEach((fn2) => {
23353
+ try {
23354
+ fn2();
23355
+ } catch (err) {
23356
+ handleError(err);
23357
+ }
23358
+ });
23359
+ });
23364
23360
  }
23365
- });
23366
- done = true;
23367
- });
23368
- const resourceTarget = unwrapStore(resource);
23369
- const opts = {
23370
- track,
23371
- cleanup(fn) {
23372
- if (typeof fn === "function") {
23373
- cleanups.push(fn);
23374
- }
23375
- },
23376
- cache(policy) {
23377
- let milliseconds = 0;
23378
- if (policy === "immutable") {
23379
- milliseconds = Infinity;
23380
- } else {
23381
- milliseconds = policy;
23382
- }
23383
- resource._cache = milliseconds;
23384
- },
23385
- previous: resourceTarget._resolved
23386
- };
23387
- let resolve;
23388
- let reject;
23389
- let done = false;
23390
- const setState = (resolved, value) => {
23391
- if (!done) {
23392
- done = true;
23393
- if (resolved) {
23394
- done = true;
23395
- resource.loading = false;
23396
- resource._state = "resolved";
23397
- resource._resolved = value;
23398
- resource._error = void 0;
23399
- resolve(value);
23400
- } else {
23401
- done = true;
23402
- resource.loading = false;
23403
- resource._state = "rejected";
23404
- resource._error = value;
23405
- reject(value);
23406
- }
23407
- return true;
23361
+ cleanupFns.push(fn);
23408
23362
  }
23409
- return false;
23410
23363
  };
23411
- cleanups.push(() => {
23412
- if (untrack(() => resource.loading) === true) {
23413
- const value = untrack(() => resource._resolved);
23414
- setState(true, value);
23415
- }
23416
- });
23417
- invoke(iCtx, () => {
23418
- resource._state = "pending";
23419
- resource.loading = !isServerPlatform();
23420
- const promise2 = resource.value = new Promise((r, re) => {
23421
- resolve = r;
23422
- reject = re;
23423
- });
23424
- promise2.catch(ignoreErrorToPreventNodeFromCrashing);
23425
- });
23426
- const promise = safeCall(
23427
- () => Promise.resolve(taskFn(opts)),
23428
- (value) => {
23429
- setState(true, value);
23430
- },
23364
+ const taskApi = { track, cleanup: cleanup2 };
23365
+ const result = safeCall(
23366
+ () => taskFn(taskApi),
23367
+ cleanup2,
23431
23368
  (err) => {
23432
23369
  if (isPromise(err)) {
23433
- return err.then(() => runResource(task, container, host));
23370
+ return err.then(() => runTask(task, container, host));
23434
23371
  } else {
23435
- setState(false, err);
23372
+ throw err;
23436
23373
  }
23437
23374
  }
23438
23375
  );
23439
- const timeout = resourceTarget._timeout;
23440
- if (timeout > 0) {
23441
- return Promise.race([
23442
- promise,
23443
- delay(timeout).then(() => {
23444
- if (setState(false, new Error("timeout"))) {
23445
- cleanupTask(task);
23446
- }
23447
- })
23448
- ]);
23376
+ return result;
23377
+ };
23378
+ var cleanupTask = (task) => {
23379
+ const destroy = task.$destroy$;
23380
+ if (destroy) {
23381
+ task.$destroy$ = null;
23382
+ try {
23383
+ destroy();
23384
+ } catch (err) {
23385
+ logError(err);
23386
+ }
23449
23387
  }
23450
- return promise;
23451
23388
  };
23452
- var ignoreErrorToPreventNodeFromCrashing = (err) => {
23389
+ var Task = class extends BackRef {
23390
+ constructor($flags$, $index$, $el$, $qrl$, $state$, $destroy$) {
23391
+ super();
23392
+ this.$flags$ = $flags$;
23393
+ this.$index$ = $index$;
23394
+ this.$el$ = $el$;
23395
+ this.$qrl$ = $qrl$;
23396
+ this.$state$ = $state$;
23397
+ this.$destroy$ = $destroy$;
23398
+ }
23399
+ };
23400
+ var isTask = (value) => {
23401
+ return value instanceof Task;
23453
23402
  };
23454
23403
 
23455
23404
  // packages/qwik/src/core/client/vnode-diff.ts
23456
- import { isDev as isDev4 } from "@qwik.dev/core/build";
23405
+ import { isDev as isDev6 } from "@qwik.dev/core/build";
23406
+
23407
+ // packages/qwik/src/core/client/util-mapArray.ts
23408
+ var mapApp_findIndx = (array, key, start) => {
23409
+ assertTrue(start % 2 === 0, "Expecting even number.");
23410
+ let bottom = start >> 1;
23411
+ let top = array.length - 2 >> 1;
23412
+ while (bottom <= top) {
23413
+ const mid = bottom + (top - bottom >> 1);
23414
+ const midKey = array[mid << 1];
23415
+ if (midKey === key) {
23416
+ return mid << 1;
23417
+ }
23418
+ if (midKey < key) {
23419
+ bottom = mid + 1;
23420
+ } else {
23421
+ top = mid - 1;
23422
+ }
23423
+ }
23424
+ return bottom << 1 ^ -1;
23425
+ };
23426
+ var mapArray_set = (array, key, value, start) => {
23427
+ const indx = mapApp_findIndx(array, key, start);
23428
+ if (indx >= 0) {
23429
+ if (value == null) {
23430
+ array.splice(indx, 2);
23431
+ } else {
23432
+ array[indx + 1] = value;
23433
+ }
23434
+ } else if (value != null) {
23435
+ array.splice(indx ^ -1, 0, key, value);
23436
+ }
23437
+ };
23438
+ var mapApp_remove = (array, key, start) => {
23439
+ const indx = mapApp_findIndx(array, key, start);
23440
+ let value = null;
23441
+ if (indx >= 0) {
23442
+ value = array[indx + 1];
23443
+ array.splice(indx, 2);
23444
+ return value;
23445
+ }
23446
+ return value;
23447
+ };
23448
+ var mapArray_get = (array, key, start) => {
23449
+ const indx = mapApp_findIndx(array, key, start);
23450
+ if (indx >= 0) {
23451
+ return array[indx + 1];
23452
+ } else {
23453
+ return null;
23454
+ }
23455
+ };
23456
+ var mapArray_has = (array, key, start) => {
23457
+ return mapApp_findIndx(array, key, start) >= 0;
23458
+ };
23457
23459
 
23458
23460
  // packages/qwik/src/core/client/vnode-namespace.ts
23459
- var isForeignObjectElement = (elementName) => elementName.toLowerCase() === "foreignobject";
23461
+ import { isDev as isDev4 } from "@qwik.dev/core/build";
23462
+ var isForeignObjectElement = (elementName) => {
23463
+ return isDev4 ? elementName.toLowerCase() === "foreignobject" : elementName === "foreignObject";
23464
+ };
23460
23465
  var isSvgElement = (elementName) => elementName === "svg" || isForeignObjectElement(elementName);
23461
23466
  var isMathElement = (elementName) => elementName === "math";
23462
23467
  var vnode_isDefaultNamespace = (vnode) => {
23463
23468
  const flags = vnode[0 /* flags */];
23464
23469
  return (flags & 192 /* NAMESPACE_MASK */) === 0;
23465
23470
  };
23466
- var vnode_getElementNamespaceFlags = (elementName) => {
23467
- if (isSvgElement(elementName)) {
23468
- return 64 /* NS_svg */;
23469
- } else if (isMathElement(elementName)) {
23470
- return 128 /* NS_math */;
23471
- } else {
23472
- return 0 /* NS_html */;
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 */;
23473
23480
  }
23474
23481
  };
23475
23482
  function vnode_getDomChildrenWithCorrectNamespacesToInsert(journal, domParentVNode, newChild) {
@@ -23625,21 +23632,28 @@ function getNewElementNamespaceData(domParentVNode, tagOrVNode) {
23625
23632
  }
23626
23633
 
23627
23634
  // packages/qwik/src/core/shared/component-execution.ts
23628
- import { isDev as isDev3 } from "@qwik.dev/core/build";
23635
+ import { isDev as isDev5 } from "@qwik.dev/core/build";
23629
23636
  var executeComponent = (container, renderHost, subscriptionHost, componentQRL, props) => {
23630
- const iCtx = newInvokeContext(container.$locale$, subscriptionHost, void 0, RenderEvent);
23631
- iCtx.$effectSubscriber$ = [subscriptionHost, ":" /* COMPONENT */];
23632
- iCtx.$container$ = container;
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
+ }
23633
23647
  let componentFn;
23634
23648
  container.ensureProjectionResolved(renderHost);
23635
23649
  let isInlineComponent = false;
23636
23650
  if (componentQRL === null) {
23637
- componentQRL = componentQRL || container.getHostProp(renderHost, OnRenderProp);
23651
+ componentQRL = container.getHostProp(renderHost, OnRenderProp);
23638
23652
  assertDefined(componentQRL, "No Component found at this location");
23639
23653
  }
23640
- if (isQrl2(componentQRL)) {
23654
+ if (isQrl(componentQRL)) {
23641
23655
  props = props || container.getHostProp(renderHost, ELEMENT_PROPS) || EMPTY_OBJ;
23642
- if (props && props.children) {
23656
+ if (props.children) {
23643
23657
  delete props.children;
23644
23658
  }
23645
23659
  componentFn = componentQRL.getFn(iCtx);
@@ -23656,19 +23670,17 @@ var executeComponent = (container, renderHost, subscriptionHost, componentQRL, p
23656
23670
  if (!isInlineComponent) {
23657
23671
  container.setHostProp(renderHost, ELEMENT_SEQ_IDX, null);
23658
23672
  container.setHostProp(renderHost, USE_ON_LOCAL_SEQ_IDX, null);
23659
- if (container.getHostProp(renderHost, ELEMENT_PROPS) !== props) {
23660
- container.setHostProp(renderHost, ELEMENT_PROPS, props);
23661
- }
23673
+ container.setHostProp(renderHost, ELEMENT_PROPS, props);
23662
23674
  }
23663
23675
  if (vnode_isVNode(renderHost)) {
23664
- clearVNodeEffectDependencies(container, renderHost);
23676
+ clearAllEffects(container, renderHost);
23665
23677
  }
23666
23678
  return componentFn(props);
23667
23679
  },
23668
23680
  (jsx4) => {
23669
23681
  const useOnEvents = container.getHostProp(renderHost, USE_ON_LOCAL);
23670
23682
  if (useOnEvents) {
23671
- return maybeThen(addUseOnEvents(jsx4, useOnEvents), () => jsx4);
23683
+ return addUseOnEvents(jsx4, useOnEvents);
23672
23684
  }
23673
23685
  return jsx4;
23674
23686
  },
@@ -23686,6 +23698,7 @@ var executeComponent = (container, renderHost, subscriptionHost, componentQRL, p
23686
23698
  };
23687
23699
  function addUseOnEvents(jsx4, useOnEvents) {
23688
23700
  const jsxElement = findFirstStringJSX(jsx4);
23701
+ let jsxResult = jsx4;
23689
23702
  return maybeThen(jsxElement, (jsxElement2) => {
23690
23703
  let isInvisibleComponent = false;
23691
23704
  if (!jsxElement2) {
@@ -23695,16 +23708,18 @@ function addUseOnEvents(jsx4, useOnEvents) {
23695
23708
  if (Object.prototype.hasOwnProperty.call(useOnEvents, key)) {
23696
23709
  if (isInvisibleComponent) {
23697
23710
  if (key === "onQvisible$") {
23698
- jsxElement2 = addScriptNodeForInvisibleComponents(jsx4);
23699
- if (jsxElement2) {
23700
- 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]);
23701
23715
  }
23702
23716
  } else if (key.startsWith("document:") || key.startsWith("window:")) {
23703
- jsxElement2 = addScriptNodeForInvisibleComponents(jsx4);
23704
- if (jsxElement2) {
23705
- addUseOnEvent(jsxElement2, key, useOnEvents[key]);
23717
+ const [jsxElement3, jsx5] = addScriptNodeForInvisibleComponents(jsxResult);
23718
+ jsxResult = jsx5;
23719
+ if (jsxElement3) {
23720
+ addUseOnEvent(jsxElement3, key, useOnEvents[key]);
23706
23721
  }
23707
- } else if (isDev3) {
23722
+ } else if (isDev5) {
23708
23723
  logWarn(
23709
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. '
23710
23725
  );
@@ -23714,7 +23729,7 @@ function addUseOnEvents(jsx4, useOnEvents) {
23714
23729
  }
23715
23730
  }
23716
23731
  }
23717
- return jsxElement2;
23732
+ return jsxResult;
23718
23733
  });
23719
23734
  }
23720
23735
  function addUseOnEvent(jsxElement, key, value) {
@@ -23765,6 +23780,9 @@ function addScriptNodeForInvisibleComponents(jsx4) {
23765
23780
  null,
23766
23781
  3
23767
23782
  );
23783
+ if (jsx4.type === Slot) {
23784
+ return [jsxElement, _jsxSorted(Fragment, null, null, [jsx4, jsxElement], 0, null)];
23785
+ }
23768
23786
  if (jsx4.children == null) {
23769
23787
  jsx4.children = jsxElement;
23770
23788
  } else if (Array.isArray(jsx4.children)) {
@@ -23772,20 +23790,23 @@ function addScriptNodeForInvisibleComponents(jsx4) {
23772
23790
  } else {
23773
23791
  jsx4.children = [jsx4.children, jsxElement];
23774
23792
  }
23775
- return jsxElement;
23793
+ return [jsxElement, jsx4];
23776
23794
  } else if (Array.isArray(jsx4) && jsx4.length) {
23777
- return addScriptNodeForInvisibleComponents(jsx4[0]);
23795
+ const [jsxElement, _] = addScriptNodeForInvisibleComponents(jsx4[0]);
23796
+ return [jsxElement, jsx4];
23778
23797
  }
23779
- return null;
23798
+ return [null, null];
23780
23799
  }
23781
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
+
23782
23806
  // packages/qwik/src/core/shared/utils/prop.ts
23783
23807
  function isSlotProp(prop) {
23784
23808
  return !prop.startsWith("q:") && !prop.startsWith(NON_SERIALIZABLE_MARKER_PREFIX);
23785
23809
  }
23786
- function isParentSlotProp(prop) {
23787
- return prop.startsWith(QSlotParent);
23788
- }
23789
23810
 
23790
23811
  // packages/qwik/src/core/shared/utils/character-escaping.ts
23791
23812
  function escapeHTML(html) {
@@ -23817,18 +23838,6 @@ function escapeHTML(html) {
23817
23838
  }
23818
23839
  }
23819
23840
 
23820
- // packages/qwik/src/core/shared/utils/jsx-filename.ts
23821
- function getFileLocationFromJsx(jsxDev) {
23822
- if (!jsxDev) {
23823
- return null;
23824
- }
23825
- const sanitizedFileName = jsxDev.fileName?.replace(/\\/g, "/");
23826
- if (sanitizedFileName) {
23827
- return `${sanitizedFileName}:${jsxDev.lineNumber}:${jsxDev.columnNumber}`;
23828
- }
23829
- return null;
23830
- }
23831
-
23832
23841
  // packages/qwik/src/core/client/vnode-diff.ts
23833
23842
  var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
23834
23843
  let journal = container.$journal$;
@@ -23865,7 +23874,7 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
23865
23874
  descend(jsxValue, false);
23866
23875
  } else if (isSignal(jsxValue)) {
23867
23876
  if (vCurrent) {
23868
- clearVNodeEffectDependencies(container, vCurrent);
23877
+ clearAllEffects(container, vCurrent);
23869
23878
  }
23870
23879
  expectVirtual("S" /* WrappedSignal */, null);
23871
23880
  descend(
@@ -24022,8 +24031,9 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
24022
24031
  };
24023
24032
  const projections = [];
24024
24033
  if (host) {
24025
- for (let i = vnode_getPropStartIndex(host); i < host.length; i = i + 2) {
24026
- const prop = host[i];
24034
+ const props = vnode_getProps(host);
24035
+ for (let i = 0; i < props.length; i = i + 2) {
24036
+ const prop = props[i];
24027
24037
  if (isSlotProp(prop)) {
24028
24038
  const slotName = prop;
24029
24039
  projections.push(slotName);
@@ -24065,10 +24075,11 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
24065
24075
  slotName,
24066
24076
  (id) => vnode_locate(container.rootVNode, id)
24067
24077
  );
24078
+ vCurrent = vCurrent && vCurrent[0 /* flags */] & 32 /* Deleted */ ? null : vCurrent;
24068
24079
  if (vCurrent == null) {
24069
24080
  vNewNode = vnode_newVirtual();
24070
- isDev4 && vnode_setProp(vNewNode, DEBUG_TYPE, "P" /* Projection */);
24071
- isDev4 && vnode_setProp(vNewNode, "q:code", "expectProjection");
24081
+ isDev6 && vnode_setProp(vNewNode, DEBUG_TYPE, "P" /* Projection */);
24082
+ isDev6 && vnode_setProp(vNewNode, "q:code", "expectProjection");
24072
24083
  vnode_setProp(vNewNode, QSlot, slotName);
24073
24084
  vnode_setProp(vNewNode, QSlotParent, vParent);
24074
24085
  vnode_setProp(vParent, slotName, vNewNode);
@@ -24094,11 +24105,16 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
24094
24105
  );
24095
24106
  vnode_setProp(vNewNode, QSlot, slotNameKey);
24096
24107
  vHost && vnode_setProp(vHost, slotNameKey, vNewNode);
24097
- isDev4 && vnode_setProp(vNewNode, DEBUG_TYPE, "P" /* Projection */);
24098
- isDev4 && vnode_setProp(vNewNode, "q:code", "expectSlot" + count++);
24108
+ isDev6 && vnode_setProp(vNewNode, DEBUG_TYPE, "P" /* Projection */);
24109
+ isDev6 && vnode_setProp(vNewNode, "q:code", "expectSlot" + count++);
24099
24110
  return false;
24100
24111
  } else if (vProjectedNode === vCurrent) {
24101
24112
  } else {
24113
+ const parent = vnode_getParent(vProjectedNode);
24114
+ const isAlreadyProjected = !!parent && !(vnode_isElementVNode(parent) && vnode_getElementName(parent) === QTemplate);
24115
+ if (isAlreadyProjected && vParent !== parent) {
24116
+ vnode_remove(journal, parent, vProjectedNode, false);
24117
+ }
24102
24118
  vnode_insertBefore(
24103
24119
  journal,
24104
24120
  vParent,
@@ -24107,8 +24123,8 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
24107
24123
  );
24108
24124
  vnode_setProp(vNewNode, QSlot, slotNameKey);
24109
24125
  vHost && vnode_setProp(vHost, slotNameKey, vNewNode);
24110
- isDev4 && vnode_setProp(vNewNode, DEBUG_TYPE, "P" /* Projection */);
24111
- isDev4 && vnode_setProp(vNewNode, "q:code", "expectSlot" + count++);
24126
+ isDev6 && vnode_setProp(vNewNode, DEBUG_TYPE, "P" /* Projection */);
24127
+ isDev6 && vnode_setProp(vNewNode, "q:code", "expectSlot" + count++);
24112
24128
  }
24113
24129
  return true;
24114
24130
  }
@@ -24154,8 +24170,8 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
24154
24170
  while (vCurrent) {
24155
24171
  const toRemove = vCurrent;
24156
24172
  advanceToNextSibling();
24157
- cleanup(container, toRemove);
24158
24173
  if (vParent === vnode_getParent(toRemove)) {
24174
+ cleanup(container, toRemove);
24159
24175
  vnode_remove(journal, vParent, toRemove, true);
24160
24176
  }
24161
24177
  }
@@ -24179,14 +24195,20 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
24179
24195
  if (isJsxPropertyAnEventName(key2)) {
24180
24196
  const eventName = getEventNameFromJsxProp(key2);
24181
24197
  const scope = getEventNameScopeFromJsxProp(key2);
24182
- vnode_setProp(
24183
- vNewNode,
24184
- HANDLER_PREFIX + ":" + scope + ":" + eventName,
24185
- value
24186
- );
24187
24198
  if (eventName) {
24199
+ vnode_setProp(
24200
+ vNewNode,
24201
+ HANDLER_PREFIX + ":" + scope + ":" + eventName,
24202
+ value
24203
+ );
24188
24204
  registerQwikLoaderEvent(eventName);
24189
24205
  }
24206
+ if (scope) {
24207
+ const htmlEvent = convertEventNameFromJsxPropToHtmlAttr(key2);
24208
+ if (htmlEvent) {
24209
+ vnode_setAttr(journal, vNewNode, htmlEvent, "");
24210
+ }
24211
+ }
24190
24212
  needsQDispatchEventPatch = true;
24191
24213
  continue;
24192
24214
  }
@@ -24197,12 +24219,14 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
24197
24219
  } else if (typeof value === "function") {
24198
24220
  value(element);
24199
24221
  continue;
24222
+ } else if (value == null) {
24223
+ continue;
24200
24224
  } else {
24201
24225
  throw qError(32 /* invalidRefValue */, [currentFile]);
24202
24226
  }
24203
24227
  }
24204
24228
  if (isSignal(value)) {
24205
- const signalData = new EffectPropData({
24229
+ const signalData = new SubscriptionData({
24206
24230
  $scopedStyleIdPrefix$: scopedStyleIdPrefix,
24207
24231
  $isConst$: true
24208
24232
  });
@@ -24221,7 +24245,7 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
24221
24245
  }
24222
24246
  if (elementName === "textarea" && key2 === "value") {
24223
24247
  if (value && typeof value !== "string") {
24224
- if (isDev4) {
24248
+ if (isDev6) {
24225
24249
  throw qError(40 /* wrongTextareaValue */, [currentFile, value]);
24226
24250
  }
24227
24251
  continue;
@@ -24302,7 +24326,12 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
24302
24326
  let returnValue = false;
24303
24327
  qrls.flat(2).forEach((qrl2) => {
24304
24328
  if (qrl2) {
24305
- const value = qrl2(event, element);
24329
+ const value = container.$scheduler$(
24330
+ 2 /* RUN_QRL */,
24331
+ vNode,
24332
+ qrl2,
24333
+ [event, element]
24334
+ );
24306
24335
  returnValue = returnValue || value === true;
24307
24336
  }
24308
24337
  });
@@ -24313,10 +24342,10 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
24313
24342
  }
24314
24343
  function setBulkProps(vnode, srcAttrs, currentFile) {
24315
24344
  vnode_ensureElementInflated(vnode);
24316
- const dstAttrs = vnode;
24345
+ const dstAttrs = vnode_getProps(vnode);
24317
24346
  let srcIdx = 0;
24318
24347
  const srcLength = srcAttrs.length;
24319
- let dstIdx = 8 /* PROPS_OFFSET */;
24348
+ let dstIdx = 0;
24320
24349
  let dstLength = dstAttrs.length;
24321
24350
  let srcKey = srcIdx < srcLength ? srcAttrs[srcIdx++] : null;
24322
24351
  let dstKey = dstIdx < dstLength ? dstAttrs[dstIdx++] : null;
@@ -24334,12 +24363,14 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
24334
24363
  } else if (typeof value === "function") {
24335
24364
  value(element);
24336
24365
  return;
24366
+ } else if (value == null) {
24367
+ return;
24337
24368
  } else {
24338
24369
  throw qError(32 /* invalidRefValue */, [currentFile]);
24339
24370
  }
24340
24371
  }
24341
24372
  if (isSignal(value)) {
24342
- const signalData = new EffectPropData({
24373
+ const signalData = new SubscriptionData({
24343
24374
  $scopedStyleIdPrefix$: scopedStyleIdPrefix,
24344
24375
  $isConst$: false
24345
24376
  });
@@ -24352,17 +24383,17 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
24352
24383
  };
24353
24384
  const recordJsxEvent = (key, value) => {
24354
24385
  const eventName = getEventNameFromJsxProp(key);
24386
+ const scope = getEventNameScopeFromJsxProp(key);
24355
24387
  if (eventName) {
24356
- const scope = getEventNameScopeFromJsxProp(key);
24357
24388
  record(":" + scope + ":" + eventName, value);
24358
- }
24359
- const htmlEvent = convertEventNameFromJsxPropToHtmlAttr(key);
24360
- if (htmlEvent) {
24361
- record(htmlEvent, "");
24362
- }
24363
- if (eventName) {
24364
24389
  registerQwikLoaderEvent(eventName);
24365
24390
  }
24391
+ if (scope) {
24392
+ const htmlEvent = convertEventNameFromJsxPropToHtmlAttr(key);
24393
+ if (htmlEvent) {
24394
+ record(htmlEvent, "");
24395
+ }
24396
+ }
24366
24397
  };
24367
24398
  while (srcKey !== null || dstKey !== null) {
24368
24399
  if (dstKey?.startsWith(HANDLER_PREFIX) || dstKey?.startsWith(Q_PREFIX)) {
@@ -24478,7 +24509,7 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
24478
24509
  vCurrent && getInsertBefore()
24479
24510
  );
24480
24511
  vnode_setProp(vNewNode, ELEMENT_KEY, jsxKey);
24481
- isDev4 && vnode_setProp(vNewNode || vCurrent, DEBUG_TYPE, type);
24512
+ isDev6 && vnode_setProp(vNewNode || vCurrent, DEBUG_TYPE, type);
24482
24513
  }
24483
24514
  function expectComponent(component) {
24484
24515
  const componentMeta = component[SERIALIZABLE_STATE];
@@ -24505,20 +24536,15 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
24505
24536
  shouldRender = true;
24506
24537
  } else if (!hashesAreEqual) {
24507
24538
  insertNewComponent(host, componentQRL, jsxProps);
24508
- if (vNewNode) {
24509
- if (host) {
24510
- vNewNode[0 /* flags */] = host[0 /* flags */];
24511
- }
24512
- host = vNewNode;
24513
- shouldRender = true;
24514
- }
24539
+ host = vNewNode;
24540
+ shouldRender = true;
24515
24541
  }
24516
24542
  if (host) {
24517
24543
  const vNodeProps = vnode_getProp(host, ELEMENT_PROPS, container.$getObjectById$);
24518
24544
  shouldRender = shouldRender || propsDiffer(jsxProps, vNodeProps);
24519
24545
  if (shouldRender) {
24520
24546
  host[0 /* flags */] &= ~32 /* Deleted */;
24521
- container.$scheduler$(7 /* COMPONENT */, host, componentQRL, jsxProps);
24547
+ container.$scheduler$(6 /* COMPONENT */, host, componentQRL, jsxProps);
24522
24548
  }
24523
24549
  }
24524
24550
  descendContentToProject(jsxNode2.children, host);
@@ -24526,6 +24552,7 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
24526
24552
  const lookupKey = jsxNode2.key;
24527
24553
  const vNodeLookupKey = getKey(host);
24528
24554
  const lookupKeysAreEqual = lookupKey === vNodeLookupKey;
24555
+ const vNodeComponentHash = getComponentHash(host, container.$getObjectById$);
24529
24556
  if (!lookupKeysAreEqual) {
24530
24557
  vNewNode = retrieveChildWithKey(null, lookupKey);
24531
24558
  if (vNewNode) {
@@ -24534,6 +24561,9 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
24534
24561
  insertNewInlineComponent();
24535
24562
  }
24536
24563
  host = vNewNode;
24564
+ } else if (vNodeComponentHash != null) {
24565
+ insertNewInlineComponent();
24566
+ host = vNewNode;
24537
24567
  }
24538
24568
  if (host) {
24539
24569
  let componentHost = host;
@@ -24553,7 +24583,7 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
24553
24583
  }
24554
24584
  function insertNewComponent(host, componentQRL, jsxProps) {
24555
24585
  if (host) {
24556
- clearVNodeEffectDependencies(container, host);
24586
+ clearAllEffects(container, host);
24557
24587
  }
24558
24588
  vnode_insertBefore(
24559
24589
  journal,
@@ -24562,7 +24592,7 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
24562
24592
  vCurrent && getInsertBefore()
24563
24593
  );
24564
24594
  const jsxNode2 = jsxValue;
24565
- isDev4 && vnode_setProp(vNewNode, DEBUG_TYPE, "C" /* Component */);
24595
+ isDev6 && vnode_setProp(vNewNode, DEBUG_TYPE, "C" /* Component */);
24566
24596
  container.setHostProp(vNewNode, OnRenderProp, componentQRL);
24567
24597
  container.setHostProp(vNewNode, ELEMENT_PROPS, jsxProps);
24568
24598
  container.setHostProp(vNewNode, ELEMENT_KEY, jsxNode2.key);
@@ -24575,7 +24605,7 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
24575
24605
  vCurrent && getInsertBefore()
24576
24606
  );
24577
24607
  const jsxNode2 = jsxValue;
24578
- isDev4 && vnode_setProp(vNewNode, DEBUG_TYPE, "I" /* InlineComponent */);
24608
+ isDev6 && vnode_setProp(vNewNode, DEBUG_TYPE, "I" /* InlineComponent */);
24579
24609
  vnode_setProp(vNewNode, ELEMENT_PROPS, jsxNode2.props);
24580
24610
  if (jsxNode2.key) {
24581
24611
  vnode_setProp(vNewNode, ELEMENT_KEY, jsxNode2.key);
@@ -24619,8 +24649,8 @@ function propsDiffer(src, dst) {
24619
24649
  if (!src || !dst) {
24620
24650
  return true;
24621
24651
  }
24622
- let srcKeys = removePropsKeys(Object.keys(src), ["children", QSubscribers]);
24623
- let dstKeys = removePropsKeys(Object.keys(dst), ["children", QSubscribers]);
24652
+ let srcKeys = removePropsKeys(Object.keys(src), ["children", QBackRefs]);
24653
+ let dstKeys = removePropsKeys(Object.keys(dst), ["children", QBackRefs]);
24624
24654
  if (srcKeys.length !== dstKeys.length) {
24625
24655
  return true;
24626
24656
  }
@@ -24648,13 +24678,14 @@ function removePropsKeys(keys, propKeys) {
24648
24678
  function cleanup(container, vNode) {
24649
24679
  let vCursor = vNode;
24650
24680
  if (vnode_isTextVNode(vNode)) {
24681
+ markVNodeAsDeleted(vCursor);
24651
24682
  return;
24652
24683
  }
24653
24684
  let vParent = null;
24654
24685
  do {
24655
24686
  const type = vCursor[0 /* flags */];
24656
24687
  if (type & 3 /* ELEMENT_OR_VIRTUAL_MASK */) {
24657
- clearVNodeEffectDependencies(container, vCursor);
24688
+ clearAllEffects(container, vCursor);
24658
24689
  markVNodeAsDeleted(vCursor);
24659
24690
  if (type & 2 /* Virtual */) {
24660
24691
  const seq = container.getHostProp(vCursor, ELEMENT_SEQ);
@@ -24663,7 +24694,7 @@ function cleanup(container, vNode) {
24663
24694
  const obj = seq[i];
24664
24695
  if (isTask(obj)) {
24665
24696
  const task = obj;
24666
- clearSubscriberEffectDependencies(container, task);
24697
+ clearAllEffects(container, task);
24667
24698
  if (task.$flags$ & 1 /* VISIBLE_TASK */) {
24668
24699
  container.$scheduler$(48 /* CLEANUP_VISIBLE */, task);
24669
24700
  } else {
@@ -24675,10 +24706,10 @@ function cleanup(container, vNode) {
24675
24706
  }
24676
24707
  const isComponent = type & 2 /* Virtual */ && vnode_getProp(vCursor, OnRenderProp, null) !== null;
24677
24708
  if (isComponent) {
24678
- const attrs = vCursor;
24679
- for (let i = 6 /* PROPS_OFFSET */; i < attrs.length; i = i + 2) {
24709
+ const attrs = vnode_getProps(vCursor);
24710
+ for (let i = 0; i < attrs.length; i = i + 2) {
24680
24711
  const key = attrs[i];
24681
- if (!isParentSlotProp(key) && isSlotProp(key)) {
24712
+ if (isSlotProp(key)) {
24682
24713
  const value = attrs[i + 1];
24683
24714
  if (value) {
24684
24715
  attrs[i + 1] = null;
@@ -24693,7 +24724,7 @@ function cleanup(container, vNode) {
24693
24724
  }
24694
24725
  }
24695
24726
  }
24696
- const isProjection = type & 2 /* Virtual */ && vnode_getProp(vCursor, QSlot, null) !== null;
24727
+ const isProjection = vnode_isProjection(vCursor);
24697
24728
  if (!isProjection) {
24698
24729
  const vFirstChild = vnode_getFirstChild(vCursor);
24699
24730
  if (vFirstChild) {
@@ -24707,6 +24738,8 @@ function cleanup(container, vNode) {
24707
24738
  return;
24708
24739
  }
24709
24740
  }
24741
+ } else if (type & 4 /* Text */) {
24742
+ markVNodeAsDeleted(vCursor);
24710
24743
  }
24711
24744
  if (vCursor === vNode) {
24712
24745
  return;
@@ -24748,58 +24781,198 @@ function markVNodeAsDeleted(vCursor) {
24748
24781
  var HANDLER_PREFIX = ":";
24749
24782
  var count = 0;
24750
24783
 
24751
- // packages/qwik/src/core/shared/qrl/implicit_dollar.ts
24752
- var implicit$FirstArg = (fn) => {
24753
- return function(first, ...rest) {
24754
- return fn.call(null, dollar(first), ...rest);
24784
+ // packages/qwik/src/core/use/use-resource.ts
24785
+ var _createResourceReturn = (opts) => {
24786
+ const resource = {
24787
+ __brand: "resource",
24788
+ value: void 0,
24789
+ loading: isServerPlatform() ? false : true,
24790
+ _resolved: void 0,
24791
+ _error: void 0,
24792
+ _state: "pending",
24793
+ _timeout: opts?.timeout ?? -1,
24794
+ _cache: 0
24755
24795
  };
24796
+ return resource;
24756
24797
  };
24757
-
24758
- // packages/qwik/src/core/shared/scheduler-document-position.ts
24759
- var aVNodePath = [];
24760
- var bVNodePath = [];
24761
- var vnode_documentPosition = (a, b, rootVNode) => {
24762
- if (a === b) {
24763
- return 0;
24764
- }
24765
- let aDepth = -1;
24766
- let bDepth = -1;
24767
- while (a) {
24768
- const vNode = aVNodePath[++aDepth] = a;
24769
- a = vNode[1 /* parent */] || rootVNode && vnode_getProp(a, QSlotParent, (id) => vnode_locate(rootVNode, id));
24770
- }
24771
- while (b) {
24772
- const vNode = bVNodePath[++bDepth] = b;
24773
- b = vNode[1 /* parent */] || rootVNode && vnode_getProp(b, QSlotParent, (id) => vnode_locate(rootVNode, id));
24774
- }
24775
- while (aDepth >= 0 && bDepth >= 0) {
24776
- a = aVNodePath[aDepth];
24777
- b = bVNodePath[bDepth];
24778
- if (a === b) {
24779
- aDepth--;
24780
- bDepth--;
24781
- } else {
24782
- let cursor = b;
24783
- do {
24784
- cursor = vnode_getNextSibling(cursor);
24785
- if (cursor === a) {
24786
- return 1;
24787
- }
24788
- } while (cursor);
24789
- cursor = b;
24790
- do {
24791
- cursor = vnode_getPreviousSibling(cursor);
24792
- if (cursor === a) {
24793
- return -1;
24794
- }
24795
- } while (cursor);
24796
- if (rootVNode && vnode_getProp(b, QSlotParent, (id) => vnode_locate(rootVNode, id))) {
24797
- return -1;
24798
- }
24799
- return 1;
24800
- }
24801
- }
24802
- return aDepth < bDepth ? -1 : 1;
24798
+ var createResourceReturn = (container, opts, initialPromise) => {
24799
+ const result = _createResourceReturn(opts);
24800
+ result.value = initialPromise;
24801
+ return createStore(container, result, 1 /* RECURSIVE */);
24802
+ };
24803
+ var runResource = (task, container, host) => {
24804
+ task.$flags$ &= ~8 /* DIRTY */;
24805
+ cleanupTask(task);
24806
+ const iCtx = newInvokeContext(container.$locale$, host, void 0, ResourceEvent);
24807
+ iCtx.$container$ = container;
24808
+ const taskFn = task.$qrl$.getFn(iCtx, () => clearAllEffects(container, task));
24809
+ const resource = task.$state$;
24810
+ assertDefined(
24811
+ resource,
24812
+ 'useResource: when running a resource, "task.resource" must be a defined.',
24813
+ task
24814
+ );
24815
+ const track = (obj, prop) => {
24816
+ const ctx = newInvokeContext();
24817
+ ctx.$effectSubscriber$ = getSubscriber(task, ":" /* COMPONENT */);
24818
+ ctx.$container$ = container;
24819
+ return invoke(ctx, () => {
24820
+ if (isFunction(obj)) {
24821
+ return obj();
24822
+ }
24823
+ if (prop) {
24824
+ return obj[prop];
24825
+ } else if (isSignal(obj)) {
24826
+ return obj.value;
24827
+ } else {
24828
+ return obj;
24829
+ }
24830
+ });
24831
+ };
24832
+ const handleError = (reason) => container.handleError(reason, host);
24833
+ const cleanups = [];
24834
+ task.$destroy$ = noSerialize(() => {
24835
+ cleanups.forEach((fn) => {
24836
+ try {
24837
+ fn();
24838
+ } catch (err) {
24839
+ handleError(err);
24840
+ }
24841
+ });
24842
+ done = true;
24843
+ });
24844
+ const resourceTarget = unwrapStore(resource);
24845
+ const opts = {
24846
+ track,
24847
+ cleanup(fn) {
24848
+ if (typeof fn === "function") {
24849
+ cleanups.push(fn);
24850
+ }
24851
+ },
24852
+ cache(policy) {
24853
+ let milliseconds = 0;
24854
+ if (policy === "immutable") {
24855
+ milliseconds = Infinity;
24856
+ } else {
24857
+ milliseconds = policy;
24858
+ }
24859
+ resource._cache = milliseconds;
24860
+ },
24861
+ previous: resourceTarget._resolved
24862
+ };
24863
+ let resolve;
24864
+ let reject;
24865
+ let done = false;
24866
+ const setState = (resolved, value) => {
24867
+ if (!done) {
24868
+ done = true;
24869
+ if (resolved) {
24870
+ done = true;
24871
+ resource.loading = false;
24872
+ resource._state = "resolved";
24873
+ resource._resolved = value;
24874
+ resource._error = void 0;
24875
+ resolve(value);
24876
+ } else {
24877
+ done = true;
24878
+ resource.loading = false;
24879
+ resource._state = "rejected";
24880
+ resource._error = value;
24881
+ reject(value);
24882
+ }
24883
+ return true;
24884
+ }
24885
+ return false;
24886
+ };
24887
+ cleanups.push(() => {
24888
+ if (untrack(() => resource.loading) === true) {
24889
+ const value = untrack(() => resource._resolved);
24890
+ setState(true, value);
24891
+ }
24892
+ });
24893
+ invoke(iCtx, () => {
24894
+ resource._state = "pending";
24895
+ resource.loading = !isServerPlatform();
24896
+ const promise2 = resource.value = new Promise((r, re) => {
24897
+ resolve = r;
24898
+ reject = re;
24899
+ });
24900
+ promise2.catch(ignoreErrorToPreventNodeFromCrashing);
24901
+ });
24902
+ const promise = safeCall(
24903
+ () => Promise.resolve(taskFn(opts)),
24904
+ (value) => {
24905
+ setState(true, value);
24906
+ },
24907
+ (err) => {
24908
+ if (isPromise(err)) {
24909
+ return err.then(() => runResource(task, container, host));
24910
+ } else {
24911
+ setState(false, err);
24912
+ }
24913
+ }
24914
+ );
24915
+ const timeout = resourceTarget._timeout;
24916
+ if (timeout > 0) {
24917
+ return Promise.race([
24918
+ promise,
24919
+ delay(timeout).then(() => {
24920
+ if (setState(false, new Error("timeout"))) {
24921
+ cleanupTask(task);
24922
+ }
24923
+ })
24924
+ ]);
24925
+ }
24926
+ return promise;
24927
+ };
24928
+ var ignoreErrorToPreventNodeFromCrashing = (err) => {
24929
+ };
24930
+
24931
+ // packages/qwik/src/core/shared/scheduler-document-position.ts
24932
+ var aVNodePath = [];
24933
+ var bVNodePath = [];
24934
+ var vnode_documentPosition = (a, b, rootVNode) => {
24935
+ if (a === b) {
24936
+ return 0;
24937
+ }
24938
+ let aDepth = -1;
24939
+ let bDepth = -1;
24940
+ while (a) {
24941
+ const vNode = aVNodePath[++aDepth] = a;
24942
+ a = vNode[1 /* parent */] || rootVNode && vnode_getProp(a, QSlotParent, (id) => vnode_locate(rootVNode, id));
24943
+ }
24944
+ while (b) {
24945
+ const vNode = bVNodePath[++bDepth] = b;
24946
+ b = vNode[1 /* parent */] || rootVNode && vnode_getProp(b, QSlotParent, (id) => vnode_locate(rootVNode, id));
24947
+ }
24948
+ while (aDepth >= 0 && bDepth >= 0) {
24949
+ a = aVNodePath[aDepth];
24950
+ b = bVNodePath[bDepth];
24951
+ if (a === b) {
24952
+ aDepth--;
24953
+ bDepth--;
24954
+ } else {
24955
+ let cursor = b;
24956
+ do {
24957
+ cursor = vnode_getNextSibling(cursor);
24958
+ if (cursor === a) {
24959
+ return 1;
24960
+ }
24961
+ } while (cursor);
24962
+ cursor = b;
24963
+ do {
24964
+ cursor = vnode_getPreviousSibling(cursor);
24965
+ if (cursor === a) {
24966
+ return -1;
24967
+ }
24968
+ } while (cursor);
24969
+ if (rootVNode && vnode_getProp(b, QSlotParent, (id) => vnode_locate(rootVNode, id))) {
24970
+ return -1;
24971
+ }
24972
+ return 1;
24973
+ }
24974
+ }
24975
+ return aDepth < bDepth ? -1 : 1;
24803
24976
  };
24804
24977
  var aSsrNodePath = [];
24805
24978
  var bSsrNodePath = [];
@@ -24832,14 +25005,30 @@ var ssrNodeDocumentPosition = (a, b) => {
24832
25005
 
24833
25006
  // packages/qwik/src/core/shared/scheduler.ts
24834
25007
  var DEBUG2 = false;
25008
+ var getPromise = (chore) => chore.$promise$ || (chore.$promise$ = new Promise((resolve) => {
25009
+ chore.$resolve$ = resolve;
25010
+ }));
24835
25011
  var createScheduler = (container, scheduleDrain, journalFlush) => {
24836
25012
  const choreQueue = [];
25013
+ const qrlRuns = [];
24837
25014
  let currentChore = null;
24838
- let journalFlushScheduled = false;
25015
+ let drainScheduled = false;
24839
25016
  return schedule;
24840
25017
  function schedule(type, hostOrTask = null, targetOrQrl = null, payload = null) {
24841
- const runLater = type !== 255 /* WAIT_FOR_ALL */ && type !== 6 /* COMPONENT_SSR */;
24842
- const isTask2 = type === 3 /* TASK */ || type === 32 /* VISIBLE */ || type === 2 /* RESOURCE */ || type === 48 /* CLEANUP_VISIBLE */;
25018
+ const isServer4 = !isDomContainer(container);
25019
+ const isComponentSsr = isServer4 && type === 6 /* COMPONENT */;
25020
+ const runLater = type !== 255 /* WAIT_FOR_ALL */ && !isComponentSsr && type !== 2 /* RUN_QRL */;
25021
+ const isTask2 = type === 3 /* TASK */ || type === 32 /* VISIBLE */ || type === 48 /* CLEANUP_VISIBLE */;
25022
+ const isClientOnly = type === 16 /* JOURNAL_FLUSH */ || type === 4 /* NODE_DIFF */ || type === 5 /* NODE_PROP */;
25023
+ if (isServer4 && isClientOnly) {
25024
+ DEBUG2 && debugTrace(
25025
+ `skip client chore ${debugChoreTypeToString(type)}`,
25026
+ null,
25027
+ currentChore,
25028
+ choreQueue
25029
+ );
25030
+ return;
25031
+ }
24843
25032
  if (isTask2) {
24844
25033
  hostOrTask.$flags$ |= 8 /* DIRTY */;
24845
25034
  }
@@ -24854,179 +25043,226 @@ var createScheduler = (container, scheduleDrain, journalFlush) => {
24854
25043
  $returnValue$: null,
24855
25044
  $executed$: false
24856
25045
  };
24857
- chore.$promise$ = new Promise((resolve) => chore.$resolve$ = resolve);
24858
- DEBUG2 && debugTrace("schedule", chore, currentChore, choreQueue);
24859
25046
  chore = sortedInsert(choreQueue, chore, container.rootVNode || null);
24860
- if (!journalFlushScheduled && runLater) {
24861
- journalFlushScheduled = true;
25047
+ DEBUG2 && debugTrace("schedule", chore, currentChore, choreQueue);
25048
+ if (!drainScheduled && runLater) {
25049
+ drainScheduled = true;
24862
25050
  schedule(16 /* JOURNAL_FLUSH */);
24863
- scheduleDrain();
25051
+ scheduleDrain()?.catch?.(() => {
25052
+ });
24864
25053
  }
24865
25054
  if (runLater) {
24866
- return chore.$promise$;
25055
+ return getPromise(chore);
24867
25056
  } else {
24868
- return drainUpTo(chore, container.rootVNode || null);
25057
+ return drainUpTo(chore, isServer4);
24869
25058
  }
24870
25059
  }
24871
- function drainUpTo(runUptoChore, rootVNode) {
24872
- if (runUptoChore.$executed$) {
24873
- return runUptoChore.$returnValue$;
24874
- }
24875
- if (currentChore) {
24876
- return runUptoChore.$promise$;
24877
- }
25060
+ function drainUpTo(runUptoChore, isServer4) {
25061
+ let maxRetries = 5e3;
24878
25062
  while (choreQueue.length) {
24879
- const nextChore = choreQueue.shift();
24880
- const order = choreComparator(nextChore, runUptoChore, rootVNode);
24881
- if (order === null) {
24882
- continue;
25063
+ if (maxRetries-- < 0) {
25064
+ throw new Error("drainUpTo: max retries reached");
24883
25065
  }
24884
- if (order > 0) {
24885
- break;
25066
+ if (currentChore) {
25067
+ return getPromise(currentChore).then(() => drainUpTo(runUptoChore, isServer4)).catch((e) => {
25068
+ container.handleError(e, currentChore?.$host$);
25069
+ });
25070
+ }
25071
+ const nextChore = choreQueue[0];
25072
+ if (nextChore.$executed$) {
25073
+ choreQueue.shift();
25074
+ if (nextChore === runUptoChore) {
25075
+ break;
25076
+ }
25077
+ continue;
24886
25078
  }
24887
- const isDeletedVNode = vNodeAlreadyDeleted(nextChore);
24888
- if (isDeletedVNode && // we need to process cleanup tasks for deleted nodes
25079
+ if (vNodeAlreadyDeleted(nextChore) && // we need to process cleanup tasks for deleted nodes
24889
25080
  nextChore.$type$ !== 48 /* CLEANUP_VISIBLE */) {
24890
25081
  DEBUG2 && debugTrace("skip chore", nextChore, currentChore, choreQueue);
25082
+ choreQueue.shift();
24891
25083
  continue;
24892
25084
  }
24893
- const returnValue = executeChore(nextChore);
24894
- if (isPromise(returnValue)) {
24895
- const promise = returnValue.then(() => drainUpTo(runUptoChore, rootVNode));
24896
- return promise;
24897
- }
25085
+ executeChore(nextChore, isServer4);
24898
25086
  }
24899
25087
  return runUptoChore.$returnValue$;
24900
25088
  }
24901
- function executeChore(chore) {
25089
+ function executeChore(chore, isServer4) {
24902
25090
  const host = chore.$host$;
24903
25091
  DEBUG2 && debugTrace("execute", chore, currentChore, choreQueue);
24904
25092
  assertEqual(currentChore, null, "Chore already running.");
24905
25093
  currentChore = chore;
24906
25094
  let returnValue = null;
24907
- switch (chore.$type$) {
24908
- case 16 /* JOURNAL_FLUSH */:
24909
- returnValue = journalFlush();
24910
- journalFlushScheduled = false;
24911
- break;
24912
- case 7 /* COMPONENT */:
24913
- case 6 /* COMPONENT_SSR */:
24914
- returnValue = safeCall(
24915
- () => executeComponent(
24916
- container,
24917
- host,
24918
- host,
24919
- chore.$target$,
24920
- chore.$payload$
24921
- ),
24922
- (jsx5) => {
24923
- if (chore.$type$ === 7 /* COMPONENT */) {
24924
- const styleScopedId = container.getHostProp(host, QScopedStyle);
24925
- return retryOnPromise(
24926
- () => vnode_diff(
24927
- container,
24928
- jsx5,
24929
- host,
24930
- addComponentStylePrefix(styleScopedId)
24931
- )
24932
- );
25095
+ try {
25096
+ switch (chore.$type$) {
25097
+ case 255 /* WAIT_FOR_ALL */:
25098
+ {
25099
+ if (isServer4) {
25100
+ drainScheduled = false;
25101
+ }
25102
+ }
25103
+ break;
25104
+ case 16 /* JOURNAL_FLUSH */:
25105
+ {
25106
+ returnValue = journalFlush();
25107
+ drainScheduled = false;
25108
+ }
25109
+ break;
25110
+ case 6 /* COMPONENT */:
25111
+ {
25112
+ returnValue = safeCall(
25113
+ () => executeComponent(
25114
+ container,
25115
+ host,
25116
+ host,
25117
+ chore.$target$,
25118
+ chore.$payload$
25119
+ ),
25120
+ (jsx4) => {
25121
+ if (isServer4) {
25122
+ return jsx4;
25123
+ } else {
25124
+ const styleScopedId = container.getHostProp(host, QScopedStyle);
25125
+ return retryOnPromise(
25126
+ () => vnode_diff(
25127
+ container,
25128
+ jsx4,
25129
+ host,
25130
+ addComponentStylePrefix(styleScopedId)
25131
+ )
25132
+ );
25133
+ }
25134
+ },
25135
+ (err) => container.handleError(err, host)
25136
+ );
25137
+ }
25138
+ break;
25139
+ case 2 /* RUN_QRL */:
25140
+ {
25141
+ const fn = chore.$target$.getFn();
25142
+ const result = retryOnPromise(() => fn(...chore.$payload$));
25143
+ if (isPromise(result)) {
25144
+ const handled = result.finally(() => {
25145
+ qrlRuns.splice(qrlRuns.indexOf(handled), 1);
25146
+ }).catch((error) => {
25147
+ container.handleError(error, chore.$host$);
25148
+ });
25149
+ qrlRuns.push(handled);
25150
+ DEBUG2 && debugTrace("execute.DONE (but still running)", chore, currentChore, choreQueue);
25151
+ chore.$returnValue$ = handled;
25152
+ chore.$resolve$?.(handled);
25153
+ currentChore = null;
25154
+ chore.$executed$ = true;
25155
+ return;
25156
+ }
25157
+ returnValue = null;
25158
+ }
25159
+ break;
25160
+ case 3 /* TASK */:
25161
+ case 32 /* VISIBLE */:
25162
+ {
25163
+ const payload = chore.$payload$;
25164
+ if (payload.$flags$ & 4 /* RESOURCE */) {
25165
+ const result = runResource(payload, container, host);
25166
+ returnValue = isServer4 ? result : null;
24933
25167
  } else {
24934
- return jsx5;
25168
+ returnValue = runTask(payload, container, host);
24935
25169
  }
24936
- },
24937
- (err) => container.handleError(err, host)
24938
- );
24939
- break;
24940
- case 2 /* RESOURCE */:
24941
- const result = runResource(chore.$payload$, container, host);
24942
- returnValue = isDomContainer(container) ? null : result;
24943
- break;
24944
- case 3 /* TASK */:
24945
- returnValue = runTask(chore.$payload$, container, host);
24946
- break;
24947
- case 32 /* VISIBLE */:
24948
- returnValue = runTask(chore.$payload$, container, host);
24949
- break;
24950
- case 48 /* CLEANUP_VISIBLE */:
24951
- const task = chore.$payload$;
24952
- cleanupTask(task);
24953
- break;
24954
- case 4 /* NODE_DIFF */:
24955
- const parentVirtualNode = chore.$target$;
24956
- let jsx4 = chore.$payload$;
24957
- if (isSignal(jsx4)) {
24958
- jsx4 = jsx4.value;
24959
- }
24960
- returnValue = retryOnPromise(
24961
- () => vnode_diff(container, jsx4, parentVirtualNode, null)
24962
- );
24963
- break;
24964
- case 5 /* NODE_PROP */:
24965
- const virtualNode = chore.$host$;
24966
- const payload = chore.$payload$;
24967
- let value = payload.$value$;
24968
- if (isSignal(value)) {
24969
- value = value.value;
24970
- }
24971
- const isConst = payload.$isConst$;
24972
- const journal = container.$journal$;
24973
- const property = chore.$idx$;
24974
- const serializedValue = serializeAttribute(property, value, payload.$scopedStyleIdPrefix$);
24975
- if (isConst) {
24976
- const element = virtualNode[6 /* element */];
24977
- journal.push(2 /* SetAttribute */, element, property, serializedValue);
24978
- } else {
24979
- vnode_setAttr(journal, virtualNode, property, serializedValue);
24980
- }
24981
- break;
24982
- case 1 /* QRL_RESOLVE */: {
24983
- const target = chore.$target$;
24984
- returnValue = !target.resolved ? target.resolve() : null;
24985
- break;
24986
- }
24987
- case 8 /* RECOMPUTE_AND_SCHEDULE_EFFECTS */: {
24988
- const target = chore.$target$;
24989
- const forceRunEffects = target.$forceRunEffects$;
24990
- target.$forceRunEffects$ = false;
24991
- if (!target.$effects$?.length) {
25170
+ }
25171
+ break;
25172
+ case 48 /* CLEANUP_VISIBLE */:
25173
+ {
25174
+ const task = chore.$payload$;
25175
+ cleanupTask(task);
25176
+ }
25177
+ break;
25178
+ case 4 /* NODE_DIFF */:
25179
+ {
25180
+ const parentVirtualNode = chore.$target$;
25181
+ let jsx4 = chore.$payload$;
25182
+ if (isSignal(jsx4)) {
25183
+ jsx4 = jsx4.value;
25184
+ }
25185
+ returnValue = retryOnPromise(
25186
+ () => vnode_diff(container, jsx4, parentVirtualNode, null)
25187
+ );
25188
+ }
25189
+ break;
25190
+ case 5 /* NODE_PROP */:
25191
+ {
25192
+ const virtualNode = chore.$host$;
25193
+ const payload = chore.$payload$;
25194
+ let value = payload.$value$;
25195
+ if (isSignal(value)) {
25196
+ value = value.value;
25197
+ }
25198
+ const isConst = payload.$isConst$;
25199
+ const journal = container.$journal$;
25200
+ const property = chore.$idx$;
25201
+ const serializedValue = serializeAttribute(
25202
+ property,
25203
+ value,
25204
+ payload.$scopedStyleIdPrefix$
25205
+ );
25206
+ if (isConst) {
25207
+ const element = virtualNode[6 /* element */];
25208
+ journal.push(2 /* SetAttribute */, element, property, serializedValue);
25209
+ } else {
25210
+ vnode_setAttr(journal, virtualNode, property, serializedValue);
25211
+ }
25212
+ }
25213
+ break;
25214
+ case 1 /* QRL_RESOLVE */: {
25215
+ {
25216
+ const target = chore.$target$;
25217
+ returnValue = !target.resolved ? target.resolve() : null;
25218
+ }
24992
25219
  break;
24993
25220
  }
24994
- returnValue = retryOnPromise(() => {
24995
- if (target.$computeIfNeeded$() || forceRunEffects) {
24996
- triggerEffects(container, target, target.$effects$);
25221
+ case 7 /* RECOMPUTE_AND_SCHEDULE_EFFECTS */: {
25222
+ {
25223
+ const target = chore.$target$;
25224
+ const forceRunEffects = target.$forceRunEffects$;
25225
+ target.$forceRunEffects$ = false;
25226
+ if (!target.$effects$?.size) {
25227
+ break;
25228
+ }
25229
+ returnValue = retryOnPromise(() => {
25230
+ if (target.$computeIfNeeded$() || forceRunEffects) {
25231
+ triggerEffects(container, target, target.$effects$);
25232
+ }
25233
+ });
24997
25234
  }
24998
- });
24999
- break;
25235
+ break;
25236
+ }
25000
25237
  }
25238
+ } catch (e) {
25239
+ returnValue = Promise.reject(e);
25001
25240
  }
25002
- return maybeThenPassError(returnValue, (value) => {
25003
- DEBUG2 && debugTrace("execute.DONE", null, currentChore, choreQueue);
25004
- if (currentChore) {
25005
- currentChore.$executed$ = true;
25006
- currentChore.$resolve$?.(value);
25007
- }
25241
+ const after = (value, error) => {
25008
25242
  currentChore = null;
25009
- return chore.$returnValue$ = value;
25010
- });
25011
- }
25012
- };
25013
- var toNumber = (value) => {
25014
- return typeof value === "number" ? value : -1;
25015
- };
25016
- var choreUpdate = (existing, newChore) => {
25017
- if (existing.$type$ === 4 /* NODE_DIFF */) {
25018
- existing.$payload$ = newChore.$payload$;
25019
- }
25020
- };
25021
- function vNodeAlreadyDeleted(chore) {
25022
- return !!(chore.$host$ && vnode_isVNode(chore.$host$) && chore.$host$[0 /* flags */] & 32 /* Deleted */);
25023
- }
25024
- function choreComparator(a, b, rootVNode) {
25025
- const macroTypeDiff = (a.$type$ & 240 /* MACRO */) - (b.$type$ & 240 /* MACRO */);
25026
- if (macroTypeDiff !== 0) {
25027
- return macroTypeDiff;
25243
+ chore.$executed$ = true;
25244
+ if (error) {
25245
+ DEBUG2 && debugTrace("execute.ERROR", chore, currentChore, choreQueue);
25246
+ container.handleError(error, host);
25247
+ } else {
25248
+ chore.$returnValue$ = value;
25249
+ DEBUG2 && debugTrace("execute.DONE", chore, currentChore, choreQueue);
25250
+ chore.$resolve$?.(value);
25251
+ }
25252
+ };
25253
+ if (isPromise(returnValue)) {
25254
+ chore.$promise$ = returnValue.then(after, (error) => after(void 0, error));
25255
+ chore.$resolve$?.(chore.$promise$);
25256
+ chore.$resolve$ = void 0;
25257
+ } else {
25258
+ after(returnValue);
25259
+ }
25028
25260
  }
25029
- if (a.$type$ !== 16 /* JOURNAL_FLUSH */) {
25261
+ function choreComparator(a, b, rootVNode) {
25262
+ const macroTypeDiff = (a.$type$ & 240 /* MACRO */) - (b.$type$ & 240 /* MACRO */);
25263
+ if (macroTypeDiff !== 0) {
25264
+ return macroTypeDiff;
25265
+ }
25030
25266
  const aHost = a.$host$;
25031
25267
  const bHost = b.$host$;
25032
25268
  if (aHost !== bHost && aHost !== null && bHost !== null) {
@@ -25036,6 +25272,8 @@ function choreComparator(a, b, rootVNode) {
25036
25272
  return hostDiff;
25037
25273
  }
25038
25274
  } else {
25275
+ assertFalse(vnode_isVNode(aHost), "expected aHost to be SSRNode but it is a VNode");
25276
+ assertFalse(vnode_isVNode(bHost), "expected bHost to be SSRNode but it is a VNode");
25039
25277
  const errorMessage = `SERVER: during HTML streaming, re-running tasks on a different host is not allowed.
25040
25278
  You are attempting to change a state that has already been streamed to the client.
25041
25279
  This can lead to inconsistencies between Server-Side Rendering (SSR) and Client-Side Rendering (CSR).
@@ -25055,165 +25293,89 @@ function choreComparator(a, b, rootVNode) {
25055
25293
  if (idxDiff !== 0) {
25056
25294
  return idxDiff;
25057
25295
  }
25058
- if (a.$target$ !== b.$target$ && (a.$type$ === 1 /* QRL_RESOLVE */ && b.$type$ === 1 /* QRL_RESOLVE */ || a.$type$ === 5 /* NODE_PROP */ && b.$type$ === 5 /* NODE_PROP */ || a.$type$ === 8 /* RECOMPUTE_AND_SCHEDULE_EFFECTS */ && b.$type$ === 8 /* RECOMPUTE_AND_SCHEDULE_EFFECTS */)) {
25296
+ if (a.$target$ !== b.$target$ || a.$payload$ !== b.$payload$) {
25059
25297
  return 1;
25060
25298
  }
25061
- }
25062
- return 0;
25063
- }
25064
- function sortedFindIndex(sortedArray, value, rootVNode) {
25065
- let bottom = 0;
25066
- let top = sortedArray.length;
25067
- while (bottom < top) {
25068
- const middle = bottom + (top - bottom >> 1);
25069
- const midChore = sortedArray[middle];
25070
- const comp = choreComparator(value, midChore, rootVNode);
25071
- if (comp < 0) {
25072
- top = middle;
25073
- } else if (comp > 0) {
25074
- bottom = middle + 1;
25075
- } else {
25076
- return middle;
25077
- }
25078
- }
25079
- return ~bottom;
25080
- }
25081
- function sortedInsert(sortedArray, value, rootVNode) {
25082
- const idx = sortedFindIndex(sortedArray, value, rootVNode);
25083
- if (idx < 0) {
25084
- sortedArray.splice(~idx, 0, value);
25085
- return value;
25086
- }
25087
- const existing = sortedArray[idx];
25088
- choreUpdate(existing, value);
25089
- return existing;
25090
- }
25091
- function debugChoreToString(chore) {
25092
- const type = {
25093
- [1 /* QRL_RESOLVE */]: "QRL_RESOLVE",
25094
- [2 /* RESOURCE */]: "RESOURCE",
25095
- [3 /* TASK */]: "TASK",
25096
- [4 /* NODE_DIFF */]: "NODE_DIFF",
25097
- [5 /* NODE_PROP */]: "NODE_PROP",
25098
- [7 /* COMPONENT */]: "COMPONENT",
25099
- [6 /* COMPONENT_SSR */]: "COMPONENT_SSR",
25100
- [8 /* RECOMPUTE_AND_SCHEDULE_EFFECTS */]: "RECOMPUTE_SIGNAL",
25101
- [16 /* JOURNAL_FLUSH */]: "JOURNAL_FLUSH",
25102
- [32 /* VISIBLE */]: "VISIBLE",
25103
- [48 /* CLEANUP_VISIBLE */]: "CLEANUP_VISIBLE",
25104
- [255 /* WAIT_FOR_ALL */]: "WAIT_FOR_ALL"
25105
- }[chore.$type$] || "UNKNOWN: " + chore.$type$;
25106
- const host = String(chore.$host$).replaceAll(/\n.*/gim, "");
25107
- const qrlTarget = chore.$target$?.$symbol$;
25108
- return `Chore(${type} ${chore.$type$ === 1 /* QRL_RESOLVE */ ? qrlTarget : host} ${chore.$idx$})`;
25109
- }
25110
- function debugTrace(action, arg, currentChore, queue) {
25111
- const lines = ["Scheduler: " + action];
25112
- if (arg) {
25113
- lines.push(
25114
- " arg: " + ("$type$" in arg ? debugChoreToString(arg) : String(arg).replaceAll(/\n.*/gim, ""))
25115
- );
25116
- }
25117
- if (currentChore) {
25118
- lines.push("running: " + debugChoreToString(currentChore));
25119
- }
25120
- if (queue) {
25121
- queue.forEach((chore, idx) => {
25122
- lines.push((idx == 0 ? " queue: " : " ") + debugChoreToString(chore));
25123
- });
25124
- }
25125
- console.log(lines.join("\n ") + "\n");
25126
- }
25127
-
25128
- // packages/qwik/src/core/use/use-task.ts
25129
- var runTask = (task, container, host) => {
25130
- task.$flags$ &= ~8 /* DIRTY */;
25131
- cleanupTask(task);
25132
- const iCtx = newInvokeContext(container.$locale$, host, void 0, TaskEvent);
25133
- iCtx.$container$ = container;
25134
- const taskFn = task.$qrl$.getFn(
25135
- iCtx,
25136
- () => clearSubscriberEffectDependencies(container, task)
25137
- );
25138
- const track = (obj, prop) => {
25139
- const ctx = newInvokeContext();
25140
- ctx.$effectSubscriber$ = [task, ":" /* COMPONENT */];
25141
- ctx.$container$ = container;
25142
- return invoke(ctx, () => {
25143
- if (isFunction(obj)) {
25144
- return obj();
25145
- }
25146
- if (prop) {
25147
- return obj[prop];
25148
- } else if (isSignal(obj)) {
25149
- return obj.value;
25150
- } else {
25151
- return obj;
25152
- }
25153
- });
25154
- };
25155
- const handleError = (reason) => container.handleError(reason, host);
25156
- let cleanupFns = null;
25157
- const cleanup2 = (fn) => {
25158
- if (typeof fn == "function") {
25159
- if (!cleanupFns) {
25160
- cleanupFns = [];
25161
- task.$destroy$ = noSerialize(() => {
25162
- task.$destroy$ = null;
25163
- cleanupFns.forEach((fn2) => {
25164
- try {
25165
- fn2();
25166
- } catch (err) {
25167
- handleError(err);
25168
- }
25169
- });
25170
- });
25171
- }
25172
- cleanupFns.push(fn);
25173
- }
25174
- };
25175
- const taskApi = { track, cleanup: cleanup2 };
25176
- const result = safeCall(
25177
- () => taskFn(taskApi),
25178
- cleanup2,
25179
- (err) => {
25180
- if (isPromise(err)) {
25181
- return err.then(() => runTask(task, container, host));
25182
- } else {
25183
- return handleError(err);
25184
- }
25185
- }
25186
- );
25187
- return result;
25188
- };
25189
- var cleanupTask = (task) => {
25190
- const destroy = task.$destroy$;
25191
- if (destroy) {
25192
- task.$destroy$ = null;
25193
- try {
25194
- destroy();
25195
- } catch (err) {
25196
- logError(err);
25299
+ if (b === currentChore) {
25300
+ return 1;
25197
25301
  }
25302
+ return 0;
25198
25303
  }
25199
- };
25200
- var Task = class extends Subscriber {
25201
- constructor($flags$, $index$, $el$, $qrl$, $state$, $destroy$) {
25202
- super();
25203
- this.$flags$ = $flags$;
25204
- this.$index$ = $index$;
25205
- this.$el$ = $el$;
25206
- this.$qrl$ = $qrl$;
25207
- this.$state$ = $state$;
25208
- this.$destroy$ = $destroy$;
25304
+ function sortedFindIndex(sortedArray, value, rootVNode) {
25305
+ let bottom = 0;
25306
+ let top = sortedArray.length;
25307
+ while (bottom < top) {
25308
+ const middle = bottom + (top - bottom >> 1);
25309
+ const midChore = sortedArray[middle];
25310
+ const comp = choreComparator(value, midChore, rootVNode);
25311
+ if (comp < 0) {
25312
+ top = middle;
25313
+ } else if (comp > 0) {
25314
+ bottom = middle + 1;
25315
+ } else {
25316
+ return middle;
25317
+ }
25318
+ }
25319
+ return ~bottom;
25320
+ }
25321
+ function sortedInsert(sortedArray, value, rootVNode) {
25322
+ const idx = sortedFindIndex(sortedArray, value, rootVNode);
25323
+ if (idx < 0) {
25324
+ sortedArray.splice(~idx, 0, value);
25325
+ return value;
25326
+ }
25327
+ const existing = sortedArray[idx];
25328
+ if (existing.$type$ === 4 /* NODE_DIFF */) {
25329
+ existing.$payload$ = value.$payload$;
25330
+ }
25331
+ if (existing.$executed$) {
25332
+ existing.$executed$ = false;
25333
+ }
25334
+ return existing;
25209
25335
  }
25210
25336
  };
25211
- var isTask = (value) => {
25212
- return value instanceof Task;
25337
+ var toNumber = (value) => {
25338
+ return typeof value === "number" ? value : -1;
25213
25339
  };
25214
-
25215
- // packages/qwik/src/core/signal/flags.ts
25216
- var NEEDS_COMPUTATION = Symbol("invalid");
25340
+ function vNodeAlreadyDeleted(chore) {
25341
+ return !!(chore.$host$ && vnode_isVNode(chore.$host$) && chore.$host$[0 /* flags */] & 32 /* Deleted */);
25342
+ }
25343
+ function debugChoreTypeToString(type) {
25344
+ return {
25345
+ [1 /* QRL_RESOLVE */]: "QRL_RESOLVE",
25346
+ [2 /* RUN_QRL */]: "RUN_QRL",
25347
+ [3 /* TASK */]: "TASK",
25348
+ [4 /* NODE_DIFF */]: "NODE_DIFF",
25349
+ [5 /* NODE_PROP */]: "NODE_PROP",
25350
+ [6 /* COMPONENT */]: "COMPONENT",
25351
+ [7 /* RECOMPUTE_AND_SCHEDULE_EFFECTS */]: "RECOMPUTE_SIGNAL",
25352
+ [16 /* JOURNAL_FLUSH */]: "JOURNAL_FLUSH",
25353
+ [32 /* VISIBLE */]: "VISIBLE",
25354
+ [48 /* CLEANUP_VISIBLE */]: "CLEANUP_VISIBLE",
25355
+ [255 /* WAIT_FOR_ALL */]: "WAIT_FOR_ALL"
25356
+ }[type] || "UNKNOWN: " + type;
25357
+ }
25358
+ function debugChoreToString(chore) {
25359
+ const type = debugChoreTypeToString(chore.$type$);
25360
+ const host = String(chore.$host$).replaceAll(/\n.*/gim, "");
25361
+ const qrlTarget = chore.$target$?.$symbol$;
25362
+ return `Chore(${type} ${chore.$type$ === 1 /* QRL_RESOLVE */ || chore.$type$ === 2 /* RUN_QRL */ ? qrlTarget : host} ${chore.$idx$})`;
25363
+ }
25364
+ function debugTrace(action, arg, currentChore, queue) {
25365
+ const lines = ["===========================\nScheduler: " + action];
25366
+ if (arg && !("$type$" in arg)) {
25367
+ lines.push(" arg: " + String(arg).replaceAll(/\n.*/gim, ""));
25368
+ }
25369
+ if (queue) {
25370
+ queue.forEach((chore) => {
25371
+ const active = chore === arg ? ">>>" : " ";
25372
+ lines.push(
25373
+ ` ${active} > ` + (chore === currentChore ? "[running] " : "") + debugChoreToString(chore)
25374
+ );
25375
+ });
25376
+ }
25377
+ console.log(lines.join("\n") + "\n");
25378
+ }
25217
25379
 
25218
25380
  // packages/qwik/src/core/signal/signal.ts
25219
25381
  var DEBUG3 = false;
@@ -25227,7 +25389,7 @@ var throwIfQRLNotResolved = (qrl2) => {
25227
25389
  var isSignal = (value) => {
25228
25390
  return value instanceof Signal;
25229
25391
  };
25230
- var EffectPropData = class {
25392
+ var SubscriptionData = class {
25231
25393
  constructor(data) {
25232
25394
  __publicField(this, "data");
25233
25395
  this.data = data;
@@ -25266,16 +25428,10 @@ var Signal = class {
25266
25428
  }
25267
25429
  const effectSubscriber = ctx.$effectSubscriber$;
25268
25430
  if (effectSubscriber) {
25269
- const effects = this.$effects$ || (this.$effects$ = []);
25270
- ensureContainsEffect(effects, effectSubscriber);
25271
- ensureContains(effectSubscriber, this);
25272
- if (isSubscriber(this)) {
25273
- ensureEffectContainsSubscriber(
25274
- effectSubscriber[0 /* EFFECT */],
25275
- this,
25276
- this.$container$
25277
- );
25278
- }
25431
+ const effects = this.$effects$ || (this.$effects$ = /* @__PURE__ */ new Set());
25432
+ ensureContainsSubscription(effects, effectSubscriber);
25433
+ ensureContainsBackRef(effectSubscriber, this);
25434
+ addQrlToSerializationCtx(effectSubscriber, this.$container$);
25279
25435
  DEBUG3 && log2("read->sub", pad("\n" + this.toString(), " "));
25280
25436
  }
25281
25437
  }
@@ -25295,119 +25451,92 @@ var Signal = class {
25295
25451
  }
25296
25452
  }
25297
25453
  toString() {
25298
- return `[${this.constructor.name}${this.$invalid$ ? " INVALID" : ""} ${String(this.$untrackedValue$)}]` + (this.$effects$?.map((e) => "\n -> " + pad(qwikDebugToString(e[0]), " ")).join("\n") || "");
25454
+ return `[${this.constructor.name}${this.$flags$ & 1 /* INVALID */ ? " INVALID" : ""} ${String(this.$untrackedValue$)}]` + (Array.from(this.$effects$ || []).map((e) => "\n -> " + pad(qwikDebugToString(e[0]), " ")).join("\n") || "");
25299
25455
  }
25300
25456
  toJSON() {
25301
25457
  return { value: this.$untrackedValue$ };
25302
25458
  }
25303
25459
  };
25304
- var ensureContains = (array, value) => {
25305
- const isMissing = array.indexOf(value) === -1;
25306
- if (isMissing) {
25307
- array.push(value);
25308
- }
25309
- };
25310
- var ensureContainsEffect = (array, effectSubscriptions) => {
25311
- for (let i = 0; i < array.length; i++) {
25312
- const existingEffect = array[i];
25313
- if (existingEffect[0] === effectSubscriptions[0] && existingEffect[1] === effectSubscriptions[1]) {
25314
- return;
25315
- }
25316
- }
25317
- array.push(effectSubscriptions);
25318
- };
25319
- var ensureEffectContainsSubscriber = (effect, subscriber, container) => {
25320
- if (isSubscriber(effect)) {
25321
- effect.$effectDependencies$ || (effect.$effectDependencies$ = []);
25322
- if (subscriberExistInSubscribers(effect.$effectDependencies$, subscriber)) {
25323
- return;
25324
- }
25325
- effect.$effectDependencies$.push(subscriber);
25326
- } else if (vnode_isVNode(effect) && !vnode_isTextVNode(effect)) {
25327
- let subscribers = vnode_getProp(
25328
- effect,
25329
- QSubscribers,
25330
- container ? container.$getObjectById$ : null
25331
- );
25332
- subscribers || (subscribers = []);
25333
- if (subscriberExistInSubscribers(subscribers, subscriber)) {
25334
- return;
25335
- }
25336
- subscribers.push(subscriber);
25337
- vnode_setProp(effect, QSubscribers, subscribers);
25338
- } else if (isSSRNode(effect)) {
25339
- let subscribers = effect.getProp(QSubscribers);
25340
- subscribers || (subscribers = []);
25341
- if (subscriberExistInSubscribers(subscribers, subscriber)) {
25342
- return;
25343
- }
25344
- subscribers.push(subscriber);
25345
- effect.setProp(QSubscribers, subscribers);
25346
- }
25460
+ var ensureContainsSubscription = (array, effectSubscription) => {
25461
+ array.add(effectSubscription);
25347
25462
  };
25348
- var isSSRNode = (effect) => {
25349
- return "setProp" in effect && "getProp" in effect && "removeProp" in effect && "id" in effect;
25463
+ var ensureContainsBackRef = (array, value) => {
25464
+ var _a4;
25465
+ array[_a4 = 2 /* BACK_REF */] || (array[_a4] = /* @__PURE__ */ new Set());
25466
+ array[2 /* BACK_REF */].add(value);
25350
25467
  };
25351
- var subscriberExistInSubscribers = (subscribers, subscriber) => {
25352
- for (let i = 0; i < subscribers.length; i++) {
25353
- if (subscribers[i] === subscriber) {
25354
- return true;
25468
+ var addQrlToSerializationCtx = (effectSubscriber, container) => {
25469
+ if (!!container && !isDomContainer(container)) {
25470
+ const effect = effectSubscriber[0 /* CONSUMER */];
25471
+ const property = effectSubscriber[1 /* PROPERTY */];
25472
+ let qrl2 = null;
25473
+ if (isTask(effect)) {
25474
+ qrl2 = effect.$qrl$;
25475
+ } else if (effect instanceof ComputedSignal) {
25476
+ qrl2 = effect.$computeQrl$;
25477
+ } else if (property === ":" /* COMPONENT */) {
25478
+ qrl2 = container.getHostProp(effect, OnRenderProp);
25479
+ }
25480
+ if (qrl2) {
25481
+ container.serializationCtx.$eventQrls$.add(qrl2);
25355
25482
  }
25356
25483
  }
25357
- return false;
25358
25484
  };
25359
25485
  var triggerEffects = (container, signal, effects) => {
25486
+ const isBrowser2 = isDomContainer(container);
25360
25487
  if (effects) {
25361
- const scheduleEffect = (effectSubscriptions) => {
25362
- const effect = effectSubscriptions[0 /* EFFECT */];
25363
- const property = effectSubscriptions[1 /* PROPERTY */];
25488
+ const scheduleEffect = (effectSubscription) => {
25489
+ const consumer = effectSubscription[0 /* CONSUMER */];
25490
+ const property = effectSubscription[1 /* PROPERTY */];
25364
25491
  assertDefined(container, "Container must be defined.");
25365
- if (isTask(effect)) {
25366
- effect.$flags$ |= 8 /* DIRTY */;
25367
- DEBUG3 && log2("schedule.effect.task", pad("\n" + String(effect), " "));
25492
+ if (isTask(consumer)) {
25493
+ consumer.$flags$ |= 8 /* DIRTY */;
25494
+ DEBUG3 && log2("schedule.consumer.task", pad("\n" + String(consumer), " "));
25368
25495
  let choreType = 3 /* TASK */;
25369
- if (effect.$flags$ & 1 /* VISIBLE_TASK */) {
25496
+ if (consumer.$flags$ & 1 /* VISIBLE_TASK */) {
25370
25497
  choreType = 32 /* VISIBLE */;
25371
- } else if (effect.$flags$ & 4 /* RESOURCE */) {
25372
- choreType = 2 /* RESOURCE */;
25373
25498
  }
25374
- container.$scheduler$(choreType, effect);
25375
- } else if (effect instanceof Signal) {
25376
- if (effect instanceof ComputedSignal) {
25377
- if (!effect.$computeQrl$.resolved) {
25378
- container.$scheduler$(1 /* QRL_RESOLVE */, null, effect.$computeQrl$);
25499
+ container.$scheduler$(choreType, consumer);
25500
+ } else if (consumer instanceof Signal) {
25501
+ if (consumer instanceof ComputedSignal) {
25502
+ if (!consumer.$computeQrl$.resolved) {
25503
+ container.$scheduler$(1 /* QRL_RESOLVE */, null, consumer.$computeQrl$);
25379
25504
  }
25380
25505
  }
25381
- effect.$invalidate$();
25506
+ consumer.$invalidate$();
25382
25507
  } else if (property === ":" /* COMPONENT */) {
25383
- const host = effect;
25508
+ const host = consumer;
25384
25509
  const qrl2 = container.getHostProp(host, OnRenderProp);
25385
25510
  assertDefined(qrl2, "Component must have QRL");
25386
25511
  const props = container.getHostProp(host, ELEMENT_PROPS);
25387
- container.$scheduler$(7 /* COMPONENT */, host, qrl2, props);
25388
- } else if (property === "." /* VNODE */) {
25389
- const host = effect;
25390
- const target = host;
25391
- container.$scheduler$(4 /* NODE_DIFF */, host, target, signal);
25392
- } else {
25393
- const host = effect;
25394
- const effectData = effectSubscriptions[2 /* FIRST_BACK_REF_OR_DATA */];
25395
- if (effectData instanceof EffectPropData) {
25396
- const data = effectData.data;
25397
- const payload = {
25398
- ...data,
25399
- $value$: signal
25400
- };
25401
- container.$scheduler$(5 /* NODE_PROP */, host, property, payload);
25512
+ container.$scheduler$(6 /* COMPONENT */, host, qrl2, props);
25513
+ } else if (isBrowser2) {
25514
+ if (property === "." /* VNODE */) {
25515
+ const host = consumer;
25516
+ container.$scheduler$(4 /* NODE_DIFF */, host, host, signal);
25517
+ } else {
25518
+ const host = consumer;
25519
+ const effectData = effectSubscription[3 /* DATA */];
25520
+ if (effectData instanceof SubscriptionData) {
25521
+ const data = effectData.data;
25522
+ const payload = {
25523
+ ...data,
25524
+ $value$: signal
25525
+ };
25526
+ container.$scheduler$(5 /* NODE_PROP */, host, property, payload);
25527
+ }
25402
25528
  }
25403
25529
  }
25404
25530
  };
25405
- effects.forEach(scheduleEffect);
25531
+ for (const effect of effects) {
25532
+ scheduleEffect(effect);
25533
+ }
25406
25534
  }
25407
25535
  DEBUG3 && log2("done scheduling");
25408
25536
  };
25409
- var ComputedSignal = class extends Signal {
25410
- constructor(container, fn) {
25537
+ var _a2, _b;
25538
+ var ComputedSignal = class extends (_b = Signal, _a2 = _EFFECT_BACK_REF, _b) {
25539
+ constructor(container, fn, flags = 1 /* INVALID */) {
25411
25540
  super(container, NEEDS_COMPUTATION);
25412
25541
  /**
25413
25542
  * The compute function is stored here.
@@ -25416,23 +25545,23 @@ var ComputedSignal = class extends Signal {
25416
25545
  * resolve the QRL during the mark dirty phase so that any call to it will be synchronous). )
25417
25546
  */
25418
25547
  __publicField(this, "$computeQrl$");
25419
- // We need a separate flag to know when the computation needs running because
25420
- // we need the old value to know if effects need running after computation
25421
- __publicField(this, "$invalid$", true);
25548
+ __publicField(this, "$flags$");
25422
25549
  __publicField(this, "$forceRunEffects$", false);
25550
+ __publicField(this, _a2, null);
25423
25551
  this.$computeQrl$ = fn;
25552
+ this.$flags$ = flags;
25424
25553
  }
25425
25554
  $invalidate$() {
25426
- this.$invalid$ = true;
25555
+ this.$flags$ |= 1 /* INVALID */;
25427
25556
  this.$forceRunEffects$ = false;
25428
- this.$container$?.$scheduler$(8 /* RECOMPUTE_AND_SCHEDULE_EFFECTS */, null, this);
25557
+ this.$container$?.$scheduler$(7 /* RECOMPUTE_AND_SCHEDULE_EFFECTS */, null, this);
25429
25558
  }
25430
25559
  /**
25431
25560
  * Use this to force running subscribers, for example when the calculated value has mutated but
25432
25561
  * remained the same object
25433
25562
  */
25434
25563
  force() {
25435
- this.$invalid$ = true;
25564
+ this.$flags$ |= 1 /* INVALID */;
25436
25565
  this.$forceRunEffects$ = false;
25437
25566
  triggerEffects(this.$container$, this, this.$effects$);
25438
25567
  }
@@ -25445,14 +25574,14 @@ var ComputedSignal = class extends Signal {
25445
25574
  return this.$untrackedValue$;
25446
25575
  }
25447
25576
  $computeIfNeeded$() {
25448
- if (!this.$invalid$) {
25577
+ if (!(this.$flags$ & 1 /* INVALID */)) {
25449
25578
  return false;
25450
25579
  }
25451
25580
  const computeQrl = this.$computeQrl$;
25452
25581
  throwIfQRLNotResolved(computeQrl);
25453
25582
  const ctx = tryGetInvokeContext();
25454
25583
  const previousEffectSubscription = ctx?.$effectSubscriber$;
25455
- ctx && (ctx.$effectSubscriber$ = [this, "." /* VNODE */]);
25584
+ ctx && (ctx.$effectSubscriber$ = getSubscriber(this, "." /* VNODE */));
25456
25585
  try {
25457
25586
  const untrackedValue = computeQrl.getFn(ctx)();
25458
25587
  if (isPromise(untrackedValue)) {
@@ -25462,7 +25591,7 @@ var ComputedSignal = class extends Signal {
25462
25591
  ]);
25463
25592
  }
25464
25593
  DEBUG3 && log2("Signal.$compute$", untrackedValue);
25465
- this.$invalid$ = false;
25594
+ this.$flags$ &= ~1 /* INVALID */;
25466
25595
  const didChange = untrackedValue !== this.$untrackedValue$;
25467
25596
  if (didChange) {
25468
25597
  this.$untrackedValue$ = untrackedValue;
@@ -25482,27 +25611,27 @@ var ComputedSignal = class extends Signal {
25482
25611
  throw qError(47 /* computedReadOnly */);
25483
25612
  }
25484
25613
  };
25485
- var WrappedSignal = class extends Signal {
25486
- constructor(container, fn, args, fnStr) {
25614
+ var _a3, _b2;
25615
+ var WrappedSignal = class extends (_b2 = Signal, _a3 = _EFFECT_BACK_REF, _b2) {
25616
+ constructor(container, fn, args, fnStr, flags = 1 /* INVALID */ | 2 /* UNWRAP */) {
25487
25617
  super(container, NEEDS_COMPUTATION);
25488
25618
  __publicField(this, "$args$");
25489
25619
  __publicField(this, "$func$");
25490
25620
  __publicField(this, "$funcStr$");
25491
- // We need a separate flag to know when the computation needs running because
25492
- // we need the old value to know if effects need running after computation
25493
- __publicField(this, "$invalid$", true);
25494
- __publicField(this, "$effectDependencies$", null);
25621
+ __publicField(this, "$flags$");
25495
25622
  __publicField(this, "$hostElement$", null);
25496
25623
  __publicField(this, "$forceRunEffects$", false);
25624
+ __publicField(this, _a3, null);
25497
25625
  this.$args$ = args;
25498
25626
  this.$func$ = fn;
25499
25627
  this.$funcStr$ = fnStr;
25628
+ this.$flags$ = flags;
25500
25629
  }
25501
25630
  $invalidate$() {
25502
- this.$invalid$ = true;
25631
+ this.$flags$ |= 1 /* INVALID */;
25503
25632
  this.$forceRunEffects$ = false;
25504
25633
  this.$container$?.$scheduler$(
25505
- 8 /* RECOMPUTE_AND_SCHEDULE_EFFECTS */,
25634
+ 7 /* RECOMPUTE_AND_SCHEDULE_EFFECTS */,
25506
25635
  this.$hostElement$,
25507
25636
  this
25508
25637
  );
@@ -25512,7 +25641,7 @@ var WrappedSignal = class extends Signal {
25512
25641
  * remained the same object
25513
25642
  */
25514
25643
  force() {
25515
- this.$invalid$ = true;
25644
+ this.$flags$ |= 1 /* INVALID */;
25516
25645
  this.$forceRunEffects$ = false;
25517
25646
  triggerEffects(this.$container$, this, this.$effects$);
25518
25647
  }
@@ -25525,7 +25654,7 @@ var WrappedSignal = class extends Signal {
25525
25654
  return this.$untrackedValue$;
25526
25655
  }
25527
25656
  $computeIfNeeded$() {
25528
- if (!this.$invalid$) {
25657
+ if (!(this.$flags$ & 1 /* INVALID */)) {
25529
25658
  return false;
25530
25659
  }
25531
25660
  const untrackedValue = trackSignal(
@@ -25591,16 +25720,6 @@ var _SharedContainer = class {
25591
25720
  }
25592
25721
  };
25593
25722
 
25594
- // packages/qwik/src/core/shared/utils/constants.ts
25595
- var QObjectRecursive = 1 << 0;
25596
- var QObjectImmutable = 1 << 1;
25597
- var QObjectTargetSymbol = Symbol("proxy target");
25598
- var QObjectFlagsSymbol = Symbol("proxy flags");
25599
- var QObjectManagerSymbol = Symbol("proxy manager");
25600
- var _CONST_PROPS = Symbol("CONST");
25601
- var _VAR_PROPS = Symbol("VAR");
25602
- var _IMMUTABLE = Symbol("IMMUTABLE");
25603
-
25604
25723
  // packages/qwik/src/core/shared-types.ts
25605
25724
  function isStringifiable(value) {
25606
25725
  return value === null || typeof value === "string" || typeof value === "number" || typeof value === "boolean";
@@ -25717,7 +25836,7 @@ var PropsProxyHandler = class {
25717
25836
  return this.$children$;
25718
25837
  }
25719
25838
  const value = this.$constProps$ && prop in this.$constProps$ ? this.$constProps$[prop] : this.$varProps$[prop];
25720
- return value instanceof WrappedSignal ? value.value : value;
25839
+ return value instanceof WrappedSignal && value.$flags$ & 2 /* UNWRAP */ ? value.value : value;
25721
25840
  }
25722
25841
  set(_, prop, value) {
25723
25842
  if (prop === _CONST_PROPS) {
@@ -25792,7 +25911,7 @@ function qwikDebugToString(value) {
25792
25911
  return String(value);
25793
25912
  } else if (isTask(value)) {
25794
25913
  return `Task(${qwikDebugToString(value.$qrl$)})`;
25795
- } else if (isQrl(value)) {
25914
+ } else if (isQrl2(value)) {
25796
25915
  return `Qrl(${value.$symbol$})`;
25797
25916
  } else if (typeof value === "object" || typeof value === "function") {
25798
25917
  if (stringifyPath.includes(value)) {
@@ -26070,13 +26189,13 @@ var VNodeDataChar = {
26070
26189
  /* ****** */
26071
26190
  ">"
26072
26191
  ),
26073
- SLOT_REF: (
26074
- /* *********** */
26192
+ SLOT_PARENT: (
26193
+ /* ******** */
26075
26194
  63
26076
26195
  ),
26077
- // `?` - `q:sref` - Slot reference.
26078
- SLOT_REF_CHAR: (
26079
- /* *** */
26196
+ // `?` - `q:sparent` - Slot parent.
26197
+ SLOT_PARENT_CHAR: (
26198
+ /* */
26080
26199
  "?"
26081
26200
  ),
26082
26201
  KEY: (
@@ -26121,13 +26240,13 @@ var VNodeDataChar = {
26121
26240
  /* **** */
26122
26241
  "^"
26123
26242
  ),
26124
- SUBS: (
26125
- /* *************** */
26243
+ BACK_REFS: (
26244
+ /* ********** */
26126
26245
  96
26127
26246
  ),
26128
- // '`' - `q:subs' - Effect dependencies/subscriptions
26129
- SUBS_CHAR: (
26130
- /* ******* */
26247
+ // '`' - `q:brefs' - Effect dependencies/subscriptions
26248
+ BACK_REFS_CHAR: (
26249
+ /* ** */
26131
26250
  "`"
26132
26251
  ),
26133
26252
  SEPARATOR: (
@@ -26150,6 +26269,14 @@ var VNodeDataChar = {
26150
26269
  )
26151
26270
  };
26152
26271
 
26272
+ // packages/qwik/src/core/shared/utils/maps.ts
26273
+ var mergeMaps = (map1, map2) => {
26274
+ for (const [k, v] of map2) {
26275
+ map1.set(k, v);
26276
+ }
26277
+ return map1;
26278
+ };
26279
+
26153
26280
  // packages/qwik/src/core/client/vnode.ts
26154
26281
  var vnode_newElement = (element, elementName) => {
26155
26282
  assertEqual(fastNodeType(element), 1, "Expecting element node.");
@@ -26272,6 +26399,11 @@ var vnode_isVirtualVNode = (vNode) => {
26272
26399
  const flag = vNode[0 /* flags */];
26273
26400
  return (flag & 2 /* Virtual */) === 2 /* Virtual */;
26274
26401
  };
26402
+ var vnode_isProjection = (vNode) => {
26403
+ assertDefined(vNode, "Missing vNode");
26404
+ const flag = vNode[0 /* flags */];
26405
+ return (flag & 2 /* Virtual */) === 2 /* Virtual */ && vnode_getProp(vNode, QSlot, null) !== null;
26406
+ };
26275
26407
  var ensureTextVNode = (vNode) => {
26276
26408
  assertTrue(vnode_isTextVNode(vNode), "Expecting TextVNode was: " + vnode_getNodeTypeName(vNode));
26277
26409
  return vNode;
@@ -26311,6 +26443,7 @@ var vnode_ensureElementInflated = (vnode) => {
26311
26443
  elementVNode[0 /* flags */] ^= 8 /* Inflated */;
26312
26444
  const element = elementVNode[6 /* element */];
26313
26445
  const attributes = element.attributes;
26446
+ const props = vnode_getProps(elementVNode);
26314
26447
  for (let idx = 0; idx < attributes.length; idx++) {
26315
26448
  const attr = attributes[idx];
26316
26449
  const key = attr.name;
@@ -26318,23 +26451,13 @@ var vnode_ensureElementInflated = (vnode) => {
26318
26451
  break;
26319
26452
  } else if (key.startsWith(QContainerAttr)) {
26320
26453
  if (attr.value === "html" /* HTML */) {
26321
- mapArray_set(
26322
- elementVNode,
26323
- dangerouslySetInnerHTML,
26324
- element.innerHTML,
26325
- 8 /* PROPS_OFFSET */
26326
- );
26454
+ mapArray_set(props, dangerouslySetInnerHTML, element.innerHTML, 0);
26327
26455
  } else if (attr.value === "text" /* TEXT */ && "value" in element) {
26328
- mapArray_set(
26329
- elementVNode,
26330
- "value",
26331
- element.value,
26332
- 8 /* PROPS_OFFSET */
26333
- );
26456
+ mapArray_set(props, "value", element.value, 0);
26334
26457
  }
26335
26458
  } else if (!key.startsWith("on:")) {
26336
26459
  const value = attr.value;
26337
- mapArray_set(elementVNode, key, value, 8 /* PROPS_OFFSET */);
26460
+ mapArray_set(props, key, value, 0);
26338
26461
  }
26339
26462
  }
26340
26463
  }
@@ -26346,7 +26469,9 @@ function vnode_walkVNode(vNode, callback) {
26346
26469
  }
26347
26470
  let vParent = null;
26348
26471
  do {
26349
- callback?.(vCursor, vParent);
26472
+ if (callback?.(vCursor, vParent)) {
26473
+ return;
26474
+ }
26350
26475
  const vFirstChild = vnode_getFirstChild(vCursor);
26351
26476
  if (vFirstChild) {
26352
26477
  vCursor = vFirstChild;
@@ -26622,7 +26747,7 @@ var vnode_applyJournal = (journal) => {
26622
26747
  if (isBooleanAttr(element, key)) {
26623
26748
  element[key] = parseBoolean(value);
26624
26749
  } else if (key === "value" && key in element) {
26625
- element.value = escapeHTML(String(value));
26750
+ element.value = String(value);
26626
26751
  } else if (key === dangerouslySetInnerHTML) {
26627
26752
  element.innerHTML = value;
26628
26753
  } else {
@@ -26662,59 +26787,14 @@ var vnode_applyJournal = (journal) => {
26662
26787
  }
26663
26788
  journal.length = 0;
26664
26789
  };
26665
- var mapApp_findIndx = (elementVNode, key, start) => {
26666
- assertTrue(start % 2 === 0, "Expecting even number.");
26667
- let bottom = start >> 1;
26668
- let top = elementVNode.length - 2 >> 1;
26669
- while (bottom <= top) {
26670
- const mid = bottom + (top - bottom >> 1);
26671
- const midKey = elementVNode[mid << 1];
26672
- if (midKey === key) {
26673
- return mid << 1;
26674
- }
26675
- if (midKey < key) {
26676
- bottom = mid + 1;
26677
- } else {
26678
- top = mid - 1;
26679
- }
26680
- }
26681
- return bottom << 1 ^ -1;
26682
- };
26683
- var mapArray_set = (elementVNode, key, value, start) => {
26684
- const indx = mapApp_findIndx(elementVNode, key, start);
26685
- if (indx >= 0) {
26686
- if (value == null) {
26687
- elementVNode.splice(indx, 2);
26688
- } else {
26689
- elementVNode[indx + 1] = value;
26690
- }
26691
- } else if (value != null) {
26692
- elementVNode.splice(indx ^ -1, 0, key, value);
26693
- }
26694
- };
26695
- var mapApp_remove = (elementVNode, key, start) => {
26696
- const indx = mapApp_findIndx(elementVNode, key, start);
26697
- let value = null;
26698
- if (indx >= 0) {
26699
- value = elementVNode[indx + 1];
26700
- elementVNode.splice(indx, 2);
26701
- return value;
26702
- }
26703
- return value;
26704
- };
26705
- var mapArray_get = (elementVNode, key, start) => {
26706
- const indx = mapApp_findIndx(elementVNode, key, start);
26707
- if (indx >= 0) {
26708
- return elementVNode[indx + 1];
26709
- } else {
26710
- return null;
26711
- }
26712
- };
26713
26790
  var vnode_insertBefore = (journal, parent, newChild, insertBefore) => {
26714
26791
  ensureElementOrVirtualVNode(parent);
26715
26792
  if (vnode_isElementVNode(parent)) {
26716
26793
  ensureMaterialized(parent);
26717
26794
  }
26795
+ if (newChild === insertBefore) {
26796
+ insertBefore = null;
26797
+ }
26718
26798
  let adjustedInsertBefore = null;
26719
26799
  if (insertBefore == null) {
26720
26800
  if (vnode_isVirtualVNode(parent)) {
@@ -26817,8 +26897,10 @@ var vnode_getElementName = (vnode) => {
26817
26897
  const elementVNode = ensureElementVNode(vnode);
26818
26898
  let elementName = elementVNode[7 /* elementName */];
26819
26899
  if (elementName === void 0) {
26820
- elementName = elementVNode[7 /* elementName */] = elementVNode[6 /* element */].nodeName.toLowerCase();
26821
- elementVNode[0 /* flags */] |= vnode_getElementNamespaceFlags(elementName);
26900
+ const element = elementVNode[6 /* element */];
26901
+ const nodeName = isDev7 ? fastNodeName(element).toLowerCase() : fastNodeName(element);
26902
+ elementName = elementVNode[7 /* elementName */] = nodeName;
26903
+ elementVNode[0 /* flags */] |= vnode_getElementNamespaceFlags(element);
26822
26904
  }
26823
26905
  return elementName;
26824
26906
  };
@@ -26984,6 +27066,20 @@ var fastFirstChild = (node) => {
26984
27066
  }
26985
27067
  return node;
26986
27068
  };
27069
+ var _fastNamespaceURI = null;
27070
+ var fastNamespaceURI = (element) => {
27071
+ if (!_fastNamespaceURI) {
27072
+ _fastNamespaceURI = fastGetter(element, "namespaceURI");
27073
+ }
27074
+ return _fastNamespaceURI.call(element);
27075
+ };
27076
+ var _fastNodeName = null;
27077
+ var fastNodeName = (element) => {
27078
+ if (!_fastNodeName) {
27079
+ _fastNodeName = fastGetter(element, "nodeName");
27080
+ }
27081
+ return _fastNodeName.call(element);
27082
+ };
26987
27083
  var fastGetter = (prototype, name) => {
26988
27084
  let getter;
26989
27085
  while (prototype && !(getter = Object.getOwnPropertyDescriptor(prototype, name)?.get)) {
@@ -27039,9 +27135,12 @@ var materializeFromDOM = (vParent, firstChild, vData) => {
27039
27135
  }
27040
27136
  const id = consumeValue();
27041
27137
  container.$setRawState$(parseInt(id), vParent);
27042
- isDev6 && vnode_setAttr(null, vParent, ELEMENT_ID, id);
27043
- } else if (peek() === VNodeDataChar.SUBS) {
27044
- vnode_setProp(vParent, QSubscribers, consumeValue());
27138
+ isDev7 && vnode_setAttr(null, vParent, ELEMENT_ID, id);
27139
+ } else if (peek() === VNodeDataChar.BACK_REFS) {
27140
+ if (!container) {
27141
+ container = getDomContainer(vParent[6 /* element */]);
27142
+ }
27143
+ setEffectBackRefFromVNodeData(vParent, consumeValue(), container);
27045
27144
  } else {
27046
27145
  consumeValue();
27047
27146
  }
@@ -27049,6 +27148,17 @@ var materializeFromDOM = (vParent, firstChild, vData) => {
27049
27148
  }
27050
27149
  return vFirstChild;
27051
27150
  };
27151
+ function setEffectBackRefFromVNodeData(vParent, value, container) {
27152
+ const deserializedSubMap = container.$getObjectById$(value);
27153
+ if (!vParent[_EFFECT_BACK_REF]) {
27154
+ Object.defineProperty(vParent, _EFFECT_BACK_REF, {
27155
+ value: deserializedSubMap
27156
+ });
27157
+ } else {
27158
+ const subMap = vParent[_EFFECT_BACK_REF];
27159
+ mergeMaps(subMap, deserializedSubMap);
27160
+ }
27161
+ }
27052
27162
  var processVNodeData = (vData, callback) => {
27053
27163
  let nextToConsumeIdx = 0;
27054
27164
  let ch = 0;
@@ -27089,8 +27199,9 @@ var vnode_getAttrKeys = (vnode) => {
27089
27199
  if ((type & 3 /* ELEMENT_OR_VIRTUAL_MASK */) !== 0) {
27090
27200
  vnode_ensureElementInflated(vnode);
27091
27201
  const keys = [];
27092
- for (let i = vnode_getPropStartIndex(vnode); i < vnode.length; i = i + 2) {
27093
- const key = vnode[i];
27202
+ const props = vnode_getProps(vnode);
27203
+ for (let i = 0; i < props.length; i = i + 2) {
27204
+ const key = props[i];
27094
27205
  if (!key.startsWith(Q_PROPS_SEPARATOR)) {
27095
27206
  keys.push(key);
27096
27207
  }
@@ -27103,19 +27214,20 @@ var vnode_setAttr = (journal, vnode, key, value) => {
27103
27214
  const type = vnode[0 /* flags */];
27104
27215
  if ((type & 3 /* ELEMENT_OR_VIRTUAL_MASK */) !== 0) {
27105
27216
  vnode_ensureElementInflated(vnode);
27106
- const idx = mapApp_findIndx(vnode, key, vnode_getPropStartIndex(vnode));
27217
+ const props = vnode_getProps(vnode);
27218
+ const idx = mapApp_findIndx(props, key, 0);
27107
27219
  if (idx >= 0) {
27108
- if (vnode[idx + 1] != value && (type & 1 /* Element */) !== 0) {
27220
+ if (props[idx + 1] != value && (type & 1 /* Element */) !== 0) {
27109
27221
  const element = vnode[6 /* element */];
27110
27222
  journal && journal.push(2 /* SetAttribute */, element, key, value);
27111
27223
  }
27112
27224
  if (value == null) {
27113
- vnode.splice(idx, 2);
27225
+ props.splice(idx, 2);
27114
27226
  } else {
27115
- vnode[idx + 1] = value;
27227
+ props[idx + 1] = value;
27116
27228
  }
27117
27229
  } else if (value != null) {
27118
- vnode.splice(idx ^ -1, 0, key, value);
27230
+ props.splice(idx ^ -1, 0, key, value);
27119
27231
  if ((type & 1 /* Element */) !== 0) {
27120
27232
  const element = vnode[6 /* element */];
27121
27233
  journal && journal.push(2 /* SetAttribute */, element, key, value);
@@ -27127,7 +27239,8 @@ var vnode_getAttr = (vnode, key) => {
27127
27239
  const type = vnode[0 /* flags */];
27128
27240
  if ((type & 3 /* ELEMENT_OR_VIRTUAL_MASK */) !== 0) {
27129
27241
  vnode_ensureElementInflated(vnode);
27130
- return mapArray_get(vnode, key, vnode_getPropStartIndex(vnode));
27242
+ const props = vnode_getProps(vnode);
27243
+ return mapArray_get(props, key, 0);
27131
27244
  }
27132
27245
  return null;
27133
27246
  };
@@ -27135,11 +27248,12 @@ var vnode_getProp = (vnode, key, getObject) => {
27135
27248
  const type = vnode[0 /* flags */];
27136
27249
  if ((type & 3 /* ELEMENT_OR_VIRTUAL_MASK */) !== 0) {
27137
27250
  type & 1 /* Element */ && vnode_ensureElementInflated(vnode);
27138
- const idx = mapApp_findIndx(vnode, key, vnode_getPropStartIndex(vnode));
27251
+ const props = vnode_getProps(vnode);
27252
+ const idx = mapApp_findIndx(props, key, 0);
27139
27253
  if (idx >= 0) {
27140
- let value = vnode[idx + 1];
27254
+ let value = props[idx + 1];
27141
27255
  if (typeof value === "string" && getObject) {
27142
- vnode[idx + 1] = value = getObject(value);
27256
+ props[idx + 1] = value = getObject(value);
27143
27257
  }
27144
27258
  return value;
27145
27259
  }
@@ -27148,11 +27262,12 @@ var vnode_getProp = (vnode, key, getObject) => {
27148
27262
  };
27149
27263
  var vnode_setProp = (vnode, key, value) => {
27150
27264
  ensureElementOrVirtualVNode(vnode);
27151
- const idx = mapApp_findIndx(vnode, key, vnode_getPropStartIndex(vnode));
27265
+ const props = vnode_getProps(vnode);
27266
+ const idx = mapApp_findIndx(props, key, 0);
27152
27267
  if (idx >= 0) {
27153
- vnode[idx + 1] = value;
27268
+ props[idx + 1] = value;
27154
27269
  } else if (value != null) {
27155
- vnode.splice(idx ^ -1, 0, key, value);
27270
+ props.splice(idx ^ -1, 0, key, value);
27156
27271
  }
27157
27272
  };
27158
27273
  var vnode_getPropStartIndex = (vnode) => {
@@ -27164,6 +27279,9 @@ var vnode_getPropStartIndex = (vnode) => {
27164
27279
  }
27165
27280
  throw qError(43 /* invalidVNodeType */, [type]);
27166
27281
  };
27282
+ var vnode_getProps = (vnode) => {
27283
+ return vnode[vnode_getPropStartIndex(vnode)];
27284
+ };
27167
27285
  var vnode_getParent = (vnode) => {
27168
27286
  return vnode[1 /* parent */] || null;
27169
27287
  };
@@ -27301,19 +27419,22 @@ function materializeFromVNodeData(vParent, vData, element, child) {
27301
27419
  }
27302
27420
  const id = consumeValue();
27303
27421
  container.$setRawState$(parseInt(id), vParent);
27304
- isDev6 && vnode_setAttr(null, vParent, ELEMENT_ID, id);
27422
+ isDev7 && vnode_setAttr(null, vParent, ELEMENT_ID, id);
27305
27423
  } else if (peek() === VNodeDataChar.PROPS) {
27306
27424
  vnode_setAttr(null, vParent, ELEMENT_PROPS, consumeValue());
27307
- } else if (peek() === VNodeDataChar.SLOT_REF) {
27308
- vnode_setAttr(null, vParent, QSlotRef, consumeValue());
27309
27425
  } else if (peek() === VNodeDataChar.KEY) {
27310
27426
  vnode_setAttr(null, vParent, ELEMENT_KEY, consumeValue());
27311
27427
  } else if (peek() === VNodeDataChar.SEQ) {
27312
27428
  vnode_setAttr(null, vParent, ELEMENT_SEQ, consumeValue());
27313
27429
  } else if (peek() === VNodeDataChar.SEQ_IDX) {
27314
27430
  vnode_setAttr(null, vParent, ELEMENT_SEQ_IDX, consumeValue());
27315
- } else if (peek() === VNodeDataChar.SUBS) {
27316
- vnode_setProp(vParent, QSubscribers, consumeValue());
27431
+ } else if (peek() === VNodeDataChar.BACK_REFS) {
27432
+ if (!container) {
27433
+ container = getDomContainer(element);
27434
+ }
27435
+ setEffectBackRefFromVNodeData(vParent, consumeValue(), container);
27436
+ } else if (peek() === VNodeDataChar.SLOT_PARENT) {
27437
+ vnode_setProp(vParent, QSlotParent, consumeValue());
27317
27438
  } else if (peek() === VNodeDataChar.CONTEXT) {
27318
27439
  vnode_setAttr(null, vParent, QCtxAttr, consumeValue());
27319
27440
  } else if (peek() === VNodeDataChar.OPEN) {
@@ -27396,24 +27517,38 @@ var vnode_getProjectionParentComponent = (vHost, rootVNode) => {
27396
27517
  };
27397
27518
  var VNodeArray = class VNode extends Array {
27398
27519
  static createElement(flags, parent, previousSibling, nextSibling, firstChild, lastChild, element, elementName) {
27399
- const vnode = new VNode(flags, parent, previousSibling, nextSibling);
27400
- vnode.push(firstChild, lastChild, element, elementName);
27520
+ const vnode = new VNode(
27521
+ flags,
27522
+ parent,
27523
+ previousSibling,
27524
+ nextSibling,
27525
+ firstChild,
27526
+ lastChild,
27527
+ element,
27528
+ elementName,
27529
+ []
27530
+ );
27401
27531
  return vnode;
27402
27532
  }
27403
27533
  static createText(flags, parent, previousSibling, nextSibling, textNode, text) {
27404
- const vnode = new VNode(flags, parent, previousSibling, nextSibling);
27405
- vnode.push(textNode, text);
27534
+ const vnode = new VNode(flags, parent, previousSibling, nextSibling, textNode, text);
27406
27535
  return vnode;
27407
27536
  }
27408
27537
  static createVirtual(flags, parent, previousSibling, nextSibling, firstChild, lastChild) {
27409
- const vnode = new VNode(flags, parent, previousSibling, nextSibling);
27410
- vnode.push(firstChild, lastChild);
27538
+ const vnode = new VNode(
27539
+ flags,
27540
+ parent,
27541
+ previousSibling,
27542
+ nextSibling,
27543
+ firstChild,
27544
+ lastChild,
27545
+ []
27546
+ );
27411
27547
  return vnode;
27412
27548
  }
27413
- constructor(flags, parent, previousSibling, nextSibling) {
27414
- super();
27415
- this.push(flags, parent, previousSibling, nextSibling);
27416
- if (isDev6) {
27549
+ constructor(flags, parent, previousSibling, nextSibling, ...rest) {
27550
+ super(flags, parent, previousSibling, nextSibling, ...rest);
27551
+ if (isDev7) {
27417
27552
  this.toString = vnode_toString;
27418
27553
  }
27419
27554
  }
@@ -27458,10 +27593,12 @@ function invokeApply(context, fn, args) {
27458
27593
  return returnValue;
27459
27594
  }
27460
27595
  var newInvokeContextFromTuple = ([element, event, url]) => {
27461
- const container = element.closest(QContainerSelector);
27596
+ const domContainer = getDomContainer(element);
27597
+ const container = domContainer.element;
27598
+ const vNode = container ? vnode_locate(domContainer.rootVNode, element) : void 0;
27462
27599
  const locale = container?.getAttribute(QLocaleAttr) || void 0;
27463
27600
  locale && setLocale(locale);
27464
- return newInvokeContext(locale, void 0, element, event, url);
27601
+ return newInvokeContext(locale, vNode, element, event, url);
27465
27602
  };
27466
27603
  var newInvokeContext = (locale, hostElement, element, event, url) => {
27467
27604
  const $locale$ = locale || (typeof event === "object" && event && "locale" in event ? event.locale : void 0);
@@ -27492,10 +27629,7 @@ var trackSignal = (fn, subscriber, property, container, data) => {
27492
27629
  const previousSubscriber = trackInvocation.$effectSubscriber$;
27493
27630
  const previousContainer = trackInvocation.$container$;
27494
27631
  try {
27495
- trackInvocation.$effectSubscriber$ = [subscriber, property];
27496
- if (data) {
27497
- trackInvocation.$effectSubscriber$.push(data);
27498
- }
27632
+ trackInvocation.$effectSubscriber$ = getSubscriber(subscriber, property, data);
27499
27633
  trackInvocation.$container$ = container;
27500
27634
  return invoke(trackInvocation, fn);
27501
27635
  } finally {
@@ -27842,7 +27976,7 @@ var DomContainer = class extends _SharedContainer {
27842
27976
  () => this.scheduleRender(),
27843
27977
  () => vnode_applyJournal(this.$journal$),
27844
27978
  {},
27845
- element.getAttribute("q:locale")
27979
+ element.getAttribute(QLocaleAttr)
27846
27980
  );
27847
27981
  __publicField(this, "element");
27848
27982
  __publicField(this, "qContainer");
@@ -27856,9 +27990,9 @@ var DomContainer = class extends _SharedContainer {
27856
27990
  __publicField(this, "$storeProxyMap$", /* @__PURE__ */ new WeakMap());
27857
27991
  __publicField(this, "$qFuncs$");
27858
27992
  __publicField(this, "$instanceHash$");
27859
- __publicField(this, "stateData");
27993
+ __publicField(this, "vNodeLocate", (id) => vnode_locate(this.rootVNode, id));
27994
+ __publicField(this, "$stateData$");
27860
27995
  __publicField(this, "$styleIds$", null);
27861
- __publicField(this, "$vnodeLocate$", (id) => vnode_locate(this.rootVNode, id));
27862
27996
  __publicField(this, "$renderCount$", 0);
27863
27997
  __publicField(this, "$getObjectById$", (id) => {
27864
27998
  if (typeof id === "string") {
@@ -27868,7 +28002,7 @@ var DomContainer = class extends _SharedContainer {
27868
28002
  id < this.$rawStateData$.length / 2,
27869
28003
  `Invalid reference: ${id} >= ${this.$rawStateData$.length / 2}`
27870
28004
  );
27871
- return this.stateData[id];
28005
+ return this.$stateData$[id];
27872
28006
  });
27873
28007
  this.qContainer = element.getAttribute(QContainerAttr);
27874
28008
  if (!this.qContainer) {
@@ -27890,29 +28024,29 @@ var DomContainer = class extends _SharedContainer {
27890
28024
  this.qManifestHash = element.getAttribute("q:manifest-hash");
27891
28025
  this.rootVNode = vnode_newUnMaterializedElement(this.element);
27892
28026
  this.$rawStateData$ = null;
27893
- this.stateData = null;
28027
+ this.$stateData$ = null;
27894
28028
  const document2 = this.element.ownerDocument;
27895
28029
  if (!document2.qVNodeData) {
27896
28030
  processVNodeData2(document2);
27897
28031
  }
27898
28032
  this.$rawStateData$ = [];
27899
- this.stateData = [];
28033
+ this.$stateData$ = [];
27900
28034
  const qwikStates = element.querySelectorAll('script[type="qwik/state"]');
27901
28035
  if (qwikStates.length !== 0) {
27902
28036
  const lastState = qwikStates[qwikStates.length - 1];
27903
28037
  this.$rawStateData$ = JSON.parse(lastState.textContent);
27904
- this.stateData = wrapDeserializerProxy(this, this.$rawStateData$);
28038
+ this.$stateData$ = wrapDeserializerProxy(this, this.$rawStateData$);
27905
28039
  }
27906
28040
  this.$qFuncs$ = getQFuncs(document2, this.$instanceHash$) || EMPTY_ARRAY;
27907
28041
  }
27908
28042
  $setRawState$(id, vParent) {
27909
- this.stateData[id] = vParent;
28043
+ this.$stateData$[id] = vParent;
27910
28044
  }
27911
28045
  parseQRL(qrl2) {
27912
28046
  return inflateQRL(this, parseQRL(qrl2));
27913
28047
  }
27914
28048
  handleError(err, host) {
27915
- if (qDev) {
28049
+ if (qDev && host) {
27916
28050
  if (typeof document !== "undefined") {
27917
28051
  const vHost = host;
27918
28052
  const errorDiv = document.createElement("errored-host");
@@ -27935,7 +28069,7 @@ var DomContainer = class extends _SharedContainer {
27935
28069
  throw err;
27936
28070
  }
27937
28071
  }
27938
- const errorStore = this.resolveContext(host, ERROR_CONTEXT);
28072
+ const errorStore = host && this.resolveContext(host, ERROR_CONTEXT);
27939
28073
  if (!errorStore) {
27940
28074
  throw err;
27941
28075
  }
@@ -27969,7 +28103,7 @@ var DomContainer = class extends _SharedContainer {
27969
28103
  return vNode;
27970
28104
  }
27971
28105
  vNode = vnode_getParent(vNode) || // If virtual node, than it could be a slot so we need to read its parent.
27972
- vnode_getProp(vNode, QSlotParent, this.$vnodeLocate$);
28106
+ vnode_getProp(vNode, QSlotParent, this.vNodeLocate);
27973
28107
  } else {
27974
28108
  vNode = vnode_getParent(vNode);
27975
28109
  }
@@ -27988,7 +28122,7 @@ var DomContainer = class extends _SharedContainer {
27988
28122
  case ELEMENT_PROPS:
27989
28123
  case OnRenderProp:
27990
28124
  case QCtxAttr:
27991
- case QSubscribers:
28125
+ case QBackRefs:
27992
28126
  getObjectById = this.$getObjectById$;
27993
28127
  break;
27994
28128
  case ELEMENT_SEQ_IDX:
@@ -28001,7 +28135,9 @@ var DomContainer = class extends _SharedContainer {
28001
28135
  scheduleRender() {
28002
28136
  this.$renderCount$++;
28003
28137
  this.renderDone || (this.renderDone = getPlatform().nextTick(() => this.processChores()));
28004
- return this.renderDone;
28138
+ return this.renderDone.finally(
28139
+ () => emitEvent("qrender", { instanceHash: this.$instanceHash$, renderCount: this.$renderCount$ })
28140
+ );
28005
28141
  }
28006
28142
  processChores() {
28007
28143
  let renderCount = this.$renderCount$;
@@ -28024,12 +28160,13 @@ var DomContainer = class extends _SharedContainer {
28024
28160
  ensureProjectionResolved(vNode) {
28025
28161
  if ((vNode[0 /* flags */] & 16 /* Resolved */) === 0) {
28026
28162
  vNode[0 /* flags */] |= 16 /* Resolved */;
28027
- for (let i = vnode_getPropStartIndex(vNode); i < vNode.length; i = i + 2) {
28028
- const prop = vNode[i];
28163
+ const props = vnode_getProps(vNode);
28164
+ for (let i = 0; i < props.length; i = i + 2) {
28165
+ const prop = props[i];
28029
28166
  if (isSlotProp(prop)) {
28030
- const value = vNode[i + 1];
28167
+ const value = props[i + 1];
28031
28168
  if (typeof value == "string") {
28032
- vNode[i + 1] = this.$vnodeLocate$(value);
28169
+ props[i + 1] = this.vNodeLocate(value);
28033
28170
  }
28034
28171
  }
28035
28172
  }
@@ -28096,8 +28233,7 @@ var DeserializationHandler = class {
28096
28233
  }
28097
28234
  const i = typeof property === "number" ? property : typeof property === "string" ? parseInt(property, 10) : NaN;
28098
28235
  if (Number.isNaN(i) || i < 0 || i >= this.$length$) {
28099
- const out = Reflect.get(target, property, receiver);
28100
- return out;
28236
+ return Reflect.get(target, property, receiver);
28101
28237
  }
28102
28238
  const idx = i * 2;
28103
28239
  const typeId = this.$data$[idx];
@@ -28194,7 +28330,7 @@ var inflate = (container, target, typeId, data) => {
28194
28330
  task.$flags$ = v[1];
28195
28331
  task.$index$ = v[2];
28196
28332
  task.$el$ = v[3];
28197
- task.$effectDependencies$ = v[4];
28333
+ task[_EFFECT_BACK_REF] = v[4];
28198
28334
  task.$state$ = v[5];
28199
28335
  break;
28200
28336
  case 20 /* Resource */:
@@ -28216,12 +28352,9 @@ var inflate = (container, target, typeId, data) => {
28216
28352
  break;
28217
28353
  case 25 /* Store */:
28218
28354
  case 26 /* StoreArray */: {
28219
- const [value, flags, effects2, storeEffect] = data;
28355
+ const [value, flags, effects2] = data;
28220
28356
  const store = getOrCreateStore(value, flags, container);
28221
28357
  const storeHandler = getStoreHandler(store);
28222
- if (storeEffect) {
28223
- effects2[STORE_ARRAY_PROP] = storeEffect;
28224
- }
28225
28358
  storeHandler.$effects$ = effects2;
28226
28359
  target = store;
28227
28360
  break;
@@ -28230,7 +28363,7 @@ var inflate = (container, target, typeId, data) => {
28230
28363
  const signal = target;
28231
28364
  const d = data;
28232
28365
  signal.$untrackedValue$ = d[0];
28233
- signal.$effects$ = d.slice(1);
28366
+ signal.$effects$ = new Set(d.slice(1));
28234
28367
  break;
28235
28368
  }
28236
28369
  case 23 /* WrappedSignal */: {
@@ -28238,10 +28371,11 @@ var inflate = (container, target, typeId, data) => {
28238
28371
  const d = data;
28239
28372
  signal.$func$ = container.getSyncFn(d[0]);
28240
28373
  signal.$args$ = d[1];
28241
- signal.$effectDependencies$ = d[2];
28374
+ signal[_EFFECT_BACK_REF] = d[2];
28242
28375
  signal.$untrackedValue$ = d[3];
28243
- signal.$hostElement$ = d[4];
28244
- signal.$effects$ = d.slice(5);
28376
+ signal.$flags$ = d[4];
28377
+ signal.$hostElement$ = d[5];
28378
+ signal.$effects$ = new Set(d.slice(6));
28245
28379
  break;
28246
28380
  }
28247
28381
  case 24 /* ComputedSignal */: {
@@ -28252,7 +28386,7 @@ var inflate = (container, target, typeId, data) => {
28252
28386
  if (d.length === 3) {
28253
28387
  computed.$untrackedValue$ = d[2];
28254
28388
  } else {
28255
- computed.$invalid$ = true;
28389
+ computed.$flags$ |= 1 /* INVALID */;
28256
28390
  computed.$computeQrl$.resolve();
28257
28391
  container.$scheduler$?.(
28258
28392
  1 /* QRL_RESOLVE */,
@@ -28355,6 +28489,7 @@ var _constants = [
28355
28489
  EMPTY_ARRAY,
28356
28490
  EMPTY_OBJ,
28357
28491
  NEEDS_COMPUTATION,
28492
+ STORE_ALL_PROPS,
28358
28493
  Slot,
28359
28494
  Fragment,
28360
28495
  NaN,
@@ -28373,6 +28508,7 @@ var _constantNames = [
28373
28508
  "EMPTY_ARRAY",
28374
28509
  "EMPTY_OBJ",
28375
28510
  "NEEDS_COMPUTATION",
28511
+ "STORE_ALL_PROPS",
28376
28512
  "Slot",
28377
28513
  "Fragment",
28378
28514
  "NaN",
@@ -28454,6 +28590,8 @@ var allocate = (container, typeId, value) => {
28454
28590
  reject = rej;
28455
28591
  });
28456
28592
  resolvers.set(promise, [resolve, reject]);
28593
+ promise.catch(() => {
28594
+ });
28457
28595
  return promise;
28458
28596
  case 17 /* Uint8Array */:
28459
28597
  const encodedLength = value.length;
@@ -28463,12 +28601,9 @@ var allocate = (container, typeId, value) => {
28463
28601
  return new Uint8Array(decodedLength);
28464
28602
  case 29 /* PropsProxy */:
28465
28603
  return createPropsProxy(null, null);
28466
- case 9 /* RefVNode */:
28467
28604
  case 8 /* VNode */:
28468
- const vnodeOrDocument = retrieveVNodeOrDocument(container, value);
28469
- if (typeId === 8 /* VNode */) {
28470
- return vnodeOrDocument;
28471
- }
28605
+ return retrieveVNodeOrDocument(container, value);
28606
+ case 9 /* RefVNode */:
28472
28607
  const vNode = retrieveVNodeOrDocument(container, value);
28473
28608
  if (vnode_isVNode(vNode)) {
28474
28609
  return vnode_getNode(vNode);
@@ -28476,7 +28611,7 @@ var allocate = (container, typeId, value) => {
28476
28611
  throw qError(34 /* serializeErrorExpectedVNode */, [typeof vNode]);
28477
28612
  }
28478
28613
  case 30 /* EffectData */:
28479
- return new EffectPropData({});
28614
+ return new SubscriptionData({});
28480
28615
  default:
28481
28616
  throw qError(35 /* serializeErrorCannotAllocate */, [typeId]);
28482
28617
  }
@@ -28492,12 +28627,12 @@ function parseQRL(qrl2) {
28492
28627
  const symbol = captureStart > -1 ? qrl2.slice(hashIdx + 1, captureStart) : qrl2.slice(hashIdx + 1);
28493
28628
  const captureIds = captureStart > -1 && captureEnd > -1 ? qrl2.slice(captureStart + 1, captureEnd).split(" ").filter((v) => v.length).map((s) => parseInt(s, 10)) : null;
28494
28629
  let qrlRef = null;
28495
- if (isDev && chunk === QRL_RUNTIME_CHUNK) {
28630
+ if (isDev2 && chunk === QRL_RUNTIME_CHUNK) {
28496
28631
  const backChannel = globalThis[QRL_RUNTIME_CHUNK];
28497
28632
  assertDefined(backChannel, "Missing QRL_RUNTIME_CHUNK");
28498
28633
  qrlRef = backChannel.get(symbol);
28499
28634
  }
28500
- return createQRL(chunk, symbol, qrlRef, null, captureIds, null, null);
28635
+ return createQRL(chunk, symbol, qrlRef, null, captureIds, null);
28501
28636
  }
28502
28637
  function inflateQRL(container, qrl2) {
28503
28638
  const captureIds = qrl2.$capture$;
@@ -28531,13 +28666,13 @@ var createSerializationContext = (NodeConstructor, DomRefConstructor, symbolToCh
28531
28666
  }
28532
28667
  return id;
28533
28668
  };
28534
- const isSsrNode = NodeConstructor ? (obj) => obj instanceof NodeConstructor : () => false;
28669
+ const isSsrNode2 = NodeConstructor ? (obj) => obj instanceof NodeConstructor : () => false;
28535
28670
  isDomRef = DomRefConstructor ? (obj) => obj instanceof DomRefConstructor : () => false;
28536
28671
  return {
28537
28672
  $serialize$() {
28538
28673
  serialize(this);
28539
28674
  },
28540
- $isSsrNode$: isSsrNode,
28675
+ $isSsrNode$: isSsrNode2,
28541
28676
  $isDomRef$: isDomRef,
28542
28677
  $symbolToChunkResolver$: symbolToChunkResolver,
28543
28678
  $wasSeen$,
@@ -28593,7 +28728,7 @@ var createSerializationContext = (NodeConstructor, DomRefConstructor, symbolToCh
28593
28728
  const promises = [];
28594
28729
  const visit = (obj) => {
28595
28730
  if (typeof obj === "function") {
28596
- if (isQrl2(obj)) {
28731
+ if (isQrl(obj)) {
28597
28732
  if (obj.$captureRef$) {
28598
28733
  discoveredValues.push(...obj.$captureRef$);
28599
28734
  }
@@ -28603,7 +28738,7 @@ var createSerializationContext = (NodeConstructor, DomRefConstructor, symbolToCh
28603
28738
  }
28604
28739
  } else if (
28605
28740
  // skip as these are primitives
28606
- typeof obj !== "object" || obj === null || obj instanceof URL || obj instanceof Date || obj instanceof RegExp || obj instanceof Uint8Array || obj instanceof URLSearchParams || typeof FormData !== "undefined" && obj instanceof FormData || // Ignore the no serialize objects
28741
+ typeof obj !== "object" || obj === null || obj instanceof URL || obj instanceof Date || obj instanceof RegExp || obj instanceof Uint8Array || obj instanceof URLSearchParams || vnode_isVNode(obj) || typeof FormData !== "undefined" && obj instanceof FormData || // Ignore the no serialize objects
28607
28742
  fastSkipSerialize(obj)
28608
28743
  ) {
28609
28744
  } else if (obj instanceof Error) {
@@ -28611,8 +28746,7 @@ var createSerializationContext = (NodeConstructor, DomRefConstructor, symbolToCh
28611
28746
  } else if (isStore(obj)) {
28612
28747
  const target = getStoreTarget(obj);
28613
28748
  const effects = getStoreHandler(obj).$effects$;
28614
- const storeEffect = effects?.[STORE_ARRAY_PROP] ?? null;
28615
- discoveredValues.push(target, effects, storeEffect);
28749
+ discoveredValues.push(target, effects);
28616
28750
  for (const prop in target) {
28617
28751
  const propValue = target[prop];
28618
28752
  if (storeProxyMap.has(propValue)) {
@@ -28626,17 +28760,15 @@ var createSerializationContext = (NodeConstructor, DomRefConstructor, symbolToCh
28626
28760
  discoveredValues.push(k, v);
28627
28761
  });
28628
28762
  } else if (obj instanceof Signal) {
28629
- const v = obj instanceof WrappedSignal ? obj.untrackedValue : obj instanceof ComputedSignal && (obj.$invalid$ || fastSkipSerialize(obj)) ? NEEDS_COMPUTATION : obj.$untrackedValue$;
28763
+ const v = obj instanceof WrappedSignal ? obj.untrackedValue : obj instanceof ComputedSignal && (obj.$flags$ & 1 /* INVALID */ || fastSkipSerialize(obj)) ? NEEDS_COMPUTATION : obj.$untrackedValue$;
28630
28764
  if (v !== NEEDS_COMPUTATION) {
28631
28765
  discoveredValues.push(v);
28632
28766
  }
28633
28767
  if (obj.$effects$) {
28634
- discoveredValues.push(...obj.$effects$);
28768
+ discoveredValues.push(obj.$effects$);
28635
28769
  }
28636
28770
  if (obj instanceof WrappedSignal) {
28637
- if (obj.$effectDependencies$) {
28638
- discoveredValues.push(...obj.$effectDependencies$);
28639
- }
28771
+ discoverEffectBackRefs(obj[_EFFECT_BACK_REF], discoveredValues);
28640
28772
  if (obj.$args$) {
28641
28773
  discoveredValues.push(...obj.$args$);
28642
28774
  }
@@ -28644,11 +28776,13 @@ var createSerializationContext = (NodeConstructor, DomRefConstructor, symbolToCh
28644
28776
  discoveredValues.push(obj.$hostElement$);
28645
28777
  }
28646
28778
  } else if (obj instanceof ComputedSignal) {
28779
+ discoverEffectBackRefs(obj[_EFFECT_BACK_REF], discoveredValues);
28647
28780
  discoveredValues.push(obj.$computeQrl$);
28648
28781
  }
28649
28782
  } else if (obj instanceof Task) {
28650
- discoveredValues.push(obj.$el$, obj.$qrl$, obj.$state$, obj.$effectDependencies$);
28651
- } else if (isSsrNode(obj)) {
28783
+ discoveredValues.push(obj.$el$, obj.$qrl$, obj.$state$);
28784
+ discoverEffectBackRefs(obj[_EFFECT_BACK_REF], discoveredValues);
28785
+ } else if (isSsrNode2(obj)) {
28652
28786
  discoverValuesForVNodeData(obj.vnodeData, discoveredValues);
28653
28787
  if (obj.childrenVNodeData && obj.childrenVNodeData.length) {
28654
28788
  for (const data of obj.childrenVNodeData) {
@@ -28661,7 +28795,7 @@ var createSerializationContext = (NodeConstructor, DomRefConstructor, symbolToCh
28661
28795
  discoveredValues.push(obj.type, obj.props, obj.constProps, obj.children);
28662
28796
  } else if (Array.isArray(obj)) {
28663
28797
  discoveredValues.push(...obj);
28664
- } else if (isQrl2(obj)) {
28798
+ } else if (isQrl(obj)) {
28665
28799
  obj.$captureRef$ && obj.$captureRef$.length && discoveredValues.push(...obj.$captureRef$);
28666
28800
  } else if (isPropsProxy(obj)) {
28667
28801
  discoveredValues.push(obj[_VAR_PROPS], obj[_CONST_PROPS]);
@@ -28677,7 +28811,7 @@ var createSerializationContext = (NodeConstructor, DomRefConstructor, symbolToCh
28677
28811
  }
28678
28812
  );
28679
28813
  promises.push(obj);
28680
- } else if (obj instanceof EffectPropData) {
28814
+ } else if (obj instanceof SubscriptionData) {
28681
28815
  discoveredValues.push(obj.data);
28682
28816
  } else if (isObjectLiteral(obj)) {
28683
28817
  Object.entries(obj).forEach(([key, value]) => {
@@ -28714,15 +28848,20 @@ var discoverValuesForVNodeData = (vnodeData, discoveredValues) => {
28714
28848
  for (const value of vnodeData) {
28715
28849
  if (isSsrAttrs(value)) {
28716
28850
  for (let i = 1; i < value.length; i += 2) {
28717
- if (value[i - 1] === ELEMENT_KEY) {
28851
+ const attrValue = value[i];
28852
+ if (typeof attrValue === "string") {
28718
28853
  continue;
28719
28854
  }
28720
- const attrValue = value[i];
28721
28855
  discoveredValues.push(attrValue);
28722
28856
  }
28723
28857
  }
28724
28858
  }
28725
28859
  };
28860
+ var discoverEffectBackRefs = (effectsBackRefs, discoveredValues) => {
28861
+ if (effectsBackRefs) {
28862
+ discoveredValues.push(effectsBackRefs);
28863
+ }
28864
+ };
28726
28865
  var promiseResults = /* @__PURE__ */ new WeakMap();
28727
28866
  function serialize(serializationContext) {
28728
28867
  const { $writer$, $isSsrNode$, $isDomRef$, $setProp$, $storeProxyMap$ } = serializationContext;
@@ -28771,10 +28910,10 @@ function serialize(serializationContext) {
28771
28910
  output(1 /* Constant */, value ? 2 /* True */ : 3 /* False */);
28772
28911
  } else if (typeof value === "function") {
28773
28912
  if (value === Slot) {
28774
- output(1 /* Constant */, 8 /* Slot */);
28913
+ output(1 /* Constant */, 9 /* Slot */);
28775
28914
  } else if (value === Fragment) {
28776
- output(1 /* Constant */, 9 /* Fragment */);
28777
- } else if (isQrl2(value)) {
28915
+ output(1 /* Constant */, 10 /* Fragment */);
28916
+ } else if (isQrl(value)) {
28778
28917
  const qrl2 = qrlToString(serializationContext, value);
28779
28918
  const id = serializationContext.$addRoot$(qrl2);
28780
28919
  output(18 /* QRL */, id);
@@ -28788,18 +28927,18 @@ function serialize(serializationContext) {
28788
28927
  }
28789
28928
  } else if (typeof value === "number") {
28790
28929
  if (Number.isNaN(value)) {
28791
- output(1 /* Constant */, 10 /* NaN */);
28930
+ output(1 /* Constant */, 11 /* NaN */);
28792
28931
  } else if (!Number.isFinite(value)) {
28793
28932
  output(
28794
28933
  1 /* Constant */,
28795
- value < 0 ? 12 /* NegativeInfinity */ : 11 /* PositiveInfinity */
28934
+ value < 0 ? 13 /* NegativeInfinity */ : 12 /* PositiveInfinity */
28796
28935
  );
28797
28936
  } else if (value === Number.MAX_SAFE_INTEGER) {
28798
- output(1 /* Constant */, 13 /* MaxSafeInt */);
28937
+ output(1 /* Constant */, 14 /* MaxSafeInt */);
28799
28938
  } else if (value === Number.MAX_SAFE_INTEGER - 1) {
28800
- output(1 /* Constant */, 14 /* AlmostMaxSafeInt */);
28939
+ output(1 /* Constant */, 15 /* AlmostMaxSafeInt */);
28801
28940
  } else if (value === Number.MIN_SAFE_INTEGER) {
28802
- output(1 /* Constant */, 15 /* MinSafeInt */);
28941
+ output(1 /* Constant */, 16 /* MinSafeInt */);
28803
28942
  } else {
28804
28943
  output(2 /* Number */, value);
28805
28944
  }
@@ -28832,6 +28971,8 @@ function serialize(serializationContext) {
28832
28971
  output(1 /* Constant */, 0 /* Undefined */);
28833
28972
  } else if (value === NEEDS_COMPUTATION) {
28834
28973
  output(1 /* Constant */, 7 /* NEEDS_COMPUTATION */);
28974
+ } else if (value === STORE_ALL_PROPS) {
28975
+ output(1 /* Constant */, 8 /* STORE_ALL_PROPS */);
28835
28976
  } else {
28836
28977
  throw qError(37 /* serializeErrorUnknownType */, [typeof value]);
28837
28978
  }
@@ -28850,7 +28991,7 @@ function serialize(serializationContext) {
28850
28991
  const constProps = value[_CONST_PROPS];
28851
28992
  const out = constProps ? [varProps, constProps] : Object.keys(varProps).length ? [varProps] : 0;
28852
28993
  output(29 /* PropsProxy */, out);
28853
- } else if (value instanceof EffectPropData) {
28994
+ } else if (value instanceof SubscriptionData) {
28854
28995
  output(30 /* EffectData */, [value.data.$scopedStyleIdPrefix$, value.data.$isConst$]);
28855
28996
  } else if (isStore(value)) {
28856
28997
  if (isResource(value)) {
@@ -28865,7 +29006,6 @@ function serialize(serializationContext) {
28865
29006
  const storeTarget = getStoreTarget(value);
28866
29007
  const flags = storeHandler.$flags$;
28867
29008
  const effects = storeHandler.$effects$;
28868
- const storeEffect = effects?.[STORE_ARRAY_PROP] ?? null;
28869
29009
  const innerStores = [];
28870
29010
  for (const prop in storeTarget) {
28871
29011
  const propValue = storeTarget[prop];
@@ -28875,7 +29015,7 @@ function serialize(serializationContext) {
28875
29015
  serializationContext.$addRoot$(innerStore);
28876
29016
  }
28877
29017
  }
28878
- const out = [storeTarget, flags, effects, storeEffect, ...innerStores];
29018
+ const out = [storeTarget, flags, effects, ...innerStores];
28879
29019
  while (out[out.length - 1] == null) {
28880
29020
  out.pop();
28881
29021
  }
@@ -28897,12 +29037,13 @@ function serialize(serializationContext) {
28897
29037
  value.$ssrNode$.vnodeData[0] |= 16 /* SERIALIZE */;
28898
29038
  output(9 /* RefVNode */, value.$ssrNode$.id);
28899
29039
  } else if (value instanceof Signal) {
28900
- const v = value instanceof ComputedSignal && (value.$invalid$ || fastSkipSerialize(value.$untrackedValue$)) ? NEEDS_COMPUTATION : value.$untrackedValue$;
29040
+ const v = value instanceof ComputedSignal && (value.$flags$ & 1 /* INVALID */ || fastSkipSerialize(value.$untrackedValue$)) ? NEEDS_COMPUTATION : value.$untrackedValue$;
28901
29041
  if (value instanceof WrappedSignal) {
28902
29042
  output(23 /* WrappedSignal */, [
28903
29043
  ...serializeWrappingFn(serializationContext, value),
28904
- value.$effectDependencies$,
29044
+ filterEffectBackRefs(value[_EFFECT_BACK_REF]),
28905
29045
  v,
29046
+ value.$flags$,
28906
29047
  value.$hostElement$,
28907
29048
  ...value.$effects$ || []
28908
29049
  ]);
@@ -28931,7 +29072,7 @@ function serialize(serializationContext) {
28931
29072
  if (extraProps.length) {
28932
29073
  out.push(extraProps);
28933
29074
  }
28934
- if (isDev) {
29075
+ if (isDev2) {
28935
29076
  out.push(value.stack);
28936
29077
  }
28937
29078
  output(12 /* Error */, out);
@@ -28988,7 +29129,7 @@ function serialize(serializationContext) {
28988
29129
  value.$flags$,
28989
29130
  value.$index$,
28990
29131
  value.$el$,
28991
- value.$effectDependencies$,
29132
+ value[_EFFECT_BACK_REF],
28992
29133
  value.$state$
28993
29134
  ];
28994
29135
  while (out[out.length - 1] == null) {
@@ -29008,12 +29149,26 @@ function serialize(serializationContext) {
29008
29149
  }
29009
29150
  const out = btoa(buf).replace(/=+$/, "");
29010
29151
  output(17 /* Uint8Array */, out);
29152
+ } else if (vnode_isVNode(value)) {
29153
+ output(1 /* Constant */, 0 /* Undefined */);
29011
29154
  } else {
29012
29155
  throw qError(37 /* serializeErrorUnknownType */, [typeof value]);
29013
29156
  }
29014
29157
  };
29015
29158
  writeValue(serializationContext.$roots$, -1);
29016
29159
  }
29160
+ function filterEffectBackRefs(effectBackRef) {
29161
+ let effectBackRefToSerialize = null;
29162
+ if (effectBackRef) {
29163
+ for (const [effectProp, effect] of effectBackRef) {
29164
+ if (effect[2 /* BACK_REF */]) {
29165
+ effectBackRefToSerialize || (effectBackRefToSerialize = /* @__PURE__ */ new Map());
29166
+ effectBackRefToSerialize.set(effectProp, effect);
29167
+ }
29168
+ }
29169
+ }
29170
+ return effectBackRefToSerialize;
29171
+ }
29017
29172
  function serializeWrappingFn(serializationContext, value) {
29018
29173
  if (value.$funcStr$ && value.$funcStr$[0] === "{") {
29019
29174
  value.$funcStr$ = `(${value.$funcStr$})`;
@@ -29028,15 +29183,12 @@ function serializeWrappingFn(serializationContext, value) {
29028
29183
  function qrlToString(serializationContext, value) {
29029
29184
  let symbol = value.$symbol$;
29030
29185
  let chunk = value.$chunk$;
29031
- const refSymbol = value.$refSymbol$ ?? symbol;
29032
29186
  const platform = getPlatform();
29033
29187
  if (platform) {
29034
- const result = platform.chunkForSymbol(refSymbol, chunk, value.dev?.file);
29188
+ const result = platform.chunkForSymbol(symbol, chunk, value.dev?.file);
29035
29189
  if (result) {
29036
29190
  chunk = result[1];
29037
- if (!value.$refSymbol$) {
29038
- symbol = result[0];
29039
- }
29191
+ symbol = result[0];
29040
29192
  }
29041
29193
  }
29042
29194
  const isSync = isSyncQrl(value);
@@ -29044,7 +29196,7 @@ function qrlToString(serializationContext, value) {
29044
29196
  if (!chunk) {
29045
29197
  chunk = serializationContext.$symbolToChunkResolver$(value.$hash$);
29046
29198
  }
29047
- if (isDev) {
29199
+ if (isDev2) {
29048
29200
  let backChannel = globalThis[QRL_RUNTIME_CHUNK];
29049
29201
  if (!backChannel) {
29050
29202
  backChannel = globalThis[QRL_RUNTIME_CHUNK] = /* @__PURE__ */ new Map();
@@ -29110,26 +29262,33 @@ function isResource(value) {
29110
29262
  return "__brand" in value && value.__brand === "resource";
29111
29263
  }
29112
29264
  var frameworkType = (obj) => {
29113
- return typeof obj === "object" && obj !== null && (obj instanceof Signal || obj instanceof Task || isJSXNode(obj)) || isQrl2(obj);
29265
+ return typeof obj === "object" && obj !== null && (obj instanceof Signal || obj instanceof Task || isJSXNode(obj)) || isQrl(obj);
29114
29266
  };
29115
- var canSerialize = (value) => {
29267
+ var canSerialize = (value, seen = /* @__PURE__ */ new WeakSet()) => {
29116
29268
  if (value == null || typeof value === "string" || typeof value === "number" || typeof value === "boolean" || typeof value === "bigint") {
29117
29269
  return true;
29118
29270
  } else if (typeof value === "object") {
29271
+ if (seen.has(value)) {
29272
+ return true;
29273
+ }
29274
+ seen.add(value);
29119
29275
  const proto = Object.getPrototypeOf(value);
29120
29276
  if (isStore(value)) {
29121
29277
  value = getStoreTarget(value);
29122
29278
  }
29123
29279
  if (proto == Object.prototype) {
29124
29280
  for (const key in value) {
29125
- if (!canSerialize(untrack(() => value[key]))) {
29281
+ if (!canSerialize(
29282
+ untrack(() => value[key]),
29283
+ seen
29284
+ )) {
29126
29285
  return false;
29127
29286
  }
29128
29287
  }
29129
29288
  return true;
29130
29289
  } else if (proto == Array.prototype) {
29131
29290
  for (let i = 0; i < value.length; i++) {
29132
- if (!canSerialize(value[i])) {
29291
+ if (!canSerialize(value[i], seen)) {
29133
29292
  return false;
29134
29293
  }
29135
29294
  }
@@ -29164,7 +29323,7 @@ var canSerialize = (value) => {
29164
29323
  return true;
29165
29324
  }
29166
29325
  } else if (typeof value === "function") {
29167
- if (isQrl2(value) || isQwikComponent(value)) {
29326
+ if (isQrl(value) || isQwikComponent(value)) {
29168
29327
  return true;
29169
29328
  }
29170
29329
  }
@@ -29282,7 +29441,7 @@ var constantToName = (code2) => {
29282
29441
 
29283
29442
  // packages/qwik/src/core/shared/utils/serialize-utils.ts
29284
29443
  var verifySerializable = (value, preMessage) => {
29285
- const seen = /* @__PURE__ */ new Set();
29444
+ const seen = /* @__PURE__ */ new WeakSet();
29286
29445
  return _verifySerializable(value, seen, "_", preMessage);
29287
29446
  };
29288
29447
  var _verifySerializable = (value, seen, ctx, preMessage) => {
@@ -29291,10 +29450,12 @@ var _verifySerializable = (value, seen, ctx, preMessage) => {
29291
29450
  return value;
29292
29451
  }
29293
29452
  if (shouldSerialize(unwrapped)) {
29294
- if (seen.has(unwrapped)) {
29295
- return value;
29453
+ if (typeof unwrapped === "object") {
29454
+ if (seen.has(unwrapped)) {
29455
+ return value;
29456
+ }
29457
+ seen.add(unwrapped);
29296
29458
  }
29297
- seen.add(unwrapped);
29298
29459
  if (isSignal(unwrapped)) {
29299
29460
  return value;
29300
29461
  }
@@ -29376,14 +29537,7 @@ var noSerialize = (input) => {
29376
29537
  };
29377
29538
 
29378
29539
  // packages/qwik/src/core/shared/qrl/qrl-class.ts
29379
- var isQrl2 = (value) => {
29380
- return typeof value === "function" && typeof value.getSymbol === "function";
29381
- };
29382
- var SYNC_QRL = "<sync>";
29383
- var isSyncQrl = (value) => {
29384
- return isQrl2(value) && value.$symbol$ == SYNC_QRL;
29385
- };
29386
- var createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef, refSymbol) => {
29540
+ var createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef) => {
29387
29541
  if (qDev && qSerialize) {
29388
29542
  if (captureRef) {
29389
29543
  for (const item of captureRef) {
@@ -29404,9 +29558,14 @@ var createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef, refSym
29404
29558
  return _containerEl;
29405
29559
  };
29406
29560
  function bindFnToContext(currentCtx, beforeFn) {
29407
- return (...args) => maybeThen(resolveLazy(), (fn) => {
29408
- if (!isFunction(fn)) {
29409
- throw qError(10 /* qrlIsNotFunction */);
29561
+ const bound = (...args) => {
29562
+ if (!qrl2.resolved) {
29563
+ return qrl2.resolve().then((fn) => {
29564
+ if (!isFunction(fn)) {
29565
+ throw qError(10 /* qrlIsNotFunction */);
29566
+ }
29567
+ return bound(...args);
29568
+ });
29410
29569
  }
29411
29570
  if (beforeFn && beforeFn() === false) {
29412
29571
  return;
@@ -29417,12 +29576,13 @@ var createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef, refSym
29417
29576
  context.$qrl$ = qrl2;
29418
29577
  context.$event$ || (context.$event$ = this);
29419
29578
  try {
29420
- return invoke.call(this, context, fn, ...args);
29579
+ return invoke.call(this, context, symbolRef, ...args);
29421
29580
  } finally {
29422
29581
  context.$qrl$ = prevQrl;
29423
29582
  context.$event$ = prevEvent;
29424
29583
  }
29425
- });
29584
+ };
29585
+ return bound;
29426
29586
  }
29427
29587
  const resolveLazy = (containerEl) => {
29428
29588
  return symbolRef !== null ? symbolRef : resolve(containerEl);
@@ -29434,7 +29594,16 @@ var createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef, refSym
29434
29594
  return function(...args) {
29435
29595
  let context = tryGetInvokeContext();
29436
29596
  if (context) {
29437
- return fn.apply(this, args);
29597
+ if (context.$qrl$?.$symbol$ === qrl2.$symbol$) {
29598
+ return fn.apply(this, args);
29599
+ }
29600
+ const prevQrl = context.$qrl$;
29601
+ context.$qrl$ = qrl2;
29602
+ try {
29603
+ return fn.apply(this, args);
29604
+ } finally {
29605
+ context.$qrl$ = prevQrl;
29606
+ }
29438
29607
  }
29439
29608
  context = newInvokeContext();
29440
29609
  context.$qrl$ = qrl2;
@@ -29459,10 +29628,12 @@ var createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef, refSym
29459
29628
  const start = now();
29460
29629
  const ctx = tryGetInvokeContext();
29461
29630
  if (symbolFn !== null) {
29462
- symbolRef = symbolFn().then((module) => qrl2.resolved = symbolRef = wrapFn(module[symbol]));
29631
+ symbolRef = symbolFn().then(
29632
+ (module) => qrl2.resolved = wrapFn(symbolRef = module[symbol])
29633
+ );
29463
29634
  } else {
29464
29635
  const imported = getPlatform().importSymbol(_containerEl, chunk, symbol);
29465
- symbolRef = maybeThen(imported, (ref) => qrl2.resolved = symbolRef = wrapFn(ref));
29636
+ symbolRef = maybeThen(imported, (ref) => qrl2.resolved = wrapFn(symbolRef = ref));
29466
29637
  }
29467
29638
  if (typeof symbolRef === "object" && isPromise(symbolRef)) {
29468
29639
  symbolRef.then(
@@ -29485,10 +29656,9 @@ var createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef, refSym
29485
29656
  return invoke2;
29486
29657
  }
29487
29658
  };
29488
- const resolvedSymbol = refSymbol ?? symbol;
29489
- const hash3 = getSymbolHash(resolvedSymbol);
29659
+ const hash3 = getSymbolHash(symbol);
29490
29660
  Object.assign(qrl2, {
29491
- getSymbol: () => resolvedSymbol,
29661
+ getSymbol: () => symbol,
29492
29662
  getHash: () => hash3,
29493
29663
  getCaptured: () => captureRef,
29494
29664
  resolve,
@@ -29496,7 +29666,6 @@ var createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef, refSym
29496
29666
  $setContainer$: setContainer,
29497
29667
  $chunk$: chunk,
29498
29668
  $symbol$: symbol,
29499
- $refSymbol$: refSymbol,
29500
29669
  $hash$: hash3,
29501
29670
  getFn: bindFnToContext,
29502
29671
  $capture$: capture,
@@ -29505,9 +29674,9 @@ var createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef, refSym
29505
29674
  resolved: void 0
29506
29675
  });
29507
29676
  if (symbolRef) {
29508
- symbolRef = maybeThen(symbolRef, (resolved) => qrl2.resolved = symbolRef = wrapFn(resolved));
29677
+ symbolRef = maybeThen(symbolRef, (resolved) => qrl2.resolved = wrapFn(symbolRef = resolved));
29509
29678
  }
29510
- if (isDev7) {
29679
+ if (isDev8) {
29511
29680
  Object.defineProperty(qrl2, "_devOnlySymbolRef", {
29512
29681
  get() {
29513
29682
  return symbolRef;
@@ -29519,20 +29688,6 @@ var createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef, refSym
29519
29688
  }
29520
29689
  return qrl2;
29521
29690
  };
29522
- var getSymbolHash = (symbolName) => {
29523
- const index = symbolName.lastIndexOf("_");
29524
- if (index > -1) {
29525
- return symbolName.slice(index + 1);
29526
- }
29527
- return symbolName;
29528
- };
29529
- function assertQrl(qrl2) {
29530
- if (qDev) {
29531
- if (!isQrl2(qrl2)) {
29532
- throw new Error("Not a QRL");
29533
- }
29534
- }
29535
- }
29536
29691
  var EMITTED = /* @__PURE__ */ new Set();
29537
29692
  var emitUsedSymbol = (symbol, element, reqTime) => {
29538
29693
  if (!EMITTED.has(symbol)) {
@@ -29572,7 +29727,7 @@ var $ = (expression) => {
29572
29727
  "Optimizer should replace all usages of $() with some special syntax. If you need to create a QRL manually, use inlinedQrl() instead."
29573
29728
  );
29574
29729
  }
29575
- return createQRL(null, "s" + runtimeSymbolId++, expression, null, null, null, null);
29730
+ return createQRL(null, "s" + runtimeSymbolId++, expression, null, null, null);
29576
29731
  };
29577
29732
  var dollar = $;
29578
29733
  var eventQrl = (qrl2) => {
@@ -29599,9 +29754,6 @@ var isQwikComponent = (component) => {
29599
29754
  return typeof component == "function" && component[SERIALIZABLE_STATE] !== void 0;
29600
29755
  };
29601
29756
 
29602
- // packages/qwik/src/core/index.ts
29603
- import { isBrowser as isBrowser2, isDev as isDev9, isServer as isServer3 } from "@qwik.dev/core/build";
29604
-
29605
29757
  // packages/qwik/src/core/shared/qrl/qrl.public.dollar.ts
29606
29758
  var event$ = implicit$FirstArg(eventQrl);
29607
29759
 
@@ -29788,9 +29940,6 @@ var useComputedQrl = (qrl2) => {
29788
29940
  // packages/qwik/src/core/use/use-computed-dollar.ts
29789
29941
  var useComputed$ = implicit$FirstArg(useComputedQrl);
29790
29942
 
29791
- // packages/qwik/src/core/shared/prefetch-service-worker/prefetch.ts
29792
- import { isDev as isDev8 } from "@qwik.dev/core/build";
29793
-
29794
29943
  // packages/qwik/src/testing/vdom-diff.unit-util.ts
29795
29944
  import { expect } from "vitest";
29796
29945
  import { format } from "prettier";
@@ -29903,7 +30052,7 @@ expect.extend({
29903
30052
  };
29904
30053
  }
29905
30054
  });
29906
- var ignoredAttributes = [QSubscribers, ELEMENT_ID, "", Q_PROPS_SEPARATOR];
30055
+ var ignoredAttributes = [QBackRefs, ELEMENT_ID, "", Q_PROPS_SEPARATOR];
29907
30056
  function getContainerElement(vNode) {
29908
30057
  let maybeParent;
29909
30058
  do {
@@ -30331,7 +30480,6 @@ function attrsEqual(expectedValue, receivedValue) {
30331
30480
  }
30332
30481
 
30333
30482
  // packages/qwik/src/testing/element-fixture.ts
30334
- import { vi } from "vitest";
30335
30483
  import { getDomContainer as getDomContainer2 } from "../core.mjs";
30336
30484
 
30337
30485
  // packages/qwik/src/testing/platform.ts
@@ -30509,7 +30657,6 @@ var dispatch = async (element, attrName, event, scope) => {
30509
30657
  const isDocumentOrWindow = isDocumentOrWindowEvent(event.type);
30510
30658
  const preventAttributeName = PREVENT_DEFAULT + (isDocumentOrWindow ? event.type.substring(1) : event.type);
30511
30659
  const stopPropagationName = STOP_PROPAGATION + event.type;
30512
- const collectListeners = [];
30513
30660
  while (element) {
30514
30661
  const preventDefault = element.hasAttribute(preventAttributeName);
30515
30662
  const stopPropagation = element.hasAttribute(stopPropagationName);
@@ -30526,15 +30673,21 @@ var dispatch = async (element, attrName, event, scope) => {
30526
30673
  } else if (element.hasAttribute(attrName)) {
30527
30674
  const container = getDomContainer2(element);
30528
30675
  const qrl2 = element.getAttribute(attrName);
30529
- qrl2.split("\n").map((qrl3) => container.parseQRL(qrl3.trim())).map((qrl3) => qrl3(event, element));
30676
+ const ctx = newInvokeContextFromTuple([element, event]);
30677
+ try {
30678
+ await Promise.all(
30679
+ qrl2.split("\n").map((qrl3) => container.parseQRL(qrl3.trim())).map((qrl3) => {
30680
+ return invokeApply(ctx, qrl3, [event, element]);
30681
+ })
30682
+ );
30683
+ } catch (error) {
30684
+ console.error("!!! qrl error", qrl2, error);
30685
+ throw error;
30686
+ }
30530
30687
  return;
30531
30688
  }
30532
30689
  element = element.parentElement;
30533
30690
  }
30534
- for (let i = 0; i < collectListeners.length; i++) {
30535
- const { element: element2, qrl: qrl2 } = collectListeners[i];
30536
- await qrl2.getFn([element2, event], () => element2.isConnected)(event, element2);
30537
- }
30538
30691
  };
30539
30692
 
30540
30693
  // packages/qwik/src/testing/library.ts
@@ -30579,7 +30732,21 @@ import { expect as expect2 } from "vitest";
30579
30732
 
30580
30733
  // packages/qwik/src/server/platform.ts
30581
30734
  import { setPlatform as setPlatform2 } from "../core.mjs";
30582
- var SYNC_QRL2 = "<sync>";
30735
+
30736
+ // packages/qwik/src/optimizer/src/versions.ts
30737
+ var versions2 = {
30738
+ qwik: globalThis.QWIK_VERSION
30739
+ };
30740
+
30741
+ // packages/qwik/src/optimizer/src/manifest.ts
30742
+ function getValidManifest(manifest) {
30743
+ if (manifest != null && manifest.mapping != null && typeof manifest.mapping === "object" && manifest.symbols != null && typeof manifest.symbols === "object" && manifest.bundles != null && typeof manifest.bundles === "object") {
30744
+ return manifest;
30745
+ }
30746
+ return void 0;
30747
+ }
30748
+
30749
+ // packages/qwik/src/server/platform.ts
30583
30750
  function createPlatform3(opts, resolvedManifest) {
30584
30751
  const mapper = resolvedManifest?.mapper;
30585
30752
  const mapperFn = opts.symbolMapper ? opts.symbolMapper : (symbolName, _chunk, parent) => {
@@ -30587,7 +30754,7 @@ function createPlatform3(opts, resolvedManifest) {
30587
30754
  const hash3 = getSymbolHash2(symbolName);
30588
30755
  const result = mapper[hash3];
30589
30756
  if (!result) {
30590
- if (hash3 === SYNC_QRL2) {
30757
+ if (hash3 === SYNC_QRL) {
30591
30758
  return [hash3, ""];
30592
30759
  }
30593
30760
  const isRegistered = globalThis.__qwik_reg_symbols?.has(hash3);
@@ -30649,19 +30816,6 @@ var getSymbolHash2 = (symbolName) => {
30649
30816
  return symbolName;
30650
30817
  };
30651
30818
 
30652
- // packages/qwik/src/optimizer/src/versions.ts
30653
- var versions2 = {
30654
- qwik: globalThis.QWIK_VERSION
30655
- };
30656
-
30657
- // packages/qwik/src/optimizer/src/manifest.ts
30658
- function getValidManifest(manifest) {
30659
- if (manifest != null && manifest.mapping != null && typeof manifest.mapping === "object" && manifest.symbols != null && typeof manifest.symbols === "object" && manifest.bundles != null && typeof manifest.bundles === "object") {
30660
- return manifest;
30661
- }
30662
- return void 0;
30663
- }
30664
-
30665
30819
  // packages/qwik/src/server/ssr-container.ts
30666
30820
  import {
30667
30821
  _EffectData as EffectData,
@@ -30671,7 +30825,7 @@ import {
30671
30825
  _walkJSX as _walkJSX2,
30672
30826
  isSignal as isSignal3
30673
30827
  } from "../core.mjs";
30674
- import { isDev as isDev11 } from "@qwik.dev/core/build";
30828
+ import { isDev as isDev10 } from "@qwik.dev/core/build";
30675
30829
 
30676
30830
  // packages/qwik/src/server/prefetch-utils.ts
30677
30831
  function workerFetchScript() {
@@ -30689,7 +30843,8 @@ function prefetchUrlsEventScript(base, prefetchResources) {
30689
30843
  bundles: flattenPrefetchResources(prefetchResources).map((u) => u.split("/").pop())
30690
30844
  };
30691
30845
  const args = JSON.stringify(["prefetch", base, ...data.bundles]);
30692
- 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});`;
30693
30848
  }
30694
30849
  function flattenPrefetchResources(prefetchResources) {
30695
30850
  const urls = [];
@@ -30847,8 +31002,12 @@ var PrefetchImplementationDefault = {
30847
31002
  };
30848
31003
 
30849
31004
  // packages/qwik/src/server/ssr-node.ts
30850
- import { _isJSXNode as isJSXNode2, _EMPTY_ARRAY } from "../core.mjs";
30851
- import { isDev as isDev10 } from "@qwik.dev/core/build";
31005
+ import {
31006
+ _isJSXNode as isJSXNode2,
31007
+ _EMPTY_ARRAY,
31008
+ _EFFECT_BACK_REF as _EFFECT_BACK_REF2
31009
+ } from "../core.mjs";
31010
+ import { isDev as isDev9 } from "@qwik.dev/core/build";
30852
31011
  var SsrNode = class {
30853
31012
  constructor(currentComponentNode, nodeType, id, attrs, cleanupQueue, vnodeData) {
30854
31013
  this.attrs = attrs;
@@ -30871,10 +31030,13 @@ var SsrNode = class {
30871
31030
  this.currentComponentNode?.addChildVNodeData(this.vnodeData);
30872
31031
  this.nodeType = nodeType;
30873
31032
  this.id = id;
30874
- if (isDev10 && id.indexOf("undefined") != -1) {
31033
+ if (isDev9 && id.indexOf("undefined") != -1) {
30875
31034
  throw new Error(`Invalid SSR node id: ${id}`);
30876
31035
  }
30877
31036
  }
31037
+ get [_EFFECT_BACK_REF2]() {
31038
+ return this.getProp(QBackRefs);
31039
+ }
30878
31040
  setProp(name, value) {
30879
31041
  if (this.attrs === _EMPTY_ARRAY) {
30880
31042
  this.attrs = [];
@@ -30986,14 +31148,12 @@ var SsrComponentFrame = class {
30986
31148
  return QDefaultSlot;
30987
31149
  }
30988
31150
  hasSlot(slotName) {
30989
- return mapArray_get(this.slots, slotName, 0) !== null;
31151
+ return mapArray_has(this.slots, slotName, 0);
30990
31152
  }
30991
31153
  consumeChildrenForSlot(projectionNode, slotName) {
30992
31154
  const children = mapApp_remove(this.slots, slotName, 0);
30993
- if (children !== null) {
30994
- this.componentNode.setProp(slotName, projectionNode.id);
30995
- projectionNode.setProp(QSlotParent, this.componentNode.id);
30996
- }
31155
+ this.componentNode.setProp(slotName, projectionNode.id);
31156
+ projectionNode.setProp(QSlotParent, this.componentNode.id);
30997
31157
  return children;
30998
31158
  }
30999
31159
  releaseUnclaimedProjections(unclaimedProjections) {
@@ -31417,7 +31577,13 @@ var EMPTY_OBJ2 = {};
31417
31577
  var SSRContainer = class extends _SharedContainer2 {
31418
31578
  constructor(opts) {
31419
31579
  super(
31420
- () => null,
31580
+ () => {
31581
+ try {
31582
+ return this.$scheduler$(255 /* WAIT_FOR_ALL */);
31583
+ } catch (e) {
31584
+ this.handleError(e, null);
31585
+ }
31586
+ },
31421
31587
  () => null,
31422
31588
  opts.renderOptions.serverData ?? EMPTY_OBJ2,
31423
31589
  opts.locale
@@ -31485,15 +31651,14 @@ var SSRContainer = class extends _SharedContainer2 {
31485
31651
  this.renderOptions = opts.renderOptions;
31486
31652
  this.$processInjectionsFromManifest$();
31487
31653
  }
31488
- ensureProjectionResolved(host) {
31654
+ ensureProjectionResolved(_host) {
31489
31655
  }
31490
- handleError(err, $host$) {
31656
+ handleError(err, _$host$) {
31491
31657
  throw err;
31492
31658
  }
31493
31659
  async render(jsx4) {
31494
31660
  this.openContainer();
31495
31661
  await _walkJSX2(this, jsx4, {
31496
- allowPromises: true,
31497
31662
  currentStyleScoped: null,
31498
31663
  parentComponentFrame: this.getComponentFrame()
31499
31664
  });
@@ -31547,7 +31712,7 @@ var SSRContainer = class extends _SharedContainer2 {
31547
31712
  containerAttributes[QContainerAttr] = "paused" /* PAUSED */;
31548
31713
  containerAttributes[QRuntimeAttr] = "2";
31549
31714
  containerAttributes[QVersionAttr] = this.$version$ ?? "dev";
31550
- containerAttributes[QRenderAttr] = (qRender ? qRender + "-" : "") + (isDev11 ? "ssr-dev" : "ssr");
31715
+ containerAttributes[QRenderAttr] = (qRender ? qRender + "-" : "") + (isDev10 ? "ssr-dev" : "ssr");
31551
31716
  containerAttributes[QBaseAttr] = this.buildBase || "";
31552
31717
  containerAttributes[QLocaleAttr] = this.$locale$;
31553
31718
  containerAttributes[QManifestHashAttr] = this.resolvedManifest.manifest.manifestHash;
@@ -31582,7 +31747,7 @@ var SSRContainer = class extends _SharedContainer2 {
31582
31747
  innerHTML = this.writeAttrs(elementName, varAttrs, false, currentFile);
31583
31748
  }
31584
31749
  this.write(" " + Q_PROPS_SEPARATOR);
31585
- isDev11 && this.write('=""');
31750
+ isDev10 && this.write('=""');
31586
31751
  if (constAttrs && constAttrs.length) {
31587
31752
  innerHTML = this.writeAttrs(elementName, constAttrs, true, currentFile) || innerHTML;
31588
31753
  }
@@ -31891,9 +32056,6 @@ var SSRContainer = class extends _SharedContainer2 {
31891
32056
  case ELEMENT_PROPS:
31892
32057
  write(VNodeDataChar.PROPS_CHAR);
31893
32058
  break;
31894
- case QSlotRef:
31895
- write(VNodeDataChar.SLOT_REF_CHAR);
31896
- break;
31897
32059
  case ELEMENT_KEY:
31898
32060
  write(VNodeDataChar.KEY_CHAR);
31899
32061
  break;
@@ -31903,8 +32065,11 @@ var SSRContainer = class extends _SharedContainer2 {
31903
32065
  case ELEMENT_SEQ_IDX:
31904
32066
  write(VNodeDataChar.SEQ_IDX_CHAR);
31905
32067
  break;
31906
- case QSubscribers:
31907
- write(VNodeDataChar.SUBS_CHAR);
32068
+ case QBackRefs:
32069
+ write(VNodeDataChar.BACK_REFS_CHAR);
32070
+ break;
32071
+ case QSlotParent:
32072
+ write(VNodeDataChar.SLOT_PARENT_CHAR);
31908
32073
  break;
31909
32074
  // Skipping `\` character for now because it is used for escaping.
31910
32075
  case QCtxAttr:
@@ -32101,7 +32266,7 @@ var SSRContainer = class extends _SharedContainer2 {
32101
32266
  }
32102
32267
  this.unclaimedProjectionComponentFrameQueue.shift();
32103
32268
  this.openFragment(
32104
- isDev11 ? [DEBUG_TYPE, "P" /* Projection */, QSlotParent, ssrComponentNode.id] : [QSlotParent, ssrComponentNode.id]
32269
+ isDev10 ? [DEBUG_TYPE, "P" /* Projection */, QSlotParent, ssrComponentNode.id] : [QSlotParent, ssrComponentNode.id]
32105
32270
  );
32106
32271
  const lastNode = this.getLastNode();
32107
32272
  if (lastNode.vnodeData) {
@@ -32109,7 +32274,6 @@ var SSRContainer = class extends _SharedContainer2 {
32109
32274
  }
32110
32275
  ssrComponentNode?.setProp(value, lastNode.id);
32111
32276
  await _walkJSX2(this, children, {
32112
- allowPromises: true,
32113
32277
  currentStyleScoped: scopedStyleId,
32114
32278
  parentComponentFrame: null
32115
32279
  });
@@ -32151,7 +32315,7 @@ var SSRContainer = class extends _SharedContainer2 {
32151
32315
  }
32152
32316
  createAndPushFrame(elementName, depthFirstElementIdx, currentFile) {
32153
32317
  let tagNesting = 10 /* ANYTHING */;
32154
- if (isDev11) {
32318
+ if (isDev10) {
32155
32319
  if (!this.currentElementFrame) {
32156
32320
  tagNesting = initialTag(elementName);
32157
32321
  } else {
@@ -32227,8 +32391,8 @@ var SSRContainer = class extends _SharedContainer2 {
32227
32391
  let value = attrs[i];
32228
32392
  let styleScopedId = null;
32229
32393
  if (isSSRUnsafeAttr(key)) {
32230
- if (isDev11) {
32231
- throw qError(50 /* unsafeAttr */);
32394
+ if (isDev10) {
32395
+ throw qError(49 /* unsafeAttr */);
32232
32396
  }
32233
32397
  continue;
32234
32398
  }
@@ -32245,6 +32409,8 @@ var SSRContainer = class extends _SharedContainer2 {
32245
32409
  } else if (typeof value === "function") {
32246
32410
  value(new DomRef(lastNode));
32247
32411
  continue;
32412
+ } else if (value == null) {
32413
+ continue;
32248
32414
  } else {
32249
32415
  throw qError(32 /* invalidRefValue */, [currentFile]);
32250
32416
  }
@@ -32267,7 +32433,7 @@ var SSRContainer = class extends _SharedContainer2 {
32267
32433
  }
32268
32434
  if (tag === "textarea" && key === "value") {
32269
32435
  if (value && typeof value !== "string") {
32270
- if (isDev11) {
32436
+ if (isDev10) {
32271
32437
  throw qError(40 /* wrongTextareaValue */, [currentFile, value]);
32272
32438
  }
32273
32439
  continue;
@@ -32610,7 +32776,7 @@ async function ssrRenderToDom(jsx4, opts = {}) {
32610
32776
  let child = firstContainerChild;
32611
32777
  let insertBefore = null;
32612
32778
  while (child) {
32613
- if (vnode_isElementVNode(child) && (vnode_getElementName(child) === "script" && vnode_getAttr(child, "type") === "qwik/state" || vnode_getElementName(child) === "q:template")) {
32779
+ if (vnode_isElementVNode(child) && (vnode_getElementName(child) === "script" && (vnode_getAttr(child, "type") === "qwik/state" || vnode_getAttr(child, "id") === "qwikloader") || vnode_getElementName(child) === "q:template")) {
32614
32780
  insertBefore = child;
32615
32781
  break;
32616
32782
  }
@@ -32670,14 +32836,16 @@ function renderStyles(getStyles) {
32670
32836
  console.log(START2 + key + ": " + END2 + value);
32671
32837
  });
32672
32838
  }
32673
- async function rerenderComponent(element) {
32839
+ async function rerenderComponent(element, flush) {
32674
32840
  const container = _getDomContainer(element);
32675
32841
  const vElement = vnode_locate(container.rootVNode, element);
32676
32842
  const host = getHostVNode(vElement);
32677
32843
  const qrl2 = container.getHostProp(host, OnRenderProp);
32678
32844
  const props = container.getHostProp(host, ELEMENT_PROPS);
32679
- await container.$scheduler$(7 /* COMPONENT */, host, qrl2, props);
32680
- await getTestPlatform().flush();
32845
+ container.$scheduler$(6 /* COMPONENT */, host, qrl2, props);
32846
+ if (flush) {
32847
+ await getTestPlatform().flush();
32848
+ }
32681
32849
  }
32682
32850
  function getHostVNode(vElement) {
32683
32851
  while (vElement != null) {