@dxos/plugin-attention 0.6.13 → 0.6.14-main.2b6a0f3
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-OH3BP6UG.mjs → chunk-56S77L6M.mjs} +1 -1
- package/dist/lib/browser/chunk-56S77L6M.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +15 -16
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/meta.mjs +1 -1
- package/dist/lib/node/{chunk-F2QM2H7J.cjs → chunk-VEMWITWY.cjs} +4 -4
- package/dist/lib/node/chunk-VEMWITWY.cjs.map +7 -0
- package/dist/lib/node/index.cjs +15 -16
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.cjs +3 -3
- package/dist/lib/node/meta.cjs.map +1 -1
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node-esm/chunk-NWBDAVCK.mjs +14 -0
- package/dist/lib/node-esm/chunk-NWBDAVCK.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +70 -0
- package/dist/lib/node-esm/index.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -0
- package/dist/lib/node-esm/meta.mjs +10 -0
- package/dist/lib/node-esm/meta.mjs.map +7 -0
- package/dist/types/src/AttentionPlugin.d.ts +6 -2
- package/dist/types/src/AttentionPlugin.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts.map +1 -1
- package/package.json +13 -10
- package/src/AttentionPlugin.tsx +20 -19
- package/src/meta.ts +3 -1
- package/dist/lib/browser/chunk-OH3BP6UG.mjs.map +0 -7
- package/dist/lib/node/chunk-F2QM2H7J.cjs.map +0 -7
|
@@ -0,0 +1,7 @@
|
|
|
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,26 +1,23 @@
|
|
|
1
1
|
import {
|
|
2
2
|
meta_default
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-56S77L6M.mjs";
|
|
4
4
|
|
|
5
5
|
// packages/plugins/plugin-attention/src/AttentionPlugin.tsx
|
|
6
6
|
import { effect } from "@preact/signals-core";
|
|
7
7
|
import React from "react";
|
|
8
8
|
import { resolvePlugin, parseGraphPlugin } from "@dxos/app-framework";
|
|
9
|
-
import { create } from "@dxos/echo-schema";
|
|
10
9
|
import { Keyboard } from "@dxos/keyboard";
|
|
11
|
-
import {
|
|
10
|
+
import { AttentionManager, RootAttentionProvider } from "@dxos/react-ui-attention";
|
|
12
11
|
var parseAttentionPlugin = (plugin) => typeof (plugin?.provides).attention === "object" ? plugin : void 0;
|
|
13
12
|
var AttentionPlugin = () => {
|
|
14
|
-
const attention =
|
|
15
|
-
attended: /* @__PURE__ */ new Set()
|
|
16
|
-
});
|
|
13
|
+
const attention = new AttentionManager();
|
|
17
14
|
let graphPlugin;
|
|
18
15
|
return {
|
|
19
16
|
meta: meta_default,
|
|
20
17
|
ready: async (plugins) => {
|
|
21
18
|
graphPlugin = resolvePlugin(plugins, parseGraphPlugin);
|
|
22
19
|
effect(() => {
|
|
23
|
-
const id = Array.from(attention.
|
|
20
|
+
const id = Array.from(attention.current)[0];
|
|
24
21
|
const path = id && graphPlugin?.provides.graph.getPath({
|
|
25
22
|
target: id
|
|
26
23
|
});
|
|
@@ -31,11 +28,15 @@ var AttentionPlugin = () => {
|
|
|
31
28
|
setupDevtools(attention);
|
|
32
29
|
},
|
|
33
30
|
provides: {
|
|
34
|
-
attention
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
31
|
+
attention: {
|
|
32
|
+
get attended() {
|
|
33
|
+
return attention.current;
|
|
34
|
+
},
|
|
35
|
+
getAttention: attention.get
|
|
36
|
+
},
|
|
37
|
+
context: (props) => /* @__PURE__ */ React.createElement(RootAttentionProvider, {
|
|
38
|
+
attention,
|
|
39
|
+
onChange: (nextAttended) => {
|
|
39
40
|
}
|
|
40
41
|
}, props.children)
|
|
41
42
|
}
|
|
@@ -45,12 +46,10 @@ var setupDevtools = (attention) => {
|
|
|
45
46
|
globalThis.composer ??= {};
|
|
46
47
|
globalThis.composer.attention = {
|
|
47
48
|
get attended() {
|
|
48
|
-
return
|
|
49
|
-
...attention.attended ?? []
|
|
50
|
-
];
|
|
49
|
+
return attention.current;
|
|
51
50
|
},
|
|
52
51
|
get currentSpace() {
|
|
53
|
-
for (const id of attention.
|
|
52
|
+
for (const id of attention.current) {
|
|
54
53
|
const [spaceId, objectId] = id.split(":");
|
|
55
54
|
if (spaceId && objectId && spaceId.length === 33) {
|
|
56
55
|
return spaceId;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/AttentionPlugin.tsx", "../../../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport { effect } from '@preact/signals-core';\nimport React, { type PropsWithChildren } from 'react';\n\nimport {\n type Plugin,\n type
|
|
5
|
-
"mappings": ";;;;;AAIA,SAASA,cAAc;AACvB,OAAOC,WAAuC;AAE9C,
|
|
6
|
-
"names": ["effect", "React", "resolvePlugin", "parseGraphPlugin", "
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport { effect } from '@preact/signals-core';\nimport React, { type PropsWithChildren } from 'react';\n\nimport {\n type Plugin,\n type GraphProvides,\n resolvePlugin,\n parseGraphPlugin,\n type PluginDefinition,\n} from '@dxos/app-framework';\nimport { Keyboard } from '@dxos/keyboard';\nimport { type Attention, AttentionManager, RootAttentionProvider } from '@dxos/react-ui-attention';\n\nimport meta from './meta';\n\ntype AttentionProvides = {\n attention: {\n attended: Readonly<string[]>;\n getAttention: (path: string[]) => Attention;\n };\n};\n\nexport type AttentionPluginProvides = AttentionProvides;\n\nexport const parseAttentionPlugin = (plugin?: Plugin) =>\n typeof (plugin?.provides as any).attention === 'object' ? (plugin as Plugin<AttentionPluginProvides>) : undefined;\n\nexport const AttentionPlugin = (): PluginDefinition<AttentionPluginProvides> => {\n const attention = new AttentionManager();\n let graphPlugin: Plugin<GraphProvides> | undefined;\n\n return {\n meta,\n ready: async (plugins: any) => {\n graphPlugin = resolvePlugin(plugins, parseGraphPlugin);\n\n effect(() => {\n const id = Array.from(attention.current)[0];\n const path = id && graphPlugin?.provides.graph.getPath({ target: id });\n if (path) {\n Keyboard.singleton.setCurrentContext(path.join('/'));\n }\n });\n\n setupDevtools(attention);\n },\n provides: {\n attention: {\n get attended() {\n return attention.current;\n },\n getAttention: attention.get,\n },\n context: (props: PropsWithChildren) => (\n <RootAttentionProvider\n attention={attention}\n onChange={(nextAttended) => {\n // TODO(Zan): Workout why this was in deck plugin. It didn't seem to work?\n // if (layout.values.scrollIntoView && nextAttended.has(layout.values.scrollIntoView)) {\n // layout.values.scrollIntoView = undefined;\n // }\n }}\n >\n {props.children}\n </RootAttentionProvider>\n ),\n },\n };\n};\n\nconst setupDevtools = (attention: AttentionManager) => {\n (globalThis as any).composer ??= {};\n\n (globalThis as any).composer.attention = {\n get attended() {\n return attention.current;\n },\n get currentSpace() {\n for (const id of attention.current) {\n const [spaceId, objectId] = id.split(':');\n if (spaceId && objectId && spaceId.length === 33) {\n return spaceId;\n }\n }\n },\n };\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { AttentionPlugin } from './AttentionPlugin';\n\nexport default AttentionPlugin;\n\nexport * from './AttentionPlugin';\n"],
|
|
5
|
+
"mappings": ";;;;;AAIA,SAASA,cAAc;AACvB,OAAOC,WAAuC;AAE9C,SAGEC,eACAC,wBAEK;AACP,SAASC,gBAAgB;AACzB,SAAyBC,kBAAkBC,6BAA6B;AAajE,IAAMC,uBAAuB,CAACC,WACnC,QAAQA,QAAQC,UAAiBC,cAAc,WAAYF,SAA6CG;AAEnG,IAAMC,kBAAkB,MAAA;AAC7B,QAAMF,YAAY,IAAIG,iBAAAA;AACtB,MAAIC;AAEJ,SAAO;IACLC;IACAC,OAAO,OAAOC,YAAAA;AACZH,oBAAcI,cAAcD,SAASE,gBAAAA;AAErCC,aAAO,MAAA;AACL,cAAMC,KAAKC,MAAMC,KAAKb,UAAUc,OAAO,EAAE,CAAA;AACzC,cAAMC,OAAOJ,MAAMP,aAAaL,SAASiB,MAAMC,QAAQ;UAAEC,QAAQP;QAAG,CAAA;AACpE,YAAII,MAAM;AACRI,mBAASC,UAAUC,kBAAkBN,KAAKO,KAAK,GAAA,CAAA;QACjD;MACF,CAAA;AAEAC,oBAAcvB,SAAAA;IAChB;IACAD,UAAU;MACRC,WAAW;QACT,IAAIwB,WAAW;AACb,iBAAOxB,UAAUc;QACnB;QACAW,cAAczB,UAAU0B;MAC1B;MACAC,SAAS,CAACC,UACR,sBAAA,cAACC,uBAAAA;QACC7B;QACA8B,UAAU,CAACC,iBAAAA;QAKX;SAECH,MAAMI,QAAQ;IAGrB;EACF;AACF;AAEA,IAAMT,gBAAgB,CAACvB,cAAAA;AACpBiC,aAAmBC,aAAa,CAAC;AAEjCD,aAAmBC,SAASlC,YAAY;IACvC,IAAIwB,WAAW;AACb,aAAOxB,UAAUc;IACnB;IACA,IAAIqB,eAAe;AACjB,iBAAWxB,MAAMX,UAAUc,SAAS;AAClC,cAAM,CAACsB,SAASC,QAAAA,IAAY1B,GAAG2B,MAAM,GAAA;AACrC,YAAIF,WAAWC,YAAYD,QAAQG,WAAW,IAAI;AAChD,iBAAOH;QACT;MACF;IACF;EACF;AACF;;;ACpFA,IAAA,cAAeI;",
|
|
6
|
+
"names": ["effect", "React", "resolvePlugin", "parseGraphPlugin", "Keyboard", "AttentionManager", "RootAttentionProvider", "parseAttentionPlugin", "plugin", "provides", "attention", "undefined", "AttentionPlugin", "AttentionManager", "graphPlugin", "meta", "ready", "plugins", "resolvePlugin", "parseGraphPlugin", "effect", "id", "Array", "from", "current", "path", "graph", "getPath", "target", "Keyboard", "singleton", "setCurrentContext", "join", "setupDevtools", "attended", "getAttention", "get", "context", "props", "RootAttentionProvider", "onChange", "nextAttended", "children", "globalThis", "composer", "currentSpace", "spaceId", "objectId", "split", "length", "AttentionPlugin"]
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"packages/plugins/plugin-attention/src/meta.ts":{"bytes":
|
|
1
|
+
{"inputs":{"packages/plugins/plugin-attention/src/meta.ts":{"bytes":973,"imports":[],"format":"esm"},"packages/plugins/plugin-attention/src/AttentionPlugin.tsx":{"bytes":8587,"imports":[{"path":"@preact/signals-core","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/keyboard","kind":"import-statement","external":true},{"path":"@dxos/react-ui-attention","kind":"import-statement","external":true},{"path":"packages/plugins/plugin-attention/src/meta.ts","kind":"import-statement","original":"./meta"}],"format":"esm"},"packages/plugins/plugin-attention/src/index.ts":{"bytes":821,"imports":[{"path":"packages/plugins/plugin-attention/src/AttentionPlugin.tsx","kind":"import-statement","original":"./AttentionPlugin"},{"path":"packages/plugins/plugin-attention/src/AttentionPlugin.tsx","kind":"import-statement","original":"./AttentionPlugin"}],"format":"esm"}},"outputs":{"packages/plugins/plugin-attention/dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":4704},"packages/plugins/plugin-attention/dist/lib/browser/index.mjs":{"imports":[{"path":"packages/plugins/plugin-attention/dist/lib/browser/chunk-56S77L6M.mjs","kind":"import-statement"},{"path":"@preact/signals-core","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/keyboard","kind":"import-statement","external":true},{"path":"@dxos/react-ui-attention","kind":"import-statement","external":true}],"exports":["AttentionPlugin","default","parseAttentionPlugin"],"entryPoint":"packages/plugins/plugin-attention/src/index.ts","inputs":{"packages/plugins/plugin-attention/src/AttentionPlugin.tsx":{"bytesInOutput":1662},"packages/plugins/plugin-attention/src/index.ts":{"bytesInOutput":35}},"bytes":1980},"packages/plugins/plugin-attention/dist/lib/browser/meta.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":93},"packages/plugins/plugin-attention/dist/lib/browser/meta.mjs":{"imports":[{"path":"packages/plugins/plugin-attention/dist/lib/browser/chunk-56S77L6M.mjs","kind":"import-statement"}],"exports":["ATTENTION_PLUGIN","default"],"entryPoint":"packages/plugins/plugin-attention/src/meta.ts","inputs":{},"bytes":167},"packages/plugins/plugin-attention/dist/lib/browser/chunk-56S77L6M.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":462},"packages/plugins/plugin-attention/dist/lib/browser/chunk-56S77L6M.mjs":{"imports":[],"exports":["ATTENTION_PLUGIN","meta_default"],"inputs":{"packages/plugins/plugin-attention/src/meta.ts":{"bytesInOutput":120}},"bytes":261}}}
|
|
@@ -16,12 +16,12 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var
|
|
20
|
-
__export(
|
|
19
|
+
var chunk_VEMWITWY_exports = {};
|
|
20
|
+
__export(chunk_VEMWITWY_exports, {
|
|
21
21
|
ATTENTION_PLUGIN: () => ATTENTION_PLUGIN,
|
|
22
22
|
meta_default: () => meta_default
|
|
23
23
|
});
|
|
24
|
-
module.exports = __toCommonJS(
|
|
24
|
+
module.exports = __toCommonJS(chunk_VEMWITWY_exports);
|
|
25
25
|
var ATTENTION_PLUGIN = "dxos.org/plugin/attention";
|
|
26
26
|
var meta_default = {
|
|
27
27
|
id: ATTENTION_PLUGIN,
|
|
@@ -32,4 +32,4 @@ var meta_default = {
|
|
|
32
32
|
ATTENTION_PLUGIN,
|
|
33
33
|
meta_default
|
|
34
34
|
});
|
|
35
|
-
//# sourceMappingURL=chunk-
|
|
35
|
+
//# sourceMappingURL=chunk-VEMWITWY.cjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
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/index.cjs
CHANGED
|
@@ -33,25 +33,22 @@ __export(node_exports, {
|
|
|
33
33
|
parseAttentionPlugin: () => parseAttentionPlugin
|
|
34
34
|
});
|
|
35
35
|
module.exports = __toCommonJS(node_exports);
|
|
36
|
-
var
|
|
36
|
+
var import_chunk_VEMWITWY = require("./chunk-VEMWITWY.cjs");
|
|
37
37
|
var import_signals_core = require("@preact/signals-core");
|
|
38
38
|
var import_react = __toESM(require("react"));
|
|
39
39
|
var import_app_framework = require("@dxos/app-framework");
|
|
40
|
-
var import_echo_schema = require("@dxos/echo-schema");
|
|
41
40
|
var import_keyboard = require("@dxos/keyboard");
|
|
42
41
|
var import_react_ui_attention = require("@dxos/react-ui-attention");
|
|
43
42
|
var parseAttentionPlugin = (plugin) => typeof (plugin?.provides).attention === "object" ? plugin : void 0;
|
|
44
43
|
var AttentionPlugin = () => {
|
|
45
|
-
const attention =
|
|
46
|
-
attended: /* @__PURE__ */ new Set()
|
|
47
|
-
});
|
|
44
|
+
const attention = new import_react_ui_attention.AttentionManager();
|
|
48
45
|
let graphPlugin;
|
|
49
46
|
return {
|
|
50
|
-
meta:
|
|
47
|
+
meta: import_chunk_VEMWITWY.meta_default,
|
|
51
48
|
ready: async (plugins) => {
|
|
52
49
|
graphPlugin = (0, import_app_framework.resolvePlugin)(plugins, import_app_framework.parseGraphPlugin);
|
|
53
50
|
(0, import_signals_core.effect)(() => {
|
|
54
|
-
const id = Array.from(attention.
|
|
51
|
+
const id = Array.from(attention.current)[0];
|
|
55
52
|
const path = id && graphPlugin?.provides.graph.getPath({
|
|
56
53
|
target: id
|
|
57
54
|
});
|
|
@@ -62,11 +59,15 @@ var AttentionPlugin = () => {
|
|
|
62
59
|
setupDevtools(attention);
|
|
63
60
|
},
|
|
64
61
|
provides: {
|
|
65
|
-
attention
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
62
|
+
attention: {
|
|
63
|
+
get attended() {
|
|
64
|
+
return attention.current;
|
|
65
|
+
},
|
|
66
|
+
getAttention: attention.get
|
|
67
|
+
},
|
|
68
|
+
context: (props) => /* @__PURE__ */ import_react.default.createElement(import_react_ui_attention.RootAttentionProvider, {
|
|
69
|
+
attention,
|
|
70
|
+
onChange: (nextAttended) => {
|
|
70
71
|
}
|
|
71
72
|
}, props.children)
|
|
72
73
|
}
|
|
@@ -76,12 +77,10 @@ var setupDevtools = (attention) => {
|
|
|
76
77
|
globalThis.composer ??= {};
|
|
77
78
|
globalThis.composer.attention = {
|
|
78
79
|
get attended() {
|
|
79
|
-
return
|
|
80
|
-
...attention.attended ?? []
|
|
81
|
-
];
|
|
80
|
+
return attention.current;
|
|
82
81
|
},
|
|
83
82
|
get currentSpace() {
|
|
84
|
-
for (const id of attention.
|
|
83
|
+
for (const id of attention.current) {
|
|
85
84
|
const [spaceId, objectId] = id.split(":");
|
|
86
85
|
if (spaceId && objectId && spaceId.length === 33) {
|
|
87
86
|
return spaceId;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/AttentionPlugin.tsx", "../../../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport { effect } from '@preact/signals-core';\nimport React, { type PropsWithChildren } from 'react';\n\nimport {\n type Plugin,\n type
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,0BAAuB;AACvB,mBAA8C;AAE9C,
|
|
6
|
-
"names": ["parseAttentionPlugin", "plugin", "provides", "attention", "undefined", "AttentionPlugin", "
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport { effect } from '@preact/signals-core';\nimport React, { type PropsWithChildren } from 'react';\n\nimport {\n type Plugin,\n type GraphProvides,\n resolvePlugin,\n parseGraphPlugin,\n type PluginDefinition,\n} from '@dxos/app-framework';\nimport { Keyboard } from '@dxos/keyboard';\nimport { type Attention, AttentionManager, RootAttentionProvider } from '@dxos/react-ui-attention';\n\nimport meta from './meta';\n\ntype AttentionProvides = {\n attention: {\n attended: Readonly<string[]>;\n getAttention: (path: string[]) => Attention;\n };\n};\n\nexport type AttentionPluginProvides = AttentionProvides;\n\nexport const parseAttentionPlugin = (plugin?: Plugin) =>\n typeof (plugin?.provides as any).attention === 'object' ? (plugin as Plugin<AttentionPluginProvides>) : undefined;\n\nexport const AttentionPlugin = (): PluginDefinition<AttentionPluginProvides> => {\n const attention = new AttentionManager();\n let graphPlugin: Plugin<GraphProvides> | undefined;\n\n return {\n meta,\n ready: async (plugins: any) => {\n graphPlugin = resolvePlugin(plugins, parseGraphPlugin);\n\n effect(() => {\n const id = Array.from(attention.current)[0];\n const path = id && graphPlugin?.provides.graph.getPath({ target: id });\n if (path) {\n Keyboard.singleton.setCurrentContext(path.join('/'));\n }\n });\n\n setupDevtools(attention);\n },\n provides: {\n attention: {\n get attended() {\n return attention.current;\n },\n getAttention: attention.get,\n },\n context: (props: PropsWithChildren) => (\n <RootAttentionProvider\n attention={attention}\n onChange={(nextAttended) => {\n // TODO(Zan): Workout why this was in deck plugin. It didn't seem to work?\n // if (layout.values.scrollIntoView && nextAttended.has(layout.values.scrollIntoView)) {\n // layout.values.scrollIntoView = undefined;\n // }\n }}\n >\n {props.children}\n </RootAttentionProvider>\n ),\n },\n };\n};\n\nconst setupDevtools = (attention: AttentionManager) => {\n (globalThis as any).composer ??= {};\n\n (globalThis as any).composer.attention = {\n get attended() {\n return attention.current;\n },\n get currentSpace() {\n for (const id of attention.current) {\n const [spaceId, objectId] = id.split(':');\n if (spaceId && objectId && spaceId.length === 33) {\n return spaceId;\n }\n }\n },\n };\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { AttentionPlugin } from './AttentionPlugin';\n\nexport default AttentionPlugin;\n\nexport * from './AttentionPlugin';\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,0BAAuB;AACvB,mBAA8C;AAE9C,2BAMO;AACP,sBAAyB;AACzB,gCAAwE;AAajE,IAAMA,uBAAuB,CAACC,WACnC,QAAQA,QAAQC,UAAiBC,cAAc,WAAYF,SAA6CG;AAEnG,IAAMC,kBAAkB,MAAA;AAC7B,QAAMF,YAAY,IAAIG,2CAAAA;AACtB,MAAIC;AAEJ,SAAO;IACLC,MAAAA;IACAC,OAAO,OAAOC,YAAAA;AACZH,wBAAcI,oCAAcD,SAASE,qCAAAA;AAErCC,sCAAO,MAAA;AACL,cAAMC,KAAKC,MAAMC,KAAKb,UAAUc,OAAO,EAAE,CAAA;AACzC,cAAMC,OAAOJ,MAAMP,aAAaL,SAASiB,MAAMC,QAAQ;UAAEC,QAAQP;QAAG,CAAA;AACpE,YAAII,MAAM;AACRI,mCAASC,UAAUC,kBAAkBN,KAAKO,KAAK,GAAA,CAAA;QACjD;MACF,CAAA;AAEAC,oBAAcvB,SAAAA;IAChB;IACAD,UAAU;MACRC,WAAW;QACT,IAAIwB,WAAW;AACb,iBAAOxB,UAAUc;QACnB;QACAW,cAAczB,UAAU0B;MAC1B;MACAC,SAAS,CAACC,UACR,6BAAAC,QAAA,cAACC,iDAAAA;QACC9B;QACA+B,UAAU,CAACC,iBAAAA;QAKX;SAECJ,MAAMK,QAAQ;IAGrB;EACF;AACF;AAEA,IAAMV,gBAAgB,CAACvB,cAAAA;AACpBkC,aAAmBC,aAAa,CAAC;AAEjCD,aAAmBC,SAASnC,YAAY;IACvC,IAAIwB,WAAW;AACb,aAAOxB,UAAUc;IACnB;IACA,IAAIsB,eAAe;AACjB,iBAAWzB,MAAMX,UAAUc,SAAS;AAClC,cAAM,CAACuB,SAASC,QAAAA,IAAY3B,GAAG4B,MAAM,GAAA;AACrC,YAAIF,WAAWC,YAAYD,QAAQG,WAAW,IAAI;AAChD,iBAAOH;QACT;MACF;IACF;EACF;AACF;ACpFA,IAAA,cAAenC;",
|
|
6
|
+
"names": ["parseAttentionPlugin", "plugin", "provides", "attention", "undefined", "AttentionPlugin", "AttentionManager", "graphPlugin", "meta", "ready", "plugins", "resolvePlugin", "parseGraphPlugin", "effect", "id", "Array", "from", "current", "path", "graph", "getPath", "target", "Keyboard", "singleton", "setCurrentContext", "join", "setupDevtools", "attended", "getAttention", "get", "context", "props", "React", "RootAttentionProvider", "onChange", "nextAttended", "children", "globalThis", "composer", "currentSpace", "spaceId", "objectId", "split", "length"]
|
|
7
7
|
}
|
package/dist/lib/node/meta.cjs
CHANGED
|
@@ -18,11 +18,11 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var meta_exports = {};
|
|
20
20
|
__export(meta_exports, {
|
|
21
|
-
ATTENTION_PLUGIN: () =>
|
|
22
|
-
default: () =>
|
|
21
|
+
ATTENTION_PLUGIN: () => import_chunk_VEMWITWY.ATTENTION_PLUGIN,
|
|
22
|
+
default: () => import_chunk_VEMWITWY.meta_default
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(meta_exports);
|
|
25
|
-
var
|
|
25
|
+
var import_chunk_VEMWITWY = require("./chunk-VEMWITWY.cjs");
|
|
26
26
|
// Annotate the CommonJS export names for ESM import in node:
|
|
27
27
|
0 && (module.exports = {
|
|
28
28
|
ATTENTION_PLUGIN
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["meta.cjs"],
|
|
4
|
-
"sourcesContent": ["import {\n ATTENTION_PLUGIN,\n meta_default\n} from \"./chunk-
|
|
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
5
|
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,4BAGO;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/lib/node/meta.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"packages/plugins/plugin-attention/src/meta.ts":{"bytes":
|
|
1
|
+
{"inputs":{"packages/plugins/plugin-attention/src/meta.ts":{"bytes":973,"imports":[],"format":"esm"},"packages/plugins/plugin-attention/src/AttentionPlugin.tsx":{"bytes":8587,"imports":[{"path":"@preact/signals-core","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/keyboard","kind":"import-statement","external":true},{"path":"@dxos/react-ui-attention","kind":"import-statement","external":true},{"path":"packages/plugins/plugin-attention/src/meta.ts","kind":"import-statement","original":"./meta"}],"format":"esm"},"packages/plugins/plugin-attention/src/index.ts":{"bytes":821,"imports":[{"path":"packages/plugins/plugin-attention/src/AttentionPlugin.tsx","kind":"import-statement","original":"./AttentionPlugin"},{"path":"packages/plugins/plugin-attention/src/AttentionPlugin.tsx","kind":"import-statement","original":"./AttentionPlugin"}],"format":"esm"}},"outputs":{"packages/plugins/plugin-attention/dist/lib/node/index.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":4704},"packages/plugins/plugin-attention/dist/lib/node/index.cjs":{"imports":[{"path":"packages/plugins/plugin-attention/dist/lib/node/chunk-VEMWITWY.cjs","kind":"import-statement"},{"path":"@preact/signals-core","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/keyboard","kind":"import-statement","external":true},{"path":"@dxos/react-ui-attention","kind":"import-statement","external":true}],"exports":["AttentionPlugin","default","parseAttentionPlugin"],"entryPoint":"packages/plugins/plugin-attention/src/index.ts","inputs":{"packages/plugins/plugin-attention/src/AttentionPlugin.tsx":{"bytesInOutput":1662},"packages/plugins/plugin-attention/src/index.ts":{"bytesInOutput":35}},"bytes":1980},"packages/plugins/plugin-attention/dist/lib/node/meta.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":93},"packages/plugins/plugin-attention/dist/lib/node/meta.cjs":{"imports":[{"path":"packages/plugins/plugin-attention/dist/lib/node/chunk-VEMWITWY.cjs","kind":"import-statement"}],"exports":["ATTENTION_PLUGIN","default"],"entryPoint":"packages/plugins/plugin-attention/src/meta.ts","inputs":{},"bytes":167},"packages/plugins/plugin-attention/dist/lib/node/chunk-VEMWITWY.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":462},"packages/plugins/plugin-attention/dist/lib/node/chunk-VEMWITWY.cjs":{"imports":[],"exports":["ATTENTION_PLUGIN","meta_default"],"inputs":{"packages/plugins/plugin-attention/src/meta.ts":{"bytesInOutput":120}},"bytes":261}}}
|
|
@@ -0,0 +1,14 @@
|
|
|
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
|
|
@@ -0,0 +1,7 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
meta_default
|
|
4
|
+
} from "./chunk-NWBDAVCK.mjs";
|
|
5
|
+
|
|
6
|
+
// packages/plugins/plugin-attention/src/AttentionPlugin.tsx
|
|
7
|
+
import { effect } from "@preact/signals-core";
|
|
8
|
+
import React from "react";
|
|
9
|
+
import { resolvePlugin, parseGraphPlugin } from "@dxos/app-framework";
|
|
10
|
+
import { Keyboard } from "@dxos/keyboard";
|
|
11
|
+
import { AttentionManager, RootAttentionProvider } from "@dxos/react-ui-attention";
|
|
12
|
+
var parseAttentionPlugin = (plugin) => typeof (plugin?.provides).attention === "object" ? plugin : void 0;
|
|
13
|
+
var AttentionPlugin = () => {
|
|
14
|
+
const attention = new AttentionManager();
|
|
15
|
+
let graphPlugin;
|
|
16
|
+
return {
|
|
17
|
+
meta: meta_default,
|
|
18
|
+
ready: async (plugins) => {
|
|
19
|
+
graphPlugin = resolvePlugin(plugins, parseGraphPlugin);
|
|
20
|
+
effect(() => {
|
|
21
|
+
const id = Array.from(attention.current)[0];
|
|
22
|
+
const path = id && graphPlugin?.provides.graph.getPath({
|
|
23
|
+
target: id
|
|
24
|
+
});
|
|
25
|
+
if (path) {
|
|
26
|
+
Keyboard.singleton.setCurrentContext(path.join("/"));
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
setupDevtools(attention);
|
|
30
|
+
},
|
|
31
|
+
provides: {
|
|
32
|
+
attention: {
|
|
33
|
+
get attended() {
|
|
34
|
+
return attention.current;
|
|
35
|
+
},
|
|
36
|
+
getAttention: attention.get
|
|
37
|
+
},
|
|
38
|
+
context: (props) => /* @__PURE__ */ React.createElement(RootAttentionProvider, {
|
|
39
|
+
attention,
|
|
40
|
+
onChange: (nextAttended) => {
|
|
41
|
+
}
|
|
42
|
+
}, props.children)
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
var setupDevtools = (attention) => {
|
|
47
|
+
globalThis.composer ??= {};
|
|
48
|
+
globalThis.composer.attention = {
|
|
49
|
+
get attended() {
|
|
50
|
+
return attention.current;
|
|
51
|
+
},
|
|
52
|
+
get currentSpace() {
|
|
53
|
+
for (const id of attention.current) {
|
|
54
|
+
const [spaceId, objectId] = id.split(":");
|
|
55
|
+
if (spaceId && objectId && spaceId.length === 33) {
|
|
56
|
+
return spaceId;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
// packages/plugins/plugin-attention/src/index.ts
|
|
64
|
+
var src_default = AttentionPlugin;
|
|
65
|
+
export {
|
|
66
|
+
AttentionPlugin,
|
|
67
|
+
src_default as default,
|
|
68
|
+
parseAttentionPlugin
|
|
69
|
+
};
|
|
70
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/AttentionPlugin.tsx", "../../../src/index.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport { effect } from '@preact/signals-core';\nimport React, { type PropsWithChildren } from 'react';\n\nimport {\n type Plugin,\n type GraphProvides,\n resolvePlugin,\n parseGraphPlugin,\n type PluginDefinition,\n} from '@dxos/app-framework';\nimport { Keyboard } from '@dxos/keyboard';\nimport { type Attention, AttentionManager, RootAttentionProvider } from '@dxos/react-ui-attention';\n\nimport meta from './meta';\n\ntype AttentionProvides = {\n attention: {\n attended: Readonly<string[]>;\n getAttention: (path: string[]) => Attention;\n };\n};\n\nexport type AttentionPluginProvides = AttentionProvides;\n\nexport const parseAttentionPlugin = (plugin?: Plugin) =>\n typeof (plugin?.provides as any).attention === 'object' ? (plugin as Plugin<AttentionPluginProvides>) : undefined;\n\nexport const AttentionPlugin = (): PluginDefinition<AttentionPluginProvides> => {\n const attention = new AttentionManager();\n let graphPlugin: Plugin<GraphProvides> | undefined;\n\n return {\n meta,\n ready: async (plugins: any) => {\n graphPlugin = resolvePlugin(plugins, parseGraphPlugin);\n\n effect(() => {\n const id = Array.from(attention.current)[0];\n const path = id && graphPlugin?.provides.graph.getPath({ target: id });\n if (path) {\n Keyboard.singleton.setCurrentContext(path.join('/'));\n }\n });\n\n setupDevtools(attention);\n },\n provides: {\n attention: {\n get attended() {\n return attention.current;\n },\n getAttention: attention.get,\n },\n context: (props: PropsWithChildren) => (\n <RootAttentionProvider\n attention={attention}\n onChange={(nextAttended) => {\n // TODO(Zan): Workout why this was in deck plugin. It didn't seem to work?\n // if (layout.values.scrollIntoView && nextAttended.has(layout.values.scrollIntoView)) {\n // layout.values.scrollIntoView = undefined;\n // }\n }}\n >\n {props.children}\n </RootAttentionProvider>\n ),\n },\n };\n};\n\nconst setupDevtools = (attention: AttentionManager) => {\n (globalThis as any).composer ??= {};\n\n (globalThis as any).composer.attention = {\n get attended() {\n return attention.current;\n },\n get currentSpace() {\n for (const id of attention.current) {\n const [spaceId, objectId] = id.split(':');\n if (spaceId && objectId && spaceId.length === 33) {\n return spaceId;\n }\n }\n },\n };\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { AttentionPlugin } from './AttentionPlugin';\n\nexport default AttentionPlugin;\n\nexport * from './AttentionPlugin';\n"],
|
|
5
|
+
"mappings": ";;;;;;AAIA,SAASA,cAAc;AACvB,OAAOC,WAAuC;AAE9C,SAGEC,eACAC,wBAEK;AACP,SAASC,gBAAgB;AACzB,SAAyBC,kBAAkBC,6BAA6B;AAajE,IAAMC,uBAAuB,CAACC,WACnC,QAAQA,QAAQC,UAAiBC,cAAc,WAAYF,SAA6CG;AAEnG,IAAMC,kBAAkB,MAAA;AAC7B,QAAMF,YAAY,IAAIG,iBAAAA;AACtB,MAAIC;AAEJ,SAAO;IACLC;IACAC,OAAO,OAAOC,YAAAA;AACZH,oBAAcI,cAAcD,SAASE,gBAAAA;AAErCC,aAAO,MAAA;AACL,cAAMC,KAAKC,MAAMC,KAAKb,UAAUc,OAAO,EAAE,CAAA;AACzC,cAAMC,OAAOJ,MAAMP,aAAaL,SAASiB,MAAMC,QAAQ;UAAEC,QAAQP;QAAG,CAAA;AACpE,YAAII,MAAM;AACRI,mBAASC,UAAUC,kBAAkBN,KAAKO,KAAK,GAAA,CAAA;QACjD;MACF,CAAA;AAEAC,oBAAcvB,SAAAA;IAChB;IACAD,UAAU;MACRC,WAAW;QACT,IAAIwB,WAAW;AACb,iBAAOxB,UAAUc;QACnB;QACAW,cAAczB,UAAU0B;MAC1B;MACAC,SAAS,CAACC,UACR,sBAAA,cAACC,uBAAAA;QACC7B;QACA8B,UAAU,CAACC,iBAAAA;QAKX;SAECH,MAAMI,QAAQ;IAGrB;EACF;AACF;AAEA,IAAMT,gBAAgB,CAACvB,cAAAA;AACpBiC,aAAmBC,aAAa,CAAC;AAEjCD,aAAmBC,SAASlC,YAAY;IACvC,IAAIwB,WAAW;AACb,aAAOxB,UAAUc;IACnB;IACA,IAAIqB,eAAe;AACjB,iBAAWxB,MAAMX,UAAUc,SAAS;AAClC,cAAM,CAACsB,SAASC,QAAAA,IAAY1B,GAAG2B,MAAM,GAAA;AACrC,YAAIF,WAAWC,YAAYD,QAAQG,WAAW,IAAI;AAChD,iBAAOH;QACT;MACF;IACF;EACF;AACF;;;ACpFA,IAAA,cAAeI;",
|
|
6
|
+
"names": ["effect", "React", "resolvePlugin", "parseGraphPlugin", "Keyboard", "AttentionManager", "RootAttentionProvider", "parseAttentionPlugin", "plugin", "provides", "attention", "undefined", "AttentionPlugin", "AttentionManager", "graphPlugin", "meta", "ready", "plugins", "resolvePlugin", "parseGraphPlugin", "effect", "id", "Array", "from", "current", "path", "graph", "getPath", "target", "Keyboard", "singleton", "setCurrentContext", "join", "setupDevtools", "attended", "getAttention", "get", "context", "props", "RootAttentionProvider", "onChange", "nextAttended", "children", "globalThis", "composer", "currentSpace", "spaceId", "objectId", "split", "length", "AttentionPlugin"]
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"inputs":{"packages/plugins/plugin-attention/src/meta.ts":{"bytes":973,"imports":[],"format":"esm"},"packages/plugins/plugin-attention/src/AttentionPlugin.tsx":{"bytes":8587,"imports":[{"path":"@preact/signals-core","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/keyboard","kind":"import-statement","external":true},{"path":"@dxos/react-ui-attention","kind":"import-statement","external":true},{"path":"packages/plugins/plugin-attention/src/meta.ts","kind":"import-statement","original":"./meta"}],"format":"esm"},"packages/plugins/plugin-attention/src/index.ts":{"bytes":821,"imports":[{"path":"packages/plugins/plugin-attention/src/AttentionPlugin.tsx","kind":"import-statement","original":"./AttentionPlugin"},{"path":"packages/plugins/plugin-attention/src/AttentionPlugin.tsx","kind":"import-statement","original":"./AttentionPlugin"}],"format":"esm"}},"outputs":{"packages/plugins/plugin-attention/dist/lib/node-esm/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":4705},"packages/plugins/plugin-attention/dist/lib/node-esm/index.mjs":{"imports":[{"path":"packages/plugins/plugin-attention/dist/lib/node-esm/chunk-NWBDAVCK.mjs","kind":"import-statement"},{"path":"@preact/signals-core","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/keyboard","kind":"import-statement","external":true},{"path":"@dxos/react-ui-attention","kind":"import-statement","external":true}],"exports":["AttentionPlugin","default","parseAttentionPlugin"],"entryPoint":"packages/plugins/plugin-attention/src/index.ts","inputs":{"packages/plugins/plugin-attention/src/AttentionPlugin.tsx":{"bytesInOutput":1662},"packages/plugins/plugin-attention/src/index.ts":{"bytesInOutput":35}},"bytes":2072},"packages/plugins/plugin-attention/dist/lib/node-esm/meta.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":93},"packages/plugins/plugin-attention/dist/lib/node-esm/meta.mjs":{"imports":[{"path":"packages/plugins/plugin-attention/dist/lib/node-esm/chunk-NWBDAVCK.mjs","kind":"import-statement"}],"exports":["ATTENTION_PLUGIN","default"],"entryPoint":"packages/plugins/plugin-attention/src/meta.ts","inputs":{},"bytes":259},"packages/plugins/plugin-attention/dist/lib/node-esm/chunk-NWBDAVCK.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":464},"packages/plugins/plugin-attention/dist/lib/node-esm/chunk-NWBDAVCK.mjs":{"imports":[],"exports":["ATTENTION_PLUGIN","meta_default"],"inputs":{"packages/plugins/plugin-attention/src/meta.ts":{"bytesInOutput":120}},"bytes":354}}}
|
|
@@ -0,0 +1,10 @@
|
|
|
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,6 +1,10 @@
|
|
|
1
|
-
import { type Plugin, type
|
|
1
|
+
import { type Plugin, type PluginDefinition } from '@dxos/app-framework';
|
|
2
|
+
import { type Attention } from '@dxos/react-ui-attention';
|
|
2
3
|
type AttentionProvides = {
|
|
3
|
-
attention:
|
|
4
|
+
attention: {
|
|
5
|
+
attended: Readonly<string[]>;
|
|
6
|
+
getAttention: (path: string[]) => Attention;
|
|
7
|
+
};
|
|
4
8
|
};
|
|
5
9
|
export type AttentionPluginProvides = AttentionProvides;
|
|
6
10
|
export declare const parseAttentionPlugin: (plugin?: Plugin) => Plugin<AttentionProvides> | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AttentionPlugin.d.ts","sourceRoot":"","sources":["../../../src/AttentionPlugin.tsx"],"names":[],"mappings":"AAOA,OAAO,EACL,KAAK,MAAM,
|
|
1
|
+
{"version":3,"file":"AttentionPlugin.d.ts","sourceRoot":"","sources":["../../../src/AttentionPlugin.tsx"],"names":[],"mappings":"AAOA,OAAO,EACL,KAAK,MAAM,EAIX,KAAK,gBAAgB,EACtB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,KAAK,SAAS,EAA2C,MAAM,0BAA0B,CAAC;AAInG,KAAK,iBAAiB,GAAG;IACvB,SAAS,EAAE;QACT,QAAQ,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;QAC7B,YAAY,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,SAAS,CAAC;KAC7C,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG,iBAAiB,CAAC;AAExD,eAAO,MAAM,oBAAoB,YAAa,MAAM,0CAC+D,CAAC;AAEpH,eAAO,MAAM,eAAe,QAAO,gBAAgB,CAAC,uBAAuB,CAyC1E,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"meta.d.ts","sourceRoot":"","sources":["../../../src/meta.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"meta.d.ts","sourceRoot":"","sources":["../../../src/meta.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,gBAAgB,8BAA8B,CAAC;;;;;AAE5D,wBAGuB"}
|
package/package.json
CHANGED
|
@@ -1,23 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/plugin-attention",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.14-main.2b6a0f3",
|
|
4
4
|
"description": "Plugin for attention",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"author": "DXOS.org",
|
|
9
|
+
"sideEffects": false,
|
|
9
10
|
"exports": {
|
|
10
11
|
".": {
|
|
11
12
|
"browser": "./dist/lib/browser/index.mjs",
|
|
12
13
|
"node": {
|
|
13
|
-
"
|
|
14
|
+
"require": "./dist/lib/node/index.cjs",
|
|
15
|
+
"default": "./dist/lib/node-esm/index.mjs"
|
|
14
16
|
},
|
|
15
17
|
"types": "./dist/types/src/index.d.ts"
|
|
16
18
|
},
|
|
17
19
|
"./meta": {
|
|
18
20
|
"browser": "./dist/lib/browser/meta.mjs",
|
|
19
21
|
"node": {
|
|
20
|
-
"
|
|
22
|
+
"require": "./dist/lib/node/meta.cjs",
|
|
23
|
+
"default": "./dist/lib/node-esm/meta.mjs"
|
|
21
24
|
},
|
|
22
25
|
"types": "./dist/types/src/meta.d.ts"
|
|
23
26
|
}
|
|
@@ -36,11 +39,11 @@
|
|
|
36
39
|
],
|
|
37
40
|
"dependencies": {
|
|
38
41
|
"@preact/signals-core": "^1.6.0",
|
|
39
|
-
"@dxos/app-framework": "0.6.
|
|
40
|
-
"@dxos/echo-schema": "0.6.
|
|
41
|
-
"@dxos/
|
|
42
|
-
"@dxos/
|
|
43
|
-
"@dxos/
|
|
42
|
+
"@dxos/app-framework": "0.6.14-main.2b6a0f3",
|
|
43
|
+
"@dxos/echo-schema": "0.6.14-main.2b6a0f3",
|
|
44
|
+
"@dxos/echo-signals": "0.6.14-main.2b6a0f3",
|
|
45
|
+
"@dxos/react-ui-attention": "0.6.14-main.2b6a0f3",
|
|
46
|
+
"@dxos/keyboard": "0.6.14-main.2b6a0f3"
|
|
44
47
|
},
|
|
45
48
|
"devDependencies": {
|
|
46
49
|
"@types/react": "~18.2.0",
|
|
@@ -48,8 +51,8 @@
|
|
|
48
51
|
"react-dom": "~18.2.0"
|
|
49
52
|
},
|
|
50
53
|
"peerDependencies": {
|
|
51
|
-
"react": "
|
|
52
|
-
"react-dom": "
|
|
54
|
+
"react": "~18.2.0",
|
|
55
|
+
"react-dom": "~18.2.0"
|
|
53
56
|
},
|
|
54
57
|
"publishConfig": {
|
|
55
58
|
"access": "public"
|
package/src/AttentionPlugin.tsx
CHANGED
|
@@ -7,20 +7,21 @@ import React, { type PropsWithChildren } from 'react';
|
|
|
7
7
|
|
|
8
8
|
import {
|
|
9
9
|
type Plugin,
|
|
10
|
-
type Attention,
|
|
11
10
|
type GraphProvides,
|
|
12
11
|
resolvePlugin,
|
|
13
12
|
parseGraphPlugin,
|
|
14
13
|
type PluginDefinition,
|
|
15
14
|
} from '@dxos/app-framework';
|
|
16
|
-
import { create, type ReactiveObject } from '@dxos/echo-schema';
|
|
17
15
|
import { Keyboard } from '@dxos/keyboard';
|
|
18
|
-
import {
|
|
16
|
+
import { type Attention, AttentionManager, RootAttentionProvider } from '@dxos/react-ui-attention';
|
|
19
17
|
|
|
20
18
|
import meta from './meta';
|
|
21
19
|
|
|
22
20
|
type AttentionProvides = {
|
|
23
|
-
attention:
|
|
21
|
+
attention: {
|
|
22
|
+
attended: Readonly<string[]>;
|
|
23
|
+
getAttention: (path: string[]) => Attention;
|
|
24
|
+
};
|
|
24
25
|
};
|
|
25
26
|
|
|
26
27
|
export type AttentionPluginProvides = AttentionProvides;
|
|
@@ -29,10 +30,7 @@ export const parseAttentionPlugin = (plugin?: Plugin) =>
|
|
|
29
30
|
typeof (plugin?.provides as any).attention === 'object' ? (plugin as Plugin<AttentionPluginProvides>) : undefined;
|
|
30
31
|
|
|
31
32
|
export const AttentionPlugin = (): PluginDefinition<AttentionPluginProvides> => {
|
|
32
|
-
const attention =
|
|
33
|
-
attended: new Set(),
|
|
34
|
-
});
|
|
35
|
-
|
|
33
|
+
const attention = new AttentionManager();
|
|
36
34
|
let graphPlugin: Plugin<GraphProvides> | undefined;
|
|
37
35
|
|
|
38
36
|
return {
|
|
@@ -41,7 +39,7 @@ export const AttentionPlugin = (): PluginDefinition<AttentionPluginProvides> =>
|
|
|
41
39
|
graphPlugin = resolvePlugin(plugins, parseGraphPlugin);
|
|
42
40
|
|
|
43
41
|
effect(() => {
|
|
44
|
-
const id = Array.from(attention.
|
|
42
|
+
const id = Array.from(attention.current)[0];
|
|
45
43
|
const path = id && graphPlugin?.provides.graph.getPath({ target: id });
|
|
46
44
|
if (path) {
|
|
47
45
|
Keyboard.singleton.setCurrentContext(path.join('/'));
|
|
@@ -51,13 +49,16 @@ export const AttentionPlugin = (): PluginDefinition<AttentionPluginProvides> =>
|
|
|
51
49
|
setupDevtools(attention);
|
|
52
50
|
},
|
|
53
51
|
provides: {
|
|
54
|
-
attention
|
|
52
|
+
attention: {
|
|
53
|
+
get attended() {
|
|
54
|
+
return attention.current;
|
|
55
|
+
},
|
|
56
|
+
getAttention: attention.get,
|
|
57
|
+
},
|
|
55
58
|
context: (props: PropsWithChildren) => (
|
|
56
|
-
<
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
attention.attended = nextAttended;
|
|
60
|
-
|
|
59
|
+
<RootAttentionProvider
|
|
60
|
+
attention={attention}
|
|
61
|
+
onChange={(nextAttended) => {
|
|
61
62
|
// TODO(Zan): Workout why this was in deck plugin. It didn't seem to work?
|
|
62
63
|
// if (layout.values.scrollIntoView && nextAttended.has(layout.values.scrollIntoView)) {
|
|
63
64
|
// layout.values.scrollIntoView = undefined;
|
|
@@ -65,21 +66,21 @@ export const AttentionPlugin = (): PluginDefinition<AttentionPluginProvides> =>
|
|
|
65
66
|
}}
|
|
66
67
|
>
|
|
67
68
|
{props.children}
|
|
68
|
-
</
|
|
69
|
+
</RootAttentionProvider>
|
|
69
70
|
),
|
|
70
71
|
},
|
|
71
72
|
};
|
|
72
73
|
};
|
|
73
74
|
|
|
74
|
-
const setupDevtools = (attention:
|
|
75
|
+
const setupDevtools = (attention: AttentionManager) => {
|
|
75
76
|
(globalThis as any).composer ??= {};
|
|
76
77
|
|
|
77
78
|
(globalThis as any).composer.attention = {
|
|
78
79
|
get attended() {
|
|
79
|
-
return
|
|
80
|
+
return attention.current;
|
|
80
81
|
},
|
|
81
82
|
get currentSpace() {
|
|
82
|
-
for (const id of attention.
|
|
83
|
+
for (const id of attention.current) {
|
|
83
84
|
const [spaceId, objectId] = id.split(':');
|
|
84
85
|
if (spaceId && objectId && spaceId.length === 33) {
|
|
85
86
|
return spaceId;
|
package/src/meta.ts
CHANGED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/meta.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nexport const ATTENTION_PLUGIN = 'dxos.org/plugin/attention';\n\nexport default {\n id: ATTENTION_PLUGIN,\n name: 'Attention',\n};\n"],
|
|
5
|
-
"mappings": ";AAIO,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\nexport const ATTENTION_PLUGIN = 'dxos.org/plugin/attention';\n\nexport default {\n id: ATTENTION_PLUGIN,\n name: 'Attention',\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAIO,IAAMA,mBAAmB;AAEhC,IAAA,eAAe;EACbC,IAAID;EACJE,MAAM;AACR;",
|
|
6
|
-
"names": ["ATTENTION_PLUGIN", "id", "name"]
|
|
7
|
-
}
|