@picked/client 0.0.72-next.1 → 0.0.72-next.3
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/.tsbuildinfo +1 -1
- package/dist/{api-B9DDtylO.cjs → api-B4qxWoQN.cjs} +1 -1
- package/dist/{api-BmzHzzpu.js → api-DNvaLWw_.js} +1 -1
- package/dist/cjs/index.js +2 -2
- package/dist/cjs/plugins/dynamic-experiences/index.js +1 -1
- package/dist/cjs/server/index.js +1 -1
- package/dist/docs/explanation/content-references.md +99 -0
- package/dist/docs/explanation/how-picked-works.md +25 -3
- package/dist/docs/explanation/the-content-model.md +38 -28
- package/dist/docs/how-to/create-a-content-entry.md +48 -0
- package/dist/docs/how-to/define-a-page-layout.md +12 -5
- package/dist/docs/how-to/point-one-entry-at-another.md +61 -0
- package/dist/docs/how-to/read-a-referenced-entry.md +111 -0
- package/dist/docs/how-to/reuse-a-section.md +26 -10
- package/dist/docs/index.md +1 -1
- package/dist/docs/reference/dashboard/content/blocks.mdx +57 -0
- package/dist/docs/reference/dashboard/content/content-entries.mdx +61 -10
- package/dist/docs/reference/dashboard/content/models.mdx +108 -0
- package/dist/docs/reference/dashboard/content/pages.mdx +4 -3
- package/dist/docs/reference/dashboard/fields.mdx +1 -1
- package/dist/docs/reference/dashboard/steps.mdx +2 -2
- package/dist/docs/reference/delivery-api/experience-content.md +68 -13
- package/dist/docs/reference/glossary.md +13 -5
- package/dist/docs/reference/management-api/error-handling.md +2 -2
- package/dist/docs/reference/sdk/content.md +216 -0
- package/dist/docs/reference/sdk/plugins/dynamic-experiences.md +51 -3
- package/dist/docs/reference/sdk/ssr/serialize.md +6 -3
- package/dist/docs/reference/tools/vite-plugin.md +90 -8
- package/dist/docs/tutorials/first-api-call.md +1 -1
- package/dist/docs/tutorials/first-server-rendered-page.mdx +1 -1
- package/dist/esm/index.js +484 -429
- package/dist/esm/plugins/dynamic-experiences/index.js +4 -3
- package/dist/esm/server/index.js +43 -46
- package/dist/plugin-DkSWIASL.cjs +1 -0
- package/dist/plugin-DviILBha.js +153 -0
- package/dist/provider-Bskcgd6U.js +68 -0
- package/dist/provider-Bv5nM3So.cjs +1 -0
- package/dist/registry-BMXsAEbZ.cjs +1 -0
- package/dist/registry-DjBZ8upD.js +74 -0
- package/dist/types/data-source/api.d.ts +60 -0
- package/dist/types/data-source/api.d.ts.map +1 -0
- package/dist/types/data-source/provider.d.ts +90 -0
- package/dist/types/data-source/provider.d.ts.map +1 -0
- package/dist/types/data-source/registry.d.ts +26 -0
- package/dist/types/data-source/registry.d.ts.map +1 -0
- package/dist/types/data-source/virtual-data.d.ts +19 -0
- package/dist/types/data-source/virtual-data.d.ts.map +1 -0
- package/dist/types/entities/content/reference.d.ts +101 -0
- package/dist/types/entities/content/reference.d.ts.map +1 -0
- package/dist/types/exports.d.ts +2 -0
- package/dist/types/exports.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/picked.d.ts +65 -1
- package/dist/types/picked.d.ts.map +1 -1
- package/dist/types/plugins/dynamic-experiences/index.d.ts +1 -0
- package/dist/types/plugins/dynamic-experiences/index.d.ts.map +1 -1
- package/dist/types/plugins/dynamic-experiences/plugin.d.ts +9 -40
- package/dist/types/plugins/dynamic-experiences/plugin.d.ts.map +1 -1
- package/dist/types/plugins/dynamic-experiences/types.d.ts +25 -23
- package/dist/types/plugins/dynamic-experiences/types.d.ts.map +1 -1
- package/dist/types/server/index.d.ts +1 -1
- package/dist/types/server/index.d.ts.map +1 -1
- package/dist/types/server/serialize.d.ts +27 -34
- package/dist/types/server/serialize.d.ts.map +1 -1
- package/package.json +3 -3
- package/dist/docs/reference/dashboard/content/layouts.mdx +0 -62
- package/dist/docs/reference/dashboard/content/sections.mdx +0 -28
- package/dist/plugin-CZN0_kqv.js +0 -252
- package/dist/plugin-SFx511s_.cjs +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@picked/client",
|
|
3
|
-
"version": "0.0.72-next.
|
|
3
|
+
"version": "0.0.72-next.3",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"@withease/factories": "^1.0.5"
|
|
6
6
|
},
|
|
@@ -171,8 +171,8 @@
|
|
|
171
171
|
"size-limit": [
|
|
172
172
|
{
|
|
173
173
|
"path": "dist/esm/index.js",
|
|
174
|
-
"limit": "
|
|
175
|
-
"name": "index (incl. lazily-loaded preview channel; see AGENTS.md)"
|
|
174
|
+
"limit": "18 kB",
|
|
175
|
+
"name": "index (incl. lazily-loaded preview channel and data provider; see AGENTS.md)"
|
|
176
176
|
},
|
|
177
177
|
{
|
|
178
178
|
"path": "dist/esm/server/index.js",
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
type: reference
|
|
3
|
-
layout: docs
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
import { Screenshot } from '../../../../../components/Screenshot'
|
|
7
|
-
|
|
8
|
-
# Page & Step Layouts
|
|
9
|
-
|
|
10
|
-
Layouts are reusable JSON schemas. Page Layouts back standalone Pages; Step Layouts back individual Steps inside a Flow.
|
|
11
|
-
|
|
12
|
-
<Screenshot
|
|
13
|
-
route="/{orgSlug}/{projectId}/workspaces/{workspaceId}/models"
|
|
14
|
-
alt="The layouts list in the schema builder on the Picked dashboard"
|
|
15
|
-
/>
|
|
16
|
-
|
|
17
|
-
## A page layout and a step layout
|
|
18
|
-
|
|
19
|
-
Each layout has a fixed category, and the category decides what the layout gives its
|
|
20
|
-
shape to:
|
|
21
|
-
|
|
22
|
-
| Layout | It gives its shape to | Who renders it |
|
|
23
|
-
| --- | --- | --- |
|
|
24
|
-
| **Page Layout** | A standalone [Page](/reference/dashboard/content/pages). | The SDK renders the entry on your server. |
|
|
25
|
-
| **Step Layout** | One [Step](/reference/dashboard/steps) inside a Flow. | The Step renders the entry in the browser. |
|
|
26
|
-
|
|
27
|
-
## Field types
|
|
28
|
-
|
|
29
|
-
A layout is built from fields. Each field has a type that decides its editor and the shape of the value it stores.
|
|
30
|
-
|
|
31
|
-
| Type | Stores | Use it for |
|
|
32
|
-
| --- | --- | --- |
|
|
33
|
-
| **Single-line text** | A short string. | A title, a label, or a short headline. |
|
|
34
|
-
| **Multi-line text** | A longer plain string. | A description, or a paragraph with no format marks. |
|
|
35
|
-
| **Markdown** | A Markdown string. | Body copy with format marks. |
|
|
36
|
-
| **Slug** | A URL-safe string. | A part of a path, or an identifier. |
|
|
37
|
-
| **Number** | A numeric value. | A price, a count, or a rating. |
|
|
38
|
-
| **Boolean** | A true or false value. | A toggle or a flag. |
|
|
39
|
-
| **Date** | A date value. | A publish date or a deadline. |
|
|
40
|
-
| **Color** | A color value. | A theme accent or a swatch. |
|
|
41
|
-
| **JSON** | Any JSON value. | Structured data with no editor of its own. |
|
|
42
|
-
| **Group** | An object of fields inside the layout. | A set of related fields, held together. |
|
|
43
|
-
| **Section** | A [Section](/reference/dashboard/content/sections) schema inside the layout. | A shared schema fragment that you reuse. |
|
|
44
|
-
| **Asset** | A link to an [Asset Library](/reference/dashboard/content/asset-library) item. | An image, a video, or a document. |
|
|
45
|
-
| **HTML asset** | A link to a `.html` file in your library. | HTML that you wrote before, held inside the content. |
|
|
46
|
-
|
|
47
|
-
## Repeatable and grouped fields
|
|
48
|
-
|
|
49
|
-
You can make any field **repeatable**. It then renders as a sortable list of values,
|
|
50
|
-
and not as one value. Use it for a gallery, for a list of features, or for any
|
|
51
|
-
collection.
|
|
52
|
-
|
|
53
|
-
A **Group** field holds a set of fields under one key, and it gives a structured
|
|
54
|
-
object. Make a group repeatable to describe a list of objects, such as a list of
|
|
55
|
-
feature cards.
|
|
56
|
-
|
|
57
|
-
## Related
|
|
58
|
-
|
|
59
|
-
- [About the content model](/explanation/the-content-model) — why a schema change does not
|
|
60
|
-
migrate your data.
|
|
61
|
-
- [How to define a page layout](/how-to/define-a-page-layout)
|
|
62
|
-
- [How to reuse a section](/how-to/reuse-a-section)
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
type: reference
|
|
3
|
-
layout: docs
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
import { Screenshot } from '../../../../../components/Screenshot'
|
|
7
|
-
|
|
8
|
-
# Sections
|
|
9
|
-
|
|
10
|
-
Sections are reusable schema fragments you embed inside layouts, so common structures such as a hero or a feature list are defined once.
|
|
11
|
-
|
|
12
|
-
<Screenshot
|
|
13
|
-
route="/{orgSlug}/{projectId}/workspaces/{workspaceId}/blocks"
|
|
14
|
-
alt="The sections list in the schema builder on the Picked dashboard"
|
|
15
|
-
/>
|
|
16
|
-
|
|
17
|
-
## What a section is
|
|
18
|
-
|
|
19
|
-
A Section is a reusable schema fragment with its own **Key**. A
|
|
20
|
-
[layout](/reference/dashboard/content/layouts) gives its shape to a whole Page or Step. A Section is a
|
|
21
|
-
part that you put into one or more layouts. Define the shape one time, then reuse it
|
|
22
|
-
everywhere.
|
|
23
|
-
|
|
24
|
-
## Related
|
|
25
|
-
|
|
26
|
-
- [About the content model](/explanation/the-content-model) — why sections exist.
|
|
27
|
-
- [How to reuse a section](/how-to/reuse-a-section)
|
|
28
|
-
- [Page and step layouts](/reference/dashboard/content/layouts)
|
package/dist/plugin-CZN0_kqv.js
DELETED
|
@@ -1,252 +0,0 @@
|
|
|
1
|
-
import "./logger-DMN6TxJJ.js";
|
|
2
|
-
import { t as e } from "./api-BmzHzzpu.js";
|
|
3
|
-
import { attach as t } from "effector";
|
|
4
|
-
//#region src/plugins/dynamic-experiences/hash.ts
|
|
5
|
-
function n(e) {
|
|
6
|
-
let t = 2166136261;
|
|
7
|
-
for (let n of e) t ^= n.codePointAt(0) ?? 0, t = Math.imul(t, 16777619);
|
|
8
|
-
return t >>> 0;
|
|
9
|
-
}
|
|
10
|
-
function r(e) {
|
|
11
|
-
let t = e;
|
|
12
|
-
return t ^= t >>> 16, t = Math.imul(t, 2246822507), t ^= t >>> 13, t = Math.imul(t, 3266489909), t ^= t >>> 16, t >>> 0;
|
|
13
|
-
}
|
|
14
|
-
function i(e, t) {
|
|
15
|
-
return r(n(`${e}:${t}`)) % 100;
|
|
16
|
-
}
|
|
17
|
-
function a(e, t) {
|
|
18
|
-
return t <= 0 ? !1 : t >= 100 || e < t;
|
|
19
|
-
}
|
|
20
|
-
//#endregion
|
|
21
|
-
//#region src/plugins/dynamic-experiences/plugin.ts
|
|
22
|
-
function o(e) {
|
|
23
|
-
return typeof e == "object" && !!e && "features" in e && Array.isArray(e.features);
|
|
24
|
-
}
|
|
25
|
-
function s(e, t) {
|
|
26
|
-
if (Array.isArray(t.conditions)) for (let n of t.conditions) e.registerCondition(n);
|
|
27
|
-
}
|
|
28
|
-
function c(e, t) {
|
|
29
|
-
e.registerExperience({
|
|
30
|
-
id: t.id,
|
|
31
|
-
key: t.key,
|
|
32
|
-
name: t.name,
|
|
33
|
-
targets: t.targets,
|
|
34
|
-
nodes: t.nodes,
|
|
35
|
-
edges: t.edges,
|
|
36
|
-
condition: t.condition,
|
|
37
|
-
initializeOpen: t.initializeOpen,
|
|
38
|
-
componentName: t.componentName
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
function l(e, t) {
|
|
42
|
-
if (Array.isArray(t.fields)) for (let n of t.fields) e.registerField(n);
|
|
43
|
-
}
|
|
44
|
-
function u(e, t) {
|
|
45
|
-
if (!Array.isArray(t.steps)) return;
|
|
46
|
-
let n = new Map(t.fields.map((e) => [e.id, e.key]));
|
|
47
|
-
for (let r of t.steps) {
|
|
48
|
-
let t = [];
|
|
49
|
-
for (let e of r.fieldIds ?? []) {
|
|
50
|
-
let i = n.get(e);
|
|
51
|
-
if (i === void 0) {
|
|
52
|
-
`${r.key}${e}`;
|
|
53
|
-
continue;
|
|
54
|
-
}
|
|
55
|
-
t.push(i);
|
|
56
|
-
}
|
|
57
|
-
let i = r.layoutContentId ? e.contents.getById(r.layoutContentId) : null;
|
|
58
|
-
e.registerStep({
|
|
59
|
-
id: r.id,
|
|
60
|
-
key: r.key,
|
|
61
|
-
name: r.name,
|
|
62
|
-
fieldKeys: t,
|
|
63
|
-
layoutName: r.layoutName,
|
|
64
|
-
...r.layoutContentId !== void 0 && {
|
|
65
|
-
layoutContentId: r.layoutContentId,
|
|
66
|
-
layoutContentStore: i
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
function d(e, t) {
|
|
72
|
-
if (Array.isArray(t.experiences)) for (let n of t.experiences) c(e, n);
|
|
73
|
-
}
|
|
74
|
-
function f(e, t, n) {
|
|
75
|
-
h(e, t, n.isPreview, n.sessionId), s(e, t), l(e, t), u(e, t), d(e, t);
|
|
76
|
-
}
|
|
77
|
-
function p(e) {
|
|
78
|
-
let t = e.searchParams["preview-token"];
|
|
79
|
-
if (t && t.length > 0) return t[0];
|
|
80
|
-
}
|
|
81
|
-
function m(e) {
|
|
82
|
-
let t = /* @__PURE__ */ new Set(), n = e.searchParams.feature;
|
|
83
|
-
if (!n) return t;
|
|
84
|
-
for (let e of n) {
|
|
85
|
-
let n = e.indexOf(":");
|
|
86
|
-
n > 0 && t.add(e.substring(0, n));
|
|
87
|
-
}
|
|
88
|
-
return t;
|
|
89
|
-
}
|
|
90
|
-
function h(e, t, n, r) {
|
|
91
|
-
let i = m(e);
|
|
92
|
-
for (let a of t.features) i.has(a.id) || g(e, a, n, r);
|
|
93
|
-
}
|
|
94
|
-
function g(e, t, n, r) {
|
|
95
|
-
let o = i(r, t.id);
|
|
96
|
-
e.registerFeature(t.id, {
|
|
97
|
-
key: `v${t.version}`,
|
|
98
|
-
name: t.name,
|
|
99
|
-
enabled: t.enabled,
|
|
100
|
-
weight: t.weight,
|
|
101
|
-
storage: n ? "session" : "local",
|
|
102
|
-
decide: () => a(o, t.weight)
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
function _(e) {
|
|
106
|
-
try {
|
|
107
|
-
let t = new URL(e).hostname;
|
|
108
|
-
return t === "localhost" || t === "127.0.0.1" || t === "::1";
|
|
109
|
-
} catch {
|
|
110
|
-
return !1;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
function v(e) {
|
|
114
|
-
if (typeof e != "object" || !e || !("cause" in e)) return !1;
|
|
115
|
-
let { cause: t } = e;
|
|
116
|
-
return typeof t != "object" || !t || !("code" in t) ? !1 : t.code === "ECONNREFUSED";
|
|
117
|
-
}
|
|
118
|
-
async function y(t, n, r) {
|
|
119
|
-
let i = r?.previewToken ? `projects/${n}?preview_token=${encodeURIComponent(r.previewToken)}` : `projects/${n}`, a;
|
|
120
|
-
try {
|
|
121
|
-
a = await e(t, i, r?.headers);
|
|
122
|
-
} catch (e) {
|
|
123
|
-
return _(t) && v(e), null;
|
|
124
|
-
}
|
|
125
|
-
if (!a.ok) return `${a.status.toString()}`, null;
|
|
126
|
-
let s;
|
|
127
|
-
try {
|
|
128
|
-
s = await a.json();
|
|
129
|
-
} catch {
|
|
130
|
-
return null;
|
|
131
|
-
}
|
|
132
|
-
return o(s) ? s : null;
|
|
133
|
-
}
|
|
134
|
-
function b(e) {
|
|
135
|
-
return typeof e != "object" || !e || !("experienceId" in e) || !("content" in e) ? !1 : Array.isArray(e.content);
|
|
136
|
-
}
|
|
137
|
-
async function x(t, n, r, i) {
|
|
138
|
-
let a = i?.previewToken ? `projects/${n}/experiences/${r}/content?preview_token=${encodeURIComponent(i.previewToken)}` : `projects/${n}/experiences/${r}/content`, o;
|
|
139
|
-
try {
|
|
140
|
-
o = await e(t, a, i?.headers, i?.signal);
|
|
141
|
-
} catch (e) {
|
|
142
|
-
return _(t) && v(e) || `${r}`, null;
|
|
143
|
-
}
|
|
144
|
-
if (!o.ok) return `${r}${o.status.toString()}`, null;
|
|
145
|
-
let s;
|
|
146
|
-
try {
|
|
147
|
-
s = await o.json();
|
|
148
|
-
} catch {
|
|
149
|
-
return `${r}`, null;
|
|
150
|
-
}
|
|
151
|
-
return b(s) ? s : (`${r}`, null);
|
|
152
|
-
}
|
|
153
|
-
function S(e, t) {
|
|
154
|
-
for (let n of t.content) e.registerContent({
|
|
155
|
-
id: n.id,
|
|
156
|
-
contentModelKey: n.contentModelKey,
|
|
157
|
-
data: n.data
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
function C(e) {
|
|
161
|
-
if (typeof e != "object" || !e || !("projectConfig" in e) || !("experienceContent" in e) || !("manifestMetadata" in e)) return !1;
|
|
162
|
-
let { experienceContent: t } = e;
|
|
163
|
-
return typeof t == "function";
|
|
164
|
-
}
|
|
165
|
-
async function w() {
|
|
166
|
-
try {
|
|
167
|
-
let e = await import("virtual:picked/data");
|
|
168
|
-
return C(e) ? e : null;
|
|
169
|
-
} catch {
|
|
170
|
-
return null;
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
function T(e, t, n) {
|
|
174
|
-
return (r) => x(e, t, r.id, n ? { previewToken: n } : void 0);
|
|
175
|
-
}
|
|
176
|
-
function E(e, t) {
|
|
177
|
-
return (n) => e(n, t ? { previewToken: t } : void 0);
|
|
178
|
-
}
|
|
179
|
-
function D(e) {
|
|
180
|
-
return (t, n) => e.experienceContent(t, n);
|
|
181
|
-
}
|
|
182
|
-
function O(e, t) {
|
|
183
|
-
let n = /* @__PURE__ */ new Map();
|
|
184
|
-
return (r, i) => {
|
|
185
|
-
let a = n.get(r.id);
|
|
186
|
-
if (a) return a;
|
|
187
|
-
let o = (async () => {
|
|
188
|
-
try {
|
|
189
|
-
let n = await t(r, i);
|
|
190
|
-
return n && S(e, n), n;
|
|
191
|
-
} finally {
|
|
192
|
-
n.delete(r.id);
|
|
193
|
-
}
|
|
194
|
-
})();
|
|
195
|
-
return n.set(r.id, o), o;
|
|
196
|
-
};
|
|
197
|
-
}
|
|
198
|
-
function k(e, t) {
|
|
199
|
-
let n = new Set(t && Array.isArray(t.experiences) ? t.experiences.map((e) => e.id) : []);
|
|
200
|
-
return (t, r) => n.has(t.id) ? e(t, r) : Promise.resolve(null);
|
|
201
|
-
}
|
|
202
|
-
async function A(e) {
|
|
203
|
-
let { client: t, apiUrl: n, options: r } = e, i = p(t), a = !!i, o = r?.projectConfig ?? null, s = r?.getContent ? E(r.getContent, i) : null, c = null;
|
|
204
|
-
if (i) return o ??= await y(n, t.projectId, { previewToken: i }), s ??= T(n, t.projectId, i), {
|
|
205
|
-
config: o,
|
|
206
|
-
contentLoader: s,
|
|
207
|
-
dataSource: c,
|
|
208
|
-
isPreview: a
|
|
209
|
-
};
|
|
210
|
-
if (o && s) return {
|
|
211
|
-
config: o,
|
|
212
|
-
contentLoader: s,
|
|
213
|
-
dataSource: c,
|
|
214
|
-
isPreview: a
|
|
215
|
-
};
|
|
216
|
-
let l = await w();
|
|
217
|
-
return l ? (o ??= l.projectConfig, s ??= D(l), c = l.manifestMetadata, {
|
|
218
|
-
config: o,
|
|
219
|
-
contentLoader: s,
|
|
220
|
-
dataSource: c,
|
|
221
|
-
isPreview: a
|
|
222
|
-
}) : (o ??= await y(n, t.projectId), s ??= T(n, t.projectId), {
|
|
223
|
-
config: o,
|
|
224
|
-
contentLoader: s,
|
|
225
|
-
dataSource: c,
|
|
226
|
-
isPreview: a
|
|
227
|
-
});
|
|
228
|
-
}
|
|
229
|
-
function j(e) {
|
|
230
|
-
return {
|
|
231
|
-
name: "dynamic-experiences",
|
|
232
|
-
setup: (n) => {
|
|
233
|
-
let r = e?.apiUrl ?? n.apiUrl;
|
|
234
|
-
return { onStart: t({
|
|
235
|
-
source: n.session.store.map((e) => e.id),
|
|
236
|
-
effect: async (t) => {
|
|
237
|
-
let { config: i, contentLoader: a, dataSource: o, isPreview: s } = await A({
|
|
238
|
-
client: n,
|
|
239
|
-
apiUrl: r,
|
|
240
|
-
options: e
|
|
241
|
-
});
|
|
242
|
-
a && (n.contentLoader = O(n, k(a, i))), n.dataSource = o, i && (n.previewEmbedderOrigins = i.previewEmbedderOrigins ?? null, f(n, i, {
|
|
243
|
-
isPreview: s,
|
|
244
|
-
sessionId: t
|
|
245
|
-
}));
|
|
246
|
-
}
|
|
247
|
-
}) };
|
|
248
|
-
}
|
|
249
|
-
};
|
|
250
|
-
}
|
|
251
|
-
//#endregion
|
|
252
|
-
export { f as i, x as n, y as r, j as t };
|
package/dist/plugin-SFx511s_.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
require("./logger-CSTvAyyB.cjs");const e=require("./api-B9DDtylO.cjs");let t=require("effector");function n(e){let t=2166136261;for(let n of e)t^=n.codePointAt(0)??0,t=Math.imul(t,16777619);return t>>>0}function r(e){let t=e;return t^=t>>>16,t=Math.imul(t,2246822507),t^=t>>>13,t=Math.imul(t,3266489909),t^=t>>>16,t>>>0}function i(e,t){return r(n(`${e}:${t}`))%100}function a(e,t){return t<=0?!1:t>=100||e<t}function o(e){return typeof e==`object`&&!!e&&`features`in e&&Array.isArray(e.features)}function s(e,t){if(Array.isArray(t.conditions))for(let n of t.conditions)e.registerCondition(n)}function c(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 l(e,t){if(Array.isArray(t.fields))for(let n of t.fields)e.registerField(n)}function u(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 d(e,t){if(Array.isArray(t.experiences))for(let n of t.experiences)c(e,n)}function f(e,t,n){h(e,t,n.isPreview,n.sessionId),s(e,t),l(e,t),u(e,t),d(e,t)}function p(e){let t=e.searchParams[`preview-token`];if(t&&t.length>0)return t[0]}function m(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 h(e,t,n,r){let i=m(e);for(let a of t.features)i.has(a.id)||g(e,a,n,r)}function g(e,t,n,r){let o=i(r,t.id);e.registerFeature(t.id,{key:`v${t.version}`,name:t.name,enabled:t.enabled,weight:t.weight,storage:n?`session`:`local`,decide:()=>a(o,t.weight)})}function _(e){try{let t=new URL(e).hostname;return t===`localhost`||t===`127.0.0.1`||t===`::1`}catch{return!1}}function v(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 y(t,n,r){let i=r?.previewToken?`projects/${n}?preview_token=${encodeURIComponent(r.previewToken)}`:`projects/${n}`,a;try{a=await e.t(t,i,r?.headers)}catch(e){return _(t)&&v(e),null}if(!a.ok)return`${a.status.toString()}`,null;let s;try{s=await a.json()}catch{return null}return o(s)?s:null}function b(e){return typeof e!=`object`||!e||!(`experienceId`in e)||!(`content`in e)?!1:Array.isArray(e.content)}async function x(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 _(t)&&v(e)||`${r}`,null}if(!o.ok)return`${r}${o.status.toString()}`,null;let s;try{s=await o.json()}catch{return`${r}`,null}return b(s)?s:(`${r}`,null)}function S(e,t){for(let n of t.content)e.registerContent({id:n.id,contentModelKey:n.contentModelKey,data:n.data})}function C(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 w(){try{let e=await import(`virtual:picked/data`);return C(e)?e:null}catch{return null}}function T(e,t,n){return r=>x(e,t,r.id,n?{previewToken:n}:void 0)}function E(e,t){return n=>e(n,t?{previewToken:t}:void 0)}function D(e){return(t,n)=>e.experienceContent(t,n)}function O(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&&S(e,n),n}finally{n.delete(r.id)}})();return n.set(r.id,o),o}}function k(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 A(e){let{client:t,apiUrl:n,options:r}=e,i=p(t),a=!!i,o=r?.projectConfig??null,s=r?.getContent?E(r.getContent,i):null,c=null;if(i)return o??=await y(n,t.projectId,{previewToken:i}),s??=T(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 w();return l?(o??=l.projectConfig,s??=D(l),c=l.manifestMetadata,{config:o,contentLoader:s,dataSource:c,isPreview:a}):(o??=await y(n,t.projectId),s??=T(n,t.projectId),{config:o,contentLoader:s,dataSource:c,isPreview:a})}function j(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 A({client:n,apiUrl:r,options:e});a&&(n.contentLoader=O(n,k(a,i))),n.dataSource=o,i&&(n.previewEmbedderOrigins=i.previewEmbedderOrigins??null,f(n,i,{isPreview:s,sessionId:t}))}})}}}}Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return f}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return x}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return y}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return j}});
|