@dxos/app-framework 0.8.4-main.5ad4a44 → 0.8.4-main.66e292d
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/{app-graph-builder-77MY7KAY.mjs → app-graph-builder-OIEZZC45.mjs} +7 -7
- package/dist/lib/browser/app-graph-builder-OIEZZC45.mjs.map +7 -0
- package/dist/lib/browser/{chunk-4NFLRSTX.mjs → chunk-6XKO24JP.mjs} +108 -92
- package/dist/lib/browser/chunk-6XKO24JP.mjs.map +7 -0
- package/dist/lib/browser/{chunk-OKF2PAWO.mjs → chunk-WPW5VVAX.mjs} +208 -203
- package/dist/lib/browser/chunk-WPW5VVAX.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +5 -33
- package/dist/lib/browser/index.mjs.map +2 -2
- package/dist/lib/browser/{intent-dispatcher-Y4LZNOBC.mjs → intent-dispatcher-LZ4AE66E.mjs} +2 -2
- package/dist/lib/browser/{intent-resolver-XO5OYWVD.mjs → intent-resolver-QVCKRX6G.mjs} +2 -2
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/react/index.mjs +34 -0
- package/dist/lib/browser/{store-E3YSBPJQ.mjs → store-CNPHOYTJ.mjs} +3 -3
- package/dist/lib/browser/store-CNPHOYTJ.mjs.map +7 -0
- package/dist/lib/browser/testing/index.mjs +5 -4
- package/dist/lib/browser/testing/index.mjs.map +3 -3
- package/dist/lib/node-esm/{app-graph-builder-WK7WBM6I.mjs → app-graph-builder-EBU4NVWD.mjs} +7 -7
- package/dist/lib/node-esm/app-graph-builder-EBU4NVWD.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-AHCD4UYO.mjs → chunk-3UPX5OIS.mjs} +108 -92
- package/dist/lib/node-esm/chunk-3UPX5OIS.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-7DNZQ6H2.mjs → chunk-XJZGUJ3H.mjs} +208 -203
- package/dist/lib/node-esm/chunk-XJZGUJ3H.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +5 -33
- package/dist/lib/node-esm/index.mjs.map +2 -2
- package/dist/lib/node-esm/{intent-dispatcher-R4CCPBHO.mjs → intent-dispatcher-MGOJ3CHD.mjs} +2 -2
- package/dist/lib/node-esm/{intent-resolver-NVYY6BQA.mjs → intent-resolver-URF3HN3G.mjs} +2 -2
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/react/index.mjs +35 -0
- package/dist/lib/node-esm/{store-QA5DGTOS.mjs → store-RK5B4XEL.mjs} +3 -3
- package/dist/lib/node-esm/store-RK5B4XEL.mjs.map +7 -0
- package/dist/lib/node-esm/testing/index.mjs +5 -4
- package/dist/lib/node-esm/testing/index.mjs.map +3 -3
- package/dist/types/src/common/capabilities.d.ts +36 -42
- package/dist/types/src/common/capabilities.d.ts.map +1 -1
- package/dist/types/src/common/surface.d.ts +16 -7
- package/dist/types/src/common/surface.d.ts.map +1 -1
- package/dist/types/src/core/capabilities.d.ts +14 -14
- package/dist/types/src/core/capabilities.d.ts.map +1 -1
- package/dist/types/src/core/manager.d.ts +1 -1
- package/dist/types/src/core/manager.d.ts.map +1 -1
- package/dist/types/src/core/plugin.d.ts +4 -0
- package/dist/types/src/core/plugin.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +0 -2
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/playground/generator/Main.d.ts.map +1 -1
- package/dist/types/src/plugin-intent/intent-dispatcher.d.ts.map +1 -1
- package/dist/types/src/react/App.d.ts.map +1 -0
- package/dist/types/src/react/App.stories.d.ts.map +1 -0
- package/dist/types/src/react/DefaultFallback.d.ts.map +1 -0
- package/dist/types/src/react/Surface.d.ts +4 -4
- package/dist/types/src/react/Surface.d.ts.map +1 -1
- package/dist/types/src/react/Surface.stories.d.ts +3 -6
- package/dist/types/src/react/Surface.stories.d.ts.map +1 -1
- package/dist/types/src/react/index.d.ts +2 -0
- package/dist/types/src/react/index.d.ts.map +1 -1
- package/dist/types/src/react/types.d.ts +14 -0
- package/dist/types/src/react/types.d.ts.map +1 -0
- package/dist/types/src/{components → react}/useApp.d.ts +2 -2
- package/dist/types/src/react/useApp.d.ts.map +1 -0
- package/dist/types/src/react/useLoading.d.ts.map +1 -0
- package/dist/types/src/testing/withPluginManager.d.ts +4 -3
- package/dist/types/src/testing/withPluginManager.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/moon.yml +1 -1
- package/package.json +36 -33
- package/src/common/capabilities.ts +19 -22
- package/src/common/collaboration.ts +2 -2
- package/src/common/surface.ts +14 -9
- package/src/core/capabilities.test.ts +1 -1
- package/src/core/capabilities.ts +25 -21
- package/src/core/manager.ts +2 -2
- package/src/core/plugin.ts +5 -0
- package/src/index.ts +0 -2
- package/src/playground/generator/Main.tsx +0 -1
- package/src/playground/playground.stories.tsx +1 -1
- package/src/plugin-intent/errors.ts +1 -1
- package/src/plugin-intent/intent-dispatcher.ts +5 -0
- package/src/plugin-settings/app-graph-builder.ts +5 -5
- package/src/plugin-settings/store.ts +2 -2
- package/src/plugin-settings/translations.ts +1 -1
- package/src/{components → react}/App.tsx +1 -1
- package/src/{components → react}/DefaultFallback.tsx +1 -1
- package/src/react/Surface.stories.tsx +69 -45
- package/src/react/Surface.tsx +56 -33
- package/src/react/index.ts +4 -0
- package/src/react/types.ts +38 -0
- package/src/{components → react}/useApp.tsx +15 -14
- package/src/react/useCapabilities.ts +2 -2
- package/src/testing/withPluginManager.tsx +9 -4
- package/tsconfig.json +9 -0
- package/dist/lib/browser/app-graph-builder-77MY7KAY.mjs.map +0 -7
- package/dist/lib/browser/chunk-4NFLRSTX.mjs.map +0 -7
- package/dist/lib/browser/chunk-OKF2PAWO.mjs.map +0 -7
- package/dist/lib/browser/store-E3YSBPJQ.mjs.map +0 -7
- package/dist/lib/browser/worker.mjs +0 -77
- package/dist/lib/node-esm/app-graph-builder-WK7WBM6I.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-7DNZQ6H2.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-AHCD4UYO.mjs.map +0 -7
- package/dist/lib/node-esm/store-QA5DGTOS.mjs.map +0 -7
- package/dist/lib/node-esm/worker.mjs +0 -78
- package/dist/types/src/components/App.d.ts.map +0 -1
- package/dist/types/src/components/App.stories.d.ts.map +0 -1
- package/dist/types/src/components/DefaultFallback.d.ts.map +0 -1
- package/dist/types/src/components/index.d.ts +0 -2
- package/dist/types/src/components/index.d.ts.map +0 -1
- package/dist/types/src/components/useApp.d.ts.map +0 -1
- package/dist/types/src/components/useLoading.d.ts.map +0 -1
- package/dist/types/src/worker.d.ts +0 -4
- package/dist/types/src/worker.d.ts.map +0 -1
- package/src/components/index.ts +0 -5
- package/src/worker.ts +0 -11
- /package/dist/lib/browser/{intent-dispatcher-Y4LZNOBC.mjs.map → intent-dispatcher-LZ4AE66E.mjs.map} +0 -0
- /package/dist/lib/browser/{intent-resolver-XO5OYWVD.mjs.map → intent-resolver-QVCKRX6G.mjs.map} +0 -0
- /package/dist/lib/browser/{worker.mjs.map → react/index.mjs.map} +0 -0
- /package/dist/lib/node-esm/{intent-dispatcher-R4CCPBHO.mjs.map → intent-dispatcher-MGOJ3CHD.mjs.map} +0 -0
- /package/dist/lib/node-esm/{intent-resolver-NVYY6BQA.mjs.map → intent-resolver-URF3HN3G.mjs.map} +0 -0
- /package/dist/lib/node-esm/{worker.mjs.map → react/index.mjs.map} +0 -0
- /package/dist/types/src/{components → react}/App.d.ts +0 -0
- /package/dist/types/src/{components → react}/App.stories.d.ts +0 -0
- /package/dist/types/src/{components → react}/DefaultFallback.d.ts +0 -0
- /package/dist/types/src/{components → react}/useLoading.d.ts +0 -0
- /package/src/{components → react}/App.stories.tsx +0 -0
- /package/src/{components → react}/useLoading.tsx +0 -0
package/moon.yml
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/app-framework",
|
|
3
|
-
"version": "0.8.4-main.
|
|
3
|
+
"version": "0.8.4-main.66e292d",
|
|
4
4
|
"description": "A framework for building applications from composible plugins.",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -15,27 +15,27 @@
|
|
|
15
15
|
"browser": "./dist/lib/browser/index.mjs",
|
|
16
16
|
"node": "./dist/lib/node-esm/index.mjs"
|
|
17
17
|
},
|
|
18
|
+
"./react": {
|
|
19
|
+
"source": "./src/react/index.ts",
|
|
20
|
+
"types": "./dist/types/src/react/index.d.ts",
|
|
21
|
+
"browser": "./dist/lib/browser/react/index.mjs",
|
|
22
|
+
"node": "./dist/lib/node-esm/react/index.mjs"
|
|
23
|
+
},
|
|
18
24
|
"./testing": {
|
|
19
25
|
"source": "./src/testing/index.ts",
|
|
20
26
|
"types": "./dist/types/src/testing/index.d.ts",
|
|
21
27
|
"browser": "./dist/lib/browser/testing/index.mjs",
|
|
22
28
|
"node": "./dist/lib/node-esm/testing/index.mjs"
|
|
23
|
-
},
|
|
24
|
-
"./worker": {
|
|
25
|
-
"source": "./src/worker.ts",
|
|
26
|
-
"types": "./dist/types/src/worker.d.ts",
|
|
27
|
-
"browser": "./dist/lib/browser/worker.mjs",
|
|
28
|
-
"node": "./dist/lib/node-esm/worker.mjs"
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
31
|
"types": "dist/types/src/index.d.ts",
|
|
32
32
|
"typesVersions": {
|
|
33
33
|
"*": {
|
|
34
|
+
"react": [
|
|
35
|
+
"dist/types/src/react/index.d.ts"
|
|
36
|
+
],
|
|
34
37
|
"testing": [
|
|
35
38
|
"dist/types/src/testing/index.d.ts"
|
|
36
|
-
],
|
|
37
|
-
"worker": [
|
|
38
|
-
"dist/types/src/worker.d.ts"
|
|
39
39
|
]
|
|
40
40
|
}
|
|
41
41
|
},
|
|
@@ -44,38 +44,41 @@
|
|
|
44
44
|
"@effect/experimental": "0.56.0",
|
|
45
45
|
"@preact-signals/safe-react": "^0.9.0",
|
|
46
46
|
"@preact/signals-core": "^1.12.1",
|
|
47
|
-
"@dxos/ai": "0.8.4-main.
|
|
48
|
-
"@dxos/
|
|
49
|
-
"@dxos/blueprints": "0.8.4-main.
|
|
50
|
-
"@dxos/
|
|
51
|
-
"@dxos/
|
|
52
|
-
"@dxos/
|
|
53
|
-
"@dxos/
|
|
54
|
-
"@dxos/
|
|
55
|
-
"@dxos/
|
|
56
|
-
"@dxos/
|
|
57
|
-
"@dxos/
|
|
58
|
-
"@dxos/
|
|
59
|
-
"@dxos/
|
|
60
|
-
"@dxos/
|
|
61
|
-
"@dxos/
|
|
62
|
-
"@dxos/
|
|
47
|
+
"@dxos/ai": "0.8.4-main.66e292d",
|
|
48
|
+
"@dxos/app-graph": "0.8.4-main.66e292d",
|
|
49
|
+
"@dxos/blueprints": "0.8.4-main.66e292d",
|
|
50
|
+
"@dxos/assistant": "0.8.4-main.66e292d",
|
|
51
|
+
"@dxos/debug": "0.8.4-main.66e292d",
|
|
52
|
+
"@dxos/client-protocol": "0.8.4-main.66e292d",
|
|
53
|
+
"@dxos/async": "0.8.4-main.66e292d",
|
|
54
|
+
"@dxos/echo": "0.8.4-main.66e292d",
|
|
55
|
+
"@dxos/functions": "0.8.4-main.66e292d",
|
|
56
|
+
"@dxos/invariant": "0.8.4-main.66e292d",
|
|
57
|
+
"@dxos/keys": "0.8.4-main.66e292d",
|
|
58
|
+
"@dxos/local-storage": "0.8.4-main.66e292d",
|
|
59
|
+
"@dxos/live-object": "0.8.4-main.66e292d",
|
|
60
|
+
"@dxos/schema": "0.8.4-main.66e292d",
|
|
61
|
+
"@dxos/log": "0.8.4-main.66e292d",
|
|
62
|
+
"@dxos/react-hooks": "0.8.4-main.66e292d",
|
|
63
|
+
"@dxos/types": "0.8.4-main.66e292d",
|
|
64
|
+
"@dxos/util": "0.8.4-main.66e292d"
|
|
63
65
|
},
|
|
64
66
|
"devDependencies": {
|
|
65
|
-
"@effect-
|
|
67
|
+
"@effect-atom/atom-react": "^0.3.4",
|
|
66
68
|
"@effect/platform": "0.92.1",
|
|
67
69
|
"@types/react": "~19.2.2",
|
|
68
70
|
"effect": "3.18.3",
|
|
69
71
|
"react": "~19.2.0",
|
|
70
72
|
"typedoc": "0.28.1",
|
|
71
|
-
"@dxos/echo-signals": "0.8.4-main.
|
|
72
|
-
"@dxos/
|
|
73
|
-
"@dxos/
|
|
74
|
-
"@dxos/react-ui-
|
|
75
|
-
"@dxos/
|
|
73
|
+
"@dxos/echo-signals": "0.8.4-main.66e292d",
|
|
74
|
+
"@dxos/random": "0.8.4-main.66e292d",
|
|
75
|
+
"@dxos/react-ui": "0.8.4-main.66e292d",
|
|
76
|
+
"@dxos/react-ui-theme": "0.8.4-main.66e292d",
|
|
77
|
+
"@dxos/react-ui-syntax-highlighter": "0.8.4-main.66e292d",
|
|
78
|
+
"@dxos/storybook-utils": "0.8.4-main.66e292d"
|
|
76
79
|
},
|
|
77
80
|
"peerDependencies": {
|
|
78
|
-
"@effect-
|
|
81
|
+
"@effect-atom/atom-react": "^0.3.4",
|
|
79
82
|
"@effect/platform": "^0.80.12",
|
|
80
83
|
"effect": "^3.13.3",
|
|
81
84
|
"react": "^19.0.0"
|
|
@@ -2,9 +2,7 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import type
|
|
6
|
-
import type * as Toolkit from '@effect/ai/Toolkit';
|
|
7
|
-
import { type Registry } from '@effect-rx/rx-react';
|
|
5
|
+
import { type Registry } from '@effect-atom/atom-react';
|
|
8
6
|
import type * as Layer from 'effect/Layer';
|
|
9
7
|
import type * as Schema from 'effect/Schema';
|
|
10
8
|
import { type FC, type PropsWithChildren } from 'react';
|
|
@@ -12,11 +10,12 @@ import { type FC, type PropsWithChildren } from 'react';
|
|
|
12
10
|
import { type AiService } from '@dxos/ai';
|
|
13
11
|
import type * as AiServiceRouter from '@dxos/ai/AiServiceRouter';
|
|
14
12
|
import { type BuilderExtensions, type GraphBuilder } from '@dxos/app-graph';
|
|
13
|
+
import { type GenericToolkit } from '@dxos/assistant';
|
|
15
14
|
import { type Blueprint } from '@dxos/blueprints';
|
|
16
15
|
import { type Space } from '@dxos/client-protocol';
|
|
17
16
|
import { type FunctionDefinition } from '@dxos/functions';
|
|
18
17
|
import { type RootSettingsStore } from '@dxos/local-storage';
|
|
19
|
-
import { type AnchoredTo } from '@dxos/
|
|
18
|
+
import { type AnchoredTo } from '@dxos/types';
|
|
20
19
|
|
|
21
20
|
import { type PluginManager, defineCapability } from '../core';
|
|
22
21
|
import { type AnyIntentResolver, type IntentContext } from '../plugin-intent';
|
|
@@ -41,9 +40,13 @@ export namespace Capabilities {
|
|
|
41
40
|
/**
|
|
42
41
|
* @category Capability
|
|
43
42
|
*/
|
|
44
|
-
export const
|
|
43
|
+
export const AtomRegistry = defineCapability<Registry.Registry>('dxos.org/app-framework/capability/atom-registry');
|
|
45
44
|
|
|
46
|
-
export type ReactContext = Readonly<{
|
|
45
|
+
export type ReactContext = Readonly<{
|
|
46
|
+
id: string;
|
|
47
|
+
dependsOn?: string[];
|
|
48
|
+
context: FC<PropsWithChildren>;
|
|
49
|
+
}>;
|
|
47
50
|
|
|
48
51
|
/**
|
|
49
52
|
* @category Capability
|
|
@@ -151,25 +154,21 @@ export namespace Capabilities {
|
|
|
151
154
|
*/
|
|
152
155
|
export const Settings = defineCapability<Settings>('dxos.org/app-framework/capability/settings');
|
|
153
156
|
|
|
154
|
-
export type Metadata = Readonly<{
|
|
157
|
+
export type Metadata = Readonly<{
|
|
158
|
+
id: string;
|
|
159
|
+
metadata: Record<string, any>;
|
|
160
|
+
}>;
|
|
155
161
|
|
|
156
162
|
/**
|
|
157
163
|
* @category Capability
|
|
158
164
|
*/
|
|
159
165
|
export const Metadata = defineCapability<Metadata>('dxos.org/app-framework/capability/metadata');
|
|
160
166
|
|
|
161
|
-
// TODO(dmaretskyi): Consider combining Toolkit and ToolkitHandler for type-safe context.
|
|
162
|
-
|
|
163
|
-
/**
|
|
164
|
-
* @category Capability
|
|
165
|
-
*/
|
|
166
|
-
export const Toolkit = defineCapability<Toolkit.Any>('dxos.org/app-framework/capability/ai-toolkit');
|
|
167
|
-
|
|
168
167
|
/**
|
|
169
168
|
* @category Capability
|
|
170
169
|
*/
|
|
171
|
-
export const
|
|
172
|
-
'dxos.org/app-framework/capability/ai-toolkit
|
|
170
|
+
export const Toolkit = defineCapability<GenericToolkit.GenericToolkit>(
|
|
171
|
+
'dxos.org/app-framework/capability/ai-toolkit',
|
|
173
172
|
);
|
|
174
173
|
|
|
175
174
|
/**
|
|
@@ -194,20 +193,18 @@ export namespace Capabilities {
|
|
|
194
193
|
/**
|
|
195
194
|
* @category Capability
|
|
196
195
|
*/
|
|
197
|
-
export const Functions = defineCapability<FunctionDefinition
|
|
198
|
-
'dxos.org/app-framework/capability/functions',
|
|
199
|
-
);
|
|
196
|
+
export const Functions = defineCapability<FunctionDefinition.Any[]>('dxos.org/app-framework/capability/functions');
|
|
200
197
|
|
|
201
|
-
export type FileUploader = (
|
|
198
|
+
export type FileUploader = (space: Space, file: File) => Promise<FileInfo | undefined>;
|
|
202
199
|
|
|
203
200
|
/**
|
|
204
201
|
* @category Capability
|
|
205
202
|
*/
|
|
206
203
|
export const FileUploader = defineCapability<FileUploader>('dxos.org/app-framework/capability/file-uploader');
|
|
207
204
|
|
|
208
|
-
type AnchorSort = {
|
|
205
|
+
export type AnchorSort = {
|
|
209
206
|
key: string;
|
|
210
|
-
sort: (anchorA: AnchoredTo, anchorB: AnchoredTo) => number;
|
|
207
|
+
sort: (anchorA: AnchoredTo.AnchoredTo, anchorB: AnchoredTo.AnchoredTo) => number;
|
|
211
208
|
};
|
|
212
209
|
|
|
213
210
|
/**
|
|
@@ -4,14 +4,14 @@
|
|
|
4
4
|
|
|
5
5
|
import * as Schema from 'effect/Schema';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { ContentBlock } from '@dxos/types';
|
|
8
8
|
|
|
9
9
|
export namespace CollaborationActions {
|
|
10
10
|
export class AcceptProposal extends Schema.TaggedClass<AcceptProposal>()('collaboration/accept-proposal', {
|
|
11
11
|
input: Schema.Struct({
|
|
12
12
|
subject: Schema.Any,
|
|
13
13
|
anchor: Schema.String,
|
|
14
|
-
proposal:
|
|
14
|
+
proposal: ContentBlock.Proposal,
|
|
15
15
|
}),
|
|
16
16
|
output: Schema.Void,
|
|
17
17
|
}) {}
|
package/src/common/surface.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import type { ComponentType, PropsWithChildren, ReactNode } from 'react';
|
|
6
6
|
|
|
7
|
-
import { type
|
|
7
|
+
import { type MakeOptional, type Position } from '@dxos/util';
|
|
8
8
|
|
|
9
9
|
import { type ErrorBoundary } from '../react';
|
|
10
10
|
|
|
@@ -24,15 +24,19 @@ export type SurfaceProps<T extends Record<string, any> = Record<string, unknown>
|
|
|
24
24
|
*/
|
|
25
25
|
placeholder?: ReactNode;
|
|
26
26
|
} & MakeOptional<CoreSurfaceProps<T>, 'id' | 'data'> &
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
/**
|
|
28
|
+
* Additional props to pass to the component.
|
|
29
|
+
* These props are not used by Surface itself but may be used by components which resolve the surface.
|
|
30
|
+
* Exclude known prop names to prevent overriding well-defined props.
|
|
31
|
+
*/
|
|
30
32
|
{
|
|
31
33
|
[K in keyof Record<string, any>]: K extends keyof CoreSurfaceProps<T> | 'fallback' | 'placeholder' ? never : any;
|
|
32
34
|
};
|
|
33
35
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
+
/**
|
|
37
|
+
* NOTE: If `[key: string]: unknown` is included in shared types, when re-used other fields become unknown as well.
|
|
38
|
+
*/
|
|
39
|
+
export type CoreSurfaceProps<T extends Record<string, any> = Record<string, unknown>> = PropsWithChildren<{
|
|
36
40
|
/**
|
|
37
41
|
* ID for debugging.
|
|
38
42
|
*/
|
|
@@ -45,6 +49,7 @@ type CoreSurfaceProps<T extends Record<string, any> = Record<string, unknown>> =
|
|
|
45
49
|
|
|
46
50
|
/**
|
|
47
51
|
* The data to be rendered by the surface.
|
|
52
|
+
* NOTE: This must be a stable value.
|
|
48
53
|
*/
|
|
49
54
|
data: T;
|
|
50
55
|
|
|
@@ -54,13 +59,13 @@ type CoreSurfaceProps<T extends Record<string, any> = Record<string, unknown>> =
|
|
|
54
59
|
limit?: number | undefined;
|
|
55
60
|
}>;
|
|
56
61
|
|
|
57
|
-
type SurfaceComponentProps<T extends Record<string, any> = Record<string,
|
|
62
|
+
export type SurfaceComponentProps<T extends Record<string, any> = Record<string, any>> = CoreSurfaceProps<T> &
|
|
58
63
|
Record<string, any>;
|
|
59
64
|
|
|
60
65
|
/**
|
|
61
66
|
* React component used to render a surface once is has matched.
|
|
62
67
|
*/
|
|
63
|
-
export type SurfaceComponent<T extends Record<string, any> = Record<string,
|
|
68
|
+
export type SurfaceComponent<T extends Record<string, any> = Record<string, any>> = ComponentType<
|
|
64
69
|
SurfaceComponentProps<T>
|
|
65
70
|
>;
|
|
66
71
|
|
|
@@ -71,8 +76,8 @@ export type SurfaceDefinition<T extends Record<string, any> = any> = Readonly<{
|
|
|
71
76
|
id: string;
|
|
72
77
|
role: string | string[];
|
|
73
78
|
position?: Position;
|
|
79
|
+
component: SurfaceComponent<T>;
|
|
74
80
|
filter?: (data: Record<string, unknown>) => data is T;
|
|
75
|
-
component: SurfaceComponent<GuardedType<SurfaceDefinition<T>['filter']>>;
|
|
76
81
|
}>;
|
|
77
82
|
|
|
78
83
|
/**
|
package/src/core/capabilities.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { type Registry
|
|
5
|
+
import { Atom, type Registry } from '@effect-atom/atom-react';
|
|
6
6
|
import * as Effect from 'effect/Effect';
|
|
7
7
|
|
|
8
8
|
import { Trigger } from '@dxos/async';
|
|
@@ -41,17 +41,17 @@ export type Capability<T> = {
|
|
|
41
41
|
/**
|
|
42
42
|
* The interface definition of the capability.
|
|
43
43
|
*/
|
|
44
|
-
interface: InterfaceDef<T>;
|
|
44
|
+
readonly interface: InterfaceDef<T>;
|
|
45
45
|
|
|
46
46
|
/**
|
|
47
47
|
* The implementation of the capability.
|
|
48
48
|
*/
|
|
49
|
-
implementation: T;
|
|
49
|
+
readonly implementation: T;
|
|
50
50
|
|
|
51
51
|
/**
|
|
52
52
|
* Called when the capability is deactivated.
|
|
53
53
|
*/
|
|
54
|
-
deactivate?: () => MaybePromise<void> | Effect.Effect<void, Error>;
|
|
54
|
+
readonly deactivate?: () => MaybePromise<void> | Effect.Effect<void, Error>;
|
|
55
55
|
};
|
|
56
56
|
|
|
57
57
|
export type AnyCapability = Capability<any>;
|
|
@@ -78,7 +78,11 @@ export const contributes = <I extends InterfaceDef<any>>(
|
|
|
78
78
|
implementation: Capability<InterfaceDef.Implementation<I>>['implementation'],
|
|
79
79
|
deactivate?: Capability<InterfaceDef.Implementation<I>>['deactivate'],
|
|
80
80
|
): Capability<I> => {
|
|
81
|
-
return {
|
|
81
|
+
return {
|
|
82
|
+
interface: interfaceDef,
|
|
83
|
+
implementation,
|
|
84
|
+
deactivate,
|
|
85
|
+
} satisfies Capability<I>;
|
|
82
86
|
};
|
|
83
87
|
|
|
84
88
|
type LoadCapability<T, U> = () => Promise<{ default: (props: T) => MaybePromise<Capability<U>> }>;
|
|
@@ -105,19 +109,19 @@ export const lazy =
|
|
|
105
109
|
export class PluginContext {
|
|
106
110
|
private readonly _registry: Registry.Registry;
|
|
107
111
|
|
|
108
|
-
private readonly _capabilityImpls =
|
|
109
|
-
return
|
|
112
|
+
private readonly _capabilityImpls = Atom.family<string, Atom.Writable<CapabilityImpl<unknown>[]>>(() => {
|
|
113
|
+
return Atom.make<CapabilityImpl<unknown>[]>([]).pipe(Atom.keepAlive);
|
|
110
114
|
});
|
|
111
115
|
|
|
112
|
-
readonly _capabilities =
|
|
113
|
-
return
|
|
116
|
+
readonly _capabilities = Atom.family<string, Atom.Atom<unknown[]>>((id: string) => {
|
|
117
|
+
return Atom.make((get) => {
|
|
114
118
|
const current = get(this._capabilityImpls(id));
|
|
115
119
|
return current.map((c) => c.implementation);
|
|
116
120
|
});
|
|
117
121
|
});
|
|
118
122
|
|
|
119
|
-
readonly _capability =
|
|
120
|
-
return
|
|
123
|
+
readonly _capability = Atom.family<string, Atom.Atom<unknown>>((id: string) => {
|
|
124
|
+
return Atom.make((get) => {
|
|
121
125
|
const current = get(this._capabilities(id));
|
|
122
126
|
invariant(current.length > 0, `No capability found for ${id}`);
|
|
123
127
|
return current[0];
|
|
@@ -189,26 +193,26 @@ export class PluginContext {
|
|
|
189
193
|
}
|
|
190
194
|
|
|
191
195
|
/**
|
|
192
|
-
* Get the
|
|
193
|
-
* Primarily useful for deriving other
|
|
196
|
+
* Get the Atom reference to the available capabilities for a given interface.
|
|
197
|
+
* Primarily useful for deriving other Atom values based on the capabilities or
|
|
194
198
|
* for subscribing to changes in the capabilities.
|
|
195
|
-
* @returns An
|
|
199
|
+
* @returns An atom reference to the available capabilities.
|
|
196
200
|
*/
|
|
197
|
-
capabilities<T>(interfaceDef: InterfaceDef<T>):
|
|
201
|
+
capabilities<T>(interfaceDef: InterfaceDef<T>): Atom.Atom<T[]> {
|
|
198
202
|
// NOTE: This the type-checking for capabilities is done at the time of contribution.
|
|
199
|
-
return this._capabilities(interfaceDef.identifier) as
|
|
203
|
+
return this._capabilities(interfaceDef.identifier) as Atom.Atom<T[]>;
|
|
200
204
|
}
|
|
201
205
|
|
|
202
206
|
/**
|
|
203
|
-
* Get the
|
|
204
|
-
* Primarily useful for deriving other
|
|
207
|
+
* Get the Atom reference to the available capabilities for a given interface.
|
|
208
|
+
* Primarily useful for deriving other Atom values based on the capability or
|
|
205
209
|
* for subscribing to changes in the capability.
|
|
206
|
-
* @returns An
|
|
210
|
+
* @returns An atom reference to the available capability.
|
|
207
211
|
* @throws If no capability is found.
|
|
208
212
|
*/
|
|
209
|
-
capability<T>(interfaceDef: InterfaceDef<T>):
|
|
213
|
+
capability<T>(interfaceDef: InterfaceDef<T>): Atom.Atom<T> {
|
|
210
214
|
// NOTE: This the type-checking for capabilities is done at the time of contribution.
|
|
211
|
-
return this._capability(interfaceDef.identifier) as
|
|
215
|
+
return this._capability(interfaceDef.identifier) as Atom.Atom<T>;
|
|
212
216
|
}
|
|
213
217
|
|
|
214
218
|
/**
|
package/src/core/manager.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { Registry } from '@effect-
|
|
5
|
+
import { Registry } from '@effect-atom/atom-react';
|
|
6
6
|
import { untracked } from '@preact/signals-core';
|
|
7
7
|
import * as Array from 'effect/Array';
|
|
8
8
|
import * as Duration from 'effect/Duration';
|
|
@@ -55,7 +55,7 @@ export class PluginManager {
|
|
|
55
55
|
readonly context: PluginContext;
|
|
56
56
|
readonly registry: Registry.Registry;
|
|
57
57
|
|
|
58
|
-
// TODO(wittjosiah): Replace with
|
|
58
|
+
// TODO(wittjosiah): Replace with Atom.
|
|
59
59
|
private readonly _state: Live<PluginManagerState>;
|
|
60
60
|
private readonly _pluginLoader: PluginManagerOptions['pluginLoader'];
|
|
61
61
|
private readonly _capabilities = new Map<string, AnyCapability[]>();
|
package/src/core/plugin.ts
CHANGED
|
@@ -110,6 +110,11 @@ export type PluginMeta = {
|
|
|
110
110
|
* A grep-able symbol string which can be resolved to an icon asset by @ch-ui/icons, via @ch-ui/vite-plugin-icons.
|
|
111
111
|
*/
|
|
112
112
|
icon?: string;
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Icon hue (ChromaticPalette).
|
|
116
|
+
*/
|
|
117
|
+
iconHue?: string;
|
|
113
118
|
};
|
|
114
119
|
|
|
115
120
|
/**
|
package/src/index.ts
CHANGED
|
@@ -7,8 +7,8 @@ import React from 'react';
|
|
|
7
7
|
|
|
8
8
|
import { withTheme } from '@dxos/react-ui/testing';
|
|
9
9
|
|
|
10
|
-
import { useApp } from '../components';
|
|
11
10
|
import { IntentPlugin } from '../plugin-intent';
|
|
11
|
+
import { useApp } from '../react';
|
|
12
12
|
|
|
13
13
|
import { DebugPlugin } from './debug';
|
|
14
14
|
import { GeneratorPlugin, createNumberPlugin } from './generator';
|
|
@@ -24,7 +24,7 @@ export class BaseError extends Error {
|
|
|
24
24
|
|
|
25
25
|
export class NoResolversError extends BaseError {
|
|
26
26
|
constructor(action: string) {
|
|
27
|
-
super('NO_RESOLVERS',
|
|
27
|
+
super('NO_RESOLVERS', `No resolvers were found for the action: ${action}`, { action });
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
|
|
@@ -209,6 +209,7 @@ export const createDispatcher = (
|
|
|
209
209
|
});
|
|
210
210
|
|
|
211
211
|
const dispatch: IntentDispatcher = (intentChain, depth = 0) => {
|
|
212
|
+
log('dispatch', { intentChain: intentChain.all.map((i) => i.id), depth });
|
|
212
213
|
return Effect.gen(function* () {
|
|
213
214
|
if (depth > executionLimit) {
|
|
214
215
|
return yield* Effect.fail(new CycleDetectedError());
|
|
@@ -216,8 +217,10 @@ export const createDispatcher = (
|
|
|
216
217
|
|
|
217
218
|
const resultsRef = yield* Ref.make<AnyIntentResult[]>([]);
|
|
218
219
|
for (const intent of intentChain.all) {
|
|
220
|
+
log('processing', { intent });
|
|
219
221
|
const { data: prev } = (yield* resultsRef.get)[0] ?? {};
|
|
220
222
|
const result = yield* handleIntent({ ...intent, data: { ...intent.data, ...prev } });
|
|
223
|
+
log('ok', { intent: intent.id, result });
|
|
221
224
|
yield* Ref.update(resultsRef, (results) => [result, ...results]);
|
|
222
225
|
if (result.intents) {
|
|
223
226
|
for (const intent of result.intents) {
|
|
@@ -234,6 +237,7 @@ export const createDispatcher = (
|
|
|
234
237
|
// error: result.error.message,
|
|
235
238
|
// }),
|
|
236
239
|
// );
|
|
240
|
+
log.error('failed', { intent: intent.id, error: result.error });
|
|
237
241
|
return yield* Effect.fail(result.error);
|
|
238
242
|
}
|
|
239
243
|
}
|
|
@@ -263,6 +267,7 @@ export const createDispatcher = (
|
|
|
263
267
|
);
|
|
264
268
|
}
|
|
265
269
|
|
|
270
|
+
log('done', { intent: intentChain.all.map((i) => i.id), result: result.data });
|
|
266
271
|
return result.data;
|
|
267
272
|
});
|
|
268
273
|
};
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { Atom } from '@effect-atom/atom-react';
|
|
6
6
|
import * as Function from 'effect/Function';
|
|
7
7
|
import * as Option from 'effect/Option';
|
|
8
8
|
|
|
@@ -22,7 +22,7 @@ export default (context: PluginContext) =>
|
|
|
22
22
|
createExtension({
|
|
23
23
|
id: `${meta.id}/action`,
|
|
24
24
|
actions: (node) =>
|
|
25
|
-
|
|
25
|
+
Atom.make((get) =>
|
|
26
26
|
Function.pipe(
|
|
27
27
|
get(node),
|
|
28
28
|
Option.flatMap((node) => (node.id === ROOT_ID ? Option.some(node) : Option.none())),
|
|
@@ -51,7 +51,7 @@ export default (context: PluginContext) =>
|
|
|
51
51
|
createExtension({
|
|
52
52
|
id: `${meta.id}/core`,
|
|
53
53
|
connector: (node) =>
|
|
54
|
-
|
|
54
|
+
Atom.make((get) =>
|
|
55
55
|
Function.pipe(
|
|
56
56
|
get(node),
|
|
57
57
|
Option.flatMap((node) => (node.id === ROOT_ID ? Option.some(node) : Option.none())),
|
|
@@ -75,7 +75,7 @@ export default (context: PluginContext) =>
|
|
|
75
75
|
createExtension({
|
|
76
76
|
id: `${meta.id}/core-plugins`,
|
|
77
77
|
connector: (node) =>
|
|
78
|
-
|
|
78
|
+
Atom.make((get) =>
|
|
79
79
|
Function.pipe(
|
|
80
80
|
get(node),
|
|
81
81
|
Option.flatMap((node) => (node.id !== SETTINGS_ID ? Option.none() : Option.some(node))),
|
|
@@ -123,7 +123,7 @@ export default (context: PluginContext) =>
|
|
|
123
123
|
createExtension({
|
|
124
124
|
id: `${meta.id}/custom-plugins`,
|
|
125
125
|
connector: (node) =>
|
|
126
|
-
|
|
126
|
+
Atom.make((get) =>
|
|
127
127
|
Function.pipe(
|
|
128
128
|
get(node),
|
|
129
129
|
Option.flatMap((node) =>
|
|
@@ -8,11 +8,11 @@ import { Capabilities } from '../common';
|
|
|
8
8
|
import { type PluginContext, contributes } from '../core';
|
|
9
9
|
|
|
10
10
|
export default (context: PluginContext) => {
|
|
11
|
-
// TODO(wittjosiah): Replace with
|
|
11
|
+
// TODO(wittjosiah): Replace with atom?
|
|
12
12
|
const settingsStore = new RootSettingsStore();
|
|
13
13
|
|
|
14
14
|
let previous: Capabilities.Settings[] = [];
|
|
15
|
-
const registry = context.getCapability(Capabilities.
|
|
15
|
+
const registry = context.getCapability(Capabilities.AtomRegistry);
|
|
16
16
|
const cancel = registry.subscribe(
|
|
17
17
|
context.capabilities(Capabilities.Settings),
|
|
18
18
|
(allSettings) => {
|
|
@@ -6,9 +6,9 @@ import React, { type PropsWithChildren } from 'react';
|
|
|
6
6
|
|
|
7
7
|
import { Capabilities } from '../common';
|
|
8
8
|
import { topologicalSort } from '../helpers';
|
|
9
|
-
import { useCapabilities } from '../react';
|
|
10
9
|
|
|
11
10
|
import { type UseAppOptions } from './useApp';
|
|
11
|
+
import { useCapabilities } from './useCapabilities';
|
|
12
12
|
import { LoadingState, useLoading } from './useLoading';
|
|
13
13
|
|
|
14
14
|
export type AppProps = Pick<UseAppOptions, 'placeholder' | 'debounce'> & {
|
|
@@ -19,7 +19,7 @@ export const DefaultFallback = ({ error }: { error: Error }) => {
|
|
|
19
19
|
}}
|
|
20
20
|
>
|
|
21
21
|
{/* TODO(wittjosiah): Link to docs for replacing default. */}
|
|
22
|
-
<h1 style={{ margin: '0.5rem 0', fontSize: '1.2rem' }}>
|
|
22
|
+
<h1 style={{ margin: '0.5rem 0', fontSize: '1.2rem' }}>ERROR: {error.message}</h1>
|
|
23
23
|
<pre style={{ overflow: 'auto', fontSize: '1rem', whiteSpace: 'pre-wrap', color: '#888888' }}>{error.stack}</pre>
|
|
24
24
|
</div>
|
|
25
25
|
);
|