@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.
- 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.wasm.cjs +259 -272
- package/bindings/qwik.wasm.mjs +259 -272
- 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 +1384 -761
- package/dist/core-internal.d.ts +14 -4
- package/dist/core.cjs +121 -106
- package/dist/core.cjs.map +1 -1
- package/dist/core.min.mjs +1 -1
- package/dist/core.mjs +121 -106
- package/dist/core.mjs.map +1 -1
- package/dist/core.prod.cjs +80 -63
- package/dist/core.prod.mjs +82 -65
- package/dist/insights/index.qwik.cjs +1 -1
- package/dist/insights/index.qwik.mjs +1 -1
- package/dist/loader/index.cjs +2 -2
- package/dist/loader/index.mjs +2 -2
- package/dist/loader/package.json +1 -1
- package/dist/optimizer.cjs +94 -80
- package/dist/optimizer.mjs +96 -82
- package/dist/prefetch/package.json +1 -1
- package/dist/qwikloader.debug.js +1 -0
- package/dist/qwikloader.js +2 -2
- package/dist/server.cjs +125 -96
- package/dist/server.mjs +125 -96
- package/dist/starters/features/auth/package.json +3 -1
- package/dist/starters/features/drizzle/package.json +2 -1
- package/dist/starters/features/postcss/package.json +3 -0
- package/dist/starters/features/prisma/package.json +2 -1
- package/dist/starters/features/tailwind/package.json +3 -0
- package/dist/starters/features/turso/package.json +4 -1
- package/dist/testing/index.cjs +121 -92
- package/dist/testing/index.mjs +121 -92
- package/dist/testing/package.json +1 -1
- package/package.json +6 -4
package/dist/core-internal.d.ts
CHANGED
|
@@ -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;
|
|
@@ -552,6 +551,10 @@ declare interface Container {
|
|
|
552
551
|
nodeType: number;
|
|
553
552
|
id: string;
|
|
554
553
|
};
|
|
554
|
+
} | null, DomRefConstructor: {
|
|
555
|
+
new (...rest: any[]): {
|
|
556
|
+
$ssrNode$: ISsrNode;
|
|
557
|
+
};
|
|
555
558
|
} | null, symbolToChunkResolver: SymbolToChunkResolver, writer?: StreamWriter): SerializationContext;
|
|
556
559
|
}
|
|
557
560
|
|
|
@@ -868,7 +871,6 @@ declare class DomContainer extends _SharedContainer implements ClientContainer {
|
|
|
868
871
|
constructor(element: _ContainerElement);
|
|
869
872
|
$setRawState$(id: number, vParent: _ElementVNode | _VirtualVNode): void;
|
|
870
873
|
parseQRL<T = unknown>(qrl: string): QRL<T>;
|
|
871
|
-
processJsx(host: HostElement, jsx: JSXOutput): ValueOrPromise<void>;
|
|
872
874
|
handleError(err: any, host: HostElement): void;
|
|
873
875
|
setContext<T>(host: HostElement, context: ContextId<T>, value: T): void;
|
|
874
876
|
resolveContext<T>(host: HostElement, contextId: ContextId<T>): T | undefined;
|
|
@@ -885,6 +887,10 @@ declare class DomContainer extends _SharedContainer implements ClientContainer {
|
|
|
885
887
|
export { DomContainer }
|
|
886
888
|
export { DomContainer as _DomContainer }
|
|
887
889
|
|
|
890
|
+
declare type DomRef = {
|
|
891
|
+
$ssrNode$: SsrNode;
|
|
892
|
+
};
|
|
893
|
+
|
|
888
894
|
/** @public */
|
|
889
895
|
export declare type EagernessOptions = 'visible' | 'load' | 'idle';
|
|
890
896
|
|
|
@@ -2278,6 +2284,7 @@ declare interface SerializationContext {
|
|
|
2278
2284
|
$addSyncFn$($funcStr$: string | null, argsCount: number, fn: Function): number;
|
|
2279
2285
|
$breakCircularDepsAndAwaitPromises$: () => ValueOrPromise<void>;
|
|
2280
2286
|
$isSsrNode$: (obj: unknown) => obj is SsrNode;
|
|
2287
|
+
$isDomRef$: (obj: unknown) => obj is DomRef;
|
|
2281
2288
|
$writer$: StreamWriter_2;
|
|
2282
2289
|
$syncFns$: string[];
|
|
2283
2290
|
$eventQrls$: Set<QRL>;
|
|
@@ -2327,9 +2334,12 @@ export declare abstract class _SharedContainer implements Container {
|
|
|
2327
2334
|
nodeType: number;
|
|
2328
2335
|
id: string;
|
|
2329
2336
|
};
|
|
2337
|
+
} | null, DomRefConstructor: {
|
|
2338
|
+
new (...rest: any[]): {
|
|
2339
|
+
$ssrNode$: ISsrNode;
|
|
2340
|
+
};
|
|
2330
2341
|
} | null, symbolToChunkResolver: SymbolToChunkResolver, writer?: StreamWriter, prepVNodeData?: (vNode: any) => void): SerializationContext;
|
|
2331
2342
|
abstract ensureProjectionResolved(host: HostElement): void;
|
|
2332
|
-
abstract processJsx(host: HostElement, jsx: JSXOutput): ValueOrPromise<void>;
|
|
2333
2343
|
abstract handleError(err: any, $host$: HostElement): void;
|
|
2334
2344
|
abstract getParentHost(host: HostElement): HostElement | null;
|
|
2335
2345
|
abstract setContext<T>(host: HostElement, context: ContextId<T>, value: T): void;
|
|
@@ -3708,7 +3718,7 @@ export declare const _VAR_PROPS: unique symbol;
|
|
|
3708
3718
|
export declare const _verifySerializable: <T>(value: T, preMessage?: string) => T;
|
|
3709
3719
|
|
|
3710
3720
|
/**
|
|
3711
|
-
* 2.0.0-alpha.
|
|
3721
|
+
* 2.0.0-alpha.3-dev+418fd6d
|
|
3712
3722
|
*
|
|
3713
3723
|
* @public
|
|
3714
3724
|
*/
|
package/dist/core.cjs
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.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
|
|
@@ -1267,6 +1267,12 @@
|
|
|
1267
1267
|
return subscriptionRemoved;
|
|
1268
1268
|
}
|
|
1269
1269
|
|
|
1270
|
+
/**
|
|
1271
|
+
* Special value used to mark that a given signal needs to be computed. This is essentially a
|
|
1272
|
+
* "marked as dirty" flag.
|
|
1273
|
+
*/
|
|
1274
|
+
const NEEDS_COMPUTATION = Symbol('invalid');
|
|
1275
|
+
|
|
1270
1276
|
/**
|
|
1271
1277
|
* @file
|
|
1272
1278
|
*
|
|
@@ -1281,11 +1287,6 @@
|
|
|
1281
1287
|
* - It is `Readonly` because it is computed.
|
|
1282
1288
|
*/
|
|
1283
1289
|
const DEBUG = false;
|
|
1284
|
-
/**
|
|
1285
|
-
* Special value used to mark that a given signal needs to be computed. This is essentially a
|
|
1286
|
-
* "marked as dirty" flag.
|
|
1287
|
-
*/
|
|
1288
|
-
const NEEDS_COMPUTATION = Symbol('invalid');
|
|
1289
1290
|
// eslint-disable-next-line no-console
|
|
1290
1291
|
const log = (...args) => console.log('SIGNAL', ...args.map(qwikDebugToString));
|
|
1291
1292
|
const throwIfQRLNotResolved = (qrl) => {
|
|
@@ -2179,6 +2180,15 @@
|
|
|
2179
2180
|
if (prop === STORE_TARGET) {
|
|
2180
2181
|
return true;
|
|
2181
2182
|
}
|
|
2183
|
+
if (typeof prop === 'string') {
|
|
2184
|
+
const ctx = tryGetInvokeContext();
|
|
2185
|
+
if (ctx) {
|
|
2186
|
+
const effectSubscriber = ctx.$effectSubscriber$;
|
|
2187
|
+
if (effectSubscriber) {
|
|
2188
|
+
addEffect(target, Array.isArray(target) ? STORE_ARRAY_PROP : prop, this, effectSubscriber);
|
|
2189
|
+
}
|
|
2190
|
+
}
|
|
2191
|
+
}
|
|
2182
2192
|
return Object.prototype.hasOwnProperty.call(target, prop);
|
|
2183
2193
|
}
|
|
2184
2194
|
ownKeys(target) {
|
|
@@ -3285,48 +3295,48 @@
|
|
|
3285
3295
|
/////////////////////////////////////////////////////////////////////////////
|
|
3286
3296
|
/////////////////////////////////////////////////////////////////////////////
|
|
3287
3297
|
function descendContentToProject(children, host) {
|
|
3288
|
-
|
|
3289
|
-
|
|
3290
|
-
|
|
3291
|
-
|
|
3292
|
-
|
|
3293
|
-
|
|
3294
|
-
|
|
3295
|
-
|
|
3296
|
-
|
|
3297
|
-
|
|
3298
|
-
|
|
3299
|
-
|
|
3300
|
-
|
|
3301
|
-
const slotName = prop;
|
|
3302
|
-
projections.push(slotName);
|
|
3303
|
-
projections.push(createProjectionJSXNode(slotName));
|
|
3304
|
-
}
|
|
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));
|
|
3305
3311
|
}
|
|
3306
3312
|
}
|
|
3307
|
-
|
|
3308
|
-
|
|
3309
|
-
|
|
3310
|
-
|
|
3311
|
-
|
|
3312
|
-
|
|
3313
|
-
|
|
3314
|
-
|
|
3315
|
-
|
|
3316
|
-
|
|
3317
|
-
|
|
3318
|
-
|
|
3319
|
-
|
|
3320
|
-
if (!removeProjection) {
|
|
3321
|
-
jsxBucket.children.push(child);
|
|
3322
|
-
}
|
|
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];
|
|
3323
3326
|
}
|
|
3324
|
-
|
|
3325
|
-
|
|
3326
|
-
projections.splice(i, 1);
|
|
3327
|
+
else {
|
|
3328
|
+
projections.splice(~idx, 0, slotName, (jsxBucket = createProjectionJSXNode(slotName)));
|
|
3327
3329
|
}
|
|
3328
|
-
|
|
3330
|
+
const removeProjection = child === false;
|
|
3331
|
+
if (!removeProjection) {
|
|
3332
|
+
jsxBucket.children.push(child);
|
|
3333
|
+
}
|
|
3334
|
+
}
|
|
3335
|
+
/// STEP 2: remove the names
|
|
3336
|
+
for (let i = projections.length - 2; i >= 0; i = i - 2) {
|
|
3337
|
+
projections.splice(i, 1);
|
|
3329
3338
|
}
|
|
3339
|
+
descend(projections, true);
|
|
3330
3340
|
}
|
|
3331
3341
|
function expectProjection() {
|
|
3332
3342
|
const jsxNode = jsxValue;
|
|
@@ -3848,7 +3858,7 @@
|
|
|
3848
3858
|
container.$scheduler$(ChoreType.COMPONENT, host, componentQRL, jsxProps);
|
|
3849
3859
|
}
|
|
3850
3860
|
}
|
|
3851
|
-
|
|
3861
|
+
descendContentToProject(jsxNode.children, host);
|
|
3852
3862
|
}
|
|
3853
3863
|
else {
|
|
3854
3864
|
const lookupKey = jsxNode.key;
|
|
@@ -4349,9 +4359,13 @@
|
|
|
4349
4359
|
case ChoreType.COMPONENT:
|
|
4350
4360
|
case ChoreType.COMPONENT_SSR:
|
|
4351
4361
|
returnValue = safeCall(() => executeComponent(container, host, host, chore.$target$, chore.$payload$), (jsx) => {
|
|
4352
|
-
|
|
4353
|
-
|
|
4354
|
-
|
|
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
|
+
}
|
|
4355
4369
|
}, (err) => container.handleError(err, host));
|
|
4356
4370
|
break;
|
|
4357
4371
|
case ChoreType.RESOURCE:
|
|
@@ -4456,7 +4470,10 @@
|
|
|
4456
4470
|
// On server we can't schedule task for a different host!
|
|
4457
4471
|
// Server is SSR, and therefore scheduling for anything but the current host
|
|
4458
4472
|
// implies that things need to be re-run nad that is not supported because of streaming.
|
|
4459
|
-
const errorMessage =
|
|
4473
|
+
const errorMessage = `SERVER: during HTML streaming, re-running tasks on a different host is not allowed.
|
|
4474
|
+
You are attempting to change a state that has already been streamed to the client.
|
|
4475
|
+
This can lead to inconsistencies between Server-Side Rendering (SSR) and Client-Side Rendering (CSR).
|
|
4476
|
+
Problematic Node: ${aHost.toString()}`;
|
|
4460
4477
|
if (shouldThrowOnHostMismatch) {
|
|
4461
4478
|
throwErrorAndStop(errorMessage);
|
|
4462
4479
|
}
|
|
@@ -4523,7 +4540,7 @@
|
|
|
4523
4540
|
*
|
|
4524
4541
|
* @public
|
|
4525
4542
|
*/
|
|
4526
|
-
const version = "2.0.0-alpha.
|
|
4543
|
+
const version = "2.0.0-alpha.3-dev+418fd6d";
|
|
4527
4544
|
|
|
4528
4545
|
/** @internal */
|
|
4529
4546
|
class _SharedContainer {
|
|
@@ -4550,8 +4567,8 @@
|
|
|
4550
4567
|
trackSignalValue(signal, subscriber, property, data) {
|
|
4551
4568
|
return trackSignal(() => signal.value, subscriber, property, this, data);
|
|
4552
4569
|
}
|
|
4553
|
-
serializationCtxFactory(NodeConstructor, symbolToChunkResolver, writer, prepVNodeData) {
|
|
4554
|
-
return createSerializationContext(NodeConstructor, symbolToChunkResolver, this.getHostProp.bind(this), this.setHostProp.bind(this), this.$storeProxyMap$, writer, prepVNodeData);
|
|
4570
|
+
serializationCtxFactory(NodeConstructor, DomRefConstructor, symbolToChunkResolver, writer, prepVNodeData) {
|
|
4571
|
+
return createSerializationContext(NodeConstructor, DomRefConstructor, symbolToChunkResolver, this.getHostProp.bind(this), this.setHostProp.bind(this), this.$storeProxyMap$, writer, prepVNodeData);
|
|
4555
4572
|
}
|
|
4556
4573
|
}
|
|
4557
4574
|
|
|
@@ -5073,11 +5090,6 @@
|
|
|
5073
5090
|
parseQRL(qrl) {
|
|
5074
5091
|
return inflateQRL(this, parseQRL(qrl));
|
|
5075
5092
|
}
|
|
5076
|
-
processJsx(host, jsx) {
|
|
5077
|
-
// console.log('>>>> processJsx', String(host));
|
|
5078
|
-
const styleScopedId = this.getHostProp(host, QScopedStyle);
|
|
5079
|
-
return vnode_diff(this, jsx, host, addComponentStylePrefix(styleScopedId));
|
|
5080
|
-
}
|
|
5081
5093
|
handleError(err, host) {
|
|
5082
5094
|
if (qDev) {
|
|
5083
5095
|
// Clean vdom
|
|
@@ -8039,7 +8051,10 @@
|
|
|
8039
8051
|
if (valType === TypeIds.RootRef || valType >= TypeIds.Error) {
|
|
8040
8052
|
Object.defineProperty(target, key, {
|
|
8041
8053
|
get() {
|
|
8042
|
-
|
|
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;
|
|
8043
8058
|
},
|
|
8044
8059
|
set(value) {
|
|
8045
8060
|
Object.defineProperty(target, key, {
|
|
@@ -8381,13 +8396,7 @@
|
|
|
8381
8396
|
}
|
|
8382
8397
|
return qrl;
|
|
8383
8398
|
}
|
|
8384
|
-
|
|
8385
|
-
class DomVRef {
|
|
8386
|
-
id;
|
|
8387
|
-
constructor(id) {
|
|
8388
|
-
this.id = id;
|
|
8389
|
-
}
|
|
8390
|
-
}
|
|
8399
|
+
let isDomRef = (obj) => false;
|
|
8391
8400
|
const createSerializationContext = (
|
|
8392
8401
|
/**
|
|
8393
8402
|
* Node constructor, for instanceof checks.
|
|
@@ -8395,7 +8404,9 @@
|
|
|
8395
8404
|
* A node constructor can be null. For example on the client we can't serialize DOM nodes as
|
|
8396
8405
|
* server will not know what to do with them.
|
|
8397
8406
|
*/
|
|
8398
|
-
NodeConstructor,
|
|
8407
|
+
NodeConstructor,
|
|
8408
|
+
/** DomRef constructor, for instanceof checks. */
|
|
8409
|
+
DomRefConstructor, symbolToChunkResolver, getProp, setProp, storeProxyMap, writer,
|
|
8399
8410
|
// temporary until we serdes the vnode data here
|
|
8400
8411
|
prepVNodeData) => {
|
|
8401
8412
|
if (!writer) {
|
|
@@ -8421,11 +8432,13 @@
|
|
|
8421
8432
|
return id;
|
|
8422
8433
|
};
|
|
8423
8434
|
const isSsrNode = (NodeConstructor ? (obj) => obj instanceof NodeConstructor : () => false);
|
|
8435
|
+
isDomRef = (DomRefConstructor ? (obj) => obj instanceof DomRefConstructor : () => false);
|
|
8424
8436
|
return {
|
|
8425
8437
|
$serialize$() {
|
|
8426
8438
|
serialize(this);
|
|
8427
8439
|
},
|
|
8428
8440
|
$isSsrNode$: isSsrNode,
|
|
8441
|
+
$isDomRef$: isDomRef,
|
|
8429
8442
|
$symbolToChunkResolver$: symbolToChunkResolver,
|
|
8430
8443
|
$wasSeen$,
|
|
8431
8444
|
$roots$: roots,
|
|
@@ -8571,6 +8584,9 @@
|
|
|
8571
8584
|
else if (isSsrNode(obj)) {
|
|
8572
8585
|
discoveredValues.push(obj.vnodeData);
|
|
8573
8586
|
}
|
|
8587
|
+
else if (isDomRef(obj)) {
|
|
8588
|
+
discoveredValues.push(obj.$ssrNode$.id);
|
|
8589
|
+
}
|
|
8574
8590
|
else if (isJSXNode(obj)) {
|
|
8575
8591
|
discoveredValues.push(obj.type, obj.props, obj.constProps, obj.children);
|
|
8576
8592
|
}
|
|
@@ -8644,7 +8660,7 @@
|
|
|
8644
8660
|
* - Therefore root indexes need to be doubled to get the actual index.
|
|
8645
8661
|
*/
|
|
8646
8662
|
function serialize(serializationContext) {
|
|
8647
|
-
const { $writer$, $isSsrNode$, $setProp$, $storeProxyMap$ } = serializationContext;
|
|
8663
|
+
const { $writer$, $isSsrNode$, $isDomRef$, $setProp$, $storeProxyMap$ } = serializationContext;
|
|
8648
8664
|
let depth = -1;
|
|
8649
8665
|
// Skip the type for the roots output
|
|
8650
8666
|
let writeType = false;
|
|
@@ -8866,23 +8882,19 @@
|
|
|
8866
8882
|
output(TypeIds.Object, out);
|
|
8867
8883
|
}
|
|
8868
8884
|
}
|
|
8869
|
-
else if (value
|
|
8870
|
-
|
|
8885
|
+
else if ($isDomRef$(value)) {
|
|
8886
|
+
value.$ssrNode$.vnodeData[0] |= VNodeDataFlag.SERIALIZE;
|
|
8887
|
+
output(TypeIds.RefVNode, value.$ssrNode$.id);
|
|
8871
8888
|
}
|
|
8872
8889
|
else if (value instanceof Signal) {
|
|
8873
8890
|
/**
|
|
8874
8891
|
* Special case: when a Signal value is an SSRNode, it always needs to be a DOM ref instead.
|
|
8875
8892
|
* It can never be meant to become a vNode, because vNodes are internal only.
|
|
8876
8893
|
*/
|
|
8877
|
-
|
|
8894
|
+
const v = value instanceof ComputedSignal &&
|
|
8878
8895
|
(value.$invalid$ || fastSkipSerialize(value.$untrackedValue$))
|
|
8879
8896
|
? NEEDS_COMPUTATION
|
|
8880
8897
|
: value.$untrackedValue$;
|
|
8881
|
-
if ($isSsrNode$(v)) {
|
|
8882
|
-
// TODO maybe we don't need to store all vnode data if it's only a ref
|
|
8883
|
-
serializationContext.$addRoot$(v);
|
|
8884
|
-
v = new DomVRef(v.id);
|
|
8885
|
-
}
|
|
8886
8898
|
if (value instanceof WrappedSignal) {
|
|
8887
8899
|
output(TypeIds.WrappedSignal, [
|
|
8888
8900
|
...serializeWrappingFn(serializationContext, value),
|
|
@@ -9099,7 +9111,7 @@
|
|
|
9099
9111
|
* @internal
|
|
9100
9112
|
*/
|
|
9101
9113
|
async function _serialize(data) {
|
|
9102
|
-
const serializationContext = createSerializationContext(null, () => '', () => '', () => { }, new WeakMap());
|
|
9114
|
+
const serializationContext = createSerializationContext(null, null, () => '', () => '', () => { }, new WeakMap());
|
|
9103
9115
|
for (const root of data) {
|
|
9104
9116
|
serializationContext.$addRoot$(root);
|
|
9105
9117
|
}
|
|
@@ -9290,6 +9302,9 @@
|
|
|
9290
9302
|
else if (value instanceof Uint8Array) {
|
|
9291
9303
|
return true;
|
|
9292
9304
|
}
|
|
9305
|
+
else if (isDomRef?.(value)) {
|
|
9306
|
+
return true;
|
|
9307
|
+
}
|
|
9293
9308
|
}
|
|
9294
9309
|
else if (typeof value === 'function') {
|
|
9295
9310
|
if (isQrl(value) || isQwikComponent(value)) {
|
|
@@ -9494,8 +9509,8 @@
|
|
|
9494
9509
|
}
|
|
9495
9510
|
let _containerEl;
|
|
9496
9511
|
const qrl = async function (...args) {
|
|
9497
|
-
const
|
|
9498
|
-
const result = await
|
|
9512
|
+
const boundedFn = bindFnToContext.call(this, tryGetInvokeContext());
|
|
9513
|
+
const result = await boundedFn(...args);
|
|
9499
9514
|
return result;
|
|
9500
9515
|
};
|
|
9501
9516
|
const setContainer = (el) => {
|
|
@@ -9504,6 +9519,34 @@
|
|
|
9504
9519
|
}
|
|
9505
9520
|
return _containerEl;
|
|
9506
9521
|
};
|
|
9522
|
+
function bindFnToContext(currentCtx, beforeFn) {
|
|
9523
|
+
// Note that we bind the current `this`
|
|
9524
|
+
return (...args) => maybeThen(resolveLazy(), (fn) => {
|
|
9525
|
+
if (!isFunction(fn)) {
|
|
9526
|
+
throw qError(QError_qrlIsNotFunction);
|
|
9527
|
+
}
|
|
9528
|
+
if (beforeFn && beforeFn() === false) {
|
|
9529
|
+
return;
|
|
9530
|
+
}
|
|
9531
|
+
const context = createOrReuseInvocationContext(currentCtx);
|
|
9532
|
+
const prevQrl = context.$qrl$;
|
|
9533
|
+
const prevEvent = context.$event$;
|
|
9534
|
+
// Note that we set the qrl here instead of in wrapFn because
|
|
9535
|
+
// it is possible we're called on a copied qrl
|
|
9536
|
+
context.$qrl$ = qrl;
|
|
9537
|
+
context.$event$ ||= this;
|
|
9538
|
+
try {
|
|
9539
|
+
return invoke.call(this, context, fn, ...args);
|
|
9540
|
+
}
|
|
9541
|
+
finally {
|
|
9542
|
+
context.$qrl$ = prevQrl;
|
|
9543
|
+
context.$event$ = prevEvent;
|
|
9544
|
+
}
|
|
9545
|
+
});
|
|
9546
|
+
}
|
|
9547
|
+
const resolveLazy = (containerEl) => {
|
|
9548
|
+
return symbolRef !== null ? symbolRef : resolve(containerEl);
|
|
9549
|
+
};
|
|
9507
9550
|
// Wrap functions to provide their lexical scope
|
|
9508
9551
|
const wrapFn = (fn) => {
|
|
9509
9552
|
if (typeof fn !== 'function' || (!capture?.length && !captureRef?.length)) {
|
|
@@ -9556,34 +9599,6 @@
|
|
|
9556
9599
|
}
|
|
9557
9600
|
return symbolRef;
|
|
9558
9601
|
};
|
|
9559
|
-
const resolveLazy = (containerEl) => {
|
|
9560
|
-
return symbolRef !== null ? symbolRef : resolve(containerEl);
|
|
9561
|
-
};
|
|
9562
|
-
function invokeFn(currentCtx, beforeFn) {
|
|
9563
|
-
// Note that we bind the current `this`
|
|
9564
|
-
return (...args) => maybeThen(resolveLazy(), (f) => {
|
|
9565
|
-
if (!isFunction(f)) {
|
|
9566
|
-
throw qError(QError_qrlIsNotFunction);
|
|
9567
|
-
}
|
|
9568
|
-
if (beforeFn && beforeFn() === false) {
|
|
9569
|
-
return;
|
|
9570
|
-
}
|
|
9571
|
-
const context = createOrReuseInvocationContext(currentCtx);
|
|
9572
|
-
const prevQrl = context.$qrl$;
|
|
9573
|
-
const prevEvent = context.$event$;
|
|
9574
|
-
// Note that we set the qrl here instead of in wrapFn because
|
|
9575
|
-
// it is possible we're called on a copied qrl
|
|
9576
|
-
context.$qrl$ = qrl;
|
|
9577
|
-
context.$event$ ||= this;
|
|
9578
|
-
try {
|
|
9579
|
-
return invoke.call(this, context, f, ...args);
|
|
9580
|
-
}
|
|
9581
|
-
finally {
|
|
9582
|
-
context.$qrl$ = prevQrl;
|
|
9583
|
-
context.$event$ = prevEvent;
|
|
9584
|
-
}
|
|
9585
|
-
});
|
|
9586
|
-
}
|
|
9587
9602
|
const createOrReuseInvocationContext = (invoke) => {
|
|
9588
9603
|
if (invoke == null) {
|
|
9589
9604
|
return newInvokeContext();
|
|
@@ -9608,7 +9623,7 @@
|
|
|
9608
9623
|
$symbol$: symbol,
|
|
9609
9624
|
$refSymbol$: refSymbol,
|
|
9610
9625
|
$hash$: hash,
|
|
9611
|
-
getFn:
|
|
9626
|
+
getFn: bindFnToContext,
|
|
9612
9627
|
$capture$: capture,
|
|
9613
9628
|
$captureRef$: captureRef,
|
|
9614
9629
|
dev: null,
|