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

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 (39) 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.wasm.cjs +259 -272
  5. package/bindings/qwik.wasm.mjs +259 -272
  6. package/bindings/qwik.win32-x64-msvc.node +0 -0
  7. package/bindings/qwik_wasm_bg.wasm +0 -0
  8. package/dist/build/package.json +1 -1
  9. package/dist/cli.cjs +1384 -761
  10. package/dist/core-internal.d.ts +14 -4
  11. package/dist/core.cjs +121 -106
  12. package/dist/core.cjs.map +1 -1
  13. package/dist/core.min.mjs +1 -1
  14. package/dist/core.mjs +121 -106
  15. package/dist/core.mjs.map +1 -1
  16. package/dist/core.prod.cjs +80 -63
  17. package/dist/core.prod.mjs +82 -65
  18. package/dist/insights/index.qwik.cjs +1 -1
  19. package/dist/insights/index.qwik.mjs +1 -1
  20. package/dist/loader/index.cjs +2 -2
  21. package/dist/loader/index.mjs +2 -2
  22. package/dist/loader/package.json +1 -1
  23. package/dist/optimizer.cjs +94 -80
  24. package/dist/optimizer.mjs +96 -82
  25. package/dist/prefetch/package.json +1 -1
  26. package/dist/qwikloader.debug.js +1 -0
  27. package/dist/qwikloader.js +2 -2
  28. package/dist/server.cjs +125 -96
  29. package/dist/server.mjs +125 -96
  30. package/dist/starters/features/auth/package.json +3 -1
  31. package/dist/starters/features/drizzle/package.json +2 -1
  32. package/dist/starters/features/postcss/package.json +3 -0
  33. package/dist/starters/features/prisma/package.json +2 -1
  34. package/dist/starters/features/tailwind/package.json +3 -0
  35. package/dist/starters/features/turso/package.json +4 -1
  36. package/dist/testing/index.cjs +121 -92
  37. package/dist/testing/index.mjs +121 -92
  38. package/dist/testing/package.json +1 -1
  39. package/package.json +6 -4
@@ -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.3-dev+418fd6d
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
@@ -23077,9 +23077,11 @@ function clearEffects(subscriber, value) {
23077
23077
  return subscriptionRemoved;
23078
23078
  }
23079
23079
 
23080
+ // packages/qwik/src/core/signal/flags.ts
23081
+ var NEEDS_COMPUTATION = Symbol("invalid");
23082
+
23080
23083
  // packages/qwik/src/core/signal/signal.ts
23081
23084
  var DEBUG = false;
23082
- var NEEDS_COMPUTATION = Symbol("invalid");
23083
23085
  var log = (...args) => console.log("SIGNAL", ...args.map(qwikDebugToString));
23084
23086
  var throwIfQRLNotResolved = (qrl2) => {
23085
23087
  const resolved = qrl2.resolved;
@@ -23615,6 +23617,20 @@ var StoreHandler = class {
23615
23617
  if (prop === STORE_TARGET) {
23616
23618
  return true;
23617
23619
  }
23620
+ if (typeof prop === "string") {
23621
+ const ctx = tryGetInvokeContext();
23622
+ if (ctx) {
23623
+ const effectSubscriber = ctx.$effectSubscriber$;
23624
+ if (effectSubscriber) {
23625
+ addEffect(
23626
+ target,
23627
+ Array.isArray(target) ? STORE_ARRAY_PROP : prop,
23628
+ this,
23629
+ effectSubscriber
23630
+ );
23631
+ }
23632
+ }
23633
+ }
23618
23634
  return Object.prototype.hasOwnProperty.call(target, prop);
23619
23635
  }
23620
23636
  ownKeys(target) {
@@ -24351,46 +24367,45 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
24351
24367
  }
24352
24368
  }
24353
24369
  function descendContentToProject(children, host) {
24354
- if (!Array.isArray(children)) {
24355
- children = [children];
24356
- }
24357
- if (children.length) {
24358
- const createProjectionJSXNode = (slotName) => {
24359
- return new JSXNodeImpl(Projection, EMPTY_OBJ, null, [], 0, slotName);
24360
- };
24361
- const projections = [];
24362
- if (host) {
24363
- for (let i = vnode_getPropStartIndex(host); i < host.length; i = i + 2) {
24364
- const prop = host[i];
24365
- if (isSlotProp(prop)) {
24366
- const slotName = prop;
24367
- projections.push(slotName);
24368
- projections.push(createProjectionJSXNode(slotName));
24369
- }
24370
+ const projectionChildren = Array.isArray(children) ? children : [children];
24371
+ const createProjectionJSXNode = (slotName) => {
24372
+ return new JSXNodeImpl(Projection, EMPTY_OBJ, null, [], 0, slotName);
24373
+ };
24374
+ const projections = [];
24375
+ if (host) {
24376
+ for (let i = vnode_getPropStartIndex(host); i < host.length; i = i + 2) {
24377
+ const prop = host[i];
24378
+ if (isSlotProp(prop)) {
24379
+ const slotName = prop;
24380
+ projections.push(slotName);
24381
+ projections.push(createProjectionJSXNode(slotName));
24370
24382
  }
24371
24383
  }
24372
- for (let i = 0; i < children.length; i++) {
24373
- const child = children[i];
24374
- const slotName = String(
24375
- isJSXNode(child) && directGetPropsProxyProp(child, QSlot) || QDefaultSlot
24376
- );
24377
- const idx = mapApp_findIndx(projections, slotName, 0);
24378
- let jsxBucket;
24379
- if (idx >= 0) {
24380
- jsxBucket = projections[idx + 1];
24381
- } else {
24382
- projections.splice(~idx, 0, slotName, jsxBucket = createProjectionJSXNode(slotName));
24383
- }
24384
- const removeProjection = child === false;
24385
- if (!removeProjection) {
24386
- jsxBucket.children.push(child);
24387
- }
24384
+ }
24385
+ if (projections.length === 0 && children == null) {
24386
+ return;
24387
+ }
24388
+ for (let i = 0; i < projectionChildren.length; i++) {
24389
+ const child = projectionChildren[i];
24390
+ const slotName = String(
24391
+ isJSXNode(child) && directGetPropsProxyProp(child, QSlot) || QDefaultSlot
24392
+ );
24393
+ const idx = mapApp_findIndx(projections, slotName, 0);
24394
+ let jsxBucket;
24395
+ if (idx >= 0) {
24396
+ jsxBucket = projections[idx + 1];
24397
+ } else {
24398
+ projections.splice(~idx, 0, slotName, jsxBucket = createProjectionJSXNode(slotName));
24388
24399
  }
24389
- for (let i = projections.length - 2; i >= 0; i = i - 2) {
24390
- projections.splice(i, 1);
24400
+ const removeProjection = child === false;
24401
+ if (!removeProjection) {
24402
+ jsxBucket.children.push(child);
24391
24403
  }
24392
- descend(projections, true);
24393
24404
  }
24405
+ for (let i = projections.length - 2; i >= 0; i = i - 2) {
24406
+ projections.splice(i, 1);
24407
+ }
24408
+ descend(projections, true);
24394
24409
  }
24395
24410
  function expectProjection() {
24396
24411
  const jsxNode2 = jsxValue;
@@ -24842,7 +24857,7 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
24842
24857
  container.$scheduler$(7 /* COMPONENT */, host, componentQRL, jsxProps);
24843
24858
  }
24844
24859
  }
24845
- jsxNode2.children != null && descendContentToProject(jsxNode2.children, host);
24860
+ descendContentToProject(jsxNode2.children, host);
24846
24861
  } else {
24847
24862
  const lookupKey = jsxNode2.key;
24848
24863
  const vNodeLookupKey = getKey(host);
@@ -25156,7 +25171,17 @@ var createScheduler = (container, scheduleDrain, journalFlush) => {
25156
25171
  chore.$payload$
25157
25172
  ),
25158
25173
  (jsx5) => {
25159
- return chore.$type$ === 7 /* COMPONENT */ ? maybeThen(container.processJsx(host, jsx5), () => jsx5) : jsx5;
25174
+ if (chore.$type$ === 7 /* COMPONENT */) {
25175
+ const styleScopedId = container.getHostProp(host, QScopedStyle);
25176
+ return vnode_diff(
25177
+ container,
25178
+ jsx5,
25179
+ host,
25180
+ addComponentStylePrefix(styleScopedId)
25181
+ );
25182
+ } else {
25183
+ return jsx5;
25184
+ }
25160
25185
  },
25161
25186
  (err) => container.handleError(err, host)
25162
25187
  );
@@ -25245,7 +25270,10 @@ function choreComparator(a, b, shouldThrowOnHostMismatch) {
25245
25270
  return hostDiff;
25246
25271
  }
25247
25272
  } else {
25248
- const errorMessage = "SERVER: during HTML streaming, it is not possible to cause a re-run of tasks on a different host";
25273
+ const errorMessage = `SERVER: during HTML streaming, re-running tasks on a different host is not allowed.
25274
+ You are attempting to change a state that has already been streamed to the client.
25275
+ This can lead to inconsistencies between Server-Side Rendering (SSR) and Client-Side Rendering (CSR).
25276
+ Problematic Node: ${aHost.toString()}`;
25249
25277
  if (shouldThrowOnHostMismatch) {
25250
25278
  throwErrorAndStop(errorMessage);
25251
25279
  }
@@ -25360,9 +25388,10 @@ var _SharedContainer = class {
25360
25388
  trackSignalValue(signal, subscriber, property, data) {
25361
25389
  return trackSignal(() => signal.value, subscriber, property, this, data);
25362
25390
  }
25363
- serializationCtxFactory(NodeConstructor, symbolToChunkResolver, writer, prepVNodeData) {
25391
+ serializationCtxFactory(NodeConstructor, DomRefConstructor, symbolToChunkResolver, writer, prepVNodeData) {
25364
25392
  return createSerializationContext(
25365
25393
  NodeConstructor,
25394
+ DomRefConstructor,
25366
25395
  symbolToChunkResolver,
25367
25396
  this.getHostProp.bind(this),
25368
25397
  this.setHostProp.bind(this),
@@ -26006,10 +26035,6 @@ var DomContainer = class extends _SharedContainer {
26006
26035
  parseQRL(qrl2) {
26007
26036
  return inflateQRL(this, parseQRL(qrl2));
26008
26037
  }
26009
- processJsx(host, jsx4) {
26010
- const styleScopedId = this.getHostProp(host, QScopedStyle);
26011
- return vnode_diff(this, jsx4, host, addComponentStylePrefix(styleScopedId));
26012
- }
26013
26038
  handleError(err, host) {
26014
26039
  if (qDev) {
26015
26040
  if (typeof document !== "undefined") {
@@ -27891,6 +27916,11 @@ var SsrNode = class {
27891
27916
  return `SSRNode [<${this.id}> ${stringifiedAttrs}]`;
27892
27917
  }
27893
27918
  };
27919
+ var DomRef = class {
27920
+ constructor($ssrNode$) {
27921
+ this.$ssrNode$ = $ssrNode$;
27922
+ }
27923
+ };
27894
27924
  var SsrComponentFrame = class {
27895
27925
  constructor(componentNode) {
27896
27926
  this.componentNode = componentNode;
@@ -28163,7 +28193,9 @@ var inflate = (container, target, typeId, data) => {
28163
28193
  if (valType === 0 /* RootRef */ || valType >= 12 /* Error */) {
28164
28194
  Object.defineProperty(target, key, {
28165
28195
  get() {
28166
- return deserializeData(container, valType, valData);
28196
+ const value = deserializeData(container, valType, valData);
28197
+ target[key] = value;
28198
+ return value;
28167
28199
  },
28168
28200
  set(value) {
28169
28201
  Object.defineProperty(target, key, {
@@ -28505,12 +28537,8 @@ function inflateQRL(container, qrl2) {
28505
28537
  }
28506
28538
  return qrl2;
28507
28539
  }
28508
- var DomVRef = class {
28509
- constructor(id) {
28510
- this.id = id;
28511
- }
28512
- };
28513
- var createSerializationContext = (NodeConstructor, symbolToChunkResolver, getProp, setProp, storeProxyMap, writer, prepVNodeData) => {
28540
+ var isDomRef = (obj) => false;
28541
+ var createSerializationContext = (NodeConstructor, DomRefConstructor, symbolToChunkResolver, getProp, setProp, storeProxyMap, writer, prepVNodeData) => {
28514
28542
  if (!writer) {
28515
28543
  const buffer = [];
28516
28544
  writer = {
@@ -28534,11 +28562,13 @@ var createSerializationContext = (NodeConstructor, symbolToChunkResolver, getPro
28534
28562
  return id;
28535
28563
  };
28536
28564
  const isSsrNode = NodeConstructor ? (obj) => obj instanceof NodeConstructor : () => false;
28565
+ isDomRef = DomRefConstructor ? (obj) => obj instanceof DomRefConstructor : () => false;
28537
28566
  return {
28538
28567
  $serialize$() {
28539
28568
  serialize(this);
28540
28569
  },
28541
28570
  $isSsrNode$: isSsrNode,
28571
+ $isDomRef$: isDomRef,
28542
28572
  $symbolToChunkResolver$: symbolToChunkResolver,
28543
28573
  $wasSeen$,
28544
28574
  $roots$: roots,
@@ -28647,6 +28677,8 @@ var createSerializationContext = (NodeConstructor, symbolToChunkResolver, getPro
28647
28677
  discoveredValues.push(obj.$el$, obj.$qrl$, obj.$state$, obj.$effectDependencies$);
28648
28678
  } else if (isSsrNode(obj)) {
28649
28679
  discoveredValues.push(obj.vnodeData);
28680
+ } else if (isDomRef(obj)) {
28681
+ discoveredValues.push(obj.$ssrNode$.id);
28650
28682
  } else if (isJSXNode(obj)) {
28651
28683
  discoveredValues.push(obj.type, obj.props, obj.constProps, obj.children);
28652
28684
  } else if (Array.isArray(obj)) {
@@ -28701,7 +28733,7 @@ var createSerializationContext = (NodeConstructor, symbolToChunkResolver, getPro
28701
28733
  };
28702
28734
  var promiseResults = /* @__PURE__ */ new WeakMap();
28703
28735
  function serialize(serializationContext) {
28704
- const { $writer$, $isSsrNode$, $setProp$, $storeProxyMap$ } = serializationContext;
28736
+ const { $writer$, $isSsrNode$, $isDomRef$, $setProp$, $storeProxyMap$ } = serializationContext;
28705
28737
  let depth = -1;
28706
28738
  let writeType = false;
28707
28739
  const output = (type, value) => {
@@ -28870,14 +28902,11 @@ function serialize(serializationContext) {
28870
28902
  }
28871
28903
  output(13 /* Object */, out);
28872
28904
  }
28873
- } else if (value instanceof DomVRef) {
28874
- output(9 /* RefVNode */, value.id);
28905
+ } else if ($isDomRef$(value)) {
28906
+ value.$ssrNode$.vnodeData[0] |= 8 /* SERIALIZE */;
28907
+ output(9 /* RefVNode */, value.$ssrNode$.id);
28875
28908
  } else if (value instanceof Signal) {
28876
- let v = value instanceof ComputedSignal && (value.$invalid$ || fastSkipSerialize(value.$untrackedValue$)) ? NEEDS_COMPUTATION : value.$untrackedValue$;
28877
- if ($isSsrNode$(v)) {
28878
- serializationContext.$addRoot$(v);
28879
- v = new DomVRef(v.id);
28880
- }
28909
+ const v = value instanceof ComputedSignal && (value.$invalid$ || fastSkipSerialize(value.$untrackedValue$)) ? NEEDS_COMPUTATION : value.$untrackedValue$;
28881
28910
  if (value instanceof WrappedSignal) {
28882
28911
  output(23 /* WrappedSignal */, [
28883
28912
  ...serializeWrappingFn(serializationContext, value),
@@ -29140,6 +29169,8 @@ var canSerialize = (value) => {
29140
29169
  return true;
29141
29170
  } else if (value instanceof Uint8Array) {
29142
29171
  return true;
29172
+ } else if (isDomRef == null ? void 0 : isDomRef(value)) {
29173
+ return true;
29143
29174
  }
29144
29175
  } else if (typeof value === "function") {
29145
29176
  if (isQrl2(value) || isQwikComponent(value)) {
@@ -29372,8 +29403,8 @@ var createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef, refSym
29372
29403
  }
29373
29404
  let _containerEl;
29374
29405
  const qrl2 = async function(...args) {
29375
- const fn = invokeFn.call(this, tryGetInvokeContext());
29376
- const result = await fn(...args);
29406
+ const boundedFn = bindFnToContext.call(this, tryGetInvokeContext());
29407
+ const result = await boundedFn(...args);
29377
29408
  return result;
29378
29409
  };
29379
29410
  const setContainer = (el) => {
@@ -29382,6 +29413,30 @@ var createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef, refSym
29382
29413
  }
29383
29414
  return _containerEl;
29384
29415
  };
29416
+ function bindFnToContext(currentCtx, beforeFn) {
29417
+ return (...args) => maybeThen(resolveLazy(), (fn) => {
29418
+ if (!isFunction(fn)) {
29419
+ throw qError(QError_qrlIsNotFunction);
29420
+ }
29421
+ if (beforeFn && beforeFn() === false) {
29422
+ return;
29423
+ }
29424
+ const context = createOrReuseInvocationContext(currentCtx);
29425
+ const prevQrl = context.$qrl$;
29426
+ const prevEvent = context.$event$;
29427
+ context.$qrl$ = qrl2;
29428
+ context.$event$ ||= this;
29429
+ try {
29430
+ return invoke.call(this, context, fn, ...args);
29431
+ } finally {
29432
+ context.$qrl$ = prevQrl;
29433
+ context.$event$ = prevEvent;
29434
+ }
29435
+ });
29436
+ }
29437
+ const resolveLazy = (containerEl) => {
29438
+ return symbolRef !== null ? symbolRef : resolve(containerEl);
29439
+ };
29385
29440
  const wrapFn = (fn) => {
29386
29441
  if (typeof fn !== "function" || !(capture == null ? void 0 : capture.length) && !(captureRef == null ? void 0 : captureRef.length)) {
29387
29442
  return fn;
@@ -29431,30 +29486,6 @@ var createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef, refSym
29431
29486
  }
29432
29487
  return symbolRef;
29433
29488
  };
29434
- const resolveLazy = (containerEl) => {
29435
- return symbolRef !== null ? symbolRef : resolve(containerEl);
29436
- };
29437
- function invokeFn(currentCtx, beforeFn) {
29438
- return (...args) => maybeThen(resolveLazy(), (f) => {
29439
- if (!isFunction(f)) {
29440
- throw qError(QError_qrlIsNotFunction);
29441
- }
29442
- if (beforeFn && beforeFn() === false) {
29443
- return;
29444
- }
29445
- const context = createOrReuseInvocationContext(currentCtx);
29446
- const prevQrl = context.$qrl$;
29447
- const prevEvent = context.$event$;
29448
- context.$qrl$ = qrl2;
29449
- context.$event$ ||= this;
29450
- try {
29451
- return invoke.call(this, context, f, ...args);
29452
- } finally {
29453
- context.$qrl$ = prevQrl;
29454
- context.$event$ = prevEvent;
29455
- }
29456
- });
29457
- }
29458
29489
  const createOrReuseInvocationContext = (invoke2) => {
29459
29490
  if (invoke2 == null) {
29460
29491
  return newInvokeContext();
@@ -29477,7 +29508,7 @@ var createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef, refSym
29477
29508
  $symbol$: symbol,
29478
29509
  $refSymbol$: refSymbol,
29479
29510
  $hash$: hash3,
29480
- getFn: invokeFn,
29511
+ getFn: bindFnToContext,
29481
29512
  $capture$: capture,
29482
29513
  $captureRef$: captureRef,
29483
29514
  dev: null,
@@ -31160,6 +31191,7 @@ var SSRContainer = class extends import_core5._SharedContainer {
31160
31191
  };
31161
31192
  this.serializationCtx = this.serializationCtxFactory(
31162
31193
  SsrNode,
31194
+ DomRef,
31163
31195
  this.symbolToChunkResolver,
31164
31196
  opts.writer,
31165
31197
  (vNodeData) => this.addVNodeToSerializationRoots(vNodeData)
@@ -31175,9 +31207,6 @@ var SSRContainer = class extends import_core5._SharedContainer {
31175
31207
  }
31176
31208
  ensureProjectionResolved(host) {
31177
31209
  }
31178
- processJsx(host, jsx4) {
31179
- throw new Error("Should not get here.");
31180
- }
31181
31210
  handleError(err, $host$) {
31182
31211
  throw err;
31183
31212
  }
@@ -31933,10 +31962,10 @@ var SSRContainer = class extends import_core5._SharedContainer {
31933
31962
  if (key === "ref") {
31934
31963
  const lastNode = this.getLastNode();
31935
31964
  if ((0, import_core5.isSignal)(value)) {
31936
- value.value = lastNode;
31965
+ value.value = new DomRef(lastNode);
31937
31966
  continue;
31938
31967
  } else if (typeof value === "function") {
31939
- value(lastNode);
31968
+ value(new DomRef(lastNode));
31940
31969
  continue;
31941
31970
  }
31942
31971
  }