@picked/client 0.0.70-next.1 → 0.0.70-next.2
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/{api-RrCWPX5t.js → api-6xq5wVtp.js} +1 -1
- package/dist/{api-CHKRKQ_I.cjs → api-CGaBTtfd.cjs} +1 -1
- package/dist/cjs/index.js +2 -2
- package/dist/cjs/plugins/dynamic-experiences/index.js +1 -1
- package/dist/cjs/preview/index.js +1 -0
- package/dist/cjs/server/index.js +1 -1
- package/dist/esm/index.js +243 -211
- package/dist/esm/plugins/dynamic-experiences/index.js +2 -2
- package/dist/esm/preview/index.js +2 -0
- package/dist/esm/server/index.js +1 -1
- package/dist/inert-script-report-B_bMPRzp.js +18 -0
- package/dist/inert-script-report-ijRHPtcY.cjs +1 -0
- package/dist/{plugin-DF3_YOaU.js → plugin-GGRZMJr7.js} +3 -3
- package/dist/{plugin-DSfS1fY2.cjs → plugin-p0c8ECxA.cjs} +1 -1
- package/dist/preview-channel-Cx0e6fye.cjs +1 -0
- package/dist/preview-channel-DW9J8t4B.js +98 -0
- package/dist/protocol-Bb_vpLKE.cjs +1 -0
- package/dist/protocol-DSqOlW2r.js +84 -0
- package/dist/types/entities/content/content.d.ts +10 -0
- package/dist/types/entities/content/content.d.ts.map +1 -1
- package/dist/types/exports.d.ts +2 -0
- package/dist/types/exports.d.ts.map +1 -1
- package/dist/types/picked.d.ts +39 -7
- package/dist/types/picked.d.ts.map +1 -1
- package/dist/types/plugins/dynamic-experiences/plugin.d.ts.map +1 -1
- package/dist/types/plugins/dynamic-experiences/types.d.ts +6 -0
- package/dist/types/plugins/dynamic-experiences/types.d.ts.map +1 -1
- package/dist/types/preview/index.d.ts +18 -0
- package/dist/types/preview/index.d.ts.map +1 -0
- package/dist/types/preview-channel.d.ts +12 -0
- package/dist/types/preview-channel.d.ts.map +1 -0
- package/dist/types/preview-receiver/apply-ops.d.ts +32 -0
- package/dist/types/preview-receiver/apply-ops.d.ts.map +1 -0
- package/dist/types/preview-receiver/index.d.ts +15 -0
- package/dist/types/preview-receiver/index.d.ts.map +1 -0
- package/dist/types/preview-receiver/protocol.d.ts +60 -0
- package/dist/types/preview-receiver/protocol.d.ts.map +1 -0
- package/dist/types/utils/content-path.d.ts +37 -0
- package/dist/types/utils/content-path.d.ts.map +1 -0
- package/dist/types/utils/inert-script-report.d.ts +40 -0
- package/dist/types/utils/inert-script-report.d.ts.map +1 -0
- package/dist/types/utils/preview-session.d.ts +12 -0
- package/dist/types/utils/preview-session.d.ts.map +1 -0
- package/package.json +14 -2
- package/dist/preview-bridge-CpX1BkSA.cjs +0 -1
- package/dist/preview-bridge-D76l-dPy.js +0 -33
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { i as e } from "../../../api-
|
|
2
|
-
import { n as t, r as n, t as r } from "../../../plugin-
|
|
1
|
+
import { i as e } from "../../../api-6xq5wVtp.js";
|
|
2
|
+
import { n as t, r as n, t as r } from "../../../plugin-GGRZMJr7.js";
|
|
3
3
|
export { e as createClientHeaders, r as dynamicExperiencesPlugin, t as fetchExperienceContent, n as fetchProject };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as e, c as t, i as n, l as r, n as i, r as a, s as o, t as s } from "../../protocol-DSqOlW2r.js";
|
|
2
|
+
export { s as PREVIEW_CONTENT_PATCH_MESSAGE, i as PREVIEW_INERT_SCRIPTS_MESSAGE, a as PREVIEW_PROTOCOL_VERSION, n as PREVIEW_READY_MESSAGE, e as PREVIEW_RESYNC_MESSAGE, o as applyContentOps, t as formatContentPath, r as parseContentPath };
|
package/dist/esm/server/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { a as e, c as t, i as n, o as r, s as i, t as a, u as o } from "../../experience-instance-DOJShRk5.js";
|
|
2
|
-
import { i as s, n as c } from "../../plugin-
|
|
2
|
+
import { i as s, n as c } from "../../plugin-GGRZMJr7.js";
|
|
3
3
|
import { attach as l, createEffect as u, createEvent as d, createStore as f, sample as p } from "effector";
|
|
4
4
|
//#region src/server/serialize.ts
|
|
5
5
|
var m = 1e4;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
//#region src/utils/inert-script-report.ts
|
|
2
|
+
var e = 0, t = /* @__PURE__ */ new Set();
|
|
3
|
+
function n(n) {
|
|
4
|
+
if (!(!Number.isFinite(n) || n <= 0)) {
|
|
5
|
+
e += n;
|
|
6
|
+
for (let n of t) n(e);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
function r(n) {
|
|
10
|
+
return t.add(n), e > 0 && n(e), () => {
|
|
11
|
+
t.delete(n);
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
function i() {
|
|
15
|
+
e = 0, t.clear();
|
|
16
|
+
}
|
|
17
|
+
//#endregion
|
|
18
|
+
export { n, i as r, r as t };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=0,t=new Set;function n(n){if(!(!Number.isFinite(n)||n<=0)){e+=n;for(let n of t)n(e)}}function r(n){return t.add(n),e>0&&n(e),()=>{t.delete(n)}}function i(){e=0,t.clear()}Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return r}});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "./logger-DMN6TxJJ.js";
|
|
2
|
-
import { t as e } from "./api-
|
|
2
|
+
import { t as e } from "./api-6xq5wVtp.js";
|
|
3
3
|
import { attach as t } from "effector";
|
|
4
4
|
//#region src/plugins/dynamic-experiences/hash.ts
|
|
5
5
|
function n(e) {
|
|
@@ -234,10 +234,10 @@ function A(e) {
|
|
|
234
234
|
apiUrl: r,
|
|
235
235
|
options: e
|
|
236
236
|
});
|
|
237
|
-
a && (n.contentLoader = D(n, O(a, i))), n.dataSource = o, i && d(n, i, {
|
|
237
|
+
a && (n.contentLoader = D(n, O(a, i))), n.dataSource = o, i && (n.previewEmbedderOrigins = i.previewEmbedderOrigins ?? null, d(n, i, {
|
|
238
238
|
isPreview: s,
|
|
239
239
|
sessionId: t
|
|
240
|
-
});
|
|
240
|
+
}));
|
|
241
241
|
}
|
|
242
242
|
}) };
|
|
243
243
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
require("./logger-CSTvAyyB.cjs");const e=require("./api-
|
|
1
|
+
require("./logger-CSTvAyyB.cjs");const e=require("./api-CGaBTtfd.cjs");let t=require("effector");function n(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t>>>0}function r(e){return n(e)%100}function i(e,t){return t<=0?!1:t>=100?!0:e<t}function a(e){return typeof e==`object`&&!!e&&`features`in e&&Array.isArray(e.features)}function o(e,t){if(Array.isArray(t.conditions))for(let n of t.conditions)e.registerCondition(n)}function s(e,t){e.registerExperience({id:t.id,key:t.key,name:t.name,targets:t.targets,nodes:t.nodes,edges:t.edges,condition:t.condition,initializeOpen:t.initializeOpen,componentName:t.componentName})}function c(e,t){if(Array.isArray(t.fields))for(let n of t.fields)e.registerField(n)}function l(e,t){if(!Array.isArray(t.steps))return;let n=new Map(t.fields.map(e=>[e.id,e.key]));for(let r of t.steps){let t=[];for(let e of r.fieldIds??[]){let i=n.get(e);if(i===void 0){`${r.key}${e}`;continue}t.push(i)}let i=r.layoutContentId?e.contents.getById(r.layoutContentId):null;e.registerStep({id:r.id,key:r.key,name:r.name,fieldKeys:t,layoutName:r.layoutName,...r.layoutContentId!==void 0&&{layoutContentId:r.layoutContentId,layoutContentStore:i}})}}function u(e,t){if(Array.isArray(t.experiences))for(let n of t.experiences)s(e,n)}function d(e,t,n){m(e,t,n.isPreview,n.sessionId),o(e,t),c(e,t),l(e,t),u(e,t)}function f(e){let t=e.searchParams[`preview-token`];if(t&&t.length>0)return t[0]}function p(e){let t=new Set,n=e.searchParams.feature;if(!n)return t;for(let e of n){let n=e.indexOf(`:`);n>0&&t.add(e.substring(0,n))}return t}function m(e,t,n,i){let a=p(e),o=r(i);for(let r of t.features)a.has(r.id)||h(e,r,n,o)}function h(e,t,n,r){e.registerFeature(t.id,{key:`v${t.version}`,name:t.name,enabled:t.enabled,weight:t.weight,storage:n?`session`:`local`,decide:()=>t.enabled?i(r,t.weight):!1})}function g(e){try{let t=new URL(e).hostname;return t===`localhost`||t===`127.0.0.1`||t===`::1`}catch{return!1}}function _(e){if(typeof e!=`object`||!e||!(`cause`in e))return!1;let{cause:t}=e;return typeof t!=`object`||!t||!(`code`in t)?!1:t.code===`ECONNREFUSED`}async function v(t,n,r){let i=r?.previewToken?`projects/${n}?preview_token=${encodeURIComponent(r.previewToken)}`:`projects/${n}`,o;try{o=await e.t(t,i,r?.headers)}catch(e){return g(t)&&_(e),null}if(!o.ok)return`${o.status.toString()}`,null;let s;try{s=await o.json()}catch{return null}return a(s)?s:null}function y(e){return typeof e!=`object`||!e||!(`experienceId`in e)||!(`content`in e)?!1:Array.isArray(e.content)}async function b(t,n,r,i){let a=i?.previewToken?`projects/${n}/experiences/${r}/content?preview_token=${encodeURIComponent(i.previewToken)}`:`projects/${n}/experiences/${r}/content`,o;try{o=await e.t(t,a,i?.headers,i?.signal)}catch(e){return g(t)&&_(e)||`${r}`,null}if(!o.ok)return`${r}${o.status.toString()}`,null;let s;try{s=await o.json()}catch{return`${r}`,null}return y(s)?s:(`${r}`,null)}function x(e,t){for(let n of t.content)e.registerContent({id:n.id,contentModelKey:n.contentModelKey,data:n.data})}function S(e){if(typeof e!=`object`||!e||!(`projectConfig`in e)||!(`experienceContent`in e)||!(`manifestMetadata`in e))return!1;let{experienceContent:t}=e;return typeof t==`function`}async function C(){try{let e=await import(`virtual:picked/data`);return S(e)?e:null}catch{return null}}function w(e,t,n){return r=>b(e,t,r.id,n?{previewToken:n}:void 0)}function T(e,t){return n=>e(n,t?{previewToken:t}:void 0)}function E(e){return(t,n)=>e.experienceContent(t,n)}function D(e,t){let n=new Map;return(r,i)=>{let a=n.get(r.id);if(a)return a;let o=(async()=>{try{let n=await t(r,i);return n&&x(e,n),n}finally{n.delete(r.id)}})();return n.set(r.id,o),o}}function O(e,t){let n=new Set(t&&Array.isArray(t.experiences)?t.experiences.map(e=>e.id):[]);return(t,r)=>n.has(t.id)?e(t,r):Promise.resolve(null)}async function k(e){let{client:t,apiUrl:n,options:r}=e,i=f(t),a=!!i,o=r?.projectConfig??null,s=r?.getContent?T(r.getContent,i):null,c=null;if(i)return o??=await v(n,t.projectId,{previewToken:i}),s??=w(n,t.projectId,i),{config:o,contentLoader:s,dataSource:c,isPreview:a};if(o&&s)return{config:o,contentLoader:s,dataSource:c,isPreview:a};let l=await C();return l?(o??=l.projectConfig,s??=E(l),c=l.manifestMetadata,{config:o,contentLoader:s,dataSource:c,isPreview:a}):(o??=await v(n,t.projectId),s??=w(n,t.projectId),{config:o,contentLoader:s,dataSource:c,isPreview:a})}function A(e){return{name:`dynamic-experiences`,setup:n=>{let r=e?.apiUrl??n.apiUrl;return{onStart:(0,t.attach)({source:n.session.store.map(e=>e.id),effect:async t=>{let{config:i,contentLoader:a,dataSource:o,isPreview:s}=await k({client:n,apiUrl:r,options:e});a&&(n.contentLoader=D(n,O(a,i))),n.dataSource=o,i&&(n.previewEmbedderOrigins=i.previewEmbedderOrigins??null,d(n,i,{isPreview:s,sessionId:t}))}})}}}}Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return b}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return v}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return A}});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require("./object-CIkt7Fkr.cjs"),t=require("./supports-DBzjGaWD.cjs"),n=require("./inert-script-report-ijRHPtcY.cjs"),r=require("./protocol-Bb_vpLKE.cjs");var i=`picked-preview:navigation`,a=!1;function o(){return`*`}function s(){let{href:e,pathname:t,search:n}=globalThis.location,r={type:i,href:e,pathname:t,search:n};globalThis.parent.postMessage(r,o())}function c(e){return function(...t){e.apply(this,t),s()}}function l(){if(a||!t.f())return()=>void 0;a=!0,s();let n=()=>{s()};return globalThis.addEventListener(`popstate`,n),t.a()&&(e.n(globalThis.history,`pushState`,c),e.n(globalThis.history,`replaceState`,c)),()=>{a=!1,globalThis.removeEventListener(`popstate`,n)}}var u=5e3,d=!1;function f(e,t,n){if(e){e.postMessage(n);return}for(let e of t)globalThis.parent.postMessage(n,e)}function p(e){if(d)return()=>void 0;d=!0;let t=null,i=!1,a=new Map,o=()=>e.previewEmbedderOrigins??[],s=()=>{if(i)return;let n=o();if(n.length===0)return;i=!0;let a={type:r.i,protocolVersion:1,contentIds:Object.keys(e.contents.indexStore.getState())};f(t,n,a)},c=n=>{if(!r.o(n))return;let i=a.get(n.contentId);if(i!==void 0&&n.seq>i+1){let e={type:r.a,contentId:n.contentId,lastSeq:i};f(t,o(),e)}a.set(n.contentId,n.seq),n.ops.length>0&&e.patchContent(n.contentId,e=>r.s(e,n.ops))},l=e=>{if(!o().includes(e.origin))return;let n=e.ports.at(0);n&&!t&&(t=n,t.onmessage=e=>c(e.data),t.start()),c(e.data)};globalThis.addEventListener(`message`,l);let p=n.t(e=>{let n=o();n.length!==0&&f(t,n,{type:r.n,total:e})}),m=e.contents.indexStore.watch(e=>{Object.keys(e).length>0&&s()}),h=setTimeout(s,u);return()=>{d=!1,i=!1,clearTimeout(h),globalThis.removeEventListener(`message`,l),p(),m.unsubscribe(),t&&(t.onmessage=null),t=null}}function m(e){let t=l(),n=p(e);return()=>{t(),n()}}exports.initPreviewChannel=m;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { n as e } from "./object-BUDGxEqy.js";
|
|
2
|
+
import { a as t, f as n } from "./supports-CO9bJGNl.js";
|
|
3
|
+
import { t as r } from "./inert-script-report-B_bMPRzp.js";
|
|
4
|
+
import { a as i, i as a, n as o, o as s, s as c } from "./protocol-DSqOlW2r.js";
|
|
5
|
+
//#region src/preview-bridge/index.ts
|
|
6
|
+
var l = "picked-preview:navigation", u = !1;
|
|
7
|
+
function d() {
|
|
8
|
+
return "*";
|
|
9
|
+
}
|
|
10
|
+
function f() {
|
|
11
|
+
let { href: e, pathname: t, search: n } = globalThis.location, r = {
|
|
12
|
+
type: l,
|
|
13
|
+
href: e,
|
|
14
|
+
pathname: t,
|
|
15
|
+
search: n
|
|
16
|
+
};
|
|
17
|
+
globalThis.parent.postMessage(r, d());
|
|
18
|
+
}
|
|
19
|
+
function p(e) {
|
|
20
|
+
return function(...t) {
|
|
21
|
+
e.apply(this, t), f();
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
function m() {
|
|
25
|
+
if (u || !n()) return () => void 0;
|
|
26
|
+
u = !0, f();
|
|
27
|
+
let r = () => {
|
|
28
|
+
f();
|
|
29
|
+
};
|
|
30
|
+
return globalThis.addEventListener("popstate", r), t() && (e(globalThis.history, "pushState", p), e(globalThis.history, "replaceState", p)), () => {
|
|
31
|
+
u = !1, globalThis.removeEventListener("popstate", r);
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
//#endregion
|
|
35
|
+
//#region src/preview-receiver/index.ts
|
|
36
|
+
var h = 5e3, g = !1;
|
|
37
|
+
function _(e, t, n) {
|
|
38
|
+
if (e) {
|
|
39
|
+
e.postMessage(n);
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
for (let e of t) globalThis.parent.postMessage(n, e);
|
|
43
|
+
}
|
|
44
|
+
function v(e) {
|
|
45
|
+
if (g) return () => void 0;
|
|
46
|
+
g = !0;
|
|
47
|
+
let t = null, n = !1, l = /* @__PURE__ */ new Map(), u = () => e.previewEmbedderOrigins ?? [], d = () => {
|
|
48
|
+
if (n) return;
|
|
49
|
+
let r = u();
|
|
50
|
+
if (r.length === 0) return;
|
|
51
|
+
n = !0;
|
|
52
|
+
let i = {
|
|
53
|
+
type: a,
|
|
54
|
+
protocolVersion: 1,
|
|
55
|
+
contentIds: Object.keys(e.contents.indexStore.getState())
|
|
56
|
+
};
|
|
57
|
+
_(t, r, i);
|
|
58
|
+
}, f = (n) => {
|
|
59
|
+
if (!s(n)) return;
|
|
60
|
+
let r = l.get(n.contentId);
|
|
61
|
+
if (r !== void 0 && n.seq > r + 1) {
|
|
62
|
+
let e = {
|
|
63
|
+
type: i,
|
|
64
|
+
contentId: n.contentId,
|
|
65
|
+
lastSeq: r
|
|
66
|
+
};
|
|
67
|
+
_(t, u(), e);
|
|
68
|
+
}
|
|
69
|
+
l.set(n.contentId, n.seq), n.ops.length > 0 && e.patchContent(n.contentId, (e) => c(e, n.ops));
|
|
70
|
+
}, p = (e) => {
|
|
71
|
+
if (!u().includes(e.origin)) return;
|
|
72
|
+
let n = e.ports.at(0);
|
|
73
|
+
n && !t && (t = n, t.onmessage = (e) => f(e.data), t.start()), f(e.data);
|
|
74
|
+
};
|
|
75
|
+
globalThis.addEventListener("message", p);
|
|
76
|
+
let m = r((e) => {
|
|
77
|
+
let n = u();
|
|
78
|
+
n.length !== 0 && _(t, n, {
|
|
79
|
+
type: o,
|
|
80
|
+
total: e
|
|
81
|
+
});
|
|
82
|
+
}), v = e.contents.indexStore.watch((e) => {
|
|
83
|
+
Object.keys(e).length > 0 && d();
|
|
84
|
+
}), y = setTimeout(d, h);
|
|
85
|
+
return () => {
|
|
86
|
+
g = !1, n = !1, clearTimeout(y), globalThis.removeEventListener("message", p), m(), v.unsubscribe(), t && (t.onmessage = null), t = null;
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
//#endregion
|
|
90
|
+
//#region src/preview-channel.ts
|
|
91
|
+
function y(e) {
|
|
92
|
+
let t = m(), n = v(e);
|
|
93
|
+
return () => {
|
|
94
|
+
t(), n();
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
//#endregion
|
|
98
|
+
export { y as initPreviewChannel };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=/^[a-z][a-z0-9_]*$/,t=/^\d+$/,n=new Set([`__proto__`,`constructor`,`prototype`]);function r(r){let i=r.indexOf(`[`),a=i===-1?r:r.slice(0,i);if(!e.test(a)||n.has(a))return null;if(i===-1)return[a];let o=[a],s=r.slice(i);for(;s.length>0;){if(!s.startsWith(`[`))return null;let e=s.indexOf(`]`);if(e===-1)return null;let n=s.slice(1,e);if(!t.test(n))return null;o.push(Number(n)),s=s.slice(e+1)}return o}function i(e){if(typeof e!=`string`||e===``||e===`$`||!e.startsWith(`$.`))return[];let t=[];for(let n of e.slice(2).split(`.`)){let e=r(n);if(e===null)return[];t.push(...e)}return t}function a(e){let t=`$`;for(let n of e)t+=typeof n==`number`?`[${n}]`:`.${n}`;return t}function o(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function s(e,t,n){let[r,...i]=t;if(r===void 0)return n;if(typeof r==`number`){if(!Array.isArray(e)||r>=e.length)return e;let t=e[r],a=s(t,i,n);if(a===t)return e;let o=[...e];return o[r]=a,o}if(!o(e))return e;let a=e[r],c=i.length>0&&a===void 0&&typeof i[0]==`string`?s({},i,n):s(a,i,n);return c===a?e:{...e,[r]:c}}function c(e,t){let n=e;for(let e of t){let t=i(e.path);if(t.length===0)continue;let r=s(n,t,e.value);o(r)&&(n=r)}return n}var l=1,u=`picked-preview:ready`,d=`picked-preview:content-patch`,f=`picked-preview:resync`,p=`picked-preview:inert-scripts`;function m(e){return typeof e==`object`&&!!e&&`type`in e&&typeof Reflect.get(e,`type`)==`string`}function h(e){return typeof e!=`object`||!e?!1:typeof Reflect.get(e,`path`)==`string`&&`value`in e}function g(e){if(!m(e)||e.type!==`picked-preview:content-patch`)return!1;let t=Reflect.get(e,`contentId`),n=Reflect.get(e,`ops`),r=Reflect.get(e,`seq`);return typeof t==`string`&&t.length>0&&typeof r==`number`&&Number.isFinite(r)&&Array.isArray(n)&&n.every(h)}Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return f}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return p}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return g}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return d}});
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
//#region src/utils/content-path.ts
|
|
2
|
+
var e = /^[a-z][a-z0-9_]*$/, t = /^\d+$/, n = new Set([
|
|
3
|
+
"__proto__",
|
|
4
|
+
"constructor",
|
|
5
|
+
"prototype"
|
|
6
|
+
]);
|
|
7
|
+
function r(r) {
|
|
8
|
+
let i = r.indexOf("["), a = i === -1 ? r : r.slice(0, i);
|
|
9
|
+
if (!e.test(a) || n.has(a)) return null;
|
|
10
|
+
if (i === -1) return [a];
|
|
11
|
+
let o = [a], s = r.slice(i);
|
|
12
|
+
for (; s.length > 0;) {
|
|
13
|
+
if (!s.startsWith("[")) return null;
|
|
14
|
+
let e = s.indexOf("]");
|
|
15
|
+
if (e === -1) return null;
|
|
16
|
+
let n = s.slice(1, e);
|
|
17
|
+
if (!t.test(n)) return null;
|
|
18
|
+
o.push(Number(n)), s = s.slice(e + 1);
|
|
19
|
+
}
|
|
20
|
+
return o;
|
|
21
|
+
}
|
|
22
|
+
function i(e) {
|
|
23
|
+
if (typeof e != "string" || e === "" || e === "$" || !e.startsWith("$.")) return [];
|
|
24
|
+
let t = [];
|
|
25
|
+
for (let n of e.slice(2).split(".")) {
|
|
26
|
+
let e = r(n);
|
|
27
|
+
if (e === null) return [];
|
|
28
|
+
t.push(...e);
|
|
29
|
+
}
|
|
30
|
+
return t;
|
|
31
|
+
}
|
|
32
|
+
function a(e) {
|
|
33
|
+
let t = "$";
|
|
34
|
+
for (let n of e) t += typeof n == "number" ? `[${n}]` : `.${n}`;
|
|
35
|
+
return t;
|
|
36
|
+
}
|
|
37
|
+
//#endregion
|
|
38
|
+
//#region src/preview-receiver/apply-ops.ts
|
|
39
|
+
function o(e) {
|
|
40
|
+
return typeof e == "object" && !!e && !Array.isArray(e);
|
|
41
|
+
}
|
|
42
|
+
function s(e, t, n) {
|
|
43
|
+
let [r, ...i] = t;
|
|
44
|
+
if (r === void 0) return n;
|
|
45
|
+
if (typeof r == "number") {
|
|
46
|
+
if (!Array.isArray(e) || r >= e.length) return e;
|
|
47
|
+
let t = e[r], a = s(t, i, n);
|
|
48
|
+
if (a === t) return e;
|
|
49
|
+
let o = [...e];
|
|
50
|
+
return o[r] = a, o;
|
|
51
|
+
}
|
|
52
|
+
if (!o(e)) return e;
|
|
53
|
+
let a = e[r], c = i.length > 0 && a === void 0 && typeof i[0] == "string" ? s({}, i, n) : s(a, i, n);
|
|
54
|
+
return c === a ? e : {
|
|
55
|
+
...e,
|
|
56
|
+
[r]: c
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
function c(e, t) {
|
|
60
|
+
let n = e;
|
|
61
|
+
for (let e of t) {
|
|
62
|
+
let t = i(e.path);
|
|
63
|
+
if (t.length === 0) continue;
|
|
64
|
+
let r = s(n, t, e.value);
|
|
65
|
+
o(r) && (n = r);
|
|
66
|
+
}
|
|
67
|
+
return n;
|
|
68
|
+
}
|
|
69
|
+
//#endregion
|
|
70
|
+
//#region src/preview-receiver/protocol.ts
|
|
71
|
+
var l = 1, u = "picked-preview:ready", d = "picked-preview:content-patch", f = "picked-preview:resync", p = "picked-preview:inert-scripts";
|
|
72
|
+
function m(e) {
|
|
73
|
+
return typeof e == "object" && !!e && "type" in e && typeof Reflect.get(e, "type") == "string";
|
|
74
|
+
}
|
|
75
|
+
function h(e) {
|
|
76
|
+
return typeof e != "object" || !e ? !1 : typeof Reflect.get(e, "path") == "string" && "value" in e;
|
|
77
|
+
}
|
|
78
|
+
function g(e) {
|
|
79
|
+
if (!m(e) || e.type !== "picked-preview:content-patch") return !1;
|
|
80
|
+
let t = Reflect.get(e, "contentId"), n = Reflect.get(e, "ops"), r = Reflect.get(e, "seq");
|
|
81
|
+
return typeof t == "string" && t.length > 0 && typeof r == "number" && Number.isFinite(r) && Array.isArray(n) && n.every(h);
|
|
82
|
+
}
|
|
83
|
+
//#endregion
|
|
84
|
+
export { f as a, a as c, u as i, i as l, p as n, g as o, l as r, c as s, d as t };
|
|
@@ -8,9 +8,19 @@ export interface Content {
|
|
|
8
8
|
contentModelKey?: string | null;
|
|
9
9
|
data: Record<string, unknown>;
|
|
10
10
|
}
|
|
11
|
+
/**
|
|
12
|
+
* Transforms a content record's `data`, returning the next blob.
|
|
13
|
+
*
|
|
14
|
+
* Applied inside the store's own update so the read-modify-write cannot interleave with another
|
|
15
|
+
* write. Callers that want path-addressed ops build one of these with `applyContentOps` from
|
|
16
|
+
* `@picked/client/preview`, which is code-split away from the main bundle because only the
|
|
17
|
+
* live-preview channel needs it.
|
|
18
|
+
*/
|
|
19
|
+
export type ContentDataPatch = (data: Record<string, unknown>) => Record<string, unknown>;
|
|
11
20
|
export type ContentsStore = ReturnType<typeof createContentIndex>;
|
|
12
21
|
declare const createContentIndexFactory: () => {
|
|
13
22
|
register: (content: Content) => void;
|
|
23
|
+
patch: (id: string, apply: ContentDataPatch) => void;
|
|
14
24
|
getById: (id: Content["id"]) => Store<Content | null>;
|
|
15
25
|
listStore: Store<Content[]>;
|
|
16
26
|
indexStore: import('effector').StoreWritable<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"content.d.ts","sourceRoot":"","sources":["../../../../src/entities/content/content.ts"],"names":[],"mappings":"AAAA,oGAAoG;AACpG,OAAO,EAA2B,KAAK,KAAK,EAAE,MAAM,UAAU,CAAA;AAK9D,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAA;IACV;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC/B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAC9B;AAED,MAAM,MAAM,aAAa,GAAG,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAA;AAEjE,QAAA,MAAM,yBAAyB;
|
|
1
|
+
{"version":3,"file":"content.d.ts","sourceRoot":"","sources":["../../../../src/entities/content/content.ts"],"names":[],"mappings":"AAAA,oGAAoG;AACpG,OAAO,EAA2B,KAAK,KAAK,EAAE,MAAM,UAAU,CAAA;AAK9D,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAA;IACV;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC/B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAC9B;AAED;;;;;;;GAOG;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;AAEzF,MAAM,MAAM,aAAa,GAAG,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAA;AAEjE,QAAA,MAAM,yBAAyB;wBAiCF,OAAO,KAAG,IAAI;gBAkBtB,MAAM,SAAS,gBAAgB,KAAG,IAAI;kBAmBpC,OAAO,CAAC,IAAI,CAAC,KAAG,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC;;;;;CAW1D,CAAA;AAEF;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,IAAI,UAAU,CAAC,OAAO,yBAAyB,CAAC,CAEjF;AAED;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,aAAa,GAAG,IAAI,CAEzE"}
|
package/dist/types/exports.d.ts
CHANGED
|
@@ -4,6 +4,8 @@ export { isPickedRoot } from './utils/dom';
|
|
|
4
4
|
export { rehydrateScripts, buildRehydrateBootstrap, PICKED_SCRIPT_TYPE, PICKED_MODULE_SCRIPT_TYPE, PICKED_HYDRATED_ATTR, } from './utils/rehydrate-scripts';
|
|
5
5
|
export { isHtmlAssetValue } from './utils/html-asset-value';
|
|
6
6
|
export type { HtmlAssetValue } from './utils/html-asset-value';
|
|
7
|
+
export { isPreviewSession, PREVIEW_TOKEN_PARAM } from './utils/preview-session';
|
|
8
|
+
export { onInertScriptSubtrees, reportInertScriptSubtrees, resetInertScriptReport, } from './utils/inert-script-report';
|
|
7
9
|
export * from './utils/supports';
|
|
8
10
|
export * from './utils/storage';
|
|
9
11
|
export type * from './utils/storage';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exports.d.ts","sourceRoot":"","sources":["../../src/exports.ts"],"names":[],"mappings":"AAAA,8IAA8I;AAC9I,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAA;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAGjC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,EACL,gBAAgB,EAChB,uBAAuB,EACvB,kBAAkB,EAClB,yBAAyB,EACzB,oBAAoB,GACrB,MAAM,2BAA2B,CAAA;AAClC,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAA;AAC3D,YAAY,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;
|
|
1
|
+
{"version":3,"file":"exports.d.ts","sourceRoot":"","sources":["../../src/exports.ts"],"names":[],"mappings":"AAAA,8IAA8I;AAC9I,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAA;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAGjC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,EACL,gBAAgB,EAChB,uBAAuB,EACvB,kBAAkB,EAClB,yBAAyB,EACzB,oBAAoB,GACrB,MAAM,2BAA2B,CAAA;AAClC,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAA;AAC3D,YAAY,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAC9D,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAA;AAC/E,OAAO,EACL,qBAAqB,EACrB,yBAAyB,EACzB,sBAAsB,GACvB,MAAM,6BAA6B,CAAA;AAEpC,cAAc,kBAAkB,CAAA;AAChC,cAAc,iBAAiB,CAAA;AAC/B,mBAAmB,iBAAiB,CAAA;AACpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AACvD,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAA;AAChF,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAA;AAE7D;;;;;;;;;;GAUG;AACH,eAAO,MAAM,YAAY,GAAI,SAAS,mBAAmB,KAAG,MAI3D,CAAA;AAED,YAAY,EACV,uBAAuB,EACvB,qBAAqB,GACtB,MAAM,kCAAkC,CAAA"}
|
package/dist/types/picked.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ import { Feature } from './entities/feature/feature';
|
|
|
13
13
|
import { EventBusPayload, EventHistoryStore } from './utils/events';
|
|
14
14
|
import { Field } from './entities/field/field';
|
|
15
15
|
import { ExperienceStep } from './entities/step/step';
|
|
16
|
-
import { Content } from './entities/content/content';
|
|
16
|
+
import { Content, ContentDataPatch } from './entities/content/content';
|
|
17
17
|
import { ContentLoader } from './plugins/dynamic-experiences/types';
|
|
18
18
|
import { Action } from './entities/action/action';
|
|
19
19
|
import { Condition } from './entities/condition/condition';
|
|
@@ -49,6 +49,13 @@ export declare class Picked {
|
|
|
49
49
|
* has registered one yet.
|
|
50
50
|
*/
|
|
51
51
|
contentLoader?: ContentLoader;
|
|
52
|
+
/**
|
|
53
|
+
* Origins allowed to push live-preview content patches into this page, issued by the API on the
|
|
54
|
+
* preview surface and set by `dynamicExperiencesPlugin`. `null` until the project config
|
|
55
|
+
* resolves, and on every non-preview surface — the preview receiver treats that as "trust
|
|
56
|
+
* nobody" and stays closed.
|
|
57
|
+
*/
|
|
58
|
+
previewEmbedderOrigins: string[] | null;
|
|
52
59
|
private readonly plugins;
|
|
53
60
|
readonly eventBus: EventCallable<EventBusPayload>;
|
|
54
61
|
readonly events: EventHistoryStore;
|
|
@@ -201,6 +208,7 @@ export declare class Picked {
|
|
|
201
208
|
};
|
|
202
209
|
readonly contents: {
|
|
203
210
|
register: (content: Content) => void;
|
|
211
|
+
patch: (id: string, apply: ContentDataPatch) => void;
|
|
204
212
|
getById: (id: Content["id"]) => Store<Content | null>;
|
|
205
213
|
listStore: Store<Content[]>;
|
|
206
214
|
indexStore: StoreWritable<{
|
|
@@ -252,16 +260,20 @@ export declare class Picked {
|
|
|
252
260
|
}, string, Error>;
|
|
253
261
|
constructor(options: CreateClientOptions);
|
|
254
262
|
/**
|
|
255
|
-
* Lazily starts the preview
|
|
256
|
-
*
|
|
257
|
-
*
|
|
258
|
-
*
|
|
263
|
+
* Lazily starts the preview channel when this frame is a live-preview session: the outbound
|
|
264
|
+
* bridge, which reports the frame's URL to the dashboard, and the inbound receiver, which applies
|
|
265
|
+
* the dashboard's content patches.
|
|
266
|
+
*
|
|
267
|
+
* Both load from a single dynamic `import()` so there is one code-split point and neither reaches
|
|
268
|
+
* production bundles. Failures are swallowed so client creation never depends on the preview
|
|
269
|
+
* channel, and the receiver refuses every message until the API issues an origin allowlist, so
|
|
270
|
+
* starting it before the project config resolves is safe.
|
|
259
271
|
*
|
|
260
272
|
* @returns {void} Nothing.
|
|
261
273
|
* @example
|
|
262
|
-
* this.
|
|
274
|
+
* this.maybeStartPreviewChannel()
|
|
263
275
|
*/
|
|
264
|
-
private
|
|
276
|
+
private maybeStartPreviewChannel;
|
|
265
277
|
registerFramework: (framework: Framework) => void;
|
|
266
278
|
registerComponent: (name: string, component: AdaptedComponent) => void;
|
|
267
279
|
registerPlugin: (plugin: Plugin) => void;
|
|
@@ -271,6 +283,26 @@ export declare class Picked {
|
|
|
271
283
|
registerField: (field: Field) => void;
|
|
272
284
|
registerStep: (step: ExperienceStep) => void;
|
|
273
285
|
registerContent: (content: Content) => void;
|
|
286
|
+
/**
|
|
287
|
+
* Applies path-addressed replacements to a registered content record, leaving every untouched
|
|
288
|
+
* branch of the blob shared by reference so only the affected subtree re-renders.
|
|
289
|
+
*
|
|
290
|
+
* A no-op when no record with `id` is registered — the record's base blob comes from
|
|
291
|
+
* `contentLoader`, and a patch that arrives first must not fabricate one.
|
|
292
|
+
*
|
|
293
|
+
* Takes a transform rather than a list of path ops so the path parser and the spine-rebuilding
|
|
294
|
+
* walk stay out of this module's import graph — they belong to the lazily-loaded preview channel.
|
|
295
|
+
* Build one with `applyContentOps` from `@picked/client/preview`.
|
|
296
|
+
*
|
|
297
|
+
* @param {string} id - The content record id to patch.
|
|
298
|
+
* @param {ContentDataPatch} apply - Transform producing the next `data` blob.
|
|
299
|
+
* @returns {void} Nothing.
|
|
300
|
+
* @example
|
|
301
|
+
* ```typescript
|
|
302
|
+
* client.patchContent('c1', (data) => ({ ...data, headline: 'Hello' }))
|
|
303
|
+
* ```
|
|
304
|
+
*/
|
|
305
|
+
patchContent: (id: string, apply: ContentDataPatch) => void;
|
|
274
306
|
registerAction: (key: string, action: Action) => void;
|
|
275
307
|
registerExperience: (experience: Experience) => void;
|
|
276
308
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"picked.d.ts","sourceRoot":"","sources":["../../src/picked.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,OAAO,EAGL,KAAK,MAAM,EACX,KAAK,aAAa,EAClB,KAAK,KAAK,EACV,KAAK,aAAa,EACnB,MAAM,UAAU,CAAA;AACjB,OAAO,EAEL,KAAK,UAAU,EACf,KAAK,uBAAuB,EAC7B,MAAM,kCAAkC,CAAA;AACzC,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,iBAAiB,EAAe,MAAM,0BAA0B,CAAA;AAC3F,OAAO,EAAE,KAAK,mBAA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qB,CACnC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,aAAa,EACrB,OAAO,EAAE;IAAE,SAAS,EAAE,OAAO,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GACjD,IAAI,CAMN;AA8JD;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,YAAY,CAChC,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,OAAO,CAAC,EAAE,mBAAmB,GAC5B,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC,CAmC/B;AAoBD;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,sBAAsB,CAC1C,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,MAAM,EACpB,OAAO,CAAC,EAAE,mBAAmB,GAC5B,OAAO,CAAC,yBAAyB,GAAG,IAAI,CAAC,CAsC3C;AA4QD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,CAAC,EAAE,+BAA+B,GAAG,MAAM,CAsC1F"}
|
|
@@ -68,6 +68,12 @@ export interface ProjectConfig {
|
|
|
68
68
|
name: string;
|
|
69
69
|
key: string;
|
|
70
70
|
}>;
|
|
71
|
+
/**
|
|
72
|
+
* Origins permitted to push live-preview content patches into this page, issued by the API on the
|
|
73
|
+
* preview surface only. The preview receiver validates every inbound message against this list;
|
|
74
|
+
* absent or empty means no embedder is trusted and the channel stays closed.
|
|
75
|
+
*/
|
|
76
|
+
previewEmbedderOrigins?: string[];
|
|
71
77
|
}
|
|
72
78
|
export interface DynamicExperiencesPluginOptions {
|
|
73
79
|
apiUrl?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/plugins/dynamic-experiences/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAC9D,OAAO,KAAK,EAAE,KAAK,E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+
/**
|
|
2
|
+
* @file Public entry for live-preview helpers.
|
|
3
|
+
*
|
|
4
|
+
* Separate from the root entry so the path parser and the ops applier never reach the bundle every
|
|
5
|
+
* customer page loads. Imported by the Picked dashboard, and by the SDK's own preview receiver.
|
|
6
|
+
*
|
|
7
|
+
* The wire protocol is exported from here so the embedder builds against the same declaration the
|
|
8
|
+
* receiver does — see `preview-receiver/protocol` for why that stays compatible with older SDKs.
|
|
9
|
+
* The receiver's own inbound guard is not exported: the embedder sends patches rather than
|
|
10
|
+
* receiving them, and leaving it out keeps this entry inside its `size-limit` budget.
|
|
11
|
+
*/
|
|
12
|
+
export { formatContentPath, parseContentPath } from '../utils/content-path';
|
|
13
|
+
export type { ContentPathSegment } from '../utils/content-path';
|
|
14
|
+
export { applyContentOps } from '../preview-receiver/apply-ops';
|
|
15
|
+
export type { ContentPatchOp } from '../preview-receiver/apply-ops';
|
|
16
|
+
export { PREVIEW_CONTENT_PATCH_MESSAGE, PREVIEW_INERT_SCRIPTS_MESSAGE, PREVIEW_PROTOCOL_VERSION, PREVIEW_READY_MESSAGE, PREVIEW_RESYNC_MESSAGE, } from '../preview-receiver/protocol';
|
|
17
|
+
export type { PreviewInertScriptsMessage, PreviewReadyMessage, PreviewResyncMessage, } from '../preview-receiver/protocol';
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/preview/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAC3E,YAAY,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AAC/D,YAAY,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAA;AACnE,OAAO,EACL,6BAA6B,EAC7B,6BAA6B,EAC7B,wBAAwB,EACxB,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,8BAA8B,CAAA;AACrC,YAAY,EACV,0BAA0B,EAC1B,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,8BAA8B,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Picked } from './picked';
|
|
2
|
+
/**
|
|
3
|
+
* Starts both halves of the preview channel: the outbound bridge that reports this frame's URL to
|
|
4
|
+
* the dashboard, and the inbound receiver that applies the dashboard's content patches.
|
|
5
|
+
*
|
|
6
|
+
* @param {Picked} client - The Picked client whose content index receives the patches.
|
|
7
|
+
* @returns {() => void} Teardown that stops both halves.
|
|
8
|
+
* @example
|
|
9
|
+
* const stop = initPreviewChannel(client)
|
|
10
|
+
*/
|
|
11
|
+
export declare function initPreviewChannel(client: Picked): () => void;
|
|
12
|
+
//# sourceMappingURL=preview-channel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preview-channel.d.ts","sourceRoot":"","sources":["../../src/preview-channel.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAItC;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,IAAI,CAQ7D"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A single path-addressed replacement inside a content record's `data`.
|
|
3
|
+
*
|
|
4
|
+
* `path` uses the format the Picked API already emits for content-data validation errors —
|
|
5
|
+
* `$.sections[0].data.title`. See `utils/content-path`.
|
|
6
|
+
*/
|
|
7
|
+
export interface ContentPatchOp {
|
|
8
|
+
/** Path to the value being replaced, for example `$.sections[0].data.title`. */
|
|
9
|
+
path: string;
|
|
10
|
+
/** The replacement value. */
|
|
11
|
+
value: unknown;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Applies path-addressed replacements to a content `data` blob, returning a new blob that shares
|
|
15
|
+
* every untouched branch with the original.
|
|
16
|
+
*
|
|
17
|
+
* That structural sharing is the point of per-field patching: replacing the whole blob would mint a
|
|
18
|
+
* fresh object identity for every field on every keystroke, re-rendering every memoised consumer in
|
|
19
|
+
* the host app's tree. Here only the touched spine changes identity.
|
|
20
|
+
*
|
|
21
|
+
* Ops that cannot be applied — a malformed path, the root, a prototype-polluting key, an index into
|
|
22
|
+
* a non-array, an out-of-range index — are skipped. A patch arrives from another frame, so a bad op
|
|
23
|
+
* must degrade to a no-op rather than throw inside a customer's page.
|
|
24
|
+
*
|
|
25
|
+
* @param {Record<string, unknown>} data - The content `data` blob to patch.
|
|
26
|
+
* @param {readonly ContentPatchOp[]} ops - The replacements to apply, in order.
|
|
27
|
+
* @returns {Record<string, unknown>} The patched blob, or `data` unchanged when no op applied.
|
|
28
|
+
* @example
|
|
29
|
+
* applyContentOps({ headline: 'old' }, [{ path: '$.headline', value: 'new' }])
|
|
30
|
+
*/
|
|
31
|
+
export declare function applyContentOps(data: Record<string, unknown>, ops: readonly ContentPatchOp[]): Record<string, unknown>;
|
|
32
|
+
//# sourceMappingURL=apply-ops.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apply-ops.d.ts","sourceRoot":"","sources":["../../../src/preview-receiver/apply-ops.ts"],"names":[],"mappings":"AASA;;;;;GAKG;AACH,MAAM,WAAW,cAAc;IAC7B,gFAAgF;IAChF,IAAI,EAAE,MAAM,CAAA;IACZ,6BAA6B;IAC7B,KAAK,EAAE,OAAO,CAAA;CACf;AA4DD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,eAAe,CAC7B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,GAAG,EAAE,SAAS,cAAc,EAAE,GAC7B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAUzB"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Picked } from '../picked';
|
|
2
|
+
/**
|
|
3
|
+
* Starts the live-preview receiver: announces readiness to the allowlisted embedder origins once
|
|
4
|
+
* content is registered, then applies inbound content patches to the client's content index.
|
|
5
|
+
*
|
|
6
|
+
* Wired at most once per frame, so several Picked clients on one page cannot double-apply a patch.
|
|
7
|
+
*
|
|
8
|
+
* @param {Picked} client - The Picked client whose content index receives the patches.
|
|
9
|
+
* @returns {() => void} Teardown that detaches every listener and re-arms the receiver.
|
|
10
|
+
* @example
|
|
11
|
+
* const stop = initPreviewReceiver(client)
|
|
12
|
+
* // later, e.g. in a test: stop()
|
|
13
|
+
*/
|
|
14
|
+
export declare function initPreviewReceiver(client: Picked): () => void;
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/preview-receiver/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AA4CvC;;;;;;;;;;;GAWG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,IAAI,CAyG9D"}
|