@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.
- package/dist/lib/browser/chunk-TBISRVXA.mjs +20 -0
- package/dist/lib/browser/chunk-TBISRVXA.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +50 -45
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/keyboard-QID5LXKS.mjs +26 -0
- package/dist/lib/browser/keyboard-QID5LXKS.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/react-context-YJB443IX.mjs +24 -0
- package/dist/lib/browser/react-context-YJB443IX.mjs.map +7 -0
- package/dist/lib/node/{chunk-VEMWITWY.cjs → chunk-5B4YWZQ5.cjs} +14 -7
- package/dist/lib/node/chunk-5B4YWZQ5.cjs.map +7 -0
- package/dist/lib/node/index.cjs +42 -40
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/keyboard-ZALVEHH3.cjs +42 -0
- package/dist/lib/node/keyboard-ZALVEHH3.cjs.map +7 -0
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/react-context-JOSQYVWS.cjs +49 -0
- package/dist/lib/node/react-context-JOSQYVWS.cjs.map +7 -0
- package/dist/lib/node-esm/chunk-EMYCEZDW.mjs +22 -0
- package/dist/lib/node-esm/chunk-EMYCEZDW.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +50 -45
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/keyboard-SZNNVXFG.mjs +27 -0
- package/dist/lib/node-esm/keyboard-SZNNVXFG.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/react-context-6RDXU5HM.mjs +25 -0
- package/dist/lib/node-esm/react-context-6RDXU5HM.mjs.map +7 -0
- package/dist/types/src/AttentionPlugin.d.ts +1 -12
- package/dist/types/src/AttentionPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/capabilities.d.ts +5 -0
- package/dist/types/src/capabilities/capabilities.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +8 -0
- package/dist/types/src/capabilities/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/keyboard.d.ts +4 -0
- package/dist/types/src/capabilities/keyboard.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-context.d.ts +8 -0
- package/dist/types/src/capabilities/react-context.d.ts.map +1 -0
- package/dist/types/src/events.d.ts +4 -0
- package/dist/types/src/events.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +4 -2
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +1 -2
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +7 -16
- package/src/AttentionPlugin.ts +52 -0
- package/src/capabilities/capabilities.ts +12 -0
- package/src/capabilities/index.ts +10 -0
- package/src/capabilities/keyboard.ts +25 -0
- package/src/capabilities/react-context.tsx +33 -0
- package/src/events.ts +11 -0
- package/src/index.ts +4 -3
- package/src/meta.ts +1 -1
- package/dist/lib/browser/chunk-56S77L6M.mjs +0 -12
- package/dist/lib/browser/chunk-56S77L6M.mjs.map +0 -7
- package/dist/lib/browser/meta.mjs +0 -9
- package/dist/lib/browser/meta.mjs.map +0 -7
- package/dist/lib/node/chunk-VEMWITWY.cjs.map +0 -7
- package/dist/lib/node/meta.cjs +0 -30
- package/dist/lib/node/meta.cjs.map +0 -7
- package/dist/lib/node-esm/chunk-NWBDAVCK.mjs +0 -14
- package/dist/lib/node-esm/chunk-NWBDAVCK.mjs.map +0 -7
- package/dist/lib/node-esm/meta.mjs +0 -10
- package/dist/lib/node-esm/meta.mjs.map +0 -7
- 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
|
-
|
|
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
|
@@ -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,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
|
-
}
|
package/dist/lib/node/meta.cjs
DELETED
|
@@ -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
|
package/src/AttentionPlugin.tsx
DELETED
|
@@ -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
|
-
};
|