@qwik.dev/core 2.0.0-alpha.5 → 2.0.0-alpha.6
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/bindings/qwik.darwin-arm64.node +0 -0
- package/bindings/qwik.darwin-x64.node +0 -0
- package/bindings/qwik.linux-x64-gnu.node +0 -0
- package/bindings/qwik.win32-x64-msvc.node +0 -0
- package/bindings/qwik_wasm_bg.wasm +0 -0
- package/dist/build/package.json +1 -1
- package/dist/cli.cjs +2 -23
- package/dist/core-internal.d.ts +2 -2
- package/dist/core.cjs +268 -190
- package/dist/core.cjs.map +1 -1
- package/dist/core.min.mjs +1 -1
- package/dist/core.mjs +268 -190
- package/dist/core.mjs.map +1 -1
- package/dist/core.prod.cjs +119 -84
- package/dist/core.prod.mjs +206 -167
- package/dist/insights/index.qwik.cjs +8 -8
- package/dist/insights/index.qwik.mjs +8 -8
- package/dist/loader/package.json +1 -1
- package/dist/optimizer.cjs +170 -127
- package/dist/optimizer.mjs +222 -176
- package/dist/prefetch/package.json +1 -1
- package/dist/server.cjs +222 -170
- package/dist/server.mjs +222 -170
- package/dist/starters/features/turso/src/utils/turso.ts +1 -1
- package/dist/testing/index.cjs +220 -168
- package/dist/testing/index.mjs +220 -168
- package/dist/testing/package.json +1 -1
- package/package.json +3 -3
package/dist/core.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* @qwik.dev/core 2.0.0-alpha.
|
|
3
|
+
* @qwik.dev/core 2.0.0-alpha.6-dev+d848ba5
|
|
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
|
|
@@ -162,7 +162,6 @@ const codeToText = (code, ...parts) => {
|
|
|
162
162
|
"Element must have 'q:container' attribute.", // 42
|
|
163
163
|
'Unknown vnode type {{0}}.', // 43
|
|
164
164
|
'Materialize error: missing element: {{0}} {{1}} {{2}}', // 44
|
|
165
|
-
'SsrError: {{0}}', // 45
|
|
166
165
|
'Cannot coerce a Signal, use `.value` instead', // 46
|
|
167
166
|
'useComputedSignal$ QRL {{0}} {{1}} returned a Promise', // 47
|
|
168
167
|
'ComputedSignal is read-only', // 48
|
|
@@ -234,19 +233,130 @@ var QError;
|
|
|
234
233
|
QError[QError["elementWithoutContainer"] = 42] = "elementWithoutContainer";
|
|
235
234
|
QError[QError["invalidVNodeType"] = 43] = "invalidVNodeType";
|
|
236
235
|
QError[QError["materializeVNodeDataError"] = 44] = "materializeVNodeDataError";
|
|
237
|
-
QError[QError["
|
|
238
|
-
QError[QError["
|
|
239
|
-
QError[QError["
|
|
240
|
-
QError[QError["
|
|
241
|
-
QError[QError["
|
|
242
|
-
QError[QError["
|
|
243
|
-
QError[QError["unsafeAttr"] = 51] = "unsafeAttr";
|
|
236
|
+
QError[QError["cannotCoerceSignal"] = 45] = "cannotCoerceSignal";
|
|
237
|
+
QError[QError["computedNotSync"] = 46] = "computedNotSync";
|
|
238
|
+
QError[QError["computedReadOnly"] = 47] = "computedReadOnly";
|
|
239
|
+
QError[QError["wrappedReadOnly"] = 48] = "wrappedReadOnly";
|
|
240
|
+
QError[QError["promisesNotExpected"] = 49] = "promisesNotExpected";
|
|
241
|
+
QError[QError["unsafeAttr"] = 50] = "unsafeAttr";
|
|
244
242
|
})(QError || (QError = {}));
|
|
245
243
|
const qError = (code, errorMessageArgs = []) => {
|
|
246
244
|
const text = codeToText(code, ...errorMessageArgs);
|
|
247
245
|
return logErrorAndStop(text, ...errorMessageArgs);
|
|
248
246
|
};
|
|
249
247
|
|
|
248
|
+
/**
|
|
249
|
+
* A friendly name tag for a VirtualVNode.
|
|
250
|
+
*
|
|
251
|
+
* Theses are used to give a name to a VirtualVNode. This is useful for debugging and testing.
|
|
252
|
+
*
|
|
253
|
+
* The name is only added in development mode and is not included in production builds.
|
|
254
|
+
*/
|
|
255
|
+
const DEBUG_TYPE = 'q:type';
|
|
256
|
+
var VirtualType;
|
|
257
|
+
(function (VirtualType) {
|
|
258
|
+
VirtualType["Virtual"] = "V";
|
|
259
|
+
VirtualType["Fragment"] = "F";
|
|
260
|
+
VirtualType["WrappedSignal"] = "S";
|
|
261
|
+
VirtualType["Awaited"] = "A";
|
|
262
|
+
VirtualType["Component"] = "C";
|
|
263
|
+
VirtualType["InlineComponent"] = "I";
|
|
264
|
+
VirtualType["Projection"] = "P";
|
|
265
|
+
})(VirtualType || (VirtualType = {}));
|
|
266
|
+
const START = '\x1b[34m';
|
|
267
|
+
const END = '\x1b[0m';
|
|
268
|
+
const VirtualTypeName = {
|
|
269
|
+
[VirtualType.Virtual]: /* ********* */ START + 'Virtual' + END, //
|
|
270
|
+
[VirtualType.Fragment]: /* ******** */ START + 'Fragment' + END, //
|
|
271
|
+
[VirtualType.WrappedSignal]: /* *** */ START + 'Signal' + END, //
|
|
272
|
+
[VirtualType.Awaited]: /* ********* */ START + 'Awaited' + END, //
|
|
273
|
+
[VirtualType.Component]: /* ******* */ START + 'Component' + END, //
|
|
274
|
+
[VirtualType.InlineComponent]: /* * */ START + 'InlineComponent' + END, //
|
|
275
|
+
[VirtualType.Projection]: /* ****** */ START + 'Projection' + END, //
|
|
276
|
+
};
|
|
277
|
+
var QContainerValue;
|
|
278
|
+
(function (QContainerValue) {
|
|
279
|
+
QContainerValue["PAUSED"] = "paused";
|
|
280
|
+
QContainerValue["RESUMED"] = "resumed";
|
|
281
|
+
// these values below are used in the qwik loader as a plain text for the q:container selector
|
|
282
|
+
// standard dangerouslySetInnerHTML
|
|
283
|
+
QContainerValue["HTML"] = "html";
|
|
284
|
+
// textarea
|
|
285
|
+
QContainerValue["TEXT"] = "text";
|
|
286
|
+
})(QContainerValue || (QContainerValue = {}));
|
|
287
|
+
|
|
288
|
+
/** State factory of the component. */
|
|
289
|
+
const OnRenderProp = 'q:renderFn';
|
|
290
|
+
/** Component style content prefix */
|
|
291
|
+
const ComponentStylesPrefixContent = '⭐️';
|
|
292
|
+
/** `<some-element q:slot="...">` */
|
|
293
|
+
const QSlot = 'q:slot';
|
|
294
|
+
const QSlotParent = ':';
|
|
295
|
+
const QSlotRef = 'q:sref';
|
|
296
|
+
const QSlotS = 'q:s';
|
|
297
|
+
const QStyle = 'q:style';
|
|
298
|
+
const QStyleSelector = 'style[q\\:style]';
|
|
299
|
+
const QStyleSSelector = 'style[q\\:sstyle]';
|
|
300
|
+
const QStylesAllSelector = QStyleSelector + ',' + QStyleSSelector;
|
|
301
|
+
const QScopedStyle = 'q:sstyle';
|
|
302
|
+
const QCtxAttr = 'q:ctx';
|
|
303
|
+
const QSubscribers = 'q:subs';
|
|
304
|
+
const QFuncsPrefix = 'qFuncs_';
|
|
305
|
+
const getQFuncs = (document, hash) => {
|
|
306
|
+
return document[QFuncsPrefix + hash] || [];
|
|
307
|
+
};
|
|
308
|
+
const QBaseAttr = 'q:base';
|
|
309
|
+
const QLocaleAttr = 'q:locale';
|
|
310
|
+
const QManifestHashAttr = 'q:manifest-hash';
|
|
311
|
+
const QInstanceAttr = 'q:instance';
|
|
312
|
+
const QContainerIsland = 'q:container-island';
|
|
313
|
+
const QContainerIslandEnd = '/' + QContainerIsland;
|
|
314
|
+
const QIgnore = 'q:ignore';
|
|
315
|
+
const QIgnoreEnd = '/' + QIgnore;
|
|
316
|
+
const QContainerAttr = 'q:container';
|
|
317
|
+
const QContainerAttrEnd = '/' + QContainerAttr;
|
|
318
|
+
const QTemplate = 'q:template';
|
|
319
|
+
// the same selector should be inside the qwik loader
|
|
320
|
+
// and the same selector should be inside the qwik router spa-shim and spa-init
|
|
321
|
+
const QContainerSelector = '[q\\:container]:not([q\\:container=' +
|
|
322
|
+
QContainerValue.HTML +
|
|
323
|
+
']):not([q\\:container=' +
|
|
324
|
+
QContainerValue.TEXT +
|
|
325
|
+
'])';
|
|
326
|
+
const HTML_NS = 'http://www.w3.org/1999/xhtml';
|
|
327
|
+
const SVG_NS = 'http://www.w3.org/2000/svg';
|
|
328
|
+
const MATH_NS = 'http://www.w3.org/1998/Math/MathML';
|
|
329
|
+
const ResourceEvent = 'qResource';
|
|
330
|
+
const RenderEvent = 'qRender';
|
|
331
|
+
const TaskEvent = 'qTask';
|
|
332
|
+
const QDefaultSlot = '';
|
|
333
|
+
/**
|
|
334
|
+
* Attribute to mark that this VNode has a pointer to itself from the `qwik/json` state.
|
|
335
|
+
*
|
|
336
|
+
* As the VNode get materialized the vnode now becomes eligible for mutation. Once the vnode mutates
|
|
337
|
+
* the `VNode` references from the `qwik/json` may become invalid. For this reason, these references
|
|
338
|
+
* need to be eagerly resolved. `VNODE_REF` stores a pointer to "this" vnode. This allows the system
|
|
339
|
+
* to eagerly resolve these pointes as the vnodes are materialized.
|
|
340
|
+
*/
|
|
341
|
+
const ELEMENT_ID = 'q:id';
|
|
342
|
+
const ELEMENT_KEY = 'q:key';
|
|
343
|
+
const ELEMENT_PROPS = 'q:props';
|
|
344
|
+
const ELEMENT_SEQ = 'q:seq';
|
|
345
|
+
const ELEMENT_SEQ_IDX = 'q:seqIdx';
|
|
346
|
+
const Q_PREFIX = 'q:';
|
|
347
|
+
/** Non serializable markers - always begins with `:` character */
|
|
348
|
+
const NON_SERIALIZABLE_MARKER_PREFIX = ':';
|
|
349
|
+
const USE_ON_LOCAL = NON_SERIALIZABLE_MARKER_PREFIX + 'on';
|
|
350
|
+
const USE_ON_LOCAL_SEQ_IDX = NON_SERIALIZABLE_MARKER_PREFIX + 'onIdx';
|
|
351
|
+
const USE_ON_LOCAL_FLAGS = NON_SERIALIZABLE_MARKER_PREFIX + 'onFlags';
|
|
352
|
+
// comment nodes
|
|
353
|
+
const FLUSH_COMMENT = 'qkssr-f';
|
|
354
|
+
const STREAM_BLOCK_START_COMMENT = 'qkssr-pu';
|
|
355
|
+
const STREAM_BLOCK_END_COMMENT = 'qkssr-po';
|
|
356
|
+
const Q_PROPS_SEPARATOR = ':';
|
|
357
|
+
const dangerouslySetInnerHTML = 'dangerouslySetInnerHTML';
|
|
358
|
+
const qwikInspectorAttr = 'data-qwik-inspector';
|
|
359
|
+
|
|
250
360
|
// keep this import from core/build so the cjs build works
|
|
251
361
|
const createPlatform = () => {
|
|
252
362
|
return {
|
|
@@ -307,7 +417,7 @@ const createPlatform = () => {
|
|
|
307
417
|
*/
|
|
308
418
|
const toUrl = (doc, containerEl, url) => {
|
|
309
419
|
const baseURI = doc.baseURI;
|
|
310
|
-
const base = new URL(containerEl.getAttribute(
|
|
420
|
+
const base = new URL(containerEl.getAttribute(QBaseAttr) ?? baseURI, baseURI);
|
|
311
421
|
return new URL(url, base);
|
|
312
422
|
};
|
|
313
423
|
let _platform = /*#__PURE__ */ createPlatform();
|
|
@@ -399,15 +509,24 @@ const delay = (timeout) => {
|
|
|
399
509
|
setTimeout(resolve, timeout);
|
|
400
510
|
});
|
|
401
511
|
};
|
|
512
|
+
// Retries a function that throws a promise.
|
|
402
513
|
function retryOnPromise(fn, retryCount = 0) {
|
|
403
|
-
|
|
404
|
-
return fn();
|
|
405
|
-
}
|
|
406
|
-
catch (e) {
|
|
514
|
+
const retryOrThrow = (e) => {
|
|
407
515
|
if (isPromise(e) && retryCount < MAX_RETRY_ON_PROMISE_COUNT) {
|
|
408
516
|
return e.then(retryOnPromise.bind(null, fn, retryCount++));
|
|
409
517
|
}
|
|
410
518
|
throw e;
|
|
519
|
+
};
|
|
520
|
+
try {
|
|
521
|
+
const result = fn();
|
|
522
|
+
if (isPromise(result)) {
|
|
523
|
+
// not awaited promise is not caught by try/catch block
|
|
524
|
+
return result.catch((e) => retryOrThrow(e));
|
|
525
|
+
}
|
|
526
|
+
return result;
|
|
527
|
+
}
|
|
528
|
+
catch (e) {
|
|
529
|
+
return retryOrThrow(e);
|
|
411
530
|
}
|
|
412
531
|
}
|
|
413
532
|
|
|
@@ -450,118 +569,6 @@ var VNodeDataFlag;
|
|
|
450
569
|
VNodeDataFlag[VNodeDataFlag["SERIALIZE"] = 16] = "SERIALIZE";
|
|
451
570
|
})(VNodeDataFlag || (VNodeDataFlag = {}));
|
|
452
571
|
|
|
453
|
-
/**
|
|
454
|
-
* A friendly name tag for a VirtualVNode.
|
|
455
|
-
*
|
|
456
|
-
* Theses are used to give a name to a VirtualVNode. This is useful for debugging and testing.
|
|
457
|
-
*
|
|
458
|
-
* The name is only added in development mode and is not included in production builds.
|
|
459
|
-
*/
|
|
460
|
-
const DEBUG_TYPE = 'q:type';
|
|
461
|
-
var VirtualType;
|
|
462
|
-
(function (VirtualType) {
|
|
463
|
-
VirtualType["Virtual"] = "V";
|
|
464
|
-
VirtualType["Fragment"] = "F";
|
|
465
|
-
VirtualType["WrappedSignal"] = "S";
|
|
466
|
-
VirtualType["Awaited"] = "A";
|
|
467
|
-
VirtualType["Component"] = "C";
|
|
468
|
-
VirtualType["InlineComponent"] = "I";
|
|
469
|
-
VirtualType["Projection"] = "P";
|
|
470
|
-
})(VirtualType || (VirtualType = {}));
|
|
471
|
-
const START = '\x1b[34m';
|
|
472
|
-
const END = '\x1b[0m';
|
|
473
|
-
const VirtualTypeName = {
|
|
474
|
-
[VirtualType.Virtual]: /* ********* */ START + 'Virtual' + END, //
|
|
475
|
-
[VirtualType.Fragment]: /* ******** */ START + 'Fragment' + END, //
|
|
476
|
-
[VirtualType.WrappedSignal]: /* *** */ START + 'Signal' + END, //
|
|
477
|
-
[VirtualType.Awaited]: /* ********* */ START + 'Awaited' + END, //
|
|
478
|
-
[VirtualType.Component]: /* ******* */ START + 'Component' + END, //
|
|
479
|
-
[VirtualType.InlineComponent]: /* * */ START + 'InlineComponent' + END, //
|
|
480
|
-
[VirtualType.Projection]: /* ****** */ START + 'Projection' + END, //
|
|
481
|
-
};
|
|
482
|
-
var QContainerValue;
|
|
483
|
-
(function (QContainerValue) {
|
|
484
|
-
QContainerValue["PAUSED"] = "paused";
|
|
485
|
-
QContainerValue["RESUMED"] = "resumed";
|
|
486
|
-
// these values below are used in the qwik loader as a plain text for the q:container selector
|
|
487
|
-
// standard dangerouslySetInnerHTML
|
|
488
|
-
QContainerValue["HTML"] = "html";
|
|
489
|
-
// textarea
|
|
490
|
-
QContainerValue["TEXT"] = "text";
|
|
491
|
-
})(QContainerValue || (QContainerValue = {}));
|
|
492
|
-
|
|
493
|
-
/** State factory of the component. */
|
|
494
|
-
const OnRenderProp = 'q:renderFn';
|
|
495
|
-
/** Component style content prefix */
|
|
496
|
-
const ComponentStylesPrefixContent = '⭐️';
|
|
497
|
-
/** `<some-element q:slot="...">` */
|
|
498
|
-
const QSlot = 'q:slot';
|
|
499
|
-
const QSlotParent = ':';
|
|
500
|
-
const QSlotRef = 'q:sref';
|
|
501
|
-
const QSlotS = 'q:s';
|
|
502
|
-
const QStyle = 'q:style';
|
|
503
|
-
const QStyleSelector = 'style[q\\:style]';
|
|
504
|
-
const QStyleSSelector = 'style[q\\:sstyle]';
|
|
505
|
-
const QStylesAllSelector = QStyleSelector + ',' + QStyleSSelector;
|
|
506
|
-
const QScopedStyle = 'q:sstyle';
|
|
507
|
-
const QCtxAttr = 'q:ctx';
|
|
508
|
-
const QSubscribers = 'q:subs';
|
|
509
|
-
const QFuncsPrefix = 'qFuncs_';
|
|
510
|
-
const getQFuncs = (document, hash) => {
|
|
511
|
-
return document[QFuncsPrefix + hash] || [];
|
|
512
|
-
};
|
|
513
|
-
const QBaseAttr = 'q:base';
|
|
514
|
-
const QLocaleAttr = 'q:locale';
|
|
515
|
-
const QManifestHashAttr = 'q:manifest-hash';
|
|
516
|
-
const QInstanceAttr = 'q:instance';
|
|
517
|
-
const QContainerIsland = 'q:container-island';
|
|
518
|
-
const QContainerIslandEnd = '/' + QContainerIsland;
|
|
519
|
-
const QIgnore = 'q:ignore';
|
|
520
|
-
const QIgnoreEnd = '/' + QIgnore;
|
|
521
|
-
const QContainerAttr = 'q:container';
|
|
522
|
-
const QContainerAttrEnd = '/' + QContainerAttr;
|
|
523
|
-
const QTemplate = 'q:template';
|
|
524
|
-
// the same selector should be inside the qwik loader
|
|
525
|
-
// and the same selector should be inside the qwik router spa-shim and spa-init
|
|
526
|
-
const QContainerSelector = '[q\\:container]:not([q\\:container=' +
|
|
527
|
-
QContainerValue.HTML +
|
|
528
|
-
']):not([q\\:container=' +
|
|
529
|
-
QContainerValue.TEXT +
|
|
530
|
-
'])';
|
|
531
|
-
const HTML_NS = 'http://www.w3.org/1999/xhtml';
|
|
532
|
-
const SVG_NS = 'http://www.w3.org/2000/svg';
|
|
533
|
-
const MATH_NS = 'http://www.w3.org/1998/Math/MathML';
|
|
534
|
-
const ResourceEvent = 'qResource';
|
|
535
|
-
const RenderEvent = 'qRender';
|
|
536
|
-
const TaskEvent = 'qTask';
|
|
537
|
-
const QDefaultSlot = '';
|
|
538
|
-
/**
|
|
539
|
-
* Attribute to mark that this VNode has a pointer to itself from the `qwik/json` state.
|
|
540
|
-
*
|
|
541
|
-
* As the VNode get materialized the vnode now becomes eligible for mutation. Once the vnode mutates
|
|
542
|
-
* the `VNode` references from the `qwik/json` may become invalid. For this reason, these references
|
|
543
|
-
* need to be eagerly resolved. `VNODE_REF` stores a pointer to "this" vnode. This allows the system
|
|
544
|
-
* to eagerly resolve these pointes as the vnodes are materialized.
|
|
545
|
-
*/
|
|
546
|
-
const ELEMENT_ID = 'q:id';
|
|
547
|
-
const ELEMENT_KEY = 'q:key';
|
|
548
|
-
const ELEMENT_PROPS = 'q:props';
|
|
549
|
-
const ELEMENT_SEQ = 'q:seq';
|
|
550
|
-
const ELEMENT_SEQ_IDX = 'q:seqIdx';
|
|
551
|
-
const Q_PREFIX = 'q:';
|
|
552
|
-
/** Non serializable markers - always begins with `:` character */
|
|
553
|
-
const NON_SERIALIZABLE_MARKER_PREFIX = ':';
|
|
554
|
-
const USE_ON_LOCAL = NON_SERIALIZABLE_MARKER_PREFIX + 'on';
|
|
555
|
-
const USE_ON_LOCAL_SEQ_IDX = NON_SERIALIZABLE_MARKER_PREFIX + 'onIdx';
|
|
556
|
-
const USE_ON_LOCAL_FLAGS = NON_SERIALIZABLE_MARKER_PREFIX + 'onFlags';
|
|
557
|
-
// comment nodes
|
|
558
|
-
const FLUSH_COMMENT = 'qkssr-f';
|
|
559
|
-
const STREAM_BLOCK_START_COMMENT = 'qkssr-pu';
|
|
560
|
-
const STREAM_BLOCK_END_COMMENT = 'qkssr-po';
|
|
561
|
-
const Q_PROPS_SEPARATOR = ':';
|
|
562
|
-
const dangerouslySetInnerHTML = 'dangerouslySetInnerHTML';
|
|
563
|
-
const qwikInspectorAttr = 'data-qwik-inspector';
|
|
564
|
-
|
|
565
572
|
let _locale = undefined;
|
|
566
573
|
/**
|
|
567
574
|
* Retrieve the current locale.
|
|
@@ -1371,6 +1378,21 @@ function clearArgEffect(arg, subscriber, seenSet) {
|
|
|
1371
1378
|
if (isStore(arg)) {
|
|
1372
1379
|
clearStoreEffects(getStoreHandler(arg), subscriber);
|
|
1373
1380
|
}
|
|
1381
|
+
else if (isPropsProxy(arg)) {
|
|
1382
|
+
// Separate check for props proxy, because props proxy getter could call signal getter.
|
|
1383
|
+
// To avoid that we need to get the constProps and varProps directly
|
|
1384
|
+
// from the props proxy object and loop over them.
|
|
1385
|
+
const constProps = arg[_CONST_PROPS];
|
|
1386
|
+
const varProps = arg[_VAR_PROPS];
|
|
1387
|
+
if (constProps) {
|
|
1388
|
+
for (const key in constProps) {
|
|
1389
|
+
clearArgEffect(constProps[key], subscriber, seenSet);
|
|
1390
|
+
}
|
|
1391
|
+
}
|
|
1392
|
+
for (const key in varProps) {
|
|
1393
|
+
clearArgEffect(varProps[key], subscriber, seenSet);
|
|
1394
|
+
}
|
|
1395
|
+
}
|
|
1374
1396
|
else {
|
|
1375
1397
|
for (const key in arg) {
|
|
1376
1398
|
clearArgEffect(arg[key], subscriber, seenSet);
|
|
@@ -3580,6 +3602,108 @@ const createComputedQrl = createComputedSignal;
|
|
|
3580
3602
|
*/
|
|
3581
3603
|
const createComputed$ = /*#__PURE__*/ implicit$FirstArg(createComputedQrl);
|
|
3582
3604
|
|
|
3605
|
+
/// These global variables are used to avoid creating new arrays for each call to `vnode_documentPosition`.
|
|
3606
|
+
const aVNodePath = [];
|
|
3607
|
+
const bVNodePath = [];
|
|
3608
|
+
/**
|
|
3609
|
+
* Compare two VNodes and determine their document position relative to each other.
|
|
3610
|
+
*
|
|
3611
|
+
* @param a VNode to compare
|
|
3612
|
+
* @param b VNode to compare
|
|
3613
|
+
* @param rootVNode - Root VNode of a container
|
|
3614
|
+
* @returns -1 if `a` is before `b`, 0 if `a` is the same as `b`, 1 if `a` is after `b`.
|
|
3615
|
+
*/
|
|
3616
|
+
const vnode_documentPosition = (a, b, rootVNode) => {
|
|
3617
|
+
if (a === b) {
|
|
3618
|
+
return 0;
|
|
3619
|
+
}
|
|
3620
|
+
let aDepth = -1;
|
|
3621
|
+
let bDepth = -1;
|
|
3622
|
+
while (a) {
|
|
3623
|
+
const vNode = (aVNodePath[++aDepth] = a);
|
|
3624
|
+
a = (vNode[VNodeProps.parent] ||
|
|
3625
|
+
(rootVNode && vnode_getProp(a, QSlotParent, (id) => vnode_locate(rootVNode, id))));
|
|
3626
|
+
}
|
|
3627
|
+
while (b) {
|
|
3628
|
+
const vNode = (bVNodePath[++bDepth] = b);
|
|
3629
|
+
b = (vNode[VNodeProps.parent] ||
|
|
3630
|
+
(rootVNode && vnode_getProp(b, QSlotParent, (id) => vnode_locate(rootVNode, id))));
|
|
3631
|
+
}
|
|
3632
|
+
while (aDepth >= 0 && bDepth >= 0) {
|
|
3633
|
+
a = aVNodePath[aDepth];
|
|
3634
|
+
b = bVNodePath[bDepth];
|
|
3635
|
+
if (a === b) {
|
|
3636
|
+
// if the nodes are the same, we need to check the next level.
|
|
3637
|
+
aDepth--;
|
|
3638
|
+
bDepth--;
|
|
3639
|
+
}
|
|
3640
|
+
else {
|
|
3641
|
+
// We found a difference so we need to scan nodes at this level.
|
|
3642
|
+
let cursor = b;
|
|
3643
|
+
do {
|
|
3644
|
+
cursor = vnode_getNextSibling(cursor);
|
|
3645
|
+
if (cursor === a) {
|
|
3646
|
+
return 1;
|
|
3647
|
+
}
|
|
3648
|
+
} while (cursor);
|
|
3649
|
+
cursor = b;
|
|
3650
|
+
do {
|
|
3651
|
+
cursor = vnode_getPreviousSibling(cursor);
|
|
3652
|
+
if (cursor === a) {
|
|
3653
|
+
return -1;
|
|
3654
|
+
}
|
|
3655
|
+
} while (cursor);
|
|
3656
|
+
if (rootVNode && vnode_getProp(b, QSlotParent, (id) => vnode_locate(rootVNode, id))) {
|
|
3657
|
+
// The "b" node is a projection, so we need to set it after "a" node,
|
|
3658
|
+
// because the "a" node could be a context provider.
|
|
3659
|
+
return -1;
|
|
3660
|
+
}
|
|
3661
|
+
// The node is not in the list of siblings, that means it must be disconnected.
|
|
3662
|
+
return 1;
|
|
3663
|
+
}
|
|
3664
|
+
}
|
|
3665
|
+
return aDepth < bDepth ? -1 : 1;
|
|
3666
|
+
};
|
|
3667
|
+
/// These global variables are used to avoid creating new arrays for each call to `ssrNodeDocumentPosition`.
|
|
3668
|
+
const aSsrNodePath = [];
|
|
3669
|
+
const bSsrNodePath = [];
|
|
3670
|
+
/**
|
|
3671
|
+
* Compare two SSR nodes and determine their document position relative to each other. Compares only
|
|
3672
|
+
* position between parent and child.
|
|
3673
|
+
*
|
|
3674
|
+
* @param a SSR node to compare
|
|
3675
|
+
* @param b SSR node to compare
|
|
3676
|
+
* @returns -1 if `a` is before `b`, 0 if `a` is the same as `b`, 1 if `a` is after `b`.
|
|
3677
|
+
*/
|
|
3678
|
+
const ssrNodeDocumentPosition = (a, b) => {
|
|
3679
|
+
if (a === b) {
|
|
3680
|
+
return 0;
|
|
3681
|
+
}
|
|
3682
|
+
let aDepth = -1;
|
|
3683
|
+
let bDepth = -1;
|
|
3684
|
+
while (a) {
|
|
3685
|
+
const ssrNode = (aSsrNodePath[++aDepth] = a);
|
|
3686
|
+
a = ssrNode.currentComponentNode;
|
|
3687
|
+
}
|
|
3688
|
+
while (b) {
|
|
3689
|
+
const ssrNode = (bSsrNodePath[++bDepth] = b);
|
|
3690
|
+
b = ssrNode.currentComponentNode;
|
|
3691
|
+
}
|
|
3692
|
+
while (aDepth >= 0 && bDepth >= 0) {
|
|
3693
|
+
a = aSsrNodePath[aDepth];
|
|
3694
|
+
b = bSsrNodePath[bDepth];
|
|
3695
|
+
if (a === b) {
|
|
3696
|
+
// if the nodes are the same, we need to check the next level.
|
|
3697
|
+
aDepth--;
|
|
3698
|
+
bDepth--;
|
|
3699
|
+
}
|
|
3700
|
+
else {
|
|
3701
|
+
return 1;
|
|
3702
|
+
}
|
|
3703
|
+
}
|
|
3704
|
+
return aDepth < bDepth ? -1 : 1;
|
|
3705
|
+
};
|
|
3706
|
+
|
|
3583
3707
|
/**
|
|
3584
3708
|
* Scheduler is responsible for running application code in predictable order.
|
|
3585
3709
|
*
|
|
@@ -3742,7 +3866,7 @@ const createScheduler = (container, scheduleDrain, journalFlush) => {
|
|
|
3742
3866
|
}
|
|
3743
3867
|
while (choreQueue.length) {
|
|
3744
3868
|
const nextChore = choreQueue.shift();
|
|
3745
|
-
const order = choreComparator(nextChore, runUptoChore, rootVNode
|
|
3869
|
+
const order = choreComparator(nextChore, runUptoChore, rootVNode);
|
|
3746
3870
|
if (order === null) {
|
|
3747
3871
|
continue;
|
|
3748
3872
|
}
|
|
@@ -3779,7 +3903,7 @@ const createScheduler = (container, scheduleDrain, journalFlush) => {
|
|
|
3779
3903
|
returnValue = safeCall(() => executeComponent(container, host, host, chore.$target$, chore.$payload$), (jsx) => {
|
|
3780
3904
|
if (chore.$type$ === ChoreType.COMPONENT) {
|
|
3781
3905
|
const styleScopedId = container.getHostProp(host, QScopedStyle);
|
|
3782
|
-
return vnode_diff(container, jsx, host, addComponentStylePrefix(styleScopedId));
|
|
3906
|
+
return retryOnPromise(() => vnode_diff(container, jsx, host, addComponentStylePrefix(styleScopedId)));
|
|
3783
3907
|
}
|
|
3784
3908
|
else {
|
|
3785
3909
|
return jsx;
|
|
@@ -3810,7 +3934,7 @@ const createScheduler = (container, scheduleDrain, journalFlush) => {
|
|
|
3810
3934
|
if (isSignal(jsx)) {
|
|
3811
3935
|
jsx = jsx.value;
|
|
3812
3936
|
}
|
|
3813
|
-
returnValue = vnode_diff(container, jsx, parentVirtualNode, null);
|
|
3937
|
+
returnValue = retryOnPromise(() => vnode_diff(container, jsx, parentVirtualNode, null));
|
|
3814
3938
|
break;
|
|
3815
3939
|
case ChoreType.NODE_PROP:
|
|
3816
3940
|
const virtualNode = chore.$host$;
|
|
@@ -3879,7 +4003,15 @@ function vNodeAlreadyDeleted(chore) {
|
|
|
3879
4003
|
vnode_isVNode(chore.$host$) &&
|
|
3880
4004
|
chore.$host$[VNodeProps.flags] & VNodeFlags.Deleted);
|
|
3881
4005
|
}
|
|
3882
|
-
|
|
4006
|
+
/**
|
|
4007
|
+
* Compares two chores to determine their execution order in the scheduler's queue.
|
|
4008
|
+
*
|
|
4009
|
+
* @param a - The first chore to compare
|
|
4010
|
+
* @param b - The second chore to compare
|
|
4011
|
+
* @returns A number indicating the relative order of the chores. A negative number means `a` runs
|
|
4012
|
+
* before `b`.
|
|
4013
|
+
*/
|
|
4014
|
+
function choreComparator(a, b, rootVNode) {
|
|
3883
4015
|
const macroTypeDiff = (a.$type$ & ChoreType.MACRO) - (b.$type$ & ChoreType.MACRO);
|
|
3884
4016
|
if (macroTypeDiff !== 0) {
|
|
3885
4017
|
return macroTypeDiff;
|
|
@@ -3906,11 +4038,11 @@ function choreComparator(a, b, rootVNode, shouldThrowOnHostMismatch) {
|
|
|
3906
4038
|
You are attempting to change a state that has already been streamed to the client.
|
|
3907
4039
|
This can lead to inconsistencies between Server-Side Rendering (SSR) and Client-Side Rendering (CSR).
|
|
3908
4040
|
Problematic Node: ${aHost.toString()}`;
|
|
3909
|
-
if (shouldThrowOnHostMismatch) {
|
|
3910
|
-
throw qError(QError.serverHostMismatch, [errorMessage]);
|
|
3911
|
-
}
|
|
3912
4041
|
logWarn(errorMessage);
|
|
3913
|
-
|
|
4042
|
+
const hostDiff = ssrNodeDocumentPosition(aHost, bHost);
|
|
4043
|
+
if (hostDiff !== 0) {
|
|
4044
|
+
return hostDiff;
|
|
4045
|
+
}
|
|
3914
4046
|
}
|
|
3915
4047
|
}
|
|
3916
4048
|
const microTypeDiff = (a.$type$ & ChoreType.MICRO) - (b.$type$ & ChoreType.MICRO);
|
|
@@ -3941,7 +4073,7 @@ function sortedFindIndex(sortedArray, value, rootVNode) {
|
|
|
3941
4073
|
while (bottom < top) {
|
|
3942
4074
|
const middle = bottom + ((top - bottom) >> 1);
|
|
3943
4075
|
const midChore = sortedArray[middle];
|
|
3944
|
-
const comp = choreComparator(value, midChore, rootVNode
|
|
4076
|
+
const comp = choreComparator(value, midChore, rootVNode);
|
|
3945
4077
|
if (comp < 0) {
|
|
3946
4078
|
top = middle;
|
|
3947
4079
|
}
|
|
@@ -4963,7 +5095,7 @@ function appendClassIfScopedStyleExists(jsx, styleScoped) {
|
|
|
4963
5095
|
*
|
|
4964
5096
|
* @public
|
|
4965
5097
|
*/
|
|
4966
|
-
const version = "2.0.0-alpha.
|
|
5098
|
+
const version = "2.0.0-alpha.6-dev+d848ba5";
|
|
4967
5099
|
|
|
4968
5100
|
/** @internal */
|
|
4969
5101
|
class _SharedContainer {
|
|
@@ -7071,60 +7203,6 @@ const vnode_getType = (vnode) => {
|
|
|
7071
7203
|
throw qError(QError.invalidVNodeType, [type]);
|
|
7072
7204
|
};
|
|
7073
7205
|
const isElement = (node) => node && typeof node == 'object' && fastNodeType(node) === /** Node.ELEMENT_NODE* */ 1;
|
|
7074
|
-
/// These global variables are used to avoid creating new arrays for each call to `vnode_documentPosition`.
|
|
7075
|
-
const aPath = [];
|
|
7076
|
-
const bPath = [];
|
|
7077
|
-
const vnode_documentPosition = (a, b, rootVNode) => {
|
|
7078
|
-
if (a === b) {
|
|
7079
|
-
return 0;
|
|
7080
|
-
}
|
|
7081
|
-
let aDepth = -1;
|
|
7082
|
-
let bDepth = -1;
|
|
7083
|
-
while (a) {
|
|
7084
|
-
const vNode = (aPath[++aDepth] = a);
|
|
7085
|
-
a = (vNode[VNodeProps.parent] ||
|
|
7086
|
-
(rootVNode && vnode_getProp(a, QSlotParent, (id) => vnode_locate(rootVNode, id))));
|
|
7087
|
-
}
|
|
7088
|
-
while (b) {
|
|
7089
|
-
const vNode = (bPath[++bDepth] = b);
|
|
7090
|
-
b = (vNode[VNodeProps.parent] ||
|
|
7091
|
-
(rootVNode && vnode_getProp(b, QSlotParent, (id) => vnode_locate(rootVNode, id))));
|
|
7092
|
-
}
|
|
7093
|
-
while (aDepth >= 0 && bDepth >= 0) {
|
|
7094
|
-
a = aPath[aDepth];
|
|
7095
|
-
b = bPath[bDepth];
|
|
7096
|
-
if (a === b) {
|
|
7097
|
-
// if the nodes are the same, we need to check the next level.
|
|
7098
|
-
aDepth--;
|
|
7099
|
-
bDepth--;
|
|
7100
|
-
}
|
|
7101
|
-
else {
|
|
7102
|
-
// We found a difference so we need to scan nodes at this level.
|
|
7103
|
-
let cursor = b;
|
|
7104
|
-
do {
|
|
7105
|
-
cursor = vnode_getNextSibling(cursor);
|
|
7106
|
-
if (cursor === a) {
|
|
7107
|
-
return 1;
|
|
7108
|
-
}
|
|
7109
|
-
} while (cursor);
|
|
7110
|
-
cursor = b;
|
|
7111
|
-
do {
|
|
7112
|
-
cursor = vnode_getPreviousSibling(cursor);
|
|
7113
|
-
if (cursor === a) {
|
|
7114
|
-
return -1;
|
|
7115
|
-
}
|
|
7116
|
-
} while (cursor);
|
|
7117
|
-
if (rootVNode && vnode_getProp(b, QSlotParent, (id) => vnode_locate(rootVNode, id))) {
|
|
7118
|
-
// The "b" node is a projection, so we need to set it after "a" node,
|
|
7119
|
-
// because the "a" node could be a context provider.
|
|
7120
|
-
return -1;
|
|
7121
|
-
}
|
|
7122
|
-
// The node is not in the list of siblings, that means it must be disconnected.
|
|
7123
|
-
return 1;
|
|
7124
|
-
}
|
|
7125
|
-
}
|
|
7126
|
-
return aDepth < bDepth ? -1 : 1;
|
|
7127
|
-
};
|
|
7128
7206
|
/**
|
|
7129
7207
|
* Use this method to find the parent component for projection.
|
|
7130
7208
|
*
|