@opentiny/genui-sdk-vue 1.3.2-alpha.1 → 1.4.0-alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/README.md +11 -2
  2. package/dist/ConfigProvider-D6LFAgg5.js +131 -0
  3. package/dist/ConfigProvider-D6LFAgg5.js.map +1 -0
  4. package/dist/GenuiRenderer-f2_6u1TA.js +141 -0
  5. package/dist/GenuiRenderer-f2_6u1TA.js.map +1 -0
  6. package/dist/chat.d.ts +6 -0
  7. package/dist/chat.js +17 -15
  8. package/dist/chat.js.map +1 -1
  9. package/dist/chat.types-DEDNSs5o.js +1817 -0
  10. package/dist/chat.types-DEDNSs5o.js.map +1 -0
  11. package/dist/code-generator.d.ts +139 -0
  12. package/dist/code-generator.js +6 -0
  13. package/dist/code-generator.js.map +1 -0
  14. package/dist/config-provider.d.ts +24 -12
  15. package/dist/config-provider.js +5 -5
  16. package/dist/index.d.ts +1101 -691
  17. package/dist/index.js +39 -31
  18. package/dist/index.js.map +1 -1
  19. package/dist/{GenuiRenderer-B22XV3Mr.js → injection-tokens-DDgspg4x.js} +3224 -3269
  20. package/dist/injection-tokens-DDgspg4x.js.map +1 -0
  21. package/dist/legacy-chat.d.ts +789 -534
  22. package/dist/legacy-chat.js +63 -19
  23. package/dist/legacy-chat.js.map +1 -1
  24. package/dist/legacy-config-provider.d.ts +58 -0
  25. package/dist/legacy-config-provider.js +25 -0
  26. package/dist/legacy-config-provider.js.map +1 -0
  27. package/dist/legacy-renderer.d.ts +28 -20
  28. package/dist/legacy-renderer.js +38 -4
  29. package/dist/legacy-renderer.js.map +1 -1
  30. package/dist/renderer.d.ts +4 -16
  31. package/dist/renderer.js +1 -1
  32. package/dist/transform-jsx.d.ts +2 -3
  33. package/dist/transform-jsx.js +14044 -14019
  34. package/dist/transform-jsx.js.map +1 -1
  35. package/dist/vue-code-generator-CwPQ3GDh.js +573 -0
  36. package/dist/vue-code-generator-CwPQ3GDh.js.map +1 -0
  37. package/package.json +18 -7
  38. package/dist/ConfigProvider-BzxW9L3f.js +0 -95
  39. package/dist/ConfigProvider-BzxW9L3f.js.map +0 -1
  40. package/dist/GenuiChatWithMaterials.vue_vue_type_script_setup_true_lang-oky3QRk7.js +0 -49
  41. package/dist/GenuiChatWithMaterials.vue_vue_type_script_setup_true_lang-oky3QRk7.js.map +0 -1
  42. package/dist/GenuiRenderer-B22XV3Mr.js.map +0 -1
  43. package/dist/GenuiRendererWithMaterials.vue_vue_type_script_setup_true_lang-sYP74-5X.js +0 -39
  44. package/dist/GenuiRendererWithMaterials.vue_vue_type_script_setup_true_lang-sYP74-5X.js.map +0 -1
  45. package/dist/chat.types-CIkLm6Gm.js +0 -1794
  46. package/dist/chat.types-CIkLm6Gm.js.map +0 -1
  47. package/dist/injection-tokens-CuDQs1ne.js +0 -114
  48. package/dist/injection-tokens-CuDQs1ne.js.map +0 -1
package/README.md CHANGED
@@ -33,13 +33,22 @@ import { materials } from '@opentiny/genui-sdk-materials-vue-opentiny-vue/materi
33
33
  </template>
34
34
  ```
35
35
 
36
+ Import by feature via subpaths (`/chat`, `/renderer`, `/config-provider`, `/code-generator`) to avoid unused modules:
37
+
38
+ ```ts
39
+ import { generateCode } from '@opentiny/genui-sdk-vue/code-generator';
40
+ ```
41
+
36
42
  ## Documentation
37
43
 
38
44
  * [quick-start](https://docs.opentiny.design/genui-sdk/guide/quick-start)
39
- * [start-with-render](https://docs.opentiny.design/genui-sdk/guide/start-with-renderer)
45
+ * [start-with-renderer](https://docs.opentiny.design/genui-sdk/guide/start-with-renderer)
40
46
 
41
47
  ## API
42
48
 
43
- * [GenuiRender](https://docs.opentiny.design/genui-sdk/components/renderer)
49
+ * [GenuiRenderer](https://docs.opentiny.design/genui-sdk/components/renderer)
44
50
  * [GenuiChat](https://docs.opentiny.design/genui-sdk/components/chat)
45
51
  * [GenuiConfigProvider](https://docs.opentiny.design/genui-sdk/components/config-provider)
52
+ * [generateCode](https://docs.opentiny.design/genui-sdk/components/code-generator)
53
+ * [Vue OpenTiny Vue materials](https://docs.opentiny.design/genui-sdk/components/materials/vue-opentiny-vue)
54
+ * [Vue Element Plus materials](https://docs.opentiny.design/genui-sdk/components/materials/vue-element-plus)
@@ -0,0 +1,131 @@
1
+ (function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode(".tg-config-provider[data-v-7d5e1407]{--tr-sender-bg-color: var(--tr-container-bg-default);--tr-sender-text-color: var(--tr-text-primary);--tr-sender-action-buttons-icon-color: var(--tr-text-secondary);--tr-sender-action-buttons-send-bg-color: var(--tr-color-primary);height:100%}")),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})();
2
+ import { ref as N, readonly as L, defineComponent as I, provide as u, computed as m, watch as h, inject as z, h as O, shallowRef as Q, onBeforeUnmount as q, createElementBlock as W, openBlock as D, createVNode as k, unref as E, normalizeProps as H, guardReactiveProps as J, withCtx as C, renderSlot as K } from "vue";
3
+ import { ThemeProvider as X } from "@opentiny/tiny-robot";
4
+ import { G as Y, u as Z, a as V, b as ee, $ as G, _ as te } from "./injection-tokens-DDgspg4x.js";
5
+ const P = () => typeof window < "u" && window.matchMedia, R = () => P() && window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light", A = N(R());
6
+ let v = null;
7
+ const oe = () => {
8
+ A.value = R();
9
+ }, re = () => {
10
+ P() && !v && (v = window.matchMedia("(prefers-color-scheme: dark)"), v.addEventListener("change", oe));
11
+ }, ne = () => (re(), {
12
+ theme: L(A)
13
+ }), ae = ["id"], ie = /* @__PURE__ */ I({
14
+ __name: "ConfigProvider",
15
+ props: {
16
+ theme: {},
17
+ id: { default: "tiny-genui-config-provider" },
18
+ locale: { default: "zh_CN" },
19
+ i18n: {},
20
+ materials: {},
21
+ notify: {}
22
+ },
23
+ setup(S) {
24
+ const o = S, i = Z();
25
+ u(Y, i);
26
+ const { theme: b } = ne(), x = m(() => {
27
+ var e;
28
+ const t = (e = o.materials) == null ? void 0 : e.themeFactory;
29
+ return t ? Array.isArray(t) ? t : [t] : [];
30
+ }), a = /* @__PURE__ */ new Map();
31
+ function F(t) {
32
+ for (const e of a.keys())
33
+ t.includes(e) || a.delete(e);
34
+ return t.map((e) => {
35
+ let r = a.get(e);
36
+ return r || (r = e(), a.set(e, r)), r;
37
+ });
38
+ }
39
+ const U = m(() => o.theme || "light"), f = N("light"), $ = m(() => ({
40
+ colorScheme: f.value,
41
+ id: o.id
42
+ }));
43
+ u(V, $);
44
+ const _ = {};
45
+ h(() => o.materials, (t) => {
46
+ Object.assign(_, t);
47
+ }, { immediate: !0 }), u(ee, _);
48
+ const n = z(G, {}), y = {
49
+ ...n && typeof n == "object" ? n : {}
50
+ };
51
+ h(
52
+ () => o.notify,
53
+ (t) => {
54
+ y.notify = t ?? (n == null ? void 0 : n.notify);
55
+ },
56
+ { immediate: !0 }
57
+ ), u(G, y), h(
58
+ () => [o.locale, o.i18n],
59
+ () => {
60
+ o.locale && o.locale !== i.locale.value && i.setLocale(o.locale), o.i18n && i.mergeMessages(o.i18n);
61
+ },
62
+ { immediate: !0 }
63
+ );
64
+ const j = I({
65
+ name: "ThemeRoots",
66
+ props: {
67
+ roots: { type: Array, required: !0 }
68
+ },
69
+ setup(t, { slots: e }) {
70
+ return () => {
71
+ var s;
72
+ const r = ((s = e.default) == null ? void 0 : s.call(e)) ?? [];
73
+ return t.roots.reduceRight(
74
+ (c, d) => O(d, {}, () => c),
75
+ r
76
+ );
77
+ };
78
+ }
79
+ }), w = Q([]);
80
+ let p = [];
81
+ function M() {
82
+ const t = p;
83
+ p = [], t.forEach((e) => {
84
+ var r;
85
+ return (r = e.dispose) == null ? void 0 : r.call(e);
86
+ });
87
+ }
88
+ h(
89
+ () => [x.value, U.value, b.value, o.id],
90
+ ([t, e, r]) => {
91
+ var T;
92
+ const s = F(t);
93
+ M();
94
+ const c = [], d = [];
95
+ for (const g of s) {
96
+ const l = g.apply(e, { systemColorScheme: r });
97
+ l.root && d.push(l.root), c.push(l), p.push(l);
98
+ }
99
+ w.value = d, f.value = ((T = c.find((g) => g.descriptor.colorScheme)) == null ? void 0 : T.descriptor.colorScheme) ?? (e === "auto" ? r : e === "dark" ? "dark" : "light");
100
+ },
101
+ { immediate: !0 }
102
+ ), q(() => {
103
+ M(), a.clear();
104
+ });
105
+ const B = m(() => ({
106
+ colorMode: f.value,
107
+ targetElement: `#${o.id}`
108
+ }));
109
+ return (t, e) => (D(), W("div", {
110
+ id: o.id,
111
+ class: "tg-config-provider"
112
+ }, [
113
+ k(E(X), H(J(B.value)), {
114
+ default: C(() => [
115
+ k(E(j), { roots: w.value }, {
116
+ default: C(() => [
117
+ K(t.$slots, "default", {}, void 0, !0)
118
+ ]),
119
+ _: 3
120
+ }, 8, ["roots"])
121
+ ]),
122
+ _: 3
123
+ }, 16)
124
+ ], 8, ae));
125
+ }
126
+ }), le = /* @__PURE__ */ te(ie, [["__scopeId", "data-v-7d5e1407"]]);
127
+ export {
128
+ le as G,
129
+ ne as u
130
+ };
131
+ //# sourceMappingURL=ConfigProvider-D6LFAgg5.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConfigProvider-D6LFAgg5.js","sources":["../src/config-provider/use-media-theme.ts","../src/config-provider/ConfigProvider.vue"],"sourcesContent":["import { ref, readonly } from 'vue';\n\nconst hasMediaQuery = () => typeof window !== 'undefined' && window.matchMedia;\n\nconst getMediaTheme = (): 'light' | 'dark' => {\n if (hasMediaQuery()) {\n return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';\n }\n return 'light';\n};\n\nconst theme = ref<'light' | 'dark'>(getMediaTheme());\nlet mediaQuery: MediaQueryList | null = null;\n\nconst handleThemeChange = () => {\n theme.value = getMediaTheme();\n};\n\nconst startWatchMediaTheme = () => {\n if (hasMediaQuery() && !mediaQuery) {\n mediaQuery = window.matchMedia('(prefers-color-scheme: dark)');\n mediaQuery.addEventListener('change', handleThemeChange);\n }\n};\n\nexport const useMediaTheme = () => {\n startWatchMediaTheme();\n return {\n theme: readonly(theme),\n }\n}\n","<script setup lang=\"ts\">\nimport { ThemeProvider } from '@opentiny/tiny-robot';\nimport {\n type IMaterialsTheme,\n type MaterialsThemeFactory,\n type MergedMaterials,\n type IThemeApplyResult,\n type ThemeColorScheme,\n} from '@opentiny/genui-sdk-core';\nimport {\n watch,\n provide,\n inject,\n computed,\n ref,\n shallowRef,\n onBeforeUnmount,\n defineComponent,\n h,\n type Component,\n type PropType,\n type VNode,\n} from 'vue';\nimport { RENDERER_SETTINGS_KEY } from '@opentiny/tiny-schema-renderer';\nimport { I18nMessages, useI18n } from '../chat/i18n';\nimport { GENUI_I18N, GENUI_CONFIG, GENUI_MATERIALS } from './injection-tokens';\nimport { useMediaTheme } from './use-media-theme';\nimport type { NotifyHandler } from './notify.types';\n\nexport type { NotifyHandler };\n\nexport interface ConfigProviderProps {\n theme?: string;\n id?: string;\n locale?: string;\n i18n?: I18nMessages;\n materials?: MergedMaterials;\n notify?: NotifyHandler;\n}\n\nconst props = withDefaults(defineProps<ConfigProviderProps>(), {\n id: 'tiny-genui-config-provider',\n locale: 'zh_CN',\n});\n\nconst i18n = useI18n();\nprovide(GENUI_I18N, i18n);\n\nconst { theme: mediaTheme } = useMediaTheme();\n\nconst themeFactories = computed<MaterialsThemeFactory[]>(() => {\n const themeFactory = props.materials?.themeFactory;\n if (!themeFactory) {\n return [];\n }\n return Array.isArray(themeFactory) ? themeFactory : [themeFactory];\n});\n\nconst themeInstances = new Map<MaterialsThemeFactory, IMaterialsTheme>();\n\nfunction resolveThemeInstances(factories: MaterialsThemeFactory[]) {\n for (const key of themeInstances.keys()) {\n if (!factories.includes(key)) {\n themeInstances.delete(key);\n }\n }\n return factories.map((factory) => {\n let instance = themeInstances.get(factory);\n if (!instance) {\n instance = factory();\n themeInstances.set(factory, instance);\n }\n return instance;\n });\n}\n\nconst theme = computed(() => props.theme || 'light');\n\nconst colorScheme = ref<ThemeColorScheme>('light');\n\nconst genuiConfig = computed(() => ({\n colorScheme: colorScheme.value,\n id: props.id,\n}));\n\nprovide(GENUI_CONFIG, genuiConfig);\n\nconst internalMaterials = {};\nwatch(() => props.materials, (newVal) => {\n Object.assign(internalMaterials, newVal);\n}, { immediate: true });\n\nprovide(GENUI_MATERIALS, internalMaterials);\n\nconst parentRendererSettings = inject(RENDERER_SETTINGS_KEY, {}) as Record<string, any>;\nconst rendererSettings = {\n ...(parentRendererSettings && typeof parentRendererSettings === 'object' ? parentRendererSettings : {}),\n};\nwatch(\n () => props.notify,\n (notify) => {\n rendererSettings.notify = notify ?? parentRendererSettings?.notify;\n },\n { immediate: true },\n);\nprovide(RENDERER_SETTINGS_KEY, rendererSettings);\n\nwatch(\n () => [props.locale, props.i18n] as const,\n () => {\n if (props.locale && props.locale !== i18n.locale.value) {\n i18n.setLocale(props.locale);\n }\n props.i18n && i18n.mergeMessages(props.i18n);\n },\n { immediate: true },\n);\n\nconst ThemeRoots = defineComponent({\n name: 'ThemeRoots',\n props: {\n roots: { type: Array as PropType<Component[]>, required: true },\n },\n setup(props, { slots }) {\n return () => {\n const children = slots.default?.() ?? [];\n return props.roots.reduceRight<VNode | VNode[]>(\n (acc, root) => h(root, {}, () => acc),\n children,\n );\n };\n },\n});\n\nconst themeRoots = shallowRef<Component[]>([]);\n\nlet applied: IThemeApplyResult[] = [];\n\nfunction clearTheme() {\n const pending = applied;\n applied = [];\n pending.forEach((item) => item.dispose?.());\n}\n\nwatch(\n () => [themeFactories.value, theme.value, mediaTheme.value, props.id] as const,\n ([factories, themeValue, systemColorScheme]) => {\n const apis = resolveThemeInstances(factories);\n clearTheme();\n const results: IThemeApplyResult[] = [];\n const roots: Component[] = [];\n\n for (const api of apis) {\n const result = api.apply(themeValue, { systemColorScheme });\n if (result.root) {\n roots.push(result.root as Component);\n }\n results.push(result);\n applied.push(result);\n }\n\n themeRoots.value = roots;\n colorScheme.value =\n results.find((result) => result.descriptor.colorScheme)?.descriptor.colorScheme ??\n (themeValue === 'auto'\n ? systemColorScheme\n : themeValue === 'dark'\n ? 'dark'\n : 'light');\n },\n { immediate: true },\n);\n\nonBeforeUnmount(() => {\n clearTheme();\n themeInstances.clear();\n});\n\nconst robotProviderProps = computed(() => ({\n colorMode: colorScheme.value,\n targetElement: `#${props.id}`,\n}));\n</script>\n\n<template>\n <div :id=\"props.id\" class=\"tg-config-provider\">\n <ThemeProvider v-bind=\"robotProviderProps\">\n <ThemeRoots :roots=\"themeRoots\">\n <slot />\n </ThemeRoots>\n </ThemeProvider>\n </div>\n</template>\n\n<style scoped>\n.tg-config-provider {\n --tr-sender-bg-color: var(--tr-container-bg-default);\n --tr-sender-text-color: var(--tr-text-primary);\n --tr-sender-action-buttons-icon-color: var(--tr-text-secondary);\n --tr-sender-action-buttons-send-bg-color: var(--tr-color-primary);\n height: 100%;\n}\n</style>\n"],"names":["hasMediaQuery","getMediaTheme","theme","ref","mediaQuery","handleThemeChange","startWatchMediaTheme","useMediaTheme","readonly","props","__props","i18n","useI18n","provide","GENUI_I18N","mediaTheme","themeFactories","computed","themeFactory","_a","themeInstances","resolveThemeInstances","factories","key","factory","instance","colorScheme","genuiConfig","GENUI_CONFIG","internalMaterials","watch","newVal","GENUI_MATERIALS","parentRendererSettings","inject","RENDERER_SETTINGS_KEY","rendererSettings","notify","ThemeRoots","defineComponent","slots","children","acc","root","h","themeRoots","shallowRef","applied","clearTheme","pending","item","themeValue","systemColorScheme","apis","results","roots","api","result","onBeforeUnmount","robotProviderProps","_createElementBlock","_createVNode","_unref","_renderSlot","_ctx"],"mappings":";;;AAEA,MAAMA,IAAgB,MAAM,OAAO,SAAW,OAAe,OAAO,YAE9DC,IAAgB,MAChBD,OACK,OAAO,WAAW,8BAA8B,EAAE,UAAU,SAE9D,SAGHE,IAAQC,EAAsBF,GAAe;AACnD,IAAIG,IAAoC;AAExC,MAAMC,KAAoB,MAAM;AAC9B,EAAAH,EAAM,QAAQD,EAAA;AAChB,GAEMK,KAAuB,MAAM;AACjC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@@
1
+ (function(){"use strict";try{if(typeof document<"u"){var a=document.createElement("style");a.appendChild(document.createTextNode("[data-v-68c3e02f] .tiny-card.tiny-card.tiny-card{width:100%;background-color:var(--content-bg);border-radius:24px}[data-v-68c3e02f] .tiny-card.tiny-card.tiny-card .tiny-card--logo__main{color:var(--text-color)}[data-v-68c3e02f] .tiny-card.tiny-card.tiny-card .tiny-card--logo{max-width:100%}[data-v-68c3e02f] .tiny-row.tiny-row{line-height:2}[data-v-68c3e02f] ol[data-tag=ol],[data-v-68c3e02f] ul[data-tag=ul]{list-style:revert;margin:revert;padding:revert}[data-v-68c3e02f] li[data-tag=li]{margin:revert;padding:revert}[data-v-68c3e02f] *,[data-v-68c3e02f] *:before,[data-v-68c3e02f] *:after{box-sizing:border-box}[data-v-68c3e02f] h1[data-tag=h1],[data-v-68c3e02f] h2[data-tag=h2],[data-v-68c3e02f] h3[data-tag=h3],[data-v-68c3e02f] h4[data-tag=h4],[data-v-68c3e02f] h5[data-tag=h5],[data-v-68c3e02f] h6[data-tag=h6],[data-v-68c3e02f] p[data-tag=p]{font-size:revert;font-weight:revert;color:revert;margin:revert;padding:revert}.schema-render-container[data-v-68c3e02f]{--ti-genui-renderer-text-color: #191919;position:relative;color:var(--ti-genui-renderer-text-color)}.schema-render-container.dark[data-v-68c3e02f]{--ti-genui-renderer-text-color: #f5f5f5}.schema-render-container[data-v-68c3e02f]:has(.loading-warp):after{display:none}[data-v-68c3e02f] .loading-warp.loading-warp,[data-v-68c3e02f] .loading-warp .loading{display:none}")),document.head.appendChild(a)}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();
2
+ import { defineComponent as q, onErrorCaptured as G, ref as d, inject as f, watch as m, provide as J, shallowRef as b, computed as k, nextTick as h, createElementBlock as R, openBlock as j, normalizeClass as $, unref as y, renderSlot as g, createVNode as B } from "vue";
3
+ import { b as P, a as T, $ as x, u as U, l as D, _ as O } from "./injection-tokens-DDgspg4x.js";
4
+ import { DeltaPatcher as w, repairJson as z, RepairJsonState as L } from "@opentiny/genui-sdk-core";
5
+ const M = Symbol("schema-card-id"), W = [
6
+ "[componentName=img] > props > src",
7
+ "componentName",
8
+ "style",
9
+ "[componentName=Page] > css",
10
+ "[type=JSFunction]",
11
+ "[type=JSExpression]",
12
+ "[type=JSSlot][value=]",
13
+ "type",
14
+ ":empty:object",
15
+ "[componentName] > props > ref"
16
+ ], H = /* @__PURE__ */ q({
17
+ __name: "GenuiRenderer",
18
+ props: {
19
+ content: {},
20
+ generating: { type: Boolean },
21
+ isJsonComplete: { type: Boolean, default: !0 },
22
+ customComponents: {},
23
+ customActions: {},
24
+ requiredCompleteFieldSelectors: {},
25
+ id: {},
26
+ state: {}
27
+ },
28
+ setup(E) {
29
+ G((e) => (console.error("GenuiRenderer error:", e), !0));
30
+ const r = E, i = d({}), n = d(null), _ = (e, s) => {
31
+ var t, l;
32
+ if (!((t = r.customActions) != null && t[e])) {
33
+ console.warn(`Action ${e} not found`);
34
+ return;
35
+ }
36
+ return (l = r.customActions[e]) == null ? void 0 : l.execute(s, n.value.getContext());
37
+ }, o = f(P, {}), F = f(T, null), v = f(x, {});
38
+ m(() => r.customComponents, (e) => {
39
+ o.components && Object.assign(o.components, e);
40
+ }, { immediate: !0 }), v.materials = o, J(x, v);
41
+ const C = b(null);
42
+ m(
43
+ () => [o == null ? void 0 : o.requiredCompleteFieldSelectors, r.requiredCompleteFieldSelectors],
44
+ () => {
45
+ C.value = new w({
46
+ requiredCompleteFieldSelectors: [
47
+ ...W,
48
+ ...(o == null ? void 0 : o.requiredCompleteFieldSelectors) || [],
49
+ ...r.requiredCompleteFieldSelectors || []
50
+ ]
51
+ });
52
+ },
53
+ { immediate: !0 }
54
+ );
55
+ const { t: A } = U(), I = {
56
+ componentName: "Page",
57
+ children: [
58
+ {
59
+ componentName: "Text",
60
+ props: {
61
+ text: A("renderer.error.displayError"),
62
+ style: "line-height: 40px; color: var(--tv-color-error-text)"
63
+ }
64
+ }
65
+ ]
66
+ }, c = d(!1), N = k(() => c.value ? I : i.value);
67
+ let a = null;
68
+ function S() {
69
+ var e, s, t;
70
+ (e = n.value) == null || e.setContext({
71
+ callAction: _
72
+ }), (s = n.value) == null || s.setContext({
73
+ [M]: r.id
74
+ }), (t = n.value) == null || t.setState(r.state || {});
75
+ }
76
+ return m(
77
+ [() => r.content, () => r.isJsonComplete],
78
+ ([e, s]) => {
79
+ c.value = !1;
80
+ let t = e, l = !0;
81
+ if (typeof e == "string")
82
+ if (e.trim()) {
83
+ const { value: u, state: p } = z(e);
84
+ if (!u || typeof u != "object") {
85
+ c.value = !0;
86
+ return;
87
+ }
88
+ t = u, l = p === L.SUCCESS;
89
+ } else
90
+ t = {};
91
+ else
92
+ l = s ?? !0;
93
+ if (!l && t && "lifeCycles" in t) {
94
+ const { lifeCycles: u, ...p } = t;
95
+ t = p;
96
+ }
97
+ C.value.patchWithDelta(i.value, t, l), a || (a = h(() => {
98
+ n.value && (S(), a = null);
99
+ }));
100
+ },
101
+ {
102
+ immediate: !0
103
+ }
104
+ ), m(
105
+ () => n.value,
106
+ (e) => {
107
+ e && a && (h(() => S()), a = null);
108
+ },
109
+ {
110
+ immediate: !0
111
+ }
112
+ ), (e, s) => {
113
+ var t;
114
+ return j(), R("div", {
115
+ class: $(["schema-render-container", { dark: ((t = y(F)) == null ? void 0 : t.colorScheme) === "dark" }])
116
+ }, [
117
+ g(e.$slots, "header", {
118
+ schema: i.value,
119
+ isError: c.value,
120
+ isFinished: !r.generating
121
+ }, void 0, !0),
122
+ B(y(D), {
123
+ schema: N.value,
124
+ ref_key: "rendererInstance",
125
+ ref: n
126
+ }, null, 8, ["schema"]),
127
+ g(e.$slots, "footer", {
128
+ schema: i.value,
129
+ isError: c.value,
130
+ isFinished: !r.generating
131
+ }, void 0, !0)
132
+ ], 2);
133
+ };
134
+ }
135
+ }), Y = /* @__PURE__ */ O(H, [["__scopeId", "data-v-68c3e02f"]]);
136
+ export {
137
+ Y as G,
138
+ M as c,
139
+ W as r
140
+ };
141
+ //# sourceMappingURL=GenuiRenderer-f2_6u1TA.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GenuiRenderer-f2_6u1TA.js","sources":["../src/chat/useChat.ts","../src/renderer/config.ts","../src/renderer/GenuiRenderer.vue"],"sourcesContent":["export const cardIdSymbol = Symbol('schema-card-id');\n","export const requiredCompleteFieldSelectors = [\n '[componentName=img] > props > src',\n 'componentName',\n 'style',\n '[componentName=Page] > css',\n '[type=JSFunction]',\n '[type=JSExpression]',\n '[type=JSSlot][value=]',\n 'type',\n ':empty:object',\n '[componentName] > props > ref',\n];\n","<script setup lang=\"ts\">\nimport { ref, watch, computed, inject, nextTick, onErrorCaptured, provide, shallowRef } from 'vue';\n// @ts-ignore\nimport SchemaRenderer, { RENDERER_SETTINGS_KEY } from '@opentiny/tiny-schema-renderer';\nimport { DeltaPatcher, repairJson, RepairJsonState, type IMaterials } from '@opentiny/genui-sdk-core';\nimport { requiredCompleteFieldSelectors as internalRequiredCompleteFieldSelectors } from './config';\nimport { GENUI_CONFIG, GENUI_MATERIALS } from '../config-provider/injection-tokens';\nimport type { IRendererProps } from './renderer.types';\nimport { cardIdSymbol } from '../chat/useChat';\nimport { useI18n } from '../chat/i18n';\n\nonErrorCaptured((error) => {\n console.error('GenuiRenderer error:', error);\n return true;\n});\n\nconst props = withDefaults(defineProps<IRendererProps>(), {\n isJsonComplete: true,\n});\n\nconst schema = ref<any>({});\nconst rendererInstance = ref<SchemaRenderer | null>(null);\n\nconst callAction = (actionName: string, params: any) => {\n if (!props.customActions?.[actionName]) {\n console.warn(`Action ${actionName} not found`);\n return;\n }\n return props.customActions[actionName]?.execute(params, rendererInstance.value.getContext());\n};\n\nconst materials = inject<IMaterials>(GENUI_MATERIALS, {});\nconst genuiConfig = inject(GENUI_CONFIG, null);\nconst customSettings = inject(RENDERER_SETTINGS_KEY, {}) as Record<string, any>;\n\nwatch(() => props.customComponents, (newVal) => {\n // TODO: 1、materials.components更新后,customComponents会丢失 2、旧的customComponents没有被移除\n if (materials.components) {\n Object.assign(materials.components, newVal);\n }\n}, { immediate: true });\n\ncustomSettings.materials = materials;\nprovide(RENDERER_SETTINGS_KEY, customSettings);\n\nconst deltaPatcher = shallowRef(null);\n\nwatch(\n () => [materials?.requiredCompleteFieldSelectors, props.requiredCompleteFieldSelectors],\n () => {\n deltaPatcher.value = new DeltaPatcher({\n requiredCompleteFieldSelectors: [\n ...internalRequiredCompleteFieldSelectors,\n ...(materials?.requiredCompleteFieldSelectors || []),\n ...(props.requiredCompleteFieldSelectors || []),\n ],\n });\n },\n { immediate: true },\n);\n\nconst { t } = useI18n();\n\nconst errorSchema = {\n componentName: 'Page',\n children: [\n {\n componentName: 'Text',\n props: {\n text: t('renderer.error.displayError'),\n style: 'line-height: 40px; color: var(--tv-color-error-text)',\n },\n },\n ],\n};\n\nconst isError = ref(false);\n\nconst displaySchema = computed(() => {\n if (isError.value) {\n return errorSchema;\n }\n return schema.value;\n});\n\nlet updateActionTimer: any | null = null;\n\nfunction updateContextAndState() {\n rendererInstance.value?.setContext({\n callAction,\n });\n rendererInstance.value?.setContext({\n [cardIdSymbol]: props.id,\n });\n rendererInstance.value?.setState(props.state || {});\n}\n\nwatch(\n [() => props.content, () => props.isJsonComplete],\n ([newVal, isJsonComplete]) => {\n isError.value = false;\n let json: any = newVal;\n let isCompleted = true;\n if (typeof newVal === 'string') {\n if (newVal.trim()) {\n const { value, state } = repairJson(newVal);\n if (!value || typeof value !== 'object') {\n isError.value = true;\n return;\n }\n json = value;\n isCompleted = state === RepairJsonState.SUCCESS;\n } else {\n json = {};\n }\n } else {\n isCompleted = isJsonComplete ?? true;\n }\n if (!isCompleted && json && 'lifeCycles' in json) {\n const { lifeCycles, ...rest } = json;\n json = rest;\n }\n deltaPatcher.value.patchWithDelta(schema.value, json, isCompleted); // TODO: 速率限制\n if (!updateActionTimer) {\n updateActionTimer = nextTick(() => {\n if (!rendererInstance.value) return;\n updateContextAndState();\n updateActionTimer = null;\n });\n }\n },\n {\n immediate: true,\n },\n);\n// 异步组件可能在更新context时候并未ready,导致恢复会话的时候context没更新\nwatch(\n () => rendererInstance.value,\n (newVal) => {\n if (newVal && updateActionTimer) {\n nextTick(() => updateContextAndState());\n updateActionTimer = null;\n }\n },\n {\n immediate: true,\n },\n);\n</script>\n\n<template>\n <div class=\"schema-render-container\" :class=\"{ dark: genuiConfig?.colorScheme === 'dark' }\">\n <slot name=\"header\" :schema=\"schema\" :isError=\"isError\" :isFinished=\"!props.generating\"></slot>\n <SchemaRenderer :schema=\"displaySchema\" ref=\"rendererInstance\" />\n <slot name=\"footer\" :schema=\"schema\" :isError=\"isError\" :isFinished=\"!props.generating\"></slot>\n </div>\n</template>\n\n<style scoped>\n@import url('./custom.css');\n\n.schema-render-container {\n --ti-genui-renderer-text-color: #191919;\n position: relative;\n color: var(--ti-genui-renderer-text-color);\n}\n\n.schema-render-container.dark {\n --ti-genui-renderer-text-color: #f5f5f5;\n}\n\n.schema-render-container:has(.loading-warp):after {\n display: none;\n}\n\n:deep(.loading-warp.loading-warp) {\n display: none;\n}\n\n:deep(.loading-warp .loading) {\n display: none;\n}\n</style>\n"],"names":["cardIdSymbol","requiredCompleteFieldSelectors","onErrorCaptured","error","props","__props","schema","ref","rendererInstance","callAction","actionName","params","_a","_b","materials","inject","GENUI_MATERIALS","genuiConfig","GENUI_CONFIG","customSettings","RENDERER_SETTINGS_KEY","watch","newVal","provide","deltaPatcher","shallowRef","DeltaPatcher","internalRequiredCompleteFieldSelectors","t","useI18n","errorSchema","isError","displaySchema","computed","updateActionTimer","updateContextAndState","_c","isJsonComplete","json","isCompleted","value","state","repairJson","RepairJsonState","lifeCycles","rest","nextTick","_createElementBlock","_normalizeClass","_unref","_renderSlot","_ctx","_createVNode","SchemaRenderer"],"mappings":";;;AAAO,MAAMA,IAAe,OAAO,gBAAgB,GCAtCC,IAAiC;AAAA,EAC5C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,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,GAAMC,CAAW,GAC5DL,MACHA,IAAoBY,EAAS,MAAM;AACjC,UAAKtC,EAAiB,UACtB2B,EAAA,GACAD,IAAoB;AAAA,QACtB,CAAC;AAAA,MAEL;AAAA,MACA;AAAA,QACE,WAAW;AAAA,MAAA;AAAA,IACb,GAGFb;AAAA,MACE,MAAMb,EAAiB;AAAA,MACvB,CAACc,MAAW;AACV,QAAIA,KAAUY,MACZY,EAAS,MAAMX,GAAuB,GACtCD,IAAoB;AAAA,MAExB;AAAA,MACA;AAAA,QACE,WAAW;AAAA,MAAA;AAAA,IACb;;kBAKAa,EAIM,OAAA;AAAA,QAJD,OAAKC,EAAA,CAAC,2BAAyB,EAAA,QAAiBC,IAAAA,EAAAhC,CAAA,MAAAgC,gBAAAA,EAAa,iBAAW,QAAA,CAAA;AAAA,MAAA;QAC3EC,EAA+FC,EAAA,QAAA,UAAA;AAAA,UAA1E,QAAQ7C,EAAA;AAAA,UAAS,SAASyB,EAAA;AAAA,UAAU,YAAU,CAAG3B,EAAM;AAAA,QAAA;QAC5EgD,EAAiEH,EAAAI,CAAA,GAAA;AAAA,UAAhD,QAAQrB,EAAA;AAAA,mBAAmB;AAAA,UAAJ,KAAIxB;AAAA,QAAA;QAC5C0C,EAA+FC,EAAA,QAAA,UAAA;AAAA,UAA1E,QAAQ7C,EAAA;AAAA,UAAS,SAASyB,EAAA;AAAA,UAAU,YAAU,CAAG3B,EAAM;AAAA,QAAA;;;;;"}
package/dist/chat.d.ts CHANGED
@@ -141,6 +141,8 @@ declare type __VLS_WithTemplateSlots<T, S> = T & {
141
141
  };
142
142
  };
143
143
 
144
+ export declare const cardIdSymbol: unique symbol;
145
+
144
146
  export declare function createI18n(options?: I18nOptions): I18nInstance;
145
147
 
146
148
  /**
@@ -171,6 +173,8 @@ export declare class CustomModelProvider extends BaseModelProvider {
171
173
  }): Promise<void>;
172
174
  protected setupStreamContext(context: Record<string, unknown>, _request: ChatCompletionRequest): void;
173
175
  handlerChunk(rawData: string, context: any): void;
176
+ handlerBeforeRequest(context: any): void;
177
+ handlerRequestError(context: any, error?: unknown): void;
174
178
  handlerStart(context: any, handlers: {
175
179
  onData: (data: IChatMessage) => void;
176
180
  onDone: () => void;
@@ -375,6 +379,8 @@ export declare interface IResponseHandler<T> {
375
379
  match: (data: T, context: any) => boolean;
376
380
  handler: (data: T, context: any) => boolean;
377
381
  notMatchHandler?: (data: T, context: any) => boolean;
382
+ beforeRequest?: (context: any) => void;
383
+ onRequestError?: (context: any, error?: unknown) => void;
378
384
  start?: (context: any, handlers: {
379
385
  onData: (data: IChatMessage) => void;
380
386
  onDone: () => void;
package/dist/chat.js CHANGED
@@ -1,21 +1,23 @@
1
- import { C as s, D as t, E as r, G as n, I as o, M as u, T as d, d as E, e as i, s as l, b as M, t as g, u as m, a as I } from "./chat.types-CIkLm6Gm.js";
2
- import { c, u as p } from "./injection-tokens-CuDQs1ne.js";
1
+ import { C as s, D as t, E as r, G as o, I as n, M as d, T as u, d as l, e as E, s as i, b as m, t as c, u as I, a as M } from "./chat.types-DEDNSs5o.js";
2
+ import { c as p } from "./GenuiRenderer-f2_6u1TA.js";
3
+ import { c as f, u as x } from "./injection-tokens-DDgspg4x.js";
3
4
  export {
4
5
  s as CustomModelProvider,
5
6
  t as DEFAULT_IMAGE_FEATURES,
6
7
  r as EventEmitter,
7
- n as GenuiChat,
8
- o as IndexedDBStrategy,
9
- u as MessageManager,
10
- d as ThinkTagWrapPattern,
11
- c as createI18n,
12
- E as defaultResponseHandlers,
13
- i as emitter,
14
- l as scrollEnd,
15
- M as throttle,
16
- g as toSlotFunction,
17
- m as useConversation,
18
- p as useI18n,
19
- I as useMessage
8
+ o as GenuiChat,
9
+ n as IndexedDBStrategy,
10
+ d as MessageManager,
11
+ u as ThinkTagWrapPattern,
12
+ p as cardIdSymbol,
13
+ f as createI18n,
14
+ l as defaultResponseHandlers,
15
+ E as emitter,
16
+ i as scrollEnd,
17
+ m as throttle,
18
+ c as toSlotFunction,
19
+ I as useConversation,
20
+ x as useI18n,
21
+ M as useMessage
20
22
  };
21
23
  //# sourceMappingURL=chat.js.map
package/dist/chat.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"chat.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
1
+ {"version":3,"file":"chat.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}