@lionweb/class-core 0.8.0-beta.3 → 0.8.0-beta.5
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/CHANGELOG.md +6 -0
- package/dist/deltas/appliers.d.ts.map +1 -1
- package/dist/deltas/appliers.js +6 -101
- package/dist/deltas/appliers.js.map +1 -1
- package/dist/deltas/inverters.d.ts.map +1 -1
- package/dist/deltas/inverters.js +1 -28
- package/dist/deltas/inverters.js.map +1 -1
- package/dist/deltas/serialization/deserializer.g.d.ts.map +1 -1
- package/dist/deltas/serialization/deserializer.g.js +1 -58
- package/dist/deltas/serialization/deserializer.g.js.map +1 -1
- package/dist/deltas/serialization/serializer.g.d.ts.map +1 -1
- package/dist/deltas/serialization/serializer.g.js +1 -70
- package/dist/deltas/serialization/serializer.g.js.map +1 -1
- package/dist/deltas/serialization/types.g.d.ts +6 -63
- package/dist/deltas/serialization/types.g.d.ts.map +1 -1
- package/dist/deltas/types.g.d.ts +0 -57
- package/dist/deltas/types.g.d.ts.map +1 -1
- package/dist/deltas/types.g.js +0 -63
- package/dist/deltas/types.g.js.map +1 -1
- package/dist/deserializer.d.ts +6 -4
- package/dist/deserializer.d.ts.map +1 -1
- package/dist/deserializer.js +16 -16
- package/dist/deserializer.js.map +1 -1
- package/dist/duplicator.d.ts.map +1 -1
- package/dist/duplicator.js +2 -2
- package/dist/duplicator.js.map +1 -1
- package/dist/id-mapping.d.ts +2 -2
- package/dist/id-mapping.d.ts.map +1 -1
- package/dist/id-mapping.js +4 -4
- package/dist/id-mapping.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/references.d.ts +4 -4
- package/dist/references.d.ts.map +1 -1
- package/dist/references.js +3 -3
- package/dist/references.js.map +1 -1
- package/dist/serializer.d.ts +2 -2
- package/dist/serializer.d.ts.map +1 -1
- package/dist/serializer.js +30 -24
- package/dist/serializer.js.map +1 -1
- package/dist/textualizer.d.ts.map +1 -1
- package/dist/textualizer.js +9 -5
- package/dist/textualizer.js.map +1 -1
- package/dist/value-managers/references.d.ts.map +1 -1
- package/dist/value-managers/references.js +5 -2
- package/dist/value-managers/references.js.map +1 -1
- package/package.json +4 -4
- package/src/deltas/appliers.ts +5 -97
- package/src/deltas/inverters.ts +0 -33
- package/src/deltas/serialization/deserializer.g.ts +0 -63
- package/src/deltas/serialization/serializer.g.ts +0 -87
- package/src/deltas/serialization/types.g.ts +5 -74
- package/src/deltas/types.g.ts +0 -75
- package/src/deserializer.ts +23 -21
- package/src/duplicator.ts +12 -2
- package/src/id-mapping.ts +6 -6
- package/src/index.ts +2 -2
- package/src/references.ts +5 -5
- package/src/serializer.ts +32 -24
- package/src/textualizer.ts +19 -6
- package/src/value-managers/references.ts +5 -7
|
@@ -42,12 +42,6 @@ import {
|
|
|
42
42
|
ChildMovedInSameContainmentDelta,
|
|
43
43
|
ChildReplacedDelta,
|
|
44
44
|
CompositeDelta,
|
|
45
|
-
EntryMovedAndReplacedFromOtherReferenceDelta,
|
|
46
|
-
EntryMovedAndReplacedFromOtherReferenceInSameParentDelta,
|
|
47
|
-
EntryMovedAndReplacedInSameReferenceDelta,
|
|
48
|
-
EntryMovedFromOtherReferenceDelta,
|
|
49
|
-
EntryMovedFromOtherReferenceInSameParentDelta,
|
|
50
|
-
EntryMovedInSameReferenceDelta,
|
|
51
45
|
NoOpDelta,
|
|
52
46
|
PartitionAddedDelta,
|
|
53
47
|
PartitionDeletedDelta,
|
|
@@ -243,63 +237,6 @@ export const deltaDeserializer = (languageBases: ILanguageBase[], idMapping: IdM
|
|
|
243
237
|
const oldTarget = idMapping.fromRefId(delta.oldTarget);
|
|
244
238
|
return new ReferenceChangedDelta(parent, reference, index, newTarget, oldTarget);
|
|
245
239
|
}
|
|
246
|
-
case "EntryMovedFromOtherReference": {
|
|
247
|
-
const oldParent = idMapping.fromId(delta.oldParent);
|
|
248
|
-
const oldReference = resolvedReferenceFrom(delta.oldReference, oldParent.classifier);
|
|
249
|
-
const oldIndex = delta.oldIndex;
|
|
250
|
-
const newParent = idMapping.fromId(delta.newParent);
|
|
251
|
-
const newReference = resolvedReferenceFrom(delta.newReference, newParent.classifier);
|
|
252
|
-
const newIndex = delta.newIndex;
|
|
253
|
-
const movedTarget = idMapping.fromRefId(delta.movedTarget);
|
|
254
|
-
return new EntryMovedFromOtherReferenceDelta(oldParent, oldReference, oldIndex, newParent, newReference, newIndex, movedTarget);
|
|
255
|
-
}
|
|
256
|
-
case "EntryMovedFromOtherReferenceInSameParent": {
|
|
257
|
-
const parent = idMapping.fromId(delta.parent);
|
|
258
|
-
const oldReference = resolvedReferenceFrom(delta.oldReference, parent.classifier);
|
|
259
|
-
const oldIndex = delta.oldIndex;
|
|
260
|
-
const newReference = resolvedReferenceFrom(delta.newReference, parent.classifier);
|
|
261
|
-
const newIndex = delta.newIndex;
|
|
262
|
-
const movedTarget = idMapping.fromRefId(delta.movedTarget);
|
|
263
|
-
return new EntryMovedFromOtherReferenceInSameParentDelta(parent, oldReference, oldIndex, newReference, newIndex, movedTarget);
|
|
264
|
-
}
|
|
265
|
-
case "EntryMovedInSameReference": {
|
|
266
|
-
const parent = idMapping.fromId(delta.parent);
|
|
267
|
-
const reference = resolvedReferenceFrom(delta.reference, parent.classifier);
|
|
268
|
-
const oldIndex = delta.oldIndex;
|
|
269
|
-
const newIndex = delta.newIndex;
|
|
270
|
-
const movedTarget = idMapping.fromRefId(delta.movedTarget);
|
|
271
|
-
return new EntryMovedInSameReferenceDelta(parent, reference, oldIndex, newIndex, movedTarget);
|
|
272
|
-
}
|
|
273
|
-
case "EntryMovedAndReplacedFromOtherReference": {
|
|
274
|
-
const newParent = idMapping.fromId(delta.newParent);
|
|
275
|
-
const newReference = resolvedReferenceFrom(delta.newReference, newParent.classifier);
|
|
276
|
-
const newIndex = delta.newIndex;
|
|
277
|
-
const movedTarget = idMapping.fromRefId(delta.movedTarget);
|
|
278
|
-
const oldParent = idMapping.fromId(delta.oldParent);
|
|
279
|
-
const oldReference = resolvedReferenceFrom(delta.oldReference, oldParent.classifier);
|
|
280
|
-
const oldIndex = delta.oldIndex;
|
|
281
|
-
const replacedTarget = idMapping.fromRefId(delta.replacedTarget);
|
|
282
|
-
return new EntryMovedAndReplacedFromOtherReferenceDelta(newParent, newReference, newIndex, movedTarget, oldParent, oldReference, oldIndex, replacedTarget);
|
|
283
|
-
}
|
|
284
|
-
case "EntryMovedAndReplacedFromOtherReferenceInSameParent": {
|
|
285
|
-
const parent = idMapping.fromId(delta.parent);
|
|
286
|
-
const oldReference = resolvedReferenceFrom(delta.oldReference, parent.classifier);
|
|
287
|
-
const oldIndex = delta.oldIndex;
|
|
288
|
-
const newReference = resolvedReferenceFrom(delta.newReference, parent.classifier);
|
|
289
|
-
const newIndex = delta.newIndex;
|
|
290
|
-
const movedTarget = idMapping.fromRefId(delta.movedTarget);
|
|
291
|
-
const replacedTarget = idMapping.fromRefId(delta.replacedTarget);
|
|
292
|
-
return new EntryMovedAndReplacedFromOtherReferenceInSameParentDelta(parent, oldReference, oldIndex, newReference, newIndex, movedTarget, replacedTarget);
|
|
293
|
-
}
|
|
294
|
-
case "EntryMovedAndReplacedInSameReference": {
|
|
295
|
-
const parent = idMapping.fromId(delta.parent);
|
|
296
|
-
const reference = resolvedReferenceFrom(delta.reference, parent.classifier);
|
|
297
|
-
const oldIndex = delta.oldIndex;
|
|
298
|
-
const newIndex = delta.newIndex;
|
|
299
|
-
const movedTarget = idMapping.fromRefId(delta.movedTarget);
|
|
300
|
-
const replacedTarget = idMapping.fromRefId(delta.replacedTarget);
|
|
301
|
-
return new EntryMovedAndReplacedInSameReferenceDelta(parent, reference, oldIndex, newIndex, movedTarget, replacedTarget);
|
|
302
|
-
}
|
|
303
240
|
case "Composite": {
|
|
304
241
|
const parts = delta.parts.map(deserializedDelta);
|
|
305
242
|
return new CompositeDelta(parts);
|
|
@@ -38,12 +38,6 @@ import {
|
|
|
38
38
|
ChildMovedInSameContainmentDelta,
|
|
39
39
|
ChildReplacedDelta,
|
|
40
40
|
CompositeDelta,
|
|
41
|
-
EntryMovedAndReplacedFromOtherReferenceDelta,
|
|
42
|
-
EntryMovedAndReplacedFromOtherReferenceInSameParentDelta,
|
|
43
|
-
EntryMovedAndReplacedInSameReferenceDelta,
|
|
44
|
-
EntryMovedFromOtherReferenceDelta,
|
|
45
|
-
EntryMovedFromOtherReferenceInSameParentDelta,
|
|
46
|
-
EntryMovedInSameReferenceDelta,
|
|
47
41
|
NoOpDelta,
|
|
48
42
|
PartitionAddedDelta,
|
|
49
43
|
PartitionDeletedDelta,
|
|
@@ -72,12 +66,6 @@ import {
|
|
|
72
66
|
ChildMovedInSameContainmentSerializedDelta,
|
|
73
67
|
ChildReplacedSerializedDelta,
|
|
74
68
|
CompositeSerializedDelta,
|
|
75
|
-
EntryMovedAndReplacedFromOtherReferenceInSameParentSerializedDelta,
|
|
76
|
-
EntryMovedAndReplacedFromOtherReferenceSerializedDelta,
|
|
77
|
-
EntryMovedAndReplacedInSameReferenceSerializedDelta,
|
|
78
|
-
EntryMovedFromOtherReferenceInSameParentSerializedDelta,
|
|
79
|
-
EntryMovedFromOtherReferenceSerializedDelta,
|
|
80
|
-
EntryMovedInSameReferenceSerializedDelta,
|
|
81
69
|
NoOpSerializedDelta,
|
|
82
70
|
PartitionAddedSerializedDelta,
|
|
83
71
|
PartitionDeletedSerializedDelta,
|
|
@@ -360,81 +348,6 @@ export const serializeDelta = (delta: IDelta): SerializedDelta => {
|
|
|
360
348
|
} as ReferenceChangedSerializedDelta;
|
|
361
349
|
}
|
|
362
350
|
|
|
363
|
-
if (delta instanceof EntryMovedFromOtherReferenceDelta) {
|
|
364
|
-
return {
|
|
365
|
-
kind: "EntryMovedFromOtherReference",
|
|
366
|
-
oldParent: delta.oldParent.id,
|
|
367
|
-
oldReference: metaPointerFor(delta.oldReference),
|
|
368
|
-
oldIndex: delta.oldIndex,
|
|
369
|
-
newParent: delta.newParent.id,
|
|
370
|
-
newReference: metaPointerFor(delta.newReference),
|
|
371
|
-
newIndex: delta.newIndex,
|
|
372
|
-
movedTarget: idFrom(delta.movedTarget)
|
|
373
|
-
} as EntryMovedFromOtherReferenceSerializedDelta;
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
if (delta instanceof EntryMovedFromOtherReferenceInSameParentDelta) {
|
|
377
|
-
return {
|
|
378
|
-
kind: "EntryMovedFromOtherReferenceInSameParent",
|
|
379
|
-
parent: delta.parent.id,
|
|
380
|
-
oldReference: metaPointerFor(delta.oldReference),
|
|
381
|
-
oldIndex: delta.oldIndex,
|
|
382
|
-
newReference: metaPointerFor(delta.newReference),
|
|
383
|
-
newIndex: delta.newIndex,
|
|
384
|
-
movedTarget: idFrom(delta.movedTarget)
|
|
385
|
-
} as EntryMovedFromOtherReferenceInSameParentSerializedDelta;
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
if (delta instanceof EntryMovedInSameReferenceDelta) {
|
|
389
|
-
return {
|
|
390
|
-
kind: "EntryMovedInSameReference",
|
|
391
|
-
parent: delta.parent.id,
|
|
392
|
-
reference: metaPointerFor(delta.reference),
|
|
393
|
-
oldIndex: delta.oldIndex,
|
|
394
|
-
newIndex: delta.newIndex,
|
|
395
|
-
movedTarget: idFrom(delta.movedTarget)
|
|
396
|
-
} as EntryMovedInSameReferenceSerializedDelta;
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
if (delta instanceof EntryMovedAndReplacedFromOtherReferenceDelta) {
|
|
400
|
-
return {
|
|
401
|
-
kind: "EntryMovedAndReplacedFromOtherReference",
|
|
402
|
-
newParent: delta.newParent.id,
|
|
403
|
-
newReference: metaPointerFor(delta.newReference),
|
|
404
|
-
newIndex: delta.newIndex,
|
|
405
|
-
movedTarget: idFrom(delta.movedTarget),
|
|
406
|
-
oldParent: delta.oldParent.id,
|
|
407
|
-
oldReference: metaPointerFor(delta.oldReference),
|
|
408
|
-
oldIndex: delta.oldIndex,
|
|
409
|
-
replacedTarget: idFrom(delta.replacedTarget)
|
|
410
|
-
} as EntryMovedAndReplacedFromOtherReferenceSerializedDelta;
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
if (delta instanceof EntryMovedAndReplacedFromOtherReferenceInSameParentDelta) {
|
|
414
|
-
return {
|
|
415
|
-
kind: "EntryMovedAndReplacedFromOtherReferenceInSameParent",
|
|
416
|
-
parent: delta.parent.id,
|
|
417
|
-
oldReference: metaPointerFor(delta.oldReference),
|
|
418
|
-
oldIndex: delta.oldIndex,
|
|
419
|
-
newReference: metaPointerFor(delta.newReference),
|
|
420
|
-
newIndex: delta.newIndex,
|
|
421
|
-
movedTarget: idFrom(delta.movedTarget),
|
|
422
|
-
replacedTarget: idFrom(delta.replacedTarget)
|
|
423
|
-
} as EntryMovedAndReplacedFromOtherReferenceInSameParentSerializedDelta;
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
if (delta instanceof EntryMovedAndReplacedInSameReferenceDelta) {
|
|
427
|
-
return {
|
|
428
|
-
kind: "EntryMovedAndReplacedInSameReference",
|
|
429
|
-
parent: delta.parent.id,
|
|
430
|
-
reference: metaPointerFor(delta.reference),
|
|
431
|
-
oldIndex: delta.oldIndex,
|
|
432
|
-
newIndex: delta.newIndex,
|
|
433
|
-
movedTarget: idFrom(delta.movedTarget),
|
|
434
|
-
replacedTarget: idFrom(delta.replacedTarget)
|
|
435
|
-
} as EntryMovedAndReplacedInSameReferenceSerializedDelta;
|
|
436
|
-
}
|
|
437
|
-
|
|
438
351
|
if (delta instanceof CompositeDelta) {
|
|
439
352
|
return {
|
|
440
353
|
kind: "Composite",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
// Modifying it by hand is useless at best, and sabotage at worst.
|
|
20
20
|
|
|
21
21
|
import { LionWebId, LionWebJsonMetaPointer, LionWebJsonChunk } from "@lionweb/json";
|
|
22
|
-
import {
|
|
22
|
+
import { IdOrNull } from "../../references.js";
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
export type SerializedDelta =
|
|
@@ -47,12 +47,6 @@ export type SerializedDelta =
|
|
|
47
47
|
| ReferenceAddedSerializedDelta
|
|
48
48
|
| ReferenceDeletedSerializedDelta
|
|
49
49
|
| ReferenceChangedSerializedDelta
|
|
50
|
-
| EntryMovedFromOtherReferenceSerializedDelta
|
|
51
|
-
| EntryMovedFromOtherReferenceInSameParentSerializedDelta
|
|
52
|
-
| EntryMovedInSameReferenceSerializedDelta
|
|
53
|
-
| EntryMovedAndReplacedFromOtherReferenceSerializedDelta
|
|
54
|
-
| EntryMovedAndReplacedFromOtherReferenceInSameParentSerializedDelta
|
|
55
|
-
| EntryMovedAndReplacedInSameReferenceSerializedDelta
|
|
56
50
|
| CompositeSerializedDelta
|
|
57
51
|
| NoOpSerializedDelta
|
|
58
52
|
;
|
|
@@ -255,7 +249,7 @@ export type ReferenceAddedSerializedDelta = {
|
|
|
255
249
|
parent: LionWebId
|
|
256
250
|
reference: LionWebJsonMetaPointer
|
|
257
251
|
index: number
|
|
258
|
-
newTarget:
|
|
252
|
+
newTarget: IdOrNull
|
|
259
253
|
}
|
|
260
254
|
|
|
261
255
|
export type ReferenceDeletedSerializedDelta = {
|
|
@@ -263,7 +257,7 @@ export type ReferenceDeletedSerializedDelta = {
|
|
|
263
257
|
parent: LionWebId
|
|
264
258
|
reference: LionWebJsonMetaPointer
|
|
265
259
|
index: number
|
|
266
|
-
deletedTarget:
|
|
260
|
+
deletedTarget: IdOrNull
|
|
267
261
|
}
|
|
268
262
|
|
|
269
263
|
export type ReferenceChangedSerializedDelta = {
|
|
@@ -271,71 +265,8 @@ export type ReferenceChangedSerializedDelta = {
|
|
|
271
265
|
parent: LionWebId
|
|
272
266
|
reference: LionWebJsonMetaPointer
|
|
273
267
|
index: number
|
|
274
|
-
newTarget:
|
|
275
|
-
oldTarget:
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
export type EntryMovedFromOtherReferenceSerializedDelta = {
|
|
279
|
-
kind: "EntryMovedFromOtherReference"
|
|
280
|
-
oldParent: LionWebId
|
|
281
|
-
oldReference: LionWebJsonMetaPointer
|
|
282
|
-
oldIndex: number
|
|
283
|
-
newParent: LionWebId
|
|
284
|
-
newReference: LionWebJsonMetaPointer
|
|
285
|
-
newIndex: number
|
|
286
|
-
movedTarget: IdOrUnresolved
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
export type EntryMovedFromOtherReferenceInSameParentSerializedDelta = {
|
|
290
|
-
kind: "EntryMovedFromOtherReferenceInSameParent"
|
|
291
|
-
parent: LionWebId
|
|
292
|
-
oldReference: LionWebJsonMetaPointer
|
|
293
|
-
oldIndex: number
|
|
294
|
-
newReference: LionWebJsonMetaPointer
|
|
295
|
-
newIndex: number
|
|
296
|
-
movedTarget: IdOrUnresolved
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
export type EntryMovedInSameReferenceSerializedDelta = {
|
|
300
|
-
kind: "EntryMovedInSameReference"
|
|
301
|
-
parent: LionWebId
|
|
302
|
-
reference: LionWebJsonMetaPointer
|
|
303
|
-
oldIndex: number
|
|
304
|
-
newIndex: number
|
|
305
|
-
movedTarget: IdOrUnresolved
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
export type EntryMovedAndReplacedFromOtherReferenceSerializedDelta = {
|
|
309
|
-
kind: "EntryMovedAndReplacedFromOtherReference"
|
|
310
|
-
newParent: LionWebId
|
|
311
|
-
newReference: LionWebJsonMetaPointer
|
|
312
|
-
newIndex: number
|
|
313
|
-
movedTarget: IdOrUnresolved
|
|
314
|
-
oldParent: LionWebId
|
|
315
|
-
oldReference: LionWebJsonMetaPointer
|
|
316
|
-
oldIndex: number
|
|
317
|
-
replacedTarget: IdOrUnresolved
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
export type EntryMovedAndReplacedFromOtherReferenceInSameParentSerializedDelta = {
|
|
321
|
-
kind: "EntryMovedAndReplacedFromOtherReferenceInSameParent"
|
|
322
|
-
parent: LionWebId
|
|
323
|
-
oldReference: LionWebJsonMetaPointer
|
|
324
|
-
oldIndex: number
|
|
325
|
-
newReference: LionWebJsonMetaPointer
|
|
326
|
-
newIndex: number
|
|
327
|
-
movedTarget: IdOrUnresolved
|
|
328
|
-
replacedTarget: IdOrUnresolved
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
export type EntryMovedAndReplacedInSameReferenceSerializedDelta = {
|
|
332
|
-
kind: "EntryMovedAndReplacedInSameReference"
|
|
333
|
-
parent: LionWebId
|
|
334
|
-
reference: LionWebJsonMetaPointer
|
|
335
|
-
oldIndex: number
|
|
336
|
-
newIndex: number
|
|
337
|
-
movedTarget: IdOrUnresolved
|
|
338
|
-
replacedTarget: IdOrUnresolved
|
|
268
|
+
newTarget: IdOrNull
|
|
269
|
+
oldTarget: IdOrNull
|
|
339
270
|
}
|
|
340
271
|
|
|
341
272
|
export type CompositeSerializedDelta = {
|
package/src/deltas/types.g.ts
CHANGED
|
@@ -280,81 +280,6 @@ export class ReferenceChangedDelta implements IDelta {
|
|
|
280
280
|
}
|
|
281
281
|
}
|
|
282
282
|
|
|
283
|
-
export class EntryMovedFromOtherReferenceDelta implements IDelta {
|
|
284
|
-
constructor(
|
|
285
|
-
public readonly oldParent: INodeBase,
|
|
286
|
-
public readonly oldReference: Reference,
|
|
287
|
-
public readonly oldIndex: number,
|
|
288
|
-
public readonly newParent: INodeBase,
|
|
289
|
-
public readonly newReference: Reference,
|
|
290
|
-
public readonly newIndex: number,
|
|
291
|
-
public readonly movedTarget: SingleRef<INodeBase>
|
|
292
|
-
) {
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
export class EntryMovedFromOtherReferenceInSameParentDelta implements IDelta {
|
|
297
|
-
constructor(
|
|
298
|
-
public readonly parent: INodeBase,
|
|
299
|
-
public readonly oldReference: Reference,
|
|
300
|
-
public readonly oldIndex: number,
|
|
301
|
-
public readonly newReference: Reference,
|
|
302
|
-
public readonly newIndex: number,
|
|
303
|
-
public readonly movedTarget: SingleRef<INodeBase>
|
|
304
|
-
) {
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
export class EntryMovedInSameReferenceDelta implements IDelta {
|
|
309
|
-
constructor(
|
|
310
|
-
public readonly parent: INodeBase,
|
|
311
|
-
public readonly reference: Reference,
|
|
312
|
-
public readonly oldIndex: number,
|
|
313
|
-
public readonly newIndex: number,
|
|
314
|
-
public readonly movedTarget: SingleRef<INodeBase>
|
|
315
|
-
) {
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
export class EntryMovedAndReplacedFromOtherReferenceDelta implements IDelta {
|
|
320
|
-
constructor(
|
|
321
|
-
public readonly newParent: INodeBase,
|
|
322
|
-
public readonly newReference: Reference,
|
|
323
|
-
public readonly newIndex: number,
|
|
324
|
-
public readonly movedTarget: SingleRef<INodeBase>,
|
|
325
|
-
public readonly oldParent: INodeBase,
|
|
326
|
-
public readonly oldReference: Reference,
|
|
327
|
-
public readonly oldIndex: number,
|
|
328
|
-
public readonly replacedTarget: SingleRef<INodeBase>
|
|
329
|
-
) {
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
export class EntryMovedAndReplacedFromOtherReferenceInSameParentDelta implements IDelta {
|
|
334
|
-
constructor(
|
|
335
|
-
public readonly parent: INodeBase,
|
|
336
|
-
public readonly oldReference: Reference,
|
|
337
|
-
public readonly oldIndex: number,
|
|
338
|
-
public readonly newReference: Reference,
|
|
339
|
-
public readonly newIndex: number,
|
|
340
|
-
public readonly movedTarget: SingleRef<INodeBase>,
|
|
341
|
-
public readonly replacedTarget: SingleRef<INodeBase>
|
|
342
|
-
) {
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
export class EntryMovedAndReplacedInSameReferenceDelta implements IDelta {
|
|
347
|
-
constructor(
|
|
348
|
-
public readonly parent: INodeBase,
|
|
349
|
-
public readonly reference: Reference,
|
|
350
|
-
public readonly oldIndex: number,
|
|
351
|
-
public readonly newIndex: number,
|
|
352
|
-
public readonly movedTarget: SingleRef<INodeBase>,
|
|
353
|
-
public readonly replacedTarget: SingleRef<INodeBase>
|
|
354
|
-
) {
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
|
|
358
283
|
export class CompositeDelta implements IDelta {
|
|
359
284
|
constructor(
|
|
360
285
|
public readonly parts: IDelta[]
|
package/src/deserializer.ts
CHANGED
|
@@ -18,21 +18,21 @@
|
|
|
18
18
|
import {
|
|
19
19
|
builtinPropertyValueDeserializer,
|
|
20
20
|
Classifier,
|
|
21
|
+
consoleProblemReporter,
|
|
21
22
|
Containment,
|
|
22
|
-
defaultSimplisticHandler,
|
|
23
23
|
Enumeration,
|
|
24
24
|
MemoisingSymbolTable,
|
|
25
25
|
PrimitiveType,
|
|
26
|
+
ProblemReporter,
|
|
26
27
|
Property,
|
|
27
28
|
PropertyValueDeserializer,
|
|
28
29
|
Reference,
|
|
29
|
-
|
|
30
|
-
unresolved
|
|
30
|
+
referenceToSet
|
|
31
31
|
} from "@lionweb/core"
|
|
32
32
|
import { LionWebId, LionWebJsonChunk, LionWebJsonNode } from "@lionweb/json"
|
|
33
33
|
import { byIdMap, keepDefineds } from "@lionweb/ts-utils"
|
|
34
34
|
|
|
35
|
-
import { DeltaReceiver, IdMapping, ILanguageBase, INodeBase
|
|
35
|
+
import { DeltaReceiver, FactoryConfiguration, IdMapping, ILanguageBase, INodeBase } from "./index.js"
|
|
36
36
|
import { combinedLanguageBaseLookupFor } from "./factory.js"
|
|
37
37
|
import { NodesToInstall } from "./linking.js"
|
|
38
38
|
|
|
@@ -62,8 +62,10 @@ export type RootsWithIdMapping = { roots: INodeBase[], idMapping: IdMapping };
|
|
|
62
62
|
export type DeserializerConfiguration = {
|
|
63
63
|
/** Default: {@link builtinPropertyValueDeserializer}. */
|
|
64
64
|
propertyValueDeserializer?: PropertyValueDeserializer,
|
|
65
|
-
/** Default: {@link
|
|
66
|
-
|
|
65
|
+
/** Default: {@link consoleProblemReporter}. */
|
|
66
|
+
problemReporter?: ProblemReporter
|
|
67
|
+
/** Legacy alias for {@link problemReporter}, kept for backward compatibility, and to be deprecated and removed later. */
|
|
68
|
+
problemsHandler?: ProblemReporter
|
|
67
69
|
};
|
|
68
70
|
|
|
69
71
|
|
|
@@ -79,9 +81,9 @@ function nodeBaseDeserializerWithIdMapping(languageBases: ILanguageBase[], recei
|
|
|
79
81
|
*/
|
|
80
82
|
function nodeBaseDeserializerWithIdMapping(configuration: FactoryConfiguration & DeserializerConfiguration): Deserializer<RootsWithIdMapping>;
|
|
81
83
|
function nodeBaseDeserializerWithIdMapping(languageBasesOrConfiguration: ILanguageBase[] | (FactoryConfiguration & DeserializerConfiguration), mayBeReceiveDelta?: DeltaReceiver): Deserializer<RootsWithIdMapping> {
|
|
82
|
-
const [languageBases, receiveDelta, propertyValueDeserializer,
|
|
83
|
-
? [languageBasesOrConfiguration, mayBeReceiveDelta, builtinPropertyValueDeserializer,
|
|
84
|
-
: [languageBasesOrConfiguration.languageBases, languageBasesOrConfiguration.receiveDelta, languageBasesOrConfiguration.propertyValueDeserializer ?? builtinPropertyValueDeserializer, languageBasesOrConfiguration.problemsHandler ??
|
|
84
|
+
const [languageBases, receiveDelta, propertyValueDeserializer, problemReporter] = Array.isArray(languageBasesOrConfiguration)
|
|
85
|
+
? [languageBasesOrConfiguration, mayBeReceiveDelta, builtinPropertyValueDeserializer, consoleProblemReporter]
|
|
86
|
+
: [languageBasesOrConfiguration.languageBases, languageBasesOrConfiguration.receiveDelta, languageBasesOrConfiguration.propertyValueDeserializer ?? builtinPropertyValueDeserializer, languageBasesOrConfiguration.problemReporter ?? languageBasesOrConfiguration.problemsHandler ?? consoleProblemReporter];
|
|
85
87
|
|
|
86
88
|
const symbolTable = new MemoisingSymbolTable(languageBases.map(({language}) => language));
|
|
87
89
|
const languageBaseFor = combinedLanguageBaseLookupFor(languageBases);
|
|
@@ -97,7 +99,7 @@ function nodeBaseDeserializerWithIdMapping(languageBasesOrConfiguration: ILangua
|
|
|
97
99
|
const languageMessage = `language ${classifierMetaPointer.language} (${classifierMetaPointer.version})`;
|
|
98
100
|
const classifier = symbolTable.entityMatching(classifierMetaPointer);
|
|
99
101
|
if (classifier === undefined || !(classifier instanceof Classifier)) {
|
|
100
|
-
|
|
102
|
+
problemReporter.reportProblem(`can't deserialize node with id=${id}: can't find the classifier with key ${classifierMetaPointer.key} in ${languageMessage} - skipping`);
|
|
101
103
|
return undefined;
|
|
102
104
|
}
|
|
103
105
|
|
|
@@ -106,7 +108,7 @@ function nodeBaseDeserializerWithIdMapping(languageBasesOrConfiguration: ILangua
|
|
|
106
108
|
properties.forEach(({property: propertyMetaPointer, value}) => {
|
|
107
109
|
const feature = symbolTable.featureMatching(classifierMetaPointer, propertyMetaPointer);
|
|
108
110
|
if (feature === undefined) {
|
|
109
|
-
|
|
111
|
+
problemReporter.reportProblem(`can't deserialize value for feature with key ${propertyMetaPointer.key} in ${languageMessage}: feature not found on classifier ${classifierMetaPointer.key} in language (${classifierMetaPointer.language}, ${classifierMetaPointer.version}) - skipping`);
|
|
110
112
|
} else if (feature instanceof Property) {
|
|
111
113
|
if (feature.type instanceof PrimitiveType) {
|
|
112
114
|
node.getPropertyValueManager(feature).setDirectly(value === null ? undefined : propertyValueDeserializer.deserializeValue(value, feature));
|
|
@@ -114,32 +116,32 @@ function nodeBaseDeserializerWithIdMapping(languageBasesOrConfiguration: ILangua
|
|
|
114
116
|
if (value !== undefined) {
|
|
115
117
|
const literal = feature.type.literals.find((literal) => literal.key === value);
|
|
116
118
|
if (literal === undefined) {
|
|
117
|
-
|
|
119
|
+
problemReporter.reportProblem(`can't deserialize literal encoded as: ${value}`);
|
|
118
120
|
} else {
|
|
119
121
|
node.getPropertyValueManager(feature).setDirectly(languageBaseFor(feature.type.language).enumLiteralFrom(literal));
|
|
120
122
|
}
|
|
121
123
|
}
|
|
122
124
|
}
|
|
123
125
|
} else {
|
|
124
|
-
|
|
126
|
+
problemReporter.reportProblem(`can't deserialize value for feature with key ${propertyMetaPointer.key} in ${languageMessage}: feature is not a property - skipping`);
|
|
125
127
|
}
|
|
126
128
|
});
|
|
127
129
|
|
|
128
130
|
containments.forEach(({containment: containmentMetaPointer, children}) => {
|
|
129
131
|
const feature = symbolTable.featureMatching(classifierMetaPointer, containmentMetaPointer);
|
|
130
132
|
if (feature === undefined) {
|
|
131
|
-
|
|
133
|
+
problemReporter.reportProblem(`can't deserialize value for feature with key ${containmentMetaPointer.key} in ${languageMessage}: feature not found on classifier ${classifierMetaPointer.key} in language (${classifierMetaPointer.language}, ${classifierMetaPointer.version}) - skipping`);
|
|
132
134
|
} else if (feature instanceof Containment) {
|
|
133
135
|
nodesToInstall.push([node, feature, children]);
|
|
134
136
|
} else {
|
|
135
|
-
|
|
137
|
+
problemReporter.reportProblem(`can't deserialize value for feature with key ${containmentMetaPointer.key} in ${languageMessage}: feature is not a containment - skipping`);
|
|
136
138
|
}
|
|
137
139
|
});
|
|
138
140
|
|
|
139
141
|
references.forEach(({reference: referenceMetaPointer, targets}) => {
|
|
140
142
|
const feature = symbolTable.featureMatching(classifierMetaPointer, referenceMetaPointer);
|
|
141
143
|
if (feature === undefined) {
|
|
142
|
-
|
|
144
|
+
problemReporter.reportProblem(`can't deserialize value for feature with key ${referenceMetaPointer.key} in ${languageMessage}: feature not found on classifier ${classifierMetaPointer.key} in language (${classifierMetaPointer.language}, ${classifierMetaPointer.version}) - skipping`);
|
|
143
145
|
} else if (feature instanceof Reference) {
|
|
144
146
|
nodesToInstall.push(
|
|
145
147
|
[
|
|
@@ -152,7 +154,7 @@ function nodeBaseDeserializerWithIdMapping(languageBasesOrConfiguration: ILangua
|
|
|
152
154
|
]
|
|
153
155
|
);
|
|
154
156
|
} else {
|
|
155
|
-
|
|
157
|
+
problemReporter.reportProblem(`can't deserialize value for feature with key ${referenceMetaPointer.key} in ${languageMessage}: feature is not a reference - skipping`);
|
|
156
158
|
}
|
|
157
159
|
});
|
|
158
160
|
|
|
@@ -180,7 +182,7 @@ function nodeBaseDeserializerWithIdMapping(languageBasesOrConfiguration: ILangua
|
|
|
180
182
|
ids.forEach((id) => {
|
|
181
183
|
const nodeToInstall = lookupNodeById(id);
|
|
182
184
|
if (nodeToInstall === undefined) {
|
|
183
|
-
|
|
185
|
+
problemReporter.reportProblem(`couldn't resolve the child with id=${id} of the "${feature.name}" containment feature on the node with id=${node.id}`);
|
|
184
186
|
} else {
|
|
185
187
|
valueManager.addDirectly(nodeToInstall);
|
|
186
188
|
nodeToInstall.attachTo(node, feature);
|
|
@@ -193,8 +195,8 @@ function nodeBaseDeserializerWithIdMapping(languageBasesOrConfiguration: ILangua
|
|
|
193
195
|
ids.forEach((id) => {
|
|
194
196
|
const nodeToInstall = lookupNodeById(id);
|
|
195
197
|
if (nodeToInstall === undefined) {
|
|
196
|
-
|
|
197
|
-
valueManager.addDirectly(
|
|
198
|
+
problemReporter.reportProblem(`couldn't resolve the target with id=${id} of the "${feature.name}" reference feature on the node with id=${node.id}`);
|
|
199
|
+
valueManager.addDirectly(referenceToSet());
|
|
198
200
|
} else {
|
|
199
201
|
valueManager.addDirectly(nodeToInstall);
|
|
200
202
|
}
|
|
@@ -206,7 +208,7 @@ function nodeBaseDeserializerWithIdMapping(languageBasesOrConfiguration: ILangua
|
|
|
206
208
|
ids.forEach((id) => {
|
|
207
209
|
const nodeToInstall = lookupNodeById(id);
|
|
208
210
|
if (nodeToInstall === undefined) {
|
|
209
|
-
|
|
211
|
+
problemReporter.reportProblem(`couldn't resolve the annotation with id=${id} on the node with id=${node.id}`);
|
|
210
212
|
} else {
|
|
211
213
|
valueManager.addDirectly(nodeToInstall);
|
|
212
214
|
nodeToInstall.attachTo(node, feature);
|
package/src/duplicator.ts
CHANGED
|
@@ -15,7 +15,17 @@
|
|
|
15
15
|
// SPDX-FileCopyrightText: 2025 TRUMPF Laser SE and other contributors
|
|
16
16
|
// SPDX-License-Identifier: Apache-2.0
|
|
17
17
|
|
|
18
|
-
import {
|
|
18
|
+
import {
|
|
19
|
+
Containment,
|
|
20
|
+
Feature,
|
|
21
|
+
idOf,
|
|
22
|
+
isUnresolvedReference,
|
|
23
|
+
Link,
|
|
24
|
+
MultiRef,
|
|
25
|
+
Property,
|
|
26
|
+
Reference,
|
|
27
|
+
SingleRef
|
|
28
|
+
} from "@lionweb/core"
|
|
19
29
|
import { LionWebId } from "@lionweb/json"
|
|
20
30
|
import { asArray } from "@lionweb/ts-utils"
|
|
21
31
|
|
|
@@ -55,7 +65,7 @@ export const deepDuplicateWith = (duplicateNode: NodeDuplicator): Duplicator =>
|
|
|
55
65
|
duplicatedNode.getPropertyValueManager(feature).setDirectly(value);
|
|
56
66
|
} else if (feature instanceof Link) {
|
|
57
67
|
const values = asArray(value as (MultiRef<INodeBase> | SingleRef<INodeBase>));
|
|
58
|
-
const resolvedValues = values.filter((value) => value
|
|
68
|
+
const resolvedValues = values.filter((value) => !isUnresolvedReference(value)) as INodeBase[];
|
|
59
69
|
if (resolvedValues.length > 0) {
|
|
60
70
|
nodesToInstall.push([
|
|
61
71
|
duplicatedNode,
|
package/src/id-mapping.ts
CHANGED
|
@@ -15,11 +15,11 @@
|
|
|
15
15
|
// SPDX-FileCopyrightText: 2025 TRUMPF Laser SE and other contributors
|
|
16
16
|
// SPDX-License-Identifier: Apache-2.0
|
|
17
17
|
|
|
18
|
-
import {
|
|
18
|
+
import { referenceToSet, SingleRef } from "@lionweb/core"
|
|
19
19
|
import { LionWebId } from "@lionweb/json"
|
|
20
20
|
|
|
21
21
|
import { INodeBase } from "./base-types.js"
|
|
22
|
-
import {
|
|
22
|
+
import { IdOrNull } from "./references.js"
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
/**
|
|
@@ -63,10 +63,10 @@ export class IdMapping {
|
|
|
63
63
|
* @return the {@link INodeBase node} referenced from the given {@link LionWebId ID},
|
|
64
64
|
* or `unresolved` if `unresolved` was passed in or no node with the given ID was registered.
|
|
65
65
|
*/
|
|
66
|
-
fromRefId = (
|
|
67
|
-
|
|
68
|
-
?
|
|
69
|
-
: (this.nodesById[
|
|
66
|
+
fromRefId = (idOrNull: IdOrNull): SingleRef<INodeBase> =>
|
|
67
|
+
idOrNull === null
|
|
68
|
+
? referenceToSet()
|
|
69
|
+
: (this.nodesById[idOrNull] ?? referenceToSet());
|
|
70
70
|
|
|
71
71
|
/**
|
|
72
72
|
* Updates this {@link IdMapping} with the given `node` *and all its descendants* (recursively).
|
package/src/index.ts
CHANGED
|
@@ -25,9 +25,9 @@ export { Forest, ObservableForest } from "./forest.js";
|
|
|
25
25
|
export * from "./id-mapping.js";
|
|
26
26
|
// skip linking.js: see comment there
|
|
27
27
|
export * from "./LionCore_builtins.g.js";
|
|
28
|
-
export type {
|
|
28
|
+
export type { IdOrNull } from "./references.js";
|
|
29
29
|
export { idFrom } from "./references.js";
|
|
30
|
-
export { propertyValueSerializerWith, serializeNodeBases } from "./serializer.js";
|
|
30
|
+
export { nodeBaseReader, propertyValueSerializerWith, serializeNodeBases } from "./serializer.js";
|
|
31
31
|
export { asTreeTextWith } from "./textualizer.js";
|
|
32
32
|
export * from "./value-managers/index.js";
|
|
33
33
|
|
package/src/references.ts
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
// SPDX-FileCopyrightText: 2025 TRUMPF Laser SE and other contributors
|
|
16
16
|
// SPDX-License-Identifier: Apache-2.0
|
|
17
17
|
|
|
18
|
-
import {
|
|
18
|
+
import { isUnresolvedReference, SingleRef } from "@lionweb/core"
|
|
19
19
|
import { LionWebId } from "@lionweb/json"
|
|
20
20
|
|
|
21
21
|
import { INodeBase } from "./base-types.js"
|
|
@@ -24,12 +24,12 @@ import { INodeBase } from "./base-types.js"
|
|
|
24
24
|
/**
|
|
25
25
|
* A type that expresses a value is either an {@link LionWebId} or a value to indicate that resolution to a node previously failed.
|
|
26
26
|
*/
|
|
27
|
-
export type
|
|
27
|
+
export type IdOrNull = LionWebId | null
|
|
28
28
|
|
|
29
29
|
|
|
30
30
|
/**
|
|
31
|
-
* @return the ID of a given reference to a {@link INodeBase}, or
|
|
31
|
+
* @return the ID of a given reference to a {@link INodeBase}, or `null` if that reference was previously unresolved.
|
|
32
32
|
*/
|
|
33
|
-
export const idFrom = (ref: SingleRef<INodeBase>):
|
|
34
|
-
ref
|
|
33
|
+
export const idFrom = (ref: SingleRef<INodeBase>): IdOrNull =>
|
|
34
|
+
isUnresolvedReference(ref) ? null : ref.id
|
|
35
35
|
|