Skip to content

Commit dea848e

Browse files
committed
feat: single-pass serialization and deserialization
1 parent 187cd1a commit dea848e

File tree

8 files changed

+488
-179
lines changed

8 files changed

+488
-179
lines changed

packages/qwik/src/core/client/dom-container.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,12 @@ import { emitEvent } from '../shared/qrl/qrl-class';
88
import type { QRL } from '../shared/qrl/qrl.public';
99
import { ChoreType } from '../shared/util-chore-type';
1010
import { _SharedContainer } from '../shared/shared-container';
11-
import { inflateQRL, parseQRL, wrapDeserializerProxy } from '../shared/shared-serialization';
11+
import {
12+
inflateQRL,
13+
parseQRL,
14+
preprocessState,
15+
wrapDeserializerProxy,
16+
} from '../shared/shared-serialization';
1217
import { QContainerValue, type HostElement, type ObjToProxyMap } from '../shared/types';
1318
import { EMPTY_ARRAY } from '../shared/utils/flyweight';
1419
import {
@@ -112,6 +117,7 @@ export class DomContainer extends _SharedContainer implements IClientContainer {
112117
public $storeProxyMap$: ObjToProxyMap = new WeakMap();
113118
public $qFuncs$: Array<(...args: unknown[]) => unknown>;
114119
public $instanceHash$: string;
120+
public $forwardRefs$: Array<number> | null = null;
115121
public vNodeLocate: (id: string | Element) => VNode = (id) => vnode_locate(this.rootVNode, id);
116122

117123
private $stateData$: unknown[];
@@ -159,6 +165,7 @@ export class DomContainer extends _SharedContainer implements IClientContainer {
159165
if (qwikStates.length !== 0) {
160166
const lastState = qwikStates[qwikStates.length - 1];
161167
this.$rawStateData$ = JSON.parse(lastState.textContent!);
168+
preprocessState(this.$rawStateData$, this);
162169
this.$stateData$ = wrapDeserializerProxy(this, this.$rawStateData$) as unknown[];
163170
}
164171
}

packages/qwik/src/core/client/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export interface ClientContainer extends Container {
1818
rootVNode: ElementVNode;
1919
$journal$: VNodeJournal;
2020
renderDone: Promise<void> | null;
21+
$forwardRefs$: Array<number> | null;
2122
parseQRL<T = unknown>(qrl: string): QRL<T>;
2223
$setRawState$(id: number, vParent: ElementVNode | VirtualVNode): void;
2324
}

packages/qwik/src/core/core.api.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ export type ClassList = string | undefined | null | false | Record<string, boole
2424
//
2525
// @internal (undocumented)
2626
export interface ClientContainer extends Container {
27+
// (undocumented)
28+
$forwardRefs$: Array<number> | null;
2729
// Warning: (ae-forgotten-export) The symbol "VNodeJournal" needs to be exported by the entry point index.d.ts
2830
//
2931
// (undocumented)
@@ -177,6 +179,8 @@ class DomContainer extends _SharedContainer implements ClientContainer {
177179
// (undocumented)
178180
$appendStyle$(content: string, styleId: string, host: _VirtualVNode, scoped: boolean): void;
179181
// (undocumented)
182+
$forwardRefs$: Array<number> | null;
183+
// (undocumented)
180184
$getObjectById$: (id: number | string) => unknown;
181185
// (undocumented)
182186
$instanceHash$: string;

0 commit comments

Comments
 (0)