@dxos/plugin-simple-layout 0.8.4-main.c85a9c8dae → 0.8.4-main.fcc0d83b33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/index.mjs +15 -68
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/translations.mjs +34 -0
- package/dist/lib/browser/translations.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +15 -67
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/translations.mjs +36 -0
- package/dist/lib/node-esm/translations.mjs.map +7 -0
- package/dist/types/src/SimpleLayoutPlugin.d.ts +1 -1
- package/dist/types/src/SimpleLayoutPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/app-graph-builder.d.ts +6 -0
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +21 -6
- package/dist/types/src/capabilities/index.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-root.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
- package/dist/types/src/capabilities/{spotlight-dismiss/spotlight-dismiss.d.ts → spotlight-dismiss.d.ts} +1 -1
- package/dist/types/src/capabilities/spotlight-dismiss.d.ts.map +1 -0
- package/dist/types/src/capabilities/{state/state.d.ts → state.d.ts} +1 -1
- package/dist/types/src/capabilities/state.d.ts.map +1 -0
- package/dist/types/src/capabilities/{url-handler/url-handler.d.ts → url-handler.d.ts} +3 -3
- package/dist/types/src/capabilities/url-handler.d.ts.map +1 -0
- package/dist/types/src/components/ContentError.stories.d.ts +26 -19
- package/dist/types/src/components/ContentError.stories.d.ts.map +1 -1
- package/dist/types/src/components/DebugOverlay/DebugOverlay.d.ts +19 -0
- package/dist/types/src/components/DebugOverlay/DebugOverlay.d.ts.map +1 -0
- package/dist/types/src/components/DebugOverlay/index.d.ts +2 -0
- package/dist/types/src/components/DebugOverlay/index.d.ts.map +1 -0
- package/dist/types/src/components/Dialog/Dialog.d.ts.map +1 -1
- package/dist/types/src/components/Home/Home.d.ts.map +1 -1
- package/dist/types/src/components/Loading/Loading.d.ts +3 -0
- package/dist/types/src/components/Loading/Loading.d.ts.map +1 -0
- package/dist/types/src/components/{ContentLoading.stories.d.ts → Loading/Loading.stories.d.ts} +1 -1
- package/dist/types/src/components/Loading/Loading.stories.d.ts.map +1 -0
- package/dist/types/src/components/Loading/index.d.ts +2 -0
- package/dist/types/src/components/Loading/index.d.ts.map +1 -0
- package/dist/types/src/components/MobileLayout/MobileLayout.d.ts +2 -2
- package/dist/types/src/components/MobileLayout/MobileLayout.d.ts.map +1 -1
- package/dist/types/src/components/MobileLayout/MobileLayout.stories.d.ts.map +1 -1
- package/dist/types/src/components/NavBranch/NavBranch.d.ts +11 -0
- package/dist/types/src/components/NavBranch/NavBranch.d.ts.map +1 -0
- package/dist/types/src/components/NavBranch/index.d.ts +2 -0
- package/dist/types/src/components/NavBranch/index.d.ts.map +1 -0
- package/dist/types/src/components/Popover/Popover.d.ts.map +1 -1
- package/dist/types/src/components/SimpleLayout/AppBar.d.ts +5 -7
- package/dist/types/src/components/SimpleLayout/AppBar.d.ts.map +1 -1
- package/dist/types/src/components/SimpleLayout/AppBar.stories.d.ts +29 -22
- package/dist/types/src/components/SimpleLayout/AppBar.stories.d.ts.map +1 -1
- package/dist/types/src/components/SimpleLayout/Drawer.d.ts +4 -7
- package/dist/types/src/components/SimpleLayout/Drawer.d.ts.map +1 -1
- package/dist/types/src/components/SimpleLayout/Main.d.ts +4 -7
- package/dist/types/src/components/SimpleLayout/Main.d.ts.map +1 -1
- package/dist/types/src/components/SimpleLayout/NavBar.d.ts +5 -7
- package/dist/types/src/components/SimpleLayout/NavBar.d.ts.map +1 -1
- package/dist/types/src/components/SimpleLayout/NavBar.stories.d.ts +29 -23
- package/dist/types/src/components/SimpleLayout/NavBar.stories.d.ts.map +1 -1
- package/dist/types/src/components/SimpleLayout/SimpleLayout.d.ts.map +1 -1
- package/dist/types/src/components/SimpleLayout/SimpleLayout.stories.d.ts +26 -25
- package/dist/types/src/components/SimpleLayout/SimpleLayout.stories.d.ts.map +1 -1
- package/dist/types/src/components/hooks.d.ts +4 -2
- package/dist/types/src/components/hooks.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +3 -2
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/hooks/actions.d.ts +5 -6
- package/dist/types/src/hooks/actions.d.ts.map +1 -1
- package/dist/types/src/hooks/useAppBarProps.d.ts +2 -2
- package/dist/types/src/hooks/useAppBarProps.d.ts.map +1 -1
- package/dist/types/src/hooks/useCompanions.d.ts.map +1 -1
- package/dist/types/src/hooks/useDrawerActions.d.ts.map +1 -1
- package/dist/types/src/hooks/useNavbarActions.d.ts.map +1 -1
- package/dist/types/src/hooks/useSimpleLayoutState.d.ts +1 -1
- package/dist/types/src/hooks/useSimpleLayoutState.d.ts.map +1 -1
- package/dist/types/src/operations/close.d.ts +5 -0
- package/dist/types/src/operations/close.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/operations/open.d.ts +5 -0
- package/dist/types/src/operations/open.d.ts.map +1 -0
- package/dist/types/src/operations/revert-workspace.d.ts +5 -0
- package/dist/types/src/operations/revert-workspace.d.ts.map +1 -0
- package/dist/types/src/operations/set-layout-mode.d.ts +5 -0
- package/dist/types/src/operations/set-layout-mode.d.ts.map +1 -0
- package/dist/types/src/operations/set.d.ts +5 -0
- package/dist/types/src/operations/set.d.ts.map +1 -0
- package/dist/types/src/operations/state-access.d.ts +8 -0
- package/dist/types/src/operations/state-access.d.ts.map +1 -0
- package/dist/types/src/operations/switch-workspace.d.ts +5 -0
- package/dist/types/src/operations/switch-workspace.d.ts.map +1 -0
- package/dist/types/src/operations/update-complementary.d.ts +5 -0
- package/dist/types/src/operations/update-complementary.d.ts.map +1 -0
- package/dist/types/src/operations/update-dialog.d.ts +5 -0
- package/dist/types/src/operations/update-dialog.d.ts.map +1 -0
- package/dist/types/src/operations/update-popover.d.ts +5 -0
- package/dist/types/src/operations/update-popover.d.ts.map +1 -0
- package/dist/types/src/operations/update-sidebar.d.ts +5 -0
- package/dist/types/src/operations/update-sidebar.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +26 -20
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/capabilities.d.ts +10 -2
- package/dist/types/src/types/capabilities.d.ts.map +1 -1
- package/dist/types/src/types/events.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +47 -30
- package/src/SimpleLayoutPlugin.ts +16 -7
- package/src/capabilities/app-graph-builder.ts +21 -0
- package/src/capabilities/index.ts +13 -6
- package/src/capabilities/operation-handler.ts +14 -0
- package/src/capabilities/{react-root/react-root.tsx → react-root.tsx} +2 -2
- package/src/capabilities/{react-surface/react-surface.tsx → react-surface.tsx} +17 -8
- package/src/capabilities/{state/state.tsx → state.tsx} +2 -2
- package/src/capabilities/url-handler.ts +161 -0
- package/src/components/ContentError.stories.tsx +1 -1
- package/src/components/DebugOverlay/DebugOverlay.tsx +96 -0
- package/src/components/DebugOverlay/index.ts +5 -0
- package/src/components/Dialog/Dialog.tsx +14 -3
- package/src/components/Home/Home.tsx +32 -32
- package/src/components/{ContentLoading.stories.tsx → Loading/Loading.stories.tsx} +4 -4
- package/src/components/{ContentLoading.tsx → Loading/Loading.tsx} +1 -1
- package/src/components/Loading/index.ts +5 -0
- package/src/components/MobileLayout/MobileLayout.stories.tsx +21 -17
- package/src/components/MobileLayout/MobileLayout.tsx +118 -49
- package/src/components/{Workspace/Workspace.tsx → NavBranch/NavBranch.tsx} +40 -41
- package/src/components/{Workspace → NavBranch}/index.ts +1 -1
- package/src/components/Popover/Popover.tsx +10 -16
- package/src/components/SimpleLayout/AppBar.stories.tsx +10 -10
- package/src/components/SimpleLayout/AppBar.tsx +60 -60
- package/src/components/SimpleLayout/Drawer.tsx +30 -31
- package/src/components/SimpleLayout/Main.tsx +21 -26
- package/src/components/SimpleLayout/NavBar.stories.tsx +2 -2
- package/src/components/SimpleLayout/NavBar.tsx +8 -9
- package/src/components/SimpleLayout/SimpleLayout.stories.tsx +44 -67
- package/src/components/SimpleLayout/SimpleLayout.tsx +33 -34
- package/src/components/hooks.ts +8 -8
- package/src/components/index.ts +3 -2
- package/src/hooks/actions.ts +15 -16
- package/src/hooks/useAppBarProps.ts +9 -30
- package/src/hooks/useDrawerActions.ts +13 -11
- package/src/hooks/useNavbarActions.ts +8 -7
- package/src/hooks/useSimpleLayoutState.ts +1 -1
- package/src/meta.ts +1 -1
- package/src/operations/close.ts +34 -0
- package/src/operations/index.ts +16 -0
- package/src/operations/open.ts +63 -0
- package/src/operations/revert-workspace.ts +22 -0
- package/src/operations/set-layout-mode.ts +12 -0
- package/src/operations/set.ts +23 -0
- package/src/operations/state-access.ts +19 -0
- package/src/operations/switch-workspace.ts +26 -0
- package/src/operations/update-complementary.ts +35 -0
- package/src/operations/update-dialog.ts +28 -0
- package/src/operations/update-popover.ts +35 -0
- package/src/operations/update-sidebar.ts +12 -0
- package/src/translations.ts +21 -19
- package/src/types/capabilities.ts +4 -4
- package/dist/lib/browser/chunk-7VLT3S46.mjs +0 -29
- package/dist/lib/browser/chunk-7VLT3S46.mjs.map +0 -7
- package/dist/lib/browser/chunk-TMZNLVT2.mjs +0 -1170
- package/dist/lib/browser/chunk-TMZNLVT2.mjs.map +0 -7
- package/dist/lib/browser/operation-resolver-BYRIQOQT.mjs +0 -205
- package/dist/lib/browser/operation-resolver-BYRIQOQT.mjs.map +0 -7
- package/dist/lib/browser/react-root-MMB575WY.mjs +0 -21
- package/dist/lib/browser/react-root-MMB575WY.mjs.map +0 -7
- package/dist/lib/browser/react-surface-M6CURANW.mjs +0 -41
- package/dist/lib/browser/react-surface-M6CURANW.mjs.map +0 -7
- package/dist/lib/browser/spotlight-dismiss-67PHYS5B.mjs +0 -66
- package/dist/lib/browser/spotlight-dismiss-67PHYS5B.mjs.map +0 -7
- package/dist/lib/browser/state-A3PGDWWZ.mjs +0 -48
- package/dist/lib/browser/state-A3PGDWWZ.mjs.map +0 -7
- package/dist/lib/browser/url-handler-HTIUY6WL.mjs +0 -152
- package/dist/lib/browser/url-handler-HTIUY6WL.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-FLOYBAHE.mjs +0 -1171
- package/dist/lib/node-esm/chunk-FLOYBAHE.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-VIDE5UMB.mjs +0 -31
- package/dist/lib/node-esm/chunk-VIDE5UMB.mjs.map +0 -7
- package/dist/lib/node-esm/operation-resolver-BDTFNCS2.mjs +0 -206
- package/dist/lib/node-esm/operation-resolver-BDTFNCS2.mjs.map +0 -7
- package/dist/lib/node-esm/react-root-ENZKVSY4.mjs +0 -22
- package/dist/lib/node-esm/react-root-ENZKVSY4.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-ITVNQYLG.mjs +0 -42
- package/dist/lib/node-esm/react-surface-ITVNQYLG.mjs.map +0 -7
- package/dist/lib/node-esm/spotlight-dismiss-RMLRZUVY.mjs +0 -68
- package/dist/lib/node-esm/spotlight-dismiss-RMLRZUVY.mjs.map +0 -7
- package/dist/lib/node-esm/state-ZCFZTTPL.mjs +0 -49
- package/dist/lib/node-esm/state-ZCFZTTPL.mjs.map +0 -7
- package/dist/lib/node-esm/url-handler-WBVVKVPC.mjs +0 -153
- package/dist/lib/node-esm/url-handler-WBVVKVPC.mjs.map +0 -7
- package/dist/types/src/capabilities/operation-resolver/index.d.ts +0 -3
- package/dist/types/src/capabilities/operation-resolver/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts +0 -5
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-root/index.d.ts +0 -6
- package/dist/types/src/capabilities/react-root/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-root/react-root.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface/index.d.ts +0 -3
- package/dist/types/src/capabilities/react-surface/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +0 -1
- package/dist/types/src/capabilities/spotlight-dismiss/index.d.ts +0 -3
- package/dist/types/src/capabilities/spotlight-dismiss/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/spotlight-dismiss/spotlight-dismiss.d.ts.map +0 -1
- package/dist/types/src/capabilities/state/index.d.ts +0 -13
- package/dist/types/src/capabilities/state/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/state/state.d.ts.map +0 -1
- package/dist/types/src/capabilities/url-handler/index.d.ts +0 -3
- package/dist/types/src/capabilities/url-handler/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/url-handler/url-handler.d.ts.map +0 -1
- package/dist/types/src/components/ContentLoading.d.ts +0 -3
- package/dist/types/src/components/ContentLoading.d.ts.map +0 -1
- package/dist/types/src/components/ContentLoading.stories.d.ts.map +0 -1
- package/dist/types/src/components/Workspace/Workspace.d.ts +0 -11
- package/dist/types/src/components/Workspace/Workspace.d.ts.map +0 -1
- package/dist/types/src/components/Workspace/index.d.ts +0 -2
- package/dist/types/src/components/Workspace/index.d.ts.map +0 -1
- package/src/capabilities/operation-resolver/index.ts +0 -10
- package/src/capabilities/operation-resolver/operation-resolver.ts +0 -217
- package/src/capabilities/react-root/index.ts +0 -7
- package/src/capabilities/react-surface/index.ts +0 -7
- package/src/capabilities/spotlight-dismiss/index.ts +0 -7
- package/src/capabilities/state/index.ts +0 -9
- package/src/capabilities/url-handler/index.ts +0 -7
- package/src/capabilities/url-handler/url-handler.ts +0 -157
- /package/dist/types/src/capabilities/{react-root/react-root.d.ts → react-root.d.ts} +0 -0
- /package/dist/types/src/capabilities/{react-surface/react-surface.d.ts → react-surface.d.ts} +0 -0
- /package/src/capabilities/{spotlight-dismiss/spotlight-dismiss.ts → spotlight-dismiss.ts} +0 -0
|
@@ -1,217 +0,0 @@
|
|
|
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 { LayoutOperation } from '@dxos/app-toolkit';
|
|
9
|
-
import { Operation, OperationResolver } from '@dxos/operation';
|
|
10
|
-
import { ATTENDABLE_PATH_SEPARATOR } from '@dxos/react-ui-attention';
|
|
11
|
-
|
|
12
|
-
import { type SimpleLayoutState, SimpleLayoutState as SimpleLayoutStateCapability } from '../../types';
|
|
13
|
-
|
|
14
|
-
/** Maximum number of items to keep in navigation history. */
|
|
15
|
-
const MAX_HISTORY_LENGTH = 50;
|
|
16
|
-
|
|
17
|
-
/** Parse entry ID to extract primary ID and variant. */
|
|
18
|
-
const parseEntryId = (entryId: string) => {
|
|
19
|
-
const [id, variant] = entryId.split(ATTENDABLE_PATH_SEPARATOR);
|
|
20
|
-
return { id, variant };
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export default Capability.makeModule(
|
|
24
|
-
Effect.fnUntraced(function* () {
|
|
25
|
-
const registry = yield* Capability.get(Capabilities.AtomRegistry);
|
|
26
|
-
const stateAtom = yield* Capability.get(SimpleLayoutStateCapability);
|
|
27
|
-
|
|
28
|
-
const getState = () => registry.get(stateAtom);
|
|
29
|
-
const updateState = (fn: (current: SimpleLayoutState) => SimpleLayoutState) => {
|
|
30
|
-
registry.set(stateAtom, fn(getState()));
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
return Capability.contributes(Capabilities.OperationResolver, [
|
|
34
|
-
//
|
|
35
|
-
// SetLayoutMode
|
|
36
|
-
//
|
|
37
|
-
// TODO(burdon): No-op for to fix startup bug?
|
|
38
|
-
OperationResolver.make({
|
|
39
|
-
operation: LayoutOperation.SetLayoutMode,
|
|
40
|
-
handler: Effect.fnUntraced(function* () {}),
|
|
41
|
-
}),
|
|
42
|
-
|
|
43
|
-
//
|
|
44
|
-
// UpdateSidebar - No-op for simple layout.
|
|
45
|
-
//
|
|
46
|
-
OperationResolver.make({
|
|
47
|
-
operation: LayoutOperation.UpdateSidebar,
|
|
48
|
-
handler: () => Effect.void,
|
|
49
|
-
}),
|
|
50
|
-
|
|
51
|
-
//
|
|
52
|
-
// UpdateComplementary - Controls companion drawer.
|
|
53
|
-
//
|
|
54
|
-
OperationResolver.make({
|
|
55
|
-
operation: LayoutOperation.UpdateComplementary,
|
|
56
|
-
handler: Effect.fnUntraced(function* (input) {
|
|
57
|
-
if (input.state === 'closed') {
|
|
58
|
-
updateState((state) => ({
|
|
59
|
-
...state,
|
|
60
|
-
drawerState: 'closed',
|
|
61
|
-
}));
|
|
62
|
-
}
|
|
63
|
-
}),
|
|
64
|
-
}),
|
|
65
|
-
|
|
66
|
-
//
|
|
67
|
-
// UpdateDialog
|
|
68
|
-
//
|
|
69
|
-
OperationResolver.make({
|
|
70
|
-
operation: LayoutOperation.UpdateDialog,
|
|
71
|
-
handler: Effect.fnUntraced(function* (input) {
|
|
72
|
-
updateState((state) => ({
|
|
73
|
-
...state,
|
|
74
|
-
dialogOpen: input.state ?? Boolean(input.subject),
|
|
75
|
-
dialogType: input.type ?? 'default',
|
|
76
|
-
dialogBlockAlign: input.blockAlign ?? 'center',
|
|
77
|
-
dialogOverlayClasses: input.overlayClasses,
|
|
78
|
-
dialogOverlayStyle: input.overlayStyle,
|
|
79
|
-
dialogContent: input.subject ? { component: input.subject, props: input.props } : undefined,
|
|
80
|
-
}));
|
|
81
|
-
}),
|
|
82
|
-
}),
|
|
83
|
-
|
|
84
|
-
//
|
|
85
|
-
// UpdatePopover
|
|
86
|
-
//
|
|
87
|
-
OperationResolver.make({
|
|
88
|
-
operation: LayoutOperation.UpdatePopover,
|
|
89
|
-
handler: Effect.fnUntraced(function* (input) {
|
|
90
|
-
updateState((state) => ({
|
|
91
|
-
...state,
|
|
92
|
-
popoverOpen: input.state ?? Boolean(input.subject),
|
|
93
|
-
popoverKind: input.kind ?? 'base',
|
|
94
|
-
popoverTitle: input.kind === 'card' ? input.title : undefined,
|
|
95
|
-
popoverContent:
|
|
96
|
-
typeof input.subject === 'string'
|
|
97
|
-
? { component: input.subject, props: input.props }
|
|
98
|
-
: input.subject
|
|
99
|
-
? { subject: input.subject }
|
|
100
|
-
: undefined,
|
|
101
|
-
popoverSide: input.side,
|
|
102
|
-
popoverVariant: input.variant,
|
|
103
|
-
popoverAnchor: input.variant === 'virtual' ? input.anchor : state.popoverAnchor,
|
|
104
|
-
popoverAnchorId: input.variant !== 'virtual' ? input.anchorId : state.popoverAnchorId,
|
|
105
|
-
}));
|
|
106
|
-
}),
|
|
107
|
-
}),
|
|
108
|
-
|
|
109
|
-
//
|
|
110
|
-
// SwitchWorkspace
|
|
111
|
-
//
|
|
112
|
-
OperationResolver.make({
|
|
113
|
-
operation: LayoutOperation.SwitchWorkspace,
|
|
114
|
-
handler: Effect.fnUntraced(function* (input) {
|
|
115
|
-
updateState((state) => ({
|
|
116
|
-
...state,
|
|
117
|
-
// TODO(wittjosiah): This is a hack to prevent the previous deck from being set for pinned items.
|
|
118
|
-
// Ideally this should be worked into the data model in a generic way.
|
|
119
|
-
previousWorkspace: !state.workspace.startsWith('!') ? state.workspace : state.previousWorkspace,
|
|
120
|
-
workspace: input.subject,
|
|
121
|
-
active: undefined,
|
|
122
|
-
// Clear history when switching workspaces.
|
|
123
|
-
history: [],
|
|
124
|
-
}));
|
|
125
|
-
}),
|
|
126
|
-
}),
|
|
127
|
-
|
|
128
|
-
//
|
|
129
|
-
// RevertWorkspace
|
|
130
|
-
//
|
|
131
|
-
OperationResolver.make({
|
|
132
|
-
operation: LayoutOperation.RevertWorkspace,
|
|
133
|
-
handler: Effect.fnUntraced(function* () {
|
|
134
|
-
const state = getState();
|
|
135
|
-
yield* Operation.invoke(LayoutOperation.SwitchWorkspace, {
|
|
136
|
-
subject: state.previousWorkspace,
|
|
137
|
-
});
|
|
138
|
-
}),
|
|
139
|
-
}),
|
|
140
|
-
|
|
141
|
-
//
|
|
142
|
-
// Open
|
|
143
|
-
//
|
|
144
|
-
OperationResolver.make({
|
|
145
|
-
operation: LayoutOperation.Open,
|
|
146
|
-
handler: Effect.fnUntraced(function* (input) {
|
|
147
|
-
const id = input.subject[0];
|
|
148
|
-
const { id: primaryId, variant } = parseEntryId(id);
|
|
149
|
-
const state = getState();
|
|
150
|
-
|
|
151
|
-
// Only treat as companion when opening a variant of the current workspace/active (e.g. object~comments).
|
|
152
|
-
// IDs like settings~spaceId are alternate-tree nodes and should navigate main content, not open the drawer.
|
|
153
|
-
// TODO(wittjosiah): Factor out the change-companion operation from deck to a common layout operation.
|
|
154
|
-
const isCompanionOfCurrent = variant && (primaryId === state.workspace || primaryId === state.active);
|
|
155
|
-
if (isCompanionOfCurrent) {
|
|
156
|
-
updateState((state) => ({
|
|
157
|
-
...state,
|
|
158
|
-
companionVariant: variant,
|
|
159
|
-
drawerState: state.drawerState === 'closed' || !state.drawerState ? 'open' : state.drawerState,
|
|
160
|
-
}));
|
|
161
|
-
} else {
|
|
162
|
-
// Regular navigation - update active and history (use full id for alternate-tree nodes).
|
|
163
|
-
updateState((state) => {
|
|
164
|
-
const newHistory = state.active ? [...state.history, state.active] : state.history;
|
|
165
|
-
const trimmedHistory =
|
|
166
|
-
newHistory.length > MAX_HISTORY_LENGTH ? newHistory.slice(-MAX_HISTORY_LENGTH) : newHistory;
|
|
167
|
-
return {
|
|
168
|
-
...state,
|
|
169
|
-
active: id,
|
|
170
|
-
history: trimmedHistory,
|
|
171
|
-
};
|
|
172
|
-
});
|
|
173
|
-
}
|
|
174
|
-
}),
|
|
175
|
-
}),
|
|
176
|
-
|
|
177
|
-
//
|
|
178
|
-
// Close
|
|
179
|
-
//
|
|
180
|
-
OperationResolver.make({
|
|
181
|
-
operation: LayoutOperation.Close,
|
|
182
|
-
handler: Effect.fnUntraced(function* () {
|
|
183
|
-
updateState((state) => {
|
|
184
|
-
// Pop from history if available.
|
|
185
|
-
if (state.history.length > 0) {
|
|
186
|
-
const newHistory = [...state.history];
|
|
187
|
-
const previousActive = newHistory.pop();
|
|
188
|
-
return {
|
|
189
|
-
...state,
|
|
190
|
-
active: previousActive,
|
|
191
|
-
history: newHistory,
|
|
192
|
-
};
|
|
193
|
-
}
|
|
194
|
-
// No history, just clear active.
|
|
195
|
-
return {
|
|
196
|
-
...state,
|
|
197
|
-
active: undefined,
|
|
198
|
-
};
|
|
199
|
-
});
|
|
200
|
-
}),
|
|
201
|
-
}),
|
|
202
|
-
|
|
203
|
-
//
|
|
204
|
-
// Set
|
|
205
|
-
//
|
|
206
|
-
OperationResolver.make({
|
|
207
|
-
operation: LayoutOperation.Set,
|
|
208
|
-
handler: Effect.fnUntraced(function* (input) {
|
|
209
|
-
updateState((state) => ({
|
|
210
|
-
...state,
|
|
211
|
-
active: input.subject[0],
|
|
212
|
-
}));
|
|
213
|
-
}),
|
|
214
|
-
}),
|
|
215
|
-
]);
|
|
216
|
-
}),
|
|
217
|
-
);
|
|
@@ -1,157 +0,0 @@
|
|
|
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 { LayoutOperation } from '@dxos/app-toolkit';
|
|
9
|
-
import { log } from '@dxos/log';
|
|
10
|
-
import { Node } from '@dxos/plugin-graph';
|
|
11
|
-
import { isTauri } from '@dxos/util';
|
|
12
|
-
|
|
13
|
-
import { type SimpleLayoutState, SimpleLayoutState as SimpleLayoutStateCapability } from '../../types';
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* URL handler for simple layout that syncs browser URL with layout state.
|
|
17
|
-
* URL format: /{workspace} or /{workspace}/{active}
|
|
18
|
-
* Root is represented as / or /root.
|
|
19
|
-
*
|
|
20
|
-
* On mobile Tauri, also listens for deep links via the deep-link plugin.
|
|
21
|
-
*/
|
|
22
|
-
export default Capability.makeModule(
|
|
23
|
-
Effect.fnUntraced(function* () {
|
|
24
|
-
const { invokeSync } = yield* Capability.get(Capabilities.OperationInvoker);
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Handle navigation from a pathname.
|
|
28
|
-
* Parses path and updates state accordingly.
|
|
29
|
-
*/
|
|
30
|
-
const handlePathNavigation = (pathname: string) => {
|
|
31
|
-
log.info('[UrlHandler] Navigating to path', { pathname });
|
|
32
|
-
|
|
33
|
-
// Parse URL segments: /{workspace}/{active}
|
|
34
|
-
const [_, nextWorkspace, nextActive] = pathname.split('/');
|
|
35
|
-
|
|
36
|
-
// Determine target workspace (empty or 'root' means Node.RootId).
|
|
37
|
-
const targetWorkspace = !nextWorkspace || nextWorkspace === 'root' ? Node.RootId : nextWorkspace;
|
|
38
|
-
|
|
39
|
-
// Navigate via operations (they will update state accordingly).
|
|
40
|
-
invokeSync(LayoutOperation.SwitchWorkspace, { subject: targetWorkspace });
|
|
41
|
-
if (nextActive) {
|
|
42
|
-
invokeSync(LayoutOperation.Open, { subject: [nextActive] });
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
const onNavigation = handleNavigation(handlePathNavigation);
|
|
47
|
-
|
|
48
|
-
// Handle initial URL and listen for browser navigation.
|
|
49
|
-
yield* Effect.sync(() => onNavigation());
|
|
50
|
-
window.addEventListener('popstate', onNavigation);
|
|
51
|
-
|
|
52
|
-
// Set up deep link listener for mobile Tauri.
|
|
53
|
-
let unlistenDeepLink: (() => void) | undefined;
|
|
54
|
-
if (isTauri()) {
|
|
55
|
-
yield* Effect.tryPromise({
|
|
56
|
-
try: async () => {
|
|
57
|
-
const { getCurrent, onOpenUrl } = await import('@tauri-apps/plugin-deep-link');
|
|
58
|
-
|
|
59
|
-
// Check if app was launched via deep link (cold start).
|
|
60
|
-
const launchUrls = await getCurrent();
|
|
61
|
-
if (launchUrls && launchUrls.length > 0) {
|
|
62
|
-
log.info('[UrlHandler] App launched with deep links', { urls: launchUrls });
|
|
63
|
-
for (const url of launchUrls) {
|
|
64
|
-
handleDeepLink(url, handlePathNavigation);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
// Listen for deep links while app is running.
|
|
69
|
-
unlistenDeepLink = await onOpenUrl((urls) => {
|
|
70
|
-
log.info('[UrlHandler] Deep links received', { urls });
|
|
71
|
-
for (const url of urls) {
|
|
72
|
-
handleDeepLink(url, handlePathNavigation);
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
log.info('[UrlHandler] Deep link listener initialized');
|
|
77
|
-
},
|
|
78
|
-
catch: (error) => {
|
|
79
|
-
log.warn('[UrlHandler] Failed to initialize deep link listener', { error });
|
|
80
|
-
return error;
|
|
81
|
-
},
|
|
82
|
-
}).pipe(Effect.catchAll(() => Effect.void));
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
// Subscribe to state changes to update the URL.
|
|
86
|
-
let lastWorkspace: string | undefined;
|
|
87
|
-
let lastActive: string | undefined;
|
|
88
|
-
const unsubscribe = yield* Capabilities.subscribeAtom(SimpleLayoutStateCapability, (state: SimpleLayoutState) => {
|
|
89
|
-
const { workspace, active } = state;
|
|
90
|
-
|
|
91
|
-
// Only update URL if relevant state changed.
|
|
92
|
-
if (workspace !== lastWorkspace || active !== lastActive) {
|
|
93
|
-
lastWorkspace = workspace;
|
|
94
|
-
lastActive = active;
|
|
95
|
-
|
|
96
|
-
const path = pathFromState(workspace, active);
|
|
97
|
-
if (window.location.pathname !== path) {
|
|
98
|
-
history.pushState(null, '', `${path}${window.location.search}`);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
return Capability.contributes(Capabilities.Null, null, () =>
|
|
104
|
-
Effect.sync(() => {
|
|
105
|
-
window.removeEventListener('popstate', onNavigation);
|
|
106
|
-
unsubscribe();
|
|
107
|
-
unlistenDeepLink?.();
|
|
108
|
-
}),
|
|
109
|
-
);
|
|
110
|
-
}),
|
|
111
|
-
);
|
|
112
|
-
|
|
113
|
-
// TODO(wittjosiah): Instead of hardcoding redirect paths, we should either:
|
|
114
|
-
// 1. Validate that the workspace exists in the graph before navigating.
|
|
115
|
-
// 2. Implement more structured routing with explicit route definitions.
|
|
116
|
-
/**
|
|
117
|
-
* Check if a path is a special redirect path that shouldn't be navigated to.
|
|
118
|
-
* These paths are handled by other systems (e.g., OAuth).
|
|
119
|
-
*/
|
|
120
|
-
const isRedirectPath = (pathname: string): boolean => pathname.startsWith('/redirect/');
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* Build pathname from layout state. Root workspace is / or /root/{active}.
|
|
124
|
-
*/
|
|
125
|
-
const pathFromState = (workspace: string, active: string | undefined): string =>
|
|
126
|
-
workspace === Node.RootId
|
|
127
|
-
? active
|
|
128
|
-
? `/${Node.RootId}/${active}`
|
|
129
|
-
: '/'
|
|
130
|
-
: active
|
|
131
|
-
? `/${workspace}/${active}`
|
|
132
|
-
: `/${workspace}`;
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
* Returns a handler for navigation events (initial load and popstate) that navigates to current pathname.
|
|
136
|
-
*/
|
|
137
|
-
const handleNavigation =
|
|
138
|
-
(navigate: (pathname: string) => void): (() => void) =>
|
|
139
|
-
() =>
|
|
140
|
-
navigate(window.location.pathname);
|
|
141
|
-
|
|
142
|
-
/**
|
|
143
|
-
* Handle deep link URL from Tauri. Parses the URL and calls navigate unless it's a redirect path.
|
|
144
|
-
*/
|
|
145
|
-
const handleDeepLink = (urlString: string, navigate: (pathname: string) => void): void => {
|
|
146
|
-
log.info('[UrlHandler] Deep link received', { url: urlString });
|
|
147
|
-
try {
|
|
148
|
-
const url = new URL(urlString);
|
|
149
|
-
if (isRedirectPath(url.pathname)) {
|
|
150
|
-
log.info('[UrlHandler] Skipping redirect path (handled elsewhere)', { pathname: url.pathname });
|
|
151
|
-
return;
|
|
152
|
-
}
|
|
153
|
-
navigate(url.pathname);
|
|
154
|
-
} catch (error) {
|
|
155
|
-
log.warn('[UrlHandler] Failed to parse deep link URL', { urlString, error });
|
|
156
|
-
}
|
|
157
|
-
};
|
|
File without changes
|
/package/dist/types/src/capabilities/{react-surface/react-surface.d.ts → react-surface.d.ts}
RENAMED
|
File without changes
|
|
File without changes
|