@pstdio/workbench 0.39.0 → 0.41.0
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/README.md +2 -2
- package/dist/extensions.d.ts +350 -26
- package/dist/extensions.js +611 -550
- package/dist/extensions.js.map +1 -1
- package/dist/file-renderer-view-CiuJ_aMB.js +670 -0
- package/dist/file-renderer-view-CiuJ_aMB.js.map +1 -0
- package/dist/{index-Bzx1gf5-.d.ts → index-Dh0tRr9k.d.ts} +343 -316
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2359 -2016
- package/dist/index.js.map +1 -1
- package/dist/{kanban-presentation-yKUdZyuY.d.ts → kanban-presentation-C21WIlnn.d.ts} +1 -1
- package/dist/{navigation-tree-registry-DazyPivr.js → navigation-tree-registry-DkJ3i8ym.js} +2 -2
- package/dist/{navigation-tree-registry-DazyPivr.js.map → navigation-tree-registry-DkJ3i8ym.js.map} +1 -1
- package/dist/react-B-rd34kK.js +9750 -0
- package/dist/react-B-rd34kK.js.map +1 -0
- package/dist/react.d.ts +46 -7
- package/dist/react.js +2 -2
- package/dist/storage.d.ts +3 -3
- package/dist/storage.js +38 -51
- package/dist/storage.js.map +1 -1
- package/dist/webview-runtime.js +1 -1
- package/dist/{workbench-renderers-DNXWpDWd.js → workbench-renderers-CUHzLWMx.js} +126 -123
- package/dist/workbench-renderers-CUHzLWMx.js.map +1 -0
- package/package.json +4 -6
- package/dist/file-renderer-view-Cf3pcX_K.js +0 -637
- package/dist/file-renderer-view-Cf3pcX_K.js.map +0 -1
- package/dist/react-CgOb52iV.js +0 -8927
- package/dist/react-CgOb52iV.js.map +0 -1
- package/dist/workbench-renderers-DNXWpDWd.js.map +0 -1
package/dist/react.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as ReactResourceContextAction, i as ReactKanbanRendererContribution, n as ReactAttributesSource, r as ReactBoardColumnConfig, t as ReactAttributeDescriptor } from "./kanban-presentation-
|
|
1
|
+
import { $r as RegisteredWidgetContribution, A as WorkbenchCore, Ct as PreferenceScope, Fi as CommandParamSchema, Gi as ResourceRef, Jr as RegisteredMenuItem, Kr as MenuPath, Li as WorkbenchCommandExecutionContext, Ni as CommandParamDescriptor, Nr as TreeAction, P as WorkbenchModuleContribution, Pi as CommandParamOption, Qn as RegisteredDataTableRendererContribution, Qr as RegisteredPlaceholderContribution, Tt as PreferenceValue, Ut as KeybindingSequence, W as ThemePreferenceOption$1, Wr as WorkbenchPanelRenderInput, Xr as WorkbenchFocusRegionId, Xt as WorkbenchTerminalController, Y as WorkbenchStatusRegistry, bt as PreferencePropertySchema, j as WorkbenchCoreContributionContext, ji as Command, ma as Disposable, ni as WorkbenchPanelInstance, pa as WorkbenchStore, pi as WorkbenchWidgetPlacement, vi as WorkbenchRegion$1, xt as PreferenceRegistry } from "./index-Dh0tRr9k.js";
|
|
2
|
+
import { a as ReactResourceContextAction, i as ReactKanbanRendererContribution, n as ReactAttributesSource, r as ReactBoardColumnConfig, t as ReactAttributeDescriptor } from "./kanban-presentation-C21WIlnn.js";
|
|
3
3
|
import { ReactNode } from "react";
|
|
4
|
-
import { FileIconThemePreferenceOption, ResourceContextAction, ThemePreference, ThemePreferenceOption } from "@pstdio/ui";
|
|
5
4
|
import { FileUploadValue, ParamEditorProps, ParamValue } from "@pstdio/ui/param-editor";
|
|
5
|
+
import { FileIconThemePreferenceOption, ResourceContextAction, ThemePreference, ThemePreferenceOption, ThemePreferenceStorage } from "@pstdio/ui";
|
|
6
6
|
import { BoxProps, IconProps } from "@chakra-ui/react";
|
|
7
7
|
import { TerminalBridge } from "@pstdio/ui/terminal";
|
|
8
8
|
//#region src/react/breadcrumb/breadcrumb-view.d.ts
|
|
@@ -27,6 +27,22 @@ export declare const listCommandParamEntries: (params: CommandParamSchema | unde
|
|
|
27
27
|
export declare const buildCommandParamInitialValues: (params: CommandParamSchema | undefined, baseArgs?: unknown, context?: WorkbenchCommandExecutionContext) => Record<string, CommandParamValue>;
|
|
28
28
|
export declare const normalizeCommandParamValues: (params: CommandParamSchema | undefined, values: Record<string, CommandParamValue>) => Record<string, unknown>;
|
|
29
29
|
//#endregion
|
|
30
|
+
//#region src/react/command-palette/command-option-resolver.d.ts
|
|
31
|
+
interface CommandOptionState {
|
|
32
|
+
key: string;
|
|
33
|
+
status: "loading" | "ready" | "error";
|
|
34
|
+
options: CommandParamOption[];
|
|
35
|
+
error?: string;
|
|
36
|
+
}
|
|
37
|
+
type ExecuteOptionCommand = (commandId: string, args: Record<string, unknown>, signal?: AbortSignal) => Promise<unknown>;
|
|
38
|
+
//#endregion
|
|
39
|
+
//#region src/react/command-palette/command-option-status.d.ts
|
|
40
|
+
interface CommandOptionStatusProps {
|
|
41
|
+
state?: CommandOptionState;
|
|
42
|
+
onRetry: () => void;
|
|
43
|
+
}
|
|
44
|
+
export declare const CommandOptionStatus: (props: CommandOptionStatusProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
45
|
+
//#endregion
|
|
30
46
|
//#region src/react/command-palette/command-param-field.d.ts
|
|
31
47
|
interface CommandParamFieldProps {
|
|
32
48
|
entry: CommandParamEntry;
|
|
@@ -66,6 +82,15 @@ export declare const commandParamName: (entry: CommandParamEntry) => string;
|
|
|
66
82
|
/** Narrows an editor value back to what a command param can carry. */
|
|
67
83
|
export declare const readCommandParamValue: (value: ParamValue, entry?: CommandParamEntry) => CommandParamValue;
|
|
68
84
|
//#endregion
|
|
85
|
+
//#region src/react/command-palette/use-command-options.d.ts
|
|
86
|
+
export declare const useCommandOptions: (schema: CommandParamSchema, values: Record<string, CommandParamValue>, execute: ExecuteOptionCommand | undefined, onChange: (key: string, value: CommandParamValue) => void) => {
|
|
87
|
+
states: Record<string, CommandOptionState>;
|
|
88
|
+
validate: (next: {
|
|
89
|
+
[x: string]: CommandParamValue;
|
|
90
|
+
}) => Record<string, string>;
|
|
91
|
+
retry: (key: string) => void;
|
|
92
|
+
};
|
|
93
|
+
//#endregion
|
|
69
94
|
//#region src/react/focus/focus-region.d.ts
|
|
70
95
|
interface WorkbenchFocusRegionProps extends BoxProps {
|
|
71
96
|
workbench: WorkbenchCore;
|
|
@@ -106,7 +131,7 @@ export declare const createWorkbenchHotkeyRegistrations: (input: CreateWorkbench
|
|
|
106
131
|
hotkey: KeybindingSequence;
|
|
107
132
|
enabled: boolean;
|
|
108
133
|
ignoreInputs: true;
|
|
109
|
-
execute: () => Promise<
|
|
134
|
+
execute: () => Promise<void>;
|
|
110
135
|
}[];
|
|
111
136
|
export declare const WorkbenchKeybindingDispatcher: (props: WorkbenchKeybindingDispatcherProps) => null;
|
|
112
137
|
//#endregion
|
|
@@ -156,7 +181,7 @@ interface WorkbenchRegionTabsProps {
|
|
|
156
181
|
region: WorkbenchRegion$1;
|
|
157
182
|
visibilityStorageKey?: string;
|
|
158
183
|
}
|
|
159
|
-
export declare const WorkbenchRegionTabs: (props: WorkbenchRegionTabsProps) => import("react/jsx-runtime").JSX.Element
|
|
184
|
+
export declare const WorkbenchRegionTabs: (props: WorkbenchRegionTabsProps) => import("react/jsx-runtime").JSX.Element;
|
|
160
185
|
//#endregion
|
|
161
186
|
//#region src/react/region/widget-host.d.ts
|
|
162
187
|
interface WorkbenchWidgetHostProps {
|
|
@@ -232,6 +257,13 @@ interface WorkbenchTreeViewProps {
|
|
|
232
257
|
}
|
|
233
258
|
export declare const WorkbenchTreeView: (props: WorkbenchTreeViewProps) => import("react/jsx-runtime").JSX.Element;
|
|
234
259
|
//#endregion
|
|
260
|
+
//#region src/react/renderers/workbench-connection-provider.d.ts
|
|
261
|
+
interface WorkbenchConnectionProviderProps {
|
|
262
|
+
connected: boolean;
|
|
263
|
+
children: ReactNode;
|
|
264
|
+
}
|
|
265
|
+
export declare const WorkbenchConnectionProvider: (props: WorkbenchConnectionProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
266
|
+
//#endregion
|
|
235
267
|
//#region src/react/settings/settings-resources.d.ts
|
|
236
268
|
export declare const WORKBENCH_SETTINGS_OPEN_COMMAND_ID = "workbench.settings.open";
|
|
237
269
|
//#endregion
|
|
@@ -267,7 +299,10 @@ interface WorkbenchSidePanelProps {
|
|
|
267
299
|
onOpen?: () => void;
|
|
268
300
|
}
|
|
269
301
|
export declare const WorkbenchAttachedSidePanel: (props: WorkbenchSidePanelProps) => import("react/jsx-runtime").JSX.Element;
|
|
270
|
-
|
|
302
|
+
interface WorkbenchFloatingSidePanelProps extends WorkbenchSidePanelProps {
|
|
303
|
+
available?: boolean;
|
|
304
|
+
}
|
|
305
|
+
export declare const WorkbenchFloatingSidePanel: (props: WorkbenchFloatingSidePanelProps) => import("react/jsx-runtime").JSX.Element;
|
|
271
306
|
//#endregion
|
|
272
307
|
//#region src/react/statuses/workflow-status-settings.d.ts
|
|
273
308
|
interface WorkflowStatusSettingsProps {
|
|
@@ -335,6 +370,8 @@ interface WorkbenchThemeProviderProps {
|
|
|
335
370
|
initialThemePreference?: ThemePreference;
|
|
336
371
|
defaultThemePreference?: ThemePreference;
|
|
337
372
|
preferenceScope?: string;
|
|
373
|
+
/** Where the chosen theme is saved. Defaults to browser storage. */
|
|
374
|
+
themeStorage?: ThemePreferenceStorage;
|
|
338
375
|
themePreferences?: readonly ThemePreferenceOption[];
|
|
339
376
|
fileIconThemePreferences?: readonly FileIconThemePreferenceOption[];
|
|
340
377
|
}
|
|
@@ -380,6 +417,8 @@ interface WorkbenchProps {
|
|
|
380
417
|
sidePanelBubbleIcon?: ReactNode;
|
|
381
418
|
/** Host action for opening the closed Side Panel from its bubble launcher. */
|
|
382
419
|
onOpenSidePanel?: () => void;
|
|
420
|
+
/** Host storage for the chosen theme. Defaults to browser storage. */
|
|
421
|
+
themeStorage?: ThemePreferenceStorage;
|
|
383
422
|
}
|
|
384
423
|
export declare const Workbench: (props: WorkbenchProps) => import("react/jsx-runtime").JSX.Element;
|
|
385
424
|
//#endregion
|
|
@@ -395,5 +434,5 @@ export declare const disposeWorkbenchModuleHostRegistrations: (registrations: Ma
|
|
|
395
434
|
export declare const syncWorkbenchModuleHostRegistrations: (workbench: WorkbenchCore, registrations: Map<string, WorkbenchModuleHostRegistration>, modules: readonly WorkbenchModuleContribution[]) => void;
|
|
396
435
|
export declare const WorkbenchModuleHost: (props: WorkbenchModuleHostProps) => null;
|
|
397
436
|
//#endregion
|
|
398
|
-
export type { CommandFilesParamValue, CommandParamEntry, CommandParamFieldProps, CommandParamFieldRenderer, CommandParamValue, PreferenceParamEntry, ReactAttributeDescriptor, ReactAttributesSource, ReactBoardColumnConfig, ReactKanbanRendererContribution, ReactResourceContextAction, TreeActionParamsRequest, WorkbenchHotkeyRegistration, WorkbenchMenuItem, WorkbenchModuleHostProps, WorkbenchModuleHostRegistration, WorkbenchOverlayWidgetConfig, WorkbenchPanelRenderInput, WorkbenchPreferencesFormProps, WorkbenchSettingsModuleOptions };
|
|
437
|
+
export type { CommandFilesParamValue, CommandOptionState, CommandParamEntry, CommandParamFieldProps, CommandParamFieldRenderer, CommandParamValue, ExecuteOptionCommand, PreferenceParamEntry, ReactAttributeDescriptor, ReactAttributesSource, ReactBoardColumnConfig, ReactKanbanRendererContribution, ReactResourceContextAction, TreeActionParamsRequest, WorkbenchHotkeyRegistration, WorkbenchMenuItem, WorkbenchModuleHostProps, WorkbenchModuleHostRegistration, WorkbenchOverlayWidgetConfig, WorkbenchPanelRenderInput, WorkbenchPreferencesFormProps, WorkbenchSettingsModuleOptions };
|
|
399
438
|
export {};
|
package/dist/react.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $ as e, A as t, B as n, C as r, D as i, E as a, F as o, G as s, H as c, I as l, J as u, K as d, L as f, M as p, N as m, O as h, P as g, Q as _, R as v, S as y, T as b, U as x, V as S, W as C, X as w, Y as T, Z as E, _ as D,
|
|
2
|
-
export {
|
|
1
|
+
import { $ as e, A as t, B as n, C as r, D as i, E as a, F as o, G as s, H as c, I as l, J as u, K as d, L as f, M as p, N as m, O as h, P as g, Q as _, R as v, S as y, T as b, U as x, V as S, W as C, X as w, Y as T, Z as E, _ as D, at as O, b as k, ct as A, d as j, et as M, f as N, g as P, h as F, i as I, it as L, j as R, k as z, m as B, n as V, nt as H, ot as U, p as W, q as G, r as K, rt as q, st as J, t as Y, tt as X, v as Z, w as Q, x as $, y as ee, z as te } from "./react-B-rd34kK.js";
|
|
2
|
+
export { O as CommandOptionStatus, E as CommandParamField, b as WORKBENCH_SETTINGS_NAV_WIDGET_ID, z as WORKBENCH_SETTINGS_OPEN_COMMAND_ID, a as WORKBENCH_SETTINGS_PANEL_WIDGET_ID, i as WORKBENCH_SETTINGS_WIDGET_ID, F as WORKBENCH_TERMINAL_OPEN_COMMAND_ID, P as WORKBENCH_TERMINAL_PANEL_SIZE, D as WORKBENCH_TERMINAL_WIDGET_ID, I as Workbench, r as WorkbenchAttachedSidePanel, U as WorkbenchBreadcrumbView, T as WorkbenchCommandPalette, o as WorkbenchConnectionProvider, g as WorkbenchDataTableView, Q as WorkbenchFloatingSidePanel, u as WorkbenchFocusRegion, d as WorkbenchHeaderActions, A as WorkbenchIcon, x as WorkbenchKeybindingDispatcher, Y as WorkbenchModuleHost, te as WorkbenchNotificationHost, j as WorkbenchOverlayLayer, R as WorkbenchPreferencesForm, f as WorkbenchRegion, l as WorkbenchRegionTabs, k as WorkbenchTerminalPanel, W as WorkbenchThemeProvider, N as WorkbenchThemeScope, t as WorkbenchTreeView, v as WorkbenchWidgetHost, y as WorkflowStatusSettings, M as buildCommandParamInitialValues, _ as commandParamName, X as createCommandFilesParamValue, $ as createControllerTerminalBridge, c as createTreeContextMenuItems, C as createWorkbenchHotkeyRegistrations, n as createWorkbenchResourceActions, h as createWorkbenchSettingsModule, Z as createWorkbenchTerminalModule, V as disposeWorkbenchModuleHostRegistrations, H as isCommandFilesParamValue, q as listCommandParamEntries, G as listWorkbenchMenuItems, L as normalizeCommandParamValues, s as normalizeWorkbenchKeybinding, ee as openWorkbenchTerminal, p as paramValueToPreference, m as preferenceSchemaToParams, e as readCommandParamValue, K as syncWorkbenchModuleHostRegistrations, w as useCommandOptions, S as useWorkbenchResourceActionResolver, J as useWorkbenchStore, B as useWorkbenchThemePreferences };
|
package/dist/storage.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { R as WorkbenchPersistenceAdapter, Vr as TreeRendererPersistenceAdapter, Zr as LayoutPersistenceAdapter, gn as WorkbenchPageLocationPersistence, nt as WorkbenchStatusBarPersistenceAdapter, un as WorkbenchPanelMenuStatePersistenceAdapter } from "./index-Dh0tRr9k.js";
|
|
2
2
|
//#region src/storage/local-storage-persistence-helpers.d.ts
|
|
3
3
|
interface WorkbenchStorageLike {
|
|
4
4
|
readonly length?: number;
|
|
@@ -7,7 +7,7 @@ interface WorkbenchStorageLike {
|
|
|
7
7
|
setItem(key: string, value: string): void;
|
|
8
8
|
removeItem?(key: string): void;
|
|
9
9
|
}
|
|
10
|
-
type WorkbenchStoragePersistenceKind = "layout" | "layout-compatibility" | "layout-generation" | "layout-resource-index" | "layout-scope-index" | "panel-menus" | "page-location" | "
|
|
10
|
+
type WorkbenchStoragePersistenceKind = "layout" | "layout-compatibility" | "layout-generation" | "layout-resource-index" | "layout-scope-index" | "panel-menus" | "page-location" | "status-bar" | "tree";
|
|
11
11
|
interface CreateWorkbenchStoragePersistenceInput {
|
|
12
12
|
debounceMs?: number;
|
|
13
13
|
eventTarget?: {
|
|
@@ -37,11 +37,11 @@ export declare const createLocalStoragePanelMenuStatePersistence: (input: Create
|
|
|
37
37
|
export declare const createLocalStorageTreePersistence: (input: CreateLocalStorageTreePersistenceInput) => TreeRendererPersistenceAdapter;
|
|
38
38
|
export declare const createLocalStorageWorkbenchPersistence: (input: CreateLocalStorageWorkbenchPersistenceInput) => {
|
|
39
39
|
snapshotPersistence: WorkbenchPersistenceAdapter;
|
|
40
|
+
statusBarPersistence: WorkbenchStatusBarPersistenceAdapter;
|
|
40
41
|
layoutPersistence: LayoutPersistenceAdapter;
|
|
41
42
|
panelMenuStatePersistence: WorkbenchPanelMenuStatePersistenceAdapter;
|
|
42
43
|
pageLocationPersistence: WorkbenchPageLocationPersistence;
|
|
43
44
|
treePersistence: TreeRendererPersistenceAdapter;
|
|
44
|
-
sidePanelPersistence: WorkbenchSidePanelPersistenceAdapter;
|
|
45
45
|
};
|
|
46
46
|
//#endregion
|
|
47
47
|
export type { CreateLocalStoragePanelMenuStatePersistenceInput, CreateLocalStorageTreePersistenceInput, CreateLocalStorageWorkbenchPersistenceInput, WorkbenchStorageLike, WorkbenchStoragePersistenceKind };
|
package/dist/storage.js
CHANGED
|
@@ -21,7 +21,7 @@ var e = (e, t, n) => `${e}:${t}:${n ?? "global"}`, t = () => {
|
|
|
21
21
|
} catch {
|
|
22
22
|
return;
|
|
23
23
|
}
|
|
24
|
-
}, i =
|
|
24
|
+
}, i = 5, a = 1, o = 50, s = (t) => {
|
|
25
25
|
let s = n(t.storage), c = /* @__PURE__ */ new Map(), l = t.debounceMs ?? 250, u = t.eventTarget ?? (typeof window < "u" ? {
|
|
26
26
|
addEventListener: (e, t) => window.addEventListener(e, t),
|
|
27
27
|
removeEventListener: (e, t) => window.removeEventListener(e, t)
|
|
@@ -72,6 +72,10 @@ var e = (e, t, n) => `${e}:${t}:${n ?? "global"}`, t = () => {
|
|
|
72
72
|
let r = p();
|
|
73
73
|
for (let i of n) i.generation === r && (s.setItem(e(t.namespace, "layout", i.scope), i.raw), b(i.scope), x(i.scope));
|
|
74
74
|
}, C = () => {
|
|
75
|
+
if (l === 0) {
|
|
76
|
+
S();
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
75
79
|
d && clearTimeout(d), d = setTimeout(S, l);
|
|
76
80
|
};
|
|
77
81
|
return u?.addEventListener("pagehide", S), {
|
|
@@ -128,12 +132,15 @@ var e = (e, t, n) => `${e}:${t}:${n ?? "global"}`, t = () => {
|
|
|
128
132
|
return {
|
|
129
133
|
load: (n) => {
|
|
130
134
|
let a = r(i, e(t.namespace, "page-location", n));
|
|
131
|
-
|
|
135
|
+
if (a?.version === c) return {
|
|
136
|
+
location: a.location,
|
|
137
|
+
...a.rootLevel ? { rootLevel: a.rootLevel } : {}
|
|
138
|
+
};
|
|
132
139
|
},
|
|
133
140
|
save: (n, r) => {
|
|
134
141
|
let a = {
|
|
135
142
|
version: c,
|
|
136
|
-
|
|
143
|
+
...r
|
|
137
144
|
};
|
|
138
145
|
i.setItem(e(t.namespace, "page-location", n), JSON.stringify(a));
|
|
139
146
|
}
|
|
@@ -155,65 +162,45 @@ var e = (e, t, n) => `${e}:${t}:${n ?? "global"}`, t = () => {
|
|
|
155
162
|
i.setItem(a, JSON.stringify(e));
|
|
156
163
|
}
|
|
157
164
|
};
|
|
158
|
-
}, f =
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
let
|
|
167
|
-
|
|
165
|
+
}, f = (t) => {
|
|
166
|
+
let i = n(t.storage), a = s({
|
|
167
|
+
debounceMs: t.debounceMs,
|
|
168
|
+
eventTarget: t.eventTarget,
|
|
169
|
+
namespace: t.namespace,
|
|
170
|
+
storage: i
|
|
171
|
+
}), o = {
|
|
172
|
+
getSnapshot: (e) => {
|
|
173
|
+
let t = a.getLayout(e);
|
|
174
|
+
return t ? { layout: t } : void 0;
|
|
168
175
|
},
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
};
|
|
174
|
-
i.setItem(a, JSON.stringify(t));
|
|
175
|
-
}
|
|
176
|
-
};
|
|
177
|
-
}, h = (e) => {
|
|
178
|
-
let t = n(e.storage), r = s({
|
|
179
|
-
debounceMs: e.debounceMs,
|
|
180
|
-
eventTarget: e.eventTarget,
|
|
181
|
-
namespace: e.namespace,
|
|
182
|
-
storage: t
|
|
183
|
-
});
|
|
176
|
+
setSnapshot: (e, t) => a.setLayout(e.layout, t),
|
|
177
|
+
flush: a.flush,
|
|
178
|
+
dispose: a.dispose
|
|
179
|
+
}, c = e(t.namespace, "status-bar", void 0);
|
|
184
180
|
return {
|
|
185
|
-
snapshotPersistence:
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
},
|
|
190
|
-
setSnapshot: (e, t) => r.setLayout(e.layout, t),
|
|
191
|
-
flush: r.flush,
|
|
192
|
-
dispose: r.dispose
|
|
181
|
+
snapshotPersistence: o,
|
|
182
|
+
statusBarPersistence: {
|
|
183
|
+
getOrder: () => r(i, c),
|
|
184
|
+
setOrder: (e) => i.setItem(c, JSON.stringify(e))
|
|
193
185
|
},
|
|
194
|
-
layoutPersistence:
|
|
186
|
+
layoutPersistence: a,
|
|
195
187
|
panelMenuStatePersistence: u({
|
|
196
|
-
namespace:
|
|
197
|
-
scope:
|
|
198
|
-
storage:
|
|
188
|
+
namespace: t.namespace,
|
|
189
|
+
scope: t.scope ?? "global",
|
|
190
|
+
storage: i
|
|
199
191
|
}),
|
|
200
192
|
pageLocationPersistence: l({
|
|
201
|
-
namespace:
|
|
202
|
-
storage:
|
|
193
|
+
namespace: t.namespace,
|
|
194
|
+
storage: i
|
|
203
195
|
}),
|
|
204
196
|
treePersistence: d({
|
|
205
|
-
namespace:
|
|
206
|
-
scope:
|
|
207
|
-
storage:
|
|
208
|
-
}),
|
|
209
|
-
sidePanelPersistence: m({
|
|
210
|
-
namespace: e.namespace,
|
|
211
|
-
scope: e.scope,
|
|
212
|
-
storage: t
|
|
197
|
+
namespace: t.namespace,
|
|
198
|
+
scope: t.scope,
|
|
199
|
+
storage: i
|
|
213
200
|
})
|
|
214
201
|
};
|
|
215
202
|
};
|
|
216
203
|
//#endregion
|
|
217
|
-
export { s as createLocalStorageLayoutPersistence, l as createLocalStoragePageLocationPersistence, u as createLocalStoragePanelMenuStatePersistence, d as createLocalStorageTreePersistence,
|
|
204
|
+
export { s as createLocalStorageLayoutPersistence, l as createLocalStoragePageLocationPersistence, u as createLocalStoragePanelMenuStatePersistence, d as createLocalStorageTreePersistence, f as createLocalStorageWorkbenchPersistence, e as workbenchStoragePersistenceKey };
|
|
218
205
|
|
|
219
206
|
//# sourceMappingURL=storage.js.map
|
package/dist/storage.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.js","names":["WorkbenchStorageLike","length","getItem","key","index","setItem","value","removeItem","WorkbenchStoragePersistenceKind","CreateWorkbenchStoragePersistenceInput","debounceMs","eventTarget","addEventListener","type","listener","removeEventListener","namespace","storage","workbenchStoragePersistenceKey","kind","scope","createMemoryStorage","map","Map","size","get","keys","set","delete","resolveStorage","localStorage","readJson","T","raw","undefined","JSON","parse","LayoutPersistenceAdapter","WorkbenchLayout","CreateWorkbenchStoragePersistenceInput","readJson","resolveStorage","workbenchStoragePersistenceKey","PersistedWorkbenchLayoutV4","version","layout","PersistedWorkbenchLayout","WORKBENCH_LAYOUT_VERSION","const","WORKBENCH_LAYOUT_INDEX_VERSION","WORKBENCH_LAYOUT_RESOURCE_LIMIT","PersistedWorkbenchLayoutScopeIndex","scopes","PersistedWorkbenchLayoutGeneration","generation","createLocalStorageLayoutPersistence","input","storage","pending","Map","raw","scope","debounceMs","eventTarget","window","addEventListener","type","listener","removeEventListener","undefined","timer","ReturnType","setTimeout","generationKey","namespace","getGeneration","persisted","advanceGeneration","setItem","JSON","stringify","resourceProjectId","match","scopeProjectId","storedProjectScopes","projectId","key","prefix","index","length","startsWith","slice","push","readScopes","kind","Array","isArray","filter","getItem","writeScopes","next","touchProjectScope","candidate","touchResourceScope","evictedScope","splice","Math","max","removeItem","flush","clearTimeout","writes","values","clear","write","scheduleFlush","getLayout","pendingWrite","get","parse","setLayout","delete","set","listScopes","Set","transformLayouts","transform","getCompatibilityMarker","setCompatibilityMarker","value","advanceWriteGeneration","dispose","PageLocation","PersistedTreeRendererStates","PersistedWorkbenchPanelMenuState","TreeRendererPersistenceAdapter","WorkbenchPageLocationPersistence","WorkbenchPanelMenuStatePersistenceAdapter","WorkbenchPersistenceAdapter","WorkbenchSidePanelMode","WorkbenchSidePanelPersistenceAdapter","createLocalStorageLayoutPersistence","CreateWorkbenchStoragePersistenceInput","readJson","resolveStorage","workbenchStoragePersistenceKey","WorkbenchStorageLike","WorkbenchStoragePersistenceKind","CreateLocalStoragePanelMenuStatePersistenceInput","scope","CreateLocalStorageTreePersistenceInput","CreateLocalStorageWorkbenchPersistenceInput","PersistedWorkbenchPageLocation","version","location","WORKBENCH_PAGE_LOCATION_VERSION","const","createLocalStoragePageLocationPersistence","input","storage","load","projectId","persisted","namespace","undefined","save","setItem","JSON","stringify","createLocalStoragePanelMenuStatePersistence","getMenuStates","setMenuStates","state","key","createLocalStorageTreePersistence","getTreeStates","setTreeStates","PersistedWorkbenchSidePanel","mode","WORKBENCH_SIDE_PANEL_VERSION","sidePanelModes","CreateLocalStorageSidePanelPersistenceInput","createLocalStorageSidePanelPersistence","getMode","includes","setMode","createLocalStorageWorkbenchPersistence","layoutPersistence","debounceMs","eventTarget","snapshotPersistence","getSnapshot","layout","getLayout","setSnapshot","snapshot","setLayout","flush","dispose","panelMenuStatePersistence","pageLocationPersistence","treePersistence","sidePanelPersistence","workbenchStoragePersistenceKey","namespace","kind","scope","createMemoryStorage","map","key","index","value","resolveStorage","storage","readJson","raw","WORKBENCH_LAYOUT_VERSION","WORKBENCH_LAYOUT_INDEX_VERSION","WORKBENCH_LAYOUT_RESOURCE_LIMIT","createLocalStorageLayoutPersistence","input","pending","debounceMs","eventTarget","type","listener","timer","generationKey","getGeneration","persisted","advanceGeneration","generation","resourceProjectId","scopeProjectId","storedProjectScopes","prefix","scopes","projectId","readScopes","writeScopes","next","touchProjectScope","candidate","touchResourceScope","evictedScope","flush","writes","write","scheduleFlush","pendingWrite","layout","transform","WORKBENCH_PAGE_LOCATION_VERSION","createLocalStoragePageLocationPersistence","createLocalStoragePanelMenuStatePersistence","state","createLocalStorageTreePersistence","WORKBENCH_SIDE_PANEL_VERSION","sidePanelModes","createLocalStorageSidePanelPersistence","createLocalStorageWorkbenchPersistence","layoutPersistence","snapshot"],"sources":["../src/storage/local-storage-persistence-helpers.ts","../src/storage/local-storage-layout-persistence.ts","../src/storage/local-storage-persistence.ts"],"sourcesContent":["export interface WorkbenchStorageLike {\n readonly length?: number;\n getItem(key: string): string | null;\n key?(index: number): string | null;\n setItem(key: string, value: string): void;\n removeItem?(key: string): void;\n}\n\nexport type WorkbenchStoragePersistenceKind =\n | \"layout\"\n | \"layout-compatibility\"\n | \"layout-generation\"\n | \"layout-resource-index\"\n | \"layout-scope-index\"\n | \"panel-menus\"\n | \"page-location\"\n | \"side-panel\"\n | \"tree\";\n\nexport interface CreateWorkbenchStoragePersistenceInput {\n debounceMs?: number;\n eventTarget?: {\n addEventListener(type: \"pagehide\", listener: () => void): void;\n removeEventListener(type: \"pagehide\", listener: () => void): void;\n };\n namespace: string;\n storage?: WorkbenchStorageLike;\n}\n\nexport const workbenchStoragePersistenceKey = (\n namespace: string,\n kind: WorkbenchStoragePersistenceKind,\n scope: string | undefined,\n) => `${namespace}:${kind}:${scope ?? \"global\"}`;\n\nconst createMemoryStorage = (): WorkbenchStorageLike => {\n const map = new Map<string, string>();\n return {\n get length() {\n return map.size;\n },\n getItem: (key) => map.get(key) ?? null,\n key: (index) => [...map.keys()][index] ?? null,\n setItem: (key, value) => {\n map.set(key, value);\n },\n removeItem: (key) => {\n map.delete(key);\n },\n };\n};\n\nexport const resolveStorage = (storage?: WorkbenchStorageLike): WorkbenchStorageLike => {\n if (storage) return storage;\n if (typeof localStorage !== \"undefined\") return localStorage;\n return createMemoryStorage();\n};\n\nexport const readJson = <T>(storage: WorkbenchStorageLike, key: string): T | undefined => {\n const raw = storage.getItem(key);\n if (!raw) return undefined;\n try {\n return JSON.parse(raw) as T;\n } catch {\n return undefined;\n }\n};\n","import type { LayoutPersistenceAdapter, WorkbenchLayout } from \"../core\";\nimport {\n type CreateWorkbenchStoragePersistenceInput,\n readJson,\n resolveStorage,\n workbenchStoragePersistenceKey,\n} from \"./local-storage-persistence-helpers\";\n\ninterface PersistedWorkbenchLayoutV4 {\n version: 4;\n layout: WorkbenchLayout;\n}\n\ntype PersistedWorkbenchLayout = PersistedWorkbenchLayoutV4;\n\n// Version 4 stores ResourceRef identity keys and page Main collections. Only the\n// layout cache changes; routed locations and independent preferences stay valid.\nconst WORKBENCH_LAYOUT_VERSION = 4 as const;\nconst WORKBENCH_LAYOUT_INDEX_VERSION = 1 as const;\nconst WORKBENCH_LAYOUT_RESOURCE_LIMIT = 50;\n\ninterface PersistedWorkbenchLayoutScopeIndex {\n version: 1;\n scopes: string[];\n}\n\ninterface PersistedWorkbenchLayoutGeneration {\n version: 1;\n generation: number;\n}\n\nexport const createLocalStorageLayoutPersistence = (\n input: CreateWorkbenchStoragePersistenceInput,\n): LayoutPersistenceAdapter => {\n const storage = resolveStorage(input.storage);\n const pending = new Map<string, { generation: number; raw: string; scope: string | undefined }>();\n const debounceMs = input.debounceMs ?? 250;\n const eventTarget =\n input.eventTarget ??\n (typeof window !== \"undefined\"\n ? {\n addEventListener: (type: \"pagehide\", listener: () => void) => window.addEventListener(type, listener),\n removeEventListener: (type: \"pagehide\", listener: () => void) => window.removeEventListener(type, listener),\n }\n : undefined);\n let timer: ReturnType<typeof setTimeout> | undefined;\n\n const generationKey = workbenchStoragePersistenceKey(input.namespace, \"layout-generation\", undefined);\n const getGeneration = () => {\n const persisted = readJson<unknown>(storage, generationKey);\n return typeof persisted === \"object\" &&\n persisted !== null &&\n \"version\" in persisted &&\n persisted.version === 1 &&\n \"generation\" in persisted &&\n typeof persisted.generation === \"number\"\n ? persisted.generation\n : 0;\n };\n\n const advanceGeneration = () => {\n const generation = getGeneration() + 1;\n const persisted: PersistedWorkbenchLayoutGeneration = { version: 1, generation };\n storage.setItem(generationKey, JSON.stringify(persisted));\n return generation;\n };\n\n const resourceProjectId = (scope: string | undefined) =>\n scope?.match(/^project\\/([^/]+)\\/mode\\/[^/]+\\/resource\\//)?.[1];\n const scopeProjectId = (scope: string | undefined) => scope?.match(/^project\\/([^/]+)/)?.[1];\n\n const storedProjectScopes = (projectId: string) => {\n if (!storage.key) return [];\n const prefix = `${input.namespace}:layout:`;\n const scopes: string[] = [];\n for (let index = 0; index < (storage.length ?? 0); index += 1) {\n const key = storage.key(index);\n if (!key?.startsWith(prefix)) continue;\n const scope = key.slice(prefix.length);\n if (scopeProjectId(scope) === projectId) scopes.push(scope);\n }\n return scopes;\n };\n\n const readScopes = (kind: \"layout-resource-index\" | \"layout-scope-index\", projectId: string) => {\n const persisted = readJson<unknown>(storage, workbenchStoragePersistenceKey(input.namespace, kind, projectId));\n return typeof persisted === \"object\" &&\n persisted !== null &&\n \"version\" in persisted &&\n persisted.version === WORKBENCH_LAYOUT_INDEX_VERSION &&\n \"scopes\" in persisted &&\n Array.isArray(persisted.scopes)\n ? persisted.scopes.filter(\n (scope): scope is string =>\n typeof scope === \"string\" &&\n storage.getItem(workbenchStoragePersistenceKey(input.namespace, \"layout\", scope)) !== null,\n )\n : [];\n };\n\n const writeScopes = (kind: \"layout-resource-index\" | \"layout-scope-index\", projectId: string, scopes: string[]) => {\n const next: PersistedWorkbenchLayoutScopeIndex = { version: WORKBENCH_LAYOUT_INDEX_VERSION, scopes };\n storage.setItem(workbenchStoragePersistenceKey(input.namespace, kind, projectId), JSON.stringify(next));\n };\n\n const touchProjectScope = (scope: string | undefined) => {\n const projectId = scopeProjectId(scope);\n if (!projectId || !scope) return;\n const scopes = readScopes(\"layout-scope-index\", projectId).filter((candidate) => candidate !== scope);\n scopes.push(scope);\n writeScopes(\"layout-scope-index\", projectId, scopes);\n };\n\n const touchResourceScope = (scope: string | undefined) => {\n const projectId = resourceProjectId(scope);\n if (!projectId || !scope) return;\n const scopes = readScopes(\"layout-resource-index\", projectId).filter((candidate) => candidate !== scope);\n scopes.push(scope);\n for (const evictedScope of scopes.splice(0, Math.max(0, scopes.length - WORKBENCH_LAYOUT_RESOURCE_LIMIT))) {\n storage.removeItem?.(workbenchStoragePersistenceKey(input.namespace, \"layout\", evictedScope));\n storage.removeItem?.(workbenchStoragePersistenceKey(input.namespace, \"panel-menus\", evictedScope));\n }\n writeScopes(\"layout-resource-index\", projectId, scopes);\n };\n\n const flush = () => {\n if (timer) clearTimeout(timer);\n timer = undefined;\n const writes = [...pending.values()];\n pending.clear();\n const generation = getGeneration();\n for (const write of writes) {\n if (write.generation !== generation) continue;\n storage.setItem(workbenchStoragePersistenceKey(input.namespace, \"layout\", write.scope), write.raw);\n touchProjectScope(write.scope);\n touchResourceScope(write.scope);\n }\n };\n\n const scheduleFlush = () => {\n if (timer) clearTimeout(timer);\n timer = setTimeout(flush, debounceMs);\n };\n\n eventTarget?.addEventListener(\"pagehide\", flush);\n\n return {\n getLayout: (scope) => {\n const key = workbenchStoragePersistenceKey(input.namespace, \"layout\", scope);\n const pendingWrite = pending.get(key);\n const persisted =\n pendingWrite && pendingWrite.generation === getGeneration()\n ? (JSON.parse(pendingWrite.raw) as PersistedWorkbenchLayout)\n : readJson<PersistedWorkbenchLayout>(storage, key);\n if (persisted?.version === WORKBENCH_LAYOUT_VERSION) return persisted.layout;\n return undefined;\n },\n setLayout: (layout, scope) => {\n const persisted: PersistedWorkbenchLayoutV4 = { version: WORKBENCH_LAYOUT_VERSION, layout };\n const key = workbenchStoragePersistenceKey(input.namespace, \"layout\", scope);\n pending.delete(key);\n pending.set(key, {\n generation: getGeneration(),\n raw: JSON.stringify(persisted),\n scope,\n });\n scheduleFlush();\n },\n flush,\n listScopes(projectId) {\n return [\n ...new Set([\n ...readScopes(\"layout-scope-index\", projectId),\n ...readScopes(\"layout-resource-index\", projectId),\n ...storedProjectScopes(projectId),\n ]),\n ];\n },\n transformLayouts(projectId, transform) {\n flush();\n advanceGeneration();\n for (const scope of this.listScopes?.(projectId) ?? []) {\n const key = workbenchStoragePersistenceKey(input.namespace, \"layout\", scope);\n const persisted = readJson<PersistedWorkbenchLayout>(storage, key);\n if (persisted?.version !== WORKBENCH_LAYOUT_VERSION) continue;\n const layout = transform(persisted.layout, scope);\n if (!layout) {\n storage.removeItem?.(key);\n continue;\n }\n storage.setItem(\n key,\n JSON.stringify({ version: WORKBENCH_LAYOUT_VERSION, layout } satisfies PersistedWorkbenchLayoutV4),\n );\n }\n },\n getCompatibilityMarker: (key) =>\n readJson<string>(storage, workbenchStoragePersistenceKey(input.namespace, \"layout-compatibility\", key)),\n setCompatibilityMarker: (key, value) => {\n advanceGeneration();\n storage.setItem(\n workbenchStoragePersistenceKey(input.namespace, \"layout-compatibility\", key),\n JSON.stringify(value),\n );\n },\n advanceWriteGeneration: advanceGeneration,\n dispose() {\n flush();\n eventTarget?.removeEventListener(\"pagehide\", flush);\n },\n };\n};\n","import type { PageLocation } from \"@pstdio/sdk/extensions\";\nimport type {\n PersistedTreeRendererStates,\n PersistedWorkbenchPanelMenuState,\n TreeRendererPersistenceAdapter,\n WorkbenchPageLocationPersistence,\n WorkbenchPanelMenuStatePersistenceAdapter,\n WorkbenchPersistenceAdapter,\n WorkbenchSidePanelMode,\n WorkbenchSidePanelPersistenceAdapter,\n} from \"../core\";\nimport { createLocalStorageLayoutPersistence } from \"./local-storage-layout-persistence\";\nimport {\n type CreateWorkbenchStoragePersistenceInput,\n readJson,\n resolveStorage,\n workbenchStoragePersistenceKey,\n} from \"./local-storage-persistence-helpers\";\n\nexport type {\n WorkbenchStorageLike,\n WorkbenchStoragePersistenceKind,\n} from \"./local-storage-persistence-helpers\";\nexport { createLocalStorageLayoutPersistence, workbenchStoragePersistenceKey };\n\nexport interface CreateLocalStoragePanelMenuStatePersistenceInput extends CreateWorkbenchStoragePersistenceInput {\n scope: string;\n}\n\nexport interface CreateLocalStorageTreePersistenceInput extends CreateWorkbenchStoragePersistenceInput {\n scope?: string;\n}\n\nexport interface CreateLocalStorageWorkbenchPersistenceInput extends CreateWorkbenchStoragePersistenceInput {\n scope?: string;\n}\n\ninterface PersistedWorkbenchPageLocation {\n version: 1;\n location: PageLocation;\n}\n\nconst WORKBENCH_PAGE_LOCATION_VERSION = 1 as const;\n\nexport const createLocalStoragePageLocationPersistence = (\n input: CreateWorkbenchStoragePersistenceInput,\n): WorkbenchPageLocationPersistence => {\n const storage = resolveStorage(input.storage);\n return {\n load: (projectId) => {\n const persisted = readJson<PersistedWorkbenchPageLocation>(\n storage,\n workbenchStoragePersistenceKey(input.namespace, \"page-location\", projectId),\n );\n return persisted?.version === WORKBENCH_PAGE_LOCATION_VERSION ? persisted.location : undefined;\n },\n save: (projectId, location) => {\n const persisted: PersistedWorkbenchPageLocation = {\n version: WORKBENCH_PAGE_LOCATION_VERSION,\n location,\n };\n storage.setItem(\n workbenchStoragePersistenceKey(input.namespace, \"page-location\", projectId),\n JSON.stringify(persisted),\n );\n },\n };\n};\nexport const createLocalStoragePanelMenuStatePersistence = (\n input: CreateLocalStoragePanelMenuStatePersistenceInput,\n): WorkbenchPanelMenuStatePersistenceAdapter => {\n const storage = resolveStorage(input.storage);\n return {\n getMenuStates: (scope) =>\n readJson<PersistedWorkbenchPanelMenuState>(\n storage,\n workbenchStoragePersistenceKey(input.namespace, \"panel-menus\", scope ?? input.scope),\n ),\n setMenuStates: (state, scope) => {\n const key = workbenchStoragePersistenceKey(input.namespace, \"panel-menus\", scope ?? input.scope);\n storage.setItem(key, JSON.stringify(state));\n },\n };\n};\n\nexport const createLocalStorageTreePersistence = (\n input: CreateLocalStorageTreePersistenceInput,\n): TreeRendererPersistenceAdapter => {\n const storage = resolveStorage(input.storage);\n const key = workbenchStoragePersistenceKey(input.namespace, \"tree\", input.scope);\n return {\n getTreeStates: () => readJson<PersistedTreeRendererStates>(storage, key),\n setTreeStates: (state) => {\n storage.setItem(key, JSON.stringify(state));\n },\n };\n};\n\ninterface PersistedWorkbenchSidePanel {\n version: 1;\n mode: WorkbenchSidePanelMode;\n}\n\nconst WORKBENCH_SIDE_PANEL_VERSION = 1 as const;\nconst sidePanelModes: readonly WorkbenchSidePanelMode[] = [\"attached\", \"closed\", \"floating\"];\n\nexport interface CreateLocalStorageSidePanelPersistenceInput extends CreateWorkbenchStoragePersistenceInput {\n scope?: string;\n}\n\nexport const createLocalStorageSidePanelPersistence = (\n input: CreateLocalStorageSidePanelPersistenceInput,\n): WorkbenchSidePanelPersistenceAdapter => {\n const storage = resolveStorage(input.storage);\n const key = workbenchStoragePersistenceKey(input.namespace, \"side-panel\", input.scope);\n return {\n getMode: () => {\n const persisted = readJson<PersistedWorkbenchSidePanel>(storage, key);\n if (persisted?.version !== WORKBENCH_SIDE_PANEL_VERSION) return undefined;\n return sidePanelModes.includes(persisted.mode) ? persisted.mode : undefined;\n },\n setMode: (mode) => {\n const persisted: PersistedWorkbenchSidePanel = { version: WORKBENCH_SIDE_PANEL_VERSION, mode };\n storage.setItem(key, JSON.stringify(persisted));\n },\n };\n};\n\nexport const createLocalStorageWorkbenchPersistence = (input: CreateLocalStorageWorkbenchPersistenceInput) => {\n const storage = resolveStorage(input.storage);\n const layoutPersistence = createLocalStorageLayoutPersistence({\n debounceMs: input.debounceMs,\n eventTarget: input.eventTarget,\n namespace: input.namespace,\n storage,\n });\n const snapshotPersistence: WorkbenchPersistenceAdapter = {\n getSnapshot: (scope) => {\n const layout = layoutPersistence.getLayout(scope);\n return layout ? { layout } : undefined;\n },\n setSnapshot: (snapshot, scope) => layoutPersistence.setLayout(snapshot.layout, scope),\n flush: layoutPersistence.flush,\n dispose: layoutPersistence.dispose,\n };\n\n return {\n snapshotPersistence,\n layoutPersistence,\n panelMenuStatePersistence: createLocalStoragePanelMenuStatePersistence({\n namespace: input.namespace,\n scope: input.scope ?? \"global\",\n storage,\n }),\n pageLocationPersistence: createLocalStoragePageLocationPersistence({ namespace: input.namespace, storage }),\n treePersistence: createLocalStorageTreePersistence({ namespace: input.namespace, scope: input.scope, storage }),\n sidePanelPersistence: createLocalStorageSidePanelPersistence({\n namespace: input.namespace,\n scope: input.scope,\n storage,\n }),\n };\n};\n"],"mappings":";AA6BA,IAAakB,KACXF,GACAG,GACAC,MACG,GAAGJ,EAAS,GAAIG,EAAI,GAAIC,KAAS,YAEhCC,UAAkD;CACtD,IAAMC,oBAAM,I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C,CAAK;GACpFgD,OAAOV,EAAkBU;GACzBC,SAASX,EAAkBW;EAI3BR;EACAH;EACAY,2BAA2B9B,EAA4C;GACrEN,WAAWL,EAAMK;GACjBd,OAAOS,EAAMT,SAAS;GACtBU;EACF,CAAC;EACDyC,yBAAyB3C,EAA0C;GAAEM,WAAWL,EAAMK;GAAWJ;EAAQ,CAAC;EAC1G0C,iBAAiB3B,EAAkC;GAAEX,WAAWL,EAAMK;GAAWd,OAAOS,EAAMT;GAAOU;EAAQ,CAAC;EAC9G2C,sBAAsBpB,EAAuC;GAC3DnB,WAAWL,EAAMK;GACjBd,OAAOS,EAAMT;GACbU;EACF,CAAC;CACH;AACF"}
|
|
1
|
+
{"version":3,"file":"storage.js","names":["WorkbenchStorageLike","length","getItem","key","index","setItem","value","removeItem","WorkbenchStoragePersistenceKind","CreateWorkbenchStoragePersistenceInput","debounceMs","eventTarget","addEventListener","type","listener","removeEventListener","namespace","storage","workbenchStoragePersistenceKey","kind","scope","createMemoryStorage","map","Map","size","get","keys","set","delete","resolveStorage","localStorage","readJson","T","raw","undefined","JSON","parse","LayoutPersistenceAdapter","WorkbenchLayout","CreateWorkbenchStoragePersistenceInput","readJson","resolveStorage","workbenchStoragePersistenceKey","PersistedWorkbenchLayoutV5","version","layout","PersistedWorkbenchLayout","WORKBENCH_LAYOUT_VERSION","const","WORKBENCH_LAYOUT_INDEX_VERSION","WORKBENCH_LAYOUT_RESOURCE_LIMIT","PersistedWorkbenchLayoutScopeIndex","scopes","PersistedWorkbenchLayoutGeneration","generation","createLocalStorageLayoutPersistence","input","storage","pending","Map","raw","scope","debounceMs","eventTarget","window","addEventListener","type","listener","removeEventListener","undefined","timer","ReturnType","setTimeout","generationKey","namespace","getGeneration","persisted","advanceGeneration","setItem","JSON","stringify","resourceProjectId","match","scopeProjectId","storedProjectScopes","projectId","key","prefix","index","length","startsWith","slice","push","readScopes","kind","Array","isArray","filter","getItem","writeScopes","next","touchProjectScope","candidate","touchResourceScope","evictedScope","splice","Math","max","removeItem","flush","clearTimeout","writes","values","clear","write","scheduleFlush","getLayout","pendingWrite","get","parse","setLayout","delete","set","listScopes","Set","transformLayouts","transform","getCompatibilityMarker","setCompatibilityMarker","value","advanceWriteGeneration","dispose","PersistedTreeRendererStates","PersistedWorkbenchPageLocation","PersistedWorkbenchPanelMenuState","TreeRendererPersistenceAdapter","WorkbenchPageLocationPersistence","WorkbenchPanelMenuStatePersistenceAdapter","WorkbenchPersistenceAdapter","WorkbenchStatusBarPersistenceAdapter","createLocalStorageLayoutPersistence","CreateWorkbenchStoragePersistenceInput","readJson","resolveStorage","workbenchStoragePersistenceKey","WorkbenchStorageLike","WorkbenchStoragePersistenceKind","CreateLocalStoragePanelMenuStatePersistenceInput","scope","CreateLocalStorageTreePersistenceInput","CreateLocalStorageWorkbenchPersistenceInput","StoredWorkbenchPageLocation","version","WORKBENCH_PAGE_LOCATION_VERSION","const","createLocalStoragePageLocationPersistence","input","storage","load","projectId","stored","namespace","undefined","location","rootLevel","save","persisted","setItem","JSON","stringify","createLocalStoragePanelMenuStatePersistence","getMenuStates","setMenuStates","state","key","createLocalStorageTreePersistence","getTreeStates","setTreeStates","createLocalStorageWorkbenchPersistence","layoutPersistence","debounceMs","eventTarget","snapshotPersistence","getSnapshot","layout","getLayout","setSnapshot","snapshot","setLayout","flush","dispose","statusBarKey","statusBarPersistence","getOrder","setOrder","ids","panelMenuStatePersistence","pageLocationPersistence","treePersistence","workbenchStoragePersistenceKey","namespace","kind","scope","createMemoryStorage","map","key","index","value","resolveStorage","storage","readJson","raw","WORKBENCH_LAYOUT_VERSION","WORKBENCH_LAYOUT_INDEX_VERSION","WORKBENCH_LAYOUT_RESOURCE_LIMIT","createLocalStorageLayoutPersistence","input","pending","debounceMs","eventTarget","type","listener","timer","generationKey","getGeneration","persisted","advanceGeneration","generation","resourceProjectId","scopeProjectId","storedProjectScopes","prefix","scopes","projectId","readScopes","writeScopes","next","touchProjectScope","candidate","touchResourceScope","evictedScope","flush","writes","write","scheduleFlush","pendingWrite","layout","transform","WORKBENCH_PAGE_LOCATION_VERSION","createLocalStoragePageLocationPersistence","stored","createLocalStoragePanelMenuStatePersistence","state","createLocalStorageTreePersistence","createLocalStorageWorkbenchPersistence","layoutPersistence","snapshotPersistence","snapshot","statusBarKey","ids"],"sources":["../src/storage/local-storage-persistence-helpers.ts","../src/storage/local-storage-layout-persistence.ts","../src/storage/local-storage-persistence.ts"],"sourcesContent":["export interface WorkbenchStorageLike {\n readonly length?: number;\n getItem(key: string): string | null;\n key?(index: number): string | null;\n setItem(key: string, value: string): void;\n removeItem?(key: string): void;\n}\n\nexport type WorkbenchStoragePersistenceKind =\n | \"layout\"\n | \"layout-compatibility\"\n | \"layout-generation\"\n | \"layout-resource-index\"\n | \"layout-scope-index\"\n | \"panel-menus\"\n | \"page-location\"\n | \"status-bar\"\n | \"tree\";\n\nexport interface CreateWorkbenchStoragePersistenceInput {\n debounceMs?: number;\n eventTarget?: {\n addEventListener(type: \"pagehide\", listener: () => void): void;\n removeEventListener(type: \"pagehide\", listener: () => void): void;\n };\n namespace: string;\n storage?: WorkbenchStorageLike;\n}\n\nexport const workbenchStoragePersistenceKey = (\n namespace: string,\n kind: WorkbenchStoragePersistenceKind,\n scope: string | undefined,\n) => `${namespace}:${kind}:${scope ?? \"global\"}`;\n\nconst createMemoryStorage = (): WorkbenchStorageLike => {\n const map = new Map<string, string>();\n return {\n get length() {\n return map.size;\n },\n getItem: (key) => map.get(key) ?? null,\n key: (index) => [...map.keys()][index] ?? null,\n setItem: (key, value) => {\n map.set(key, value);\n },\n removeItem: (key) => {\n map.delete(key);\n },\n };\n};\n\nexport const resolveStorage = (storage?: WorkbenchStorageLike): WorkbenchStorageLike => {\n if (storage) return storage;\n if (typeof localStorage !== \"undefined\") return localStorage;\n return createMemoryStorage();\n};\n\nexport const readJson = <T>(storage: WorkbenchStorageLike, key: string): T | undefined => {\n const raw = storage.getItem(key);\n if (!raw) return undefined;\n try {\n return JSON.parse(raw) as T;\n } catch {\n return undefined;\n }\n};\n","import type { LayoutPersistenceAdapter, WorkbenchLayout } from \"../core\";\nimport {\n type CreateWorkbenchStoragePersistenceInput,\n readJson,\n resolveStorage,\n workbenchStoragePersistenceKey,\n} from \"./local-storage-persistence-helpers\";\n\ninterface PersistedWorkbenchLayoutV5 {\n version: 5;\n layout: WorkbenchLayout;\n}\n\ntype PersistedWorkbenchLayout = PersistedWorkbenchLayoutV5;\n\n// Version 5 makes the side region's visibility the Side Panel's open state. Older\n// layouts saved a side visibility that never meant open, so they are discarded.\n// Only the layout cache changes; routed locations and independent preferences stay valid.\nconst WORKBENCH_LAYOUT_VERSION = 5 as const;\nconst WORKBENCH_LAYOUT_INDEX_VERSION = 1 as const;\nconst WORKBENCH_LAYOUT_RESOURCE_LIMIT = 50;\n\ninterface PersistedWorkbenchLayoutScopeIndex {\n version: 1;\n scopes: string[];\n}\n\ninterface PersistedWorkbenchLayoutGeneration {\n version: 1;\n generation: number;\n}\n\nexport const createLocalStorageLayoutPersistence = (\n input: CreateWorkbenchStoragePersistenceInput,\n): LayoutPersistenceAdapter => {\n const storage = resolveStorage(input.storage);\n const pending = new Map<string, { generation: number; raw: string; scope: string | undefined }>();\n const debounceMs = input.debounceMs ?? 250;\n const eventTarget =\n input.eventTarget ??\n (typeof window !== \"undefined\"\n ? {\n addEventListener: (type: \"pagehide\", listener: () => void) => window.addEventListener(type, listener),\n removeEventListener: (type: \"pagehide\", listener: () => void) => window.removeEventListener(type, listener),\n }\n : undefined);\n let timer: ReturnType<typeof setTimeout> | undefined;\n\n const generationKey = workbenchStoragePersistenceKey(input.namespace, \"layout-generation\", undefined);\n const getGeneration = () => {\n const persisted = readJson<unknown>(storage, generationKey);\n return typeof persisted === \"object\" &&\n persisted !== null &&\n \"version\" in persisted &&\n persisted.version === 1 &&\n \"generation\" in persisted &&\n typeof persisted.generation === \"number\"\n ? persisted.generation\n : 0;\n };\n\n const advanceGeneration = () => {\n const generation = getGeneration() + 1;\n const persisted: PersistedWorkbenchLayoutGeneration = { version: 1, generation };\n storage.setItem(generationKey, JSON.stringify(persisted));\n return generation;\n };\n\n const resourceProjectId = (scope: string | undefined) =>\n scope?.match(/^project\\/([^/]+)\\/mode\\/[^/]+\\/resource\\//)?.[1];\n const scopeProjectId = (scope: string | undefined) => scope?.match(/^project\\/([^/]+)/)?.[1];\n\n const storedProjectScopes = (projectId: string) => {\n if (!storage.key) return [];\n const prefix = `${input.namespace}:layout:`;\n const scopes: string[] = [];\n for (let index = 0; index < (storage.length ?? 0); index += 1) {\n const key = storage.key(index);\n if (!key?.startsWith(prefix)) continue;\n const scope = key.slice(prefix.length);\n if (scopeProjectId(scope) === projectId) scopes.push(scope);\n }\n return scopes;\n };\n\n const readScopes = (kind: \"layout-resource-index\" | \"layout-scope-index\", projectId: string) => {\n const persisted = readJson<unknown>(storage, workbenchStoragePersistenceKey(input.namespace, kind, projectId));\n return typeof persisted === \"object\" &&\n persisted !== null &&\n \"version\" in persisted &&\n persisted.version === WORKBENCH_LAYOUT_INDEX_VERSION &&\n \"scopes\" in persisted &&\n Array.isArray(persisted.scopes)\n ? persisted.scopes.filter(\n (scope): scope is string =>\n typeof scope === \"string\" &&\n storage.getItem(workbenchStoragePersistenceKey(input.namespace, \"layout\", scope)) !== null,\n )\n : [];\n };\n\n const writeScopes = (kind: \"layout-resource-index\" | \"layout-scope-index\", projectId: string, scopes: string[]) => {\n const next: PersistedWorkbenchLayoutScopeIndex = { version: WORKBENCH_LAYOUT_INDEX_VERSION, scopes };\n storage.setItem(workbenchStoragePersistenceKey(input.namespace, kind, projectId), JSON.stringify(next));\n };\n\n const touchProjectScope = (scope: string | undefined) => {\n const projectId = scopeProjectId(scope);\n if (!projectId || !scope) return;\n const scopes = readScopes(\"layout-scope-index\", projectId).filter((candidate) => candidate !== scope);\n scopes.push(scope);\n writeScopes(\"layout-scope-index\", projectId, scopes);\n };\n\n const touchResourceScope = (scope: string | undefined) => {\n const projectId = resourceProjectId(scope);\n if (!projectId || !scope) return;\n const scopes = readScopes(\"layout-resource-index\", projectId).filter((candidate) => candidate !== scope);\n scopes.push(scope);\n for (const evictedScope of scopes.splice(0, Math.max(0, scopes.length - WORKBENCH_LAYOUT_RESOURCE_LIMIT))) {\n storage.removeItem?.(workbenchStoragePersistenceKey(input.namespace, \"layout\", evictedScope));\n storage.removeItem?.(workbenchStoragePersistenceKey(input.namespace, \"panel-menus\", evictedScope));\n }\n writeScopes(\"layout-resource-index\", projectId, scopes);\n };\n\n const flush = () => {\n if (timer) clearTimeout(timer);\n timer = undefined;\n const writes = [...pending.values()];\n pending.clear();\n const generation = getGeneration();\n for (const write of writes) {\n if (write.generation !== generation) continue;\n storage.setItem(workbenchStoragePersistenceKey(input.namespace, \"layout\", write.scope), write.raw);\n touchProjectScope(write.scope);\n touchResourceScope(write.scope);\n }\n };\n\n const scheduleFlush = () => {\n if (debounceMs === 0) {\n flush();\n return;\n }\n if (timer) clearTimeout(timer);\n timer = setTimeout(flush, debounceMs);\n };\n\n eventTarget?.addEventListener(\"pagehide\", flush);\n\n return {\n getLayout: (scope) => {\n const key = workbenchStoragePersistenceKey(input.namespace, \"layout\", scope);\n const pendingWrite = pending.get(key);\n const persisted =\n pendingWrite && pendingWrite.generation === getGeneration()\n ? (JSON.parse(pendingWrite.raw) as PersistedWorkbenchLayout)\n : readJson<PersistedWorkbenchLayout>(storage, key);\n if (persisted?.version === WORKBENCH_LAYOUT_VERSION) return persisted.layout;\n return undefined;\n },\n setLayout: (layout, scope) => {\n const persisted: PersistedWorkbenchLayoutV5 = { version: WORKBENCH_LAYOUT_VERSION, layout };\n const key = workbenchStoragePersistenceKey(input.namespace, \"layout\", scope);\n pending.delete(key);\n pending.set(key, {\n generation: getGeneration(),\n raw: JSON.stringify(persisted),\n scope,\n });\n scheduleFlush();\n },\n flush,\n listScopes(projectId) {\n return [\n ...new Set([\n ...readScopes(\"layout-scope-index\", projectId),\n ...readScopes(\"layout-resource-index\", projectId),\n ...storedProjectScopes(projectId),\n ]),\n ];\n },\n transformLayouts(projectId, transform) {\n flush();\n advanceGeneration();\n for (const scope of this.listScopes?.(projectId) ?? []) {\n const key = workbenchStoragePersistenceKey(input.namespace, \"layout\", scope);\n const persisted = readJson<PersistedWorkbenchLayout>(storage, key);\n if (persisted?.version !== WORKBENCH_LAYOUT_VERSION) continue;\n const layout = transform(persisted.layout, scope);\n if (!layout) {\n storage.removeItem?.(key);\n continue;\n }\n storage.setItem(\n key,\n JSON.stringify({ version: WORKBENCH_LAYOUT_VERSION, layout } satisfies PersistedWorkbenchLayoutV5),\n );\n }\n },\n getCompatibilityMarker: (key) =>\n readJson<string>(storage, workbenchStoragePersistenceKey(input.namespace, \"layout-compatibility\", key)),\n setCompatibilityMarker: (key, value) => {\n advanceGeneration();\n storage.setItem(\n workbenchStoragePersistenceKey(input.namespace, \"layout-compatibility\", key),\n JSON.stringify(value),\n );\n },\n advanceWriteGeneration: advanceGeneration,\n dispose() {\n flush();\n eventTarget?.removeEventListener(\"pagehide\", flush);\n },\n };\n};\n","import type {\n PersistedTreeRendererStates,\n PersistedWorkbenchPageLocation,\n PersistedWorkbenchPanelMenuState,\n TreeRendererPersistenceAdapter,\n WorkbenchPageLocationPersistence,\n WorkbenchPanelMenuStatePersistenceAdapter,\n WorkbenchPersistenceAdapter,\n WorkbenchStatusBarPersistenceAdapter,\n} from \"../core\";\nimport { createLocalStorageLayoutPersistence } from \"./local-storage-layout-persistence\";\nimport {\n type CreateWorkbenchStoragePersistenceInput,\n readJson,\n resolveStorage,\n workbenchStoragePersistenceKey,\n} from \"./local-storage-persistence-helpers\";\n\nexport type {\n WorkbenchStorageLike,\n WorkbenchStoragePersistenceKind,\n} from \"./local-storage-persistence-helpers\";\nexport { createLocalStorageLayoutPersistence, workbenchStoragePersistenceKey };\n\nexport interface CreateLocalStoragePanelMenuStatePersistenceInput extends CreateWorkbenchStoragePersistenceInput {\n scope: string;\n}\n\nexport interface CreateLocalStorageTreePersistenceInput extends CreateWorkbenchStoragePersistenceInput {\n scope?: string;\n}\n\nexport interface CreateLocalStorageWorkbenchPersistenceInput extends CreateWorkbenchStoragePersistenceInput {\n scope?: string;\n}\n\ntype StoredWorkbenchPageLocation = PersistedWorkbenchPageLocation & { version: 1 };\n\nconst WORKBENCH_PAGE_LOCATION_VERSION = 1 as const;\n\nexport const createLocalStoragePageLocationPersistence = (\n input: CreateWorkbenchStoragePersistenceInput,\n): WorkbenchPageLocationPersistence => {\n const storage = resolveStorage(input.storage);\n return {\n load: (projectId) => {\n const stored = readJson<StoredWorkbenchPageLocation>(\n storage,\n workbenchStoragePersistenceKey(input.namespace, \"page-location\", projectId),\n );\n if (stored?.version !== WORKBENCH_PAGE_LOCATION_VERSION) return undefined;\n return { location: stored.location, ...(stored.rootLevel ? { rootLevel: stored.rootLevel } : {}) };\n },\n save: (projectId, persisted) => {\n const stored: StoredWorkbenchPageLocation = { version: WORKBENCH_PAGE_LOCATION_VERSION, ...persisted };\n storage.setItem(\n workbenchStoragePersistenceKey(input.namespace, \"page-location\", projectId),\n JSON.stringify(stored),\n );\n },\n };\n};\nexport const createLocalStoragePanelMenuStatePersistence = (\n input: CreateLocalStoragePanelMenuStatePersistenceInput,\n): WorkbenchPanelMenuStatePersistenceAdapter => {\n const storage = resolveStorage(input.storage);\n return {\n getMenuStates: (scope) =>\n readJson<PersistedWorkbenchPanelMenuState>(\n storage,\n workbenchStoragePersistenceKey(input.namespace, \"panel-menus\", scope ?? input.scope),\n ),\n setMenuStates: (state, scope) => {\n const key = workbenchStoragePersistenceKey(input.namespace, \"panel-menus\", scope ?? input.scope);\n storage.setItem(key, JSON.stringify(state));\n },\n };\n};\n\nexport const createLocalStorageTreePersistence = (\n input: CreateLocalStorageTreePersistenceInput,\n): TreeRendererPersistenceAdapter => {\n const storage = resolveStorage(input.storage);\n const key = workbenchStoragePersistenceKey(input.namespace, \"tree\", input.scope);\n return {\n getTreeStates: () => readJson<PersistedTreeRendererStates>(storage, key),\n setTreeStates: (state) => {\n storage.setItem(key, JSON.stringify(state));\n },\n };\n};\n\nexport const createLocalStorageWorkbenchPersistence = (input: CreateLocalStorageWorkbenchPersistenceInput) => {\n const storage = resolveStorage(input.storage);\n const layoutPersistence = createLocalStorageLayoutPersistence({\n debounceMs: input.debounceMs,\n eventTarget: input.eventTarget,\n namespace: input.namespace,\n storage,\n });\n const snapshotPersistence: WorkbenchPersistenceAdapter = {\n getSnapshot: (scope) => {\n const layout = layoutPersistence.getLayout(scope);\n return layout ? { layout } : undefined;\n },\n setSnapshot: (snapshot, scope) => layoutPersistence.setLayout(snapshot.layout, scope),\n flush: layoutPersistence.flush,\n dispose: layoutPersistence.dispose,\n };\n const statusBarKey = workbenchStoragePersistenceKey(input.namespace, \"status-bar\", undefined);\n const statusBarPersistence: WorkbenchStatusBarPersistenceAdapter = {\n getOrder: () => readJson<string[]>(storage, statusBarKey),\n setOrder: (ids) => storage.setItem(statusBarKey, JSON.stringify(ids)),\n };\n\n return {\n snapshotPersistence,\n statusBarPersistence,\n layoutPersistence,\n panelMenuStatePersistence: createLocalStoragePanelMenuStatePersistence({\n namespace: input.namespace,\n scope: input.scope ?? \"global\",\n storage,\n }),\n pageLocationPersistence: createLocalStoragePageLocationPersistence({ namespace: input.namespace, storage }),\n treePersistence: createLocalStorageTreePersistence({ namespace: input.namespace, scope: input.scope, storage }),\n };\n};\n"],"mappings":";AA6BA,IAAakB,KACXF,GACAG,GACAC,MACG,GAAGJ,EAAS,GAAIG,EAAI,GAAIC,KAAS,YAEhCC,UAAkD;CACtD,IAAMC,oBAAM,IAAIC,IAAoB;CACpC,OAAO;EACL,IAAItB,SAAS;GACX,OAAOqB,EAAIE;EACb;EACAtB,UAAUC,MAAQmB,EAAIG,IAAItB,CAAG,KAAK;EAClCA,MAAMC,MAAU,CAAC,GAAGkB,EAAII,KAAK,CAAC,CAAC,CAACtB,MAAU;EAC1CC,UAAUF,GAAKG,MAAU;GACvBgB,EAAIK,IAAIxB,GAAKG,CAAK;EACpB;EACAC,aAAaJ,MAAQ;GACnBm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
|
|
29
29
|
</html>
|
|
30
|
-
`, i = (e) => r(`<script src="${t(e)}"><\/script>`), a = (e) => r(`<script>${n(e)}<\/script>`), o = () => "// Generated by packages/pstdio-extensions/scripts/build-runtime.ts\nfunction te(){let e=globalThis;if(e.window!==void 0&&e.document!==void 0)return\"browser\";if(e.WorkerGlobalScope!==void 0&&e.self!==void 0&&e.self instanceof e.WorkerGlobalScope||e.window===void 0&&e.self!==void 0&&typeof e.importScripts==\"function\")return\"worker\";let t=e.process;if(t&&typeof t==\"object\"){let r=t.versions??{},s=t.release?.name;if(r.bun||s===\"bun\"||e.Bun!==void 0)return\"bun\";if(r.node&&s===\"node\")return\"node\"}return e.Bun===void 0?\"browser\":\"bun\"}function T(){return te()}function B(){return T()===\"worker\"}function z(){let e=T();return e===\"node\"||e===\"bun\"}function re(){return window.self!==window.top}function ne(e){let t={};return function r(s,i=\"\"){Object.keys(s).forEach((n)=>{let o=i?`${i}.${n}`:n;s[n]===Object(s[n])&&r(s[n],o),typeof s[n]==\"function\"&&(t[o]=s[n],delete s[n])})}(e),t}function se(e){return!e||e===\"null\"?\"*\":e}function oe(e,t,r){if(!e||typeof e!=\"object\")return e;let s=Array.isArray(t)?t:t.split(\".\").map((n)=>n.match(/^\\d+$/)?Number(n):n),i=e;for(let n=0;n<s.length;n++){let o=s[n];n===s.length-1?i[o]=r:((!i[o]||typeof i[o]!=\"object\")&&(i[o]=typeof s[n+1]==\"number\"?[]:{}),i=i[o])}return e}function ie(e=10){let t=\"\";for(let r=0;r<e;r++)t+=\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789\".charAt(Math.floor(Math.random()*62));return t}var V=T(),x=null;if(V===\"node\"||V===\"bun\")try{let e=globalThis.require;x=e?.(\"node:worker_threads\")?.parentPort??null}catch{}function ae(){if(z())return x;if(B())return self;if(re())return window.parent;throw Error(\"No valid target found for postMessage\")}function C(e,t,r,s){if(!e)throw Error(\"Rimless Error: No target specified for postMessage\");if(z()&&e===x){e.postMessage(t,{transfer:s});return}if(B()){e.postMessage(t,{transfer:s});return}if(e.postMessage){e.postMessage(t,{targetOrigin:se(r),transfer:s});return}throw Error(\"Rimless Error: Invalid target for postMessage\")}function G(e){return x!==null&&e===x}function H(e,t,r){G(e)?e.on(t,r):(\"addEventListener\"in e)&&e.addEventListener(t,r)}function O(e,t,r){G(e)?e.off(t,r):(\"removeEventListener\"in e)&&e.removeEventListener(t,r)}function L(e){return e.data||e}var b=function(e){return e.MESSAGE=\"message\",e}({}),y=function(e){return e.HANDSHAKE_REQUEST=\"RIMLESS/HANDSHAKE_REQUEST\",e.HANDSHAKE_REPLY=\"RIMLESS/HANDSHAKE_REPLY\",e.RPC_REQUEST=\"RIMLESS/RPC_REQUEST\",e.RPC_RESOLVE=\"RIMLESS/RPC_RESOLVE\",e.RPC_REJECT=\"RIMLESS/RPC_REJECT\",e}({}),S=Symbol();function ce(e={},t,r,s,i){let n=[];for(let[o,d]of Object.entries(e)){async function a(u){let{action:E,callID:m,connectionID:f,callName:v,args:w=[]}=L(u);if(E!==y.RPC_REQUEST||!m||!v||v!==o||f!==t)return;let g={action:y.RPC_RESOLVE,callID:m,callName:v,connectionID:f,error:null,result:null},R;try{g.result=await d(...w,i),g.result?.[S]&&(R=g.result[S]??[],delete g.result[S])}catch(A){g.action=y.RPC_REJECT,g.error=JSON.parse(JSON.stringify(A,Object.getOwnPropertyNames(A)))}C(s,g,u?.origin,R)}H(r,b.MESSAGE,a),n.push(()=>O(r,b.MESSAGE,a))}return()=>n.forEach((o)=>o())}function de(e,t,r,s=[],i,n){return(...o)=>new Promise((d,a)=>{let u=ie();function E(v){let{callID:w,connectionID:g,callName:R,result:A,error:ee,action:W}=L(v);if(!(!w||!R)&&R===e&&w===u&&g===t){if(W===y.RPC_RESOLVE)return d(A);if(W===y.RPC_REJECT)return a(ee)}}let m={action:y.RPC_REQUEST,args:o,callID:u,callName:e,connectionID:t},f=o.reduce((v,w)=>w[S]?.length?v.concat(w[S]):v,o[S]??[]);H(i,b.MESSAGE,E),s.push(()=>O(i,b.MESSAGE,E)),C(n,m,r?.origin,f)})}function le(e={},t=[],r,s,i,n){let o={...e},d=[];for(let a of t)oe(o,a,de(a,r,s,d,i,n));return{remote:o,unregisterRemote:()=>d.forEach((a)=>a())}}function fe(e={},t){return new Promise(async(r)=>{let s=ne(e),i=ae(),n=self||window;async function o(d){let a=L(d);if(a?.action!==y.HANDSHAKE_REPLY)return;let{remote:u,unregisterRemote:E}=le(a.schema,a.methodNames,a.connectionID,d,n,i),m=ce(s,a.connectionID,n,i,u);return await t?.onConnectionSetup?.(u),C(i,{action:y.HANDSHAKE_REPLY,connectionID:a.connectionID},d?.origin),r({remote:u,close:()=>{O(n,b.MESSAGE,o),E(),m()},id:a.connectionID})}H(n,b.MESSAGE,o),C(i,{action:y.HANDSHAKE_REQUEST,methodNames:Object.keys(s),schema:e})})}var J={connect:fe};var pe=(e)=>typeof e===\"object\"&&e!==null,q=(e)=>{try{let t=JSON.stringify(e);if(typeof t===\"string\"&&t.length>0)return t}catch{}try{return String(e)}catch{return\"Unknown error\"}},M=(e)=>{if(e instanceof Error)return{message:e.message,stack:e.stack};if(typeof e===\"string\")return{message:e};if(pe(e)){let t=typeof e.message===\"string\"?e.message:null,r=typeof e.stack===\"string\"?e.stack:void 0;if(t)return r?{message:t,stack:r}:{message:t};return{message:q(e)}}if(e===null||e===void 0)return{message:\"Unknown error\"};return{message:q(e)}};var N=\"(?:0|[1-9]\\\\d*)\",xe=new RegExp(`^\\\\^(${N}\\\\.${N}\\\\.${N})$`),U=[\"sidenav\",\"main\",\"secondary\",\"side\"];var p=(e,t)=>({extensionId:\"pstdio\",kind:e,id:t}),h={project:p(\"mode\",\"project\"),sessions:p(\"mode\",\"sessions\"),settings:p(\"mode\",\"settings\")},Pe={project:{ref:h.project,regions:U},sessions:{ref:h.sessions,regions:U},settings:{ref:h.settings,regions:U}},_=(e,t,r)=>({id:e,ref:p(\"resource-kind\",e),label:t,menuSlots:r}),K=[{id:\"headerPrimary\",placement:\"header-primary\",access:\"public\"},{id:\"headerOverflow\",placement:\"header-overflow\",access:\"public\"}],D={project:_(\"project\",\"Extension\",K),session:_(\"session\",\"Session\",K),workspace:_(\"workspace\",\"Workspace\",K)},k={project:D.project.ref,session:D.session.ref,workspace:D.workspace.ref},P={start:p(\"page\",\"start\"),sessions:p(\"page\",\"sessions\"),session:p(\"page\",\"session\"),workspaces:p(\"page\",\"workspaces\"),workspace:p(\"page\",\"workspace\")},Ae={start:{ref:P.start,mode:h.project,path:\"\",primary:{cardinality:\"one\",resourceKinds:[]}},sessions:{ref:P.sessions,mode:h.sessions,path:\"sessions\",primary:{cardinality:\"one\",resourceKinds:[]}},session:{ref:P.session,mode:h.sessions,path:\"session\",primary:{cardinality:\"one\",resourceKinds:[\"session\",\"session-draft\"]}},workspaces:{ref:P.workspaces,mode:h.project,path:\"workspaces\",primary:{cardinality:\"one\",resourceKinds:[]}},workspace:{ref:P.workspace,mode:h.project,path:\"workspace\",primary:{cardinality:\"many\",resourceKinds:[\"workspace\"]}}},ue={projectSession:p(\"placement\",\"project-session\")},Ce={projectSession:{ref:ue.projectSession,mode:h.project,cardinality:\"many\",resourceKinds:[\"session\",\"session-draft\"]}},Me={projectSettings:p(\"settings-panel\",\"project.settings\"),statusBarLeading:p(\"status-bar-item\",\"status-bar.leading\"),statusBarTrailing:p(\"status-bar-item\",\"status-bar.trailing\")};var Y=(e)=>({...e,kind:\"command\"}),je=Object.assign(Y,{forExtension:(e)=>(t)=>Y({extensionId:`${e.publisher}.${e.name}`,id:t})}),me=(e)=>({...e,kind:\"event\"}),j=(e,t)=>({id:e,kind:t.kind,label:t.label,description:t.description,metadata:t.metadata}),l=(e)=>me({extensionId:\"pstdio\",id:e}),I=(e,t)=>j(`${e.id}.${t}`,{kind:\"menu\"}),Te={sidenav:j(\"project.sidenav\",{kind:\"panel\"}),headerPrimary:I(k.project,\"headerPrimary\"),headerOverflow:I(k.project,\"headerOverflow\"),settingsPanels:j(\"project.settingsPanels\",{kind:\"settings\"})},He={headerPrimary:I(k.session,\"headerPrimary\"),headerOverflow:I(k.session,\"headerOverflow\")},Oe={headerPrimary:I(k.workspace,\"headerPrimary\"),headerOverflow:I(k.workspace,\"headerOverflow\"),sidenav:j(\"workspace.sidenav\",{kind:\"panel\"})},$e={opened:l(\"project.opened\")},Le={sessionsChanged:l(\"view.sessions.changed\"),workspacesChanged:l(\"view.workspaces.changed\"),repositoriesChanged:l(\"view.repositories.changed\")},Ne={started:l(\"session.started\"),resumed:l(\"session.resumed\"),awaitingInput:l(\"session.awaitingInput\"),succeeded:l(\"session.succeeded\"),failed:l(\"session.failed\"),completed:l(\"session.completed\")},Ue={created:l(\"workspace.created\"),provision:l(\"workspace.provision\"),ready:l(\"workspace.ready\"),archived:l(\"workspace.archived\"),deleted:l(\"workspace.deleted\")},_e={removed:l(\"worktree.removed\")},Ke={committed:l(\"git.committed\"),rebased:l(\"git.rebased\"),merged:l(\"git.merged\"),conflicted:l(\"git.conflicted\")};var ge=[\"clipboard.write\",\"commands.execute\",\"navigation.open\",\"placement.close\",\"notification.show\",\"notification.action\",\"notification.resolve\",\"notification.dismiss\",\"preferences.get\",\"preferences.set\",\"extension.settings.all\",\"extension.settings.get\",\"extension.settings.set\",\"extension.settings.delete\",\"terminal.session\",\"files.upload\",\"files.list\",\"files.delete\"],ye=[\"artifacts.read\"],he=[\"host.dispatchKeyboardEvent\"],De=[...ge.filter((e)=>e!==\"clipboard.write\"),...ye,...he];var c=(e)=>(t)=>({...t,ref:{kind:e,id:t.id}}),We=c(\"view\"),Ve=c(\"view-menu\"),Be=c(\"placement\"),ze=c(\"resource-kind\");var Ge=c(\"navigation-item\"),Je=c(\"navigation-tree\"),qe=c(\"mode\");var Ye=c(\"status-bar-item\"),Qe=c(\"status\"),Fe=c(\"settings-panel\"),Xe=c(\"activity-item\"),Ze=c(\"settings-section\"),et=c(\"command-palette-resource\"),tt=c(\"keybinding\"),rt=c(\"schedule\"),nt=c(\"artifact-mount\"),st=c(\"template-type\"),ot=c(\"template\"),it=c(\"skill\"),at=c(\"theme\"),ct=c(\"file-icon-theme\"),dt=c(\"workspace-type\"),lt=c(\"harness\"),ft=c(\"connection\");var Q=(e,t,r)=>({call:async(s,...i)=>{try{return await e({method:s,params:i[0]})}catch(n){if(n instanceof Error)throw n;throw Error(M(n).message)}},onEvent:t,extensionId:r}),F=(e)=>{let t=e,r=new Set;return{get:()=>t,subscribe:(s)=>(r.add(s),()=>r.delete(s)),set:(s)=>{t=s;for(let i of r)i(t)}}};var X=\"pstdio-extension-mount\",Ee=()=>{let e=new Map;return{get length(){return e.size},clear:()=>e.clear(),getItem:(t)=>e.get(t)??null,key:(t)=>Array.from(e.keys())[t]??null,removeItem:(t)=>e.delete(t),setItem:(t,r)=>e.set(t,r)}},ve=()=>{for(let e of[\"localStorage\",\"sessionStorage\"])try{window[e]}catch{Object.defineProperty(window,e,{configurable:!0,value:Ee()})}},Z=(e,t)=>{let r=document.documentElement,s=e===\"dark\"?\"light\":\"dark\";r.classList.remove(s),r.classList.add(e),r.setAttribute(\"data-theme\",e),r.style.colorScheme=e;for(let[i,n]of Object.entries(t))if(i.startsWith(\"--\"))r.style.setProperty(i,n)},we=(e)=>{for(let t of e){let r=document.createElement(\"link\");r.rel=\"stylesheet\",r.href=t,document.head.appendChild(r)}},Se=()=>{let e=document.getElementById(X);if(!e)e=document.createElement(\"div\"),e.id=X,e.style.height=\"100%\",e.style.width=\"100%\",document.body.appendChild(e);return e},be=(e)=>e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement||e instanceof HTMLElement&&e.isContentEditable,ke=async()=>{ve();let e=F(void 0),t=new Map,r=(o,d)=>{let a=t.get(o)??new Set;return a.add(d),t.set(o,a),()=>{a.delete(d)}},s,i=!1,n=await J.connect({init:async(o)=>{try{Z(o.theme,o.themeVariables),we(o.styles),e.set(o.props);let d=Se(),a=await import(o.moduleUrl),u=a.default??(a.mount?a:void 0);if(!u?.mount)throw Error(\"Extension module does not export a default view (defineExtensionView).\");let E=Q((f)=>n.remote.call(f),r,o.extensionId),m=await u.mount(d,E,e);if(s=typeof m===\"function\"?m:void 0,!i)i=!0,document.addEventListener(\"keydown\",(f)=>{if(!f.ctrlKey&&!f.metaKey&&!f.altKey)return;if(be(f.target)&&!f.shiftKey)return;n.remote.call({method:\"host.dispatchKeyboardEvent\",params:{key:f.key,code:f.code,ctrlKey:f.ctrlKey,metaKey:f.metaKey,altKey:f.altKey,shiftKey:f.shiftKey,repeat:f.repeat}}).catch(()=>{})},!0)}catch(d){let a=M(d);throw n.remote.runtimeError(a),d instanceof Error?d:Error(a.message)}},themeUpdate:(o)=>{Z(o.theme,o.variables)},propsUpdate:(o)=>{e.set(o.props)},hostEvent:(o)=>{for(let d of t.get(o.scope)??[])d(o.payload)}});n.remote.ready({}),window.addEventListener(\"beforeunload\",()=>{s?.()})};ke();\n";
|
|
30
|
+
`, i = (e) => r(`<script src="${t(e)}"><\/script>`), a = (e) => r(`<script>${n(e)}<\/script>`), o = () => "// Generated by packages/pstdio-extensions/scripts/build-runtime.ts\nfunction te(){let e=globalThis;if(e.window!==void 0&&e.document!==void 0)return\"browser\";if(e.WorkerGlobalScope!==void 0&&e.self!==void 0&&e.self instanceof e.WorkerGlobalScope||e.window===void 0&&e.self!==void 0&&typeof e.importScripts==\"function\")return\"worker\";let t=e.process;if(t&&typeof t==\"object\"){let n=t.versions??{},s=t.release?.name;if(n.bun||s===\"bun\"||e.Bun!==void 0)return\"bun\";if(n.node&&s===\"node\")return\"node\"}return e.Bun===void 0?\"browser\":\"bun\"}function M(){return te()}function B(){return M()===\"worker\"}function z(){let e=M();return e===\"node\"||e===\"bun\"}function ne(){return window.self!==window.top}function re(e){let t={};return function n(s,i=\"\"){Object.keys(s).forEach((r)=>{let o=i?`${i}.${r}`:r;s[r]===Object(s[r])&&n(s[r],o),typeof s[r]==\"function\"&&(t[o]=s[r],delete s[r])})}(e),t}function se(e){return!e||e===\"null\"?\"*\":e}function oe(e,t,n){if(!e||typeof e!=\"object\")return e;let s=Array.isArray(t)?t:t.split(\".\").map((r)=>r.match(/^\\d+$/)?Number(r):r),i=e;for(let r=0;r<s.length;r++){let o=s[r];r===s.length-1?i[o]=n:((!i[o]||typeof i[o]!=\"object\")&&(i[o]=typeof s[r+1]==\"number\"?[]:{}),i=i[o])}return e}function ie(e=10){let t=\"\";for(let n=0;n<e;n++)t+=\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789\".charAt(Math.floor(Math.random()*62));return t}var V=M(),P=null;if(V===\"node\"||V===\"bun\")try{let e=globalThis.require;P=e?.(\"node:worker_threads\")?.parentPort??null}catch{}function ae(){if(z())return P;if(B())return self;if(ne())return window.parent;throw Error(\"No valid target found for postMessage\")}function C(e,t,n,s){if(!e)throw Error(\"Rimless Error: No target specified for postMessage\");if(z()&&e===P){e.postMessage(t,{transfer:s});return}if(B()){e.postMessage(t,{transfer:s});return}if(e.postMessage){e.postMessage(t,{targetOrigin:se(n),transfer:s});return}throw Error(\"Rimless Error: Invalid target for postMessage\")}function G(e){return P!==null&&e===P}function L(e,t,n){G(e)?e.on(t,n):(\"addEventListener\"in e)&&e.addEventListener(t,n)}function O(e,t,n){G(e)?e.off(t,n):(\"removeEventListener\"in e)&&e.removeEventListener(t,n)}function N(e){return e.data||e}var S=function(e){return e.MESSAGE=\"message\",e}({}),y=function(e){return e.HANDSHAKE_REQUEST=\"RIMLESS/HANDSHAKE_REQUEST\",e.HANDSHAKE_REPLY=\"RIMLESS/HANDSHAKE_REPLY\",e.RPC_REQUEST=\"RIMLESS/RPC_REQUEST\",e.RPC_RESOLVE=\"RIMLESS/RPC_RESOLVE\",e.RPC_REJECT=\"RIMLESS/RPC_REJECT\",e}({}),b=Symbol();function ce(e={},t,n,s,i){let r=[];for(let[o,d]of Object.entries(e)){async function a(p){let{action:E,callID:m,connectionID:f,callName:w,args:v=[]}=N(p);if(E!==y.RPC_REQUEST||!m||!w||w!==o||f!==t)return;let g={action:y.RPC_RESOLVE,callID:m,callName:w,connectionID:f,error:null,result:null},R;try{g.result=await d(...v,i),g.result?.[b]&&(R=g.result[b]??[],delete g.result[b])}catch(A){g.action=y.RPC_REJECT,g.error=JSON.parse(JSON.stringify(A,Object.getOwnPropertyNames(A)))}C(s,g,p?.origin,R)}L(n,S.MESSAGE,a),r.push(()=>O(n,S.MESSAGE,a))}return()=>r.forEach((o)=>o())}function de(e,t,n,s=[],i,r){return(...o)=>new Promise((d,a)=>{let p=ie();function E(w){let{callID:v,connectionID:g,callName:R,result:A,error:ee,action:W}=N(w);if(!(!v||!R)&&R===e&&v===p&&g===t){if(W===y.RPC_RESOLVE)return d(A);if(W===y.RPC_REJECT)return a(ee)}}let m={action:y.RPC_REQUEST,args:o,callID:p,callName:e,connectionID:t},f=o.reduce((w,v)=>v[b]?.length?w.concat(v[b]):w,o[b]??[]);L(i,S.MESSAGE,E),s.push(()=>O(i,S.MESSAGE,E)),C(r,m,n?.origin,f)})}function le(e={},t=[],n,s,i,r){let o={...e},d=[];for(let a of t)oe(o,a,de(a,n,s,d,i,r));return{remote:o,unregisterRemote:()=>d.forEach((a)=>a())}}function fe(e={},t){return new Promise(async(n)=>{let s=re(e),i=ae(),r=self||window;async function o(d){let a=N(d);if(a?.action!==y.HANDSHAKE_REPLY)return;let{remote:p,unregisterRemote:E}=le(a.schema,a.methodNames,a.connectionID,d,r,i),m=ce(s,a.connectionID,r,i,p);return await t?.onConnectionSetup?.(p),C(i,{action:y.HANDSHAKE_REPLY,connectionID:a.connectionID},d?.origin),n({remote:p,close:()=>{O(r,S.MESSAGE,o),E(),m()},id:a.connectionID})}L(r,S.MESSAGE,o),C(i,{action:y.HANDSHAKE_REQUEST,methodNames:Object.keys(s),schema:e})})}var F={connect:fe};var ue=(e)=>typeof e===\"object\"&&e!==null,J=(e)=>{try{let t=JSON.stringify(e);if(typeof t===\"string\"&&t.length>0)return t}catch{}try{return String(e)}catch{return\"Unknown error\"}},T=(e)=>{if(e instanceof Error)return{message:e.message,stack:e.stack};if(typeof e===\"string\")return{message:e};if(ue(e)){let t=typeof e.message===\"string\"?e.message:null,n=typeof e.stack===\"string\"?e.stack:void 0;if(t)return n?{message:t,stack:n}:{message:t};return{message:J(e)}}if(e===null||e===void 0)return{message:\"Unknown error\"};return{message:J(e)}};var H=\"(?:0|[1-9]\\\\d*)\",xe=new RegExp(`^\\\\^(${H}\\\\.${H}\\\\.${H})$`);var _=[\"sidenav\",\"main\",\"secondary\",\"side\"];var u=(e,t)=>({extensionId:\"pstdio\",kind:e,id:t}),h={project:u(\"mode\",\"project\"),sessions:u(\"mode\",\"sessions\"),settings:u(\"mode\",\"settings\")},Ae={project:{ref:h.project,regions:_},sessions:{ref:h.sessions,regions:_},settings:{ref:h.settings,regions:_}},U=(e,t,n)=>({id:e,ref:u(\"resource-kind\",e),label:t,menuSlots:n}),D=[{id:\"headerPrimary\",placement:\"header-primary\",access:\"public\"},{id:\"headerOverflow\",placement:\"header-overflow\",access:\"public\"}],K={project:U(\"project\",\"Extension\",D),session:U(\"session\",\"Session\",D),workspace:U(\"workspace\",\"Workspace\",D)},k={project:K.project.ref,session:K.session.ref,workspace:K.workspace.ref},x={start:u(\"page\",\"start\"),sessions:u(\"page\",\"sessions\"),session:u(\"page\",\"session\"),workspaces:u(\"page\",\"workspaces\"),workspace:u(\"page\",\"workspace\")},Ce={start:{ref:x.start,mode:h.project,path:\"\",primary:{cardinality:\"one\",resourceKinds:[]}},sessions:{ref:x.sessions,mode:h.sessions,path:\"sessions\",primary:{cardinality:\"one\",resourceKinds:[]}},session:{ref:x.session,mode:h.sessions,path:\"session\",primary:{cardinality:\"one\",resourceKinds:[\"session\",\"session-draft\"]}},workspaces:{ref:x.workspaces,mode:h.project,path:\"workspaces\",primary:{cardinality:\"one\",resourceKinds:[]}},workspace:{ref:x.workspace,mode:h.project,path:\"workspace\",primary:{cardinality:\"many\",resourceKinds:[\"workspace\"]}}},pe={projectSession:u(\"placement\",\"project-session\")},Te={projectSession:{ref:pe.projectSession,mode:h.project,cardinality:\"many\",resourceKinds:[\"session\",\"session-draft\"]}},je={projectSettings:u(\"settings-panel\",\"project.settings\"),statusBarLeading:u(\"status-bar-item\",\"status-bar.leading\"),statusBarTrailing:u(\"status-bar-item\",\"status-bar.trailing\")};var q=(e)=>({...e,kind:\"command\"}),Me=Object.assign(q,{forExtension:(e)=>(t)=>q({extensionId:`${e.publisher}.${e.name}`,id:t})}),me=(e)=>({...e,kind:\"event\"}),j=(e,t)=>({id:e,kind:t.kind,label:t.label,description:t.description,metadata:t.metadata}),l=(e)=>me({extensionId:\"pstdio\",id:e}),I=(e,t)=>j(`${e.id}.${t}`,{kind:\"menu\"}),Le={sidenav:j(\"project.sidenav\",{kind:\"panel\"}),headerPrimary:I(k.project,\"headerPrimary\"),headerOverflow:I(k.project,\"headerOverflow\"),settingsPanels:j(\"project.settingsPanels\",{kind:\"settings\"})},Oe={headerPrimary:I(k.session,\"headerPrimary\"),headerOverflow:I(k.session,\"headerOverflow\")},Ne={headerPrimary:I(k.workspace,\"headerPrimary\"),headerOverflow:I(k.workspace,\"headerOverflow\"),sidenav:j(\"workspace.sidenav\",{kind:\"panel\"})},$e={opened:l(\"project.opened\")},He={sessionsChanged:l(\"view.sessions.changed\"),workspacesChanged:l(\"view.workspaces.changed\"),repositoriesChanged:l(\"view.repositories.changed\")},_e={started:l(\"session.started\"),resumed:l(\"session.resumed\"),awaitingInput:l(\"session.awaitingInput\"),succeeded:l(\"session.succeeded\"),failed:l(\"session.failed\"),completed:l(\"session.completed\")},Ue={created:l(\"workspace.created\"),provision:l(\"workspace.provision\"),ready:l(\"workspace.ready\"),archived:l(\"workspace.archived\"),deleted:l(\"workspace.deleted\")},De={removed:l(\"worktree.removed\")},Ke={committed:l(\"git.committed\"),rebased:l(\"git.rebased\"),merged:l(\"git.merged\"),conflicted:l(\"git.conflicted\")};var ge=[\"clipboard.write\",\"commands.execute\",\"navigation.open\",\"placement.close\",\"notification.show\",\"notification.action\",\"notification.resolve\",\"notification.dismiss\",\"preferences.get\",\"preferences.set\",\"extension.settings.all\",\"extension.settings.get\",\"extension.settings.set\",\"extension.settings.delete\",\"terminal.session\",\"files.upload\",\"files.list\",\"files.delete\"],ye=[\"artifacts.read\"],he=[\"host.dispatchKeyboardEvent\"],We=[...ge.filter((e)=>e!==\"clipboard.write\"),...ye,...he];var c=(e)=>(t)=>({...t,ref:{kind:e,id:t.id}}),Ve=c(\"view\"),Be=c(\"view-menu\"),ze=c(\"placement\"),Ge=c(\"resource-kind\");var Fe=c(\"navigation-item\"),Je=c(\"navigation-tree\"),qe=c(\"mode\");var Ye=c(\"status-bar-item\"),Qe=c(\"status\"),Xe=c(\"settings-panel\"),Ze=c(\"activity-item\"),et=c(\"settings-section\"),tt=c(\"command-palette-resource\"),nt=c(\"keybinding\"),rt=c(\"schedule\"),st=c(\"artifact-mount\"),ot=c(\"template-type\"),it=c(\"template\"),at=c(\"skill\"),ct=c(\"theme\"),dt=c(\"file-icon-theme\"),lt=c(\"workspace-type\"),ft=c(\"harness\"),ut=c(\"connection\");var Y=(e,t,n)=>({call:async(s,...i)=>{try{return await e({method:s,params:i[0]})}catch(r){if(r instanceof Error)throw r;throw Error(T(r).message)}},onEvent:t,extensionId:n}),Q=(e)=>{let t=e,n=new Set;return{get:()=>t,subscribe:(s)=>(n.add(s),()=>n.delete(s)),set:(s)=>{t=s;for(let i of n)i(t)}}};var X=\"pstdio-extension-mount\",Ee=()=>{let e=new Map;return{get length(){return e.size},clear:()=>e.clear(),getItem:(t)=>e.get(t)??null,key:(t)=>Array.from(e.keys())[t]??null,removeItem:(t)=>e.delete(t),setItem:(t,n)=>e.set(t,n)}},we=()=>{for(let e of[\"localStorage\",\"sessionStorage\"])try{window[e]}catch{Object.defineProperty(window,e,{configurable:!0,value:Ee()})}},Z=(e,t)=>{let n=document.documentElement,s=e===\"dark\"?\"light\":\"dark\";n.classList.remove(s),n.classList.add(e),n.setAttribute(\"data-theme\",e),n.style.colorScheme=e;for(let[i,r]of Object.entries(t))if(i.startsWith(\"--\"))n.style.setProperty(i,r)},ve=(e)=>{for(let t of e){let n=document.createElement(\"link\");n.rel=\"stylesheet\",n.href=t,document.head.appendChild(n)}},be=()=>{let e=document.getElementById(X);if(!e)e=document.createElement(\"div\"),e.id=X,e.style.height=\"100%\",e.style.width=\"100%\",document.body.appendChild(e);return e},Se=()=>{window.addEventListener(\"message\",(e)=>{let t=e.data?.action;if(typeof t!==\"string\"||!t.startsWith(\"RIMLESS/\"))return;if(e.source!==window.parent)e.stopImmediatePropagation()},{capture:!0})},ke=(e)=>e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement||e instanceof HTMLElement&&e.isContentEditable,Ie=async()=>{we(),Se();let e=Q(void 0),t=new Map,n=(o,d)=>{let a=t.get(o)??new Set;return a.add(d),t.set(o,a),()=>{a.delete(d)}},s,i=!1,r=await F.connect({init:async(o)=>{try{Z(o.theme,o.themeVariables),ve(o.styles),e.set(o.props);let d=be(),a=await import(o.moduleUrl),p=a.default??(a.mount?a:void 0);if(!p?.mount)throw Error(\"Extension module does not export a default view (defineExtensionView).\");let E=Y((f)=>r.remote.call(f),n,o.extensionId),m=await p.mount(d,E,e);if(s=typeof m===\"function\"?m:void 0,!i)i=!0,document.addEventListener(\"keydown\",(f)=>{if(!f.ctrlKey&&!f.metaKey&&!f.altKey)return;if(ke(f.target)&&!f.shiftKey)return;r.remote.call({method:\"host.dispatchKeyboardEvent\",params:{key:f.key,code:f.code,ctrlKey:f.ctrlKey,metaKey:f.metaKey,altKey:f.altKey,shiftKey:f.shiftKey,repeat:f.repeat}}).catch(()=>{})},!0)}catch(d){let a=T(d);throw r.remote.runtimeError(a),d instanceof Error?d:Error(a.message)}},themeUpdate:(o)=>{Z(o.theme,o.variables)},propsUpdate:(o)=>{e.set(o.props)},hostEvent:(o)=>{for(let d of t.get(o.scope)??[])d(o.payload)}});r.remote.ready({}),window.addEventListener(\"beforeunload\",()=>{s?.()})};Ie();\n";
|
|
31
31
|
//#endregion
|
|
32
32
|
export { o as getExtensionRuntimeScript, i as renderExtensionRuntimeHtml, a as renderInlineExtensionRuntimeHtml };
|
|
33
33
|
|