@ostack.tech/kform-scaffolder 0.35.0 → 0.37.0
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 +32 -22
- package/ostack-kform-scaffolder.js.map +1 -1
- package/package.json +1 -1
- package/types/scaffolding/ScaffoldingData.d.ts +2 -2
- package/types/util/useSafeLayoutEffect.d.ts +3 -0
- package/webapp/assets/{index-DPI2KAvV.js → index-DEhNKj6v.js} +4 -4
- package/webapp/index.html +1 -1
- package/types/util/useLayoutEffect.d.ts +0 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
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";
|
|
2
|
+
import { createContext, useCallback, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
3
3
|
import { create } from "zustand";
|
|
4
4
|
import { persist } from "zustand/middleware";
|
|
5
5
|
import { fileOpen, fileSave, supported } from "browser-fs-access";
|
|
@@ -254,7 +254,7 @@ function UseFileBase64SerializerConfig({ disabled }) {
|
|
|
254
254
|
disabled
|
|
255
255
|
}),
|
|
256
256
|
"Use ",
|
|
257
|
-
/* @__PURE__ */ jsx("code", { children: "
|
|
257
|
+
/* @__PURE__ */ jsx("code", { children: "FileBase64Serializer" })
|
|
258
258
|
] })
|
|
259
259
|
});
|
|
260
260
|
}
|
|
@@ -272,7 +272,7 @@ function UseTableValuesSerializerConfig({ disabled }) {
|
|
|
272
272
|
disabled
|
|
273
273
|
}),
|
|
274
274
|
"Use ",
|
|
275
|
-
/* @__PURE__ */ jsx("code", { children: "
|
|
275
|
+
/* @__PURE__ */ jsx("code", { children: "TableValuesSerializer" })
|
|
276
276
|
] })
|
|
277
277
|
});
|
|
278
278
|
}
|
|
@@ -342,7 +342,7 @@ function scaffoldModels(schematic, data) {
|
|
|
342
342
|
}
|
|
343
343
|
function scaffoldModelDeclaration(schematic, data) {
|
|
344
344
|
const schematicKind = data.schematicKinds.get(schematic.kind);
|
|
345
|
-
if (!schematicKind) throw new Error(`Unknown schematic kind ${schematic.kind}
|
|
345
|
+
if (!schematicKind) throw new Error(`Unknown schematic kind: '${schematic.kind}'.`);
|
|
346
346
|
const nDecls = data.currentFile.declarations.length;
|
|
347
347
|
data.currentFile.declarations.push("");
|
|
348
348
|
const decl = schematicKind.scaffoldModel?.(schematic, data) ?? `typealias ${schematic.name} = ${scaffoldType(schematic, data)}`;
|
|
@@ -350,12 +350,12 @@ function scaffoldModelDeclaration(schematic, data) {
|
|
|
350
350
|
}
|
|
351
351
|
function scaffoldPropertyAnnotations(schematic, data) {
|
|
352
352
|
const schematicKind = data.schematicKinds.get(schematic.kind);
|
|
353
|
-
if (!schematicKind) throw new Error(`Unknown schematic kind ${schematic.kind}
|
|
353
|
+
if (!schematicKind) throw new Error(`Unknown schematic kind: '${schematic.kind}'.`);
|
|
354
354
|
return typeof schematicKind.propertyAnnotations === "function" ? schematicKind.propertyAnnotations(schematic, data) : schematicKind.propertyAnnotations;
|
|
355
355
|
}
|
|
356
356
|
function scaffoldType(schematic, data) {
|
|
357
357
|
const schematicKind = data.schematicKinds.get(schematic.kind);
|
|
358
|
-
if (!schematicKind) throw new Error(`Unknown schematic kind ${schematic.kind}
|
|
358
|
+
if (!schematicKind) throw new Error(`Unknown schematic kind: '${schematic.kind}'.`);
|
|
359
359
|
const schematicPackage = schematicKind.package ?? joinPackages(data.currentPackage, schematic.packageSuffix);
|
|
360
360
|
const schematicName = schematic.name || schematicKind.name;
|
|
361
361
|
if (schematicPackage !== data.currentPackage) data.currentFile.imports.add(joinPackages(schematicPackage, schematicName));
|
|
@@ -369,7 +369,7 @@ function scaffoldType(schematic, data) {
|
|
|
369
369
|
}
|
|
370
370
|
function scaffoldDefaultValue(schematic, data) {
|
|
371
371
|
const schematicKind = data.schematicKinds.get(schematic.kind);
|
|
372
|
-
if (!schematicKind) throw new Error(`Unknown schematic kind ${schematic.kind}
|
|
372
|
+
if (!schematicKind) throw new Error(`Unknown schematic kind: '${schematic.kind}'.`);
|
|
373
373
|
return schematic.nullable ? "null" : typeof schematicKind.defaultValue === "function" ? schematicKind.defaultValue(schematic, data) : schematicKind.defaultValue;
|
|
374
374
|
}
|
|
375
375
|
//#endregion
|
|
@@ -644,7 +644,7 @@ function ClassBuilder() {
|
|
|
644
644
|
}),
|
|
645
645
|
fields.length > 0 && /* @__PURE__ */ jsxs("ul", {
|
|
646
646
|
className: "builder-children",
|
|
647
|
-
children: [fields.map((field, i) => /* @__PURE__ */ jsx(SchematicBuilderContext
|
|
647
|
+
children: [fields.map((field, i) => /* @__PURE__ */ jsx(SchematicBuilderContext, {
|
|
648
648
|
value: {
|
|
649
649
|
...schematicBuilderContext,
|
|
650
650
|
useSchematic: (selector) => useSchematic((schematic) => selector(schematic.children[i])),
|
|
@@ -741,7 +741,7 @@ function ClassFieldBuilder() {
|
|
|
741
741
|
className: "builder-operator",
|
|
742
742
|
children: "∶"
|
|
743
743
|
}),
|
|
744
|
-
/* @__PURE__ */ jsx(SchematicBuilderContext
|
|
744
|
+
/* @__PURE__ */ jsx(SchematicBuilderContext, {
|
|
745
745
|
value: {
|
|
746
746
|
...schematicBuilderContext,
|
|
747
747
|
parentChildName: childName
|
|
@@ -751,7 +751,7 @@ function ClassFieldBuilder() {
|
|
|
751
751
|
/* @__PURE__ */ jsx(NullableInput, {}),
|
|
752
752
|
/* @__PURE__ */ jsx(ChildRemove, {})
|
|
753
753
|
]
|
|
754
|
-
}), Builder && !collapsed && /* @__PURE__ */ jsx(SchematicBuilderContext
|
|
754
|
+
}), Builder && !collapsed && /* @__PURE__ */ jsx(SchematicBuilderContext, {
|
|
755
755
|
value: {
|
|
756
756
|
...schematicBuilderContext,
|
|
757
757
|
parentChildName: childName,
|
|
@@ -791,7 +791,7 @@ function EnumBuilder() {
|
|
|
791
791
|
}),
|
|
792
792
|
fields.length > 0 && /* @__PURE__ */ jsxs("ul", {
|
|
793
793
|
className: "builder-children",
|
|
794
|
-
children: [fields.map((field, i) => /* @__PURE__ */ jsx(SchematicBuilderContext
|
|
794
|
+
children: [fields.map((field, i) => /* @__PURE__ */ jsx(SchematicBuilderContext, {
|
|
795
795
|
value: {
|
|
796
796
|
...schematicBuilderContext,
|
|
797
797
|
useSchematic: (selector) => useSchematic((schematic) => selector(schematic.children[i])),
|
|
@@ -893,7 +893,7 @@ function ListableBuilder({ showKindSelect = true }) {
|
|
|
893
893
|
const id = useSchematic((schematic) => schematic.id);
|
|
894
894
|
return /* @__PURE__ */ jsx("div", {
|
|
895
895
|
className: "listable-builder builder",
|
|
896
|
-
children: /* @__PURE__ */ jsx(SchematicBuilderContext
|
|
896
|
+
children: /* @__PURE__ */ jsx(SchematicBuilderContext, {
|
|
897
897
|
value: {
|
|
898
898
|
...schematicBuilderContext,
|
|
899
899
|
useSchematic: (selector) => useSchematic((schematic) => selector(schematic.children[0])),
|
|
@@ -1075,7 +1075,12 @@ var fileSchematicKind = {
|
|
|
1075
1075
|
data.currentFile.imports.add("tech.ostack.kform.datatypes.emptyPlaceholderFile");
|
|
1076
1076
|
return "emptyPlaceholderFile()";
|
|
1077
1077
|
},
|
|
1078
|
-
propertyAnnotations: (_schematic, data) =>
|
|
1078
|
+
propertyAnnotations: (_schematic, data) => {
|
|
1079
|
+
if (data.useFileBase64Serializer) {
|
|
1080
|
+
data.currentFile.imports.add("tech.ostack.kform.serializers.FileBase64Serializer");
|
|
1081
|
+
return "@Serializable(with = FileBase64Serializer::class)";
|
|
1082
|
+
}
|
|
1083
|
+
}
|
|
1079
1084
|
};
|
|
1080
1085
|
var floatSchematicKind = {
|
|
1081
1086
|
kind: "Float",
|
|
@@ -1168,7 +1173,12 @@ var tableSchematicKind = {
|
|
|
1168
1173
|
},
|
|
1169
1174
|
builder: ListableBuilder,
|
|
1170
1175
|
initChildren: () => [createSchematic()],
|
|
1171
|
-
propertyAnnotations: (_schematic, data) =>
|
|
1176
|
+
propertyAnnotations: (_schematic, data) => {
|
|
1177
|
+
if (data.useTableValuesSerializer) {
|
|
1178
|
+
data.currentFile.imports.add("tech.ostack.kform.serializers.TableValuesSerializer");
|
|
1179
|
+
return "@Serializable(with = TableValuesSerializer::class)";
|
|
1180
|
+
}
|
|
1181
|
+
},
|
|
1172
1182
|
scaffoldType: (schematic, data) => `Table<${scaffoldType(schematic.children[0], {
|
|
1173
1183
|
...data,
|
|
1174
1184
|
currentPath: joinPaths(data.currentPath, "*")
|
|
@@ -1216,7 +1226,7 @@ function scaffoldSchemas(schematic, data) {
|
|
|
1216
1226
|
}
|
|
1217
1227
|
function scaffoldSchemaDeclaration(schematic, data) {
|
|
1218
1228
|
const schematicKind = data.schematicKinds.get(schematic.kind);
|
|
1219
|
-
if (!schematicKind) throw new Error(`Unknown schematic kind ${schematic.kind}
|
|
1229
|
+
if (!schematicKind) throw new Error(`Unknown schematic kind: '${schematic.kind}'.`);
|
|
1220
1230
|
const nDecls = data.currentFile.declarations.length;
|
|
1221
1231
|
data.currentFile.declarations.push("");
|
|
1222
1232
|
const decl = `val ${schematic.name}Schema = ${schematicKind.scaffoldSchema?.(schematic, data) ?? `${simpleKtName(schematicKind.schema)}()`}`;
|
|
@@ -1225,7 +1235,7 @@ function scaffoldSchemaDeclaration(schematic, data) {
|
|
|
1225
1235
|
}
|
|
1226
1236
|
function scaffoldSchema(schematic, data) {
|
|
1227
1237
|
const schematicKind = data.schematicKinds.get(schematic.kind);
|
|
1228
|
-
if (!schematicKind) throw new Error(`Unknown schematic kind ${schematic.kind}
|
|
1238
|
+
if (!schematicKind) throw new Error(`Unknown schematic kind: '${schematic.kind}'.`);
|
|
1229
1239
|
const schematicPackage = schematicKind.package ?? joinPackages(data.currentPackage, schematic.packageSuffix);
|
|
1230
1240
|
let scaffoldedSchema;
|
|
1231
1241
|
if (schematicKind.package == null && schematicPackage !== data.currentPackage) {
|
|
@@ -1296,9 +1306,9 @@ function scaffoldValidator(schematic, data) {
|
|
|
1296
1306
|
});
|
|
1297
1307
|
}
|
|
1298
1308
|
//#endregion
|
|
1299
|
-
//#region src/util/
|
|
1300
|
-
/** `useLayoutEffect` hook which
|
|
1301
|
-
var
|
|
1309
|
+
//#region src/util/useSafeLayoutEffect.ts
|
|
1310
|
+
/** `useLayoutEffect` hook which runs `useEffect` on the server. */
|
|
1311
|
+
var useSafeLayoutEffect = typeof document !== "undefined" ? useLayoutEffect : useEffect;
|
|
1302
1312
|
//#endregion
|
|
1303
1313
|
//#region src/util/useMeasure.ts
|
|
1304
1314
|
/**
|
|
@@ -1306,7 +1316,7 @@ var useLayoutEffect$1 = typeof document !== "undefined" ? useLayoutEffect : () =
|
|
|
1306
1316
|
* API + window resize.
|
|
1307
1317
|
*/
|
|
1308
1318
|
function useMeasure(element, setMeasurement) {
|
|
1309
|
-
|
|
1319
|
+
useSafeLayoutEffect(() => {
|
|
1310
1320
|
if (!element) {
|
|
1311
1321
|
setMeasurement(void 0);
|
|
1312
1322
|
return;
|
|
@@ -1372,7 +1382,7 @@ function SchematicBuilder({ name = "kform", title = document.title, basePath, ba
|
|
|
1372
1382
|
/* @__PURE__ */ jsx(LoadSchematic, {}),
|
|
1373
1383
|
/* @__PURE__ */ jsx(SaveSchematic, {}),
|
|
1374
1384
|
/* @__PURE__ */ jsx(ScaffoldToZip, {})
|
|
1375
|
-
] }), configs = /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(UseFileBase64SerializerConfig, {}), /* @__PURE__ */ jsx(UseTableValuesSerializerConfig, {})] }), version = "0.
|
|
1385
|
+
] }), configs = /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(UseFileBase64SerializerConfig, {}), /* @__PURE__ */ jsx(UseTableValuesSerializerConfig, {})] }), version = "0.37.0" }) {
|
|
1376
1386
|
const [useSchematic] = useState(() => create(persist(() => createSchematic({
|
|
1377
1387
|
kind: classSchematicKind.kind,
|
|
1378
1388
|
packageSuffix: defaultRootClassPackage,
|
|
@@ -1387,7 +1397,7 @@ function SchematicBuilder({ name = "kform", title = document.title, basePath, ba
|
|
|
1387
1397
|
delay: 400,
|
|
1388
1398
|
tolerance: 20
|
|
1389
1399
|
} }), useSensor(KeyboardSensor));
|
|
1390
|
-
return /* @__PURE__ */ jsx(SchematicBuilderContext
|
|
1400
|
+
return /* @__PURE__ */ jsx(SchematicBuilderContext, {
|
|
1391
1401
|
value: {
|
|
1392
1402
|
name,
|
|
1393
1403
|
basePath,
|