@lionweb/class-core-generator 0.6.13-beta.7 → 0.7.0-alpha.1

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 (82) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/dist/api/entity-types.templates.d.ts +3 -2
  3. package/dist/api/entity-types.templates.d.ts.map +1 -1
  4. package/dist/api/entity-types.templates.js +2 -2
  5. package/dist/api/entity-types.templates.js.map +1 -1
  6. package/dist/api/generation-headers.js.map +1 -1
  7. package/dist/api/generator.d.ts.map +1 -1
  8. package/dist/api/generator.js.map +1 -1
  9. package/dist/api/helpers/classifiers.d.ts.map +1 -1
  10. package/dist/api/helpers/classifiers.js +1 -1
  11. package/dist/api/helpers/classifiers.js.map +1 -1
  12. package/dist/api/helpers/dependencies.d.ts.map +1 -1
  13. package/dist/api/helpers/dependencies.js +2 -2
  14. package/dist/api/helpers/dependencies.js.map +1 -1
  15. package/dist/api/helpers/entities.d.ts.map +1 -1
  16. package/dist/api/helpers/entities.js.map +1 -1
  17. package/dist/api/helpers/features.d.ts.map +1 -1
  18. package/dist/api/helpers/features.js +3 -3
  19. package/dist/api/helpers/features.js.map +1 -1
  20. package/dist/api/helpers/imports-tracking.d.ts +3 -0
  21. package/dist/api/helpers/imports-tracking.d.ts.map +1 -1
  22. package/dist/api/helpers/imports-tracking.js +8 -0
  23. package/dist/api/helpers/imports-tracking.js.map +1 -1
  24. package/dist/api/helpers/index.d.ts +1 -1
  25. package/dist/api/helpers/index.d.ts.map +1 -1
  26. package/dist/api/helpers/index.js +1 -1
  27. package/dist/api/helpers/index.js.map +1 -1
  28. package/dist/api/helpers/mps-annotations.d.ts +6 -6
  29. package/dist/api/helpers/mps-annotations.d.ts.map +1 -1
  30. package/dist/api/helpers/mps-annotations.js.map +1 -1
  31. package/dist/api/helpers/{types.d.ts → primitive-types.d.ts} +1 -1
  32. package/dist/api/helpers/primitive-types.d.ts.map +1 -0
  33. package/dist/api/helpers/{types.js → primitive-types.js} +9 -5
  34. package/dist/api/helpers/primitive-types.js.map +1 -0
  35. package/dist/api/index-ts.d.ts.map +1 -1
  36. package/dist/api/index-ts.js +5 -6
  37. package/dist/api/index-ts.js.map +1 -1
  38. package/dist/api/language-file.templates.d.ts.map +1 -1
  39. package/dist/api/language-file.templates.js +7 -11
  40. package/dist/api/language-file.templates.js.map +1 -1
  41. package/dist/api/mega-factory.templates.d.ts.map +1 -1
  42. package/dist/api/mega-factory.templates.js +4 -7
  43. package/dist/api/mega-factory.templates.js.map +1 -1
  44. package/dist/api/reflective-layer.templates.d.ts.map +1 -1
  45. package/dist/api/reflective-layer.templates.js +19 -34
  46. package/dist/api/reflective-layer.templates.js.map +1 -1
  47. package/dist/utils/index.d.ts +0 -1
  48. package/dist/utils/index.d.ts.map +1 -1
  49. package/dist/utils/index.js +0 -1
  50. package/dist/utils/index.js.map +1 -1
  51. package/dist/utils/textgen.d.ts.map +1 -1
  52. package/dist/utils/textgen.js.map +1 -1
  53. package/package.json +13 -9
  54. package/src/api/entity-types.templates.ts +6 -7
  55. package/src/api/generation-headers.ts +1 -1
  56. package/src/api/generator.ts +10 -10
  57. package/src/api/helpers/classifiers.ts +3 -15
  58. package/src/api/helpers/dependencies.ts +4 -4
  59. package/src/api/helpers/entities.ts +2 -8
  60. package/src/api/helpers/features.ts +5 -5
  61. package/src/api/helpers/imports-tracking.ts +12 -5
  62. package/src/api/helpers/index.ts +1 -1
  63. package/src/api/helpers/mps-annotations.ts +6 -8
  64. package/src/api/helpers/{types.ts → primitive-types.ts} +9 -6
  65. package/src/api/index-ts.ts +26 -16
  66. package/src/api/language-file.templates.ts +11 -16
  67. package/src/api/mega-factory.templates.ts +20 -26
  68. package/src/api/reflective-layer.templates.ts +46 -69
  69. package/src/utils/index.ts +0 -1
  70. package/src/utils/textgen.ts +1 -1
  71. package/dist/api/helpers/types.d.ts.map +0 -1
  72. package/dist/api/helpers/types.js.map +0 -1
  73. package/dist/utils/string-sorting.d.ts +0 -4
  74. package/dist/utils/string-sorting.d.ts.map +0 -1
  75. package/dist/utils/string-sorting.js +0 -23
  76. package/dist/utils/string-sorting.js.map +0 -1
  77. package/dist/utils/toposort.d.ts +0 -6
  78. package/dist/utils/toposort.d.ts.map +0 -1
  79. package/dist/utils/toposort.js +0 -41
  80. package/dist/utils/toposort.js.map +0 -1
  81. package/src/utils/string-sorting.ts +0 -29
  82. package/src/utils/toposort.ts +0 -49
@@ -15,25 +15,19 @@
15
15
  // SPDX-FileCopyrightText: 2025 TRUMPF Laser SE and other contributors
16
16
  // SPDX-License-Identifier: Apache-2.0
17
17
 
18
- import {Concept, groupBy, Language} from "@lionweb/core"
19
- import {asString, commaSeparated, when, withNewlineAppended} from "littoral-templates"
20
-
21
- import {typeForLanguageEntity} from "./entity-types.templates.js"
22
- import {reflectiveClassFor} from "./reflective-layer.templates.js"
23
- import {indent} from "../utils/textgen.js"
24
- import {sortedStringsByUppercase} from "../utils/string-sorting.js"
25
- import {dependencyOrderOf} from "../utils/toposort.js"
26
- import {Imports} from "./helpers/index.js"
27
- import {GeneratorOptions} from "./generator.js"
18
+ import { sortedStringsByUppercase } from "@lionweb/ts-utils"
19
+ import { Concept, Language } from "@lionweb/core"
20
+ import { dependencyOrderOf, groupBy } from "@lionweb/ts-utils"
21
+ import { asString, commaSeparated, when, withNewlineAppended } from "littoral-templates"
22
+ import { indent } from "../utils/textgen.js"
28
23
 
24
+ import { typeForLanguageEntity } from "./entity-types.templates.js"
25
+ import { GeneratorOptions } from "./generator.js"
26
+ import { Imports } from "./helpers/index.js"
27
+ import { reflectiveClassFor } from "./reflective-layer.templates.js"
29
28
 
30
29
  const importStatement = (dep: string, items: string[]) =>
31
- when(items.length > 0)([
32
- `import {`,
33
- indent(commaSeparated(sortedStringsByUppercase(items))),
34
- `} from "${dep}";`,
35
- ``
36
- ])
30
+ when(items.length > 0)([`import {`, indent(commaSeparated(sortedStringsByUppercase(items))), `} from "${dep}";`, ``])
37
31
 
38
32
 
39
33
  export const languageFileFor = (language: Language, options: GeneratorOptions) => {
@@ -71,6 +65,7 @@ export const languageFileFor = (language: Language, options: GeneratorOptions) =
71
65
  ``,
72
66
  ``,
73
67
  importStatement(`@lionweb/core`, imports.coreImports),
68
+ importStatement(`@lionweb/json`, imports.jsonImports),
74
69
  importStatement(options.genericImportLocation, imports.genericImports),
75
70
  importStatement(`./index.g.js`, imports.languageImports),
76
71
  postImportsPart
@@ -15,46 +15,42 @@
15
15
  // SPDX-FileCopyrightText: 2025 TRUMPF Laser SE and other contributors
16
16
  // SPDX-License-Identifier: Apache-2.0
17
17
 
18
- import {isConcrete, Language, LanguageEntity} from "@lionweb/core"
19
- import {asString, commaSeparated} from "littoral-templates"
20
-
21
- import {asJSIdentifier, indent} from "../utils/textgen.js"
22
- import {Deprecated, MpsAnnotation} from "./helpers/index.js";
18
+ import { isConcrete, Language, LanguageEntity } from "@lionweb/core"
19
+ import { asString, commaSeparated } from "littoral-templates"
23
20
 
21
+ import { asJSIdentifier, indent } from "../utils/textgen.js"
22
+ import { Deprecated, MpsAnnotation } from "./helpers/index.js"
24
23
 
25
24
  export const megaFactoryFor = (megaFactoryName: string, languages: Language[], mpsAnnotations: MpsAnnotation[] = [], header?: string) => {
26
- const isNotDeprecated = (entity: LanguageEntity)=>
27
- !mpsAnnotations.some(
28
- (mpsAnnotation) => mpsAnnotation.annotatedNodeId === entity.id && mpsAnnotation instanceof Deprecated
29
- )
25
+ const isNotDeprecated = (entity: LanguageEntity) =>
26
+ !mpsAnnotations.some(mpsAnnotation => mpsAnnotation.annotatedNodeId === entity.id && mpsAnnotation instanceof Deprecated)
30
27
 
31
- const requiresFactoryMethod = (entity: LanguageEntity) =>
32
- isConcrete(entity) && isNotDeprecated(entity)
28
+ const requiresFactoryMethod = (entity: LanguageEntity) => isConcrete(entity) && isNotDeprecated(entity)
33
29
 
34
30
  const factoryFor = (language: Language) => [
35
31
  `${asJSIdentifier(language.name)}Factory = {`,
36
- indent(commaSeparated(
37
- language.entities
38
- .filter(requiresFactoryMethod)
39
- .map((classifier) => `create${classifier.name}: () => ${asJSIdentifier(language.name)}.${classifier.name}.create(newId(), this.handleDelta)`)
40
- )),
32
+ indent(
33
+ commaSeparated(
34
+ language.entities
35
+ .filter(requiresFactoryMethod)
36
+ .map(
37
+ classifier =>
38
+ `create${classifier.name}: () => ${asJSIdentifier(language.name)}.${classifier.name}.create(newId(), this.handleDelta)`
39
+ )
40
+ )
41
+ ),
41
42
  `}`,
42
43
  ``
43
44
  ]
44
45
 
45
- const languagesWithFactoryMethods = languages
46
- .filter(
47
- (language) => language.entities.some(requiresFactoryMethod)
48
- )
46
+ const languagesWithFactoryMethods = languages.filter(language => language.entities.some(requiresFactoryMethod))
49
47
 
50
48
  return asString([
51
49
  header ?? [],
52
50
  `import {DeltaHandler} from "@lionweb/class-core";`,
53
51
  ``,
54
52
  `import {`,
55
- indent(commaSeparated(
56
- languagesWithFactoryMethods.map(({name}) => asJSIdentifier(name))
57
- )),
53
+ indent(commaSeparated(languagesWithFactoryMethods.map(({ name }) => asJSIdentifier(name)))),
58
54
  `} from "./index.g.js";`,
59
55
  ``,
60
56
  `import {newId} from "../index.js";`,
@@ -64,9 +60,7 @@ export const megaFactoryFor = (megaFactoryName: string, languages: Language[], m
64
60
  indent([
65
61
  ``,
66
62
  `constructor(`,
67
- indent([
68
- `public readonly handleDelta?: DeltaHandler`
69
- ]),
63
+ indent([`public readonly handleDelta?: DeltaHandler`]),
70
64
  `) {`,
71
65
  `}`,
72
66
  ``,
@@ -17,7 +17,6 @@
17
17
 
18
18
  import {
19
19
  Annotation,
20
- asArray,
21
20
  Classifier,
22
21
  Concept,
23
22
  Enumeration,
@@ -36,90 +35,70 @@ import {
36
35
  Property,
37
36
  SingleRef
38
37
  } from "@lionweb/core"
39
- import {when, withNewlineAppended} from "littoral-templates"
40
-
41
- import {indent, switchOrIf} from "../utils/textgen.js"
42
- import {entityMetaType, extendsFrom, Imports, nameOfBaseClassForLanguage} from "./helpers/index.js"
38
+ import { asArray } from "@lionweb/ts-utils"
39
+ import { when, withNewlineAppended } from "littoral-templates"
43
40
 
41
+ import { indent, switchOrIf } from "../utils/textgen.js"
42
+ import { entityMetaType, extendsFrom, Imports, nameOfBaseClassForLanguage } from "./helpers/index.js"
44
43
 
45
44
  export const reflectiveClassFor = (imports: Imports) => {
46
-
47
45
  // classifier:
48
46
 
49
47
  const reflectiveMembersForFeature = (feature: Feature) => {
50
- const {classifier, name, key, id, optional} = feature
48
+ const { classifier, name, key, id, optional } = feature
51
49
  const metaType = featureMetaType(feature)
52
50
  const qName = `${classifier.name}_${name}`
53
51
  return [
54
52
  `private readonly _${qName} = new ${imports.core(metaType)}(this._${classifier.name}, "${name}", "${key}", "${id}")${optional ? ".isOptional()" : ""}${isMultiple(feature) ? ".isMultiple()" : ""};`,
55
53
  // | core (2nd x) |
56
54
  `get ${qName}(): ${metaType} {`,
57
- indent([
58
- `this.ensureWiredUp();`,
59
- `return this._${qName};`
60
- ]),
55
+ indent([`this.ensureWiredUp();`, `return this._${qName};`]),
61
56
  `}`
62
57
  ]
63
58
  }
64
59
 
65
60
  const reflectiveMembersForClassifier = (classifier: Classifier) => {
66
- const {name, key, id, features} = classifier
61
+ const { name, key, id, features } = classifier
67
62
  const metaType = entityMetaType(classifier)
68
63
  return [
69
- `public readonly _${name} = new ${imports.core(metaType)}(this._language, "${name}", "${key}", "${id}"${classifier instanceof Concept ? (", " + classifier.abstract) : ""});`,
64
+ `public readonly _${name} = new ${imports.core(metaType)}(this._language, "${name}", "${key}", "${id}"${classifier instanceof Concept ? ", " + classifier.abstract : ""});`,
70
65
  // | core (2nd x) |
71
66
  `get ${name}(): ${metaType} {`,
72
- indent([
73
- `this.ensureWiredUp();`,
74
- `return this._${name};`
75
- ]),
67
+ indent([`this.ensureWiredUp();`, `return this._${name};`]),
76
68
  `}`,
77
69
  features.map(reflectiveMembersForFeature)
78
70
  ]
79
71
  }
80
72
 
73
+ // enumeration:
81
74
 
82
- // enumeration:
83
-
84
- const reflectiveMemberForEnumerationLiteral = ({enumeration, name, key, id}: EnumerationLiteral) => {
75
+ const reflectiveMemberForEnumerationLiteral = ({ enumeration, name, key, id }: EnumerationLiteral) => {
85
76
  const qName = `${enumeration.name}_${name}`
86
77
  return [
87
78
  `private readonly _${qName} = new ${imports.core("EnumerationLiteral")}(this._${enumeration.name}, "${name}", "${key}", "${id}");`,
88
79
  // | core (2nd x) |
89
80
  `get ${qName}(): EnumerationLiteral {`,
90
- indent([
91
- `this.ensureWiredUp();`,
92
- `return this._${qName};`
93
- ]),
81
+ indent([`this.ensureWiredUp();`, `return this._${qName};`]),
94
82
  `}`
95
83
  ]
96
84
  }
97
85
 
98
- const reflectiveMembersForEnumeration = ({name, key, id, literals}: Enumeration) =>
99
- [
100
- `public readonly _${name} = new ${imports.core("Enumeration")}(this._language, "${name}", "${key}", "${id}");`,
101
- // | core (2nd x) |
102
- `get ${name}(): Enumeration {`,
103
- indent([
104
- `this.ensureWiredUp();`,
105
- `return this._${name};`
106
- ]),
107
- `}`,
108
- literals.map(reflectiveMemberForEnumerationLiteral)
109
- ]
110
-
111
- const reflectiveMembersForPrimitiveType = ({name, key, id}: PrimitiveType) =>
112
- [
113
- `public readonly _${name} = new ${imports.core("PrimitiveType")}(this._language, "${name}", "${key}", "${id}");`,
114
- // | core (2nd x) |
115
- `get ${name}(): PrimitiveType {`,
116
- indent([
117
- `this.ensureWiredUp();`,
118
- `return this._${name};`
119
- ]),
120
- `}`
121
- ]
122
-
86
+ const reflectiveMembersForEnumeration = ({ name, key, id, literals }: Enumeration) => [
87
+ `public readonly _${name} = new ${imports.core("Enumeration")}(this._language, "${name}", "${key}", "${id}");`,
88
+ // | core (2nd x) |
89
+ `get ${name}(): Enumeration {`,
90
+ indent([`this.ensureWiredUp();`, `return this._${name};`]),
91
+ `}`,
92
+ literals.map(reflectiveMemberForEnumerationLiteral)
93
+ ]
94
+
95
+ const reflectiveMembersForPrimitiveType = ({ name, key, id }: PrimitiveType) => [
96
+ `public readonly _${name} = new ${imports.core("PrimitiveType")}(this._language, "${name}", "${key}", "${id}");`,
97
+ // | core (2nd x) |
98
+ `get ${name}(): PrimitiveType {`,
99
+ indent([`this.ensureWiredUp();`, `return this._${name};`]),
100
+ `}`
101
+ ]
123
102
 
124
103
  const reflectiveMembersForEntity = (entity: LanguageEntity) => {
125
104
  if (entity instanceof Classifier) {
@@ -134,7 +113,6 @@ export const reflectiveClassFor = (imports: Imports) => {
134
113
  return `// unhandled language entity <${entityMetaType(entity)}>"${entity.name}"`
135
114
  }
136
115
 
137
-
138
116
  const refForType = (type: SingleRef<LanguageEntity>) => {
139
117
  if (type === null) {
140
118
  return `???`
@@ -146,12 +124,12 @@ export const reflectiveClassFor = (imports: Imports) => {
146
124
  }
147
125
 
148
126
  const wireUpStatementsForProperty = (property: Property) => {
149
- const {classifier, name, type, optional} = property
127
+ const { classifier, name, type, optional } = property
150
128
  return `this._${classifier.name}_${name}.ofType(${refForType(type)})${optional ? ".isOptional()" : ""};`
151
129
  }
152
130
 
153
131
  const wireUpStatementsForLink = (link: Link) => {
154
- const {classifier, name, type} = link
132
+ const { classifier, name, type } = link
155
133
  return `this._${classifier.name}_${name}.ofType(${refForType(type)});`
156
134
  }
157
135
 
@@ -165,23 +143,24 @@ export const reflectiveClassFor = (imports: Imports) => {
165
143
  return `// unhandled feature <${featureMetaType(feature)}>"${feature.name}"`
166
144
  }
167
145
 
168
- const isConcreteClassifier = (classifier: Classifier): classifier is (Annotation | Concept) =>
146
+ const isConcreteClassifier = (classifier: Classifier): classifier is Annotation | Concept =>
169
147
  classifier instanceof Annotation || classifier instanceof Concept
170
148
 
171
149
  const wireUpStatementsForEntity = (entity: LanguageEntity) => {
172
- const {name} = entity
150
+ const { name } = entity
173
151
  const thisLocalName = (localName: string) => `this._${name}_${localName}`
174
152
  if (entity instanceof Classifier) {
175
153
  const extends_ = extendsFrom(entity)
176
154
  return [
177
- extends_ instanceof Classifier
178
- ? `this._${name}.extends = ${refForType(extends_)};`
179
- : [],
155
+ extends_ instanceof Classifier ? `this._${name}.extends = ${refForType(extends_)};` : [],
180
156
  when(entity instanceof Interface && entity.extends.length > 0)(
181
- () => `this._${name}.extending(${(entity as Interface).extends.map((interface_) => refForType(interface_)).join(", ")});`
157
+ () => `this._${name}.extending(${(entity as Interface).extends.map(interface_ => refForType(interface_)).join(", ")});`
182
158
  ),
183
159
  when(isConcreteClassifier(entity) && entity.implements.length > 0)(
184
- () => `this._${name}.implementing(${asArray((entity as (Annotation | Concept)).implements).map((interface_) => refForType(interface_)).join(", ")});`
160
+ () =>
161
+ `this._${name}.implementing(${asArray((entity as Annotation | Concept).implements)
162
+ .map(interface_ => refForType(interface_))
163
+ .join(", ")});`
185
164
  ),
186
165
  when(entity.features.length > 0)(
187
166
  `this._${name}.havingFeatures(${entity.features.map(nameOf).map(thisLocalName).join(", ")});`
@@ -193,13 +172,13 @@ export const reflectiveClassFor = (imports: Imports) => {
193
172
  return `this._${name}.havingLiterals(${entity.literals.map(nameOf).map(thisLocalName).join(", ")});`
194
173
  }
195
174
  if (entity instanceof PrimitiveType) {
196
- return [] // (nothing to do)
175
+ return [] // (nothing to do)
197
176
  }
198
177
  return `// unhandled language entity <${entityMetaType(entity)}>"${name}"`
199
178
  }
200
179
 
201
180
  return (language: Language) => {
202
- const {version, id, key, entities} = language
181
+ const { version, id, key, entities } = language
203
182
  const enumerations = entities.filter(isEnumeration)
204
183
  const concreteClassifiers = entities.filter(isConcrete)
205
184
  const parameterPrefix = concreteClassifiers.length === 0 ? "_" : ""
@@ -212,10 +191,7 @@ export const reflectiveClassFor = (imports: Imports) => {
212
191
  `private readonly _language: ${imports.core("Language")} = new Language("${imports.thisLanguageNameAsJsIdentifier}", "${version}", "${id}", "${key}");`,
213
192
  // | core | (3rd x)
214
193
  `get language(): Language {`,
215
- indent([
216
- `this.ensureWiredUp();`,
217
- `return this._language;`
218
- ]),
194
+ indent([`this.ensureWiredUp();`, `return this._language;`]),
219
195
  `}`,
220
196
  ``,
221
197
  entities.map(withNewlineAppended(reflectiveMembersForEntity)),
@@ -233,11 +209,13 @@ export const reflectiveClassFor = (imports: Imports) => {
233
209
  ``,
234
210
  `factory(${parameterPrefix}handleDelta?: ${imports.generic("DeltaHandler")}): ${imports.generic("NodeBaseFactory")} {`,
235
211
  indent([
236
- `return (classifier: ${imports.core("Classifier")}, ${parameterPrefix}id: ${imports.core("Id")}) => {`,
212
+ `return (classifier: ${imports.core("Classifier")}, ${parameterPrefix}id: ${imports.json("LionWebId")}) => {`,
237
213
  indent(
238
214
  switchOrIf(
239
215
  "classifier.key",
240
- concreteClassifiers.map(nameOf).map((name) => [`this._${name}.key`, `${name}.create(id, ${parameterPrefix}handleDelta)`]),
216
+ concreteClassifiers
217
+ .map(nameOf)
218
+ .map(name => [`this._${name}.key`, `${name}.create(id, ${parameterPrefix}handleDelta)`]),
241
219
  [
242
220
  `const {language} = classifier;`,
243
221
  `throw new Error(\`can't instantiate \${classifier.name} (key=\${classifier.key}): classifier is not known in language \${language.name} (key=\${language.key}, version=\${language.version})\`);`
@@ -254,7 +232,7 @@ export const reflectiveClassFor = (imports: Imports) => {
254
232
  `const {enumeration} = enumerationLiteral;`,
255
233
  switchOrIf(
256
234
  "enumeration.key",
257
- enumerations.map(nameOf).map((name) => [`this._${name}.key`, "enumerationLiteral.key as EnumType"]),
235
+ enumerations.map(nameOf).map(name => [`this._${name}.key`, "enumerationLiteral.key as EnumType"]),
258
236
  [
259
237
  `const {language} = enumeration;`,
260
238
  `throw new Error(\`enumeration with key \${enumeration.key} is not known in language \${language.name} (key=\${language.key}, version=\${language.version})\`);`
@@ -268,6 +246,5 @@ export const reflectiveClassFor = (imports: Imports) => {
268
246
  `}`
269
247
  ]
270
248
  }
271
-
272
249
  }
273
250
 
@@ -16,6 +16,5 @@
16
16
  // SPDX-License-Identifier: Apache-2.0
17
17
 
18
18
  export {asTypeScript} from "./json-as-ts.js"
19
- export {sortedStrings, sortedStringsByUppercase} from "./string-sorting.js"
20
19
  export {indent} from "./textgen.js"
21
20
 
@@ -21,7 +21,7 @@
21
21
  */
22
22
 
23
23
 
24
- import {asString, indentWith, Template} from "littoral-templates"
24
+ import { asString, indentWith, Template } from "littoral-templates"
25
25
 
26
26
 
27
27
  /**
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/api/helpers/types.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAoB,aAAa,EAAC,MAAM,eAAe,CAAA;AAG9D,eAAO,MAAM,sBAAsB,kBAAmB,aAAa,KAAG,MASrE,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/api/helpers/types.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,EAAE;AACF,iEAAiE;AACjE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,iDAAiD;AACjD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AACjC,EAAE;AACF,sEAAsE;AACtE,sCAAsC;AAEtC,OAAO,EAAC,iBAAiB,EAAgB,MAAM,eAAe,CAAA;AAG9D,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,aAA4B,EAAU,EAAE;IAC3E,QAAQ,aAAa,EAAE,CAAC;QACpB,KAAK,iBAAiB,CAAC,eAAe,CAAC,CAAC,OAAO,SAAS,CAAA;QACxD,KAAK,iBAAiB,CAAC,cAAc,CAAC,CAAC,OAAO,QAAQ,CAAA;QACtD,KAAK,iBAAiB,CAAC,eAAe,CAAC,CAAC,OAAO,QAAQ,CAAA;QACvD,KAAK,iBAAiB,CAAC,YAAY,CAAC,CAAC,OAAO,SAAS,CAAA;QACrD;YACI,OAAO,QAAQ,CAAA;IACvB,CAAC;AACL,CAAC,CAAA"}
@@ -1,4 +0,0 @@
1
- export type StringSorter = (strings: string[]) => string[];
2
- export declare const sortedStrings: StringSorter;
3
- export declare const sortedStringsByUppercase: StringSorter;
4
- //# sourceMappingURL=string-sorting.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"string-sorting.d.ts","sourceRoot":"","sources":["../../src/utils/string-sorting.ts"],"names":[],"mappings":"AAiBA,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,MAAM,EAAE,CAAA;AAQ1D,eAAO,MAAM,aAAa,cAAkC,CAAA;AAE5D,eAAO,MAAM,wBAAwB,cAAgD,CAAA"}
@@ -1,23 +0,0 @@
1
- // Copyright 2025 TRUMPF Laser SE and other contributors
2
- //
3
- // Licensed under the Apache License, Version 2.0 (the "License")
4
- // you may not use this file except in compliance with the License.
5
- // You may obtain a copy of the License at
6
- //
7
- // http://www.apache.org/licenses/LICENSE-2.0
8
- //
9
- // Unless required by applicable law or agreed to in writing, software
10
- // distributed under the License is distributed on an "AS IS" BASIS,
11
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- // See the License for the specific language governing permissions and
13
- // limitations under the License.
14
- //
15
- // SPDX-FileCopyrightText: 2025 TRUMPF Laser SE and other contributors
16
- // SPDX-License-Identifier: Apache-2.0
17
- const sortedStringsWith = (strMap) => (strings) => {
18
- strings.sort((l, r) => strMap(l).localeCompare(strMap(r)));
19
- return strings;
20
- };
21
- export const sortedStrings = sortedStringsWith((str) => str);
22
- export const sortedStringsByUppercase = sortedStringsWith((str) => str.toUpperCase());
23
- //# sourceMappingURL=string-sorting.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"string-sorting.js","sourceRoot":"","sources":["../../src/utils/string-sorting.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,EAAE;AACF,iEAAiE;AACjE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,iDAAiD;AACjD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AACjC,EAAE;AACF,sEAAsE;AACtE,sCAAsC;AAItC,MAAM,iBAAiB,GAAG,CAAC,MAA+B,EAAgB,EAAE,CACxE,CAAC,OAAO,EAAE,EAAE;IACR,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IAC1D,OAAO,OAAO,CAAA;AAClB,CAAC,CAAA;AAEL,MAAM,CAAC,MAAM,aAAa,GAAG,iBAAiB,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,CAAA;AAE5D,MAAM,CAAC,MAAM,wBAAwB,GAAG,iBAAiB,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,CAAA"}
@@ -1,6 +0,0 @@
1
- /**
2
- * Computes the topological order of the transitive closure of the graph with the given vertices and edges given by the edge function,
3
- * or returns {@code false} if there's a cycle.
4
- */
5
- export declare const dependencyOrderOf: <T>(vertices: T[], edgesOf: (vertex: T) => T[]) => false | T[];
6
- //# sourceMappingURL=toposort.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"toposort.d.ts","sourceRoot":"","sources":["../../src/utils/toposort.ts"],"names":[],"mappings":"AAiBA;;;GAGG;AACH,eAAO,MAAM,iBAAiB,gEA0B7B,CAAA"}
@@ -1,41 +0,0 @@
1
- // Copyright 2025 TRUMPF Laser SE and other contributors
2
- //
3
- // Licensed under the Apache License, Version 2.0 (the "License")
4
- // you may not use this file except in compliance with the License.
5
- // You may obtain a copy of the License at
6
- //
7
- // http://www.apache.org/licenses/LICENSE-2.0
8
- //
9
- // Unless required by applicable law or agreed to in writing, software
10
- // distributed under the License is distributed on an "AS IS" BASIS,
11
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- // See the License for the specific language governing permissions and
13
- // limitations under the License.
14
- //
15
- // SPDX-FileCopyrightText: 2025 TRUMPF Laser SE and other contributors
16
- // SPDX-License-Identifier: Apache-2.0
17
- /**
18
- * Computes the topological order of the transitive closure of the graph with the given vertices and edges given by the edge function,
19
- * or returns {@code false} if there's a cycle.
20
- */
21
- export const dependencyOrderOf = (vertices, edgesOf) => {
22
- const ordered = [];
23
- const visit = (current, chain) => {
24
- if (ordered.indexOf(current) > -1) {
25
- return false;
26
- }
27
- if (chain.indexOf(current) > -1) {
28
- return true;
29
- }
30
- const extendedChain = [...chain, current];
31
- const hasCycle = edgesOf(current).some((edge) => visit(edge, extendedChain));
32
- ordered.push(current);
33
- if (hasCycle) {
34
- console.dir(ordered);
35
- }
36
- return hasCycle;
37
- };
38
- const hasCycle = vertices.some((vertex) => visit(vertex, []));
39
- return hasCycle ? false : ordered;
40
- };
41
- //# sourceMappingURL=toposort.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"toposort.js","sourceRoot":"","sources":["../../src/utils/toposort.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,EAAE;AACF,iEAAiE;AACjE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,iDAAiD;AACjD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AACjC,EAAE;AACF,sEAAsE;AACtE,sCAAsC;AAEtC;;;GAGG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAI,QAAa,EAAE,OAA2B,EAAe,EAAE;IAC5F,MAAM,OAAO,GAAQ,EAAE,CAAA;IAEvB,MAAM,KAAK,GAAG,CAAC,OAAU,EAAE,KAAU,EAAE,EAAE;QACrC,IAAI,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;YAChC,OAAO,KAAK,CAAA;QAChB,CAAC;QACD,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;YAC9B,OAAO,IAAI,CAAA;QACf,CAAC;QACD,MAAM,aAAa,GAAG,CAAE,GAAG,KAAK,EAAE,OAAO,CAAE,CAAA;QAC3C,MAAM,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,IAAI,CAClC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,aAAa,CAAC,CACvC,CAAA;QACD,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QACrB,IAAI,QAAQ,EAAE,CAAC;YACX,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;QACxB,CAAC;QACD,OAAO,QAAQ,CAAA;IACnB,CAAC,CAAA;IAED,MAAM,QAAQ,GAAG,QAAQ,CAAC,IAAI,CAC1B,CAAC,MAAM,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC,CAChC,CAAA;IAED,OAAO,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAA;AACrC,CAAC,CAAA"}
@@ -1,29 +0,0 @@
1
- // Copyright 2025 TRUMPF Laser SE and other contributors
2
- //
3
- // Licensed under the Apache License, Version 2.0 (the "License")
4
- // you may not use this file except in compliance with the License.
5
- // You may obtain a copy of the License at
6
- //
7
- // http://www.apache.org/licenses/LICENSE-2.0
8
- //
9
- // Unless required by applicable law or agreed to in writing, software
10
- // distributed under the License is distributed on an "AS IS" BASIS,
11
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- // See the License for the specific language governing permissions and
13
- // limitations under the License.
14
- //
15
- // SPDX-FileCopyrightText: 2025 TRUMPF Laser SE and other contributors
16
- // SPDX-License-Identifier: Apache-2.0
17
-
18
- export type StringSorter = (strings: string[]) => string[]
19
-
20
- const sortedStringsWith = (strMap: (str: string) => string): StringSorter =>
21
- (strings) => {
22
- strings.sort((l, r) => strMap(l).localeCompare(strMap(r)))
23
- return strings
24
- }
25
-
26
- export const sortedStrings = sortedStringsWith((str) => str)
27
-
28
- export const sortedStringsByUppercase = sortedStringsWith((str) => str.toUpperCase())
29
-
@@ -1,49 +0,0 @@
1
- // Copyright 2025 TRUMPF Laser SE and other contributors
2
- //
3
- // Licensed under the Apache License, Version 2.0 (the "License")
4
- // you may not use this file except in compliance with the License.
5
- // You may obtain a copy of the License at
6
- //
7
- // http://www.apache.org/licenses/LICENSE-2.0
8
- //
9
- // Unless required by applicable law or agreed to in writing, software
10
- // distributed under the License is distributed on an "AS IS" BASIS,
11
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- // See the License for the specific language governing permissions and
13
- // limitations under the License.
14
- //
15
- // SPDX-FileCopyrightText: 2025 TRUMPF Laser SE and other contributors
16
- // SPDX-License-Identifier: Apache-2.0
17
-
18
- /**
19
- * Computes the topological order of the transitive closure of the graph with the given vertices and edges given by the edge function,
20
- * or returns {@code false} if there's a cycle.
21
- */
22
- export const dependencyOrderOf = <T>(vertices: T[], edgesOf: (vertex: T) => T[]): T[] | false => {
23
- const ordered: T[] = []
24
-
25
- const visit = (current: T, chain: T[]) => {
26
- if (ordered.indexOf(current) > -1) {
27
- return false
28
- }
29
- if (chain.indexOf(current) > -1) {
30
- return true
31
- }
32
- const extendedChain = [ ...chain, current ]
33
- const hasCycle = edgesOf(current).some(
34
- (edge) => visit(edge, extendedChain)
35
- )
36
- ordered.push(current)
37
- if (hasCycle) {
38
- console.dir(ordered)
39
- }
40
- return hasCycle
41
- }
42
-
43
- const hasCycle = vertices.some(
44
- (vertex) => visit(vertex, [])
45
- )
46
-
47
- return hasCycle ? false : ordered
48
- }
49
-