@dxos/plugin-simple-layout 0.8.4-main.d05673bc65 → 0.8.4-main.fcfe5033a5
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 +35 -56
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +35 -55
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- 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.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} +1 -1
- package/dist/types/src/capabilities/url-handler.d.ts.map +1 -0
- package/dist/types/src/components/ContentError.stories.d.ts +25 -18
- 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/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.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.map +1 -1
- 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 +28 -21
- package/dist/types/src/components/SimpleLayout/AppBar.stories.d.ts.map +1 -1
- package/dist/types/src/components/SimpleLayout/Drawer.d.ts.map +1 -1
- 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 +28 -22
- 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/index.d.ts +2 -1
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/hooks/actions.d.ts +1 -1
- package/dist/types/src/hooks/actions.d.ts.map +1 -1
- package/dist/types/src/hooks/useAppBarProps.d.ts +1 -1
- package/dist/types/src/hooks/useAppBarProps.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 -19
- 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/tsconfig.tsbuildinfo +1 -1
- package/package.json +39 -29
- package/src/SimpleLayoutPlugin.ts +16 -6
- 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} +11 -4
- package/src/capabilities/{state/state.tsx → state.tsx} +2 -2
- package/src/capabilities/url-handler.ts +161 -0
- 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 +29 -29
- package/src/components/{ContentLoading/ContentLoading.stories.tsx → Loading/Loading.stories.tsx} +4 -4
- package/src/components/{ContentLoading/ContentLoading.tsx → Loading/Loading.tsx} +1 -1
- package/src/components/{ContentLoading → Loading}/index.ts +1 -1
- package/src/components/MobileLayout/MobileLayout.stories.tsx +21 -17
- package/src/components/MobileLayout/MobileLayout.tsx +118 -49
- package/src/components/NavBranch/NavBranch.tsx +29 -31
- package/src/components/Popover/Popover.tsx +10 -16
- package/src/components/SimpleLayout/AppBar.stories.tsx +8 -9
- package/src/components/SimpleLayout/AppBar.tsx +60 -60
- package/src/components/SimpleLayout/Drawer.tsx +30 -22
- package/src/components/SimpleLayout/Main.tsx +19 -23
- package/src/components/SimpleLayout/NavBar.stories.tsx +1 -2
- package/src/components/SimpleLayout/NavBar.tsx +8 -9
- package/src/components/SimpleLayout/SimpleLayout.stories.tsx +43 -66
- package/src/components/SimpleLayout/SimpleLayout.tsx +33 -34
- package/src/components/hooks.ts +1 -1
- package/src/components/index.ts +2 -1
- package/src/hooks/actions.ts +4 -3
- package/src/hooks/useAppBarProps.ts +9 -9
- package/src/hooks/useDrawerActions.ts +6 -6
- package/src/hooks/useNavbarActions.ts +3 -3
- package/src/hooks/useSimpleLayoutState.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 +3 -3
- package/dist/lib/browser/chunk-MDPEKLKR.mjs +0 -1163
- package/dist/lib/browser/chunk-MDPEKLKR.mjs.map +0 -7
- package/dist/lib/browser/chunk-MRR7PXSM.mjs +0 -29
- package/dist/lib/browser/chunk-MRR7PXSM.mjs.map +0 -7
- package/dist/lib/browser/operation-resolver-VTZ6HZ4B.mjs +0 -194
- package/dist/lib/browser/operation-resolver-VTZ6HZ4B.mjs.map +0 -7
- package/dist/lib/browser/react-root-WVQYY2JA.mjs +0 -21
- package/dist/lib/browser/react-root-WVQYY2JA.mjs.map +0 -7
- package/dist/lib/browser/react-surface-VLBR37ED.mjs +0 -44
- package/dist/lib/browser/react-surface-VLBR37ED.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-TXSMUWYI.mjs +0 -48
- package/dist/lib/browser/state-TXSMUWYI.mjs.map +0 -7
- package/dist/lib/browser/url-handler-RBRONH7S.mjs +0 -151
- package/dist/lib/browser/url-handler-RBRONH7S.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-DCKASLMP.mjs +0 -1164
- package/dist/lib/node-esm/chunk-DCKASLMP.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-WMNTJ2MK.mjs +0 -31
- package/dist/lib/node-esm/chunk-WMNTJ2MK.mjs.map +0 -7
- package/dist/lib/node-esm/operation-resolver-R7CQ6ERU.mjs +0 -195
- package/dist/lib/node-esm/operation-resolver-R7CQ6ERU.mjs.map +0 -7
- package/dist/lib/node-esm/react-root-XBNDM7BE.mjs +0 -22
- package/dist/lib/node-esm/react-root-XBNDM7BE.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-U5NHA367.mjs +0 -45
- package/dist/lib/node-esm/react-surface-U5NHA367.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-JMX6FAG4.mjs +0 -49
- package/dist/lib/node-esm/state-JMX6FAG4.mjs.map +0 -7
- package/dist/lib/node-esm/url-handler-QSMCH3JB.mjs +0 -152
- package/dist/lib/node-esm/url-handler-QSMCH3JB.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/ContentLoading.d.ts +0 -3
- package/dist/types/src/components/ContentLoading/ContentLoading.d.ts.map +0 -1
- package/dist/types/src/components/ContentLoading/ContentLoading.stories.d.ts.map +0 -1
- package/dist/types/src/components/ContentLoading/index.d.ts +0 -2
- package/dist/types/src/components/ContentLoading/index.d.ts.map +0 -1
- package/src/capabilities/operation-resolver/index.ts +0 -10
- package/src/capabilities/operation-resolver/operation-resolver.ts +0 -202
- 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 -133
- /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/dist/types/src/capabilities/{spotlight-dismiss/spotlight-dismiss.d.ts → spotlight-dismiss.d.ts} +0 -0
- /package/src/capabilities/{spotlight-dismiss/spotlight-dismiss.ts → spotlight-dismiss.ts} +0 -0
|
@@ -1,202 +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 { getCompanionVariant, LayoutOperation, isPinnedWorkspace } from '@dxos/app-toolkit';
|
|
9
|
-
import { Operation, OperationResolver } from '@dxos/operation';
|
|
10
|
-
|
|
11
|
-
import { type SimpleLayoutState, SimpleLayoutState as SimpleLayoutStateCapability } from '../../types';
|
|
12
|
-
|
|
13
|
-
/** Maximum number of items to keep in navigation history. */
|
|
14
|
-
const MAX_HISTORY_LENGTH = 50;
|
|
15
|
-
|
|
16
|
-
export default Capability.makeModule(
|
|
17
|
-
Effect.fnUntraced(function* () {
|
|
18
|
-
const registry = yield* Capability.get(Capabilities.AtomRegistry);
|
|
19
|
-
const stateAtom = yield* Capability.get(SimpleLayoutStateCapability);
|
|
20
|
-
|
|
21
|
-
const getState = () => registry.get(stateAtom);
|
|
22
|
-
const updateState = (fn: (current: SimpleLayoutState) => SimpleLayoutState) => {
|
|
23
|
-
registry.set(stateAtom, fn(getState()));
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
return Capability.contributes(Capabilities.OperationResolver, [
|
|
27
|
-
//
|
|
28
|
-
// SetLayoutMode
|
|
29
|
-
//
|
|
30
|
-
// TODO(burdon): No-op for to fix startup bug?
|
|
31
|
-
OperationResolver.make({
|
|
32
|
-
operation: LayoutOperation.SetLayoutMode,
|
|
33
|
-
handler: Effect.fnUntraced(function* () {}),
|
|
34
|
-
}),
|
|
35
|
-
|
|
36
|
-
//
|
|
37
|
-
// UpdateSidebar - No-op for simple layout.
|
|
38
|
-
//
|
|
39
|
-
OperationResolver.make({
|
|
40
|
-
operation: LayoutOperation.UpdateSidebar,
|
|
41
|
-
handler: () => Effect.void,
|
|
42
|
-
}),
|
|
43
|
-
|
|
44
|
-
//
|
|
45
|
-
// UpdateComplementary - Controls companion drawer.
|
|
46
|
-
//
|
|
47
|
-
// TODO(wittjosiah): Not sure if we should be using this for the drawer.
|
|
48
|
-
OperationResolver.make({
|
|
49
|
-
operation: LayoutOperation.UpdateComplementary,
|
|
50
|
-
handler: Effect.fnUntraced(function* (input) {
|
|
51
|
-
if (input.state === 'closed') {
|
|
52
|
-
updateState((state) => ({
|
|
53
|
-
...state,
|
|
54
|
-
drawerState: 'closed',
|
|
55
|
-
}));
|
|
56
|
-
} else if (input.subject) {
|
|
57
|
-
const variant = getCompanionVariant(input.subject);
|
|
58
|
-
updateState((state) => ({
|
|
59
|
-
...state,
|
|
60
|
-
companionVariant: variant,
|
|
61
|
-
drawerState: input.state === 'expanded' ? 'expanded' : 'open',
|
|
62
|
-
}));
|
|
63
|
-
}
|
|
64
|
-
}),
|
|
65
|
-
}),
|
|
66
|
-
|
|
67
|
-
//
|
|
68
|
-
// UpdateDialog
|
|
69
|
-
//
|
|
70
|
-
OperationResolver.make({
|
|
71
|
-
operation: LayoutOperation.UpdateDialog,
|
|
72
|
-
handler: Effect.fnUntraced(function* (input) {
|
|
73
|
-
updateState((state) => ({
|
|
74
|
-
...state,
|
|
75
|
-
dialogOpen: input.state ?? Boolean(input.subject),
|
|
76
|
-
dialogType: input.type ?? 'default',
|
|
77
|
-
dialogBlockAlign: input.blockAlign ?? 'center',
|
|
78
|
-
dialogOverlayClasses: input.overlayClasses,
|
|
79
|
-
dialogOverlayStyle: input.overlayStyle,
|
|
80
|
-
dialogContent: input.subject ? { component: input.subject, props: input.props } : undefined,
|
|
81
|
-
}));
|
|
82
|
-
}),
|
|
83
|
-
}),
|
|
84
|
-
|
|
85
|
-
//
|
|
86
|
-
// UpdatePopover
|
|
87
|
-
//
|
|
88
|
-
OperationResolver.make({
|
|
89
|
-
operation: LayoutOperation.UpdatePopover,
|
|
90
|
-
handler: Effect.fnUntraced(function* (input) {
|
|
91
|
-
updateState((state) => ({
|
|
92
|
-
...state,
|
|
93
|
-
popoverOpen: input.state ?? Boolean(input.subject),
|
|
94
|
-
popoverKind: input.kind ?? 'base',
|
|
95
|
-
popoverTitle: input.kind === 'card' ? input.title : undefined,
|
|
96
|
-
popoverContent:
|
|
97
|
-
typeof input.subject === 'string'
|
|
98
|
-
? { component: input.subject, props: input.props }
|
|
99
|
-
: input.subject
|
|
100
|
-
? { subject: input.subject }
|
|
101
|
-
: undefined,
|
|
102
|
-
popoverSide: input.side,
|
|
103
|
-
popoverVariant: input.variant,
|
|
104
|
-
popoverAnchor: input.variant === 'virtual' ? input.anchor : state.popoverAnchor,
|
|
105
|
-
popoverAnchorId: input.variant !== 'virtual' ? input.anchorId : state.popoverAnchorId,
|
|
106
|
-
}));
|
|
107
|
-
}),
|
|
108
|
-
}),
|
|
109
|
-
|
|
110
|
-
//
|
|
111
|
-
// SwitchWorkspace
|
|
112
|
-
//
|
|
113
|
-
OperationResolver.make({
|
|
114
|
-
operation: LayoutOperation.SwitchWorkspace,
|
|
115
|
-
handler: Effect.fnUntraced(function* (input) {
|
|
116
|
-
updateState((state) => ({
|
|
117
|
-
...state,
|
|
118
|
-
// TODO(wittjosiah): This is a hack to prevent the previous deck from being set for pinned items.
|
|
119
|
-
// Ideally this should be worked into the data model in a generic way.
|
|
120
|
-
previousWorkspace: !isPinnedWorkspace(state.workspace) ? state.workspace : state.previousWorkspace,
|
|
121
|
-
workspace: input.subject,
|
|
122
|
-
active: undefined,
|
|
123
|
-
// Clear history when switching workspaces.
|
|
124
|
-
history: [],
|
|
125
|
-
}));
|
|
126
|
-
}),
|
|
127
|
-
}),
|
|
128
|
-
|
|
129
|
-
//
|
|
130
|
-
// RevertWorkspace
|
|
131
|
-
//
|
|
132
|
-
OperationResolver.make({
|
|
133
|
-
operation: LayoutOperation.RevertWorkspace,
|
|
134
|
-
handler: Effect.fnUntraced(function* () {
|
|
135
|
-
const state = getState();
|
|
136
|
-
yield* Operation.invoke(LayoutOperation.SwitchWorkspace, {
|
|
137
|
-
subject: state.previousWorkspace,
|
|
138
|
-
});
|
|
139
|
-
}),
|
|
140
|
-
}),
|
|
141
|
-
|
|
142
|
-
//
|
|
143
|
-
// Open
|
|
144
|
-
//
|
|
145
|
-
OperationResolver.make({
|
|
146
|
-
operation: LayoutOperation.Open,
|
|
147
|
-
handler: Effect.fnUntraced(function* (input) {
|
|
148
|
-
const id = input.subject[0];
|
|
149
|
-
updateState((state) => {
|
|
150
|
-
const newHistory = state.active ? [...state.history, state.active] : state.history;
|
|
151
|
-
const trimmedHistory =
|
|
152
|
-
newHistory.length > MAX_HISTORY_LENGTH ? newHistory.slice(-MAX_HISTORY_LENGTH) : newHistory;
|
|
153
|
-
return {
|
|
154
|
-
...state,
|
|
155
|
-
active: id,
|
|
156
|
-
history: trimmedHistory,
|
|
157
|
-
};
|
|
158
|
-
});
|
|
159
|
-
}),
|
|
160
|
-
}),
|
|
161
|
-
|
|
162
|
-
//
|
|
163
|
-
// Close
|
|
164
|
-
//
|
|
165
|
-
OperationResolver.make({
|
|
166
|
-
operation: LayoutOperation.Close,
|
|
167
|
-
handler: Effect.fnUntraced(function* () {
|
|
168
|
-
updateState((state) => {
|
|
169
|
-
// Pop from history if available.
|
|
170
|
-
if (state.history.length > 0) {
|
|
171
|
-
const newHistory = [...state.history];
|
|
172
|
-
const previousActive = newHistory.pop();
|
|
173
|
-
return {
|
|
174
|
-
...state,
|
|
175
|
-
active: previousActive,
|
|
176
|
-
history: newHistory,
|
|
177
|
-
};
|
|
178
|
-
}
|
|
179
|
-
// No history, just clear active.
|
|
180
|
-
return {
|
|
181
|
-
...state,
|
|
182
|
-
active: undefined,
|
|
183
|
-
};
|
|
184
|
-
});
|
|
185
|
-
}),
|
|
186
|
-
}),
|
|
187
|
-
|
|
188
|
-
//
|
|
189
|
-
// Set
|
|
190
|
-
//
|
|
191
|
-
OperationResolver.make({
|
|
192
|
-
operation: LayoutOperation.Set,
|
|
193
|
-
handler: Effect.fnUntraced(function* (input) {
|
|
194
|
-
updateState((state) => ({
|
|
195
|
-
...state,
|
|
196
|
-
active: input.subject[0],
|
|
197
|
-
}));
|
|
198
|
-
}),
|
|
199
|
-
}),
|
|
200
|
-
]);
|
|
201
|
-
}),
|
|
202
|
-
);
|
|
@@ -1,133 +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, fromUrlPath, getWorkspaceFromPath, toUrlPath } from '@dxos/app-toolkit';
|
|
9
|
-
import { log } from '@dxos/log';
|
|
10
|
-
import { isTauri } from '@dxos/util';
|
|
11
|
-
|
|
12
|
-
import { type SimpleLayoutState, SimpleLayoutState as SimpleLayoutStateCapability } from '../../types';
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* URL handler for simple layout that syncs browser URL with layout state.
|
|
16
|
-
* URL paths map directly to qualified graph IDs with the leading `root` segment stripped.
|
|
17
|
-
* Root is represented as `/`.
|
|
18
|
-
*
|
|
19
|
-
* On mobile Tauri, also listens for deep links via the deep-link plugin.
|
|
20
|
-
*/
|
|
21
|
-
export default Capability.makeModule(
|
|
22
|
-
Effect.fnUntraced(function* () {
|
|
23
|
-
const { invokeSync } = yield* Capability.get(Capabilities.OperationInvoker);
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Handle navigation from a pathname.
|
|
27
|
-
* Restores the qualified graph ID and dispatches layout operations.
|
|
28
|
-
*/
|
|
29
|
-
const handlePathNavigation = (pathname: string) => {
|
|
30
|
-
log.info('[UrlHandler] Navigating to path', { pathname });
|
|
31
|
-
|
|
32
|
-
const qualifiedId = fromUrlPath(pathname);
|
|
33
|
-
const workspace = getWorkspaceFromPath(qualifiedId);
|
|
34
|
-
|
|
35
|
-
invokeSync(LayoutOperation.SwitchWorkspace, { subject: workspace });
|
|
36
|
-
|
|
37
|
-
const activeId = qualifiedId !== workspace ? qualifiedId : undefined;
|
|
38
|
-
if (activeId) {
|
|
39
|
-
invokeSync(LayoutOperation.Open, { subject: [activeId] });
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
const onNavigation = handleNavigation(handlePathNavigation);
|
|
44
|
-
|
|
45
|
-
yield* Effect.sync(() => onNavigation());
|
|
46
|
-
window.addEventListener('popstate', onNavigation);
|
|
47
|
-
|
|
48
|
-
let unlistenDeepLink: (() => void) | undefined;
|
|
49
|
-
if (isTauri()) {
|
|
50
|
-
yield* Effect.tryPromise({
|
|
51
|
-
try: async () => {
|
|
52
|
-
const { getCurrent, onOpenUrl } = await import('@tauri-apps/plugin-deep-link');
|
|
53
|
-
|
|
54
|
-
const launchUrls = await getCurrent();
|
|
55
|
-
if (launchUrls && launchUrls.length > 0) {
|
|
56
|
-
log.info('[UrlHandler] App launched with deep links', { urls: launchUrls });
|
|
57
|
-
for (const url of launchUrls) {
|
|
58
|
-
handleDeepLink(url, handlePathNavigation);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
unlistenDeepLink = await onOpenUrl((urls) => {
|
|
63
|
-
log.info('[UrlHandler] Deep links received', { urls });
|
|
64
|
-
for (const url of urls) {
|
|
65
|
-
handleDeepLink(url, handlePathNavigation);
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
log.info('[UrlHandler] Deep link listener initialized');
|
|
70
|
-
},
|
|
71
|
-
catch: (error) => {
|
|
72
|
-
log.warn('[UrlHandler] Failed to initialize deep link listener', { error });
|
|
73
|
-
return error;
|
|
74
|
-
},
|
|
75
|
-
}).pipe(Effect.catchAll(() => Effect.void));
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
let lastWorkspace: string | undefined;
|
|
79
|
-
let lastActive: string | undefined;
|
|
80
|
-
const unsubscribe = yield* Capabilities.subscribeAtom(SimpleLayoutStateCapability, (state: SimpleLayoutState) => {
|
|
81
|
-
const { workspace, active } = state;
|
|
82
|
-
|
|
83
|
-
if (workspace !== lastWorkspace || active !== lastActive) {
|
|
84
|
-
lastWorkspace = workspace;
|
|
85
|
-
lastActive = active;
|
|
86
|
-
|
|
87
|
-
const path = active ? toUrlPath(active) : toUrlPath(workspace);
|
|
88
|
-
if (window.location.pathname !== path) {
|
|
89
|
-
history.pushState(null, '', `${path}${window.location.search}`);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
return Capability.contributes(Capabilities.Null, null, () =>
|
|
95
|
-
Effect.sync(() => {
|
|
96
|
-
window.removeEventListener('popstate', onNavigation);
|
|
97
|
-
unsubscribe();
|
|
98
|
-
unlistenDeepLink?.();
|
|
99
|
-
}),
|
|
100
|
-
);
|
|
101
|
-
}),
|
|
102
|
-
);
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* Check if a path is a special redirect path that shouldn't be navigated to.
|
|
106
|
-
* These paths are handled by other systems (e.g., OAuth).
|
|
107
|
-
*/
|
|
108
|
-
const isRedirectPath = (pathname: string): boolean => pathname.startsWith('/redirect/');
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* Returns a handler for navigation events (initial load and popstate) that navigates to current pathname.
|
|
112
|
-
*/
|
|
113
|
-
const handleNavigation =
|
|
114
|
-
(navigate: (pathname: string) => void): (() => void) =>
|
|
115
|
-
() =>
|
|
116
|
-
navigate(window.location.pathname);
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* Handle deep link URL from Tauri. Parses the URL and calls navigate unless it's a redirect path.
|
|
120
|
-
*/
|
|
121
|
-
const handleDeepLink = (urlString: string, navigate: (pathname: string) => void): void => {
|
|
122
|
-
log.info('[UrlHandler] Deep link received', { url: urlString });
|
|
123
|
-
try {
|
|
124
|
-
const url = new URL(urlString);
|
|
125
|
-
if (isRedirectPath(url.pathname)) {
|
|
126
|
-
log.info('[UrlHandler] Skipping redirect path (handled elsewhere)', { pathname: url.pathname });
|
|
127
|
-
return;
|
|
128
|
-
}
|
|
129
|
-
navigate(url.pathname);
|
|
130
|
-
} catch (error) {
|
|
131
|
-
log.warn('[UrlHandler] Failed to parse deep link URL', { urlString, error });
|
|
132
|
-
}
|
|
133
|
-
};
|
|
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
|
|
File without changes
|