@widgentic/designer 0.1.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/LICENSE +21 -0
- package/README.md +27 -0
- package/dist/action-designer.d.ts +35 -0
- package/dist/action-designer.d.ts.map +1 -0
- package/dist/action-designer.js +294 -0
- package/dist/action-designer.js.map +1 -0
- package/dist/action-editor.d.ts +49 -0
- package/dist/action-editor.d.ts.map +1 -0
- package/dist/action-editor.js +515 -0
- package/dist/action-editor.js.map +1 -0
- package/dist/browser/widgentic-designer.js +433 -0
- package/dist/browser/widgentic-designer.js.map +7 -0
- package/dist/browser.d.ts +2 -0
- package/dist/browser.d.ts.map +1 -0
- package/dist/browser.js +12 -0
- package/dist/browser.js.map +1 -0
- package/dist/dom.d.ts +37 -0
- package/dist/dom.d.ts.map +1 -0
- package/dist/dom.js +387 -0
- package/dist/dom.js.map +1 -0
- package/dist/element.d.ts +12 -0
- package/dist/element.d.ts.map +1 -0
- package/dist/element.js +131 -0
- package/dist/element.js.map +1 -0
- package/dist/highlight.d.ts +30 -0
- package/dist/highlight.d.ts.map +1 -0
- package/dist/highlight.js +123 -0
- package/dist/highlight.js.map +1 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/dist/internal.d.ts +6 -0
- package/dist/internal.d.ts.map +1 -0
- package/dist/internal.js +10 -0
- package/dist/internal.js.map +1 -0
- package/dist/io.d.ts +32 -0
- package/dist/io.d.ts.map +1 -0
- package/dist/io.js +155 -0
- package/dist/io.js.map +1 -0
- package/dist/json-tree-editor.d.ts +8 -0
- package/dist/json-tree-editor.d.ts.map +1 -0
- package/dist/json-tree-editor.js +186 -0
- package/dist/json-tree-editor.js.map +1 -0
- package/dist/panels.d.ts +13 -0
- package/dist/panels.d.ts.map +1 -0
- package/dist/panels.js +414 -0
- package/dist/panels.js.map +1 -0
- package/dist/preview.d.ts +40 -0
- package/dist/preview.d.ts.map +1 -0
- package/dist/preview.js +138 -0
- package/dist/preview.js.map +1 -0
- package/dist/record-editor.d.ts +11 -0
- package/dist/record-editor.d.ts.map +1 -0
- package/dist/record-editor.js +70 -0
- package/dist/record-editor.js.map +1 -0
- package/dist/schema-builder.d.ts +8 -0
- package/dist/schema-builder.d.ts.map +1 -0
- package/dist/schema-builder.js +235 -0
- package/dist/schema-builder.js.map +1 -0
- package/dist/schema-designer.d.ts +33 -0
- package/dist/schema-designer.d.ts.map +1 -0
- package/dist/schema-designer.js +251 -0
- package/dist/schema-designer.js.map +1 -0
- package/dist/schema-form.d.ts +8 -0
- package/dist/schema-form.d.ts.map +1 -0
- package/dist/schema-form.js +181 -0
- package/dist/schema-form.js.map +1 -0
- package/dist/schema-paths.d.ts +18 -0
- package/dist/schema-paths.d.ts.map +1 -0
- package/dist/schema-paths.js +75 -0
- package/dist/schema-paths.js.map +1 -0
- package/dist/seed.d.ts +18 -0
- package/dist/seed.d.ts.map +1 -0
- package/dist/seed.js +299 -0
- package/dist/seed.js.map +1 -0
- package/dist/shell.d.ts +59 -0
- package/dist/shell.d.ts.map +1 -0
- package/dist/shell.js +102 -0
- package/dist/shell.js.map +1 -0
- package/dist/store.d.ts +44 -0
- package/dist/store.d.ts.map +1 -0
- package/dist/store.js +71 -0
- package/dist/store.js.map +1 -0
- package/dist/styles-editor.d.ts +8 -0
- package/dist/styles-editor.d.ts.map +1 -0
- package/dist/styles-editor.js +100 -0
- package/dist/styles-editor.js.map +1 -0
- package/dist/template-panel.d.ts +19 -0
- package/dist/template-panel.d.ts.map +1 -0
- package/dist/template-panel.js +585 -0
- package/dist/template-panel.js.map +1 -0
- package/dist/theme-designer.d.ts +35 -0
- package/dist/theme-designer.d.ts.map +1 -0
- package/dist/theme-designer.js +336 -0
- package/dist/theme-designer.js.map +1 -0
- package/dist/theme-panel.d.ts +20 -0
- package/dist/theme-panel.d.ts.map +1 -0
- package/dist/theme-panel.js +96 -0
- package/dist/theme-panel.js.map +1 -0
- package/dist/validate.d.ts +57 -0
- package/dist/validate.d.ts.map +1 -0
- package/dist/validate.js +131 -0
- package/dist/validate.js.map +1 -0
- package/package.json +49 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cheap syntax coloring for the JSON textareas: a highlighted <pre> layer
|
|
3
|
+
* sits exactly behind a transparent-text <textarea>, so the browser keeps
|
|
4
|
+
* doing all the real work (typing, selection, undo, IME) and we only paint
|
|
5
|
+
* colors. No editor library, no parsing beyond a tokenizer — invalid JSON
|
|
6
|
+
* still colors sensibly because the tokenizer is regex-based, never a
|
|
7
|
+
* parser.
|
|
8
|
+
*
|
|
9
|
+
* The two layers must agree on every metric that affects glyph position
|
|
10
|
+
* (font, size, line-height, padding, border width, white-space); the
|
|
11
|
+
* stylesheet keeps them in lockstep.
|
|
12
|
+
*/
|
|
13
|
+
interface Token {
|
|
14
|
+
/** Token class suffix: k(ey) s(tring) n(umber) b(oolean/null) p(unctuation). */
|
|
15
|
+
cls: string;
|
|
16
|
+
text: string;
|
|
17
|
+
}
|
|
18
|
+
export declare function tokenizeJson(text: string): Token[];
|
|
19
|
+
/**
|
|
20
|
+
* Wrap a textarea in the highlight layer. Returns a disposer that restores
|
|
21
|
+
* the original DOM shape.
|
|
22
|
+
*/
|
|
23
|
+
export declare function attachJsonHighlight(textarea: HTMLTextAreaElement): () => void;
|
|
24
|
+
/**
|
|
25
|
+
* Repaint after a programmatic value change (store refresh), which fires
|
|
26
|
+
* no input event.
|
|
27
|
+
*/
|
|
28
|
+
export declare function repaintHighlight(textarea: HTMLTextAreaElement): void;
|
|
29
|
+
export {};
|
|
30
|
+
//# sourceMappingURL=highlight.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"highlight.d.ts","sourceRoot":"","sources":["../src/highlight.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,UAAU,KAAK;IACb,gFAAgF;IAChF,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;CACd;AAKD,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,KAAK,EAAE,CA0BlD;AAoBD;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,mBAAmB,GAAG,MAAM,IAAI,CAgD7E;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,mBAAmB,GAAG,IAAI,CAGpE"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cheap syntax coloring for the JSON textareas: a highlighted <pre> layer
|
|
3
|
+
* sits exactly behind a transparent-text <textarea>, so the browser keeps
|
|
4
|
+
* doing all the real work (typing, selection, undo, IME) and we only paint
|
|
5
|
+
* colors. No editor library, no parsing beyond a tokenizer — invalid JSON
|
|
6
|
+
* still colors sensibly because the tokenizer is regex-based, never a
|
|
7
|
+
* parser.
|
|
8
|
+
*
|
|
9
|
+
* The two layers must agree on every metric that affects glyph position
|
|
10
|
+
* (font, size, line-height, padding, border width, white-space); the
|
|
11
|
+
* stylesheet keeps them in lockstep.
|
|
12
|
+
*/
|
|
13
|
+
const JSON_TOKENS = /("(?:[^"\\]|\\.)*")(\s*:)?|(-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)|\b(true|false|null)\b|([{}[\],:])/g;
|
|
14
|
+
export function tokenizeJson(text) {
|
|
15
|
+
const out = [];
|
|
16
|
+
let last = 0;
|
|
17
|
+
let match;
|
|
18
|
+
JSON_TOKENS.lastIndex = 0;
|
|
19
|
+
while ((match = JSON_TOKENS.exec(text)) !== null) {
|
|
20
|
+
if (match.index > last)
|
|
21
|
+
out.push({ cls: "", text: text.slice(last, match.index) });
|
|
22
|
+
if (match[1] !== undefined) {
|
|
23
|
+
// A string followed by ':' is an object key.
|
|
24
|
+
if (match[2] !== undefined) {
|
|
25
|
+
out.push({ cls: "k", text: match[1] });
|
|
26
|
+
out.push({ cls: "p", text: match[2] });
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
out.push({ cls: "s", text: match[1] });
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
else if (match[3] !== undefined) {
|
|
33
|
+
out.push({ cls: "n", text: match[3] });
|
|
34
|
+
}
|
|
35
|
+
else if (match[4] !== undefined) {
|
|
36
|
+
out.push({ cls: "b", text: match[4] });
|
|
37
|
+
}
|
|
38
|
+
else if (match[5] !== undefined) {
|
|
39
|
+
out.push({ cls: "p", text: match[5] });
|
|
40
|
+
}
|
|
41
|
+
last = JSON_TOKENS.lastIndex;
|
|
42
|
+
}
|
|
43
|
+
if (last < text.length)
|
|
44
|
+
out.push({ cls: "", text: text.slice(last) });
|
|
45
|
+
return out;
|
|
46
|
+
}
|
|
47
|
+
/** Paint tokens into the layer as DOM nodes (never innerHTML). */
|
|
48
|
+
function paint(layer, text) {
|
|
49
|
+
const nodes = [];
|
|
50
|
+
for (const token of tokenizeJson(text)) {
|
|
51
|
+
if (token.cls === "") {
|
|
52
|
+
nodes.push(document.createTextNode(token.text));
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
const span = document.createElement("span");
|
|
56
|
+
span.className = `wgd-hl-${token.cls}`;
|
|
57
|
+
span.textContent = token.text;
|
|
58
|
+
nodes.push(span);
|
|
59
|
+
}
|
|
60
|
+
// A trailing newline needs a following glyph box to render as a line.
|
|
61
|
+
nodes.push(document.createTextNode("\n"));
|
|
62
|
+
layer.replaceChildren(...nodes);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Wrap a textarea in the highlight layer. Returns a disposer that restores
|
|
66
|
+
* the original DOM shape.
|
|
67
|
+
*/
|
|
68
|
+
export function attachJsonHighlight(textarea) {
|
|
69
|
+
const parent = textarea.parentNode;
|
|
70
|
+
if (parent === null)
|
|
71
|
+
return () => undefined;
|
|
72
|
+
const wrap = document.createElement("div");
|
|
73
|
+
wrap.className = "wgd-hlwrap";
|
|
74
|
+
const layer = document.createElement("pre");
|
|
75
|
+
layer.className = "wgd-hl";
|
|
76
|
+
layer.setAttribute("aria-hidden", "true");
|
|
77
|
+
parent.insertBefore(wrap, textarea);
|
|
78
|
+
wrap.append(layer, textarea);
|
|
79
|
+
textarea.classList.add("wgd-hl-input");
|
|
80
|
+
const sync = () => {
|
|
81
|
+
paint(layer, textarea.value);
|
|
82
|
+
layer.scrollTop = textarea.scrollTop;
|
|
83
|
+
layer.scrollLeft = textarea.scrollLeft;
|
|
84
|
+
};
|
|
85
|
+
const syncScroll = () => {
|
|
86
|
+
layer.scrollTop = textarea.scrollTop;
|
|
87
|
+
layer.scrollLeft = textarea.scrollLeft;
|
|
88
|
+
};
|
|
89
|
+
// Tab indents instead of moving focus — these panes hold indented JSON.
|
|
90
|
+
// Shift+Tab keeps its focus-moving default as the keyboard escape.
|
|
91
|
+
const onTab = (event) => {
|
|
92
|
+
if (event.key !== "Tab" || event.shiftKey || textarea.readOnly)
|
|
93
|
+
return;
|
|
94
|
+
event.preventDefault();
|
|
95
|
+
const { selectionStart, selectionEnd, value } = textarea;
|
|
96
|
+
textarea.value = `${value.slice(0, selectionStart)} ${value.slice(selectionEnd)}`;
|
|
97
|
+
textarea.selectionStart = textarea.selectionEnd = selectionStart + 2;
|
|
98
|
+
// The commit path listens for input; a synthetic one keeps the store
|
|
99
|
+
// and the paint layer in step with the inserted spaces.
|
|
100
|
+
textarea.dispatchEvent(new Event("input", { bubbles: true }));
|
|
101
|
+
};
|
|
102
|
+
textarea.addEventListener("input", sync);
|
|
103
|
+
textarea.addEventListener("scroll", syncScroll);
|
|
104
|
+
textarea.addEventListener("keydown", onTab);
|
|
105
|
+
sync();
|
|
106
|
+
return () => {
|
|
107
|
+
textarea.removeEventListener("input", sync);
|
|
108
|
+
textarea.removeEventListener("scroll", syncScroll);
|
|
109
|
+
textarea.removeEventListener("keydown", onTab);
|
|
110
|
+
textarea.classList.remove("wgd-hl-input");
|
|
111
|
+
wrap.replaceWith(textarea);
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Repaint after a programmatic value change (store refresh), which fires
|
|
116
|
+
* no input event.
|
|
117
|
+
*/
|
|
118
|
+
export function repaintHighlight(textarea) {
|
|
119
|
+
const layer = textarea.parentElement?.querySelector(".wgd-hl");
|
|
120
|
+
if (layer instanceof HTMLElement)
|
|
121
|
+
paint(layer, textarea.value);
|
|
122
|
+
}
|
|
123
|
+
//# sourceMappingURL=highlight.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"highlight.js","sourceRoot":"","sources":["../src/highlight.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAQH,MAAM,WAAW,GACf,kGAAkG,CAAC;AAErG,MAAM,UAAU,YAAY,CAAC,IAAY;IACvC,MAAM,GAAG,GAAY,EAAE,CAAC;IACxB,IAAI,IAAI,GAAG,CAAC,CAAC;IACb,IAAI,KAA6B,CAAC;IAClC,WAAW,CAAC,SAAS,GAAG,CAAC,CAAC;IAC1B,OAAO,CAAC,KAAK,GAAG,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;QACjD,IAAI,KAAK,CAAC,KAAK,GAAG,IAAI;YAAE,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QACnF,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,SAAS,EAAE,CAAC;YAC3B,6CAA6C;YAC7C,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,SAAS,EAAE,CAAC;gBAC3B,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;gBACvC,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI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AEP,OAAO,GAAG,EAAE;QACV,QAAQ,CAAC,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QAC5C,QAAQ,CAAC,mBAAmB,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;QACnD,QAAQ,CAAC,mBAAmB,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;QAC/C,QAAQ,CAAC,SAAS,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;QAC1C,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;IAC7B,CAAC,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,QAA6B;IAC5D,MAAM,KAAK,GAAG,QAAQ,CAAC,aAAa,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;IAC/D,IAAI,KAAK,YAAY,WAAW;QAAE,KAAK,CAAC,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC;AACjE,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* widgentic/designer — the embeddable designers: widget, theme, schema and
|
|
3
|
+
* action, each mountable standalone or as a custom element.
|
|
4
|
+
*
|
|
5
|
+
* Import discipline: this capability consumes the rest of widgentic ONLY
|
|
6
|
+
* through public package entries (`widgentic/catalog`, `widgentic/templates`,
|
|
7
|
+
* `widgentic/theming`, `widgentic/reactive`, `widgentic/contract`) so it can
|
|
8
|
+
* be extracted into a standalone npm package without code changes. It
|
|
9
|
+
* performs no network I/O — hosts own persistence via change events.
|
|
10
|
+
*/
|
|
11
|
+
export { createDesigner } from "./shell.js";
|
|
12
|
+
export type { DesignerHandle, DesignerOptions, LoadResult, WidgetDefinition } from "./shell.js";
|
|
13
|
+
export { defineDesignerElement, defineThemeDesignerElement, defineSchemaDesignerElement, defineActionDesignerElement, DEFAULT_TAG, DEFAULT_THEME_TAG, DEFAULT_SCHEMA_TAG, DEFAULT_ACTION_TAG } from "./element.js";
|
|
14
|
+
export { createActionDesigner, checkActionEntry } from "./action-designer.js";
|
|
15
|
+
export type { ActionDesignerHandle, ActionDesignerOptions, ActionEntry, ActionLoadResult } from "./action-designer.js";
|
|
16
|
+
export { createBindingEditor, createDefinitionEditor, starterHttpDefinition, starterPromptDefinition } from "./action-editor.js";
|
|
17
|
+
export type { ActionEditorContext, BindingEditor, BindingEditorContext, DefinitionEditor } from "./action-editor.js";
|
|
18
|
+
export { createThemeDesigner, checkThemeEntry } from "./theme-designer.js";
|
|
19
|
+
export { createSchemaDesigner, checkSchemaEntry } from "./schema-designer.js";
|
|
20
|
+
export type { SchemaDesignerHandle, SchemaDesignerOptions, SchemaEntry, SchemaLoadResult } from "./schema-designer.js";
|
|
21
|
+
export type { ThemeDesignerHandle, ThemeDesignerOptions, ThemeLoadResult } from "./theme-designer.js";
|
|
22
|
+
export type { WidgetDraft, DraftStore } from "./store.js";
|
|
23
|
+
export { starterDraft } from "./store.js";
|
|
24
|
+
export { seedWidgetDraft, seedThemeEntry, SEEDABLE_BUILTINS } from "./seed.js";
|
|
25
|
+
export type { SeedableBuiltin } from "./seed.js";
|
|
26
|
+
export { deriveDiagnostics } from "./validate.js";
|
|
27
|
+
export type { DesignerDiagnostics, StyleIssue, TemplateIssue } from "./validate.js";
|
|
28
|
+
export { exportWidgetJson, exportThemeJson, importWidgetJson, toTypeScriptModule } from "./io.js";
|
|
29
|
+
export type { ImportResult } from "./io.js";
|
|
30
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,YAAY,EACV,cAAc,EACd,eAAe,EACf,UAAU,EACV,gBAAgB,EACjB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,qBAAqB,EACrB,0BAA0B,EAC1B,2BAA2B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M,SAAS,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* widgentic/designer — the embeddable designers: widget, theme, schema and
|
|
3
|
+
* action, each mountable standalone or as a custom element.
|
|
4
|
+
*
|
|
5
|
+
* Import discipline: this capability consumes the rest of widgentic ONLY
|
|
6
|
+
* through public package entries (`widgentic/catalog`, `widgentic/templates`,
|
|
7
|
+
* `widgentic/theming`, `widgentic/reactive`, `widgentic/contract`) so it can
|
|
8
|
+
* be extracted into a standalone npm package without code changes. It
|
|
9
|
+
* performs no network I/O — hosts own persistence via change events.
|
|
10
|
+
*/
|
|
11
|
+
export { createDesigner } from "./shell.js";
|
|
12
|
+
export { defineDesignerElement, defineThemeDesignerElement, defineSchemaDesignerElement, defineActionDesignerElement, DEFAULT_TAG, DEFAULT_THEME_TAG, DEFAULT_SCHEMA_TAG, DEFAULT_ACTION_TAG } from "./element.js";
|
|
13
|
+
export { createActionDesigner, checkActionEntry } from "./action-designer.js";
|
|
14
|
+
export { createBindingEditor, createDefinitionEditor, starterHttpDefinition, starterPromptDefinition } from "./action-editor.js";
|
|
15
|
+
export { createThemeDesigner, checkThemeEntry } from "./theme-designer.js";
|
|
16
|
+
export { createSchemaDesigner, checkSchemaEntry } from "./schema-designer.js";
|
|
17
|
+
export { starterDraft } from "./store.js";
|
|
18
|
+
export { seedWidgetDraft, seedThemeEntry, SEEDABLE_BUILTINS } from "./seed.js";
|
|
19
|
+
export { deriveDiagnostics } from "./validate.js";
|
|
20
|
+
export { exportWidgetJson, exportThemeJson, importWidgetJson, toTypeScriptModule } from "./io.js";
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAO5C,OAAO,EACL,qBAAqB,EACrB,0BAA0B,EAC1B,2BAA2B,EAC3B,2BAA2B,EAC3B,WAAW,EACX,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EACnB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAO9E,OAAO,EACL,mBAAmB,EACnB,sBAAsB,EACtB,qBAAqB,EACrB,uBAAuB,EACxB,MAAM,oBAAoB,CAAC;AAO5B,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3E,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAa9E,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAE/E,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAMlD,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,kBAAkB,EACnB,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** Package-local helpers (kept here rather than exported from core — see design D4). */
|
|
2
|
+
/** Structural copy of JSON-shaped data; the designers hand out copies, never their state. */
|
|
3
|
+
export declare function clone<T>(value: T): T;
|
|
4
|
+
/** A caught value's message without asserting it is an Error. */
|
|
5
|
+
export declare function errorMessage(error: unknown): string;
|
|
6
|
+
//# sourceMappingURL=internal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAAA,wFAAwF;AAExF,6FAA6F;AAC7F,wBAAgB,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAEpC;AAED,iEAAiE;AACjE,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAEnD"}
|
package/dist/internal.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Package-local helpers (kept here rather than exported from core — see design D4). */
|
|
2
|
+
/** Structural copy of JSON-shaped data; the designers hand out copies, never their state. */
|
|
3
|
+
export function clone(value) {
|
|
4
|
+
return JSON.parse(JSON.stringify(value));
|
|
5
|
+
}
|
|
6
|
+
/** A caught value's message without asserting it is an Error. */
|
|
7
|
+
export function errorMessage(error) {
|
|
8
|
+
return error instanceof Error ? error.message : String(error);
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=internal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAAA,wFAAwF;AAExF,6FAA6F;AAC7F,MAAM,UAAU,KAAK,CAAI,KAAQ;IAC/B,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAM,CAAC;AAChD,CAAC;AAED,iEAAiE;AACjE,MAAM,UAAU,YAAY,CAAC,KAAc;IACzC,OAAO,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAChE,CAAC"}
|
package/dist/io.d.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { ActionBinding } from "@widgentic/core";
|
|
2
|
+
import type { DraftStore, WidgetDraft } from "./store.js";
|
|
3
|
+
export interface WidgetDefinition {
|
|
4
|
+
kind: WidgetDraft["kind"];
|
|
5
|
+
template: WidgetDraft["template"];
|
|
6
|
+
descriptor: WidgetDraft["descriptor"];
|
|
7
|
+
load?: ActionBinding;
|
|
8
|
+
}
|
|
9
|
+
/** Validate an untrusted definition; errors instead of throws. */
|
|
10
|
+
export declare function checkDefinition(definition: unknown): string[];
|
|
11
|
+
export declare function exportWidgetJson(draft: WidgetDraft): string;
|
|
12
|
+
export declare function exportThemeJson(draft: WidgetDraft): string;
|
|
13
|
+
export type ImportResult = {
|
|
14
|
+
ok: true;
|
|
15
|
+
definition: WidgetDefinition;
|
|
16
|
+
} | {
|
|
17
|
+
ok: false;
|
|
18
|
+
errors: string[];
|
|
19
|
+
};
|
|
20
|
+
export declare function importWidgetJson(text: string): ImportResult;
|
|
21
|
+
/** Apply a validated definition to the store, preserving the session theme. */
|
|
22
|
+
export declare function applyDefinition(store: DraftStore, definition: WidgetDefinition): void;
|
|
23
|
+
/**
|
|
24
|
+
* Emit a module body compatible with `examples/mcp-server/widgets/` —
|
|
25
|
+
* the manual-registration bridge until wire registration exists.
|
|
26
|
+
*/
|
|
27
|
+
export declare function toTypeScriptModule(draft: WidgetDraft): string;
|
|
28
|
+
export declare function mountIoPanel(store: DraftStore): {
|
|
29
|
+
element: HTMLElement;
|
|
30
|
+
dispose(): void;
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=io.d.ts.map
|
package/dist/io.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"io.d.ts","sourceRoot":"","sources":["../src/io.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAIrD,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE1D,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC1B,QAAQ,EAAE,WAAW,CAAC,UAAU,CAAC,CAAC;IAClC,UAAU,EAAE,WAAW,CAAC,YAAY,CAAC,CAAC;IACtC,IAAI,CAAC,EAAE,aAAa,CAAC;CACtB;AAED,kEAAkE;AAClE,wBAAgB,eAAe,CAAC,UAAU,EAAE,OAAO,GAAG,MAAM,EAAE,CAsB7D;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,WAAW,GAAG,MAAM,CAQ3D;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,WAAW,GAAG,MAAM,CAE1D;AAED,MAAM,MAAM,YAAY,GACpB;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,UAAU,EAAE,gBAAgB,CAAA;CAAE,GAC1C;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC;AAEpC,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,CAU3D;AAED,+EAA+E;AAC/E,wBAAgB,eAAe,CAAC,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,gBAAgB,GAAG,IAAI,CASrF;AAUD;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,WAAW,GAAG,MAAM,CAe7D;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,UAAU,GAAG;IAC/C,OAAO,EAAE,WAAW,CAAC;IACrB,OAAO,IAAI,IAAI,CAAC;CACjB,CA4DA"}
|
package/dist/io.js
ADDED
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Import/export in the server's shapes: widget JSON is exactly the
|
|
3
|
+
* `CustomWidget` definition (`{ kind, template, descriptor }`) that
|
|
4
|
+
* `examples/mcp-server/widgets/` registers; themes are bare token maps.
|
|
5
|
+
* Imports are untrusted — everything re-validates, and a failed import
|
|
6
|
+
* never touches the current draft.
|
|
7
|
+
*/
|
|
8
|
+
import { errorMessage } from "./internal.js";
|
|
9
|
+
import { isPlainObject } from "@widgentic/core";
|
|
10
|
+
import { parsePath, validateTemplate } from "@widgentic/core";
|
|
11
|
+
import { validateLoadBinding } from "@widgentic/core";
|
|
12
|
+
import { diagnosticLine, h, section, textArea, requireChild } from "./dom.js";
|
|
13
|
+
import { attachJsonHighlight, repaintHighlight } from "./highlight.js";
|
|
14
|
+
/** Validate an untrusted definition; errors instead of throws. */
|
|
15
|
+
export function checkDefinition(definition) {
|
|
16
|
+
const errors = [];
|
|
17
|
+
if (!isPlainObject(definition))
|
|
18
|
+
return ["Definition must be an object."];
|
|
19
|
+
if (typeof definition.kind !== "string" || definition.kind.trim() === "") {
|
|
20
|
+
errors.push("'kind' must be a non-empty string.");
|
|
21
|
+
}
|
|
22
|
+
const template = validateTemplate(definition.template);
|
|
23
|
+
if (!template.ok) {
|
|
24
|
+
errors.push(`template: ${template.error.code} — ${template.error.message}`);
|
|
25
|
+
}
|
|
26
|
+
if (!isPlainObject(definition.descriptor)) {
|
|
27
|
+
errors.push("'descriptor' must be an object.");
|
|
28
|
+
}
|
|
29
|
+
else if (typeof definition.descriptor.description !== "string") {
|
|
30
|
+
errors.push("'descriptor.description' must be a string.");
|
|
31
|
+
}
|
|
32
|
+
if (definition.load !== undefined) {
|
|
33
|
+
const problem = validateLoadBinding(definition.load, "load", {
|
|
34
|
+
isPath: (value) => parsePath(value) !== undefined
|
|
35
|
+
});
|
|
36
|
+
if (problem)
|
|
37
|
+
errors.push(`load: ${problem.message} (at ${problem.path})`);
|
|
38
|
+
}
|
|
39
|
+
return errors;
|
|
40
|
+
}
|
|
41
|
+
export function exportWidgetJson(draft) {
|
|
42
|
+
const definition = {
|
|
43
|
+
kind: draft.kind,
|
|
44
|
+
template: draft.template,
|
|
45
|
+
descriptor: draft.descriptor,
|
|
46
|
+
...(draft.load !== undefined ? { load: draft.load } : {})
|
|
47
|
+
};
|
|
48
|
+
return JSON.stringify(definition, null, 2);
|
|
49
|
+
}
|
|
50
|
+
export function exportThemeJson(draft) {
|
|
51
|
+
return JSON.stringify(draft.theme ?? {}, null, 2);
|
|
52
|
+
}
|
|
53
|
+
export function importWidgetJson(text) {
|
|
54
|
+
let parsed;
|
|
55
|
+
try {
|
|
56
|
+
parsed = JSON.parse(text);
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
return { ok: false, errors: [`Invalid JSON: ${errorMessage(error)}`] };
|
|
60
|
+
}
|
|
61
|
+
const errors = checkDefinition(parsed);
|
|
62
|
+
if (errors.length > 0)
|
|
63
|
+
return { ok: false, errors };
|
|
64
|
+
return { ok: true, definition: parsed };
|
|
65
|
+
}
|
|
66
|
+
/** Apply a validated definition to the store, preserving the session theme. */
|
|
67
|
+
export function applyDefinition(store, definition) {
|
|
68
|
+
const theme = store.get().theme;
|
|
69
|
+
store.replace({
|
|
70
|
+
kind: definition.kind,
|
|
71
|
+
template: definition.template,
|
|
72
|
+
descriptor: definition.descriptor,
|
|
73
|
+
...(definition.load !== undefined ? { load: definition.load } : {}),
|
|
74
|
+
...(theme !== undefined ? { theme } : {})
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
function camelCase(kind) {
|
|
78
|
+
return kind
|
|
79
|
+
.split(/[^a-zA-Z0-9]+/)
|
|
80
|
+
.filter((part) => part.length > 0)
|
|
81
|
+
.map((part, i) => (i === 0 ? part : part[0]?.toUpperCase() + part.slice(1)))
|
|
82
|
+
.join("");
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Emit a module body compatible with `examples/mcp-server/widgets/` —
|
|
86
|
+
* the manual-registration bridge until wire registration exists.
|
|
87
|
+
*/
|
|
88
|
+
export function toTypeScriptModule(draft) {
|
|
89
|
+
const name = camelCase(draft.kind) || "custom";
|
|
90
|
+
return (`import type { CustomWidget } from "./index.js";\n\n` +
|
|
91
|
+
`export const ${name}Widget: CustomWidget = ${JSON.stringify({
|
|
92
|
+
kind: draft.kind,
|
|
93
|
+
template: draft.template,
|
|
94
|
+
descriptor: draft.descriptor,
|
|
95
|
+
...(draft.load !== undefined ? { load: draft.load } : {})
|
|
96
|
+
}, null, 2)};\n`);
|
|
97
|
+
}
|
|
98
|
+
export function mountIoPanel(store) {
|
|
99
|
+
const output = h("textarea", {
|
|
100
|
+
class: "wgd-textarea",
|
|
101
|
+
rows: "8",
|
|
102
|
+
readonly: "",
|
|
103
|
+
spellcheck: "false"
|
|
104
|
+
});
|
|
105
|
+
function button(label, produce) {
|
|
106
|
+
const el = h("button", { class: "wgd-button wgd-add", type: "button" }, [label]);
|
|
107
|
+
el.addEventListener("click", () => {
|
|
108
|
+
output.value = produce();
|
|
109
|
+
repaintHighlight(output);
|
|
110
|
+
});
|
|
111
|
+
return el;
|
|
112
|
+
}
|
|
113
|
+
const importError = diagnosticLine(undefined);
|
|
114
|
+
const importField = textArea("Import widget JSON", "", () => undefined, 5);
|
|
115
|
+
const importArea = requireChild(importField, "textarea");
|
|
116
|
+
attachJsonHighlight(importArea);
|
|
117
|
+
const importButton = h("button", { class: "wgd-button", type: "button" }, [
|
|
118
|
+
"Import"
|
|
119
|
+
]);
|
|
120
|
+
importButton.addEventListener("click", () => {
|
|
121
|
+
const result = importWidgetJson(importArea.value);
|
|
122
|
+
if (!result.ok) {
|
|
123
|
+
importError.hidden = false;
|
|
124
|
+
importError.textContent = result.errors.join("\n");
|
|
125
|
+
return; // current draft untouched
|
|
126
|
+
}
|
|
127
|
+
importError.hidden = true;
|
|
128
|
+
importError.textContent = "";
|
|
129
|
+
applyDefinition(store, result.definition);
|
|
130
|
+
});
|
|
131
|
+
// Import and export are independent flows — two sections, import first
|
|
132
|
+
// (bringing a drafted definition in is the more common entry point).
|
|
133
|
+
const importSection = section("Import", [
|
|
134
|
+
importField,
|
|
135
|
+
importError,
|
|
136
|
+
h("div", { class: "wgd-row" }, [importButton])
|
|
137
|
+
]);
|
|
138
|
+
// Export copies out what is already on screen, so read-only leaves it
|
|
139
|
+
// operable: the mode restricts editing, not looking.
|
|
140
|
+
const exportSection = section("Export", [
|
|
141
|
+
h("div", { class: "wgd-row" }, [
|
|
142
|
+
button("Export widget JSON", () => exportWidgetJson(store.get())),
|
|
143
|
+
button("Export theme JSON", () => exportThemeJson(store.get())),
|
|
144
|
+
button("Copy as TypeScript", () => toTypeScriptModule(store.get()))
|
|
145
|
+
]),
|
|
146
|
+
output
|
|
147
|
+
]);
|
|
148
|
+
exportSection.classList.add("wgd-view-only");
|
|
149
|
+
const element = h("div", { class: "wgd-io" }, [importSection, exportSection]);
|
|
150
|
+
// After assembly: the layer wraps the textarea in place, so the element
|
|
151
|
+
// must already have its parent.
|
|
152
|
+
attachJsonHighlight(output);
|
|
153
|
+
return { element, dispose: () => element.remove() };
|
|
154
|
+
}
|
|
155
|
+
//# sourceMappingURL=io.js.map
|
package/dist/io.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"io.js","sourceRoot":"","sources":["../src/io.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAGtD,OAAO,EAAE,cAAc,EAAE,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAC9E,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAUvE,kEAAkE;AAClE,MAAM,UAAU,eAAe,CAAC,UAAmB;IACjD,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC;QAAE,OAAO,CAAC,+BAA+B,CAAC,CAAC;IACzE,IAAI,OAAO,UAAU,CAAC,IAAI,KAAK,QAAQ,IAAI,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;QACzE,MAAM,CAAC,IAAI,CAAC,oCAAoC,CAAC,CAAC;IACpD,CAAC;IACD,MAAM,QAAQ,GAAG,gBAAgB,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;IACvD,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;QACjB,MAAM,CAAC,IAAI,CAAC,aAAa,QAAQ,CAAC,KAAK,CAAC,IAAI,MAAM,QAAQ,CAAC,KAAK,CAAC,OAAO,EAA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AAC,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE,CAAC,YAAY,CAAC,CAAC;KAC/C,CAAC,CAAC;IACH,sEAAsE;IACtE,qDAAqD;IACrD,MAAM,aAAa,GAAG,OAAO,CAAC,QAAQ,EAAE;QACtC,CAAC,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE;YAC7B,MAAM,CAAC,oBAAoB,EAAE,GAAG,EAAE,CAAC,gBAAgB,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC;YACjE,MAAM,CAAC,mBAAmB,EAAE,GAAG,EAAE,CAAC,eAAe,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC;YAC/D,MAAM,CAAC,oBAAoB,EAAE,GAAG,EAAE,CAAC,kBAAkB,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC;SACpE,CAAC;QACF,MAAM;KACP,CAAC,CAAC;IACH,aAAa,CAAC,SAAS,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;IAC7C,MAAM,OAAO,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC,CAAC;IAC9E,wEAAwE;IACxE,gCAAgC;IAChC,mBAAmB,CAAC,MAAM,CAAC,CAAC;IAE5B,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC;AACtD,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export interface JsonTreeEditor {
|
|
2
|
+
element: HTMLElement;
|
|
3
|
+
getValue(): unknown;
|
|
4
|
+
/** External update (skipped while the user is editing inside the tree). */
|
|
5
|
+
setValue(value: unknown): void;
|
|
6
|
+
}
|
|
7
|
+
export declare function createJsonTreeEditor(initial: unknown, onChange: (value: unknown) => void): JsonTreeEditor;
|
|
8
|
+
//# sourceMappingURL=json-tree-editor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-tree-editor.d.ts","sourceRoot":"","sources":["../src/json-tree-editor.ts"],"names":[],"mappings":"AA4EA,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,WAAW,CAAC;IACrB,QAAQ,IAAI,OAAO,CAAC;IACpB,2EAA2E;IAC3E,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAAC;CAChC;AAED,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,GACjC,cAAc,CAwIhB"}
|