@dxos/plugin-navtree 0.8.4-main.fd6878d → 0.8.4-staging.60fe92afc8
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/LICENSE +102 -5
- package/PLUGIN.mdl +376 -0
- package/README.md +1 -1
- package/dist/lib/neutral/CommandsDialogContent-UBGIQ5FI.mjs +112 -0
- package/dist/lib/neutral/CommandsDialogContent-UBGIQ5FI.mjs.map +7 -0
- package/dist/lib/neutral/CommandsTrigger-BH5WLMHK.mjs +27 -0
- package/dist/lib/neutral/CommandsTrigger-BH5WLMHK.mjs.map +7 -0
- package/dist/lib/neutral/NavTreeContainer-6AR4BFDD.mjs +12 -0
- package/dist/lib/neutral/NavTreeContainer-6AR4BFDD.mjs.map +7 -0
- package/dist/lib/neutral/NavTreeDocumentTitle-H3E6ZLYE.mjs +22 -0
- package/dist/lib/neutral/NavTreeDocumentTitle-H3E6ZLYE.mjs.map +7 -0
- package/dist/lib/neutral/NavTreePlugin.mjs +68 -0
- package/dist/lib/neutral/NavTreePlugin.mjs.map +7 -0
- package/dist/lib/neutral/NavTreePlugin.node.mjs +18 -0
- package/dist/lib/neutral/NavTreePlugin.node.mjs.map +7 -0
- package/dist/lib/neutral/NavTreePlugin.workerd.mjs +16 -0
- package/dist/lib/neutral/NavTreePlugin.workerd.mjs.map +7 -0
- package/dist/lib/neutral/app-graph-builder-Z347LKSF.mjs +42 -0
- package/dist/lib/neutral/app-graph-builder-Z347LKSF.mjs.map +7 -0
- package/dist/lib/neutral/capabilities/index.mjs +17 -0
- package/dist/lib/neutral/capabilities/index.mjs.map +7 -0
- package/dist/lib/neutral/chunk-5OPDKH6B.mjs +273 -0
- package/dist/lib/neutral/chunk-5OPDKH6B.mjs.map +7 -0
- package/dist/lib/neutral/chunk-J5LGTIGS.mjs +10 -0
- package/dist/lib/neutral/chunk-J5LGTIGS.mjs.map +7 -0
- package/dist/lib/neutral/chunk-JOSNCOV4.mjs +79 -0
- package/dist/lib/neutral/chunk-JOSNCOV4.mjs.map +7 -0
- package/dist/lib/neutral/chunk-MDGKDQMZ.mjs +37 -0
- package/dist/lib/neutral/chunk-MDGKDQMZ.mjs.map +7 -0
- package/dist/lib/neutral/chunk-T7QS2EFI.mjs +8 -0
- package/dist/lib/neutral/chunk-T7QS2EFI.mjs.map +7 -0
- package/dist/lib/neutral/chunk-ZSWYB7JW.mjs +27 -0
- package/dist/lib/neutral/chunk-ZSWYB7JW.mjs.map +7 -0
- package/dist/lib/neutral/components/index.mjs +805 -0
- package/dist/lib/neutral/components/index.mjs.map +7 -0
- package/dist/lib/neutral/containers/index.mjs +20 -0
- package/dist/lib/neutral/containers/index.mjs.map +7 -0
- package/dist/lib/neutral/expose-26FV4W5D.mjs +38 -0
- package/dist/lib/neutral/expose-26FV4W5D.mjs.map +7 -0
- package/dist/lib/neutral/hooks/index.mjs +178 -0
- package/dist/lib/neutral/hooks/index.mjs.map +7 -0
- package/dist/lib/neutral/index.mjs +34 -0
- package/dist/lib/neutral/index.mjs.map +7 -0
- package/dist/lib/{browser/keyboard-HMTMA33N.mjs → neutral/keyboard-EJ65BVTC.mjs} +25 -20
- package/dist/lib/neutral/keyboard-EJ65BVTC.mjs.map +7 -0
- package/dist/lib/neutral/meta.json +1 -0
- package/dist/lib/neutral/meta.mjs +12 -0
- package/dist/lib/neutral/meta.mjs.map +7 -0
- package/dist/lib/neutral/operation-handler-ORDOJUL2.mjs +13 -0
- package/dist/lib/neutral/operation-handler-ORDOJUL2.mjs.map +7 -0
- package/dist/lib/neutral/operations/index.mjs +8 -0
- package/dist/lib/neutral/operations/index.mjs.map +7 -0
- package/dist/lib/neutral/plugin.mjs +16 -0
- package/dist/lib/neutral/plugin.mjs.map +7 -0
- package/dist/lib/neutral/react-surface-Q5XMAG7Z.mjs +50 -0
- package/dist/lib/neutral/react-surface-Q5XMAG7Z.mjs.map +7 -0
- package/dist/lib/neutral/state-VVJEWUHM.mjs +126 -0
- package/dist/lib/neutral/state-VVJEWUHM.mjs.map +7 -0
- package/dist/lib/neutral/testing/index.mjs +439 -0
- package/dist/lib/neutral/testing/index.mjs.map +7 -0
- package/dist/lib/neutral/translations.mjs +23 -0
- package/dist/lib/neutral/translations.mjs.map +7 -0
- package/dist/lib/neutral/types/index.mjs +10 -0
- package/dist/lib/neutral/types/index.mjs.map +7 -0
- package/dist/types/src/NavTreePlugin.d.ts +3 -1
- package/dist/types/src/NavTreePlugin.d.ts.map +1 -1
- package/dist/types/src/NavTreePlugin.node.d.ts +4 -0
- package/dist/types/src/NavTreePlugin.node.d.ts.map +1 -0
- package/dist/types/src/NavTreePlugin.test.d.ts +2 -0
- package/dist/types/src/NavTreePlugin.test.d.ts.map +1 -0
- package/dist/types/src/NavTreePlugin.workerd.d.ts +4 -0
- package/dist/types/src/NavTreePlugin.workerd.d.ts.map +1 -0
- package/dist/types/src/capabilities/app-graph-builder.d.ts +4 -2
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts +7 -105
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/keyboard.d.ts +3 -2
- package/dist/types/src/capabilities/keyboard.d.ts.map +1 -1
- package/dist/types/src/capabilities/operation-handler.d.ts +6 -0
- package/dist/types/src/capabilities/operation-handler.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface.d.ts +3 -2
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/capabilities/state.d.ts +4 -18
- package/dist/types/src/capabilities/state.d.ts.map +1 -1
- package/dist/types/src/components/NavTree/NavTree.d.ts +11 -4
- package/dist/types/src/components/NavTree/NavTree.d.ts.map +1 -1
- package/dist/types/src/components/NavTree/NavTree.stories.d.ts +25 -5
- package/dist/types/src/components/NavTree/NavTree.stories.d.ts.map +1 -1
- package/dist/types/src/components/{NavTreeContext.d.ts → NavTreeContext/NavTreeContext.d.ts} +1 -1
- package/dist/types/src/components/NavTreeContext/NavTreeContext.d.ts.map +1 -0
- package/dist/types/src/components/NavTreeContext/index.d.ts +2 -0
- package/dist/types/src/components/NavTreeContext/index.d.ts.map +1 -0
- package/dist/types/src/components/NavTreeItem/NavTreeItemAction.d.ts +13 -9
- package/dist/types/src/components/NavTreeItem/NavTreeItemAction.d.ts.map +1 -1
- package/dist/types/src/components/NavTreeItem/NavTreeItemAction.stories.d.ts +33 -4
- package/dist/types/src/components/NavTreeItem/NavTreeItemAction.stories.d.ts.map +1 -1
- package/dist/types/src/components/NavTreeItem/NavTreeItemColumns.d.ts +1 -1
- package/dist/types/src/components/NavTreeItem/NavTreeItemColumns.d.ts.map +1 -1
- package/dist/types/src/components/Sidebar/L0Menu.d.ts +10 -5
- package/dist/types/src/components/Sidebar/L0Menu.d.ts.map +1 -1
- package/dist/types/src/components/Sidebar/L1Panel.d.ts +4 -7
- package/dist/types/src/components/Sidebar/L1Panel.d.ts.map +1 -1
- package/dist/types/src/components/Sidebar/L1Tabs.d.ts +5 -4
- package/dist/types/src/components/Sidebar/L1Tabs.d.ts.map +1 -1
- package/dist/types/src/components/UserAccountAvatar/UserAccountAvatar.d.ts.map +1 -1
- package/dist/types/src/components/UserAccountAvatar/UserAccountAvatar.stories.d.ts +8 -5
- package/dist/types/src/components/UserAccountAvatar/UserAccountAvatar.stories.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +0 -3
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/components/types.d.ts +8 -17
- package/dist/types/src/components/types.d.ts.map +1 -1
- package/dist/types/src/containers/CommandsDialogContent/CommandsDialogContent.d.ts +6 -0
- package/dist/types/src/containers/CommandsDialogContent/CommandsDialogContent.d.ts.map +1 -0
- package/dist/types/src/containers/CommandsDialogContent/CommandsDialogContent.stories.d.ts +28 -0
- package/dist/types/src/containers/CommandsDialogContent/CommandsDialogContent.stories.d.ts.map +1 -0
- package/dist/types/src/containers/CommandsDialogContent/index.d.ts +2 -0
- package/dist/types/src/containers/CommandsDialogContent/index.d.ts.map +1 -0
- package/dist/types/src/containers/CommandsTrigger/CommandsTrigger.d.ts.map +1 -0
- package/dist/types/src/containers/CommandsTrigger/index.d.ts +2 -0
- package/dist/types/src/containers/CommandsTrigger/index.d.ts.map +1 -0
- package/dist/types/src/containers/NavTreeContainer/NavTreeContainer.d.ts +9 -0
- package/dist/types/src/containers/NavTreeContainer/NavTreeContainer.d.ts.map +1 -0
- package/dist/types/src/containers/NavTreeContainer/index.d.ts +3 -0
- package/dist/types/src/containers/NavTreeContainer/index.d.ts.map +1 -0
- package/dist/types/src/{components → containers/NavTreeDocumentTitle}/NavTreeDocumentTitle.d.ts +1 -1
- package/dist/types/src/containers/NavTreeDocumentTitle/NavTreeDocumentTitle.d.ts.map +1 -0
- package/dist/types/src/containers/NavTreeDocumentTitle/index.d.ts +2 -0
- package/dist/types/src/containers/NavTreeDocumentTitle/index.d.ts.map +1 -0
- package/dist/types/src/containers/index.d.ts +7 -0
- package/dist/types/src/containers/index.d.ts.map +1 -0
- package/dist/types/src/experimental/Tree.d.ts +3 -4
- package/dist/types/src/experimental/Tree.d.ts.map +1 -1
- package/dist/types/src/experimental/Tree.stories.d.ts +23 -6
- package/dist/types/src/experimental/Tree.stories.d.ts.map +1 -1
- package/dist/types/src/hooks/index.d.ts +5 -0
- package/dist/types/src/hooks/index.d.ts.map +1 -0
- package/dist/types/src/hooks/useActions.d.ts +11 -0
- package/dist/types/src/hooks/useActions.d.ts.map +1 -0
- package/dist/types/src/hooks/useLoadDescendents.d.ts +6 -0
- package/dist/types/src/hooks/useLoadDescendents.d.ts.map +1 -0
- package/dist/types/src/hooks/useNavTreeModel.d.ts +7 -0
- package/dist/types/src/hooks/useNavTreeModel.d.ts.map +1 -0
- package/dist/types/src/hooks/useNavTreeState.d.ts +18 -0
- package/dist/types/src/hooks/useNavTreeState.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +1 -3
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +4 -4
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/operations/expose.d.ts +5 -0
- package/dist/types/src/operations/expose.d.ts.map +1 -0
- package/dist/types/src/operations/index.d.ts +3 -0
- package/dist/types/src/operations/index.d.ts.map +1 -0
- package/dist/types/src/plugin.d.ts +4 -0
- package/dist/types/src/plugin.d.ts.map +1 -0
- package/dist/types/src/testing/app-graph-builder.d.ts +2 -3
- package/dist/types/src/testing/app-graph-builder.d.ts.map +1 -1
- package/dist/types/src/testing/generator.d.ts +5 -6
- package/dist/types/src/testing/generator.d.ts.map +1 -1
- package/dist/types/src/testing/update-state.d.ts +2 -2
- package/dist/types/src/testing/update-state.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +8 -11
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/NavTreeCapabilities.d.ts +13 -0
- package/dist/types/src/types/NavTreeCapabilities.d.ts.map +1 -0
- package/dist/types/src/types/NavTreeEvents.d.ts +3 -0
- package/dist/types/src/types/NavTreeEvents.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +4 -0
- package/dist/types/src/types/index.d.ts.map +1 -0
- package/dist/types/src/{types.d.ts → types/schema.d.ts} +14 -9
- package/dist/types/src/types/schema.d.ts.map +1 -0
- package/dist/types/src/util.d.ts +12 -8
- package/dist/types/src/util.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +124 -62
- package/src/NavTreePlugin.node.ts +17 -0
- package/src/NavTreePlugin.test.ts +27 -0
- package/src/NavTreePlugin.tsx +56 -87
- package/src/NavTreePlugin.workerd.ts +16 -0
- package/src/capabilities/app-graph-builder.ts +34 -44
- package/src/capabilities/index.ts +10 -8
- package/src/capabilities/keyboard.ts +58 -51
- package/src/capabilities/operation-handler.ts +16 -0
- package/src/capabilities/react-surface.tsx +46 -38
- package/src/capabilities/state.ts +132 -84
- package/src/components/NavTree/NavTree.stories.tsx +112 -106
- package/src/components/NavTree/NavTree.tsx +69 -33
- package/src/components/{NavTreeContext.tsx → NavTreeContext/NavTreeContext.tsx} +1 -1
- package/src/components/NavTreeContext/index.ts +5 -0
- package/src/components/NavTreeItem/NavTreeItemAction.stories.tsx +25 -19
- package/src/components/NavTreeItem/NavTreeItemAction.tsx +78 -54
- package/src/components/NavTreeItem/NavTreeItemColumns.tsx +40 -51
- package/src/components/Sidebar/L0Menu.tsx +182 -210
- package/src/components/Sidebar/L1Panel.tsx +185 -110
- package/src/components/Sidebar/L1Tabs.tsx +18 -34
- package/src/components/UserAccountAvatar/UserAccountAvatar.stories.tsx +9 -9
- package/src/components/UserAccountAvatar/UserAccountAvatar.tsx +20 -12
- package/src/components/index.ts +1 -3
- package/src/components/types.ts +13 -19
- package/src/containers/CommandsDialogContent/CommandsDialogContent.stories.tsx +46 -0
- package/src/containers/CommandsDialogContent/CommandsDialogContent.tsx +127 -0
- package/src/containers/CommandsDialogContent/index.ts +5 -0
- package/src/containers/CommandsTrigger/CommandsTrigger.tsx +28 -0
- package/src/containers/CommandsTrigger/index.ts +5 -0
- package/src/containers/NavTreeContainer/NavTreeContainer.tsx +271 -0
- package/src/containers/NavTreeContainer/index.ts +6 -0
- package/src/{components → containers/NavTreeDocumentTitle}/NavTreeDocumentTitle.tsx +5 -4
- package/src/containers/NavTreeDocumentTitle/index.ts +5 -0
- package/src/containers/index.ts +12 -0
- package/src/experimental/Tree.stories.tsx +105 -110
- package/src/experimental/Tree.tsx +7 -24
- package/src/hooks/index.ts +8 -0
- package/src/hooks/useActions.ts +44 -0
- package/src/hooks/useLoadDescendents.ts +23 -0
- package/src/hooks/useNavTreeModel.ts +120 -0
- package/src/hooks/useNavTreeState.ts +35 -0
- package/src/index.ts +1 -3
- package/src/meta.ts +26 -8
- package/src/operations/expose.ts +42 -0
- package/src/operations/index.ts +7 -0
- package/src/plugin.ts +11 -0
- package/src/testing/app-graph-builder.ts +169 -238
- package/src/testing/generator.ts +36 -39
- package/src/testing/update-state.ts +6 -6
- package/src/translations.ts +8 -10
- package/src/types/NavTreeCapabilities.ts +21 -0
- package/src/types/NavTreeEvents.ts +12 -0
- package/src/types/index.ts +8 -0
- package/src/{types.ts → types/schema.ts} +13 -8
- package/src/util.ts +28 -17
- package/src/vite-env.d.ts +10 -0
- package/dist/lib/browser/app-graph-builder-6JDBQ25U.mjs +0 -45
- package/dist/lib/browser/app-graph-builder-6JDBQ25U.mjs.map +0 -7
- package/dist/lib/browser/chunk-ERDGQTH5.mjs +0 -16
- package/dist/lib/browser/chunk-ERDGQTH5.mjs.map +0 -7
- package/dist/lib/browser/chunk-SNGLGBFJ.mjs +0 -1469
- package/dist/lib/browser/chunk-SNGLGBFJ.mjs.map +0 -7
- package/dist/lib/browser/chunk-WCARAZ7J.mjs +0 -15
- package/dist/lib/browser/chunk-WCARAZ7J.mjs.map +0 -7
- package/dist/lib/browser/index.mjs +0 -148
- package/dist/lib/browser/index.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-N35ZIHFD.mjs +0 -47
- package/dist/lib/browser/intent-resolver-N35ZIHFD.mjs.map +0 -7
- package/dist/lib/browser/keyboard-HMTMA33N.mjs.map +0 -7
- package/dist/lib/browser/meta.json +0 -1
- package/dist/lib/browser/react-surface-WKWXMM2N.mjs +0 -51
- package/dist/lib/browser/react-surface-WKWXMM2N.mjs.map +0 -7
- package/dist/lib/browser/state-P5DGL7KS.mjs +0 -117
- package/dist/lib/browser/state-P5DGL7KS.mjs.map +0 -7
- package/dist/types/src/capabilities/capabilities.d.ts +0 -21
- package/dist/types/src/capabilities/capabilities.d.ts.map +0 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
- package/dist/types/src/components/CommandsDialog/CommandsDialog.d.ts +0 -5
- package/dist/types/src/components/CommandsDialog/CommandsDialog.d.ts.map +0 -1
- package/dist/types/src/components/CommandsDialog/CommandsTrigger.d.ts.map +0 -1
- package/dist/types/src/components/CommandsDialog/index.d.ts +0 -3
- package/dist/types/src/components/CommandsDialog/index.d.ts.map +0 -1
- package/dist/types/src/components/NavTreeContainer.d.ts +0 -9
- package/dist/types/src/components/NavTreeContainer.d.ts.map +0 -1
- package/dist/types/src/components/NavTreeContext.d.ts.map +0 -1
- package/dist/types/src/components/NavTreeDocumentTitle.d.ts.map +0 -1
- package/dist/types/src/events.d.ts +0 -4
- package/dist/types/src/events.d.ts.map +0 -1
- package/dist/types/src/hooks.d.ts +0 -3
- package/dist/types/src/hooks.d.ts.map +0 -1
- package/dist/types/src/types.d.ts.map +0 -1
- package/src/capabilities/capabilities.ts +0 -20
- package/src/capabilities/intent-resolver.ts +0 -37
- package/src/components/CommandsDialog/CommandsDialog.tsx +0 -118
- package/src/components/CommandsDialog/CommandsTrigger.tsx +0 -35
- package/src/components/CommandsDialog/index.ts +0 -6
- package/src/components/NavTreeContainer.tsx +0 -337
- package/src/events.ts +0 -11
- package/src/hooks.ts +0 -21
- /package/dist/types/src/{components/CommandsDialog → containers/CommandsTrigger}/CommandsTrigger.d.ts +0 -0
|
@@ -2,58 +2,65 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
6
|
+
|
|
7
|
+
import { Capabilities, Capability } from '@dxos/app-framework';
|
|
8
|
+
import { AppCapabilities } from '@dxos/app-toolkit';
|
|
6
9
|
import { debounce } from '@dxos/async';
|
|
7
10
|
import { Keyboard } from '@dxos/keyboard';
|
|
8
|
-
import {
|
|
11
|
+
import { Graph, Node, runAction } from '@dxos/plugin-graph';
|
|
9
12
|
import { getHostPlatform } from '@dxos/util';
|
|
10
13
|
|
|
11
|
-
import { KEY_BINDING } from '
|
|
12
|
-
|
|
13
|
-
export default (
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
14
|
+
import { KEY_BINDING } from '#meta';
|
|
15
|
+
|
|
16
|
+
export default Capability.makeModule(
|
|
17
|
+
Effect.fnUntraced(function* () {
|
|
18
|
+
const { graph } = yield* Capability.get(AppCapabilities.AppGraph);
|
|
19
|
+
const invoker = yield* Capability.get(Capabilities.OperationInvoker);
|
|
20
|
+
const pluginContext = yield* Capability.Service;
|
|
21
|
+
|
|
22
|
+
// TODO(wittjosiah): Factor out.
|
|
23
|
+
// TODO(wittjosiah): Handle removal of actions.
|
|
24
|
+
const visitor = (node: Node.Node, path: string[]) => {
|
|
25
|
+
let shortcut: string | undefined;
|
|
26
|
+
if (typeof node.properties.keyBinding === 'object') {
|
|
27
|
+
const availablePlatforms = Object.keys(node.properties.keyBinding);
|
|
28
|
+
const platform = getHostPlatform();
|
|
29
|
+
shortcut = availablePlatforms.includes(platform)
|
|
30
|
+
? node.properties.keyBinding[platform]
|
|
31
|
+
: platform === 'ios'
|
|
32
|
+
? node.properties.keyBinding.macos // Fallback to macos if ios-specific bindings not provided.
|
|
33
|
+
: platform === 'linux' || platform === 'unknown'
|
|
34
|
+
? node.properties.keyBinding.windows // Fallback to windows if platform-specific bindings not provided.
|
|
35
|
+
: undefined;
|
|
36
|
+
} else {
|
|
37
|
+
shortcut = node.properties.keyBinding;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (shortcut && Node.isAction(node)) {
|
|
41
|
+
Keyboard.singleton.getContext(path.slice(0, -1).join('/')).bind({
|
|
42
|
+
shortcut,
|
|
43
|
+
handler: () => void runAction(invoker, pluginContext, node, { parent: node, caller: KEY_BINDING }),
|
|
44
|
+
data: node.properties.label,
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const eventHandler = debounce(() => {
|
|
50
|
+
Graph.traverse(graph, { relation: ['child', 'action'], visitor });
|
|
51
|
+
}, 500);
|
|
52
|
+
|
|
53
|
+
const unsubscribe = graph.onNodeChanged.on(eventHandler);
|
|
54
|
+
|
|
55
|
+
// TODO(burdon): Create context and plugin.
|
|
56
|
+
Keyboard.singleton.initialize();
|
|
57
|
+
Keyboard.singleton.setCurrentContext(Node.RootId);
|
|
58
|
+
|
|
59
|
+
return Capability.contributes(Capabilities.Null, null, () =>
|
|
60
|
+
Effect.sync(() => {
|
|
61
|
+
unsubscribe();
|
|
62
|
+
Keyboard.singleton.destroy();
|
|
63
|
+
}),
|
|
64
|
+
);
|
|
65
|
+
}),
|
|
66
|
+
);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
6
|
+
|
|
7
|
+
import { Capabilities, Capability } from '@dxos/app-framework';
|
|
8
|
+
import type { OperationHandlerSet } from '@dxos/compute';
|
|
9
|
+
|
|
10
|
+
import { NavTreeOperationHandlerSet } from '#operations';
|
|
11
|
+
|
|
12
|
+
export default Capability.makeModule<OperationHandlerSet.OperationHandlerSet>(
|
|
13
|
+
Effect.fnUntraced(function* () {
|
|
14
|
+
return Capability.contributes(Capabilities.OperationHandler, NavTreeOperationHandlerSet);
|
|
15
|
+
}),
|
|
16
|
+
);
|
|
@@ -2,44 +2,52 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
6
|
+
import React, { type ComponentProps } from 'react';
|
|
6
7
|
|
|
7
|
-
import { Capabilities,
|
|
8
|
-
import {
|
|
8
|
+
import { Capabilities, Capability } from '@dxos/app-framework';
|
|
9
|
+
import { Surface } from '@dxos/app-framework/ui';
|
|
10
|
+
import { AppSurface } from '@dxos/app-toolkit/ui';
|
|
11
|
+
import { Node } from '@dxos/plugin-graph';
|
|
9
12
|
|
|
10
|
-
import { CommandsDialogContent, CommandsTrigger, NavTreeContainer, NavTreeDocumentTitle } from '
|
|
11
|
-
import { COMMANDS_DIALOG
|
|
13
|
+
import { CommandsDialogContent, CommandsTrigger, NavTreeContainer, NavTreeDocumentTitle } from '#containers';
|
|
14
|
+
import { COMMANDS_DIALOG } from '#meta';
|
|
12
15
|
|
|
13
|
-
export default () =>
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
16
|
+
export default Capability.makeModule(() =>
|
|
17
|
+
Effect.succeed(
|
|
18
|
+
Capability.contributes(Capabilities.ReactSurface, [
|
|
19
|
+
Surface.create({
|
|
20
|
+
id: COMMANDS_DIALOG,
|
|
21
|
+
filter: AppSurface.component<ComponentProps<typeof CommandsDialogContent>>(AppSurface.Dialog, COMMANDS_DIALOG),
|
|
22
|
+
component: ({ data, ref }) => <CommandsDialogContent {...data.props} ref={ref} />,
|
|
23
|
+
}),
|
|
24
|
+
Surface.create({
|
|
25
|
+
id: 'navigation',
|
|
26
|
+
role: 'navigation',
|
|
27
|
+
filter: (data): data is { popoverAnchorId?: string; current: string } => typeof data.current === 'string',
|
|
28
|
+
component: ({ data, ref }) => {
|
|
29
|
+
return (
|
|
30
|
+
<NavTreeContainer
|
|
31
|
+
tab={data.current}
|
|
32
|
+
popoverAnchorId={data.popoverAnchorId as string | undefined}
|
|
33
|
+
ref={ref}
|
|
34
|
+
/>
|
|
35
|
+
);
|
|
36
|
+
},
|
|
37
|
+
}),
|
|
38
|
+
Surface.create({
|
|
39
|
+
id: 'documentTitle',
|
|
40
|
+
role: 'document-title',
|
|
41
|
+
component: ({ data }) => (
|
|
42
|
+
<NavTreeDocumentTitle node={Node.isGraphNode(data.subject) ? data.subject : undefined} />
|
|
43
|
+
),
|
|
44
|
+
}),
|
|
45
|
+
Surface.create({
|
|
46
|
+
id: 'searchInput',
|
|
47
|
+
role: 'search-input',
|
|
48
|
+
position: 'last',
|
|
49
|
+
component: () => <CommandsTrigger />,
|
|
50
|
+
}),
|
|
51
|
+
]),
|
|
52
|
+
),
|
|
53
|
+
);
|
|
@@ -2,104 +2,152 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { Atom } from '@effect-atom/atom-react';
|
|
6
|
+
import * as Effect from 'effect/Effect';
|
|
6
7
|
|
|
7
|
-
import { Capabilities,
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
8
|
+
import { Capabilities, Capability } from '@dxos/app-framework';
|
|
9
|
+
import { AppCapabilities } from '@dxos/app-toolkit';
|
|
10
|
+
import { Graph, Node } from '@dxos/plugin-graph';
|
|
10
11
|
import { Path } from '@dxos/react-ui-list';
|
|
11
12
|
|
|
12
|
-
import {
|
|
13
|
+
import { meta } from '#meta';
|
|
14
|
+
import { NavTreeCapabilities } from '#types';
|
|
13
15
|
|
|
14
|
-
|
|
16
|
+
const KEY = `${meta.id}.state.v1`;
|
|
15
17
|
|
|
16
|
-
|
|
18
|
+
/** Default item state for new entries. */
|
|
19
|
+
const defaultItemState: NavTreeCapabilities.NavTreeItemState = { open: false, current: false };
|
|
17
20
|
|
|
18
|
-
|
|
21
|
+
/** L0 (top-level workspace) paths are direct children of root — not part of the expandable tree model. */
|
|
22
|
+
const isTopLevelPath = (path: string[]): boolean => path.length === 2 && path[0] === Node.RootId;
|
|
23
|
+
|
|
24
|
+
/** Default state entries for initial tree structure. */
|
|
25
|
+
// TODO(thure): Initialize these dynamically.
|
|
26
|
+
const defaultStateEntries: [string, NavTreeCapabilities.NavTreeItemState][] = [
|
|
27
|
+
['root', { open: true, current: false }],
|
|
28
|
+
];
|
|
29
|
+
|
|
30
|
+
const getInitialState = (): Map<string, NavTreeCapabilities.NavTreeItemState> => {
|
|
19
31
|
const stringified = localStorage.getItem(KEY);
|
|
20
32
|
if (!stringified) {
|
|
21
|
-
return;
|
|
33
|
+
return new Map(defaultStateEntries);
|
|
22
34
|
}
|
|
23
35
|
|
|
24
36
|
try {
|
|
25
37
|
const cached: [string, { open: boolean; current: boolean }][] = JSON.parse(stringified);
|
|
26
|
-
return cached.map(([key, value])
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
} catch {}
|
|
38
|
+
return new Map(cached.map(([key, value]) => [key, { open: value.open, current: false }]));
|
|
39
|
+
} catch {
|
|
40
|
+
return new Map(defaultStateEntries);
|
|
41
|
+
}
|
|
31
42
|
};
|
|
32
43
|
|
|
33
|
-
export default (
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
const setItem = (path: string[], key: 'open' | 'current' | 'alternateTree', next: boolean) => {
|
|
60
|
-
const value = getItem(path);
|
|
61
|
-
value[key] = next;
|
|
62
|
-
|
|
63
|
-
localStorage.setItem(KEY, JSON.stringify(Array.from(state.entries())));
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
const isOpen = (path: string[]) => getItem(path).open;
|
|
67
|
-
const isCurrent = (path: string[]) => getItem(path).current;
|
|
68
|
-
const isAlternateTree = (path: string[]) => {
|
|
69
|
-
const item = getItem(path);
|
|
70
|
-
return item.alternateTree ?? false;
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
let previous: string[] = [];
|
|
74
|
-
const unsubscribe = effect(() => {
|
|
75
|
-
const removed = previous.filter((id) => !layout.active.includes(id));
|
|
76
|
-
previous = layout.active;
|
|
77
|
-
|
|
78
|
-
const handleUpdate = () => {
|
|
79
|
-
removed.forEach((id) => {
|
|
80
|
-
const keys = Array.from(state.keys()).filter((key) => Path.last(key) === id);
|
|
81
|
-
keys.forEach((key) => {
|
|
82
|
-
setItem(Path.parts(key), 'current', false);
|
|
83
|
-
});
|
|
84
|
-
});
|
|
44
|
+
export default Capability.makeModule(
|
|
45
|
+
Effect.fnUntraced(function* () {
|
|
46
|
+
const registry = yield* Capability.get(Capabilities.AtomRegistry);
|
|
47
|
+
const layoutAtom = yield* Capability.get(AppCapabilities.Layout);
|
|
48
|
+
|
|
49
|
+
// Backing state for persistence (not reactive).
|
|
50
|
+
const backingState = getInitialState();
|
|
51
|
+
|
|
52
|
+
// Per-path atom family for fine-grained reactivity.
|
|
53
|
+
// keepAlive prevents atoms from being garbage collected when components unmount,
|
|
54
|
+
// ensuring state is preserved across deletion/restoration cycles.
|
|
55
|
+
const itemAtomFamily = Atom.family((pathString: string) =>
|
|
56
|
+
Atom.make<NavTreeCapabilities.NavTreeItemState>(backingState.get(pathString) ?? { ...defaultItemState }).pipe(
|
|
57
|
+
Atom.keepAlive,
|
|
58
|
+
),
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
const getItemAtom = (path: string[]): Atom.Atom<NavTreeCapabilities.NavTreeItemState> => {
|
|
62
|
+
const pathString = Path.create(...path);
|
|
63
|
+
if (!backingState.has(pathString)) {
|
|
64
|
+
backingState.set(pathString, { ...defaultItemState });
|
|
65
|
+
}
|
|
66
|
+
return itemAtomFamily(pathString);
|
|
67
|
+
};
|
|
85
68
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
keys.forEach((key) => {
|
|
89
|
-
setItem(Path.parts(key), 'current', true);
|
|
90
|
-
});
|
|
91
|
-
});
|
|
69
|
+
const getItem = (path: string[]): NavTreeCapabilities.NavTreeItemState => {
|
|
70
|
+
return registry.get(getItemAtom(path));
|
|
92
71
|
};
|
|
93
72
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
}
|
|
73
|
+
const setItem = (path: string[], key: 'open' | 'current', next: boolean) => {
|
|
74
|
+
const pathString = Path.create(...path);
|
|
75
|
+
const atom = itemAtomFamily(pathString);
|
|
76
|
+
const currentValue = registry.get(atom);
|
|
77
|
+
const newValue = { ...currentValue, [key]: next };
|
|
78
|
+
|
|
79
|
+
registry.set(atom, newValue);
|
|
80
|
+
|
|
81
|
+
if (!(key === 'open' && isTopLevelPath(path))) {
|
|
82
|
+
backingState.set(pathString, newValue);
|
|
83
|
+
localStorage.setItem(KEY, JSON.stringify(Array.from(backingState.entries())));
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
// Subscribe to layout changes to update current state.
|
|
88
|
+
let previous: string[] = [];
|
|
89
|
+
const unsubscribe = registry.subscribe(layoutAtom, (layout) => {
|
|
90
|
+
const removed = previous.filter((id) => !layout.active.includes(id));
|
|
91
|
+
previous = layout.active;
|
|
92
|
+
|
|
93
|
+
const handleUpdate = () => {
|
|
94
|
+
// Mark removed items as not current.
|
|
95
|
+
removed.forEach((id) => {
|
|
96
|
+
const keys = Array.from(backingState.keys()).filter((key) => Path.last(key) === id);
|
|
97
|
+
keys.forEach((key) => {
|
|
98
|
+
setItem(Path.parts(key), 'current', false);
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
// Mark active items as current.
|
|
103
|
+
layout.active.forEach((id: string) => {
|
|
104
|
+
const keys = Array.from(new Set([...backingState.keys(), id])).filter((key) => Path.last(key) === id);
|
|
105
|
+
keys.forEach((key) => {
|
|
106
|
+
setItem(Path.parts(key), 'current', true);
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
// TODO(wittjosiah): This is setTimeout because there's a race between the keys being initialized.
|
|
112
|
+
// Keys are initialized on the first render of an item in the navtree.
|
|
113
|
+
// This could be avoided if the location was a path as well and not just an id.
|
|
114
|
+
// Defer so item path atoms exist and we do not setState during tree render.
|
|
115
|
+
const timeout = setTimeout(handleUpdate, 500);
|
|
116
|
+
return () => clearTimeout(timeout);
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
// Once graph is ready, expand every node marked open in state so the graph has children loaded for rendering.
|
|
120
|
+
yield* Effect.gen(function* () {
|
|
121
|
+
const { graph } = yield* Capability.waitFor(AppCapabilities.AppGraph);
|
|
122
|
+
|
|
123
|
+
// Always expand the active workspace so its subtree is initialized.
|
|
124
|
+
const layout = registry.get(layoutAtom);
|
|
125
|
+
if (layout.workspace) {
|
|
126
|
+
Graph.expand(graph, layout.workspace, 'child');
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// Expand persisted open nodes, skipping inactive workspace tabs.
|
|
130
|
+
const openPaths = Array.from(backingState.entries())
|
|
131
|
+
.filter(([, state]) => state.open)
|
|
132
|
+
.map(([pathString]) => Path.parts(pathString))
|
|
133
|
+
.filter((path) => !isTopLevelPath(path));
|
|
134
|
+
for (const path of openPaths) {
|
|
135
|
+
const nodeId = path[path.length - 1];
|
|
136
|
+
if (!nodeId) {
|
|
137
|
+
continue;
|
|
138
|
+
}
|
|
139
|
+
Graph.expand(graph, nodeId, 'child');
|
|
140
|
+
}
|
|
141
|
+
}).pipe(Effect.forkDaemon);
|
|
142
|
+
|
|
143
|
+
return Capability.contributes(
|
|
144
|
+
NavTreeCapabilities.State,
|
|
145
|
+
{
|
|
146
|
+
getItem,
|
|
147
|
+
getItemAtom,
|
|
148
|
+
setItem,
|
|
149
|
+
},
|
|
150
|
+
() => Effect.sync(() => unsubscribe()),
|
|
151
|
+
);
|
|
152
|
+
}),
|
|
153
|
+
);
|