@preprio/toolkit 1.0.0-rc.6 → 1.0.0-rc.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/astro/index.cjs +25 -25
- package/dist/astro/index.js +25 -25
- package/dist/{chunk-WQRPW3TM.js → chunk-6EWXOHZZ.js} +1 -1
- package/dist/{chunk-OCTRCNW2.js → chunk-GIZY3JFC.js} +1 -1
- package/dist/{chunk-RWFAFYHU.js → chunk-J4POHQKB.js} +24 -24
- package/dist/{chunk-SAOE54OB.js → chunk-OKP6KD3I.js} +1 -1
- package/dist/{chunk-I26P2EQI.js → chunk-WQXLVSHA.js} +1 -1
- package/dist/index.cjs +26 -26
- package/dist/index.d.cts +5 -4
- package/dist/index.d.ts +5 -4
- package/dist/index.js +6 -6
- package/dist/{live-preview-NUDEDAYQ.js → live-preview-PLHDSQ53.js} +2 -2
- package/dist/nextjs/components.cjs +1 -1
- package/dist/nextjs/components.js +2 -2
- package/dist/nextjs/index.cjs +25 -25
- package/dist/nextjs/index.d.cts +6 -2
- package/dist/nextjs/index.d.ts +6 -2
- package/dist/nextjs/index.js +25 -25
- package/dist/nextjs/live-action.js +3 -3
- package/dist/nextjs/live.cjs +42 -29
- package/dist/nextjs/live.d.cts +6 -2
- package/dist/nextjs/live.d.ts +6 -2
- package/dist/nextjs/live.js +18 -8
- package/dist/nuxt/index.cjs +1 -1
- package/dist/nuxt/index.js +1 -1
- package/dist/nuxt/{live-preview-V2X6GPSK.js → live-preview-T5YCASSA.js} +23 -21
- package/dist/nuxt/live.cjs +25 -22
- package/dist/nuxt/live.js +1 -1
- package/dist/react/components.cjs +1 -1
- package/dist/react/components.js +1 -1
- package/dist/sveltekit/index.cjs +1 -1
- package/dist/sveltekit/index.js +1 -1
- package/dist/sveltekit/{live-preview-V2X6GPSK.js → live-preview-T5YCASSA.js} +23 -21
- package/dist/sveltekit/live.cjs +25 -22
- package/dist/sveltekit/live.js +1 -1
- package/package.json +1 -1
package/dist/astro/index.cjs
CHANGED
|
@@ -34,7 +34,7 @@ __export(astro_exports, {
|
|
|
34
34
|
module.exports = __toCommonJS(astro_exports);
|
|
35
35
|
|
|
36
36
|
// src/version.ts
|
|
37
|
-
var VERSION = "1.0.0-rc.
|
|
37
|
+
var VERSION = "1.0.0-rc.7";
|
|
38
38
|
|
|
39
39
|
// src/core/constants.ts
|
|
40
40
|
var COOKIE_PREVIEW_MODE = "Prepr-Preview-Mode";
|
|
@@ -563,62 +563,59 @@ function indexSnapshot(data) {
|
|
|
563
563
|
return index;
|
|
564
564
|
}
|
|
565
565
|
|
|
566
|
-
// src/core/live-preview/patch.ts
|
|
567
|
-
var import_stega2 = require("@vercel/stega");
|
|
568
|
-
|
|
569
566
|
// src/core/live-preview/internal-links.ts
|
|
570
567
|
var INTERNAL_HREF = /^[pa]uuid#/;
|
|
568
|
+
var INTERNAL_MARK = "uuid#";
|
|
571
569
|
var ANCHOR = /<a\b([^>]*)>([\s\S]*?)<\/a>/gi;
|
|
572
570
|
var HREF = /(\shref\s*=\s*)(["'])(.*?)\2/i;
|
|
573
571
|
var TAGS = /<[^>]+>/g;
|
|
572
|
+
var MAX_PAIRINGS = 25e4;
|
|
574
573
|
function anchorsIn(html) {
|
|
575
574
|
const out = [];
|
|
576
575
|
for (const match of html.matchAll(ANCHOR)) {
|
|
577
576
|
const attributes = match[1];
|
|
578
577
|
const inner = match[2];
|
|
578
|
+
const href = HREF.exec(attributes)?.[3] ?? null;
|
|
579
579
|
out.push({
|
|
580
580
|
start: match.index ?? 0,
|
|
581
581
|
end: (match.index ?? 0) + match[0].length,
|
|
582
582
|
attributes,
|
|
583
583
|
inner,
|
|
584
|
-
href
|
|
584
|
+
href,
|
|
585
|
+
internal: href !== null && INTERNAL_HREF.test(href),
|
|
585
586
|
text: inner.replace(TAGS, "").trim()
|
|
586
587
|
});
|
|
587
588
|
}
|
|
588
589
|
return out;
|
|
589
590
|
}
|
|
590
|
-
var isInternal = (anchor) => anchor.href !== null && INTERNAL_HREF.test(anchor.href);
|
|
591
591
|
function fit(pushed, page) {
|
|
592
|
-
if (
|
|
593
|
-
if (isInternal(pushed) && page.href !== null && INTERNAL_HREF.test(page.href))
|
|
594
|
-
return 0;
|
|
592
|
+
if (pushed.internal ? page.internal : pushed.href !== page.href) return 0;
|
|
595
593
|
return pushed.text === page.text ? 2 : 1;
|
|
596
594
|
}
|
|
597
595
|
function align(pushed, page) {
|
|
598
|
-
const
|
|
596
|
+
const out = new Array(pushed.length).fill(-1);
|
|
597
|
+
if (!page.length || pushed.length * page.length > MAX_PAIRINGS) return out;
|
|
599
598
|
const cols = page.length + 1;
|
|
600
|
-
const score =
|
|
601
|
-
{ length: rows },
|
|
602
|
-
() => new Array(cols).fill(0)
|
|
603
|
-
);
|
|
599
|
+
const score = new Int32Array((pushed.length + 1) * cols);
|
|
604
600
|
for (let i2 = pushed.length - 1; i2 >= 0; i2--) {
|
|
605
601
|
for (let j2 = page.length - 1; j2 >= 0; j2--) {
|
|
602
|
+
const at = i2 * cols + j2;
|
|
606
603
|
const pair = fit(pushed[i2], page[j2]);
|
|
607
|
-
score[
|
|
608
|
-
score[
|
|
609
|
-
score[
|
|
610
|
-
pair ? pair + score[
|
|
604
|
+
score[at] = Math.max(
|
|
605
|
+
score[at + cols],
|
|
606
|
+
score[at + 1],
|
|
607
|
+
pair ? pair + score[at + cols + 1] : 0
|
|
611
608
|
);
|
|
612
609
|
}
|
|
613
610
|
}
|
|
614
|
-
const out = new Array(pushed.length).fill(-1);
|
|
615
611
|
let i = 0;
|
|
616
612
|
let j = 0;
|
|
617
613
|
while (i < pushed.length && j < page.length) {
|
|
614
|
+
const at = i * cols + j;
|
|
618
615
|
const pair = fit(pushed[i], page[j]);
|
|
619
|
-
if (pair && score[
|
|
616
|
+
if (pair && score[at] === pair + score[at + cols + 1]) {
|
|
620
617
|
out[i++] = j++;
|
|
621
|
-
} else if (score[
|
|
618
|
+
} else if (score[at + cols] >= score[at + 1]) {
|
|
622
619
|
i++;
|
|
623
620
|
} else {
|
|
624
621
|
j++;
|
|
@@ -627,14 +624,15 @@ function align(pushed, page) {
|
|
|
627
624
|
return out;
|
|
628
625
|
}
|
|
629
626
|
function resolveInternalLinks(current, value) {
|
|
627
|
+
if (!value.includes(INTERNAL_MARK)) return value;
|
|
630
628
|
const pushed = anchorsIn(value);
|
|
631
|
-
if (!pushed.some(
|
|
629
|
+
if (!pushed.some((anchor) => anchor.internal)) return value;
|
|
632
630
|
const page = typeof current === "string" ? anchorsIn(current) : [];
|
|
633
631
|
const pairs = align(pushed, page);
|
|
634
632
|
let out = "";
|
|
635
633
|
let cursor = 0;
|
|
636
634
|
pushed.forEach((anchor, i) => {
|
|
637
|
-
if (!
|
|
635
|
+
if (!anchor.internal) return;
|
|
638
636
|
out += value.slice(cursor, anchor.start);
|
|
639
637
|
const match = pairs[i] >= 0 ? page[pairs[i]] : null;
|
|
640
638
|
if (match?.href != null) {
|
|
@@ -653,6 +651,7 @@ function resolveInternalLinks(current, value) {
|
|
|
653
651
|
}
|
|
654
652
|
|
|
655
653
|
// src/core/live-preview/patch.ts
|
|
654
|
+
var import_stega2 = require("@vercel/stega");
|
|
656
655
|
var FORBIDDEN_SEGMENTS = /* @__PURE__ */ new Set(["__proto__", "prototype", "constructor"]);
|
|
657
656
|
function mergeObject(current, incoming) {
|
|
658
657
|
let changed = false;
|
|
@@ -776,7 +775,7 @@ function listKeysOf(entry) {
|
|
|
776
775
|
return keys;
|
|
777
776
|
}
|
|
778
777
|
function buildText(entry, template) {
|
|
779
|
-
const body = typeof entry.body === "string" ? entry.body : "";
|
|
778
|
+
const body = typeof entry.body === "string" ? resolveInternalLinks(null, entry.body) : "";
|
|
780
779
|
const full = {
|
|
781
780
|
__typename: "Text",
|
|
782
781
|
_id: entry._id,
|
|
@@ -1471,7 +1470,8 @@ function fillObject(doc, selections, typename, values, id, ctx) {
|
|
|
1471
1470
|
out[field.key] = [];
|
|
1472
1471
|
continue;
|
|
1473
1472
|
}
|
|
1474
|
-
const
|
|
1473
|
+
const sent = value === void 0 || value !== null && typeof value === "object" ? null : value;
|
|
1474
|
+
const scalar = typeof sent === "string" ? resolveInternalLinks(null, sent) : sent;
|
|
1475
1475
|
const target = typeof scalar === "string" ? editField(field.name) : null;
|
|
1476
1476
|
out[field.key] = target && links ? links.encode(scalar, target) : scalar;
|
|
1477
1477
|
}
|
package/dist/astro/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/version.ts
|
|
2
|
-
var VERSION = "1.0.0-rc.
|
|
2
|
+
var VERSION = "1.0.0-rc.7";
|
|
3
3
|
|
|
4
4
|
// src/core/constants.ts
|
|
5
5
|
var COOKIE_PREVIEW_MODE = "Prepr-Preview-Mode";
|
|
@@ -532,62 +532,59 @@ function indexSnapshot(data) {
|
|
|
532
532
|
return index;
|
|
533
533
|
}
|
|
534
534
|
|
|
535
|
-
// src/core/live-preview/patch.ts
|
|
536
|
-
import { vercelStegaSplit as vercelStegaSplit2 } from "@vercel/stega";
|
|
537
|
-
|
|
538
535
|
// src/core/live-preview/internal-links.ts
|
|
539
536
|
var INTERNAL_HREF = /^[pa]uuid#/;
|
|
537
|
+
var INTERNAL_MARK = "uuid#";
|
|
540
538
|
var ANCHOR = /<a\b([^>]*)>([\s\S]*?)<\/a>/gi;
|
|
541
539
|
var HREF = /(\shref\s*=\s*)(["'])(.*?)\2/i;
|
|
542
540
|
var TAGS = /<[^>]+>/g;
|
|
541
|
+
var MAX_PAIRINGS = 25e4;
|
|
543
542
|
function anchorsIn(html) {
|
|
544
543
|
const out = [];
|
|
545
544
|
for (const match of html.matchAll(ANCHOR)) {
|
|
546
545
|
const attributes = match[1];
|
|
547
546
|
const inner = match[2];
|
|
547
|
+
const href = HREF.exec(attributes)?.[3] ?? null;
|
|
548
548
|
out.push({
|
|
549
549
|
start: match.index ?? 0,
|
|
550
550
|
end: (match.index ?? 0) + match[0].length,
|
|
551
551
|
attributes,
|
|
552
552
|
inner,
|
|
553
|
-
href
|
|
553
|
+
href,
|
|
554
|
+
internal: href !== null && INTERNAL_HREF.test(href),
|
|
554
555
|
text: inner.replace(TAGS, "").trim()
|
|
555
556
|
});
|
|
556
557
|
}
|
|
557
558
|
return out;
|
|
558
559
|
}
|
|
559
|
-
var isInternal = (anchor) => anchor.href !== null && INTERNAL_HREF.test(anchor.href);
|
|
560
560
|
function fit(pushed, page) {
|
|
561
|
-
if (
|
|
562
|
-
if (isInternal(pushed) && page.href !== null && INTERNAL_HREF.test(page.href))
|
|
563
|
-
return 0;
|
|
561
|
+
if (pushed.internal ? page.internal : pushed.href !== page.href) return 0;
|
|
564
562
|
return pushed.text === page.text ? 2 : 1;
|
|
565
563
|
}
|
|
566
564
|
function align(pushed, page) {
|
|
567
|
-
const
|
|
565
|
+
const out = new Array(pushed.length).fill(-1);
|
|
566
|
+
if (!page.length || pushed.length * page.length > MAX_PAIRINGS) return out;
|
|
568
567
|
const cols = page.length + 1;
|
|
569
|
-
const score =
|
|
570
|
-
{ length: rows },
|
|
571
|
-
() => new Array(cols).fill(0)
|
|
572
|
-
);
|
|
568
|
+
const score = new Int32Array((pushed.length + 1) * cols);
|
|
573
569
|
for (let i2 = pushed.length - 1; i2 >= 0; i2--) {
|
|
574
570
|
for (let j2 = page.length - 1; j2 >= 0; j2--) {
|
|
571
|
+
const at = i2 * cols + j2;
|
|
575
572
|
const pair = fit(pushed[i2], page[j2]);
|
|
576
|
-
score[
|
|
577
|
-
score[
|
|
578
|
-
score[
|
|
579
|
-
pair ? pair + score[
|
|
573
|
+
score[at] = Math.max(
|
|
574
|
+
score[at + cols],
|
|
575
|
+
score[at + 1],
|
|
576
|
+
pair ? pair + score[at + cols + 1] : 0
|
|
580
577
|
);
|
|
581
578
|
}
|
|
582
579
|
}
|
|
583
|
-
const out = new Array(pushed.length).fill(-1);
|
|
584
580
|
let i = 0;
|
|
585
581
|
let j = 0;
|
|
586
582
|
while (i < pushed.length && j < page.length) {
|
|
583
|
+
const at = i * cols + j;
|
|
587
584
|
const pair = fit(pushed[i], page[j]);
|
|
588
|
-
if (pair && score[
|
|
585
|
+
if (pair && score[at] === pair + score[at + cols + 1]) {
|
|
589
586
|
out[i++] = j++;
|
|
590
|
-
} else if (score[
|
|
587
|
+
} else if (score[at + cols] >= score[at + 1]) {
|
|
591
588
|
i++;
|
|
592
589
|
} else {
|
|
593
590
|
j++;
|
|
@@ -596,14 +593,15 @@ function align(pushed, page) {
|
|
|
596
593
|
return out;
|
|
597
594
|
}
|
|
598
595
|
function resolveInternalLinks(current, value) {
|
|
596
|
+
if (!value.includes(INTERNAL_MARK)) return value;
|
|
599
597
|
const pushed = anchorsIn(value);
|
|
600
|
-
if (!pushed.some(
|
|
598
|
+
if (!pushed.some((anchor) => anchor.internal)) return value;
|
|
601
599
|
const page = typeof current === "string" ? anchorsIn(current) : [];
|
|
602
600
|
const pairs = align(pushed, page);
|
|
603
601
|
let out = "";
|
|
604
602
|
let cursor = 0;
|
|
605
603
|
pushed.forEach((anchor, i) => {
|
|
606
|
-
if (!
|
|
604
|
+
if (!anchor.internal) return;
|
|
607
605
|
out += value.slice(cursor, anchor.start);
|
|
608
606
|
const match = pairs[i] >= 0 ? page[pairs[i]] : null;
|
|
609
607
|
if (match?.href != null) {
|
|
@@ -622,6 +620,7 @@ function resolveInternalLinks(current, value) {
|
|
|
622
620
|
}
|
|
623
621
|
|
|
624
622
|
// src/core/live-preview/patch.ts
|
|
623
|
+
import { vercelStegaSplit as vercelStegaSplit2 } from "@vercel/stega";
|
|
625
624
|
var FORBIDDEN_SEGMENTS = /* @__PURE__ */ new Set(["__proto__", "prototype", "constructor"]);
|
|
626
625
|
function mergeObject(current, incoming) {
|
|
627
626
|
let changed = false;
|
|
@@ -745,7 +744,7 @@ function listKeysOf(entry) {
|
|
|
745
744
|
return keys;
|
|
746
745
|
}
|
|
747
746
|
function buildText(entry, template) {
|
|
748
|
-
const body = typeof entry.body === "string" ? entry.body : "";
|
|
747
|
+
const body = typeof entry.body === "string" ? resolveInternalLinks(null, entry.body) : "";
|
|
749
748
|
const full = {
|
|
750
749
|
__typename: "Text",
|
|
751
750
|
_id: entry._id,
|
|
@@ -1440,7 +1439,8 @@ function fillObject(doc, selections, typename, values, id, ctx) {
|
|
|
1440
1439
|
out[field.key] = [];
|
|
1441
1440
|
continue;
|
|
1442
1441
|
}
|
|
1443
|
-
const
|
|
1442
|
+
const sent = value === void 0 || value !== null && typeof value === "object" ? null : value;
|
|
1443
|
+
const scalar = typeof sent === "string" ? resolveInternalLinks(null, sent) : sent;
|
|
1444
1444
|
const target = typeof scalar === "string" ? editField(field.name) : null;
|
|
1445
1445
|
out[field.key] = target && links ? links.encode(scalar, target) : scalar;
|
|
1446
1446
|
}
|
|
@@ -280,62 +280,59 @@ function indexSnapshot(data) {
|
|
|
280
280
|
return index;
|
|
281
281
|
}
|
|
282
282
|
|
|
283
|
-
// src/core/live-preview/patch.ts
|
|
284
|
-
import { vercelStegaSplit as vercelStegaSplit2 } from "@vercel/stega";
|
|
285
|
-
|
|
286
283
|
// src/core/live-preview/internal-links.ts
|
|
287
284
|
var INTERNAL_HREF = /^[pa]uuid#/;
|
|
285
|
+
var INTERNAL_MARK = "uuid#";
|
|
288
286
|
var ANCHOR = /<a\b([^>]*)>([\s\S]*?)<\/a>/gi;
|
|
289
287
|
var HREF = /(\shref\s*=\s*)(["'])(.*?)\2/i;
|
|
290
288
|
var TAGS = /<[^>]+>/g;
|
|
289
|
+
var MAX_PAIRINGS = 25e4;
|
|
291
290
|
function anchorsIn(html) {
|
|
292
291
|
const out = [];
|
|
293
292
|
for (const match of html.matchAll(ANCHOR)) {
|
|
294
293
|
const attributes = match[1];
|
|
295
294
|
const inner = match[2];
|
|
295
|
+
const href = HREF.exec(attributes)?.[3] ?? null;
|
|
296
296
|
out.push({
|
|
297
297
|
start: match.index ?? 0,
|
|
298
298
|
end: (match.index ?? 0) + match[0].length,
|
|
299
299
|
attributes,
|
|
300
300
|
inner,
|
|
301
|
-
href
|
|
301
|
+
href,
|
|
302
|
+
internal: href !== null && INTERNAL_HREF.test(href),
|
|
302
303
|
text: inner.replace(TAGS, "").trim()
|
|
303
304
|
});
|
|
304
305
|
}
|
|
305
306
|
return out;
|
|
306
307
|
}
|
|
307
|
-
var isInternal = (anchor) => anchor.href !== null && INTERNAL_HREF.test(anchor.href);
|
|
308
308
|
function fit(pushed, page) {
|
|
309
|
-
if (
|
|
310
|
-
if (isInternal(pushed) && page.href !== null && INTERNAL_HREF.test(page.href))
|
|
311
|
-
return 0;
|
|
309
|
+
if (pushed.internal ? page.internal : pushed.href !== page.href) return 0;
|
|
312
310
|
return pushed.text === page.text ? 2 : 1;
|
|
313
311
|
}
|
|
314
312
|
function align(pushed, page) {
|
|
315
|
-
const
|
|
313
|
+
const out = new Array(pushed.length).fill(-1);
|
|
314
|
+
if (!page.length || pushed.length * page.length > MAX_PAIRINGS) return out;
|
|
316
315
|
const cols = page.length + 1;
|
|
317
|
-
const score =
|
|
318
|
-
{ length: rows },
|
|
319
|
-
() => new Array(cols).fill(0)
|
|
320
|
-
);
|
|
316
|
+
const score = new Int32Array((pushed.length + 1) * cols);
|
|
321
317
|
for (let i2 = pushed.length - 1; i2 >= 0; i2--) {
|
|
322
318
|
for (let j2 = page.length - 1; j2 >= 0; j2--) {
|
|
319
|
+
const at = i2 * cols + j2;
|
|
323
320
|
const pair = fit(pushed[i2], page[j2]);
|
|
324
|
-
score[
|
|
325
|
-
score[
|
|
326
|
-
score[
|
|
327
|
-
pair ? pair + score[
|
|
321
|
+
score[at] = Math.max(
|
|
322
|
+
score[at + cols],
|
|
323
|
+
score[at + 1],
|
|
324
|
+
pair ? pair + score[at + cols + 1] : 0
|
|
328
325
|
);
|
|
329
326
|
}
|
|
330
327
|
}
|
|
331
|
-
const out = new Array(pushed.length).fill(-1);
|
|
332
328
|
let i = 0;
|
|
333
329
|
let j = 0;
|
|
334
330
|
while (i < pushed.length && j < page.length) {
|
|
331
|
+
const at = i * cols + j;
|
|
335
332
|
const pair = fit(pushed[i], page[j]);
|
|
336
|
-
if (pair && score[
|
|
333
|
+
if (pair && score[at] === pair + score[at + cols + 1]) {
|
|
337
334
|
out[i++] = j++;
|
|
338
|
-
} else if (score[
|
|
335
|
+
} else if (score[at + cols] >= score[at + 1]) {
|
|
339
336
|
i++;
|
|
340
337
|
} else {
|
|
341
338
|
j++;
|
|
@@ -344,14 +341,15 @@ function align(pushed, page) {
|
|
|
344
341
|
return out;
|
|
345
342
|
}
|
|
346
343
|
function resolveInternalLinks(current, value) {
|
|
344
|
+
if (!value.includes(INTERNAL_MARK)) return value;
|
|
347
345
|
const pushed = anchorsIn(value);
|
|
348
|
-
if (!pushed.some(
|
|
346
|
+
if (!pushed.some((anchor) => anchor.internal)) return value;
|
|
349
347
|
const page = typeof current === "string" ? anchorsIn(current) : [];
|
|
350
348
|
const pairs = align(pushed, page);
|
|
351
349
|
let out = "";
|
|
352
350
|
let cursor = 0;
|
|
353
351
|
pushed.forEach((anchor, i) => {
|
|
354
|
-
if (!
|
|
352
|
+
if (!anchor.internal) return;
|
|
355
353
|
out += value.slice(cursor, anchor.start);
|
|
356
354
|
const match = pairs[i] >= 0 ? page[pairs[i]] : null;
|
|
357
355
|
if (match?.href != null) {
|
|
@@ -370,6 +368,7 @@ function resolveInternalLinks(current, value) {
|
|
|
370
368
|
}
|
|
371
369
|
|
|
372
370
|
// src/core/live-preview/patch.ts
|
|
371
|
+
import { vercelStegaSplit as vercelStegaSplit2 } from "@vercel/stega";
|
|
373
372
|
var INDEX_SEGMENT = /^\d+$/;
|
|
374
373
|
var FORBIDDEN_SEGMENTS = /* @__PURE__ */ new Set(["__proto__", "prototype", "constructor"]);
|
|
375
374
|
function mergeObject(current, incoming) {
|
|
@@ -564,7 +563,7 @@ function listKeysOf(entry) {
|
|
|
564
563
|
return keys;
|
|
565
564
|
}
|
|
566
565
|
function buildText(entry, template) {
|
|
567
|
-
const body = typeof entry.body === "string" ? entry.body : "";
|
|
566
|
+
const body = typeof entry.body === "string" ? resolveInternalLinks(null, entry.body) : "";
|
|
568
567
|
const full = {
|
|
569
568
|
__typename: "Text",
|
|
570
569
|
_id: entry._id,
|
|
@@ -1270,7 +1269,8 @@ function fillObject(doc, selections, typename, values, id, ctx) {
|
|
|
1270
1269
|
out[field.key] = [];
|
|
1271
1270
|
continue;
|
|
1272
1271
|
}
|
|
1273
|
-
const
|
|
1272
|
+
const sent = value === void 0 || value !== null && typeof value === "object" ? null : value;
|
|
1273
|
+
const scalar = typeof sent === "string" ? resolveInternalLinks(null, sent) : sent;
|
|
1274
1274
|
const target = typeof scalar === "string" ? editField(field.name) : null;
|
|
1275
1275
|
out[field.key] = target && links ? links.encode(scalar, target) : scalar;
|
|
1276
1276
|
}
|
package/dist/index.cjs
CHANGED
|
@@ -51,7 +51,7 @@ __export(src_exports, {
|
|
|
51
51
|
module.exports = __toCommonJS(src_exports);
|
|
52
52
|
|
|
53
53
|
// src/version.ts
|
|
54
|
-
var VERSION = "1.0.0-rc.
|
|
54
|
+
var VERSION = "1.0.0-rc.7";
|
|
55
55
|
|
|
56
56
|
// src/core/features.ts
|
|
57
57
|
function isEnabled(config) {
|
|
@@ -4046,62 +4046,59 @@ function indexSnapshot(data) {
|
|
|
4046
4046
|
return index;
|
|
4047
4047
|
}
|
|
4048
4048
|
|
|
4049
|
-
// src/core/live-preview/patch.ts
|
|
4050
|
-
var import_stega6 = require("@vercel/stega");
|
|
4051
|
-
|
|
4052
4049
|
// src/core/live-preview/internal-links.ts
|
|
4053
4050
|
var INTERNAL_HREF = /^[pa]uuid#/;
|
|
4051
|
+
var INTERNAL_MARK = "uuid#";
|
|
4054
4052
|
var ANCHOR = /<a\b([^>]*)>([\s\S]*?)<\/a>/gi;
|
|
4055
4053
|
var HREF = /(\shref\s*=\s*)(["'])(.*?)\2/i;
|
|
4056
4054
|
var TAGS = /<[^>]+>/g;
|
|
4055
|
+
var MAX_PAIRINGS = 25e4;
|
|
4057
4056
|
function anchorsIn(html) {
|
|
4058
4057
|
const out = [];
|
|
4059
4058
|
for (const match of html.matchAll(ANCHOR)) {
|
|
4060
4059
|
const attributes = match[1];
|
|
4061
4060
|
const inner = match[2];
|
|
4061
|
+
const href = HREF.exec(attributes)?.[3] ?? null;
|
|
4062
4062
|
out.push({
|
|
4063
4063
|
start: match.index ?? 0,
|
|
4064
4064
|
end: (match.index ?? 0) + match[0].length,
|
|
4065
4065
|
attributes,
|
|
4066
4066
|
inner,
|
|
4067
|
-
href
|
|
4067
|
+
href,
|
|
4068
|
+
internal: href !== null && INTERNAL_HREF.test(href),
|
|
4068
4069
|
text: inner.replace(TAGS, "").trim()
|
|
4069
4070
|
});
|
|
4070
4071
|
}
|
|
4071
4072
|
return out;
|
|
4072
4073
|
}
|
|
4073
|
-
var isInternal = (anchor) => anchor.href !== null && INTERNAL_HREF.test(anchor.href);
|
|
4074
4074
|
function fit(pushed, page) {
|
|
4075
|
-
if (
|
|
4076
|
-
if (isInternal(pushed) && page.href !== null && INTERNAL_HREF.test(page.href))
|
|
4077
|
-
return 0;
|
|
4075
|
+
if (pushed.internal ? page.internal : pushed.href !== page.href) return 0;
|
|
4078
4076
|
return pushed.text === page.text ? 2 : 1;
|
|
4079
4077
|
}
|
|
4080
4078
|
function align(pushed, page) {
|
|
4081
|
-
const
|
|
4079
|
+
const out = new Array(pushed.length).fill(-1);
|
|
4080
|
+
if (!page.length || pushed.length * page.length > MAX_PAIRINGS) return out;
|
|
4082
4081
|
const cols = page.length + 1;
|
|
4083
|
-
const score =
|
|
4084
|
-
{ length: rows },
|
|
4085
|
-
() => new Array(cols).fill(0)
|
|
4086
|
-
);
|
|
4082
|
+
const score = new Int32Array((pushed.length + 1) * cols);
|
|
4087
4083
|
for (let i3 = pushed.length - 1; i3 >= 0; i3--) {
|
|
4088
4084
|
for (let j3 = page.length - 1; j3 >= 0; j3--) {
|
|
4085
|
+
const at = i3 * cols + j3;
|
|
4089
4086
|
const pair = fit(pushed[i3], page[j3]);
|
|
4090
|
-
score[
|
|
4091
|
-
score[
|
|
4092
|
-
score[
|
|
4093
|
-
pair ? pair + score[
|
|
4087
|
+
score[at] = Math.max(
|
|
4088
|
+
score[at + cols],
|
|
4089
|
+
score[at + 1],
|
|
4090
|
+
pair ? pair + score[at + cols + 1] : 0
|
|
4094
4091
|
);
|
|
4095
4092
|
}
|
|
4096
4093
|
}
|
|
4097
|
-
const out = new Array(pushed.length).fill(-1);
|
|
4098
4094
|
let i2 = 0;
|
|
4099
4095
|
let j2 = 0;
|
|
4100
4096
|
while (i2 < pushed.length && j2 < page.length) {
|
|
4097
|
+
const at = i2 * cols + j2;
|
|
4101
4098
|
const pair = fit(pushed[i2], page[j2]);
|
|
4102
|
-
if (pair && score[
|
|
4099
|
+
if (pair && score[at] === pair + score[at + cols + 1]) {
|
|
4103
4100
|
out[i2++] = j2++;
|
|
4104
|
-
} else if (score[
|
|
4101
|
+
} else if (score[at + cols] >= score[at + 1]) {
|
|
4105
4102
|
i2++;
|
|
4106
4103
|
} else {
|
|
4107
4104
|
j2++;
|
|
@@ -4110,14 +4107,15 @@ function align(pushed, page) {
|
|
|
4110
4107
|
return out;
|
|
4111
4108
|
}
|
|
4112
4109
|
function resolveInternalLinks(current, value) {
|
|
4110
|
+
if (!value.includes(INTERNAL_MARK)) return value;
|
|
4113
4111
|
const pushed = anchorsIn(value);
|
|
4114
|
-
if (!pushed.some(
|
|
4112
|
+
if (!pushed.some((anchor) => anchor.internal)) return value;
|
|
4115
4113
|
const page = typeof current === "string" ? anchorsIn(current) : [];
|
|
4116
4114
|
const pairs = align(pushed, page);
|
|
4117
4115
|
let out = "";
|
|
4118
4116
|
let cursor = 0;
|
|
4119
4117
|
pushed.forEach((anchor, i2) => {
|
|
4120
|
-
if (!
|
|
4118
|
+
if (!anchor.internal) return;
|
|
4121
4119
|
out += value.slice(cursor, anchor.start);
|
|
4122
4120
|
const match = pairs[i2] >= 0 ? page[pairs[i2]] : null;
|
|
4123
4121
|
if (match?.href != null) {
|
|
@@ -4136,6 +4134,7 @@ function resolveInternalLinks(current, value) {
|
|
|
4136
4134
|
}
|
|
4137
4135
|
|
|
4138
4136
|
// src/core/live-preview/patch.ts
|
|
4137
|
+
var import_stega6 = require("@vercel/stega");
|
|
4139
4138
|
var INDEX_SEGMENT2 = /^\d+$/;
|
|
4140
4139
|
var FORBIDDEN_SEGMENTS = /* @__PURE__ */ new Set(["__proto__", "prototype", "constructor"]);
|
|
4141
4140
|
function mergeObject(current, incoming) {
|
|
@@ -4330,7 +4329,7 @@ function listKeysOf(entry) {
|
|
|
4330
4329
|
return keys;
|
|
4331
4330
|
}
|
|
4332
4331
|
function buildText(entry, template) {
|
|
4333
|
-
const body = typeof entry.body === "string" ? entry.body : "";
|
|
4332
|
+
const body = typeof entry.body === "string" ? resolveInternalLinks(null, entry.body) : "";
|
|
4334
4333
|
const full = {
|
|
4335
4334
|
__typename: "Text",
|
|
4336
4335
|
_id: entry._id,
|
|
@@ -5036,7 +5035,8 @@ function fillObject(doc, selections, typename, values, id, ctx) {
|
|
|
5036
5035
|
out[field.key] = [];
|
|
5037
5036
|
continue;
|
|
5038
5037
|
}
|
|
5039
|
-
const
|
|
5038
|
+
const sent = value === void 0 || value !== null && typeof value === "object" ? null : value;
|
|
5039
|
+
const scalar = typeof sent === "string" ? resolveInternalLinks(null, sent) : sent;
|
|
5040
5040
|
const target = typeof scalar === "string" ? editField(field.name) : null;
|
|
5041
5041
|
out[field.key] = target && links ? links.encode(scalar, target) : scalar;
|
|
5042
5042
|
}
|
|
@@ -5501,7 +5501,7 @@ function adopt(node, parent) {
|
|
|
5501
5501
|
// src/core/live-preview/html-live.ts
|
|
5502
5502
|
var debug14 = createScopedLogger("live-preview:html");
|
|
5503
5503
|
var COMPLETE_DOCUMENT = /<\/html>\s*$/i;
|
|
5504
|
-
var SYNC_DEBOUNCE_MS =
|
|
5504
|
+
var SYNC_DEBOUNCE_MS = 0;
|
|
5505
5505
|
function startHtmlLivePreview(options = {}) {
|
|
5506
5506
|
if (typeof window === "undefined" || window.self === window.top) {
|
|
5507
5507
|
return { stop() {
|
package/dist/index.d.cts
CHANGED
|
@@ -5,7 +5,7 @@ export { g as PreprEnvironment, h as PreprEventType, i as PreprFeatureConfig, j
|
|
|
5
5
|
* Package version; must match package.json. Lives in its own leaf module so
|
|
6
6
|
* core can import it without cycling through the barrel.
|
|
7
7
|
*/
|
|
8
|
-
declare const VERSION = "1.0.0-rc.
|
|
8
|
+
declare const VERSION = "1.0.0-rc.7";
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Resolve a `PreprFeatures` bag to plain booleans, defaulting every omitted key
|
|
@@ -449,9 +449,10 @@ interface HtmlLivePreviewOptions {
|
|
|
449
449
|
strictMode?: boolean;
|
|
450
450
|
/**
|
|
451
451
|
* How long typing must pause, in milliseconds, before the page is
|
|
452
|
-
* requested with the unsaved changes. Default
|
|
453
|
-
*
|
|
454
|
-
*
|
|
452
|
+
* requested with the unsaved changes. Default 0: the page is requested as
|
|
453
|
+
* soon as the editor sends a change, which it does after a pause of its
|
|
454
|
+
* own. Requests run one at a time either way; raise this when a render is
|
|
455
|
+
* expensive, to have fewer of them.
|
|
455
456
|
*/
|
|
456
457
|
syncDebounceMs?: number;
|
|
457
458
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export { g as PreprEnvironment, h as PreprEventType, i as PreprFeatureConfig, j
|
|
|
5
5
|
* Package version; must match package.json. Lives in its own leaf module so
|
|
6
6
|
* core can import it without cycling through the barrel.
|
|
7
7
|
*/
|
|
8
|
-
declare const VERSION = "1.0.0-rc.
|
|
8
|
+
declare const VERSION = "1.0.0-rc.7";
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Resolve a `PreprFeatures` bag to plain booleans, defaulting every omitted key
|
|
@@ -449,9 +449,10 @@ interface HtmlLivePreviewOptions {
|
|
|
449
449
|
strictMode?: boolean;
|
|
450
450
|
/**
|
|
451
451
|
* How long typing must pause, in milliseconds, before the page is
|
|
452
|
-
* requested with the unsaved changes. Default
|
|
453
|
-
*
|
|
454
|
-
*
|
|
452
|
+
* requested with the unsaved changes. Default 0: the page is requested as
|
|
453
|
+
* soon as the editor sends a change, which it does after a pause of its
|
|
454
|
+
* own. Requests run one at a time either way; raise this when a render is
|
|
455
|
+
* expensive, to have fewer of them.
|
|
455
456
|
*/
|
|
456
457
|
syncDebounceMs?: number;
|
|
457
458
|
}
|
package/dist/index.js
CHANGED
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
setTrackingParam,
|
|
9
9
|
stegaClean,
|
|
10
10
|
trackEvent
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-6EWXOHZZ.js";
|
|
12
12
|
import {
|
|
13
13
|
PreprError,
|
|
14
14
|
extractAccessToken,
|
|
@@ -19,15 +19,15 @@ import {
|
|
|
19
19
|
getPreprUUIDFromHeaders,
|
|
20
20
|
getToolbarPropsFromHeaders,
|
|
21
21
|
validatePreprToken
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-OKP6KD3I.js";
|
|
23
23
|
import {
|
|
24
24
|
VERSION,
|
|
25
25
|
resolveFeatures
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-GIZY3JFC.js";
|
|
27
27
|
import {
|
|
28
28
|
createLiveBridge,
|
|
29
29
|
createLiveStore
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-WQXLVSHA.js";
|
|
31
31
|
import "./chunk-Y7JWV7WV.js";
|
|
32
32
|
import {
|
|
33
33
|
COOKIE_HUBSPOT,
|
|
@@ -48,7 +48,7 @@ import {
|
|
|
48
48
|
normalizeQuery,
|
|
49
49
|
parsePatchLog,
|
|
50
50
|
readQueryDocument
|
|
51
|
-
} from "./chunk-
|
|
51
|
+
} from "./chunk-J4POHQKB.js";
|
|
52
52
|
import {
|
|
53
53
|
createScopedLogger
|
|
54
54
|
} from "./chunk-V7MCHPE7.js";
|
|
@@ -270,7 +270,7 @@ function adopt(node, parent) {
|
|
|
270
270
|
// src/core/live-preview/html-live.ts
|
|
271
271
|
var debug = createScopedLogger("live-preview:html");
|
|
272
272
|
var COMPLETE_DOCUMENT = /<\/html>\s*$/i;
|
|
273
|
-
var SYNC_DEBOUNCE_MS =
|
|
273
|
+
var SYNC_DEBOUNCE_MS = 0;
|
|
274
274
|
function startHtmlLivePreview(options = {}) {
|
|
275
275
|
if (typeof window === "undefined" || window.self === window.top) {
|
|
276
276
|
return { stop() {
|