@dxos/plugin-script 0.7.5-main.9d26e3a → 0.7.5-main.b19bfc8
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-6HFRNRWV.mjs} +3 -3
- package/dist/lib/browser/ScriptContainer-U3BFT76B.mjs +713 -0
- package/dist/lib/browser/ScriptContainer-U3BFT76B.mjs.map +7 -0
- package/dist/lib/browser/artifact-definition-NAWYXFF5.mjs +243 -0
- package/dist/lib/browser/artifact-definition-NAWYXFF5.mjs.map +7 -0
- package/dist/lib/browser/{chunk-K7KY6YMG.mjs → chunk-5SXOHNAK.mjs} +4 -4
- package/dist/lib/browser/chunk-5SXOHNAK.mjs.map +7 -0
- package/dist/lib/browser/chunk-6MOQ4BP3.mjs +15 -0
- package/dist/lib/browser/chunk-6MOQ4BP3.mjs.map +7 -0
- package/dist/lib/browser/chunk-FVVCAWNP.mjs +21 -0
- package/dist/lib/browser/chunk-FVVCAWNP.mjs.map +7 -0
- package/dist/lib/browser/chunk-HJNS3BBK.mjs +236 -0
- package/dist/lib/browser/chunk-HJNS3BBK.mjs.map +7 -0
- package/dist/lib/browser/chunk-N46LE7FS.mjs +40 -0
- package/dist/lib/browser/chunk-N46LE7FS.mjs.map +7 -0
- package/dist/lib/browser/chunk-PZPYF7M4.mjs +69 -0
- package/dist/lib/browser/chunk-PZPYF7M4.mjs.map +7 -0
- package/dist/lib/browser/compiler-YY2XSKHQ.mjs +82 -0
- package/dist/lib/browser/compiler-YY2XSKHQ.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +129 -288
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/intent-resolver-D6FPY5ZA.mjs +45 -0
- package/dist/lib/browser/intent-resolver-D6FPY5ZA.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/react-surface-DIXYM2HA.mjs +65 -0
- package/dist/lib/browser/react-surface-DIXYM2HA.mjs.map +7 -0
- package/dist/lib/browser/settings-SZCDKHWO.mjs +24 -0
- package/dist/lib/browser/settings-SZCDKHWO.mjs.map +7 -0
- package/dist/lib/browser/types.mjs +6 -4
- package/dist/lib/node/{AutomationPanel-5CJEF4MI.cjs → AutomationPanel-RBQ4DODN.cjs} +8 -8
- package/dist/lib/node/ScriptContainer-PSLB34RX.cjs +719 -0
- package/dist/lib/node/ScriptContainer-PSLB34RX.cjs.map +7 -0
- package/dist/lib/node/artifact-definition-7AANUS3X.cjs +262 -0
- package/dist/lib/node/artifact-definition-7AANUS3X.cjs.map +7 -0
- package/dist/lib/node/chunk-2UNNYU2C.cjs +264 -0
- package/dist/lib/node/chunk-2UNNYU2C.cjs.map +7 -0
- package/dist/lib/node/{chunk-6LYX73ZT.cjs → chunk-5UH3F7TA.cjs} +11 -8
- package/dist/lib/node/chunk-5UH3F7TA.cjs.map +7 -0
- package/dist/lib/node/{meta.cjs → chunk-ALY3N6PW.cjs} +12 -8
- package/dist/lib/node/chunk-ALY3N6PW.cjs.map +7 -0
- package/dist/lib/node/{chunk-PK3OQP5L.cjs → chunk-DJGLGRQV.cjs} +26 -11
- package/dist/lib/node/chunk-DJGLGRQV.cjs.map +7 -0
- package/dist/lib/node/chunk-ITAJ3WRW.cjs +77 -0
- package/dist/lib/node/chunk-ITAJ3WRW.cjs.map +7 -0
- package/dist/lib/node/{chunk-4INUJLXL.cjs → chunk-K3ZZWVXS.cjs} +7 -7
- package/dist/lib/node/chunk-K3ZZWVXS.cjs.map +7 -0
- package/dist/lib/node/compiler-UIBLKJKG.cjs +104 -0
- package/dist/lib/node/compiler-UIBLKJKG.cjs.map +7 -0
- package/dist/lib/node/index.cjs +122 -277
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/intent-resolver-NYJFPD5B.cjs +59 -0
- package/dist/lib/node/intent-resolver-NYJFPD5B.cjs.map +7 -0
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/react-surface-JOMWTFI2.cjs +84 -0
- package/dist/lib/node/react-surface-JOMWTFI2.cjs.map +7 -0
- package/dist/lib/node/settings-SZFSMSKM.cjs +38 -0
- package/dist/lib/node/settings-SZFSMSKM.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-WTVVVMRH.mjs} +3 -3
- package/dist/lib/node-esm/ScriptContainer-E4J6XXE6.mjs +714 -0
- package/dist/lib/node-esm/ScriptContainer-E4J6XXE6.mjs.map +7 -0
- package/dist/lib/node-esm/artifact-definition-KBASPVMM.mjs +245 -0
- package/dist/lib/node-esm/artifact-definition-KBASPVMM.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-OFYGBUNI.mjs → chunk-2AFXX34U.mjs} +4 -4
- package/dist/lib/node-esm/chunk-2AFXX34U.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-4OCRARHP.mjs +237 -0
- package/dist/lib/node-esm/chunk-4OCRARHP.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-CP5LXTK5.mjs +16 -0
- package/dist/lib/node-esm/chunk-CP5LXTK5.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-SLTZMY34.mjs → chunk-P2V2Y5LV.mjs} +7 -4
- package/dist/lib/node-esm/chunk-P2V2Y5LV.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-UNQFIERE.mjs +41 -0
- package/dist/lib/node-esm/chunk-UNQFIERE.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-YIWRJ25J.mjs +71 -0
- package/dist/lib/node-esm/chunk-YIWRJ25J.mjs.map +7 -0
- package/dist/lib/node-esm/compiler-XTXFGZJM.mjs +83 -0
- package/dist/lib/node-esm/compiler-XTXFGZJM.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +129 -288
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/intent-resolver-KLBHSMW4.mjs +46 -0
- package/dist/lib/node-esm/intent-resolver-KLBHSMW4.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/react-surface-OLH7N3DK.mjs +66 -0
- package/dist/lib/node-esm/react-surface-OLH7N3DK.mjs.map +7 -0
- package/dist/lib/node-esm/settings-GR4O2WHZ.mjs +25 -0
- package/dist/lib/node-esm/settings-GR4O2WHZ.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/artifact-definition.d.ts +11 -0
- package/dist/types/src/capabilities/artifact-definition.d.ts.map +1 -0
- 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 +7 -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 +1 -2
- package/dist/types/src/components/AutomationPanel/AutomationPanel.d.ts.map +1 -1
- package/dist/types/src/components/DebugPanel/DebugPanel.d.ts +1 -2
- package/dist/types/src/components/DebugPanel/DebugPanel.d.ts.map +1 -1
- package/dist/types/src/components/FrameContainer/FrameContainer.d.ts +3 -4
- package/dist/types/src/components/FrameContainer/FrameContainer.d.ts.map +1 -1
- package/dist/types/src/components/ScriptContainer.d.ts +10 -3
- package/dist/types/src/components/ScriptContainer.d.ts.map +1 -1
- package/dist/types/src/components/ScriptSettings/ScriptSettings.d.ts +1 -2
- package/dist/types/src/components/ScriptSettings/ScriptSettings.d.ts.map +1 -1
- package/dist/types/src/components/ScriptSettingsPanel.d.ts +1 -2
- package/dist/types/src/components/ScriptSettingsPanel.d.ts.map +1 -1
- package/dist/types/src/components/ScriptToolbar/ScriptToolbar.d.ts +10 -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/index.d.ts +2 -0
- package/dist/types/src/components/ScriptToolbar/index.d.ts.map +1 -0
- package/dist/types/src/components/TypescriptEditor/TypescriptEditor.d.ts +4 -3
- 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 +2 -2
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/events.d.ts +4 -0
- package/dist/types/src/events.d.ts.map +1 -0
- package/dist/types/src/hooks/deploy.d.ts +48 -0
- package/dist/types/src/hooks/deploy.d.ts.map +1 -0
- package/dist/types/src/hooks/format.d.ts +25 -0
- package/dist/types/src/hooks/format.d.ts.map +1 -0
- package/dist/types/src/hooks/index.d.ts +7 -0
- package/dist/types/src/hooks/index.d.ts.map +1 -0
- package/dist/types/src/hooks/template.d.ts +31 -0
- package/dist/types/src/hooks/template.d.ts.map +1 -0
- package/dist/types/src/hooks/useToolbarAction.d.ts +14 -0
- package/dist/types/src/hooks/useToolbarAction.d.ts.map +1 -0
- package/dist/types/src/hooks/useToolbarState.d.ts +10 -0
- package/dist/types/src/hooks/useToolbarState.d.ts.map +1 -0
- package/dist/types/src/hooks/view.d.ts +33 -0
- package/dist/types/src/hooks/view.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +2 -5
- 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/chess.d.ts +1 -4
- package/dist/types/src/templates/chess.d.ts.map +1 -1
- package/dist/types/src/templates/discord.d.ts +3 -0
- package/dist/types/src/templates/discord.d.ts.map +1 -0
- package/dist/types/src/templates/echo.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/forex-effect.d.ts +3 -0
- package/dist/types/src/templates/forex-effect.d.ts.map +1 -0
- package/dist/types/src/templates/forex.d.ts +1 -4
- package/dist/types/src/templates/forex.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 +97 -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 +70 -90
- package/src/capabilities/artifact-definition.ts +219 -0
- package/src/capabilities/capabilities.ts +12 -0
- package/src/capabilities/compiler.ts +33 -0
- package/src/capabilities/index.ts +13 -0
- package/src/capabilities/intent-resolver.ts +46 -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/DebugPanel/DebugPanel.tsx +2 -2
- package/src/components/FrameContainer/FrameContainer.tsx +5 -4
- package/src/components/ScriptContainer.tsx +69 -9
- package/src/components/ScriptSettings/ScriptSettings.tsx +28 -4
- package/src/components/ScriptSettingsPanel.tsx +139 -51
- package/src/components/{Toolbar/Toolbar.stories.tsx → ScriptToolbar/ScriptToolbar.stories.tsx} +2 -2
- package/src/components/ScriptToolbar/ScriptToolbar.tsx +53 -0
- package/src/{bundler → components/ScriptToolbar}/index.ts +1 -1
- package/src/components/TypescriptEditor/TypescriptEditor.stories.tsx +2 -0
- package/src/components/TypescriptEditor/TypescriptEditor.tsx +75 -10
- package/src/events.ts +11 -0
- package/src/hooks/deploy.ts +169 -0
- package/src/hooks/format.ts +47 -0
- package/src/hooks/index.ts +11 -0
- package/src/hooks/template.ts +64 -0
- package/src/hooks/useToolbarAction.ts +54 -0
- package/src/hooks/useToolbarState.ts +16 -0
- package/src/hooks/view.ts +52 -0
- package/src/index.ts +2 -7
- package/src/meta.ts +4 -2
- package/src/templates/chat.ts +4 -4
- package/src/templates/chess.ts +42 -35
- package/src/templates/discord.ts +103 -0
- package/src/templates/echo.ts +5 -1
- package/src/templates/email.ts +26 -23
- package/src/templates/forex-effect.ts +41 -0
- package/src/templates/forex.ts +23 -16
- package/src/{templates.ts → templates/index.ts} +20 -5
- package/src/translations.ts +23 -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-4UTRJLQ3.mjs +0 -286
- package/dist/lib/browser/chunk-4UTRJLQ3.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-K7KY6YMG.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-4INUJLXL.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 +0 -298
- 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-4SRPREUK.mjs +0 -288
- package/dist/lib/node-esm/chunk-4SRPREUK.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-OFYGBUNI.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/bundler/bundler.d.ts +0 -39
- package/dist/types/src/bundler/bundler.d.ts.map +0 -1
- package/dist/types/src/bundler/bundler.test.d.ts +0 -2
- package/dist/types/src/bundler/bundler.test.d.ts.map +0 -1
- package/dist/types/src/bundler/index.d.ts +0 -2
- package/dist/types/src/bundler/index.d.ts.map +0 -1
- 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/bundler/bundler.test.ts +0 -54
- package/src/bundler/bundler.ts +0 -250
- 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/src/components/Toolbar/index.ts +0 -5
- /package/dist/lib/browser/{AutomationPanel-RFQAQ7NF.mjs.map → AutomationPanel-6HFRNRWV.mjs.map} +0 -0
- /package/dist/lib/node/{AutomationPanel-5CJEF4MI.cjs.map → AutomationPanel-RBQ4DODN.cjs.map} +0 -0
- /package/dist/lib/node-esm/{AutomationPanel-7Y6REBNJ.mjs.map → AutomationPanel-WTVVVMRH.mjs.map} +0 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/capabilities/compiler.ts", "../../../src/compiler/compiler.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\n// @ts-ignore\nimport wasmUrl from 'esbuild-wasm/esbuild.wasm?url';\n\nimport { contributes } from '@dxos/app-framework';\nimport { initializeBundler } from '@dxos/functions/bundler';\n\nimport { ScriptCapabilities } from './capabilities';\nimport { Compiler } from '../compiler';\n\nexport default async () => {\n const compiler = new Compiler();\n\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 return contributes(ScriptCapabilities.Compiler, compiler);\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"],
|
|
5
|
+
"mappings": ";;;;;;;AAKA,OAAOA,aAAa;AAEpB,SAASC,mBAAmB;AAC5B,SAASC,yBAAyB;;;ACJlC,SACEC,yBACAC,cACAC,0CAEK;AACP,OAAOC,QAAQ;AAEf,SAASC,iBAAiB;;AAE1B,IAAMC,iBAAqC;EACzCC,KAAK;IAAC;IAAO;;EACbC,QAAQJ,GAAGK,aAAaC;AAC1B;AAEO,IAAMC,WAAN,MAAMA;EAIXC,YAA6BC,WAA+BP,gBAAgB;SAA/CO,WAAAA;EAAgD;EAE7E,MAAMC,aAAa;AACjB,QAAI,KAAKC,MAAM;AACb;IACF;AAIA,SAAKC,SAAS,MAAMf,wBAAwB,KAAKY,UAAU,SAAS,MAAMT,EAAAA;AAC1E,UAAMa,SAASf,aAAa,KAAKc,MAAM;AACvC,SAAKD,OAAOZ,mCAAmCc,QAAQ,CAAA,GAAIb,IAAI,KAAKS,QAAQ;EAC9E;EAEA,IAAIK,cAAc;AAChBb,cAAU,KAAKU,MAAM,yCAAA;;;;;;;;;AACrB,WAAO,KAAKA;EACd;EAEAI,QAAQC,UAAkBC,SAAiB;AACzChB,cAAU,KAAKW,QAAQ,oCAAA;;;;;;;;;AACvB,SAAKE,YAAYI,WAAWF,UAAUC,OAAAA;EACxC;EAEAE,QAAQH,UAAkB;AACxB,WAAO,KAAKF,YAAYM,gBAAgBC,cAAcL,QAAAA;EACxD;AACF;;;ADrCA,IAAA,mBAAe,YAAA;AACb,QAAMM,WAAW,IAAIC,SAAAA;AAErB,QAAMD,SAASE,WAAU;AAEzBF,WAASG,QAAQ,qBAAqB,6BAAA;AAGtCH,WAASG,QACP,mBACA;;;;OAIG;AAEL,QAAMC,kBAAkB;IAAEC;EAAQ,CAAA;AAElC,SAAOC,YAAYC,mBAAmBN,UAAUD,QAAAA;AAClD;",
|
|
6
|
+
"names": ["wasmUrl", "contributes", "initializeBundler", "createDefaultMapFromCDN", "createSystem", "createVirtualTypeScriptEnvironment", "ts", "invariant", "defaultOptions", "lib", "target", "ScriptTarget", "ES2022", "Compiler", "constructor", "_options", "initialize", "_env", "_fsMap", "system", "environment", "setFile", "fileName", "content", "createFile", "compile", "languageService", "getEmitOutput", "compiler", "Compiler", "initialize", "setFile", "initializeBundler", "wasmUrl", "contributes", "ScriptCapabilities"]
|
|
7
|
+
}
|
|
@@ -1,207 +1,59 @@
|
|
|
1
1
|
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
AutomationPanel,
|
|
4
|
+
ScriptContainer,
|
|
5
|
+
ScriptSettings,
|
|
6
|
+
ScriptSettingsPanel
|
|
7
|
+
} from "./chunk-4OCRARHP.mjs";
|
|
5
8
|
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
ScriptCapabilities
|
|
10
|
+
} from "./chunk-CP5LXTK5.mjs";
|
|
11
|
+
import {
|
|
12
|
+
ScriptAction
|
|
13
|
+
} from "./chunk-UNQFIERE.mjs";
|
|
10
14
|
import {
|
|
11
15
|
SCRIPT_PLUGIN,
|
|
12
|
-
|
|
13
|
-
} from "./chunk-
|
|
14
|
-
|
|
15
|
-
// packages/plugins/experimental/plugin-script/src/ScriptPlugin.tsx
|
|
16
|
-
import wasmUrl from "esbuild-wasm/esbuild.wasm?url";
|
|
17
|
-
import React3 from "react";
|
|
18
|
-
import { createIntent, createResolver, createSurface } from "@dxos/app-framework";
|
|
19
|
-
import { FunctionType as FunctionType2, ScriptType } from "@dxos/functions";
|
|
20
|
-
import { create, makeRef, RefArray } from "@dxos/live-object";
|
|
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
|
-
};
|
|
16
|
+
meta
|
|
17
|
+
} from "./chunk-P2V2Y5LV.mjs";
|
|
75
18
|
|
|
76
|
-
// packages/plugins/experimental/plugin-script/src/
|
|
77
|
-
import { lazy } from "
|
|
19
|
+
// packages/plugins/experimental/plugin-script/src/capabilities/index.ts
|
|
20
|
+
import { lazy } from "@dxos/app-framework";
|
|
21
|
+
var Compiler = lazy(() => import("./compiler-XTXFGZJM.mjs"));
|
|
22
|
+
var IntentResolver = lazy(() => import("./intent-resolver-KLBHSMW4.mjs"));
|
|
23
|
+
var ReactSurface = lazy(() => import("./react-surface-OLH7N3DK.mjs"));
|
|
24
|
+
var ScriptSettings2 = lazy(() => import("./settings-GR4O2WHZ.mjs"));
|
|
25
|
+
var ArtifactDefinition = lazy(() => import("./artifact-definition-KBASPVMM.mjs"));
|
|
78
26
|
|
|
79
|
-
// packages/plugins/experimental/plugin-script/src/
|
|
80
|
-
import
|
|
81
|
-
import {
|
|
82
|
-
import {
|
|
83
|
-
import {
|
|
84
|
-
|
|
85
|
-
|
|
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
|
-
};
|
|
27
|
+
// packages/plugins/experimental/plugin-script/src/ScriptPlugin.tsx
|
|
28
|
+
import { Capabilities, contributes, createIntent, defineModule, definePlugin, Events } from "@dxos/app-framework";
|
|
29
|
+
import { FunctionType, ScriptType as ScriptType2 } from "@dxos/functions";
|
|
30
|
+
import { RefArray } from "@dxos/live-object";
|
|
31
|
+
import { ClientCapabilities, ClientEvents } from "@dxos/plugin-client";
|
|
32
|
+
import { SpaceCapabilities } from "@dxos/plugin-space";
|
|
33
|
+
import { defineObjectForm } from "@dxos/plugin-space/types";
|
|
191
34
|
|
|
192
|
-
// packages/plugins/experimental/plugin-script/src/
|
|
193
|
-
|
|
194
|
-
var
|
|
35
|
+
// packages/plugins/experimental/plugin-script/src/events.ts
|
|
36
|
+
import { defineEvent } from "@dxos/app-framework";
|
|
37
|
+
var ScriptEvents;
|
|
38
|
+
(function(ScriptEvents2) {
|
|
39
|
+
ScriptEvents2.SetupCompiler = defineEvent(`${SCRIPT_PLUGIN}/event/setup-compiler`);
|
|
40
|
+
})(ScriptEvents || (ScriptEvents = {}));
|
|
195
41
|
|
|
196
42
|
// packages/plugins/experimental/plugin-script/src/translations.ts
|
|
43
|
+
import { ScriptType } from "@dxos/functions";
|
|
197
44
|
var translations_default = [
|
|
198
45
|
{
|
|
199
46
|
"en-US": {
|
|
47
|
+
[ScriptType.typename]: {
|
|
48
|
+
"typename label": "Script"
|
|
49
|
+
},
|
|
200
50
|
[SCRIPT_PLUGIN]: {
|
|
201
51
|
"plugin name": "Scripts",
|
|
202
52
|
"object title placeholder": "New script",
|
|
203
53
|
"create object label": "Create script",
|
|
204
54
|
"create stack section label": "Create script",
|
|
55
|
+
"description label": "Description",
|
|
56
|
+
"description placeholder": "Describe what the script does.",
|
|
205
57
|
"binding placeholder": "Function name",
|
|
206
58
|
"function request placeholder": "Function request",
|
|
207
59
|
"deploy label": "Deploy",
|
|
@@ -216,123 +68,112 @@ var translations_default = [
|
|
|
216
68
|
"remote function settings heading": "Remote Function",
|
|
217
69
|
"function url label": "Invocation URL",
|
|
218
70
|
"function binding label": "Function binding",
|
|
219
|
-
"function binding placeholder": "BINDING"
|
|
71
|
+
"function binding placeholder": "BINDING",
|
|
72
|
+
"script publish settings label": "Publishing",
|
|
73
|
+
"script publish settings description": "Scripts can be shared publicly as Github gists.",
|
|
74
|
+
"no github token label": "This space has no Github access token available.",
|
|
75
|
+
"open token manager label": "Open Token Manager",
|
|
76
|
+
"publish label": "Publish",
|
|
77
|
+
"publishing label": "Publishing",
|
|
78
|
+
"editor input mode label": "Editor input mode",
|
|
79
|
+
"select editor input mode placeholder": "Select editor input mode\u2026",
|
|
80
|
+
"settings editor input mode default label": "Default",
|
|
81
|
+
"settings editor input mode vim label": "Vim",
|
|
82
|
+
"settings editor input mode vscode label": "VS Code",
|
|
83
|
+
"view group label": "View",
|
|
84
|
+
"view editor label": "Editor",
|
|
85
|
+
"view split label": "Split",
|
|
86
|
+
"view debug label": "Debug",
|
|
87
|
+
"template select group label": "Select template"
|
|
220
88
|
}
|
|
221
89
|
}
|
|
222
90
|
}
|
|
223
91
|
];
|
|
224
92
|
|
|
225
93
|
// 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
|
-
|
|
94
|
+
var ScriptPlugin = () => definePlugin(meta, [
|
|
95
|
+
defineModule({
|
|
96
|
+
id: `${meta.id}/module/settings`,
|
|
97
|
+
activatesOn: Events.SetupSettings,
|
|
98
|
+
activate: ScriptSettings2
|
|
99
|
+
}),
|
|
100
|
+
defineModule({
|
|
101
|
+
id: `${meta.id}/module/compiler`,
|
|
102
|
+
activatesOn: ScriptEvents.SetupCompiler,
|
|
103
|
+
activate: Compiler
|
|
104
|
+
}),
|
|
105
|
+
defineModule({
|
|
106
|
+
id: `${meta.id}/module/translations`,
|
|
107
|
+
activatesOn: Events.SetupTranslations,
|
|
108
|
+
activate: () => contributes(Capabilities.Translations, translations_default)
|
|
109
|
+
}),
|
|
110
|
+
defineModule({
|
|
111
|
+
id: `${meta.id}/module/metadata`,
|
|
112
|
+
activatesOn: Events.SetupMetadata,
|
|
113
|
+
activate: () => contributes(Capabilities.Metadata, {
|
|
114
|
+
id: ScriptType2.typename,
|
|
244
115
|
metadata: {
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
"object title placeholder",
|
|
250
|
-
{
|
|
251
|
-
ns: SCRIPT_PLUGIN
|
|
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
|
-
])
|
|
116
|
+
placeholder: [
|
|
117
|
+
"object title placeholder",
|
|
118
|
+
{
|
|
119
|
+
ns: SCRIPT_PLUGIN
|
|
259
120
|
}
|
|
260
|
-
}
|
|
261
|
-
},
|
|
262
|
-
translations: translations_default,
|
|
263
|
-
echo: {
|
|
264
|
-
schema: [
|
|
265
|
-
ScriptType
|
|
266
121
|
],
|
|
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
|
-
}))
|
|
122
|
+
icon: "ph--code--regular",
|
|
123
|
+
// TODO(wittjosiah): Move out of metadata.
|
|
124
|
+
loadReferences: async (script) => await RefArray.loadAll([
|
|
125
|
+
script.source
|
|
126
|
+
])
|
|
319
127
|
}
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
128
|
+
})
|
|
129
|
+
}),
|
|
130
|
+
defineModule({
|
|
131
|
+
id: `${meta.id}/module/object-form`,
|
|
132
|
+
activatesOn: ClientEvents.SetupSchema,
|
|
133
|
+
activate: () => contributes(SpaceCapabilities.ObjectForm, defineObjectForm({
|
|
134
|
+
objectSchema: ScriptType2,
|
|
135
|
+
formSchema: ScriptAction.CreateScriptSchema,
|
|
136
|
+
getIntent: (props, options) => createIntent(ScriptAction.Create, {
|
|
137
|
+
...props,
|
|
138
|
+
space: options.space
|
|
139
|
+
})
|
|
140
|
+
}))
|
|
141
|
+
}),
|
|
142
|
+
defineModule({
|
|
143
|
+
id: `${meta.id}/module/schema`,
|
|
144
|
+
activatesOn: ClientEvents.SetupSchema,
|
|
145
|
+
activate: () => contributes(ClientCapabilities.Schema, [
|
|
146
|
+
FunctionType
|
|
147
|
+
])
|
|
148
|
+
}),
|
|
149
|
+
defineModule({
|
|
150
|
+
id: `${meta.id}/module/react-surface`,
|
|
151
|
+
activatesOn: Events.SetupReactSurface,
|
|
152
|
+
// TODO(wittjosiah): Should occur before the script editor is loaded when surfaces activation is more granular.
|
|
153
|
+
activatesBefore: [
|
|
154
|
+
ScriptEvents.SetupCompiler
|
|
155
|
+
],
|
|
156
|
+
activate: ReactSurface
|
|
157
|
+
}),
|
|
158
|
+
defineModule({
|
|
159
|
+
id: `${meta.id}/module/intent-resolver`,
|
|
160
|
+
activatesOn: Events.SetupIntentResolver,
|
|
161
|
+
activate: IntentResolver
|
|
162
|
+
}),
|
|
163
|
+
defineModule({
|
|
164
|
+
id: `${meta.id}/module/artifact-definition`,
|
|
165
|
+
activatesOn: Events.SetupArtifactDefinition,
|
|
166
|
+
activate: ArtifactDefinition
|
|
167
|
+
})
|
|
168
|
+
]);
|
|
326
169
|
export {
|
|
327
170
|
AutomationPanel,
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
ScriptAction,
|
|
171
|
+
SCRIPT_PLUGIN,
|
|
172
|
+
ScriptCapabilities,
|
|
331
173
|
ScriptContainer,
|
|
332
174
|
ScriptPlugin,
|
|
333
175
|
ScriptSettings,
|
|
334
176
|
ScriptSettingsPanel,
|
|
335
|
-
|
|
336
|
-
initializeBundler
|
|
177
|
+
meta
|
|
337
178
|
};
|
|
338
179
|
//# 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/events.ts", "../../../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'));\nexport const ArtifactDefinition = lazy(() => import('./artifact-definition'));\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 { FunctionType, ScriptType } from '@dxos/functions';\nimport { RefArray } from '@dxos/live-object';\nimport { ClientCapabilities, ClientEvents } from '@dxos/plugin-client';\nimport { SpaceCapabilities } from '@dxos/plugin-space';\nimport { defineObjectForm } from '@dxos/plugin-space/types';\n\nimport { ArtifactDefinition, Compiler, IntentResolver, ReactSurface, ScriptSettings } from './capabilities';\nimport { ScriptEvents } from './events';\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: ScriptEvents.SetupCompiler,\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 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/object-form`,\n activatesOn: ClientEvents.SetupSchema,\n activate: () =>\n contributes(\n SpaceCapabilities.ObjectForm,\n defineObjectForm({\n objectSchema: ScriptType,\n formSchema: ScriptAction.CreateScriptSchema,\n getIntent: (props, options) => createIntent(ScriptAction.Create, { ...props, space: options.space }),\n }),\n ),\n }),\n defineModule({\n id: `${meta.id}/module/schema`,\n activatesOn: ClientEvents.SetupSchema,\n activate: () => contributes(ClientCapabilities.Schema, [FunctionType]),\n }),\n defineModule({\n id: `${meta.id}/module/react-surface`,\n activatesOn: Events.SetupReactSurface,\n // TODO(wittjosiah): Should occur before the script editor is loaded when surfaces activation is more granular.\n activatesBefore: [ScriptEvents.SetupCompiler],\n activate: ReactSurface,\n }),\n defineModule({\n id: `${meta.id}/module/intent-resolver`,\n activatesOn: Events.SetupIntentResolver,\n activate: IntentResolver,\n }),\n defineModule({\n id: `${meta.id}/module/artifact-definition`,\n activatesOn: Events.SetupArtifactDefinition,\n activate: ArtifactDefinition,\n }),\n ]);\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { defineEvent } from '@dxos/app-framework';\n\nimport { SCRIPT_PLUGIN } from './meta';\n\nexport namespace ScriptEvents {\n export const SetupCompiler = defineEvent(`${SCRIPT_PLUGIN}/event/setup-compiler`);\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 'description label': 'Description',\n 'description placeholder': 'Describe what the script does.',\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;AACzC,IAAMI,qBAAqBJ,KAAK,MAAM,OAAO,oCAAA,CAAA;;;ACJpD,SAASK,cAAcC,aAAaC,cAAcC,cAAcC,cAAcC,cAAc;AAC5F,SAASC,cAAcC,cAAAA,mBAAkB;AACzC,SAASC,gBAAgB;AACzB,SAASC,oBAAoBC,oBAAoB;AACjD,SAASC,yBAAyB;AAClC,SAASC,wBAAwB;;;ACPjC,SAASC,mBAAmB;;UAIXC,eAAAA;gBACFC,gBAAgBC,YAAY,GAAGC,aAAAA,uBAAoC;AAClF,GAFiBH,iBAAAA,eAAAA,CAAAA,EAAAA;;;ACJjB,SAASI,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,qBAAqB;QACrB,2BAA2B;QAC3B,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;;;;AFnCK,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,aAAaK,aAAaC;IAC1BH,UAAUI;EACZ,CAAA;EACAT,aAAa;IACXC,IAAI,GAAGF,KAAKE,EAAE;IACdC,aAAaC,OAAOO;IACpBL,UAAU,MAAMM,YAAYC,aAAaC,cAAcC,oBAAAA;EACzD,CAAA;EACAd,aAAa;IACXC,IAAI,GAAGF,KAAKE,EAAE;IACdC,aAAaC,OAAOY;IACpBV,UAAU,MACRM,YAAYC,aAAaI,UAAU;MACjCf,IAAIgB,YAAWC;MACfC,UAAU;QACRC,aAAa;UAAC;UAA4B;YAAEC,IAAIC;UAAc;;QAC9DC,MAAM;;QAENC,gBAAgB,OAAOC,WAAuB,MAAMC,SAASC,QAAQ;UAACF,OAAOG;SAAO;MACtF;IACF,CAAA;EACJ,CAAA;EACA5B,aAAa;IACXC,IAAI,GAAGF,KAAKE,EAAE;IACdC,aAAa2B,aAAaC;IAC1BzB,UAAU,MACRM,YACEoB,kBAAkBC,YAClBC,iBAAiB;MACfC,cAAcjB;MACdkB,YAAYC,aAAaC;MACzBC,WAAW,CAACC,OAAOC,YAAYC,aAAaL,aAAaM,QAAQ;QAAE,GAAGH;QAAOI,OAAOH,QAAQG;MAAM,CAAA;IACpG,CAAA,CAAA;EAEN,CAAA;EACA3C,aAAa;IACXC,IAAI,GAAGF,KAAKE,EAAE;IACdC,aAAa2B,aAAaC;IAC1BzB,UAAU,MAAMM,YAAYiC,mBAAmBC,QAAQ;MAACC;KAAa;EACvE,CAAA;EACA9C,aAAa;IACXC,IAAI,GAAGF,KAAKE,EAAE;IACdC,aAAaC,OAAO4C;;IAEpBC,iBAAiB;MAACzC,aAAaC;;IAC/BH,UAAU4C;EACZ,CAAA;EACAjD,aAAa;IACXC,IAAI,GAAGF,KAAKE,EAAE;IACdC,aAAaC,OAAO+C;IACpB7C,UAAU8C;EACZ,CAAA;EACAnD,aAAa;IACXC,IAAI,GAAGF,KAAKE,EAAE;IACdC,aAAaC,OAAOiD;IACpB/C,UAAUgD;EACZ,CAAA;CACD;",
|
|
6
|
+
"names": ["lazy", "Compiler", "lazy", "IntentResolver", "ReactSurface", "ScriptSettings", "ArtifactDefinition", "Capabilities", "contributes", "createIntent", "defineModule", "definePlugin", "Events", "FunctionType", "ScriptType", "RefArray", "ClientCapabilities", "ClientEvents", "SpaceCapabilities", "defineObjectForm", "defineEvent", "ScriptEvents", "SetupCompiler", "defineEvent", "SCRIPT_PLUGIN", "ScriptType", "ScriptType", "typename", "SCRIPT_PLUGIN", "ScriptPlugin", "definePlugin", "meta", "defineModule", "id", "activatesOn", "Events", "SetupSettings", "activate", "ScriptSettings", "ScriptEvents", "SetupCompiler", "Compiler", "SetupTranslations", "contributes", "Capabilities", "Translations", "translations", "SetupMetadata", "Metadata", "ScriptType", "typename", "metadata", "placeholder", "ns", "SCRIPT_PLUGIN", "icon", "loadReferences", "script", "RefArray", "loadAll", "source", "ClientEvents", "SetupSchema", "SpaceCapabilities", "ObjectForm", "defineObjectForm", "objectSchema", "formSchema", "ScriptAction", "CreateScriptSchema", "getIntent", "props", "options", "createIntent", "Create", "space", "ClientCapabilities", "Schema", "FunctionType", "SetupReactSurface", "activatesBefore", "ReactSurface", "SetupIntentResolver", "IntentResolver", "SetupArtifactDefinition", "ArtifactDefinition"]
|
|
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-YIWRJ25J.mjs";
|
|
5
|
+
import {
|
|
6
|
+
ScriptAction
|
|
7
|
+
} from "./chunk-UNQFIERE.mjs";
|
|
8
|
+
import "./chunk-P2V2Y5LV.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-KLBHSMW4.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
|
+
}
|