@glodon-aiot/agent-cli-ui 2.4.7 → 3.0.4
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/es/AgentClientUI.mjs +97 -110
- package/dist/es/Dialog/AgentChat/index.mjs +516 -467
- package/dist/es/Dialog/ConnectToNetwork/index.mjs +25 -24
- package/dist/es/Dialog/FileCard/index.mjs +48 -55
- package/dist/es/Dialog/FilePreview/index.mjs +35 -42
- package/dist/es/Dialog/HistoryItem/index.mjs +48 -53
- package/dist/es/Dialog/KnowledgeList/index.mjs +55 -48
- package/dist/es/Dialog/PromptManager/index.mjs +29 -36
- package/dist/es/Dialog/PromptSetting/index.mjs +53 -66
- package/dist/es/Dialog/SessionAction/index.mjs +92 -91
- package/dist/es/Dialog/SessionList/index.mjs +135 -121
- package/dist/es/Dialog/SessionListDrawer/index.mjs +8 -7
- package/dist/es/Dialog/SessionRefer/ReferItem/index.mjs +29 -36
- package/dist/es/Dialog/SessionRefer/index.mjs +29 -36
- package/dist/es/Dialog/SessionRelated/index.mjs +17 -14
- package/dist/es/Dialog/UploadKnowledgeFiles/index.mjs +125 -132
- package/dist/es/Dialog/index.mjs +125 -93
- package/dist/es/QuillEditor/index.mjs +91 -86
- package/dist/es/_virtual/index.mjs +2 -2
- package/dist/es/components/Markdown/Image/index.mjs +20 -20
- package/dist/es/components/Markdown/index.mjs +27 -22
- package/dist/es/constant.mjs +8 -5
- package/dist/es/index.mjs +178 -152
- package/dist/es/node_modules/classnames/index.mjs +1 -1
- package/dist/es/node_modules/comma-separated-tokens/index.mjs +13 -0
- package/dist/es/node_modules/devlop/lib/default.mjs +5 -0
- package/dist/es/node_modules/hast-util-from-dom/lib/index.mjs +93 -0
- package/dist/es/node_modules/hast-util-from-dom/node_modules/hastscript/lib/create-h.mjs +126 -0
- package/dist/es/node_modules/hast-util-from-dom/node_modules/hastscript/lib/index.mjs +8 -0
- package/dist/es/node_modules/hast-util-from-dom/node_modules/hastscript/lib/svg-case-sensitive-tag-names.mjs +4 -0
- package/dist/es/node_modules/hast-util-from-dom/node_modules/property-information/index.mjs +12 -0
- package/dist/es/node_modules/hast-util-from-dom/node_modules/property-information/lib/aria.mjs +61 -0
- package/dist/es/node_modules/hast-util-from-dom/node_modules/property-information/lib/find.mjs +33 -0
- package/dist/es/node_modules/hast-util-from-dom/node_modules/property-information/lib/html.mjs +368 -0
- package/dist/es/node_modules/hast-util-from-dom/node_modules/property-information/lib/normalize.mjs +6 -0
- package/dist/es/node_modules/hast-util-from-dom/node_modules/property-information/lib/svg.mjs +566 -0
- package/dist/es/node_modules/hast-util-from-dom/node_modules/property-information/lib/util/case-insensitive-transform.mjs +7 -0
- package/dist/es/node_modules/hast-util-from-dom/node_modules/property-information/lib/util/case-sensitive-transform.mjs +6 -0
- package/dist/es/node_modules/hast-util-from-dom/node_modules/property-information/lib/util/create.mjs +14 -0
- package/dist/es/node_modules/hast-util-from-dom/node_modules/property-information/lib/util/defined-info.mjs +36 -0
- package/dist/es/node_modules/hast-util-from-dom/node_modules/property-information/lib/util/info.mjs +28 -0
- package/dist/es/node_modules/hast-util-from-dom/node_modules/property-information/lib/util/merge.mjs +10 -0
- package/dist/es/node_modules/hast-util-from-dom/node_modules/property-information/lib/util/schema.mjs +21 -0
- package/dist/es/node_modules/hast-util-from-dom/node_modules/property-information/lib/util/types.mjs +15 -0
- package/dist/es/node_modules/hast-util-from-dom/node_modules/property-information/lib/xlink.mjs +19 -0
- package/dist/es/node_modules/hast-util-from-dom/node_modules/property-information/lib/xml.mjs +15 -0
- package/dist/es/node_modules/hast-util-from-dom/node_modules/property-information/lib/xmlns.mjs +16 -0
- package/dist/es/node_modules/hast-util-from-html-isomorphic/lib/browser.mjs +16 -0
- package/dist/es/node_modules/hast-util-is-element/lib/index.mjs +61 -0
- package/dist/es/node_modules/hast-util-parse-selector/lib/index.mjs +20 -0
- package/dist/es/node_modules/hast-util-to-text/lib/index.mjs +223 -0
- package/dist/es/node_modules/katex/dist/katex.min.css.mjs +4 -0
- package/dist/es/node_modules/katex/dist/katex.mjs +11700 -0
- package/dist/es/node_modules/longest-streak/index.mjs +12 -0
- package/dist/es/node_modules/mdast-util-math/lib/index.mjs +170 -0
- package/dist/es/node_modules/micromark-extension-math/lib/math-flow.mjs +76 -0
- package/dist/es/node_modules/micromark-extension-math/lib/math-text.mjs +48 -0
- package/dist/es/node_modules/micromark-extension-math/lib/syntax.mjs +15 -0
- package/dist/es/node_modules/micromark-factory-space/index.mjs +15 -0
- package/dist/es/node_modules/micromark-util-character/index.mjs +10 -0
- package/dist/es/node_modules/rehype-katex/lib/index.mjs +83 -0
- package/dist/es/node_modules/remark-math/lib/index.mjs +13 -0
- package/dist/es/node_modules/space-separated-tokens/index.mjs +7 -0
- package/dist/es/node_modules/unist-util-find-after/lib/index.mjs +32 -0
- package/dist/es/node_modules/unist-util-is/lib/index.mjs +81 -0
- package/dist/es/node_modules/unist-util-visit-parents/lib/color.mjs +6 -0
- package/dist/es/node_modules/unist-util-visit-parents/lib/index.mjs +56 -0
- package/dist/es/node_modules/web-namespaces/index.mjs +11 -0
- package/dist/es/utils/index.mjs +44 -27
- package/dist/lib/index.js +278 -138
- package/dist/src/Dialog/AgentChat/index.d.ts +4 -2
- package/dist/src/Dialog/ConnectToNetwork/index.d.ts +1 -0
- package/dist/src/Dialog/KnowledgeList/KnowledgeSelect/index.d.ts +1 -1
- package/dist/src/Dialog/KnowledgeList/index.d.ts +2 -3
- package/dist/src/Dialog/PromptSetting/index.d.ts +1 -0
- package/dist/src/Dialog/SessionAction/index.d.ts +2 -0
- package/dist/src/Dialog/SessionList/index.d.ts +5 -4
- package/dist/src/QuillEditor/index.d.ts +1 -0
- package/dist/src/components/Markdown/Text/index.d.ts +8 -0
- package/dist/src/components/MathJaxLoader/index.d.ts +7 -0
- package/dist/src/components/MathJaxRender/index.d.ts +6 -0
- package/dist/src/constant.d.ts +1 -1
- package/dist/src/contexts/MathJaxContext.d.ts +12 -0
- package/dist/src/index.d.ts +4 -1
- package/dist/src/types.d.ts +26 -6
- package/dist/src/utils/index.d.ts +15 -0
- package/package.json +18 -17
- package/dist/es/_virtual/index2.mjs +0 -4
- package/dist/es/_virtual/index3.mjs +0 -4
- package/dist/es/_virtual/index4.mjs +0 -4
- package/dist/es/_virtual/minio-zj.mjs +0 -4
- package/dist/es/node_modules/@glodon-aiot/minio/dist/minio-zj.mjs +0 -26485
- package/dist/es/node_modules/@socket.io/component-emitter/lib/esm/index.mjs +0 -54
- package/dist/es/node_modules/base64-js/index.mjs +0 -47
- package/dist/es/node_modules/buffer/index.mjs +0 -927
- package/dist/es/node_modules/engine.io-client/build/esm/contrib/has-cors.mjs +0 -9
- package/dist/es/node_modules/engine.io-client/build/esm/contrib/parseqs.mjs +0 -18
- package/dist/es/node_modules/engine.io-client/build/esm/contrib/parseuri.mjs +0 -24
- package/dist/es/node_modules/engine.io-client/build/esm/contrib/yeast.mjs +0 -19
- package/dist/es/node_modules/engine.io-client/build/esm/globalThis.browser.mjs +0 -4
- package/dist/es/node_modules/engine.io-client/build/esm/socket.mjs +0 -317
- package/dist/es/node_modules/engine.io-client/build/esm/transport.mjs +0 -113
- package/dist/es/node_modules/engine.io-client/build/esm/transports/index.mjs +0 -11
- package/dist/es/node_modules/engine.io-client/build/esm/transports/polling.mjs +0 -273
- package/dist/es/node_modules/engine.io-client/build/esm/transports/websocket-constructor.browser.mjs +0 -8
- package/dist/es/node_modules/engine.io-client/build/esm/transports/websocket.mjs +0 -87
- package/dist/es/node_modules/engine.io-client/build/esm/transports/webtransport.mjs +0 -52
- package/dist/es/node_modules/engine.io-client/build/esm/transports/xmlhttprequest.browser.mjs +0 -21
- package/dist/es/node_modules/engine.io-client/build/esm/util.mjs +0 -23
- package/dist/es/node_modules/engine.io-parser/build/esm/commons.mjs +0 -21
- package/dist/es/node_modules/engine.io-parser/build/esm/contrib/base64-arraybuffer.mjs +0 -14
- package/dist/es/node_modules/engine.io-parser/build/esm/decodePacket.browser.mjs +0 -39
- package/dist/es/node_modules/engine.io-parser/build/esm/encodePacket.browser.mjs +0 -28
- package/dist/es/node_modules/engine.io-parser/build/esm/index.mjs +0 -105
- package/dist/es/node_modules/ieee754/index.mjs +0 -28
- package/dist/es/node_modules/js-base64/base64.mjs +0 -31
- package/dist/es/node_modules/socket.io-client/build/esm/contrib/backo2.mjs +0 -26
- package/dist/es/node_modules/socket.io-client/build/esm/index.mjs +0 -25
- package/dist/es/node_modules/socket.io-client/build/esm/manager.mjs +0 -242
- package/dist/es/node_modules/socket.io-client/build/esm/on.mjs +0 -8
- package/dist/es/node_modules/socket.io-client/build/esm/socket.mjs +0 -608
- package/dist/es/node_modules/socket.io-client/build/esm/url.mjs +0 -19
- package/dist/es/node_modules/socket.io-parser/build/esm/binary.mjs +0 -52
- package/dist/es/node_modules/socket.io-parser/build/esm/index.mjs +0 -203
- package/dist/es/node_modules/socket.io-parser/build/esm/is-binary.mjs +0 -26
- package/dist/es/packages/agent-cli-sdk/src/AgentSession.mjs +0 -243
- package/dist/es/packages/agent-cli-sdk/src/BotClient.mjs +0 -242
- package/dist/es/packages/agent-cli-sdk/src/Config.mjs +0 -34
- package/dist/es/packages/agent-cli-sdk/src/DialogSession.mjs +0 -281
- package/dist/es/packages/agent-cli-sdk/src/EventBus.mjs +0 -64
- package/dist/es/packages/agent-cli-sdk/src/Logger.mjs +0 -31
- package/dist/es/packages/agent-cli-sdk/src/PayloadTypes.mjs +0 -4
- package/dist/es/packages/agent-cli-sdk/src/Session.mjs +0 -527
- package/dist/es/packages/agent-cli-sdk/src/api/fetchEventSource/fetch.mjs +0 -112
- package/dist/es/packages/agent-cli-sdk/src/api/fetchEventSource/parse.mjs +0 -97
- package/dist/es/packages/agent-cli-sdk/src/api/index.mjs +0 -48
- package/dist/es/packages/agent-cli-sdk/src/utils.mjs +0 -11
- package/dist/es/packages/apis/dist/es/aecpilot/cosntant.mjs +0 -5
- package/dist/es/packages/apis/dist/es/aecpilot/model.mjs +0 -9
- package/dist/es/packages/apis/dist/es/aecpilotui/index.mjs +0 -8
- package/dist/es/packages/apis/dist/es/agentcliui/index.mjs +0 -414
- package/dist/es/packages/apis/dist/es/base/index.mjs +0 -154
- package/dist/es/packages/apis/dist/es/cvforce/index.mjs +0 -431
- package/dist/es/packages/apis/dist/es/cvforce/model.mjs +0 -6
- package/dist/es/packages/apis/dist/es/node_modules/uuid/dist/esm-browser/native.mjs +0 -6
- package/dist/es/packages/apis/dist/es/node_modules/uuid/dist/esm-browser/rng.mjs +0 -10
- package/dist/es/packages/apis/dist/es/node_modules/uuid/dist/esm-browser/stringify.mjs +0 -9
- package/dist/es/packages/apis/dist/es/node_modules/uuid/dist/esm-browser/v4.mjs +0 -19
- package/dist/es/packages/apis/dist/es/utils/fetchEventSource/fetch.mjs +0 -106
- package/dist/es/packages/apis/dist/es/utils/fetchEventSource/parse.mjs +0 -97
package/dist/es/node_modules/hast-util-from-dom/node_modules/property-information/lib/xlink.mjs
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { create as n } from "./util/create.mjs";
|
|
2
|
+
const r = n({
|
|
3
|
+
properties: {
|
|
4
|
+
xLinkActuate: null,
|
|
5
|
+
xLinkArcRole: null,
|
|
6
|
+
xLinkHref: null,
|
|
7
|
+
xLinkRole: null,
|
|
8
|
+
xLinkShow: null,
|
|
9
|
+
xLinkTitle: null,
|
|
10
|
+
xLinkType: null
|
|
11
|
+
},
|
|
12
|
+
space: "xlink",
|
|
13
|
+
transform(e, l) {
|
|
14
|
+
return "xlink:" + l.slice(5).toLowerCase();
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
export {
|
|
18
|
+
r as xlink
|
|
19
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { create as e } from "./util/create.mjs";
|
|
2
|
+
const o = e({
|
|
3
|
+
properties: {
|
|
4
|
+
xmlBase: null,
|
|
5
|
+
xmlLang: null,
|
|
6
|
+
xmlSpace: null
|
|
7
|
+
},
|
|
8
|
+
space: "xml",
|
|
9
|
+
transform(r, l) {
|
|
10
|
+
return "xml:" + l.slice(3).toLowerCase();
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
export {
|
|
14
|
+
o as xml
|
|
15
|
+
};
|
package/dist/es/node_modules/hast-util-from-dom/node_modules/property-information/lib/xmlns.mjs
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { create as n } from "./util/create.mjs";
|
|
2
|
+
import { caseInsensitiveTransform as s } from "./util/case-insensitive-transform.mjs";
|
|
3
|
+
const m = n({
|
|
4
|
+
attributes: {
|
|
5
|
+
xmlnsxlink: "xmlns:xlink"
|
|
6
|
+
},
|
|
7
|
+
properties: {
|
|
8
|
+
xmlnsXLink: null,
|
|
9
|
+
xmlns: null
|
|
10
|
+
},
|
|
11
|
+
space: "xmlns",
|
|
12
|
+
transform: s
|
|
13
|
+
});
|
|
14
|
+
export {
|
|
15
|
+
m as xmlns
|
|
16
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { fromDom as n } from "../../hast-util-from-dom/lib/index.mjs";
|
|
2
|
+
const m = new DOMParser();
|
|
3
|
+
function a(r, e) {
|
|
4
|
+
const t = e != null && e.fragment ? c(r) : m.parseFromString(r, "text/html");
|
|
5
|
+
return (
|
|
6
|
+
/** @type {Root} */
|
|
7
|
+
n(t)
|
|
8
|
+
);
|
|
9
|
+
}
|
|
10
|
+
function c(r) {
|
|
11
|
+
const e = document.createElement("template");
|
|
12
|
+
return e.innerHTML = r, e.content;
|
|
13
|
+
}
|
|
14
|
+
export {
|
|
15
|
+
a as fromHtmlIsomorphic
|
|
16
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
const f = (
|
|
2
|
+
// Note: overloads in JSDoc can’t yet use different `@template`s.
|
|
3
|
+
/**
|
|
4
|
+
* @type {(
|
|
5
|
+
* (<Condition extends TestFunction>(test: Condition) => (element: unknown, index?: number | null | undefined, parent?: Parents | null | undefined, context?: unknown) => element is Element & Predicate<Condition, Element>) &
|
|
6
|
+
* (<Condition extends string>(test: Condition) => (element: unknown, index?: number | null | undefined, parent?: Parents | null | undefined, context?: unknown) => element is Element & {tagName: Condition}) &
|
|
7
|
+
* ((test?: null | undefined) => (element?: unknown, index?: number | null | undefined, parent?: Parents | null | undefined, context?: unknown) => element is Element) &
|
|
8
|
+
* ((test?: Test) => Check)
|
|
9
|
+
* )}
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* @param {Test | null | undefined} [test]
|
|
13
|
+
* @returns {Check}
|
|
14
|
+
*/
|
|
15
|
+
function(n) {
|
|
16
|
+
if (n == null)
|
|
17
|
+
return y;
|
|
18
|
+
if (typeof n == "string")
|
|
19
|
+
return a(n);
|
|
20
|
+
if (typeof n == "object")
|
|
21
|
+
return u(n);
|
|
22
|
+
if (typeof n == "function")
|
|
23
|
+
return i(n);
|
|
24
|
+
throw new Error("Expected function, string, or array as `test`");
|
|
25
|
+
}
|
|
26
|
+
);
|
|
27
|
+
function u(n) {
|
|
28
|
+
const r = [];
|
|
29
|
+
let t = -1;
|
|
30
|
+
for (; ++t < n.length; )
|
|
31
|
+
r[t] = f(n[t]);
|
|
32
|
+
return i(e);
|
|
33
|
+
function e(...o) {
|
|
34
|
+
let c = -1;
|
|
35
|
+
for (; ++c < r.length; )
|
|
36
|
+
if (r[c].apply(this, o))
|
|
37
|
+
return !0;
|
|
38
|
+
return !1;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function a(n) {
|
|
42
|
+
return i(r);
|
|
43
|
+
function r(t) {
|
|
44
|
+
return t.tagName === n;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
function i(n) {
|
|
48
|
+
return r;
|
|
49
|
+
function r(t, e, o) {
|
|
50
|
+
return !!(p(t) && n.call(this, t, typeof e == "number" ? e : void 0, o || void 0));
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
function y(n) {
|
|
54
|
+
return !!(n && typeof n == "object" && "type" in n && n.type === "element" && "tagName" in n && typeof n.tagName == "string");
|
|
55
|
+
}
|
|
56
|
+
function p(n) {
|
|
57
|
+
return n !== null && typeof n == "object" && "type" in n && "tagName" in n;
|
|
58
|
+
}
|
|
59
|
+
export {
|
|
60
|
+
f as convertElement
|
|
61
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const i = /[#.]/g;
|
|
2
|
+
function p(n, o) {
|
|
3
|
+
const l = n || "", s = {};
|
|
4
|
+
let t = 0, r, c;
|
|
5
|
+
for (; t < l.length; ) {
|
|
6
|
+
i.lastIndex = t;
|
|
7
|
+
const a = i.exec(l), e = l.slice(t, a ? a.index : l.length);
|
|
8
|
+
e && (r ? r === "#" ? s.id = e : Array.isArray(s.className) ? s.className.push(e) : s.className = [e] : c = e, t += e.length), a && (r = a[0], t++);
|
|
9
|
+
}
|
|
10
|
+
return {
|
|
11
|
+
type: "element",
|
|
12
|
+
// @ts-expect-error: tag name is parsed.
|
|
13
|
+
tagName: c || o || "div",
|
|
14
|
+
properties: s,
|
|
15
|
+
children: []
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
export {
|
|
19
|
+
p as parseSelector
|
|
20
|
+
};
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import { convertElement as p } from "../../hast-util-is-element/lib/index.mjs";
|
|
2
|
+
import { findAfter as f } from "../../unist-util-find-after/lib/index.mjs";
|
|
3
|
+
const d = /\n/g, g = /[\t ]+/g, h = p("br"), m = p(N), y = p("p"), x = p("tr"), C = p([
|
|
4
|
+
// List from: <https://html.spec.whatwg.org/multipage/rendering.html#hidden-elements>
|
|
5
|
+
"datalist",
|
|
6
|
+
"head",
|
|
7
|
+
"noembed",
|
|
8
|
+
"noframes",
|
|
9
|
+
"noscript",
|
|
10
|
+
// Act as if we support scripting.
|
|
11
|
+
"rp",
|
|
12
|
+
"script",
|
|
13
|
+
"style",
|
|
14
|
+
"template",
|
|
15
|
+
"title",
|
|
16
|
+
// Hidden attribute.
|
|
17
|
+
E,
|
|
18
|
+
// From: <https://html.spec.whatwg.org/multipage/rendering.html#flow-content-3>
|
|
19
|
+
S
|
|
20
|
+
]), b = p([
|
|
21
|
+
"address",
|
|
22
|
+
// Flow content
|
|
23
|
+
"article",
|
|
24
|
+
// Sections and headings
|
|
25
|
+
"aside",
|
|
26
|
+
// Sections and headings
|
|
27
|
+
"blockquote",
|
|
28
|
+
// Flow content
|
|
29
|
+
"body",
|
|
30
|
+
// Page
|
|
31
|
+
"caption",
|
|
32
|
+
// `table-caption`
|
|
33
|
+
"center",
|
|
34
|
+
// Flow content (legacy)
|
|
35
|
+
"dd",
|
|
36
|
+
// Lists
|
|
37
|
+
"dialog",
|
|
38
|
+
// Flow content
|
|
39
|
+
"dir",
|
|
40
|
+
// Lists (legacy)
|
|
41
|
+
"dl",
|
|
42
|
+
// Lists
|
|
43
|
+
"dt",
|
|
44
|
+
// Lists
|
|
45
|
+
"div",
|
|
46
|
+
// Flow content
|
|
47
|
+
"figure",
|
|
48
|
+
// Flow content
|
|
49
|
+
"figcaption",
|
|
50
|
+
// Flow content
|
|
51
|
+
"footer",
|
|
52
|
+
// Flow content
|
|
53
|
+
"form,",
|
|
54
|
+
// Flow content
|
|
55
|
+
"h1",
|
|
56
|
+
// Sections and headings
|
|
57
|
+
"h2",
|
|
58
|
+
// Sections and headings
|
|
59
|
+
"h3",
|
|
60
|
+
// Sections and headings
|
|
61
|
+
"h4",
|
|
62
|
+
// Sections and headings
|
|
63
|
+
"h5",
|
|
64
|
+
// Sections and headings
|
|
65
|
+
"h6",
|
|
66
|
+
// Sections and headings
|
|
67
|
+
"header",
|
|
68
|
+
// Flow content
|
|
69
|
+
"hgroup",
|
|
70
|
+
// Sections and headings
|
|
71
|
+
"hr",
|
|
72
|
+
// Flow content
|
|
73
|
+
"html",
|
|
74
|
+
// Page
|
|
75
|
+
"legend",
|
|
76
|
+
// Flow content
|
|
77
|
+
"li",
|
|
78
|
+
// Lists (as `display: list-item`)
|
|
79
|
+
"listing",
|
|
80
|
+
// Flow content (legacy)
|
|
81
|
+
"main",
|
|
82
|
+
// Flow content
|
|
83
|
+
"menu",
|
|
84
|
+
// Lists
|
|
85
|
+
"nav",
|
|
86
|
+
// Sections and headings
|
|
87
|
+
"ol",
|
|
88
|
+
// Lists
|
|
89
|
+
"p",
|
|
90
|
+
// Flow content
|
|
91
|
+
"plaintext",
|
|
92
|
+
// Flow content (legacy)
|
|
93
|
+
"pre",
|
|
94
|
+
// Flow content
|
|
95
|
+
"section",
|
|
96
|
+
// Sections and headings
|
|
97
|
+
"ul",
|
|
98
|
+
// Lists
|
|
99
|
+
"xmp"
|
|
100
|
+
// Flow content (legacy)
|
|
101
|
+
]);
|
|
102
|
+
function F(e, a) {
|
|
103
|
+
const l = a || {}, n = "children" in e ? e.children : [], i = b(e), r = A(e, {
|
|
104
|
+
whitespace: l.whitespace || "normal",
|
|
105
|
+
breakBefore: !1,
|
|
106
|
+
breakAfter: !1
|
|
107
|
+
}), t = [];
|
|
108
|
+
(e.type === "text" || e.type === "comment") && t.push(...k(e, {
|
|
109
|
+
whitespace: r,
|
|
110
|
+
breakBefore: !0,
|
|
111
|
+
breakAfter: !0
|
|
112
|
+
}));
|
|
113
|
+
let s = -1;
|
|
114
|
+
for (; ++s < n.length; )
|
|
115
|
+
t.push(...w(
|
|
116
|
+
n[s],
|
|
117
|
+
// @ts-expect-error: `tree` is a parent if we’re here.
|
|
118
|
+
e,
|
|
119
|
+
{
|
|
120
|
+
whitespace: r,
|
|
121
|
+
breakBefore: s ? void 0 : i,
|
|
122
|
+
breakAfter: s < n.length - 1 ? h(n[s + 1]) : i
|
|
123
|
+
}
|
|
124
|
+
));
|
|
125
|
+
const c = [];
|
|
126
|
+
let o;
|
|
127
|
+
for (s = -1; ++s < t.length; ) {
|
|
128
|
+
const u = t[s];
|
|
129
|
+
typeof u == "number" ? o !== void 0 && u > o && (o = u) : u && (o !== void 0 && o > -1 && c.push(`
|
|
130
|
+
`.repeat(o) || " "), o = -1, c.push(u));
|
|
131
|
+
}
|
|
132
|
+
return c.join("");
|
|
133
|
+
}
|
|
134
|
+
function w(e, a, l) {
|
|
135
|
+
return e.type === "element" ? B(e, a, l) : e.type === "text" ? l.whitespace === "normal" ? k(e, l) : T(e) : [];
|
|
136
|
+
}
|
|
137
|
+
function B(e, a, l) {
|
|
138
|
+
const n = A(e, l), i = e.children || [];
|
|
139
|
+
let r = -1, t = [];
|
|
140
|
+
if (C(e))
|
|
141
|
+
return t;
|
|
142
|
+
let s, c;
|
|
143
|
+
for (h(e) || x(e) && // @ts-expect-error: something up with types of parents.
|
|
144
|
+
f(a, e, x) ? c = `
|
|
145
|
+
` : y(e) ? (s = 2, c = 2) : b(e) && (s = 1, c = 1); ++r < i.length; )
|
|
146
|
+
t = t.concat(w(i[r], e, {
|
|
147
|
+
whitespace: n,
|
|
148
|
+
breakBefore: r ? void 0 : s,
|
|
149
|
+
breakAfter: r < i.length - 1 ? h(i[r + 1]) : c
|
|
150
|
+
}));
|
|
151
|
+
return m(e) && // @ts-expect-error: something up with types of parents.
|
|
152
|
+
f(a, e, m) && t.push(" "), s && t.unshift(s), c && t.push(c), t;
|
|
153
|
+
}
|
|
154
|
+
function k(e, a) {
|
|
155
|
+
const l = String(e.value), n = [], i = [];
|
|
156
|
+
let r = 0;
|
|
157
|
+
for (; r <= l.length; ) {
|
|
158
|
+
d.lastIndex = r;
|
|
159
|
+
const c = d.exec(l), o = c && "index" in c ? c.index : l.length;
|
|
160
|
+
n.push(
|
|
161
|
+
// Any sequence of collapsible spaces and tabs immediately preceding or
|
|
162
|
+
// following a segment break is removed.
|
|
163
|
+
v(
|
|
164
|
+
// […] ignoring bidi formatting characters (characters with the
|
|
165
|
+
// Bidi_Control property [UAX9]: ALM, LTR, RTL, LRE-RLO, LRI-PDI) as if
|
|
166
|
+
// they were not there.
|
|
167
|
+
l.slice(r, o).replace(/[\u061C\u200E\u200F\u202A-\u202E\u2066-\u2069]/g, ""),
|
|
168
|
+
r === 0 ? a.breakBefore : !0,
|
|
169
|
+
o === l.length ? a.breakAfter : !0
|
|
170
|
+
)
|
|
171
|
+
), r = o + 1;
|
|
172
|
+
}
|
|
173
|
+
let t = -1, s;
|
|
174
|
+
for (; ++t < n.length; )
|
|
175
|
+
n[t].charCodeAt(n[t].length - 1) === 8203 || t < n.length - 1 && n[t + 1].charCodeAt(0) === 8203 ? (i.push(n[t]), s = void 0) : n[t] ? (typeof s == "number" && i.push(s), i.push(n[t]), s = 0) : (t === 0 || t === n.length - 1) && i.push(0);
|
|
176
|
+
return i;
|
|
177
|
+
}
|
|
178
|
+
function T(e) {
|
|
179
|
+
return [String(e.value)];
|
|
180
|
+
}
|
|
181
|
+
function v(e, a, l) {
|
|
182
|
+
const n = [];
|
|
183
|
+
let i = 0, r;
|
|
184
|
+
for (; i < e.length; ) {
|
|
185
|
+
g.lastIndex = i;
|
|
186
|
+
const t = g.exec(e);
|
|
187
|
+
r = t ? t.index : e.length, !i && !r && t && !a && n.push(""), i !== r && n.push(e.slice(i, r)), i = t ? r + t[0].length : r;
|
|
188
|
+
}
|
|
189
|
+
return i !== r && !l && n.push(""), n.join(" ");
|
|
190
|
+
}
|
|
191
|
+
function A(e, a) {
|
|
192
|
+
if (e.type === "element") {
|
|
193
|
+
const l = e.properties || {};
|
|
194
|
+
switch (e.tagName) {
|
|
195
|
+
case "listing":
|
|
196
|
+
case "plaintext":
|
|
197
|
+
case "xmp":
|
|
198
|
+
return "pre";
|
|
199
|
+
case "nobr":
|
|
200
|
+
return "nowrap";
|
|
201
|
+
case "pre":
|
|
202
|
+
return l.wrap ? "pre-wrap" : "pre";
|
|
203
|
+
case "td":
|
|
204
|
+
case "th":
|
|
205
|
+
return l.noWrap ? "nowrap" : a.whitespace;
|
|
206
|
+
case "textarea":
|
|
207
|
+
return "pre-wrap";
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
return a.whitespace;
|
|
211
|
+
}
|
|
212
|
+
function E(e) {
|
|
213
|
+
return !!(e.properties || {}).hidden;
|
|
214
|
+
}
|
|
215
|
+
function N(e) {
|
|
216
|
+
return e.tagName === "td" || e.tagName === "th";
|
|
217
|
+
}
|
|
218
|
+
function S(e) {
|
|
219
|
+
return e.tagName === "dialog" && !(e.properties || {}).open;
|
|
220
|
+
}
|
|
221
|
+
export {
|
|
222
|
+
F as toText
|
|
223
|
+
};
|