@dxos/plugin-attention 0.6.14-main.7bd9c89 → 0.6.14-staging.934c9de

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.
@@ -6,21 +6,18 @@ import {
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 { RootAttentionProvider } from "@dxos/react-ui-attention";
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 = create({
15
- attended: []
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.attended ?? [])[0];
20
+ const id = Array.from(attention.current)[0];
24
21
  const path = id && graphPlugin?.provides.graph.getPath({
25
22
  target: id
26
23
  });
@@ -31,7 +28,12 @@ var AttentionPlugin = () => {
31
28
  setupDevtools(attention);
32
29
  },
33
30
  provides: {
34
- attention,
31
+ attention: {
32
+ get attended() {
33
+ return attention.current;
34
+ },
35
+ getAttention: attention.get
36
+ },
35
37
  context: (props) => /* @__PURE__ */ React.createElement(RootAttentionProvider, {
36
38
  attention,
37
39
  onChange: (nextAttended) => {
@@ -44,12 +46,10 @@ var setupDevtools = (attention) => {
44
46
  globalThis.composer ??= {};
45
47
  globalThis.composer.attention = {
46
48
  get attended() {
47
- return [
48
- ...attention.attended ?? []
49
- ];
49
+ return attention.current;
50
50
  },
51
51
  get currentSpace() {
52
- for (const id of attention.attended ?? []) {
52
+ for (const id of attention.current) {
53
53
  const [spaceId, objectId] = id.split(":");
54
54
  if (spaceId && objectId && spaceId.length === 33) {
55
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 GraphProvides,\n resolvePlugin,\n parseGraphPlugin,\n type PluginDefinition,\n} from '@dxos/app-framework';\nimport { create, type ReactiveObject } from '@dxos/echo-schema';\nimport { Keyboard } from '@dxos/keyboard';\nimport { type Attention, RootAttentionProvider } from '@dxos/react-ui-attention';\n\nimport meta from './meta';\n\ntype AttentionProvides = {\n attention: Readonly<Attention>;\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 = create<Attention>({ attended: [] });\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.attended ?? [])[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 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: ReactiveObject<Attention>) => {\n (globalThis as any).composer ??= {};\n\n (globalThis as any).composer.attention = {\n get attended() {\n return [...(attention.attended ?? [])];\n },\n get currentSpace() {\n for (const id of attention.attended ?? []) {\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,cAAmC;AAC5C,SAASC,gBAAgB;AACzB,SAAyBC,6BAA6B;AAU/C,IAAMC,uBAAuB,CAACC,WACnC,QAAQA,QAAQC,UAAiBC,cAAc,WAAYF,SAA6CG;AAEnG,IAAMC,kBAAkB,MAAA;AAC7B,QAAMF,YAAYG,OAAkB;IAAEC,UAAU,CAAA;EAAG,CAAA;AACnD,MAAIC;AAEJ,SAAO;IACLC;IACAC,OAAO,OAAOC,YAAAA;AACZH,oBAAcI,cAAcD,SAASE,gBAAAA;AAErCC,aAAO,MAAA;AACL,cAAMC,KAAKC,MAAMC,KAAKd,UAAUI,YAAY,CAAA,CAAE,EAAE,CAAA;AAChD,cAAMW,OAAOH,MAAMP,aAAaN,SAASiB,MAAMC,QAAQ;UAAEC,QAAQN;QAAG,CAAA;AACpE,YAAIG,MAAM;AACRI,mBAASC,UAAUC,kBAAkBN,KAAKO,KAAK,GAAA,CAAA;QACjD;MACF,CAAA;AAEAC,oBAAcvB,SAAAA;IAChB;IACAD,UAAU;MACRC;MACAwB,SAAS,CAACC,UACR,sBAAA,cAACC,uBAAAA;QACC1B;QACA2B,UAAU,CAACC,iBAAAA;QAKX;SAECH,MAAMI,QAAQ;IAGrB;EACF;AACF;AAEA,IAAMN,gBAAgB,CAACvB,cAAAA;AACpB8B,aAAmBC,aAAa,CAAC;AAEjCD,aAAmBC,SAAS/B,YAAY;IACvC,IAAII,WAAW;AACb,aAAO;WAAKJ,UAAUI,YAAY,CAAA;;IACpC;IACA,IAAI4B,eAAe;AACjB,iBAAWpB,MAAMZ,UAAUI,YAAY,CAAA,GAAI;AACzC,cAAM,CAAC6B,SAASC,QAAAA,IAAYtB,GAAGuB,MAAM,GAAA;AACrC,YAAIF,WAAWC,YAAYD,QAAQG,WAAW,IAAI;AAChD,iBAAOH;QACT;MACF;IACF;EACF;AACF;;;AC7EA,IAAA,cAAeI;",
6
- "names": ["effect", "React", "resolvePlugin", "parseGraphPlugin", "create", "Keyboard", "RootAttentionProvider", "parseAttentionPlugin", "plugin", "provides", "attention", "undefined", "AttentionPlugin", "create", "attended", "graphPlugin", "meta", "ready", "plugins", "resolvePlugin", "parseGraphPlugin", "effect", "id", "Array", "from", "path", "graph", "getPath", "target", "Keyboard", "singleton", "setCurrentContext", "join", "setupDevtools", "context", "props", "RootAttentionProvider", "onChange", "nextAttended", "children", "globalThis", "composer", "currentSpace", "spaceId", "objectId", "split", "length", "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,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":973,"imports":[],"format":"esm"},"packages/plugins/plugin-attention/src/AttentionPlugin.tsx":{"bytes":8327,"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/echo-schema","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":4543},"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/echo-schema","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":1619},"packages/plugins/plugin-attention/src/index.ts":{"bytesInOutput":35}},"bytes":1937},"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}}}
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}}}
@@ -37,21 +37,18 @@ 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 = (0, import_echo_schema.create)({
46
- attended: []
47
- });
44
+ const attention = new import_react_ui_attention.AttentionManager();
48
45
  let graphPlugin;
49
46
  return {
50
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.attended ?? [])[0];
51
+ const id = Array.from(attention.current)[0];
55
52
  const path = id && graphPlugin?.provides.graph.getPath({
56
53
  target: id
57
54
  });
@@ -62,7 +59,12 @@ var AttentionPlugin = () => {
62
59
  setupDevtools(attention);
63
60
  },
64
61
  provides: {
65
- attention,
62
+ attention: {
63
+ get attended() {
64
+ return attention.current;
65
+ },
66
+ getAttention: attention.get
67
+ },
66
68
  context: (props) => /* @__PURE__ */ import_react.default.createElement(import_react_ui_attention.RootAttentionProvider, {
67
69
  attention,
68
70
  onChange: (nextAttended) => {
@@ -75,12 +77,10 @@ var setupDevtools = (attention) => {
75
77
  globalThis.composer ??= {};
76
78
  globalThis.composer.attention = {
77
79
  get attended() {
78
- return [
79
- ...attention.attended ?? []
80
- ];
80
+ return attention.current;
81
81
  },
82
82
  get currentSpace() {
83
- for (const id of attention.attended ?? []) {
83
+ for (const id of attention.current) {
84
84
  const [spaceId, objectId] = id.split(":");
85
85
  if (spaceId && objectId && spaceId.length === 33) {
86
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 GraphProvides,\n resolvePlugin,\n parseGraphPlugin,\n type PluginDefinition,\n} from '@dxos/app-framework';\nimport { create, type ReactiveObject } from '@dxos/echo-schema';\nimport { Keyboard } from '@dxos/keyboard';\nimport { type Attention, RootAttentionProvider } from '@dxos/react-ui-attention';\n\nimport meta from './meta';\n\ntype AttentionProvides = {\n attention: Readonly<Attention>;\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 = create<Attention>({ attended: [] });\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.attended ?? [])[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 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: ReactiveObject<Attention>) => {\n (globalThis as any).composer ??= {};\n\n (globalThis as any).composer.attention = {\n get attended() {\n return [...(attention.attended ?? [])];\n },\n get currentSpace() {\n for (const id of attention.attended ?? []) {\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,yBAA4C;AAC5C,sBAAyB;AACzB,gCAAsD;AAU/C,IAAMA,uBAAuB,CAACC,WACnC,QAAQA,QAAQC,UAAiBC,cAAc,WAAYF,SAA6CG;AAEnG,IAAMC,kBAAkB,MAAA;AAC7B,QAAMF,gBAAYG,2BAAkB;IAAEC,UAAU,CAAA;EAAG,CAAA;AACnD,MAAIC;AAEJ,SAAO;IACLC,MAAAA;IACAC,OAAO,OAAOC,YAAAA;AACZH,wBAAcI,oCAAcD,SAASE,qCAAAA;AAErCC,sCAAO,MAAA;AACL,cAAMC,KAAKC,MAAMC,KAAKd,UAAUI,YAAY,CAAA,CAAE,EAAE,CAAA;AAChD,cAAMW,OAAOH,MAAMP,aAAaN,SAASiB,MAAMC,QAAQ;UAAEC,QAAQN;QAAG,CAAA;AACpE,YAAIG,MAAM;AACRI,mCAASC,UAAUC,kBAAkBN,KAAKO,KAAK,GAAA,CAAA;QACjD;MACF,CAAA;AAEAC,oBAAcvB,SAAAA;IAChB;IACAD,UAAU;MACRC;MACAwB,SAAS,CAACC,UACR,6BAAAC,QAAA,cAACC,iDAAAA;QACC3B;QACA4B,UAAU,CAACC,iBAAAA;QAKX;SAECJ,MAAMK,QAAQ;IAGrB;EACF;AACF;AAEA,IAAMP,gBAAgB,CAACvB,cAAAA;AACpB+B,aAAmBC,aAAa,CAAC;AAEjCD,aAAmBC,SAAShC,YAAY;IACvC,IAAII,WAAW;AACb,aAAO;WAAKJ,UAAUI,YAAY,CAAA;;IACpC;IACA,IAAI6B,eAAe;AACjB,iBAAWrB,MAAMZ,UAAUI,YAAY,CAAA,GAAI;AACzC,cAAM,CAAC8B,SAASC,QAAAA,IAAYvB,GAAGwB,MAAM,GAAA;AACrC,YAAIF,WAAWC,YAAYD,QAAQG,WAAW,IAAI;AAChD,iBAAOH;QACT;MACF;IACF;EACF;AACF;AC7EA,IAAA,cAAehC;",
6
- "names": ["parseAttentionPlugin", "plugin", "provides", "attention", "undefined", "AttentionPlugin", "create", "attended", "graphPlugin", "meta", "ready", "plugins", "resolvePlugin", "parseGraphPlugin", "effect", "id", "Array", "from", "path", "graph", "getPath", "target", "Keyboard", "singleton", "setCurrentContext", "join", "setupDevtools", "context", "props", "React", "RootAttentionProvider", "onChange", "nextAttended", "children", "globalThis", "composer", "currentSpace", "spaceId", "objectId", "split", "length"]
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
  }
@@ -1 +1 @@
1
- {"inputs":{"packages/plugins/plugin-attention/src/meta.ts":{"bytes":973,"imports":[],"format":"esm"},"packages/plugins/plugin-attention/src/AttentionPlugin.tsx":{"bytes":8327,"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/echo-schema","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":4543},"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/echo-schema","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":1619},"packages/plugins/plugin-attention/src/index.ts":{"bytesInOutput":35}},"bytes":1937},"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}}}
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}}}
@@ -7,21 +7,18 @@ import {
7
7
  import { effect } from "@preact/signals-core";
8
8
  import React from "react";
9
9
  import { resolvePlugin, parseGraphPlugin } from "@dxos/app-framework";
10
- import { create } from "@dxos/echo-schema";
11
10
  import { Keyboard } from "@dxos/keyboard";
12
- import { RootAttentionProvider } from "@dxos/react-ui-attention";
11
+ import { AttentionManager, RootAttentionProvider } from "@dxos/react-ui-attention";
13
12
  var parseAttentionPlugin = (plugin) => typeof (plugin?.provides).attention === "object" ? plugin : void 0;
14
13
  var AttentionPlugin = () => {
15
- const attention = create({
16
- attended: []
17
- });
14
+ const attention = new AttentionManager();
18
15
  let graphPlugin;
19
16
  return {
20
17
  meta: meta_default,
21
18
  ready: async (plugins) => {
22
19
  graphPlugin = resolvePlugin(plugins, parseGraphPlugin);
23
20
  effect(() => {
24
- const id = Array.from(attention.attended ?? [])[0];
21
+ const id = Array.from(attention.current)[0];
25
22
  const path = id && graphPlugin?.provides.graph.getPath({
26
23
  target: id
27
24
  });
@@ -32,7 +29,12 @@ var AttentionPlugin = () => {
32
29
  setupDevtools(attention);
33
30
  },
34
31
  provides: {
35
- attention,
32
+ attention: {
33
+ get attended() {
34
+ return attention.current;
35
+ },
36
+ getAttention: attention.get
37
+ },
36
38
  context: (props) => /* @__PURE__ */ React.createElement(RootAttentionProvider, {
37
39
  attention,
38
40
  onChange: (nextAttended) => {
@@ -45,12 +47,10 @@ var setupDevtools = (attention) => {
45
47
  globalThis.composer ??= {};
46
48
  globalThis.composer.attention = {
47
49
  get attended() {
48
- return [
49
- ...attention.attended ?? []
50
- ];
50
+ return attention.current;
51
51
  },
52
52
  get currentSpace() {
53
- for (const id of attention.attended ?? []) {
53
+ for (const id of attention.current) {
54
54
  const [spaceId, objectId] = id.split(":");
55
55
  if (spaceId && objectId && spaceId.length === 33) {
56
56
  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 GraphProvides,\n resolvePlugin,\n parseGraphPlugin,\n type PluginDefinition,\n} from '@dxos/app-framework';\nimport { create, type ReactiveObject } from '@dxos/echo-schema';\nimport { Keyboard } from '@dxos/keyboard';\nimport { type Attention, RootAttentionProvider } from '@dxos/react-ui-attention';\n\nimport meta from './meta';\n\ntype AttentionProvides = {\n attention: Readonly<Attention>;\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 = create<Attention>({ attended: [] });\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.attended ?? [])[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 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: ReactiveObject<Attention>) => {\n (globalThis as any).composer ??= {};\n\n (globalThis as any).composer.attention = {\n get attended() {\n return [...(attention.attended ?? [])];\n },\n get currentSpace() {\n for (const id of attention.attended ?? []) {\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,cAAmC;AAC5C,SAASC,gBAAgB;AACzB,SAAyBC,6BAA6B;AAU/C,IAAMC,uBAAuB,CAACC,WACnC,QAAQA,QAAQC,UAAiBC,cAAc,WAAYF,SAA6CG;AAEnG,IAAMC,kBAAkB,MAAA;AAC7B,QAAMF,YAAYG,OAAkB;IAAEC,UAAU,CAAA;EAAG,CAAA;AACnD,MAAIC;AAEJ,SAAO;IACLC;IACAC,OAAO,OAAOC,YAAAA;AACZH,oBAAcI,cAAcD,SAASE,gBAAAA;AAErCC,aAAO,MAAA;AACL,cAAMC,KAAKC,MAAMC,KAAKd,UAAUI,YAAY,CAAA,CAAE,EAAE,CAAA;AAChD,cAAMW,OAAOH,MAAMP,aAAaN,SAASiB,MAAMC,QAAQ;UAAEC,QAAQN;QAAG,CAAA;AACpE,YAAIG,MAAM;AACRI,mBAASC,UAAUC,kBAAkBN,KAAKO,KAAK,GAAA,CAAA;QACjD;MACF,CAAA;AAEAC,oBAAcvB,SAAAA;IAChB;IACAD,UAAU;MACRC;MACAwB,SAAS,CAACC,UACR,sBAAA,cAACC,uBAAAA;QACC1B;QACA2B,UAAU,CAACC,iBAAAA;QAKX;SAECH,MAAMI,QAAQ;IAGrB;EACF;AACF;AAEA,IAAMN,gBAAgB,CAACvB,cAAAA;AACpB8B,aAAmBC,aAAa,CAAC;AAEjCD,aAAmBC,SAAS/B,YAAY;IACvC,IAAII,WAAW;AACb,aAAO;WAAKJ,UAAUI,YAAY,CAAA;;IACpC;IACA,IAAI4B,eAAe;AACjB,iBAAWpB,MAAMZ,UAAUI,YAAY,CAAA,GAAI;AACzC,cAAM,CAAC6B,SAASC,QAAAA,IAAYtB,GAAGuB,MAAM,GAAA;AACrC,YAAIF,WAAWC,YAAYD,QAAQG,WAAW,IAAI;AAChD,iBAAOH;QACT;MACF;IACF;EACF;AACF;;;AC7EA,IAAA,cAAeI;",
6
- "names": ["effect", "React", "resolvePlugin", "parseGraphPlugin", "create", "Keyboard", "RootAttentionProvider", "parseAttentionPlugin", "plugin", "provides", "attention", "undefined", "AttentionPlugin", "create", "attended", "graphPlugin", "meta", "ready", "plugins", "resolvePlugin", "parseGraphPlugin", "effect", "id", "Array", "from", "path", "graph", "getPath", "target", "Keyboard", "singleton", "setCurrentContext", "join", "setupDevtools", "context", "props", "RootAttentionProvider", "onChange", "nextAttended", "children", "globalThis", "composer", "currentSpace", "spaceId", "objectId", "split", "length", "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,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":973,"imports":[],"format":"esm"},"packages/plugins/plugin-attention/src/AttentionPlugin.tsx":{"bytes":8327,"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/echo-schema","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":4544},"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/echo-schema","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":1619},"packages/plugins/plugin-attention/src/index.ts":{"bytesInOutput":35}},"bytes":2029},"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}}}
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}}}
@@ -1,7 +1,10 @@
1
1
  import { type Plugin, type PluginDefinition } from '@dxos/app-framework';
2
2
  import { type Attention } from '@dxos/react-ui-attention';
3
3
  type AttentionProvides = {
4
- attention: Readonly<Attention>;
4
+ attention: {
5
+ attended: Readonly<string[]>;
6
+ getAttention: (path: string[]) => Attention;
7
+ };
5
8
  };
6
9
  export type AttentionPluginProvides = AttentionProvides;
7
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,EAIX,KAAK,gBAAgB,EACtB,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EAAE,KAAK,SAAS,EAAyB,MAAM,0BAA0B,CAAC;AAIjF,KAAK,iBAAiB,GAAG;IACvB,SAAS,EAAE,QAAQ,CAAC,SAAS,CAAC,CAAC;CAChC,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,CAoC1E,CAAC"}
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"}
package/package.json CHANGED
@@ -1,27 +1,22 @@
1
1
  {
2
2
  "name": "@dxos/plugin-attention",
3
- "version": "0.6.14-main.7bd9c89",
3
+ "version": "0.6.14-staging.934c9de",
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": true,
9
10
  "exports": {
10
11
  ".": {
12
+ "types": "./dist/types/src/index.d.ts",
11
13
  "browser": "./dist/lib/browser/index.mjs",
12
- "node": {
13
- "require": "./dist/lib/node/index.cjs",
14
- "default": "./dist/lib/node-esm/index.mjs"
15
- },
16
- "types": "./dist/types/src/index.d.ts"
14
+ "node": "./dist/lib/node-esm/index.mjs"
17
15
  },
18
16
  "./meta": {
17
+ "types": "./dist/types/src/meta.d.ts",
19
18
  "browser": "./dist/lib/browser/meta.mjs",
20
- "node": {
21
- "require": "./dist/lib/node/meta.cjs",
22
- "default": "./dist/lib/node-esm/meta.mjs"
23
- },
24
- "types": "./dist/types/src/meta.d.ts"
19
+ "node": "./dist/lib/node-esm/meta.mjs"
25
20
  }
26
21
  },
27
22
  "types": "dist/types/src/index.d.ts",
@@ -38,11 +33,11 @@
38
33
  ],
39
34
  "dependencies": {
40
35
  "@preact/signals-core": "^1.6.0",
41
- "@dxos/app-framework": "0.6.14-main.7bd9c89",
42
- "@dxos/echo-schema": "0.6.14-main.7bd9c89",
43
- "@dxos/keyboard": "0.6.14-main.7bd9c89",
44
- "@dxos/react-ui-attention": "0.6.14-main.7bd9c89",
45
- "@dxos/echo-signals": "0.6.14-main.7bd9c89"
36
+ "@dxos/app-framework": "0.6.14-staging.934c9de",
37
+ "@dxos/echo-schema": "0.6.14-staging.934c9de",
38
+ "@dxos/keyboard": "0.6.14-staging.934c9de",
39
+ "@dxos/react-ui-attention": "0.6.14-staging.934c9de",
40
+ "@dxos/echo-signals": "0.6.14-staging.934c9de"
46
41
  },
47
42
  "devDependencies": {
48
43
  "@types/react": "~18.2.0",
@@ -12,14 +12,16 @@ import {
12
12
  parseGraphPlugin,
13
13
  type PluginDefinition,
14
14
  } from '@dxos/app-framework';
15
- import { create, type ReactiveObject } from '@dxos/echo-schema';
16
15
  import { Keyboard } from '@dxos/keyboard';
17
- import { type Attention, RootAttentionProvider } from '@dxos/react-ui-attention';
16
+ import { type Attention, AttentionManager, RootAttentionProvider } from '@dxos/react-ui-attention';
18
17
 
19
18
  import meta from './meta';
20
19
 
21
20
  type AttentionProvides = {
22
- attention: Readonly<Attention>;
21
+ attention: {
22
+ attended: Readonly<string[]>;
23
+ getAttention: (path: string[]) => Attention;
24
+ };
23
25
  };
24
26
 
25
27
  export type AttentionPluginProvides = AttentionProvides;
@@ -28,7 +30,7 @@ export const parseAttentionPlugin = (plugin?: Plugin) =>
28
30
  typeof (plugin?.provides as any).attention === 'object' ? (plugin as Plugin<AttentionPluginProvides>) : undefined;
29
31
 
30
32
  export const AttentionPlugin = (): PluginDefinition<AttentionPluginProvides> => {
31
- const attention = create<Attention>({ attended: [] });
33
+ const attention = new AttentionManager();
32
34
  let graphPlugin: Plugin<GraphProvides> | undefined;
33
35
 
34
36
  return {
@@ -37,7 +39,7 @@ export const AttentionPlugin = (): PluginDefinition<AttentionPluginProvides> =>
37
39
  graphPlugin = resolvePlugin(plugins, parseGraphPlugin);
38
40
 
39
41
  effect(() => {
40
- const id = Array.from(attention.attended ?? [])[0];
42
+ const id = Array.from(attention.current)[0];
41
43
  const path = id && graphPlugin?.provides.graph.getPath({ target: id });
42
44
  if (path) {
43
45
  Keyboard.singleton.setCurrentContext(path.join('/'));
@@ -47,7 +49,12 @@ export const AttentionPlugin = (): PluginDefinition<AttentionPluginProvides> =>
47
49
  setupDevtools(attention);
48
50
  },
49
51
  provides: {
50
- attention,
52
+ attention: {
53
+ get attended() {
54
+ return attention.current;
55
+ },
56
+ getAttention: attention.get,
57
+ },
51
58
  context: (props: PropsWithChildren) => (
52
59
  <RootAttentionProvider
53
60
  attention={attention}
@@ -65,15 +72,15 @@ export const AttentionPlugin = (): PluginDefinition<AttentionPluginProvides> =>
65
72
  };
66
73
  };
67
74
 
68
- const setupDevtools = (attention: ReactiveObject<Attention>) => {
75
+ const setupDevtools = (attention: AttentionManager) => {
69
76
  (globalThis as any).composer ??= {};
70
77
 
71
78
  (globalThis as any).composer.attention = {
72
79
  get attended() {
73
- return [...(attention.attended ?? [])];
80
+ return attention.current;
74
81
  },
75
82
  get currentSpace() {
76
- for (const id of attention.attended ?? []) {
83
+ for (const id of attention.current) {
77
84
  const [spaceId, objectId] = id.split(':');
78
85
  if (spaceId && objectId && spaceId.length === 33) {
79
86
  return spaceId;