@dxos/plugin-script 0.6.13-main.ed424a1 → 0.6.13
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/README.md +1 -1
- package/dist/lib/browser/{ScriptContainer-M4MDQTBU.mjs → ScriptEditor-5Y3EROG3.mjs} +106 -258
- package/dist/lib/browser/ScriptEditor-5Y3EROG3.mjs.map +7 -0
- package/dist/lib/browser/TypescriptEditor-GPE72Y6I.mjs +9 -0
- package/dist/lib/browser/{chunk-G6FWCTGT.mjs → chunk-DL5XQRQM.mjs} +5 -7
- package/dist/lib/browser/chunk-DL5XQRQM.mjs.map +7 -0
- package/dist/lib/browser/chunk-JBACGDOJ.mjs +21 -0
- package/dist/lib/browser/chunk-JBACGDOJ.mjs.map +7 -0
- package/dist/lib/browser/chunk-MRGOT5RF.mjs +78 -0
- package/dist/lib/browser/chunk-MRGOT5RF.mjs.map +7 -0
- package/dist/lib/browser/{chunk-KXVQPS4Y.mjs → chunk-O4LWBX6A.mjs} +2 -2
- package/dist/lib/browser/{chunk-KXVQPS4Y.mjs.map → chunk-O4LWBX6A.mjs.map} +2 -2
- package/dist/lib/browser/{chunk-G6H56WFS.mjs → chunk-RHEZ5LUU.mjs} +2 -51
- package/dist/lib/browser/{chunk-G6H56WFS.mjs.map → chunk-RHEZ5LUU.mjs.map} +4 -4
- package/dist/lib/browser/edge/index.mjs +1 -3
- package/dist/lib/browser/index.mjs +62 -80
- 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/ScriptEditor-YCUQFWQM.cjs +526 -0
- package/dist/lib/node/ScriptEditor-YCUQFWQM.cjs.map +7 -0
- package/dist/lib/node/{chunk-EJC55SDD.cjs → TypescriptEditor-M3WWFIP2.cjs} +8 -18
- package/dist/lib/node/TypescriptEditor-M3WWFIP2.cjs.map +7 -0
- package/dist/lib/node/{chunk-ACLCRWDB.cjs → chunk-4GTXIELQ.cjs} +6 -44
- package/dist/lib/node/chunk-4GTXIELQ.cjs.map +7 -0
- package/dist/lib/node/chunk-4VMNBXWU.cjs +54 -0
- package/dist/lib/node/chunk-4VMNBXWU.cjs.map +7 -0
- package/dist/lib/node/{chunk-25PQE7FL.cjs → chunk-5RBVXKXT.cjs} +6 -6
- package/dist/lib/node/{chunk-25PQE7FL.cjs.map → chunk-5RBVXKXT.cjs.map} +2 -2
- package/dist/lib/node/chunk-IMLDKD5Y.cjs +111 -0
- package/dist/lib/node/chunk-IMLDKD5Y.cjs.map +7 -0
- package/dist/lib/node/{chunk-UZ3ZXEBF.cjs → chunk-PFH3ROEH.cjs} +8 -11
- package/dist/lib/node/chunk-PFH3ROEH.cjs.map +7 -0
- package/dist/lib/node/edge/index.cjs +8 -10
- package/dist/lib/node/edge/index.cjs.map +2 -2
- package/dist/lib/node/index.cjs +82 -95
- 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/types/src/ScriptPlugin.d.ts.map +1 -1
- package/dist/types/src/components/DebugPanel.d.ts.map +1 -0
- package/dist/types/src/components/{FrameContainer → ScriptBlock/FrameContainer}/FrameContainer.d.ts +1 -1
- package/dist/types/src/components/ScriptBlock/FrameContainer/FrameContainer.d.ts.map +1 -0
- package/dist/types/src/components/ScriptBlock/FrameContainer/frame.d.ts.map +1 -0
- package/dist/types/src/components/ScriptBlock/FrameContainer/index.d.ts.map +1 -0
- package/dist/types/src/components/ScriptBlock/ScriptBlock.d.ts +3 -1
- 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/ScriptBlock/Splitter/Splitter.d.ts +15 -0
- package/dist/types/src/components/ScriptBlock/Splitter/Splitter.d.ts.map +1 -0
- package/dist/types/src/components/ScriptBlock/Splitter/Splitter.stories.d.ts +13 -0
- package/dist/types/src/components/ScriptBlock/Splitter/Splitter.stories.d.ts.map +1 -0
- package/dist/types/src/components/ScriptBlock/Splitter/index.d.ts +2 -0
- package/dist/types/src/components/ScriptBlock/Splitter/index.d.ts.map +1 -0
- package/dist/types/src/components/ScriptEditor.d.ts +5 -4
- package/dist/types/src/components/ScriptEditor.d.ts.map +1 -1
- package/dist/types/src/components/Toolbar.d.ts +13 -0
- package/dist/types/src/components/Toolbar.d.ts.map +1 -0
- package/dist/types/src/components/Toolbar.stories.d.ts +14 -0
- package/dist/types/src/components/Toolbar.stories.d.ts.map +1 -0
- package/dist/types/src/components/{TypescriptEditor/TypescriptEditor.d.ts → TypescriptEditor.d.ts} +2 -1
- package/dist/types/src/components/TypescriptEditor.d.ts.map +1 -0
- package/dist/types/src/components/TypescriptEditor.stories.d.ts +10 -0
- package/dist/types/src/components/TypescriptEditor.stories.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 +0 -1
- package/dist/types/src/edge/functions.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +9 -4
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +0 -2
- 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 +3 -4
- package/dist/types/src/types/types.d.ts.map +1 -1
- package/package.json +55 -61
- package/src/ScriptPlugin.tsx +38 -22
- package/src/bundler/bundler.test.ts +2 -12
- package/src/components/{DebugPanel/DebugPanel.tsx → DebugPanel.tsx} +41 -48
- package/src/components/{FrameContainer → ScriptBlock/FrameContainer}/FrameContainer.tsx +1 -1
- package/src/components/ScriptBlock/ScriptBlock.stories.tsx +8 -6
- package/src/components/ScriptBlock/ScriptBlock.tsx +36 -10
- package/src/components/ScriptBlock/Splitter/Splitter.stories.tsx +37 -0
- package/src/components/ScriptBlock/Splitter/Splitter.tsx +52 -0
- package/src/components/{Toolbar → ScriptBlock/Splitter}/index.ts +1 -1
- package/src/components/ScriptEditor.tsx +46 -47
- package/src/components/{Toolbar/Toolbar.stories.tsx → Toolbar.stories.tsx} +1 -10
- package/src/components/Toolbar.tsx +147 -0
- package/src/components/{TypescriptEditor/TypescriptEditor.stories.tsx → TypescriptEditor.stories.tsx} +29 -8
- package/src/components/{TypescriptEditor/TypescriptEditor.tsx → TypescriptEditor.tsx} +3 -1
- package/src/components/index.ts +2 -3
- package/src/edge/functions.ts +0 -1
- package/src/meta.tsx +19 -0
- package/src/translations.ts +0 -2
- package/src/types/types.ts +5 -9
- package/dist/lib/browser/ScriptContainer-M4MDQTBU.mjs.map +0 -7
- package/dist/lib/browser/chunk-G6FWCTGT.mjs.map +0 -7
- package/dist/lib/browser/chunk-SGQHRB4P.mjs +0 -17
- package/dist/lib/browser/chunk-SGQHRB4P.mjs.map +0 -7
- package/dist/lib/node/ScriptContainer-KMIPKT3H.cjs +0 -668
- package/dist/lib/node/ScriptContainer-KMIPKT3H.cjs.map +0 -7
- package/dist/lib/node/chunk-ACLCRWDB.cjs.map +0 -7
- package/dist/lib/node/chunk-EJC55SDD.cjs.map +0 -7
- package/dist/lib/node/chunk-UZ3ZXEBF.cjs.map +0 -7
- package/dist/lib/node-esm/ScriptContainer-EAE6L5JV.mjs +0 -666
- package/dist/lib/node-esm/ScriptContainer-EAE6L5JV.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-2NX3HWPM.mjs +0 -245
- package/dist/lib/node-esm/chunk-2NX3HWPM.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-7EDYDVQH.mjs +0 -47
- package/dist/lib/node-esm/chunk-7EDYDVQH.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-GO7HYFM5.mjs +0 -19
- package/dist/lib/node-esm/chunk-GO7HYFM5.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-LDLNTVAK.mjs +0 -280
- package/dist/lib/node-esm/chunk-LDLNTVAK.mjs.map +0 -7
- package/dist/lib/node-esm/edge/index.mjs +0 -22
- package/dist/lib/node-esm/index.mjs +0 -310
- package/dist/lib/node-esm/index.mjs.map +0 -7
- package/dist/lib/node-esm/meta.json +0 -1
- package/dist/lib/node-esm/meta.mjs +0 -10
- package/dist/lib/node-esm/meta.mjs.map +0 -7
- package/dist/lib/node-esm/types/index.mjs +0 -13
- package/dist/lib/node-esm/types/index.mjs.map +0 -7
- package/dist/types/src/components/DebugPanel/DebugPanel.d.ts.map +0 -1
- package/dist/types/src/components/DebugPanel/index.d.ts +0 -2
- package/dist/types/src/components/DebugPanel/index.d.ts.map +0 -1
- package/dist/types/src/components/FrameContainer/FrameContainer.d.ts.map +0 -1
- package/dist/types/src/components/FrameContainer/frame.d.ts.map +0 -1
- package/dist/types/src/components/FrameContainer/index.d.ts.map +0 -1
- package/dist/types/src/components/ScriptContainer.d.ts +0 -5
- package/dist/types/src/components/ScriptContainer.d.ts.map +0 -1
- package/dist/types/src/components/ScriptSettings/ScriptSettings.d.ts +0 -6
- package/dist/types/src/components/ScriptSettings/ScriptSettings.d.ts.map +0 -1
- package/dist/types/src/components/ScriptSettings/index.d.ts +0 -2
- package/dist/types/src/components/ScriptSettings/index.d.ts.map +0 -1
- package/dist/types/src/components/Toolbar/Toolbar.d.ts +0 -23
- package/dist/types/src/components/Toolbar/Toolbar.d.ts.map +0 -1
- package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts +0 -17
- package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts.map +0 -1
- package/dist/types/src/components/Toolbar/index.d.ts +0 -2
- package/dist/types/src/components/Toolbar/index.d.ts.map +0 -1
- package/dist/types/src/components/TypescriptEditor/TypescriptEditor.d.ts.map +0 -1
- package/dist/types/src/components/TypescriptEditor/TypescriptEditor.stories.d.ts +0 -10
- package/dist/types/src/components/TypescriptEditor/TypescriptEditor.stories.d.ts.map +0 -1
- package/dist/types/src/components/TypescriptEditor/index.d.ts +0 -2
- package/dist/types/src/components/TypescriptEditor/index.d.ts.map +0 -1
- package/dist/types/src/templates/chat.d.ts +0 -6
- package/dist/types/src/templates/chat.d.ts.map +0 -1
- package/dist/types/src/templates/chess.d.ts +0 -6
- package/dist/types/src/templates/chess.d.ts.map +0 -1
- package/dist/types/src/templates/echo.d.ts +0 -6
- package/dist/types/src/templates/echo.d.ts.map +0 -1
- package/dist/types/src/templates/email.d.ts +0 -6
- package/dist/types/src/templates/email.d.ts.map +0 -1
- package/dist/types/src/templates/forex.d.ts +0 -6
- package/dist/types/src/templates/forex.d.ts.map +0 -1
- package/dist/types/src/templates.d.ts +0 -8
- package/dist/types/src/templates.d.ts.map +0 -1
- package/src/components/DebugPanel/index.ts +0 -5
- package/src/components/ScriptContainer.tsx +0 -22
- package/src/components/ScriptSettings/ScriptSettings.tsx +0 -47
- package/src/components/ScriptSettings/index.ts +0 -5
- package/src/components/Toolbar/Toolbar.tsx +0 -180
- package/src/components/TypescriptEditor/index.ts +0 -5
- package/src/meta.ts +0 -15
- package/src/templates/chat.ts +0 -102
- package/src/templates/chess.ts +0 -41
- package/src/templates/echo.ts +0 -15
- package/src/templates/email.ts +0 -38
- package/src/templates/forex.ts +0 -21
- package/src/templates.ts +0 -54
- /package/dist/lib/{node-esm/edge/index.mjs.map → browser/TypescriptEditor-GPE72Y6I.mjs.map} +0 -0
- /package/dist/types/src/components/{DebugPanel/DebugPanel.d.ts → DebugPanel.d.ts} +0 -0
- /package/dist/types/src/components/{FrameContainer → ScriptBlock/FrameContainer}/frame.d.ts +0 -0
- /package/dist/types/src/components/{FrameContainer → ScriptBlock/FrameContainer}/index.d.ts +0 -0
- /package/src/components/{FrameContainer → ScriptBlock/FrameContainer}/frame.html +0 -0
- /package/src/components/{FrameContainer → ScriptBlock/FrameContainer}/frame.tsx +0 -0
- /package/src/components/{FrameContainer → ScriptBlock/FrameContainer}/index.ts +0 -0
|
@@ -1,666 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
|
-
import {
|
|
3
|
-
USERFUNCTIONS_PRESET_META_KEY,
|
|
4
|
-
getUserFunctionUrlInMetadata,
|
|
5
|
-
publicKeyToDid,
|
|
6
|
-
setUserFunctionUrlInMetadata,
|
|
7
|
-
uploadWorkerFunction
|
|
8
|
-
} from "./chunk-2NX3HWPM.mjs";
|
|
9
|
-
import {
|
|
10
|
-
Bundler,
|
|
11
|
-
templates
|
|
12
|
-
} from "./chunk-LDLNTVAK.mjs";
|
|
13
|
-
import {
|
|
14
|
-
FunctionType
|
|
15
|
-
} from "./chunk-7EDYDVQH.mjs";
|
|
16
|
-
import {
|
|
17
|
-
SCRIPT_PLUGIN
|
|
18
|
-
} from "./chunk-GO7HYFM5.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 { useAttendableAttributes } from "@dxos/react-ui-attention";
|
|
24
|
-
import { mx as mx3 } from "@dxos/react-ui-theme";
|
|
25
|
-
|
|
26
|
-
// packages/plugins/experimental/plugin-script/src/components/ScriptEditor.tsx
|
|
27
|
-
import { format } from "prettier";
|
|
28
|
-
import prettierPluginEstree from "prettier/plugins/estree";
|
|
29
|
-
import prettierPluginTypescript from "prettier/plugins/typescript";
|
|
30
|
-
import React4, { useCallback, useMemo, useState as useState3 } from "react";
|
|
31
|
-
import { log as log2 } from "@dxos/log";
|
|
32
|
-
import { useClient } from "@dxos/react-client";
|
|
33
|
-
import { create, createDocAccessor, Filter, getMeta, getSpace, useQuery } from "@dxos/react-client/echo";
|
|
34
|
-
import { useIdentity } from "@dxos/react-client/halo";
|
|
35
|
-
import { useTranslation as useTranslation3 } from "@dxos/react-ui";
|
|
36
|
-
import { createDataExtensions, listener } from "@dxos/react-ui-editor";
|
|
37
|
-
import { mx as mx2 } from "@dxos/react-ui-theme";
|
|
38
|
-
|
|
39
|
-
// packages/plugins/experimental/plugin-script/src/components/DebugPanel/DebugPanel.tsx
|
|
40
|
-
import React, { useEffect, useRef, useState } from "react";
|
|
41
|
-
import { log } from "@dxos/log";
|
|
42
|
-
import { Avatar, DensityProvider, Icon, Input, Toolbar, useControlledValue, useTranslation } from "@dxos/react-ui";
|
|
43
|
-
import { SyntaxHighlighter } from "@dxos/react-ui-syntax-highlighter";
|
|
44
|
-
import { mx } from "@dxos/react-ui-theme";
|
|
45
|
-
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/experimental/plugin-script/src/components/DebugPanel/DebugPanel.tsx";
|
|
46
|
-
var DebugPanel = ({ classNames, functionUrl, binding: _binding, onBindingChange }) => {
|
|
47
|
-
const { t } = useTranslation(SCRIPT_PLUGIN);
|
|
48
|
-
const bindingInputRef = useRef(null);
|
|
49
|
-
const [binding, setBinding] = useControlledValue(_binding ?? "");
|
|
50
|
-
const handleBlur = () => {
|
|
51
|
-
onBindingChange?.(binding);
|
|
52
|
-
};
|
|
53
|
-
const inputRef = useRef(null);
|
|
54
|
-
const [input, setInput] = useState("");
|
|
55
|
-
const [result, setResult] = useState("");
|
|
56
|
-
const [state, setState] = useState(null);
|
|
57
|
-
const [history, setHistory] = useState([]);
|
|
58
|
-
const scrollerRef = useRef(null);
|
|
59
|
-
const handleScroll = () => {
|
|
60
|
-
if (scrollerRef.current) {
|
|
61
|
-
scrollerRef.current.scrollTop = scrollerRef.current.scrollHeight;
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
const controller = useRef();
|
|
65
|
-
useEffect(() => {
|
|
66
|
-
return () => {
|
|
67
|
-
handleStop();
|
|
68
|
-
};
|
|
69
|
-
}, []);
|
|
70
|
-
const handleStop = () => {
|
|
71
|
-
controller.current?.abort("stop");
|
|
72
|
-
controller.current = void 0;
|
|
73
|
-
};
|
|
74
|
-
const handleClear = () => {
|
|
75
|
-
handleStop();
|
|
76
|
-
setInput("");
|
|
77
|
-
setResult("");
|
|
78
|
-
setHistory([]);
|
|
79
|
-
inputRef.current?.focus();
|
|
80
|
-
};
|
|
81
|
-
const handleResponse = ({ text, data, error } = {}) => {
|
|
82
|
-
controller.current = void 0;
|
|
83
|
-
setHistory((history2) => [
|
|
84
|
-
...history2,
|
|
85
|
-
{
|
|
86
|
-
type: "response",
|
|
87
|
-
text,
|
|
88
|
-
data,
|
|
89
|
-
error
|
|
90
|
-
}
|
|
91
|
-
]);
|
|
92
|
-
setResult("");
|
|
93
|
-
setState(null);
|
|
94
|
-
handleScroll();
|
|
95
|
-
};
|
|
96
|
-
const handleRequest = async (input2) => {
|
|
97
|
-
try {
|
|
98
|
-
setState("pending");
|
|
99
|
-
let data = null;
|
|
100
|
-
if (input2.charAt(0) === "{") {
|
|
101
|
-
try {
|
|
102
|
-
const validJsonString = input2.replace(/'/g, '"').replace(/([{,]\s*)([a-zA-Z0-9_]+)(\s*:)/g, '$1"$2"$3');
|
|
103
|
-
data = JSON.parse(validJsonString);
|
|
104
|
-
input2 = JSON.stringify(data, null, 2);
|
|
105
|
-
} catch (err) {
|
|
106
|
-
inputRef.current?.focus();
|
|
107
|
-
return;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
setInput("");
|
|
111
|
-
setResult("");
|
|
112
|
-
setHistory((history2) => [
|
|
113
|
-
...history2,
|
|
114
|
-
{
|
|
115
|
-
type: "request",
|
|
116
|
-
text: input2
|
|
117
|
-
}
|
|
118
|
-
]);
|
|
119
|
-
setTimeout(() => {
|
|
120
|
-
handleScroll();
|
|
121
|
-
});
|
|
122
|
-
controller.current = new AbortController();
|
|
123
|
-
const response = await fetch(functionUrl, {
|
|
124
|
-
signal: controller.current.signal,
|
|
125
|
-
method: "POST",
|
|
126
|
-
body: input2,
|
|
127
|
-
headers: {
|
|
128
|
-
"Content-Type": data ? "application/json" : "text/plain"
|
|
129
|
-
}
|
|
130
|
-
});
|
|
131
|
-
if (!response.ok) {
|
|
132
|
-
const text2 = await response.text();
|
|
133
|
-
handleResponse({
|
|
134
|
-
error: new Error(text2 || response.statusText || String(response.status))
|
|
135
|
-
});
|
|
136
|
-
return;
|
|
137
|
-
}
|
|
138
|
-
const contentType = response.headers.get("content-type");
|
|
139
|
-
if (contentType === "application/json") {
|
|
140
|
-
const data2 = await response.json();
|
|
141
|
-
handleResponse({
|
|
142
|
-
data: data2
|
|
143
|
-
});
|
|
144
|
-
return;
|
|
145
|
-
}
|
|
146
|
-
setState("responding");
|
|
147
|
-
let text = "";
|
|
148
|
-
const reader = response.body.getReader();
|
|
149
|
-
const pump = async ({ done, value }) => {
|
|
150
|
-
text = text + new TextDecoder().decode(value);
|
|
151
|
-
if (!controller.current || done) {
|
|
152
|
-
handleResponse({
|
|
153
|
-
text
|
|
154
|
-
});
|
|
155
|
-
return;
|
|
156
|
-
}
|
|
157
|
-
setResult(text);
|
|
158
|
-
setTimeout(() => {
|
|
159
|
-
handleScroll();
|
|
160
|
-
});
|
|
161
|
-
return reader.read().then(pump);
|
|
162
|
-
};
|
|
163
|
-
void reader.read().then(pump).catch((err) => {
|
|
164
|
-
if (err.name !== "AbortError") {
|
|
165
|
-
log.catch(err, void 0, {
|
|
166
|
-
F: __dxlog_file,
|
|
167
|
-
L: 163,
|
|
168
|
-
S: void 0,
|
|
169
|
-
C: (f, a) => f(...a)
|
|
170
|
-
});
|
|
171
|
-
}
|
|
172
|
-
});
|
|
173
|
-
} catch (err) {
|
|
174
|
-
if (err !== "stop") {
|
|
175
|
-
const error = err instanceof Error ? err : new Error(err);
|
|
176
|
-
handleResponse({
|
|
177
|
-
error
|
|
178
|
-
});
|
|
179
|
-
log.catch(err, void 0, {
|
|
180
|
-
F: __dxlog_file,
|
|
181
|
-
L: 170,
|
|
182
|
-
S: void 0,
|
|
183
|
-
C: (f, a) => f(...a)
|
|
184
|
-
});
|
|
185
|
-
} else {
|
|
186
|
-
handleResponse();
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
};
|
|
190
|
-
return /* @__PURE__ */ React.createElement(DensityProvider, {
|
|
191
|
-
density: "fine"
|
|
192
|
-
}, /* @__PURE__ */ React.createElement("div", {
|
|
193
|
-
className: mx("flex flex-col h-full overflow-hidden", classNames)
|
|
194
|
-
}, /* @__PURE__ */ React.createElement("div", {
|
|
195
|
-
ref: scrollerRef,
|
|
196
|
-
className: "flex flex-col gap-6 h-full p-4 overflow-x-hidden overflow-y-auto"
|
|
197
|
-
}, /* @__PURE__ */ React.createElement(MessageThread, {
|
|
198
|
-
state,
|
|
199
|
-
result,
|
|
200
|
-
history
|
|
201
|
-
})), /* @__PURE__ */ React.createElement(Toolbar.Root, {
|
|
202
|
-
classNames: "p-2"
|
|
203
|
-
}, /* @__PURE__ */ React.createElement(Input.Root, null, /* @__PURE__ */ React.createElement(Input.TextInput, {
|
|
204
|
-
ref: inputRef,
|
|
205
|
-
autoFocus: true,
|
|
206
|
-
placeholder: t("function request placeholder"),
|
|
207
|
-
value: input,
|
|
208
|
-
onChange: (ev) => setInput(ev.target.value),
|
|
209
|
-
onKeyDown: (ev) => ev.key === "Enter" && handleRequest(input)
|
|
210
|
-
})), /* @__PURE__ */ React.createElement(Input.Root, null, /* @__PURE__ */ React.createElement(Input.TextInput, {
|
|
211
|
-
ref: bindingInputRef,
|
|
212
|
-
classNames: "!w-[10rem]",
|
|
213
|
-
placeholder: t("binding placeholder"),
|
|
214
|
-
value: binding,
|
|
215
|
-
onChange: (ev) => setBinding(ev.target.value.toUpperCase()),
|
|
216
|
-
onBlur: handleBlur
|
|
217
|
-
})), /* @__PURE__ */ React.createElement(Toolbar.Button, {
|
|
218
|
-
onClick: () => handleRequest(input)
|
|
219
|
-
}, /* @__PURE__ */ React.createElement(Icon, {
|
|
220
|
-
icon: "ph--play--regular",
|
|
221
|
-
size: 4
|
|
222
|
-
})), /* @__PURE__ */ React.createElement(Toolbar.Button, {
|
|
223
|
-
onClick: () => state ? handleStop() : handleClear()
|
|
224
|
-
}, /* @__PURE__ */ React.createElement(Icon, {
|
|
225
|
-
icon: state ? "ph--stop--regular" : "ph--trash--regular",
|
|
226
|
-
size: 4
|
|
227
|
-
})))));
|
|
228
|
-
};
|
|
229
|
-
var MessageThread = ({ state, result, history }) => {
|
|
230
|
-
return /* @__PURE__ */ React.createElement(React.Fragment, null, history.map((message, i) => /* @__PURE__ */ React.createElement("div", {
|
|
231
|
-
key: i,
|
|
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"
|
|
237
|
-
}, /* @__PURE__ */ React.createElement(MessageItem, {
|
|
238
|
-
message
|
|
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, {
|
|
244
|
-
icon: "ph--spinner--regular",
|
|
245
|
-
size: 6,
|
|
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
|
-
}))));
|
|
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
|
-
})));
|
|
280
|
-
|
|
281
|
-
// packages/plugins/experimental/plugin-script/src/components/Toolbar/Toolbar.tsx
|
|
282
|
-
import React2, { useState as useState2 } from "react";
|
|
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 }) => {
|
|
285
|
-
const { t } = useTranslation2(SCRIPT_PLUGIN);
|
|
286
|
-
const [pending, setPending] = useState2(false);
|
|
287
|
-
const handleCopyLink = async () => {
|
|
288
|
-
if (!functionUrl) {
|
|
289
|
-
return;
|
|
290
|
-
}
|
|
291
|
-
await navigator.clipboard.writeText(functionUrl);
|
|
292
|
-
};
|
|
293
|
-
const handleDeploy = async () => {
|
|
294
|
-
if (!pending) {
|
|
295
|
-
setPending(true);
|
|
296
|
-
await onDeploy?.();
|
|
297
|
-
setPending(false);
|
|
298
|
-
}
|
|
299
|
-
};
|
|
300
|
-
return /* @__PURE__ */ React2.createElement(DensityProvider2, {
|
|
301
|
-
density: "fine"
|
|
302
|
-
}, /* @__PURE__ */ React2.createElement(ElevationProvider, {
|
|
303
|
-
elevation: "chrome"
|
|
304
|
-
}, /* @__PURE__ */ React2.createElement(NaturalToolbar.Root, {
|
|
305
|
-
classNames: [
|
|
306
|
-
"p-1",
|
|
307
|
-
classNames
|
|
308
|
-
],
|
|
309
|
-
style: {
|
|
310
|
-
contain: "layout"
|
|
311
|
-
}
|
|
312
|
-
}, templates2 && /* @__PURE__ */ React2.createElement(TemplateSelect, {
|
|
313
|
-
templates: templates2,
|
|
314
|
-
onTemplateSelect
|
|
315
|
-
}), onFormat && /* @__PURE__ */ React2.createElement(ToolbarIconButton, {
|
|
316
|
-
icon: "ph--magic-wand--regular",
|
|
317
|
-
text: t("format label"),
|
|
318
|
-
onClick: onFormat
|
|
319
|
-
}), /* @__PURE__ */ React2.createElement("div", {
|
|
320
|
-
role: "separator",
|
|
321
|
-
className: "grow"
|
|
322
|
-
}), error ? /* @__PURE__ */ React2.createElement(Tooltip.Root, null, /* @__PURE__ */ React2.createElement(Tooltip.Trigger, null, /* @__PURE__ */ React2.createElement(Icon2, {
|
|
323
|
-
icon: "ph--warning-circle--regular",
|
|
324
|
-
size: 4
|
|
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, {
|
|
326
|
-
icon: "ph--link--regular",
|
|
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, {
|
|
343
|
-
asChild: true
|
|
344
|
-
}, /* @__PURE__ */ React2.createElement(NaturalToolbar.Button, {
|
|
345
|
-
variant: "ghost",
|
|
346
|
-
disabled,
|
|
347
|
-
onClick
|
|
348
|
-
}, /* @__PURE__ */ React2.createElement(Icon2, {
|
|
349
|
-
icon,
|
|
350
|
-
size: 4,
|
|
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",
|
|
375
|
-
size: 4
|
|
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"
|
|
385
|
-
}, /* @__PURE__ */ React2.createElement(Icon2, {
|
|
386
|
-
icon: "ph--eye--regular",
|
|
387
|
-
size: 4
|
|
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
|
-
});
|
|
461
|
-
};
|
|
462
|
-
|
|
463
|
-
// packages/plugins/experimental/plugin-script/src/components/ScriptEditor.tsx
|
|
464
|
-
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/plugins/experimental/plugin-script/src/components/ScriptEditor.tsx";
|
|
465
|
-
var ScriptEditor = ({ classNames, script, env }) => {
|
|
466
|
-
const { t } = useTranslation3(SCRIPT_PLUGIN);
|
|
467
|
-
const client = useClient();
|
|
468
|
-
const identity = useIdentity();
|
|
469
|
-
const space = getSpace(script);
|
|
470
|
-
const [fn] = useQuery(space, Filter.schema(FunctionType, (fn2) => fn2.source === script));
|
|
471
|
-
const extensions = useMemo(() => [
|
|
472
|
-
listener({
|
|
473
|
-
onChange: (text) => {
|
|
474
|
-
if (script.source && script.source?.content !== text) {
|
|
475
|
-
script.changed = true;
|
|
476
|
-
}
|
|
477
|
-
}
|
|
478
|
-
}),
|
|
479
|
-
createDataExtensions({
|
|
480
|
-
id: script.id,
|
|
481
|
-
text: script.source && createDocAccessor(script.source, [
|
|
482
|
-
"content"
|
|
483
|
-
]),
|
|
484
|
-
space,
|
|
485
|
-
identity
|
|
486
|
-
})
|
|
487
|
-
], [
|
|
488
|
-
script,
|
|
489
|
-
script.source,
|
|
490
|
-
space,
|
|
491
|
-
identity
|
|
492
|
-
]);
|
|
493
|
-
const [view, setView] = useState3("editor");
|
|
494
|
-
const initialValue = useMemo(() => script.source?.content, [
|
|
495
|
-
script.source
|
|
496
|
-
]);
|
|
497
|
-
const existingFunctionUrl = fn && getUserFunctionUrlInMetadata(getMeta(fn));
|
|
498
|
-
const [error, setError] = useState3();
|
|
499
|
-
const handleBindingChange = useCallback((binding) => {
|
|
500
|
-
fn.binding = binding;
|
|
501
|
-
}, [
|
|
502
|
-
fn
|
|
503
|
-
]);
|
|
504
|
-
const handleFormat = useCallback(async () => {
|
|
505
|
-
if (!script.source) {
|
|
506
|
-
return;
|
|
507
|
-
}
|
|
508
|
-
try {
|
|
509
|
-
script.source.content = await format(script.source.content, {
|
|
510
|
-
parser: "typescript",
|
|
511
|
-
plugins: [
|
|
512
|
-
prettierPluginEstree,
|
|
513
|
-
prettierPluginTypescript
|
|
514
|
-
],
|
|
515
|
-
semi: true,
|
|
516
|
-
singleQuote: true
|
|
517
|
-
});
|
|
518
|
-
} catch (err) {
|
|
519
|
-
log2.catch(err, void 0, {
|
|
520
|
-
F: __dxlog_file2,
|
|
521
|
-
L: 94,
|
|
522
|
-
S: void 0,
|
|
523
|
-
C: (f, a) => f(...a)
|
|
524
|
-
});
|
|
525
|
-
}
|
|
526
|
-
}, [
|
|
527
|
-
script.source
|
|
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
|
-
};
|
|
547
|
-
const handleDeploy = useCallback(async () => {
|
|
548
|
-
if (!script.source || !identity || !space) {
|
|
549
|
-
return;
|
|
550
|
-
}
|
|
551
|
-
setError(void 0);
|
|
552
|
-
try {
|
|
553
|
-
const existingFunctionId = existingFunctionUrl?.split("/").at(-1);
|
|
554
|
-
const ownerDid = existingFunctionUrl?.split("/").at(-2) ?? publicKeyToDid(identity.identityKey);
|
|
555
|
-
const bundler = new Bundler({
|
|
556
|
-
platform: "browser",
|
|
557
|
-
sandboxedModules: [],
|
|
558
|
-
remoteModules: {}
|
|
559
|
-
});
|
|
560
|
-
const buildResult = await bundler.bundle(script.source.content);
|
|
561
|
-
if (buildResult.error || !buildResult.bundle) {
|
|
562
|
-
throw buildResult.error;
|
|
563
|
-
}
|
|
564
|
-
const { result, functionId, functionVersionNumber, errorMessage } = await uploadWorkerFunction({
|
|
565
|
-
clientConfig: client.config,
|
|
566
|
-
halo: client.halo,
|
|
567
|
-
ownerDid,
|
|
568
|
-
functionId: existingFunctionId,
|
|
569
|
-
source: buildResult.bundle
|
|
570
|
-
});
|
|
571
|
-
if (result !== "success" || functionId === void 0 || functionVersionNumber === void 0) {
|
|
572
|
-
throw new Error(errorMessage);
|
|
573
|
-
}
|
|
574
|
-
log2.info("function uploaded", {
|
|
575
|
-
functionId,
|
|
576
|
-
functionVersionNumber
|
|
577
|
-
}, {
|
|
578
|
-
F: __dxlog_file2,
|
|
579
|
-
L: 142,
|
|
580
|
-
S: void 0,
|
|
581
|
-
C: (f, a) => f(...a)
|
|
582
|
-
});
|
|
583
|
-
if (fn) {
|
|
584
|
-
fn.version = functionVersionNumber;
|
|
585
|
-
}
|
|
586
|
-
const deployedFunction = fn ?? space.db.add(create(FunctionType, {
|
|
587
|
-
version: functionVersionNumber,
|
|
588
|
-
source: script
|
|
589
|
-
}));
|
|
590
|
-
const meta = getMeta(deployedFunction);
|
|
591
|
-
script.changed = false;
|
|
592
|
-
setUserFunctionUrlInMetadata(meta, `/${ownerDid}/${functionId}`);
|
|
593
|
-
setView("split");
|
|
594
|
-
} catch (err) {
|
|
595
|
-
log2.catch(err, void 0, {
|
|
596
|
-
F: __dxlog_file2,
|
|
597
|
-
L: 154,
|
|
598
|
-
S: void 0,
|
|
599
|
-
C: (f, a) => f(...a)
|
|
600
|
-
});
|
|
601
|
-
setError(t("upload failed label"));
|
|
602
|
-
}
|
|
603
|
-
}, [
|
|
604
|
-
fn,
|
|
605
|
-
existingFunctionUrl,
|
|
606
|
-
script,
|
|
607
|
-
script.name,
|
|
608
|
-
script.source
|
|
609
|
-
]);
|
|
610
|
-
const functionUrl = useMemo(() => {
|
|
611
|
-
if (!existingFunctionUrl) {
|
|
612
|
-
return;
|
|
613
|
-
}
|
|
614
|
-
const baseUrl = new URL("functions/", client.config.values.runtime?.services?.edge?.url);
|
|
615
|
-
const relativeUrl = existingFunctionUrl.replace(/^\//, "");
|
|
616
|
-
const url = new URL(`./${relativeUrl}`, baseUrl.toString());
|
|
617
|
-
space && url.searchParams.set("spaceId", space.id);
|
|
618
|
-
url.protocol = "https";
|
|
619
|
-
return url.toString();
|
|
620
|
-
}, [
|
|
621
|
-
existingFunctionUrl,
|
|
622
|
-
space
|
|
623
|
-
]);
|
|
624
|
-
return /* @__PURE__ */ React4.createElement("div", {
|
|
625
|
-
role: "none",
|
|
626
|
-
className: mx2("flex flex-col w-full overflow-hidden divide-y divide-separator", classNames)
|
|
627
|
-
}, /* @__PURE__ */ React4.createElement(Toolbar2, {
|
|
628
|
-
deployed: Boolean(existingFunctionUrl) && !script.changed,
|
|
629
|
-
functionUrl,
|
|
630
|
-
error,
|
|
631
|
-
view,
|
|
632
|
-
templates,
|
|
633
|
-
onDeploy: handleDeploy,
|
|
634
|
-
onFormat: handleFormat,
|
|
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, {
|
|
644
|
-
functionUrl,
|
|
645
|
-
binding: fn?.binding,
|
|
646
|
-
onBindingChange: handleBindingChange
|
|
647
|
-
}));
|
|
648
|
-
};
|
|
649
|
-
|
|
650
|
-
// packages/plugins/experimental/plugin-script/src/components/ScriptContainer.tsx
|
|
651
|
-
var ScriptContainer = ({ script, ...props }) => {
|
|
652
|
-
const attendableAttrs = useAttendableAttributes(fullyQualifiedId(script));
|
|
653
|
-
return /* @__PURE__ */ React5.createElement("div", {
|
|
654
|
-
role: "none",
|
|
655
|
-
className: mx3("flex row-span-2 w-full overflow-hidden attention-surface"),
|
|
656
|
-
...attendableAttrs
|
|
657
|
-
}, /* @__PURE__ */ React5.createElement(ScriptEditor, {
|
|
658
|
-
...props,
|
|
659
|
-
script
|
|
660
|
-
}));
|
|
661
|
-
};
|
|
662
|
-
var ScriptContainer_default = ScriptContainer;
|
|
663
|
-
export {
|
|
664
|
-
ScriptContainer_default as default
|
|
665
|
-
};
|
|
666
|
-
//# sourceMappingURL=ScriptContainer-EAE6L5JV.mjs.map
|