@ostack.tech/kform-scaffolder 0.32.5 → 0.33.0-SNAPSHOT.20260319184938
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/ostack-kform-scaffolder.js +1369 -1638
- package/ostack-kform-scaffolder.js.map +1 -1
- package/package.json +1 -1
- package/webapp/assets/index-BKUWl2po.css +1 -0
- package/webapp/assets/index-DzBG-Yil.js +173 -0
- package/webapp/index.html +2 -2
- package/webapp/assets/index-DwnUHNYx.js +0 -173
- package/webapp/assets/index-x_B5n20N.css +0 -1
|
@@ -1,1770 +1,1501 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { createContext, useContext, useCallback, useMemo, useRef, useLayoutEffect as useLayoutEffect$1, useState } from "react";
|
|
1
|
+
import { DndContext, DragOverlay, KeyboardSensor, PointerSensor, closestCenter, useDraggable, useDroppable, useSensor, useSensors } from "@dnd-kit/core";
|
|
2
|
+
import { createContext, useCallback, useContext, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
4
3
|
import { create } from "zustand";
|
|
5
4
|
import { persist } from "zustand/middleware";
|
|
6
5
|
import { fileOpen, fileSave, supported } from "browser-fs-access";
|
|
6
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
7
7
|
import JSZip from "jszip";
|
|
8
8
|
import { render } from "ejs";
|
|
9
|
+
//#region src/Schematic.ts
|
|
9
10
|
function createSchematic(schematic) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
return {
|
|
12
|
+
id: self.crypto.randomUUID(),
|
|
13
|
+
kind: "",
|
|
14
|
+
...schematic
|
|
15
|
+
};
|
|
15
16
|
}
|
|
16
17
|
function moveSchematic(schematic, moveId, parentId, sortBefore) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
moveId
|
|
20
|
-
);
|
|
21
|
-
return add(schematicWithoutFrom, fromSchematic, parentId, sortBefore);
|
|
18
|
+
const { schematic: schematicWithoutFrom, removed: fromSchematic } = remove(schematic, moveId);
|
|
19
|
+
return add(schematicWithoutFrom, fromSchematic, parentId, sortBefore);
|
|
22
20
|
}
|
|
23
21
|
function remove(schematic, id) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
22
|
+
if (schematic.id === id) return {
|
|
23
|
+
schematic: null,
|
|
24
|
+
removed: schematic
|
|
25
|
+
};
|
|
26
|
+
if (!schematic.children) return {
|
|
27
|
+
schematic,
|
|
28
|
+
removed: null
|
|
29
|
+
};
|
|
30
|
+
const newChildren = [];
|
|
31
|
+
let removed = null;
|
|
32
|
+
for (const child of schematic.children) {
|
|
33
|
+
const { schematic: newChild, removed: removedChild } = remove(child, id);
|
|
34
|
+
if (newChild !== null) newChildren.push(newChild);
|
|
35
|
+
if (removedChild !== null) removed = removedChild;
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
schematic: {
|
|
39
|
+
...schematic,
|
|
40
|
+
children: newChildren
|
|
41
|
+
},
|
|
42
|
+
removed
|
|
43
|
+
};
|
|
42
44
|
}
|
|
43
45
|
function add(schematic, toAdd, parentId, sortBefore) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
const SchematicBuilderContext = createContext(null);
|
|
46
|
+
if (schematic.id === parentId) {
|
|
47
|
+
const oldChildren = schematic.children ?? [];
|
|
48
|
+
const index = sortBefore === null ? oldChildren.length : oldChildren.findIndex((c) => c.id === sortBefore);
|
|
49
|
+
return {
|
|
50
|
+
...schematic,
|
|
51
|
+
children: [
|
|
52
|
+
...oldChildren.slice(0, index),
|
|
53
|
+
toAdd,
|
|
54
|
+
...oldChildren.slice(index)
|
|
55
|
+
]
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
if (!schematic.children) return schematic;
|
|
59
|
+
return {
|
|
60
|
+
...schematic,
|
|
61
|
+
children: schematic.children.map((child) => add(child, toAdd, parentId, sortBefore))
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
//#endregion
|
|
65
|
+
//#region src/SchematicBuilderContext.ts
|
|
66
|
+
var SchematicBuilderContext = createContext(null);
|
|
67
67
|
function useSchematicBuilderContext() {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
return context;
|
|
68
|
+
const context = useContext(SchematicBuilderContext);
|
|
69
|
+
if (context === null) throw new Error("Schematic builder not in context.");
|
|
70
|
+
return context;
|
|
73
71
|
}
|
|
72
|
+
//#endregion
|
|
73
|
+
//#region src/actions/LoadSchematic.tsx
|
|
74
74
|
function LoadSchematic() {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}
|
|
103
|
-
);
|
|
104
|
-
}
|
|
75
|
+
const { name, setSchematic, latestSchematicFileHandleRef } = useSchematicBuilderContext();
|
|
76
|
+
return /* @__PURE__ */ jsx("button", {
|
|
77
|
+
className: "builder-icon-button builder-action builder-load-schematic",
|
|
78
|
+
type: "button",
|
|
79
|
+
onClick: async () => {
|
|
80
|
+
try {
|
|
81
|
+
const file = await fileOpen({
|
|
82
|
+
extensions: [".json"],
|
|
83
|
+
mimeTypes: ["application/json"],
|
|
84
|
+
description: "Form schematic",
|
|
85
|
+
id: name
|
|
86
|
+
});
|
|
87
|
+
latestSchematicFileHandleRef.current = file.handle ?? null;
|
|
88
|
+
const content = JSON.parse(await file.text());
|
|
89
|
+
setSchematic(() => content);
|
|
90
|
+
} catch (err) {
|
|
91
|
+
if (err instanceof DOMException && err.name === "AbortError") return;
|
|
92
|
+
alert(`Unable to load schematic: ${err?.toString()}`);
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
title: "Load schematic",
|
|
96
|
+
"aria-label": "Load schematic",
|
|
97
|
+
children: "📂"
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
//#endregion
|
|
101
|
+
//#region src/actions/SaveSchematic.tsx
|
|
105
102
|
function SaveSchematic() {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
}
|
|
135
|
-
alert(`Unable to save schematic: ${err?.toString()}`);
|
|
136
|
-
}
|
|
137
|
-
},
|
|
138
|
-
title: "Save schematic",
|
|
139
|
-
"aria-label": "Save schematic",
|
|
140
|
-
children: "💾"
|
|
141
|
-
}
|
|
142
|
-
);
|
|
143
|
-
}
|
|
103
|
+
const { name, getRootSchematic, latestSchematicFileHandleRef } = useSchematicBuilderContext();
|
|
104
|
+
return /* @__PURE__ */ jsx("button", {
|
|
105
|
+
className: "builder-icon-button builder-action builder-save-schematic",
|
|
106
|
+
type: "button",
|
|
107
|
+
onClick: async () => {
|
|
108
|
+
try {
|
|
109
|
+
const schematic = getRootSchematic();
|
|
110
|
+
latestSchematicFileHandleRef.current = await fileSave(new Blob([JSON.stringify(schematic, null, 2)]), {
|
|
111
|
+
fileName: `${schematic.name}-schematic.json`,
|
|
112
|
+
extensions: [".json"],
|
|
113
|
+
mimeTypes: ["application/json"],
|
|
114
|
+
description: "Form schematic",
|
|
115
|
+
id: name
|
|
116
|
+
}, latestSchematicFileHandleRef.current);
|
|
117
|
+
if (supported) alert(`Schematic saved successfully as “${latestSchematicFileHandleRef.current?.name ?? "unknown"}”.`);
|
|
118
|
+
} catch (err) {
|
|
119
|
+
if (err instanceof DOMException && err.name === "AbortError") return;
|
|
120
|
+
alert(`Unable to save schematic: ${err?.toString()}`);
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
title: "Save schematic",
|
|
124
|
+
"aria-label": "Save schematic",
|
|
125
|
+
children: "💾"
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
//#endregion
|
|
129
|
+
//#region src/scaffolding/configScaffolder.ts
|
|
130
|
+
/** Returns a new scaffolder with its data merged with the provided data. */
|
|
144
131
|
function configScaffolder(scaffolder, data) {
|
|
145
|
-
|
|
132
|
+
return (schematic, originalData) => scaffolder(schematic, {
|
|
133
|
+
...originalData,
|
|
134
|
+
...data
|
|
135
|
+
});
|
|
146
136
|
}
|
|
137
|
+
//#endregion
|
|
138
|
+
//#region src/util/join.ts
|
|
147
139
|
function join(s1, s2, separator) {
|
|
148
|
-
|
|
140
|
+
return !s1 || !s2 ? s1 || s2 || "" : `${s1}${s1.endsWith(separator) ? "" : separator}${s2}`;
|
|
149
141
|
}
|
|
150
142
|
function joinPaths(path1, path2) {
|
|
151
|
-
|
|
143
|
+
return join(path1, path2, "/");
|
|
152
144
|
}
|
|
153
145
|
function joinPackages(pkg1, pkg2) {
|
|
154
|
-
|
|
146
|
+
return join(pkg1, pkg2, ".");
|
|
155
147
|
}
|
|
148
|
+
//#endregion
|
|
149
|
+
//#region src/scaffolding/scaffold.ts
|
|
156
150
|
function scaffold(schematic, scaffolders, options) {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
151
|
+
const files = /* @__PURE__ */ new Map();
|
|
152
|
+
const data = {
|
|
153
|
+
schematicKinds: options.schematicKinds,
|
|
154
|
+
rootSchematic: schematic,
|
|
155
|
+
files,
|
|
156
|
+
currentPath: options.basePath ?? "/",
|
|
157
|
+
currentPackage: joinPackages(options.basePackage, schematic.packageSuffix),
|
|
158
|
+
currentDir: options.baseDir
|
|
159
|
+
};
|
|
160
|
+
for (const scaffolder of scaffolders) scaffolder(schematic, data);
|
|
161
|
+
return Array.from(files).map(([path, file]) => ({
|
|
162
|
+
path,
|
|
163
|
+
content: file.getContent(),
|
|
164
|
+
base64: file.base64,
|
|
165
|
+
binary: file.binary,
|
|
166
|
+
executable: file.executable
|
|
167
|
+
}));
|
|
168
|
+
}
|
|
169
|
+
//#endregion
|
|
170
|
+
//#region src/scaffolding/useScaffolder.ts
|
|
177
171
|
function useScaffolder() {
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
}, [
|
|
203
|
-
baseDir,
|
|
204
|
-
basePackage,
|
|
205
|
-
basePath,
|
|
206
|
-
getRootSchematic,
|
|
207
|
-
scaffolders,
|
|
208
|
-
scaffoldingData,
|
|
209
|
-
schematicKinds
|
|
210
|
-
]);
|
|
211
|
-
}
|
|
172
|
+
const { basePath, basePackage, baseDir, schematicKinds, scaffolders, scaffoldingData, getRootSchematic } = useSchematicBuilderContext();
|
|
173
|
+
return useCallback(() => {
|
|
174
|
+
const schematic = getRootSchematic();
|
|
175
|
+
let actualScaffolders = typeof scaffolders === "function" ? scaffolders(schematic) : scaffolders;
|
|
176
|
+
const actualScaffoldingData = typeof scaffoldingData === "function" ? scaffoldingData(schematic) : scaffoldingData;
|
|
177
|
+
if (actualScaffoldingData) actualScaffolders = actualScaffolders.map((scaffolder) => configScaffolder(scaffolder, actualScaffoldingData));
|
|
178
|
+
return scaffold(schematic, actualScaffolders, {
|
|
179
|
+
schematicKinds,
|
|
180
|
+
basePath,
|
|
181
|
+
basePackage,
|
|
182
|
+
baseDir: typeof baseDir === "function" ? baseDir(schematic) : baseDir
|
|
183
|
+
});
|
|
184
|
+
}, [
|
|
185
|
+
baseDir,
|
|
186
|
+
basePackage,
|
|
187
|
+
basePath,
|
|
188
|
+
getRootSchematic,
|
|
189
|
+
scaffolders,
|
|
190
|
+
scaffoldingData,
|
|
191
|
+
schematicKinds
|
|
192
|
+
]);
|
|
193
|
+
}
|
|
194
|
+
//#endregion
|
|
195
|
+
//#region src/actions/ScaffoldToZip.tsx
|
|
212
196
|
function ScaffoldToZip() {
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
return;
|
|
251
|
-
}
|
|
252
|
-
alert(`Unable to scaffold project: ${err?.toString()}`);
|
|
253
|
-
}
|
|
254
|
-
},
|
|
255
|
-
children: "Scaffold 🏗️"
|
|
256
|
-
}
|
|
257
|
-
);
|
|
258
|
-
}
|
|
197
|
+
const { getRootSchematic, name } = useSchematicBuilderContext();
|
|
198
|
+
const scaffold = useScaffolder();
|
|
199
|
+
return /* @__PURE__ */ jsx("button", {
|
|
200
|
+
className: "builder-input builder-action builder-scaffold-zip",
|
|
201
|
+
type: "submit",
|
|
202
|
+
onClick: async (evt) => {
|
|
203
|
+
evt.preventDefault();
|
|
204
|
+
try {
|
|
205
|
+
const schematic = getRootSchematic();
|
|
206
|
+
const files = scaffold();
|
|
207
|
+
const zip = new JSZip();
|
|
208
|
+
for (const { path, content, base64, binary, executable } of files) zip.file(path, content, {
|
|
209
|
+
base64,
|
|
210
|
+
binary,
|
|
211
|
+
unixPermissions: executable ? "755" : void 0
|
|
212
|
+
});
|
|
213
|
+
const fileHandle = await fileSave(zip.generateAsync({
|
|
214
|
+
platform: "UNIX",
|
|
215
|
+
type: "blob"
|
|
216
|
+
}), {
|
|
217
|
+
fileName: `${schematic.name}.zip`,
|
|
218
|
+
extensions: [".zip"],
|
|
219
|
+
mimeTypes: ["application/zip"],
|
|
220
|
+
description: "Form scaffolding",
|
|
221
|
+
id: name
|
|
222
|
+
});
|
|
223
|
+
if (supported) alert(`Project scaffolded successfully in “${fileHandle?.name ?? "unknown"}”.`);
|
|
224
|
+
} catch (err) {
|
|
225
|
+
if (err instanceof DOMException && err.name === "AbortError") return;
|
|
226
|
+
alert(`Unable to scaffold project: ${err?.toString()}`);
|
|
227
|
+
}
|
|
228
|
+
},
|
|
229
|
+
children: "Scaffold 🏗️"
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
//#endregion
|
|
233
|
+
//#region src/configs/util/useConfig.ts
|
|
259
234
|
function useConfig(configName, defaultValue) {
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
})
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
})
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
/^kotlin\.[^.]+$/,
|
|
316
|
-
/^kotlin\.annotation\.[^.]+$/,
|
|
317
|
-
/^kotlin\.collections\.[^.]+$/,
|
|
318
|
-
/^kotlin\.comparisons\.[^.]+$/,
|
|
319
|
-
/^kotlin\.io\.[^.]+$/,
|
|
320
|
-
/^kotlin\.ranges\.[^.]+$/,
|
|
321
|
-
/^kotlin\.sequences\.[^.]+$/,
|
|
322
|
-
/^kotlin\.text\.[^.]+$/
|
|
235
|
+
const { useSchematic, setSchematic } = useSchematicBuilderContext();
|
|
236
|
+
const configValue = useSchematic((schematic) => schematic.config?.[configName] ?? defaultValue);
|
|
237
|
+
const setConfigValue = useCallback((configValue) => setSchematic((schematic) => ({ config: {
|
|
238
|
+
...schematic.config,
|
|
239
|
+
[configName]: typeof configValue === "function" ? configValue(schematic.config?.[configName]) : configValue
|
|
240
|
+
} })), [configName, setSchematic]);
|
|
241
|
+
return useMemo(() => [configValue, setConfigValue], [configValue, setConfigValue]);
|
|
242
|
+
}
|
|
243
|
+
//#endregion
|
|
244
|
+
//#region src/configs/UseFileBase64SerializerConfig.tsx
|
|
245
|
+
function UseFileBase64SerializerConfig({ disabled }) {
|
|
246
|
+
const [config, setConfig] = useConfig("useFileBase64Serializer", false);
|
|
247
|
+
return /* @__PURE__ */ jsx("div", {
|
|
248
|
+
className: "builder-config-field",
|
|
249
|
+
children: /* @__PURE__ */ jsxs("label", { children: [
|
|
250
|
+
/* @__PURE__ */ jsx("input", {
|
|
251
|
+
type: "checkbox",
|
|
252
|
+
checked: config,
|
|
253
|
+
onChange: (evt) => setConfig(evt.target.checked),
|
|
254
|
+
disabled
|
|
255
|
+
}),
|
|
256
|
+
"Use ",
|
|
257
|
+
/* @__PURE__ */ jsx("code", { children: "File.Base64Serializer" })
|
|
258
|
+
] })
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
//#endregion
|
|
262
|
+
//#region src/configs/UseTableValuesSerializerConfig.tsx
|
|
263
|
+
function UseTableValuesSerializerConfig({ disabled }) {
|
|
264
|
+
const [config, setConfig] = useConfig("useTableValuesSerializer", false);
|
|
265
|
+
return /* @__PURE__ */ jsx("div", {
|
|
266
|
+
className: "builder-config-field",
|
|
267
|
+
children: /* @__PURE__ */ jsxs("label", { children: [
|
|
268
|
+
/* @__PURE__ */ jsx("input", {
|
|
269
|
+
type: "checkbox",
|
|
270
|
+
checked: config,
|
|
271
|
+
onChange: (evt) => setConfig(evt.target.checked),
|
|
272
|
+
disabled
|
|
273
|
+
}),
|
|
274
|
+
"Use ",
|
|
275
|
+
/* @__PURE__ */ jsx("code", { children: "Table.ValuesSerializer" })
|
|
276
|
+
] })
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
//#endregion
|
|
280
|
+
//#region src/scaffolding/kotlin/util/defaultImports.ts
|
|
281
|
+
var DEFAULT_IMPORTS = [
|
|
282
|
+
/^kotlin\.[^.]+$/,
|
|
283
|
+
/^kotlin\.annotation\.[^.]+$/,
|
|
284
|
+
/^kotlin\.collections\.[^.]+$/,
|
|
285
|
+
/^kotlin\.comparisons\.[^.]+$/,
|
|
286
|
+
/^kotlin\.io\.[^.]+$/,
|
|
287
|
+
/^kotlin\.ranges\.[^.]+$/,
|
|
288
|
+
/^kotlin\.sequences\.[^.]+$/,
|
|
289
|
+
/^kotlin\.text\.[^.]+$/
|
|
323
290
|
];
|
|
324
291
|
function isDefaultKtImport(qualifiedName) {
|
|
325
|
-
|
|
292
|
+
return DEFAULT_IMPORTS.some((i) => i.test(qualifiedName));
|
|
326
293
|
}
|
|
294
|
+
//#endregion
|
|
295
|
+
//#region src/scaffolding/kotlin/KtFile.ts
|
|
327
296
|
function ktFile(data) {
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
297
|
+
return {
|
|
298
|
+
package: data.currentPackage ?? "",
|
|
299
|
+
imports: /* @__PURE__ */ new Set(),
|
|
300
|
+
declarations: [],
|
|
301
|
+
getContent: ktFileContent
|
|
302
|
+
};
|
|
334
303
|
}
|
|
335
304
|
function ktFileContent() {
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
}
|
|
305
|
+
return [
|
|
306
|
+
this.package && `package ${this.package}`,
|
|
307
|
+
Array.from(this.imports).filter((i) => !isDefaultKtImport(i)).sort().map((i) => `import ${i}`).join("\n"),
|
|
308
|
+
...this.declarations
|
|
309
|
+
].filter((s) => s).join("\n\n") + "\n";
|
|
310
|
+
}
|
|
311
|
+
//#endregion
|
|
312
|
+
//#region src/scaffolding/kotlin/util/simpleKtName.ts
|
|
345
313
|
function simpleKtName(qualifiedName) {
|
|
346
|
-
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
}
|
|
314
|
+
return qualifiedName.substring(qualifiedName.lastIndexOf(".") + 1);
|
|
315
|
+
}
|
|
316
|
+
//#endregion
|
|
317
|
+
//#region src/scaffolding/kotlin/util/annotations.ts
|
|
318
|
+
var JS_EXPORT = "kotlin.js.JsExport";
|
|
319
|
+
var SERIALIZABLE = "kotlinx.serialization.Serializable";
|
|
320
|
+
function annotate(annotations, code) {
|
|
321
|
+
if (!annotations || annotations.length === 0) return code;
|
|
322
|
+
return [...typeof annotations === "string" ? [annotations] : annotations, code].join("\n");
|
|
323
|
+
}
|
|
324
|
+
function jsExport(code, data) {
|
|
325
|
+
data.currentFile.imports.add(JS_EXPORT);
|
|
326
|
+
return annotate(`@${simpleKtName(JS_EXPORT)}`, code);
|
|
327
|
+
}
|
|
328
|
+
function serializable(code, data) {
|
|
329
|
+
data.currentFile.imports.add(SERIALIZABLE);
|
|
330
|
+
return annotate(`@${simpleKtName(SERIALIZABLE)}`, code);
|
|
331
|
+
}
|
|
332
|
+
//#endregion
|
|
333
|
+
//#region src/scaffolding/scaffolders/scaffoldModels.ts
|
|
367
334
|
function scaffoldModels(schematic, data) {
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
335
|
+
const fileName = joinPaths(data.currentDir, `${schematic.name}.kt`);
|
|
336
|
+
let file = data.files.get(fileName);
|
|
337
|
+
if (!file) data.files.set(fileName, file = ktFile(data));
|
|
338
|
+
scaffoldModelDeclaration(schematic, {
|
|
339
|
+
...data,
|
|
340
|
+
currentFile: file
|
|
341
|
+
});
|
|
374
342
|
}
|
|
375
343
|
function scaffoldModelDeclaration(schematic, data) {
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
const decl = schematicKind.scaffoldModel?.(schematic, data) ?? `typealias ${schematic.name} = ${scaffoldType(schematic, data)}`;
|
|
383
|
-
data.currentFile.declarations[nDecls] = schematicKind.scaffoldModel ? jsExport(serializable(decl, data), data) : decl;
|
|
344
|
+
const schematicKind = data.schematicKinds.get(schematic.kind);
|
|
345
|
+
if (!schematicKind) throw new Error(`Unknown schematic kind ${schematic.kind}`);
|
|
346
|
+
const nDecls = data.currentFile.declarations.length;
|
|
347
|
+
data.currentFile.declarations.push("");
|
|
348
|
+
const decl = schematicKind.scaffoldModel?.(schematic, data) ?? `typealias ${schematic.name} = ${scaffoldType(schematic, data)}`;
|
|
349
|
+
data.currentFile.declarations[nDecls] = schematicKind.scaffoldModel ? jsExport(serializable(decl, data), data) : decl;
|
|
384
350
|
}
|
|
385
351
|
function scaffoldPropertyAnnotations(schematic, data) {
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
}
|
|
390
|
-
return typeof schematicKind.propertyAnnotations === "function" ? schematicKind.propertyAnnotations(schematic, data) : schematicKind.propertyAnnotations;
|
|
352
|
+
const schematicKind = data.schematicKinds.get(schematic.kind);
|
|
353
|
+
if (!schematicKind) throw new Error(`Unknown schematic kind ${schematic.kind}`);
|
|
354
|
+
return typeof schematicKind.propertyAnnotations === "function" ? schematicKind.propertyAnnotations(schematic, data) : schematicKind.propertyAnnotations;
|
|
391
355
|
}
|
|
392
356
|
function scaffoldType(schematic, data) {
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
currentPackage: joinPackages(
|
|
406
|
-
data.currentPackage,
|
|
407
|
-
schematic.packageSuffix
|
|
408
|
-
),
|
|
409
|
-
currentDir: joinPaths(
|
|
410
|
-
data.currentDir,
|
|
411
|
-
schematic.packageSuffix?.replace(".", "/")
|
|
412
|
-
)
|
|
413
|
-
});
|
|
414
|
-
} else if (schematicKind.scaffoldModel) {
|
|
415
|
-
scaffoldModelDeclaration(schematic, data);
|
|
416
|
-
}
|
|
417
|
-
return (schematicKind.scaffoldType?.(schematic, data) ?? schematicName) + (schematic.nullable ? "?" : "");
|
|
357
|
+
const schematicKind = data.schematicKinds.get(schematic.kind);
|
|
358
|
+
if (!schematicKind) throw new Error(`Unknown schematic kind ${schematic.kind}`);
|
|
359
|
+
const schematicPackage = schematicKind.package ?? joinPackages(data.currentPackage, schematic.packageSuffix);
|
|
360
|
+
const schematicName = schematic.name || schematicKind.name;
|
|
361
|
+
if (schematicPackage !== data.currentPackage) data.currentFile.imports.add(joinPackages(schematicPackage, schematicName));
|
|
362
|
+
if (schematicKind.package == null && schematicPackage !== data.currentPackage) scaffoldModels(schematic, {
|
|
363
|
+
...data,
|
|
364
|
+
currentPackage: joinPackages(data.currentPackage, schematic.packageSuffix),
|
|
365
|
+
currentDir: joinPaths(data.currentDir, schematic.packageSuffix?.replace(".", "/"))
|
|
366
|
+
});
|
|
367
|
+
else if (schematicKind.scaffoldModel) scaffoldModelDeclaration(schematic, data);
|
|
368
|
+
return (schematicKind.scaffoldType?.(schematic, data) ?? schematicName) + (schematic.nullable ? "?" : "");
|
|
418
369
|
}
|
|
419
370
|
function scaffoldDefaultValue(schematic, data) {
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
371
|
+
const schematicKind = data.schematicKinds.get(schematic.kind);
|
|
372
|
+
if (!schematicKind) throw new Error(`Unknown schematic kind ${schematic.kind}`);
|
|
373
|
+
return schematic.nullable ? "null" : typeof schematicKind.defaultValue === "function" ? schematicKind.defaultValue(schematic, data) : schematicKind.defaultValue;
|
|
374
|
+
}
|
|
375
|
+
//#endregion
|
|
376
|
+
//#region ../../node_modules/change-case/dist/index.js
|
|
377
|
+
var SPLIT_LOWER_UPPER_RE = /([\p{Ll}\d])(\p{Lu})/gu;
|
|
378
|
+
var SPLIT_UPPER_UPPER_RE = /(\p{Lu})([\p{Lu}][\p{Ll}])/gu;
|
|
379
|
+
var SPLIT_SEPARATE_NUMBER_RE = /(\d)\p{Ll}|(\p{L})\d/u;
|
|
380
|
+
var DEFAULT_STRIP_REGEXP = /[^\p{L}\d]+/giu;
|
|
381
|
+
var SPLIT_REPLACE_VALUE = "$1\0$2";
|
|
382
|
+
var DEFAULT_PREFIX_SUFFIX_CHARACTERS = "";
|
|
383
|
+
/**
|
|
384
|
+
* Split any cased input strings into an array of words.
|
|
385
|
+
*/
|
|
432
386
|
function split(value) {
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
387
|
+
let result = value.trim();
|
|
388
|
+
result = result.replace(SPLIT_LOWER_UPPER_RE, SPLIT_REPLACE_VALUE).replace(SPLIT_UPPER_UPPER_RE, SPLIT_REPLACE_VALUE);
|
|
389
|
+
result = result.replace(DEFAULT_STRIP_REGEXP, "\0");
|
|
390
|
+
let start = 0;
|
|
391
|
+
let end = result.length;
|
|
392
|
+
while (result.charAt(start) === "\0") start++;
|
|
393
|
+
if (start === end) return [];
|
|
394
|
+
while (result.charAt(end - 1) === "\0") end--;
|
|
395
|
+
return result.slice(start, end).split(/\0/g);
|
|
396
|
+
}
|
|
397
|
+
/**
|
|
398
|
+
* Split the input string into an array of words, separating numbers.
|
|
399
|
+
*/
|
|
446
400
|
function splitSeparateNumbers(value) {
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
}
|
|
401
|
+
const words = split(value);
|
|
402
|
+
for (let i = 0; i < words.length; i++) {
|
|
403
|
+
const word = words[i];
|
|
404
|
+
const match = SPLIT_SEPARATE_NUMBER_RE.exec(word);
|
|
405
|
+
if (match) {
|
|
406
|
+
const offset = match.index + (match[1] ?? match[2]).length;
|
|
407
|
+
words.splice(i, 1, word.slice(0, offset), word.slice(offset));
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
return words;
|
|
411
|
+
}
|
|
412
|
+
/**
|
|
413
|
+
* Convert a string to camel case (`fooBar`).
|
|
414
|
+
*/
|
|
458
415
|
function camelCase(input, options) {
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
416
|
+
const [prefix, words, suffix] = splitPrefixSuffix(input, options);
|
|
417
|
+
const lower = lowerFactory(options?.locale);
|
|
418
|
+
const upper = upperFactory(options?.locale);
|
|
419
|
+
const transform = options?.mergeAmbiguousCharacters ? capitalCaseTransformFactory(lower, upper) : pascalCaseTransformFactory(lower, upper);
|
|
420
|
+
return prefix + words.map((word, index) => {
|
|
421
|
+
if (index === 0) return lower(word);
|
|
422
|
+
return transform(word, index);
|
|
423
|
+
}).join(options?.delimiter ?? "") + suffix;
|
|
424
|
+
}
|
|
425
|
+
/**
|
|
426
|
+
* Convert a string to pascal case (`FooBar`).
|
|
427
|
+
*/
|
|
469
428
|
function pascalCase(input, options) {
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
429
|
+
const [prefix, words, suffix] = splitPrefixSuffix(input, options);
|
|
430
|
+
const lower = lowerFactory(options?.locale);
|
|
431
|
+
const upper = upperFactory(options?.locale);
|
|
432
|
+
const transform = options?.mergeAmbiguousCharacters ? capitalCaseTransformFactory(lower, upper) : pascalCaseTransformFactory(lower, upper);
|
|
433
|
+
return prefix + words.map(transform).join(options?.delimiter ?? "") + suffix;
|
|
475
434
|
}
|
|
476
435
|
function lowerFactory(locale) {
|
|
477
|
-
|
|
436
|
+
return locale === false ? (input) => input.toLowerCase() : (input) => input.toLocaleLowerCase(locale);
|
|
478
437
|
}
|
|
479
438
|
function upperFactory(locale) {
|
|
480
|
-
|
|
439
|
+
return locale === false ? (input) => input.toUpperCase() : (input) => input.toLocaleUpperCase(locale);
|
|
440
|
+
}
|
|
441
|
+
function capitalCaseTransformFactory(lower, upper) {
|
|
442
|
+
return (word) => `${upper(word[0])}${lower(word.slice(1))}`;
|
|
481
443
|
}
|
|
482
444
|
function pascalCaseTransformFactory(lower, upper) {
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
};
|
|
445
|
+
return (word, index) => {
|
|
446
|
+
const char0 = word[0];
|
|
447
|
+
return (index > 0 && char0 >= "0" && char0 <= "9" ? "_" + char0 : upper(char0)) + lower(word.slice(1));
|
|
448
|
+
};
|
|
488
449
|
}
|
|
489
450
|
function splitPrefixSuffix(input, options = {}) {
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
451
|
+
const splitFn = options.split ?? (options.separateNumbers ? splitSeparateNumbers : split);
|
|
452
|
+
const prefixCharacters = options.prefixCharacters ?? DEFAULT_PREFIX_SUFFIX_CHARACTERS;
|
|
453
|
+
const suffixCharacters = options.suffixCharacters ?? DEFAULT_PREFIX_SUFFIX_CHARACTERS;
|
|
454
|
+
let prefixIndex = 0;
|
|
455
|
+
let suffixIndex = input.length;
|
|
456
|
+
while (prefixIndex < input.length) {
|
|
457
|
+
const char = input.charAt(prefixIndex);
|
|
458
|
+
if (!prefixCharacters.includes(char)) break;
|
|
459
|
+
prefixIndex++;
|
|
460
|
+
}
|
|
461
|
+
while (suffixIndex > prefixIndex) {
|
|
462
|
+
const index = suffixIndex - 1;
|
|
463
|
+
const char = input.charAt(index);
|
|
464
|
+
if (!suffixCharacters.includes(char)) break;
|
|
465
|
+
suffixIndex = index;
|
|
466
|
+
}
|
|
467
|
+
return [
|
|
468
|
+
input.slice(0, prefixIndex),
|
|
469
|
+
splitFn(input.slice(prefixIndex, suffixIndex)),
|
|
470
|
+
input.slice(suffixIndex)
|
|
471
|
+
];
|
|
472
|
+
}
|
|
473
|
+
//#endregion
|
|
474
|
+
//#region src/util/boolDataAttr.ts
|
|
475
|
+
/** Value for a data attribute given a condition. */
|
|
514
476
|
function boolDataAttr(condition) {
|
|
515
|
-
|
|
516
|
-
}
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
477
|
+
return condition ? "" : void 0;
|
|
478
|
+
}
|
|
479
|
+
//#endregion
|
|
480
|
+
//#region src/util/preventDrag.ts
|
|
481
|
+
/** Properties used to prevent an element from being dragged. */
|
|
482
|
+
var preventDrag = {
|
|
483
|
+
onKeyDown: (evt) => evt.stopPropagation(),
|
|
484
|
+
onPointerDown: (evt) => evt.stopPropagation()
|
|
520
485
|
};
|
|
486
|
+
//#endregion
|
|
487
|
+
//#region src/schematicBuilders/util/ChildMarker.tsx
|
|
521
488
|
function ChildMarker() {
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
}
|
|
489
|
+
const { schematicKinds, useSchematic, setSchematic } = useSchematicBuilderContext();
|
|
490
|
+
const kind = useSchematic((schematic) => schematic.kind);
|
|
491
|
+
const collapsed = useSchematic((schematic) => schematic.collapsed);
|
|
492
|
+
return schematicKinds.get(kind)?.builder ? /* @__PURE__ */ jsx("button", {
|
|
493
|
+
type: "button",
|
|
494
|
+
className: "builder-child-marker",
|
|
495
|
+
title: collapsed ? "Expand" : "Collapse",
|
|
496
|
+
onClick: () => setSchematic((schematic) => ({ collapsed: !schematic.collapsed })),
|
|
497
|
+
...preventDrag,
|
|
498
|
+
children: collapsed ? "▸" : "▾"
|
|
499
|
+
}) : /* @__PURE__ */ jsx("span", {
|
|
500
|
+
className: "builder-child-marker",
|
|
501
|
+
children: "•"
|
|
502
|
+
});
|
|
503
|
+
}
|
|
504
|
+
//#endregion
|
|
505
|
+
//#region src/schematicBuilders/util/ChildRemove.tsx
|
|
540
506
|
function ChildRemove() {
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
const KIND_PLACEHOLDER = "--KIND--";
|
|
507
|
+
const { removeSchematic } = useSchematicBuilderContext();
|
|
508
|
+
return /* @__PURE__ */ jsx("button", {
|
|
509
|
+
className: "builder-icon-button builder-child-remove",
|
|
510
|
+
type: "button",
|
|
511
|
+
title: "Remove",
|
|
512
|
+
onClick: removeSchematic,
|
|
513
|
+
...preventDrag,
|
|
514
|
+
children: "×"
|
|
515
|
+
});
|
|
516
|
+
}
|
|
517
|
+
//#endregion
|
|
518
|
+
//#region src/schematicBuilders/util/KindSelect.tsx
|
|
519
|
+
var KIND_PLACEHOLDER = "--KIND--";
|
|
555
520
|
function KindSelect() {
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
Array.from(schematicKinds.values()).filter((kind2) => !kind2.internal).map((kind2) => /* @__PURE__ */ jsx("option", { value: kind2.kind, children: kind2.kind }, kind2.kind))
|
|
584
|
-
]
|
|
585
|
-
}
|
|
586
|
-
);
|
|
587
|
-
}
|
|
521
|
+
const { schematicKinds, useSchematic, setSchematic, parentChildName } = useSchematicBuilderContext();
|
|
522
|
+
const kind = useSchematic((schematic) => schematic.kind);
|
|
523
|
+
return /* @__PURE__ */ jsxs("select", {
|
|
524
|
+
className: "builder-input builder-schema",
|
|
525
|
+
value: kind,
|
|
526
|
+
onChange: (evt) => {
|
|
527
|
+
const schematicKind = schematicKinds.get(evt.target.value);
|
|
528
|
+
setSchematic({
|
|
529
|
+
kind: evt.target.value,
|
|
530
|
+
packageSuffix: schematicKind?.defaultPackageSuffix?.(parentChildName),
|
|
531
|
+
name: schematicKind?.defaultName?.(parentChildName),
|
|
532
|
+
collapsed: false,
|
|
533
|
+
nullable: schematicKind?.nullable ?? schematicKind?.defaultNullable,
|
|
534
|
+
children: schematicKind?.initChildren?.(parentChildName)
|
|
535
|
+
});
|
|
536
|
+
},
|
|
537
|
+
required: true,
|
|
538
|
+
style: { width: `calc(${(kind || KIND_PLACEHOLDER).length}ch + 1.85rem)` },
|
|
539
|
+
...preventDrag,
|
|
540
|
+
children: [/* @__PURE__ */ jsx("option", { children: KIND_PLACEHOLDER }), Array.from(schematicKinds.values()).filter((kind) => !kind.internal).map((kind) => /* @__PURE__ */ jsx("option", {
|
|
541
|
+
value: kind.kind,
|
|
542
|
+
children: kind.kind
|
|
543
|
+
}, kind.kind))]
|
|
544
|
+
});
|
|
545
|
+
}
|
|
546
|
+
//#endregion
|
|
547
|
+
//#region src/schematicBuilders/util/NullableInput.tsx
|
|
588
548
|
function NullableInput() {
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
const PACKAGE_PLACEHOLDER = "package.suffix";
|
|
607
|
-
const NAME_PLACEHOLDER = "ClassName";
|
|
549
|
+
const { schematicKinds, useSchematic, setSchematic } = useSchematicBuilderContext();
|
|
550
|
+
const kind = useSchematic((schematic) => schematic.kind);
|
|
551
|
+
const nullable = useSchematic((schematic) => !!schematic.nullable);
|
|
552
|
+
const schematicKind = schematicKinds.get(kind);
|
|
553
|
+
return schematicKind && schematicKind.nullable === void 0 && /* @__PURE__ */ jsx("input", {
|
|
554
|
+
className: "builder-input builder-nullable",
|
|
555
|
+
type: "checkbox",
|
|
556
|
+
title: "Nullable?",
|
|
557
|
+
checked: nullable,
|
|
558
|
+
onChange: (evt) => setSchematic({ nullable: evt.target.checked }),
|
|
559
|
+
...preventDrag
|
|
560
|
+
});
|
|
561
|
+
}
|
|
562
|
+
//#endregion
|
|
563
|
+
//#region src/schematicBuilders/util/PackageNameInput.tsx
|
|
564
|
+
var PACKAGE_PLACEHOLDER = "package.suffix";
|
|
565
|
+
var NAME_PLACEHOLDER = "ClassName";
|
|
608
566
|
function PackageNameInput() {
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
const CLASS_DND_TYPE = "class-field";
|
|
567
|
+
const { useSchematic, setSchematic, parentPackage } = useSchematicBuilderContext();
|
|
568
|
+
const pkgRef = useRef(null);
|
|
569
|
+
const packageSuffix = useSchematic((schematic) => schematic.packageSuffix);
|
|
570
|
+
const name = useSchematic((schematic) => schematic.name);
|
|
571
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
572
|
+
className: "builder-package-name",
|
|
573
|
+
children: [
|
|
574
|
+
parentPackage && /* @__PURE__ */ jsxs("span", {
|
|
575
|
+
className: "builder-package-prefix",
|
|
576
|
+
children: [parentPackage, "."]
|
|
577
|
+
}),
|
|
578
|
+
/* @__PURE__ */ jsx("input", {
|
|
579
|
+
className: "builder-input builder-package",
|
|
580
|
+
placeholder: PACKAGE_PLACEHOLDER,
|
|
581
|
+
value: packageSuffix ?? "",
|
|
582
|
+
onChange: (evt) => setSchematic({ packageSuffix: evt.target.value }),
|
|
583
|
+
pattern: "(([a-z_][a-z0-9_]*)(\\.([a-z_][a-z0-9_]*))*)?",
|
|
584
|
+
style: { width: `${(packageSuffix || PACKAGE_PLACEHOLDER).length}ch` },
|
|
585
|
+
...preventDrag,
|
|
586
|
+
ref: pkgRef
|
|
587
|
+
}),
|
|
588
|
+
/* @__PURE__ */ jsx("button", {
|
|
589
|
+
type: "button",
|
|
590
|
+
className: "builder-icon-button builder-edit-package",
|
|
591
|
+
onClick: () => {
|
|
592
|
+
const pkgInput = pkgRef.current;
|
|
593
|
+
pkgInput.style.display = "initial";
|
|
594
|
+
pkgInput.focus();
|
|
595
|
+
pkgInput.style.display = "";
|
|
596
|
+
},
|
|
597
|
+
children: "🖉"
|
|
598
|
+
}),
|
|
599
|
+
/* @__PURE__ */ jsx("span", {
|
|
600
|
+
className: "builder-operator",
|
|
601
|
+
children: "."
|
|
602
|
+
}),
|
|
603
|
+
/* @__PURE__ */ jsx("input", {
|
|
604
|
+
className: "builder-input builder-name",
|
|
605
|
+
placeholder: NAME_PLACEHOLDER,
|
|
606
|
+
value: name ?? "",
|
|
607
|
+
onChange: (evt) => setSchematic({ name: evt.target.value }),
|
|
608
|
+
required: true,
|
|
609
|
+
pattern: "[a-zA-Z_][a-zA-Z0-9_]*",
|
|
610
|
+
style: { width: `${(name || NAME_PLACEHOLDER).length}ch` },
|
|
611
|
+
...preventDrag
|
|
612
|
+
})
|
|
613
|
+
]
|
|
614
|
+
});
|
|
615
|
+
}
|
|
616
|
+
//#endregion
|
|
617
|
+
//#region src/schematicBuilders/ClassBuilder.tsx
|
|
618
|
+
var CLASS_DND_TYPE = "class-field";
|
|
662
619
|
function ClassBuilder() {
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
...schematic,
|
|
733
|
-
children: [
|
|
734
|
-
...schematic.children ?? [],
|
|
735
|
-
createSchematic({ childName: "" })
|
|
736
|
-
]
|
|
737
|
-
}));
|
|
738
|
-
},
|
|
739
|
-
...preventDrag,
|
|
740
|
-
children: "Add field"
|
|
741
|
-
}
|
|
742
|
-
)
|
|
743
|
-
] });
|
|
744
|
-
}
|
|
745
|
-
const CHILD_NAME_PLACEHOLDER$1 = "fieldName";
|
|
620
|
+
const schematicBuilderContext = useSchematicBuilderContext();
|
|
621
|
+
const { useSchematic, setSchematic, draggedSchematic, disableDrop } = schematicBuilderContext;
|
|
622
|
+
const id = useSchematic((schematic) => schematic.id);
|
|
623
|
+
const packageSuffix = useSchematic((schematic) => schematic.packageSuffix);
|
|
624
|
+
const fields = useSchematic((schematic) => schematic.children) ?? [];
|
|
625
|
+
const shouldIgnoreDrop = draggedSchematic != null && draggedSchematic.id === fields.at(-1)?.id;
|
|
626
|
+
const { setNodeRef: setDroppableRef, isOver } = useDroppable({
|
|
627
|
+
id: `${id}-append`,
|
|
628
|
+
data: {
|
|
629
|
+
parentId: id,
|
|
630
|
+
sortBefore: null,
|
|
631
|
+
ignored: shouldIgnoreDrop
|
|
632
|
+
},
|
|
633
|
+
disabled: disableDrop || draggedSchematic?.type !== "class-field"
|
|
634
|
+
});
|
|
635
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
636
|
+
className: "class-builder builder",
|
|
637
|
+
children: [
|
|
638
|
+
/* @__PURE__ */ jsx(PackageNameInput, {}),
|
|
639
|
+
fields.length === 0 && /* @__PURE__ */ jsx("div", {
|
|
640
|
+
className: "builder-empty",
|
|
641
|
+
"data-over": boolDataAttr(isOver),
|
|
642
|
+
ref: setDroppableRef,
|
|
643
|
+
children: "No fields."
|
|
644
|
+
}),
|
|
645
|
+
fields.length > 0 && /* @__PURE__ */ jsxs("ul", {
|
|
646
|
+
className: "builder-children",
|
|
647
|
+
children: [fields.map((field, i) => /* @__PURE__ */ jsx(SchematicBuilderContext.Provider, {
|
|
648
|
+
value: {
|
|
649
|
+
...schematicBuilderContext,
|
|
650
|
+
useSchematic: (selector) => useSchematic((schematic) => selector(schematic.children[i])),
|
|
651
|
+
setSchematic: (toSet) => setSchematic((schematic) => ({
|
|
652
|
+
...schematic,
|
|
653
|
+
children: schematic.children.map((f) => field === f ? {
|
|
654
|
+
...f,
|
|
655
|
+
...typeof toSet === "function" ? toSet(f) : toSet
|
|
656
|
+
} : f)
|
|
657
|
+
})),
|
|
658
|
+
removeSchematic: () => setSchematic((schematic) => ({
|
|
659
|
+
...schematic,
|
|
660
|
+
children: schematic.children.filter((f) => f !== field)
|
|
661
|
+
})),
|
|
662
|
+
parentPackage: joinPackages(schematicBuilderContext.parentPackage, packageSuffix),
|
|
663
|
+
parentId: id,
|
|
664
|
+
ignoreDrop: draggedSchematic != null && draggedSchematic.id === fields[i - 1]?.id
|
|
665
|
+
},
|
|
666
|
+
children: /* @__PURE__ */ jsx(ClassFieldBuilder, {})
|
|
667
|
+
}, field.id)), /* @__PURE__ */ jsx("li", {
|
|
668
|
+
className: "builder-child-droppable",
|
|
669
|
+
"data-over": boolDataAttr(isOver && !shouldIgnoreDrop),
|
|
670
|
+
ref: setDroppableRef
|
|
671
|
+
})]
|
|
672
|
+
}),
|
|
673
|
+
/* @__PURE__ */ jsx("button", {
|
|
674
|
+
className: "builder-input builder-new-child",
|
|
675
|
+
type: "button",
|
|
676
|
+
onClick: () => {
|
|
677
|
+
setSchematic((schematic) => ({
|
|
678
|
+
...schematic,
|
|
679
|
+
children: [...schematic.children ?? [], createSchematic({ childName: "" })]
|
|
680
|
+
}));
|
|
681
|
+
},
|
|
682
|
+
...preventDrag,
|
|
683
|
+
children: "Add field"
|
|
684
|
+
})
|
|
685
|
+
]
|
|
686
|
+
});
|
|
687
|
+
}
|
|
688
|
+
var CHILD_NAME_PLACEHOLDER$1 = "fieldName";
|
|
746
689
|
function ClassFieldBuilder() {
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
value: { ...schematicBuilderContext, parentChildName: childName },
|
|
825
|
-
children: /* @__PURE__ */ jsx(KindSelect, {})
|
|
826
|
-
}
|
|
827
|
-
),
|
|
828
|
-
/* @__PURE__ */ jsx(NullableInput, {}),
|
|
829
|
-
/* @__PURE__ */ jsx(ChildRemove, {})
|
|
830
|
-
] }),
|
|
831
|
-
Builder && !collapsed && /* @__PURE__ */ jsx(
|
|
832
|
-
SchematicBuilderContext.Provider,
|
|
833
|
-
{
|
|
834
|
-
value: {
|
|
835
|
-
...schematicBuilderContext,
|
|
836
|
-
parentChildName: childName,
|
|
837
|
-
disableDrop: disableDrop || isDragging
|
|
838
|
-
},
|
|
839
|
-
children: /* @__PURE__ */ jsx(Builder, {})
|
|
840
|
-
}
|
|
841
|
-
)
|
|
842
|
-
]
|
|
843
|
-
}
|
|
844
|
-
)
|
|
845
|
-
] });
|
|
846
|
-
}
|
|
847
|
-
const ENUM_DND_TYPE = "enum-entry";
|
|
690
|
+
const schematicBuilderContext = useSchematicBuilderContext();
|
|
691
|
+
const { schematicKinds, useSchematic, setSchematic, draggedSchematic, parentId, disableDrop, ignoreDrop } = schematicBuilderContext;
|
|
692
|
+
const id = useSchematic((schematic) => schematic.id);
|
|
693
|
+
const childName = useSchematic((schematic) => schematic.childName);
|
|
694
|
+
const kind = useSchematic((schematic) => schematic.kind);
|
|
695
|
+
const nullable = useSchematic((schematic) => schematic.nullable);
|
|
696
|
+
const collapsed = useSchematic((schematic) => schematic.collapsed);
|
|
697
|
+
const Builder = schematicKinds.get(kind)?.builder;
|
|
698
|
+
const { attributes, listeners, setNodeRef: setDraggableRef, isDragging } = useDraggable({
|
|
699
|
+
id,
|
|
700
|
+
data: {
|
|
701
|
+
type: CLASS_DND_TYPE,
|
|
702
|
+
node: /* @__PURE__ */ jsxs(Fragment, { children: [[childName, kind].filter((s) => s).join(": "), nullable ? "?" : ""] })
|
|
703
|
+
}
|
|
704
|
+
});
|
|
705
|
+
const shouldIgnoreDrop = isDragging || ignoreDrop;
|
|
706
|
+
const { setNodeRef: setDroppableRef, isOver } = useDroppable({
|
|
707
|
+
id,
|
|
708
|
+
data: {
|
|
709
|
+
parentId,
|
|
710
|
+
sortBefore: id,
|
|
711
|
+
ignored: shouldIgnoreDrop
|
|
712
|
+
},
|
|
713
|
+
disabled: disableDrop || draggedSchematic?.type !== "class-field"
|
|
714
|
+
});
|
|
715
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("li", {
|
|
716
|
+
className: "builder-child-droppable",
|
|
717
|
+
"data-over": boolDataAttr(isOver && !shouldIgnoreDrop),
|
|
718
|
+
ref: setDroppableRef
|
|
719
|
+
}), /* @__PURE__ */ jsxs("li", {
|
|
720
|
+
className: "builder-child class-builder-field",
|
|
721
|
+
"data-dragging": boolDataAttr(isDragging),
|
|
722
|
+
...listeners,
|
|
723
|
+
...attributes,
|
|
724
|
+
ref: setDraggableRef,
|
|
725
|
+
"data-collapsible": boolDataAttr(Builder != null),
|
|
726
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
727
|
+
className: "builder-child-content",
|
|
728
|
+
children: [
|
|
729
|
+
/* @__PURE__ */ jsx(ChildMarker, {}),
|
|
730
|
+
/* @__PURE__ */ jsx("input", {
|
|
731
|
+
className: "builder-input class-builder-field-id",
|
|
732
|
+
placeholder: CHILD_NAME_PLACEHOLDER$1,
|
|
733
|
+
value: childName,
|
|
734
|
+
onChange: (evt) => setSchematic({ childName: evt.target.value }),
|
|
735
|
+
required: true,
|
|
736
|
+
pattern: "[a-zA-Z_][a-zA-Z0-9_]*",
|
|
737
|
+
style: { width: `${(childName || CHILD_NAME_PLACEHOLDER$1).length}ch` },
|
|
738
|
+
...preventDrag
|
|
739
|
+
}),
|
|
740
|
+
/* @__PURE__ */ jsx("span", {
|
|
741
|
+
className: "builder-operator",
|
|
742
|
+
children: "∶"
|
|
743
|
+
}),
|
|
744
|
+
/* @__PURE__ */ jsx(SchematicBuilderContext.Provider, {
|
|
745
|
+
value: {
|
|
746
|
+
...schematicBuilderContext,
|
|
747
|
+
parentChildName: childName
|
|
748
|
+
},
|
|
749
|
+
children: /* @__PURE__ */ jsx(KindSelect, {})
|
|
750
|
+
}),
|
|
751
|
+
/* @__PURE__ */ jsx(NullableInput, {}),
|
|
752
|
+
/* @__PURE__ */ jsx(ChildRemove, {})
|
|
753
|
+
]
|
|
754
|
+
}), Builder && !collapsed && /* @__PURE__ */ jsx(SchematicBuilderContext.Provider, {
|
|
755
|
+
value: {
|
|
756
|
+
...schematicBuilderContext,
|
|
757
|
+
parentChildName: childName,
|
|
758
|
+
disableDrop: disableDrop || isDragging
|
|
759
|
+
},
|
|
760
|
+
children: /* @__PURE__ */ jsx(Builder, {})
|
|
761
|
+
})]
|
|
762
|
+
})] });
|
|
763
|
+
}
|
|
764
|
+
//#endregion
|
|
765
|
+
//#region src/schematicBuilders/EnumBuilder.tsx
|
|
766
|
+
var ENUM_DND_TYPE = "enum-entry";
|
|
848
767
|
function EnumBuilder() {
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
createSchematic({ childName: "" })
|
|
917
|
-
]
|
|
918
|
-
}));
|
|
919
|
-
},
|
|
920
|
-
...preventDrag,
|
|
921
|
-
children: "Add entry"
|
|
922
|
-
}
|
|
923
|
-
)
|
|
924
|
-
] });
|
|
925
|
-
}
|
|
926
|
-
const CHILD_NAME_PLACEHOLDER = "ENTRY_NAME";
|
|
768
|
+
const schematicBuilderContext = useSchematicBuilderContext();
|
|
769
|
+
const { useSchematic, setSchematic, draggedSchematic, disableDrop } = schematicBuilderContext;
|
|
770
|
+
const id = useSchematic((schematic) => schematic.id);
|
|
771
|
+
const fields = useSchematic((schematic) => schematic.children) ?? [];
|
|
772
|
+
const shouldIgnoreDrop = draggedSchematic != null && draggedSchematic.id === fields.at(-1)?.id;
|
|
773
|
+
const { setNodeRef: setDroppableRef, isOver } = useDroppable({
|
|
774
|
+
id: `${id}-append`,
|
|
775
|
+
data: {
|
|
776
|
+
parentId: id,
|
|
777
|
+
sortBefore: null,
|
|
778
|
+
ignored: shouldIgnoreDrop
|
|
779
|
+
},
|
|
780
|
+
disabled: disableDrop || draggedSchematic?.type !== "enum-entry"
|
|
781
|
+
});
|
|
782
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
783
|
+
className: "enum-builder builder",
|
|
784
|
+
children: [
|
|
785
|
+
/* @__PURE__ */ jsx(PackageNameInput, {}),
|
|
786
|
+
fields.length === 0 && /* @__PURE__ */ jsx("div", {
|
|
787
|
+
className: "builder-empty",
|
|
788
|
+
"data-over": boolDataAttr(isOver),
|
|
789
|
+
ref: setDroppableRef,
|
|
790
|
+
children: "No entries."
|
|
791
|
+
}),
|
|
792
|
+
fields.length > 0 && /* @__PURE__ */ jsxs("ul", {
|
|
793
|
+
className: "builder-children",
|
|
794
|
+
children: [fields.map((field, i) => /* @__PURE__ */ jsx(SchematicBuilderContext.Provider, {
|
|
795
|
+
value: {
|
|
796
|
+
...schematicBuilderContext,
|
|
797
|
+
useSchematic: (selector) => useSchematic((schematic) => selector(schematic.children[i])),
|
|
798
|
+
setSchematic: (toSet) => setSchematic((schematic) => ({
|
|
799
|
+
...schematic,
|
|
800
|
+
children: schematic.children.map((f) => field === f ? {
|
|
801
|
+
...f,
|
|
802
|
+
...typeof toSet === "function" ? toSet(f) : toSet
|
|
803
|
+
} : f)
|
|
804
|
+
})),
|
|
805
|
+
removeSchematic: () => setSchematic((schematic) => ({
|
|
806
|
+
...schematic,
|
|
807
|
+
children: schematic.children.filter((f) => f !== field)
|
|
808
|
+
})),
|
|
809
|
+
parentId: id,
|
|
810
|
+
ignoreDrop: draggedSchematic != null && draggedSchematic.id === fields[i - 1]?.id
|
|
811
|
+
},
|
|
812
|
+
children: /* @__PURE__ */ jsx(EnumEntryBuilder, {})
|
|
813
|
+
}, field.id)), /* @__PURE__ */ jsx("li", {
|
|
814
|
+
className: "builder-child-droppable",
|
|
815
|
+
"data-over": boolDataAttr(isOver && !shouldIgnoreDrop),
|
|
816
|
+
ref: setDroppableRef
|
|
817
|
+
})]
|
|
818
|
+
}),
|
|
819
|
+
/* @__PURE__ */ jsx("button", {
|
|
820
|
+
className: "builder-input builder-new-child",
|
|
821
|
+
type: "button",
|
|
822
|
+
onClick: () => {
|
|
823
|
+
setSchematic((schematic) => ({
|
|
824
|
+
...schematic,
|
|
825
|
+
children: [...schematic.children ?? [], createSchematic({ childName: "" })]
|
|
826
|
+
}));
|
|
827
|
+
},
|
|
828
|
+
...preventDrag,
|
|
829
|
+
children: "Add entry"
|
|
830
|
+
})
|
|
831
|
+
]
|
|
832
|
+
});
|
|
833
|
+
}
|
|
834
|
+
var CHILD_NAME_PLACEHOLDER = "ENTRY_NAME";
|
|
927
835
|
function EnumEntryBuilder() {
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
})
|
|
1004
|
-
|
|
1005
|
-
const { useSchematic, setSchematic } = schematicBuilderContext;
|
|
1006
|
-
const id = useSchematic((schematic) => schematic.id);
|
|
1007
|
-
return /* @__PURE__ */ jsx("div", { className: "listable-builder builder", children: /* @__PURE__ */ jsx(
|
|
1008
|
-
SchematicBuilderContext.Provider,
|
|
1009
|
-
{
|
|
1010
|
-
value: {
|
|
1011
|
-
...schematicBuilderContext,
|
|
1012
|
-
useSchematic: (selector) => useSchematic((schematic) => selector(schematic.children[0])),
|
|
1013
|
-
setSchematic: (toSet) => setSchematic((schematic) => ({
|
|
1014
|
-
...schematic,
|
|
1015
|
-
children: [
|
|
1016
|
-
{
|
|
1017
|
-
...schematic.children[0],
|
|
1018
|
-
...typeof toSet === "function" ? toSet(schematic.children[0]) : toSet
|
|
1019
|
-
}
|
|
1020
|
-
]
|
|
1021
|
-
})),
|
|
1022
|
-
removeSchematic: () => {
|
|
1023
|
-
},
|
|
1024
|
-
parentId: id
|
|
1025
|
-
},
|
|
1026
|
-
children: /* @__PURE__ */ jsx(ListableItemBuilder, { showKindSelect })
|
|
1027
|
-
}
|
|
1028
|
-
) });
|
|
836
|
+
const { schematicKinds, useSchematic, setSchematic, draggedSchematic, parentId, disableDrop, ignoreDrop } = useSchematicBuilderContext();
|
|
837
|
+
const id = useSchematic((schematic) => schematic.id);
|
|
838
|
+
const childName = useSchematic((schematic) => schematic.childName);
|
|
839
|
+
const kind = useSchematic((schematic) => schematic.kind);
|
|
840
|
+
const Builder = schematicKinds.get(kind)?.builder;
|
|
841
|
+
const { attributes, listeners, setNodeRef: setDraggableRef, isDragging } = useDraggable({
|
|
842
|
+
id,
|
|
843
|
+
data: {
|
|
844
|
+
type: ENUM_DND_TYPE,
|
|
845
|
+
node: /* @__PURE__ */ jsx(Fragment, { children: [childName, kind].filter((s) => s).join(": ") })
|
|
846
|
+
}
|
|
847
|
+
});
|
|
848
|
+
const shouldIgnoreDrop = isDragging || ignoreDrop;
|
|
849
|
+
const { setNodeRef: setDroppableRef, isOver } = useDroppable({
|
|
850
|
+
id,
|
|
851
|
+
data: {
|
|
852
|
+
parentId,
|
|
853
|
+
sortBefore: id,
|
|
854
|
+
ignored: shouldIgnoreDrop
|
|
855
|
+
},
|
|
856
|
+
disabled: disableDrop || draggedSchematic?.type !== "enum-entry"
|
|
857
|
+
});
|
|
858
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("li", {
|
|
859
|
+
className: "builder-child-droppable",
|
|
860
|
+
"data-over": boolDataAttr(isOver && !shouldIgnoreDrop),
|
|
861
|
+
ref: setDroppableRef
|
|
862
|
+
}), /* @__PURE__ */ jsx("li", {
|
|
863
|
+
className: "builder-child",
|
|
864
|
+
"data-dragging": boolDataAttr(isDragging),
|
|
865
|
+
...listeners,
|
|
866
|
+
...attributes,
|
|
867
|
+
ref: setDraggableRef,
|
|
868
|
+
"data-collapsible": boolDataAttr(Builder != null),
|
|
869
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
870
|
+
className: "builder-child-content",
|
|
871
|
+
children: [
|
|
872
|
+
/* @__PURE__ */ jsx(ChildMarker, {}),
|
|
873
|
+
/* @__PURE__ */ jsx("input", {
|
|
874
|
+
className: "builder-input enum-builder-entry-id",
|
|
875
|
+
placeholder: CHILD_NAME_PLACEHOLDER,
|
|
876
|
+
value: childName,
|
|
877
|
+
onChange: (evt) => setSchematic({ childName: evt.target.value }),
|
|
878
|
+
required: true,
|
|
879
|
+
pattern: "[a-zA-Z_][a-zA-Z0-9_]*",
|
|
880
|
+
style: { width: `${(childName || CHILD_NAME_PLACEHOLDER).length}ch` },
|
|
881
|
+
...preventDrag
|
|
882
|
+
}),
|
|
883
|
+
/* @__PURE__ */ jsx(ChildRemove, {})
|
|
884
|
+
]
|
|
885
|
+
})
|
|
886
|
+
})] });
|
|
887
|
+
}
|
|
888
|
+
//#endregion
|
|
889
|
+
//#region src/schematicBuilders/ListableBuilder.tsx
|
|
890
|
+
function ListableBuilder({ showKindSelect = true }) {
|
|
891
|
+
const schematicBuilderContext = useSchematicBuilderContext();
|
|
892
|
+
const { useSchematic, setSchematic } = schematicBuilderContext;
|
|
893
|
+
const id = useSchematic((schematic) => schematic.id);
|
|
894
|
+
return /* @__PURE__ */ jsx("div", {
|
|
895
|
+
className: "listable-builder builder",
|
|
896
|
+
children: /* @__PURE__ */ jsx(SchematicBuilderContext.Provider, {
|
|
897
|
+
value: {
|
|
898
|
+
...schematicBuilderContext,
|
|
899
|
+
useSchematic: (selector) => useSchematic((schematic) => selector(schematic.children[0])),
|
|
900
|
+
setSchematic: (toSet) => setSchematic((schematic) => ({
|
|
901
|
+
...schematic,
|
|
902
|
+
children: [{
|
|
903
|
+
...schematic.children[0],
|
|
904
|
+
...typeof toSet === "function" ? toSet(schematic.children[0]) : toSet
|
|
905
|
+
}]
|
|
906
|
+
})),
|
|
907
|
+
removeSchematic: () => {},
|
|
908
|
+
parentId: id
|
|
909
|
+
},
|
|
910
|
+
children: /* @__PURE__ */ jsx(ListableItemBuilder, { showKindSelect })
|
|
911
|
+
})
|
|
912
|
+
});
|
|
1029
913
|
}
|
|
1030
914
|
function ListableBuilderWithoutKindSelect() {
|
|
1031
|
-
|
|
1032
|
-
}
|
|
1033
|
-
function ListableItemBuilder({
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
const SPACE = /\s/;
|
|
1047
|
-
const LF_AFFIX = /(^\r?\n)|(\r?\n$)/g;
|
|
915
|
+
return /* @__PURE__ */ jsx(ListableBuilder, { showKindSelect: false });
|
|
916
|
+
}
|
|
917
|
+
function ListableItemBuilder({ showKindSelect = true }) {
|
|
918
|
+
const { schematicKinds, useSchematic } = useSchematicBuilderContext();
|
|
919
|
+
const kind = useSchematic((schematic) => schematic.kind);
|
|
920
|
+
const Builder = schematicKinds.get(kind)?.builder;
|
|
921
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [showKindSelect && /* @__PURE__ */ jsx(KindSelect, {}), Builder && /* @__PURE__ */ jsx(Builder, {})] });
|
|
922
|
+
}
|
|
923
|
+
//#endregion
|
|
924
|
+
//#region src/util/code.ts
|
|
925
|
+
var LF = /\r?\n/;
|
|
926
|
+
var EMPTY_LINE = /^\s*$/;
|
|
927
|
+
var SPACE = /\s/;
|
|
928
|
+
var LF_AFFIX = /(^\r?\n)|(\r?\n$)/g;
|
|
929
|
+
/** Tag function used to aid in the construction of code blocks. */
|
|
1048
930
|
function code(strings, ...values) {
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
indentWidth(trimmedString.split(LF).at(-1))
|
|
1059
|
-
);
|
|
1060
|
-
}
|
|
1061
|
-
result += trimNoninitialLines(strings.at(-1), minIndent);
|
|
1062
|
-
return result.replace(LF_AFFIX, "");
|
|
931
|
+
const minIndent = Math.min(...strings.join("").split(LF).filter(isNotEmpty).map(indentWidth));
|
|
932
|
+
let result = "";
|
|
933
|
+
for (let i = 0; i < values.length; ++i) {
|
|
934
|
+
const trimmedString = trimNoninitialLines(strings[i], minIndent);
|
|
935
|
+
result += trimmedString;
|
|
936
|
+
result += indentNoninitialLines(String(values[i]), indentWidth(trimmedString.split(LF).at(-1)));
|
|
937
|
+
}
|
|
938
|
+
result += trimNoninitialLines(strings.at(-1), minIndent);
|
|
939
|
+
return result.replace(LF_AFFIX, "");
|
|
1063
940
|
}
|
|
1064
941
|
function isNotEmpty(line) {
|
|
1065
|
-
|
|
942
|
+
return !EMPTY_LINE.test(line);
|
|
1066
943
|
}
|
|
1067
944
|
function indentWidth(line) {
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
defaultValue: "null",
|
|
1102
|
-
scaffoldType: () => "Any?"
|
|
945
|
+
let width = 0;
|
|
946
|
+
for (const c of line) {
|
|
947
|
+
if (!SPACE.test(c)) break;
|
|
948
|
+
++width;
|
|
949
|
+
}
|
|
950
|
+
return width;
|
|
951
|
+
}
|
|
952
|
+
function indentNoninitialLines(str, indentWidth) {
|
|
953
|
+
const lines = str.split(LF);
|
|
954
|
+
const resultLines = [lines[0]];
|
|
955
|
+
for (let i = 1; i < lines.length; ++i) {
|
|
956
|
+
const line = lines[i];
|
|
957
|
+
resultLines.push(line && " ".repeat(indentWidth) + line);
|
|
958
|
+
}
|
|
959
|
+
return resultLines.join("\n");
|
|
960
|
+
}
|
|
961
|
+
function trimNoninitialLines(str, indentWidth) {
|
|
962
|
+
const lines = str.split(LF);
|
|
963
|
+
const resultLines = [lines[0]];
|
|
964
|
+
for (let i = 1; i < lines.length; ++i) resultLines.push(lines[i].slice(indentWidth));
|
|
965
|
+
return resultLines.join("\n");
|
|
966
|
+
}
|
|
967
|
+
//#endregion
|
|
968
|
+
//#region src/SchematicKind.ts
|
|
969
|
+
var NULLABLE_SCHEMA = "tech.ostack.kform.schemas.NullableSchema";
|
|
970
|
+
var anySchematicKind = {
|
|
971
|
+
kind: "Any",
|
|
972
|
+
package: "kotlin",
|
|
973
|
+
name: "Any",
|
|
974
|
+
schema: "tech.ostack.kform.schemas.AnySchema",
|
|
975
|
+
nullable: false,
|
|
976
|
+
defaultValue: "null",
|
|
977
|
+
scaffoldType: () => "Any?"
|
|
1103
978
|
};
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
979
|
+
var bigDecimalSchematicKind = {
|
|
980
|
+
kind: "BigDecimal",
|
|
981
|
+
package: "tech.ostack.kform.datatypes",
|
|
982
|
+
name: "BigDecimal",
|
|
983
|
+
schema: "tech.ostack.kform.schemas.BigDecimalSchema",
|
|
984
|
+
defaultNullable: true,
|
|
985
|
+
defaultValue: "BigDecimal.ZERO"
|
|
1111
986
|
};
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
987
|
+
var bigIntegerSchematicKind = {
|
|
988
|
+
kind: "BigInteger",
|
|
989
|
+
package: "tech.ostack.kform.datatypes",
|
|
990
|
+
name: "BigInteger",
|
|
991
|
+
schema: "tech.ostack.kform.schemas.BigIntegerSchema",
|
|
992
|
+
defaultNullable: true,
|
|
993
|
+
defaultValue: "BigInteger.ZERO"
|
|
1119
994
|
};
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
995
|
+
var booleanSchematicKind = {
|
|
996
|
+
kind: "Boolean",
|
|
997
|
+
package: "kotlin",
|
|
998
|
+
name: "Boolean",
|
|
999
|
+
schema: "tech.ostack.kform.schemas.BooleanSchema",
|
|
1000
|
+
defaultValue: "false"
|
|
1126
1001
|
};
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1002
|
+
var byteSchematicKind = {
|
|
1003
|
+
kind: "Byte",
|
|
1004
|
+
package: "kotlin",
|
|
1005
|
+
name: "Byte",
|
|
1006
|
+
schema: "tech.ostack.kform.schemas.ByteSchema",
|
|
1007
|
+
defaultNullable: true,
|
|
1008
|
+
defaultValue: "0.toByte()"
|
|
1134
1009
|
};
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1010
|
+
var charSchematicKind = {
|
|
1011
|
+
kind: "Char",
|
|
1012
|
+
package: "kotlin",
|
|
1013
|
+
name: "Char",
|
|
1014
|
+
schema: "tech.ostack.kform.schemas.CharSchema",
|
|
1015
|
+
defaultNullable: true,
|
|
1016
|
+
defaultValue: "0.toChar()"
|
|
1142
1017
|
};
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1018
|
+
var classSchematicKind = {
|
|
1019
|
+
kind: "Class",
|
|
1020
|
+
schema: "tech.ostack.kform.schemas.ClassSchema",
|
|
1021
|
+
defaultValue: (schematic) => `${schematic.name}()`,
|
|
1022
|
+
builder: ClassBuilder,
|
|
1023
|
+
initChildren: () => [],
|
|
1024
|
+
defaultPackageSuffix: (childName) => childName.toLowerCase(),
|
|
1025
|
+
defaultName: (childName) => pascalCase(childName),
|
|
1026
|
+
scaffoldModel: (schematic, data) => code`
|
|
1152
1027
|
data class ${schematic.name}(
|
|
1153
1028
|
${schematic.children?.map((childSchematic) => {
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
};
|
|
1161
|
-
return annotate(
|
|
1162
|
-
scaffoldPropertyAnnotations(childSchematic, childData),
|
|
1163
|
-
`var ${childSchematic.childName}: ${scaffoldType(
|
|
1164
|
-
childSchematic,
|
|
1165
|
-
childData
|
|
1166
|
-
)} = ${scaffoldDefaultValue(childSchematic, childData)}`
|
|
1167
|
-
);
|
|
1168
|
-
}).join(",\n")}
|
|
1029
|
+
const childData = {
|
|
1030
|
+
...data,
|
|
1031
|
+
currentPath: joinPaths(data.currentPath, childSchematic.childName)
|
|
1032
|
+
};
|
|
1033
|
+
return annotate(scaffoldPropertyAnnotations(childSchematic, childData), `var ${childSchematic.childName}: ${scaffoldType(childSchematic, childData)} = ${scaffoldDefaultValue(childSchematic, childData)}`);
|
|
1034
|
+
}).join(",\n")}
|
|
1169
1035
|
)
|
|
1170
1036
|
`,
|
|
1171
|
-
|
|
1037
|
+
scaffoldSchema: (schematic, data) => code`
|
|
1172
1038
|
ClassSchema {
|
|
1173
|
-
${schematic.children?.map(
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
...data,
|
|
1178
|
-
currentPath: joinPaths(
|
|
1179
|
-
data.currentPath,
|
|
1180
|
-
childSchematic.childName
|
|
1181
|
-
)
|
|
1182
|
-
}
|
|
1183
|
-
)} }`
|
|
1184
|
-
).join("\n")}
|
|
1039
|
+
${schematic.children?.map((childSchematic) => `${schematic.name}::${childSchematic.childName} { ${scaffoldSchema(childSchematic, {
|
|
1040
|
+
...data,
|
|
1041
|
+
currentPath: joinPaths(data.currentPath, childSchematic.childName)
|
|
1042
|
+
})} }`).join("\n")}
|
|
1185
1043
|
}
|
|
1186
1044
|
`
|
|
1187
1045
|
};
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1046
|
+
var doubleSchematicKind = {
|
|
1047
|
+
kind: "Double",
|
|
1048
|
+
package: "kotlin",
|
|
1049
|
+
name: "Double",
|
|
1050
|
+
schema: "tech.ostack.kform.schemas.DoubleSchema",
|
|
1051
|
+
defaultNullable: true,
|
|
1052
|
+
defaultValue: "0.0"
|
|
1195
1053
|
};
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1054
|
+
var enumSchematicKind = {
|
|
1055
|
+
kind: "Enum",
|
|
1056
|
+
schema: "tech.ostack.kform.schemas.EnumSchema",
|
|
1057
|
+
defaultNullable: true,
|
|
1058
|
+
defaultValue: (schematic) => `${schematic.name}.${schematic.children?.[0].childName}`,
|
|
1059
|
+
builder: EnumBuilder,
|
|
1060
|
+
initChildren: () => [],
|
|
1061
|
+
defaultName: (childName) => pascalCase(childName),
|
|
1062
|
+
scaffoldModel: (schematic) => code`
|
|
1205
1063
|
enum class ${schematic.name} {
|
|
1206
1064
|
${schematic.children?.map((childSchematic) => childSchematic.childName).join(",\n")}
|
|
1207
1065
|
}
|
|
1208
1066
|
`
|
|
1209
1067
|
};
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
},
|
|
1222
|
-
propertyAnnotations: (_schematic, data) => data.useFileBase64Serializer ? "@Serializable(with = File.Base64Serializer::class)" : void 0
|
|
1068
|
+
var fileSchematicKind = {
|
|
1069
|
+
kind: "File",
|
|
1070
|
+
package: "tech.ostack.kform.datatypes",
|
|
1071
|
+
name: "File",
|
|
1072
|
+
schema: "tech.ostack.kform.schemas.FileSchema",
|
|
1073
|
+
defaultNullable: true,
|
|
1074
|
+
defaultValue: (_schematic, data) => {
|
|
1075
|
+
data.currentFile.imports.add("tech.ostack.kform.datatypes.emptyPlaceholderFile");
|
|
1076
|
+
return "emptyPlaceholderFile()";
|
|
1077
|
+
},
|
|
1078
|
+
propertyAnnotations: (_schematic, data) => data.useFileBase64Serializer ? "@Serializable(with = File.Base64Serializer::class)" : void 0
|
|
1223
1079
|
};
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1080
|
+
var floatSchematicKind = {
|
|
1081
|
+
kind: "Float",
|
|
1082
|
+
package: "kotlin",
|
|
1083
|
+
name: "Float",
|
|
1084
|
+
schema: "tech.ostack.kform.schemas.FloatSchema",
|
|
1085
|
+
defaultNullable: true,
|
|
1086
|
+
defaultValue: "0f"
|
|
1231
1087
|
};
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
propertyAnnotations: (_schematic, data) => {
|
|
1240
|
-
data.currentFile.imports.add("kotlin.OptIn").add("kotlin.time.ExperimentalTime");
|
|
1241
|
-
return "@OptIn(ExperimentalTime::class)";
|
|
1242
|
-
}
|
|
1088
|
+
var instantSchematicKind = {
|
|
1089
|
+
kind: "Instant",
|
|
1090
|
+
package: "kotlin.time",
|
|
1091
|
+
name: "Instant",
|
|
1092
|
+
schema: "tech.ostack.kform.schemas.InstantSchema",
|
|
1093
|
+
defaultNullable: true,
|
|
1094
|
+
defaultValue: "Instant.fromEpochMilliseconds(0)"
|
|
1243
1095
|
};
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1096
|
+
var intSchematicKind = {
|
|
1097
|
+
kind: "Int",
|
|
1098
|
+
package: "kotlin",
|
|
1099
|
+
name: "Int",
|
|
1100
|
+
schema: "tech.ostack.kform.schemas.IntSchema",
|
|
1101
|
+
defaultNullable: true,
|
|
1102
|
+
defaultValue: "0"
|
|
1251
1103
|
};
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1104
|
+
var listSchematicKind = {
|
|
1105
|
+
kind: "List",
|
|
1106
|
+
package: "kotlin.collections",
|
|
1107
|
+
name: "List",
|
|
1108
|
+
schema: "tech.ostack.kform.schemas.ListSchema",
|
|
1109
|
+
defaultValue: "emptyList()",
|
|
1110
|
+
builder: ListableBuilder,
|
|
1111
|
+
initChildren: () => [createSchematic()],
|
|
1112
|
+
scaffoldType: (schematic, data) => `List<${scaffoldType(schematic.children[0], {
|
|
1113
|
+
...data,
|
|
1114
|
+
currentPath: joinPaths(data.currentPath, "*")
|
|
1115
|
+
})}>`,
|
|
1116
|
+
scaffoldSchema: (schematic, data) => `ListSchema { ${scaffoldSchema(schematic.children[0], {
|
|
1117
|
+
...data,
|
|
1118
|
+
currentPath: joinPaths(data.currentPath, "*")
|
|
1119
|
+
})} }`
|
|
1268
1120
|
};
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1121
|
+
var localDateSchematicKind = {
|
|
1122
|
+
kind: "LocalDate",
|
|
1123
|
+
package: "kotlinx.datetime",
|
|
1124
|
+
name: "LocalDate",
|
|
1125
|
+
schema: "tech.ostack.kform.schemas.LocalDateSchema",
|
|
1126
|
+
defaultNullable: true,
|
|
1127
|
+
defaultValue: "LocalDate(1970, 1, 1)"
|
|
1276
1128
|
};
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1129
|
+
var localDateTimeSchematicKind = {
|
|
1130
|
+
kind: "LocalDateTime",
|
|
1131
|
+
package: "kotlinx.datetime",
|
|
1132
|
+
name: "LocalDateTime",
|
|
1133
|
+
schema: "tech.ostack.kform.schemas.LocalDateTimeSchema",
|
|
1134
|
+
defaultNullable: true,
|
|
1135
|
+
defaultValue: "LocalDateTime(1970, 1, 1, 0, 0)"
|
|
1284
1136
|
};
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1137
|
+
var longSchematicKind = {
|
|
1138
|
+
kind: "Long",
|
|
1139
|
+
package: "kotlin",
|
|
1140
|
+
name: "Long",
|
|
1141
|
+
schema: "tech.ostack.kform.schemas.LongSchema",
|
|
1142
|
+
defaultNullable: true,
|
|
1143
|
+
defaultValue: "0L"
|
|
1292
1144
|
};
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1145
|
+
var shortSchematicKind = {
|
|
1146
|
+
kind: "Short",
|
|
1147
|
+
package: "kotlin",
|
|
1148
|
+
name: "Short",
|
|
1149
|
+
schema: "tech.ostack.kform.schemas.ShortSchema",
|
|
1150
|
+
defaultNullable: true,
|
|
1151
|
+
defaultValue: "0.toShort()"
|
|
1300
1152
|
};
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1153
|
+
var stringSchematicKind = {
|
|
1154
|
+
kind: "String",
|
|
1155
|
+
package: "kotlin",
|
|
1156
|
+
name: "String",
|
|
1157
|
+
schema: "tech.ostack.kform.schemas.StringSchema",
|
|
1158
|
+
defaultValue: "\"\""
|
|
1307
1159
|
};
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1160
|
+
var tableSchematicKind = {
|
|
1161
|
+
kind: "Table",
|
|
1162
|
+
package: "tech.ostack.kform.datatypes",
|
|
1163
|
+
name: "Table",
|
|
1164
|
+
schema: "tech.ostack.kform.schemas.TableSchema",
|
|
1165
|
+
defaultValue: (_schematic, data) => {
|
|
1166
|
+
data.currentFile.imports.add("tech.ostack.kform.datatypes.tableOf");
|
|
1167
|
+
return "tableOf()";
|
|
1168
|
+
},
|
|
1169
|
+
builder: ListableBuilder,
|
|
1170
|
+
initChildren: () => [createSchematic()],
|
|
1171
|
+
propertyAnnotations: (_schematic, data) => data.useTableValuesSerializer ? "@Serializable(with = Table.ValuesSerializer::class)" : void 0,
|
|
1172
|
+
scaffoldType: (schematic, data) => `Table<${scaffoldType(schematic.children[0], {
|
|
1173
|
+
...data,
|
|
1174
|
+
currentPath: joinPaths(data.currentPath, "*")
|
|
1175
|
+
})}>`,
|
|
1176
|
+
scaffoldSchema: (schematic, data) => `TableSchema { ${scaffoldSchema(schematic.children[0], {
|
|
1177
|
+
...data,
|
|
1178
|
+
currentPath: joinPaths(data.currentPath, "*")
|
|
1179
|
+
})} }`
|
|
1328
1180
|
};
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1181
|
+
var defaultSchematicKinds = [
|
|
1182
|
+
anySchematicKind,
|
|
1183
|
+
bigDecimalSchematicKind,
|
|
1184
|
+
bigIntegerSchematicKind,
|
|
1185
|
+
booleanSchematicKind,
|
|
1186
|
+
byteSchematicKind,
|
|
1187
|
+
charSchematicKind,
|
|
1188
|
+
classSchematicKind,
|
|
1189
|
+
doubleSchematicKind,
|
|
1190
|
+
enumSchematicKind,
|
|
1191
|
+
fileSchematicKind,
|
|
1192
|
+
floatSchematicKind,
|
|
1193
|
+
instantSchematicKind,
|
|
1194
|
+
intSchematicKind,
|
|
1195
|
+
listSchematicKind,
|
|
1196
|
+
localDateSchematicKind,
|
|
1197
|
+
localDateTimeSchematicKind,
|
|
1198
|
+
longSchematicKind,
|
|
1199
|
+
shortSchematicKind,
|
|
1200
|
+
stringSchematicKind,
|
|
1201
|
+
tableSchematicKind
|
|
1350
1202
|
];
|
|
1203
|
+
//#endregion
|
|
1204
|
+
//#region src/scaffolding/scaffolders/scaffoldSchemas.ts
|
|
1351
1205
|
function scaffoldSchemas(schematic, data) {
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1206
|
+
const fileName = joinPaths(data.currentDir, `${schematic.name}Schema.kt`);
|
|
1207
|
+
let file = data.files.get(fileName);
|
|
1208
|
+
if (!file) {
|
|
1209
|
+
data.files.set(fileName, file = ktFile(data));
|
|
1210
|
+
data.files.set(joinPaths(data.currentDir, `${schematic.name}Validations.kt`), ktFile(data));
|
|
1211
|
+
}
|
|
1212
|
+
scaffoldSchemaDeclaration(schematic, {
|
|
1213
|
+
...data,
|
|
1214
|
+
currentFile: file
|
|
1215
|
+
});
|
|
1362
1216
|
}
|
|
1363
1217
|
function scaffoldSchemaDeclaration(schematic, data) {
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
data.currentFile.imports.add(schematicKind.schema);
|
|
1372
|
-
data.currentFile.declarations[nDecls] = data.currentPath === "/" ? jsExport(decl, data) : decl;
|
|
1218
|
+
const schematicKind = data.schematicKinds.get(schematic.kind);
|
|
1219
|
+
if (!schematicKind) throw new Error(`Unknown schematic kind ${schematic.kind}`);
|
|
1220
|
+
const nDecls = data.currentFile.declarations.length;
|
|
1221
|
+
data.currentFile.declarations.push("");
|
|
1222
|
+
const decl = `val ${schematic.name}Schema = ${schematicKind.scaffoldSchema?.(schematic, data) ?? `${simpleKtName(schematicKind.schema)}()`}`;
|
|
1223
|
+
data.currentFile.imports.add(schematicKind.schema);
|
|
1224
|
+
data.currentFile.declarations[nDecls] = data.currentPath === "/" ? jsExport(decl, data) : decl;
|
|
1373
1225
|
}
|
|
1374
1226
|
function scaffoldSchema(schematic, data) {
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
}
|
|
1403
|
-
return scaffoldedSchema;
|
|
1404
|
-
}
|
|
1405
|
-
const serializerKt = "package <%= filePackage %>\n\nimport kotlin.js.JsExport\nimport kotlin.jvm.JvmOverloads\nimport kotlinx.serialization.json.Json\n\n/** Base JSON configuration. */\nprivate val JSON_CONFIG = Json.Default\n/** Pretty JSON configuration. */\nprivate val JSON_CONFIG_PRETTY = Json(JSON_CONFIG) { prettyPrint = true }\n\n/** JSON configuration. */\n@JvmOverloads\nfun jsonConfig(prettyPrint: Boolean = false): Json =\n if (prettyPrint) JSON_CONFIG_PRETTY else JSON_CONFIG\n\n@JsExport\n@JvmOverloads\nfun encode<%= formClass %>ToString(<%= formVar %>: <%= formClass %>, prettyPrint: Boolean = false): String =\n jsonConfig(prettyPrint).encodeToString(<%= formVar %>)\n\n@JsExport\nfun decode<%= formClass %>FromString(json: String): <%= formClass %> =\n jsonConfig().decodeFromString(json)\n";
|
|
1227
|
+
const schematicKind = data.schematicKinds.get(schematic.kind);
|
|
1228
|
+
if (!schematicKind) throw new Error(`Unknown schematic kind ${schematic.kind}`);
|
|
1229
|
+
const schematicPackage = schematicKind.package ?? joinPackages(data.currentPackage, schematic.packageSuffix);
|
|
1230
|
+
let scaffoldedSchema;
|
|
1231
|
+
if (schematicKind.package == null && schematicPackage !== data.currentPackage) {
|
|
1232
|
+
scaffoldedSchema = `${schematic.name}Schema`;
|
|
1233
|
+
data.currentFile.imports.add(`${schematicPackage}.${scaffoldedSchema}`);
|
|
1234
|
+
scaffoldSchemas(schematic, {
|
|
1235
|
+
...data,
|
|
1236
|
+
currentPackage: joinPackages(data.currentPackage, schematic.packageSuffix),
|
|
1237
|
+
currentDir: joinPaths(data.currentDir, schematic.packageSuffix?.replace(".", "/"))
|
|
1238
|
+
});
|
|
1239
|
+
} else {
|
|
1240
|
+
scaffoldedSchema = schematicKind.scaffoldSchema?.(schematic, data) ?? `${simpleKtName(schematicKind.schema)}()`;
|
|
1241
|
+
data.currentFile.imports.add(schematicKind.schema);
|
|
1242
|
+
}
|
|
1243
|
+
if (schematic.nullable) {
|
|
1244
|
+
data.currentFile.imports.add(NULLABLE_SCHEMA);
|
|
1245
|
+
return `${simpleKtName(NULLABLE_SCHEMA)} { ${scaffoldedSchema} }`;
|
|
1246
|
+
}
|
|
1247
|
+
return scaffoldedSchema;
|
|
1248
|
+
}
|
|
1249
|
+
//#endregion
|
|
1250
|
+
//#region src/scaffolding/templates/Serializer.kt.ejs?raw
|
|
1251
|
+
var Serializer_kt_default = "package <%= filePackage %>\n\nimport kotlin.js.JsExport\nimport kotlin.jvm.JvmOverloads\nimport kotlinx.serialization.json.Json\n\n/** Base JSON configuration. */\nprivate val JSON_CONFIG = Json.Default\n/** Pretty JSON configuration. */\nprivate val JSON_CONFIG_PRETTY = Json(JSON_CONFIG) { prettyPrint = true }\n\n/** JSON configuration. */\n@JvmOverloads\nfun jsonConfig(prettyPrint: Boolean = false): Json =\n if (prettyPrint) JSON_CONFIG_PRETTY else JSON_CONFIG\n\n@JsExport\n@JvmOverloads\nfun encode<%= formClass %>ToString(<%= formVar %>: <%= formClass %>, prettyPrint: Boolean = false): String =\n jsonConfig(prettyPrint).encodeToString(<%= formVar %>)\n\n@JsExport\nfun decode<%= formClass %>FromString(json: String): <%= formClass %> =\n jsonConfig().decodeFromString(json)\n";
|
|
1252
|
+
//#endregion
|
|
1253
|
+
//#region src/scaffolding/templating/EjsTemplateFile.ts
|
|
1406
1254
|
function ejsTemplateFile(content, ejsData, { base64, binary, executable, ...ejsOptions } = {}) {
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1255
|
+
return {
|
|
1256
|
+
content,
|
|
1257
|
+
ejsData,
|
|
1258
|
+
base64,
|
|
1259
|
+
binary,
|
|
1260
|
+
executable,
|
|
1261
|
+
ejsOptions,
|
|
1262
|
+
getContent: ejsTemplateFileContent
|
|
1263
|
+
};
|
|
1416
1264
|
}
|
|
1417
1265
|
function ejsTemplateFileContent() {
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
}
|
|
1266
|
+
return render(this.content, this.ejsData, {
|
|
1267
|
+
strict: true,
|
|
1268
|
+
destructuredLocals: Object.keys(this.ejsData ?? {}),
|
|
1269
|
+
...this.ejsOptions
|
|
1270
|
+
});
|
|
1271
|
+
}
|
|
1272
|
+
//#endregion
|
|
1273
|
+
//#region src/scaffolding/templating/util/addEjsTemplateFile.ts
|
|
1424
1274
|
function addEjsTemplateFile(data, fileName, content, ejsData, options) {
|
|
1425
|
-
|
|
1426
|
-
joinPaths(data.currentDir, fileName),
|
|
1427
|
-
ejsTemplateFile(content, ejsData, options)
|
|
1428
|
-
);
|
|
1275
|
+
data.files.set(joinPaths(data.currentDir, fileName), ejsTemplateFile(content, ejsData, options));
|
|
1429
1276
|
}
|
|
1277
|
+
//#endregion
|
|
1278
|
+
//#region src/scaffolding/scaffolders/scaffoldSerializer.ts
|
|
1430
1279
|
function scaffoldSerializer(schematic, data) {
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
}
|
|
1437
|
-
|
|
1280
|
+
addEjsTemplateFile(data, `${schematic.name}Serializer.kt`, Serializer_kt_default, {
|
|
1281
|
+
filePackage: data.currentPackage,
|
|
1282
|
+
formVar: camelCase(schematic.name),
|
|
1283
|
+
formClass: schematic.name
|
|
1284
|
+
});
|
|
1285
|
+
}
|
|
1286
|
+
//#endregion
|
|
1287
|
+
//#region src/scaffolding/templates/Validator.kt.ejs?raw
|
|
1288
|
+
var Validator_kt_default = "package <%= filePackage %>\n\nimport tech.ostack.kform.ExternalContexts\nimport tech.ostack.kform.FormValidator\nimport tech.ostack.kform.LocatedValidationError\nimport tech.ostack.kform.LocatedValidationWarning\nimport tech.ostack.kform.test.assertContainsMatchingIssue\nimport tech.ostack.kform.test.assertNotContainsMatchingIssue\n\nval <%= formVar %>Validator by lazy { FormValidator(<%= formClass %>Schema) }\n\nfun validate<%= formClass %>(\n <%= formVar %>: <%= formClass %>,\n path: String,\n externalContexts: ExternalContexts = emptyMap(),\n) = <%= formVar %>Validator.validate(<%= formVar %>, path, externalContexts)\n\nsuspend fun assert<%= formClass %>ContainsError(\n path: String,\n code: String,\n <%= formVar %>: <%= formClass %>,\n externalContexts: ExternalContexts = emptyMap(),\n) =\n assertContainsMatchingIssue(\n LocatedValidationError(path, code),\n validate<%= formClass %>(<%= formVar %>, path, externalContexts),\n )\n\nsuspend fun assert<%= formClass %>NotContainsError(\n path: String,\n code: String,\n <%= formVar %>: <%= formClass %>,\n externalContexts: ExternalContexts = emptyMap(),\n) =\n assertNotContainsMatchingIssue(\n LocatedValidationError(path, code),\n validate<%= formClass %>(<%= formVar %>, path, externalContexts),\n )\n\nsuspend fun assert<%= formClass %>ContainsWarning(\n path: String,\n code: String,\n <%= formVar %>: <%= formClass %>,\n externalContexts: ExternalContexts = emptyMap(),\n) =\n assertContainsMatchingIssue(\n LocatedValidationWarning(path, code),\n validate<%= formClass %>(<%= formVar %>, path, externalContexts),\n )\n\nsuspend fun assert<%= formClass %>NotContainsWarning(\n path: String,\n code: String,\n <%= formVar %>: <%= formClass %>,\n externalContexts: ExternalContexts = emptyMap(),\n) =\n assertNotContainsMatchingIssue(\n LocatedValidationWarning(path, code),\n validate<%= formClass %>(<%= formVar %>, path, externalContexts),\n )\n";
|
|
1289
|
+
//#endregion
|
|
1290
|
+
//#region src/scaffolding/scaffolders/scaffoldValidator.ts
|
|
1438
1291
|
function scaffoldValidator(schematic, data) {
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
}
|
|
1445
|
-
|
|
1446
|
-
|
|
1292
|
+
addEjsTemplateFile(data, `${schematic.name}Validator.kt`, Validator_kt_default, {
|
|
1293
|
+
filePackage: data.currentPackage,
|
|
1294
|
+
formVar: camelCase(schematic.name),
|
|
1295
|
+
formClass: schematic.name
|
|
1296
|
+
});
|
|
1297
|
+
}
|
|
1298
|
+
//#endregion
|
|
1299
|
+
//#region src/util/useLayoutEffect.ts
|
|
1300
|
+
/** `useLayoutEffect` hook which performs a noop when run on the server. */
|
|
1301
|
+
var useLayoutEffect$1 = typeof document !== "undefined" ? useLayoutEffect : () => {};
|
|
1302
|
+
//#endregion
|
|
1303
|
+
//#region src/util/useMeasure.ts
|
|
1304
|
+
/**
|
|
1305
|
+
* Hook that tracks the dimensions of an HTML element using the Resize Observer
|
|
1306
|
+
* API + window resize.
|
|
1307
|
+
*/
|
|
1447
1308
|
function useMeasure(element, setMeasurement) {
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
}
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
}) {
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
};
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
DndContext,
|
|
1587
|
-
{
|
|
1588
|
-
sensors,
|
|
1589
|
-
collisionDetection: closestCenter,
|
|
1590
|
-
onDragStart: (evt) => setDraggedSchematic({
|
|
1591
|
-
id: evt.active.id,
|
|
1592
|
-
...evt.active.data.current
|
|
1593
|
-
}),
|
|
1594
|
-
onDragEnd: (evt) => {
|
|
1595
|
-
const { parentId, sortBefore, ignored } = evt.over?.data.current ?? {};
|
|
1596
|
-
if (!ignored) {
|
|
1597
|
-
useSchematic.setState(
|
|
1598
|
-
(schematic) => moveSchematic(
|
|
1599
|
-
schematic,
|
|
1600
|
-
evt.active.id,
|
|
1601
|
-
parentId,
|
|
1602
|
-
sortBefore
|
|
1603
|
-
)
|
|
1604
|
-
);
|
|
1605
|
-
}
|
|
1606
|
-
setDraggedSchematic(null);
|
|
1607
|
-
},
|
|
1608
|
-
children: [
|
|
1609
|
-
/* @__PURE__ */ jsxs("form", { className: "builder-root", children: [
|
|
1610
|
-
/* @__PURE__ */ jsxs("header", { className: "builder-header", children: [
|
|
1611
|
-
/* @__PURE__ */ jsx("h1", { className: "builder-title", children: title }),
|
|
1612
|
-
version && /* @__PURE__ */ jsx("div", { className: "builder-version", children: version }),
|
|
1613
|
-
/* @__PURE__ */ jsxs("div", { className: "builder-actions", children: [
|
|
1614
|
-
configs && /* @__PURE__ */ jsx(SchematicBuilderConfig, { children: configs }),
|
|
1615
|
-
actions
|
|
1616
|
-
] })
|
|
1617
|
-
] }),
|
|
1618
|
-
/* @__PURE__ */ jsx(ClassBuilder, {})
|
|
1619
|
-
] }),
|
|
1620
|
-
/* @__PURE__ */ jsx(DragOverlay, { children: draggedSchematic && /* @__PURE__ */ jsx("div", { className: "builder-dragged", children: draggedSchematic.node }) })
|
|
1621
|
-
]
|
|
1622
|
-
}
|
|
1623
|
-
)
|
|
1624
|
-
}
|
|
1625
|
-
);
|
|
1626
|
-
}
|
|
1309
|
+
useLayoutEffect$1(() => {
|
|
1310
|
+
if (!element) {
|
|
1311
|
+
setMeasurement(void 0);
|
|
1312
|
+
return;
|
|
1313
|
+
}
|
|
1314
|
+
const cb = () => setMeasurement(element.getBoundingClientRect());
|
|
1315
|
+
cb();
|
|
1316
|
+
const observer = new ResizeObserver(([entry]) => entry && cb());
|
|
1317
|
+
observer.observe(element);
|
|
1318
|
+
window.addEventListener("resize", cb);
|
|
1319
|
+
return () => {
|
|
1320
|
+
observer.disconnect();
|
|
1321
|
+
window.removeEventListener("resize", cb);
|
|
1322
|
+
setMeasurement(void 0);
|
|
1323
|
+
};
|
|
1324
|
+
}, [element, setMeasurement]);
|
|
1325
|
+
}
|
|
1326
|
+
//#endregion
|
|
1327
|
+
//#region src/SchematicBuilderConfig.tsx
|
|
1328
|
+
function SchematicBuilderConfig({ children }) {
|
|
1329
|
+
const [anchorEl, setAnchorEl] = useState(null);
|
|
1330
|
+
const [popoverEl, setPopoverEl] = useState(null);
|
|
1331
|
+
useMeasure(anchorEl, (measurement) => {
|
|
1332
|
+
if (popoverEl && measurement) {
|
|
1333
|
+
popoverEl.style.setProperty("--anchor-top", `${measurement.top}px`);
|
|
1334
|
+
popoverEl.style.setProperty("--anchor-left", `${measurement.left}px`);
|
|
1335
|
+
popoverEl.style.setProperty("--anchor-bottom", `${measurement.bottom}px`);
|
|
1336
|
+
popoverEl.style.setProperty("--anchor-right", `${measurement.right}px`);
|
|
1337
|
+
popoverEl.style.setProperty("--anchor-width", `${measurement.width}px`);
|
|
1338
|
+
popoverEl.style.setProperty("--anchor-height", `${measurement.height}px`);
|
|
1339
|
+
}
|
|
1340
|
+
});
|
|
1341
|
+
useMeasure(popoverEl, (measurement) => {
|
|
1342
|
+
if (popoverEl && measurement) {
|
|
1343
|
+
popoverEl.style.setProperty("--width", `${measurement.width}px`);
|
|
1344
|
+
popoverEl.style.setProperty("--height", `${measurement.height}px`);
|
|
1345
|
+
}
|
|
1346
|
+
});
|
|
1347
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("button", {
|
|
1348
|
+
type: "button",
|
|
1349
|
+
className: "builder-icon-button builder-action builder-config-schematic",
|
|
1350
|
+
popoverTarget: "builder-config-popover",
|
|
1351
|
+
title: "Config",
|
|
1352
|
+
"aria-label": "Config",
|
|
1353
|
+
ref: setAnchorEl,
|
|
1354
|
+
children: "⚙️"
|
|
1355
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
1356
|
+
popover: "",
|
|
1357
|
+
id: "builder-config-popover",
|
|
1358
|
+
ref: setPopoverEl,
|
|
1359
|
+
children
|
|
1360
|
+
})] });
|
|
1361
|
+
}
|
|
1362
|
+
//#endregion
|
|
1363
|
+
//#region src/SchematicBuilder.tsx
|
|
1364
|
+
var kotlinMainData = { currentDir: "shared/src/commonMain/kotlin" };
|
|
1365
|
+
var kotlinTestData = { currentDir: "shared/src/commonTest/kotlin" };
|
|
1366
|
+
function SchematicBuilder({ name = "kform", title = document.title, basePath, basePackage, baseDir, defaultRootClassPackage = "org.example", defaultRootClassName = "MyForm", schematicKinds = defaultSchematicKinds, scaffolders = [
|
|
1367
|
+
configScaffolder(scaffoldSchemas, kotlinMainData),
|
|
1368
|
+
configScaffolder(scaffoldModels, kotlinMainData),
|
|
1369
|
+
configScaffolder(scaffoldSerializer, kotlinMainData),
|
|
1370
|
+
configScaffolder(scaffoldValidator, kotlinTestData)
|
|
1371
|
+
], scaffoldingData = (schematic) => schematic.config, actions = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1372
|
+
/* @__PURE__ */ jsx(LoadSchematic, {}),
|
|
1373
|
+
/* @__PURE__ */ jsx(SaveSchematic, {}),
|
|
1374
|
+
/* @__PURE__ */ jsx(ScaffoldToZip, {})
|
|
1375
|
+
] }), configs = /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(UseFileBase64SerializerConfig, {}), /* @__PURE__ */ jsx(UseTableValuesSerializerConfig, {})] }), version = "0.33.0-SNAPSHOT" }) {
|
|
1376
|
+
const [useSchematic] = useState(() => create(persist(() => createSchematic({
|
|
1377
|
+
kind: classSchematicKind.kind,
|
|
1378
|
+
packageSuffix: defaultRootClassPackage,
|
|
1379
|
+
name: defaultRootClassName,
|
|
1380
|
+
children: []
|
|
1381
|
+
}), { name })));
|
|
1382
|
+
const schematicKindsMap = useMemo(() => new Map(schematicKinds.sort((t1, t2) => t1.kind.localeCompare(t2.kind)).map((t) => [t.kind, t])), [schematicKinds]);
|
|
1383
|
+
const latestSchematicFileHandleRef = useRef(null);
|
|
1384
|
+
const [draggedSchematic, setDraggedSchematic] = useState(null);
|
|
1385
|
+
const sensors = useSensors(useSensor(PointerSensor, { activationConstraint: {
|
|
1386
|
+
distance: 10,
|
|
1387
|
+
delay: 400,
|
|
1388
|
+
tolerance: 20
|
|
1389
|
+
} }), useSensor(KeyboardSensor));
|
|
1390
|
+
return /* @__PURE__ */ jsx(SchematicBuilderContext.Provider, {
|
|
1391
|
+
value: {
|
|
1392
|
+
name,
|
|
1393
|
+
basePath,
|
|
1394
|
+
basePackage,
|
|
1395
|
+
baseDir,
|
|
1396
|
+
schematicKinds: schematicKindsMap,
|
|
1397
|
+
scaffolders,
|
|
1398
|
+
scaffoldingData,
|
|
1399
|
+
getRootSchematic: useSchematic.getState,
|
|
1400
|
+
useSchematic,
|
|
1401
|
+
setSchematic: useSchematic.setState,
|
|
1402
|
+
removeSchematic: () => {},
|
|
1403
|
+
parentPackage: basePackage,
|
|
1404
|
+
draggedSchematic,
|
|
1405
|
+
latestSchematicFileHandleRef
|
|
1406
|
+
},
|
|
1407
|
+
children: /* @__PURE__ */ jsxs(DndContext, {
|
|
1408
|
+
sensors,
|
|
1409
|
+
collisionDetection: closestCenter,
|
|
1410
|
+
onDragStart: (evt) => setDraggedSchematic({
|
|
1411
|
+
id: evt.active.id,
|
|
1412
|
+
...evt.active.data.current
|
|
1413
|
+
}),
|
|
1414
|
+
onDragEnd: (evt) => {
|
|
1415
|
+
const { parentId, sortBefore, ignored } = evt.over?.data.current ?? {};
|
|
1416
|
+
if (!ignored) useSchematic.setState((schematic) => moveSchematic(schematic, evt.active.id, parentId, sortBefore));
|
|
1417
|
+
setDraggedSchematic(null);
|
|
1418
|
+
},
|
|
1419
|
+
children: [/* @__PURE__ */ jsxs("form", {
|
|
1420
|
+
className: "builder-root",
|
|
1421
|
+
children: [/* @__PURE__ */ jsxs("header", {
|
|
1422
|
+
className: "builder-header",
|
|
1423
|
+
children: [
|
|
1424
|
+
/* @__PURE__ */ jsx("h1", {
|
|
1425
|
+
className: "builder-title",
|
|
1426
|
+
children: title
|
|
1427
|
+
}),
|
|
1428
|
+
version && /* @__PURE__ */ jsx("div", {
|
|
1429
|
+
className: "builder-version",
|
|
1430
|
+
children: version
|
|
1431
|
+
}),
|
|
1432
|
+
/* @__PURE__ */ jsxs("div", {
|
|
1433
|
+
className: "builder-actions",
|
|
1434
|
+
children: [configs && /* @__PURE__ */ jsx(SchematicBuilderConfig, { children: configs }), actions]
|
|
1435
|
+
})
|
|
1436
|
+
]
|
|
1437
|
+
}), /* @__PURE__ */ jsx(ClassBuilder, {})]
|
|
1438
|
+
}), /* @__PURE__ */ jsx(DragOverlay, { children: draggedSchematic && /* @__PURE__ */ jsx("div", {
|
|
1439
|
+
className: "builder-dragged",
|
|
1440
|
+
children: draggedSchematic.node
|
|
1441
|
+
}) })]
|
|
1442
|
+
})
|
|
1443
|
+
});
|
|
1444
|
+
}
|
|
1445
|
+
//#endregion
|
|
1446
|
+
//#region src/scaffolding/templating/TemplateFile.ts
|
|
1627
1447
|
function templateFile(content, options) {
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1448
|
+
return {
|
|
1449
|
+
...options,
|
|
1450
|
+
content,
|
|
1451
|
+
getContent: templateFileContent
|
|
1452
|
+
};
|
|
1633
1453
|
}
|
|
1634
1454
|
function templateFileContent() {
|
|
1635
|
-
|
|
1455
|
+
return this.content;
|
|
1636
1456
|
}
|
|
1457
|
+
//#endregion
|
|
1458
|
+
//#region src/scaffolding/templating/util/addTemplateFile.ts
|
|
1637
1459
|
function addTemplateFile(data, fileName, content, options) {
|
|
1638
|
-
|
|
1639
|
-
joinPaths(data.currentDir, fileName),
|
|
1640
|
-
templateFile(content, options)
|
|
1641
|
-
);
|
|
1460
|
+
data.files.set(joinPaths(data.currentDir, fileName), templateFile(content, options));
|
|
1642
1461
|
}
|
|
1462
|
+
//#endregion
|
|
1463
|
+
//#region src/scaffolding/typescript/TsFile.ts
|
|
1643
1464
|
function tsFile() {
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1465
|
+
return {
|
|
1466
|
+
imports: [],
|
|
1467
|
+
declarations: [],
|
|
1468
|
+
getContent: tsFileContent
|
|
1469
|
+
};
|
|
1649
1470
|
}
|
|
1650
1471
|
function tsFileContent() {
|
|
1651
|
-
|
|
1652
|
-
return [
|
|
1653
|
-
// Imports
|
|
1654
|
-
importStatements.sort((i1, i2) => i1.moduleName.localeCompare(i2.moduleName)).map((i) => tsImportStatementToString(i)).join("\n"),
|
|
1655
|
-
// Declarations
|
|
1656
|
-
...this.declarations
|
|
1657
|
-
].filter((s) => s).join("\n\n") + "\n";
|
|
1472
|
+
return [tsImportsToStatements(this.imports).sort((i1, i2) => i1.moduleName.localeCompare(i2.moduleName)).map((i) => tsImportStatementToString(i)).join("\n"), ...this.declarations].filter((s) => s).join("\n\n") + "\n";
|
|
1658
1473
|
}
|
|
1659
1474
|
function tsImportsToStatements(imports) {
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
statement.defaultImport = imp.name;
|
|
1671
|
-
} else if (imp.isNamespace) {
|
|
1672
|
-
statement.namespaceImport = imp.name;
|
|
1673
|
-
} else if (imp.isType) {
|
|
1674
|
-
(statement.typedImports ??= /* @__PURE__ */ new Set()).add(imp.name);
|
|
1675
|
-
} else if (imp.name) {
|
|
1676
|
-
(statement.namedImports ??= /* @__PURE__ */ new Set()).add(imp.name);
|
|
1677
|
-
}
|
|
1678
|
-
}
|
|
1679
|
-
return Array.from(importsStatements.values());
|
|
1475
|
+
const importsStatements = /* @__PURE__ */ new Map();
|
|
1476
|
+
for (const imp of imports) {
|
|
1477
|
+
let statement = importsStatements.get(imp.moduleName);
|
|
1478
|
+
if (!statement) importsStatements.set(imp.moduleName, statement = { moduleName: imp.moduleName });
|
|
1479
|
+
if (imp.isDefault) statement.defaultImport = imp.name;
|
|
1480
|
+
else if (imp.isNamespace) statement.namespaceImport = imp.name;
|
|
1481
|
+
else if (imp.isType) (statement.typedImports ??= /* @__PURE__ */ new Set()).add(imp.name);
|
|
1482
|
+
else if (imp.name) (statement.namedImports ??= /* @__PURE__ */ new Set()).add(imp.name);
|
|
1483
|
+
}
|
|
1484
|
+
return Array.from(importsStatements.values());
|
|
1680
1485
|
}
|
|
1681
1486
|
function tsImportStatementToString(importStatement) {
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
const moduleName = JSON.stringify(importStatement.moduleName);
|
|
1698
|
-
return allImports ? `import ${allImports} from ${moduleName};` : `import ${moduleName};`;
|
|
1699
|
-
}
|
|
1700
|
-
export {
|
|
1701
|
-
CLASS_DND_TYPE,
|
|
1702
|
-
ClassBuilder,
|
|
1703
|
-
ClassFieldBuilder,
|
|
1704
|
-
ENUM_DND_TYPE,
|
|
1705
|
-
EnumBuilder,
|
|
1706
|
-
EnumEntryBuilder,
|
|
1707
|
-
ListableBuilder,
|
|
1708
|
-
ListableBuilderWithoutKindSelect,
|
|
1709
|
-
ListableItemBuilder,
|
|
1710
|
-
LoadSchematic,
|
|
1711
|
-
NULLABLE_SCHEMA,
|
|
1712
|
-
SaveSchematic,
|
|
1713
|
-
ScaffoldToZip,
|
|
1714
|
-
SchematicBuilder,
|
|
1715
|
-
SchematicBuilderContext,
|
|
1716
|
-
UseFileBase64SerializerConfig,
|
|
1717
|
-
UseTableValuesSerializerConfig,
|
|
1718
|
-
addEjsTemplateFile,
|
|
1719
|
-
addTemplateFile,
|
|
1720
|
-
annotate,
|
|
1721
|
-
anySchematicKind,
|
|
1722
|
-
bigDecimalSchematicKind,
|
|
1723
|
-
bigIntegerSchematicKind,
|
|
1724
|
-
boolDataAttr,
|
|
1725
|
-
booleanSchematicKind,
|
|
1726
|
-
byteSchematicKind,
|
|
1727
|
-
charSchematicKind,
|
|
1728
|
-
classSchematicKind,
|
|
1729
|
-
code,
|
|
1730
|
-
configScaffolder,
|
|
1731
|
-
createSchematic,
|
|
1732
|
-
defaultSchematicKinds,
|
|
1733
|
-
doubleSchematicKind,
|
|
1734
|
-
ejsTemplateFile,
|
|
1735
|
-
enumSchematicKind,
|
|
1736
|
-
fileSchematicKind,
|
|
1737
|
-
floatSchematicKind,
|
|
1738
|
-
instantSchematicKind,
|
|
1739
|
-
intSchematicKind,
|
|
1740
|
-
joinPackages,
|
|
1741
|
-
joinPaths,
|
|
1742
|
-
jsExport,
|
|
1743
|
-
ktFile,
|
|
1744
|
-
listSchematicKind,
|
|
1745
|
-
localDateSchematicKind,
|
|
1746
|
-
localDateTimeSchematicKind,
|
|
1747
|
-
longSchematicKind,
|
|
1748
|
-
moveSchematic,
|
|
1749
|
-
preventDrag,
|
|
1750
|
-
scaffold,
|
|
1751
|
-
scaffoldDefaultValue,
|
|
1752
|
-
scaffoldModels,
|
|
1753
|
-
scaffoldPropertyAnnotations,
|
|
1754
|
-
scaffoldSchema,
|
|
1755
|
-
scaffoldSchemas,
|
|
1756
|
-
scaffoldSerializer,
|
|
1757
|
-
scaffoldType,
|
|
1758
|
-
scaffoldValidator,
|
|
1759
|
-
serializable,
|
|
1760
|
-
shortSchematicKind,
|
|
1761
|
-
simpleKtName,
|
|
1762
|
-
stringSchematicKind,
|
|
1763
|
-
tableSchematicKind,
|
|
1764
|
-
templateFile,
|
|
1765
|
-
tsFile,
|
|
1766
|
-
useConfig,
|
|
1767
|
-
useScaffolder,
|
|
1768
|
-
useSchematicBuilderContext
|
|
1769
|
-
};
|
|
1770
|
-
//# sourceMappingURL=ostack-kform-scaffolder.js.map
|
|
1487
|
+
const namedImportsArr = [...new Set([...importStatement.namedImports ?? [], ...importStatement.typedImports ?? []])].sort((i1, i2) => i1.localeCompare(i2));
|
|
1488
|
+
const allNamedImportsAreTyped = namedImportsArr.every((i) => !importStatement.namedImports?.has(i));
|
|
1489
|
+
const namedImports = namedImportsArr.length > 0 ? allNamedImportsAreTyped ? `type { ${namedImportsArr.join(", ")} }` : `{ ${namedImportsArr.map((i) => importStatement.namedImports?.has(i) ? i : `type ${i}`).join(", ")} }` : null;
|
|
1490
|
+
const allImports = [
|
|
1491
|
+
importStatement.defaultImport || null,
|
|
1492
|
+
importStatement.namespaceImport ? `* as ${importStatement.namespaceImport}` : null,
|
|
1493
|
+
namedImports
|
|
1494
|
+
].filter((s) => s).join(", ");
|
|
1495
|
+
const moduleName = JSON.stringify(importStatement.moduleName);
|
|
1496
|
+
return allImports ? `import ${allImports} from ${moduleName};` : `import ${moduleName};`;
|
|
1497
|
+
}
|
|
1498
|
+
//#endregion
|
|
1499
|
+
export { CLASS_DND_TYPE, ClassBuilder, ClassFieldBuilder, ENUM_DND_TYPE, EnumBuilder, EnumEntryBuilder, ListableBuilder, ListableBuilderWithoutKindSelect, ListableItemBuilder, LoadSchematic, NULLABLE_SCHEMA, SaveSchematic, ScaffoldToZip, SchematicBuilder, SchematicBuilderContext, UseFileBase64SerializerConfig, UseTableValuesSerializerConfig, addEjsTemplateFile, addTemplateFile, annotate, anySchematicKind, bigDecimalSchematicKind, bigIntegerSchematicKind, boolDataAttr, booleanSchematicKind, byteSchematicKind, charSchematicKind, classSchematicKind, code, configScaffolder, createSchematic, defaultSchematicKinds, doubleSchematicKind, ejsTemplateFile, enumSchematicKind, fileSchematicKind, floatSchematicKind, instantSchematicKind, intSchematicKind, joinPackages, joinPaths, jsExport, ktFile, listSchematicKind, localDateSchematicKind, localDateTimeSchematicKind, longSchematicKind, moveSchematic, preventDrag, scaffold, scaffoldDefaultValue, scaffoldModels, scaffoldPropertyAnnotations, scaffoldSchema, scaffoldSchemas, scaffoldSerializer, scaffoldType, scaffoldValidator, serializable, shortSchematicKind, simpleKtName, stringSchematicKind, tableSchematicKind, templateFile, tsFile, useConfig, useScaffolder, useSchematicBuilderContext };
|
|
1500
|
+
|
|
1501
|
+
//# sourceMappingURL=ostack-kform-scaffolder.js.map
|