@preprio/toolkit 0.5.0-rc.2 → 0.5.0-rc.4

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 (50) hide show
  1. package/README.md +209 -10
  2. package/dist/astro/index.cjs +1194 -1
  3. package/dist/astro/index.d.cts +47 -1
  4. package/dist/astro/index.d.ts +47 -1
  5. package/dist/astro/index.js +1197 -1
  6. package/dist/chunk-46ISDRHT.js +26 -0
  7. package/dist/chunk-74KY5EAM.js +1219 -0
  8. package/dist/chunk-AHBN6FQP.js +184 -0
  9. package/dist/{chunk-FLPNN3CV.js → chunk-PDNCNTDB.js} +1370 -623
  10. package/dist/chunk-S3VT4UWM.js +75 -0
  11. package/dist/chunk-TG6N3C22.js +246 -0
  12. package/dist/chunk-URXSDJOU.js +356 -0
  13. package/dist/index.cjs +3166 -392
  14. package/dist/index.d.cts +238 -4
  15. package/dist/index.d.ts +238 -4
  16. package/dist/index.js +189 -149
  17. package/dist/live-preview-H4643QYF.js +18 -0
  18. package/dist/nextjs/components.cjs +1522 -359
  19. package/dist/nextjs/components.d.cts +1 -1
  20. package/dist/nextjs/components.d.ts +1 -1
  21. package/dist/nextjs/components.js +4 -1
  22. package/dist/nextjs/index.cjs +1085 -6
  23. package/dist/nextjs/index.d.cts +73 -1
  24. package/dist/nextjs/index.d.ts +73 -1
  25. package/dist/nextjs/index.js +1079 -7
  26. package/dist/nextjs/live-action.cjs +285 -0
  27. package/dist/nextjs/live-action.d.cts +12 -0
  28. package/dist/nextjs/live-action.d.ts +12 -0
  29. package/dist/nextjs/live-action.js +68 -0
  30. package/dist/nextjs/live.cjs +1896 -0
  31. package/dist/nextjs/live.d.cts +52 -0
  32. package/dist/nextjs/live.d.ts +52 -0
  33. package/dist/nextjs/live.js +265 -0
  34. package/dist/nuxt/index.cjs +1 -1
  35. package/dist/nuxt/index.js +1 -1
  36. package/dist/nuxt/live-preview-O2ZTJNW4.js +1520 -0
  37. package/dist/nuxt/live.cjs +1720 -0
  38. package/dist/nuxt/live.d.cts +43 -0
  39. package/dist/nuxt/live.d.ts +43 -0
  40. package/dist/nuxt/live.js +94 -0
  41. package/dist/{pixel-B3oQNbZ3.d.cts → pixel-CX422dCO.d.cts} +10 -1
  42. package/dist/{pixel-B3oQNbZ3.d.ts → pixel-CX422dCO.d.ts} +10 -1
  43. package/dist/react/components.cjs +1522 -359
  44. package/dist/react/components.d.cts +9 -0
  45. package/dist/react/components.d.ts +9 -0
  46. package/dist/react/components.js +1522 -359
  47. package/dist/sveltekit/index.cjs +1 -1
  48. package/dist/sveltekit/index.js +1 -1
  49. package/package.json +12 -1
  50. package/src/astro/PreprToolbar.astro +7 -1
@@ -2,7 +2,7 @@
2
2
  import { NextResponse } from "next/server";
3
3
 
4
4
  // src/version.ts
5
- var VERSION = "0.5.0-rc.2";
5
+ var VERSION = "0.5.0-rc.4";
6
6
 
7
7
  // src/core/constants.ts
8
8
  var COOKIE_PREVIEW_MODE = "Prepr-Preview-Mode";
@@ -47,9 +47,9 @@ function sanitizeHeaderValue(value) {
47
47
  return stripped.length > MAX_HEADER_VALUE_LENGTH ? stripped.slice(0, MAX_HEADER_VALUE_LENGTH) : stripped;
48
48
  }
49
49
  function parseCookies(request) {
50
- const cookies = /* @__PURE__ */ new Map();
50
+ const cookies2 = /* @__PURE__ */ new Map();
51
51
  const header = request.headers.get("cookie");
52
- if (!header) return cookies;
52
+ if (!header) return cookies2;
53
53
  for (const part of header.split(";")) {
54
54
  const eq = part.indexOf("=");
55
55
  if (eq === -1) continue;
@@ -57,12 +57,12 @@ function parseCookies(request) {
57
57
  const value = part.slice(eq + 1).trim();
58
58
  if (!name) continue;
59
59
  try {
60
- cookies.set(name, decodeURIComponent(value));
60
+ cookies2.set(name, decodeURIComponent(value));
61
61
  } catch {
62
- cookies.set(name, value);
62
+ cookies2.set(name, value);
63
63
  }
64
64
  }
65
- return cookies;
65
+ return cookies2;
66
66
  }
67
67
  function processFrameworkRequest(request, opts, framework) {
68
68
  const requestHeaders = new Headers(request.headers);
@@ -227,7 +227,1057 @@ function createPreprMiddleware(request, responseOrOptions, maybeOptions) {
227
227
  }
228
228
 
229
229
  // src/nextjs/server.ts
230
- import { headers } from "next/headers";
230
+ import { cookies, headers } from "next/headers";
231
+ import * as navigation from "next/navigation";
232
+
233
+ // src/core/live-preview/normalize-query.ts
234
+ import {
235
+ vercelStegaCombine,
236
+ vercelStegaDecode,
237
+ vercelStegaSplit as vercelStegaSplit2
238
+ } from "@vercel/stega";
239
+
240
+ // src/core/utils.ts
241
+ var DebugLogger = class {
242
+ constructor(options) {
243
+ this.options = {
244
+ prefix: "[Prepr]",
245
+ ...options
246
+ };
247
+ }
248
+ // A local `enabled` wins; otherwise defer to the global logger so scoped
249
+ // loggers created before initDebugLogger() still pick up the setting.
250
+ isEnabled() {
251
+ if (this.options.enabled !== void 0) {
252
+ return this.options.enabled;
253
+ }
254
+ return globalDebugLogger?.options?.enabled ?? false;
255
+ }
256
+ log(message, ...args) {
257
+ if (!this.isEnabled()) return;
258
+ const prefix = this.options.prefix;
259
+ console.log(`${prefix} ${message}`, ...args);
260
+ }
261
+ warn(message, ...args) {
262
+ if (!this.isEnabled()) return;
263
+ const prefix = this.options.prefix;
264
+ console.warn(`${prefix} ${message}`, ...args);
265
+ }
266
+ error(message, ...args) {
267
+ if (!this.isEnabled()) return;
268
+ const prefix = this.options.prefix;
269
+ console.error(`${prefix} ${message}`, ...args);
270
+ }
271
+ };
272
+ var globalDebugLogger = null;
273
+ function createScopedLogger(scopeName) {
274
+ return new DebugLogger({
275
+ prefix: `[Prepr][${scopeName}]`
276
+ });
277
+ }
278
+
279
+ // src/core/live-preview/field-name.ts
280
+ var UPPERCASE_BOUNDARY = /(.)(?=[A-Z])/g;
281
+ function graphqlFieldName(apiId) {
282
+ return apiId.replace(UPPERCASE_BOUNDARY, "$1_").toLowerCase();
283
+ }
284
+ var TEXT_BODY_FIELDS = [
285
+ { name: "body", plain: false },
286
+ { name: "html", plain: false },
287
+ { name: "text", plain: true }
288
+ ];
289
+ var TAG_PATTERN = /<[^>]+>/g;
290
+ function plainTextFromHtml(html) {
291
+ return html.replace(TAG_PATTERN, "");
292
+ }
293
+ function isTextEntry(record) {
294
+ const typename = record.__typename;
295
+ if (typeof typename === "string") return typename === "Text";
296
+ return "html" in record || "text" in record && "format" in record;
297
+ }
298
+
299
+ // src/core/live-preview/index-snapshot.ts
300
+ var debug = createScopedLogger("live-preview");
301
+ function indexSnapshot(data) {
302
+ const index = /* @__PURE__ */ new Map();
303
+ const visited = /* @__PURE__ */ new WeakSet();
304
+ const path = [];
305
+ function walk(node) {
306
+ if (node === null || typeof node !== "object") return;
307
+ if (visited.has(node)) return;
308
+ visited.add(node);
309
+ if (Array.isArray(node)) {
310
+ for (let i = 0; i < node.length; i++) {
311
+ path.push(i);
312
+ walk(node[i]);
313
+ path.pop();
314
+ }
315
+ return;
316
+ }
317
+ const record = node;
318
+ if (typeof record._id === "string") {
319
+ const paths = index.get(record._id);
320
+ if (paths) paths.push([...path]);
321
+ else index.set(record._id, [[...path]]);
322
+ } else if (typeof record.__typename === "string") {
323
+ debug.log("item without _id will not live-update", {
324
+ __typename: record.__typename
325
+ });
326
+ }
327
+ for (const key in record) {
328
+ if (!Object.prototype.hasOwnProperty.call(record, key)) continue;
329
+ path.push(key);
330
+ walk(record[key]);
331
+ path.pop();
332
+ }
333
+ }
334
+ walk(data);
335
+ return index;
336
+ }
337
+
338
+ // src/core/live-preview/patch.ts
339
+ import { vercelStegaSplit } from "@vercel/stega";
340
+ var FORBIDDEN_SEGMENTS = /* @__PURE__ */ new Set(["__proto__", "prototype", "constructor"]);
341
+ function isPlainObject(value) {
342
+ return value !== null && typeof value === "object" && !Array.isArray(value);
343
+ }
344
+ function mergeObject(current, incoming) {
345
+ let changed = false;
346
+ const next = { ...current };
347
+ for (const key of Object.keys(current)) {
348
+ if (!(key in incoming) || incoming[key] === void 0) continue;
349
+ const value = isPlainObject(current[key]) && isPlainObject(incoming[key]) ? mergeObject(current[key], incoming[key]) : incoming[key];
350
+ if (value !== current[key]) {
351
+ next[key] = value;
352
+ changed = true;
353
+ }
354
+ }
355
+ return changed ? next : current;
356
+ }
357
+ function shapeLike(template, incoming) {
358
+ const out = {};
359
+ for (const key of Object.keys(template)) {
360
+ const value = incoming[key];
361
+ out[key] = value === void 0 ? null : isPlainObject(template[key]) && isPlainObject(value) ? shapeLike(template[key], value) : value;
362
+ }
363
+ return out;
364
+ }
365
+ function mergeStructured(current, incoming) {
366
+ if (incoming === null || Array.isArray(incoming) && !incoming.length) {
367
+ if (Array.isArray(current)) return current.length ? [] : current;
368
+ return null;
369
+ }
370
+ const list = Array.isArray(incoming) ? incoming : [incoming];
371
+ if (current === null || current === void 0) return incoming;
372
+ if (Array.isArray(current)) {
373
+ const template = current.find(isPlainObject);
374
+ return list.map((entry) => {
375
+ const match = current.find(
376
+ (c) => isPlainObject(c) && c._id !== void 0 && c._id === entry._id
377
+ );
378
+ if (isPlainObject(match)) return mergeObject(match, entry);
379
+ return isPlainObject(template) ? shapeLike(template, entry) : entry;
380
+ });
381
+ }
382
+ if (isPlainObject(current)) return mergeObject(current, list[0]);
383
+ return current;
384
+ }
385
+ function isPatchable(current) {
386
+ return current === null || typeof current === "string" || typeof current === "number" || typeof current === "boolean";
387
+ }
388
+ function cloneNode(node) {
389
+ return Array.isArray(node) ? [...node] : { ...node };
390
+ }
391
+ function writeAtPath(root, fullPath, value, markChanged = () => {
392
+ }) {
393
+ if (!fullPath.length) return root;
394
+ if (fullPath.some((s) => FORBIDDEN_SEGMENTS.has(String(s)))) return root;
395
+ const last = fullPath.length - 1;
396
+ let node = root;
397
+ for (let i = 0; i < last; i++) {
398
+ if (node === null || typeof node !== "object") return root;
399
+ node = node[fullPath[i]];
400
+ }
401
+ if (node === null || typeof node !== "object") return root;
402
+ const container = node;
403
+ const key = fullPath[last];
404
+ if (!(key in container)) return root;
405
+ let next;
406
+ if (value === null || typeof value === "object") {
407
+ next = mergeStructured(container[key], value);
408
+ } else if (!isPatchable(container[key])) {
409
+ return root;
410
+ } else {
411
+ next = keepEditLink(container[key], value);
412
+ }
413
+ if (container[key] === next) return root;
414
+ const newRoot = cloneNode(root);
415
+ let cursor = newRoot;
416
+ for (let i = 0; i < last; i++) {
417
+ const child = cloneNode(cursor[fullPath[i]]);
418
+ cursor[fullPath[i]] = child;
419
+ cursor = child;
420
+ }
421
+ cursor[key] = next;
422
+ markChanged();
423
+ return newRoot;
424
+ }
425
+ function listKeysOf(entry) {
426
+ if (!isPlainObject(entry)) return [];
427
+ const keys = [];
428
+ if (typeof entry._id === "string") keys.push(entry._id);
429
+ const first = Array.isArray(entry.items) ? entry.items[0] : null;
430
+ if (isPlainObject(first) && typeof first._id === "string") {
431
+ keys.push(first._id);
432
+ }
433
+ return keys;
434
+ }
435
+ function buildText(entry, template) {
436
+ const body = typeof entry.body === "string" ? entry.body : "";
437
+ const full = {
438
+ __typename: "Text",
439
+ _id: entry._id,
440
+ body,
441
+ html: body,
442
+ text: plainTextFromHtml(body),
443
+ format: entry.format ?? null
444
+ };
445
+ if (!template) return full;
446
+ const out = {};
447
+ for (const key of Object.keys(template)) {
448
+ out[key] = key in full ? full[key] : null;
449
+ }
450
+ return out;
451
+ }
452
+ function syncList(current, entries, build) {
453
+ if (current === null || current === void 0) {
454
+ const built = syncList([], entries, build);
455
+ return built.length ? built : current;
456
+ }
457
+ if (!Array.isArray(current)) return current;
458
+ const byKey = /* @__PURE__ */ new Map();
459
+ const templates = /* @__PURE__ */ new Map();
460
+ for (const c of current) {
461
+ for (const key of listKeysOf(c)) byKey.set(key, c);
462
+ if (isPlainObject(c) && typeof c.__typename === "string") {
463
+ if (!templates.has(c.__typename)) templates.set(c.__typename, c);
464
+ }
465
+ }
466
+ if (!entries.length) return current.length ? [] : current;
467
+ if (current.length && !byKey.size) return current;
468
+ if (current.length && !entries.some((e) => byKey.has(e._id))) return current;
469
+ const next = [];
470
+ for (const entry of entries) {
471
+ const existing = byKey.get(entry._id);
472
+ const built = existing === void 0 && entry.fields ? build?.(entry) : void 0;
473
+ if (existing !== void 0) {
474
+ next.push(existing);
475
+ } else if (built) {
476
+ next.push(built);
477
+ } else if (entry.__typename === "Text") {
478
+ next.push(buildText(entry, templates.get("Text")));
479
+ }
480
+ }
481
+ const same = next.length === current.length && next.every((n, i) => n === current[i]);
482
+ return same ? current : next;
483
+ }
484
+ function syncListAtPath(root, fullPath, entries, build) {
485
+ if (!fullPath.length) return root;
486
+ if (fullPath.some((s) => FORBIDDEN_SEGMENTS.has(String(s)))) return root;
487
+ let node = root;
488
+ for (const key of fullPath) {
489
+ node = node !== null && typeof node === "object" ? node[key] : void 0;
490
+ }
491
+ const next = syncList(node, entries, build);
492
+ if (next === node) return root;
493
+ const newRoot = cloneNode(root);
494
+ let cursor = newRoot;
495
+ for (let i = 0; i < fullPath.length - 1; i++) {
496
+ const child = cloneNode(cursor[fullPath[i]]);
497
+ cursor[fullPath[i]] = child;
498
+ cursor = child;
499
+ }
500
+ cursor[fullPath[fullPath.length - 1]] = next;
501
+ return newRoot;
502
+ }
503
+ function keepEditLink(current, value) {
504
+ if (typeof current !== "string" || typeof value !== "string") return value;
505
+ const { encoded } = vercelStegaSplit(current);
506
+ if (!encoded || vercelStegaSplit(value).encoded) return value;
507
+ return value + encoded;
508
+ }
509
+
510
+ // src/core/live-preview/query-document.ts
511
+ var NAME_START = /[_A-Za-z]/;
512
+ var NAME_CONTINUE = /[_0-9A-Za-z]/;
513
+ var PUNCT = /* @__PURE__ */ new Set([
514
+ "!",
515
+ "$",
516
+ "&",
517
+ "(",
518
+ ")",
519
+ ":",
520
+ "=",
521
+ "@",
522
+ "[",
523
+ "]",
524
+ "{",
525
+ "|",
526
+ "}"
527
+ ]);
528
+ function tokenize(source) {
529
+ const tokens = [];
530
+ let i = 0;
531
+ const n = source.length;
532
+ while (i < n) {
533
+ const ch = source[i];
534
+ if (ch === " " || ch === " " || ch === "\n" || ch === "\r" || ch === "," || ch === "\uFEFF") {
535
+ i++;
536
+ } else if (ch === "#") {
537
+ while (i < n && source[i] !== "\n" && source[i] !== "\r") i++;
538
+ } else if (ch === "." && source.startsWith("...", i)) {
539
+ tokens.push({ type: "punct", value: "..." });
540
+ i += 3;
541
+ } else if (PUNCT.has(ch)) {
542
+ tokens.push({ type: "punct", value: ch });
543
+ i++;
544
+ } else if (NAME_START.test(ch)) {
545
+ const start = i;
546
+ while (i < n && NAME_CONTINUE.test(source[i])) i++;
547
+ tokens.push({ type: "name", value: source.slice(start, i) });
548
+ } else if (ch === '"') {
549
+ if (source.startsWith('"""', i)) {
550
+ i += 3;
551
+ while (i < n && !source.startsWith('"""', i)) {
552
+ i += source.startsWith('\\"""', i) ? 4 : 1;
553
+ }
554
+ if (i >= n) throw new SyntaxError("Unterminated block string");
555
+ i += 3;
556
+ } else {
557
+ i++;
558
+ while (i < n && source[i] !== '"') {
559
+ if (source[i] === "\n" || source[i] === "\r") {
560
+ throw new SyntaxError("Unterminated string");
561
+ }
562
+ i += source[i] === "\\" ? 2 : 1;
563
+ }
564
+ if (i >= n) throw new SyntaxError("Unterminated string");
565
+ i++;
566
+ }
567
+ tokens.push({ type: "value" });
568
+ } else if (ch === "-" || ch >= "0" && ch <= "9") {
569
+ i++;
570
+ while (i < n && /[0-9.eE+-]/.test(source[i])) i++;
571
+ tokens.push({ type: "value" });
572
+ } else {
573
+ throw new SyntaxError(`Unexpected character "${ch}"`);
574
+ }
575
+ }
576
+ return tokens;
577
+ }
578
+ function parseSource(source, operationName) {
579
+ const tokens = tokenize(source);
580
+ let pos = 0;
581
+ const peek = () => tokens[pos];
582
+ const isPunct = (value) => {
583
+ const t = tokens[pos];
584
+ return t?.type === "punct" && t.value === value;
585
+ };
586
+ const expectPunct = (value) => {
587
+ if (!isPunct(value)) throw new SyntaxError(`Expected "${value}"`);
588
+ pos++;
589
+ };
590
+ const expectName = () => {
591
+ const t = tokens[pos];
592
+ if (t?.type !== "name") throw new SyntaxError("Expected a name");
593
+ pos++;
594
+ return t.value;
595
+ };
596
+ const skipParens = () => {
597
+ expectPunct("(");
598
+ let depth = 1;
599
+ while (depth > 0) {
600
+ const t = tokens[pos++];
601
+ if (!t) throw new SyntaxError("Unbalanced parentheses");
602
+ if (t.type === "punct" && t.value === "(") depth++;
603
+ else if (t.type === "punct" && t.value === ")") depth--;
604
+ }
605
+ };
606
+ const skipDirectives = () => {
607
+ while (isPunct("@")) {
608
+ pos++;
609
+ expectName();
610
+ if (isPunct("(")) skipParens();
611
+ }
612
+ };
613
+ const parseSelectionSet = () => {
614
+ expectPunct("{");
615
+ const selections = [];
616
+ while (!isPunct("}")) {
617
+ if (!peek()) throw new SyntaxError("Unterminated selection set");
618
+ selections.push(parseSelection());
619
+ }
620
+ pos++;
621
+ return selections;
622
+ };
623
+ const parseSelection = () => {
624
+ if (isPunct("...")) {
625
+ pos++;
626
+ const t = peek();
627
+ if (t?.type === "name" && t.value !== "on") {
628
+ pos++;
629
+ skipDirectives();
630
+ return { kind: "spread", name: t.value };
631
+ }
632
+ let on = null;
633
+ if (t?.type === "name") {
634
+ pos++;
635
+ on = expectName();
636
+ }
637
+ skipDirectives();
638
+ return { kind: "inline", on, selections: parseSelectionSet() };
639
+ }
640
+ let name = expectName();
641
+ const key = name;
642
+ if (isPunct(":")) {
643
+ pos++;
644
+ name = expectName();
645
+ }
646
+ let hasArgs = false;
647
+ if (isPunct("(")) {
648
+ hasArgs = true;
649
+ skipParens();
650
+ }
651
+ skipDirectives();
652
+ const selections = isPunct("{") ? parseSelectionSet() : null;
653
+ return { kind: "field", name, key, hasArgs, selections };
654
+ };
655
+ const fragments = /* @__PURE__ */ new Map();
656
+ const operations = [];
657
+ while (pos < tokens.length) {
658
+ if (isPunct("{")) {
659
+ operations.push({ name: null, selections: parseSelectionSet() });
660
+ continue;
661
+ }
662
+ const keyword = expectName();
663
+ if (keyword === "fragment") {
664
+ const name = expectName();
665
+ if (expectName() !== "on") throw new SyntaxError('Expected "on"');
666
+ const on = expectName();
667
+ skipDirectives();
668
+ fragments.set(name, { on, selections: parseSelectionSet() });
669
+ } else if (keyword === "query" || keyword === "mutation" || keyword === "subscription") {
670
+ const t = peek();
671
+ let name = null;
672
+ if (t?.type === "name") name = expectName();
673
+ if (isPunct("(")) skipParens();
674
+ skipDirectives();
675
+ operations.push({ name, selections: parseSelectionSet() });
676
+ } else {
677
+ throw new SyntaxError(`Unexpected "${keyword}"`);
678
+ }
679
+ }
680
+ return { operation: pickOperation(operations, operationName), fragments };
681
+ }
682
+ function pickOperation(operations, operationName) {
683
+ const op = operationName ? operations.find((o) => o.name === operationName) : operations[0];
684
+ if (!op) throw new SyntaxError("The document has no operation");
685
+ return op.selections;
686
+ }
687
+ function fromAstSelections(set) {
688
+ return set.selections.map((s) => {
689
+ if (s.kind === "FragmentSpread")
690
+ return { kind: "spread", name: s.name.value };
691
+ if (s.kind === "InlineFragment") {
692
+ return {
693
+ kind: "inline",
694
+ on: s.typeCondition?.name.value ?? null,
695
+ selections: fromAstSelections(s.selectionSet)
696
+ };
697
+ }
698
+ const name = s.name.value;
699
+ return {
700
+ kind: "field",
701
+ name,
702
+ key: s.alias?.value ?? name,
703
+ hasArgs: Boolean(s.arguments?.length),
704
+ selections: s.selectionSet ? fromAstSelections(s.selectionSet) : null
705
+ };
706
+ });
707
+ }
708
+ function fromAst(doc, operationName) {
709
+ const fragments = /* @__PURE__ */ new Map();
710
+ const operations = [];
711
+ for (const def of doc.definitions ?? []) {
712
+ if (def.kind === "FragmentDefinition" && def.name && def.typeCondition && def.selectionSet) {
713
+ fragments.set(def.name.value, {
714
+ on: def.typeCondition.name.value,
715
+ selections: fromAstSelections(def.selectionSet)
716
+ });
717
+ } else if (def.kind === "OperationDefinition" && def.selectionSet) {
718
+ operations.push({
719
+ name: def.name?.value ?? null,
720
+ selections: fromAstSelections(def.selectionSet)
721
+ });
722
+ }
723
+ }
724
+ return { operation: pickOperation(operations, operationName), fragments };
725
+ }
726
+ var astCache = /* @__PURE__ */ new WeakMap();
727
+ var sourceCache = /* @__PURE__ */ new Map();
728
+ var SOURCE_CACHE_LIMIT = 200;
729
+ function readQueryDocument(query, operationName) {
730
+ const cacheKey = operationName ?? "";
731
+ if (typeof query === "object" && query !== null && query.kind === "Document") {
732
+ let byName = astCache.get(query);
733
+ if (!byName) astCache.set(query, byName = /* @__PURE__ */ new Map());
734
+ let parsed2 = byName.get(cacheKey);
735
+ if (!parsed2) {
736
+ parsed2 = fromAst(
737
+ query,
738
+ operationName
739
+ );
740
+ byName.set(cacheKey, parsed2);
741
+ }
742
+ return parsed2;
743
+ }
744
+ const source = String(query);
745
+ const sourceKey = `${cacheKey}
746
+ ${source}`;
747
+ let parsed = sourceCache.get(sourceKey);
748
+ if (!parsed) {
749
+ parsed = parseSource(source, operationName);
750
+ if (sourceCache.size >= SOURCE_CACHE_LIMIT) {
751
+ sourceCache.delete(sourceCache.keys().next().value);
752
+ }
753
+ sourceCache.set(sourceKey, parsed);
754
+ }
755
+ return parsed;
756
+ }
757
+ var fieldsCache = /* @__PURE__ */ new WeakMap();
758
+ function collectFields(selections, typename, doc, options = {}) {
759
+ const cacheKey = `${options.strict ? "s" : "l"}:${typename ?? ""}`;
760
+ let cached = fieldsCache.get(selections);
761
+ if (!cached) {
762
+ cached = /* @__PURE__ */ new Map();
763
+ fieldsCache.set(selections, cached);
764
+ }
765
+ const hit = cached.get(cacheKey);
766
+ if (hit) return hit;
767
+ const fields = resolveFields(selections, typename, doc, options);
768
+ cached.set(cacheKey, fields);
769
+ return fields;
770
+ }
771
+ function resolveFields(selections, typename, doc, options) {
772
+ const exact = /* @__PURE__ */ new Map();
773
+ const loose = /* @__PURE__ */ new Map();
774
+ const merged = /* @__PURE__ */ new Map();
775
+ const walkedMatched = /* @__PURE__ */ new Set();
776
+ const walkedLoose = /* @__PURE__ */ new Set();
777
+ const add = (target, s) => {
778
+ let field = target.get(s.key);
779
+ if (!field) {
780
+ field = { name: s.name, key: s.key, hasArgs: s.hasArgs, selections: [] };
781
+ target.set(s.key, field);
782
+ merged.set(field, /* @__PURE__ */ new Set());
783
+ }
784
+ const done = merged.get(field);
785
+ if (s.selections && !done.has(s.selections)) {
786
+ done.add(s.selections);
787
+ field.selections = [...field.selections, ...s.selections];
788
+ }
789
+ };
790
+ const applies = (on, list) => conditionMatches(on, typename) || typename !== void 0 && typeConditions(list, doc).includes(typename);
791
+ const walk = (list, matched) => {
792
+ for (const s of list) {
793
+ if (s.kind === "field") {
794
+ add(matched ? exact : loose, s);
795
+ } else if (s.kind === "inline") {
796
+ walk(s.selections, matched && applies(s.on, s.selections));
797
+ } else {
798
+ const fragment = doc.fragments.get(s.name);
799
+ if (!fragment) continue;
800
+ const asMatched = matched && applies(fragment.on, fragment.selections);
801
+ if (walkedMatched.has(fragment)) continue;
802
+ if (!asMatched && walkedLoose.has(fragment)) continue;
803
+ (asMatched ? walkedMatched : walkedLoose).add(fragment);
804
+ walk(fragment.selections, asMatched);
805
+ }
806
+ }
807
+ };
808
+ walk(selections, true);
809
+ if (!options.strict) {
810
+ for (const [key, field] of loose) {
811
+ if (!exact.has(key)) exact.set(key, field);
812
+ }
813
+ }
814
+ return exact;
815
+ }
816
+ function conditionMatches(on, typename) {
817
+ return on === null || typename === void 0 || on === typename;
818
+ }
819
+ var conditionsCache = /* @__PURE__ */ new WeakMap();
820
+ function typeConditions(selections, doc) {
821
+ const hit = conditionsCache.get(selections);
822
+ if (hit) return hit;
823
+ const names = /* @__PURE__ */ new Set();
824
+ const seen = /* @__PURE__ */ new Set();
825
+ const walk = (list) => {
826
+ for (const s of list) {
827
+ if (s.kind === "inline") {
828
+ if (s.on) names.add(s.on);
829
+ walk(s.selections);
830
+ } else if (s.kind === "spread") {
831
+ const fragment = doc.fragments.get(s.name);
832
+ if (!fragment || seen.has(fragment)) continue;
833
+ seen.add(fragment);
834
+ names.add(fragment.on);
835
+ walk(fragment.selections);
836
+ }
837
+ }
838
+ };
839
+ walk(selections);
840
+ const conditions = [...names];
841
+ conditionsCache.set(selections, conditions);
842
+ return conditions;
843
+ }
844
+
845
+ // src/core/live-preview/validate.ts
846
+ function isPlainRecord(v) {
847
+ return v !== null && typeof v === "object" && Object.getPrototypeOf(v) === Object.prototype;
848
+ }
849
+
850
+ // src/core/live-preview/normalize-query.ts
851
+ var debug2 = createScopedLogger("live-preview:normalize");
852
+ var INDEX_SEGMENT = /^\d+$/;
853
+ var FORBIDDEN_SEGMENTS2 = /* @__PURE__ */ new Set(["__proto__", "prototype", "constructor"]);
854
+ var ENVELOPE_KEYS = /* @__PURE__ */ new Set(["data", "errors", "extensions"]);
855
+ function applyPatchLog(query, result, log, operationName) {
856
+ if (!log.length || result === null || typeof result !== "object") {
857
+ return result;
858
+ }
859
+ if (isEnvelope(result)) {
860
+ const data = applyPatchLog(query, result.data, log, operationName);
861
+ return data === result.data ? result : { ...result, data };
862
+ }
863
+ let doc = null;
864
+ try {
865
+ doc = readQueryDocument(query, operationName);
866
+ } catch (error) {
867
+ debug2.log("could not read the query; applying fields by literal path", {
868
+ error: String(error)
869
+ });
870
+ }
871
+ let root = result;
872
+ let index = null;
873
+ for (const patch of log) {
874
+ try {
875
+ index ?? (index = indexSnapshot(root));
876
+ const next = applyPatch(root, index, patch, doc, result);
877
+ if (next !== root) {
878
+ root = next;
879
+ if (patch.type === "list" || !isScalarValue(patch.value)) {
880
+ index = null;
881
+ }
882
+ }
883
+ } catch (error) {
884
+ debug2.log("could not apply a change", {
885
+ itemId: patch.itemId,
886
+ field: patch.field,
887
+ error: String(error)
888
+ });
889
+ }
890
+ }
891
+ return root;
892
+ }
893
+ function isScalarValue(value) {
894
+ return value === null || typeof value !== "object";
895
+ }
896
+ function applyPatch(root, index, patch, doc, result) {
897
+ const ownerPaths = index.get(patch.itemId);
898
+ if (!ownerPaths?.length) return root;
899
+ const segments = patch.field.split(".");
900
+ if (segments.some((s) => !s || FORBIDDEN_SEGMENTS2.has(s))) return root;
901
+ const targets = [];
902
+ const plain = /* @__PURE__ */ new Set();
903
+ for (const ownerPath of ownerPaths) {
904
+ if (doc) {
905
+ const resolved = resolveTargets(root, doc, ownerPath, segments);
906
+ root = resolved.root;
907
+ targets.push(...resolved.targets);
908
+ resolved.plain.forEach((target) => plain.add(target));
909
+ } else {
910
+ targets.push([...ownerPath, ...segments.map(toPathSegment)]);
911
+ }
912
+ }
913
+ if (!targets.length) {
914
+ debug2.log("no field in the query matches", {
915
+ itemId: patch.itemId,
916
+ field: patch.field
917
+ });
918
+ return root;
919
+ }
920
+ if (patch.type === "field") {
921
+ for (const target of targets) {
922
+ const pushed = plain.has(target) && typeof patch.value === "string" ? plainTextFromHtml(patch.value) : patch.value;
923
+ let value = keepEditLink(readAtPath(root, target), pushed);
924
+ if (patch.edit && typeof value === "string" && !vercelStegaSplit2(value).encoded) {
925
+ value = editLinksFor(result, patch.edit.item)?.encode(
926
+ value,
927
+ patch.edit.field
928
+ ) ?? value;
929
+ }
930
+ root = writeAtPath(root, target, value);
931
+ }
932
+ } else {
933
+ for (const target of targets) {
934
+ const selections = doc ? selectionsAt(root, doc, target) : null;
935
+ const build = doc && selections ? (entry) => buildEntry(doc, selections, entry, {
936
+ links: editLinks(result, entry),
937
+ lists: listKeysIn(result)
938
+ }) : void 0;
939
+ root = syncListAtPath(root, target, patch.entries, build);
940
+ }
941
+ }
942
+ return root;
943
+ }
944
+ function readAtPath(root, path) {
945
+ let node = root;
946
+ for (const step of path) {
947
+ if (node === null || typeof node !== "object") return void 0;
948
+ node = node[step];
949
+ }
950
+ return node;
951
+ }
952
+ function isEnvelope(value) {
953
+ if (Array.isArray(value) || !("data" in value)) return false;
954
+ return Object.keys(value).every((key) => ENVELOPE_KEYS.has(key));
955
+ }
956
+ function toPathSegment(segment) {
957
+ return INDEX_SEGMENT.test(segment) ? Number(segment) : segment;
958
+ }
959
+ function typenameOf(node) {
960
+ const typename = node.__typename;
961
+ return typeof typename === "string" ? typename : void 0;
962
+ }
963
+ function selectionsAt(root, doc, path) {
964
+ let node = root;
965
+ let selections = doc.operation;
966
+ for (const step of path) {
967
+ if (Array.isArray(node)) {
968
+ node = node[step];
969
+ continue;
970
+ }
971
+ if (node === null || typeof node !== "object") return null;
972
+ const field = collectFields(selections, typenameOf(node), doc).get(
973
+ String(step)
974
+ );
975
+ if (!field) return null;
976
+ selections = field.selections;
977
+ node = node[String(step)];
978
+ }
979
+ return selections;
980
+ }
981
+ function resolveTargets(root, doc, ownerPath, segments) {
982
+ let owner = root;
983
+ for (const step of ownerPath) {
984
+ owner = owner[step];
985
+ }
986
+ const selections = selectionsAt(root, doc, ownerPath);
987
+ if (!selections) return { root, targets: [], plain: /* @__PURE__ */ new Set() };
988
+ let current = root;
989
+ const out = [];
990
+ const plain = /* @__PURE__ */ new Set();
991
+ const walk = (node, sel, i, path) => {
992
+ if (i === segments.length) {
993
+ out.push(path);
994
+ return;
995
+ }
996
+ const segment = segments[i];
997
+ if (Array.isArray(node)) {
998
+ if (INDEX_SEGMENT.test(segment)) {
999
+ const position = Number(segment);
1000
+ if (position < node.length) {
1001
+ walk(node[position], sel, i + 1, [...path, position]);
1002
+ }
1003
+ } else if (segment === "items") {
1004
+ walk(node, sel, i + 1, path);
1005
+ }
1006
+ return;
1007
+ }
1008
+ if (node === null || typeof node !== "object") return;
1009
+ const record = node;
1010
+ const wanted = graphqlFieldName(segment);
1011
+ const textBody = i === segments.length - 1 && segment === "body" && isTextEntry(record) ? TEXT_BODY_FIELDS : null;
1012
+ let matched = false;
1013
+ for (const field of collectFields(sel, typenameOf(node), doc).values()) {
1014
+ const alias = textBody?.find((f) => f.name === field.name);
1015
+ if (field.name !== segment && field.name !== wanted && !alias) continue;
1016
+ if (!Object.prototype.hasOwnProperty.call(record, field.key)) continue;
1017
+ matched = true;
1018
+ const fieldPath = [...path, field.key];
1019
+ if (alias?.plain) plain.add(fieldPath);
1020
+ let value = record[field.key];
1021
+ const next = segments[i + 1];
1022
+ if (value === null && field.selections.length && next !== void 0 && next !== "items" && !INDEX_SEGMENT.test(next)) {
1023
+ const typename = resolveTypename(
1024
+ doc,
1025
+ field.selections,
1026
+ void 0,
1027
+ void 0
1028
+ );
1029
+ if (typename !== void 0) {
1030
+ value = fillObject(doc, field.selections, typename, {}, void 0, {
1031
+ links: null,
1032
+ lists: listKeysIn(root)
1033
+ });
1034
+ current = writeAtPath(current, fieldPath, value);
1035
+ }
1036
+ }
1037
+ walk(value, field.selections, i + 1, fieldPath);
1038
+ }
1039
+ if (!matched && segment === "items") walk(node, sel, i + 1, path);
1040
+ };
1041
+ walk(owner, selections, 0, ownerPath);
1042
+ return { root: current, targets: out, plain };
1043
+ }
1044
+ var NON_ALPHANUMERIC = /[^a-z0-9]/gi;
1045
+ var typeKey = (name) => name.replace(NON_ALPHANUMERIC, "").toLowerCase();
1046
+ function resolveTypename(doc, selections, typename, typeName) {
1047
+ const known = typeConditions(selections, doc);
1048
+ const explicit = typeof typename === "string" ? typename : void 0;
1049
+ if (!known.length) return explicit ?? null;
1050
+ if (explicit && known.includes(explicit)) return explicit;
1051
+ for (const candidate of [explicit, typeName]) {
1052
+ if (typeof candidate !== "string" || !candidate) continue;
1053
+ const match = known.find((name) => typeKey(name) === typeKey(candidate));
1054
+ if (match) return match;
1055
+ }
1056
+ const named = explicit !== void 0 || typeof typeName === "string";
1057
+ return known.length === 1 && !named ? known[0] : void 0;
1058
+ }
1059
+ function buildEntry(doc, selections, entry, ctx) {
1060
+ const typename = resolveTypename(
1061
+ doc,
1062
+ selections,
1063
+ entry.__typename,
1064
+ entry.typeName
1065
+ );
1066
+ if (typename === void 0) return void 0;
1067
+ return fillObject(
1068
+ doc,
1069
+ selections,
1070
+ typename,
1071
+ entry.fields ?? {},
1072
+ entry._id,
1073
+ ctx
1074
+ );
1075
+ }
1076
+ function fillObject(doc, selections, typename, values, id, ctx) {
1077
+ const out = {};
1078
+ const { links } = ctx;
1079
+ const lists = ctx.lists(typename);
1080
+ const edit = isPlainRecord(values.__edit) ? values.__edit : null;
1081
+ const apiIdOf = /* @__PURE__ */ new Map();
1082
+ for (const key of Object.keys(values)) {
1083
+ apiIdOf.set(key, key);
1084
+ const name = graphqlFieldName(key);
1085
+ if (!apiIdOf.has(name)) apiIdOf.set(name, key);
1086
+ }
1087
+ if (edit && isPlainRecord(edit.apiIds)) {
1088
+ for (const [name, apiId] of Object.entries(edit.apiIds)) {
1089
+ if (typeof apiId === "string") apiIdOf.set(name, apiId);
1090
+ }
1091
+ }
1092
+ const valueOf = (name) => {
1093
+ if (Object.prototype.hasOwnProperty.call(values, name)) return values[name];
1094
+ const key = apiIdOf.get(name);
1095
+ return key !== void 0 && key in values ? values[key] : void 0;
1096
+ };
1097
+ const editField = (name) => {
1098
+ if (!edit) return null;
1099
+ if (typeof edit.field === "string")
1100
+ return name === "body" ? edit.field : null;
1101
+ if (typeof edit.path !== "string") return null;
1102
+ const apiId = apiIdOf.get(name) ?? name;
1103
+ const text = Array.isArray(edit.text) ? edit.text : [];
1104
+ if (!text.includes(apiId) && !text.includes(name)) return null;
1105
+ return `${edit.path}.items.${apiId}`;
1106
+ };
1107
+ const fields = collectFields(selections, typename ?? void 0, doc, {
1108
+ strict: true
1109
+ });
1110
+ for (const field of fields.values()) {
1111
+ if (field.name === "__typename") {
1112
+ out[field.key] = typename;
1113
+ } else if (field.name === "_id") {
1114
+ out[field.key] = typeof id === "string" ? id : values._id ?? null;
1115
+ } else if (field.selections.length) {
1116
+ const value = valueOf(field.name);
1117
+ out[field.key] = value == null && lists.has(field.key) ? [] : fillNested(doc, field.selections, value, ctx);
1118
+ } else {
1119
+ const value = valueOf(field.name);
1120
+ if (Array.isArray(value) && value.every(isScalarItem)) {
1121
+ out[field.key] = value;
1122
+ continue;
1123
+ }
1124
+ if (value == null && lists.has(field.key)) {
1125
+ out[field.key] = [];
1126
+ continue;
1127
+ }
1128
+ const scalar = value === void 0 || value !== null && typeof value === "object" ? null : value;
1129
+ const target = typeof scalar === "string" ? editField(field.name) : null;
1130
+ out[field.key] = target && links ? links.encode(scalar, target) : scalar;
1131
+ }
1132
+ }
1133
+ return out;
1134
+ }
1135
+ function fillNested(doc, selections, value, ctx) {
1136
+ const one = (item) => {
1137
+ if (!isPlainRecord(item)) return null;
1138
+ const typename = resolveTypename(
1139
+ doc,
1140
+ selections,
1141
+ item.__typename,
1142
+ item.typeName
1143
+ );
1144
+ if (typename === void 0) return null;
1145
+ return fillObject(doc, selections, typename, item, item._id, ctx);
1146
+ };
1147
+ if (Array.isArray(value)) return value.map(one).filter((v) => v !== null);
1148
+ return value === void 0 ? null : one(value);
1149
+ }
1150
+ function isScalarItem(value) {
1151
+ return typeof value === "string" || typeof value === "number" || typeof value === "boolean";
1152
+ }
1153
+ var NO_KEYS = /* @__PURE__ */ new Set();
1154
+ var listKeysCache = /* @__PURE__ */ new WeakMap();
1155
+ function listKeysIn(result) {
1156
+ return (typename) => {
1157
+ if (!typename || result === null || typeof result !== "object") {
1158
+ return NO_KEYS;
1159
+ }
1160
+ let byType = listKeysCache.get(result);
1161
+ if (!byType) {
1162
+ byType = /* @__PURE__ */ new Map();
1163
+ const seen = /* @__PURE__ */ new WeakSet();
1164
+ const walk = (node) => {
1165
+ if (node === null || typeof node !== "object" || seen.has(node)) return;
1166
+ seen.add(node);
1167
+ if (Array.isArray(node)) {
1168
+ node.forEach(walk);
1169
+ return;
1170
+ }
1171
+ const record = node;
1172
+ const type = typeof record.__typename === "string" ? record.__typename : null;
1173
+ for (const [key, value] of Object.entries(record)) {
1174
+ if (type && Array.isArray(value)) {
1175
+ let keys = byType.get(type);
1176
+ if (!keys) byType.set(type, keys = /* @__PURE__ */ new Set());
1177
+ keys.add(key);
1178
+ }
1179
+ walk(value);
1180
+ }
1181
+ };
1182
+ walk(result);
1183
+ listKeysCache.set(result, byType);
1184
+ }
1185
+ return byType.get(typename) ?? NO_KEYS;
1186
+ };
1187
+ }
1188
+ var EDIT_PATH = /\/content\/edit\/[^/?#]+/;
1189
+ function editLinks(result, entry) {
1190
+ const edit = entry.fields?.__edit;
1191
+ if (!isPlainRecord(edit) || typeof edit.item !== "string") return null;
1192
+ return editLinksFor(result, edit.item);
1193
+ }
1194
+ var ITEM_ID = /^[A-Za-z0-9_-]+$/;
1195
+ function editLinksFor(result, item) {
1196
+ if (!ITEM_ID.test(item)) return null;
1197
+ const template = findEditLink(result);
1198
+ if (!template) return null;
1199
+ return {
1200
+ encode(text, field) {
1201
+ if (vercelStegaSplit2(text).encoded) return text;
1202
+ let href;
1203
+ try {
1204
+ href = new URL(template.href);
1205
+ } catch {
1206
+ return text;
1207
+ }
1208
+ href.pathname = href.pathname.replace(
1209
+ EDIT_PATH,
1210
+ () => `/content/edit/${item}`
1211
+ );
1212
+ href.searchParams.set("field", field);
1213
+ const link = href.toString().replace(/%2E/gi, ".").replace(/%2F/gi, "/");
1214
+ return vercelStegaCombine(text, { origin: template.origin, href: link });
1215
+ }
1216
+ };
1217
+ }
1218
+ var linkCache = /* @__PURE__ */ new WeakMap();
1219
+ function findEditLink(root) {
1220
+ if (root === null || typeof root !== "object") return null;
1221
+ if (linkCache.has(root)) return linkCache.get(root) ?? null;
1222
+ let found = null;
1223
+ const seen = /* @__PURE__ */ new WeakSet();
1224
+ const walk = (node) => {
1225
+ if (found) return;
1226
+ if (typeof node === "string") {
1227
+ if (!vercelStegaSplit2(node).encoded) return;
1228
+ try {
1229
+ const decoded = vercelStegaDecode(node);
1230
+ if (typeof decoded?.origin === "string" && typeof decoded.href === "string" && EDIT_PATH.test(decoded.href)) {
1231
+ found = { origin: decoded.origin, href: decoded.href };
1232
+ }
1233
+ } catch {
1234
+ }
1235
+ return;
1236
+ }
1237
+ if (node === null || typeof node !== "object" || seen.has(node)) return;
1238
+ seen.add(node);
1239
+ for (const value of Object.values(node)) walk(value);
1240
+ };
1241
+ walk(root);
1242
+ linkCache.set(root, found);
1243
+ return found;
1244
+ }
1245
+
1246
+ // src/nextjs/server.ts
1247
+ import * as React from "react";
1248
+
1249
+ // src/nextjs/live-log.ts
1250
+ var LIVE_LOG_COOKIE = "__prepr_live";
1251
+ var MAX_SLOTS = 50;
1252
+ var TOKEN_PATTERN = /^[0-9a-f]{32}$/;
1253
+ var KEY = /* @__PURE__ */ Symbol.for("@preprio/toolkit/live-log");
1254
+ function slots() {
1255
+ const holder = globalThis;
1256
+ let map = holder[KEY];
1257
+ if (!map) {
1258
+ map = /* @__PURE__ */ new Map();
1259
+ holder[KEY] = map;
1260
+ }
1261
+ return map;
1262
+ }
1263
+ function prune(map, now) {
1264
+ for (const [token, slot] of map) {
1265
+ if (slot.expires <= now) map.delete(token);
1266
+ }
1267
+ while (map.size >= MAX_SLOTS) {
1268
+ map.delete(map.keys().next().value);
1269
+ }
1270
+ }
1271
+ function takeLiveLog(token) {
1272
+ if (!token || !TOKEN_PATTERN.test(token)) return [];
1273
+ const map = slots();
1274
+ const slot = map.get(token);
1275
+ map.delete(token);
1276
+ const now = Date.now();
1277
+ prune(map, now);
1278
+ if (!slot || slot.expires <= now) return [];
1279
+ return slot.log;
1280
+ }
231
1281
 
232
1282
  // src/core/server.ts
233
1283
  var PreprError = class extends Error {
@@ -416,6 +1466,27 @@ async function getToolbarProps(token, features) {
416
1466
  const h = await readHeaders();
417
1467
  return getToolbarPropsFromHeaders(h, token, features);
418
1468
  }
1469
+ var HEADER_NEXT_ACTION = "next-action";
1470
+ var cacheForRender = React.cache ?? ((fn) => fn);
1471
+ var getPreprLiveLog = cacheForRender(
1472
+ async () => {
1473
+ let token;
1474
+ try {
1475
+ if (!(await headers()).has(HEADER_NEXT_ACTION)) return [];
1476
+ token = (await cookies()).get(LIVE_LOG_COOKIE)?.value;
1477
+ } catch (error) {
1478
+ navigation.unstable_rethrow?.(error);
1479
+ return [];
1480
+ }
1481
+ return takeLiveLog(token);
1482
+ }
1483
+ );
1484
+ async function normalizeQuery(query, result, options = {}) {
1485
+ if (!options.enabled) return result;
1486
+ const log = await getPreprLiveLog();
1487
+ if (!log.length) return result;
1488
+ return applyPatchLog(query, result, log, options.operationName);
1489
+ }
419
1490
 
420
1491
  // src/nextjs/index.ts
421
1492
  import {
@@ -433,5 +1504,6 @@ export {
433
1504
  getPreprHeaders,
434
1505
  getPreprUUID,
435
1506
  getToolbarProps,
1507
+ normalizeQuery,
436
1508
  validatePreprToken
437
1509
  };