@qwik.dev/core 2.0.0-alpha.1 → 2.0.0-alpha.2

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.
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * @qwik.dev/core/testing 2.0.0-alpha.1-dev+10f5414
3
+ * @qwik.dev/core/testing 2.0.0-alpha.2-dev+58b6f8d
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
@@ -23062,9 +23062,11 @@ function clearEffects(subscriber, value) {
23062
23062
  return subscriptionRemoved;
23063
23063
  }
23064
23064
 
23065
+ // packages/qwik/src/core/signal/flags.ts
23066
+ var NEEDS_COMPUTATION = Symbol("invalid");
23067
+
23065
23068
  // packages/qwik/src/core/signal/signal.ts
23066
23069
  var DEBUG = false;
23067
- var NEEDS_COMPUTATION = Symbol("invalid");
23068
23070
  var log = (...args) => console.log("SIGNAL", ...args.map(qwikDebugToString));
23069
23071
  var throwIfQRLNotResolved = (qrl2) => {
23070
23072
  const resolved = qrl2.resolved;
@@ -23597,6 +23599,20 @@ var StoreHandler = class {
23597
23599
  if (prop === STORE_TARGET) {
23598
23600
  return true;
23599
23601
  }
23602
+ if (typeof prop === "string") {
23603
+ const ctx = tryGetInvokeContext();
23604
+ if (ctx) {
23605
+ const effectSubscriber = ctx.$effectSubscriber$;
23606
+ if (effectSubscriber) {
23607
+ addEffect(
23608
+ target,
23609
+ Array.isArray(target) ? STORE_ARRAY_PROP : prop,
23610
+ this,
23611
+ effectSubscriber
23612
+ );
23613
+ }
23614
+ }
23615
+ }
23600
23616
  return Object.prototype.hasOwnProperty.call(target, prop);
23601
23617
  }
23602
23618
  ownKeys(target) {
@@ -25226,7 +25242,10 @@ function choreComparator(a, b, shouldThrowOnHostMismatch) {
25226
25242
  return hostDiff;
25227
25243
  }
25228
25244
  } else {
25229
- const errorMessage = "SERVER: during HTML streaming, it is not possible to cause a re-run of tasks on a different host";
25245
+ const errorMessage = `SERVER: during HTML streaming, re-running tasks on a different host is not allowed.
25246
+ You are attempting to change a state that has already been streamed to the client.
25247
+ This can lead to inconsistencies between Server-Side Rendering (SSR) and Client-Side Rendering (CSR).
25248
+ Problematic Node: ${aHost.toString()}`;
25230
25249
  if (shouldThrowOnHostMismatch) {
25231
25250
  throwErrorAndStop(errorMessage);
25232
25251
  }
@@ -25340,9 +25359,10 @@ var _SharedContainer = class {
25340
25359
  trackSignalValue(signal, subscriber, property, data) {
25341
25360
  return trackSignal(() => signal.value, subscriber, property, this, data);
25342
25361
  }
25343
- serializationCtxFactory(NodeConstructor, symbolToChunkResolver, writer, prepVNodeData) {
25362
+ serializationCtxFactory(NodeConstructor, DomRefConstructor, symbolToChunkResolver, writer, prepVNodeData) {
25344
25363
  return createSerializationContext(
25345
25364
  NodeConstructor,
25365
+ DomRefConstructor,
25346
25366
  symbolToChunkResolver,
25347
25367
  this.getHostProp.bind(this),
25348
25368
  this.setHostProp.bind(this),
@@ -27863,6 +27883,12 @@ __publicField(SsrNode, "ELEMENT_NODE", 1);
27863
27883
  __publicField(SsrNode, "TEXT_NODE", 3);
27864
27884
  __publicField(SsrNode, "DOCUMENT_NODE", 9);
27865
27885
  __publicField(SsrNode, "DOCUMENT_FRAGMENT_NODE", 11);
27886
+ var DomRef = class {
27887
+ /** @id is the same id as for SsrNode */
27888
+ constructor(id) {
27889
+ this.id = id;
27890
+ }
27891
+ };
27866
27892
  var SsrComponentFrame = class {
27867
27893
  constructor(componentNode) {
27868
27894
  this.componentNode = componentNode;
@@ -28474,12 +28500,7 @@ function inflateQRL(container, qrl2) {
28474
28500
  }
28475
28501
  return qrl2;
28476
28502
  }
28477
- var DomVRef = class {
28478
- constructor(id) {
28479
- this.id = id;
28480
- }
28481
- };
28482
- var createSerializationContext = (NodeConstructor, symbolToChunkResolver, getProp, setProp, storeProxyMap, writer, prepVNodeData) => {
28503
+ var createSerializationContext = (NodeConstructor, DomRefConstructor, symbolToChunkResolver, getProp, setProp, storeProxyMap, writer, prepVNodeData) => {
28483
28504
  if (!writer) {
28484
28505
  const buffer = [];
28485
28506
  writer = {
@@ -28503,11 +28524,13 @@ var createSerializationContext = (NodeConstructor, symbolToChunkResolver, getPro
28503
28524
  return id;
28504
28525
  };
28505
28526
  const isSsrNode = NodeConstructor ? (obj) => obj instanceof NodeConstructor : () => false;
28527
+ const isDomRef = DomRefConstructor ? (obj) => obj instanceof DomRefConstructor : () => false;
28506
28528
  return {
28507
28529
  $serialize$() {
28508
28530
  serialize(this);
28509
28531
  },
28510
28532
  $isSsrNode$: isSsrNode,
28533
+ $isDomRef$: isDomRef,
28511
28534
  $symbolToChunkResolver$: symbolToChunkResolver,
28512
28535
  $wasSeen$,
28513
28536
  $roots$: roots,
@@ -28616,6 +28639,8 @@ var createSerializationContext = (NodeConstructor, symbolToChunkResolver, getPro
28616
28639
  discoveredValues.push(obj.$el$, obj.$qrl$, obj.$state$, obj.$effectDependencies$);
28617
28640
  } else if (isSsrNode(obj)) {
28618
28641
  discoveredValues.push(obj.vnodeData);
28642
+ } else if (isDomRef(obj)) {
28643
+ discoveredValues.push(obj.id);
28619
28644
  } else if (isJSXNode(obj)) {
28620
28645
  discoveredValues.push(obj.type, obj.props, obj.constProps, obj.children);
28621
28646
  } else if (Array.isArray(obj)) {
@@ -28670,7 +28695,7 @@ var createSerializationContext = (NodeConstructor, symbolToChunkResolver, getPro
28670
28695
  };
28671
28696
  var promiseResults = /* @__PURE__ */ new WeakMap();
28672
28697
  function serialize(serializationContext) {
28673
- const { $writer$, $isSsrNode$, $setProp$, $storeProxyMap$ } = serializationContext;
28698
+ const { $writer$, $isSsrNode$, $isDomRef$, $setProp$, $storeProxyMap$ } = serializationContext;
28674
28699
  let depth = -1;
28675
28700
  let writeType = false;
28676
28701
  const output = (type, value) => {
@@ -28838,14 +28863,10 @@ function serialize(serializationContext) {
28838
28863
  }
28839
28864
  output(13 /* Object */, out);
28840
28865
  }
28841
- } else if (value instanceof DomVRef) {
28866
+ } else if ($isDomRef$(value)) {
28842
28867
  output(9 /* RefVNode */, value.id);
28843
28868
  } else if (value instanceof Signal) {
28844
- let v = value instanceof ComputedSignal && (value.$invalid$ || fastSkipSerialize(value.$untrackedValue$)) ? NEEDS_COMPUTATION : value.$untrackedValue$;
28845
- if ($isSsrNode$(v)) {
28846
- serializationContext.$addRoot$(v);
28847
- v = new DomVRef(v.id);
28848
- }
28869
+ const v = value instanceof ComputedSignal && (value.$invalid$ || fastSkipSerialize(value.$untrackedValue$)) ? NEEDS_COMPUTATION : value.$untrackedValue$;
28849
28870
  if (value instanceof WrappedSignal) {
28850
28871
  output(23 /* WrappedSignal */, [
28851
28872
  ...serializeWrappingFn(serializationContext, value),
@@ -29339,8 +29360,8 @@ var createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef, refSym
29339
29360
  }
29340
29361
  let _containerEl;
29341
29362
  const qrl2 = async function(...args) {
29342
- const fn = invokeFn.call(this, tryGetInvokeContext());
29343
- const result = await fn(...args);
29363
+ const boundedFn = bindFnToContext.call(this, tryGetInvokeContext());
29364
+ const result = await boundedFn(...args);
29344
29365
  return result;
29345
29366
  };
29346
29367
  const setContainer = (el) => {
@@ -29349,6 +29370,30 @@ var createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef, refSym
29349
29370
  }
29350
29371
  return _containerEl;
29351
29372
  };
29373
+ function bindFnToContext(currentCtx, beforeFn) {
29374
+ return (...args) => maybeThen(resolveLazy(), (fn) => {
29375
+ if (!isFunction(fn)) {
29376
+ throw qError(QError_qrlIsNotFunction);
29377
+ }
29378
+ if (beforeFn && beforeFn() === false) {
29379
+ return;
29380
+ }
29381
+ const context = createOrReuseInvocationContext(currentCtx);
29382
+ const prevQrl = context.$qrl$;
29383
+ const prevEvent = context.$event$;
29384
+ context.$qrl$ = qrl2;
29385
+ context.$event$ || (context.$event$ = this);
29386
+ try {
29387
+ return invoke.call(this, context, fn, ...args);
29388
+ } finally {
29389
+ context.$qrl$ = prevQrl;
29390
+ context.$event$ = prevEvent;
29391
+ }
29392
+ });
29393
+ }
29394
+ const resolveLazy = (containerEl) => {
29395
+ return symbolRef !== null ? symbolRef : resolve(containerEl);
29396
+ };
29352
29397
  const wrapFn = (fn) => {
29353
29398
  if (typeof fn !== "function" || !capture?.length && !captureRef?.length) {
29354
29399
  return fn;
@@ -29398,30 +29443,6 @@ var createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef, refSym
29398
29443
  }
29399
29444
  return symbolRef;
29400
29445
  };
29401
- const resolveLazy = (containerEl) => {
29402
- return symbolRef !== null ? symbolRef : resolve(containerEl);
29403
- };
29404
- function invokeFn(currentCtx, beforeFn) {
29405
- return (...args) => maybeThen(resolveLazy(), (f) => {
29406
- if (!isFunction(f)) {
29407
- throw qError(QError_qrlIsNotFunction);
29408
- }
29409
- if (beforeFn && beforeFn() === false) {
29410
- return;
29411
- }
29412
- const context = createOrReuseInvocationContext(currentCtx);
29413
- const prevQrl = context.$qrl$;
29414
- const prevEvent = context.$event$;
29415
- context.$qrl$ = qrl2;
29416
- context.$event$ || (context.$event$ = this);
29417
- try {
29418
- return invoke.call(this, context, f, ...args);
29419
- } finally {
29420
- context.$qrl$ = prevQrl;
29421
- context.$event$ = prevEvent;
29422
- }
29423
- });
29424
- }
29425
29446
  const createOrReuseInvocationContext = (invoke2) => {
29426
29447
  if (invoke2 == null) {
29427
29448
  return newInvokeContext();
@@ -29444,7 +29465,7 @@ var createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef, refSym
29444
29465
  $symbol$: symbol,
29445
29466
  $refSymbol$: refSymbol,
29446
29467
  $hash$: hash3,
29447
- getFn: invokeFn,
29468
+ getFn: bindFnToContext,
29448
29469
  $capture$: capture,
29449
29470
  $captureRef$: captureRef,
29450
29471
  dev: null,
@@ -31138,6 +31159,7 @@ var SSRContainer = class extends _SharedContainer2 {
31138
31159
  };
31139
31160
  this.serializationCtx = this.serializationCtxFactory(
31140
31161
  SsrNode,
31162
+ DomRef,
31141
31163
  this.symbolToChunkResolver,
31142
31164
  opts.writer,
31143
31165
  (vNodeData) => this.addVNodeToSerializationRoots(vNodeData)
@@ -31901,10 +31923,10 @@ var SSRContainer = class extends _SharedContainer2 {
31901
31923
  if (key === "ref") {
31902
31924
  const lastNode = this.getLastNode();
31903
31925
  if (isSignal3(value)) {
31904
- value.value = lastNode;
31926
+ value.value = new DomRef(lastNode.id);
31905
31927
  continue;
31906
31928
  } else if (typeof value === "function") {
31907
- value(lastNode);
31929
+ value(new DomRef(lastNode.id));
31908
31930
  continue;
31909
31931
  }
31910
31932
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qwik.dev/core/testing",
3
- "version": "2.0.0-alpha.1-dev+10f5414",
3
+ "version": "2.0.0-alpha.2-dev+58b6f8d",
4
4
  "main": "index.mjs",
5
5
  "types": "index.d.ts",
6
6
  "private": true,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@qwik.dev/core",
3
3
  "description": "An open source framework for building instant loading web apps at any scale, without the extra effort.",
4
- "version": "2.0.0-alpha.1",
4
+ "version": "2.0.0-alpha.2",
5
5
  "author": "Qwik Team",
6
6
  "bin": {
7
7
  "qwik": "./qwik-cli.cjs"
@@ -13,9 +13,11 @@
13
13
  "devDependencies": {
14
14
  "image-size": "1.1.1",
15
15
  "kleur": "4.1.5",
16
+ "ignore": "5.3.1",
16
17
  "prettier": "3.3.3",
18
+ "ts-morph": "23.0.0",
17
19
  "vitest": "2.1.4",
18
- "@qwik.dev/core": "2.0.0-alpha.1",
20
+ "@qwik.dev/core": "2.0.0-alpha.2",
19
21
  "@qwik.dev/dom": "2.1.19"
20
22
  },
21
23
  "engines": {