@dxos/plugin-attention 0.8.4-main.e8ec1fe → 0.8.4-main.effb148878
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/LICENSE +102 -5
- package/README.md +1 -1
- package/dist/lib/neutral/AttentionPlugin.mjs +9 -0
- package/dist/lib/neutral/capabilities/index.mjs +11 -0
- package/dist/lib/neutral/capabilities/index.mjs.map +7 -0
- package/dist/lib/neutral/chunk-DPUSNLAH.mjs +60 -0
- package/dist/lib/neutral/chunk-DPUSNLAH.mjs.map +7 -0
- package/dist/lib/neutral/chunk-DTGSOFCE.mjs +41 -0
- package/dist/lib/neutral/chunk-DTGSOFCE.mjs.map +7 -0
- package/dist/lib/neutral/chunk-QSTYRKHK.mjs +8 -0
- package/dist/lib/neutral/chunk-QSTYRKHK.mjs.map +7 -0
- package/dist/lib/{browser/chunk-62F4J5KY.mjs → neutral/chunk-TNTMPZ3O.mjs} +7 -3
- package/dist/lib/neutral/chunk-TNTMPZ3O.mjs.map +7 -0
- package/dist/lib/neutral/index.mjs +15 -0
- package/dist/lib/neutral/keyboard-6CPNUR24.mjs +19 -0
- package/dist/lib/neutral/keyboard-6CPNUR24.mjs.map +7 -0
- package/dist/lib/neutral/meta.json +1 -0
- package/dist/lib/neutral/meta.mjs +7 -0
- package/dist/lib/neutral/meta.mjs.map +7 -0
- package/dist/lib/neutral/operation-handler-O5PDEBTC.mjs +11 -0
- package/dist/lib/neutral/operation-handler-O5PDEBTC.mjs.map +7 -0
- package/dist/lib/neutral/operations/index.mjs +7 -0
- package/dist/lib/neutral/operations/index.mjs.map +7 -0
- package/dist/lib/neutral/plugin.mjs +15 -0
- package/dist/lib/neutral/plugin.mjs.map +7 -0
- package/dist/lib/{browser/react-context-HXORYGNN.mjs → neutral/react-context-W7BGQDHK.mjs} +8 -12
- package/dist/lib/neutral/react-context-W7BGQDHK.mjs.map +7 -0
- package/dist/lib/neutral/select-CI2OLVWT.mjs +46 -0
- package/dist/lib/neutral/select-CI2OLVWT.mjs.map +7 -0
- package/dist/lib/neutral/testing.mjs +7 -0
- package/dist/lib/neutral/testing.mjs.map +7 -0
- package/dist/lib/neutral/types/index.mjs +11 -0
- package/dist/lib/neutral/types/index.mjs.map +7 -0
- package/dist/types/src/AttentionPlugin.d.ts +3 -1
- package/dist/types/src/AttentionPlugin.d.ts.map +1 -1
- package/dist/types/src/AttentionPlugin.test.d.ts +2 -0
- package/dist/types/src/AttentionPlugin.test.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +6 -5
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/keyboard.d.ts +3 -2
- package/dist/types/src/capabilities/keyboard.d.ts.map +1 -1
- package/dist/types/src/capabilities/operation-handler.d.ts +6 -0
- package/dist/types/src/capabilities/operation-handler.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-context.d.ts +4 -2
- package/dist/types/src/capabilities/react-context.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -4
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +2 -2
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/operations/index.d.ts +3 -0
- package/dist/types/src/operations/index.d.ts.map +1 -0
- package/dist/types/src/operations/select.d.ts +5 -0
- package/dist/types/src/operations/select.d.ts.map +1 -0
- package/dist/types/src/plugin.d.ts +4 -0
- package/dist/types/src/plugin.d.ts.map +1 -0
- package/dist/types/src/testing.d.ts +2 -0
- package/dist/types/src/testing.d.ts.map +1 -0
- package/dist/types/src/types/capabilities.d.ts +7 -0
- package/dist/types/src/types/capabilities.d.ts.map +1 -0
- package/dist/types/src/types/events.d.ts +5 -0
- package/dist/types/src/types/events.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +2 -0
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/src/types/types.d.ts +2 -2
- package/dist/types/src/types/types.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +58 -31
- package/src/AttentionPlugin.test.ts +32 -0
- package/src/AttentionPlugin.ts +38 -35
- package/src/capabilities/index.ts +8 -6
- package/src/capabilities/keyboard.ts +15 -16
- package/src/capabilities/operation-handler.ts +16 -0
- package/src/capabilities/react-context.tsx +29 -26
- package/src/index.ts +1 -5
- package/src/meta.ts +5 -3
- package/src/operations/index.ts +7 -0
- package/src/operations/select.ts +43 -0
- package/src/plugin.ts +11 -0
- package/src/testing.ts +7 -0
- package/src/types/capabilities.ts +13 -0
- package/src/types/events.ts +11 -0
- package/src/types/index.ts +2 -0
- package/src/types/types.ts +3 -3
- package/dist/lib/browser/chunk-62F4J5KY.mjs.map +0 -7
- package/dist/lib/browser/chunk-NG4RYQK5.mjs +0 -25
- package/dist/lib/browser/chunk-NG4RYQK5.mjs.map +0 -7
- package/dist/lib/browser/chunk-NIBJFU73.mjs +0 -16
- package/dist/lib/browser/chunk-NIBJFU73.mjs.map +0 -7
- package/dist/lib/browser/index.mjs +0 -87
- package/dist/lib/browser/index.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-OE6EFE7U.mjs +0 -51
- package/dist/lib/browser/intent-resolver-OE6EFE7U.mjs.map +0 -7
- package/dist/lib/browser/keyboard-QDSNLHR3.mjs +0 -28
- package/dist/lib/browser/keyboard-QDSNLHR3.mjs.map +0 -7
- package/dist/lib/browser/meta.json +0 -1
- package/dist/lib/browser/react-context-HXORYGNN.mjs.map +0 -7
- package/dist/lib/browser/types/index.mjs +0 -8
- package/dist/lib/node-esm/chunk-BH4E4TWY.mjs +0 -17
- package/dist/lib/node-esm/chunk-BH4E4TWY.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-JJFC7PBD.mjs +0 -26
- package/dist/lib/node-esm/chunk-JJFC7PBD.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-T6SUMOZA.mjs +0 -17
- package/dist/lib/node-esm/chunk-T6SUMOZA.mjs.map +0 -7
- package/dist/lib/node-esm/index.mjs +0 -88
- package/dist/lib/node-esm/index.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-QAU7TPNB.mjs +0 -52
- package/dist/lib/node-esm/intent-resolver-QAU7TPNB.mjs.map +0 -7
- package/dist/lib/node-esm/keyboard-GWCD2NVU.mjs +0 -29
- package/dist/lib/node-esm/keyboard-GWCD2NVU.mjs.map +0 -7
- package/dist/lib/node-esm/meta.json +0 -1
- package/dist/lib/node-esm/react-context-D5BP2M6I.mjs +0 -31
- package/dist/lib/node-esm/react-context-D5BP2M6I.mjs.map +0 -7
- package/dist/lib/node-esm/types/index.mjs +0 -9
- package/dist/types/src/capabilities/capabilities.d.ts +0 -6
- package/dist/types/src/capabilities/capabilities.d.ts.map +0 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
- package/dist/types/src/events.d.ts +0 -4
- package/dist/types/src/events.d.ts.map +0 -1
- package/src/capabilities/capabilities.ts +0 -13
- package/src/capabilities/intent-resolver.ts +0 -43
- package/src/events.ts +0 -11
- /package/dist/lib/{browser/types/index.mjs.map → neutral/AttentionPlugin.mjs.map} +0 -0
- /package/dist/lib/{node-esm/types → neutral}/index.mjs.map +0 -0
package/package.json
CHANGED
|
@@ -1,59 +1,86 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/plugin-attention",
|
|
3
|
-
"version": "0.8.4-main.
|
|
3
|
+
"version": "0.8.4-main.effb148878",
|
|
4
4
|
"description": "Plugin for attention",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
7
|
-
"
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/dxos/dxos"
|
|
10
|
+
},
|
|
11
|
+
"license": "FSL-1.1-Apache-2.0",
|
|
8
12
|
"author": "DXOS.org",
|
|
9
13
|
"sideEffects": true,
|
|
10
14
|
"type": "module",
|
|
15
|
+
"imports": {
|
|
16
|
+
"#capabilities": {
|
|
17
|
+
"source": "./src/capabilities/index.ts",
|
|
18
|
+
"types": "./dist/types/src/capabilities/index.d.ts",
|
|
19
|
+
"default": "./dist/lib/neutral/capabilities/index.mjs"
|
|
20
|
+
},
|
|
21
|
+
"#meta": {
|
|
22
|
+
"source": "./src/meta.ts",
|
|
23
|
+
"types": "./dist/types/src/meta.d.ts",
|
|
24
|
+
"default": "./dist/lib/neutral/meta.mjs"
|
|
25
|
+
},
|
|
26
|
+
"#operations": {
|
|
27
|
+
"source": "./src/operations/index.ts",
|
|
28
|
+
"types": "./dist/types/src/operations/index.d.ts",
|
|
29
|
+
"default": "./dist/lib/neutral/operations/index.mjs"
|
|
30
|
+
},
|
|
31
|
+
"#plugin": {
|
|
32
|
+
"source": "./src/AttentionPlugin.ts",
|
|
33
|
+
"types": "./dist/types/src/AttentionPlugin.d.ts",
|
|
34
|
+
"default": "./dist/lib/neutral/AttentionPlugin.mjs"
|
|
35
|
+
},
|
|
36
|
+
"#types": {
|
|
37
|
+
"source": "./src/types/index.ts",
|
|
38
|
+
"types": "./dist/types/src/types/index.d.ts",
|
|
39
|
+
"default": "./dist/lib/neutral/types/index.mjs"
|
|
40
|
+
}
|
|
41
|
+
},
|
|
11
42
|
"exports": {
|
|
12
43
|
".": {
|
|
13
44
|
"source": "./src/index.ts",
|
|
14
45
|
"types": "./dist/types/src/index.d.ts",
|
|
15
|
-
"
|
|
16
|
-
"node": "./dist/lib/node-esm/index.mjs"
|
|
46
|
+
"default": "./dist/lib/neutral/index.mjs"
|
|
17
47
|
},
|
|
18
|
-
"./
|
|
19
|
-
"source": "./src/
|
|
20
|
-
"types": "./dist/types/src/
|
|
21
|
-
"
|
|
22
|
-
|
|
48
|
+
"./plugin": {
|
|
49
|
+
"source": "./src/plugin.ts",
|
|
50
|
+
"types": "./dist/types/src/plugin.d.ts",
|
|
51
|
+
"default": "./dist/lib/neutral/plugin.mjs"
|
|
52
|
+
},
|
|
53
|
+
"./testing": {
|
|
54
|
+
"source": "./src/testing.ts",
|
|
55
|
+
"types": "./dist/types/src/testing.d.ts",
|
|
56
|
+
"default": "./dist/lib/neutral/testing.mjs"
|
|
23
57
|
}
|
|
24
58
|
},
|
|
25
59
|
"types": "dist/types/src/index.d.ts",
|
|
26
|
-
"typesVersions": {
|
|
27
|
-
"*": {
|
|
28
|
-
"types": [
|
|
29
|
-
"dist/types/src/types/index.d.ts"
|
|
30
|
-
]
|
|
31
|
-
}
|
|
32
|
-
},
|
|
33
60
|
"files": [
|
|
34
61
|
"dist",
|
|
35
62
|
"src"
|
|
36
63
|
],
|
|
37
64
|
"dependencies": {
|
|
38
|
-
"
|
|
39
|
-
"@
|
|
40
|
-
"
|
|
41
|
-
"@dxos/
|
|
42
|
-
"@dxos/echo": "0.8.4-main.
|
|
43
|
-
"@dxos/
|
|
44
|
-
"@dxos/util": "0.8.4-main.
|
|
45
|
-
"@dxos/
|
|
46
|
-
"@dxos/react-ui-attention": "0.8.4-main.
|
|
65
|
+
"effect": "3.20.0",
|
|
66
|
+
"@dxos/app-framework": "0.8.4-main.effb148878",
|
|
67
|
+
"@dxos/app-toolkit": "0.8.4-main.effb148878",
|
|
68
|
+
"@dxos/keyboard": "0.8.4-main.effb148878",
|
|
69
|
+
"@dxos/echo": "0.8.4-main.effb148878",
|
|
70
|
+
"@dxos/plugin-graph": "0.8.4-main.effb148878",
|
|
71
|
+
"@dxos/util": "0.8.4-main.effb148878",
|
|
72
|
+
"@dxos/compute": "0.8.4-main.effb148878",
|
|
73
|
+
"@dxos/react-ui-attention": "0.8.4-main.effb148878"
|
|
47
74
|
},
|
|
48
75
|
"devDependencies": {
|
|
49
|
-
"@types/react": "~19.2.
|
|
50
|
-
"react": "~19.2.
|
|
51
|
-
"react-dom": "~19.2.
|
|
76
|
+
"@types/react": "~19.2.7",
|
|
77
|
+
"react": "~19.2.3",
|
|
78
|
+
"react-dom": "~19.2.3"
|
|
52
79
|
},
|
|
53
80
|
"peerDependencies": {
|
|
54
|
-
"effect": "
|
|
55
|
-
"react": "
|
|
56
|
-
"react-dom": "
|
|
81
|
+
"effect": "3.20.0",
|
|
82
|
+
"react": "~19.2.3",
|
|
83
|
+
"react-dom": "~19.2.3"
|
|
57
84
|
},
|
|
58
85
|
"publishConfig": {
|
|
59
86
|
"access": "public"
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2026 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { describe, test } from 'vitest';
|
|
6
|
+
|
|
7
|
+
import { ActivationEvents, ProcessManagerPlugin } from '@dxos/app-framework';
|
|
8
|
+
import { createTestApp } from '@dxos/app-framework/testing';
|
|
9
|
+
import { GraphPlugin } from '@dxos/plugin-graph/plugin';
|
|
10
|
+
|
|
11
|
+
import { AttentionPlugin } from '#plugin';
|
|
12
|
+
|
|
13
|
+
import { meta } from './meta';
|
|
14
|
+
|
|
15
|
+
const moduleId = (name: string) => `${meta.id}.module.${name}`;
|
|
16
|
+
|
|
17
|
+
describe('AttentionPlugin', () => {
|
|
18
|
+
test('modules activate on the expected events', async ({ expect }) => {
|
|
19
|
+
await using harness = await createTestApp({
|
|
20
|
+
plugins: [GraphPlugin(), ProcessManagerPlugin(), AttentionPlugin()],
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
// Modules expected to be active after a normal startup.
|
|
24
|
+
expect(harness.manager.getActive()).toEqual(
|
|
25
|
+
expect.arrayContaining([moduleId('attention'), moduleId('ReactContext'), moduleId('Keyboard')]),
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
// OperationHandler fires lazily when an operation is invoked.
|
|
29
|
+
await harness.fire(ActivationEvents.SetupProcessManager);
|
|
30
|
+
expect(harness.manager.getActive()).toContain(moduleId('OperationHandler'));
|
|
31
|
+
});
|
|
32
|
+
});
|
package/src/AttentionPlugin.ts
CHANGED
|
@@ -2,44 +2,45 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
6
|
+
|
|
7
|
+
import { ActivationEvent, ActivationEvents, Capabilities, Capability, Plugin } from '@dxos/app-framework';
|
|
8
|
+
import { AppActivationEvents, AppPlugin } from '@dxos/app-toolkit';
|
|
6
9
|
import { AttentionManager, SelectionManager } from '@dxos/react-ui-attention';
|
|
7
10
|
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
+
import { Keyboard, OperationHandler, ReactContext } from '#capabilities';
|
|
12
|
+
import { meta } from '#meta';
|
|
13
|
+
import { AttentionEvents } from '#types';
|
|
14
|
+
import { AttentionCapabilities } from '#types';
|
|
11
15
|
|
|
12
|
-
export const AttentionPlugin =
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
16
|
+
export const AttentionPlugin = Plugin.define(meta).pipe(
|
|
17
|
+
AppPlugin.addOperationHandlerModule({ activate: OperationHandler }),
|
|
18
|
+
Plugin.addModule({
|
|
19
|
+
id: 'attention',
|
|
20
|
+
activatesOn: ActivationEvents.Startup,
|
|
21
|
+
firesAfterActivation: [AttentionEvents.AttentionReady],
|
|
22
|
+
activate: () =>
|
|
23
|
+
Effect.gen(function* () {
|
|
24
|
+
const registry = yield* Capability.get(Capabilities.AtomRegistry);
|
|
25
|
+
const attention = new AttentionManager(registry);
|
|
26
|
+
const selection = new SelectionManager(registry);
|
|
27
|
+
setupDevtools(attention);
|
|
28
|
+
return [
|
|
29
|
+
Capability.contributes(AttentionCapabilities.Attention, attention),
|
|
30
|
+
Capability.contributes(AttentionCapabilities.Selection, selection),
|
|
31
|
+
];
|
|
32
|
+
}),
|
|
26
33
|
}),
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
activatesOn: Events.Startup,
|
|
34
|
+
Plugin.addModule({
|
|
35
|
+
activatesOn: ActivationEvents.Startup,
|
|
30
36
|
activate: ReactContext,
|
|
31
37
|
}),
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
activatesOn: allOf(Events.AppGraphReady, AttentionEvents.AttentionReady),
|
|
38
|
+
Plugin.addModule({
|
|
39
|
+
activatesOn: ActivationEvent.allOf(AppActivationEvents.AppGraphReady, AttentionEvents.AttentionReady),
|
|
35
40
|
activate: Keyboard,
|
|
36
41
|
}),
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
activatesOn: Events.SetupIntentResolver,
|
|
40
|
-
activate: IntentResolver,
|
|
41
|
-
}),
|
|
42
|
-
]);
|
|
42
|
+
Plugin.make,
|
|
43
|
+
);
|
|
43
44
|
|
|
44
45
|
const setupDevtools = (attention: AttentionManager) => {
|
|
45
46
|
(globalThis as any).composer ??= {};
|
|
@@ -49,15 +50,17 @@ const setupDevtools = (attention: AttentionManager) => {
|
|
|
49
50
|
return attention;
|
|
50
51
|
},
|
|
51
52
|
get attended() {
|
|
52
|
-
return attention.
|
|
53
|
+
return attention.getCurrent();
|
|
53
54
|
},
|
|
54
55
|
get currentSpace() {
|
|
55
|
-
for (const id of attention.
|
|
56
|
-
const
|
|
57
|
-
if (
|
|
58
|
-
return
|
|
56
|
+
for (const id of attention.getCurrent()) {
|
|
57
|
+
const segments = id.split('/');
|
|
58
|
+
if (segments.length > 1 && segments[1].length === 33) {
|
|
59
|
+
return segments[1];
|
|
59
60
|
}
|
|
60
61
|
}
|
|
61
62
|
},
|
|
62
63
|
};
|
|
63
64
|
};
|
|
65
|
+
|
|
66
|
+
export default AttentionPlugin;
|
|
@@ -2,10 +2,12 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { Capability } from '@dxos/app-framework';
|
|
6
|
+
import { OperationHandlerSet } from '@dxos/compute';
|
|
6
7
|
|
|
7
|
-
export const
|
|
8
|
-
export const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
export const Keyboard = Capability.lazy('Keyboard', () => import('./keyboard'));
|
|
9
|
+
export const OperationHandler = Capability.lazy<OperationHandlerSet.OperationHandlerSet>(
|
|
10
|
+
'OperationHandler',
|
|
11
|
+
() => import('./operation-handler'),
|
|
12
|
+
);
|
|
13
|
+
export const ReactContext = Capability.lazy('ReactContext', () => import('./react-context'));
|
|
@@ -2,25 +2,24 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
6
|
-
import * as Option from 'effect/Option';
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
7
6
|
|
|
8
|
-
import { Capabilities
|
|
7
|
+
import { Capabilities, Capability } from '@dxos/app-framework';
|
|
9
8
|
import { Keyboard } from '@dxos/keyboard';
|
|
10
9
|
|
|
11
|
-
import { AttentionCapabilities } from '
|
|
10
|
+
import { AttentionCapabilities } from '#types';
|
|
12
11
|
|
|
13
|
-
export default (
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
export default Capability.makeModule(
|
|
13
|
+
Effect.fnUntraced(function* () {
|
|
14
|
+
const attention = yield* Capability.get(AttentionCapabilities.Attention);
|
|
16
15
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
});
|
|
16
|
+
const unsubscribe = attention.subscribeCurrent((current) => {
|
|
17
|
+
const id = current[0];
|
|
18
|
+
if (id) {
|
|
19
|
+
Keyboard.singleton.setCurrentContext(id);
|
|
20
|
+
}
|
|
21
|
+
});
|
|
24
22
|
|
|
25
|
-
|
|
26
|
-
}
|
|
23
|
+
return Capability.contributes(Capabilities.Null, null, () => Effect.sync(() => unsubscribe()));
|
|
24
|
+
}),
|
|
25
|
+
);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
6
|
+
|
|
7
|
+
import { Capabilities, Capability } from '@dxos/app-framework';
|
|
8
|
+
import type { OperationHandlerSet } from '@dxos/compute';
|
|
9
|
+
|
|
10
|
+
import { AttentionOperationHandlerSet } from '#operations';
|
|
11
|
+
|
|
12
|
+
export default Capability.makeModule<OperationHandlerSet.OperationHandlerSet>(
|
|
13
|
+
Effect.fnUntraced(function* () {
|
|
14
|
+
return Capability.contributes(Capabilities.OperationHandler, AttentionOperationHandlerSet);
|
|
15
|
+
}),
|
|
16
|
+
);
|
|
@@ -2,35 +2,38 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
5
6
|
import React, { type PropsWithChildren } from 'react';
|
|
6
7
|
|
|
7
|
-
import { Capabilities,
|
|
8
|
-
import { useCapability } from '@dxos/app-framework/
|
|
8
|
+
import { Capabilities, Capability } from '@dxos/app-framework';
|
|
9
|
+
import { useCapability } from '@dxos/app-framework/ui';
|
|
9
10
|
import { RootAttentionProvider, SelectionProvider } from '@dxos/react-ui-attention';
|
|
10
11
|
|
|
11
|
-
import { meta } from '
|
|
12
|
+
import { meta } from '#meta';
|
|
13
|
+
import { AttentionCapabilities } from '#types';
|
|
12
14
|
|
|
13
|
-
|
|
15
|
+
export default Capability.makeModule(() =>
|
|
16
|
+
Effect.succeed(
|
|
17
|
+
Capability.contributes(Capabilities.ReactContext, {
|
|
18
|
+
id: meta.id,
|
|
19
|
+
context: (props: PropsWithChildren) => {
|
|
20
|
+
const attention = useCapability(AttentionCapabilities.Attention);
|
|
21
|
+
const selection = useCapability(AttentionCapabilities.Selection);
|
|
14
22
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
<SelectionProvider selection={selection}>{props.children}</SelectionProvider>
|
|
33
|
-
</RootAttentionProvider>
|
|
34
|
-
);
|
|
35
|
-
},
|
|
36
|
-
});
|
|
23
|
+
return (
|
|
24
|
+
<RootAttentionProvider
|
|
25
|
+
attention={attention}
|
|
26
|
+
onChange={(nextAttended) => {
|
|
27
|
+
// TODO(Zan): Workout why this was in deck plugin. It didn't seem to work?
|
|
28
|
+
// if (layout.values.scrollIntoView && nextAttended.has(layout.values.scrollIntoView)) {
|
|
29
|
+
// layout.values.scrollIntoView = undefined;
|
|
30
|
+
// }
|
|
31
|
+
}}
|
|
32
|
+
>
|
|
33
|
+
<SelectionProvider selection={selection}>{props.children}</SelectionProvider>
|
|
34
|
+
</RootAttentionProvider>
|
|
35
|
+
);
|
|
36
|
+
},
|
|
37
|
+
}),
|
|
38
|
+
),
|
|
39
|
+
);
|
package/src/index.ts
CHANGED
package/src/meta.ts
CHANGED
|
@@ -2,14 +2,16 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { type
|
|
5
|
+
import { type Plugin } from '@dxos/app-framework';
|
|
6
6
|
import { trim } from '@dxos/util';
|
|
7
7
|
|
|
8
|
-
export const meta:
|
|
9
|
-
id: 'dxos.
|
|
8
|
+
export const meta: Plugin.Meta = {
|
|
9
|
+
id: 'org.dxos.plugin.attention',
|
|
10
10
|
name: 'Attention',
|
|
11
|
+
author: 'DXOS',
|
|
11
12
|
description: trim`
|
|
12
13
|
Track and manage focused attention on objects across your workspace.
|
|
13
14
|
Highlight items requiring action and coordinate team focus on priority work.
|
|
14
15
|
`,
|
|
16
|
+
tags: ['system'],
|
|
15
17
|
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
6
|
+
import * as Match from 'effect/Match';
|
|
7
|
+
|
|
8
|
+
import { Capability } from '@dxos/app-framework';
|
|
9
|
+
import { LayoutOperation } from '@dxos/app-toolkit';
|
|
10
|
+
import { Operation } from '@dxos/compute';
|
|
11
|
+
|
|
12
|
+
import { AttentionCapabilities } from '../types';
|
|
13
|
+
|
|
14
|
+
const handler: Operation.WithHandler<typeof LayoutOperation.Select> = LayoutOperation.Select.pipe(
|
|
15
|
+
Operation.withHandler(
|
|
16
|
+
Effect.fnUntraced(function* (input) {
|
|
17
|
+
const selection = yield* Capability.get(AttentionCapabilities.Selection);
|
|
18
|
+
Match.value(input.subject).pipe(
|
|
19
|
+
Match.when({ mode: 'single', id: undefined }, () => {
|
|
20
|
+
selection.clearSelection(input.contextId);
|
|
21
|
+
}),
|
|
22
|
+
Match.when({ mode: 'single' }, (s) => {
|
|
23
|
+
selection.updateSingle(input.contextId, s.id!);
|
|
24
|
+
}),
|
|
25
|
+
Match.when({ mode: 'multi' }, (s) => {
|
|
26
|
+
selection.updateMulti(input.contextId, s.ids);
|
|
27
|
+
}),
|
|
28
|
+
Match.when({ mode: 'range', from: undefined, to: undefined }, () => {
|
|
29
|
+
selection.clearSelection(input.contextId);
|
|
30
|
+
}),
|
|
31
|
+
Match.when({ mode: 'range' }, (s) => {
|
|
32
|
+
selection.updateRange(input.contextId, s.from!, s.to!);
|
|
33
|
+
}),
|
|
34
|
+
Match.when({ mode: 'multi-range' }, (s) => {
|
|
35
|
+
selection.updateMultiRange(input.contextId, s.ranges);
|
|
36
|
+
}),
|
|
37
|
+
Match.exhaustive,
|
|
38
|
+
);
|
|
39
|
+
}),
|
|
40
|
+
),
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
export default handler;
|
package/src/plugin.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { Plugin } from '@dxos/app-framework';
|
|
6
|
+
|
|
7
|
+
import { meta } from './meta';
|
|
8
|
+
|
|
9
|
+
export const AttentionPlugin = Plugin.lazy(meta, () => import('#plugin'));
|
|
10
|
+
|
|
11
|
+
export { AttentionOperationHandlerSet } from './operations';
|
package/src/testing.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { Capability } from '@dxos/app-framework';
|
|
6
|
+
import { type AttentionManager, type SelectionManager } from '@dxos/react-ui-attention';
|
|
7
|
+
|
|
8
|
+
import { meta } from '#meta';
|
|
9
|
+
|
|
10
|
+
export namespace AttentionCapabilities {
|
|
11
|
+
export const Attention = Capability.make<AttentionManager>(`${meta.id}.capability.attention`);
|
|
12
|
+
export const Selection = Capability.make<SelectionManager>(`${meta.id}.capability.selection`);
|
|
13
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { ActivationEvent } from '@dxos/app-framework';
|
|
6
|
+
|
|
7
|
+
import { meta } from '#meta';
|
|
8
|
+
|
|
9
|
+
export namespace AttentionEvents {
|
|
10
|
+
export const AttentionReady = ActivationEvent.make(`${meta.id}.event.attention-ready`);
|
|
11
|
+
}
|
package/src/types/index.ts
CHANGED
package/src/types/types.ts
CHANGED
|
@@ -6,12 +6,12 @@ import * as Schema from 'effect/Schema';
|
|
|
6
6
|
|
|
7
7
|
import { SelectionSchema } from '@dxos/react-ui-attention';
|
|
8
8
|
|
|
9
|
-
import { meta } from '
|
|
9
|
+
import { meta } from '#meta';
|
|
10
10
|
|
|
11
11
|
export namespace AttentionAction {
|
|
12
|
-
const ATTENTION_ACTION = `${meta.id}
|
|
12
|
+
const ATTENTION_ACTION = `${meta.id}.action`;
|
|
13
13
|
|
|
14
|
-
export class Select extends Schema.TaggedClass<Select>()(`${ATTENTION_ACTION}
|
|
14
|
+
export class Select extends Schema.TaggedClass<Select>()(`${ATTENTION_ACTION}.select`, {
|
|
15
15
|
input: Schema.Struct({
|
|
16
16
|
contextId: Schema.String,
|
|
17
17
|
selection: SelectionSchema,
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/meta.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport { type PluginMeta } from '@dxos/app-framework';\nimport { trim } from '@dxos/util';\n\nexport const meta: PluginMeta = {\n id: 'dxos.org/plugin/attention',\n name: 'Attention',\n description: trim`\n Track and manage focused attention on objects across your workspace.\n Highlight items requiring action and coordinate team focus on priority work.\n `,\n};\n"],
|
|
5
|
-
"mappings": ";AAKA,SAASA,YAAY;AAEd,IAAMC,OAAmB;EAC9BC,IAAI;EACJC,MAAM;EACNC,aAAaC;;;;AAIf;",
|
|
6
|
-
"names": ["trim", "meta", "id", "name", "description", "trim"]
|
|
7
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
meta
|
|
3
|
-
} from "./chunk-62F4J5KY.mjs";
|
|
4
|
-
|
|
5
|
-
// src/types/types.ts
|
|
6
|
-
import * as Schema from "effect/Schema";
|
|
7
|
-
import { SelectionSchema } from "@dxos/react-ui-attention";
|
|
8
|
-
(function(AttentionAction2) {
|
|
9
|
-
const ATTENTION_ACTION = `${meta.id}/action`;
|
|
10
|
-
class Select extends Schema.TaggedClass()(`${ATTENTION_ACTION}/select`, {
|
|
11
|
-
input: Schema.Struct({
|
|
12
|
-
contextId: Schema.String,
|
|
13
|
-
selection: SelectionSchema
|
|
14
|
-
}),
|
|
15
|
-
output: Schema.Void
|
|
16
|
-
}) {
|
|
17
|
-
}
|
|
18
|
-
AttentionAction2.Select = Select;
|
|
19
|
-
})(AttentionAction || (AttentionAction = {}));
|
|
20
|
-
var AttentionAction;
|
|
21
|
-
|
|
22
|
-
export {
|
|
23
|
-
AttentionAction
|
|
24
|
-
};
|
|
25
|
-
//# sourceMappingURL=chunk-NG4RYQK5.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/types/types.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\n\nimport { SelectionSchema } from '@dxos/react-ui-attention';\n\nimport { meta } from '../meta';\n\nexport namespace AttentionAction {\n const ATTENTION_ACTION = `${meta.id}/action`;\n\n export class Select extends Schema.TaggedClass<Select>()(`${ATTENTION_ACTION}/select`, {\n input: Schema.Struct({\n contextId: Schema.String,\n selection: SelectionSchema,\n }),\n output: Schema.Void,\n }) {}\n}\n"],
|
|
5
|
-
"mappings": ";;;;;AAIA,YAAYA,YAAY;AAExB,SAASC,uBAAuB;UAIfC,kBAAAA;AACf,QAAMC,mBAAmB,GAAGC,KAAKC,EAAE;EAE5B,MAAMC,eAAsBC,mBAAW,EAAW,GAAGJ,gBAAAA,WAA2B;IACrFK,OAAcC,cAAO;MACnBC,WAAkBC;MAClBC,WAAWC;IACb,CAAA;IACAC,QAAeC;EACjB,CAAA,EAAA;EAAI;mBANST,SAAAA;AAOf,GAViBJ,oBAAAA,kBAAAA,CAAAA,EAAAA;;",
|
|
6
|
-
"names": ["Schema", "SelectionSchema", "AttentionAction", "ATTENTION_ACTION", "meta", "id", "Select", "TaggedClass", "input", "Struct", "contextId", "String", "selection", "SelectionSchema", "output", "Void"]
|
|
7
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
meta
|
|
3
|
-
} from "./chunk-62F4J5KY.mjs";
|
|
4
|
-
|
|
5
|
-
// src/capabilities/capabilities.ts
|
|
6
|
-
import { defineCapability } from "@dxos/app-framework";
|
|
7
|
-
(function(AttentionCapabilities2) {
|
|
8
|
-
AttentionCapabilities2.Attention = defineCapability(`${meta.id}/capability/attention`);
|
|
9
|
-
AttentionCapabilities2.Selection = defineCapability(`${meta.id}/capability/selection`);
|
|
10
|
-
})(AttentionCapabilities || (AttentionCapabilities = {}));
|
|
11
|
-
var AttentionCapabilities;
|
|
12
|
-
|
|
13
|
-
export {
|
|
14
|
-
AttentionCapabilities
|
|
15
|
-
};
|
|
16
|
-
//# sourceMappingURL=chunk-NIBJFU73.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/capabilities/capabilities.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { defineCapability } from '@dxos/app-framework';\nimport { type AttentionManager, type SelectionManager } from '@dxos/react-ui-attention';\n\nimport { meta } from '../meta';\n\nexport namespace AttentionCapabilities {\n export const Attention = defineCapability<AttentionManager>(`${meta.id}/capability/attention`);\n export const Selection = defineCapability<SelectionManager>(`${meta.id}/capability/selection`);\n}\n"],
|
|
5
|
-
"mappings": ";;;;;AAIA,SAASA,wBAAwB;UAKhBC,wBAAAA;yBACFC,YAAYC,iBAAmC,GAAGC,KAAKC,EAAE,uBAAuB;yBAChFC,YAAYH,iBAAmC,GAAGC,KAAKC,EAAE,uBAAuB;AAC/F,GAHiBJ,0BAAAA,wBAAAA,CAAAA,EAAAA;;",
|
|
6
|
-
"names": ["defineCapability", "AttentionCapabilities", "Attention", "defineCapability", "meta", "id", "Selection"]
|
|
7
|
-
}
|