@lionweb/core 0.7.0-alpha.1 → 0.7.0-alpha.10

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.
Files changed (65) hide show
  1. package/CHANGELOG.md +22 -5
  2. package/dist/deserializer.d.ts +15 -6
  3. package/dist/deserializer.d.ts.map +1 -1
  4. package/dist/deserializer.js +13 -13
  5. package/dist/deserializer.js.map +1 -1
  6. package/dist/dynamic-facade.d.ts +14 -5
  7. package/dist/dynamic-facade.d.ts.map +1 -1
  8. package/dist/dynamic-facade.js +13 -5
  9. package/dist/dynamic-facade.js.map +1 -1
  10. package/dist/extraction.d.ts +15 -0
  11. package/dist/extraction.d.ts.map +1 -0
  12. package/dist/extraction.js +17 -0
  13. package/dist/extraction.js.map +1 -0
  14. package/dist/index.d.ts +4 -2
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +4 -2
  17. package/dist/index.js.map +1 -1
  18. package/dist/m1/reference-utils.d.ts +7 -7
  19. package/dist/m1/reference-utils.d.ts.map +1 -1
  20. package/dist/m1/reference-utils.js +10 -10
  21. package/dist/m1/reference-utils.js.map +1 -1
  22. package/dist/m3/builtins.d.ts +38 -17
  23. package/dist/m3/builtins.d.ts.map +1 -1
  24. package/dist/m3/builtins.js +53 -28
  25. package/dist/m3/builtins.js.map +1 -1
  26. package/dist/m3/constraints.js +2 -2
  27. package/dist/m3/constraints.js.map +1 -1
  28. package/dist/m3/deserializer.js +4 -4
  29. package/dist/m3/deserializer.js.map +1 -1
  30. package/dist/m3/facade.d.ts +13 -4
  31. package/dist/m3/facade.d.ts.map +1 -1
  32. package/dist/m3/facade.js +12 -4
  33. package/dist/m3/facade.js.map +1 -1
  34. package/dist/m3/functions.d.ts +20 -4
  35. package/dist/m3/functions.d.ts.map +1 -1
  36. package/dist/m3/functions.js +21 -5
  37. package/dist/m3/functions.js.map +1 -1
  38. package/dist/m3/lioncore.js +7 -7
  39. package/dist/m3/serializer.d.ts.map +1 -1
  40. package/dist/m3/serializer.js +3 -3
  41. package/dist/m3/serializer.js.map +1 -1
  42. package/dist/m3/types.d.ts +12 -7
  43. package/dist/m3/types.d.ts.map +1 -1
  44. package/dist/m3/types.js +9 -4
  45. package/dist/m3/types.js.map +1 -1
  46. package/dist/reading.d.ts +45 -0
  47. package/dist/reading.d.ts.map +1 -0
  48. package/dist/reading.js +2 -0
  49. package/dist/reading.js.map +1 -0
  50. package/dist/serializer.d.ts +28 -7
  51. package/dist/serializer.d.ts.map +1 -1
  52. package/dist/serializer.js +108 -100
  53. package/dist/serializer.js.map +1 -1
  54. package/dist/symbol-table.d.ts.map +1 -1
  55. package/dist/symbol-table.js +1 -8
  56. package/dist/symbol-table.js.map +1 -1
  57. package/dist/writing.d.ts +49 -0
  58. package/dist/writing.d.ts.map +1 -0
  59. package/dist/writing.js +30 -0
  60. package/dist/writing.js.map +1 -0
  61. package/package.json +4 -4
  62. package/dist/facade.d.ts +0 -85
  63. package/dist/facade.d.ts.map +0 -1
  64. package/dist/facade.js +0 -42
  65. package/dist/facade.js.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lionweb/core",
3
- "version": "0.7.0-alpha.1",
3
+ "version": "0.7.0-alpha.10",
4
4
  "description": "LionWeb core for {Java|Type}Script",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -15,7 +15,7 @@
15
15
  "url": "https://github.com/LionWeb-io/lionweb-typescript/issues"
16
16
  },
17
17
  "scripts": {
18
- "clean": "rm -rf dist/ node_modules/ lionweb-core-*.tgz",
18
+ "clean": "npx rimraf dist node_modules -g lionweb-core-*.tgz",
19
19
  "build": "tsc",
20
20
  "lint": "eslint src",
21
21
  "prep:pre-release": "npm run clean && npm install && npm run build",
@@ -27,7 +27,7 @@
27
27
  "release": "npm publish"
28
28
  },
29
29
  "dependencies": {
30
- "@lionweb/json": "0.7.0-alpha.1",
31
- "@lionweb/ts-utils": "0.7.0-alpha.1"
30
+ "@lionweb/json": "0.7.0-alpha.10",
31
+ "@lionweb/ts-utils": "0.7.0-alpha.10"
32
32
  }
33
33
  }
package/dist/facade.d.ts DELETED
@@ -1,85 +0,0 @@
1
- import { LionWebId, LionWebKey } from "@lionweb/json";
2
- import { Classifier, Enumeration, EnumerationLiteral, Feature } from "./m3/types.js";
3
- import { Node } from "./types.js";
4
- /**
5
- * Type def. for functions that deduce the {@link Classifier classifier} of a given {@link Node node}.
6
- */
7
- type ClassifierDeducer<NT extends Node> = (node: NT) => Classifier;
8
- /**
9
- * Type def. for functions that deduce the string value of the `resolveInfo` field of a
10
- * {@link LionWebJsonReferenceTarget serialized reference target}, or {@code undefined}
11
- * to indicate that no `resolveInfo` could be derived.
12
- */
13
- type ResolveInfoDeducer<NT extends Node> = (node: NT) => string | undefined;
14
- /**
15
- * Two interfaces that defines façades for in-memory models.
16
- * Instances/implementations of this interface parametrize generic (de-)serialization.
17
- * Implementations of these interfaces {w|c}ould be:
18
- * - specific to Lioncore (so to match m3/types.ts)
19
- * - generic to deserialize into @link DynamicNode}
20
- */
21
- interface ExtractionFacade<NT extends Node> {
22
- /**
23
- * @return The {@link Concept concept} of the given node
24
- */
25
- classifierOf: ClassifierDeducer<NT>;
26
- /**
27
- * @return The value of the given {@link Feature feature} on the given node.
28
- */
29
- getFeatureValue: (node: NT, feature: Feature) => unknown;
30
- /**
31
- * @return The {@link EnumerationLiteral} corresponding to
32
- * the given {@link Enumeration} and the runtime encoding of a literal of it,
33
- */
34
- enumerationLiteralFrom: (encoding: unknown, enumeration: Enumeration) => EnumerationLiteral | null;
35
- /**
36
- * @return The string value of the `resolveInfo` field of a {@link LionWebJsonReferenceTarget serialized reference target},
37
- * or {@code undefined} to indicate that no `resolveInfo` could be derived.
38
- */
39
- resolveInfoFor?: ResolveInfoDeducer<NT>;
40
- }
41
- interface InstantiationFacade<NT extends Node, PNT extends Node = NT> {
42
- /**
43
- * @return An instance of the given concept, also given its parent (or {@link undefined} for root nodes),
44
- * its ID and the values of the node's properties ("settings").
45
- * (The latter may be required as arguments for the constructor of a class, whose instances represent nodes.)
46
- */
47
- nodeFor: (parent: PNT | undefined, classifier: Classifier, id: LionWebId, propertySettings: {
48
- [propertyKey: LionWebKey]: unknown;
49
- }) => NT;
50
- /**
51
- * Sets the *single* given value of the indicated {@link Feature} on the given node.
52
- * This means adding it in case the feature is multi-valued, meaning it is a {@link Link} with {@code multiple = true}.
53
- */
54
- setFeatureValue: (node: NT, feature: Feature, value: unknown) => void;
55
- /**
56
- * @return The runtime encoding of the given {@link EnumerationLiteral}.
57
- */
58
- encodingOf: (literal: EnumerationLiteral) => unknown;
59
- }
60
- /**
61
- * Type def. for functions that extract {@link Node nodes} from a given one.
62
- */
63
- type NodesExtractor<NT extends Node> = (node: NT) => NT[];
64
- /**
65
- * @return A function that extracts the children from a given node.
66
- */
67
- declare const childrenExtractorUsing: <NT extends Node>(extractionFacade: ExtractionFacade<NT>) => NodesExtractor<NT>;
68
- /**
69
- * @return a function that extracts *all* nodes from a given start node - usually a root node.
70
- */
71
- declare const nodesExtractorUsing: <NT extends Node>(extractionFacade: ExtractionFacade<NT>) => NodesExtractor<NT>;
72
- type SettingsUpdater = (settings: Record<string, unknown>, feature: Feature, value: unknown) => void;
73
- /**
74
- * Updates the value of the given {@link Feature feature} on the given "settings" object
75
- * (either a {@link Node node} or a sub object of it), using the feature's *name*.
76
- */
77
- declare const updateSettingsNameBased: SettingsUpdater;
78
- /**
79
- * Updates the value of the given {@link Feature feature} on the given "settings" object
80
- * (either a {@link Node node} or a sub object of it), using the feature's *key*.
81
- */
82
- declare const updateSettingsKeyBased: SettingsUpdater;
83
- export type { ClassifierDeducer, ExtractionFacade, InstantiationFacade, NodesExtractor, ResolveInfoDeducer };
84
- export { childrenExtractorUsing, nodesExtractorUsing, updateSettingsKeyBased, updateSettingsNameBased };
85
- //# sourceMappingURL=facade.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"facade.d.ts","sourceRoot":"","sources":["../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AAO,EAAE,KAAK,EAAE,OAAO,KAAK,IAAI,CAAA;IAGrE;;OAEG;IACH,UAAU,EAAE,CAAC,OAAO,EAAE,kBAAkB,KAAK,OAAO,CAAA;CAEvD;AAED;;GAEG;AACH,KAAK,cAAc,CAAC,EAAE,SAAS,IAAI,IAAI,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,EAAE,CAAA;AAEzD;;GAEG;AACH,QAAA,MAAM,sBAAsB,iFAOf,CAAA;AAGb;;GAEG;AACH,QAAA,MAAM,mBAAmB,iFACsE,CAAA;AAG/F,KAAK,eAAe,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,KAAK,IAAI,CAAA;AAiBpG;;;GAGG;AACH,QAAA,MAAM,uBAAuB,EAAE,eAAyC,CAAA;AAExE;;;GAGG;AACH,QAAA,MAAM,sBAAsB,iBAAyB,CAAA;AAErD,YAAY,EACR,iBAAiB,EACjB,gBAAgB,EAChB,mBAAmB,EACnB,cAAc,EACd,kBAAkB,EACrB,CAAA;AAED,OAAO,EACH,sBAAsB,EACtB,mBAAmB,EACnB,sBAAsB,EACtB,uBAAuB,EAC1B,CAAA"}
package/dist/facade.js DELETED
@@ -1,42 +0,0 @@
1
- import { flatMapNonCyclingFollowing, trivialFlatMapper } from "@lionweb/ts-utils";
2
- import { allFeaturesOf, isContainment } from "./m3/functions.js";
3
- import { Link } from "./m3/types.js";
4
- /**
5
- * @return A function that extracts the children from a given node.
6
- */
7
- const childrenExtractorUsing = (extractionFacade) => (node) => [
8
- ...(allFeaturesOf(extractionFacade.classifierOf(node))
9
- .filter(isContainment)
10
- .flatMap((containment) => extractionFacade.getFeatureValue(node, containment) ?? [])),
11
- // FIXME there's NO guarantee about the result of extractionFacade.getFeatureValue(node, containment) !!!
12
- ...node.annotations
13
- ];
14
- /**
15
- * @return a function that extracts *all* nodes from a given start node - usually a root node.
16
- */
17
- const nodesExtractorUsing = (extractionFacade) => flatMapNonCyclingFollowing(trivialFlatMapper, childrenExtractorUsing(extractionFacade));
18
- const settingsUpdater = (metaKey) => (settings, feature, value) => {
19
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
20
- const key = feature[metaKey];
21
- if (feature instanceof Link && feature.multiple) {
22
- if (!Array.isArray(settings[key])) {
23
- settings[key] = [];
24
- }
25
- settings[key].push(value);
26
- }
27
- else {
28
- settings[key] = value;
29
- }
30
- };
31
- /**
32
- * Updates the value of the given {@link Feature feature} on the given "settings" object
33
- * (either a {@link Node node} or a sub object of it), using the feature's *name*.
34
- */
35
- const updateSettingsNameBased = settingsUpdater("name");
36
- /**
37
- * Updates the value of the given {@link Feature feature} on the given "settings" object
38
- * (either a {@link Node node} or a sub object of it), using the feature's *key*.
39
- */
40
- const updateSettingsKeyBased = settingsUpdater("key");
41
- export { childrenExtractorUsing, nodesExtractorUsing, updateSettingsKeyBased, updateSettingsNameBased };
42
- //# sourceMappingURL=facade.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"facade.js","sourceRoot":"","sources":["../src/facade.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,0BAA0B,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AACjF,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAChE,OAAO,EAAwD,IAAI,EAAE,MAAM,eAAe,CAAA;AAkF1F;;GAEG;AACH,MAAM,sBAAsB,GAAG,CAAkB,gBAAsC,EAAsB,EAAE,CAC3G,CAAC,IAAQ,EAAQ,EAAE,CAAC;IAChB,GAAG,CAAC,aAAa,CAAC,gBAAgB,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;SACjD,MAAM,CAAC,aAAa,CAAC;SACrB,OAAO,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,gBAAgB,CAAC,eAAe,CAAC,IAAI,EAAE,WAAW,CAAC,IAAI,EAAE,CAAC,CAAC;IACjG,0GAA0G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