@preprio/toolkit 0.5.0-rc.1 → 0.5.0-rc.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +416 -23
- package/dist/astro/index.cjs +1290 -1
- package/dist/astro/index.d.cts +47 -1
- package/dist/astro/index.d.ts +47 -1
- package/dist/astro/index.js +1297 -1
- package/dist/chunk-F46GJS6Y.js +26 -0
- package/dist/{chunk-4JNKYIEV.js → chunk-IDEC77LZ.js} +1423 -642
- package/dist/chunk-IPMB32AZ.js +246 -0
- package/dist/chunk-KD3GK6TO.js +1221 -0
- package/dist/chunk-S3VT4UWM.js +75 -0
- package/dist/chunk-TBBU3LDD.js +184 -0
- package/dist/chunk-URXSDJOU.js +356 -0
- package/dist/codegen/index.cjs +82 -0
- package/dist/codegen/index.d.cts +70 -0
- package/dist/codegen/index.d.ts +70 -0
- package/dist/codegen/index.js +64 -0
- package/dist/index.cjs +3342 -417
- package/dist/index.d.cts +276 -5
- package/dist/index.d.ts +276 -5
- package/dist/index.js +307 -144
- package/dist/live-preview-DLXGXRE5.js +18 -0
- package/dist/nextjs/components.cjs +1582 -386
- package/dist/nextjs/components.d.cts +1 -1
- package/dist/nextjs/components.d.ts +1 -1
- package/dist/nextjs/components.js +4 -1
- package/dist/nextjs/index.cjs +1181 -6
- package/dist/nextjs/index.d.cts +83 -3
- package/dist/nextjs/index.d.ts +83 -3
- package/dist/nextjs/index.js +1179 -7
- package/dist/nextjs/live-action.cjs +285 -0
- package/dist/nextjs/live-action.d.cts +12 -0
- package/dist/nextjs/live-action.d.ts +12 -0
- package/dist/nextjs/live-action.js +68 -0
- package/dist/nextjs/live.cjs +1899 -0
- package/dist/nextjs/live.d.cts +54 -0
- package/dist/nextjs/live.d.ts +54 -0
- package/dist/nextjs/live.js +268 -0
- package/dist/nuxt/chunk-BWPGO25E.js +340 -0
- package/dist/nuxt/index.cjs +1 -1
- package/dist/nuxt/index.js +1 -1
- package/dist/nuxt/live-preview-2RCU35W5.js +1189 -0
- package/dist/nuxt/live.cjs +1816 -0
- package/dist/nuxt/live.d.cts +43 -0
- package/dist/nuxt/live.d.ts +43 -0
- package/dist/nuxt/live.js +198 -0
- package/dist/{pixel-e1fUWl2Y.d.cts → pixel-CX422dCO.d.cts} +18 -3
- package/dist/{pixel-e1fUWl2Y.d.ts → pixel-CX422dCO.d.ts} +18 -3
- package/dist/react/components.cjs +1582 -386
- package/dist/react/components.d.cts +17 -2
- package/dist/react/components.d.ts +17 -2
- package/dist/react/components.js +1582 -386
- package/dist/sveltekit/chunk-BWPGO25E.js +340 -0
- package/dist/sveltekit/index.cjs +1 -1
- package/dist/sveltekit/index.js +1 -1
- package/dist/sveltekit/live-preview-2RCU35W5.js +1189 -0
- package/dist/sveltekit/live.cjs +1830 -0
- package/dist/sveltekit/live.d.cts +59 -0
- package/dist/sveltekit/live.d.ts +59 -0
- package/dist/sveltekit/live.js +204 -0
- package/package.json +37 -11
- package/src/astro/PreprToolbar.astro +7 -1
package/dist/nextjs/index.cjs
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __export = (target, all) => {
|
|
7
9
|
for (var name in all)
|
|
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
}
|
|
16
18
|
return to;
|
|
17
19
|
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
18
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
29
|
|
|
20
30
|
// src/nextjs/index.ts
|
|
@@ -30,6 +40,7 @@ __export(nextjs_exports, {
|
|
|
30
40
|
getPreprHeaders: () => getPreprHeaders,
|
|
31
41
|
getPreprUUID: () => getPreprUUID,
|
|
32
42
|
getToolbarProps: () => getToolbarProps,
|
|
43
|
+
normalizeQuery: () => normalizeQuery,
|
|
33
44
|
validatePreprToken: () => validatePreprToken
|
|
34
45
|
});
|
|
35
46
|
module.exports = __toCommonJS(nextjs_exports);
|
|
@@ -38,7 +49,7 @@ module.exports = __toCommonJS(nextjs_exports);
|
|
|
38
49
|
var import_server = require("next/server");
|
|
39
50
|
|
|
40
51
|
// src/version.ts
|
|
41
|
-
var VERSION = "0.5.0-rc.
|
|
52
|
+
var VERSION = "0.5.0-rc.10";
|
|
42
53
|
|
|
43
54
|
// src/core/constants.ts
|
|
44
55
|
var COOKIE_PREVIEW_MODE = "Prepr-Preview-Mode";
|
|
@@ -83,9 +94,9 @@ function sanitizeHeaderValue(value) {
|
|
|
83
94
|
return stripped.length > MAX_HEADER_VALUE_LENGTH ? stripped.slice(0, MAX_HEADER_VALUE_LENGTH) : stripped;
|
|
84
95
|
}
|
|
85
96
|
function parseCookies(request) {
|
|
86
|
-
const
|
|
97
|
+
const cookies2 = /* @__PURE__ */ new Map();
|
|
87
98
|
const header = request.headers.get("cookie");
|
|
88
|
-
if (!header) return
|
|
99
|
+
if (!header) return cookies2;
|
|
89
100
|
for (const part of header.split(";")) {
|
|
90
101
|
const eq = part.indexOf("=");
|
|
91
102
|
if (eq === -1) continue;
|
|
@@ -93,12 +104,12 @@ function parseCookies(request) {
|
|
|
93
104
|
const value = part.slice(eq + 1).trim();
|
|
94
105
|
if (!name) continue;
|
|
95
106
|
try {
|
|
96
|
-
|
|
107
|
+
cookies2.set(name, decodeURIComponent(value));
|
|
97
108
|
} catch {
|
|
98
|
-
|
|
109
|
+
cookies2.set(name, value);
|
|
99
110
|
}
|
|
100
111
|
}
|
|
101
|
-
return
|
|
112
|
+
return cookies2;
|
|
102
113
|
}
|
|
103
114
|
function processFrameworkRequest(request, opts, framework) {
|
|
104
115
|
const requestHeaders = new Headers(request.headers);
|
|
@@ -264,6 +275,1147 @@ function createPreprMiddleware(request, responseOrOptions, maybeOptions) {
|
|
|
264
275
|
|
|
265
276
|
// src/nextjs/server.ts
|
|
266
277
|
var import_headers = require("next/headers");
|
|
278
|
+
var navigation = __toESM(require("next/navigation"), 1);
|
|
279
|
+
|
|
280
|
+
// src/core/live-preview/normalize-query.ts
|
|
281
|
+
var import_stega2 = require("@vercel/stega");
|
|
282
|
+
|
|
283
|
+
// src/core/utils.ts
|
|
284
|
+
var DebugLogger = class {
|
|
285
|
+
constructor(options) {
|
|
286
|
+
this.options = {
|
|
287
|
+
prefix: "[Prepr]",
|
|
288
|
+
...options
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
// A local `enabled` wins; otherwise defer to the global logger so scoped
|
|
292
|
+
// loggers created before initDebugLogger() still pick up the setting.
|
|
293
|
+
isEnabled() {
|
|
294
|
+
if (this.options.enabled !== void 0) {
|
|
295
|
+
return this.options.enabled;
|
|
296
|
+
}
|
|
297
|
+
return globalDebugLogger?.options?.enabled ?? false;
|
|
298
|
+
}
|
|
299
|
+
log(message, ...args) {
|
|
300
|
+
if (!this.isEnabled()) return;
|
|
301
|
+
const prefix = this.options.prefix;
|
|
302
|
+
console.log(`${prefix} ${message}`, ...args);
|
|
303
|
+
}
|
|
304
|
+
warn(message, ...args) {
|
|
305
|
+
if (!this.isEnabled()) return;
|
|
306
|
+
const prefix = this.options.prefix;
|
|
307
|
+
console.warn(`${prefix} ${message}`, ...args);
|
|
308
|
+
}
|
|
309
|
+
error(message, ...args) {
|
|
310
|
+
if (!this.isEnabled()) return;
|
|
311
|
+
const prefix = this.options.prefix;
|
|
312
|
+
console.error(`${prefix} ${message}`, ...args);
|
|
313
|
+
}
|
|
314
|
+
};
|
|
315
|
+
var globalDebugLogger = null;
|
|
316
|
+
function createScopedLogger(scopeName) {
|
|
317
|
+
return new DebugLogger({
|
|
318
|
+
prefix: `[Prepr][${scopeName}]`
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
// src/core/live-preview/field-name.ts
|
|
323
|
+
var UPPERCASE_BOUNDARY = /(.)(?=[A-Z])/g;
|
|
324
|
+
function graphqlFieldName(apiId) {
|
|
325
|
+
return apiId.replace(UPPERCASE_BOUNDARY, "$1_").toLowerCase();
|
|
326
|
+
}
|
|
327
|
+
var TEXT_BODY_FIELDS = [
|
|
328
|
+
{ name: "body", plain: false },
|
|
329
|
+
{ name: "html", plain: false },
|
|
330
|
+
{ name: "text", plain: true }
|
|
331
|
+
];
|
|
332
|
+
var TAG_PATTERN = /<[^>]+>/g;
|
|
333
|
+
function plainTextFromHtml(html) {
|
|
334
|
+
return html.replace(TAG_PATTERN, "");
|
|
335
|
+
}
|
|
336
|
+
function isTextEntry(record) {
|
|
337
|
+
const typename = record.__typename;
|
|
338
|
+
if (typeof typename === "string") return typename === "Text";
|
|
339
|
+
return "html" in record || "text" in record && "format" in record;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
// src/core/live-preview/index-snapshot.ts
|
|
343
|
+
var debug = createScopedLogger("live-preview");
|
|
344
|
+
function indexSnapshot(data) {
|
|
345
|
+
const index = /* @__PURE__ */ new Map();
|
|
346
|
+
const visited = /* @__PURE__ */ new WeakSet();
|
|
347
|
+
const path = [];
|
|
348
|
+
function walk2(node) {
|
|
349
|
+
if (node === null || typeof node !== "object") return;
|
|
350
|
+
if (visited.has(node)) return;
|
|
351
|
+
visited.add(node);
|
|
352
|
+
if (Array.isArray(node)) {
|
|
353
|
+
for (let i = 0; i < node.length; i++) {
|
|
354
|
+
path.push(i);
|
|
355
|
+
walk2(node[i]);
|
|
356
|
+
path.pop();
|
|
357
|
+
}
|
|
358
|
+
return;
|
|
359
|
+
}
|
|
360
|
+
const record = node;
|
|
361
|
+
if (typeof record._id === "string") {
|
|
362
|
+
const paths = index.get(record._id);
|
|
363
|
+
if (paths) paths.push([...path]);
|
|
364
|
+
else index.set(record._id, [[...path]]);
|
|
365
|
+
} else if (typeof record.__typename === "string") {
|
|
366
|
+
debug.log("item without _id will not live-update", {
|
|
367
|
+
__typename: record.__typename
|
|
368
|
+
});
|
|
369
|
+
}
|
|
370
|
+
for (const key in record) {
|
|
371
|
+
if (!Object.prototype.hasOwnProperty.call(record, key)) continue;
|
|
372
|
+
path.push(key);
|
|
373
|
+
walk2(record[key]);
|
|
374
|
+
path.pop();
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
walk2(data);
|
|
378
|
+
return index;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
// src/core/live-preview/patch.ts
|
|
382
|
+
var import_stega = require("@vercel/stega");
|
|
383
|
+
var FORBIDDEN_SEGMENTS = /* @__PURE__ */ new Set(["__proto__", "prototype", "constructor"]);
|
|
384
|
+
function isPlainObject(value) {
|
|
385
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
386
|
+
}
|
|
387
|
+
function mergeObject(current, incoming) {
|
|
388
|
+
let changed = false;
|
|
389
|
+
const next = { ...current };
|
|
390
|
+
for (const key of Object.keys(current)) {
|
|
391
|
+
if (!(key in incoming) || incoming[key] === void 0) continue;
|
|
392
|
+
const value = isPlainObject(current[key]) && isPlainObject(incoming[key]) ? mergeObject(current[key], incoming[key]) : incoming[key];
|
|
393
|
+
if (value !== current[key]) {
|
|
394
|
+
next[key] = value;
|
|
395
|
+
changed = true;
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
return changed ? next : current;
|
|
399
|
+
}
|
|
400
|
+
function shapeLike(template, incoming) {
|
|
401
|
+
const out = {};
|
|
402
|
+
for (const key of Object.keys(template)) {
|
|
403
|
+
const value = incoming[key];
|
|
404
|
+
out[key] = value === void 0 ? null : isPlainObject(template[key]) && isPlainObject(value) ? shapeLike(template[key], value) : value;
|
|
405
|
+
}
|
|
406
|
+
return out;
|
|
407
|
+
}
|
|
408
|
+
function mergeStructured(current, incoming) {
|
|
409
|
+
if (incoming === null || Array.isArray(incoming) && !incoming.length) {
|
|
410
|
+
if (Array.isArray(current)) return current.length ? [] : current;
|
|
411
|
+
return null;
|
|
412
|
+
}
|
|
413
|
+
const list = Array.isArray(incoming) ? incoming : [incoming];
|
|
414
|
+
if (current === null || current === void 0) return incoming;
|
|
415
|
+
if (Array.isArray(current)) {
|
|
416
|
+
const template = current.find(isPlainObject);
|
|
417
|
+
return list.map((entry) => {
|
|
418
|
+
const match = current.find(
|
|
419
|
+
(c) => isPlainObject(c) && c._id !== void 0 && c._id === entry._id
|
|
420
|
+
);
|
|
421
|
+
if (isPlainObject(match)) return mergeObject(match, entry);
|
|
422
|
+
return isPlainObject(template) ? shapeLike(template, entry) : entry;
|
|
423
|
+
});
|
|
424
|
+
}
|
|
425
|
+
if (isPlainObject(current)) return mergeObject(current, list[0]);
|
|
426
|
+
return current;
|
|
427
|
+
}
|
|
428
|
+
function isPatchable(current) {
|
|
429
|
+
return current === null || typeof current === "string" || typeof current === "number" || typeof current === "boolean";
|
|
430
|
+
}
|
|
431
|
+
function cloneNode(node) {
|
|
432
|
+
return Array.isArray(node) ? [...node] : { ...node };
|
|
433
|
+
}
|
|
434
|
+
function writeAtPath(root, fullPath, value, markChanged = () => {
|
|
435
|
+
}) {
|
|
436
|
+
if (!fullPath.length) return root;
|
|
437
|
+
if (fullPath.some((s) => FORBIDDEN_SEGMENTS.has(String(s)))) return root;
|
|
438
|
+
const last = fullPath.length - 1;
|
|
439
|
+
let node = root;
|
|
440
|
+
for (let i = 0; i < last; i++) {
|
|
441
|
+
if (node === null || typeof node !== "object") return root;
|
|
442
|
+
node = node[fullPath[i]];
|
|
443
|
+
}
|
|
444
|
+
if (node === null || typeof node !== "object") return root;
|
|
445
|
+
const container = node;
|
|
446
|
+
const key = fullPath[last];
|
|
447
|
+
if (!(key in container)) return root;
|
|
448
|
+
let next;
|
|
449
|
+
if (value === null || typeof value === "object") {
|
|
450
|
+
next = mergeStructured(container[key], value);
|
|
451
|
+
} else if (!isPatchable(container[key])) {
|
|
452
|
+
return root;
|
|
453
|
+
} else {
|
|
454
|
+
next = keepEditLink(container[key], value);
|
|
455
|
+
}
|
|
456
|
+
if (container[key] === next) return root;
|
|
457
|
+
const newRoot = cloneNode(root);
|
|
458
|
+
let cursor = newRoot;
|
|
459
|
+
for (let i = 0; i < last; i++) {
|
|
460
|
+
const child = cloneNode(cursor[fullPath[i]]);
|
|
461
|
+
cursor[fullPath[i]] = child;
|
|
462
|
+
cursor = child;
|
|
463
|
+
}
|
|
464
|
+
cursor[key] = next;
|
|
465
|
+
markChanged();
|
|
466
|
+
return newRoot;
|
|
467
|
+
}
|
|
468
|
+
function listKeysOf(entry) {
|
|
469
|
+
if (!isPlainObject(entry)) return [];
|
|
470
|
+
const keys = [];
|
|
471
|
+
if (typeof entry._id === "string") keys.push(entry._id);
|
|
472
|
+
const first = Array.isArray(entry.items) ? entry.items[0] : null;
|
|
473
|
+
if (isPlainObject(first) && typeof first._id === "string") {
|
|
474
|
+
keys.push(first._id);
|
|
475
|
+
}
|
|
476
|
+
return keys;
|
|
477
|
+
}
|
|
478
|
+
function buildText(entry, template) {
|
|
479
|
+
const body = typeof entry.body === "string" ? entry.body : "";
|
|
480
|
+
const full = {
|
|
481
|
+
__typename: "Text",
|
|
482
|
+
_id: entry._id,
|
|
483
|
+
body,
|
|
484
|
+
html: body,
|
|
485
|
+
text: plainTextFromHtml(body),
|
|
486
|
+
format: entry.format ?? null
|
|
487
|
+
};
|
|
488
|
+
if (!template) return full;
|
|
489
|
+
const out = {};
|
|
490
|
+
for (const key of Object.keys(template)) {
|
|
491
|
+
out[key] = key in full ? full[key] : null;
|
|
492
|
+
}
|
|
493
|
+
return out;
|
|
494
|
+
}
|
|
495
|
+
function syncList(current, entries, build) {
|
|
496
|
+
if (current === null || current === void 0) {
|
|
497
|
+
const built = syncList([], entries, build);
|
|
498
|
+
return built.length ? built : current;
|
|
499
|
+
}
|
|
500
|
+
if (!Array.isArray(current)) return current;
|
|
501
|
+
const byKey = /* @__PURE__ */ new Map();
|
|
502
|
+
const templates = /* @__PURE__ */ new Map();
|
|
503
|
+
for (const c of current) {
|
|
504
|
+
for (const key of listKeysOf(c)) byKey.set(key, c);
|
|
505
|
+
if (isPlainObject(c) && typeof c.__typename === "string") {
|
|
506
|
+
if (!templates.has(c.__typename)) templates.set(c.__typename, c);
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
if (!entries.length) return current.length ? [] : current;
|
|
510
|
+
if (current.length && !byKey.size) return current;
|
|
511
|
+
if (current.length && !entries.some((e) => byKey.has(e._id))) return current;
|
|
512
|
+
const next = [];
|
|
513
|
+
for (const entry of entries) {
|
|
514
|
+
const existing = byKey.get(entry._id);
|
|
515
|
+
const built = existing === void 0 && entry.fields ? build?.(entry) : void 0;
|
|
516
|
+
if (existing !== void 0) {
|
|
517
|
+
next.push(existing);
|
|
518
|
+
} else if (built) {
|
|
519
|
+
next.push(built);
|
|
520
|
+
} else if (entry.__typename === "Text") {
|
|
521
|
+
next.push(buildText(entry, templates.get("Text")));
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
const same = next.length === current.length && next.every((n, i) => n === current[i]);
|
|
525
|
+
return same ? current : next;
|
|
526
|
+
}
|
|
527
|
+
function syncListAtPath(root, fullPath, entries, build) {
|
|
528
|
+
if (!fullPath.length) return root;
|
|
529
|
+
if (fullPath.some((s) => FORBIDDEN_SEGMENTS.has(String(s)))) return root;
|
|
530
|
+
let node = root;
|
|
531
|
+
for (const key of fullPath) {
|
|
532
|
+
node = node !== null && typeof node === "object" ? node[key] : void 0;
|
|
533
|
+
}
|
|
534
|
+
const next = syncList(node, entries, build);
|
|
535
|
+
if (next === node) return root;
|
|
536
|
+
const newRoot = cloneNode(root);
|
|
537
|
+
let cursor = newRoot;
|
|
538
|
+
for (let i = 0; i < fullPath.length - 1; i++) {
|
|
539
|
+
const child = cloneNode(cursor[fullPath[i]]);
|
|
540
|
+
cursor[fullPath[i]] = child;
|
|
541
|
+
cursor = child;
|
|
542
|
+
}
|
|
543
|
+
cursor[fullPath[fullPath.length - 1]] = next;
|
|
544
|
+
return newRoot;
|
|
545
|
+
}
|
|
546
|
+
function keepEditLink(current, value) {
|
|
547
|
+
if (typeof current !== "string" || typeof value !== "string") return value;
|
|
548
|
+
const { encoded } = (0, import_stega.vercelStegaSplit)(current);
|
|
549
|
+
if (!encoded || (0, import_stega.vercelStegaSplit)(value).encoded) return value;
|
|
550
|
+
return value + encoded;
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
// src/core/live-preview/query-document.ts
|
|
554
|
+
var NAME_START = /[_A-Za-z]/;
|
|
555
|
+
var NAME_CONTINUE = /[_0-9A-Za-z]/;
|
|
556
|
+
var PUNCT = /* @__PURE__ */ new Set([
|
|
557
|
+
"!",
|
|
558
|
+
"$",
|
|
559
|
+
"&",
|
|
560
|
+
"(",
|
|
561
|
+
")",
|
|
562
|
+
":",
|
|
563
|
+
"=",
|
|
564
|
+
"@",
|
|
565
|
+
"[",
|
|
566
|
+
"]",
|
|
567
|
+
"{",
|
|
568
|
+
"|",
|
|
569
|
+
"}"
|
|
570
|
+
]);
|
|
571
|
+
function tokenize(source) {
|
|
572
|
+
const tokens = [];
|
|
573
|
+
let i = 0;
|
|
574
|
+
const n = source.length;
|
|
575
|
+
while (i < n) {
|
|
576
|
+
const ch = source[i];
|
|
577
|
+
if (ch === " " || ch === " " || ch === "\n" || ch === "\r" || ch === "," || ch === "\uFEFF") {
|
|
578
|
+
i++;
|
|
579
|
+
} else if (ch === "#") {
|
|
580
|
+
while (i < n && source[i] !== "\n" && source[i] !== "\r") i++;
|
|
581
|
+
} else if (ch === "." && source.startsWith("...", i)) {
|
|
582
|
+
tokens.push({ type: "punct", value: "..." });
|
|
583
|
+
i += 3;
|
|
584
|
+
} else if (PUNCT.has(ch)) {
|
|
585
|
+
tokens.push({ type: "punct", value: ch });
|
|
586
|
+
i++;
|
|
587
|
+
} else if (NAME_START.test(ch)) {
|
|
588
|
+
const start = i;
|
|
589
|
+
while (i < n && NAME_CONTINUE.test(source[i])) i++;
|
|
590
|
+
tokens.push({ type: "name", value: source.slice(start, i) });
|
|
591
|
+
} else if (ch === '"') {
|
|
592
|
+
if (source.startsWith('"""', i)) {
|
|
593
|
+
i += 3;
|
|
594
|
+
while (i < n && !source.startsWith('"""', i)) {
|
|
595
|
+
i += source.startsWith('\\"""', i) ? 4 : 1;
|
|
596
|
+
}
|
|
597
|
+
if (i >= n) throw new SyntaxError("Unterminated block string");
|
|
598
|
+
i += 3;
|
|
599
|
+
} else {
|
|
600
|
+
i++;
|
|
601
|
+
while (i < n && source[i] !== '"') {
|
|
602
|
+
if (source[i] === "\n" || source[i] === "\r") {
|
|
603
|
+
throw new SyntaxError("Unterminated string");
|
|
604
|
+
}
|
|
605
|
+
i += source[i] === "\\" ? 2 : 1;
|
|
606
|
+
}
|
|
607
|
+
if (i >= n) throw new SyntaxError("Unterminated string");
|
|
608
|
+
i++;
|
|
609
|
+
}
|
|
610
|
+
tokens.push({ type: "value" });
|
|
611
|
+
} else if (ch === "-" || ch >= "0" && ch <= "9") {
|
|
612
|
+
i++;
|
|
613
|
+
while (i < n && /[0-9.eE+-]/.test(source[i])) i++;
|
|
614
|
+
tokens.push({ type: "value" });
|
|
615
|
+
} else {
|
|
616
|
+
throw new SyntaxError(`Unexpected character "${ch}"`);
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
return tokens;
|
|
620
|
+
}
|
|
621
|
+
function parseSource(source, operationName) {
|
|
622
|
+
const tokens = tokenize(source);
|
|
623
|
+
let pos = 0;
|
|
624
|
+
const peek = () => tokens[pos];
|
|
625
|
+
const isPunct = (value) => {
|
|
626
|
+
const t = tokens[pos];
|
|
627
|
+
return t?.type === "punct" && t.value === value;
|
|
628
|
+
};
|
|
629
|
+
const expectPunct = (value) => {
|
|
630
|
+
if (!isPunct(value)) throw new SyntaxError(`Expected "${value}"`);
|
|
631
|
+
pos++;
|
|
632
|
+
};
|
|
633
|
+
const expectName = () => {
|
|
634
|
+
const t = tokens[pos];
|
|
635
|
+
if (t?.type !== "name") throw new SyntaxError("Expected a name");
|
|
636
|
+
pos++;
|
|
637
|
+
return t.value;
|
|
638
|
+
};
|
|
639
|
+
const skipParens = () => {
|
|
640
|
+
expectPunct("(");
|
|
641
|
+
let depth = 1;
|
|
642
|
+
while (depth > 0) {
|
|
643
|
+
const t = tokens[pos++];
|
|
644
|
+
if (!t) throw new SyntaxError("Unbalanced parentheses");
|
|
645
|
+
if (t.type === "punct" && t.value === "(") depth++;
|
|
646
|
+
else if (t.type === "punct" && t.value === ")") depth--;
|
|
647
|
+
}
|
|
648
|
+
};
|
|
649
|
+
const skipDirectives = () => {
|
|
650
|
+
while (isPunct("@")) {
|
|
651
|
+
pos++;
|
|
652
|
+
expectName();
|
|
653
|
+
if (isPunct("(")) skipParens();
|
|
654
|
+
}
|
|
655
|
+
};
|
|
656
|
+
const parseSelectionSet = () => {
|
|
657
|
+
expectPunct("{");
|
|
658
|
+
const selections = [];
|
|
659
|
+
while (!isPunct("}")) {
|
|
660
|
+
if (!peek()) throw new SyntaxError("Unterminated selection set");
|
|
661
|
+
selections.push(parseSelection());
|
|
662
|
+
}
|
|
663
|
+
pos++;
|
|
664
|
+
return selections;
|
|
665
|
+
};
|
|
666
|
+
const parseSelection = () => {
|
|
667
|
+
if (isPunct("...")) {
|
|
668
|
+
pos++;
|
|
669
|
+
const t = peek();
|
|
670
|
+
if (t?.type === "name" && t.value !== "on") {
|
|
671
|
+
pos++;
|
|
672
|
+
skipDirectives();
|
|
673
|
+
return { kind: "spread", name: t.value };
|
|
674
|
+
}
|
|
675
|
+
let on = null;
|
|
676
|
+
if (t?.type === "name") {
|
|
677
|
+
pos++;
|
|
678
|
+
on = expectName();
|
|
679
|
+
}
|
|
680
|
+
skipDirectives();
|
|
681
|
+
return { kind: "inline", on, selections: parseSelectionSet() };
|
|
682
|
+
}
|
|
683
|
+
let name = expectName();
|
|
684
|
+
const key = name;
|
|
685
|
+
if (isPunct(":")) {
|
|
686
|
+
pos++;
|
|
687
|
+
name = expectName();
|
|
688
|
+
}
|
|
689
|
+
let hasArgs = false;
|
|
690
|
+
if (isPunct("(")) {
|
|
691
|
+
hasArgs = true;
|
|
692
|
+
skipParens();
|
|
693
|
+
}
|
|
694
|
+
skipDirectives();
|
|
695
|
+
const selections = isPunct("{") ? parseSelectionSet() : null;
|
|
696
|
+
return { kind: "field", name, key, hasArgs, selections };
|
|
697
|
+
};
|
|
698
|
+
const fragments = /* @__PURE__ */ new Map();
|
|
699
|
+
const operations = [];
|
|
700
|
+
while (pos < tokens.length) {
|
|
701
|
+
if (isPunct("{")) {
|
|
702
|
+
operations.push({ name: null, selections: parseSelectionSet() });
|
|
703
|
+
continue;
|
|
704
|
+
}
|
|
705
|
+
const keyword = expectName();
|
|
706
|
+
if (keyword === "fragment") {
|
|
707
|
+
const name = expectName();
|
|
708
|
+
if (expectName() !== "on") throw new SyntaxError('Expected "on"');
|
|
709
|
+
const on = expectName();
|
|
710
|
+
skipDirectives();
|
|
711
|
+
fragments.set(name, { on, selections: parseSelectionSet() });
|
|
712
|
+
} else if (keyword === "query" || keyword === "mutation" || keyword === "subscription") {
|
|
713
|
+
const t = peek();
|
|
714
|
+
let name = null;
|
|
715
|
+
if (t?.type === "name") name = expectName();
|
|
716
|
+
if (isPunct("(")) skipParens();
|
|
717
|
+
skipDirectives();
|
|
718
|
+
operations.push({ name, selections: parseSelectionSet() });
|
|
719
|
+
} else {
|
|
720
|
+
throw new SyntaxError(`Unexpected "${keyword}"`);
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
return { operation: pickOperation(operations, operationName), fragments };
|
|
724
|
+
}
|
|
725
|
+
function pickOperation(operations, operationName) {
|
|
726
|
+
const op = operationName ? operations.find((o) => o.name === operationName) : operations[0];
|
|
727
|
+
if (!op) throw new SyntaxError("The document has no operation");
|
|
728
|
+
return op.selections;
|
|
729
|
+
}
|
|
730
|
+
function fromAstSelections(set) {
|
|
731
|
+
return set.selections.map((s) => {
|
|
732
|
+
if (s.kind === "FragmentSpread")
|
|
733
|
+
return { kind: "spread", name: s.name.value };
|
|
734
|
+
if (s.kind === "InlineFragment") {
|
|
735
|
+
return {
|
|
736
|
+
kind: "inline",
|
|
737
|
+
on: s.typeCondition?.name.value ?? null,
|
|
738
|
+
selections: fromAstSelections(s.selectionSet)
|
|
739
|
+
};
|
|
740
|
+
}
|
|
741
|
+
const name = s.name.value;
|
|
742
|
+
return {
|
|
743
|
+
kind: "field",
|
|
744
|
+
name,
|
|
745
|
+
key: s.alias?.value ?? name,
|
|
746
|
+
hasArgs: Boolean(s.arguments?.length),
|
|
747
|
+
selections: s.selectionSet ? fromAstSelections(s.selectionSet) : null
|
|
748
|
+
};
|
|
749
|
+
});
|
|
750
|
+
}
|
|
751
|
+
function fromAst(doc, operationName) {
|
|
752
|
+
const fragments = /* @__PURE__ */ new Map();
|
|
753
|
+
const operations = [];
|
|
754
|
+
for (const def of doc.definitions ?? []) {
|
|
755
|
+
if (def.kind === "FragmentDefinition" && def.name && def.typeCondition && def.selectionSet) {
|
|
756
|
+
fragments.set(def.name.value, {
|
|
757
|
+
on: def.typeCondition.name.value,
|
|
758
|
+
selections: fromAstSelections(def.selectionSet)
|
|
759
|
+
});
|
|
760
|
+
} else if (def.kind === "OperationDefinition" && def.selectionSet) {
|
|
761
|
+
operations.push({
|
|
762
|
+
name: def.name?.value ?? null,
|
|
763
|
+
selections: fromAstSelections(def.selectionSet)
|
|
764
|
+
});
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
return { operation: pickOperation(operations, operationName), fragments };
|
|
768
|
+
}
|
|
769
|
+
var astCache = /* @__PURE__ */ new WeakMap();
|
|
770
|
+
var sourceCache = /* @__PURE__ */ new Map();
|
|
771
|
+
var SOURCE_CACHE_LIMIT = 200;
|
|
772
|
+
function readQueryDocument(query, operationName) {
|
|
773
|
+
const cacheKey = operationName ?? "";
|
|
774
|
+
if (typeof query === "object" && query !== null && query.kind === "Document") {
|
|
775
|
+
let byName = astCache.get(query);
|
|
776
|
+
if (!byName) astCache.set(query, byName = /* @__PURE__ */ new Map());
|
|
777
|
+
let parsed2 = byName.get(cacheKey);
|
|
778
|
+
if (!parsed2) {
|
|
779
|
+
parsed2 = fromAst(
|
|
780
|
+
query,
|
|
781
|
+
operationName
|
|
782
|
+
);
|
|
783
|
+
byName.set(cacheKey, parsed2);
|
|
784
|
+
}
|
|
785
|
+
return parsed2;
|
|
786
|
+
}
|
|
787
|
+
const source = String(query);
|
|
788
|
+
const sourceKey = `${cacheKey}
|
|
789
|
+
${source}`;
|
|
790
|
+
let parsed = sourceCache.get(sourceKey);
|
|
791
|
+
if (!parsed) {
|
|
792
|
+
parsed = parseSource(source, operationName);
|
|
793
|
+
if (sourceCache.size >= SOURCE_CACHE_LIMIT) {
|
|
794
|
+
sourceCache.delete(sourceCache.keys().next().value);
|
|
795
|
+
}
|
|
796
|
+
sourceCache.set(sourceKey, parsed);
|
|
797
|
+
}
|
|
798
|
+
return parsed;
|
|
799
|
+
}
|
|
800
|
+
var fieldsCache = /* @__PURE__ */ new WeakMap();
|
|
801
|
+
function collectFields(selections, typename, doc, options = {}) {
|
|
802
|
+
const cacheKey = `${options.strict ? "s" : "l"}:${typename ?? ""}`;
|
|
803
|
+
let cached = fieldsCache.get(selections);
|
|
804
|
+
if (!cached) {
|
|
805
|
+
cached = /* @__PURE__ */ new Map();
|
|
806
|
+
fieldsCache.set(selections, cached);
|
|
807
|
+
}
|
|
808
|
+
const hit = cached.get(cacheKey);
|
|
809
|
+
if (hit) return hit;
|
|
810
|
+
const fields = resolveFields(selections, typename, doc, options);
|
|
811
|
+
cached.set(cacheKey, fields);
|
|
812
|
+
return fields;
|
|
813
|
+
}
|
|
814
|
+
function resolveFields(selections, typename, doc, options) {
|
|
815
|
+
const exact = /* @__PURE__ */ new Map();
|
|
816
|
+
const loose = /* @__PURE__ */ new Map();
|
|
817
|
+
const merged = /* @__PURE__ */ new Map();
|
|
818
|
+
const walkedMatched = /* @__PURE__ */ new Set();
|
|
819
|
+
const walkedLoose = /* @__PURE__ */ new Set();
|
|
820
|
+
const add = (target, s) => {
|
|
821
|
+
let field = target.get(s.key);
|
|
822
|
+
if (!field) {
|
|
823
|
+
field = { name: s.name, key: s.key, hasArgs: s.hasArgs, selections: [] };
|
|
824
|
+
target.set(s.key, field);
|
|
825
|
+
merged.set(field, /* @__PURE__ */ new Set());
|
|
826
|
+
}
|
|
827
|
+
const done = merged.get(field);
|
|
828
|
+
if (s.selections && !done.has(s.selections)) {
|
|
829
|
+
done.add(s.selections);
|
|
830
|
+
field.selections = [...field.selections, ...s.selections];
|
|
831
|
+
}
|
|
832
|
+
};
|
|
833
|
+
const applies = (on, list) => conditionMatches(on, typename) || typename !== void 0 && typeConditions(list, doc).includes(typename);
|
|
834
|
+
const walk2 = (list, matched) => {
|
|
835
|
+
for (const s of list) {
|
|
836
|
+
if (s.kind === "field") {
|
|
837
|
+
add(matched ? exact : loose, s);
|
|
838
|
+
} else if (s.kind === "inline") {
|
|
839
|
+
walk2(s.selections, matched && applies(s.on, s.selections));
|
|
840
|
+
} else {
|
|
841
|
+
const fragment = doc.fragments.get(s.name);
|
|
842
|
+
if (!fragment) continue;
|
|
843
|
+
const asMatched = matched && applies(fragment.on, fragment.selections);
|
|
844
|
+
if (walkedMatched.has(fragment)) continue;
|
|
845
|
+
if (!asMatched && walkedLoose.has(fragment)) continue;
|
|
846
|
+
(asMatched ? walkedMatched : walkedLoose).add(fragment);
|
|
847
|
+
walk2(fragment.selections, asMatched);
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
};
|
|
851
|
+
walk2(selections, true);
|
|
852
|
+
if (!options.strict) {
|
|
853
|
+
for (const [key, field] of loose) {
|
|
854
|
+
if (!exact.has(key)) exact.set(key, field);
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
return exact;
|
|
858
|
+
}
|
|
859
|
+
function conditionMatches(on, typename) {
|
|
860
|
+
return on === null || typename === void 0 || on === typename;
|
|
861
|
+
}
|
|
862
|
+
var conditionsCache = /* @__PURE__ */ new WeakMap();
|
|
863
|
+
function typeConditions(selections, doc) {
|
|
864
|
+
const hit = conditionsCache.get(selections);
|
|
865
|
+
if (hit) return hit;
|
|
866
|
+
const names = /* @__PURE__ */ new Set();
|
|
867
|
+
const seen = /* @__PURE__ */ new Set();
|
|
868
|
+
const walk2 = (list) => {
|
|
869
|
+
for (const s of list) {
|
|
870
|
+
if (s.kind === "inline") {
|
|
871
|
+
if (s.on) names.add(s.on);
|
|
872
|
+
walk2(s.selections);
|
|
873
|
+
} else if (s.kind === "spread") {
|
|
874
|
+
const fragment = doc.fragments.get(s.name);
|
|
875
|
+
if (!fragment || seen.has(fragment)) continue;
|
|
876
|
+
seen.add(fragment);
|
|
877
|
+
names.add(fragment.on);
|
|
878
|
+
walk2(fragment.selections);
|
|
879
|
+
}
|
|
880
|
+
}
|
|
881
|
+
};
|
|
882
|
+
walk2(selections);
|
|
883
|
+
const conditions = [...names];
|
|
884
|
+
conditionsCache.set(selections, conditions);
|
|
885
|
+
return conditions;
|
|
886
|
+
}
|
|
887
|
+
|
|
888
|
+
// src/core/live-preview/validate.ts
|
|
889
|
+
function isPlainRecord(v) {
|
|
890
|
+
return v !== null && typeof v === "object" && Object.getPrototypeOf(v) === Object.prototype;
|
|
891
|
+
}
|
|
892
|
+
|
|
893
|
+
// src/core/live-preview/normalize-query.ts
|
|
894
|
+
var debug2 = createScopedLogger("live-preview:normalize");
|
|
895
|
+
var INDEX_SEGMENT = /^\d+$/;
|
|
896
|
+
var FORBIDDEN_SEGMENTS2 = /* @__PURE__ */ new Set(["__proto__", "prototype", "constructor"]);
|
|
897
|
+
var ENVELOPE_KEYS = /* @__PURE__ */ new Set(["data", "errors", "extensions"]);
|
|
898
|
+
function applyPatchLog(query, result, log, operationName) {
|
|
899
|
+
if (!log.length || result === null || typeof result !== "object") {
|
|
900
|
+
return result;
|
|
901
|
+
}
|
|
902
|
+
if (isEnvelope(result)) {
|
|
903
|
+
const data = applyPatchLog(query, result.data, log, operationName);
|
|
904
|
+
return data === result.data ? result : { ...result, data };
|
|
905
|
+
}
|
|
906
|
+
let doc = null;
|
|
907
|
+
try {
|
|
908
|
+
doc = readQueryDocument(query, operationName);
|
|
909
|
+
} catch (error) {
|
|
910
|
+
debug2.log("could not read the query; applying fields by literal path", {
|
|
911
|
+
error: String(error)
|
|
912
|
+
});
|
|
913
|
+
}
|
|
914
|
+
let root = result;
|
|
915
|
+
let index = null;
|
|
916
|
+
for (const patch of log) {
|
|
917
|
+
try {
|
|
918
|
+
index ?? (index = indexSnapshot(root));
|
|
919
|
+
const next = applyPatch(root, index, patch, doc, result);
|
|
920
|
+
if (next !== root) {
|
|
921
|
+
root = next;
|
|
922
|
+
if (patch.type === "list" || !isScalarValue(patch.value)) {
|
|
923
|
+
index = null;
|
|
924
|
+
}
|
|
925
|
+
}
|
|
926
|
+
} catch (error) {
|
|
927
|
+
debug2.log("could not apply a change", {
|
|
928
|
+
itemId: patch.itemId,
|
|
929
|
+
field: patch.field,
|
|
930
|
+
error: String(error)
|
|
931
|
+
});
|
|
932
|
+
}
|
|
933
|
+
}
|
|
934
|
+
return root;
|
|
935
|
+
}
|
|
936
|
+
function isScalarValue(value) {
|
|
937
|
+
return value === null || typeof value !== "object";
|
|
938
|
+
}
|
|
939
|
+
function applyPatch(root, index, patch, doc, result) {
|
|
940
|
+
const ownerPaths = index.get(patch.itemId);
|
|
941
|
+
if (!ownerPaths?.length) return root;
|
|
942
|
+
const segments = patch.field.split(".");
|
|
943
|
+
if (segments.some((s) => !s || FORBIDDEN_SEGMENTS2.has(s))) return root;
|
|
944
|
+
const targets = [];
|
|
945
|
+
const plain = /* @__PURE__ */ new Set();
|
|
946
|
+
for (const ownerPath of ownerPaths) {
|
|
947
|
+
if (doc) {
|
|
948
|
+
const resolved = resolveTargets(root, doc, ownerPath, segments);
|
|
949
|
+
root = resolved.root;
|
|
950
|
+
targets.push(...resolved.targets);
|
|
951
|
+
resolved.plain.forEach((target) => plain.add(target));
|
|
952
|
+
} else {
|
|
953
|
+
targets.push([...ownerPath, ...segments.map(toPathSegment)]);
|
|
954
|
+
}
|
|
955
|
+
}
|
|
956
|
+
if (!targets.length) {
|
|
957
|
+
debug2.log("no field in the query matches", {
|
|
958
|
+
itemId: patch.itemId,
|
|
959
|
+
field: patch.field
|
|
960
|
+
});
|
|
961
|
+
return root;
|
|
962
|
+
}
|
|
963
|
+
if (patch.type === "field") {
|
|
964
|
+
for (const target of targets) {
|
|
965
|
+
const pushed = plain.has(target) && typeof patch.value === "string" ? plainTextFromHtml(patch.value) : patch.value;
|
|
966
|
+
let value = keepEditLink(readAtPath(root, target), pushed);
|
|
967
|
+
if (patch.edit && typeof value === "string" && !(0, import_stega2.vercelStegaSplit)(value).encoded) {
|
|
968
|
+
value = editLinksFor(result, patch.edit.item)?.encode(
|
|
969
|
+
value,
|
|
970
|
+
patch.edit.field
|
|
971
|
+
) ?? value;
|
|
972
|
+
}
|
|
973
|
+
root = writeAtPath(root, target, value);
|
|
974
|
+
}
|
|
975
|
+
} else {
|
|
976
|
+
for (const target of targets) {
|
|
977
|
+
const selections = doc ? selectionsAt(root, doc, target) : null;
|
|
978
|
+
const build = doc && selections ? (entry) => buildEntry(doc, selections, entry, {
|
|
979
|
+
links: editLinks(result, entry),
|
|
980
|
+
lists: listKeysIn(result)
|
|
981
|
+
}) : void 0;
|
|
982
|
+
root = syncListAtPath(root, target, patch.entries, build);
|
|
983
|
+
}
|
|
984
|
+
}
|
|
985
|
+
return root;
|
|
986
|
+
}
|
|
987
|
+
function readAtPath(root, path) {
|
|
988
|
+
let node = root;
|
|
989
|
+
for (const step of path) {
|
|
990
|
+
if (node === null || typeof node !== "object") return void 0;
|
|
991
|
+
node = node[step];
|
|
992
|
+
}
|
|
993
|
+
return node;
|
|
994
|
+
}
|
|
995
|
+
function isEnvelope(value) {
|
|
996
|
+
if (Array.isArray(value) || !("data" in value)) return false;
|
|
997
|
+
return Object.keys(value).every((key) => ENVELOPE_KEYS.has(key));
|
|
998
|
+
}
|
|
999
|
+
function toPathSegment(segment) {
|
|
1000
|
+
return INDEX_SEGMENT.test(segment) ? Number(segment) : segment;
|
|
1001
|
+
}
|
|
1002
|
+
function typenameOf(node) {
|
|
1003
|
+
const typename = node.__typename;
|
|
1004
|
+
return typeof typename === "string" ? typename : void 0;
|
|
1005
|
+
}
|
|
1006
|
+
function selectionsAt(root, doc, path) {
|
|
1007
|
+
let node = root;
|
|
1008
|
+
let selections = doc.operation;
|
|
1009
|
+
for (const step of path) {
|
|
1010
|
+
if (Array.isArray(node)) {
|
|
1011
|
+
node = node[step];
|
|
1012
|
+
continue;
|
|
1013
|
+
}
|
|
1014
|
+
if (node === null || typeof node !== "object") return null;
|
|
1015
|
+
const field = collectFields(selections, typenameOf(node), doc).get(
|
|
1016
|
+
String(step)
|
|
1017
|
+
);
|
|
1018
|
+
if (!field) return null;
|
|
1019
|
+
selections = field.selections;
|
|
1020
|
+
node = node[String(step)];
|
|
1021
|
+
}
|
|
1022
|
+
return selections;
|
|
1023
|
+
}
|
|
1024
|
+
function resolveTargets(root, doc, ownerPath, segments) {
|
|
1025
|
+
let owner = root;
|
|
1026
|
+
for (const step of ownerPath) {
|
|
1027
|
+
owner = owner[step];
|
|
1028
|
+
}
|
|
1029
|
+
const selections = selectionsAt(root, doc, ownerPath);
|
|
1030
|
+
if (!selections) return { root, targets: [], plain: /* @__PURE__ */ new Set() };
|
|
1031
|
+
let current = root;
|
|
1032
|
+
const out = [];
|
|
1033
|
+
const plain = /* @__PURE__ */ new Set();
|
|
1034
|
+
const walk2 = (node, sel, i, path) => {
|
|
1035
|
+
if (i === segments.length) {
|
|
1036
|
+
out.push(path);
|
|
1037
|
+
return;
|
|
1038
|
+
}
|
|
1039
|
+
const segment = segments[i];
|
|
1040
|
+
if (Array.isArray(node)) {
|
|
1041
|
+
if (INDEX_SEGMENT.test(segment)) {
|
|
1042
|
+
const position = Number(segment);
|
|
1043
|
+
if (position < node.length) {
|
|
1044
|
+
walk2(node[position], sel, i + 1, [...path, position]);
|
|
1045
|
+
}
|
|
1046
|
+
} else if (segment === "items") {
|
|
1047
|
+
walk2(node, sel, i + 1, path);
|
|
1048
|
+
}
|
|
1049
|
+
return;
|
|
1050
|
+
}
|
|
1051
|
+
if (node === null || typeof node !== "object") return;
|
|
1052
|
+
const record = node;
|
|
1053
|
+
const wanted = graphqlFieldName(segment);
|
|
1054
|
+
const textBody = i === segments.length - 1 && segment === "body" && isTextEntry(record) ? TEXT_BODY_FIELDS : null;
|
|
1055
|
+
let matched = false;
|
|
1056
|
+
for (const field of collectFields(sel, typenameOf(node), doc).values()) {
|
|
1057
|
+
const alias = textBody?.find((f) => f.name === field.name);
|
|
1058
|
+
if (field.name !== segment && field.name !== wanted && !alias) continue;
|
|
1059
|
+
if (!Object.prototype.hasOwnProperty.call(record, field.key)) continue;
|
|
1060
|
+
matched = true;
|
|
1061
|
+
const fieldPath = [...path, field.key];
|
|
1062
|
+
if (alias?.plain) plain.add(fieldPath);
|
|
1063
|
+
let value = record[field.key];
|
|
1064
|
+
const next = segments[i + 1];
|
|
1065
|
+
if (value === null && field.selections.length && next !== void 0 && next !== "items" && !INDEX_SEGMENT.test(next)) {
|
|
1066
|
+
const typename = resolveTypename(
|
|
1067
|
+
doc,
|
|
1068
|
+
field.selections,
|
|
1069
|
+
void 0,
|
|
1070
|
+
void 0
|
|
1071
|
+
);
|
|
1072
|
+
if (typename !== void 0) {
|
|
1073
|
+
value = fillObject(doc, field.selections, typename, {}, void 0, {
|
|
1074
|
+
links: null,
|
|
1075
|
+
lists: listKeysIn(root)
|
|
1076
|
+
});
|
|
1077
|
+
current = writeAtPath(current, fieldPath, value);
|
|
1078
|
+
}
|
|
1079
|
+
}
|
|
1080
|
+
walk2(value, field.selections, i + 1, fieldPath);
|
|
1081
|
+
}
|
|
1082
|
+
if (!matched && segment === "items") walk2(node, sel, i + 1, path);
|
|
1083
|
+
};
|
|
1084
|
+
walk2(owner, selections, 0, ownerPath);
|
|
1085
|
+
return { root: current, targets: out, plain };
|
|
1086
|
+
}
|
|
1087
|
+
var NON_ALPHANUMERIC = /[^a-z0-9]/gi;
|
|
1088
|
+
var typeKey = (name) => name.replace(NON_ALPHANUMERIC, "").toLowerCase();
|
|
1089
|
+
function resolveTypename(doc, selections, typename, typeName) {
|
|
1090
|
+
const known = typeConditions(selections, doc);
|
|
1091
|
+
const explicit = typeof typename === "string" ? typename : void 0;
|
|
1092
|
+
if (!known.length) return explicit ?? null;
|
|
1093
|
+
if (explicit && known.includes(explicit)) return explicit;
|
|
1094
|
+
for (const candidate of [explicit, typeName]) {
|
|
1095
|
+
if (typeof candidate !== "string" || !candidate) continue;
|
|
1096
|
+
const match = known.find((name) => typeKey(name) === typeKey(candidate));
|
|
1097
|
+
if (match) return match;
|
|
1098
|
+
}
|
|
1099
|
+
const named = explicit !== void 0 || typeof typeName === "string";
|
|
1100
|
+
return known.length === 1 && !named ? known[0] : void 0;
|
|
1101
|
+
}
|
|
1102
|
+
function buildEntry(doc, selections, entry, ctx) {
|
|
1103
|
+
const typename = resolveTypename(
|
|
1104
|
+
doc,
|
|
1105
|
+
selections,
|
|
1106
|
+
entry.__typename,
|
|
1107
|
+
entry.typeName
|
|
1108
|
+
);
|
|
1109
|
+
if (typename === void 0) return void 0;
|
|
1110
|
+
return fillObject(
|
|
1111
|
+
doc,
|
|
1112
|
+
selections,
|
|
1113
|
+
typename,
|
|
1114
|
+
entry.fields ?? {},
|
|
1115
|
+
entry._id,
|
|
1116
|
+
ctx
|
|
1117
|
+
);
|
|
1118
|
+
}
|
|
1119
|
+
function fillObject(doc, selections, typename, values, id, ctx) {
|
|
1120
|
+
const out = {};
|
|
1121
|
+
const { links } = ctx;
|
|
1122
|
+
const lists = ctx.lists(typename);
|
|
1123
|
+
const edit = isPlainRecord(values.__edit) ? values.__edit : null;
|
|
1124
|
+
const apiIdOf = /* @__PURE__ */ new Map();
|
|
1125
|
+
for (const key of Object.keys(values)) {
|
|
1126
|
+
apiIdOf.set(key, key);
|
|
1127
|
+
const name = graphqlFieldName(key);
|
|
1128
|
+
if (!apiIdOf.has(name)) apiIdOf.set(name, key);
|
|
1129
|
+
}
|
|
1130
|
+
if (edit && isPlainRecord(edit.apiIds)) {
|
|
1131
|
+
for (const [name, apiId] of Object.entries(edit.apiIds)) {
|
|
1132
|
+
if (typeof apiId === "string") apiIdOf.set(name, apiId);
|
|
1133
|
+
}
|
|
1134
|
+
}
|
|
1135
|
+
const valueOf = (name) => {
|
|
1136
|
+
if (Object.prototype.hasOwnProperty.call(values, name)) return values[name];
|
|
1137
|
+
const key = apiIdOf.get(name);
|
|
1138
|
+
return key !== void 0 && key in values ? values[key] : void 0;
|
|
1139
|
+
};
|
|
1140
|
+
const editField = (name) => {
|
|
1141
|
+
if (!edit) return null;
|
|
1142
|
+
if (typeof edit.field === "string")
|
|
1143
|
+
return name === "body" ? edit.field : null;
|
|
1144
|
+
if (typeof edit.path !== "string") return null;
|
|
1145
|
+
const apiId = apiIdOf.get(name) ?? name;
|
|
1146
|
+
const text = Array.isArray(edit.text) ? edit.text : [];
|
|
1147
|
+
if (!text.includes(apiId) && !text.includes(name)) return null;
|
|
1148
|
+
return `${edit.path}.items.${apiId}`;
|
|
1149
|
+
};
|
|
1150
|
+
const fields = collectFields(selections, typename ?? void 0, doc, {
|
|
1151
|
+
strict: true
|
|
1152
|
+
});
|
|
1153
|
+
for (const field of fields.values()) {
|
|
1154
|
+
if (field.name === "__typename") {
|
|
1155
|
+
out[field.key] = typename;
|
|
1156
|
+
} else if (field.name === "_id") {
|
|
1157
|
+
out[field.key] = typeof id === "string" ? id : values._id ?? null;
|
|
1158
|
+
} else if (field.selections.length) {
|
|
1159
|
+
const value = valueOf(field.name);
|
|
1160
|
+
out[field.key] = value == null && lists.has(field.key) ? [] : fillNested(doc, field.selections, value, ctx);
|
|
1161
|
+
} else {
|
|
1162
|
+
const value = valueOf(field.name);
|
|
1163
|
+
if (Array.isArray(value) && value.every(isScalarItem)) {
|
|
1164
|
+
out[field.key] = value;
|
|
1165
|
+
continue;
|
|
1166
|
+
}
|
|
1167
|
+
if (value == null && lists.has(field.key)) {
|
|
1168
|
+
out[field.key] = [];
|
|
1169
|
+
continue;
|
|
1170
|
+
}
|
|
1171
|
+
const scalar = value === void 0 || value !== null && typeof value === "object" ? null : value;
|
|
1172
|
+
const target = typeof scalar === "string" ? editField(field.name) : null;
|
|
1173
|
+
out[field.key] = target && links ? links.encode(scalar, target) : scalar;
|
|
1174
|
+
}
|
|
1175
|
+
}
|
|
1176
|
+
return out;
|
|
1177
|
+
}
|
|
1178
|
+
function fillNested(doc, selections, value, ctx) {
|
|
1179
|
+
const one = (item) => {
|
|
1180
|
+
if (!isPlainRecord(item)) return null;
|
|
1181
|
+
const typename = resolveTypename(
|
|
1182
|
+
doc,
|
|
1183
|
+
selections,
|
|
1184
|
+
item.__typename,
|
|
1185
|
+
item.typeName
|
|
1186
|
+
);
|
|
1187
|
+
if (typename === void 0) return null;
|
|
1188
|
+
return fillObject(doc, selections, typename, item, item._id, ctx);
|
|
1189
|
+
};
|
|
1190
|
+
if (Array.isArray(value)) return value.map(one).filter((v) => v !== null);
|
|
1191
|
+
return value === void 0 ? null : one(value);
|
|
1192
|
+
}
|
|
1193
|
+
function isScalarItem(value) {
|
|
1194
|
+
return typeof value === "string" || typeof value === "number" || typeof value === "boolean";
|
|
1195
|
+
}
|
|
1196
|
+
var NO_KEYS = /* @__PURE__ */ new Set();
|
|
1197
|
+
var listKeysCache = /* @__PURE__ */ new WeakMap();
|
|
1198
|
+
function listKeysIn(result) {
|
|
1199
|
+
return (typename) => {
|
|
1200
|
+
if (!typename || result === null || typeof result !== "object") {
|
|
1201
|
+
return NO_KEYS;
|
|
1202
|
+
}
|
|
1203
|
+
let byType = listKeysCache.get(result);
|
|
1204
|
+
if (!byType) {
|
|
1205
|
+
byType = /* @__PURE__ */ new Map();
|
|
1206
|
+
const seen = /* @__PURE__ */ new WeakSet();
|
|
1207
|
+
const walk2 = (node) => {
|
|
1208
|
+
if (node === null || typeof node !== "object" || seen.has(node)) return;
|
|
1209
|
+
seen.add(node);
|
|
1210
|
+
if (Array.isArray(node)) {
|
|
1211
|
+
node.forEach(walk2);
|
|
1212
|
+
return;
|
|
1213
|
+
}
|
|
1214
|
+
const record = node;
|
|
1215
|
+
const type = typeof record.__typename === "string" ? record.__typename : null;
|
|
1216
|
+
for (const [key, value] of Object.entries(record)) {
|
|
1217
|
+
if (type && Array.isArray(value)) {
|
|
1218
|
+
let keys = byType.get(type);
|
|
1219
|
+
if (!keys) byType.set(type, keys = /* @__PURE__ */ new Set());
|
|
1220
|
+
keys.add(key);
|
|
1221
|
+
}
|
|
1222
|
+
walk2(value);
|
|
1223
|
+
}
|
|
1224
|
+
};
|
|
1225
|
+
walk2(result);
|
|
1226
|
+
listKeysCache.set(result, byType);
|
|
1227
|
+
}
|
|
1228
|
+
return byType.get(typename) ?? NO_KEYS;
|
|
1229
|
+
};
|
|
1230
|
+
}
|
|
1231
|
+
var EDIT_PATH = /\/content\/edit\/[^/?#]+/;
|
|
1232
|
+
function editLinks(result, entry) {
|
|
1233
|
+
const edit = entry.fields?.__edit;
|
|
1234
|
+
if (!isPlainRecord(edit) || typeof edit.item !== "string") return null;
|
|
1235
|
+
return editLinksFor(result, edit.item);
|
|
1236
|
+
}
|
|
1237
|
+
var ITEM_ID = /^[A-Za-z0-9_-]+$/;
|
|
1238
|
+
function editLinksFor(result, item) {
|
|
1239
|
+
if (!ITEM_ID.test(item)) return null;
|
|
1240
|
+
const template = findEditLink(result);
|
|
1241
|
+
if (!template) return null;
|
|
1242
|
+
return {
|
|
1243
|
+
encode(text, field) {
|
|
1244
|
+
if ((0, import_stega2.vercelStegaSplit)(text).encoded) return text;
|
|
1245
|
+
let href;
|
|
1246
|
+
try {
|
|
1247
|
+
href = new URL(template.href);
|
|
1248
|
+
} catch {
|
|
1249
|
+
return text;
|
|
1250
|
+
}
|
|
1251
|
+
href.pathname = href.pathname.replace(
|
|
1252
|
+
EDIT_PATH,
|
|
1253
|
+
() => `/content/edit/${item}`
|
|
1254
|
+
);
|
|
1255
|
+
href.searchParams.set("field", field);
|
|
1256
|
+
const link = href.toString().replace(/%2E/gi, ".").replace(/%2F/gi, "/");
|
|
1257
|
+
return (0, import_stega2.vercelStegaCombine)(text, { origin: template.origin, href: link });
|
|
1258
|
+
}
|
|
1259
|
+
};
|
|
1260
|
+
}
|
|
1261
|
+
var linkCache = /* @__PURE__ */ new WeakMap();
|
|
1262
|
+
function findEditLink(root) {
|
|
1263
|
+
if (root === null || typeof root !== "object") return null;
|
|
1264
|
+
if (linkCache.has(root)) return linkCache.get(root) ?? null;
|
|
1265
|
+
let found = null;
|
|
1266
|
+
const seen = /* @__PURE__ */ new WeakSet();
|
|
1267
|
+
const walk2 = (node) => {
|
|
1268
|
+
if (found) return;
|
|
1269
|
+
if (typeof node === "string") {
|
|
1270
|
+
if (!(0, import_stega2.vercelStegaSplit)(node).encoded) return;
|
|
1271
|
+
try {
|
|
1272
|
+
const decoded = (0, import_stega2.vercelStegaDecode)(node);
|
|
1273
|
+
if (typeof decoded?.origin === "string" && typeof decoded.href === "string" && EDIT_PATH.test(decoded.href)) {
|
|
1274
|
+
found = { origin: decoded.origin, href: decoded.href };
|
|
1275
|
+
}
|
|
1276
|
+
} catch {
|
|
1277
|
+
}
|
|
1278
|
+
return;
|
|
1279
|
+
}
|
|
1280
|
+
if (node === null || typeof node !== "object" || seen.has(node)) return;
|
|
1281
|
+
seen.add(node);
|
|
1282
|
+
for (const value of Object.values(node)) walk2(value);
|
|
1283
|
+
};
|
|
1284
|
+
walk2(root);
|
|
1285
|
+
linkCache.set(root, found);
|
|
1286
|
+
return found;
|
|
1287
|
+
}
|
|
1288
|
+
|
|
1289
|
+
// src/core/live-preview/edit-links.ts
|
|
1290
|
+
var import_stega3 = require("@vercel/stega");
|
|
1291
|
+
var ENTRY_PARAM = "entry";
|
|
1292
|
+
var TOP_LEVEL_ENTRY = /^[A-Za-z0-9_]+\.\d+$/;
|
|
1293
|
+
function entryIdOf(element) {
|
|
1294
|
+
if (!isRecord(element)) return void 0;
|
|
1295
|
+
if (typeof element._id === "string") return element._id;
|
|
1296
|
+
if (element.__typename !== "Assets" || !Array.isArray(element.items)) {
|
|
1297
|
+
return void 0;
|
|
1298
|
+
}
|
|
1299
|
+
const first = element.items[0];
|
|
1300
|
+
return isRecord(first) && typeof first._id === "string" ? first._id : void 0;
|
|
1301
|
+
}
|
|
1302
|
+
function isRecord(value) {
|
|
1303
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1304
|
+
}
|
|
1305
|
+
function annotate(value, ctx) {
|
|
1306
|
+
if (!ctx.entryId) return value;
|
|
1307
|
+
const { cleaned, encoded } = (0, import_stega3.vercelStegaSplit)(value);
|
|
1308
|
+
if (!encoded) return value;
|
|
1309
|
+
let payload;
|
|
1310
|
+
try {
|
|
1311
|
+
payload = (0, import_stega3.vercelStegaDecode)(encoded);
|
|
1312
|
+
} catch {
|
|
1313
|
+
return value;
|
|
1314
|
+
}
|
|
1315
|
+
if (typeof payload?.href !== "string") return value;
|
|
1316
|
+
let url;
|
|
1317
|
+
try {
|
|
1318
|
+
url = new URL(payload.href);
|
|
1319
|
+
} catch {
|
|
1320
|
+
return value;
|
|
1321
|
+
}
|
|
1322
|
+
if (url.searchParams.has(ENTRY_PARAM)) return value;
|
|
1323
|
+
url.searchParams.set(ENTRY_PARAM, ctx.entryId);
|
|
1324
|
+
const itemId = decodeURIComponent(url.pathname.split("/").pop() ?? "");
|
|
1325
|
+
if (!url.searchParams.has("field") && ctx.entryField && TOP_LEVEL_ENTRY.test(ctx.entryField) && itemId === ctx.entryOwnerId) {
|
|
1326
|
+
url.searchParams.set("field", ctx.entryField);
|
|
1327
|
+
}
|
|
1328
|
+
return (0, import_stega3.vercelStegaCombine)(
|
|
1329
|
+
cleaned,
|
|
1330
|
+
{ ...payload, href: url.toString() },
|
|
1331
|
+
false
|
|
1332
|
+
);
|
|
1333
|
+
}
|
|
1334
|
+
function walk(value, selections, ctx) {
|
|
1335
|
+
if (typeof value === "string") return annotate(value, ctx);
|
|
1336
|
+
if (Array.isArray(value)) {
|
|
1337
|
+
let changed2 = false;
|
|
1338
|
+
const next2 = value.map((element, index) => {
|
|
1339
|
+
const path = [...ctx.path, String(index)];
|
|
1340
|
+
const entryId = ctx.inAssets ? void 0 : entryIdOf(element);
|
|
1341
|
+
const entry = entryId ? {
|
|
1342
|
+
entryId,
|
|
1343
|
+
entryField: ctx.ownerId ? path.join(".") : void 0,
|
|
1344
|
+
entryOwnerId: ctx.ownerId,
|
|
1345
|
+
inAssets: isRecord(element) && element._id === void 0
|
|
1346
|
+
} : {};
|
|
1347
|
+
const out = walk(element, selections, { ...ctx, ...entry, path });
|
|
1348
|
+
if (out !== element) changed2 = true;
|
|
1349
|
+
return out;
|
|
1350
|
+
});
|
|
1351
|
+
return changed2 ? next2 : value;
|
|
1352
|
+
}
|
|
1353
|
+
if (!isRecord(value)) return value;
|
|
1354
|
+
const id = typeof value._id === "string" ? value._id : void 0;
|
|
1355
|
+
const typename = typeof value.__typename === "string" ? value.__typename : void 0;
|
|
1356
|
+
const fields = ctx.doc && selections ? collectFields(selections, typename, ctx.doc) : null;
|
|
1357
|
+
let changed = false;
|
|
1358
|
+
const next = {};
|
|
1359
|
+
for (const [key, child] of Object.entries(value)) {
|
|
1360
|
+
const field = fields?.get(key);
|
|
1361
|
+
const name = field?.name ?? key;
|
|
1362
|
+
const out = walk(child, field?.selections ?? null, {
|
|
1363
|
+
...ctx,
|
|
1364
|
+
ownerId: id ?? ctx.ownerId,
|
|
1365
|
+
path: id ? [name] : [...ctx.path, name]
|
|
1366
|
+
});
|
|
1367
|
+
if (out !== child) changed = true;
|
|
1368
|
+
next[key] = out;
|
|
1369
|
+
}
|
|
1370
|
+
return changed ? next : value;
|
|
1371
|
+
}
|
|
1372
|
+
function annotateEditLinks(result, query, operationName) {
|
|
1373
|
+
let doc = null;
|
|
1374
|
+
if (query !== void 0) {
|
|
1375
|
+
try {
|
|
1376
|
+
doc = readQueryDocument(query, operationName);
|
|
1377
|
+
} catch {
|
|
1378
|
+
doc = null;
|
|
1379
|
+
}
|
|
1380
|
+
}
|
|
1381
|
+
return walk(result, doc?.operation ?? null, { doc, path: [] });
|
|
1382
|
+
}
|
|
1383
|
+
|
|
1384
|
+
// src/nextjs/server.ts
|
|
1385
|
+
var React = __toESM(require("react"), 1);
|
|
1386
|
+
|
|
1387
|
+
// src/nextjs/live-log.ts
|
|
1388
|
+
var LIVE_LOG_COOKIE = "__prepr_live";
|
|
1389
|
+
var MAX_SLOTS = 50;
|
|
1390
|
+
var TOKEN_PATTERN = /^[0-9a-f]{32}$/;
|
|
1391
|
+
var KEY = /* @__PURE__ */ Symbol.for("@preprio/toolkit/live-log");
|
|
1392
|
+
function slots() {
|
|
1393
|
+
const holder = globalThis;
|
|
1394
|
+
let map = holder[KEY];
|
|
1395
|
+
if (!map) {
|
|
1396
|
+
map = /* @__PURE__ */ new Map();
|
|
1397
|
+
holder[KEY] = map;
|
|
1398
|
+
}
|
|
1399
|
+
return map;
|
|
1400
|
+
}
|
|
1401
|
+
function prune(map, now) {
|
|
1402
|
+
for (const [token, slot] of map) {
|
|
1403
|
+
if (slot.expires <= now) map.delete(token);
|
|
1404
|
+
}
|
|
1405
|
+
while (map.size >= MAX_SLOTS) {
|
|
1406
|
+
map.delete(map.keys().next().value);
|
|
1407
|
+
}
|
|
1408
|
+
}
|
|
1409
|
+
function takeLiveLog(token) {
|
|
1410
|
+
if (!token || !TOKEN_PATTERN.test(token)) return [];
|
|
1411
|
+
const map = slots();
|
|
1412
|
+
const slot = map.get(token);
|
|
1413
|
+
map.delete(token);
|
|
1414
|
+
const now = Date.now();
|
|
1415
|
+
prune(map, now);
|
|
1416
|
+
if (!slot || slot.expires <= now) return [];
|
|
1417
|
+
return slot.log;
|
|
1418
|
+
}
|
|
267
1419
|
|
|
268
1420
|
// src/core/server.ts
|
|
269
1421
|
var PreprError = class extends Error {
|
|
@@ -452,6 +1604,28 @@ async function getToolbarProps(token, features) {
|
|
|
452
1604
|
const h = await readHeaders();
|
|
453
1605
|
return getToolbarPropsFromHeaders(h, token, features);
|
|
454
1606
|
}
|
|
1607
|
+
var HEADER_NEXT_ACTION = "next-action";
|
|
1608
|
+
var cacheForRender = React.cache ?? ((fn) => fn);
|
|
1609
|
+
var getPreprLiveLog = cacheForRender(
|
|
1610
|
+
async () => {
|
|
1611
|
+
let token;
|
|
1612
|
+
try {
|
|
1613
|
+
if (!(await (0, import_headers.headers)()).has(HEADER_NEXT_ACTION)) return [];
|
|
1614
|
+
token = (await (0, import_headers.cookies)()).get(LIVE_LOG_COOKIE)?.value;
|
|
1615
|
+
} catch (error) {
|
|
1616
|
+
navigation.unstable_rethrow?.(error);
|
|
1617
|
+
return [];
|
|
1618
|
+
}
|
|
1619
|
+
return takeLiveLog(token);
|
|
1620
|
+
}
|
|
1621
|
+
);
|
|
1622
|
+
async function normalizeQuery(query, result, options = {}) {
|
|
1623
|
+
if (!options.enabled) return result;
|
|
1624
|
+
const annotated = annotateEditLinks(result, query, options.operationName);
|
|
1625
|
+
const log = await getPreprLiveLog();
|
|
1626
|
+
if (!log.length) return annotated;
|
|
1627
|
+
return applyPatchLog(query, annotated, log, options.operationName);
|
|
1628
|
+
}
|
|
455
1629
|
|
|
456
1630
|
// src/nextjs/index.ts
|
|
457
1631
|
var import_components = require("./components.cjs");
|
|
@@ -467,5 +1641,6 @@ var import_components = require("./components.cjs");
|
|
|
467
1641
|
getPreprHeaders,
|
|
468
1642
|
getPreprUUID,
|
|
469
1643
|
getToolbarProps,
|
|
1644
|
+
normalizeQuery,
|
|
470
1645
|
validatePreprToken
|
|
471
1646
|
});
|