@dxos/app-framework 0.8.4-main.67995b8 → 0.8.4-main.72ec0f3
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/.storybook/main.mts +11 -0
- package/.storybook/preview.mts +8 -0
- package/.swc/plugins/linux_x86_64_19.0.0/727453fb3a62f7f1d952a41e051ca8a6f88cadc45cee43c6a4d1aa45f9b75665.wasmer-v7 +0 -0
- package/.swc/plugins/{v7_linux_x86_64_13.0.0/fce1bdb8e20a094e4af08bad09cc81497ed0e2e7c51223b07d371063cca18429 → linux_x86_64_19.0.0/fce1bdb8e20a094e4af08bad09cc81497ed0e2e7c51223b07d371063cca18429.wasmer-v7} +0 -0
- package/dist/lib/browser/{app-graph-builder-LYF7EKNN.mjs → app-graph-builder-OIEZZC45.mjs} +32 -31
- package/dist/lib/browser/app-graph-builder-OIEZZC45.mjs.map +7 -0
- package/dist/lib/browser/{chunk-ORWHM7CO.mjs → chunk-SCPE4ZO2.mjs} +11 -8
- package/dist/lib/browser/chunk-SCPE4ZO2.mjs.map +7 -0
- package/dist/lib/browser/{chunk-FO2PH7M3.mjs → chunk-VFUKEZIN.mjs} +254 -186
- package/dist/lib/browser/chunk-VFUKEZIN.mjs.map +7 -0
- package/dist/lib/browser/{chunk-FMN65HSW.mjs → chunk-WPW5VVAX.mjs} +397 -265
- package/dist/lib/browser/chunk-WPW5VVAX.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +20 -56
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/{intent-dispatcher-LSYQZSEB.mjs → intent-dispatcher-LZ4AE66E.mjs} +2 -2
- package/dist/lib/browser/{intent-resolver-ZTNOSO3A.mjs → intent-resolver-QVCKRX6G.mjs} +7 -7
- package/dist/lib/browser/intent-resolver-QVCKRX6G.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/react/index.mjs +34 -0
- package/dist/lib/browser/{store-KML2R4IE.mjs → store-CNPHOYTJ.mjs} +5 -5
- package/dist/lib/browser/store-CNPHOYTJ.mjs.map +7 -0
- package/dist/lib/browser/testing/index.mjs +17 -21
- package/dist/lib/browser/testing/index.mjs.map +3 -3
- package/dist/lib/node-esm/{app-graph-builder-SAOWGJDK.mjs → app-graph-builder-EBU4NVWD.mjs} +32 -31
- package/dist/lib/node-esm/app-graph-builder-EBU4NVWD.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-73HGSHKE.mjs → chunk-IJOHO66N.mjs} +254 -186
- package/dist/lib/node-esm/chunk-IJOHO66N.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-ZEZ4FVEU.mjs → chunk-XJZGUJ3H.mjs} +397 -265
- package/dist/lib/node-esm/chunk-XJZGUJ3H.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-UMZQERLE.mjs → chunk-ZX63QUGE.mjs} +11 -8
- package/dist/lib/node-esm/chunk-ZX63QUGE.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +20 -56
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/{intent-dispatcher-6CYNGPSW.mjs → intent-dispatcher-MGOJ3CHD.mjs} +2 -2
- package/dist/lib/node-esm/{intent-resolver-W7Z7WFFM.mjs → intent-resolver-URF3HN3G.mjs} +7 -7
- package/dist/lib/node-esm/intent-resolver-URF3HN3G.mjs.map +7 -0
- 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-QEXGXLWZ.mjs → store-RK5B4XEL.mjs} +5 -5
- package/dist/lib/node-esm/store-RK5B4XEL.mjs.map +7 -0
- package/dist/lib/node-esm/testing/index.mjs +17 -21
- package/dist/lib/node-esm/testing/index.mjs.map +3 -3
- package/dist/types/src/common/capabilities.d.ts +110 -39
- package/dist/types/src/common/capabilities.d.ts.map +1 -1
- package/dist/types/src/common/collaboration.d.ts +10 -9
- package/dist/types/src/common/collaboration.d.ts.map +1 -1
- package/dist/types/src/common/events.d.ts.map +1 -1
- package/dist/types/src/common/file.d.ts +1 -1
- package/dist/types/src/common/file.d.ts.map +1 -1
- package/dist/types/src/common/index.d.ts +1 -1
- package/dist/types/src/common/index.d.ts.map +1 -1
- package/dist/types/src/common/layout.d.ts +1 -3
- package/dist/types/src/common/layout.d.ts.map +1 -1
- package/dist/types/src/common/surface.d.ts +19 -16
- package/dist/types/src/common/surface.d.ts.map +1 -1
- package/dist/types/src/common/translations.d.ts +1 -1
- package/dist/types/src/common/translations.d.ts.map +1 -1
- package/dist/types/src/core/capabilities.d.ts +19 -16
- package/dist/types/src/core/capabilities.d.ts.map +1 -1
- package/dist/types/src/core/manager.d.ts +7 -3
- package/dist/types/src/core/manager.d.ts.map +1 -1
- package/dist/types/src/core/plugin.d.ts +8 -1
- 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/debug/Debug.d.ts +1 -1
- package/dist/types/src/playground/debug/plugin.d.ts +1 -1
- package/dist/types/src/playground/debug/plugin.d.ts.map +1 -1
- package/dist/types/src/playground/generator/Main.d.ts +1 -1
- package/dist/types/src/playground/generator/Main.d.ts.map +1 -1
- package/dist/types/src/playground/generator/Toolbar.d.ts +1 -1
- package/dist/types/src/playground/generator/Toolbar.d.ts.map +1 -1
- package/dist/types/src/playground/generator/generator.d.ts +1 -1
- package/dist/types/src/playground/generator/generator.d.ts.map +1 -1
- package/dist/types/src/playground/generator/plugin.d.ts +1 -1
- package/dist/types/src/playground/generator/plugin.d.ts.map +1 -1
- package/dist/types/src/playground/layout/Layout.d.ts +2 -2
- package/dist/types/src/playground/layout/plugin.d.ts +1 -1
- package/dist/types/src/playground/layout/plugin.d.ts.map +1 -1
- package/dist/types/src/playground/logger/Toolbar.d.ts +1 -1
- package/dist/types/src/playground/logger/Toolbar.d.ts.map +1 -1
- package/dist/types/src/playground/logger/plugin.d.ts +1 -1
- package/dist/types/src/playground/logger/plugin.d.ts.map +1 -1
- package/dist/types/src/playground/logger/schema.d.ts +1 -1
- package/dist/types/src/playground/logger/schema.d.ts.map +1 -1
- package/dist/types/src/playground/playground.stories.d.ts +5 -4
- package/dist/types/src/playground/playground.stories.d.ts.map +1 -1
- package/dist/types/src/plugin-intent/IntentPlugin.d.ts +1 -1
- package/dist/types/src/plugin-intent/IntentPlugin.d.ts.map +1 -1
- package/dist/types/src/plugin-intent/actions.d.ts +5 -7
- package/dist/types/src/plugin-intent/actions.d.ts.map +1 -1
- package/dist/types/src/plugin-intent/errors.d.ts.map +1 -1
- package/dist/types/src/plugin-intent/index.d.ts +1 -0
- package/dist/types/src/plugin-intent/index.d.ts.map +1 -1
- package/dist/types/src/plugin-intent/intent-dispatcher.d.ts +7 -7
- package/dist/types/src/plugin-intent/intent-dispatcher.d.ts.map +1 -1
- package/dist/types/src/plugin-intent/intent.d.ts +1 -1
- package/dist/types/src/plugin-intent/intent.d.ts.map +1 -1
- package/dist/types/src/plugin-intent/meta.d.ts +3 -0
- package/dist/types/src/plugin-intent/meta.d.ts.map +1 -0
- package/dist/types/src/plugin-settings/SettingsPlugin.d.ts +1 -1
- package/dist/types/src/plugin-settings/SettingsPlugin.d.ts.map +1 -1
- package/dist/types/src/plugin-settings/actions.d.ts +5 -7
- package/dist/types/src/plugin-settings/actions.d.ts.map +1 -1
- package/dist/types/src/plugin-settings/app-graph-builder.d.ts +1 -1
- package/dist/types/src/plugin-settings/app-graph-builder.d.ts.map +1 -1
- package/dist/types/src/plugin-settings/intent-resolver.d.ts +1 -1
- package/dist/types/src/plugin-settings/intent-resolver.d.ts.map +1 -1
- package/dist/types/src/plugin-settings/meta.d.ts +3 -0
- package/dist/types/src/plugin-settings/meta.d.ts.map +1 -0
- package/dist/types/src/plugin-settings/store.d.ts +1 -1
- package/dist/types/src/plugin-settings/store.d.ts.map +1 -1
- package/dist/types/src/plugin-settings/translations.d.ts +2 -1
- package/dist/types/src/plugin-settings/translations.d.ts.map +1 -1
- package/dist/types/src/react/App.d.ts +10 -0
- package/dist/types/src/react/App.d.ts.map +1 -0
- package/dist/types/src/react/App.stories.d.ts +14 -0
- package/dist/types/src/react/App.stories.d.ts.map +1 -0
- package/dist/types/src/react/DefaultFallback.d.ts +8 -0
- package/dist/types/src/react/DefaultFallback.d.ts.map +1 -0
- package/dist/types/src/react/ErrorBoundary.d.ts +13 -14
- package/dist/types/src/react/ErrorBoundary.d.ts.map +1 -1
- package/dist/types/src/react/IntentContext.d.ts.map +1 -1
- package/dist/types/src/react/Surface.d.ts +5 -5
- package/dist/types/src/react/Surface.d.ts.map +1 -1
- package/dist/types/src/react/Surface.stories.d.ts +8 -10
- package/dist/types/src/react/Surface.stories.d.ts.map +1 -1
- package/dist/types/src/react/common.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/{App.d.ts → react/useApp.d.ts} +7 -6
- package/dist/types/src/react/useApp.d.ts.map +1 -0
- package/dist/types/src/react/useCapabilities.d.ts.map +1 -1
- package/dist/types/src/react/useLoading.d.ts +19 -0
- package/dist/types/src/react/useLoading.d.ts.map +1 -0
- package/dist/types/src/testing/withPluginManager.d.ts +9 -8
- package/dist/types/src/testing/withPluginManager.d.ts.map +1 -1
- package/dist/types/src/testing/withPluginManager.stories.d.ts +9 -3
- package/dist/types/src/testing/withPluginManager.stories.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/moon.yml +5 -1
- package/package.json +48 -43
- package/src/common/capabilities.ts +116 -20
- package/src/common/collaboration.ts +6 -9
- package/src/common/events.ts +3 -1
- package/src/common/file.ts +1 -1
- package/src/common/index.ts +1 -1
- package/src/common/layout.ts +3 -4
- package/src/common/surface.ts +23 -21
- package/src/common/translations.ts +1 -1
- package/src/core/capabilities.test.ts +3 -3
- package/src/core/capabilities.ts +36 -27
- package/src/core/manager.test.ts +22 -21
- package/src/core/manager.ts +141 -56
- package/src/core/plugin.ts +13 -2
- package/src/helpers.test.ts +1 -1
- package/src/index.ts +0 -2
- package/src/playground/debug/Debug.tsx +1 -1
- package/src/playground/debug/plugin.ts +7 -8
- package/src/playground/generator/Main.tsx +0 -1
- package/src/playground/generator/Toolbar.tsx +2 -1
- package/src/playground/generator/generator.ts +4 -4
- package/src/playground/generator/plugin.ts +12 -13
- package/src/playground/layout/plugin.ts +10 -9
- package/src/playground/logger/Toolbar.tsx +2 -1
- package/src/playground/logger/plugin.ts +30 -25
- package/src/playground/logger/schema.ts +1 -1
- package/src/playground/playground.stories.tsx +20 -16
- package/src/plugin-intent/IntentPlugin.ts +13 -13
- package/src/plugin-intent/actions.ts +4 -6
- package/src/plugin-intent/errors.ts +2 -1
- package/src/plugin-intent/index.ts +1 -0
- package/src/plugin-intent/intent-dispatcher.test.ts +10 -3
- package/src/plugin-intent/intent-dispatcher.ts +21 -12
- package/src/plugin-intent/intent.ts +1 -1
- package/src/plugin-intent/meta.ts +10 -0
- package/src/plugin-settings/SettingsPlugin.ts +27 -28
- package/src/plugin-settings/actions.ts +9 -13
- package/src/plugin-settings/app-graph-builder.ts +25 -22
- package/src/plugin-settings/intent-resolver.ts +5 -4
- package/src/plugin-settings/meta.ts +10 -0
- package/src/plugin-settings/store.ts +3 -3
- package/src/plugin-settings/translations.ts +4 -4
- package/src/react/App.stories.tsx +33 -0
- package/src/react/App.tsx +59 -0
- package/src/react/DefaultFallback.tsx +26 -0
- package/src/react/ErrorBoundary.tsx +26 -15
- package/src/react/IntentContext.tsx +3 -2
- package/src/react/Surface.stories.tsx +81 -52
- package/src/react/Surface.tsx +70 -38
- package/src/react/common.ts +2 -1
- package/src/react/index.ts +4 -0
- package/src/react/types.ts +37 -0
- package/src/react/useApp.tsx +165 -0
- package/src/react/useCapabilities.ts +4 -3
- package/src/react/useLoading.tsx +70 -0
- package/src/testing/withPluginManager.stories.tsx +9 -5
- package/src/testing/withPluginManager.tsx +33 -32
- package/tsconfig.json +11 -9
- package/vitest.config.ts +8 -6
- package/.swc/plugins/v7_linux_x86_64_13.0.0/f45bdff002284d9e8f9ef3f0be909de12da36c049cbcf261ac78fc00abb09a2d +0 -0
- package/dist/lib/browser/app-graph-builder-LYF7EKNN.mjs.map +0 -7
- package/dist/lib/browser/chunk-FMN65HSW.mjs.map +0 -7
- package/dist/lib/browser/chunk-FO2PH7M3.mjs.map +0 -7
- package/dist/lib/browser/chunk-ORWHM7CO.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-ZTNOSO3A.mjs.map +0 -7
- package/dist/lib/browser/store-KML2R4IE.mjs.map +0 -7
- package/dist/lib/browser/worker.mjs +0 -79
- package/dist/lib/node-esm/app-graph-builder-SAOWGJDK.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-73HGSHKE.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-UMZQERLE.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-ZEZ4FVEU.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-W7Z7WFFM.mjs.map +0 -7
- package/dist/lib/node-esm/store-QEXGXLWZ.mjs.map +0 -7
- package/dist/lib/node-esm/worker.mjs +0 -80
- package/dist/types/src/App.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/App.tsx +0 -276
- package/src/worker.ts +0 -11
- /package/dist/lib/browser/{intent-dispatcher-LSYQZSEB.mjs.map → intent-dispatcher-LZ4AE66E.mjs.map} +0 -0
- /package/dist/lib/browser/{worker.mjs.map → react/index.mjs.map} +0 -0
- /package/dist/lib/node-esm/{intent-dispatcher-6CYNGPSW.mjs.map → intent-dispatcher-MGOJ3CHD.mjs.map} +0 -0
- /package/dist/lib/node-esm/{worker.mjs.map → react/index.mjs.map} +0 -0
|
@@ -22,7 +22,7 @@ export const Debug = () => {
|
|
|
22
22
|
};
|
|
23
23
|
|
|
24
24
|
return (
|
|
25
|
-
<SyntaxHighlighter language='json' classNames='
|
|
25
|
+
<SyntaxHighlighter language='json' classNames='text-xs opacity-75 rounded'>
|
|
26
26
|
{JSON.stringify(object, undefined, 2)}
|
|
27
27
|
</SyntaxHighlighter>
|
|
28
28
|
);
|
|
@@ -7,11 +7,10 @@ import { defineModule, definePlugin, lazy } from '../../core';
|
|
|
7
7
|
|
|
8
8
|
const Debug = lazy(() => import('./Debug'));
|
|
9
9
|
|
|
10
|
-
export const DebugPlugin = () =>
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
]);
|
|
10
|
+
export const DebugPlugin = definePlugin({ id: 'dxos.org/test/plugin-debug', name: 'Debug' }, () => [
|
|
11
|
+
defineModule({
|
|
12
|
+
id: 'dxos.org/test/debug/main',
|
|
13
|
+
activatesOn: Events.Startup,
|
|
14
|
+
activate: Debug,
|
|
15
|
+
}),
|
|
16
|
+
]);
|
|
@@ -6,12 +6,13 @@ import React, { useCallback } from 'react';
|
|
|
6
6
|
|
|
7
7
|
import { Button } from '@dxos/react-ui';
|
|
8
8
|
|
|
9
|
-
import { createGeneratorIntent, createPluginId, Number } from './generator';
|
|
10
9
|
import { Capabilities } from '../../common';
|
|
11
10
|
import { contributes } from '../../core';
|
|
12
11
|
import { createIntent } from '../../plugin-intent';
|
|
13
12
|
import { useCapabilities, useIntentDispatcher, usePluginManager } from '../../react';
|
|
14
13
|
|
|
14
|
+
import { Number, createGeneratorIntent, createPluginId } from './generator';
|
|
15
|
+
|
|
15
16
|
export const Toolbar = () => {
|
|
16
17
|
const manager = usePluginManager();
|
|
17
18
|
const { dispatchPromise: dispatch } = useIntentDispatcher();
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
6
|
|
|
7
7
|
import { Capabilities, Events } from '../../common';
|
|
8
|
-
import { contributes,
|
|
9
|
-
import {
|
|
8
|
+
import { contributes, defineCapability, defineEvent, defineModule, definePlugin } from '../../core';
|
|
9
|
+
import { type IntentSchema, createResolver } from '../../plugin-intent';
|
|
10
10
|
|
|
11
11
|
export const Number = defineCapability<number>('dxos.org/test/generator/number');
|
|
12
12
|
|
|
@@ -26,7 +26,7 @@ export const createGeneratorIntent = (id: string) => {
|
|
|
26
26
|
export const createNumberPlugin = (id: string) => {
|
|
27
27
|
const number = Math.floor(Math.random() * 100);
|
|
28
28
|
|
|
29
|
-
return definePlugin({ id, name: `Plugin ${id}` }, [
|
|
29
|
+
return definePlugin({ id, name: `Plugin ${id}` }, () => [
|
|
30
30
|
defineModule({
|
|
31
31
|
id: `${id}/main`,
|
|
32
32
|
activatesOn: CountEvent,
|
|
@@ -8,16 +8,15 @@ import { defineModule, definePlugin, lazy } from '../../core';
|
|
|
8
8
|
const Main = lazy(() => import('./Main'));
|
|
9
9
|
const Toolbar = lazy(() => import('./Toolbar'));
|
|
10
10
|
|
|
11
|
-
export const GeneratorPlugin = () =>
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
]);
|
|
11
|
+
export const GeneratorPlugin = definePlugin({ id: 'dxos.org/test/generator', name: 'Generator' }, () => [
|
|
12
|
+
defineModule({
|
|
13
|
+
id: 'dxos.org/test/generator/main',
|
|
14
|
+
activatesOn: Events.Startup,
|
|
15
|
+
activate: Main,
|
|
16
|
+
}),
|
|
17
|
+
defineModule({
|
|
18
|
+
id: 'dxos.org/test/generator/toolbar',
|
|
19
|
+
activatesOn: Events.Startup,
|
|
20
|
+
activate: Toolbar,
|
|
21
|
+
}),
|
|
22
|
+
]);
|
|
@@ -3,15 +3,16 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { Events } from '../../common';
|
|
6
|
-
import { definePlugin, lazy
|
|
6
|
+
import { defineModule, definePlugin, lazy } from '../../core';
|
|
7
7
|
|
|
8
8
|
const Layout = lazy(() => import('./Layout'));
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
10
|
+
const meta = { id: 'dxos.org/test/layout', name: 'Layout' };
|
|
11
|
+
|
|
12
|
+
export const LayoutPlugin = definePlugin(meta, () => [
|
|
13
|
+
defineModule({
|
|
14
|
+
id: 'dxos.org/test/layout/root',
|
|
15
|
+
activatesOn: Events.Startup,
|
|
16
|
+
activate: Layout,
|
|
17
|
+
}),
|
|
18
|
+
]);
|
|
@@ -6,12 +6,13 @@ import React, { useCallback } from 'react';
|
|
|
6
6
|
|
|
7
7
|
import { Button } from '@dxos/react-ui';
|
|
8
8
|
|
|
9
|
-
import { Log } from './schema';
|
|
10
9
|
import { Capabilities, createSurface } from '../../common';
|
|
11
10
|
import { contributes } from '../../core';
|
|
12
11
|
import { createIntent } from '../../plugin-intent';
|
|
13
12
|
import { useIntentDispatcher } from '../../react';
|
|
14
13
|
|
|
14
|
+
import { Log } from './schema';
|
|
15
|
+
|
|
15
16
|
export const Logger = () => {
|
|
16
17
|
const { dispatchPromise } = useIntentDispatcher();
|
|
17
18
|
const handleClick = useCallback(() => dispatchPromise(createIntent(Log, { message: 'Hello, world!' })), []);
|
|
@@ -4,33 +4,38 @@
|
|
|
4
4
|
|
|
5
5
|
import { log } from '@dxos/log';
|
|
6
6
|
|
|
7
|
-
import { Log } from './schema';
|
|
8
7
|
import { Capabilities, Events } from '../../common';
|
|
9
|
-
import { contributes, defineModule,
|
|
8
|
+
import { contributes, defineModule, definePlugin, lazy } from '../../core';
|
|
10
9
|
import { createResolver } from '../../plugin-intent';
|
|
11
10
|
|
|
11
|
+
import { Log } from './schema';
|
|
12
|
+
|
|
12
13
|
const Toolbar = lazy(() => import('./Toolbar'));
|
|
13
14
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
15
|
+
const meta = {
|
|
16
|
+
id: 'dxos.org/test/logger',
|
|
17
|
+
name: 'Logger',
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const LoggerPlugin = definePlugin(meta, () => [
|
|
21
|
+
defineModule({
|
|
22
|
+
id: 'dxos.org/test/logger/intents',
|
|
23
|
+
activatesOn: Events.SetupIntentResolver,
|
|
24
|
+
activate: () => [
|
|
25
|
+
contributes(
|
|
26
|
+
Capabilities.IntentResolver,
|
|
27
|
+
createResolver({
|
|
28
|
+
intent: Log,
|
|
29
|
+
resolve: ({ message }) => {
|
|
30
|
+
log.info(message);
|
|
31
|
+
},
|
|
32
|
+
}),
|
|
33
|
+
),
|
|
34
|
+
],
|
|
35
|
+
}),
|
|
36
|
+
defineModule({
|
|
37
|
+
id: 'dxos.org/test/logger/surfaces',
|
|
38
|
+
activatesOn: Events.Startup,
|
|
39
|
+
activate: Toolbar,
|
|
40
|
+
}),
|
|
41
|
+
]);
|
|
@@ -2,41 +2,45 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import '@
|
|
6
|
-
|
|
5
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
7
6
|
import React from 'react';
|
|
8
7
|
|
|
9
|
-
import {
|
|
8
|
+
import { withTheme } from '@dxos/react-ui/testing';
|
|
9
|
+
|
|
10
|
+
import { IntentPlugin } from '../plugin-intent';
|
|
11
|
+
import { useApp } from '../react';
|
|
10
12
|
|
|
11
13
|
import { DebugPlugin } from './debug';
|
|
12
|
-
import {
|
|
14
|
+
import { GeneratorPlugin, createNumberPlugin } from './generator';
|
|
13
15
|
import { LayoutPlugin } from './layout';
|
|
14
16
|
import { LoggerPlugin } from './logger';
|
|
15
|
-
import { useApp } from '../App';
|
|
16
|
-
import { IntentPlugin } from '../plugin-intent';
|
|
17
17
|
|
|
18
|
-
const
|
|
18
|
+
const pluginFactories = [IntentPlugin, LayoutPlugin, DebugPlugin(), LoggerPlugin(), GeneratorPlugin()];
|
|
19
|
+
const plugins = pluginFactories.map((factory) => (typeof factory === 'function' ? factory() : factory));
|
|
19
20
|
|
|
20
21
|
const Placeholder = () => {
|
|
21
22
|
return <div>Loading...</div>;
|
|
22
23
|
};
|
|
23
24
|
|
|
24
|
-
const
|
|
25
|
+
const DefaultStory = () => {
|
|
25
26
|
const App = useApp({
|
|
26
|
-
pluginLoader: (id) => createNumberPlugin(id),
|
|
27
|
+
pluginLoader: (id) => createNumberPlugin(id)(),
|
|
27
28
|
plugins,
|
|
28
29
|
core: plugins.map((plugin) => plugin.meta.id),
|
|
29
|
-
// Having a non-empty placeholder makes it clear if it's taking a while to load.
|
|
30
30
|
placeholder: Placeholder,
|
|
31
31
|
});
|
|
32
32
|
|
|
33
33
|
return <App />;
|
|
34
34
|
};
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
export default {
|
|
36
|
+
const meta = {
|
|
39
37
|
title: 'sdk/app-framework/playground',
|
|
40
|
-
render:
|
|
41
|
-
decorators: [withTheme
|
|
42
|
-
}
|
|
38
|
+
render: DefaultStory,
|
|
39
|
+
decorators: [withTheme],
|
|
40
|
+
} satisfies Meta<typeof DefaultStory>;
|
|
41
|
+
|
|
42
|
+
export default meta;
|
|
43
|
+
|
|
44
|
+
type Story = StoryObj<typeof meta>;
|
|
45
|
+
|
|
46
|
+
export const Playground: Story = {};
|
|
@@ -2,19 +2,19 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { INTENT_PLUGIN } from './actions';
|
|
6
5
|
import { Events } from '../common';
|
|
7
6
|
import { defineModule, definePlugin, lazy } from '../core';
|
|
8
7
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
8
|
+
import { meta } from './meta';
|
|
9
|
+
|
|
10
|
+
export const IntentPlugin = definePlugin(meta, () => [
|
|
11
|
+
defineModule({
|
|
12
|
+
id: `${meta.id}/module/dispatcher`,
|
|
13
|
+
// TODO(wittjosiah): This will mean that startup needs to be reset when intents are added or removed.
|
|
14
|
+
// This is fine for now because it's how it worked prior to capabilities api anyways.
|
|
15
|
+
// In the future, the intent dispatcher should be able to be reset without resetting the entire app.
|
|
16
|
+
activatesOn: Events.Startup,
|
|
17
|
+
activatesAfter: [Events.DispatcherReady],
|
|
18
|
+
activate: lazy(() => import('./intent-dispatcher')),
|
|
19
|
+
}),
|
|
20
|
+
]);
|
|
@@ -2,18 +2,16 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
6
|
|
|
7
7
|
import { Label } from './intent';
|
|
8
|
-
|
|
9
|
-
export const INTENT_PLUGIN = 'dxos.org/plugin/intent';
|
|
10
|
-
export const INTENT_ACTION = `${INTENT_PLUGIN}/action`;
|
|
8
|
+
import { meta } from './meta';
|
|
11
9
|
|
|
12
10
|
export namespace IntentAction {
|
|
13
11
|
/**
|
|
14
12
|
* Log an intent.
|
|
15
13
|
*/
|
|
16
|
-
export class Track extends Schema.TaggedClass<Track>()(`${
|
|
14
|
+
export class Track extends Schema.TaggedClass<Track>()(`${meta.id}/action/track`, {
|
|
17
15
|
input: Schema.Struct({
|
|
18
16
|
intents: Schema.Array(Schema.String),
|
|
19
17
|
error: Schema.optional(Schema.String),
|
|
@@ -24,7 +22,7 @@ export namespace IntentAction {
|
|
|
24
22
|
/**
|
|
25
23
|
* Fired after an intent is dispatched if the intent is undoable.
|
|
26
24
|
*/
|
|
27
|
-
export class ShowUndo extends Schema.TaggedClass<ShowUndo>()(`${
|
|
25
|
+
export class ShowUndo extends Schema.TaggedClass<ShowUndo>()(`${meta.id}/action/show-undo`, {
|
|
28
26
|
input: Schema.Struct({
|
|
29
27
|
message: Label,
|
|
30
28
|
}),
|
|
@@ -24,10 +24,11 @@ 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
|
|
|
31
|
+
// TODO(burdon): Detect loops.
|
|
31
32
|
export class CycleDetectedError extends BaseError {
|
|
32
33
|
constructor(context?: Record<string, any>) {
|
|
33
34
|
super(
|
|
@@ -2,7 +2,10 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
6
|
+
import * as Fiber from 'effect/Fiber';
|
|
7
|
+
import * as Function from 'effect/Function';
|
|
8
|
+
import * as Schema from 'effect/Schema';
|
|
6
9
|
import { describe, expect, test } from 'vitest';
|
|
7
10
|
|
|
8
11
|
import { chain, createIntent } from './intent';
|
|
@@ -104,7 +107,11 @@ describe('Intent dispatcher', () => {
|
|
|
104
107
|
|
|
105
108
|
test('chain intents', async () => {
|
|
106
109
|
const { dispatch } = createDispatcher(() => [computeResolver, toStringResolver, concatResolver]);
|
|
107
|
-
const intent = pipe(
|
|
110
|
+
const intent = Function.pipe(
|
|
111
|
+
createIntent(Compute, { value: 1 }),
|
|
112
|
+
chain(ToString, {}),
|
|
113
|
+
chain(Concat, { plus: '!' }),
|
|
114
|
+
);
|
|
108
115
|
|
|
109
116
|
expect(intent.first.id).toBe(Compute._tag);
|
|
110
117
|
expect(intent.last.id).toBe(Concat._tag);
|
|
@@ -120,7 +127,7 @@ describe('Intent dispatcher', () => {
|
|
|
120
127
|
|
|
121
128
|
test('undo chained intent', async () => {
|
|
122
129
|
const { dispatch, undo } = createDispatcher(() => [computeResolver, toStringResolver, concatResolver]);
|
|
123
|
-
const intent = pipe(createIntent(Compute, { value: 1 }), chain(Compute, {}), chain(Compute, {}));
|
|
130
|
+
const intent = Function.pipe(createIntent(Compute, { value: 1 }), chain(Compute, {}), chain(Compute, {}));
|
|
124
131
|
const program = Effect.gen(function* () {
|
|
125
132
|
const a = yield* dispatch(intent);
|
|
126
133
|
|
|
@@ -2,17 +2,22 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
6
|
-
import
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
6
|
+
import * as Function from 'effect/Function';
|
|
7
|
+
import * as Option from 'effect/Option';
|
|
8
|
+
import * as Ref from 'effect/Ref';
|
|
9
|
+
import type * as Types from 'effect/Types';
|
|
7
10
|
|
|
8
11
|
import { live } from '@dxos/live-object';
|
|
9
12
|
import { log } from '@dxos/log';
|
|
10
|
-
import {
|
|
13
|
+
import { type GuardedType, type MaybePromise, type Position, byPosition } from '@dxos/util';
|
|
14
|
+
|
|
15
|
+
import { Capabilities, Events } from '../common';
|
|
16
|
+
import { type PluginContext, contributes } from '../core';
|
|
11
17
|
|
|
12
18
|
import { IntentAction } from './actions';
|
|
13
19
|
import { CycleDetectedError, NoResolversError } from './errors';
|
|
14
20
|
import {
|
|
15
|
-
createIntent,
|
|
16
21
|
type AnyIntent,
|
|
17
22
|
type AnyIntentChain,
|
|
18
23
|
type Intent,
|
|
@@ -22,9 +27,8 @@ import {
|
|
|
22
27
|
type IntentResultData,
|
|
23
28
|
type IntentSchema,
|
|
24
29
|
type Label,
|
|
30
|
+
createIntent,
|
|
25
31
|
} from './intent';
|
|
26
|
-
import { Events, Capabilities } from '../common';
|
|
27
|
-
import { contributes, type PluginContext } from '../core';
|
|
28
32
|
|
|
29
33
|
const EXECUTION_LIMIT = 100;
|
|
30
34
|
const HISTORY_LIMIT = 100;
|
|
@@ -131,7 +135,7 @@ export const createResolver = <Tag extends string, Fields extends IntentParams,
|
|
|
131
135
|
*/
|
|
132
136
|
export type PromiseIntentDispatcher = <Fields extends IntentParams>(
|
|
133
137
|
intent: IntentChain<any, any, any, Fields>,
|
|
134
|
-
) => Promise<Simplify<IntentDispatcherResult<IntentData<Fields>, IntentResultData<Fields>>>>;
|
|
138
|
+
) => Promise<Types.Simplify<IntentDispatcherResult<IntentData<Fields>, IntentResultData<Fields>>>>;
|
|
135
139
|
|
|
136
140
|
/**
|
|
137
141
|
* Creates an effect for intents.
|
|
@@ -140,7 +144,7 @@ export type IntentDispatcher = <Fields extends IntentParams>(
|
|
|
140
144
|
intent: IntentChain<any, any, any, Fields>,
|
|
141
145
|
depth?: number,
|
|
142
146
|
) => Effect.Effect<
|
|
143
|
-
Simplify<Required<IntentDispatcherResult<IntentData<Fields>, IntentResultData<Fields>>>['data']>,
|
|
147
|
+
Types.Simplify<Required<IntentDispatcherResult<IntentData<Fields>, IntentResultData<Fields>>>['data']>,
|
|
144
148
|
Error
|
|
145
149
|
>;
|
|
146
150
|
|
|
@@ -196,7 +200,7 @@ export const createDispatcher = (
|
|
|
196
200
|
.filter((resolver) => !resolver.filter || resolver.filter(intent.data))
|
|
197
201
|
.toSorted(byPosition);
|
|
198
202
|
if (candidates.length === 0) {
|
|
199
|
-
yield* Effect.fail(new NoResolversError(intent.id));
|
|
203
|
+
return yield* Effect.fail(new NoResolversError(intent.id));
|
|
200
204
|
}
|
|
201
205
|
|
|
202
206
|
const effect = candidates[0].resolve(intent.data, intent.undo ?? false);
|
|
@@ -205,15 +209,18 @@ export const createDispatcher = (
|
|
|
205
209
|
});
|
|
206
210
|
|
|
207
211
|
const dispatch: IntentDispatcher = (intentChain, depth = 0) => {
|
|
212
|
+
log('dispatch', { intentChain: intentChain.all.map((i) => i.id), depth });
|
|
208
213
|
return Effect.gen(function* () {
|
|
209
214
|
if (depth > executionLimit) {
|
|
210
|
-
yield* Effect.fail(new CycleDetectedError());
|
|
215
|
+
return yield* Effect.fail(new CycleDetectedError());
|
|
211
216
|
}
|
|
212
217
|
|
|
213
218
|
const resultsRef = yield* Ref.make<AnyIntentResult[]>([]);
|
|
214
219
|
for (const intent of intentChain.all) {
|
|
220
|
+
log('processing', { intent });
|
|
215
221
|
const { data: prev } = (yield* resultsRef.get)[0] ?? {};
|
|
216
222
|
const result = yield* handleIntent({ ...intent, data: { ...intent.data, ...prev } });
|
|
223
|
+
log('ok', { intent: intent.id, result });
|
|
217
224
|
yield* Ref.update(resultsRef, (results) => [result, ...results]);
|
|
218
225
|
if (result.intents) {
|
|
219
226
|
for (const intent of result.intents) {
|
|
@@ -230,7 +237,8 @@ export const createDispatcher = (
|
|
|
230
237
|
// error: result.error.message,
|
|
231
238
|
// }),
|
|
232
239
|
// );
|
|
233
|
-
|
|
240
|
+
log.error('failed', { intent: intent.id, error: result.error });
|
|
241
|
+
return yield* Effect.fail(result.error);
|
|
234
242
|
}
|
|
235
243
|
}
|
|
236
244
|
|
|
@@ -251,7 +259,7 @@ export const createDispatcher = (
|
|
|
251
259
|
|
|
252
260
|
if (result.undoable && isUndoable(results)) {
|
|
253
261
|
// TODO(wittjosiah): Is there a better way to handle showing undo for chains?
|
|
254
|
-
yield* pipe(
|
|
262
|
+
yield* Function.pipe(
|
|
255
263
|
dispatch(createIntent(IntentAction.ShowUndo, { message: result.undoable.message })),
|
|
256
264
|
Effect.catchSome((err) =>
|
|
257
265
|
err instanceof NoResolversError ? Option.some(Effect.succeed(undefined)) : Option.none(),
|
|
@@ -259,6 +267,7 @@ export const createDispatcher = (
|
|
|
259
267
|
);
|
|
260
268
|
}
|
|
261
269
|
|
|
270
|
+
log('done', { intent: intentChain.all.map((i) => i.id), result: result.data });
|
|
262
271
|
return result.data;
|
|
263
272
|
});
|
|
264
273
|
};
|
|
@@ -2,34 +2,33 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { SETTINGS_PLUGIN } from './actions';
|
|
6
|
-
import { translations } from './translations';
|
|
7
5
|
import { Capabilities, Events } from '../common';
|
|
8
6
|
import { contributes, defineModule, definePlugin, lazy } from '../core';
|
|
9
7
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
8
|
+
import { meta } from './meta';
|
|
9
|
+
import { translations } from './translations';
|
|
10
|
+
|
|
11
|
+
export const SettingsPlugin = definePlugin(meta, () => [
|
|
12
|
+
defineModule({
|
|
13
|
+
id: `${meta.id}/module/store`,
|
|
14
|
+
activatesOn: Events.Startup,
|
|
15
|
+
activatesBefore: [Events.SetupSettings],
|
|
16
|
+
activatesAfter: [Events.SettingsReady],
|
|
17
|
+
activate: lazy(() => import('./store')),
|
|
18
|
+
}),
|
|
19
|
+
defineModule({
|
|
20
|
+
id: `${meta.id}/module/translations`,
|
|
21
|
+
activatesOn: Events.SetupTranslations,
|
|
22
|
+
activate: () => contributes(Capabilities.Translations, translations),
|
|
23
|
+
}),
|
|
24
|
+
defineModule({
|
|
25
|
+
id: `${meta.id}/module/intent-resolver`,
|
|
26
|
+
activatesOn: Events.SetupIntentResolver,
|
|
27
|
+
activate: lazy(() => import('./intent-resolver')),
|
|
28
|
+
}),
|
|
29
|
+
defineModule({
|
|
30
|
+
id: `${meta.id}/module/app-graph-builder`,
|
|
31
|
+
activatesOn: Events.SetupAppGraph,
|
|
32
|
+
activate: lazy(() => import('./app-graph-builder')),
|
|
33
|
+
}),
|
|
34
|
+
]);
|
|
@@ -2,28 +2,24 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
// TODO(
|
|
10
|
-
// Ideally this should be worked into the data model in a generic way.
|
|
7
|
+
import { meta } from './meta';
|
|
8
|
+
|
|
9
|
+
// TODO(burdon): Document.
|
|
11
10
|
export const SETTINGS_ID = '!dxos:settings';
|
|
12
11
|
export const SETTINGS_KEY = 'settings';
|
|
13
12
|
|
|
14
13
|
export namespace SettingsAction {
|
|
15
|
-
export class Open extends Schema.TaggedClass<Open>()(`${
|
|
14
|
+
export class Open extends Schema.TaggedClass<Open>()(`${meta.id}/open`, {
|
|
16
15
|
input: Schema.Struct({
|
|
17
16
|
plugin: Schema.optional(Schema.String),
|
|
18
17
|
}),
|
|
19
18
|
output: Schema.Void,
|
|
20
19
|
}) {}
|
|
21
20
|
|
|
22
|
-
export class OpenPluginRegistry extends Schema.TaggedClass<OpenPluginRegistry>()(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
output: Schema.Void,
|
|
27
|
-
},
|
|
28
|
-
) {}
|
|
21
|
+
export class OpenPluginRegistry extends Schema.TaggedClass<OpenPluginRegistry>()(`${meta.id}/open-plugin-registry`, {
|
|
22
|
+
input: Schema.Void,
|
|
23
|
+
output: Schema.Void,
|
|
24
|
+
}) {}
|
|
29
25
|
}
|