@dxos/plugin-script 0.6.10-main.e92b5eb → 0.6.10-staging.3cfcc89
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +45 -0
- package/dist/lib/browser/ScriptEditor-WNCGR5OU.mjs +452 -0
- package/dist/lib/browser/ScriptEditor-WNCGR5OU.mjs.map +7 -0
- package/dist/lib/browser/{TypescriptEditor-PIRIDDUS.mjs → TypescriptEditor-XTGRVCMY.mjs} +2 -2
- package/dist/lib/browser/{chunk-ISMNAD3P.mjs → chunk-DL5XQRQM.mjs} +13 -7
- package/dist/lib/browser/{chunk-ISMNAD3P.mjs.map → chunk-DL5XQRQM.mjs.map} +3 -3
- package/dist/lib/browser/{chunk-D4O723CR.mjs → chunk-DX5CSOBP.mjs} +22 -5
- package/dist/lib/browser/chunk-DX5CSOBP.mjs.map +7 -0
- package/dist/lib/browser/chunk-RHEZ5LUU.mjs +229 -0
- package/dist/lib/browser/chunk-RHEZ5LUU.mjs.map +7 -0
- package/dist/lib/browser/edge/index.mjs +1 -1
- package/dist/lib/browser/index.mjs +88 -195
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/ScriptEditor-RR7AVOQL.cjs +465 -0
- package/dist/lib/node/ScriptEditor-RR7AVOQL.cjs.map +7 -0
- package/dist/lib/node/{TypescriptEditor-OTWJUIWB.cjs → TypescriptEditor-CRONCQSI.cjs} +7 -7
- package/dist/lib/node/{TypescriptEditor-OTWJUIWB.cjs.map → TypescriptEditor-CRONCQSI.cjs.map} +2 -2
- package/dist/lib/node/chunk-4GTXIELQ.cjs +252 -0
- package/dist/lib/node/chunk-4GTXIELQ.cjs.map +7 -0
- package/dist/lib/node/{chunk-HN3AVLUL.cjs → chunk-PFH3ROEH.cjs} +16 -10
- package/dist/lib/node/{chunk-HN3AVLUL.cjs.map → chunk-PFH3ROEH.cjs.map} +3 -3
- package/dist/lib/node/{chunk-ITLHJMWP.cjs → chunk-RXI576K3.cjs} +24 -7
- package/dist/lib/node/chunk-RXI576K3.cjs.map +7 -0
- package/dist/lib/node/edge/index.cjs +8 -8
- package/dist/lib/node/edge/index.cjs.map +1 -1
- package/dist/lib/node/index.cjs +85 -194
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/types/src/ScriptPlugin.d.ts +1 -4
- package/dist/types/src/ScriptPlugin.d.ts.map +1 -1
- package/dist/types/src/bundler/bundler.d.ts +39 -0
- package/dist/types/src/bundler/bundler.d.ts.map +1 -0
- package/dist/types/src/bundler/bundler.test.d.ts +2 -0
- package/dist/types/src/bundler/bundler.test.d.ts.map +1 -0
- package/dist/types/src/bundler/index.d.ts +2 -0
- package/dist/types/src/bundler/index.d.ts.map +1 -0
- package/dist/types/src/compiler/compiler.browser.test.d.ts +2 -0
- package/dist/types/src/compiler/compiler.browser.test.d.ts.map +1 -0
- package/dist/types/src/compiler/compiler.d.ts +9 -34
- package/dist/types/src/compiler/compiler.d.ts.map +1 -1
- package/dist/types/src/components/DetailsPanel.d.ts +9 -0
- package/dist/types/src/components/DetailsPanel.d.ts.map +1 -0
- package/dist/types/src/components/ScriptBlock/FrameContainer/FrameContainer.d.ts +2 -2
- package/dist/types/src/components/ScriptBlock/FrameContainer/FrameContainer.d.ts.map +1 -1
- package/dist/types/src/components/ScriptBlock/ScriptBlock.d.ts.map +1 -1
- package/dist/types/src/components/ScriptEditor.d.ts +3 -2
- package/dist/types/src/components/ScriptEditor.d.ts.map +1 -1
- package/dist/types/src/components/Toolbar.d.ts +9 -7
- package/dist/types/src/components/Toolbar.d.ts.map +1 -1
- package/dist/types/src/components/Toolbar.stories.d.ts +1 -1
- package/dist/types/src/components/TypescriptEditor.d.ts +3 -1
- package/dist/types/src/components/TypescriptEditor.d.ts.map +1 -1
- package/dist/types/src/components/TypescriptEditor.stories.d.ts +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/data/templates.md.d.ts +3 -0
- package/dist/types/src/data/templates.md.d.ts.map +1 -0
- package/dist/types/src/edge/functions.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +3 -2
- package/dist/types/src/translations.d.ts.map +1 -1
- package/package.json +38 -33
- package/src/ScriptPlugin.tsx +29 -10
- package/src/bundler/bundler.test.ts +44 -0
- package/src/bundler/bundler.ts +246 -0
- package/src/bundler/index.ts +5 -0
- package/src/compiler/compiler.browser.test.ts +18 -0
- package/src/compiler/compiler.ts +31 -190
- package/src/compiler/index.ts +1 -1
- package/src/components/DetailsPanel.tsx +218 -0
- package/src/components/ScriptBlock/FrameContainer/FrameContainer.tsx +2 -2
- package/src/components/ScriptBlock/ScriptBlock.tsx +10 -7
- package/src/components/ScriptEditor.tsx +71 -13
- package/src/components/Toolbar.tsx +69 -91
- package/src/components/TypescriptEditor.tsx +18 -4
- package/src/data/templates.md.ts +44 -0
- package/src/edge/functions.ts +9 -2
- package/src/index.ts +1 -0
- package/src/translations.ts +4 -3
- package/dist/lib/browser/ScriptEditor-MSQDR6D7.mjs +0 -241
- package/dist/lib/browser/ScriptEditor-MSQDR6D7.mjs.map +0 -7
- package/dist/lib/browser/chunk-D4O723CR.mjs.map +0 -7
- package/dist/lib/node/ScriptEditor-KBSACFYK.cjs +0 -258
- package/dist/lib/node/ScriptEditor-KBSACFYK.cjs.map +0 -7
- package/dist/lib/node/chunk-ITLHJMWP.cjs.map +0 -7
- package/dist/types/src/compiler/compiler.test.d.ts +0 -2
- package/dist/types/src/compiler/compiler.test.d.ts.map +0 -1
- package/src/compiler/compiler.test.ts +0 -17
- /package/dist/lib/browser/{TypescriptEditor-PIRIDDUS.mjs.map → TypescriptEditor-XTGRVCMY.mjs.map} +0 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { type BuildOptions } from 'esbuild';
|
|
2
|
+
import { type BuildResult } from 'esbuild-wasm';
|
|
3
|
+
export type Import = {
|
|
4
|
+
moduleUrl: string;
|
|
5
|
+
defaultImport: boolean;
|
|
6
|
+
namedImports: string[];
|
|
7
|
+
};
|
|
8
|
+
export type BundlerResult = {
|
|
9
|
+
timestamp: number;
|
|
10
|
+
sourceHash: Buffer;
|
|
11
|
+
imports?: Import[];
|
|
12
|
+
bundle?: string;
|
|
13
|
+
error?: any;
|
|
14
|
+
};
|
|
15
|
+
export type BundlerOptions = {
|
|
16
|
+
platform: BuildOptions['platform'];
|
|
17
|
+
sandboxedModules: string[];
|
|
18
|
+
remoteModules: Record<string, string>;
|
|
19
|
+
};
|
|
20
|
+
export declare const initializeBundler: (options: {
|
|
21
|
+
wasmUrl: string;
|
|
22
|
+
}) => Promise<void>;
|
|
23
|
+
/**
|
|
24
|
+
* ESBuild bundler.
|
|
25
|
+
*/
|
|
26
|
+
export declare class Bundler {
|
|
27
|
+
private readonly _options;
|
|
28
|
+
constructor(_options: BundlerOptions);
|
|
29
|
+
bundle(source: string): Promise<BundlerResult>;
|
|
30
|
+
analyzeImports(result: BuildResult): Import[];
|
|
31
|
+
analyzeSourceFileImports(code: string): {
|
|
32
|
+
defaultImportName: string;
|
|
33
|
+
namedImports: string[];
|
|
34
|
+
wildcardImportName: string;
|
|
35
|
+
moduleIdentifier: string;
|
|
36
|
+
quotes: string;
|
|
37
|
+
}[];
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=bundler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bundler.d.ts","sourceRoot":"","sources":["../../../../src/bundler/bundler.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAqB,KAAK,WAAW,EAAe,MAAM,cAAc,CAAC;AAMhF,MAAM,MAAM,MAAM,GAAG;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,OAAO,CAAC;IACvB,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,GAAG,CAAC;CACb,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,QAAQ,EAAE,YAAY,CAAC,UAAU,CAAC,CAAC;IACnC,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACvC,CAAC;AAGF,eAAO,MAAM,iBAAiB,YAAmB;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,kBAInE,CAAC;AAEF;;GAEG;AACH,qBAAa,OAAO;IACN,OAAO,CAAC,QAAQ,CAAC,QAAQ;gBAAR,QAAQ,EAAE,cAAc;IAE/C,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAoFpD,cAAc,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,EAAE;IA2B7C,wBAAwB,CAAC,IAAI,EAAE,MAAM;;;;;;;CAatC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bundler.test.d.ts","sourceRoot":"","sources":["../../../../src/bundler/bundler.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/bundler/index.ts"],"names":[],"mappings":"AAIA,cAAc,WAAW,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compiler.browser.test.d.ts","sourceRoot":"","sources":["../../../../src/compiler/compiler.browser.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,38 +1,13 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
import
|
|
3
|
-
export type Import = {
|
|
4
|
-
moduleUrl: string;
|
|
5
|
-
defaultImport: boolean;
|
|
6
|
-
namedImports: string[];
|
|
7
|
-
};
|
|
8
|
-
export type CompilerResult = {
|
|
9
|
-
timestamp: number;
|
|
10
|
-
sourceHash: Buffer;
|
|
11
|
-
imports?: Import[];
|
|
12
|
-
bundle?: string;
|
|
13
|
-
error?: any;
|
|
14
|
-
};
|
|
15
|
-
export type CompilerOptions = {
|
|
16
|
-
platform: BuildOptions['platform'];
|
|
17
|
-
providedModules: string[];
|
|
18
|
-
};
|
|
19
|
-
export declare const initializeCompiler: (options: {
|
|
20
|
-
wasmURL: string;
|
|
21
|
-
}) => Promise<void>;
|
|
22
|
-
/**
|
|
23
|
-
* ESBuild compiler.
|
|
24
|
-
*/
|
|
1
|
+
import { type VirtualTypeScriptEnvironment } from '@typescript/vfs';
|
|
2
|
+
import ts from 'typescript';
|
|
25
3
|
export declare class Compiler {
|
|
26
4
|
private readonly _options;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
moduleIdentifier: string;
|
|
35
|
-
quotes: string;
|
|
36
|
-
}[];
|
|
5
|
+
private _env;
|
|
6
|
+
private _fsMap;
|
|
7
|
+
constructor(_options?: ts.CompilerOptions);
|
|
8
|
+
initialize(): Promise<void>;
|
|
9
|
+
get environment(): VirtualTypeScriptEnvironment;
|
|
10
|
+
setFile(fileName: string, content: string): void;
|
|
11
|
+
compile(fileName: string): ts.EmitOutput;
|
|
37
12
|
}
|
|
38
13
|
//# sourceMappingURL=compiler.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compiler.d.ts","sourceRoot":"","sources":["../../../../src/compiler/compiler.ts"],"names":[],"mappings":"AAIA,OAAO,
|
|
1
|
+
{"version":3,"file":"compiler.d.ts","sourceRoot":"","sources":["../../../../src/compiler/compiler.ts"],"names":[],"mappings":"AAIA,OAAO,EAIL,KAAK,4BAA4B,EAClC,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,MAAM,YAAY,CAAC;AAS5B,qBAAa,QAAQ;IAIP,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAHrC,OAAO,CAAC,IAAI,CAA2C;IACvD,OAAO,CAAC,MAAM,CAAkC;gBAEnB,QAAQ,GAAE,EAAE,CAAC,eAAgC;IAEpE,UAAU;IAYhB,IAAI,WAAW,iCAGd;IAED,OAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;IAKzC,OAAO,CAAC,QAAQ,EAAE,MAAM;CAGzB"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type ThemedClassName } from '@dxos/react-ui';
|
|
3
|
+
export type DetailsPanelProps = ThemedClassName<{
|
|
4
|
+
functionUrl?: string;
|
|
5
|
+
binding?: string;
|
|
6
|
+
onBindingChange?: (binding: string) => void;
|
|
7
|
+
}>;
|
|
8
|
+
export declare const DetailsPanel: ({ classNames, functionUrl, binding: _binding, onBindingChange }: DetailsPanelProps) => React.JSX.Element;
|
|
9
|
+
//# sourceMappingURL=DetailsPanel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DetailsPanel.d.ts","sourceRoot":"","sources":["../../../../src/components/DetailsPanel.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAG3D,OAAO,EAKL,KAAK,eAAe,EAKrB,MAAM,gBAAgB,CAAC;AASxB,MAAM,MAAM,iBAAiB,GAAG,eAAe,CAAC;IAC9C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,eAAe,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CAC7C,CAAC,CAAC;AAEH,eAAO,MAAM,YAAY,oEAAqE,iBAAiB,sBAsJ9G,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { type
|
|
2
|
+
import { type BundlerResult } from '../../../bundler';
|
|
3
3
|
export type FrameContainerProps = {
|
|
4
4
|
containerUrl: string;
|
|
5
|
-
result:
|
|
5
|
+
result: BundlerResult;
|
|
6
6
|
debug?: boolean;
|
|
7
7
|
};
|
|
8
8
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FrameContainer.d.ts","sourceRoot":"","sources":["../../../../../../src/components/ScriptBlock/FrameContainer/FrameContainer.tsx"],"names":[],"mappings":"AAIA,OAAO,KAA4B,MAAM,OAAO,CAAC;AASjD,OAAO,EAAE,KAAK,
|
|
1
|
+
{"version":3,"file":"FrameContainer.d.ts","sourceRoot":"","sources":["../../../../../../src/components/ScriptBlock/FrameContainer/FrameContainer.tsx"],"names":[],"mappings":"AAIA,OAAO,KAA4B,MAAM,OAAO,CAAC;AASjD,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEtD,MAAM,MAAM,mBAAmB,GAAG;IAChC,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,aAAa,CAAC;IACtB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,cAAc,oCAA4C,mBAAmB,sBAyDzF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScriptBlock.d.ts","sourceRoot":"","sources":["../../../../../src/components/ScriptBlock/ScriptBlock.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAoD,MAAM,OAAO,CAAC;AAOzE,OAAO,EAA8B,KAAK,IAAI,EAAE,MAAM,YAAY,CAAC;AAEnE,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC;AAa9C,MAAM,MAAM,gBAAgB,GAAG;IAC7B,MAAM,EAAE,UAAU,CAAC;IACnB,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,OAAO,CAAC,EAAE;QACR,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;IAGF,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF;;GAEG;AAEH,eAAO,MAAM,WAAW,2EAMrB,gBAAgB,
|
|
1
|
+
{"version":3,"file":"ScriptBlock.d.ts","sourceRoot":"","sources":["../../../../../src/components/ScriptBlock/ScriptBlock.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAoD,MAAM,OAAO,CAAC;AAOzE,OAAO,EAA8B,KAAK,IAAI,EAAE,MAAM,YAAY,CAAC;AAEnE,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC;AAa9C,MAAM,MAAM,gBAAgB,GAAG;IAC7B,MAAM,EAAE,UAAU,CAAC;IACnB,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,OAAO,CAAC,EAAE;QACR,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;IAGF,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF;;GAEG;AAEH,eAAO,MAAM,WAAW,2EAMrB,gBAAgB,sBAkFlB,CAAC"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { type TypescriptEditorProps } from './TypescriptEditor';
|
|
2
3
|
import { type ScriptType } from '../types';
|
|
3
4
|
export type ScriptEditorProps = {
|
|
4
5
|
script: ScriptType;
|
|
5
6
|
role?: string;
|
|
6
|
-
}
|
|
7
|
-
export declare const ScriptEditor: ({ script, role }: ScriptEditorProps) => React.JSX.Element;
|
|
7
|
+
} & Pick<TypescriptEditorProps, 'env'>;
|
|
8
|
+
export declare const ScriptEditor: ({ env, script, role }: ScriptEditorProps) => React.JSX.Element;
|
|
8
9
|
export default ScriptEditor;
|
|
9
10
|
//# sourceMappingURL=ScriptEditor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScriptEditor.d.ts","sourceRoot":"","sources":["../../../../src/components/ScriptEditor.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ScriptEditor.d.ts","sourceRoot":"","sources":["../../../../src/components/ScriptEditor.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAyC,MAAM,OAAO,CAAC;AAY9D,OAAO,EAAoB,KAAK,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AASlF,OAAO,EAAgB,KAAK,UAAU,EAAE,MAAM,UAAU,CAAC;AAEzD,MAAM,MAAM,iBAAiB,GAAG;IAC9B,MAAM,EAAE,UAAU,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,GAAG,IAAI,CAAC,qBAAqB,EAAE,KAAK,CAAC,CAAC;AAEvC,eAAO,MAAM,YAAY,0BAA2B,iBAAiB,sBAoJpE,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
onBindingChange: (binding: string) => void;
|
|
2
|
+
import { type ThemedClassName } from '@dxos/react-ui';
|
|
3
|
+
export type ToolbarProps = ThemedClassName<{
|
|
5
4
|
deployed?: boolean;
|
|
6
|
-
onDeploy?: () => Promise<void>;
|
|
7
|
-
functionUrl?: string;
|
|
8
5
|
error?: string;
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
functionUrl?: string;
|
|
7
|
+
showPanel?: boolean;
|
|
8
|
+
onDeploy?: () => Promise<void>;
|
|
9
|
+
onFormat?: () => Promise<void>;
|
|
10
|
+
onTogglePanel?: () => Promise<void>;
|
|
11
|
+
}>;
|
|
12
|
+
export declare const Toolbar: ({ classNames, deployed, error, functionUrl, showPanel, onDeploy, onFormat, onTogglePanel, }: ToolbarProps) => React.JSX.Element;
|
|
11
13
|
//# sourceMappingURL=Toolbar.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Toolbar.d.ts","sourceRoot":"","sources":["../../../../src/components/Toolbar.tsx"],"names":[],"mappings":"AAKA,OAAO,
|
|
1
|
+
{"version":3,"file":"Toolbar.d.ts","sourceRoot":"","sources":["../../../../src/components/Toolbar.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,OAAO,EAIL,KAAK,eAAe,EAIrB,MAAM,gBAAgB,CAAC;AAKxB,MAAM,MAAM,YAAY,GAAG,eAAe,CAAC;IACzC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/B,QAAQ,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/B,aAAa,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CACrC,CAAC,CAAC;AAEH,eAAO,MAAM,OAAO,gGASjB,YAAY,sBAyHd,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import '@dxos-theme';
|
|
2
2
|
declare const _default: {
|
|
3
3
|
title: string;
|
|
4
|
-
component: ({
|
|
4
|
+
component: ({ classNames, deployed, error, functionUrl, showPanel, onDeploy, onFormat, onTogglePanel, }: import("./Toolbar").ToolbarProps) => import("react").JSX.Element;
|
|
5
5
|
parameters: {
|
|
6
6
|
layout: string;
|
|
7
7
|
};
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
+
import { type VirtualTypeScriptEnvironment } from '@typescript/vfs';
|
|
1
2
|
import React from 'react';
|
|
2
3
|
import { type UseTextEditorProps } from '@dxos/react-ui-editor';
|
|
3
4
|
export type TypescriptEditorProps = {
|
|
4
5
|
id: string;
|
|
6
|
+
env?: VirtualTypeScriptEnvironment;
|
|
5
7
|
className?: string;
|
|
6
8
|
scrollPastEnd?: boolean;
|
|
7
9
|
} & Pick<UseTextEditorProps, 'initialValue' | 'extensions' | 'scrollTo' | 'selection'>;
|
|
8
|
-
export declare const TypescriptEditor: ({ id, extensions, initialValue, scrollTo, selection, className, scrollPastEnd, }: TypescriptEditorProps) => React.JSX.Element;
|
|
10
|
+
export declare const TypescriptEditor: ({ id, extensions, env, initialValue, scrollTo, selection, className, scrollPastEnd, }: TypescriptEditorProps) => React.JSX.Element;
|
|
9
11
|
export default TypescriptEditor;
|
|
10
12
|
//# sourceMappingURL=TypescriptEditor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TypescriptEditor.d.ts","sourceRoot":"","sources":["../../../../src/components/TypescriptEditor.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,
|
|
1
|
+
{"version":3,"file":"TypescriptEditor.d.ts","sourceRoot":"","sources":["../../../../src/components/TypescriptEditor.tsx"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,4BAA4B,EAAE,MAAM,iBAAiB,CAAC;AAEpE,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EASL,KAAK,kBAAkB,EACxB,MAAM,uBAAuB,CAAC;AAG/B,MAAM,MAAM,qBAAqB,GAAG;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,CAAC,EAAE,4BAA4B,CAAC;IACnC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,GAAG,IAAI,CAAC,kBAAkB,EAAE,cAAc,GAAG,YAAY,GAAG,UAAU,GAAG,WAAW,CAAC,CAAC;AAEvF,eAAO,MAAM,gBAAgB,0FAS1B,qBAAqB,sBAuCvB,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
|
|
@@ -2,7 +2,7 @@ import '@dxos-theme';
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
declare const _default: {
|
|
4
4
|
title: string;
|
|
5
|
-
component: ({ id, extensions, initialValue, scrollTo, selection, className, scrollPastEnd, }: import("./TypescriptEditor").TypescriptEditorProps) => React.JSX.Element;
|
|
5
|
+
component: ({ id, extensions, env, initialValue, scrollTo, selection, className, scrollPastEnd, }: import("./TypescriptEditor").TypescriptEditorProps) => React.JSX.Element;
|
|
6
6
|
render: () => React.JSX.Element;
|
|
7
7
|
parameters: {
|
|
8
8
|
layout: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
export declare const ScriptEditor: React.LazyExoticComponent<({ script, role }: import("./ScriptEditor").ScriptEditorProps) => React.JSX.Element>;
|
|
3
|
-
export declare const TypescriptEditor: React.LazyExoticComponent<({ id, extensions, initialValue, scrollTo, selection, className, scrollPastEnd, }: import("./TypescriptEditor").TypescriptEditorProps) => React.JSX.Element>;
|
|
2
|
+
export declare const ScriptEditor: React.LazyExoticComponent<({ env, script, role }: import("./ScriptEditor").ScriptEditorProps) => React.JSX.Element>;
|
|
3
|
+
export declare const TypescriptEditor: React.LazyExoticComponent<({ id, extensions, env, initialValue, scrollTo, selection, className, scrollPastEnd, }: import("./TypescriptEditor").TypescriptEditorProps) => React.JSX.Element>;
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,eAAO,MAAM,YAAY,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,eAAO,MAAM,YAAY,qHAA6C,CAAC;AACvE,eAAO,MAAM,gBAAgB,6LAAiD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"templates.md.d.ts","sourceRoot":"","sources":["../../../../src/data/templates.md.ts"],"names":[],"mappings":"qFASG,GAAG;AALN,wBAuCE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"functions.d.ts","sourceRoot":"","sources":["../../../../src/edge/functions.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,GAAG,EAAE,MAAM,eAAe,CAAC;AAGzC,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAapD,MAAM,MAAM,wBAAwB,GAAG;IACrC,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC;IAC5B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,qBAAqB,CAAC,EAAE,MAAM,CAAC;CAChC,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,IAAI,CAAC;IACX,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,GAAG,CAAC;IACd,qBAAqB,CAAC,EAAE,MAAM,CAAC;CAChC,CAAC;
|
|
1
|
+
{"version":3,"file":"functions.d.ts","sourceRoot":"","sources":["../../../../src/edge/functions.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,GAAG,EAAE,MAAM,eAAe,CAAC;AAGzC,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAapD,MAAM,MAAM,wBAAwB,GAAG;IACrC,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC;IAC5B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,qBAAqB,CAAC,EAAE,MAAM,CAAC;CAChC,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,IAAI,CAAC;IACX,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,GAAG,CAAC;IACd,qBAAqB,CAAC,EAAE,MAAM,CAAC;CAChC,CAAC;AAeF,eAAO,MAAM,oBAAoB,uFAQ9B,iBAAiB,sCAwBnB,CAAC;AAEF,eAAO,MAAM,4BAA4B,SAAU,UAAU,uBAE5D,CAAC;AAEF,eAAO,MAAM,4BAA4B,SAAU,UAAU,eAAe,MAAM,SASjF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,eAAe,YAAY,CAAC;AAE5B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AAExB,cAAc,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,eAAe,YAAY,CAAC;AAE5B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AAExB,cAAc,gBAAgB,CAAC"}
|
|
@@ -5,13 +5,14 @@ declare const _default: {
|
|
|
5
5
|
'object title placeholder': string;
|
|
6
6
|
'create object label': string;
|
|
7
7
|
'create stack section label': string;
|
|
8
|
-
'binding label': string;
|
|
9
8
|
'binding placeholder': string;
|
|
10
|
-
'
|
|
9
|
+
'function request placeholder': string;
|
|
11
10
|
'deploy label': string;
|
|
12
11
|
'deployed label': string;
|
|
13
12
|
'upload failed label': string;
|
|
14
13
|
'copy link label': string;
|
|
14
|
+
'format label': string;
|
|
15
|
+
'toggle details label': string;
|
|
15
16
|
};
|
|
16
17
|
};
|
|
17
18
|
}[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"translations.d.ts","sourceRoot":"","sources":["../../../src/translations.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"translations.d.ts","sourceRoot":"","sources":["../../../src/translations.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAMA,wBAmBE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/plugin-script",
|
|
3
|
-
"version": "0.6.10-
|
|
3
|
+
"version": "0.6.10-staging.3cfcc89",
|
|
4
4
|
"description": "Braneframe notebook plugin",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -58,38 +58,43 @@
|
|
|
58
58
|
"@codemirror/autocomplete": "^6.18.0",
|
|
59
59
|
"@codemirror/lang-javascript": "^6.2.2",
|
|
60
60
|
"@codemirror/language": "^6.10.2",
|
|
61
|
+
"@codemirror/lint": "^6.8.1",
|
|
61
62
|
"@codemirror/state": "^6.4.1",
|
|
62
63
|
"@codemirror/theme-one-dark": "^6.1.2",
|
|
63
64
|
"@codemirror/view": "^6.29.1",
|
|
64
65
|
"@lezer/common": "^1.2.1",
|
|
65
66
|
"@preact/signals-core": "^1.6.0",
|
|
67
|
+
"@typescript/vfs": "^1.6.0",
|
|
68
|
+
"@valtown/codemirror-ts": "^2.2.0",
|
|
66
69
|
"codemirror": "^6.0.1",
|
|
67
70
|
"esbuild-wasm": "^0.16.14",
|
|
68
71
|
"iso-did": "^1.6.0",
|
|
69
72
|
"lodash.get": "^4.4.2",
|
|
70
|
-
"
|
|
71
|
-
"
|
|
72
|
-
"@dxos/
|
|
73
|
-
"@dxos/
|
|
74
|
-
"@dxos/
|
|
75
|
-
"@dxos/
|
|
76
|
-
"@dxos/
|
|
77
|
-
"@dxos/
|
|
78
|
-
"@dxos/
|
|
79
|
-
"@dxos/
|
|
80
|
-
"@dxos/
|
|
81
|
-
"@dxos/
|
|
82
|
-
"@dxos/plugin-
|
|
83
|
-
"@dxos/plugin-
|
|
84
|
-
"@dxos/plugin-
|
|
85
|
-
"@dxos/plugin-markdown": "0.6.10-
|
|
86
|
-
"@dxos/plugin-
|
|
87
|
-
"@dxos/
|
|
88
|
-
"@dxos/
|
|
89
|
-
"@dxos/
|
|
90
|
-
"@dxos/
|
|
91
|
-
"@dxos/
|
|
92
|
-
"@dxos/
|
|
73
|
+
"prettier": "^3.2.4",
|
|
74
|
+
"typescript": "^5.5.4",
|
|
75
|
+
"@dxos/app-framework": "0.6.10-staging.3cfcc89",
|
|
76
|
+
"@dxos/async": "0.6.10-staging.3cfcc89",
|
|
77
|
+
"@dxos/client-protocol": "0.6.10-staging.3cfcc89",
|
|
78
|
+
"@dxos/client": "0.6.10-staging.3cfcc89",
|
|
79
|
+
"@dxos/crypto": "0.6.10-staging.3cfcc89",
|
|
80
|
+
"@dxos/echo-schema": "0.6.10-staging.3cfcc89",
|
|
81
|
+
"@dxos/invariant": "0.6.10-staging.3cfcc89",
|
|
82
|
+
"@dxos/debug": "0.6.10-staging.3cfcc89",
|
|
83
|
+
"@dxos/log": "0.6.10-staging.3cfcc89",
|
|
84
|
+
"@dxos/keys": "0.6.10-staging.3cfcc89",
|
|
85
|
+
"@dxos/plugin-client": "0.6.10-staging.3cfcc89",
|
|
86
|
+
"@dxos/plugin-explorer": "0.6.10-staging.3cfcc89",
|
|
87
|
+
"@dxos/plugin-graph": "0.6.10-staging.3cfcc89",
|
|
88
|
+
"@dxos/plugin-markdown": "0.6.10-staging.3cfcc89",
|
|
89
|
+
"@dxos/plugin-space": "0.6.10-staging.3cfcc89",
|
|
90
|
+
"@dxos/plugin-stack": "0.6.10-staging.3cfcc89",
|
|
91
|
+
"@dxos/plugin-theme": "0.6.10-staging.3cfcc89",
|
|
92
|
+
"@dxos/protocols": "0.6.10-staging.3cfcc89",
|
|
93
|
+
"@dxos/react-ui-editor": "0.6.10-staging.3cfcc89",
|
|
94
|
+
"@dxos/react-client": "0.6.10-staging.3cfcc89",
|
|
95
|
+
"@dxos/rpc": "0.6.10-staging.3cfcc89",
|
|
96
|
+
"@dxos/rpc-tunnel": "0.6.10-staging.3cfcc89",
|
|
97
|
+
"@dxos/util": "0.6.10-staging.3cfcc89"
|
|
93
98
|
},
|
|
94
99
|
"devDependencies": {
|
|
95
100
|
"@phosphor-icons/react": "^2.1.5",
|
|
@@ -99,20 +104,20 @@
|
|
|
99
104
|
"react": "~18.2.0",
|
|
100
105
|
"react-dom": "~18.2.0",
|
|
101
106
|
"vite": "^5.3.4",
|
|
102
|
-
"@dxos/
|
|
103
|
-
"@dxos/
|
|
104
|
-
"@dxos/random": "0.6.10-
|
|
105
|
-
"@dxos/react-ui-mosaic": "0.6.10-
|
|
106
|
-
"@dxos/react-ui-theme": "0.6.10-
|
|
107
|
-
"@dxos/storybook-utils": "0.6.10-
|
|
107
|
+
"@dxos/echo-generator": "0.6.10-staging.3cfcc89",
|
|
108
|
+
"@dxos/react-ui": "0.6.10-staging.3cfcc89",
|
|
109
|
+
"@dxos/random": "0.6.10-staging.3cfcc89",
|
|
110
|
+
"@dxos/react-ui-mosaic": "0.6.10-staging.3cfcc89",
|
|
111
|
+
"@dxos/react-ui-theme": "0.6.10-staging.3cfcc89",
|
|
112
|
+
"@dxos/storybook-utils": "0.6.10-staging.3cfcc89"
|
|
108
113
|
},
|
|
109
114
|
"optionalDependencies": {
|
|
110
115
|
"@phosphor-icons/react": "^2.1.5",
|
|
111
116
|
"react": "^18.0.0",
|
|
112
117
|
"react-dom": "^18.0.0",
|
|
113
|
-
"@dxos/react-ui": "0.6.10-
|
|
114
|
-
"@dxos/react-ui-mosaic": "0.6.10-
|
|
115
|
-
"@dxos/react-ui-theme": "0.6.10-
|
|
118
|
+
"@dxos/react-ui": "0.6.10-staging.3cfcc89",
|
|
119
|
+
"@dxos/react-ui-mosaic": "0.6.10-staging.3cfcc89",
|
|
120
|
+
"@dxos/react-ui-theme": "0.6.10-staging.3cfcc89"
|
|
116
121
|
},
|
|
117
122
|
"publishConfig": {
|
|
118
123
|
"access": "public"
|
package/src/ScriptPlugin.tsx
CHANGED
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { Code, type IconProps } from '@phosphor-icons/react';
|
|
6
|
+
// @ts-ignore
|
|
7
|
+
import wasmUrl from 'esbuild-wasm/esbuild.wasm?url';
|
|
6
8
|
import React from 'react';
|
|
7
9
|
|
|
8
10
|
import { parseIntentPlugin, type PluginDefinition, resolvePlugin, NavigationAction } from '@dxos/app-framework';
|
|
@@ -13,19 +15,35 @@ import { TextType } from '@dxos/plugin-markdown/types';
|
|
|
13
15
|
import { SpaceAction } from '@dxos/plugin-space';
|
|
14
16
|
import { loadObjectReferences } from '@dxos/react-client/echo';
|
|
15
17
|
|
|
18
|
+
import { initializeBundler } from './bundler';
|
|
19
|
+
import { Compiler } from './compiler';
|
|
16
20
|
import { ScriptEditor } from './components';
|
|
17
21
|
import meta, { SCRIPT_PLUGIN } from './meta';
|
|
18
22
|
import translations from './translations';
|
|
19
23
|
import { FunctionType, ScriptType } from './types';
|
|
20
24
|
import { ScriptAction, type ScriptPluginProvides } from './types';
|
|
21
25
|
|
|
22
|
-
export
|
|
23
|
-
|
|
24
|
-
};
|
|
26
|
+
export const ScriptPlugin = (): PluginDefinition<ScriptPluginProvides> => {
|
|
27
|
+
const compiler = new Compiler();
|
|
25
28
|
|
|
26
|
-
export const ScriptPlugin = ({ containerUrl }: ScriptPluginProps): PluginDefinition<ScriptPluginProvides> => {
|
|
27
29
|
return {
|
|
28
30
|
meta,
|
|
31
|
+
initialize: async () => {
|
|
32
|
+
await compiler.initialize();
|
|
33
|
+
// TODO(wittjosiah): Fetch types for https modules.
|
|
34
|
+
compiler.setFile('/src/typings.d.ts', "declare module 'https://*';");
|
|
35
|
+
// TODO(wittjosiah): Proper function handler types.
|
|
36
|
+
// TODO(wittjosiah): Remove.
|
|
37
|
+
compiler.setFile(
|
|
38
|
+
'/src/runtime.ts',
|
|
39
|
+
`
|
|
40
|
+
export const Filter: any = {};
|
|
41
|
+
export type FunctionHandler = ({ event, context }: { event: any; context: any }) => Promise<Response>;
|
|
42
|
+
export const functionHandler = (handler: FunctionHandler) => handler;
|
|
43
|
+
`,
|
|
44
|
+
);
|
|
45
|
+
await initializeBundler({ wasmUrl });
|
|
46
|
+
},
|
|
29
47
|
provides: {
|
|
30
48
|
metadata: {
|
|
31
49
|
records: {
|
|
@@ -104,7 +122,7 @@ export const ScriptPlugin = ({ containerUrl }: ScriptPluginProps): PluginDefinit
|
|
|
104
122
|
}
|
|
105
123
|
|
|
106
124
|
if (data.object instanceof ScriptType) {
|
|
107
|
-
return <ScriptEditor script={data.object} role={role} />;
|
|
125
|
+
return <ScriptEditor env={compiler.environment} script={data.object} role={role} />;
|
|
108
126
|
}
|
|
109
127
|
|
|
110
128
|
return null;
|
|
@@ -125,10 +143,11 @@ export const ScriptPlugin = ({ containerUrl }: ScriptPluginProps): PluginDefinit
|
|
|
125
143
|
|
|
126
144
|
// TODO(burdon): Import.
|
|
127
145
|
const example = [
|
|
128
|
-
'export default {',
|
|
129
|
-
'
|
|
130
|
-
|
|
131
|
-
'
|
|
132
|
-
'
|
|
146
|
+
'export default async ({ ',
|
|
147
|
+
' event: { data: { request } },',
|
|
148
|
+
' context: { space, ai } ',
|
|
149
|
+
'}) => {',
|
|
150
|
+
" return new Response('Hello World, from ScriptPlugin!');",
|
|
151
|
+
'};',
|
|
133
152
|
'',
|
|
134
153
|
].join('\n');
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2022 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { describe, expect, test } from 'vitest';
|
|
6
|
+
|
|
7
|
+
import { Bundler } from './bundler';
|
|
8
|
+
|
|
9
|
+
describe('Bundler', () => {
|
|
10
|
+
test('Basic', async () => {
|
|
11
|
+
const bundler = new Bundler({ platform: 'node', sandboxedModules: [], remoteModules: {} });
|
|
12
|
+
const result = await bundler.bundle('const x = 100'); // TODO(burdon): Test import.
|
|
13
|
+
expect(result.bundle).to.exist;
|
|
14
|
+
expect(result.error).to.not.exist;
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
test('Import', async () => {
|
|
18
|
+
const bundler = new Bundler({ platform: 'node', sandboxedModules: [], remoteModules: {} });
|
|
19
|
+
const result = await bundler.bundle(`
|
|
20
|
+
import { Filter } from './runtime.js';
|
|
21
|
+
|
|
22
|
+
const query = Filter.typename('dxos.org/type/Example');
|
|
23
|
+
`);
|
|
24
|
+
expect(result.bundle).to.exist;
|
|
25
|
+
expect(result.error).to.not.exist;
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
test('HTTPS Import', async () => {
|
|
29
|
+
const bundler = new Bundler({ platform: 'node', sandboxedModules: [], remoteModules: {} });
|
|
30
|
+
const result = await bundler.bundle(`
|
|
31
|
+
import { Octokit } from 'https://esm.sh/octokit';
|
|
32
|
+
const octokit = new Octokit();
|
|
33
|
+
`);
|
|
34
|
+
expect(result.bundle).to.exist;
|
|
35
|
+
expect(result.error).to.not.exist;
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
test('Error', async () => {
|
|
39
|
+
const bundler = new Bundler({ platform: 'node', sandboxedModules: [], remoteModules: {} });
|
|
40
|
+
const result = await bundler.bundle("import missing from './module'; missing();");
|
|
41
|
+
expect(result.bundle).to.not.exist;
|
|
42
|
+
expect(result.error).to.exist;
|
|
43
|
+
});
|
|
44
|
+
});
|