@ulearning/ai-generative-frame 0.0.0-stage → 1.0.0-next.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 +233 -2
- package/dist/assistant-ui/entry.d.ts +34 -0
- package/dist/assistant-ui/entry.d.ts.map +1 -0
- package/dist/assistant-ui/entry.js +50 -0
- package/dist/assistant-ui/entry.js.map +1 -0
- package/dist/assistant-ui/extension.d.ts +18 -0
- package/dist/assistant-ui/extension.d.ts.map +1 -0
- package/dist/assistant-ui/extension.js +0 -0
- package/dist/assistant-ui/history.d.ts +15 -0
- package/dist/assistant-ui/history.d.ts.map +1 -0
- package/dist/assistant-ui/history.js +39 -0
- package/dist/assistant-ui/history.js.map +1 -0
- package/dist/assistant-ui/modelContext.d.ts +45 -0
- package/dist/assistant-ui/modelContext.d.ts.map +1 -0
- package/dist/assistant-ui/modelContext.js +88 -0
- package/dist/assistant-ui/modelContext.js.map +1 -0
- package/dist/assistant-ui/snapshotSaver.d.ts +11 -0
- package/dist/assistant-ui/snapshotSaver.d.ts.map +1 -0
- package/dist/assistant-ui/snapshotSaver.js +83 -0
- package/dist/assistant-ui/snapshotSaver.js.map +1 -0
- package/dist/assistant-ui/tool-calls.d.ts +21 -0
- package/dist/assistant-ui/tool-calls.d.ts.map +1 -0
- package/dist/assistant-ui/tool-calls.js +65 -0
- package/dist/assistant-ui/tool-calls.js.map +1 -0
- package/dist/assistant-ui/toolkit.d.ts +96 -0
- package/dist/assistant-ui/toolkit.d.ts.map +1 -0
- package/dist/assistant-ui/toolkit.js +456 -0
- package/dist/assistant-ui/toolkit.js.map +1 -0
- package/dist/assistant-ui/useSharedContext.d.ts +14 -0
- package/dist/assistant-ui/useSharedContext.d.ts.map +1 -0
- package/dist/assistant-ui/useSharedContext.js +27 -0
- package/dist/assistant-ui/useSharedContext.js.map +1 -0
- package/dist/assistant-ui.d.ts +3 -0
- package/dist/assistant-ui.d.ts.map +1 -0
- package/dist/assistant-ui.js +1 -0
- package/dist/bootstrap.d.ts +23 -0
- package/dist/bootstrap.d.ts.map +1 -0
- package/dist/bootstrap.js +78 -0
- package/dist/bootstrap.js.map +1 -0
- package/dist/csp.d.ts +25 -0
- package/dist/csp.d.ts.map +1 -0
- package/dist/csp.js +78 -0
- package/dist/csp.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/json-schema.d.ts +70 -0
- package/dist/json-schema.d.ts.map +1 -0
- package/dist/json-schema.js +163 -0
- package/dist/json-schema.js.map +1 -0
- package/dist/preview.d.ts +30 -0
- package/dist/preview.d.ts.map +1 -0
- package/dist/preview.js +60 -0
- package/dist/preview.js.map +1 -0
- package/dist/prompts/guidance.d.ts +41 -0
- package/dist/prompts/guidance.d.ts.map +1 -0
- package/dist/prompts/guidance.js +268 -0
- package/dist/prompts/guidance.js.map +1 -0
- package/dist/prompts.d.ts +2 -0
- package/dist/prompts.d.ts.map +1 -0
- package/dist/prompts.js +1 -0
- package/dist/protocol.d.ts +114 -0
- package/dist/protocol.d.ts.map +1 -0
- package/dist/protocol.js +49 -0
- package/dist/protocol.js.map +1 -0
- package/dist/repair/repair.d.ts +72 -0
- package/dist/repair/repair.d.ts.map +1 -0
- package/dist/repair/repair.js +103 -0
- package/dist/repair/repair.js.map +1 -0
- package/dist/repair.d.ts +2 -0
- package/dist/repair.d.ts.map +1 -0
- package/dist/repair.js +1 -0
- package/dist/rpc.d.ts +60 -0
- package/dist/rpc.d.ts.map +1 -0
- package/dist/rpc.js +127 -0
- package/dist/rpc.js.map +1 -0
- package/dist/runtime/diagnostics.d.ts +17 -0
- package/dist/runtime/diagnostics.d.ts.map +1 -0
- package/dist/runtime/diagnostics.js +128 -0
- package/dist/runtime/diagnostics.js.map +1 -0
- package/dist/runtime/generated.d.ts +2 -0
- package/dist/runtime/generated.d.ts.map +1 -0
- package/dist/runtime/generated.js +5 -0
- package/dist/runtime/generated.js.map +1 -0
- package/dist/runtime/index.d.ts +7 -0
- package/dist/runtime/index.d.ts.map +1 -0
- package/dist/runtime/index.js +264 -0
- package/dist/runtime/index.js.map +1 -0
- package/dist/runtime/morph.d.ts +51 -0
- package/dist/runtime/morph.d.ts.map +1 -0
- package/dist/runtime/morph.js +251 -0
- package/dist/runtime/morph.js.map +1 -0
- package/dist/runtime/screenshot.d.ts +23 -0
- package/dist/runtime/screenshot.d.ts.map +1 -0
- package/dist/runtime/screenshot.js +188 -0
- package/dist/runtime/screenshot.js.map +1 -0
- package/dist/runtime/size.d.ts +10 -0
- package/dist/runtime/size.d.ts.map +1 -0
- package/dist/runtime/size.js +21 -0
- package/dist/runtime/size.js.map +1 -0
- package/dist/runtime/storage.d.ts +4 -0
- package/dist/runtime/storage.d.ts.map +1 -0
- package/dist/runtime/storage.js +38 -0
- package/dist/runtime/storage.js.map +1 -0
- package/dist/spec/actions.d.ts +40 -0
- package/dist/spec/actions.d.ts.map +1 -0
- package/dist/spec/actions.js +53 -0
- package/dist/spec/actions.js.map +1 -0
- package/dist/spec/assistant-ui/thread.d.ts +66 -0
- package/dist/spec/assistant-ui/thread.d.ts.map +1 -0
- package/dist/spec/assistant-ui/thread.js +252 -0
- package/dist/spec/assistant-ui/thread.js.map +1 -0
- package/dist/spec/assistant-ui/toolkit.d.ts +33 -0
- package/dist/spec/assistant-ui/toolkit.d.ts.map +1 -0
- package/dist/spec/assistant-ui/toolkit.js +142 -0
- package/dist/spec/assistant-ui/toolkit.js.map +1 -0
- package/dist/spec/assistant-ui/web.d.ts +6 -0
- package/dist/spec/assistant-ui/web.d.ts.map +1 -0
- package/dist/spec/assistant-ui/web.js +48 -0
- package/dist/spec/assistant-ui/web.js.map +1 -0
- package/dist/spec/assistant-ui.d.ts +3 -0
- package/dist/spec/assistant-ui.d.ts.map +1 -0
- package/dist/spec/assistant-ui.js +1 -0
- package/dist/spec/calc.d.ts +8 -0
- package/dist/spec/calc.d.ts.map +1 -0
- package/dist/spec/calc.js +498 -0
- package/dist/spec/calc.js.map +1 -0
- package/dist/spec/catalog.d.ts +52 -0
- package/dist/spec/catalog.d.ts.map +1 -0
- package/dist/spec/catalog.js +104 -0
- package/dist/spec/catalog.js.map +1 -0
- package/dist/spec/expressions.d.ts +45 -0
- package/dist/spec/expressions.d.ts.map +1 -0
- package/dist/spec/expressions.js +199 -0
- package/dist/spec/expressions.js.map +1 -0
- package/dist/spec/patch.d.ts +20 -0
- package/dist/spec/patch.d.ts.map +1 -0
- package/dist/spec/patch.js +77 -0
- package/dist/spec/patch.js.map +1 -0
- package/dist/spec/pending.d.ts +15 -0
- package/dist/spec/pending.d.ts.map +1 -0
- package/dist/spec/pending.js +33 -0
- package/dist/spec/pending.js.map +1 -0
- package/dist/spec/pointer.d.ts +17 -0
- package/dist/spec/pointer.d.ts.map +1 -0
- package/dist/spec/pointer.js +88 -0
- package/dist/spec/pointer.js.map +1 -0
- package/dist/spec/prompt.d.ts +29 -0
- package/dist/spec/prompt.d.ts.map +1 -0
- package/dist/spec/prompt.js +145 -0
- package/dist/spec/prompt.js.map +1 -0
- package/dist/spec/render-spec.d.ts +50 -0
- package/dist/spec/render-spec.d.ts.map +1 -0
- package/dist/spec/render-spec.js +104 -0
- package/dist/spec/render-spec.js.map +1 -0
- package/dist/spec/resolve.d.ts +39 -0
- package/dist/spec/resolve.d.ts.map +1 -0
- package/dist/spec/resolve.js +51 -0
- package/dist/spec/resolve.js.map +1 -0
- package/dist/spec/resolved.d.ts +3 -0
- package/dist/spec/resolved.d.ts.map +1 -0
- package/dist/spec/resolved.js +36 -0
- package/dist/spec/resolved.js.map +1 -0
- package/dist/spec/state.d.ts +34 -0
- package/dist/spec/state.d.ts.map +1 -0
- package/dist/spec/state.js +111 -0
- package/dist/spec/state.js.map +1 -0
- package/dist/spec/stream.d.ts +50 -0
- package/dist/spec/stream.d.ts.map +1 -0
- package/dist/spec/stream.js +168 -0
- package/dist/spec/stream.js.map +1 -0
- package/dist/spec/tools.d.ts +3 -0
- package/dist/spec/tools.d.ts.map +1 -0
- package/dist/spec/tools.js +3 -0
- package/dist/spec/tree.d.ts +21 -0
- package/dist/spec/tree.d.ts.map +1 -0
- package/dist/spec/tree.js +27 -0
- package/dist/spec/tree.js.map +1 -0
- package/dist/spec/types.d.ts +66 -0
- package/dist/spec/types.d.ts.map +1 -0
- package/dist/spec/types.js +9 -0
- package/dist/spec/types.js.map +1 -0
- package/dist/spec/validate.d.ts +32 -0
- package/dist/spec/validate.d.ts.map +1 -0
- package/dist/spec/validate.js +264 -0
- package/dist/spec/validate.js.map +1 -0
- package/dist/spec/vue/SpecRenderer.d.ts +43 -0
- package/dist/spec/vue/SpecRenderer.d.ts.map +1 -0
- package/dist/spec/vue/SpecRenderer.js +357 -0
- package/dist/spec/vue/SpecRenderer.js.map +1 -0
- package/dist/spec/vue/useSpecStream.d.ts +19 -0
- package/dist/spec/vue/useSpecStream.d.ts.map +1 -0
- package/dist/spec/vue/useSpecStream.js +115 -0
- package/dist/spec/vue/useSpecStream.js.map +1 -0
- package/dist/spec/vue.d.ts +3 -0
- package/dist/spec/vue.d.ts.map +1 -0
- package/dist/spec/vue.js +3 -0
- package/dist/spec.d.ts +12 -0
- package/dist/spec.d.ts.map +1 -0
- package/dist/spec.js +8 -0
- package/dist/theme.d.ts +38 -0
- package/dist/theme.d.ts.map +1 -0
- package/dist/theme.js +370 -0
- package/dist/theme.js.map +1 -0
- package/dist/tools/define.d.ts +43 -0
- package/dist/tools/define.d.ts.map +1 -0
- package/dist/tools/define.js +31 -0
- package/dist/tools/define.js.map +1 -0
- package/dist/tools/edits.d.ts +19 -0
- package/dist/tools/edits.d.ts.map +1 -0
- package/dist/tools/edits.js +55 -0
- package/dist/tools/edits.js.map +1 -0
- package/dist/tools/registry.d.ts +19 -0
- package/dist/tools/registry.d.ts.map +1 -0
- package/dist/tools/registry.js +33 -0
- package/dist/tools/registry.js.map +1 -0
- package/dist/tools/tools.d.ts +88 -0
- package/dist/tools/tools.d.ts.map +1 -0
- package/dist/tools/tools.js +235 -0
- package/dist/tools/tools.js.map +1 -0
- package/dist/tools.d.ts +5 -0
- package/dist/tools.d.ts.map +1 -0
- package/dist/tools.js +5 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +5 -0
- package/dist/version.js.map +1 -0
- package/dist/vue/Widget.d.ts +16 -0
- package/dist/vue/Widget.d.ts.map +1 -0
- package/dist/vue/Widget.js +58 -0
- package/dist/vue/Widget.js.map +1 -0
- package/dist/vue/sync.d.ts +19 -0
- package/dist/vue/sync.d.ts.map +1 -0
- package/dist/vue/sync.js +31 -0
- package/dist/vue/sync.js.map +1 -0
- package/dist/vue/themeStore.d.ts +23 -0
- package/dist/vue/themeStore.d.ts.map +1 -0
- package/dist/vue/themeStore.js +115 -0
- package/dist/vue/themeStore.js.map +1 -0
- package/dist/vue/useThemeTokens.d.ts +6 -0
- package/dist/vue/useThemeTokens.d.ts.map +1 -0
- package/dist/vue/useThemeTokens.js +49 -0
- package/dist/vue/useThemeTokens.js.map +1 -0
- package/dist/vue/useWidget.d.ts +10 -0
- package/dist/vue/useWidget.d.ts.map +1 -0
- package/dist/vue/useWidget.js +81 -0
- package/dist/vue/useWidget.js.map +1 -0
- package/dist/vue.d.ts +5 -0
- package/dist/vue.d.ts.map +1 -0
- package/dist/vue.js +4 -0
- package/dist/widget.d.ts +129 -0
- package/dist/widget.d.ts.map +1 -0
- package/dist/widget.js +655 -0
- package/dist/widget.js.map +1 -0
- package/package.json +125 -3
- package/src/assistant-ui/entry.ts +124 -0
- package/src/assistant-ui/extension.ts +19 -0
- package/src/assistant-ui/history.ts +63 -0
- package/src/assistant-ui/modelContext.ts +162 -0
- package/src/assistant-ui/snapshotSaver.ts +116 -0
- package/src/assistant-ui/tool-calls.ts +115 -0
- package/src/assistant-ui/toolkit.tsx +747 -0
- package/src/assistant-ui/useSharedContext.ts +40 -0
- package/src/assistant-ui.ts +14 -0
- package/src/bootstrap.ts +112 -0
- package/src/csp.ts +96 -0
- package/src/index.ts +44 -0
- package/src/json-schema.ts +353 -0
- package/src/preview.ts +120 -0
- package/src/prompts/guidance.ts +369 -0
- package/src/prompts.ts +8 -0
- package/src/protocol.ts +141 -0
- package/src/repair/repair.ts +202 -0
- package/src/repair.ts +11 -0
- package/src/rpc.ts +228 -0
- package/src/runtime/diagnostics.ts +165 -0
- package/src/runtime/generated.ts +2 -0
- package/src/runtime/index.ts +343 -0
- package/src/runtime/morph.ts +352 -0
- package/src/runtime/screenshot.ts +288 -0
- package/src/runtime/size.ts +17 -0
- package/src/runtime/storage.ts +49 -0
- package/src/spec/actions.ts +111 -0
- package/src/spec/assistant-ui/thread.ts +381 -0
- package/src/spec/assistant-ui/toolkit.tsx +295 -0
- package/src/spec/assistant-ui/web.tsx +63 -0
- package/src/spec/assistant-ui.ts +2 -0
- package/src/spec/calc.ts +598 -0
- package/src/spec/catalog.ts +196 -0
- package/src/spec/expressions.ts +301 -0
- package/src/spec/patch.ts +112 -0
- package/src/spec/pending.ts +36 -0
- package/src/spec/pointer.ts +170 -0
- package/src/spec/prompt.ts +243 -0
- package/src/spec/render-spec.ts +144 -0
- package/src/spec/resolve.ts +123 -0
- package/src/spec/resolved.ts +53 -0
- package/src/spec/state.ts +193 -0
- package/src/spec/stream.ts +230 -0
- package/src/spec/tools.ts +17 -0
- package/src/spec/tree.ts +37 -0
- package/src/spec/types.ts +51 -0
- package/src/spec/validate.ts +429 -0
- package/src/spec/vue/SpecRenderer.tsx +544 -0
- package/src/spec/vue/__tests__/harness.ts +50 -0
- package/src/spec/vue/useSpecStream.ts +162 -0
- package/src/spec/vue.ts +13 -0
- package/src/spec.ts +55 -0
- package/src/theme.ts +423 -0
- package/src/tools/define.ts +65 -0
- package/src/tools/edits.ts +73 -0
- package/src/tools/registry.ts +44 -0
- package/src/tools/tools.ts +361 -0
- package/src/tools.ts +32 -0
- package/src/version.ts +4 -0
- package/src/vue/Widget.tsx +74 -0
- package/src/vue/sync.ts +36 -0
- package/src/vue/themeStore.ts +157 -0
- package/src/vue/useThemeTokens.ts +71 -0
- package/src/vue/useWidget.ts +117 -0
- package/src/vue.ts +8 -0
- package/src/widget.ts +1080 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theme.d.ts","mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAY;AAE7C;AACA,MAAM,MAAM,WAAW,GAAG;IACxB,WAAW,EAAE,WAAW;IACxB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;CAClC;AAED,MAAM,MAAM,cAAc,GACtB,oBAAoB,GACpB,iBAAiB,GACjB,uBAAuB,GACvB,cAAc,GACd,oBAAoB,GACpB,qBAAqB,GACrB,gBAAgB,GAChB,uBAAuB,GACvB,gBAAgB,GAChB,qBAAqB,GACrB,gBAAgB,GAChB,iBAAiB,GACjB,iBAAiB,GACjB,cAAc,GACd,WAAW,GACX,WAAW,GACX,WAAW,GACX,WAAW,GACX,WAAW,GACX,WAAW,GACX,aAAa,GACb,aAAa,GACb,aAAa,GACb,aAAa,GACb,aAAa;AAEjB,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,EAAE,cAAc;IACpB,KAAK,EACD,SAAS,GACT,MAAM,GACN,QAAQ,GACR,QAAQ,GACR,QAAQ,GACR,OAAO,GACP,MAAM,GACN,OAAO;IACX,KAAK,EAAE,MAAM;CACd;AAED;AACA,eAAO,MAAM,YAAY,EAAE,SAAS,cAAc,EAuFjD;AAYD,eAAO,MAAM,oBAAoB,EAAE,WAyBlC;AAED,eAAO,MAAM,mBAAmB,EAAE,WAyBjC;AAED,eAAO,MAAM,kBAAkB,GAAI,QAAQ,WAAW,KAAG,WACO;AAEhE;;;;AAIA,MAAM,MAAM,iBAAiB,GAAG,OAAO,CACrC,MAAM,CAAC,cAAc,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,CAAC,CACnD;AAED,eAAO,MAAM,qBAAqB,EAAE,MAAM,CAAC,cAAc,EAAE,SAAS,MAAM,EAAE,CA+BzE;AAoBH;AACA,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,OAAO,GAAG,WAAW;AAkBhE;;;;AAIA,wBAAgB,eAAe,CAC7B,OAAO,GAAE,OAAkC,EAC3C,OAAO,GAAE,iBAAsB,GAC9B,WAAW;AAsDd;;;;AAIA,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,WAAW,GAClB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;AAoEzB;AACA,wBAAgB,cAAc,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC","names":[],"ignoreList":[],"sources":["../src/theme.ts"],"sourcesContent":[null]}
|
package/dist/theme.js
ADDED
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
// src/theme.ts
|
|
2
|
+
/** The canonical tokens every frame defines, in prompt order. */
|
|
3
|
+
const THEME_TOKENS = [
|
|
4
|
+
{
|
|
5
|
+
name: "--color-background",
|
|
6
|
+
group: "surface",
|
|
7
|
+
usage: "the host page behind the widget; for knockouts only, the widget itself stays transparent"
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
name: "--color-surface",
|
|
11
|
+
group: "surface",
|
|
12
|
+
usage: "cards, panels, popovers"
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
name: "--color-surface-muted",
|
|
16
|
+
group: "surface",
|
|
17
|
+
usage: "wells, table stripes, hover fills, code blocks"
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
name: "--color-text",
|
|
21
|
+
group: "text",
|
|
22
|
+
usage: "body text, headings, primary values"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
name: "--color-text-muted",
|
|
26
|
+
group: "text",
|
|
27
|
+
usage: "labels, secondary text, axis titles"
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
name: "--color-text-subtle",
|
|
31
|
+
group: "text",
|
|
32
|
+
usage: "captions, tick labels, placeholders, disabled"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
name: "--color-border",
|
|
36
|
+
group: "border",
|
|
37
|
+
usage: "hairlines, dividers, card outlines, gridlines"
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
name: "--color-border-strong",
|
|
41
|
+
group: "border",
|
|
42
|
+
usage: "inputs, emphasized outlines, focus-adjacent edges"
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
name: "--color-accent",
|
|
46
|
+
group: "accent",
|
|
47
|
+
usage: "primary actions, selection, the one highlighted series"
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
name: "--color-accent-text",
|
|
51
|
+
group: "accent",
|
|
52
|
+
usage: "text and icons placed on --color-accent"
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
name: "--color-danger",
|
|
56
|
+
group: "status",
|
|
57
|
+
usage: "errors, destructive actions, negative deltas"
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
name: "--color-success",
|
|
61
|
+
group: "status",
|
|
62
|
+
usage: "success, positive deltas"
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
name: "--color-warning",
|
|
66
|
+
group: "status",
|
|
67
|
+
usage: "warnings, pending states"
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
name: "--color-info",
|
|
71
|
+
group: "status",
|
|
72
|
+
usage: "neutral notices, links inside callouts"
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
name: "--chart-1",
|
|
76
|
+
group: "chart",
|
|
77
|
+
usage: "first categorical series"
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
name: "--chart-2",
|
|
81
|
+
group: "chart",
|
|
82
|
+
usage: "second categorical series"
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
name: "--chart-3",
|
|
86
|
+
group: "chart",
|
|
87
|
+
usage: "third categorical series"
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
name: "--chart-4",
|
|
91
|
+
group: "chart",
|
|
92
|
+
usage: "fourth categorical series"
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
name: "--chart-5",
|
|
96
|
+
group: "chart",
|
|
97
|
+
usage: "fifth categorical series"
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
name: "--chart-6",
|
|
101
|
+
group: "chart",
|
|
102
|
+
usage: "sixth categorical series"
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
name: "--font-sans",
|
|
106
|
+
group: "type",
|
|
107
|
+
usage: "all UI text"
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
name: "--font-mono",
|
|
111
|
+
group: "type",
|
|
112
|
+
usage: "code, tabular identifiers"
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
name: "--radius-sm",
|
|
116
|
+
group: "shape",
|
|
117
|
+
usage: "chips, inputs, small buttons"
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
name: "--radius-md",
|
|
121
|
+
group: "shape",
|
|
122
|
+
usage: "buttons, cards"
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
name: "--radius-lg",
|
|
126
|
+
group: "shape",
|
|
127
|
+
usage: "large panels, dialogs"
|
|
128
|
+
}
|
|
129
|
+
];
|
|
130
|
+
const SHARED = {
|
|
131
|
+
"--font-sans": "ui-sans-serif, system-ui, -apple-system, \"Segoe UI\", Roboto, \"Helvetica Neue\", Arial, sans-serif",
|
|
132
|
+
"--font-mono": "ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, \"Liberation Mono\", monospace",
|
|
133
|
+
"--radius-sm": "6px",
|
|
134
|
+
"--radius-md": "8px",
|
|
135
|
+
"--radius-lg": "12px"
|
|
136
|
+
};
|
|
137
|
+
const DEFAULT_LIGHT_TOKENS = {
|
|
138
|
+
colorScheme: "light",
|
|
139
|
+
variables: {
|
|
140
|
+
...SHARED,
|
|
141
|
+
"--color-background": "#ffffff",
|
|
142
|
+
"--color-surface": "#ffffff",
|
|
143
|
+
"--color-surface-muted": "#f4f4f5",
|
|
144
|
+
"--color-text": "#18181b",
|
|
145
|
+
"--color-text-muted": "#52525b",
|
|
146
|
+
"--color-text-subtle": "#71717a",
|
|
147
|
+
"--color-border": "#e4e4e7",
|
|
148
|
+
"--color-border-strong": "#d4d4d8",
|
|
149
|
+
"--color-accent": "#2563eb",
|
|
150
|
+
"--color-accent-text": "#ffffff",
|
|
151
|
+
"--color-danger": "#dc2626",
|
|
152
|
+
"--color-success": "#16a34a",
|
|
153
|
+
"--color-warning": "#d97706",
|
|
154
|
+
"--color-info": "#0284c7",
|
|
155
|
+
"--chart-1": "#2563eb",
|
|
156
|
+
"--chart-2": "#0d9488",
|
|
157
|
+
"--chart-3": "#d97706",
|
|
158
|
+
"--chart-4": "#db2777",
|
|
159
|
+
"--chart-5": "#7c3aed",
|
|
160
|
+
"--chart-6": "#65a30d"
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
const DEFAULT_DARK_TOKENS = {
|
|
164
|
+
colorScheme: "dark",
|
|
165
|
+
variables: {
|
|
166
|
+
...SHARED,
|
|
167
|
+
"--color-background": "#09090b",
|
|
168
|
+
"--color-surface": "#18181b",
|
|
169
|
+
"--color-surface-muted": "#27272a",
|
|
170
|
+
"--color-text": "#fafafa",
|
|
171
|
+
"--color-text-muted": "#a1a1aa",
|
|
172
|
+
"--color-text-subtle": "#71717a",
|
|
173
|
+
"--color-border": "#27272a",
|
|
174
|
+
"--color-border-strong": "#3f3f46",
|
|
175
|
+
"--color-accent": "#3b82f6",
|
|
176
|
+
"--color-accent-text": "#ffffff",
|
|
177
|
+
"--color-danger": "#f87171",
|
|
178
|
+
"--color-success": "#4ade80",
|
|
179
|
+
"--color-warning": "#fbbf24",
|
|
180
|
+
"--color-info": "#38bdf8",
|
|
181
|
+
"--chart-1": "#60a5fa",
|
|
182
|
+
"--chart-2": "#2dd4bf",
|
|
183
|
+
"--chart-3": "#fbbf24",
|
|
184
|
+
"--chart-4": "#f472b6",
|
|
185
|
+
"--chart-5": "#a78bfa",
|
|
186
|
+
"--chart-6": "#a3e635"
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
const defaultThemeTokens = (scheme) => scheme === "dark" ? DEFAULT_DARK_TOKENS : DEFAULT_LIGHT_TOKENS;
|
|
190
|
+
const DEFAULT_TOKEN_SOURCES = {
|
|
191
|
+
"--color-background": ["--color-background", "--background"],
|
|
192
|
+
"--color-surface": [
|
|
193
|
+
"--color-surface",
|
|
194
|
+
"--card",
|
|
195
|
+
"--background"
|
|
196
|
+
],
|
|
197
|
+
"--color-surface-muted": [
|
|
198
|
+
"--color-surface-muted",
|
|
199
|
+
"--muted",
|
|
200
|
+
"--secondary"
|
|
201
|
+
],
|
|
202
|
+
"--color-text": ["--color-text", "--foreground"],
|
|
203
|
+
"--color-text-muted": ["--color-text-muted", "--muted-foreground"],
|
|
204
|
+
"--color-text-subtle": ["--color-text-subtle", "--muted-foreground"],
|
|
205
|
+
"--color-border": ["--color-border", "--border"],
|
|
206
|
+
"--color-border-strong": [
|
|
207
|
+
"--color-border-strong",
|
|
208
|
+
"--input",
|
|
209
|
+
"--ring"
|
|
210
|
+
],
|
|
211
|
+
"--color-accent": ["--color-accent", "--primary"],
|
|
212
|
+
"--color-accent-text": ["--color-accent-text", "--primary-foreground"],
|
|
213
|
+
"--color-danger": ["--color-danger", "--destructive"],
|
|
214
|
+
"--color-success": ["--color-success"],
|
|
215
|
+
"--color-warning": ["--color-warning"],
|
|
216
|
+
"--color-info": ["--color-info"],
|
|
217
|
+
"--chart-1": ["--chart-1"],
|
|
218
|
+
"--chart-2": ["--chart-2"],
|
|
219
|
+
"--chart-3": ["--chart-3"],
|
|
220
|
+
"--chart-4": ["--chart-4"],
|
|
221
|
+
"--chart-5": ["--chart-5"],
|
|
222
|
+
"--chart-6": ["--chart-6"],
|
|
223
|
+
"--font-sans": ["--font-sans"],
|
|
224
|
+
"--font-mono": ["--font-mono"],
|
|
225
|
+
"--radius-sm": ["--radius-sm"],
|
|
226
|
+
"--radius-md": ["--radius-md", "--radius"],
|
|
227
|
+
"--radius-lg": ["--radius-lg"]
|
|
228
|
+
};
|
|
229
|
+
/** shadcn/ui before Tailwind v4 stored colors as bare HSL channels, e.g. `222 47% 11%`. */
|
|
230
|
+
const HSL_CHANNELS = /^-?[\d.]+(?:deg)?\s+[\d.]+%\s+[\d.]+%(?:\s*\/\s*[\d.]+%?)?$/;
|
|
231
|
+
const RGB = /^rgba?\(\s*([\d.]+)[\s,]+([\d.]+)[\s,]+([\d.]+)(?:[\s,/]+([\d.]+))?/i;
|
|
232
|
+
const schemeFromColor = (color) => {
|
|
233
|
+
const match = RGB.exec(color);
|
|
234
|
+
if (!match || match[4] === "0") return void 0;
|
|
235
|
+
const [r, g, b] = [
|
|
236
|
+
match[1],
|
|
237
|
+
match[2],
|
|
238
|
+
match[3]
|
|
239
|
+
].map(Number);
|
|
240
|
+
return .2126 * r + .7152 * g + .0722 * b < 128 ? "dark" : "light";
|
|
241
|
+
};
|
|
242
|
+
/** Infers the color scheme an element renders in. */
|
|
243
|
+
function detectColorScheme(element) {
|
|
244
|
+
if (element.closest(".dark, [data-theme=\"dark\"], [data-mode=\"dark\"]")) return "dark";
|
|
245
|
+
if (element.closest(".light, [data-theme=\"light\"], [data-mode=\"light\"]")) return "light";
|
|
246
|
+
const view = element.ownerDocument.defaultView;
|
|
247
|
+
const style = view?.getComputedStyle(element);
|
|
248
|
+
const declared = style?.colorScheme.trim();
|
|
249
|
+
if (declared === "dark" || declared === "light") return declared;
|
|
250
|
+
const fromBackground = style && schemeFromColor(style.backgroundColor);
|
|
251
|
+
if (fromBackground) return fromBackground;
|
|
252
|
+
return view?.matchMedia?.("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Reads the host page's theme into canonical tokens. Tokens the page does not
|
|
256
|
+
* define fall back to the built-in palette for the detected color scheme.
|
|
257
|
+
*/
|
|
258
|
+
function readThemeTokens(element = document.documentElement, sources = {}) {
|
|
259
|
+
const colorScheme = detectColorScheme(element);
|
|
260
|
+
const style = element.ownerDocument.defaultView?.getComputedStyle(element);
|
|
261
|
+
const variables = { ...defaultThemeTokens(colorScheme).variables };
|
|
262
|
+
if (!style) return {
|
|
263
|
+
colorScheme,
|
|
264
|
+
variables
|
|
265
|
+
};
|
|
266
|
+
const declared = /* @__PURE__ */ new Set();
|
|
267
|
+
for (const info of THEME_TOKENS) {
|
|
268
|
+
const override = sources[info.name];
|
|
269
|
+
const candidates = override === void 0 ? DEFAULT_TOKEN_SOURCES[info.name] : typeof override === "string" ? [override] : override;
|
|
270
|
+
for (const candidate of candidates) {
|
|
271
|
+
const value = style.getPropertyValue(candidate).trim();
|
|
272
|
+
if (value) {
|
|
273
|
+
declared.add(info.name);
|
|
274
|
+
variables[info.name] = HSL_CHANNELS.test(value) ? `hsl(${value})` : value;
|
|
275
|
+
break;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
const radius = style.getPropertyValue("--radius").trim();
|
|
280
|
+
if (radius && !style.getPropertyValue("--radius-sm").trim()) variables["--radius-sm"] = `calc(${radius} - 2px)`;
|
|
281
|
+
if (radius && !style.getPropertyValue("--radius-lg").trim()) variables["--radius-lg"] = `calc(${radius} + 4px)`;
|
|
282
|
+
const doc = element.ownerDocument;
|
|
283
|
+
const font = declared.has("--font-sans") ? variables["--font-sans"] : doc.defaultView?.getComputedStyle(element === doc.documentElement && doc.body ? doc.body : element).fontFamily;
|
|
284
|
+
if (font) variables["--font-sans"] = `${font}, ${SHARED["--font-sans"]}`;
|
|
285
|
+
if (declared.has("--font-mono")) variables["--font-mono"] = `${variables["--font-mono"]}, ${SHARED["--font-mono"]}`;
|
|
286
|
+
return {
|
|
287
|
+
colorScheme,
|
|
288
|
+
variables
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
const tint = (color, percent) => color ? `color-mix(in srgb, ${color} ${percent}%, transparent)` : void 0;
|
|
292
|
+
/**
|
|
293
|
+
* Maps canonical tokens onto the MCP Apps standard style variables, so
|
|
294
|
+
* widgets written for MCP Apps hosts pick up the host theme too.
|
|
295
|
+
*/
|
|
296
|
+
function toMcpAppsVariables(tokens) {
|
|
297
|
+
const v = tokens.variables;
|
|
298
|
+
const entries = [
|
|
299
|
+
["--color-background-primary", v["--color-background"]],
|
|
300
|
+
["--color-background-secondary", v["--color-surface"]],
|
|
301
|
+
["--color-background-tertiary", v["--color-surface-muted"]],
|
|
302
|
+
["--color-background-inverse", v["--color-text"]],
|
|
303
|
+
["--color-background-ghost", "transparent"],
|
|
304
|
+
["--color-background-info", tint(v["--color-info"], 12)],
|
|
305
|
+
["--color-background-danger", tint(v["--color-danger"], 12)],
|
|
306
|
+
["--color-background-success", tint(v["--color-success"], 12)],
|
|
307
|
+
["--color-background-warning", tint(v["--color-warning"], 12)],
|
|
308
|
+
["--color-background-disabled", v["--color-surface-muted"]],
|
|
309
|
+
["--color-text-primary", v["--color-text"]],
|
|
310
|
+
["--color-text-secondary", v["--color-text-muted"]],
|
|
311
|
+
["--color-text-tertiary", v["--color-text-subtle"]],
|
|
312
|
+
["--color-text-inverse", v["--color-background"]],
|
|
313
|
+
["--color-text-ghost", v["--color-text-subtle"]],
|
|
314
|
+
["--color-text-info", v["--color-info"]],
|
|
315
|
+
["--color-text-danger", v["--color-danger"]],
|
|
316
|
+
["--color-text-success", v["--color-success"]],
|
|
317
|
+
["--color-text-warning", v["--color-warning"]],
|
|
318
|
+
["--color-text-disabled", v["--color-text-subtle"]],
|
|
319
|
+
["--color-border-primary", v["--color-border"]],
|
|
320
|
+
["--color-border-secondary", v["--color-border-strong"]],
|
|
321
|
+
["--color-border-tertiary", v["--color-border"]],
|
|
322
|
+
["--color-border-inverse", v["--color-text"]],
|
|
323
|
+
["--color-border-ghost", "transparent"],
|
|
324
|
+
["--color-border-info", v["--color-info"]],
|
|
325
|
+
["--color-border-danger", v["--color-danger"]],
|
|
326
|
+
["--color-border-success", v["--color-success"]],
|
|
327
|
+
["--color-border-warning", v["--color-warning"]],
|
|
328
|
+
["--color-border-disabled", v["--color-border"]],
|
|
329
|
+
["--color-ring-primary", v["--color-accent"]],
|
|
330
|
+
["--color-ring-secondary", v["--color-border-strong"]],
|
|
331
|
+
["--color-ring-inverse", v["--color-background"]],
|
|
332
|
+
["--color-ring-info", v["--color-info"]],
|
|
333
|
+
["--color-ring-danger", v["--color-danger"]],
|
|
334
|
+
["--color-ring-success", v["--color-success"]],
|
|
335
|
+
["--color-ring-warning", v["--color-warning"]],
|
|
336
|
+
["--font-sans", v["--font-sans"]],
|
|
337
|
+
["--font-mono", v["--font-mono"]],
|
|
338
|
+
["--font-weight-normal", "400"],
|
|
339
|
+
["--font-weight-medium", "500"],
|
|
340
|
+
["--font-weight-semibold", "600"],
|
|
341
|
+
["--font-weight-bold", "700"],
|
|
342
|
+
["--font-text-xs-size", "12px"],
|
|
343
|
+
["--font-text-sm-size", "14px"],
|
|
344
|
+
["--font-text-md-size", "16px"],
|
|
345
|
+
["--font-text-lg-size", "18px"],
|
|
346
|
+
["--font-heading-sm-size", "18px"],
|
|
347
|
+
["--font-heading-md-size", "22px"],
|
|
348
|
+
["--font-heading-lg-size", "28px"],
|
|
349
|
+
["--border-radius-xs", v["--radius-sm"]],
|
|
350
|
+
["--border-radius-sm", v["--radius-sm"]],
|
|
351
|
+
["--border-radius-md", v["--radius-md"]],
|
|
352
|
+
["--border-radius-lg", v["--radius-lg"]],
|
|
353
|
+
["--border-radius-xl", v["--radius-lg"]],
|
|
354
|
+
["--border-radius-full", "9999px"],
|
|
355
|
+
["--border-width-regular", "1px"]
|
|
356
|
+
];
|
|
357
|
+
const result = {};
|
|
358
|
+
for (const [name, value] of entries) if (value !== void 0) result[name] = value;
|
|
359
|
+
return result;
|
|
360
|
+
}
|
|
361
|
+
/** Every variable a frame receives: canonical tokens plus their MCP Apps aliases. */
|
|
362
|
+
function themeVariables(tokens) {
|
|
363
|
+
return {
|
|
364
|
+
...toMcpAppsVariables(tokens),
|
|
365
|
+
...tokens.variables
|
|
366
|
+
};
|
|
367
|
+
}
|
|
368
|
+
export { DEFAULT_DARK_TOKENS, DEFAULT_LIGHT_TOKENS, DEFAULT_TOKEN_SOURCES, THEME_TOKENS, defaultThemeTokens, detectColorScheme, readThemeTokens, themeVariables, toMcpAppsVariables };
|
|
369
|
+
|
|
370
|
+
//# sourceMappingURL=theme.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theme.js","names":[],"sources":["../src/theme.ts"],"sourcesContent":["import type { ColorScheme } from \"./protocol\";\n\n/** Theme values sent into a widget frame, keyed by CSS custom property name. */\nexport type ThemeTokens = {\n colorScheme: ColorScheme;\n variables: Record<string, string>;\n};\n\nexport type ThemeTokenName =\n | \"--color-background\"\n | \"--color-surface\"\n | \"--color-surface-muted\"\n | \"--color-text\"\n | \"--color-text-muted\"\n | \"--color-text-subtle\"\n | \"--color-border\"\n | \"--color-border-strong\"\n | \"--color-accent\"\n | \"--color-accent-text\"\n | \"--color-danger\"\n | \"--color-success\"\n | \"--color-warning\"\n | \"--color-info\"\n | \"--chart-1\"\n | \"--chart-2\"\n | \"--chart-3\"\n | \"--chart-4\"\n | \"--chart-5\"\n | \"--chart-6\"\n | \"--font-sans\"\n | \"--font-mono\"\n | \"--radius-sm\"\n | \"--radius-md\"\n | \"--radius-lg\";\n\nexport type ThemeTokenInfo = {\n name: ThemeTokenName;\n group:\n | \"surface\"\n | \"text\"\n | \"border\"\n | \"accent\"\n | \"status\"\n | \"chart\"\n | \"type\"\n | \"shape\";\n usage: string;\n};\n\n/** The canonical tokens every frame defines, in prompt order. */\nexport const THEME_TOKENS: readonly ThemeTokenInfo[] = [\n {\n name: \"--color-background\",\n group: \"surface\",\n usage:\n \"the host page behind the widget; for knockouts only, the widget itself stays transparent\",\n },\n {\n name: \"--color-surface\",\n group: \"surface\",\n usage: \"cards, panels, popovers\",\n },\n {\n name: \"--color-surface-muted\",\n group: \"surface\",\n usage: \"wells, table stripes, hover fills, code blocks\",\n },\n {\n name: \"--color-text\",\n group: \"text\",\n usage: \"body text, headings, primary values\",\n },\n {\n name: \"--color-text-muted\",\n group: \"text\",\n usage: \"labels, secondary text, axis titles\",\n },\n {\n name: \"--color-text-subtle\",\n group: \"text\",\n usage: \"captions, tick labels, placeholders, disabled\",\n },\n {\n name: \"--color-border\",\n group: \"border\",\n usage: \"hairlines, dividers, card outlines, gridlines\",\n },\n {\n name: \"--color-border-strong\",\n group: \"border\",\n usage: \"inputs, emphasized outlines, focus-adjacent edges\",\n },\n {\n name: \"--color-accent\",\n group: \"accent\",\n usage: \"primary actions, selection, the one highlighted series\",\n },\n {\n name: \"--color-accent-text\",\n group: \"accent\",\n usage: \"text and icons placed on --color-accent\",\n },\n {\n name: \"--color-danger\",\n group: \"status\",\n usage: \"errors, destructive actions, negative deltas\",\n },\n {\n name: \"--color-success\",\n group: \"status\",\n usage: \"success, positive deltas\",\n },\n {\n name: \"--color-warning\",\n group: \"status\",\n usage: \"warnings, pending states\",\n },\n {\n name: \"--color-info\",\n group: \"status\",\n usage: \"neutral notices, links inside callouts\",\n },\n { name: \"--chart-1\", group: \"chart\", usage: \"first categorical series\" },\n { name: \"--chart-2\", group: \"chart\", usage: \"second categorical series\" },\n { name: \"--chart-3\", group: \"chart\", usage: \"third categorical series\" },\n { name: \"--chart-4\", group: \"chart\", usage: \"fourth categorical series\" },\n { name: \"--chart-5\", group: \"chart\", usage: \"fifth categorical series\" },\n { name: \"--chart-6\", group: \"chart\", usage: \"sixth categorical series\" },\n { name: \"--font-sans\", group: \"type\", usage: \"all UI text\" },\n { name: \"--font-mono\", group: \"type\", usage: \"code, tabular identifiers\" },\n {\n name: \"--radius-sm\",\n group: \"shape\",\n usage: \"chips, inputs, small buttons\",\n },\n { name: \"--radius-md\", group: \"shape\", usage: \"buttons, cards\" },\n { name: \"--radius-lg\", group: \"shape\", usage: \"large panels, dialogs\" },\n];\n\nconst SHARED: Partial<Record<ThemeTokenName, string>> = {\n \"--font-sans\":\n 'ui-sans-serif, system-ui, -apple-system, \"Segoe UI\", Roboto, \"Helvetica Neue\", Arial, sans-serif',\n \"--font-mono\":\n 'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, \"Liberation Mono\", monospace',\n \"--radius-sm\": \"6px\",\n \"--radius-md\": \"8px\",\n \"--radius-lg\": \"12px\",\n};\n\nexport const DEFAULT_LIGHT_TOKENS: ThemeTokens = {\n colorScheme: \"light\",\n variables: {\n ...SHARED,\n \"--color-background\": \"#ffffff\",\n \"--color-surface\": \"#ffffff\",\n \"--color-surface-muted\": \"#f4f4f5\",\n \"--color-text\": \"#18181b\",\n \"--color-text-muted\": \"#52525b\",\n \"--color-text-subtle\": \"#71717a\",\n \"--color-border\": \"#e4e4e7\",\n \"--color-border-strong\": \"#d4d4d8\",\n \"--color-accent\": \"#2563eb\",\n \"--color-accent-text\": \"#ffffff\",\n \"--color-danger\": \"#dc2626\",\n \"--color-success\": \"#16a34a\",\n \"--color-warning\": \"#d97706\",\n \"--color-info\": \"#0284c7\",\n \"--chart-1\": \"#2563eb\",\n \"--chart-2\": \"#0d9488\",\n \"--chart-3\": \"#d97706\",\n \"--chart-4\": \"#db2777\",\n \"--chart-5\": \"#7c3aed\",\n \"--chart-6\": \"#65a30d\",\n } as Record<string, string>,\n};\n\nexport const DEFAULT_DARK_TOKENS: ThemeTokens = {\n colorScheme: \"dark\",\n variables: {\n ...SHARED,\n \"--color-background\": \"#09090b\",\n \"--color-surface\": \"#18181b\",\n \"--color-surface-muted\": \"#27272a\",\n \"--color-text\": \"#fafafa\",\n \"--color-text-muted\": \"#a1a1aa\",\n \"--color-text-subtle\": \"#71717a\",\n \"--color-border\": \"#27272a\",\n \"--color-border-strong\": \"#3f3f46\",\n \"--color-accent\": \"#3b82f6\",\n \"--color-accent-text\": \"#ffffff\",\n \"--color-danger\": \"#f87171\",\n \"--color-success\": \"#4ade80\",\n \"--color-warning\": \"#fbbf24\",\n \"--color-info\": \"#38bdf8\",\n \"--chart-1\": \"#60a5fa\",\n \"--chart-2\": \"#2dd4bf\",\n \"--chart-3\": \"#fbbf24\",\n \"--chart-4\": \"#f472b6\",\n \"--chart-5\": \"#a78bfa\",\n \"--chart-6\": \"#a3e635\",\n } as Record<string, string>,\n};\n\nexport const defaultThemeTokens = (scheme: ColorScheme): ThemeTokens =>\n scheme === \"dark\" ? DEFAULT_DARK_TOKENS : DEFAULT_LIGHT_TOKENS;\n\n/**\n * Where `readThemeTokens` looks for each canonical token, first match wins.\n * The defaults read the canonical name, then the shadcn/ui variable.\n */\nexport type ThemeTokenSources = Partial<\n Record<ThemeTokenName, string | readonly string[]>\n>;\n\nexport const DEFAULT_TOKEN_SOURCES: Record<ThemeTokenName, readonly string[]> =\n {\n \"--color-background\": [\"--color-background\", \"--background\"],\n \"--color-surface\": [\"--color-surface\", \"--card\", \"--background\"],\n \"--color-surface-muted\": [\n \"--color-surface-muted\",\n \"--muted\",\n \"--secondary\",\n ],\n \"--color-text\": [\"--color-text\", \"--foreground\"],\n \"--color-text-muted\": [\"--color-text-muted\", \"--muted-foreground\"],\n \"--color-text-subtle\": [\"--color-text-subtle\", \"--muted-foreground\"],\n \"--color-border\": [\"--color-border\", \"--border\"],\n \"--color-border-strong\": [\"--color-border-strong\", \"--input\", \"--ring\"],\n \"--color-accent\": [\"--color-accent\", \"--primary\"],\n \"--color-accent-text\": [\"--color-accent-text\", \"--primary-foreground\"],\n \"--color-danger\": [\"--color-danger\", \"--destructive\"],\n \"--color-success\": [\"--color-success\"],\n \"--color-warning\": [\"--color-warning\"],\n \"--color-info\": [\"--color-info\"],\n \"--chart-1\": [\"--chart-1\"],\n \"--chart-2\": [\"--chart-2\"],\n \"--chart-3\": [\"--chart-3\"],\n \"--chart-4\": [\"--chart-4\"],\n \"--chart-5\": [\"--chart-5\"],\n \"--chart-6\": [\"--chart-6\"],\n \"--font-sans\": [\"--font-sans\"],\n \"--font-mono\": [\"--font-mono\"],\n \"--radius-sm\": [\"--radius-sm\"],\n \"--radius-md\": [\"--radius-md\", \"--radius\"],\n \"--radius-lg\": [\"--radius-lg\"],\n };\n\n/** shadcn/ui before Tailwind v4 stored colors as bare HSL channels, e.g. `222 47% 11%`. */\nconst HSL_CHANNELS =\n /^-?[\\d.]+(?:deg)?\\s+[\\d.]+%\\s+[\\d.]+%(?:\\s*\\/\\s*[\\d.]+%?)?$/;\n\nconst RGB =\n /^rgba?\\(\\s*([\\d.]+)[\\s,]+([\\d.]+)[\\s,]+([\\d.]+)(?:[\\s,/]+([\\d.]+))?/i;\n\nconst schemeFromColor = (color: string): ColorScheme | undefined => {\n const match = RGB.exec(color);\n if (!match || match[4] === \"0\") return undefined;\n const [r, g, b] = [match[1], match[2], match[3]].map(Number) as [\n number,\n number,\n number,\n ];\n return 0.2126 * r + 0.7152 * g + 0.0722 * b < 128 ? \"dark\" : \"light\";\n};\n\n/** Infers the color scheme an element renders in. */\nexport function detectColorScheme(element: Element): ColorScheme {\n if (element.closest('.dark, [data-theme=\"dark\"], [data-mode=\"dark\"]')) {\n return \"dark\";\n }\n if (element.closest('.light, [data-theme=\"light\"], [data-mode=\"light\"]')) {\n return \"light\";\n }\n const view = element.ownerDocument.defaultView;\n const style = view?.getComputedStyle(element);\n const declared = style?.colorScheme.trim();\n if (declared === \"dark\" || declared === \"light\") return declared;\n const fromBackground = style && schemeFromColor(style.backgroundColor);\n if (fromBackground) return fromBackground;\n return view?.matchMedia?.(\"(prefers-color-scheme: dark)\").matches\n ? \"dark\"\n : \"light\";\n}\n\n/**\n * Reads the host page's theme into canonical tokens. Tokens the page does not\n * define fall back to the built-in palette for the detected color scheme.\n */\nexport function readThemeTokens(\n element: Element = document.documentElement,\n sources: ThemeTokenSources = {},\n): ThemeTokens {\n const colorScheme = detectColorScheme(element);\n const style = element.ownerDocument.defaultView?.getComputedStyle(element);\n const defaults = defaultThemeTokens(colorScheme).variables;\n const variables: Record<string, string> = { ...defaults };\n if (!style) return { colorScheme, variables };\n\n const declared = new Set<ThemeTokenName>();\n for (const info of THEME_TOKENS) {\n const override = sources[info.name];\n const candidates =\n override === undefined\n ? DEFAULT_TOKEN_SOURCES[info.name]\n : typeof override === \"string\"\n ? [override]\n : override;\n for (const candidate of candidates) {\n const value = style.getPropertyValue(candidate).trim();\n if (value) {\n declared.add(info.name);\n variables[info.name] = HSL_CHANNELS.test(value)\n ? `hsl(${value})`\n : value;\n break;\n }\n }\n }\n\n const radius = style.getPropertyValue(\"--radius\").trim();\n if (radius && !style.getPropertyValue(\"--radius-sm\").trim()) {\n variables[\"--radius-sm\"] = `calc(${radius} - 2px)`;\n }\n if (radius && !style.getPropertyValue(\"--radius-lg\").trim()) {\n variables[\"--radius-lg\"] = `calc(${radius} + 4px)`;\n }\n const doc = element.ownerDocument;\n const font = declared.has(\"--font-sans\")\n ? variables[\"--font-sans\"]\n : doc.defaultView?.getComputedStyle(\n element === doc.documentElement && doc.body ? doc.body : element,\n ).fontFamily;\n // The page's web fonts do not load inside the frame, so the default stacks follow them.\n if (font) variables[\"--font-sans\"] = `${font}, ${SHARED[\"--font-sans\"]}`;\n if (declared.has(\"--font-mono\")) {\n variables[\"--font-mono\"] =\n `${variables[\"--font-mono\"]}, ${SHARED[\"--font-mono\"]}`;\n }\n\n return { colorScheme, variables };\n}\n\nconst tint = (color: string | undefined, percent: number) =>\n color ? `color-mix(in srgb, ${color} ${percent}%, transparent)` : undefined;\n\n/**\n * Maps canonical tokens onto the MCP Apps standard style variables, so\n * widgets written for MCP Apps hosts pick up the host theme too.\n */\nexport function toMcpAppsVariables(\n tokens: ThemeTokens,\n): Record<string, string> {\n const v = tokens.variables;\n const entries: [string, string | undefined][] = [\n [\"--color-background-primary\", v[\"--color-background\"]],\n [\"--color-background-secondary\", v[\"--color-surface\"]],\n [\"--color-background-tertiary\", v[\"--color-surface-muted\"]],\n [\"--color-background-inverse\", v[\"--color-text\"]],\n [\"--color-background-ghost\", \"transparent\"],\n [\"--color-background-info\", tint(v[\"--color-info\"], 12)],\n [\"--color-background-danger\", tint(v[\"--color-danger\"], 12)],\n [\"--color-background-success\", tint(v[\"--color-success\"], 12)],\n [\"--color-background-warning\", tint(v[\"--color-warning\"], 12)],\n [\"--color-background-disabled\", v[\"--color-surface-muted\"]],\n [\"--color-text-primary\", v[\"--color-text\"]],\n [\"--color-text-secondary\", v[\"--color-text-muted\"]],\n [\"--color-text-tertiary\", v[\"--color-text-subtle\"]],\n [\"--color-text-inverse\", v[\"--color-background\"]],\n [\"--color-text-ghost\", v[\"--color-text-subtle\"]],\n [\"--color-text-info\", v[\"--color-info\"]],\n [\"--color-text-danger\", v[\"--color-danger\"]],\n [\"--color-text-success\", v[\"--color-success\"]],\n [\"--color-text-warning\", v[\"--color-warning\"]],\n [\"--color-text-disabled\", v[\"--color-text-subtle\"]],\n [\"--color-border-primary\", v[\"--color-border\"]],\n [\"--color-border-secondary\", v[\"--color-border-strong\"]],\n [\"--color-border-tertiary\", v[\"--color-border\"]],\n [\"--color-border-inverse\", v[\"--color-text\"]],\n [\"--color-border-ghost\", \"transparent\"],\n [\"--color-border-info\", v[\"--color-info\"]],\n [\"--color-border-danger\", v[\"--color-danger\"]],\n [\"--color-border-success\", v[\"--color-success\"]],\n [\"--color-border-warning\", v[\"--color-warning\"]],\n [\"--color-border-disabled\", v[\"--color-border\"]],\n [\"--color-ring-primary\", v[\"--color-accent\"]],\n [\"--color-ring-secondary\", v[\"--color-border-strong\"]],\n [\"--color-ring-inverse\", v[\"--color-background\"]],\n [\"--color-ring-info\", v[\"--color-info\"]],\n [\"--color-ring-danger\", v[\"--color-danger\"]],\n [\"--color-ring-success\", v[\"--color-success\"]],\n [\"--color-ring-warning\", v[\"--color-warning\"]],\n [\"--font-sans\", v[\"--font-sans\"]],\n [\"--font-mono\", v[\"--font-mono\"]],\n [\"--font-weight-normal\", \"400\"],\n [\"--font-weight-medium\", \"500\"],\n [\"--font-weight-semibold\", \"600\"],\n [\"--font-weight-bold\", \"700\"],\n [\"--font-text-xs-size\", \"12px\"],\n [\"--font-text-sm-size\", \"14px\"],\n [\"--font-text-md-size\", \"16px\"],\n [\"--font-text-lg-size\", \"18px\"],\n [\"--font-heading-sm-size\", \"18px\"],\n [\"--font-heading-md-size\", \"22px\"],\n [\"--font-heading-lg-size\", \"28px\"],\n [\"--border-radius-xs\", v[\"--radius-sm\"]],\n [\"--border-radius-sm\", v[\"--radius-sm\"]],\n [\"--border-radius-md\", v[\"--radius-md\"]],\n [\"--border-radius-lg\", v[\"--radius-lg\"]],\n [\"--border-radius-xl\", v[\"--radius-lg\"]],\n [\"--border-radius-full\", \"9999px\"],\n [\"--border-width-regular\", \"1px\"],\n ];\n const result: Record<string, string> = {};\n for (const [name, value] of entries) {\n if (value !== undefined) result[name] = value;\n }\n return result;\n}\n\n/** Every variable a frame receives: canonical tokens plus their MCP Apps aliases. */\nexport function themeVariables(tokens: ThemeTokens): Record<string, string> {\n return { ...toMcpAppsVariables(tokens), ...tokens.variables };\n}\n"],"mappings":";;AAkDA,MAAa,eAA0C;CACrD;EACE,MAAM;EACN,OAAO;EACP,OACE;CACJ;CACA;EACE,MAAM;EACN,OAAO;EACP,OAAO;CACT;CACA;EACE,MAAM;EACN,OAAO;EACP,OAAO;CACT;CACA;EACE,MAAM;EACN,OAAO;EACP,OAAO;CACT;CACA;EACE,MAAM;EACN,OAAO;EACP,OAAO;CACT;CACA;EACE,MAAM;EACN,OAAO;EACP,OAAO;CACT;CACA;EACE,MAAM;EACN,OAAO;EACP,OAAO;CACT;CACA;EACE,MAAM;EACN,OAAO;EACP,OAAO;CACT;CACA;EACE,MAAM;EACN,OAAO;EACP,OAAO;CACT;CACA;EACE,MAAM;EACN,OAAO;EACP,OAAO;CACT;CACA;EACE,MAAM;EACN,OAAO;EACP,OAAO;CACT;CACA;EACE,MAAM;EACN,OAAO;EACP,OAAO;CACT;CACA;EACE,MAAM;EACN,OAAO;EACP,OAAO;CACT;CACA;EACE,MAAM;EACN,OAAO;EACP,OAAO;CACT;CACA;EAAE,MAAM;EAAa,OAAO;EAA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,CAAC,0BAA0B,KAAK;CAClC;CACA,MAAM,SAAiC,CAAC;CACxC,KAAK,MAAM,CAAC,MAAM,UAAU,SAC1B,IAAI,UAAU,KAAA,GAAW,OAAO,QAAQ;CAE1C,OAAO;AACT;;AAGA,SAAgB,eAAe,QAA6C;CAC1E,OAAO;EAAE,GAAG,mBAAmB,MAAM;EAAG,GAAG,OAAO;CAAU;AAC9D"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { JsonSchema } from "../json-schema.js";
|
|
2
|
+
export type { JsonSchema };
|
|
3
|
+
/** A model-facing tool, independent of any provider SDK. */
|
|
4
|
+
export type ToolDefinition<Input, Output> = {
|
|
5
|
+
name: string;
|
|
6
|
+
description: string;
|
|
7
|
+
inputSchema: JsonSchema;
|
|
8
|
+
execute(input: Input): Promise<Output>;
|
|
9
|
+
};
|
|
10
|
+
export type AnyTool = ToolDefinition<never, unknown>;
|
|
11
|
+
/** A `read_me` module contributed from outside the built-in set. */
|
|
12
|
+
export type GuidanceModule = {
|
|
13
|
+
name: string;
|
|
14
|
+
/** One line shown in the `read_me` module list. */
|
|
15
|
+
summary: string;
|
|
16
|
+
guidance(): string;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Converts tools to the Vercel AI SDK shape without depending on it: pass
|
|
20
|
+
* the SDK's own `jsonSchema` helper, e.g.
|
|
21
|
+
* `toAISDKTools(tools, { jsonSchema })` with `import { jsonSchema } from "ai"`.
|
|
22
|
+
*/
|
|
23
|
+
export declare function toAISDKTools<T extends Record<string, AnyTool>, Schema>(tools: T, sdk: {
|
|
24
|
+
jsonSchema: (schema: JsonSchema) => Schema;
|
|
25
|
+
}): {
|
|
26
|
+
[K in keyof T]: {
|
|
27
|
+
description: string;
|
|
28
|
+
inputSchema: Schema;
|
|
29
|
+
execute: T[K]["execute"];
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Each tool's name, description, and input schema without `execute`, for
|
|
34
|
+
* declaring tools to a model where they do not run, e.g. on a server that
|
|
35
|
+
* forwards calls to tools executing in the browser.
|
|
36
|
+
*/
|
|
37
|
+
export declare function getToolDeclarations<T extends Record<string, AnyTool>>(tools: T): {
|
|
38
|
+
[K in keyof T]: {
|
|
39
|
+
description: string;
|
|
40
|
+
inputSchema: JsonSchema;
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
//# sourceMappingURL=define.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"define.d.ts","mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAgB;AAEhD,YAAY,EAAE,UAAU,EAAE;AAE1B;AACA,MAAM,MAAM,cAAc,CAAC,KAAK,EAAE,MAAM,IAAI;IAC1C,IAAI,EAAE,MAAM;IACZ,WAAW,EAAE,MAAM;IACnB,WAAW,EAAE,UAAU;IACvB,OAAO,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC;CACvC;AAED,MAAM,MAAM,OAAO,GAAG,cAAc,CAAC,KAAK,EAAE,OAAO,CAAC;AAEpD;AACA,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,EAAE,MAAM;IACZ;IACA,OAAO,EAAE,MAAM;IACf,QAAQ,IAAI,MAAM;CACnB;AAED;;;;;AAKA,wBAAgB,YAAY,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,EACpE,KAAK,EAAE,CAAC,EACR,GAAG,EAAE;IAAE,UAAU,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,MAAM;CAAE,GAClD;KACA,CAAC,IAAI,MAAM,CAAC,GAAG;QACd,WAAW,EAAE,MAAM;QACnB,WAAW,EAAE,MAAM;QACnB,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;KACzB;CACF;AAYD;;;;;AAKA,wBAAgB,mBAAmB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACnE,KAAK,EAAE,CAAC,GACP;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG;QAAE,WAAW,EAAE,MAAM;QAAE,WAAW,EAAE,UAAU;KAAE;CAAE","names":[],"ignoreList":[],"sources":["../../src/tools/define.ts"],"sourcesContent":[null]}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// src/tools/define.ts
|
|
2
|
+
/**
|
|
3
|
+
* Converts tools to the Vercel AI SDK shape without depending on it: pass
|
|
4
|
+
* the SDK's own `jsonSchema` helper, e.g.
|
|
5
|
+
* `toAISDKTools(tools, { jsonSchema })` with `import { jsonSchema } from "ai"`.
|
|
6
|
+
*/
|
|
7
|
+
function toAISDKTools(tools, sdk) {
|
|
8
|
+
const result = {};
|
|
9
|
+
for (const [key, tool] of Object.entries(tools)) result[key] = {
|
|
10
|
+
description: tool.description,
|
|
11
|
+
inputSchema: sdk.jsonSchema(tool.inputSchema),
|
|
12
|
+
execute: (input) => tool.execute(input)
|
|
13
|
+
};
|
|
14
|
+
return result;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Each tool's name, description, and input schema without `execute`, for
|
|
18
|
+
* declaring tools to a model where they do not run, e.g. on a server that
|
|
19
|
+
* forwards calls to tools executing in the browser.
|
|
20
|
+
*/
|
|
21
|
+
function getToolDeclarations(tools) {
|
|
22
|
+
const result = {};
|
|
23
|
+
for (const [key, tool] of Object.entries(tools)) result[key] = {
|
|
24
|
+
description: tool.description,
|
|
25
|
+
inputSchema: tool.inputSchema
|
|
26
|
+
};
|
|
27
|
+
return result;
|
|
28
|
+
}
|
|
29
|
+
export { getToolDeclarations, toAISDKTools };
|
|
30
|
+
|
|
31
|
+
//# sourceMappingURL=define.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"define.js","names":[],"sources":["../../src/tools/define.ts"],"sourcesContent":["import type { JsonSchema } from \"../json-schema\";\n\nexport type { JsonSchema };\n\n/** A model-facing tool, independent of any provider SDK. */\nexport type ToolDefinition<Input, Output> = {\n name: string;\n description: string;\n inputSchema: JsonSchema;\n execute(input: Input): Promise<Output>;\n};\n\nexport type AnyTool = ToolDefinition<never, unknown>;\n\n/** A `read_me` module contributed from outside the built-in set. */\nexport type GuidanceModule = {\n name: string;\n /** One line shown in the `read_me` module list. */\n summary: string;\n guidance(): string;\n};\n\n/**\n * Converts tools to the Vercel AI SDK shape without depending on it: pass\n * the SDK's own `jsonSchema` helper, e.g.\n * `toAISDKTools(tools, { jsonSchema })` with `import { jsonSchema } from \"ai\"`.\n */\nexport function toAISDKTools<T extends Record<string, AnyTool>, Schema>(\n tools: T,\n sdk: { jsonSchema: (schema: JsonSchema) => Schema },\n): {\n [K in keyof T]: {\n description: string;\n inputSchema: Schema;\n execute: T[K][\"execute\"];\n };\n} {\n const result: Record<string, unknown> = {};\n for (const [key, tool] of Object.entries(tools)) {\n result[key] = {\n description: tool.description,\n inputSchema: sdk.jsonSchema(tool.inputSchema),\n execute: (input: never) => tool.execute(input),\n };\n }\n return result as never;\n}\n\n/**\n * Each tool's name, description, and input schema without `execute`, for\n * declaring tools to a model where they do not run, e.g. on a server that\n * forwards calls to tools executing in the browser.\n */\nexport function getToolDeclarations<T extends Record<string, AnyTool>>(\n tools: T,\n): { [K in keyof T]: { description: string; inputSchema: JsonSchema } } {\n const result: Record<string, unknown> = {};\n for (const [key, tool] of Object.entries(tools)) {\n result[key] = {\n description: tool.description,\n inputSchema: tool.inputSchema,\n };\n }\n return result as never;\n}\n"],"mappings":";;;;;;AA2BA,SAAgB,aACd,OACA,KAOA;CACA,MAAM,SAAkC,CAAC;CACzC,KAAK,MAAM,CAAC,KAAK,SAAS,OAAO,QAAQ,KAAK,GAC5C,OAAO,OAAO;EACZ,aAAa,KAAK;EAClB,aAAa,IAAI,WAAW,KAAK,WAAW;EAC5C,UAAU,UAAiB,KAAK,QAAQ,KAAK;CAC/C;CAEF,OAAO;AACT;;;;;;AAOA,SAAgB,oBACd,OACsE;CACtE,MAAM,SAAkC,CAAC;CACzC,KAAK,MAAM,CAAC,KAAK,SAAS,OAAO,QAAQ,KAAK,GAC5C,OAAO,OAAO;EACZ,aAAa,KAAK;EAClB,aAAa,KAAK;CACpB;CAEF,OAAO;AACT"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type WidgetEdit = {
|
|
2
|
+
old_string: string;
|
|
3
|
+
new_string: string;
|
|
4
|
+
};
|
|
5
|
+
export type ApplyEditsResult = {
|
|
6
|
+
ok: true;
|
|
7
|
+
code: string;
|
|
8
|
+
} | {
|
|
9
|
+
ok: false;
|
|
10
|
+
error: string;
|
|
11
|
+
index: number;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Applies exact string replacements in order. Each `old_string` must occur
|
|
15
|
+
* exactly once in the code as it stands after the previous edits; on any
|
|
16
|
+
* failure no edit is applied.
|
|
17
|
+
*/
|
|
18
|
+
export declare function applyWidgetEdits(code: string, edits: readonly WidgetEdit[]): ApplyEditsResult;
|
|
19
|
+
//# sourceMappingURL=edits.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"edits.d.ts","mappings":"AAAA,MAAM,MAAM,UAAU,GAAG;IAAE,UAAU,EAAE,MAAM;IAAE,UAAU,EAAE,MAAM;CAAE;AAEnE,MAAM,MAAM,gBAAgB,GACxB;IAAE,EAAE,EAAE,IAAI;IAAE,IAAI,EAAE,MAAM;CAAE,GAC1B;IAAE,EAAE,EAAE,KAAK;IAAE,KAAK,EAAE,MAAM;IAAE,KAAK,EAAE,MAAM;CAAE;AAkB/C;;;;;AAKA,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,SAAS,UAAU,EAAE,GAC3B,gBAAgB","names":[],"ignoreList":[],"sources":["../../src/tools/edits.ts"],"sourcesContent":[null]}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// src/tools/edits.ts
|
|
2
|
+
const countOccurrences = (haystack, needle) => {
|
|
3
|
+
let count = 0;
|
|
4
|
+
for (let at = haystack.indexOf(needle); at !== -1; at = haystack.indexOf(needle, at + 1)) {
|
|
5
|
+
count++;
|
|
6
|
+
if (count > 1) break;
|
|
7
|
+
}
|
|
8
|
+
return count;
|
|
9
|
+
};
|
|
10
|
+
const preview = (text) => JSON.stringify(text.length > 80 ? `${text.slice(0, 80)}…` : text);
|
|
11
|
+
/**
|
|
12
|
+
* Applies exact string replacements in order. Each `old_string` must occur
|
|
13
|
+
* exactly once in the code as it stands after the previous edits; on any
|
|
14
|
+
* failure no edit is applied.
|
|
15
|
+
*/
|
|
16
|
+
function applyWidgetEdits(code, edits) {
|
|
17
|
+
if (edits.length === 0) return {
|
|
18
|
+
ok: false,
|
|
19
|
+
error: "edits must contain at least one replacement",
|
|
20
|
+
index: -1
|
|
21
|
+
};
|
|
22
|
+
let next = code;
|
|
23
|
+
for (const [index, edit] of edits.entries()) {
|
|
24
|
+
if (!edit.old_string) return {
|
|
25
|
+
ok: false,
|
|
26
|
+
error: `edits[${index}].old_string is empty`,
|
|
27
|
+
index
|
|
28
|
+
};
|
|
29
|
+
if (edit.old_string === edit.new_string) return {
|
|
30
|
+
ok: false,
|
|
31
|
+
error: `edits[${index}] does not change anything`,
|
|
32
|
+
index
|
|
33
|
+
};
|
|
34
|
+
const count = countOccurrences(next, edit.old_string);
|
|
35
|
+
if (count === 0) return {
|
|
36
|
+
ok: false,
|
|
37
|
+
error: `edits[${index}].old_string was not found: ${preview(edit.old_string)}. Copy it exactly from the widget's latest code.`,
|
|
38
|
+
index
|
|
39
|
+
};
|
|
40
|
+
if (count > 1) return {
|
|
41
|
+
ok: false,
|
|
42
|
+
error: `edits[${index}].old_string occurs more than once: ${preview(edit.old_string)}. Include surrounding text so it matches exactly one place.`,
|
|
43
|
+
index
|
|
44
|
+
};
|
|
45
|
+
const at = next.indexOf(edit.old_string);
|
|
46
|
+
next = next.slice(0, at) + edit.new_string + next.slice(at + edit.old_string.length);
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
ok: true,
|
|
50
|
+
code: next
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
export { applyWidgetEdits };
|
|
54
|
+
|
|
55
|
+
//# sourceMappingURL=edits.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"edits.js","names":[],"sources":["../../src/tools/edits.ts"],"sourcesContent":["export type WidgetEdit = { old_string: string; new_string: string };\n\nexport type ApplyEditsResult =\n | { ok: true; code: string }\n | { ok: false; error: string; index: number };\n\nconst countOccurrences = (haystack: string, needle: string) => {\n let count = 0;\n for (\n let at = haystack.indexOf(needle);\n at !== -1;\n at = haystack.indexOf(needle, at + 1)\n ) {\n count++;\n if (count > 1) break;\n }\n return count;\n};\n\nconst preview = (text: string) =>\n JSON.stringify(text.length > 80 ? `${text.slice(0, 80)}…` : text);\n\n/**\n * Applies exact string replacements in order. Each `old_string` must occur\n * exactly once in the code as it stands after the previous edits; on any\n * failure no edit is applied.\n */\nexport function applyWidgetEdits(\n code: string,\n edits: readonly WidgetEdit[],\n): ApplyEditsResult {\n if (edits.length === 0) {\n return {\n ok: false,\n error: \"edits must contain at least one replacement\",\n index: -1,\n };\n }\n let next = code;\n for (const [index, edit] of edits.entries()) {\n if (!edit.old_string) {\n return { ok: false, error: `edits[${index}].old_string is empty`, index };\n }\n if (edit.old_string === edit.new_string) {\n return {\n ok: false,\n error: `edits[${index}] does not change anything`,\n index,\n };\n }\n const count = countOccurrences(next, edit.old_string);\n if (count === 0) {\n return {\n ok: false,\n error: `edits[${index}].old_string was not found: ${preview(edit.old_string)}. Copy it exactly from the widget's latest code.`,\n index,\n };\n }\n if (count > 1) {\n return {\n ok: false,\n error: `edits[${index}].old_string occurs more than once: ${preview(edit.old_string)}. Include surrounding text so it matches exactly one place.`,\n index,\n };\n }\n const at = next.indexOf(edit.old_string);\n next =\n next.slice(0, at) +\n edit.new_string +\n next.slice(at + edit.old_string.length);\n }\n return { ok: true, code: next };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
4
|
+
/** Increments on every show or edit of this title. */
|
|
5
|
+
version: number;
|
|
6
|
+
};
|
|
7
|
+
export type WidgetRegistry = {
|
|
8
|
+
get(title: string): WidgetRecord | undefined;
|
|
9
|
+
set(title: string, code: string): WidgetRecord;
|
|
10
|
+
delete(title: string): boolean;
|
|
11
|
+
list(): WidgetRecord[];
|
|
12
|
+
subscribe(listener: (record: WidgetRecord) => void): () => void;
|
|
13
|
+
};
|
|
14
|
+
/** Tracks the latest code of each widget by title, so edits apply to what the user sees. */
|
|
15
|
+
export declare function createWidgetRegistry(initial?: Iterable<{
|
|
16
|
+
title: string;
|
|
17
|
+
code: string;
|
|
18
|
+
}>): WidgetRegistry;
|
|
19
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","mappings":"AAAA,MAAM,MAAM,YAAY,GAAG;IACzB,KAAK,EAAE,MAAM;IACb,IAAI,EAAE,MAAM;IACZ;IACA,OAAO,EAAE,MAAM;CAChB;AAED,MAAM,MAAM,cAAc,GAAG;IAC3B,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS;IAC5C,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,YAAY;IAC9C,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;IAC9B,IAAI,IAAI,YAAY,EAAE;IACtB,SAAS,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,YAAY,KAAK,IAAI,GAAG,MAAM,IAAI;CAChE;AAED;AACA,wBAAgB,oBAAoB,CAClC,OAAO,GAAE,QAAQ,CAAC;IAAE,KAAK,EAAE,MAAM;IAAE,IAAI,EAAE,MAAM;CAAE,CAAM,GACtD,cAAc","names":[],"ignoreList":[],"sources":["../../src/tools/registry.ts"],"sourcesContent":[null]}
|