dsh-zen-remote 2.0.3 → 2.2.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.
Files changed (114) hide show
  1. package/AGENTS.md +15 -1
  2. package/README.md +11 -5
  3. package/README.zh-CN.md +11 -5
  4. package/docs/adr/0001-plugin-bridge-forwards-plugin-routes.md +15 -0
  5. package/docs/adr/0002-relay-emulates-websocket.md +8 -0
  6. package/docs/interface.md +3 -1
  7. package/docs/plugin-bridge.md +140 -0
  8. package/docs/remote-access.en.md +57 -0
  9. package/docs/remote-access.md +57 -0
  10. package/lib/adapters/dsh-better-sidebar/index.js +144 -0
  11. package/lib/adapters/dsh-better-sidebar/index.js.map +1 -0
  12. package/lib/adapters/dsh-better-sidebar/methods.js +198 -0
  13. package/lib/adapters/dsh-better-sidebar/methods.js.map +1 -0
  14. package/lib/adapters/index.js +17 -0
  15. package/lib/adapters/index.js.map +1 -0
  16. package/lib/adapters/types.js +17 -0
  17. package/lib/adapters/types.js.map +1 -0
  18. package/lib/admin-routes.js +51 -0
  19. package/lib/admin-routes.js.map +1 -1
  20. package/lib/client-routes.js +18 -1
  21. package/lib/client-routes.js.map +1 -1
  22. package/lib/client.js +449 -45
  23. package/lib/config.js +27 -0
  24. package/lib/config.js.map +1 -1
  25. package/lib/http.js +10 -0
  26. package/lib/http.js.map +1 -1
  27. package/lib/index.js +246 -0
  28. package/lib/index.js.map +1 -1
  29. package/lib/plugin-adapter-core.js +385 -0
  30. package/lib/plugin-adapter-core.js.map +1 -0
  31. package/lib/plugin-bridge.js +318 -0
  32. package/lib/plugin-bridge.js.map +1 -0
  33. package/lib/plugin-loopback.js +207 -0
  34. package/lib/plugin-loopback.js.map +1 -0
  35. package/lib/plugin-route-intercept.js +1103 -0
  36. package/lib/plugin-route-intercept.js.map +1 -0
  37. package/lib/plugin-tunnel.js +416 -0
  38. package/lib/plugin-tunnel.js.map +1 -0
  39. package/lib/relay-client.js +319 -2
  40. package/lib/relay-client.js.map +1 -1
  41. package/lib/relay-server.js +633 -0
  42. package/lib/relay-server.js.map +1 -1
  43. package/lib/types/adapters/dsh-better-sidebar/index.d.ts +27 -0
  44. package/lib/types/adapters/dsh-better-sidebar/index.d.ts.map +1 -0
  45. package/lib/types/adapters/dsh-better-sidebar/methods.d.ts +51 -0
  46. package/lib/types/adapters/dsh-better-sidebar/methods.d.ts.map +1 -0
  47. package/lib/types/adapters/index.d.ts +17 -0
  48. package/lib/types/adapters/index.d.ts.map +1 -0
  49. package/lib/types/adapters/types.d.ts +42 -0
  50. package/lib/types/adapters/types.d.ts.map +1 -0
  51. package/lib/types/admin-routes.d.ts +16 -0
  52. package/lib/types/admin-routes.d.ts.map +1 -1
  53. package/lib/types/client/effects/remote-session.d.ts +0 -22
  54. package/lib/types/client/effects/remote-session.d.ts.map +1 -1
  55. package/lib/types/client/locales.d.ts +16 -0
  56. package/lib/types/client/locales.d.ts.map +1 -1
  57. package/lib/types/client/settings/SettingsSection.d.ts.map +1 -1
  58. package/lib/types/client/styles/remote-session.css.d.ts +1 -1
  59. package/lib/types/client/styles/remote-session.css.d.ts.map +1 -1
  60. package/lib/types/client-data/plugin-bridge.d.ts +79 -0
  61. package/lib/types/client-data/plugin-bridge.d.ts.map +1 -0
  62. package/lib/types/client-data/remote-status.d.ts +20 -0
  63. package/lib/types/client-data/remote-status.d.ts.map +1 -1
  64. package/lib/types/client-data/settings-form.d.ts +37 -1
  65. package/lib/types/client-data/settings-form.d.ts.map +1 -1
  66. package/lib/types/client-routes.d.ts +13 -0
  67. package/lib/types/client-routes.d.ts.map +1 -1
  68. package/lib/types/config.d.ts +8 -0
  69. package/lib/types/config.d.ts.map +1 -1
  70. package/lib/types/http.d.ts +7 -0
  71. package/lib/types/http.d.ts.map +1 -1
  72. package/lib/types/index.d.ts +4 -0
  73. package/lib/types/index.d.ts.map +1 -1
  74. package/lib/types/plugin-adapter-core.d.ts +263 -0
  75. package/lib/types/plugin-adapter-core.d.ts.map +1 -0
  76. package/lib/types/plugin-bridge.d.ts +187 -0
  77. package/lib/types/plugin-bridge.d.ts.map +1 -0
  78. package/lib/types/plugin-loopback.d.ts +104 -0
  79. package/lib/types/plugin-loopback.d.ts.map +1 -0
  80. package/lib/types/plugin-route-intercept.d.ts +114 -0
  81. package/lib/types/plugin-route-intercept.d.ts.map +1 -0
  82. package/lib/types/plugin-tunnel.d.ts +96 -0
  83. package/lib/types/plugin-tunnel.d.ts.map +1 -0
  84. package/lib/types/relay-client.d.ts +76 -0
  85. package/lib/types/relay-client.d.ts.map +1 -1
  86. package/lib/types/relay-server.d.ts +32 -1
  87. package/lib/types/relay-server.d.ts.map +1 -1
  88. package/llms.txt +1 -0
  89. package/package.json +2 -2
  90. package/scripts/check-plugin-bridge-ui.mjs +168 -0
  91. package/scripts/check-settings-form.mjs +3 -1
  92. package/src/adapters/dsh-better-sidebar/index.ts +144 -0
  93. package/src/adapters/dsh-better-sidebar/methods.ts +215 -0
  94. package/src/adapters/index.ts +19 -0
  95. package/src/adapters/types.ts +44 -0
  96. package/src/admin-routes.ts +64 -0
  97. package/src/client/effects/remote-session.ts +82 -10
  98. package/src/client/locales.ts +36 -0
  99. package/src/client/settings/SettingsSection.tsx +107 -3
  100. package/src/client/styles/remote-session.css.ts +70 -31
  101. package/src/client-data/plugin-bridge.ts +150 -0
  102. package/src/client-data/remote-status.ts +30 -0
  103. package/src/client-data/settings-form.ts +78 -0
  104. package/src/client-routes.ts +29 -1
  105. package/src/config.ts +32 -0
  106. package/src/http.ts +12 -0
  107. package/src/index.ts +252 -0
  108. package/src/plugin-adapter-core.ts +530 -0
  109. package/src/plugin-bridge.ts +435 -0
  110. package/src/plugin-loopback.ts +299 -0
  111. package/src/plugin-route-intercept.ts +1193 -0
  112. package/src/plugin-tunnel.ts +470 -0
  113. package/src/relay-client.ts +394 -2
  114. package/src/relay-server.ts +656 -1
@@ -0,0 +1,385 @@
1
+ /**
2
+ * The plugin bridge's adapter core (PB-11) — the framework half of the
3
+ * pluggable adapters. A cooperative plugin registers its OWN bridge
4
+ * declaration (PB-1); an adapter is zen-remote-internal code, written
5
+ * against one third-party plugin's EXACT version, that locates the session
6
+ * ids in that plugin's requests and rewrites them both ways (GLOSSARY:
7
+ * 适配器). This module owns everything the framework needs to run one:
8
+ * the route/locator shapes, their validation, the locate → classify →
9
+ * rewrite pipeline, and the digest the adapter registers under.
10
+ *
11
+ * Deliberately OUTSIDE `src/adapters/`: the pluggability contract
12
+ * (test/adapters-pluggable.test.cjs) is that deleting that directory breaks
13
+ * ONLY the wiring import in src/index.ts. The adapter-author face — the
14
+ * `BridgeAdapter` interface — lives in `src/adapters/types.ts` ON TOP of
15
+ * the shapes defined here (it re-exports them), so the framework never
16
+ * imports a single thing from `src/adapters/`.
17
+ *
18
+ * Pure logic: no DSH, no I/O. The id semantics ride src/virtual-id.ts —
19
+ * a request counts as REMOTE exactly when every id the route's locator
20
+ * finds is a `zr~` virtual id, and the rewrite swaps each for its real
21
+ * half before the request leaves for the relay (docs/adr/0001: the
22
+ * sub-client never lets a remote session's request reach a local plugin).
23
+ */
24
+ import { createHash } from 'node:crypto';
25
+ import { isVirtual, fromVirtual } from './virtual-id.js';
26
+ import { BRIDGE_METHODS, DEFAULT_ROUTE_BODY_BYTES } from './plugin-bridge.js';
27
+ export { fromVirtual };
28
+ /** The npm package name of an adapter's target, same shape the cooperative
29
+ * declarations validate. */
30
+ const PLUGIN_PATTERN = /^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*$/u;
31
+ const MAX_ROUTES = 64;
32
+ /** The body cap an ADAPTER route may declare: 100 MiB — the relay's own
33
+ * upload budget (lib/relay-server.js `MAX_UPLOAD_BYTES`), which the
34
+ * better-sidebar upload route rides. Wider than the cooperative
35
+ * declaration's 64 MiB because raw media uploads are exactly what an
36
+ * adapter exists to carry; test/adapter-better-sidebar.test.cjs pins the
37
+ * two numbers together. */
38
+ export const MAX_ADAPTER_BODY_BYTES = 100 * 1024 * 1024;
39
+ function isRecord(value) {
40
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
41
+ }
42
+ function fail(field, detail) {
43
+ throw new Error(`invalid adapter, ${field}: ${detail}`);
44
+ }
45
+ /** Validate one adapter's route table and fold it, together with the
46
+ * INSTALLED plugin version, into the registry-ready form.
47
+ *
48
+ * Route paths follow the cooperative declaration's rules verbatim (plain
49
+ * absolute paths, off the host-owned `/_dsh/` and `/api` prefixes) — an
50
+ * adapter must not be able to reach anything a declaration cannot. The
51
+ * installed version must be listed EXACTLY (`versions` are what the
52
+ * adapter was written against); anything else refuses the adapter whole.
53
+ * @throws with a field-naming message on any illegal shape.
54
+ */
55
+ export function normalizeAdapter(input, installedVersion) {
56
+ if (!isRecord(input))
57
+ fail('adapter', 'expected an object');
58
+ for (const key of Object.keys(input)) {
59
+ if (key !== 'plugin' && key !== 'versions' && key !== 'routes' && key !== 'client' && key !== 'server') {
60
+ fail(key, 'unknown field (typo guard)');
61
+ }
62
+ }
63
+ const { plugin, versions, routes } = input;
64
+ if (typeof plugin !== 'string' || plugin === '' || plugin.length > 214 || !PLUGIN_PATTERN.test(plugin)) {
65
+ fail('plugin', `"${String(plugin)}" is not an npm package name`);
66
+ }
67
+ if (!Array.isArray(versions) || versions.length === 0 || versions.some((v) => typeof v !== 'string' || v === '')) {
68
+ fail('versions', 'must be a non-empty array of version strings');
69
+ }
70
+ if (!versions.includes(installedVersion)) {
71
+ fail('versions', `installed version "${installedVersion}" is not among the adapter's versions`);
72
+ }
73
+ if (!Array.isArray(routes) || routes.length === 0)
74
+ fail('routes', 'must be a non-empty array');
75
+ if (routes.length > MAX_ROUTES)
76
+ fail('routes', `${routes.length} routes exceeds the ${MAX_ROUTES} cap`);
77
+ const seen = new Set();
78
+ const normalized = routes.map((route, index) => {
79
+ if (!isRecord(route))
80
+ fail(`routes[${index}]`, 'expected an object');
81
+ for (const key of Object.keys(route)) {
82
+ if (key !== 'path' && key !== 'match' && key !== 'methods' && key !== 'maxBody' && key !== 'stream' && key !== 'upgrade' && key !== 'locator' && key !== 'local' && key !== 'deny') {
83
+ fail(`routes[${index}].${key}`, 'unknown field (typo guard)');
84
+ }
85
+ }
86
+ const { path, match, methods, maxBody, stream, upgrade, locator, local, deny } = route;
87
+ if (typeof path !== 'string' || path === '' || !path.startsWith('/') || path.includes('?') || path.includes('#') || path.includes('..') || /\s/u.test(path)) {
88
+ fail(`routes[${index}].path`, `"${String(path)}" must be a plain absolute path`);
89
+ }
90
+ if (path.startsWith('/_dsh/') || path.startsWith('/api')) {
91
+ fail(`routes[${index}].path`, `"${path}" starts with a host-owned prefix (/_dsh/ or /api)`);
92
+ }
93
+ if (match !== 'exact' && match !== 'prefix')
94
+ fail(`routes[${index}].match`, 'must be "exact" or "prefix"');
95
+ if (seen.has(path))
96
+ fail(`routes[${index}].path`, `duplicate path "${path}"`);
97
+ seen.add(path);
98
+ let normalizedMethods;
99
+ if (methods === undefined) {
100
+ normalizedMethods = ['GET'];
101
+ }
102
+ else {
103
+ if (!Array.isArray(methods) || methods.length === 0)
104
+ fail(`routes[${index}].methods`, 'must be a non-empty array of HTTP methods');
105
+ const upper = [];
106
+ for (const entry of methods) {
107
+ if (typeof entry !== 'string' || !BRIDGE_METHODS.includes(entry)) {
108
+ fail(`routes[${index}].methods`, `${JSON.stringify(entry ?? null)} is not one of ${BRIDGE_METHODS.join(', ')}`);
109
+ }
110
+ if (!upper.includes(entry))
111
+ upper.push(entry);
112
+ }
113
+ upper.sort();
114
+ normalizedMethods = upper;
115
+ }
116
+ const normalizedMaxBody = maxBody === undefined ? DEFAULT_ROUTE_BODY_BYTES : maxBody;
117
+ if (typeof normalizedMaxBody !== 'number' || !Number.isInteger(normalizedMaxBody) || normalizedMaxBody <= 0 || normalizedMaxBody > MAX_ADAPTER_BODY_BYTES) {
118
+ fail(`routes[${index}].maxBody`, `must be a positive integer up to ${MAX_ADAPTER_BODY_BYTES}`);
119
+ }
120
+ const normalizedStream = stream === undefined ? false : stream;
121
+ if (typeof normalizedStream !== 'boolean')
122
+ fail(`routes[${index}].stream`, 'must be a boolean');
123
+ const normalizedUpgrade = upgrade === undefined ? false : upgrade;
124
+ if (typeof normalizedUpgrade !== 'boolean')
125
+ fail(`routes[${index}].upgrade`, 'must be a boolean');
126
+ if (normalizedUpgrade) {
127
+ if (normalizedStream)
128
+ fail(`routes[${index}].upgrade`, 'cannot be combined with stream');
129
+ if (normalizedMethods.some((entry) => entry !== 'GET'))
130
+ fail(`routes[${index}].upgrade`, 'upgrade routes are GET-only');
131
+ }
132
+ if (!isRecord(locator))
133
+ fail(`routes[${index}].locator`, 'expected an object');
134
+ if (locator.in === 'query') {
135
+ if (typeof locator.name !== 'string' || !/^[A-Za-z][A-Za-z0-9_]{0,63}$/u.test(locator.name)) {
136
+ fail(`routes[${index}].locator.name`, 'must be a query parameter name');
137
+ }
138
+ }
139
+ else if (locator.in === 'path-segment') {
140
+ if (typeof locator.index !== 'number' || !Number.isInteger(locator.index) || locator.index < 0) {
141
+ fail(`routes[${index}].locator.index`, 'must be a non-negative integer');
142
+ }
143
+ if (match !== 'prefix')
144
+ fail(`routes[${index}].locator`, 'path-segment locating needs a prefix route');
145
+ }
146
+ else if (locator.in === 'json-body') {
147
+ if (!Array.isArray(locator.fields) || locator.fields.length === 0 || locator.fields.some((f) => typeof f !== 'string' || f === '')) {
148
+ fail(`routes[${index}].locator.fields`, 'must be a non-empty array of top-level field names');
149
+ }
150
+ }
151
+ else {
152
+ fail(`routes[${index}].locator.in`, 'must be "query", "path-segment" or "json-body"');
153
+ }
154
+ if (local !== undefined && local !== true && local !== false)
155
+ fail(`routes[${index}].local`, 'must be a boolean');
156
+ const normalizedLocal = local === true;
157
+ if (deny !== undefined && typeof deny !== 'function')
158
+ fail(`routes[${index}].deny`, 'must be a function or omitted');
159
+ return {
160
+ path,
161
+ match,
162
+ methods: normalizedMethods,
163
+ maxBody: normalizedMaxBody,
164
+ stream: normalizedStream,
165
+ upgrade: normalizedUpgrade,
166
+ locator: locator,
167
+ local: normalizedLocal,
168
+ ...(deny !== undefined && typeof deny === 'function' ? { deny: deny } : {}),
169
+ };
170
+ });
171
+ normalized.sort((a, b) => (a.path < b.path ? -1 : a.path > b.path ? 1 : 0));
172
+ const digest = adapterDigestOf(plugin, installedVersion, normalized);
173
+ // The registry entry: server-scope routes only (an adapter is whole-machine
174
+ // data by definition — the consent wall applies per plugin, default off),
175
+ // local routes left out (they never forward, so the server half must never
176
+ // see them).
177
+ const declaration = {
178
+ plugin,
179
+ version: installedVersion,
180
+ routes: normalized
181
+ .filter((route) => !route.local)
182
+ .map((route) => ({
183
+ path: route.path,
184
+ scope: 'server',
185
+ sessionParam: 'sessionId',
186
+ stream: route.stream,
187
+ methods: route.methods.length === 1 && route.methods[0] === 'GET' ? undefined : [...route.methods],
188
+ maxBody: route.maxBody === DEFAULT_ROUTE_BODY_BYTES ? undefined : route.maxBody,
189
+ upgrade: route.upgrade ? true : undefined,
190
+ })),
191
+ digest,
192
+ };
193
+ const hooks = {};
194
+ if (isRecord(input.client) || input.client === undefined) {
195
+ const client = input.client;
196
+ if (client !== undefined && (typeof client.request === 'function' || typeof client.response === 'function')) {
197
+ hooks.client = {
198
+ ...(typeof client.request === 'function' ? { request: (ctx) => client.request(ctx) } : {}),
199
+ ...(typeof client.response === 'function' ? { response: (ctx) => client.response(ctx) } : {}),
200
+ };
201
+ }
202
+ }
203
+ if (isRecord(input.server) || input.server === undefined) {
204
+ const server = input.server;
205
+ if (server !== undefined && typeof server.request === 'function') {
206
+ hooks.server = { request: (ctx) => server.request(ctx) };
207
+ }
208
+ }
209
+ return { plugin, versions: [...versions], routes: normalized, digest, declaration, hooks };
210
+ }
211
+ /** The digest of one adapter's route table: sha256 over a canonical JSON of
212
+ * `{plugin, version, routes}` — the locator and the match mode INCLUDED (a
213
+ * different locating rule is a different adapter), hex, first 16 chars.
214
+ * Routes arrive path-sorted, so order never moves the hash. */
215
+ export function adapterDigestOf(plugin, version, routes) {
216
+ const canonical = JSON.stringify({
217
+ plugin,
218
+ version,
219
+ routes: routes.map((route) => ({
220
+ path: route.path,
221
+ match: route.match,
222
+ methods: route.methods,
223
+ maxBody: route.maxBody,
224
+ stream: route.stream,
225
+ upgrade: route.upgrade,
226
+ locator: route.locator,
227
+ local: route.local,
228
+ })),
229
+ });
230
+ return createHash('sha256').update(canonical, 'utf8').digest('hex').slice(0, 16);
231
+ }
232
+ /** The prefix-match rule, shared verbatim by both halves: equality or one
233
+ * path segment deeper, on the RAW undecoded pathname. */
234
+ export function adapterPathMatches(route, pathname) {
235
+ if (route.match === 'exact')
236
+ return pathname === route.path;
237
+ return pathname === route.path || pathname.startsWith(`${route.path}/`);
238
+ }
239
+ /** The adapter route a forwarded request hit, or `undefined`. `local`
240
+ * routes never match here — they stay on the sub-client's own machine in
241
+ * both directions, so the server half must never see (nor serve) them. */
242
+ export function matchAdapterRoute(adapters, pathname) {
243
+ if (adapters === undefined)
244
+ return undefined;
245
+ for (const adapter of adapters) {
246
+ for (const route of adapter.routes) {
247
+ if (route.local)
248
+ continue;
249
+ if (adapterPathMatches(route, pathname))
250
+ return { adapter, route };
251
+ }
252
+ }
253
+ return undefined;
254
+ }
255
+ /** Thrown when a query parameter the locator reads appears with MORE than
256
+ * one value: the cooperative bridge refuses such requests as `bad-query`
257
+ * (a duplicated id is a shape violation, never a forward of whichever
258
+ * duplicate a parser happens to keep), and so does the adapter (PB-12
259
+ * review note — the old behavior silently collapsed to `set`, rewriting
260
+ * only one of the values). Callers catch this and answer 503/400
261
+ * `bad-query`. */
262
+ export class AdapterMultiValueQueryError extends Error {
263
+ constructor(name) {
264
+ super(`query parameter "${name}" appears more than once`);
265
+ this.name = 'AdapterMultiValueQueryError';
266
+ }
267
+ }
268
+ /** Locate the session ids one request carries for one route. A query
269
+ * parameter counts once per value it appears with; a JSON body field counts
270
+ * when present with a non-empty string value; a path segment counts when
271
+ * the segment exists (decoded once off the wire). */
272
+ export function locateAdapterIds(route, pathname, search, body) {
273
+ const hits = [];
274
+ const locator = route.locator;
275
+ if (locator.in === 'query') {
276
+ const values = search.getAll(locator.name);
277
+ if (values.length > 1)
278
+ throw new AdapterMultiValueQueryError(locator.name);
279
+ for (const value of values) {
280
+ if (value !== '')
281
+ hits.push({ kind: 'query', key: locator.name, value });
282
+ }
283
+ }
284
+ else if (locator.in === 'path-segment') {
285
+ // `index` counts the segments AFTER the declared path: /p/api + open/X
286
+ // → index 0 is "open", index 1 is "X". In split('/') terms the prefix
287
+ // occupies subscripts 1..prefixDepth, so the target sits one past it.
288
+ const prefixDepth = route.path.split('/').length - 1;
289
+ const segments = pathname.split('/');
290
+ const at = prefixDepth + 1 + locator.index;
291
+ if (at < segments.length && segments[at] !== '') {
292
+ let decoded = segments[at];
293
+ try {
294
+ decoded = decodeURIComponent(segments[at]);
295
+ }
296
+ catch {
297
+ // A malformed escape stays verbatim — the value simply will not be
298
+ // a session id.
299
+ }
300
+ hits.push({ kind: 'path-segment', key: undefined, value: decoded });
301
+ }
302
+ }
303
+ else {
304
+ if (isRecord(body)) {
305
+ for (const field of locator.fields) {
306
+ const value = body[field];
307
+ if (typeof value === 'string' && value !== '')
308
+ hits.push({ kind: 'json-body', key: field, value });
309
+ }
310
+ }
311
+ }
312
+ return hits;
313
+ }
314
+ export function classifyAdapterRequest(route, pathname, search, body) {
315
+ const hits = locateAdapterIds(route, pathname, search, body);
316
+ if (hits.length === 0)
317
+ return { kind: 'local' };
318
+ const virtual = hits.map((hit) => isVirtual(hit.value));
319
+ if (virtual.every(Boolean))
320
+ return { kind: 'remote', hits };
321
+ if (virtual.every((entry) => !entry))
322
+ return { kind: 'local' };
323
+ return { kind: 'mixed' };
324
+ }
325
+ /** Swap every located virtual id for its real half (the pure client-half
326
+ * rewrite): the query is re-serialized, the path segment re-encoded, the
327
+ * JSON body re-serialized. The re-encode direction is the wire contract —
328
+ * `encodeURIComponent` of the real id is what the server decodes again. */
329
+ export function rewriteAdapterRequest(route, pathname, search, body, hits, realIdOf) {
330
+ const rewrittenQuery = new URLSearchParams(search);
331
+ let rewrittenPathname = pathname;
332
+ let bodyText;
333
+ // The body copy is made ONCE: several fields of one body can locate ids,
334
+ // and re-copying per hit would drop every earlier field's rewrite.
335
+ let bodyCopy;
336
+ for (const hit of hits) {
337
+ const parts = fromVirtual(hit.value);
338
+ if (parts === undefined)
339
+ continue;
340
+ const real = realIdOf(hit.value);
341
+ if (hit.kind === 'query') {
342
+ rewrittenQuery.set(hit.key, real);
343
+ }
344
+ else if (hit.kind === 'path-segment') {
345
+ const prefixDepth = route.path.split('/').length - 1;
346
+ const segments = rewrittenPathname.split('/');
347
+ segments[prefixDepth + 1 + route.locator.index] = encodeURIComponent(real);
348
+ rewrittenPathname = segments.join('/');
349
+ }
350
+ else {
351
+ if (bodyCopy === undefined && isRecord(body))
352
+ bodyCopy = { ...body };
353
+ if (bodyCopy !== undefined) {
354
+ bodyCopy[hit.key] = real;
355
+ bodyText = JSON.stringify(bodyCopy);
356
+ }
357
+ }
358
+ }
359
+ return { pathname: rewrittenPathname, query: rewrittenQuery, bodyText };
360
+ }
361
+ /** Whether the adapter still owns its plugin's registry entry, or a
362
+ * cooperative declaration (the plugin's OWN `zenRemote.bridge(...)`, which
363
+ * always wins) has taken the seat since: an entry with a different digest
364
+ * means the adapter yielded. */
365
+ export function adapterOwnsRegistryEntry(adapter, registryEntry) {
366
+ return registryEntry !== undefined && registryEntry.digest === adapter.digest && registryEntry.version === adapter.declaration.version;
367
+ }
368
+ /** The largest JSON answer the client half will buffer for a response
369
+ * rewrite: past this the body passes through untouched (8 MB). */
370
+ export const MAX_ADAPTER_RESPONSE_BUFFER_BYTES = 8 * 1024 * 1024;
371
+ /** Response headers an ADAPTER answer may carry through VERBATIM, beyond
372
+ * the three every bridged forward passes (content-type, content-length,
373
+ * cache-control): the better-sidebar HTML preview ships a `content-
374
+ * security-policy` sandbox and downloads carry `content-disposition` —
375
+ * stripping those breaks the very panels the adapter exists to serve.
376
+ * Cooperative declaration routes keep the three-header behavior. */
377
+ export const ADAPTER_RESPONSE_HEADER_ALLOWLIST = [
378
+ 'content-security-policy',
379
+ 'content-disposition',
380
+ 'etag',
381
+ 'last-modified',
382
+ 'accept-ranges',
383
+ 'content-range',
384
+ ];
385
+ //# sourceMappingURL=plugin-adapter-core.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin-adapter-core.js","sourceRoot":"","sources":["../src/plugin-adapter-core.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAExD,OAAO,EAAE,cAAc,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAA;AAE7E,OAAO,EAAE,WAAW,EAAE,CAAA;AAmItB;4BAC4B;AAC5B,MAAM,cAAc,GAAG,qDAAqD,CAAA;AAC5E,MAAM,UAAU,GAAG,EAAE,CAAA;AAErB;;;;;2BAK2B;AAC3B,MAAM,CAAC,MAAM,sBAAsB,GAAG,GAAG,GAAG,IAAI,GAAG,IAAI,CAAA;AAEvD,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;AAC7E,CAAC;AAED,SAAS,IAAI,CAAC,KAAa,EAAE,MAAc;IACzC,MAAM,IAAI,KAAK,CAAC,oBAAoB,KAAK,KAAK,MAAM,EAAE,CAAC,CAAA;AACzD,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAc,EAAE,gBAAwB;IACvE,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,IAAI,CAAC,SAAS,EAAE,oBAAoB,CAAC,CAAA;IAC3D,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QACrC,IAA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