@dxos/plugin-script 0.7.4 → 0.7.5-main.9cb18ac

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (101) hide show
  1. package/dist/lib/browser/{AutomationPanel-PMTZROAZ.mjs → AutomationPanel-RFQAQ7NF.mjs} +2 -9
  2. package/dist/lib/browser/AutomationPanel-RFQAQ7NF.mjs.map +7 -0
  3. package/dist/lib/browser/{ScriptContainer-RYZFYCNK.mjs → ScriptContainer-GDVBWFI7.mjs} +16 -26
  4. package/dist/lib/browser/ScriptContainer-GDVBWFI7.mjs.map +7 -0
  5. package/dist/lib/browser/chunk-RQA3EB5K.mjs +26 -0
  6. package/dist/lib/browser/chunk-RQA3EB5K.mjs.map +7 -0
  7. package/dist/lib/browser/index.mjs +57 -131
  8. package/dist/lib/browser/index.mjs.map +3 -3
  9. package/dist/lib/browser/meta.json +1 -1
  10. package/dist/lib/browser/types.mjs +8 -0
  11. package/dist/lib/node/{AutomationPanel-AAGQREH7.cjs → AutomationPanel-5CJEF4MI.cjs} +12 -13
  12. package/dist/lib/node/AutomationPanel-5CJEF4MI.cjs.map +7 -0
  13. package/dist/lib/node/{ScriptContainer-FZ44UIRC.cjs → ScriptContainer-YWXXNLG6.cjs} +27 -28
  14. package/dist/lib/node/ScriptContainer-YWXXNLG6.cjs.map +7 -0
  15. package/dist/lib/node/chunk-PK3OQP5L.cjs +45 -0
  16. package/dist/lib/node/chunk-PK3OQP5L.cjs.map +7 -0
  17. package/dist/lib/node/index.cjs +61 -132
  18. package/dist/lib/node/index.cjs.map +3 -3
  19. package/dist/lib/node/meta.json +1 -1
  20. package/dist/lib/node/{types/index.cjs → types.cjs} +5 -9
  21. package/dist/lib/node/types.cjs.map +7 -0
  22. package/dist/lib/node-esm/{AutomationPanel-ETQEDY5I.mjs → AutomationPanel-7Y6REBNJ.mjs} +2 -9
  23. package/dist/lib/node-esm/AutomationPanel-7Y6REBNJ.mjs.map +7 -0
  24. package/dist/lib/node-esm/{ScriptContainer-3PKDW34A.mjs → ScriptContainer-BG2PHKEH.mjs} +16 -26
  25. package/dist/lib/node-esm/ScriptContainer-BG2PHKEH.mjs.map +7 -0
  26. package/dist/lib/node-esm/chunk-H6BBLQ5Q.mjs +27 -0
  27. package/dist/lib/node-esm/chunk-H6BBLQ5Q.mjs.map +7 -0
  28. package/dist/lib/node-esm/index.mjs +57 -131
  29. package/dist/lib/node-esm/index.mjs.map +3 -3
  30. package/dist/lib/node-esm/meta.json +1 -1
  31. package/dist/lib/node-esm/types.mjs +9 -0
  32. package/dist/types/src/ScriptPlugin.d.ts.map +1 -1
  33. package/dist/types/src/components/AutomationPanel/AutomationPanel.d.ts +2 -2
  34. package/dist/types/src/components/AutomationPanel/AutomationPanel.d.ts.map +1 -1
  35. package/dist/types/src/components/ScriptBlock/ScriptBlock.d.ts +1 -1
  36. package/dist/types/src/components/ScriptBlock/ScriptBlock.d.ts.map +1 -1
  37. package/dist/types/src/components/ScriptBlock/ScriptBlock.stories.d.ts.map +1 -1
  38. package/dist/types/src/components/ScriptEditor.d.ts +1 -1
  39. package/dist/types/src/components/ScriptEditor.d.ts.map +1 -1
  40. package/dist/types/src/components/ScriptSettingsPanel.d.ts +1 -1
  41. package/dist/types/src/components/ScriptSettingsPanel.d.ts.map +1 -1
  42. package/dist/types/src/translations.d.ts +0 -43
  43. package/dist/types/src/translations.d.ts.map +1 -1
  44. package/dist/types/src/types.d.ts +22 -0
  45. package/dist/types/src/types.d.ts.map +1 -0
  46. package/dist/types/tsconfig.tsbuildinfo +1 -0
  47. package/package.json +39 -47
  48. package/src/ScriptPlugin.tsx +43 -95
  49. package/src/components/AutomationPanel/AutomationPanel.tsx +2 -4
  50. package/src/components/FrameContainer/FrameContainer.tsx +1 -1
  51. package/src/components/ScriptBlock/ScriptBlock.stories.tsx +6 -3
  52. package/src/components/ScriptBlock/ScriptBlock.tsx +2 -2
  53. package/src/components/ScriptEditor.tsx +20 -18
  54. package/src/components/ScriptSettingsPanel.tsx +1 -2
  55. package/src/components/Toolbar/Toolbar.tsx +1 -1
  56. package/src/translations.ts +0 -4
  57. package/src/types.ts +38 -0
  58. package/dist/lib/browser/AutomationPanel-PMTZROAZ.mjs.map +0 -7
  59. package/dist/lib/browser/ScriptContainer-RYZFYCNK.mjs.map +0 -7
  60. package/dist/lib/browser/chunk-QFZUFT5G.mjs +0 -48
  61. package/dist/lib/browser/chunk-QFZUFT5G.mjs.map +0 -7
  62. package/dist/lib/browser/chunk-U3OP64V4.mjs +0 -123
  63. package/dist/lib/browser/chunk-U3OP64V4.mjs.map +0 -7
  64. package/dist/lib/browser/edge/index.mjs +0 -19
  65. package/dist/lib/browser/types/index.mjs +0 -12
  66. package/dist/lib/node/AutomationPanel-AAGQREH7.cjs.map +0 -7
  67. package/dist/lib/node/ScriptContainer-FZ44UIRC.cjs.map +0 -7
  68. package/dist/lib/node/chunk-CS25QNKZ.cjs +0 -151
  69. package/dist/lib/node/chunk-CS25QNKZ.cjs.map +0 -7
  70. package/dist/lib/node/chunk-DQYAU2CJ.cjs +0 -67
  71. package/dist/lib/node/chunk-DQYAU2CJ.cjs.map +0 -7
  72. package/dist/lib/node/edge/index.cjs +0 -41
  73. package/dist/lib/node/edge/index.cjs.map +0 -7
  74. package/dist/lib/node/types/index.cjs.map +0 -7
  75. package/dist/lib/node-esm/AutomationPanel-ETQEDY5I.mjs.map +0 -7
  76. package/dist/lib/node-esm/ScriptContainer-3PKDW34A.mjs.map +0 -7
  77. package/dist/lib/node-esm/chunk-36DLLQ6E.mjs +0 -125
  78. package/dist/lib/node-esm/chunk-36DLLQ6E.mjs.map +0 -7
  79. package/dist/lib/node-esm/chunk-GMVPKT6A.mjs +0 -49
  80. package/dist/lib/node-esm/chunk-GMVPKT6A.mjs.map +0 -7
  81. package/dist/lib/node-esm/edge/index.mjs +0 -20
  82. package/dist/lib/node-esm/edge/index.mjs.map +0 -7
  83. package/dist/lib/node-esm/types/index.mjs +0 -13
  84. package/dist/lib/node-esm/types/index.mjs.map +0 -7
  85. package/dist/types/src/edge/functions.d.ts +0 -25
  86. package/dist/types/src/edge/functions.d.ts.map +0 -1
  87. package/dist/types/src/edge/index.d.ts +0 -2
  88. package/dist/types/src/edge/index.d.ts.map +0 -1
  89. package/dist/types/src/types/index.d.ts +0 -3
  90. package/dist/types/src/types/index.d.ts.map +0 -1
  91. package/dist/types/src/types/schema.d.ts +0 -71
  92. package/dist/types/src/types/schema.d.ts.map +0 -1
  93. package/dist/types/src/types/types.d.ts +0 -8
  94. package/dist/types/src/types/types.d.ts.map +0 -1
  95. package/src/edge/functions.ts +0 -116
  96. package/src/edge/index.ts +0 -7
  97. package/src/types/index.ts +0 -6
  98. package/src/types/schema.ts +0 -44
  99. package/src/types/types.ts +0 -29
  100. /package/dist/lib/browser/{edge/index.mjs.map → types.mjs.map} +0 -0
  101. /package/dist/lib/{browser/types/index.mjs.map → node-esm/types.mjs.map} +0 -0
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/components/ScriptContainer.tsx", "../../../src/components/ScriptEditor.tsx", "../../../src/components/Toolbar/Toolbar.tsx", "../../../src/components/TypescriptEditor/TypescriptEditor.tsx"],
4
+ "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport React from 'react';\n\nimport { fullyQualifiedId } from '@dxos/react-client/echo';\nimport { useAttendableAttributes } from '@dxos/react-ui-attention';\nimport { mx } from '@dxos/react-ui-theme';\n\nimport { ScriptEditor, type ScriptEditorProps } from './ScriptEditor';\n\nconst ScriptContainer = ({ script, ...props }: ScriptEditorProps) => {\n const attendableAttrs = useAttendableAttributes(fullyQualifiedId(script));\n return (\n <div role='none' className={mx('flex row-span-2 w-full overflow-hidden attention-surface')} {...attendableAttrs}>\n <ScriptEditor {...props} script={script} />\n </div>\n );\n};\n\nexport default ScriptContainer;\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { format } from 'prettier';\nimport prettierPluginEstree from 'prettier/plugins/estree';\nimport prettierPluginTypescript from 'prettier/plugins/typescript';\nimport React, { useCallback, useMemo, useState } from 'react';\n\nimport {\n FUNCTIONS_PRESET_META_KEY,\n FunctionType,\n type ScriptType,\n getInvocationUrl,\n getUserFunctionUrlInMetadata,\n setUserFunctionUrlInMetadata,\n uploadWorkerFunction,\n incrementSemverPatch,\n} from '@dxos/functions';\nimport { log } from '@dxos/log';\nimport { useClient } from '@dxos/react-client';\nimport { create, createDocAccessor, Filter, getMeta, getSpace, makeRef, useQuery } from '@dxos/react-client/echo';\nimport { useIdentity } from '@dxos/react-client/halo';\nimport { useTranslation, type ThemedClassName } from '@dxos/react-ui';\nimport { createDataExtensions, listener } from '@dxos/react-ui-editor';\nimport { mx } from '@dxos/react-ui-theme';\n\nimport { DebugPanel } from './DebugPanel';\nimport { type TemplateSelectProps, Toolbar, type ViewType } from './Toolbar';\nimport { TypescriptEditor, type TypescriptEditorProps } from './TypescriptEditor';\nimport { Bundler } from '../bundler';\nimport { SCRIPT_PLUGIN } from '../meta';\nimport { templates } from '../templates';\n\nexport type ScriptEditorProps = ThemedClassName<{\n script: ScriptType;\n}> &\n Pick<TypescriptEditorProps, 'env'>;\n\nexport const ScriptEditor = ({ classNames, script, env }: ScriptEditorProps) => {\n const { t } = useTranslation(SCRIPT_PLUGIN);\n const client = useClient();\n const identity = useIdentity();\n const space = getSpace(script);\n const [fn] = useQuery(space, Filter.schema(FunctionType, { source: script }));\n\n const extensions = useMemo(\n () => [\n listener({\n onChange: (text) => {\n if (script.source.target && script.source.target.content !== text) {\n script.changed = true;\n }\n },\n }),\n createDataExtensions({\n id: script.id,\n text: script.source.target && createDocAccessor(script.source.target, ['content']),\n space,\n identity,\n }),\n ],\n [script, script.source.target, space, identity],\n );\n\n const [view, setView] = useState<ViewType>('editor');\n const existingFunctionUrl = fn && getUserFunctionUrlInMetadata(getMeta(fn));\n const [error, setError] = useState<string>();\n\n const handleFormat = useCallback(async () => {\n if (!script.source) {\n return;\n }\n\n try {\n script.source.target!.content = await format(script.source.target!.content, {\n parser: 'typescript',\n plugins: [prettierPluginEstree, prettierPluginTypescript],\n semi: true,\n singleQuote: true,\n });\n } catch (err: any) {\n // TODO(wittjosiah): Show error in UI.\n log.catch(err);\n }\n }, [script.source]);\n\n const handleTemplateChange: TemplateSelectProps['onTemplateSelect'] = (id) => {\n const template = templates.find((template) => template.id === id);\n if (template) {\n script.name = template.name;\n script.source!.target!.content = template.source;\n const metaKeys = getMeta(script).keys;\n const oldPresetIndex = metaKeys.findIndex((key) => key.source === FUNCTIONS_PRESET_META_KEY);\n if (oldPresetIndex >= 0) {\n metaKeys.splice(oldPresetIndex, 1);\n }\n if (template.presetId) {\n metaKeys.push({ source: FUNCTIONS_PRESET_META_KEY, id: template.presetId });\n }\n }\n };\n\n const handleDeploy = useCallback(async () => {\n if (!script.source || !identity || !space) {\n return;\n }\n\n setError(undefined);\n\n try {\n const existingFunctionId = existingFunctionUrl?.split('/').at(-1);\n\n const bundler = new Bundler({ platform: 'browser', sandboxedModules: [], remoteModules: {} });\n const buildResult = await bundler.bundle(script.source.target!.content);\n if (buildResult.error || !buildResult.bundle) {\n throw buildResult.error;\n }\n\n const { functionId, version, meta } = await uploadWorkerFunction({\n client,\n spaceId: space.id,\n version: fn ? incrementSemverPatch(fn.version) : '0.0.1',\n functionId: existingFunctionId,\n source: buildResult.bundle,\n });\n if (functionId === undefined || version === undefined) {\n throw new Error(`Upload didn't return expected data: functionId=${functionId}, version=${version}`);\n }\n\n log.info('function uploaded', { functionId, version });\n if (fn) {\n fn.version = version;\n }\n\n const deployedFunction =\n fn ?? space.db.add(create(FunctionType, { name: functionId, version, source: makeRef(script) }));\n\n script.changed = false;\n\n if (meta.inputSchema) {\n deployedFunction.inputSchema = meta.inputSchema;\n } else {\n log.verbose('no input schema in function metadata', { functionId });\n }\n\n setUserFunctionUrlInMetadata(getMeta(deployedFunction), `/${space.id}/${functionId}`);\n\n setView('split');\n } catch (err: any) {\n log.catch(err);\n setError(t('upload failed label'));\n }\n }, [fn, existingFunctionUrl, script, script.name, script.source, space?.id ?? null]);\n\n const functionUrl = useMemo(() => {\n if (!existingFunctionUrl) {\n return;\n }\n\n return getInvocationUrl(existingFunctionUrl, client.config.values.runtime?.services?.edge?.url ?? '', {\n spaceId: space?.id,\n });\n }, [existingFunctionUrl, space]);\n\n return (\n <div role='none' className={mx('flex flex-col w-full overflow-hidden divide-y divide-separator', classNames)}>\n <Toolbar\n deployed={Boolean(existingFunctionUrl) && !script.changed}\n functionUrl={functionUrl}\n error={error}\n view={view}\n templates={templates}\n onDeploy={handleDeploy}\n onFormat={handleFormat}\n onViewChange={setView}\n onTemplateSelect={handleTemplateChange}\n />\n\n {view !== 'preview' && (\n <TypescriptEditor\n id={script.id}\n env={env}\n initialValue={script.source?.target?.content}\n extensions={extensions}\n className='flex is-full bs-full overflow-hidden ch-focus-ring-inset-over-all'\n />\n )}\n\n {view !== 'editor' && <DebugPanel functionUrl={functionUrl} />}\n </div>\n );\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport React, { useState } from 'react';\n\nimport {\n ElevationProvider,\n Icon,\n Select,\n type ThemedClassName,\n ToggleGroup,\n ToggleGroupItem,\n type ToolbarButtonProps,\n Toolbar as NaturalToolbar,\n Tooltip,\n useTranslation,\n} from '@dxos/react-ui';\n\nimport { SCRIPT_PLUGIN } from '../../meta';\nimport { type Template } from '../../templates';\n\nexport type ToolbarProps = ThemedClassName<\n {\n deployed?: boolean;\n error?: string;\n functionUrl?: string;\n onDeploy?: () => Promise<void>;\n onFormat?: () => Promise<void>;\n } & TemplateSelectProps &\n ViewSelectorProps\n>;\n\nexport const Toolbar = ({\n classNames,\n deployed,\n error,\n functionUrl,\n view,\n templates,\n onDeploy,\n onFormat,\n onViewChange,\n onTemplateSelect,\n}: ToolbarProps) => {\n const { t } = useTranslation(SCRIPT_PLUGIN);\n const [pending, setPending] = useState(false);\n\n const handleCopyLink = async () => {\n if (!functionUrl) {\n return;\n }\n\n await navigator.clipboard.writeText(functionUrl);\n };\n\n const handleDeploy = async () => {\n if (!pending) {\n setPending(true);\n await onDeploy?.();\n setPending(false);\n }\n };\n\n // TODO(burdon): Factor out common toolbar components with sheet/editor?\n return (\n <ElevationProvider elevation='positioned'>\n <NaturalToolbar.Root classNames={['p-1', classNames]} style={{ contain: 'layout' }}>\n {templates && <TemplateSelect templates={templates} onTemplateSelect={onTemplateSelect} />}\n {onFormat && <ToolbarIconButton icon='ph--magic-wand--regular' text={t('format label')} onClick={onFormat} />}\n\n <div role='separator' className='grow' />\n\n {error ? (\n <Tooltip.Root>\n <Tooltip.Trigger>\n <Icon icon='ph--warning-circle--regular' size={4} />\n </Tooltip.Trigger>\n <Tooltip.Portal>\n <Tooltip.Content>\n <Tooltip.Arrow />\n {error}\n </Tooltip.Content>\n </Tooltip.Portal>\n </Tooltip.Root>\n ) : null}\n\n {functionUrl && deployed && (\n <ToolbarIconButton icon='ph--link--regular' text={t('copy link label')} onClick={handleCopyLink} />\n )}\n\n {onDeploy && (\n <ToolbarIconButton\n icon={pending ? 'ph--spinner-gap--regular' : 'ph--cloud-arrow-up--regular'}\n classNames={[pending && 'animate-spin']}\n text={pending ? t('pending label') : t('deploy label')}\n onClick={handleDeploy}\n />\n )}\n\n <ViewSelector view={view} onViewChange={onViewChange} />\n </NaturalToolbar.Root>\n </ElevationProvider>\n );\n};\n\nconst ToolbarIconButton = ({\n icon,\n text,\n classNames,\n disabled,\n onClick,\n}: { icon: string; text: string } & Pick<ToolbarButtonProps, 'classNames' | 'disabled' | 'onClick'>) => {\n return (\n <Tooltip.Root>\n <Tooltip.Trigger asChild>\n <NaturalToolbar.Button variant='ghost' disabled={disabled} onClick={onClick}>\n <Icon icon={icon} size={4} classNames={classNames} />\n </NaturalToolbar.Button>\n </Tooltip.Trigger>\n <Tooltip.Portal>\n <Tooltip.Content>\n <Tooltip.Arrow />\n {text}\n </Tooltip.Content>\n </Tooltip.Portal>\n </Tooltip.Root>\n );\n};\n\nexport type ViewType = 'editor' | 'split' | 'preview';\n\nexport type TemplateSelectProps = {\n templates?: Template[];\n onTemplateSelect?: (id: string) => void;\n};\n\nexport const TemplateSelect = ({ templates = [], onTemplateSelect }: TemplateSelectProps) => {\n return (\n <Select.Root value={''} onValueChange={onTemplateSelect}>\n <Select.TriggerButton />\n <Select.Portal>\n <Select.Content>\n <Select.Viewport>\n <Select.Option value={''}>Template</Select.Option>\n {templates.map(({ id, name }) => (\n <Select.Option key={id} value={id}>\n {name}\n </Select.Option>\n ))}\n </Select.Viewport>\n </Select.Content>\n </Select.Portal>\n </Select.Root>\n );\n};\n\nexport type ViewSelectorProps = {\n view?: ViewType;\n onViewChange?: (view: ViewType) => void;\n};\n\nexport const ViewSelector = ({ view, onViewChange }: ViewSelectorProps) => {\n return (\n <ToggleGroup type='single' value={view} onValueChange={(value) => onViewChange?.(value as ViewType)}>\n <ToggleGroupItem value='editor' classNames='bg-transparent text-subdued'>\n <Icon icon='ph--code--regular' size={4} />\n </ToggleGroupItem>\n <ToggleGroupItem value='split' classNames='bg-transparent text-subdued'>\n <Icon icon='ph--square-split-vertical--regular' size={4} />\n </ToggleGroupItem>\n <ToggleGroupItem value='preview' classNames='bg-transparent text-subdued'>\n <Icon icon='ph--eye--regular' size={4} />\n </ToggleGroupItem>\n </ToggleGroup>\n );\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { javascript } from '@codemirror/lang-javascript';\nimport { type VirtualTypeScriptEnvironment } from '@typescript/vfs';\nimport { tsSync, tsFacet, tsLinter, tsAutocomplete, tsHover } from '@valtown/codemirror-ts';\nimport React from 'react';\n\nimport { useThemeContext } from '@dxos/react-ui';\nimport {\n autocomplete,\n createBasicExtensions,\n createThemeExtensions,\n editorFullWidth,\n editorGutter,\n editorMonospace,\n InputModeExtensions,\n useTextEditor,\n type UseTextEditorProps,\n} from '@dxos/react-ui-editor';\nimport { nonNullable } from '@dxos/util';\n\nexport type TypescriptEditorProps = {\n id: string;\n env?: VirtualTypeScriptEnvironment;\n} & Pick<UseTextEditorProps, 'className' | 'initialValue' | 'extensions' | 'scrollTo' | 'selection'>;\n\nexport const TypescriptEditor = ({\n id,\n env,\n className,\n initialValue,\n extensions,\n scrollTo,\n selection,\n}: TypescriptEditorProps) => {\n const { themeMode } = useThemeContext();\n const { parentRef, focusAttributes } = useTextEditor(\n () => ({\n id,\n initialValue,\n extensions: [\n extensions,\n createBasicExtensions({\n highlightActiveLine: true,\n indentWithTab: true,\n lineNumbers: true,\n lineWrapping: false,\n scrollPastEnd: true,\n }),\n createThemeExtensions({\n themeMode,\n syntaxHighlighting: true,\n slots: {\n content: { className: editorFullWidth },\n },\n }),\n editorGutter,\n // TODO(burdon): Factor out.\n [\n editorMonospace,\n javascript({ typescript: true }),\n // https://github.com/val-town/codemirror-ts\n autocomplete({ override: env ? [tsAutocomplete()] : [] }),\n env ? [tsFacet.of({ env, path: `/src/${id}.ts` }), tsSync(), tsLinter(), tsHover()] : [],\n InputModeExtensions.vscode,\n ],\n ].filter(nonNullable),\n selection,\n scrollTo,\n }),\n [id, extensions, themeMode, selection, scrollTo],\n );\n\n return <div ref={parentRef} className={className} {...focusAttributes} />;\n};\n\nexport default TypescriptEditor;\n"],
5
+ "mappings": ";;;;;;;;;;;;;AAIA,OAAOA,YAAW;AAElB,SAASC,wBAAwB;AACjC,SAASC,+BAA+B;AACxC,SAASC,MAAAA,WAAU;;;ACJnB,SAASC,cAAc;AACvB,OAAOC,0BAA0B;AACjC,OAAOC,8BAA8B;AACrC,OAAOC,UAASC,aAAaC,SAASC,YAAAA,iBAAgB;AAEtD,SACEC,2BACAC,cAEAC,kBACAC,8BACAC,8BACAC,sBACAC,4BACK;AACP,SAASC,WAAW;AACpB,SAASC,iBAAiB;AAC1B,SAASC,QAAQC,mBAAmBC,QAAQC,SAASC,UAAUC,SAASC,gBAAgB;AACxF,SAASC,mBAAmB;AAC5B,SAASC,kBAAAA,uBAA4C;AACrD,SAASC,sBAAsBC,gBAAgB;AAC/C,SAASC,UAAU;;;ACrBnB,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;IAACK;IAAqBtB;GAAM;AAE/B,SACE,gBAAAyF,OAAA,cAACC,OAAAA;IAAIC,MAAK;IAAOC,WAAWC,GAAG,kEAAkEvG,UAAAA;KAC/F,gBAAAmG,OAAA,cAACK,SAAAA;IACCC,UAAUC,QAAQ1E,mBAAAA,KAAwB,CAAC/B,OAAOwB;IAClDkE;IACAxD;IACAN;IACAsB;IACAwD,UAAU5C;IACV6C,UAAUvE;IACVwE,cAAc/E;IACdgF,kBAAkB7D;MAGnBpB,SAAS,aACR,gBAAAsE,OAAA,cAACY,kBAAAA;IACCpF,IAAI1B,OAAO0B;IACXzB;IACA8G,cAAc/G,OAAOgB,QAAQM,QAAQC;IACrCN;IACAoF,WAAU;MAIbzE,SAAS,YAAY,gBAAAsE,OAAA,cAACc,YAAAA;IAAWtB;;AAGxC;;;ADpLA,IAAMuB,kBAAkB,CAAC,EAAEC,QAAQ,GAAGC,MAAAA,MAA0B;AAC9D,QAAMC,kBAAkBC,wBAAwBC,iBAAiBJ,MAAAA,CAAAA;AACjE,SACE,gBAAAK,OAAA,cAACC,OAAAA;IAAIC,MAAK;IAAOC,WAAWC,IAAG,0DAAA;IAA8D,GAAGP;KAC9F,gBAAAG,OAAA,cAACK,cAAAA;IAAc,GAAGT;IAAOD;;AAG/B;AAEA,IAAA,0BAAeD;",
6
+ "names": ["React", "fullyQualifiedId", "useAttendableAttributes", "mx", "format", "prettierPluginEstree", "prettierPluginTypescript", "React", "useCallback", "useMemo", "useState", "FUNCTIONS_PRESET_META_KEY", "FunctionType", "getInvocationUrl", "getUserFunctionUrlInMetadata", "setUserFunctionUrlInMetadata", "uploadWorkerFunction", "incrementSemverPatch", "log", "useClient", "create", "createDocAccessor", "Filter", "getMeta", "getSpace", "makeRef", "useQuery", "useIdentity", "useTranslation", "createDataExtensions", "listener", "mx", "React", "useState", "ElevationProvider", "Icon", "Select", "ToggleGroup", "ToggleGroupItem", "Toolbar", "NaturalToolbar", "Tooltip", "useTranslation", "Toolbar", "classNames", "deployed", "error", "functionUrl", "view", "templates", "onDeploy", "onFormat", "onViewChange", "onTemplateSelect", "t", "useTranslation", "SCRIPT_PLUGIN", "pending", "setPending", "useState", "handleCopyLink", "navigator", "clipboard", "writeText", "handleDeploy", "ElevationProvider", "elevation", "NaturalToolbar", "Root", "style", "contain", "TemplateSelect", "ToolbarIconButton", "icon", "text", "onClick", "div", "role", "className", "Tooltip", "Trigger", "Icon", "size", "Portal", "Content", "Arrow", "ViewSelector", "disabled", "asChild", "Button", "variant", "Select", "value", "onValueChange", "TriggerButton", "Viewport", "Option", "map", "id", "name", "key", "ToggleGroup", "type", "ToggleGroupItem", "javascript", "tsSync", "tsFacet", "tsLinter", "tsAutocomplete", "tsHover", "React", "useThemeContext", "autocomplete", "createBasicExtensions", "createThemeExtensions", "editorFullWidth", "editorGutter", "editorMonospace", "InputModeExtensions", "useTextEditor", "nonNullable", "TypescriptEditor", "id", "env", "className", "initialValue", "extensions", "scrollTo", "selection", "themeMode", "useThemeContext", "parentRef", "focusAttributes", "useTextEditor", "createBasicExtensions", "highlightActiveLine", "indentWithTab", "lineNumbers", "lineWrapping", "scrollPastEnd", "createThemeExtensions", "syntaxHighlighting", "slots", "content", "editorFullWidth", "editorGutter", "editorMonospace", "javascript", "typescript", "autocomplete", "override", "tsAutocomplete", "tsFacet", "of", "path", "tsSync", "tsLinter", "tsHover", "InputModeExtensions", "vscode", "filter", "nonNullable", "React", "div", "ref", "ScriptEditor", "classNames", "script", "env", "t", "useTranslation", "SCRIPT_PLUGIN", "client", "useClient", "identity", "useIdentity", "space", "getSpace", "fn", "useQuery", "Filter", "schema", "FunctionType", "source", "extensions", "useMemo", "listener", "onChange", "text", "target", "content", "changed", "createDataExtensions", "id", "createDocAccessor", "view", "setView", "useState", "existingFunctionUrl", "getUserFunctionUrlInMetadata", "getMeta", "error", "setError", "handleFormat", "useCallback", "format", "parser", "plugins", "prettierPluginEstree", "prettierPluginTypescript", "semi", "singleQuote", "err", "log", "catch", "handleTemplateChange", "template", "templates", "find", "name", "metaKeys", "keys", "oldPresetIndex", "findIndex", "key", "FUNCTIONS_PRESET_META_KEY", "splice", "presetId", "push", "handleDeploy", "undefined", "existingFunctionId", "split", "at", "bundler", "Bundler", "platform", "sandboxedModules", "remoteModules", "buildResult", "bundle", "functionId", "version", "meta", "uploadWorkerFunction", "spaceId", "incrementSemverPatch", "Error", "info", "deployedFunction", "db", "add", "create", "makeRef", "inputSchema", "verbose", "setUserFunctionUrlInMetadata", "functionUrl", "getInvocationUrl", "config", "values", "runtime", "services", "edge", "url", "React", "div", "role", "className", "mx", "Toolbar", "deployed", "Boolean", "onDeploy", "onFormat", "onViewChange", "onTemplateSelect", "TypescriptEditor", "initialValue", "DebugPanel", "ScriptContainer", "script", "props", "attendableAttrs", "useAttendableAttributes", "fullyQualifiedId", "React", "div", "role", "className", "mx", "ScriptEditor"]
7
+ }
@@ -0,0 +1,27 @@
1
+ import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
+ import {
3
+ SCRIPT_PLUGIN
4
+ } from "./chunk-SLTZMY34.mjs";
5
+
6
+ // packages/plugins/experimental/plugin-script/src/types.ts
7
+ import { S } from "@dxos/echo-schema";
8
+ import { ScriptType } from "@dxos/functions";
9
+ var ScriptAction;
10
+ (function(ScriptAction2) {
11
+ const SCRIPT_ACTION = `${SCRIPT_PLUGIN}/action`;
12
+ class Create extends S.TaggedClass()(`${SCRIPT_ACTION}/create`, {
13
+ input: S.Struct({
14
+ name: S.optional(S.String)
15
+ }),
16
+ output: S.Struct({
17
+ object: ScriptType
18
+ })
19
+ }) {
20
+ }
21
+ ScriptAction2.Create = Create;
22
+ })(ScriptAction || (ScriptAction = {}));
23
+
24
+ export {
25
+ ScriptAction
26
+ };
27
+ //# sourceMappingURL=chunk-H6BBLQ5Q.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 type {\n IntentResolverProvides,\n MetadataRecordsProvides,\n SettingsProvides,\n SurfaceProvides,\n TranslationsProvides,\n} from '@dxos/app-framework';\nimport { S } from '@dxos/echo-schema';\nimport { ScriptType } from '@dxos/functions';\nimport { type SchemaProvides } from '@dxos/plugin-space';\n\nimport { SCRIPT_PLUGIN } from './meta';\n\nexport namespace ScriptAction {\n const SCRIPT_ACTION = `${SCRIPT_PLUGIN}/action`;\n\n export class Create extends S.TaggedClass<Create>()(`${SCRIPT_ACTION}/create`, {\n input: S.Struct({\n name: S.optional(S.String),\n }),\n output: S.Struct({\n object: ScriptType,\n }),\n }) {}\n}\n\nexport type ScriptSettingsProps = {};\n\nexport type ScriptPluginProvides = IntentResolverProvides &\n MetadataRecordsProvides &\n SchemaProvides &\n SettingsProvides<ScriptSettingsProps> &\n SurfaceProvides &\n TranslationsProvides;\n"],
5
+ "mappings": ";;;;;;AAWA,SAASA,SAAS;AAClB,SAASC,kBAAkB;;UAKVC,eAAAA;AACf,QAAMC,gBAAgB,GAAGC,aAAAA;EAElB,MAAMC,eAAeC,EAAEC,YAAW,EAAW,GAAGJ,aAAAA,WAAwB;IAC7EK,OAAOF,EAAEG,OAAO;MACdC,MAAMJ,EAAEK,SAASL,EAAEM,MAAM;IAC3B,CAAA;IACAC,QAAQP,EAAEG,OAAO;MACfK,QAAQC;IACV,CAAA;EACF,CAAA,EAAA;EAAI;gBAPSV,SAAAA;AAQf,GAXiBH,iBAAAA,eAAAA,CAAAA,EAAAA;",
6
+ "names": ["S", "ScriptType", "ScriptAction", "SCRIPT_ACTION", "SCRIPT_PLUGIN", "Create", "S", "TaggedClass", "input", "Struct", "name", "optional", "String", "output", "object", "ScriptType"]
7
+ }
@@ -1,18 +1,12 @@
1
1
  import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
+ import {
3
+ ScriptAction
4
+ } from "./chunk-H6BBLQ5Q.mjs";
2
5
  import {
3
6
  Bundler,
4
7
  initializeBundler,
5
8
  templates
6
9
  } from "./chunk-4SRPREUK.mjs";
7
- import {
8
- getInvocationUrl,
9
- getUserFunctionUrlInMetadata
10
- } from "./chunk-36DLLQ6E.mjs";
11
- import {
12
- FunctionType,
13
- ScriptAction,
14
- ScriptType
15
- } from "./chunk-GMVPKT6A.mjs";
16
10
  import {
17
11
  SCRIPT_PLUGIN,
18
12
  meta_default
@@ -21,13 +15,10 @@ import {
21
15
  // packages/plugins/experimental/plugin-script/src/ScriptPlugin.tsx
22
16
  import wasmUrl from "esbuild-wasm/esbuild.wasm?url";
23
17
  import React3 from "react";
24
- import { NavigationAction, parseIntentPlugin, resolvePlugin } from "@dxos/app-framework";
25
- import { create } from "@dxos/live-object";
26
- import { parseClientPlugin } from "@dxos/plugin-client";
27
- import { createExtension, isActionGroup } from "@dxos/plugin-graph";
18
+ import { createIntent, createResolver, createSurface } from "@dxos/app-framework";
19
+ import { FunctionType as FunctionType2, ScriptType } from "@dxos/functions";
20
+ import { create, makeRef, RefArray } from "@dxos/live-object";
28
21
  import { TextType } from "@dxos/plugin-markdown/types";
29
- import { SpaceAction } from "@dxos/plugin-space";
30
- import { loadObjectReferences } from "@dxos/react-client/echo";
31
22
 
32
23
  // packages/plugins/experimental/plugin-script/src/compiler/compiler.ts
33
24
  import { createDefaultMapFromCDN, createSystem, createVirtualTypeScriptEnvironment } from "@typescript/vfs";
@@ -123,6 +114,7 @@ var ScriptSettings = ({ settings }) => {
123
114
 
124
115
  // packages/plugins/experimental/plugin-script/src/components/ScriptSettingsPanel.tsx
125
116
  import React2, { useCallback } from "react";
117
+ import { FunctionType, getInvocationUrl, getUserFunctionUrlInMetadata } from "@dxos/functions";
126
118
  import { useClient as useClient2 } from "@dxos/react-client";
127
119
  import { Filter, getMeta, getSpace, useQuery } from "@dxos/react-client/echo";
128
120
  import { Button as Button2, Icon, Input, useControlledValue, useTranslation as useTranslation2 } from "@dxos/react-ui";
@@ -198,16 +190,13 @@ var ScriptSettingsPanel = ({ script }) => {
198
190
  };
199
191
 
200
192
  // packages/plugins/experimental/plugin-script/src/components/index.ts
201
- var AutomationPanel = lazy(() => import("./AutomationPanel-ETQEDY5I.mjs"));
202
- var ScriptContainer = lazy(() => import("./ScriptContainer-3PKDW34A.mjs"));
193
+ var AutomationPanel = lazy(() => import("./AutomationPanel-7Y6REBNJ.mjs"));
194
+ var ScriptContainer = lazy(() => import("./ScriptContainer-BG2PHKEH.mjs"));
203
195
 
204
196
  // packages/plugins/experimental/plugin-script/src/translations.ts
205
197
  var translations_default = [
206
198
  {
207
199
  "en-US": {
208
- [ScriptType.typename]: {
209
- "typename label": "Script"
210
- },
211
200
  [SCRIPT_PLUGIN]: {
212
201
  "plugin name": "Scripts",
213
202
  "object title placeholder": "New script",
@@ -255,7 +244,7 @@ var ScriptPlugin = () => {
255
244
  metadata: {
256
245
  records: {
257
246
  [ScriptType.typename]: {
258
- createObject: ScriptAction.CREATE,
247
+ createObject: (props) => createIntent(ScriptAction.Create, props),
259
248
  placeholder: [
260
249
  "object title placeholder",
261
250
  {
@@ -264,8 +253,8 @@ var ScriptPlugin = () => {
264
253
  ],
265
254
  icon: "ph--code--regular",
266
255
  // TODO(wittjosiah): Move out of metadata.
267
- loadReferences: (script) => loadObjectReferences(script, (script2) => [
268
- script2.source
256
+ loadReferences: async (script) => await RefArray.loadAll([
257
+ script.source
269
258
  ])
270
259
  }
271
260
  }
@@ -276,118 +265,57 @@ var ScriptPlugin = () => {
276
265
  ScriptType
277
266
  ],
278
267
  system: [
279
- FunctionType
268
+ FunctionType2
280
269
  ]
281
270
  },
282
- graph: {
283
- builder: (plugins) => {
284
- const client = resolvePlugin(plugins, parseClientPlugin)?.provides.client;
285
- const dispatch = resolvePlugin(plugins, parseIntentPlugin)?.provides.intent.dispatch;
286
- if (!client || !dispatch) {
287
- return [];
288
- }
289
- return createExtension({
290
- id: ScriptAction.CREATE,
291
- filter: (node) => isActionGroup(node) && node.id.startsWith(SpaceAction.ADD_OBJECT),
292
- actions: ({ node }) => {
293
- const id = node.id.split("/").at(-1);
294
- const [spaceId, objectId] = id?.split(":") ?? [];
295
- const space = client.spaces.get().find((space2) => space2.id === spaceId);
296
- const object = objectId && space?.db.getObjectById(objectId);
297
- const target = objectId ? object : space;
298
- if (!target) {
299
- return;
300
- }
301
- return [
302
- {
303
- id: `${SCRIPT_PLUGIN}/create/${node.id}`,
304
- data: async () => {
305
- await dispatch([
306
- {
307
- plugin: SCRIPT_PLUGIN,
308
- action: ScriptAction.CREATE
309
- },
310
- {
311
- action: SpaceAction.ADD_OBJECT,
312
- data: {
313
- target
314
- }
315
- },
316
- {
317
- action: NavigationAction.OPEN
318
- }
319
- ]);
320
- },
321
- properties: {
322
- label: [
323
- "create object label",
324
- {
325
- ns: SCRIPT_PLUGIN
326
- }
327
- ],
328
- icon: "ph--code--regular",
329
- testId: "scriptPlugin.createObject"
330
- }
331
- }
332
- ];
333
- }
334
- });
335
- }
336
- },
337
271
  surface: {
338
- component: ({ data, role }) => {
339
- switch (role) {
340
- case "settings": {
341
- return data.plugin === meta_default.id ? /* @__PURE__ */ React3.createElement(ScriptSettings, {
342
- settings: {}
343
- }) : null;
344
- }
345
- case "article": {
346
- if (data.object instanceof ScriptType) {
347
- return /* @__PURE__ */ React3.createElement(ScriptContainer, {
348
- script: data.object,
349
- env: compiler.environment
350
- });
351
- }
352
- break;
353
- }
354
- case "complementary--automation": {
355
- if (data.subject instanceof ScriptType) {
356
- return {
357
- node: /* @__PURE__ */ React3.createElement(AutomationPanel, {
358
- subject: data.subject
359
- }),
360
- disposition: "hoist"
361
- };
362
- }
363
- break;
364
- }
365
- case "complementary--settings": {
366
- if (data.subject instanceof ScriptType) {
367
- return /* @__PURE__ */ React3.createElement(ScriptSettingsPanel, {
368
- script: data.subject
369
- });
370
- }
371
- break;
372
- }
373
- }
374
- return null;
375
- }
272
+ definitions: () => [
273
+ createSurface({
274
+ id: `${SCRIPT_PLUGIN}/settings`,
275
+ role: "settings",
276
+ filter: (data) => data.subject === SCRIPT_PLUGIN,
277
+ component: () => /* @__PURE__ */ React3.createElement(ScriptSettings, {
278
+ settings: {}
279
+ })
280
+ }),
281
+ createSurface({
282
+ id: `${SCRIPT_PLUGIN}/article`,
283
+ role: "article",
284
+ filter: (data) => data.subject instanceof ScriptType,
285
+ component: ({ data }) => /* @__PURE__ */ React3.createElement(ScriptContainer, {
286
+ script: data.subject,
287
+ env: compiler.environment
288
+ })
289
+ }),
290
+ createSurface({
291
+ id: `${SCRIPT_PLUGIN}/automation`,
292
+ role: "complementary--automation",
293
+ disposition: "hoist",
294
+ filter: (data) => data.subject instanceof ScriptType,
295
+ component: ({ data }) => /* @__PURE__ */ React3.createElement(AutomationPanel, {
296
+ subject: data.subject
297
+ })
298
+ }),
299
+ createSurface({
300
+ id: `${SCRIPT_PLUGIN}/settings-panel`,
301
+ role: "complementary--settings",
302
+ filter: (data) => data.subject instanceof ScriptType,
303
+ component: ({ data }) => /* @__PURE__ */ React3.createElement(ScriptSettingsPanel, {
304
+ script: data.subject
305
+ })
306
+ })
307
+ ]
376
308
  },
377
309
  intent: {
378
- resolver: (intent) => {
379
- switch (intent.action) {
380
- case ScriptAction.CREATE: {
381
- return {
382
- data: create(ScriptType, {
383
- source: create(TextType, {
384
- content: templates[0].source
385
- })
386
- })
387
- };
388
- }
310
+ resolvers: () => createResolver(ScriptAction.Create, ({ name }) => ({
311
+ data: {
312
+ object: create(ScriptType, {
313
+ source: makeRef(create(TextType, {
314
+ content: templates[0].source
315
+ }))
316
+ })
389
317
  }
390
- }
318
+ }))
391
319
  }
392
320
  }
393
321
  };
@@ -399,13 +327,11 @@ export {
399
327
  AutomationPanel,
400
328
  Bundler,
401
329
  Compiler,
402
- FunctionType,
403
330
  ScriptAction,
404
331
  ScriptContainer,
405
332
  ScriptPlugin,
406
333
  ScriptSettings,
407
334
  ScriptSettingsPanel,
408
- ScriptType,
409
335
  src_default as default,
410
336
  initializeBundler
411
337
  };
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/ScriptPlugin.tsx", "../../../src/compiler/compiler.ts", "../../../src/components/index.ts", "../../../src/components/ScriptSettings/ScriptSettings.tsx", "../../../src/components/ScriptSettingsPanel.tsx", "../../../src/translations.ts", "../../../src/index.ts"],
4
- "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\n// @ts-ignore\nimport wasmUrl from 'esbuild-wasm/esbuild.wasm?url';\nimport React from 'react';\n\nimport { NavigationAction, parseIntentPlugin, type PluginDefinition, resolvePlugin } from '@dxos/app-framework';\nimport { create } from '@dxos/live-object';\nimport { parseClientPlugin } from '@dxos/plugin-client';\nimport { type ActionGroup, createExtension, isActionGroup } from '@dxos/plugin-graph';\nimport { TextType } from '@dxos/plugin-markdown/types';\nimport { SpaceAction } from '@dxos/plugin-space';\nimport { loadObjectReferences } from '@dxos/react-client/echo';\n\nimport { initializeBundler } from './bundler';\nimport { Compiler } from './compiler';\nimport { AutomationPanel, ScriptContainer, ScriptSettings, ScriptSettingsPanel } from './components';\nimport meta, { SCRIPT_PLUGIN } from './meta';\nimport { templates } from './templates';\nimport translations from './translations';\nimport { FunctionType, ScriptAction, type ScriptPluginProvides, ScriptType } from './types';\n\nexport const ScriptPlugin = (): PluginDefinition<ScriptPluginProvides> => {\n const compiler = new Compiler();\n\n return {\n meta,\n initialize: async () => {\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 provides: {\n settings: {},\n metadata: {\n records: {\n [ScriptType.typename]: {\n createObject: ScriptAction.CREATE,\n placeholder: ['object title placeholder', { ns: SCRIPT_PLUGIN }],\n icon: 'ph--code--regular',\n // TODO(wittjosiah): Move out of metadata.\n loadReferences: (script: ScriptType) => loadObjectReferences(script, (script) => [script.source]),\n },\n },\n },\n translations,\n echo: {\n schema: [ScriptType],\n system: [FunctionType],\n },\n graph: {\n builder: (plugins) => {\n const client = resolvePlugin(plugins, parseClientPlugin)?.provides.client;\n const dispatch = resolvePlugin(plugins, parseIntentPlugin)?.provides.intent.dispatch;\n if (!client || !dispatch) {\n return [];\n }\n\n return createExtension({\n id: ScriptAction.CREATE,\n filter: (node): node is ActionGroup => isActionGroup(node) && node.id.startsWith(SpaceAction.ADD_OBJECT),\n actions: ({ node }) => {\n const id = node.id.split('/').at(-1);\n const [spaceId, objectId] = id?.split(':') ?? [];\n const space = client.spaces.get().find((space) => space.id === spaceId);\n const object = objectId && space?.db.getObjectById(objectId);\n const target = objectId ? object : space;\n if (!target) {\n return;\n }\n\n return [\n {\n id: `${SCRIPT_PLUGIN}/create/${node.id}`,\n data: async () => {\n await dispatch([\n { plugin: SCRIPT_PLUGIN, action: ScriptAction.CREATE },\n { action: SpaceAction.ADD_OBJECT, data: { target } },\n { action: NavigationAction.OPEN },\n ]);\n },\n properties: {\n label: ['create object label', { ns: SCRIPT_PLUGIN }],\n icon: 'ph--code--regular',\n testId: 'scriptPlugin.createObject',\n },\n },\n ];\n },\n });\n },\n },\n surface: {\n component: ({ data, role }) => {\n switch (role) {\n case 'settings': {\n return data.plugin === meta.id ? <ScriptSettings settings={{}} /> : null;\n }\n\n case 'article': {\n if (data.object instanceof ScriptType) {\n return <ScriptContainer script={data.object} env={compiler.environment} />;\n }\n break;\n }\n\n case 'complementary--automation': {\n if (data.subject instanceof ScriptType) {\n return {\n node: <AutomationPanel subject={data.subject as any} />,\n disposition: 'hoist',\n };\n }\n break;\n }\n\n case 'complementary--settings': {\n if (data.subject instanceof ScriptType) {\n return <ScriptSettingsPanel script={data.subject} />;\n }\n break;\n }\n }\n\n return null;\n },\n },\n intent: {\n resolver: (intent) => {\n switch (intent.action) {\n case ScriptAction.CREATE: {\n return {\n data: create(ScriptType, {\n source: create(TextType, {\n content: templates[0].source,\n }),\n }),\n };\n }\n }\n },\n },\n },\n };\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", "//\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", "//\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, useTranslation } from '@dxos/react-ui';\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 <DeprecatedFormInput label={t('authenticate action label')}>\n <Button onClick={handleAuthenticate}>{t('authenticate button label')}</Button>\n </DeprecatedFormInput>\n </>\n );\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport React, { type ChangeEvent, useCallback } from 'react';\n\nimport { useClient } from '@dxos/react-client';\nimport { Filter, getMeta, getSpace, useQuery } from '@dxos/react-client/echo';\nimport { Button, Icon, Input, useControlledValue, useTranslation } from '@dxos/react-ui';\n\nimport { getInvocationUrl, getUserFunctionUrlInMetadata } from '../edge';\nimport { SCRIPT_PLUGIN } from '../meta';\nimport { FunctionType, type ScriptType } from '../types';\n\nexport type ScriptSettingsPanelProps = {\n script: ScriptType;\n};\n\nexport const ScriptSettingsPanel = ({ script }: ScriptSettingsPanelProps) => {\n const { t } = useTranslation(SCRIPT_PLUGIN);\n const client = useClient();\n const space = getSpace(script);\n const [fn] = useQuery(space, Filter.schema(FunctionType, { source: script }));\n\n const handleNameChange = useCallback(\n (event: ChangeEvent<HTMLInputElement>) => {\n script.name = event.target.value;\n },\n [script],\n );\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 // TODO(wittjosiah): Use ClipboardProvider.\n const handleCopy = useCallback(() => functionUrl && navigator.clipboard.writeText(functionUrl), [functionUrl]);\n\n return (\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('name label')}</Input.Label>\n <Input.TextInput\n placeholder={t('object title placeholder')}\n value={script.name ?? ''}\n onChange={handleNameChange}\n />\n </div>\n </Input.Root>\n {fn && (\n <>\n <hr className='border-separator' />\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 <Button onClick={handleCopy}>\n <Icon icon='ph--copy--regular' size={4} />\n </Button>\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 </>\n )}\n </div>\n );\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { SCRIPT_PLUGIN } from './meta';\nimport { ScriptType } from './types';\n\nexport default [\n {\n 'en-US': {\n [ScriptType.typename]: {\n 'typename label': 'Script',\n },\n [SCRIPT_PLUGIN]: {\n 'plugin name': 'Scripts',\n 'object title placeholder': 'New script',\n 'create object label': 'Create script',\n 'create stack section label': 'Create script',\n 'binding placeholder': 'Function name',\n 'function request placeholder': 'Function request',\n 'deploy label': 'Deploy',\n 'deployed label': 'Current version of the script is deployed',\n 'upload failed label': 'Upload failed',\n 'copy link label': 'Copy function link',\n 'format label': 'Format',\n 'toggle details label': 'Toggle details panel',\n 'authenticate action label': 'Authenticate functions service',\n 'authenticate button label': 'Authenticate',\n 'name label': 'Name',\n 'remote function settings heading': 'Remote Function',\n 'function url label': 'Invocation URL',\n 'function binding label': 'Function binding',\n 'function binding placeholder': 'BINDING',\n },\n },\n },\n];\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { ScriptPlugin } from './ScriptPlugin';\n\nexport default ScriptPlugin;\n\nexport * from './bundler';\nexport * from './compiler';\nexport * from './components';\nexport * from './types';\n\nexport * from './ScriptPlugin';\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;AAKA,OAAOA,aAAa;AACpB,OAAOC,YAAW;AAElB,SAASC,kBAAkBC,mBAA0CC,qBAAqB;AAC1F,SAASC,cAAc;AACvB,SAASC,yBAAyB;AAClC,SAA2BC,iBAAiBC,qBAAqB;AACjE,SAASC,gBAAgB;AACzB,SAASC,mBAAmB;AAC5B,SAASC,4BAA4B;;;ACVrC,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;A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A,cAACQ,qBAAAA;kBAAoBzD,QAAQsC,KAAKgB;;cAC3C;AACA;YACF;UACF;AAEA,iBAAO;QACT;MACF;MACAtC,QAAQ;QACN0C,UAAU,CAAC1C,WAAAA;AACT,kBAAQA,OAAOwB,QAAM;YACnB,KAAK/C,aAAaC,QAAQ;AACxB,qBAAO;gBACL4C,MAAMqB,OAAOrE,YAAY;kBACvBY,QAAQyD,OAAOC,UAAU;oBACvBC,SAASC,UAAU,CAAA,EAAG5D;kBACxB,CAAA;gBACF,CAAA;cACF;YACF;UACF;QACF;MACF;IACF;EACF;AACF;;;AMvJA,IAAA,cAAe6D;",
6
- "names": ["wasmUrl", "React", "NavigationAction", "parseIntentPlugin", "resolvePlugin", "create", "parseClientPlugin", "createExtension", "isActionGroup", "TextType", "SpaceAction", "loadObjectReferences", "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", "lazy", "React", "useClient", "Button", "useTranslation", "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", "React", "useCallback", "useClient", "Filter", "getMeta", "getSpace", "useQuery", "Button", "Icon", "Input", "useControlledValue", "useTranslation", "ScriptSettingsPanel", "script", "t", "useTranslation", "SCRIPT_PLUGIN", "client", "useClient", "space", "getSpace", "fn", "useQuery", "Filter", "schema", "FunctionType", "source", "handleNameChange", "useCallback", "event", "name", "target", "value", "binding", "setBinding", "useControlledValue", "handleBindingChange", "handleBindingBlur", "functionPath", "getUserFunctionUrlInMetadata", "getMeta", "functionUrl", "getInvocationUrl", "config", "values", "runtime", "services", "edge", "url", "spaceId", "id", "handleCopy", "navigator", "clipboard", "writeText", "React", "div", "role", "className", "Input", "Root", "Label", "TextInput", "placeholder", "onChange", "hr", "h2", "disabled", "Button", "onClick", "Icon", "icon", "size", "onBlur", "AutomationPanel", "lazy", "ScriptContainer", "ScriptType", "typename", "SCRIPT_PLUGIN", "ScriptPlugin", "compiler", "Compiler", "meta", "initialize", "setFile", "initializeBundler", "wasmUrl", "provides", "settings", "metadata", "records", "ScriptType", "typename", "createObject", "ScriptAction", "CREATE", "placeholder", "ns", "SCRIPT_PLUGIN", "icon", "loadReferences", "script", "loadObjectReferences", "source", "translations", "echo", "schema", "system", "FunctionType", "graph", "builder", "plugins", "client", "resolvePlugin", "parseClientPlugin", "dispatch", "parseIntentPlugin", "intent", "createExtension", "id", "filter", "node", "isActionGroup", "startsWith", "SpaceAction", "ADD_OBJECT", "actions", "split", "at", "spaceId", "objectId", "space", "spaces", "get", "find", "object", "db", "getObjectById", "target", "data", "plugin", "action", "NavigationAction", "OPEN", "properties", "label", "testId", "surface", "component", "role", "React", "ScriptSettings", "ScriptContainer", "env", "environment", "subject", "AutomationPanel", "disposition", "ScriptSettingsPanel", "resolver", "create", "TextType", "content", "templates", "ScriptPlugin"]
4
+ "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\n// @ts-ignore\nimport wasmUrl from 'esbuild-wasm/esbuild.wasm?url';\nimport React from 'react';\n\nimport { createIntent, createResolver, createSurface, type PluginDefinition } from '@dxos/app-framework';\nimport { FunctionType, ScriptType } from '@dxos/functions';\nimport { create, makeRef, RefArray } from '@dxos/live-object';\nimport { TextType } from '@dxos/plugin-markdown/types';\n\nimport { initializeBundler } from './bundler';\nimport { Compiler } from './compiler';\nimport { AutomationPanel, ScriptContainer, ScriptSettings, ScriptSettingsPanel } from './components';\nimport meta, { SCRIPT_PLUGIN } from './meta';\nimport { templates } from './templates';\nimport translations from './translations';\nimport { ScriptAction, type ScriptPluginProvides } from './types';\n\nexport const ScriptPlugin = (): PluginDefinition<ScriptPluginProvides> => {\n const compiler = new Compiler();\n\n return {\n meta,\n initialize: async () => {\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 provides: {\n settings: {},\n metadata: {\n records: {\n [ScriptType.typename]: {\n createObject: (props: { name?: string }) => createIntent(ScriptAction.Create, props),\n placeholder: ['object title placeholder', { ns: SCRIPT_PLUGIN }],\n icon: 'ph--code--regular',\n // TODO(wittjosiah): Move out of metadata.\n loadReferences: async (script: ScriptType) => await RefArray.loadAll([script.source]),\n },\n },\n },\n translations,\n echo: {\n schema: [ScriptType],\n system: [FunctionType],\n },\n surface: {\n definitions: () => [\n createSurface({\n id: `${SCRIPT_PLUGIN}/settings`,\n role: 'settings',\n filter: (data): data is any => data.subject === SCRIPT_PLUGIN,\n component: () => <ScriptSettings settings={{}} />,\n }),\n createSurface({\n id: `${SCRIPT_PLUGIN}/article`,\n role: 'article',\n filter: (data): data is { subject: ScriptType } => data.subject instanceof ScriptType,\n component: ({ data }) => <ScriptContainer script={data.subject} env={compiler.environment} />,\n }),\n createSurface({\n id: `${SCRIPT_PLUGIN}/automation`,\n role: 'complementary--automation',\n disposition: 'hoist',\n filter: (data): data is { subject: ScriptType } => data.subject instanceof ScriptType,\n component: ({ data }) => <AutomationPanel subject={data.subject} />,\n }),\n createSurface({\n id: `${SCRIPT_PLUGIN}/settings-panel`,\n role: 'complementary--settings',\n filter: (data): data is { subject: ScriptType } => data.subject instanceof ScriptType,\n component: ({ data }) => <ScriptSettingsPanel script={data.subject} />,\n }),\n ],\n },\n intent: {\n resolvers: () =>\n createResolver(ScriptAction.Create, ({ name }) => ({\n data: {\n object: create(ScriptType, {\n source: makeRef(\n create(TextType, {\n content: templates[0].source,\n }),\n ),\n }),\n },\n })),\n },\n },\n };\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", "//\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", "//\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, useTranslation } from '@dxos/react-ui';\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 <DeprecatedFormInput label={t('authenticate action label')}>\n <Button onClick={handleAuthenticate}>{t('authenticate button label')}</Button>\n </DeprecatedFormInput>\n </>\n );\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport React, { type ChangeEvent, useCallback } from 'react';\n\nimport { FunctionType, type ScriptType, getInvocationUrl, getUserFunctionUrlInMetadata } from '@dxos/functions';\nimport { useClient } from '@dxos/react-client';\nimport { Filter, getMeta, getSpace, useQuery } from '@dxos/react-client/echo';\nimport { Button, Icon, Input, useControlledValue, useTranslation } from '@dxos/react-ui';\n\nimport { SCRIPT_PLUGIN } from '../meta';\n\nexport type ScriptSettingsPanelProps = {\n script: ScriptType;\n};\n\nexport const ScriptSettingsPanel = ({ script }: ScriptSettingsPanelProps) => {\n const { t } = useTranslation(SCRIPT_PLUGIN);\n const client = useClient();\n const space = getSpace(script);\n const [fn] = useQuery(space, Filter.schema(FunctionType, { source: script }));\n\n const handleNameChange = useCallback(\n (event: ChangeEvent<HTMLInputElement>) => {\n script.name = event.target.value;\n },\n [script],\n );\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 // TODO(wittjosiah): Use ClipboardProvider.\n const handleCopy = useCallback(() => functionUrl && navigator.clipboard.writeText(functionUrl), [functionUrl]);\n\n return (\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('name label')}</Input.Label>\n <Input.TextInput\n placeholder={t('object title placeholder')}\n value={script.name ?? ''}\n onChange={handleNameChange}\n />\n </div>\n </Input.Root>\n {fn && (\n <>\n <hr className='border-separator' />\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 <Button onClick={handleCopy}>\n <Icon icon='ph--copy--regular' size={4} />\n </Button>\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 </>\n )}\n </div>\n );\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { SCRIPT_PLUGIN } from './meta';\n\nexport default [\n {\n 'en-US': {\n [SCRIPT_PLUGIN]: {\n 'plugin name': 'Scripts',\n 'object title placeholder': 'New script',\n 'create object label': 'Create script',\n 'create stack section label': 'Create script',\n 'binding placeholder': 'Function name',\n 'function request placeholder': 'Function request',\n 'deploy label': 'Deploy',\n 'deployed label': 'Current version of the script is deployed',\n 'upload failed label': 'Upload failed',\n 'copy link label': 'Copy function link',\n 'format label': 'Format',\n 'toggle details label': 'Toggle details panel',\n 'authenticate action label': 'Authenticate functions service',\n 'authenticate button label': 'Authenticate',\n 'name label': 'Name',\n 'remote function settings heading': 'Remote Function',\n 'function url label': 'Invocation URL',\n 'function binding label': 'Function binding',\n 'function binding placeholder': 'BINDING',\n },\n },\n },\n];\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { ScriptPlugin } from './ScriptPlugin';\n\nexport default ScriptPlugin;\n\nexport * from './bundler';\nexport * from './compiler';\nexport * from './components';\nexport * from './types';\n\nexport * from './ScriptPlugin';\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;AAKA,OAAOA,aAAa;AACpB,OAAOC,YAAW;AAElB,SAASC,cAAcC,gBAAgBC,qBAA4C;AACnF,SAASC,gBAAAA,eAAcC,kBAAkB;AACzC,SAASC,QAAQC,SAASC,gBAAgB;AAC1C,SAASC,gBAAgB;;;ACPzB,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,SAA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1D,CAAA;UACAL,cAAc;YACZC,IAAI,GAAGf,aAAAA;YACPgB,MAAM;YACNC,QAAQ,CAACC,SAA0CA,KAAKC,mBAAmB5B;YAC3E6B,WAAW,CAAC,EAAEF,KAAI,MAAO,gBAAAG,OAAA,cAACO,qBAAAA;cAAoBzB,QAAQe,KAAKC;;UAC7D,CAAA;;MAEJ;MACAU,QAAQ;QACNC,WAAW,MACTC,eAAenC,aAAaC,QAAQ,CAAC,EAAEmC,KAAI,OAAQ;UACjDd,MAAM;YACJe,QAAQC,OAAO3C,YAAY;cACzBe,QAAQ6B,QACND,OAAOE,UAAU;gBACfC,SAASC,UAAU,CAAA,EAAGhC;cACxB,CAAA,CAAA;YAEJ,CAAA;UACF;QACF,EAAA;MACJ;IACF;EACF;AACF;;;AMnGA,IAAA,cAAeiC;",
6
+ "names": ["wasmUrl", "React", "createIntent", "createResolver", "createSurface", "FunctionType", "ScriptType", "create", "makeRef", "RefArray", "TextType", "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", "lazy", "React", "useClient", "Button", "useTranslation", "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", "React", "useCallback", "FunctionType", "getInvocationUrl", "getUserFunctionUrlInMetadata", "useClient", "Filter", "getMeta", "getSpace", "useQuery", "Button", "Icon", "Input", "useControlledValue", "useTranslation", "ScriptSettingsPanel", "script", "t", "useTranslation", "SCRIPT_PLUGIN", "client", "useClient", "space", "getSpace", "fn", "useQuery", "Filter", "schema", "FunctionType", "source", "handleNameChange", "useCallback", "event", "name", "target", "value", "binding", "setBinding", "useControlledValue", "handleBindingChange", "handleBindingBlur", "functionPath", "getUserFunctionUrlInMetadata", "getMeta", "functionUrl", "getInvocationUrl", "config", "values", "runtime", "services", "edge", "url", "spaceId", "id", "handleCopy", "navigator", "clipboard", "writeText", "React", "div", "role", "className", "Input", "Root", "Label", "TextInput", "placeholder", "onChange", "hr", "h2", "disabled", "Button", "onClick", "Icon", "icon", "size", "onBlur", "AutomationPanel", "lazy", "ScriptContainer", "SCRIPT_PLUGIN", "ScriptPlugin", "compiler", "Compiler", "meta", "initialize", "setFile", "initializeBundler", "wasmUrl", "provides", "settings", "metadata", "records", "ScriptType", "typename", "createObject", "props", "createIntent", "ScriptAction", "Create", "placeholder", "ns", "SCRIPT_PLUGIN", "icon", "loadReferences", "script", "RefArray", "loadAll", "source", "translations", "echo", "schema", "system", "FunctionType", "surface", "definitions", "createSurface", "id", "role", "filter", "data", "subject", "component", "React", "ScriptSettings", "ScriptContainer", "env", "environment", "disposition", "AutomationPanel", "ScriptSettingsPanel", "intent", "resolvers", "createResolver", "name", "object", "create", "makeRef", "TextType", "content", "templates", "ScriptPlugin"]
7
7
  }