@assistant-ui/react-generative-ui 0.0.17 → 0.0.19
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/dist/JSONGenerativeUI.client.d.ts +1 -2
- package/dist/JSONGenerativeUI.client.d.ts.map +1 -1
- package/dist/JSONGenerativeUI.server.d.ts +1 -2
- package/dist/JSONGenerativeUI.server.d.ts.map +1 -1
- package/dist/JSONGenerativeUI.shared.d.ts +8 -9
- package/dist/JSONGenerativeUI.shared.d.ts.map +1 -1
- package/dist/a2ui/convert.d.ts +1 -2
- package/dist/a2ui/convert.d.ts.map +1 -1
- package/dist/a2ui/convert.js +11 -2
- package/dist/a2ui/convert.js.map +1 -1
- package/dist/a2ui/reducer.d.ts +1 -2
- package/dist/a2ui/reducer.d.ts.map +1 -1
- package/dist/a2ui/reducer.js +63 -10
- package/dist/a2ui/reducer.js.map +1 -1
- package/dist/a2ui/types.d.ts +17 -18
- package/dist/a2ui/types.d.ts.map +1 -1
- package/dist/actionRegistry.d.ts +5 -6
- package/dist/actionRegistry.d.ts.map +1 -1
- package/dist/buildPresentParameters.d.ts +2 -3
- package/dist/buildPresentParameters.d.ts.map +1 -1
- package/dist/buildPresentParameters.js +4 -3
- package/dist/buildPresentParameters.js.map +1 -1
- package/dist/constants.d.ts +2 -2
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +2 -1
- package/dist/constants.js.map +1 -1
- package/dist/convert/boundSpec.d.ts +7 -8
- package/dist/convert/boundSpec.d.ts.map +1 -1
- package/dist/convert/copyBounded.d.ts +1 -2
- package/dist/convert/copyBounded.d.ts.map +1 -1
- package/dist/convert/isElement.d.ts +1 -2
- package/dist/convert/isElement.d.ts.map +1 -1
- package/dist/convert/takeRun.d.ts +1 -2
- package/dist/convert/takeRun.d.ts.map +1 -1
- package/dist/defineGenerativeComponents.d.ts +1 -2
- package/dist/defineGenerativeComponents.d.ts.map +1 -1
- package/dist/generativeUIToJSX.d.ts +2 -3
- package/dist/generativeUIToJSX.d.ts.map +1 -1
- package/dist/ir.d.ts +28 -29
- package/dist/ir.d.ts.map +1 -1
- package/dist/renderGenerativeUI.d.ts +1 -2
- package/dist/renderGenerativeUI.d.ts.map +1 -1
- package/dist/renderGenerativeUI.js +1 -1
- package/dist/renderGenerativeUI.js.map +1 -1
- package/dist/slack/constants.d.ts +35 -36
- package/dist/slack/constants.d.ts.map +1 -1
- package/dist/slack/decodeBlockAction.d.ts +1 -2
- package/dist/slack/decodeBlockAction.d.ts.map +1 -1
- package/dist/slack/fromSlackBlocks.d.ts +1 -2
- package/dist/slack/fromSlackBlocks.d.ts.map +1 -1
- package/dist/slack/toSlackBlocks.d.ts +1 -2
- package/dist/slack/toSlackBlocks.d.ts.map +1 -1
- package/dist/slack/types.d.ts +32 -33
- package/dist/slack/types.d.ts.map +1 -1
- package/dist/teams/constants.d.ts +14 -15
- package/dist/teams/constants.d.ts.map +1 -1
- package/dist/teams/decodeSubmitData.d.ts +1 -2
- package/dist/teams/decodeSubmitData.d.ts.map +1 -1
- package/dist/teams/toAdaptiveCard.d.ts +6 -7
- package/dist/teams/toAdaptiveCard.d.ts.map +1 -1
- package/dist/teams/toTeamsAttachments.d.ts +1 -2
- package/dist/teams/toTeamsAttachments.d.ts.map +1 -1
- package/dist/teams/types.d.ts +29 -30
- package/dist/teams/types.d.ts.map +1 -1
- package/dist/types.d.ts +9 -10
- package/dist/types.d.ts.map +1 -1
- package/dist/vocabulary/alert.d.ts +2 -3
- package/dist/vocabulary/alert.d.ts.map +1 -1
- package/dist/vocabulary/alert.js +21 -16
- package/dist/vocabulary/alert.js.map +1 -1
- package/dist/vocabulary/collectFormValues.d.ts +6 -5
- package/dist/vocabulary/collectFormValues.d.ts.map +1 -1
- package/dist/vocabulary/collectFormValues.js +3 -2
- package/dist/vocabulary/collectFormValues.js.map +1 -1
- package/dist/vocabulary/data.d.ts +1 -2
- package/dist/vocabulary/data.d.ts.map +1 -1
- package/dist/vocabulary/data.js +20 -12
- package/dist/vocabulary/data.js.map +1 -1
- package/dist/vocabulary/dispatch.d.ts +2 -3
- package/dist/vocabulary/dispatch.d.ts.map +1 -1
- package/dist/vocabulary/fact.d.ts +1 -2
- package/dist/vocabulary/fact.d.ts.map +1 -1
- package/dist/vocabulary/fact.js +3 -2
- package/dist/vocabulary/fact.js.map +1 -1
- package/dist/vocabulary/form.d.ts +1 -2
- package/dist/vocabulary/form.d.ts.map +1 -1
- package/dist/vocabulary/icon.d.ts +1 -2
- package/dist/vocabulary/icon.d.ts.map +1 -1
- package/dist/vocabulary/index.d.ts +1 -2
- package/dist/vocabulary/index.d.ts.map +1 -1
- package/dist/vocabulary/interactive.d.ts +10 -9
- package/dist/vocabulary/interactive.d.ts.map +1 -1
- package/dist/vocabulary/interactive.js +30 -23
- package/dist/vocabulary/interactive.js.map +1 -1
- package/dist/vocabulary/layout.d.ts +1 -2
- package/dist/vocabulary/layout.d.ts.map +1 -1
- package/dist/vocabulary/layout.js +7 -5
- package/dist/vocabulary/layout.js.map +1 -1
- package/dist/vocabulary/list.d.ts +1 -2
- package/dist/vocabulary/list.d.ts.map +1 -1
- package/dist/vocabulary/media.d.ts +1 -2
- package/dist/vocabulary/media.d.ts.map +1 -1
- package/dist/vocabulary/text.d.ts +2 -3
- package/dist/vocabulary/text.d.ts.map +1 -1
- package/dist/vocabulary/text.js +4 -3
- package/dist/vocabulary/text.js.map +1 -1
- package/dist/vocabulary/toTextContent.d.ts +4 -0
- package/dist/vocabulary/toTextContent.d.ts.map +1 -0
- package/dist/vocabulary/toTextContent.js +6 -0
- package/dist/vocabulary/toTextContent.js.map +1 -0
- package/package.json +12 -10
- package/src/a2ui/convert.test.ts +36 -0
- package/src/a2ui/convert.ts +21 -2
- package/src/a2ui/reducer.test.ts +223 -0
- package/src/a2ui/reducer.ts +76 -12
- package/src/buildPresentParameters.ts +7 -4
- package/src/constants.ts +2 -0
- package/src/renderGenerativeUI.test.tsx +57 -0
- package/src/renderGenerativeUI.tsx +3 -1
- package/src/slack/fromSlackBlocks.test.ts +4 -1
- package/src/slack/toSlackBlocks.test.ts +8 -4
- package/src/teams/toAdaptiveCard.test.ts +5 -3
- package/src/vocabulary/alert.test.tsx +10 -0
- package/src/vocabulary/alert.tsx +16 -7
- package/src/vocabulary/collectFormValues.test.ts +38 -0
- package/src/vocabulary/collectFormValues.ts +11 -2
- package/src/vocabulary/data.test.tsx +40 -0
- package/src/vocabulary/data.tsx +47 -26
- package/src/vocabulary/fact.test.tsx +12 -0
- package/src/vocabulary/fact.tsx +3 -2
- package/src/vocabulary/form.test.tsx +1 -0
- package/src/vocabulary/interactive.test.tsx +55 -1
- package/src/vocabulary/interactive.tsx +50 -29
- package/src/vocabulary/layout.test.tsx +17 -0
- package/src/vocabulary/layout.tsx +8 -4
- package/src/vocabulary/list.test.tsx +5 -4
- package/src/vocabulary/text.test.tsx +29 -0
- package/src/vocabulary/text.tsx +4 -3
- package/src/vocabulary/toTextContent.ts +2 -0
- package/dist/node_modules/.pnpm/@types_json-schema@7.0.15/node_modules/@types/json-schema/index.d.ts +0 -141
- package/dist/node_modules/.pnpm/@types_json-schema@7.0.15/node_modules/@types/json-schema/index.d.ts.map +0 -1
|
@@ -20,14 +20,15 @@ import { toJSONSchema } from "assistant-stream";
|
|
|
20
20
|
*/
|
|
21
21
|
function buildPresentParameters(library) {
|
|
22
22
|
const names = Object.keys(library);
|
|
23
|
-
const props =
|
|
23
|
+
const props = /* @__PURE__ */ new Map();
|
|
24
24
|
const propOwners = /* @__PURE__ */ new Map();
|
|
25
25
|
for (const name of names) {
|
|
26
26
|
const propsSchema = toJSONSchema(library[name].properties);
|
|
27
27
|
if (propsSchema.type !== "object") throw new Error(`[@assistant-ui/react-generative-ui] Component "${name}": \`properties\` must be an object schema (e.g. \`z.object({ ... })\`).`);
|
|
28
28
|
for (const [key, schema] of Object.entries(propsSchema.properties ?? {})) {
|
|
29
29
|
if (key.startsWith("$") || key === "children") continue;
|
|
30
|
-
if (
|
|
30
|
+
if (key === "__proto__") continue;
|
|
31
|
+
if (!props.has(key)) props.set(key, schema);
|
|
31
32
|
propOwners.set(key, [...propOwners.get(key) ?? [], name]);
|
|
32
33
|
}
|
|
33
34
|
}
|
|
@@ -48,7 +49,7 @@ function buildPresentParameters(library) {
|
|
|
48
49
|
description: "Stable identity for this UI node. Use it for list items that may reorder.",
|
|
49
50
|
anyOf: [{ type: "string" }, { type: "number" }]
|
|
50
51
|
},
|
|
51
|
-
...props,
|
|
52
|
+
...Object.fromEntries(props),
|
|
52
53
|
children: { $ref: "#/$defs/children" }
|
|
53
54
|
},
|
|
54
55
|
required: [TYPE_KEY]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildPresentParameters.js","names":[],"sources":["../src/buildPresentParameters.ts"],"sourcesContent":["import { toJSONSchema } from \"assistant-stream\";\nimport type { JSONSchema7, JSONSchema7Definition } from \"json-schema\";\nimport { TYPE_KEY } from \"./constants\";\nimport type { GenerativeUILibrary } from \"./types\";\n\n/**\n * Builds the JSON schema for the `present` tool from a {@link GenerativeUILibrary}.\n *\n * The model produces a node `{ $type, $key?, ...props }` where `$type` selects\n * a component, the optional `$key` pins a stable identity for list items that\n * may reorder, and the rest are its props. The schema is a flat object: `$type`\n * is an enum of the component names, every component's props are merged into\n * one optional bag, and `children` recurses via `$defs` so the tree can nest.\n *\n * It is intentionally flat rather than a per-`$type` discriminated union. Tool /\n * function-call schemas (OpenAI and others) require the top-level parameters to\n * be a plain object and reject a top-level `oneOf`/`anyOf`/`enum`. So props can't\n * be refined per `$type` at the root; the model is guided instead by `$type`'s\n * description (which lists each component) and each prop's own description. The\n * renderer validates nothing here — an unknown `$type` or stray prop is handled\n * at render time — so a looser schema only costs the model a hint, not safety.\n */\nexport function buildPresentParameters(\n library: GenerativeUILibrary,\n): JSONSchema7 {\n const names = Object.keys(library);\n\n // Merge every component's props into one optional bag. `$`-prefixed keys and\n // `children` are framework-reserved (see ir.ts), so drop any author-declared\n // copies. On a name clash the first component's schema wins — props are an\n // advisory hint here, not a strict per-component contract.\n const props
|
|
1
|
+
{"version":3,"file":"buildPresentParameters.js","names":[],"sources":["../src/buildPresentParameters.ts"],"sourcesContent":["import { toJSONSchema } from \"assistant-stream\";\nimport type { JSONSchema7, JSONSchema7Definition } from \"json-schema\";\nimport { TYPE_KEY } from \"./constants\";\nimport type { GenerativeUILibrary } from \"./types\";\n\n/**\n * Builds the JSON schema for the `present` tool from a {@link GenerativeUILibrary}.\n *\n * The model produces a node `{ $type, $key?, ...props }` where `$type` selects\n * a component, the optional `$key` pins a stable identity for list items that\n * may reorder, and the rest are its props. The schema is a flat object: `$type`\n * is an enum of the component names, every component's props are merged into\n * one optional bag, and `children` recurses via `$defs` so the tree can nest.\n *\n * It is intentionally flat rather than a per-`$type` discriminated union. Tool /\n * function-call schemas (OpenAI and others) require the top-level parameters to\n * be a plain object and reject a top-level `oneOf`/`anyOf`/`enum`. So props can't\n * be refined per `$type` at the root; the model is guided instead by `$type`'s\n * description (which lists each component) and each prop's own description. The\n * renderer validates nothing here — an unknown `$type` or stray prop is handled\n * at render time — so a looser schema only costs the model a hint, not safety.\n */\nexport function buildPresentParameters(\n library: GenerativeUILibrary,\n): JSONSchema7 {\n const names = Object.keys(library);\n\n // Merge every component's props into one optional bag. `$`-prefixed keys and\n // `children` are framework-reserved (see ir.ts), so drop any author-declared\n // copies. On a name clash the first component's schema wins — props are an\n // advisory hint here, not a strict per-component contract.\n const props = new Map<string, JSONSchema7Definition>();\n const propOwners = new Map<string, string[]>();\n for (const name of names) {\n const propsSchema = toJSONSchema(library[name]!.properties);\n if (propsSchema.type !== \"object\") {\n throw new Error(\n `[@assistant-ui/react-generative-ui] Component \"${name}\": ` +\n \"`properties` must be an object schema (e.g. `z.object({ ... })`).\",\n );\n }\n for (const [key, schema] of Object.entries(propsSchema.properties ?? {})) {\n if (key.startsWith(\"$\") || key === \"children\") continue;\n // secure-json-parse rejects the whole tool-argument payload on this key,\n // so advertising it would cost the model the node rather than one prop.\n if (key === \"__proto__\") continue;\n if (!props.has(key)) {\n props.set(key, schema);\n }\n propOwners.set(key, [...(propOwners.get(key) ?? []), name]);\n }\n }\n\n if (process.env[\"NODE_ENV\"] !== \"production\") {\n for (const [key, owners] of propOwners) {\n if (owners.length < 2) continue;\n // eslint-disable-next-line no-console\n console.warn(\n `[@assistant-ui/react-generative-ui] Prop \"${key}\" is declared by ` +\n `${formatComponentList(owners)}; keeping \"${owners[0]}\"'s schema. ` +\n \"Rename or align the prop type to avoid an ambiguous schema.\",\n );\n }\n }\n\n // Carry each component's description on the `$type` enum, since there are no\n // per-branch schemas to hang them on anymore.\n const typeDescription =\n names.length > 0\n ? `The component to render. ${names\n .map((name) => `\"${name}\": ${library[name]!.description}`)\n .join(\"; \")}`\n : \"The component to render.\";\n\n const node: JSONSchema7 = {\n type: \"object\",\n properties: {\n [TYPE_KEY]: { type: \"string\", enum: names, description: typeDescription },\n $key: {\n description:\n \"Stable identity for this UI node. Use it for list items that may reorder.\",\n anyOf: [{ type: \"string\" }, { type: \"number\" }],\n },\n ...Object.fromEntries(props),\n children: { $ref: \"#/$defs/children\" },\n },\n required: [TYPE_KEY],\n };\n\n const children: JSONSchema7 = {\n description: \"Nested generative UI rendered inside this component.\",\n anyOf: [\n { type: \"string\" },\n { $ref: \"#/$defs/node\" },\n {\n type: \"array\",\n items: { anyOf: [{ type: \"string\" }, { $ref: \"#/$defs/node\" }] },\n },\n ],\n };\n\n return {\n ...node,\n $defs: { node, children },\n };\n}\n\nfunction formatComponentList(names: string[]) {\n if (names.length <= 2) return names.map((name) => `\"${name}\"`).join(\" and \");\n\n return `${names\n .slice(0, -1)\n .map((name) => `\"${name}\"`)\n .join(\", \")}, and \"${names[names.length - 1]}\"`;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAsBA,SAAgB,uBACd,SACa;CACb,MAAM,QAAQ,OAAO,KAAK,OAAO;CAMjC,MAAM,wBAAQ,IAAI,IAAmC;CACrD,MAAM,6BAAa,IAAI,IAAsB;CAC7C,KAAK,MAAM,QAAQ,OAAO;EACxB,MAAM,cAAc,aAAa,QAAQ,KAAK,CAAE,UAAU;EAC1D,IAAI,YAAY,SAAS,UACvB,MAAM,IAAI,MACR,kDAAkD,KAAK,yEAEzD;EAEF,KAAK,MAAM,CAAC,KAAK,WAAW,OAAO,QAAQ,YAAY,cAAc,CAAC,CAAC,GAAG;GACxE,IAAI,IAAI,WAAW,GAAG,KAAK,QAAQ,YAAY;GAG/C,IAAI,QAAQ,aAAa;GACzB,IAAI,CAAC,MAAM,IAAI,GAAG,GAChB,MAAM,IAAI,KAAK,MAAM;GAEvB,WAAW,IAAI,KAAK,CAAC,GAAI,WAAW,IAAI,GAAG,KAAK,CAAC,GAAI,IAAI,CAAC;EAC5D;CACF;CAEA,IAAI,QAAQ,IAAI,gBAAgB,cAC9B,KAAK,MAAM,CAAC,KAAK,WAAW,YAAY;EACtC,IAAI,OAAO,SAAS,GAAG;EAEvB,QAAQ,KACN,6CAA6C,IAAI,mBAC5C,oBAAoB,MAAM,EAAE,aAAa,OAAO,GAAG,wEAE1D;CACF;CAKF,MAAM,kBACJ,MAAM,SAAS,IACX,4BAA4B,MACzB,KAAK,SAAS,IAAI,KAAK,KAAK,QAAQ,KAAK,CAAE,aAAa,CAAC,CACzD,KAAK,IAAI,MACZ;CAEN,MAAM,OAAoB;EACxB,MAAM;EACN,YAAY;IACT,WAAW;IAAE,MAAM;IAAU,MAAM;IAAO,aAAa;GAAgB;GACxE,MAAM;IACJ,aACE;IACF,OAAO,CAAC,EAAE,MAAM,SAAS,GAAG,EAAE,MAAM,SAAS,CAAC;GAChD;GACA,GAAG,OAAO,YAAY,KAAK;GAC3B,UAAU,EAAE,MAAM,mBAAmB;EACvC;EACA,UAAU,CAAC,QAAQ;CACrB;CAEA,MAAM,WAAwB;EAC5B,aAAa;EACb,OAAO;GACL,EAAE,MAAM,SAAS;GACjB,EAAE,MAAM,eAAe;GACvB;IACE,MAAM;IACN,OAAO,EAAE,OAAO,CAAC,EAAE,MAAM,SAAS,GAAG,EAAE,MAAM,eAAe,CAAC,EAAE;GACjE;EACF;CACF;CAEA,OAAO;EACL,GAAG;EACH,OAAO;GAAE;GAAM;EAAS;CAC1B;AACF;AAEA,SAAS,oBAAoB,OAAiB;CAC5C,IAAI,MAAM,UAAU,GAAG,OAAO,MAAM,KAAK,SAAS,IAAI,KAAK,EAAE,CAAC,CAAC,KAAK,OAAO;CAE3E,OAAO,GAAG,MACP,MAAM,GAAG,EAAE,CAAC,CACZ,KAAK,SAAS,IAAI,KAAK,EAAE,CAAC,CAC1B,KAAK,IAAI,EAAE,SAAS,MAAM,MAAM,SAAS,GAAG;AACjD"}
|
package/dist/constants.d.ts
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* colliding with the discriminator. It mirrors the `$type` discriminator
|
|
9
9
|
* convention used by JSON polymorphism elsewhere.
|
|
10
10
|
*/
|
|
11
|
-
declare const TYPE_KEY = "$type";
|
|
11
|
+
export declare const TYPE_KEY = "$type";
|
|
12
|
+
export declare const GENERATED_NAME_ATTR = "data-aui-generated-name";
|
|
12
13
|
//#endregion
|
|
13
|
-
export { TYPE_KEY };
|
|
14
14
|
//# sourceMappingURL=constants.d.ts.map
|
package/dist/constants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","names":[],"sources":["../src/constants.ts"],"mappings":";;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"constants.d.ts","names":[],"sources":["../src/constants.ts"],"mappings":";;;;;;;;;;qBASa;qBAEA"}
|
package/dist/constants.js
CHANGED
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
* convention used by JSON polymorphism elsewhere.
|
|
10
10
|
*/
|
|
11
11
|
const TYPE_KEY = "$type";
|
|
12
|
+
const GENERATED_NAME_ATTR = "data-aui-generated-name";
|
|
12
13
|
//#endregion
|
|
13
|
-
export { TYPE_KEY };
|
|
14
|
+
export { GENERATED_NAME_ATTR, TYPE_KEY };
|
|
14
15
|
|
|
15
16
|
//# sourceMappingURL=constants.js.map
|
package/dist/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","names":[],"sources":["../src/constants.ts"],"sourcesContent":["/**\n * The wire key naming the component to render.\n *\n * The model emits nodes as flat objects `{ [TYPE_KEY]: name, ...props }`. We\n * use `$type` rather than `type` so a component's own `type` prop (e.g. a\n * button's `type=\"submit\"`) flows through as an ordinary prop without\n * colliding with the discriminator. It mirrors the `$type` discriminator\n * convention used by JSON polymorphism elsewhere.\n */\nexport const TYPE_KEY = \"$type\";\n"],"mappings":";;;;;;;;;;AASA,MAAa,WAAW"}
|
|
1
|
+
{"version":3,"file":"constants.js","names":[],"sources":["../src/constants.ts"],"sourcesContent":["/**\n * The wire key naming the component to render.\n *\n * The model emits nodes as flat objects `{ [TYPE_KEY]: name, ...props }`. We\n * use `$type` rather than `type` so a component's own `type` prop (e.g. a\n * button's `type=\"submit\"`) flows through as an ordinary prop without\n * colliding with the discriminator. It mirrors the `$type` discriminator\n * convention used by JSON polymorphism elsewhere.\n */\nexport const TYPE_KEY = \"$type\";\n\nexport const GENERATED_NAME_ATTR = \"data-aui-generated-name\";\n"],"mappings":";;;;;;;;;;AASA,MAAa,WAAW;AAExB,MAAa,sBAAsB"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
//#region src/convert/boundSpec.d.ts
|
|
2
2
|
/** The maximum traversal depth, counted in visited values, not tree levels. */
|
|
3
|
-
declare const MAX_TRAVERSAL_DEPTH = 64;
|
|
3
|
+
export declare const MAX_TRAVERSAL_DEPTH = 64;
|
|
4
4
|
/**
|
|
5
5
|
* The element-nesting ceiling a caller observes. `boundNode` visits an element
|
|
6
6
|
* and its `children` array separately, so one level of nesting spends two of
|
|
7
7
|
* {@link MAX_TRAVERSAL_DEPTH}; it runs before the conversion walk and is never
|
|
8
8
|
* the looser of the two. A root array costs one more level than a root object.
|
|
9
9
|
*/
|
|
10
|
-
declare const MAX_ELEMENT_DEPTH: number;
|
|
10
|
+
export declare const MAX_ELEMENT_DEPTH: number;
|
|
11
11
|
/**
|
|
12
12
|
* The maximum number of entries kept at any single level (root, or a
|
|
13
13
|
* `children` array at any depth) of the raw spec, before it ever reaches
|
|
@@ -15,7 +15,7 @@ declare const MAX_ELEMENT_DEPTH: number;
|
|
|
15
15
|
* can never be made to walk further than this regardless of what the array
|
|
16
16
|
* claims about itself.
|
|
17
17
|
*/
|
|
18
|
-
declare const CHILDREN_CAP = 200;
|
|
18
|
+
export declare const CHILDREN_CAP = 200;
|
|
19
19
|
/**
|
|
20
20
|
* The total number of nodes {@link boundSpec} will visit across one walk,
|
|
21
21
|
* regardless of how many times a shared reference recurs. Bounds the
|
|
@@ -23,10 +23,10 @@ declare const CHILDREN_CAP = 200;
|
|
|
23
23
|
* otherwise force even though each individual array stays within
|
|
24
24
|
* {@link CHILDREN_CAP}.
|
|
25
25
|
*/
|
|
26
|
-
declare const NODE_BUDGET = 5000;
|
|
27
|
-
type ClampReason = "children" | "budget" | "cycle" | "depth";
|
|
26
|
+
export declare const NODE_BUDGET = 5000;
|
|
27
|
+
export type ClampReason = "children" | "budget" | "cycle" | "depth";
|
|
28
28
|
/** Renders the warning detail a protocol reports for one {@link ClampReason}. */
|
|
29
|
-
declare function clampReasonDetail(reason: ClampReason): string;
|
|
29
|
+
export declare function clampReasonDetail(reason: ClampReason): string;
|
|
30
30
|
/**
|
|
31
31
|
* Produces a bounded plain copy of a raw generative-ui spec before it
|
|
32
32
|
* reaches `normalizeSpec`, whose own traversal of the root array or any
|
|
@@ -45,7 +45,6 @@ declare function clampReasonDetail(reason: ClampReason): string;
|
|
|
45
45
|
* {@link NODE_BUDGET} nodes, so shared references cannot multiply work
|
|
46
46
|
* exponentially, and a node that is its own ancestor is cut to `null`.
|
|
47
47
|
*/
|
|
48
|
-
declare function boundSpec(spec: unknown, onClamp: (reason: ClampReason) => void): unknown;
|
|
48
|
+
export declare function boundSpec(spec: unknown, onClamp: (reason: ClampReason) => void): unknown;
|
|
49
49
|
//#endregion
|
|
50
|
-
export { CHILDREN_CAP, ClampReason, MAX_ELEMENT_DEPTH, MAX_TRAVERSAL_DEPTH, NODE_BUDGET, boundSpec, clampReasonDetail };
|
|
51
50
|
//# sourceMappingURL=boundSpec.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"boundSpec.d.ts","names":[],"sources":["../../src/convert/boundSpec.ts"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"boundSpec.d.ts","names":[],"sources":["../../src/convert/boundSpec.ts"],"mappings":";;qBAGa;;;;;;;qBAQA;;;;;;;;qBASA;;;;;;;;qBASA;YAED;;wBAGI,kBAAkB,QAAQ;;;;;;;;;;;;;;;;;;;wBAwF1B,UACd,eACA,UAAU,QAAQ"}
|
|
@@ -19,10 +19,9 @@
|
|
|
19
19
|
* that same normalized figure, so a `length` whose `valueOf` answers differently
|
|
20
20
|
* on a second conversion cannot separate the warning from the bound.
|
|
21
21
|
*/
|
|
22
|
-
declare const copyBounded: <T>(value: readonly T[], cap: number) => {
|
|
22
|
+
export declare const copyBounded: <T>(value: readonly T[], cap: number) => {
|
|
23
23
|
readonly items: T[];
|
|
24
24
|
readonly truncated: boolean;
|
|
25
25
|
};
|
|
26
26
|
//#endregion
|
|
27
|
-
export { copyBounded };
|
|
28
27
|
//# sourceMappingURL=copyBounded.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"copyBounded.d.ts","names":[],"sources":["../../src/convert/copyBounded.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"copyBounded.d.ts","names":[],"sources":["../../src/convert/copyBounded.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;qBAoBa,cAAe,GAC1B,gBAAgB,KAChB;WACY,OAAO;WAAc"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { NormalizedUIElement, NormalizedUINode } from "../ir.js";
|
|
2
2
|
//#region src/convert/isElement.d.ts
|
|
3
|
-
declare const isElement: (node: NormalizedUINode) => node is NormalizedUIElement;
|
|
3
|
+
export declare const isElement: (node: NormalizedUINode) => node is NormalizedUIElement;
|
|
4
4
|
//#endregion
|
|
5
|
-
export { isElement };
|
|
6
5
|
//# sourceMappingURL=isElement.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isElement.d.ts","names":[],"sources":["../../src/convert/isElement.ts"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"isElement.d.ts","names":[],"sources":["../../src/convert/isElement.ts"],"mappings":";;qBAEa,YACX,MAAM,qBACL,QAAQ"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { NormalizedUIElement, NormalizedUINode } from "../ir.js";
|
|
2
2
|
//#region src/convert/takeRun.d.ts
|
|
3
|
-
declare function takeRun(nodes: readonly (NormalizedUINode | undefined)[], index: number, matches: (element: NormalizedUIElement) => boolean): {
|
|
3
|
+
export declare function takeRun(nodes: readonly (NormalizedUINode | undefined)[], index: number, matches: (element: NormalizedUIElement) => boolean): {
|
|
4
4
|
run: NormalizedUIElement[];
|
|
5
5
|
next: number;
|
|
6
6
|
};
|
|
7
7
|
//#endregion
|
|
8
|
-
export { takeRun };
|
|
9
8
|
//# sourceMappingURL=takeRun.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"takeRun.d.ts","names":[],"sources":["../../src/convert/takeRun.ts"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"takeRun.d.ts","names":[],"sources":["../../src/convert/takeRun.ts"],"mappings":";;wBAGgB,QACd,iBAAiB,iCACjB,eACA,UAAU,SAAS;EAChB,KAAK;EAAuB"}
|
|
@@ -26,7 +26,6 @@ import { GenerativeUILibrary } from "./types.js";
|
|
|
26
26
|
* is missing, or it was used outside a `"use generative"` file), so it throws
|
|
27
27
|
* rather than shipping client `render` code to the server.
|
|
28
28
|
*/
|
|
29
|
-
declare function defineGenerativeComponents(_library: GenerativeUILibrary): GenerativeUILibrary;
|
|
29
|
+
export declare function defineGenerativeComponents(_library: GenerativeUILibrary): GenerativeUILibrary;
|
|
30
30
|
//#endregion
|
|
31
|
-
export { defineGenerativeComponents };
|
|
32
31
|
//# sourceMappingURL=defineGenerativeComponents.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defineGenerativeComponents.d.ts","names":[],"sources":["../src/defineGenerativeComponents.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"defineGenerativeComponents.d.ts","names":[],"sources":["../src/defineGenerativeComponents.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;wBA4BgB,2BACd,UAAU,sBACT"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
//#region src/generativeUIToJSX.d.ts
|
|
2
2
|
/** Options for {@link generativeUIToJSX}. */
|
|
3
|
-
interface GenerativeUIToJSXOptions {
|
|
3
|
+
export interface GenerativeUIToJSXOptions {
|
|
4
4
|
/** Escape string children so the output is safe to paste back into a JSX file. Defaults to `false`. */
|
|
5
5
|
escape?: boolean;
|
|
6
6
|
/** Pretty-print nested element trees with two-space indentation. Defaults to `false`. */
|
|
@@ -15,7 +15,6 @@ interface GenerativeUIToJSXOptions {
|
|
|
15
15
|
*
|
|
16
16
|
* Pass `{ pretty: true }` to pretty-print nested element trees with two-space indentation, while pure text children stay on one line.
|
|
17
17
|
*/
|
|
18
|
-
declare function generativeUIToJSX(node: unknown, options?: GenerativeUIToJSXOptions): string;
|
|
18
|
+
export declare function generativeUIToJSX(node: unknown, options?: GenerativeUIToJSXOptions): string;
|
|
19
19
|
//#endregion
|
|
20
|
-
export { GenerativeUIToJSXOptions, generativeUIToJSX };
|
|
21
20
|
//# sourceMappingURL=generativeUIToJSX.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generativeUIToJSX.d.ts","names":[],"sources":["../src/generativeUIToJSX.ts"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"generativeUIToJSX.d.ts","names":[],"sources":["../src/generativeUIToJSX.ts"],"mappings":";;iBAGiB;;EAEf;;EAEA;;;;;;;;;;;wBAYc,kBACd,eACA,UAAU"}
|
package/dist/ir.d.ts
CHANGED
|
@@ -15,30 +15,30 @@
|
|
|
15
15
|
* - `children` is additionally reserved (the JSX convention).
|
|
16
16
|
* - every other key is an inline prop passed straight to the component.
|
|
17
17
|
*/
|
|
18
|
-
declare const TEXT_SIZES: readonly ["sm", "md", "lg", "xl", "2xl", "3xl"];
|
|
19
|
-
type TextSize = (typeof TEXT_SIZES)[number];
|
|
20
|
-
declare const IMAGE_SIZE_TOKENS: readonly ["sm", "md", "lg"];
|
|
21
|
-
type ImageSize = (typeof IMAGE_SIZE_TOKENS)[number] | number;
|
|
22
|
-
declare const WEIGHTS: readonly ["normal", "medium", "semibold", "bold"];
|
|
23
|
-
type Weight = (typeof WEIGHTS)[number];
|
|
24
|
-
declare const COLORS: readonly ["emphasis", "secondary", "alpha-70", "white", "white-70", "white-50"];
|
|
25
|
-
type Color = (typeof COLORS)[number];
|
|
26
|
-
declare const ALIGNS: readonly ["start", "center", "end"];
|
|
27
|
-
type Align = (typeof ALIGNS)[number];
|
|
28
|
-
declare const JUSTIFIES: readonly ["start", "center", "end", "between"];
|
|
29
|
-
type Justify = (typeof JUSTIFIES)[number];
|
|
30
|
-
declare const BUTTON_STYLES: readonly ["primary", "secondary", "outline", "ghost", "danger"];
|
|
31
|
-
type ButtonStyle = (typeof BUTTON_STYLES)[number];
|
|
32
|
-
declare const ALERT_TONES: readonly ["info", "success", "warning", "danger"];
|
|
18
|
+
export declare const TEXT_SIZES: readonly ["sm", "md", "lg", "xl", "2xl", "3xl"];
|
|
19
|
+
export type TextSize = (typeof TEXT_SIZES)[number];
|
|
20
|
+
export declare const IMAGE_SIZE_TOKENS: readonly ["sm", "md", "lg"];
|
|
21
|
+
export type ImageSize = (typeof IMAGE_SIZE_TOKENS)[number] | number;
|
|
22
|
+
export declare const WEIGHTS: readonly ["normal", "medium", "semibold", "bold"];
|
|
23
|
+
export type Weight = (typeof WEIGHTS)[number];
|
|
24
|
+
export declare const COLORS: readonly ["emphasis", "secondary", "alpha-70", "white", "white-70", "white-50"];
|
|
25
|
+
export type Color = (typeof COLORS)[number];
|
|
26
|
+
export declare const ALIGNS: readonly ["start", "center", "end"];
|
|
27
|
+
export type Align = (typeof ALIGNS)[number];
|
|
28
|
+
export declare const JUSTIFIES: readonly ["start", "center", "end", "between"];
|
|
29
|
+
export type Justify = (typeof JUSTIFIES)[number];
|
|
30
|
+
export declare const BUTTON_STYLES: readonly ["primary", "secondary", "outline", "ghost", "danger"];
|
|
31
|
+
export type ButtonStyle = (typeof BUTTON_STYLES)[number];
|
|
32
|
+
export declare const ALERT_TONES: readonly ["info", "success", "warning", "danger"];
|
|
33
33
|
/** A severity level, from informational to destructive. */
|
|
34
|
-
type AlertTone = (typeof ALERT_TONES)[number];
|
|
35
|
-
declare const ICON_NAMES: readonly ["sun", "moon", "cloud", "rain", "snow", "wind", "play", "pause", "check", "x", "star", "heart", "arrow-right", "arrow-up-right", "chevron-right", "calendar", "clock", "map-pin", "plane", "truck", "credit-card", "user", "search", "bell"];
|
|
34
|
+
export type AlertTone = (typeof ALERT_TONES)[number];
|
|
35
|
+
export declare const ICON_NAMES: readonly ["sun", "moon", "cloud", "rain", "snow", "wind", "play", "pause", "check", "x", "star", "heart", "arrow-right", "arrow-up-right", "chevron-right", "calendar", "clock", "map-pin", "plane", "truck", "credit-card", "user", "search", "bell"];
|
|
36
36
|
/** A name from the built-in icon set; the closed enum lets the model see exactly which icons exist. */
|
|
37
|
-
type IconName = (typeof ICON_NAMES)[number];
|
|
37
|
+
export type IconName = (typeof ICON_NAMES)[number];
|
|
38
38
|
/**
|
|
39
39
|
* Behavior payload carried by an interactive node. `type` is resolved by the host's action registry, not the renderer; keeping behavior as data keeps the tree serializable, so the same node renders on web while converters may bind the type to a native action id on other platforms.
|
|
40
40
|
*/
|
|
41
|
-
interface Action {
|
|
41
|
+
export interface Action {
|
|
42
42
|
readonly type: string;
|
|
43
43
|
readonly [payload: string]: unknown;
|
|
44
44
|
}
|
|
@@ -48,12 +48,12 @@ interface Action {
|
|
|
48
48
|
* input boundary (numbers render as text, falsy/boolean as nothing, arrays as
|
|
49
49
|
* lists); {@link normalizeUINode} accepts that full range.
|
|
50
50
|
*/
|
|
51
|
-
type UINode = string | number | UIElement | LegacyComponentNode;
|
|
52
|
-
type UIChildren = UINode | readonly UINode[];
|
|
51
|
+
export type UINode = string | number | UIElement | LegacyComponentNode;
|
|
52
|
+
export type UIChildren = UINode | readonly UINode[];
|
|
53
53
|
/** The flat node shape: inline props keep the tree compact and natural for a
|
|
54
54
|
* model to emit, instead of a nested `{ type, props }` bag. Reserved keys are
|
|
55
55
|
* stripped before props reach the component (see the module header). */
|
|
56
|
-
interface UIElement {
|
|
56
|
+
export interface UIElement {
|
|
57
57
|
readonly $type: string;
|
|
58
58
|
readonly $key?: string | number;
|
|
59
59
|
readonly children?: UIChildren;
|
|
@@ -65,13 +65,13 @@ interface UIElement {
|
|
|
65
65
|
* for backward compatibility. New code authors the flat {@link UIElement}
|
|
66
66
|
* shape instead.
|
|
67
67
|
*/
|
|
68
|
-
interface LegacyComponentNode {
|
|
68
|
+
export interface LegacyComponentNode {
|
|
69
69
|
readonly component: string;
|
|
70
70
|
readonly props?: Record<string, unknown>;
|
|
71
71
|
readonly children?: UIChildren;
|
|
72
72
|
readonly key?: string;
|
|
73
73
|
}
|
|
74
|
-
type UISpec = UINode | readonly UINode[];
|
|
74
|
+
export type UISpec = UINode | readonly UINode[];
|
|
75
75
|
/**
|
|
76
76
|
* A node normalized to a single canonical shape: a `type` string, an inline
|
|
77
77
|
* `props` bag, recursive `children`, an optional `key`, and an optional
|
|
@@ -80,14 +80,14 @@ type UISpec = UINode | readonly UINode[];
|
|
|
80
80
|
* `component` shape, and they never see the reserved `$`-prefixed keys leak
|
|
81
81
|
* into component props.
|
|
82
82
|
*/
|
|
83
|
-
interface NormalizedUIElement {
|
|
83
|
+
export interface NormalizedUIElement {
|
|
84
84
|
readonly type: string;
|
|
85
85
|
readonly props: Readonly<Record<string, unknown>>;
|
|
86
86
|
readonly children?: NormalizedUINode | undefined;
|
|
87
87
|
readonly key?: string | number | undefined;
|
|
88
88
|
readonly action?: Action | undefined;
|
|
89
89
|
}
|
|
90
|
-
type NormalizedUINode = string | number | readonly NormalizedUINode[] | NormalizedUIElement | null;
|
|
90
|
+
export type NormalizedUINode = string | number | readonly NormalizedUINode[] | NormalizedUIElement | null;
|
|
91
91
|
/**
|
|
92
92
|
* Normalizes a generative-ui input to {@link NormalizedUINode}. The flat
|
|
93
93
|
* `$type` shape and the legacy `component` shape both map to the same canonical
|
|
@@ -102,14 +102,13 @@ type NormalizedUINode = string | number | readonly NormalizedUINode[] | Normaliz
|
|
|
102
102
|
* node is held back while completed siblings render. Omit it for a
|
|
103
103
|
* non-streaming (converter) normalize.
|
|
104
104
|
*/
|
|
105
|
-
declare function normalizeUINode(node: unknown, partialPath?: readonly string[] | undefined, depth?: number): NormalizedUINode;
|
|
105
|
+
export declare function normalizeUINode(node: unknown, partialPath?: readonly string[] | undefined, depth?: number): NormalizedUINode;
|
|
106
106
|
/**
|
|
107
107
|
* Normalizes the root of a {@link UISpec}, preserving whether the root was a
|
|
108
108
|
* single node or a list.
|
|
109
109
|
*/
|
|
110
|
-
declare function normalizeSpec(spec: UISpec): {
|
|
110
|
+
export declare function normalizeSpec(spec: UISpec): {
|
|
111
111
|
readonly root: NormalizedUINode | readonly NormalizedUINode[];
|
|
112
112
|
};
|
|
113
113
|
//#endregion
|
|
114
|
-
export { ALERT_TONES, ALIGNS, Action, AlertTone, Align, BUTTON_STYLES, ButtonStyle, COLORS, Color, ICON_NAMES, IMAGE_SIZE_TOKENS, IconName, ImageSize, JUSTIFIES, Justify, LegacyComponentNode, NormalizedUIElement, NormalizedUINode, TEXT_SIZES, TextSize, UIChildren, UIElement, UINode, UISpec, WEIGHTS, Weight, normalizeSpec, normalizeUINode };
|
|
115
114
|
//# sourceMappingURL=ir.d.ts.map
|
package/dist/ir.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ir.d.ts","names":[],"sources":["../src/ir.ts"],"mappings":";;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"ir.d.ts","names":[],"sources":["../src/ir.ts"],"mappings":";;;;;;;;;;;;;;;;;qBAmBa;YACD,mBAAmB;qBAElB;YACD,oBAAoB;qBAEnB;YACD,iBAAiB;qBAEhB;YAQD,gBAAgB;qBAEf;YACD,gBAAgB;qBAEf;YACD,kBAAkB;qBAEjB;YAOD,sBAAsB;qBAErB;;YAED,oBAAoB;qBAEnB;;YA2BD,mBAAmB;;;;iBAKd;WACN;YACC;;;;;;;;YASA,2BAA2B,YAAY;YAEvC,aAAa,kBAAkB;;;;iBAK1B;WACN;WACA;WACA,WAAW;WACX,UAAU;YACT;;;;;;;iBAQK;WACN;WACA,QAAQ;WACR,WAAW;WACX;;YAGC,SAAS,kBAAkB;;;;;;;;;iBAUtB;WACN;WACA,OAAO,SAAS;WAChB,WAAW;WACX;WACA,SAAS;;YAGR,8CAGC,qBACT;;;;;;;;;;;;;;;wBA6CY,gBACd,eACA,6CACA,iBACC;;;;;wBAuEa,cAAc,MAAM;WACzB,MAAM,4BAA4B"}
|
|
@@ -11,7 +11,6 @@ import { ReactNode } from "react";
|
|
|
11
11
|
* `render(props, context)`, with `children` rendered recursively so components
|
|
12
12
|
* can nest.
|
|
13
13
|
*/
|
|
14
|
-
declare function renderGenerativeUI(node: unknown, library: GenerativeUILibrary, context?: GenerativeUIRenderContext): ReactNode;
|
|
14
|
+
export declare function renderGenerativeUI(node: unknown, library: GenerativeUILibrary, context?: GenerativeUIRenderContext): ReactNode;
|
|
15
15
|
//#endregion
|
|
16
|
-
export { renderGenerativeUI };
|
|
17
16
|
//# sourceMappingURL=renderGenerativeUI.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderGenerativeUI.d.ts","names":[],"sources":["../src/renderGenerativeUI.tsx"],"mappings":";;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"renderGenerativeUI.d.ts","names":[],"sources":["../src/renderGenerativeUI.tsx"],"mappings":";;;;;;;;;;;;;wBAwBgB,mBACd,eACA,SAAS,qBACT,UAAS,4BACR"}
|
|
@@ -27,7 +27,7 @@ function renderNode(node, library, context) {
|
|
|
27
27
|
return isElement(node) ? renderElement(node, library, context) : null;
|
|
28
28
|
}
|
|
29
29
|
function renderElement(element, library, context) {
|
|
30
|
-
const entry = library[element.type];
|
|
30
|
+
const entry = Object.hasOwn(library, element.type) ? library[element.type] : void 0;
|
|
31
31
|
if (!entry) {
|
|
32
32
|
reportUnknownComponent(element.type, Object.keys(library));
|
|
33
33
|
return null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderGenerativeUI.js","names":[],"sources":["../src/renderGenerativeUI.tsx"],"sourcesContent":["import { getPartialJsonObjectMeta } from \"assistant-stream/utils\";\nimport { Fragment, type ReactNode } from \"react\";\nimport {\n normalizeUINode,\n type NormalizedUIElement,\n type NormalizedUINode,\n} from \"./ir\";\nimport type { GenerativeUILibrary, GenerativeUIRenderContext } from \"./types\";\n\nconst DEFAULT_CONTEXT: GenerativeUIRenderContext = { status: \"done\" };\n\nconst isElement = (node: NormalizedUINode): node is NormalizedUIElement =>\n typeof node === \"object\" && node !== null && !Array.isArray(node);\n\n/**\n * Renders a generative-ui tree against a {@link GenerativeUILibrary}.\n *\n * The model emits each node as a flat object `{ $type, ...props }`. We first\n * normalize that wire form into the canonical {@link NormalizedUINode} (with\n * `children` lifted to a reserved top-level key), then render: each `type` is\n * looked up in the library and its `props` are passed to the component's\n * `render(props, context)`, with `children` rendered recursively so components\n * can nest.\n */\nexport function renderGenerativeUI(\n node: unknown,\n library: GenerativeUILibrary,\n context: GenerativeUIRenderContext = DEFAULT_CONTEXT,\n): ReactNode {\n // Tool args are parsed incrementally, and the parse meta records which path\n // is still mid-arrival, so normalization can hold back a node whose `$type`\n // string has not finished streaming.\n const meta = getPartialJsonObjectMeta(node as Record<symbol, unknown>);\n const partialPath = meta?.state === \"partial\" ? meta.partialPath : undefined;\n return renderNode(normalizeUINode(node, partialPath), library, context);\n}\n\nfunction renderNode(\n node: NormalizedUINode,\n library: GenerativeUILibrary,\n context: GenerativeUIRenderContext,\n): ReactNode {\n if (node == null || typeof node === \"boolean\") return null;\n if (typeof node === \"string\" || typeof node === \"number\") return node;\n if (Array.isArray(node)) {\n // Use a model-provided stable key when present. Otherwise, keep the\n // positional fallback: pairing the index with the node's kind means that\n // when the kind at an index changes, React remounts instead of handing a\n // streaming node's hook state to a different component.\n return node.map((child, index) => (\n <Fragment key={nodeKey(child, index)}>\n {renderNode(child, library, context)}\n </Fragment>\n ));\n }\n return isElement(node) ? renderElement(node, library, context) : null;\n}\n\nfunction renderElement(\n element: NormalizedUIElement,\n library: GenerativeUILibrary,\n context: GenerativeUIRenderContext,\n): ReactNode {\n const entry = library[element.type];\n if (!entry) {\n reportUnknownComponent(element.type, Object.keys(library));\n return null;\n }\n\n // Components that opt out of prop streaming wait until their props are\n // complete rather than rendering from a partial parse.\n if (!entry.streamProperties && context.status === \"streaming\") return null;\n\n // `children` is a reserved top-level key on the normalized element, not a\n // prop, so it is not in `props`. Inject the framework props last so the model\n // can never override them. `$action` is likewise reserved and stripped from\n // the prop bag during normalization, so it is re-injected here for components\n // that carry behavior (e.g. `Button`).\n const props: Record<string, unknown> = {\n ...element.props,\n $status: context.status,\n };\n if (context.dispatch !== undefined) {\n props[\"$dispatch\"] = context.dispatch;\n }\n if (element.action !== undefined) {\n props[\"$action\"] = element.action;\n }\n if (element.children !== undefined) {\n props[\"children\"] = renderNode(element.children, library, context);\n }\n\n return <GenerativeUIComponentRenderer render={entry.render} props={props} />;\n}\n\n/**\n * Mounts a single node's `render` on its own fiber so the function may use\n * hooks and hold state independently of its siblings and parent.\n */\nfunction GenerativeUIComponentRenderer({\n render,\n props,\n}: {\n render: (props: any) => ReactNode;\n props: Record<string, unknown>;\n}): ReactNode {\n return render(props);\n}\n\n/** A coarse kind tag for a child, used in its list key so a node changing kind\n * at a given index forces a remount rather than a wrong-fiber reuse. */\nfunction nodeKind(node: NormalizedUINode): string {\n if (node == null || typeof node === \"boolean\") return \"\";\n if (typeof node === \"string\" || typeof node === \"number\") return \"#text\";\n if (Array.isArray(node)) return \"#array\";\n return isElement(node) ? node.type : \"\";\n}\n\nfunction nodeKey(node: NormalizedUINode, index: number): string {\n return isElement(node) &&\n (typeof node.key === \"string\" || typeof node.key === \"number\")\n ? `model:${node.key}`\n : `${index}:${nodeKind(node)}`;\n}\n\nfunction reportUnknownComponent(type: string, available: string[]): void {\n if (process.env[\"NODE_ENV\"] !== \"production\") {\n // eslint-disable-next-line no-console\n console.error(\n `[@assistant-ui/react-generative-ui] Unknown component \"${type}\". ` +\n `Available components: ${available.join(\", \") || \"(none)\"}.`,\n );\n }\n}\n"],"mappings":";;;;;AASA,MAAM,kBAA6C,EAAE,QAAQ,OAAO;AAEpE,MAAM,aAAa,SACjB,OAAO,SAAS,YAAY,SAAS,QAAQ,CAAC,MAAM,QAAQ,IAAI;;;;;;;;;;;AAYlE,SAAgB,mBACd,MACA,SACA,UAAqC,iBAC1B;CAIX,MAAM,OAAO,yBAAyB,IAA+B;CACrE,MAAM,cAAc,MAAM,UAAU,YAAY,KAAK,cAAc,KAAA;CACnE,OAAO,WAAW,gBAAgB,MAAM,WAAW,GAAG,SAAS,OAAO;AACxE;AAEA,SAAS,WACP,MACA,SACA,SACW;CACX,IAAI,QAAQ,QAAQ,OAAO,SAAS,WAAW,OAAO;CACtD,IAAI,OAAO,SAAS,YAAY,OAAO,SAAS,UAAU,OAAO;CACjE,IAAI,MAAM,QAAQ,IAAI,GAKpB,OAAO,KAAK,KAAK,OAAO,UACtB,oBAAC,UAAD,EAAA,UACG,WAAW,OAAO,SAAS,OAAO,EAC3B,GAFK,QAAQ,OAAO,KAAK,CAEzB,CACX;CAEH,OAAO,UAAU,IAAI,IAAI,cAAc,MAAM,SAAS,OAAO,IAAI;AACnE;AAEA,SAAS,cACP,SACA,SACA,SACW;CACX,MAAM,QAAQ,QAAQ,QAAQ;
|
|
1
|
+
{"version":3,"file":"renderGenerativeUI.js","names":[],"sources":["../src/renderGenerativeUI.tsx"],"sourcesContent":["import { getPartialJsonObjectMeta } from \"assistant-stream/utils\";\nimport { Fragment, type ReactNode } from \"react\";\nimport {\n normalizeUINode,\n type NormalizedUIElement,\n type NormalizedUINode,\n} from \"./ir\";\nimport type { GenerativeUILibrary, GenerativeUIRenderContext } from \"./types\";\n\nconst DEFAULT_CONTEXT: GenerativeUIRenderContext = { status: \"done\" };\n\nconst isElement = (node: NormalizedUINode): node is NormalizedUIElement =>\n typeof node === \"object\" && node !== null && !Array.isArray(node);\n\n/**\n * Renders a generative-ui tree against a {@link GenerativeUILibrary}.\n *\n * The model emits each node as a flat object `{ $type, ...props }`. We first\n * normalize that wire form into the canonical {@link NormalizedUINode} (with\n * `children` lifted to a reserved top-level key), then render: each `type` is\n * looked up in the library and its `props` are passed to the component's\n * `render(props, context)`, with `children` rendered recursively so components\n * can nest.\n */\nexport function renderGenerativeUI(\n node: unknown,\n library: GenerativeUILibrary,\n context: GenerativeUIRenderContext = DEFAULT_CONTEXT,\n): ReactNode {\n // Tool args are parsed incrementally, and the parse meta records which path\n // is still mid-arrival, so normalization can hold back a node whose `$type`\n // string has not finished streaming.\n const meta = getPartialJsonObjectMeta(node as Record<symbol, unknown>);\n const partialPath = meta?.state === \"partial\" ? meta.partialPath : undefined;\n return renderNode(normalizeUINode(node, partialPath), library, context);\n}\n\nfunction renderNode(\n node: NormalizedUINode,\n library: GenerativeUILibrary,\n context: GenerativeUIRenderContext,\n): ReactNode {\n if (node == null || typeof node === \"boolean\") return null;\n if (typeof node === \"string\" || typeof node === \"number\") return node;\n if (Array.isArray(node)) {\n // Use a model-provided stable key when present. Otherwise, keep the\n // positional fallback: pairing the index with the node's kind means that\n // when the kind at an index changes, React remounts instead of handing a\n // streaming node's hook state to a different component.\n return node.map((child, index) => (\n <Fragment key={nodeKey(child, index)}>\n {renderNode(child, library, context)}\n </Fragment>\n ));\n }\n return isElement(node) ? renderElement(node, library, context) : null;\n}\n\nfunction renderElement(\n element: NormalizedUIElement,\n library: GenerativeUILibrary,\n context: GenerativeUIRenderContext,\n): ReactNode {\n const entry = Object.hasOwn(library, element.type)\n ? library[element.type]\n : undefined;\n if (!entry) {\n reportUnknownComponent(element.type, Object.keys(library));\n return null;\n }\n\n // Components that opt out of prop streaming wait until their props are\n // complete rather than rendering from a partial parse.\n if (!entry.streamProperties && context.status === \"streaming\") return null;\n\n // `children` is a reserved top-level key on the normalized element, not a\n // prop, so it is not in `props`. Inject the framework props last so the model\n // can never override them. `$action` is likewise reserved and stripped from\n // the prop bag during normalization, so it is re-injected here for components\n // that carry behavior (e.g. `Button`).\n const props: Record<string, unknown> = {\n ...element.props,\n $status: context.status,\n };\n if (context.dispatch !== undefined) {\n props[\"$dispatch\"] = context.dispatch;\n }\n if (element.action !== undefined) {\n props[\"$action\"] = element.action;\n }\n if (element.children !== undefined) {\n props[\"children\"] = renderNode(element.children, library, context);\n }\n\n return <GenerativeUIComponentRenderer render={entry.render} props={props} />;\n}\n\n/**\n * Mounts a single node's `render` on its own fiber so the function may use\n * hooks and hold state independently of its siblings and parent.\n */\nfunction GenerativeUIComponentRenderer({\n render,\n props,\n}: {\n render: (props: any) => ReactNode;\n props: Record<string, unknown>;\n}): ReactNode {\n return render(props);\n}\n\n/** A coarse kind tag for a child, used in its list key so a node changing kind\n * at a given index forces a remount rather than a wrong-fiber reuse. */\nfunction nodeKind(node: NormalizedUINode): string {\n if (node == null || typeof node === \"boolean\") return \"\";\n if (typeof node === \"string\" || typeof node === \"number\") return \"#text\";\n if (Array.isArray(node)) return \"#array\";\n return isElement(node) ? node.type : \"\";\n}\n\nfunction nodeKey(node: NormalizedUINode, index: number): string {\n return isElement(node) &&\n (typeof node.key === \"string\" || typeof node.key === \"number\")\n ? `model:${node.key}`\n : `${index}:${nodeKind(node)}`;\n}\n\nfunction reportUnknownComponent(type: string, available: string[]): void {\n if (process.env[\"NODE_ENV\"] !== \"production\") {\n // eslint-disable-next-line no-console\n console.error(\n `[@assistant-ui/react-generative-ui] Unknown component \"${type}\". ` +\n `Available components: ${available.join(\", \") || \"(none)\"}.`,\n );\n }\n}\n"],"mappings":";;;;;AASA,MAAM,kBAA6C,EAAE,QAAQ,OAAO;AAEpE,MAAM,aAAa,SACjB,OAAO,SAAS,YAAY,SAAS,QAAQ,CAAC,MAAM,QAAQ,IAAI;;;;;;;;;;;AAYlE,SAAgB,mBACd,MACA,SACA,UAAqC,iBAC1B;CAIX,MAAM,OAAO,yBAAyB,IAA+B;CACrE,MAAM,cAAc,MAAM,UAAU,YAAY,KAAK,cAAc,KAAA;CACnE,OAAO,WAAW,gBAAgB,MAAM,WAAW,GAAG,SAAS,OAAO;AACxE;AAEA,SAAS,WACP,MACA,SACA,SACW;CACX,IAAI,QAAQ,QAAQ,OAAO,SAAS,WAAW,OAAO;CACtD,IAAI,OAAO,SAAS,YAAY,OAAO,SAAS,UAAU,OAAO;CACjE,IAAI,MAAM,QAAQ,IAAI,GAKpB,OAAO,KAAK,KAAK,OAAO,UACtB,oBAAC,UAAD,EAAA,UACG,WAAW,OAAO,SAAS,OAAO,EAC3B,GAFK,QAAQ,OAAO,KAAK,CAEzB,CACX;CAEH,OAAO,UAAU,IAAI,IAAI,cAAc,MAAM,SAAS,OAAO,IAAI;AACnE;AAEA,SAAS,cACP,SACA,SACA,SACW;CACX,MAAM,QAAQ,OAAO,OAAO,SAAS,QAAQ,IAAI,IAC7C,QAAQ,QAAQ,QAChB,KAAA;CACJ,IAAI,CAAC,OAAO;EACV,uBAAuB,QAAQ,MAAM,OAAO,KAAK,OAAO,CAAC;EACzD,OAAO;CACT;CAIA,IAAI,CAAC,MAAM,oBAAoB,QAAQ,WAAW,aAAa,OAAO;CAOtE,MAAM,QAAiC;EACrC,GAAG,QAAQ;EACX,SAAS,QAAQ;CACnB;CACA,IAAI,QAAQ,aAAa,KAAA,GACvB,MAAM,eAAe,QAAQ;CAE/B,IAAI,QAAQ,WAAW,KAAA,GACrB,MAAM,aAAa,QAAQ;CAE7B,IAAI,QAAQ,aAAa,KAAA,GACvB,MAAM,cAAc,WAAW,QAAQ,UAAU,SAAS,OAAO;CAGnE,OAAO,oBAAC,+BAAD;EAA+B,QAAQ,MAAM;EAAe;CAAQ,CAAA;AAC7E;;;;;AAMA,SAAS,8BAA8B,EACrC,QACA,SAIY;CACZ,OAAO,OAAO,KAAK;AACrB;;;AAIA,SAAS,SAAS,MAAgC;CAChD,IAAI,QAAQ,QAAQ,OAAO,SAAS,WAAW,OAAO;CACtD,IAAI,OAAO,SAAS,YAAY,OAAO,SAAS,UAAU,OAAO;CACjE,IAAI,MAAM,QAAQ,IAAI,GAAG,OAAO;CAChC,OAAO,UAAU,IAAI,IAAI,KAAK,OAAO;AACvC;AAEA,SAAS,QAAQ,MAAwB,OAAuB;CAC9D,OAAO,UAAU,IAAI,MAClB,OAAO,KAAK,QAAQ,YAAY,OAAO,KAAK,QAAQ,YACnD,SAAS,KAAK,QACd,GAAG,MAAM,GAAG,SAAS,IAAI;AAC/B;AAEA,SAAS,uBAAuB,MAAc,WAA2B;CACvE,IAAI,QAAQ,IAAI,gBAAgB,cAE9B,QAAQ,MACN,0DAA0D,KAAK,2BACpC,UAAU,KAAK,IAAI,KAAK,SAAS,EAC9D;AAEJ"}
|
|
@@ -1,77 +1,77 @@
|
|
|
1
1
|
import { SlackAlertBlock, SlackButtonElement, SlackCardBlock, SlackCarouselBlock, SlackContextBlock, SlackDataTableBlock, SlackDataTableCell, SlackImageBlock, SlackSectionBlock, SlackTextObject } from "./types.js";
|
|
2
2
|
//#region src/slack/constants.d.ts
|
|
3
3
|
/** The block limit for a Slack message. */
|
|
4
|
-
declare const MESSAGE_BLOCK_CAP = 50;
|
|
4
|
+
export declare const MESSAGE_BLOCK_CAP = 50;
|
|
5
5
|
/** The block limit for a Slack modal. */
|
|
6
|
-
declare const MODAL_BLOCK_CAP = 100;
|
|
6
|
+
export declare const MODAL_BLOCK_CAP = 100;
|
|
7
7
|
/**
|
|
8
8
|
* The maximum number of top-level blocks accepted when parsing Slack Block
|
|
9
9
|
* Kit JSON back into generative UI, guarding against a hostile or malformed
|
|
10
10
|
* payload.
|
|
11
11
|
*/
|
|
12
|
-
declare const INBOUND_BLOCK_CAP = 200;
|
|
12
|
+
export declare const INBOUND_BLOCK_CAP = 200;
|
|
13
13
|
/** The character limit for header text. */
|
|
14
|
-
declare const HEADER_TEXT_CAP = 150;
|
|
14
|
+
export declare const HEADER_TEXT_CAP = 150;
|
|
15
15
|
/** The character limit for section text. */
|
|
16
|
-
declare const SECTION_TEXT_CAP = 3000;
|
|
16
|
+
export declare const SECTION_TEXT_CAP = 3000;
|
|
17
17
|
/** The maximum number of fields in one section. */
|
|
18
|
-
declare const FACT_FIELD_CAP = 10;
|
|
18
|
+
export declare const FACT_FIELD_CAP = 10;
|
|
19
19
|
/** The character limit for one section field. */
|
|
20
|
-
declare const FACT_FIELD_TEXT_CAP = 2000;
|
|
20
|
+
export declare const FACT_FIELD_TEXT_CAP = 2000;
|
|
21
21
|
/** The character limit for button labels and option labels. */
|
|
22
|
-
declare const INTERACTIVE_TEXT_CAP = 75;
|
|
22
|
+
export declare const INTERACTIVE_TEXT_CAP = 75;
|
|
23
23
|
/** The character limit for an action_id. */
|
|
24
|
-
declare const ACTION_ID_CAP = 255;
|
|
24
|
+
export declare const ACTION_ID_CAP = 255;
|
|
25
25
|
/** The character limit for a button's serialized value payload. */
|
|
26
|
-
declare const BUTTON_VALUE_CAP = 2000;
|
|
26
|
+
export declare const BUTTON_VALUE_CAP = 2000;
|
|
27
27
|
/** The maximum number of elements in one actions block. */
|
|
28
|
-
declare const ACTIONS_ELEMENT_CAP = 25;
|
|
28
|
+
export declare const ACTIONS_ELEMENT_CAP = 25;
|
|
29
29
|
/** The maximum number of options in a static select. */
|
|
30
|
-
declare const SELECT_OPTION_CAP = 100;
|
|
30
|
+
export declare const SELECT_OPTION_CAP = 100;
|
|
31
31
|
/** The maximum number of options in a radio-button group. */
|
|
32
|
-
declare const RADIO_OPTION_CAP = 10;
|
|
32
|
+
export declare const RADIO_OPTION_CAP = 10;
|
|
33
33
|
/** The character limit for a select or input placeholder. */
|
|
34
|
-
declare const PLACEHOLDER_TEXT_CAP = 150;
|
|
34
|
+
export declare const PLACEHOLDER_TEXT_CAP = 150;
|
|
35
35
|
/** The character limit for an input's label. */
|
|
36
|
-
declare const INPUT_LABEL_CAP = 2000;
|
|
36
|
+
export declare const INPUT_LABEL_CAP = 2000;
|
|
37
37
|
/** The maximum number of elements in one context block. */
|
|
38
|
-
declare const CONTEXT_ELEMENT_CAP = 10;
|
|
38
|
+
export declare const CONTEXT_ELEMENT_CAP = 10;
|
|
39
39
|
/** The character limit for one context element's text. */
|
|
40
|
-
declare const CONTEXT_TEXT_CAP = 3000;
|
|
40
|
+
export declare const CONTEXT_TEXT_CAP = 3000;
|
|
41
41
|
/** The character limit for card titles and subtitles. */
|
|
42
|
-
declare const CARD_TITLE_CAP = 150;
|
|
42
|
+
export declare const CARD_TITLE_CAP = 150;
|
|
43
43
|
/** The character limit for a card's body text. */
|
|
44
|
-
declare const CARD_BODY_CAP = 200;
|
|
44
|
+
export declare const CARD_BODY_CAP = 200;
|
|
45
45
|
/** The character limit for a card's subtext. */
|
|
46
|
-
declare const CARD_SUBTEXT_CAP = 200;
|
|
46
|
+
export declare const CARD_SUBTEXT_CAP = 200;
|
|
47
47
|
/** The maximum number of buttons in a card's actions. */
|
|
48
|
-
declare const CARD_ACTIONS_CAP = 3;
|
|
48
|
+
export declare const CARD_ACTIONS_CAP = 3;
|
|
49
49
|
/** The minimum number of elements in a renderable carousel. */
|
|
50
|
-
declare const CAROUSEL_CARD_MIN = 1;
|
|
50
|
+
export declare const CAROUSEL_CARD_MIN = 1;
|
|
51
51
|
/** The maximum number of elements in a carousel. */
|
|
52
|
-
declare const CAROUSEL_CARD_CAP = 10;
|
|
52
|
+
export declare const CAROUSEL_CARD_CAP = 10;
|
|
53
53
|
/** The character limit for an alert's text. */
|
|
54
|
-
declare const ALERT_TEXT_CAP = 200;
|
|
54
|
+
export declare const ALERT_TEXT_CAP = 200;
|
|
55
55
|
/**
|
|
56
56
|
* The maximum number of data rows in a data-table block; the emitted `rows`
|
|
57
57
|
* array additionally carries one header row.
|
|
58
58
|
*/
|
|
59
|
-
declare const DATA_TABLE_ROW_CAP = 200;
|
|
59
|
+
export declare const DATA_TABLE_ROW_CAP = 200;
|
|
60
60
|
/** The maximum number of columns in a data-table block. */
|
|
61
|
-
declare const DATA_TABLE_COLUMN_CAP = 20;
|
|
61
|
+
export declare const DATA_TABLE_COLUMN_CAP = 20;
|
|
62
62
|
/**
|
|
63
63
|
* The cumulative character limit (summed across every cell's text) shared by
|
|
64
64
|
* every data-table block in one payload.
|
|
65
65
|
*/
|
|
66
|
-
declare const DATA_TABLE_CHAR_BUDGET = 20000;
|
|
66
|
+
export declare const DATA_TABLE_CHAR_BUDGET = 20000;
|
|
67
67
|
/** The caption emitted on every native data-table block. */
|
|
68
|
-
declare const TABLE_CAPTION = "Table";
|
|
68
|
+
export declare const TABLE_CAPTION = "Table";
|
|
69
69
|
/** The cumulative character limit for native markdown blocks. */
|
|
70
|
-
declare const MARKDOWN_TEXT_BUDGET = 12000;
|
|
70
|
+
export declare const MARKDOWN_TEXT_BUDGET = 12000;
|
|
71
71
|
/** Builds the message-surface fallback for an alert. */
|
|
72
|
-
declare function buildAlertFallback(title: string, description: string, tone: "info" | "success" | "warning" | "danger"): readonly [SlackContextBlock, SlackSectionBlock];
|
|
72
|
+
export declare function buildAlertFallback(title: string, description: string, tone: "info" | "success" | "warning" | "danger"): readonly [SlackContextBlock, SlackSectionBlock];
|
|
73
73
|
/** Builds a 2026 Slack modal-only alert block, mapping `tone` to its `level`. */
|
|
74
|
-
declare function buildAlertBlock(text: string, tone: "info" | "success" | "warning" | "danger"): SlackAlertBlock;
|
|
74
|
+
export declare function buildAlertBlock(text: string, tone: "info" | "success" | "warning" | "danger"): SlackAlertBlock;
|
|
75
75
|
type CardBlockFields = {
|
|
76
76
|
readonly heroImage?: SlackImageBlock;
|
|
77
77
|
readonly title?: SlackTextObject;
|
|
@@ -81,13 +81,12 @@ type CardBlockFields = {
|
|
|
81
81
|
readonly actions?: readonly SlackButtonElement[];
|
|
82
82
|
};
|
|
83
83
|
/** Builds a 2026 Slack card block from its already-clamped fields. */
|
|
84
|
-
declare function buildCardBlock(fields: CardBlockFields): SlackCardBlock;
|
|
84
|
+
export declare function buildCardBlock(fields: CardBlockFields): SlackCardBlock;
|
|
85
85
|
/** Builds a 2026 Slack carousel block. */
|
|
86
|
-
declare function buildCarouselBlock(elements: readonly SlackCardBlock[]): SlackCarouselBlock;
|
|
86
|
+
export declare function buildCarouselBlock(elements: readonly SlackCardBlock[]): SlackCarouselBlock;
|
|
87
87
|
/** Builds a 2026 Slack data-table block; `rows[0]` must be the header row. */
|
|
88
|
-
declare function buildDataTableBlock(rows: readonly (readonly SlackDataTableCell[])[]): SlackDataTableBlock;
|
|
88
|
+
export declare function buildDataTableBlock(rows: readonly (readonly SlackDataTableCell[])[]): SlackDataTableBlock;
|
|
89
89
|
/** Builds the final note used when a surface block budget is exceeded. */
|
|
90
|
-
declare function buildBlockBudgetNote(omitted: number): SlackContextBlock;
|
|
90
|
+
export declare function buildBlockBudgetNote(omitted: number): SlackContextBlock;
|
|
91
91
|
//#endregion
|
|
92
|
-
export { ACTIONS_ELEMENT_CAP, ACTION_ID_CAP, ALERT_TEXT_CAP, BUTTON_VALUE_CAP, CARD_ACTIONS_CAP, CARD_BODY_CAP, CARD_SUBTEXT_CAP, CARD_TITLE_CAP, CAROUSEL_CARD_CAP, CAROUSEL_CARD_MIN, CONTEXT_ELEMENT_CAP, CONTEXT_TEXT_CAP, DATA_TABLE_CHAR_BUDGET, DATA_TABLE_COLUMN_CAP, DATA_TABLE_ROW_CAP, FACT_FIELD_CAP, FACT_FIELD_TEXT_CAP, HEADER_TEXT_CAP, INBOUND_BLOCK_CAP, INPUT_LABEL_CAP, INTERACTIVE_TEXT_CAP, MARKDOWN_TEXT_BUDGET, MESSAGE_BLOCK_CAP, MODAL_BLOCK_CAP, PLACEHOLDER_TEXT_CAP, RADIO_OPTION_CAP, SECTION_TEXT_CAP, SELECT_OPTION_CAP, TABLE_CAPTION, buildAlertBlock, buildAlertFallback, buildBlockBudgetNote, buildCardBlock, buildCarouselBlock, buildDataTableBlock };
|
|
93
92
|
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","names":[],"sources":["../../src/slack/constants.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"constants.d.ts","names":[],"sources":["../../src/slack/constants.ts"],"mappings":";;;qBAca;;qBAGA;;;;;;qBAOA;;qBAGA;;qBAGA;;qBAGA;;qBAGA;;qBAGA;;qBAGA;;qBAGA;;qBAGA;;qBAGA;;qBAGA;;qBAGA;;qBAGA;;qBAGA;;qBAGA;;qBAGA;;qBAGA;;qBAGA;;qBAGA;;qBAGA;;qBAGA;;qBAGA;;;;;qBAMA;;qBAGA;;;;;qBAMA;;qBAGA;;qBAGA;;wBAGG,mBACd,eACA,qBACA,4DACW,mBAAmB;;wBAmBhB,gBACd,cACA,kDACC;KAKE;WACM,YAAY;WACZ,QAAQ;WACR,WAAW;WACX,OAAO;WACP,UAAU;WACV,mBAAmB;;;wBAId,eAAe,QAAQ,kBAAkB;;wBAczC,mBACd,mBAAmB,mBAClB;;wBAKa,oBACd,yBAAyB,0BACxB;;wBAKa,qBAAqB,kBAAkB"}
|
|
@@ -5,7 +5,6 @@ import { Action } from "../ir.js";
|
|
|
5
5
|
* `$input` is reserved for the runtime selection: a `$input` key inside the
|
|
6
6
|
* button's JSON `value` payload is dropped rather than spread into the result.
|
|
7
7
|
*/
|
|
8
|
-
declare function decodeBlockAction(action: unknown): Action | undefined;
|
|
8
|
+
export declare function decodeBlockAction(action: unknown): Action | undefined;
|
|
9
9
|
//#endregion
|
|
10
|
-
export { decodeBlockAction };
|
|
11
10
|
//# sourceMappingURL=decodeBlockAction.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decodeBlockAction.d.ts","names":[],"sources":["../../src/slack/decodeBlockAction.ts"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"decodeBlockAction.d.ts","names":[],"sources":["../../src/slack/decodeBlockAction.ts"],"mappings":";;;;;;;wBAegB,kBAAkB,kBAAkB"}
|
|
@@ -24,7 +24,6 @@ import { FromSlackBlocksResult } from "./types.js";
|
|
|
24
24
|
* string, even when its text is the stringified form of a boolean, since the
|
|
25
25
|
* Slack shape does not distinguish a boolean from ordinary text.
|
|
26
26
|
*/
|
|
27
|
-
declare function fromSlackBlocks(blocks: unknown): FromSlackBlocksResult;
|
|
27
|
+
export declare function fromSlackBlocks(blocks: unknown): FromSlackBlocksResult;
|
|
28
28
|
//#endregion
|
|
29
|
-
export { fromSlackBlocks };
|
|
30
29
|
//# sourceMappingURL=fromSlackBlocks.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fromSlackBlocks.d.ts","names":[],"sources":["../../src/slack/fromSlackBlocks.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"fromSlackBlocks.d.ts","names":[],"sources":["../../src/slack/fromSlackBlocks.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;wBA+pBgB,gBAAgB,kBAAkB"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { SlackBlocksResult, ToSlackBlocksOptions } from "./types.js";
|
|
2
2
|
//#region src/slack/toSlackBlocks.d.ts
|
|
3
3
|
/** Converts a generative-UI tree into Slack Block Kit JSON and downgrade warnings. */
|
|
4
|
-
declare function toSlackBlocks(node: unknown, options?: ToSlackBlocksOptions): SlackBlocksResult;
|
|
4
|
+
export declare function toSlackBlocks(node: unknown, options?: ToSlackBlocksOptions): SlackBlocksResult;
|
|
5
5
|
//#endregion
|
|
6
|
-
export { toSlackBlocks };
|
|
7
6
|
//# sourceMappingURL=toSlackBlocks.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toSlackBlocks.d.ts","names":[],"sources":["../../src/slack/toSlackBlocks.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"toSlackBlocks.d.ts","names":[],"sources":["../../src/slack/toSlackBlocks.ts"],"mappings":";;;wBAqzCgB,cACd,eACA,UAAU,uBACT"}
|