markdown-flow-ui 0.1.83-beta.1 → 0.1.83-beta.2
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/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/@braintree_sanitize-url@7.1.1/node_modules/@braintree/sanitize-url/dist/index.js +1 -1
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/classnames@2.5.1/node_modules/classnames/index.js +1 -1
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/c4Diagram-YG6GDRKO.js +1 -1
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/chunk-S3R3BYOJ.js +1 -1
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/chunk-TZMSLE5B.js +1 -1
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/ganttDiagram-LVOFAZNH.js +1 -1
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/sequenceDiagram-WL72ISMW.js +1 -1
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rc-input@1.8.0_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-input/es/BaseInput.js +1 -1
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rc-textarea@1.10.2_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-textarea/es/ResizableTextArea.js +1 -1
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rc-textarea@1.10.2_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-textarea/es/TextArea.js +1 -1
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rc-textarea@1.10.2_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-textarea/es/index.js +1 -1
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/remark-flow@0.1.6/node_modules/remark-flow/dist/index.js +1 -1
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/remark-flow@0.1.6/node_modules/remark-flow/dist/remark-custom-variable.js +1 -1
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/remark-flow@0.1.6/node_modules/remark-flow/dist/remark-interaction.js +1 -1
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/style-to-object@1.0.11/node_modules/style-to-object/cjs/index.js +1 -1
- package/dist/_virtual/index10.js +2 -2
- package/dist/_virtual/index2.js +2 -5
- package/dist/_virtual/index2.js.map +1 -1
- package/dist/_virtual/index3.js +4 -2
- package/dist/_virtual/index3.js.map +1 -1
- package/dist/_virtual/index4.js +5 -4
- package/dist/_virtual/index4.js.map +1 -1
- package/dist/_virtual/index7.js +3 -2
- package/dist/_virtual/index7.js.map +1 -1
- package/dist/_virtual/index8.js +2 -3
- package/dist/_virtual/index8.js.map +1 -1
- package/dist/components/ContentRender/IframeSandbox.js +26 -27
- package/dist/components/ContentRender/IframeSandbox.js.map +1 -1
- package/dist/components/ContentRender/SandboxApp.d.ts +0 -1
- package/dist/components/ContentRender/SandboxApp.js +79 -120
- package/dist/components/ContentRender/SandboxApp.js.map +1 -1
- package/dist/components/ui/inputGroup/textarea.js +1 -1
- package/package.json +1 -1
|
@@ -4,7 +4,7 @@ import { setAccDescription as Be, getAccDescription as Ie, getAccTitle as Me, se
|
|
|
4
4
|
import { __name as g, log as fe } from "./chunk-AGHRB4JF.js";
|
|
5
5
|
import "../../../../../../d3-transition@3.0.1_d3-selection@3.0.0/node_modules/d3-transition/src/selection/index.js";
|
|
6
6
|
import "../../../../../../d3-zoom@3.0.0/node_modules/d3-zoom/src/transform.js";
|
|
7
|
-
import { d as je } from "../../../../../../../../../../../_virtual/
|
|
7
|
+
import { d as je } from "../../../../../../../../../../../_virtual/index7.js";
|
|
8
8
|
import jt from "../../../../../../d3-selection@3.0.0/node_modules/d3-selection/src/select.js";
|
|
9
9
|
var Ft = (function() {
|
|
10
10
|
var e = /* @__PURE__ */ g(function(_t, x, m, v) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { common_default as b, assignWithDepth_default as E, directiveRegex as $, sanitizeDirective as X, detectType as Y } from "./chunk-ABZYJK2D.js";
|
|
2
2
|
import { __name as s, log as g } from "./chunk-AGHRB4JF.js";
|
|
3
|
-
import { d as G } from "../../../../../../../../../../../_virtual/
|
|
3
|
+
import { d as G } from "../../../../../../../../../../../_virtual/index7.js";
|
|
4
4
|
import "../../../../../../d3-transition@3.0.1_d3-selection@3.0.0/node_modules/d3-transition/src/selection/index.js";
|
|
5
5
|
import "../../../../../../d3-zoom@3.0.0/node_modules/d3-zoom/src/transform.js";
|
|
6
6
|
import w from "../../../../../../lodash-es@4.17.21/node_modules/lodash-es/memoize.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { lineBreakRegex as o } from "./chunk-ABZYJK2D.js";
|
|
2
2
|
import { __name as n } from "./chunk-AGHRB4JF.js";
|
|
3
|
-
import { d as l } from "../../../../../../../../../../../_virtual/
|
|
3
|
+
import { d as l } from "../../../../../../../../../../../_virtual/index7.js";
|
|
4
4
|
var x = /* @__PURE__ */ n((s, t) => {
|
|
5
5
|
const r = s.append("rect");
|
|
6
6
|
if (r.attr("x", t.x), r.attr("y", t.y), r.attr("fill", t.fill), r.attr("stroke", t.stroke), r.attr("width", t.width), r.attr("height", t.height), t.name && r.attr("name", t.name), t.rx && r.attr("rx", t.rx), t.ry && r.attr("ry", t.ry), t.attrs !== void 0)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { utils_default as ie } from "./chunk-S3R3BYOJ.js";
|
|
2
2
|
import { getAccDescription as se, setAccDescription as ne, getDiagramTitle as ae, setDiagramTitle as oe, getAccTitle as ce, setAccTitle as le, getConfig2 as K, configureSvgSize as ue, common_default as de, clear as fe } from "./chunk-ABZYJK2D.js";
|
|
3
3
|
import { __name as c, log as mt } from "./chunk-AGHRB4JF.js";
|
|
4
|
-
import { d as he } from "../../../../../../../../../../../_virtual/
|
|
4
|
+
import { d as he } from "../../../../../../../../../../../_virtual/index7.js";
|
|
5
5
|
import L from "../../../../../../../../../../../_virtual/dayjs.min.js";
|
|
6
6
|
import me from "../../../../../../../../../../../_virtual/isoWeek.js";
|
|
7
7
|
import ke from "../../../../../../../../../../../_virtual/customParseFormat.js";
|
|
@@ -6,7 +6,7 @@ import { setConfig2 as ke, getConfig2 as st, configureSvgSize as Pe, assignWithD
|
|
|
6
6
|
import { __name as f, log as Q } from "./chunk-AGHRB4JF.js";
|
|
7
7
|
import "../../../../../../d3-transition@3.0.1_d3-selection@3.0.0/node_modules/d3-transition/src/selection/index.js";
|
|
8
8
|
import "../../../../../../d3-zoom@3.0.0/node_modules/d3-zoom/src/transform.js";
|
|
9
|
-
import { d as ne } from "../../../../../../../../../../../_virtual/
|
|
9
|
+
import { d as ne } from "../../../../../../../../../../../_virtual/index7.js";
|
|
10
10
|
import Mt from "../../../../../../d3-selection@3.0.0/node_modules/d3-selection/src/select.js";
|
|
11
11
|
var Ut = (function() {
|
|
12
12
|
var e = /* @__PURE__ */ f(function(pt, v, A, L) {
|
|
@@ -2,7 +2,7 @@ import $ from "../../../../@babel_runtime@7.28.4/node_modules/@babel/runtime/hel
|
|
|
2
2
|
import oe from "../../../../@babel_runtime@7.28.4/node_modules/@babel/runtime/helpers/esm/extends.js";
|
|
3
3
|
import r from "../../../../@babel_runtime@7.28.4/node_modules/@babel/runtime/helpers/esm/defineProperty.js";
|
|
4
4
|
import te from "../../../../@babel_runtime@7.28.4/node_modules/@babel/runtime/helpers/esm/typeof.js";
|
|
5
|
-
import d from "../../../../../../../../../_virtual/
|
|
5
|
+
import d from "../../../../../../../../../_virtual/index4.js";
|
|
6
6
|
import l, { useRef as q, cloneElement as ie } from "react";
|
|
7
7
|
import { hasPrefixSuffix as re, hasAddon as de } from "./utils/commonUtils.js";
|
|
8
8
|
var xe = /* @__PURE__ */ l.forwardRef(function(e, z) {
|
|
@@ -4,7 +4,7 @@ import w from "../../../../@babel_runtime@7.28.4/node_modules/@babel/runtime/hel
|
|
|
4
4
|
import J from "../../../../@babel_runtime@7.28.4/node_modules/@babel/runtime/helpers/esm/typeof.js";
|
|
5
5
|
import s from "../../../../@babel_runtime@7.28.4/node_modules/@babel/runtime/helpers/esm/slicedToArray.js";
|
|
6
6
|
import K from "../../../../@babel_runtime@7.28.4/node_modules/@babel/runtime/helpers/esm/objectWithoutProperties.js";
|
|
7
|
-
import Q from "../../../../../../../../../_virtual/
|
|
7
|
+
import Q from "../../../../../../../../../_virtual/index4.js";
|
|
8
8
|
import ee from "../../../../rc-resize-observer@1.4.3_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-resize-observer/es/index.js";
|
|
9
9
|
import M from "../../../../rc-util@5.44.4_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-util/es/hooks/useLayoutEffect.js";
|
|
10
10
|
import te from "../../../../rc-util@5.44.4_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-util/es/hooks/useMergedState.js";
|
|
@@ -4,7 +4,7 @@ import d from "../../../../@babel_runtime@7.28.4/node_modules/@babel/runtime/hel
|
|
|
4
4
|
import Ae from "../../../../@babel_runtime@7.28.4/node_modules/@babel/runtime/helpers/esm/toConsumableArray.js";
|
|
5
5
|
import x from "../../../../@babel_runtime@7.28.4/node_modules/@babel/runtime/helpers/esm/slicedToArray.js";
|
|
6
6
|
import Fe from "../../../../@babel_runtime@7.28.4/node_modules/@babel/runtime/helpers/esm/objectWithoutProperties.js";
|
|
7
|
-
import h from "../../../../../../../../../_virtual/
|
|
7
|
+
import h from "../../../../../../../../../_virtual/index4.js";
|
|
8
8
|
import Ne from "../../../../rc-input@1.8.0_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-input/es/BaseInput.js";
|
|
9
9
|
import Te from "../../../../rc-util@5.44.4_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-util/es/hooks/useMergedState.js";
|
|
10
10
|
import o, { useRef as Y, useImperativeHandle as $e, useEffect as Ie } from "react";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import t from "./TextArea.js";
|
|
2
|
-
import "../../../../../../../../../_virtual/
|
|
2
|
+
import "../../../../../../../../../_virtual/index4.js";
|
|
3
3
|
import "../../../../rc-resize-observer@1.4.3_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-resize-observer/es/index.js";
|
|
4
4
|
import "../../../../rc-util@5.44.4_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-util/es/hooks/useLayoutEffect.js";
|
|
5
5
|
import "react";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __exports as e } from "../../../../../../../../../_virtual/
|
|
1
|
+
import { __exports as e } from "../../../../../../../../../_virtual/index2.js";
|
|
2
2
|
import { __require as _ } from "./remark-custom-variable.js";
|
|
3
3
|
import { __require as m } from "./remark-flow.js";
|
|
4
4
|
import { __require as f } from "./remark-interaction.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __exports as a } from "../../../../../../../../../_virtual/remark-custom-variable.js";
|
|
2
|
-
import g from "../../../../../../../../../_virtual/
|
|
2
|
+
import g from "../../../../../../../../../_virtual/index3.js";
|
|
3
3
|
import { __require as h } from "./interaction-parser.js";
|
|
4
4
|
var m;
|
|
5
5
|
function C() {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __exports as n } from "../../../../../../../../../_virtual/remark-interaction.js";
|
|
2
|
-
import I from "../../../../../../../../../_virtual/
|
|
2
|
+
import I from "../../../../../../../../../_virtual/index3.js";
|
|
3
3
|
import { __require as g } from "./interaction-parser.js";
|
|
4
4
|
var m;
|
|
5
5
|
function k() {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __exports as r } from "../../../../../../../../../_virtual/
|
|
1
|
+
import { __exports as r } from "../../../../../../../../../_virtual/index8.js";
|
|
2
2
|
import { __require as p } from "../../../../inline-style-parser@0.2.4/node_modules/inline-style-parser/index.js";
|
|
3
3
|
var f;
|
|
4
4
|
function q() {
|
package/dist/_virtual/index10.js
CHANGED
package/dist/_virtual/index2.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
import { __require as s } from "../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/classnames@2.5.1/node_modules/classnames/index.js";
|
|
3
|
-
var e = s();
|
|
4
|
-
const t = /* @__PURE__ */ r(e);
|
|
1
|
+
var r = {};
|
|
5
2
|
export {
|
|
6
|
-
|
|
3
|
+
r as __exports
|
|
7
4
|
};
|
|
8
5
|
//# sourceMappingURL=index2.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index2.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index2.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
package/dist/_virtual/index3.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import { getAugmentedNamespace as e } from "./_commonjsHelpers.js";
|
|
2
|
+
import * as r from "../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/unist-util-visit@5.0.0/node_modules/unist-util-visit/index.js";
|
|
3
|
+
const m = /* @__PURE__ */ e(r);
|
|
2
4
|
export {
|
|
3
|
-
|
|
5
|
+
m as default
|
|
4
6
|
};
|
|
5
7
|
//# sourceMappingURL=index3.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index3.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index3.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}
|
package/dist/_virtual/index4.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
|
|
1
|
+
import { getDefaultExportFromCjs as r } from "./_commonjsHelpers.js";
|
|
2
|
+
import { __require as s } from "../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/classnames@2.5.1/node_modules/classnames/index.js";
|
|
3
|
+
var e = s();
|
|
4
|
+
const t = /* @__PURE__ */ r(e);
|
|
4
5
|
export {
|
|
5
|
-
|
|
6
|
+
t as default
|
|
6
7
|
};
|
|
7
8
|
//# sourceMappingURL=index4.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index4.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index4.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
|
package/dist/_virtual/index7.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import { __require as r } from "../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/@braintree_sanitize-url@7.1.1/node_modules/@braintree/sanitize-url/dist/index.js";
|
|
2
|
+
var i = r();
|
|
2
3
|
export {
|
|
3
|
-
|
|
4
|
+
i as d
|
|
4
5
|
};
|
|
5
6
|
//# sourceMappingURL=index7.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index7.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index7.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
|
package/dist/_virtual/index8.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
var i = r();
|
|
1
|
+
var r = {};
|
|
3
2
|
export {
|
|
4
|
-
|
|
3
|
+
r as __exports
|
|
5
4
|
};
|
|
6
5
|
//# sourceMappingURL=index8.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index8.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index8.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
import { j as l } from "../../_virtual/jsx-runtime.js";
|
|
2
|
-
import _, { useRef as s, useState as
|
|
2
|
+
import _, { useRef as s, useState as g, useEffect as a } from "react";
|
|
3
3
|
import { createRoot as L } from "react-dom/client";
|
|
4
4
|
import P from "./SandboxApp.js";
|
|
5
5
|
import { splitContentSegments as W } from "./utils/split-content.js";
|
|
6
6
|
import Y from "./ContentRender.js";
|
|
7
|
-
const
|
|
7
|
+
const T = ({
|
|
8
8
|
content: i,
|
|
9
9
|
type: E,
|
|
10
10
|
className: F,
|
|
11
|
-
loadingText:
|
|
11
|
+
loadingText: p,
|
|
12
12
|
styleLoadingText: x,
|
|
13
|
-
scriptLoadingText:
|
|
14
|
-
fullScreenButtonText:
|
|
13
|
+
scriptLoadingText: v,
|
|
14
|
+
fullScreenButtonText: R,
|
|
15
15
|
mode: c = "content"
|
|
16
16
|
}) => {
|
|
17
|
-
const y = s(null), u = s(null),
|
|
18
|
-
}), [H, j] =
|
|
17
|
+
const y = s(null), u = s(null), d = s(null), C = s(null), m = s(() => {
|
|
18
|
+
}), [H, j] = g(480), [w, k] = g(0), [S, M] = g(!1), f = s(""), r = _.useMemo(() => {
|
|
19
19
|
const t = W(i).filter((o) => o.type === "sandbox");
|
|
20
20
|
return (c === "blackboard" ? t[t.length - 1]?.value || "" : t.map((o) => o.value).join(`
|
|
21
21
|
`)) || "";
|
|
22
22
|
}, [i, c]);
|
|
23
23
|
a(() => {
|
|
24
24
|
if (c !== "blackboard") {
|
|
25
|
-
|
|
25
|
+
f.current = r;
|
|
26
26
|
return;
|
|
27
27
|
}
|
|
28
|
-
const e =
|
|
29
|
-
!(e && r.startsWith(e)) && e && k((n) => n + 1),
|
|
28
|
+
const e = f.current;
|
|
29
|
+
!(e && r.startsWith(e)) && e && k((n) => n + 1), f.current = r;
|
|
30
30
|
}, [r, c]), a(() => {
|
|
31
31
|
const e = u.current;
|
|
32
32
|
if (!e) return;
|
|
@@ -47,21 +47,21 @@ const U = ({
|
|
|
47
47
|
const n = t.getElementById("root");
|
|
48
48
|
if (!n) return;
|
|
49
49
|
const o = L(n);
|
|
50
|
-
|
|
51
|
-
const
|
|
50
|
+
d.current = o;
|
|
51
|
+
const h = () => {
|
|
52
52
|
if (!u.current || !t.body) return;
|
|
53
|
-
const q = t.body.getBoundingClientRect(), z = t.documentElement?.getBoundingClientRect(),
|
|
53
|
+
const q = t.body.getBoundingClientRect(), z = t.documentElement?.getBoundingClientRect(), B = q.height, O = z?.height || 0, A = Math.max(B, O), D = Math.max(200, Math.ceil(A));
|
|
54
54
|
j(D);
|
|
55
55
|
};
|
|
56
|
-
|
|
57
|
-
const
|
|
58
|
-
return
|
|
59
|
-
|
|
56
|
+
m.current = h, h();
|
|
57
|
+
const b = new ResizeObserver(() => h());
|
|
58
|
+
return b.observe(t.body), n && b.observe(n), () => {
|
|
59
|
+
b.disconnect(), o.unmount(), d.current = null, C.current = null, m.current = () => {
|
|
60
60
|
};
|
|
61
61
|
};
|
|
62
62
|
}, []), a(() => {
|
|
63
63
|
const e = () => {
|
|
64
|
-
|
|
64
|
+
M(!!document.fullscreenElement);
|
|
65
65
|
};
|
|
66
66
|
return document.addEventListener("fullscreenchange", e), () => document.removeEventListener("fullscreenchange", e);
|
|
67
67
|
}, []);
|
|
@@ -78,27 +78,26 @@ const U = ({
|
|
|
78
78
|
}
|
|
79
79
|
};
|
|
80
80
|
return a(() => {
|
|
81
|
-
const e =
|
|
81
|
+
const e = d.current;
|
|
82
82
|
e && (e.render(
|
|
83
83
|
/* @__PURE__ */ l.jsx(
|
|
84
84
|
P,
|
|
85
85
|
{
|
|
86
86
|
html: r,
|
|
87
|
-
loadingText:
|
|
87
|
+
loadingText: p,
|
|
88
88
|
styleLoadingText: x,
|
|
89
|
-
scriptLoadingText:
|
|
90
|
-
fullScreenButtonText: d,
|
|
89
|
+
scriptLoadingText: v,
|
|
91
90
|
resetToken: w
|
|
92
91
|
}
|
|
93
92
|
)
|
|
94
|
-
), requestAnimationFrame(() =>
|
|
93
|
+
), requestAnimationFrame(() => m.current?.()));
|
|
95
94
|
}, [
|
|
96
95
|
i,
|
|
97
96
|
r,
|
|
98
|
-
|
|
97
|
+
p,
|
|
99
98
|
x,
|
|
99
|
+
v,
|
|
100
100
|
R,
|
|
101
|
-
d,
|
|
102
101
|
w
|
|
103
102
|
]), /* @__PURE__ */ l.jsxs(
|
|
104
103
|
"div",
|
|
@@ -128,7 +127,7 @@ const U = ({
|
|
|
128
127
|
borderRadius: 6,
|
|
129
128
|
cursor: "pointer"
|
|
130
129
|
},
|
|
131
|
-
children:
|
|
130
|
+
children: S ? "退出全屏" : R || "全屏浏览"
|
|
132
131
|
}
|
|
133
132
|
),
|
|
134
133
|
c === "blackboard" && E === "markdown" ? /* @__PURE__ */ l.jsx(Y, { content: i }) : /* @__PURE__ */ l.jsx(
|
|
@@ -152,6 +151,6 @@ const U = ({
|
|
|
152
151
|
);
|
|
153
152
|
};
|
|
154
153
|
export {
|
|
155
|
-
|
|
154
|
+
T as default
|
|
156
155
|
};
|
|
157
156
|
//# sourceMappingURL=IframeSandbox.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IframeSandbox.js","sources":["../../../src/components/ContentRender/IframeSandbox.tsx"],"sourcesContent":["import React, { useEffect, useRef, useState } from \"react\";\nimport { createRoot, Root } from \"react-dom/client\";\nimport SandboxApp from \"./SandboxApp\";\nimport { splitContentSegments } from \"./utils/split-content\";\nimport ContentRender from \"./ContentRender\";\nexport interface IframeSandboxProps {\n content: string;\n className?: string;\n loadingText?: string;\n styleLoadingText?: string;\n scriptLoadingText?: string;\n fullScreenButtonText?: string;\n mode?: \"content\" | \"blackboard\";\n type: \"sandbox\" | \"markdown\";\n}\n\nconst IframeSandbox: React.FC<IframeSandboxProps> = ({\n content,\n type,\n className,\n loadingText,\n styleLoadingText,\n scriptLoadingText,\n fullScreenButtonText,\n mode = \"content\",\n}) => {\n const containerRef = useRef<HTMLDivElement>(null);\n const iframeRef = useRef<HTMLIFrameElement>(null);\n const rootRef = useRef<Root | null>(null);\n const docRef = useRef<Document | null>(null);\n const updateHeightRef = useRef<() => void>(() => {});\n const [height, setHeight] = useState(480);\n const [resetToken, setResetToken] = useState(0);\n const [isFullscreen, setIsFullscreen] = useState(false);\n const prevHtmlRef = useRef<string>(\"\");\n const htmlContent = React.useMemo(() => {\n const segments = splitContentSegments(content);\n // console.log('segments=====', segments);\n const sandboxSegments = segments.filter((seg) => seg.type === \"sandbox\");\n const sandboxContent =\n mode === \"blackboard\"\n ? sandboxSegments[sandboxSegments.length - 1]?.value || \"\"\n : sandboxSegments.map((seg) => seg.value).join(\"\\n\");\n return sandboxContent || \"\";\n }, [content, mode]);\n\n useEffect(() => {\n if (mode !== \"blackboard\") {\n prevHtmlRef.current = htmlContent;\n return;\n }\n const prev = prevHtmlRef.current;\n const isContinuation = prev && htmlContent.startsWith(prev);\n if (!isContinuation && prev) {\n setResetToken((token) => token + 1);\n }\n prevHtmlRef.current = htmlContent;\n }, [htmlContent, mode]);\n\n useEffect(() => {\n const iframe = iframeRef.current;\n if (!iframe) return undefined;\n\n const doc = iframe.contentDocument;\n if (!doc) return undefined;\n\n doc.open();\n doc.write(`<!DOCTYPE html>\n<html>\n <head>\n <meta charset=\"utf-8\" />\n <style>\n html, body { margin: 0; padding: 0; }\n </style>\n </head>\n <body>\n <div id=\"root\"></div>\n </body>\n</html>`);\n doc.close();\n docRef.current = doc;\n\n const rootEl = doc.getElementById(\"root\");\n if (!rootEl) return undefined;\n\n const root = createRoot(rootEl);\n rootRef.current = root;\n\n const updateHeight = () => {\n if (!iframeRef.current || !doc.body) return;\n const bodyRect = doc.body.getBoundingClientRect();\n const htmlRect = doc.documentElement?.getBoundingClientRect();\n const bodyHeight = bodyRect.height;\n const htmlHeight = htmlRect?.height || 0;\n const contentHeight = Math.max(bodyHeight, htmlHeight);\n const nextHeight = Math.max(200, Math.ceil(contentHeight));\n setHeight(nextHeight);\n };\n updateHeightRef.current = updateHeight;\n\n updateHeight();\n\n const resizeObserver = new ResizeObserver(() => updateHeight());\n resizeObserver.observe(doc.body);\n if (rootEl) {\n resizeObserver.observe(rootEl);\n }\n\n return () => {\n resizeObserver.disconnect();\n root.unmount();\n rootRef.current = null;\n docRef.current = null;\n updateHeightRef.current = () => {};\n };\n }, []);\n\n useEffect(() => {\n const onFullscreenChange = () => {\n setIsFullscreen(Boolean(document.fullscreenElement));\n };\n document.addEventListener(\"fullscreenchange\", onFullscreenChange);\n return () =>\n document.removeEventListener(\"fullscreenchange\", onFullscreenChange);\n }, []);\n\n const toggleFullscreen = () => {\n const target = containerRef.current || iframeRef.current;\n if (!target) return;\n if (document.fullscreenElement) {\n document.exitFullscreen().catch(() => {});\n return;\n }\n if (target.requestFullscreen) {\n target.requestFullscreen().catch(() => {});\n }\n };\n\n useEffect(() => {\n const root = rootRef.current;\n if (!root) return;\n\n root.render(\n <SandboxApp\n html={htmlContent}\n loadingText={loadingText}\n styleLoadingText={styleLoadingText}\n scriptLoadingText={scriptLoadingText}\n fullScreenButtonText={fullScreenButtonText}\n resetToken={resetToken}\n />\n );\n requestAnimationFrame(() => updateHeightRef.current?.());\n }, [\n content,\n htmlContent,\n loadingText,\n styleLoadingText,\n scriptLoadingText,\n fullScreenButtonText,\n resetToken,\n ]);\n\n return (\n <div\n ref={containerRef}\n style={{\n width: \"100%\",\n height: \"100%\",\n overflow: \"auto\",\n position: \"relative\",\n }}\n >\n <button\n type=\"button\"\n onClick={toggleFullscreen}\n style={{\n position: \"absolute\",\n top: 8,\n right: 8,\n zIndex: 5,\n padding: \"6px 10px\",\n background: \"rgba(0, 0, 0, 0.75)\",\n color: \"#fff\",\n border: \"none\",\n borderRadius: 6,\n cursor: \"pointer\",\n }}\n >\n {isFullscreen ? \"退出全屏\" : fullScreenButtonText || \"全屏浏览\"}\n </button>\n {mode === \"blackboard\" && type === \"markdown\" ? (\n <ContentRender content={content} />\n ) : (\n <iframe\n ref={iframeRef}\n sandbox=\"allow-scripts allow-same-origin\"\n allow=\"fullscreen\"\n allowFullScreen\n className={className}\n style={{\n width: \"100%\",\n height: `${height}px`,\n // margin: \"16px 0\",\n }}\n title=\"HTML Sandbox\"\n />\n )}\n </div>\n );\n};\n\nexport default IframeSandbox;\n"],"names":["IframeSandbox","content","type","className","loadingText","styleLoadingText","scriptLoadingText","fullScreenButtonText","mode","containerRef","useRef","iframeRef","rootRef","docRef","updateHeightRef","height","setHeight","useState","resetToken","setResetToken","isFullscreen","setIsFullscreen","prevHtmlRef","htmlContent","React","sandboxSegments","splitContentSegments","seg","useEffect","prev","token","iframe","doc","rootEl","root","createRoot","updateHeight","bodyRect","htmlRect","bodyHeight","htmlHeight","contentHeight","nextHeight","resizeObserver","onFullscreenChange","toggleFullscreen","target","jsx","SandboxApp","jsxs","ContentRender"],"mappings":";;;;;;AAgBA,MAAMA,IAA8C,CAAC;AAAA,EACnD,SAAAC;AAAA,EACA,MAAAC;AAAA,EACA,WAAAC;AAAA,EACA,aAAAC;AAAA,EACA,kBAAAC;AAAA,EACA,mBAAAC;AAAA,EACA,sBAAAC;AAAA,EACA,MAAAC,IAAO;AACT,MAAM;AACJ,QAAMC,IAAeC,EAAuB,IAAI,GAC1CC,IAAYD,EAA0B,IAAI,GAC1CE,IAAUF,EAAoB,IAAI,GAClCG,IAASH,EAAwB,IAAI,GACrCI,IAAkBJ,EAAmB,MAAM;AAAA,EAAC,CAAC,GAC7C,CAACK,GAAQC,CAAS,IAAIC,EAAS,GAAG,GAClC,CAACC,GAAYC,CAAa,IAAIF,EAAS,CAAC,GACxC,CAACG,GAAcC,CAAe,IAAIJ,EAAS,EAAK,GAChDK,IAAcZ,EAAe,EAAE,GAC/Ba,IAAcC,EAAM,QAAQ,MA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,IACDb;AAAA,IACAsB;AAAA,IACAnB;AAAA,IACAC;AAAA,IACAC;AAAA,IACAC;AAAA,IACAW;AAAA,EAAA,CACD,GAGC+B,gBAAAA,EAAAA;AAAAA,IAAC;AAAA,IAAA;AAAA,MACC,KAAKxC;AAAA,MACL,OAAO;AAAA,QACL,OAAO;AAAA,QACP,QAAQ;AAAA,QACR,UAAU;AAAA,QACV,UAAU;AAAA,MAAA;AAAA,MAGZ,UAAA;AAAA,QAAAsC,gBAAAA,EAAAA;AAAAA,UAAC;AAAA,UAAA;AAAA,YACC,MAAK;AAAA,YACL,SAASF;AAAA,YACT,OAAO;AAAA,cACL,UAAU;AAAA,cACV,KAAK;AAAA,cACL,OAAO;AAAA,cACP,QAAQ;AAAA,cACR,SAAS;AAAA,cACT,YAAY;AAAA,cACZ,OAAO;AAAA,cACP,QAAQ;AAAA,cACR,cAAc;AAAA,cACd,QAAQ;AAAA,YAAA;AAAA,YAGT,UAAAzB,IAAe,SAASb,KAAwB;AAAA,UAAA;AAAA,QAAA;AAAA,QAElDC,MAAS,gBAAgBN,MAAS,aACjC6C,gBAAAA,EAAAA,IAACG,GAAA,EAAc,SAAAjD,GAAkB,IAEjC8C,gBAAAA,EAAAA;AAAAA,UAAC;AAAA,UAAA;AAAA,YACC,KAAKpC;AAAA,YACL,SAAQ;AAAA,YACR,OAAM;AAAA,YACN,iBAAe;AAAA,YACf,WAAAR;AAAA,YACA,OAAO;AAAA,cACL,OAAO;AAAA,cACP,QAAQ,GAAGY,CAAM;AAAA;AAAA,YAAA;AAAA,YAGnB,OAAM;AAAA,UAAA;AAAA,QAAA;AAAA,MACR;AAAA,IAAA;AAAA,EAAA;AAIR;"}
|
|
1
|
+
{"version":3,"file":"IframeSandbox.js","sources":["../../../src/components/ContentRender/IframeSandbox.tsx"],"sourcesContent":["import React, { useEffect, useRef, useState } from \"react\";\nimport { createRoot, Root } from \"react-dom/client\";\nimport SandboxApp from \"./SandboxApp\";\nimport { splitContentSegments } from \"./utils/split-content\";\nimport ContentRender from \"./ContentRender\";\nexport interface IframeSandboxProps {\n content: string;\n className?: string;\n loadingText?: string;\n styleLoadingText?: string;\n scriptLoadingText?: string;\n fullScreenButtonText?: string;\n mode?: \"content\" | \"blackboard\";\n type: \"sandbox\" | \"markdown\";\n}\n\nconst IframeSandbox: React.FC<IframeSandboxProps> = ({\n content,\n type,\n className,\n loadingText,\n styleLoadingText,\n scriptLoadingText,\n fullScreenButtonText,\n mode = \"content\",\n}) => {\n const containerRef = useRef<HTMLDivElement>(null);\n const iframeRef = useRef<HTMLIFrameElement>(null);\n const rootRef = useRef<Root | null>(null);\n const docRef = useRef<Document | null>(null);\n const updateHeightRef = useRef<() => void>(() => {});\n const [height, setHeight] = useState(480);\n const [resetToken, setResetToken] = useState(0);\n const [isFullscreen, setIsFullscreen] = useState(false);\n const prevHtmlRef = useRef<string>(\"\");\n const htmlContent = React.useMemo(() => {\n const segments = splitContentSegments(content);\n // console.log('segments=====', segments);\n const sandboxSegments = segments.filter((seg) => seg.type === \"sandbox\");\n const sandboxContent =\n mode === \"blackboard\"\n ? sandboxSegments[sandboxSegments.length - 1]?.value || \"\"\n : sandboxSegments.map((seg) => seg.value).join(\"\\n\");\n return sandboxContent || \"\";\n }, [content, mode]);\n\n useEffect(() => {\n if (mode !== \"blackboard\") {\n prevHtmlRef.current = htmlContent;\n return;\n }\n const prev = prevHtmlRef.current;\n const isContinuation = prev && htmlContent.startsWith(prev);\n if (!isContinuation && prev) {\n setResetToken((token) => token + 1);\n }\n prevHtmlRef.current = htmlContent;\n }, [htmlContent, mode]);\n\n useEffect(() => {\n const iframe = iframeRef.current;\n if (!iframe) return undefined;\n\n const doc = iframe.contentDocument;\n if (!doc) return undefined;\n\n doc.open();\n doc.write(`<!DOCTYPE html>\n<html>\n <head>\n <meta charset=\"utf-8\" />\n <style>\n html, body { margin: 0; padding: 0; }\n </style>\n </head>\n <body>\n <div id=\"root\"></div>\n </body>\n</html>`);\n doc.close();\n docRef.current = doc;\n\n const rootEl = doc.getElementById(\"root\");\n if (!rootEl) return undefined;\n\n const root = createRoot(rootEl);\n rootRef.current = root;\n\n const updateHeight = () => {\n if (!iframeRef.current || !doc.body) return;\n const bodyRect = doc.body.getBoundingClientRect();\n const htmlRect = doc.documentElement?.getBoundingClientRect();\n const bodyHeight = bodyRect.height;\n const htmlHeight = htmlRect?.height || 0;\n const contentHeight = Math.max(bodyHeight, htmlHeight);\n const nextHeight = Math.max(200, Math.ceil(contentHeight));\n setHeight(nextHeight);\n };\n updateHeightRef.current = updateHeight;\n\n updateHeight();\n\n const resizeObserver = new ResizeObserver(() => updateHeight());\n resizeObserver.observe(doc.body);\n if (rootEl) {\n resizeObserver.observe(rootEl);\n }\n\n return () => {\n resizeObserver.disconnect();\n root.unmount();\n rootRef.current = null;\n docRef.current = null;\n updateHeightRef.current = () => {};\n };\n }, []);\n\n useEffect(() => {\n const onFullscreenChange = () => {\n setIsFullscreen(Boolean(document.fullscreenElement));\n };\n document.addEventListener(\"fullscreenchange\", onFullscreenChange);\n return () =>\n document.removeEventListener(\"fullscreenchange\", onFullscreenChange);\n }, []);\n\n const toggleFullscreen = () => {\n const target = containerRef.current || iframeRef.current;\n if (!target) return;\n if (document.fullscreenElement) {\n document.exitFullscreen().catch(() => {});\n return;\n }\n if (target.requestFullscreen) {\n target.requestFullscreen().catch(() => {});\n }\n };\n\n useEffect(() => {\n const root = rootRef.current;\n if (!root) return;\n\n root.render(\n <SandboxApp\n html={htmlContent}\n loadingText={loadingText}\n styleLoadingText={styleLoadingText}\n scriptLoadingText={scriptLoadingText}\n resetToken={resetToken}\n />\n );\n requestAnimationFrame(() => updateHeightRef.current?.());\n }, [\n content,\n htmlContent,\n loadingText,\n styleLoadingText,\n scriptLoadingText,\n fullScreenButtonText,\n resetToken,\n ]);\n\n return (\n <div\n ref={containerRef}\n style={{\n width: \"100%\",\n height: \"100%\",\n overflow: \"auto\",\n position: \"relative\",\n }}\n >\n <button\n type=\"button\"\n onClick={toggleFullscreen}\n style={{\n position: \"absolute\",\n top: 8,\n right: 8,\n zIndex: 5,\n padding: \"6px 10px\",\n background: \"rgba(0, 0, 0, 0.75)\",\n color: \"#fff\",\n border: \"none\",\n borderRadius: 6,\n cursor: \"pointer\",\n }}\n >\n {isFullscreen ? \"退出全屏\" : fullScreenButtonText || \"全屏浏览\"}\n </button>\n {mode === \"blackboard\" && type === \"markdown\" ? (\n <ContentRender content={content} />\n ) : (\n <iframe\n ref={iframeRef}\n sandbox=\"allow-scripts allow-same-origin\"\n allow=\"fullscreen\"\n allowFullScreen\n className={className}\n style={{\n width: \"100%\",\n height: `${height}px`,\n // margin: \"16px 0\",\n }}\n title=\"HTML Sandbox\"\n />\n )}\n </div>\n );\n};\n\nexport default IframeSandbox;\n"],"names":["IframeSandbox","content","type","className","loadingText","styleLoadingText","scriptLoadingText","fullScreenButtonText","mode","containerRef","useRef","iframeRef","rootRef","docRef","updateHeightRef","height","setHeight","useState","resetToken","setResetToken","isFullscreen","setIsFullscreen","prevHtmlRef","htmlContent","React","sandboxSegments","splitContentSegments","seg","useEffect","prev","token","iframe","doc","rootEl","root","createRoot","updateHeight","bodyRect","htmlRect","bodyHeight","htmlHeight","contentHeight","nextHeight","resizeObserver","onFullscreenChange","toggleFullscreen","target","jsx","SandboxApp","jsxs","ContentRender"],"mappings":";;;;;;AAgBA,MAAMA,IAA8C,CAAC;AAAA,EACnD,SAAAC;AAAA,EACA,MAAAC;AAAA,EACA,WAAAC;AAAA,EACA,aAAAC;AAAA,EACA,kBAAAC;AAAA,EACA,mBAAAC;AAAA,EACA,sBAAAC;AAAA,EACA,MAAAC,IAAO;AACT,MAAM;AACJ,QAAMC,IAAeC,EAAuB,IAAI,GAC1CC,IAAYD,EAA0B,IAAI,GAC1CE,IAAUF,EAAoB,IAAI,GAClCG,IAASH,EAAwB,IAAI,GACrCI,IAAkBJ,EAAmB,MAAM;AAAA,EAAC,CAAC,GAC7C,CAACK,GAAQC,CAAS,IAAIC,EAAS,GAAG,GAClC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as n, useState as
|
|
3
|
-
import
|
|
4
|
-
const
|
|
5
|
-
html:
|
|
6
|
-
loadingText:
|
|
7
|
-
styleLoadingText:
|
|
8
|
-
scriptLoadingText:
|
|
9
|
-
|
|
10
|
-
resetToken: p = 0
|
|
1
|
+
import { j as S } from "../../_virtual/jsx-runtime.js";
|
|
2
|
+
import { useRef as n, useState as A, useEffect as I } from "react";
|
|
3
|
+
import K from "../../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/loader-circle.js";
|
|
4
|
+
const Z = ({
|
|
5
|
+
html: u,
|
|
6
|
+
loadingText: B,
|
|
7
|
+
styleLoadingText: W,
|
|
8
|
+
scriptLoadingText: z,
|
|
9
|
+
resetToken: f = 0
|
|
11
10
|
}) => {
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
},
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
},
|
|
11
|
+
const H = n(null), v = n(null), [q, L] = A(!0), [V, C] = A(!1), [_, E] = A(!1), b = n([]), w = n([]), N = n(0), j = n(0), p = n(null), d = n(null), m = n(!1), h = n(!1), R = n(!1), M = n(f), O = 200, c = (t) => {
|
|
12
|
+
t.current && (clearTimeout(t.current), t.current = null);
|
|
13
|
+
}, D = (t, s, o, g) => {
|
|
14
|
+
const i = performance.now() - o.current, x = Math.max(0, O - i);
|
|
15
|
+
c(s), s.current = window.setTimeout(() => {
|
|
16
|
+
t(!1), g?.(), s.current = null;
|
|
17
|
+
}, x);
|
|
19
18
|
};
|
|
20
|
-
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
};
|
|
24
|
-
return document.addEventListener("fullscreenchange", e), () => {
|
|
25
|
-
document.removeEventListener("fullscreenchange", e);
|
|
26
|
-
};
|
|
27
|
-
}, []), v(() => {
|
|
28
|
-
const e = S.current?.ownerDocument;
|
|
29
|
-
if (!e) return;
|
|
19
|
+
I(() => {
|
|
20
|
+
const t = v.current?.ownerDocument;
|
|
21
|
+
if (!t) return;
|
|
30
22
|
const s = "sandbox-spinner-style";
|
|
31
|
-
let
|
|
32
|
-
|
|
33
|
-
}, []),
|
|
34
|
-
|
|
35
|
-
const
|
|
36
|
-
if (!
|
|
37
|
-
const s =
|
|
38
|
-
if (!
|
|
39
|
-
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
const
|
|
45
|
-
Array.from(
|
|
46
|
-
if (
|
|
23
|
+
let o = t.getElementById(s);
|
|
24
|
+
o || (o = t.createElement("style"), o.id = s, o.textContent = "@keyframes sandbox-spin { from { transform: rotate(0deg);} to { transform: rotate(360deg);} }", t.head?.appendChild(o));
|
|
25
|
+
}, []), I(() => {
|
|
26
|
+
f !== M.current && (R.current = !1, M.current = f), c(p), c(d), m.current = !1, h.current = !1;
|
|
27
|
+
const t = v.current;
|
|
28
|
+
if (!t) return;
|
|
29
|
+
const s = t.ownerDocument, o = s?.body;
|
|
30
|
+
if (!o) return;
|
|
31
|
+
b.current.forEach((e) => e.remove()), b.current = [], w.current.forEach((e) => e.remove()), w.current = [];
|
|
32
|
+
const g = R.current;
|
|
33
|
+
L(!g), C(!1), E(!1), t.innerHTML = "";
|
|
34
|
+
const i = document.createElement("div");
|
|
35
|
+
i.innerHTML = u;
|
|
36
|
+
const x = (u.match(/<script[\s>]/gi) || []).length, Q = (u.match(/<\/script>/gi) || []).length, k = x > 0 && x === Q, l = [];
|
|
37
|
+
Array.from(i.querySelectorAll("style, script")).forEach((e) => {
|
|
38
|
+
if (e.tagName.toLowerCase() === "style") {
|
|
47
39
|
const r = s.createElement("style");
|
|
48
|
-
r.textContent =
|
|
49
|
-
r.setAttribute(
|
|
40
|
+
r.textContent = e.textContent || "", Array.from(e.attributes).forEach((a) => {
|
|
41
|
+
r.setAttribute(a.name, a.value);
|
|
50
42
|
}), l.push(r);
|
|
51
43
|
} else {
|
|
52
44
|
const r = s.createElement("script");
|
|
53
|
-
Array.from(
|
|
54
|
-
r.setAttribute(
|
|
55
|
-
}), r.textContent =
|
|
45
|
+
Array.from(e.attributes).forEach((a) => {
|
|
46
|
+
r.setAttribute(a.name, a.value);
|
|
47
|
+
}), r.textContent = e.textContent || "", l.push(r);
|
|
56
48
|
}
|
|
57
|
-
|
|
49
|
+
e.remove();
|
|
58
50
|
});
|
|
59
|
-
const
|
|
60
|
-
(
|
|
61
|
-
),
|
|
62
|
-
(
|
|
51
|
+
const T = l.some(
|
|
52
|
+
(e) => e.tagName.toLowerCase() === "style"
|
|
53
|
+
), F = l.some(
|
|
54
|
+
(e) => e.tagName.toLowerCase() === "script"
|
|
63
55
|
);
|
|
64
|
-
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
if (
|
|
70
|
-
s.head?.appendChild(
|
|
56
|
+
T && (m.current = !0, N.current = performance.now(), c(p), C(!0)), F && (h.current = !0, j.current = performance.now(), c(d), E(!0));
|
|
57
|
+
const G = !!i.firstElementChild;
|
|
58
|
+
L(!G && !g), G && (R.current = !0);
|
|
59
|
+
const J = Array.from(i.childNodes);
|
|
60
|
+
t.append(...J), l.forEach((e) => {
|
|
61
|
+
if (e.tagName.toLowerCase() === "style") {
|
|
62
|
+
s.head?.appendChild(e), b.current.push(e);
|
|
71
63
|
return;
|
|
72
64
|
}
|
|
73
|
-
if (
|
|
74
|
-
const r =
|
|
65
|
+
if (k) {
|
|
66
|
+
const r = e, a = r.textContent || "";
|
|
75
67
|
if (!r.src)
|
|
76
68
|
try {
|
|
77
|
-
new Function(
|
|
69
|
+
new Function(a);
|
|
78
70
|
} catch {
|
|
79
71
|
r.remove();
|
|
80
72
|
return;
|
|
81
73
|
}
|
|
82
74
|
try {
|
|
83
|
-
|
|
75
|
+
o.appendChild(r), w.current.push(r);
|
|
84
76
|
} catch {
|
|
85
77
|
r.remove();
|
|
86
78
|
}
|
|
87
79
|
} else
|
|
88
|
-
|
|
80
|
+
e.remove();
|
|
89
81
|
}), requestAnimationFrame(() => {
|
|
90
|
-
|
|
82
|
+
T && D(
|
|
91
83
|
C,
|
|
84
|
+
p,
|
|
85
|
+
N,
|
|
86
|
+
() => {
|
|
87
|
+
m.current = !1;
|
|
88
|
+
}
|
|
89
|
+
), F && D(
|
|
90
|
+
E,
|
|
92
91
|
d,
|
|
93
92
|
j,
|
|
94
93
|
() => {
|
|
95
94
|
h.current = !1;
|
|
96
95
|
}
|
|
97
|
-
), G && T(
|
|
98
|
-
w,
|
|
99
|
-
m,
|
|
100
|
-
M,
|
|
101
|
-
() => {
|
|
102
|
-
y.current = !1;
|
|
103
|
-
}
|
|
104
96
|
);
|
|
105
97
|
});
|
|
106
|
-
}, [
|
|
98
|
+
}, [u, f]), I(
|
|
107
99
|
() => () => {
|
|
108
|
-
|
|
100
|
+
c(p), c(d);
|
|
109
101
|
},
|
|
110
102
|
[]
|
|
111
103
|
);
|
|
112
|
-
const
|
|
113
|
-
|
|
114
|
-
if (e) {
|
|
115
|
-
if (!document.fullscreenElement) {
|
|
116
|
-
e.requestFullscreen?.().catch(() => {
|
|
117
|
-
});
|
|
118
|
-
return;
|
|
119
|
-
}
|
|
120
|
-
document.exitFullscreen?.();
|
|
121
|
-
}
|
|
122
|
-
};
|
|
123
|
-
return /* @__PURE__ */ u.jsxs(
|
|
104
|
+
const y = _ || h.current ? z || "Building scripts cache..." : V || m.current ? W || "Building styles..." : q ? B || "Loading..." : null;
|
|
105
|
+
return /* @__PURE__ */ S.jsxs(
|
|
124
106
|
"div",
|
|
125
107
|
{
|
|
126
|
-
ref:
|
|
108
|
+
ref: H,
|
|
127
109
|
style: { position: "relative", minHeight: 120 },
|
|
128
|
-
"aria-busy": !!
|
|
110
|
+
"aria-busy": !!y,
|
|
129
111
|
children: [
|
|
130
|
-
/* @__PURE__ */
|
|
112
|
+
/* @__PURE__ */ S.jsx(
|
|
131
113
|
"div",
|
|
132
114
|
{
|
|
133
|
-
ref:
|
|
115
|
+
ref: v,
|
|
134
116
|
style: {
|
|
135
|
-
pointerEvents:
|
|
117
|
+
pointerEvents: y ? "none" : void 0
|
|
136
118
|
}
|
|
137
119
|
}
|
|
138
120
|
),
|
|
139
|
-
/* @__PURE__ */
|
|
140
|
-
"button",
|
|
141
|
-
{
|
|
142
|
-
type: "button",
|
|
143
|
-
onClick: K,
|
|
144
|
-
style: {
|
|
145
|
-
position: "absolute",
|
|
146
|
-
top: 8,
|
|
147
|
-
right: 8,
|
|
148
|
-
zIndex: 30,
|
|
149
|
-
padding: "6px 10px",
|
|
150
|
-
borderRadius: 6,
|
|
151
|
-
border: "1px solid #cbd5e1",
|
|
152
|
-
background: "#ffffffcc",
|
|
153
|
-
color: "#0f172a",
|
|
154
|
-
fontSize: 12,
|
|
155
|
-
fontWeight: 600,
|
|
156
|
-
cursor: "pointer",
|
|
157
|
-
boxShadow: "0 4px 10px rgba(15, 23, 42, 0.08)"
|
|
158
|
-
},
|
|
159
|
-
children: O ? L || "Exit Fullscreen" : L || "Fullscreen"
|
|
160
|
-
}
|
|
161
|
-
),
|
|
162
|
-
g && /* @__PURE__ */ u.jsxs(
|
|
121
|
+
y && /* @__PURE__ */ S.jsxs(
|
|
163
122
|
"div",
|
|
164
123
|
{
|
|
165
124
|
style: {
|
|
@@ -177,15 +136,15 @@ const re = ({
|
|
|
177
136
|
zIndex: 20
|
|
178
137
|
},
|
|
179
138
|
children: [
|
|
180
|
-
/* @__PURE__ */
|
|
181
|
-
|
|
139
|
+
/* @__PURE__ */ S.jsx(
|
|
140
|
+
K,
|
|
182
141
|
{
|
|
183
142
|
"aria-hidden": !0,
|
|
184
143
|
size: 20,
|
|
185
144
|
style: { animation: "sandbox-spin 1s linear infinite" }
|
|
186
145
|
}
|
|
187
146
|
),
|
|
188
|
-
|
|
147
|
+
y
|
|
189
148
|
]
|
|
190
149
|
}
|
|
191
150
|
)
|
|
@@ -194,6 +153,6 @@ const re = ({
|
|
|
194
153
|
);
|
|
195
154
|
};
|
|
196
155
|
export {
|
|
197
|
-
|
|
156
|
+
Z as default
|
|
198
157
|
};
|
|
199
158
|
//# sourceMappingURL=SandboxApp.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SandboxApp.js","sources":["../../../src/components/ContentRender/SandboxApp.tsx"],"sourcesContent":["import React, { useEffect, useRef, useState } from \"react\";\nimport { Loader2 } from \"lucide-react\";\n\nexport interface SandboxAppProps {\n html: string;\n loadingText?: string;\n styleLoadingText?: string;\n scriptLoadingText?: string;\n fullScreenButtonText?: string;\n resetToken?: number;\n}\n\nconst SandboxApp: React.FC<SandboxAppProps> = ({\n html,\n loadingText,\n styleLoadingText,\n scriptLoadingText,\n fullScreenButtonText,\n resetToken = 0,\n}) => {\n const wrapperRef = useRef<HTMLDivElement>(null);\n const containerRef = useRef<HTMLDivElement>(null);\n const [isWaitingFirstDiv, setIsWaitingFirstDiv] = useState(true);\n const [isGeneratingStyles, setIsGeneratingStyles] = useState(false);\n const [isGeneratingScripts, setIsGeneratingScripts] = useState(false);\n const [isFullscreen, setIsFullscreen] = useState(false);\n const appendedStylesRef = useRef<HTMLStyleElement[]>([]);\n const appendedScriptsRef = useRef<HTMLScriptElement[]>([]);\n const styleStartRef = useRef(0);\n const scriptStartRef = useRef(0);\n const styleTimerRef = useRef<number | null>(null);\n const scriptTimerRef = useRef<number | null>(null);\n const hasStylesRef = useRef(false);\n const hasScriptsRef = useRef(false);\n const hasRenderedContentRef = useRef(false);\n const prevResetTokenRef = useRef(resetToken);\n const MIN_LOADING_MS = 200;\n\n const clearTimer = (timerRef: React.MutableRefObject<number | null>) => {\n if (timerRef.current) {\n clearTimeout(timerRef.current);\n timerRef.current = null;\n }\n };\n\n const settleStateWithMinimumDelay = (\n setter: React.Dispatch<React.SetStateAction<boolean>>,\n timerRef: React.MutableRefObject<number | null>,\n startRef: React.MutableRefObject<number>,\n onDone?: () => void\n ) => {\n const elapsed = performance.now() - startRef.current;\n const delay = Math.max(0, MIN_LOADING_MS - elapsed);\n clearTimer(timerRef);\n timerRef.current = window.setTimeout(() => {\n setter(false);\n onDone?.();\n timerRef.current = null;\n }, delay);\n };\n\n useEffect(() => {\n const onFullscreenChange = () => {\n setIsFullscreen(!!document.fullscreenElement);\n };\n document.addEventListener(\"fullscreenchange\", onFullscreenChange);\n return () => {\n document.removeEventListener(\"fullscreenchange\", onFullscreenChange);\n };\n }, []);\n\n useEffect(() => {\n const doc = containerRef.current?.ownerDocument;\n if (!doc) return;\n const styleId = \"sandbox-spinner-style\";\n let styleEl = doc.getElementById(styleId) as HTMLStyleElement | null;\n if (!styleEl) {\n styleEl = doc.createElement(\"style\");\n styleEl.id = styleId;\n styleEl.textContent =\n \"@keyframes sandbox-spin { from { transform: rotate(0deg);} to { transform: rotate(360deg);} }\";\n doc.head?.appendChild(styleEl);\n }\n }, []);\n\n useEffect(() => {\n if (resetToken !== prevResetTokenRef.current) {\n hasRenderedContentRef.current = false;\n prevResetTokenRef.current = resetToken;\n }\n clearTimer(styleTimerRef);\n clearTimer(scriptTimerRef);\n hasStylesRef.current = false;\n hasScriptsRef.current = false;\n\n const container = containerRef.current;\n if (!container) return;\n const doc = container.ownerDocument;\n const body = doc?.body;\n if (!body) return;\n\n appendedStylesRef.current.forEach((node) => node.remove());\n appendedStylesRef.current = [];\n appendedScriptsRef.current.forEach((node) => node.remove());\n appendedScriptsRef.current = [];\n\n const hasRenderedBefore = hasRenderedContentRef.current;\n setIsWaitingFirstDiv(!hasRenderedBefore);\n setIsGeneratingStyles(false);\n setIsGeneratingScripts(false);\n container.innerHTML = \"\";\n const wrapper = document.createElement(\"div\");\n wrapper.innerHTML = html;\n\n const openScriptCount = (html.match(/<script[\\s>]/gi) || []).length;\n const closeScriptCount = (html.match(/<\\/script>/gi) || []).length;\n const shouldExecuteScripts =\n openScriptCount > 0 && openScriptCount === closeScriptCount;\n\n const resourceQueue: HTMLElement[] = [];\n\n Array.from(wrapper.querySelectorAll(\"style, script\")).forEach((node) => {\n if (node.tagName.toLowerCase() === \"style\") {\n const cloned = doc.createElement(\"style\");\n cloned.textContent = node.textContent || \"\";\n Array.from(node.attributes).forEach((attr) => {\n cloned.setAttribute(attr.name, attr.value);\n });\n resourceQueue.push(cloned);\n } else {\n const replacement = doc.createElement(\"script\");\n Array.from(node.attributes).forEach((attr) => {\n replacement.setAttribute(attr.name, attr.value);\n });\n replacement.textContent = node.textContent || \"\";\n resourceQueue.push(replacement);\n }\n node.remove();\n });\n\n const hasStyles = resourceQueue.some(\n (node) => node.tagName.toLowerCase() === \"style\"\n );\n const hasScripts = resourceQueue.some(\n (node) => node.tagName.toLowerCase() === \"script\"\n );\n if (hasStyles) {\n hasStylesRef.current = true;\n styleStartRef.current = performance.now();\n clearTimer(styleTimerRef);\n setIsGeneratingStyles(true);\n }\n if (hasScripts) {\n hasScriptsRef.current = true;\n scriptStartRef.current = performance.now();\n clearTimer(scriptTimerRef);\n setIsGeneratingScripts(true);\n }\n\n const hasFirstElement = !!wrapper.firstElementChild;\n setIsWaitingFirstDiv(!hasFirstElement && !hasRenderedBefore);\n if (hasFirstElement) {\n hasRenderedContentRef.current = true;\n }\n\n const contentNodes = Array.from(wrapper.childNodes);\n container.append(...contentNodes);\n\n resourceQueue.forEach((node) => {\n if (node.tagName.toLowerCase() === \"style\") {\n doc.head?.appendChild(node);\n appendedStylesRef.current.push(node as HTMLStyleElement);\n return;\n }\n\n if (shouldExecuteScripts) {\n const scriptNode = node as HTMLScriptElement;\n const scriptText = scriptNode.textContent || \"\";\n const shouldValidate = !scriptNode.src;\n\n if (shouldValidate) {\n try {\n // Validate script is syntactically complete before executing\n\n new Function(scriptText);\n } catch {\n scriptNode.remove();\n return;\n }\n }\n\n try {\n body.appendChild(scriptNode);\n appendedScriptsRef.current.push(scriptNode);\n } catch {\n scriptNode.remove();\n }\n } else {\n // Defer execution until all script tags are fully received\n node.remove();\n }\n });\n requestAnimationFrame(() => {\n if (hasStyles) {\n settleStateWithMinimumDelay(\n setIsGeneratingStyles,\n styleTimerRef,\n styleStartRef,\n () => {\n hasStylesRef.current = false;\n }\n );\n }\n if (hasScripts) {\n settleStateWithMinimumDelay(\n setIsGeneratingScripts,\n scriptTimerRef,\n scriptStartRef,\n () => {\n hasScriptsRef.current = false;\n }\n );\n }\n });\n }, [html, resetToken]);\n\n useEffect(\n () => () => {\n clearTimer(styleTimerRef);\n clearTimer(scriptTimerRef);\n },\n []\n );\n\n const overlayMessage = (() => {\n if (isGeneratingScripts || hasScriptsRef.current)\n return scriptLoadingText || \"Building scripts cache...\";\n if (isGeneratingStyles || hasStylesRef.current)\n return styleLoadingText || \"Building styles...\";\n if (isWaitingFirstDiv) return loadingText || \"Loading...\";\n return null;\n })();\n\n const handleToggleFullscreen = () => {\n const wrapper = wrapperRef.current;\n if (!wrapper) return;\n if (!document.fullscreenElement) {\n wrapper.requestFullscreen?.().catch(() => {});\n return;\n }\n document.exitFullscreen?.();\n };\n\n return (\n <div\n ref={wrapperRef}\n style={{ position: \"relative\", minHeight: 120 }}\n aria-busy={!!overlayMessage}\n >\n <div\n ref={containerRef}\n style={{\n pointerEvents: overlayMessage ? \"none\" : undefined,\n }}\n />\n <button\n type=\"button\"\n onClick={handleToggleFullscreen}\n style={{\n position: \"absolute\",\n top: 8,\n right: 8,\n zIndex: 30,\n padding: \"6px 10px\",\n borderRadius: 6,\n border: \"1px solid #cbd5e1\",\n background: \"#ffffffcc\",\n color: \"#0f172a\",\n fontSize: 12,\n fontWeight: 600,\n cursor: \"pointer\",\n boxShadow: \"0 4px 10px rgba(15, 23, 42, 0.08)\",\n }}\n >\n {isFullscreen\n ? fullScreenButtonText || \"Exit Fullscreen\"\n : fullScreenButtonText || \"Fullscreen\"}\n </button>\n {overlayMessage && (\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n background: \"rgba(51, 51, 51, 0.80)\",\n color: \"#ffffff\",\n fontSize: 16,\n fontWeight: 700,\n gap: 10,\n pointerEvents: \"auto\",\n zIndex: 20,\n }}\n >\n <Loader2\n aria-hidden\n size={20}\n style={{ animation: \"sandbox-spin 1s linear infinite\" }}\n />\n {overlayMessage}\n </div>\n )}\n </div>\n );\n};\n\nexport default SandboxApp;\n"],"names":["SandboxApp","html","loadingText","styleLoadingText","scriptLoadingText","fullScreenButtonText","resetToken","wrapperRef","useRef","containerRef","isWaitingFirstDiv","setIsWaitingFirstDiv","useState","isGeneratingStyles","setIsGeneratingStyles","isGeneratingScripts","setIsGeneratingScripts","isFullscreen","setIsFullscreen","appendedStylesRef","appendedScriptsRef","styleStartRef","scriptStartRef","styleTimerRef","scriptTimerRef","hasStylesRef","hasScriptsRef","hasRenderedContentRef","prevResetTokenRef","MIN_LOADING_MS","clearTimer","timerRef","settleStateWithMinimumDelay","setter","startRef","onDone","elapsed","delay","useEffect","onFullscreenChange","doc","styleId","styleEl","container","body","node","hasRenderedBefore","wrapper","openScriptCount","closeScriptCount","shouldExecuteScripts","resourceQueue","cloned","attr","replacement","hasStyles","hasScripts","hasFirstElement","contentNodes","scriptNode","scriptText","overlayMessage","handleToggleFullscreen","jsxs","jsx","Loader2"],"mappings":";;;AAYA,MAAMA,KAAwC,CAAC;AAAA,EAC7C,MAAAC;AAAA,EACA,aAAAC;AAAA,EACA,kBAAAC;AAAA,EACA,mBAAAC;AAAA,EACA,sBAAAC;AAAA,EACA,YAAAC,IAAa;AACf,MAAM;AACJ,QAAMC,IAAaC,EAAuB,IAAI,GACxCC,IAAeD,EAAuB,IAAI,GAC1C,CAACE,GAAmBC,CAAoB,IAAIC,EAAS,EAAI,GACzD,CAACC,GAAoBC,CAAqB,IAAIF,EAAS,EAAK,GAC5D,CAACG,GAAqBC,CAAsB,IAAIJ,EAAS,EAAK,GAC9D,CAACK,GAAcC,CAAe,IAAIN,EAAS,EAAK,GAChDO,IAAoBX,EAA2B,EAAE,GACjDY,IAAqBZ,EAA4B,EAAE,GACnDa,IAAgBb,EAAO,CAAC,GACxBc,IAAiBd,EAAO,CAAC,GACzBe,IAAgBf,EAAsB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YACL,SAASF;AAAA,YACT,OAAO;AAAA,cACL,UAAU;AAAA,cACV,KAAK;AAAA,cACL,OAAO;AAAA,cACP,QAAQ;AAAA,cACR,SAAS;AAAA,cACT,cAAc;AAAA,cACd,QAAQ;AAAA,cACR,YAAY;AAAA,cACZ,OAAO;AAAA,cACP,UAAU;AAAA,cACV,YAAY;AAAA,cACZ,QAAQ;AAAA,cACR,WAAW;AAAA,YAAA;AAAA,YAGZ,UAAA7C,IACGZ,KAAwB,oBACxBA,KAAwB;AAAA,UAAA;AAAA,QAAA;AAAA,QAE7BwD,KACCE,gBAAAA,EAAAA;AAAAA,UAAC;AAAA,UAAA;AAAA,YACC,OAAO;AAAA,cACL,UAAU;AAAA,cACV,OAAO;AAAA,cACP,SAAS;AAAA,cACT,YAAY;AAAA,cACZ,gBAAgB;AAAA,cAChB,YAAY;AAAA,cACZ,OAAO;AAAA,cACP,UAAU;AAAA,cACV,YAAY;AAAA,cACZ,KAAK;AAAA,cACL,eAAe;AAAA,cACf,QAAQ;AAAA,YAAA;AAAA,YAGV,UAAA;AAAA,cAAAC,gBAAAA,EAAAA;AAAAA,gBAACC;AAAAA,gBAAA;AAAA,kBACC,eAAW;AAAA,kBACX,MAAM;AAAA,kBACN,OAAO,EAAE,WAAW,kCAAA;AAAA,gBAAkC;AAAA,cAAA;AAAA,cAEvDJ;AAAA,YAAA;AAAA,UAAA;AAAA,QAAA;AAAA,MACH;AAAA,IAAA;AAAA,EAAA;AAIR;"}
|
|
1
|
+
{"version":3,"file":"SandboxApp.js","sources":["../../../src/components/ContentRender/SandboxApp.tsx"],"sourcesContent":["import React, { useEffect, useRef, useState } from \"react\";\nimport { Loader2 } from \"lucide-react\";\n\nexport interface SandboxAppProps {\n html: string;\n loadingText?: string;\n styleLoadingText?: string;\n scriptLoadingText?: string;\n resetToken?: number;\n}\n\nconst SandboxApp: React.FC<SandboxAppProps> = ({\n html,\n loadingText,\n styleLoadingText,\n scriptLoadingText,\n resetToken = 0,\n}) => {\n const wrapperRef = useRef<HTMLDivElement>(null);\n const containerRef = useRef<HTMLDivElement>(null);\n const [isWaitingFirstDiv, setIsWaitingFirstDiv] = useState(true);\n const [isGeneratingStyles, setIsGeneratingStyles] = useState(false);\n const [isGeneratingScripts, setIsGeneratingScripts] = useState(false);\n const appendedStylesRef = useRef<HTMLStyleElement[]>([]);\n const appendedScriptsRef = useRef<HTMLScriptElement[]>([]);\n const styleStartRef = useRef(0);\n const scriptStartRef = useRef(0);\n const styleTimerRef = useRef<number | null>(null);\n const scriptTimerRef = useRef<number | null>(null);\n const hasStylesRef = useRef(false);\n const hasScriptsRef = useRef(false);\n const hasRenderedContentRef = useRef(false);\n const prevResetTokenRef = useRef(resetToken);\n const MIN_LOADING_MS = 200;\n\n const clearTimer = (timerRef: React.MutableRefObject<number | null>) => {\n if (timerRef.current) {\n clearTimeout(timerRef.current);\n timerRef.current = null;\n }\n };\n\n const settleStateWithMinimumDelay = (\n setter: React.Dispatch<React.SetStateAction<boolean>>,\n timerRef: React.MutableRefObject<number | null>,\n startRef: React.MutableRefObject<number>,\n onDone?: () => void\n ) => {\n const elapsed = performance.now() - startRef.current;\n const delay = Math.max(0, MIN_LOADING_MS - elapsed);\n clearTimer(timerRef);\n timerRef.current = window.setTimeout(() => {\n setter(false);\n onDone?.();\n timerRef.current = null;\n }, delay);\n };\n\n useEffect(() => {\n const doc = containerRef.current?.ownerDocument;\n if (!doc) return;\n const styleId = \"sandbox-spinner-style\";\n let styleEl = doc.getElementById(styleId) as HTMLStyleElement | null;\n if (!styleEl) {\n styleEl = doc.createElement(\"style\");\n styleEl.id = styleId;\n styleEl.textContent =\n \"@keyframes sandbox-spin { from { transform: rotate(0deg);} to { transform: rotate(360deg);} }\";\n doc.head?.appendChild(styleEl);\n }\n }, []);\n\n useEffect(() => {\n if (resetToken !== prevResetTokenRef.current) {\n hasRenderedContentRef.current = false;\n prevResetTokenRef.current = resetToken;\n }\n clearTimer(styleTimerRef);\n clearTimer(scriptTimerRef);\n hasStylesRef.current = false;\n hasScriptsRef.current = false;\n\n const container = containerRef.current;\n if (!container) return;\n const doc = container.ownerDocument;\n const body = doc?.body;\n if (!body) return;\n\n appendedStylesRef.current.forEach((node) => node.remove());\n appendedStylesRef.current = [];\n appendedScriptsRef.current.forEach((node) => node.remove());\n appendedScriptsRef.current = [];\n\n const hasRenderedBefore = hasRenderedContentRef.current;\n setIsWaitingFirstDiv(!hasRenderedBefore);\n setIsGeneratingStyles(false);\n setIsGeneratingScripts(false);\n container.innerHTML = \"\";\n const wrapper = document.createElement(\"div\");\n wrapper.innerHTML = html;\n\n const openScriptCount = (html.match(/<script[\\s>]/gi) || []).length;\n const closeScriptCount = (html.match(/<\\/script>/gi) || []).length;\n const shouldExecuteScripts =\n openScriptCount > 0 && openScriptCount === closeScriptCount;\n\n const resourceQueue: HTMLElement[] = [];\n\n Array.from(wrapper.querySelectorAll(\"style, script\")).forEach((node) => {\n if (node.tagName.toLowerCase() === \"style\") {\n const cloned = doc.createElement(\"style\");\n cloned.textContent = node.textContent || \"\";\n Array.from(node.attributes).forEach((attr) => {\n cloned.setAttribute(attr.name, attr.value);\n });\n resourceQueue.push(cloned);\n } else {\n const replacement = doc.createElement(\"script\");\n Array.from(node.attributes).forEach((attr) => {\n replacement.setAttribute(attr.name, attr.value);\n });\n replacement.textContent = node.textContent || \"\";\n resourceQueue.push(replacement);\n }\n node.remove();\n });\n\n const hasStyles = resourceQueue.some(\n (node) => node.tagName.toLowerCase() === \"style\"\n );\n const hasScripts = resourceQueue.some(\n (node) => node.tagName.toLowerCase() === \"script\"\n );\n if (hasStyles) {\n hasStylesRef.current = true;\n styleStartRef.current = performance.now();\n clearTimer(styleTimerRef);\n setIsGeneratingStyles(true);\n }\n if (hasScripts) {\n hasScriptsRef.current = true;\n scriptStartRef.current = performance.now();\n clearTimer(scriptTimerRef);\n setIsGeneratingScripts(true);\n }\n\n const hasFirstElement = !!wrapper.firstElementChild;\n setIsWaitingFirstDiv(!hasFirstElement && !hasRenderedBefore);\n if (hasFirstElement) {\n hasRenderedContentRef.current = true;\n }\n\n const contentNodes = Array.from(wrapper.childNodes);\n container.append(...contentNodes);\n\n resourceQueue.forEach((node) => {\n if (node.tagName.toLowerCase() === \"style\") {\n doc.head?.appendChild(node);\n appendedStylesRef.current.push(node as HTMLStyleElement);\n return;\n }\n\n if (shouldExecuteScripts) {\n const scriptNode = node as HTMLScriptElement;\n const scriptText = scriptNode.textContent || \"\";\n const shouldValidate = !scriptNode.src;\n\n if (shouldValidate) {\n try {\n // Validate script is syntactically complete before executing\n\n new Function(scriptText);\n } catch {\n scriptNode.remove();\n return;\n }\n }\n\n try {\n body.appendChild(scriptNode);\n appendedScriptsRef.current.push(scriptNode);\n } catch {\n scriptNode.remove();\n }\n } else {\n // Defer execution until all script tags are fully received\n node.remove();\n }\n });\n requestAnimationFrame(() => {\n if (hasStyles) {\n settleStateWithMinimumDelay(\n setIsGeneratingStyles,\n styleTimerRef,\n styleStartRef,\n () => {\n hasStylesRef.current = false;\n }\n );\n }\n if (hasScripts) {\n settleStateWithMinimumDelay(\n setIsGeneratingScripts,\n scriptTimerRef,\n scriptStartRef,\n () => {\n hasScriptsRef.current = false;\n }\n );\n }\n });\n }, [html, resetToken]);\n\n useEffect(\n () => () => {\n clearTimer(styleTimerRef);\n clearTimer(scriptTimerRef);\n },\n []\n );\n\n const overlayMessage = (() => {\n if (isGeneratingScripts || hasScriptsRef.current)\n return scriptLoadingText || \"Building scripts cache...\";\n if (isGeneratingStyles || hasStylesRef.current)\n return styleLoadingText || \"Building styles...\";\n if (isWaitingFirstDiv) return loadingText || \"Loading...\";\n return null;\n })();\n\n return (\n <div\n ref={wrapperRef}\n style={{ position: \"relative\", minHeight: 120 }}\n aria-busy={!!overlayMessage}\n >\n <div\n ref={containerRef}\n style={{\n pointerEvents: overlayMessage ? \"none\" : undefined,\n }}\n />\n {overlayMessage && (\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n background: \"rgba(51, 51, 51, 0.80)\",\n color: \"#ffffff\",\n fontSize: 16,\n fontWeight: 700,\n gap: 10,\n pointerEvents: \"auto\",\n zIndex: 20,\n }}\n >\n <Loader2\n aria-hidden\n size={20}\n style={{ animation: \"sandbox-spin 1s linear infinite\" }}\n />\n {overlayMessage}\n </div>\n )}\n </div>\n );\n};\n\nexport default SandboxApp;\n"],"names":["SandboxApp","html","loadingText","styleLoadingText","scriptLoadingText","resetToken","wrapperRef","useRef","containerRef","isWaitingFirstDiv","setIsWaitingFirstDiv","useState","isGeneratingStyles","setIsGeneratingStyles","isGeneratingScripts","setIsGeneratingScripts","appendedStylesRef","appendedScriptsRef","styleStartRef","scriptStartRef","styleTimerRef","scriptTimerRef","hasStylesRef","hasScriptsRef","hasRenderedContentRef","prevResetTokenRef","MIN_LOADING_MS","clearTimer","timerRef","settleStateWithMinimumDelay","setter","startRef","onDone","elapsed","delay","useEffect","doc","styleId","styleEl","container","body","node","hasRenderedBefore","wrapper","openScriptCount","closeScriptCount","shouldExecuteScripts","resourceQueue","cloned","attr","replacement","hasStyles","hasScripts","hasFirstElement","contentNodes","scriptNode","scriptText","overlayMessage","jsxs","jsx","Loader2"],"mappings":";;;AAWA,MAAMA,IAAwC,CAAC;AAAA,EAC7C,MAAAC;AAAA,EACA,aAAAC;AAAA,EACA,kBAAAC;AAAA,EACA,mBAAAC;AAAA,EACA,YAAAC,IAAa;AACf,MAAM;AACJ,QAAMC,IAAaC,EAAuB,IAAI,GACxCC,IAAeD,EAAuB,IAAI,GAC1C,CAACE,GAAmBC,CAAoB,IAAIC,EAAS,EAAI,GACzD,CAACC,GAAoBC,CAAqB,IAAIF,EAAS,EAAK,GAC5D,CAACG,GAAqBC,CAAsB,IAAIJ,EAAS,EAAK,GAC9DK,IAAoBT,EAA2B,EAAE,GACjDU,IAAqBV,EAA4B,EAAE,GACnDW,IAAgBX,EAAO,CAAC,GACxBY,IAAiBZ,EAAO,CAAC,GACzBa,IAAgBb,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,QAAA;AAAA,MACH;AAAA,IAAA;AAAA,EAAA;AAIR;"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { j as i } from "../../../_virtual/jsx-runtime.js";
|
|
2
2
|
import * as d from "react";
|
|
3
3
|
import n from "../../../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rc-textarea@1.10.2_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-textarea/es/TextArea.js";
|
|
4
|
-
import "../../../_virtual/
|
|
4
|
+
import "../../../_virtual/index4.js";
|
|
5
5
|
import "../../../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rc-resize-observer@1.4.3_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-resize-observer/es/index.js";
|
|
6
6
|
import "../../../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rc-util@5.44.4_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-util/es/hooks/useLayoutEffect.js";
|
|
7
7
|
import "../../../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rc-util@5.44.4_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-util/es/raf.js";
|