@dxos/plugin-script 0.7.4 → 0.7.5-labs.401163d
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/{AutomationPanel-PMTZROAZ.mjs → AutomationPanel-J3SZ5L3Y.mjs} +4 -11
- package/dist/lib/browser/AutomationPanel-J3SZ5L3Y.mjs.map +7 -0
- package/dist/lib/browser/ScriptContainer-JHAVO2KA.mjs +713 -0
- package/dist/lib/browser/ScriptContainer-JHAVO2KA.mjs.map +7 -0
- package/dist/lib/browser/artifact-YCIVHFSS.mjs +243 -0
- package/dist/lib/browser/artifact-YCIVHFSS.mjs.map +7 -0
- package/dist/lib/browser/{chunk-K7KY6YMG.mjs → chunk-45LXDWNF.mjs} +2 -2
- 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-N46LE7FS.mjs +40 -0
- package/dist/lib/browser/chunk-N46LE7FS.mjs.map +7 -0
- package/dist/lib/browser/chunk-UDLKK74O.mjs +69 -0
- package/dist/lib/browser/chunk-UDLKK74O.mjs.map +7 -0
- package/dist/lib/browser/chunk-WAXHENSY.mjs +236 -0
- package/dist/lib/browser/chunk-WAXHENSY.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 +111 -359
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/intent-resolver-RV3YXIVN.mjs +45 -0
- package/dist/lib/browser/intent-resolver-RV3YXIVN.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/react-surface-ETY4XKFG.mjs +65 -0
- package/dist/lib/browser/react-surface-ETY4XKFG.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 +10 -0
- package/dist/lib/node/{AutomationPanel-AAGQREH7.cjs → AutomationPanel-4M55FURO.cjs} +16 -17
- package/dist/lib/node/AutomationPanel-4M55FURO.cjs.map +7 -0
- package/dist/lib/node/ScriptContainer-EBIT6CT4.cjs +719 -0
- package/dist/lib/node/ScriptContainer-EBIT6CT4.cjs.map +7 -0
- package/dist/lib/node/artifact-IPGGY2Z2.cjs +262 -0
- package/dist/lib/node/artifact-IPGGY2Z2.cjs.map +7 -0
- package/dist/lib/node/chunk-3VDHZ54A.cjs +264 -0
- package/dist/lib/node/chunk-3VDHZ54A.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-DJGLGRQV.cjs +60 -0
- package/dist/lib/node/chunk-DJGLGRQV.cjs.map +7 -0
- package/dist/lib/node/{chunk-4INUJLXL.cjs → chunk-IID7WUQS.cjs} +6 -6
- package/dist/lib/node/chunk-JKPNBFU2.cjs +77 -0
- package/dist/lib/node/chunk-JKPNBFU2.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 +108 -347
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/intent-resolver-WFLQNAID.cjs +59 -0
- package/dist/lib/node/intent-resolver-WFLQNAID.cjs.map +7 -0
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/react-surface-OIQJFA7P.cjs +84 -0
- package/dist/lib/node/react-surface-OIQJFA7P.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/index.cjs → types.cjs} +6 -8
- package/dist/lib/node/types.cjs.map +7 -0
- package/dist/lib/node-esm/{AutomationPanel-ETQEDY5I.mjs → AutomationPanel-W6SKG35R.mjs} +4 -11
- package/dist/lib/node-esm/AutomationPanel-W6SKG35R.mjs.map +7 -0
- package/dist/lib/node-esm/ScriptContainer-QVFTCAML.mjs +714 -0
- package/dist/lib/node-esm/ScriptContainer-QVFTCAML.mjs.map +7 -0
- package/dist/lib/node-esm/artifact-7H4HGX5W.mjs +245 -0
- package/dist/lib/node-esm/artifact-7H4HGX5W.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-5CEKSMA5.mjs +71 -0
- package/dist/lib/node-esm/chunk-5CEKSMA5.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-OFYGBUNI.mjs → chunk-CGF7EOGD.mjs} +2 -2
- 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-WCAUDRF4.mjs +237 -0
- package/dist/lib/node-esm/chunk-WCAUDRF4.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 +111 -359
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/intent-resolver-CYT6IYYH.mjs +46 -0
- package/dist/lib/node-esm/intent-resolver-CYT6IYYH.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/react-surface-N67GNKC2.mjs +66 -0
- package/dist/lib/node-esm/react-surface-N67GNKC2.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 +11 -0
- package/dist/types/src/ScriptPlugin.d.ts +1 -3
- package/dist/types/src/ScriptPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/artifact.d.ts +11 -0
- package/dist/types/src/capabilities/artifact.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 +2 -2
- package/dist/types/src/components/AutomationPanel/AutomationPanel.d.ts.map +1 -1
- package/dist/types/src/components/FrameContainer/FrameContainer.d.ts +2 -2
- package/dist/types/src/components/FrameContainer/FrameContainer.d.ts.map +1 -1
- package/dist/types/src/components/ScriptContainer.d.ts +10 -2
- package/dist/types/src/components/ScriptContainer.d.ts.map +1 -1
- package/dist/types/src/components/ScriptSettings/ScriptSettings.d.ts.map +1 -1
- package/dist/types/src/components/ScriptSettingsPanel.d.ts +1 -1
- package/dist/types/src/components/ScriptSettingsPanel.d.ts.map +1 -1
- package/dist/types/src/components/ScriptToolbar/ScriptToolbar.d.ts +11 -0
- package/dist/types/src/components/ScriptToolbar/ScriptToolbar.d.ts.map +1 -0
- package/dist/types/src/components/{Toolbar/Toolbar.stories.d.ts → ScriptToolbar/ScriptToolbar.stories.d.ts} +1 -1
- package/dist/types/src/components/ScriptToolbar/ScriptToolbar.stories.d.ts.map +1 -0
- package/dist/types/src/components/ScriptToolbar/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 -2
- package/dist/types/src/components/TypescriptEditor/TypescriptEditor.d.ts.map +1 -1
- package/dist/types/src/components/TypescriptEditor/TypescriptEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +1 -1
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/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/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 +6 -0
- package/dist/types/src/templates/forex-effect.d.ts.map +1 -0
- package/dist/types/src/templates/forex.d.ts +1 -1
- 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 +54 -0
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types.d.ts +30 -0
- package/dist/types/src/types.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -0
- package/package.json +45 -55
- package/src/ScriptPlugin.tsx +62 -145
- package/src/capabilities/artifact.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/AutomationPanel/AutomationPanel.tsx +2 -4
- 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 +140 -53
- 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/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/discord.ts +88 -0
- package/src/templates/echo.ts +5 -1
- package/src/templates/email.ts +26 -23
- package/src/templates/forex-effect.ts +44 -0
- package/src/templates/forex.ts +21 -13
- package/src/{templates.ts → templates/index.ts} +20 -5
- package/src/translations.ts +20 -1
- package/src/types.ts +39 -0
- package/dist/lib/browser/AutomationPanel-PMTZROAZ.mjs.map +0 -7
- package/dist/lib/browser/ScriptContainer-RYZFYCNK.mjs +0 -425
- package/dist/lib/browser/ScriptContainer-RYZFYCNK.mjs.map +0 -7
- package/dist/lib/browser/chunk-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-QFZUFT5G.mjs +0 -48
- package/dist/lib/browser/chunk-QFZUFT5G.mjs.map +0 -7
- package/dist/lib/browser/chunk-U3OP64V4.mjs +0 -123
- package/dist/lib/browser/chunk-U3OP64V4.mjs.map +0 -7
- package/dist/lib/browser/edge/index.mjs +0 -19
- package/dist/lib/browser/meta.mjs +0 -9
- package/dist/lib/browser/types/index.mjs +0 -12
- package/dist/lib/browser/types/index.mjs.map +0 -7
- package/dist/lib/node/AutomationPanel-AAGQREH7.cjs.map +0 -7
- package/dist/lib/node/ScriptContainer-FZ44UIRC.cjs +0 -427
- package/dist/lib/node/ScriptContainer-FZ44UIRC.cjs.map +0 -7
- package/dist/lib/node/chunk-6LYX73ZT.cjs.map +0 -7
- package/dist/lib/node/chunk-CS25QNKZ.cjs +0 -151
- package/dist/lib/node/chunk-CS25QNKZ.cjs.map +0 -7
- package/dist/lib/node/chunk-DQYAU2CJ.cjs +0 -67
- package/dist/lib/node/chunk-DQYAU2CJ.cjs.map +0 -7
- package/dist/lib/node/chunk-WPP65EYS.cjs +0 -298
- package/dist/lib/node/chunk-WPP65EYS.cjs.map +0 -7
- package/dist/lib/node/edge/index.cjs +0 -41
- package/dist/lib/node/edge/index.cjs.map +0 -7
- package/dist/lib/node/meta.cjs.map +0 -7
- package/dist/lib/node/types/index.cjs.map +0 -7
- package/dist/lib/node-esm/AutomationPanel-ETQEDY5I.mjs.map +0 -7
- package/dist/lib/node-esm/ScriptContainer-3PKDW34A.mjs +0 -426
- package/dist/lib/node-esm/ScriptContainer-3PKDW34A.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-36DLLQ6E.mjs +0 -125
- package/dist/lib/node-esm/chunk-36DLLQ6E.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-4SRPREUK.mjs +0 -288
- package/dist/lib/node-esm/chunk-4SRPREUK.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-GMVPKT6A.mjs +0 -49
- package/dist/lib/node-esm/chunk-GMVPKT6A.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-SLTZMY34.mjs.map +0 -7
- package/dist/lib/node-esm/edge/index.mjs +0 -20
- package/dist/lib/node-esm/edge/index.mjs.map +0 -7
- package/dist/lib/node-esm/meta.mjs +0 -10
- package/dist/lib/node-esm/meta.mjs.map +0 -7
- package/dist/lib/node-esm/types/index.mjs +0 -13
- package/dist/lib/node-esm/types/index.mjs.map +0 -7
- package/dist/types/src/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/edge/functions.d.ts +0 -25
- package/dist/types/src/edge/functions.d.ts.map +0 -1
- package/dist/types/src/edge/index.d.ts +0 -2
- package/dist/types/src/edge/index.d.ts.map +0 -1
- package/dist/types/src/templates.d.ts.map +0 -1
- package/dist/types/src/types/index.d.ts +0 -3
- package/dist/types/src/types/index.d.ts.map +0 -1
- package/dist/types/src/types/schema.d.ts +0 -71
- package/dist/types/src/types/schema.d.ts.map +0 -1
- package/dist/types/src/types/types.d.ts +0 -8
- package/dist/types/src/types/types.d.ts.map +0 -1
- package/src/bundler/bundler.test.ts +0 -54
- package/src/bundler/bundler.ts +0 -250
- package/src/components/ScriptBlock/ScriptBlock.stories.tsx +0 -52
- package/src/components/ScriptBlock/ScriptBlock.tsx +0 -102
- package/src/components/ScriptBlock/index.ts +0 -5
- package/src/components/ScriptEditor.tsx +0 -191
- package/src/components/Toolbar/Toolbar.tsx +0 -177
- package/src/components/Toolbar/index.ts +0 -5
- package/src/edge/functions.ts +0 -116
- package/src/edge/index.ts +0 -7
- package/src/types/index.ts +0 -6
- package/src/types/schema.ts +0 -44
- package/src/types/types.ts +0 -29
- /package/dist/lib/browser/{chunk-K7KY6YMG.mjs.map → chunk-45LXDWNF.mjs.map} +0 -0
- /package/dist/lib/browser/{edge/index.mjs.map → types.mjs.map} +0 -0
- /package/dist/lib/node/{chunk-4INUJLXL.cjs.map → chunk-IID7WUQS.cjs.map} +0 -0
- /package/dist/lib/node-esm/{chunk-OFYGBUNI.mjs.map → chunk-CGF7EOGD.mjs.map} +0 -0
- /package/dist/lib/{browser/meta.mjs.map → node-esm/types.mjs.map} +0 -0
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { type ThemedClassName } from '@dxos/react-ui';
|
|
3
|
-
import { type Template } from '../../templates';
|
|
4
|
-
export type ToolbarProps = ThemedClassName<{
|
|
5
|
-
deployed?: boolean;
|
|
6
|
-
error?: string;
|
|
7
|
-
functionUrl?: string;
|
|
8
|
-
onDeploy?: () => Promise<void>;
|
|
9
|
-
onFormat?: () => Promise<void>;
|
|
10
|
-
} & TemplateSelectProps & ViewSelectorProps>;
|
|
11
|
-
export declare const Toolbar: ({ classNames, deployed, error, functionUrl, view, templates, onDeploy, onFormat, onViewChange, onTemplateSelect, }: ToolbarProps) => React.JSX.Element;
|
|
12
|
-
export type ViewType = 'editor' | 'split' | 'preview';
|
|
13
|
-
export type TemplateSelectProps = {
|
|
14
|
-
templates?: Template[];
|
|
15
|
-
onTemplateSelect?: (id: string) => void;
|
|
16
|
-
};
|
|
17
|
-
export declare const TemplateSelect: ({ templates, onTemplateSelect }: TemplateSelectProps) => React.JSX.Element;
|
|
18
|
-
export type ViewSelectorProps = {
|
|
19
|
-
view?: ViewType;
|
|
20
|
-
onViewChange?: (view: ViewType) => void;
|
|
21
|
-
};
|
|
22
|
-
export declare const ViewSelector: ({ view, onViewChange }: ViewSelectorProps) => React.JSX.Element;
|
|
23
|
-
//# sourceMappingURL=Toolbar.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Toolbar.d.ts","sourceRoot":"","sources":["../../../../../src/components/Toolbar/Toolbar.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,OAAO,EAIL,KAAK,eAAe,EAOrB,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAEhD,MAAM,MAAM,YAAY,GAAG,eAAe,CACxC;IACE,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/B,QAAQ,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAChC,GAAG,mBAAmB,GACrB,iBAAiB,CACpB,CAAC;AAEF,eAAO,MAAM,OAAO,uHAWjB,YAAY,sBA4Dd,CAAC;AA0BF,MAAM,MAAM,QAAQ,GAAG,QAAQ,GAAG,OAAO,GAAG,SAAS,CAAC;AAEtD,MAAM,MAAM,mBAAmB,GAAG;IAChC,SAAS,CAAC,EAAE,QAAQ,EAAE,CAAC;IACvB,gBAAgB,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;CACzC,CAAC;AAEF,eAAO,MAAM,cAAc,oCAA0C,mBAAmB,sBAkBvF,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,IAAI,CAAC;CACzC,CAAC;AAEF,eAAO,MAAM,YAAY,2BAA4B,iBAAiB,sBAcrE,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Toolbar.stories.d.ts","sourceRoot":"","sources":["../../../../../src/components/Toolbar/Toolbar.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,aAAa,CAAC;AAErB,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAO7C,eAAO,MAAM,OAAO;;;;;;;;CAQnB,CAAC;AAEF,QAAA,MAAM,IAAI,EAAE,IAIX,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/Toolbar/index.ts"],"names":[],"mappings":"AAIA,cAAc,WAAW,CAAC"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { type DID } from 'iso-did/types';
|
|
2
|
-
import { type Client } from '@dxos/client';
|
|
3
|
-
import { type ObjectMeta } from '@dxos/echo-schema';
|
|
4
|
-
import type { PublicKey, SpaceId } from '@dxos/keys';
|
|
5
|
-
import { type UploadFunctionResponseBody } from '@dxos/protocols';
|
|
6
|
-
export declare const FUNCTIONS_PRESET_META_KEY = "dxos.org/service/function-preset";
|
|
7
|
-
export type UploadWorkerArgs = {
|
|
8
|
-
client: Client;
|
|
9
|
-
name?: string;
|
|
10
|
-
source: string;
|
|
11
|
-
version: string;
|
|
12
|
-
functionId?: string;
|
|
13
|
-
spaceId: SpaceId;
|
|
14
|
-
};
|
|
15
|
-
export declare const uploadWorkerFunction: ({ client, name, version, source, spaceId, functionId, }: UploadWorkerArgs) => Promise<UploadFunctionResponseBody>;
|
|
16
|
-
export declare const getUserFunctionUrlInMetadata: (meta: ObjectMeta) => string | undefined;
|
|
17
|
-
export declare const setUserFunctionUrlInMetadata: (meta: ObjectMeta, functionUrl: string) => void;
|
|
18
|
-
export declare const getInvocationUrl: (functionUrl: string, edgeUrl: string, options?: InvocationOptions) => string;
|
|
19
|
-
export declare const incrementSemverPatch: (version: string) => string;
|
|
20
|
-
export declare const publicKeyToDid: (key: PublicKey) => DID;
|
|
21
|
-
export type InvocationOptions = {
|
|
22
|
-
spaceId?: SpaceId;
|
|
23
|
-
subjectId?: string;
|
|
24
|
-
};
|
|
25
|
-
//# sourceMappingURL=functions.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"functions.d.ts","sourceRoot":"","sources":["../../../../src/edge/functions.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,GAAG,EAAE,MAAM,eAAe,CAAC;AAEzC,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAGpD,OAAO,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAErD,OAAO,EAAE,KAAK,0BAA0B,EAAE,MAAM,iBAAiB,CAAC;AAKlE,eAAO,MAAM,yBAAyB,qCAAqC,CAAC;AAE5E,MAAM,MAAM,gBAAgB,GAAG;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,eAAO,MAAM,oBAAoB,4DAO9B,gBAAgB,KAAG,OAAO,CAAC,0BAA0B,CAiBvD,CAAC;AAEF,eAAO,MAAM,4BAA4B,SAAU,UAAU,uBAE5D,CAAC;AAEF,eAAO,MAAM,4BAA4B,SAAU,UAAU,eAAe,MAAM,SASjF,CAAC;AAEF,eAAO,MAAM,gBAAgB,gBAAiB,MAAM,WAAW,MAAM,YAAW,iBAAiB,WAUhG,CAAC;AAsBF,eAAO,MAAM,oBAAoB,YAAa,MAAM,KAAG,MAKtD,CAAC;AAEF,eAAO,MAAM,cAAc,QAAS,SAAS,KAAG,GAE/C,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/edge/index.ts"],"names":[],"mappings":"AAMA,cAAc,aAAa,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../../../src/templates.ts"],"names":[],"mappings":"AAiBA,MAAM,MAAM,QAAQ,GAAG;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,QAAQ,EA6B/B,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/types/index.ts"],"names":[],"mappings":"AAIA,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC"}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { JsonSchemaType, ref, S } from '@dxos/echo-schema';
|
|
2
|
-
declare const ScriptType_base: import("@dxos/echo-schema").AbstractTypedObject<{
|
|
3
|
-
name?: string | undefined;
|
|
4
|
-
description?: string | undefined;
|
|
5
|
-
changed?: boolean | undefined;
|
|
6
|
-
source: import("@dxos/echo-schema").Ref<{
|
|
7
|
-
content: string;
|
|
8
|
-
} & {
|
|
9
|
-
id: string;
|
|
10
|
-
}>;
|
|
11
|
-
} & {
|
|
12
|
-
id: string;
|
|
13
|
-
}, S.Struct.Encoded<{
|
|
14
|
-
name: S.optional<typeof S.String>;
|
|
15
|
-
description: S.optional<typeof S.String>;
|
|
16
|
-
changed: S.optional<typeof S.Boolean>;
|
|
17
|
-
source: ref<{
|
|
18
|
-
content: string;
|
|
19
|
-
} & {
|
|
20
|
-
id: string;
|
|
21
|
-
}>;
|
|
22
|
-
}>>;
|
|
23
|
-
/**
|
|
24
|
-
* Source script.
|
|
25
|
-
*/
|
|
26
|
-
export declare class ScriptType extends ScriptType_base {
|
|
27
|
-
}
|
|
28
|
-
declare const FunctionType_base: import("@dxos/echo-schema").AbstractTypedObject<{
|
|
29
|
-
name: string;
|
|
30
|
-
source?: import("@dxos/echo-schema").Ref<{
|
|
31
|
-
name?: string | undefined;
|
|
32
|
-
description?: string | undefined;
|
|
33
|
-
changed?: boolean | undefined;
|
|
34
|
-
source: import("@dxos/echo-schema").Ref<{
|
|
35
|
-
content: string;
|
|
36
|
-
} & {
|
|
37
|
-
id: string;
|
|
38
|
-
}>;
|
|
39
|
-
} & {
|
|
40
|
-
id: string;
|
|
41
|
-
}>;
|
|
42
|
-
version: string;
|
|
43
|
-
inputSchema?: JsonSchemaType | undefined;
|
|
44
|
-
binding?: string | undefined;
|
|
45
|
-
} & {
|
|
46
|
-
id: string;
|
|
47
|
-
}, S.Struct.Encoded<{
|
|
48
|
-
name: typeof S.NonEmptyString;
|
|
49
|
-
version: typeof S.String;
|
|
50
|
-
source: S.optional<ref<{
|
|
51
|
-
name?: string | undefined;
|
|
52
|
-
description?: string | undefined;
|
|
53
|
-
changed?: boolean | undefined;
|
|
54
|
-
source: import("@dxos/echo-schema").Ref<{
|
|
55
|
-
content: string;
|
|
56
|
-
} & {
|
|
57
|
-
id: string;
|
|
58
|
-
}>;
|
|
59
|
-
} & {
|
|
60
|
-
id: string;
|
|
61
|
-
}>>;
|
|
62
|
-
inputSchema: S.optional<S.Schema<JsonSchemaType, JsonSchemaType, never>>;
|
|
63
|
-
binding: S.optional<typeof S.String>;
|
|
64
|
-
}>>;
|
|
65
|
-
/**
|
|
66
|
-
* Function deployment.
|
|
67
|
-
*/
|
|
68
|
-
export declare class FunctionType extends FunctionType_base {
|
|
69
|
-
}
|
|
70
|
-
export {};
|
|
71
|
-
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../../src/types/schema.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAE,GAAG,EAAE,CAAC,EAAe,MAAM,mBAAmB,CAAC;;;;;;;;;;;;;;;;;;;;;;AAGxE;;GAEG;AACH,qBAAa,UAAW,SAAQ,eAW9B;CAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEL;;GAEG;AAEH,qBAAa,YAAa,SAAQ,iBAgBhC;CAAG"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { GraphBuilderProvides, IntentResolverProvides, MetadataRecordsProvides, SettingsProvides, SurfaceProvides, TranslationsProvides } from '@dxos/app-framework';
|
|
2
|
-
import { type SchemaProvides } from '@dxos/plugin-space';
|
|
3
|
-
export declare enum ScriptAction {
|
|
4
|
-
CREATE = "dxos.org/plugin/script/create"
|
|
5
|
-
}
|
|
6
|
-
export type ScriptSettingsProps = {};
|
|
7
|
-
export type ScriptPluginProvides = GraphBuilderProvides & IntentResolverProvides & MetadataRecordsProvides & SchemaProvides & SettingsProvides<ScriptSettingsProps> & SurfaceProvides & TranslationsProvides;
|
|
8
|
-
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/types/types.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,oBAAoB,EACpB,sBAAsB,EACtB,uBAAuB,EACvB,gBAAgB,EAChB,eAAe,EACf,oBAAoB,EACrB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAIzD,oBAAY,YAAY;IACtB,MAAM,kCAA4B;CACnC;AAED,MAAM,MAAM,mBAAmB,GAAG,EAAE,CAAC;AAErC,MAAM,MAAM,oBAAoB,GAAG,oBAAoB,GACrD,sBAAsB,GACtB,uBAAuB,GACvB,cAAc,GACd,gBAAgB,CAAC,mBAAmB,CAAC,GACrC,eAAe,GACf,oBAAoB,CAAC"}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2022 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
// @ts-ignore
|
|
6
|
-
import wasmUrl from 'esbuild-wasm/esbuild.wasm?url';
|
|
7
|
-
import { beforeAll, describe, expect, test } from 'vitest';
|
|
8
|
-
|
|
9
|
-
import { isNode } from '@dxos/util';
|
|
10
|
-
|
|
11
|
-
import { Bundler, initializeBundler } from './bundler';
|
|
12
|
-
|
|
13
|
-
describe('Bundler', () => {
|
|
14
|
-
beforeAll(async () => {
|
|
15
|
-
if (!isNode()) {
|
|
16
|
-
await initializeBundler({ wasmUrl });
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
test('Basic', async () => {
|
|
21
|
-
const bundler = new Bundler({ platform: 'node', sandboxedModules: [], remoteModules: {} });
|
|
22
|
-
const result = await bundler.bundle('const x = 100'); // TODO(burdon): Test import.
|
|
23
|
-
expect(result.bundle).to.exist;
|
|
24
|
-
expect(result.error).to.not.exist;
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
test('Import', async () => {
|
|
28
|
-
const bundler = new Bundler({ platform: 'node', sandboxedModules: [], remoteModules: {} });
|
|
29
|
-
const result = await bundler.bundle(`
|
|
30
|
-
import { Filter } from './runtime.js';
|
|
31
|
-
|
|
32
|
-
const query = Filter.typename('dxos.org/type/Example');
|
|
33
|
-
`);
|
|
34
|
-
expect(result.bundle).to.exist;
|
|
35
|
-
expect(result.error).to.not.exist;
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
test('HTTPS Import', async () => {
|
|
39
|
-
const bundler = new Bundler({ platform: 'node', sandboxedModules: [], remoteModules: {} });
|
|
40
|
-
const result = await bundler.bundle(`
|
|
41
|
-
import { Octokit } from 'https://esm.sh/octokit';
|
|
42
|
-
const octokit = new Octokit();
|
|
43
|
-
`);
|
|
44
|
-
expect(result.bundle).to.exist;
|
|
45
|
-
expect(result.error).to.not.exist;
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
test('Error', async () => {
|
|
49
|
-
const bundler = new Bundler({ platform: 'node', sandboxedModules: [], remoteModules: {} });
|
|
50
|
-
const result = await bundler.bundle("import missing from './module'; missing();");
|
|
51
|
-
expect(result.bundle).to.not.exist;
|
|
52
|
-
expect(result.error).to.exist;
|
|
53
|
-
});
|
|
54
|
-
});
|
package/src/bundler/bundler.ts
DELETED
|
@@ -1,250 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2023 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { type BuildOptions } from 'esbuild';
|
|
6
|
-
import { build, initialize, type BuildResult, type Plugin } from 'esbuild-wasm';
|
|
7
|
-
|
|
8
|
-
import { subtleCrypto } from '@dxos/crypto';
|
|
9
|
-
import { invariant } from '@dxos/invariant';
|
|
10
|
-
import { log } from '@dxos/log';
|
|
11
|
-
|
|
12
|
-
export type Import = {
|
|
13
|
-
moduleUrl: string;
|
|
14
|
-
defaultImport: boolean;
|
|
15
|
-
namedImports: string[];
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export type BundlerResult = {
|
|
19
|
-
timestamp: number;
|
|
20
|
-
sourceHash: Buffer;
|
|
21
|
-
imports?: Import[];
|
|
22
|
-
bundle?: string;
|
|
23
|
-
error?: any;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export type BundlerOptions = {
|
|
27
|
-
platform: BuildOptions['platform'];
|
|
28
|
-
sandboxedModules: string[];
|
|
29
|
-
remoteModules: Record<string, string>;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
let initialized: Promise<void>;
|
|
33
|
-
export const initializeBundler = async (options: { wasmUrl: string }) => {
|
|
34
|
-
await (initialized ??= initialize({
|
|
35
|
-
wasmURL: options.wasmUrl,
|
|
36
|
-
}));
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* ESBuild bundler.
|
|
41
|
-
*/
|
|
42
|
-
export class Bundler {
|
|
43
|
-
constructor(private readonly _options: BundlerOptions) {}
|
|
44
|
-
|
|
45
|
-
async bundle(source: string): Promise<BundlerResult> {
|
|
46
|
-
const { sandboxedModules: providedModules, ...options } = this._options;
|
|
47
|
-
|
|
48
|
-
const createResult = async (result?: Partial<BundlerResult>) => {
|
|
49
|
-
return {
|
|
50
|
-
timestamp: Date.now(),
|
|
51
|
-
sourceHash: Buffer.from(await subtleCrypto.digest('SHA-256', Buffer.from(source))),
|
|
52
|
-
...result,
|
|
53
|
-
};
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
if (this._options.platform === 'browser') {
|
|
57
|
-
invariant(initialized, 'Compiler not initialized.');
|
|
58
|
-
await initialized;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
const imports = analyzeSourceFileImports(source);
|
|
62
|
-
|
|
63
|
-
// https://esbuild.github.io/api/#build
|
|
64
|
-
try {
|
|
65
|
-
const result = await build({
|
|
66
|
-
platform: options.platform,
|
|
67
|
-
conditions: ['workerd', 'browser'],
|
|
68
|
-
metafile: true,
|
|
69
|
-
write: false,
|
|
70
|
-
entryPoints: ['memory:main.tsx'],
|
|
71
|
-
bundle: true,
|
|
72
|
-
format: 'esm',
|
|
73
|
-
plugins: [
|
|
74
|
-
{
|
|
75
|
-
name: 'memory',
|
|
76
|
-
setup: (build) => {
|
|
77
|
-
build.onResolve({ filter: /^\.\/runtime\.js$/ }, ({ path }) => {
|
|
78
|
-
return { path, external: true };
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
build.onResolve({ filter: /^dxos:functions$/ }, ({ path }) => {
|
|
82
|
-
return { path: './runtime.js', external: true };
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
build.onResolve({ filter: /^memory:/ }, ({ path }) => {
|
|
86
|
-
return { path: path.split(':')[1], namespace: 'memory' };
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
build.onLoad({ filter: /.*/, namespace: 'memory' }, ({ path }) => {
|
|
90
|
-
if (path === 'main.tsx') {
|
|
91
|
-
return {
|
|
92
|
-
contents: source,
|
|
93
|
-
loader: 'tsx',
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
for (const module of providedModules) {
|
|
99
|
-
build.onResolve({ filter: new RegExp(`^${module}$`) }, ({ path }) => {
|
|
100
|
-
return { path, namespace: 'injected-module' };
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
build.onLoad({ filter: /.*/, namespace: 'injected-module' }, ({ path }) => {
|
|
105
|
-
const namedImports = imports.find((entry) => entry.moduleIdentifier === path)?.namedImports ?? [];
|
|
106
|
-
return {
|
|
107
|
-
contents: `
|
|
108
|
-
const { ${namedImports.join(',')} } = window.__DXOS_SANDBOX_MODULES__[${JSON.stringify(path)}];
|
|
109
|
-
export { ${namedImports.join(',')} };
|
|
110
|
-
export default window.__DXOS_SANDBOX_MODULES__[${JSON.stringify(path)}].default;
|
|
111
|
-
`,
|
|
112
|
-
loader: 'tsx',
|
|
113
|
-
};
|
|
114
|
-
});
|
|
115
|
-
},
|
|
116
|
-
},
|
|
117
|
-
httpPlugin,
|
|
118
|
-
],
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
log('compile complete', result.metafile);
|
|
122
|
-
|
|
123
|
-
return await createResult({
|
|
124
|
-
imports: this.analyzeImports(result),
|
|
125
|
-
bundle: result.outputFiles![0].text,
|
|
126
|
-
});
|
|
127
|
-
} catch (err) {
|
|
128
|
-
return await createResult({ error: err });
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
// TODO(dmaretskyi): In the future we can replace the compiler with SWC with plugins running in WASM.
|
|
133
|
-
analyzeImports(result: BuildResult): Import[] {
|
|
134
|
-
invariant(result.outputFiles);
|
|
135
|
-
|
|
136
|
-
// TODO(dmaretskyi): Support import aliases and wildcard imports.
|
|
137
|
-
const parsedImports = allMatches(IMPORT_REGEX, result.outputFiles[0].text);
|
|
138
|
-
return Object.values(result.metafile!.outputs)[0].imports.map((entry): Import => {
|
|
139
|
-
const namedImports: string[] = [];
|
|
140
|
-
|
|
141
|
-
const parsedImport = parsedImports.find((capture) => capture?.[4] === entry.path);
|
|
142
|
-
if (parsedImport?.[2]) {
|
|
143
|
-
NAMED_IMPORTS_REGEX.lastIndex = 0;
|
|
144
|
-
const namedImportsMatch = NAMED_IMPORTS_REGEX.exec(parsedImport[2]);
|
|
145
|
-
if (namedImportsMatch) {
|
|
146
|
-
namedImportsMatch[1].split(',').forEach((importName) => {
|
|
147
|
-
namedImports.push(importName.trim());
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
return {
|
|
153
|
-
moduleUrl: entry.path,
|
|
154
|
-
defaultImport: !!parsedImport?.[1],
|
|
155
|
-
namedImports,
|
|
156
|
-
};
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
analyzeSourceFileImports(code: string) {
|
|
161
|
-
// TODO(dmaretskyi): Support import aliases and wildcard imports.
|
|
162
|
-
const parsedImports = allMatches(IMPORT_REGEX, code);
|
|
163
|
-
return parsedImports.map((capture) => {
|
|
164
|
-
return {
|
|
165
|
-
defaultImportName: capture[1],
|
|
166
|
-
namedImports: capture[2]?.split(',').map((importName) => importName.trim()),
|
|
167
|
-
wildcardImportName: capture[3],
|
|
168
|
-
moduleIdentifier: capture[4],
|
|
169
|
-
quotes: capture[5],
|
|
170
|
-
};
|
|
171
|
-
});
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
// https://regex101.com/r/FEN5ks/1
|
|
176
|
-
// https://stackoverflow.com/a/73265022
|
|
177
|
-
// $1 = default import name (can be non-existent)
|
|
178
|
-
// $2 = destructured exports (can be non-existent)
|
|
179
|
-
// $3 = wildcard import name (can be non-existent)
|
|
180
|
-
// $4 = module identifier
|
|
181
|
-
// $5 = quotes used (either ' or ")
|
|
182
|
-
const IMPORT_REGEX =
|
|
183
|
-
/import(?:(?:(?:[ \n\t]+([^ *\n\t{},]+)[ \n\t]*(?:,|[ \n\t]+))?([ \n\t]*{(?:[ \n\t]*[^ \n\t"'{}]+[ \n\t]*,?)+})?[ \n\t]*)|[ \n\t]*\*[ \n\t]*as[ \n\t]+([^ \n\t{}]+)[ \n\t]+)from[ \n\t]*(?:['"])([^'"\n]+)(['"])/gm;
|
|
184
|
-
|
|
185
|
-
const NAMED_IMPORTS_REGEX = /[ \n\t]*{((?:[ \n\t]*[^ \n\t"'{}]+[ \n\t]*,?)+)}[ \n\t]*/gm;
|
|
186
|
-
|
|
187
|
-
const allMatches = (regex: RegExp, str: string) => {
|
|
188
|
-
regex.lastIndex = 0;
|
|
189
|
-
|
|
190
|
-
let match;
|
|
191
|
-
const matches = [];
|
|
192
|
-
while ((match = regex.exec(str))) {
|
|
193
|
-
matches.push(match);
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
return matches;
|
|
197
|
-
};
|
|
198
|
-
|
|
199
|
-
type ParsedImport = {
|
|
200
|
-
defaultImportName?: string;
|
|
201
|
-
namedImports: string[];
|
|
202
|
-
wildcardImportName?: string;
|
|
203
|
-
moduleIdentifier: string;
|
|
204
|
-
quotes: string;
|
|
205
|
-
};
|
|
206
|
-
|
|
207
|
-
const analyzeSourceFileImports = (code: string): ParsedImport[] => {
|
|
208
|
-
// TODO(dmaretskyi): Support import aliases and wildcard imports.
|
|
209
|
-
const parsedImports = allMatches(IMPORT_REGEX, code);
|
|
210
|
-
return parsedImports.map((capture) => {
|
|
211
|
-
return {
|
|
212
|
-
defaultImportName: capture[1],
|
|
213
|
-
namedImports: capture[2]
|
|
214
|
-
?.trim()
|
|
215
|
-
.slice(1, -1)
|
|
216
|
-
.split(',')
|
|
217
|
-
.map((importName) => importName.trim()),
|
|
218
|
-
wildcardImportName: capture[3],
|
|
219
|
-
moduleIdentifier: capture[4],
|
|
220
|
-
quotes: capture[5],
|
|
221
|
-
};
|
|
222
|
-
});
|
|
223
|
-
};
|
|
224
|
-
|
|
225
|
-
const httpPlugin: Plugin = {
|
|
226
|
-
name: 'http',
|
|
227
|
-
setup: (build) => {
|
|
228
|
-
// Intercept import paths starting with "http:" and "https:" so esbuild doesn't attempt to map them to a file system location.
|
|
229
|
-
// Tag them with the "http-url" namespace to associate them with this plugin.
|
|
230
|
-
build.onResolve({ filter: /^https?:\/\// }, (args) => ({
|
|
231
|
-
path: args.path,
|
|
232
|
-
namespace: 'http-url',
|
|
233
|
-
}));
|
|
234
|
-
|
|
235
|
-
// We also want to intercept all import paths inside downloaded files and resolve them against the original URL.
|
|
236
|
-
// All of these files will be in the "http-url" namespace.
|
|
237
|
-
// Make sure to keep the newly resolved URL in the "http-url" namespace so imports inside it will also be resolved as URLs recursively.
|
|
238
|
-
build.onResolve({ filter: /.*/, namespace: 'http-url' }, (args) => ({
|
|
239
|
-
path: new URL(args.path, args.importer).toString(),
|
|
240
|
-
namespace: 'http-url',
|
|
241
|
-
}));
|
|
242
|
-
|
|
243
|
-
// When a URL is loaded, we want to actually download the content from the internet.
|
|
244
|
-
// This has just enough logic to be able to handle the example import from unpkg.com but in reality this would probably need to be more complex.
|
|
245
|
-
build.onLoad({ filter: /.*/, namespace: 'http-url' }, async (args) => {
|
|
246
|
-
const response = await fetch(args.path);
|
|
247
|
-
return { contents: await response.text(), loader: 'jsx' };
|
|
248
|
-
});
|
|
249
|
-
},
|
|
250
|
-
};
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2023 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import '@dxos-theme';
|
|
6
|
-
|
|
7
|
-
import { type Meta } from '@storybook/react';
|
|
8
|
-
import React, { useMemo } from 'react';
|
|
9
|
-
|
|
10
|
-
import { TextType } from '@dxos/plugin-markdown/types';
|
|
11
|
-
import { create, createObject } from '@dxos/react-client/echo';
|
|
12
|
-
import { withClientProvider } from '@dxos/react-client/testing';
|
|
13
|
-
import { withLayout, withTheme } from '@dxos/storybook-utils';
|
|
14
|
-
|
|
15
|
-
import { ScriptBlock } from './ScriptBlock';
|
|
16
|
-
import { ScriptType } from '../../types';
|
|
17
|
-
// @ts-ignore
|
|
18
|
-
import mainUrl from '../FrameContainer/frame?url';
|
|
19
|
-
|
|
20
|
-
const typename = 'example.com/type/contact';
|
|
21
|
-
|
|
22
|
-
const code = [
|
|
23
|
-
"import { Filter, useQuery, useSpaces} from '@dxos/react-client/echo';",
|
|
24
|
-
"import { Chart, Explorer, Globe } from '@dxos/plugin-explorer';",
|
|
25
|
-
'',
|
|
26
|
-
'export default () => {',
|
|
27
|
-
' const spaces = useSpaces();',
|
|
28
|
-
' const space = spaces[1]',
|
|
29
|
-
` const objects = useQuery(space, Filter.typename('${typename}'));`,
|
|
30
|
-
' return <Chart items={objects} accessor={object => ({ x: object.lat, y: object.lng })} />',
|
|
31
|
-
'}',
|
|
32
|
-
].join('\n');
|
|
33
|
-
|
|
34
|
-
const DefaultStory = () => {
|
|
35
|
-
// TODO(burdon): Review what's the right way to create automerge-backed objects.
|
|
36
|
-
const object = useMemo(() => createObject(create(ScriptType, { source: create(TextType, { content: code }) })), []);
|
|
37
|
-
|
|
38
|
-
// TODO(dmaretskyi): Not sure how to provide `containerUrl` here since the html now lives in composer-app.
|
|
39
|
-
// TODO(burdon): Normalize html/frame.tsx with composer-app to test locally.
|
|
40
|
-
return <ScriptBlock script={object} containerUrl={mainUrl} />;
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
export const Default = {};
|
|
44
|
-
|
|
45
|
-
const meta: Meta = {
|
|
46
|
-
title: 'plugins/plugin-script/ScriptBlock',
|
|
47
|
-
component: ScriptBlock,
|
|
48
|
-
render: DefaultStory,
|
|
49
|
-
decorators: [withClientProvider({ createSpace: true }), withTheme, withLayout({ fullscreen: true, tooltips: true })],
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
export default meta;
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2023 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
// @ts-ignore
|
|
6
|
-
import wasmUrl from 'esbuild-wasm/esbuild.wasm?url';
|
|
7
|
-
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
|
8
|
-
|
|
9
|
-
import { createDocAccessor, DocAccessor } from '@dxos/react-client/echo';
|
|
10
|
-
import { Toolbar, Button, Icon } from '@dxos/react-ui';
|
|
11
|
-
|
|
12
|
-
import { Bundler, type BundlerResult, initializeBundler } from '../../bundler';
|
|
13
|
-
import { type ScriptType } from '../../types';
|
|
14
|
-
import { FrameContainer } from '../FrameContainer';
|
|
15
|
-
import { ScriptEditor } from '../ScriptEditor';
|
|
16
|
-
|
|
17
|
-
// Keep in sync with packages/apps/composer-app/script-frame/main.tsx .
|
|
18
|
-
const PROVIDED_MODULES = [
|
|
19
|
-
'react',
|
|
20
|
-
'react-dom/client',
|
|
21
|
-
'@dxos/client',
|
|
22
|
-
'@dxos/react-client',
|
|
23
|
-
'@dxos/react-client/echo',
|
|
24
|
-
'@dxos/plugin-explorer',
|
|
25
|
-
];
|
|
26
|
-
|
|
27
|
-
export type ScriptBlockProps = {
|
|
28
|
-
script: ScriptType;
|
|
29
|
-
hideSelector?: boolean;
|
|
30
|
-
|
|
31
|
-
// Url to the page used to host the script in the iframe.
|
|
32
|
-
containerUrl: string;
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* @deprecated
|
|
37
|
-
*/
|
|
38
|
-
// TODO(burdon): Cache compiled results in context.
|
|
39
|
-
export const ScriptBlock = ({ script, hideSelector, containerUrl }: ScriptBlockProps) => {
|
|
40
|
-
const source = useMemo(() => script.source && createDocAccessor(script.source, ['content']), [script.source]);
|
|
41
|
-
const [result, setResult] = useState<BundlerResult>();
|
|
42
|
-
const bundler = useMemo(
|
|
43
|
-
() => new Bundler({ platform: 'browser', sandboxedModules: PROVIDED_MODULES, remoteModules: {} }),
|
|
44
|
-
[],
|
|
45
|
-
);
|
|
46
|
-
useEffect(() => {
|
|
47
|
-
// TODO(burdon): Create useCompiler hook (with initialization).
|
|
48
|
-
void initializeBundler({ wasmUrl });
|
|
49
|
-
}, []);
|
|
50
|
-
useEffect(() => {
|
|
51
|
-
// TODO(burdon): Throttle and listen for update.
|
|
52
|
-
const t = setTimeout(async () => {
|
|
53
|
-
if (!source) {
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
const result = await bundler.bundle(DocAccessor.getValue(source));
|
|
58
|
-
setResult(result);
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
return () => clearTimeout(t);
|
|
62
|
-
}, [source]);
|
|
63
|
-
|
|
64
|
-
const handleExec = useCallback(
|
|
65
|
-
async (auto = true) => {
|
|
66
|
-
if (!source) {
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
const result = await bundler.bundle(DocAccessor.getValue(source));
|
|
70
|
-
setResult(result);
|
|
71
|
-
},
|
|
72
|
-
[source],
|
|
73
|
-
);
|
|
74
|
-
|
|
75
|
-
return (
|
|
76
|
-
<div className='flex flex-col grow overflow-hidden'>
|
|
77
|
-
{!hideSelector && (
|
|
78
|
-
<Toolbar.Root>
|
|
79
|
-
<div className='grow' />
|
|
80
|
-
{result?.bundle && !result?.error && (
|
|
81
|
-
<div title={String(result.error)}>
|
|
82
|
-
<Icon icon='ph--check--regular' size={5} classNames='text-green-500' />
|
|
83
|
-
</div>
|
|
84
|
-
)}
|
|
85
|
-
{result?.error && (
|
|
86
|
-
<div title={String(result.error)}>
|
|
87
|
-
<Icon icon='ph--warning--regular' size={5} classNames='text-orange-500' />
|
|
88
|
-
</div>
|
|
89
|
-
)}
|
|
90
|
-
<Button variant='ghost' onClick={() => handleExec()}>
|
|
91
|
-
<Icon icon='ph--play--regular' size={5} />
|
|
92
|
-
</Button>
|
|
93
|
-
</Toolbar.Root>
|
|
94
|
-
)}
|
|
95
|
-
|
|
96
|
-
<div className='flex'>
|
|
97
|
-
<ScriptEditor script={script} />
|
|
98
|
-
{result && <FrameContainer key={script.id} result={result} containerUrl={containerUrl} />}
|
|
99
|
-
</div>
|
|
100
|
-
</div>
|
|
101
|
-
);
|
|
102
|
-
};
|