@pstdio/workbench 0.38.0 → 0.40.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 +43 -2
- package/dist/extensions.js +284 -255
- package/dist/extensions.js.map +1 -1
- package/dist/{file-renderer-view-B1tNSzpa.js → file-renderer-view-C95GHv9m.js} +3 -3
- package/dist/{file-renderer-view-B1tNSzpa.js.map → file-renderer-view-C95GHv9m.js.map} +1 -1
- package/dist/{index-Cl3NI1pb.d.ts → index-DLh_fcGT.d.ts} +327 -263
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1496 -1316
- package/dist/index.js.map +1 -1
- package/dist/{kanban-presentation-Mb9rbE48.d.ts → kanban-presentation-Ds4FpmbS.d.ts} +1 -1
- package/dist/navigation-tree-registry-DazyPivr.js +106 -0
- package/dist/navigation-tree-registry-DazyPivr.js.map +1 -0
- package/dist/{react-Dnt2zZRw.js → react-NAZBfSZz.js} +2926 -2580
- package/dist/react-NAZBfSZz.js.map +1 -0
- package/dist/react.d.ts +3 -2
- package/dist/react.js +1 -1
- package/dist/storage.d.ts +2 -3
- package/dist/storage.js +12 -29
- package/dist/storage.js.map +1 -1
- package/dist/webview-runtime.js +1 -1
- package/dist/{workbench-renderers-RPeMVtTc.js → workbench-renderers-DNXWpDWd.js} +151 -144
- package/dist/workbench-renderers-DNXWpDWd.js.map +1 -0
- package/package.json +3 -3
- package/dist/navigation-tree-registry-CKB9qsW1.js +0 -102
- package/dist/navigation-tree-registry-CKB9qsW1.js.map +0 -1
- package/dist/react-Dnt2zZRw.js.map +0 -1
- package/dist/workbench-renderers-RPeMVtTc.js.map +0 -1
package/dist/react.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
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 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";
|
|
3
3
|
import { ReactNode } from "react";
|
|
4
4
|
import { FileIconThemePreferenceOption, ResourceContextAction, ThemePreference, ThemePreferenceOption } from "@pstdio/ui";
|
|
5
5
|
import { FileUploadValue, ParamEditorProps, ParamValue } from "@pstdio/ui/param-editor";
|
|
@@ -170,6 +170,7 @@ export declare const WorkbenchWidgetHost: (props: WorkbenchWidgetHostProps) => i
|
|
|
170
170
|
//#region src/react/renderers/data-table/data-table-view.d.ts
|
|
171
171
|
interface WorkbenchDataTableViewProps {
|
|
172
172
|
workbench: WorkbenchCore;
|
|
173
|
+
renderParamField?: CommandParamFieldRenderer;
|
|
173
174
|
contribution: RegisteredDataTableRendererContribution;
|
|
174
175
|
placement: WorkbenchPanelInstance;
|
|
175
176
|
}
|
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-
|
|
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
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 };
|
package/dist/storage.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Jr as LayoutPersistenceAdapter, L as WorkbenchPersistenceAdapter, Rr as TreeRendererPersistenceAdapter, pn as WorkbenchPageLocationPersistence, sn as WorkbenchPanelMenuStatePersistenceAdapter } from "./index-DLh_fcGT.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" | "tree";
|
|
11
11
|
interface CreateWorkbenchStoragePersistenceInput {
|
|
12
12
|
debounceMs?: number;
|
|
13
13
|
eventTarget?: {
|
|
@@ -41,7 +41,6 @@ export declare const createLocalStorageWorkbenchPersistence: (input: CreateLocal
|
|
|
41
41
|
panelMenuStatePersistence: WorkbenchPanelMenuStatePersistenceAdapter;
|
|
42
42
|
pageLocationPersistence: WorkbenchPageLocationPersistence;
|
|
43
43
|
treePersistence: TreeRendererPersistenceAdapter;
|
|
44
|
-
sidePanelPersistence: WorkbenchSidePanelPersistenceAdapter;
|
|
45
44
|
};
|
|
46
45
|
//#endregion
|
|
47
46
|
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,26 +162,7 @@ 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
|
-
"attached",
|
|
160
|
-
"closed",
|
|
161
|
-
"floating"
|
|
162
|
-
], m = (t) => {
|
|
163
|
-
let i = n(t.storage), a = e(t.namespace, "side-panel", t.scope);
|
|
164
|
-
return {
|
|
165
|
-
getMode: () => {
|
|
166
|
-
let e = r(i, a);
|
|
167
|
-
if (e?.version === f) return p.includes(e.mode) ? e.mode : void 0;
|
|
168
|
-
},
|
|
169
|
-
setMode: (e) => {
|
|
170
|
-
let t = {
|
|
171
|
-
version: f,
|
|
172
|
-
mode: e
|
|
173
|
-
};
|
|
174
|
-
i.setItem(a, JSON.stringify(t));
|
|
175
|
-
}
|
|
176
|
-
};
|
|
177
|
-
}, h = (e) => {
|
|
165
|
+
}, f = (e) => {
|
|
178
166
|
let t = n(e.storage), r = s({
|
|
179
167
|
debounceMs: e.debounceMs,
|
|
180
168
|
eventTarget: e.eventTarget,
|
|
@@ -205,15 +193,10 @@ var e = (e, t, n) => `${e}:${t}:${n ?? "global"}`, t = () => {
|
|
|
205
193
|
namespace: e.namespace,
|
|
206
194
|
scope: e.scope,
|
|
207
195
|
storage: t
|
|
208
|
-
}),
|
|
209
|
-
sidePanelPersistence: m({
|
|
210
|
-
namespace: e.namespace,
|
|
211
|
-
scope: e.scope,
|
|
212
|
-
storage: t
|
|
213
196
|
})
|
|
214
197
|
};
|
|
215
198
|
};
|
|
216
199
|
//#endregion
|
|
217
|
-
export { s as createLocalStorageLayoutPersistence, l as createLocalStoragePageLocationPersistence, u as createLocalStoragePanelMenuStatePersistence, d as createLocalStorageTreePersistence,
|
|
200
|
+
export { s as createLocalStorageLayoutPersistence, l as createLocalStoragePageLocationPersistence, u as createLocalStoragePanelMenuStatePersistence, d as createLocalStorageTreePersistence, f as createLocalStorageWorkbenchPersistence, e as workbenchStoragePersistenceKey };
|
|
218
201
|
|
|
219
202
|
//# 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,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,GCjDMc,IAA2B,GAC3BE,IAAiC,GACjCC,IAAkC,IAY3BK,KACXC,MAC6B;CAC7B,IAAMC,IAAUhB,EAAee,EAAMC,OAAO,GACtCC,oBAAU,IAAIC,IAA4E,GAC1FG,IAAaN,EAAMM,cAAc,KACjCC,IACJP,EAAMO,gBACL,OAAOC,SAAW,MACf;EACEC,mBAAmBC,GAAkBC,MAAyBH,OAAOC,iBAAiBC,GAAMC,CAAQ;EACpGC,sBAAsBF,GAAkBC,MAAyBH,OAAOI,oBAAoBF,GAAMC,CAAQ;CAC5G,IACAE,KAAAA,IACFC,GAEEG,IAAgB/B,EAA+Bc,EAAMkB,WAAW,qBAA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,EAAM+B;EACnB1B,WAAWL,EAAMK;EACjBJ;CACF,CAAC;CAWD,OAAO;EACL+B,qBAAAA;GAVAC,cAAc1C,MAAU;IACtB,IAAM2C,IAASL,EAAkBM,UAAU5C,CAAK;IAChD,OAAO2C,IAAS,EAAEA,UAAO,IAAI5B,KAAAA;GAC/B;GACA8B,cAAcC,GAAU9C,MAAUsC,EAAkBS,UAAUD,EAASH,QAAQ3C,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","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,KAA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qBAAqBlC,EAAsCe,GAASiB,CAAG;EACvEG,gBAAgBJ,MAAU;GACxBhB,EAAQU,QAAQO,GAAKN,KAAKC,UAAUI,CAAK,CAAC;EAC5C;CACF;AACF,GAEaK,KAA0CtB,MAAuD;CAC5G,IAAMC,IAAUd,EAAea,EAAMC,OAAO,GACtCsB,IAAoBvC,EAAoC;EAC5DwC,YAAYxB,EAAMwB;EAClBC,aAAazB,EAAMyB;EACnBpB,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"}
|
package/dist/webview-runtime.js
CHANGED
|
@@ -27,7 +27,7 @@ var e = "pstdio-extension-mount", t = (e) => e.replaceAll("&", "&").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 re(){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 H(){return re()}function z(){return H()===\"worker\"}function B(){let e=H();return e===\"node\"||e===\"bun\"}function ne(){return window.self!==window.top}function se(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 oe(e){return!e||e===\"null\"?\"*\":e}function ie(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 ae(e=10){let t=\"\";for(let r=0;r<e;r++)t+=\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789\".charAt(Math.floor(Math.random()*62));return t}var V=H(),x=null;if(V===\"node\"||V===\"bun\")try{let e=globalThis.require;x=e?.(\"node:worker_threads\")?.parentPort??null}catch{}function ce(){if(B())return x;if(z())return self;if(ne())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(B()&&e===x){e.postMessage(t,{transfer:s});return}if(z()){e.postMessage(t,{transfer:s});return}if(e.postMessage){e.postMessage(t,{targetOrigin:oe(r),transfer:s});return}throw Error(\"Rimless Error: Invalid target for postMessage\")}function G(e){return x!==null&&e===x}function L(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 N(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 de(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=[]}=N(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)}L(r,b.MESSAGE,a),n.push(()=>O(r,b.MESSAGE,a))}return()=>n.forEach((o)=>o())}function le(e,t,r,s=[],i,n){return(...o)=>new Promise((d,a)=>{let u=ae();function E(v){let{callID:w,connectionID:g,callName:R,result:A,error:te,action:W}=N(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(te)}}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]??[]);L(i,b.MESSAGE,E),s.push(()=>O(i,b.MESSAGE,E)),C(n,m,r?.origin,f)})}function fe(e={},t=[],r,s,i,n){let o={...e},d=[];for(let a of t)ie(o,a,le(a,r,s,d,i,n));return{remote:o,unregisterRemote:()=>d.forEach((a)=>a())}}function pe(e={},t){return new Promise(async(r)=>{let s=se(e),i=ce(),n=self||window;async function o(d){let a=N(d);if(a?.action!==y.HANDSHAKE_REPLY)return;let{remote:u,unregisterRemote:E}=fe(a.schema,a.methodNames,a.connectionID,d,n,i),m=de(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})}L(n,b.MESSAGE,o),C(i,{action:y.HANDSHAKE_REQUEST,methodNames:Object.keys(s),schema:e})})}var J={connect:pe};var ue=(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(ue(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 j=\"(?:0|[1-9]\\\\d*)\",Y=`(?:${j}|\\\\d*[A-Za-z-][0-9A-Za-z-]*)`,Pe=new RegExp(`^${j}\\\\.${j}\\\\.${j}(?:-${Y}(?:\\\\.${Y})*)?(?:\\\\+[0-9A-Za-z-]+(?:\\\\.[0-9A-Za-z-]+)*)?$`),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\")},Ae={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\")},Ce={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\"]}}},me={projectSession:p(\"placement\",\"project-session\")},Me={projectSession:{ref:me.projectSession,mode:h.project,cardinality:\"many\",resourceKinds:[\"session\",\"session-draft\"]}},je={projectSettings:p(\"settings-panel\",\"project.settings\"),statusBarLeading:p(\"status-bar-item\",\"status-bar.leading\"),statusBarTrailing:p(\"status-bar-item\",\"status-bar.trailing\")};var Q=(e)=>({...e,kind:\"command\"}),Te=Object.assign(Q,{forExtension:(e)=>(t)=>Q({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}),l=(e)=>ge({extensionId:\"pstdio\",id:e}),I=(e,t)=>T(`${e.id}.${t}`,{kind:\"menu\"}),$e={sidenav:T(\"project.sidenav\",{kind:\"panel\"}),headerPrimary:I(k.project,\"headerPrimary\"),headerOverflow:I(k.project,\"headerOverflow\"),settingsPanels:T(\"project.settingsPanels\",{kind:\"settings\"})},He={headerPrimary:I(k.session,\"headerPrimary\"),headerOverflow:I(k.session,\"headerOverflow\")},Le={headerPrimary:I(k.workspace,\"headerPrimary\"),headerOverflow:I(k.workspace,\"headerOverflow\"),sidenav:T(\"workspace.sidenav\",{kind:\"panel\"})},Oe={opened:l(\"project.opened\")},Ne={sessionsChanged:l(\"view.sessions.changed\"),workspacesChanged:l(\"view.workspaces.changed\"),repositoriesChanged:l(\"view.repositories.changed\")},Ue={started:l(\"session.started\"),resumed:l(\"session.resumed\"),awaitingInput:l(\"session.awaitingInput\"),succeeded:l(\"session.succeeded\"),failed:l(\"session.failed\"),completed:l(\"session.completed\")},_e={created:l(\"workspace.created\"),provision:l(\"workspace.provision\"),ready:l(\"workspace.ready\"),archived:l(\"workspace.archived\"),deleted:l(\"workspace.deleted\")},Ke={removed:l(\"worktree.removed\")},De={committed:l(\"git.committed\"),rebased:l(\"git.rebased\"),merged:l(\"git.merged\"),conflicted:l(\"git.conflicted\")};var ye=[\"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\"],he=[\"artifacts.read\"],Ee=[\"host.dispatchKeyboardEvent\"],We=[...ye.filter((e)=>e!==\"clipboard.write\"),...he,...Ee];var c=(e)=>(t)=>({...t,ref:{kind:e,id:t.id}}),Ve=c(\"view\"),ze=c(\"view-menu\"),Be=c(\"placement\"),Ge=c(\"resource-kind\");var Je=c(\"navigation-item\"),qe=c(\"navigation-tree\"),Ye=c(\"mode\");var Qe=c(\"status-bar-item\"),Fe=c(\"status\"),Ze=c(\"settings-panel\"),Xe=c(\"activity-item\"),et=c(\"settings-section\"),tt=c(\"command-palette-resource\"),rt=c(\"keybinding\"),nt=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\"),pt=c(\"connection\");var F=(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}),Z=(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\",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,r)=>e.set(t,r)}},we=()=>{for(let e of[\"localStorage\",\"sessionStorage\"])try{window[e]}catch{Object.defineProperty(window,e,{configurable:!0,value:ve()})}},ee=(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)},Se=(e)=>{for(let t of e){let r=document.createElement(\"link\");r.rel=\"stylesheet\",r.href=t,document.head.appendChild(r)}},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},ke=(e)=>e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement||e instanceof HTMLElement&&e.isContentEditable,Ie=async()=>{we();let e=Z(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{ee(o.theme,o.themeVariables),Se(o.styles),e.set(o.props);let d=be(),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=F((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(ke(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)=>{ee(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?.()})};Ie();\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 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";
|
|
31
31
|
//#endregion
|
|
32
32
|
export { o as getExtensionRuntimeScript, i as renderExtensionRuntimeHtml, a as renderInlineExtensionRuntimeHtml };
|
|
33
33
|
|