@dxos/plugin-script 0.7.5-main.9cb18ac → 0.7.5-main.9d2a38b
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/{AutomationPanel-RFQAQ7NF.mjs → AutomationPanel-OOIRJFPJ.mjs} +3 -3
- package/dist/lib/browser/ScriptContainer-T2AOMDT3.mjs +685 -0
- package/dist/lib/browser/ScriptContainer-T2AOMDT3.mjs.map +7 -0
- package/dist/lib/browser/{chunk-C7VBULMK.mjs → chunk-5BU5ERNU.mjs} +3 -3
- package/dist/lib/browser/chunk-5BU5ERNU.mjs.map +7 -0
- package/dist/lib/browser/chunk-REL2R7SB.mjs +52 -0
- package/dist/lib/browser/chunk-REL2R7SB.mjs.map +7 -0
- package/dist/lib/browser/{chunk-4UTRJLQ3.mjs → chunk-SDHKTS6H.mjs} +2 -51
- package/dist/lib/browser/{chunk-4UTRJLQ3.mjs.map → chunk-SDHKTS6H.mjs.map} +4 -4
- package/dist/lib/browser/chunk-SIOGRRPF.mjs +224 -0
- package/dist/lib/browser/chunk-SIOGRRPF.mjs.map +7 -0
- package/dist/lib/browser/{chunk-K7KY6YMG.mjs → chunk-SJ4J527G.mjs} +2 -2
- package/dist/lib/browser/chunk-XPGBHZ3L.mjs +40 -0
- package/dist/lib/browser/chunk-XPGBHZ3L.mjs.map +7 -0
- package/dist/lib/browser/chunk-ZM6T4HPR.mjs +15 -0
- package/dist/lib/browser/chunk-ZM6T4HPR.mjs.map +7 -0
- package/dist/lib/browser/compiler-HT53ILG7.mjs +84 -0
- package/dist/lib/browser/compiler-HT53ILG7.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +112 -288
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/intent-resolver-YPHT6HDZ.mjs +42 -0
- package/dist/lib/browser/intent-resolver-YPHT6HDZ.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/react-surface-GAWVYTJ5.mjs +67 -0
- package/dist/lib/browser/react-surface-GAWVYTJ5.mjs.map +7 -0
- package/dist/lib/browser/settings-YQQEU3DF.mjs +24 -0
- package/dist/lib/browser/settings-YQQEU3DF.mjs.map +7 -0
- package/dist/lib/browser/types.mjs +6 -4
- package/dist/lib/node/{AutomationPanel-5CJEF4MI.cjs → AutomationPanel-EPRDDR3A.cjs} +8 -8
- package/dist/lib/node/ScriptContainer-BV56I4OL.cjs +689 -0
- package/dist/lib/node/ScriptContainer-BV56I4OL.cjs.map +7 -0
- package/dist/lib/node/chunk-5V3XGLTR.cjs +252 -0
- package/dist/lib/node/chunk-5V3XGLTR.cjs.map +7 -0
- package/dist/lib/node/{chunk-PK3OQP5L.cjs → chunk-6VKZJ4MH.cjs} +26 -11
- package/dist/lib/node/chunk-6VKZJ4MH.cjs.map +7 -0
- package/dist/lib/node/{meta.cjs → chunk-A2DI2G4D.cjs} +12 -8
- package/dist/lib/node/chunk-A2DI2G4D.cjs.map +7 -0
- package/dist/lib/node/{chunk-4INUJLXL.cjs → chunk-DQRAVZM7.cjs} +6 -6
- package/dist/lib/node/{chunk-6LYX73ZT.cjs → chunk-EFTZN5X7.cjs} +7 -7
- package/dist/lib/node/chunk-EFTZN5X7.cjs.map +7 -0
- package/dist/lib/node/{chunk-WPP65EYS.cjs → chunk-T4TXCRN5.cjs} +6 -44
- package/dist/lib/node/chunk-T4TXCRN5.cjs.map +7 -0
- package/dist/lib/node/chunk-TJ4BTPOS.cjs +64 -0
- package/dist/lib/node/chunk-TJ4BTPOS.cjs.map +7 -0
- package/dist/lib/node/compiler-457ZR24G.cjs +104 -0
- package/dist/lib/node/compiler-457ZR24G.cjs.map +7 -0
- package/dist/lib/node/index.cjs +105 -276
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/intent-resolver-SUAPE7H3.cjs +56 -0
- package/dist/lib/node/intent-resolver-SUAPE7H3.cjs.map +7 -0
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/react-surface-OMBMSFZT.cjs +86 -0
- package/dist/lib/node/react-surface-OMBMSFZT.cjs.map +7 -0
- package/dist/lib/node/settings-NGHDYAVK.cjs +38 -0
- package/dist/lib/node/settings-NGHDYAVK.cjs.map +7 -0
- package/dist/lib/node/types.cjs +6 -4
- package/dist/lib/node/types.cjs.map +2 -2
- package/dist/lib/node-esm/{AutomationPanel-7Y6REBNJ.mjs → AutomationPanel-DMLAGQS5.mjs} +3 -3
- package/dist/lib/node-esm/ScriptContainer-3S5VHJVR.mjs +686 -0
- package/dist/lib/node-esm/ScriptContainer-3S5VHJVR.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-675XSDRN.mjs +16 -0
- package/dist/lib/node-esm/chunk-675XSDRN.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-SLTZMY34.mjs → chunk-BHP545D7.mjs} +3 -3
- package/dist/lib/node-esm/chunk-BHP545D7.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-4SRPREUK.mjs → chunk-G76M6O46.mjs} +2 -51
- package/dist/lib/node-esm/{chunk-4SRPREUK.mjs.map → chunk-G76M6O46.mjs.map} +4 -4
- package/dist/lib/node-esm/chunk-JHGOPQVO.mjs +41 -0
- package/dist/lib/node-esm/chunk-JHGOPQVO.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-JJZYWSD7.mjs +54 -0
- package/dist/lib/node-esm/chunk-JJZYWSD7.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-XPIKUBGS.mjs +225 -0
- package/dist/lib/node-esm/chunk-XPIKUBGS.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-OFYGBUNI.mjs → chunk-XUWS7OTK.mjs} +2 -2
- package/dist/lib/node-esm/compiler-PEARFTFR.mjs +85 -0
- package/dist/lib/node-esm/compiler-PEARFTFR.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +112 -288
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/intent-resolver-SZJXQ3CW.mjs +43 -0
- package/dist/lib/node-esm/intent-resolver-SZJXQ3CW.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/react-surface-J7NLV2V4.mjs +68 -0
- package/dist/lib/node-esm/react-surface-J7NLV2V4.mjs.map +7 -0
- package/dist/lib/node-esm/settings-XGXDY4NI.mjs +25 -0
- package/dist/lib/node-esm/settings-XGXDY4NI.mjs.map +7 -0
- package/dist/lib/node-esm/types.mjs +6 -4
- package/dist/types/src/ScriptPlugin.d.ts +1 -3
- package/dist/types/src/ScriptPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/capabilities.d.ts +5 -0
- package/dist/types/src/capabilities/capabilities.d.ts.map +1 -0
- package/dist/types/src/capabilities/compiler.d.ts +4 -0
- package/dist/types/src/capabilities/compiler.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +6 -0
- package/dist/types/src/capabilities/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/intent-resolver.d.ts +4 -0
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface.d.ts +4 -0
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
- package/dist/types/src/capabilities/settings.d.ts +4 -0
- package/dist/types/src/capabilities/settings.d.ts.map +1 -0
- package/dist/types/src/components/ScriptContainer.d.ts +10 -2
- package/dist/types/src/components/ScriptContainer.d.ts.map +1 -1
- package/dist/types/src/components/ScriptSettings/ScriptSettings.d.ts.map +1 -1
- package/dist/types/src/components/ScriptSettingsPanel.d.ts.map +1 -1
- package/dist/types/src/components/ScriptToolbar/ScriptToolbar.d.ts +11 -0
- package/dist/types/src/components/ScriptToolbar/ScriptToolbar.d.ts.map +1 -0
- package/dist/types/src/components/{Toolbar/Toolbar.stories.d.ts → ScriptToolbar/ScriptToolbar.stories.d.ts} +1 -1
- package/dist/types/src/components/ScriptToolbar/ScriptToolbar.stories.d.ts.map +1 -0
- package/dist/types/src/components/ScriptToolbar/deploy.d.ts +48 -0
- package/dist/types/src/components/ScriptToolbar/deploy.d.ts.map +1 -0
- package/dist/types/src/components/ScriptToolbar/format.d.ts +25 -0
- package/dist/types/src/components/ScriptToolbar/format.d.ts.map +1 -0
- package/dist/types/src/components/ScriptToolbar/index.d.ts +2 -0
- package/dist/types/src/components/ScriptToolbar/index.d.ts.map +1 -0
- package/dist/types/src/components/ScriptToolbar/templateSelect.d.ts +31 -0
- package/dist/types/src/components/ScriptToolbar/templateSelect.d.ts.map +1 -0
- package/dist/types/src/components/ScriptToolbar/useToolbarAction.d.ts +14 -0
- package/dist/types/src/components/ScriptToolbar/useToolbarAction.d.ts.map +1 -0
- package/dist/types/src/components/ScriptToolbar/useToolbarState.d.ts +10 -0
- package/dist/types/src/components/ScriptToolbar/useToolbarState.d.ts.map +1 -0
- package/dist/types/src/components/ScriptToolbar/view.d.ts +33 -0
- package/dist/types/src/components/ScriptToolbar/view.d.ts.map +1 -0
- package/dist/types/src/components/TypescriptEditor/TypescriptEditor.d.ts +4 -2
- package/dist/types/src/components/TypescriptEditor/TypescriptEditor.d.ts.map +1 -1
- package/dist/types/src/components/TypescriptEditor/TypescriptEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +1 -1
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +2 -4
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +1 -2
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/templates/email.d.ts +2 -1
- package/dist/types/src/templates/email.d.ts.map +1 -1
- package/dist/types/src/{templates.d.ts → templates/index.d.ts} +1 -1
- package/dist/types/src/templates/index.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +91 -0
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types.d.ts +14 -6
- package/dist/types/src/types.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +44 -46
- package/src/ScriptPlugin.tsx +63 -91
- package/src/bundler/bundler.test.ts +2 -2
- package/src/capabilities/capabilities.ts +12 -0
- package/src/capabilities/compiler.ts +33 -0
- package/src/capabilities/index.ts +12 -0
- package/src/capabilities/intent-resolver.ts +43 -0
- package/src/capabilities/react-surface.tsx +54 -0
- package/src/capabilities/settings.ts +14 -0
- package/src/components/ScriptContainer.tsx +64 -9
- package/src/components/ScriptSettings/ScriptSettings.tsx +25 -1
- package/src/components/ScriptSettingsPanel.tsx +124 -50
- package/src/components/{Toolbar/Toolbar.stories.tsx → ScriptToolbar/ScriptToolbar.stories.tsx} +2 -2
- package/src/components/ScriptToolbar/ScriptToolbar.tsx +51 -0
- package/src/components/ScriptToolbar/deploy.ts +157 -0
- package/src/components/ScriptToolbar/format.ts +47 -0
- package/src/components/{Toolbar → ScriptToolbar}/index.ts +1 -1
- package/src/components/ScriptToolbar/templateSelect.ts +64 -0
- package/src/components/ScriptToolbar/useToolbarAction.ts +54 -0
- package/src/components/ScriptToolbar/useToolbarState.ts +16 -0
- package/src/components/ScriptToolbar/view.ts +52 -0
- package/src/components/TypescriptEditor/TypescriptEditor.stories.tsx +2 -0
- package/src/components/TypescriptEditor/TypescriptEditor.tsx +73 -8
- package/src/index.ts +2 -6
- package/src/meta.ts +1 -1
- package/src/templates/email.ts +26 -23
- package/src/{templates.ts → templates/index.ts} +5 -5
- package/src/translations.ts +21 -0
- package/src/types.ts +19 -18
- package/dist/lib/browser/ScriptContainer-GDVBWFI7.mjs +0 -415
- package/dist/lib/browser/ScriptContainer-GDVBWFI7.mjs.map +0 -7
- package/dist/lib/browser/chunk-C7VBULMK.mjs.map +0 -7
- package/dist/lib/browser/chunk-RQA3EB5K.mjs +0 -26
- package/dist/lib/browser/chunk-RQA3EB5K.mjs.map +0 -7
- package/dist/lib/browser/meta.mjs +0 -9
- package/dist/lib/browser/meta.mjs.map +0 -7
- package/dist/lib/node/ScriptContainer-YWXXNLG6.cjs +0 -426
- package/dist/lib/node/ScriptContainer-YWXXNLG6.cjs.map +0 -7
- package/dist/lib/node/chunk-6LYX73ZT.cjs.map +0 -7
- package/dist/lib/node/chunk-PK3OQP5L.cjs.map +0 -7
- package/dist/lib/node/chunk-WPP65EYS.cjs.map +0 -7
- package/dist/lib/node/meta.cjs.map +0 -7
- package/dist/lib/node-esm/ScriptContainer-BG2PHKEH.mjs +0 -416
- package/dist/lib/node-esm/ScriptContainer-BG2PHKEH.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-H6BBLQ5Q.mjs +0 -27
- package/dist/lib/node-esm/chunk-H6BBLQ5Q.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-SLTZMY34.mjs.map +0 -7
- package/dist/lib/node-esm/meta.mjs +0 -10
- package/dist/lib/node-esm/meta.mjs.map +0 -7
- package/dist/types/src/components/ScriptBlock/ScriptBlock.d.ts +0 -12
- package/dist/types/src/components/ScriptBlock/ScriptBlock.d.ts.map +0 -1
- package/dist/types/src/components/ScriptBlock/ScriptBlock.stories.d.ts +0 -6
- package/dist/types/src/components/ScriptBlock/ScriptBlock.stories.d.ts.map +0 -1
- package/dist/types/src/components/ScriptBlock/index.d.ts +0 -2
- package/dist/types/src/components/ScriptBlock/index.d.ts.map +0 -1
- package/dist/types/src/components/ScriptEditor.d.ts +0 -9
- package/dist/types/src/components/ScriptEditor.d.ts.map +0 -1
- package/dist/types/src/components/Toolbar/Toolbar.d.ts +0 -23
- package/dist/types/src/components/Toolbar/Toolbar.d.ts.map +0 -1
- package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts.map +0 -1
- package/dist/types/src/components/Toolbar/index.d.ts +0 -2
- package/dist/types/src/components/Toolbar/index.d.ts.map +0 -1
- package/dist/types/src/templates.d.ts.map +0 -1
- package/src/components/ScriptBlock/ScriptBlock.stories.tsx +0 -55
- package/src/components/ScriptBlock/ScriptBlock.tsx +0 -102
- package/src/components/ScriptBlock/index.ts +0 -5
- package/src/components/ScriptEditor.tsx +0 -193
- package/src/components/Toolbar/Toolbar.tsx +0 -177
- /package/dist/lib/browser/{AutomationPanel-RFQAQ7NF.mjs.map → AutomationPanel-OOIRJFPJ.mjs.map} +0 -0
- /package/dist/lib/browser/{chunk-K7KY6YMG.mjs.map → chunk-SJ4J527G.mjs.map} +0 -0
- /package/dist/lib/node/{AutomationPanel-5CJEF4MI.cjs.map → AutomationPanel-EPRDDR3A.cjs.map} +0 -0
- /package/dist/lib/node/{chunk-4INUJLXL.cjs.map → chunk-DQRAVZM7.cjs.map} +0 -0
- /package/dist/lib/node-esm/{AutomationPanel-7Y6REBNJ.mjs.map → AutomationPanel-DMLAGQS5.mjs.map} +0 -0
- /package/dist/lib/node-esm/{chunk-OFYGBUNI.mjs.map → chunk-XUWS7OTK.mjs.map} +0 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/ScriptSettings/ScriptSettings.tsx", "../../../src/components/ScriptSettingsPanel.tsx", "../../../src/components/index.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport React from 'react';\n\nimport { type Credential } from '@dxos/protocols/proto/dxos/halo/credentials';\nimport { useClient } from '@dxos/react-client';\nimport { Button, Select, useTranslation } from '@dxos/react-ui';\nimport { type EditorInputMode, EditorInputModes } from '@dxos/react-ui-editor';\nimport { DeprecatedFormInput } from '@dxos/react-ui-form';\n\nimport { SCRIPT_PLUGIN } from '../../meta';\nimport { type ScriptSettingsProps } from '../../types';\n\nexport const ScriptSettings = ({ settings }: { settings: ScriptSettingsProps }) => {\n const { t } = useTranslation(SCRIPT_PLUGIN);\n const client = useClient();\n\n // TODO(burdon): Check token.\n const handleAuthenticate = async () => {\n const { identityKey } = client.halo.identity.get()!;\n await client.halo.writeCredentials([\n {\n issuer: identityKey,\n issuanceDate: new Date(),\n subject: {\n id: identityKey,\n assertion: {\n '@type': 'dxos.halo.credentials.ServiceAccess',\n serverName: 'hub.dxos.network',\n serverKey: identityKey,\n identityKey,\n capabilities: ['composer:beta'],\n },\n },\n } satisfies Credential,\n ]);\n };\n\n return (\n <>\n {/* TODO(wittjosiah): Hide outside of dev environments. */}\n <DeprecatedFormInput label={t('authenticate action label')}>\n <Button onClick={handleAuthenticate}>{t('authenticate button label')}</Button>\n </DeprecatedFormInput>\n\n <DeprecatedFormInput label={t('editor input mode label')}>\n <Select.Root\n value={settings.editorInputMode ?? 'default'}\n onValueChange={(value) => {\n settings.editorInputMode = value as EditorInputMode;\n }}\n >\n <Select.TriggerButton placeholder={t('select editor input mode placeholder')} />\n <Select.Portal>\n <Select.Content>\n <Select.Viewport>\n {EditorInputModes.map((mode) => (\n <Select.Option key={mode} value={mode}>\n {t(`settings editor input mode ${mode} label`)}\n </Select.Option>\n ))}\n </Select.Viewport>\n </Select.Content>\n </Select.Portal>\n </Select.Root>\n </DeprecatedFormInput>\n </>\n );\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { Octokit } from '@octokit/core';\nimport React, { type ChangeEvent, useCallback, useEffect, useState } from 'react';\n\nimport { createIntent, SettingsAction, useIntentDispatcher } from '@dxos/app-framework';\nimport { FunctionType, type ScriptType, getInvocationUrl, getUserFunctionUrlInMetadata } from '@dxos/functions';\nimport { log } from '@dxos/log';\nimport { useClient } from '@dxos/react-client';\nimport { Filter, getMeta, getSpace, useQuery } from '@dxos/react-client/echo';\nimport { Button, Clipboard, Input, Separator, useControlledValue, useTranslation } from '@dxos/react-ui';\nimport { AccessTokenType } from '@dxos/schema';\n\nimport { SCRIPT_PLUGIN } from '../meta';\n\n// TODO(wittjosiah): Factor out.\n// From https://stackoverflow.com/a/67243723/2804332\nconst kebabize = (str: string) => str.replace(/[A-Z]+(?![a-z])|[A-Z]/g, ($, ofs) => (ofs ? '-' : '') + $.toLowerCase());\n\nexport type ScriptSettingsPanelProps = {\n script: ScriptType;\n};\n\nexport const ScriptSettingsPanel = ({ script }: ScriptSettingsPanelProps) => {\n const { t } = useTranslation(SCRIPT_PLUGIN);\n const { dispatchPromise: dispatch } = useIntentDispatcher();\n const client = useClient();\n const space = getSpace(script);\n const [fn] = useQuery(space, Filter.schema(FunctionType, { source: script }));\n const [githubToken] = useQuery(space, Filter.schema(AccessTokenType, { source: 'github.com' }));\n const gistKey = getMeta(script).keys.find(({ source }) => source === 'github.com');\n const [gistUrl, setGistUrl] = useState<string | undefined>();\n\n useEffect(() => {\n const token = githubToken?.token;\n const gistId = gistKey?.id;\n if (!token || !gistId) {\n setGistUrl(undefined);\n return;\n }\n\n const timeout = setTimeout(async () => {\n try {\n const octokit = new Octokit({ auth: githubToken.token });\n const response = await octokit.request('GET /gists/{gist_id}', {\n gist_id: gistId,\n });\n setGistUrl(response.data.html_url);\n } catch (err) {\n log.catch(err);\n setGistUrl(undefined);\n }\n });\n\n return () => clearTimeout(timeout);\n }, [githubToken, gistKey]);\n\n const [binding, setBinding] = useControlledValue(fn?.binding ?? '');\n const handleBindingChange = useCallback(\n (event: ChangeEvent<HTMLInputElement>) => {\n setBinding(event.target.value);\n },\n [setBinding],\n );\n const handleBindingBlur = useCallback(() => {\n fn.binding = binding;\n }, [fn, binding]);\n\n const functionPath = fn && getUserFunctionUrlInMetadata(getMeta(fn));\n const functionUrl =\n functionPath &&\n getInvocationUrl(functionPath, client.config.values.runtime?.services?.edge?.url ?? '', {\n spaceId: space?.id,\n });\n\n const handleOpenTokenManager = useCallback(\n () => dispatch(createIntent(SettingsAction.Open, { plugin: 'dxos.org/plugin/token-manager' })),\n [],\n );\n\n const [publishing, setPublishing] = useState(false);\n const handlePublish = useCallback(async () => {\n setPublishing(true);\n const octokit = new Octokit({ auth: githubToken.token });\n const source = await script.source.load();\n const filename = script.name ? kebabize(script.name) : 'composer-script';\n const files = { [`${filename}.ts`]: { content: source.content } };\n\n try {\n // TODO(wittjosiah): Factor out to intent.\n const meta = getMeta(script);\n const githubKey = meta.keys.find(({ source }) => source === 'github.com');\n const gistId = githubKey?.id;\n if (gistId) {\n await octokit.request('PATCH /gists/{gist_id}', {\n gist_id: gistId,\n files,\n });\n } else {\n const response = await octokit.request('POST /gists', {\n public: true,\n files,\n });\n if (response.data.id) {\n meta.keys.push({ source: 'github.com', id: response.data.id });\n }\n }\n } finally {\n setPublishing(false);\n }\n }, [script, githubToken]);\n\n return (\n <>\n {fn && functionUrl && (\n <>\n <Separator />\n <div role='form' className='flex flex-col w-full p-2 gap-4'>\n <h2>{t('remote function settings heading')}</h2>\n <Input.Root>\n <div role='none' className='flex flex-col gap-1'>\n <Input.Label>{t('function url label')}</Input.Label>\n <div role='none' className='flex gap-1'>\n <Input.TextInput\n disabled\n value={functionUrl}\n onChange={(event) => {\n fn.name = event.target.value;\n }}\n />\n <Clipboard.IconButton value={functionUrl} />\n </div>\n </div>\n </Input.Root>\n <Input.Root>\n <div role='none' className='flex flex-col gap-1'>\n <Input.Label>{t('function binding label')}</Input.Label>\n <Input.TextInput\n placeholder={t('function binding placeholder')}\n value={binding}\n onChange={handleBindingChange}\n onBlur={handleBindingBlur}\n />\n </div>\n </Input.Root>\n </div>\n </>\n )}\n <Separator />\n <div className='flex flex-col w-full p-2 gap-4'>\n <div>\n <h2>{t('script publish settings label')}</h2>\n <p className='text-description text-sm'>{t('script publish settings description')}</p>\n </div>\n {!githubToken && (\n <div className='flex flex-col items-center justify-center gap-2'>\n <span>{t('no github token label')}</span>\n <Button onClick={handleOpenTokenManager}>{t('open token manager label')}</Button>\n </div>\n )}\n {githubToken && (\n <div className='flex justify-end gap-2'>\n {gistUrl && <Clipboard.IconButton value={gistUrl} />}\n <Button disabled={publishing} onClick={handlePublish}>\n {t(publishing ? 'publishing label' : 'publish label')}\n </Button>\n </div>\n )}\n </div>\n </>\n );\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { lazy } from 'react';\n\nexport * from './ScriptSettings';\nexport * from './ScriptSettingsPanel';\n\nexport const AutomationPanel = lazy(() => import('./AutomationPanel'));\nexport const ScriptContainer = lazy(() => import('./ScriptContainer'));\n"],
|
|
5
|
+
"mappings": ";;;;;AAIA,OAAOA,WAAW;AAG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"useTranslation", "EditorInputModes", "DeprecatedFormInput", "ScriptSettings", "settings", "t", "useTranslation", "SCRIPT_PLUGIN", "client", "useClient", "handleAuthenticate", "identityKey", "halo", "identity", "get", "writeCredentials", "issuer", "issuanceDate", "Date", "subject", "id", "assertion", "serverName", "serverKey", "capabilities", "DeprecatedFormInput", "label", "Button", "onClick", "Select", "Root", "value", "editorInputMode", "onValueChange", "TriggerButton", "placeholder", "Portal", "Content", "Viewport", "EditorInputModes", "map", "mode", "Option", "key", "Octokit", "React", "useCallback", "useEffect", "useState", "createIntent", "SettingsAction", "useIntentDispatcher", "FunctionType", "getInvocationUrl", "getUserFunctionUrlInMetadata", "log", "useClient", "Filter", "getMeta", "getSpace", "useQuery", "Button", "Clipboard", "Input", "Separator", "useControlledValue", "useTranslation", "AccessTokenType", "kebabize", "str", "replace", "$", "ofs", "toLowerCase", "ScriptSettingsPanel", "script", "t", "useTranslation", "SCRIPT_PLUGIN", "dispatchPromise", "dispatch", "useIntentDispatcher", "client", "useClient", "space", "getSpace", "fn", "useQuery", "Filter", "schema", "FunctionType", "source", "githubToken", "AccessTokenType", "gistKey", "getMeta", "keys", "find", "gistUrl", "setGistUrl", "useState", "useEffect", "token", "gistId", "id", "undefined", "timeout", "setTimeout", "octokit", "Octokit", "auth", "response", "request", "gist_id", "data", "html_url", "err", "log", "catch", "clearTimeout", "binding", "setBinding", "useControlledValue", "handleBindingChange", "useCallback", "event", "target", "value", "handleBindingBlur", "functionPath", "getUserFunctionUrlInMetadata", "functionUrl", "getInvocationUrl", "config", "values", "runtime", "services", "edge", "url", "spaceId", "handleOpenTokenManager", "createIntent", "SettingsAction", "Open", "plugin", "publishing", "setPublishing", "handlePublish", "load", "filename", "name", "files", "content", "meta", "githubKey", "public", "push", "React", "Separator", "div", "role", "className", "h2", "Input", "Root", "Label", "TextInput", "disabled", "onChange", "Clipboard", "IconButton", "placeholder", "onBlur", "p", "span", "Button", "onClick", "lazy", "AutomationPanel", "lazy", "ScriptContainer"]
|
|
7
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
SCRIPT_PLUGIN
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-5BU5ERNU.mjs";
|
|
4
4
|
|
|
5
5
|
// packages/plugins/experimental/plugin-script/src/components/DebugPanel/DebugPanel.tsx
|
|
6
6
|
import React, { forwardRef, useEffect, useRef, useState } from "react";
|
|
@@ -237,4 +237,4 @@ var RobotAvatar = () => /* @__PURE__ */ React.createElement(Avatar.Root, {
|
|
|
237
237
|
export {
|
|
238
238
|
DebugPanel
|
|
239
239
|
};
|
|
240
|
-
//# sourceMappingURL=chunk-
|
|
240
|
+
//# sourceMappingURL=chunk-SJ4J527G.mjs.map
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import {
|
|
2
|
+
SCRIPT_PLUGIN
|
|
3
|
+
} from "./chunk-5BU5ERNU.mjs";
|
|
4
|
+
|
|
5
|
+
// packages/plugins/experimental/plugin-script/src/types.ts
|
|
6
|
+
import { TitleAnnotationId } from "@effect/schema/AST";
|
|
7
|
+
import { SpaceSchema } from "@dxos/client/echo";
|
|
8
|
+
import { S } from "@dxos/echo-schema";
|
|
9
|
+
import { ScriptType } from "@dxos/functions";
|
|
10
|
+
import { EditorInputMode } from "@dxos/react-ui-editor";
|
|
11
|
+
var ScriptAction;
|
|
12
|
+
(function(ScriptAction2) {
|
|
13
|
+
const SCRIPT_ACTION = `${SCRIPT_PLUGIN}/action`;
|
|
14
|
+
ScriptAction2.CreateScriptSchema = S.Struct({
|
|
15
|
+
name: S.optional(S.String),
|
|
16
|
+
// TODO(wittjosiah): Placeholder annotation?
|
|
17
|
+
gistUrl: S.optional(S.String.annotations({
|
|
18
|
+
[TitleAnnotationId]: "Import from Gist (url)"
|
|
19
|
+
}))
|
|
20
|
+
});
|
|
21
|
+
class Create extends S.TaggedClass()(`${SCRIPT_ACTION}/create`, {
|
|
22
|
+
input: S.extend(ScriptAction2.CreateScriptSchema, S.Struct({
|
|
23
|
+
space: SpaceSchema
|
|
24
|
+
})),
|
|
25
|
+
output: S.Struct({
|
|
26
|
+
object: ScriptType
|
|
27
|
+
})
|
|
28
|
+
}) {
|
|
29
|
+
}
|
|
30
|
+
ScriptAction2.Create = Create;
|
|
31
|
+
})(ScriptAction || (ScriptAction = {}));
|
|
32
|
+
var ScriptSettingsSchema = S.mutable(S.Struct({
|
|
33
|
+
editorInputMode: EditorInputMode
|
|
34
|
+
}));
|
|
35
|
+
|
|
36
|
+
export {
|
|
37
|
+
ScriptAction,
|
|
38
|
+
ScriptSettingsSchema
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=chunk-XPGBHZ3L.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/types.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { TitleAnnotationId } from '@effect/schema/AST';\n\nimport { SpaceSchema } from '@dxos/client/echo';\nimport { S } from '@dxos/echo-schema';\nimport { ScriptType } from '@dxos/functions';\nimport { EditorInputMode } from '@dxos/react-ui-editor';\n\nimport { SCRIPT_PLUGIN } from './meta';\n\nexport namespace ScriptAction {\n const SCRIPT_ACTION = `${SCRIPT_PLUGIN}/action`;\n\n export const CreateScriptSchema = S.Struct({\n name: S.optional(S.String),\n // TODO(wittjosiah): Placeholder annotation?\n gistUrl: S.optional(S.String.annotations({ [TitleAnnotationId]: 'Import from Gist (url)' })),\n });\n\n export type CreateScriptProps = S.Schema.Type<typeof CreateScriptSchema>;\n\n export class Create extends S.TaggedClass<Create>()(`${SCRIPT_ACTION}/create`, {\n input: S.extend(CreateScriptSchema, S.Struct({ space: SpaceSchema })),\n output: S.Struct({\n object: ScriptType,\n }),\n }) {}\n}\n\nexport const ScriptSettingsSchema = S.mutable(\n S.Struct({\n editorInputMode: EditorInputMode,\n }),\n);\n\nexport type ScriptSettingsProps = S.Schema.Type<typeof ScriptSettingsSchema>;\n"],
|
|
5
|
+
"mappings": ";;;;;AAIA,SAASA,yBAAyB;AAElC,SAASC,mBAAmB;AAC5B,SAASC,SAAS;AAClB,SAASC,kBAAkB;AAC3B,SAASC,uBAAuB;;UAIfC,eAAAA;AACf,QAAMC,gBAAgB,GAAGC,aAAAA;gBAEZC,qBAAqBC,EAAEC,OAAO;IACzCC,MAAMF,EAAEG,SAASH,EAAEI,MAAM;;IAEzBC,SAASL,EAAEG,SAASH,EAAEI,OAAOE,YAAY;MAAE,CAACC,iBAAAA,GAAoB;IAAyB,CAAA,CAAA;EAC3F,CAAA;EAIO,MAAMC,eAAeR,EAAES,YAAW,EAAW,GAAGZ,aAAAA,WAAwB;IAC7Ea,OAAOV,EAAEW,OAAMf,cAACG,oBAAoBC,EAAEC,OAAO;MAAEW,OAAOC;IAAY,CAAA,CAAA;IAClEC,QAAQd,EAAEC,OAAO;MACfc,QAAQC;IACV,CAAA;EACF,CAAA,EAAA;EAAI;gBALSR,SAAAA;AAMf,GAjBiBZ,iBAAAA,eAAAA,CAAAA,EAAAA;AAmBV,IAAMqB,uBAAuBjB,EAAEkB,QACpClB,EAAEC,OAAO;EACPkB,iBAAiBC;AACnB,CAAA,CAAA;",
|
|
6
|
+
"names": ["TitleAnnotationId", "SpaceSchema", "S", "ScriptType", "EditorInputMode", "ScriptAction", "SCRIPT_ACTION", "SCRIPT_PLUGIN", "CreateScriptSchema", "S", "Struct", "name", "optional", "String", "gistUrl", "annotations", "TitleAnnotationId", "Create", "TaggedClass", "input", "extend", "space", "SpaceSchema", "output", "object", "ScriptType", "ScriptSettingsSchema", "mutable", "editorInputMode", "EditorInputMode"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import {
|
|
2
|
+
SCRIPT_PLUGIN
|
|
3
|
+
} from "./chunk-5BU5ERNU.mjs";
|
|
4
|
+
|
|
5
|
+
// packages/plugins/experimental/plugin-script/src/capabilities/capabilities.ts
|
|
6
|
+
import { defineCapability } from "@dxos/app-framework";
|
|
7
|
+
var ScriptCapabilities;
|
|
8
|
+
(function(ScriptCapabilities2) {
|
|
9
|
+
ScriptCapabilities2.Compiler = defineCapability(`${SCRIPT_PLUGIN}/capability/compiler`);
|
|
10
|
+
})(ScriptCapabilities || (ScriptCapabilities = {}));
|
|
11
|
+
|
|
12
|
+
export {
|
|
13
|
+
ScriptCapabilities
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=chunk-ZM6T4HPR.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/capabilities/capabilities.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { defineCapability } from '@dxos/app-framework';\n\nimport { type Compiler } from '../compiler';\nimport { SCRIPT_PLUGIN } from '../meta';\n\nexport namespace ScriptCapabilities {\n export const Compiler = defineCapability<Compiler>(`${SCRIPT_PLUGIN}/capability/compiler`);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;AAIA,SAASA,wBAAwB;;UAKhBC,qBAAAA;sBACFC,WAAWC,iBAA2B,GAAGC,aAAAA,sBAAmC;AAC3F,GAFiBH,uBAAAA,qBAAAA,CAAAA,EAAAA;",
|
|
6
|
+
"names": ["defineCapability", "ScriptCapabilities", "Compiler", "defineCapability", "SCRIPT_PLUGIN"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import {
|
|
2
|
+
initializeBundler
|
|
3
|
+
} from "./chunk-SDHKTS6H.mjs";
|
|
4
|
+
import {
|
|
5
|
+
ScriptCapabilities
|
|
6
|
+
} from "./chunk-ZM6T4HPR.mjs";
|
|
7
|
+
import "./chunk-5BU5ERNU.mjs";
|
|
8
|
+
|
|
9
|
+
// packages/plugins/experimental/plugin-script/src/capabilities/compiler.ts
|
|
10
|
+
import wasmUrl from "esbuild-wasm/esbuild.wasm?url";
|
|
11
|
+
import { contributes } from "@dxos/app-framework";
|
|
12
|
+
|
|
13
|
+
// packages/plugins/experimental/plugin-script/src/compiler/compiler.ts
|
|
14
|
+
import { createDefaultMapFromCDN, createSystem, createVirtualTypeScriptEnvironment } from "@typescript/vfs";
|
|
15
|
+
import ts from "typescript";
|
|
16
|
+
import { invariant } from "@dxos/invariant";
|
|
17
|
+
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/experimental/plugin-script/src/compiler/compiler.ts";
|
|
18
|
+
var defaultOptions = {
|
|
19
|
+
lib: [
|
|
20
|
+
"DOM",
|
|
21
|
+
"es2022"
|
|
22
|
+
],
|
|
23
|
+
target: ts.ScriptTarget.ES2022
|
|
24
|
+
};
|
|
25
|
+
var Compiler = class {
|
|
26
|
+
constructor(_options = defaultOptions) {
|
|
27
|
+
this._options = _options;
|
|
28
|
+
}
|
|
29
|
+
async initialize() {
|
|
30
|
+
if (this._env) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
this._fsMap = await createDefaultMapFromCDN(this._options, "5.5.4", true, ts);
|
|
34
|
+
const system = createSystem(this._fsMap);
|
|
35
|
+
this._env = createVirtualTypeScriptEnvironment(system, [], ts, this._options);
|
|
36
|
+
}
|
|
37
|
+
get environment() {
|
|
38
|
+
invariant(this._env, "Compiler environment not initialized.", {
|
|
39
|
+
F: __dxlog_file,
|
|
40
|
+
L: 39,
|
|
41
|
+
S: this,
|
|
42
|
+
A: [
|
|
43
|
+
"this._env",
|
|
44
|
+
"'Compiler environment not initialized.'"
|
|
45
|
+
]
|
|
46
|
+
});
|
|
47
|
+
return this._env;
|
|
48
|
+
}
|
|
49
|
+
setFile(fileName, content) {
|
|
50
|
+
invariant(this._fsMap, "File system map not initialized.", {
|
|
51
|
+
F: __dxlog_file,
|
|
52
|
+
L: 44,
|
|
53
|
+
S: this,
|
|
54
|
+
A: [
|
|
55
|
+
"this._fsMap",
|
|
56
|
+
"'File system map not initialized.'"
|
|
57
|
+
]
|
|
58
|
+
});
|
|
59
|
+
this.environment.createFile(fileName, content);
|
|
60
|
+
}
|
|
61
|
+
compile(fileName) {
|
|
62
|
+
return this.environment.languageService.getEmitOutput(fileName);
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
// packages/plugins/experimental/plugin-script/src/capabilities/compiler.ts
|
|
67
|
+
var compiler_default = async () => {
|
|
68
|
+
const compiler = new Compiler();
|
|
69
|
+
await compiler.initialize();
|
|
70
|
+
compiler.setFile("/src/typings.d.ts", "declare module 'https://*';");
|
|
71
|
+
compiler.setFile("/src/runtime.ts", `
|
|
72
|
+
export const Filter: any = {};
|
|
73
|
+
export type FunctionHandler = ({ event, context }: { event: any; context: any }) => Promise<Response>;
|
|
74
|
+
export const functionHandler = (handler: FunctionHandler) => handler;
|
|
75
|
+
`);
|
|
76
|
+
await initializeBundler({
|
|
77
|
+
wasmUrl
|
|
78
|
+
});
|
|
79
|
+
return contributes(ScriptCapabilities.Compiler, compiler);
|
|
80
|
+
};
|
|
81
|
+
export {
|
|
82
|
+
compiler_default as default
|
|
83
|
+
};
|
|
84
|
+
//# sourceMappingURL=compiler-HT53ILG7.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/capabilities/compiler.ts", "../../../src/compiler/compiler.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\n// @ts-ignore\nimport wasmUrl from 'esbuild-wasm/esbuild.wasm?url';\n\nimport { contributes } from '@dxos/app-framework';\n\nimport { ScriptCapabilities } from './capabilities';\nimport { initializeBundler } from '../bundler';\nimport { Compiler } from '../compiler';\n\nexport default async () => {\n const compiler = new Compiler();\n\n await compiler.initialize();\n // TODO(wittjosiah): Fetch types for https modules.\n compiler.setFile('/src/typings.d.ts', \"declare module 'https://*';\");\n // TODO(wittjosiah): Proper function handler types.\n // TODO(wittjosiah): Remove.\n compiler.setFile(\n '/src/runtime.ts',\n `\n export const Filter: any = {};\n export type FunctionHandler = ({ event, context }: { event: any; context: any }) => Promise<Response>;\n export const functionHandler = (handler: FunctionHandler) => handler;\n `,\n );\n await initializeBundler({ wasmUrl });\n\n return contributes(ScriptCapabilities.Compiler, compiler);\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport {\n createDefaultMapFromCDN,\n createSystem,\n createVirtualTypeScriptEnvironment,\n type VirtualTypeScriptEnvironment,\n} from '@typescript/vfs';\nimport ts from 'typescript';\n\nimport { invariant } from '@dxos/invariant';\n\nconst defaultOptions: ts.CompilerOptions = {\n lib: ['DOM', 'es2022'],\n target: ts.ScriptTarget.ES2022,\n};\n\nexport class Compiler {\n private _env: VirtualTypeScriptEnvironment | undefined;\n private _fsMap: Map<string, string> | undefined;\n\n constructor(private readonly _options: ts.CompilerOptions = defaultOptions) {}\n\n async initialize() {\n if (this._env) {\n return;\n }\n\n // TODO(wittjosiah): Figure out how to get workers working in plugin packages.\n // https://github.com/val-town/codemirror-ts?tab=readme-ov-file#setup-worker\n this._fsMap = await createDefaultMapFromCDN(this._options, '5.5.4', true, ts);\n const system = createSystem(this._fsMap);\n this._env = createVirtualTypeScriptEnvironment(system, [], ts, this._options);\n }\n\n get environment() {\n invariant(this._env, 'Compiler environment not initialized.');\n return this._env;\n }\n\n setFile(fileName: string, content: string) {\n invariant(this._fsMap, 'File system map not initialized.');\n this.environment.createFile(fileName, content);\n }\n\n compile(fileName: string) {\n return this.environment.languageService.getEmitOutput(fileName);\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;AAKA,OAAOA,aAAa;AAEpB,SAASC,mBAAmB;;;ACH5B,SACEC,yBACAC,cACAC,0CAEK;AACP,OAAOC,QAAQ;AAEf,SAASC,iBAAiB;;AAE1B,IAAMC,iBAAqC;EACzCC,KAAK;IAAC;IAAO;;EACbC,QAAQJ,GAAGK,aAAaC;AAC1B;AAEO,IAAMC,WAAN,MAAMA;EAIXC,YAA6BC,WAA+BP,gBAAgB;SAA/CO,WAAAA;EAAgD;EAE7E,MAAMC,aAAa;AACjB,QAAI,KAAKC,MAAM;AACb;IACF;AAIA,SAAKC,SAAS,MAAMf,wBAAwB,KAAKY,UAAU,SAAS,MAAMT,EAAAA;AAC1E,UAAMa,SAASf,aAAa,KAAKc,MAAM;AACvC,SAAKD,OAAOZ,mCAAmCc,QAAQ,CAAA,GAAIb,IAAI,KAAKS,QAAQ;EAC9E;EAEA,IAAIK,cAAc;AAChBb,cAAU,KAAKU,MAAM,yCAAA;;;;;;;;;AACrB,WAAO,KAAKA;EACd;EAEAI,QAAQC,UAAkBC,SAAiB;AACzChB,cAAU,KAAKW,QAAQ,oCAAA;;;;;;;;;AACvB,SAAKE,YAAYI,WAAWF,UAAUC,OAAAA;EACxC;EAEAE,QAAQH,UAAkB;AACxB,WAAO,KAAKF,YAAYM,gBAAgBC,cAAcL,QAAAA;EACxD;AACF;;;ADrCA,IAAA,mBAAe,YAAA;AACb,QAAMM,WAAW,IAAIC,SAAAA;AAErB,QAAMD,SAASE,WAAU;AAEzBF,WAASG,QAAQ,qBAAqB,6BAAA;AAGtCH,WAASG,QACP,mBACA;;;;OAIG;AAEL,QAAMC,kBAAkB;IAAEC;EAAQ,CAAA;AAElC,SAAOC,YAAYC,mBAAmBN,UAAUD,QAAAA;AAClD;",
|
|
6
|
+
"names": ["wasmUrl", "contributes", "createDefaultMapFromCDN", "createSystem", "createVirtualTypeScriptEnvironment", "ts", "invariant", "defaultOptions", "lib", "target", "ScriptTarget", "ES2022", "Compiler", "constructor", "_options", "initialize", "_env", "_fsMap", "system", "environment", "setFile", "fileName", "content", "createFile", "compile", "languageService", "getEmitOutput", "compiler", "Compiler", "initialize", "setFile", "initializeBundler", "wasmUrl", "contributes", "ScriptCapabilities"]
|
|
7
|
+
}
|