@dxos/plugin-attention 0.7.5-main.9cb18ac → 0.7.5-main.9d2a38b

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/dist/lib/browser/chunk-TBISRVXA.mjs +20 -0
  2. package/dist/lib/browser/chunk-TBISRVXA.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +50 -45
  4. package/dist/lib/browser/index.mjs.map +4 -4
  5. package/dist/lib/browser/keyboard-QID5LXKS.mjs +26 -0
  6. package/dist/lib/browser/keyboard-QID5LXKS.mjs.map +7 -0
  7. package/dist/lib/browser/meta.json +1 -1
  8. package/dist/lib/browser/react-context-YJB443IX.mjs +24 -0
  9. package/dist/lib/browser/react-context-YJB443IX.mjs.map +7 -0
  10. package/dist/lib/node/{chunk-VEMWITWY.cjs → chunk-5B4YWZQ5.cjs} +14 -7
  11. package/dist/lib/node/chunk-5B4YWZQ5.cjs.map +7 -0
  12. package/dist/lib/node/index.cjs +42 -40
  13. package/dist/lib/node/index.cjs.map +4 -4
  14. package/dist/lib/node/keyboard-ZALVEHH3.cjs +42 -0
  15. package/dist/lib/node/keyboard-ZALVEHH3.cjs.map +7 -0
  16. package/dist/lib/node/meta.json +1 -1
  17. package/dist/lib/node/react-context-JOSQYVWS.cjs +49 -0
  18. package/dist/lib/node/react-context-JOSQYVWS.cjs.map +7 -0
  19. package/dist/lib/node-esm/chunk-EMYCEZDW.mjs +22 -0
  20. package/dist/lib/node-esm/chunk-EMYCEZDW.mjs.map +7 -0
  21. package/dist/lib/node-esm/index.mjs +50 -45
  22. package/dist/lib/node-esm/index.mjs.map +4 -4
  23. package/dist/lib/node-esm/keyboard-SZNNVXFG.mjs +27 -0
  24. package/dist/lib/node-esm/keyboard-SZNNVXFG.mjs.map +7 -0
  25. package/dist/lib/node-esm/meta.json +1 -1
  26. package/dist/lib/node-esm/react-context-6RDXU5HM.mjs +25 -0
  27. package/dist/lib/node-esm/react-context-6RDXU5HM.mjs.map +7 -0
  28. package/dist/types/src/AttentionPlugin.d.ts +1 -12
  29. package/dist/types/src/AttentionPlugin.d.ts.map +1 -1
  30. package/dist/types/src/capabilities/capabilities.d.ts +5 -0
  31. package/dist/types/src/capabilities/capabilities.d.ts.map +1 -0
  32. package/dist/types/src/capabilities/index.d.ts +8 -0
  33. package/dist/types/src/capabilities/index.d.ts.map +1 -0
  34. package/dist/types/src/capabilities/keyboard.d.ts +4 -0
  35. package/dist/types/src/capabilities/keyboard.d.ts.map +1 -0
  36. package/dist/types/src/capabilities/react-context.d.ts +8 -0
  37. package/dist/types/src/capabilities/react-context.d.ts.map +1 -0
  38. package/dist/types/src/events.d.ts +4 -0
  39. package/dist/types/src/events.d.ts.map +1 -0
  40. package/dist/types/src/index.d.ts +4 -2
  41. package/dist/types/src/index.d.ts.map +1 -1
  42. package/dist/types/src/meta.d.ts +1 -2
  43. package/dist/types/src/meta.d.ts.map +1 -1
  44. package/dist/types/tsconfig.tsbuildinfo +1 -1
  45. package/package.json +7 -16
  46. package/src/AttentionPlugin.ts +52 -0
  47. package/src/capabilities/capabilities.ts +12 -0
  48. package/src/capabilities/index.ts +10 -0
  49. package/src/capabilities/keyboard.ts +25 -0
  50. package/src/capabilities/react-context.tsx +33 -0
  51. package/src/events.ts +11 -0
  52. package/src/index.ts +4 -3
  53. package/src/meta.ts +1 -1
  54. package/dist/lib/browser/chunk-56S77L6M.mjs +0 -12
  55. package/dist/lib/browser/chunk-56S77L6M.mjs.map +0 -7
  56. package/dist/lib/browser/meta.mjs +0 -9
  57. package/dist/lib/browser/meta.mjs.map +0 -7
  58. package/dist/lib/node/chunk-VEMWITWY.cjs.map +0 -7
  59. package/dist/lib/node/meta.cjs +0 -30
  60. package/dist/lib/node/meta.cjs.map +0 -7
  61. package/dist/lib/node-esm/chunk-NWBDAVCK.mjs +0 -14
  62. package/dist/lib/node-esm/chunk-NWBDAVCK.mjs.map +0 -7
  63. package/dist/lib/node-esm/meta.mjs +0 -10
  64. package/dist/lib/node-esm/meta.mjs.map +0 -7
  65. package/src/AttentionPlugin.tsx +0 -91
@@ -0,0 +1,25 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { effect } from '@preact/signals-core';
6
+
7
+ import { Capabilities as AppCapabilities, contributes, type PluginsContext } from '@dxos/app-framework';
8
+ import { Keyboard } from '@dxos/keyboard';
9
+
10
+ import { AttentionCapabilities } from './capabilities';
11
+
12
+ export default (context: PluginsContext) => {
13
+ const { graph } = context.requestCapability(AppCapabilities.AppGraph);
14
+ const attention = context.requestCapability(AttentionCapabilities.Attention);
15
+
16
+ const unsubscribe = effect(() => {
17
+ const id = Array.from(attention.current)[0];
18
+ const path = id && graph.getPath({ target: id });
19
+ if (path) {
20
+ Keyboard.singleton.setCurrentContext(path.join('/'));
21
+ }
22
+ });
23
+
24
+ return contributes(AppCapabilities.Null, null, () => unsubscribe());
25
+ };
@@ -0,0 +1,33 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import React, { type PropsWithChildren } from 'react';
6
+
7
+ import { Capabilities as AppCapabilities, contributes, useCapability } from '@dxos/app-framework';
8
+ import { RootAttentionProvider } from '@dxos/react-ui-attention';
9
+
10
+ import { AttentionCapabilities } from './capabilities';
11
+ import { ATTENTION_PLUGIN } from '../meta';
12
+
13
+ export default () =>
14
+ contributes(AppCapabilities.ReactContext, {
15
+ id: ATTENTION_PLUGIN,
16
+ context: (props: PropsWithChildren) => {
17
+ const attention = useCapability(AttentionCapabilities.Attention);
18
+
19
+ return (
20
+ <RootAttentionProvider
21
+ attention={attention}
22
+ onChange={(nextAttended) => {
23
+ // TODO(Zan): Workout why this was in deck plugin. It didn't seem to work?
24
+ // if (layout.values.scrollIntoView && nextAttended.has(layout.values.scrollIntoView)) {
25
+ // layout.values.scrollIntoView = undefined;
26
+ // }
27
+ }}
28
+ >
29
+ {props.children}
30
+ </RootAttentionProvider>
31
+ );
32
+ },
33
+ });
package/src/events.ts ADDED
@@ -0,0 +1,11 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { defineEvent } from '@dxos/app-framework';
6
+
7
+ import { ATTENTION_PLUGIN } from './meta';
8
+
9
+ export namespace AttentionEvents {
10
+ export const AttentionReady = defineEvent(`${ATTENTION_PLUGIN}/event/attention-ready`);
11
+ }
package/src/index.ts CHANGED
@@ -2,8 +2,9 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import { AttentionPlugin } from './AttentionPlugin';
6
-
7
- export default AttentionPlugin;
5
+ export * from '@dxos/react-ui-attention';
8
6
 
9
7
  export * from './AttentionPlugin';
8
+ export { AttentionCapabilities } from './capabilities';
9
+ export * from './events';
10
+ export * from './meta';
package/src/meta.ts CHANGED
@@ -6,7 +6,7 @@ import { type PluginMeta } from '@dxos/app-framework';
6
6
 
7
7
  export const ATTENTION_PLUGIN = 'dxos.org/plugin/attention';
8
8
 
9
- export default {
9
+ export const meta = {
10
10
  id: ATTENTION_PLUGIN,
11
11
  name: 'Attention',
12
12
  } satisfies PluginMeta;
@@ -1,12 +0,0 @@
1
- // packages/plugins/plugin-attention/src/meta.ts
2
- var ATTENTION_PLUGIN = "dxos.org/plugin/attention";
3
- var meta_default = {
4
- id: ATTENTION_PLUGIN,
5
- name: "Attention"
6
- };
7
-
8
- export {
9
- ATTENTION_PLUGIN,
10
- meta_default
11
- };
12
- //# sourceMappingURL=chunk-56S77L6M.mjs.map
@@ -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';\n\nexport const ATTENTION_PLUGIN = 'dxos.org/plugin/attention';\n\nexport default {\n id: ATTENTION_PLUGIN,\n name: 'Attention',\n} satisfies PluginMeta;\n"],
5
- "mappings": ";AAMO,IAAMA,mBAAmB;AAEhC,IAAA,eAAe;EACbC,IAAID;EACJE,MAAM;AACR;",
6
- "names": ["ATTENTION_PLUGIN", "id", "name"]
7
- }
@@ -1,9 +0,0 @@
1
- import {
2
- ATTENTION_PLUGIN,
3
- meta_default
4
- } from "./chunk-56S77L6M.mjs";
5
- export {
6
- ATTENTION_PLUGIN,
7
- meta_default as default
8
- };
9
- //# sourceMappingURL=meta.mjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": [],
4
- "sourcesContent": [],
5
- "mappings": "",
6
- "names": []
7
- }
@@ -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';\n\nexport const ATTENTION_PLUGIN = 'dxos.org/plugin/attention';\n\nexport default {\n id: ATTENTION_PLUGIN,\n name: 'Attention',\n} satisfies PluginMeta;\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAMO,IAAMA,mBAAmB;AAEhC,IAAA,eAAe;EACbC,IAAID;EACJE,MAAM;AACR;",
6
- "names": ["ATTENTION_PLUGIN", "id", "name"]
7
- }
@@ -1,30 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var meta_exports = {};
20
- __export(meta_exports, {
21
- ATTENTION_PLUGIN: () => import_chunk_VEMWITWY.ATTENTION_PLUGIN,
22
- default: () => import_chunk_VEMWITWY.meta_default
23
- });
24
- module.exports = __toCommonJS(meta_exports);
25
- var import_chunk_VEMWITWY = require("./chunk-VEMWITWY.cjs");
26
- // Annotate the CommonJS export names for ESM import in node:
27
- 0 && (module.exports = {
28
- ATTENTION_PLUGIN
29
- });
30
- //# sourceMappingURL=meta.cjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["meta.cjs"],
4
- "sourcesContent": ["import {\n ATTENTION_PLUGIN,\n meta_default\n} from \"./chunk-VEMWITWY.cjs\";\nexport {\n ATTENTION_PLUGIN,\n meta_default as default\n};\n//# sourceMappingURL=meta.cjs.map\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,4BAGO;",
6
- "names": []
7
- }
@@ -1,14 +0,0 @@
1
- import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
-
3
- // packages/plugins/plugin-attention/src/meta.ts
4
- var ATTENTION_PLUGIN = "dxos.org/plugin/attention";
5
- var meta_default = {
6
- id: ATTENTION_PLUGIN,
7
- name: "Attention"
8
- };
9
-
10
- export {
11
- ATTENTION_PLUGIN,
12
- meta_default
13
- };
14
- //# sourceMappingURL=chunk-NWBDAVCK.mjs.map
@@ -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';\n\nexport const ATTENTION_PLUGIN = 'dxos.org/plugin/attention';\n\nexport default {\n id: ATTENTION_PLUGIN,\n name: 'Attention',\n} satisfies PluginMeta;\n"],
5
- "mappings": ";;;AAMO,IAAMA,mBAAmB;AAEhC,IAAA,eAAe;EACbC,IAAID;EACJE,MAAM;AACR;",
6
- "names": ["ATTENTION_PLUGIN", "id", "name"]
7
- }
@@ -1,10 +0,0 @@
1
- import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
- import {
3
- ATTENTION_PLUGIN,
4
- meta_default
5
- } from "./chunk-NWBDAVCK.mjs";
6
- export {
7
- ATTENTION_PLUGIN,
8
- meta_default as default
9
- };
10
- //# sourceMappingURL=meta.mjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": [],
4
- "sourcesContent": [],
5
- "mappings": "",
6
- "names": []
7
- }
@@ -1,91 +0,0 @@
1
- //
2
- // Copyright 2024 DXOS.org
3
- //
4
-
5
- import { effect } from '@preact/signals-core';
6
- import React, { type PropsWithChildren } from 'react';
7
-
8
- import {
9
- type Plugin,
10
- type GraphProvides,
11
- resolvePlugin,
12
- parseGraphPlugin,
13
- type PluginDefinition,
14
- } from '@dxos/app-framework';
15
- import { Keyboard } from '@dxos/keyboard';
16
- import { type Attention, AttentionManager, RootAttentionProvider } from '@dxos/react-ui-attention';
17
-
18
- import meta from './meta';
19
-
20
- type AttentionProvides = {
21
- attention: {
22
- attended: Readonly<string[]>;
23
- getAttention: (path: string[]) => Attention;
24
- };
25
- };
26
-
27
- export type AttentionPluginProvides = AttentionProvides;
28
-
29
- export const parseAttentionPlugin = (plugin?: Plugin) =>
30
- typeof (plugin?.provides as any).attention === 'object' ? (plugin as Plugin<AttentionPluginProvides>) : undefined;
31
-
32
- export const AttentionPlugin = (): PluginDefinition<AttentionPluginProvides> => {
33
- const attention = new AttentionManager();
34
- let graphPlugin: Plugin<GraphProvides> | undefined;
35
-
36
- return {
37
- meta,
38
- ready: async ({ plugins }) => {
39
- graphPlugin = resolvePlugin(plugins, parseGraphPlugin);
40
-
41
- effect(() => {
42
- const id = Array.from(attention.current)[0];
43
- const path = id && graphPlugin?.provides.graph.getPath({ target: id });
44
- if (path) {
45
- Keyboard.singleton.setCurrentContext(path.join('/'));
46
- }
47
- });
48
-
49
- setupDevtools(attention);
50
- },
51
- provides: {
52
- attention: {
53
- get attended() {
54
- return attention.current;
55
- },
56
- getAttention: attention.get,
57
- },
58
- context: (props: PropsWithChildren) => (
59
- <RootAttentionProvider
60
- attention={attention}
61
- onChange={(nextAttended) => {
62
- // TODO(Zan): Workout why this was in deck plugin. It didn't seem to work?
63
- // if (layout.values.scrollIntoView && nextAttended.has(layout.values.scrollIntoView)) {
64
- // layout.values.scrollIntoView = undefined;
65
- // }
66
- }}
67
- >
68
- {props.children}
69
- </RootAttentionProvider>
70
- ),
71
- },
72
- };
73
- };
74
-
75
- const setupDevtools = (attention: AttentionManager) => {
76
- (globalThis as any).composer ??= {};
77
-
78
- (globalThis as any).composer.attention = {
79
- get attended() {
80
- return attention.current;
81
- },
82
- get currentSpace() {
83
- for (const id of attention.current) {
84
- const [spaceId, objectId] = id.split(':');
85
- if (spaceId && objectId && spaceId.length === 33) {
86
- return spaceId;
87
- }
88
- }
89
- },
90
- };
91
- };