@dxos/plugin-simple-layout 0.8.4-main.d05673bc65 → 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.
Files changed (218) hide show
  1. package/dist/lib/browser/index.mjs +15 -68
  2. package/dist/lib/browser/index.mjs.map +4 -4
  3. package/dist/lib/browser/meta.json +1 -1
  4. package/dist/lib/browser/translations.mjs +34 -0
  5. package/dist/lib/browser/translations.mjs.map +7 -0
  6. package/dist/lib/node-esm/index.mjs +15 -67
  7. package/dist/lib/node-esm/index.mjs.map +4 -4
  8. package/dist/lib/node-esm/meta.json +1 -1
  9. package/dist/lib/node-esm/translations.mjs +36 -0
  10. package/dist/lib/node-esm/translations.mjs.map +7 -0
  11. package/dist/types/src/SimpleLayoutPlugin.d.ts +1 -1
  12. package/dist/types/src/SimpleLayoutPlugin.d.ts.map +1 -1
  13. package/dist/types/src/capabilities/app-graph-builder.d.ts +6 -0
  14. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -0
  15. package/dist/types/src/capabilities/index.d.ts +21 -6
  16. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  17. package/dist/types/src/capabilities/operation-handler.d.ts +6 -0
  18. package/dist/types/src/capabilities/operation-handler.d.ts.map +1 -0
  19. package/dist/types/src/capabilities/react-root.d.ts.map +1 -0
  20. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
  21. package/dist/types/src/capabilities/{spotlight-dismiss/spotlight-dismiss.d.ts → spotlight-dismiss.d.ts} +1 -1
  22. package/dist/types/src/capabilities/spotlight-dismiss.d.ts.map +1 -0
  23. package/dist/types/src/capabilities/{state/state.d.ts → state.d.ts} +1 -1
  24. package/dist/types/src/capabilities/state.d.ts.map +1 -0
  25. package/dist/types/src/capabilities/{url-handler/url-handler.d.ts → url-handler.d.ts} +1 -1
  26. package/dist/types/src/capabilities/url-handler.d.ts.map +1 -0
  27. package/dist/types/src/components/ContentError.stories.d.ts +26 -19
  28. package/dist/types/src/components/ContentError.stories.d.ts.map +1 -1
  29. package/dist/types/src/components/DebugOverlay/DebugOverlay.d.ts +19 -0
  30. package/dist/types/src/components/DebugOverlay/DebugOverlay.d.ts.map +1 -0
  31. package/dist/types/src/components/DebugOverlay/index.d.ts +2 -0
  32. package/dist/types/src/components/DebugOverlay/index.d.ts.map +1 -0
  33. package/dist/types/src/components/Dialog/Dialog.d.ts.map +1 -1
  34. package/dist/types/src/components/Home/Home.d.ts.map +1 -1
  35. package/dist/types/src/components/Loading/Loading.d.ts +3 -0
  36. package/dist/types/src/components/Loading/Loading.d.ts.map +1 -0
  37. package/dist/types/src/components/{ContentLoading/ContentLoading.stories.d.ts → Loading/Loading.stories.d.ts} +1 -1
  38. package/dist/types/src/components/Loading/Loading.stories.d.ts.map +1 -0
  39. package/dist/types/src/components/Loading/index.d.ts +2 -0
  40. package/dist/types/src/components/Loading/index.d.ts.map +1 -0
  41. package/dist/types/src/components/MobileLayout/MobileLayout.d.ts +2 -2
  42. package/dist/types/src/components/MobileLayout/MobileLayout.d.ts.map +1 -1
  43. package/dist/types/src/components/MobileLayout/MobileLayout.stories.d.ts.map +1 -1
  44. package/dist/types/src/components/NavBranch/NavBranch.d.ts.map +1 -1
  45. package/dist/types/src/components/Popover/Popover.d.ts.map +1 -1
  46. package/dist/types/src/components/SimpleLayout/AppBar.d.ts +5 -7
  47. package/dist/types/src/components/SimpleLayout/AppBar.d.ts.map +1 -1
  48. package/dist/types/src/components/SimpleLayout/AppBar.stories.d.ts +29 -22
  49. package/dist/types/src/components/SimpleLayout/AppBar.stories.d.ts.map +1 -1
  50. package/dist/types/src/components/SimpleLayout/Drawer.d.ts +4 -7
  51. package/dist/types/src/components/SimpleLayout/Drawer.d.ts.map +1 -1
  52. package/dist/types/src/components/SimpleLayout/Main.d.ts +4 -7
  53. package/dist/types/src/components/SimpleLayout/Main.d.ts.map +1 -1
  54. package/dist/types/src/components/SimpleLayout/NavBar.d.ts +5 -7
  55. package/dist/types/src/components/SimpleLayout/NavBar.d.ts.map +1 -1
  56. package/dist/types/src/components/SimpleLayout/NavBar.stories.d.ts +29 -23
  57. package/dist/types/src/components/SimpleLayout/NavBar.stories.d.ts.map +1 -1
  58. package/dist/types/src/components/SimpleLayout/SimpleLayout.d.ts.map +1 -1
  59. package/dist/types/src/components/SimpleLayout/SimpleLayout.stories.d.ts +26 -25
  60. package/dist/types/src/components/SimpleLayout/SimpleLayout.stories.d.ts.map +1 -1
  61. package/dist/types/src/components/hooks.d.ts.map +1 -1
  62. package/dist/types/src/components/index.d.ts +2 -1
  63. package/dist/types/src/components/index.d.ts.map +1 -1
  64. package/dist/types/src/hooks/actions.d.ts +2 -2
  65. package/dist/types/src/hooks/actions.d.ts.map +1 -1
  66. package/dist/types/src/hooks/useAppBarProps.d.ts +2 -2
  67. package/dist/types/src/hooks/useAppBarProps.d.ts.map +1 -1
  68. package/dist/types/src/hooks/useCompanions.d.ts.map +1 -1
  69. package/dist/types/src/hooks/useDrawerActions.d.ts.map +1 -1
  70. package/dist/types/src/hooks/useSimpleLayoutState.d.ts +1 -1
  71. package/dist/types/src/hooks/useSimpleLayoutState.d.ts.map +1 -1
  72. package/dist/types/src/operations/close.d.ts +5 -0
  73. package/dist/types/src/operations/close.d.ts.map +1 -0
  74. package/dist/types/src/operations/index.d.ts +3 -0
  75. package/dist/types/src/operations/index.d.ts.map +1 -0
  76. package/dist/types/src/operations/open.d.ts +5 -0
  77. package/dist/types/src/operations/open.d.ts.map +1 -0
  78. package/dist/types/src/operations/revert-workspace.d.ts +5 -0
  79. package/dist/types/src/operations/revert-workspace.d.ts.map +1 -0
  80. package/dist/types/src/operations/set-layout-mode.d.ts +5 -0
  81. package/dist/types/src/operations/set-layout-mode.d.ts.map +1 -0
  82. package/dist/types/src/operations/set.d.ts +5 -0
  83. package/dist/types/src/operations/set.d.ts.map +1 -0
  84. package/dist/types/src/operations/state-access.d.ts +8 -0
  85. package/dist/types/src/operations/state-access.d.ts.map +1 -0
  86. package/dist/types/src/operations/switch-workspace.d.ts +5 -0
  87. package/dist/types/src/operations/switch-workspace.d.ts.map +1 -0
  88. package/dist/types/src/operations/update-complementary.d.ts +5 -0
  89. package/dist/types/src/operations/update-complementary.d.ts.map +1 -0
  90. package/dist/types/src/operations/update-dialog.d.ts +5 -0
  91. package/dist/types/src/operations/update-dialog.d.ts.map +1 -0
  92. package/dist/types/src/operations/update-popover.d.ts +5 -0
  93. package/dist/types/src/operations/update-popover.d.ts.map +1 -0
  94. package/dist/types/src/operations/update-sidebar.d.ts +5 -0
  95. package/dist/types/src/operations/update-sidebar.d.ts.map +1 -0
  96. package/dist/types/src/translations.d.ts +26 -20
  97. package/dist/types/src/translations.d.ts.map +1 -1
  98. package/dist/types/src/types/capabilities.d.ts +10 -2
  99. package/dist/types/src/types/capabilities.d.ts.map +1 -1
  100. package/dist/types/src/types/events.d.ts.map +1 -1
  101. package/dist/types/tsconfig.tsbuildinfo +1 -1
  102. package/package.json +47 -30
  103. package/src/SimpleLayoutPlugin.ts +16 -7
  104. package/src/capabilities/app-graph-builder.ts +21 -0
  105. package/src/capabilities/index.ts +13 -6
  106. package/src/capabilities/operation-handler.ts +14 -0
  107. package/src/capabilities/{react-root/react-root.tsx → react-root.tsx} +2 -2
  108. package/src/capabilities/{react-surface/react-surface.tsx → react-surface.tsx} +12 -5
  109. package/src/capabilities/{state/state.tsx → state.tsx} +2 -2
  110. package/src/capabilities/url-handler.ts +161 -0
  111. package/src/components/ContentError.stories.tsx +1 -1
  112. package/src/components/DebugOverlay/DebugOverlay.tsx +96 -0
  113. package/src/components/DebugOverlay/index.ts +5 -0
  114. package/src/components/Dialog/Dialog.tsx +14 -3
  115. package/src/components/Home/Home.tsx +29 -29
  116. package/src/components/{ContentLoading/ContentLoading.stories.tsx → Loading/Loading.stories.tsx} +4 -4
  117. package/src/components/{ContentLoading/ContentLoading.tsx → Loading/Loading.tsx} +1 -1
  118. package/src/components/{ContentLoading → Loading}/index.ts +1 -1
  119. package/src/components/MobileLayout/MobileLayout.stories.tsx +21 -17
  120. package/src/components/MobileLayout/MobileLayout.tsx +118 -49
  121. package/src/components/NavBranch/NavBranch.tsx +26 -32
  122. package/src/components/Popover/Popover.tsx +10 -16
  123. package/src/components/SimpleLayout/AppBar.stories.tsx +10 -10
  124. package/src/components/SimpleLayout/AppBar.tsx +60 -60
  125. package/src/components/SimpleLayout/Drawer.tsx +30 -22
  126. package/src/components/SimpleLayout/Main.tsx +19 -23
  127. package/src/components/SimpleLayout/NavBar.stories.tsx +2 -2
  128. package/src/components/SimpleLayout/NavBar.tsx +8 -9
  129. package/src/components/SimpleLayout/SimpleLayout.stories.tsx +44 -67
  130. package/src/components/SimpleLayout/SimpleLayout.tsx +33 -34
  131. package/src/components/hooks.ts +1 -1
  132. package/src/components/index.ts +2 -1
  133. package/src/hooks/actions.ts +4 -3
  134. package/src/hooks/useAppBarProps.ts +8 -28
  135. package/src/hooks/useDrawerActions.ts +6 -6
  136. package/src/hooks/useNavbarActions.ts +3 -3
  137. package/src/hooks/useSimpleLayoutState.ts +1 -1
  138. package/src/operations/close.ts +34 -0
  139. package/src/operations/index.ts +16 -0
  140. package/src/operations/open.ts +63 -0
  141. package/src/operations/revert-workspace.ts +22 -0
  142. package/src/operations/set-layout-mode.ts +12 -0
  143. package/src/operations/set.ts +23 -0
  144. package/src/operations/state-access.ts +19 -0
  145. package/src/operations/switch-workspace.ts +26 -0
  146. package/src/operations/update-complementary.ts +35 -0
  147. package/src/operations/update-dialog.ts +28 -0
  148. package/src/operations/update-popover.ts +35 -0
  149. package/src/operations/update-sidebar.ts +12 -0
  150. package/src/translations.ts +21 -19
  151. package/src/types/capabilities.ts +3 -3
  152. package/dist/lib/browser/chunk-MDPEKLKR.mjs +0 -1163
  153. package/dist/lib/browser/chunk-MDPEKLKR.mjs.map +0 -7
  154. package/dist/lib/browser/chunk-MRR7PXSM.mjs +0 -29
  155. package/dist/lib/browser/chunk-MRR7PXSM.mjs.map +0 -7
  156. package/dist/lib/browser/operation-resolver-VTZ6HZ4B.mjs +0 -194
  157. package/dist/lib/browser/operation-resolver-VTZ6HZ4B.mjs.map +0 -7
  158. package/dist/lib/browser/react-root-WVQYY2JA.mjs +0 -21
  159. package/dist/lib/browser/react-root-WVQYY2JA.mjs.map +0 -7
  160. package/dist/lib/browser/react-surface-VLBR37ED.mjs +0 -44
  161. package/dist/lib/browser/react-surface-VLBR37ED.mjs.map +0 -7
  162. package/dist/lib/browser/spotlight-dismiss-67PHYS5B.mjs +0 -66
  163. package/dist/lib/browser/spotlight-dismiss-67PHYS5B.mjs.map +0 -7
  164. package/dist/lib/browser/state-TXSMUWYI.mjs +0 -48
  165. package/dist/lib/browser/state-TXSMUWYI.mjs.map +0 -7
  166. package/dist/lib/browser/url-handler-RBRONH7S.mjs +0 -151
  167. package/dist/lib/browser/url-handler-RBRONH7S.mjs.map +0 -7
  168. package/dist/lib/node-esm/chunk-DCKASLMP.mjs +0 -1164
  169. package/dist/lib/node-esm/chunk-DCKASLMP.mjs.map +0 -7
  170. package/dist/lib/node-esm/chunk-WMNTJ2MK.mjs +0 -31
  171. package/dist/lib/node-esm/chunk-WMNTJ2MK.mjs.map +0 -7
  172. package/dist/lib/node-esm/operation-resolver-R7CQ6ERU.mjs +0 -195
  173. package/dist/lib/node-esm/operation-resolver-R7CQ6ERU.mjs.map +0 -7
  174. package/dist/lib/node-esm/react-root-XBNDM7BE.mjs +0 -22
  175. package/dist/lib/node-esm/react-root-XBNDM7BE.mjs.map +0 -7
  176. package/dist/lib/node-esm/react-surface-U5NHA367.mjs +0 -45
  177. package/dist/lib/node-esm/react-surface-U5NHA367.mjs.map +0 -7
  178. package/dist/lib/node-esm/spotlight-dismiss-RMLRZUVY.mjs +0 -68
  179. package/dist/lib/node-esm/spotlight-dismiss-RMLRZUVY.mjs.map +0 -7
  180. package/dist/lib/node-esm/state-JMX6FAG4.mjs +0 -49
  181. package/dist/lib/node-esm/state-JMX6FAG4.mjs.map +0 -7
  182. package/dist/lib/node-esm/url-handler-QSMCH3JB.mjs +0 -152
  183. package/dist/lib/node-esm/url-handler-QSMCH3JB.mjs.map +0 -7
  184. package/dist/types/src/capabilities/operation-resolver/index.d.ts +0 -3
  185. package/dist/types/src/capabilities/operation-resolver/index.d.ts.map +0 -1
  186. package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts +0 -5
  187. package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +0 -1
  188. package/dist/types/src/capabilities/react-root/index.d.ts +0 -6
  189. package/dist/types/src/capabilities/react-root/index.d.ts.map +0 -1
  190. package/dist/types/src/capabilities/react-root/react-root.d.ts.map +0 -1
  191. package/dist/types/src/capabilities/react-surface/index.d.ts +0 -3
  192. package/dist/types/src/capabilities/react-surface/index.d.ts.map +0 -1
  193. package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +0 -1
  194. package/dist/types/src/capabilities/spotlight-dismiss/index.d.ts +0 -3
  195. package/dist/types/src/capabilities/spotlight-dismiss/index.d.ts.map +0 -1
  196. package/dist/types/src/capabilities/spotlight-dismiss/spotlight-dismiss.d.ts.map +0 -1
  197. package/dist/types/src/capabilities/state/index.d.ts +0 -13
  198. package/dist/types/src/capabilities/state/index.d.ts.map +0 -1
  199. package/dist/types/src/capabilities/state/state.d.ts.map +0 -1
  200. package/dist/types/src/capabilities/url-handler/index.d.ts +0 -3
  201. package/dist/types/src/capabilities/url-handler/index.d.ts.map +0 -1
  202. package/dist/types/src/capabilities/url-handler/url-handler.d.ts.map +0 -1
  203. package/dist/types/src/components/ContentLoading/ContentLoading.d.ts +0 -3
  204. package/dist/types/src/components/ContentLoading/ContentLoading.d.ts.map +0 -1
  205. package/dist/types/src/components/ContentLoading/ContentLoading.stories.d.ts.map +0 -1
  206. package/dist/types/src/components/ContentLoading/index.d.ts +0 -2
  207. package/dist/types/src/components/ContentLoading/index.d.ts.map +0 -1
  208. package/src/capabilities/operation-resolver/index.ts +0 -10
  209. package/src/capabilities/operation-resolver/operation-resolver.ts +0 -202
  210. package/src/capabilities/react-root/index.ts +0 -7
  211. package/src/capabilities/react-surface/index.ts +0 -7
  212. package/src/capabilities/spotlight-dismiss/index.ts +0 -7
  213. package/src/capabilities/state/index.ts +0 -9
  214. package/src/capabilities/url-handler/index.ts +0 -7
  215. package/src/capabilities/url-handler/url-handler.ts +0 -133
  216. /package/dist/types/src/capabilities/{react-root/react-root.d.ts → react-root.d.ts} +0 -0
  217. /package/dist/types/src/capabilities/{react-surface/react-surface.d.ts → react-surface.d.ts} +0 -0
  218. /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,7 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import { Capability } from '@dxos/app-framework';
6
-
7
- export const ReactRoot = Capability.lazy('ReactRoot', () => import('./react-root'));
@@ -1,7 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import { Capability } from '@dxos/app-framework';
6
-
7
- export const ReactSurface = Capability.lazy('ReactSurface', () => import('./react-surface'));
@@ -1,7 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import { Capability } from '@dxos/app-framework';
6
-
7
- export const SpotlightDismiss = Capability.lazy('SpotlightDismiss', () => import('./spotlight-dismiss'));
@@ -1,9 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import { Capability } from '@dxos/app-framework';
6
-
7
- export const State = Capability.lazy('State', () => import('./state'));
8
-
9
- export type { SimpleLayoutStateOptions } from './state';
@@ -1,7 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import { Capability } from '@dxos/app-framework';
6
-
7
- export const UrlHandler = Capability.lazy('UrlHandler', () => import('./url-handler'));
@@ -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
- };