@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
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createLiveBridge,
|
|
3
3
|
createLiveStore
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-WQXLVSHA.js";
|
|
5
5
|
import "./chunk-Y7JWV7WV.js";
|
|
6
6
|
import "./chunk-UTKH7DOI.js";
|
|
7
7
|
import {
|
|
8
8
|
applyPatchLog,
|
|
9
9
|
normalizeQuery,
|
|
10
10
|
parsePatchLog
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-J4POHQKB.js";
|
|
12
12
|
import "./chunk-V7MCHPE7.js";
|
|
13
13
|
export {
|
|
14
14
|
applyPatchLog,
|
|
@@ -3707,7 +3707,7 @@ function createPreprPreview(opts = {}) {
|
|
|
3707
3707
|
var import_react = require("react");
|
|
3708
3708
|
|
|
3709
3709
|
// src/version.ts
|
|
3710
|
-
var VERSION = "1.0.0-rc.
|
|
3710
|
+
var VERSION = "1.0.0-rc.7";
|
|
3711
3711
|
|
|
3712
3712
|
// src/core/pixel.ts
|
|
3713
3713
|
var PIXEL_SCRIPT_URL = "https://cdn.tracking.prepr.io/js/prepr.min.js";
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
import {
|
|
3
3
|
createPreprPreview,
|
|
4
4
|
loadTrackingPixel
|
|
5
|
-
} from "../chunk-
|
|
6
|
-
import "../chunk-
|
|
5
|
+
} from "../chunk-6EWXOHZZ.js";
|
|
6
|
+
import "../chunk-GIZY3JFC.js";
|
|
7
7
|
import "../chunk-Y7JWV7WV.js";
|
|
8
8
|
import "../chunk-UTKH7DOI.js";
|
|
9
9
|
import "../chunk-V7MCHPE7.js";
|
package/dist/nextjs/index.cjs
CHANGED
|
@@ -50,7 +50,7 @@ module.exports = __toCommonJS(nextjs_exports);
|
|
|
50
50
|
var import_server = require("next/server");
|
|
51
51
|
|
|
52
52
|
// src/version.ts
|
|
53
|
-
var VERSION = "1.0.0-rc.
|
|
53
|
+
var VERSION = "1.0.0-rc.7";
|
|
54
54
|
|
|
55
55
|
// src/core/constants.ts
|
|
56
56
|
var COOKIE_PREVIEW_MODE = "Prepr-Preview-Mode";
|
|
@@ -475,62 +475,59 @@ function indexSnapshot(data) {
|
|
|
475
475
|
return index;
|
|
476
476
|
}
|
|
477
477
|
|
|
478
|
-
// src/core/live-preview/patch.ts
|
|
479
|
-
var import_stega2 = require("@vercel/stega");
|
|
480
|
-
|
|
481
478
|
// src/core/live-preview/internal-links.ts
|
|
482
479
|
var INTERNAL_HREF = /^[pa]uuid#/;
|
|
480
|
+
var INTERNAL_MARK = "uuid#";
|
|
483
481
|
var ANCHOR = /<a\b([^>]*)>([\s\S]*?)<\/a>/gi;
|
|
484
482
|
var HREF = /(\shref\s*=\s*)(["'])(.*?)\2/i;
|
|
485
483
|
var TAGS = /<[^>]+>/g;
|
|
484
|
+
var MAX_PAIRINGS = 25e4;
|
|
486
485
|
function anchorsIn(html) {
|
|
487
486
|
const out = [];
|
|
488
487
|
for (const match of html.matchAll(ANCHOR)) {
|
|
489
488
|
const attributes = match[1];
|
|
490
489
|
const inner = match[2];
|
|
490
|
+
const href = HREF.exec(attributes)?.[3] ?? null;
|
|
491
491
|
out.push({
|
|
492
492
|
start: match.index ?? 0,
|
|
493
493
|
end: (match.index ?? 0) + match[0].length,
|
|
494
494
|
attributes,
|
|
495
495
|
inner,
|
|
496
|
-
href
|
|
496
|
+
href,
|
|
497
|
+
internal: href !== null && INTERNAL_HREF.test(href),
|
|
497
498
|
text: inner.replace(TAGS, "").trim()
|
|
498
499
|
});
|
|
499
500
|
}
|
|
500
501
|
return out;
|
|
501
502
|
}
|
|
502
|
-
var isInternal = (anchor) => anchor.href !== null && INTERNAL_HREF.test(anchor.href);
|
|
503
503
|
function fit(pushed, page) {
|
|
504
|
-
if (
|
|
505
|
-
if (isInternal(pushed) && page.href !== null && INTERNAL_HREF.test(page.href))
|
|
506
|
-
return 0;
|
|
504
|
+
if (pushed.internal ? page.internal : pushed.href !== page.href) return 0;
|
|
507
505
|
return pushed.text === page.text ? 2 : 1;
|
|
508
506
|
}
|
|
509
507
|
function align(pushed, page) {
|
|
510
|
-
const
|
|
508
|
+
const out = new Array(pushed.length).fill(-1);
|
|
509
|
+
if (!page.length || pushed.length * page.length > MAX_PAIRINGS) return out;
|
|
511
510
|
const cols = page.length + 1;
|
|
512
|
-
const score =
|
|
513
|
-
{ length: rows },
|
|
514
|
-
() => new Array(cols).fill(0)
|
|
515
|
-
);
|
|
511
|
+
const score = new Int32Array((pushed.length + 1) * cols);
|
|
516
512
|
for (let i2 = pushed.length - 1; i2 >= 0; i2--) {
|
|
517
513
|
for (let j2 = page.length - 1; j2 >= 0; j2--) {
|
|
514
|
+
const at = i2 * cols + j2;
|
|
518
515
|
const pair = fit(pushed[i2], page[j2]);
|
|
519
|
-
score[
|
|
520
|
-
score[
|
|
521
|
-
score[
|
|
522
|
-
pair ? pair + score[
|
|
516
|
+
score[at] = Math.max(
|
|
517
|
+
score[at + cols],
|
|
518
|
+
score[at + 1],
|
|
519
|
+
pair ? pair + score[at + cols + 1] : 0
|
|
523
520
|
);
|
|
524
521
|
}
|
|
525
522
|
}
|
|
526
|
-
const out = new Array(pushed.length).fill(-1);
|
|
527
523
|
let i = 0;
|
|
528
524
|
let j = 0;
|
|
529
525
|
while (i < pushed.length && j < page.length) {
|
|
526
|
+
const at = i * cols + j;
|
|
530
527
|
const pair = fit(pushed[i], page[j]);
|
|
531
|
-
if (pair && score[
|
|
528
|
+
if (pair && score[at] === pair + score[at + cols + 1]) {
|
|
532
529
|
out[i++] = j++;
|
|
533
|
-
} else if (score[
|
|
530
|
+
} else if (score[at + cols] >= score[at + 1]) {
|
|
534
531
|
i++;
|
|
535
532
|
} else {
|
|
536
533
|
j++;
|
|
@@ -539,14 +536,15 @@ function align(pushed, page) {
|
|
|
539
536
|
return out;
|
|
540
537
|
}
|
|
541
538
|
function resolveInternalLinks(current, value) {
|
|
539
|
+
if (!value.includes(INTERNAL_MARK)) return value;
|
|
542
540
|
const pushed = anchorsIn(value);
|
|
543
|
-
if (!pushed.some(
|
|
541
|
+
if (!pushed.some((anchor) => anchor.internal)) return value;
|
|
544
542
|
const page = typeof current === "string" ? anchorsIn(current) : [];
|
|
545
543
|
const pairs = align(pushed, page);
|
|
546
544
|
let out = "";
|
|
547
545
|
let cursor = 0;
|
|
548
546
|
pushed.forEach((anchor, i) => {
|
|
549
|
-
if (!
|
|
547
|
+
if (!anchor.internal) return;
|
|
550
548
|
out += value.slice(cursor, anchor.start);
|
|
551
549
|
const match = pairs[i] >= 0 ? page[pairs[i]] : null;
|
|
552
550
|
if (match?.href != null) {
|
|
@@ -565,6 +563,7 @@ function resolveInternalLinks(current, value) {
|
|
|
565
563
|
}
|
|
566
564
|
|
|
567
565
|
// src/core/live-preview/patch.ts
|
|
566
|
+
var import_stega2 = require("@vercel/stega");
|
|
568
567
|
var FORBIDDEN_SEGMENTS = /* @__PURE__ */ new Set(["__proto__", "prototype", "constructor"]);
|
|
569
568
|
function mergeObject(current, incoming) {
|
|
570
569
|
let changed = false;
|
|
@@ -688,7 +687,7 @@ function listKeysOf(entry) {
|
|
|
688
687
|
return keys;
|
|
689
688
|
}
|
|
690
689
|
function buildText(entry, template) {
|
|
691
|
-
const body = typeof entry.body === "string" ? entry.body : "";
|
|
690
|
+
const body = typeof entry.body === "string" ? resolveInternalLinks(null, entry.body) : "";
|
|
692
691
|
const full = {
|
|
693
692
|
__typename: "Text",
|
|
694
693
|
_id: entry._id,
|
|
@@ -1375,7 +1374,8 @@ function fillObject(doc, selections, typename, values, id, ctx) {
|
|
|
1375
1374
|
out[field.key] = [];
|
|
1376
1375
|
continue;
|
|
1377
1376
|
}
|
|
1378
|
-
const
|
|
1377
|
+
const sent = value === void 0 || value !== null && typeof value === "object" ? null : value;
|
|
1378
|
+
const scalar = typeof sent === "string" ? resolveInternalLinks(null, sent) : sent;
|
|
1379
1379
|
const target = typeof scalar === "string" ? editField(field.name) : null;
|
|
1380
1380
|
out[field.key] = target && links ? links.encode(scalar, target) : scalar;
|
|
1381
1381
|
}
|
package/dist/nextjs/index.d.cts
CHANGED
|
@@ -382,8 +382,12 @@ interface PreprRefreshProps {
|
|
|
382
382
|
strictMode?: boolean;
|
|
383
383
|
/**
|
|
384
384
|
* How long typing must pause, in milliseconds, before the unsaved changes
|
|
385
|
-
* go to the server. Default
|
|
386
|
-
*
|
|
385
|
+
* go to the server. Default 0: a change goes out as soon as the editor
|
|
386
|
+
* sends it, which it does after a pause of its own. Renders run one at a
|
|
387
|
+
* time either way; raise this when a render is expensive, to have fewer of
|
|
388
|
+
* them. While typing continues, changes still go out at least every four
|
|
389
|
+
* times this value (600 ms at the least), so the preview never stalls
|
|
390
|
+
* until a pause.
|
|
387
391
|
*/
|
|
388
392
|
syncDebounceMs?: number;
|
|
389
393
|
}
|
package/dist/nextjs/index.d.ts
CHANGED
|
@@ -382,8 +382,12 @@ interface PreprRefreshProps {
|
|
|
382
382
|
strictMode?: boolean;
|
|
383
383
|
/**
|
|
384
384
|
* How long typing must pause, in milliseconds, before the unsaved changes
|
|
385
|
-
* go to the server. Default
|
|
386
|
-
*
|
|
385
|
+
* go to the server. Default 0: a change goes out as soon as the editor
|
|
386
|
+
* sends it, which it does after a pause of its own. Renders run one at a
|
|
387
|
+
* time either way; raise this when a render is expensive, to have fewer of
|
|
388
|
+
* them. While typing continues, changes still go out at least every four
|
|
389
|
+
* times this value (600 ms at the least), so the preview never stalls
|
|
390
|
+
* until a pause.
|
|
387
391
|
*/
|
|
388
392
|
syncDebounceMs?: number;
|
|
389
393
|
}
|
package/dist/nextjs/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { NextResponse } from "next/server";
|
|
3
3
|
|
|
4
4
|
// src/version.ts
|
|
5
|
-
var VERSION = "1.0.0-rc.
|
|
5
|
+
var VERSION = "1.0.0-rc.7";
|
|
6
6
|
|
|
7
7
|
// src/core/constants.ts
|
|
8
8
|
var COOKIE_PREVIEW_MODE = "Prepr-Preview-Mode";
|
|
@@ -431,62 +431,59 @@ function indexSnapshot(data) {
|
|
|
431
431
|
return index;
|
|
432
432
|
}
|
|
433
433
|
|
|
434
|
-
// src/core/live-preview/patch.ts
|
|
435
|
-
import { vercelStegaSplit as vercelStegaSplit2 } from "@vercel/stega";
|
|
436
|
-
|
|
437
434
|
// src/core/live-preview/internal-links.ts
|
|
438
435
|
var INTERNAL_HREF = /^[pa]uuid#/;
|
|
436
|
+
var INTERNAL_MARK = "uuid#";
|
|
439
437
|
var ANCHOR = /<a\b([^>]*)>([\s\S]*?)<\/a>/gi;
|
|
440
438
|
var HREF = /(\shref\s*=\s*)(["'])(.*?)\2/i;
|
|
441
439
|
var TAGS = /<[^>]+>/g;
|
|
440
|
+
var MAX_PAIRINGS = 25e4;
|
|
442
441
|
function anchorsIn(html) {
|
|
443
442
|
const out = [];
|
|
444
443
|
for (const match of html.matchAll(ANCHOR)) {
|
|
445
444
|
const attributes = match[1];
|
|
446
445
|
const inner = match[2];
|
|
446
|
+
const href = HREF.exec(attributes)?.[3] ?? null;
|
|
447
447
|
out.push({
|
|
448
448
|
start: match.index ?? 0,
|
|
449
449
|
end: (match.index ?? 0) + match[0].length,
|
|
450
450
|
attributes,
|
|
451
451
|
inner,
|
|
452
|
-
href
|
|
452
|
+
href,
|
|
453
|
+
internal: href !== null && INTERNAL_HREF.test(href),
|
|
453
454
|
text: inner.replace(TAGS, "").trim()
|
|
454
455
|
});
|
|
455
456
|
}
|
|
456
457
|
return out;
|
|
457
458
|
}
|
|
458
|
-
var isInternal = (anchor) => anchor.href !== null && INTERNAL_HREF.test(anchor.href);
|
|
459
459
|
function fit(pushed, page) {
|
|
460
|
-
if (
|
|
461
|
-
if (isInternal(pushed) && page.href !== null && INTERNAL_HREF.test(page.href))
|
|
462
|
-
return 0;
|
|
460
|
+
if (pushed.internal ? page.internal : pushed.href !== page.href) return 0;
|
|
463
461
|
return pushed.text === page.text ? 2 : 1;
|
|
464
462
|
}
|
|
465
463
|
function align(pushed, page) {
|
|
466
|
-
const
|
|
464
|
+
const out = new Array(pushed.length).fill(-1);
|
|
465
|
+
if (!page.length || pushed.length * page.length > MAX_PAIRINGS) return out;
|
|
467
466
|
const cols = page.length + 1;
|
|
468
|
-
const score =
|
|
469
|
-
{ length: rows },
|
|
470
|
-
() => new Array(cols).fill(0)
|
|
471
|
-
);
|
|
467
|
+
const score = new Int32Array((pushed.length + 1) * cols);
|
|
472
468
|
for (let i2 = pushed.length - 1; i2 >= 0; i2--) {
|
|
473
469
|
for (let j2 = page.length - 1; j2 >= 0; j2--) {
|
|
470
|
+
const at = i2 * cols + j2;
|
|
474
471
|
const pair = fit(pushed[i2], page[j2]);
|
|
475
|
-
score[
|
|
476
|
-
score[
|
|
477
|
-
score[
|
|
478
|
-
pair ? pair + score[
|
|
472
|
+
score[at] = Math.max(
|
|
473
|
+
score[at + cols],
|
|
474
|
+
score[at + 1],
|
|
475
|
+
pair ? pair + score[at + cols + 1] : 0
|
|
479
476
|
);
|
|
480
477
|
}
|
|
481
478
|
}
|
|
482
|
-
const out = new Array(pushed.length).fill(-1);
|
|
483
479
|
let i = 0;
|
|
484
480
|
let j = 0;
|
|
485
481
|
while (i < pushed.length && j < page.length) {
|
|
482
|
+
const at = i * cols + j;
|
|
486
483
|
const pair = fit(pushed[i], page[j]);
|
|
487
|
-
if (pair && score[
|
|
484
|
+
if (pair && score[at] === pair + score[at + cols + 1]) {
|
|
488
485
|
out[i++] = j++;
|
|
489
|
-
} else if (score[
|
|
486
|
+
} else if (score[at + cols] >= score[at + 1]) {
|
|
490
487
|
i++;
|
|
491
488
|
} else {
|
|
492
489
|
j++;
|
|
@@ -495,14 +492,15 @@ function align(pushed, page) {
|
|
|
495
492
|
return out;
|
|
496
493
|
}
|
|
497
494
|
function resolveInternalLinks(current, value) {
|
|
495
|
+
if (!value.includes(INTERNAL_MARK)) return value;
|
|
498
496
|
const pushed = anchorsIn(value);
|
|
499
|
-
if (!pushed.some(
|
|
497
|
+
if (!pushed.some((anchor) => anchor.internal)) return value;
|
|
500
498
|
const page = typeof current === "string" ? anchorsIn(current) : [];
|
|
501
499
|
const pairs = align(pushed, page);
|
|
502
500
|
let out = "";
|
|
503
501
|
let cursor = 0;
|
|
504
502
|
pushed.forEach((anchor, i) => {
|
|
505
|
-
if (!
|
|
503
|
+
if (!anchor.internal) return;
|
|
506
504
|
out += value.slice(cursor, anchor.start);
|
|
507
505
|
const match = pairs[i] >= 0 ? page[pairs[i]] : null;
|
|
508
506
|
if (match?.href != null) {
|
|
@@ -521,6 +519,7 @@ function resolveInternalLinks(current, value) {
|
|
|
521
519
|
}
|
|
522
520
|
|
|
523
521
|
// src/core/live-preview/patch.ts
|
|
522
|
+
import { vercelStegaSplit as vercelStegaSplit2 } from "@vercel/stega";
|
|
524
523
|
var FORBIDDEN_SEGMENTS = /* @__PURE__ */ new Set(["__proto__", "prototype", "constructor"]);
|
|
525
524
|
function mergeObject(current, incoming) {
|
|
526
525
|
let changed = false;
|
|
@@ -644,7 +643,7 @@ function listKeysOf(entry) {
|
|
|
644
643
|
return keys;
|
|
645
644
|
}
|
|
646
645
|
function buildText(entry, template) {
|
|
647
|
-
const body = typeof entry.body === "string" ? entry.body : "";
|
|
646
|
+
const body = typeof entry.body === "string" ? resolveInternalLinks(null, entry.body) : "";
|
|
648
647
|
const full = {
|
|
649
648
|
__typename: "Text",
|
|
650
649
|
_id: entry._id,
|
|
@@ -1331,7 +1330,8 @@ function fillObject(doc, selections, typename, values, id, ctx) {
|
|
|
1331
1330
|
out[field.key] = [];
|
|
1332
1331
|
continue;
|
|
1333
1332
|
}
|
|
1334
|
-
const
|
|
1333
|
+
const sent = value === void 0 || value !== null && typeof value === "object" ? null : value;
|
|
1334
|
+
const scalar = typeof sent === "string" ? resolveInternalLinks(null, sent) : sent;
|
|
1335
1335
|
const target = typeof scalar === "string" ? editField(field.name) : null;
|
|
1336
1336
|
out[field.key] = target && links ? links.encode(scalar, target) : scalar;
|
|
1337
1337
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use server";
|
|
2
2
|
import {
|
|
3
3
|
isPreviewFromHeaders
|
|
4
|
-
} from "../chunk-
|
|
5
|
-
import "../chunk-
|
|
4
|
+
} from "../chunk-OKP6KD3I.js";
|
|
5
|
+
import "../chunk-GIZY3JFC.js";
|
|
6
6
|
import {
|
|
7
7
|
parsePatchLog
|
|
8
|
-
} from "../chunk-
|
|
8
|
+
} from "../chunk-J4POHQKB.js";
|
|
9
9
|
import "../chunk-V7MCHPE7.js";
|
|
10
10
|
|
|
11
11
|
// src/nextjs/live-action.ts
|
package/dist/nextjs/live.cjs
CHANGED
|
@@ -221,48 +221,47 @@ function anchorsIn(html) {
|
|
|
221
221
|
for (const match of html.matchAll(ANCHOR)) {
|
|
222
222
|
const attributes = match[1];
|
|
223
223
|
const inner = match[2];
|
|
224
|
+
const href = HREF.exec(attributes)?.[3] ?? null;
|
|
224
225
|
out.push({
|
|
225
226
|
start: match.index ?? 0,
|
|
226
227
|
end: (match.index ?? 0) + match[0].length,
|
|
227
228
|
attributes,
|
|
228
229
|
inner,
|
|
229
|
-
href
|
|
230
|
+
href,
|
|
231
|
+
internal: href !== null && INTERNAL_HREF.test(href),
|
|
230
232
|
text: inner.replace(TAGS, "").trim()
|
|
231
233
|
});
|
|
232
234
|
}
|
|
233
235
|
return out;
|
|
234
236
|
}
|
|
235
237
|
function fit(pushed, page) {
|
|
236
|
-
if (
|
|
237
|
-
if (isInternal(pushed) && page.href !== null && INTERNAL_HREF.test(page.href))
|
|
238
|
-
return 0;
|
|
238
|
+
if (pushed.internal ? page.internal : pushed.href !== page.href) return 0;
|
|
239
239
|
return pushed.text === page.text ? 2 : 1;
|
|
240
240
|
}
|
|
241
241
|
function align(pushed, page) {
|
|
242
|
-
const
|
|
242
|
+
const out = new Array(pushed.length).fill(-1);
|
|
243
|
+
if (!page.length || pushed.length * page.length > MAX_PAIRINGS) return out;
|
|
243
244
|
const cols = page.length + 1;
|
|
244
|
-
const score =
|
|
245
|
-
{ length: rows },
|
|
246
|
-
() => new Array(cols).fill(0)
|
|
247
|
-
);
|
|
245
|
+
const score = new Int32Array((pushed.length + 1) * cols);
|
|
248
246
|
for (let i2 = pushed.length - 1; i2 >= 0; i2--) {
|
|
249
247
|
for (let j2 = page.length - 1; j2 >= 0; j2--) {
|
|
248
|
+
const at = i2 * cols + j2;
|
|
250
249
|
const pair = fit(pushed[i2], page[j2]);
|
|
251
|
-
score[
|
|
252
|
-
score[
|
|
253
|
-
score[
|
|
254
|
-
pair ? pair + score[
|
|
250
|
+
score[at] = Math.max(
|
|
251
|
+
score[at + cols],
|
|
252
|
+
score[at + 1],
|
|
253
|
+
pair ? pair + score[at + cols + 1] : 0
|
|
255
254
|
);
|
|
256
255
|
}
|
|
257
256
|
}
|
|
258
|
-
const out = new Array(pushed.length).fill(-1);
|
|
259
257
|
let i = 0;
|
|
260
258
|
let j = 0;
|
|
261
259
|
while (i < pushed.length && j < page.length) {
|
|
260
|
+
const at = i * cols + j;
|
|
262
261
|
const pair = fit(pushed[i], page[j]);
|
|
263
|
-
if (pair && score[
|
|
262
|
+
if (pair && score[at] === pair + score[at + cols + 1]) {
|
|
264
263
|
out[i++] = j++;
|
|
265
|
-
} else if (score[
|
|
264
|
+
} else if (score[at + cols] >= score[at + 1]) {
|
|
266
265
|
i++;
|
|
267
266
|
} else {
|
|
268
267
|
j++;
|
|
@@ -271,14 +270,15 @@ function align(pushed, page) {
|
|
|
271
270
|
return out;
|
|
272
271
|
}
|
|
273
272
|
function resolveInternalLinks(current, value) {
|
|
273
|
+
if (!value.includes(INTERNAL_MARK)) return value;
|
|
274
274
|
const pushed = anchorsIn(value);
|
|
275
|
-
if (!pushed.some(
|
|
275
|
+
if (!pushed.some((anchor) => anchor.internal)) return value;
|
|
276
276
|
const page = typeof current === "string" ? anchorsIn(current) : [];
|
|
277
277
|
const pairs = align(pushed, page);
|
|
278
278
|
let out = "";
|
|
279
279
|
let cursor = 0;
|
|
280
280
|
pushed.forEach((anchor, i) => {
|
|
281
|
-
if (!
|
|
281
|
+
if (!anchor.internal) return;
|
|
282
282
|
out += value.slice(cursor, anchor.start);
|
|
283
283
|
const match = pairs[i] >= 0 ? page[pairs[i]] : null;
|
|
284
284
|
if (match?.href != null) {
|
|
@@ -295,15 +295,16 @@ function resolveInternalLinks(current, value) {
|
|
|
295
295
|
});
|
|
296
296
|
return out + value.slice(cursor);
|
|
297
297
|
}
|
|
298
|
-
var INTERNAL_HREF, ANCHOR, HREF, TAGS,
|
|
298
|
+
var INTERNAL_HREF, INTERNAL_MARK, ANCHOR, HREF, TAGS, MAX_PAIRINGS;
|
|
299
299
|
var init_internal_links = __esm({
|
|
300
300
|
"src/core/live-preview/internal-links.ts"() {
|
|
301
301
|
"use strict";
|
|
302
302
|
INTERNAL_HREF = /^[pa]uuid#/;
|
|
303
|
+
INTERNAL_MARK = "uuid#";
|
|
303
304
|
ANCHOR = /<a\b([^>]*)>([\s\S]*?)<\/a>/gi;
|
|
304
305
|
HREF = /(\shref\s*=\s*)(["'])(.*?)\2/i;
|
|
305
306
|
TAGS = /<[^>]+>/g;
|
|
306
|
-
|
|
307
|
+
MAX_PAIRINGS = 25e4;
|
|
307
308
|
}
|
|
308
309
|
});
|
|
309
310
|
|
|
@@ -500,7 +501,7 @@ function listKeysOf(entry) {
|
|
|
500
501
|
return keys;
|
|
501
502
|
}
|
|
502
503
|
function buildText(entry, template) {
|
|
503
|
-
const body = typeof entry.body === "string" ? entry.body : "";
|
|
504
|
+
const body = typeof entry.body === "string" ? resolveInternalLinks(null, entry.body) : "";
|
|
504
505
|
const full = {
|
|
505
506
|
__typename: "Text",
|
|
506
507
|
_id: entry._id,
|
|
@@ -1714,7 +1715,8 @@ function fillObject(doc, selections, typename, values, id, ctx) {
|
|
|
1714
1715
|
out[field.key] = [];
|
|
1715
1716
|
continue;
|
|
1716
1717
|
}
|
|
1717
|
-
const
|
|
1718
|
+
const sent = value === void 0 || value !== null && typeof value === "object" ? null : value;
|
|
1719
|
+
const scalar = typeof sent === "string" ? resolveInternalLinks(null, sent) : sent;
|
|
1718
1720
|
const target = typeof scalar === "string" ? editField(field.name) : null;
|
|
1719
1721
|
out[field.key] = target && links ? links.encode(scalar, target) : scalar;
|
|
1720
1722
|
}
|
|
@@ -1780,6 +1782,7 @@ var init_normalize_query = __esm({
|
|
|
1780
1782
|
init_utils();
|
|
1781
1783
|
init_field_name();
|
|
1782
1784
|
init_index_snapshot();
|
|
1785
|
+
init_internal_links();
|
|
1783
1786
|
init_patch();
|
|
1784
1787
|
init_query_document();
|
|
1785
1788
|
init_validate();
|
|
@@ -1891,12 +1894,13 @@ function createLiveStarter(options = {}) {
|
|
|
1891
1894
|
// src/nextjs/live.ts
|
|
1892
1895
|
var import_live_action = require("./live-action.cjs");
|
|
1893
1896
|
var debug6 = createScopedLogger("live-preview:next");
|
|
1894
|
-
var LOG_SYNC_DEBOUNCE_MS =
|
|
1897
|
+
var LOG_SYNC_DEBOUNCE_MS = 0;
|
|
1898
|
+
var MIN_SYNC_MAX_WAIT_MS = 600;
|
|
1895
1899
|
var debounceOf = (value) => typeof value === "number" && Number.isFinite(value) && value >= 0 ? value : LOG_SYNC_DEBOUNCE_MS;
|
|
1896
1900
|
var starter = createLiveStarter({
|
|
1897
1901
|
storeOptions() {
|
|
1898
1902
|
const skipped = new Set(quarantined());
|
|
1899
|
-
return { accept: (patch) => !skipped.has(patchKey(patch)) };
|
|
1903
|
+
return skipped.size ? { accept: (patch) => !skipped.has(patchKey(patch)) } : {};
|
|
1900
1904
|
},
|
|
1901
1905
|
onStart: (store) => watchClientRenders(store),
|
|
1902
1906
|
onReset() {
|
|
@@ -2044,6 +2048,8 @@ function watchClientRenders(watched) {
|
|
|
2044
2048
|
});
|
|
2045
2049
|
}
|
|
2046
2050
|
function createLogSync(debounceMs) {
|
|
2051
|
+
const maxWaitMs = Math.max(debounceMs * 4, MIN_SYNC_MAX_WAIT_MS);
|
|
2052
|
+
let waitingSince = null;
|
|
2047
2053
|
let timer = null;
|
|
2048
2054
|
let inFlight = false;
|
|
2049
2055
|
let pending = null;
|
|
@@ -2091,15 +2097,22 @@ function createLogSync(debounceMs) {
|
|
|
2091
2097
|
schedule(log) {
|
|
2092
2098
|
cancelled = false;
|
|
2093
2099
|
if (timer) clearTimeout(timer);
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2100
|
+
waitingSince ?? (waitingSince = Date.now());
|
|
2101
|
+
const left = waitingSince + maxWaitMs - Date.now();
|
|
2102
|
+
timer = setTimeout(
|
|
2103
|
+
() => {
|
|
2104
|
+
timer = null;
|
|
2105
|
+
waitingSince = null;
|
|
2106
|
+
if (inFlight) pending = log;
|
|
2107
|
+
else void send(log);
|
|
2108
|
+
},
|
|
2109
|
+
Math.max(0, Math.min(debounceMs, left))
|
|
2110
|
+
);
|
|
2099
2111
|
},
|
|
2100
2112
|
cancel() {
|
|
2101
2113
|
cancelled = true;
|
|
2102
2114
|
pending = null;
|
|
2115
|
+
waitingSince = null;
|
|
2103
2116
|
if (timer) clearTimeout(timer);
|
|
2104
2117
|
timer = null;
|
|
2105
2118
|
},
|
package/dist/nextjs/live.d.cts
CHANGED
|
@@ -25,8 +25,12 @@ interface PreprRefreshProps {
|
|
|
25
25
|
strictMode?: boolean;
|
|
26
26
|
/**
|
|
27
27
|
* How long typing must pause, in milliseconds, before the unsaved changes
|
|
28
|
-
* go to the server. Default
|
|
29
|
-
*
|
|
28
|
+
* go to the server. Default 0: a change goes out as soon as the editor
|
|
29
|
+
* sends it, which it does after a pause of its own. Renders run one at a
|
|
30
|
+
* time either way; raise this when a render is expensive, to have fewer of
|
|
31
|
+
* them. While typing continues, changes still go out at least every four
|
|
32
|
+
* times this value (600 ms at the least), so the preview never stalls
|
|
33
|
+
* until a pause.
|
|
30
34
|
*/
|
|
31
35
|
syncDebounceMs?: number;
|
|
32
36
|
}
|
package/dist/nextjs/live.d.ts
CHANGED
|
@@ -25,8 +25,12 @@ interface PreprRefreshProps {
|
|
|
25
25
|
strictMode?: boolean;
|
|
26
26
|
/**
|
|
27
27
|
* How long typing must pause, in milliseconds, before the unsaved changes
|
|
28
|
-
* go to the server. Default
|
|
29
|
-
*
|
|
28
|
+
* go to the server. Default 0: a change goes out as soon as the editor
|
|
29
|
+
* sends it, which it does after a pause of its own. Renders run one at a
|
|
30
|
+
* time either way; raise this when a render is expensive, to have fewer of
|
|
31
|
+
* them. While typing continues, changes still go out at least every four
|
|
32
|
+
* times this value (600 ms at the least), so the preview never stalls
|
|
33
|
+
* until a pause.
|
|
30
34
|
*/
|
|
31
35
|
syncDebounceMs?: number;
|
|
32
36
|
}
|
package/dist/nextjs/live.js
CHANGED
|
@@ -45,7 +45,7 @@ function createLiveStarter(options = {}) {
|
|
|
45
45
|
}
|
|
46
46
|
},
|
|
47
47
|
start() {
|
|
48
|
-
starting ?? (starting = import("../live-preview-
|
|
48
|
+
starting ?? (starting = import("../live-preview-PLHDSQ53.js").then((runtime) => {
|
|
49
49
|
const started = runtime.createLiveStore(options.storeOptions?.());
|
|
50
50
|
options.onStart?.(started, runtime);
|
|
51
51
|
bridge = runtime.createLiveBridge(started, {
|
|
@@ -75,12 +75,13 @@ function createLiveStarter(options = {}) {
|
|
|
75
75
|
// src/nextjs/live.ts
|
|
76
76
|
import { syncPreprLiveLog } from "./live-action.js";
|
|
77
77
|
var debug = createScopedLogger("live-preview:next");
|
|
78
|
-
var LOG_SYNC_DEBOUNCE_MS =
|
|
78
|
+
var LOG_SYNC_DEBOUNCE_MS = 0;
|
|
79
|
+
var MIN_SYNC_MAX_WAIT_MS = 600;
|
|
79
80
|
var debounceOf = (value) => typeof value === "number" && Number.isFinite(value) && value >= 0 ? value : LOG_SYNC_DEBOUNCE_MS;
|
|
80
81
|
var starter = createLiveStarter({
|
|
81
82
|
storeOptions() {
|
|
82
83
|
const skipped = new Set(quarantined());
|
|
83
|
-
return { accept: (patch) => !skipped.has(patchKey(patch)) };
|
|
84
|
+
return skipped.size ? { accept: (patch) => !skipped.has(patchKey(patch)) } : {};
|
|
84
85
|
},
|
|
85
86
|
onStart: (store) => watchClientRenders(store),
|
|
86
87
|
onReset() {
|
|
@@ -228,6 +229,8 @@ function watchClientRenders(watched) {
|
|
|
228
229
|
});
|
|
229
230
|
}
|
|
230
231
|
function createLogSync(debounceMs) {
|
|
232
|
+
const maxWaitMs = Math.max(debounceMs * 4, MIN_SYNC_MAX_WAIT_MS);
|
|
233
|
+
let waitingSince = null;
|
|
231
234
|
let timer = null;
|
|
232
235
|
let inFlight = false;
|
|
233
236
|
let pending = null;
|
|
@@ -275,15 +278,22 @@ function createLogSync(debounceMs) {
|
|
|
275
278
|
schedule(log) {
|
|
276
279
|
cancelled = false;
|
|
277
280
|
if (timer) clearTimeout(timer);
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
281
|
+
waitingSince ?? (waitingSince = Date.now());
|
|
282
|
+
const left = waitingSince + maxWaitMs - Date.now();
|
|
283
|
+
timer = setTimeout(
|
|
284
|
+
() => {
|
|
285
|
+
timer = null;
|
|
286
|
+
waitingSince = null;
|
|
287
|
+
if (inFlight) pending = log;
|
|
288
|
+
else void send(log);
|
|
289
|
+
},
|
|
290
|
+
Math.max(0, Math.min(debounceMs, left))
|
|
291
|
+
);
|
|
283
292
|
},
|
|
284
293
|
cancel() {
|
|
285
294
|
cancelled = true;
|
|
286
295
|
pending = null;
|
|
296
|
+
waitingSince = null;
|
|
287
297
|
if (timer) clearTimeout(timer);
|
|
288
298
|
timer = null;
|
|
289
299
|
},
|
package/dist/nuxt/index.cjs
CHANGED