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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) 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 -63
  8. package/dist/core-internal.d.ts +78 -77
  9. package/dist/core.cjs +1770 -1517
  10. package/dist/core.cjs.map +1 -1
  11. package/dist/core.min.mjs +1 -1
  12. package/dist/core.mjs +1768 -1517
  13. package/dist/core.mjs.map +1 -1
  14. package/dist/core.prod.cjs +985 -848
  15. package/dist/core.prod.mjs +1210 -1032
  16. package/dist/insights/index.qwik.cjs +3658 -160
  17. package/dist/insights/index.qwik.mjs +3658 -160
  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 +230 -5691
  22. package/dist/optimizer.mjs +192 -5992
  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 +754 -7067
  27. package/dist/server.mjs +771 -7062
  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/turso/src/utils/turso.ts +1 -1
  44. package/dist/starters/features/vitest/package.json +1 -1
  45. package/dist/testing/index.cjs +1445 -1252
  46. package/dist/testing/index.mjs +1455 -1256
  47. package/dist/testing/package.json +1 -1
  48. package/handlers.mjs +9 -0
  49. package/package.json +7 -5
  50. package/public.d.ts +2 -0
  51. package/dist/starters/features/tailwind/.vscode/settings.json +0 -3
  52. package/dist/starters/features/tailwind/postcss.config.cjs +0 -6
  53. 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.5-dev+cb53bbd
3
+ * @qwik.dev/core/testing 2.0.0-alpha.7-dev+a26598a
4
4
  * Copyright QwikDev. All Rights Reserved.
5
5
  * Use of this source code is governed by an MIT-style license that can be
6
6
  * found in the LICENSE file at https://github.com/QwikDev/qwik/blob/main/LICENSE
@@ -22166,7 +22166,7 @@ var seal = (obj) => {
22166
22166
  };
22167
22167
 
22168
22168
  // packages/qwik/src/core/shared/qrl/qrl-class.ts
22169
- var import_build8 = require("@qwik.dev/core/build");
22169
+ var import_build10 = require("@qwik.dev/core/build");
22170
22170
 
22171
22171
  // packages/qwik/src/core/shared/utils/log.ts
22172
22172
  var STYLE = qDev ? `background: #564CE0; color: white; padding: 2px 3px; border-radius: 2px; font-size: 0.8em;` : "";
@@ -22246,10 +22246,10 @@ var codeToText = (code2, ...parts) => {
22246
22246
  const MAP = [
22247
22247
  "Error while serializing class or style attributes",
22248
22248
  // 0
22249
- "",
22250
- // 1 unused
22251
- "",
22252
- // 2 unused
22249
+ "Scheduler not found",
22250
+ // 1
22251
+ "track() received object, without prop to track",
22252
+ // 2
22253
22253
  "Only primitive and object literals can be serialized. {{0}}",
22254
22254
  // 3
22255
22255
  "",
@@ -22335,20 +22335,16 @@ See https://qwik.dev/docs/components/tasks/#use-method-rules`,
22335
22335
  // 43
22336
22336
  "Materialize error: missing element: {{0}} {{1}} {{2}}",
22337
22337
  // 44
22338
- "SsrError: {{0}}",
22339
- // 45
22340
22338
  "Cannot coerce a Signal, use `.value` instead",
22341
- // 46
22339
+ // 45
22342
22340
  "useComputedSignal$ QRL {{0}} {{1}} returned a Promise",
22343
- // 47
22341
+ // 46
22344
22342
  "ComputedSignal is read-only",
22345
- // 48
22343
+ // 47
22346
22344
  "WrappedSignal is read-only",
22347
- // 49
22348
- "SsrError: Promises not expected here.",
22349
- // 50
22345
+ // 48
22350
22346
  "Attribute value is unsafe for SSR"
22351
- // 51
22347
+ // 49
22352
22348
  ];
22353
22349
  let text = MAP[code2] ?? "";
22354
22350
  if (parts.length) {
@@ -22371,13 +22367,137 @@ var qError = (code2, errorMessageArgs = []) => {
22371
22367
  };
22372
22368
 
22373
22369
  // packages/qwik/src/core/shared/platform/platform.ts
22370
+ var import_build2 = require("@qwik.dev/core/build");
22371
+
22372
+ // packages/qwik/src/core/shared/qrl/qrl-utils.ts
22374
22373
  var import_build = require("@qwik.dev/core/build");
22374
+ var SYNC_QRL = "<sync>";
22375
+ var isSyncQrl = (value) => {
22376
+ return isQrl(value) && value.$symbol$ == SYNC_QRL;
22377
+ };
22378
+ var isQrl = (value) => {
22379
+ return typeof value === "function" && typeof value.getSymbol === "function";
22380
+ };
22381
+ function assertQrl(qrl2) {
22382
+ if (import_build.isDev) {
22383
+ if (!isQrl(qrl2)) {
22384
+ throw new Error("Not a QRL");
22385
+ }
22386
+ }
22387
+ }
22388
+ var getSymbolHash = (symbolName) => {
22389
+ const index = symbolName.lastIndexOf("_");
22390
+ if (index > -1) {
22391
+ return symbolName.slice(index + 1);
22392
+ }
22393
+ return symbolName;
22394
+ };
22395
+
22396
+ // packages/qwik/src/core/shared/types.ts
22397
+ var DEBUG_TYPE = "q:type";
22398
+ var START = "\x1B[34m";
22399
+ var END = "\x1B[0m";
22400
+ var VirtualTypeName = {
22401
+ ["V" /* Virtual */]: (
22402
+ /* ********* */
22403
+ START + "Virtual" + END
22404
+ ),
22405
+ //
22406
+ ["F" /* Fragment */]: (
22407
+ /* ******** */
22408
+ START + "Fragment" + END
22409
+ ),
22410
+ //
22411
+ ["S" /* WrappedSignal */]: (
22412
+ /* *** */
22413
+ START + "Signal" + END
22414
+ ),
22415
+ //
22416
+ ["A" /* Awaited */]: (
22417
+ /* ********* */
22418
+ START + "Awaited" + END
22419
+ ),
22420
+ //
22421
+ ["C" /* Component */]: (
22422
+ /* ******* */
22423
+ START + "Component" + END
22424
+ ),
22425
+ //
22426
+ ["I" /* InlineComponent */]: (
22427
+ /* * */
22428
+ START + "InlineComponent" + END
22429
+ ),
22430
+ //
22431
+ ["P" /* Projection */]: (
22432
+ /* ****** */
22433
+ START + "Projection" + END
22434
+ )
22435
+ //
22436
+ };
22437
+
22438
+ // packages/qwik/src/core/shared/utils/markers.ts
22439
+ var OnRenderProp = "q:renderFn";
22440
+ var ComponentStylesPrefixContent = "\u26A1\uFE0F";
22441
+ var QSlot = "q:slot";
22442
+ var QSlotParent = ":";
22443
+ var QSlotRef = "q:sref";
22444
+ var QSlotS = "q:s";
22445
+ var QStyle = "q:style";
22446
+ var QStyleSelector = "style[q\\:style]";
22447
+ var QStyleSSelector = "style[q\\:sstyle]";
22448
+ var QStylesAllSelector = QStyleSelector + "," + QStyleSSelector;
22449
+ var QScopedStyle = "q:sstyle";
22450
+ var QCtxAttr = "q:ctx";
22451
+ var QBackRefs = "q:brefs";
22452
+ var QFuncsPrefix = "qFuncs_";
22453
+ var getQFuncs = (document2, hash3) => {
22454
+ return document2[QFuncsPrefix + hash3] || [];
22455
+ };
22456
+ var QRenderAttr = "q:render";
22457
+ var QRuntimeAttr = "q:runtime";
22458
+ var QVersionAttr = "q:version";
22459
+ var QBaseAttr = "q:base";
22460
+ var QLocaleAttr = "q:locale";
22461
+ var QManifestHashAttr = "q:manifest-hash";
22462
+ var QInstanceAttr = "q:instance";
22463
+ var QContainerIsland = "q:container-island";
22464
+ var QContainerIslandEnd = "/" + QContainerIsland;
22465
+ var QIgnore = "q:ignore";
22466
+ var QIgnoreEnd = "/" + QIgnore;
22467
+ var QContainerAttr = "q:container";
22468
+ var QContainerAttrEnd = "/" + QContainerAttr;
22469
+ var QTemplate = "q:template";
22470
+ var QContainerSelector = "[q\\:container]:not([q\\:container=" + "html" /* HTML */ + "]):not([q\\:container=" + "text" /* TEXT */ + "])";
22471
+ var HTML_NS = "http://www.w3.org/1999/xhtml";
22472
+ var SVG_NS = "http://www.w3.org/2000/svg";
22473
+ var MATH_NS = "http://www.w3.org/1998/Math/MathML";
22474
+ var ResourceEvent = "qResource";
22475
+ var RenderEvent = "qRender";
22476
+ var TaskEvent = "qTask";
22477
+ var QDefaultSlot = "";
22478
+ var ELEMENT_ID = "q:id";
22479
+ var ELEMENT_KEY = "q:key";
22480
+ var ELEMENT_PROPS = "q:props";
22481
+ var ELEMENT_SEQ = "q:seq";
22482
+ var ELEMENT_SEQ_IDX = "q:seqIdx";
22483
+ var Q_PREFIX = "q:";
22484
+ var NON_SERIALIZABLE_MARKER_PREFIX = ":";
22485
+ var USE_ON_LOCAL = NON_SERIALIZABLE_MARKER_PREFIX + "on";
22486
+ var USE_ON_LOCAL_SEQ_IDX = NON_SERIALIZABLE_MARKER_PREFIX + "onIdx";
22487
+ var USE_ON_LOCAL_FLAGS = NON_SERIALIZABLE_MARKER_PREFIX + "onFlags";
22488
+ var FLUSH_COMMENT = "qkssr-f";
22489
+ var STREAM_BLOCK_START_COMMENT = "qkssr-pu";
22490
+ var STREAM_BLOCK_END_COMMENT = "qkssr-po";
22491
+ var Q_PROPS_SEPARATOR = ":";
22492
+ var dangerouslySetInnerHTML = "dangerouslySetInnerHTML";
22493
+
22494
+ // packages/qwik/src/core/shared/platform/platform.ts
22375
22495
  var createPlatform = () => {
22376
22496
  return {
22377
- isServer: import_build.isServer,
22497
+ isServer: import_build2.isServer,
22378
22498
  importSymbol(containerEl, url, symbolName) {
22379
22499
  var _a;
22380
- if (import_build.isServer) {
22500
+ if (import_build2.isServer) {
22381
22501
  const hash3 = getSymbolHash(symbolName);
22382
22502
  const regSym = (_a = globalThis.__qwik_reg_symbols) == null ? void 0 : _a.get(hash3);
22383
22503
  if (regSym) {
@@ -22422,7 +22542,7 @@ var createPlatform = () => {
22422
22542
  };
22423
22543
  var toUrl = (doc, containerEl, url) => {
22424
22544
  const baseURI = doc.baseURI;
22425
- const base = new URL(containerEl.getAttribute("q:base") ?? baseURI, baseURI);
22545
+ const base = new URL(containerEl.getAttribute(QBaseAttr) ?? baseURI, baseURI);
22426
22546
  return new URL(url, base);
22427
22547
  };
22428
22548
  var _platform = /* @__PURE__ */ createPlatform();
@@ -22465,9 +22585,6 @@ var safeCall = (call, thenFn, rejectFn) => {
22465
22585
  var maybeThen = (valueOrPromise, thenFn) => {
22466
22586
  return isPromise(valueOrPromise) ? valueOrPromise.then(thenFn, shouldNotError) : thenFn(valueOrPromise);
22467
22587
  };
22468
- var maybeThenPassError = (valueOrPromise, thenFn) => {
22469
- return isPromise(valueOrPromise) ? valueOrPromise.then(thenFn) : thenFn(valueOrPromise);
22470
- };
22471
22588
  var shouldNotError = (reason) => {
22472
22589
  throwErrorAndStop(reason);
22473
22590
  };
@@ -22477,13 +22594,20 @@ var delay = (timeout) => {
22477
22594
  });
22478
22595
  };
22479
22596
  function retryOnPromise(fn, retryCount = 0) {
22480
- try {
22481
- return fn();
22482
- } catch (e) {
22597
+ const retryOrThrow = (e) => {
22483
22598
  if (isPromise(e) && retryCount < MAX_RETRY_ON_PROMISE_COUNT) {
22484
22599
  return e.then(retryOnPromise.bind(null, fn, retryCount++));
22485
22600
  }
22486
22601
  throw e;
22602
+ };
22603
+ try {
22604
+ const result = fn();
22605
+ if (isPromise(result)) {
22606
+ return result.catch((e) => retryOrThrow(e));
22607
+ }
22608
+ return result;
22609
+ } catch (e) {
22610
+ return retryOrThrow(e);
22487
22611
  }
22488
22612
  }
22489
22613
 
@@ -22506,105 +22630,7 @@ var isFunction = (v) => {
22506
22630
  };
22507
22631
 
22508
22632
  // packages/qwik/src/build/index.dev.ts
22509
- var isDev = true;
22510
-
22511
- // packages/qwik/src/core/shared/types.ts
22512
- var DEBUG_TYPE = "q:type";
22513
- var START = "\x1B[34m";
22514
- var END = "\x1B[0m";
22515
- var VirtualTypeName = {
22516
- ["V" /* Virtual */]: (
22517
- /* ********* */
22518
- START + "Virtual" + END
22519
- ),
22520
- //
22521
- ["F" /* Fragment */]: (
22522
- /* ******** */
22523
- START + "Fragment" + END
22524
- ),
22525
- //
22526
- ["S" /* WrappedSignal */]: (
22527
- /* *** */
22528
- START + "Signal" + END
22529
- ),
22530
- //
22531
- ["A" /* Awaited */]: (
22532
- /* ********* */
22533
- START + "Awaited" + END
22534
- ),
22535
- //
22536
- ["C" /* Component */]: (
22537
- /* ******* */
22538
- START + "Component" + END
22539
- ),
22540
- //
22541
- ["I" /* InlineComponent */]: (
22542
- /* * */
22543
- START + "InlineComponent" + END
22544
- ),
22545
- //
22546
- ["P" /* Projection */]: (
22547
- /* ****** */
22548
- START + "Projection" + END
22549
- )
22550
- //
22551
- };
22552
-
22553
- // packages/qwik/src/core/shared/utils/markers.ts
22554
- var OnRenderProp = "q:renderFn";
22555
- var ComponentStylesPrefixContent = "\u2B50\uFE0F";
22556
- var QSlot = "q:slot";
22557
- var QSlotParent = ":";
22558
- var QSlotRef = "q:sref";
22559
- var QSlotS = "q:s";
22560
- var QStyle = "q:style";
22561
- var QStyleSelector = "style[q\\:style]";
22562
- var QStyleSSelector = "style[q\\:sstyle]";
22563
- var QStylesAllSelector = QStyleSelector + "," + QStyleSSelector;
22564
- var QScopedStyle = "q:sstyle";
22565
- var QCtxAttr = "q:ctx";
22566
- var QSubscribers = "q:subs";
22567
- var QFuncsPrefix = "qFuncs_";
22568
- var getQFuncs = (document2, hash3) => {
22569
- return document2[QFuncsPrefix + hash3] || [];
22570
- };
22571
- var QRenderAttr = "q:render";
22572
- var QRuntimeAttr = "q:runtime";
22573
- var QVersionAttr = "q:version";
22574
- var QBaseAttr = "q:base";
22575
- var QLocaleAttr = "q:locale";
22576
- var QManifestHashAttr = "q:manifest-hash";
22577
- var QInstanceAttr = "q:instance";
22578
- var QContainerIsland = "q:container-island";
22579
- var QContainerIslandEnd = "/" + QContainerIsland;
22580
- var QIgnore = "q:ignore";
22581
- var QIgnoreEnd = "/" + QIgnore;
22582
- var QContainerAttr = "q:container";
22583
- var QContainerAttrEnd = "/" + QContainerAttr;
22584
- var QTemplate = "q:template";
22585
- var QContainerSelector = "[q\\:container]:not([q\\:container=" + "html" /* HTML */ + "]):not([q\\:container=" + "text" /* TEXT */ + "])";
22586
- var HTML_NS = "http://www.w3.org/1999/xhtml";
22587
- var SVG_NS = "http://www.w3.org/2000/svg";
22588
- var MATH_NS = "http://www.w3.org/1998/Math/MathML";
22589
- var ResourceEvent = "qResource";
22590
- var RenderEvent = "qRender";
22591
- var TaskEvent = "qTask";
22592
- var QDefaultSlot = "";
22593
- var ELEMENT_ID = "q:id";
22594
- var ELEMENT_KEY = "q:key";
22595
- var ELEMENT_PROPS = "q:props";
22596
- var ELEMENT_SEQ = "q:seq";
22597
- var ELEMENT_SEQ_IDX = "q:seqIdx";
22598
- var Q_PREFIX = "q:";
22599
- var NON_SERIALIZABLE_MARKER_PREFIX = ":";
22600
- var USE_ON_LOCAL = NON_SERIALIZABLE_MARKER_PREFIX + "on";
22601
- var USE_ON_LOCAL_SEQ_IDX = NON_SERIALIZABLE_MARKER_PREFIX + "onIdx";
22602
- var USE_ON_LOCAL_FLAGS = NON_SERIALIZABLE_MARKER_PREFIX + "onFlags";
22603
- var FLUSH_COMMENT = "qkssr-f";
22604
- var STREAM_BLOCK_START_COMMENT = "qkssr-pu";
22605
- var STREAM_BLOCK_END_COMMENT = "qkssr-po";
22606
- var Q_PROPS_SEPARATOR = ":";
22607
- var dangerouslySetInnerHTML = "dangerouslySetInnerHTML";
22633
+ var isDev2 = true;
22608
22634
 
22609
22635
  // packages/qwik/src/core/use/use-locale.ts
22610
22636
  var _locale = void 0;
@@ -22613,7 +22639,7 @@ function setLocale(locale) {
22613
22639
  }
22614
22640
 
22615
22641
  // packages/qwik/src/core/client/vnode.ts
22616
- var import_build6 = require("@qwik.dev/core/build");
22642
+ var import_build8 = require("@qwik.dev/core/build");
22617
22643
 
22618
22644
  // packages/qwik/src/server/utils.ts
22619
22645
  var import_meta = {};
@@ -22647,7 +22673,7 @@ var versions = {
22647
22673
  };
22648
22674
 
22649
22675
  // packages/qwik/src/server/prefetch-strategy.ts
22650
- var import_build2 = require("@qwik.dev/core/build");
22676
+ var import_build3 = require("@qwik.dev/core/build");
22651
22677
  function getPrefetchResources(qrls, opts, resolvedManifest) {
22652
22678
  if (!resolvedManifest) {
22653
22679
  return [];
@@ -22685,7 +22711,7 @@ function getAutoPrefetch(qrls, resolvedManifest, buildBase) {
22685
22711
  return prefetchResources;
22686
22712
  }
22687
22713
  function addBundle(manifest, urls, prefetchResources, buildBase, bundleFileName) {
22688
- const url = import_build2.isDev ? bundleFileName : buildBase + bundleFileName;
22714
+ const url = import_build3.isDev ? bundleFileName : buildBase + bundleFileName;
22689
22715
  let prefetchResource = urls.get(url);
22690
22716
  if (!prefetchResource) {
22691
22717
  prefetchResource = {
@@ -22704,7 +22730,7 @@ function addBundle(manifest, urls, prefetchResources, buildBase, bundleFileName)
22704
22730
  }
22705
22731
  prefetchResources.push(prefetchResource);
22706
22732
  }
22707
- var isQrl = (value) => {
22733
+ var isQrl2 = (value) => {
22708
22734
  return typeof value === "function" && typeof value.getSymbol === "function";
22709
22735
  };
22710
22736
 
@@ -22716,12 +22742,9 @@ Object.freeze(EMPTY_OBJ);
22716
22742
 
22717
22743
  // packages/qwik/src/core/shared/qrl/qrl.ts
22718
22744
  var inlinedQrl = (symbol, symbolName, lexicalScopeCapture = EMPTY_ARRAY) => {
22719
- return createQRL(null, symbolName, symbol, null, null, lexicalScopeCapture, null);
22745
+ return createQRL(null, symbolName, symbol, null, null, lexicalScopeCapture);
22720
22746
  };
22721
22747
 
22722
- // packages/qwik/src/core/ssr/ssr-render-jsx.ts
22723
- var import_build5 = require("@qwik.dev/core/build");
22724
-
22725
22748
  // packages/qwik/src/core/shared/jsx/slot.public.ts
22726
22749
  var Slot = (props) => {
22727
22750
  return _jsxSorted(Virtual, null, { [QSlotS]: "" }, props.children, 0, props.name ?? "");
@@ -22808,17 +22831,61 @@ function isPreventDefault(key) {
22808
22831
  return key.startsWith("preventdefault:");
22809
22832
  }
22810
22833
 
22811
- // packages/qwik/src/core/shared/utils/unitless_number.ts
22812
- var unitlessNumbers = /* @__PURE__ */ new Set([
22813
- "animationIterationCount",
22814
- "aspectRatio",
22815
- "borderImageOutset",
22816
- "borderImageSlice",
22817
- "borderImageWidth",
22818
- "boxFlex",
22819
- "boxFlexGroup",
22820
- "boxOrdinalGroup",
22821
- "columnCount",
22834
+ // packages/qwik/src/core/shared/utils/jsx-filename.ts
22835
+ function getFileLocationFromJsx(jsxDev) {
22836
+ var _a;
22837
+ if (!jsxDev) {
22838
+ return null;
22839
+ }
22840
+ const sanitizedFileName = (_a = jsxDev.fileName) == null ? void 0 : _a.replace(/\\/g, "/");
22841
+ if (sanitizedFileName) {
22842
+ return `${sanitizedFileName}:${jsxDev.lineNumber}:${jsxDev.columnNumber}`;
22843
+ }
22844
+ return null;
22845
+ }
22846
+
22847
+ // packages/qwik/src/core/shared/utils/scoped-styles.ts
22848
+ var styleContent = (styleId) => {
22849
+ return ComponentStylesPrefixContent + styleId;
22850
+ };
22851
+ function hasClassAttr(props) {
22852
+ for (const key in props) {
22853
+ if (Object.prototype.hasOwnProperty.call(props, key) && isClassAttr(key)) {
22854
+ return true;
22855
+ }
22856
+ }
22857
+ return false;
22858
+ }
22859
+ function isClassAttr(key) {
22860
+ return key === "class" || key === "className";
22861
+ }
22862
+ function convertScopedStyleIdsToArray(scopedStyleIds) {
22863
+ return (scopedStyleIds == null ? void 0 : scopedStyleIds.split(" ")) ?? null;
22864
+ }
22865
+ function convertStyleIdsToString(scopedStyleIds) {
22866
+ return Array.from(scopedStyleIds).join(" ");
22867
+ }
22868
+ var addComponentStylePrefix = (styleId) => {
22869
+ if (styleId) {
22870
+ let idx = 0;
22871
+ do {
22872
+ styleId = styleId.substring(0, idx) + styleContent(styleId.substring(idx));
22873
+ } while ((idx = styleId.indexOf(" ", idx) + 1) !== 0);
22874
+ }
22875
+ return styleId || null;
22876
+ };
22877
+
22878
+ // packages/qwik/src/core/shared/utils/unitless_number.ts
22879
+ var unitlessNumbers = /* @__PURE__ */ new Set([
22880
+ "animationIterationCount",
22881
+ "aspectRatio",
22882
+ "borderImageOutset",
22883
+ "borderImageSlice",
22884
+ "borderImageWidth",
22885
+ "boxFlex",
22886
+ "boxFlexGroup",
22887
+ "boxOrdinalGroup",
22888
+ "columnCount",
22822
22889
  "columns",
22823
22890
  "flex",
22824
22891
  "flexGrow",
@@ -22945,37 +23012,6 @@ var setValueForStyle = (styleName, value) => {
22945
23012
  function isAriaAttribute(prop) {
22946
23013
  return prop.startsWith("aria-");
22947
23014
  }
22948
- var styleContent = (styleId) => {
22949
- return ComponentStylesPrefixContent + styleId;
22950
- };
22951
-
22952
- // packages/qwik/src/core/shared/utils/scoped-styles.ts
22953
- function hasClassAttr(props) {
22954
- for (const key in props) {
22955
- if (Object.prototype.hasOwnProperty.call(props, key) && isClassAttr(key)) {
22956
- return true;
22957
- }
22958
- }
22959
- return false;
22960
- }
22961
- function isClassAttr(key) {
22962
- return key === "class" || key === "className";
22963
- }
22964
- function convertScopedStyleIdsToArray(scopedStyleIds) {
22965
- return (scopedStyleIds == null ? void 0 : scopedStyleIds.split(" ")) ?? null;
22966
- }
22967
- function convertStyleIdsToString(scopedStyleIds) {
22968
- return Array.from(scopedStyleIds).join(" ");
22969
- }
22970
- var addComponentStylePrefix = (styleId) => {
22971
- if (styleId) {
22972
- let idx = 0;
22973
- do {
22974
- styleId = styleId.substring(0, idx) + styleContent(styleId.substring(idx));
22975
- } while ((idx = styleId.indexOf(" ", idx) + 1) !== 0);
22976
- }
22977
- return styleId || null;
22978
- };
22979
23015
 
22980
23016
  // packages/qwik/src/core/signal/store.ts
22981
23017
  var DEBUG = false;
@@ -23111,8 +23147,12 @@ var StoreHandler = class {
23111
23147
  return Reflect.ownKeys(target);
23112
23148
  }
23113
23149
  getOwnPropertyDescriptor(target, prop) {
23150
+ const descriptor = Reflect.getOwnPropertyDescriptor(target, prop);
23114
23151
  if (Array.isArray(target) || typeof prop === "symbol") {
23115
- return Object.getOwnPropertyDescriptor(target, prop);
23152
+ return descriptor;
23153
+ }
23154
+ if (descriptor && !descriptor.configurable) {
23155
+ return descriptor;
23116
23156
  }
23117
23157
  return {
23118
23158
  enumerable: true,
@@ -23120,17 +23160,18 @@ var StoreHandler = class {
23120
23160
  };
23121
23161
  }
23122
23162
  };
23123
- function addEffect(target, prop, store, effectSubscriber) {
23124
- const effectsMap = store.$effects$ ||= {};
23125
- const effects = Object.prototype.hasOwnProperty.call(effectsMap, prop) && effectsMap[prop] || (effectsMap[prop] = []);
23126
- ensureContainsEffect(effects, effectSubscriber);
23127
- ensureContains(effectSubscriber, target);
23128
- ensureEffectContainsSubscriber(
23129
- effectSubscriber[0 /* EFFECT */],
23130
- target,
23131
- store.$container$
23132
- );
23133
- DEBUG && log("sub", pad("\n" + store.$effects$.toString(), " "));
23163
+ function addEffect(target, prop, store, effectSubscription) {
23164
+ var _a;
23165
+ const effectsMap = store.$effects$ ||= /* @__PURE__ */ new Map();
23166
+ let effects = effectsMap.get(prop);
23167
+ if (!effects) {
23168
+ effects = /* @__PURE__ */ new Set();
23169
+ effectsMap.set(prop, effects);
23170
+ }
23171
+ ensureContainsSubscription(effects, effectSubscription);
23172
+ ensureContainsBackRef(effectSubscription, target);
23173
+ addQrlToSerializationCtx(effectSubscription, store.$container$);
23174
+ DEBUG && log("sub", pad("\n" + ((_a = store.$effects$) == null ? void 0 : _a.entries.toString()), " "));
23134
23175
  }
23135
23176
  function setNewValueAndTriggerEffects(prop, value, target, currentStore) {
23136
23177
  target[prop] = value;
@@ -23141,15 +23182,87 @@ function setNewValueAndTriggerEffects(prop, value, target, currentStore) {
23141
23182
  );
23142
23183
  }
23143
23184
  function getEffects(target, prop, storeEffects) {
23144
- let effectsToTrigger = storeEffects ? Array.isArray(target) ? Object.values(storeEffects).flatMap((effects) => effects) : storeEffects[prop] : null;
23145
- const storeArrayValue = storeEffects == null ? void 0 : storeEffects[STORE_ARRAY_PROP];
23185
+ let effectsToTrigger;
23186
+ if (storeEffects) {
23187
+ if (Array.isArray(target)) {
23188
+ for (const effects of storeEffects.values()) {
23189
+ effectsToTrigger ||= /* @__PURE__ */ new Set();
23190
+ for (const effect of effects) {
23191
+ effectsToTrigger.add(effect);
23192
+ }
23193
+ }
23194
+ } else {
23195
+ effectsToTrigger = storeEffects.get(prop);
23196
+ }
23197
+ }
23198
+ const storeArrayValue = storeEffects == null ? void 0 : storeEffects.get(STORE_ARRAY_PROP);
23146
23199
  if (storeArrayValue) {
23147
- effectsToTrigger ||= [];
23148
- effectsToTrigger.push(...storeArrayValue);
23200
+ effectsToTrigger ||= /* @__PURE__ */ new Set();
23201
+ for (const effect of storeArrayValue) {
23202
+ effectsToTrigger.add(effect);
23203
+ }
23204
+ }
23205
+ return effectsToTrigger || null;
23206
+ }
23207
+
23208
+ // packages/qwik/src/core/signal/flags.ts
23209
+ var NEEDS_COMPUTATION = Symbol("invalid");
23210
+ var _EFFECT_BACK_REF = Symbol("backRef");
23211
+
23212
+ // packages/qwik/src/core/signal/signal-cleanup.ts
23213
+ var BackRef = class {
23214
+ [_EFFECT_BACK_REF] = null;
23215
+ };
23216
+ function clearAllEffects(container, consumer) {
23217
+ if (vnode_isVNode(consumer) && vnode_isElementVNode(consumer)) {
23218
+ ensureMaterialized(consumer);
23219
+ }
23220
+ const effects = consumer[_EFFECT_BACK_REF];
23221
+ if (!effects) {
23222
+ return;
23223
+ }
23224
+ for (const [, effect] of effects) {
23225
+ const backRefs = effect[2 /* BACK_REF */];
23226
+ if (!backRefs) {
23227
+ return;
23228
+ }
23229
+ for (const producer of backRefs) {
23230
+ if (producer instanceof Signal) {
23231
+ clearSignal(container, producer, effect);
23232
+ } else if (container.$storeProxyMap$.has(producer)) {
23233
+ const target = container.$storeProxyMap$.get(producer);
23234
+ const storeHandler = getStoreHandler(target);
23235
+ clearStore(storeHandler, effect);
23236
+ }
23237
+ }
23238
+ }
23239
+ }
23240
+ function clearSignal(container, producer, effect) {
23241
+ const effects = producer.$effects$;
23242
+ if (effects) {
23243
+ effects.delete(effect);
23244
+ }
23245
+ if (producer instanceof WrappedSignal) {
23246
+ producer.$hostElement$ = null;
23247
+ clearAllEffects(container, producer);
23248
+ }
23249
+ }
23250
+ function clearStore(producer, effect) {
23251
+ const effects = producer == null ? void 0 : producer.$effects$;
23252
+ if (effects) {
23253
+ for (const propEffects of effects.values()) {
23254
+ propEffects.delete(effect);
23255
+ }
23149
23256
  }
23150
- return effectsToTrigger;
23151
23257
  }
23152
23258
 
23259
+ // packages/qwik/src/core/shared/qrl/implicit_dollar.ts
23260
+ var implicit$FirstArg = (fn) => {
23261
+ return function(first, ...rest) {
23262
+ return fn.call(null, dollar(first), ...rest);
23263
+ };
23264
+ };
23265
+
23153
23266
  // packages/qwik/src/core/use/use-sequential-scope.ts
23154
23267
  var useSequentialScope = () => {
23155
23268
  const iCtx = useInvokeContext();
@@ -23182,160 +23295,41 @@ var useSequentialScope = () => {
23182
23295
  };
23183
23296
  };
23184
23297
 
23185
- // packages/qwik/src/core/signal/signal-subscriber.ts
23186
- var Subscriber = class {
23187
- $effectDependencies$ = null;
23188
- };
23189
- function isSubscriber(value) {
23190
- return value instanceof Subscriber || value instanceof WrappedSignal;
23191
- }
23192
- function clearVNodeEffectDependencies(container, value) {
23193
- if (vnode_isElementVNode(value)) {
23194
- ensureMaterialized(value);
23195
- }
23196
- const effects = vnode_getProp(value, QSubscribers, container.$getObjectById$);
23197
- if (!effects) {
23198
- return;
23199
- }
23200
- for (let i = effects.length - 1; i >= 0; i--) {
23201
- const subscriber = effects[i];
23202
- clearEffects(subscriber, value, effects, i, container);
23203
- }
23204
- if (effects.length === 0) {
23205
- vnode_setProp(value, QSubscribers, null);
23206
- }
23207
- }
23208
- function clearSubscriberEffectDependencies(container, value) {
23209
- if (value.$effectDependencies$) {
23210
- for (let i = value.$effectDependencies$.length - 1; i >= 0; i--) {
23211
- const subscriber = value.$effectDependencies$[i];
23212
- clearEffects(subscriber, value, value.$effectDependencies$, i, container);
23213
- }
23214
- if (value.$effectDependencies$.length === 0) {
23215
- value.$effectDependencies$ = null;
23216
- }
23217
- }
23218
- }
23219
- function clearEffects(subscriber, value, effectArray, indexToRemove, container) {
23220
- let subscriptionRemoved = false;
23221
- const seenSet = /* @__PURE__ */ new Set();
23222
- if (subscriber instanceof WrappedSignal) {
23223
- subscriptionRemoved = clearSignalEffects(subscriber, value, seenSet);
23224
- } else if (container.$storeProxyMap$.has(subscriber)) {
23225
- const store = container.$storeProxyMap$.get(subscriber);
23226
- const handler = getStoreHandler(store);
23227
- subscriptionRemoved = clearStoreEffects(handler, value);
23228
- }
23229
- if (subscriptionRemoved) {
23230
- effectArray.splice(indexToRemove, 1);
23231
- }
23232
- }
23233
- function clearSignalEffects(subscriber, value, seenSet) {
23234
- const effectSubscriptions = subscriber.$effects$;
23235
- let subscriptionRemoved = false;
23236
- if (effectSubscriptions) {
23237
- for (let i = effectSubscriptions.length - 1; i >= 0; i--) {
23238
- const effect = effectSubscriptions[i];
23239
- if (effect[0 /* EFFECT */] === value) {
23240
- effectSubscriptions.splice(i, 1);
23241
- subscriptionRemoved = true;
23242
- }
23243
- }
23244
- }
23245
- if (subscriber instanceof WrappedSignal) {
23246
- const hostElement = subscriber.$hostElement$;
23247
- if (hostElement && hostElement === value) {
23248
- subscriber.$hostElement$ = null;
23249
- }
23250
- const args = subscriber.$args$;
23251
- if (args) {
23252
- clearArgsEffects(args, subscriber, seenSet);
23298
+ // packages/qwik/src/core/signal/subscriber.ts
23299
+ var import_build4 = require("@qwik.dev/core/build");
23300
+ function getSubscriber(effect, prop, data) {
23301
+ if (!effect[_EFFECT_BACK_REF]) {
23302
+ if (import_build4.isServer && isSsrNode(effect)) {
23303
+ effect.setProp(QBackRefs, /* @__PURE__ */ new Map());
23304
+ } else {
23305
+ effect[_EFFECT_BACK_REF] = /* @__PURE__ */ new Map();
23253
23306
  }
23254
23307
  }
23255
- return subscriptionRemoved;
23256
- }
23257
- function clearStoreEffects(storeHandler, value) {
23258
- const effectSubscriptions = storeHandler.$effects$;
23259
- if (!effectSubscriptions) {
23260
- return false;
23261
- }
23262
- let subscriptionRemoved = false;
23263
- for (const key in effectSubscriptions) {
23264
- const effects = effectSubscriptions[key];
23265
- for (let i = effects.length - 1; i >= 0; i--) {
23266
- const effect = effects[i];
23267
- if (effect[0 /* EFFECT */] === value) {
23268
- effects.splice(i, 1);
23269
- subscriptionRemoved = true;
23270
- }
23271
- }
23272
- if (effects.length === 0) {
23273
- delete effectSubscriptions[key];
23274
- }
23308
+ const subMap = effect[_EFFECT_BACK_REF];
23309
+ let sub = subMap.get(prop);
23310
+ if (!sub) {
23311
+ sub = [effect, prop];
23312
+ subMap.set(prop, sub);
23275
23313
  }
23276
- return subscriptionRemoved;
23277
- }
23278
- function clearArgsEffects(args, subscriber, seenSet) {
23279
- for (let i = args.length - 1; i >= 0; i--) {
23280
- const arg = args[i];
23281
- clearArgEffect(arg, subscriber, seenSet);
23314
+ if (data) {
23315
+ sub[3 /* DATA */] = data;
23282
23316
  }
23317
+ return sub;
23283
23318
  }
23284
- function clearArgEffect(arg, subscriber, seenSet) {
23285
- if (seenSet.has(arg)) {
23286
- return;
23287
- }
23288
- seenSet.add(arg);
23289
- if (isSignal(arg)) {
23290
- clearSignalEffects(arg, subscriber, seenSet);
23291
- } else if (typeof arg === "object" && arg !== null) {
23292
- if (isStore(arg)) {
23293
- clearStoreEffects(getStoreHandler(arg), subscriber);
23294
- } else {
23295
- for (const key in arg) {
23296
- clearArgEffect(arg[key], subscriber, seenSet);
23297
- }
23298
- }
23299
- } else if (Array.isArray(arg)) {
23300
- clearArgsEffects(arg, subscriber, seenSet);
23301
- } else {
23302
- }
23319
+ function isSsrNode(value) {
23320
+ return "__brand__" in value && "currentComponentNode" in value;
23303
23321
  }
23304
23322
 
23305
- // packages/qwik/src/core/use/use-resource.ts
23306
- var _createResourceReturn = (opts) => {
23307
- const resource = {
23308
- __brand: "resource",
23309
- value: void 0,
23310
- loading: isServerPlatform() ? false : true,
23311
- _resolved: void 0,
23312
- _error: void 0,
23313
- _state: "pending",
23314
- _timeout: (opts == null ? void 0 : opts.timeout) ?? -1,
23315
- _cache: 0
23316
- };
23317
- return resource;
23318
- };
23319
- var createResourceReturn = (container, opts, initialPromise) => {
23320
- const result = _createResourceReturn(opts);
23321
- result.value = initialPromise;
23322
- return createStore(container, result, 1 /* RECURSIVE */);
23323
- };
23324
- var runResource = (task, container, host) => {
23323
+ // packages/qwik/src/core/use/use-task.ts
23324
+ var runTask = (task, container, host) => {
23325
23325
  task.$flags$ &= ~8 /* DIRTY */;
23326
23326
  cleanupTask(task);
23327
- const iCtx = newInvokeContext(container.$locale$, host, void 0, ResourceEvent);
23327
+ const iCtx = newInvokeContext(container.$locale$, host, void 0, TaskEvent);
23328
23328
  iCtx.$container$ = container;
23329
- const taskFn = task.$qrl$.getFn(iCtx, () => clearSubscriberEffectDependencies(container, task));
23330
- const resource = task.$state$;
23331
- assertDefined(
23332
- resource,
23333
- 'useResource: when running a resource, "task.resource" must be a defined.',
23334
- task
23335
- );
23329
+ const taskFn = task.$qrl$.getFn(iCtx, () => clearAllEffects(container, task));
23336
23330
  const track = (obj, prop) => {
23337
23331
  const ctx = newInvokeContext();
23338
- ctx.$effectSubscriber$ = [task, ":" /* COMPONENT */];
23332
+ ctx.$effectSubscriber$ = getSubscriber(task, ":" /* COMPONENT */);
23339
23333
  ctx.$container$ = container;
23340
23334
  return invoke(ctx, () => {
23341
23335
  if (isFunction(obj)) {
@@ -23346,127 +23340,143 @@ var runResource = (task, container, host) => {
23346
23340
  } else if (isSignal(obj)) {
23347
23341
  return obj.value;
23348
23342
  } else {
23349
- return obj;
23343
+ throw qError(2 /* trackObjectWithoutProp */);
23350
23344
  }
23351
23345
  });
23352
23346
  };
23353
23347
  const handleError = (reason) => container.handleError(reason, host);
23354
- const cleanups = [];
23355
- task.$destroy$ = noSerialize(() => {
23356
- cleanups.forEach((fn) => {
23357
- try {
23358
- fn();
23359
- } catch (err) {
23360
- handleError(err);
23361
- }
23362
- });
23363
- done = true;
23364
- });
23365
- const resourceTarget = unwrapStore(resource);
23366
- const opts = {
23367
- track,
23368
- cleanup(fn) {
23369
- if (typeof fn === "function") {
23370
- cleanups.push(fn);
23348
+ let cleanupFns = null;
23349
+ const cleanup2 = (fn) => {
23350
+ if (typeof fn == "function") {
23351
+ if (!cleanupFns) {
23352
+ cleanupFns = [];
23353
+ task.$destroy$ = noSerialize(() => {
23354
+ task.$destroy$ = null;
23355
+ cleanupFns.forEach((fn2) => {
23356
+ try {
23357
+ fn2();
23358
+ } catch (err) {
23359
+ handleError(err);
23360
+ }
23361
+ });
23362
+ });
23371
23363
  }
23372
- },
23373
- cache(policy) {
23374
- let milliseconds = 0;
23375
- if (policy === "immutable") {
23376
- milliseconds = Infinity;
23364
+ cleanupFns.push(fn);
23365
+ }
23366
+ };
23367
+ const taskApi = { track, cleanup: cleanup2 };
23368
+ const result = safeCall(
23369
+ () => taskFn(taskApi),
23370
+ cleanup2,
23371
+ (err) => {
23372
+ if (isPromise(err)) {
23373
+ return err.then(() => runTask(task, container, host));
23377
23374
  } else {
23378
- milliseconds = policy;
23379
- }
23380
- resource._cache = milliseconds;
23381
- },
23382
- previous: resourceTarget._resolved
23383
- };
23384
- let resolve;
23385
- let reject;
23386
- let done = false;
23387
- const setState = (resolved, value) => {
23388
- if (!done) {
23389
- done = true;
23390
- if (resolved) {
23391
- done = true;
23392
- resource.loading = false;
23393
- resource._state = "resolved";
23394
- resource._resolved = value;
23395
- resource._error = void 0;
23396
- resolve(value);
23397
- } else {
23398
- done = true;
23399
- resource.loading = false;
23400
- resource._state = "rejected";
23401
- resource._error = value;
23402
- reject(value);
23403
- }
23404
- return true;
23405
- }
23406
- return false;
23407
- };
23408
- cleanups.push(() => {
23409
- if (untrack(() => resource.loading) === true) {
23410
- const value = untrack(() => resource._resolved);
23411
- setState(true, value);
23412
- }
23413
- });
23414
- invoke(iCtx, () => {
23415
- resource._state = "pending";
23416
- resource.loading = !isServerPlatform();
23417
- const promise2 = resource.value = new Promise((r, re) => {
23418
- resolve = r;
23419
- reject = re;
23420
- });
23421
- promise2.catch(ignoreErrorToPreventNodeFromCrashing);
23422
- });
23423
- const promise = safeCall(
23424
- () => Promise.resolve(taskFn(opts)),
23425
- (value) => {
23426
- setState(true, value);
23427
- },
23428
- (err) => {
23429
- if (isPromise(err)) {
23430
- return err.then(() => runResource(task, container, host));
23431
- } else {
23432
- setState(false, err);
23375
+ throw err;
23433
23376
  }
23434
23377
  }
23435
23378
  );
23436
- const timeout = resourceTarget._timeout;
23437
- if (timeout > 0) {
23438
- return Promise.race([
23439
- promise,
23440
- delay(timeout).then(() => {
23441
- if (setState(false, new Error("timeout"))) {
23442
- cleanupTask(task);
23443
- }
23444
- })
23445
- ]);
23379
+ return result;
23380
+ };
23381
+ var cleanupTask = (task) => {
23382
+ const destroy = task.$destroy$;
23383
+ if (destroy) {
23384
+ task.$destroy$ = null;
23385
+ try {
23386
+ destroy();
23387
+ } catch (err) {
23388
+ logError(err);
23389
+ }
23446
23390
  }
23447
- return promise;
23448
23391
  };
23449
- var ignoreErrorToPreventNodeFromCrashing = (err) => {
23392
+ var Task = class extends BackRef {
23393
+ constructor($flags$, $index$, $el$, $qrl$, $state$, $destroy$) {
23394
+ super();
23395
+ this.$flags$ = $flags$;
23396
+ this.$index$ = $index$;
23397
+ this.$el$ = $el$;
23398
+ this.$qrl$ = $qrl$;
23399
+ this.$state$ = $state$;
23400
+ this.$destroy$ = $destroy$;
23401
+ }
23402
+ };
23403
+ var isTask = (value) => {
23404
+ return value instanceof Task;
23450
23405
  };
23451
23406
 
23452
23407
  // packages/qwik/src/core/client/vnode-diff.ts
23453
- var import_build4 = require("@qwik.dev/core/build");
23408
+ var import_build7 = require("@qwik.dev/core/build");
23409
+
23410
+ // packages/qwik/src/core/client/util-mapArray.ts
23411
+ var mapApp_findIndx = (elementVNode, key, start) => {
23412
+ assertTrue(start % 2 === 0, "Expecting even number.");
23413
+ let bottom = start >> 1;
23414
+ let top = elementVNode.length - 2 >> 1;
23415
+ while (bottom <= top) {
23416
+ const mid = bottom + (top - bottom >> 1);
23417
+ const midKey = elementVNode[mid << 1];
23418
+ if (midKey === key) {
23419
+ return mid << 1;
23420
+ }
23421
+ if (midKey < key) {
23422
+ bottom = mid + 1;
23423
+ } else {
23424
+ top = mid - 1;
23425
+ }
23426
+ }
23427
+ return bottom << 1 ^ -1;
23428
+ };
23429
+ var mapArray_set = (elementVNode, key, value, start) => {
23430
+ const indx = mapApp_findIndx(elementVNode, key, start);
23431
+ if (indx >= 0) {
23432
+ if (value == null) {
23433
+ elementVNode.splice(indx, 2);
23434
+ } else {
23435
+ elementVNode[indx + 1] = value;
23436
+ }
23437
+ } else if (value != null) {
23438
+ elementVNode.splice(indx ^ -1, 0, key, value);
23439
+ }
23440
+ };
23441
+ var mapApp_remove = (elementVNode, key, start) => {
23442
+ const indx = mapApp_findIndx(elementVNode, key, start);
23443
+ let value = null;
23444
+ if (indx >= 0) {
23445
+ value = elementVNode[indx + 1];
23446
+ elementVNode.splice(indx, 2);
23447
+ return value;
23448
+ }
23449
+ return value;
23450
+ };
23451
+ var mapArray_get = (elementVNode, key, start) => {
23452
+ const indx = mapApp_findIndx(elementVNode, key, start);
23453
+ if (indx >= 0) {
23454
+ return elementVNode[indx + 1];
23455
+ } else {
23456
+ return null;
23457
+ }
23458
+ };
23454
23459
 
23455
23460
  // packages/qwik/src/core/client/vnode-namespace.ts
23456
- var isForeignObjectElement = (elementName) => elementName.toLowerCase() === "foreignobject";
23461
+ var import_build5 = require("@qwik.dev/core/build");
23462
+ var isForeignObjectElement = (elementName) => {
23463
+ return import_build5.isDev ? elementName.toLowerCase() === "foreignobject" : elementName === "foreignObject";
23464
+ };
23457
23465
  var isSvgElement = (elementName) => elementName === "svg" || isForeignObjectElement(elementName);
23458
23466
  var isMathElement = (elementName) => elementName === "math";
23459
23467
  var vnode_isDefaultNamespace = (vnode) => {
23460
23468
  const flags = vnode[0 /* flags */];
23461
23469
  return (flags & 192 /* NAMESPACE_MASK */) === 0;
23462
23470
  };
23463
- var vnode_getElementNamespaceFlags = (elementName) => {
23464
- if (isSvgElement(elementName)) {
23465
- return 64 /* NS_svg */;
23466
- } else if (isMathElement(elementName)) {
23467
- return 128 /* NS_math */;
23468
- } else {
23469
- 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 */;
23470
23480
  }
23471
23481
  };
23472
23482
  function vnode_getDomChildrenWithCorrectNamespacesToInsert(journal, domParentVNode, newChild) {
@@ -23622,21 +23632,28 @@ function getNewElementNamespaceData(domParentVNode, tagOrVNode) {
23622
23632
  }
23623
23633
 
23624
23634
  // packages/qwik/src/core/shared/component-execution.ts
23625
- var import_build3 = require("@qwik.dev/core/build");
23635
+ var import_build6 = require("@qwik.dev/core/build");
23626
23636
  var executeComponent = (container, renderHost, subscriptionHost, componentQRL, props) => {
23627
- const iCtx = newInvokeContext(container.$locale$, subscriptionHost, void 0, RenderEvent);
23628
- iCtx.$effectSubscriber$ = [subscriptionHost, ":" /* COMPONENT */];
23629
- 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
+ }
23630
23647
  let componentFn;
23631
23648
  container.ensureProjectionResolved(renderHost);
23632
23649
  let isInlineComponent = false;
23633
23650
  if (componentQRL === null) {
23634
- componentQRL = componentQRL || container.getHostProp(renderHost, OnRenderProp);
23651
+ componentQRL = container.getHostProp(renderHost, OnRenderProp);
23635
23652
  assertDefined(componentQRL, "No Component found at this location");
23636
23653
  }
23637
- if (isQrl2(componentQRL)) {
23654
+ if (isQrl(componentQRL)) {
23638
23655
  props = props || container.getHostProp(renderHost, ELEMENT_PROPS) || EMPTY_OBJ;
23639
- if (props && props.children) {
23656
+ if (props.children) {
23640
23657
  delete props.children;
23641
23658
  }
23642
23659
  componentFn = componentQRL.getFn(iCtx);
@@ -23653,19 +23670,17 @@ var executeComponent = (container, renderHost, subscriptionHost, componentQRL, p
23653
23670
  if (!isInlineComponent) {
23654
23671
  container.setHostProp(renderHost, ELEMENT_SEQ_IDX, null);
23655
23672
  container.setHostProp(renderHost, USE_ON_LOCAL_SEQ_IDX, null);
23656
- if (container.getHostProp(renderHost, ELEMENT_PROPS) !== props) {
23657
- container.setHostProp(renderHost, ELEMENT_PROPS, props);
23658
- }
23673
+ container.setHostProp(renderHost, ELEMENT_PROPS, props);
23659
23674
  }
23660
23675
  if (vnode_isVNode(renderHost)) {
23661
- clearVNodeEffectDependencies(container, renderHost);
23676
+ clearAllEffects(container, renderHost);
23662
23677
  }
23663
23678
  return componentFn(props);
23664
23679
  },
23665
23680
  (jsx4) => {
23666
23681
  const useOnEvents = container.getHostProp(renderHost, USE_ON_LOCAL);
23667
23682
  if (useOnEvents) {
23668
- return maybeThen(addUseOnEvents(jsx4, useOnEvents), () => jsx4);
23683
+ return addUseOnEvents(jsx4, useOnEvents);
23669
23684
  }
23670
23685
  return jsx4;
23671
23686
  },
@@ -23683,6 +23698,7 @@ var executeComponent = (container, renderHost, subscriptionHost, componentQRL, p
23683
23698
  };
23684
23699
  function addUseOnEvents(jsx4, useOnEvents) {
23685
23700
  const jsxElement = findFirstStringJSX(jsx4);
23701
+ let jsxResult = jsx4;
23686
23702
  return maybeThen(jsxElement, (jsxElement2) => {
23687
23703
  let isInvisibleComponent = false;
23688
23704
  if (!jsxElement2) {
@@ -23692,16 +23708,18 @@ function addUseOnEvents(jsx4, useOnEvents) {
23692
23708
  if (Object.prototype.hasOwnProperty.call(useOnEvents, key)) {
23693
23709
  if (isInvisibleComponent) {
23694
23710
  if (key === "onQvisible$") {
23695
- jsxElement2 = addScriptNodeForInvisibleComponents(jsx4);
23696
- if (jsxElement2) {
23697
- 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]);
23698
23715
  }
23699
23716
  } else if (key.startsWith("document:") || key.startsWith("window:")) {
23700
- jsxElement2 = addScriptNodeForInvisibleComponents(jsx4);
23701
- if (jsxElement2) {
23702
- addUseOnEvent(jsxElement2, key, useOnEvents[key]);
23717
+ const [jsxElement3, jsx5] = addScriptNodeForInvisibleComponents(jsxResult);
23718
+ jsxResult = jsx5;
23719
+ if (jsxElement3) {
23720
+ addUseOnEvent(jsxElement3, key, useOnEvents[key]);
23703
23721
  }
23704
- } else if (import_build3.isDev) {
23722
+ } else if (import_build6.isDev) {
23705
23723
  logWarn(
23706
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. '
23707
23725
  );
@@ -23711,7 +23729,7 @@ function addUseOnEvents(jsx4, useOnEvents) {
23711
23729
  }
23712
23730
  }
23713
23731
  }
23714
- return jsxElement2;
23732
+ return jsxResult;
23715
23733
  });
23716
23734
  }
23717
23735
  function addUseOnEvent(jsxElement, key, value) {
@@ -23762,6 +23780,9 @@ function addScriptNodeForInvisibleComponents(jsx4) {
23762
23780
  null,
23763
23781
  3
23764
23782
  );
23783
+ if (jsx4.type === Slot) {
23784
+ return [jsxElement, _jsxSorted(Fragment, null, null, [jsx4, jsxElement], 0, null)];
23785
+ }
23765
23786
  if (jsx4.children == null) {
23766
23787
  jsx4.children = jsxElement;
23767
23788
  } else if (Array.isArray(jsx4.children)) {
@@ -23769,13 +23790,19 @@ function addScriptNodeForInvisibleComponents(jsx4) {
23769
23790
  } else {
23770
23791
  jsx4.children = [jsx4.children, jsxElement];
23771
23792
  }
23772
- return jsxElement;
23793
+ return [jsxElement, jsx4];
23773
23794
  } else if (Array.isArray(jsx4) && jsx4.length) {
23774
- return addScriptNodeForInvisibleComponents(jsx4[0]);
23795
+ const [jsxElement, _] = addScriptNodeForInvisibleComponents(jsx4[0]);
23796
+ return [jsxElement, jsx4];
23775
23797
  }
23776
- return null;
23798
+ return [null, null];
23777
23799
  }
23778
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
+
23779
23806
  // packages/qwik/src/core/shared/utils/prop.ts
23780
23807
  function isSlotProp(prop) {
23781
23808
  return !prop.startsWith("q:") && !prop.startsWith(NON_SERIALIZABLE_MARKER_PREFIX);
@@ -23814,19 +23841,6 @@ function escapeHTML(html) {
23814
23841
  }
23815
23842
  }
23816
23843
 
23817
- // packages/qwik/src/core/shared/utils/jsx-filename.ts
23818
- function getFileLocationFromJsx(jsxDev) {
23819
- var _a;
23820
- if (!jsxDev) {
23821
- return null;
23822
- }
23823
- const sanitizedFileName = (_a = jsxDev.fileName) == null ? void 0 : _a.replace(/\\/g, "/");
23824
- if (sanitizedFileName) {
23825
- return `${sanitizedFileName}:${jsxDev.lineNumber}:${jsxDev.columnNumber}`;
23826
- }
23827
- return null;
23828
- }
23829
-
23830
23844
  // packages/qwik/src/core/client/vnode-diff.ts
23831
23845
  var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
23832
23846
  let journal = container.$journal$;
@@ -23863,7 +23877,7 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
23863
23877
  descend(jsxValue, false);
23864
23878
  } else if (isSignal(jsxValue)) {
23865
23879
  if (vCurrent) {
23866
- clearVNodeEffectDependencies(container, vCurrent);
23880
+ clearAllEffects(container, vCurrent);
23867
23881
  }
23868
23882
  expectVirtual("S" /* WrappedSignal */, null);
23869
23883
  descend(
@@ -24020,8 +24034,9 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
24020
24034
  };
24021
24035
  const projections = [];
24022
24036
  if (host) {
24023
- for (let i = vnode_getPropStartIndex(host); i < host.length; i = i + 2) {
24024
- const prop = host[i];
24037
+ const props = vnode_getProps(host);
24038
+ for (let i = 0; i < props.length; i = i + 2) {
24039
+ const prop = props[i];
24025
24040
  if (isSlotProp(prop)) {
24026
24041
  const slotName = prop;
24027
24042
  projections.push(slotName);
@@ -24065,8 +24080,8 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
24065
24080
  );
24066
24081
  if (vCurrent == null) {
24067
24082
  vNewNode = vnode_newVirtual();
24068
- import_build4.isDev && vnode_setProp(vNewNode, DEBUG_TYPE, "P" /* Projection */);
24069
- import_build4.isDev && vnode_setProp(vNewNode, "q:code", "expectProjection");
24083
+ import_build7.isDev && vnode_setProp(vNewNode, DEBUG_TYPE, "P" /* Projection */);
24084
+ import_build7.isDev && vnode_setProp(vNewNode, "q:code", "expectProjection");
24070
24085
  vnode_setProp(vNewNode, QSlot, slotName);
24071
24086
  vnode_setProp(vNewNode, QSlotParent, vParent);
24072
24087
  vnode_setProp(vParent, slotName, vNewNode);
@@ -24092,8 +24107,8 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
24092
24107
  );
24093
24108
  vnode_setProp(vNewNode, QSlot, slotNameKey);
24094
24109
  vHost && vnode_setProp(vHost, slotNameKey, vNewNode);
24095
- import_build4.isDev && vnode_setProp(vNewNode, DEBUG_TYPE, "P" /* Projection */);
24096
- import_build4.isDev && vnode_setProp(vNewNode, "q:code", "expectSlot" + count++);
24110
+ import_build7.isDev && vnode_setProp(vNewNode, DEBUG_TYPE, "P" /* Projection */);
24111
+ import_build7.isDev && vnode_setProp(vNewNode, "q:code", "expectSlot" + count++);
24097
24112
  return false;
24098
24113
  } else if (vProjectedNode === vCurrent) {
24099
24114
  } else {
@@ -24105,8 +24120,8 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
24105
24120
  );
24106
24121
  vnode_setProp(vNewNode, QSlot, slotNameKey);
24107
24122
  vHost && vnode_setProp(vHost, slotNameKey, vNewNode);
24108
- import_build4.isDev && vnode_setProp(vNewNode, DEBUG_TYPE, "P" /* Projection */);
24109
- import_build4.isDev && vnode_setProp(vNewNode, "q:code", "expectSlot" + count++);
24123
+ import_build7.isDev && vnode_setProp(vNewNode, DEBUG_TYPE, "P" /* Projection */);
24124
+ import_build7.isDev && vnode_setProp(vNewNode, "q:code", "expectSlot" + count++);
24110
24125
  }
24111
24126
  return true;
24112
24127
  }
@@ -24177,14 +24192,20 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
24177
24192
  if (isJsxPropertyAnEventName(key2)) {
24178
24193
  const eventName = getEventNameFromJsxProp(key2);
24179
24194
  const scope = getEventNameScopeFromJsxProp(key2);
24180
- vnode_setProp(
24181
- vNewNode,
24182
- HANDLER_PREFIX + ":" + scope + ":" + eventName,
24183
- value
24184
- );
24185
24195
  if (eventName) {
24196
+ vnode_setProp(
24197
+ vNewNode,
24198
+ HANDLER_PREFIX + ":" + scope + ":" + eventName,
24199
+ value
24200
+ );
24186
24201
  registerQwikLoaderEvent(eventName);
24187
24202
  }
24203
+ if (scope) {
24204
+ const htmlEvent = convertEventNameFromJsxPropToHtmlAttr(key2);
24205
+ if (htmlEvent) {
24206
+ vnode_setAttr(journal, vNewNode, htmlEvent, "");
24207
+ }
24208
+ }
24188
24209
  needsQDispatchEventPatch = true;
24189
24210
  continue;
24190
24211
  }
@@ -24195,12 +24216,14 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
24195
24216
  } else if (typeof value === "function") {
24196
24217
  value(element);
24197
24218
  continue;
24219
+ } else if (value == null) {
24220
+ continue;
24198
24221
  } else {
24199
24222
  throw qError(32 /* invalidRefValue */, [currentFile]);
24200
24223
  }
24201
24224
  }
24202
24225
  if (isSignal(value)) {
24203
- const signalData = new EffectPropData({
24226
+ const signalData = new SubscriptionData({
24204
24227
  $scopedStyleIdPrefix$: scopedStyleIdPrefix,
24205
24228
  $isConst$: true
24206
24229
  });
@@ -24219,7 +24242,7 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
24219
24242
  }
24220
24243
  if (elementName === "textarea" && key2 === "value") {
24221
24244
  if (value && typeof value !== "string") {
24222
- if (import_build4.isDev) {
24245
+ if (import_build7.isDev) {
24223
24246
  throw qError(40 /* wrongTextareaValue */, [currentFile, value]);
24224
24247
  }
24225
24248
  continue;
@@ -24300,7 +24323,12 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
24300
24323
  let returnValue = false;
24301
24324
  qrls.flat(2).forEach((qrl2) => {
24302
24325
  if (qrl2) {
24303
- const value = qrl2(event, element);
24326
+ const value = container.$scheduler$(
24327
+ 2 /* RUN_QRL */,
24328
+ vNode,
24329
+ qrl2,
24330
+ [event, element]
24331
+ );
24304
24332
  returnValue = returnValue || value === true;
24305
24333
  }
24306
24334
  });
@@ -24311,10 +24339,10 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
24311
24339
  }
24312
24340
  function setBulkProps(vnode, srcAttrs, currentFile) {
24313
24341
  vnode_ensureElementInflated(vnode);
24314
- const dstAttrs = vnode;
24342
+ const dstAttrs = vnode_getProps(vnode);
24315
24343
  let srcIdx = 0;
24316
24344
  const srcLength = srcAttrs.length;
24317
- let dstIdx = 8 /* PROPS_OFFSET */;
24345
+ let dstIdx = 0;
24318
24346
  let dstLength = dstAttrs.length;
24319
24347
  let srcKey = srcIdx < srcLength ? srcAttrs[srcIdx++] : null;
24320
24348
  let dstKey = dstIdx < dstLength ? dstAttrs[dstIdx++] : null;
@@ -24332,12 +24360,14 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
24332
24360
  } else if (typeof value === "function") {
24333
24361
  value(element);
24334
24362
  return;
24363
+ } else if (value == null) {
24364
+ return;
24335
24365
  } else {
24336
24366
  throw qError(32 /* invalidRefValue */, [currentFile]);
24337
24367
  }
24338
24368
  }
24339
24369
  if (isSignal(value)) {
24340
- const signalData = new EffectPropData({
24370
+ const signalData = new SubscriptionData({
24341
24371
  $scopedStyleIdPrefix$: scopedStyleIdPrefix,
24342
24372
  $isConst$: false
24343
24373
  });
@@ -24350,17 +24380,17 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
24350
24380
  };
24351
24381
  const recordJsxEvent = (key, value) => {
24352
24382
  const eventName = getEventNameFromJsxProp(key);
24383
+ const scope = getEventNameScopeFromJsxProp(key);
24353
24384
  if (eventName) {
24354
- const scope = getEventNameScopeFromJsxProp(key);
24355
24385
  record(":" + scope + ":" + eventName, value);
24356
- }
24357
- const htmlEvent = convertEventNameFromJsxPropToHtmlAttr(key);
24358
- if (htmlEvent) {
24359
- record(htmlEvent, "");
24360
- }
24361
- if (eventName) {
24362
24386
  registerQwikLoaderEvent(eventName);
24363
24387
  }
24388
+ if (scope) {
24389
+ const htmlEvent = convertEventNameFromJsxPropToHtmlAttr(key);
24390
+ if (htmlEvent) {
24391
+ record(htmlEvent, "");
24392
+ }
24393
+ }
24364
24394
  };
24365
24395
  while (srcKey !== null || dstKey !== null) {
24366
24396
  if ((dstKey == null ? void 0 : dstKey.startsWith(HANDLER_PREFIX)) || (dstKey == null ? void 0 : dstKey.startsWith(Q_PREFIX))) {
@@ -24476,7 +24506,7 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
24476
24506
  vCurrent && getInsertBefore()
24477
24507
  );
24478
24508
  vnode_setProp(vNewNode, ELEMENT_KEY, jsxKey);
24479
- import_build4.isDev && vnode_setProp(vNewNode || vCurrent, DEBUG_TYPE, type);
24509
+ import_build7.isDev && vnode_setProp(vNewNode || vCurrent, DEBUG_TYPE, type);
24480
24510
  }
24481
24511
  function expectComponent(component) {
24482
24512
  const componentMeta = component[SERIALIZABLE_STATE];
@@ -24504,9 +24534,6 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
24504
24534
  } else if (!hashesAreEqual) {
24505
24535
  insertNewComponent(host, componentQRL, jsxProps);
24506
24536
  if (vNewNode) {
24507
- if (host) {
24508
- vNewNode[0 /* flags */] = host[0 /* flags */];
24509
- }
24510
24537
  host = vNewNode;
24511
24538
  shouldRender = true;
24512
24539
  }
@@ -24516,7 +24543,7 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
24516
24543
  shouldRender = shouldRender || propsDiffer(jsxProps, vNodeProps);
24517
24544
  if (shouldRender) {
24518
24545
  host[0 /* flags */] &= ~32 /* Deleted */;
24519
- container.$scheduler$(7 /* COMPONENT */, host, componentQRL, jsxProps);
24546
+ container.$scheduler$(6 /* COMPONENT */, host, componentQRL, jsxProps);
24520
24547
  }
24521
24548
  }
24522
24549
  descendContentToProject(jsxNode2.children, host);
@@ -24551,7 +24578,7 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
24551
24578
  }
24552
24579
  function insertNewComponent(host, componentQRL, jsxProps) {
24553
24580
  if (host) {
24554
- clearVNodeEffectDependencies(container, host);
24581
+ clearAllEffects(container, host);
24555
24582
  }
24556
24583
  vnode_insertBefore(
24557
24584
  journal,
@@ -24560,7 +24587,7 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
24560
24587
  vCurrent && getInsertBefore()
24561
24588
  );
24562
24589
  const jsxNode2 = jsxValue;
24563
- import_build4.isDev && vnode_setProp(vNewNode, DEBUG_TYPE, "C" /* Component */);
24590
+ import_build7.isDev && vnode_setProp(vNewNode, DEBUG_TYPE, "C" /* Component */);
24564
24591
  container.setHostProp(vNewNode, OnRenderProp, componentQRL);
24565
24592
  container.setHostProp(vNewNode, ELEMENT_PROPS, jsxProps);
24566
24593
  container.setHostProp(vNewNode, ELEMENT_KEY, jsxNode2.key);
@@ -24573,7 +24600,7 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
24573
24600
  vCurrent && getInsertBefore()
24574
24601
  );
24575
24602
  const jsxNode2 = jsxValue;
24576
- import_build4.isDev && vnode_setProp(vNewNode, DEBUG_TYPE, "I" /* InlineComponent */);
24603
+ import_build7.isDev && vnode_setProp(vNewNode, DEBUG_TYPE, "I" /* InlineComponent */);
24577
24604
  vnode_setProp(vNewNode, ELEMENT_PROPS, jsxNode2.props);
24578
24605
  if (jsxNode2.key) {
24579
24606
  vnode_setProp(vNewNode, ELEMENT_KEY, jsxNode2.key);
@@ -24617,8 +24644,8 @@ function propsDiffer(src, dst) {
24617
24644
  if (!src || !dst) {
24618
24645
  return true;
24619
24646
  }
24620
- let srcKeys = removePropsKeys(Object.keys(src), ["children", QSubscribers]);
24621
- let dstKeys = removePropsKeys(Object.keys(dst), ["children", QSubscribers]);
24647
+ let srcKeys = removePropsKeys(Object.keys(src), ["children", QBackRefs]);
24648
+ let dstKeys = removePropsKeys(Object.keys(dst), ["children", QBackRefs]);
24622
24649
  if (srcKeys.length !== dstKeys.length) {
24623
24650
  return true;
24624
24651
  }
@@ -24652,7 +24679,7 @@ function cleanup(container, vNode) {
24652
24679
  do {
24653
24680
  const type = vCursor[0 /* flags */];
24654
24681
  if (type & 3 /* ELEMENT_OR_VIRTUAL_MASK */) {
24655
- clearVNodeEffectDependencies(container, vCursor);
24682
+ clearAllEffects(container, vCursor);
24656
24683
  markVNodeAsDeleted(vCursor);
24657
24684
  if (type & 2 /* Virtual */) {
24658
24685
  const seq = container.getHostProp(vCursor, ELEMENT_SEQ);
@@ -24661,7 +24688,7 @@ function cleanup(container, vNode) {
24661
24688
  const obj = seq[i];
24662
24689
  if (isTask(obj)) {
24663
24690
  const task = obj;
24664
- clearSubscriberEffectDependencies(container, task);
24691
+ clearAllEffects(container, task);
24665
24692
  if (task.$flags$ & 1 /* VISIBLE_TASK */) {
24666
24693
  container.$scheduler$(48 /* CLEANUP_VISIBLE */, task);
24667
24694
  } else {
@@ -24673,8 +24700,8 @@ function cleanup(container, vNode) {
24673
24700
  }
24674
24701
  const isComponent = type & 2 /* Virtual */ && vnode_getProp(vCursor, OnRenderProp, null) !== null;
24675
24702
  if (isComponent) {
24676
- const attrs = vCursor;
24677
- for (let i = 6 /* PROPS_OFFSET */; i < attrs.length; i = i + 2) {
24703
+ const attrs = vnode_getProps(vCursor);
24704
+ for (let i = 0; i < attrs.length; i = i + 2) {
24678
24705
  const key = attrs[i];
24679
24706
  if (!isParentSlotProp(key) && isSlotProp(key)) {
24680
24707
  const value = attrs[i + 1];
@@ -24746,208 +24773,491 @@ function markVNodeAsDeleted(vCursor) {
24746
24773
  var HANDLER_PREFIX = ":";
24747
24774
  var count = 0;
24748
24775
 
24749
- // packages/qwik/src/core/shared/qrl/implicit_dollar.ts
24750
- var implicit$FirstArg = (fn) => {
24751
- return function(first, ...rest) {
24752
- return fn.call(null, dollar(first), ...rest);
24776
+ // packages/qwik/src/core/use/use-resource.ts
24777
+ var _createResourceReturn = (opts) => {
24778
+ const resource = {
24779
+ __brand: "resource",
24780
+ value: void 0,
24781
+ loading: isServerPlatform() ? false : true,
24782
+ _resolved: void 0,
24783
+ _error: void 0,
24784
+ _state: "pending",
24785
+ _timeout: (opts == null ? void 0 : opts.timeout) ?? -1,
24786
+ _cache: 0
24753
24787
  };
24788
+ return resource;
24754
24789
  };
24755
-
24756
- // packages/qwik/src/core/shared/scheduler.ts
24757
- var DEBUG2 = false;
24758
- var createScheduler = (container, scheduleDrain, journalFlush) => {
24759
- const choreQueue = [];
24760
- let currentChore = null;
24761
- let journalFlushScheduled = false;
24762
- return schedule;
24763
- function schedule(type, hostOrTask = null, targetOrQrl = null, payload = null) {
24764
- const runLater = type !== 255 /* WAIT_FOR_ALL */ && type !== 6 /* COMPONENT_SSR */;
24765
- const isTask2 = type === 3 /* TASK */ || type === 32 /* VISIBLE */ || type === 2 /* RESOURCE */ || type === 48 /* CLEANUP_VISIBLE */;
24766
- if (isTask2) {
24767
- hostOrTask.$flags$ |= 8 /* DIRTY */;
24768
- }
24769
- let chore = {
24770
- $type$: type,
24771
- $idx$: isTask2 ? hostOrTask.$index$ : typeof targetOrQrl === "string" ? targetOrQrl : 0,
24772
- $host$: isTask2 ? hostOrTask.$el$ : hostOrTask,
24773
- $target$: targetOrQrl,
24774
- $payload$: isTask2 ? hostOrTask : payload,
24775
- $resolve$: null,
24776
- $promise$: null,
24777
- $returnValue$: null,
24778
- $executed$: false
24779
- };
24780
- chore.$promise$ = new Promise((resolve) => chore.$resolve$ = resolve);
24781
- DEBUG2 && debugTrace("schedule", chore, currentChore, choreQueue);
24782
- chore = sortedInsert(choreQueue, chore, container.rootVNode || null);
24783
- if (!journalFlushScheduled && runLater) {
24784
- journalFlushScheduled = true;
24785
- schedule(16 /* JOURNAL_FLUSH */);
24786
- scheduleDrain();
24787
- }
24788
- if (runLater) {
24789
- return chore.$promise$;
24790
- } else {
24791
- return drainUpTo(chore, container.rootVNode || null);
24792
- }
24793
- }
24794
- function drainUpTo(runUptoChore, rootVNode) {
24795
- if (runUptoChore.$executed$) {
24796
- return runUptoChore.$returnValue$;
24797
- }
24798
- if (currentChore) {
24799
- return runUptoChore.$promise$;
24800
- }
24801
- while (choreQueue.length) {
24802
- const nextChore = choreQueue.shift();
24803
- const order = choreComparator(nextChore, runUptoChore, rootVNode, false);
24804
- if (order === null) {
24805
- continue;
24806
- }
24807
- if (order > 0) {
24808
- break;
24809
- }
24810
- const isDeletedVNode = vNodeAlreadyDeleted(nextChore);
24811
- if (isDeletedVNode && // we need to process cleanup tasks for deleted nodes
24812
- nextChore.$type$ !== 48 /* CLEANUP_VISIBLE */) {
24813
- DEBUG2 && debugTrace("skip chore", nextChore, currentChore, choreQueue);
24814
- continue;
24790
+ var createResourceReturn = (container, opts, initialPromise) => {
24791
+ const result = _createResourceReturn(opts);
24792
+ result.value = initialPromise;
24793
+ return createStore(container, result, 1 /* RECURSIVE */);
24794
+ };
24795
+ var runResource = (task, container, host) => {
24796
+ task.$flags$ &= ~8 /* DIRTY */;
24797
+ cleanupTask(task);
24798
+ const iCtx = newInvokeContext(container.$locale$, host, void 0, ResourceEvent);
24799
+ iCtx.$container$ = container;
24800
+ const taskFn = task.$qrl$.getFn(iCtx, () => clearAllEffects(container, task));
24801
+ const resource = task.$state$;
24802
+ assertDefined(
24803
+ resource,
24804
+ 'useResource: when running a resource, "task.resource" must be a defined.',
24805
+ task
24806
+ );
24807
+ const track = (obj, prop) => {
24808
+ const ctx = newInvokeContext();
24809
+ ctx.$effectSubscriber$ = getSubscriber(task, ":" /* COMPONENT */);
24810
+ ctx.$container$ = container;
24811
+ return invoke(ctx, () => {
24812
+ if (isFunction(obj)) {
24813
+ return obj();
24815
24814
  }
24816
- const returnValue = executeChore(nextChore);
24817
- if (isPromise(returnValue)) {
24818
- const promise = returnValue.then(() => drainUpTo(runUptoChore, rootVNode));
24819
- return promise;
24815
+ if (prop) {
24816
+ return obj[prop];
24817
+ } else if (isSignal(obj)) {
24818
+ return obj.value;
24819
+ } else {
24820
+ return obj;
24820
24821
  }
24821
- }
24822
- return runUptoChore.$returnValue$;
24822
+ });
24823
+ };
24824
+ const handleError = (reason) => container.handleError(reason, host);
24825
+ const cleanups = [];
24826
+ task.$destroy$ = noSerialize(() => {
24827
+ cleanups.forEach((fn) => {
24828
+ try {
24829
+ fn();
24830
+ } catch (err) {
24831
+ handleError(err);
24832
+ }
24833
+ });
24834
+ done = true;
24835
+ });
24836
+ const resourceTarget = unwrapStore(resource);
24837
+ const opts = {
24838
+ track,
24839
+ cleanup(fn) {
24840
+ if (typeof fn === "function") {
24841
+ cleanups.push(fn);
24842
+ }
24843
+ },
24844
+ cache(policy) {
24845
+ let milliseconds = 0;
24846
+ if (policy === "immutable") {
24847
+ milliseconds = Infinity;
24848
+ } else {
24849
+ milliseconds = policy;
24850
+ }
24851
+ resource._cache = milliseconds;
24852
+ },
24853
+ previous: resourceTarget._resolved
24854
+ };
24855
+ let resolve;
24856
+ let reject;
24857
+ let done = false;
24858
+ const setState = (resolved, value) => {
24859
+ if (!done) {
24860
+ done = true;
24861
+ if (resolved) {
24862
+ done = true;
24863
+ resource.loading = false;
24864
+ resource._state = "resolved";
24865
+ resource._resolved = value;
24866
+ resource._error = void 0;
24867
+ resolve(value);
24868
+ } else {
24869
+ done = true;
24870
+ resource.loading = false;
24871
+ resource._state = "rejected";
24872
+ resource._error = value;
24873
+ reject(value);
24874
+ }
24875
+ return true;
24876
+ }
24877
+ return false;
24878
+ };
24879
+ cleanups.push(() => {
24880
+ if (untrack(() => resource.loading) === true) {
24881
+ const value = untrack(() => resource._resolved);
24882
+ setState(true, value);
24883
+ }
24884
+ });
24885
+ invoke(iCtx, () => {
24886
+ resource._state = "pending";
24887
+ resource.loading = !isServerPlatform();
24888
+ const promise2 = resource.value = new Promise((r, re) => {
24889
+ resolve = r;
24890
+ reject = re;
24891
+ });
24892
+ promise2.catch(ignoreErrorToPreventNodeFromCrashing);
24893
+ });
24894
+ const promise = safeCall(
24895
+ () => Promise.resolve(taskFn(opts)),
24896
+ (value) => {
24897
+ setState(true, value);
24898
+ },
24899
+ (err) => {
24900
+ if (isPromise(err)) {
24901
+ return err.then(() => runResource(task, container, host));
24902
+ } else {
24903
+ setState(false, err);
24904
+ }
24905
+ }
24906
+ );
24907
+ const timeout = resourceTarget._timeout;
24908
+ if (timeout > 0) {
24909
+ return Promise.race([
24910
+ promise,
24911
+ delay(timeout).then(() => {
24912
+ if (setState(false, new Error("timeout"))) {
24913
+ cleanupTask(task);
24914
+ }
24915
+ })
24916
+ ]);
24823
24917
  }
24824
- function executeChore(chore) {
24825
- var _a;
24918
+ return promise;
24919
+ };
24920
+ var ignoreErrorToPreventNodeFromCrashing = (err) => {
24921
+ };
24922
+
24923
+ // packages/qwik/src/core/shared/scheduler-document-position.ts
24924
+ var aVNodePath = [];
24925
+ var bVNodePath = [];
24926
+ var vnode_documentPosition = (a, b, rootVNode) => {
24927
+ if (a === b) {
24928
+ return 0;
24929
+ }
24930
+ let aDepth = -1;
24931
+ let bDepth = -1;
24932
+ while (a) {
24933
+ const vNode = aVNodePath[++aDepth] = a;
24934
+ a = vNode[1 /* parent */] || rootVNode && vnode_getProp(a, QSlotParent, (id) => vnode_locate(rootVNode, id));
24935
+ }
24936
+ while (b) {
24937
+ const vNode = bVNodePath[++bDepth] = b;
24938
+ b = vNode[1 /* parent */] || rootVNode && vnode_getProp(b, QSlotParent, (id) => vnode_locate(rootVNode, id));
24939
+ }
24940
+ while (aDepth >= 0 && bDepth >= 0) {
24941
+ a = aVNodePath[aDepth];
24942
+ b = bVNodePath[bDepth];
24943
+ if (a === b) {
24944
+ aDepth--;
24945
+ bDepth--;
24946
+ } else {
24947
+ let cursor = b;
24948
+ do {
24949
+ cursor = vnode_getNextSibling(cursor);
24950
+ if (cursor === a) {
24951
+ return 1;
24952
+ }
24953
+ } while (cursor);
24954
+ cursor = b;
24955
+ do {
24956
+ cursor = vnode_getPreviousSibling(cursor);
24957
+ if (cursor === a) {
24958
+ return -1;
24959
+ }
24960
+ } while (cursor);
24961
+ if (rootVNode && vnode_getProp(b, QSlotParent, (id) => vnode_locate(rootVNode, id))) {
24962
+ return -1;
24963
+ }
24964
+ return 1;
24965
+ }
24966
+ }
24967
+ return aDepth < bDepth ? -1 : 1;
24968
+ };
24969
+ var aSsrNodePath = [];
24970
+ var bSsrNodePath = [];
24971
+ var ssrNodeDocumentPosition = (a, b) => {
24972
+ if (a === b) {
24973
+ return 0;
24974
+ }
24975
+ let aDepth = -1;
24976
+ let bDepth = -1;
24977
+ while (a) {
24978
+ const ssrNode = aSsrNodePath[++aDepth] = a;
24979
+ a = ssrNode.currentComponentNode;
24980
+ }
24981
+ while (b) {
24982
+ const ssrNode = bSsrNodePath[++bDepth] = b;
24983
+ b = ssrNode.currentComponentNode;
24984
+ }
24985
+ while (aDepth >= 0 && bDepth >= 0) {
24986
+ a = aSsrNodePath[aDepth];
24987
+ b = bSsrNodePath[bDepth];
24988
+ if (a === b) {
24989
+ aDepth--;
24990
+ bDepth--;
24991
+ } else {
24992
+ return 1;
24993
+ }
24994
+ }
24995
+ return aDepth < bDepth ? -1 : 1;
24996
+ };
24997
+
24998
+ // packages/qwik/src/core/shared/scheduler.ts
24999
+ var DEBUG2 = false;
25000
+ var getPromise = (chore) => chore.$promise$ ||= new Promise((resolve) => {
25001
+ chore.$resolve$ = resolve;
25002
+ });
25003
+ var createScheduler = (container, scheduleDrain, journalFlush) => {
25004
+ const choreQueue = [];
25005
+ const qrlRuns = [];
25006
+ let currentChore = null;
25007
+ let drainScheduled = false;
25008
+ return schedule;
25009
+ function schedule(type, hostOrTask = null, targetOrQrl = null, payload = null) {
25010
+ var _a, _b;
25011
+ const isServer4 = !isDomContainer(container);
25012
+ const isComponentSsr = isServer4 && type === 6 /* COMPONENT */;
25013
+ const runLater = type !== 255 /* WAIT_FOR_ALL */ && !isComponentSsr && type !== 2 /* RUN_QRL */;
25014
+ const isTask2 = type === 3 /* TASK */ || type === 32 /* VISIBLE */ || type === 48 /* CLEANUP_VISIBLE */;
25015
+ const isClientOnly = type === 16 /* JOURNAL_FLUSH */ || type === 4 /* NODE_DIFF */ || type === 5 /* NODE_PROP */;
25016
+ if (isServer4 && isClientOnly) {
25017
+ DEBUG2 && debugTrace(
25018
+ `skip client chore ${debugChoreTypeToString(type)}`,
25019
+ null,
25020
+ currentChore,
25021
+ choreQueue
25022
+ );
25023
+ return;
25024
+ }
25025
+ if (isTask2) {
25026
+ hostOrTask.$flags$ |= 8 /* DIRTY */;
25027
+ }
25028
+ let chore = {
25029
+ $type$: type,
25030
+ $idx$: isTask2 ? hostOrTask.$index$ : typeof targetOrQrl === "string" ? targetOrQrl : 0,
25031
+ $host$: isTask2 ? hostOrTask.$el$ : hostOrTask,
25032
+ $target$: targetOrQrl,
25033
+ $payload$: isTask2 ? hostOrTask : payload,
25034
+ $resolve$: null,
25035
+ $promise$: null,
25036
+ $returnValue$: null,
25037
+ $executed$: false
25038
+ };
25039
+ chore = sortedInsert(choreQueue, chore, container.rootVNode || null);
25040
+ DEBUG2 && debugTrace("schedule", chore, currentChore, choreQueue);
25041
+ if (!drainScheduled && runLater) {
25042
+ drainScheduled = true;
25043
+ schedule(16 /* JOURNAL_FLUSH */);
25044
+ (_b = (_a = scheduleDrain()) == null ? void 0 : _a.catch) == null ? void 0 : _b.call(_a, () => {
25045
+ });
25046
+ }
25047
+ if (runLater) {
25048
+ return getPromise(chore);
25049
+ } else {
25050
+ return drainUpTo(chore, isServer4);
25051
+ }
25052
+ }
25053
+ function drainUpTo(runUptoChore, isServer4) {
25054
+ let maxRetries = 5e3;
25055
+ while (choreQueue.length) {
25056
+ if (maxRetries-- < 0) {
25057
+ throw new Error("drainUpTo: max retries reached");
25058
+ }
25059
+ if (currentChore) {
25060
+ return getPromise(currentChore).then(() => drainUpTo(runUptoChore, isServer4)).catch((e) => {
25061
+ container.handleError(e, currentChore == null ? void 0 : currentChore.$host$);
25062
+ });
25063
+ }
25064
+ const nextChore = choreQueue[0];
25065
+ if (nextChore.$executed$) {
25066
+ choreQueue.shift();
25067
+ if (nextChore === runUptoChore) {
25068
+ break;
25069
+ }
25070
+ continue;
25071
+ }
25072
+ if (vNodeAlreadyDeleted(nextChore) && // we need to process cleanup tasks for deleted nodes
25073
+ nextChore.$type$ !== 48 /* CLEANUP_VISIBLE */) {
25074
+ DEBUG2 && debugTrace("skip chore", nextChore, currentChore, choreQueue);
25075
+ choreQueue.shift();
25076
+ continue;
25077
+ }
25078
+ executeChore(nextChore, isServer4);
25079
+ }
25080
+ return runUptoChore.$returnValue$;
25081
+ }
25082
+ function executeChore(chore, isServer4) {
25083
+ var _a, _b, _c;
24826
25084
  const host = chore.$host$;
24827
25085
  DEBUG2 && debugTrace("execute", chore, currentChore, choreQueue);
24828
25086
  assertEqual(currentChore, null, "Chore already running.");
24829
25087
  currentChore = chore;
24830
25088
  let returnValue = null;
24831
- switch (chore.$type$) {
24832
- case 16 /* JOURNAL_FLUSH */:
24833
- returnValue = journalFlush();
24834
- journalFlushScheduled = false;
24835
- break;
24836
- case 7 /* COMPONENT */:
24837
- case 6 /* COMPONENT_SSR */:
24838
- returnValue = safeCall(
24839
- () => executeComponent(
24840
- container,
24841
- host,
24842
- host,
24843
- chore.$target$,
24844
- chore.$payload$
24845
- ),
24846
- (jsx5) => {
24847
- if (chore.$type$ === 7 /* COMPONENT */) {
24848
- const styleScopedId = container.getHostProp(host, QScopedStyle);
24849
- return vnode_diff(
25089
+ try {
25090
+ switch (chore.$type$) {
25091
+ case 255 /* WAIT_FOR_ALL */:
25092
+ {
25093
+ if (isServer4) {
25094
+ drainScheduled = false;
25095
+ }
25096
+ }
25097
+ break;
25098
+ case 16 /* JOURNAL_FLUSH */:
25099
+ {
25100
+ returnValue = journalFlush();
25101
+ drainScheduled = false;
25102
+ }
25103
+ break;
25104
+ case 6 /* COMPONENT */:
25105
+ {
25106
+ returnValue = safeCall(
25107
+ () => executeComponent(
24850
25108
  container,
24851
- jsx5,
24852
25109
  host,
24853
- addComponentStylePrefix(styleScopedId)
24854
- );
25110
+ host,
25111
+ chore.$target$,
25112
+ chore.$payload$
25113
+ ),
25114
+ (jsx4) => {
25115
+ if (isServer4) {
25116
+ return jsx4;
25117
+ } else {
25118
+ const styleScopedId = container.getHostProp(host, QScopedStyle);
25119
+ return retryOnPromise(
25120
+ () => vnode_diff(
25121
+ container,
25122
+ jsx4,
25123
+ host,
25124
+ addComponentStylePrefix(styleScopedId)
25125
+ )
25126
+ );
25127
+ }
25128
+ },
25129
+ (err) => container.handleError(err, host)
25130
+ );
25131
+ }
25132
+ break;
25133
+ case 2 /* RUN_QRL */:
25134
+ {
25135
+ const fn = chore.$target$.getFn();
25136
+ const result = retryOnPromise(() => fn(...chore.$payload$));
25137
+ if (isPromise(result)) {
25138
+ const handled = result.finally(() => {
25139
+ qrlRuns.splice(qrlRuns.indexOf(handled), 1);
25140
+ }).catch((error) => {
25141
+ container.handleError(error, chore.$host$);
25142
+ });
25143
+ qrlRuns.push(handled);
25144
+ DEBUG2 && debugTrace("execute.DONE (but still running)", chore, currentChore, choreQueue);
25145
+ chore.$returnValue$ = handled;
25146
+ (_a = chore.$resolve$) == null ? void 0 : _a.call(chore, handled);
25147
+ currentChore = null;
25148
+ chore.$executed$ = true;
25149
+ return;
25150
+ }
25151
+ returnValue = null;
25152
+ }
25153
+ break;
25154
+ case 3 /* TASK */:
25155
+ case 32 /* VISIBLE */:
25156
+ {
25157
+ const payload = chore.$payload$;
25158
+ if (payload.$flags$ & 4 /* RESOURCE */) {
25159
+ const result = runResource(payload, container, host);
25160
+ returnValue = isServer4 ? result : null;
24855
25161
  } else {
24856
- return jsx5;
25162
+ returnValue = runTask(payload, container, host);
24857
25163
  }
24858
- },
24859
- (err) => container.handleError(err, host)
24860
- );
24861
- break;
24862
- case 2 /* RESOURCE */:
24863
- const result = runResource(chore.$payload$, container, host);
24864
- returnValue = isDomContainer(container) ? null : result;
24865
- break;
24866
- case 3 /* TASK */:
24867
- returnValue = runTask(chore.$payload$, container, host);
24868
- break;
24869
- case 32 /* VISIBLE */:
24870
- returnValue = runTask(chore.$payload$, container, host);
24871
- break;
24872
- case 48 /* CLEANUP_VISIBLE */:
24873
- const task = chore.$payload$;
24874
- cleanupTask(task);
24875
- break;
24876
- case 4 /* NODE_DIFF */:
24877
- const parentVirtualNode = chore.$target$;
24878
- let jsx4 = chore.$payload$;
24879
- if (isSignal(jsx4)) {
24880
- jsx4 = jsx4.value;
24881
- }
24882
- returnValue = vnode_diff(container, jsx4, parentVirtualNode, null);
24883
- break;
24884
- case 5 /* NODE_PROP */:
24885
- const virtualNode = chore.$host$;
24886
- const payload = chore.$payload$;
24887
- let value = payload.$value$;
24888
- if (isSignal(value)) {
24889
- value = value.value;
24890
- }
24891
- const isConst = payload.$isConst$;
24892
- const journal = container.$journal$;
24893
- const property = chore.$idx$;
24894
- const serializedValue = serializeAttribute(property, value, payload.$scopedStyleIdPrefix$);
24895
- if (isConst) {
24896
- const element = virtualNode[6 /* element */];
24897
- journal.push(2 /* SetAttribute */, element, property, serializedValue);
24898
- } else {
24899
- vnode_setAttr(journal, virtualNode, property, serializedValue);
24900
- }
24901
- break;
24902
- case 1 /* QRL_RESOLVE */: {
24903
- const target = chore.$target$;
24904
- returnValue = !target.resolved ? target.resolve() : null;
24905
- break;
24906
- }
24907
- case 8 /* RECOMPUTE_AND_SCHEDULE_EFFECTS */: {
24908
- const target = chore.$target$;
24909
- const forceRunEffects = target.$forceRunEffects$;
24910
- target.$forceRunEffects$ = false;
24911
- if (!((_a = target.$effects$) == null ? void 0 : _a.length)) {
25164
+ }
25165
+ break;
25166
+ case 48 /* CLEANUP_VISIBLE */:
25167
+ {
25168
+ const task = chore.$payload$;
25169
+ cleanupTask(task);
25170
+ }
25171
+ break;
25172
+ case 4 /* NODE_DIFF */:
25173
+ {
25174
+ const parentVirtualNode = chore.$target$;
25175
+ let jsx4 = chore.$payload$;
25176
+ if (isSignal(jsx4)) {
25177
+ jsx4 = jsx4.value;
25178
+ }
25179
+ returnValue = retryOnPromise(
25180
+ () => vnode_diff(container, jsx4, parentVirtualNode, null)
25181
+ );
25182
+ }
25183
+ break;
25184
+ case 5 /* NODE_PROP */:
25185
+ {
25186
+ const virtualNode = chore.$host$;
25187
+ const payload = chore.$payload$;
25188
+ let value = payload.$value$;
25189
+ if (isSignal(value)) {
25190
+ value = value.value;
25191
+ }
25192
+ const isConst = payload.$isConst$;
25193
+ const journal = container.$journal$;
25194
+ const property = chore.$idx$;
25195
+ const serializedValue = serializeAttribute(
25196
+ property,
25197
+ value,
25198
+ payload.$scopedStyleIdPrefix$
25199
+ );
25200
+ if (isConst) {
25201
+ const element = virtualNode[6 /* element */];
25202
+ journal.push(2 /* SetAttribute */, element, property, serializedValue);
25203
+ } else {
25204
+ vnode_setAttr(journal, virtualNode, property, serializedValue);
25205
+ }
25206
+ }
25207
+ break;
25208
+ case 1 /* QRL_RESOLVE */: {
25209
+ {
25210
+ const target = chore.$target$;
25211
+ returnValue = !target.resolved ? target.resolve() : null;
25212
+ }
24912
25213
  break;
24913
25214
  }
24914
- returnValue = retryOnPromise(() => {
24915
- if (target.$computeIfNeeded$() || forceRunEffects) {
24916
- triggerEffects(container, target, target.$effects$);
25215
+ case 7 /* RECOMPUTE_AND_SCHEDULE_EFFECTS */: {
25216
+ {
25217
+ const target = chore.$target$;
25218
+ const forceRunEffects = target.$forceRunEffects$;
25219
+ target.$forceRunEffects$ = false;
25220
+ if (!((_b = target.$effects$) == null ? void 0 : _b.size)) {
25221
+ break;
25222
+ }
25223
+ returnValue = retryOnPromise(() => {
25224
+ if (target.$computeIfNeeded$() || forceRunEffects) {
25225
+ triggerEffects(container, target, target.$effects$);
25226
+ }
25227
+ });
24917
25228
  }
24918
- });
24919
- break;
25229
+ break;
25230
+ }
24920
25231
  }
25232
+ } catch (e) {
25233
+ returnValue = Promise.reject(e);
24921
25234
  }
24922
- return maybeThenPassError(returnValue, (value) => {
25235
+ const after = (value, error) => {
24923
25236
  var _a2;
24924
- DEBUG2 && debugTrace("execute.DONE", null, currentChore, choreQueue);
24925
- if (currentChore) {
24926
- currentChore.$executed$ = true;
24927
- (_a2 = currentChore.$resolve$) == null ? void 0 : _a2.call(currentChore, value);
24928
- }
24929
25237
  currentChore = null;
24930
- return chore.$returnValue$ = value;
24931
- });
24932
- }
24933
- };
24934
- var toNumber = (value) => {
24935
- return typeof value === "number" ? value : -1;
24936
- };
24937
- var choreUpdate = (existing, newChore) => {
24938
- if (existing.$type$ === 4 /* NODE_DIFF */) {
24939
- existing.$payload$ = newChore.$payload$;
24940
- }
24941
- };
24942
- function vNodeAlreadyDeleted(chore) {
24943
- return !!(chore.$host$ && vnode_isVNode(chore.$host$) && chore.$host$[0 /* flags */] & 32 /* Deleted */);
24944
- }
24945
- function choreComparator(a, b, rootVNode, shouldThrowOnHostMismatch) {
24946
- const macroTypeDiff = (a.$type$ & 240 /* MACRO */) - (b.$type$ & 240 /* MACRO */);
24947
- if (macroTypeDiff !== 0) {
24948
- return macroTypeDiff;
25238
+ chore.$executed$ = true;
25239
+ if (error) {
25240
+ DEBUG2 && debugTrace("execute.ERROR", chore, currentChore, choreQueue);
25241
+ container.handleError(error, host);
25242
+ } else {
25243
+ chore.$returnValue$ = value;
25244
+ DEBUG2 && debugTrace("execute.DONE", chore, currentChore, choreQueue);
25245
+ (_a2 = chore.$resolve$) == null ? void 0 : _a2.call(chore, value);
25246
+ }
25247
+ };
25248
+ if (isPromise(returnValue)) {
25249
+ chore.$promise$ = returnValue.then(after, (error) => after(void 0, error));
25250
+ (_c = chore.$resolve$) == null ? void 0 : _c.call(chore, chore.$promise$);
25251
+ chore.$resolve$ = void 0;
25252
+ } else {
25253
+ after(returnValue);
25254
+ }
24949
25255
  }
24950
- if (a.$type$ !== 16 /* JOURNAL_FLUSH */) {
25256
+ function choreComparator(a, b, rootVNode) {
25257
+ const macroTypeDiff = (a.$type$ & 240 /* MACRO */) - (b.$type$ & 240 /* MACRO */);
25258
+ if (macroTypeDiff !== 0) {
25259
+ return macroTypeDiff;
25260
+ }
24951
25261
  const aHost = a.$host$;
24952
25262
  const bHost = b.$host$;
24953
25263
  if (aHost !== bHost && aHost !== null && bHost !== null) {
@@ -24957,15 +25267,17 @@ function choreComparator(a, b, rootVNode, shouldThrowOnHostMismatch) {
24957
25267
  return hostDiff;
24958
25268
  }
24959
25269
  } else {
25270
+ assertFalse(vnode_isVNode(aHost), "expected aHost to be SSRNode but it is a VNode");
25271
+ assertFalse(vnode_isVNode(bHost), "expected bHost to be SSRNode but it is a VNode");
24960
25272
  const errorMessage = `SERVER: during HTML streaming, re-running tasks on a different host is not allowed.
24961
25273
  You are attempting to change a state that has already been streamed to the client.
24962
25274
  This can lead to inconsistencies between Server-Side Rendering (SSR) and Client-Side Rendering (CSR).
24963
25275
  Problematic Node: ${aHost.toString()}`;
24964
- if (shouldThrowOnHostMismatch) {
24965
- throw qError(45 /* serverHostMismatch */, [errorMessage]);
24966
- }
24967
25276
  logWarn(errorMessage);
24968
- return null;
25277
+ const hostDiff = ssrNodeDocumentPosition(aHost, bHost);
25278
+ if (hostDiff !== 0) {
25279
+ return hostDiff;
25280
+ }
24969
25281
  }
24970
25282
  }
24971
25283
  const microTypeDiff = (a.$type$ & 15 /* MICRO */) - (b.$type$ & 15 /* MICRO */);
@@ -24976,167 +25288,91 @@ function choreComparator(a, b, rootVNode, shouldThrowOnHostMismatch) {
24976
25288
  if (idxDiff !== 0) {
24977
25289
  return idxDiff;
24978
25290
  }
24979
- if (a.$target$ !== b.$target$ && (a.$type$ === 1 /* QRL_RESOLVE */ && b.$type$ === 1 /* QRL_RESOLVE */ || a.$type$ === 5 /* NODE_PROP */ && b.$type$ === 5 /* NODE_PROP */ || a.$type$ === 8 /* RECOMPUTE_AND_SCHEDULE_EFFECTS */ && b.$type$ === 8 /* RECOMPUTE_AND_SCHEDULE_EFFECTS */)) {
25291
+ if (a.$target$ !== b.$target$ || a.$payload$ !== b.$payload$) {
25292
+ return 1;
25293
+ }
25294
+ if (b === currentChore) {
24980
25295
  return 1;
24981
25296
  }
25297
+ return 0;
24982
25298
  }
24983
- return 0;
24984
- }
24985
- function sortedFindIndex(sortedArray, value, rootVNode) {
24986
- let bottom = 0;
24987
- let top = sortedArray.length;
24988
- while (bottom < top) {
24989
- const middle = bottom + (top - bottom >> 1);
24990
- const midChore = sortedArray[middle];
24991
- const comp = choreComparator(value, midChore, rootVNode, true);
24992
- if (comp < 0) {
24993
- top = middle;
24994
- } else if (comp > 0) {
24995
- bottom = middle + 1;
24996
- } else {
24997
- return middle;
25299
+ function sortedFindIndex(sortedArray, value, rootVNode) {
25300
+ let bottom = 0;
25301
+ let top = sortedArray.length;
25302
+ while (bottom < top) {
25303
+ const middle = bottom + (top - bottom >> 1);
25304
+ const midChore = sortedArray[middle];
25305
+ const comp = choreComparator(value, midChore, rootVNode);
25306
+ if (comp < 0) {
25307
+ top = middle;
25308
+ } else if (comp > 0) {
25309
+ bottom = middle + 1;
25310
+ } else {
25311
+ return middle;
25312
+ }
24998
25313
  }
25314
+ return ~bottom;
24999
25315
  }
25000
- return ~bottom;
25001
- }
25002
- function sortedInsert(sortedArray, value, rootVNode) {
25003
- const idx = sortedFindIndex(sortedArray, value, rootVNode);
25004
- if (idx < 0) {
25005
- sortedArray.splice(~idx, 0, value);
25006
- return value;
25316
+ function sortedInsert(sortedArray, value, rootVNode) {
25317
+ const idx = sortedFindIndex(sortedArray, value, rootVNode);
25318
+ if (idx < 0) {
25319
+ sortedArray.splice(~idx, 0, value);
25320
+ return value;
25321
+ }
25322
+ const existing = sortedArray[idx];
25323
+ if (existing.$type$ === 4 /* NODE_DIFF */) {
25324
+ existing.$payload$ = value.$payload$;
25325
+ }
25326
+ if (existing.$executed$) {
25327
+ existing.$executed$ = false;
25328
+ }
25329
+ return existing;
25007
25330
  }
25008
- const existing = sortedArray[idx];
25009
- choreUpdate(existing, value);
25010
- return existing;
25331
+ };
25332
+ var toNumber = (value) => {
25333
+ return typeof value === "number" ? value : -1;
25334
+ };
25335
+ function vNodeAlreadyDeleted(chore) {
25336
+ return !!(chore.$host$ && vnode_isVNode(chore.$host$) && chore.$host$[0 /* flags */] & 32 /* Deleted */);
25011
25337
  }
25012
- function debugChoreToString(chore) {
25013
- var _a;
25014
- const type = {
25338
+ function debugChoreTypeToString(type) {
25339
+ return {
25015
25340
  [1 /* QRL_RESOLVE */]: "QRL_RESOLVE",
25016
- [2 /* RESOURCE */]: "RESOURCE",
25341
+ [2 /* RUN_QRL */]: "RUN_QRL",
25017
25342
  [3 /* TASK */]: "TASK",
25018
25343
  [4 /* NODE_DIFF */]: "NODE_DIFF",
25019
25344
  [5 /* NODE_PROP */]: "NODE_PROP",
25020
- [7 /* COMPONENT */]: "COMPONENT",
25021
- [6 /* COMPONENT_SSR */]: "COMPONENT_SSR",
25022
- [8 /* RECOMPUTE_AND_SCHEDULE_EFFECTS */]: "RECOMPUTE_SIGNAL",
25345
+ [6 /* COMPONENT */]: "COMPONENT",
25346
+ [7 /* RECOMPUTE_AND_SCHEDULE_EFFECTS */]: "RECOMPUTE_SIGNAL",
25023
25347
  [16 /* JOURNAL_FLUSH */]: "JOURNAL_FLUSH",
25024
25348
  [32 /* VISIBLE */]: "VISIBLE",
25025
25349
  [48 /* CLEANUP_VISIBLE */]: "CLEANUP_VISIBLE",
25026
25350
  [255 /* WAIT_FOR_ALL */]: "WAIT_FOR_ALL"
25027
- }[chore.$type$] || "UNKNOWN: " + chore.$type$;
25351
+ }[type] || "UNKNOWN: " + type;
25352
+ }
25353
+ function debugChoreToString(chore) {
25354
+ var _a;
25355
+ const type = debugChoreTypeToString(chore.$type$);
25028
25356
  const host = String(chore.$host$).replaceAll(/\n.*/gim, "");
25029
25357
  const qrlTarget = (_a = chore.$target$) == null ? void 0 : _a.$symbol$;
25030
- return `Chore(${type} ${chore.$type$ === 1 /* QRL_RESOLVE */ ? qrlTarget : host} ${chore.$idx$})`;
25358
+ return `Chore(${type} ${chore.$type$ === 1 /* QRL_RESOLVE */ || chore.$type$ === 2 /* RUN_QRL */ ? qrlTarget : host} ${chore.$idx$})`;
25031
25359
  }
25032
25360
  function debugTrace(action, arg, currentChore, queue) {
25033
- const lines = ["Scheduler: " + action];
25034
- if (arg) {
25035
- lines.push(
25036
- " arg: " + ("$type$" in arg ? debugChoreToString(arg) : String(arg).replaceAll(/\n.*/gim, ""))
25037
- );
25038
- }
25039
- if (currentChore) {
25040
- lines.push("running: " + debugChoreToString(currentChore));
25361
+ const lines = ["===========================\nScheduler: " + action];
25362
+ if (arg && !("$type$" in arg)) {
25363
+ lines.push(" arg: " + String(arg).replaceAll(/\n.*/gim, ""));
25041
25364
  }
25042
25365
  if (queue) {
25043
- queue.forEach((chore, idx) => {
25044
- lines.push((idx == 0 ? " queue: " : " ") + debugChoreToString(chore));
25366
+ queue.forEach((chore) => {
25367
+ const active = chore === arg ? ">>>" : " ";
25368
+ lines.push(
25369
+ ` ${active} > ` + (chore === currentChore ? "[running] " : "") + debugChoreToString(chore)
25370
+ );
25045
25371
  });
25046
25372
  }
25047
- console.log(lines.join("\n ") + "\n");
25373
+ console.log(lines.join("\n") + "\n");
25048
25374
  }
25049
25375
 
25050
- // packages/qwik/src/core/use/use-task.ts
25051
- var runTask = (task, container, host) => {
25052
- task.$flags$ &= ~8 /* DIRTY */;
25053
- cleanupTask(task);
25054
- const iCtx = newInvokeContext(container.$locale$, host, void 0, TaskEvent);
25055
- iCtx.$container$ = container;
25056
- const taskFn = task.$qrl$.getFn(
25057
- iCtx,
25058
- () => clearSubscriberEffectDependencies(container, task)
25059
- );
25060
- const track = (obj, prop) => {
25061
- const ctx = newInvokeContext();
25062
- ctx.$effectSubscriber$ = [task, ":" /* COMPONENT */];
25063
- ctx.$container$ = container;
25064
- return invoke(ctx, () => {
25065
- if (isFunction(obj)) {
25066
- return obj();
25067
- }
25068
- if (prop) {
25069
- return obj[prop];
25070
- } else if (isSignal(obj)) {
25071
- return obj.value;
25072
- } else {
25073
- return obj;
25074
- }
25075
- });
25076
- };
25077
- const handleError = (reason) => container.handleError(reason, host);
25078
- let cleanupFns = null;
25079
- const cleanup2 = (fn) => {
25080
- if (typeof fn == "function") {
25081
- if (!cleanupFns) {
25082
- cleanupFns = [];
25083
- task.$destroy$ = noSerialize(() => {
25084
- task.$destroy$ = null;
25085
- cleanupFns.forEach((fn2) => {
25086
- try {
25087
- fn2();
25088
- } catch (err) {
25089
- handleError(err);
25090
- }
25091
- });
25092
- });
25093
- }
25094
- cleanupFns.push(fn);
25095
- }
25096
- };
25097
- const taskApi = { track, cleanup: cleanup2 };
25098
- const result = safeCall(
25099
- () => taskFn(taskApi),
25100
- cleanup2,
25101
- (err) => {
25102
- if (isPromise(err)) {
25103
- return err.then(() => runTask(task, container, host));
25104
- } else {
25105
- return handleError(err);
25106
- }
25107
- }
25108
- );
25109
- return result;
25110
- };
25111
- var cleanupTask = (task) => {
25112
- const destroy = task.$destroy$;
25113
- if (destroy) {
25114
- task.$destroy$ = null;
25115
- try {
25116
- destroy();
25117
- } catch (err) {
25118
- logError(err);
25119
- }
25120
- }
25121
- };
25122
- var Task = class extends Subscriber {
25123
- constructor($flags$, $index$, $el$, $qrl$, $state$, $destroy$) {
25124
- super();
25125
- this.$flags$ = $flags$;
25126
- this.$index$ = $index$;
25127
- this.$el$ = $el$;
25128
- this.$qrl$ = $qrl$;
25129
- this.$state$ = $state$;
25130
- this.$destroy$ = $destroy$;
25131
- }
25132
- };
25133
- var isTask = (value) => {
25134
- return value instanceof Task;
25135
- };
25136
-
25137
- // packages/qwik/src/core/signal/flags.ts
25138
- var NEEDS_COMPUTATION = Symbol("invalid");
25139
-
25140
25376
  // packages/qwik/src/core/signal/signal.ts
25141
25377
  var DEBUG3 = false;
25142
25378
  var log2 = (...args) => console.log("SIGNAL", ...args.map(qwikDebugToString));
@@ -25149,7 +25385,7 @@ var throwIfQRLNotResolved = (qrl2) => {
25149
25385
  var isSignal = (value) => {
25150
25386
  return value instanceof Signal;
25151
25387
  };
25152
- var EffectPropData = class {
25388
+ var SubscriptionData = class {
25153
25389
  data;
25154
25390
  constructor(data) {
25155
25391
  this.data = data;
@@ -25188,16 +25424,10 @@ var Signal = class {
25188
25424
  }
25189
25425
  const effectSubscriber = ctx.$effectSubscriber$;
25190
25426
  if (effectSubscriber) {
25191
- const effects = this.$effects$ ||= [];
25192
- ensureContainsEffect(effects, effectSubscriber);
25193
- ensureContains(effectSubscriber, this);
25194
- if (isSubscriber(this)) {
25195
- ensureEffectContainsSubscriber(
25196
- effectSubscriber[0 /* EFFECT */],
25197
- this,
25198
- this.$container$
25199
- );
25200
- }
25427
+ const effects = this.$effects$ ||= /* @__PURE__ */ new Set();
25428
+ ensureContainsSubscription(effects, effectSubscriber);
25429
+ ensureContainsBackRef(effectSubscriber, this);
25430
+ addQrlToSerializationCtx(effectSubscriber, this.$container$);
25201
25431
  DEBUG3 && log2("read->sub", pad("\n" + this.toString(), " "));
25202
25432
  }
25203
25433
  }
@@ -25213,119 +25443,89 @@ var Signal = class {
25213
25443
  // prevent accidental use as value
25214
25444
  valueOf() {
25215
25445
  if (qDev) {
25216
- throw qError(46 /* cannotCoerceSignal */);
25446
+ throw qError(45 /* cannotCoerceSignal */);
25217
25447
  }
25218
25448
  }
25219
25449
  toString() {
25220
- var _a;
25221
- return `[${this.constructor.name}${this.$invalid$ ? " INVALID" : ""} ${String(this.$untrackedValue$)}]` + (((_a = this.$effects$) == null ? void 0 : _a.map((e) => "\n -> " + pad(qwikDebugToString(e[0]), " ")).join("\n")) || "");
25450
+ return `[${this.constructor.name}${this.$invalid$ ? " INVALID" : ""} ${String(this.$untrackedValue$)}]` + (Array.from(this.$effects$ || []).map((e) => "\n -> " + pad(qwikDebugToString(e[0]), " ")).join("\n") || "");
25222
25451
  }
25223
25452
  toJSON() {
25224
25453
  return { value: this.$untrackedValue$ };
25225
25454
  }
25226
25455
  };
25227
- var ensureContains = (array, value) => {
25228
- const isMissing = array.indexOf(value) === -1;
25229
- if (isMissing) {
25230
- array.push(value);
25231
- }
25232
- };
25233
- var ensureContainsEffect = (array, effectSubscriptions) => {
25234
- for (let i = 0; i < array.length; i++) {
25235
- const existingEffect = array[i];
25236
- if (existingEffect[0] === effectSubscriptions[0] && existingEffect[1] === effectSubscriptions[1]) {
25237
- return;
25238
- }
25239
- }
25240
- array.push(effectSubscriptions);
25241
- };
25242
- var ensureEffectContainsSubscriber = (effect, subscriber, container) => {
25243
- if (isSubscriber(effect)) {
25244
- effect.$effectDependencies$ ||= [];
25245
- if (subscriberExistInSubscribers(effect.$effectDependencies$, subscriber)) {
25246
- return;
25247
- }
25248
- effect.$effectDependencies$.push(subscriber);
25249
- } else if (vnode_isVNode(effect) && !vnode_isTextVNode(effect)) {
25250
- let subscribers = vnode_getProp(
25251
- effect,
25252
- QSubscribers,
25253
- container ? container.$getObjectById$ : null
25254
- );
25255
- subscribers ||= [];
25256
- if (subscriberExistInSubscribers(subscribers, subscriber)) {
25257
- return;
25258
- }
25259
- subscribers.push(subscriber);
25260
- vnode_setProp(effect, QSubscribers, subscribers);
25261
- } else if (isSSRNode(effect)) {
25262
- let subscribers = effect.getProp(QSubscribers);
25263
- subscribers ||= [];
25264
- if (subscriberExistInSubscribers(subscribers, subscriber)) {
25265
- return;
25266
- }
25267
- subscribers.push(subscriber);
25268
- effect.setProp(QSubscribers, subscribers);
25269
- }
25456
+ var ensureContainsSubscription = (array, effectSubscription) => {
25457
+ array.add(effectSubscription);
25270
25458
  };
25271
- var isSSRNode = (effect) => {
25272
- return "setProp" in effect && "getProp" in effect && "removeProp" in effect && "id" in effect;
25459
+ var ensureContainsBackRef = (array, value) => {
25460
+ array[2 /* BACK_REF */] ||= /* @__PURE__ */ new Set();
25461
+ array[2 /* BACK_REF */].add(value);
25273
25462
  };
25274
- var subscriberExistInSubscribers = (subscribers, subscriber) => {
25275
- for (let i = 0; i < subscribers.length; i++) {
25276
- if (subscribers[i] === subscriber) {
25277
- return true;
25463
+ var addQrlToSerializationCtx = (effectSubscriber, container) => {
25464
+ if (!!container && !isDomContainer(container)) {
25465
+ const effect = effectSubscriber[0 /* CONSUMER */];
25466
+ const property = effectSubscriber[1 /* PROPERTY */];
25467
+ let qrl2 = null;
25468
+ if (isTask(effect)) {
25469
+ qrl2 = effect.$qrl$;
25470
+ } else if (effect instanceof ComputedSignal) {
25471
+ qrl2 = effect.$computeQrl$;
25472
+ } else if (property === ":" /* COMPONENT */) {
25473
+ qrl2 = container.getHostProp(effect, OnRenderProp);
25474
+ }
25475
+ if (qrl2) {
25476
+ container.serializationCtx.$eventQrls$.add(qrl2);
25278
25477
  }
25279
25478
  }
25280
- return false;
25281
25479
  };
25282
25480
  var triggerEffects = (container, signal, effects) => {
25481
+ const isBrowser2 = isDomContainer(container);
25283
25482
  if (effects) {
25284
- const scheduleEffect = (effectSubscriptions) => {
25285
- const effect = effectSubscriptions[0 /* EFFECT */];
25286
- const property = effectSubscriptions[1 /* PROPERTY */];
25483
+ const scheduleEffect = (effectSubscription) => {
25484
+ const consumer = effectSubscription[0 /* CONSUMER */];
25485
+ const property = effectSubscription[1 /* PROPERTY */];
25287
25486
  assertDefined(container, "Container must be defined.");
25288
- if (isTask(effect)) {
25289
- effect.$flags$ |= 8 /* DIRTY */;
25290
- DEBUG3 && log2("schedule.effect.task", pad("\n" + String(effect), " "));
25487
+ if (isTask(consumer)) {
25488
+ consumer.$flags$ |= 8 /* DIRTY */;
25489
+ DEBUG3 && log2("schedule.consumer.task", pad("\n" + String(consumer), " "));
25291
25490
  let choreType = 3 /* TASK */;
25292
- if (effect.$flags$ & 1 /* VISIBLE_TASK */) {
25491
+ if (consumer.$flags$ & 1 /* VISIBLE_TASK */) {
25293
25492
  choreType = 32 /* VISIBLE */;
25294
- } else if (effect.$flags$ & 4 /* RESOURCE */) {
25295
- choreType = 2 /* RESOURCE */;
25296
25493
  }
25297
- container.$scheduler$(choreType, effect);
25298
- } else if (effect instanceof Signal) {
25299
- if (effect instanceof ComputedSignal) {
25300
- if (!effect.$computeQrl$.resolved) {
25301
- container.$scheduler$(1 /* QRL_RESOLVE */, null, effect.$computeQrl$);
25494
+ container.$scheduler$(choreType, consumer);
25495
+ } else if (consumer instanceof Signal) {
25496
+ if (consumer instanceof ComputedSignal) {
25497
+ if (!consumer.$computeQrl$.resolved) {
25498
+ container.$scheduler$(1 /* QRL_RESOLVE */, null, consumer.$computeQrl$);
25302
25499
  }
25303
25500
  }
25304
- effect.$invalidate$();
25501
+ consumer.$invalidate$();
25305
25502
  } else if (property === ":" /* COMPONENT */) {
25306
- const host = effect;
25503
+ const host = consumer;
25307
25504
  const qrl2 = container.getHostProp(host, OnRenderProp);
25308
25505
  assertDefined(qrl2, "Component must have QRL");
25309
25506
  const props = container.getHostProp(host, ELEMENT_PROPS);
25310
- container.$scheduler$(7 /* COMPONENT */, host, qrl2, props);
25311
- } else if (property === "." /* VNODE */) {
25312
- const host = effect;
25313
- const target = host;
25314
- container.$scheduler$(4 /* NODE_DIFF */, host, target, signal);
25315
- } else {
25316
- const host = effect;
25317
- const effectData = effectSubscriptions[2 /* FIRST_BACK_REF_OR_DATA */];
25318
- if (effectData instanceof EffectPropData) {
25319
- const data = effectData.data;
25320
- const payload = {
25321
- ...data,
25322
- $value$: signal
25323
- };
25324
- container.$scheduler$(5 /* NODE_PROP */, host, property, payload);
25507
+ container.$scheduler$(6 /* COMPONENT */, host, qrl2, props);
25508
+ } else if (isBrowser2) {
25509
+ if (property === "." /* VNODE */) {
25510
+ const host = consumer;
25511
+ container.$scheduler$(4 /* NODE_DIFF */, host, host, signal);
25512
+ } else {
25513
+ const host = consumer;
25514
+ const effectData = effectSubscription[3 /* DATA */];
25515
+ if (effectData instanceof SubscriptionData) {
25516
+ const data = effectData.data;
25517
+ const payload = {
25518
+ ...data,
25519
+ $value$: signal
25520
+ };
25521
+ container.$scheduler$(5 /* NODE_PROP */, host, property, payload);
25522
+ }
25325
25523
  }
25326
25524
  }
25327
25525
  };
25328
- effects.forEach(scheduleEffect);
25526
+ for (const effect of effects) {
25527
+ scheduleEffect(effect);
25528
+ }
25329
25529
  }
25330
25530
  DEBUG3 && log2("done scheduling");
25331
25531
  };
@@ -25349,7 +25549,7 @@ var ComputedSignal = class extends Signal {
25349
25549
  var _a;
25350
25550
  this.$invalid$ = true;
25351
25551
  this.$forceRunEffects$ = false;
25352
- (_a = this.$container$) == null ? void 0 : _a.$scheduler$(8 /* RECOMPUTE_AND_SCHEDULE_EFFECTS */, null, this);
25552
+ (_a = this.$container$) == null ? void 0 : _a.$scheduler$(7 /* RECOMPUTE_AND_SCHEDULE_EFFECTS */, null, this);
25353
25553
  }
25354
25554
  /**
25355
25555
  * Use this to force running subscribers, for example when the calculated value has mutated but
@@ -25376,11 +25576,11 @@ var ComputedSignal = class extends Signal {
25376
25576
  throwIfQRLNotResolved(computeQrl);
25377
25577
  const ctx = tryGetInvokeContext();
25378
25578
  const previousEffectSubscription = ctx == null ? void 0 : ctx.$effectSubscriber$;
25379
- ctx && (ctx.$effectSubscriber$ = [this, "." /* VNODE */]);
25579
+ ctx && (ctx.$effectSubscriber$ = getSubscriber(this, "." /* VNODE */));
25380
25580
  try {
25381
25581
  const untrackedValue = computeQrl.getFn(ctx)();
25382
25582
  if (isPromise(untrackedValue)) {
25383
- throw qError(47 /* computedNotSync */, [
25583
+ throw qError(46 /* computedNotSync */, [
25384
25584
  computeQrl.dev ? computeQrl.dev.file : "",
25385
25585
  computeQrl.$hash$
25386
25586
  ]);
@@ -25403,7 +25603,7 @@ var ComputedSignal = class extends Signal {
25403
25603
  return super.value;
25404
25604
  }
25405
25605
  set value(_) {
25406
- throw qError(48 /* computedReadOnly */);
25606
+ throw qError(47 /* computedReadOnly */);
25407
25607
  }
25408
25608
  };
25409
25609
  var WrappedSignal = class extends Signal {
@@ -25413,9 +25613,9 @@ var WrappedSignal = class extends Signal {
25413
25613
  // We need a separate flag to know when the computation needs running because
25414
25614
  // we need the old value to know if effects need running after computation
25415
25615
  $invalid$ = true;
25416
- $effectDependencies$ = null;
25417
25616
  $hostElement$ = null;
25418
25617
  $forceRunEffects$ = false;
25618
+ [_EFFECT_BACK_REF] = null;
25419
25619
  constructor(container, fn, args, fnStr) {
25420
25620
  super(container, NEEDS_COMPUTATION);
25421
25621
  this.$args$ = args;
@@ -25427,7 +25627,7 @@ var WrappedSignal = class extends Signal {
25427
25627
  this.$invalid$ = true;
25428
25628
  this.$forceRunEffects$ = false;
25429
25629
  (_a = this.$container$) == null ? void 0 : _a.$scheduler$(
25430
- 8 /* RECOMPUTE_AND_SCHEDULE_EFFECTS */,
25630
+ 7 /* RECOMPUTE_AND_SCHEDULE_EFFECTS */,
25431
25631
  this.$hostElement$,
25432
25632
  this
25433
25633
  );
@@ -25470,7 +25670,7 @@ var WrappedSignal = class extends Signal {
25470
25670
  return super.value;
25471
25671
  }
25472
25672
  set value(_) {
25473
- throw qError(49 /* wrappedReadOnly */);
25673
+ throw qError(48 /* wrappedReadOnly */);
25474
25674
  }
25475
25675
  };
25476
25676
 
@@ -25516,16 +25716,6 @@ var _SharedContainer = class {
25516
25716
  }
25517
25717
  };
25518
25718
 
25519
- // packages/qwik/src/core/shared/utils/constants.ts
25520
- var QObjectRecursive = 1 << 0;
25521
- var QObjectImmutable = 1 << 1;
25522
- var QObjectTargetSymbol = Symbol("proxy target");
25523
- var QObjectFlagsSymbol = Symbol("proxy flags");
25524
- var QObjectManagerSymbol = Symbol("proxy manager");
25525
- var _CONST_PROPS = Symbol("CONST");
25526
- var _VAR_PROPS = Symbol("VAR");
25527
- var _IMMUTABLE = Symbol("IMMUTABLE");
25528
-
25529
25719
  // packages/qwik/src/core/shared-types.ts
25530
25720
  function isStringifiable(value) {
25531
25721
  return value === null || typeof value === "string" || typeof value === "number" || typeof value === "boolean";
@@ -25717,7 +25907,7 @@ function qwikDebugToString(value) {
25717
25907
  return String(value);
25718
25908
  } else if (isTask(value)) {
25719
25909
  return `Task(${qwikDebugToString(value.$qrl$)})`;
25720
- } else if (isQrl(value)) {
25910
+ } else if (isQrl2(value)) {
25721
25911
  return `Qrl(${value.$symbol$})`;
25722
25912
  } else if (typeof value === "object" || typeof value === "function") {
25723
25913
  if (stringifyPath.includes(value)) {
@@ -26046,13 +26236,13 @@ var VNodeDataChar = {
26046
26236
  /* **** */
26047
26237
  "^"
26048
26238
  ),
26049
- SUBS: (
26050
- /* *************** */
26239
+ BACK_REFS: (
26240
+ /* ********** */
26051
26241
  96
26052
26242
  ),
26053
- // '`' - `q:subs' - Effect dependencies/subscriptions
26054
- SUBS_CHAR: (
26055
- /* ******* */
26243
+ // '`' - `q:brefs' - Effect dependencies/subscriptions
26244
+ BACK_REFS_CHAR: (
26245
+ /* ** */
26056
26246
  "`"
26057
26247
  ),
26058
26248
  SEPARATOR: (
@@ -26075,6 +26265,14 @@ var VNodeDataChar = {
26075
26265
  )
26076
26266
  };
26077
26267
 
26268
+ // packages/qwik/src/core/shared/utils/maps.ts
26269
+ var mergeMaps = (map1, map2) => {
26270
+ for (const [k, v] of map2) {
26271
+ map1.set(k, v);
26272
+ }
26273
+ return map1;
26274
+ };
26275
+
26078
26276
  // packages/qwik/src/core/client/vnode.ts
26079
26277
  var vnode_newElement = (element, elementName) => {
26080
26278
  assertEqual(fastNodeType(element), 1, "Expecting element node.");
@@ -26236,6 +26434,7 @@ var vnode_ensureElementInflated = (vnode) => {
26236
26434
  elementVNode[0 /* flags */] ^= 8 /* Inflated */;
26237
26435
  const element = elementVNode[6 /* element */];
26238
26436
  const attributes = element.attributes;
26437
+ const props = vnode_getProps(elementVNode);
26239
26438
  for (let idx = 0; idx < attributes.length; idx++) {
26240
26439
  const attr = attributes[idx];
26241
26440
  const key = attr.name;
@@ -26243,23 +26442,13 @@ var vnode_ensureElementInflated = (vnode) => {
26243
26442
  break;
26244
26443
  } else if (key.startsWith(QContainerAttr)) {
26245
26444
  if (attr.value === "html" /* HTML */) {
26246
- mapArray_set(
26247
- elementVNode,
26248
- dangerouslySetInnerHTML,
26249
- element.innerHTML,
26250
- 8 /* PROPS_OFFSET */
26251
- );
26445
+ mapArray_set(props, dangerouslySetInnerHTML, element.innerHTML, 0);
26252
26446
  } else if (attr.value === "text" /* TEXT */ && "value" in element) {
26253
- mapArray_set(
26254
- elementVNode,
26255
- "value",
26256
- element.value,
26257
- 8 /* PROPS_OFFSET */
26258
- );
26447
+ mapArray_set(props, "value", element.value, 0);
26259
26448
  }
26260
26449
  } else if (!key.startsWith("on:")) {
26261
26450
  const value = attr.value;
26262
- mapArray_set(elementVNode, key, value, 8 /* PROPS_OFFSET */);
26451
+ mapArray_set(props, key, value, 0);
26263
26452
  }
26264
26453
  }
26265
26454
  }
@@ -26588,59 +26777,14 @@ var vnode_applyJournal = (journal) => {
26588
26777
  }
26589
26778
  journal.length = 0;
26590
26779
  };
26591
- var mapApp_findIndx = (elementVNode, key, start) => {
26592
- assertTrue(start % 2 === 0, "Expecting even number.");
26593
- let bottom = start >> 1;
26594
- let top = elementVNode.length - 2 >> 1;
26595
- while (bottom <= top) {
26596
- const mid = bottom + (top - bottom >> 1);
26597
- const midKey = elementVNode[mid << 1];
26598
- if (midKey === key) {
26599
- return mid << 1;
26600
- }
26601
- if (midKey < key) {
26602
- bottom = mid + 1;
26603
- } else {
26604
- top = mid - 1;
26605
- }
26606
- }
26607
- return bottom << 1 ^ -1;
26608
- };
26609
- var mapArray_set = (elementVNode, key, value, start) => {
26610
- const indx = mapApp_findIndx(elementVNode, key, start);
26611
- if (indx >= 0) {
26612
- if (value == null) {
26613
- elementVNode.splice(indx, 2);
26614
- } else {
26615
- elementVNode[indx + 1] = value;
26616
- }
26617
- } else if (value != null) {
26618
- elementVNode.splice(indx ^ -1, 0, key, value);
26619
- }
26620
- };
26621
- var mapApp_remove = (elementVNode, key, start) => {
26622
- const indx = mapApp_findIndx(elementVNode, key, start);
26623
- let value = null;
26624
- if (indx >= 0) {
26625
- value = elementVNode[indx + 1];
26626
- elementVNode.splice(indx, 2);
26627
- return value;
26628
- }
26629
- return value;
26630
- };
26631
- var mapArray_get = (elementVNode, key, start) => {
26632
- const indx = mapApp_findIndx(elementVNode, key, start);
26633
- if (indx >= 0) {
26634
- return elementVNode[indx + 1];
26635
- } else {
26636
- return null;
26637
- }
26638
- };
26639
26780
  var vnode_insertBefore = (journal, parent, newChild, insertBefore) => {
26640
26781
  ensureElementOrVirtualVNode(parent);
26641
26782
  if (vnode_isElementVNode(parent)) {
26642
26783
  ensureMaterialized(parent);
26643
26784
  }
26785
+ if (newChild === insertBefore) {
26786
+ insertBefore = null;
26787
+ }
26644
26788
  let adjustedInsertBefore = null;
26645
26789
  if (insertBefore == null) {
26646
26790
  if (vnode_isVirtualVNode(parent)) {
@@ -26743,8 +26887,10 @@ var vnode_getElementName = (vnode) => {
26743
26887
  const elementVNode = ensureElementVNode(vnode);
26744
26888
  let elementName = elementVNode[7 /* elementName */];
26745
26889
  if (elementName === void 0) {
26746
- elementName = elementVNode[7 /* elementName */] = elementVNode[6 /* element */].nodeName.toLowerCase();
26747
- elementVNode[0 /* flags */] |= vnode_getElementNamespaceFlags(elementName);
26890
+ const element = elementVNode[6 /* element */];
26891
+ const nodeName = import_build8.isDev ? fastNodeName(element).toLowerCase() : fastNodeName(element);
26892
+ elementName = elementVNode[7 /* elementName */] = nodeName;
26893
+ elementVNode[0 /* flags */] |= vnode_getElementNamespaceFlags(element);
26748
26894
  }
26749
26895
  return elementName;
26750
26896
  };
@@ -26913,6 +27059,20 @@ var fastFirstChild = (node) => {
26913
27059
  }
26914
27060
  return node;
26915
27061
  };
27062
+ var _fastNamespaceURI = null;
27063
+ var fastNamespaceURI = (element) => {
27064
+ if (!_fastNamespaceURI) {
27065
+ _fastNamespaceURI = fastGetter(element, "namespaceURI");
27066
+ }
27067
+ return _fastNamespaceURI.call(element);
27068
+ };
27069
+ var _fastNodeName = null;
27070
+ var fastNodeName = (element) => {
27071
+ if (!_fastNodeName) {
27072
+ _fastNodeName = fastGetter(element, "nodeName");
27073
+ }
27074
+ return _fastNodeName.call(element);
27075
+ };
26916
27076
  var fastGetter = (prototype, name) => {
26917
27077
  var _a;
26918
27078
  let getter;
@@ -26969,9 +27129,12 @@ var materializeFromDOM = (vParent, firstChild, vData) => {
26969
27129
  }
26970
27130
  const id = consumeValue();
26971
27131
  container.$setRawState$(parseInt(id), vParent);
26972
- import_build6.isDev && vnode_setAttr(null, vParent, ELEMENT_ID, id);
26973
- } else if (peek() === VNodeDataChar.SUBS) {
26974
- vnode_setProp(vParent, QSubscribers, consumeValue());
27132
+ import_build8.isDev && vnode_setAttr(null, vParent, ELEMENT_ID, id);
27133
+ } else if (peek() === VNodeDataChar.BACK_REFS) {
27134
+ if (!container) {
27135
+ container = getDomContainer(vParent[6 /* element */]);
27136
+ }
27137
+ setEffectBackRefFromVNodeData(vParent, consumeValue(), container);
26975
27138
  } else {
26976
27139
  consumeValue();
26977
27140
  }
@@ -26979,6 +27142,17 @@ var materializeFromDOM = (vParent, firstChild, vData) => {
26979
27142
  }
26980
27143
  return vFirstChild;
26981
27144
  };
27145
+ function setEffectBackRefFromVNodeData(vParent, value, container) {
27146
+ const deserializedSubMap = container.$getObjectById$(value);
27147
+ if (!vParent[_EFFECT_BACK_REF]) {
27148
+ Object.defineProperty(vParent, _EFFECT_BACK_REF, {
27149
+ value: deserializedSubMap
27150
+ });
27151
+ } else {
27152
+ const subMap = vParent[_EFFECT_BACK_REF];
27153
+ mergeMaps(subMap, deserializedSubMap);
27154
+ }
27155
+ }
26982
27156
  var processVNodeData = (vData, callback) => {
26983
27157
  let nextToConsumeIdx = 0;
26984
27158
  let ch = 0;
@@ -27019,8 +27193,9 @@ var vnode_getAttrKeys = (vnode) => {
27019
27193
  if ((type & 3 /* ELEMENT_OR_VIRTUAL_MASK */) !== 0) {
27020
27194
  vnode_ensureElementInflated(vnode);
27021
27195
  const keys = [];
27022
- for (let i = vnode_getPropStartIndex(vnode); i < vnode.length; i = i + 2) {
27023
- const key = vnode[i];
27196
+ const props = vnode_getProps(vnode);
27197
+ for (let i = 0; i < props.length; i = i + 2) {
27198
+ const key = props[i];
27024
27199
  if (!key.startsWith(Q_PROPS_SEPARATOR)) {
27025
27200
  keys.push(key);
27026
27201
  }
@@ -27033,19 +27208,20 @@ var vnode_setAttr = (journal, vnode, key, value) => {
27033
27208
  const type = vnode[0 /* flags */];
27034
27209
  if ((type & 3 /* ELEMENT_OR_VIRTUAL_MASK */) !== 0) {
27035
27210
  vnode_ensureElementInflated(vnode);
27036
- const idx = mapApp_findIndx(vnode, key, vnode_getPropStartIndex(vnode));
27211
+ const props = vnode_getProps(vnode);
27212
+ const idx = mapApp_findIndx(props, key, 0);
27037
27213
  if (idx >= 0) {
27038
- if (vnode[idx + 1] != value && (type & 1 /* Element */) !== 0) {
27214
+ if (props[idx + 1] != value && (type & 1 /* Element */) !== 0) {
27039
27215
  const element = vnode[6 /* element */];
27040
27216
  journal && journal.push(2 /* SetAttribute */, element, key, value);
27041
27217
  }
27042
27218
  if (value == null) {
27043
- vnode.splice(idx, 2);
27219
+ props.splice(idx, 2);
27044
27220
  } else {
27045
- vnode[idx + 1] = value;
27221
+ props[idx + 1] = value;
27046
27222
  }
27047
27223
  } else if (value != null) {
27048
- vnode.splice(idx ^ -1, 0, key, value);
27224
+ props.splice(idx ^ -1, 0, key, value);
27049
27225
  if ((type & 1 /* Element */) !== 0) {
27050
27226
  const element = vnode[6 /* element */];
27051
27227
  journal && journal.push(2 /* SetAttribute */, element, key, value);
@@ -27057,7 +27233,8 @@ var vnode_getAttr = (vnode, key) => {
27057
27233
  const type = vnode[0 /* flags */];
27058
27234
  if ((type & 3 /* ELEMENT_OR_VIRTUAL_MASK */) !== 0) {
27059
27235
  vnode_ensureElementInflated(vnode);
27060
- return mapArray_get(vnode, key, vnode_getPropStartIndex(vnode));
27236
+ const props = vnode_getProps(vnode);
27237
+ return mapArray_get(props, key, 0);
27061
27238
  }
27062
27239
  return null;
27063
27240
  };
@@ -27065,11 +27242,12 @@ var vnode_getProp = (vnode, key, getObject) => {
27065
27242
  const type = vnode[0 /* flags */];
27066
27243
  if ((type & 3 /* ELEMENT_OR_VIRTUAL_MASK */) !== 0) {
27067
27244
  type & 1 /* Element */ && vnode_ensureElementInflated(vnode);
27068
- const idx = mapApp_findIndx(vnode, key, vnode_getPropStartIndex(vnode));
27245
+ const props = vnode_getProps(vnode);
27246
+ const idx = mapApp_findIndx(props, key, 0);
27069
27247
  if (idx >= 0) {
27070
- let value = vnode[idx + 1];
27248
+ let value = props[idx + 1];
27071
27249
  if (typeof value === "string" && getObject) {
27072
- vnode[idx + 1] = value = getObject(value);
27250
+ props[idx + 1] = value = getObject(value);
27073
27251
  }
27074
27252
  return value;
27075
27253
  }
@@ -27078,11 +27256,12 @@ var vnode_getProp = (vnode, key, getObject) => {
27078
27256
  };
27079
27257
  var vnode_setProp = (vnode, key, value) => {
27080
27258
  ensureElementOrVirtualVNode(vnode);
27081
- const idx = mapApp_findIndx(vnode, key, vnode_getPropStartIndex(vnode));
27259
+ const props = vnode_getProps(vnode);
27260
+ const idx = mapApp_findIndx(props, key, 0);
27082
27261
  if (idx >= 0) {
27083
- vnode[idx + 1] = value;
27262
+ props[idx + 1] = value;
27084
27263
  } else if (value != null) {
27085
- vnode.splice(idx ^ -1, 0, key, value);
27264
+ props.splice(idx ^ -1, 0, key, value);
27086
27265
  }
27087
27266
  };
27088
27267
  var vnode_getPropStartIndex = (vnode) => {
@@ -27094,6 +27273,9 @@ var vnode_getPropStartIndex = (vnode) => {
27094
27273
  }
27095
27274
  throw qError(43 /* invalidVNodeType */, [type]);
27096
27275
  };
27276
+ var vnode_getProps = (vnode) => {
27277
+ return vnode[vnode_getPropStartIndex(vnode)];
27278
+ };
27097
27279
  var vnode_getParent = (vnode) => {
27098
27280
  return vnode[1 /* parent */] || null;
27099
27281
  };
@@ -27232,7 +27414,7 @@ function materializeFromVNodeData(vParent, vData, element, child) {
27232
27414
  }
27233
27415
  const id = consumeValue();
27234
27416
  container.$setRawState$(parseInt(id), vParent);
27235
- import_build6.isDev && vnode_setAttr(null, vParent, ELEMENT_ID, id);
27417
+ import_build8.isDev && vnode_setAttr(null, vParent, ELEMENT_ID, id);
27236
27418
  } else if (peek() === VNodeDataChar.PROPS) {
27237
27419
  vnode_setAttr(null, vParent, ELEMENT_PROPS, consumeValue());
27238
27420
  } else if (peek() === VNodeDataChar.SLOT_REF) {
@@ -27243,8 +27425,11 @@ function materializeFromVNodeData(vParent, vData, element, child) {
27243
27425
  vnode_setAttr(null, vParent, ELEMENT_SEQ, consumeValue());
27244
27426
  } else if (peek() === VNodeDataChar.SEQ_IDX) {
27245
27427
  vnode_setAttr(null, vParent, ELEMENT_SEQ_IDX, consumeValue());
27246
- } else if (peek() === VNodeDataChar.SUBS) {
27247
- vnode_setProp(vParent, QSubscribers, consumeValue());
27428
+ } else if (peek() === VNodeDataChar.BACK_REFS) {
27429
+ if (!container) {
27430
+ container = getDomContainer(element);
27431
+ }
27432
+ setEffectBackRefFromVNodeData(vParent, consumeValue(), container);
27248
27433
  } else if (peek() === VNodeDataChar.CONTEXT) {
27249
27434
  vnode_setAttr(null, vParent, QCtxAttr, consumeValue());
27250
27435
  } else if (peek() === VNodeDataChar.OPEN) {
@@ -27304,51 +27489,6 @@ var vnode_getType = (vnode) => {
27304
27489
  };
27305
27490
  var isElement = (node) => node && typeof node == "object" && fastNodeType(node) === /** Node.ELEMENT_NODE* */
27306
27491
  1;
27307
- var aPath = [];
27308
- var bPath = [];
27309
- var vnode_documentPosition = (a, b, rootVNode) => {
27310
- if (a === b) {
27311
- return 0;
27312
- }
27313
- let aDepth = -1;
27314
- let bDepth = -1;
27315
- while (a) {
27316
- const vNode = aPath[++aDepth] = a;
27317
- a = vNode[1 /* parent */] || rootVNode && vnode_getProp(a, QSlotParent, (id) => vnode_locate(rootVNode, id));
27318
- }
27319
- while (b) {
27320
- const vNode = bPath[++bDepth] = b;
27321
- b = vNode[1 /* parent */] || rootVNode && vnode_getProp(b, QSlotParent, (id) => vnode_locate(rootVNode, id));
27322
- }
27323
- while (aDepth >= 0 && bDepth >= 0) {
27324
- a = aPath[aDepth];
27325
- b = bPath[bDepth];
27326
- if (a === b) {
27327
- aDepth--;
27328
- bDepth--;
27329
- } else {
27330
- let cursor = b;
27331
- do {
27332
- cursor = vnode_getNextSibling(cursor);
27333
- if (cursor === a) {
27334
- return 1;
27335
- }
27336
- } while (cursor);
27337
- cursor = b;
27338
- do {
27339
- cursor = vnode_getPreviousSibling(cursor);
27340
- if (cursor === a) {
27341
- return -1;
27342
- }
27343
- } while (cursor);
27344
- if (rootVNode && vnode_getProp(b, QSlotParent, (id) => vnode_locate(rootVNode, id))) {
27345
- return -1;
27346
- }
27347
- return 1;
27348
- }
27349
- }
27350
- return aDepth < bDepth ? -1 : 1;
27351
- };
27352
27492
  var vnode_getProjectionParentComponent = (vHost, rootVNode) => {
27353
27493
  let projectionDepth = 1;
27354
27494
  while (projectionDepth--) {
@@ -27372,24 +27512,38 @@ var vnode_getProjectionParentComponent = (vHost, rootVNode) => {
27372
27512
  };
27373
27513
  var VNodeArray = class VNode extends Array {
27374
27514
  static createElement(flags, parent, previousSibling, nextSibling, firstChild, lastChild, element, elementName) {
27375
- const vnode = new VNode(flags, parent, previousSibling, nextSibling);
27376
- vnode.push(firstChild, lastChild, element, elementName);
27515
+ const vnode = new VNode(
27516
+ flags,
27517
+ parent,
27518
+ previousSibling,
27519
+ nextSibling,
27520
+ firstChild,
27521
+ lastChild,
27522
+ element,
27523
+ elementName,
27524
+ []
27525
+ );
27377
27526
  return vnode;
27378
27527
  }
27379
27528
  static createText(flags, parent, previousSibling, nextSibling, textNode, text) {
27380
- const vnode = new VNode(flags, parent, previousSibling, nextSibling);
27381
- vnode.push(textNode, text);
27529
+ const vnode = new VNode(flags, parent, previousSibling, nextSibling, textNode, text);
27382
27530
  return vnode;
27383
27531
  }
27384
27532
  static createVirtual(flags, parent, previousSibling, nextSibling, firstChild, lastChild) {
27385
- const vnode = new VNode(flags, parent, previousSibling, nextSibling);
27386
- vnode.push(firstChild, lastChild);
27533
+ const vnode = new VNode(
27534
+ flags,
27535
+ parent,
27536
+ previousSibling,
27537
+ nextSibling,
27538
+ firstChild,
27539
+ lastChild,
27540
+ []
27541
+ );
27387
27542
  return vnode;
27388
27543
  }
27389
- constructor(flags, parent, previousSibling, nextSibling) {
27390
- super();
27391
- this.push(flags, parent, previousSibling, nextSibling);
27392
- if (import_build6.isDev) {
27544
+ constructor(flags, parent, previousSibling, nextSibling, ...rest) {
27545
+ super(flags, parent, previousSibling, nextSibling, ...rest);
27546
+ if (import_build8.isDev) {
27393
27547
  this.toString = vnode_toString;
27394
27548
  }
27395
27549
  }
@@ -27434,10 +27588,12 @@ function invokeApply(context, fn, args) {
27434
27588
  return returnValue;
27435
27589
  }
27436
27590
  var newInvokeContextFromTuple = ([element, event, url]) => {
27437
- const container = element.closest(QContainerSelector);
27591
+ const domContainer = getDomContainer(element);
27592
+ const container = domContainer.element;
27593
+ const vNode = container ? vnode_locate(domContainer.rootVNode, element) : void 0;
27438
27594
  const locale = (container == null ? void 0 : container.getAttribute(QLocaleAttr)) || void 0;
27439
27595
  locale && setLocale(locale);
27440
- return newInvokeContext(locale, void 0, element, event, url);
27596
+ return newInvokeContext(locale, vNode, element, event, url);
27441
27597
  };
27442
27598
  var newInvokeContext = (locale, hostElement, element, event, url) => {
27443
27599
  const $locale$ = locale || (typeof event === "object" && event && "locale" in event ? event.locale : void 0);
@@ -27468,10 +27624,7 @@ var trackSignal = (fn, subscriber, property, container, data) => {
27468
27624
  const previousSubscriber = trackInvocation.$effectSubscriber$;
27469
27625
  const previousContainer = trackInvocation.$container$;
27470
27626
  try {
27471
- trackInvocation.$effectSubscriber$ = [subscriber, property];
27472
- if (data) {
27473
- trackInvocation.$effectSubscriber$.push(data);
27474
- }
27627
+ trackInvocation.$effectSubscriber$ = getSubscriber(subscriber, property, data);
27475
27628
  trackInvocation.$container$ = container;
27476
27629
  return invoke(trackInvocation, fn);
27477
27630
  } finally {
@@ -27826,9 +27979,9 @@ var DomContainer = class extends _SharedContainer {
27826
27979
  $storeProxyMap$ = /* @__PURE__ */ new WeakMap();
27827
27980
  $qFuncs$;
27828
27981
  $instanceHash$;
27829
- stateData;
27982
+ vNodeLocate = (id) => vnode_locate(this.rootVNode, id);
27983
+ $stateData$;
27830
27984
  $styleIds$ = null;
27831
- $vnodeLocate$ = (id) => vnode_locate(this.rootVNode, id);
27832
27985
  $renderCount$ = 0;
27833
27986
  constructor(element) {
27834
27987
  super(
@@ -27857,29 +28010,29 @@ var DomContainer = class extends _SharedContainer {
27857
28010
  this.qManifestHash = element.getAttribute("q:manifest-hash");
27858
28011
  this.rootVNode = vnode_newUnMaterializedElement(this.element);
27859
28012
  this.$rawStateData$ = null;
27860
- this.stateData = null;
28013
+ this.$stateData$ = null;
27861
28014
  const document2 = this.element.ownerDocument;
27862
28015
  if (!document2.qVNodeData) {
27863
28016
  processVNodeData2(document2);
27864
28017
  }
27865
28018
  this.$rawStateData$ = [];
27866
- this.stateData = [];
28019
+ this.$stateData$ = [];
27867
28020
  const qwikStates = element.querySelectorAll('script[type="qwik/state"]');
27868
28021
  if (qwikStates.length !== 0) {
27869
28022
  const lastState = qwikStates[qwikStates.length - 1];
27870
28023
  this.$rawStateData$ = JSON.parse(lastState.textContent);
27871
- this.stateData = wrapDeserializerProxy(this, this.$rawStateData$);
28024
+ this.$stateData$ = wrapDeserializerProxy(this, this.$rawStateData$);
27872
28025
  }
27873
28026
  this.$qFuncs$ = getQFuncs(document2, this.$instanceHash$) || EMPTY_ARRAY;
27874
28027
  }
27875
28028
  $setRawState$(id, vParent) {
27876
- this.stateData[id] = vParent;
28029
+ this.$stateData$[id] = vParent;
27877
28030
  }
27878
28031
  parseQRL(qrl2) {
27879
28032
  return inflateQRL(this, parseQRL(qrl2));
27880
28033
  }
27881
28034
  handleError(err, host) {
27882
- if (qDev) {
28035
+ if (qDev && host) {
27883
28036
  if (typeof document !== "undefined") {
27884
28037
  const vHost = host;
27885
28038
  const errorDiv = document.createElement("errored-host");
@@ -27902,7 +28055,7 @@ var DomContainer = class extends _SharedContainer {
27902
28055
  throw err;
27903
28056
  }
27904
28057
  }
27905
- const errorStore = this.resolveContext(host, ERROR_CONTEXT);
28058
+ const errorStore = host && this.resolveContext(host, ERROR_CONTEXT);
27906
28059
  if (!errorStore) {
27907
28060
  throw err;
27908
28061
  }
@@ -27936,7 +28089,7 @@ var DomContainer = class extends _SharedContainer {
27936
28089
  return vNode;
27937
28090
  }
27938
28091
  vNode = vnode_getParent(vNode) || // If virtual node, than it could be a slot so we need to read its parent.
27939
- vnode_getProp(vNode, QSlotParent, this.$vnodeLocate$);
28092
+ vnode_getProp(vNode, QSlotParent, this.vNodeLocate);
27940
28093
  } else {
27941
28094
  vNode = vnode_getParent(vNode);
27942
28095
  }
@@ -27955,7 +28108,7 @@ var DomContainer = class extends _SharedContainer {
27955
28108
  case ELEMENT_PROPS:
27956
28109
  case OnRenderProp:
27957
28110
  case QCtxAttr:
27958
- case QSubscribers:
28111
+ case QBackRefs:
27959
28112
  getObjectById = this.$getObjectById$;
27960
28113
  break;
27961
28114
  case ELEMENT_SEQ_IDX:
@@ -27968,7 +28121,9 @@ var DomContainer = class extends _SharedContainer {
27968
28121
  scheduleRender() {
27969
28122
  this.$renderCount$++;
27970
28123
  this.renderDone ||= getPlatform().nextTick(() => this.processChores());
27971
- return this.renderDone;
28124
+ return this.renderDone.finally(
28125
+ () => emitEvent("qrender", { instanceHash: this.$instanceHash$, renderCount: this.$renderCount$ })
28126
+ );
27972
28127
  }
27973
28128
  processChores() {
27974
28129
  let renderCount = this.$renderCount$;
@@ -27991,12 +28146,13 @@ var DomContainer = class extends _SharedContainer {
27991
28146
  ensureProjectionResolved(vNode) {
27992
28147
  if ((vNode[0 /* flags */] & 16 /* Resolved */) === 0) {
27993
28148
  vNode[0 /* flags */] |= 16 /* Resolved */;
27994
- for (let i = vnode_getPropStartIndex(vNode); i < vNode.length; i = i + 2) {
27995
- const prop = vNode[i];
28149
+ const props = vnode_getProps(vNode);
28150
+ for (let i = 0; i < props.length; i = i + 2) {
28151
+ const prop = props[i];
27996
28152
  if (isSlotProp(prop)) {
27997
- const value = vNode[i + 1];
28153
+ const value = props[i + 1];
27998
28154
  if (typeof value == "string") {
27999
- vNode[i + 1] = this.$vnodeLocate$(value);
28155
+ props[i + 1] = this.vNodeLocate(value);
28000
28156
  }
28001
28157
  }
28002
28158
  }
@@ -28010,7 +28166,7 @@ var DomContainer = class extends _SharedContainer {
28010
28166
  id < this.$rawStateData$.length / 2,
28011
28167
  `Invalid reference: ${id} >= ${this.$rawStateData$.length / 2}`
28012
28168
  );
28013
- return this.stateData[id];
28169
+ return this.$stateData$[id];
28014
28170
  };
28015
28171
  getSyncFn(id) {
28016
28172
  const fn = this.$qFuncs$[id];
@@ -28073,8 +28229,7 @@ var DeserializationHandler = class {
28073
28229
  }
28074
28230
  const i = typeof property === "number" ? property : typeof property === "string" ? parseInt(property, 10) : NaN;
28075
28231
  if (Number.isNaN(i) || i < 0 || i >= this.$length$) {
28076
- const out = Reflect.get(target, property, receiver);
28077
- return out;
28232
+ return Reflect.get(target, property, receiver);
28078
28233
  }
28079
28234
  const idx = i * 2;
28080
28235
  const typeId = this.$data$[idx];
@@ -28172,7 +28327,7 @@ var inflate = (container, target, typeId, data) => {
28172
28327
  task.$flags$ = v[1];
28173
28328
  task.$index$ = v[2];
28174
28329
  task.$el$ = v[3];
28175
- task.$effectDependencies$ = v[4];
28330
+ task[_EFFECT_BACK_REF] = v[4];
28176
28331
  task.$state$ = v[5];
28177
28332
  break;
28178
28333
  case 20 /* Resource */:
@@ -28194,12 +28349,9 @@ var inflate = (container, target, typeId, data) => {
28194
28349
  break;
28195
28350
  case 25 /* Store */:
28196
28351
  case 26 /* StoreArray */: {
28197
- const [value, flags, effects2, storeEffect] = data;
28352
+ const [value, flags, effects2] = data;
28198
28353
  const store = getOrCreateStore(value, flags, container);
28199
28354
  const storeHandler = getStoreHandler(store);
28200
- if (storeEffect) {
28201
- effects2[STORE_ARRAY_PROP] = storeEffect;
28202
- }
28203
28355
  storeHandler.$effects$ = effects2;
28204
28356
  target = store;
28205
28357
  break;
@@ -28208,7 +28360,7 @@ var inflate = (container, target, typeId, data) => {
28208
28360
  const signal = target;
28209
28361
  const d = data;
28210
28362
  signal.$untrackedValue$ = d[0];
28211
- signal.$effects$ = d.slice(1);
28363
+ signal.$effects$ = new Set(d.slice(1));
28212
28364
  break;
28213
28365
  }
28214
28366
  case 23 /* WrappedSignal */: {
@@ -28216,10 +28368,10 @@ var inflate = (container, target, typeId, data) => {
28216
28368
  const d = data;
28217
28369
  signal.$func$ = container.getSyncFn(d[0]);
28218
28370
  signal.$args$ = d[1];
28219
- signal.$effectDependencies$ = d[2];
28371
+ signal[_EFFECT_BACK_REF] = d[2];
28220
28372
  signal.$untrackedValue$ = d[3];
28221
28373
  signal.$hostElement$ = d[4];
28222
- signal.$effects$ = d.slice(5);
28374
+ signal.$effects$ = new Set(d.slice(5));
28223
28375
  break;
28224
28376
  }
28225
28377
  case 24 /* ComputedSignal */: {
@@ -28334,6 +28486,7 @@ var _constants = [
28334
28486
  EMPTY_ARRAY,
28335
28487
  EMPTY_OBJ,
28336
28488
  NEEDS_COMPUTATION,
28489
+ STORE_ARRAY_PROP,
28337
28490
  Slot,
28338
28491
  Fragment,
28339
28492
  NaN,
@@ -28352,6 +28505,7 @@ var _constantNames = [
28352
28505
  "EMPTY_ARRAY",
28353
28506
  "EMPTY_OBJ",
28354
28507
  "NEEDS_COMPUTATION",
28508
+ "STORE_ARRAY_PROP",
28355
28509
  "Slot",
28356
28510
  "Fragment",
28357
28511
  "NaN",
@@ -28433,6 +28587,8 @@ var allocate = (container, typeId, value) => {
28433
28587
  reject = rej;
28434
28588
  });
28435
28589
  resolvers.set(promise, [resolve, reject]);
28590
+ promise.catch(() => {
28591
+ });
28436
28592
  return promise;
28437
28593
  case 17 /* Uint8Array */:
28438
28594
  const encodedLength = value.length;
@@ -28442,12 +28598,9 @@ var allocate = (container, typeId, value) => {
28442
28598
  return new Uint8Array(decodedLength);
28443
28599
  case 29 /* PropsProxy */:
28444
28600
  return createPropsProxy(null, null);
28445
- case 9 /* RefVNode */:
28446
28601
  case 8 /* VNode */:
28447
- const vnodeOrDocument = retrieveVNodeOrDocument(container, value);
28448
- if (typeId === 8 /* VNode */) {
28449
- return vnodeOrDocument;
28450
- }
28602
+ return retrieveVNodeOrDocument(container, value);
28603
+ case 9 /* RefVNode */:
28451
28604
  const vNode = retrieveVNodeOrDocument(container, value);
28452
28605
  if (vnode_isVNode(vNode)) {
28453
28606
  return vnode_getNode(vNode);
@@ -28455,7 +28608,7 @@ var allocate = (container, typeId, value) => {
28455
28608
  throw qError(34 /* serializeErrorExpectedVNode */, [typeof vNode]);
28456
28609
  }
28457
28610
  case 30 /* EffectData */:
28458
- return new EffectPropData({});
28611
+ return new SubscriptionData({});
28459
28612
  default:
28460
28613
  throw qError(35 /* serializeErrorCannotAllocate */, [typeId]);
28461
28614
  }
@@ -28472,12 +28625,12 @@ function parseQRL(qrl2) {
28472
28625
  const symbol = captureStart > -1 ? qrl2.slice(hashIdx + 1, captureStart) : qrl2.slice(hashIdx + 1);
28473
28626
  const captureIds = captureStart > -1 && captureEnd > -1 ? qrl2.slice(captureStart + 1, captureEnd).split(" ").filter((v) => v.length).map((s) => parseInt(s, 10)) : null;
28474
28627
  let qrlRef = null;
28475
- if (isDev && chunk === QRL_RUNTIME_CHUNK) {
28628
+ if (isDev2 && chunk === QRL_RUNTIME_CHUNK) {
28476
28629
  const backChannel = globalThis[QRL_RUNTIME_CHUNK];
28477
28630
  assertDefined(backChannel, "Missing QRL_RUNTIME_CHUNK");
28478
28631
  qrlRef = backChannel.get(symbol);
28479
28632
  }
28480
- return createQRL(chunk, symbol, qrlRef, null, captureIds, null, null);
28633
+ return createQRL(chunk, symbol, qrlRef, null, captureIds, null);
28481
28634
  }
28482
28635
  function inflateQRL(container, qrl2) {
28483
28636
  const captureIds = qrl2.$capture$;
@@ -28511,13 +28664,13 @@ var createSerializationContext = (NodeConstructor, DomRefConstructor, symbolToCh
28511
28664
  }
28512
28665
  return id;
28513
28666
  };
28514
- const isSsrNode = NodeConstructor ? (obj) => obj instanceof NodeConstructor : () => false;
28667
+ const isSsrNode2 = NodeConstructor ? (obj) => obj instanceof NodeConstructor : () => false;
28515
28668
  isDomRef = DomRefConstructor ? (obj) => obj instanceof DomRefConstructor : () => false;
28516
28669
  return {
28517
28670
  $serialize$() {
28518
28671
  serialize(this);
28519
28672
  },
28520
- $isSsrNode$: isSsrNode,
28673
+ $isSsrNode$: isSsrNode2,
28521
28674
  $isDomRef$: isDomRef,
28522
28675
  $symbolToChunkResolver$: symbolToChunkResolver,
28523
28676
  $wasSeen$,
@@ -28573,7 +28726,7 @@ var createSerializationContext = (NodeConstructor, DomRefConstructor, symbolToCh
28573
28726
  const promises = [];
28574
28727
  const visit = (obj) => {
28575
28728
  if (typeof obj === "function") {
28576
- if (isQrl2(obj)) {
28729
+ if (isQrl(obj)) {
28577
28730
  if (obj.$captureRef$) {
28578
28731
  discoveredValues.push(...obj.$captureRef$);
28579
28732
  }
@@ -28583,7 +28736,7 @@ var createSerializationContext = (NodeConstructor, DomRefConstructor, symbolToCh
28583
28736
  }
28584
28737
  } else if (
28585
28738
  // skip as these are primitives
28586
- typeof obj !== "object" || obj === null || obj instanceof URL || obj instanceof Date || obj instanceof RegExp || obj instanceof Uint8Array || obj instanceof URLSearchParams || typeof FormData !== "undefined" && obj instanceof FormData || // Ignore the no serialize objects
28739
+ typeof obj !== "object" || obj === null || obj instanceof URL || obj instanceof Date || obj instanceof RegExp || obj instanceof Uint8Array || obj instanceof URLSearchParams || vnode_isVNode(obj) || typeof FormData !== "undefined" && obj instanceof FormData || // Ignore the no serialize objects
28587
28740
  fastSkipSerialize(obj)
28588
28741
  ) {
28589
28742
  } else if (obj instanceof Error) {
@@ -28591,8 +28744,7 @@ var createSerializationContext = (NodeConstructor, DomRefConstructor, symbolToCh
28591
28744
  } else if (isStore(obj)) {
28592
28745
  const target = getStoreTarget(obj);
28593
28746
  const effects = getStoreHandler(obj).$effects$;
28594
- const storeEffect = (effects == null ? void 0 : effects[STORE_ARRAY_PROP]) ?? null;
28595
- discoveredValues.push(target, effects, storeEffect);
28747
+ discoveredValues.push(target, effects);
28596
28748
  for (const prop in target) {
28597
28749
  const propValue = target[prop];
28598
28750
  if (storeProxyMap.has(propValue)) {
@@ -28614,9 +28766,7 @@ var createSerializationContext = (NodeConstructor, DomRefConstructor, symbolToCh
28614
28766
  discoveredValues.push(...obj.$effects$);
28615
28767
  }
28616
28768
  if (obj instanceof WrappedSignal) {
28617
- if (obj.$effectDependencies$) {
28618
- discoveredValues.push(...obj.$effectDependencies$);
28619
- }
28769
+ discoverEffectBackRefs(obj[_EFFECT_BACK_REF], discoveredValues);
28620
28770
  if (obj.$args$) {
28621
28771
  discoveredValues.push(...obj.$args$);
28622
28772
  }
@@ -28627,8 +28777,9 @@ var createSerializationContext = (NodeConstructor, DomRefConstructor, symbolToCh
28627
28777
  discoveredValues.push(obj.$computeQrl$);
28628
28778
  }
28629
28779
  } else if (obj instanceof Task) {
28630
- discoveredValues.push(obj.$el$, obj.$qrl$, obj.$state$, obj.$effectDependencies$);
28631
- } else if (isSsrNode(obj)) {
28780
+ discoveredValues.push(obj.$el$, obj.$qrl$, obj.$state$);
28781
+ discoverEffectBackRefs(obj[_EFFECT_BACK_REF], discoveredValues);
28782
+ } else if (isSsrNode2(obj)) {
28632
28783
  discoverValuesForVNodeData(obj.vnodeData, discoveredValues);
28633
28784
  if (obj.childrenVNodeData && obj.childrenVNodeData.length) {
28634
28785
  for (const data of obj.childrenVNodeData) {
@@ -28641,7 +28792,7 @@ var createSerializationContext = (NodeConstructor, DomRefConstructor, symbolToCh
28641
28792
  discoveredValues.push(obj.type, obj.props, obj.constProps, obj.children);
28642
28793
  } else if (Array.isArray(obj)) {
28643
28794
  discoveredValues.push(...obj);
28644
- } else if (isQrl2(obj)) {
28795
+ } else if (isQrl(obj)) {
28645
28796
  obj.$captureRef$ && obj.$captureRef$.length && discoveredValues.push(...obj.$captureRef$);
28646
28797
  } else if (isPropsProxy(obj)) {
28647
28798
  discoveredValues.push(obj[_VAR_PROPS], obj[_CONST_PROPS]);
@@ -28657,7 +28808,7 @@ var createSerializationContext = (NodeConstructor, DomRefConstructor, symbolToCh
28657
28808
  }
28658
28809
  );
28659
28810
  promises.push(obj);
28660
- } else if (obj instanceof EffectPropData) {
28811
+ } else if (obj instanceof SubscriptionData) {
28661
28812
  discoveredValues.push(obj.data);
28662
28813
  } else if (isObjectLiteral(obj)) {
28663
28814
  Object.entries(obj).forEach(([key, value]) => {
@@ -28694,15 +28845,30 @@ var discoverValuesForVNodeData = (vnodeData, discoveredValues) => {
28694
28845
  for (const value of vnodeData) {
28695
28846
  if (isSsrAttrs(value)) {
28696
28847
  for (let i = 1; i < value.length; i += 2) {
28697
- if (value[i - 1] === ELEMENT_KEY) {
28848
+ const attrValue = value[i];
28849
+ if (typeof attrValue === "string") {
28698
28850
  continue;
28699
28851
  }
28700
- const attrValue = value[i];
28701
28852
  discoveredValues.push(attrValue);
28702
28853
  }
28703
28854
  }
28704
28855
  }
28705
28856
  };
28857
+ var discoverEffectBackRefs = (effectsBackRefs, discoveredValues) => {
28858
+ if (effectsBackRefs) {
28859
+ let hasBackRefs = false;
28860
+ for (const [, effect] of effectsBackRefs) {
28861
+ const backRefs = effect[2 /* BACK_REF */];
28862
+ if (backRefs) {
28863
+ hasBackRefs = true;
28864
+ break;
28865
+ }
28866
+ }
28867
+ if (hasBackRefs) {
28868
+ discoveredValues.push(effectsBackRefs);
28869
+ }
28870
+ }
28871
+ };
28706
28872
  var promiseResults = /* @__PURE__ */ new WeakMap();
28707
28873
  function serialize(serializationContext) {
28708
28874
  const { $writer$, $isSsrNode$, $isDomRef$, $setProp$, $storeProxyMap$ } = serializationContext;
@@ -28751,10 +28917,10 @@ function serialize(serializationContext) {
28751
28917
  output(1 /* Constant */, value ? 2 /* True */ : 3 /* False */);
28752
28918
  } else if (typeof value === "function") {
28753
28919
  if (value === Slot) {
28754
- output(1 /* Constant */, 8 /* Slot */);
28920
+ output(1 /* Constant */, 9 /* Slot */);
28755
28921
  } else if (value === Fragment) {
28756
- output(1 /* Constant */, 9 /* Fragment */);
28757
- } else if (isQrl2(value)) {
28922
+ output(1 /* Constant */, 10 /* Fragment */);
28923
+ } else if (isQrl(value)) {
28758
28924
  const qrl2 = qrlToString(serializationContext, value);
28759
28925
  const id = serializationContext.$addRoot$(qrl2);
28760
28926
  output(18 /* QRL */, id);
@@ -28768,18 +28934,18 @@ function serialize(serializationContext) {
28768
28934
  }
28769
28935
  } else if (typeof value === "number") {
28770
28936
  if (Number.isNaN(value)) {
28771
- output(1 /* Constant */, 10 /* NaN */);
28937
+ output(1 /* Constant */, 11 /* NaN */);
28772
28938
  } else if (!Number.isFinite(value)) {
28773
28939
  output(
28774
28940
  1 /* Constant */,
28775
- value < 0 ? 12 /* NegativeInfinity */ : 11 /* PositiveInfinity */
28941
+ value < 0 ? 13 /* NegativeInfinity */ : 12 /* PositiveInfinity */
28776
28942
  );
28777
28943
  } else if (value === Number.MAX_SAFE_INTEGER) {
28778
- output(1 /* Constant */, 13 /* MaxSafeInt */);
28944
+ output(1 /* Constant */, 14 /* MaxSafeInt */);
28779
28945
  } else if (value === Number.MAX_SAFE_INTEGER - 1) {
28780
- output(1 /* Constant */, 14 /* AlmostMaxSafeInt */);
28946
+ output(1 /* Constant */, 15 /* AlmostMaxSafeInt */);
28781
28947
  } else if (value === Number.MIN_SAFE_INTEGER) {
28782
- output(1 /* Constant */, 15 /* MinSafeInt */);
28948
+ output(1 /* Constant */, 16 /* MinSafeInt */);
28783
28949
  } else {
28784
28950
  output(2 /* Number */, value);
28785
28951
  }
@@ -28812,6 +28978,8 @@ function serialize(serializationContext) {
28812
28978
  output(1 /* Constant */, 0 /* Undefined */);
28813
28979
  } else if (value === NEEDS_COMPUTATION) {
28814
28980
  output(1 /* Constant */, 7 /* NEEDS_COMPUTATION */);
28981
+ } else if (value === STORE_ARRAY_PROP) {
28982
+ output(1 /* Constant */, 8 /* STORE_ARRAY_PROP */);
28815
28983
  } else {
28816
28984
  throw qError(37 /* serializeErrorUnknownType */, [typeof value]);
28817
28985
  }
@@ -28831,7 +28999,7 @@ function serialize(serializationContext) {
28831
28999
  const constProps = value[_CONST_PROPS];
28832
29000
  const out = constProps ? [varProps, constProps] : Object.keys(varProps).length ? [varProps] : 0;
28833
29001
  output(29 /* PropsProxy */, out);
28834
- } else if (value instanceof EffectPropData) {
29002
+ } else if (value instanceof SubscriptionData) {
28835
29003
  output(30 /* EffectData */, [value.data.$scopedStyleIdPrefix$, value.data.$isConst$]);
28836
29004
  } else if (isStore(value)) {
28837
29005
  if (isResource(value)) {
@@ -28846,7 +29014,6 @@ function serialize(serializationContext) {
28846
29014
  const storeTarget = getStoreTarget(value);
28847
29015
  const flags = storeHandler.$flags$;
28848
29016
  const effects = storeHandler.$effects$;
28849
- const storeEffect = (effects == null ? void 0 : effects[STORE_ARRAY_PROP]) ?? null;
28850
29017
  const innerStores = [];
28851
29018
  for (const prop in storeTarget) {
28852
29019
  const propValue = storeTarget[prop];
@@ -28856,7 +29023,7 @@ function serialize(serializationContext) {
28856
29023
  serializationContext.$addRoot$(innerStore);
28857
29024
  }
28858
29025
  }
28859
- const out = [storeTarget, flags, effects, storeEffect, ...innerStores];
29026
+ const out = [storeTarget, flags, effects, ...innerStores];
28860
29027
  while (out[out.length - 1] == null) {
28861
29028
  out.pop();
28862
29029
  }
@@ -28882,7 +29049,7 @@ function serialize(serializationContext) {
28882
29049
  if (value instanceof WrappedSignal) {
28883
29050
  output(23 /* WrappedSignal */, [
28884
29051
  ...serializeWrappingFn(serializationContext, value),
28885
- value.$effectDependencies$,
29052
+ filterEffectBackRefs(value[_EFFECT_BACK_REF]),
28886
29053
  v,
28887
29054
  value.$hostElement$,
28888
29055
  ...value.$effects$ || []
@@ -28912,7 +29079,7 @@ function serialize(serializationContext) {
28912
29079
  if (extraProps.length) {
28913
29080
  out.push(extraProps);
28914
29081
  }
28915
- if (isDev) {
29082
+ if (isDev2) {
28916
29083
  out.push(value.stack);
28917
29084
  }
28918
29085
  output(12 /* Error */, out);
@@ -28969,7 +29136,7 @@ function serialize(serializationContext) {
28969
29136
  value.$flags$,
28970
29137
  value.$index$,
28971
29138
  value.$el$,
28972
- value.$effectDependencies$,
29139
+ value[_EFFECT_BACK_REF],
28973
29140
  value.$state$
28974
29141
  ];
28975
29142
  while (out[out.length - 1] == null) {
@@ -28989,12 +29156,26 @@ function serialize(serializationContext) {
28989
29156
  }
28990
29157
  const out = btoa(buf).replace(/=+$/, "");
28991
29158
  output(17 /* Uint8Array */, out);
29159
+ } else if (vnode_isVNode(value)) {
29160
+ output(1 /* Constant */, 0 /* Undefined */);
28992
29161
  } else {
28993
29162
  throw qError(37 /* serializeErrorUnknownType */, [typeof value]);
28994
29163
  }
28995
29164
  };
28996
29165
  writeValue(serializationContext.$roots$, -1);
28997
29166
  }
29167
+ function filterEffectBackRefs(effectBackRef) {
29168
+ let effectBackRefToSerialize = null;
29169
+ if (effectBackRef) {
29170
+ for (const [effectProp, effect] of effectBackRef) {
29171
+ if (effect[2 /* BACK_REF */]) {
29172
+ effectBackRefToSerialize ||= /* @__PURE__ */ new Map();
29173
+ effectBackRefToSerialize.set(effectProp, effect);
29174
+ }
29175
+ }
29176
+ }
29177
+ return effectBackRefToSerialize;
29178
+ }
28998
29179
  function serializeWrappingFn(serializationContext, value) {
28999
29180
  if (value.$funcStr$ && value.$funcStr$[0] === "{") {
29000
29181
  value.$funcStr$ = `(${value.$funcStr$})`;
@@ -29010,15 +29191,12 @@ function qrlToString(serializationContext, value) {
29010
29191
  var _a;
29011
29192
  let symbol = value.$symbol$;
29012
29193
  let chunk = value.$chunk$;
29013
- const refSymbol = value.$refSymbol$ ?? symbol;
29014
29194
  const platform = getPlatform();
29015
29195
  if (platform) {
29016
- const result = platform.chunkForSymbol(refSymbol, chunk, (_a = value.dev) == null ? void 0 : _a.file);
29196
+ const result = platform.chunkForSymbol(symbol, chunk, (_a = value.dev) == null ? void 0 : _a.file);
29017
29197
  if (result) {
29018
29198
  chunk = result[1];
29019
- if (!value.$refSymbol$) {
29020
- symbol = result[0];
29021
- }
29199
+ symbol = result[0];
29022
29200
  }
29023
29201
  }
29024
29202
  const isSync = isSyncQrl(value);
@@ -29026,7 +29204,7 @@ function qrlToString(serializationContext, value) {
29026
29204
  if (!chunk) {
29027
29205
  chunk = serializationContext.$symbolToChunkResolver$(value.$hash$);
29028
29206
  }
29029
- if (isDev) {
29207
+ if (isDev2) {
29030
29208
  let backChannel = globalThis[QRL_RUNTIME_CHUNK];
29031
29209
  if (!backChannel) {
29032
29210
  backChannel = globalThis[QRL_RUNTIME_CHUNK] = /* @__PURE__ */ new Map();
@@ -29092,26 +29270,33 @@ function isResource(value) {
29092
29270
  return "__brand" in value && value.__brand === "resource";
29093
29271
  }
29094
29272
  var frameworkType = (obj) => {
29095
- return typeof obj === "object" && obj !== null && (obj instanceof Signal || obj instanceof Task || isJSXNode(obj)) || isQrl2(obj);
29273
+ return typeof obj === "object" && obj !== null && (obj instanceof Signal || obj instanceof Task || isJSXNode(obj)) || isQrl(obj);
29096
29274
  };
29097
- var canSerialize = (value) => {
29275
+ var canSerialize = (value, seen = /* @__PURE__ */ new WeakSet()) => {
29098
29276
  if (value == null || typeof value === "string" || typeof value === "number" || typeof value === "boolean" || typeof value === "bigint") {
29099
29277
  return true;
29100
29278
  } else if (typeof value === "object") {
29279
+ if (seen.has(value)) {
29280
+ return true;
29281
+ }
29282
+ seen.add(value);
29101
29283
  const proto = Object.getPrototypeOf(value);
29102
29284
  if (isStore(value)) {
29103
29285
  value = getStoreTarget(value);
29104
29286
  }
29105
29287
  if (proto == Object.prototype) {
29106
29288
  for (const key in value) {
29107
- if (!canSerialize(untrack(() => value[key]))) {
29289
+ if (!canSerialize(
29290
+ untrack(() => value[key]),
29291
+ seen
29292
+ )) {
29108
29293
  return false;
29109
29294
  }
29110
29295
  }
29111
29296
  return true;
29112
29297
  } else if (proto == Array.prototype) {
29113
29298
  for (let i = 0; i < value.length; i++) {
29114
- if (!canSerialize(value[i])) {
29299
+ if (!canSerialize(value[i], seen)) {
29115
29300
  return false;
29116
29301
  }
29117
29302
  }
@@ -29146,7 +29331,7 @@ var canSerialize = (value) => {
29146
29331
  return true;
29147
29332
  }
29148
29333
  } else if (typeof value === "function") {
29149
- if (isQrl2(value) || isQwikComponent(value)) {
29334
+ if (isQrl(value) || isQwikComponent(value)) {
29150
29335
  return true;
29151
29336
  }
29152
29337
  }
@@ -29264,7 +29449,7 @@ var constantToName = (code2) => {
29264
29449
 
29265
29450
  // packages/qwik/src/core/shared/utils/serialize-utils.ts
29266
29451
  var verifySerializable = (value, preMessage) => {
29267
- const seen = /* @__PURE__ */ new Set();
29452
+ const seen = /* @__PURE__ */ new WeakSet();
29268
29453
  return _verifySerializable(value, seen, "_", preMessage);
29269
29454
  };
29270
29455
  var _verifySerializable = (value, seen, ctx, preMessage) => {
@@ -29273,10 +29458,12 @@ var _verifySerializable = (value, seen, ctx, preMessage) => {
29273
29458
  return value;
29274
29459
  }
29275
29460
  if (shouldSerialize(unwrapped)) {
29276
- if (seen.has(unwrapped)) {
29277
- return value;
29461
+ if (typeof unwrapped === "object") {
29462
+ if (seen.has(unwrapped)) {
29463
+ return value;
29464
+ }
29465
+ seen.add(unwrapped);
29278
29466
  }
29279
- seen.add(unwrapped);
29280
29467
  if (isSignal(unwrapped)) {
29281
29468
  return value;
29282
29469
  }
@@ -29358,14 +29545,7 @@ var noSerialize = (input) => {
29358
29545
  };
29359
29546
 
29360
29547
  // packages/qwik/src/core/shared/qrl/qrl-class.ts
29361
- var isQrl2 = (value) => {
29362
- return typeof value === "function" && typeof value.getSymbol === "function";
29363
- };
29364
- var SYNC_QRL = "<sync>";
29365
- var isSyncQrl = (value) => {
29366
- return isQrl2(value) && value.$symbol$ == SYNC_QRL;
29367
- };
29368
- var createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef, refSymbol) => {
29548
+ var createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef) => {
29369
29549
  if (qDev && qSerialize) {
29370
29550
  if (captureRef) {
29371
29551
  for (const item of captureRef) {
@@ -29386,9 +29566,14 @@ var createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef, refSym
29386
29566
  return _containerEl;
29387
29567
  };
29388
29568
  function bindFnToContext(currentCtx, beforeFn) {
29389
- return (...args) => maybeThen(resolveLazy(), (fn) => {
29390
- if (!isFunction(fn)) {
29391
- throw qError(10 /* qrlIsNotFunction */);
29569
+ const bound = (...args) => {
29570
+ if (!qrl2.resolved) {
29571
+ return qrl2.resolve().then((fn) => {
29572
+ if (!isFunction(fn)) {
29573
+ throw qError(10 /* qrlIsNotFunction */);
29574
+ }
29575
+ return bound(...args);
29576
+ });
29392
29577
  }
29393
29578
  if (beforeFn && beforeFn() === false) {
29394
29579
  return;
@@ -29399,12 +29584,13 @@ var createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef, refSym
29399
29584
  context.$qrl$ = qrl2;
29400
29585
  context.$event$ ||= this;
29401
29586
  try {
29402
- return invoke.call(this, context, fn, ...args);
29587
+ return invoke.call(this, context, symbolRef, ...args);
29403
29588
  } finally {
29404
29589
  context.$qrl$ = prevQrl;
29405
29590
  context.$event$ = prevEvent;
29406
29591
  }
29407
- });
29592
+ };
29593
+ return bound;
29408
29594
  }
29409
29595
  const resolveLazy = (containerEl) => {
29410
29596
  return symbolRef !== null ? symbolRef : resolve(containerEl);
@@ -29414,9 +29600,19 @@ var createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef, refSym
29414
29600
  return fn;
29415
29601
  }
29416
29602
  return function(...args) {
29603
+ var _a;
29417
29604
  let context = tryGetInvokeContext();
29418
29605
  if (context) {
29419
- return fn.apply(this, args);
29606
+ if (((_a = context.$qrl$) == null ? void 0 : _a.$symbol$) === qrl2.$symbol$) {
29607
+ return fn.apply(this, args);
29608
+ }
29609
+ const prevQrl = context.$qrl$;
29610
+ context.$qrl$ = qrl2;
29611
+ try {
29612
+ return fn.apply(this, args);
29613
+ } finally {
29614
+ context.$qrl$ = prevQrl;
29615
+ }
29420
29616
  }
29421
29617
  context = newInvokeContext();
29422
29618
  context.$qrl$ = qrl2;
@@ -29441,10 +29637,12 @@ var createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef, refSym
29441
29637
  const start = now();
29442
29638
  const ctx = tryGetInvokeContext();
29443
29639
  if (symbolFn !== null) {
29444
- symbolRef = symbolFn().then((module2) => qrl2.resolved = symbolRef = wrapFn(module2[symbol]));
29640
+ symbolRef = symbolFn().then(
29641
+ (module2) => qrl2.resolved = wrapFn(symbolRef = module2[symbol])
29642
+ );
29445
29643
  } else {
29446
29644
  const imported = getPlatform().importSymbol(_containerEl, chunk, symbol);
29447
- symbolRef = maybeThen(imported, (ref) => qrl2.resolved = symbolRef = wrapFn(ref));
29645
+ symbolRef = maybeThen(imported, (ref) => qrl2.resolved = wrapFn(symbolRef = ref));
29448
29646
  }
29449
29647
  if (typeof symbolRef === "object" && isPromise(symbolRef)) {
29450
29648
  symbolRef.then(
@@ -29467,10 +29665,9 @@ var createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef, refSym
29467
29665
  return invoke2;
29468
29666
  }
29469
29667
  };
29470
- const resolvedSymbol = refSymbol ?? symbol;
29471
- const hash3 = getSymbolHash(resolvedSymbol);
29668
+ const hash3 = getSymbolHash(symbol);
29472
29669
  Object.assign(qrl2, {
29473
- getSymbol: () => resolvedSymbol,
29670
+ getSymbol: () => symbol,
29474
29671
  getHash: () => hash3,
29475
29672
  getCaptured: () => captureRef,
29476
29673
  resolve,
@@ -29478,7 +29675,6 @@ var createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef, refSym
29478
29675
  $setContainer$: setContainer,
29479
29676
  $chunk$: chunk,
29480
29677
  $symbol$: symbol,
29481
- $refSymbol$: refSymbol,
29482
29678
  $hash$: hash3,
29483
29679
  getFn: bindFnToContext,
29484
29680
  $capture$: capture,
@@ -29487,9 +29683,9 @@ var createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef, refSym
29487
29683
  resolved: void 0
29488
29684
  });
29489
29685
  if (symbolRef) {
29490
- symbolRef = maybeThen(symbolRef, (resolved) => qrl2.resolved = symbolRef = wrapFn(resolved));
29686
+ symbolRef = maybeThen(symbolRef, (resolved) => qrl2.resolved = wrapFn(symbolRef = resolved));
29491
29687
  }
29492
- if (import_build8.isDev) {
29688
+ if (import_build10.isDev) {
29493
29689
  Object.defineProperty(qrl2, "_devOnlySymbolRef", {
29494
29690
  get() {
29495
29691
  return symbolRef;
@@ -29501,20 +29697,6 @@ var createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef, refSym
29501
29697
  }
29502
29698
  return qrl2;
29503
29699
  };
29504
- var getSymbolHash = (symbolName) => {
29505
- const index = symbolName.lastIndexOf("_");
29506
- if (index > -1) {
29507
- return symbolName.slice(index + 1);
29508
- }
29509
- return symbolName;
29510
- };
29511
- function assertQrl(qrl2) {
29512
- if (qDev) {
29513
- if (!isQrl2(qrl2)) {
29514
- throw new Error("Not a QRL");
29515
- }
29516
- }
29517
- }
29518
29700
  var EMITTED = /* @__PURE__ */ new Set();
29519
29701
  var emitUsedSymbol = (symbol, element, reqTime) => {
29520
29702
  if (!EMITTED.has(symbol)) {
@@ -29554,7 +29736,7 @@ var $ = (expression) => {
29554
29736
  "Optimizer should replace all usages of $() with some special syntax. If you need to create a QRL manually, use inlinedQrl() instead."
29555
29737
  );
29556
29738
  }
29557
- return createQRL(null, "s" + runtimeSymbolId++, expression, null, null, null, null);
29739
+ return createQRL(null, "s" + runtimeSymbolId++, expression, null, null, null);
29558
29740
  };
29559
29741
  var dollar = $;
29560
29742
  var eventQrl = (qrl2) => {
@@ -29581,9 +29763,6 @@ var isQwikComponent = (component) => {
29581
29763
  return typeof component == "function" && component[SERIALIZABLE_STATE] !== void 0;
29582
29764
  };
29583
29765
 
29584
- // packages/qwik/src/core/index.ts
29585
- var import_build10 = require("@qwik.dev/core/build");
29586
-
29587
29766
  // packages/qwik/src/core/shared/qrl/qrl.public.dollar.ts
29588
29767
  var event$ = implicit$FirstArg(eventQrl);
29589
29768
 
@@ -29770,9 +29949,6 @@ var useComputedQrl = (qrl2) => {
29770
29949
  // packages/qwik/src/core/use/use-computed-dollar.ts
29771
29950
  var useComputed$ = implicit$FirstArg(useComputedQrl);
29772
29951
 
29773
- // packages/qwik/src/core/shared/prefetch-service-worker/prefetch.ts
29774
- var import_build9 = require("@qwik.dev/core/build");
29775
-
29776
29952
  // packages/qwik/src/testing/vdom-diff.unit-util.ts
29777
29953
  var import_vitest = require("vitest");
29778
29954
  var import_prettier = require("prettier");
@@ -29885,7 +30061,7 @@ import_vitest.expect.extend({
29885
30061
  };
29886
30062
  }
29887
30063
  });
29888
- var ignoredAttributes = [QSubscribers, ELEMENT_ID, "", Q_PROPS_SEPARATOR];
30064
+ var ignoredAttributes = [QBackRefs, ELEMENT_ID, "", Q_PROPS_SEPARATOR];
29889
30065
  function getContainerElement(vNode) {
29890
30066
  let maybeParent;
29891
30067
  do {
@@ -30314,7 +30490,6 @@ function attrsEqual(expectedValue, receivedValue) {
30314
30490
  }
30315
30491
 
30316
30492
  // packages/qwik/src/testing/element-fixture.ts
30317
- var import_vitest2 = require("vitest");
30318
30493
  var import_core2 = require("../core.cjs");
30319
30494
 
30320
30495
  // packages/qwik/src/testing/platform.ts
@@ -30492,7 +30667,6 @@ var dispatch = async (element, attrName, event, scope) => {
30492
30667
  const isDocumentOrWindow = isDocumentOrWindowEvent(event.type);
30493
30668
  const preventAttributeName = PREVENT_DEFAULT + (isDocumentOrWindow ? event.type.substring(1) : event.type);
30494
30669
  const stopPropagationName = STOP_PROPAGATION + event.type;
30495
- const collectListeners = [];
30496
30670
  while (element) {
30497
30671
  const preventDefault = element.hasAttribute(preventAttributeName);
30498
30672
  const stopPropagation = element.hasAttribute(stopPropagationName);
@@ -30509,15 +30683,21 @@ var dispatch = async (element, attrName, event, scope) => {
30509
30683
  } else if (element.hasAttribute(attrName)) {
30510
30684
  const container = (0, import_core2.getDomContainer)(element);
30511
30685
  const qrl2 = element.getAttribute(attrName);
30512
- qrl2.split("\n").map((qrl3) => container.parseQRL(qrl3.trim())).map((qrl3) => qrl3(event, element));
30686
+ const ctx = newInvokeContextFromTuple([element, event]);
30687
+ try {
30688
+ await Promise.all(
30689
+ qrl2.split("\n").map((qrl3) => container.parseQRL(qrl3.trim())).map((qrl3) => {
30690
+ return invokeApply(ctx, qrl3, [event, element]);
30691
+ })
30692
+ );
30693
+ } catch (error) {
30694
+ console.error("!!! qrl error", qrl2, error);
30695
+ throw error;
30696
+ }
30513
30697
  return;
30514
30698
  }
30515
30699
  element = element.parentElement;
30516
30700
  }
30517
- for (let i = 0; i < collectListeners.length; i++) {
30518
- const { element: element2, qrl: qrl2 } = collectListeners[i];
30519
- await qrl2.getFn([element2, event], () => element2.isConnected)(event, element2);
30520
- }
30521
30701
  };
30522
30702
 
30523
30703
  // packages/qwik/src/testing/library.ts
@@ -30544,20 +30724,34 @@ var getQwik = async () => {
30544
30724
  };
30545
30725
 
30546
30726
  // packages/qwik/src/testing/expect-dom.tsx
30547
- var import_vitest3 = require("vitest");
30727
+ var import_vitest2 = require("vitest");
30548
30728
  var import_prettier2 = require("prettier");
30549
30729
  async function expectDOM(actual, expected) {
30550
30730
  const options = { parser: "html", htmlWhitespaceSensitivity: "ignore" };
30551
- import_vitest3.assert.equal(await (0, import_prettier2.format)(actual.outerHTML, options), await (0, import_prettier2.format)(expected, options));
30731
+ import_vitest2.assert.equal(await (0, import_prettier2.format)(actual.outerHTML, options), await (0, import_prettier2.format)(expected, options));
30552
30732
  }
30553
30733
 
30554
30734
  // packages/qwik/src/testing/rendering.unit-util.tsx
30555
30735
  var import_core8 = require("../core.cjs");
30556
- var import_vitest4 = require("vitest");
30736
+ var import_vitest3 = require("vitest");
30557
30737
 
30558
30738
  // packages/qwik/src/server/platform.ts
30559
30739
  var import_core3 = require("../core.cjs");
30560
- var SYNC_QRL2 = "<sync>";
30740
+
30741
+ // packages/qwik/src/optimizer/src/versions.ts
30742
+ var versions2 = {
30743
+ qwik: globalThis.QWIK_VERSION
30744
+ };
30745
+
30746
+ // packages/qwik/src/optimizer/src/manifest.ts
30747
+ function getValidManifest(manifest) {
30748
+ if (manifest != null && manifest.mapping != null && typeof manifest.mapping === "object" && manifest.symbols != null && typeof manifest.symbols === "object" && manifest.bundles != null && typeof manifest.bundles === "object") {
30749
+ return manifest;
30750
+ }
30751
+ return void 0;
30752
+ }
30753
+
30754
+ // packages/qwik/src/server/platform.ts
30561
30755
  function createPlatform3(opts, resolvedManifest) {
30562
30756
  const mapper = resolvedManifest == null ? void 0 : resolvedManifest.mapper;
30563
30757
  const mapperFn = opts.symbolMapper ? opts.symbolMapper : (symbolName, _chunk, parent) => {
@@ -30566,7 +30760,7 @@ function createPlatform3(opts, resolvedManifest) {
30566
30760
  const hash3 = getSymbolHash2(symbolName);
30567
30761
  const result = mapper[hash3];
30568
30762
  if (!result) {
30569
- if (hash3 === SYNC_QRL2) {
30763
+ if (hash3 === SYNC_QRL) {
30570
30764
  return [hash3, ""];
30571
30765
  }
30572
30766
  const isRegistered = (_a = globalThis.__qwik_reg_symbols) == null ? void 0 : _a.has(hash3);
@@ -30629,19 +30823,6 @@ var getSymbolHash2 = (symbolName) => {
30629
30823
  return symbolName;
30630
30824
  };
30631
30825
 
30632
- // packages/qwik/src/optimizer/src/versions.ts
30633
- var versions2 = {
30634
- qwik: globalThis.QWIK_VERSION
30635
- };
30636
-
30637
- // packages/qwik/src/optimizer/src/manifest.ts
30638
- function getValidManifest(manifest) {
30639
- if (manifest != null && manifest.mapping != null && typeof manifest.mapping === "object" && manifest.symbols != null && typeof manifest.symbols === "object" && manifest.bundles != null && typeof manifest.bundles === "object") {
30640
- return manifest;
30641
- }
30642
- return void 0;
30643
- }
30644
-
30645
30826
  // packages/qwik/src/server/ssr-container.ts
30646
30827
  var import_core6 = require("../core.cjs");
30647
30828
  var import_build12 = require("@qwik.dev/core/build");
@@ -30662,7 +30843,8 @@ function prefetchUrlsEventScript(base, prefetchResources) {
30662
30843
  bundles: flattenPrefetchResources(prefetchResources).map((u) => u.split("/").pop())
30663
30844
  };
30664
30845
  const args = JSON.stringify(["prefetch", base, ...data.bundles]);
30665
- 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});`;
30666
30848
  }
30667
30849
  function flattenPrefetchResources(prefetchResources) {
30668
30850
  const urls = [];
@@ -30853,6 +31035,9 @@ var SsrNode = class {
30853
31035
  locals = null;
30854
31036
  currentComponentNode;
30855
31037
  childrenVNodeData = null;
31038
+ get [import_core4._EFFECT_BACK_REF]() {
31039
+ return this.getProp(QBackRefs);
31040
+ }
30856
31041
  setProp(name, value) {
30857
31042
  if (this.attrs === import_core4._EMPTY_ARRAY) {
30858
31043
  this.attrs = [];
@@ -31431,7 +31616,13 @@ var SSRContainer = class extends import_core6._SharedContainer {
31431
31616
  $noMoreRoots$ = false;
31432
31617
  constructor(opts) {
31433
31618
  super(
31434
- () => null,
31619
+ () => {
31620
+ try {
31621
+ return this.$scheduler$(255 /* WAIT_FOR_ALL */);
31622
+ } catch (e) {
31623
+ this.handleError(e, null);
31624
+ }
31625
+ },
31435
31626
  () => null,
31436
31627
  opts.renderOptions.serverData ?? EMPTY_OBJ2,
31437
31628
  opts.locale
@@ -31457,15 +31648,14 @@ var SSRContainer = class extends import_core6._SharedContainer {
31457
31648
  this.renderOptions = opts.renderOptions;
31458
31649
  this.$processInjectionsFromManifest$();
31459
31650
  }
31460
- ensureProjectionResolved(host) {
31651
+ ensureProjectionResolved(_host) {
31461
31652
  }
31462
- handleError(err, $host$) {
31653
+ handleError(err, _$host$) {
31463
31654
  throw err;
31464
31655
  }
31465
31656
  async render(jsx4) {
31466
31657
  this.openContainer();
31467
31658
  await (0, import_core6._walkJSX)(this, jsx4, {
31468
- allowPromises: true,
31469
31659
  currentStyleScoped: null,
31470
31660
  parentComponentFrame: this.getComponentFrame()
31471
31661
  });
@@ -31879,8 +32069,8 @@ var SSRContainer = class extends import_core6._SharedContainer {
31879
32069
  case ELEMENT_SEQ_IDX:
31880
32070
  write(VNodeDataChar.SEQ_IDX_CHAR);
31881
32071
  break;
31882
- case QSubscribers:
31883
- write(VNodeDataChar.SUBS_CHAR);
32072
+ case QBackRefs:
32073
+ write(VNodeDataChar.BACK_REFS_CHAR);
31884
32074
  break;
31885
32075
  // Skipping `\` character for now because it is used for escaping.
31886
32076
  case QCtxAttr:
@@ -32090,7 +32280,6 @@ var SSRContainer = class extends import_core6._SharedContainer {
32090
32280
  }
32091
32281
  ssrComponentNode == null ? void 0 : ssrComponentNode.setProp(value, lastNode.id);
32092
32282
  await (0, import_core6._walkJSX)(this, children, {
32093
- allowPromises: true,
32094
32283
  currentStyleScoped: scopedStyleId,
32095
32284
  parentComponentFrame: null
32096
32285
  });
@@ -32209,7 +32398,7 @@ var SSRContainer = class extends import_core6._SharedContainer {
32209
32398
  let styleScopedId = null;
32210
32399
  if (isSSRUnsafeAttr(key)) {
32211
32400
  if (import_build12.isDev) {
32212
- throw qError(51 /* unsafeAttr */);
32401
+ throw qError(49 /* unsafeAttr */);
32213
32402
  }
32214
32403
  continue;
32215
32404
  }
@@ -32226,6 +32415,8 @@ var SSRContainer = class extends import_core6._SharedContainer {
32226
32415
  } else if (typeof value === "function") {
32227
32416
  value(new DomRef(lastNode));
32228
32417
  continue;
32418
+ } else if (value == null) {
32419
+ continue;
32229
32420
  } else {
32230
32421
  throw qError(32 /* invalidRefValue */, [currentFile]);
32231
32422
  }
@@ -32549,7 +32740,7 @@ async function ssrRenderToDom(jsx4, opts = {}) {
32549
32740
  const platform = getPlatform();
32550
32741
  try {
32551
32742
  const jsxToRender = opts.raw ? jsx4 : [
32552
- /* @__PURE__ */ (0, import_core7.jsx)("head", { children: /* @__PURE__ */ (0, import_core7.jsx)("title", { children: import_vitest4.expect.getState().testPath }) }),
32743
+ /* @__PURE__ */ (0, import_core7.jsx)("head", { children: /* @__PURE__ */ (0, import_core7.jsx)("title", { children: import_vitest3.expect.getState().testPath }) }),
32553
32744
  /* @__PURE__ */ (0, import_core7.jsx)("body", { children: jsx4 })
32554
32745
  ];
32555
32746
  const result = await renderToString(jsxToRender);
@@ -32594,7 +32785,7 @@ async function ssrRenderToDom(jsx4, opts = {}) {
32594
32785
  let child = firstContainerChild;
32595
32786
  let insertBefore = null;
32596
32787
  while (child) {
32597
- if (vnode_isElementVNode(child) && (vnode_getElementName(child) === "script" && vnode_getAttr(child, "type") === "qwik/state" || vnode_getElementName(child) === "q:template")) {
32788
+ if (vnode_isElementVNode(child) && (vnode_getElementName(child) === "script" && (vnode_getAttr(child, "type") === "qwik/state" || vnode_getAttr(child, "id") === "qwikloader") || vnode_getElementName(child) === "q:template")) {
32598
32789
  insertBefore = child;
32599
32790
  break;
32600
32791
  }
@@ -32654,14 +32845,16 @@ function renderStyles(getStyles) {
32654
32845
  console.log(START2 + key + ": " + END2 + value);
32655
32846
  });
32656
32847
  }
32657
- async function rerenderComponent(element) {
32848
+ async function rerenderComponent(element, flush) {
32658
32849
  const container = (0, import_core8._getDomContainer)(element);
32659
32850
  const vElement = vnode_locate(container.rootVNode, element);
32660
32851
  const host = getHostVNode(vElement);
32661
32852
  const qrl2 = container.getHostProp(host, OnRenderProp);
32662
32853
  const props = container.getHostProp(host, ELEMENT_PROPS);
32663
- await container.$scheduler$(7 /* COMPONENT */, host, qrl2, props);
32664
- await getTestPlatform().flush();
32854
+ container.$scheduler$(6 /* COMPONENT */, host, qrl2, props);
32855
+ if (flush) {
32856
+ await getTestPlatform().flush();
32857
+ }
32665
32858
  }
32666
32859
  function getHostVNode(vElement) {
32667
32860
  while (vElement != null) {