@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
|
@@ -152,57 +152,57 @@ function isTextEntry(record) {
|
|
|
152
152
|
|
|
153
153
|
// src/core/live-preview/internal-links.ts
|
|
154
154
|
var INTERNAL_HREF = /^[pa]uuid#/;
|
|
155
|
+
var INTERNAL_MARK = "uuid#";
|
|
155
156
|
var ANCHOR = /<a\b([^>]*)>([\s\S]*?)<\/a>/gi;
|
|
156
157
|
var HREF = /(\shref\s*=\s*)(["'])(.*?)\2/i;
|
|
157
158
|
var TAGS = /<[^>]+>/g;
|
|
159
|
+
var MAX_PAIRINGS = 25e4;
|
|
158
160
|
function anchorsIn(html) {
|
|
159
161
|
const out = [];
|
|
160
162
|
for (const match of html.matchAll(ANCHOR)) {
|
|
161
163
|
const attributes = match[1];
|
|
162
164
|
const inner = match[2];
|
|
165
|
+
const href = HREF.exec(attributes)?.[3] ?? null;
|
|
163
166
|
out.push({
|
|
164
167
|
start: match.index ?? 0,
|
|
165
168
|
end: (match.index ?? 0) + match[0].length,
|
|
166
169
|
attributes,
|
|
167
170
|
inner,
|
|
168
|
-
href
|
|
171
|
+
href,
|
|
172
|
+
internal: href !== null && INTERNAL_HREF.test(href),
|
|
169
173
|
text: inner.replace(TAGS, "").trim()
|
|
170
174
|
});
|
|
171
175
|
}
|
|
172
176
|
return out;
|
|
173
177
|
}
|
|
174
|
-
var isInternal = (anchor) => anchor.href !== null && INTERNAL_HREF.test(anchor.href);
|
|
175
178
|
function fit(pushed, page) {
|
|
176
|
-
if (
|
|
177
|
-
if (isInternal(pushed) && page.href !== null && INTERNAL_HREF.test(page.href))
|
|
178
|
-
return 0;
|
|
179
|
+
if (pushed.internal ? page.internal : pushed.href !== page.href) return 0;
|
|
179
180
|
return pushed.text === page.text ? 2 : 1;
|
|
180
181
|
}
|
|
181
182
|
function align(pushed, page) {
|
|
182
|
-
const
|
|
183
|
+
const out = new Array(pushed.length).fill(-1);
|
|
184
|
+
if (!page.length || pushed.length * page.length > MAX_PAIRINGS) return out;
|
|
183
185
|
const cols = page.length + 1;
|
|
184
|
-
const score =
|
|
185
|
-
{ length: rows },
|
|
186
|
-
() => new Array(cols).fill(0)
|
|
187
|
-
);
|
|
186
|
+
const score = new Int32Array((pushed.length + 1) * cols);
|
|
188
187
|
for (let i2 = pushed.length - 1; i2 >= 0; i2--) {
|
|
189
188
|
for (let j2 = page.length - 1; j2 >= 0; j2--) {
|
|
189
|
+
const at = i2 * cols + j2;
|
|
190
190
|
const pair = fit(pushed[i2], page[j2]);
|
|
191
|
-
score[
|
|
192
|
-
score[
|
|
193
|
-
score[
|
|
194
|
-
pair ? pair + score[
|
|
191
|
+
score[at] = Math.max(
|
|
192
|
+
score[at + cols],
|
|
193
|
+
score[at + 1],
|
|
194
|
+
pair ? pair + score[at + cols + 1] : 0
|
|
195
195
|
);
|
|
196
196
|
}
|
|
197
197
|
}
|
|
198
|
-
const out = new Array(pushed.length).fill(-1);
|
|
199
198
|
let i = 0;
|
|
200
199
|
let j = 0;
|
|
201
200
|
while (i < pushed.length && j < page.length) {
|
|
201
|
+
const at = i * cols + j;
|
|
202
202
|
const pair = fit(pushed[i], page[j]);
|
|
203
|
-
if (pair && score[
|
|
203
|
+
if (pair && score[at] === pair + score[at + cols + 1]) {
|
|
204
204
|
out[i++] = j++;
|
|
205
|
-
} else if (score[
|
|
205
|
+
} else if (score[at + cols] >= score[at + 1]) {
|
|
206
206
|
i++;
|
|
207
207
|
} else {
|
|
208
208
|
j++;
|
|
@@ -211,14 +211,15 @@ function align(pushed, page) {
|
|
|
211
211
|
return out;
|
|
212
212
|
}
|
|
213
213
|
function resolveInternalLinks(current, value) {
|
|
214
|
+
if (!value.includes(INTERNAL_MARK)) return value;
|
|
214
215
|
const pushed = anchorsIn(value);
|
|
215
|
-
if (!pushed.some(
|
|
216
|
+
if (!pushed.some((anchor) => anchor.internal)) return value;
|
|
216
217
|
const page = typeof current === "string" ? anchorsIn(current) : [];
|
|
217
218
|
const pairs = align(pushed, page);
|
|
218
219
|
let out = "";
|
|
219
220
|
let cursor = 0;
|
|
220
221
|
pushed.forEach((anchor, i) => {
|
|
221
|
-
if (!
|
|
222
|
+
if (!anchor.internal) return;
|
|
222
223
|
out += value.slice(cursor, anchor.start);
|
|
223
224
|
const match = pairs[i] >= 0 ? page[pairs[i]] : null;
|
|
224
225
|
if (match?.href != null) {
|
|
@@ -431,7 +432,7 @@ function listKeysOf(entry) {
|
|
|
431
432
|
return keys;
|
|
432
433
|
}
|
|
433
434
|
function buildText(entry, template) {
|
|
434
|
-
const body = typeof entry.body === "string" ? entry.body : "";
|
|
435
|
+
const body = typeof entry.body === "string" ? resolveInternalLinks(null, entry.body) : "";
|
|
435
436
|
const full = {
|
|
436
437
|
__typename: "Text",
|
|
437
438
|
_id: entry._id,
|
|
@@ -1255,7 +1256,8 @@ function fillObject(doc, selections, typename, values, id, ctx) {
|
|
|
1255
1256
|
out[field.key] = [];
|
|
1256
1257
|
continue;
|
|
1257
1258
|
}
|
|
1258
|
-
const
|
|
1259
|
+
const sent = value === void 0 || value !== null && typeof value === "object" ? null : value;
|
|
1260
|
+
const scalar = typeof sent === "string" ? resolveInternalLinks(null, sent) : sent;
|
|
1259
1261
|
const target = typeof scalar === "string" ? editField(field.name) : null;
|
|
1260
1262
|
out[field.key] = target && links ? links.encode(scalar, target) : scalar;
|
|
1261
1263
|
}
|
package/dist/nuxt/live.cjs
CHANGED
|
@@ -546,48 +546,47 @@ function anchorsIn(html) {
|
|
|
546
546
|
for (const match of html.matchAll(ANCHOR)) {
|
|
547
547
|
const attributes = match[1];
|
|
548
548
|
const inner = match[2];
|
|
549
|
+
const href = HREF.exec(attributes)?.[3] ?? null;
|
|
549
550
|
out.push({
|
|
550
551
|
start: match.index ?? 0,
|
|
551
552
|
end: (match.index ?? 0) + match[0].length,
|
|
552
553
|
attributes,
|
|
553
554
|
inner,
|
|
554
|
-
href
|
|
555
|
+
href,
|
|
556
|
+
internal: href !== null && INTERNAL_HREF.test(href),
|
|
555
557
|
text: inner.replace(TAGS, "").trim()
|
|
556
558
|
});
|
|
557
559
|
}
|
|
558
560
|
return out;
|
|
559
561
|
}
|
|
560
562
|
function fit(pushed, page) {
|
|
561
|
-
if (
|
|
562
|
-
if (isInternal(pushed) && page.href !== null && INTERNAL_HREF.test(page.href))
|
|
563
|
-
return 0;
|
|
563
|
+
if (pushed.internal ? page.internal : pushed.href !== page.href) return 0;
|
|
564
564
|
return pushed.text === page.text ? 2 : 1;
|
|
565
565
|
}
|
|
566
566
|
function align(pushed, page) {
|
|
567
|
-
const
|
|
567
|
+
const out = new Array(pushed.length).fill(-1);
|
|
568
|
+
if (!page.length || pushed.length * page.length > MAX_PAIRINGS) return out;
|
|
568
569
|
const cols = page.length + 1;
|
|
569
|
-
const score =
|
|
570
|
-
{ length: rows },
|
|
571
|
-
() => new Array(cols).fill(0)
|
|
572
|
-
);
|
|
570
|
+
const score = new Int32Array((pushed.length + 1) * cols);
|
|
573
571
|
for (let i2 = pushed.length - 1; i2 >= 0; i2--) {
|
|
574
572
|
for (let j2 = page.length - 1; j2 >= 0; j2--) {
|
|
573
|
+
const at = i2 * cols + j2;
|
|
575
574
|
const pair = fit(pushed[i2], page[j2]);
|
|
576
|
-
score[
|
|
577
|
-
score[
|
|
578
|
-
score[
|
|
579
|
-
pair ? pair + score[
|
|
575
|
+
score[at] = Math.max(
|
|
576
|
+
score[at + cols],
|
|
577
|
+
score[at + 1],
|
|
578
|
+
pair ? pair + score[at + cols + 1] : 0
|
|
580
579
|
);
|
|
581
580
|
}
|
|
582
581
|
}
|
|
583
|
-
const out = new Array(pushed.length).fill(-1);
|
|
584
582
|
let i = 0;
|
|
585
583
|
let j = 0;
|
|
586
584
|
while (i < pushed.length && j < page.length) {
|
|
585
|
+
const at = i * cols + j;
|
|
587
586
|
const pair = fit(pushed[i], page[j]);
|
|
588
|
-
if (pair && score[
|
|
587
|
+
if (pair && score[at] === pair + score[at + cols + 1]) {
|
|
589
588
|
out[i++] = j++;
|
|
590
|
-
} else if (score[
|
|
589
|
+
} else if (score[at + cols] >= score[at + 1]) {
|
|
591
590
|
i++;
|
|
592
591
|
} else {
|
|
593
592
|
j++;
|
|
@@ -596,14 +595,15 @@ function align(pushed, page) {
|
|
|
596
595
|
return out;
|
|
597
596
|
}
|
|
598
597
|
function resolveInternalLinks(current, value) {
|
|
598
|
+
if (!value.includes(INTERNAL_MARK)) return value;
|
|
599
599
|
const pushed = anchorsIn(value);
|
|
600
|
-
if (!pushed.some(
|
|
600
|
+
if (!pushed.some((anchor) => anchor.internal)) return value;
|
|
601
601
|
const page = typeof current === "string" ? anchorsIn(current) : [];
|
|
602
602
|
const pairs = align(pushed, page);
|
|
603
603
|
let out = "";
|
|
604
604
|
let cursor = 0;
|
|
605
605
|
pushed.forEach((anchor, i) => {
|
|
606
|
-
if (!
|
|
606
|
+
if (!anchor.internal) return;
|
|
607
607
|
out += value.slice(cursor, anchor.start);
|
|
608
608
|
const match = pairs[i] >= 0 ? page[pairs[i]] : null;
|
|
609
609
|
if (match?.href != null) {
|
|
@@ -620,15 +620,16 @@ function resolveInternalLinks(current, value) {
|
|
|
620
620
|
});
|
|
621
621
|
return out + value.slice(cursor);
|
|
622
622
|
}
|
|
623
|
-
var INTERNAL_HREF, ANCHOR, HREF, TAGS,
|
|
623
|
+
var INTERNAL_HREF, INTERNAL_MARK, ANCHOR, HREF, TAGS, MAX_PAIRINGS;
|
|
624
624
|
var init_internal_links = __esm({
|
|
625
625
|
"src/core/live-preview/internal-links.ts"() {
|
|
626
626
|
"use strict";
|
|
627
627
|
INTERNAL_HREF = /^[pa]uuid#/;
|
|
628
|
+
INTERNAL_MARK = "uuid#";
|
|
628
629
|
ANCHOR = /<a\b([^>]*)>([\s\S]*?)<\/a>/gi;
|
|
629
630
|
HREF = /(\shref\s*=\s*)(["'])(.*?)\2/i;
|
|
630
631
|
TAGS = /<[^>]+>/g;
|
|
631
|
-
|
|
632
|
+
MAX_PAIRINGS = 25e4;
|
|
632
633
|
}
|
|
633
634
|
});
|
|
634
635
|
|
|
@@ -825,7 +826,7 @@ function listKeysOf(entry) {
|
|
|
825
826
|
return keys;
|
|
826
827
|
}
|
|
827
828
|
function buildText(entry, template) {
|
|
828
|
-
const body = typeof entry.body === "string" ? entry.body : "";
|
|
829
|
+
const body = typeof entry.body === "string" ? resolveInternalLinks(null, entry.body) : "";
|
|
829
830
|
const full = {
|
|
830
831
|
__typename: "Text",
|
|
831
832
|
_id: entry._id,
|
|
@@ -1713,7 +1714,8 @@ function fillObject(doc, selections, typename, values, id, ctx) {
|
|
|
1713
1714
|
out[field.key] = [];
|
|
1714
1715
|
continue;
|
|
1715
1716
|
}
|
|
1716
|
-
const
|
|
1717
|
+
const sent = value === void 0 || value !== null && typeof value === "object" ? null : value;
|
|
1718
|
+
const scalar = typeof sent === "string" ? resolveInternalLinks(null, sent) : sent;
|
|
1717
1719
|
const target = typeof scalar === "string" ? editField(field.name) : null;
|
|
1718
1720
|
out[field.key] = target && links ? links.encode(scalar, target) : scalar;
|
|
1719
1721
|
}
|
|
@@ -1779,6 +1781,7 @@ var init_normalize_query = __esm({
|
|
|
1779
1781
|
init_utils();
|
|
1780
1782
|
init_field_name();
|
|
1781
1783
|
init_index_snapshot();
|
|
1784
|
+
init_internal_links();
|
|
1782
1785
|
init_patch();
|
|
1783
1786
|
init_query_document();
|
|
1784
1787
|
init_validate();
|
package/dist/nuxt/live.js
CHANGED
|
@@ -164,7 +164,7 @@ function createLiveStarter(options = {}) {
|
|
|
164
164
|
}
|
|
165
165
|
},
|
|
166
166
|
start() {
|
|
167
|
-
starting ?? (starting = import("./live-preview-
|
|
167
|
+
starting ?? (starting = import("./live-preview-T5YCASSA.js").then((runtime) => {
|
|
168
168
|
const started = runtime.createLiveStore(options.storeOptions?.());
|
|
169
169
|
options.onStart?.(started, runtime);
|
|
170
170
|
bridge = runtime.createLiveBridge(started, {
|
|
@@ -3703,7 +3703,7 @@ function createPreprPreview(opts = {}) {
|
|
|
3703
3703
|
}
|
|
3704
3704
|
|
|
3705
3705
|
// src/version.ts
|
|
3706
|
-
var VERSION = "1.0.0-rc.
|
|
3706
|
+
var VERSION = "1.0.0-rc.7";
|
|
3707
3707
|
|
|
3708
3708
|
// src/core/pixel.ts
|
|
3709
3709
|
var PIXEL_SCRIPT_URL = "https://cdn.tracking.prepr.io/js/prepr.min.js";
|
package/dist/react/components.js
CHANGED
|
@@ -3679,7 +3679,7 @@ function createPreprPreview(opts = {}) {
|
|
|
3679
3679
|
}
|
|
3680
3680
|
|
|
3681
3681
|
// src/version.ts
|
|
3682
|
-
var VERSION = "1.0.0-rc.
|
|
3682
|
+
var VERSION = "1.0.0-rc.7";
|
|
3683
3683
|
|
|
3684
3684
|
// src/core/pixel.ts
|
|
3685
3685
|
var PIXEL_SCRIPT_URL = "https://cdn.tracking.prepr.io/js/prepr.min.js";
|
package/dist/sveltekit/index.cjs
CHANGED
package/dist/sveltekit/index.js
CHANGED
|
@@ -152,57 +152,57 @@ function isTextEntry(record) {
|
|
|
152
152
|
|
|
153
153
|
// src/core/live-preview/internal-links.ts
|
|
154
154
|
var INTERNAL_HREF = /^[pa]uuid#/;
|
|
155
|
+
var INTERNAL_MARK = "uuid#";
|
|
155
156
|
var ANCHOR = /<a\b([^>]*)>([\s\S]*?)<\/a>/gi;
|
|
156
157
|
var HREF = /(\shref\s*=\s*)(["'])(.*?)\2/i;
|
|
157
158
|
var TAGS = /<[^>]+>/g;
|
|
159
|
+
var MAX_PAIRINGS = 25e4;
|
|
158
160
|
function anchorsIn(html) {
|
|
159
161
|
const out = [];
|
|
160
162
|
for (const match of html.matchAll(ANCHOR)) {
|
|
161
163
|
const attributes = match[1];
|
|
162
164
|
const inner = match[2];
|
|
165
|
+
const href = HREF.exec(attributes)?.[3] ?? null;
|
|
163
166
|
out.push({
|
|
164
167
|
start: match.index ?? 0,
|
|
165
168
|
end: (match.index ?? 0) + match[0].length,
|
|
166
169
|
attributes,
|
|
167
170
|
inner,
|
|
168
|
-
href
|
|
171
|
+
href,
|
|
172
|
+
internal: href !== null && INTERNAL_HREF.test(href),
|
|
169
173
|
text: inner.replace(TAGS, "").trim()
|
|
170
174
|
});
|
|
171
175
|
}
|
|
172
176
|
return out;
|
|
173
177
|
}
|
|
174
|
-
var isInternal = (anchor) => anchor.href !== null && INTERNAL_HREF.test(anchor.href);
|
|
175
178
|
function fit(pushed, page) {
|
|
176
|
-
if (
|
|
177
|
-
if (isInternal(pushed) && page.href !== null && INTERNAL_HREF.test(page.href))
|
|
178
|
-
return 0;
|
|
179
|
+
if (pushed.internal ? page.internal : pushed.href !== page.href) return 0;
|
|
179
180
|
return pushed.text === page.text ? 2 : 1;
|
|
180
181
|
}
|
|
181
182
|
function align(pushed, page) {
|
|
182
|
-
const
|
|
183
|
+
const out = new Array(pushed.length).fill(-1);
|
|
184
|
+
if (!page.length || pushed.length * page.length > MAX_PAIRINGS) return out;
|
|
183
185
|
const cols = page.length + 1;
|
|
184
|
-
const score =
|
|
185
|
-
{ length: rows },
|
|
186
|
-
() => new Array(cols).fill(0)
|
|
187
|
-
);
|
|
186
|
+
const score = new Int32Array((pushed.length + 1) * cols);
|
|
188
187
|
for (let i2 = pushed.length - 1; i2 >= 0; i2--) {
|
|
189
188
|
for (let j2 = page.length - 1; j2 >= 0; j2--) {
|
|
189
|
+
const at = i2 * cols + j2;
|
|
190
190
|
const pair = fit(pushed[i2], page[j2]);
|
|
191
|
-
score[
|
|
192
|
-
score[
|
|
193
|
-
score[
|
|
194
|
-
pair ? pair + score[
|
|
191
|
+
score[at] = Math.max(
|
|
192
|
+
score[at + cols],
|
|
193
|
+
score[at + 1],
|
|
194
|
+
pair ? pair + score[at + cols + 1] : 0
|
|
195
195
|
);
|
|
196
196
|
}
|
|
197
197
|
}
|
|
198
|
-
const out = new Array(pushed.length).fill(-1);
|
|
199
198
|
let i = 0;
|
|
200
199
|
let j = 0;
|
|
201
200
|
while (i < pushed.length && j < page.length) {
|
|
201
|
+
const at = i * cols + j;
|
|
202
202
|
const pair = fit(pushed[i], page[j]);
|
|
203
|
-
if (pair && score[
|
|
203
|
+
if (pair && score[at] === pair + score[at + cols + 1]) {
|
|
204
204
|
out[i++] = j++;
|
|
205
|
-
} else if (score[
|
|
205
|
+
} else if (score[at + cols] >= score[at + 1]) {
|
|
206
206
|
i++;
|
|
207
207
|
} else {
|
|
208
208
|
j++;
|
|
@@ -211,14 +211,15 @@ function align(pushed, page) {
|
|
|
211
211
|
return out;
|
|
212
212
|
}
|
|
213
213
|
function resolveInternalLinks(current, value) {
|
|
214
|
+
if (!value.includes(INTERNAL_MARK)) return value;
|
|
214
215
|
const pushed = anchorsIn(value);
|
|
215
|
-
if (!pushed.some(
|
|
216
|
+
if (!pushed.some((anchor) => anchor.internal)) return value;
|
|
216
217
|
const page = typeof current === "string" ? anchorsIn(current) : [];
|
|
217
218
|
const pairs = align(pushed, page);
|
|
218
219
|
let out = "";
|
|
219
220
|
let cursor = 0;
|
|
220
221
|
pushed.forEach((anchor, i) => {
|
|
221
|
-
if (!
|
|
222
|
+
if (!anchor.internal) return;
|
|
222
223
|
out += value.slice(cursor, anchor.start);
|
|
223
224
|
const match = pairs[i] >= 0 ? page[pairs[i]] : null;
|
|
224
225
|
if (match?.href != null) {
|
|
@@ -431,7 +432,7 @@ function listKeysOf(entry) {
|
|
|
431
432
|
return keys;
|
|
432
433
|
}
|
|
433
434
|
function buildText(entry, template) {
|
|
434
|
-
const body = typeof entry.body === "string" ? entry.body : "";
|
|
435
|
+
const body = typeof entry.body === "string" ? resolveInternalLinks(null, entry.body) : "";
|
|
435
436
|
const full = {
|
|
436
437
|
__typename: "Text",
|
|
437
438
|
_id: entry._id,
|
|
@@ -1255,7 +1256,8 @@ function fillObject(doc, selections, typename, values, id, ctx) {
|
|
|
1255
1256
|
out[field.key] = [];
|
|
1256
1257
|
continue;
|
|
1257
1258
|
}
|
|
1258
|
-
const
|
|
1259
|
+
const sent = value === void 0 || value !== null && typeof value === "object" ? null : value;
|
|
1260
|
+
const scalar = typeof sent === "string" ? resolveInternalLinks(null, sent) : sent;
|
|
1259
1261
|
const target = typeof scalar === "string" ? editField(field.name) : null;
|
|
1260
1262
|
out[field.key] = target && links ? links.encode(scalar, target) : scalar;
|
|
1261
1263
|
}
|
package/dist/sveltekit/live.cjs
CHANGED
|
@@ -546,48 +546,47 @@ function anchorsIn(html) {
|
|
|
546
546
|
for (const match of html.matchAll(ANCHOR)) {
|
|
547
547
|
const attributes = match[1];
|
|
548
548
|
const inner = match[2];
|
|
549
|
+
const href = HREF.exec(attributes)?.[3] ?? null;
|
|
549
550
|
out.push({
|
|
550
551
|
start: match.index ?? 0,
|
|
551
552
|
end: (match.index ?? 0) + match[0].length,
|
|
552
553
|
attributes,
|
|
553
554
|
inner,
|
|
554
|
-
href
|
|
555
|
+
href,
|
|
556
|
+
internal: href !== null && INTERNAL_HREF.test(href),
|
|
555
557
|
text: inner.replace(TAGS, "").trim()
|
|
556
558
|
});
|
|
557
559
|
}
|
|
558
560
|
return out;
|
|
559
561
|
}
|
|
560
562
|
function fit(pushed, page) {
|
|
561
|
-
if (
|
|
562
|
-
if (isInternal(pushed) && page.href !== null && INTERNAL_HREF.test(page.href))
|
|
563
|
-
return 0;
|
|
563
|
+
if (pushed.internal ? page.internal : pushed.href !== page.href) return 0;
|
|
564
564
|
return pushed.text === page.text ? 2 : 1;
|
|
565
565
|
}
|
|
566
566
|
function align(pushed, page) {
|
|
567
|
-
const
|
|
567
|
+
const out = new Array(pushed.length).fill(-1);
|
|
568
|
+
if (!page.length || pushed.length * page.length > MAX_PAIRINGS) return out;
|
|
568
569
|
const cols = page.length + 1;
|
|
569
|
-
const score =
|
|
570
|
-
{ length: rows },
|
|
571
|
-
() => new Array(cols).fill(0)
|
|
572
|
-
);
|
|
570
|
+
const score = new Int32Array((pushed.length + 1) * cols);
|
|
573
571
|
for (let i2 = pushed.length - 1; i2 >= 0; i2--) {
|
|
574
572
|
for (let j2 = page.length - 1; j2 >= 0; j2--) {
|
|
573
|
+
const at = i2 * cols + j2;
|
|
575
574
|
const pair = fit(pushed[i2], page[j2]);
|
|
576
|
-
score[
|
|
577
|
-
score[
|
|
578
|
-
score[
|
|
579
|
-
pair ? pair + score[
|
|
575
|
+
score[at] = Math.max(
|
|
576
|
+
score[at + cols],
|
|
577
|
+
score[at + 1],
|
|
578
|
+
pair ? pair + score[at + cols + 1] : 0
|
|
580
579
|
);
|
|
581
580
|
}
|
|
582
581
|
}
|
|
583
|
-
const out = new Array(pushed.length).fill(-1);
|
|
584
582
|
let i = 0;
|
|
585
583
|
let j = 0;
|
|
586
584
|
while (i < pushed.length && j < page.length) {
|
|
585
|
+
const at = i * cols + j;
|
|
587
586
|
const pair = fit(pushed[i], page[j]);
|
|
588
|
-
if (pair && score[
|
|
587
|
+
if (pair && score[at] === pair + score[at + cols + 1]) {
|
|
589
588
|
out[i++] = j++;
|
|
590
|
-
} else if (score[
|
|
589
|
+
} else if (score[at + cols] >= score[at + 1]) {
|
|
591
590
|
i++;
|
|
592
591
|
} else {
|
|
593
592
|
j++;
|
|
@@ -596,14 +595,15 @@ function align(pushed, page) {
|
|
|
596
595
|
return out;
|
|
597
596
|
}
|
|
598
597
|
function resolveInternalLinks(current, value) {
|
|
598
|
+
if (!value.includes(INTERNAL_MARK)) return value;
|
|
599
599
|
const pushed = anchorsIn(value);
|
|
600
|
-
if (!pushed.some(
|
|
600
|
+
if (!pushed.some((anchor) => anchor.internal)) return value;
|
|
601
601
|
const page = typeof current === "string" ? anchorsIn(current) : [];
|
|
602
602
|
const pairs = align(pushed, page);
|
|
603
603
|
let out = "";
|
|
604
604
|
let cursor = 0;
|
|
605
605
|
pushed.forEach((anchor, i) => {
|
|
606
|
-
if (!
|
|
606
|
+
if (!anchor.internal) return;
|
|
607
607
|
out += value.slice(cursor, anchor.start);
|
|
608
608
|
const match = pairs[i] >= 0 ? page[pairs[i]] : null;
|
|
609
609
|
if (match?.href != null) {
|
|
@@ -620,15 +620,16 @@ function resolveInternalLinks(current, value) {
|
|
|
620
620
|
});
|
|
621
621
|
return out + value.slice(cursor);
|
|
622
622
|
}
|
|
623
|
-
var INTERNAL_HREF, ANCHOR, HREF, TAGS,
|
|
623
|
+
var INTERNAL_HREF, INTERNAL_MARK, ANCHOR, HREF, TAGS, MAX_PAIRINGS;
|
|
624
624
|
var init_internal_links = __esm({
|
|
625
625
|
"src/core/live-preview/internal-links.ts"() {
|
|
626
626
|
"use strict";
|
|
627
627
|
INTERNAL_HREF = /^[pa]uuid#/;
|
|
628
|
+
INTERNAL_MARK = "uuid#";
|
|
628
629
|
ANCHOR = /<a\b([^>]*)>([\s\S]*?)<\/a>/gi;
|
|
629
630
|
HREF = /(\shref\s*=\s*)(["'])(.*?)\2/i;
|
|
630
631
|
TAGS = /<[^>]+>/g;
|
|
631
|
-
|
|
632
|
+
MAX_PAIRINGS = 25e4;
|
|
632
633
|
}
|
|
633
634
|
});
|
|
634
635
|
|
|
@@ -825,7 +826,7 @@ function listKeysOf(entry) {
|
|
|
825
826
|
return keys;
|
|
826
827
|
}
|
|
827
828
|
function buildText(entry, template) {
|
|
828
|
-
const body = typeof entry.body === "string" ? entry.body : "";
|
|
829
|
+
const body = typeof entry.body === "string" ? resolveInternalLinks(null, entry.body) : "";
|
|
829
830
|
const full = {
|
|
830
831
|
__typename: "Text",
|
|
831
832
|
_id: entry._id,
|
|
@@ -1713,7 +1714,8 @@ function fillObject(doc, selections, typename, values, id, ctx) {
|
|
|
1713
1714
|
out[field.key] = [];
|
|
1714
1715
|
continue;
|
|
1715
1716
|
}
|
|
1716
|
-
const
|
|
1717
|
+
const sent = value === void 0 || value !== null && typeof value === "object" ? null : value;
|
|
1718
|
+
const scalar = typeof sent === "string" ? resolveInternalLinks(null, sent) : sent;
|
|
1717
1719
|
const target = typeof scalar === "string" ? editField(field.name) : null;
|
|
1718
1720
|
out[field.key] = target && links ? links.encode(scalar, target) : scalar;
|
|
1719
1721
|
}
|
|
@@ -1779,6 +1781,7 @@ var init_normalize_query = __esm({
|
|
|
1779
1781
|
init_utils();
|
|
1780
1782
|
init_field_name();
|
|
1781
1783
|
init_index_snapshot();
|
|
1784
|
+
init_internal_links();
|
|
1782
1785
|
init_patch();
|
|
1783
1786
|
init_query_document();
|
|
1784
1787
|
init_validate();
|
package/dist/sveltekit/live.js
CHANGED
|
@@ -155,7 +155,7 @@ function createLiveStarter(options = {}) {
|
|
|
155
155
|
}
|
|
156
156
|
},
|
|
157
157
|
start() {
|
|
158
|
-
starting ?? (starting = import("./live-preview-
|
|
158
|
+
starting ?? (starting = import("./live-preview-T5YCASSA.js").then((runtime) => {
|
|
159
159
|
const started = runtime.createLiveStore(options.storeOptions?.());
|
|
160
160
|
options.onStart?.(started, runtime);
|
|
161
161
|
bridge = runtime.createLiveBridge(started, {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@preprio/toolkit",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.7",
|
|
4
4
|
"description": "Prepr personalization, A/B testing and preview toolkit for React, Next.js, Nuxt, Astro, SvelteKit and Express",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Prepr B.V. (https://prepr.io)",
|