@dxos/plugin-simple-layout 0.0.0 → 0.8.4-main.1068cf700f
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/chunk-7VLT3S46.mjs +29 -0
- package/dist/lib/browser/chunk-7VLT3S46.mjs.map +7 -0
- package/dist/lib/browser/chunk-O3BQBYMW.mjs +1165 -0
- package/dist/lib/browser/chunk-O3BQBYMW.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +101 -0
- package/dist/lib/browser/index.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -0
- package/dist/lib/browser/operation-resolver-BYRIQOQT.mjs +205 -0
- package/dist/lib/browser/operation-resolver-BYRIQOQT.mjs.map +7 -0
- package/dist/lib/browser/react-root-GPTKI5H2.mjs +21 -0
- package/dist/lib/browser/react-root-GPTKI5H2.mjs.map +7 -0
- package/dist/lib/browser/react-surface-LT5JJTPR.mjs +41 -0
- package/dist/lib/browser/react-surface-LT5JJTPR.mjs.map +7 -0
- package/dist/lib/browser/spotlight-dismiss-67PHYS5B.mjs +66 -0
- package/dist/lib/browser/spotlight-dismiss-67PHYS5B.mjs.map +7 -0
- package/dist/lib/browser/state-A3PGDWWZ.mjs +48 -0
- package/dist/lib/browser/state-A3PGDWWZ.mjs.map +7 -0
- package/dist/lib/browser/url-handler-HTIUY6WL.mjs +152 -0
- package/dist/lib/browser/url-handler-HTIUY6WL.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-UAWM4B2S.mjs +1166 -0
- package/dist/lib/node-esm/chunk-UAWM4B2S.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-VIDE5UMB.mjs +31 -0
- package/dist/lib/node-esm/chunk-VIDE5UMB.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +102 -0
- package/dist/lib/node-esm/index.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -0
- package/dist/lib/node-esm/operation-resolver-BDTFNCS2.mjs +206 -0
- package/dist/lib/node-esm/operation-resolver-BDTFNCS2.mjs.map +7 -0
- package/dist/lib/node-esm/react-root-GRG2OAI2.mjs +22 -0
- package/dist/lib/node-esm/react-root-GRG2OAI2.mjs.map +7 -0
- package/dist/lib/node-esm/react-surface-TCUSDIN2.mjs +42 -0
- package/dist/lib/node-esm/react-surface-TCUSDIN2.mjs.map +7 -0
- package/dist/lib/node-esm/spotlight-dismiss-RMLRZUVY.mjs +68 -0
- package/dist/lib/node-esm/spotlight-dismiss-RMLRZUVY.mjs.map +7 -0
- package/dist/lib/node-esm/state-ZCFZTTPL.mjs +49 -0
- package/dist/lib/node-esm/state-ZCFZTTPL.mjs.map +7 -0
- package/dist/lib/node-esm/url-handler-WBVVKVPC.mjs +153 -0
- package/dist/lib/node-esm/url-handler-WBVVKVPC.mjs.map +7 -0
- package/dist/types/src/SimpleLayoutPlugin.d.ts +7 -0
- package/dist/types/src/SimpleLayoutPlugin.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +7 -0
- package/dist/types/src/capabilities/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/operation-resolver/index.d.ts +3 -0
- package/dist/types/src/capabilities/operation-resolver/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts +5 -0
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-root/index.d.ts +6 -0
- package/dist/types/src/capabilities/react-root/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-root/react-root.d.ts +9 -0
- package/dist/types/src/capabilities/react-root/react-root.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface/index.d.ts +3 -0
- package/dist/types/src/capabilities/react-surface/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts +5 -0
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +1 -0
- package/dist/types/src/capabilities/spotlight-dismiss/index.d.ts +3 -0
- package/dist/types/src/capabilities/spotlight-dismiss/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/spotlight-dismiss/spotlight-dismiss.d.ts +14 -0
- package/dist/types/src/capabilities/spotlight-dismiss/spotlight-dismiss.d.ts.map +1 -0
- package/dist/types/src/capabilities/state/index.d.ts +13 -0
- package/dist/types/src/capabilities/state/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/state/state.d.ts +19 -0
- package/dist/types/src/capabilities/state/state.d.ts.map +1 -0
- package/dist/types/src/capabilities/url-handler/index.d.ts +3 -0
- package/dist/types/src/capabilities/url-handler/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/url-handler/url-handler.d.ts +12 -0
- package/dist/types/src/capabilities/url-handler/url-handler.d.ts.map +1 -0
- package/dist/types/src/components/ContentError.d.ts +5 -0
- package/dist/types/src/components/ContentError.d.ts.map +1 -0
- package/dist/types/src/components/ContentError.stories.d.ts +41 -0
- package/dist/types/src/components/ContentError.stories.d.ts.map +1 -0
- package/dist/types/src/components/ContentLoading.d.ts +3 -0
- package/dist/types/src/components/ContentLoading.d.ts.map +1 -0
- package/dist/types/src/components/ContentLoading.stories.d.ts +13 -0
- package/dist/types/src/components/ContentLoading.stories.d.ts.map +1 -0
- package/dist/types/src/components/Dialog/Dialog.d.ts +3 -0
- package/dist/types/src/components/Dialog/Dialog.d.ts.map +1 -0
- package/dist/types/src/components/Dialog/index.d.ts +2 -0
- package/dist/types/src/components/Dialog/index.d.ts.map +1 -0
- package/dist/types/src/components/Home/Home.d.ts +7 -0
- package/dist/types/src/components/Home/Home.d.ts.map +1 -0
- package/dist/types/src/components/Home/index.d.ts +2 -0
- package/dist/types/src/components/Home/index.d.ts.map +1 -0
- package/dist/types/src/components/MobileLayout/MobileLayout.d.ts +35 -0
- package/dist/types/src/components/MobileLayout/MobileLayout.d.ts.map +1 -0
- package/dist/types/src/components/MobileLayout/MobileLayout.stories.d.ts +7 -0
- package/dist/types/src/components/MobileLayout/MobileLayout.stories.d.ts.map +1 -0
- package/dist/types/src/components/MobileLayout/index.d.ts +2 -0
- package/dist/types/src/components/MobileLayout/index.d.ts.map +1 -0
- package/dist/types/src/components/Popover/Popover.d.ts +4 -0
- package/dist/types/src/components/Popover/Popover.d.ts.map +1 -0
- package/dist/types/src/components/Popover/index.d.ts +2 -0
- package/dist/types/src/components/Popover/index.d.ts.map +1 -0
- package/dist/types/src/components/SimpleLayout/AppBar.d.ts +26 -0
- package/dist/types/src/components/SimpleLayout/AppBar.d.ts.map +1 -0
- package/dist/types/src/components/SimpleLayout/AppBar.stories.d.ts +47 -0
- package/dist/types/src/components/SimpleLayout/AppBar.stories.d.ts.map +1 -0
- package/dist/types/src/components/SimpleLayout/Drawer.d.ts +9 -0
- package/dist/types/src/components/SimpleLayout/Drawer.d.ts.map +1 -0
- package/dist/types/src/components/SimpleLayout/Main.d.ts +9 -0
- package/dist/types/src/components/SimpleLayout/Main.d.ts.map +1 -0
- package/dist/types/src/components/SimpleLayout/NavBar.d.ts +18 -0
- package/dist/types/src/components/SimpleLayout/NavBar.d.ts.map +1 -0
- package/dist/types/src/components/SimpleLayout/NavBar.stories.d.ts +43 -0
- package/dist/types/src/components/SimpleLayout/NavBar.stories.d.ts.map +1 -0
- package/dist/types/src/components/SimpleLayout/SimpleLayout.d.ts +3 -0
- package/dist/types/src/components/SimpleLayout/SimpleLayout.d.ts.map +1 -0
- package/dist/types/src/components/SimpleLayout/SimpleLayout.stories.d.ts +47 -0
- package/dist/types/src/components/SimpleLayout/SimpleLayout.stories.d.ts.map +1 -0
- package/dist/types/src/components/SimpleLayout/index.d.ts +5 -0
- package/dist/types/src/components/SimpleLayout/index.d.ts.map +1 -0
- package/dist/types/src/components/Workspace/Workspace.d.ts +11 -0
- package/dist/types/src/components/Workspace/Workspace.d.ts.map +1 -0
- package/dist/types/src/components/Workspace/index.d.ts +2 -0
- package/dist/types/src/components/Workspace/index.d.ts.map +1 -0
- package/dist/types/src/components/hooks.d.ts +5 -0
- package/dist/types/src/components/hooks.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +7 -0
- package/dist/types/src/components/index.d.ts.map +1 -0
- package/dist/types/src/hooks/actions.d.ts +20 -0
- package/dist/types/src/hooks/actions.d.ts.map +1 -0
- package/dist/types/src/hooks/index.d.ts +7 -0
- package/dist/types/src/hooks/index.d.ts.map +1 -0
- package/dist/types/src/hooks/useAppBarProps.d.ts +7 -0
- package/dist/types/src/hooks/useAppBarProps.d.ts.map +1 -0
- package/dist/types/src/hooks/useCompanions.d.ts +12 -0
- package/dist/types/src/hooks/useCompanions.d.ts.map +1 -0
- package/dist/types/src/hooks/useDrawerActions.d.ts +13 -0
- package/dist/types/src/hooks/useDrawerActions.d.ts.map +1 -0
- package/dist/types/src/hooks/useNavbarActions.d.ts +14 -0
- package/dist/types/src/hooks/useNavbarActions.d.ts.map +1 -0
- package/dist/types/src/hooks/useSimpleLayoutState.d.ts +7 -0
- package/dist/types/src/hooks/useSimpleLayoutState.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +2 -0
- package/dist/types/src/index.d.ts.map +1 -0
- package/dist/types/src/meta.d.ts +3 -0
- package/dist/types/src/meta.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +26 -0
- package/dist/types/src/translations.d.ts.map +1 -0
- package/dist/types/src/types/capabilities.d.ts +36 -0
- package/dist/types/src/types/capabilities.d.ts.map +1 -0
- package/dist/types/src/types/events.d.ts +6 -0
- package/dist/types/src/types/events.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +3 -0
- package/dist/types/src/types/index.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -0
- package/package.json +39 -29
- package/src/SimpleLayoutPlugin.ts +25 -8
- package/src/capabilities/index.ts +3 -0
- package/src/capabilities/operation-resolver/operation-resolver.ts +135 -53
- package/src/capabilities/react-root/react-root.tsx +2 -2
- package/src/capabilities/react-surface/index.ts +7 -0
- package/src/capabilities/react-surface/react-surface.tsx +41 -0
- package/src/capabilities/spotlight-dismiss/index.ts +7 -0
- package/src/{hooks/useSpotlightDismiss.ts → capabilities/spotlight-dismiss/spotlight-dismiss.ts} +31 -40
- package/src/capabilities/state/state.tsx +25 -33
- package/src/capabilities/url-handler/index.ts +7 -0
- package/src/capabilities/url-handler/url-handler.ts +157 -0
- package/src/components/ContentError.stories.tsx +1 -1
- package/src/components/ContentLoading.stories.tsx +1 -1
- package/src/components/Dialog/Dialog.tsx +14 -14
- package/src/components/Home/Home.tsx +64 -70
- package/src/components/MobileLayout/MobileLayout.stories.tsx +125 -0
- package/src/components/MobileLayout/MobileLayout.tsx +305 -0
- package/src/components/MobileLayout/index.ts +5 -0
- package/src/components/Popover/Popover.tsx +45 -27
- package/src/components/SimpleLayout/AppBar.stories.tsx +144 -0
- package/src/components/SimpleLayout/AppBar.tsx +101 -0
- package/src/components/SimpleLayout/Drawer.tsx +102 -0
- package/src/components/SimpleLayout/Main.tsx +53 -57
- package/src/components/SimpleLayout/NavBar.stories.tsx +164 -0
- package/src/components/SimpleLayout/NavBar.tsx +29 -86
- package/src/components/SimpleLayout/SimpleLayout.stories.tsx +24 -18
- package/src/components/SimpleLayout/SimpleLayout.tsx +45 -7
- package/src/components/SimpleLayout/index.ts +3 -0
- package/src/components/Workspace/Workspace.tsx +119 -0
- package/src/components/Workspace/index.ts +5 -0
- package/src/components/hooks.ts +26 -0
- package/src/components/index.ts +2 -0
- package/src/hooks/actions.ts +85 -0
- package/src/hooks/index.ts +6 -1
- package/src/hooks/useAppBarProps.ts +112 -0
- package/src/hooks/useCompanions.ts +22 -0
- package/src/hooks/useDrawerActions.ts +98 -0
- package/src/hooks/useNavbarActions.ts +86 -0
- package/src/hooks/useSimpleLayoutState.ts +30 -0
- package/src/translations.ts +6 -0
- package/src/types/capabilities.ts +20 -4
- package/src/types/events.ts +15 -0
- package/src/types/index.ts +1 -0
- package/src/components/SimpleLayout/Banner.tsx +0 -60
- package/src/components/SimpleLayout/NavBarstories.tsx +0 -59
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import {
|
|
2
|
+
SimpleLayoutState
|
|
3
|
+
} from "./chunk-7VLT3S46.mjs";
|
|
4
|
+
|
|
5
|
+
// src/capabilities/operation-resolver/operation-resolver.ts
|
|
6
|
+
import * as Effect from "effect/Effect";
|
|
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
|
+
var MAX_HISTORY_LENGTH = 50;
|
|
12
|
+
var parseEntryId = (entryId) => {
|
|
13
|
+
const [id, variant] = entryId.split(ATTENDABLE_PATH_SEPARATOR);
|
|
14
|
+
return {
|
|
15
|
+
id,
|
|
16
|
+
variant
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
var operation_resolver_default = Capability.makeModule(Effect.fnUntraced(function* () {
|
|
20
|
+
const registry = yield* Capability.get(Capabilities.AtomRegistry);
|
|
21
|
+
const stateAtom = yield* Capability.get(SimpleLayoutState);
|
|
22
|
+
const getState = () => registry.get(stateAtom);
|
|
23
|
+
const updateState = (fn) => {
|
|
24
|
+
registry.set(stateAtom, fn(getState()));
|
|
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
|
+
// UpdateComplementary - Controls companion drawer.
|
|
45
|
+
//
|
|
46
|
+
OperationResolver.make({
|
|
47
|
+
operation: LayoutOperation.UpdateComplementary,
|
|
48
|
+
handler: Effect.fnUntraced(function* (input) {
|
|
49
|
+
if (input.state === "closed") {
|
|
50
|
+
updateState((state) => ({
|
|
51
|
+
...state,
|
|
52
|
+
drawerState: "closed"
|
|
53
|
+
}));
|
|
54
|
+
}
|
|
55
|
+
})
|
|
56
|
+
}),
|
|
57
|
+
//
|
|
58
|
+
// UpdateDialog
|
|
59
|
+
//
|
|
60
|
+
OperationResolver.make({
|
|
61
|
+
operation: LayoutOperation.UpdateDialog,
|
|
62
|
+
handler: Effect.fnUntraced(function* (input) {
|
|
63
|
+
updateState((state) => ({
|
|
64
|
+
...state,
|
|
65
|
+
dialogOpen: input.state ?? Boolean(input.subject),
|
|
66
|
+
dialogType: input.type ?? "default",
|
|
67
|
+
dialogBlockAlign: input.blockAlign ?? "center",
|
|
68
|
+
dialogOverlayClasses: input.overlayClasses,
|
|
69
|
+
dialogOverlayStyle: input.overlayStyle,
|
|
70
|
+
dialogContent: input.subject ? {
|
|
71
|
+
component: input.subject,
|
|
72
|
+
props: input.props
|
|
73
|
+
} : void 0
|
|
74
|
+
}));
|
|
75
|
+
})
|
|
76
|
+
}),
|
|
77
|
+
//
|
|
78
|
+
// UpdatePopover
|
|
79
|
+
//
|
|
80
|
+
OperationResolver.make({
|
|
81
|
+
operation: LayoutOperation.UpdatePopover,
|
|
82
|
+
handler: Effect.fnUntraced(function* (input) {
|
|
83
|
+
updateState((state) => ({
|
|
84
|
+
...state,
|
|
85
|
+
popoverOpen: input.state ?? Boolean(input.subject),
|
|
86
|
+
popoverKind: input.kind ?? "base",
|
|
87
|
+
popoverTitle: input.kind === "card" ? input.title : void 0,
|
|
88
|
+
popoverContent: typeof input.subject === "string" ? {
|
|
89
|
+
component: input.subject,
|
|
90
|
+
props: input.props
|
|
91
|
+
} : input.subject ? {
|
|
92
|
+
subject: input.subject
|
|
93
|
+
} : void 0,
|
|
94
|
+
popoverSide: input.side,
|
|
95
|
+
popoverVariant: input.variant,
|
|
96
|
+
popoverAnchor: input.variant === "virtual" ? input.anchor : state.popoverAnchor,
|
|
97
|
+
popoverAnchorId: input.variant !== "virtual" ? input.anchorId : state.popoverAnchorId
|
|
98
|
+
}));
|
|
99
|
+
})
|
|
100
|
+
}),
|
|
101
|
+
//
|
|
102
|
+
// SwitchWorkspace
|
|
103
|
+
//
|
|
104
|
+
OperationResolver.make({
|
|
105
|
+
operation: LayoutOperation.SwitchWorkspace,
|
|
106
|
+
handler: Effect.fnUntraced(function* (input) {
|
|
107
|
+
updateState((state) => ({
|
|
108
|
+
...state,
|
|
109
|
+
// TODO(wittjosiah): This is a hack to prevent the previous deck from being set for pinned items.
|
|
110
|
+
// Ideally this should be worked into the data model in a generic way.
|
|
111
|
+
previousWorkspace: !state.workspace.startsWith("!") ? state.workspace : state.previousWorkspace,
|
|
112
|
+
workspace: input.subject,
|
|
113
|
+
active: void 0,
|
|
114
|
+
// Clear history when switching workspaces.
|
|
115
|
+
history: []
|
|
116
|
+
}));
|
|
117
|
+
})
|
|
118
|
+
}),
|
|
119
|
+
//
|
|
120
|
+
// RevertWorkspace
|
|
121
|
+
//
|
|
122
|
+
OperationResolver.make({
|
|
123
|
+
operation: LayoutOperation.RevertWorkspace,
|
|
124
|
+
handler: Effect.fnUntraced(function* () {
|
|
125
|
+
const state = getState();
|
|
126
|
+
yield* Operation.invoke(LayoutOperation.SwitchWorkspace, {
|
|
127
|
+
subject: state.previousWorkspace
|
|
128
|
+
});
|
|
129
|
+
})
|
|
130
|
+
}),
|
|
131
|
+
//
|
|
132
|
+
// Open
|
|
133
|
+
//
|
|
134
|
+
OperationResolver.make({
|
|
135
|
+
operation: LayoutOperation.Open,
|
|
136
|
+
handler: Effect.fnUntraced(function* (input) {
|
|
137
|
+
const id = input.subject[0];
|
|
138
|
+
const { id: primaryId, variant } = parseEntryId(id);
|
|
139
|
+
const state = getState();
|
|
140
|
+
const isCompanionOfCurrent = variant && (primaryId === state.workspace || primaryId === state.active);
|
|
141
|
+
if (isCompanionOfCurrent) {
|
|
142
|
+
updateState((state2) => ({
|
|
143
|
+
...state2,
|
|
144
|
+
companionVariant: variant,
|
|
145
|
+
drawerState: state2.drawerState === "closed" || !state2.drawerState ? "open" : state2.drawerState
|
|
146
|
+
}));
|
|
147
|
+
} else {
|
|
148
|
+
updateState((state2) => {
|
|
149
|
+
const newHistory = state2.active ? [
|
|
150
|
+
...state2.history,
|
|
151
|
+
state2.active
|
|
152
|
+
] : state2.history;
|
|
153
|
+
const trimmedHistory = newHistory.length > MAX_HISTORY_LENGTH ? newHistory.slice(-MAX_HISTORY_LENGTH) : newHistory;
|
|
154
|
+
return {
|
|
155
|
+
...state2,
|
|
156
|
+
active: id,
|
|
157
|
+
history: trimmedHistory
|
|
158
|
+
};
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
})
|
|
162
|
+
}),
|
|
163
|
+
//
|
|
164
|
+
// Close
|
|
165
|
+
//
|
|
166
|
+
OperationResolver.make({
|
|
167
|
+
operation: LayoutOperation.Close,
|
|
168
|
+
handler: Effect.fnUntraced(function* () {
|
|
169
|
+
updateState((state) => {
|
|
170
|
+
if (state.history.length > 0) {
|
|
171
|
+
const newHistory = [
|
|
172
|
+
...state.history
|
|
173
|
+
];
|
|
174
|
+
const previousActive = newHistory.pop();
|
|
175
|
+
return {
|
|
176
|
+
...state,
|
|
177
|
+
active: previousActive,
|
|
178
|
+
history: newHistory
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
return {
|
|
182
|
+
...state,
|
|
183
|
+
active: void 0
|
|
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
|
+
export {
|
|
203
|
+
operation_resolver_default as default
|
|
204
|
+
};
|
|
205
|
+
//# sourceMappingURL=operation-resolver-BYRIQOQT.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/capabilities/operation-resolver/operation-resolver.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\n\nimport { Capabilities, Capability } from '@dxos/app-framework';\nimport { LayoutOperation } from '@dxos/app-toolkit';\nimport { Operation, OperationResolver } from '@dxos/operation';\nimport { ATTENDABLE_PATH_SEPARATOR } from '@dxos/react-ui-attention';\n\nimport { type SimpleLayoutState, SimpleLayoutState as SimpleLayoutStateCapability } from '../../types';\n\n/** Maximum number of items to keep in navigation history. */\nconst MAX_HISTORY_LENGTH = 50;\n\n/** Parse entry ID to extract primary ID and variant. */\nconst parseEntryId = (entryId: string) => {\n const [id, variant] = entryId.split(ATTENDABLE_PATH_SEPARATOR);\n return { id, variant };\n};\n\nexport default Capability.makeModule(\n Effect.fnUntraced(function* () {\n const registry = yield* Capability.get(Capabilities.AtomRegistry);\n const stateAtom = yield* Capability.get(SimpleLayoutStateCapability);\n\n const getState = () => registry.get(stateAtom);\n const updateState = (fn: (current: SimpleLayoutState) => SimpleLayoutState) => {\n registry.set(stateAtom, fn(getState()));\n };\n\n return Capability.contributes(Capabilities.OperationResolver, [\n //\n // SetLayoutMode\n //\n // TODO(burdon): No-op for to fix startup bug?\n OperationResolver.make({\n operation: LayoutOperation.SetLayoutMode,\n handler: Effect.fnUntraced(function* () {}),\n }),\n\n //\n // UpdateSidebar - No-op for simple layout.\n //\n OperationResolver.make({\n operation: LayoutOperation.UpdateSidebar,\n handler: () => Effect.void,\n }),\n\n //\n // UpdateComplementary - Controls companion drawer.\n //\n OperationResolver.make({\n operation: LayoutOperation.UpdateComplementary,\n handler: Effect.fnUntraced(function* (input) {\n if (input.state === 'closed') {\n updateState((state) => ({\n ...state,\n drawerState: 'closed',\n }));\n }\n }),\n }),\n\n //\n // UpdateDialog\n //\n OperationResolver.make({\n operation: LayoutOperation.UpdateDialog,\n handler: Effect.fnUntraced(function* (input) {\n updateState((state) => ({\n ...state,\n dialogOpen: input.state ?? Boolean(input.subject),\n dialogType: input.type ?? 'default',\n dialogBlockAlign: input.blockAlign ?? 'center',\n dialogOverlayClasses: input.overlayClasses,\n dialogOverlayStyle: input.overlayStyle,\n dialogContent: input.subject ? { component: input.subject, props: input.props } : undefined,\n }));\n }),\n }),\n\n //\n // UpdatePopover\n //\n OperationResolver.make({\n operation: LayoutOperation.UpdatePopover,\n handler: Effect.fnUntraced(function* (input) {\n updateState((state) => ({\n ...state,\n popoverOpen: input.state ?? Boolean(input.subject),\n popoverKind: input.kind ?? 'base',\n popoverTitle: input.kind === 'card' ? input.title : undefined,\n popoverContent:\n typeof input.subject === 'string'\n ? { component: input.subject, props: input.props }\n : input.subject\n ? { subject: input.subject }\n : undefined,\n popoverSide: input.side,\n popoverVariant: input.variant,\n popoverAnchor: input.variant === 'virtual' ? input.anchor : state.popoverAnchor,\n popoverAnchorId: input.variant !== 'virtual' ? input.anchorId : state.popoverAnchorId,\n }));\n }),\n }),\n\n //\n // SwitchWorkspace\n //\n OperationResolver.make({\n operation: LayoutOperation.SwitchWorkspace,\n handler: Effect.fnUntraced(function* (input) {\n updateState((state) => ({\n ...state,\n // TODO(wittjosiah): This is a hack to prevent the previous deck from being set for pinned items.\n // Ideally this should be worked into the data model in a generic way.\n previousWorkspace: !state.workspace.startsWith('!') ? state.workspace : state.previousWorkspace,\n workspace: input.subject,\n active: undefined,\n // Clear history when switching workspaces.\n history: [],\n }));\n }),\n }),\n\n //\n // RevertWorkspace\n //\n OperationResolver.make({\n operation: LayoutOperation.RevertWorkspace,\n handler: Effect.fnUntraced(function* () {\n const state = getState();\n yield* Operation.invoke(LayoutOperation.SwitchWorkspace, {\n subject: state.previousWorkspace,\n });\n }),\n }),\n\n //\n // Open\n //\n OperationResolver.make({\n operation: LayoutOperation.Open,\n handler: Effect.fnUntraced(function* (input) {\n const id = input.subject[0];\n const { id: primaryId, variant } = parseEntryId(id);\n const state = getState();\n\n // Only treat as companion when opening a variant of the current workspace/active (e.g. object~comments).\n // IDs like settings~spaceId are alternate-tree nodes and should navigate main content, not open the drawer.\n // TODO(wittjosiah): Factor out the change-companion operation from deck to a common layout operation.\n const isCompanionOfCurrent = variant && (primaryId === state.workspace || primaryId === state.active);\n if (isCompanionOfCurrent) {\n updateState((state) => ({\n ...state,\n companionVariant: variant,\n drawerState: state.drawerState === 'closed' || !state.drawerState ? 'open' : state.drawerState,\n }));\n } else {\n // Regular navigation - update active and history (use full id for alternate-tree nodes).\n updateState((state) => {\n const newHistory = state.active ? [...state.history, state.active] : state.history;\n const trimmedHistory =\n newHistory.length > MAX_HISTORY_LENGTH ? newHistory.slice(-MAX_HISTORY_LENGTH) : newHistory;\n return {\n ...state,\n active: id,\n history: trimmedHistory,\n };\n });\n }\n }),\n }),\n\n //\n // Close\n //\n OperationResolver.make({\n operation: LayoutOperation.Close,\n handler: Effect.fnUntraced(function* () {\n updateState((state) => {\n // Pop from history if available.\n if (state.history.length > 0) {\n const newHistory = [...state.history];\n const previousActive = newHistory.pop();\n return {\n ...state,\n active: previousActive,\n history: newHistory,\n };\n }\n // No history, just clear active.\n return {\n ...state,\n active: undefined,\n };\n });\n }),\n }),\n\n //\n // Set\n //\n OperationResolver.make({\n operation: LayoutOperation.Set,\n handler: Effect.fnUntraced(function* (input) {\n updateState((state) => ({\n ...state,\n active: input.subject[0],\n }));\n }),\n }),\n ]);\n }),\n);\n"],
|
|
5
|
+
"mappings": ";;;;;AAIA,YAAYA,YAAY;AAExB,SAASC,cAAcC,kBAAkB;AACzC,S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AAA;;;;IAKA3B,kBAAkBC,KAAK;MACrBC,WAAWC,gBAAgB2D;MAC3BzD,SAAgBjB,kBAAW,WAAWqB,OAAK;AACzCb,oBAAY,CAACc,WAAW;UACtB,GAAGA;UACHoC,QAAQrC,MAAMM,QAAQ,CAAA;QACxB,EAAA;MACF,CAAA;IACF,CAAA;GACD;AACH,CAAA,CAAA;",
|
|
6
|
+
"names": ["Effect", "Capabilities", "Capability", "LayoutOperation", "Operation", "OperationResolver", "ATTENDABLE_PATH_SEPARATOR", "MAX_HISTORY_LENGTH", "parseEntryId", "entryId", "id", "variant", "split", "ATTENDABLE_PATH_SEPARATOR", "Capability", "makeModule", "fnUntraced", "registry", "get", "Capabilities", "AtomRegistry", "stateAtom", "SimpleLayoutStateCapability", "getState", "updateState", "fn", "set", "contributes", "OperationResolver", "make", "operation", "LayoutOperation", "SetLayoutMode", "handler", "UpdateSidebar", "void", "UpdateComplementary", "input", "state", "drawerState", "UpdateDialog", "dialogOpen", "Boolean", "subject", "dialogType", "type", "dialogBlockAlign", "blockAlign", "dialogOverlayClasses", "overlayClasses", "dialogOverlayStyle", "overlayStyle", "dialogContent", "component", "props", "undefined", "UpdatePopover", "popoverOpen", "popoverKind", "kind", "popoverTitle", "title", "popoverContent", "popoverSide", "side", "popoverVariant", "popoverAnchor", "anchor", "popoverAnchorId", "anchorId", "SwitchWorkspace", "previousWorkspace", "workspace", "startsWith", "active", "history", "RevertWorkspace", "Operation", "invoke", "Open", "primaryId", "isCompanionOfCurrent", "companionVariant", "newHistory", "trimmedHistory", "length", "slice", "Close", "previousActive", "pop", "Set"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import {
|
|
2
|
+
SimpleLayout
|
|
3
|
+
} from "./chunk-O3BQBYMW.mjs";
|
|
4
|
+
import {
|
|
5
|
+
meta
|
|
6
|
+
} from "./chunk-7VLT3S46.mjs";
|
|
7
|
+
|
|
8
|
+
// src/capabilities/react-root/react-root.tsx
|
|
9
|
+
import * as Effect from "effect/Effect";
|
|
10
|
+
import React from "react";
|
|
11
|
+
import { Capabilities, Capability } from "@dxos/app-framework";
|
|
12
|
+
var react_root_default = Capability.makeModule(() => Effect.succeed(Capability.contributes(Capabilities.ReactRoot, {
|
|
13
|
+
id: meta.id,
|
|
14
|
+
root: () => {
|
|
15
|
+
return /* @__PURE__ */ React.createElement(SimpleLayout, null);
|
|
16
|
+
}
|
|
17
|
+
})));
|
|
18
|
+
export {
|
|
19
|
+
react_root_default as default
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=react-root-GPTKI5H2.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/capabilities/react-root/react-root.tsx"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\nimport React from 'react';\n\nimport { Capabilities, Capability } from '@dxos/app-framework';\n\nimport { SimpleLayout } from '../../components';\nimport { meta } from '../../meta';\n\nexport default Capability.makeModule(() =>\n Effect.succeed(\n Capability.contributes(Capabilities.ReactRoot, {\n id: meta.id,\n root: () => {\n return <SimpleLayout />;\n },\n }),\n ),\n);\n"],
|
|
5
|
+
"mappings": ";;;;;;;;AAIA,YAAYA,YAAY;AACxB,OAAOC,WAAW;AAElB,SAASC,cAAcC,kBAAkB;AAKzC,IAAA,qBAAeC,WAAWC,WAAW,MAC5BC,eACLF,WAAWG,YAAYC,aAAaC,WAAW;EAC7CC,IAAIC,KAAKD;EACTE,MAAM,MAAA;AACJ,WAAO,sBAAA,cAACC,cAAAA,IAAAA;EACV;AACF,CAAA,CAAA,CAAA;",
|
|
6
|
+
"names": ["Effect", "React", "Capabilities", "Capability", "Capability", "makeModule", "succeed", "contributes", "Capabilities", "ReactRoot", "id", "meta", "root", "SimpleLayout"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Home,
|
|
3
|
+
Workspace
|
|
4
|
+
} from "./chunk-O3BQBYMW.mjs";
|
|
5
|
+
import {
|
|
6
|
+
meta
|
|
7
|
+
} from "./chunk-7VLT3S46.mjs";
|
|
8
|
+
|
|
9
|
+
// src/capabilities/react-surface/react-surface.tsx
|
|
10
|
+
import * as Effect from "effect/Effect";
|
|
11
|
+
import React from "react";
|
|
12
|
+
import { Capabilities, Capability } from "@dxos/app-framework";
|
|
13
|
+
import { Surface } from "@dxos/app-framework/ui";
|
|
14
|
+
import { Node } from "@dxos/plugin-graph";
|
|
15
|
+
var ALLOWED_DISPOSITIONS = [
|
|
16
|
+
"workspace",
|
|
17
|
+
"user-account",
|
|
18
|
+
"pin-end",
|
|
19
|
+
"alternate-tree"
|
|
20
|
+
];
|
|
21
|
+
var react_surface_default = Capability.makeModule(() => Effect.succeed(Capability.contributes(Capabilities.ReactSurface, [
|
|
22
|
+
Surface.create({
|
|
23
|
+
id: `${meta.id}/home`,
|
|
24
|
+
role: "article",
|
|
25
|
+
filter: (data) => data.attendableId === Node.RootId,
|
|
26
|
+
component: () => /* @__PURE__ */ React.createElement(Home, null)
|
|
27
|
+
}),
|
|
28
|
+
Surface.create({
|
|
29
|
+
id: `${meta.id}/workspace-article`,
|
|
30
|
+
role: "article",
|
|
31
|
+
position: "fallback",
|
|
32
|
+
filter: (data) => ALLOWED_DISPOSITIONS.includes(data.properties?.disposition),
|
|
33
|
+
component: ({ data }) => /* @__PURE__ */ React.createElement(Workspace, {
|
|
34
|
+
id: data.attendableId
|
|
35
|
+
})
|
|
36
|
+
})
|
|
37
|
+
])));
|
|
38
|
+
export {
|
|
39
|
+
react_surface_default as default
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=react-surface-LT5JJTPR.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/capabilities/react-surface/react-surface.tsx"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\nimport React from 'react';\n\nimport { Capabilities, Capability } from '@dxos/app-framework';\nimport { Surface } from '@dxos/app-framework/ui';\nimport { Node } from '@dxos/plugin-graph';\n\nimport { Home, Workspace } from '../../components';\nimport { meta } from '../../meta';\n\ntype SurfaceData = {\n attendableId: string;\n properties: Record<string, any>;\n};\n\nconst ALLOWED_DISPOSITIONS = ['workspace', 'user-account', 'pin-end', 'alternate-tree'];\n\nexport default Capability.makeModule(() =>\n Effect.succeed(\n Capability.contributes(Capabilities.ReactSurface, [\n Surface.create({\n id: `${meta.id}/home`,\n role: 'article',\n filter: (data): data is SurfaceData => data.attendableId === Node.RootId,\n component: () => <Home />,\n }),\n Surface.create({\n id: `${meta.id}/workspace-article`,\n role: 'article',\n position: 'fallback',\n filter: (data): data is SurfaceData =>\n ALLOWED_DISPOSITIONS.includes((data.properties as Record<string, any>)?.disposition),\n component: ({ data }) => <Workspace id={data.attendableId} />,\n }),\n ]),\n ),\n);\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;AAIA,YAAYA,YAAY;AACxB,OAAOC,WAAW;AAElB,SAASC,cAAcC,kBAAkB;AACzC,SAASC,eAAe;AACxB,SAASC,YAAY;AAUrB,IAAMC,uBAAuB;EAAC;EAAa;EAAgB;EAAW;;AAEtE,IAAA,wBAAeC,WAAWC,WAAW,MAC5BC,eACLF,WAAWG,YAAYC,aAAaC,cAAc;EAChDC,QAAQC,OAAO;IACbC,IAAI,GAAGC,KAAKD,EAAE;IACdE,MAAM;IACNC,QAAQ,CAACC,SAA8BA,KAAKC,iBAAiBC,KAAKC;IAClEC,WAAW,MAAM,sBAAA,cAACC,MAAAA,IAAAA;EACpB,CAAA;EACAX,QAAQC,OAAO;IACbC,IAAI,GAAGC,KAAKD,EAAE;IACdE,MAAM;IACNQ,UAAU;IACVP,QAAQ,CAACC,SACPb,qBAAqBoB,SAAUP,KAAKQ,YAAoCC,WAAAA;IAC1EL,WAAW,CAAC,EAAEJ,KAAI,MAAO,sBAAA,cAACU,WAAAA;MAAUd,IAAII,KAAKC;;EAC/C,CAAA;CACD,CAAA,CAAA;",
|
|
6
|
+
"names": ["Effect", "React", "Capabilities", "Capability", "Surface", "Node", "ALLOWED_DISPOSITIONS", "Capability", "makeModule", "succeed", "contributes", "Capabilities", "ReactSurface", "Surface", "create", "id", "meta", "role", "filter", "data", "attendableId", "Node", "RootId", "component", "Home", "position", "includes", "properties", "disposition", "Workspace"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// src/capabilities/spotlight-dismiss/spotlight-dismiss.ts
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
import { Capabilities, Capability } from "@dxos/app-framework";
|
|
4
|
+
import { log } from "@dxos/log";
|
|
5
|
+
import { isTauri } from "@dxos/util";
|
|
6
|
+
var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-simple-layout/src/capabilities/spotlight-dismiss/spotlight-dismiss.ts";
|
|
7
|
+
var getTauriWindow = () => {
|
|
8
|
+
const tauri = globalThis.__TAURI__;
|
|
9
|
+
return tauri?.window;
|
|
10
|
+
};
|
|
11
|
+
var getTauriCore = () => {
|
|
12
|
+
const tauri = globalThis.__TAURI__;
|
|
13
|
+
return tauri?.core;
|
|
14
|
+
};
|
|
15
|
+
var spotlight_dismiss_default = Capability.makeModule(({ isPopover = false } = {}) => Effect.promise(async () => {
|
|
16
|
+
if (!isPopover || !isTauri()) {
|
|
17
|
+
return [];
|
|
18
|
+
}
|
|
19
|
+
let focusCleanup;
|
|
20
|
+
try {
|
|
21
|
+
const tauriWindow = getTauriWindow();
|
|
22
|
+
const tauriCore = getTauriCore();
|
|
23
|
+
if (tauriWindow && tauriCore) {
|
|
24
|
+
const win = tauriWindow.getCurrentWindow();
|
|
25
|
+
focusCleanup = await win.onFocusChanged(async ({ payload }) => {
|
|
26
|
+
if (!payload) {
|
|
27
|
+
await tauriCore.invoke("hide_spotlight");
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
} catch (err) {
|
|
32
|
+
log.catch(err, void 0, {
|
|
33
|
+
F: __dxlog_file,
|
|
34
|
+
L: 60,
|
|
35
|
+
S: void 0,
|
|
36
|
+
C: (f, a) => f(...a)
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
const handleKeyDown = async (event) => {
|
|
40
|
+
if (event.key === "Escape") {
|
|
41
|
+
event.preventDefault();
|
|
42
|
+
try {
|
|
43
|
+
const tauriCore = getTauriCore();
|
|
44
|
+
if (tauriCore) {
|
|
45
|
+
await tauriCore.invoke("hide_spotlight");
|
|
46
|
+
}
|
|
47
|
+
} catch (err) {
|
|
48
|
+
log.catch(err, void 0, {
|
|
49
|
+
F: __dxlog_file,
|
|
50
|
+
L: 73,
|
|
51
|
+
S: void 0,
|
|
52
|
+
C: (f, a) => f(...a)
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
window.addEventListener("keydown", handleKeyDown);
|
|
58
|
+
return Capability.contributes(Capabilities.Null, null, () => Effect.sync(() => {
|
|
59
|
+
focusCleanup?.();
|
|
60
|
+
window.removeEventListener("keydown", handleKeyDown);
|
|
61
|
+
}));
|
|
62
|
+
}));
|
|
63
|
+
export {
|
|
64
|
+
spotlight_dismiss_default as default
|
|
65
|
+
};
|
|
66
|
+
//# sourceMappingURL=spotlight-dismiss-67PHYS5B.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/capabilities/spotlight-dismiss/spotlight-dismiss.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\n// Based on the frontend-driven dismiss pattern from:\n// https://github.com/Jedliu/tauri-template-demo\n\nimport * as Effect from 'effect/Effect';\n\nimport { Capabilities, Capability } from '@dxos/app-framework';\nimport { log } from '@dxos/log';\nimport { isTauri } from '@dxos/util';\n\n/**\n * Get the Tauri window API from the global object.\n */\nconst getTauriWindow = (): any => {\n const tauri = (globalThis as any).__TAURI__;\n return tauri?.window;\n};\n\n/**\n * Get the Tauri core API (invoke) from the global object.\n */\nconst getTauriCore = (): any => {\n const tauri = (globalThis as any).__TAURI__;\n return tauri?.core;\n};\n\nexport type SpotlightDismissOptions = {\n /** Whether running in popover window context. */\n isPopover?: boolean;\n};\n\n/**\n * Capability that sets up spotlight panel dismiss behavior.\n * When running in Tauri popover mode, listens for focus loss and Escape key\n * to dismiss the spotlight panel. Runs at startup before React renders.\n */\nexport default Capability.makeModule(({ isPopover = false }: SpotlightDismissOptions = {}) =>\n Effect.promise(async () => {\n if (!isPopover || !isTauri()) {\n return [];\n }\n\n // Set up focus listener.\n let focusCleanup: (() => void) | undefined;\n try {\n const tauriWindow = getTauriWindow();\n const tauriCore = getTauriCore();\n if (tauriWindow && tauriCore) {\n const win = tauriWindow.getCurrentWindow();\n focusCleanup = await win.onFocusChanged(async ({ payload }: { payload: boolean }) => {\n if (!payload) {\n await tauriCore.invoke('hide_spotlight');\n }\n });\n }\n } catch (err) {\n log.catch(err);\n }\n\n // Set up Escape key listener.\n const handleKeyDown = async (event: KeyboardEvent) => {\n if (event.key === 'Escape') {\n event.preventDefault();\n try {\n const tauriCore = getTauriCore();\n if (tauriCore) {\n await tauriCore.invoke('hide_spotlight');\n }\n } catch (err) {\n log.catch(err);\n }\n }\n };\n window.addEventListener('keydown', handleKeyDown);\n\n return Capability.contributes(Capabilities.Null, null, () =>\n Effect.sync(() => {\n focusCleanup?.();\n window.removeEventListener('keydown', handleKeyDown);\n }),\n );\n }),\n);\n"],
|
|
5
|
+
"mappings": ";AAOA,YAAYA,YAAY;AAExB,SAASC,cAAcC,kBAAkB;AACzC,SAASC,WAAW;AACpB,SAASC,eAAe;;AAKxB,IAAMC,iBAAiB,MAAA;AACrB,QAAMC,QAASC,WAAmBC;AAClC,SAAOF,OAAOG;AAChB;AAKA,IAAMC,eAAe,MAAA;AACnB,QAAMJ,QAASC,WAAmBC;AAClC,SAAOF,OAAOK;AAChB;AAYA,IAAA,4BAAeT,WAAWU,WAAW,CAAC,EAAEC,YAAY,MAAK,IAA8B,CAAC,MAC/EC,eAAQ,YAAA;AACb,MAAI,CAACD,aAAa,CAACT,QAAAA,GAAW;AAC5B,WAAO,CAAA;EACT;AAGA,MAAIW;AACJ,MAAI;AACF,UAAMC,cAAcX,eAAAA;AACpB,UAAMY,YAAYP,aAAAA;AAClB,QAAIM,eAAeC,WAAW;AAC5B,YAAMC,MAAMF,YAAYG,iBAAgB;AACxCJ,qBAAe,MAAMG,IAAIE,eAAe,OAAO,EAAEC,QAAO,MAAwB;AAC9E,YAAI,CAACA,SAAS;AACZ,gBAAMJ,UAAUK,OAAO,gBAAA;QACzB;MACF,CAAA;IACF;EACF,SAASC,KAAK;AACZpB,QAAIqB,MAAMD,KAAAA,QAAAA;;;;;;EACZ;AAGA,QAAME,gBAAgB,OAAOC,UAAAA;AAC3B,QAAIA,MAAMC,QAAQ,UAAU;AAC1BD,YAAME,eAAc;AACpB,UAAI;AACF,cAAMX,YAAYP,aAAAA;AAClB,YAAIO,WAAW;AACb,gBAAMA,UAAUK,OAAO,gBAAA;QACzB;MACF,SAASC,KAAK;AACZpB,YAAIqB,MAAMD,KAAAA,QAAAA;;;;;;MACZ;IACF;EACF;AACAd,SAAOoB,iBAAiB,WAAWJ,aAAAA;AAEnC,SAAOvB,WAAW4B,YAAY7B,aAAa8B,MAAM,MAAM,MAC9CC,YAAK,MAAA;AACVjB,mBAAAA;AACAN,WAAOwB,oBAAoB,WAAWR,aAAAA;EACxC,CAAA,CAAA;AAEJ,CAAA,CAAA;",
|
|
6
|
+
"names": ["Effect", "Capabilities", "Capability", "log", "isTauri", "getTauriWindow", "tauri", "globalThis", "__TAURI__", "window", "getTauriCore", "core", "makeModule", "isPopover", "promise", "focusCleanup", "tauriWindow", "tauriCore", "win", "getCurrentWindow", "onFocusChanged", "payload", "invoke", "err", "catch", "handleKeyDown", "event", "key", "preventDefault", "addEventListener", "contributes", "Null", "sync", "removeEventListener"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import {
|
|
2
|
+
SimpleLayoutState
|
|
3
|
+
} from "./chunk-7VLT3S46.mjs";
|
|
4
|
+
|
|
5
|
+
// src/capabilities/state/state.tsx
|
|
6
|
+
import { Atom } from "@effect-atom/atom-react";
|
|
7
|
+
import * as Effect from "effect/Effect";
|
|
8
|
+
import { Capability } from "@dxos/app-framework";
|
|
9
|
+
import { AppCapabilities } from "@dxos/app-toolkit";
|
|
10
|
+
import { Node } from "@dxos/plugin-graph";
|
|
11
|
+
var defaultState = {
|
|
12
|
+
dialogOpen: false,
|
|
13
|
+
workspace: Node.RootId,
|
|
14
|
+
previousWorkspace: Node.RootId,
|
|
15
|
+
history: [],
|
|
16
|
+
isPopover: false,
|
|
17
|
+
companionVariant: void 0,
|
|
18
|
+
drawerState: "closed"
|
|
19
|
+
};
|
|
20
|
+
var state_default = Capability.makeModule(({ initialState } = {}) => Effect.sync(() => {
|
|
21
|
+
const stateAtom = Atom.make({
|
|
22
|
+
...defaultState,
|
|
23
|
+
...initialState
|
|
24
|
+
});
|
|
25
|
+
const layoutAtom = Atom.make((get) => {
|
|
26
|
+
const state = get(stateAtom);
|
|
27
|
+
return {
|
|
28
|
+
mode: "simple",
|
|
29
|
+
dialogOpen: state.dialogOpen,
|
|
30
|
+
sidebarOpen: false,
|
|
31
|
+
complementarySidebarOpen: false,
|
|
32
|
+
workspace: state.workspace,
|
|
33
|
+
active: state.active ? [
|
|
34
|
+
state.active
|
|
35
|
+
] : [],
|
|
36
|
+
inactive: [],
|
|
37
|
+
scrollIntoView: void 0
|
|
38
|
+
};
|
|
39
|
+
});
|
|
40
|
+
return [
|
|
41
|
+
Capability.contributes(SimpleLayoutState, stateAtom),
|
|
42
|
+
Capability.contributes(AppCapabilities.Layout, layoutAtom)
|
|
43
|
+
];
|
|
44
|
+
}));
|
|
45
|
+
export {
|
|
46
|
+
state_default as default
|
|
47
|
+
};
|
|
48
|
+
//# sourceMappingURL=state-A3PGDWWZ.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/capabilities/state/state.tsx"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { Atom } from '@effect-atom/atom-react';\nimport * as Effect from 'effect/Effect';\n\nimport { Capability } from '@dxos/app-framework';\nimport { AppCapabilities } from '@dxos/app-toolkit';\nimport { Node } from '@dxos/plugin-graph';\n\nimport { type SimpleLayoutState } from '../../types';\nimport { SimpleLayoutState as SimpleLayoutStateCapability } from '../../types';\n\nconst defaultState: SimpleLayoutState = {\n dialogOpen: false,\n workspace: Node.RootId,\n previousWorkspace: Node.RootId,\n history: [],\n isPopover: false,\n companionVariant: undefined,\n drawerState: 'closed',\n};\n\nexport type SimpleLayoutStateOptions = {\n initialState?: Partial<SimpleLayoutState>;\n};\n\nexport default Capability.makeModule(({ initialState }: SimpleLayoutStateOptions = {}) =>\n Effect.sync(() => {\n const stateAtom = Atom.make<SimpleLayoutState>({ ...defaultState, ...initialState });\n\n const layoutAtom = Atom.make((get): AppCapabilities.Layout => {\n const state = get(stateAtom);\n return {\n mode: 'simple',\n dialogOpen: state.dialogOpen,\n sidebarOpen: false,\n complementarySidebarOpen: false,\n workspace: state.workspace,\n active: state.active ? [state.active] : [],\n inactive: [],\n scrollIntoView: undefined,\n };\n });\n\n return [\n Capability.contributes(SimpleLayoutStateCapability, stateAtom),\n Capability.contributes(AppCapabilities.Layout, layoutAtom),\n ];\n }),\n);\n"],
|
|
5
|
+
"mappings": ";;;;;AAIA,SAASA,YAAY;AACrB,YAAYC,YAAY;AAExB,SAASC,kBAAkB;AAC3B,SAASC,uBAAuB;AAChC,SAASC,YAAY;AAKrB,IAAMC,eAAkC;EACtCC,YAAY;EACZC,WAAWC,KAAKC;EAChBC,mBAAmBF,KAAKC;EACxBE,SAAS,CAAA;EACTC,WAAW;EACXC,kBAAkBC;EAClBC,aAAa;AACf;AAMA,IAAA,gBAAeC,WAAWC,WAAW,CAAC,EAAEC,aAAY,IAA+B,CAAC,MAC3EC,YAAK,MAAA;AACV,QAAMC,YAAYC,KAAKC,KAAwB;IAAE,GAAGjB;IAAc,GAAGa;EAAa,CAAA;AAElF,QAAMK,aAAaF,KAAKC,KAAK,CAACE,QAAAA;AAC5B,UAAMC,QAAQD,IAAIJ,SAAAA;AAClB,WAAO;MACLM,MAAM;MACNpB,YAAYmB,MAAMnB;MAClBqB,aAAa;MACbC,0BAA0B;MAC1BrB,WAAWkB,MAAMlB;MACjBsB,QAAQJ,MAAMI,SAAS;QAACJ,MAAMI;UAAU,CAAA;MACxCC,UAAU,CAAA;MACVC,gBAAgBjB;IAClB;EACF,CAAA;AAEA,SAAO;IACLE,WAAWgB,YAAYC,mBAA6Bb,SAAAA;IACpDJ,WAAWgB,YAAYE,gBAAgBC,QAAQZ,UAAAA;;AAEnD,CAAA,CAAA;",
|
|
6
|
+
"names": ["Atom", "Effect", "Capability", "AppCapabilities", "Node", "defaultState", "dialogOpen", "workspace", "Node", "RootId", "previousWorkspace", "history", "isPopover", "companionVariant", "undefined", "drawerState", "Capability", "makeModule", "initialState", "sync", "stateAtom", "Atom", "make", "layoutAtom", "get", "state", "mode", "sidebarOpen", "complementarySidebarOpen", "active", "inactive", "scrollIntoView", "contributes", "SimpleLayoutStateCapability", "AppCapabilities", "Layout"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import {
|
|
2
|
+
SimpleLayoutState
|
|
3
|
+
} from "./chunk-7VLT3S46.mjs";
|
|
4
|
+
|
|
5
|
+
// src/capabilities/url-handler/url-handler.ts
|
|
6
|
+
import * as Effect from "effect/Effect";
|
|
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
|
+
var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-simple-layout/src/capabilities/url-handler/url-handler.ts";
|
|
13
|
+
var url_handler_default = Capability.makeModule(Effect.fnUntraced(function* () {
|
|
14
|
+
const { invokeSync } = yield* Capability.get(Capabilities.OperationInvoker);
|
|
15
|
+
const handlePathNavigation = (pathname) => {
|
|
16
|
+
log.info("[UrlHandler] Navigating to path", {
|
|
17
|
+
pathname
|
|
18
|
+
}, {
|
|
19
|
+
F: __dxlog_file,
|
|
20
|
+
L: 31,
|
|
21
|
+
S: this,
|
|
22
|
+
C: (f, a) => f(...a)
|
|
23
|
+
});
|
|
24
|
+
const [_, nextWorkspace, nextActive] = pathname.split("/");
|
|
25
|
+
const targetWorkspace = !nextWorkspace || nextWorkspace === "root" ? Node.RootId : nextWorkspace;
|
|
26
|
+
invokeSync(LayoutOperation.SwitchWorkspace, {
|
|
27
|
+
subject: targetWorkspace
|
|
28
|
+
});
|
|
29
|
+
if (nextActive) {
|
|
30
|
+
invokeSync(LayoutOperation.Open, {
|
|
31
|
+
subject: [
|
|
32
|
+
nextActive
|
|
33
|
+
]
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
const onNavigation = handleNavigation(handlePathNavigation);
|
|
38
|
+
yield* Effect.sync(() => onNavigation());
|
|
39
|
+
window.addEventListener("popstate", onNavigation);
|
|
40
|
+
let unlistenDeepLink;
|
|
41
|
+
if (isTauri()) {
|
|
42
|
+
yield* Effect.tryPromise({
|
|
43
|
+
try: async () => {
|
|
44
|
+
const { getCurrent, onOpenUrl } = await import("@tauri-apps/plugin-deep-link");
|
|
45
|
+
const launchUrls = await getCurrent();
|
|
46
|
+
if (launchUrls && launchUrls.length > 0) {
|
|
47
|
+
log.info("[UrlHandler] App launched with deep links", {
|
|
48
|
+
urls: launchUrls
|
|
49
|
+
}, {
|
|
50
|
+
F: __dxlog_file,
|
|
51
|
+
L: 62,
|
|
52
|
+
S: this,
|
|
53
|
+
C: (f, a) => f(...a)
|
|
54
|
+
});
|
|
55
|
+
for (const url of launchUrls) {
|
|
56
|
+
handleDeepLink(url, handlePathNavigation);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
unlistenDeepLink = await onOpenUrl((urls) => {
|
|
60
|
+
log.info("[UrlHandler] Deep links received", {
|
|
61
|
+
urls
|
|
62
|
+
}, {
|
|
63
|
+
F: __dxlog_file,
|
|
64
|
+
L: 70,
|
|
65
|
+
S: this,
|
|
66
|
+
C: (f, a) => f(...a)
|
|
67
|
+
});
|
|
68
|
+
for (const url of urls) {
|
|
69
|
+
handleDeepLink(url, handlePathNavigation);
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
log.info("[UrlHandler] Deep link listener initialized", void 0, {
|
|
73
|
+
F: __dxlog_file,
|
|
74
|
+
L: 76,
|
|
75
|
+
S: this,
|
|
76
|
+
C: (f, a) => f(...a)
|
|
77
|
+
});
|
|
78
|
+
},
|
|
79
|
+
catch: (error) => {
|
|
80
|
+
log.warn("[UrlHandler] Failed to initialize deep link listener", {
|
|
81
|
+
error
|
|
82
|
+
}, {
|
|
83
|
+
F: __dxlog_file,
|
|
84
|
+
L: 79,
|
|
85
|
+
S: this,
|
|
86
|
+
C: (f, a) => f(...a)
|
|
87
|
+
});
|
|
88
|
+
return error;
|
|
89
|
+
}
|
|
90
|
+
}).pipe(Effect.catchAll(() => Effect.void));
|
|
91
|
+
}
|
|
92
|
+
let lastWorkspace;
|
|
93
|
+
let lastActive;
|
|
94
|
+
const unsubscribe = yield* Capabilities.subscribeAtom(SimpleLayoutState, (state) => {
|
|
95
|
+
const { workspace, active } = state;
|
|
96
|
+
if (workspace !== lastWorkspace || active !== lastActive) {
|
|
97
|
+
lastWorkspace = workspace;
|
|
98
|
+
lastActive = active;
|
|
99
|
+
const path = pathFromState(workspace, active);
|
|
100
|
+
if (window.location.pathname !== path) {
|
|
101
|
+
history.pushState(null, "", `${path}${window.location.search}`);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
return Capability.contributes(Capabilities.Null, null, () => Effect.sync(() => {
|
|
106
|
+
window.removeEventListener("popstate", onNavigation);
|
|
107
|
+
unsubscribe();
|
|
108
|
+
unlistenDeepLink?.();
|
|
109
|
+
}));
|
|
110
|
+
}));
|
|
111
|
+
var isRedirectPath = (pathname) => pathname.startsWith("/redirect/");
|
|
112
|
+
var pathFromState = (workspace, active) => workspace === Node.RootId ? active ? `/${Node.RootId}/${active}` : "/" : active ? `/${workspace}/${active}` : `/${workspace}`;
|
|
113
|
+
var handleNavigation = (navigate) => () => navigate(window.location.pathname);
|
|
114
|
+
var handleDeepLink = (urlString, navigate) => {
|
|
115
|
+
log.info("[UrlHandler] Deep link received", {
|
|
116
|
+
url: urlString
|
|
117
|
+
}, {
|
|
118
|
+
F: __dxlog_file,
|
|
119
|
+
L: 146,
|
|
120
|
+
S: void 0,
|
|
121
|
+
C: (f, a) => f(...a)
|
|
122
|
+
});
|
|
123
|
+
try {
|
|
124
|
+
const url = new URL(urlString);
|
|
125
|
+
if (isRedirectPath(url.pathname)) {
|
|
126
|
+
log.info("[UrlHandler] Skipping redirect path (handled elsewhere)", {
|
|
127
|
+
pathname: url.pathname
|
|
128
|
+
}, {
|
|
129
|
+
F: __dxlog_file,
|
|
130
|
+
L: 150,
|
|
131
|
+
S: void 0,
|
|
132
|
+
C: (f, a) => f(...a)
|
|
133
|
+
});
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
navigate(url.pathname);
|
|
137
|
+
} catch (error) {
|
|
138
|
+
log.warn("[UrlHandler] Failed to parse deep link URL", {
|
|
139
|
+
urlString,
|
|
140
|
+
error
|
|
141
|
+
}, {
|
|
142
|
+
F: __dxlog_file,
|
|
143
|
+
L: 155,
|
|
144
|
+
S: void 0,
|
|
145
|
+
C: (f, a) => f(...a)
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
export {
|
|
150
|
+
url_handler_default as default
|
|
151
|
+
};
|
|
152
|
+
//# sourceMappingURL=url-handler-HTIUY6WL.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/capabilities/url-handler/url-handler.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\n\nimport { Capabilities, Capability } from '@dxos/app-framework';\nimport { LayoutOperation } from '@dxos/app-toolkit';\nimport { log } from '@dxos/log';\nimport { Node } from '@dxos/plugin-graph';\nimport { isTauri } from '@dxos/util';\n\nimport { type SimpleLayoutState, SimpleLayoutState as SimpleLayoutStateCapability } from '../../types';\n\n/**\n * URL handler for simple layout that syncs browser URL with layout state.\n * URL format: /{workspace} or /{workspace}/{active}\n * Root is represented as / or /root.\n *\n * On mobile Tauri, also listens for deep links via the deep-link plugin.\n */\nexport default Capability.makeModule(\n Effect.fnUntraced(function* () {\n const { invokeSync } = yield* Capability.get(Capabilities.OperationInvoker);\n\n /**\n * Handle navigation from a pathname.\n * Parses path and updates state accordingly.\n */\n const handlePathNavigation = (pathname: string) => {\n log.info('[UrlHandler] Navigating to path', { pathname });\n\n // Parse URL segments: /{workspace}/{active}\n const [_, nextWorkspace, nextActive] = pathname.split('/');\n\n // Determine target workspace (empty or 'root' means Node.RootId).\n const targetWorkspace = !nextWorkspace || nextWorkspace === 'root' ? Node.RootId : nextWorkspace;\n\n // Navigate via operations (they will update state accordingly).\n invokeSync(LayoutOperation.SwitchWorkspace, { subject: targetWorkspace });\n if (nextActive) {\n invokeSync(LayoutOperation.Open, { subject: [nextActive] });\n }\n };\n\n const onNavigation = handleNavigation(handlePathNavigation);\n\n // Handle initial URL and listen for browser navigation.\n yield* Effect.sync(() => onNavigation());\n window.addEventListener('popstate', onNavigation);\n\n // Set up deep link listener for mobile Tauri.\n let unlistenDeepLink: (() => void) | undefined;\n if (isTauri()) {\n yield* Effect.tryPromise({\n try: async () => {\n const { getCurrent, onOpenUrl } = await import('@tauri-apps/plugin-deep-link');\n\n // Check if app was launched via deep link (cold start).\n const launchUrls = await getCurrent();\n if (launchUrls && launchUrls.length > 0) {\n log.info('[UrlHandler] App launched with deep links', { urls: launchUrls });\n for (const url of launchUrls) {\n handleDeepLink(url, handlePathNavigation);\n }\n }\n\n // Listen for deep links while app is running.\n unlistenDeepLink = await onOpenUrl((urls) => {\n log.info('[UrlHandler] Deep links received', { urls });\n for (const url of urls) {\n handleDeepLink(url, handlePathNavigation);\n }\n });\n\n log.info('[UrlHandler] Deep link listener initialized');\n },\n catch: (error) => {\n log.warn('[UrlHandler] Failed to initialize deep link listener', { error });\n return error;\n },\n }).pipe(Effect.catchAll(() => Effect.void));\n }\n\n // Subscribe to state changes to update the URL.\n let lastWorkspace: string | undefined;\n let lastActive: string | undefined;\n const unsubscribe = yield* Capabilities.subscribeAtom(SimpleLayoutStateCapability, (state: SimpleLayoutState) => {\n const { workspace, active } = state;\n\n // Only update URL if relevant state changed.\n if (workspace !== lastWorkspace || active !== lastActive) {\n lastWorkspace = workspace;\n lastActive = active;\n\n const path = pathFromState(workspace, active);\n if (window.location.pathname !== path) {\n history.pushState(null, '', `${path}${window.location.search}`);\n }\n }\n });\n\n return Capability.contributes(Capabilities.Null, null, () =>\n Effect.sync(() => {\n window.removeEventListener('popstate', onNavigation);\n unsubscribe();\n unlistenDeepLink?.();\n }),\n );\n }),\n);\n\n// TODO(wittjosiah): Instead of hardcoding redirect paths, we should either:\n// 1. Validate that the workspace exists in the graph before navigating.\n// 2. Implement more structured routing with explicit route definitions.\n/**\n * Check if a path is a special redirect path that shouldn't be navigated to.\n * These paths are handled by other systems (e.g., OAuth).\n */\nconst isRedirectPath = (pathname: string): boolean => pathname.startsWith('/redirect/');\n\n/**\n * Build pathname from layout state. Root workspace is / or /root/{active}.\n */\nconst pathFromState = (workspace: string, active: string | undefined): string =>\n workspace === Node.RootId\n ? active\n ? `/${Node.RootId}/${active}`\n : '/'\n : active\n ? `/${workspace}/${active}`\n : `/${workspace}`;\n\n/**\n * Returns a handler for navigation events (initial load and popstate) that navigates to current pathname.\n */\nconst handleNavigation =\n (navigate: (pathname: string) => void): (() => void) =>\n () =>\n navigate(window.location.pathname);\n\n/**\n * Handle deep link URL from Tauri. Parses the URL and calls navigate unless it's a redirect path.\n */\nconst handleDeepLink = (urlString: string, navigate: (pathname: string) => void): void => {\n log.info('[UrlHandler] Deep link received', { url: urlString });\n try {\n const url = new URL(urlString);\n if (isRedirectPath(url.pathname)) {\n log.info('[UrlHandler] Skipping redirect path (handled elsewhere)', { pathname: url.pathname });\n return;\n }\n navigate(url.pathname);\n } catch (error) {\n log.warn('[UrlHandler] Failed to parse deep link URL', { urlString, error });\n }\n};\n"],
|
|
5
|
+
"mappings": ";;;;;AAIA,YAAYA,YAAY;AAExB,SAASC,cAAcC,kBAAkB;AACzC,SAASC,uBAAuB;AAChC,SAASC,WAAW;AACpB,SAASC,YAAY;AACrB,SAASC,eAAe;;AAWxB,IAAA,sBAAeC,WAAWC,WACjBC,kBAAW,aAAA;AAChB,QAAM,EAAEC,WAAU,IAAK,OAAOH,WAAWI,IAAIC,aAAaC,gBAAgB;AAM1E,QAAMC,uBAAuB,CAACC,aAAAA;AAC5BC,QAAIC,KAAK,mCAAmC;MAAEF;IAAS,GAAA;;;;;;AAGvD,UAAM,CAACG,GAAGC,eAAeC,UAAAA,IAAcL,SAASM,MAAM,GAAA;AAGtD,UAAMC,kBAAkB,CAACH,iBAAiBA,kBAAkB,SAASI,KAAKC,SAASL;AAGnFT,eAAWe,gBAAgBC,iBAAiB;MAAEC,SAASL;IAAgB,CAAA;AACvE,QAAIF,YAAY;AACdV,iBAAWe,gBAAgBG,MAAM;QAAED,SAAS;UAACP;;MAAY,CAAA;IAC3D;EACF;AAEA,QAAMS,e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;AAEA,SAAOzD,WAAW0D,YAAYrD,aAAasD,MAAM,MAAM,MAC9CnC,YAAK,MAAA;AACVC,WAAOmC,oBAAoB,YAAYtC,YAAAA;AACvCwB,gBAAAA;AACAnB,uBAAAA;EACF,CAAA,CAAA;AAEJ,CAAA,CAAA;AAUF,IAAMkC,iBAAiB,CAACrD,aAA8BA,SAASsD,WAAW,YAAA;AAK1E,IAAMT,gBAAgB,CAACH,WAAmBC,WACxCD,cAAclC,KAAKC,SACfkC,SACE,IAAInC,KAAKC,MAAM,IAAIkC,MAAAA,KACnB,MACFA,SACE,IAAID,SAAAA,IAAaC,MAAAA,KACjB,IAAID,SAAAA;AAKZ,IAAM3B,mBACJ,CAACwC,aACD,MACEA,SAAStC,OAAO6B,SAAS9C,QAAQ;AAKrC,IAAM6B,iBAAiB,CAAC2B,WAAmBD,aAAAA;AACzCtD,MAAIC,KAAK,mCAAmC;IAAE0B,KAAK4B;EAAU,GAAA;;;;;;AAC7D,MAAI;AACF,UAAM5B,MAAM,IAAI6B,IAAID,SAAAA;AACpB,QAAIH,eAAezB,IAAI5B,QAAQ,GAAG;AAChCC,UAAIC,KAAK,2DAA2D;QAAEF,UAAU4B,IAAI5B;MAAS,GAAA;;;;;;AAC7F;IACF;AACAuD,aAAS3B,IAAI5B,QAAQ;EACvB,SAAS+B,OAAO;AACd9B,QAAI+B,KAAK,8CAA8C;MAAEwB;MAAWzB;IAAM,GAAA;;;;;;EAC5E;AACF;",
|
|
6
|
+
"names": ["Effect", "Capabilities", "Capability", "LayoutOperation", "log", "Node", "isTauri", "Capability", "makeModule", "fnUntraced", "invokeSync", "get", "Capabilities", "OperationInvoker", "handlePathNavigation", "pathname", "log", "info", "_", "nextWorkspace", "nextActive", "split", "targetWorkspace", "Node", "RootId", "LayoutOperation", "SwitchWorkspace", "subject", "Open", "onNavigation", "handleNavigation", "sync", "window", "addEventListener", "unlistenDeepLink", "isTauri", "tryPromise", "try", "getCurrent", "onOpenUrl", "launchUrls", "length", "urls", "url", "handleDeepLink", "catch", "error", "warn", "pipe", "catchAll", "void", "lastWorkspace", "lastActive", "unsubscribe", "subscribeAtom", "SimpleLayoutStateCapability", "state", "workspace", "active", "path", "pathFromState", "location", "history", "pushState", "search", "contributes", "Null", "removeEventListener", "isRedirectPath", "startsWith", "navigate", "urlString", "URL"]
|
|
7
|
+
}
|