@dxos/plugin-navtree 0.8.4-main.3f58842 → 0.8.4-main.52d7546f51

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (184) hide show
  1. package/dist/lib/browser/app-graph-builder-XGA4GPGL.mjs +44 -0
  2. package/dist/lib/browser/app-graph-builder-XGA4GPGL.mjs.map +7 -0
  3. package/dist/lib/browser/chunk-63YLDLLE.mjs +1373 -0
  4. package/dist/lib/browser/chunk-63YLDLLE.mjs.map +7 -0
  5. package/dist/lib/browser/chunk-X2HDG62A.mjs +23 -0
  6. package/dist/lib/browser/chunk-X2HDG62A.mjs.map +7 -0
  7. package/dist/lib/browser/chunk-YKTYPINZ.mjs +19 -0
  8. package/dist/lib/browser/chunk-YKTYPINZ.mjs.map +7 -0
  9. package/dist/lib/browser/index.mjs +85 -96
  10. package/dist/lib/browser/index.mjs.map +4 -4
  11. package/dist/lib/browser/{keyboard-QRS6WOQH.mjs → keyboard-46XQHY2O.mjs} +21 -19
  12. package/dist/lib/browser/keyboard-46XQHY2O.mjs.map +7 -0
  13. package/dist/lib/browser/meta.json +1 -1
  14. package/dist/lib/browser/operation-resolver-NNNDII45.mjs +53 -0
  15. package/dist/lib/browser/operation-resolver-NNNDII45.mjs.map +7 -0
  16. package/dist/lib/browser/react-surface-APSEG23H.mjs +59 -0
  17. package/dist/lib/browser/react-surface-APSEG23H.mjs.map +7 -0
  18. package/dist/lib/browser/state-M5YUCIQU.mjs +121 -0
  19. package/dist/lib/browser/state-M5YUCIQU.mjs.map +7 -0
  20. package/dist/types/src/NavTreePlugin.d.ts +2 -1
  21. package/dist/types/src/NavTreePlugin.d.ts.map +1 -1
  22. package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts +6 -0
  23. package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts.map +1 -0
  24. package/dist/types/src/capabilities/app-graph-builder/index.d.ts +3 -0
  25. package/dist/types/src/capabilities/app-graph-builder/index.d.ts.map +1 -0
  26. package/dist/types/src/capabilities/index.d.ts +5 -105
  27. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  28. package/dist/types/src/capabilities/keyboard/index.d.ts +3 -0
  29. package/dist/types/src/capabilities/keyboard/index.d.ts.map +1 -0
  30. package/dist/types/src/capabilities/keyboard/keyboard.d.ts +5 -0
  31. package/dist/types/src/capabilities/keyboard/keyboard.d.ts.map +1 -0
  32. package/dist/types/src/capabilities/operation-resolver/index.d.ts +3 -0
  33. package/dist/types/src/capabilities/operation-resolver/index.d.ts.map +1 -0
  34. package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts +5 -0
  35. package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +1 -0
  36. package/dist/types/src/capabilities/react-surface/index.d.ts +3 -0
  37. package/dist/types/src/capabilities/react-surface/index.d.ts.map +1 -0
  38. package/dist/types/src/capabilities/react-surface/react-surface.d.ts +5 -0
  39. package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +1 -0
  40. package/dist/types/src/capabilities/state/index.d.ts +3 -0
  41. package/dist/types/src/capabilities/state/index.d.ts.map +1 -0
  42. package/dist/types/src/capabilities/state/state.d.ts +6 -0
  43. package/dist/types/src/capabilities/state/state.d.ts.map +1 -0
  44. package/dist/types/src/components/CommandsDialog/CommandsDialog.d.ts +3 -2
  45. package/dist/types/src/components/CommandsDialog/CommandsDialog.d.ts.map +1 -1
  46. package/dist/types/src/components/CommandsDialog/CommandsTrigger.d.ts.map +1 -1
  47. package/dist/types/src/components/NavTree/NavTree.d.ts +32 -3
  48. package/dist/types/src/components/NavTree/NavTree.d.ts.map +1 -1
  49. package/dist/types/src/components/NavTree/NavTree.stories.d.ts +29 -4
  50. package/dist/types/src/components/NavTree/NavTree.stories.d.ts.map +1 -1
  51. package/dist/types/src/components/NavTreeContainer.d.ts +8 -1
  52. package/dist/types/src/components/NavTreeContainer.d.ts.map +1 -1
  53. package/dist/types/src/components/NavTreeDocumentTitle.d.ts +1 -1
  54. package/dist/types/src/components/NavTreeDocumentTitle.d.ts.map +1 -1
  55. package/dist/types/src/components/NavTreeItem/NavTreeItemAction.d.ts +6 -6
  56. package/dist/types/src/components/NavTreeItem/NavTreeItemAction.d.ts.map +1 -1
  57. package/dist/types/src/components/NavTreeItem/NavTreeItemAction.stories.d.ts +33 -4
  58. package/dist/types/src/components/NavTreeItem/NavTreeItemAction.stories.d.ts.map +1 -1
  59. package/dist/types/src/components/NavTreeItem/NavTreeItemColumns.d.ts +2 -2
  60. package/dist/types/src/components/NavTreeItem/NavTreeItemColumns.d.ts.map +1 -1
  61. package/dist/types/src/components/Sidebar/L0Menu.d.ts +6 -4
  62. package/dist/types/src/components/Sidebar/L0Menu.d.ts.map +1 -1
  63. package/dist/types/src/components/Sidebar/L1Panel.d.ts +6 -7
  64. package/dist/types/src/components/Sidebar/L1Panel.d.ts.map +1 -1
  65. package/dist/types/src/components/Sidebar/L1Tabs.d.ts +12 -0
  66. package/dist/types/src/components/Sidebar/L1Tabs.d.ts.map +1 -0
  67. package/dist/types/src/components/Sidebar/index.d.ts +1 -0
  68. package/dist/types/src/components/Sidebar/index.d.ts.map +1 -1
  69. package/dist/types/src/components/UserAccountAvatar/UserAccountAvatar.d.ts.map +1 -1
  70. package/dist/types/src/components/UserAccountAvatar/UserAccountAvatar.stories.d.ts +8 -5
  71. package/dist/types/src/components/UserAccountAvatar/UserAccountAvatar.stories.d.ts.map +1 -1
  72. package/dist/types/src/components/index.d.ts.map +1 -1
  73. package/dist/types/src/components/types.d.ts +8 -8
  74. package/dist/types/src/components/types.d.ts.map +1 -1
  75. package/dist/types/src/experimental/Tree.d.ts +1 -2
  76. package/dist/types/src/experimental/Tree.d.ts.map +1 -1
  77. package/dist/types/src/experimental/Tree.stories.d.ts +23 -6
  78. package/dist/types/src/experimental/Tree.stories.d.ts.map +1 -1
  79. package/dist/types/src/hooks.d.ts +32 -1
  80. package/dist/types/src/hooks.d.ts.map +1 -1
  81. package/dist/types/src/index.d.ts +1 -2
  82. package/dist/types/src/index.d.ts.map +1 -1
  83. package/dist/types/src/meta.d.ts +3 -4
  84. package/dist/types/src/meta.d.ts.map +1 -1
  85. package/dist/types/src/testing/app-graph-builder.d.ts +2 -3
  86. package/dist/types/src/testing/app-graph-builder.d.ts.map +1 -1
  87. package/dist/types/src/testing/generator.d.ts +5 -6
  88. package/dist/types/src/testing/generator.d.ts.map +1 -1
  89. package/dist/types/src/testing/update-state.d.ts +2 -2
  90. package/dist/types/src/testing/update-state.d.ts.map +1 -1
  91. package/dist/types/src/translations.d.ts +1 -0
  92. package/dist/types/src/translations.d.ts.map +1 -1
  93. package/dist/types/src/types/capabilities.d.ts +16 -0
  94. package/dist/types/src/types/capabilities.d.ts.map +1 -0
  95. package/dist/types/src/types/events.d.ts +5 -0
  96. package/dist/types/src/types/events.d.ts.map +1 -0
  97. package/dist/types/src/types/index.d.ts +4 -0
  98. package/dist/types/src/types/index.d.ts.map +1 -0
  99. package/dist/types/src/{types.d.ts → types/schema.d.ts} +10 -9
  100. package/dist/types/src/types/schema.d.ts.map +1 -0
  101. package/dist/types/src/util.d.ts +8 -9
  102. package/dist/types/src/util.d.ts.map +1 -1
  103. package/dist/types/tsconfig.tsbuildinfo +1 -1
  104. package/package.json +56 -53
  105. package/src/NavTreePlugin.tsx +63 -83
  106. package/src/capabilities/app-graph-builder/app-graph-builder.ts +42 -0
  107. package/src/capabilities/app-graph-builder/index.ts +7 -0
  108. package/src/capabilities/index.ts +5 -9
  109. package/src/capabilities/keyboard/index.ts +7 -0
  110. package/src/capabilities/keyboard/keyboard.ts +66 -0
  111. package/src/capabilities/operation-resolver/index.ts +7 -0
  112. package/src/capabilities/operation-resolver/operation-resolver.ts +42 -0
  113. package/src/capabilities/react-surface/index.ts +7 -0
  114. package/src/capabilities/react-surface/react-surface.tsx +55 -0
  115. package/src/capabilities/state/index.ts +7 -0
  116. package/src/capabilities/state/state.ts +122 -0
  117. package/src/components/CommandsDialog/CommandsDialog.tsx +108 -98
  118. package/src/components/CommandsDialog/CommandsTrigger.tsx +6 -15
  119. package/src/components/NavTree/NavTree.stories.tsx +99 -93
  120. package/src/components/NavTree/NavTree.tsx +12 -18
  121. package/src/components/NavTreeContainer.tsx +282 -257
  122. package/src/components/NavTreeDocumentTitle.tsx +5 -4
  123. package/src/components/NavTreeItem/NavTreeItemAction.stories.tsx +20 -12
  124. package/src/components/NavTreeItem/NavTreeItemAction.tsx +25 -18
  125. package/src/components/NavTreeItem/NavTreeItemColumns.tsx +38 -32
  126. package/src/components/Sidebar/L0Menu.tsx +115 -143
  127. package/src/components/Sidebar/L1Panel.tsx +177 -121
  128. package/src/components/Sidebar/L1Tabs.tsx +33 -0
  129. package/src/components/Sidebar/index.ts +1 -0
  130. package/src/components/UserAccountAvatar/UserAccountAvatar.stories.tsx +9 -8
  131. package/src/components/UserAccountAvatar/UserAccountAvatar.tsx +20 -12
  132. package/src/components/index.ts +1 -0
  133. package/src/components/types.ts +9 -8
  134. package/src/experimental/Tree.stories.tsx +69 -77
  135. package/src/experimental/Tree.tsx +7 -24
  136. package/src/hooks.ts +54 -2
  137. package/src/index.ts +1 -2
  138. package/src/meta.ts +11 -8
  139. package/src/testing/app-graph-builder.ts +159 -234
  140. package/src/testing/generator.ts +20 -18
  141. package/src/testing/update-state.ts +6 -6
  142. package/src/translations.ts +1 -0
  143. package/src/types/capabilities.ts +21 -0
  144. package/src/types/events.ts +12 -0
  145. package/src/types/index.ts +7 -0
  146. package/src/{types.ts → types/schema.ts} +9 -8
  147. package/src/util.ts +14 -35
  148. package/dist/lib/browser/app-graph-builder-5J4LRWDX.mjs +0 -45
  149. package/dist/lib/browser/app-graph-builder-5J4LRWDX.mjs.map +0 -7
  150. package/dist/lib/browser/chunk-ERDGQTH5.mjs +0 -16
  151. package/dist/lib/browser/chunk-ERDGQTH5.mjs.map +0 -7
  152. package/dist/lib/browser/chunk-SICQTLXC.mjs +0 -1442
  153. package/dist/lib/browser/chunk-SICQTLXC.mjs.map +0 -7
  154. package/dist/lib/browser/chunk-WCARAZ7J.mjs +0 -15
  155. package/dist/lib/browser/chunk-WCARAZ7J.mjs.map +0 -7
  156. package/dist/lib/browser/intent-resolver-3XYN2CBU.mjs +0 -47
  157. package/dist/lib/browser/intent-resolver-3XYN2CBU.mjs.map +0 -7
  158. package/dist/lib/browser/keyboard-QRS6WOQH.mjs.map +0 -7
  159. package/dist/lib/browser/react-surface-WURHCBQQ.mjs +0 -51
  160. package/dist/lib/browser/react-surface-WURHCBQQ.mjs.map +0 -7
  161. package/dist/lib/browser/state-54DY3DOY.mjs +0 -117
  162. package/dist/lib/browser/state-54DY3DOY.mjs.map +0 -7
  163. package/dist/types/src/capabilities/app-graph-builder.d.ts +0 -4
  164. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +0 -1
  165. package/dist/types/src/capabilities/capabilities.d.ts +0 -21
  166. package/dist/types/src/capabilities/capabilities.d.ts.map +0 -1
  167. package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
  168. package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
  169. package/dist/types/src/capabilities/keyboard.d.ts +0 -4
  170. package/dist/types/src/capabilities/keyboard.d.ts.map +0 -1
  171. package/dist/types/src/capabilities/react-surface.d.ts +0 -4
  172. package/dist/types/src/capabilities/react-surface.d.ts.map +0 -1
  173. package/dist/types/src/capabilities/state.d.ts +0 -20
  174. package/dist/types/src/capabilities/state.d.ts.map +0 -1
  175. package/dist/types/src/events.d.ts +0 -4
  176. package/dist/types/src/events.d.ts.map +0 -1
  177. package/dist/types/src/types.d.ts.map +0 -1
  178. package/src/capabilities/app-graph-builder.ts +0 -52
  179. package/src/capabilities/capabilities.ts +0 -20
  180. package/src/capabilities/intent-resolver.ts +0 -37
  181. package/src/capabilities/keyboard.ts +0 -59
  182. package/src/capabilities/react-surface.tsx +0 -45
  183. package/src/capabilities/state.ts +0 -104
  184. package/src/events.ts +0 -11
@@ -1 +0,0 @@
1
- {"version":3,"file":"intent-resolver.d.ts","sourceRoot":"","sources":["../../../../src/capabilities/intent-resolver.ts"],"names":[],"mappings":"AAMA,OAAO,EAAe,KAAK,aAAa,EAAE,YAAY,EAAgC,MAAM,qBAAqB,CAAC;yBAKlG,SAAS,aAAa;AAAtC,wBAyBI"}
@@ -1,4 +0,0 @@
1
- import { type PluginContext } from '@dxos/app-framework';
2
- declare const _default: (context: PluginContext) => import("@dxos/app-framework").Capability<null>;
3
- export default _default;
4
- //# sourceMappingURL=keyboard.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"keyboard.d.ts","sourceRoot":"","sources":["../../../../src/capabilities/keyboard.ts"],"names":[],"mappings":"AAIA,OAAO,EAAgD,KAAK,aAAa,EAAE,MAAM,qBAAqB,CAAC;yBAQvF,SAAS,aAAa;AAAtC,wBA8CE"}
@@ -1,4 +0,0 @@
1
- import { Capabilities } from '@dxos/app-framework';
2
- declare const _default: () => import("@dxos/app-framework").Capability<Capabilities.ReactSurface>;
3
- export default _default;
4
- //# sourceMappingURL=react-surface.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"react-surface.d.ts","sourceRoot":"","sources":["../../../../src/capabilities/react-surface.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAE,YAAY,EAA8B,MAAM,qBAAqB,CAAC;;AAM/E,wBAgCK"}
@@ -1,20 +0,0 @@
1
- import { type PluginContext } from '@dxos/app-framework';
2
- import { type Live } from '@dxos/echo';
3
- declare const _default: (context: PluginContext) => import("@dxos/app-framework").Capability<{
4
- state: Map<string, Live<{
5
- open: boolean;
6
- current: boolean;
7
- alternateTree?: boolean;
8
- }>>;
9
- getItem: (path: string[]) => Live<{
10
- open: boolean;
11
- current: boolean;
12
- alternateTree?: boolean;
13
- }>;
14
- setItem: (path: string[], key: "open" | "current" | "alternateTree", next: boolean) => void;
15
- isOpen: (path: string[], item: import("../types").NavTreeItemGraphNode) => boolean;
16
- isCurrent: (path: string[], item: import("../types").NavTreeItemGraphNode) => boolean;
17
- isAlternateTree: (path: string[], item: import("../types").NavTreeItemGraphNode) => boolean;
18
- }>;
19
- export default _default;
20
- //# sourceMappingURL=state.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../../../src/capabilities/state.ts"],"names":[],"mappings":"AAMA,OAAO,EAA6B,KAAK,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpF,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,YAAY,CAAC;yBAwBvB,SAAS,aAAa;;;;qBAnBL,CAAC;;;;;qBAKjB,CAAC;;;;;;;AAclB,wBAwEE"}
@@ -1,4 +0,0 @@
1
- export declare namespace NavTreeEvents {
2
- const StateReady: import("@dxos/app-framework").ActivationEvent;
3
- }
4
- //# sourceMappingURL=events.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../../src/events.ts"],"names":[],"mappings":"AAQA,yBAAiB,aAAa,CAAC;IACtB,MAAM,UAAU,+CAA0C,CAAC;CACnE"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,UAAU,EAAE,KAAK,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAC1E,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE9D,MAAM,MAAM,oBAAoB,GAAG,IAAI,CACrC,GAAG,EACH,OAAO,CACL,cAAc,GAAG;IACf,gBAAgB,EAAE,MAAM,CAAC;IACzB,cAAc,EAAE,MAAM,CAAC;IACvB,sBAAsB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACpC,oBAAoB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAClC,mBAAmB,EAAE,CAAC,SAAS,EAAE,oBAAoB,EAAE,KAAK,YAAY,CAAC,IAAI,CAAC,CAAC;IAC/E,MAAM,EAAE,CAAC,UAAU,EAAE,oBAAoB,EAAE,KAAK,CAAC,EAAE,MAAM,KAAK,YAAY,CAAC,IAAI,CAAC,CAAC;IACjF,eAAe,EAAE,CAAC,UAAU,EAAE,oBAAoB,EAAE,KAAK,CAAC,EAAE,MAAM,KAAK,YAAY,CAAC,IAAI,CAAC,CAAC;IAC1F,aAAa,EAAE,CAAC,UAAU,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,oBAAoB,KAAK,YAAY,CAAC,IAAI,CAAC,CAAC;CAClH,CACF,CACF,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,OAAO,EAAE,UAAU,EAAE,CAAC;IACtB,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;CAC1C,CAAC;AAEF,KAAK,gBAAgB,GAAG;IACtB,KAAK,EAAE,KAAK,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,gBAAgB,GAAG;IAC9C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,gBAAgB,GAAG;IAChD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,UAAU,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC;CAClC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG;IAGvB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC"}
@@ -1,52 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import { Rx } from '@effect-rx/rx-react';
6
- import { Option, pipe } from 'effect';
7
-
8
- import { Capabilities, contributes, type PluginContext, createIntent, LayoutAction } from '@dxos/app-framework';
9
- import { createExtension, ROOT_ID } from '@dxos/plugin-graph';
10
-
11
- import { COMMANDS_DIALOG, NAVTREE_PLUGIN } from '../meta';
12
-
13
- export default (context: PluginContext) =>
14
- contributes(
15
- Capabilities.AppGraphBuilder,
16
- createExtension({
17
- id: NAVTREE_PLUGIN,
18
- actions: (node) =>
19
- Rx.make((get) =>
20
- pipe(
21
- get(node),
22
- Option.flatMap((node) => (node.id === ROOT_ID ? Option.some(node) : Option.none())),
23
- Option.map(() => [
24
- {
25
- id: COMMANDS_DIALOG,
26
- data: async () => {
27
- const { dispatchPromise: dispatch } = context.getCapability(Capabilities.IntentDispatcher);
28
- await dispatch(
29
- createIntent(LayoutAction.UpdateDialog, {
30
- part: 'dialog',
31
- subject: COMMANDS_DIALOG,
32
- options: {
33
- blockAlign: 'start',
34
- },
35
- }),
36
- );
37
- },
38
- properties: {
39
- label: ['open commands label', { ns: NAVTREE_PLUGIN }],
40
- icon: 'ph--magnifying-glass--regular',
41
- keyBinding: {
42
- macos: 'meta+k',
43
- windows: 'ctrl+k',
44
- },
45
- },
46
- },
47
- ]),
48
- Option.getOrElse(() => []),
49
- ),
50
- ),
51
- }),
52
- );
@@ -1,20 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import { defineCapability } from '@dxos/app-framework';
6
- import { type Live } from '@dxos/live-object';
7
-
8
- import { NAVTREE_PLUGIN } from '../meta';
9
- import { type NavTreeItemGraphNode } from '../types';
10
-
11
- export namespace NavTreeCapabilities {
12
- export const State = defineCapability<{
13
- state: Map<string, Live<{ open: boolean; current: boolean; alternateTree?: boolean }>>;
14
- getItem: (path: string[]) => Live<{ open: boolean; current: boolean; alternateTree?: boolean }>;
15
- setItem: (path: string[], key: 'open' | 'current' | 'alternateTree', next: boolean) => void;
16
- isOpen: (path: string[], item: NavTreeItemGraphNode) => boolean;
17
- isCurrent: (path: string[], item: NavTreeItemGraphNode) => boolean;
18
- isAlternateTree: (path: string[], item: NavTreeItemGraphNode) => boolean;
19
- }>(`${NAVTREE_PLUGIN}/capability/state`);
20
- }
@@ -1,37 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import { Schema } from 'effect';
6
-
7
- import { contributes, type PluginContext, Capabilities, createResolver, LayoutAction } from '@dxos/app-framework';
8
- import { log } from '@dxos/log';
9
-
10
- import { NavTreeCapabilities } from './capabilities';
11
-
12
- export default (context: PluginContext) =>
13
- contributes(
14
- Capabilities.IntentResolver,
15
- createResolver({
16
- intent: LayoutAction.UpdateLayout,
17
- filter: (data): data is Schema.Schema.Type<typeof LayoutAction.Expose.fields.input> =>
18
- Schema.is(LayoutAction.Expose.fields.input)(data),
19
- resolve: async ({ subject }) => {
20
- const { graph } = context.getCapability(Capabilities.AppGraph);
21
- const { getItem, setItem } = context.getCapability(NavTreeCapabilities.State);
22
-
23
- try {
24
- const path = await graph.waitForPath({ target: subject }, { timeout: 1_000 });
25
- [...Array(path.length)].forEach((_, index) => {
26
- const subpath = path.slice(0, index);
27
- const value = getItem(subpath);
28
- if (!value.open) {
29
- setItem(subpath, 'open', true);
30
- }
31
- });
32
- } catch {
33
- log('Path to node not found', { subject });
34
- }
35
- },
36
- }),
37
- );
@@ -1,59 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import { Capabilities as AppCapabilities, contributes, type PluginContext } from '@dxos/app-framework';
6
- import { debounce } from '@dxos/async';
7
- import { Keyboard } from '@dxos/keyboard';
8
- import { isAction, type Node } from '@dxos/plugin-graph';
9
- import { getHostPlatform } from '@dxos/util';
10
-
11
- import { KEY_BINDING } from '../meta';
12
-
13
- export default (context: PluginContext) => {
14
- const { graph } = context.getCapability(AppCapabilities.AppGraph);
15
-
16
- // TODO(wittjosiah): Factor out.
17
- // TODO(wittjosiah): Handle removal of actions.
18
- const visitor = (node: Node, path: string[]) => {
19
- let shortcut: string | undefined;
20
- if (typeof node.properties.keyBinding === 'object') {
21
- const availablePlatforms = Object.keys(node.properties.keyBinding);
22
- const platform = getHostPlatform();
23
- shortcut = availablePlatforms.includes(platform)
24
- ? node.properties.keyBinding[platform]
25
- : platform === 'ios'
26
- ? node.properties.keyBinding.macos // Fallback to macos if ios-specific bindings not provided.
27
- : platform === 'linux' || platform === 'unknown'
28
- ? node.properties.keyBinding.windows // Fallback to windows if platform-specific bindings not provided.
29
- : undefined;
30
- } else {
31
- shortcut = node.properties.keyBinding;
32
- }
33
-
34
- if (shortcut && isAction(node)) {
35
- Keyboard.singleton.getContext(path.slice(0, -1).join('/')).bind({
36
- shortcut,
37
- handler: () => {
38
- void node.data({ parent: node, caller: KEY_BINDING });
39
- },
40
- data: node.properties.label,
41
- });
42
- }
43
- };
44
-
45
- const eventHandler = debounce(() => {
46
- graph.traverse({ visitor });
47
- }, 500);
48
-
49
- const unsubscribe = graph.onNodeChanged.on(eventHandler);
50
-
51
- // TODO(burdon): Create context and plugin.
52
- Keyboard.singleton.initialize();
53
- Keyboard.singleton.setCurrentContext(graph.root.id);
54
-
55
- return contributes(AppCapabilities.Null, null, () => {
56
- unsubscribe();
57
- Keyboard.singleton.destroy();
58
- });
59
- };
@@ -1,45 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import React from 'react';
6
-
7
- import { Capabilities, contributes, createSurface } from '@dxos/app-framework';
8
- import { isGraphNode } from '@dxos/plugin-graph';
9
-
10
- import { CommandsDialogContent, CommandsTrigger, NavTreeDocumentTitle, NavTreeContainer } from '../components';
11
- import { COMMANDS_DIALOG, NAVTREE_PLUGIN } from '../meta';
12
-
13
- export default () =>
14
- contributes(Capabilities.ReactSurface, [
15
- createSurface({
16
- id: COMMANDS_DIALOG,
17
- role: 'dialog',
18
- filter: (data): data is { props: { selected?: string } } => data.component === COMMANDS_DIALOG,
19
- component: ({ data }) => <CommandsDialogContent {...data.props} />,
20
- }),
21
- createSurface({
22
- id: `${NAVTREE_PLUGIN}/navigation`,
23
- role: 'navigation',
24
- filter: (data): data is { popoverAnchorId?: string; topbar: boolean; current: string } =>
25
- typeof data.current === 'string',
26
- component: ({ data }) => (
27
- <NavTreeContainer
28
- tab={data.current}
29
- popoverAnchorId={data.popoverAnchorId as string | undefined}
30
- topbar={data.topbar as boolean}
31
- />
32
- ),
33
- }),
34
- createSurface({
35
- id: `${NAVTREE_PLUGIN}/document-title`,
36
- role: 'document-title',
37
- component: ({ data }) => <NavTreeDocumentTitle node={isGraphNode(data.subject) ? data.subject : undefined} />,
38
- }),
39
- createSurface({
40
- id: `${NAVTREE_PLUGIN}/search-input`,
41
- role: 'search-input',
42
- position: 'fallback',
43
- component: () => <CommandsTrigger />,
44
- }),
45
- ]);
@@ -1,104 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import { effect, untracked } from '@preact/signals-core';
6
-
7
- import { Capabilities, contributes, type PluginContext } from '@dxos/app-framework';
8
- import { type Live } from '@dxos/echo';
9
- import { live } from '@dxos/live-object';
10
- import { Path } from '@dxos/react-ui-list';
11
-
12
- import { NavTreeCapabilities } from './capabilities';
13
- import { NAVTREE_PLUGIN } from '../meta';
14
-
15
- const KEY = `${NAVTREE_PLUGIN}/state/v1`;
16
-
17
- const getInitialState = () => {
18
- const stringified = localStorage.getItem(KEY);
19
- if (!stringified) {
20
- return;
21
- }
22
-
23
- try {
24
- const cached: [string, { open: boolean; current: boolean }][] = JSON.parse(stringified);
25
- return cached.map(([key, value]): [string, Live<{ open: boolean; current: boolean }>] => [
26
- key,
27
- live({ open: value.open, current: false }),
28
- ]);
29
- } catch {}
30
- };
31
-
32
- export default (context: PluginContext) => {
33
- const layout = context.getCapability(Capabilities.Layout);
34
-
35
- // TODO(wittjosiah): This currently needs to be not a Live at the root.
36
- // If it is a Live then React errors when initializing new paths because of state change during render.
37
- // Ideally this could be a Live but be able to access and update the root level without breaking render.
38
- // Wrapping accesses and updates in `untracked` didn't seem to work in all cases.
39
- const state = new Map<string, Live<{ open: boolean; current: boolean; alternateTree?: boolean }>>(
40
- getInitialState() ?? [
41
- // TODO(thure): Initialize these dynamically.
42
- ['root', live({ open: true, current: false })],
43
- ['root~dxos.org/plugin/space-spaces', live({ open: true, current: false })],
44
- ['root~dxos.org/plugin/files', live({ open: true, current: false })],
45
- ],
46
- );
47
-
48
- const getItem = (_path: string[]) => {
49
- const path = Path.create(..._path);
50
- const value = state.get(path) ?? live({ open: false, current: false, alternateTree: false });
51
- if (!state.has(path)) {
52
- state.set(path, value);
53
- }
54
-
55
- return value;
56
- };
57
-
58
- const setItem = (path: string[], key: 'open' | 'current' | 'alternateTree', next: boolean) => {
59
- const value = getItem(path);
60
- value[key] = next;
61
-
62
- localStorage.setItem(KEY, JSON.stringify(Array.from(state.entries())));
63
- };
64
-
65
- const isOpen = (path: string[]) => getItem(path).open;
66
- const isCurrent = (path: string[]) => getItem(path).current;
67
- const isAlternateTree = (path: string[]) => {
68
- const item = getItem(path);
69
- return item.alternateTree ?? false;
70
- };
71
-
72
- let previous: string[] = [];
73
- const unsubscribe = effect(() => {
74
- const removed = previous.filter((id) => !layout.active.includes(id));
75
- previous = layout.active;
76
-
77
- const handleUpdate = () => {
78
- removed.forEach((id) => {
79
- const keys = Array.from(state.keys()).filter((key) => Path.last(key) === id);
80
- keys.forEach((key) => {
81
- setItem(Path.parts(key), 'current', false);
82
- });
83
- });
84
-
85
- layout.active.forEach((id) => {
86
- const keys = Array.from(new Set([...state.keys(), id])).filter((key) => Path.last(key) === id);
87
- keys.forEach((key) => {
88
- setItem(Path.parts(key), 'current', true);
89
- });
90
- });
91
- };
92
-
93
- // TODO(wittjosiah): This is setTimeout because there's a race between the keys be initialized.
94
- // Keys are initialized on the first render of an item in the navtree.
95
- // This could be avoided if the location was a path as well and not just an id.
96
- const timeout = setTimeout(handleUpdate, 500);
97
- untracked(() => handleUpdate());
98
- return () => clearTimeout(timeout);
99
- });
100
-
101
- return contributes(NavTreeCapabilities.State, { state, getItem, setItem, isOpen, isCurrent, isAlternateTree }, () =>
102
- unsubscribe(),
103
- );
104
- };
package/src/events.ts DELETED
@@ -1,11 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import { Events } from '@dxos/app-framework';
6
-
7
- import { NAVTREE_PLUGIN } from './meta';
8
-
9
- export namespace NavTreeEvents {
10
- export const StateReady = Events.createStateEvent(NAVTREE_PLUGIN);
11
- }