@dxos/plugin-script 0.7.2-staging.6d26b2a → 0.7.3-main.2dd075e

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-BZCRRLOQ.mjs → AutomationPanel-PMTZROAZ.mjs} +18 -11
  2. package/dist/lib/browser/AutomationPanel-PMTZROAZ.mjs.map +7 -0
  3. package/dist/lib/browser/{ScriptContainer-GQ2KJ5BM.mjs → ScriptContainer-RYZFYCNK.mjs} +27 -25
  4. package/dist/lib/browser/ScriptContainer-RYZFYCNK.mjs.map +7 -0
  5. package/dist/lib/browser/{chunk-NCZUJKJE.mjs → chunk-K7KY6YMG.mjs} +14 -10
  6. package/dist/lib/browser/chunk-K7KY6YMG.mjs.map +7 -0
  7. package/dist/lib/browser/{chunk-DTVOXLPP.mjs → chunk-QFZUFT5G.mjs} +2 -2
  8. package/dist/lib/browser/{chunk-DTVOXLPP.mjs.map → chunk-QFZUFT5G.mjs.map} +3 -3
  9. package/dist/lib/browser/chunk-U3OP64V4.mjs +123 -0
  10. package/dist/lib/browser/chunk-U3OP64V4.mjs.map +7 -0
  11. package/dist/lib/browser/edge/index.mjs +5 -9
  12. package/dist/lib/browser/index.mjs +14 -18
  13. package/dist/lib/browser/index.mjs.map +3 -3
  14. package/dist/lib/browser/meta.json +1 -1
  15. package/dist/lib/browser/types/index.mjs +1 -1
  16. package/dist/lib/node/{AutomationPanel-VNLNP3EE.cjs → AutomationPanel-AAGQREH7.cjs} +21 -16
  17. package/dist/lib/node/AutomationPanel-AAGQREH7.cjs.map +7 -0
  18. package/dist/lib/node/{ScriptContainer-K67ZWCKL.cjs → ScriptContainer-FZ44UIRC.cjs} +32 -30
  19. package/dist/lib/node/ScriptContainer-FZ44UIRC.cjs.map +7 -0
  20. package/dist/lib/node/{chunk-BJ4WIWCP.cjs → chunk-4INUJLXL.cjs} +16 -12
  21. package/dist/lib/node/chunk-4INUJLXL.cjs.map +7 -0
  22. package/dist/lib/node/chunk-CS25QNKZ.cjs +151 -0
  23. package/dist/lib/node/chunk-CS25QNKZ.cjs.map +7 -0
  24. package/dist/lib/node/{chunk-T4PYTKIW.cjs → chunk-DQYAU2CJ.cjs} +5 -5
  25. package/dist/lib/node/{chunk-T4PYTKIW.cjs.map → chunk-DQYAU2CJ.cjs.map} +3 -3
  26. package/dist/lib/node/edge/index.cjs +10 -14
  27. package/dist/lib/node/edge/index.cjs.map +2 -2
  28. package/dist/lib/node/index.cjs +29 -33
  29. package/dist/lib/node/index.cjs.map +3 -3
  30. package/dist/lib/node/meta.json +1 -1
  31. package/dist/lib/node/types/index.cjs +4 -4
  32. package/dist/lib/node/types/index.cjs.map +1 -1
  33. package/dist/lib/node-esm/{AutomationPanel-NWE2QCOE.mjs → AutomationPanel-ETQEDY5I.mjs} +18 -11
  34. package/dist/lib/node-esm/AutomationPanel-ETQEDY5I.mjs.map +7 -0
  35. package/dist/lib/node-esm/{ScriptContainer-BVDYLJZI.mjs → ScriptContainer-3PKDW34A.mjs} +27 -25
  36. package/dist/lib/node-esm/ScriptContainer-3PKDW34A.mjs.map +7 -0
  37. package/dist/lib/node-esm/chunk-36DLLQ6E.mjs +125 -0
  38. package/dist/lib/node-esm/chunk-36DLLQ6E.mjs.map +7 -0
  39. package/dist/lib/node-esm/{chunk-2HYWFUEN.mjs → chunk-GMVPKT6A.mjs} +2 -2
  40. package/dist/lib/node-esm/{chunk-2HYWFUEN.mjs.map → chunk-GMVPKT6A.mjs.map} +3 -3
  41. package/dist/lib/node-esm/{chunk-DXWSRDEN.mjs → chunk-OFYGBUNI.mjs} +14 -10
  42. package/dist/lib/node-esm/chunk-OFYGBUNI.mjs.map +7 -0
  43. package/dist/lib/node-esm/edge/index.mjs +5 -9
  44. package/dist/lib/node-esm/index.mjs +14 -18
  45. package/dist/lib/node-esm/index.mjs.map +3 -3
  46. package/dist/lib/node-esm/meta.json +1 -1
  47. package/dist/lib/node-esm/types/index.mjs +1 -1
  48. package/dist/types/src/ScriptPlugin.d.ts.map +1 -1
  49. package/dist/types/src/components/AutomationPanel/AutomationPanel.d.ts.map +1 -1
  50. package/dist/types/src/components/DebugPanel/DebugPanel.d.ts.map +1 -1
  51. package/dist/types/src/components/ScriptBlock/ScriptBlock.d.ts +1 -5
  52. package/dist/types/src/components/ScriptBlock/ScriptBlock.d.ts.map +1 -1
  53. package/dist/types/src/components/ScriptBlock/ScriptBlock.stories.d.ts.map +1 -1
  54. package/dist/types/src/components/ScriptEditor.d.ts.map +1 -1
  55. package/dist/types/src/components/ScriptSettingsPanel.d.ts.map +1 -1
  56. package/dist/types/src/edge/functions.d.ts +13 -21
  57. package/dist/types/src/edge/functions.d.ts.map +1 -1
  58. package/dist/types/src/edge/index.d.ts +0 -3
  59. package/dist/types/src/edge/index.d.ts.map +1 -1
  60. package/dist/types/src/translations.d.ts +43 -0
  61. package/dist/types/src/translations.d.ts.map +1 -1
  62. package/dist/types/src/types/schema.d.ts +2 -2
  63. package/dist/types/src/types/types.d.ts +2 -3
  64. package/dist/types/src/types/types.d.ts.map +1 -1
  65. package/package.json +37 -36
  66. package/src/ScriptPlugin.tsx +3 -8
  67. package/src/components/AutomationPanel/AutomationPanel.tsx +10 -5
  68. package/src/components/DebugPanel/DebugPanel.tsx +41 -30
  69. package/src/components/ScriptBlock/ScriptBlock.stories.tsx +5 -25
  70. package/src/components/ScriptBlock/ScriptBlock.tsx +3 -8
  71. package/src/components/ScriptEditor.tsx +16 -23
  72. package/src/components/ScriptSettingsPanel.tsx +1 -5
  73. package/src/edge/functions.ts +69 -109
  74. package/src/edge/index.ts +0 -3
  75. package/src/translations.ts +4 -0
  76. package/src/types/schema.ts +1 -1
  77. package/src/types/types.ts +1 -3
  78. package/dist/lib/browser/AutomationPanel-BZCRRLOQ.mjs.map +0 -7
  79. package/dist/lib/browser/ScriptContainer-GQ2KJ5BM.mjs.map +0 -7
  80. package/dist/lib/browser/chunk-5GGRYRS4.mjs +0 -253
  81. package/dist/lib/browser/chunk-5GGRYRS4.mjs.map +0 -7
  82. package/dist/lib/browser/chunk-NCZUJKJE.mjs.map +0 -7
  83. package/dist/lib/node/AutomationPanel-VNLNP3EE.cjs.map +0 -7
  84. package/dist/lib/node/ScriptContainer-K67ZWCKL.cjs.map +0 -7
  85. package/dist/lib/node/chunk-BJ4WIWCP.cjs.map +0 -7
  86. package/dist/lib/node/chunk-XS6GEYYH.cjs +0 -273
  87. package/dist/lib/node/chunk-XS6GEYYH.cjs.map +0 -7
  88. package/dist/lib/node-esm/AutomationPanel-NWE2QCOE.mjs.map +0 -7
  89. package/dist/lib/node-esm/ScriptContainer-BVDYLJZI.mjs.map +0 -7
  90. package/dist/lib/node-esm/chunk-DXWSRDEN.mjs.map +0 -7
  91. package/dist/lib/node-esm/chunk-V74XKPLC.mjs +0 -255
  92. package/dist/lib/node-esm/chunk-V74XKPLC.mjs.map +0 -7
  93. package/dist/types/src/edge/codec.d.ts +0 -4
  94. package/dist/types/src/edge/codec.d.ts.map +0 -1
  95. package/dist/types/src/edge/header-codec.d.ts +0 -24
  96. package/dist/types/src/edge/header-codec.d.ts.map +0 -1
  97. package/dist/types/src/edge/hub-protocol.d.ts +0 -6
  98. package/dist/types/src/edge/hub-protocol.d.ts.map +0 -1
  99. package/src/edge/codec.ts +0 -13
  100. package/src/edge/header-codec.ts +0 -97
  101. package/src/edge/hub-protocol.ts +0 -27
@@ -1,5 +1,48 @@
1
1
  declare const _default: {
2
2
  'en-US': {
3
+ [x: string]: {
4
+ 'typename label': string;
5
+ 'plugin name'?: undefined;
6
+ 'object title placeholder'?: undefined;
7
+ 'create object label'?: undefined;
8
+ 'create stack section label'?: undefined;
9
+ 'binding placeholder'?: undefined;
10
+ 'function request placeholder'?: undefined;
11
+ 'deploy label'?: undefined;
12
+ 'deployed label'?: undefined;
13
+ 'upload failed label'?: undefined;
14
+ 'copy link label'?: undefined;
15
+ 'format label'?: undefined;
16
+ 'toggle details label'?: undefined;
17
+ 'authenticate action label'?: undefined;
18
+ 'authenticate button label'?: undefined;
19
+ 'name label'?: undefined;
20
+ 'remote function settings heading'?: undefined;
21
+ 'function url label'?: undefined;
22
+ 'function binding label'?: undefined;
23
+ 'function binding placeholder'?: undefined;
24
+ } | {
25
+ 'plugin name': string;
26
+ 'object title placeholder': string;
27
+ 'create object label': string;
28
+ 'create stack section label': string;
29
+ 'binding placeholder': string;
30
+ 'function request placeholder': string;
31
+ 'deploy label': string;
32
+ 'deployed label': string;
33
+ 'upload failed label': string;
34
+ 'copy link label': string;
35
+ 'format label': string;
36
+ 'toggle details label': string;
37
+ 'authenticate action label': string;
38
+ 'authenticate button label': string;
39
+ 'name label': string;
40
+ 'remote function settings heading': string;
41
+ 'function url label': string;
42
+ 'function binding label': string;
43
+ 'function binding placeholder': string;
44
+ 'typename label'?: undefined;
45
+ };
3
46
  "dxos.org/plugin/script": {
4
47
  'plugin name': string;
5
48
  'object title placeholder': string;
@@ -1 +1 @@
1
- {"version":3,"file":"translations.d.ts","sourceRoot":"","sources":["../../../src/translations.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAMA,wBA0BE"}
1
+ {"version":3,"file":"translations.d.ts","sourceRoot":"","sources":["../../../src/translations.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,wBA6BE"}
@@ -39,14 +39,14 @@ declare const FunctionType_base: import("@dxos/echo-schema").AbstractTypedObject
39
39
  } & {
40
40
  id: string;
41
41
  }>;
42
- version: number;
42
+ version: string;
43
43
  inputSchema?: JsonSchemaType | undefined;
44
44
  binding?: string | undefined;
45
45
  } & {
46
46
  id: string;
47
47
  }, S.Struct.Encoded<{
48
48
  name: typeof S.NonEmptyString;
49
- version: typeof S.Number;
49
+ version: typeof S.String;
50
50
  source: S.optional<ref<{
51
51
  name?: string | undefined;
52
52
  description?: string | undefined;
@@ -1,9 +1,8 @@
1
1
  import type { GraphBuilderProvides, IntentResolverProvides, MetadataRecordsProvides, SettingsProvides, SurfaceProvides, TranslationsProvides } from '@dxos/app-framework';
2
- import { type SchemaProvides } from '@dxos/plugin-client';
3
- import { type SpaceInitProvides } from '@dxos/plugin-space';
2
+ import { type SchemaProvides } from '@dxos/plugin-space';
4
3
  export declare enum ScriptAction {
5
4
  CREATE = "dxos.org/plugin/script/create"
6
5
  }
7
6
  export type ScriptSettingsProps = {};
8
- export type ScriptPluginProvides = GraphBuilderProvides & IntentResolverProvides & MetadataRecordsProvides & SchemaProvides & SettingsProvides<ScriptSettingsProps> & SpaceInitProvides & SurfaceProvides & TranslationsProvides;
7
+ export type ScriptPluginProvides = GraphBuilderProvides & IntentResolverProvides & MetadataRecordsProvides & SchemaProvides & SettingsProvides<ScriptSettingsProps> & SurfaceProvides & TranslationsProvides;
9
8
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/types/types.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,oBAAoB,EACpB,sBAAsB,EACtB,uBAAuB,EACvB,gBAAgB,EAChB,eAAe,EACf,oBAAoB,EACrB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAI5D,oBAAY,YAAY;IACtB,MAAM,kCAA4B;CACnC;AAED,MAAM,MAAM,mBAAmB,GAAG,EAAE,CAAC;AAErC,MAAM,MAAM,oBAAoB,GAAG,oBAAoB,GACrD,sBAAsB,GACtB,uBAAuB,GACvB,cAAc,GACd,gBAAgB,CAAC,mBAAmB,CAAC,GACrC,iBAAiB,GACjB,eAAe,GACf,oBAAoB,CAAC"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/types/types.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,oBAAoB,EACpB,sBAAsB,EACtB,uBAAuB,EACvB,gBAAgB,EAChB,eAAe,EACf,oBAAoB,EACrB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAIzD,oBAAY,YAAY;IACtB,MAAM,kCAA4B;CACnC;AAED,MAAM,MAAM,mBAAmB,GAAG,EAAE,CAAC;AAErC,MAAM,MAAM,oBAAoB,GAAG,oBAAoB,GACrD,sBAAsB,GACtB,uBAAuB,GACvB,cAAc,GACd,gBAAgB,CAAC,mBAAmB,CAAC,GACrC,eAAe,GACf,oBAAoB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/plugin-script",
3
- "version": "0.7.2-staging.6d26b2a",
3
+ "version": "0.7.3-main.2dd075e",
4
4
  "description": "Braneframe notebook plugin",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
@@ -67,32 +67,34 @@
67
67
  "prettier": "^3.2.4",
68
68
  "react-syntax-highlighter": "^15.5.0",
69
69
  "typescript": "^5.6.2",
70
- "@dxos/app-framework": "0.7.2-staging.6d26b2a",
71
- "@dxos/client-protocol": "0.7.2-staging.6d26b2a",
72
- "@dxos/async": "0.7.2-staging.6d26b2a",
73
- "@dxos/debug": "0.7.2-staging.6d26b2a",
74
- "@dxos/client": "0.7.2-staging.6d26b2a",
75
- "@dxos/invariant": "0.7.2-staging.6d26b2a",
76
- "@dxos/echo-schema": "0.7.2-staging.6d26b2a",
77
- "@dxos/crypto": "0.7.2-staging.6d26b2a",
78
- "@dxos/keys": "0.7.2-staging.6d26b2a",
79
- "@dxos/log": "0.7.2-staging.6d26b2a",
80
- "@dxos/plugin-explorer": "0.7.2-staging.6d26b2a",
81
- "@dxos/plugin-client": "0.7.2-staging.6d26b2a",
82
- "@dxos/plugin-markdown": "0.7.2-staging.6d26b2a",
83
- "@dxos/plugin-space": "0.7.2-staging.6d26b2a",
84
- "@dxos/plugin-graph": "0.7.2-staging.6d26b2a",
85
- "@dxos/plugin-stack": "0.7.2-staging.6d26b2a",
86
- "@dxos/plugin-theme": "0.7.2-staging.6d26b2a",
87
- "@dxos/protocols": "0.7.2-staging.6d26b2a",
88
- "@dxos/react-client": "0.7.2-staging.6d26b2a",
89
- "@dxos/react-ui-attention": "0.7.2-staging.6d26b2a",
90
- "@dxos/react-ui-form": "0.7.2-staging.6d26b2a",
91
- "@dxos/react-ui-editor": "0.7.2-staging.6d26b2a",
92
- "@dxos/react-ui-syntax-highlighter": "0.7.2-staging.6d26b2a",
93
- "@dxos/rpc": "0.7.2-staging.6d26b2a",
94
- "@dxos/rpc-tunnel": "0.7.2-staging.6d26b2a",
95
- "@dxos/util": "0.7.2-staging.6d26b2a"
70
+ "@dxos/app-framework": "0.7.3-main.2dd075e",
71
+ "@dxos/async": "0.7.3-main.2dd075e",
72
+ "@dxos/client-protocol": "0.7.3-main.2dd075e",
73
+ "@dxos/crypto": "0.7.3-main.2dd075e",
74
+ "@dxos/client": "0.7.3-main.2dd075e",
75
+ "@dxos/debug": "0.7.3-main.2dd075e",
76
+ "@dxos/edge-client": "0.7.3-main.2dd075e",
77
+ "@dxos/echo-schema": "0.7.3-main.2dd075e",
78
+ "@dxos/invariant": "0.7.3-main.2dd075e",
79
+ "@dxos/keys": "0.7.3-main.2dd075e",
80
+ "@dxos/live-object": "0.7.3-main.2dd075e",
81
+ "@dxos/log": "0.7.3-main.2dd075e",
82
+ "@dxos/plugin-explorer": "0.7.3-main.2dd075e",
83
+ "@dxos/plugin-client": "0.7.3-main.2dd075e",
84
+ "@dxos/plugin-markdown": "0.7.3-main.2dd075e",
85
+ "@dxos/plugin-stack": "0.7.3-main.2dd075e",
86
+ "@dxos/plugin-graph": "0.7.3-main.2dd075e",
87
+ "@dxos/plugin-space": "0.7.3-main.2dd075e",
88
+ "@dxos/plugin-theme": "0.7.3-main.2dd075e",
89
+ "@dxos/protocols": "0.7.3-main.2dd075e",
90
+ "@dxos/react-client": "0.7.3-main.2dd075e",
91
+ "@dxos/react-ui-attention": "0.7.3-main.2dd075e",
92
+ "@dxos/react-ui-editor": "0.7.3-main.2dd075e",
93
+ "@dxos/react-ui-form": "0.7.3-main.2dd075e",
94
+ "@dxos/react-ui-syntax-highlighter": "0.7.3-main.2dd075e",
95
+ "@dxos/rpc": "0.7.3-main.2dd075e",
96
+ "@dxos/rpc-tunnel": "0.7.3-main.2dd075e",
97
+ "@dxos/util": "0.7.3-main.2dd075e"
96
98
  },
97
99
  "devDependencies": {
98
100
  "@phosphor-icons/react": "^2.1.5",
@@ -102,20 +104,19 @@
102
104
  "react": "~18.2.0",
103
105
  "react-dom": "~18.2.0",
104
106
  "vite": "5.4.7",
105
- "@dxos/echo-generator": "0.7.2-staging.6d26b2a",
106
- "@dxos/random": "0.7.2-staging.6d26b2a",
107
- "@dxos/react-ui": "0.7.2-staging.6d26b2a",
108
- "@dxos/react-ui-mosaic": "0.7.2-staging.6d26b2a",
109
- "@dxos/react-ui-theme": "0.7.2-staging.6d26b2a",
110
- "@dxos/storybook-utils": "0.7.2-staging.6d26b2a"
107
+ "@dxos/random": "0.7.3-main.2dd075e",
108
+ "@dxos/react-ui": "0.7.3-main.2dd075e",
109
+ "@dxos/react-ui-theme": "0.7.3-main.2dd075e",
110
+ "@dxos/react-ui-mosaic": "0.7.3-main.2dd075e",
111
+ "@dxos/storybook-utils": "0.7.3-main.2dd075e"
111
112
  },
112
113
  "peerDependencies": {
113
114
  "@phosphor-icons/react": "^2.1.5",
114
115
  "react": "~18.2.0",
115
116
  "react-dom": "~18.2.0",
116
- "@dxos/react-ui-mosaic": "0.7.2-staging.6d26b2a",
117
- "@dxos/react-ui": "0.7.2-staging.6d26b2a",
118
- "@dxos/react-ui-theme": "0.7.2-staging.6d26b2a"
117
+ "@dxos/react-ui": "0.7.3-main.2dd075e",
118
+ "@dxos/react-ui-mosaic": "0.7.3-main.2dd075e",
119
+ "@dxos/react-ui-theme": "0.7.3-main.2dd075e"
119
120
  },
120
121
  "publishConfig": {
121
122
  "access": "public"
@@ -7,7 +7,7 @@ import wasmUrl from 'esbuild-wasm/esbuild.wasm?url';
7
7
  import React from 'react';
8
8
 
9
9
  import { NavigationAction, parseIntentPlugin, type PluginDefinition, resolvePlugin } from '@dxos/app-framework';
10
- import { create } from '@dxos/echo-schema';
10
+ import { create } from '@dxos/live-object';
11
11
  import { parseClientPlugin } from '@dxos/plugin-client';
12
12
  import { type ActionGroup, createExtension, isActionGroup } from '@dxos/plugin-graph';
13
13
  import { TextType } from '@dxos/plugin-markdown/types';
@@ -57,13 +57,8 @@ export const ScriptPlugin = (): PluginDefinition<ScriptPluginProvides> => {
57
57
  },
58
58
  translations,
59
59
  echo: {
60
- schema: [ScriptType, FunctionType],
61
- },
62
- space: {
63
- onSpaceCreate: {
64
- label: ['create object label', { ns: SCRIPT_PLUGIN }],
65
- action: ScriptAction.CREATE,
66
- },
60
+ schema: [ScriptType],
61
+ system: [FunctionType],
67
62
  },
68
63
  graph: {
69
64
  builder: (plugins) => {
@@ -8,9 +8,10 @@ import { type ReactiveEchoObject } from '@dxos/client/echo';
8
8
  import { failUndefined } from '@dxos/debug';
9
9
  import { useClient } from '@dxos/react-client';
10
10
  import { Filter, getMeta, getSpace, useQuery } from '@dxos/react-client/echo';
11
- import { Select } from '@dxos/react-ui';
11
+ import { Select, useTranslation } from '@dxos/react-ui';
12
12
 
13
13
  import { getInvocationUrl, getUserFunctionUrlInMetadata } from '../../edge';
14
+ import { SCRIPT_PLUGIN } from '../../meta';
14
15
  import { FunctionType, ScriptType } from '../../types';
15
16
  import { DebugPanel } from '../DebugPanel';
16
17
 
@@ -19,17 +20,21 @@ export interface AutomationPanelProps {
19
20
  }
20
21
 
21
22
  export const AutomationPanel = ({ subject }: AutomationPanelProps) => {
23
+ const { t } = useTranslation(SCRIPT_PLUGIN);
22
24
  const space = getSpace(subject);
23
25
 
24
26
  // TODO(dmaretskyi): Parametric query.
25
27
  const functions = useQuery(
26
28
  space ?? undefined,
27
- Filter.schema(FunctionType, (fn) => (subject instanceof ScriptType ? fn.source === subject : fn.binding != null)),
29
+ subject instanceof ScriptType
30
+ ? Filter.schema(FunctionType, { source: subject })
31
+ : Filter.schema(FunctionType, (fn) => fn.binding != null),
28
32
  {},
29
33
  [subject],
30
34
  );
35
+
31
36
  const [selectedFunction, setSelectedFunction] = useState<FunctionType | null>(null);
32
- const functionToChatWith = subject instanceof ScriptType ? functions[0] : selectedFunction;
37
+ const chatFunction = subject instanceof ScriptType ? functions[0] : selectedFunction;
33
38
 
34
39
  return (
35
40
  <div className='h-full flex flex-col'>
@@ -40,8 +45,8 @@ export const AutomationPanel = ({ subject }: AutomationPanelProps) => {
40
45
  functions={functions}
41
46
  />
42
47
  )}
43
- {functionToChatWith && <ChatPanel fn={functionToChatWith} subject={subject} />}
44
- {subject instanceof ScriptType && functions.length === 0 && <p>Deploy function to interact with it.</p>}
48
+ {chatFunction && <ChatPanel fn={chatFunction} subject={subject} />}
49
+ {subject instanceof ScriptType && functions.length === 0 && <div className='p-1'>{t('not deployed')}</div>}
45
50
  </div>
46
51
  );
47
52
  };
@@ -2,7 +2,7 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import React, { useEffect, useRef, useState } from 'react';
5
+ import React, { forwardRef, useEffect, useRef, useState } from 'react';
6
6
 
7
7
  import { log } from '@dxos/log';
8
8
  import { Avatar, Icon, Input, type ThemedClassName, Toolbar, useTranslation } from '@dxos/react-ui';
@@ -159,12 +159,10 @@ export const DebugPanel = ({ classNames, functionUrl }: DebugPanelProps) => {
159
159
 
160
160
  return (
161
161
  <div className={mx('flex flex-col h-full overflow-hidden', classNames)}>
162
- {/* TODO(burdon): Replace with Thread? */}
163
- <div ref={scrollerRef} className='flex flex-col gap-6 h-full p-2 overflow-x-hidden overflow-y-auto'>
164
- <MessageThread state={state} result={result} history={history} />
165
- </div>
162
+ {/* TODO(burdon): Replace with Thread. */}
163
+ <MessageThread ref={scrollerRef} state={state} result={result} history={history} />
166
164
 
167
- <Toolbar.Root classNames='p-2'>
165
+ <Toolbar.Root classNames='p-1'>
168
166
  <Input.Root>
169
167
  <Input.TextInput
170
168
  ref={inputRef}
@@ -189,32 +187,45 @@ export const DebugPanel = ({ classNames, functionUrl }: DebugPanelProps) => {
189
187
  // TODO(burdon): Replace with thread?
190
188
  // TODO(burdon): Button to delete individual messages.
191
189
  // TODO(burdon): Button to edit/re-run question.
192
- const MessageThread = ({ state, result, history }: { state: State | null; result: string; history: Message[] }) => {
193
- return (
194
- <>
195
- {history.map((message, i) => (
196
- <div key={i} className='grid grid-cols-[2rem_1fr_2rem]'>
197
- <div className='p-1'>{message.type === 'response' && <RobotAvatar />}</div>
198
- <div className='overflow-auto'>
199
- <MessageItem message={message} />
200
- </div>
201
- </div>
202
- ))}
203
- {result?.length > 0 && (
204
- <div className='grid grid-cols-[2rem_1fr_2rem]'>
205
- <div className='p-1'>
206
- {(state === 'pending' && <Icon icon='ph--spinner--regular' size={6} classNames='animate-spin' />) || (
207
- <Icon icon='ph--robot--regular' size={6} classNames='animate-[pulse_1s_ease-in-out_infinite]' />
208
- )}
190
+ type MessageThreadProps = {
191
+ state: State | null;
192
+ history: Message[];
193
+ result: string;
194
+ };
195
+
196
+ const MessageThread = forwardRef<HTMLDivElement, MessageThreadProps>(
197
+ ({ state, history, result }: MessageThreadProps, forwardedRef) => {
198
+ if (!history.length && !result.length) {
199
+ return null;
200
+ }
201
+
202
+ return (
203
+ <div ref={forwardedRef} className='flex flex-col gap-6 h-full p-2 overflow-x-hidden overflow-y-auto'>
204
+ {history.map((message, i) => (
205
+ <div key={i} className='grid grid-cols-[2rem_1fr_2rem]'>
206
+ <div className='p-1'>{message.type === 'response' && <RobotAvatar />}</div>
207
+ <div className='overflow-auto'>
208
+ <MessageItem message={message} />
209
+ </div>
209
210
  </div>
210
- <div className='overflow-auto'>
211
- <MessageItem message={{ type: 'response', text: result }} />
211
+ ))}
212
+
213
+ {result?.length > 0 && (
214
+ <div className='grid grid-cols-[2rem_1fr_2rem]'>
215
+ <div className='p-1'>
216
+ {(state === 'pending' && <Icon icon='ph--spinner--regular' size={6} classNames='animate-spin' />) || (
217
+ <Icon icon='ph--robot--regular' size={6} classNames='animate-[pulse_1s_ease-in-out_infinite]' />
218
+ )}
219
+ </div>
220
+ <div className='overflow-auto'>
221
+ <MessageItem message={{ type: 'response', text: result }} />
222
+ </div>
212
223
  </div>
213
- </div>
214
- )}
215
- </>
216
- );
217
- };
224
+ )}
225
+ </div>
226
+ );
227
+ },
228
+ );
218
229
 
219
230
  const MessageItem = ({ classNames, message }: ThemedClassName<{ message: Message }>) => {
220
231
  const { type, text, data, error } = message;
@@ -5,12 +5,10 @@
5
5
  import '@dxos-theme';
6
6
 
7
7
  import { type Meta } from '@storybook/react';
8
- import React, { useEffect, useMemo } from 'react';
8
+ import React, { useMemo } from 'react';
9
9
 
10
- import { createSpaceObjectGenerator, TestSchemaType } from '@dxos/echo-generator';
11
10
  import { TextType } from '@dxos/plugin-markdown/types';
12
- import { useClient } from '@dxos/react-client';
13
- import { create, createObject, useSpaces } from '@dxos/react-client/echo';
11
+ import { create, createObject } from '@dxos/react-client/echo';
14
12
  import { withClientProvider } from '@dxos/react-client/testing';
15
13
  import { withLayout, withTheme } from '@dxos/storybook-utils';
16
14
 
@@ -19,6 +17,8 @@ import { ScriptType } from '../../types';
19
17
  // @ts-ignore
20
18
  import mainUrl from '../FrameContainer/frame?url';
21
19
 
20
+ const typename = 'example.com/type/contact';
21
+
22
22
  const code = [
23
23
  "import { Filter, useQuery, useSpaces} from '@dxos/react-client/echo';",
24
24
  "import { Chart, Explorer, Globe } from '@dxos/plugin-explorer';",
@@ -26,32 +26,12 @@ const code = [
26
26
  'export default () => {',
27
27
  ' const spaces = useSpaces();',
28
28
  ' const space = spaces[1]',
29
- " const objects = useQuery(space, Filter.typename('example.com/type/contact'));",
29
+ ` const objects = useQuery(space, Filter.typename('${typename}'));`,
30
30
  ' return <Chart items={objects} accessor={object => ({ x: object.lat, y: object.lng })} />',
31
31
  '}',
32
32
  ].join('\n');
33
33
 
34
34
  const DefaultStory = () => {
35
- const client = useClient();
36
- const spaces = useSpaces();
37
- console.log(spaces.length);
38
-
39
- useEffect(() => {
40
- try {
41
- // TODO(burdon): Default not set.
42
- const generator = createSpaceObjectGenerator(client.spaces.default);
43
- generator.addSchemas();
44
- void generator
45
- .createObjects({
46
- [TestSchemaType.organization]: 20,
47
- [TestSchemaType.contact]: 50,
48
- })
49
- .catch(() => {});
50
- } catch (err) {
51
- console.log(err);
52
- }
53
- }, [client]);
54
-
55
35
  // TODO(burdon): Review what's the right way to create automerge-backed objects.
56
36
  const object = useMemo(() => createObject(create(ScriptType, { source: create(TextType, { content: code }) })), []);
57
37
 
@@ -8,7 +8,6 @@ import React, { useCallback, useEffect, useMemo, useState } from 'react';
8
8
 
9
9
  import { createDocAccessor, DocAccessor } from '@dxos/react-client/echo';
10
10
  import { Toolbar, Button, Icon } from '@dxos/react-ui';
11
- import { mx } from '@dxos/react-ui-theme';
12
11
 
13
12
  import { Bundler, type BundlerResult, initializeBundler } from '../../bundler';
14
13
  import { type ScriptType } from '../../types';
@@ -28,10 +27,6 @@ const PROVIDED_MODULES = [
28
27
  export type ScriptBlockProps = {
29
28
  script: ScriptType;
30
29
  hideSelector?: boolean;
31
- classes?: {
32
- root?: string;
33
- toolbar?: string;
34
- };
35
30
 
36
31
  // Url to the page used to host the script in the iframe.
37
32
  containerUrl: string;
@@ -41,7 +36,7 @@ export type ScriptBlockProps = {
41
36
  * @deprecated
42
37
  */
43
38
  // TODO(burdon): Cache compiled results in context.
44
- export const ScriptBlock = ({ script, hideSelector, classes, containerUrl }: ScriptBlockProps) => {
39
+ export const ScriptBlock = ({ script, hideSelector, containerUrl }: ScriptBlockProps) => {
45
40
  const source = useMemo(() => script.source && createDocAccessor(script.source, ['content']), [script.source]);
46
41
  const [result, setResult] = useState<BundlerResult>();
47
42
  const bundler = useMemo(
@@ -78,9 +73,9 @@ export const ScriptBlock = ({ script, hideSelector, classes, containerUrl }: Scr
78
73
  );
79
74
 
80
75
  return (
81
- <div className={mx('flex flex-col grow overflow-hidden', classes?.root)}>
76
+ <div className='flex flex-col grow overflow-hidden'>
82
77
  {!hideSelector && (
83
- <Toolbar.Root classNames={mx('mb-2', classes?.toolbar)}>
78
+ <Toolbar.Root>
84
79
  <div className='grow' />
85
80
  {result?.bundle && !result?.error && (
86
81
  <div title={String(result.error)}>
@@ -2,7 +2,6 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import { type DID } from 'iso-did/types';
6
5
  import { format } from 'prettier';
7
6
  import prettierPluginEstree from 'prettier/plugins/estree';
8
7
  import prettierPluginTypescript from 'prettier/plugins/typescript';
@@ -23,10 +22,10 @@ import { Bundler } from '../bundler';
23
22
  import {
24
23
  getInvocationUrl,
25
24
  getUserFunctionUrlInMetadata,
26
- publicKeyToDid,
27
25
  setUserFunctionUrlInMetadata,
28
26
  uploadWorkerFunction,
29
- USERFUNCTIONS_PRESET_META_KEY,
27
+ FUNCTIONS_PRESET_META_KEY,
28
+ incrementSemverPatch,
30
29
  } from '../edge';
31
30
  import { SCRIPT_PLUGIN } from '../meta';
32
31
  import { templates } from '../templates';
@@ -42,11 +41,7 @@ export const ScriptEditor = ({ classNames, script, env }: ScriptEditorProps) =>
42
41
  const client = useClient();
43
42
  const identity = useIdentity();
44
43
  const space = getSpace(script);
45
- // TODO(dmaretskyi): Parametric query.
46
- const [fn] = useQuery(
47
- space,
48
- Filter.schema(FunctionType, (fn) => fn.source === script),
49
- );
44
+ const [fn] = useQuery(space, Filter.schema(FunctionType, { source: script }));
50
45
 
51
46
  const extensions = useMemo(
52
47
  () => [
@@ -95,12 +90,12 @@ export const ScriptEditor = ({ classNames, script, env }: ScriptEditorProps) =>
95
90
  script.name = template.name;
96
91
  script.source!.content = template.source;
97
92
  const metaKeys = getMeta(script).keys;
98
- const oldPresetIndex = metaKeys.findIndex((key) => key.source === USERFUNCTIONS_PRESET_META_KEY);
93
+ const oldPresetIndex = metaKeys.findIndex((key) => key.source === FUNCTIONS_PRESET_META_KEY);
99
94
  if (oldPresetIndex >= 0) {
100
95
  metaKeys.splice(oldPresetIndex, 1);
101
96
  }
102
97
  if (template.presetId) {
103
- metaKeys.push({ source: USERFUNCTIONS_PRESET_META_KEY, id: template.presetId });
98
+ metaKeys.push({ source: FUNCTIONS_PRESET_META_KEY, id: template.presetId });
104
99
  }
105
100
  }
106
101
  };
@@ -114,7 +109,6 @@ export const ScriptEditor = ({ classNames, script, env }: ScriptEditorProps) =>
114
109
 
115
110
  try {
116
111
  const existingFunctionId = existingFunctionUrl?.split('/').at(-1);
117
- const ownerDid = (existingFunctionUrl?.split('/').at(-2) as DID) ?? publicKeyToDid(identity.identityKey);
118
112
 
119
113
  const bundler = new Bundler({ platform: 'browser', sandboxedModules: [], remoteModules: {} });
120
114
  const buildResult = await bundler.bundle(script.source.content);
@@ -122,24 +116,23 @@ export const ScriptEditor = ({ classNames, script, env }: ScriptEditorProps) =>
122
116
  throw buildResult.error;
123
117
  }
124
118
 
125
- const { result, functionId, functionVersionNumber, errorMessage, meta } = await uploadWorkerFunction({
126
- clientConfig: client.config,
127
- halo: client.halo,
128
- ownerDid,
119
+ const { functionId, version, meta } = await uploadWorkerFunction({
120
+ client,
121
+ spaceId: space.id,
122
+ version: fn ? incrementSemverPatch(fn.version) : '0.0.1',
129
123
  functionId: existingFunctionId,
130
124
  source: buildResult.bundle,
131
125
  });
132
- if (result !== 'success' || functionId === undefined || functionVersionNumber === undefined) {
133
- throw new Error(errorMessage);
126
+ if (functionId === undefined || version === undefined) {
127
+ throw new Error(`Upload didn't return expected data: functionId=${functionId}, version=${version}`);
134
128
  }
135
129
 
136
- log.info('function uploaded', { functionId, functionVersionNumber });
130
+ log.info('function uploaded', { functionId, version });
137
131
  if (fn) {
138
- fn.version = functionVersionNumber;
132
+ fn.version = version;
139
133
  }
140
134
 
141
- const deployedFunction =
142
- fn ?? space.db.add(create(FunctionType, { name: functionId, version: functionVersionNumber, source: script }));
135
+ const deployedFunction = fn ?? space.db.add(create(FunctionType, { name: functionId, version, source: script }));
143
136
 
144
137
  script.changed = false;
145
138
 
@@ -149,14 +142,14 @@ export const ScriptEditor = ({ classNames, script, env }: ScriptEditorProps) =>
149
142
  log.verbose('no input schema in function metadata', { functionId });
150
143
  }
151
144
 
152
- setUserFunctionUrlInMetadata(getMeta(deployedFunction), `/${ownerDid}/${functionId}`);
145
+ setUserFunctionUrlInMetadata(getMeta(deployedFunction), `/${space.id}/${functionId}`);
153
146
 
154
147
  setView('split');
155
148
  } catch (err: any) {
156
149
  log.catch(err);
157
150
  setError(t('upload failed label'));
158
151
  }
159
- }, [fn, existingFunctionUrl, script, script.name, script.source]);
152
+ }, [fn, existingFunctionUrl, script, script.name, script.source, space?.id ?? null]);
160
153
 
161
154
  const functionUrl = useMemo(() => {
162
155
  if (!existingFunctionUrl) {
@@ -20,11 +20,7 @@ export const ScriptSettingsPanel = ({ script }: ScriptSettingsPanelProps) => {
20
20
  const { t } = useTranslation(SCRIPT_PLUGIN);
21
21
  const client = useClient();
22
22
  const space = getSpace(script);
23
- // TODO(dmaretskyi): Parametric query.
24
- const [fn] = useQuery(
25
- space,
26
- Filter.schema(FunctionType, (fn) => fn.source === script),
27
- );
23
+ const [fn] = useQuery(space, Filter.schema(FunctionType, { source: script }));
28
24
 
29
25
  const handleNameChange = useCallback(
30
26
  (event: ChangeEvent<HTMLInputElement>) => {