@lionweb/class-core-generator 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.
- package/CHANGELOG.md +6 -0
- package/dist/entity-types.templates.d.ts +4 -0
- package/dist/entity-types.templates.d.ts.map +1 -0
- package/dist/{api/entity-types.templates.js → entity-types.templates.js} +36 -15
- package/dist/entity-types.templates.js.map +1 -0
- package/dist/{api/generation-headers.d.ts → generation-headers.d.ts} +1 -1
- package/dist/generation-headers.d.ts.map +1 -0
- package/dist/{api/generation-headers.js → generation-headers.js} +19 -13
- package/dist/generation-headers.js.map +1 -0
- package/dist/{api/generator.d.ts → generator.d.ts} +0 -2
- package/dist/generator.d.ts.map +1 -0
- package/dist/{api/generator.js → generator.js} +0 -1
- package/dist/generator.js.map +1 -0
- package/dist/helpers/classifiers.d.ts.map +1 -0
- package/dist/helpers/classifiers.js.map +1 -0
- package/dist/helpers/entities.d.ts.map +1 -0
- package/dist/helpers/entities.js.map +1 -0
- package/dist/{api/helpers → helpers}/features.d.ts +3 -3
- package/dist/helpers/features.d.ts.map +1 -0
- package/dist/{api/helpers → helpers}/features.js +8 -8
- package/dist/helpers/features.js.map +1 -0
- package/dist/helpers/imports-tracking.d.ts.map +1 -0
- package/dist/{api/helpers → helpers}/imports-tracking.js +1 -1
- package/dist/helpers/imports-tracking.js.map +1 -0
- package/dist/{api/helpers → helpers}/index.d.ts +0 -2
- package/dist/helpers/index.d.ts.map +1 -0
- package/dist/{api/helpers → helpers}/index.js +0 -2
- package/dist/helpers/index.js.map +1 -0
- package/dist/helpers/primitive-types.d.ts.map +1 -0
- package/dist/{api/helpers → helpers}/primitive-types.js +4 -4
- package/dist/helpers/primitive-types.js.map +1 -0
- package/dist/index-ts.d.ts.map +1 -0
- package/dist/{api/index-ts.js → index-ts.js} +3 -2
- package/dist/index-ts.js.map +1 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/language-file.templates.d.ts.map +1 -0
- package/dist/{api/language-file.templates.js → language-file.templates.js} +3 -5
- package/dist/language-file.templates.js.map +1 -0
- package/dist/mega-factory.templates.d.ts +3 -0
- package/dist/mega-factory.templates.d.ts.map +1 -0
- package/dist/{api/mega-factory.templates.js → mega-factory.templates.js} +4 -4
- package/dist/mega-factory.templates.js.map +1 -0
- package/dist/reflective-layer.templates.d.ts.map +1 -0
- package/dist/{api/reflective-layer.templates.js → reflective-layer.templates.js} +9 -5
- package/dist/reflective-layer.templates.js.map +1 -0
- package/package.json +9 -7
- package/src/{api/entity-types.templates.ts → entity-types.templates.ts} +56 -20
- package/src/{api/generation-headers.ts → generation-headers.ts} +19 -15
- package/src/{api/generator.ts → generator.ts} +0 -3
- package/src/{api/helpers → helpers}/features.ts +9 -9
- package/src/{api/helpers → helpers}/imports-tracking.ts +1 -1
- package/src/{api/helpers → helpers}/index.ts +0 -2
- package/src/{api/helpers → helpers}/primitive-types.ts +4 -4
- package/src/{api/index-ts.ts → index-ts.ts} +4 -3
- package/src/index.ts +3 -2
- package/src/{api/language-file.templates.ts → language-file.templates.ts} +3 -6
- package/src/{api/mega-factory.templates.ts → mega-factory.templates.ts} +4 -5
- package/src/{api/reflective-layer.templates.ts → reflective-layer.templates.ts} +9 -4
- package/dist/api/entity-types.templates.d.ts +0 -5
- package/dist/api/entity-types.templates.d.ts.map +0 -1
- package/dist/api/entity-types.templates.js.map +0 -1
- package/dist/api/generation-headers.d.ts.map +0 -1
- package/dist/api/generation-headers.js.map +0 -1
- package/dist/api/generator.d.ts.map +0 -1
- package/dist/api/generator.js.map +0 -1
- package/dist/api/helpers/classifiers.d.ts.map +0 -1
- package/dist/api/helpers/classifiers.js.map +0 -1
- package/dist/api/helpers/dependencies.d.ts +0 -11
- package/dist/api/helpers/dependencies.d.ts.map +0 -1
- package/dist/api/helpers/dependencies.js +0 -52
- package/dist/api/helpers/dependencies.js.map +0 -1
- package/dist/api/helpers/entities.d.ts.map +0 -1
- package/dist/api/helpers/entities.js.map +0 -1
- package/dist/api/helpers/features.d.ts.map +0 -1
- package/dist/api/helpers/features.js.map +0 -1
- package/dist/api/helpers/imports-tracking.d.ts.map +0 -1
- package/dist/api/helpers/imports-tracking.js.map +0 -1
- package/dist/api/helpers/index.d.ts.map +0 -1
- package/dist/api/helpers/index.js.map +0 -1
- package/dist/api/helpers/mps-annotations.d.ts +0 -19
- package/dist/api/helpers/mps-annotations.d.ts.map +0 -1
- package/dist/api/helpers/mps-annotations.js +0 -65
- package/dist/api/helpers/mps-annotations.js.map +0 -1
- package/dist/api/helpers/primitive-types.d.ts.map +0 -1
- package/dist/api/helpers/primitive-types.js.map +0 -1
- package/dist/api/index-ts.d.ts.map +0 -1
- package/dist/api/index-ts.js.map +0 -1
- package/dist/api/index.d.ts +0 -5
- package/dist/api/index.d.ts.map +0 -1
- package/dist/api/index.js +0 -21
- package/dist/api/index.js.map +0 -1
- package/dist/api/language-file.templates.d.ts.map +0 -1
- package/dist/api/language-file.templates.js.map +0 -1
- package/dist/api/mega-factory.templates.d.ts +0 -4
- package/dist/api/mega-factory.templates.d.ts.map +0 -1
- package/dist/api/mega-factory.templates.js.map +0 -1
- package/dist/api/reflective-layer.templates.d.ts.map +0 -1
- package/dist/api/reflective-layer.templates.js.map +0 -1
- package/dist/utils/index.d.ts +0 -3
- package/dist/utils/index.d.ts.map +0 -1
- package/dist/utils/index.js +0 -19
- package/dist/utils/index.js.map +0 -1
- package/dist/utils/json-as-ts.d.ts +0 -2
- package/dist/utils/json-as-ts.d.ts.map +0 -1
- package/dist/utils/json-as-ts.js +0 -18
- package/dist/utils/json-as-ts.js.map +0 -1
- package/dist/utils/textgen.d.ts +0 -21
- package/dist/utils/textgen.d.ts.map +0 -1
- package/dist/utils/textgen.js +0 -67
- package/dist/utils/textgen.js.map +0 -1
- package/src/api/helpers/dependencies.ts +0 -62
- package/src/api/helpers/mps-annotations.ts +0 -67
- package/src/api/index.ts +0 -21
- package/src/utils/index.ts +0 -20
- package/src/utils/json-as-ts.ts +0 -20
- package/src/utils/textgen.ts +0 -89
- /package/dist/{api/helpers → helpers}/classifiers.d.ts +0 -0
- /package/dist/{api/helpers → helpers}/classifiers.js +0 -0
- /package/dist/{api/helpers → helpers}/entities.d.ts +0 -0
- /package/dist/{api/helpers → helpers}/entities.js +0 -0
- /package/dist/{api/helpers → helpers}/imports-tracking.d.ts +0 -0
- /package/dist/{api/helpers → helpers}/primitive-types.d.ts +0 -0
- /package/dist/{api/index-ts.d.ts → index-ts.d.ts} +0 -0
- /package/dist/{api/language-file.templates.d.ts → language-file.templates.d.ts} +0 -0
- /package/dist/{api/reflective-layer.templates.d.ts → reflective-layer.templates.d.ts} +0 -0
- /package/src/{api/helpers → helpers}/classifiers.ts +0 -0
- /package/src/{api/helpers → helpers}/entities.ts +0 -0
package/src/utils/textgen.ts
DELETED
|
@@ -1,89 +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
|
-
* NOTE: this code is copied verbatim from the @lionweb/utilities package, and subsequently modified/added to.
|
|
20
|
-
* This code should “flow back” to the @lionweb packages.
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
import { asString, indentWith, Template } from "littoral-templates"
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* @return an indenter function that indents by 4 spaces.
|
|
29
|
-
*/
|
|
30
|
-
export const indent = indentWith(" ")(1)
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
const withFirstCased = (charFunc: (ch: string) => string) =>
|
|
34
|
-
(str: string) => {
|
|
35
|
-
if (str.length === 0) {
|
|
36
|
-
return str
|
|
37
|
-
}
|
|
38
|
-
return charFunc(str.charAt(0))
|
|
39
|
-
+ (str.length > 1 ? str.substring(1) : "")
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* @return the given string but with its first character lower-cased (when possible).
|
|
44
|
-
*/
|
|
45
|
-
export const withFirstLower = withFirstCased((ch) => ch.toLowerCase())
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* @return the given string but with its first character upper-cased (when possible).
|
|
49
|
-
*/
|
|
50
|
-
export const withFirstUpper = withFirstCased((ch) => ch.toUpperCase())
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* @return a sanitized version of the given string that should be suitable as a valid JavaScript identifier.
|
|
55
|
-
*/
|
|
56
|
-
export const asJSIdentifier = (str: string): string =>
|
|
57
|
-
str
|
|
58
|
-
.replaceAll(".", "_")
|
|
59
|
-
.replaceAll("-", "_")
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
export const wrapInIf = (condition: boolean, left: () => string, right: string) =>
|
|
63
|
-
(text: string) =>
|
|
64
|
-
condition
|
|
65
|
-
? `${left()}${text}${right}`
|
|
66
|
-
: text
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
export type MatchCase = [caseExpression: string, returnValue: string]
|
|
70
|
-
|
|
71
|
-
export const switchOrIf = (expression: string, cases: MatchCase[], defaultBlock: Template) =>
|
|
72
|
-
cases.length > 1
|
|
73
|
-
? [
|
|
74
|
-
`switch (${expression}) {`,
|
|
75
|
-
indent([
|
|
76
|
-
cases.map(([caseExpression, returnValue]) => `case ${caseExpression}: return ${returnValue};`),
|
|
77
|
-
`default: ${typeof defaultBlock === "string" ? defaultBlock : asString(["{", indent(defaultBlock), "}"])}`
|
|
78
|
-
]),
|
|
79
|
-
`}`
|
|
80
|
-
]
|
|
81
|
-
: [
|
|
82
|
-
cases.map(([caseExpression, returnValue]) => [
|
|
83
|
-
`if (${expression} === ${caseExpression}) {`,
|
|
84
|
-
indent(`return ${returnValue};`),
|
|
85
|
-
`}`
|
|
86
|
-
]),
|
|
87
|
-
defaultBlock
|
|
88
|
-
]
|
|
89
|
-
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|