@dxos/plugin-script 0.6.10 → 0.6.11-staging.9c4dc38

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/dist/lib/browser/{ScriptEditor-WNCGR5OU.mjs → ScriptEditor-5Y3EROG3.mjs} +126 -65
  2. package/dist/lib/browser/ScriptEditor-5Y3EROG3.mjs.map +7 -0
  3. package/dist/lib/browser/{TypescriptEditor-XTGRVCMY.mjs → TypescriptEditor-GPE72Y6I.mjs} +2 -2
  4. package/dist/lib/browser/{chunk-DX5CSOBP.mjs → chunk-MRGOT5RF.mjs} +25 -26
  5. package/dist/lib/browser/chunk-MRGOT5RF.mjs.map +7 -0
  6. package/dist/lib/browser/{chunk-ZGCETT2W.mjs → chunk-O4LWBX6A.mjs} +7 -2
  7. package/dist/lib/browser/chunk-O4LWBX6A.mjs.map +7 -0
  8. package/dist/lib/browser/index.mjs +6 -6
  9. package/dist/lib/browser/index.mjs.map +2 -2
  10. package/dist/lib/browser/meta.json +1 -1
  11. package/dist/lib/browser/types/index.mjs +1 -1
  12. package/dist/lib/node/{ScriptEditor-RR7AVOQL.cjs → ScriptEditor-YCUQFWQM.cjs} +142 -81
  13. package/dist/lib/node/ScriptEditor-YCUQFWQM.cjs.map +7 -0
  14. package/dist/lib/node/{TypescriptEditor-CRONCQSI.cjs → TypescriptEditor-M3WWFIP2.cjs} +7 -7
  15. package/dist/lib/node/{TypescriptEditor-CRONCQSI.cjs.map → TypescriptEditor-M3WWFIP2.cjs.map} +2 -2
  16. package/dist/lib/node/{chunk-VW2POILW.cjs → chunk-5RBVXKXT.cjs} +9 -4
  17. package/dist/lib/node/chunk-5RBVXKXT.cjs.map +7 -0
  18. package/dist/lib/node/{chunk-RXI576K3.cjs → chunk-IMLDKD5Y.cjs} +28 -29
  19. package/dist/lib/node/chunk-IMLDKD5Y.cjs.map +7 -0
  20. package/dist/lib/node/index.cjs +18 -18
  21. package/dist/lib/node/index.cjs.map +2 -2
  22. package/dist/lib/node/meta.json +1 -1
  23. package/dist/lib/node/types/index.cjs +4 -4
  24. package/dist/lib/node/types/index.cjs.map +1 -1
  25. package/dist/types/src/ScriptPlugin.d.ts.map +1 -1
  26. package/dist/types/src/components/DebugPanel.d.ts +9 -0
  27. package/dist/types/src/components/DebugPanel.d.ts.map +1 -0
  28. package/dist/types/src/components/ScriptBlock/ScriptBlock.stories.d.ts +1 -4
  29. package/dist/types/src/components/ScriptBlock/ScriptBlock.stories.d.ts.map +1 -1
  30. package/dist/types/src/components/ScriptEditor.d.ts.map +1 -1
  31. package/dist/types/src/components/Toolbar.d.ts.map +1 -1
  32. package/dist/types/src/components/Toolbar.stories.d.ts +1 -3
  33. package/dist/types/src/components/Toolbar.stories.d.ts.map +1 -1
  34. package/dist/types/src/components/TypescriptEditor.d.ts +3 -4
  35. package/dist/types/src/components/TypescriptEditor.d.ts.map +1 -1
  36. package/dist/types/src/components/TypescriptEditor.stories.d.ts +1 -4
  37. package/dist/types/src/components/TypescriptEditor.stories.d.ts.map +1 -1
  38. package/dist/types/src/components/index.d.ts +1 -1
  39. package/dist/types/src/types/script.d.ts +12 -0
  40. package/dist/types/src/types/script.d.ts.map +1 -1
  41. package/dist/types/src/types/types.d.ts.map +1 -1
  42. package/package.json +36 -33
  43. package/src/ScriptPlugin.tsx +7 -4
  44. package/src/components/{DetailsPanel.tsx → DebugPanel.tsx} +87 -36
  45. package/src/components/ScriptBlock/ScriptBlock.stories.tsx +27 -20
  46. package/src/components/ScriptEditor.tsx +20 -5
  47. package/src/components/Toolbar.stories.tsx +2 -4
  48. package/src/components/Toolbar.tsx +15 -29
  49. package/src/components/TypescriptEditor.stories.tsx +9 -12
  50. package/src/components/TypescriptEditor.tsx +15 -17
  51. package/src/types/script.ts +13 -0
  52. package/dist/lib/browser/ScriptEditor-WNCGR5OU.mjs.map +0 -7
  53. package/dist/lib/browser/chunk-DX5CSOBP.mjs.map +0 -7
  54. package/dist/lib/browser/chunk-ZGCETT2W.mjs.map +0 -7
  55. package/dist/lib/node/ScriptEditor-RR7AVOQL.cjs.map +0 -7
  56. package/dist/lib/node/chunk-RXI576K3.cjs.map +0 -7
  57. package/dist/lib/node/chunk-VW2POILW.cjs.map +0 -7
  58. package/dist/types/src/components/DetailsPanel.d.ts +0 -9
  59. package/dist/types/src/components/DetailsPanel.d.ts.map +0 -1
  60. package/dist/types/src/data/templates.md.d.ts +0 -3
  61. package/dist/types/src/data/templates.md.d.ts.map +0 -1
  62. package/src/data/templates.md.ts +0 -44
  63. /package/dist/lib/browser/{TypescriptEditor-XTGRVCMY.mjs.map → TypescriptEditor-GPE72Y6I.mjs.map} +0 -0
  64. /package/src/types/{types.tsx → types.ts} +0 -0
@@ -9,13 +9,13 @@ import {
9
9
  } from "./chunk-RHEZ5LUU.mjs";
10
10
  import {
11
11
  FunctionType
12
- } from "./chunk-ZGCETT2W.mjs";
12
+ } from "./chunk-O4LWBX6A.mjs";
13
13
  import {
14
14
  SCRIPT_PLUGIN
15
15
  } from "./chunk-JBACGDOJ.mjs";
16
16
  import {
17
17
  TypescriptEditor
18
- } from "./chunk-DX5CSOBP.mjs";
18
+ } from "./chunk-MRGOT5RF.mjs";
19
19
 
20
20
  // packages/plugins/experimental/plugin-script/src/components/ScriptEditor.tsx
21
21
  import { format } from "prettier";
@@ -24,19 +24,21 @@ import prettierPluginTypescript from "prettier/plugins/typescript";
24
24
  import React3, { useCallback, useMemo, useState as useState3 } from "react";
25
25
  import { log as log2 } from "@dxos/log";
26
26
  import { useClient } from "@dxos/react-client";
27
- import { create, createDocAccessor, Filter, getMeta, getSpace, useQuery } from "@dxos/react-client/echo";
27
+ import { create, createDocAccessor, Filter, fullyQualifiedId, getMeta, getSpace, useQuery } from "@dxos/react-client/echo";
28
28
  import { useIdentity } from "@dxos/react-client/halo";
29
29
  import { useTranslation as useTranslation3 } from "@dxos/react-ui";
30
+ import { useHasAttention } from "@dxos/react-ui-attention";
30
31
  import { createDataExtensions, listener } from "@dxos/react-ui-editor";
31
- import { mx as mx3 } from "@dxos/react-ui-theme";
32
+ import { mx as mx2 } from "@dxos/react-ui-theme";
32
33
 
33
- // packages/plugins/experimental/plugin-script/src/components/DetailsPanel.tsx
34
+ // packages/plugins/experimental/plugin-script/src/components/DebugPanel.tsx
34
35
  import React, { useEffect, useRef, useState } from "react";
35
36
  import { log } from "@dxos/log";
36
- import { Avatar, DensityProvider, Icon, Input, Toolbar, useControlledValue, useDynamicRef, useTranslation } from "@dxos/react-ui";
37
+ import { Avatar, DensityProvider, Icon, Input, Toolbar, useControlledValue, useTranslation } from "@dxos/react-ui";
38
+ import { SyntaxHighlighter } from "@dxos/react-ui-syntax-highlighter";
37
39
  import { mx } from "@dxos/react-ui-theme";
38
- var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/experimental/plugin-script/src/components/DetailsPanel.tsx";
39
- var DetailsPanel = ({ classNames, functionUrl, binding: _binding, onBindingChange }) => {
40
+ var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/experimental/plugin-script/src/components/DebugPanel.tsx";
41
+ var DebugPanel = ({ classNames, functionUrl, binding: _binding, onBindingChange }) => {
40
42
  const { t } = useTranslation(SCRIPT_PLUGIN);
41
43
  const bindingInputRef = useRef(null);
42
44
  const [binding, setBinding] = useControlledValue(_binding ?? "");
@@ -46,7 +48,6 @@ var DetailsPanel = ({ classNames, functionUrl, binding: _binding, onBindingChang
46
48
  const inputRef = useRef(null);
47
49
  const [input, setInput] = useState("");
48
50
  const [result, setResult] = useState("");
49
- const resultRef = useDynamicRef(result);
50
51
  const [state, setState] = useState(null);
51
52
  const [history, setHistory] = useState([]);
52
53
  const scrollerRef = useRef(null);
@@ -72,75 +73,112 @@ var DetailsPanel = ({ classNames, functionUrl, binding: _binding, onBindingChang
72
73
  setHistory([]);
73
74
  inputRef.current?.focus();
74
75
  };
75
- const handleDone = () => {
76
+ const handleResponse = ({ text, data, error } = {}) => {
76
77
  controller.current = void 0;
77
78
  setHistory((history2) => [
78
79
  ...history2,
79
80
  {
80
81
  type: "response",
81
- text: resultRef.current
82
+ text,
83
+ data,
84
+ error
82
85
  }
83
86
  ]);
84
87
  setResult("");
85
88
  setState(null);
86
89
  handleScroll();
87
90
  };
88
- const handleRun = async (input2) => {
89
- if (input2.trim().length === 0) {
90
- inputRef.current?.focus();
91
- return;
92
- }
93
- setHistory((history2) => [
94
- ...history2,
95
- {
96
- type: "request",
97
- text: input2
98
- }
99
- ]);
100
- setInput("");
101
- setResult("");
91
+ const handleRequest = async (input2) => {
102
92
  try {
103
93
  setState("pending");
94
+ let data = null;
95
+ if (input2.charAt(0) === "{") {
96
+ try {
97
+ const validJsonString = input2.replace(/'/g, '"').replace(/([{,]\s*)([a-zA-Z0-9_]+)(\s*:)/g, '$1"$2"$3');
98
+ data = JSON.parse(validJsonString);
99
+ input2 = JSON.stringify(data, null, 2);
100
+ } catch (err) {
101
+ inputRef.current?.focus();
102
+ return;
103
+ }
104
+ }
105
+ setInput("");
106
+ setResult("");
107
+ setHistory((history2) => [
108
+ ...history2,
109
+ {
110
+ type: "request",
111
+ text: input2
112
+ }
113
+ ]);
114
+ setTimeout(() => {
115
+ handleScroll();
116
+ });
104
117
  controller.current = new AbortController();
105
118
  const response = await fetch(functionUrl, {
106
119
  signal: controller.current.signal,
107
120
  method: "POST",
108
- body: input2
121
+ body: input2,
122
+ headers: {
123
+ "Content-Type": data ? "application/json" : "text/plain"
124
+ }
109
125
  });
110
126
  if (!response.ok) {
111
- setState(null);
127
+ const text2 = await response.text();
128
+ handleResponse({
129
+ error: new Error(text2 || response.statusText || String(response.status))
130
+ });
131
+ return;
132
+ }
133
+ const contentType = response.headers.get("content-type");
134
+ if (contentType === "application/json") {
135
+ const data2 = await response.json();
136
+ handleResponse({
137
+ data: data2
138
+ });
112
139
  return;
113
140
  }
114
141
  setState("responding");
142
+ let text = "";
115
143
  const reader = response.body.getReader();
116
144
  const pump = async ({ done, value }) => {
117
- setResult((result2) => result2 + new TextDecoder().decode(value));
118
- handleScroll();
145
+ text = text + new TextDecoder().decode(value);
119
146
  if (!controller.current || done) {
120
- handleDone();
147
+ handleResponse({
148
+ text
149
+ });
121
150
  return;
122
151
  }
152
+ setResult(text);
153
+ setTimeout(() => {
154
+ handleScroll();
155
+ });
123
156
  return reader.read().then(pump);
124
157
  };
125
158
  void reader.read().then(pump).catch((err) => {
126
159
  if (err.name !== "AbortError") {
127
160
  log.catch(err, void 0, {
128
161
  F: __dxlog_file,
129
- L: 133,
162
+ L: 163,
130
163
  S: void 0,
131
164
  C: (f, a) => f(...a)
132
165
  });
133
166
  }
134
167
  });
135
168
  } catch (err) {
136
- setState(null);
137
169
  if (err !== "stop") {
170
+ const error = err instanceof Error ? err : new Error(err);
171
+ handleResponse({
172
+ error
173
+ });
138
174
  log.catch(err, void 0, {
139
175
  F: __dxlog_file,
140
- L: 139,
176
+ L: 170,
141
177
  S: void 0,
142
178
  C: (f, a) => f(...a)
143
179
  });
180
+ } else {
181
+ handleResponse();
144
182
  }
145
183
  }
146
184
  };
@@ -163,7 +201,7 @@ var DetailsPanel = ({ classNames, functionUrl, binding: _binding, onBindingChang
163
201
  placeholder: t("function request placeholder"),
164
202
  value: input,
165
203
  onChange: (ev) => setInput(ev.target.value),
166
- onKeyDown: (ev) => ev.key === "Enter" && handleRun(input)
204
+ onKeyDown: (ev) => ev.key === "Enter" && handleRequest(input)
167
205
  })), /* @__PURE__ */ React.createElement(Input.Root, null, /* @__PURE__ */ React.createElement(Input.TextInput, {
168
206
  ref: bindingInputRef,
169
207
  classNames: "!w-[10rem]",
@@ -172,7 +210,7 @@ var DetailsPanel = ({ classNames, functionUrl, binding: _binding, onBindingChang
172
210
  onChange: (ev) => setBinding(ev.target.value.toUpperCase()),
173
211
  onBlur: handleBlur
174
212
  })), /* @__PURE__ */ React.createElement(Toolbar.Button, {
175
- onClick: () => handleRun(input)
213
+ onClick: () => handleRequest(input)
176
214
  }, /* @__PURE__ */ React.createElement(Icon, {
177
215
  icon: "ph--play--regular",
178
216
  size: 4
@@ -189,15 +227,34 @@ var RobotAvatar = () => /* @__PURE__ */ React.createElement(Avatar.Root, {
189
227
  }, /* @__PURE__ */ React.createElement(Avatar.Frame, null, /* @__PURE__ */ React.createElement(Avatar.Icon, {
190
228
  icon: "ph--robot--regular"
191
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
+ };
192
246
  var MessageThread = ({ state, result, history }) => {
193
- return /* @__PURE__ */ React.createElement(React.Fragment, null, history.map(({ type, text }, i) => /* @__PURE__ */ React.createElement("div", {
247
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, history.map((message, i) => /* @__PURE__ */ React.createElement("div", {
194
248
  key: i,
195
249
  className: "grid grid-cols-[3rem_1fr]"
196
- }, /* @__PURE__ */ React.createElement("div", null, type === "response" && /* @__PURE__ */ React.createElement(RobotAvatar, null)), /* @__PURE__ */ React.createElement("div", {
197
- className: mx("flex", type === "request" && "justify-end")
198
- }, /* @__PURE__ */ React.createElement("span", {
199
- className: mx(type === "request" && "p-1 px-2 rounded-lg bg-hoverSurface")
200
- }, text)))), /* @__PURE__ */ React.createElement("div", {
250
+ }, /* @__PURE__ */ React.createElement("div", null, message.type === "response" && /* @__PURE__ */ React.createElement(RobotAvatar, null)), /* @__PURE__ */ React.createElement("div", {
251
+ className: mx("flex", message.type === "request" && "justify-end")
252
+ }, /* @__PURE__ */ React.createElement(MessageItem, {
253
+ classNames: [
254
+ message.type === "request" && "p-1 px-2 rounded-lg bg-hoverSurface"
255
+ ],
256
+ message
257
+ })))), /* @__PURE__ */ React.createElement("div", {
201
258
  className: "grid grid-cols-[3rem_1fr]"
202
259
  }, /* @__PURE__ */ React.createElement("div", null, state === "pending" && /* @__PURE__ */ React.createElement(Icon, {
203
260
  icon: "ph--spinner--regular",
@@ -207,10 +264,8 @@ var MessageThread = ({ state, result, history }) => {
207
264
  };
208
265
 
209
266
  // packages/plugins/experimental/plugin-script/src/components/Toolbar.tsx
210
- import { Checks, CircleNotch, Link, MagicWand, UploadSimple, WarningCircle } from "@phosphor-icons/react";
211
267
  import React2, { useState as useState2 } from "react";
212
268
  import { DensityProvider as DensityProvider2, ElevationProvider, Icon as Icon2, Toolbar as NaturalToolbar, Tooltip, useTranslation as useTranslation2 } from "@dxos/react-ui";
213
- import { getSize, mx as mx2 } from "@dxos/react-ui-theme";
214
269
  var Toolbar2 = ({ classNames, deployed, error, functionUrl, showPanel, onDeploy, onFormat, onTogglePanel }) => {
215
270
  const { t } = useTranslation2(SCRIPT_PLUGIN);
216
271
  const [pending, setPending] = useState2(false);
@@ -242,39 +297,43 @@ var Toolbar2 = ({ classNames, deployed, error, functionUrl, showPanel, onDeploy,
242
297
  }, /* @__PURE__ */ React2.createElement(NaturalToolbar.Button, {
243
298
  variant: "ghost",
244
299
  onClick: onFormat
245
- }, /* @__PURE__ */ React2.createElement(MagicWand, {
246
- className: getSize(4)
300
+ }, /* @__PURE__ */ React2.createElement(Icon2, {
301
+ icon: "ph--magic-wand--regular",
302
+ size: 4
247
303
  }))), /* @__PURE__ */ React2.createElement(Tooltip.Portal, null, /* @__PURE__ */ React2.createElement(Tooltip.Content, null, /* @__PURE__ */ React2.createElement(Tooltip.Arrow, null), t("format label")))), /* @__PURE__ */ React2.createElement("div", {
248
304
  role: "separator",
249
305
  className: "grow"
250
- }), functionUrl && /* @__PURE__ */ React2.createElement(Tooltip.Root, null, /* @__PURE__ */ React2.createElement(Tooltip.Trigger, {
306
+ }), error ? /* @__PURE__ */ React2.createElement(Tooltip.Root, null, /* @__PURE__ */ React2.createElement(Tooltip.Trigger, null, /* @__PURE__ */ React2.createElement(Icon2, {
307
+ icon: "ph--warning-circle--regular",
308
+ 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(Tooltip.Root, null, /* @__PURE__ */ React2.createElement(Tooltip.Trigger, {
251
310
  asChild: true
252
311
  }, /* @__PURE__ */ React2.createElement(NaturalToolbar.Button, {
253
312
  variant: "ghost",
254
313
  onClick: handleCopyLink
255
- }, /* @__PURE__ */ React2.createElement(Link, {
256
- className: getSize(4)
257
- }))), /* @__PURE__ */ React2.createElement(Tooltip.Portal, null, /* @__PURE__ */ React2.createElement(Tooltip.Content, null, /* @__PURE__ */ React2.createElement(Tooltip.Arrow, null), t("copy link label")))), error ? /* @__PURE__ */ React2.createElement(Tooltip.Root, null, /* @__PURE__ */ React2.createElement(Tooltip.Trigger, null, /* @__PURE__ */ React2.createElement(WarningCircle, {
258
- className: getSize(4)
259
- })), /* @__PURE__ */ React2.createElement(Tooltip.Portal, null, /* @__PURE__ */ React2.createElement(Tooltip.Content, null, /* @__PURE__ */ React2.createElement(Tooltip.Arrow, null), error))) : deployed ? /* @__PURE__ */ React2.createElement(Tooltip.Root, null, /* @__PURE__ */ React2.createElement(Tooltip.Trigger, null, /* @__PURE__ */ React2.createElement(Checks, {
260
- className: getSize(4)
261
- })), /* @__PURE__ */ React2.createElement(Tooltip.Portal, null, /* @__PURE__ */ React2.createElement(Tooltip.Content, null, /* @__PURE__ */ React2.createElement(Tooltip.Arrow, null), t("deployed label")))) : null, /* @__PURE__ */ React2.createElement(Tooltip.Root, null, /* @__PURE__ */ React2.createElement(Tooltip.Trigger, {
314
+ }, /* @__PURE__ */ React2.createElement(Icon2, {
315
+ icon: "ph--link--regular",
316
+ size: 4
317
+ }))), /* @__PURE__ */ React2.createElement(Tooltip.Portal, null, /* @__PURE__ */ React2.createElement(Tooltip.Content, null, /* @__PURE__ */ React2.createElement(Tooltip.Arrow, null), t("copy link label")))), /* @__PURE__ */ React2.createElement(Tooltip.Root, null, /* @__PURE__ */ React2.createElement(Tooltip.Trigger, {
262
318
  asChild: true
263
319
  }, /* @__PURE__ */ React2.createElement(NaturalToolbar.Button, {
264
320
  variant: "ghost",
265
321
  onClick: handleDeploy,
266
322
  disabled: pending
267
- }, pending ? /* @__PURE__ */ React2.createElement(CircleNotch, {
268
- className: mx2("spinner", getSize(4))
269
- }) : /* @__PURE__ */ React2.createElement(UploadSimple, {
270
- className: getSize(4)
323
+ }, pending ? /* @__PURE__ */ React2.createElement(Icon2, {
324
+ icon: "ph--spinner--regular",
325
+ size: 4,
326
+ classNames: "animate-spin-slow"
327
+ }) : /* @__PURE__ */ React2.createElement(Icon2, {
328
+ icon: "ph--cloud-arrow-up--regular",
329
+ size: 4
271
330
  }))), /* @__PURE__ */ React2.createElement(Tooltip.Portal, null, /* @__PURE__ */ React2.createElement(Tooltip.Content, null, /* @__PURE__ */ React2.createElement(Tooltip.Arrow, null), pending ? t("pending label") : t("deploy label")))), onTogglePanel && /* @__PURE__ */ React2.createElement(Tooltip.Root, null, /* @__PURE__ */ React2.createElement(Tooltip.Trigger, {
272
331
  asChild: true
273
332
  }, /* @__PURE__ */ React2.createElement(NaturalToolbar.Button, {
274
333
  variant: "ghost",
275
334
  onClick: onTogglePanel
276
335
  }, /* @__PURE__ */ React2.createElement(Icon2, {
277
- icon: showPanel ? "ph--caret-up--regular" : "ph--caret-down--regular",
336
+ icon: showPanel ? "ph--caret-down--regular" : "ph--caret-up--regular",
278
337
  size: 4
279
338
  }))), /* @__PURE__ */ React2.createElement(Tooltip.Portal, null, /* @__PURE__ */ React2.createElement(Tooltip.Content, null, /* @__PURE__ */ React2.createElement(Tooltip.Arrow, null), t("toggle details label")))))));
280
339
  };
@@ -283,6 +342,7 @@ var Toolbar2 = ({ classNames, deployed, error, functionUrl, showPanel, onDeploy,
283
342
  var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/plugins/experimental/plugin-script/src/components/ScriptEditor.tsx";
284
343
  var ScriptEditor = ({ env, script, role }) => {
285
344
  const { t } = useTranslation3(SCRIPT_PLUGIN);
345
+ const hasAttention = useHasAttention(fullyQualifiedId(script));
286
346
  const client = useClient();
287
347
  const identity = useIdentity();
288
348
  const space = getSpace(script);
@@ -337,7 +397,7 @@ var ScriptEditor = ({ env, script, role }) => {
337
397
  } catch (err) {
338
398
  log2.catch(err, void 0, {
339
399
  F: __dxlog_file2,
340
- L: 92,
400
+ L: 102,
341
401
  S: void 0,
342
402
  C: (f, a) => f(...a)
343
403
  });
@@ -377,7 +437,7 @@ var ScriptEditor = ({ env, script, role }) => {
377
437
  functionVersionNumber
378
438
  }, {
379
439
  F: __dxlog_file2,
380
- L: 127,
440
+ L: 137,
381
441
  S: void 0,
382
442
  C: (f, a) => f(...a)
383
443
  });
@@ -394,7 +454,7 @@ var ScriptEditor = ({ env, script, role }) => {
394
454
  } catch (err) {
395
455
  log2.catch(err, void 0, {
396
456
  F: __dxlog_file2,
397
- L: 137,
457
+ L: 147,
398
458
  S: void 0,
399
459
  C: (f, a) => f(...a)
400
460
  });
@@ -423,14 +483,15 @@ var ScriptEditor = ({ env, script, role }) => {
423
483
  ]);
424
484
  return /* @__PURE__ */ React3.createElement("div", {
425
485
  role: "none",
426
- className: mx3(role === "article" && "row-span-2", "flex flex-col is-full bs-full overflow-hidden")
486
+ className: mx2("flex flex-col is-full bs-full overflow-hidden", role === "article" && "row-span-2", hasAttention && "attention-surface")
427
487
  }, /* @__PURE__ */ React3.createElement(TypescriptEditor, {
428
488
  id: script.id,
429
489
  env,
430
490
  initialValue,
431
491
  extensions,
432
- className: "flex is-full bs-full overflow-hidden border-b border-separator"
492
+ className: "flex is-full bs-full overflow-hidden ch-focus-ring-inset-over-all"
433
493
  }), /* @__PURE__ */ React3.createElement(Toolbar2, {
494
+ classNames: "border-t border-separator",
434
495
  deployed: Boolean(existingFunctionUrl) && !script.changed,
435
496
  functionUrl,
436
497
  error,
@@ -438,7 +499,7 @@ var ScriptEditor = ({ env, script, role }) => {
438
499
  onDeploy: handleDeploy,
439
500
  onFormat: handleFormat,
440
501
  onTogglePanel: async () => setShowPanel((showDetails) => !showDetails)
441
- }), showPanel && /* @__PURE__ */ React3.createElement(DetailsPanel, {
502
+ }), showPanel && /* @__PURE__ */ React3.createElement(DebugPanel, {
442
503
  functionUrl,
443
504
  binding: fn?.binding,
444
505
  onBindingChange: handleBindingChange
@@ -449,4 +510,4 @@ export {
449
510
  ScriptEditor,
450
511
  ScriptEditor_default as default
451
512
  };
452
- //# sourceMappingURL=ScriptEditor-WNCGR5OU.mjs.map
513
+ //# sourceMappingURL=ScriptEditor-5Y3EROG3.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/components/ScriptEditor.tsx", "../../../src/components/DebugPanel.tsx", "../../../src/components/Toolbar.tsx"],
4
+ "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { type DID } from 'iso-did/types';\nimport { format } from 'prettier';\nimport prettierPluginEstree from 'prettier/plugins/estree';\nimport prettierPluginTypescript from 'prettier/plugins/typescript';\nimport React, { useCallback, useMemo, useState } from 'react';\n\nimport { log } from '@dxos/log';\nimport { useClient } from '@dxos/react-client';\nimport {\n create,\n createDocAccessor,\n Filter,\n fullyQualifiedId,\n getMeta,\n getSpace,\n useQuery,\n} from '@dxos/react-client/echo';\nimport { useIdentity } from '@dxos/react-client/halo';\nimport { useTranslation } from '@dxos/react-ui';\nimport { useHasAttention } from '@dxos/react-ui-attention';\nimport { createDataExtensions, listener } from '@dxos/react-ui-editor';\nimport { mx } from '@dxos/react-ui-theme';\n\nimport { DebugPanel } from './DebugPanel';\nimport { Toolbar } from './Toolbar';\nimport { TypescriptEditor, type TypescriptEditorProps } from './TypescriptEditor';\nimport { Bundler } from '../bundler';\nimport {\n getUserFunctionUrlInMetadata,\n publicKeyToDid,\n setUserFunctionUrlInMetadata,\n uploadWorkerFunction,\n} from '../edge';\nimport { SCRIPT_PLUGIN } from '../meta';\nimport { FunctionType, type ScriptType } from '../types';\n\nexport type ScriptEditorProps = {\n script: ScriptType;\n role?: string;\n} & Pick<TypescriptEditorProps, 'env'>;\n\nexport const ScriptEditor = ({ env, script, role }: ScriptEditorProps) => {\n const { t } = useTranslation(SCRIPT_PLUGIN);\n const hasAttention = useHasAttention(fullyQualifiedId(script));\n const client = useClient();\n const identity = useIdentity();\n const space = getSpace(script);\n const [fn] = useQuery(\n space,\n Filter.schema(FunctionType, (fn) => fn.source === script),\n );\n\n const extensions = useMemo(\n () => [\n listener({\n onChange: (text) => {\n if (script.source && script.source?.content !== text) {\n script.changed = true;\n }\n },\n }),\n createDataExtensions({\n id: script.id,\n text: script.source && createDocAccessor(script.source, ['content']),\n space,\n identity,\n }),\n ],\n [script, script.source, space, identity],\n );\n\n const [showPanel, setShowPanel] = useState(false);\n const initialValue = useMemo(() => script.source?.content, [script.source]);\n const existingFunctionUrl = fn && getUserFunctionUrlInMetadata(getMeta(fn));\n const [error, setError] = useState<string>();\n\n const handleBindingChange = useCallback(\n (binding: string) => {\n fn.binding = binding;\n },\n [fn],\n );\n\n const handleFormat = useCallback(async () => {\n if (!script.source) {\n return;\n }\n\n try {\n script.source.content = await format(script.source.content, {\n parser: 'typescript',\n plugins: [prettierPluginEstree, prettierPluginTypescript],\n semi: true,\n singleQuote: true,\n });\n } catch (err: any) {\n // TODO(wittjosiah): Show error in UI.\n log.catch(err);\n }\n }, [script.source]);\n\n const handleDeploy = useCallback(async () => {\n if (!script.source || !identity || !space) {\n return;\n }\n\n setError(undefined);\n\n try {\n const existingFunctionId = existingFunctionUrl?.split('/').at(-1);\n const ownerDid = (existingFunctionUrl?.split('/').at(-2) as DID) ?? publicKeyToDid(identity.identityKey);\n\n const bundler = new Bundler({\n platform: 'browser',\n sandboxedModules: [],\n remoteModules: {},\n });\n const buildResult = await bundler.bundle(script.source.content);\n if (buildResult.error || !buildResult.bundle) {\n throw buildResult.error;\n }\n\n const { result, functionId, functionVersionNumber, errorMessage } = await uploadWorkerFunction({\n clientConfig: client.config,\n halo: client.halo,\n ownerDid,\n functionId: existingFunctionId,\n source: buildResult.bundle,\n });\n if (result !== 'success' || functionId === undefined || functionVersionNumber === undefined) {\n throw new Error(errorMessage);\n }\n log.info('function uploaded', { functionId, functionVersionNumber });\n if (fn) {\n fn.version = functionVersionNumber;\n }\n const deployedFunction =\n fn ?? space.db.add(create(FunctionType, { version: functionVersionNumber, source: script }));\n const meta = getMeta(deployedFunction);\n setUserFunctionUrlInMetadata(meta, `/${ownerDid}/${functionId}`);\n script.changed = false;\n } catch (err: any) {\n log.catch(err);\n setError(t('upload failed label'));\n }\n }, [fn, existingFunctionUrl, script, script.name, script.source]);\n\n const functionUrl = useMemo(() => {\n if (!existingFunctionUrl) {\n return;\n }\n\n const baseUrl = new URL('functions/', client.config.values.runtime?.services?.edge?.url);\n\n // Leading slashes cause the URL to be treated as an absolute path.\n const relativeUrl = existingFunctionUrl.replace(/^\\//, '');\n const url = new URL(`./${relativeUrl}`, baseUrl.toString());\n space && url.searchParams.set('spaceId', space.id);\n url.protocol = 'https';\n return url.toString();\n }, [existingFunctionUrl, space]);\n\n return (\n <div\n role='none'\n className={mx(\n 'flex flex-col is-full bs-full overflow-hidden',\n role === 'article' && 'row-span-2',\n hasAttention && 'attention-surface',\n )}\n >\n <TypescriptEditor\n id={script.id}\n env={env}\n initialValue={initialValue}\n extensions={extensions}\n className='flex is-full bs-full overflow-hidden ch-focus-ring-inset-over-all'\n />\n\n <Toolbar\n classNames='border-t border-separator'\n deployed={Boolean(existingFunctionUrl) && !script.changed}\n functionUrl={functionUrl}\n error={error}\n showPanel={showPanel}\n onDeploy={handleDeploy}\n onFormat={handleFormat}\n onTogglePanel={async () => setShowPanel((showDetails) => !showDetails)}\n />\n\n {showPanel && (\n <DebugPanel functionUrl={functionUrl} binding={fn?.binding} onBindingChange={handleBindingChange} />\n )}\n </div>\n );\n};\n\nexport default ScriptEditor;\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport React, { useEffect, useRef, useState } from 'react';\n\nimport { log } from '@dxos/log';\nimport {\n Avatar,\n DensityProvider,\n Icon,\n Input,\n type ThemedClassName,\n Toolbar,\n useControlledValue,\n useTranslation,\n} from '@dxos/react-ui';\nimport { SyntaxHighlighter } from '@dxos/react-ui-syntax-highlighter';\nimport { mx } from '@dxos/react-ui-theme';\n\nimport { SCRIPT_PLUGIN } from '../meta';\n\ntype State = 'pending' | 'responding';\n\n/**\n * Request or response.\n */\ntype Message = { type: 'request' | 'response'; text?: string; data?: any; error?: Error };\n\nexport type DebugPanelProps = ThemedClassName<{\n functionUrl?: string;\n binding?: string;\n onBindingChange?: (binding: string) => void;\n}>;\n\nexport const DebugPanel = ({ classNames, functionUrl, binding: _binding, onBindingChange }: DebugPanelProps) => {\n const { t } = useTranslation(SCRIPT_PLUGIN);\n\n const bindingInputRef = useRef<HTMLInputElement>(null);\n const [binding, setBinding] = useControlledValue(_binding ?? '');\n const handleBlur = () => {\n onBindingChange?.(binding);\n };\n\n const inputRef = useRef<HTMLInputElement>(null);\n const [input, setInput] = useState('');\n const [result, setResult] = useState('');\n const [state, setState] = useState<State | null>(null);\n\n // TODO(burdon): Persistent history (non-space ECHO data?)\n const [history, setHistory] = useState<Message[]>([]);\n\n const scrollerRef = useRef<HTMLDivElement>(null);\n const handleScroll = () => {\n if (scrollerRef.current) {\n scrollerRef.current.scrollTop = scrollerRef.current.scrollHeight;\n }\n };\n\n const controller = useRef<AbortController>();\n useEffect(() => {\n return () => {\n handleStop();\n };\n }, []);\n\n const handleStop = () => {\n controller.current?.abort('stop');\n controller.current = undefined;\n };\n\n const handleClear = () => {\n handleStop();\n setInput('');\n setResult('');\n setHistory([]);\n inputRef.current?.focus();\n };\n\n const handleResponse = ({ text, data, error }: { text?: string; data?: any; error?: Error } = {}) => {\n controller.current = undefined;\n setHistory((history) => [...history, { type: 'response', text, data, error } satisfies Message]);\n setResult('');\n setState(null);\n handleScroll();\n };\n\n const handleRequest = async (input: string) => {\n // Returns a promise that resolves when a value has been received.\n try {\n setState('pending');\n\n let data = null;\n // Detect JSON input.\n if (input.charAt(0) === '{') {\n try {\n const validJsonString = input.replace(/'/g, '\"').replace(/([{,]\\s*)([a-zA-Z0-9_]+)(\\s*:)/g, '$1\"$2\"$3');\n data = JSON.parse(validJsonString);\n input = JSON.stringify(data, null, 2);\n } catch (err) {\n inputRef.current?.focus();\n return;\n }\n }\n\n setInput('');\n setResult('');\n setHistory((history) => [...history, { type: 'request', text: input }]);\n setTimeout(() => {\n handleScroll();\n });\n\n // Throws DOMException when aborted.\n controller.current = new AbortController();\n const response = await fetch(functionUrl!, {\n signal: controller.current.signal,\n method: 'POST',\n body: input,\n headers: {\n 'Content-Type': data ? 'application/json' : 'text/plain',\n },\n });\n\n // Check for error.\n if (!response.ok) {\n const text = await response.text();\n handleResponse({ error: new Error(text || response.statusText || String(response.status)) });\n return;\n }\n\n // Check for JSON.\n const contentType = response.headers.get('content-type');\n if (contentType === 'application/json') {\n const data = await response.json();\n handleResponse({ data });\n return;\n }\n\n // Text (including streaming).\n setState('responding');\n let text = '';\n const reader = response.body!.getReader();\n const pump = async ({ done, value }: ReadableStreamReadResult<Uint8Array>): Promise<void> => {\n text = text + new TextDecoder().decode(value);\n if (!controller.current || done) {\n handleResponse({ text });\n return;\n }\n\n setResult(text);\n setTimeout(() => {\n handleScroll();\n });\n\n return reader.read().then(pump);\n };\n\n void reader\n .read()\n .then(pump)\n .catch((err) => {\n if (err.name !== 'AbortError') {\n log.catch(err);\n }\n });\n } catch (err: any) {\n if (err !== 'stop') {\n const error = err instanceof Error ? err : new Error(err);\n handleResponse({ error });\n log.catch(err);\n } else {\n handleResponse();\n }\n }\n };\n\n return (\n <DensityProvider density='fine'>\n <div className={mx('flex flex-col h-full overflow-hidden', classNames)}>\n {/* TODO(burdon): Replace with Thread? */}\n <div ref={scrollerRef} className='flex flex-col gap-6 h-full p-4 overflow-x-hidden overflow-y-auto'>\n <MessageThread state={state} result={result} history={history} />\n </div>\n\n <Toolbar.Root classNames='p-2'>\n <Input.Root>\n <Input.TextInput\n ref={inputRef}\n autoFocus\n placeholder={t('function request placeholder')}\n value={input}\n onChange={(ev) => setInput(ev.target.value)}\n onKeyDown={(ev) => ev.key === 'Enter' && handleRequest(input)}\n />\n </Input.Root>\n <Input.Root>\n <Input.TextInput\n ref={bindingInputRef}\n classNames='!w-[10rem]'\n placeholder={t('binding placeholder')}\n value={binding}\n onChange={(ev) => setBinding(ev.target.value.toUpperCase())}\n onBlur={handleBlur}\n />\n </Input.Root>\n <Toolbar.Button onClick={() => handleRequest(input)}>\n <Icon icon='ph--play--regular' size={4} />\n </Toolbar.Button>\n <Toolbar.Button onClick={() => (state ? handleStop() : handleClear())}>\n <Icon icon={state ? 'ph--stop--regular' : 'ph--trash--regular'} size={4} />\n </Toolbar.Button>\n </Toolbar.Root>\n </div>\n </DensityProvider>\n );\n};\n\nconst RobotAvatar = () => (\n <Avatar.Root size={6} variant='circle'>\n <Avatar.Frame>\n <Avatar.Icon icon='ph--robot--regular' />\n </Avatar.Frame>\n </Avatar.Root>\n);\n\nconst MessageItem = ({ classNames, message }: ThemedClassName<{ message: Message }>) => {\n const { text, data, error } = message;\n if (error) {\n return <span className={mx(classNames, 'whitespace-pre text-error')}>{String(error)}</span>;\n } else if (data) {\n return (\n <SyntaxHighlighter language='json' className={mx('text-xs', classNames)}>\n {JSON.stringify(data, null, 2)}\n </SyntaxHighlighter>\n );\n }\n\n return <span className={mx(classNames)}>{text || '\\u00D8'}</span>;\n};\n\n// TODO(burdon): Replace with thread?\n// TODO(burdon): Button to delete individual messages.\n// TODO(burdon): Button to re-run question.\nconst MessageThread = ({ state, result, history }: { state: State | null; result: string; history: Message[] }) => {\n return (\n <>\n {history.map((message, i) => (\n <div key={i} className='grid grid-cols-[3rem_1fr]'>\n <div>{message.type === 'response' && <RobotAvatar />}</div>\n <div className={mx('flex', message.type === 'request' && 'justify-end')}>\n <MessageItem\n classNames={[message.type === 'request' && 'p-1 px-2 rounded-lg bg-hoverSurface']}\n message={message}\n />\n </div>\n </div>\n ))}\n <div className='grid grid-cols-[3rem_1fr]'>\n <div>\n {(state === 'pending' && <Icon icon='ph--spinner--regular' size={6} classNames='animate-spin-slow' />) ||\n (result.length > 0 && <RobotAvatar />)}\n </div>\n <div>\n <span>{result}</span>\n </div>\n </div>\n </>\n );\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport React, { useState } from 'react';\n\nimport {\n DensityProvider,\n ElevationProvider,\n Icon,\n type ThemedClassName,\n Toolbar as NaturalToolbar,\n Tooltip,\n useTranslation,\n} from '@dxos/react-ui';\n\nimport { SCRIPT_PLUGIN } from '../meta';\n\nexport type ToolbarProps = ThemedClassName<{\n deployed?: boolean;\n error?: string;\n functionUrl?: string;\n showPanel?: boolean;\n onDeploy?: () => Promise<void>;\n onFormat?: () => Promise<void>;\n onTogglePanel?: () => Promise<void>;\n}>;\n\nexport const Toolbar = ({\n classNames,\n deployed,\n error,\n functionUrl,\n showPanel,\n onDeploy,\n onFormat,\n onTogglePanel,\n}: ToolbarProps) => {\n const { t } = useTranslation(SCRIPT_PLUGIN);\n const [pending, setPending] = useState(false);\n\n const handleCopyLink = async () => {\n if (!functionUrl) {\n return;\n }\n\n await navigator.clipboard.writeText(functionUrl);\n };\n\n const handleDeploy = async () => {\n setPending(true);\n await onDeploy?.();\n setPending(false);\n };\n\n // TODO(burdon): Simplify tooltips.\n // TODO(burdon): Factor out common toolbar components with sheet/editor?\n return (\n <DensityProvider density='fine'>\n <ElevationProvider elevation='chrome'>\n <NaturalToolbar.Root classNames={['p-1', classNames]} style={{ contain: 'layout' }}>\n {onFormat && (\n <Tooltip.Root>\n <Tooltip.Trigger asChild>\n <NaturalToolbar.Button variant='ghost' onClick={onFormat}>\n <Icon icon='ph--magic-wand--regular' size={4} />\n </NaturalToolbar.Button>\n </Tooltip.Trigger>\n <Tooltip.Portal>\n <Tooltip.Content>\n <Tooltip.Arrow />\n {t('format label')}\n </Tooltip.Content>\n </Tooltip.Portal>\n </Tooltip.Root>\n )}\n\n <div role='separator' className='grow' />\n\n {error ? (\n <Tooltip.Root>\n <Tooltip.Trigger>\n <Icon icon='ph--warning-circle--regular' size={4} />\n </Tooltip.Trigger>\n <Tooltip.Portal>\n <Tooltip.Content>\n <Tooltip.Arrow />\n {error}\n </Tooltip.Content>\n </Tooltip.Portal>\n </Tooltip.Root>\n ) : null}\n\n {functionUrl && deployed && (\n <Tooltip.Root>\n <Tooltip.Trigger asChild>\n <NaturalToolbar.Button variant='ghost' onClick={handleCopyLink}>\n <Icon icon='ph--link--regular' size={4} />\n </NaturalToolbar.Button>\n </Tooltip.Trigger>\n <Tooltip.Portal>\n <Tooltip.Content>\n <Tooltip.Arrow />\n {t('copy link label')}\n </Tooltip.Content>\n </Tooltip.Portal>\n </Tooltip.Root>\n )}\n\n <Tooltip.Root>\n <Tooltip.Trigger asChild>\n <NaturalToolbar.Button variant='ghost' onClick={handleDeploy} disabled={pending}>\n {pending ? (\n <Icon icon='ph--spinner--regular' size={4} classNames='animate-spin-slow' />\n ) : (\n <Icon icon='ph--cloud-arrow-up--regular' size={4} />\n )}\n </NaturalToolbar.Button>\n </Tooltip.Trigger>\n <Tooltip.Portal>\n <Tooltip.Content>\n <Tooltip.Arrow />\n {pending ? t('pending label') : t('deploy label')}\n </Tooltip.Content>\n </Tooltip.Portal>\n </Tooltip.Root>\n\n {onTogglePanel && (\n <Tooltip.Root>\n <Tooltip.Trigger asChild>\n <NaturalToolbar.Button variant='ghost' onClick={onTogglePanel}>\n <Icon icon={showPanel ? 'ph--caret-down--regular' : 'ph--caret-up--regular'} size={4} />\n </NaturalToolbar.Button>\n </Tooltip.Trigger>\n <Tooltip.Portal>\n <Tooltip.Content>\n <Tooltip.Arrow />\n {t('toggle details label')}\n </Tooltip.Content>\n </Tooltip.Portal>\n </Tooltip.Root>\n )}\n </NaturalToolbar.Root>\n </ElevationProvider>\n </DensityProvider>\n );\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAKA,SAASA,cAAc;AACvB,OAAOC,0BAA0B;AACjC,OAAOC,8BAA8B;AACrC,OAAOC,UAASC,aAAaC,SAASC,YAAAA,iBAAgB;AAEtD,SAASC,OAAAA,YAAW;AACpB,SAASC,iBAAiB;AAC1B,SACEC,QACAC,mBACAC,QACAC,kBACAC,SACAC,UACAC,gBACK;AACP,SAASC,mBAAmB;AAC5B,SAASC,kBAAAA,uBAAsB;AAC/B,SAASC,uBAAuB;AAChC,SAASC,sBAAsBC,gBAAgB;AAC/C,SAASC,MAAAA,WAAU;;;ACrBnB,OAAOC,SAASC,WAAWC,QAAQC,gBAAgB;AAEnD,SAASC,WAAW;AACpB,SACEC,QACAC,iBACAC,MACAC,OAEAC,SACAC,oBACAC,sBACK;AACP,SAASC,yBAAyB;AAClC,SAASC,UAAU;;AAiBZ,IAAMC,aAAa,CAAC,EAAEC,YAAYC,aAAaC,SAASC,UAAUC,gBAAe,MAAmB;AACzG,QAAM,EAAEC,EAAC,IAAKC,eAAeC,aAAAA;AAE7B,QAAMC,kBAAkBC,OAAyB,IAAA;AACjD,QAAM,CAACP,SAASQ,UAAAA,IAAcC,mBAAmBR,YAAY,EAAA;AAC7D,QAAMS,aAAa,MAAA;AACjBR,sBAAkBF,OAAAA;EACpB;AAEA,QAAMW,WAAWJ,OAAyB,IAAA;AAC1C,QAAM,CAACK,OAAOC,QAAAA,IAAYC,SAAS,EAAA;AACnC,QAAM,CAACC,QAAQC,SAAAA,IAAaF,SAAS,EAAA;AACrC,QAAM,CAACG,OAAOC,QAAAA,IAAYJ,SAAuB,IAAA;AAGjD,QAAM,CAACK,SAASC,UAAAA,IAAcN,SAAoB,CAAA,CAAE;AAEpD,QAAMO,cAAcd,OAAuB,IAAA;AAC3C,QAAMe,eAAe,MAAA;AACnB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OAAAA;IACCpG,MAAK;IACLqG,WAAWC,IACT,iDACAtG,SAAS,aAAa,cACtBI,gBAAgB,mBAAA;KAGlB,gBAAA+F,OAAA,cAACI,kBAAAA;IACC5E,IAAI5B,OAAO4B;IACX7B;IACAkC;IACAb;IACAkF,WAAU;MAGZ,gBAAAF,OAAA,cAACK,UAAAA;IACCC,YAAW;IACXC,UAAUC,QAAQ1E,mBAAAA,KAAwB,CAAClC,OAAO0B;IAClD4D;IACAjD;IACAP;IACA+E,UAAUxD;IACVyD,UAAUpE;IACVqE,eAAe,YAAYhF,aAAa,CAACiF,gBAAgB,CAACA,WAAAA;MAG3DlF,aACC,gBAAAsE,OAAA,cAACa,YAAAA;IAAW3B;IAA0B7C,SAAS3B,IAAI2B;IAASyE,iBAAiB3E;;AAIrF;AAEA,IAAA,uBAAezC;",
6
+ "names": ["format", "prettierPluginEstree", "prettierPluginTypescript", "React", "useCallback", "useMemo", "useState", "log", "useClient", "create", "createDocAccessor", "Filter", "fullyQualifiedId", "getMeta", "getSpace", "useQuery", "useIdentity", "useTranslation", "useHasAttention", "createDataExtensions", "listener", "mx", "React", "useEffect", "useRef", "useState", "log", "Avatar", "DensityProvider", "Icon", "Input", "Toolbar", "useControlledValue", "useTranslation", "SyntaxHighlighter", "mx", "DebugPanel", "classNames", "functionUrl", "binding", "_binding", "onBindingChange", "t", "useTranslation", "SCRIPT_PLUGIN", "bindingInputRef", "useRef", "setBinding", "useControlledValue", "handleBlur", "inputRef", "input", "setInput", "useState", "result", "setResult", "state", "setState", "history", "setHistory", "scrollerRef", "handleScroll", "current", "scrollTop", "scrollHeight", "controller", "useEffect", "handleStop", "abort", "undefined", "handleClear", "focus", "handleResponse", "text", "data", "error", "type", "handleRequest", "charAt", "validJsonString", "replace", "JSON", "parse", "stringify", "err", "setTimeout", "AbortController", "response", "fetch", "signal", "method", "body", "headers", "ok", "Error", "statusText", "String", "status", "contentType", "get", "json", "reader", "getReader", "pump", "done", "value", "TextDecoder", "decode", "read", "then", "catch", "name", "log", "DensityProvider", "density", "div", "className", "mx", "ref", "MessageThread", "Toolbar", "Root", "Input", "TextInput", "autoFocus", "placeholder", "onChange", "ev", "target", "onKeyDown", "key", "toUpperCase", "onBlur", "Button", "onClick", "Icon", "icon", "size", "RobotAvatar", "Avatar", "variant", "Frame", "MessageItem", "message", "span", "SyntaxHighlighter", "language", "map", "i", "length", "React", "useState", "DensityProvider", "ElevationProvider", "Icon", "Toolbar", "NaturalToolbar", "Tooltip", "useTranslation", "Toolbar", "classNames", "deployed", "error", "functionUrl", "showPanel", "onDeploy", "onFormat", "onTogglePanel", "t", "useTranslation", "SCRIPT_PLUGIN", "pending", "setPending", "useState", "handleCopyLink", "navigator", "clipboard", "writeText", "handleDeploy", "React", "DensityProvider", "density", "ElevationProvider", "elevation", "NaturalToolbar", "Root", "style", "contain", "Tooltip", "Trigger", "asChild", "Button", "variant", "onClick", "Icon", "icon", "size", "Portal", "Content", "Arrow", "div", "role", "className", "disabled", "ScriptEditor", "env", "script", "role", "t", "useTranslation", "SCRIPT_PLUGIN", "hasAttention", "useHasAttention", "fullyQualifiedId", "client", "useClient", "identity", "useIdentity", "space", "getSpace", "fn", "useQuery", "Filter", "schema", "FunctionType", "source", "extensions", "useMemo", "listener", "onChange", "text", "content", "changed", "createDataExtensions", "id", "createDocAccessor", "showPanel", "setShowPanel", "useState", "initialValue", "existingFunctionUrl", "getUserFunctionUrlInMetadata", "getMeta", "error", "setError", "handleBindingChange", "useCallback", "binding", "handleFormat", "format", "parser", "plugins", "prettierPluginEstree", "prettierPluginTypescript", "semi", "singleQuote", "err", "log", "catch", "handleDeploy", "undefined", "existingFunctionId", "split", "at", "ownerDid", "publicKeyToDid", "identityKey", "bundler", "Bundler", "platform", "sandboxedModules", "remoteModules", "buildResult", "bundle", "result", "functionId", "functionVersionNumber", "errorMessage", "uploadWorkerFunction", "clientConfig", "config", "halo", "Error", "info", "version", "deployedFunction", "db", "add", "create", "meta", "setUserFunctionUrlInMetadata", "name", "functionUrl", "baseUrl", "URL", "values", "runtime", "services", "edge", "url", "relativeUrl", "replace", "toString", "searchParams", "set", "protocol", "React", "div", "className", "mx", "TypescriptEditor", "Toolbar", "classNames", "deployed", "Boolean", "onDeploy", "onFormat", "onTogglePanel", "showDetails", "DebugPanel", "onBindingChange"]
7
+ }
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  TypescriptEditor,
3
3
  TypescriptEditor_default
4
- } from "./chunk-DX5CSOBP.mjs";
4
+ } from "./chunk-MRGOT5RF.mjs";
5
5
  export {
6
6
  TypescriptEditor,
7
7
  TypescriptEditor_default as default
8
8
  };
9
- //# sourceMappingURL=TypescriptEditor-XTGRVCMY.mjs.map
9
+ //# sourceMappingURL=TypescriptEditor-GPE72Y6I.mjs.map
@@ -1,20 +1,17 @@
1
1
  // packages/plugins/experimental/plugin-script/src/components/TypescriptEditor.tsx
2
2
  import { javascript } from "@codemirror/lang-javascript";
3
- import { defaultHighlightStyle, syntaxHighlighting } from "@codemirror/language";
4
- import { oneDarkHighlightStyle } from "@codemirror/theme-one-dark";
5
3
  import { tsSync, tsFacet, tsLinter, tsAutocomplete, tsHover } from "@valtown/codemirror-ts";
6
4
  import React from "react";
7
5
  import { useThemeContext } from "@dxos/react-ui";
8
6
  import { autocomplete, createBasicExtensions, createThemeExtensions, editorFullWidth, editorGutter, editorMonospace, InputModeExtensions, useTextEditor } from "@dxos/react-ui-editor";
9
7
  import { nonNullable } from "@dxos/util";
10
- var TypescriptEditor = ({ id, extensions, env, initialValue, scrollTo, selection, className, scrollPastEnd }) => {
8
+ var TypescriptEditor = ({ id, scrollPastEnd, env, className, initialValue, extensions, scrollTo, selection }) => {
11
9
  const { themeMode } = useThemeContext();
12
10
  const { parentRef, focusAttributes } = useTextEditor(() => ({
13
11
  id,
14
12
  initialValue,
15
13
  extensions: [
16
14
  extensions,
17
- // TODO(wittjosiah): Highlight active line doesn't work.
18
15
  createBasicExtensions({
19
16
  highlightActiveLine: true,
20
17
  indentWithTab: true,
@@ -22,10 +19,9 @@ var TypescriptEditor = ({ id, extensions, env, initialValue, scrollTo, selection
22
19
  lineWrapping: false,
23
20
  scrollPastEnd
24
21
  }),
25
- // TODO(wittjosiah): Factor out syntax highlighting to theme extensions.
26
- themeMode === "dark" ? syntaxHighlighting(oneDarkHighlightStyle) : syntaxHighlighting(defaultHighlightStyle),
27
22
  createThemeExtensions({
28
23
  themeMode,
24
+ syntaxHighlighting: true,
29
25
  slots: {
30
26
  content: {
31
27
  className: editorFullWidth
@@ -33,26 +29,29 @@ var TypescriptEditor = ({ id, extensions, env, initialValue, scrollTo, selection
33
29
  }
34
30
  }),
35
31
  editorGutter,
36
- editorMonospace,
37
- javascript({
38
- typescript: true
39
- }),
40
- // https://github.com/val-town/codemirror-ts
41
- env ? [
42
- tsFacet.of({
43
- env,
44
- path: `/src/${id}.ts`
32
+ // TODO(burdon): Factor out.
33
+ [
34
+ editorMonospace,
35
+ javascript({
36
+ typescript: true
45
37
  }),
46
- tsSync(),
47
- tsLinter(),
48
- tsHover()
49
- ] : [],
50
- autocomplete({
51
- override: env ? [
52
- tsAutocomplete()
53
- ] : []
54
- }),
55
- InputModeExtensions.vscode
38
+ // https://github.com/val-town/codemirror-ts
39
+ autocomplete({
40
+ override: env ? [
41
+ tsAutocomplete()
42
+ ] : []
43
+ }),
44
+ env ? [
45
+ tsFacet.of({
46
+ env,
47
+ path: `/src/${id}.ts`
48
+ }),
49
+ tsSync(),
50
+ tsLinter(),
51
+ tsHover()
52
+ ] : [],
53
+ InputModeExtensions.vscode
54
+ ]
56
55
  ].filter(nonNullable),
57
56
  selection,
58
57
  scrollTo
@@ -76,4 +75,4 @@ export {
76
75
  TypescriptEditor,
77
76
  TypescriptEditor_default
78
77
  };
79
- //# sourceMappingURL=chunk-DX5CSOBP.mjs.map
78
+ //# sourceMappingURL=chunk-MRGOT5RF.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/components/TypescriptEditor.tsx"],
4
+ "sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport { javascript } from '@codemirror/lang-javascript';\nimport { type VirtualTypeScriptEnvironment } from '@typescript/vfs';\nimport { tsSync, tsFacet, tsLinter, tsAutocomplete, tsHover } from '@valtown/codemirror-ts';\nimport React from 'react';\n\nimport { useThemeContext } from '@dxos/react-ui';\nimport {\n autocomplete,\n createBasicExtensions,\n createThemeExtensions,\n editorFullWidth,\n editorGutter,\n editorMonospace,\n InputModeExtensions,\n useTextEditor,\n type UseTextEditorProps,\n} from '@dxos/react-ui-editor';\nimport { nonNullable } from '@dxos/util';\n\nexport type TypescriptEditorProps = {\n id: string;\n scrollPastEnd?: boolean;\n env?: VirtualTypeScriptEnvironment;\n} & Pick<UseTextEditorProps, 'className' | 'initialValue' | 'extensions' | 'scrollTo' | 'selection'>;\n\nexport const TypescriptEditor = ({\n id,\n scrollPastEnd,\n env,\n className,\n initialValue,\n extensions,\n scrollTo,\n selection,\n}: TypescriptEditorProps) => {\n const { themeMode } = useThemeContext();\n const { parentRef, focusAttributes } = useTextEditor(\n () => ({\n id,\n initialValue,\n extensions: [\n extensions,\n createBasicExtensions({\n highlightActiveLine: true,\n indentWithTab: true,\n lineNumbers: true,\n lineWrapping: false,\n scrollPastEnd,\n }),\n createThemeExtensions({\n themeMode,\n syntaxHighlighting: true,\n slots: {\n content: { className: editorFullWidth },\n },\n }),\n editorGutter,\n // TODO(burdon): Factor out.\n [\n editorMonospace,\n javascript({ typescript: true }),\n // https://github.com/val-town/codemirror-ts\n autocomplete({ override: env ? [tsAutocomplete()] : [] }),\n env ? [tsFacet.of({ env, path: `/src/${id}.ts` }), tsSync(), tsLinter(), tsHover()] : [],\n InputModeExtensions.vscode,\n ],\n ].filter(nonNullable),\n selection,\n scrollTo,\n }),\n [id, initialValue, extensions, themeMode, selection, scrollTo],\n );\n\n return <div ref={parentRef} className={className} {...focusAttributes} />;\n};\n\nexport default TypescriptEditor;\n"],
5
+ "mappings": ";AAIA,SAASA,kBAAkB;AAE3B,SAASC,QAAQC,SAASC,UAAUC,gBAAgBC,eAAe;AACnE,OAAOC,WAAW;AAElB,SAASC,uBAAuB;AAChC,SACEC,cACAC,uBACAC,uBACAC,iBACAC,cACAC,iBACAC,qBACAC,qBAEK;AACP,SAASC,mBAAmB;AAQrB,IAAMC,mBAAmB,CAAC,EAC/BC,IACAC,eACAC,KACAC,WACAC,cACAC,YACAC,UACAC,UAAS,MACa;AACtB,QAAM,EAAEC,UAAS,IAAKC,gBAAAA;AACtB,QAAM,EAAEC,WAAWC,gBAAe,IAAKC,cACrC,OAAO;IACLZ;IACAI;IACAC,YAAY;MACVA;MACAQ,sBAAsB;QACpBC,qBAAqB;QACrBC,eAAe;QACfC,aAAa;QACbC,cAAc;QACdhB;MACF,CAAA;MACAiB,sBAAsB;QACpBV;QACAW,oBAAoB;QACpBC,OAAO;UACLC,SAAS;YAAElB,WAAWmB;UAAgB;QACxC;MACF,CAAA;MACAC;;MAEA;QACEC;QACAC,WAAW;UAAEC,YAAY;QAAK,CAAA;;QAE9BC,aAAa;UAAEC,UAAU1B,MAAM;YAAC2B,eAAAA;cAAoB,CAAA;QAAG,CAAA;QACvD3B,MAAM;UAAC4B,QAAQC,GAAG;YAAE7B;YAAK8B,MAAM,QAAQhC,EAAAA;UAAQ,CAAA;UAAIiC,OAAAA;UAAUC,SAAAA;UAAYC,QAAAA;YAAa,CAAA;QACtFC,oBAAoBC;;MAEtBC,OAAOC,WAAAA;IACThC;IACAD;EACF,IACA;IAACN;IAAII;IAAcC;IAAYG;IAAWD;IAAWD;GAAS;AAGhE,SAAO,sBAAA,cAACkC,OAAAA;IAAIC,KAAK/B;IAAWP;IAAuB,GAAGQ;;AACxD;AAEA,IAAA,2BAAeZ;",
6
+ "names": ["javascript", "tsSync", "tsFacet", "tsLinter", "tsAutocomplete", "tsHover", "React", "useThemeContext", "autocomplete", "createBasicExtensions", "createThemeExtensions", "editorFullWidth", "editorGutter", "editorMonospace", "InputModeExtensions", "useTextEditor", "nonNullable", "TypescriptEditor", "id", "scrollPastEnd", "env", "className", "initialValue", "extensions", "scrollTo", "selection", "themeMode", "useThemeContext", "parentRef", "focusAttributes", "useTextEditor", "createBasicExtensions", "highlightActiveLine", "indentWithTab", "lineNumbers", "lineWrapping", "createThemeExtensions", "syntaxHighlighting", "slots", "content", "editorFullWidth", "editorGutter", "editorMonospace", "javascript", "typescript", "autocomplete", "override", "tsAutocomplete", "tsFacet", "of", "path", "tsSync", "tsLinter", "tsHover", "InputModeExtensions", "vscode", "filter", "nonNullable", "div", "ref"]
7
+ }
@@ -9,8 +9,11 @@ var ScriptType = class extends TypedObject({
9
9
  typename: "dxos.org/type/Script",
10
10
  version: "0.1.0"
11
11
  })({
12
+ // TODO(burdon): Change to URI?
12
13
  name: S.optional(S.String),
14
+ description: S.optional(S.String),
13
15
  source: ref(TextType),
16
+ // TODO(burdon): Change to has of deployed content.
14
17
  // Whether source has changed since last deploy.
15
18
  changed: S.optional(S.Boolean)
16
19
  }) {
@@ -19,15 +22,17 @@ var FunctionType = class extends TypedObject({
19
22
  typename: "dxos.org/type/Function",
20
23
  version: "0.1.0"
21
24
  })({
25
+ name: S.optional(S.String),
22
26
  version: S.Number,
23
27
  // Local binding to a function name.
28
+ // TODO(burdon): Move binding to inner type.
24
29
  binding: S.optional(S.String),
25
30
  // Reference to a source script if it exists within ECHO.
26
31
  source: S.optional(ref(ScriptType))
27
32
  }) {
28
33
  };
29
34
 
30
- // packages/plugins/experimental/plugin-script/src/types/types.tsx
35
+ // packages/plugins/experimental/plugin-script/src/types/types.ts
31
36
  var ScriptAction;
32
37
  (function(ScriptAction2) {
33
38
  ScriptAction2[ScriptAction2["CREATE"] = `${SCRIPT_PLUGIN}/create`] = "CREATE";
@@ -38,4 +43,4 @@ export {
38
43
  FunctionType,
39
44
  ScriptAction
40
45
  };
41
- //# sourceMappingURL=chunk-ZGCETT2W.mjs.map
46
+ //# sourceMappingURL=chunk-O4LWBX6A.mjs.map