@qwik.dev/core 2.0.0-alpha.2 → 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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qwik.dev/core/build",
3
- "version": "2.0.0-alpha.2-dev+58b6f8d",
3
+ "version": "2.0.0-alpha.3-dev+418fd6d",
4
4
  "main": "index.mjs",
5
5
  "types": "index.d.ts",
6
6
  "private": true,
package/dist/cli.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * @qwik.dev/core/cli 2.0.0-alpha.2-dev+58b6f8d
3
+ * @qwik.dev/core/cli 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
@@ -5504,7 +5504,7 @@ async function printHelp(app) {
5504
5504
  await runCommand2(Object.assign(app, { task: args[0], args }));
5505
5505
  }
5506
5506
  function printVersion() {
5507
- console.log("2.0.0-alpha.2-dev+58b6f8d");
5507
+ console.log("2.0.0-alpha.3-dev+418fd6d");
5508
5508
  }
5509
5509
  // Annotate the CommonJS export names for ESM import in node:
5510
5510
  0 && (module.exports = {
@@ -530,7 +530,6 @@ declare interface Container {
530
530
  readonly $getObjectById$: (id: number | string) => any;
531
531
  readonly $serverData$: Record<string, any>;
532
532
  $currentUniqueId$: number;
533
- processJsx(host: HostElement, jsx: JSXOutput): ValueOrPromise<void>;
534
533
  handleError(err: any, $host$: HostElement): void;
535
534
  getParentHost(host: HostElement): HostElement | null;
536
535
  setContext<T>(host: HostElement, context: ContextId<T>, value: T): void;
@@ -554,7 +553,7 @@ declare interface Container {
554
553
  };
555
554
  } | null, DomRefConstructor: {
556
555
  new (...rest: any[]): {
557
- id: string;
556
+ $ssrNode$: ISsrNode;
558
557
  };
559
558
  } | null, symbolToChunkResolver: SymbolToChunkResolver, writer?: StreamWriter): SerializationContext;
560
559
  }
@@ -872,7 +871,6 @@ declare class DomContainer extends _SharedContainer implements ClientContainer {
872
871
  constructor(element: _ContainerElement);
873
872
  $setRawState$(id: number, vParent: _ElementVNode | _VirtualVNode): void;
874
873
  parseQRL<T = unknown>(qrl: string): QRL<T>;
875
- processJsx(host: HostElement, jsx: JSXOutput): ValueOrPromise<void>;
876
874
  handleError(err: any, host: HostElement): void;
877
875
  setContext<T>(host: HostElement, context: ContextId<T>, value: T): void;
878
876
  resolveContext<T>(host: HostElement, contextId: ContextId<T>): T | undefined;
@@ -890,7 +888,7 @@ export { DomContainer }
890
888
  export { DomContainer as _DomContainer }
891
889
 
892
890
  declare type DomRef = {
893
- id: string;
891
+ $ssrNode$: SsrNode;
894
892
  };
895
893
 
896
894
  /** @public */
@@ -2338,11 +2336,10 @@ export declare abstract class _SharedContainer implements Container {
2338
2336
  };
2339
2337
  } | null, DomRefConstructor: {
2340
2338
  new (...rest: any[]): {
2341
- id: string;
2339
+ $ssrNode$: ISsrNode;
2342
2340
  };
2343
2341
  } | null, symbolToChunkResolver: SymbolToChunkResolver, writer?: StreamWriter, prepVNodeData?: (vNode: any) => void): SerializationContext;
2344
2342
  abstract ensureProjectionResolved(host: HostElement): void;
2345
- abstract processJsx(host: HostElement, jsx: JSXOutput): ValueOrPromise<void>;
2346
2343
  abstract handleError(err: any, $host$: HostElement): void;
2347
2344
  abstract getParentHost(host: HostElement): HostElement | null;
2348
2345
  abstract setContext<T>(host: HostElement, context: ContextId<T>, value: T): void;
@@ -3721,7 +3718,7 @@ export declare const _VAR_PROPS: unique symbol;
3721
3718
  export declare const _verifySerializable: <T>(value: T, preMessage?: string) => T;
3722
3719
 
3723
3720
  /**
3724
- * 2.0.0-alpha.2-dev+58b6f8d
3721
+ * 2.0.0-alpha.3-dev+418fd6d
3725
3722
  *
3726
3723
  * @public
3727
3724
  */
package/dist/core.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * @qwik.dev/core 2.0.0-alpha.2-dev+58b6f8d
3
+ * @qwik.dev/core 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
@@ -3295,48 +3295,48 @@
3295
3295
  /////////////////////////////////////////////////////////////////////////////
3296
3296
  /////////////////////////////////////////////////////////////////////////////
3297
3297
  function descendContentToProject(children, host) {
3298
- if (!Array.isArray(children)) {
3299
- children = [children];
3300
- }
3301
- if (children.length) {
3302
- const createProjectionJSXNode = (slotName) => {
3303
- return new JSXNodeImpl(Projection, EMPTY_OBJ, null, [], 0, slotName);
3304
- };
3305
- const projections = [];
3306
- if (host) {
3307
- // we need to create empty projections for all the slots to remove unused slots content
3308
- for (let i = vnode_getPropStartIndex(host); i < host.length; i = i + 2) {
3309
- const prop = host[i];
3310
- if (isSlotProp(prop)) {
3311
- const slotName = prop;
3312
- projections.push(slotName);
3313
- projections.push(createProjectionJSXNode(slotName));
3314
- }
3298
+ const projectionChildren = Array.isArray(children) ? children : [children];
3299
+ const createProjectionJSXNode = (slotName) => {
3300
+ return new JSXNodeImpl(Projection, EMPTY_OBJ, null, [], 0, slotName);
3301
+ };
3302
+ const projections = [];
3303
+ if (host) {
3304
+ // we need to create empty projections for all the slots to remove unused slots content
3305
+ for (let i = vnode_getPropStartIndex(host); i < host.length; i = i + 2) {
3306
+ const prop = host[i];
3307
+ if (isSlotProp(prop)) {
3308
+ const slotName = prop;
3309
+ projections.push(slotName);
3310
+ projections.push(createProjectionJSXNode(slotName));
3315
3311
  }
3316
3312
  }
3317
- /// STEP 1: Bucketize the children based on the projection name.
3318
- for (let i = 0; i < children.length; i++) {
3319
- const child = children[i];
3320
- const slotName = String((isJSXNode(child) && directGetPropsProxyProp(child, QSlot)) || QDefaultSlot);
3321
- const idx = mapApp_findIndx(projections, slotName, 0);
3322
- let jsxBucket;
3323
- if (idx >= 0) {
3324
- jsxBucket = projections[idx + 1];
3325
- }
3326
- else {
3327
- projections.splice(~idx, 0, slotName, (jsxBucket = createProjectionJSXNode(slotName)));
3328
- }
3329
- const removeProjection = child === false;
3330
- if (!removeProjection) {
3331
- jsxBucket.children.push(child);
3332
- }
3313
+ }
3314
+ if (projections.length === 0 && children == null) {
3315
+ // We did not find any existing slots and we don't have any children to project.
3316
+ return;
3317
+ }
3318
+ /// STEP 1: Bucketize the children based on the projection name.
3319
+ for (let i = 0; i < projectionChildren.length; i++) {
3320
+ const child = projectionChildren[i];
3321
+ const slotName = String((isJSXNode(child) && directGetPropsProxyProp(child, QSlot)) || QDefaultSlot);
3322
+ const idx = mapApp_findIndx(projections, slotName, 0);
3323
+ let jsxBucket;
3324
+ if (idx >= 0) {
3325
+ jsxBucket = projections[idx + 1];
3326
+ }
3327
+ else {
3328
+ projections.splice(~idx, 0, slotName, (jsxBucket = createProjectionJSXNode(slotName)));
3333
3329
  }
3334
- /// STEP 2: remove the names
3335
- for (let i = projections.length - 2; i >= 0; i = i - 2) {
3336
- projections.splice(i, 1);
3330
+ const removeProjection = child === false;
3331
+ if (!removeProjection) {
3332
+ jsxBucket.children.push(child);
3337
3333
  }
3338
- descend(projections, true);
3339
3334
  }
3335
+ /// STEP 2: remove the names
3336
+ for (let i = projections.length - 2; i >= 0; i = i - 2) {
3337
+ projections.splice(i, 1);
3338
+ }
3339
+ descend(projections, true);
3340
3340
  }
3341
3341
  function expectProjection() {
3342
3342
  const jsxNode = jsxValue;
@@ -3858,7 +3858,7 @@
3858
3858
  container.$scheduler$(ChoreType.COMPONENT, host, componentQRL, jsxProps);
3859
3859
  }
3860
3860
  }
3861
- jsxNode.children != null && descendContentToProject(jsxNode.children, host);
3861
+ descendContentToProject(jsxNode.children, host);
3862
3862
  }
3863
3863
  else {
3864
3864
  const lookupKey = jsxNode.key;
@@ -4359,9 +4359,13 @@
4359
4359
  case ChoreType.COMPONENT:
4360
4360
  case ChoreType.COMPONENT_SSR:
4361
4361
  returnValue = safeCall(() => executeComponent(container, host, host, chore.$target$, chore.$payload$), (jsx) => {
4362
- return chore.$type$ === ChoreType.COMPONENT
4363
- ? maybeThen(container.processJsx(host, jsx), () => jsx)
4364
- : jsx;
4362
+ if (chore.$type$ === ChoreType.COMPONENT) {
4363
+ const styleScopedId = container.getHostProp(host, QScopedStyle);
4364
+ return vnode_diff(container, jsx, host, addComponentStylePrefix(styleScopedId));
4365
+ }
4366
+ else {
4367
+ return jsx;
4368
+ }
4365
4369
  }, (err) => container.handleError(err, host));
4366
4370
  break;
4367
4371
  case ChoreType.RESOURCE:
@@ -4536,7 +4540,7 @@
4536
4540
  *
4537
4541
  * @public
4538
4542
  */
4539
- const version = "2.0.0-alpha.2-dev+58b6f8d";
4543
+ const version = "2.0.0-alpha.3-dev+418fd6d";
4540
4544
 
4541
4545
  /** @internal */
4542
4546
  class _SharedContainer {
@@ -5086,11 +5090,6 @@
5086
5090
  parseQRL(qrl) {
5087
5091
  return inflateQRL(this, parseQRL(qrl));
5088
5092
  }
5089
- processJsx(host, jsx) {
5090
- // console.log('>>>> processJsx', String(host));
5091
- const styleScopedId = this.getHostProp(host, QScopedStyle);
5092
- return vnode_diff(this, jsx, host, addComponentStylePrefix(styleScopedId));
5093
- }
5094
5093
  handleError(err, host) {
5095
5094
  if (qDev) {
5096
5095
  // Clean vdom
@@ -8052,7 +8051,10 @@
8052
8051
  if (valType === TypeIds.RootRef || valType >= TypeIds.Error) {
8053
8052
  Object.defineProperty(target, key, {
8054
8053
  get() {
8055
- return deserializeData(container, valType, valData);
8054
+ const value = deserializeData(container, valType, valData);
8055
+ // after first deserialize, we can replace the Object.defineProperty with the value
8056
+ target[key] = value;
8057
+ return value;
8056
8058
  },
8057
8059
  set(value) {
8058
8060
  Object.defineProperty(target, key, {
@@ -8394,6 +8396,7 @@
8394
8396
  }
8395
8397
  return qrl;
8396
8398
  }
8399
+ let isDomRef = (obj) => false;
8397
8400
  const createSerializationContext = (
8398
8401
  /**
8399
8402
  * Node constructor, for instanceof checks.
@@ -8429,7 +8432,7 @@
8429
8432
  return id;
8430
8433
  };
8431
8434
  const isSsrNode = (NodeConstructor ? (obj) => obj instanceof NodeConstructor : () => false);
8432
- const isDomRef = (DomRefConstructor ? (obj) => obj instanceof DomRefConstructor : () => false);
8435
+ isDomRef = (DomRefConstructor ? (obj) => obj instanceof DomRefConstructor : () => false);
8433
8436
  return {
8434
8437
  $serialize$() {
8435
8438
  serialize(this);
@@ -8582,7 +8585,7 @@
8582
8585
  discoveredValues.push(obj.vnodeData);
8583
8586
  }
8584
8587
  else if (isDomRef(obj)) {
8585
- discoveredValues.push(obj.id);
8588
+ discoveredValues.push(obj.$ssrNode$.id);
8586
8589
  }
8587
8590
  else if (isJSXNode(obj)) {
8588
8591
  discoveredValues.push(obj.type, obj.props, obj.constProps, obj.children);
@@ -8880,7 +8883,8 @@
8880
8883
  }
8881
8884
  }
8882
8885
  else if ($isDomRef$(value)) {
8883
- output(TypeIds.RefVNode, value.id);
8886
+ value.$ssrNode$.vnodeData[0] |= VNodeDataFlag.SERIALIZE;
8887
+ output(TypeIds.RefVNode, value.$ssrNode$.id);
8884
8888
  }
8885
8889
  else if (value instanceof Signal) {
8886
8890
  /**
@@ -9298,6 +9302,9 @@
9298
9302
  else if (value instanceof Uint8Array) {
9299
9303
  return true;
9300
9304
  }
9305
+ else if (isDomRef?.(value)) {
9306
+ return true;
9307
+ }
9301
9308
  }
9302
9309
  else if (typeof value === 'function') {
9303
9310
  if (isQrl(value) || isQwikComponent(value)) {