@dxos/plugin-script 0.7.4 → 0.7.5-labs.a279d8c
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/{AutomationPanel-PMTZROAZ.mjs → AutomationPanel-OOIRJFPJ.mjs} +4 -11
- package/dist/lib/browser/AutomationPanel-OOIRJFPJ.mjs.map +7 -0
- package/dist/lib/browser/ScriptContainer-T2AOMDT3.mjs +685 -0
- package/dist/lib/browser/ScriptContainer-T2AOMDT3.mjs.map +7 -0
- package/dist/lib/browser/{chunk-C7VBULMK.mjs → chunk-5BU5ERNU.mjs} +3 -3
- package/dist/lib/browser/chunk-5BU5ERNU.mjs.map +7 -0
- package/dist/lib/browser/chunk-REL2R7SB.mjs +52 -0
- package/dist/lib/browser/chunk-REL2R7SB.mjs.map +7 -0
- package/dist/lib/browser/{chunk-4UTRJLQ3.mjs → chunk-SDHKTS6H.mjs} +2 -51
- package/dist/lib/browser/{chunk-4UTRJLQ3.mjs.map → chunk-SDHKTS6H.mjs.map} +4 -4
- package/dist/lib/browser/chunk-SIOGRRPF.mjs +224 -0
- package/dist/lib/browser/chunk-SIOGRRPF.mjs.map +7 -0
- package/dist/lib/browser/{chunk-K7KY6YMG.mjs → chunk-SJ4J527G.mjs} +2 -2
- package/dist/lib/browser/chunk-XPGBHZ3L.mjs +40 -0
- package/dist/lib/browser/chunk-XPGBHZ3L.mjs.map +7 -0
- package/dist/lib/browser/chunk-ZM6T4HPR.mjs +15 -0
- package/dist/lib/browser/chunk-ZM6T4HPR.mjs.map +7 -0
- package/dist/lib/browser/compiler-HT53ILG7.mjs +84 -0
- package/dist/lib/browser/compiler-HT53ILG7.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +107 -357
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/intent-resolver-YPHT6HDZ.mjs +42 -0
- package/dist/lib/browser/intent-resolver-YPHT6HDZ.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/react-surface-GAWVYTJ5.mjs +67 -0
- package/dist/lib/browser/react-surface-GAWVYTJ5.mjs.map +7 -0
- package/dist/lib/browser/settings-YQQEU3DF.mjs +24 -0
- package/dist/lib/browser/settings-YQQEU3DF.mjs.map +7 -0
- package/dist/lib/browser/types.mjs +10 -0
- package/dist/lib/node/{AutomationPanel-AAGQREH7.cjs → AutomationPanel-EPRDDR3A.cjs} +16 -17
- package/dist/lib/node/AutomationPanel-EPRDDR3A.cjs.map +7 -0
- package/dist/lib/node/ScriptContainer-BV56I4OL.cjs +689 -0
- package/dist/lib/node/ScriptContainer-BV56I4OL.cjs.map +7 -0
- package/dist/lib/node/chunk-5V3XGLTR.cjs +252 -0
- package/dist/lib/node/chunk-5V3XGLTR.cjs.map +7 -0
- package/dist/lib/node/chunk-6VKZJ4MH.cjs +60 -0
- package/dist/lib/node/chunk-6VKZJ4MH.cjs.map +7 -0
- package/dist/lib/node/{meta.cjs → chunk-A2DI2G4D.cjs} +12 -8
- package/dist/lib/node/chunk-A2DI2G4D.cjs.map +7 -0
- package/dist/lib/node/{chunk-4INUJLXL.cjs → chunk-DQRAVZM7.cjs} +6 -6
- package/dist/lib/node/{chunk-6LYX73ZT.cjs → chunk-EFTZN5X7.cjs} +7 -7
- package/dist/lib/node/chunk-EFTZN5X7.cjs.map +7 -0
- package/dist/lib/node/{chunk-WPP65EYS.cjs → chunk-T4TXCRN5.cjs} +6 -44
- package/dist/lib/node/chunk-T4TXCRN5.cjs.map +7 -0
- package/dist/lib/node/chunk-TJ4BTPOS.cjs +64 -0
- package/dist/lib/node/chunk-TJ4BTPOS.cjs.map +7 -0
- package/dist/lib/node/compiler-457ZR24G.cjs +104 -0
- package/dist/lib/node/compiler-457ZR24G.cjs.map +7 -0
- package/dist/lib/node/index.cjs +104 -346
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/intent-resolver-SUAPE7H3.cjs +56 -0
- package/dist/lib/node/intent-resolver-SUAPE7H3.cjs.map +7 -0
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/react-surface-OMBMSFZT.cjs +86 -0
- package/dist/lib/node/react-surface-OMBMSFZT.cjs.map +7 -0
- package/dist/lib/node/settings-NGHDYAVK.cjs +38 -0
- package/dist/lib/node/settings-NGHDYAVK.cjs.map +7 -0
- package/dist/lib/node/{types/index.cjs → types.cjs} +6 -8
- package/dist/lib/node/types.cjs.map +7 -0
- package/dist/lib/node-esm/{AutomationPanel-ETQEDY5I.mjs → AutomationPanel-DMLAGQS5.mjs} +4 -11
- package/dist/lib/node-esm/AutomationPanel-DMLAGQS5.mjs.map +7 -0
- package/dist/lib/node-esm/ScriptContainer-3S5VHJVR.mjs +686 -0
- package/dist/lib/node-esm/ScriptContainer-3S5VHJVR.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-675XSDRN.mjs +16 -0
- package/dist/lib/node-esm/chunk-675XSDRN.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-SLTZMY34.mjs → chunk-BHP545D7.mjs} +3 -3
- package/dist/lib/node-esm/chunk-BHP545D7.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-4SRPREUK.mjs → chunk-G76M6O46.mjs} +2 -51
- package/dist/lib/node-esm/{chunk-4SRPREUK.mjs.map → chunk-G76M6O46.mjs.map} +4 -4
- package/dist/lib/node-esm/chunk-JHGOPQVO.mjs +41 -0
- package/dist/lib/node-esm/chunk-JHGOPQVO.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-JJZYWSD7.mjs +54 -0
- package/dist/lib/node-esm/chunk-JJZYWSD7.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-XPIKUBGS.mjs +225 -0
- package/dist/lib/node-esm/chunk-XPIKUBGS.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-OFYGBUNI.mjs → chunk-XUWS7OTK.mjs} +2 -2
- package/dist/lib/node-esm/compiler-PEARFTFR.mjs +85 -0
- package/dist/lib/node-esm/compiler-PEARFTFR.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +107 -357
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/intent-resolver-SZJXQ3CW.mjs +43 -0
- package/dist/lib/node-esm/intent-resolver-SZJXQ3CW.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/react-surface-J7NLV2V4.mjs +68 -0
- package/dist/lib/node-esm/react-surface-J7NLV2V4.mjs.map +7 -0
- package/dist/lib/node-esm/settings-XGXDY4NI.mjs +25 -0
- package/dist/lib/node-esm/settings-XGXDY4NI.mjs.map +7 -0
- package/dist/lib/node-esm/types.mjs +11 -0
- package/dist/types/src/ScriptPlugin.d.ts +1 -3
- package/dist/types/src/ScriptPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/capabilities.d.ts +5 -0
- package/dist/types/src/capabilities/capabilities.d.ts.map +1 -0
- package/dist/types/src/capabilities/compiler.d.ts +4 -0
- package/dist/types/src/capabilities/compiler.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +6 -0
- package/dist/types/src/capabilities/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/intent-resolver.d.ts +4 -0
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface.d.ts +4 -0
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
- package/dist/types/src/capabilities/settings.d.ts +4 -0
- package/dist/types/src/capabilities/settings.d.ts.map +1 -0
- package/dist/types/src/components/AutomationPanel/AutomationPanel.d.ts +2 -2
- package/dist/types/src/components/AutomationPanel/AutomationPanel.d.ts.map +1 -1
- package/dist/types/src/components/ScriptContainer.d.ts +10 -2
- package/dist/types/src/components/ScriptContainer.d.ts.map +1 -1
- package/dist/types/src/components/ScriptSettings/ScriptSettings.d.ts.map +1 -1
- package/dist/types/src/components/ScriptSettingsPanel.d.ts +1 -1
- package/dist/types/src/components/ScriptSettingsPanel.d.ts.map +1 -1
- package/dist/types/src/components/ScriptToolbar/ScriptToolbar.d.ts +11 -0
- package/dist/types/src/components/ScriptToolbar/ScriptToolbar.d.ts.map +1 -0
- package/dist/types/src/components/{Toolbar/Toolbar.stories.d.ts → ScriptToolbar/ScriptToolbar.stories.d.ts} +1 -1
- package/dist/types/src/components/ScriptToolbar/ScriptToolbar.stories.d.ts.map +1 -0
- package/dist/types/src/components/ScriptToolbar/deploy.d.ts +48 -0
- package/dist/types/src/components/ScriptToolbar/deploy.d.ts.map +1 -0
- package/dist/types/src/components/ScriptToolbar/format.d.ts +25 -0
- package/dist/types/src/components/ScriptToolbar/format.d.ts.map +1 -0
- package/dist/types/src/components/ScriptToolbar/index.d.ts +2 -0
- package/dist/types/src/components/ScriptToolbar/index.d.ts.map +1 -0
- package/dist/types/src/components/ScriptToolbar/templateSelect.d.ts +31 -0
- package/dist/types/src/components/ScriptToolbar/templateSelect.d.ts.map +1 -0
- package/dist/types/src/components/ScriptToolbar/useToolbarAction.d.ts +14 -0
- package/dist/types/src/components/ScriptToolbar/useToolbarAction.d.ts.map +1 -0
- package/dist/types/src/components/ScriptToolbar/useToolbarState.d.ts +10 -0
- package/dist/types/src/components/ScriptToolbar/useToolbarState.d.ts.map +1 -0
- package/dist/types/src/components/ScriptToolbar/view.d.ts +33 -0
- package/dist/types/src/components/ScriptToolbar/view.d.ts.map +1 -0
- package/dist/types/src/components/TypescriptEditor/TypescriptEditor.d.ts +4 -2
- package/dist/types/src/components/TypescriptEditor/TypescriptEditor.d.ts.map +1 -1
- package/dist/types/src/components/TypescriptEditor/TypescriptEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +1 -1
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +2 -4
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +1 -2
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/templates/email.d.ts +2 -1
- package/dist/types/src/templates/email.d.ts.map +1 -1
- package/dist/types/src/{templates.d.ts → templates/index.d.ts} +1 -1
- package/dist/types/src/templates/index.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +48 -0
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types.d.ts +30 -0
- package/dist/types/src/types.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -0
- package/package.json +45 -55
- package/src/ScriptPlugin.tsx +65 -145
- package/src/bundler/bundler.test.ts +4 -3
- package/src/capabilities/capabilities.ts +12 -0
- package/src/capabilities/compiler.ts +33 -0
- package/src/capabilities/index.ts +12 -0
- package/src/capabilities/intent-resolver.ts +43 -0
- package/src/capabilities/react-surface.tsx +54 -0
- package/src/capabilities/settings.ts +14 -0
- package/src/compiler/compiler.browser.test.ts +1 -1
- package/src/components/AutomationPanel/AutomationPanel.tsx +2 -4
- package/src/components/FrameContainer/FrameContainer.tsx +1 -1
- package/src/components/ScriptContainer.tsx +64 -9
- package/src/components/ScriptSettings/ScriptSettings.tsx +25 -1
- package/src/components/ScriptSettingsPanel.tsx +125 -52
- package/src/components/{Toolbar/Toolbar.stories.tsx → ScriptToolbar/ScriptToolbar.stories.tsx} +2 -2
- package/src/components/ScriptToolbar/ScriptToolbar.tsx +51 -0
- package/src/components/ScriptToolbar/deploy.ts +157 -0
- package/src/components/ScriptToolbar/format.ts +47 -0
- package/src/components/{Toolbar → ScriptToolbar}/index.ts +1 -1
- package/src/components/ScriptToolbar/templateSelect.ts +64 -0
- package/src/components/ScriptToolbar/useToolbarAction.ts +54 -0
- package/src/components/ScriptToolbar/useToolbarState.ts +16 -0
- package/src/components/ScriptToolbar/view.ts +52 -0
- package/src/components/TypescriptEditor/TypescriptEditor.stories.tsx +2 -0
- package/src/components/TypescriptEditor/TypescriptEditor.tsx +73 -8
- package/src/index.ts +2 -6
- package/src/meta.ts +1 -1
- package/src/templates/email.ts +26 -23
- package/src/{templates.ts → templates/index.ts} +5 -5
- package/src/translations.ts +18 -1
- package/src/types.ts +39 -0
- package/dist/lib/browser/AutomationPanel-PMTZROAZ.mjs.map +0 -7
- package/dist/lib/browser/ScriptContainer-RYZFYCNK.mjs +0 -425
- package/dist/lib/browser/ScriptContainer-RYZFYCNK.mjs.map +0 -7
- package/dist/lib/browser/chunk-C7VBULMK.mjs.map +0 -7
- package/dist/lib/browser/chunk-QFZUFT5G.mjs +0 -48
- package/dist/lib/browser/chunk-QFZUFT5G.mjs.map +0 -7
- package/dist/lib/browser/chunk-U3OP64V4.mjs +0 -123
- package/dist/lib/browser/chunk-U3OP64V4.mjs.map +0 -7
- package/dist/lib/browser/edge/index.mjs +0 -19
- package/dist/lib/browser/meta.mjs +0 -9
- package/dist/lib/browser/types/index.mjs +0 -12
- package/dist/lib/browser/types/index.mjs.map +0 -7
- package/dist/lib/node/AutomationPanel-AAGQREH7.cjs.map +0 -7
- package/dist/lib/node/ScriptContainer-FZ44UIRC.cjs +0 -427
- package/dist/lib/node/ScriptContainer-FZ44UIRC.cjs.map +0 -7
- package/dist/lib/node/chunk-6LYX73ZT.cjs.map +0 -7
- package/dist/lib/node/chunk-CS25QNKZ.cjs +0 -151
- package/dist/lib/node/chunk-CS25QNKZ.cjs.map +0 -7
- package/dist/lib/node/chunk-DQYAU2CJ.cjs +0 -67
- package/dist/lib/node/chunk-DQYAU2CJ.cjs.map +0 -7
- package/dist/lib/node/chunk-WPP65EYS.cjs.map +0 -7
- package/dist/lib/node/edge/index.cjs +0 -41
- package/dist/lib/node/edge/index.cjs.map +0 -7
- package/dist/lib/node/meta.cjs.map +0 -7
- package/dist/lib/node/types/index.cjs.map +0 -7
- package/dist/lib/node-esm/AutomationPanel-ETQEDY5I.mjs.map +0 -7
- package/dist/lib/node-esm/ScriptContainer-3PKDW34A.mjs +0 -426
- package/dist/lib/node-esm/ScriptContainer-3PKDW34A.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-36DLLQ6E.mjs +0 -125
- package/dist/lib/node-esm/chunk-36DLLQ6E.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-GMVPKT6A.mjs +0 -49
- package/dist/lib/node-esm/chunk-GMVPKT6A.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-SLTZMY34.mjs.map +0 -7
- package/dist/lib/node-esm/edge/index.mjs +0 -20
- package/dist/lib/node-esm/edge/index.mjs.map +0 -7
- 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/ScriptBlock/ScriptBlock.d.ts +0 -12
- package/dist/types/src/components/ScriptBlock/ScriptBlock.d.ts.map +0 -1
- package/dist/types/src/components/ScriptBlock/ScriptBlock.stories.d.ts +0 -6
- package/dist/types/src/components/ScriptBlock/ScriptBlock.stories.d.ts.map +0 -1
- package/dist/types/src/components/ScriptBlock/index.d.ts +0 -2
- package/dist/types/src/components/ScriptBlock/index.d.ts.map +0 -1
- package/dist/types/src/components/ScriptEditor.d.ts +0 -9
- package/dist/types/src/components/ScriptEditor.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.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/edge/functions.d.ts +0 -25
- package/dist/types/src/edge/functions.d.ts.map +0 -1
- package/dist/types/src/edge/index.d.ts +0 -2
- package/dist/types/src/edge/index.d.ts.map +0 -1
- package/dist/types/src/templates.d.ts.map +0 -1
- package/dist/types/src/types/index.d.ts +0 -3
- package/dist/types/src/types/index.d.ts.map +0 -1
- package/dist/types/src/types/schema.d.ts +0 -71
- package/dist/types/src/types/schema.d.ts.map +0 -1
- package/dist/types/src/types/types.d.ts +0 -8
- package/dist/types/src/types/types.d.ts.map +0 -1
- package/src/components/ScriptBlock/ScriptBlock.stories.tsx +0 -52
- package/src/components/ScriptBlock/ScriptBlock.tsx +0 -102
- package/src/components/ScriptBlock/index.ts +0 -5
- package/src/components/ScriptEditor.tsx +0 -191
- package/src/components/Toolbar/Toolbar.tsx +0 -177
- package/src/edge/functions.ts +0 -116
- package/src/edge/index.ts +0 -7
- package/src/types/index.ts +0 -6
- package/src/types/schema.ts +0 -44
- package/src/types/types.ts +0 -29
- /package/dist/lib/browser/{chunk-K7KY6YMG.mjs.map → chunk-SJ4J527G.mjs.map} +0 -0
- /package/dist/lib/browser/{edge/index.mjs.map → types.mjs.map} +0 -0
- /package/dist/lib/node/{chunk-4INUJLXL.cjs.map → chunk-DQRAVZM7.cjs.map} +0 -0
- /package/dist/lib/node-esm/{chunk-OFYGBUNI.mjs.map → chunk-XUWS7OTK.mjs.map} +0 -0
- /package/dist/lib/{browser/meta.mjs.map → node-esm/types.mjs.map} +0 -0
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
// packages/plugins/experimental/plugin-script/src/edge/functions.ts
|
|
2
|
-
import { EdgeHttpClient } from "@dxos/edge-client";
|
|
3
|
-
import { invariant } from "@dxos/invariant";
|
|
4
|
-
import { log } from "@dxos/log";
|
|
5
|
-
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/experimental/plugin-script/src/edge/functions.ts";
|
|
6
|
-
var FUNCTIONS_META_KEY = "dxos.org/service/function";
|
|
7
|
-
var FUNCTIONS_PRESET_META_KEY = "dxos.org/service/function-preset";
|
|
8
|
-
var uploadWorkerFunction = async ({ client, name, version, source, spaceId, functionId }) => {
|
|
9
|
-
const edgeUrl = client.config.values.runtime?.services?.edge?.url;
|
|
10
|
-
invariant(edgeUrl, "Edge is not configured.", {
|
|
11
|
-
F: __dxlog_file,
|
|
12
|
-
L: 38,
|
|
13
|
-
S: void 0,
|
|
14
|
-
A: [
|
|
15
|
-
"edgeUrl",
|
|
16
|
-
"'Edge is not configured.'"
|
|
17
|
-
]
|
|
18
|
-
});
|
|
19
|
-
const edgeClient = new EdgeHttpClient(edgeUrl);
|
|
20
|
-
const edgeIdentity = createEdgeIdentity(client);
|
|
21
|
-
edgeClient.setIdentity(edgeIdentity);
|
|
22
|
-
const response = await edgeClient.uploadFunction({
|
|
23
|
-
spaceId,
|
|
24
|
-
functionId
|
|
25
|
-
}, {
|
|
26
|
-
name,
|
|
27
|
-
version,
|
|
28
|
-
script: source
|
|
29
|
-
});
|
|
30
|
-
log("Uploaded", {
|
|
31
|
-
functionId,
|
|
32
|
-
source,
|
|
33
|
-
name,
|
|
34
|
-
identityKey: edgeIdentity.identityKey,
|
|
35
|
-
response
|
|
36
|
-
}, {
|
|
37
|
-
F: __dxlog_file,
|
|
38
|
-
L: 44,
|
|
39
|
-
S: void 0,
|
|
40
|
-
C: (f, a) => f(...a)
|
|
41
|
-
});
|
|
42
|
-
return response;
|
|
43
|
-
};
|
|
44
|
-
var getUserFunctionUrlInMetadata = (meta) => {
|
|
45
|
-
return meta.keys.find((key) => key.source === FUNCTIONS_META_KEY)?.id;
|
|
46
|
-
};
|
|
47
|
-
var setUserFunctionUrlInMetadata = (meta, functionUrl) => {
|
|
48
|
-
const key = meta.keys.find((key2) => key2.source === FUNCTIONS_META_KEY);
|
|
49
|
-
if (key) {
|
|
50
|
-
if (key.id !== functionUrl) {
|
|
51
|
-
throw new Error("Metadata mismatch");
|
|
52
|
-
}
|
|
53
|
-
} else {
|
|
54
|
-
meta.keys.push({
|
|
55
|
-
source: FUNCTIONS_META_KEY,
|
|
56
|
-
id: functionUrl
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
var getInvocationUrl = (functionUrl, edgeUrl, options = {}) => {
|
|
61
|
-
const baseUrl = new URL("functions/", edgeUrl);
|
|
62
|
-
const relativeUrl = functionUrl.replace(/^\//, "");
|
|
63
|
-
const url = new URL(`./${relativeUrl}`, baseUrl.toString());
|
|
64
|
-
options.spaceId && url.searchParams.set("spaceId", options.spaceId);
|
|
65
|
-
options.subjectId && url.searchParams.set("subjectId", options.subjectId);
|
|
66
|
-
url.protocol = "https";
|
|
67
|
-
return url.toString();
|
|
68
|
-
};
|
|
69
|
-
var createEdgeIdentity = (client) => {
|
|
70
|
-
const identity = client.halo.identity.get();
|
|
71
|
-
const device = client.halo.device;
|
|
72
|
-
if (!identity || !device) {
|
|
73
|
-
throw new Error("Identity not available");
|
|
74
|
-
}
|
|
75
|
-
return {
|
|
76
|
-
identityKey: identity.identityKey.toHex(),
|
|
77
|
-
peerKey: device.deviceKey.toHex(),
|
|
78
|
-
presentCredentials: async ({ challenge }) => {
|
|
79
|
-
const identityService = client.services.services.IdentityService;
|
|
80
|
-
const authCredential = await identityService.createAuthCredential();
|
|
81
|
-
return identityService.signPresentation({
|
|
82
|
-
presentation: {
|
|
83
|
-
credentials: [
|
|
84
|
-
authCredential
|
|
85
|
-
]
|
|
86
|
-
},
|
|
87
|
-
nonce: challenge
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
};
|
|
92
|
-
var incrementSemverPatch = (version) => {
|
|
93
|
-
const [major, minor, patch] = version.split(".");
|
|
94
|
-
const patchNum = Number(patch);
|
|
95
|
-
invariant(!Number.isNaN(patchNum), "Unexpected function version format.", {
|
|
96
|
-
F: __dxlog_file,
|
|
97
|
-
L: 105,
|
|
98
|
-
S: void 0,
|
|
99
|
-
A: [
|
|
100
|
-
"!Number.isNaN(patchNum)",
|
|
101
|
-
"'Unexpected function version format.'"
|
|
102
|
-
]
|
|
103
|
-
});
|
|
104
|
-
return [
|
|
105
|
-
major,
|
|
106
|
-
minor,
|
|
107
|
-
String(patchNum + 1)
|
|
108
|
-
].join(".");
|
|
109
|
-
};
|
|
110
|
-
var publicKeyToDid = (key) => {
|
|
111
|
-
return `did:key:${key.toHex()}`;
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
export {
|
|
115
|
-
FUNCTIONS_PRESET_META_KEY,
|
|
116
|
-
uploadWorkerFunction,
|
|
117
|
-
getUserFunctionUrlInMetadata,
|
|
118
|
-
setUserFunctionUrlInMetadata,
|
|
119
|
-
getInvocationUrl,
|
|
120
|
-
incrementSemverPatch,
|
|
121
|
-
publicKeyToDid
|
|
122
|
-
};
|
|
123
|
-
//# sourceMappingURL=chunk-U3OP64V4.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/edge/functions.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport { type DID } from 'iso-did/types';\n\nimport { type Client } from '@dxos/client';\nimport { type ObjectMeta } from '@dxos/echo-schema';\nimport { EdgeHttpClient, type EdgeIdentity } from '@dxos/edge-client';\nimport { invariant } from '@dxos/invariant';\nimport type { PublicKey, SpaceId } from '@dxos/keys';\nimport { log } from '@dxos/log';\nimport { type UploadFunctionResponseBody } from '@dxos/protocols';\n\n// TODO: use URL scheme for source?\nconst FUNCTIONS_META_KEY = 'dxos.org/service/function';\n\nexport const FUNCTIONS_PRESET_META_KEY = 'dxos.org/service/function-preset';\n\nexport type UploadWorkerArgs = {\n client: Client;\n name?: string;\n source: string;\n version: string;\n functionId?: string;\n spaceId: SpaceId;\n};\n\nexport const uploadWorkerFunction = async ({\n client,\n name,\n version,\n source,\n spaceId,\n functionId,\n}: UploadWorkerArgs): Promise<UploadFunctionResponseBody> => {\n const edgeUrl = client.config.values.runtime?.services?.edge?.url;\n invariant(edgeUrl, 'Edge is not configured.');\n const edgeClient = new EdgeHttpClient(edgeUrl);\n const edgeIdentity = createEdgeIdentity(client);\n edgeClient.setIdentity(edgeIdentity);\n const response = await edgeClient.uploadFunction({ spaceId, functionId }, { name, version, script: source });\n\n log('Uploaded', {\n functionId,\n source,\n name,\n identityKey: edgeIdentity.identityKey,\n response,\n });\n\n return response;\n};\n\nexport const getUserFunctionUrlInMetadata = (meta: ObjectMeta) => {\n return meta.keys.find((key) => key.source === FUNCTIONS_META_KEY)?.id;\n};\n\nexport const setUserFunctionUrlInMetadata = (meta: ObjectMeta, functionUrl: string) => {\n const key = meta.keys.find((key) => key.source === FUNCTIONS_META_KEY);\n if (key) {\n if (key.id !== functionUrl) {\n throw new Error('Metadata mismatch');\n }\n } else {\n meta.keys.push({ source: FUNCTIONS_META_KEY, id: functionUrl });\n }\n};\n\nexport const getInvocationUrl = (functionUrl: string, edgeUrl: string, options: InvocationOptions = {}) => {\n const baseUrl = new URL('functions/', edgeUrl);\n\n // Leading slashes cause the URL to be treated as an absolute path.\n const relativeUrl = functionUrl.replace(/^\\//, '');\n const url = new URL(`./${relativeUrl}`, baseUrl.toString());\n options.spaceId && url.searchParams.set('spaceId', options.spaceId);\n options.subjectId && url.searchParams.set('subjectId', options.subjectId);\n url.protocol = 'https';\n return url.toString();\n};\n\nconst createEdgeIdentity = (client: Client): EdgeIdentity => {\n const identity = client.halo.identity.get();\n const device = client.halo.device;\n if (!identity || !device) {\n throw new Error('Identity not available');\n }\n return {\n identityKey: identity.identityKey.toHex(),\n peerKey: device.deviceKey.toHex(),\n presentCredentials: async ({ challenge }) => {\n const identityService = client.services.services.IdentityService!;\n const authCredential = await identityService.createAuthCredential();\n return identityService.signPresentation({\n presentation: { credentials: [authCredential] },\n nonce: challenge,\n });\n },\n };\n};\n\nexport const incrementSemverPatch = (version: string): string => {\n const [major, minor, patch] = version.split('.');\n const patchNum = Number(patch);\n invariant(!Number.isNaN(patchNum), 'Unexpected function version format.');\n return [major, minor, String(patchNum + 1)].join('.');\n};\n\nexport const publicKeyToDid = (key: PublicKey): DID => {\n return `did:key:${key.toHex()}`;\n};\n\nexport type InvocationOptions = {\n spaceId?: SpaceId;\n subjectId?: string;\n};\n"],
|
|
5
|
-
"mappings": ";AAQA,SAASA,sBAAyC;AAClD,SAASC,iBAAiB;AAE1B,SAASC,WAAW;;AAIpB,IAAMC,qBAAqB;AAEpB,IAAMC,4BAA4B;AAWlC,IAAMC,uBAAuB,OAAO,EACzCC,QACAC,MACAC,SACAC,QACAC,SACAC,WAAU,MACO;AACjB,QAAMC,UAAUN,OAAOO,OAAOC,OAAOC,SAASC,UAAUC,MAAMC;AAC9DjB,YAAUW,SAAS,2BAAA;;;;;;;;;AACnB,QAAMO,aAAa,IAAInB,eAAeY,OAAAA;AACtC,QAAMQ,eAAeC,mBAAmBf,MAAAA;AACxCa,aAAWG,YAAYF,YAAAA;AACvB,QAAMG,WAAW,MAAMJ,WAAWK,eAAe;IAAEd;IAASC;EAAW,GAAG;IAAEJ;IAAMC;IAASiB,QAAQhB;EAAO,CAAA;AAE1GP,MAAI,YAAY;IACdS;IACAF;IACAF;IACAmB,aAAaN,aAAaM;IAC1BH;EACF,GAAA;;;;;;AAEA,SAAOA;AACT;AAEO,IAAMI,+BAA+B,CAACC,SAAAA;AAC3C,SAAOA,KAAKC,KAAKC,KAAK,CAACC,QAAQA,IAAItB,WAAWN,kBAAAA,GAAqB6B;AACrE;AAEO,IAAMC,+BAA+B,CAACL,MAAkBM,gBAAAA;AAC7D,QAAMH,MAAMH,KAAKC,KAAKC,KAAK,CAACC,SAAQA,KAAItB,WAAWN,kBAAAA;AACnD,MAAI4B,KAAK;AACP,QAAIA,IAAIC,OAAOE,aAAa;AAC1B,YAAM,IAAIC,MAAM,mBAAA;IAClB;EACF,OAAO;AACLP,SAAKC,KAAKO,KAAK;MAAE3B,QAAQN;MAAoB6B,IAAIE;IAAY,CAAA;EAC/D;AACF;AAEO,IAAMG,mBAAmB,CAACH,aAAqBtB,SAAiB0B,UAA6B,CAAC,MAAC;AACpG,QAAMC,UAAU,IAAIC,IAAI,cAAc5B,OAAAA;AAGtC,QAAM6B,cAAcP,YAAYQ,QAAQ,OAAO,EAAA;AAC/C,QAAMxB,MAAM,IAAIsB,IAAI,KAAKC,WAAAA,IAAeF,QAAQI,SAAQ,CAAA;AACxDL,UAAQ5B,WAAWQ,IAAI0B,aAAaC,IAAI,WAAWP,QAAQ5B,OAAO;AAClE4B,UAAQQ,aAAa5B,IAAI0B,aAAaC,IAAI,aAAaP,QAAQQ,SAAS;AACxE5B,MAAI6B,WAAW;AACf,SAAO7B,IAAIyB,SAAQ;AACrB;AAEA,IAAMtB,qBAAqB,CAACf,WAAAA;AAC1B,QAAM0C,WAAW1C,OAAO2C,KAAKD,SAASE,IAAG;AACzC,QAAMC,SAAS7C,OAAO2C,KAAKE;AAC3B,MAAI,CAACH,YAAY,CAACG,QAAQ;AACxB,UAAM,IAAIhB,MAAM,wBAAA;EAClB;AACA,SAAO;IACLT,aAAasB,SAAStB,YAAY0B,MAAK;IACvCC,SAASF,OAAOG,UAAUF,MAAK;IAC/BG,oBAAoB,OAAO,EAAEC,UAAS,MAAE;AACtC,YAAMC,kBAAkBnD,OAAOU,SAASA,SAAS0C;AACjD,YAAMC,iBAAiB,MAAMF,gBAAgBG,qBAAoB;AACjE,aAAOH,gBAAgBI,iBAAiB;QACtCC,cAAc;UAAEC,aAAa;YAACJ;;QAAgB;QAC9CK,OAAOR;MACT,CAAA;IACF;EACF;AACF;AAEO,IAAMS,uBAAuB,CAACzD,YAAAA;AACnC,QAAM,CAAC0D,OAAOC,OAAOC,KAAAA,IAAS5D,QAAQ6D,MAAM,GAAA;AAC5C,QAAMC,WAAWC,OAAOH,KAAAA;AACxBnE,YAAU,CAACsE,OAAOC,MAAMF,QAAAA,GAAW,uCAAA;;;;;;;;;AACnC,SAAO;IAACJ;IAAOC;IAAOM,OAAOH,WAAW,CAAA;IAAII,KAAK,GAAA;AACnD;AAEO,IAAMC,iBAAiB,CAAC5C,QAAAA;AAC7B,SAAO,WAAWA,IAAIqB,MAAK,CAAA;AAC7B;",
|
|
6
|
-
"names": ["EdgeHttpClient", "invariant", "log", "FUNCTIONS_META_KEY", "FUNCTIONS_PRESET_META_KEY", "uploadWorkerFunction", "client", "name", "version", "source", "spaceId", "functionId", "edgeUrl", "config", "values", "runtime", "services", "edge", "url", "edgeClient", "edgeIdentity", "createEdgeIdentity", "setIdentity", "response", "uploadFunction", "script", "identityKey", "getUserFunctionUrlInMetadata", "meta", "keys", "find", "key", "id", "setUserFunctionUrlInMetadata", "functionUrl", "Error", "push", "getInvocationUrl", "options", "baseUrl", "URL", "relativeUrl", "replace", "toString", "searchParams", "set", "subjectId", "protocol", "identity", "halo", "get", "device", "toHex", "peerKey", "deviceKey", "presentCredentials", "challenge", "identityService", "IdentityService", "authCredential", "createAuthCredential", "signPresentation", "presentation", "credentials", "nonce", "incrementSemverPatch", "major", "minor", "patch", "split", "patchNum", "Number", "isNaN", "String", "join", "publicKeyToDid"]
|
|
7
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
FUNCTIONS_PRESET_META_KEY,
|
|
3
|
-
getInvocationUrl,
|
|
4
|
-
getUserFunctionUrlInMetadata,
|
|
5
|
-
incrementSemverPatch,
|
|
6
|
-
publicKeyToDid,
|
|
7
|
-
setUserFunctionUrlInMetadata,
|
|
8
|
-
uploadWorkerFunction
|
|
9
|
-
} from "../chunk-U3OP64V4.mjs";
|
|
10
|
-
export {
|
|
11
|
-
FUNCTIONS_PRESET_META_KEY,
|
|
12
|
-
getInvocationUrl,
|
|
13
|
-
getUserFunctionUrlInMetadata,
|
|
14
|
-
incrementSemverPatch,
|
|
15
|
-
publicKeyToDid,
|
|
16
|
-
setUserFunctionUrlInMetadata,
|
|
17
|
-
uploadWorkerFunction
|
|
18
|
-
};
|
|
19
|
-
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/components/AutomationPanel/AutomationPanel.tsx", "../../../src/components/AutomationPanel/index.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport React, { useMemo, useState } from 'react';\n\nimport { type ReactiveEchoObject } from '@dxos/client/echo';\nimport { failUndefined } from '@dxos/debug';\nimport { useClient } from '@dxos/react-client';\nimport { Filter, getMeta, getSpace, useQuery } from '@dxos/react-client/echo';\nimport { Select, useTranslation } from '@dxos/react-ui';\n\nimport { getInvocationUrl, getUserFunctionUrlInMetadata } from '../../edge';\nimport { SCRIPT_PLUGIN } from '../../meta';\nimport { FunctionType, ScriptType } from '../../types';\nimport { DebugPanel } from '../DebugPanel';\n\nexport interface AutomationPanelProps {\n subject: ReactiveEchoObject<any>;\n}\n\nexport const AutomationPanel = ({ subject }: AutomationPanelProps) => {\n const { t } = useTranslation(SCRIPT_PLUGIN);\n const space = getSpace(subject);\n\n // TODO(dmaretskyi): Parametric query.\n const functions = useQuery(\n space ?? undefined,\n subject instanceof ScriptType\n ? Filter.schema(FunctionType, { source: subject })\n : Filter.schema(FunctionType, (fn) => fn.binding != null),\n {},\n [subject],\n );\n\n const [selectedFunction, setSelectedFunction] = useState<FunctionType | null>(null);\n const chatFunction = subject instanceof ScriptType ? functions[0] : selectedFunction;\n\n return (\n <div className='h-full flex flex-col'>\n {!(subject instanceof ScriptType) && (\n <BindingSelect\n selectedFunction={selectedFunction}\n setSelectedFunction={setSelectedFunction}\n functions={functions}\n />\n )}\n {chatFunction && <ChatPanel fn={chatFunction} subject={subject} />}\n {subject instanceof ScriptType && functions.length === 0 && <div className='p-1'>{t('not deployed')}</div>}\n </div>\n );\n};\n\nexport interface ChatPanelProps {\n fn: FunctionType;\n subject: ReactiveEchoObject<any>;\n}\n\nconst ChatPanel = ({ fn, subject }: ChatPanelProps) => {\n const client = useClient();\n const space = getSpace(fn);\n const existingFunctionUrl = getUserFunctionUrlInMetadata(getMeta(fn));\n const functionUrl = useMemo(() => {\n if (!existingFunctionUrl) {\n return;\n }\n\n return getInvocationUrl(existingFunctionUrl, client.config.values.runtime?.services?.edge?.url ?? '', {\n spaceId: space?.id,\n subjectId: subject?.id,\n });\n }, [existingFunctionUrl, space, subject]);\n\n return <DebugPanel functionUrl={functionUrl} classNames='flex-1' />;\n};\n\nexport interface BindingSelectProps {\n selectedFunction: FunctionType | null;\n setSelectedFunction: (fn: FunctionType) => void;\n functions: FunctionType[];\n}\n\nconst BindingSelect = ({ selectedFunction, setSelectedFunction, functions }: BindingSelectProps) => {\n return (\n <Select.Root\n value={selectedFunction?.id}\n onValueChange={(id) => setSelectedFunction(functions.find((fn) => fn.id === id) ?? failUndefined())}\n >\n <Select.TriggerButton placeholder='Select value' />\n <Select.Portal>\n <Select.Content>\n <Select.ScrollUpButton />\n <Select.Viewport>\n {functions.map(({ id, binding }) => (\n <Select.Option key={id} value={id}>\n {binding}\n </Select.Option>\n ))}\n </Select.Viewport>\n <Select.ScrollDownButton />\n <Select.Arrow />\n </Select.Content>\n </Select.Portal>\n </Select.Root>\n );\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { AutomationPanel } from './AutomationPanel';\n\nexport * from './AutomationPanel';\n\nexport default AutomationPanel;\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,mBAAyC;AAGzC,mBAA8B;AAC9B,0BAA0B;AAC1B,kBAAoD;AACpD,sBAAuC;AAWhC,IAAMA,kBAAkB,CAAC,EAAEC,QAAO,MAAwB;AAC/D,QAAM,EAAEC,EAAC,QAAKC,gCAAeC,mCAAAA;AAC7B,QAAMC,YAAQC,sBAASL,OAAAA;AAGvB,QAAMM,gBAAYC,sBAChBH,SAASI,QACTR,mBAAmBS,mCACfC,mBAAOC,OAAOC,oCAAc;IAAEC,QAAQb;EAAQ,CAAA,IAC9CU,mBAAOC,OAAOC,oCAAc,CAACE,OAAOA,GAAGC,WAAW,IAAA,GACtD,CAAC,GACD;IAACf;GAAQ;AAGX,QAAM,CAACgB,kBAAkBC,mBAAAA,QAAuBC,uBAA8B,IAAA;AAC9E,QAAMC,eAAenB,mBAAmBS,mCAAaH,UAAU,CAAA,IAAKU;AAEpE,SACE,6BAAAI,QAAA,cAACC,OAAAA;IAAIC,WAAU;KACZ,EAAEtB,mBAAmBS,qCACpB,6BAAAW,QAAA,cAACG,eAAAA;IACCP;IACAC;IACAX;MAGHa,gBAAgB,6BAAAC,QAAA,cAACI,WAAAA;IAAUV,IAAIK;IAAcnB;MAC7CA,mBAAmBS,oCAAcH,UAAUmB,WAAW,KAAK,6BAAAL,QAAA,cAACC,OAAAA;IAAIC,WAAU;KAAOrB,EAAE,cAAA,CAAA,CAAA;AAG1F;AAOA,IAAMuB,YAAY,CAAC,EAAEV,IAAId,QAAO,MAAkB;AAChD,QAAM0B,aAASC,+BAAAA;AACf,QAAMvB,YAAQC,sBAASS,EAAAA;AACvB,QAAMc,0BAAsBC,wDAA6BC,qBAAQhB,EAAAA,CAAAA;AACjE,QAAMiB,kBAAcC,sBAAQ,MAAA;AAC1B,QAAI,CAACJ,qBAAqB;AACxB;IACF;AAEA,eAAOK,wCAAiBL,qBAAqBF,OAAOQ,OAAOC,OAAOC,SAASC,UAAUC,MAAMC,OAAO,IAAI;MACpGC,SAASpC,OAAOqC;MAChBC,WAAW1C,SAASyC;IACtB,CAAA;EACF,GAAG;IAACb;IAAqBxB;IAAOJ;GAAQ;AAExC,SAAO,6BAAAoB,QAAA,cAACuB,kCAAAA;IAAWZ;IAA0Ba,YAAW;;AAC1D;AAQA,IAAMrB,gBAAgB,CAAC,EAAEP,kBAAkBC,qBAAqBX,UAAS,MAAsB;AAC7F,SACE,6BAAAc,QAAA,cAACyB,uBAAOC,MAAI;IACVC,OAAO/B,kBAAkByB;IACzBO,eAAe,CAACP,OAAOxB,oBAAoBX,UAAU2C,KAAK,CAACnC,OAAOA,GAAG2B,OAAOA,EAAAA,SAAOS,4BAAAA,CAAAA;KAEnF,6BAAA9B,QAAA,cAACyB,uBAAOM,eAAa;IAACC,aAAY;MAClC,6BAAAhC,QAAA,cAACyB,uBAAOQ,QAAM,MACZ,6BAAAjC,QAAA,cAACyB,uBAAOS,SAAO,MACb,6BAAAlC,QAAA,cAACyB,uBAAOU,gBAAc,IAAA,GACtB,6BAAAnC,QAAA,cAACyB,uBAAOW,UAAQ,MACblD,UAAUmD,IAAI,CAAC,EAAEhB,IAAI1B,QAAO,MAC3B,6BAAAK,QAAA,cAACyB,uBAAOa,QAAM;IAACC,KAAKlB;IAAIM,OAAON;KAC5B1B,OAAAA,CAAAA,CAAAA,GAIP,6BAAAK,QAAA,cAACyB,uBAAOe,kBAAgB,IAAA,GACxB,6BAAAxC,QAAA,cAACyB,uBAAOgB,OAAK,IAAA,CAAA,CAAA,CAAA;AAKvB;ACjGA,IAAA,0BAAe9D;",
|
|
6
|
-
"names": ["AutomationPanel", "subject", "t", "useTranslation", "SCRIPT_PLUGIN", "space", "getSpace", "functions", "useQuery", "undefined", "ScriptType", "Filter", "schema", "FunctionType", "source", "fn", "binding", "selectedFunction", "setSelectedFunction", "useState", "chatFunction", "React", "div", "className", "BindingSelect", "ChatPanel", "length", "client", "useClient", "existingFunctionUrl", "getUserFunctionUrlInMetadata", "getMeta", "functionUrl", "useMemo", "getInvocationUrl", "config", "values", "runtime", "services", "edge", "url", "spaceId", "id", "subjectId", "DebugPanel", "classNames", "Select", "Root", "value", "onValueChange", "find", "failUndefined", "TriggerButton", "placeholder", "Portal", "Content", "ScrollUpButton", "Viewport", "map", "Option", "key", "ScrollDownButton", "Arrow"]
|
|
7
|
-
}
|
|
@@ -1,427 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var ScriptContainer_FZ44UIRC_exports = {};
|
|
30
|
-
__export(ScriptContainer_FZ44UIRC_exports, {
|
|
31
|
-
default: () => ScriptContainer_default
|
|
32
|
-
});
|
|
33
|
-
module.exports = __toCommonJS(ScriptContainer_FZ44UIRC_exports);
|
|
34
|
-
var import_chunk_WPP65EYS = require("./chunk-WPP65EYS.cjs");
|
|
35
|
-
var import_chunk_4INUJLXL = require("./chunk-4INUJLXL.cjs");
|
|
36
|
-
var import_chunk_CS25QNKZ = require("./chunk-CS25QNKZ.cjs");
|
|
37
|
-
var import_chunk_DQYAU2CJ = require("./chunk-DQYAU2CJ.cjs");
|
|
38
|
-
var import_chunk_6LYX73ZT = require("./chunk-6LYX73ZT.cjs");
|
|
39
|
-
var import_react = __toESM(require("react"));
|
|
40
|
-
var import_echo = require("@dxos/react-client/echo");
|
|
41
|
-
var import_react_ui_attention = require("@dxos/react-ui-attention");
|
|
42
|
-
var import_react_ui_theme = require("@dxos/react-ui-theme");
|
|
43
|
-
var import_prettier = require("prettier");
|
|
44
|
-
var import_estree = __toESM(require("prettier/plugins/estree"));
|
|
45
|
-
var import_typescript = __toESM(require("prettier/plugins/typescript"));
|
|
46
|
-
var import_react2 = __toESM(require("react"));
|
|
47
|
-
var import_log = require("@dxos/log");
|
|
48
|
-
var import_react_client = require("@dxos/react-client");
|
|
49
|
-
var import_echo2 = require("@dxos/react-client/echo");
|
|
50
|
-
var import_halo = require("@dxos/react-client/halo");
|
|
51
|
-
var import_react_ui = require("@dxos/react-ui");
|
|
52
|
-
var import_react_ui_editor = require("@dxos/react-ui-editor");
|
|
53
|
-
var import_react_ui_theme2 = require("@dxos/react-ui-theme");
|
|
54
|
-
var import_react3 = __toESM(require("react"));
|
|
55
|
-
var import_react_ui2 = require("@dxos/react-ui");
|
|
56
|
-
var import_lang_javascript = require("@codemirror/lang-javascript");
|
|
57
|
-
var import_codemirror_ts = require("@valtown/codemirror-ts");
|
|
58
|
-
var import_react4 = __toESM(require("react"));
|
|
59
|
-
var import_react_ui3 = require("@dxos/react-ui");
|
|
60
|
-
var import_react_ui_editor2 = require("@dxos/react-ui-editor");
|
|
61
|
-
var import_util = require("@dxos/util");
|
|
62
|
-
var Toolbar = ({ classNames, deployed, error, functionUrl, view, templates: templates2, onDeploy, onFormat, onViewChange, onTemplateSelect }) => {
|
|
63
|
-
const { t } = (0, import_react_ui2.useTranslation)(import_chunk_6LYX73ZT.SCRIPT_PLUGIN);
|
|
64
|
-
const [pending, setPending] = (0, import_react3.useState)(false);
|
|
65
|
-
const handleCopyLink = async () => {
|
|
66
|
-
if (!functionUrl) {
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
await navigator.clipboard.writeText(functionUrl);
|
|
70
|
-
};
|
|
71
|
-
const handleDeploy = async () => {
|
|
72
|
-
if (!pending) {
|
|
73
|
-
setPending(true);
|
|
74
|
-
await onDeploy?.();
|
|
75
|
-
setPending(false);
|
|
76
|
-
}
|
|
77
|
-
};
|
|
78
|
-
return /* @__PURE__ */ import_react3.default.createElement(import_react_ui2.ElevationProvider, {
|
|
79
|
-
elevation: "chrome"
|
|
80
|
-
}, /* @__PURE__ */ import_react3.default.createElement(import_react_ui2.Toolbar.Root, {
|
|
81
|
-
classNames: [
|
|
82
|
-
"p-1",
|
|
83
|
-
classNames
|
|
84
|
-
],
|
|
85
|
-
style: {
|
|
86
|
-
contain: "layout"
|
|
87
|
-
}
|
|
88
|
-
}, templates2 && /* @__PURE__ */ import_react3.default.createElement(TemplateSelect, {
|
|
89
|
-
templates: templates2,
|
|
90
|
-
onTemplateSelect
|
|
91
|
-
}), onFormat && /* @__PURE__ */ import_react3.default.createElement(ToolbarIconButton, {
|
|
92
|
-
icon: "ph--magic-wand--regular",
|
|
93
|
-
text: t("format label"),
|
|
94
|
-
onClick: onFormat
|
|
95
|
-
}), /* @__PURE__ */ import_react3.default.createElement("div", {
|
|
96
|
-
role: "separator",
|
|
97
|
-
className: "grow"
|
|
98
|
-
}), error ? /* @__PURE__ */ import_react3.default.createElement(import_react_ui2.Tooltip.Root, null, /* @__PURE__ */ import_react3.default.createElement(import_react_ui2.Tooltip.Trigger, null, /* @__PURE__ */ import_react3.default.createElement(import_react_ui2.Icon, {
|
|
99
|
-
icon: "ph--warning-circle--regular",
|
|
100
|
-
size: 4
|
|
101
|
-
})), /* @__PURE__ */ import_react3.default.createElement(import_react_ui2.Tooltip.Portal, null, /* @__PURE__ */ import_react3.default.createElement(import_react_ui2.Tooltip.Content, null, /* @__PURE__ */ import_react3.default.createElement(import_react_ui2.Tooltip.Arrow, null), error))) : null, functionUrl && deployed && /* @__PURE__ */ import_react3.default.createElement(ToolbarIconButton, {
|
|
102
|
-
icon: "ph--link--regular",
|
|
103
|
-
text: t("copy link label"),
|
|
104
|
-
onClick: handleCopyLink
|
|
105
|
-
}), onDeploy && /* @__PURE__ */ import_react3.default.createElement(ToolbarIconButton, {
|
|
106
|
-
icon: pending ? "ph--spinner-gap--regular" : "ph--cloud-arrow-up--regular",
|
|
107
|
-
classNames: [
|
|
108
|
-
pending && "animate-spin"
|
|
109
|
-
],
|
|
110
|
-
text: pending ? t("pending label") : t("deploy label"),
|
|
111
|
-
onClick: handleDeploy
|
|
112
|
-
}), /* @__PURE__ */ import_react3.default.createElement(ViewSelector, {
|
|
113
|
-
view,
|
|
114
|
-
onViewChange
|
|
115
|
-
})));
|
|
116
|
-
};
|
|
117
|
-
var ToolbarIconButton = ({ icon, text, classNames, disabled, onClick }) => {
|
|
118
|
-
return /* @__PURE__ */ import_react3.default.createElement(import_react_ui2.Tooltip.Root, null, /* @__PURE__ */ import_react3.default.createElement(import_react_ui2.Tooltip.Trigger, {
|
|
119
|
-
asChild: true
|
|
120
|
-
}, /* @__PURE__ */ import_react3.default.createElement(import_react_ui2.Toolbar.Button, {
|
|
121
|
-
variant: "ghost",
|
|
122
|
-
disabled,
|
|
123
|
-
onClick
|
|
124
|
-
}, /* @__PURE__ */ import_react3.default.createElement(import_react_ui2.Icon, {
|
|
125
|
-
icon,
|
|
126
|
-
size: 4,
|
|
127
|
-
classNames
|
|
128
|
-
}))), /* @__PURE__ */ import_react3.default.createElement(import_react_ui2.Tooltip.Portal, null, /* @__PURE__ */ import_react3.default.createElement(import_react_ui2.Tooltip.Content, null, /* @__PURE__ */ import_react3.default.createElement(import_react_ui2.Tooltip.Arrow, null), text)));
|
|
129
|
-
};
|
|
130
|
-
var TemplateSelect = ({ templates: templates2 = [], onTemplateSelect }) => {
|
|
131
|
-
return /* @__PURE__ */ import_react3.default.createElement(import_react_ui2.Select.Root, {
|
|
132
|
-
value: "",
|
|
133
|
-
onValueChange: onTemplateSelect
|
|
134
|
-
}, /* @__PURE__ */ import_react3.default.createElement(import_react_ui2.Select.TriggerButton, null), /* @__PURE__ */ import_react3.default.createElement(import_react_ui2.Select.Portal, null, /* @__PURE__ */ import_react3.default.createElement(import_react_ui2.Select.Content, null, /* @__PURE__ */ import_react3.default.createElement(import_react_ui2.Select.Viewport, null, /* @__PURE__ */ import_react3.default.createElement(import_react_ui2.Select.Option, {
|
|
135
|
-
value: ""
|
|
136
|
-
}, "Template"), templates2.map(({ id, name }) => /* @__PURE__ */ import_react3.default.createElement(import_react_ui2.Select.Option, {
|
|
137
|
-
key: id,
|
|
138
|
-
value: id
|
|
139
|
-
}, name))))));
|
|
140
|
-
};
|
|
141
|
-
var ViewSelector = ({ view, onViewChange }) => {
|
|
142
|
-
return /* @__PURE__ */ import_react3.default.createElement(import_react_ui2.ToggleGroup, {
|
|
143
|
-
type: "single",
|
|
144
|
-
value: view,
|
|
145
|
-
onValueChange: (value) => onViewChange?.(value)
|
|
146
|
-
}, /* @__PURE__ */ import_react3.default.createElement(import_react_ui2.ToggleGroupItem, {
|
|
147
|
-
value: "editor",
|
|
148
|
-
classNames: "bg-transparent text-subdued"
|
|
149
|
-
}, /* @__PURE__ */ import_react3.default.createElement(import_react_ui2.Icon, {
|
|
150
|
-
icon: "ph--code--regular",
|
|
151
|
-
size: 4
|
|
152
|
-
})), /* @__PURE__ */ import_react3.default.createElement(import_react_ui2.ToggleGroupItem, {
|
|
153
|
-
value: "split",
|
|
154
|
-
classNames: "bg-transparent text-subdued"
|
|
155
|
-
}, /* @__PURE__ */ import_react3.default.createElement(import_react_ui2.Icon, {
|
|
156
|
-
icon: "ph--square-split-vertical--regular",
|
|
157
|
-
size: 4
|
|
158
|
-
})), /* @__PURE__ */ import_react3.default.createElement(import_react_ui2.ToggleGroupItem, {
|
|
159
|
-
value: "preview",
|
|
160
|
-
classNames: "bg-transparent text-subdued"
|
|
161
|
-
}, /* @__PURE__ */ import_react3.default.createElement(import_react_ui2.Icon, {
|
|
162
|
-
icon: "ph--eye--regular",
|
|
163
|
-
size: 4
|
|
164
|
-
})));
|
|
165
|
-
};
|
|
166
|
-
var TypescriptEditor = ({ id, env, className, initialValue, extensions, scrollTo, selection }) => {
|
|
167
|
-
const { themeMode } = (0, import_react_ui3.useThemeContext)();
|
|
168
|
-
const { parentRef, focusAttributes } = (0, import_react_ui_editor2.useTextEditor)(() => ({
|
|
169
|
-
id,
|
|
170
|
-
initialValue,
|
|
171
|
-
extensions: [
|
|
172
|
-
extensions,
|
|
173
|
-
(0, import_react_ui_editor2.createBasicExtensions)({
|
|
174
|
-
highlightActiveLine: true,
|
|
175
|
-
indentWithTab: true,
|
|
176
|
-
lineNumbers: true,
|
|
177
|
-
lineWrapping: false,
|
|
178
|
-
scrollPastEnd: true
|
|
179
|
-
}),
|
|
180
|
-
(0, import_react_ui_editor2.createThemeExtensions)({
|
|
181
|
-
themeMode,
|
|
182
|
-
syntaxHighlighting: true,
|
|
183
|
-
slots: {
|
|
184
|
-
content: {
|
|
185
|
-
className: import_react_ui_editor2.editorFullWidth
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
}),
|
|
189
|
-
import_react_ui_editor2.editorGutter,
|
|
190
|
-
// TODO(burdon): Factor out.
|
|
191
|
-
[
|
|
192
|
-
import_react_ui_editor2.editorMonospace,
|
|
193
|
-
(0, import_lang_javascript.javascript)({
|
|
194
|
-
typescript: true
|
|
195
|
-
}),
|
|
196
|
-
// https://github.com/val-town/codemirror-ts
|
|
197
|
-
(0, import_react_ui_editor2.autocomplete)({
|
|
198
|
-
override: env ? [
|
|
199
|
-
(0, import_codemirror_ts.tsAutocomplete)()
|
|
200
|
-
] : []
|
|
201
|
-
}),
|
|
202
|
-
env ? [
|
|
203
|
-
import_codemirror_ts.tsFacet.of({
|
|
204
|
-
env,
|
|
205
|
-
path: `/src/${id}.ts`
|
|
206
|
-
}),
|
|
207
|
-
(0, import_codemirror_ts.tsSync)(),
|
|
208
|
-
(0, import_codemirror_ts.tsLinter)(),
|
|
209
|
-
(0, import_codemirror_ts.tsHover)()
|
|
210
|
-
] : [],
|
|
211
|
-
import_react_ui_editor2.InputModeExtensions.vscode
|
|
212
|
-
]
|
|
213
|
-
].filter(import_util.nonNullable),
|
|
214
|
-
selection,
|
|
215
|
-
scrollTo
|
|
216
|
-
}), [
|
|
217
|
-
id,
|
|
218
|
-
extensions,
|
|
219
|
-
themeMode,
|
|
220
|
-
selection,
|
|
221
|
-
scrollTo
|
|
222
|
-
]);
|
|
223
|
-
return /* @__PURE__ */ import_react4.default.createElement("div", {
|
|
224
|
-
ref: parentRef,
|
|
225
|
-
className,
|
|
226
|
-
...focusAttributes
|
|
227
|
-
});
|
|
228
|
-
};
|
|
229
|
-
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/experimental/plugin-script/src/components/ScriptEditor.tsx";
|
|
230
|
-
var ScriptEditor = ({ classNames, script, env }) => {
|
|
231
|
-
const { t } = (0, import_react_ui.useTranslation)(import_chunk_6LYX73ZT.SCRIPT_PLUGIN);
|
|
232
|
-
const client = (0, import_react_client.useClient)();
|
|
233
|
-
const identity = (0, import_halo.useIdentity)();
|
|
234
|
-
const space = (0, import_echo2.getSpace)(script);
|
|
235
|
-
const [fn] = (0, import_echo2.useQuery)(space, import_echo2.Filter.schema(import_chunk_DQYAU2CJ.FunctionType, {
|
|
236
|
-
source: script
|
|
237
|
-
}));
|
|
238
|
-
const extensions = (0, import_react2.useMemo)(() => [
|
|
239
|
-
(0, import_react_ui_editor.listener)({
|
|
240
|
-
onChange: (text) => {
|
|
241
|
-
if (script.source && script.source?.content !== text) {
|
|
242
|
-
script.changed = true;
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
}),
|
|
246
|
-
(0, import_react_ui_editor.createDataExtensions)({
|
|
247
|
-
id: script.id,
|
|
248
|
-
text: script.source && (0, import_echo2.createDocAccessor)(script.source, [
|
|
249
|
-
"content"
|
|
250
|
-
]),
|
|
251
|
-
space,
|
|
252
|
-
identity
|
|
253
|
-
})
|
|
254
|
-
], [
|
|
255
|
-
script,
|
|
256
|
-
script.source,
|
|
257
|
-
space,
|
|
258
|
-
identity
|
|
259
|
-
]);
|
|
260
|
-
const [view, setView] = (0, import_react2.useState)("editor");
|
|
261
|
-
const existingFunctionUrl = fn && (0, import_chunk_CS25QNKZ.getUserFunctionUrlInMetadata)((0, import_echo2.getMeta)(fn));
|
|
262
|
-
const [error, setError] = (0, import_react2.useState)();
|
|
263
|
-
const handleFormat = (0, import_react2.useCallback)(async () => {
|
|
264
|
-
if (!script.source) {
|
|
265
|
-
return;
|
|
266
|
-
}
|
|
267
|
-
try {
|
|
268
|
-
script.source.content = await (0, import_prettier.format)(script.source.content, {
|
|
269
|
-
parser: "typescript",
|
|
270
|
-
plugins: [
|
|
271
|
-
import_estree.default,
|
|
272
|
-
import_typescript.default
|
|
273
|
-
],
|
|
274
|
-
semi: true,
|
|
275
|
-
singleQuote: true
|
|
276
|
-
});
|
|
277
|
-
} catch (err) {
|
|
278
|
-
import_log.log.catch(err, void 0, {
|
|
279
|
-
F: __dxlog_file,
|
|
280
|
-
L: 83,
|
|
281
|
-
S: void 0,
|
|
282
|
-
C: (f, a) => f(...a)
|
|
283
|
-
});
|
|
284
|
-
}
|
|
285
|
-
}, [
|
|
286
|
-
script.source
|
|
287
|
-
]);
|
|
288
|
-
const handleTemplateChange = (id) => {
|
|
289
|
-
const template = import_chunk_WPP65EYS.templates.find((template2) => template2.id === id);
|
|
290
|
-
if (template) {
|
|
291
|
-
script.name = template.name;
|
|
292
|
-
script.source.content = template.source;
|
|
293
|
-
const metaKeys = (0, import_echo2.getMeta)(script).keys;
|
|
294
|
-
const oldPresetIndex = metaKeys.findIndex((key) => key.source === import_chunk_CS25QNKZ.FUNCTIONS_PRESET_META_KEY);
|
|
295
|
-
if (oldPresetIndex >= 0) {
|
|
296
|
-
metaKeys.splice(oldPresetIndex, 1);
|
|
297
|
-
}
|
|
298
|
-
if (template.presetId) {
|
|
299
|
-
metaKeys.push({
|
|
300
|
-
source: import_chunk_CS25QNKZ.FUNCTIONS_PRESET_META_KEY,
|
|
301
|
-
id: template.presetId
|
|
302
|
-
});
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
};
|
|
306
|
-
const handleDeploy = (0, import_react2.useCallback)(async () => {
|
|
307
|
-
if (!script.source || !identity || !space) {
|
|
308
|
-
return;
|
|
309
|
-
}
|
|
310
|
-
setError(void 0);
|
|
311
|
-
try {
|
|
312
|
-
const existingFunctionId = existingFunctionUrl?.split("/").at(-1);
|
|
313
|
-
const bundler = new import_chunk_WPP65EYS.Bundler({
|
|
314
|
-
platform: "browser",
|
|
315
|
-
sandboxedModules: [],
|
|
316
|
-
remoteModules: {}
|
|
317
|
-
});
|
|
318
|
-
const buildResult = await bundler.bundle(script.source.content);
|
|
319
|
-
if (buildResult.error || !buildResult.bundle) {
|
|
320
|
-
throw buildResult.error;
|
|
321
|
-
}
|
|
322
|
-
const { functionId, version, meta } = await (0, import_chunk_CS25QNKZ.uploadWorkerFunction)({
|
|
323
|
-
client,
|
|
324
|
-
spaceId: space.id,
|
|
325
|
-
version: fn ? (0, import_chunk_CS25QNKZ.incrementSemverPatch)(fn.version) : "0.0.1",
|
|
326
|
-
functionId: existingFunctionId,
|
|
327
|
-
source: buildResult.bundle
|
|
328
|
-
});
|
|
329
|
-
if (functionId === void 0 || version === void 0) {
|
|
330
|
-
throw new Error(`Upload didn't return expected data: functionId=${functionId}, version=${version}`);
|
|
331
|
-
}
|
|
332
|
-
import_log.log.info("function uploaded", {
|
|
333
|
-
functionId,
|
|
334
|
-
version
|
|
335
|
-
}, {
|
|
336
|
-
F: __dxlog_file,
|
|
337
|
-
L: 130,
|
|
338
|
-
S: void 0,
|
|
339
|
-
C: (f, a) => f(...a)
|
|
340
|
-
});
|
|
341
|
-
if (fn) {
|
|
342
|
-
fn.version = version;
|
|
343
|
-
}
|
|
344
|
-
const deployedFunction = fn ?? space.db.add((0, import_echo2.create)(import_chunk_DQYAU2CJ.FunctionType, {
|
|
345
|
-
name: functionId,
|
|
346
|
-
version,
|
|
347
|
-
source: script
|
|
348
|
-
}));
|
|
349
|
-
script.changed = false;
|
|
350
|
-
if (meta.inputSchema) {
|
|
351
|
-
deployedFunction.inputSchema = meta.inputSchema;
|
|
352
|
-
} else {
|
|
353
|
-
import_log.log.verbose("no input schema in function metadata", {
|
|
354
|
-
functionId
|
|
355
|
-
}, {
|
|
356
|
-
F: __dxlog_file,
|
|
357
|
-
L: 142,
|
|
358
|
-
S: void 0,
|
|
359
|
-
C: (f, a) => f(...a)
|
|
360
|
-
});
|
|
361
|
-
}
|
|
362
|
-
(0, import_chunk_CS25QNKZ.setUserFunctionUrlInMetadata)((0, import_echo2.getMeta)(deployedFunction), `/${space.id}/${functionId}`);
|
|
363
|
-
setView("split");
|
|
364
|
-
} catch (err) {
|
|
365
|
-
import_log.log.catch(err, void 0, {
|
|
366
|
-
F: __dxlog_file,
|
|
367
|
-
L: 149,
|
|
368
|
-
S: void 0,
|
|
369
|
-
C: (f, a) => f(...a)
|
|
370
|
-
});
|
|
371
|
-
setError(t("upload failed label"));
|
|
372
|
-
}
|
|
373
|
-
}, [
|
|
374
|
-
fn,
|
|
375
|
-
existingFunctionUrl,
|
|
376
|
-
script,
|
|
377
|
-
script.name,
|
|
378
|
-
script.source,
|
|
379
|
-
space?.id ?? null
|
|
380
|
-
]);
|
|
381
|
-
const functionUrl = (0, import_react2.useMemo)(() => {
|
|
382
|
-
if (!existingFunctionUrl) {
|
|
383
|
-
return;
|
|
384
|
-
}
|
|
385
|
-
return (0, import_chunk_CS25QNKZ.getInvocationUrl)(existingFunctionUrl, client.config.values.runtime?.services?.edge?.url ?? "", {
|
|
386
|
-
spaceId: space?.id
|
|
387
|
-
});
|
|
388
|
-
}, [
|
|
389
|
-
existingFunctionUrl,
|
|
390
|
-
space
|
|
391
|
-
]);
|
|
392
|
-
return /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
393
|
-
role: "none",
|
|
394
|
-
className: (0, import_react_ui_theme2.mx)("flex flex-col w-full overflow-hidden divide-y divide-separator", classNames)
|
|
395
|
-
}, /* @__PURE__ */ import_react2.default.createElement(Toolbar, {
|
|
396
|
-
deployed: Boolean(existingFunctionUrl) && !script.changed,
|
|
397
|
-
functionUrl,
|
|
398
|
-
error,
|
|
399
|
-
view,
|
|
400
|
-
templates: import_chunk_WPP65EYS.templates,
|
|
401
|
-
onDeploy: handleDeploy,
|
|
402
|
-
onFormat: handleFormat,
|
|
403
|
-
onViewChange: setView,
|
|
404
|
-
onTemplateSelect: handleTemplateChange
|
|
405
|
-
}), view !== "preview" && /* @__PURE__ */ import_react2.default.createElement(TypescriptEditor, {
|
|
406
|
-
id: script.id,
|
|
407
|
-
env,
|
|
408
|
-
initialValue: script.source?.content,
|
|
409
|
-
extensions,
|
|
410
|
-
className: "flex is-full bs-full overflow-hidden ch-focus-ring-inset-over-all"
|
|
411
|
-
}), view !== "editor" && /* @__PURE__ */ import_react2.default.createElement(import_chunk_4INUJLXL.DebugPanel, {
|
|
412
|
-
functionUrl
|
|
413
|
-
}));
|
|
414
|
-
};
|
|
415
|
-
var ScriptContainer = ({ script, ...props }) => {
|
|
416
|
-
const attendableAttrs = (0, import_react_ui_attention.useAttendableAttributes)((0, import_echo.fullyQualifiedId)(script));
|
|
417
|
-
return /* @__PURE__ */ import_react.default.createElement("div", {
|
|
418
|
-
role: "none",
|
|
419
|
-
className: (0, import_react_ui_theme.mx)("flex row-span-2 w-full overflow-hidden attention-surface"),
|
|
420
|
-
...attendableAttrs
|
|
421
|
-
}, /* @__PURE__ */ import_react.default.createElement(ScriptEditor, {
|
|
422
|
-
...props,
|
|
423
|
-
script
|
|
424
|
-
}));
|
|
425
|
-
};
|
|
426
|
-
var ScriptContainer_default = ScriptContainer;
|
|
427
|
-
//# sourceMappingURL=ScriptContainer-FZ44UIRC.cjs.map
|