@dxos/plugin-script 0.7.5-main.9d26e3a → 0.7.5-main.e9bb01b
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-RFQAQ7NF.mjs → AutomationPanel-KZVZMZE6.mjs} +3 -3
- package/dist/lib/browser/ScriptContainer-AERJBGYK.mjs +685 -0
- package/dist/lib/browser/ScriptContainer-AERJBGYK.mjs.map +7 -0
- package/dist/lib/browser/chunk-ABNZIPST.mjs +15 -0
- package/dist/lib/browser/chunk-ABNZIPST.mjs.map +7 -0
- package/dist/lib/browser/chunk-ESPJMGXJ.mjs +21 -0
- package/dist/lib/browser/chunk-ESPJMGXJ.mjs.map +7 -0
- package/dist/lib/browser/chunk-J7CBIZI2.mjs +224 -0
- package/dist/lib/browser/chunk-J7CBIZI2.mjs.map +7 -0
- package/dist/lib/browser/chunk-NFPF4OIU.mjs +40 -0
- package/dist/lib/browser/chunk-NFPF4OIU.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-K7KY6YMG.mjs → chunk-Y4CVWFVS.mjs} +2 -2
- package/dist/lib/browser/compiler-4QD7VFZX.mjs +84 -0
- package/dist/lib/browser/compiler-4QD7VFZX.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +112 -288
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/intent-resolver-YABC4JRJ.mjs +45 -0
- package/dist/lib/browser/intent-resolver-YABC4JRJ.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/react-surface-FRQIIYKG.mjs +65 -0
- package/dist/lib/browser/react-surface-FRQIIYKG.mjs.map +7 -0
- package/dist/lib/browser/settings-S4MGGM4D.mjs +24 -0
- package/dist/lib/browser/settings-S4MGGM4D.mjs.map +7 -0
- package/dist/lib/browser/types.mjs +6 -4
- package/dist/lib/node/{AutomationPanel-5CJEF4MI.cjs → AutomationPanel-6QSV7ZYK.cjs} +8 -8
- package/dist/lib/node/ScriptContainer-DOAQ6KOE.cjs +689 -0
- package/dist/lib/node/ScriptContainer-DOAQ6KOE.cjs.map +7 -0
- package/dist/lib/node/chunk-63C2KSD6.cjs +252 -0
- package/dist/lib/node/chunk-63C2KSD6.cjs.map +7 -0
- package/dist/lib/node/{chunk-PK3OQP5L.cjs → chunk-6M2VRFBC.cjs} +26 -11
- package/dist/lib/node/chunk-6M2VRFBC.cjs.map +7 -0
- package/dist/lib/node/{chunk-4INUJLXL.cjs → chunk-CZVVFUVL.cjs} +6 -6
- package/dist/lib/node/{chunk-6LYX73ZT.cjs → chunk-HU2JXUXI.cjs} +11 -8
- package/dist/lib/node/chunk-HU2JXUXI.cjs.map +7 -0
- package/dist/lib/node/{meta.cjs → chunk-RZHY5LAR.cjs} +12 -8
- package/dist/lib/node/chunk-RZHY5LAR.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-Q3EXWKV5.cjs +104 -0
- package/dist/lib/node/compiler-Q3EXWKV5.cjs.map +7 -0
- package/dist/lib/node/index.cjs +105 -276
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/intent-resolver-7HI2CDGB.cjs +59 -0
- package/dist/lib/node/intent-resolver-7HI2CDGB.cjs.map +7 -0
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/react-surface-IKONODLG.cjs +84 -0
- package/dist/lib/node/react-surface-IKONODLG.cjs.map +7 -0
- package/dist/lib/node/settings-Q5XIA4LZ.cjs +38 -0
- package/dist/lib/node/settings-Q5XIA4LZ.cjs.map +7 -0
- package/dist/lib/node/types.cjs +6 -4
- package/dist/lib/node/types.cjs.map +2 -2
- package/dist/lib/node-esm/{AutomationPanel-7Y6REBNJ.mjs → AutomationPanel-EZQSGJLS.mjs} +3 -3
- package/dist/lib/node-esm/ScriptContainer-HE5QPPFZ.mjs +686 -0
- package/dist/lib/node-esm/ScriptContainer-HE5QPPFZ.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-3YOO5E2D.mjs +16 -0
- package/dist/lib/node-esm/chunk-3YOO5E2D.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-5D2AXTAW.mjs +41 -0
- package/dist/lib/node-esm/chunk-5D2AXTAW.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-OFYGBUNI.mjs → chunk-77LRZF2W.mjs} +2 -2
- package/dist/lib/node-esm/{chunk-SLTZMY34.mjs → chunk-EOBGHKNT.mjs} +7 -4
- package/dist/lib/node-esm/chunk-EOBGHKNT.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-JJZYWSD7.mjs +54 -0
- package/dist/lib/node-esm/chunk-JJZYWSD7.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-UWHMEJYW.mjs +225 -0
- package/dist/lib/node-esm/chunk-UWHMEJYW.mjs.map +7 -0
- package/dist/lib/node-esm/compiler-KJEIPDZ6.mjs +85 -0
- package/dist/lib/node-esm/compiler-KJEIPDZ6.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +112 -288
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/intent-resolver-KG7I6JJA.mjs +46 -0
- package/dist/lib/node-esm/intent-resolver-KG7I6JJA.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/react-surface-YA7WIRAM.mjs +66 -0
- package/dist/lib/node-esm/react-surface-YA7WIRAM.mjs.map +7 -0
- package/dist/lib/node-esm/settings-NZXHNIQ3.mjs +25 -0
- package/dist/lib/node-esm/settings-NZXHNIQ3.mjs.map +7 -0
- package/dist/lib/node-esm/types.mjs +6 -4
- 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/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.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 +2 -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 +91 -0
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types.d.ts +14 -6
- package/dist/types/src/types.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +45 -46
- package/src/ScriptPlugin.tsx +55 -91
- 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 +46 -0
- package/src/capabilities/react-surface.tsx +53 -0
- package/src/capabilities/settings.ts +14 -0
- package/src/components/ScriptContainer.tsx +64 -9
- package/src/components/ScriptSettings/ScriptSettings.tsx +28 -4
- package/src/components/ScriptSettingsPanel.tsx +124 -50
- 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 +3 -2
- package/src/templates/email.ts +26 -23
- package/src/{templates.ts → templates/index.ts} +5 -5
- package/src/translations.ts +21 -0
- package/src/types.ts +19 -18
- package/dist/lib/browser/ScriptContainer-GDVBWFI7.mjs +0 -415
- package/dist/lib/browser/ScriptContainer-GDVBWFI7.mjs.map +0 -7
- package/dist/lib/browser/chunk-C7VBULMK.mjs +0 -18
- package/dist/lib/browser/chunk-C7VBULMK.mjs.map +0 -7
- package/dist/lib/browser/chunk-RQA3EB5K.mjs +0 -26
- package/dist/lib/browser/chunk-RQA3EB5K.mjs.map +0 -7
- package/dist/lib/browser/meta.mjs +0 -9
- package/dist/lib/browser/meta.mjs.map +0 -7
- package/dist/lib/node/ScriptContainer-YWXXNLG6.cjs +0 -426
- package/dist/lib/node/ScriptContainer-YWXXNLG6.cjs.map +0 -7
- package/dist/lib/node/chunk-6LYX73ZT.cjs.map +0 -7
- package/dist/lib/node/chunk-PK3OQP5L.cjs.map +0 -7
- package/dist/lib/node/chunk-WPP65EYS.cjs.map +0 -7
- package/dist/lib/node/meta.cjs.map +0 -7
- package/dist/lib/node-esm/ScriptContainer-BG2PHKEH.mjs +0 -416
- package/dist/lib/node-esm/ScriptContainer-BG2PHKEH.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-H6BBLQ5Q.mjs +0 -27
- package/dist/lib/node-esm/chunk-H6BBLQ5Q.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-SLTZMY34.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/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/templates.d.ts.map +0 -1
- package/src/components/ScriptBlock/ScriptBlock.stories.tsx +0 -55
- package/src/components/ScriptBlock/ScriptBlock.tsx +0 -102
- package/src/components/ScriptBlock/index.ts +0 -5
- package/src/components/ScriptEditor.tsx +0 -193
- package/src/components/Toolbar/Toolbar.tsx +0 -177
- /package/dist/lib/browser/{AutomationPanel-RFQAQ7NF.mjs.map → AutomationPanel-KZVZMZE6.mjs.map} +0 -0
- /package/dist/lib/browser/{chunk-K7KY6YMG.mjs.map → chunk-Y4CVWFVS.mjs.map} +0 -0
- /package/dist/lib/node/{AutomationPanel-5CJEF4MI.cjs.map → AutomationPanel-6QSV7ZYK.cjs.map} +0 -0
- /package/dist/lib/node/{chunk-4INUJLXL.cjs.map → chunk-CZVVFUVL.cjs.map} +0 -0
- /package/dist/lib/node-esm/{AutomationPanel-7Y6REBNJ.mjs.map → AutomationPanel-EZQSGJLS.mjs.map} +0 -0
- /package/dist/lib/node-esm/{chunk-OFYGBUNI.mjs.map → chunk-77LRZF2W.mjs.map} +0 -0
|
@@ -1,202 +1,46 @@
|
|
|
1
1
|
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
|
-
import {
|
|
3
|
-
ScriptAction
|
|
4
|
-
} from "./chunk-H6BBLQ5Q.mjs";
|
|
5
2
|
import {
|
|
6
3
|
Bundler,
|
|
7
|
-
initializeBundler
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
initializeBundler
|
|
5
|
+
} from "./chunk-G76M6O46.mjs";
|
|
6
|
+
import {
|
|
7
|
+
AutomationPanel,
|
|
8
|
+
ScriptContainer,
|
|
9
|
+
ScriptSettings,
|
|
10
|
+
ScriptSettingsPanel
|
|
11
|
+
} from "./chunk-UWHMEJYW.mjs";
|
|
12
|
+
import {
|
|
13
|
+
ScriptCapabilities
|
|
14
|
+
} from "./chunk-3YOO5E2D.mjs";
|
|
15
|
+
import {
|
|
16
|
+
ScriptAction
|
|
17
|
+
} from "./chunk-5D2AXTAW.mjs";
|
|
10
18
|
import {
|
|
11
19
|
SCRIPT_PLUGIN,
|
|
12
|
-
|
|
13
|
-
} from "./chunk-
|
|
20
|
+
meta
|
|
21
|
+
} from "./chunk-EOBGHKNT.mjs";
|
|
14
22
|
|
|
15
|
-
// packages/plugins/experimental/plugin-script/src/
|
|
16
|
-
import
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
import { TextType } from "@dxos/plugin-markdown/types";
|
|
22
|
-
|
|
23
|
-
// packages/plugins/experimental/plugin-script/src/compiler/compiler.ts
|
|
24
|
-
import { createDefaultMapFromCDN, createSystem, createVirtualTypeScriptEnvironment } from "@typescript/vfs";
|
|
25
|
-
import ts from "typescript";
|
|
26
|
-
import { invariant } from "@dxos/invariant";
|
|
27
|
-
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/experimental/plugin-script/src/compiler/compiler.ts";
|
|
28
|
-
var defaultOptions = {
|
|
29
|
-
lib: [
|
|
30
|
-
"DOM",
|
|
31
|
-
"es2022"
|
|
32
|
-
],
|
|
33
|
-
target: ts.ScriptTarget.ES2022
|
|
34
|
-
};
|
|
35
|
-
var Compiler = class {
|
|
36
|
-
constructor(_options = defaultOptions) {
|
|
37
|
-
this._options = _options;
|
|
38
|
-
}
|
|
39
|
-
async initialize() {
|
|
40
|
-
if (this._env) {
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
this._fsMap = await createDefaultMapFromCDN(this._options, "5.5.4", true, ts);
|
|
44
|
-
const system = createSystem(this._fsMap);
|
|
45
|
-
this._env = createVirtualTypeScriptEnvironment(system, [], ts, this._options);
|
|
46
|
-
}
|
|
47
|
-
get environment() {
|
|
48
|
-
invariant(this._env, "Compiler environment not initialized.", {
|
|
49
|
-
F: __dxlog_file,
|
|
50
|
-
L: 39,
|
|
51
|
-
S: this,
|
|
52
|
-
A: [
|
|
53
|
-
"this._env",
|
|
54
|
-
"'Compiler environment not initialized.'"
|
|
55
|
-
]
|
|
56
|
-
});
|
|
57
|
-
return this._env;
|
|
58
|
-
}
|
|
59
|
-
setFile(fileName, content) {
|
|
60
|
-
invariant(this._fsMap, "File system map not initialized.", {
|
|
61
|
-
F: __dxlog_file,
|
|
62
|
-
L: 44,
|
|
63
|
-
S: this,
|
|
64
|
-
A: [
|
|
65
|
-
"this._fsMap",
|
|
66
|
-
"'File system map not initialized.'"
|
|
67
|
-
]
|
|
68
|
-
});
|
|
69
|
-
this.environment.createFile(fileName, content);
|
|
70
|
-
}
|
|
71
|
-
compile(fileName) {
|
|
72
|
-
return this.environment.languageService.getEmitOutput(fileName);
|
|
73
|
-
}
|
|
74
|
-
};
|
|
23
|
+
// packages/plugins/experimental/plugin-script/src/capabilities/index.ts
|
|
24
|
+
import { lazy } from "@dxos/app-framework";
|
|
25
|
+
var Compiler = lazy(() => import("./compiler-KJEIPDZ6.mjs"));
|
|
26
|
+
var IntentResolver = lazy(() => import("./intent-resolver-KG7I6JJA.mjs"));
|
|
27
|
+
var ReactSurface = lazy(() => import("./react-surface-YA7WIRAM.mjs"));
|
|
28
|
+
var ScriptSettings2 = lazy(() => import("./settings-NZXHNIQ3.mjs"));
|
|
75
29
|
|
|
76
|
-
// packages/plugins/experimental/plugin-script/src/
|
|
77
|
-
import {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
import
|
|
81
|
-
import { useClient } from "@dxos/react-client";
|
|
82
|
-
import { Button, useTranslation } from "@dxos/react-ui";
|
|
83
|
-
import { DeprecatedFormInput } from "@dxos/react-ui-form";
|
|
84
|
-
var ScriptSettings = ({ settings }) => {
|
|
85
|
-
const { t } = useTranslation(SCRIPT_PLUGIN);
|
|
86
|
-
const client = useClient();
|
|
87
|
-
const handleAuthenticate = async () => {
|
|
88
|
-
const { identityKey } = client.halo.identity.get();
|
|
89
|
-
await client.halo.writeCredentials([
|
|
90
|
-
{
|
|
91
|
-
issuer: identityKey,
|
|
92
|
-
issuanceDate: /* @__PURE__ */ new Date(),
|
|
93
|
-
subject: {
|
|
94
|
-
id: identityKey,
|
|
95
|
-
assertion: {
|
|
96
|
-
"@type": "dxos.halo.credentials.ServiceAccess",
|
|
97
|
-
serverName: "hub.dxos.network",
|
|
98
|
-
serverKey: identityKey,
|
|
99
|
-
identityKey,
|
|
100
|
-
capabilities: [
|
|
101
|
-
"composer:beta"
|
|
102
|
-
]
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
]);
|
|
107
|
-
};
|
|
108
|
-
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(DeprecatedFormInput, {
|
|
109
|
-
label: t("authenticate action label")
|
|
110
|
-
}, /* @__PURE__ */ React.createElement(Button, {
|
|
111
|
-
onClick: handleAuthenticate
|
|
112
|
-
}, t("authenticate button label"))));
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
// packages/plugins/experimental/plugin-script/src/components/ScriptSettingsPanel.tsx
|
|
116
|
-
import React2, { useCallback } from "react";
|
|
117
|
-
import { FunctionType, getInvocationUrl, getUserFunctionUrlInMetadata } from "@dxos/functions";
|
|
118
|
-
import { useClient as useClient2 } from "@dxos/react-client";
|
|
119
|
-
import { Filter, getMeta, getSpace, useQuery } from "@dxos/react-client/echo";
|
|
120
|
-
import { Button as Button2, Icon, Input, useControlledValue, useTranslation as useTranslation2 } from "@dxos/react-ui";
|
|
121
|
-
var ScriptSettingsPanel = ({ script }) => {
|
|
122
|
-
const { t } = useTranslation2(SCRIPT_PLUGIN);
|
|
123
|
-
const client = useClient2();
|
|
124
|
-
const space = getSpace(script);
|
|
125
|
-
const [fn] = useQuery(space, Filter.schema(FunctionType, {
|
|
126
|
-
source: script
|
|
127
|
-
}));
|
|
128
|
-
const handleNameChange = useCallback((event) => {
|
|
129
|
-
script.name = event.target.value;
|
|
130
|
-
}, [
|
|
131
|
-
script
|
|
132
|
-
]);
|
|
133
|
-
const [binding, setBinding] = useControlledValue(fn?.binding ?? "");
|
|
134
|
-
const handleBindingChange = useCallback((event) => {
|
|
135
|
-
setBinding(event.target.value);
|
|
136
|
-
}, [
|
|
137
|
-
setBinding
|
|
138
|
-
]);
|
|
139
|
-
const handleBindingBlur = useCallback(() => {
|
|
140
|
-
fn.binding = binding;
|
|
141
|
-
}, [
|
|
142
|
-
fn,
|
|
143
|
-
binding
|
|
144
|
-
]);
|
|
145
|
-
const functionPath = fn && getUserFunctionUrlInMetadata(getMeta(fn));
|
|
146
|
-
const functionUrl = functionPath && getInvocationUrl(functionPath, client.config.values.runtime?.services?.edge?.url ?? "", {
|
|
147
|
-
spaceId: space?.id
|
|
148
|
-
});
|
|
149
|
-
const handleCopy = useCallback(() => functionUrl && navigator.clipboard.writeText(functionUrl), [
|
|
150
|
-
functionUrl
|
|
151
|
-
]);
|
|
152
|
-
return /* @__PURE__ */ React2.createElement("div", {
|
|
153
|
-
role: "form",
|
|
154
|
-
className: "flex flex-col w-full p-2 gap-4"
|
|
155
|
-
}, /* @__PURE__ */ React2.createElement(Input.Root, null, /* @__PURE__ */ React2.createElement("div", {
|
|
156
|
-
role: "none",
|
|
157
|
-
className: "flex flex-col gap-1"
|
|
158
|
-
}, /* @__PURE__ */ React2.createElement(Input.Label, null, t("name label")), /* @__PURE__ */ React2.createElement(Input.TextInput, {
|
|
159
|
-
placeholder: t("object title placeholder"),
|
|
160
|
-
value: script.name ?? "",
|
|
161
|
-
onChange: handleNameChange
|
|
162
|
-
}))), fn && /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement("hr", {
|
|
163
|
-
className: "border-separator"
|
|
164
|
-
}), /* @__PURE__ */ React2.createElement("h2", null, t("remote function settings heading")), /* @__PURE__ */ React2.createElement(Input.Root, null, /* @__PURE__ */ React2.createElement("div", {
|
|
165
|
-
role: "none",
|
|
166
|
-
className: "flex flex-col gap-1"
|
|
167
|
-
}, /* @__PURE__ */ React2.createElement(Input.Label, null, t("function url label")), /* @__PURE__ */ React2.createElement("div", {
|
|
168
|
-
role: "none",
|
|
169
|
-
className: "flex gap-1"
|
|
170
|
-
}, /* @__PURE__ */ React2.createElement(Input.TextInput, {
|
|
171
|
-
disabled: true,
|
|
172
|
-
value: functionUrl,
|
|
173
|
-
onChange: (event) => {
|
|
174
|
-
fn.name = event.target.value;
|
|
175
|
-
}
|
|
176
|
-
}), /* @__PURE__ */ React2.createElement(Button2, {
|
|
177
|
-
onClick: handleCopy
|
|
178
|
-
}, /* @__PURE__ */ React2.createElement(Icon, {
|
|
179
|
-
icon: "ph--copy--regular",
|
|
180
|
-
size: 4
|
|
181
|
-
}))))), /* @__PURE__ */ React2.createElement(Input.Root, null, /* @__PURE__ */ React2.createElement("div", {
|
|
182
|
-
role: "none",
|
|
183
|
-
className: "flex flex-col gap-1"
|
|
184
|
-
}, /* @__PURE__ */ React2.createElement(Input.Label, null, t("function binding label")), /* @__PURE__ */ React2.createElement(Input.TextInput, {
|
|
185
|
-
placeholder: t("function binding placeholder"),
|
|
186
|
-
value: binding,
|
|
187
|
-
onChange: handleBindingChange,
|
|
188
|
-
onBlur: handleBindingBlur
|
|
189
|
-
})))));
|
|
190
|
-
};
|
|
191
|
-
|
|
192
|
-
// packages/plugins/experimental/plugin-script/src/components/index.ts
|
|
193
|
-
var AutomationPanel = lazy(() => import("./AutomationPanel-7Y6REBNJ.mjs"));
|
|
194
|
-
var ScriptContainer = lazy(() => import("./ScriptContainer-BG2PHKEH.mjs"));
|
|
30
|
+
// packages/plugins/experimental/plugin-script/src/ScriptPlugin.tsx
|
|
31
|
+
import { Capabilities, contributes, createIntent, defineModule, definePlugin, Events } from "@dxos/app-framework";
|
|
32
|
+
import { FunctionType, ScriptType as ScriptType2 } from "@dxos/functions";
|
|
33
|
+
import { RefArray } from "@dxos/live-object";
|
|
34
|
+
import { ClientCapabilities, ClientEvents } from "@dxos/plugin-client";
|
|
195
35
|
|
|
196
36
|
// packages/plugins/experimental/plugin-script/src/translations.ts
|
|
37
|
+
import { ScriptType } from "@dxos/functions";
|
|
197
38
|
var translations_default = [
|
|
198
39
|
{
|
|
199
40
|
"en-US": {
|
|
41
|
+
[ScriptType.typename]: {
|
|
42
|
+
"typename label": "Script"
|
|
43
|
+
},
|
|
200
44
|
[SCRIPT_PLUGIN]: {
|
|
201
45
|
"plugin name": "Scripts",
|
|
202
46
|
"object title placeholder": "New script",
|
|
@@ -216,123 +60,103 @@ var translations_default = [
|
|
|
216
60
|
"remote function settings heading": "Remote Function",
|
|
217
61
|
"function url label": "Invocation URL",
|
|
218
62
|
"function binding label": "Function binding",
|
|
219
|
-
"function binding placeholder": "BINDING"
|
|
63
|
+
"function binding placeholder": "BINDING",
|
|
64
|
+
"script publish settings label": "Publishing",
|
|
65
|
+
"script publish settings description": "Scripts can be shared publicly as Github gists.",
|
|
66
|
+
"no github token label": "This space has no Github access token available.",
|
|
67
|
+
"open token manager label": "Open Token Manager",
|
|
68
|
+
"publish label": "Publish",
|
|
69
|
+
"publishing label": "Publishing",
|
|
70
|
+
"editor input mode label": "Editor input mode",
|
|
71
|
+
"select editor input mode placeholder": "Select editor input mode\u2026",
|
|
72
|
+
"settings editor input mode default label": "Default",
|
|
73
|
+
"settings editor input mode vim label": "Vim",
|
|
74
|
+
"settings editor input mode vscode label": "VS Code",
|
|
75
|
+
"view group label": "View",
|
|
76
|
+
"view editor label": "Editor",
|
|
77
|
+
"view split label": "Split",
|
|
78
|
+
"view debug label": "Debug",
|
|
79
|
+
"template select group label": "Select template"
|
|
220
80
|
}
|
|
221
81
|
}
|
|
222
82
|
}
|
|
223
83
|
];
|
|
224
84
|
|
|
225
85
|
// packages/plugins/experimental/plugin-script/src/ScriptPlugin.tsx
|
|
226
|
-
var ScriptPlugin = () =>
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
86
|
+
var ScriptPlugin = () => definePlugin(meta, [
|
|
87
|
+
defineModule({
|
|
88
|
+
id: `${meta.id}/module/settings`,
|
|
89
|
+
activatesOn: Events.SetupSettings,
|
|
90
|
+
activate: ScriptSettings2
|
|
91
|
+
}),
|
|
92
|
+
defineModule({
|
|
93
|
+
id: `${meta.id}/module/compiler`,
|
|
94
|
+
activatesOn: Events.Startup,
|
|
95
|
+
activate: Compiler
|
|
96
|
+
}),
|
|
97
|
+
defineModule({
|
|
98
|
+
id: `${meta.id}/module/translations`,
|
|
99
|
+
activatesOn: Events.SetupTranslations,
|
|
100
|
+
activate: () => contributes(Capabilities.Translations, translations_default)
|
|
101
|
+
}),
|
|
102
|
+
defineModule({
|
|
103
|
+
id: `${meta.id}/module/metadata`,
|
|
104
|
+
activatesOn: Events.SetupMetadata,
|
|
105
|
+
activate: () => contributes(Capabilities.Metadata, {
|
|
106
|
+
id: ScriptType2.typename,
|
|
244
107
|
metadata: {
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
icon: "ph--code--regular",
|
|
255
|
-
// TODO(wittjosiah): Move out of metadata.
|
|
256
|
-
loadReferences: async (script) => await RefArray.loadAll([
|
|
257
|
-
script.source
|
|
258
|
-
])
|
|
108
|
+
creationSchema: ScriptAction.CreateScriptSchema,
|
|
109
|
+
createObject: (props, { space }) => createIntent(ScriptAction.Create, {
|
|
110
|
+
...props,
|
|
111
|
+
space
|
|
112
|
+
}),
|
|
113
|
+
placeholder: [
|
|
114
|
+
"object title placeholder",
|
|
115
|
+
{
|
|
116
|
+
ns: SCRIPT_PLUGIN
|
|
259
117
|
}
|
|
260
|
-
}
|
|
261
|
-
},
|
|
262
|
-
translations: translations_default,
|
|
263
|
-
echo: {
|
|
264
|
-
schema: [
|
|
265
|
-
ScriptType
|
|
266
118
|
],
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
definitions: () => [
|
|
273
|
-
createSurface({
|
|
274
|
-
id: `${SCRIPT_PLUGIN}/settings`,
|
|
275
|
-
role: "settings",
|
|
276
|
-
filter: (data) => data.subject === SCRIPT_PLUGIN,
|
|
277
|
-
component: () => /* @__PURE__ */ React3.createElement(ScriptSettings, {
|
|
278
|
-
settings: {}
|
|
279
|
-
})
|
|
280
|
-
}),
|
|
281
|
-
createSurface({
|
|
282
|
-
id: `${SCRIPT_PLUGIN}/article`,
|
|
283
|
-
role: "article",
|
|
284
|
-
filter: (data) => data.subject instanceof ScriptType,
|
|
285
|
-
component: ({ data }) => /* @__PURE__ */ React3.createElement(ScriptContainer, {
|
|
286
|
-
script: data.subject,
|
|
287
|
-
env: compiler.environment
|
|
288
|
-
})
|
|
289
|
-
}),
|
|
290
|
-
createSurface({
|
|
291
|
-
id: `${SCRIPT_PLUGIN}/automation`,
|
|
292
|
-
role: "complementary--automation",
|
|
293
|
-
disposition: "hoist",
|
|
294
|
-
filter: (data) => data.subject instanceof ScriptType,
|
|
295
|
-
component: ({ data }) => /* @__PURE__ */ React3.createElement(AutomationPanel, {
|
|
296
|
-
subject: data.subject
|
|
297
|
-
})
|
|
298
|
-
}),
|
|
299
|
-
createSurface({
|
|
300
|
-
id: `${SCRIPT_PLUGIN}/settings-panel`,
|
|
301
|
-
role: "complementary--settings",
|
|
302
|
-
filter: (data) => data.subject instanceof ScriptType,
|
|
303
|
-
component: ({ data }) => /* @__PURE__ */ React3.createElement(ScriptSettingsPanel, {
|
|
304
|
-
script: data.subject
|
|
305
|
-
})
|
|
306
|
-
})
|
|
307
|
-
]
|
|
308
|
-
},
|
|
309
|
-
intent: {
|
|
310
|
-
resolvers: () => createResolver(ScriptAction.Create, ({ name }) => ({
|
|
311
|
-
data: {
|
|
312
|
-
object: create(ScriptType, {
|
|
313
|
-
source: makeRef(create(TextType, {
|
|
314
|
-
content: templates[0].source
|
|
315
|
-
}))
|
|
316
|
-
})
|
|
317
|
-
}
|
|
318
|
-
}))
|
|
119
|
+
icon: "ph--code--regular",
|
|
120
|
+
// TODO(wittjosiah): Move out of metadata.
|
|
121
|
+
loadReferences: async (script) => await RefArray.loadAll([
|
|
122
|
+
script.source
|
|
123
|
+
])
|
|
319
124
|
}
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
125
|
+
})
|
|
126
|
+
}),
|
|
127
|
+
defineModule({
|
|
128
|
+
id: `${meta.id}/module/schema`,
|
|
129
|
+
activatesOn: ClientEvents.SetupSchema,
|
|
130
|
+
activate: () => [
|
|
131
|
+
contributes(ClientCapabilities.SystemSchema, [
|
|
132
|
+
FunctionType
|
|
133
|
+
]),
|
|
134
|
+
contributes(ClientCapabilities.Schema, [
|
|
135
|
+
ScriptType2
|
|
136
|
+
])
|
|
137
|
+
]
|
|
138
|
+
}),
|
|
139
|
+
defineModule({
|
|
140
|
+
id: `${meta.id}/module/react-surface`,
|
|
141
|
+
activatesOn: Events.SetupSurfaces,
|
|
142
|
+
activate: ReactSurface
|
|
143
|
+
}),
|
|
144
|
+
defineModule({
|
|
145
|
+
id: `${meta.id}/module/intent-resolver`,
|
|
146
|
+
activatesOn: Events.SetupIntents,
|
|
147
|
+
activate: IntentResolver
|
|
148
|
+
})
|
|
149
|
+
]);
|
|
326
150
|
export {
|
|
327
151
|
AutomationPanel,
|
|
328
152
|
Bundler,
|
|
329
|
-
|
|
330
|
-
|
|
153
|
+
SCRIPT_PLUGIN,
|
|
154
|
+
ScriptCapabilities,
|
|
331
155
|
ScriptContainer,
|
|
332
156
|
ScriptPlugin,
|
|
333
157
|
ScriptSettings,
|
|
334
158
|
ScriptSettingsPanel,
|
|
335
|
-
|
|
336
|
-
|
|
159
|
+
initializeBundler,
|
|
160
|
+
meta
|
|
337
161
|
};
|
|
338
162
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../../src/
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\n// @ts-ignore\nimport wasmUrl from 'esbuild-wasm/esbuild.wasm?url';\nimport React from 'react';\n\nimport { createIntent, createResolver, createSurface, type PluginDefinition } from '@dxos/app-framework';\nimport { FunctionType, ScriptType } from '@dxos/functions';\nimport { create, makeRef, RefArray } from '@dxos/live-object';\nimport { TextType } from '@dxos/plugin-markdown/types';\n\nimport { initializeBundler } from './bundler';\nimport { Compiler } from './compiler';\nimport { AutomationPanel, ScriptContainer, ScriptSettings, ScriptSettingsPanel } from './components';\nimport meta, { SCRIPT_PLUGIN } from './meta';\nimport { templates } from './templates';\nimport translations from './translations';\nimport { ScriptAction, type ScriptPluginProvides } from './types';\n\nexport const ScriptPlugin = (): PluginDefinition<ScriptPluginProvides> => {\n const compiler = new Compiler();\n\n return {\n meta,\n initialize: async () => {\n await compiler.initialize();\n // TODO(wittjosiah): Fetch types for https modules.\n compiler.setFile('/src/typings.d.ts', \"declare module 'https://*';\");\n // TODO(wittjosiah): Proper function handler types.\n // TODO(wittjosiah): Remove.\n compiler.setFile(\n '/src/runtime.ts',\n `\n export const Filter: any = {};\n export type FunctionHandler = ({ event, context }: { event: any; context: any }) => Promise<Response>;\n export const functionHandler = (handler: FunctionHandler) => handler;\n `,\n );\n await initializeBundler({ wasmUrl });\n },\n provides: {\n settings: {},\n metadata: {\n records: {\n [ScriptType.typename]: {\n createObject: (props: { name?: string }) => createIntent(ScriptAction.Create, props),\n placeholder: ['object title placeholder', { ns: SCRIPT_PLUGIN }],\n icon: 'ph--code--regular',\n // TODO(wittjosiah): Move out of metadata.\n loadReferences: async (script: ScriptType) => await RefArray.loadAll([script.source]),\n },\n },\n },\n translations,\n echo: {\n schema: [ScriptType],\n system: [FunctionType],\n },\n surface: {\n definitions: () => [\n createSurface({\n id: `${SCRIPT_PLUGIN}/settings`,\n role: 'settings',\n filter: (data): data is any => data.subject === SCRIPT_PLUGIN,\n component: () => <ScriptSettings settings={{}} />,\n }),\n createSurface({\n id: `${SCRIPT_PLUGIN}/article`,\n role: 'article',\n filter: (data): data is { subject: ScriptType } => data.subject instanceof ScriptType,\n component: ({ data }) => <ScriptContainer script={data.subject} env={compiler.environment} />,\n }),\n createSurface({\n id: `${SCRIPT_PLUGIN}/automation`,\n role: 'complementary--automation',\n disposition: 'hoist',\n filter: (data): data is { subject: ScriptType } => data.subject instanceof ScriptType,\n component: ({ data }) => <AutomationPanel subject={data.subject} />,\n }),\n createSurface({\n id: `${SCRIPT_PLUGIN}/settings-panel`,\n role: 'complementary--settings',\n filter: (data): data is { subject: ScriptType } => data.subject instanceof ScriptType,\n component: ({ data }) => <ScriptSettingsPanel script={data.subject} />,\n }),\n ],\n },\n intent: {\n resolvers: () =>\n createResolver(ScriptAction.Create, ({ name }) => ({\n data: {\n object: create(ScriptType, {\n source: makeRef(\n create(TextType, {\n content: templates[0].source,\n }),\n ),\n }),\n },\n })),\n },\n },\n };\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport {\n createDefaultMapFromCDN,\n createSystem,\n createVirtualTypeScriptEnvironment,\n type VirtualTypeScriptEnvironment,\n} from '@typescript/vfs';\nimport ts from 'typescript';\n\nimport { invariant } from '@dxos/invariant';\n\nconst defaultOptions: ts.CompilerOptions = {\n lib: ['DOM', 'es2022'],\n target: ts.ScriptTarget.ES2022,\n};\n\nexport class Compiler {\n private _env: VirtualTypeScriptEnvironment | undefined;\n private _fsMap: Map<string, string> | undefined;\n\n constructor(private readonly _options: ts.CompilerOptions = defaultOptions) {}\n\n async initialize() {\n if (this._env) {\n return;\n }\n\n // TODO(wittjosiah): Figure out how to get workers working in plugin packages.\n // https://github.com/val-town/codemirror-ts?tab=readme-ov-file#setup-worker\n this._fsMap = await createDefaultMapFromCDN(this._options, '5.5.4', true, ts);\n const system = createSystem(this._fsMap);\n this._env = createVirtualTypeScriptEnvironment(system, [], ts, this._options);\n }\n\n get environment() {\n invariant(this._env, 'Compiler environment not initialized.');\n return this._env;\n }\n\n setFile(fileName: string, content: string) {\n invariant(this._fsMap, 'File system map not initialized.');\n this.environment.createFile(fileName, content);\n }\n\n compile(fileName: string) {\n return this.environment.languageService.getEmitOutput(fileName);\n }\n}\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { lazy } from 'react';\n\nexport * from './ScriptSettings';\nexport * from './ScriptSettingsPanel';\n\nexport const AutomationPanel = lazy(() => import('./AutomationPanel'));\nexport const ScriptContainer = lazy(() => import('./ScriptContainer'));\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport React from 'react';\n\nimport { type Credential } from '@dxos/protocols/proto/dxos/halo/credentials';\nimport { useClient } from '@dxos/react-client';\nimport { Button, useTranslation } from '@dxos/react-ui';\nimport { DeprecatedFormInput } from '@dxos/react-ui-form';\n\nimport { SCRIPT_PLUGIN } from '../../meta';\nimport { type ScriptSettingsProps } from '../../types';\n\nexport const ScriptSettings = ({ settings }: { settings: ScriptSettingsProps }) => {\n const { t } = useTranslation(SCRIPT_PLUGIN);\n const client = useClient();\n\n // TODO(burdon): Check token.\n const handleAuthenticate = async () => {\n const { identityKey } = client.halo.identity.get()!;\n await client.halo.writeCredentials([\n {\n issuer: identityKey,\n issuanceDate: new Date(),\n subject: {\n id: identityKey,\n assertion: {\n '@type': 'dxos.halo.credentials.ServiceAccess',\n serverName: 'hub.dxos.network',\n serverKey: identityKey,\n identityKey,\n capabilities: ['composer:beta'],\n },\n },\n } satisfies Credential,\n ]);\n };\n\n return (\n <>\n <DeprecatedFormInput label={t('authenticate action label')}>\n <Button onClick={handleAuthenticate}>{t('authenticate button label')}</Button>\n </DeprecatedFormInput>\n </>\n );\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport React, { type ChangeEvent, useCallback } from 'react';\n\nimport { FunctionType, type ScriptType, getInvocationUrl, getUserFunctionUrlInMetadata } from '@dxos/functions';\nimport { useClient } from '@dxos/react-client';\nimport { Filter, getMeta, getSpace, useQuery } from '@dxos/react-client/echo';\nimport { Button, Icon, Input, useControlledValue, useTranslation } from '@dxos/react-ui';\n\nimport { SCRIPT_PLUGIN } from '../meta';\n\nexport type ScriptSettingsPanelProps = {\n script: ScriptType;\n};\n\nexport const ScriptSettingsPanel = ({ script }: ScriptSettingsPanelProps) => {\n const { t } = useTranslation(SCRIPT_PLUGIN);\n const client = useClient();\n const space = getSpace(script);\n const [fn] = useQuery(space, Filter.schema(FunctionType, { source: script }));\n\n const handleNameChange = useCallback(\n (event: ChangeEvent<HTMLInputElement>) => {\n script.name = event.target.value;\n },\n [script],\n );\n\n const [binding, setBinding] = useControlledValue(fn?.binding ?? '');\n const handleBindingChange = useCallback(\n (event: ChangeEvent<HTMLInputElement>) => {\n setBinding(event.target.value);\n },\n [setBinding],\n );\n const handleBindingBlur = useCallback(() => {\n fn.binding = binding;\n }, [fn, binding]);\n\n const functionPath = fn && getUserFunctionUrlInMetadata(getMeta(fn));\n const functionUrl =\n functionPath &&\n getInvocationUrl(functionPath, client.config.values.runtime?.services?.edge?.url ?? '', {\n spaceId: space?.id,\n });\n\n // TODO(wittjosiah): Use ClipboardProvider.\n const handleCopy = useCallback(() => functionUrl && navigator.clipboard.writeText(functionUrl), [functionUrl]);\n\n return (\n <div role='form' className='flex flex-col w-full p-2 gap-4'>\n <Input.Root>\n <div role='none' className='flex flex-col gap-1'>\n <Input.Label>{t('name label')}</Input.Label>\n <Input.TextInput\n placeholder={t('object title placeholder')}\n value={script.name ?? ''}\n onChange={handleNameChange}\n />\n </div>\n </Input.Root>\n {fn && (\n <>\n <hr className='border-separator' />\n <h2>{t('remote function settings heading')}</h2>\n <Input.Root>\n <div role='none' className='flex flex-col gap-1'>\n <Input.Label>{t('function url label')}</Input.Label>\n <div role='none' className='flex gap-1'>\n <Input.TextInput\n disabled\n value={functionUrl}\n onChange={(event) => {\n fn.name = event.target.value;\n }}\n />\n <Button onClick={handleCopy}>\n <Icon icon='ph--copy--regular' size={4} />\n </Button>\n </div>\n </div>\n </Input.Root>\n <Input.Root>\n <div role='none' className='flex flex-col gap-1'>\n <Input.Label>{t('function binding label')}</Input.Label>\n <Input.TextInput\n placeholder={t('function binding placeholder')}\n value={binding}\n onChange={handleBindingChange}\n onBlur={handleBindingBlur}\n />\n </div>\n </Input.Root>\n </>\n )}\n </div>\n );\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { SCRIPT_PLUGIN } from './meta';\n\nexport default [\n {\n 'en-US': {\n [SCRIPT_PLUGIN]: {\n 'plugin name': 'Scripts',\n 'object title placeholder': 'New script',\n 'create object label': 'Create script',\n 'create stack section label': 'Create script',\n 'binding placeholder': 'Function name',\n 'function request placeholder': 'Function request',\n 'deploy label': 'Deploy',\n 'deployed label': 'Current version of the script is deployed',\n 'upload failed label': 'Upload failed',\n 'copy link label': 'Copy function link',\n 'format label': 'Format',\n 'toggle details label': 'Toggle details panel',\n 'authenticate action label': 'Authenticate functions service',\n 'authenticate button label': 'Authenticate',\n 'name label': 'Name',\n 'remote function settings heading': 'Remote Function',\n 'function url label': 'Invocation URL',\n 'function binding label': 'Function binding',\n 'function binding placeholder': 'BINDING',\n },\n },\n },\n];\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { ScriptPlugin } from './ScriptPlugin';\n\nexport default ScriptPlugin;\n\nexport * from './bundler';\nexport * from './compiler';\nexport * from './components';\nexport * from './types';\n\nexport * from './ScriptPlugin';\n"],
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["
|
|
3
|
+
"sources": ["../../../src/capabilities/index.ts", "../../../src/ScriptPlugin.tsx", "../../../src/translations.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { lazy } from '@dxos/app-framework';\n\nexport const Compiler = lazy(() => import('./compiler'));\nexport const IntentResolver = lazy(() => import('./intent-resolver'));\nexport const ReactSurface = lazy(() => import('./react-surface'));\nexport const ScriptSettings = lazy(() => import('./settings'));\n\nexport * from './capabilities';\n", "//\n// Copyright 2023 DXOS.org\n//\n\n// @ts-ignore\n\nimport { Capabilities, contributes, createIntent, defineModule, definePlugin, Events } from '@dxos/app-framework';\nimport { type Space } from '@dxos/client/echo';\nimport { FunctionType, ScriptType } from '@dxos/functions';\nimport { RefArray } from '@dxos/live-object';\nimport { ClientCapabilities, ClientEvents } from '@dxos/plugin-client';\n\nimport { Compiler, IntentResolver, ReactSurface, ScriptSettings } from './capabilities';\nimport { meta, SCRIPT_PLUGIN } from './meta';\nimport translations from './translations';\nimport { ScriptAction } from './types';\n\nexport const ScriptPlugin = () =>\n definePlugin(meta, [\n defineModule({\n id: `${meta.id}/module/settings`,\n activatesOn: Events.SetupSettings,\n activate: ScriptSettings,\n }),\n defineModule({\n id: `${meta.id}/module/compiler`,\n activatesOn: Events.Startup,\n activate: Compiler,\n }),\n defineModule({\n id: `${meta.id}/module/translations`,\n activatesOn: Events.SetupTranslations,\n activate: () => contributes(Capabilities.Translations, translations),\n }),\n defineModule({\n id: `${meta.id}/module/metadata`,\n activatesOn: Events.SetupMetadata,\n activate: () =>\n contributes(Capabilities.Metadata, {\n id: ScriptType.typename,\n metadata: {\n creationSchema: ScriptAction.CreateScriptSchema,\n createObject: (props: ScriptAction.CreateScriptProps, { space }: { space: Space }) =>\n createIntent(ScriptAction.Create, { ...props, space }),\n placeholder: ['object title placeholder', { ns: SCRIPT_PLUGIN }],\n icon: 'ph--code--regular',\n // TODO(wittjosiah): Move out of metadata.\n loadReferences: async (script: ScriptType) => await RefArray.loadAll([script.source]),\n },\n }),\n }),\n defineModule({\n id: `${meta.id}/module/schema`,\n activatesOn: ClientEvents.SetupSchema,\n activate: () => [\n contributes(ClientCapabilities.SystemSchema, [FunctionType]),\n contributes(ClientCapabilities.Schema, [ScriptType]),\n ],\n }),\n defineModule({\n id: `${meta.id}/module/react-surface`,\n activatesOn: Events.SetupSurfaces,\n activate: ReactSurface,\n }),\n defineModule({\n id: `${meta.id}/module/intent-resolver`,\n activatesOn: Events.SetupIntents,\n activate: IntentResolver,\n }),\n ]);\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { ScriptType } from '@dxos/functions';\n\nimport { SCRIPT_PLUGIN } from './meta';\n\nexport default [\n {\n 'en-US': {\n [ScriptType.typename]: {\n 'typename label': 'Script',\n },\n [SCRIPT_PLUGIN]: {\n 'plugin name': 'Scripts',\n 'object title placeholder': 'New script',\n 'create object label': 'Create script',\n 'create stack section label': 'Create script',\n 'binding placeholder': 'Function name',\n 'function request placeholder': 'Function request',\n 'deploy label': 'Deploy',\n 'deployed label': 'Current version of the script is deployed',\n 'upload failed label': 'Upload failed',\n 'copy link label': 'Copy function link',\n 'format label': 'Format',\n 'toggle details label': 'Toggle details panel',\n 'authenticate action label': 'Authenticate functions service',\n 'authenticate button label': 'Authenticate',\n 'name label': 'Name',\n 'remote function settings heading': 'Remote Function',\n 'function url label': 'Invocation URL',\n 'function binding label': 'Function binding',\n 'function binding placeholder': 'BINDING',\n 'script publish settings label': 'Publishing',\n 'script publish settings description': 'Scripts can be shared publicly as Github gists.',\n 'no github token label': 'This space has no Github access token available.',\n 'open token manager label': 'Open Token Manager',\n 'publish label': 'Publish',\n 'publishing label': 'Publishing',\n 'editor input mode label': 'Editor input mode',\n 'select editor input mode placeholder': 'Select editor input mode…',\n 'settings editor input mode default label': 'Default',\n 'settings editor input mode vim label': 'Vim',\n 'settings editor input mode vscode label': 'VS Code',\n 'view group label': 'View',\n 'view editor label': 'Editor',\n 'view split label': 'Split',\n 'view debug label': 'Debug',\n 'template select group label': 'Select template',\n },\n },\n },\n];\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAIA,SAASA,YAAY;AAEd,IAAMC,WAAWC,KAAK,MAAM,OAAO,yBAAA,CAAA;AACnC,IAAMC,iBAAiBD,KAAK,MAAM,OAAO,gCAAA,CAAA;AACzC,IAAME,eAAeF,KAAK,MAAM,OAAO,8BAAA,CAAA;AACvC,IAAMG,kBAAiBH,KAAK,MAAM,OAAO,yBAAA,CAAA;;;ACHhD,SAASI,cAAcC,aAAaC,cAAcC,cAAcC,cAAcC,cAAc;AAE5F,SAASC,cAAcC,cAAAA,mBAAkB;AACzC,SAASC,gBAAgB;AACzB,SAASC,oBAAoBC,oBAAoB;;;ACNjD,SAASC,kBAAkB;AAI3B,IAAA,uBAAe;EACb;IACE,SAAS;MACP,CAACC,WAAWC,QAAQ,GAAG;QACrB,kBAAkB;MACpB;MACA,CAACC,aAAAA,GAAgB;QACf,eAAe;QACf,4BAA4B;QAC5B,uBAAuB;QACvB,8BAA8B;QAC9B,uBAAuB;QACvB,gCAAgC;QAChC,gBAAgB;QAChB,kBAAkB;QAClB,uBAAuB;QACvB,mBAAmB;QACnB,gBAAgB;QAChB,wBAAwB;QACxB,6BAA6B;QAC7B,6BAA6B;QAC7B,cAAc;QACd,oCAAoC;QACpC,sBAAsB;QACtB,0BAA0B;QAC1B,gCAAgC;QAChC,iCAAiC;QACjC,uCAAuC;QACvC,yBAAyB;QACzB,4BAA4B;QAC5B,iBAAiB;QACjB,oBAAoB;QACpB,2BAA2B;QAC3B,wCAAwC;QACxC,4CAA4C;QAC5C,wCAAwC;QACxC,2CAA2C;QAC3C,oBAAoB;QACpB,qBAAqB;QACrB,oBAAoB;QACpB,oBAAoB;QACpB,+BAA+B;MACjC;IACF;EACF;;;;ADnCK,IAAMC,eAAe,MAC1BC,aAAaC,MAAM;EACjBC,aAAa;IACXC,IAAI,GAAGF,KAAKE,EAAE;IACdC,aAAaC,OAAOC;IACpBC,UAAUC;EACZ,CAAA;EACAN,aAAa;IACXC,IAAI,GAAGF,KAAKE,EAAE;IACdC,aAAaC,OAAOI;IACpBF,UAAUG;EACZ,CAAA;EACAR,aAAa;IACXC,IAAI,GAAGF,KAAKE,EAAE;IACdC,aAAaC,OAAOM;IACpBJ,UAAU,MAAMK,YAAYC,aAAaC,cAAcC,oBAAAA;EACzD,CAAA;EACAb,aAAa;IACXC,IAAI,GAAGF,KAAKE,EAAE;IACdC,aAAaC,OAAOW;IACpBT,UAAU,MACRK,YAAYC,aAAaI,UAAU;MACjCd,IAAIe,YAAWC;MACfC,UAAU;QACRC,gBAAgBC,aAAaC;QAC7BC,cAAc,CAACC,OAAuC,EAAEC,MAAK,MAC3DC,aAAaL,aAAaM,QAAQ;UAAE,GAAGH;UAAOC;QAAM,CAAA;QACtDG,aAAa;UAAC;UAA4B;YAAEC,IAAIC;UAAc;;QAC9DC,MAAM;;QAENC,gBAAgB,OAAOC,WAAuB,MAAMC,SAASC,QAAQ;UAACF,OAAOG;SAAO;MACtF;IACF,CAAA;EACJ,CAAA;EACAnC,aAAa;IACXC,IAAI,GAAGF,KAAKE,EAAE;IACdC,aAAakC,aAAaC;IAC1BhC,UAAU,MAAM;MACdK,YAAY4B,mBAAmBC,cAAc;QAACC;OAAa;MAC3D9B,YAAY4B,mBAAmBG,QAAQ;QAACzB;OAAW;;EAEvD,CAAA;EACAhB,aAAa;IACXC,IAAI,GAAGF,KAAKE,EAAE;IACdC,aAAaC,OAAOuC;IACpBrC,UAAUsC;EACZ,CAAA;EACA3C,aAAa;IACXC,IAAI,GAAGF,KAAKE,EAAE;IACdC,aAAaC,OAAOyC;IACpBvC,UAAUwC;EACZ,CAAA;CACD;",
|
|
6
|
+
"names": ["lazy", "Compiler", "lazy", "IntentResolver", "ReactSurface", "ScriptSettings", "Capabilities", "contributes", "createIntent", "defineModule", "definePlugin", "Events", "FunctionType", "ScriptType", "RefArray", "ClientCapabilities", "ClientEvents", "ScriptType", "ScriptType", "typename", "SCRIPT_PLUGIN", "ScriptPlugin", "definePlugin", "meta", "defineModule", "id", "activatesOn", "Events", "SetupSettings", "activate", "ScriptSettings", "Startup", "Compiler", "SetupTranslations", "contributes", "Capabilities", "Translations", "translations", "SetupMetadata", "Metadata", "ScriptType", "typename", "metadata", "creationSchema", "ScriptAction", "CreateScriptSchema", "createObject", "props", "space", "createIntent", "Create", "placeholder", "ns", "SCRIPT_PLUGIN", "icon", "loadReferences", "script", "RefArray", "loadAll", "source", "ClientEvents", "SetupSchema", "ClientCapabilities", "SystemSchema", "FunctionType", "Schema", "SetupSurfaces", "ReactSurface", "SetupIntents", "IntentResolver"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
templates
|
|
4
|
+
} from "./chunk-JJZYWSD7.mjs";
|
|
5
|
+
import {
|
|
6
|
+
ScriptAction
|
|
7
|
+
} from "./chunk-5D2AXTAW.mjs";
|
|
8
|
+
import "./chunk-EOBGHKNT.mjs";
|
|
9
|
+
|
|
10
|
+
// packages/plugins/experimental/plugin-script/src/capabilities/intent-resolver.ts
|
|
11
|
+
import { Octokit } from "@octokit/core";
|
|
12
|
+
import { contributes, Capabilities, createResolver } from "@dxos/app-framework";
|
|
13
|
+
import { ScriptType } from "@dxos/functions";
|
|
14
|
+
import { create, makeRef } from "@dxos/live-object";
|
|
15
|
+
import { TextType } from "@dxos/schema";
|
|
16
|
+
var intent_resolver_default = () => contributes(Capabilities.IntentResolver, createResolver({
|
|
17
|
+
intent: ScriptAction.Create,
|
|
18
|
+
resolve: async ({ name, gistUrl }) => {
|
|
19
|
+
let content = templates[0].source;
|
|
20
|
+
const gistId = gistUrl?.split("/").at(-1);
|
|
21
|
+
if (gistId) {
|
|
22
|
+
const octokit = new Octokit();
|
|
23
|
+
const response = await octokit.request("GET /gists/{gist_id}", {
|
|
24
|
+
gist_id: gistId
|
|
25
|
+
});
|
|
26
|
+
const gistContent = Object.values(response.data.files ?? {})[0]?.content;
|
|
27
|
+
if (gistContent) {
|
|
28
|
+
content = gistContent;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return {
|
|
32
|
+
data: {
|
|
33
|
+
object: create(ScriptType, {
|
|
34
|
+
name,
|
|
35
|
+
source: makeRef(create(TextType, {
|
|
36
|
+
content
|
|
37
|
+
}))
|
|
38
|
+
})
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
}));
|
|
43
|
+
export {
|
|
44
|
+
intent_resolver_default as default
|
|
45
|
+
};
|
|
46
|
+
//# sourceMappingURL=intent-resolver-KG7I6JJA.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/capabilities/intent-resolver.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { Octokit } from '@octokit/core';\n\nimport { contributes, Capabilities, createResolver } from '@dxos/app-framework';\nimport { ScriptType } from '@dxos/functions';\nimport { create, makeRef } from '@dxos/live-object';\nimport { TextType } from '@dxos/schema';\n\nimport { templates } from '../templates';\nimport { ScriptAction } from '../types';\n\nexport default () =>\n contributes(\n Capabilities.IntentResolver,\n createResolver({\n intent: ScriptAction.Create,\n resolve: async ({ name, gistUrl }) => {\n let content = templates[0].source;\n const gistId = gistUrl?.split('/').at(-1);\n if (gistId) {\n // TODO(wittjosiah): Capability which contributes Octokit?\n // NOTE: AccessToken not needed to read public gists.\n const octokit = new Octokit();\n const response = await octokit.request('GET /gists/{gist_id}', {\n gist_id: gistId,\n });\n const gistContent = Object.values(response.data.files ?? {})[0]?.content;\n if (gistContent) {\n content = gistContent;\n }\n }\n\n return {\n data: {\n object: create(ScriptType, {\n name,\n source: makeRef(create(TextType, { content })),\n }),\n },\n };\n },\n }),\n );\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;AAIA,SAASA,eAAe;AAExB,SAASC,aAAaC,cAAcC,sBAAsB;AAC1D,SAASC,kBAAkB;AAC3B,SAASC,QAAQC,eAAe;AAChC,SAASC,gBAAgB;AAKzB,IAAA,0BAAe,MACbC,YACEC,aAAaC,gBACbC,eAAe;EACbC,QAAQC,aAAaC;EACrBC,SAAS,OAAO,EAAEC,MAAMC,QAAO,MAAE;AAC/B,QAAIC,UAAUC,UAAU,CAAA,EAAGC;AAC3B,UAAMC,SAASJ,SAASK,MAAM,GAAA,EAAKC,GAAG,EAAC;AACvC,QAAIF,QAAQ;AAGV,YAAMG,UAAU,IAAIC,QAAAA;AACpB,YAAMC,WAAW,MAAMF,QAAQG,QAAQ,wBAAwB;QAC7DC,SAASP;MACX,CAAA;AACA,YAAMQ,cAAcC,OAAOC,OAAOL,SAASM,KAAKC,SAAS,CAAC,CAAA,EAAG,CAAA,GAAIf;AACjE,UAAIW,aAAa;AACfX,kBAAUW;MACZ;IACF;AAEA,WAAO;MACLG,MAAM;QACJE,QAAQC,OAAOC,YAAY;UACzBpB;UACAI,QAAQiB,QAAQF,OAAOG,UAAU;YAAEpB;UAAQ,CAAA,CAAA;QAC7C,CAAA;MACF;IACF;EACF;AACF,CAAA,CAAA;",
|
|
6
|
+
"names": ["Octokit", "contributes", "Capabilities", "createResolver", "ScriptType", "create", "makeRef", "TextType", "contributes", "Capabilities", "IntentResolver", "createResolver", "intent", "ScriptAction", "Create", "resolve", "name", "gistUrl", "content", "templates", "source", "gistId", "split", "at", "octokit", "Octokit", "response", "request", "gist_id", "gistContent", "Object", "values", "data", "files", "object", "create", "ScriptType", "makeRef", "TextType"]
|
|
7
|
+
}
|