@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
@@ -22151,7 +22151,7 @@ var seal = (obj) => {
22151
22151
  };
22152
22152
 
22153
22153
  // packages/qwik/src/core/shared/qrl/qrl-class.ts
22154
- import { isDev as isDev7 } from "@qwik.dev/core/build";
22154
+ import { isDev as isDev8 } from "@qwik.dev/core/build";
22155
22155
 
22156
22156
  // packages/qwik/src/core/shared/utils/log.ts
22157
22157
  var STYLE = qDev ? `background: #564CE0; color: white; padding: 2px 3px; border-radius: 2px; font-size: 0.8em;` : "";
@@ -22231,10 +22231,10 @@ var codeToText = (code2, ...parts) => {
22231
22231
  const MAP = [
22232
22232
  "Error while serializing class or style attributes",
22233
22233
  // 0
22234
- "",
22235
- // 1 unused
22236
- "",
22237
- // 2 unused
22234
+ "Scheduler not found",
22235
+ // 1
22236
+ "track() received object, without prop to track",
22237
+ // 2
22238
22238
  "Only primitive and object literals can be serialized. {{0}}",
22239
22239
  // 3
22240
22240
  "",
@@ -22320,20 +22320,16 @@ See https://qwik.dev/docs/components/tasks/#use-method-rules`,
22320
22320
  // 43
22321
22321
  "Materialize error: missing element: {{0}} {{1}} {{2}}",
22322
22322
  // 44
22323
- "SsrError: {{0}}",
22324
- // 45
22325
22323
  "Cannot coerce a Signal, use `.value` instead",
22326
- // 46
22324
+ // 45
22327
22325
  "useComputedSignal$ QRL {{0}} {{1}} returned a Promise",
22328
- // 47
22326
+ // 46
22329
22327
  "ComputedSignal is read-only",
22330
- // 48
22328
+ // 47
22331
22329
  "WrappedSignal is read-only",
22332
- // 49
22333
- "SsrError: Promises not expected here.",
22334
- // 50
22330
+ // 48
22335
22331
  "Attribute value is unsafe for SSR"
22336
- // 51
22332
+ // 49
22337
22333
  ];
22338
22334
  let text = MAP[code2] ?? "";
22339
22335
  if (parts.length) {
@@ -22357,6 +22353,130 @@ var qError = (code2, errorMessageArgs = []) => {
22357
22353
 
22358
22354
  // packages/qwik/src/core/shared/platform/platform.ts
22359
22355
  import { isServer } from "@qwik.dev/core/build";
22356
+
22357
+ // packages/qwik/src/core/shared/qrl/qrl-utils.ts
22358
+ import { isDev } from "@qwik.dev/core/build";
22359
+ var SYNC_QRL = "<sync>";
22360
+ var isSyncQrl = (value) => {
22361
+ return isQrl(value) && value.$symbol$ == SYNC_QRL;
22362
+ };
22363
+ var isQrl = (value) => {
22364
+ return typeof value === "function" && typeof value.getSymbol === "function";
22365
+ };
22366
+ function assertQrl(qrl2) {
22367
+ if (isDev) {
22368
+ if (!isQrl(qrl2)) {
22369
+ throw new Error("Not a QRL");
22370
+ }
22371
+ }
22372
+ }
22373
+ var getSymbolHash = (symbolName) => {
22374
+ const index = symbolName.lastIndexOf("_");
22375
+ if (index > -1) {
22376
+ return symbolName.slice(index + 1);
22377
+ }
22378
+ return symbolName;
22379
+ };
22380
+
22381
+ // packages/qwik/src/core/shared/types.ts
22382
+ var DEBUG_TYPE = "q:type";
22383
+ var START = "\x1B[34m";
22384
+ var END = "\x1B[0m";
22385
+ var VirtualTypeName = {
22386
+ ["V" /* Virtual */]: (
22387
+ /* ********* */
22388
+ START + "Virtual" + END
22389
+ ),
22390
+ //
22391
+ ["F" /* Fragment */]: (
22392
+ /* ******** */
22393
+ START + "Fragment" + END
22394
+ ),
22395
+ //
22396
+ ["S" /* WrappedSignal */]: (
22397
+ /* *** */
22398
+ START + "Signal" + END
22399
+ ),
22400
+ //
22401
+ ["A" /* Awaited */]: (
22402
+ /* ********* */
22403
+ START + "Awaited" + END
22404
+ ),
22405
+ //
22406
+ ["C" /* Component */]: (
22407
+ /* ******* */
22408
+ START + "Component" + END
22409
+ ),
22410
+ //
22411
+ ["I" /* InlineComponent */]: (
22412
+ /* * */
22413
+ START + "InlineComponent" + END
22414
+ ),
22415
+ //
22416
+ ["P" /* Projection */]: (
22417
+ /* ****** */
22418
+ START + "Projection" + END
22419
+ )
22420
+ //
22421
+ };
22422
+
22423
+ // packages/qwik/src/core/shared/utils/markers.ts
22424
+ var OnRenderProp = "q:renderFn";
22425
+ var ComponentStylesPrefixContent = "\u26A1\uFE0F";
22426
+ var QSlot = "q:slot";
22427
+ var QSlotParent = ":";
22428
+ var QSlotRef = "q:sref";
22429
+ var QSlotS = "q:s";
22430
+ var QStyle = "q:style";
22431
+ var QStyleSelector = "style[q\\:style]";
22432
+ var QStyleSSelector = "style[q\\:sstyle]";
22433
+ var QStylesAllSelector = QStyleSelector + "," + QStyleSSelector;
22434
+ var QScopedStyle = "q:sstyle";
22435
+ var QCtxAttr = "q:ctx";
22436
+ var QBackRefs = "q:brefs";
22437
+ var QFuncsPrefix = "qFuncs_";
22438
+ var getQFuncs = (document2, hash3) => {
22439
+ return document2[QFuncsPrefix + hash3] || [];
22440
+ };
22441
+ var QRenderAttr = "q:render";
22442
+ var QRuntimeAttr = "q:runtime";
22443
+ var QVersionAttr = "q:version";
22444
+ var QBaseAttr = "q:base";
22445
+ var QLocaleAttr = "q:locale";
22446
+ var QManifestHashAttr = "q:manifest-hash";
22447
+ var QInstanceAttr = "q:instance";
22448
+ var QContainerIsland = "q:container-island";
22449
+ var QContainerIslandEnd = "/" + QContainerIsland;
22450
+ var QIgnore = "q:ignore";
22451
+ var QIgnoreEnd = "/" + QIgnore;
22452
+ var QContainerAttr = "q:container";
22453
+ var QContainerAttrEnd = "/" + QContainerAttr;
22454
+ var QTemplate = "q:template";
22455
+ var QContainerSelector = "[q\\:container]:not([q\\:container=" + "html" /* HTML */ + "]):not([q\\:container=" + "text" /* TEXT */ + "])";
22456
+ var HTML_NS = "http://www.w3.org/1999/xhtml";
22457
+ var SVG_NS = "http://www.w3.org/2000/svg";
22458
+ var MATH_NS = "http://www.w3.org/1998/Math/MathML";
22459
+ var ResourceEvent = "qResource";
22460
+ var RenderEvent = "qRender";
22461
+ var TaskEvent = "qTask";
22462
+ var QDefaultSlot = "";
22463
+ var ELEMENT_ID = "q:id";
22464
+ var ELEMENT_KEY = "q:key";
22465
+ var ELEMENT_PROPS = "q:props";
22466
+ var ELEMENT_SEQ = "q:seq";
22467
+ var ELEMENT_SEQ_IDX = "q:seqIdx";
22468
+ var Q_PREFIX = "q:";
22469
+ var NON_SERIALIZABLE_MARKER_PREFIX = ":";
22470
+ var USE_ON_LOCAL = NON_SERIALIZABLE_MARKER_PREFIX + "on";
22471
+ var USE_ON_LOCAL_SEQ_IDX = NON_SERIALIZABLE_MARKER_PREFIX + "onIdx";
22472
+ var USE_ON_LOCAL_FLAGS = NON_SERIALIZABLE_MARKER_PREFIX + "onFlags";
22473
+ var FLUSH_COMMENT = "qkssr-f";
22474
+ var STREAM_BLOCK_START_COMMENT = "qkssr-pu";
22475
+ var STREAM_BLOCK_END_COMMENT = "qkssr-po";
22476
+ var Q_PROPS_SEPARATOR = ":";
22477
+ var dangerouslySetInnerHTML = "dangerouslySetInnerHTML";
22478
+
22479
+ // packages/qwik/src/core/shared/platform/platform.ts
22360
22480
  var createPlatform = () => {
22361
22481
  return {
22362
22482
  isServer,
@@ -22406,7 +22526,7 @@ var createPlatform = () => {
22406
22526
  };
22407
22527
  var toUrl = (doc, containerEl, url) => {
22408
22528
  const baseURI = doc.baseURI;
22409
- const base = new URL(containerEl.getAttribute("q:base") ?? baseURI, baseURI);
22529
+ const base = new URL(containerEl.getAttribute(QBaseAttr) ?? baseURI, baseURI);
22410
22530
  return new URL(url, base);
22411
22531
  };
22412
22532
  var _platform = /* @__PURE__ */ createPlatform();
@@ -22449,9 +22569,6 @@ var safeCall = (call, thenFn, rejectFn) => {
22449
22569
  var maybeThen = (valueOrPromise, thenFn) => {
22450
22570
  return isPromise(valueOrPromise) ? valueOrPromise.then(thenFn, shouldNotError) : thenFn(valueOrPromise);
22451
22571
  };
22452
- var maybeThenPassError = (valueOrPromise, thenFn) => {
22453
- return isPromise(valueOrPromise) ? valueOrPromise.then(thenFn) : thenFn(valueOrPromise);
22454
- };
22455
22572
  var shouldNotError = (reason) => {
22456
22573
  throwErrorAndStop(reason);
22457
22574
  };
@@ -22461,13 +22578,20 @@ var delay = (timeout) => {
22461
22578
  });
22462
22579
  };
22463
22580
  function retryOnPromise(fn, retryCount = 0) {
22464
- try {
22465
- return fn();
22466
- } catch (e) {
22581
+ const retryOrThrow = (e) => {
22467
22582
  if (isPromise(e) && retryCount < MAX_RETRY_ON_PROMISE_COUNT) {
22468
22583
  return e.then(retryOnPromise.bind(null, fn, retryCount++));
22469
22584
  }
22470
22585
  throw e;
22586
+ };
22587
+ try {
22588
+ const result = fn();
22589
+ if (isPromise(result)) {
22590
+ return result.catch((e) => retryOrThrow(e));
22591
+ }
22592
+ return result;
22593
+ } catch (e) {
22594
+ return retryOrThrow(e);
22471
22595
  }
22472
22596
  }
22473
22597
 
@@ -22490,105 +22614,7 @@ var isFunction = (v) => {
22490
22614
  };
22491
22615
 
22492
22616
  // packages/qwik/src/build/index.dev.ts
22493
- var isDev = true;
22494
-
22495
- // packages/qwik/src/core/shared/types.ts
22496
- var DEBUG_TYPE = "q:type";
22497
- var START = "\x1B[34m";
22498
- var END = "\x1B[0m";
22499
- var VirtualTypeName = {
22500
- ["V" /* Virtual */]: (
22501
- /* ********* */
22502
- START + "Virtual" + END
22503
- ),
22504
- //
22505
- ["F" /* Fragment */]: (
22506
- /* ******** */
22507
- START + "Fragment" + END
22508
- ),
22509
- //
22510
- ["S" /* WrappedSignal */]: (
22511
- /* *** */
22512
- START + "Signal" + END
22513
- ),
22514
- //
22515
- ["A" /* Awaited */]: (
22516
- /* ********* */
22517
- START + "Awaited" + END
22518
- ),
22519
- //
22520
- ["C" /* Component */]: (
22521
- /* ******* */
22522
- START + "Component" + END
22523
- ),
22524
- //
22525
- ["I" /* InlineComponent */]: (
22526
- /* * */
22527
- START + "InlineComponent" + END
22528
- ),
22529
- //
22530
- ["P" /* Projection */]: (
22531
- /* ****** */
22532
- START + "Projection" + END
22533
- )
22534
- //
22535
- };
22536
-
22537
- // packages/qwik/src/core/shared/utils/markers.ts
22538
- var OnRenderProp = "q:renderFn";
22539
- var ComponentStylesPrefixContent = "\u2B50\uFE0F";
22540
- var QSlot = "q:slot";
22541
- var QSlotParent = ":";
22542
- var QSlotRef = "q:sref";
22543
- var QSlotS = "q:s";
22544
- var QStyle = "q:style";
22545
- var QStyleSelector = "style[q\\:style]";
22546
- var QStyleSSelector = "style[q\\:sstyle]";
22547
- var QStylesAllSelector = QStyleSelector + "," + QStyleSSelector;
22548
- var QScopedStyle = "q:sstyle";
22549
- var QCtxAttr = "q:ctx";
22550
- var QSubscribers = "q:subs";
22551
- var QFuncsPrefix = "qFuncs_";
22552
- var getQFuncs = (document2, hash3) => {
22553
- return document2[QFuncsPrefix + hash3] || [];
22554
- };
22555
- var QRenderAttr = "q:render";
22556
- var QRuntimeAttr = "q:runtime";
22557
- var QVersionAttr = "q:version";
22558
- var QBaseAttr = "q:base";
22559
- var QLocaleAttr = "q:locale";
22560
- var QManifestHashAttr = "q:manifest-hash";
22561
- var QInstanceAttr = "q:instance";
22562
- var QContainerIsland = "q:container-island";
22563
- var QContainerIslandEnd = "/" + QContainerIsland;
22564
- var QIgnore = "q:ignore";
22565
- var QIgnoreEnd = "/" + QIgnore;
22566
- var QContainerAttr = "q:container";
22567
- var QContainerAttrEnd = "/" + QContainerAttr;
22568
- var QTemplate = "q:template";
22569
- var QContainerSelector = "[q\\:container]:not([q\\:container=" + "html" /* HTML */ + "]):not([q\\:container=" + "text" /* TEXT */ + "])";
22570
- var HTML_NS = "http://www.w3.org/1999/xhtml";
22571
- var SVG_NS = "http://www.w3.org/2000/svg";
22572
- var MATH_NS = "http://www.w3.org/1998/Math/MathML";
22573
- var ResourceEvent = "qResource";
22574
- var RenderEvent = "qRender";
22575
- var TaskEvent = "qTask";
22576
- var QDefaultSlot = "";
22577
- var ELEMENT_ID = "q:id";
22578
- var ELEMENT_KEY = "q:key";
22579
- var ELEMENT_PROPS = "q:props";
22580
- var ELEMENT_SEQ = "q:seq";
22581
- var ELEMENT_SEQ_IDX = "q:seqIdx";
22582
- var Q_PREFIX = "q:";
22583
- var NON_SERIALIZABLE_MARKER_PREFIX = ":";
22584
- var USE_ON_LOCAL = NON_SERIALIZABLE_MARKER_PREFIX + "on";
22585
- var USE_ON_LOCAL_SEQ_IDX = NON_SERIALIZABLE_MARKER_PREFIX + "onIdx";
22586
- var USE_ON_LOCAL_FLAGS = NON_SERIALIZABLE_MARKER_PREFIX + "onFlags";
22587
- var FLUSH_COMMENT = "qkssr-f";
22588
- var STREAM_BLOCK_START_COMMENT = "qkssr-pu";
22589
- var STREAM_BLOCK_END_COMMENT = "qkssr-po";
22590
- var Q_PROPS_SEPARATOR = ":";
22591
- var dangerouslySetInnerHTML = "dangerouslySetInnerHTML";
22617
+ var isDev2 = true;
22592
22618
 
22593
22619
  // packages/qwik/src/core/use/use-locale.ts
22594
22620
  var _locale = void 0;
@@ -22597,7 +22623,7 @@ function setLocale(locale) {
22597
22623
  }
22598
22624
 
22599
22625
  // packages/qwik/src/core/client/vnode.ts
22600
- import { isDev as isDev6 } from "@qwik.dev/core/build";
22626
+ import { isDev as isDev7 } from "@qwik.dev/core/build";
22601
22627
 
22602
22628
  // packages/qwik/src/server/utils.ts
22603
22629
  function createTimer() {
@@ -22630,7 +22656,7 @@ var versions = {
22630
22656
  };
22631
22657
 
22632
22658
  // packages/qwik/src/server/prefetch-strategy.ts
22633
- import { isDev as isDev2 } from "@qwik.dev/core/build";
22659
+ import { isDev as isDev3 } from "@qwik.dev/core/build";
22634
22660
  function getPrefetchResources(qrls, opts, resolvedManifest) {
22635
22661
  if (!resolvedManifest) {
22636
22662
  return [];
@@ -22668,7 +22694,7 @@ function getAutoPrefetch(qrls, resolvedManifest, buildBase) {
22668
22694
  return prefetchResources;
22669
22695
  }
22670
22696
  function addBundle(manifest, urls, prefetchResources, buildBase, bundleFileName) {
22671
- const url = isDev2 ? bundleFileName : buildBase + bundleFileName;
22697
+ const url = isDev3 ? bundleFileName : buildBase + bundleFileName;
22672
22698
  let prefetchResource = urls.get(url);
22673
22699
  if (!prefetchResource) {
22674
22700
  prefetchResource = {
@@ -22687,7 +22713,7 @@ function addBundle(manifest, urls, prefetchResources, buildBase, bundleFileName)
22687
22713
  }
22688
22714
  prefetchResources.push(prefetchResource);
22689
22715
  }
22690
- var isQrl = (value) => {
22716
+ var isQrl2 = (value) => {
22691
22717
  return typeof value === "function" && typeof value.getSymbol === "function";
22692
22718
  };
22693
22719
 
@@ -22699,12 +22725,9 @@ Object.freeze(EMPTY_OBJ);
22699
22725
 
22700
22726
  // packages/qwik/src/core/shared/qrl/qrl.ts
22701
22727
  var inlinedQrl = (symbol, symbolName, lexicalScopeCapture = EMPTY_ARRAY) => {
22702
- return createQRL(null, symbolName, symbol, null, null, lexicalScopeCapture, null);
22728
+ return createQRL(null, symbolName, symbol, null, null, lexicalScopeCapture);
22703
22729
  };
22704
22730
 
22705
- // packages/qwik/src/core/ssr/ssr-render-jsx.ts
22706
- import { isDev as isDev5 } from "@qwik.dev/core/build";
22707
-
22708
22731
  // packages/qwik/src/core/shared/jsx/slot.public.ts
22709
22732
  var Slot = (props) => {
22710
22733
  return _jsxSorted(Virtual, null, { [QSlotS]: "" }, props.children, 0, props.name ?? "");
@@ -22791,19 +22814,62 @@ function isPreventDefault(key) {
22791
22814
  return key.startsWith("preventdefault:");
22792
22815
  }
22793
22816
 
22794
- // packages/qwik/src/core/shared/utils/unitless_number.ts
22795
- var unitlessNumbers = /* @__PURE__ */ new Set([
22796
- "animationIterationCount",
22797
- "aspectRatio",
22798
- "borderImageOutset",
22799
- "borderImageSlice",
22800
- "borderImageWidth",
22801
- "boxFlex",
22802
- "boxFlexGroup",
22803
- "boxOrdinalGroup",
22804
- "columnCount",
22805
- "columns",
22806
- "flex",
22817
+ // packages/qwik/src/core/shared/utils/jsx-filename.ts
22818
+ function getFileLocationFromJsx(jsxDev) {
22819
+ if (!jsxDev) {
22820
+ return null;
22821
+ }
22822
+ const sanitizedFileName = jsxDev.fileName?.replace(/\\/g, "/");
22823
+ if (sanitizedFileName) {
22824
+ return `${sanitizedFileName}:${jsxDev.lineNumber}:${jsxDev.columnNumber}`;
22825
+ }
22826
+ return null;
22827
+ }
22828
+
22829
+ // packages/qwik/src/core/shared/utils/scoped-styles.ts
22830
+ var styleContent = (styleId) => {
22831
+ return ComponentStylesPrefixContent + styleId;
22832
+ };
22833
+ function hasClassAttr(props) {
22834
+ for (const key in props) {
22835
+ if (Object.prototype.hasOwnProperty.call(props, key) && isClassAttr(key)) {
22836
+ return true;
22837
+ }
22838
+ }
22839
+ return false;
22840
+ }
22841
+ function isClassAttr(key) {
22842
+ return key === "class" || key === "className";
22843
+ }
22844
+ function convertScopedStyleIdsToArray(scopedStyleIds) {
22845
+ return scopedStyleIds?.split(" ") ?? null;
22846
+ }
22847
+ function convertStyleIdsToString(scopedStyleIds) {
22848
+ return Array.from(scopedStyleIds).join(" ");
22849
+ }
22850
+ var addComponentStylePrefix = (styleId) => {
22851
+ if (styleId) {
22852
+ let idx = 0;
22853
+ do {
22854
+ styleId = styleId.substring(0, idx) + styleContent(styleId.substring(idx));
22855
+ } while ((idx = styleId.indexOf(" ", idx) + 1) !== 0);
22856
+ }
22857
+ return styleId || null;
22858
+ };
22859
+
22860
+ // packages/qwik/src/core/shared/utils/unitless_number.ts
22861
+ var unitlessNumbers = /* @__PURE__ */ new Set([
22862
+ "animationIterationCount",
22863
+ "aspectRatio",
22864
+ "borderImageOutset",
22865
+ "borderImageSlice",
22866
+ "borderImageWidth",
22867
+ "boxFlex",
22868
+ "boxFlexGroup",
22869
+ "boxOrdinalGroup",
22870
+ "columnCount",
22871
+ "columns",
22872
+ "flex",
22807
22873
  "flexGrow",
22808
22874
  "flexShrink",
22809
22875
  "gridArea",
@@ -22928,37 +22994,6 @@ var setValueForStyle = (styleName, value) => {
22928
22994
  function isAriaAttribute(prop) {
22929
22995
  return prop.startsWith("aria-");
22930
22996
  }
22931
- var styleContent = (styleId) => {
22932
- return ComponentStylesPrefixContent + styleId;
22933
- };
22934
-
22935
- // packages/qwik/src/core/shared/utils/scoped-styles.ts
22936
- function hasClassAttr(props) {
22937
- for (const key in props) {
22938
- if (Object.prototype.hasOwnProperty.call(props, key) && isClassAttr(key)) {
22939
- return true;
22940
- }
22941
- }
22942
- return false;
22943
- }
22944
- function isClassAttr(key) {
22945
- return key === "class" || key === "className";
22946
- }
22947
- function convertScopedStyleIdsToArray(scopedStyleIds) {
22948
- return scopedStyleIds?.split(" ") ?? null;
22949
- }
22950
- function convertStyleIdsToString(scopedStyleIds) {
22951
- return Array.from(scopedStyleIds).join(" ");
22952
- }
22953
- var addComponentStylePrefix = (styleId) => {
22954
- if (styleId) {
22955
- let idx = 0;
22956
- do {
22957
- styleId = styleId.substring(0, idx) + styleContent(styleId.substring(idx));
22958
- } while ((idx = styleId.indexOf(" ", idx) + 1) !== 0);
22959
- }
22960
- return styleId || null;
22961
- };
22962
22997
 
22963
22998
  // packages/qwik/src/core/signal/store.ts
22964
22999
  var DEBUG = false;
@@ -23094,8 +23129,12 @@ var StoreHandler = class {
23094
23129
  return Reflect.ownKeys(target);
23095
23130
  }
23096
23131
  getOwnPropertyDescriptor(target, prop) {
23132
+ const descriptor = Reflect.getOwnPropertyDescriptor(target, prop);
23097
23133
  if (Array.isArray(target) || typeof prop === "symbol") {
23098
- return Object.getOwnPropertyDescriptor(target, prop);
23134
+ return descriptor;
23135
+ }
23136
+ if (descriptor && !descriptor.configurable) {
23137
+ return descriptor;
23099
23138
  }
23100
23139
  return {
23101
23140
  enumerable: true,
@@ -23103,17 +23142,17 @@ var StoreHandler = class {
23103
23142
  };
23104
23143
  }
23105
23144
  };
23106
- function addEffect(target, prop, store, effectSubscriber) {
23107
- const effectsMap = store.$effects$ || (store.$effects$ = {});
23108
- const effects = Object.prototype.hasOwnProperty.call(effectsMap, prop) && effectsMap[prop] || (effectsMap[prop] = []);
23109
- ensureContainsEffect(effects, effectSubscriber);
23110
- ensureContains(effectSubscriber, target);
23111
- ensureEffectContainsSubscriber(
23112
- effectSubscriber[0 /* EFFECT */],
23113
- target,
23114
- store.$container$
23115
- );
23116
- DEBUG && log("sub", pad("\n" + store.$effects$.toString(), " "));
23145
+ function addEffect(target, prop, store, effectSubscription) {
23146
+ const effectsMap = store.$effects$ || (store.$effects$ = /* @__PURE__ */ new Map());
23147
+ let effects = effectsMap.get(prop);
23148
+ if (!effects) {
23149
+ effects = /* @__PURE__ */ new Set();
23150
+ effectsMap.set(prop, effects);
23151
+ }
23152
+ ensureContainsSubscription(effects, effectSubscription);
23153
+ ensureContainsBackRef(effectSubscription, target);
23154
+ addQrlToSerializationCtx(effectSubscription, store.$container$);
23155
+ DEBUG && log("sub", pad("\n" + store.$effects$?.entries.toString(), " "));
23117
23156
  }
23118
23157
  function setNewValueAndTriggerEffects(prop, value, target, currentStore) {
23119
23158
  target[prop] = value;
@@ -23124,15 +23163,91 @@ function setNewValueAndTriggerEffects(prop, value, target, currentStore) {
23124
23163
  );
23125
23164
  }
23126
23165
  function getEffects(target, prop, storeEffects) {
23127
- let effectsToTrigger = storeEffects ? Array.isArray(target) ? Object.values(storeEffects).flatMap((effects) => effects) : storeEffects[prop] : null;
23128
- const storeArrayValue = storeEffects?.[STORE_ARRAY_PROP];
23166
+ let effectsToTrigger;
23167
+ if (storeEffects) {
23168
+ if (Array.isArray(target)) {
23169
+ for (const effects of storeEffects.values()) {
23170
+ effectsToTrigger || (effectsToTrigger = /* @__PURE__ */ new Set());
23171
+ for (const effect of effects) {
23172
+ effectsToTrigger.add(effect);
23173
+ }
23174
+ }
23175
+ } else {
23176
+ effectsToTrigger = storeEffects.get(prop);
23177
+ }
23178
+ }
23179
+ const storeArrayValue = storeEffects?.get(STORE_ARRAY_PROP);
23129
23180
  if (storeArrayValue) {
23130
- effectsToTrigger || (effectsToTrigger = []);
23131
- effectsToTrigger.push(...storeArrayValue);
23181
+ effectsToTrigger || (effectsToTrigger = /* @__PURE__ */ new Set());
23182
+ for (const effect of storeArrayValue) {
23183
+ effectsToTrigger.add(effect);
23184
+ }
23185
+ }
23186
+ return effectsToTrigger || null;
23187
+ }
23188
+
23189
+ // packages/qwik/src/core/signal/flags.ts
23190
+ var NEEDS_COMPUTATION = Symbol("invalid");
23191
+ var _EFFECT_BACK_REF = Symbol("backRef");
23192
+
23193
+ // packages/qwik/src/core/signal/signal-cleanup.ts
23194
+ var _a;
23195
+ _a = _EFFECT_BACK_REF;
23196
+ var BackRef = class {
23197
+ constructor() {
23198
+ __publicField(this, _a, null);
23199
+ }
23200
+ };
23201
+ function clearAllEffects(container, consumer) {
23202
+ if (vnode_isVNode(consumer) && vnode_isElementVNode(consumer)) {
23203
+ ensureMaterialized(consumer);
23204
+ }
23205
+ const effects = consumer[_EFFECT_BACK_REF];
23206
+ if (!effects) {
23207
+ return;
23208
+ }
23209
+ for (const [, effect] of effects) {
23210
+ const backRefs = effect[2 /* BACK_REF */];
23211
+ if (!backRefs) {
23212
+ return;
23213
+ }
23214
+ for (const producer of backRefs) {
23215
+ if (producer instanceof Signal) {
23216
+ clearSignal(container, producer, effect);
23217
+ } else if (container.$storeProxyMap$.has(producer)) {
23218
+ const target = container.$storeProxyMap$.get(producer);
23219
+ const storeHandler = getStoreHandler(target);
23220
+ clearStore(storeHandler, effect);
23221
+ }
23222
+ }
23223
+ }
23224
+ }
23225
+ function clearSignal(container, producer, effect) {
23226
+ const effects = producer.$effects$;
23227
+ if (effects) {
23228
+ effects.delete(effect);
23229
+ }
23230
+ if (producer instanceof WrappedSignal) {
23231
+ producer.$hostElement$ = null;
23232
+ clearAllEffects(container, producer);
23233
+ }
23234
+ }
23235
+ function clearStore(producer, effect) {
23236
+ const effects = producer?.$effects$;
23237
+ if (effects) {
23238
+ for (const propEffects of effects.values()) {
23239
+ propEffects.delete(effect);
23240
+ }
23132
23241
  }
23133
- return effectsToTrigger;
23134
23242
  }
23135
23243
 
23244
+ // packages/qwik/src/core/shared/qrl/implicit_dollar.ts
23245
+ var implicit$FirstArg = (fn) => {
23246
+ return function(first, ...rest) {
23247
+ return fn.call(null, dollar(first), ...rest);
23248
+ };
23249
+ };
23250
+
23136
23251
  // packages/qwik/src/core/use/use-sequential-scope.ts
23137
23252
  var useSequentialScope = () => {
23138
23253
  const iCtx = useInvokeContext();
@@ -23165,162 +23280,41 @@ var useSequentialScope = () => {
23165
23280
  };
23166
23281
  };
23167
23282
 
23168
- // packages/qwik/src/core/signal/signal-subscriber.ts
23169
- var Subscriber = class {
23170
- constructor() {
23171
- __publicField(this, "$effectDependencies$", null);
23172
- }
23173
- };
23174
- function isSubscriber(value) {
23175
- return value instanceof Subscriber || value instanceof WrappedSignal;
23176
- }
23177
- function clearVNodeEffectDependencies(container, value) {
23178
- if (vnode_isElementVNode(value)) {
23179
- ensureMaterialized(value);
23180
- }
23181
- const effects = vnode_getProp(value, QSubscribers, container.$getObjectById$);
23182
- if (!effects) {
23183
- return;
23184
- }
23185
- for (let i = effects.length - 1; i >= 0; i--) {
23186
- const subscriber = effects[i];
23187
- clearEffects(subscriber, value, effects, i, container);
23188
- }
23189
- if (effects.length === 0) {
23190
- vnode_setProp(value, QSubscribers, null);
23191
- }
23192
- }
23193
- function clearSubscriberEffectDependencies(container, value) {
23194
- if (value.$effectDependencies$) {
23195
- for (let i = value.$effectDependencies$.length - 1; i >= 0; i--) {
23196
- const subscriber = value.$effectDependencies$[i];
23197
- clearEffects(subscriber, value, value.$effectDependencies$, i, container);
23198
- }
23199
- if (value.$effectDependencies$.length === 0) {
23200
- value.$effectDependencies$ = null;
23201
- }
23202
- }
23203
- }
23204
- function clearEffects(subscriber, value, effectArray, indexToRemove, container) {
23205
- let subscriptionRemoved = false;
23206
- const seenSet = /* @__PURE__ */ new Set();
23207
- if (subscriber instanceof WrappedSignal) {
23208
- subscriptionRemoved = clearSignalEffects(subscriber, value, seenSet);
23209
- } else if (container.$storeProxyMap$.has(subscriber)) {
23210
- const store = container.$storeProxyMap$.get(subscriber);
23211
- const handler = getStoreHandler(store);
23212
- subscriptionRemoved = clearStoreEffects(handler, value);
23213
- }
23214
- if (subscriptionRemoved) {
23215
- effectArray.splice(indexToRemove, 1);
23216
- }
23217
- }
23218
- function clearSignalEffects(subscriber, value, seenSet) {
23219
- const effectSubscriptions = subscriber.$effects$;
23220
- let subscriptionRemoved = false;
23221
- if (effectSubscriptions) {
23222
- for (let i = effectSubscriptions.length - 1; i >= 0; i--) {
23223
- const effect = effectSubscriptions[i];
23224
- if (effect[0 /* EFFECT */] === value) {
23225
- effectSubscriptions.splice(i, 1);
23226
- subscriptionRemoved = true;
23227
- }
23228
- }
23229
- }
23230
- if (subscriber instanceof WrappedSignal) {
23231
- const hostElement = subscriber.$hostElement$;
23232
- if (hostElement && hostElement === value) {
23233
- subscriber.$hostElement$ = null;
23234
- }
23235
- const args = subscriber.$args$;
23236
- if (args) {
23237
- clearArgsEffects(args, subscriber, seenSet);
23283
+ // packages/qwik/src/core/signal/subscriber.ts
23284
+ import { isServer as isServer3 } from "@qwik.dev/core/build";
23285
+ function getSubscriber(effect, prop, data) {
23286
+ if (!effect[_EFFECT_BACK_REF]) {
23287
+ if (isServer3 && isSsrNode(effect)) {
23288
+ effect.setProp(QBackRefs, /* @__PURE__ */ new Map());
23289
+ } else {
23290
+ effect[_EFFECT_BACK_REF] = /* @__PURE__ */ new Map();
23238
23291
  }
23239
23292
  }
23240
- return subscriptionRemoved;
23241
- }
23242
- function clearStoreEffects(storeHandler, value) {
23243
- const effectSubscriptions = storeHandler.$effects$;
23244
- if (!effectSubscriptions) {
23245
- return false;
23246
- }
23247
- let subscriptionRemoved = false;
23248
- for (const key in effectSubscriptions) {
23249
- const effects = effectSubscriptions[key];
23250
- for (let i = effects.length - 1; i >= 0; i--) {
23251
- const effect = effects[i];
23252
- if (effect[0 /* EFFECT */] === value) {
23253
- effects.splice(i, 1);
23254
- subscriptionRemoved = true;
23255
- }
23256
- }
23257
- if (effects.length === 0) {
23258
- delete effectSubscriptions[key];
23259
- }
23293
+ const subMap = effect[_EFFECT_BACK_REF];
23294
+ let sub = subMap.get(prop);
23295
+ if (!sub) {
23296
+ sub = [effect, prop];
23297
+ subMap.set(prop, sub);
23260
23298
  }
23261
- return subscriptionRemoved;
23262
- }
23263
- function clearArgsEffects(args, subscriber, seenSet) {
23264
- for (let i = args.length - 1; i >= 0; i--) {
23265
- const arg = args[i];
23266
- clearArgEffect(arg, subscriber, seenSet);
23299
+ if (data) {
23300
+ sub[3 /* DATA */] = data;
23267
23301
  }
23302
+ return sub;
23268
23303
  }
23269
- function clearArgEffect(arg, subscriber, seenSet) {
23270
- if (seenSet.has(arg)) {
23271
- return;
23272
- }
23273
- seenSet.add(arg);
23274
- if (isSignal(arg)) {
23275
- clearSignalEffects(arg, subscriber, seenSet);
23276
- } else if (typeof arg === "object" && arg !== null) {
23277
- if (isStore(arg)) {
23278
- clearStoreEffects(getStoreHandler(arg), subscriber);
23279
- } else {
23280
- for (const key in arg) {
23281
- clearArgEffect(arg[key], subscriber, seenSet);
23282
- }
23283
- }
23284
- } else if (Array.isArray(arg)) {
23285
- clearArgsEffects(arg, subscriber, seenSet);
23286
- } else {
23287
- }
23304
+ function isSsrNode(value) {
23305
+ return "__brand__" in value && "currentComponentNode" in value;
23288
23306
  }
23289
23307
 
23290
- // packages/qwik/src/core/use/use-resource.ts
23291
- var _createResourceReturn = (opts) => {
23292
- const resource = {
23293
- __brand: "resource",
23294
- value: void 0,
23295
- loading: isServerPlatform() ? false : true,
23296
- _resolved: void 0,
23297
- _error: void 0,
23298
- _state: "pending",
23299
- _timeout: opts?.timeout ?? -1,
23300
- _cache: 0
23301
- };
23302
- return resource;
23303
- };
23304
- var createResourceReturn = (container, opts, initialPromise) => {
23305
- const result = _createResourceReturn(opts);
23306
- result.value = initialPromise;
23307
- return createStore(container, result, 1 /* RECURSIVE */);
23308
- };
23309
- var runResource = (task, container, host) => {
23308
+ // packages/qwik/src/core/use/use-task.ts
23309
+ var runTask = (task, container, host) => {
23310
23310
  task.$flags$ &= ~8 /* DIRTY */;
23311
23311
  cleanupTask(task);
23312
- const iCtx = newInvokeContext(container.$locale$, host, void 0, ResourceEvent);
23312
+ const iCtx = newInvokeContext(container.$locale$, host, void 0, TaskEvent);
23313
23313
  iCtx.$container$ = container;
23314
- const taskFn = task.$qrl$.getFn(iCtx, () => clearSubscriberEffectDependencies(container, task));
23315
- const resource = task.$state$;
23316
- assertDefined(
23317
- resource,
23318
- 'useResource: when running a resource, "task.resource" must be a defined.',
23319
- task
23320
- );
23314
+ const taskFn = task.$qrl$.getFn(iCtx, () => clearAllEffects(container, task));
23321
23315
  const track = (obj, prop) => {
23322
23316
  const ctx = newInvokeContext();
23323
- ctx.$effectSubscriber$ = [task, ":" /* COMPONENT */];
23317
+ ctx.$effectSubscriber$ = getSubscriber(task, ":" /* COMPONENT */);
23324
23318
  ctx.$container$ = container;
23325
23319
  return invoke(ctx, () => {
23326
23320
  if (isFunction(obj)) {
@@ -23331,127 +23325,143 @@ var runResource = (task, container, host) => {
23331
23325
  } else if (isSignal(obj)) {
23332
23326
  return obj.value;
23333
23327
  } else {
23334
- return obj;
23328
+ throw qError(2 /* trackObjectWithoutProp */);
23335
23329
  }
23336
23330
  });
23337
23331
  };
23338
23332
  const handleError = (reason) => container.handleError(reason, host);
23339
- const cleanups = [];
23340
- task.$destroy$ = noSerialize(() => {
23341
- cleanups.forEach((fn) => {
23342
- try {
23343
- fn();
23344
- } catch (err) {
23345
- handleError(err);
23346
- }
23347
- });
23348
- done = true;
23349
- });
23350
- const resourceTarget = unwrapStore(resource);
23351
- const opts = {
23352
- track,
23353
- cleanup(fn) {
23354
- if (typeof fn === "function") {
23355
- cleanups.push(fn);
23333
+ let cleanupFns = null;
23334
+ const cleanup2 = (fn) => {
23335
+ if (typeof fn == "function") {
23336
+ if (!cleanupFns) {
23337
+ cleanupFns = [];
23338
+ task.$destroy$ = noSerialize(() => {
23339
+ task.$destroy$ = null;
23340
+ cleanupFns.forEach((fn2) => {
23341
+ try {
23342
+ fn2();
23343
+ } catch (err) {
23344
+ handleError(err);
23345
+ }
23346
+ });
23347
+ });
23356
23348
  }
23357
- },
23358
- cache(policy) {
23359
- let milliseconds = 0;
23360
- if (policy === "immutable") {
23361
- milliseconds = Infinity;
23349
+ cleanupFns.push(fn);
23350
+ }
23351
+ };
23352
+ const taskApi = { track, cleanup: cleanup2 };
23353
+ const result = safeCall(
23354
+ () => taskFn(taskApi),
23355
+ cleanup2,
23356
+ (err) => {
23357
+ if (isPromise(err)) {
23358
+ return err.then(() => runTask(task, container, host));
23362
23359
  } else {
23363
- milliseconds = policy;
23364
- }
23365
- resource._cache = milliseconds;
23366
- },
23367
- previous: resourceTarget._resolved
23368
- };
23369
- let resolve;
23370
- let reject;
23371
- let done = false;
23372
- const setState = (resolved, value) => {
23373
- if (!done) {
23374
- done = true;
23375
- if (resolved) {
23376
- done = true;
23377
- resource.loading = false;
23378
- resource._state = "resolved";
23379
- resource._resolved = value;
23380
- resource._error = void 0;
23381
- resolve(value);
23382
- } else {
23383
- done = true;
23384
- resource.loading = false;
23385
- resource._state = "rejected";
23386
- resource._error = value;
23387
- reject(value);
23388
- }
23389
- return true;
23390
- }
23391
- return false;
23392
- };
23393
- cleanups.push(() => {
23394
- if (untrack(() => resource.loading) === true) {
23395
- const value = untrack(() => resource._resolved);
23396
- setState(true, value);
23397
- }
23398
- });
23399
- invoke(iCtx, () => {
23400
- resource._state = "pending";
23401
- resource.loading = !isServerPlatform();
23402
- const promise2 = resource.value = new Promise((r, re) => {
23403
- resolve = r;
23404
- reject = re;
23405
- });
23406
- promise2.catch(ignoreErrorToPreventNodeFromCrashing);
23407
- });
23408
- const promise = safeCall(
23409
- () => Promise.resolve(taskFn(opts)),
23410
- (value) => {
23411
- setState(true, value);
23412
- },
23413
- (err) => {
23414
- if (isPromise(err)) {
23415
- return err.then(() => runResource(task, container, host));
23416
- } else {
23417
- setState(false, err);
23360
+ throw err;
23418
23361
  }
23419
23362
  }
23420
23363
  );
23421
- const timeout = resourceTarget._timeout;
23422
- if (timeout > 0) {
23423
- return Promise.race([
23424
- promise,
23425
- delay(timeout).then(() => {
23426
- if (setState(false, new Error("timeout"))) {
23427
- cleanupTask(task);
23428
- }
23429
- })
23430
- ]);
23364
+ return result;
23365
+ };
23366
+ var cleanupTask = (task) => {
23367
+ const destroy = task.$destroy$;
23368
+ if (destroy) {
23369
+ task.$destroy$ = null;
23370
+ try {
23371
+ destroy();
23372
+ } catch (err) {
23373
+ logError(err);
23374
+ }
23431
23375
  }
23432
- return promise;
23433
23376
  };
23434
- var ignoreErrorToPreventNodeFromCrashing = (err) => {
23377
+ var Task = class extends BackRef {
23378
+ constructor($flags$, $index$, $el$, $qrl$, $state$, $destroy$) {
23379
+ super();
23380
+ this.$flags$ = $flags$;
23381
+ this.$index$ = $index$;
23382
+ this.$el$ = $el$;
23383
+ this.$qrl$ = $qrl$;
23384
+ this.$state$ = $state$;
23385
+ this.$destroy$ = $destroy$;
23386
+ }
23387
+ };
23388
+ var isTask = (value) => {
23389
+ return value instanceof Task;
23435
23390
  };
23436
23391
 
23437
23392
  // packages/qwik/src/core/client/vnode-diff.ts
23438
- import { isDev as isDev4 } from "@qwik.dev/core/build";
23393
+ import { isDev as isDev6 } from "@qwik.dev/core/build";
23394
+
23395
+ // packages/qwik/src/core/client/util-mapArray.ts
23396
+ var mapApp_findIndx = (elementVNode, key, start) => {
23397
+ assertTrue(start % 2 === 0, "Expecting even number.");
23398
+ let bottom = start >> 1;
23399
+ let top = elementVNode.length - 2 >> 1;
23400
+ while (bottom <= top) {
23401
+ const mid = bottom + (top - bottom >> 1);
23402
+ const midKey = elementVNode[mid << 1];
23403
+ if (midKey === key) {
23404
+ return mid << 1;
23405
+ }
23406
+ if (midKey < key) {
23407
+ bottom = mid + 1;
23408
+ } else {
23409
+ top = mid - 1;
23410
+ }
23411
+ }
23412
+ return bottom << 1 ^ -1;
23413
+ };
23414
+ var mapArray_set = (elementVNode, key, value, start) => {
23415
+ const indx = mapApp_findIndx(elementVNode, key, start);
23416
+ if (indx >= 0) {
23417
+ if (value == null) {
23418
+ elementVNode.splice(indx, 2);
23419
+ } else {
23420
+ elementVNode[indx + 1] = value;
23421
+ }
23422
+ } else if (value != null) {
23423
+ elementVNode.splice(indx ^ -1, 0, key, value);
23424
+ }
23425
+ };
23426
+ var mapApp_remove = (elementVNode, key, start) => {
23427
+ const indx = mapApp_findIndx(elementVNode, key, start);
23428
+ let value = null;
23429
+ if (indx >= 0) {
23430
+ value = elementVNode[indx + 1];
23431
+ elementVNode.splice(indx, 2);
23432
+ return value;
23433
+ }
23434
+ return value;
23435
+ };
23436
+ var mapArray_get = (elementVNode, key, start) => {
23437
+ const indx = mapApp_findIndx(elementVNode, key, start);
23438
+ if (indx >= 0) {
23439
+ return elementVNode[indx + 1];
23440
+ } else {
23441
+ return null;
23442
+ }
23443
+ };
23439
23444
 
23440
23445
  // packages/qwik/src/core/client/vnode-namespace.ts
23441
- var isForeignObjectElement = (elementName) => elementName.toLowerCase() === "foreignobject";
23446
+ import { isDev as isDev4 } from "@qwik.dev/core/build";
23447
+ var isForeignObjectElement = (elementName) => {
23448
+ return isDev4 ? elementName.toLowerCase() === "foreignobject" : elementName === "foreignObject";
23449
+ };
23442
23450
  var isSvgElement = (elementName) => elementName === "svg" || isForeignObjectElement(elementName);
23443
23451
  var isMathElement = (elementName) => elementName === "math";
23444
23452
  var vnode_isDefaultNamespace = (vnode) => {
23445
23453
  const flags = vnode[0 /* flags */];
23446
23454
  return (flags & 192 /* NAMESPACE_MASK */) === 0;
23447
23455
  };
23448
- var vnode_getElementNamespaceFlags = (elementName) => {
23449
- if (isSvgElement(elementName)) {
23450
- return 64 /* NS_svg */;
23451
- } else if (isMathElement(elementName)) {
23452
- return 128 /* NS_math */;
23453
- } else {
23454
- return 0 /* NS_html */;
23456
+ var vnode_getElementNamespaceFlags = (element) => {
23457
+ const namespace = fastNamespaceURI(element);
23458
+ switch (namespace) {
23459
+ case SVG_NS:
23460
+ return 64 /* NS_svg */;
23461
+ case MATH_NS:
23462
+ return 128 /* NS_math */;
23463
+ default:
23464
+ return 0 /* NS_html */;
23455
23465
  }
23456
23466
  };
23457
23467
  function vnode_getDomChildrenWithCorrectNamespacesToInsert(journal, domParentVNode, newChild) {
@@ -23607,21 +23617,28 @@ function getNewElementNamespaceData(domParentVNode, tagOrVNode) {
23607
23617
  }
23608
23618
 
23609
23619
  // packages/qwik/src/core/shared/component-execution.ts
23610
- import { isDev as isDev3 } from "@qwik.dev/core/build";
23620
+ import { isDev as isDev5 } from "@qwik.dev/core/build";
23611
23621
  var executeComponent = (container, renderHost, subscriptionHost, componentQRL, props) => {
23612
- const iCtx = newInvokeContext(container.$locale$, subscriptionHost, void 0, RenderEvent);
23613
- iCtx.$effectSubscriber$ = [subscriptionHost, ":" /* COMPONENT */];
23614
- iCtx.$container$ = container;
23622
+ const iCtx = newInvokeContext(
23623
+ container.$locale$,
23624
+ subscriptionHost || void 0,
23625
+ void 0,
23626
+ RenderEvent
23627
+ );
23628
+ if (subscriptionHost) {
23629
+ iCtx.$effectSubscriber$ = getSubscriber(subscriptionHost, ":" /* COMPONENT */);
23630
+ iCtx.$container$ = container;
23631
+ }
23615
23632
  let componentFn;
23616
23633
  container.ensureProjectionResolved(renderHost);
23617
23634
  let isInlineComponent = false;
23618
23635
  if (componentQRL === null) {
23619
- componentQRL = componentQRL || container.getHostProp(renderHost, OnRenderProp);
23636
+ componentQRL = container.getHostProp(renderHost, OnRenderProp);
23620
23637
  assertDefined(componentQRL, "No Component found at this location");
23621
23638
  }
23622
- if (isQrl2(componentQRL)) {
23639
+ if (isQrl(componentQRL)) {
23623
23640
  props = props || container.getHostProp(renderHost, ELEMENT_PROPS) || EMPTY_OBJ;
23624
- if (props && props.children) {
23641
+ if (props.children) {
23625
23642
  delete props.children;
23626
23643
  }
23627
23644
  componentFn = componentQRL.getFn(iCtx);
@@ -23638,19 +23655,17 @@ var executeComponent = (container, renderHost, subscriptionHost, componentQRL, p
23638
23655
  if (!isInlineComponent) {
23639
23656
  container.setHostProp(renderHost, ELEMENT_SEQ_IDX, null);
23640
23657
  container.setHostProp(renderHost, USE_ON_LOCAL_SEQ_IDX, null);
23641
- if (container.getHostProp(renderHost, ELEMENT_PROPS) !== props) {
23642
- container.setHostProp(renderHost, ELEMENT_PROPS, props);
23643
- }
23658
+ container.setHostProp(renderHost, ELEMENT_PROPS, props);
23644
23659
  }
23645
23660
  if (vnode_isVNode(renderHost)) {
23646
- clearVNodeEffectDependencies(container, renderHost);
23661
+ clearAllEffects(container, renderHost);
23647
23662
  }
23648
23663
  return componentFn(props);
23649
23664
  },
23650
23665
  (jsx4) => {
23651
23666
  const useOnEvents = container.getHostProp(renderHost, USE_ON_LOCAL);
23652
23667
  if (useOnEvents) {
23653
- return maybeThen(addUseOnEvents(jsx4, useOnEvents), () => jsx4);
23668
+ return addUseOnEvents(jsx4, useOnEvents);
23654
23669
  }
23655
23670
  return jsx4;
23656
23671
  },
@@ -23668,6 +23683,7 @@ var executeComponent = (container, renderHost, subscriptionHost, componentQRL, p
23668
23683
  };
23669
23684
  function addUseOnEvents(jsx4, useOnEvents) {
23670
23685
  const jsxElement = findFirstStringJSX(jsx4);
23686
+ let jsxResult = jsx4;
23671
23687
  return maybeThen(jsxElement, (jsxElement2) => {
23672
23688
  let isInvisibleComponent = false;
23673
23689
  if (!jsxElement2) {
@@ -23677,16 +23693,18 @@ function addUseOnEvents(jsx4, useOnEvents) {
23677
23693
  if (Object.prototype.hasOwnProperty.call(useOnEvents, key)) {
23678
23694
  if (isInvisibleComponent) {
23679
23695
  if (key === "onQvisible$") {
23680
- jsxElement2 = addScriptNodeForInvisibleComponents(jsx4);
23681
- if (jsxElement2) {
23682
- addUseOnEvent(jsxElement2, "document:onQinit$", useOnEvents[key]);
23696
+ const [jsxElement3, jsx5] = addScriptNodeForInvisibleComponents(jsxResult);
23697
+ jsxResult = jsx5;
23698
+ if (jsxElement3) {
23699
+ addUseOnEvent(jsxElement3, "document:onQinit$", useOnEvents[key]);
23683
23700
  }
23684
23701
  } else if (key.startsWith("document:") || key.startsWith("window:")) {
23685
- jsxElement2 = addScriptNodeForInvisibleComponents(jsx4);
23686
- if (jsxElement2) {
23687
- addUseOnEvent(jsxElement2, key, useOnEvents[key]);
23702
+ const [jsxElement3, jsx5] = addScriptNodeForInvisibleComponents(jsxResult);
23703
+ jsxResult = jsx5;
23704
+ if (jsxElement3) {
23705
+ addUseOnEvent(jsxElement3, key, useOnEvents[key]);
23688
23706
  }
23689
- } else if (isDev3) {
23707
+ } else if (isDev5) {
23690
23708
  logWarn(
23691
23709
  'You are trying to add an event "' + key + '" using `useOn` hook, but a node to which you can add an event is not found. Please make sure that the component has a valid element node. '
23692
23710
  );
@@ -23696,7 +23714,7 @@ function addUseOnEvents(jsx4, useOnEvents) {
23696
23714
  }
23697
23715
  }
23698
23716
  }
23699
- return jsxElement2;
23717
+ return jsxResult;
23700
23718
  });
23701
23719
  }
23702
23720
  function addUseOnEvent(jsxElement, key, value) {
@@ -23747,6 +23765,9 @@ function addScriptNodeForInvisibleComponents(jsx4) {
23747
23765
  null,
23748
23766
  3
23749
23767
  );
23768
+ if (jsx4.type === Slot) {
23769
+ return [jsxElement, _jsxSorted(Fragment, null, null, [jsx4, jsxElement], 0, null)];
23770
+ }
23750
23771
  if (jsx4.children == null) {
23751
23772
  jsx4.children = jsxElement;
23752
23773
  } else if (Array.isArray(jsx4.children)) {
@@ -23754,13 +23775,19 @@ function addScriptNodeForInvisibleComponents(jsx4) {
23754
23775
  } else {
23755
23776
  jsx4.children = [jsx4.children, jsxElement];
23756
23777
  }
23757
- return jsxElement;
23778
+ return [jsxElement, jsx4];
23758
23779
  } else if (Array.isArray(jsx4) && jsx4.length) {
23759
- return addScriptNodeForInvisibleComponents(jsx4[0]);
23780
+ const [jsxElement, _] = addScriptNodeForInvisibleComponents(jsx4[0]);
23781
+ return [jsxElement, jsx4];
23760
23782
  }
23761
- return null;
23783
+ return [null, null];
23762
23784
  }
23763
23785
 
23786
+ // packages/qwik/src/core/shared/utils/constants.ts
23787
+ var _CONST_PROPS = Symbol("CONST");
23788
+ var _VAR_PROPS = Symbol("VAR");
23789
+ var _IMMUTABLE = Symbol("IMMUTABLE");
23790
+
23764
23791
  // packages/qwik/src/core/shared/utils/prop.ts
23765
23792
  function isSlotProp(prop) {
23766
23793
  return !prop.startsWith("q:") && !prop.startsWith(NON_SERIALIZABLE_MARKER_PREFIX);
@@ -23799,18 +23826,6 @@ function escapeHTML(html) {
23799
23826
  }
23800
23827
  }
23801
23828
 
23802
- // packages/qwik/src/core/shared/utils/jsx-filename.ts
23803
- function getFileLocationFromJsx(jsxDev) {
23804
- if (!jsxDev) {
23805
- return null;
23806
- }
23807
- const sanitizedFileName = jsxDev.fileName?.replace(/\\/g, "/");
23808
- if (sanitizedFileName) {
23809
- return `${sanitizedFileName}:${jsxDev.lineNumber}:${jsxDev.columnNumber}`;
23810
- }
23811
- return null;
23812
- }
23813
-
23814
23829
  // packages/qwik/src/core/client/vnode-diff.ts
23815
23830
  var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
23816
23831
  let journal = container.$journal$;
@@ -23847,7 +23862,7 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
23847
23862
  descend(jsxValue, false);
23848
23863
  } else if (isSignal(jsxValue)) {
23849
23864
  if (vCurrent) {
23850
- clearVNodeEffectDependencies(container, vCurrent);
23865
+ clearAllEffects(container, vCurrent);
23851
23866
  }
23852
23867
  expectVirtual("S" /* WrappedSignal */, null);
23853
23868
  descend(
@@ -24004,8 +24019,9 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
24004
24019
  };
24005
24020
  const projections = [];
24006
24021
  if (host) {
24007
- for (let i = vnode_getPropStartIndex(host); i < host.length; i = i + 2) {
24008
- const prop = host[i];
24022
+ const props = vnode_getProps(host);
24023
+ for (let i = 0; i < props.length; i = i + 2) {
24024
+ const prop = props[i];
24009
24025
  if (isSlotProp(prop)) {
24010
24026
  const slotName = prop;
24011
24027
  projections.push(slotName);
@@ -24049,8 +24065,8 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
24049
24065
  );
24050
24066
  if (vCurrent == null) {
24051
24067
  vNewNode = vnode_newVirtual();
24052
- isDev4 && vnode_setProp(vNewNode, DEBUG_TYPE, "P" /* Projection */);
24053
- isDev4 && vnode_setProp(vNewNode, "q:code", "expectProjection");
24068
+ isDev6 && vnode_setProp(vNewNode, DEBUG_TYPE, "P" /* Projection */);
24069
+ isDev6 && vnode_setProp(vNewNode, "q:code", "expectProjection");
24054
24070
  vnode_setProp(vNewNode, QSlot, slotName);
24055
24071
  vnode_setProp(vNewNode, QSlotParent, vParent);
24056
24072
  vnode_setProp(vParent, slotName, vNewNode);
@@ -24076,8 +24092,8 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
24076
24092
  );
24077
24093
  vnode_setProp(vNewNode, QSlot, slotNameKey);
24078
24094
  vHost && vnode_setProp(vHost, slotNameKey, vNewNode);
24079
- isDev4 && vnode_setProp(vNewNode, DEBUG_TYPE, "P" /* Projection */);
24080
- isDev4 && vnode_setProp(vNewNode, "q:code", "expectSlot" + count++);
24095
+ isDev6 && vnode_setProp(vNewNode, DEBUG_TYPE, "P" /* Projection */);
24096
+ isDev6 && vnode_setProp(vNewNode, "q:code", "expectSlot" + count++);
24081
24097
  return false;
24082
24098
  } else if (vProjectedNode === vCurrent) {
24083
24099
  } else {
@@ -24089,8 +24105,8 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
24089
24105
  );
24090
24106
  vnode_setProp(vNewNode, QSlot, slotNameKey);
24091
24107
  vHost && vnode_setProp(vHost, slotNameKey, vNewNode);
24092
- isDev4 && vnode_setProp(vNewNode, DEBUG_TYPE, "P" /* Projection */);
24093
- isDev4 && vnode_setProp(vNewNode, "q:code", "expectSlot" + count++);
24108
+ isDev6 && vnode_setProp(vNewNode, DEBUG_TYPE, "P" /* Projection */);
24109
+ isDev6 && vnode_setProp(vNewNode, "q:code", "expectSlot" + count++);
24094
24110
  }
24095
24111
  return true;
24096
24112
  }
@@ -24161,14 +24177,20 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
24161
24177
  if (isJsxPropertyAnEventName(key2)) {
24162
24178
  const eventName = getEventNameFromJsxProp(key2);
24163
24179
  const scope = getEventNameScopeFromJsxProp(key2);
24164
- vnode_setProp(
24165
- vNewNode,
24166
- HANDLER_PREFIX + ":" + scope + ":" + eventName,
24167
- value
24168
- );
24169
24180
  if (eventName) {
24181
+ vnode_setProp(
24182
+ vNewNode,
24183
+ HANDLER_PREFIX + ":" + scope + ":" + eventName,
24184
+ value
24185
+ );
24170
24186
  registerQwikLoaderEvent(eventName);
24171
24187
  }
24188
+ if (scope) {
24189
+ const htmlEvent = convertEventNameFromJsxPropToHtmlAttr(key2);
24190
+ if (htmlEvent) {
24191
+ vnode_setAttr(journal, vNewNode, htmlEvent, "");
24192
+ }
24193
+ }
24172
24194
  needsQDispatchEventPatch = true;
24173
24195
  continue;
24174
24196
  }
@@ -24179,12 +24201,14 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
24179
24201
  } else if (typeof value === "function") {
24180
24202
  value(element);
24181
24203
  continue;
24204
+ } else if (value == null) {
24205
+ continue;
24182
24206
  } else {
24183
24207
  throw qError(32 /* invalidRefValue */, [currentFile]);
24184
24208
  }
24185
24209
  }
24186
24210
  if (isSignal(value)) {
24187
- const signalData = new EffectPropData({
24211
+ const signalData = new SubscriptionData({
24188
24212
  $scopedStyleIdPrefix$: scopedStyleIdPrefix,
24189
24213
  $isConst$: true
24190
24214
  });
@@ -24203,7 +24227,7 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
24203
24227
  }
24204
24228
  if (elementName === "textarea" && key2 === "value") {
24205
24229
  if (value && typeof value !== "string") {
24206
- if (isDev4) {
24230
+ if (isDev6) {
24207
24231
  throw qError(40 /* wrongTextareaValue */, [currentFile, value]);
24208
24232
  }
24209
24233
  continue;
@@ -24284,7 +24308,12 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
24284
24308
  let returnValue = false;
24285
24309
  qrls.flat(2).forEach((qrl2) => {
24286
24310
  if (qrl2) {
24287
- const value = qrl2(event, element);
24311
+ const value = container.$scheduler$(
24312
+ 2 /* RUN_QRL */,
24313
+ vNode,
24314
+ qrl2,
24315
+ [event, element]
24316
+ );
24288
24317
  returnValue = returnValue || value === true;
24289
24318
  }
24290
24319
  });
@@ -24295,10 +24324,10 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
24295
24324
  }
24296
24325
  function setBulkProps(vnode, srcAttrs, currentFile) {
24297
24326
  vnode_ensureElementInflated(vnode);
24298
- const dstAttrs = vnode;
24327
+ const dstAttrs = vnode_getProps(vnode);
24299
24328
  let srcIdx = 0;
24300
24329
  const srcLength = srcAttrs.length;
24301
- let dstIdx = 8 /* PROPS_OFFSET */;
24330
+ let dstIdx = 0;
24302
24331
  let dstLength = dstAttrs.length;
24303
24332
  let srcKey = srcIdx < srcLength ? srcAttrs[srcIdx++] : null;
24304
24333
  let dstKey = dstIdx < dstLength ? dstAttrs[dstIdx++] : null;
@@ -24316,12 +24345,14 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
24316
24345
  } else if (typeof value === "function") {
24317
24346
  value(element);
24318
24347
  return;
24348
+ } else if (value == null) {
24349
+ return;
24319
24350
  } else {
24320
24351
  throw qError(32 /* invalidRefValue */, [currentFile]);
24321
24352
  }
24322
24353
  }
24323
24354
  if (isSignal(value)) {
24324
- const signalData = new EffectPropData({
24355
+ const signalData = new SubscriptionData({
24325
24356
  $scopedStyleIdPrefix$: scopedStyleIdPrefix,
24326
24357
  $isConst$: false
24327
24358
  });
@@ -24334,17 +24365,17 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
24334
24365
  };
24335
24366
  const recordJsxEvent = (key, value) => {
24336
24367
  const eventName = getEventNameFromJsxProp(key);
24368
+ const scope = getEventNameScopeFromJsxProp(key);
24337
24369
  if (eventName) {
24338
- const scope = getEventNameScopeFromJsxProp(key);
24339
24370
  record(":" + scope + ":" + eventName, value);
24340
- }
24341
- const htmlEvent = convertEventNameFromJsxPropToHtmlAttr(key);
24342
- if (htmlEvent) {
24343
- record(htmlEvent, "");
24344
- }
24345
- if (eventName) {
24346
24371
  registerQwikLoaderEvent(eventName);
24347
24372
  }
24373
+ if (scope) {
24374
+ const htmlEvent = convertEventNameFromJsxPropToHtmlAttr(key);
24375
+ if (htmlEvent) {
24376
+ record(htmlEvent, "");
24377
+ }
24378
+ }
24348
24379
  };
24349
24380
  while (srcKey !== null || dstKey !== null) {
24350
24381
  if (dstKey?.startsWith(HANDLER_PREFIX) || dstKey?.startsWith(Q_PREFIX)) {
@@ -24460,7 +24491,7 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
24460
24491
  vCurrent && getInsertBefore()
24461
24492
  );
24462
24493
  vnode_setProp(vNewNode, ELEMENT_KEY, jsxKey);
24463
- isDev4 && vnode_setProp(vNewNode || vCurrent, DEBUG_TYPE, type);
24494
+ isDev6 && vnode_setProp(vNewNode || vCurrent, DEBUG_TYPE, type);
24464
24495
  }
24465
24496
  function expectComponent(component) {
24466
24497
  const componentMeta = component[SERIALIZABLE_STATE];
@@ -24488,9 +24519,6 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
24488
24519
  } else if (!hashesAreEqual) {
24489
24520
  insertNewComponent(host, componentQRL, jsxProps);
24490
24521
  if (vNewNode) {
24491
- if (host) {
24492
- vNewNode[0 /* flags */] = host[0 /* flags */];
24493
- }
24494
24522
  host = vNewNode;
24495
24523
  shouldRender = true;
24496
24524
  }
@@ -24500,7 +24528,7 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
24500
24528
  shouldRender = shouldRender || propsDiffer(jsxProps, vNodeProps);
24501
24529
  if (shouldRender) {
24502
24530
  host[0 /* flags */] &= ~32 /* Deleted */;
24503
- container.$scheduler$(7 /* COMPONENT */, host, componentQRL, jsxProps);
24531
+ container.$scheduler$(6 /* COMPONENT */, host, componentQRL, jsxProps);
24504
24532
  }
24505
24533
  }
24506
24534
  descendContentToProject(jsxNode2.children, host);
@@ -24535,7 +24563,7 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
24535
24563
  }
24536
24564
  function insertNewComponent(host, componentQRL, jsxProps) {
24537
24565
  if (host) {
24538
- clearVNodeEffectDependencies(container, host);
24566
+ clearAllEffects(container, host);
24539
24567
  }
24540
24568
  vnode_insertBefore(
24541
24569
  journal,
@@ -24544,7 +24572,7 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
24544
24572
  vCurrent && getInsertBefore()
24545
24573
  );
24546
24574
  const jsxNode2 = jsxValue;
24547
- isDev4 && vnode_setProp(vNewNode, DEBUG_TYPE, "C" /* Component */);
24575
+ isDev6 && vnode_setProp(vNewNode, DEBUG_TYPE, "C" /* Component */);
24548
24576
  container.setHostProp(vNewNode, OnRenderProp, componentQRL);
24549
24577
  container.setHostProp(vNewNode, ELEMENT_PROPS, jsxProps);
24550
24578
  container.setHostProp(vNewNode, ELEMENT_KEY, jsxNode2.key);
@@ -24557,7 +24585,7 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
24557
24585
  vCurrent && getInsertBefore()
24558
24586
  );
24559
24587
  const jsxNode2 = jsxValue;
24560
- isDev4 && vnode_setProp(vNewNode, DEBUG_TYPE, "I" /* InlineComponent */);
24588
+ isDev6 && vnode_setProp(vNewNode, DEBUG_TYPE, "I" /* InlineComponent */);
24561
24589
  vnode_setProp(vNewNode, ELEMENT_PROPS, jsxNode2.props);
24562
24590
  if (jsxNode2.key) {
24563
24591
  vnode_setProp(vNewNode, ELEMENT_KEY, jsxNode2.key);
@@ -24601,8 +24629,8 @@ function propsDiffer(src, dst) {
24601
24629
  if (!src || !dst) {
24602
24630
  return true;
24603
24631
  }
24604
- let srcKeys = removePropsKeys(Object.keys(src), ["children", QSubscribers]);
24605
- let dstKeys = removePropsKeys(Object.keys(dst), ["children", QSubscribers]);
24632
+ let srcKeys = removePropsKeys(Object.keys(src), ["children", QBackRefs]);
24633
+ let dstKeys = removePropsKeys(Object.keys(dst), ["children", QBackRefs]);
24606
24634
  if (srcKeys.length !== dstKeys.length) {
24607
24635
  return true;
24608
24636
  }
@@ -24636,7 +24664,7 @@ function cleanup(container, vNode) {
24636
24664
  do {
24637
24665
  const type = vCursor[0 /* flags */];
24638
24666
  if (type & 3 /* ELEMENT_OR_VIRTUAL_MASK */) {
24639
- clearVNodeEffectDependencies(container, vCursor);
24667
+ clearAllEffects(container, vCursor);
24640
24668
  markVNodeAsDeleted(vCursor);
24641
24669
  if (type & 2 /* Virtual */) {
24642
24670
  const seq = container.getHostProp(vCursor, ELEMENT_SEQ);
@@ -24645,7 +24673,7 @@ function cleanup(container, vNode) {
24645
24673
  const obj = seq[i];
24646
24674
  if (isTask(obj)) {
24647
24675
  const task = obj;
24648
- clearSubscriberEffectDependencies(container, task);
24676
+ clearAllEffects(container, task);
24649
24677
  if (task.$flags$ & 1 /* VISIBLE_TASK */) {
24650
24678
  container.$scheduler$(48 /* CLEANUP_VISIBLE */, task);
24651
24679
  } else {
@@ -24657,8 +24685,8 @@ function cleanup(container, vNode) {
24657
24685
  }
24658
24686
  const isComponent = type & 2 /* Virtual */ && vnode_getProp(vCursor, OnRenderProp, null) !== null;
24659
24687
  if (isComponent) {
24660
- const attrs = vCursor;
24661
- for (let i = 6 /* PROPS_OFFSET */; i < attrs.length; i = i + 2) {
24688
+ const attrs = vnode_getProps(vCursor);
24689
+ for (let i = 0; i < attrs.length; i = i + 2) {
24662
24690
  const key = attrs[i];
24663
24691
  if (!isParentSlotProp(key) && isSlotProp(key)) {
24664
24692
  const value = attrs[i + 1];
@@ -24730,206 +24758,488 @@ function markVNodeAsDeleted(vCursor) {
24730
24758
  var HANDLER_PREFIX = ":";
24731
24759
  var count = 0;
24732
24760
 
24733
- // packages/qwik/src/core/shared/qrl/implicit_dollar.ts
24734
- var implicit$FirstArg = (fn) => {
24735
- return function(first, ...rest) {
24736
- return fn.call(null, dollar(first), ...rest);
24761
+ // packages/qwik/src/core/use/use-resource.ts
24762
+ var _createResourceReturn = (opts) => {
24763
+ const resource = {
24764
+ __brand: "resource",
24765
+ value: void 0,
24766
+ loading: isServerPlatform() ? false : true,
24767
+ _resolved: void 0,
24768
+ _error: void 0,
24769
+ _state: "pending",
24770
+ _timeout: opts?.timeout ?? -1,
24771
+ _cache: 0
24737
24772
  };
24773
+ return resource;
24738
24774
  };
24739
-
24740
- // packages/qwik/src/core/shared/scheduler.ts
24741
- var DEBUG2 = false;
24742
- var createScheduler = (container, scheduleDrain, journalFlush) => {
24743
- const choreQueue = [];
24744
- let currentChore = null;
24745
- let journalFlushScheduled = false;
24746
- return schedule;
24747
- function schedule(type, hostOrTask = null, targetOrQrl = null, payload = null) {
24748
- const runLater = type !== 255 /* WAIT_FOR_ALL */ && type !== 6 /* COMPONENT_SSR */;
24749
- const isTask2 = type === 3 /* TASK */ || type === 32 /* VISIBLE */ || type === 2 /* RESOURCE */ || type === 48 /* CLEANUP_VISIBLE */;
24750
- if (isTask2) {
24751
- hostOrTask.$flags$ |= 8 /* DIRTY */;
24752
- }
24753
- let chore = {
24754
- $type$: type,
24755
- $idx$: isTask2 ? hostOrTask.$index$ : typeof targetOrQrl === "string" ? targetOrQrl : 0,
24756
- $host$: isTask2 ? hostOrTask.$el$ : hostOrTask,
24757
- $target$: targetOrQrl,
24758
- $payload$: isTask2 ? hostOrTask : payload,
24759
- $resolve$: null,
24760
- $promise$: null,
24761
- $returnValue$: null,
24762
- $executed$: false
24763
- };
24764
- chore.$promise$ = new Promise((resolve) => chore.$resolve$ = resolve);
24765
- DEBUG2 && debugTrace("schedule", chore, currentChore, choreQueue);
24766
- chore = sortedInsert(choreQueue, chore, container.rootVNode || null);
24767
- if (!journalFlushScheduled && runLater) {
24768
- journalFlushScheduled = true;
24769
- schedule(16 /* JOURNAL_FLUSH */);
24770
- scheduleDrain();
24771
- }
24772
- if (runLater) {
24773
- return chore.$promise$;
24774
- } else {
24775
- return drainUpTo(chore, container.rootVNode || null);
24776
- }
24777
- }
24778
- function drainUpTo(runUptoChore, rootVNode) {
24779
- if (runUptoChore.$executed$) {
24780
- return runUptoChore.$returnValue$;
24781
- }
24782
- if (currentChore) {
24783
- return runUptoChore.$promise$;
24784
- }
24785
- while (choreQueue.length) {
24786
- const nextChore = choreQueue.shift();
24787
- const order = choreComparator(nextChore, runUptoChore, rootVNode, false);
24788
- if (order === null) {
24789
- continue;
24790
- }
24791
- if (order > 0) {
24792
- break;
24775
+ var createResourceReturn = (container, opts, initialPromise) => {
24776
+ const result = _createResourceReturn(opts);
24777
+ result.value = initialPromise;
24778
+ return createStore(container, result, 1 /* RECURSIVE */);
24779
+ };
24780
+ var runResource = (task, container, host) => {
24781
+ task.$flags$ &= ~8 /* DIRTY */;
24782
+ cleanupTask(task);
24783
+ const iCtx = newInvokeContext(container.$locale$, host, void 0, ResourceEvent);
24784
+ iCtx.$container$ = container;
24785
+ const taskFn = task.$qrl$.getFn(iCtx, () => clearAllEffects(container, task));
24786
+ const resource = task.$state$;
24787
+ assertDefined(
24788
+ resource,
24789
+ 'useResource: when running a resource, "task.resource" must be a defined.',
24790
+ task
24791
+ );
24792
+ const track = (obj, prop) => {
24793
+ const ctx = newInvokeContext();
24794
+ ctx.$effectSubscriber$ = getSubscriber(task, ":" /* COMPONENT */);
24795
+ ctx.$container$ = container;
24796
+ return invoke(ctx, () => {
24797
+ if (isFunction(obj)) {
24798
+ return obj();
24793
24799
  }
24794
- const isDeletedVNode = vNodeAlreadyDeleted(nextChore);
24795
- if (isDeletedVNode && // we need to process cleanup tasks for deleted nodes
24796
- nextChore.$type$ !== 48 /* CLEANUP_VISIBLE */) {
24797
- DEBUG2 && debugTrace("skip chore", nextChore, currentChore, choreQueue);
24798
- continue;
24800
+ if (prop) {
24801
+ return obj[prop];
24802
+ } else if (isSignal(obj)) {
24803
+ return obj.value;
24804
+ } else {
24805
+ return obj;
24799
24806
  }
24800
- const returnValue = executeChore(nextChore);
24801
- if (isPromise(returnValue)) {
24802
- const promise = returnValue.then(() => drainUpTo(runUptoChore, rootVNode));
24803
- return promise;
24807
+ });
24808
+ };
24809
+ const handleError = (reason) => container.handleError(reason, host);
24810
+ const cleanups = [];
24811
+ task.$destroy$ = noSerialize(() => {
24812
+ cleanups.forEach((fn) => {
24813
+ try {
24814
+ fn();
24815
+ } catch (err) {
24816
+ handleError(err);
24817
+ }
24818
+ });
24819
+ done = true;
24820
+ });
24821
+ const resourceTarget = unwrapStore(resource);
24822
+ const opts = {
24823
+ track,
24824
+ cleanup(fn) {
24825
+ if (typeof fn === "function") {
24826
+ cleanups.push(fn);
24827
+ }
24828
+ },
24829
+ cache(policy) {
24830
+ let milliseconds = 0;
24831
+ if (policy === "immutable") {
24832
+ milliseconds = Infinity;
24833
+ } else {
24834
+ milliseconds = policy;
24835
+ }
24836
+ resource._cache = milliseconds;
24837
+ },
24838
+ previous: resourceTarget._resolved
24839
+ };
24840
+ let resolve;
24841
+ let reject;
24842
+ let done = false;
24843
+ const setState = (resolved, value) => {
24844
+ if (!done) {
24845
+ done = true;
24846
+ if (resolved) {
24847
+ done = true;
24848
+ resource.loading = false;
24849
+ resource._state = "resolved";
24850
+ resource._resolved = value;
24851
+ resource._error = void 0;
24852
+ resolve(value);
24853
+ } else {
24854
+ done = true;
24855
+ resource.loading = false;
24856
+ resource._state = "rejected";
24857
+ resource._error = value;
24858
+ reject(value);
24859
+ }
24860
+ return true;
24861
+ }
24862
+ return false;
24863
+ };
24864
+ cleanups.push(() => {
24865
+ if (untrack(() => resource.loading) === true) {
24866
+ const value = untrack(() => resource._resolved);
24867
+ setState(true, value);
24868
+ }
24869
+ });
24870
+ invoke(iCtx, () => {
24871
+ resource._state = "pending";
24872
+ resource.loading = !isServerPlatform();
24873
+ const promise2 = resource.value = new Promise((r, re) => {
24874
+ resolve = r;
24875
+ reject = re;
24876
+ });
24877
+ promise2.catch(ignoreErrorToPreventNodeFromCrashing);
24878
+ });
24879
+ const promise = safeCall(
24880
+ () => Promise.resolve(taskFn(opts)),
24881
+ (value) => {
24882
+ setState(true, value);
24883
+ },
24884
+ (err) => {
24885
+ if (isPromise(err)) {
24886
+ return err.then(() => runResource(task, container, host));
24887
+ } else {
24888
+ setState(false, err);
24889
+ }
24890
+ }
24891
+ );
24892
+ const timeout = resourceTarget._timeout;
24893
+ if (timeout > 0) {
24894
+ return Promise.race([
24895
+ promise,
24896
+ delay(timeout).then(() => {
24897
+ if (setState(false, new Error("timeout"))) {
24898
+ cleanupTask(task);
24899
+ }
24900
+ })
24901
+ ]);
24902
+ }
24903
+ return promise;
24904
+ };
24905
+ var ignoreErrorToPreventNodeFromCrashing = (err) => {
24906
+ };
24907
+
24908
+ // packages/qwik/src/core/shared/scheduler-document-position.ts
24909
+ var aVNodePath = [];
24910
+ var bVNodePath = [];
24911
+ var vnode_documentPosition = (a, b, rootVNode) => {
24912
+ if (a === b) {
24913
+ return 0;
24914
+ }
24915
+ let aDepth = -1;
24916
+ let bDepth = -1;
24917
+ while (a) {
24918
+ const vNode = aVNodePath[++aDepth] = a;
24919
+ a = vNode[1 /* parent */] || rootVNode && vnode_getProp(a, QSlotParent, (id) => vnode_locate(rootVNode, id));
24920
+ }
24921
+ while (b) {
24922
+ const vNode = bVNodePath[++bDepth] = b;
24923
+ b = vNode[1 /* parent */] || rootVNode && vnode_getProp(b, QSlotParent, (id) => vnode_locate(rootVNode, id));
24924
+ }
24925
+ while (aDepth >= 0 && bDepth >= 0) {
24926
+ a = aVNodePath[aDepth];
24927
+ b = bVNodePath[bDepth];
24928
+ if (a === b) {
24929
+ aDepth--;
24930
+ bDepth--;
24931
+ } else {
24932
+ let cursor = b;
24933
+ do {
24934
+ cursor = vnode_getNextSibling(cursor);
24935
+ if (cursor === a) {
24936
+ return 1;
24937
+ }
24938
+ } while (cursor);
24939
+ cursor = b;
24940
+ do {
24941
+ cursor = vnode_getPreviousSibling(cursor);
24942
+ if (cursor === a) {
24943
+ return -1;
24944
+ }
24945
+ } while (cursor);
24946
+ if (rootVNode && vnode_getProp(b, QSlotParent, (id) => vnode_locate(rootVNode, id))) {
24947
+ return -1;
24948
+ }
24949
+ return 1;
24950
+ }
24951
+ }
24952
+ return aDepth < bDepth ? -1 : 1;
24953
+ };
24954
+ var aSsrNodePath = [];
24955
+ var bSsrNodePath = [];
24956
+ var ssrNodeDocumentPosition = (a, b) => {
24957
+ if (a === b) {
24958
+ return 0;
24959
+ }
24960
+ let aDepth = -1;
24961
+ let bDepth = -1;
24962
+ while (a) {
24963
+ const ssrNode = aSsrNodePath[++aDepth] = a;
24964
+ a = ssrNode.currentComponentNode;
24965
+ }
24966
+ while (b) {
24967
+ const ssrNode = bSsrNodePath[++bDepth] = b;
24968
+ b = ssrNode.currentComponentNode;
24969
+ }
24970
+ while (aDepth >= 0 && bDepth >= 0) {
24971
+ a = aSsrNodePath[aDepth];
24972
+ b = bSsrNodePath[bDepth];
24973
+ if (a === b) {
24974
+ aDepth--;
24975
+ bDepth--;
24976
+ } else {
24977
+ return 1;
24978
+ }
24979
+ }
24980
+ return aDepth < bDepth ? -1 : 1;
24981
+ };
24982
+
24983
+ // packages/qwik/src/core/shared/scheduler.ts
24984
+ var DEBUG2 = false;
24985
+ var getPromise = (chore) => chore.$promise$ || (chore.$promise$ = new Promise((resolve) => {
24986
+ chore.$resolve$ = resolve;
24987
+ }));
24988
+ var createScheduler = (container, scheduleDrain, journalFlush) => {
24989
+ const choreQueue = [];
24990
+ const qrlRuns = [];
24991
+ let currentChore = null;
24992
+ let drainScheduled = false;
24993
+ return schedule;
24994
+ function schedule(type, hostOrTask = null, targetOrQrl = null, payload = null) {
24995
+ const isServer4 = !isDomContainer(container);
24996
+ const isComponentSsr = isServer4 && type === 6 /* COMPONENT */;
24997
+ const runLater = type !== 255 /* WAIT_FOR_ALL */ && !isComponentSsr && type !== 2 /* RUN_QRL */;
24998
+ const isTask2 = type === 3 /* TASK */ || type === 32 /* VISIBLE */ || type === 48 /* CLEANUP_VISIBLE */;
24999
+ const isClientOnly = type === 16 /* JOURNAL_FLUSH */ || type === 4 /* NODE_DIFF */ || type === 5 /* NODE_PROP */;
25000
+ if (isServer4 && isClientOnly) {
25001
+ DEBUG2 && debugTrace(
25002
+ `skip client chore ${debugChoreTypeToString(type)}`,
25003
+ null,
25004
+ currentChore,
25005
+ choreQueue
25006
+ );
25007
+ return;
25008
+ }
25009
+ if (isTask2) {
25010
+ hostOrTask.$flags$ |= 8 /* DIRTY */;
25011
+ }
25012
+ let chore = {
25013
+ $type$: type,
25014
+ $idx$: isTask2 ? hostOrTask.$index$ : typeof targetOrQrl === "string" ? targetOrQrl : 0,
25015
+ $host$: isTask2 ? hostOrTask.$el$ : hostOrTask,
25016
+ $target$: targetOrQrl,
25017
+ $payload$: isTask2 ? hostOrTask : payload,
25018
+ $resolve$: null,
25019
+ $promise$: null,
25020
+ $returnValue$: null,
25021
+ $executed$: false
25022
+ };
25023
+ chore = sortedInsert(choreQueue, chore, container.rootVNode || null);
25024
+ DEBUG2 && debugTrace("schedule", chore, currentChore, choreQueue);
25025
+ if (!drainScheduled && runLater) {
25026
+ drainScheduled = true;
25027
+ schedule(16 /* JOURNAL_FLUSH */);
25028
+ scheduleDrain()?.catch?.(() => {
25029
+ });
25030
+ }
25031
+ if (runLater) {
25032
+ return getPromise(chore);
25033
+ } else {
25034
+ return drainUpTo(chore, isServer4);
25035
+ }
25036
+ }
25037
+ function drainUpTo(runUptoChore, isServer4) {
25038
+ let maxRetries = 5e3;
25039
+ while (choreQueue.length) {
25040
+ if (maxRetries-- < 0) {
25041
+ throw new Error("drainUpTo: max retries reached");
25042
+ }
25043
+ if (currentChore) {
25044
+ return getPromise(currentChore).then(() => drainUpTo(runUptoChore, isServer4)).catch((e) => {
25045
+ container.handleError(e, currentChore?.$host$);
25046
+ });
25047
+ }
25048
+ const nextChore = choreQueue[0];
25049
+ if (nextChore.$executed$) {
25050
+ choreQueue.shift();
25051
+ if (nextChore === runUptoChore) {
25052
+ break;
25053
+ }
25054
+ continue;
24804
25055
  }
25056
+ if (vNodeAlreadyDeleted(nextChore) && // we need to process cleanup tasks for deleted nodes
25057
+ nextChore.$type$ !== 48 /* CLEANUP_VISIBLE */) {
25058
+ DEBUG2 && debugTrace("skip chore", nextChore, currentChore, choreQueue);
25059
+ choreQueue.shift();
25060
+ continue;
25061
+ }
25062
+ executeChore(nextChore, isServer4);
24805
25063
  }
24806
25064
  return runUptoChore.$returnValue$;
24807
25065
  }
24808
- function executeChore(chore) {
25066
+ function executeChore(chore, isServer4) {
24809
25067
  const host = chore.$host$;
24810
25068
  DEBUG2 && debugTrace("execute", chore, currentChore, choreQueue);
24811
25069
  assertEqual(currentChore, null, "Chore already running.");
24812
25070
  currentChore = chore;
24813
25071
  let returnValue = null;
24814
- switch (chore.$type$) {
24815
- case 16 /* JOURNAL_FLUSH */:
24816
- returnValue = journalFlush();
24817
- journalFlushScheduled = false;
24818
- break;
24819
- case 7 /* COMPONENT */:
24820
- case 6 /* COMPONENT_SSR */:
24821
- returnValue = safeCall(
24822
- () => executeComponent(
24823
- container,
24824
- host,
24825
- host,
24826
- chore.$target$,
24827
- chore.$payload$
24828
- ),
24829
- (jsx5) => {
24830
- if (chore.$type$ === 7 /* COMPONENT */) {
24831
- const styleScopedId = container.getHostProp(host, QScopedStyle);
24832
- return vnode_diff(
25072
+ try {
25073
+ switch (chore.$type$) {
25074
+ case 255 /* WAIT_FOR_ALL */:
25075
+ {
25076
+ if (isServer4) {
25077
+ drainScheduled = false;
25078
+ }
25079
+ }
25080
+ break;
25081
+ case 16 /* JOURNAL_FLUSH */:
25082
+ {
25083
+ returnValue = journalFlush();
25084
+ drainScheduled = false;
25085
+ }
25086
+ break;
25087
+ case 6 /* COMPONENT */:
25088
+ {
25089
+ returnValue = safeCall(
25090
+ () => executeComponent(
24833
25091
  container,
24834
- jsx5,
24835
25092
  host,
24836
- addComponentStylePrefix(styleScopedId)
24837
- );
25093
+ host,
25094
+ chore.$target$,
25095
+ chore.$payload$
25096
+ ),
25097
+ (jsx4) => {
25098
+ if (isServer4) {
25099
+ return jsx4;
25100
+ } else {
25101
+ const styleScopedId = container.getHostProp(host, QScopedStyle);
25102
+ return retryOnPromise(
25103
+ () => vnode_diff(
25104
+ container,
25105
+ jsx4,
25106
+ host,
25107
+ addComponentStylePrefix(styleScopedId)
25108
+ )
25109
+ );
25110
+ }
25111
+ },
25112
+ (err) => container.handleError(err, host)
25113
+ );
25114
+ }
25115
+ break;
25116
+ case 2 /* RUN_QRL */:
25117
+ {
25118
+ const fn = chore.$target$.getFn();
25119
+ const result = retryOnPromise(() => fn(...chore.$payload$));
25120
+ if (isPromise(result)) {
25121
+ const handled = result.finally(() => {
25122
+ qrlRuns.splice(qrlRuns.indexOf(handled), 1);
25123
+ }).catch((error) => {
25124
+ container.handleError(error, chore.$host$);
25125
+ });
25126
+ qrlRuns.push(handled);
25127
+ DEBUG2 && debugTrace("execute.DONE (but still running)", chore, currentChore, choreQueue);
25128
+ chore.$returnValue$ = handled;
25129
+ chore.$resolve$?.(handled);
25130
+ currentChore = null;
25131
+ chore.$executed$ = true;
25132
+ return;
25133
+ }
25134
+ returnValue = null;
25135
+ }
25136
+ break;
25137
+ case 3 /* TASK */:
25138
+ case 32 /* VISIBLE */:
25139
+ {
25140
+ const payload = chore.$payload$;
25141
+ if (payload.$flags$ & 4 /* RESOURCE */) {
25142
+ const result = runResource(payload, container, host);
25143
+ returnValue = isServer4 ? result : null;
24838
25144
  } else {
24839
- return jsx5;
25145
+ returnValue = runTask(payload, container, host);
24840
25146
  }
24841
- },
24842
- (err) => container.handleError(err, host)
24843
- );
24844
- break;
24845
- case 2 /* RESOURCE */:
24846
- const result = runResource(chore.$payload$, container, host);
24847
- returnValue = isDomContainer(container) ? null : result;
24848
- break;
24849
- case 3 /* TASK */:
24850
- returnValue = runTask(chore.$payload$, container, host);
24851
- break;
24852
- case 32 /* VISIBLE */:
24853
- returnValue = runTask(chore.$payload$, container, host);
24854
- break;
24855
- case 48 /* CLEANUP_VISIBLE */:
24856
- const task = chore.$payload$;
24857
- cleanupTask(task);
24858
- break;
24859
- case 4 /* NODE_DIFF */:
24860
- const parentVirtualNode = chore.$target$;
24861
- let jsx4 = chore.$payload$;
24862
- if (isSignal(jsx4)) {
24863
- jsx4 = jsx4.value;
24864
- }
24865
- returnValue = vnode_diff(container, jsx4, parentVirtualNode, null);
24866
- break;
24867
- case 5 /* NODE_PROP */:
24868
- const virtualNode = chore.$host$;
24869
- const payload = chore.$payload$;
24870
- let value = payload.$value$;
24871
- if (isSignal(value)) {
24872
- value = value.value;
24873
- }
24874
- const isConst = payload.$isConst$;
24875
- const journal = container.$journal$;
24876
- const property = chore.$idx$;
24877
- const serializedValue = serializeAttribute(property, value, payload.$scopedStyleIdPrefix$);
24878
- if (isConst) {
24879
- const element = virtualNode[6 /* element */];
24880
- journal.push(2 /* SetAttribute */, element, property, serializedValue);
24881
- } else {
24882
- vnode_setAttr(journal, virtualNode, property, serializedValue);
24883
- }
24884
- break;
24885
- case 1 /* QRL_RESOLVE */: {
24886
- const target = chore.$target$;
24887
- returnValue = !target.resolved ? target.resolve() : null;
24888
- break;
24889
- }
24890
- case 8 /* RECOMPUTE_AND_SCHEDULE_EFFECTS */: {
24891
- const target = chore.$target$;
24892
- const forceRunEffects = target.$forceRunEffects$;
24893
- target.$forceRunEffects$ = false;
24894
- if (!target.$effects$?.length) {
25147
+ }
25148
+ break;
25149
+ case 48 /* CLEANUP_VISIBLE */:
25150
+ {
25151
+ const task = chore.$payload$;
25152
+ cleanupTask(task);
25153
+ }
25154
+ break;
25155
+ case 4 /* NODE_DIFF */:
25156
+ {
25157
+ const parentVirtualNode = chore.$target$;
25158
+ let jsx4 = chore.$payload$;
25159
+ if (isSignal(jsx4)) {
25160
+ jsx4 = jsx4.value;
25161
+ }
25162
+ returnValue = retryOnPromise(
25163
+ () => vnode_diff(container, jsx4, parentVirtualNode, null)
25164
+ );
25165
+ }
25166
+ break;
25167
+ case 5 /* NODE_PROP */:
25168
+ {
25169
+ const virtualNode = chore.$host$;
25170
+ const payload = chore.$payload$;
25171
+ let value = payload.$value$;
25172
+ if (isSignal(value)) {
25173
+ value = value.value;
25174
+ }
25175
+ const isConst = payload.$isConst$;
25176
+ const journal = container.$journal$;
25177
+ const property = chore.$idx$;
25178
+ const serializedValue = serializeAttribute(
25179
+ property,
25180
+ value,
25181
+ payload.$scopedStyleIdPrefix$
25182
+ );
25183
+ if (isConst) {
25184
+ const element = virtualNode[6 /* element */];
25185
+ journal.push(2 /* SetAttribute */, element, property, serializedValue);
25186
+ } else {
25187
+ vnode_setAttr(journal, virtualNode, property, serializedValue);
25188
+ }
25189
+ }
25190
+ break;
25191
+ case 1 /* QRL_RESOLVE */: {
25192
+ {
25193
+ const target = chore.$target$;
25194
+ returnValue = !target.resolved ? target.resolve() : null;
25195
+ }
24895
25196
  break;
24896
25197
  }
24897
- returnValue = retryOnPromise(() => {
24898
- if (target.$computeIfNeeded$() || forceRunEffects) {
24899
- triggerEffects(container, target, target.$effects$);
25198
+ case 7 /* RECOMPUTE_AND_SCHEDULE_EFFECTS */: {
25199
+ {
25200
+ const target = chore.$target$;
25201
+ const forceRunEffects = target.$forceRunEffects$;
25202
+ target.$forceRunEffects$ = false;
25203
+ if (!target.$effects$?.size) {
25204
+ break;
25205
+ }
25206
+ returnValue = retryOnPromise(() => {
25207
+ if (target.$computeIfNeeded$() || forceRunEffects) {
25208
+ triggerEffects(container, target, target.$effects$);
25209
+ }
25210
+ });
24900
25211
  }
24901
- });
24902
- break;
25212
+ break;
25213
+ }
24903
25214
  }
25215
+ } catch (e) {
25216
+ returnValue = Promise.reject(e);
24904
25217
  }
24905
- return maybeThenPassError(returnValue, (value) => {
24906
- DEBUG2 && debugTrace("execute.DONE", null, currentChore, choreQueue);
24907
- if (currentChore) {
24908
- currentChore.$executed$ = true;
24909
- currentChore.$resolve$?.(value);
24910
- }
25218
+ const after = (value, error) => {
24911
25219
  currentChore = null;
24912
- return chore.$returnValue$ = value;
24913
- });
24914
- }
24915
- };
24916
- var toNumber = (value) => {
24917
- return typeof value === "number" ? value : -1;
24918
- };
24919
- var choreUpdate = (existing, newChore) => {
24920
- if (existing.$type$ === 4 /* NODE_DIFF */) {
24921
- existing.$payload$ = newChore.$payload$;
24922
- }
24923
- };
24924
- function vNodeAlreadyDeleted(chore) {
24925
- return !!(chore.$host$ && vnode_isVNode(chore.$host$) && chore.$host$[0 /* flags */] & 32 /* Deleted */);
24926
- }
24927
- function choreComparator(a, b, rootVNode, shouldThrowOnHostMismatch) {
24928
- const macroTypeDiff = (a.$type$ & 240 /* MACRO */) - (b.$type$ & 240 /* MACRO */);
24929
- if (macroTypeDiff !== 0) {
24930
- return macroTypeDiff;
25220
+ chore.$executed$ = true;
25221
+ if (error) {
25222
+ DEBUG2 && debugTrace("execute.ERROR", chore, currentChore, choreQueue);
25223
+ container.handleError(error, host);
25224
+ } else {
25225
+ chore.$returnValue$ = value;
25226
+ DEBUG2 && debugTrace("execute.DONE", chore, currentChore, choreQueue);
25227
+ chore.$resolve$?.(value);
25228
+ }
25229
+ };
25230
+ if (isPromise(returnValue)) {
25231
+ chore.$promise$ = returnValue.then(after, (error) => after(void 0, error));
25232
+ chore.$resolve$?.(chore.$promise$);
25233
+ chore.$resolve$ = void 0;
25234
+ } else {
25235
+ after(returnValue);
25236
+ }
24931
25237
  }
24932
- if (a.$type$ !== 16 /* JOURNAL_FLUSH */) {
25238
+ function choreComparator(a, b, rootVNode) {
25239
+ const macroTypeDiff = (a.$type$ & 240 /* MACRO */) - (b.$type$ & 240 /* MACRO */);
25240
+ if (macroTypeDiff !== 0) {
25241
+ return macroTypeDiff;
25242
+ }
24933
25243
  const aHost = a.$host$;
24934
25244
  const bHost = b.$host$;
24935
25245
  if (aHost !== bHost && aHost !== null && bHost !== null) {
@@ -24939,15 +25249,17 @@ function choreComparator(a, b, rootVNode, shouldThrowOnHostMismatch) {
24939
25249
  return hostDiff;
24940
25250
  }
24941
25251
  } else {
25252
+ assertFalse(vnode_isVNode(aHost), "expected aHost to be SSRNode but it is a VNode");
25253
+ assertFalse(vnode_isVNode(bHost), "expected bHost to be SSRNode but it is a VNode");
24942
25254
  const errorMessage = `SERVER: during HTML streaming, re-running tasks on a different host is not allowed.
24943
25255
  You are attempting to change a state that has already been streamed to the client.
24944
25256
  This can lead to inconsistencies between Server-Side Rendering (SSR) and Client-Side Rendering (CSR).
24945
25257
  Problematic Node: ${aHost.toString()}`;
24946
- if (shouldThrowOnHostMismatch) {
24947
- throw qError(45 /* serverHostMismatch */, [errorMessage]);
24948
- }
24949
25258
  logWarn(errorMessage);
24950
- return null;
25259
+ const hostDiff = ssrNodeDocumentPosition(aHost, bHost);
25260
+ if (hostDiff !== 0) {
25261
+ return hostDiff;
25262
+ }
24951
25263
  }
24952
25264
  }
24953
25265
  const microTypeDiff = (a.$type$ & 15 /* MICRO */) - (b.$type$ & 15 /* MICRO */);
@@ -24958,165 +25270,89 @@ function choreComparator(a, b, rootVNode, shouldThrowOnHostMismatch) {
24958
25270
  if (idxDiff !== 0) {
24959
25271
  return idxDiff;
24960
25272
  }
24961
- if (a.$target$ !== b.$target$ && (a.$type$ === 1 /* QRL_RESOLVE */ && b.$type$ === 1 /* QRL_RESOLVE */ || a.$type$ === 5 /* NODE_PROP */ && b.$type$ === 5 /* NODE_PROP */ || a.$type$ === 8 /* RECOMPUTE_AND_SCHEDULE_EFFECTS */ && b.$type$ === 8 /* RECOMPUTE_AND_SCHEDULE_EFFECTS */)) {
25273
+ if (a.$target$ !== b.$target$ || a.$payload$ !== b.$payload$) {
24962
25274
  return 1;
24963
25275
  }
25276
+ if (b === currentChore) {
25277
+ return 1;
25278
+ }
25279
+ return 0;
24964
25280
  }
24965
- return 0;
24966
- }
24967
- function sortedFindIndex(sortedArray, value, rootVNode) {
24968
- let bottom = 0;
24969
- let top = sortedArray.length;
24970
- while (bottom < top) {
24971
- const middle = bottom + (top - bottom >> 1);
24972
- const midChore = sortedArray[middle];
24973
- const comp = choreComparator(value, midChore, rootVNode, true);
24974
- if (comp < 0) {
24975
- top = middle;
24976
- } else if (comp > 0) {
24977
- bottom = middle + 1;
24978
- } else {
24979
- return middle;
25281
+ function sortedFindIndex(sortedArray, value, rootVNode) {
25282
+ let bottom = 0;
25283
+ let top = sortedArray.length;
25284
+ while (bottom < top) {
25285
+ const middle = bottom + (top - bottom >> 1);
25286
+ const midChore = sortedArray[middle];
25287
+ const comp = choreComparator(value, midChore, rootVNode);
25288
+ if (comp < 0) {
25289
+ top = middle;
25290
+ } else if (comp > 0) {
25291
+ bottom = middle + 1;
25292
+ } else {
25293
+ return middle;
25294
+ }
24980
25295
  }
25296
+ return ~bottom;
24981
25297
  }
24982
- return ~bottom;
24983
- }
24984
- function sortedInsert(sortedArray, value, rootVNode) {
24985
- const idx = sortedFindIndex(sortedArray, value, rootVNode);
24986
- if (idx < 0) {
24987
- sortedArray.splice(~idx, 0, value);
24988
- return value;
25298
+ function sortedInsert(sortedArray, value, rootVNode) {
25299
+ const idx = sortedFindIndex(sortedArray, value, rootVNode);
25300
+ if (idx < 0) {
25301
+ sortedArray.splice(~idx, 0, value);
25302
+ return value;
25303
+ }
25304
+ const existing = sortedArray[idx];
25305
+ if (existing.$type$ === 4 /* NODE_DIFF */) {
25306
+ existing.$payload$ = value.$payload$;
25307
+ }
25308
+ if (existing.$executed$) {
25309
+ existing.$executed$ = false;
25310
+ }
25311
+ return existing;
24989
25312
  }
24990
- const existing = sortedArray[idx];
24991
- choreUpdate(existing, value);
24992
- return existing;
25313
+ };
25314
+ var toNumber = (value) => {
25315
+ return typeof value === "number" ? value : -1;
25316
+ };
25317
+ function vNodeAlreadyDeleted(chore) {
25318
+ return !!(chore.$host$ && vnode_isVNode(chore.$host$) && chore.$host$[0 /* flags */] & 32 /* Deleted */);
24993
25319
  }
24994
- function debugChoreToString(chore) {
24995
- const type = {
25320
+ function debugChoreTypeToString(type) {
25321
+ return {
24996
25322
  [1 /* QRL_RESOLVE */]: "QRL_RESOLVE",
24997
- [2 /* RESOURCE */]: "RESOURCE",
25323
+ [2 /* RUN_QRL */]: "RUN_QRL",
24998
25324
  [3 /* TASK */]: "TASK",
24999
25325
  [4 /* NODE_DIFF */]: "NODE_DIFF",
25000
25326
  [5 /* NODE_PROP */]: "NODE_PROP",
25001
- [7 /* COMPONENT */]: "COMPONENT",
25002
- [6 /* COMPONENT_SSR */]: "COMPONENT_SSR",
25003
- [8 /* RECOMPUTE_AND_SCHEDULE_EFFECTS */]: "RECOMPUTE_SIGNAL",
25327
+ [6 /* COMPONENT */]: "COMPONENT",
25328
+ [7 /* RECOMPUTE_AND_SCHEDULE_EFFECTS */]: "RECOMPUTE_SIGNAL",
25004
25329
  [16 /* JOURNAL_FLUSH */]: "JOURNAL_FLUSH",
25005
25330
  [32 /* VISIBLE */]: "VISIBLE",
25006
25331
  [48 /* CLEANUP_VISIBLE */]: "CLEANUP_VISIBLE",
25007
25332
  [255 /* WAIT_FOR_ALL */]: "WAIT_FOR_ALL"
25008
- }[chore.$type$] || "UNKNOWN: " + chore.$type$;
25333
+ }[type] || "UNKNOWN: " + type;
25334
+ }
25335
+ function debugChoreToString(chore) {
25336
+ const type = debugChoreTypeToString(chore.$type$);
25009
25337
  const host = String(chore.$host$).replaceAll(/\n.*/gim, "");
25010
25338
  const qrlTarget = chore.$target$?.$symbol$;
25011
- return `Chore(${type} ${chore.$type$ === 1 /* QRL_RESOLVE */ ? qrlTarget : host} ${chore.$idx$})`;
25339
+ return `Chore(${type} ${chore.$type$ === 1 /* QRL_RESOLVE */ || chore.$type$ === 2 /* RUN_QRL */ ? qrlTarget : host} ${chore.$idx$})`;
25012
25340
  }
25013
25341
  function debugTrace(action, arg, currentChore, queue) {
25014
- const lines = ["Scheduler: " + action];
25015
- if (arg) {
25016
- lines.push(
25017
- " arg: " + ("$type$" in arg ? debugChoreToString(arg) : String(arg).replaceAll(/\n.*/gim, ""))
25018
- );
25019
- }
25020
- if (currentChore) {
25021
- lines.push("running: " + debugChoreToString(currentChore));
25342
+ const lines = ["===========================\nScheduler: " + action];
25343
+ if (arg && !("$type$" in arg)) {
25344
+ lines.push(" arg: " + String(arg).replaceAll(/\n.*/gim, ""));
25022
25345
  }
25023
25346
  if (queue) {
25024
- queue.forEach((chore, idx) => {
25025
- lines.push((idx == 0 ? " queue: " : " ") + debugChoreToString(chore));
25026
- });
25027
- }
25028
- console.log(lines.join("\n ") + "\n");
25029
- }
25030
-
25031
- // packages/qwik/src/core/use/use-task.ts
25032
- var runTask = (task, container, host) => {
25033
- task.$flags$ &= ~8 /* DIRTY */;
25034
- cleanupTask(task);
25035
- const iCtx = newInvokeContext(container.$locale$, host, void 0, TaskEvent);
25036
- iCtx.$container$ = container;
25037
- const taskFn = task.$qrl$.getFn(
25038
- iCtx,
25039
- () => clearSubscriberEffectDependencies(container, task)
25040
- );
25041
- const track = (obj, prop) => {
25042
- const ctx = newInvokeContext();
25043
- ctx.$effectSubscriber$ = [task, ":" /* COMPONENT */];
25044
- ctx.$container$ = container;
25045
- return invoke(ctx, () => {
25046
- if (isFunction(obj)) {
25047
- return obj();
25048
- }
25049
- if (prop) {
25050
- return obj[prop];
25051
- } else if (isSignal(obj)) {
25052
- return obj.value;
25053
- } else {
25054
- return obj;
25055
- }
25347
+ queue.forEach((chore) => {
25348
+ const active = chore === arg ? ">>>" : " ";
25349
+ lines.push(
25350
+ ` ${active} > ` + (chore === currentChore ? "[running] " : "") + debugChoreToString(chore)
25351
+ );
25056
25352
  });
25057
- };
25058
- const handleError = (reason) => container.handleError(reason, host);
25059
- let cleanupFns = null;
25060
- const cleanup2 = (fn) => {
25061
- if (typeof fn == "function") {
25062
- if (!cleanupFns) {
25063
- cleanupFns = [];
25064
- task.$destroy$ = noSerialize(() => {
25065
- task.$destroy$ = null;
25066
- cleanupFns.forEach((fn2) => {
25067
- try {
25068
- fn2();
25069
- } catch (err) {
25070
- handleError(err);
25071
- }
25072
- });
25073
- });
25074
- }
25075
- cleanupFns.push(fn);
25076
- }
25077
- };
25078
- const taskApi = { track, cleanup: cleanup2 };
25079
- const result = safeCall(
25080
- () => taskFn(taskApi),
25081
- cleanup2,
25082
- (err) => {
25083
- if (isPromise(err)) {
25084
- return err.then(() => runTask(task, container, host));
25085
- } else {
25086
- return handleError(err);
25087
- }
25088
- }
25089
- );
25090
- return result;
25091
- };
25092
- var cleanupTask = (task) => {
25093
- const destroy = task.$destroy$;
25094
- if (destroy) {
25095
- task.$destroy$ = null;
25096
- try {
25097
- destroy();
25098
- } catch (err) {
25099
- logError(err);
25100
- }
25101
- }
25102
- };
25103
- var Task = class extends Subscriber {
25104
- constructor($flags$, $index$, $el$, $qrl$, $state$, $destroy$) {
25105
- super();
25106
- this.$flags$ = $flags$;
25107
- this.$index$ = $index$;
25108
- this.$el$ = $el$;
25109
- this.$qrl$ = $qrl$;
25110
- this.$state$ = $state$;
25111
- this.$destroy$ = $destroy$;
25112
- }
25113
- };
25114
- var isTask = (value) => {
25115
- return value instanceof Task;
25116
- };
25117
-
25118
- // packages/qwik/src/core/signal/flags.ts
25119
- var NEEDS_COMPUTATION = Symbol("invalid");
25353
+ }
25354
+ console.log(lines.join("\n") + "\n");
25355
+ }
25120
25356
 
25121
25357
  // packages/qwik/src/core/signal/signal.ts
25122
25358
  var DEBUG3 = false;
@@ -25130,7 +25366,7 @@ var throwIfQRLNotResolved = (qrl2) => {
25130
25366
  var isSignal = (value) => {
25131
25367
  return value instanceof Signal;
25132
25368
  };
25133
- var EffectPropData = class {
25369
+ var SubscriptionData = class {
25134
25370
  constructor(data) {
25135
25371
  __publicField(this, "data");
25136
25372
  this.data = data;
@@ -25169,16 +25405,10 @@ var Signal = class {
25169
25405
  }
25170
25406
  const effectSubscriber = ctx.$effectSubscriber$;
25171
25407
  if (effectSubscriber) {
25172
- const effects = this.$effects$ || (this.$effects$ = []);
25173
- ensureContainsEffect(effects, effectSubscriber);
25174
- ensureContains(effectSubscriber, this);
25175
- if (isSubscriber(this)) {
25176
- ensureEffectContainsSubscriber(
25177
- effectSubscriber[0 /* EFFECT */],
25178
- this,
25179
- this.$container$
25180
- );
25181
- }
25408
+ const effects = this.$effects$ || (this.$effects$ = /* @__PURE__ */ new Set());
25409
+ ensureContainsSubscription(effects, effectSubscriber);
25410
+ ensureContainsBackRef(effectSubscriber, this);
25411
+ addQrlToSerializationCtx(effectSubscriber, this.$container$);
25182
25412
  DEBUG3 && log2("read->sub", pad("\n" + this.toString(), " "));
25183
25413
  }
25184
25414
  }
@@ -25194,118 +25424,90 @@ var Signal = class {
25194
25424
  // prevent accidental use as value
25195
25425
  valueOf() {
25196
25426
  if (qDev) {
25197
- throw qError(46 /* cannotCoerceSignal */);
25427
+ throw qError(45 /* cannotCoerceSignal */);
25198
25428
  }
25199
25429
  }
25200
25430
  toString() {
25201
- return `[${this.constructor.name}${this.$invalid$ ? " INVALID" : ""} ${String(this.$untrackedValue$)}]` + (this.$effects$?.map((e) => "\n -> " + pad(qwikDebugToString(e[0]), " ")).join("\n") || "");
25431
+ return `[${this.constructor.name}${this.$invalid$ ? " INVALID" : ""} ${String(this.$untrackedValue$)}]` + (Array.from(this.$effects$ || []).map((e) => "\n -> " + pad(qwikDebugToString(e[0]), " ")).join("\n") || "");
25202
25432
  }
25203
25433
  toJSON() {
25204
25434
  return { value: this.$untrackedValue$ };
25205
25435
  }
25206
25436
  };
25207
- var ensureContains = (array, value) => {
25208
- const isMissing = array.indexOf(value) === -1;
25209
- if (isMissing) {
25210
- array.push(value);
25211
- }
25212
- };
25213
- var ensureContainsEffect = (array, effectSubscriptions) => {
25214
- for (let i = 0; i < array.length; i++) {
25215
- const existingEffect = array[i];
25216
- if (existingEffect[0] === effectSubscriptions[0] && existingEffect[1] === effectSubscriptions[1]) {
25217
- return;
25218
- }
25219
- }
25220
- array.push(effectSubscriptions);
25221
- };
25222
- var ensureEffectContainsSubscriber = (effect, subscriber, container) => {
25223
- if (isSubscriber(effect)) {
25224
- effect.$effectDependencies$ || (effect.$effectDependencies$ = []);
25225
- if (subscriberExistInSubscribers(effect.$effectDependencies$, subscriber)) {
25226
- return;
25227
- }
25228
- effect.$effectDependencies$.push(subscriber);
25229
- } else if (vnode_isVNode(effect) && !vnode_isTextVNode(effect)) {
25230
- let subscribers = vnode_getProp(
25231
- effect,
25232
- QSubscribers,
25233
- container ? container.$getObjectById$ : null
25234
- );
25235
- subscribers || (subscribers = []);
25236
- if (subscriberExistInSubscribers(subscribers, subscriber)) {
25237
- return;
25238
- }
25239
- subscribers.push(subscriber);
25240
- vnode_setProp(effect, QSubscribers, subscribers);
25241
- } else if (isSSRNode(effect)) {
25242
- let subscribers = effect.getProp(QSubscribers);
25243
- subscribers || (subscribers = []);
25244
- if (subscriberExistInSubscribers(subscribers, subscriber)) {
25245
- return;
25246
- }
25247
- subscribers.push(subscriber);
25248
- effect.setProp(QSubscribers, subscribers);
25249
- }
25437
+ var ensureContainsSubscription = (array, effectSubscription) => {
25438
+ array.add(effectSubscription);
25250
25439
  };
25251
- var isSSRNode = (effect) => {
25252
- return "setProp" in effect && "getProp" in effect && "removeProp" in effect && "id" in effect;
25440
+ var ensureContainsBackRef = (array, value) => {
25441
+ var _a3;
25442
+ array[_a3 = 2 /* BACK_REF */] || (array[_a3] = /* @__PURE__ */ new Set());
25443
+ array[2 /* BACK_REF */].add(value);
25253
25444
  };
25254
- var subscriberExistInSubscribers = (subscribers, subscriber) => {
25255
- for (let i = 0; i < subscribers.length; i++) {
25256
- if (subscribers[i] === subscriber) {
25257
- return true;
25445
+ var addQrlToSerializationCtx = (effectSubscriber, container) => {
25446
+ if (!!container && !isDomContainer(container)) {
25447
+ const effect = effectSubscriber[0 /* CONSUMER */];
25448
+ const property = effectSubscriber[1 /* PROPERTY */];
25449
+ let qrl2 = null;
25450
+ if (isTask(effect)) {
25451
+ qrl2 = effect.$qrl$;
25452
+ } else if (effect instanceof ComputedSignal) {
25453
+ qrl2 = effect.$computeQrl$;
25454
+ } else if (property === ":" /* COMPONENT */) {
25455
+ qrl2 = container.getHostProp(effect, OnRenderProp);
25456
+ }
25457
+ if (qrl2) {
25458
+ container.serializationCtx.$eventQrls$.add(qrl2);
25258
25459
  }
25259
25460
  }
25260
- return false;
25261
25461
  };
25262
25462
  var triggerEffects = (container, signal, effects) => {
25463
+ const isBrowser2 = isDomContainer(container);
25263
25464
  if (effects) {
25264
- const scheduleEffect = (effectSubscriptions) => {
25265
- const effect = effectSubscriptions[0 /* EFFECT */];
25266
- const property = effectSubscriptions[1 /* PROPERTY */];
25465
+ const scheduleEffect = (effectSubscription) => {
25466
+ const consumer = effectSubscription[0 /* CONSUMER */];
25467
+ const property = effectSubscription[1 /* PROPERTY */];
25267
25468
  assertDefined(container, "Container must be defined.");
25268
- if (isTask(effect)) {
25269
- effect.$flags$ |= 8 /* DIRTY */;
25270
- DEBUG3 && log2("schedule.effect.task", pad("\n" + String(effect), " "));
25469
+ if (isTask(consumer)) {
25470
+ consumer.$flags$ |= 8 /* DIRTY */;
25471
+ DEBUG3 && log2("schedule.consumer.task", pad("\n" + String(consumer), " "));
25271
25472
  let choreType = 3 /* TASK */;
25272
- if (effect.$flags$ & 1 /* VISIBLE_TASK */) {
25473
+ if (consumer.$flags$ & 1 /* VISIBLE_TASK */) {
25273
25474
  choreType = 32 /* VISIBLE */;
25274
- } else if (effect.$flags$ & 4 /* RESOURCE */) {
25275
- choreType = 2 /* RESOURCE */;
25276
25475
  }
25277
- container.$scheduler$(choreType, effect);
25278
- } else if (effect instanceof Signal) {
25279
- if (effect instanceof ComputedSignal) {
25280
- if (!effect.$computeQrl$.resolved) {
25281
- container.$scheduler$(1 /* QRL_RESOLVE */, null, effect.$computeQrl$);
25476
+ container.$scheduler$(choreType, consumer);
25477
+ } else if (consumer instanceof Signal) {
25478
+ if (consumer instanceof ComputedSignal) {
25479
+ if (!consumer.$computeQrl$.resolved) {
25480
+ container.$scheduler$(1 /* QRL_RESOLVE */, null, consumer.$computeQrl$);
25282
25481
  }
25283
25482
  }
25284
- effect.$invalidate$();
25483
+ consumer.$invalidate$();
25285
25484
  } else if (property === ":" /* COMPONENT */) {
25286
- const host = effect;
25485
+ const host = consumer;
25287
25486
  const qrl2 = container.getHostProp(host, OnRenderProp);
25288
25487
  assertDefined(qrl2, "Component must have QRL");
25289
25488
  const props = container.getHostProp(host, ELEMENT_PROPS);
25290
- container.$scheduler$(7 /* COMPONENT */, host, qrl2, props);
25291
- } else if (property === "." /* VNODE */) {
25292
- const host = effect;
25293
- const target = host;
25294
- container.$scheduler$(4 /* NODE_DIFF */, host, target, signal);
25295
- } else {
25296
- const host = effect;
25297
- const effectData = effectSubscriptions[2 /* FIRST_BACK_REF_OR_DATA */];
25298
- if (effectData instanceof EffectPropData) {
25299
- const data = effectData.data;
25300
- const payload = {
25301
- ...data,
25302
- $value$: signal
25303
- };
25304
- container.$scheduler$(5 /* NODE_PROP */, host, property, payload);
25489
+ container.$scheduler$(6 /* COMPONENT */, host, qrl2, props);
25490
+ } else if (isBrowser2) {
25491
+ if (property === "." /* VNODE */) {
25492
+ const host = consumer;
25493
+ container.$scheduler$(4 /* NODE_DIFF */, host, host, signal);
25494
+ } else {
25495
+ const host = consumer;
25496
+ const effectData = effectSubscription[3 /* DATA */];
25497
+ if (effectData instanceof SubscriptionData) {
25498
+ const data = effectData.data;
25499
+ const payload = {
25500
+ ...data,
25501
+ $value$: signal
25502
+ };
25503
+ container.$scheduler$(5 /* NODE_PROP */, host, property, payload);
25504
+ }
25305
25505
  }
25306
25506
  }
25307
25507
  };
25308
- effects.forEach(scheduleEffect);
25508
+ for (const effect of effects) {
25509
+ scheduleEffect(effect);
25510
+ }
25309
25511
  }
25310
25512
  DEBUG3 && log2("done scheduling");
25311
25513
  };
@@ -25328,7 +25530,7 @@ var ComputedSignal = class extends Signal {
25328
25530
  $invalidate$() {
25329
25531
  this.$invalid$ = true;
25330
25532
  this.$forceRunEffects$ = false;
25331
- this.$container$?.$scheduler$(8 /* RECOMPUTE_AND_SCHEDULE_EFFECTS */, null, this);
25533
+ this.$container$?.$scheduler$(7 /* RECOMPUTE_AND_SCHEDULE_EFFECTS */, null, this);
25332
25534
  }
25333
25535
  /**
25334
25536
  * Use this to force running subscribers, for example when the calculated value has mutated but
@@ -25355,11 +25557,11 @@ var ComputedSignal = class extends Signal {
25355
25557
  throwIfQRLNotResolved(computeQrl);
25356
25558
  const ctx = tryGetInvokeContext();
25357
25559
  const previousEffectSubscription = ctx?.$effectSubscriber$;
25358
- ctx && (ctx.$effectSubscriber$ = [this, "." /* VNODE */]);
25560
+ ctx && (ctx.$effectSubscriber$ = getSubscriber(this, "." /* VNODE */));
25359
25561
  try {
25360
25562
  const untrackedValue = computeQrl.getFn(ctx)();
25361
25563
  if (isPromise(untrackedValue)) {
25362
- throw qError(47 /* computedNotSync */, [
25564
+ throw qError(46 /* computedNotSync */, [
25363
25565
  computeQrl.dev ? computeQrl.dev.file : "",
25364
25566
  computeQrl.$hash$
25365
25567
  ]);
@@ -25382,10 +25584,11 @@ var ComputedSignal = class extends Signal {
25382
25584
  return super.value;
25383
25585
  }
25384
25586
  set value(_) {
25385
- throw qError(48 /* computedReadOnly */);
25587
+ throw qError(47 /* computedReadOnly */);
25386
25588
  }
25387
25589
  };
25388
- var WrappedSignal = class extends Signal {
25590
+ var _a2, _b;
25591
+ var WrappedSignal = class extends (_b = Signal, _a2 = _EFFECT_BACK_REF, _b) {
25389
25592
  constructor(container, fn, args, fnStr) {
25390
25593
  super(container, NEEDS_COMPUTATION);
25391
25594
  __publicField(this, "$args$");
@@ -25394,9 +25597,9 @@ var WrappedSignal = class extends Signal {
25394
25597
  // We need a separate flag to know when the computation needs running because
25395
25598
  // we need the old value to know if effects need running after computation
25396
25599
  __publicField(this, "$invalid$", true);
25397
- __publicField(this, "$effectDependencies$", null);
25398
25600
  __publicField(this, "$hostElement$", null);
25399
25601
  __publicField(this, "$forceRunEffects$", false);
25602
+ __publicField(this, _a2, null);
25400
25603
  this.$args$ = args;
25401
25604
  this.$func$ = fn;
25402
25605
  this.$funcStr$ = fnStr;
@@ -25405,7 +25608,7 @@ var WrappedSignal = class extends Signal {
25405
25608
  this.$invalid$ = true;
25406
25609
  this.$forceRunEffects$ = false;
25407
25610
  this.$container$?.$scheduler$(
25408
- 8 /* RECOMPUTE_AND_SCHEDULE_EFFECTS */,
25611
+ 7 /* RECOMPUTE_AND_SCHEDULE_EFFECTS */,
25409
25612
  this.$hostElement$,
25410
25613
  this
25411
25614
  );
@@ -25448,7 +25651,7 @@ var WrappedSignal = class extends Signal {
25448
25651
  return super.value;
25449
25652
  }
25450
25653
  set value(_) {
25451
- throw qError(49 /* wrappedReadOnly */);
25654
+ throw qError(48 /* wrappedReadOnly */);
25452
25655
  }
25453
25656
  };
25454
25657
 
@@ -25494,16 +25697,6 @@ var _SharedContainer = class {
25494
25697
  }
25495
25698
  };
25496
25699
 
25497
- // packages/qwik/src/core/shared/utils/constants.ts
25498
- var QObjectRecursive = 1 << 0;
25499
- var QObjectImmutable = 1 << 1;
25500
- var QObjectTargetSymbol = Symbol("proxy target");
25501
- var QObjectFlagsSymbol = Symbol("proxy flags");
25502
- var QObjectManagerSymbol = Symbol("proxy manager");
25503
- var _CONST_PROPS = Symbol("CONST");
25504
- var _VAR_PROPS = Symbol("VAR");
25505
- var _IMMUTABLE = Symbol("IMMUTABLE");
25506
-
25507
25700
  // packages/qwik/src/core/shared-types.ts
25508
25701
  function isStringifiable(value) {
25509
25702
  return value === null || typeof value === "string" || typeof value === "number" || typeof value === "boolean";
@@ -25695,7 +25888,7 @@ function qwikDebugToString(value) {
25695
25888
  return String(value);
25696
25889
  } else if (isTask(value)) {
25697
25890
  return `Task(${qwikDebugToString(value.$qrl$)})`;
25698
- } else if (isQrl(value)) {
25891
+ } else if (isQrl2(value)) {
25699
25892
  return `Qrl(${value.$symbol$})`;
25700
25893
  } else if (typeof value === "object" || typeof value === "function") {
25701
25894
  if (stringifyPath.includes(value)) {
@@ -26024,13 +26217,13 @@ var VNodeDataChar = {
26024
26217
  /* **** */
26025
26218
  "^"
26026
26219
  ),
26027
- SUBS: (
26028
- /* *************** */
26220
+ BACK_REFS: (
26221
+ /* ********** */
26029
26222
  96
26030
26223
  ),
26031
- // '`' - `q:subs' - Effect dependencies/subscriptions
26032
- SUBS_CHAR: (
26033
- /* ******* */
26224
+ // '`' - `q:brefs' - Effect dependencies/subscriptions
26225
+ BACK_REFS_CHAR: (
26226
+ /* ** */
26034
26227
  "`"
26035
26228
  ),
26036
26229
  SEPARATOR: (
@@ -26053,6 +26246,14 @@ var VNodeDataChar = {
26053
26246
  )
26054
26247
  };
26055
26248
 
26249
+ // packages/qwik/src/core/shared/utils/maps.ts
26250
+ var mergeMaps = (map1, map2) => {
26251
+ for (const [k, v] of map2) {
26252
+ map1.set(k, v);
26253
+ }
26254
+ return map1;
26255
+ };
26256
+
26056
26257
  // packages/qwik/src/core/client/vnode.ts
26057
26258
  var vnode_newElement = (element, elementName) => {
26058
26259
  assertEqual(fastNodeType(element), 1, "Expecting element node.");
@@ -26214,6 +26415,7 @@ var vnode_ensureElementInflated = (vnode) => {
26214
26415
  elementVNode[0 /* flags */] ^= 8 /* Inflated */;
26215
26416
  const element = elementVNode[6 /* element */];
26216
26417
  const attributes = element.attributes;
26418
+ const props = vnode_getProps(elementVNode);
26217
26419
  for (let idx = 0; idx < attributes.length; idx++) {
26218
26420
  const attr = attributes[idx];
26219
26421
  const key = attr.name;
@@ -26221,23 +26423,13 @@ var vnode_ensureElementInflated = (vnode) => {
26221
26423
  break;
26222
26424
  } else if (key.startsWith(QContainerAttr)) {
26223
26425
  if (attr.value === "html" /* HTML */) {
26224
- mapArray_set(
26225
- elementVNode,
26226
- dangerouslySetInnerHTML,
26227
- element.innerHTML,
26228
- 8 /* PROPS_OFFSET */
26229
- );
26426
+ mapArray_set(props, dangerouslySetInnerHTML, element.innerHTML, 0);
26230
26427
  } else if (attr.value === "text" /* TEXT */ && "value" in element) {
26231
- mapArray_set(
26232
- elementVNode,
26233
- "value",
26234
- element.value,
26235
- 8 /* PROPS_OFFSET */
26236
- );
26428
+ mapArray_set(props, "value", element.value, 0);
26237
26429
  }
26238
26430
  } else if (!key.startsWith("on:")) {
26239
26431
  const value = attr.value;
26240
- mapArray_set(elementVNode, key, value, 8 /* PROPS_OFFSET */);
26432
+ mapArray_set(props, key, value, 0);
26241
26433
  }
26242
26434
  }
26243
26435
  }
@@ -26565,59 +26757,14 @@ var vnode_applyJournal = (journal) => {
26565
26757
  }
26566
26758
  journal.length = 0;
26567
26759
  };
26568
- var mapApp_findIndx = (elementVNode, key, start) => {
26569
- assertTrue(start % 2 === 0, "Expecting even number.");
26570
- let bottom = start >> 1;
26571
- let top = elementVNode.length - 2 >> 1;
26572
- while (bottom <= top) {
26573
- const mid = bottom + (top - bottom >> 1);
26574
- const midKey = elementVNode[mid << 1];
26575
- if (midKey === key) {
26576
- return mid << 1;
26577
- }
26578
- if (midKey < key) {
26579
- bottom = mid + 1;
26580
- } else {
26581
- top = mid - 1;
26582
- }
26583
- }
26584
- return bottom << 1 ^ -1;
26585
- };
26586
- var mapArray_set = (elementVNode, key, value, start) => {
26587
- const indx = mapApp_findIndx(elementVNode, key, start);
26588
- if (indx >= 0) {
26589
- if (value == null) {
26590
- elementVNode.splice(indx, 2);
26591
- } else {
26592
- elementVNode[indx + 1] = value;
26593
- }
26594
- } else if (value != null) {
26595
- elementVNode.splice(indx ^ -1, 0, key, value);
26596
- }
26597
- };
26598
- var mapApp_remove = (elementVNode, key, start) => {
26599
- const indx = mapApp_findIndx(elementVNode, key, start);
26600
- let value = null;
26601
- if (indx >= 0) {
26602
- value = elementVNode[indx + 1];
26603
- elementVNode.splice(indx, 2);
26604
- return value;
26605
- }
26606
- return value;
26607
- };
26608
- var mapArray_get = (elementVNode, key, start) => {
26609
- const indx = mapApp_findIndx(elementVNode, key, start);
26610
- if (indx >= 0) {
26611
- return elementVNode[indx + 1];
26612
- } else {
26613
- return null;
26614
- }
26615
- };
26616
26760
  var vnode_insertBefore = (journal, parent, newChild, insertBefore) => {
26617
26761
  ensureElementOrVirtualVNode(parent);
26618
26762
  if (vnode_isElementVNode(parent)) {
26619
26763
  ensureMaterialized(parent);
26620
26764
  }
26765
+ if (newChild === insertBefore) {
26766
+ insertBefore = null;
26767
+ }
26621
26768
  let adjustedInsertBefore = null;
26622
26769
  if (insertBefore == null) {
26623
26770
  if (vnode_isVirtualVNode(parent)) {
@@ -26720,8 +26867,10 @@ var vnode_getElementName = (vnode) => {
26720
26867
  const elementVNode = ensureElementVNode(vnode);
26721
26868
  let elementName = elementVNode[7 /* elementName */];
26722
26869
  if (elementName === void 0) {
26723
- elementName = elementVNode[7 /* elementName */] = elementVNode[6 /* element */].nodeName.toLowerCase();
26724
- elementVNode[0 /* flags */] |= vnode_getElementNamespaceFlags(elementName);
26870
+ const element = elementVNode[6 /* element */];
26871
+ const nodeName = isDev7 ? fastNodeName(element).toLowerCase() : fastNodeName(element);
26872
+ elementName = elementVNode[7 /* elementName */] = nodeName;
26873
+ elementVNode[0 /* flags */] |= vnode_getElementNamespaceFlags(element);
26725
26874
  }
26726
26875
  return elementName;
26727
26876
  };
@@ -26887,6 +27036,20 @@ var fastFirstChild = (node) => {
26887
27036
  }
26888
27037
  return node;
26889
27038
  };
27039
+ var _fastNamespaceURI = null;
27040
+ var fastNamespaceURI = (element) => {
27041
+ if (!_fastNamespaceURI) {
27042
+ _fastNamespaceURI = fastGetter(element, "namespaceURI");
27043
+ }
27044
+ return _fastNamespaceURI.call(element);
27045
+ };
27046
+ var _fastNodeName = null;
27047
+ var fastNodeName = (element) => {
27048
+ if (!_fastNodeName) {
27049
+ _fastNodeName = fastGetter(element, "nodeName");
27050
+ }
27051
+ return _fastNodeName.call(element);
27052
+ };
26890
27053
  var fastGetter = (prototype, name) => {
26891
27054
  let getter;
26892
27055
  while (prototype && !(getter = Object.getOwnPropertyDescriptor(prototype, name)?.get)) {
@@ -26942,9 +27105,12 @@ var materializeFromDOM = (vParent, firstChild, vData) => {
26942
27105
  }
26943
27106
  const id = consumeValue();
26944
27107
  container.$setRawState$(parseInt(id), vParent);
26945
- isDev6 && vnode_setAttr(null, vParent, ELEMENT_ID, id);
26946
- } else if (peek() === VNodeDataChar.SUBS) {
26947
- vnode_setProp(vParent, QSubscribers, consumeValue());
27108
+ isDev7 && vnode_setAttr(null, vParent, ELEMENT_ID, id);
27109
+ } else if (peek() === VNodeDataChar.BACK_REFS) {
27110
+ if (!container) {
27111
+ container = getDomContainer(vParent[6 /* element */]);
27112
+ }
27113
+ setEffectBackRefFromVNodeData(vParent, consumeValue(), container);
26948
27114
  } else {
26949
27115
  consumeValue();
26950
27116
  }
@@ -26952,6 +27118,17 @@ var materializeFromDOM = (vParent, firstChild, vData) => {
26952
27118
  }
26953
27119
  return vFirstChild;
26954
27120
  };
27121
+ function setEffectBackRefFromVNodeData(vParent, value, container) {
27122
+ const deserializedSubMap = container.$getObjectById$(value);
27123
+ if (!vParent[_EFFECT_BACK_REF]) {
27124
+ Object.defineProperty(vParent, _EFFECT_BACK_REF, {
27125
+ value: deserializedSubMap
27126
+ });
27127
+ } else {
27128
+ const subMap = vParent[_EFFECT_BACK_REF];
27129
+ mergeMaps(subMap, deserializedSubMap);
27130
+ }
27131
+ }
26955
27132
  var processVNodeData = (vData, callback) => {
26956
27133
  let nextToConsumeIdx = 0;
26957
27134
  let ch = 0;
@@ -26992,8 +27169,9 @@ var vnode_getAttrKeys = (vnode) => {
26992
27169
  if ((type & 3 /* ELEMENT_OR_VIRTUAL_MASK */) !== 0) {
26993
27170
  vnode_ensureElementInflated(vnode);
26994
27171
  const keys = [];
26995
- for (let i = vnode_getPropStartIndex(vnode); i < vnode.length; i = i + 2) {
26996
- const key = vnode[i];
27172
+ const props = vnode_getProps(vnode);
27173
+ for (let i = 0; i < props.length; i = i + 2) {
27174
+ const key = props[i];
26997
27175
  if (!key.startsWith(Q_PROPS_SEPARATOR)) {
26998
27176
  keys.push(key);
26999
27177
  }
@@ -27006,19 +27184,20 @@ var vnode_setAttr = (journal, vnode, key, value) => {
27006
27184
  const type = vnode[0 /* flags */];
27007
27185
  if ((type & 3 /* ELEMENT_OR_VIRTUAL_MASK */) !== 0) {
27008
27186
  vnode_ensureElementInflated(vnode);
27009
- const idx = mapApp_findIndx(vnode, key, vnode_getPropStartIndex(vnode));
27187
+ const props = vnode_getProps(vnode);
27188
+ const idx = mapApp_findIndx(props, key, 0);
27010
27189
  if (idx >= 0) {
27011
- if (vnode[idx + 1] != value && (type & 1 /* Element */) !== 0) {
27190
+ if (props[idx + 1] != value && (type & 1 /* Element */) !== 0) {
27012
27191
  const element = vnode[6 /* element */];
27013
27192
  journal && journal.push(2 /* SetAttribute */, element, key, value);
27014
27193
  }
27015
27194
  if (value == null) {
27016
- vnode.splice(idx, 2);
27195
+ props.splice(idx, 2);
27017
27196
  } else {
27018
- vnode[idx + 1] = value;
27197
+ props[idx + 1] = value;
27019
27198
  }
27020
27199
  } else if (value != null) {
27021
- vnode.splice(idx ^ -1, 0, key, value);
27200
+ props.splice(idx ^ -1, 0, key, value);
27022
27201
  if ((type & 1 /* Element */) !== 0) {
27023
27202
  const element = vnode[6 /* element */];
27024
27203
  journal && journal.push(2 /* SetAttribute */, element, key, value);
@@ -27030,7 +27209,8 @@ var vnode_getAttr = (vnode, key) => {
27030
27209
  const type = vnode[0 /* flags */];
27031
27210
  if ((type & 3 /* ELEMENT_OR_VIRTUAL_MASK */) !== 0) {
27032
27211
  vnode_ensureElementInflated(vnode);
27033
- return mapArray_get(vnode, key, vnode_getPropStartIndex(vnode));
27212
+ const props = vnode_getProps(vnode);
27213
+ return mapArray_get(props, key, 0);
27034
27214
  }
27035
27215
  return null;
27036
27216
  };
@@ -27038,11 +27218,12 @@ var vnode_getProp = (vnode, key, getObject) => {
27038
27218
  const type = vnode[0 /* flags */];
27039
27219
  if ((type & 3 /* ELEMENT_OR_VIRTUAL_MASK */) !== 0) {
27040
27220
  type & 1 /* Element */ && vnode_ensureElementInflated(vnode);
27041
- const idx = mapApp_findIndx(vnode, key, vnode_getPropStartIndex(vnode));
27221
+ const props = vnode_getProps(vnode);
27222
+ const idx = mapApp_findIndx(props, key, 0);
27042
27223
  if (idx >= 0) {
27043
- let value = vnode[idx + 1];
27224
+ let value = props[idx + 1];
27044
27225
  if (typeof value === "string" && getObject) {
27045
- vnode[idx + 1] = value = getObject(value);
27226
+ props[idx + 1] = value = getObject(value);
27046
27227
  }
27047
27228
  return value;
27048
27229
  }
@@ -27051,11 +27232,12 @@ var vnode_getProp = (vnode, key, getObject) => {
27051
27232
  };
27052
27233
  var vnode_setProp = (vnode, key, value) => {
27053
27234
  ensureElementOrVirtualVNode(vnode);
27054
- const idx = mapApp_findIndx(vnode, key, vnode_getPropStartIndex(vnode));
27235
+ const props = vnode_getProps(vnode);
27236
+ const idx = mapApp_findIndx(props, key, 0);
27055
27237
  if (idx >= 0) {
27056
- vnode[idx + 1] = value;
27238
+ props[idx + 1] = value;
27057
27239
  } else if (value != null) {
27058
- vnode.splice(idx ^ -1, 0, key, value);
27240
+ props.splice(idx ^ -1, 0, key, value);
27059
27241
  }
27060
27242
  };
27061
27243
  var vnode_getPropStartIndex = (vnode) => {
@@ -27067,6 +27249,9 @@ var vnode_getPropStartIndex = (vnode) => {
27067
27249
  }
27068
27250
  throw qError(43 /* invalidVNodeType */, [type]);
27069
27251
  };
27252
+ var vnode_getProps = (vnode) => {
27253
+ return vnode[vnode_getPropStartIndex(vnode)];
27254
+ };
27070
27255
  var vnode_getParent = (vnode) => {
27071
27256
  return vnode[1 /* parent */] || null;
27072
27257
  };
@@ -27204,7 +27389,7 @@ function materializeFromVNodeData(vParent, vData, element, child) {
27204
27389
  }
27205
27390
  const id = consumeValue();
27206
27391
  container.$setRawState$(parseInt(id), vParent);
27207
- isDev6 && vnode_setAttr(null, vParent, ELEMENT_ID, id);
27392
+ isDev7 && vnode_setAttr(null, vParent, ELEMENT_ID, id);
27208
27393
  } else if (peek() === VNodeDataChar.PROPS) {
27209
27394
  vnode_setAttr(null, vParent, ELEMENT_PROPS, consumeValue());
27210
27395
  } else if (peek() === VNodeDataChar.SLOT_REF) {
@@ -27215,8 +27400,11 @@ function materializeFromVNodeData(vParent, vData, element, child) {
27215
27400
  vnode_setAttr(null, vParent, ELEMENT_SEQ, consumeValue());
27216
27401
  } else if (peek() === VNodeDataChar.SEQ_IDX) {
27217
27402
  vnode_setAttr(null, vParent, ELEMENT_SEQ_IDX, consumeValue());
27218
- } else if (peek() === VNodeDataChar.SUBS) {
27219
- vnode_setProp(vParent, QSubscribers, consumeValue());
27403
+ } else if (peek() === VNodeDataChar.BACK_REFS) {
27404
+ if (!container) {
27405
+ container = getDomContainer(element);
27406
+ }
27407
+ setEffectBackRefFromVNodeData(vParent, consumeValue(), container);
27220
27408
  } else if (peek() === VNodeDataChar.CONTEXT) {
27221
27409
  vnode_setAttr(null, vParent, QCtxAttr, consumeValue());
27222
27410
  } else if (peek() === VNodeDataChar.OPEN) {
@@ -27276,51 +27464,6 @@ var vnode_getType = (vnode) => {
27276
27464
  };
27277
27465
  var isElement = (node) => node && typeof node == "object" && fastNodeType(node) === /** Node.ELEMENT_NODE* */
27278
27466
  1;
27279
- var aPath = [];
27280
- var bPath = [];
27281
- var vnode_documentPosition = (a, b, rootVNode) => {
27282
- if (a === b) {
27283
- return 0;
27284
- }
27285
- let aDepth = -1;
27286
- let bDepth = -1;
27287
- while (a) {
27288
- const vNode = aPath[++aDepth] = a;
27289
- a = vNode[1 /* parent */] || rootVNode && vnode_getProp(a, QSlotParent, (id) => vnode_locate(rootVNode, id));
27290
- }
27291
- while (b) {
27292
- const vNode = bPath[++bDepth] = b;
27293
- b = vNode[1 /* parent */] || rootVNode && vnode_getProp(b, QSlotParent, (id) => vnode_locate(rootVNode, id));
27294
- }
27295
- while (aDepth >= 0 && bDepth >= 0) {
27296
- a = aPath[aDepth];
27297
- b = bPath[bDepth];
27298
- if (a === b) {
27299
- aDepth--;
27300
- bDepth--;
27301
- } else {
27302
- let cursor = b;
27303
- do {
27304
- cursor = vnode_getNextSibling(cursor);
27305
- if (cursor === a) {
27306
- return 1;
27307
- }
27308
- } while (cursor);
27309
- cursor = b;
27310
- do {
27311
- cursor = vnode_getPreviousSibling(cursor);
27312
- if (cursor === a) {
27313
- return -1;
27314
- }
27315
- } while (cursor);
27316
- if (rootVNode && vnode_getProp(b, QSlotParent, (id) => vnode_locate(rootVNode, id))) {
27317
- return -1;
27318
- }
27319
- return 1;
27320
- }
27321
- }
27322
- return aDepth < bDepth ? -1 : 1;
27323
- };
27324
27467
  var vnode_getProjectionParentComponent = (vHost, rootVNode) => {
27325
27468
  let projectionDepth = 1;
27326
27469
  while (projectionDepth--) {
@@ -27344,24 +27487,38 @@ var vnode_getProjectionParentComponent = (vHost, rootVNode) => {
27344
27487
  };
27345
27488
  var VNodeArray = class VNode extends Array {
27346
27489
  static createElement(flags, parent, previousSibling, nextSibling, firstChild, lastChild, element, elementName) {
27347
- const vnode = new VNode(flags, parent, previousSibling, nextSibling);
27348
- vnode.push(firstChild, lastChild, element, elementName);
27490
+ const vnode = new VNode(
27491
+ flags,
27492
+ parent,
27493
+ previousSibling,
27494
+ nextSibling,
27495
+ firstChild,
27496
+ lastChild,
27497
+ element,
27498
+ elementName,
27499
+ []
27500
+ );
27349
27501
  return vnode;
27350
27502
  }
27351
27503
  static createText(flags, parent, previousSibling, nextSibling, textNode, text) {
27352
- const vnode = new VNode(flags, parent, previousSibling, nextSibling);
27353
- vnode.push(textNode, text);
27504
+ const vnode = new VNode(flags, parent, previousSibling, nextSibling, textNode, text);
27354
27505
  return vnode;
27355
27506
  }
27356
27507
  static createVirtual(flags, parent, previousSibling, nextSibling, firstChild, lastChild) {
27357
- const vnode = new VNode(flags, parent, previousSibling, nextSibling);
27358
- vnode.push(firstChild, lastChild);
27508
+ const vnode = new VNode(
27509
+ flags,
27510
+ parent,
27511
+ previousSibling,
27512
+ nextSibling,
27513
+ firstChild,
27514
+ lastChild,
27515
+ []
27516
+ );
27359
27517
  return vnode;
27360
27518
  }
27361
- constructor(flags, parent, previousSibling, nextSibling) {
27362
- super();
27363
- this.push(flags, parent, previousSibling, nextSibling);
27364
- if (isDev6) {
27519
+ constructor(flags, parent, previousSibling, nextSibling, ...rest) {
27520
+ super(flags, parent, previousSibling, nextSibling, ...rest);
27521
+ if (isDev7) {
27365
27522
  this.toString = vnode_toString;
27366
27523
  }
27367
27524
  }
@@ -27406,10 +27563,12 @@ function invokeApply(context, fn, args) {
27406
27563
  return returnValue;
27407
27564
  }
27408
27565
  var newInvokeContextFromTuple = ([element, event, url]) => {
27409
- const container = element.closest(QContainerSelector);
27566
+ const domContainer = getDomContainer(element);
27567
+ const container = domContainer.element;
27568
+ const vNode = container ? vnode_locate(domContainer.rootVNode, element) : void 0;
27410
27569
  const locale = container?.getAttribute(QLocaleAttr) || void 0;
27411
27570
  locale && setLocale(locale);
27412
- return newInvokeContext(locale, void 0, element, event, url);
27571
+ return newInvokeContext(locale, vNode, element, event, url);
27413
27572
  };
27414
27573
  var newInvokeContext = (locale, hostElement, element, event, url) => {
27415
27574
  const $locale$ = locale || (typeof event === "object" && event && "locale" in event ? event.locale : void 0);
@@ -27440,10 +27599,7 @@ var trackSignal = (fn, subscriber, property, container, data) => {
27440
27599
  const previousSubscriber = trackInvocation.$effectSubscriber$;
27441
27600
  const previousContainer = trackInvocation.$container$;
27442
27601
  try {
27443
- trackInvocation.$effectSubscriber$ = [subscriber, property];
27444
- if (data) {
27445
- trackInvocation.$effectSubscriber$.push(data);
27446
- }
27602
+ trackInvocation.$effectSubscriber$ = getSubscriber(subscriber, property, data);
27447
27603
  trackInvocation.$container$ = container;
27448
27604
  return invoke(trackInvocation, fn);
27449
27605
  } finally {
@@ -27804,9 +27960,9 @@ var DomContainer = class extends _SharedContainer {
27804
27960
  __publicField(this, "$storeProxyMap$", /* @__PURE__ */ new WeakMap());
27805
27961
  __publicField(this, "$qFuncs$");
27806
27962
  __publicField(this, "$instanceHash$");
27807
- __publicField(this, "stateData");
27963
+ __publicField(this, "vNodeLocate", (id) => vnode_locate(this.rootVNode, id));
27964
+ __publicField(this, "$stateData$");
27808
27965
  __publicField(this, "$styleIds$", null);
27809
- __publicField(this, "$vnodeLocate$", (id) => vnode_locate(this.rootVNode, id));
27810
27966
  __publicField(this, "$renderCount$", 0);
27811
27967
  __publicField(this, "$getObjectById$", (id) => {
27812
27968
  if (typeof id === "string") {
@@ -27816,7 +27972,7 @@ var DomContainer = class extends _SharedContainer {
27816
27972
  id < this.$rawStateData$.length / 2,
27817
27973
  `Invalid reference: ${id} >= ${this.$rawStateData$.length / 2}`
27818
27974
  );
27819
- return this.stateData[id];
27975
+ return this.$stateData$[id];
27820
27976
  });
27821
27977
  this.qContainer = element.getAttribute(QContainerAttr);
27822
27978
  if (!this.qContainer) {
@@ -27838,29 +27994,29 @@ var DomContainer = class extends _SharedContainer {
27838
27994
  this.qManifestHash = element.getAttribute("q:manifest-hash");
27839
27995
  this.rootVNode = vnode_newUnMaterializedElement(this.element);
27840
27996
  this.$rawStateData$ = null;
27841
- this.stateData = null;
27997
+ this.$stateData$ = null;
27842
27998
  const document2 = this.element.ownerDocument;
27843
27999
  if (!document2.qVNodeData) {
27844
28000
  processVNodeData2(document2);
27845
28001
  }
27846
28002
  this.$rawStateData$ = [];
27847
- this.stateData = [];
28003
+ this.$stateData$ = [];
27848
28004
  const qwikStates = element.querySelectorAll('script[type="qwik/state"]');
27849
28005
  if (qwikStates.length !== 0) {
27850
28006
  const lastState = qwikStates[qwikStates.length - 1];
27851
28007
  this.$rawStateData$ = JSON.parse(lastState.textContent);
27852
- this.stateData = wrapDeserializerProxy(this, this.$rawStateData$);
28008
+ this.$stateData$ = wrapDeserializerProxy(this, this.$rawStateData$);
27853
28009
  }
27854
28010
  this.$qFuncs$ = getQFuncs(document2, this.$instanceHash$) || EMPTY_ARRAY;
27855
28011
  }
27856
28012
  $setRawState$(id, vParent) {
27857
- this.stateData[id] = vParent;
28013
+ this.$stateData$[id] = vParent;
27858
28014
  }
27859
28015
  parseQRL(qrl2) {
27860
28016
  return inflateQRL(this, parseQRL(qrl2));
27861
28017
  }
27862
28018
  handleError(err, host) {
27863
- if (qDev) {
28019
+ if (qDev && host) {
27864
28020
  if (typeof document !== "undefined") {
27865
28021
  const vHost = host;
27866
28022
  const errorDiv = document.createElement("errored-host");
@@ -27883,7 +28039,7 @@ var DomContainer = class extends _SharedContainer {
27883
28039
  throw err;
27884
28040
  }
27885
28041
  }
27886
- const errorStore = this.resolveContext(host, ERROR_CONTEXT);
28042
+ const errorStore = host && this.resolveContext(host, ERROR_CONTEXT);
27887
28043
  if (!errorStore) {
27888
28044
  throw err;
27889
28045
  }
@@ -27917,7 +28073,7 @@ var DomContainer = class extends _SharedContainer {
27917
28073
  return vNode;
27918
28074
  }
27919
28075
  vNode = vnode_getParent(vNode) || // If virtual node, than it could be a slot so we need to read its parent.
27920
- vnode_getProp(vNode, QSlotParent, this.$vnodeLocate$);
28076
+ vnode_getProp(vNode, QSlotParent, this.vNodeLocate);
27921
28077
  } else {
27922
28078
  vNode = vnode_getParent(vNode);
27923
28079
  }
@@ -27936,7 +28092,7 @@ var DomContainer = class extends _SharedContainer {
27936
28092
  case ELEMENT_PROPS:
27937
28093
  case OnRenderProp:
27938
28094
  case QCtxAttr:
27939
- case QSubscribers:
28095
+ case QBackRefs:
27940
28096
  getObjectById = this.$getObjectById$;
27941
28097
  break;
27942
28098
  case ELEMENT_SEQ_IDX:
@@ -27949,7 +28105,9 @@ var DomContainer = class extends _SharedContainer {
27949
28105
  scheduleRender() {
27950
28106
  this.$renderCount$++;
27951
28107
  this.renderDone || (this.renderDone = getPlatform().nextTick(() => this.processChores()));
27952
- return this.renderDone;
28108
+ return this.renderDone.finally(
28109
+ () => emitEvent("qrender", { instanceHash: this.$instanceHash$, renderCount: this.$renderCount$ })
28110
+ );
27953
28111
  }
27954
28112
  processChores() {
27955
28113
  let renderCount = this.$renderCount$;
@@ -27972,12 +28130,13 @@ var DomContainer = class extends _SharedContainer {
27972
28130
  ensureProjectionResolved(vNode) {
27973
28131
  if ((vNode[0 /* flags */] & 16 /* Resolved */) === 0) {
27974
28132
  vNode[0 /* flags */] |= 16 /* Resolved */;
27975
- for (let i = vnode_getPropStartIndex(vNode); i < vNode.length; i = i + 2) {
27976
- const prop = vNode[i];
28133
+ const props = vnode_getProps(vNode);
28134
+ for (let i = 0; i < props.length; i = i + 2) {
28135
+ const prop = props[i];
27977
28136
  if (isSlotProp(prop)) {
27978
- const value = vNode[i + 1];
28137
+ const value = props[i + 1];
27979
28138
  if (typeof value == "string") {
27980
- vNode[i + 1] = this.$vnodeLocate$(value);
28139
+ props[i + 1] = this.vNodeLocate(value);
27981
28140
  }
27982
28141
  }
27983
28142
  }
@@ -28044,8 +28203,7 @@ var DeserializationHandler = class {
28044
28203
  }
28045
28204
  const i = typeof property === "number" ? property : typeof property === "string" ? parseInt(property, 10) : NaN;
28046
28205
  if (Number.isNaN(i) || i < 0 || i >= this.$length$) {
28047
- const out = Reflect.get(target, property, receiver);
28048
- return out;
28206
+ return Reflect.get(target, property, receiver);
28049
28207
  }
28050
28208
  const idx = i * 2;
28051
28209
  const typeId = this.$data$[idx];
@@ -28142,7 +28300,7 @@ var inflate = (container, target, typeId, data) => {
28142
28300
  task.$flags$ = v[1];
28143
28301
  task.$index$ = v[2];
28144
28302
  task.$el$ = v[3];
28145
- task.$effectDependencies$ = v[4];
28303
+ task[_EFFECT_BACK_REF] = v[4];
28146
28304
  task.$state$ = v[5];
28147
28305
  break;
28148
28306
  case 20 /* Resource */:
@@ -28164,12 +28322,9 @@ var inflate = (container, target, typeId, data) => {
28164
28322
  break;
28165
28323
  case 25 /* Store */:
28166
28324
  case 26 /* StoreArray */: {
28167
- const [value, flags, effects2, storeEffect] = data;
28325
+ const [value, flags, effects2] = data;
28168
28326
  const store = getOrCreateStore(value, flags, container);
28169
28327
  const storeHandler = getStoreHandler(store);
28170
- if (storeEffect) {
28171
- effects2[STORE_ARRAY_PROP] = storeEffect;
28172
- }
28173
28328
  storeHandler.$effects$ = effects2;
28174
28329
  target = store;
28175
28330
  break;
@@ -28178,7 +28333,7 @@ var inflate = (container, target, typeId, data) => {
28178
28333
  const signal = target;
28179
28334
  const d = data;
28180
28335
  signal.$untrackedValue$ = d[0];
28181
- signal.$effects$ = d.slice(1);
28336
+ signal.$effects$ = new Set(d.slice(1));
28182
28337
  break;
28183
28338
  }
28184
28339
  case 23 /* WrappedSignal */: {
@@ -28186,10 +28341,10 @@ var inflate = (container, target, typeId, data) => {
28186
28341
  const d = data;
28187
28342
  signal.$func$ = container.getSyncFn(d[0]);
28188
28343
  signal.$args$ = d[1];
28189
- signal.$effectDependencies$ = d[2];
28344
+ signal[_EFFECT_BACK_REF] = d[2];
28190
28345
  signal.$untrackedValue$ = d[3];
28191
28346
  signal.$hostElement$ = d[4];
28192
- signal.$effects$ = d.slice(5);
28347
+ signal.$effects$ = new Set(d.slice(5));
28193
28348
  break;
28194
28349
  }
28195
28350
  case 24 /* ComputedSignal */: {
@@ -28303,6 +28458,7 @@ var _constants = [
28303
28458
  EMPTY_ARRAY,
28304
28459
  EMPTY_OBJ,
28305
28460
  NEEDS_COMPUTATION,
28461
+ STORE_ARRAY_PROP,
28306
28462
  Slot,
28307
28463
  Fragment,
28308
28464
  NaN,
@@ -28321,6 +28477,7 @@ var _constantNames = [
28321
28477
  "EMPTY_ARRAY",
28322
28478
  "EMPTY_OBJ",
28323
28479
  "NEEDS_COMPUTATION",
28480
+ "STORE_ARRAY_PROP",
28324
28481
  "Slot",
28325
28482
  "Fragment",
28326
28483
  "NaN",
@@ -28402,6 +28559,8 @@ var allocate = (container, typeId, value) => {
28402
28559
  reject = rej;
28403
28560
  });
28404
28561
  resolvers.set(promise, [resolve, reject]);
28562
+ promise.catch(() => {
28563
+ });
28405
28564
  return promise;
28406
28565
  case 17 /* Uint8Array */:
28407
28566
  const encodedLength = value.length;
@@ -28411,12 +28570,9 @@ var allocate = (container, typeId, value) => {
28411
28570
  return new Uint8Array(decodedLength);
28412
28571
  case 29 /* PropsProxy */:
28413
28572
  return createPropsProxy(null, null);
28414
- case 9 /* RefVNode */:
28415
28573
  case 8 /* VNode */:
28416
- const vnodeOrDocument = retrieveVNodeOrDocument(container, value);
28417
- if (typeId === 8 /* VNode */) {
28418
- return vnodeOrDocument;
28419
- }
28574
+ return retrieveVNodeOrDocument(container, value);
28575
+ case 9 /* RefVNode */:
28420
28576
  const vNode = retrieveVNodeOrDocument(container, value);
28421
28577
  if (vnode_isVNode(vNode)) {
28422
28578
  return vnode_getNode(vNode);
@@ -28424,7 +28580,7 @@ var allocate = (container, typeId, value) => {
28424
28580
  throw qError(34 /* serializeErrorExpectedVNode */, [typeof vNode]);
28425
28581
  }
28426
28582
  case 30 /* EffectData */:
28427
- return new EffectPropData({});
28583
+ return new SubscriptionData({});
28428
28584
  default:
28429
28585
  throw qError(35 /* serializeErrorCannotAllocate */, [typeId]);
28430
28586
  }
@@ -28440,12 +28596,12 @@ function parseQRL(qrl2) {
28440
28596
  const symbol = captureStart > -1 ? qrl2.slice(hashIdx + 1, captureStart) : qrl2.slice(hashIdx + 1);
28441
28597
  const captureIds = captureStart > -1 && captureEnd > -1 ? qrl2.slice(captureStart + 1, captureEnd).split(" ").filter((v) => v.length).map((s) => parseInt(s, 10)) : null;
28442
28598
  let qrlRef = null;
28443
- if (isDev && chunk === QRL_RUNTIME_CHUNK) {
28599
+ if (isDev2 && chunk === QRL_RUNTIME_CHUNK) {
28444
28600
  const backChannel = globalThis[QRL_RUNTIME_CHUNK];
28445
28601
  assertDefined(backChannel, "Missing QRL_RUNTIME_CHUNK");
28446
28602
  qrlRef = backChannel.get(symbol);
28447
28603
  }
28448
- return createQRL(chunk, symbol, qrlRef, null, captureIds, null, null);
28604
+ return createQRL(chunk, symbol, qrlRef, null, captureIds, null);
28449
28605
  }
28450
28606
  function inflateQRL(container, qrl2) {
28451
28607
  const captureIds = qrl2.$capture$;
@@ -28479,13 +28635,13 @@ var createSerializationContext = (NodeConstructor, DomRefConstructor, symbolToCh
28479
28635
  }
28480
28636
  return id;
28481
28637
  };
28482
- const isSsrNode = NodeConstructor ? (obj) => obj instanceof NodeConstructor : () => false;
28638
+ const isSsrNode2 = NodeConstructor ? (obj) => obj instanceof NodeConstructor : () => false;
28483
28639
  isDomRef = DomRefConstructor ? (obj) => obj instanceof DomRefConstructor : () => false;
28484
28640
  return {
28485
28641
  $serialize$() {
28486
28642
  serialize(this);
28487
28643
  },
28488
- $isSsrNode$: isSsrNode,
28644
+ $isSsrNode$: isSsrNode2,
28489
28645
  $isDomRef$: isDomRef,
28490
28646
  $symbolToChunkResolver$: symbolToChunkResolver,
28491
28647
  $wasSeen$,
@@ -28541,7 +28697,7 @@ var createSerializationContext = (NodeConstructor, DomRefConstructor, symbolToCh
28541
28697
  const promises = [];
28542
28698
  const visit = (obj) => {
28543
28699
  if (typeof obj === "function") {
28544
- if (isQrl2(obj)) {
28700
+ if (isQrl(obj)) {
28545
28701
  if (obj.$captureRef$) {
28546
28702
  discoveredValues.push(...obj.$captureRef$);
28547
28703
  }
@@ -28551,7 +28707,7 @@ var createSerializationContext = (NodeConstructor, DomRefConstructor, symbolToCh
28551
28707
  }
28552
28708
  } else if (
28553
28709
  // skip as these are primitives
28554
- typeof obj !== "object" || obj === null || obj instanceof URL || obj instanceof Date || obj instanceof RegExp || obj instanceof Uint8Array || obj instanceof URLSearchParams || typeof FormData !== "undefined" && obj instanceof FormData || // Ignore the no serialize objects
28710
+ typeof obj !== "object" || obj === null || obj instanceof URL || obj instanceof Date || obj instanceof RegExp || obj instanceof Uint8Array || obj instanceof URLSearchParams || vnode_isVNode(obj) || typeof FormData !== "undefined" && obj instanceof FormData || // Ignore the no serialize objects
28555
28711
  fastSkipSerialize(obj)
28556
28712
  ) {
28557
28713
  } else if (obj instanceof Error) {
@@ -28559,8 +28715,7 @@ var createSerializationContext = (NodeConstructor, DomRefConstructor, symbolToCh
28559
28715
  } else if (isStore(obj)) {
28560
28716
  const target = getStoreTarget(obj);
28561
28717
  const effects = getStoreHandler(obj).$effects$;
28562
- const storeEffect = effects?.[STORE_ARRAY_PROP] ?? null;
28563
- discoveredValues.push(target, effects, storeEffect);
28718
+ discoveredValues.push(target, effects);
28564
28719
  for (const prop in target) {
28565
28720
  const propValue = target[prop];
28566
28721
  if (storeProxyMap.has(propValue)) {
@@ -28582,9 +28737,7 @@ var createSerializationContext = (NodeConstructor, DomRefConstructor, symbolToCh
28582
28737
  discoveredValues.push(...obj.$effects$);
28583
28738
  }
28584
28739
  if (obj instanceof WrappedSignal) {
28585
- if (obj.$effectDependencies$) {
28586
- discoveredValues.push(...obj.$effectDependencies$);
28587
- }
28740
+ discoverEffectBackRefs(obj[_EFFECT_BACK_REF], discoveredValues);
28588
28741
  if (obj.$args$) {
28589
28742
  discoveredValues.push(...obj.$args$);
28590
28743
  }
@@ -28595,8 +28748,9 @@ var createSerializationContext = (NodeConstructor, DomRefConstructor, symbolToCh
28595
28748
  discoveredValues.push(obj.$computeQrl$);
28596
28749
  }
28597
28750
  } else if (obj instanceof Task) {
28598
- discoveredValues.push(obj.$el$, obj.$qrl$, obj.$state$, obj.$effectDependencies$);
28599
- } else if (isSsrNode(obj)) {
28751
+ discoveredValues.push(obj.$el$, obj.$qrl$, obj.$state$);
28752
+ discoverEffectBackRefs(obj[_EFFECT_BACK_REF], discoveredValues);
28753
+ } else if (isSsrNode2(obj)) {
28600
28754
  discoverValuesForVNodeData(obj.vnodeData, discoveredValues);
28601
28755
  if (obj.childrenVNodeData && obj.childrenVNodeData.length) {
28602
28756
  for (const data of obj.childrenVNodeData) {
@@ -28609,7 +28763,7 @@ var createSerializationContext = (NodeConstructor, DomRefConstructor, symbolToCh
28609
28763
  discoveredValues.push(obj.type, obj.props, obj.constProps, obj.children);
28610
28764
  } else if (Array.isArray(obj)) {
28611
28765
  discoveredValues.push(...obj);
28612
- } else if (isQrl2(obj)) {
28766
+ } else if (isQrl(obj)) {
28613
28767
  obj.$captureRef$ && obj.$captureRef$.length && discoveredValues.push(...obj.$captureRef$);
28614
28768
  } else if (isPropsProxy(obj)) {
28615
28769
  discoveredValues.push(obj[_VAR_PROPS], obj[_CONST_PROPS]);
@@ -28625,7 +28779,7 @@ var createSerializationContext = (NodeConstructor, DomRefConstructor, symbolToCh
28625
28779
  }
28626
28780
  );
28627
28781
  promises.push(obj);
28628
- } else if (obj instanceof EffectPropData) {
28782
+ } else if (obj instanceof SubscriptionData) {
28629
28783
  discoveredValues.push(obj.data);
28630
28784
  } else if (isObjectLiteral(obj)) {
28631
28785
  Object.entries(obj).forEach(([key, value]) => {
@@ -28662,15 +28816,30 @@ var discoverValuesForVNodeData = (vnodeData, discoveredValues) => {
28662
28816
  for (const value of vnodeData) {
28663
28817
  if (isSsrAttrs(value)) {
28664
28818
  for (let i = 1; i < value.length; i += 2) {
28665
- if (value[i - 1] === ELEMENT_KEY) {
28819
+ const attrValue = value[i];
28820
+ if (typeof attrValue === "string") {
28666
28821
  continue;
28667
28822
  }
28668
- const attrValue = value[i];
28669
28823
  discoveredValues.push(attrValue);
28670
28824
  }
28671
28825
  }
28672
28826
  }
28673
28827
  };
28828
+ var discoverEffectBackRefs = (effectsBackRefs, discoveredValues) => {
28829
+ if (effectsBackRefs) {
28830
+ let hasBackRefs = false;
28831
+ for (const [, effect] of effectsBackRefs) {
28832
+ const backRefs = effect[2 /* BACK_REF */];
28833
+ if (backRefs) {
28834
+ hasBackRefs = true;
28835
+ break;
28836
+ }
28837
+ }
28838
+ if (hasBackRefs) {
28839
+ discoveredValues.push(effectsBackRefs);
28840
+ }
28841
+ }
28842
+ };
28674
28843
  var promiseResults = /* @__PURE__ */ new WeakMap();
28675
28844
  function serialize(serializationContext) {
28676
28845
  const { $writer$, $isSsrNode$, $isDomRef$, $setProp$, $storeProxyMap$ } = serializationContext;
@@ -28719,10 +28888,10 @@ function serialize(serializationContext) {
28719
28888
  output(1 /* Constant */, value ? 2 /* True */ : 3 /* False */);
28720
28889
  } else if (typeof value === "function") {
28721
28890
  if (value === Slot) {
28722
- output(1 /* Constant */, 8 /* Slot */);
28891
+ output(1 /* Constant */, 9 /* Slot */);
28723
28892
  } else if (value === Fragment) {
28724
- output(1 /* Constant */, 9 /* Fragment */);
28725
- } else if (isQrl2(value)) {
28893
+ output(1 /* Constant */, 10 /* Fragment */);
28894
+ } else if (isQrl(value)) {
28726
28895
  const qrl2 = qrlToString(serializationContext, value);
28727
28896
  const id = serializationContext.$addRoot$(qrl2);
28728
28897
  output(18 /* QRL */, id);
@@ -28736,18 +28905,18 @@ function serialize(serializationContext) {
28736
28905
  }
28737
28906
  } else if (typeof value === "number") {
28738
28907
  if (Number.isNaN(value)) {
28739
- output(1 /* Constant */, 10 /* NaN */);
28908
+ output(1 /* Constant */, 11 /* NaN */);
28740
28909
  } else if (!Number.isFinite(value)) {
28741
28910
  output(
28742
28911
  1 /* Constant */,
28743
- value < 0 ? 12 /* NegativeInfinity */ : 11 /* PositiveInfinity */
28912
+ value < 0 ? 13 /* NegativeInfinity */ : 12 /* PositiveInfinity */
28744
28913
  );
28745
28914
  } else if (value === Number.MAX_SAFE_INTEGER) {
28746
- output(1 /* Constant */, 13 /* MaxSafeInt */);
28915
+ output(1 /* Constant */, 14 /* MaxSafeInt */);
28747
28916
  } else if (value === Number.MAX_SAFE_INTEGER - 1) {
28748
- output(1 /* Constant */, 14 /* AlmostMaxSafeInt */);
28917
+ output(1 /* Constant */, 15 /* AlmostMaxSafeInt */);
28749
28918
  } else if (value === Number.MIN_SAFE_INTEGER) {
28750
- output(1 /* Constant */, 15 /* MinSafeInt */);
28919
+ output(1 /* Constant */, 16 /* MinSafeInt */);
28751
28920
  } else {
28752
28921
  output(2 /* Number */, value);
28753
28922
  }
@@ -28780,6 +28949,8 @@ function serialize(serializationContext) {
28780
28949
  output(1 /* Constant */, 0 /* Undefined */);
28781
28950
  } else if (value === NEEDS_COMPUTATION) {
28782
28951
  output(1 /* Constant */, 7 /* NEEDS_COMPUTATION */);
28952
+ } else if (value === STORE_ARRAY_PROP) {
28953
+ output(1 /* Constant */, 8 /* STORE_ARRAY_PROP */);
28783
28954
  } else {
28784
28955
  throw qError(37 /* serializeErrorUnknownType */, [typeof value]);
28785
28956
  }
@@ -28798,7 +28969,7 @@ function serialize(serializationContext) {
28798
28969
  const constProps = value[_CONST_PROPS];
28799
28970
  const out = constProps ? [varProps, constProps] : Object.keys(varProps).length ? [varProps] : 0;
28800
28971
  output(29 /* PropsProxy */, out);
28801
- } else if (value instanceof EffectPropData) {
28972
+ } else if (value instanceof SubscriptionData) {
28802
28973
  output(30 /* EffectData */, [value.data.$scopedStyleIdPrefix$, value.data.$isConst$]);
28803
28974
  } else if (isStore(value)) {
28804
28975
  if (isResource(value)) {
@@ -28813,7 +28984,6 @@ function serialize(serializationContext) {
28813
28984
  const storeTarget = getStoreTarget(value);
28814
28985
  const flags = storeHandler.$flags$;
28815
28986
  const effects = storeHandler.$effects$;
28816
- const storeEffect = effects?.[STORE_ARRAY_PROP] ?? null;
28817
28987
  const innerStores = [];
28818
28988
  for (const prop in storeTarget) {
28819
28989
  const propValue = storeTarget[prop];
@@ -28823,7 +28993,7 @@ function serialize(serializationContext) {
28823
28993
  serializationContext.$addRoot$(innerStore);
28824
28994
  }
28825
28995
  }
28826
- const out = [storeTarget, flags, effects, storeEffect, ...innerStores];
28996
+ const out = [storeTarget, flags, effects, ...innerStores];
28827
28997
  while (out[out.length - 1] == null) {
28828
28998
  out.pop();
28829
28999
  }
@@ -28849,7 +29019,7 @@ function serialize(serializationContext) {
28849
29019
  if (value instanceof WrappedSignal) {
28850
29020
  output(23 /* WrappedSignal */, [
28851
29021
  ...serializeWrappingFn(serializationContext, value),
28852
- value.$effectDependencies$,
29022
+ filterEffectBackRefs(value[_EFFECT_BACK_REF]),
28853
29023
  v,
28854
29024
  value.$hostElement$,
28855
29025
  ...value.$effects$ || []
@@ -28879,7 +29049,7 @@ function serialize(serializationContext) {
28879
29049
  if (extraProps.length) {
28880
29050
  out.push(extraProps);
28881
29051
  }
28882
- if (isDev) {
29052
+ if (isDev2) {
28883
29053
  out.push(value.stack);
28884
29054
  }
28885
29055
  output(12 /* Error */, out);
@@ -28936,7 +29106,7 @@ function serialize(serializationContext) {
28936
29106
  value.$flags$,
28937
29107
  value.$index$,
28938
29108
  value.$el$,
28939
- value.$effectDependencies$,
29109
+ value[_EFFECT_BACK_REF],
28940
29110
  value.$state$
28941
29111
  ];
28942
29112
  while (out[out.length - 1] == null) {
@@ -28956,12 +29126,26 @@ function serialize(serializationContext) {
28956
29126
  }
28957
29127
  const out = btoa(buf).replace(/=+$/, "");
28958
29128
  output(17 /* Uint8Array */, out);
29129
+ } else if (vnode_isVNode(value)) {
29130
+ output(1 /* Constant */, 0 /* Undefined */);
28959
29131
  } else {
28960
29132
  throw qError(37 /* serializeErrorUnknownType */, [typeof value]);
28961
29133
  }
28962
29134
  };
28963
29135
  writeValue(serializationContext.$roots$, -1);
28964
29136
  }
29137
+ function filterEffectBackRefs(effectBackRef) {
29138
+ let effectBackRefToSerialize = null;
29139
+ if (effectBackRef) {
29140
+ for (const [effectProp, effect] of effectBackRef) {
29141
+ if (effect[2 /* BACK_REF */]) {
29142
+ effectBackRefToSerialize || (effectBackRefToSerialize = /* @__PURE__ */ new Map());
29143
+ effectBackRefToSerialize.set(effectProp, effect);
29144
+ }
29145
+ }
29146
+ }
29147
+ return effectBackRefToSerialize;
29148
+ }
28965
29149
  function serializeWrappingFn(serializationContext, value) {
28966
29150
  if (value.$funcStr$ && value.$funcStr$[0] === "{") {
28967
29151
  value.$funcStr$ = `(${value.$funcStr$})`;
@@ -28976,15 +29160,12 @@ function serializeWrappingFn(serializationContext, value) {
28976
29160
  function qrlToString(serializationContext, value) {
28977
29161
  let symbol = value.$symbol$;
28978
29162
  let chunk = value.$chunk$;
28979
- const refSymbol = value.$refSymbol$ ?? symbol;
28980
29163
  const platform = getPlatform();
28981
29164
  if (platform) {
28982
- const result = platform.chunkForSymbol(refSymbol, chunk, value.dev?.file);
29165
+ const result = platform.chunkForSymbol(symbol, chunk, value.dev?.file);
28983
29166
  if (result) {
28984
29167
  chunk = result[1];
28985
- if (!value.$refSymbol$) {
28986
- symbol = result[0];
28987
- }
29168
+ symbol = result[0];
28988
29169
  }
28989
29170
  }
28990
29171
  const isSync = isSyncQrl(value);
@@ -28992,7 +29173,7 @@ function qrlToString(serializationContext, value) {
28992
29173
  if (!chunk) {
28993
29174
  chunk = serializationContext.$symbolToChunkResolver$(value.$hash$);
28994
29175
  }
28995
- if (isDev) {
29176
+ if (isDev2) {
28996
29177
  let backChannel = globalThis[QRL_RUNTIME_CHUNK];
28997
29178
  if (!backChannel) {
28998
29179
  backChannel = globalThis[QRL_RUNTIME_CHUNK] = /* @__PURE__ */ new Map();
@@ -29058,26 +29239,33 @@ function isResource(value) {
29058
29239
  return "__brand" in value && value.__brand === "resource";
29059
29240
  }
29060
29241
  var frameworkType = (obj) => {
29061
- return typeof obj === "object" && obj !== null && (obj instanceof Signal || obj instanceof Task || isJSXNode(obj)) || isQrl2(obj);
29242
+ return typeof obj === "object" && obj !== null && (obj instanceof Signal || obj instanceof Task || isJSXNode(obj)) || isQrl(obj);
29062
29243
  };
29063
- var canSerialize = (value) => {
29244
+ var canSerialize = (value, seen = /* @__PURE__ */ new WeakSet()) => {
29064
29245
  if (value == null || typeof value === "string" || typeof value === "number" || typeof value === "boolean" || typeof value === "bigint") {
29065
29246
  return true;
29066
29247
  } else if (typeof value === "object") {
29248
+ if (seen.has(value)) {
29249
+ return true;
29250
+ }
29251
+ seen.add(value);
29067
29252
  const proto = Object.getPrototypeOf(value);
29068
29253
  if (isStore(value)) {
29069
29254
  value = getStoreTarget(value);
29070
29255
  }
29071
29256
  if (proto == Object.prototype) {
29072
29257
  for (const key in value) {
29073
- if (!canSerialize(untrack(() => value[key]))) {
29258
+ if (!canSerialize(
29259
+ untrack(() => value[key]),
29260
+ seen
29261
+ )) {
29074
29262
  return false;
29075
29263
  }
29076
29264
  }
29077
29265
  return true;
29078
29266
  } else if (proto == Array.prototype) {
29079
29267
  for (let i = 0; i < value.length; i++) {
29080
- if (!canSerialize(value[i])) {
29268
+ if (!canSerialize(value[i], seen)) {
29081
29269
  return false;
29082
29270
  }
29083
29271
  }
@@ -29112,7 +29300,7 @@ var canSerialize = (value) => {
29112
29300
  return true;
29113
29301
  }
29114
29302
  } else if (typeof value === "function") {
29115
- if (isQrl2(value) || isQwikComponent(value)) {
29303
+ if (isQrl(value) || isQwikComponent(value)) {
29116
29304
  return true;
29117
29305
  }
29118
29306
  }
@@ -29230,7 +29418,7 @@ var constantToName = (code2) => {
29230
29418
 
29231
29419
  // packages/qwik/src/core/shared/utils/serialize-utils.ts
29232
29420
  var verifySerializable = (value, preMessage) => {
29233
- const seen = /* @__PURE__ */ new Set();
29421
+ const seen = /* @__PURE__ */ new WeakSet();
29234
29422
  return _verifySerializable(value, seen, "_", preMessage);
29235
29423
  };
29236
29424
  var _verifySerializable = (value, seen, ctx, preMessage) => {
@@ -29239,10 +29427,12 @@ var _verifySerializable = (value, seen, ctx, preMessage) => {
29239
29427
  return value;
29240
29428
  }
29241
29429
  if (shouldSerialize(unwrapped)) {
29242
- if (seen.has(unwrapped)) {
29243
- return value;
29430
+ if (typeof unwrapped === "object") {
29431
+ if (seen.has(unwrapped)) {
29432
+ return value;
29433
+ }
29434
+ seen.add(unwrapped);
29244
29435
  }
29245
- seen.add(unwrapped);
29246
29436
  if (isSignal(unwrapped)) {
29247
29437
  return value;
29248
29438
  }
@@ -29324,14 +29514,7 @@ var noSerialize = (input) => {
29324
29514
  };
29325
29515
 
29326
29516
  // packages/qwik/src/core/shared/qrl/qrl-class.ts
29327
- var isQrl2 = (value) => {
29328
- return typeof value === "function" && typeof value.getSymbol === "function";
29329
- };
29330
- var SYNC_QRL = "<sync>";
29331
- var isSyncQrl = (value) => {
29332
- return isQrl2(value) && value.$symbol$ == SYNC_QRL;
29333
- };
29334
- var createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef, refSymbol) => {
29517
+ var createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef) => {
29335
29518
  if (qDev && qSerialize) {
29336
29519
  if (captureRef) {
29337
29520
  for (const item of captureRef) {
@@ -29352,9 +29535,14 @@ var createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef, refSym
29352
29535
  return _containerEl;
29353
29536
  };
29354
29537
  function bindFnToContext(currentCtx, beforeFn) {
29355
- return (...args) => maybeThen(resolveLazy(), (fn) => {
29356
- if (!isFunction(fn)) {
29357
- throw qError(10 /* qrlIsNotFunction */);
29538
+ const bound = (...args) => {
29539
+ if (!qrl2.resolved) {
29540
+ return qrl2.resolve().then((fn) => {
29541
+ if (!isFunction(fn)) {
29542
+ throw qError(10 /* qrlIsNotFunction */);
29543
+ }
29544
+ return bound(...args);
29545
+ });
29358
29546
  }
29359
29547
  if (beforeFn && beforeFn() === false) {
29360
29548
  return;
@@ -29365,12 +29553,13 @@ var createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef, refSym
29365
29553
  context.$qrl$ = qrl2;
29366
29554
  context.$event$ || (context.$event$ = this);
29367
29555
  try {
29368
- return invoke.call(this, context, fn, ...args);
29556
+ return invoke.call(this, context, symbolRef, ...args);
29369
29557
  } finally {
29370
29558
  context.$qrl$ = prevQrl;
29371
29559
  context.$event$ = prevEvent;
29372
29560
  }
29373
- });
29561
+ };
29562
+ return bound;
29374
29563
  }
29375
29564
  const resolveLazy = (containerEl) => {
29376
29565
  return symbolRef !== null ? symbolRef : resolve(containerEl);
@@ -29382,7 +29571,16 @@ var createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef, refSym
29382
29571
  return function(...args) {
29383
29572
  let context = tryGetInvokeContext();
29384
29573
  if (context) {
29385
- return fn.apply(this, args);
29574
+ if (context.$qrl$?.$symbol$ === qrl2.$symbol$) {
29575
+ return fn.apply(this, args);
29576
+ }
29577
+ const prevQrl = context.$qrl$;
29578
+ context.$qrl$ = qrl2;
29579
+ try {
29580
+ return fn.apply(this, args);
29581
+ } finally {
29582
+ context.$qrl$ = prevQrl;
29583
+ }
29386
29584
  }
29387
29585
  context = newInvokeContext();
29388
29586
  context.$qrl$ = qrl2;
@@ -29407,10 +29605,12 @@ var createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef, refSym
29407
29605
  const start = now();
29408
29606
  const ctx = tryGetInvokeContext();
29409
29607
  if (symbolFn !== null) {
29410
- symbolRef = symbolFn().then((module) => qrl2.resolved = symbolRef = wrapFn(module[symbol]));
29608
+ symbolRef = symbolFn().then(
29609
+ (module) => qrl2.resolved = wrapFn(symbolRef = module[symbol])
29610
+ );
29411
29611
  } else {
29412
29612
  const imported = getPlatform().importSymbol(_containerEl, chunk, symbol);
29413
- symbolRef = maybeThen(imported, (ref) => qrl2.resolved = symbolRef = wrapFn(ref));
29613
+ symbolRef = maybeThen(imported, (ref) => qrl2.resolved = wrapFn(symbolRef = ref));
29414
29614
  }
29415
29615
  if (typeof symbolRef === "object" && isPromise(symbolRef)) {
29416
29616
  symbolRef.then(
@@ -29433,10 +29633,9 @@ var createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef, refSym
29433
29633
  return invoke2;
29434
29634
  }
29435
29635
  };
29436
- const resolvedSymbol = refSymbol ?? symbol;
29437
- const hash3 = getSymbolHash(resolvedSymbol);
29636
+ const hash3 = getSymbolHash(symbol);
29438
29637
  Object.assign(qrl2, {
29439
- getSymbol: () => resolvedSymbol,
29638
+ getSymbol: () => symbol,
29440
29639
  getHash: () => hash3,
29441
29640
  getCaptured: () => captureRef,
29442
29641
  resolve,
@@ -29444,7 +29643,6 @@ var createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef, refSym
29444
29643
  $setContainer$: setContainer,
29445
29644
  $chunk$: chunk,
29446
29645
  $symbol$: symbol,
29447
- $refSymbol$: refSymbol,
29448
29646
  $hash$: hash3,
29449
29647
  getFn: bindFnToContext,
29450
29648
  $capture$: capture,
@@ -29453,9 +29651,9 @@ var createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef, refSym
29453
29651
  resolved: void 0
29454
29652
  });
29455
29653
  if (symbolRef) {
29456
- symbolRef = maybeThen(symbolRef, (resolved) => qrl2.resolved = symbolRef = wrapFn(resolved));
29654
+ symbolRef = maybeThen(symbolRef, (resolved) => qrl2.resolved = wrapFn(symbolRef = resolved));
29457
29655
  }
29458
- if (isDev7) {
29656
+ if (isDev8) {
29459
29657
  Object.defineProperty(qrl2, "_devOnlySymbolRef", {
29460
29658
  get() {
29461
29659
  return symbolRef;
@@ -29467,20 +29665,6 @@ var createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef, refSym
29467
29665
  }
29468
29666
  return qrl2;
29469
29667
  };
29470
- var getSymbolHash = (symbolName) => {
29471
- const index = symbolName.lastIndexOf("_");
29472
- if (index > -1) {
29473
- return symbolName.slice(index + 1);
29474
- }
29475
- return symbolName;
29476
- };
29477
- function assertQrl(qrl2) {
29478
- if (qDev) {
29479
- if (!isQrl2(qrl2)) {
29480
- throw new Error("Not a QRL");
29481
- }
29482
- }
29483
- }
29484
29668
  var EMITTED = /* @__PURE__ */ new Set();
29485
29669
  var emitUsedSymbol = (symbol, element, reqTime) => {
29486
29670
  if (!EMITTED.has(symbol)) {
@@ -29520,7 +29704,7 @@ var $ = (expression) => {
29520
29704
  "Optimizer should replace all usages of $() with some special syntax. If you need to create a QRL manually, use inlinedQrl() instead."
29521
29705
  );
29522
29706
  }
29523
- return createQRL(null, "s" + runtimeSymbolId++, expression, null, null, null, null);
29707
+ return createQRL(null, "s" + runtimeSymbolId++, expression, null, null, null);
29524
29708
  };
29525
29709
  var dollar = $;
29526
29710
  var eventQrl = (qrl2) => {
@@ -29547,9 +29731,6 @@ var isQwikComponent = (component) => {
29547
29731
  return typeof component == "function" && component[SERIALIZABLE_STATE] !== void 0;
29548
29732
  };
29549
29733
 
29550
- // packages/qwik/src/core/index.ts
29551
- import { isBrowser as isBrowser2, isDev as isDev9, isServer as isServer3 } from "@qwik.dev/core/build";
29552
-
29553
29734
  // packages/qwik/src/core/shared/qrl/qrl.public.dollar.ts
29554
29735
  var event$ = implicit$FirstArg(eventQrl);
29555
29736
 
@@ -29736,9 +29917,6 @@ var useComputedQrl = (qrl2) => {
29736
29917
  // packages/qwik/src/core/use/use-computed-dollar.ts
29737
29918
  var useComputed$ = implicit$FirstArg(useComputedQrl);
29738
29919
 
29739
- // packages/qwik/src/core/shared/prefetch-service-worker/prefetch.ts
29740
- import { isDev as isDev8 } from "@qwik.dev/core/build";
29741
-
29742
29920
  // packages/qwik/src/testing/vdom-diff.unit-util.ts
29743
29921
  import { expect } from "vitest";
29744
29922
  import { format } from "prettier";
@@ -29851,7 +30029,7 @@ expect.extend({
29851
30029
  };
29852
30030
  }
29853
30031
  });
29854
- var ignoredAttributes = [QSubscribers, ELEMENT_ID, "", Q_PROPS_SEPARATOR];
30032
+ var ignoredAttributes = [QBackRefs, ELEMENT_ID, "", Q_PROPS_SEPARATOR];
29855
30033
  function getContainerElement(vNode) {
29856
30034
  let maybeParent;
29857
30035
  do {
@@ -30279,7 +30457,6 @@ function attrsEqual(expectedValue, receivedValue) {
30279
30457
  }
30280
30458
 
30281
30459
  // packages/qwik/src/testing/element-fixture.ts
30282
- import { vi } from "vitest";
30283
30460
  import { getDomContainer as getDomContainer2 } from "../core.mjs";
30284
30461
 
30285
30462
  // packages/qwik/src/testing/platform.ts
@@ -30457,7 +30634,6 @@ var dispatch = async (element, attrName, event, scope) => {
30457
30634
  const isDocumentOrWindow = isDocumentOrWindowEvent(event.type);
30458
30635
  const preventAttributeName = PREVENT_DEFAULT + (isDocumentOrWindow ? event.type.substring(1) : event.type);
30459
30636
  const stopPropagationName = STOP_PROPAGATION + event.type;
30460
- const collectListeners = [];
30461
30637
  while (element) {
30462
30638
  const preventDefault = element.hasAttribute(preventAttributeName);
30463
30639
  const stopPropagation = element.hasAttribute(stopPropagationName);
@@ -30474,15 +30650,21 @@ var dispatch = async (element, attrName, event, scope) => {
30474
30650
  } else if (element.hasAttribute(attrName)) {
30475
30651
  const container = getDomContainer2(element);
30476
30652
  const qrl2 = element.getAttribute(attrName);
30477
- qrl2.split("\n").map((qrl3) => container.parseQRL(qrl3.trim())).map((qrl3) => qrl3(event, element));
30653
+ const ctx = newInvokeContextFromTuple([element, event]);
30654
+ try {
30655
+ await Promise.all(
30656
+ qrl2.split("\n").map((qrl3) => container.parseQRL(qrl3.trim())).map((qrl3) => {
30657
+ return invokeApply(ctx, qrl3, [event, element]);
30658
+ })
30659
+ );
30660
+ } catch (error) {
30661
+ console.error("!!! qrl error", qrl2, error);
30662
+ throw error;
30663
+ }
30478
30664
  return;
30479
30665
  }
30480
30666
  element = element.parentElement;
30481
30667
  }
30482
- for (let i = 0; i < collectListeners.length; i++) {
30483
- const { element: element2, qrl: qrl2 } = collectListeners[i];
30484
- await qrl2.getFn([element2, event], () => element2.isConnected)(event, element2);
30485
- }
30486
30668
  };
30487
30669
 
30488
30670
  // packages/qwik/src/testing/library.ts
@@ -30527,7 +30709,21 @@ import { expect as expect2 } from "vitest";
30527
30709
 
30528
30710
  // packages/qwik/src/server/platform.ts
30529
30711
  import { setPlatform as setPlatform2 } from "../core.mjs";
30530
- var SYNC_QRL2 = "<sync>";
30712
+
30713
+ // packages/qwik/src/optimizer/src/versions.ts
30714
+ var versions2 = {
30715
+ qwik: globalThis.QWIK_VERSION
30716
+ };
30717
+
30718
+ // packages/qwik/src/optimizer/src/manifest.ts
30719
+ function getValidManifest(manifest) {
30720
+ if (manifest != null && manifest.mapping != null && typeof manifest.mapping === "object" && manifest.symbols != null && typeof manifest.symbols === "object" && manifest.bundles != null && typeof manifest.bundles === "object") {
30721
+ return manifest;
30722
+ }
30723
+ return void 0;
30724
+ }
30725
+
30726
+ // packages/qwik/src/server/platform.ts
30531
30727
  function createPlatform3(opts, resolvedManifest) {
30532
30728
  const mapper = resolvedManifest?.mapper;
30533
30729
  const mapperFn = opts.symbolMapper ? opts.symbolMapper : (symbolName, _chunk, parent) => {
@@ -30535,7 +30731,7 @@ function createPlatform3(opts, resolvedManifest) {
30535
30731
  const hash3 = getSymbolHash2(symbolName);
30536
30732
  const result = mapper[hash3];
30537
30733
  if (!result) {
30538
- if (hash3 === SYNC_QRL2) {
30734
+ if (hash3 === SYNC_QRL) {
30539
30735
  return [hash3, ""];
30540
30736
  }
30541
30737
  const isRegistered = globalThis.__qwik_reg_symbols?.has(hash3);
@@ -30597,19 +30793,6 @@ var getSymbolHash2 = (symbolName) => {
30597
30793
  return symbolName;
30598
30794
  };
30599
30795
 
30600
- // packages/qwik/src/optimizer/src/versions.ts
30601
- var versions2 = {
30602
- qwik: globalThis.QWIK_VERSION
30603
- };
30604
-
30605
- // packages/qwik/src/optimizer/src/manifest.ts
30606
- function getValidManifest(manifest) {
30607
- if (manifest != null && manifest.mapping != null && typeof manifest.mapping === "object" && manifest.symbols != null && typeof manifest.symbols === "object" && manifest.bundles != null && typeof manifest.bundles === "object") {
30608
- return manifest;
30609
- }
30610
- return void 0;
30611
- }
30612
-
30613
30796
  // packages/qwik/src/server/ssr-container.ts
30614
30797
  import {
30615
30798
  _EffectData as EffectData,
@@ -30619,7 +30802,7 @@ import {
30619
30802
  _walkJSX as _walkJSX2,
30620
30803
  isSignal as isSignal3
30621
30804
  } from "../core.mjs";
30622
- import { isDev as isDev11 } from "@qwik.dev/core/build";
30805
+ import { isDev as isDev10 } from "@qwik.dev/core/build";
30623
30806
 
30624
30807
  // packages/qwik/src/server/prefetch-utils.ts
30625
30808
  function workerFetchScript() {
@@ -30637,7 +30820,8 @@ function prefetchUrlsEventScript(base, prefetchResources) {
30637
30820
  bundles: flattenPrefetchResources(prefetchResources).map((u) => u.split("/").pop())
30638
30821
  };
30639
30822
  const args = JSON.stringify(["prefetch", base, ...data.bundles]);
30640
- return `(window.qwikPrefetchSW||(window.qwikPrefetchSW=[])).push(${args});`;
30823
+ return `document.dispatchEvent(new CustomEvent("qprefetch",{detail:${JSON.stringify(data)}}));
30824
+ (window.qwikPrefetchSW||(window.qwikPrefetchSW=[])).push(${args});`;
30641
30825
  }
30642
30826
  function flattenPrefetchResources(prefetchResources) {
30643
30827
  const urls = [];
@@ -30795,8 +30979,12 @@ var PrefetchImplementationDefault = {
30795
30979
  };
30796
30980
 
30797
30981
  // packages/qwik/src/server/ssr-node.ts
30798
- import { _isJSXNode as isJSXNode2, _EMPTY_ARRAY } from "../core.mjs";
30799
- import { isDev as isDev10 } from "@qwik.dev/core/build";
30982
+ import {
30983
+ _isJSXNode as isJSXNode2,
30984
+ _EMPTY_ARRAY,
30985
+ _EFFECT_BACK_REF as _EFFECT_BACK_REF2
30986
+ } from "../core.mjs";
30987
+ import { isDev as isDev9 } from "@qwik.dev/core/build";
30800
30988
  var SsrNode = class {
30801
30989
  constructor(currentComponentNode, nodeType, id, attrs, cleanupQueue, vnodeData) {
30802
30990
  this.attrs = attrs;
@@ -30819,10 +31007,13 @@ var SsrNode = class {
30819
31007
  this.currentComponentNode?.addChildVNodeData(this.vnodeData);
30820
31008
  this.nodeType = nodeType;
30821
31009
  this.id = id;
30822
- if (isDev10 && id.indexOf("undefined") != -1) {
31010
+ if (isDev9 && id.indexOf("undefined") != -1) {
30823
31011
  throw new Error(`Invalid SSR node id: ${id}`);
30824
31012
  }
30825
31013
  }
31014
+ get [_EFFECT_BACK_REF2]() {
31015
+ return this.getProp(QBackRefs);
31016
+ }
30826
31017
  setProp(name, value) {
30827
31018
  if (this.attrs === _EMPTY_ARRAY) {
30828
31019
  this.attrs = [];
@@ -31365,7 +31556,13 @@ var EMPTY_OBJ2 = {};
31365
31556
  var SSRContainer = class extends _SharedContainer2 {
31366
31557
  constructor(opts) {
31367
31558
  super(
31368
- () => null,
31559
+ () => {
31560
+ try {
31561
+ return this.$scheduler$(255 /* WAIT_FOR_ALL */);
31562
+ } catch (e) {
31563
+ this.handleError(e, null);
31564
+ }
31565
+ },
31369
31566
  () => null,
31370
31567
  opts.renderOptions.serverData ?? EMPTY_OBJ2,
31371
31568
  opts.locale
@@ -31433,15 +31630,14 @@ var SSRContainer = class extends _SharedContainer2 {
31433
31630
  this.renderOptions = opts.renderOptions;
31434
31631
  this.$processInjectionsFromManifest$();
31435
31632
  }
31436
- ensureProjectionResolved(host) {
31633
+ ensureProjectionResolved(_host) {
31437
31634
  }
31438
- handleError(err, $host$) {
31635
+ handleError(err, _$host$) {
31439
31636
  throw err;
31440
31637
  }
31441
31638
  async render(jsx4) {
31442
31639
  this.openContainer();
31443
31640
  await _walkJSX2(this, jsx4, {
31444
- allowPromises: true,
31445
31641
  currentStyleScoped: null,
31446
31642
  parentComponentFrame: this.getComponentFrame()
31447
31643
  });
@@ -31495,7 +31691,7 @@ var SSRContainer = class extends _SharedContainer2 {
31495
31691
  containerAttributes[QContainerAttr] = "paused" /* PAUSED */;
31496
31692
  containerAttributes[QRuntimeAttr] = "2";
31497
31693
  containerAttributes[QVersionAttr] = this.$version$ ?? "dev";
31498
- containerAttributes[QRenderAttr] = (qRender ? qRender + "-" : "") + (isDev11 ? "ssr-dev" : "ssr");
31694
+ containerAttributes[QRenderAttr] = (qRender ? qRender + "-" : "") + (isDev10 ? "ssr-dev" : "ssr");
31499
31695
  containerAttributes[QBaseAttr] = this.buildBase || "";
31500
31696
  containerAttributes[QLocaleAttr] = this.$locale$;
31501
31697
  containerAttributes[QManifestHashAttr] = this.resolvedManifest.manifest.manifestHash;
@@ -31530,7 +31726,7 @@ var SSRContainer = class extends _SharedContainer2 {
31530
31726
  innerHTML = this.writeAttrs(elementName, varAttrs, false, currentFile);
31531
31727
  }
31532
31728
  this.write(" " + Q_PROPS_SEPARATOR);
31533
- isDev11 && this.write('=""');
31729
+ isDev10 && this.write('=""');
31534
31730
  if (constAttrs && constAttrs.length) {
31535
31731
  innerHTML = this.writeAttrs(elementName, constAttrs, true, currentFile) || innerHTML;
31536
31732
  }
@@ -31851,8 +32047,8 @@ var SSRContainer = class extends _SharedContainer2 {
31851
32047
  case ELEMENT_SEQ_IDX:
31852
32048
  write(VNodeDataChar.SEQ_IDX_CHAR);
31853
32049
  break;
31854
- case QSubscribers:
31855
- write(VNodeDataChar.SUBS_CHAR);
32050
+ case QBackRefs:
32051
+ write(VNodeDataChar.BACK_REFS_CHAR);
31856
32052
  break;
31857
32053
  // Skipping `\` character for now because it is used for escaping.
31858
32054
  case QCtxAttr:
@@ -32049,7 +32245,7 @@ var SSRContainer = class extends _SharedContainer2 {
32049
32245
  }
32050
32246
  this.unclaimedProjectionComponentFrameQueue.shift();
32051
32247
  this.openFragment(
32052
- isDev11 ? [DEBUG_TYPE, "P" /* Projection */, QSlotParent, ssrComponentNode.id] : [QSlotParent, ssrComponentNode.id]
32248
+ isDev10 ? [DEBUG_TYPE, "P" /* Projection */, QSlotParent, ssrComponentNode.id] : [QSlotParent, ssrComponentNode.id]
32053
32249
  );
32054
32250
  const lastNode = this.getLastNode();
32055
32251
  if (lastNode.vnodeData) {
@@ -32057,7 +32253,6 @@ var SSRContainer = class extends _SharedContainer2 {
32057
32253
  }
32058
32254
  ssrComponentNode?.setProp(value, lastNode.id);
32059
32255
  await _walkJSX2(this, children, {
32060
- allowPromises: true,
32061
32256
  currentStyleScoped: scopedStyleId,
32062
32257
  parentComponentFrame: null
32063
32258
  });
@@ -32099,7 +32294,7 @@ var SSRContainer = class extends _SharedContainer2 {
32099
32294
  }
32100
32295
  createAndPushFrame(elementName, depthFirstElementIdx, currentFile) {
32101
32296
  let tagNesting = 10 /* ANYTHING */;
32102
- if (isDev11) {
32297
+ if (isDev10) {
32103
32298
  if (!this.currentElementFrame) {
32104
32299
  tagNesting = initialTag(elementName);
32105
32300
  } else {
@@ -32175,8 +32370,8 @@ var SSRContainer = class extends _SharedContainer2 {
32175
32370
  let value = attrs[i];
32176
32371
  let styleScopedId = null;
32177
32372
  if (isSSRUnsafeAttr(key)) {
32178
- if (isDev11) {
32179
- throw qError(51 /* unsafeAttr */);
32373
+ if (isDev10) {
32374
+ throw qError(49 /* unsafeAttr */);
32180
32375
  }
32181
32376
  continue;
32182
32377
  }
@@ -32193,6 +32388,8 @@ var SSRContainer = class extends _SharedContainer2 {
32193
32388
  } else if (typeof value === "function") {
32194
32389
  value(new DomRef(lastNode));
32195
32390
  continue;
32391
+ } else if (value == null) {
32392
+ continue;
32196
32393
  } else {
32197
32394
  throw qError(32 /* invalidRefValue */, [currentFile]);
32198
32395
  }
@@ -32215,7 +32412,7 @@ var SSRContainer = class extends _SharedContainer2 {
32215
32412
  }
32216
32413
  if (tag === "textarea" && key === "value") {
32217
32414
  if (value && typeof value !== "string") {
32218
- if (isDev11) {
32415
+ if (isDev10) {
32219
32416
  throw qError(40 /* wrongTextareaValue */, [currentFile, value]);
32220
32417
  }
32221
32418
  continue;
@@ -32558,7 +32755,7 @@ async function ssrRenderToDom(jsx4, opts = {}) {
32558
32755
  let child = firstContainerChild;
32559
32756
  let insertBefore = null;
32560
32757
  while (child) {
32561
- if (vnode_isElementVNode(child) && (vnode_getElementName(child) === "script" && vnode_getAttr(child, "type") === "qwik/state" || vnode_getElementName(child) === "q:template")) {
32758
+ if (vnode_isElementVNode(child) && (vnode_getElementName(child) === "script" && (vnode_getAttr(child, "type") === "qwik/state" || vnode_getAttr(child, "id") === "qwikloader") || vnode_getElementName(child) === "q:template")) {
32562
32759
  insertBefore = child;
32563
32760
  break;
32564
32761
  }
@@ -32618,14 +32815,16 @@ function renderStyles(getStyles) {
32618
32815
  console.log(START2 + key + ": " + END2 + value);
32619
32816
  });
32620
32817
  }
32621
- async function rerenderComponent(element) {
32818
+ async function rerenderComponent(element, flush) {
32622
32819
  const container = _getDomContainer(element);
32623
32820
  const vElement = vnode_locate(container.rootVNode, element);
32624
32821
  const host = getHostVNode(vElement);
32625
32822
  const qrl2 = container.getHostProp(host, OnRenderProp);
32626
32823
  const props = container.getHostProp(host, ELEMENT_PROPS);
32627
- await container.$scheduler$(7 /* COMPONENT */, host, qrl2, props);
32628
- await getTestPlatform().flush();
32824
+ container.$scheduler$(6 /* COMPONENT */, host, qrl2, props);
32825
+ if (flush) {
32826
+ await getTestPlatform().flush();
32827
+ }
32629
32828
  }
32630
32829
  function getHostVNode(vElement) {
32631
32830
  while (vElement != null) {