@pstdio/workbench 0.45.0-nightly.20261021143541 → 0.45.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/extensions.d.ts +21 -62
- package/dist/extensions.js +966 -694
- package/dist/extensions.js.map +1 -1
- package/dist/{index-D5tFB3t0.d.ts → index-DL-0XKr0.d.ts} +189 -196
- package/dist/index.d.ts +1 -1
- package/dist/index.js +434 -356
- package/dist/index.js.map +1 -1
- package/dist/{kanban-presentation-BfYisHaU.d.ts → kanban-presentation-CdHu43iH.d.ts} +1 -3
- package/dist/{layout-tab-presentation-Bz6EgFEa.js → layout-tab-presentation-CCUroIOY.js} +2 -3
- package/dist/{layout-tab-presentation-Bz6EgFEa.js.map → layout-tab-presentation-CCUroIOY.js.map} +1 -1
- package/dist/{navigation-tree-registry-OZpN52UT.js → navigation-tree-registry-DM4Lhfir.js} +3 -4
- package/dist/{navigation-tree-registry-OZpN52UT.js.map → navigation-tree-registry-DM4Lhfir.js.map} +1 -1
- package/dist/{react-CsoNLmR0.js → react-7X-EBlBD.js} +1072 -1241
- package/dist/react-7X-EBlBD.js.map +1 -0
- package/dist/react.d.ts +7 -94
- package/dist/react.js +1 -2
- package/dist/storage.d.ts +1 -7
- package/dist/storage.js +98 -87
- package/dist/storage.js.map +1 -1
- package/dist/webview-runtime.d.ts +0 -4
- package/dist/webview-runtime.js +2 -3
- package/dist/webview-runtime.js.map +1 -1
- package/dist/{workbench-renderers-DYpdN2Xi.js → workbench-renderers-DOc_oE0K.js} +9 -27
- package/dist/{workbench-renderers-DYpdN2Xi.js.map → workbench-renderers-DOc_oE0K.js.map} +1 -1
- package/package.json +3 -3
- package/dist/react-CsoNLmR0.js.map +0 -1
package/dist/storage.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as e } from "./layout-tab-presentation-
|
|
2
|
-
|
|
1
|
+
import { t as e } from "./layout-tab-presentation-CCUroIOY.js";
|
|
2
|
+
// src/storage/local-storage-persistence-helpers.ts
|
|
3
3
|
var t = (e, t, n) => `${e}:${t}:${n ?? "global"}`, n = () => {
|
|
4
4
|
let e = /* @__PURE__ */ new Map();
|
|
5
5
|
return {
|
|
@@ -22,66 +22,74 @@ var t = (e, t, n) => `${e}:${t}:${n ?? "global"}`, n = () => {
|
|
|
22
22
|
} catch {
|
|
23
23
|
return;
|
|
24
24
|
}
|
|
25
|
-
}, a = 5, o = 1, s = 50, c = (n) => {
|
|
26
|
-
let
|
|
25
|
+
}, a = 5, o = 1, s = 50, c = (e, n, r) => {
|
|
26
|
+
let o = i(e, t(n, "layout", r));
|
|
27
|
+
return o?.version === a ? o.layout : void 0;
|
|
28
|
+
}, l = (e, n, r, i) => e.removeItem ? (a) => {
|
|
29
|
+
let o = t(n, "layout", a), s = r.delete(o) || e.getItem(o) !== null;
|
|
30
|
+
e.removeItem?.(o), s && i(a, void 0);
|
|
31
|
+
} : void 0, u = (n) => {
|
|
32
|
+
let u = r(n.storage), d = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Set(), p = (e, t) => {
|
|
33
|
+
for (let n of f) n(e, t);
|
|
34
|
+
}, m = (e) => c(u, n.namespace, e), h = n.debounceMs ?? 250, g = n.eventTarget ?? (typeof window < "u" ? {
|
|
27
35
|
addEventListener: (e, t) => window.addEventListener(e, t),
|
|
28
36
|
removeEventListener: (e, t) => window.removeEventListener(e, t)
|
|
29
|
-
} : void 0),
|
|
30
|
-
let e = i(
|
|
37
|
+
} : void 0), _, v = t(n.namespace, "layout-generation", void 0), y = () => {
|
|
38
|
+
let e = i(u, v);
|
|
31
39
|
return typeof e == "object" && e && "version" in e && e.version === 1 && "generation" in e && typeof e.generation == "number" ? e.generation : 0;
|
|
32
|
-
},
|
|
33
|
-
let e =
|
|
40
|
+
}, b = () => {
|
|
41
|
+
let e = y() + 1, t = {
|
|
34
42
|
version: 1,
|
|
35
43
|
generation: e
|
|
36
44
|
};
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
45
|
+
u.setItem(v, JSON.stringify(t));
|
|
46
|
+
let n = [...d.values()];
|
|
47
|
+
d.clear();
|
|
48
|
+
for (let e of n) p(e.scope, m(e.scope));
|
|
49
|
+
return e;
|
|
50
|
+
}, x = (e) => e?.match(/^project\/([^/]+)\/mode\/[^/]+\/resource\//)?.[1], S = (e) => e?.match(/^project\/([^/]+)/)?.[1], C = (e) => {
|
|
51
|
+
if (!u.key) return [];
|
|
40
52
|
let t = `${n.namespace}:layout:`, r = [];
|
|
41
|
-
for (let n = 0; n < (
|
|
42
|
-
let i =
|
|
53
|
+
for (let n = 0; n < (u.length ?? 0); n += 1) {
|
|
54
|
+
let i = u.key(n);
|
|
43
55
|
if (!i?.startsWith(t)) continue;
|
|
44
56
|
let a = i.slice(t.length);
|
|
45
|
-
|
|
57
|
+
S(a) === e && r.push(a);
|
|
46
58
|
}
|
|
47
59
|
return r;
|
|
48
|
-
},
|
|
49
|
-
let a = i(
|
|
50
|
-
return typeof a == "object" && a && "version" in a && a.version === o && "scopes" in a && Array.isArray(a.scopes) ? a.scopes.filter((e) => typeof e == "string" &&
|
|
51
|
-
},
|
|
60
|
+
}, w = (e, r) => {
|
|
61
|
+
let a = i(u, t(n.namespace, e, r));
|
|
62
|
+
return typeof a == "object" && a && "version" in a && a.version === o && "scopes" in a && Array.isArray(a.scopes) ? a.scopes.filter((e) => typeof e == "string" && u.getItem(t(n.namespace, "layout", e)) !== null) : [];
|
|
63
|
+
}, T = (e, r, i) => {
|
|
52
64
|
let a = {
|
|
53
65
|
version: o,
|
|
54
66
|
scopes: i
|
|
55
67
|
};
|
|
56
|
-
|
|
57
|
-
},
|
|
58
|
-
let t =
|
|
68
|
+
u.setItem(t(n.namespace, e, r), JSON.stringify(a));
|
|
69
|
+
}, E = (e) => {
|
|
70
|
+
let t = S(e);
|
|
59
71
|
if (!t || !e) return;
|
|
60
|
-
let n =
|
|
61
|
-
n.push(e),
|
|
62
|
-
},
|
|
63
|
-
let r =
|
|
72
|
+
let n = w("layout-scope-index", t).filter((t) => t !== e);
|
|
73
|
+
n.push(e), T("layout-scope-index", t, n);
|
|
74
|
+
}, D = (e) => {
|
|
75
|
+
let r = x(e);
|
|
64
76
|
if (!r || !e) return;
|
|
65
|
-
let i =
|
|
77
|
+
let i = w("layout-resource-index", r).filter((t) => t !== e);
|
|
66
78
|
i.push(e);
|
|
67
|
-
for (let e of i.splice(0, Math.max(0, i.length - s)))
|
|
68
|
-
|
|
69
|
-
},
|
|
70
|
-
|
|
71
|
-
let e = [...
|
|
72
|
-
|
|
73
|
-
let r =
|
|
74
|
-
for (let i of e) i.generation === r
|
|
75
|
-
},
|
|
76
|
-
|
|
77
|
-
C();
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
f && clearTimeout(f), f = setTimeout(C, u);
|
|
79
|
+
for (let e of i.splice(0, Math.max(0, i.length - s))) u.removeItem?.(t(n.namespace, "layout", e)), u.removeItem?.(t(n.namespace, "panel-menus", e)), p(e, void 0);
|
|
80
|
+
T("layout-resource-index", r, i);
|
|
81
|
+
}, O = () => {
|
|
82
|
+
_ && clearTimeout(_), _ = void 0;
|
|
83
|
+
let e = [...d.values()];
|
|
84
|
+
d.clear();
|
|
85
|
+
let r = y();
|
|
86
|
+
for (let i of e) i.generation === r ? (u.setItem(t(n.namespace, "layout", i.scope), i.raw), E(i.scope), D(i.scope)) : p(i.scope, m(i.scope));
|
|
87
|
+
}, k = () => {
|
|
88
|
+
h === 0 ? O() : (_ && clearTimeout(_), _ = setTimeout(O, h));
|
|
81
89
|
};
|
|
82
|
-
return
|
|
90
|
+
return g?.addEventListener("pagehide", O), {
|
|
83
91
|
getLayout: (e) => {
|
|
84
|
-
let r = t(n.namespace, "layout", e), o =
|
|
92
|
+
let r = t(n.namespace, "layout", e), o = d.get(r), s = o && o.generation === y() ? JSON.parse(o.raw) : i(u, r);
|
|
85
93
|
if (s?.version === a) return s.layout;
|
|
86
94
|
},
|
|
87
95
|
setLayout: (r, i) => {
|
|
@@ -89,78 +97,80 @@ var t = (e, t, n) => `${e}:${t}:${n ?? "global"}`, n = () => {
|
|
|
89
97
|
version: a,
|
|
90
98
|
layout: e(r)
|
|
91
99
|
}, s = t(n.namespace, "layout", i);
|
|
92
|
-
|
|
93
|
-
generation:
|
|
100
|
+
d.delete(s), d.set(s, {
|
|
101
|
+
generation: y(),
|
|
94
102
|
raw: JSON.stringify(o),
|
|
95
103
|
scope: i
|
|
96
|
-
}),
|
|
104
|
+
}), p(i, o.layout), k();
|
|
105
|
+
},
|
|
106
|
+
onDidChangeLayout(e) {
|
|
107
|
+
return f.add(e), () => {
|
|
108
|
+
f.delete(e);
|
|
109
|
+
};
|
|
97
110
|
},
|
|
111
|
+
removeLayout: l(u, n.namespace, d, p),
|
|
98
112
|
listLayouts() {
|
|
99
|
-
let e = `${n.namespace}:layout:`, t = new Set(
|
|
100
|
-
for (let n = 0; n < (
|
|
101
|
-
let r =
|
|
113
|
+
let e = `${n.namespace}:layout:`, t = new Set(d.keys());
|
|
114
|
+
for (let n = 0; n < (u.length ?? 0); n++) {
|
|
115
|
+
let r = u.key?.(n);
|
|
102
116
|
r?.startsWith(e) && t.add(r);
|
|
103
117
|
}
|
|
104
118
|
return [...t].flatMap((t) => {
|
|
105
|
-
let n = t.slice(e.length), r =
|
|
106
|
-
return
|
|
107
|
-
scope:
|
|
108
|
-
layout:
|
|
119
|
+
let n = t.slice(e.length), r = n === "global" ? void 0 : n, i = this.getLayout(r);
|
|
120
|
+
return i ? [{
|
|
121
|
+
scope: r,
|
|
122
|
+
layout: i
|
|
109
123
|
}] : [];
|
|
110
124
|
});
|
|
111
125
|
},
|
|
112
|
-
flush:
|
|
126
|
+
flush: O,
|
|
113
127
|
listScopes(e) {
|
|
114
128
|
return [.../* @__PURE__ */ new Set([
|
|
115
|
-
...
|
|
116
|
-
...
|
|
117
|
-
...
|
|
129
|
+
...w("layout-scope-index", e),
|
|
130
|
+
...w("layout-resource-index", e),
|
|
131
|
+
...C(e)
|
|
118
132
|
])];
|
|
119
133
|
},
|
|
120
134
|
transformLayouts(e, r) {
|
|
121
|
-
|
|
135
|
+
O(), b();
|
|
122
136
|
for (let o of this.listScopes?.(e) ?? []) {
|
|
123
|
-
let e = t(n.namespace, "layout", o), s = i(
|
|
137
|
+
let e = t(n.namespace, "layout", o), s = i(u, e);
|
|
124
138
|
if (s?.version !== a) continue;
|
|
125
|
-
let
|
|
126
|
-
|
|
127
|
-
c.removeItem?.(e);
|
|
128
|
-
continue;
|
|
129
|
-
}
|
|
130
|
-
c.setItem(e, JSON.stringify({
|
|
139
|
+
let c = r(s.layout, o);
|
|
140
|
+
c ? (u.setItem(e, JSON.stringify({
|
|
131
141
|
version: a,
|
|
132
|
-
layout:
|
|
133
|
-
}));
|
|
142
|
+
layout: c
|
|
143
|
+
})), p(o, c)) : (u.removeItem?.(e), p(o, void 0));
|
|
134
144
|
}
|
|
135
145
|
},
|
|
136
|
-
getCompatibilityMarker: (e) => i(
|
|
146
|
+
getCompatibilityMarker: (e) => i(u, t(n.namespace, "layout-compatibility", e)),
|
|
137
147
|
setCompatibilityMarker: (e, r) => {
|
|
138
|
-
|
|
148
|
+
b(), u.setItem(t(n.namespace, "layout-compatibility", e), JSON.stringify(r));
|
|
139
149
|
},
|
|
140
|
-
advanceWriteGeneration:
|
|
150
|
+
advanceWriteGeneration: b,
|
|
141
151
|
dispose() {
|
|
142
|
-
|
|
152
|
+
O(), g?.removeEventListener("pagehide", O), f.clear();
|
|
143
153
|
}
|
|
144
154
|
};
|
|
145
|
-
},
|
|
155
|
+
}, d = 1, f = (e) => {
|
|
146
156
|
let n = r(e.storage);
|
|
147
157
|
return {
|
|
148
158
|
load: (r) => {
|
|
149
159
|
let a = i(n, t(e.namespace, "page-location", r));
|
|
150
|
-
if (a?.version ===
|
|
160
|
+
if (a?.version === d) return {
|
|
151
161
|
location: a.location,
|
|
152
162
|
...a.rootLevel ? { rootLevel: a.rootLevel } : {}
|
|
153
163
|
};
|
|
154
164
|
},
|
|
155
165
|
save: (r, i) => {
|
|
156
166
|
let a = {
|
|
157
|
-
version:
|
|
167
|
+
version: d,
|
|
158
168
|
...i
|
|
159
169
|
};
|
|
160
170
|
n.setItem(t(e.namespace, "page-location", r), JSON.stringify(a));
|
|
161
171
|
}
|
|
162
172
|
};
|
|
163
|
-
},
|
|
173
|
+
}, p = (e) => {
|
|
164
174
|
let n = r(e.storage);
|
|
165
175
|
return {
|
|
166
176
|
getMenuStates: (r) => i(n, t(e.namespace, "panel-menus", r ?? e.scope)),
|
|
@@ -169,7 +179,7 @@ var t = (e, t, n) => `${e}:${t}:${n ?? "global"}`, n = () => {
|
|
|
169
179
|
n.setItem(a, JSON.stringify(r));
|
|
170
180
|
}
|
|
171
181
|
};
|
|
172
|
-
},
|
|
182
|
+
}, m = (e) => {
|
|
173
183
|
let n = r(e.storage), a = t(e.namespace, "tree", e.scope);
|
|
174
184
|
return {
|
|
175
185
|
getTreeStates: () => i(n, a),
|
|
@@ -177,7 +187,7 @@ var t = (e, t, n) => `${e}:${t}:${n ?? "global"}`, n = () => {
|
|
|
177
187
|
n.setItem(a, JSON.stringify(e));
|
|
178
188
|
}
|
|
179
189
|
};
|
|
180
|
-
},
|
|
190
|
+
}, h = (e) => {
|
|
181
191
|
let n = r(e.storage), a = t(e.namespace, "preferences", void 0), o = {
|
|
182
192
|
getValue: (e, t) => i(n, a)?.[JSON.stringify([
|
|
183
193
|
e,
|
|
@@ -195,46 +205,47 @@ var t = (e, t, n) => `${e}:${t}:${n ?? "global"}`, n = () => {
|
|
|
195
205
|
])]: t
|
|
196
206
|
}));
|
|
197
207
|
}
|
|
198
|
-
}, s =
|
|
208
|
+
}, s = u({
|
|
199
209
|
debounceMs: e.debounceMs,
|
|
200
210
|
eventTarget: e.eventTarget,
|
|
201
211
|
namespace: e.namespace,
|
|
202
212
|
storage: n
|
|
203
|
-
}),
|
|
213
|
+
}), c = {
|
|
204
214
|
getSnapshot: (e) => {
|
|
205
215
|
let t = s.getLayout(e);
|
|
206
216
|
return t ? { layout: t } : void 0;
|
|
207
217
|
},
|
|
208
218
|
setSnapshot: (e, t) => s.setLayout(e.layout, t),
|
|
219
|
+
removeSnapshot: s.removeLayout ? (e) => s.removeLayout?.(e) : void 0,
|
|
209
220
|
listLayouts: () => s.listLayouts?.() ?? [],
|
|
221
|
+
onDidChangeLayout: s.onDidChangeLayout,
|
|
210
222
|
flush: s.flush,
|
|
211
223
|
dispose: s.dispose
|
|
212
|
-
},
|
|
224
|
+
}, l = t(e.namespace, "status-bar", void 0);
|
|
213
225
|
return {
|
|
214
226
|
preferencePersistence: o,
|
|
215
|
-
snapshotPersistence:
|
|
227
|
+
snapshotPersistence: c,
|
|
216
228
|
statusBarPersistence: {
|
|
217
|
-
getOrder: () => i(n,
|
|
218
|
-
setOrder: (e) => n.setItem(
|
|
229
|
+
getOrder: () => i(n, l),
|
|
230
|
+
setOrder: (e) => n.setItem(l, JSON.stringify(e))
|
|
219
231
|
},
|
|
220
232
|
layoutPersistence: s,
|
|
221
|
-
panelMenuStatePersistence:
|
|
233
|
+
panelMenuStatePersistence: p({
|
|
222
234
|
namespace: e.namespace,
|
|
223
235
|
scope: e.scope ?? "global",
|
|
224
236
|
storage: n
|
|
225
237
|
}),
|
|
226
|
-
pageLocationPersistence:
|
|
238
|
+
pageLocationPersistence: f({
|
|
227
239
|
namespace: e.namespace,
|
|
228
240
|
storage: n
|
|
229
241
|
}),
|
|
230
|
-
treePersistence:
|
|
242
|
+
treePersistence: m({
|
|
231
243
|
namespace: e.namespace,
|
|
232
244
|
scope: e.scope,
|
|
233
245
|
storage: n
|
|
234
246
|
})
|
|
235
247
|
};
|
|
236
248
|
};
|
|
237
|
-
|
|
238
|
-
export { c as createLocalStorageLayoutPersistence, u as createLocalStoragePageLocationPersistence, d as createLocalStoragePanelMenuStatePersistence, f as createLocalStorageTreePersistence, p as createLocalStorageWorkbenchPersistence, t as workbenchStoragePersistenceKey };
|
|
249
|
+
export { u as createLocalStorageLayoutPersistence, f as createLocalStoragePageLocationPersistence, p as createLocalStoragePanelMenuStatePersistence, m as createLocalStorageTreePersistence, h as createLocalStorageWorkbenchPersistence, t as workbenchStoragePersistenceKey };
|
|
239
250
|
|
|
240
251
|
//# 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","cacheLayoutData","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","listLayouts","keys","Set","add","flatMap","listScopes","transformLayouts","transform","getCompatibilityMarker","setCompatibilityMarker","value","advanceWriteGeneration","dispose","PersistedTreeRendererStates","PersistedWorkbenchPageLocation","PersistedWorkbenchPanelMenuState","PreferencePersistenceAdapter","PreferenceValue","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","preferenceKey","preferencePersistence","getValue","name","Record","scopeId","setValue","value","values","layoutPersistence","debounceMs","eventTarget","snapshotPersistence","getSnapshot","layout","getLayout","setSnapshot","snapshot","setLayout","listLayouts","flush","dispose","statusBarKey","statusBarPersistence","getOrder","setOrder","ids","panelMenuStatePersistence","pageLocationPersistence","treePersistence","cacheLayoutData","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","keys","transform","WORKBENCH_PAGE_LOCATION_VERSION","createLocalStoragePageLocationPersistence","stored","createLocalStoragePanelMenuStatePersistence","state","createLocalStorageTreePersistence","createLocalStorageWorkbenchPersistence","preferenceKey","preferencePersistence","name","values","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 | \"preferences\"\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 { cacheLayoutData } from \"../core/registries/layout/layout-tab-presentation\";\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 = {\n version: WORKBENCH_LAYOUT_VERSION,\n layout: cacheLayoutData(layout),\n };\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 listLayouts() {\n const prefix = `${input.namespace}:layout:`;\n const keys = new Set(pending.keys());\n for (let index = 0; index < (storage.length ?? 0); index++) {\n const key = storage.key?.(index);\n if (key?.startsWith(prefix)) keys.add(key);\n }\n return [...keys].flatMap((key) => {\n const scope = key.slice(prefix.length);\n const layout = this.getLayout(scope || undefined);\n return layout ? [{ scope, layout }] : [];\n });\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 PreferencePersistenceAdapter,\n PreferenceValue,\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 preferenceKey = workbenchStoragePersistenceKey(input.namespace, \"preferences\", undefined);\n const preferencePersistence: PreferencePersistenceAdapter = {\n getValue: (name, scope) =>\n readJson<Record<string, PreferenceValue>>(storage, preferenceKey)?.[\n JSON.stringify([name, scope.scope, scope.scopeId])\n ],\n setValue: (name, value, scope) => {\n const values = readJson<Record<string, PreferenceValue>>(storage, preferenceKey) ?? {};\n storage.setItem(\n preferenceKey,\n JSON.stringify({ ...values, [JSON.stringify([name, scope.scope, scope.scopeId])]: value }),\n );\n },\n };\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 listLayouts: () => layoutPersistence.listLayouts?.() ?? [],\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 preferencePersistence,\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":";;AA8BA,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,GChDMe,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,oB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AY;GACxDG,WAAWC,MAAQhD,EAAQU,QAAQkC,GAAcjC,KAAKC,UAAUoC,CAAG,CAAC;EAMpEH;EACAd;EACAkB,2BAA2BpC,EAA4C;GACrET,WAAWL,EAAMK;GACjBb,OAAOQ,EAAMR,SAAS;GACtBS;EACF,CAAC;EACDkD,yBAAyBpD,EAA0C;GAAEM,WAAWL,EAAMK;GAAWJ;EAAQ,CAAC;EAC1GmD,iBAAiBjC,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","cacheLayoutData","CreateWorkbenchStoragePersistenceInput","readJson","resolveStorage","WorkbenchStorageLike","workbenchStoragePersistenceKey","PersistedWorkbenchLayoutV5","version","layout","PersistedWorkbenchLayout","WORKBENCH_LAYOUT_VERSION","const","WORKBENCH_LAYOUT_INDEX_VERSION","WORKBENCH_LAYOUT_RESOURCE_LIMIT","PersistedWorkbenchLayoutScopeIndex","scopes","PersistedWorkbenchLayoutGeneration","generation","readSavedLayout","storage","namespace","scope","saved","undefined","createLayoutRemoval","pending","delete","key","notify","removeItem","existed","getItem","createLocalStorageLayoutPersistence","input","Map","raw","listeners","Set","listener","savedLayout","debounceMs","eventTarget","window","addEventListener","type","removeEventListener","timer","ReturnType","setTimeout","generationKey","getGeneration","persisted","advanceGeneration","setItem","JSON","stringify","cancelled","values","clear","write","resourceProjectId","match","scopeProjectId","storedProjectScopes","projectId","prefix","index","length","startsWith","slice","push","readScopes","kind","Array","isArray","filter","writeScopes","next","touchProjectScope","candidate","touchResourceScope","evictedScope","splice","Math","max","flush","clearTimeout","writes","scheduleFlush","getLayout","pendingWrite","get","parse","setLayout","set","onDidChangeLayout","add","removeLayout","listLayouts","keys","flatMap","suffix","listScopes","transformLayouts","transform","getCompatibilityMarker","setCompatibilityMarker","value","advanceWriteGeneration","dispose","PersistedTreeRendererStates","PersistedWorkbenchPageLocation","PersistedWorkbenchPanelMenuState","PreferencePersistenceAdapter","PreferenceValue","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","preferenceKey","preferencePersistence","getValue","name","Record","scopeId","setValue","value","values","layoutPersistence","debounceMs","eventTarget","snapshotPersistence","getSnapshot","layout","getLayout","setSnapshot","snapshot","setLayout","removeSnapshot","removeLayout","listLayouts","onDidChangeLayout","flush","dispose","statusBarKey","statusBarPersistence","getOrder","setOrder","ids","panelMenuStatePersistence","pageLocationPersistence","treePersistence","cacheLayoutData","workbenchStoragePersistenceKey","namespace","kind","scope","createMemoryStorage","map","key","index","value","resolveStorage","storage","readJson","raw","WORKBENCH_LAYOUT_VERSION","WORKBENCH_LAYOUT_INDEX_VERSION","WORKBENCH_LAYOUT_RESOURCE_LIMIT","readSavedLayout","saved","createLayoutRemoval","existed","pending","notify","createLocalStorageLayoutPersistence","input","listeners","listener","layout","savedLayout","debounceMs","eventTarget","type","timer","generationKey","getGeneration","persisted","advanceGeneration","generation","cancelled","write","resourceProjectId","scopeProjectId","storedProjectScopes","prefix","scopes","projectId","readScopes","writeScopes","next","touchProjectScope","candidate","touchResourceScope","evictedScope","flush","writes","scheduleFlush","pendingWrite","keys","suffix","transform","WORKBENCH_PAGE_LOCATION_VERSION","createLocalStoragePageLocationPersistence","stored","createLocalStoragePanelMenuStatePersistence","state","createLocalStorageTreePersistence","createLocalStorageWorkbenchPersistence","preferenceKey","preferencePersistence","name","values","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 | \"preferences\"\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 { cacheLayoutData } from \"../core/registries/layout/layout-tab-presentation\";\nimport {\n type CreateWorkbenchStoragePersistenceInput,\n readJson,\n resolveStorage,\n type WorkbenchStorageLike,\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\nconst readSavedLayout = (storage: WorkbenchStorageLike, namespace: string, scope: string | undefined) => {\n const saved = readJson<PersistedWorkbenchLayout>(storage, workbenchStoragePersistenceKey(namespace, \"layout\", scope));\n return saved?.version === WORKBENCH_LAYOUT_VERSION ? saved.layout : undefined;\n};\n\nconst createLayoutRemoval = (\n storage: WorkbenchStorageLike,\n namespace: string,\n pending: { delete(key: string): boolean },\n notify: (scope: string | undefined, layout: WorkbenchLayout | undefined) => void,\n) =>\n storage.removeItem\n ? (scope?: string) => {\n const key = workbenchStoragePersistenceKey(namespace, \"layout\", scope);\n const existed = pending.delete(key) || storage.getItem(key) !== null;\n storage.removeItem?.(key);\n if (existed) notify(scope, undefined);\n }\n : undefined;\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 listeners = new Set<(scope: string | undefined, layout: WorkbenchLayout | undefined) => void>();\n const notify = (scope: string | undefined, layout: WorkbenchLayout | undefined) => {\n for (const listener of listeners) listener(scope, layout);\n };\n const savedLayout = (scope: string | undefined) => readSavedLayout(storage, input.namespace, scope);\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 const cancelled = [...pending.values()];\n pending.clear();\n for (const write of cancelled) notify(write.scope, savedLayout(write.scope));\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 notify(evictedScope, undefined);\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) {\n notify(write.scope, savedLayout(write.scope));\n continue;\n }\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 = {\n version: WORKBENCH_LAYOUT_VERSION,\n layout: cacheLayoutData(layout),\n };\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 notify(scope, persisted.layout);\n scheduleFlush();\n },\n onDidChangeLayout(listener) {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n },\n removeLayout: createLayoutRemoval(storage, input.namespace, pending, notify),\n listLayouts() {\n const prefix = `${input.namespace}:layout:`;\n const keys = new Set(pending.keys());\n for (let index = 0; index < (storage.length ?? 0); index++) {\n const key = storage.key?.(index);\n if (key?.startsWith(prefix)) keys.add(key);\n }\n return [...keys].flatMap((key) => {\n const suffix = key.slice(prefix.length);\n const scope = suffix === \"global\" ? undefined : suffix;\n const layout = this.getLayout(scope);\n return layout ? [{ scope, layout }] : [];\n });\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 notify(scope, undefined);\n continue;\n }\n storage.setItem(\n key,\n JSON.stringify({ version: WORKBENCH_LAYOUT_VERSION, layout } satisfies PersistedWorkbenchLayoutV5),\n );\n notify(scope, layout);\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 listeners.clear();\n },\n };\n};\n","import type {\n PersistedTreeRendererStates,\n PersistedWorkbenchPageLocation,\n PersistedWorkbenchPanelMenuState,\n PreferencePersistenceAdapter,\n PreferenceValue,\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 preferenceKey = workbenchStoragePersistenceKey(input.namespace, \"preferences\", undefined);\n const preferencePersistence: PreferencePersistenceAdapter = {\n getValue: (name, scope) =>\n readJson<Record<string, PreferenceValue>>(storage, preferenceKey)?.[\n JSON.stringify([name, scope.scope, scope.scopeId])\n ],\n setValue: (name, value, scope) => {\n const values = readJson<Record<string, PreferenceValue>>(storage, preferenceKey) ?? {};\n storage.setItem(\n preferenceKey,\n JSON.stringify({ ...values, [JSON.stringify([name, scope.scope, scope.scopeId])]: value }),\n );\n },\n };\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 removeSnapshot: layoutPersistence.removeLayout ? (scope) => layoutPersistence.removeLayout?.(scope) : undefined,\n listLayouts: () => layoutPersistence.listLayouts?.() ?? [],\n onDidChangeLayout: layoutPersistence.onDidChangeLayout,\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 preferencePersistence,\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":";;AA8BA,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/CMgB,IAA2B,GAC3BE,IAAiC,GACjCC,IAAkC,IAYlCK,KAAmBC,GAA+BC,GAAmBC,MAA8B;CACvG,IAAMC,IAAQpB,EAAmCiB,GAASd,EAA+Be,GAAW,UAAUC,CAAK,CAAC;CACpH,OAAOC,GAAOf,YAA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b,EAAkBa;EACrCC,OAAOd,EAAkBc;EACzBC,SAASf,EAAkBe;CAC7B,GACMC,IAAe5D,EAA+BY,EAAMK,WAAW,cAAcC,KAAAA,CAAS;CAM5F,OAAO;EACLkB;EACAW;EACAc,sBAAAA;GAPAC,gBAAgBhE,EAAmBe,GAAS+C,CAAY;GACxDG,WAAWC,MAAQnD,EAAQU,QAAQqC,GAAcpC,KAAKC,UAAUuC,CAAG,CAAC;EAMpEH;EACAjB;EACAqB,2BAA2BvC,EAA4C;GACrET,WAAWL,EAAMK;GACjBb,OAAOQ,EAAMR,SAAS;GACtBS;EACF,CAAC;EACDqD,yBAAyBvD,EAA0C;GAAEM,WAAWL,EAAMK;GAAWJ;EAAQ,CAAC;EAC1GsD,iBAAiBpC,EAAkC;GAAEd,WAAWL,EAAMK;GAAWb,OAAOQ,EAAMR;GAAOS;EAAQ,CAAC;CAChH;AACF"}
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
//#region ../pstdio-extensions/src/bridge/webview-runtime/runtime-html.d.ts
|
|
2
1
|
export declare const renderExtensionRuntimeHtml: (scriptUrl: string) => string;
|
|
3
2
|
export declare const renderInlineExtensionRuntimeHtml: (runtimeScript: string) => string;
|
|
4
|
-
//#endregion
|
|
5
|
-
//#region src/webview-runtime/index.d.ts
|
|
6
3
|
export declare const getExtensionRuntimeScript: () => any;
|
|
7
|
-
//#endregion
|
|
8
4
|
export {};
|
package/dist/webview-runtime.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// ../pstdio-extensions/src/bridge/webview-runtime/runtime.bundle.js?raw
|
|
2
2
|
var e = "pstdio-extension-mount", t = (e) => e.replaceAll("&", "&").replaceAll("\"", """).replaceAll("<", "<"), n = (e) => e.replaceAll("<\/script", "<\\/script").replaceAll("<!--", "<\\!--"), r = (t) => `<!doctype html>
|
|
3
3
|
<html lang="en">
|
|
4
4
|
<head>
|
|
@@ -27,8 +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 oe(){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??{},n=t.release?.name;if(r.bun||n===\"bun\"||e.Bun!==void 0)return\"bun\";if(r.node&&n===\"node\")return\"node\"}return e.Bun===void 0?\"browser\":\"bun\"}function O(){return oe()}function V(){return O()===\"worker\"}function B(){let e=O();return e===\"node\"||e===\"bun\"}function ae(){return window.self!==window.top}function ie(e){let t={};return function r(n,c=\"\"){Object.keys(n).forEach((o)=>{let s=c?`${c}.${o}`:o;n[o]===Object(n[o])&&r(n[o],s),typeof n[o]==\"function\"&&(t[s]=n[o],delete n[o])})}(e),t}function ce(e){return!e||e===\"null\"?\"*\":e}function de(e,t,r){if(!e||typeof e!=\"object\")return e;let n=Array.isArray(t)?t:t.split(\".\").map((o)=>o.match(/^\\d+$/)?Number(o):o),c=e;for(let o=0;o<n.length;o++){let s=n[o];o===n.length-1?c[s]=r:((!c[s]||typeof c[s]!=\"object\")&&(c[s]=typeof n[o+1]==\"number\"?[]:{}),c=c[s])}return e}function le(e=10){let t=\"\";for(let r=0;r<e;r++)t+=\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789\".charAt(Math.floor(Math.random()*62));return t}var U=O(),C=null;if(U===\"node\"||U===\"bun\")try{let e=globalThis.require;C=e?.(\"node:worker_threads\")?.parentPort??null}catch{}function fe(){if(B())return C;if(V())return self;if(ae())return window.parent;throw Error(\"No valid target found for postMessage\")}function x(e,t,r,n){if(!e)throw Error(\"Rimless Error: No target specified for postMessage\");if(B()&&e===C){e.postMessage(t,{transfer:n});return}if(V()){e.postMessage(t,{transfer:n});return}if(e.postMessage){e.postMessage(t,{targetOrigin:ce(r),transfer:n});return}throw Error(\"Rimless Error: Invalid target for postMessage\")}function z(e){return C!==null&&e===C}function j(e,t,r){z(e)?e.on(t,r):(\"addEventListener\"in e)&&e.addEventListener(t,r)}function _(e,t,r){z(e)?e.off(t,r):(\"removeEventListener\"in e)&&e.removeEventListener(t,r)}function W(e){return e.data||e}var I=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}({}),b=Symbol();function ue(e={},t,r,n,c){let o=[];for(let[s,a]of Object.entries(e)){async function i(p){let{action:m,callID:g,connectionID:E,callName:y,args:w=[]}=W(p);if(m!==h.RPC_REQUEST||!g||!y||y!==s||E!==t)return;let u={action:h.RPC_RESOLVE,callID:g,callName:y,connectionID:E,error:null,result:null},R;try{u.result=await a(...w,c),u.result?.[b]&&(R=u.result[b]??[],delete u.result[b])}catch(k){u.action=h.RPC_REJECT,u.error=JSON.parse(JSON.stringify(k,Object.getOwnPropertyNames(k)))}x(n,u,p?.origin,R)}j(r,I.MESSAGE,i),o.push(()=>_(r,I.MESSAGE,i))}return()=>o.forEach((s)=>s())}function pe(e,t,r,n=new Set,c,o){return(...s)=>new Promise((a,i)=>{let p=le();function m(){_(c,I.MESSAGE,g),n.delete(m)}function g(w){let{callID:u,connectionID:R,callName:k,result:ne,error:se,action:D}=W(w);if(!(!u||!k)&&k===e&&u===p&&R===t){if(D===h.RPC_RESOLVE)return m(),a(ne);if(D===h.RPC_REJECT)return m(),i(se)}}let E={action:h.RPC_REQUEST,args:s,callID:p,callName:e,connectionID:t},y=s.reduce((w,u)=>u[b]?.length?w.concat(u[b]):w,s[b]??[]);j(c,I.MESSAGE,g),n.add(m),x(o,E,r?.origin,y)})}function me(e={},t=[],r,n,c,o){let s={...e},a=new Set;for(let i of t)de(s,i,pe(i,r,n,a,c,o));return{remote:s,unregisterRemote:()=>a.forEach((i)=>i())}}function ge(e={},t){return new Promise(async(r)=>{let n=ie(e),c=fe(),o=self||window;async function s(a){let i=W(a);if(i?.action!==h.HANDSHAKE_REPLY)return;let{remote:p,unregisterRemote:m}=me(i.schema,i.methodNames,i.connectionID,a,o,c),g=ue(n,i.connectionID,o,c,p);return await t?.onConnectionSetup?.(p),x(c,{action:h.HANDSHAKE_REPLY,connectionID:i.connectionID},a?.origin),r({remote:p,close:()=>{_(o,I.MESSAGE,s),m(),g()},id:i.connectionID})}j(o,I.MESSAGE,s),x(c,{action:h.HANDSHAKE_REQUEST,methodNames:Object.keys(n),schema:e})})}var G={connect:ge};var q=(e={})=>{let t=e.locale??\"en\";return{...e,projectId:e.projectId,themePreference:e.themePreference??\"system\",locale:t,resource:e.resource,pageLocation:e.pageLocation,pageParams:e.pageParams??{},translations:e.translations??{locale:t,defaultLocale:t,bundle:{},defaultBundle:{}}}};var ye=(e)=>typeof e===\"object\"&&e!==null,F=(e)=>{try{let t=JSON.stringify(e);if(typeof t===\"string\"&&t.length>0)return t}catch{}try{return String(e)}catch{return\"Unknown error\"}},T=(e)=>{if(e instanceof Error)return{message:e.message,stack:e.stack};if(typeof e===\"string\")return{message:e};if(ye(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:F(e)}}if(e===null||e===void 0)return{message:\"Unknown error\"};return{message:F(e)}};var M=[\"sidenav\",\"main\",\"secondary\",\"side\"];var f=(e,t)=>({extensionId:\"pstdio\",kind:e,id:t}),v={project:f(\"mode\",\"project\"),sessions:f(\"mode\",\"sessions\"),settings:f(\"mode\",\"settings\")},Le={project:{ref:v.project,regions:M},sessions:{ref:v.sessions,regions:M},settings:{ref:v.settings,regions:M}},N=(e,t,r)=>({id:e,ref:f(\"resource-kind\",e),label:t,menuSlots:r}),H=[{id:\"headerPrimary\",placement:\"header-primary\",access:\"public\"},{id:\"headerOverflow\",placement:\"header-overflow\",access:\"public\"}],K={project:N(\"project\",\"Extension\",H),session:N(\"session\",\"Session\",H),workspace:N(\"workspace\",\"Workspace\",H)},S={project:K.project.ref,session:K.session.ref,workspace:K.workspace.ref},A={start:f(\"page\",\"start\"),sessions:f(\"page\",\"sessions\"),session:f(\"page\",\"session\"),workspaces:f(\"page\",\"workspaces\"),workspace:f(\"page\",\"workspace\")},Oe={start:{ref:A.start,mode:v.project,path:\"\",primary:{cardinality:\"one\",resourceKinds:[]}},sessions:{ref:A.sessions,mode:v.sessions,path:\"sessions\",primary:{cardinality:\"one\",resourceKinds:[]}},session:{ref:A.session,mode:v.sessions,path:\"session\",primary:{cardinality:\"one\",resourceKinds:[\"session\",\"session-draft\"]}},workspaces:{ref:A.workspaces,mode:v.project,path:\"workspaces\",primary:{cardinality:\"one\",resourceKinds:[]}},workspace:{ref:A.workspace,mode:v.project,path:\"workspace\",primary:{cardinality:\"many\",resourceKinds:[\"workspace\"]}}},he={projectSession:f(\"placement\",\"project-session\")},je={projectSession:{ref:he.projectSession,mode:v.project,cardinality:\"many\",resourceKinds:[\"session\",\"session-draft\"]}},_e={projectSettings:f(\"settings-panel\",\"project.settings\"),extensionSettings:f(\"settings-panel\",\"extension.settings\"),statusBarLeading:f(\"status-bar-item\",\"status-bar.leading\"),statusBarTrailing:f(\"status-bar-item\",\"status-bar.trailing\")};var J=(e)=>({...e,kind:\"command\"}),We=Object.assign(J,{forExtension:(e)=>(t)=>J({extensionId:`${e.publisher}.${e.name}`,id:t})}),ve=(e)=>({...e,kind:\"event\"}),L=(e,t)=>({id:e,kind:t.kind,label:t.label,description:t.description,metadata:t.metadata}),l=(e)=>ve({extensionId:\"pstdio\",id:e}),P=(e,t)=>L(`${e.id}.${t}`,{kind:\"menu\"}),Me={sidenav:L(\"project.sidenav\",{kind:\"panel\"}),headerPrimary:P(S.project,\"headerPrimary\"),headerOverflow:P(S.project,\"headerOverflow\"),settingsPanels:L(\"project.settings\",{kind:\"settings\"})},Ne={headerPrimary:P(S.session,\"headerPrimary\"),headerOverflow:P(S.session,\"headerOverflow\")},He={headerPrimary:P(S.workspace,\"headerPrimary\"),headerOverflow:P(S.workspace,\"headerOverflow\"),sidenav:L(\"workspace.sidenav\",{kind:\"panel\"})},$e={opened:l(\"project.opened\")},Ke={boardViewsChanged:l(\"view.board-views.changed\"),resourceAnchorsChanged:l(\"view.resource-anchors.changed\"),sessionsChanged:l(\"view.sessions.changed\"),workspacesChanged:l(\"view.workspaces.changed\"),repositoriesChanged:l(\"view.repositories.changed\")},De={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={renumbered:l(\"resource.renumbered\")},Ve={created:l(\"workspace.created\"),provision:l(\"workspace.provision\"),ready:l(\"workspace.ready\"),deleted:l(\"workspace.deleted\")},Be={removed:l(\"worktree.removed\")},ze={committed:l(\"git.committed\"),rebased:l(\"git.rebased\"),merged:l(\"git.merged\"),conflicted:l(\"git.conflicted\")};var Ee=[\"clipboard.write\",\"commands.execute\",\"commands.stream\",\"harnesses.read\",\"resources.actions\",\"navigation.open\",\"page.params.update\",\"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\"],we=[\"artifacts.read\"];var Ge=[...Ee.filter((e)=>e!==\"clipboard.write\"),...we];var d=(e)=>(t)=>({...t,ref:{kind:e,id:t.id}}),qe=d(\"view\"),Fe=d(\"view-menu\"),Je=d(\"placement\"),Ye=d(\"resource-kind\");var Qe=d(\"navigation-item\"),Xe=d(\"navigation-tree\"),Ze=d(\"mode\");var et=d(\"status-bar-item\"),tt=d(\"settings-panel\"),rt=d(\"activity-item\"),nt=d(\"settings-section\"),st=d(\"command-palette-resource\"),ot=d(\"keybinding\"),at=d(\"schedule\"),it=d(\"artifact-mount\"),ct=d(\"template-type\"),dt=d(\"template\"),lt=d(\"skill\"),ft=d(\"theme\"),ut=d(\"file-icon-theme\"),pt=d(\"workspace-type\"),mt=d(\"harness\"),gt=d(\"connection\");var Y=(e,t,r,n)=>({call:async(c,...o)=>{try{let s=await e({method:c,params:o[0]});if(!s.ok)throw Object.assign(Error(s.error.message),s.error);return s.value}catch(s){if(s instanceof Error)throw s;throw Error(T(s).message)}},onEvent:t,extensionId:r,propsStore:n}),Q=(e)=>{let t=e,r=new Set;return{get:()=>t,subscribe:(n)=>(r.add(n),()=>r.delete(n)),set:(n)=>{t=n;for(let c of r)c(t)}}};var X=(e,t)=>{e.addEventListener(\"keydown\",(r)=>{let n=r;if(n.key!==\"Escape\")return;setTimeout(()=>{if(n.defaultPrevented)return;t({key:n.key,code:n.code,ctrlKey:n.ctrlKey,metaKey:n.metaKey,altKey:n.altKey,shiftKey:n.shiftKey,repeat:n.repeat}).catch(()=>{})},0)})};var Z=(e,t)=>{e.style.width=\"max-content\";let r=-1,n=new ResizeObserver(()=>{let c=Math.ceil(e.getBoundingClientRect().width);if(c===r)return;r=c,t(c)});return n.observe(e),()=>n.disconnect()};var ee=(e)=>{let t,r,n=!1;return{initialize:(c)=>{if(n)return Promise.resolve();return t??=e(c).then((o)=>{if(typeof o!==\"function\")return;if(n)o();else r=o}),t},dispose:()=>{n=!0,r?.(),r=void 0}}};var te=\"pstdio-extension-mount\",be=()=>{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)}},Ie=()=>{for(let e of[\"localStorage\",\"sessionStorage\"])try{window[e]}catch{Object.defineProperty(window,e,{configurable:!0,value:be()})}},re=(e,t)=>{let r=document.documentElement,n=e===\"dark\"?\"light\":\"dark\";r.classList.remove(n),r.classList.add(e),r.setAttribute(\"data-theme\",e),r.style.colorScheme=e;for(let[c,o]of Object.entries(t))if(c.startsWith(\"--\"))r.style.setProperty(c,o)},Se=(e)=>{for(let t of e){let r=document.createElement(\"link\");r.rel=\"stylesheet\",r.href=t,document.head.appendChild(r)}},Pe=()=>{let e=document.getElementById(te);if(!e)e=document.createElement(\"div\"),e.id=te,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})},Ce=(e)=>e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement||e instanceof HTMLElement&&e.isContentEditable,Ae=async()=>{Ie(),ke();let e=Q(q()),t=new Map,r=(s,a)=>{let i=t.get(s)??new Set;return i.add(a),t.set(s,i),()=>{i.delete(a)}},n=ee(async(s)=>{Se(s.styles);let a=await import(s.moduleUrl),i=a.default??(a.mount?a:void 0);if(!i?.mount)throw Error(\"Extension module does not export a default view (defineExtensionView).\");let p=Y((y)=>o.remote.call(y),r,s.extensionId,e),m=Pe(),g=s.sizing===\"content-width\"?Z(m,(y)=>o.remote.contentWidthChanged(y)):void 0,E=await i.mount(m,p,e);return()=>{g?.(),E?.()}}),c=!1,o=await G.connect({init:async(s)=>{try{if(re(s.theme,s.themeVariables),e.set(s.props),await n.initialize(s),!c){c=!0,X(document,(a)=>o.remote.dispatchKeyboardEvent(a)),document.addEventListener(\"keydown\",(a)=>{if(a.key===\"Escape\")return;if(!a.ctrlKey&&!a.metaKey&&!a.altKey)return;if(Ce(a.target)&&!a.shiftKey)return;o.remote.dispatchKeyboardEvent({key:a.key,code:a.code,ctrlKey:a.ctrlKey,metaKey:a.metaKey,altKey:a.altKey,shiftKey:a.shiftKey,repeat:a.repeat}).catch(()=>{})},!0);for(let a of[\"pointerdown\",\"click\"])document.addEventListener(a,(i)=>{o.remote.dispatchPointerEvent({type:a,clientX:i.clientX,clientY:i.clientY,button:i.button,buttons:i.buttons,pointerId:i.pointerId,pointerType:i.pointerType,isPrimary:i.isPrimary,ctrlKey:i.ctrlKey,metaKey:i.metaKey,altKey:i.altKey,shiftKey:i.shiftKey})},!0)}}catch(a){let i=T(a);throw o.remote.runtimeError(i),a instanceof Error?a:Error(i.message)}},themeUpdate:(s)=>{re(s.theme,s.variables)},propsUpdate:(s)=>{e.set(s.props)},hostEvent:(s)=>{for(let a of t.get(s.scope)??[])a(s.payload)}});o.remote.ready({}),window.addEventListener(\"beforeunload\",()=>{n.dispose()})};Ae();\n";
|
|
31
|
-
//#endregion
|
|
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 oe(){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??{},n=t.release?.name;if(r.bun||n===\"bun\"||e.Bun!==void 0)return\"bun\";if(r.node&&n===\"node\")return\"node\"}return e.Bun===void 0?\"browser\":\"bun\"}function O(){return oe()}function V(){return O()===\"worker\"}function B(){let e=O();return e===\"node\"||e===\"bun\"}function ae(){return window.self!==window.top}function ie(e){let t={};return function r(n,c=\"\"){Object.keys(n).forEach((o)=>{let s=c?`${c}.${o}`:o;n[o]===Object(n[o])&&r(n[o],s),typeof n[o]==\"function\"&&(t[s]=n[o],delete n[o])})}(e),t}function ce(e){return!e||e===\"null\"?\"*\":e}function de(e,t,r){if(!e||typeof e!=\"object\")return e;let n=Array.isArray(t)?t:t.split(\".\").map((o)=>o.match(/^\\d+$/)?Number(o):o),c=e;for(let o=0;o<n.length;o++){let s=n[o];o===n.length-1?c[s]=r:((!c[s]||typeof c[s]!=\"object\")&&(c[s]=typeof n[o+1]==\"number\"?[]:{}),c=c[s])}return e}function le(e=10){let t=\"\";for(let r=0;r<e;r++)t+=\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789\".charAt(Math.floor(Math.random()*62));return t}var U=O(),C=null;if(U===\"node\"||U===\"bun\")try{let e=globalThis.require;C=e?.(\"node:worker_threads\")?.parentPort??null}catch{}function fe(){if(B())return C;if(V())return self;if(ae())return window.parent;throw Error(\"No valid target found for postMessage\")}function R(e,t,r,n){if(!e)throw Error(\"Rimless Error: No target specified for postMessage\");if(B()&&e===C){e.postMessage(t,{transfer:n});return}if(V()){e.postMessage(t,{transfer:n});return}if(e.postMessage){e.postMessage(t,{targetOrigin:ce(r),transfer:n});return}throw Error(\"Rimless Error: Invalid target for postMessage\")}function z(e){return C!==null&&e===C}function L(e,t,r){z(e)?e.on(t,r):(\"addEventListener\"in e)&&e.addEventListener(t,r)}function _(e,t,r){z(e)?e.off(t,r):(\"removeEventListener\"in e)&&e.removeEventListener(t,r)}function W(e){return e.data||e}var S=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}({}),b=Symbol();function ue(e={},t,r,n,c){let o=[];for(let[s,a]of Object.entries(e)){async function i(p){let{action:m,callID:g,connectionID:w,callName:y,args:E=[]}=W(p);if(m!==h.RPC_REQUEST||!g||!y||y!==s||w!==t)return;let u={action:h.RPC_RESOLVE,callID:g,callName:y,connectionID:w,error:null,result:null},x;try{u.result=await a(...E,c),u.result?.[b]&&(x=u.result[b]??[],delete u.result[b])}catch(k){u.action=h.RPC_REJECT,u.error=JSON.parse(JSON.stringify(k,Object.getOwnPropertyNames(k)))}R(n,u,p?.origin,x)}L(r,S.MESSAGE,i),o.push(()=>_(r,S.MESSAGE,i))}return()=>o.forEach((s)=>s())}function pe(e,t,r,n=new Set,c,o){return(...s)=>new Promise((a,i)=>{let p=le();function m(){_(c,S.MESSAGE,g),n.delete(m)}function g(E){let{callID:u,connectionID:x,callName:k,result:ne,error:se,action:K}=W(E);if(!(!u||!k)&&k===e&&u===p&&x===t){if(K===h.RPC_RESOLVE)return m(),a(ne);if(K===h.RPC_REJECT)return m(),i(se)}}let w={action:h.RPC_REQUEST,args:s,callID:p,callName:e,connectionID:t},y=s.reduce((E,u)=>u[b]?.length?E.concat(u[b]):E,s[b]??[]);L(c,S.MESSAGE,g),n.add(m),R(o,w,r?.origin,y)})}function me(e={},t=[],r,n,c,o){let s={...e},a=new Set;for(let i of t)de(s,i,pe(i,r,n,a,c,o));return{remote:s,unregisterRemote:()=>a.forEach((i)=>i())}}function ge(e={},t){return new Promise(async(r)=>{let n=ie(e),c=fe(),o=self||window;async function s(a){let i=W(a);if(i?.action!==h.HANDSHAKE_REPLY)return;let{remote:p,unregisterRemote:m}=me(i.schema,i.methodNames,i.connectionID,a,o,c),g=ue(n,i.connectionID,o,c,p);return await t?.onConnectionSetup?.(p),R(c,{action:h.HANDSHAKE_REPLY,connectionID:i.connectionID},a?.origin),r({remote:p,close:()=>{_(o,S.MESSAGE,s),m(),g()},id:i.connectionID})}L(o,S.MESSAGE,s),R(c,{action:h.HANDSHAKE_REQUEST,methodNames:Object.keys(n),schema:e})})}var G={connect:ge};var q=(e={})=>{let t=e.locale??\"en\";return{...e,projectId:e.projectId,themePreference:e.themePreference??\"system\",locale:t,resource:e.resource,pageLocation:e.pageLocation,pageParams:e.pageParams??{},translations:e.translations??{locale:t,defaultLocale:t,bundle:{},defaultBundle:{}}}};var ye=(e)=>typeof e===\"object\"&&e!==null,J=(e)=>{try{let t=JSON.stringify(e);if(typeof t===\"string\"&&t.length>0)return t}catch{}try{return String(e)}catch{return\"Unknown error\"}},T=(e)=>{if(e instanceof Error)return{message:e.message,stack:e.stack};if(typeof e===\"string\")return{message:e};if(ye(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:J(e)}}if(e===null||e===void 0)return{message:\"Unknown error\"};return{message:J(e)}};var M=[\"sidenav\",\"main\",\"secondary\",\"side\"];var f=(e,t)=>({extensionId:\"pstdio\",kind:e,id:t}),v={project:f(\"mode\",\"project\"),sessions:f(\"mode\",\"sessions\"),settings:f(\"mode\",\"settings\")},je={project:{ref:v.project,regions:M},sessions:{ref:v.sessions,regions:M},settings:{ref:v.settings,regions:M}},N=(e,t,r)=>({id:e,ref:f(\"resource-kind\",e),label:t,menuSlots:r}),H=[{id:\"headerPrimary\",placement:\"header-primary\",access:\"public\"},{id:\"headerOverflow\",placement:\"header-overflow\",access:\"public\"}],D={project:N(\"project\",\"Extension\",H),session:N(\"session\",\"Session\",H),workspace:N(\"workspace\",\"Workspace\",H)},I={project:D.project.ref,session:D.session.ref,workspace:D.workspace.ref},A={start:f(\"page\",\"start\"),sessions:f(\"page\",\"sessions\"),session:f(\"page\",\"session\"),workspaces:f(\"page\",\"workspaces\"),workspace:f(\"page\",\"workspace\")},Oe={start:{ref:A.start,mode:v.project,path:\"\",primary:{cardinality:\"one\",resourceKinds:[]}},sessions:{ref:A.sessions,mode:v.sessions,path:\"sessions\",primary:{cardinality:\"one\",resourceKinds:[]}},session:{ref:A.session,mode:v.sessions,path:\"session\",primary:{cardinality:\"one\",resourceKinds:[\"session\",\"session-draft\"]}},workspaces:{ref:A.workspaces,mode:v.project,path:\"workspaces\",primary:{cardinality:\"one\",resourceKinds:[]}},workspace:{ref:A.workspace,mode:v.project,path:\"workspace\",primary:{cardinality:\"many\",resourceKinds:[\"workspace\"]}}},he={projectSession:f(\"placement\",\"project-session\")},Le={projectSession:{ref:he.projectSession,mode:v.project,cardinality:\"many\",resourceKinds:[\"session\",\"session-draft\"]}},_e={projectSettings:f(\"settings-panel\",\"project.settings\"),extensionSettings:f(\"settings-panel\",\"extension.settings\"),statusBarLeading:f(\"status-bar-item\",\"status-bar.leading\"),statusBarTrailing:f(\"status-bar-item\",\"status-bar.trailing\")};var F=(e)=>({...e,kind:\"command\"}),We=Object.assign(F,{forExtension:(e)=>(t)=>F({extensionId:`${e.publisher}.${e.name}`,id:t})}),ve=(e)=>({...e,kind:\"event\"}),j=(e,t)=>({id:e,kind:t.kind,label:t.label,description:t.description,metadata:t.metadata}),d=(e)=>ve({extensionId:\"pstdio\",id:e}),P=(e,t)=>j(`${e.id}.${t}`,{kind:\"menu\"}),Me={sidenav:j(\"project.sidenav\",{kind:\"panel\"}),headerPrimary:P(I.project,\"headerPrimary\"),headerOverflow:P(I.project,\"headerOverflow\"),settingsPanels:j(\"project.settings\",{kind:\"settings\"})},Ne={headerPrimary:P(I.session,\"headerPrimary\"),headerOverflow:P(I.session,\"headerOverflow\")},He={headerPrimary:P(I.workspace,\"headerPrimary\"),headerOverflow:P(I.workspace,\"headerOverflow\"),sidenav:j(\"workspace.sidenav\",{kind:\"panel\"})},De={opened:d(\"project.opened\")},$e={projectSyncChanged:d(\"account.project-sync.changed\")},Ke={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\")},Ve={renumbered:d(\"resource.renumbered\")},Be={created:d(\"workspace.created\"),provision:d(\"workspace.provision\"),ready:d(\"workspace.ready\"),deleted:d(\"workspace.deleted\")},ze={removed:d(\"worktree.removed\")},Ge={committed:d(\"git.committed\"),rebased:d(\"git.rebased\"),merged:d(\"git.merged\"),conflicted:d(\"git.conflicted\")};var we=[\"clipboard.write\",\"commands.execute\",\"commands.stream\",\"editing.session\",\"harnesses.read\",\"resources.actions\",\"navigation.open\",\"page.params.update\",\"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\",\"account.read\",\"account.manage\"],Ee=[\"artifacts.read\"];var qe=[...we.filter((e)=>e!==\"clipboard.write\"),...Ee];var l=(e)=>(t)=>({...t,ref:{kind:e,id:t.id}}),Je=l(\"view\"),Fe=l(\"view-menu\"),Ye=l(\"placement\"),Qe=l(\"resource-kind\");var Xe=l(\"navigation-item\"),Ze=l(\"navigation-tree\"),et=l(\"mode\");var tt=l(\"status-bar-item\"),rt=l(\"settings-panel\"),nt=l(\"activity-item\"),st=l(\"settings-section\"),ot=l(\"command-palette-resource\"),at=l(\"keybinding\"),it=l(\"schedule\"),ct=l(\"artifact-mount\"),dt=l(\"template-type\"),lt=l(\"template\"),ft=l(\"skill\"),ut=l(\"theme\"),pt=l(\"file-icon-theme\"),mt=l(\"workspace-type\"),gt=l(\"harness\"),yt=l(\"connection\");var Y=(e,t,r,n)=>({call:async(c,...o)=>{try{let s=await e({method:c,params:o[0]});if(!s.ok)throw Object.assign(Error(s.error.message),s.error);return s.value}catch(s){if(s instanceof Error)throw s;throw Error(T(s).message)}},onEvent:t,extensionId:r,propsStore:n}),Q=(e)=>{let t=e,r=new Set;return{get:()=>t,subscribe:(n)=>(r.add(n),()=>r.delete(n)),set:(n)=>{t=n;for(let c of r)c(t)}}};var X=(e,t)=>{e.addEventListener(\"keydown\",(r)=>{let n=r;if(n.key!==\"Escape\")return;setTimeout(()=>{if(n.defaultPrevented)return;t({key:n.key,code:n.code,ctrlKey:n.ctrlKey,metaKey:n.metaKey,altKey:n.altKey,shiftKey:n.shiftKey,repeat:n.repeat}).catch(()=>{})},0)})};var Z=(e,t)=>{e.style.width=\"max-content\";let r=-1,n=new ResizeObserver(()=>{let c=Math.ceil(e.getBoundingClientRect().width);if(c===r)return;r=c,t(c)});return n.observe(e),()=>n.disconnect()};var ee=(e)=>{let t,r,n=!1;return{initialize:(c)=>{if(n)return Promise.resolve();return t??=e(c).then((o)=>{if(typeof o!==\"function\")return;if(n)o();else r=o}),t},dispose:()=>{n=!0,r?.(),r=void 0}}};var te=\"pstdio-extension-mount\",be=()=>{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)}},Se=()=>{for(let e of[\"localStorage\",\"sessionStorage\"])try{window[e]}catch{Object.defineProperty(window,e,{configurable:!0,value:be()})}},re=(e,t)=>{let r=document.documentElement,n=e===\"dark\"?\"light\":\"dark\";r.classList.remove(n),r.classList.add(e),r.setAttribute(\"data-theme\",e),r.style.colorScheme=e;for(let[c,o]of Object.entries(t))if(c.startsWith(\"--\"))r.style.setProperty(c,o)},Ie=(e)=>{for(let t of e){let r=document.createElement(\"link\");r.rel=\"stylesheet\",r.href=t,document.head.appendChild(r)}},Pe=()=>{let e=document.getElementById(te);if(!e)e=document.createElement(\"div\"),e.id=te,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})},Ce=(e)=>e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement||e instanceof HTMLElement&&e.isContentEditable,Ae=async()=>{Se(),ke();let e=Q(q()),t=new Map,r=(s,a)=>{let i=t.get(s)??new Set;return i.add(a),t.set(s,i),()=>{i.delete(a)}},n=ee(async(s)=>{Ie(s.styles);let a=await import(s.moduleUrl),i=a.default??(a.mount?a:void 0);if(!i?.mount)throw Error(\"Extension module does not export a default view (defineExtensionView).\");let p=Y((y)=>o.remote.call(y),r,s.extensionId,e),m=Pe(),g=s.sizing===\"content-width\"?Z(m,(y)=>o.remote.contentWidthChanged(y)):void 0,w=await i.mount(m,p,e);return()=>{g?.(),w?.()}}),c=!1,o=await G.connect({init:async(s)=>{try{if(re(s.theme,s.themeVariables),e.set(s.props),await n.initialize(s),!c){c=!0,X(document,(a)=>o.remote.dispatchKeyboardEvent(a)),document.addEventListener(\"keydown\",(a)=>{if(a.key===\"Escape\")return;if(!a.ctrlKey&&!a.metaKey&&!a.altKey)return;if(Ce(a.target)&&!a.shiftKey)return;o.remote.dispatchKeyboardEvent({key:a.key,code:a.code,ctrlKey:a.ctrlKey,metaKey:a.metaKey,altKey:a.altKey,shiftKey:a.shiftKey,repeat:a.repeat}).catch(()=>{})},!0);for(let a of[\"pointerdown\",\"click\"])document.addEventListener(a,(i)=>{o.remote.dispatchPointerEvent({type:a,clientX:i.clientX,clientY:i.clientY,button:i.button,buttons:i.buttons,pointerId:i.pointerId,pointerType:i.pointerType,isPrimary:i.isPrimary,ctrlKey:i.ctrlKey,metaKey:i.metaKey,altKey:i.altKey,shiftKey:i.shiftKey})},!0)}}catch(a){let i=T(a);throw o.remote.runtimeError(i),a instanceof Error?a:Error(i.message)}},themeUpdate:(s)=>{re(s.theme,s.variables)},propsUpdate:(s)=>{e.set(s.props)},hostEvent:(s)=>{for(let a of t.get(s.scope)??[])a(s.payload)}});o.remote.ready({}),window.addEventListener(\"beforeunload\",()=>{n.dispose()})};Ae();\n";
|
|
32
31
|
export { o as getExtensionRuntimeScript, i as renderExtensionRuntimeHtml, a as renderInlineExtensionRuntimeHtml };
|
|
33
32
|
|
|
34
33
|
//# sourceMappingURL=webview-runtime.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webview-runtime.js","names":["MOUNT_ID","escapeAttribute","value","replaceAll","escapeScriptContent","renderRuntimeHostDocument","scriptTag","getExtensionRuntimeScriptUrl","URL","import","meta","url","href","renderExtensionRuntimeHtml","scriptUrl","renderInlineExtensionRuntimeHtml","runtimeScript","runtimeScript","renderExtensionRuntimeHtml","renderInlineExtensionRuntimeHtml","getExtensionRuntimeScript","runtimeScript","MOUNT_ID","escapeAttribute","value","escapeScriptContent","renderRuntimeHostDocument","scriptTag","renderExtensionRuntimeHtml","scriptUrl","renderInlineExtensionRuntimeHtml","runtimeScript","getExtensionRuntimeScript"],"sources":["../../pstdio-extensions/src/bridge/webview-runtime/runtime-html.ts","../src/webview-runtime/index.ts"],"sourcesContent":["const MOUNT_ID = \"pstdio-extension-mount\";\n\nconst escapeAttribute = (value: string) =>\n value.replaceAll(\"&\", \"&\").replaceAll('\"', \""\").replaceAll(\"<\", \"<\");\n\nconst escapeScriptContent = (value: string) => value.replaceAll(\"</script\", \"<\\\\/script\").replaceAll(\"<!--\", \"<\\\\!--\");\n\nconst renderRuntimeHostDocument = (scriptTag: string) => `<!doctype html>\n<html lang=\"en\">\n <head>\n <meta charset=\"utf-8\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n <style>\n html, body {\n height: 100%;\n margin: 0;\n background: transparent;\n }\n body {\n overflow-x: hidden !important;\n overflow-y: auto !important;\n }\n #${MOUNT_ID} {\n height: 100%;\n width: 100%;\n display: block;\n min-height: 0;\n }\n </style>\n </head>\n <body>\n <div id=\"${MOUNT_ID}\"></div>\n ${scriptTag}\n </body>\n</html>\n`;\n\nexport const getExtensionRuntimeScriptUrl = () => new URL(\"./runtime.bundle.js\", import.meta.url).href;\n\nexport const renderExtensionRuntimeHtml = (scriptUrl: string) =>\n renderRuntimeHostDocument(`<script src=\"${escapeAttribute(scriptUrl)}\"></script>`);\n\nexport const renderInlineExtensionRuntimeHtml = (runtimeScript: string) =>\n renderRuntimeHostDocument(`<script>${escapeScriptContent(runtimeScript)}</script>`);\n","import runtimeScript from \"pstdio-extensions/bridge/webview-runtime.bundle.js?raw\";\n\nexport {\n renderExtensionRuntimeHtml,\n renderInlineExtensionRuntimeHtml,\n} from \"pstdio-extensions/bridge/webview-runtime-html\";\n\n// The guest runtime bundle is inlined here so a host app can serve it without\n// depending on the private pstdio-extensions package.\nexport const getExtensionRuntimeScript = () => runtimeScript;\n"],"mappings":";IAAMA,IAAW,0BAEXC,KAAmBC,MACvBA,EAAMC,WAAW,KAAK,OAAO,CAAC,CAACA,WAAW,MAAK,QAAQ,CAAC,CAACA,WAAW,KAAK,MAAM,GAE3EC,KAAuBF,MAAkBA,EAAMC,WAAW,aAAY,YAAY,CAAC,CAACA,WAAW,QAAQ,QAAQ,GAE/GE,KAA6BC,MAAsB;;;;;;;;;;;;;;;SAehDN,EAAQ;;;;;;;;;eASFA,EAAQ;MACjBM,EAAAA;;;GAOOO,KAA8BC,MACzCT,EAA0B,gBAAgBJ,EAAgBa,CAAS,EAAC,aAAa,GAEtEC,KAAoCC,MAC/CX,EAA0B,WAAWD,EAAoBY,CAAa,EAAC,WAAW,GClCvEI,UAAkCH"}
|
|
1
|
+
{"version":3,"file":"webview-runtime.js","names":["MOUNT_ID","escapeAttribute","value","replaceAll","escapeScriptContent","renderRuntimeHostDocument","scriptTag","getExtensionRuntimeScriptUrl","URL","import","meta","url","href","renderExtensionRuntimeHtml","scriptUrl","renderInlineExtensionRuntimeHtml","runtimeScript","runtimeScript","renderExtensionRuntimeHtml","renderInlineExtensionRuntimeHtml","getExtensionRuntimeScript","runtimeScript","MOUNT_ID","escapeAttribute","value","escapeScriptContent","renderRuntimeHostDocument","scriptTag","renderExtensionRuntimeHtml","scriptUrl","renderInlineExtensionRuntimeHtml","runtimeScript","getExtensionRuntimeScript"],"sources":["../../pstdio-extensions/src/bridge/webview-runtime/runtime-html.ts","../src/webview-runtime/index.ts"],"sourcesContent":["const MOUNT_ID = \"pstdio-extension-mount\";\n\nconst escapeAttribute = (value: string) =>\n value.replaceAll(\"&\", \"&\").replaceAll('\"', \""\").replaceAll(\"<\", \"<\");\n\nconst escapeScriptContent = (value: string) => value.replaceAll(\"</script\", \"<\\\\/script\").replaceAll(\"<!--\", \"<\\\\!--\");\n\nconst renderRuntimeHostDocument = (scriptTag: string) => `<!doctype html>\n<html lang=\"en\">\n <head>\n <meta charset=\"utf-8\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n <style>\n html, body {\n height: 100%;\n margin: 0;\n background: transparent;\n }\n body {\n overflow-x: hidden !important;\n overflow-y: auto !important;\n }\n #${MOUNT_ID} {\n height: 100%;\n width: 100%;\n display: block;\n min-height: 0;\n }\n </style>\n </head>\n <body>\n <div id=\"${MOUNT_ID}\"></div>\n ${scriptTag}\n </body>\n</html>\n`;\n\nexport const getExtensionRuntimeScriptUrl = () => new URL(\"./runtime.bundle.js\", import.meta.url).href;\n\nexport const renderExtensionRuntimeHtml = (scriptUrl: string) =>\n renderRuntimeHostDocument(`<script src=\"${escapeAttribute(scriptUrl)}\"></script>`);\n\nexport const renderInlineExtensionRuntimeHtml = (runtimeScript: string) =>\n renderRuntimeHostDocument(`<script>${escapeScriptContent(runtimeScript)}</script>`);\n","import runtimeScript from \"pstdio-extensions/bridge/webview-runtime.bundle.js?raw\";\n\nexport {\n renderExtensionRuntimeHtml,\n renderInlineExtensionRuntimeHtml,\n} from \"pstdio-extensions/bridge/webview-runtime-html\";\n\n// The guest runtime bundle is inlined here so a host app can serve it without\n// depending on the private pstdio-extensions package.\nexport const getExtensionRuntimeScript = () => runtimeScript;\n"],"mappings":";A,IAAMA,IAAW,0BAEXC,KAAmBC,MACvBA,EAAMC,WAAW,KAAK,OAAO,CAAC,CAACA,WAAW,MAAK,QAAQ,CAAC,CAACA,WAAW,KAAK,MAAM,GAE3EC,KAAuBF,MAAkBA,EAAMC,WAAW,aAAY,YAAY,CAAC,CAACA,WAAW,QAAQ,QAAQ,GAE/GE,KAA6BC,MAAsB;;;;;;;;;;;;;;;SAehDN,EAAQ;;;;;;;;;eASFA,EAAQ;MACjBM,EAAAA;;;GAOOO,KAA8BC,MACzCT,EAA0B,gBAAgBJ,EAAgBa,CAAS,EAAC,aAAa,GAEtEC,KAAoCC,MAC/CX,EAA0B,WAAWD,EAAoBY,CAAa,EAAC,WAAW,GClCvEI,UAAkCH"}
|