seroval 0.14.1 → 0.15.0

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.
@@ -32,7 +32,6 @@ __export(src_exports, {
32
32
  deserialize: () => deserialize,
33
33
  fromCrossJSON: () => fromCrossJSON,
34
34
  fromJSON: () => fromJSON,
35
- getCrossReferenceHeader: () => getCrossReferenceHeader,
36
35
  serialize: () => serialize,
37
36
  serializeAsync: () => serializeAsync,
38
37
  toCrossJSON: () => toCrossJSON,
@@ -225,9 +224,9 @@ var GLOBAL_CONTEXT_REFERENCES = "$R";
225
224
  var GLOBAL_CONTEXT_R = `self.${GLOBAL_CONTEXT_REFERENCES}`;
226
225
  function getCrossReferenceHeader(id) {
227
226
  if (id == null) {
228
- return `${GLOBAL_CONTEXT_R}=${GLOBAL_CONTEXT_R}||[];`;
227
+ return `${GLOBAL_CONTEXT_R}=${GLOBAL_CONTEXT_R}||[]`;
229
228
  }
230
- return `(${GLOBAL_CONTEXT_R}=${GLOBAL_CONTEXT_R}||{})["${serializeString(id)}"]=[];`;
229
+ return `(${GLOBAL_CONTEXT_R}=${GLOBAL_CONTEXT_R}||{})["${serializeString(id)}"]=[]`;
231
230
  }
232
231
 
233
232
  // src/core/reference.ts
@@ -4160,6 +4159,9 @@ var CrossSyncParserContext = class extends BaseSyncParserContext {
4160
4159
  };
4161
4160
 
4162
4161
  // src/core/cross/index.ts
4162
+ function insertCrossReferenceHeader(scopeId, value) {
4163
+ return "(" + getCrossReferenceHeader(scopeId) + "," + value + ")";
4164
+ }
4163
4165
  function crossSerialize(source, options = {}) {
4164
4166
  const ctx = new CrossSyncParserContext({
4165
4167
  plugins: options.plugins,
@@ -4173,7 +4175,7 @@ function crossSerialize(source, options = {}) {
4173
4175
  scopeId: options.scopeId,
4174
4176
  markedRefs: ctx.marked
4175
4177
  });
4176
- return serial.serializeTop(tree);
4178
+ return insertCrossReferenceHeader(options.scopeId, serial.serializeTop(tree));
4177
4179
  }
4178
4180
  async function crossSerializeAsync(source, options = {}) {
4179
4181
  const ctx = new CrossAsyncParserContext({
@@ -4188,7 +4190,7 @@ async function crossSerializeAsync(source, options = {}) {
4188
4190
  scopeId: options.scopeId,
4189
4191
  markedRefs: ctx.marked
4190
4192
  });
4191
- return serial.serializeTop(tree);
4193
+ return insertCrossReferenceHeader(options.scopeId, serial.serializeTop(tree));
4192
4194
  }
4193
4195
  function toCrossJSON(source, options = {}) {
4194
4196
  const ctx = new CrossSyncParserContext({
@@ -4227,6 +4229,9 @@ function crossSerializeStream(source, options) {
4227
4229
  }
4228
4230
  return;
4229
4231
  }
4232
+ if (initial) {
4233
+ serialized = insertCrossReferenceHeader(options.scopeId, serialized);
4234
+ }
4230
4235
  options.onSerialize(
4231
4236
  serialized,
4232
4237
  initial