@dxos/plugin-script 0.6.9-staging.8e43e2a → 0.6.10-main.48c066e

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. package/dist/lib/browser/{ScriptEditor-7XICKICQ.mjs → ScriptEditor-TBM5XWUC.mjs} +73 -11
  2. package/dist/lib/browser/ScriptEditor-TBM5XWUC.mjs.map +7 -0
  3. package/dist/lib/browser/{TypescriptEditor-PIRIDDUS.mjs → TypescriptEditor-XTGRVCMY.mjs} +2 -2
  4. package/dist/lib/browser/{chunk-D4O723CR.mjs → chunk-DX5CSOBP.mjs} +22 -5
  5. package/dist/lib/browser/chunk-DX5CSOBP.mjs.map +7 -0
  6. package/dist/lib/browser/{chunk-SK3L274X.mjs → chunk-K26D5UCK.mjs} +13 -7
  7. package/dist/lib/browser/{chunk-SK3L274X.mjs.map → chunk-K26D5UCK.mjs.map} +3 -3
  8. package/dist/lib/browser/chunk-RHEZ5LUU.mjs +229 -0
  9. package/dist/lib/browser/chunk-RHEZ5LUU.mjs.map +7 -0
  10. package/dist/lib/browser/edge/index.mjs +1 -1
  11. package/dist/lib/browser/index.mjs +79 -187
  12. package/dist/lib/browser/index.mjs.map +4 -4
  13. package/dist/lib/browser/meta.json +1 -1
  14. package/dist/lib/node/{ScriptEditor-M7KZ2CRS.cjs → ScriptEditor-VWT74T2V.cjs} +78 -18
  15. package/dist/lib/node/ScriptEditor-VWT74T2V.cjs.map +7 -0
  16. package/dist/lib/node/{TypescriptEditor-OTWJUIWB.cjs → TypescriptEditor-CRONCQSI.cjs} +7 -7
  17. package/dist/lib/node/{TypescriptEditor-OTWJUIWB.cjs.map → TypescriptEditor-CRONCQSI.cjs.map} +2 -2
  18. package/dist/lib/node/chunk-4GTXIELQ.cjs +252 -0
  19. package/dist/lib/node/chunk-4GTXIELQ.cjs.map +7 -0
  20. package/dist/lib/node/{chunk-ITLHJMWP.cjs → chunk-RXI576K3.cjs} +24 -7
  21. package/dist/lib/node/chunk-RXI576K3.cjs.map +7 -0
  22. package/dist/lib/node/{chunk-X6A3D4PD.cjs → chunk-VXR2JE2I.cjs} +16 -10
  23. package/dist/lib/node/{chunk-X6A3D4PD.cjs.map → chunk-VXR2JE2I.cjs.map} +3 -3
  24. package/dist/lib/node/edge/index.cjs +8 -8
  25. package/dist/lib/node/edge/index.cjs.map +1 -1
  26. package/dist/lib/node/index.cjs +76 -186
  27. package/dist/lib/node/index.cjs.map +4 -4
  28. package/dist/lib/node/meta.json +1 -1
  29. package/dist/types/src/ScriptPlugin.d.ts +1 -4
  30. package/dist/types/src/ScriptPlugin.d.ts.map +1 -1
  31. package/dist/types/src/bundler/bundler.d.ts +39 -0
  32. package/dist/types/src/bundler/bundler.d.ts.map +1 -0
  33. package/dist/types/src/bundler/bundler.test.d.ts +2 -0
  34. package/dist/types/src/bundler/bundler.test.d.ts.map +1 -0
  35. package/dist/types/src/bundler/index.d.ts +2 -0
  36. package/dist/types/src/bundler/index.d.ts.map +1 -0
  37. package/dist/types/src/compiler/compiler.browser.test.d.ts +2 -0
  38. package/dist/types/src/compiler/compiler.browser.test.d.ts.map +1 -0
  39. package/dist/types/src/compiler/compiler.d.ts +9 -34
  40. package/dist/types/src/compiler/compiler.d.ts.map +1 -1
  41. package/dist/types/src/components/ScriptBlock/FrameContainer/FrameContainer.d.ts +2 -2
  42. package/dist/types/src/components/ScriptBlock/FrameContainer/FrameContainer.d.ts.map +1 -1
  43. package/dist/types/src/components/ScriptBlock/ScriptBlock.d.ts.map +1 -1
  44. package/dist/types/src/components/ScriptBlock/ScriptBlock.stories.d.ts +1 -1
  45. package/dist/types/src/components/ScriptBlock/ScriptBlock.stories.d.ts.map +1 -1
  46. package/dist/types/src/components/ScriptBlock/Splitter/Splitter.stories.d.ts +1 -1
  47. package/dist/types/src/components/ScriptBlock/Splitter/Splitter.stories.d.ts.map +1 -1
  48. package/dist/types/src/components/ScriptEditor.d.ts +3 -2
  49. package/dist/types/src/components/ScriptEditor.d.ts.map +1 -1
  50. package/dist/types/src/components/Toolbar.d.ts +2 -1
  51. package/dist/types/src/components/Toolbar.d.ts.map +1 -1
  52. package/dist/types/src/components/Toolbar.stories.d.ts +2 -2
  53. package/dist/types/src/components/Toolbar.stories.d.ts.map +1 -1
  54. package/dist/types/src/components/TypescriptEditor.d.ts +3 -1
  55. package/dist/types/src/components/TypescriptEditor.d.ts.map +1 -1
  56. package/dist/types/src/components/TypescriptEditor.stories.d.ts +2 -2
  57. package/dist/types/src/components/TypescriptEditor.stories.d.ts.map +1 -1
  58. package/dist/types/src/components/index.d.ts +2 -2
  59. package/dist/types/src/components/index.d.ts.map +1 -1
  60. package/dist/types/src/edge/functions.d.ts.map +1 -1
  61. package/dist/types/src/index.d.ts +1 -0
  62. package/dist/types/src/index.d.ts.map +1 -1
  63. package/dist/types/src/translations.d.ts +1 -0
  64. package/dist/types/src/translations.d.ts.map +1 -1
  65. package/dist/types/src/types/script.d.ts +4 -4
  66. package/package.json +38 -33
  67. package/src/ScriptPlugin.tsx +23 -5
  68. package/src/bundler/bundler.test.ts +44 -0
  69. package/src/bundler/bundler.ts +246 -0
  70. package/src/bundler/index.ts +5 -0
  71. package/src/compiler/compiler.browser.test.ts +18 -0
  72. package/src/compiler/compiler.ts +31 -190
  73. package/src/compiler/index.ts +1 -1
  74. package/src/components/ScriptBlock/FrameContainer/FrameContainer.tsx +2 -2
  75. package/src/components/ScriptBlock/ScriptBlock.stories.tsx +1 -1
  76. package/src/components/ScriptBlock/ScriptBlock.tsx +10 -7
  77. package/src/components/ScriptBlock/Splitter/Splitter.stories.tsx +1 -1
  78. package/src/components/ScriptEditor.tsx +51 -5
  79. package/src/components/Toolbar.stories.tsx +1 -1
  80. package/src/components/Toolbar.tsx +28 -1
  81. package/src/components/TypescriptEditor.stories.tsx +1 -1
  82. package/src/components/TypescriptEditor.tsx +18 -4
  83. package/src/edge/functions.ts +8 -2
  84. package/src/index.ts +1 -0
  85. package/src/translations.ts +1 -0
  86. package/dist/lib/browser/ScriptEditor-7XICKICQ.mjs.map +0 -7
  87. package/dist/lib/browser/chunk-D4O723CR.mjs.map +0 -7
  88. package/dist/lib/node/ScriptEditor-M7KZ2CRS.cjs.map +0 -7
  89. package/dist/lib/node/chunk-ITLHJMWP.cjs.map +0 -7
  90. package/dist/types/src/compiler/compiler.test.d.ts +0 -2
  91. package/dist/types/src/compiler/compiler.test.d.ts.map +0 -1
  92. package/src/compiler/compiler.test.ts +0 -17
  93. /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,2 @@
1
+ export {};
2
+ //# sourceMappingURL=bundler.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bundler.test.d.ts","sourceRoot":"","sources":["../../../../src/bundler/bundler.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export * from './bundler';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -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,2 @@
1
+ export {};
2
+ //# sourceMappingURL=compiler.browser.test.d.ts.map
@@ -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 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 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
- constructor(_options: CompilerOptions);
28
- compile(source: string): Promise<CompilerResult>;
29
- analyzeImports(result: BuildResult): Import[];
30
- analyzeSourceFileImports(code: string): {
31
- defaultImportName: string;
32
- namedImports: string[];
33
- wildcardImportName: string;
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,EAAE,KAAK,YAAY,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAqB,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAKnE,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,cAAc,GAAG;IAC3B,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,eAAe,GAAG;IAC5B,QAAQ,EAAE,YAAY,CAAC,UAAU,CAAC,CAAC;IACnC,eAAe,EAAE,MAAM,EAAE,CAAC;CAC3B,CAAC;AAGF,eAAO,MAAM,kBAAkB,YAAmB;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,kBAIpE,CAAC;AAEF;;GAEG;AACH,qBAAa,QAAQ;IACP,OAAO,CAAC,QAAQ,CAAC,QAAQ;gBAAR,QAAQ,EAAE,eAAe;IAEhD,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IA6EtD,cAAc,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,EAAE;IA2B7C,wBAAwB,CAAC,IAAI,EAAE,MAAM;;;;;;;CAatC"}
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"}
@@ -1,8 +1,8 @@
1
1
  import React from 'react';
2
- import { type CompilerResult } from '../../../compiler';
2
+ import { type BundlerResult } from '../../../bundler';
3
3
  export type FrameContainerProps = {
4
4
  containerUrl: string;
5
- result: CompilerResult;
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,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAExD,MAAM,MAAM,mBAAmB,GAAG;IAChC,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,cAAc,CAAC;IACvB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,cAAc,oCAA4C,mBAAmB,sBAyDzF,CAAC"}
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,sBA+ElB,CAAC"}
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,4 +1,4 @@
1
- import '@dxosTheme';
1
+ import '@dxos-theme';
2
2
  import React from 'react';
3
3
  declare const _default: {
4
4
  title: string;
@@ -1 +1 @@
1
- {"version":3,"file":"ScriptBlock.stories.d.ts","sourceRoot":"","sources":["../../../../../src/components/ScriptBlock/ScriptBlock.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,YAAY,CAAC;AAEpB,OAAO,KAA6B,MAAM,OAAO,CAAC;;;;;;;;;;AA+ClD,wBAQE;AAEF,eAAO,MAAM,OAAO,IAAK,CAAC"}
1
+ {"version":3,"file":"ScriptBlock.stories.d.ts","sourceRoot":"","sources":["../../../../../src/components/ScriptBlock/ScriptBlock.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,aAAa,CAAC;AAErB,OAAO,KAA6B,MAAM,OAAO,CAAC;;;;;;;;;;AA+ClD,wBAQE;AAEF,eAAO,MAAM,OAAO,IAAK,CAAC"}
@@ -1,4 +1,4 @@
1
- import '@dxosTheme';
1
+ import '@dxos-theme';
2
2
  import React from 'react';
3
3
  declare const _default: {
4
4
  title: string;
@@ -1 +1 @@
1
- {"version":3,"file":"Splitter.stories.d.ts","sourceRoot":"","sources":["../../../../../../src/components/ScriptBlock/Splitter/Splitter.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,YAAY,CAAC;AAEpB,OAAO,KAAmB,MAAM,OAAO,CAAC;;;;;;;;;AAqBxC,wBAOE;AAEF,eAAO,MAAM,OAAO,IAAK,CAAC"}
1
+ {"version":3,"file":"Splitter.stories.d.ts","sourceRoot":"","sources":["../../../../../../src/components/ScriptBlock/Splitter/Splitter.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,aAAa,CAAC;AAErB,OAAO,KAAmB,MAAM,OAAO,CAAC;;;;;;;;;AAqBxC,wBAOE;AAEF,eAAO,MAAM,OAAO,IAAK,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":"AAKA,OAAO,KAAyC,MAAM,OAAO,CAAC;AAmB9D,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,CAAC;AAEF,eAAO,MAAM,YAAY,qBAAsB,iBAAiB,sBA+F/D,CAAC;AAEF,eAAe,YAAY,CAAC"}
1
+ {"version":3,"file":"ScriptEditor.d.ts","sourceRoot":"","sources":["../../../../src/components/ScriptEditor.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAyC,MAAM,OAAO,CAAC;AAW9D,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,sBAyIpE,CAAC;AAEF,eAAe,YAAY,CAAC"}
@@ -2,10 +2,11 @@ import React from 'react';
2
2
  export type ToolbarProps = {
3
3
  binding: string;
4
4
  onBindingChange: (binding: string) => void;
5
+ onFormat?: () => Promise<void>;
5
6
  deployed?: boolean;
6
7
  onDeploy?: () => Promise<void>;
7
8
  functionUrl?: string;
8
9
  error?: string;
9
10
  };
10
- export declare const Toolbar: ({ binding: _binding, onBindingChange, deployed, onDeploy, functionUrl, error, }: ToolbarProps) => React.JSX.Element;
11
+ export declare const Toolbar: ({ binding: _binding, onBindingChange, onFormat, deployed, onDeploy, functionUrl, error, }: ToolbarProps) => React.JSX.Element;
11
12
  //# sourceMappingURL=Toolbar.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Toolbar.d.ts","sourceRoot":"","sources":["../../../../src/components/Toolbar.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAe3D,MAAM,MAAM,YAAY,GAAG;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3C,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,eAAO,MAAM,OAAO,oFAOjB,YAAY,sBAkJd,CAAC"}
1
+ {"version":3,"file":"Toolbar.d.ts","sourceRoot":"","sources":["../../../../src/components/Toolbar.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAe3D,MAAM,MAAM,YAAY,GAAG;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3C,QAAQ,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,eAAO,MAAM,OAAO,8FAQjB,YAAY,sBAiKd,CAAC"}
@@ -1,7 +1,7 @@
1
- import '@dxosTheme';
1
+ import '@dxos-theme';
2
2
  declare const _default: {
3
3
  title: string;
4
- component: ({ binding: _binding, onBindingChange, deployed, onDeploy, functionUrl, error, }: import("./Toolbar").ToolbarProps) => import("react").JSX.Element;
4
+ component: ({ binding: _binding, onBindingChange, onFormat, deployed, onDeploy, functionUrl, error, }: import("./Toolbar").ToolbarProps) => import("react").JSX.Element;
5
5
  parameters: {
6
6
  layout: string;
7
7
  };
@@ -1 +1 @@
1
- {"version":3,"file":"Toolbar.stories.d.ts","sourceRoot":"","sources":["../../../../src/components/Toolbar.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,YAAY,CAAC;;;;;;;;AAMpB,wBAME;AAEF,eAAO,MAAM,OAAO;;;;;CAAmD,CAAC"}
1
+ {"version":3,"file":"Toolbar.stories.d.ts","sourceRoot":"","sources":["../../../../src/components/Toolbar.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,aAAa,CAAC;;;;;;;;AAMrB,wBAME;AAEF,eAAO,MAAM,OAAO;;;;;CAAmD,CAAC"}
@@ -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,EAQL,KAAK,kBAAkB,EACxB,MAAM,uBAAuB,CAAC;AAG/B,MAAM,MAAM,qBAAqB,GAAG;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,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,qFAQ1B,qBAAqB,sBA8BvB,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
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"}
@@ -1,8 +1,8 @@
1
- import '@dxosTheme';
1
+ 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 +1 @@
1
- {"version":3,"file":"TypescriptEditor.stories.d.ts","sourceRoot":"","sources":["../../../../src/components/TypescriptEditor.stories.tsx"],"names":[],"mappings":"AAeA,OAAO,YAAY,CAAC;AAEpB,OAAO,KAAkB,MAAM,OAAO,CAAC;;;;;;;;;AAoCvC,wBAOE;AAEF,eAAO,MAAM,OAAO,IAAK,CAAC"}
1
+ {"version":3,"file":"TypescriptEditor.stories.d.ts","sourceRoot":"","sources":["../../../../src/components/TypescriptEditor.stories.tsx"],"names":[],"mappings":"AAeA,OAAO,aAAa,CAAC;AAErB,OAAO,KAAkB,MAAM,OAAO,CAAC;;;;;;;;;AAoCvC,wBAOE;AAEF,eAAO,MAAM,OAAO,IAAK,CAAC"}
@@ -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,gHAA6C,CAAC;AACvE,eAAO,MAAM,gBAAgB,wLAAiD,CAAC"}
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"}
@@ -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;AAQF,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
+ {"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;AAcF,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,5 +1,6 @@
1
1
  import { ScriptPlugin } from './ScriptPlugin';
2
2
  export default ScriptPlugin;
3
+ export * from './bundler';
3
4
  export * from './compiler';
4
5
  export * from './components';
5
6
  export * from './types';
@@ -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"}
@@ -12,6 +12,7 @@ declare const _default: {
12
12
  'deployed label': string;
13
13
  'upload failed label': string;
14
14
  'copy link label': string;
15
+ 'format label': string;
15
16
  };
16
17
  };
17
18
  }[];
@@ -1 +1 @@
1
- {"version":3,"file":"translations.d.ts","sourceRoot":"","sources":["../../../src/translations.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAMA,wBAkBE"}
1
+ {"version":3,"file":"translations.d.ts","sourceRoot":"","sources":["../../../src/translations.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAMA,wBAmBE"}
@@ -1,11 +1,11 @@
1
1
  import { ref, S } from '@dxos/echo-schema';
2
2
  declare const ScriptType_base: import("@dxos/echo-schema").AbstractTypedObject<{
3
+ name?: string | undefined;
3
4
  source: import("@dxos/echo-schema").Ref<{
4
5
  content: string;
5
6
  } & {
6
7
  id: string;
7
8
  }>;
8
- name?: string | undefined;
9
9
  changed?: boolean | undefined;
10
10
  } & {
11
11
  id: string;
@@ -21,18 +21,18 @@ declare const ScriptType_base: import("@dxos/echo-schema").AbstractTypedObject<{
21
21
  export declare class ScriptType extends ScriptType_base {
22
22
  }
23
23
  declare const FunctionType_base: import("@dxos/echo-schema").AbstractTypedObject<{
24
+ version: number;
24
25
  source?: import("@dxos/echo-schema").Ref<{
26
+ name?: string | undefined;
25
27
  source: import("@dxos/echo-schema").Ref<{
26
28
  content: string;
27
29
  } & {
28
30
  id: string;
29
31
  }>;
30
- name?: string | undefined;
31
32
  changed?: boolean | undefined;
32
33
  } & {
33
34
  id: string;
34
35
  }>;
35
- version: number;
36
36
  binding?: string | undefined;
37
37
  } & {
38
38
  id: string;
@@ -40,12 +40,12 @@ declare const FunctionType_base: import("@dxos/echo-schema").AbstractTypedObject
40
40
  version: typeof S.Number;
41
41
  binding: S.optional<typeof S.String>;
42
42
  source: S.optional<ref<{
43
+ name?: string | undefined;
43
44
  source: import("@dxos/echo-schema").Ref<{
44
45
  content: string;
45
46
  } & {
46
47
  id: string;
47
48
  }>;
48
- name?: string | undefined;
49
49
  changed?: boolean | undefined;
50
50
  } & {
51
51
  id: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/plugin-script",
3
- "version": "0.6.9-staging.8e43e2a",
3
+ "version": "0.6.10-main.48c066e",
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
- "@dxos/app-framework": "0.6.9-staging.8e43e2a",
71
- "@dxos/async": "0.6.9-staging.8e43e2a",
72
- "@dxos/client": "0.6.9-staging.8e43e2a",
73
- "@dxos/client-protocol": "0.6.9-staging.8e43e2a",
74
- "@dxos/debug": "0.6.9-staging.8e43e2a",
75
- "@dxos/echo-schema": "0.6.9-staging.8e43e2a",
76
- "@dxos/crypto": "0.6.9-staging.8e43e2a",
77
- "@dxos/invariant": "0.6.9-staging.8e43e2a",
78
- "@dxos/keys": "0.6.9-staging.8e43e2a",
79
- "@dxos/log": "0.6.9-staging.8e43e2a",
80
- "@dxos/plugin-client": "0.6.9-staging.8e43e2a",
81
- "@dxos/plugin-explorer": "0.6.9-staging.8e43e2a",
82
- "@dxos/plugin-graph": "0.6.9-staging.8e43e2a",
83
- "@dxos/plugin-space": "0.6.9-staging.8e43e2a",
84
- "@dxos/plugin-markdown": "0.6.9-staging.8e43e2a",
85
- "@dxos/plugin-theme": "0.6.9-staging.8e43e2a",
86
- "@dxos/protocols": "0.6.9-staging.8e43e2a",
87
- "@dxos/plugin-stack": "0.6.9-staging.8e43e2a",
88
- "@dxos/react-client": "0.6.9-staging.8e43e2a",
89
- "@dxos/react-ui-editor": "0.6.9-staging.8e43e2a",
90
- "@dxos/rpc": "0.6.9-staging.8e43e2a",
91
- "@dxos/util": "0.6.9-staging.8e43e2a",
92
- "@dxos/rpc-tunnel": "0.6.9-staging.8e43e2a"
73
+ "prettier": "^3.2.4",
74
+ "typescript": "^5.5.4",
75
+ "@dxos/async": "0.6.10-main.48c066e",
76
+ "@dxos/client": "0.6.10-main.48c066e",
77
+ "@dxos/app-framework": "0.6.10-main.48c066e",
78
+ "@dxos/client-protocol": "0.6.10-main.48c066e",
79
+ "@dxos/debug": "0.6.10-main.48c066e",
80
+ "@dxos/crypto": "0.6.10-main.48c066e",
81
+ "@dxos/echo-schema": "0.6.10-main.48c066e",
82
+ "@dxos/invariant": "0.6.10-main.48c066e",
83
+ "@dxos/log": "0.6.10-main.48c066e",
84
+ "@dxos/keys": "0.6.10-main.48c066e",
85
+ "@dxos/plugin-client": "0.6.10-main.48c066e",
86
+ "@dxos/plugin-explorer": "0.6.10-main.48c066e",
87
+ "@dxos/plugin-space": "0.6.10-main.48c066e",
88
+ "@dxos/plugin-graph": "0.6.10-main.48c066e",
89
+ "@dxos/plugin-stack": "0.6.10-main.48c066e",
90
+ "@dxos/plugin-markdown": "0.6.10-main.48c066e",
91
+ "@dxos/plugin-theme": "0.6.10-main.48c066e",
92
+ "@dxos/protocols": "0.6.10-main.48c066e",
93
+ "@dxos/react-client": "0.6.10-main.48c066e",
94
+ "@dxos/rpc": "0.6.10-main.48c066e",
95
+ "@dxos/react-ui-editor": "0.6.10-main.48c066e",
96
+ "@dxos/rpc-tunnel": "0.6.10-main.48c066e",
97
+ "@dxos/util": "0.6.10-main.48c066e"
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/echo-generator": "0.6.9-staging.8e43e2a",
103
- "@dxos/random": "0.6.9-staging.8e43e2a",
104
- "@dxos/react-ui-mosaic": "0.6.9-staging.8e43e2a",
105
- "@dxos/react-ui": "0.6.9-staging.8e43e2a",
106
- "@dxos/react-ui-theme": "0.6.9-staging.8e43e2a",
107
- "@dxos/storybook-utils": "0.6.9-staging.8e43e2a"
107
+ "@dxos/random": "0.6.10-main.48c066e",
108
+ "@dxos/echo-generator": "0.6.10-main.48c066e",
109
+ "@dxos/react-ui": "0.6.10-main.48c066e",
110
+ "@dxos/react-ui-theme": "0.6.10-main.48c066e",
111
+ "@dxos/storybook-utils": "0.6.10-main.48c066e",
112
+ "@dxos/react-ui-mosaic": "0.6.10-main.48c066e"
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.9-staging.8e43e2a",
114
- "@dxos/react-ui-theme": "0.6.9-staging.8e43e2a",
115
- "@dxos/react-ui-mosaic": "0.6.9-staging.8e43e2a"
118
+ "@dxos/react-ui": "0.6.10-main.48c066e",
119
+ "@dxos/react-ui-mosaic": "0.6.10-main.48c066e",
120
+ "@dxos/react-ui-theme": "0.6.10-main.48c066e"
116
121
  },
117
122
  "publishConfig": {
118
123
  "access": "public"
@@ -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 type ScriptPluginProps = {
23
- containerUrl: string;
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;
@@ -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
+ });