@sepveneto/dnde-core 0.6.3 → 0.6.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/dist/{Node-B7pDsvZF.d.cts → capability-Ce3qGTm3.d.cts} +198 -127
  2. package/dist/{Node-B7pDsvZF.d.ts → capability-Ce3qGTm3.d.ts} +198 -127
  3. package/dist/capability.cjs +172 -0
  4. package/dist/capability.d.cts +4 -0
  5. package/dist/capability.d.ts +4 -0
  6. package/dist/capability.js +15 -0
  7. package/dist/{chunk-PRK4NPVH.js → chunk-62FPS6PZ.js} +2 -0
  8. package/dist/chunk-IQ5LOS7W.js +0 -0
  9. package/dist/{chunk-KJZSF66T.js → chunk-RLMXVDJK.js} +1 -16
  10. package/dist/chunk-W7WBD3NX.js +360 -0
  11. package/dist/chunk-XXR7SKZ3.js +132 -0
  12. package/dist/class/Container.d.cts +2 -2
  13. package/dist/class/Container.d.ts +2 -2
  14. package/dist/class/Node.cjs +2 -18
  15. package/dist/class/Node.d.cts +1 -1
  16. package/dist/class/Node.d.ts +1 -1
  17. package/dist/class/Node.js +3 -5
  18. package/dist/class/Widget.d.cts +1 -1
  19. package/dist/class/Widget.d.ts +1 -1
  20. package/dist/class/index.cjs +0 -16
  21. package/dist/class/index.d.cts +2 -2
  22. package/dist/class/index.d.ts +2 -2
  23. package/dist/class/index.js +4 -5
  24. package/dist/dsl.cjs +405 -0
  25. package/dist/dsl.d.cts +85 -0
  26. package/dist/dsl.d.ts +85 -0
  27. package/dist/dsl.js +12 -0
  28. package/dist/helper/index.cjs +2 -0
  29. package/dist/helper/index.d.cts +1 -1
  30. package/dist/helper/index.d.ts +1 -1
  31. package/dist/helper/index.js +1 -1
  32. package/dist/helper/schema.cjs +2 -0
  33. package/dist/helper/schema.d.cts +3 -1
  34. package/dist/helper/schema.d.ts +3 -1
  35. package/dist/helper/schema.js +1 -1
  36. package/dist/helper/widget.d.cts +1 -1
  37. package/dist/helper/widget.d.ts +1 -1
  38. package/dist/index.cjs +693 -0
  39. package/dist/index.d.cts +3 -1
  40. package/dist/index.d.ts +3 -1
  41. package/dist/index.js +34 -1
  42. package/dist/internal.d.cts +2 -2
  43. package/dist/internal.d.ts +2 -2
  44. package/dist/tokens.d.cts +1 -1
  45. package/dist/tokens.d.ts +1 -1
  46. package/dist/types.d.cts +1 -1
  47. package/dist/types.d.ts +1 -1
  48. package/package.json +1 -1
package/dist/dsl.cjs ADDED
@@ -0,0 +1,405 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
8
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
9
+ var __spreadValues = (a, b) => {
10
+ for (var prop in b || (b = {}))
11
+ if (__hasOwnProp.call(b, prop))
12
+ __defNormalProp(a, prop, b[prop]);
13
+ if (__getOwnPropSymbols)
14
+ for (var prop of __getOwnPropSymbols(b)) {
15
+ if (__propIsEnum.call(b, prop))
16
+ __defNormalProp(a, prop, b[prop]);
17
+ }
18
+ return a;
19
+ };
20
+ var __export = (target, all) => {
21
+ for (var name in all)
22
+ __defProp(target, name, { get: all[name], enumerable: true });
23
+ };
24
+ var __copyProps = (to, from, except, desc) => {
25
+ if (from && typeof from === "object" || typeof from === "function") {
26
+ for (let key of __getOwnPropNames(from))
27
+ if (!__hasOwnProp.call(to, key) && key !== except)
28
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
29
+ }
30
+ return to;
31
+ };
32
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
33
+
34
+ // src/dsl.ts
35
+ var dsl_exports = {};
36
+ __export(dsl_exports, {
37
+ isKnownScope: () => isKnownScope,
38
+ isStyleField: () => isStyleField,
39
+ validateEditorDsl: () => validateEditorDsl
40
+ });
41
+ module.exports = __toCommonJS(dsl_exports);
42
+
43
+ // src/capability.ts
44
+ function findWidgetCapability(catalog, type) {
45
+ return catalog.widgets.find((widget) => widget.type === type);
46
+ }
47
+ function findFieldCapability(widget, key) {
48
+ return widget.fields.find((field) => field.key === key);
49
+ }
50
+ function findCustomCapability(widget, type, name) {
51
+ var _a;
52
+ return (_a = widget.customTypes.find((item) => item.type === type)) == null ? void 0 : _a.capabilities.find((capability) => capability.name === name);
53
+ }
54
+
55
+ // src/dsl.ts
56
+ function asRecord(value) {
57
+ return value && typeof value === "object" && !Array.isArray(value) ? value : {};
58
+ }
59
+ function isScope(value) {
60
+ return value === "style" || value === "content" || value === "layout";
61
+ }
62
+ function allowsScope(mode, scope) {
63
+ if (mode === "any")
64
+ return true;
65
+ return mode === "style_only" && scope === "style" || mode === "content_only" && scope === "content" || mode === "layout_only" && scope === "layout";
66
+ }
67
+ function matchesValueType(field, value) {
68
+ var _a, _b;
69
+ if (!field)
70
+ return false;
71
+ switch (field.valueType) {
72
+ case "string":
73
+ return typeof value === "string";
74
+ case "number":
75
+ return typeof value === "number" && Number.isFinite(value);
76
+ case "integer":
77
+ return Number.isInteger(value);
78
+ case "boolean":
79
+ return typeof value === "boolean";
80
+ case "enum":
81
+ return (_b = (_a = field.enum) == null ? void 0 : _a.some((item) => Object.is(item, value))) != null ? _b : true;
82
+ case "array":
83
+ return Array.isArray(value);
84
+ case "object":
85
+ return Boolean(value) && typeof value === "object" && !Array.isArray(value);
86
+ default:
87
+ return true;
88
+ }
89
+ }
90
+ function validateFieldValue(widget, key, value, scopeMode, path, issues) {
91
+ const field = findFieldCapability(widget, key);
92
+ if (!field) {
93
+ issues.push({
94
+ code: "unknown_prop",
95
+ path,
96
+ message: `${widget.type} \u6CA1\u6709\u767B\u8BB0\u6807\u51C6\u5B57\u6BB5 ${key}`
97
+ });
98
+ return false;
99
+ }
100
+ if (field.readOnly) {
101
+ issues.push({
102
+ code: "read_only_prop",
103
+ path,
104
+ message: `${widget.type}.${key} \u4E3A\u53EA\u8BFB\u5B57\u6BB5`
105
+ });
106
+ return false;
107
+ }
108
+ if (!allowsScope(scopeMode, field.scope)) {
109
+ issues.push({
110
+ code: "scope_violation",
111
+ path,
112
+ message: `${widget.type}.${key} \u5C5E\u4E8E ${field.scope}\uFF0C\u5F53\u524D scope \u4E0D\u5141\u8BB8\u5199\u5165`
113
+ });
114
+ return false;
115
+ }
116
+ if (!matchesValueType(field, value)) {
117
+ issues.push({
118
+ code: "invalid_prop_type",
119
+ path,
120
+ message: `${widget.type}.${key} \u9700\u8981 ${field.valueType} \u7C7B\u578B`
121
+ });
122
+ return false;
123
+ }
124
+ if (typeof value === "number" && field.minimum !== void 0 && value < field.minimum) {
125
+ issues.push({
126
+ code: "prop_below_minimum",
127
+ path,
128
+ message: `${widget.type}.${key} \u4E0D\u80FD\u5C0F\u4E8E ${field.minimum}`
129
+ });
130
+ return false;
131
+ }
132
+ if (typeof value === "number" && field.maximum !== void 0 && value > field.maximum) {
133
+ issues.push({
134
+ code: "prop_above_maximum",
135
+ path,
136
+ message: `${widget.type}.${key} \u4E0D\u80FD\u5927\u4E8E ${field.maximum}`
137
+ });
138
+ return false;
139
+ }
140
+ return true;
141
+ }
142
+ function validateProps(widget, props, container, scopeMode, path, issues) {
143
+ if (props === void 0)
144
+ return;
145
+ if (!props || typeof props !== "object" || Array.isArray(props)) {
146
+ issues.push({
147
+ code: "invalid_props",
148
+ path,
149
+ message: "props \u5FC5\u987B\u662F\u5BF9\u8C61"
150
+ });
151
+ return;
152
+ }
153
+ Object.entries(props).forEach(([key, value]) => {
154
+ const field = findFieldCapability(widget, key);
155
+ if (field && container === "props" && field.scope === "style") {
156
+ issues.push({
157
+ code: "style_field_in_props",
158
+ path: `${path}.${key}`,
159
+ message: `${widget.type}.${key} \u662F\u6837\u5F0F\u5B57\u6BB5\uFF0C\u5FC5\u987B\u5199\u5165 style`
160
+ });
161
+ return;
162
+ }
163
+ if (field && container === "style" && field.scope !== "style") {
164
+ issues.push({
165
+ code: "non_style_field_in_style",
166
+ path: `${path}.${key}`,
167
+ message: `${widget.type}.${key} \u4E0D\u662F\u6837\u5F0F\u5B57\u6BB5\uFF0C\u4E0D\u80FD\u5199\u5165 style`
168
+ });
169
+ return;
170
+ }
171
+ validateFieldValue(widget, key, value, scopeMode, `${path}.${key}`, issues);
172
+ });
173
+ }
174
+ function validateCustom(widget, custom, scopeMode, path, issues) {
175
+ if (custom === void 0)
176
+ return;
177
+ if (!Array.isArray(custom)) {
178
+ issues.push({
179
+ code: "invalid_custom_operations",
180
+ path,
181
+ message: "custom \u5FC5\u987B\u662F\u80FD\u529B\u64CD\u4F5C\u6570\u7EC4"
182
+ });
183
+ return;
184
+ }
185
+ custom.forEach((rawOperation, index) => {
186
+ const operation = asRecord(rawOperation);
187
+ const type = typeof operation.type === "string" ? operation.type : "";
188
+ const name = typeof operation.capability === "string" ? operation.capability : "";
189
+ const capability = findCustomCapability(widget, type, name);
190
+ if (!capability) {
191
+ issues.push({
192
+ code: "unsupported_capability",
193
+ path: `${path}[${index}]`,
194
+ message: `${widget.type} \u672A\u767B\u8BB0 custom type ${type} \u7684\u80FD\u529B ${name}`
195
+ });
196
+ return;
197
+ }
198
+ if (!allowsScope(scopeMode, capability.writableScope)) {
199
+ issues.push({
200
+ code: "scope_violation",
201
+ path: `${path}[${index}]`,
202
+ message: `\u80FD\u529B ${name} \u5C5E\u4E8E ${capability.writableScope}\uFF0C\u5F53\u524D scope \u4E0D\u5141\u8BB8\u5199\u5165`
203
+ });
204
+ }
205
+ });
206
+ }
207
+ function placementCount(placement) {
208
+ return ["afterUuid", "beforeUuid", "afterKey", "beforeKey"].filter((key) => typeof placement[key] === "string" && placement[key]).length;
209
+ }
210
+ function validateEditorDsl(input, options) {
211
+ const issues = [];
212
+ const dsl = asRecord(input);
213
+ const operations = Array.isArray(dsl.operations) ? dsl.operations : [];
214
+ const scope = asRecord(dsl.scope);
215
+ const scopeMode = scope.mode;
216
+ if (dsl.dslVersion !== "1.1") {
217
+ issues.push({
218
+ code: "unsupported_dsl_version",
219
+ path: "dslVersion",
220
+ message: "\u4EC5\u652F\u6301 dslVersion 1.1"
221
+ });
222
+ }
223
+ if (dsl.baseRevision !== options.snapshot.revision) {
224
+ issues.push({
225
+ code: "stale_revision",
226
+ path: "baseRevision",
227
+ message: `DSL \u57FA\u4E8E revision ${String(dsl.baseRevision)}\uFF0C\u5F53\u524D\u4E3A ${options.snapshot.revision}`
228
+ });
229
+ }
230
+ if (scopeMode !== "style_only" && scopeMode !== "content_only" && scopeMode !== "layout_only" && scopeMode !== "any") {
231
+ issues.push({
232
+ code: "invalid_scope",
233
+ path: "scope.mode",
234
+ message: "scope.mode \u5FC5\u987B\u662F style_only/content_only/layout_only/any"
235
+ });
236
+ }
237
+ const scopeTargets = Array.isArray(scope.targets) ? scope.targets.filter((target) => typeof target === "string") : [];
238
+ if (!operations.length) {
239
+ issues.push({
240
+ code: "empty_operations",
241
+ path: "operations",
242
+ message: "DSL \u81F3\u5C11\u9700\u8981\u4E00\u4E2A\u64CD\u4F5C"
243
+ });
244
+ }
245
+ const nodeUuids = new Set(options.snapshot.nodes.map((node) => node.uuid));
246
+ const addKeys = /* @__PURE__ */ new Set();
247
+ const normalizedOperations = [];
248
+ operations.forEach((rawOperation, index) => {
249
+ var _a, _b;
250
+ const operation = asRecord(rawOperation);
251
+ const path = `operations[${index}]`;
252
+ const op = operation.op;
253
+ if (op !== "add" && op !== "update" && op !== "delete") {
254
+ issues.push({
255
+ code: "unsupported_operation",
256
+ path: `${path}.op`,
257
+ message: `\u4E0D\u652F\u6301\u7684\u64CD\u4F5C ${String(op)}`
258
+ });
259
+ return;
260
+ }
261
+ if (op === "add") {
262
+ const key = typeof operation.key === "string" ? operation.key : "";
263
+ const widgetType = typeof operation.widget === "string" ? operation.widget : "";
264
+ const widget2 = findWidgetCapability(options.catalog, widgetType);
265
+ if (!key) {
266
+ issues.push({ code: "missing_key", path: `${path}.key`, message: "add \u5FC5\u987B\u63D0\u4F9B\u6279\u5185\u552F\u4E00 key" });
267
+ } else if (addKeys.has(key)) {
268
+ issues.push({ code: "duplicate_key", path: `${path}.key`, message: `\u6279\u5185 key \u91CD\u590D\uFF1A${key}` });
269
+ }
270
+ if (!widget2) {
271
+ issues.push({
272
+ code: "unknown_widget",
273
+ path: `${path}.widget`,
274
+ message: `\u7EC4\u4EF6\u80FD\u529B\u76EE\u5F55\u4E2D\u4E0D\u5B58\u5728 ${widgetType}`
275
+ });
276
+ }
277
+ const placement = asRecord(operation.placement);
278
+ if (placementCount(placement) > 1) {
279
+ issues.push({
280
+ code: "ambiguous_placement",
281
+ path: `${path}.placement`,
282
+ message: "placement \u53EA\u80FD\u6307\u5B9A\u4E00\u4E2A\u76F8\u5BF9\u4F4D\u7F6E"
283
+ });
284
+ }
285
+ for (const keyName of ["afterKey", "beforeKey"]) {
286
+ const reference = typeof placement[keyName] === "string" ? placement[keyName] : "";
287
+ if (reference && !addKeys.has(reference)) {
288
+ issues.push({
289
+ code: "unknown_batch_key",
290
+ path: `${path}.placement.${keyName}`,
291
+ message: `\u6279\u5185 key ${reference} \u5C1A\u672A\u521B\u5EFA`
292
+ });
293
+ }
294
+ }
295
+ for (const uuidName of ["afterUuid", "beforeUuid"]) {
296
+ const reference = typeof placement[uuidName] === "string" ? placement[uuidName] : "";
297
+ if (reference && !nodeUuids.has(reference)) {
298
+ issues.push({
299
+ code: "unknown_node",
300
+ path: `${path}.placement.${uuidName}`,
301
+ message: `\u8282\u70B9 ${reference} \u4E0D\u5B58\u5728`
302
+ });
303
+ }
304
+ }
305
+ if (widget2) {
306
+ const customOperations = operation.custom === void 0 ? [] : operation.custom;
307
+ validateProps(widget2, operation.props, "props", scopeMode, `${path}.props`, issues);
308
+ validateProps(widget2, operation.style, "style", scopeMode, `${path}.style`, issues);
309
+ validateCustom(widget2, customOperations, scopeMode, `${path}.custom`, issues);
310
+ }
311
+ if (key)
312
+ addKeys.add(key);
313
+ normalizedOperations.push({
314
+ op,
315
+ key,
316
+ widget: widgetType,
317
+ placement,
318
+ props: asRecord(operation.props),
319
+ style: asRecord(operation.style),
320
+ custom: Array.isArray(operation.custom) ? operation.custom : []
321
+ });
322
+ return;
323
+ }
324
+ const uuid = typeof operation.uuid === "string" ? operation.uuid : "";
325
+ const node = options.snapshot.nodes.find((item) => item.uuid === uuid);
326
+ if (!node) {
327
+ issues.push({
328
+ code: "unknown_node",
329
+ path: `${path}.uuid`,
330
+ message: `\u8282\u70B9 ${uuid || "(\u7A7A)"} \u4E0D\u5B58\u5728`
331
+ });
332
+ }
333
+ if (scopeTargets.length && !scopeTargets.includes(uuid)) {
334
+ issues.push({
335
+ code: "target_outside_scope",
336
+ path: `${path}.uuid`,
337
+ message: `\u8282\u70B9 ${uuid} \u4E0D\u5728 scope.targets \u5185`
338
+ });
339
+ }
340
+ if (op === "delete") {
341
+ if (!operation.confirmToken) {
342
+ issues.push({
343
+ code: "delete_confirmation_required",
344
+ path: `${path}.confirmToken`,
345
+ message: "\u5220\u9664\u64CD\u4F5C\u5FC5\u987B\u643A\u5E26\u4E00\u6B21\u6027\u786E\u8BA4\u4EE4\u724C"
346
+ });
347
+ } else if (!((_a = options.snapshot.confirmTokens) == null ? void 0 : _a.includes(String(operation.confirmToken)))) {
348
+ issues.push({
349
+ code: "invalid_confirm_token",
350
+ path: `${path}.confirmToken`,
351
+ message: "\u5220\u9664\u786E\u8BA4\u4EE4\u724C\u65E0\u6548\u6216\u5DF2\u8FC7\u671F"
352
+ });
353
+ }
354
+ normalizedOperations.push({ op, uuid, confirmToken: String((_b = operation.confirmToken) != null ? _b : "") });
355
+ return;
356
+ }
357
+ const widget = node ? findWidgetCapability(options.catalog, node.type) : void 0;
358
+ if (node && widget) {
359
+ validateProps(widget, operation.props, "props", scopeMode, `${path}.props`, issues);
360
+ validateProps(widget, operation.style, "style", scopeMode, `${path}.style`, issues);
361
+ validateCustom(widget, operation.custom, scopeMode, `${path}.custom`, issues);
362
+ }
363
+ normalizedOperations.push({
364
+ op,
365
+ uuid,
366
+ props: asRecord(operation.props),
367
+ style: asRecord(operation.style),
368
+ custom: Array.isArray(operation.custom) ? operation.custom : []
369
+ });
370
+ });
371
+ if (scopeTargets.some((target) => !nodeUuids.has(target))) {
372
+ issues.push({
373
+ code: "unknown_scope_target",
374
+ path: "scope.targets",
375
+ message: "scope.targets \u5305\u542B\u4E0D\u5B58\u5728\u7684\u8282\u70B9"
376
+ });
377
+ }
378
+ return __spreadValues({
379
+ ok: issues.length === 0,
380
+ issues
381
+ }, issues.length ? {} : {
382
+ normalized: {
383
+ dslVersion: "1.1",
384
+ baseRevision: options.snapshot.revision,
385
+ scope: {
386
+ mode: scopeMode,
387
+ targets: scopeTargets
388
+ },
389
+ operations: normalizedOperations
390
+ }
391
+ });
392
+ }
393
+ function isStyleField(widget, key) {
394
+ var _a;
395
+ return ((_a = findFieldCapability(widget, key)) == null ? void 0 : _a.scope) === "style";
396
+ }
397
+ function isKnownScope(value) {
398
+ return isScope(value);
399
+ }
400
+ // Annotate the CommonJS export names for ESM import in node:
401
+ 0 && (module.exports = {
402
+ isKnownScope,
403
+ isStyleField,
404
+ validateEditorDsl
405
+ });
package/dist/dsl.d.cts ADDED
@@ -0,0 +1,85 @@
1
+ import { j as CapabilityCatalog, i as WidgetCapability, F as FieldScope } from './capability-Ce3qGTm3.cjs';
2
+ import 'element-plus';
3
+ import 'vue';
4
+ import 'async-validator';
5
+
6
+ type DslScopeMode = 'style_only' | 'content_only' | 'layout_only' | 'any';
7
+ interface DslScope {
8
+ mode: DslScopeMode;
9
+ targets: string[];
10
+ }
11
+ interface DslPlacement {
12
+ afterUuid?: string;
13
+ beforeUuid?: string;
14
+ afterKey?: string;
15
+ beforeKey?: string;
16
+ group?: string;
17
+ }
18
+ interface DslCustomOperation {
19
+ type: string;
20
+ capability: string;
21
+ args: Record<string, unknown>;
22
+ }
23
+ interface DslAddOperation {
24
+ op: 'add';
25
+ key: string;
26
+ widget: string;
27
+ placement?: DslPlacement;
28
+ props?: Record<string, unknown>;
29
+ style?: Record<string, unknown>;
30
+ custom?: DslCustomOperation[];
31
+ }
32
+ interface DslUpdateOperation {
33
+ op: 'update';
34
+ uuid: string;
35
+ props?: Record<string, unknown>;
36
+ style?: Record<string, unknown>;
37
+ custom?: DslCustomOperation[];
38
+ }
39
+ interface DslDeleteOperation {
40
+ op: 'delete';
41
+ uuid: string;
42
+ confirmToken?: string;
43
+ }
44
+ type DslOperation = DslAddOperation | DslUpdateOperation | DslDeleteOperation;
45
+ interface EditorDsl {
46
+ dslVersion: '1.1';
47
+ baseRevision: number;
48
+ scope: DslScope;
49
+ operations: DslOperation[];
50
+ }
51
+ interface DslNodeSummary {
52
+ uuid: string;
53
+ type: string;
54
+ parentUuid?: string;
55
+ }
56
+ interface DslDocumentSnapshot {
57
+ revision: number;
58
+ nodes: DslNodeSummary[];
59
+ /** Tokens issued by the host after previewing destructive operations. */
60
+ confirmTokens?: string[];
61
+ }
62
+ interface DslIssue {
63
+ code: string;
64
+ path: string;
65
+ message: string;
66
+ }
67
+ interface DslValidationResult {
68
+ ok: boolean;
69
+ issues: DslIssue[];
70
+ normalized?: EditorDsl;
71
+ }
72
+ interface DslValidationOptions {
73
+ catalog: CapabilityCatalog;
74
+ snapshot: DslDocumentSnapshot;
75
+ }
76
+ /**
77
+ * Deterministic, side-effect-free validation for the versioned editor DSL.
78
+ * The host must validate before applying; the executor repeats critical checks
79
+ * against the live document.
80
+ */
81
+ declare function validateEditorDsl(input: unknown, options: DslValidationOptions): DslValidationResult;
82
+ declare function isStyleField(widget: WidgetCapability, key: string): boolean;
83
+ declare function isKnownScope(value: unknown): value is FieldScope;
84
+
85
+ export { type DslAddOperation, type DslCustomOperation, type DslDeleteOperation, type DslDocumentSnapshot, type DslIssue, type DslNodeSummary, type DslOperation, type DslPlacement, type DslScope, type DslScopeMode, type DslUpdateOperation, type DslValidationOptions, type DslValidationResult, type EditorDsl, isKnownScope, isStyleField, validateEditorDsl };
package/dist/dsl.d.ts ADDED
@@ -0,0 +1,85 @@
1
+ import { j as CapabilityCatalog, i as WidgetCapability, F as FieldScope } from './capability-Ce3qGTm3.js';
2
+ import 'element-plus';
3
+ import 'vue';
4
+ import 'async-validator';
5
+
6
+ type DslScopeMode = 'style_only' | 'content_only' | 'layout_only' | 'any';
7
+ interface DslScope {
8
+ mode: DslScopeMode;
9
+ targets: string[];
10
+ }
11
+ interface DslPlacement {
12
+ afterUuid?: string;
13
+ beforeUuid?: string;
14
+ afterKey?: string;
15
+ beforeKey?: string;
16
+ group?: string;
17
+ }
18
+ interface DslCustomOperation {
19
+ type: string;
20
+ capability: string;
21
+ args: Record<string, unknown>;
22
+ }
23
+ interface DslAddOperation {
24
+ op: 'add';
25
+ key: string;
26
+ widget: string;
27
+ placement?: DslPlacement;
28
+ props?: Record<string, unknown>;
29
+ style?: Record<string, unknown>;
30
+ custom?: DslCustomOperation[];
31
+ }
32
+ interface DslUpdateOperation {
33
+ op: 'update';
34
+ uuid: string;
35
+ props?: Record<string, unknown>;
36
+ style?: Record<string, unknown>;
37
+ custom?: DslCustomOperation[];
38
+ }
39
+ interface DslDeleteOperation {
40
+ op: 'delete';
41
+ uuid: string;
42
+ confirmToken?: string;
43
+ }
44
+ type DslOperation = DslAddOperation | DslUpdateOperation | DslDeleteOperation;
45
+ interface EditorDsl {
46
+ dslVersion: '1.1';
47
+ baseRevision: number;
48
+ scope: DslScope;
49
+ operations: DslOperation[];
50
+ }
51
+ interface DslNodeSummary {
52
+ uuid: string;
53
+ type: string;
54
+ parentUuid?: string;
55
+ }
56
+ interface DslDocumentSnapshot {
57
+ revision: number;
58
+ nodes: DslNodeSummary[];
59
+ /** Tokens issued by the host after previewing destructive operations. */
60
+ confirmTokens?: string[];
61
+ }
62
+ interface DslIssue {
63
+ code: string;
64
+ path: string;
65
+ message: string;
66
+ }
67
+ interface DslValidationResult {
68
+ ok: boolean;
69
+ issues: DslIssue[];
70
+ normalized?: EditorDsl;
71
+ }
72
+ interface DslValidationOptions {
73
+ catalog: CapabilityCatalog;
74
+ snapshot: DslDocumentSnapshot;
75
+ }
76
+ /**
77
+ * Deterministic, side-effect-free validation for the versioned editor DSL.
78
+ * The host must validate before applying; the executor repeats critical checks
79
+ * against the live document.
80
+ */
81
+ declare function validateEditorDsl(input: unknown, options: DslValidationOptions): DslValidationResult;
82
+ declare function isStyleField(widget: WidgetCapability, key: string): boolean;
83
+ declare function isKnownScope(value: unknown): value is FieldScope;
84
+
85
+ export { type DslAddOperation, type DslCustomOperation, type DslDeleteOperation, type DslDocumentSnapshot, type DslIssue, type DslNodeSummary, type DslOperation, type DslPlacement, type DslScope, type DslScopeMode, type DslUpdateOperation, type DslValidationOptions, type DslValidationResult, type EditorDsl, isKnownScope, isStyleField, validateEditorDsl };
package/dist/dsl.js ADDED
@@ -0,0 +1,12 @@
1
+ import {
2
+ isKnownScope,
3
+ isStyleField,
4
+ validateEditorDsl
5
+ } from "./chunk-W7WBD3NX.js";
6
+ import "./chunk-XXR7SKZ3.js";
7
+ import "./chunk-6FNC3XMI.js";
8
+ export {
9
+ isKnownScope,
10
+ isStyleField,
11
+ validateEditorDsl
12
+ };
@@ -89,6 +89,8 @@ var schema = {
89
89
  _role: config._role,
90
90
  label: config.label,
91
91
  key: config.key,
92
+ scope: config.scope,
93
+ readOnly: config.readOnly,
92
94
  type,
93
95
  formItem: config.formItem,
94
96
  rules: normalizeRules(config),
@@ -2,6 +2,6 @@ export { EventEmitter } from './EventEmitter.cjs';
2
2
  export { schema } from './schema.cjs';
3
3
  export { widget, widgetType } from './widget.cjs';
4
4
  import 'element-plus';
5
- import '../Node-B7pDsvZF.cjs';
5
+ import '../capability-Ce3qGTm3.cjs';
6
6
  import 'vue';
7
7
  import 'async-validator';
@@ -2,6 +2,6 @@ export { EventEmitter } from './EventEmitter.js';
2
2
  export { schema } from './schema.js';
3
3
  export { widget, widgetType } from './widget.js';
4
4
  import 'element-plus';
5
- import '../Node-B7pDsvZF.js';
5
+ import '../capability-Ce3qGTm3.js';
6
6
  import 'vue';
7
7
  import 'async-validator';
@@ -4,7 +4,7 @@ import {
4
4
  } from "../chunk-W776G2UQ.js";
5
5
  import {
6
6
  schema
7
- } from "../chunk-PRK4NPVH.js";
7
+ } from "../chunk-62FPS6PZ.js";
8
8
  import {
9
9
  widget,
10
10
  widgetType
@@ -53,6 +53,8 @@ var schema = {
53
53
  _role: config._role,
54
54
  label: config.label,
55
55
  key: config.key,
56
+ scope: config.scope,
57
+ readOnly: config.readOnly,
56
58
  type,
57
59
  formItem: config.formItem,
58
60
  rules: normalizeRules(config),
@@ -1,5 +1,5 @@
1
1
  import { FormItemProps, InputProps, InputNumberProps, CheckboxProps, SelectProps, RadioProps, RadioButtonProps, SwitchProps, DatePickerProps, ColorPickerProps } from 'element-plus';
2
- import { l as SchemaItem, O as Option, R as RadioOption, m as RadioButtonOption } from '../Node-B7pDsvZF.cjs';
2
+ import { b as SchemaItem, F as FieldScope, O as Option, R as RadioOption, a as RadioButtonOption } from '../capability-Ce3qGTm3.cjs';
3
3
  import 'vue';
4
4
  import 'async-validator';
5
5
 
@@ -8,6 +8,8 @@ interface BaseConfig {
8
8
  _role?: string;
9
9
  label: SchemaItem['label'];
10
10
  key: SchemaItem['key'];
11
+ scope?: FieldScope;
12
+ readOnly?: boolean;
11
13
  tips?: string;
12
14
  formItem?: Partial<FormItemProps>;
13
15
  required?: boolean | string;
@@ -1,5 +1,5 @@
1
1
  import { FormItemProps, InputProps, InputNumberProps, CheckboxProps, SelectProps, RadioProps, RadioButtonProps, SwitchProps, DatePickerProps, ColorPickerProps } from 'element-plus';
2
- import { l as SchemaItem, O as Option, R as RadioOption, m as RadioButtonOption } from '../Node-B7pDsvZF.js';
2
+ import { b as SchemaItem, F as FieldScope, O as Option, R as RadioOption, a as RadioButtonOption } from '../capability-Ce3qGTm3.js';
3
3
  import 'vue';
4
4
  import 'async-validator';
5
5
 
@@ -8,6 +8,8 @@ interface BaseConfig {
8
8
  _role?: string;
9
9
  label: SchemaItem['label'];
10
10
  key: SchemaItem['key'];
11
+ scope?: FieldScope;
12
+ readOnly?: boolean;
11
13
  tips?: string;
12
14
  formItem?: Partial<FormItemProps>;
13
15
  required?: boolean | string;
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  schema
3
- } from "../chunk-PRK4NPVH.js";
3
+ } from "../chunk-62FPS6PZ.js";
4
4
  import "../chunk-XJ2IJHKH.js";
5
5
  import "../chunk-6FNC3XMI.js";
6
6
  export {
@@ -1,4 +1,4 @@
1
- import { I as IWidget, l as SchemaItem, W as WidgetPos, b as WidgetAgent, B as Base } from '../Node-B7pDsvZF.cjs';
1
+ import { I as IWidget, b as SchemaItem, p as WidgetPos, t as WidgetAgent, B as Base } from '../capability-Ce3qGTm3.cjs';
2
2
  import * as vue from 'vue';
3
3
  import 'element-plus';
4
4
  import 'async-validator';