seroval 0.10.1 → 0.10.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/cjs/development/index.cjs +111 -59
- package/dist/cjs/development/index.cjs.map +3 -3
- package/dist/cjs/production/index.cjs +3 -12
- package/dist/esm/development/index.mjs +111 -59
- package/dist/esm/development/index.mjs.map +3 -3
- package/dist/esm/production/index.mjs +2 -11
- package/dist/types/core/Serializer.d.ts +6 -0
- package/dist/types/core/cross/context.d.ts +7 -0
- package/dist/types/core/cross/index.d.ts +1 -0
- package/dist/types/core/keys.d.ts +8 -7
- package/dist/types/core/tree/context.d.ts +0 -1
- package/dist/types/core/tree/index.d.ts +0 -1
- package/dist/types/index.d.ts +1 -1
- package/package.json +2 -2
- package/src/core/Serializer.ts +41 -6
- package/src/core/cross/context.ts +23 -0
- package/src/core/cross/index.ts +32 -17
- package/src/core/cross/serialize.ts +8 -7
- package/src/core/cross/stream.ts +7 -2
- package/src/core/header.js +54 -58
- package/src/core/keys.ts +27 -19
- package/src/core/tree/context.ts +0 -11
- package/src/core/tree/index.ts +5 -9
- package/src/index.ts +1 -1
|
@@ -25,8 +25,8 @@ var __publicField = (obj, key, value) => {
|
|
|
25
25
|
// src/index.ts
|
|
26
26
|
var src_exports = {};
|
|
27
27
|
__export(src_exports, {
|
|
28
|
-
CROSS_REFERENCE_HEADER: () => CROSS_REFERENCE_HEADER,
|
|
29
28
|
Feature: () => Feature,
|
|
29
|
+
GLOBAL_CONTEXT_API_SCRIPT: () => GLOBAL_CONTEXT_API_SCRIPT,
|
|
30
30
|
Serializer: () => Serializer,
|
|
31
31
|
compileJSON: () => compileJSON,
|
|
32
32
|
createReference: () => createReference,
|
|
@@ -36,6 +36,7 @@ __export(src_exports, {
|
|
|
36
36
|
default: () => src_default,
|
|
37
37
|
deserialize: () => deserialize,
|
|
38
38
|
fromJSON: () => fromJSON,
|
|
39
|
+
getCrossReferenceHeader: () => getCrossReferenceHeader,
|
|
39
40
|
serialize: () => serialize,
|
|
40
41
|
serializeAsync: () => serializeAsync,
|
|
41
42
|
toJSON: () => toJSON,
|
|
@@ -218,13 +219,6 @@ function getRefParam(ctx, index) {
|
|
|
218
219
|
}
|
|
219
220
|
return identifier;
|
|
220
221
|
}
|
|
221
|
-
function getRootID(ctx, current) {
|
|
222
|
-
const ref = ctx.reference.ids.get(current);
|
|
223
|
-
if (ref == null) {
|
|
224
|
-
return ctx.reference.ids.size;
|
|
225
|
-
}
|
|
226
|
-
return ref;
|
|
227
|
-
}
|
|
228
222
|
function createIndexedValue(ctx, current) {
|
|
229
223
|
const ref = ctx.reference.ids.get(current);
|
|
230
224
|
if (ref == null) {
|
|
@@ -328,26 +322,23 @@ var NAN_NODE = createConstantNode(7 /* NaN */);
|
|
|
328
322
|
|
|
329
323
|
// src/core/keys.ts
|
|
330
324
|
var REFERENCES_KEY = "__SEROVAL_REFS__";
|
|
325
|
+
var GLOBAL_CONTEXT_API = "_$";
|
|
331
326
|
var GLOBAL_CONTEXT_REFERENCES = "$R";
|
|
332
327
|
var LOCAL_CONTEXT_PROMISE_RESOLVE = "s";
|
|
333
328
|
var LOCAL_CONTEXT_PROMISE_REJECT = "f";
|
|
334
|
-
var GLOBAL_CONTEXT_PROMISE_CONSTRUCTOR = "
|
|
335
|
-
var GLOBAL_CONTEXT_PROMISE_RESOLVE = "
|
|
336
|
-
var GLOBAL_CONTEXT_PROMISE_REJECT = "
|
|
329
|
+
var GLOBAL_CONTEXT_PROMISE_CONSTRUCTOR = "P";
|
|
330
|
+
var GLOBAL_CONTEXT_PROMISE_RESOLVE = "Ps";
|
|
331
|
+
var GLOBAL_CONTEXT_PROMISE_REJECT = "Pf";
|
|
337
332
|
var LOCAL_CONTEXT_STREAM_CONTROLLER = "c";
|
|
338
|
-
var GLOBAL_CONTEXT_STREAM_CONSTRUCTOR = "
|
|
339
|
-
var GLOBAL_CONTEXT_STREAM_EMIT = "
|
|
340
|
-
var
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
function $uS(s){delete s.${LOCAL_CONTEXT_STREAM_CONTROLLER}}
|
|
348
|
-
function ${GLOBAL_CONTEXT_STREAM_EMIT}(i,t,d,s,c){switch(c=(s=${GLOBAL_CONTEXT_REFERENCES}[i]).${LOCAL_CONTEXT_STREAM_CONTROLLER},t){case 0:return c.enqueue(d);case 1:return c.error(d),$uS(s);case 2:return c.close(),$uS(s)}}
|
|
349
|
-
function ${GLOBAL_CONTEXT_STREAM_CONSTRUCTOR}(s,c){return(s=new ReadableStream({start:function(t){c=t}})).c=c,s}
|
|
350
|
-
`;
|
|
333
|
+
var GLOBAL_CONTEXT_STREAM_CONSTRUCTOR = "S";
|
|
334
|
+
var GLOBAL_CONTEXT_STREAM_EMIT = "Se";
|
|
335
|
+
var GLOBAL_CONTEXT_API_SCRIPT = `self.${GLOBAL_CONTEXT_API}=self.${GLOBAL_CONTEXT_API}||{${GLOBAL_CONTEXT_PROMISE_CONSTRUCTOR}:function(s,f,p){return(p=new Promise(function(a,b){s=a,f=b})).${LOCAL_CONTEXT_PROMISE_RESOLVE}=s,p.${LOCAL_CONTEXT_PROMISE_REJECT}=f,p},uP:function(p){delete p.${LOCAL_CONTEXT_PROMISE_RESOLVE};delete p.${LOCAL_CONTEXT_PROMISE_REJECT}},${GLOBAL_CONTEXT_PROMISE_RESOLVE}:function(p,d){p.${LOCAL_CONTEXT_PROMISE_RESOLVE}(d),p.value=d,this.uP(p)},${GLOBAL_CONTEXT_PROMISE_REJECT}:function(p,d){p.${LOCAL_CONTEXT_PROMISE_REJECT}(d),this.uP(p)},uS:function(s){delete s.${LOCAL_CONTEXT_STREAM_CONTROLLER}},${GLOBAL_CONTEXT_STREAM_EMIT}:function(s,t,d,c){switch(c=s.${LOCAL_CONTEXT_STREAM_CONTROLLER},t){case 0:return c.enqueue(d);case 1:return(this.uS(s),c.error(d));case 2:return(this.uS(s),c.close())}},${GLOBAL_CONTEXT_STREAM_CONSTRUCTOR}:function(s,c){return(s=new ReadableStream({start:function(x){c=x}})).${LOCAL_CONTEXT_STREAM_CONTROLLER}=c,s},}`;
|
|
336
|
+
function getCrossReferenceHeader(id) {
|
|
337
|
+
if (id == null) {
|
|
338
|
+
return `self.${GLOBAL_CONTEXT_REFERENCES}=self.${GLOBAL_CONTEXT_REFERENCES}||[];`;
|
|
339
|
+
}
|
|
340
|
+
return `(self.${GLOBAL_CONTEXT_REFERENCES}=self.${GLOBAL_CONTEXT_REFERENCES}||{})["${serializeString(id)}"]=[]`;
|
|
341
|
+
}
|
|
351
342
|
|
|
352
343
|
// src/core/reference.ts
|
|
353
344
|
var REFERENCE = /* @__PURE__ */ new Map();
|
|
@@ -2669,7 +2660,7 @@ function parseSync(ctx, current) {
|
|
|
2669
2660
|
|
|
2670
2661
|
// src/core/tree/index.ts
|
|
2671
2662
|
function finalize(ctx, rootID, isObject, result) {
|
|
2672
|
-
if (ctx.vars.length) {
|
|
2663
|
+
if (rootID != null && ctx.vars.length) {
|
|
2673
2664
|
const patches = resolvePatches(ctx);
|
|
2674
2665
|
let body = result;
|
|
2675
2666
|
if (patches) {
|
|
@@ -2701,7 +2692,7 @@ function serialize(source, options) {
|
|
|
2701
2692
|
const result = serializeTree(serial, tree);
|
|
2702
2693
|
return finalize(
|
|
2703
2694
|
serial,
|
|
2704
|
-
|
|
2695
|
+
tree.i,
|
|
2705
2696
|
tree.t === 10 /* Object */,
|
|
2706
2697
|
result
|
|
2707
2698
|
);
|
|
@@ -2716,7 +2707,7 @@ async function serializeAsync(source, options) {
|
|
|
2716
2707
|
const result = serializeTree(serial, tree);
|
|
2717
2708
|
return finalize(
|
|
2718
2709
|
serial,
|
|
2719
|
-
|
|
2710
|
+
tree.i,
|
|
2720
2711
|
tree.t === 10 /* Object */,
|
|
2721
2712
|
result
|
|
2722
2713
|
);
|
|
@@ -2728,7 +2719,6 @@ function toJSON(source, options) {
|
|
|
2728
2719
|
const ctx = createParserContext(options);
|
|
2729
2720
|
return {
|
|
2730
2721
|
t: parseSync(ctx, source),
|
|
2731
|
-
r: getRootID(ctx, source),
|
|
2732
2722
|
f: ctx.features,
|
|
2733
2723
|
m: Array.from(ctx.reference.marked)
|
|
2734
2724
|
};
|
|
@@ -2737,7 +2727,6 @@ async function toJSONAsync(source, options) {
|
|
|
2737
2727
|
const ctx = createParserContext(options);
|
|
2738
2728
|
return {
|
|
2739
2729
|
t: await parseAsync(ctx, source),
|
|
2740
|
-
r: getRootID(ctx, source),
|
|
2741
2730
|
f: ctx.features,
|
|
2742
2731
|
m: Array.from(ctx.reference.marked)
|
|
2743
2732
|
};
|
|
@@ -2748,7 +2737,7 @@ function compileJSON(source) {
|
|
|
2748
2737
|
markedRefs: source.m
|
|
2749
2738
|
});
|
|
2750
2739
|
const result = serializeTree(serial, source.t);
|
|
2751
|
-
return finalize(serial, source.
|
|
2740
|
+
return finalize(serial, source.t.i, source.t.i === 10 /* Object */, result);
|
|
2752
2741
|
}
|
|
2753
2742
|
function fromJSON(source) {
|
|
2754
2743
|
const serial = createDeserializerContext({
|
|
@@ -2760,6 +2749,7 @@ function fromJSON(source) {
|
|
|
2760
2749
|
// src/core/cross/context.ts
|
|
2761
2750
|
function createCrossParserContext(options = {}) {
|
|
2762
2751
|
return {
|
|
2752
|
+
scopeId: options.scopeId,
|
|
2763
2753
|
refs: options.refs || /* @__PURE__ */ new Map(),
|
|
2764
2754
|
features: ALL_ENABLED ^ (options.disabledFeatures || 0)
|
|
2765
2755
|
};
|
|
@@ -2776,11 +2766,26 @@ function createCrossIndexedValue(ctx, current) {
|
|
|
2776
2766
|
function createStreamingCrossParserContext(options) {
|
|
2777
2767
|
return {
|
|
2778
2768
|
alive: true,
|
|
2769
|
+
pending: 0,
|
|
2779
2770
|
refs: options.refs || /* @__PURE__ */ new Map(),
|
|
2780
2771
|
features: ALL_ENABLED ^ (options.disabledFeatures || 0),
|
|
2781
|
-
onParse: options.onParse
|
|
2772
|
+
onParse: options.onParse,
|
|
2773
|
+
onDone() {
|
|
2774
|
+
if (options.onDone) {
|
|
2775
|
+
options.onDone();
|
|
2776
|
+
}
|
|
2777
|
+
},
|
|
2778
|
+
scopeId: options.scopeId
|
|
2782
2779
|
};
|
|
2783
2780
|
}
|
|
2781
|
+
function pushPendingState(ctx) {
|
|
2782
|
+
ctx.pending++;
|
|
2783
|
+
}
|
|
2784
|
+
function popPendingState(ctx) {
|
|
2785
|
+
if (--ctx.pending <= 0) {
|
|
2786
|
+
ctx.onDone();
|
|
2787
|
+
}
|
|
2788
|
+
}
|
|
2784
2789
|
function createCrossSerializerContext(options) {
|
|
2785
2790
|
return {
|
|
2786
2791
|
stack: [],
|
|
@@ -3820,25 +3825,25 @@ function serializeWKSymbol2(node) {
|
|
|
3820
3825
|
return assignIndexedValue3(node.i, SYMBOL_STRING[node.s]);
|
|
3821
3826
|
}
|
|
3822
3827
|
function serializePromiseResolve(ctx, node) {
|
|
3823
|
-
return GLOBAL_CONTEXT_PROMISE_RESOLVE + "(" + node.i + "," + crossSerializeTree(ctx, node.f) + ")";
|
|
3828
|
+
return GLOBAL_CONTEXT_API + "." + GLOBAL_CONTEXT_PROMISE_RESOLVE + "(" + getRefExpr(node.i) + "," + crossSerializeTree(ctx, node.f) + ")";
|
|
3824
3829
|
}
|
|
3825
3830
|
function serializePromiseReject(ctx, node) {
|
|
3826
|
-
return GLOBAL_CONTEXT_PROMISE_REJECT + "(" + node.i + "," + crossSerializeTree(ctx, node.f) + ")";
|
|
3831
|
+
return GLOBAL_CONTEXT_API + "." + GLOBAL_CONTEXT_PROMISE_REJECT + "(" + getRefExpr(node.i) + "," + crossSerializeTree(ctx, node.f) + ")";
|
|
3827
3832
|
}
|
|
3828
3833
|
function serializePromiseConstructor(node) {
|
|
3829
|
-
return assignIndexedValue3(node.i, GLOBAL_CONTEXT_PROMISE_CONSTRUCTOR + "()");
|
|
3834
|
+
return assignIndexedValue3(node.i, GLOBAL_CONTEXT_API + "." + GLOBAL_CONTEXT_PROMISE_CONSTRUCTOR + "()");
|
|
3830
3835
|
}
|
|
3831
3836
|
function serializeReadableStreamClose(node) {
|
|
3832
|
-
return GLOBAL_CONTEXT_STREAM_EMIT + "(" + node.i + ",2)";
|
|
3837
|
+
return GLOBAL_CONTEXT_API + "." + GLOBAL_CONTEXT_STREAM_EMIT + "(" + getRefExpr(node.i) + ",2)";
|
|
3833
3838
|
}
|
|
3834
3839
|
function serializeReadableStreamEnqueue(ctx, node) {
|
|
3835
|
-
return GLOBAL_CONTEXT_STREAM_EMIT + "(" + node.i + ",0," + crossSerializeTree(ctx, node.f) + ")";
|
|
3840
|
+
return GLOBAL_CONTEXT_API + "." + GLOBAL_CONTEXT_STREAM_EMIT + "(" + getRefExpr(node.i) + ",0," + crossSerializeTree(ctx, node.f) + ")";
|
|
3836
3841
|
}
|
|
3837
3842
|
function serializeReadableStreamError(ctx, node) {
|
|
3838
|
-
return GLOBAL_CONTEXT_STREAM_EMIT + "(" + node.i + ",1," + crossSerializeTree(ctx, node.f) + ")";
|
|
3843
|
+
return GLOBAL_CONTEXT_API + "." + GLOBAL_CONTEXT_STREAM_EMIT + "(" + getRefExpr(node.i) + ",1," + crossSerializeTree(ctx, node.f) + ")";
|
|
3839
3844
|
}
|
|
3840
3845
|
function serializeReadableStreamConstructor(node) {
|
|
3841
|
-
return assignIndexedValue3(node.i, GLOBAL_CONTEXT_STREAM_CONSTRUCTOR + "()");
|
|
3846
|
+
return assignIndexedValue3(node.i, GLOBAL_CONTEXT_API + "." + GLOBAL_CONTEXT_STREAM_CONSTRUCTOR + "()");
|
|
3842
3847
|
}
|
|
3843
3848
|
function crossSerializeTree(ctx, node) {
|
|
3844
3849
|
switch (node.t) {
|
|
@@ -4125,6 +4130,7 @@ function generatePromiseNode3(ctx, id, current) {
|
|
|
4125
4130
|
b: void 0,
|
|
4126
4131
|
o: void 0
|
|
4127
4132
|
}, false);
|
|
4133
|
+
popPendingState(ctx);
|
|
4128
4134
|
}
|
|
4129
4135
|
},
|
|
4130
4136
|
(data) => {
|
|
@@ -4143,9 +4149,11 @@ function generatePromiseNode3(ctx, id, current) {
|
|
|
4143
4149
|
b: void 0,
|
|
4144
4150
|
o: void 0
|
|
4145
4151
|
}, false);
|
|
4152
|
+
popPendingState(ctx);
|
|
4146
4153
|
}
|
|
4147
4154
|
}
|
|
4148
4155
|
);
|
|
4156
|
+
pushPendingState(ctx);
|
|
4149
4157
|
return {
|
|
4150
4158
|
t: 28 /* PromiseConstructor */,
|
|
4151
4159
|
i: id,
|
|
@@ -4274,6 +4282,7 @@ function generateBoxedNode4(ctx, id, current) {
|
|
|
4274
4282
|
function generateReadableStreamNode(ctx, id, current) {
|
|
4275
4283
|
assert(ctx.features & 8192 /* WebAPI */, new UnsupportedTypeError(current));
|
|
4276
4284
|
const reader = current.getReader();
|
|
4285
|
+
pushPendingState(ctx);
|
|
4277
4286
|
function push() {
|
|
4278
4287
|
reader.read().then(
|
|
4279
4288
|
(data) => {
|
|
@@ -4293,6 +4302,7 @@ function generateReadableStreamNode(ctx, id, current) {
|
|
|
4293
4302
|
b: void 0,
|
|
4294
4303
|
o: void 0
|
|
4295
4304
|
}, false);
|
|
4305
|
+
popPendingState(ctx);
|
|
4296
4306
|
} else {
|
|
4297
4307
|
ctx.onParse({
|
|
4298
4308
|
t: 32 /* ReadableStreamEnqueue */,
|
|
@@ -4328,7 +4338,7 @@ function generateReadableStreamNode(ctx, id, current) {
|
|
|
4328
4338
|
b: void 0,
|
|
4329
4339
|
o: void 0
|
|
4330
4340
|
}, false);
|
|
4331
|
-
|
|
4341
|
+
popPendingState(ctx);
|
|
4332
4342
|
}
|
|
4333
4343
|
}
|
|
4334
4344
|
);
|
|
@@ -4909,22 +4919,23 @@ function crossParseSync(ctx, current) {
|
|
|
4909
4919
|
}
|
|
4910
4920
|
|
|
4911
4921
|
// src/core/cross/index.ts
|
|
4912
|
-
function finalize2(ctx, id, result) {
|
|
4922
|
+
function finalize2(ctx, scopeId, id, result) {
|
|
4923
|
+
if (id == null) {
|
|
4924
|
+
return result;
|
|
4925
|
+
}
|
|
4913
4926
|
const patches = resolvePatches2(ctx);
|
|
4914
|
-
|
|
4915
|
-
|
|
4916
|
-
|
|
4917
|
-
|
|
4918
|
-
|
|
4919
|
-
|
|
4920
|
-
|
|
4921
|
-
|
|
4922
|
-
|
|
4923
|
-
|
|
4924
|
-
}
|
|
4925
|
-
return "(" + result + "," + patches + getRefExpr(id) + ")";
|
|
4927
|
+
const ref = getRefExpr(id);
|
|
4928
|
+
const params = scopeId == null ? "" : GLOBAL_CONTEXT_REFERENCES;
|
|
4929
|
+
const mainBody = patches ? result + "," + patches : result;
|
|
4930
|
+
if (params === "") {
|
|
4931
|
+
return patches ? "(" + mainBody + ref + ")" : mainBody;
|
|
4932
|
+
}
|
|
4933
|
+
const args = scopeId == null ? "()" : "(" + GLOBAL_CONTEXT_REFERENCES + '["' + serializeString(scopeId) + '"])';
|
|
4934
|
+
const body = mainBody + (patches ? ref : "");
|
|
4935
|
+
if (ctx.features & 4 /* ArrowFunction */) {
|
|
4936
|
+
return "(" + params + "=>(" + body + "))" + args;
|
|
4926
4937
|
}
|
|
4927
|
-
return
|
|
4938
|
+
return "(function(" + params + "){return " + body + "})" + args;
|
|
4928
4939
|
}
|
|
4929
4940
|
function crossSerialize(source, options) {
|
|
4930
4941
|
const ctx = createCrossParserContext(options);
|
|
@@ -4935,6 +4946,7 @@ function crossSerialize(source, options) {
|
|
|
4935
4946
|
const result = crossSerializeTree(serial, tree);
|
|
4936
4947
|
return finalize2(
|
|
4937
4948
|
serial,
|
|
4949
|
+
ctx.scopeId,
|
|
4938
4950
|
tree.i,
|
|
4939
4951
|
result
|
|
4940
4952
|
);
|
|
@@ -4948,12 +4960,14 @@ async function crossSerializeAsync(source, options) {
|
|
|
4948
4960
|
const result = crossSerializeTree(serial, tree);
|
|
4949
4961
|
return finalize2(
|
|
4950
4962
|
serial,
|
|
4963
|
+
ctx.scopeId,
|
|
4951
4964
|
tree.i,
|
|
4952
4965
|
result
|
|
4953
4966
|
);
|
|
4954
4967
|
}
|
|
4955
4968
|
function crossSerializeStream(source, options) {
|
|
4956
4969
|
const ctx = createStreamingCrossParserContext({
|
|
4970
|
+
scopeId: options.scopeId,
|
|
4957
4971
|
refs: options.refs,
|
|
4958
4972
|
disabledFeatures: options.disabledFeatures,
|
|
4959
4973
|
onParse(node, initial) {
|
|
@@ -4963,16 +4977,25 @@ function crossSerializeStream(source, options) {
|
|
|
4963
4977
|
options.onSerialize(
|
|
4964
4978
|
finalize2(
|
|
4965
4979
|
serial,
|
|
4980
|
+
ctx.scopeId,
|
|
4966
4981
|
node.i,
|
|
4967
4982
|
crossSerializeTree(serial, node)
|
|
4968
4983
|
),
|
|
4969
4984
|
initial
|
|
4970
4985
|
);
|
|
4971
|
-
}
|
|
4986
|
+
},
|
|
4987
|
+
onDone: options.onDone
|
|
4972
4988
|
});
|
|
4973
4989
|
ctx.onParse(crossParseStream(ctx, source), true);
|
|
4974
|
-
|
|
4990
|
+
if (ctx.pending <= 0) {
|
|
4991
|
+
ctx.onDone();
|
|
4975
4992
|
ctx.alive = false;
|
|
4993
|
+
}
|
|
4994
|
+
return () => {
|
|
4995
|
+
if (ctx.alive) {
|
|
4996
|
+
ctx.alive = false;
|
|
4997
|
+
ctx.onDone();
|
|
4998
|
+
}
|
|
4976
4999
|
};
|
|
4977
5000
|
}
|
|
4978
5001
|
|
|
@@ -4981,27 +5004,56 @@ var Serializer = class {
|
|
|
4981
5004
|
constructor(options) {
|
|
4982
5005
|
this.options = options;
|
|
4983
5006
|
__publicField(this, "alive", true);
|
|
5007
|
+
__publicField(this, "flushed", false);
|
|
5008
|
+
__publicField(this, "done", false);
|
|
5009
|
+
__publicField(this, "pending", 0);
|
|
4984
5010
|
__publicField(this, "cleanups", []);
|
|
4985
5011
|
__publicField(this, "refs", /* @__PURE__ */ new Map());
|
|
4986
5012
|
}
|
|
4987
5013
|
write(key, value) {
|
|
4988
|
-
if (this.alive) {
|
|
5014
|
+
if (this.alive && !this.flushed) {
|
|
5015
|
+
this.pending++;
|
|
4989
5016
|
this.cleanups.push(crossSerializeStream(value, {
|
|
5017
|
+
scopeId: this.options.scopeId,
|
|
4990
5018
|
refs: this.refs,
|
|
4991
5019
|
disabledFeatures: this.options.disabledFeatures,
|
|
4992
5020
|
onSerialize: (data, initial) => {
|
|
4993
|
-
this.
|
|
4994
|
-
|
|
4995
|
-
|
|
5021
|
+
if (this.alive) {
|
|
5022
|
+
this.options.onData(
|
|
5023
|
+
initial ? this.options.globalIdentifier + '["' + serializeString(key) + '"]=' + data : data
|
|
5024
|
+
);
|
|
5025
|
+
}
|
|
5026
|
+
},
|
|
5027
|
+
onDone: () => {
|
|
5028
|
+
if (this.alive) {
|
|
5029
|
+
this.pending--;
|
|
5030
|
+
if (this.pending <= 0 && this.flushed && !this.done && this.options.onDone) {
|
|
5031
|
+
this.options.onDone();
|
|
5032
|
+
this.done = true;
|
|
5033
|
+
}
|
|
5034
|
+
}
|
|
4996
5035
|
}
|
|
4997
5036
|
}));
|
|
4998
5037
|
}
|
|
4999
5038
|
}
|
|
5039
|
+
flush() {
|
|
5040
|
+
if (this.alive) {
|
|
5041
|
+
this.flushed = true;
|
|
5042
|
+
if (this.pending <= 0 && !this.done && this.options.onDone) {
|
|
5043
|
+
this.options.onDone();
|
|
5044
|
+
this.done = true;
|
|
5045
|
+
}
|
|
5046
|
+
}
|
|
5047
|
+
}
|
|
5000
5048
|
close() {
|
|
5001
5049
|
if (this.alive) {
|
|
5002
5050
|
for (let i = 0, len = this.cleanups.length; i < len; i++) {
|
|
5003
5051
|
this.cleanups[i]();
|
|
5004
5052
|
}
|
|
5053
|
+
if (!this.done && this.options.onDone) {
|
|
5054
|
+
this.options.onDone();
|
|
5055
|
+
this.done = true;
|
|
5056
|
+
}
|
|
5005
5057
|
this.alive = false;
|
|
5006
5058
|
}
|
|
5007
5059
|
}
|