@pstdio/workbench 0.40.0 → 0.42.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/dist/react.d.ts CHANGED
@@ -1,7 +1,8 @@
1
- import { $r as WorkbenchPanelInstance, A as WorkbenchCoreContributionContext, Ai as CommandParamDescriptor, Ar as TreeAction, Bt as KeybindingSequence, Gr as RegisteredMenuItem, Hi as ResourceRef, J as WorkbenchStatusRegistry, Mi as CommandParamSchema, N as WorkbenchModuleContribution, Oi as Command, Pi as WorkbenchCommandExecutionContext, St as PreferenceValue, U as ThemePreferenceOption$1, Ur as MenuPath, Vr as WorkbenchPanelRenderInput, Xr as RegisteredWidgetContribution, Yr as RegisteredPlaceholderContribution, _t as PreferencePropertySchema, bt as PreferenceScope, hi as WorkbenchRegion$1, k as WorkbenchCore, la as WorkbenchStore, qr as WorkbenchFocusRegionId, qt as WorkbenchTerminalController, ua as Disposable, ui as WorkbenchWidgetPlacement, vr as RegisteredDataTableRendererContribution, vt as PreferenceRegistry } from "./index-DLh_fcGT.js";
2
- import { a as ReactResourceContextAction, i as ReactKanbanRendererContribution, n as ReactAttributesSource, r as ReactBoardColumnConfig, t as ReactAttributeDescriptor } from "./kanban-presentation-Ds4FpmbS.js";
1
+ import { $n as RegisteredDataTableRendererContribution, $r as RegisteredPlaceholderContribution, Et as PreferenceValue, F as WorkbenchModuleContribution, Fi as CommandParamOption, G as ThemePreferenceOption$1, Gr as WorkbenchPanelRenderInput, Ii as CommandParamSchema, Ki as ResourceRef$1, M as WorkbenchCoreContributionContext, Mi as Command, Pi as CommandParamDescriptor, Pr as TreeAction, Ri as WorkbenchCommandExecutionContext, St as PreferenceRegistry, Wt as KeybindingSequence, X as WorkbenchStatusRegistry, Yr as RegisteredMenuItem, Zr as WorkbenchFocusRegionId, Zt as WorkbenchTerminalController, ei as RegisteredWidgetContribution, ha as WorkbenchStore, j as WorkbenchCore, ma as Disposable, mi as WorkbenchWidgetPlacement, qr as MenuPath, ri as WorkbenchPanelInstance, wt as PreferenceScope, xt as PreferencePropertySchema, yi as WorkbenchRegion$1 } from "./index-BUtrxfUl.js";
2
+ import { a as ReactResourceContextAction, i as ReactKanbanRendererContribution, n as ReactAttributesSource, r as ReactBoardColumnConfig, t as ReactAttributeDescriptor } from "./kanban-presentation-Wc433DQF.js";
3
+ import { ResourceAnchor, ResourceAnchorPage, ResourceAnchorQuery, ResourceRef } from "@pstdio/sdk/extensions";
3
4
  import { ReactNode } from "react";
4
- import { FileIconThemePreferenceOption, ResourceContextAction, ThemePreference, ThemePreferenceOption } from "@pstdio/ui";
5
+ import { FileIconThemePreferenceOption, ResourceContextAction, ThemePreference, ThemePreferenceOption, ThemePreferenceStorage } from "@pstdio/ui";
5
6
  import { FileUploadValue, ParamEditorProps, ParamValue } from "@pstdio/ui/param-editor";
6
7
  import { BoxProps, IconProps } from "@chakra-ui/react";
7
8
  import { TerminalBridge } from "@pstdio/ui/terminal";
@@ -27,6 +28,22 @@ export declare const listCommandParamEntries: (params: CommandParamSchema | unde
27
28
  export declare const buildCommandParamInitialValues: (params: CommandParamSchema | undefined, baseArgs?: unknown, context?: WorkbenchCommandExecutionContext) => Record<string, CommandParamValue>;
28
29
  export declare const normalizeCommandParamValues: (params: CommandParamSchema | undefined, values: Record<string, CommandParamValue>) => Record<string, unknown>;
29
30
  //#endregion
31
+ //#region src/react/command-palette/command-option-resolver.d.ts
32
+ interface CommandOptionState {
33
+ key: string;
34
+ status: "loading" | "ready" | "error";
35
+ options: CommandParamOption[];
36
+ error?: string;
37
+ }
38
+ type ExecuteOptionCommand = (commandId: string, args: Record<string, unknown>, signal?: AbortSignal) => Promise<unknown>;
39
+ //#endregion
40
+ //#region src/react/command-palette/command-option-status.d.ts
41
+ interface CommandOptionStatusProps {
42
+ state?: CommandOptionState;
43
+ onRetry: () => void;
44
+ }
45
+ export declare const CommandOptionStatus: (props: CommandOptionStatusProps) => import("react/jsx-runtime").JSX.Element | null;
46
+ //#endregion
30
47
  //#region src/react/command-palette/command-param-field.d.ts
31
48
  interface CommandParamFieldProps {
32
49
  entry: CommandParamEntry;
@@ -41,7 +58,7 @@ export declare const CommandParamField: (props: Omit<CommandParamFieldProps, "co
41
58
  //#region src/react/command-palette/command-params-dialog.d.ts
42
59
  interface CommandParamsRequest {
43
60
  record: {
44
- command: Pick<Command, "id" | "label" | "description" | "params">;
61
+ command: Pick<Command, "id" | "label" | "description" | "params" | "resourceMutation">;
45
62
  };
46
63
  action?: RegisteredMenuItem;
47
64
  label: string;
@@ -66,6 +83,15 @@ export declare const commandParamName: (entry: CommandParamEntry) => string;
66
83
  /** Narrows an editor value back to what a command param can carry. */
67
84
  export declare const readCommandParamValue: (value: ParamValue, entry?: CommandParamEntry) => CommandParamValue;
68
85
  //#endregion
86
+ //#region src/react/command-palette/use-command-options.d.ts
87
+ export declare const useCommandOptions: (schema: CommandParamSchema, values: Record<string, CommandParamValue>, execute: ExecuteOptionCommand | undefined, onChange: (key: string, value: CommandParamValue) => void) => {
88
+ states: Record<string, CommandOptionState>;
89
+ validate: (next: {
90
+ [x: string]: CommandParamValue;
91
+ }) => Record<string, string>;
92
+ retry: (key: string) => void;
93
+ };
94
+ //#endregion
69
95
  //#region src/react/focus/focus-region.d.ts
70
96
  interface WorkbenchFocusRegionProps extends BoxProps {
71
97
  workbench: WorkbenchCore;
@@ -106,7 +132,7 @@ export declare const createWorkbenchHotkeyRegistrations: (input: CreateWorkbench
106
132
  hotkey: KeybindingSequence;
107
133
  enabled: boolean;
108
134
  ignoreInputs: true;
109
- execute: () => Promise<readonly unknown[]>;
135
+ execute: () => Promise<void>;
110
136
  }[];
111
137
  export declare const WorkbenchKeybindingDispatcher: (props: WorkbenchKeybindingDispatcherProps) => null;
112
138
  //#endregion
@@ -126,13 +152,13 @@ interface WorkbenchMenuItem {
126
152
  readOnly?: true;
127
153
  }
128
154
  interface WorkbenchMenuItemContext {
129
- resource?: ResourceRef | undefined;
155
+ resource?: ResourceRef$1 | undefined;
130
156
  }
131
157
  export declare const listWorkbenchMenuItems: (workbench: WorkbenchCore, menuPath: MenuPath, context?: WorkbenchMenuItemContext) => WorkbenchMenuItem[];
132
158
  //#endregion
133
159
  //#region src/react/menus/resource-actions.d.ts
134
- export declare const createWorkbenchResourceActions: (workbench: WorkbenchCoreContributionContext, resource: ResourceRef) => ResourceContextAction[];
135
- export declare const useWorkbenchResourceActionResolver: (workbench: WorkbenchCoreContributionContext) => (resource: ResourceRef) => ResourceContextAction[];
160
+ export declare const createWorkbenchResourceActions: (workbench: WorkbenchCoreContributionContext, resource: ResourceRef$1) => ResourceContextAction[];
161
+ export declare const useWorkbenchResourceActionResolver: (workbench: WorkbenchCoreContributionContext) => (resource: ResourceRef$1) => ResourceContextAction[];
136
162
  //#endregion
137
163
  //#region src/react/notifications/notification-host.d.ts
138
164
  interface WorkbenchNotificationHostProps {
@@ -156,7 +182,7 @@ interface WorkbenchRegionTabsProps {
156
182
  region: WorkbenchRegion$1;
157
183
  visibilityStorageKey?: string;
158
184
  }
159
- export declare const WorkbenchRegionTabs: (props: WorkbenchRegionTabsProps) => import("react/jsx-runtime").JSX.Element | null;
185
+ export declare const WorkbenchRegionTabs: (props: WorkbenchRegionTabsProps) => import("react/jsx-runtime").JSX.Element;
160
186
  //#endregion
161
187
  //#region src/react/region/widget-host.d.ts
162
188
  interface WorkbenchWidgetHostProps {
@@ -224,7 +250,7 @@ interface WorkbenchTreeViewProps {
224
250
  workbench: WorkbenchCore;
225
251
  treeViewId: string;
226
252
  activeNodeId?: string | null;
227
- resource?: ResourceRef;
253
+ resource?: ResourceRef$1;
228
254
  viewId?: string;
229
255
  renderParamField?: CommandParamFieldRenderer;
230
256
  onOpenResourceError?: (error: unknown) => void;
@@ -232,6 +258,49 @@ interface WorkbenchTreeViewProps {
232
258
  }
233
259
  export declare const WorkbenchTreeView: (props: WorkbenchTreeViewProps) => import("react/jsx-runtime").JSX.Element;
234
260
  //#endregion
261
+ //#region src/react/renderers/workbench-connection-provider.d.ts
262
+ interface WorkbenchConnectionProviderProps {
263
+ connected: boolean;
264
+ children: ReactNode;
265
+ }
266
+ export declare const WorkbenchConnectionProvider: (props: WorkbenchConnectionProviderProps) => import("react/jsx-runtime").JSX.Element;
267
+ //#endregion
268
+ //#region src/react/resource-links/resource-links-types.d.ts
269
+ interface ResourceLinkCandidate {
270
+ resource: ResourceRef;
271
+ description?: string;
272
+ open?: () => void | Promise<void>;
273
+ }
274
+ interface ResourceLinksService {
275
+ list(input: ResourceAnchorQuery): Promise<ResourceAnchorPage>;
276
+ add(source: ResourceRef, targets: ResourceAnchor[]): Promise<void>;
277
+ remove(source: ResourceRef, targets: ResourceRef[]): Promise<void>;
278
+ search(query: string, signal?: AbortSignal): Promise<ResourceLinkCandidate[]>;
279
+ resolve(resources: ResourceRef[], signal?: AbortSignal): Promise<ResourceLinkCandidate[]>;
280
+ subscribe(listener: () => void): () => void;
281
+ }
282
+ //#endregion
283
+ //#region src/react/resource-links/related-resources.d.ts
284
+ interface RelatedResourcesProps {
285
+ resource: ResourceRef;
286
+ service: ResourceLinksService;
287
+ onClose(): void;
288
+ }
289
+ export declare const RelatedResources: (props: RelatedResourcesProps) => import("react/jsx-runtime").JSX.Element;
290
+ //#endregion
291
+ //#region src/react/resource-links/resource-links-module.d.ts
292
+ interface WorkbenchResourceLinksOptions {
293
+ canonicalize(resource: ResourceRef): ResourceRef | undefined;
294
+ createService(resource: ResourceRef): ResourceLinksService;
295
+ }
296
+ export declare const resourceLinksCommandId = "workbench.resources.links";
297
+ export declare const createWorkbenchResourceLinksModule: (options: WorkbenchResourceLinksOptions) => {
298
+ id: string;
299
+ activate(ctx: WorkbenchCoreContributionContext): {
300
+ dispose: () => void;
301
+ };
302
+ };
303
+ //#endregion
235
304
  //#region src/react/settings/settings-resources.d.ts
236
305
  export declare const WORKBENCH_SETTINGS_OPEN_COMMAND_ID = "workbench.settings.open";
237
306
  //#endregion
@@ -267,7 +336,10 @@ interface WorkbenchSidePanelProps {
267
336
  onOpen?: () => void;
268
337
  }
269
338
  export declare const WorkbenchAttachedSidePanel: (props: WorkbenchSidePanelProps) => import("react/jsx-runtime").JSX.Element;
270
- export declare const WorkbenchFloatingSidePanel: (props: WorkbenchSidePanelProps) => import("react/jsx-runtime").JSX.Element | null;
339
+ interface WorkbenchFloatingSidePanelProps extends WorkbenchSidePanelProps {
340
+ available?: boolean;
341
+ }
342
+ export declare const WorkbenchFloatingSidePanel: (props: WorkbenchFloatingSidePanelProps) => import("react/jsx-runtime").JSX.Element;
271
343
  //#endregion
272
344
  //#region src/react/statuses/workflow-status-settings.d.ts
273
345
  interface WorkflowStatusSettingsProps {
@@ -286,7 +358,7 @@ export declare const WORKBENCH_TERMINAL_PANEL_SIZE: {
286
358
  minPx: number;
287
359
  };
288
360
  interface OpenWorkbenchTerminalOptions {
289
- resource?: ResourceRef;
361
+ resource?: ResourceRef$1;
290
362
  reveal?: boolean;
291
363
  }
292
364
  export declare const openWorkbenchTerminal: (ctx: WorkbenchCoreContributionContext, input?: OpenWorkbenchTerminalOptions) => WorkbenchPanelInstance;
@@ -303,7 +375,7 @@ export declare const createWorkbenchTerminalModule: () => WorkbenchModuleContrib
303
375
  //#region src/react/terminal/workbench-terminal-panel.d.ts
304
376
  interface ControllerTerminalBridgeOptions {
305
377
  getBindingId?: () => string | undefined;
306
- getResource?: () => ResourceRef | undefined;
378
+ getResource?: () => ResourceRef$1 | undefined;
307
379
  getTitle?: () => string | undefined;
308
380
  }
309
381
  export declare const createControllerTerminalBridge: (terminal: WorkbenchTerminalController, options?: ControllerTerminalBridgeOptions) => TerminalBridge;
@@ -335,6 +407,8 @@ interface WorkbenchThemeProviderProps {
335
407
  initialThemePreference?: ThemePreference;
336
408
  defaultThemePreference?: ThemePreference;
337
409
  preferenceScope?: string;
410
+ /** Where the chosen theme is saved. Defaults to browser storage. */
411
+ themeStorage?: ThemePreferenceStorage;
338
412
  themePreferences?: readonly ThemePreferenceOption[];
339
413
  fileIconThemePreferences?: readonly FileIconThemePreferenceOption[];
340
414
  }
@@ -380,6 +454,8 @@ interface WorkbenchProps {
380
454
  sidePanelBubbleIcon?: ReactNode;
381
455
  /** Host action for opening the closed Side Panel from its bubble launcher. */
382
456
  onOpenSidePanel?: () => void;
457
+ /** Host storage for the chosen theme. Defaults to browser storage. */
458
+ themeStorage?: ThemePreferenceStorage;
383
459
  }
384
460
  export declare const Workbench: (props: WorkbenchProps) => import("react/jsx-runtime").JSX.Element;
385
461
  //#endregion
@@ -395,5 +471,5 @@ export declare const disposeWorkbenchModuleHostRegistrations: (registrations: Ma
395
471
  export declare const syncWorkbenchModuleHostRegistrations: (workbench: WorkbenchCore, registrations: Map<string, WorkbenchModuleHostRegistration>, modules: readonly WorkbenchModuleContribution[]) => void;
396
472
  export declare const WorkbenchModuleHost: (props: WorkbenchModuleHostProps) => null;
397
473
  //#endregion
398
- export type { CommandFilesParamValue, CommandParamEntry, CommandParamFieldProps, CommandParamFieldRenderer, CommandParamValue, PreferenceParamEntry, ReactAttributeDescriptor, ReactAttributesSource, ReactBoardColumnConfig, ReactKanbanRendererContribution, ReactResourceContextAction, TreeActionParamsRequest, WorkbenchHotkeyRegistration, WorkbenchMenuItem, WorkbenchModuleHostProps, WorkbenchModuleHostRegistration, WorkbenchOverlayWidgetConfig, WorkbenchPanelRenderInput, WorkbenchPreferencesFormProps, WorkbenchSettingsModuleOptions };
474
+ export type { CommandFilesParamValue, CommandOptionState, CommandParamEntry, CommandParamFieldProps, CommandParamFieldRenderer, CommandParamValue, ExecuteOptionCommand, PreferenceParamEntry, ReactAttributeDescriptor, ReactAttributesSource, ReactBoardColumnConfig, ReactKanbanRendererContribution, ReactResourceContextAction, ResourceLinkCandidate, ResourceLinksService, TreeActionParamsRequest, WorkbenchHotkeyRegistration, WorkbenchMenuItem, WorkbenchModuleHostProps, WorkbenchModuleHostRegistration, WorkbenchOverlayWidgetConfig, WorkbenchPanelRenderInput, WorkbenchPreferencesFormProps, WorkbenchResourceLinksOptions, WorkbenchSettingsModuleOptions };
399
475
  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, b as O, d as k, et as A, f as j, g as M, h as N, i as P, j as F, k as I, l as L, m as R, n as z, nt as B, p as V, q as H, r as U, rt as W, t as G, tt as K, u as q, v as J, w as Y, x as X, y as Z, z as Q } from "./react-NAZBfSZz.js";
2
- export { H as CommandParamField, r as WORKBENCH_SETTINGS_NAV_WIDGET_ID, i as WORKBENCH_SETTINGS_OPEN_COMMAND_ID, Y as WORKBENCH_SETTINGS_PANEL_WIDGET_ID, b as WORKBENCH_SETTINGS_WIDGET_ID, V as WORKBENCH_TERMINAL_OPEN_COMMAND_ID, R as WORKBENCH_TERMINAL_PANEL_SIZE, N as WORKBENCH_TERMINAL_WIDGET_ID, P as Workbench, X as WorkbenchAttachedSidePanel, K as WorkbenchBreadcrumbView, d as WorkbenchCommandPalette, p as WorkbenchDataTableView, y as WorkbenchFloatingSidePanel, s as WorkbenchFocusRegion, x as WorkbenchHeaderActions, W as WorkbenchIcon, n as WorkbenchKeybindingDispatcher, G as WorkbenchModuleHost, l as WorkbenchNotificationHost, L as WorkbenchOverlayLayer, I as WorkbenchPreferencesForm, g as WorkbenchRegion, m as WorkbenchRegionTabs, J as WorkbenchTerminalPanel, k as WorkbenchThemeProvider, q as WorkbenchThemeScope, h as WorkbenchTreeView, o as WorkbenchWidgetHost, O as WorkflowStatusSettings, w as buildCommandParamInitialValues, u as commandParamName, E as createCommandFilesParamValue, Z as createControllerTerminalBridge, Q as createTreeContextMenuItems, S as createWorkbenchHotkeyRegistrations, f as createWorkbenchResourceActions, a as createWorkbenchSettingsModule, M as createWorkbenchTerminalModule, z as disposeWorkbenchModuleHostRegistrations, _ as isCommandFilesParamValue, e as listCommandParamEntries, C as listWorkbenchMenuItems, A as normalizeCommandParamValues, c as normalizeWorkbenchKeybinding, D as openWorkbenchTerminal, t as paramValueToPreference, F as preferenceSchemaToParams, T as readCommandParamValue, U as syncWorkbenchModuleHostRegistrations, v as useWorkbenchResourceActionResolver, B as useWorkbenchStore, j as useWorkbenchThemePreferences };
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, dt as M, et as N, f as P, g as F, h as I, i as L, it as R, j as z, k as B, lt as V, m as H, n as U, nt as W, ot as G, p as K, q, r as J, rt as Y, st as X, t as Z, tt as Q, ut as $, v as ee, w as te, x as ne, y as re, z as ie } from "./react-Buqbh5XD.js";
2
+ export { Y as CommandOptionStatus, N as CommandParamField, p as RelatedResources, b as WORKBENCH_SETTINGS_NAV_WIDGET_ID, B as WORKBENCH_SETTINGS_OPEN_COMMAND_ID, a as WORKBENCH_SETTINGS_PANEL_WIDGET_ID, i as WORKBENCH_SETTINGS_WIDGET_ID, I as WORKBENCH_TERMINAL_OPEN_COMMAND_ID, F as WORKBENCH_TERMINAL_PANEL_SIZE, D as WORKBENCH_TERMINAL_WIDGET_ID, L as Workbench, r as WorkbenchAttachedSidePanel, R as WorkbenchBreadcrumbView, _ as WorkbenchCommandPalette, v as WorkbenchConnectionProvider, f as WorkbenchDataTableView, te as WorkbenchFloatingSidePanel, E as WorkbenchFocusRegion, T as WorkbenchHeaderActions, M as WorkbenchIcon, d as WorkbenchKeybindingDispatcher, Z as WorkbenchModuleHost, c as WorkbenchNotificationHost, j as WorkbenchOverlayLayer, g as WorkbenchPreferencesForm, n as WorkbenchRegion, ie as WorkbenchRegionTabs, k as WorkbenchTerminalPanel, K as WorkbenchThemeProvider, P as WorkbenchThemeScope, m as WorkbenchTreeView, S as WorkbenchWidgetHost, y as WorkflowStatusSettings, G as buildCommandParamInitialValues, Q as commandParamName, X as createCommandFilesParamValue, ne as createControllerTerminalBridge, s as createTreeContextMenuItems, q as createWorkbenchHotkeyRegistrations, x as createWorkbenchResourceActions, t as createWorkbenchResourceLinksModule, h as createWorkbenchSettingsModule, ee as createWorkbenchTerminalModule, U as disposeWorkbenchModuleHostRegistrations, A as isCommandFilesParamValue, V as listCommandParamEntries, w as listWorkbenchMenuItems, $ as normalizeCommandParamValues, u as normalizeWorkbenchKeybinding, re as openWorkbenchTerminal, o as paramValueToPreference, l as preferenceSchemaToParams, W as readCommandParamValue, z as resourceLinksCommandId, J as syncWorkbenchModuleHostRegistrations, e as useCommandOptions, C as useWorkbenchResourceActionResolver, O as useWorkbenchStore, H as useWorkbenchThemePreferences };
package/dist/storage.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Jr as LayoutPersistenceAdapter, L as WorkbenchPersistenceAdapter, Rr as TreeRendererPersistenceAdapter, pn as WorkbenchPageLocationPersistence, sn as WorkbenchPanelMenuStatePersistenceAdapter } from "./index-DLh_fcGT.js";
1
+ import { Hr as TreeRendererPersistenceAdapter, Qr as LayoutPersistenceAdapter, _n as WorkbenchPageLocationPersistence, dn as WorkbenchPanelMenuStatePersistenceAdapter, rt as WorkbenchStatusBarPersistenceAdapter, z as WorkbenchPersistenceAdapter } from "./index-BUtrxfUl.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" | "tree";
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,6 +37,7 @@ 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;
package/dist/storage.js CHANGED
@@ -162,37 +162,41 @@ var e = (e, t, n) => `${e}:${t}:${n ?? "global"}`, t = () => {
162
162
  i.setItem(a, JSON.stringify(e));
163
163
  }
164
164
  };
165
- }, f = (e) => {
166
- let t = n(e.storage), r = s({
167
- debounceMs: e.debounceMs,
168
- eventTarget: e.eventTarget,
169
- namespace: e.namespace,
170
- storage: t
171
- });
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;
175
+ },
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);
172
180
  return {
173
- snapshotPersistence: {
174
- getSnapshot: (e) => {
175
- let t = r.getLayout(e);
176
- return t ? { layout: t } : void 0;
177
- },
178
- setSnapshot: (e, t) => r.setLayout(e.layout, t),
179
- flush: r.flush,
180
- dispose: r.dispose
181
+ snapshotPersistence: o,
182
+ statusBarPersistence: {
183
+ getOrder: () => r(i, c),
184
+ setOrder: (e) => i.setItem(c, JSON.stringify(e))
181
185
  },
182
- layoutPersistence: r,
186
+ layoutPersistence: a,
183
187
  panelMenuStatePersistence: u({
184
- namespace: e.namespace,
185
- scope: e.scope ?? "global",
186
- storage: t
188
+ namespace: t.namespace,
189
+ scope: t.scope ?? "global",
190
+ storage: i
187
191
  }),
188
192
  pageLocationPersistence: l({
189
- namespace: e.namespace,
190
- storage: t
193
+ namespace: t.namespace,
194
+ storage: i
191
195
  }),
192
196
  treePersistence: d({
193
- namespace: e.namespace,
194
- scope: e.scope,
195
- storage: t
197
+ namespace: t.namespace,
198
+ scope: t.scope,
199
+ storage: i
196
200
  })
197
201
  };
198
202
  };
@@ -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","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","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","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","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 | \"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} 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\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 };\n};\n"],"mappings":";AA4BA,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;GACnBmB,EAAIM,OAAOzB,CAAG;EAChB;CACF;AACF,GAEa0B,KAAkBZ,MACzBA,MACA,OAAOa,eAAiB,MAAoBA,eACzCT,EAAoB,IAGhBU,KAAed,GAA+Bd,MAA+B;CACxF,IAAM8B,IAAMhB,EAAQf,QAAQC,CAAG;CAC/B,IAAK8B,GACL,IAAI;EACF,OAAOE,KAAKC,MAAMH,CAAG;CACvB,QAAQ;EACN;CACF;AACF,GC/CMc,IAA2B,GAC3BE,IAAiC,GACjCC,IAAkC,IAY3BK,KACXC,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,WAAWL,EAAMK;EACjBJ;CACF,CAAC;CAWD,OAAO;EACLyB,qBAAAA;GAVAC,cAAcnC,MAAU;IACtB,IAAMoC,IAASL,EAAkBM,UAAUrC,CAAK;IAChD,OAAOoC,IAAS,EAAEA,UAAO,IAAItB,KAAAA;GAC/B;GACAwB,cAAcC,GAAUvC,MAAU+B,EAAkBS,UAAUD,EAASH,QAAQpC,CAAK;GACpFyC,OAAOV,EAAkBU;GACzBC,SAASX,EAAkBW;EAI3BR;EACAH;EACAY,2BAA2BrB,EAA4C;GACrET,WAAWL,EAAMK;GACjBb,OAAOQ,EAAMR,SAAS;GACtBS;EACF,CAAC;EACDmC,yBAAyBrC,EAA0C;GAAEM,WAAWL,EAAMK;GAAWJ;EAAQ,CAAC;EAC1GoC,iBAAiBlB,EAAkC;GAAEd,WAAWL,EAAMK;GAAWb,OAAOQ,EAAMR;GAAOS;EAAQ,CAAC;CAChH;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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AC;CAChH;AACF"}
@@ -27,7 +27,7 @@ var e = "pstdio-extension-mount", t = (e) => e.replaceAll("&", "&amp;").replaceA
27
27
  ${t}
28
28
  </body>
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 ne(){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??{},r=t.release?.name;if(n.bun||r===\"bun\"||e.Bun!==void 0)return\"bun\";if(n.node&&r===\"node\")return\"node\"}return e.Bun===void 0?\"browser\":\"bun\"}function M(){return ne()}function B(){return M()===\"worker\"}function z(){let e=M();return e===\"node\"||e===\"bun\"}function re(){return window.self!==window.top}function se(e){let t={};return function n(r,i=\"\"){Object.keys(r).forEach((s)=>{let o=i?`${i}.${s}`:s;r[s]===Object(r[s])&&n(r[s],o),typeof r[s]==\"function\"&&(t[o]=r[s],delete r[s])})}(e),t}function oe(e){return!e||e===\"null\"?\"*\":e}function ie(e,t,n){if(!e||typeof e!=\"object\")return e;let r=Array.isArray(t)?t:t.split(\".\").map((s)=>s.match(/^\\d+$/)?Number(s):s),i=e;for(let s=0;s<r.length;s++){let o=r[s];s===r.length-1?i[o]=n:((!i[o]||typeof i[o]!=\"object\")&&(i[o]=typeof r[s+1]==\"number\"?[]:{}),i=i[o])}return e}function ae(e=10){let t=\"\";for(let n=0;n<e;n++)t+=\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789\".charAt(Math.floor(Math.random()*62));return t}var V=M(),R=null;if(V===\"node\"||V===\"bun\")try{let e=globalThis.require;R=e?.(\"node:worker_threads\")?.parentPort??null}catch{}function ce(){if(z())return R;if(B())return self;if(re())return window.parent;throw Error(\"No valid target found for postMessage\")}function A(e,t,n,r){if(!e)throw Error(\"Rimless Error: No target specified for postMessage\");if(z()&&e===R){e.postMessage(t,{transfer:r});return}if(B()){e.postMessage(t,{transfer:r});return}if(e.postMessage){e.postMessage(t,{targetOrigin:oe(n),transfer:r});return}throw Error(\"Rimless Error: Invalid target for postMessage\")}function G(e){return R!==null&&e===R}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 _(e){return e.data||e}var b=function(e){return e.MESSAGE=\"message\",e}({}),h=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}({}),E=Symbol();function de(e={},t,n,r,i){let s=[];for(let[o,l]of Object.entries(e)){async function a(m){let{action:g,callID:y,connectionID:f,callName:I,args:v=[]}=_(m);if(g!==h.RPC_REQUEST||!y||!I||I!==o||f!==t)return;let u={action:h.RPC_RESOLVE,callID:y,callName:I,connectionID:f,error:null,result:null},C;try{u.result=await l(...v,i),u.result?.[E]&&(C=u.result[E]??[],delete u.result[E])}catch(P){u.action=h.RPC_REJECT,u.error=JSON.parse(JSON.stringify(P,Object.getOwnPropertyNames(P)))}A(r,u,m?.origin,C)}L(n,b.MESSAGE,a),s.push(()=>O(n,b.MESSAGE,a))}return()=>s.forEach((o)=>o())}function le(e,t,n,r=new Set,i,s){return(...o)=>new Promise((l,a)=>{let m=ae();function g(){O(i,b.MESSAGE,y),r.delete(g)}function y(v){let{callID:u,connectionID:C,callName:P,result:ee,error:te,action:W}=_(v);if(!(!u||!P)&&P===e&&u===m&&C===t){if(W===h.RPC_RESOLVE)return g(),l(ee);if(W===h.RPC_REJECT)return g(),a(te)}}let f={action:h.RPC_REQUEST,args:o,callID:m,callName:e,connectionID:t},I=o.reduce((v,u)=>u[E]?.length?v.concat(u[E]):v,o[E]??[]);L(i,b.MESSAGE,y),r.add(g),A(s,f,n?.origin,I)})}function fe(e={},t=[],n,r,i,s){let o={...e},l=new Set;for(let a of t)ie(o,a,le(a,n,r,l,i,s));return{remote:o,unregisterRemote:()=>l.forEach((a)=>a())}}function ue(e={},t){return new Promise(async(n)=>{let r=se(e),i=ce(),s=self||window;async function o(l){let a=_(l);if(a?.action!==h.HANDSHAKE_REPLY)return;let{remote:m,unregisterRemote:g}=fe(a.schema,a.methodNames,a.connectionID,l,s,i),y=de(r,a.connectionID,s,i,m);return await t?.onConnectionSetup?.(m),A(i,{action:h.HANDSHAKE_REPLY,connectionID:a.connectionID},l?.origin),n({remote:m,close:()=>{O(s,b.MESSAGE,o),g(),y()},id:a.connectionID})}L(s,b.MESSAGE,o),A(i,{action:h.HANDSHAKE_REQUEST,methodNames:Object.keys(r),schema:e})})}var J={connect:ue};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\"}},j=(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,n=typeof e.stack===\"string\"?e.stack:void 0;if(t)return n?{message:t,stack:n}:{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*)\",Ce=new RegExp(`^\\\\^(${N}\\\\.${N}\\\\.${N})$`);var H=[\"sidenav\",\"main\",\"secondary\",\"side\"];var p=(e,t)=>({extensionId:\"pstdio\",kind:e,id:t}),w={project:p(\"mode\",\"project\"),sessions:p(\"mode\",\"sessions\"),settings:p(\"mode\",\"settings\")},Ae={project:{ref:w.project,regions:H},sessions:{ref:w.sessions,regions:H},settings:{ref:w.settings,regions:H}},U=(e,t,n)=>({id:e,ref:p(\"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)},S={project:K.project.ref,session:K.session.ref,workspace:K.workspace.ref},x={start:p(\"page\",\"start\"),sessions:p(\"page\",\"sessions\"),session:p(\"page\",\"session\"),workspaces:p(\"page\",\"workspaces\"),workspace:p(\"page\",\"workspace\")},je={start:{ref:x.start,mode:w.project,path:\"\",primary:{cardinality:\"one\",resourceKinds:[]}},sessions:{ref:x.sessions,mode:w.sessions,path:\"sessions\",primary:{cardinality:\"one\",resourceKinds:[]}},session:{ref:x.session,mode:w.sessions,path:\"session\",primary:{cardinality:\"one\",resourceKinds:[\"session\",\"session-draft\"]}},workspaces:{ref:x.workspaces,mode:w.project,path:\"workspaces\",primary:{cardinality:\"one\",resourceKinds:[]}},workspace:{ref:x.workspace,mode:w.project,path:\"workspace\",primary:{cardinality:\"many\",resourceKinds:[\"workspace\"]}}},me={projectSession:p(\"placement\",\"project-session\")},Te={projectSession:{ref:me.projectSession,mode:w.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 F=(e)=>({...e,kind:\"command\"}),Le=Object.assign(F,{forExtension:(e)=>(t)=>F({extensionId:`${e.publisher}.${e.name}`,id:t})}),ge=(e)=>({...e,kind:\"event\"}),T=(e,t)=>({id:e,kind:t.kind,label:t.label,description:t.description,metadata:t.metadata}),d=(e)=>ge({extensionId:\"pstdio\",id:e}),k=(e,t)=>T(`${e.id}.${t}`,{kind:\"menu\"}),Oe={sidenav:T(\"project.sidenav\",{kind:\"panel\"}),headerPrimary:k(S.project,\"headerPrimary\"),headerOverflow:k(S.project,\"headerOverflow\"),settingsPanels:T(\"project.settingsPanels\",{kind:\"settings\"})},_e={headerPrimary:k(S.session,\"headerPrimary\"),headerOverflow:k(S.session,\"headerOverflow\")},$e={headerPrimary:k(S.workspace,\"headerPrimary\"),headerOverflow:k(S.workspace,\"headerOverflow\"),sidenav:T(\"workspace.sidenav\",{kind:\"panel\"})},Ne={opened:d(\"project.opened\")},He={boardViewsChanged:d(\"view.board-views.changed\"),resourceAnchorsChanged:d(\"view.resource-anchors.changed\"),sessionsChanged:d(\"view.sessions.changed\"),workspacesChanged:d(\"view.workspaces.changed\"),repositoriesChanged:d(\"view.repositories.changed\")},Ue={started:d(\"session.started\"),resumed:d(\"session.resumed\"),awaitingInput:d(\"session.awaitingInput\"),succeeded:d(\"session.succeeded\"),failed:d(\"session.failed\"),completed:d(\"session.completed\")},De={created:d(\"workspace.created\"),provision:d(\"workspace.provision\"),ready:d(\"workspace.ready\"),archived:d(\"workspace.archived\"),deleted:d(\"workspace.deleted\")},Ke={removed:d(\"worktree.removed\")},We={committed:d(\"git.committed\"),rebased:d(\"git.rebased\"),merged:d(\"git.merged\"),conflicted:d(\"git.conflicted\")};var ye=[\"clipboard.write\",\"commands.execute\",\"commands.stream\",\"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\"],he=[\"artifacts.read\"],we=[\"host.dispatchKeyboardEvent\"],Ve=[...ye.filter((e)=>e!==\"clipboard.write\"),...he,...we];var c=(e)=>(t)=>({...t,ref:{kind:e,id:t.id}}),Be=c(\"view\"),ze=c(\"view-menu\"),Ge=c(\"placement\"),Je=c(\"resource-kind\");var qe=c(\"navigation-item\"),Fe=c(\"navigation-tree\"),Ye=c(\"mode\");var Qe=c(\"status-bar-item\"),Xe=c(\"status\"),Ze=c(\"settings-panel\"),et=c(\"activity-item\"),tt=c(\"settings-section\"),nt=c(\"command-palette-resource\"),rt=c(\"keybinding\"),st=c(\"schedule\"),ot=c(\"artifact-mount\"),it=c(\"template-type\"),at=c(\"template\"),ct=c(\"skill\"),dt=c(\"theme\"),lt=c(\"file-icon-theme\"),ft=c(\"workspace-type\"),ut=c(\"harness\"),pt=c(\"connection\");var Y=(e,t,n)=>({call:async(r,...i)=>{try{return await e({method:r,params:i[0]})}catch(s){if(s instanceof Error)throw s;throw Error(j(s).message)}},onEvent:t,extensionId:n}),Q=(e)=>{let t=e,n=new Set;return{get:()=>t,subscribe:(r)=>(n.add(r),()=>n.delete(r)),set:(r)=>{t=r;for(let i of n)i(t)}}};var X=\"pstdio-extension-mount\",ve=()=>{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)}},Ee=()=>{for(let e of[\"localStorage\",\"sessionStorage\"])try{window[e]}catch{Object.defineProperty(window,e,{configurable:!0,value:ve()})}},Z=(e,t)=>{let n=document.documentElement,r=e===\"dark\"?\"light\":\"dark\";n.classList.remove(r),n.classList.add(e),n.setAttribute(\"data-theme\",e),n.style.colorScheme=e;for(let[i,s]of Object.entries(t))if(i.startsWith(\"--\"))n.style.setProperty(i,s)},be=(e)=>{for(let t of e){let n=document.createElement(\"link\");n.rel=\"stylesheet\",n.href=t,document.head.appendChild(n)}},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},ke=()=>{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})},Ie=(e)=>e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement||e instanceof HTMLElement&&e.isContentEditable,Pe=async()=>{Ee(),ke();let e=Q(void 0),t=new Map,n=(o,l)=>{let a=t.get(o)??new Set;return a.add(l),t.set(o,a),()=>{a.delete(l)}},r,i=!1,s=await J.connect({init:async(o)=>{try{Z(o.theme,o.themeVariables),be(o.styles),e.set(o.props);let l=Se(),a=await import(o.moduleUrl),m=a.default??(a.mount?a:void 0);if(!m?.mount)throw Error(\"Extension module does not export a default view (defineExtensionView).\");let g=Y((f)=>s.remote.call(f),n,o.extensionId),y=await m.mount(l,g,e);if(r=typeof y===\"function\"?y:void 0,!i)i=!0,document.addEventListener(\"keydown\",(f)=>{if(!f.ctrlKey&&!f.metaKey&&!f.altKey)return;if(Ie(f.target)&&!f.shiftKey)return;s.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(l){let a=j(l);throw s.remote.runtimeError(a),l instanceof Error?l:Error(a.message)}},themeUpdate:(o)=>{Z(o.theme,o.variables)},propsUpdate:(o)=>{e.set(o.props)},hostEvent:(o)=>{for(let l of t.get(o.scope)??[])l(o.payload)}});s.remote.ready({}),window.addEventListener(\"beforeunload\",()=>{r?.()})};Pe();\n";
31
31
  //#endregion
32
32
  export { o as getExtensionRuntimeScript, i as renderExtensionRuntimeHtml, a as renderInlineExtensionRuntimeHtml };
33
33