@dxos/plugin-script 0.7.5-staging.b81e783 → 0.8.0
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/ScriptContainer-3RFMYKTV.mjs +258 -0
- package/dist/lib/browser/ScriptContainer-3RFMYKTV.mjs.map +7 -0
- package/dist/lib/browser/{artifact-definition-NAWYXFF5.mjs → artifact-definition-4LWPD3DH.mjs} +22 -14
- package/dist/lib/browser/artifact-definition-4LWPD3DH.mjs.map +7 -0
- package/dist/lib/browser/{ScriptContainer-GR7X5NSI.mjs → chunk-G2FYNDU4.mjs} +16 -254
- package/dist/lib/browser/chunk-G2FYNDU4.mjs.map +7 -0
- package/dist/lib/browser/{chunk-YJAKD6E3.mjs → chunk-PZPYF7M4.mjs} +2 -2
- package/dist/lib/browser/chunk-PZPYF7M4.mjs.map +7 -0
- package/dist/lib/browser/{chunk-7RUMC44X.mjs → chunk-VTWBVFBK.mjs} +2 -4
- package/dist/lib/browser/{chunk-7RUMC44X.mjs.map → chunk-VTWBVFBK.mjs.map} +3 -3
- package/dist/lib/browser/index.mjs +32 -16
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/{intent-resolver-I6VDXUDH.mjs → intent-resolver-D6FPY5ZA.mjs} +2 -2
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{react-surface-FGWXHB7P.mjs → react-surface-G4C2PZ2K.mjs} +23 -7
- package/dist/lib/browser/react-surface-G4C2PZ2K.mjs.map +7 -0
- package/dist/lib/node/ScriptContainer-G6FZU4AM.cjs +274 -0
- package/dist/lib/node/ScriptContainer-G6FZU4AM.cjs.map +7 -0
- package/dist/lib/node/{artifact-definition-7AANUS3X.cjs → artifact-definition-BXQCFPAH.cjs} +22 -17
- package/dist/lib/node/artifact-definition-BXQCFPAH.cjs.map +7 -0
- package/dist/lib/node/{chunk-7XULMIYT.cjs → chunk-ITAJ3WRW.cjs} +5 -5
- package/dist/lib/node/chunk-ITAJ3WRW.cjs.map +7 -0
- package/dist/lib/node/{chunk-JITODKGN.cjs → chunk-TOXBGIEI.cjs} +5 -8
- package/dist/lib/node/{chunk-JITODKGN.cjs.map → chunk-TOXBGIEI.cjs.map} +3 -3
- package/dist/lib/node/{ScriptContainer-SLARXOSU.cjs → chunk-XKYJYY3T.cjs} +59 -280
- package/dist/lib/node/chunk-XKYJYY3T.cjs.map +7 -0
- package/dist/lib/node/index.cjs +32 -17
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/{intent-resolver-MYATX7IR.cjs → intent-resolver-NYJFPD5B.cjs} +6 -6
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/{react-surface-2GH5HQX4.cjs → react-surface-EGSE3FMN.cjs} +24 -12
- package/dist/lib/node/react-surface-EGSE3FMN.cjs.map +7 -0
- package/dist/lib/node-esm/ScriptContainer-7FTCFIF3.mjs +259 -0
- package/dist/lib/node-esm/ScriptContainer-7FTCFIF3.mjs.map +7 -0
- package/dist/lib/node-esm/{artifact-definition-KBASPVMM.mjs → artifact-definition-KT4DK2LQ.mjs} +21 -14
- package/dist/lib/node-esm/artifact-definition-KT4DK2LQ.mjs.map +7 -0
- package/dist/lib/node-esm/{ScriptContainer-MHRJXMC4.mjs → chunk-NRICF4KE.mjs} +16 -254
- package/dist/lib/node-esm/chunk-NRICF4KE.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-IAELQPSI.mjs → chunk-S64WSJQK.mjs} +2 -4
- package/dist/lib/node-esm/{chunk-IAELQPSI.mjs.map → chunk-S64WSJQK.mjs.map} +3 -3
- package/dist/lib/node-esm/{chunk-6CHX4CEL.mjs → chunk-YIWRJ25J.mjs} +2 -2
- package/dist/lib/node-esm/chunk-YIWRJ25J.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +32 -16
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/{intent-resolver-PBDTYC4P.mjs → intent-resolver-KLBHSMW4.mjs} +2 -2
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/{react-surface-MLE3J3TF.mjs → react-surface-7YSGHZQM.mjs} +23 -7
- package/dist/lib/node-esm/react-surface-7YSGHZQM.mjs.map +7 -0
- package/dist/types/src/ScriptPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/artifact-definition.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts +1 -1
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface.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/template.d.ts +1 -1
- package/dist/types/src/hooks/view.d.ts +1 -1
- package/dist/types/src/hooks/view.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +3 -0
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types.d.ts +1 -1
- package/package.json +42 -41
- package/src/ScriptPlugin.tsx +16 -7
- package/src/capabilities/artifact-definition.ts +14 -9
- package/src/capabilities/react-surface.tsx +9 -3
- package/src/components/index.ts +1 -1
- package/src/hooks/view.ts +4 -1
- package/src/templates/chat.ts +4 -4
- package/src/translations.ts +3 -0
- package/dist/lib/browser/AutomationPanel-6HFRNRWV.mjs +0 -78
- package/dist/lib/browser/AutomationPanel-6HFRNRWV.mjs.map +0 -7
- package/dist/lib/browser/ScriptContainer-GR7X5NSI.mjs.map +0 -7
- package/dist/lib/browser/artifact-definition-NAWYXFF5.mjs.map +0 -7
- package/dist/lib/browser/chunk-YJAKD6E3.mjs.map +0 -7
- package/dist/lib/browser/react-surface-FGWXHB7P.mjs.map +0 -7
- package/dist/lib/node/AutomationPanel-RBQ4DODN.cjs +0 -104
- package/dist/lib/node/AutomationPanel-RBQ4DODN.cjs.map +0 -7
- package/dist/lib/node/ScriptContainer-SLARXOSU.cjs.map +0 -7
- package/dist/lib/node/artifact-definition-7AANUS3X.cjs.map +0 -7
- package/dist/lib/node/chunk-7XULMIYT.cjs.map +0 -7
- package/dist/lib/node/react-surface-2GH5HQX4.cjs.map +0 -7
- package/dist/lib/node-esm/AutomationPanel-WTVVVMRH.mjs +0 -79
- package/dist/lib/node-esm/AutomationPanel-WTVVVMRH.mjs.map +0 -7
- package/dist/lib/node-esm/ScriptContainer-MHRJXMC4.mjs.map +0 -7
- package/dist/lib/node-esm/artifact-definition-KBASPVMM.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-6CHX4CEL.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-MLE3J3TF.mjs.map +0 -7
- package/dist/types/src/components/AutomationPanel/AutomationPanel.d.ts +0 -16
- package/dist/types/src/components/AutomationPanel/AutomationPanel.d.ts.map +0 -1
- package/dist/types/src/components/AutomationPanel/index.d.ts +0 -4
- package/dist/types/src/components/AutomationPanel/index.d.ts.map +0 -1
- package/src/components/AutomationPanel/AutomationPanel.tsx +0 -104
- package/src/components/AutomationPanel/index.ts +0 -9
- /package/dist/lib/browser/{intent-resolver-I6VDXUDH.mjs.map → intent-resolver-D6FPY5ZA.mjs.map} +0 -0
- /package/dist/lib/node/{intent-resolver-MYATX7IR.cjs.map → intent-resolver-NYJFPD5B.cjs.map} +0 -0
- /package/dist/lib/node-esm/{intent-resolver-PBDTYC4P.mjs.map → intent-resolver-KLBHSMW4.mjs.map} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
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 { DeprecatedFormContainer, 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 <DeprecatedFormContainer>\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 </DeprecatedFormContainer>\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, useControlledState, 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] = useControlledState(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 <div role='form' className='flex flex-col w-full p-2 gap-4'>\n <Input.Root>\n <div role='none' className='flex flex-col gap-1'>\n <Input.Label>{t('description label')}</Input.Label>\n <Input.TextInput\n placeholder={t('description placeholder')}\n value={script.description ?? ''}\n onChange={(event) => {\n script.description = event.target.value;\n }}\n />\n </div>\n </Input.Root>\n </div>\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 './
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["import_react", "import_react_client", "import_react_ui", "ScriptSettings", "settings", "t", "useTranslation", "SCRIPT_PLUGIN", "client", "useClient", "handleAuthenticate", "identityKey", "halo", "identity", "get", "writeCredentials", "issuer", "issuanceDate", "Date", "subject", "id", "assertion", "serverName", "serverKey", "capabilities", "React", "DeprecatedFormContainer", "DeprecatedFormInput", "label", "Button", "onClick", "Select", "Root", "value", "editorInputMode", "onValueChange", "TriggerButton", "placeholder", "Portal", "Content", "Viewport", "EditorInputModes", "map", "mode", "Option", "key", "kebabize", "str", "replace", "$", "ofs", "toLowerCase", "ScriptSettingsPanel", "script", "dispatchPromise", "dispatch", "useIntentDispatcher", "space", "getSpace", "fn", "useQuery", "Filter", "schema", "FunctionType", "source", "githubToken", "AccessTokenType", "gistKey", "getMeta", "keys", "find", "gistUrl", "setGistUrl", "useState", "useEffect", "token", "gistId", "undefined", "timeout", "setTimeout", "octokit", "Octokit", "auth", "response", "request", "gist_id", "data", "html_url", "err", "log", "catch", "clearTimeout", "binding", "setBinding", "useControlledState", "handleBindingChange", "useCallback", "event", "target", "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", "div", "role", "className", "Input", "Label", "TextInput", "description", "onChange", "Separator", "h2", "disabled", "Clipboard", "IconButton", "onBlur", "p", "span", "
|
|
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 { DeprecatedFormContainer, 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 <DeprecatedFormContainer>\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 </DeprecatedFormContainer>\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, useControlledState, 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] = useControlledState(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 <div role='form' className='flex flex-col w-full p-2 gap-4'>\n <Input.Root>\n <div role='none' className='flex flex-col gap-1'>\n <Input.Label>{t('description label')}</Input.Label>\n <Input.TextInput\n placeholder={t('description placeholder')}\n value={script.description ?? ''}\n onChange={(event) => {\n script.description = event.target.value;\n }}\n />\n </div>\n </Input.Root>\n </div>\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 './DebugPanel';\nexport * from './ScriptSettings';\nexport * from './ScriptSettingsPanel';\n\nexport const ScriptContainer = lazy(() => import('./ScriptContainer'));\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,mBAAkB;AAGlB,0BAA0B;AAC1B,sBAA+C;AAC/C,6BAAuD;AACvD,2BAA6D;ACN7D,kBAAwB;AACxB,IAAAA,gBAA0E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ACZ3D,WAAW9C,8BAAAA,QAAA,cAACkH,2BAAUC,YAAU;IAAC3G,OAAOsC;MACzC9C,8BAAAA,QAAA,cAACI,iBAAAA,QAAAA;IAAO6G,UAAUtB;IAAYtF,SAASwF;KACpCjH,EAAE+G,aAAa,qBAAqB,eAAA,CAAA,CAAA,CAAA,CAAA;AAOnD;ACjLO,IAAM4B,sBAAkBC,oBAAK,MAAM,OAAO,gCAAA,CAAA;",
|
|
6
|
+
"names": ["import_react", "import_react_client", "import_react_ui", "ScriptSettings", "settings", "t", "useTranslation", "SCRIPT_PLUGIN", "client", "useClient", "handleAuthenticate", "identityKey", "halo", "identity", "get", "writeCredentials", "issuer", "issuanceDate", "Date", "subject", "id", "assertion", "serverName", "serverKey", "capabilities", "React", "DeprecatedFormContainer", "DeprecatedFormInput", "label", "Button", "onClick", "Select", "Root", "value", "editorInputMode", "onValueChange", "TriggerButton", "placeholder", "Portal", "Content", "Viewport", "EditorInputModes", "map", "mode", "Option", "key", "kebabize", "str", "replace", "$", "ofs", "toLowerCase", "ScriptSettingsPanel", "script", "dispatchPromise", "dispatch", "useIntentDispatcher", "space", "getSpace", "fn", "useQuery", "Filter", "schema", "FunctionType", "source", "githubToken", "AccessTokenType", "gistKey", "getMeta", "keys", "find", "gistUrl", "setGistUrl", "useState", "useEffect", "token", "gistId", "undefined", "timeout", "setTimeout", "octokit", "Octokit", "auth", "response", "request", "gist_id", "data", "html_url", "err", "log", "catch", "clearTimeout", "binding", "setBinding", "useControlledState", "handleBindingChange", "useCallback", "event", "target", "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", "div", "role", "className", "Input", "Label", "TextInput", "description", "onChange", "Separator", "h2", "disabled", "Clipboard", "IconButton", "onBlur", "p", "span", "ScriptContainer", "lazy"]
|
|
7
7
|
}
|
|
@@ -26,64 +26,45 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
26
|
mod
|
|
27
27
|
));
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var
|
|
30
|
-
__export(
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
var chunk_XKYJYY3T_exports = {};
|
|
30
|
+
__export(chunk_XKYJYY3T_exports, {
|
|
31
|
+
createDeploy: () => createDeploy,
|
|
32
|
+
createFormat: () => createFormat,
|
|
33
|
+
createTemplateSelect: () => createTemplateSelect,
|
|
34
|
+
createView: () => createView,
|
|
35
|
+
useDeployState: () => useDeployState,
|
|
36
|
+
useToolbarAction: () => useToolbarAction,
|
|
37
|
+
useToolbarState: () => useToolbarState
|
|
33
38
|
});
|
|
34
|
-
module.exports = __toCommonJS(
|
|
35
|
-
var
|
|
36
|
-
var import_chunk_K3ZZWVXS = require("./chunk-K3ZZWVXS.cjs");
|
|
39
|
+
module.exports = __toCommonJS(chunk_XKYJYY3T_exports);
|
|
40
|
+
var import_chunk_ITAJ3WRW = require("./chunk-ITAJ3WRW.cjs");
|
|
37
41
|
var import_chunk_5UH3F7TA = require("./chunk-5UH3F7TA.cjs");
|
|
38
|
-
var import_react =
|
|
39
|
-
var import_echo = require("@dxos/react-client/echo");
|
|
40
|
-
var import_halo = require("@dxos/react-client/halo");
|
|
41
|
-
var import_react_ui_editor = require("@dxos/react-ui-editor");
|
|
42
|
-
var import_react_ui_stack = require("@dxos/react-ui-stack");
|
|
43
|
-
var import_react_ui_theme = require("@dxos/react-ui-theme");
|
|
44
|
-
var import_react2 = __toESM(require("react"));
|
|
45
|
-
var import_echo2 = require("@dxos/react-client/echo");
|
|
46
|
-
var import_react_ui = require("@dxos/react-ui");
|
|
47
|
-
var import_react_ui_editor2 = require("@dxos/react-ui-editor");
|
|
48
|
-
var import_react_ui_menu = require("@dxos/react-ui-menu");
|
|
49
|
-
var import_react3 = require("react");
|
|
42
|
+
var import_react = require("react");
|
|
50
43
|
var import_functions = require("@dxos/functions");
|
|
51
44
|
var import_bundler = require("@dxos/functions/bundler");
|
|
52
45
|
var import_log = require("@dxos/log");
|
|
53
46
|
var import_react_client = require("@dxos/react-client");
|
|
54
|
-
var
|
|
55
|
-
var
|
|
56
|
-
var
|
|
47
|
+
var import_echo = require("@dxos/react-client/echo");
|
|
48
|
+
var import_react_ui = require("@dxos/react-ui");
|
|
49
|
+
var import_react_ui_menu = require("@dxos/react-ui-menu");
|
|
50
|
+
var import_react2 = require("react");
|
|
51
|
+
var import_live_object = require("@dxos/live-object");
|
|
57
52
|
var import_prettier = require("prettier");
|
|
58
53
|
var import_estree = __toESM(require("prettier/plugins/estree"));
|
|
59
54
|
var import_typescript = __toESM(require("prettier/plugins/typescript"));
|
|
60
|
-
var
|
|
55
|
+
var import_react3 = require("react");
|
|
61
56
|
var import_log2 = require("@dxos/log");
|
|
62
|
-
var
|
|
63
|
-
var
|
|
57
|
+
var import_react_ui_menu2 = require("@dxos/react-ui-menu");
|
|
58
|
+
var import_react4 = require("react");
|
|
64
59
|
var import_functions2 = require("@dxos/functions");
|
|
65
|
-
var
|
|
60
|
+
var import_live_object2 = require("@dxos/live-object");
|
|
61
|
+
var import_react_ui_menu3 = require("@dxos/react-ui-menu");
|
|
66
62
|
var import_react_ui_menu4 = require("@dxos/react-ui-menu");
|
|
67
|
-
var
|
|
68
|
-
var import_react6 = require("react");
|
|
63
|
+
var import_react5 = require("react");
|
|
69
64
|
var import_log3 = require("@dxos/log");
|
|
70
|
-
var import_react7 = require("react");
|
|
71
|
-
var import_live_object2 = require("@dxos/live-object");
|
|
72
|
-
var import_lang_javascript = require("@codemirror/lang-javascript");
|
|
73
|
-
var import_language = require("@codemirror/language");
|
|
74
|
-
var import_state = require("@codemirror/state");
|
|
75
|
-
var import_theme_one_dark = require("@codemirror/theme-one-dark");
|
|
76
|
-
var import_view = require("@codemirror/view");
|
|
77
|
-
var import_highlight = require("@lezer/highlight");
|
|
78
|
-
var import_codemirror_continue = require("@valtown/codemirror-continue");
|
|
79
|
-
var import_codemirror_ts = require("@valtown/codemirror-ts");
|
|
80
|
-
var import_react8 = __toESM(require("react"));
|
|
81
|
-
var import_react_ui3 = require("@dxos/react-ui");
|
|
82
|
-
var import_react_ui_editor3 = require("@dxos/react-ui-editor");
|
|
83
|
-
var import_util = require("@dxos/util");
|
|
84
65
|
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/experimental/plugin-script/src/hooks/deploy.ts";
|
|
85
66
|
var createDeploy = (state) => {
|
|
86
|
-
const errorItem = (0,
|
|
67
|
+
const errorItem = (0, import_react_ui_menu.createMenuAction)("error", {
|
|
87
68
|
label: state.error ?? [
|
|
88
69
|
"no error label",
|
|
89
70
|
{
|
|
@@ -93,7 +74,7 @@ var createDeploy = (state) => {
|
|
|
93
74
|
icon: "ph--warning-circle--regular",
|
|
94
75
|
hidden: !state.error
|
|
95
76
|
});
|
|
96
|
-
const deployAction = (0,
|
|
77
|
+
const deployAction = (0, import_react_ui_menu.createMenuAction)("deploy", {
|
|
97
78
|
type: "deploy",
|
|
98
79
|
label: [
|
|
99
80
|
state.deploying ? "pending label" : "deploy label",
|
|
@@ -105,7 +86,7 @@ var createDeploy = (state) => {
|
|
|
105
86
|
disabled: state.deploying,
|
|
106
87
|
classNames: state.deploying ? "[&_svg]:animate-spin" : ""
|
|
107
88
|
});
|
|
108
|
-
const copyAction = (0,
|
|
89
|
+
const copyAction = (0, import_react_ui_menu.createMenuAction)("copy", {
|
|
109
90
|
type: "copy",
|
|
110
91
|
label: [
|
|
111
92
|
"copy link label",
|
|
@@ -139,12 +120,12 @@ var createDeploy = (state) => {
|
|
|
139
120
|
};
|
|
140
121
|
};
|
|
141
122
|
var useDeployDeps = ({ state, script }) => {
|
|
142
|
-
const space = (0,
|
|
143
|
-
const [fn] = (0,
|
|
123
|
+
const space = (0, import_echo.getSpace)(script);
|
|
124
|
+
const [fn] = (0, import_echo.useQuery)(space, import_echo.Filter.schema(import_functions.FunctionType, {
|
|
144
125
|
source: script
|
|
145
126
|
}));
|
|
146
127
|
const client = (0, import_react_client.useClient)();
|
|
147
|
-
const existingFunctionUrl = (0,
|
|
128
|
+
const existingFunctionUrl = (0, import_react.useMemo)(() => fn && (0, import_functions.getUserFunctionUrlInMetadata)((0, import_echo.getMeta)(fn)), [
|
|
148
129
|
fn
|
|
149
130
|
]);
|
|
150
131
|
return {
|
|
@@ -159,7 +140,7 @@ var useDeployState = ({ state, script }) => {
|
|
|
159
140
|
state,
|
|
160
141
|
script
|
|
161
142
|
});
|
|
162
|
-
(0,
|
|
143
|
+
(0, import_react.useEffect)(() => {
|
|
163
144
|
if (!existingFunctionUrl) {
|
|
164
145
|
return;
|
|
165
146
|
}
|
|
@@ -170,7 +151,7 @@ var useDeployState = ({ state, script }) => {
|
|
|
170
151
|
existingFunctionUrl,
|
|
171
152
|
space
|
|
172
153
|
]);
|
|
173
|
-
(0,
|
|
154
|
+
(0, import_react.useEffect)(() => {
|
|
174
155
|
state.deployed = Boolean(existingFunctionUrl) && !script.changed;
|
|
175
156
|
}, [
|
|
176
157
|
script.changed,
|
|
@@ -182,8 +163,8 @@ var useDeployHandler = ({ state, script }) => {
|
|
|
182
163
|
state,
|
|
183
164
|
script
|
|
184
165
|
});
|
|
185
|
-
const { t } = (0,
|
|
186
|
-
return (0,
|
|
166
|
+
const { t } = (0, import_react_ui.useTranslation)(import_chunk_5UH3F7TA.SCRIPT_PLUGIN);
|
|
167
|
+
return (0, import_react.useCallback)(async () => {
|
|
187
168
|
if (!script.source || !space) {
|
|
188
169
|
return;
|
|
189
170
|
}
|
|
@@ -224,10 +205,10 @@ var useDeployHandler = ({ state, script }) => {
|
|
|
224
205
|
if (fn) {
|
|
225
206
|
fn.version = version;
|
|
226
207
|
}
|
|
227
|
-
const deployedFunction = fn ?? space.db.add((0,
|
|
208
|
+
const deployedFunction = fn ?? space.db.add((0, import_echo.create)(import_functions.FunctionType, {
|
|
228
209
|
name: functionId,
|
|
229
210
|
version,
|
|
230
|
-
source: (0,
|
|
211
|
+
source: (0, import_echo.makeRef)(script)
|
|
231
212
|
}));
|
|
232
213
|
script.changed = false;
|
|
233
214
|
if (script.description !== void 0 && script.description.trim() !== "") {
|
|
@@ -268,7 +249,7 @@ var useDeployHandler = ({ state, script }) => {
|
|
|
268
249
|
C: (f, a) => f(...a)
|
|
269
250
|
});
|
|
270
251
|
}
|
|
271
|
-
(0, import_functions.setUserFunctionUrlInMetadata)((0,
|
|
252
|
+
(0, import_functions.setUserFunctionUrlInMetadata)((0, import_echo.getMeta)(deployedFunction), `/${space.id}/${functionId}`);
|
|
272
253
|
state.view = "split";
|
|
273
254
|
} catch (err) {
|
|
274
255
|
import_log.log.catch(err, void 0, {
|
|
@@ -291,7 +272,7 @@ var useDeployHandler = ({ state, script }) => {
|
|
|
291
272
|
space?.id ?? null
|
|
292
273
|
]);
|
|
293
274
|
};
|
|
294
|
-
var useCopyHandler = ({ state }) => (0,
|
|
275
|
+
var useCopyHandler = ({ state }) => (0, import_react.useCallback)(async () => {
|
|
295
276
|
if (!state.functionUrl) {
|
|
296
277
|
return;
|
|
297
278
|
}
|
|
@@ -299,9 +280,12 @@ var useCopyHandler = ({ state }) => (0, import_react3.useCallback)(async () => {
|
|
|
299
280
|
}, [
|
|
300
281
|
state.functionUrl
|
|
301
282
|
]);
|
|
283
|
+
var useToolbarState = (initialState = {}) => {
|
|
284
|
+
return (0, import_react2.useMemo)(() => (0, import_live_object.create)(initialState), []);
|
|
285
|
+
};
|
|
302
286
|
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/plugins/experimental/plugin-script/src/hooks/format.ts";
|
|
303
287
|
var createFormat = () => {
|
|
304
|
-
const formatAction = (0,
|
|
288
|
+
const formatAction = (0, import_react_ui_menu2.createMenuAction)("format", {
|
|
305
289
|
label: [
|
|
306
290
|
"format label",
|
|
307
291
|
{
|
|
@@ -322,7 +306,7 @@ var createFormat = () => {
|
|
|
322
306
|
]
|
|
323
307
|
};
|
|
324
308
|
};
|
|
325
|
-
var useFormatHandler = ({ script }) => (0,
|
|
309
|
+
var useFormatHandler = ({ script }) => (0, import_react3.useCallback)(async () => {
|
|
326
310
|
if (!script.source) {
|
|
327
311
|
return;
|
|
328
312
|
}
|
|
@@ -348,7 +332,7 @@ var useFormatHandler = ({ script }) => (0, import_react4.useCallback)(async () =
|
|
|
348
332
|
script.source
|
|
349
333
|
]);
|
|
350
334
|
var createTemplateSelectGroup = () => {
|
|
351
|
-
return (0,
|
|
335
|
+
return (0, import_react_ui_menu3.createMenuItemGroup)("template-select", {
|
|
352
336
|
label: [
|
|
353
337
|
"template select group label",
|
|
354
338
|
{
|
|
@@ -359,8 +343,8 @@ var createTemplateSelectGroup = () => {
|
|
|
359
343
|
});
|
|
360
344
|
};
|
|
361
345
|
var createTemplateSelectActions = () => {
|
|
362
|
-
return
|
|
363
|
-
return (0,
|
|
346
|
+
return import_chunk_ITAJ3WRW.templates.map((template) => {
|
|
347
|
+
return (0, import_react_ui_menu3.createMenuAction)(`template--${template.id}`, {
|
|
364
348
|
label: template.name,
|
|
365
349
|
value: template.id,
|
|
366
350
|
type: "template"
|
|
@@ -388,12 +372,12 @@ var createTemplateSelect = () => {
|
|
|
388
372
|
};
|
|
389
373
|
};
|
|
390
374
|
var useTemplateSelectHandler = ({ script }) => {
|
|
391
|
-
return (0,
|
|
392
|
-
const template =
|
|
375
|
+
return (0, import_react4.useCallback)((templateId) => {
|
|
376
|
+
const template = import_chunk_ITAJ3WRW.templates.find((template2) => template2.id === templateId);
|
|
393
377
|
if (template) {
|
|
394
378
|
script.name = template.name;
|
|
395
379
|
script.source.target.content = template.source;
|
|
396
|
-
const metaKeys = (0,
|
|
380
|
+
const metaKeys = (0, import_live_object2.getMeta)(script).keys;
|
|
397
381
|
const oldPresetIndex = metaKeys.findIndex((key) => key.source === import_functions2.FUNCTIONS_PRESET_META_KEY);
|
|
398
382
|
if (oldPresetIndex >= 0) {
|
|
399
383
|
metaKeys.splice(oldPresetIndex, 1);
|
|
@@ -415,7 +399,7 @@ var views = {
|
|
|
415
399
|
debug: "ph--bug--regular"
|
|
416
400
|
};
|
|
417
401
|
var createViewGroupItem = (state) => {
|
|
418
|
-
return (0,
|
|
402
|
+
return (0, import_react_ui_menu4.createMenuItemGroup)("view", {
|
|
419
403
|
label: [
|
|
420
404
|
"view group label",
|
|
421
405
|
{
|
|
@@ -429,7 +413,7 @@ var createViewGroupItem = (state) => {
|
|
|
429
413
|
};
|
|
430
414
|
var createViewActions = (state) => {
|
|
431
415
|
return Object.entries(views).map(([viewType, icon]) => {
|
|
432
|
-
return (0,
|
|
416
|
+
return (0, import_react_ui_menu4.createMenuAction)(`view--${viewType}`, {
|
|
433
417
|
type: "view",
|
|
434
418
|
value: viewType,
|
|
435
419
|
label: [
|
|
@@ -469,7 +453,7 @@ var useToolbarAction = (props) => {
|
|
|
469
453
|
const handleFormat = useFormatHandler(props);
|
|
470
454
|
const handleDeploy = useDeployHandler(props);
|
|
471
455
|
const handleCopy = useCopyHandler(props);
|
|
472
|
-
return (0,
|
|
456
|
+
return (0, import_react5.useCallback)((action) => {
|
|
473
457
|
switch (action.properties.type) {
|
|
474
458
|
case "template":
|
|
475
459
|
handleTemplateSelect(action.properties.value);
|
|
@@ -501,219 +485,14 @@ var useToolbarAction = (props) => {
|
|
|
501
485
|
handleCopy
|
|
502
486
|
]);
|
|
503
487
|
};
|
|
504
|
-
var useToolbarState = (initialState = {}) => {
|
|
505
|
-
return (0, import_react7.useMemo)(() => (0, import_live_object2.create)(initialState), []);
|
|
506
|
-
};
|
|
507
|
-
var createToolbar = (state) => {
|
|
508
|
-
const templateSelect = createTemplateSelect();
|
|
509
|
-
const format2 = createFormat();
|
|
510
|
-
const gap = (0, import_react_ui_menu.createGapSeparator)();
|
|
511
|
-
const deploy = createDeploy(state);
|
|
512
|
-
const view = createView(state);
|
|
513
|
-
return {
|
|
514
|
-
nodes: [
|
|
515
|
-
...templateSelect.nodes,
|
|
516
|
-
...format2.nodes,
|
|
517
|
-
...gap.nodes,
|
|
518
|
-
...deploy.nodes,
|
|
519
|
-
...view.nodes
|
|
520
|
-
],
|
|
521
|
-
edges: [
|
|
522
|
-
...templateSelect.edges,
|
|
523
|
-
...format2.edges,
|
|
524
|
-
...gap.edges,
|
|
525
|
-
...deploy.edges,
|
|
526
|
-
...view.edges
|
|
527
|
-
]
|
|
528
|
-
};
|
|
529
|
-
};
|
|
530
|
-
var ScriptToolbar = ({ script, role, state, classNames }) => {
|
|
531
|
-
const handleAction = useToolbarAction({
|
|
532
|
-
state,
|
|
533
|
-
script
|
|
534
|
-
});
|
|
535
|
-
const toolbarCreator = (0, import_react2.useCallback)(() => createToolbar(state), [
|
|
536
|
-
state
|
|
537
|
-
]);
|
|
538
|
-
const menu = (0, import_react_ui_menu.useMenuActions)(toolbarCreator);
|
|
539
|
-
return /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
540
|
-
role: "none",
|
|
541
|
-
className: (0, import_react_ui_editor2.stackItemContentToolbarClassNames)(role)
|
|
542
|
-
}, /* @__PURE__ */ import_react2.default.createElement(import_react_ui.ElevationProvider, {
|
|
543
|
-
elevation: role === "section" ? "positioned" : "base"
|
|
544
|
-
}, /* @__PURE__ */ import_react2.default.createElement(import_react_ui_menu.MenuProvider, {
|
|
545
|
-
...menu,
|
|
546
|
-
onAction: handleAction,
|
|
547
|
-
attendableId: (0, import_echo2.fullyQualifiedId)(script)
|
|
548
|
-
}, /* @__PURE__ */ import_react2.default.createElement(import_react_ui_menu.ToolbarMenu, {
|
|
549
|
-
classNames
|
|
550
|
-
}))));
|
|
551
|
-
};
|
|
552
|
-
var TypescriptEditor = ({ id, env, className, initialValue, extensions, scrollTo, selection, toolbar, inputMode = "vscode" }) => {
|
|
553
|
-
const { themeMode } = (0, import_react_ui3.useThemeContext)();
|
|
554
|
-
const { parentRef, focusAttributes } = (0, import_react_ui_editor3.useTextEditor)(() => ({
|
|
555
|
-
id,
|
|
556
|
-
initialValue,
|
|
557
|
-
extensions: [
|
|
558
|
-
extensions,
|
|
559
|
-
(0, import_react_ui_editor3.createBasicExtensions)({
|
|
560
|
-
highlightActiveLine: true,
|
|
561
|
-
indentWithTab: true,
|
|
562
|
-
lineNumbers: true,
|
|
563
|
-
lineWrapping: false,
|
|
564
|
-
scrollPastEnd: true
|
|
565
|
-
}),
|
|
566
|
-
(0, import_react_ui_editor3.createThemeExtensions)({
|
|
567
|
-
themeMode,
|
|
568
|
-
syntaxHighlighting: true,
|
|
569
|
-
slots: {
|
|
570
|
-
content: {
|
|
571
|
-
className: import_react_ui_editor3.editorFullWidth
|
|
572
|
-
}
|
|
573
|
-
}
|
|
574
|
-
}),
|
|
575
|
-
// NOTE: Not using default editor gutter because folding for code works best right beside text.
|
|
576
|
-
import_react_ui_editor3.EditorView.theme({
|
|
577
|
-
".cm-gutters": {
|
|
578
|
-
// Match margin from content.
|
|
579
|
-
marginTop: "16px"
|
|
580
|
-
}
|
|
581
|
-
}),
|
|
582
|
-
import_react_ui_editor3.InputModeExtensions[inputMode],
|
|
583
|
-
(0, import_react_ui_editor3.folding)(),
|
|
584
|
-
// Continues block comments when you hit Enter.
|
|
585
|
-
import_state.Prec.high(import_view.keymap.of(import_codemirror_continue.continueKeymap)),
|
|
586
|
-
// TODO(burdon): Factor out.
|
|
587
|
-
[
|
|
588
|
-
import_react_ui_editor3.editorMonospace,
|
|
589
|
-
(0, import_lang_javascript.javascript)({
|
|
590
|
-
typescript: true
|
|
591
|
-
}),
|
|
592
|
-
// https://github.com/val-town/codemirror-ts
|
|
593
|
-
(0, import_react_ui_editor3.autocomplete)({
|
|
594
|
-
override: env ? [
|
|
595
|
-
(0, import_codemirror_ts.tsAutocomplete)()
|
|
596
|
-
] : []
|
|
597
|
-
}),
|
|
598
|
-
env ? [
|
|
599
|
-
import_codemirror_ts.tsFacet.of({
|
|
600
|
-
env,
|
|
601
|
-
path: `/src/${id}.ts`
|
|
602
|
-
}),
|
|
603
|
-
(0, import_codemirror_ts.tsSync)(),
|
|
604
|
-
(0, import_codemirror_ts.tsLinter)(),
|
|
605
|
-
(0, import_codemirror_ts.tsHover)({
|
|
606
|
-
renderTooltip: createTooltipRenderer(themeMode)
|
|
607
|
-
})
|
|
608
|
-
] : []
|
|
609
|
-
]
|
|
610
|
-
].filter(import_util.isNonNullable),
|
|
611
|
-
selection,
|
|
612
|
-
scrollTo
|
|
613
|
-
}), [
|
|
614
|
-
id,
|
|
615
|
-
extensions,
|
|
616
|
-
themeMode,
|
|
617
|
-
inputMode,
|
|
618
|
-
selection,
|
|
619
|
-
scrollTo
|
|
620
|
-
]);
|
|
621
|
-
return /* @__PURE__ */ import_react8.default.createElement("div", {
|
|
622
|
-
ref: parentRef,
|
|
623
|
-
"data-toolbar": toolbar ? "enabled" : "disabled",
|
|
624
|
-
className,
|
|
625
|
-
...focusAttributes
|
|
626
|
-
});
|
|
627
|
-
};
|
|
628
|
-
var createTooltipRenderer = (themeMode) => {
|
|
629
|
-
const theme = themeMode === "dark" ? import_theme_one_dark.oneDarkHighlightStyle : import_language.defaultHighlightStyle;
|
|
630
|
-
const classFromKind = (_kind) => {
|
|
631
|
-
const kind = _kind.endsWith("Name") ? "name" : _kind;
|
|
632
|
-
const validTag = kind in import_highlight.tags;
|
|
633
|
-
if (!validTag) {
|
|
634
|
-
return "";
|
|
635
|
-
}
|
|
636
|
-
const tag = import_highlight.tags[kind];
|
|
637
|
-
if (typeof tag === "function") {
|
|
638
|
-
return "";
|
|
639
|
-
}
|
|
640
|
-
return theme.style([
|
|
641
|
-
tag
|
|
642
|
-
]) ?? "";
|
|
643
|
-
};
|
|
644
|
-
return (info) => {
|
|
645
|
-
const div = document.createElement("div");
|
|
646
|
-
div.className = "p-1 rounded border border-separator bg-baseSurface xs:max-w-80 max-w-lg";
|
|
647
|
-
if (info.quickInfo?.displayParts) {
|
|
648
|
-
for (const part of info.quickInfo.displayParts) {
|
|
649
|
-
const span = div.appendChild(document.createElement("span"));
|
|
650
|
-
span.className = classFromKind(part.kind);
|
|
651
|
-
span.innerText = part.text;
|
|
652
|
-
}
|
|
653
|
-
}
|
|
654
|
-
return {
|
|
655
|
-
dom: div
|
|
656
|
-
};
|
|
657
|
-
};
|
|
658
|
-
};
|
|
659
|
-
var ScriptContainer = ({ role, classNames, script, settings = {
|
|
660
|
-
editorInputMode: "vscode"
|
|
661
|
-
}, env }) => {
|
|
662
|
-
const identity = (0, import_halo.useIdentity)();
|
|
663
|
-
const space = (0, import_echo.getSpace)(script);
|
|
664
|
-
const extensions = (0, import_react.useMemo)(() => [
|
|
665
|
-
(0, import_react_ui_editor.listener)({
|
|
666
|
-
onChange: (text) => {
|
|
667
|
-
if (script.source.target && script.source.target.content !== text) {
|
|
668
|
-
script.changed = true;
|
|
669
|
-
}
|
|
670
|
-
}
|
|
671
|
-
}),
|
|
672
|
-
(0, import_react_ui_editor.createDataExtensions)({
|
|
673
|
-
id: script.id,
|
|
674
|
-
text: script.source.target && (0, import_echo.createDocAccessor)(script.source.target, [
|
|
675
|
-
"content"
|
|
676
|
-
]),
|
|
677
|
-
space,
|
|
678
|
-
identity
|
|
679
|
-
})
|
|
680
|
-
], [
|
|
681
|
-
script,
|
|
682
|
-
script.source.target,
|
|
683
|
-
space,
|
|
684
|
-
identity
|
|
685
|
-
]);
|
|
686
|
-
const state = useToolbarState({
|
|
687
|
-
view: "editor"
|
|
688
|
-
});
|
|
689
|
-
useDeployState({
|
|
690
|
-
state,
|
|
691
|
-
script
|
|
692
|
-
});
|
|
693
|
-
return /* @__PURE__ */ import_react.default.createElement(import_react_ui_stack.StackItem.Content, {
|
|
694
|
-
toolbar: true
|
|
695
|
-
}, /* @__PURE__ */ import_react.default.createElement(ScriptToolbar, {
|
|
696
|
-
state,
|
|
697
|
-
role,
|
|
698
|
-
script
|
|
699
|
-
}), /* @__PURE__ */ import_react.default.createElement("div", {
|
|
700
|
-
role: "none",
|
|
701
|
-
className: (0, import_react_ui_theme.mx)("flex flex-col w-full overflow-hidden divide-y divide-separator", classNames)
|
|
702
|
-
}, state.view !== "debug" && /* @__PURE__ */ import_react.default.createElement(TypescriptEditor, {
|
|
703
|
-
id: script.id,
|
|
704
|
-
env,
|
|
705
|
-
initialValue: script.source?.target?.content,
|
|
706
|
-
extensions,
|
|
707
|
-
className: (0, import_react_ui_editor.stackItemContentEditorClassNames)(role),
|
|
708
|
-
inputMode: settings.editorInputMode,
|
|
709
|
-
toolbar: true
|
|
710
|
-
}), state.view !== "editor" && /* @__PURE__ */ import_react.default.createElement(import_chunk_K3ZZWVXS.DebugPanel, {
|
|
711
|
-
functionUrl: state.functionUrl
|
|
712
|
-
})));
|
|
713
|
-
};
|
|
714
|
-
var ScriptContainer_default = ScriptContainer;
|
|
715
488
|
// Annotate the CommonJS export names for ESM import in node:
|
|
716
489
|
0 && (module.exports = {
|
|
717
|
-
|
|
490
|
+
createDeploy,
|
|
491
|
+
createFormat,
|
|
492
|
+
createTemplateSelect,
|
|
493
|
+
createView,
|
|
494
|
+
useDeployState,
|
|
495
|
+
useToolbarAction,
|
|
496
|
+
useToolbarState
|
|
718
497
|
});
|
|
719
|
-
//# sourceMappingURL=
|
|
498
|
+
//# sourceMappingURL=chunk-XKYJYY3T.cjs.map
|