@antdv-next/x 0.0.4 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/dist/actions/Actions.js +1 -1
  2. package/dist/actions/ActionsAudio.js +1 -1
  3. package/dist/actions/ActionsCopy.js +1 -1
  4. package/dist/actions/ActionsFeedback.js +1 -1
  5. package/dist/actions/ActionsItem.js +1 -1
  6. package/dist/attachments/index.js +1 -1
  7. package/dist/bubble/Bubble.js +1 -1
  8. package/dist/bubble/BubbleList.js +1 -1
  9. package/dist/bubble/Divider.js +1 -1
  10. package/dist/bubble/System.js +1 -1
  11. package/dist/code-highlighter/CodeHighlighter.js +3 -14
  12. package/dist/code-highlighter/shiki.d.ts +4 -0
  13. package/dist/code-highlighter/shiki.js +72 -0
  14. package/dist/conversations/Creation.js +1 -1
  15. package/dist/conversations/index.js +1 -1
  16. package/dist/file-card/FileCard.js +1 -1
  17. package/dist/file-card/List.js +1 -1
  18. package/dist/index.esm.js +140 -75
  19. package/dist/index.js +0 -25
  20. package/dist/index.umd.js +146 -80
  21. package/dist/mermaid/Mermaid.d.ts +1 -1
  22. package/dist/mermaid/Mermaid.js +5 -5
  23. package/dist/mermaid/loader.d.ts +6 -0
  24. package/dist/mermaid/loader.js +33 -0
  25. package/dist/mermaid/mermaid-core.d.js +0 -0
  26. package/dist/package.js +1 -1
  27. package/dist/prompts/Prompts.js +6 -4
  28. package/dist/sender/Sender.js +1 -1
  29. package/dist/sender/SenderHeader.js +1 -1
  30. package/dist/sender/SenderSwitch.js +1 -1
  31. package/dist/sources/Sources.js +1 -1
  32. package/dist/suggestion/Suggestion.js +1 -1
  33. package/dist/think/Think.js +1 -1
  34. package/dist/thought-chain/Item.js +1 -1
  35. package/dist/thought-chain/ThoughtChain.js +1 -1
  36. package/dist/welcome/index.js +1 -1
  37. package/dist/x-provider/index.js +1 -1
  38. package/global.d.ts +61 -18
  39. package/package.json +2 -2
@@ -20,7 +20,7 @@ function getMotionTransitionProps(motionName) {
20
20
  };
21
21
  }
22
22
  var XActions = /* @__PURE__ */ defineComponent({
23
- name: "XActions",
23
+ name: "AxActions",
24
24
  inheritAttrs: false,
25
25
  props: {
26
26
  items: {
@@ -3,7 +3,7 @@ import { createVNode, defineComponent, mergeProps } from "vue";
3
3
  import { MutedOutlined, SoundOutlined } from "@antdv-next/icons";
4
4
  //#region components/actions/ActionsAudio.tsx
5
5
  var XActionsAudio = /* @__PURE__ */ defineComponent({
6
- name: "XActionsAudio",
6
+ name: "AxActionsAudio",
7
7
  props: {
8
8
  status: {
9
9
  type: String,
@@ -7,7 +7,7 @@ var normalizeCopyIcons = (icon) => {
7
7
  return [icon, icon];
8
8
  };
9
9
  var XActionsCopy = /* @__PURE__ */ defineComponent({
10
- name: "XActionsCopy",
10
+ name: "AxActionsCopy",
11
11
  inheritAttrs: false,
12
12
  props: {
13
13
  text: {
@@ -10,7 +10,7 @@ var FEEDBACK_VALUE = /* @__PURE__ */ function(FEEDBACK_VALUE) {
10
10
  return FEEDBACK_VALUE;
11
11
  }(FEEDBACK_VALUE || {});
12
12
  var XActionsFeedback = /* @__PURE__ */ defineComponent({
13
- name: "XActionsFeedback",
13
+ name: "AxActionsFeedback",
14
14
  inheritAttrs: false,
15
15
  props: {
16
16
  value: {
@@ -11,7 +11,7 @@ var ACTIONS_ITEM_STATUS = /* @__PURE__ */ function(ACTIONS_ITEM_STATUS) {
11
11
  return ACTIONS_ITEM_STATUS;
12
12
  }({});
13
13
  var XActionsItem = /* @__PURE__ */ defineComponent({
14
- name: "XActionsItem",
14
+ name: "AxActionsItem",
15
15
  inheritAttrs: false,
16
16
  props: {
17
17
  status: {
@@ -12,7 +12,7 @@ function _isSlot(s) {
12
12
  return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
13
13
  }
14
14
  var XAttachments = /* @__PURE__ */ defineComponent({
15
- name: "XAttachments",
15
+ name: "AxAttachments",
16
16
  inheritAttrs: false,
17
17
  props: {
18
18
  prefixCls: {
@@ -14,7 +14,7 @@ function hasRenderableNode(node) {
14
14
  return node !== null && node !== void 0 && node !== false;
15
15
  }
16
16
  var XBubble = /* @__PURE__ */ defineComponent({
17
- name: "XBubble",
17
+ name: "AxBubble",
18
18
  inheritAttrs: false,
19
19
  props: {
20
20
  prefixCls: {
@@ -22,7 +22,7 @@ var bubbleSlotNames = [
22
22
  "extra"
23
23
  ];
24
24
  var XBubbleList = /* @__PURE__ */ defineComponent({
25
- name: "XBubbleList",
25
+ name: "AxBubbleList",
26
26
  inheritAttrs: false,
27
27
  props: {
28
28
  prefixCls: {
@@ -6,7 +6,7 @@ function _isSlot(s) {
6
6
  return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
7
7
  }
8
8
  var XBubbleDivider = /* @__PURE__ */ defineComponent({
9
- name: "XBubbleDivider",
9
+ name: "AxBubbleDivider",
10
10
  props: {
11
11
  prefixCls: {
12
12
  type: String,
@@ -2,7 +2,7 @@ import { XBubble } from "./Bubble.js";
2
2
  import { createVNode, defineComponent, mergeProps, ref } from "vue";
3
3
  //#region components/bubble/System.tsx
4
4
  var XBubbleSystem = /* @__PURE__ */ defineComponent({
5
- name: "XBubbleSystem",
5
+ name: "AxBubbleSystem",
6
6
  props: {
7
7
  prefixCls: {
8
8
  type: String,
@@ -1,20 +1,11 @@
1
+ import { codeToHtml } from "./shiki.js";
1
2
  import style_default from "./style/index.js";
2
3
  import { computed, createVNode, defineComponent, mergeProps, ref, shallowRef, useAttrs, watch } from "vue";
3
4
  import { Button, Tooltip } from "antdv-next";
4
5
  import { CheckOutlined, CopyOutlined, MoonOutlined, SunOutlined } from "@antdv-next/icons";
5
6
  //#region components/code-highlighter/CodeHighlighter.tsx
6
- var shikiHighlighter = null;
7
- var shikiPromise = null;
8
- async function initShiki() {
9
- if (shikiHighlighter) return;
10
- if (shikiPromise) return shikiPromise;
11
- shikiPromise = (async () => {
12
- shikiHighlighter = (await import("shiki")).codeToHtml;
13
- })();
14
- return shikiPromise;
15
- }
16
7
  var XCodeHighlighter = /* @__PURE__ */ defineComponent({
17
- name: "XCodeHighlighter",
8
+ name: "AxCodeHighlighter",
18
9
  inheritAttrs: false,
19
10
  props: {
20
11
  prefixCls: {
@@ -95,9 +86,7 @@ var XCodeHighlighter = /* @__PURE__ */ defineComponent({
95
86
  const highlightedHtml = shallowRef("");
96
87
  const highlightCode = async () => {
97
88
  try {
98
- await initShiki();
99
- if (!shikiHighlighter) return;
100
- highlightedHtml.value = await shikiHighlighter(props.content, {
89
+ highlightedHtml.value = await codeToHtml(props.content, {
101
90
  lang: props.language,
102
91
  theme: props.theme === "dark" ? "vitesse-dark" : "vitesse-light"
103
92
  });
@@ -0,0 +1,4 @@
1
+ export declare function codeToHtml(code: string, options?: {
2
+ lang?: string;
3
+ theme?: string;
4
+ }): Promise<string>;
@@ -0,0 +1,72 @@
1
+ import { createHighlighterCore } from "shiki/core";
2
+ import darkTheme from "shiki/dist/themes/vitesse-dark.mjs";
3
+ import lightTheme from "shiki/dist/themes/vitesse-light.mjs";
4
+ import { createJavaScriptRegexEngine } from "shiki/engine/javascript";
5
+ //#region components/code-highlighter/shiki.ts
6
+ var SUPPORTED_LANG_ALIASES = {
7
+ ts: "typescript",
8
+ js: "javascript",
9
+ py: "python",
10
+ md: "markdown",
11
+ yml: "yaml",
12
+ shell: "bash",
13
+ zsh: "bash",
14
+ sh: "bash",
15
+ vue: "vue"
16
+ };
17
+ var LANG_LOADERS = {
18
+ javascript: () => import("shiki/dist/langs/javascript.mjs"),
19
+ typescript: () => import("shiki/dist/langs/typescript.mjs"),
20
+ jsx: () => import("shiki/dist/langs/jsx.mjs"),
21
+ tsx: () => import("shiki/dist/langs/tsx.mjs"),
22
+ json: () => import("shiki/dist/langs/json.mjs"),
23
+ bash: () => import("shiki/dist/langs/bash.mjs"),
24
+ markdown: () => import("shiki/dist/langs/markdown.mjs"),
25
+ html: () => import("shiki/dist/langs/html.mjs"),
26
+ css: () => import("shiki/dist/langs/css.mjs"),
27
+ vue: () => import("shiki/dist/langs/vue.mjs"),
28
+ "vue-html": () => import("shiki/dist/langs/vue-html.mjs"),
29
+ python: () => import("shiki/dist/langs/python.mjs"),
30
+ mermaid: () => import("shiki/dist/langs/mermaid.mjs"),
31
+ yaml: () => import("shiki/dist/langs/yaml.mjs"),
32
+ diff: () => import("shiki/dist/langs/diff.mjs")
33
+ };
34
+ var highlighter = null;
35
+ var highlighterPromise = null;
36
+ var loadedLangs = /* @__PURE__ */ new Set();
37
+ function normalizeLanguage(language) {
38
+ const input = (language || "text").toLowerCase();
39
+ return SUPPORTED_LANG_ALIASES[input] || input;
40
+ }
41
+ function escapeHtml(str) {
42
+ return str.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;");
43
+ }
44
+ async function getHighlighter() {
45
+ if (highlighter) return highlighter;
46
+ if (!highlighterPromise) highlighterPromise = createHighlighterCore({
47
+ themes: [lightTheme, darkTheme],
48
+ langs: [],
49
+ engine: createJavaScriptRegexEngine()
50
+ });
51
+ highlighter = await highlighterPromise;
52
+ return highlighter;
53
+ }
54
+ async function loadLang(lang) {
55
+ const loader = LANG_LOADERS[lang];
56
+ if (!loader || loadedLangs.has(lang)) return false;
57
+ const instance = await getHighlighter();
58
+ const mod = await loader();
59
+ await instance.loadLanguage(mod.default);
60
+ loadedLangs.add(lang);
61
+ return true;
62
+ }
63
+ async function codeToHtml(code, options = {}) {
64
+ const lang = normalizeLanguage(options.lang);
65
+ if (!await loadLang(lang)) return `<pre><code>${escapeHtml(code)}</code></pre>`;
66
+ return (await getHighlighter()).codeToHtml(code, {
67
+ lang,
68
+ theme: options.theme || "vitesse-light"
69
+ });
70
+ }
71
+ //#endregion
72
+ export { codeToHtml };
@@ -2,7 +2,7 @@ import useCreation from "./hooks/useCreation.js";
2
2
  import { computed, createVNode, defineComponent } from "vue";
3
3
  //#region components/conversations/Creation.tsx
4
4
  var Creation = /* @__PURE__ */ defineComponent({
5
- name: "XConversationsCreation",
5
+ name: "AxConversationsCreation",
6
6
  props: {
7
7
  label: {
8
8
  type: [
@@ -17,7 +17,7 @@ function isTypingTarget(target) {
17
17
  return tagName === "input" || tagName === "textarea" || tagName === "select";
18
18
  }
19
19
  var ConversationsWithSub = /* @__PURE__ */ defineComponent({
20
- name: "XConversations",
20
+ name: "AxConversations",
21
21
  inheritAttrs: false,
22
22
  props: {
23
23
  items: {
@@ -123,7 +123,7 @@ var DEFAULT_ICON = {
123
123
  key: "default"
124
124
  };
125
125
  var XFileCard = /* @__PURE__ */ defineComponent({
126
- name: "XFileCard",
126
+ name: "AxFileCard",
127
127
  inheritAttrs: false,
128
128
  props: {
129
129
  prefixCls: {
@@ -10,7 +10,7 @@ function _isSlot(s) {
10
10
  return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
11
11
  }
12
12
  var XFileCardList = /* @__PURE__ */ defineComponent({
13
- name: "XFileCardList",
13
+ name: "AxFileCardList",
14
14
  props: {
15
15
  prefixCls: {
16
16
  type: String,