@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.
package/dist/core.mjs 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
@@ -3292,48 +3292,48 @@ const vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
3292
3292
  /////////////////////////////////////////////////////////////////////////////
3293
3293
  /////////////////////////////////////////////////////////////////////////////
3294
3294
  function descendContentToProject(children, host) {
3295
- if (!Array.isArray(children)) {
3296
- children = [children];
3297
- }
3298
- if (children.length) {
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));
3311
- }
3295
+ const projectionChildren = Array.isArray(children) ? children : [children];
3296
+ const createProjectionJSXNode = (slotName) => {
3297
+ return new JSXNodeImpl(Projection, EMPTY_OBJ, null, [], 0, slotName);
3298
+ };
3299
+ const projections = [];
3300
+ if (host) {
3301
+ // we need to create empty projections for all the slots to remove unused slots content
3302
+ for (let i = vnode_getPropStartIndex(host); i < host.length; i = i + 2) {
3303
+ const prop = host[i];
3304
+ if (isSlotProp(prop)) {
3305
+ const slotName = prop;
3306
+ projections.push(slotName);
3307
+ projections.push(createProjectionJSXNode(slotName));
3312
3308
  }
3313
3309
  }
3314
- /// STEP 1: Bucketize the children based on the projection name.
3315
- for (let i = 0; i < children.length; i++) {
3316
- const child = children[i];
3317
- const slotName = String((isJSXNode(child) && directGetPropsProxyProp(child, QSlot)) || QDefaultSlot);
3318
- const idx = mapApp_findIndx(projections, slotName, 0);
3319
- let jsxBucket;
3320
- if (idx >= 0) {
3321
- jsxBucket = projections[idx + 1];
3322
- }
3323
- else {
3324
- projections.splice(~idx, 0, slotName, (jsxBucket = createProjectionJSXNode(slotName)));
3325
- }
3326
- const removeProjection = child === false;
3327
- if (!removeProjection) {
3328
- jsxBucket.children.push(child);
3329
- }
3310
+ }
3311
+ if (projections.length === 0 && children == null) {
3312
+ // We did not find any existing slots and we don't have any children to project.
3313
+ return;
3314
+ }
3315
+ /// STEP 1: Bucketize the children based on the projection name.
3316
+ for (let i = 0; i < projectionChildren.length; i++) {
3317
+ const child = projectionChildren[i];
3318
+ const slotName = String((isJSXNode(child) && directGetPropsProxyProp(child, QSlot)) || QDefaultSlot);
3319
+ const idx = mapApp_findIndx(projections, slotName, 0);
3320
+ let jsxBucket;
3321
+ if (idx >= 0) {
3322
+ jsxBucket = projections[idx + 1];
3323
+ }
3324
+ else {
3325
+ projections.splice(~idx, 0, slotName, (jsxBucket = createProjectionJSXNode(slotName)));
3330
3326
  }
3331
- /// STEP 2: remove the names
3332
- for (let i = projections.length - 2; i >= 0; i = i - 2) {
3333
- projections.splice(i, 1);
3327
+ const removeProjection = child === false;
3328
+ if (!removeProjection) {
3329
+ jsxBucket.children.push(child);
3334
3330
  }
3335
- descend(projections, true);
3336
3331
  }
3332
+ /// STEP 2: remove the names
3333
+ for (let i = projections.length - 2; i >= 0; i = i - 2) {
3334
+ projections.splice(i, 1);
3335
+ }
3336
+ descend(projections, true);
3337
3337
  }
3338
3338
  function expectProjection() {
3339
3339
  const jsxNode = jsxValue;
@@ -3855,7 +3855,7 @@ const vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
3855
3855
  container.$scheduler$(ChoreType.COMPONENT, host, componentQRL, jsxProps);
3856
3856
  }
3857
3857
  }
3858
- jsxNode.children != null && descendContentToProject(jsxNode.children, host);
3858
+ descendContentToProject(jsxNode.children, host);
3859
3859
  }
3860
3860
  else {
3861
3861
  const lookupKey = jsxNode.key;
@@ -4356,9 +4356,13 @@ const createScheduler = (container, scheduleDrain, journalFlush) => {
4356
4356
  case ChoreType.COMPONENT:
4357
4357
  case ChoreType.COMPONENT_SSR:
4358
4358
  returnValue = safeCall(() => executeComponent(container, host, host, chore.$target$, chore.$payload$), (jsx) => {
4359
- return chore.$type$ === ChoreType.COMPONENT
4360
- ? maybeThen(container.processJsx(host, jsx), () => jsx)
4361
- : jsx;
4359
+ if (chore.$type$ === ChoreType.COMPONENT) {
4360
+ const styleScopedId = container.getHostProp(host, QScopedStyle);
4361
+ return vnode_diff(container, jsx, host, addComponentStylePrefix(styleScopedId));
4362
+ }
4363
+ else {
4364
+ return jsx;
4365
+ }
4362
4366
  }, (err) => container.handleError(err, host));
4363
4367
  break;
4364
4368
  case ChoreType.RESOURCE:
@@ -4533,7 +4537,7 @@ function sortedInsert(sortedArray, value) {
4533
4537
  *
4534
4538
  * @public
4535
4539
  */
4536
- const version = "2.0.0-alpha.2-dev+58b6f8d";
4540
+ const version = "2.0.0-alpha.3-dev+418fd6d";
4537
4541
 
4538
4542
  /** @internal */
4539
4543
  class _SharedContainer {
@@ -5083,11 +5087,6 @@ class DomContainer extends _SharedContainer {
5083
5087
  parseQRL(qrl) {
5084
5088
  return inflateQRL(this, parseQRL(qrl));
5085
5089
  }
5086
- processJsx(host, jsx) {
5087
- // console.log('>>>> processJsx', String(host));
5088
- const styleScopedId = this.getHostProp(host, QScopedStyle);
5089
- return vnode_diff(this, jsx, host, addComponentStylePrefix(styleScopedId));
5090
- }
5091
5090
  handleError(err, host) {
5092
5091
  if (qDev) {
5093
5092
  // Clean vdom
@@ -8049,7 +8048,10 @@ const inflate = (container, target, typeId, data) => {
8049
8048
  if (valType === TypeIds.RootRef || valType >= TypeIds.Error) {
8050
8049
  Object.defineProperty(target, key, {
8051
8050
  get() {
8052
- return deserializeData(container, valType, valData);
8051
+ const value = deserializeData(container, valType, valData);
8052
+ // after first deserialize, we can replace the Object.defineProperty with the value
8053
+ target[key] = value;
8054
+ return value;
8053
8055
  },
8054
8056
  set(value) {
8055
8057
  Object.defineProperty(target, key, {
@@ -8391,6 +8393,7 @@ function inflateQRL(container, qrl) {
8391
8393
  }
8392
8394
  return qrl;
8393
8395
  }
8396
+ let isDomRef = (obj) => false;
8394
8397
  const createSerializationContext = (
8395
8398
  /**
8396
8399
  * Node constructor, for instanceof checks.
@@ -8426,7 +8429,7 @@ prepVNodeData) => {
8426
8429
  return id;
8427
8430
  };
8428
8431
  const isSsrNode = (NodeConstructor ? (obj) => obj instanceof NodeConstructor : () => false);
8429
- const isDomRef = (DomRefConstructor ? (obj) => obj instanceof DomRefConstructor : () => false);
8432
+ isDomRef = (DomRefConstructor ? (obj) => obj instanceof DomRefConstructor : () => false);
8430
8433
  return {
8431
8434
  $serialize$() {
8432
8435
  serialize(this);
@@ -8579,7 +8582,7 @@ prepVNodeData) => {
8579
8582
  discoveredValues.push(obj.vnodeData);
8580
8583
  }
8581
8584
  else if (isDomRef(obj)) {
8582
- discoveredValues.push(obj.id);
8585
+ discoveredValues.push(obj.$ssrNode$.id);
8583
8586
  }
8584
8587
  else if (isJSXNode(obj)) {
8585
8588
  discoveredValues.push(obj.type, obj.props, obj.constProps, obj.children);
@@ -8877,7 +8880,8 @@ function serialize(serializationContext) {
8877
8880
  }
8878
8881
  }
8879
8882
  else if ($isDomRef$(value)) {
8880
- output(TypeIds.RefVNode, value.id);
8883
+ value.$ssrNode$.vnodeData[0] |= VNodeDataFlag.SERIALIZE;
8884
+ output(TypeIds.RefVNode, value.$ssrNode$.id);
8881
8885
  }
8882
8886
  else if (value instanceof Signal) {
8883
8887
  /**
@@ -9295,6 +9299,9 @@ const canSerialize = (value) => {
9295
9299
  else if (value instanceof Uint8Array) {
9296
9300
  return true;
9297
9301
  }
9302
+ else if (isDomRef?.(value)) {
9303
+ return true;
9304
+ }
9298
9305
  }
9299
9306
  else if (typeof value === 'function') {
9300
9307
  if (isQrl(value) || isQwikComponent(value)) {