@ostack.tech/kform-scaffolder 1.2.0 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ostack-kform-scaffolder.js +113 -150
- package/ostack-kform-scaffolder.js.map +1 -1
- package/package.json +3 -3
- package/types/configs/UseFileBase64SerializerConfig.d.ts +2 -1
- package/types/configs/UseTableValuesSerializerConfig.d.ts +2 -1
- package/webapp/assets/index-D6Y6lPet.js +174 -0
- package/webapp/index.html +1 -1
- package/webapp/assets/index-bY4b92vQ.js +0 -173
|
@@ -8,7 +8,7 @@ import { useStore } from "zustand/react";
|
|
|
8
8
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
9
9
|
import JSZip from "jszip";
|
|
10
10
|
import { render } from "ejs";
|
|
11
|
-
|
|
11
|
+
// src/Schematic.ts
|
|
12
12
|
function createSchematic(schematic) {
|
|
13
13
|
return {
|
|
14
14
|
id: self.crypto.randomUUID(),
|
|
@@ -63,8 +63,7 @@ function add(schematic, toAdd, parentId, sortBefore) {
|
|
|
63
63
|
children: schematic.children.map((child) => add(child, toAdd, parentId, sortBefore))
|
|
64
64
|
};
|
|
65
65
|
}
|
|
66
|
-
|
|
67
|
-
//#region src/SchematicBuilderContext.ts
|
|
66
|
+
// src/SchematicBuilderContext.ts
|
|
68
67
|
var SchematicBuilderContext = createContext(null);
|
|
69
68
|
function useSchematicBuilderContext() {
|
|
70
69
|
const context = useContext(SchematicBuilderContext);
|
|
@@ -83,8 +82,7 @@ function useSchematic(selector) {
|
|
|
83
82
|
} else t0 = $[2];
|
|
84
83
|
return useStore(store, t0);
|
|
85
84
|
}
|
|
86
|
-
|
|
87
|
-
//#region src/actions/LoadSchematic.tsx
|
|
85
|
+
// src/actions/LoadSchematic.tsx
|
|
88
86
|
function LoadSchematic() {
|
|
89
87
|
const $ = c(4);
|
|
90
88
|
const { name, setSchematic, latestSchematicFileHandleRef } = useSchematicBuilderContext();
|
|
@@ -121,8 +119,7 @@ function LoadSchematic() {
|
|
|
121
119
|
} else t0 = $[3];
|
|
122
120
|
return t0;
|
|
123
121
|
}
|
|
124
|
-
|
|
125
|
-
//#region src/actions/SaveSchematic.tsx
|
|
122
|
+
// src/actions/SaveSchematic.tsx
|
|
126
123
|
function SaveSchematic() {
|
|
127
124
|
const $ = c(4);
|
|
128
125
|
const { name, getSchematic, latestSchematicFileHandleRef } = useSchematicBuilderContext();
|
|
@@ -159,8 +156,7 @@ function SaveSchematic() {
|
|
|
159
156
|
} else t0 = $[3];
|
|
160
157
|
return t0;
|
|
161
158
|
}
|
|
162
|
-
|
|
163
|
-
//#region src/scaffolding/configScaffolder.ts
|
|
159
|
+
// src/scaffolding/configScaffolder.ts
|
|
164
160
|
/** Returns a new scaffolder with its data merged with the provided data. */
|
|
165
161
|
function configScaffolder(scaffolder, data) {
|
|
166
162
|
return (schematic, originalData) => scaffolder(schematic, {
|
|
@@ -168,8 +164,7 @@ function configScaffolder(scaffolder, data) {
|
|
|
168
164
|
...data
|
|
169
165
|
});
|
|
170
166
|
}
|
|
171
|
-
|
|
172
|
-
//#region src/util/join.ts
|
|
167
|
+
// src/util/join.ts
|
|
173
168
|
function join(s1, s2, separator) {
|
|
174
169
|
return !s1 || !s2 ? s1 || s2 || "" : `${s1}${s1.endsWith(separator) ? "" : separator}${s2}`;
|
|
175
170
|
}
|
|
@@ -179,8 +174,7 @@ function joinPaths(path1, path2) {
|
|
|
179
174
|
function joinPackages(pkg1, pkg2) {
|
|
180
175
|
return join(pkg1, pkg2, ".");
|
|
181
176
|
}
|
|
182
|
-
|
|
183
|
-
//#region src/scaffolding/scaffold.ts
|
|
177
|
+
// src/scaffolding/scaffold.ts
|
|
184
178
|
function scaffold(schematic, scaffolders, options) {
|
|
185
179
|
const files = /* @__PURE__ */ new Map();
|
|
186
180
|
const data = {
|
|
@@ -200,8 +194,7 @@ function scaffold(schematic, scaffolders, options) {
|
|
|
200
194
|
executable: file.executable
|
|
201
195
|
}));
|
|
202
196
|
}
|
|
203
|
-
|
|
204
|
-
//#region src/scaffolding/useScaffolder.ts
|
|
197
|
+
// src/scaffolding/useScaffolder.ts
|
|
205
198
|
function useScaffolder() {
|
|
206
199
|
const $ = c(8);
|
|
207
200
|
const { basePath, basePackage, baseDir, schematicKinds, scaffolders, scaffoldingData, getSchematic } = useSchematicBuilderContext();
|
|
@@ -230,8 +223,7 @@ function useScaffolder() {
|
|
|
230
223
|
} else t0 = $[7];
|
|
231
224
|
return t0;
|
|
232
225
|
}
|
|
233
|
-
|
|
234
|
-
//#region src/actions/ScaffoldToZip.tsx
|
|
226
|
+
// src/actions/ScaffoldToZip.tsx
|
|
235
227
|
function ScaffoldToZip() {
|
|
236
228
|
const $ = c(4);
|
|
237
229
|
const { getSchematic, name } = useSchematicBuilderContext();
|
|
@@ -278,8 +270,7 @@ function ScaffoldToZip() {
|
|
|
278
270
|
} else t0 = $[3];
|
|
279
271
|
return t0;
|
|
280
272
|
}
|
|
281
|
-
|
|
282
|
-
//#region src/configs/util/useConfig.ts
|
|
273
|
+
// src/configs/util/useConfig.ts
|
|
283
274
|
function useConfig(configName, defaultValue) {
|
|
284
275
|
const $ = c(9);
|
|
285
276
|
const { store } = useSchematicBuilderContext();
|
|
@@ -311,98 +302,95 @@ function useConfig(configName, defaultValue) {
|
|
|
311
302
|
} else t2 = $[8];
|
|
312
303
|
return t2;
|
|
313
304
|
}
|
|
314
|
-
|
|
315
|
-
//#region src/configs/UseFileBase64SerializerConfig.tsx
|
|
305
|
+
// src/configs/UseFileBase64SerializerConfig.tsx
|
|
316
306
|
function UseFileBase64SerializerConfig(t0) {
|
|
317
307
|
const $ = c(9);
|
|
318
|
-
const { disabled } = t0;
|
|
319
|
-
const [config, setConfig] = useConfig("useFileBase64Serializer", false);
|
|
320
|
-
let
|
|
308
|
+
const { defaultValue: t1, disabled } = t0;
|
|
309
|
+
const [config, setConfig] = useConfig("useFileBase64Serializer", t1 === void 0 ? false : t1);
|
|
310
|
+
let t2;
|
|
321
311
|
if ($[0] !== setConfig) {
|
|
322
|
-
|
|
312
|
+
t2 = (evt) => setConfig(evt.target.checked);
|
|
323
313
|
$[0] = setConfig;
|
|
324
|
-
$[1] =
|
|
325
|
-
} else
|
|
326
|
-
let
|
|
327
|
-
if ($[2] !== config || $[3] !== disabled || $[4] !==
|
|
328
|
-
|
|
314
|
+
$[1] = t2;
|
|
315
|
+
} else t2 = $[1];
|
|
316
|
+
let t3;
|
|
317
|
+
if ($[2] !== config || $[3] !== disabled || $[4] !== t2) {
|
|
318
|
+
t3 = /* @__PURE__ */ jsx("input", {
|
|
329
319
|
type: "checkbox",
|
|
330
320
|
checked: config,
|
|
331
|
-
onChange:
|
|
321
|
+
onChange: t2,
|
|
332
322
|
disabled
|
|
333
323
|
});
|
|
334
324
|
$[2] = config;
|
|
335
325
|
$[3] = disabled;
|
|
336
|
-
$[4] =
|
|
337
|
-
$[5] =
|
|
338
|
-
} else
|
|
339
|
-
let t3;
|
|
340
|
-
if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
|
|
341
|
-
t3 = /* @__PURE__ */ jsx("code", { children: "FileBase64Serializer" });
|
|
342
|
-
$[6] = t3;
|
|
343
|
-
} else t3 = $[6];
|
|
326
|
+
$[4] = t2;
|
|
327
|
+
$[5] = t3;
|
|
328
|
+
} else t3 = $[5];
|
|
344
329
|
let t4;
|
|
345
|
-
if ($[
|
|
346
|
-
t4 = /* @__PURE__ */ jsx("
|
|
330
|
+
if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
|
|
331
|
+
t4 = /* @__PURE__ */ jsx("code", { children: "FileBase64Serializer" });
|
|
332
|
+
$[6] = t4;
|
|
333
|
+
} else t4 = $[6];
|
|
334
|
+
let t5;
|
|
335
|
+
if ($[7] !== t3) {
|
|
336
|
+
t5 = /* @__PURE__ */ jsx("div", {
|
|
347
337
|
className: "builder-config-field",
|
|
348
338
|
children: /* @__PURE__ */ jsxs("label", { children: [
|
|
349
|
-
|
|
339
|
+
t3,
|
|
350
340
|
"Use ",
|
|
351
|
-
|
|
341
|
+
t4
|
|
352
342
|
] })
|
|
353
343
|
});
|
|
354
|
-
$[7] =
|
|
355
|
-
$[8] =
|
|
356
|
-
} else
|
|
357
|
-
return
|
|
344
|
+
$[7] = t3;
|
|
345
|
+
$[8] = t5;
|
|
346
|
+
} else t5 = $[8];
|
|
347
|
+
return t5;
|
|
358
348
|
}
|
|
359
|
-
|
|
360
|
-
//#region src/configs/UseTableValuesSerializerConfig.tsx
|
|
349
|
+
// src/configs/UseTableValuesSerializerConfig.tsx
|
|
361
350
|
function UseTableValuesSerializerConfig(t0) {
|
|
362
351
|
const $ = c(9);
|
|
363
|
-
const { disabled } = t0;
|
|
364
|
-
const [config, setConfig] = useConfig("useTableValuesSerializer", false);
|
|
365
|
-
let
|
|
352
|
+
const { defaultValue: t1, disabled } = t0;
|
|
353
|
+
const [config, setConfig] = useConfig("useTableValuesSerializer", t1 === void 0 ? false : t1);
|
|
354
|
+
let t2;
|
|
366
355
|
if ($[0] !== setConfig) {
|
|
367
|
-
|
|
356
|
+
t2 = (evt) => setConfig(evt.target.checked);
|
|
368
357
|
$[0] = setConfig;
|
|
369
|
-
$[1] =
|
|
370
|
-
} else
|
|
371
|
-
let
|
|
372
|
-
if ($[2] !== config || $[3] !== disabled || $[4] !==
|
|
373
|
-
|
|
358
|
+
$[1] = t2;
|
|
359
|
+
} else t2 = $[1];
|
|
360
|
+
let t3;
|
|
361
|
+
if ($[2] !== config || $[3] !== disabled || $[4] !== t2) {
|
|
362
|
+
t3 = /* @__PURE__ */ jsx("input", {
|
|
374
363
|
type: "checkbox",
|
|
375
364
|
checked: config,
|
|
376
|
-
onChange:
|
|
365
|
+
onChange: t2,
|
|
377
366
|
disabled
|
|
378
367
|
});
|
|
379
368
|
$[2] = config;
|
|
380
369
|
$[3] = disabled;
|
|
381
|
-
$[4] =
|
|
382
|
-
$[5] =
|
|
383
|
-
} else
|
|
384
|
-
let t3;
|
|
385
|
-
if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
|
|
386
|
-
t3 = /* @__PURE__ */ jsx("code", { children: "TableValuesSerializer" });
|
|
387
|
-
$[6] = t3;
|
|
388
|
-
} else t3 = $[6];
|
|
370
|
+
$[4] = t2;
|
|
371
|
+
$[5] = t3;
|
|
372
|
+
} else t3 = $[5];
|
|
389
373
|
let t4;
|
|
390
|
-
if ($[
|
|
391
|
-
t4 = /* @__PURE__ */ jsx("
|
|
374
|
+
if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
|
|
375
|
+
t4 = /* @__PURE__ */ jsx("code", { children: "TableValuesSerializer" });
|
|
376
|
+
$[6] = t4;
|
|
377
|
+
} else t4 = $[6];
|
|
378
|
+
let t5;
|
|
379
|
+
if ($[7] !== t3) {
|
|
380
|
+
t5 = /* @__PURE__ */ jsx("div", {
|
|
392
381
|
className: "builder-config-field",
|
|
393
382
|
children: /* @__PURE__ */ jsxs("label", { children: [
|
|
394
|
-
|
|
383
|
+
t3,
|
|
395
384
|
"Use ",
|
|
396
|
-
|
|
385
|
+
t4
|
|
397
386
|
] })
|
|
398
387
|
});
|
|
399
|
-
$[7] =
|
|
400
|
-
$[8] =
|
|
401
|
-
} else
|
|
402
|
-
return
|
|
388
|
+
$[7] = t3;
|
|
389
|
+
$[8] = t5;
|
|
390
|
+
} else t5 = $[8];
|
|
391
|
+
return t5;
|
|
403
392
|
}
|
|
404
|
-
|
|
405
|
-
//#region src/scaffolding/kotlin/util/defaultImports.ts
|
|
393
|
+
// src/scaffolding/kotlin/util/defaultImports.ts
|
|
406
394
|
var DEFAULT_IMPORTS = [
|
|
407
395
|
/^kotlin\.[^.]+$/,
|
|
408
396
|
/^kotlin\.annotation\.[^.]+$/,
|
|
@@ -416,8 +404,7 @@ var DEFAULT_IMPORTS = [
|
|
|
416
404
|
function isDefaultKtImport(qualifiedName) {
|
|
417
405
|
return DEFAULT_IMPORTS.some((i) => i.test(qualifiedName));
|
|
418
406
|
}
|
|
419
|
-
|
|
420
|
-
//#region src/scaffolding/kotlin/KtFile.ts
|
|
407
|
+
// src/scaffolding/kotlin/KtFile.ts
|
|
421
408
|
function ktFile(data) {
|
|
422
409
|
return {
|
|
423
410
|
package: data.currentPackage ?? "",
|
|
@@ -433,13 +420,11 @@ function ktFileContent() {
|
|
|
433
420
|
...this.declarations
|
|
434
421
|
].filter((s) => s).join("\n\n") + "\n";
|
|
435
422
|
}
|
|
436
|
-
|
|
437
|
-
//#region src/scaffolding/kotlin/util/simpleKtName.ts
|
|
423
|
+
// src/scaffolding/kotlin/util/simpleKtName.ts
|
|
438
424
|
function simpleKtName(qualifiedName) {
|
|
439
425
|
return qualifiedName.substring(qualifiedName.lastIndexOf(".") + 1);
|
|
440
426
|
}
|
|
441
|
-
|
|
442
|
-
//#region src/scaffolding/kotlin/util/annotations.ts
|
|
427
|
+
// src/scaffolding/kotlin/util/annotations.ts
|
|
443
428
|
var JS_EXPORT = "kotlin.js.JsExport";
|
|
444
429
|
var SERIALIZABLE = "kotlinx.serialization.Serializable";
|
|
445
430
|
function annotate(annotations, code) {
|
|
@@ -454,8 +439,7 @@ function serializable(code, data) {
|
|
|
454
439
|
data.currentFile.imports.add(SERIALIZABLE);
|
|
455
440
|
return annotate(`@${simpleKtName(SERIALIZABLE)}`, code);
|
|
456
441
|
}
|
|
457
|
-
|
|
458
|
-
//#region src/scaffolding/scaffolders/scaffoldModels.ts
|
|
442
|
+
// src/scaffolding/scaffolders/scaffoldModels.ts
|
|
459
443
|
function scaffoldModels(schematic, data) {
|
|
460
444
|
const fileName = joinPaths(data.currentDir, `${schematic.name}.kt`);
|
|
461
445
|
let file = data.files.get(fileName);
|
|
@@ -497,8 +481,7 @@ function scaffoldDefaultValue(schematic, data) {
|
|
|
497
481
|
if (!schematicKind) throw new Error(`Unknown schematic kind: '${schematic.kind}'.`);
|
|
498
482
|
return schematic.nullable ? "null" : typeof schematicKind.defaultValue === "function" ? schematicKind.defaultValue(schematic, data) : schematicKind.defaultValue;
|
|
499
483
|
}
|
|
500
|
-
|
|
501
|
-
//#region ../../node_modules/change-case/dist/index.js
|
|
484
|
+
// ../../node_modules/change-case/dist/index.js
|
|
502
485
|
var SPLIT_LOWER_UPPER_RE = /([\p{Ll}\d])(\p{Lu})/gu;
|
|
503
486
|
var SPLIT_UPPER_UPPER_RE = /(\p{Lu})([\p{Lu}][\p{Ll}])/gu;
|
|
504
487
|
var SPLIT_SEPARATE_NUMBER_RE = /(\d)\p{Ll}|(\p{L})\d/u;
|
|
@@ -595,21 +578,18 @@ function splitPrefixSuffix(input, options = {}) {
|
|
|
595
578
|
input.slice(suffixIndex)
|
|
596
579
|
];
|
|
597
580
|
}
|
|
598
|
-
|
|
599
|
-
//#region src/util/boolDataAttr.ts
|
|
581
|
+
// src/util/boolDataAttr.ts
|
|
600
582
|
/** Value for a data attribute given a condition. */
|
|
601
583
|
function boolDataAttr(condition) {
|
|
602
584
|
return condition ? "" : void 0;
|
|
603
585
|
}
|
|
604
|
-
|
|
605
|
-
//#region src/util/preventDrag.ts
|
|
586
|
+
// src/util/preventDrag.ts
|
|
606
587
|
/** Properties used to prevent an element from being dragged. */
|
|
607
588
|
var preventDrag = {
|
|
608
589
|
onKeyDown: (evt) => evt.stopPropagation(),
|
|
609
590
|
onPointerDown: (evt) => evt.stopPropagation()
|
|
610
591
|
};
|
|
611
|
-
|
|
612
|
-
//#region src/schematicBuilders/util/ChildMarker.tsx
|
|
592
|
+
// src/schematicBuilders/util/ChildMarker.tsx
|
|
613
593
|
function ChildMarker() {
|
|
614
594
|
const $ = c(7);
|
|
615
595
|
const { schematicKinds, setSchematic } = useSchematicBuilderContext();
|
|
@@ -652,8 +632,7 @@ function _temp2$7(schematic_0) {
|
|
|
652
632
|
function _temp$7(schematic) {
|
|
653
633
|
return schematic.kind;
|
|
654
634
|
}
|
|
655
|
-
|
|
656
|
-
//#region src/schematicBuilders/util/ChildRemove.tsx
|
|
635
|
+
// src/schematicBuilders/util/ChildRemove.tsx
|
|
657
636
|
function ChildRemove() {
|
|
658
637
|
const $ = c(2);
|
|
659
638
|
const { removeSchematic } = useSchematicBuilderContext();
|
|
@@ -672,8 +651,7 @@ function ChildRemove() {
|
|
|
672
651
|
} else t0 = $[1];
|
|
673
652
|
return t0;
|
|
674
653
|
}
|
|
675
|
-
|
|
676
|
-
//#region src/schematicBuilders/util/KindSelect.tsx
|
|
654
|
+
// src/schematicBuilders/util/KindSelect.tsx
|
|
677
655
|
var KIND_PLACEHOLDER = "--KIND--";
|
|
678
656
|
function KindSelect() {
|
|
679
657
|
const $ = c(14);
|
|
@@ -746,8 +724,7 @@ function _temp2$6(kind_0) {
|
|
|
746
724
|
function _temp$6(schematic) {
|
|
747
725
|
return schematic.kind;
|
|
748
726
|
}
|
|
749
|
-
|
|
750
|
-
//#region src/schematicBuilders/util/NullableInput.tsx
|
|
727
|
+
// src/schematicBuilders/util/NullableInput.tsx
|
|
751
728
|
function NullableInput() {
|
|
752
729
|
const $ = c(7);
|
|
753
730
|
const { schematicKinds, setSchematic } = useSchematicBuilderContext();
|
|
@@ -785,8 +762,7 @@ function _temp2$5(schematic_0) {
|
|
|
785
762
|
function _temp$5(schematic) {
|
|
786
763
|
return schematic.kind;
|
|
787
764
|
}
|
|
788
|
-
|
|
789
|
-
//#region src/schematicBuilders/util/PackageNameInput.tsx
|
|
765
|
+
// src/schematicBuilders/util/PackageNameInput.tsx
|
|
790
766
|
var PACKAGE_PLACEHOLDER = "package.suffix";
|
|
791
767
|
var NAME_PLACEHOLDER = "ClassName";
|
|
792
768
|
function PackageNameInput() {
|
|
@@ -915,8 +891,7 @@ function _temp2$4(schematic_0) {
|
|
|
915
891
|
function _temp$4(schematic) {
|
|
916
892
|
return schematic.packageSuffix;
|
|
917
893
|
}
|
|
918
|
-
|
|
919
|
-
//#region src/schematicBuilders/ClassBuilder.tsx
|
|
894
|
+
// src/schematicBuilders/ClassBuilder.tsx
|
|
920
895
|
var CLASS_DND_TYPE = "class-field";
|
|
921
896
|
function ClassBuilder() {
|
|
922
897
|
const $ = c(32);
|
|
@@ -1329,8 +1304,7 @@ function _temp6$1(schematic_0) {
|
|
|
1329
1304
|
function _temp5$1(schematic) {
|
|
1330
1305
|
return schematic.id;
|
|
1331
1306
|
}
|
|
1332
|
-
|
|
1333
|
-
//#region src/schematicBuilders/EnumBuilder.tsx
|
|
1307
|
+
// src/schematicBuilders/EnumBuilder.tsx
|
|
1334
1308
|
var ENUM_DND_TYPE = "enum-entry";
|
|
1335
1309
|
function EnumBuilder() {
|
|
1336
1310
|
const $ = c(31);
|
|
@@ -1665,8 +1639,7 @@ function _temp5(schematic_0) {
|
|
|
1665
1639
|
function _temp4(schematic) {
|
|
1666
1640
|
return schematic.id;
|
|
1667
1641
|
}
|
|
1668
|
-
|
|
1669
|
-
//#region src/schematicBuilders/ListableBuilder.tsx
|
|
1642
|
+
// src/schematicBuilders/ListableBuilder.tsx
|
|
1670
1643
|
function ListableBuilder(t0) {
|
|
1671
1644
|
const $ = c(14);
|
|
1672
1645
|
const { showKindSelect: t1 } = t0;
|
|
@@ -1779,23 +1752,29 @@ function ListableItemBuilder(t0) {
|
|
|
1779
1752
|
function _temp3$1(schematic) {
|
|
1780
1753
|
return schematic.kind;
|
|
1781
1754
|
}
|
|
1782
|
-
|
|
1783
|
-
//#region src/util/code.ts
|
|
1755
|
+
// src/util/code.ts
|
|
1784
1756
|
var LF = /\r?\n/;
|
|
1757
|
+
var LF_AFFIX = /(^\r?\n)|(\r?\n$)/g;
|
|
1785
1758
|
var EMPTY_LINE = /^\s*$/;
|
|
1786
1759
|
var SPACE = /\s/;
|
|
1787
|
-
var LF_AFFIX = /(^\r?\n)|(\r?\n$)/g;
|
|
1788
1760
|
/** Tag function used to aid in the construction of code blocks. */
|
|
1789
1761
|
function code(strings, ...values) {
|
|
1790
1762
|
const minIndent = Math.min(...strings.join("").split(LF).filter(isNotEmpty).map(indentWidth));
|
|
1763
|
+
let curLine = 0;
|
|
1791
1764
|
let result = "";
|
|
1765
|
+
const emptyInterpolationLines = /* @__PURE__ */ new Set();
|
|
1766
|
+
const append = (str) => {
|
|
1767
|
+
curLine += str.split(LF).length - 1;
|
|
1768
|
+
result += str;
|
|
1769
|
+
};
|
|
1792
1770
|
for (let i = 0; i < values.length; ++i) {
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1771
|
+
append(trimNoninitialLines(strings[i], minIndent));
|
|
1772
|
+
const value = values[i] == null || typeof values[i] === "boolean" ? "" : String(values[i]);
|
|
1773
|
+
if (value === "") emptyInterpolationLines.add(curLine);
|
|
1774
|
+
else append(indentNoninitialLines(value, indentWidth(result.slice(result.lastIndexOf("\n") + 1))));
|
|
1796
1775
|
}
|
|
1797
|
-
|
|
1798
|
-
return result.replace(LF_AFFIX, "");
|
|
1776
|
+
append(trimNoninitialLines(strings.at(-1), minIndent));
|
|
1777
|
+
return result.split(LF).filter((line, index) => !(emptyInterpolationLines.has(index) && !isNotEmpty(line))).join("\n").replace(LF_AFFIX, "");
|
|
1799
1778
|
}
|
|
1800
1779
|
function isNotEmpty(line) {
|
|
1801
1780
|
return !EMPTY_LINE.test(line);
|
|
@@ -1823,8 +1802,7 @@ function trimNoninitialLines(str, indentWidth) {
|
|
|
1823
1802
|
for (let i = 1; i < lines.length; ++i) resultLines.push(lines[i].slice(indentWidth));
|
|
1824
1803
|
return resultLines.join("\n");
|
|
1825
1804
|
}
|
|
1826
|
-
|
|
1827
|
-
//#region src/SchematicKind.ts
|
|
1805
|
+
// src/SchematicKind.ts
|
|
1828
1806
|
var NULLABLE_SCHEMA = "tech.ostack.kform.schemas.NullableSchema";
|
|
1829
1807
|
var anySchematicKind = {
|
|
1830
1808
|
kind: "Any",
|
|
@@ -1889,8 +1867,8 @@ var classSchematicKind = {
|
|
|
1889
1867
|
...data,
|
|
1890
1868
|
currentPath: joinPaths(data.currentPath, childSchematic.childName)
|
|
1891
1869
|
};
|
|
1892
|
-
return annotate(scaffoldPropertyAnnotations(childSchematic, childData), `var ${childSchematic.childName}: ${scaffoldType(childSchematic, childData)} = ${scaffoldDefaultValue(childSchematic, childData)}
|
|
1893
|
-
}).join("
|
|
1870
|
+
return annotate(scaffoldPropertyAnnotations(childSchematic, childData), `var ${childSchematic.childName}: ${scaffoldType(childSchematic, childData)} = ${scaffoldDefaultValue(childSchematic, childData)},`);
|
|
1871
|
+
}).join("\n")}
|
|
1894
1872
|
)
|
|
1895
1873
|
`,
|
|
1896
1874
|
scaffoldSchema: (schematic, data) => code`
|
|
@@ -1920,7 +1898,7 @@ var enumSchematicKind = {
|
|
|
1920
1898
|
defaultName: (childName) => pascalCase(childName),
|
|
1921
1899
|
scaffoldModel: (schematic) => code`
|
|
1922
1900
|
enum class ${schematic.name} {
|
|
1923
|
-
${schematic.children?.map((childSchematic) => childSchematic.childName).join("
|
|
1901
|
+
${schematic.children?.map((childSchematic) => `${childSchematic.childName},`).join("\n")}
|
|
1924
1902
|
}
|
|
1925
1903
|
`
|
|
1926
1904
|
};
|
|
@@ -2069,8 +2047,7 @@ var defaultSchematicKinds = [
|
|
|
2069
2047
|
stringSchematicKind,
|
|
2070
2048
|
tableSchematicKind
|
|
2071
2049
|
];
|
|
2072
|
-
|
|
2073
|
-
//#region src/scaffolding/scaffolders/scaffoldSchemas.ts
|
|
2050
|
+
// src/scaffolding/scaffolders/scaffoldSchemas.ts
|
|
2074
2051
|
function scaffoldSchemas(schematic, data) {
|
|
2075
2052
|
const fileName = joinPaths(data.currentDir, `${schematic.name}Schema.kt`);
|
|
2076
2053
|
let file = data.files.get(fileName);
|
|
@@ -2115,11 +2092,9 @@ function scaffoldSchema(schematic, data) {
|
|
|
2115
2092
|
}
|
|
2116
2093
|
return scaffoldedSchema;
|
|
2117
2094
|
}
|
|
2118
|
-
|
|
2119
|
-
//#region src/scaffolding/templates/Serializer.kt.ejs?raw
|
|
2095
|
+
// src/scaffolding/templates/Serializer.kt.ejs?raw
|
|
2120
2096
|
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";
|
|
2121
|
-
|
|
2122
|
-
//#region src/scaffolding/templating/EjsTemplateFile.ts
|
|
2097
|
+
// src/scaffolding/templating/EjsTemplateFile.ts
|
|
2123
2098
|
function ejsTemplateFile(content, ejsData, { base64, binary, executable, ...ejsOptions } = {}) {
|
|
2124
2099
|
return {
|
|
2125
2100
|
content,
|
|
@@ -2138,13 +2113,11 @@ function ejsTemplateFileContent() {
|
|
|
2138
2113
|
...this.ejsOptions
|
|
2139
2114
|
});
|
|
2140
2115
|
}
|
|
2141
|
-
|
|
2142
|
-
//#region src/scaffolding/templating/util/addEjsTemplateFile.ts
|
|
2116
|
+
// src/scaffolding/templating/util/addEjsTemplateFile.ts
|
|
2143
2117
|
function addEjsTemplateFile(data, fileName, content, ejsData, options) {
|
|
2144
2118
|
data.files.set(joinPaths(data.currentDir, fileName), ejsTemplateFile(content, ejsData, options));
|
|
2145
2119
|
}
|
|
2146
|
-
|
|
2147
|
-
//#region src/scaffolding/scaffolders/scaffoldSerializer.ts
|
|
2120
|
+
// src/scaffolding/scaffolders/scaffoldSerializer.ts
|
|
2148
2121
|
function scaffoldSerializer(schematic, data) {
|
|
2149
2122
|
addEjsTemplateFile(data, `${schematic.name}Serializer.kt`, Serializer_kt_default, {
|
|
2150
2123
|
filePackage: data.currentPackage,
|
|
@@ -2152,11 +2125,9 @@ function scaffoldSerializer(schematic, data) {
|
|
|
2152
2125
|
formClass: schematic.name
|
|
2153
2126
|
});
|
|
2154
2127
|
}
|
|
2155
|
-
|
|
2156
|
-
//#region src/scaffolding/templates/Validator.kt.ejs?raw
|
|
2128
|
+
// src/scaffolding/templates/Validator.kt.ejs?raw
|
|
2157
2129
|
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";
|
|
2158
|
-
|
|
2159
|
-
//#region src/scaffolding/scaffolders/scaffoldValidator.ts
|
|
2130
|
+
// src/scaffolding/scaffolders/scaffoldValidator.ts
|
|
2160
2131
|
function scaffoldValidator(schematic, data) {
|
|
2161
2132
|
addEjsTemplateFile(data, `${schematic.name}Validator.kt`, Validator_kt_default, {
|
|
2162
2133
|
filePackage: data.currentPackage,
|
|
@@ -2164,12 +2135,10 @@ function scaffoldValidator(schematic, data) {
|
|
|
2164
2135
|
formClass: schematic.name
|
|
2165
2136
|
});
|
|
2166
2137
|
}
|
|
2167
|
-
|
|
2168
|
-
//#region src/util/useSafeLayoutEffect.ts
|
|
2138
|
+
// src/util/useSafeLayoutEffect.ts
|
|
2169
2139
|
/** `useLayoutEffect` hook which runs `useEffect` on the server. */
|
|
2170
2140
|
var useSafeLayoutEffect = typeof document !== "undefined" ? useLayoutEffect : useEffect;
|
|
2171
|
-
|
|
2172
|
-
//#region src/util/useMeasure.ts
|
|
2141
|
+
// src/util/useMeasure.ts
|
|
2173
2142
|
/** Hook that tracks the dimensions of an HTML element using the Resize Observer API + window resize. */
|
|
2174
2143
|
function useMeasure(element, setMeasurement) {
|
|
2175
2144
|
const $ = c(4);
|
|
@@ -2206,8 +2175,7 @@ function useMeasure(element, setMeasurement) {
|
|
|
2206
2175
|
}
|
|
2207
2176
|
useSafeLayoutEffect(t0, t1);
|
|
2208
2177
|
}
|
|
2209
|
-
|
|
2210
|
-
//#region src/SchematicBuilderConfig.tsx
|
|
2178
|
+
// src/SchematicBuilderConfig.tsx
|
|
2211
2179
|
function SchematicBuilderConfig(t0) {
|
|
2212
2180
|
const $ = c(7);
|
|
2213
2181
|
const { children } = t0;
|
|
@@ -2267,11 +2235,10 @@ function SchematicBuilderConfig(t0) {
|
|
|
2267
2235
|
} else t4 = $[6];
|
|
2268
2236
|
return t4;
|
|
2269
2237
|
}
|
|
2270
|
-
|
|
2271
|
-
//#region src/SchematicBuilder.tsx
|
|
2238
|
+
// src/SchematicBuilder.tsx
|
|
2272
2239
|
var KOTLIN_MAIN_DATA = { currentDir: "shared/src/commonMain/kotlin" };
|
|
2273
2240
|
var KOTLIN_TEST_DATA = { currentDir: "shared/src/commonTest/kotlin" };
|
|
2274
|
-
var DEFAULT_APP_VERSION = "1.2.
|
|
2241
|
+
var DEFAULT_APP_VERSION = "1.2.1";
|
|
2275
2242
|
var DEFAULT_SCAFFOLDERS = [
|
|
2276
2243
|
configScaffolder(scaffoldSchemas, KOTLIN_MAIN_DATA),
|
|
2277
2244
|
configScaffolder(scaffoldModels, KOTLIN_MAIN_DATA),
|
|
@@ -2504,8 +2471,7 @@ function _temp2(t) {
|
|
|
2504
2471
|
function _temp(t1, t2) {
|
|
2505
2472
|
return t1.kind.localeCompare(t2.kind);
|
|
2506
2473
|
}
|
|
2507
|
-
|
|
2508
|
-
//#region src/scaffolding/templating/TemplateFile.ts
|
|
2474
|
+
// src/scaffolding/templating/TemplateFile.ts
|
|
2509
2475
|
function templateFile(content, options) {
|
|
2510
2476
|
return {
|
|
2511
2477
|
...options,
|
|
@@ -2516,13 +2482,11 @@ function templateFile(content, options) {
|
|
|
2516
2482
|
function templateFileContent() {
|
|
2517
2483
|
return this.content;
|
|
2518
2484
|
}
|
|
2519
|
-
|
|
2520
|
-
//#region src/scaffolding/templating/util/addTemplateFile.ts
|
|
2485
|
+
// src/scaffolding/templating/util/addTemplateFile.ts
|
|
2521
2486
|
function addTemplateFile(data, fileName, content, options) {
|
|
2522
2487
|
data.files.set(joinPaths(data.currentDir, fileName), templateFile(content, options));
|
|
2523
2488
|
}
|
|
2524
|
-
|
|
2525
|
-
//#region src/scaffolding/typescript/TsFile.ts
|
|
2489
|
+
// src/scaffolding/typescript/TsFile.ts
|
|
2526
2490
|
function tsFile() {
|
|
2527
2491
|
return {
|
|
2528
2492
|
imports: [],
|
|
@@ -2557,7 +2521,6 @@ function tsImportStatementToString(importStatement) {
|
|
|
2557
2521
|
const moduleName = JSON.stringify(importStatement.moduleName);
|
|
2558
2522
|
return allImports ? `import ${allImports} from ${moduleName};` : `import ${moduleName};`;
|
|
2559
2523
|
}
|
|
2560
|
-
//#endregion
|
|
2561
2524
|
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, useSchematic, useSchematicBuilderContext };
|
|
2562
2525
|
|
|
2563
2526
|
//# sourceMappingURL=ostack-kform-scaffolder.js.map
|