@dxos/plugin-script 0.6.12-main.5cc132e → 0.6.12-main.78ddbdf
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/lib/browser/{ScriptEditor-5Y3EROG3.mjs → ScriptContainer-7DE7USCY.mjs} +257 -106
- package/dist/lib/browser/ScriptContainer-7DE7USCY.mjs.map +7 -0
- package/dist/lib/browser/{chunk-O4LWBX6A.mjs → chunk-CAEANETO.mjs} +2 -2
- package/dist/lib/browser/{chunk-O4LWBX6A.mjs.map → chunk-CAEANETO.mjs.map} +2 -2
- package/dist/lib/browser/{chunk-DL5XQRQM.mjs → chunk-G6FWCTGT.mjs} +7 -5
- package/dist/lib/browser/chunk-G6FWCTGT.mjs.map +7 -0
- package/dist/lib/{node-esm/chunk-RHEZ5LUU.mjs → browser/chunk-G6H56WFS.mjs} +51 -2
- package/dist/lib/{node-esm/chunk-RHEZ5LUU.mjs.map → browser/chunk-G6H56WFS.mjs.map} +4 -4
- package/dist/lib/browser/{chunk-JBACGDOJ.mjs → chunk-MDX7ACIK.mjs} +3 -6
- package/dist/lib/browser/chunk-MDX7ACIK.mjs.map +7 -0
- package/dist/lib/browser/edge/index.mjs +3 -1
- package/dist/lib/browser/index.mjs +80 -61
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/meta.mjs +1 -1
- package/dist/lib/browser/types/index.mjs +2 -2
- package/dist/lib/node/ScriptContainer-J76LKPAM.cjs +667 -0
- package/dist/lib/node/ScriptContainer-J76LKPAM.cjs.map +7 -0
- package/dist/lib/node/{chunk-5RBVXKXT.cjs → chunk-2PZKJXNP.cjs} +6 -6
- package/dist/lib/node/{chunk-5RBVXKXT.cjs.map → chunk-2PZKJXNP.cjs.map} +2 -2
- package/dist/lib/node/{chunk-4GTXIELQ.cjs → chunk-ACLCRWDB.cjs} +44 -6
- package/dist/lib/node/chunk-ACLCRWDB.cjs.map +7 -0
- package/dist/lib/node/{TypescriptEditor-M3WWFIP2.cjs → chunk-OJ77BZRH.cjs} +19 -8
- package/dist/lib/node/chunk-OJ77BZRH.cjs.map +7 -0
- package/dist/lib/node/{chunk-PFH3ROEH.cjs → chunk-UZ3ZXEBF.cjs} +11 -8
- package/dist/lib/node/chunk-UZ3ZXEBF.cjs.map +7 -0
- package/dist/lib/node/edge/index.cjs +10 -8
- package/dist/lib/node/edge/index.cjs.map +2 -2
- package/dist/lib/node/index.cjs +93 -79
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.cjs +3 -3
- package/dist/lib/node/meta.cjs.map +1 -1
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/types/index.cjs +5 -5
- package/dist/lib/node/types/index.cjs.map +1 -1
- package/dist/lib/node-esm/{ScriptEditor-5Y3EROG3.mjs → ScriptContainer-F6ACEA63.mjs} +258 -106
- package/dist/lib/node-esm/ScriptContainer-F6ACEA63.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-DL5XQRQM.mjs → chunk-2NX3HWPM.mjs} +9 -5
- package/dist/lib/node-esm/chunk-2NX3HWPM.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-O4LWBX6A.mjs → chunk-7BZDZF7Z.mjs} +3 -2
- package/dist/lib/node-esm/{chunk-O4LWBX6A.mjs.map → chunk-7BZDZF7Z.mjs.map} +2 -2
- package/dist/lib/{browser/chunk-RHEZ5LUU.mjs → node-esm/chunk-LDLNTVAK.mjs} +53 -2
- package/dist/lib/node-esm/chunk-LDLNTVAK.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-JBACGDOJ.mjs → chunk-TZ3Z4SII.mjs} +5 -6
- package/dist/lib/node-esm/chunk-TZ3Z4SII.mjs.map +7 -0
- package/dist/lib/node-esm/edge/index.mjs +4 -1
- package/dist/lib/node-esm/index.mjs +81 -61
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/meta.mjs +2 -1
- package/dist/lib/node-esm/types/index.mjs +3 -2
- package/dist/types/src/ScriptPlugin.d.ts.map +1 -1
- package/dist/types/src/components/DebugPanel/DebugPanel.d.ts.map +1 -0
- package/dist/types/src/components/DebugPanel/index.d.ts +2 -0
- package/dist/types/src/components/DebugPanel/index.d.ts.map +1 -0
- package/dist/types/src/components/{ScriptBlock/FrameContainer → FrameContainer}/FrameContainer.d.ts +1 -1
- package/dist/types/src/components/FrameContainer/FrameContainer.d.ts.map +1 -0
- package/dist/types/src/components/FrameContainer/frame.d.ts.map +1 -0
- package/dist/types/src/components/FrameContainer/index.d.ts.map +1 -0
- package/dist/types/src/components/ScriptBlock/ScriptBlock.d.ts +1 -3
- package/dist/types/src/components/ScriptBlock/ScriptBlock.d.ts.map +1 -1
- package/dist/types/src/components/ScriptBlock/ScriptBlock.stories.d.ts +1 -1
- package/dist/types/src/components/ScriptBlock/ScriptBlock.stories.d.ts.map +1 -1
- package/dist/types/src/components/ScriptContainer.d.ts +5 -0
- package/dist/types/src/components/ScriptContainer.d.ts.map +1 -0
- package/dist/types/src/components/ScriptEditor.d.ts +4 -5
- package/dist/types/src/components/ScriptEditor.d.ts.map +1 -1
- package/dist/types/src/components/ScriptSettings/ScriptSettings.d.ts +6 -0
- package/dist/types/src/components/ScriptSettings/ScriptSettings.d.ts.map +1 -0
- package/dist/types/src/components/ScriptSettings/index.d.ts +2 -0
- package/dist/types/src/components/ScriptSettings/index.d.ts.map +1 -0
- package/dist/types/src/components/Toolbar/Toolbar.d.ts +23 -0
- package/dist/types/src/components/Toolbar/Toolbar.d.ts.map +1 -0
- package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts +17 -0
- package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts.map +1 -0
- package/dist/types/src/components/Toolbar/index.d.ts +2 -0
- package/dist/types/src/components/Toolbar/index.d.ts.map +1 -0
- package/dist/types/src/components/{TypescriptEditor.d.ts → TypescriptEditor/TypescriptEditor.d.ts} +1 -2
- package/dist/types/src/components/TypescriptEditor/TypescriptEditor.d.ts.map +1 -0
- package/dist/types/src/components/TypescriptEditor/TypescriptEditor.stories.d.ts +10 -0
- package/dist/types/src/components/TypescriptEditor/TypescriptEditor.stories.d.ts.map +1 -0
- package/dist/types/src/components/TypescriptEditor/index.d.ts +2 -0
- package/dist/types/src/components/TypescriptEditor/index.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +2 -2
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/edge/functions.d.ts +1 -0
- package/dist/types/src/edge/functions.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +1 -4
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/templates/chat.d.ts +6 -0
- package/dist/types/src/templates/chat.d.ts.map +1 -0
- package/dist/types/src/templates/chess.d.ts +6 -0
- package/dist/types/src/templates/chess.d.ts.map +1 -0
- package/dist/types/src/templates/echo.d.ts +6 -0
- package/dist/types/src/templates/echo.d.ts.map +1 -0
- package/dist/types/src/templates/email.d.ts +6 -0
- package/dist/types/src/templates/email.d.ts.map +1 -0
- package/dist/types/src/templates/forex.d.ts +6 -0
- package/dist/types/src/templates/forex.d.ts.map +1 -0
- package/dist/types/src/templates.d.ts +8 -0
- package/dist/types/src/templates.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +2 -0
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/script.d.ts +4 -4
- package/dist/types/src/types/types.d.ts +4 -3
- package/dist/types/src/types/types.d.ts.map +1 -1
- package/package.json +38 -37
- package/src/ScriptPlugin.tsx +21 -36
- package/src/components/{DebugPanel.tsx → DebugPanel/DebugPanel.tsx} +48 -41
- package/src/components/DebugPanel/index.ts +5 -0
- package/src/components/{ScriptBlock/FrameContainer → FrameContainer}/FrameContainer.tsx +1 -1
- package/src/components/ScriptBlock/ScriptBlock.stories.tsx +4 -3
- package/src/components/ScriptBlock/ScriptBlock.tsx +10 -36
- package/src/components/ScriptContainer.tsx +22 -0
- package/src/components/ScriptEditor.tsx +47 -46
- package/src/components/ScriptSettings/ScriptSettings.tsx +47 -0
- package/src/components/ScriptSettings/index.ts +5 -0
- package/src/components/{Toolbar.stories.tsx → Toolbar/Toolbar.stories.tsx} +10 -1
- package/src/components/Toolbar/Toolbar.tsx +180 -0
- package/src/components/{ScriptBlock/Splitter → Toolbar}/index.ts +1 -1
- package/src/components/{TypescriptEditor.stories.tsx → TypescriptEditor/TypescriptEditor.stories.tsx} +7 -28
- package/src/components/{TypescriptEditor.tsx → TypescriptEditor/TypescriptEditor.tsx} +1 -3
- package/src/components/TypescriptEditor/index.ts +5 -0
- package/src/components/index.ts +3 -2
- package/src/edge/functions.ts +1 -0
- package/src/meta.tsx +2 -6
- package/src/templates/chat.ts +102 -0
- package/src/templates/chess.ts +41 -0
- package/src/templates/echo.ts +15 -0
- package/src/templates/email.ts +38 -0
- package/src/templates/forex.ts +21 -0
- package/src/templates.ts +54 -0
- package/src/translations.ts +2 -0
- package/src/types/types.ts +9 -5
- package/dist/lib/browser/ScriptEditor-5Y3EROG3.mjs.map +0 -7
- package/dist/lib/browser/TypescriptEditor-GPE72Y6I.mjs +0 -9
- package/dist/lib/browser/TypescriptEditor-GPE72Y6I.mjs.map +0 -7
- package/dist/lib/browser/chunk-DL5XQRQM.mjs.map +0 -7
- package/dist/lib/browser/chunk-JBACGDOJ.mjs.map +0 -7
- package/dist/lib/browser/chunk-MRGOT5RF.mjs +0 -78
- package/dist/lib/browser/chunk-MRGOT5RF.mjs.map +0 -7
- package/dist/lib/browser/chunk-RHEZ5LUU.mjs.map +0 -7
- package/dist/lib/node/ScriptEditor-YCUQFWQM.cjs +0 -526
- package/dist/lib/node/ScriptEditor-YCUQFWQM.cjs.map +0 -7
- package/dist/lib/node/TypescriptEditor-M3WWFIP2.cjs.map +0 -7
- package/dist/lib/node/chunk-4GTXIELQ.cjs.map +0 -7
- package/dist/lib/node/chunk-4VMNBXWU.cjs +0 -54
- package/dist/lib/node/chunk-4VMNBXWU.cjs.map +0 -7
- package/dist/lib/node/chunk-IMLDKD5Y.cjs +0 -111
- package/dist/lib/node/chunk-IMLDKD5Y.cjs.map +0 -7
- package/dist/lib/node/chunk-PFH3ROEH.cjs.map +0 -7
- package/dist/lib/node-esm/ScriptEditor-5Y3EROG3.mjs.map +0 -7
- package/dist/lib/node-esm/TypescriptEditor-GPE72Y6I.mjs +0 -9
- package/dist/lib/node-esm/TypescriptEditor-GPE72Y6I.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-DL5XQRQM.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-JBACGDOJ.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-MRGOT5RF.mjs +0 -78
- package/dist/lib/node-esm/chunk-MRGOT5RF.mjs.map +0 -7
- package/dist/types/src/components/DebugPanel.d.ts.map +0 -1
- package/dist/types/src/components/ScriptBlock/FrameContainer/FrameContainer.d.ts.map +0 -1
- package/dist/types/src/components/ScriptBlock/FrameContainer/frame.d.ts.map +0 -1
- package/dist/types/src/components/ScriptBlock/FrameContainer/index.d.ts.map +0 -1
- package/dist/types/src/components/ScriptBlock/Splitter/Splitter.d.ts +0 -15
- package/dist/types/src/components/ScriptBlock/Splitter/Splitter.d.ts.map +0 -1
- package/dist/types/src/components/ScriptBlock/Splitter/Splitter.stories.d.ts +0 -13
- package/dist/types/src/components/ScriptBlock/Splitter/Splitter.stories.d.ts.map +0 -1
- package/dist/types/src/components/ScriptBlock/Splitter/index.d.ts +0 -2
- package/dist/types/src/components/ScriptBlock/Splitter/index.d.ts.map +0 -1
- package/dist/types/src/components/Toolbar.d.ts +0 -13
- package/dist/types/src/components/Toolbar.d.ts.map +0 -1
- package/dist/types/src/components/Toolbar.stories.d.ts +0 -14
- package/dist/types/src/components/Toolbar.stories.d.ts.map +0 -1
- package/dist/types/src/components/TypescriptEditor.d.ts.map +0 -1
- package/dist/types/src/components/TypescriptEditor.stories.d.ts +0 -10
- package/dist/types/src/components/TypescriptEditor.stories.d.ts.map +0 -1
- package/src/components/ScriptBlock/Splitter/Splitter.stories.tsx +0 -37
- package/src/components/ScriptBlock/Splitter/Splitter.tsx +0 -52
- package/src/components/Toolbar.tsx +0 -147
- /package/dist/types/src/components/{DebugPanel.d.ts → DebugPanel/DebugPanel.d.ts} +0 -0
- /package/dist/types/src/components/{ScriptBlock/FrameContainer → FrameContainer}/frame.d.ts +0 -0
- /package/dist/types/src/components/{ScriptBlock/FrameContainer → FrameContainer}/index.d.ts +0 -0
- /package/src/components/{ScriptBlock/FrameContainer → FrameContainer}/frame.html +0 -0
- /package/src/components/{ScriptBlock/FrameContainer → FrameContainer}/frame.tsx +0 -0
- /package/src/components/{ScriptBlock/FrameContainer → FrameContainer}/index.ts +0 -0
|
@@ -18,13 +18,13 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var types_exports = {};
|
|
20
20
|
__export(types_exports, {
|
|
21
|
-
FunctionType: () =>
|
|
22
|
-
ScriptAction: () =>
|
|
23
|
-
ScriptType: () =>
|
|
21
|
+
FunctionType: () => import_chunk_2PZKJXNP.FunctionType,
|
|
22
|
+
ScriptAction: () => import_chunk_2PZKJXNP.ScriptAction,
|
|
23
|
+
ScriptType: () => import_chunk_2PZKJXNP.ScriptType
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(types_exports);
|
|
26
|
-
var
|
|
27
|
-
var
|
|
26
|
+
var import_chunk_2PZKJXNP = require("../chunk-2PZKJXNP.cjs");
|
|
27
|
+
var import_chunk_OJ77BZRH = require("../chunk-OJ77BZRH.cjs");
|
|
28
28
|
// Annotate the CommonJS export names for ESM import in node:
|
|
29
29
|
0 && (module.exports = {
|
|
30
30
|
FunctionType,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["index.cjs"],
|
|
4
|
-
"sourcesContent": ["import {\n FunctionType,\n ScriptAction,\n ScriptType\n} from \"../chunk-
|
|
4
|
+
"sourcesContent": ["import {\n FunctionType,\n ScriptAction,\n ScriptType\n} from \"../chunk-2PZKJXNP.cjs\";\nimport \"../chunk-OJ77BZRH.cjs\";\nexport {\n FunctionType,\n ScriptAction,\n ScriptType\n};\n//# sourceMappingURL=index.cjs.map\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,4BAIO;AACP,4BAAO;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,43 +1,48 @@
|
|
|
1
|
+
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
1
2
|
import {
|
|
3
|
+
USERFUNCTIONS_PRESET_META_KEY,
|
|
2
4
|
getUserFunctionUrlInMetadata,
|
|
3
5
|
publicKeyToDid,
|
|
4
6
|
setUserFunctionUrlInMetadata,
|
|
5
7
|
uploadWorkerFunction
|
|
6
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-2NX3HWPM.mjs";
|
|
7
9
|
import {
|
|
8
|
-
Bundler
|
|
9
|
-
|
|
10
|
+
Bundler,
|
|
11
|
+
templates
|
|
12
|
+
} from "./chunk-LDLNTVAK.mjs";
|
|
10
13
|
import {
|
|
11
14
|
FunctionType
|
|
12
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-7BZDZF7Z.mjs";
|
|
13
16
|
import {
|
|
14
17
|
SCRIPT_PLUGIN
|
|
15
|
-
} from "./chunk-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
} from "./chunk-TZ3Z4SII.mjs";
|
|
19
|
+
|
|
20
|
+
// packages/plugins/experimental/plugin-script/src/components/ScriptContainer.tsx
|
|
21
|
+
import React5 from "react";
|
|
22
|
+
import { fullyQualifiedId } from "@dxos/react-client/echo";
|
|
23
|
+
import { useHasAttention } from "@dxos/react-ui-attention";
|
|
24
|
+
import { mx as mx3 } from "@dxos/react-ui-theme";
|
|
19
25
|
|
|
20
26
|
// packages/plugins/experimental/plugin-script/src/components/ScriptEditor.tsx
|
|
21
27
|
import { format } from "prettier";
|
|
22
28
|
import prettierPluginEstree from "prettier/plugins/estree";
|
|
23
29
|
import prettierPluginTypescript from "prettier/plugins/typescript";
|
|
24
|
-
import
|
|
30
|
+
import React4, { useCallback, useMemo, useState as useState3 } from "react";
|
|
25
31
|
import { log as log2 } from "@dxos/log";
|
|
26
32
|
import { useClient } from "@dxos/react-client";
|
|
27
|
-
import { create, createDocAccessor, Filter,
|
|
33
|
+
import { create, createDocAccessor, Filter, getMeta, getSpace, useQuery } from "@dxos/react-client/echo";
|
|
28
34
|
import { useIdentity } from "@dxos/react-client/halo";
|
|
29
35
|
import { useTranslation as useTranslation3 } from "@dxos/react-ui";
|
|
30
|
-
import { useHasAttention } from "@dxos/react-ui-attention";
|
|
31
36
|
import { createDataExtensions, listener } from "@dxos/react-ui-editor";
|
|
32
37
|
import { mx as mx2 } from "@dxos/react-ui-theme";
|
|
33
38
|
|
|
34
|
-
// packages/plugins/experimental/plugin-script/src/components/DebugPanel.tsx
|
|
39
|
+
// packages/plugins/experimental/plugin-script/src/components/DebugPanel/DebugPanel.tsx
|
|
35
40
|
import React, { useEffect, useRef, useState } from "react";
|
|
36
41
|
import { log } from "@dxos/log";
|
|
37
42
|
import { Avatar, DensityProvider, Icon, Input, Toolbar, useControlledValue, useTranslation } from "@dxos/react-ui";
|
|
38
43
|
import { SyntaxHighlighter } from "@dxos/react-ui-syntax-highlighter";
|
|
39
44
|
import { mx } from "@dxos/react-ui-theme";
|
|
40
|
-
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/experimental/plugin-script/src/components/DebugPanel.tsx";
|
|
45
|
+
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/experimental/plugin-script/src/components/DebugPanel/DebugPanel.tsx";
|
|
41
46
|
var DebugPanel = ({ classNames, functionUrl, binding: _binding, onBindingChange }) => {
|
|
42
47
|
const { t } = useTranslation(SCRIPT_PLUGIN);
|
|
43
48
|
const bindingInputRef = useRef(null);
|
|
@@ -221,52 +226,62 @@ var DebugPanel = ({ classNames, functionUrl, binding: _binding, onBindingChange
|
|
|
221
226
|
size: 4
|
|
222
227
|
})))));
|
|
223
228
|
};
|
|
224
|
-
var RobotAvatar = () => /* @__PURE__ */ React.createElement(Avatar.Root, {
|
|
225
|
-
size: 6,
|
|
226
|
-
variant: "circle"
|
|
227
|
-
}, /* @__PURE__ */ React.createElement(Avatar.Frame, null, /* @__PURE__ */ React.createElement(Avatar.Icon, {
|
|
228
|
-
icon: "ph--robot--regular"
|
|
229
|
-
})));
|
|
230
|
-
var MessageItem = ({ classNames, message }) => {
|
|
231
|
-
const { text, data, error } = message;
|
|
232
|
-
if (error) {
|
|
233
|
-
return /* @__PURE__ */ React.createElement("span", {
|
|
234
|
-
className: mx(classNames, "whitespace-pre text-error")
|
|
235
|
-
}, String(error));
|
|
236
|
-
} else if (data) {
|
|
237
|
-
return /* @__PURE__ */ React.createElement(SyntaxHighlighter, {
|
|
238
|
-
language: "json",
|
|
239
|
-
className: mx("text-xs", classNames)
|
|
240
|
-
}, JSON.stringify(data, null, 2));
|
|
241
|
-
}
|
|
242
|
-
return /* @__PURE__ */ React.createElement("span", {
|
|
243
|
-
className: mx(classNames)
|
|
244
|
-
}, text || "\xD8");
|
|
245
|
-
};
|
|
246
229
|
var MessageThread = ({ state, result, history }) => {
|
|
247
230
|
return /* @__PURE__ */ React.createElement(React.Fragment, null, history.map((message, i) => /* @__PURE__ */ React.createElement("div", {
|
|
248
231
|
key: i,
|
|
249
|
-
className: "grid grid-cols-[
|
|
250
|
-
}, /* @__PURE__ */ React.createElement("div",
|
|
251
|
-
className:
|
|
232
|
+
className: "grid grid-cols-[3rem_1fr_3rem]"
|
|
233
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
234
|
+
className: "p-1"
|
|
235
|
+
}, message.type === "response" && /* @__PURE__ */ React.createElement(RobotAvatar, null)), /* @__PURE__ */ React.createElement("div", {
|
|
236
|
+
className: "overflow-auto"
|
|
252
237
|
}, /* @__PURE__ */ React.createElement(MessageItem, {
|
|
253
|
-
classNames: [
|
|
254
|
-
message.type === "request" && "p-1 px-2 rounded-lg bg-hoverSurface"
|
|
255
|
-
],
|
|
256
238
|
message
|
|
257
|
-
})))), /* @__PURE__ */ React.createElement("div", {
|
|
258
|
-
className: "grid grid-cols-[
|
|
259
|
-
}, /* @__PURE__ */ React.createElement("div",
|
|
239
|
+
})))), result?.length > 0 && /* @__PURE__ */ React.createElement("div", {
|
|
240
|
+
className: "grid grid-cols-[3rem_1fr_3rem]"
|
|
241
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
242
|
+
className: "p-1"
|
|
243
|
+
}, state === "pending" && /* @__PURE__ */ React.createElement(Icon, {
|
|
260
244
|
icon: "ph--spinner--regular",
|
|
261
245
|
size: 6,
|
|
262
|
-
classNames: "animate-spin
|
|
263
|
-
}) ||
|
|
246
|
+
classNames: "animate-spin"
|
|
247
|
+
}) || /* @__PURE__ */ React.createElement(Icon, {
|
|
248
|
+
icon: "ph--robot--regular",
|
|
249
|
+
size: 6,
|
|
250
|
+
classNames: "animate-[pulse_1s_ease-in-out_infinite]"
|
|
251
|
+
})), /* @__PURE__ */ React.createElement("div", {
|
|
252
|
+
className: "overflow-auto"
|
|
253
|
+
}, /* @__PURE__ */ React.createElement(MessageItem, {
|
|
254
|
+
message: {
|
|
255
|
+
type: "response",
|
|
256
|
+
text: result
|
|
257
|
+
}
|
|
258
|
+
}))));
|
|
264
259
|
};
|
|
260
|
+
var MessageItem = ({ classNames, message }) => {
|
|
261
|
+
const { type, text, data, error } = message;
|
|
262
|
+
const wrapper = "p-1 px-2 rounded-lg bg-hoverSurface overflow-auto";
|
|
263
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
264
|
+
className: mx("flex", type === "request" ? "ml-[8rem] justify-end" : "mr-[8rem]", classNames)
|
|
265
|
+
}, error && /* @__PURE__ */ React.createElement("div", {
|
|
266
|
+
className: mx(wrapper, "whitespace-pre text-error")
|
|
267
|
+
}, String(error)), text !== void 0 && /* @__PURE__ */ React.createElement("div", {
|
|
268
|
+
className: mx(wrapper, type === "request" && "bg-primary-400 dark:bg-primary-600")
|
|
269
|
+
}, text || "\xD8"), data && /* @__PURE__ */ React.createElement(SyntaxHighlighter, {
|
|
270
|
+
language: "json",
|
|
271
|
+
className: mx(wrapper, "px-8 py-2 text-xs")
|
|
272
|
+
}, JSON.stringify(data, null, 2)));
|
|
273
|
+
};
|
|
274
|
+
var RobotAvatar = () => /* @__PURE__ */ React.createElement(Avatar.Root, {
|
|
275
|
+
size: 6,
|
|
276
|
+
variant: "circle"
|
|
277
|
+
}, /* @__PURE__ */ React.createElement(Avatar.Frame, null, /* @__PURE__ */ React.createElement(Avatar.Icon, {
|
|
278
|
+
icon: "ph--robot--regular"
|
|
279
|
+
})));
|
|
265
280
|
|
|
266
|
-
// packages/plugins/experimental/plugin-script/src/components/Toolbar.tsx
|
|
281
|
+
// packages/plugins/experimental/plugin-script/src/components/Toolbar/Toolbar.tsx
|
|
267
282
|
import React2, { useState as useState2 } from "react";
|
|
268
|
-
import { DensityProvider as DensityProvider2, ElevationProvider, Icon as Icon2, Toolbar as NaturalToolbar, Tooltip, useTranslation as useTranslation2 } from "@dxos/react-ui";
|
|
269
|
-
var Toolbar2 = ({ classNames, deployed, error, functionUrl,
|
|
283
|
+
import { DensityProvider as DensityProvider2, ElevationProvider, Icon as Icon2, Select, ToggleGroup, ToggleGroupItem, Toolbar as NaturalToolbar, Tooltip, useTranslation as useTranslation2 } from "@dxos/react-ui";
|
|
284
|
+
var Toolbar2 = ({ classNames, deployed, error, functionUrl, view, templates: templates2, onDeploy, onFormat, onViewChange, onTemplateSelect }) => {
|
|
270
285
|
const { t } = useTranslation2(SCRIPT_PLUGIN);
|
|
271
286
|
const [pending, setPending] = useState2(false);
|
|
272
287
|
const handleCopyLink = async () => {
|
|
@@ -276,9 +291,11 @@ var Toolbar2 = ({ classNames, deployed, error, functionUrl, showPanel, onDeploy,
|
|
|
276
291
|
await navigator.clipboard.writeText(functionUrl);
|
|
277
292
|
};
|
|
278
293
|
const handleDeploy = async () => {
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
294
|
+
if (!pending) {
|
|
295
|
+
setPending(true);
|
|
296
|
+
await onDeploy?.();
|
|
297
|
+
setPending(false);
|
|
298
|
+
}
|
|
282
299
|
};
|
|
283
300
|
return /* @__PURE__ */ React2.createElement(DensityProvider2, {
|
|
284
301
|
density: "fine"
|
|
@@ -292,57 +309,161 @@ var Toolbar2 = ({ classNames, deployed, error, functionUrl, showPanel, onDeploy,
|
|
|
292
309
|
style: {
|
|
293
310
|
contain: "layout"
|
|
294
311
|
}
|
|
295
|
-
},
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
onClick: onFormat
|
|
300
|
-
}, /* @__PURE__ */ React2.createElement(Icon2, {
|
|
312
|
+
}, templates2 && /* @__PURE__ */ React2.createElement(TemplateSelect, {
|
|
313
|
+
templates: templates2,
|
|
314
|
+
onTemplateSelect
|
|
315
|
+
}), onFormat && /* @__PURE__ */ React2.createElement(ToolbarIconButton, {
|
|
301
316
|
icon: "ph--magic-wand--regular",
|
|
302
|
-
|
|
303
|
-
|
|
317
|
+
text: t("format label"),
|
|
318
|
+
onClick: onFormat
|
|
319
|
+
}), /* @__PURE__ */ React2.createElement("div", {
|
|
304
320
|
role: "separator",
|
|
305
321
|
className: "grow"
|
|
306
322
|
}), error ? /* @__PURE__ */ React2.createElement(Tooltip.Root, null, /* @__PURE__ */ React2.createElement(Tooltip.Trigger, null, /* @__PURE__ */ React2.createElement(Icon2, {
|
|
307
323
|
icon: "ph--warning-circle--regular",
|
|
308
324
|
size: 4
|
|
309
|
-
})), /* @__PURE__ */ React2.createElement(Tooltip.Portal, null, /* @__PURE__ */ React2.createElement(Tooltip.Content, null, /* @__PURE__ */ React2.createElement(Tooltip.Arrow, null), error))) : null, functionUrl && deployed && /* @__PURE__ */ React2.createElement(
|
|
310
|
-
asChild: true
|
|
311
|
-
}, /* @__PURE__ */ React2.createElement(NaturalToolbar.Button, {
|
|
312
|
-
variant: "ghost",
|
|
313
|
-
onClick: handleCopyLink
|
|
314
|
-
}, /* @__PURE__ */ React2.createElement(Icon2, {
|
|
325
|
+
})), /* @__PURE__ */ React2.createElement(Tooltip.Portal, null, /* @__PURE__ */ React2.createElement(Tooltip.Content, null, /* @__PURE__ */ React2.createElement(Tooltip.Arrow, null), error))) : null, functionUrl && deployed && /* @__PURE__ */ React2.createElement(ToolbarIconButton, {
|
|
315
326
|
icon: "ph--link--regular",
|
|
316
|
-
|
|
317
|
-
|
|
327
|
+
text: t("copy link label"),
|
|
328
|
+
onClick: handleCopyLink
|
|
329
|
+
}), onDeploy && /* @__PURE__ */ React2.createElement(ToolbarIconButton, {
|
|
330
|
+
icon: pending ? "ph--spinner-gap--regular" : "ph--cloud-arrow-up--regular",
|
|
331
|
+
classNames: [
|
|
332
|
+
pending && "animate-spin"
|
|
333
|
+
],
|
|
334
|
+
text: pending ? t("pending label") : t("deploy label"),
|
|
335
|
+
onClick: handleDeploy
|
|
336
|
+
}), /* @__PURE__ */ React2.createElement(ViewSelector, {
|
|
337
|
+
view,
|
|
338
|
+
onViewChange
|
|
339
|
+
}))));
|
|
340
|
+
};
|
|
341
|
+
var ToolbarIconButton = ({ icon, text, classNames, disabled, onClick }) => {
|
|
342
|
+
return /* @__PURE__ */ React2.createElement(Tooltip.Root, null, /* @__PURE__ */ React2.createElement(Tooltip.Trigger, {
|
|
318
343
|
asChild: true
|
|
319
344
|
}, /* @__PURE__ */ React2.createElement(NaturalToolbar.Button, {
|
|
320
345
|
variant: "ghost",
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
},
|
|
324
|
-
icon
|
|
346
|
+
disabled,
|
|
347
|
+
onClick
|
|
348
|
+
}, /* @__PURE__ */ React2.createElement(Icon2, {
|
|
349
|
+
icon,
|
|
325
350
|
size: 4,
|
|
326
|
-
classNames
|
|
327
|
-
})
|
|
328
|
-
|
|
351
|
+
classNames
|
|
352
|
+
}))), /* @__PURE__ */ React2.createElement(Tooltip.Portal, null, /* @__PURE__ */ React2.createElement(Tooltip.Content, null, /* @__PURE__ */ React2.createElement(Tooltip.Arrow, null), text)));
|
|
353
|
+
};
|
|
354
|
+
var TemplateSelect = ({ templates: templates2 = [], onTemplateSelect }) => {
|
|
355
|
+
return /* @__PURE__ */ React2.createElement(Select.Root, {
|
|
356
|
+
value: "",
|
|
357
|
+
onValueChange: onTemplateSelect
|
|
358
|
+
}, /* @__PURE__ */ React2.createElement(Select.TriggerButton, null), /* @__PURE__ */ React2.createElement(Select.Portal, null, /* @__PURE__ */ React2.createElement(Select.Content, null, /* @__PURE__ */ React2.createElement(Select.Viewport, null, /* @__PURE__ */ React2.createElement(Select.Option, {
|
|
359
|
+
value: ""
|
|
360
|
+
}, "Template"), templates2.map(({ id, name }) => /* @__PURE__ */ React2.createElement(Select.Option, {
|
|
361
|
+
key: id,
|
|
362
|
+
value: id
|
|
363
|
+
}, name))))));
|
|
364
|
+
};
|
|
365
|
+
var ViewSelector = ({ view, onViewChange }) => {
|
|
366
|
+
return /* @__PURE__ */ React2.createElement(ToggleGroup, {
|
|
367
|
+
type: "single",
|
|
368
|
+
value: view,
|
|
369
|
+
onValueChange: (value) => onViewChange?.(value)
|
|
370
|
+
}, /* @__PURE__ */ React2.createElement(ToggleGroupItem, {
|
|
371
|
+
value: "editor",
|
|
372
|
+
classNames: "bg-transparent text-subdued"
|
|
373
|
+
}, /* @__PURE__ */ React2.createElement(Icon2, {
|
|
374
|
+
icon: "ph--code--regular",
|
|
329
375
|
size: 4
|
|
330
|
-
}))
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
376
|
+
})), /* @__PURE__ */ React2.createElement(ToggleGroupItem, {
|
|
377
|
+
value: "split",
|
|
378
|
+
classNames: "bg-transparent text-subdued"
|
|
379
|
+
}, /* @__PURE__ */ React2.createElement(Icon2, {
|
|
380
|
+
icon: "ph--square-split-vertical--regular",
|
|
381
|
+
size: 4
|
|
382
|
+
})), /* @__PURE__ */ React2.createElement(ToggleGroupItem, {
|
|
383
|
+
value: "preview",
|
|
384
|
+
classNames: "bg-transparent text-subdued"
|
|
335
385
|
}, /* @__PURE__ */ React2.createElement(Icon2, {
|
|
336
|
-
icon:
|
|
386
|
+
icon: "ph--eye--regular",
|
|
337
387
|
size: 4
|
|
338
|
-
})))
|
|
388
|
+
})));
|
|
389
|
+
};
|
|
390
|
+
|
|
391
|
+
// packages/plugins/experimental/plugin-script/src/components/TypescriptEditor/TypescriptEditor.tsx
|
|
392
|
+
import { javascript } from "@codemirror/lang-javascript";
|
|
393
|
+
import { tsSync, tsFacet, tsLinter, tsAutocomplete, tsHover } from "@valtown/codemirror-ts";
|
|
394
|
+
import React3 from "react";
|
|
395
|
+
import { useThemeContext } from "@dxos/react-ui";
|
|
396
|
+
import { autocomplete, createBasicExtensions, createThemeExtensions, editorFullWidth, editorGutter, editorMonospace, InputModeExtensions, useTextEditor } from "@dxos/react-ui-editor";
|
|
397
|
+
import { nonNullable } from "@dxos/util";
|
|
398
|
+
var TypescriptEditor = ({ id, env, className, initialValue, extensions, scrollTo, selection }) => {
|
|
399
|
+
const { themeMode } = useThemeContext();
|
|
400
|
+
const { parentRef, focusAttributes } = useTextEditor(() => ({
|
|
401
|
+
id,
|
|
402
|
+
initialValue,
|
|
403
|
+
extensions: [
|
|
404
|
+
extensions,
|
|
405
|
+
createBasicExtensions({
|
|
406
|
+
highlightActiveLine: true,
|
|
407
|
+
indentWithTab: true,
|
|
408
|
+
lineNumbers: true,
|
|
409
|
+
lineWrapping: false,
|
|
410
|
+
scrollPastEnd: true
|
|
411
|
+
}),
|
|
412
|
+
createThemeExtensions({
|
|
413
|
+
themeMode,
|
|
414
|
+
syntaxHighlighting: true,
|
|
415
|
+
slots: {
|
|
416
|
+
content: {
|
|
417
|
+
className: editorFullWidth
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
}),
|
|
421
|
+
editorGutter,
|
|
422
|
+
// TODO(burdon): Factor out.
|
|
423
|
+
[
|
|
424
|
+
editorMonospace,
|
|
425
|
+
javascript({
|
|
426
|
+
typescript: true
|
|
427
|
+
}),
|
|
428
|
+
// https://github.com/val-town/codemirror-ts
|
|
429
|
+
autocomplete({
|
|
430
|
+
override: env ? [
|
|
431
|
+
tsAutocomplete()
|
|
432
|
+
] : []
|
|
433
|
+
}),
|
|
434
|
+
env ? [
|
|
435
|
+
tsFacet.of({
|
|
436
|
+
env,
|
|
437
|
+
path: `/src/${id}.ts`
|
|
438
|
+
}),
|
|
439
|
+
tsSync(),
|
|
440
|
+
tsLinter(),
|
|
441
|
+
tsHover()
|
|
442
|
+
] : [],
|
|
443
|
+
InputModeExtensions.vscode
|
|
444
|
+
]
|
|
445
|
+
].filter(nonNullable),
|
|
446
|
+
selection,
|
|
447
|
+
scrollTo
|
|
448
|
+
}), [
|
|
449
|
+
id,
|
|
450
|
+
initialValue,
|
|
451
|
+
extensions,
|
|
452
|
+
themeMode,
|
|
453
|
+
selection,
|
|
454
|
+
scrollTo
|
|
455
|
+
]);
|
|
456
|
+
return /* @__PURE__ */ React3.createElement("div", {
|
|
457
|
+
ref: parentRef,
|
|
458
|
+
className,
|
|
459
|
+
...focusAttributes
|
|
460
|
+
});
|
|
339
461
|
};
|
|
340
462
|
|
|
341
463
|
// packages/plugins/experimental/plugin-script/src/components/ScriptEditor.tsx
|
|
342
464
|
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/plugins/experimental/plugin-script/src/components/ScriptEditor.tsx";
|
|
343
|
-
var ScriptEditor = ({
|
|
465
|
+
var ScriptEditor = ({ classNames, script, env }) => {
|
|
344
466
|
const { t } = useTranslation3(SCRIPT_PLUGIN);
|
|
345
|
-
const hasAttention = useHasAttention(fullyQualifiedId(script));
|
|
346
467
|
const client = useClient();
|
|
347
468
|
const identity = useIdentity();
|
|
348
469
|
const space = getSpace(script);
|
|
@@ -369,7 +490,7 @@ var ScriptEditor = ({ env, script, role }) => {
|
|
|
369
490
|
space,
|
|
370
491
|
identity
|
|
371
492
|
]);
|
|
372
|
-
const [
|
|
493
|
+
const [view, setView] = useState3("editor");
|
|
373
494
|
const initialValue = useMemo(() => script.source?.content, [
|
|
374
495
|
script.source
|
|
375
496
|
]);
|
|
@@ -397,7 +518,7 @@ var ScriptEditor = ({ env, script, role }) => {
|
|
|
397
518
|
} catch (err) {
|
|
398
519
|
log2.catch(err, void 0, {
|
|
399
520
|
F: __dxlog_file2,
|
|
400
|
-
L:
|
|
521
|
+
L: 94,
|
|
401
522
|
S: void 0,
|
|
402
523
|
C: (f, a) => f(...a)
|
|
403
524
|
});
|
|
@@ -405,6 +526,24 @@ var ScriptEditor = ({ env, script, role }) => {
|
|
|
405
526
|
}, [
|
|
406
527
|
script.source
|
|
407
528
|
]);
|
|
529
|
+
const handleTemplateChange = (id) => {
|
|
530
|
+
const template = templates.find((template2) => template2.id === id);
|
|
531
|
+
if (template) {
|
|
532
|
+
script.name = template.name;
|
|
533
|
+
script.source.content = template.source;
|
|
534
|
+
const metaKeys = getMeta(script).keys;
|
|
535
|
+
const oldPresetIndex = metaKeys.findIndex((key) => key.source === USERFUNCTIONS_PRESET_META_KEY);
|
|
536
|
+
if (oldPresetIndex >= 0) {
|
|
537
|
+
metaKeys.splice(oldPresetIndex, 1);
|
|
538
|
+
}
|
|
539
|
+
if (template.presetId) {
|
|
540
|
+
metaKeys.push({
|
|
541
|
+
source: USERFUNCTIONS_PRESET_META_KEY,
|
|
542
|
+
id: template.presetId
|
|
543
|
+
});
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
};
|
|
408
547
|
const handleDeploy = useCallback(async () => {
|
|
409
548
|
if (!script.source || !identity || !space) {
|
|
410
549
|
return;
|
|
@@ -437,7 +576,7 @@ var ScriptEditor = ({ env, script, role }) => {
|
|
|
437
576
|
functionVersionNumber
|
|
438
577
|
}, {
|
|
439
578
|
F: __dxlog_file2,
|
|
440
|
-
L:
|
|
579
|
+
L: 142,
|
|
441
580
|
S: void 0,
|
|
442
581
|
C: (f, a) => f(...a)
|
|
443
582
|
});
|
|
@@ -449,12 +588,13 @@ var ScriptEditor = ({ env, script, role }) => {
|
|
|
449
588
|
source: script
|
|
450
589
|
}));
|
|
451
590
|
const meta = getMeta(deployedFunction);
|
|
452
|
-
setUserFunctionUrlInMetadata(meta, `/${ownerDid}/${functionId}`);
|
|
453
591
|
script.changed = false;
|
|
592
|
+
setUserFunctionUrlInMetadata(meta, `/${ownerDid}/${functionId}`);
|
|
593
|
+
setView("split");
|
|
454
594
|
} catch (err) {
|
|
455
595
|
log2.catch(err, void 0, {
|
|
456
596
|
F: __dxlog_file2,
|
|
457
|
-
L:
|
|
597
|
+
L: 154,
|
|
458
598
|
S: void 0,
|
|
459
599
|
C: (f, a) => f(...a)
|
|
460
600
|
});
|
|
@@ -481,33 +621,45 @@ var ScriptEditor = ({ env, script, role }) => {
|
|
|
481
621
|
existingFunctionUrl,
|
|
482
622
|
space
|
|
483
623
|
]);
|
|
484
|
-
return /* @__PURE__ */
|
|
624
|
+
return /* @__PURE__ */ React4.createElement("div", {
|
|
485
625
|
role: "none",
|
|
486
|
-
className: mx2("flex flex-col
|
|
487
|
-
}, /* @__PURE__ */
|
|
488
|
-
id: script.id,
|
|
489
|
-
env,
|
|
490
|
-
initialValue,
|
|
491
|
-
extensions,
|
|
492
|
-
className: "flex is-full bs-full overflow-hidden ch-focus-ring-inset-over-all"
|
|
493
|
-
}), /* @__PURE__ */ React3.createElement(Toolbar2, {
|
|
494
|
-
classNames: "border-t border-separator",
|
|
626
|
+
className: mx2("flex flex-col w-full overflow-hidden divide-y divide-separator", classNames)
|
|
627
|
+
}, /* @__PURE__ */ React4.createElement(Toolbar2, {
|
|
495
628
|
deployed: Boolean(existingFunctionUrl) && !script.changed,
|
|
496
629
|
functionUrl,
|
|
497
630
|
error,
|
|
498
|
-
|
|
631
|
+
view,
|
|
632
|
+
templates,
|
|
499
633
|
onDeploy: handleDeploy,
|
|
500
634
|
onFormat: handleFormat,
|
|
501
|
-
|
|
502
|
-
|
|
635
|
+
onViewChange: setView,
|
|
636
|
+
onTemplateSelect: handleTemplateChange
|
|
637
|
+
}), view !== "preview" && /* @__PURE__ */ React4.createElement(TypescriptEditor, {
|
|
638
|
+
id: script.id,
|
|
639
|
+
env,
|
|
640
|
+
initialValue,
|
|
641
|
+
extensions,
|
|
642
|
+
className: "flex is-full bs-full overflow-hidden ch-focus-ring-inset-over-all"
|
|
643
|
+
}), view !== "editor" && /* @__PURE__ */ React4.createElement(DebugPanel, {
|
|
503
644
|
functionUrl,
|
|
504
645
|
binding: fn?.binding,
|
|
505
646
|
onBindingChange: handleBindingChange
|
|
506
647
|
}));
|
|
507
648
|
};
|
|
508
|
-
|
|
649
|
+
|
|
650
|
+
// packages/plugins/experimental/plugin-script/src/components/ScriptContainer.tsx
|
|
651
|
+
var ScriptContainer = ({ script, ...props }) => {
|
|
652
|
+
const hasAttention = useHasAttention(fullyQualifiedId(script));
|
|
653
|
+
return /* @__PURE__ */ React5.createElement("div", {
|
|
654
|
+
role: "none",
|
|
655
|
+
className: mx3("flex row-span-2 w-full overflow-hidden", hasAttention && "attention-surface")
|
|
656
|
+
}, /* @__PURE__ */ React5.createElement(ScriptEditor, {
|
|
657
|
+
...props,
|
|
658
|
+
script
|
|
659
|
+
}));
|
|
660
|
+
};
|
|
661
|
+
var ScriptContainer_default = ScriptContainer;
|
|
509
662
|
export {
|
|
510
|
-
|
|
511
|
-
ScriptEditor_default as default
|
|
663
|
+
ScriptContainer_default as default
|
|
512
664
|
};
|
|
513
|
-
//# sourceMappingURL=
|
|
665
|
+
//# sourceMappingURL=ScriptContainer-F6ACEA63.mjs.map
|