@preprio/toolkit 0.5.0-rc.10 → 0.5.0-rc.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -0
- package/dist/astro/index.cjs +31 -2
- package/dist/astro/index.js +31 -2
- package/dist/{chunk-KD3GK6TO.js → chunk-CABGJW5X.js} +30 -1
- package/dist/{chunk-URXSDJOU.js → chunk-H3AFUPYD.js} +9 -0
- package/dist/{chunk-F46GJS6Y.js → chunk-HVTNUCF7.js} +1 -1
- package/dist/{chunk-IPMB32AZ.js → chunk-LWUSRWFE.js} +2 -2
- package/dist/{chunk-IDEC77LZ.js → chunk-M7FT7XXV.js} +93 -20
- package/dist/{chunk-TBBU3LDD.js → chunk-TJ7VALNA.js} +1 -1
- package/dist/index.cjs +131 -20
- package/dist/index.d.cts +6 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.js +6 -6
- package/dist/{live-preview-DLXGXRE5.js → live-preview-SFBGATWC.js} +3 -3
- package/dist/nextjs/components.cjs +101 -19
- package/dist/nextjs/components.js +3 -3
- package/dist/nextjs/index.cjs +31 -2
- package/dist/nextjs/index.js +31 -2
- package/dist/nextjs/live-action.js +3 -3
- package/dist/nextjs/live.cjs +30 -1
- package/dist/nextjs/live.js +1 -1
- package/dist/nuxt/index.cjs +1 -1
- package/dist/nuxt/index.js +1 -1
- package/dist/nuxt/{live-preview-2RCU35W5.js → live-preview-XMQQZHMZ.js} +30 -1
- package/dist/nuxt/live.cjs +30 -1
- package/dist/nuxt/live.js +1 -1
- package/dist/react/components.cjs +101 -19
- package/dist/react/components.js +101 -19
- package/dist/sveltekit/index.cjs +1 -1
- package/dist/sveltekit/index.js +1 -1
- package/dist/sveltekit/{live-preview-2RCU35W5.js → live-preview-XMQQZHMZ.js} +30 -1
- package/dist/sveltekit/live.cjs +30 -1
- package/dist/sveltekit/live.js +1 -1
- package/package.json +1 -1
package/dist/sveltekit/live.cjs
CHANGED
|
@@ -536,8 +536,32 @@ function shapeLike(template, incoming) {
|
|
|
536
536
|
}
|
|
537
537
|
return out;
|
|
538
538
|
}
|
|
539
|
+
function isAsset(value) {
|
|
540
|
+
return isPlainObject(value) && (typeof value.url === "string" || value.__typename === "Asset");
|
|
541
|
+
}
|
|
542
|
+
function hasId(list, entry) {
|
|
543
|
+
return entry._id !== void 0 && list.some((c) => isPlainObject(c) && c._id === entry._id);
|
|
544
|
+
}
|
|
545
|
+
function isAssetValue(value) {
|
|
546
|
+
return Array.isArray(value) ? value.length > 0 && value.every(isAsset) : isAsset(value);
|
|
547
|
+
}
|
|
548
|
+
function keepRemovedAssets(current, next) {
|
|
549
|
+
const listed = /* @__PURE__ */ new Set();
|
|
550
|
+
for (const entry of next) {
|
|
551
|
+
if (isPlainObject(entry) && entry._id !== void 0) listed.add(entry._id);
|
|
552
|
+
}
|
|
553
|
+
let out = next;
|
|
554
|
+
current.forEach((entry, position) => {
|
|
555
|
+
if (!isPlainObject(entry) || entry._id === void 0) return;
|
|
556
|
+
if (listed.has(entry._id)) return;
|
|
557
|
+
if (out === next) out = [...next];
|
|
558
|
+
out.splice(Math.min(position, out.length), 0, entry);
|
|
559
|
+
});
|
|
560
|
+
return out;
|
|
561
|
+
}
|
|
539
562
|
function mergeStructured(current, incoming) {
|
|
540
563
|
if (incoming === null || Array.isArray(incoming) && !incoming.length) {
|
|
564
|
+
if (isAssetValue(current)) return current;
|
|
541
565
|
if (Array.isArray(current)) return current.length ? [] : current;
|
|
542
566
|
return null;
|
|
543
567
|
}
|
|
@@ -545,13 +569,18 @@ function mergeStructured(current, incoming) {
|
|
|
545
569
|
if (current === null || current === void 0) return incoming;
|
|
546
570
|
if (Array.isArray(current)) {
|
|
547
571
|
const template = current.find(isPlainObject);
|
|
548
|
-
|
|
572
|
+
const next = list.map((entry) => {
|
|
549
573
|
const match = current.find(
|
|
550
574
|
(c) => isPlainObject(c) && c._id !== void 0 && c._id === entry._id
|
|
551
575
|
);
|
|
552
576
|
if (isPlainObject(match)) return mergeObject(match, entry);
|
|
553
577
|
return isPlainObject(template) ? shapeLike(template, entry) : entry;
|
|
554
578
|
});
|
|
579
|
+
if (!isAssetValue(current) || list.some((entry) => !hasId(current, entry))) {
|
|
580
|
+
return next;
|
|
581
|
+
}
|
|
582
|
+
const kept = keepRemovedAssets(current, next);
|
|
583
|
+
return kept.length === current.length && kept.every((entry, i) => entry === current[i]) ? current : kept;
|
|
555
584
|
}
|
|
556
585
|
if (isPlainObject(current)) return mergeObject(current, list[0]);
|
|
557
586
|
return current;
|
package/dist/sveltekit/live.js
CHANGED
|
@@ -131,7 +131,7 @@ function isFramed() {
|
|
|
131
131
|
return typeof window !== "undefined" && window.self !== window.top;
|
|
132
132
|
}
|
|
133
133
|
function startLive() {
|
|
134
|
-
starting ?? (starting = import("./live-preview-
|
|
134
|
+
starting ?? (starting = import("./live-preview-XMQQZHMZ.js").then(
|
|
135
135
|
({ applyPatchLog, createLiveBridge, createLiveStore }) => {
|
|
136
136
|
applyLog = applyPatchLog;
|
|
137
137
|
const started = createLiveStore();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@preprio/toolkit",
|
|
3
|
-
"version": "0.5.0-rc.
|
|
3
|
+
"version": "0.5.0-rc.12",
|
|
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)",
|