@picked/vite-plugin-picked 0.0.111-next.3 → 0.0.111-next.4
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/cjs/index.js +6 -6
- package/dist/esm/index.js +176 -172
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +6 -6
package/dist/esm/index.js
CHANGED
|
@@ -2,22 +2,22 @@ import { existsSync as e } from "node:fs";
|
|
|
2
2
|
import { join as t, resolve as n } from "node:path";
|
|
3
3
|
import { createClientHeaders as r, fetchExperienceContent as i, fetchProject as a } from "@picked/delivery-api-client";
|
|
4
4
|
import { generate as o } from "@picked/typegen";
|
|
5
|
-
import { SNAPSHOT_FILENAME as s, detectHostEnvironment as c,
|
|
6
|
-
import { appendFile as
|
|
7
|
-
import { createSpanId as
|
|
5
|
+
import { SNAPSHOT_FILENAME as s, detectHostEnvironment as c, hasProject as l, isTelemetryEnabled as u, isTelemetryForcedOffByEnvironment as d, loadPickedConfig as f, loadResolvedPickedConfig as p, requireSnapshot as m, resolveSnapshotPath as h } from "@picked/config";
|
|
6
|
+
import { appendFile as g, mkdir as _, readFile as v, writeFile as y } from "node:fs/promises";
|
|
7
|
+
import { createSpanId as b, createTelemetryEmitter as x, createTraceId as S, toUnixNano as C } from "@picked/telemetry";
|
|
8
8
|
//#region \0@oxc-project+runtime@0.154.0/helpers/esm/taggedTemplateLiteral.js
|
|
9
|
-
function
|
|
9
|
+
function w(e, t) {
|
|
10
10
|
return t ||= e.slice(0), Object.freeze(Object.defineProperties(e, { raw: { value: Object.freeze(t) } }));
|
|
11
11
|
}
|
|
12
12
|
//#endregion
|
|
13
13
|
//#region src/launcher.ts
|
|
14
|
-
var
|
|
15
|
-
function
|
|
14
|
+
var ee, te = ["true", "false"], ne = "false";
|
|
15
|
+
function re(e) {
|
|
16
16
|
let t = e.variants;
|
|
17
|
-
return !t || t.length === 0 ?
|
|
17
|
+
return !t || t.length === 0 ? te : t.map((e) => String(e.value));
|
|
18
18
|
}
|
|
19
|
-
function
|
|
20
|
-
let t =
|
|
19
|
+
function ie(e) {
|
|
20
|
+
let t = re(e), n = Math.max(0, t.findIndex((e) => e !== ne));
|
|
21
21
|
return t.map((e, t) => `<option value="${D(e)}"${t === n ? " selected" : ""}>${E(e)}</option>`).join("");
|
|
22
22
|
}
|
|
23
23
|
function T(e) {
|
|
@@ -29,10 +29,10 @@ function T(e) {
|
|
|
29
29
|
<span class="feature-id">${E(e.id)}</span>
|
|
30
30
|
</label>
|
|
31
31
|
<select data-value-for="${D(e.id)}">
|
|
32
|
-
${
|
|
32
|
+
${ie(e)}
|
|
33
33
|
</select>
|
|
34
34
|
</div>`).join("") : "<p class=\"text no-features\">No features configured for this project.</p>";
|
|
35
|
-
return String.raw(
|
|
35
|
+
return String.raw(ee ||= w([
|
|
36
36
|
"<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n <meta charset=\"UTF-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n <meta name=\"robots\" content=\"noindex, nofollow\">\n <title>Picked</title>\n <style>\n main {\n position: fixed;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n display: grid;\n align-items: center;\n justify-content: center;\n font-family: monospace;\n color: #4A4A4A\n }\n\n .wrap {\n padding-left: 1.5rem;\n padding-right: 1.5rem;\n max-width: 480px;\n width: 100%;\n }\n\n .title {\n font-size: 1.125rem;\n font-weight: 700;\n margin-bottom: 0;\n }\n\n .text {\n margin-top: .5rem;\n font-size: .875rem\n }\n\n .text a {\n color: #4A4A4A;\n text-decoration: none;\n }\n\n .text a:hover {\n cursor: pointer;\n text-decoration: underline\n }\n\n .preview-form {\n margin-top: 2rem;\n display: flex;\n flex-direction: column;\n gap: 0.5rem;\n }\n\n .preview-input {\n padding: 0.5rem;\n border: 1px solid #4A4A4A;\n border-radius: 0;\n font-family: monospace;\n }\n\n .preview-button {\n padding: 0.5rem;\n background: #4A4A4A;\n color: white;\n border: none;\n border-radius: 0;\n cursor: pointer;\n font-family: monospace;\n }\n\n .preview-button:hover {\n opacity: 0.9;\n }\n\n .buttons {\n display: grid;\n gap: 0.5em;\n grid-template-columns: 1fr 1fr;\n }\n\n #copy-status {\n font-size: 1em;\n text-align: right;\n margin-top: 0.5em;\n }\n\n .features-section {\n margin-top: 1.5rem;\n }\n\n .features-label {\n font-weight: 700;\n font-size: .875rem;\n margin-bottom: 0.5rem;\n }\n\n .feature-row {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 0.5rem;\n padding: 0.25rem 0;\n }\n\n .feature-row label {\n display: flex;\n align-items: center;\n gap: 0.5rem;\n cursor: pointer;\n min-width: 0;\n flex: 1;\n }\n\n .feature-name {\n font-size: .875rem;\n }\n\n .feature-id {\n font-size: .75rem;\n color: #888;\n }\n\n .feature-row select {\n font-family: monospace;\n font-size: .75rem;\n padding: 0.125rem 0.25rem;\n border: 1px solid #4A4A4A;\n border-radius: 0;\n background: white;\n flex-shrink: 0;\n }\n\n .no-features {\n color: #888;\n font-style: italic;\n }\n\n .url-history {\n margin-top: 0.5rem;\n font-size: .75rem;\n }\n\n .url-history-item {\n display: flex;\n align-items: center;\n gap: 0.25rem;\n padding: 0.125rem 0;\n }\n\n .url-history-item button {\n background: none;\n border: none;\n cursor: pointer;\n font-family: monospace;\n font-size: .75rem;\n color: #888;\n padding: 0;\n }\n\n .url-history-item button.url-link {\n color: #4A4A4A;\n text-decoration: none;\n text-align: left;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n flex: 1;\n min-width: 0;\n }\n\n .url-history-item button.url-link:hover {\n text-decoration: underline;\n }\n\n .url-history-item button.url-delete:hover {\n color: #b71c1c;\n }\n\n @media (min-width: 640px) {\n .title {\n font-size: 1.25rem\n }\n\n .text {\n font-size: 1rem\n }\n }\n </style>\n</head>\n<body>\n\n<main>\n <div class=\"wrap\">\n <p class=\"title\">Picked</p>\n <p class=\"text\">\n Learn more at\n <a href=\"https://picked.app\">\n https://picked.app\n </a>\n </p>\n <div class=\"preview-form\">\n <input type=\"text\" id=\"url-input\" pattern=\"^(https?://)?.+\" placeholder=\"Enter preview URL\" required\n class=\"preview-input\">\n <div id=\"url-history\" class=\"url-history\"></div>\n <div class=\"features-section\">\n <p class=\"features-label\">Features</p>\n ",
|
|
37
37
|
"\n </div>\n <div class=\"buttons\">\n <button type=\"button\" class=\"preview-button\" id=\"copy-btn\">Copy</button>\n <button type=\"button\" class=\"preview-button\" id=\"preview-btn\">Preview</button>\n </div>\n <p class=\"text\" id=\"copy-status\" aria-live=\"polite\" style=\"visibility:hidden;\">\n \n </p>\n </div>\n </div>\n\n <script>\n var FEATURES = ",
|
|
38
38
|
";\n var STORAGE_KEY_URL = 'picked-launcher-url';\n var STORAGE_KEY_HISTORY = 'picked-launcher-history';\n var STORAGE_KEY_SELECTIONS = 'picked-launcher-selections';\n\n function getUrlInput() {\n return document.getElementById('url-input');\n }\n\n // URL history\n function getHistory() {\n try {\n var raw = localStorage.getItem(STORAGE_KEY_HISTORY);\n if (!raw) return [];\n var parsed = JSON.parse(raw);\n return Array.isArray(parsed) ? parsed : [];\n } catch (e) {\n return [];\n }\n }\n\n function saveHistory(history) {\n localStorage.setItem(STORAGE_KEY_HISTORY, JSON.stringify(history));\n }\n\n function addToHistory(url) {\n var history = getHistory().filter(function(h) { return h !== url; });\n history.unshift(url);\n if (history.length > 10) history = history.slice(0, 10);\n saveHistory(history);\n renderHistory();\n }\n\n function removeFromHistory(url) {\n var history = getHistory().filter(function(h) { return h !== url; });\n saveHistory(history);\n renderHistory();\n }\n\n function renderHistory() {\n var container = document.getElementById('url-history');\n if (!container) return;\n var history = getHistory();\n if (history.length === 0) {\n container.innerHTML = '';\n return;\n }\n container.innerHTML = history.map(function(url) {\n return '<div class=\"url-history-item\">' +\n '<button type=\"button\" class=\"url-link\" data-history-url=\"' + escapeAttr(url) + '\">' + escapeHtml(url) + '</button>' +\n '<button type=\"button\" class=\"url-delete\" data-history-delete=\"' + escapeAttr(url) + '\">x</button>' +\n '</div>';\n }).join('');\n }\n\n // Feature selection persistence\n function getSelections() {\n try {\n var raw = localStorage.getItem(STORAGE_KEY_SELECTIONS);\n if (!raw) return {};\n var parsed = JSON.parse(raw);\n return typeof parsed === 'object' && parsed !== null ? parsed : {};\n } catch (e) {\n return {};\n }\n }\n\n function saveSelections() {\n var selections = {};\n FEATURES.forEach(function(f) {\n var checkbox = document.querySelector('input[data-feature-id=\"' + f.id + '\"]');\n var select = document.querySelector('select[data-value-for=\"' + f.id + '\"]');\n if (checkbox && select) {\n selections[f.id] = { checked: checkbox.checked, value: select.value };\n }\n });\n localStorage.setItem(STORAGE_KEY_SELECTIONS, JSON.stringify(selections));\n }\n\n function restoreSelections() {\n var selections = getSelections();\n FEATURES.forEach(function(f) {\n var saved = selections[f.id];\n if (!saved) return;\n var checkbox = document.querySelector('input[data-feature-id=\"' + f.id + '\"]');\n var select = document.querySelector('select[data-value-for=\"' + f.id + '\"]');\n if (checkbox) checkbox.checked = saved.checked;\n if (select) select.value = saved.value;\n });\n }\n\n function escapeHtml(str) {\n var div = document.createElement('div');\n div.textContent = str;\n return div.innerHTML;\n }\n\n function escapeAttr(str) {\n return str.replace(/&/g, '&').replace(/\"/g, '"').replace(/</g, '<').replace(/>/g, '>');\n }\n\n function buildTargetUrl(inputValue) {\n var value = inputValue;\n if (!value.startsWith('http://') && !value.startsWith('https://')) {\n value = 'https://' + value;\n }\n var hostname = window.location.hostname;\n var subdomain = hostname.split('.').length > 2 ? hostname.split('.')[0] : '';\n var target = value;\n var sep = target.includes('?') ? '&' : '?';\n if (subdomain) {\n target = target + sep + 'cvly_env=' + encodeURIComponent(subdomain);\n sep = '&';\n }\n FEATURES.forEach(function(f) {\n var checkbox = document.querySelector('input[data-feature-id=\"' + f.id + '\"]');\n var select = document.querySelector('select[data-value-for=\"' + f.id + '\"]');\n if (checkbox && checkbox.checked && select) {\n target = target + sep + 'picked-feature=' + encodeURIComponent(f.id + ':' + select.value);\n sep = '&';\n }\n });\n return target;\n }\n\n function showCopyStatus(message, success) {\n var el = document.getElementById('copy-status');\n if (!el) return;\n el.textContent = message;\n el.style.visibility = 'visible';\n el.style.color = success ? '#2e7d32' : '#b71c1c';\n setTimeout(function() {\n el.style.visibility = 'hidden';\n }, 2000);\n }\n\n // Init\n window.addEventListener('load', function() {\n var input = getUrlInput();\n var savedUrl = localStorage.getItem(STORAGE_KEY_URL);\n if (savedUrl && input) {\n input.value = savedUrl;\n }\n renderHistory();\n restoreSelections();\n });\n\n // Delegate click events\n document.addEventListener('click', function(e) {\n var target = e.target;\n\n // History URL click\n var historyUrl = target.getAttribute('data-history-url');\n if (historyUrl) {\n var input = getUrlInput();\n if (input) input.value = historyUrl;\n return;\n }\n\n // History delete click\n var deleteUrl = target.getAttribute('data-history-delete');\n if (deleteUrl) {\n removeFromHistory(deleteUrl);\n return;\n }\n });\n\n // Feature change persistence\n document.addEventListener('change', function(e) {\n var target = e.target;\n if (target.getAttribute('data-feature-id') || target.getAttribute('data-value-for')) {\n saveSelections();\n }\n });\n\n // Copy button\n document.getElementById('copy-btn').addEventListener('click', function() {\n var input = getUrlInput();\n if (!input || !input.value) return;\n localStorage.setItem(STORAGE_KEY_URL, input.value);\n addToHistory(input.value);\n saveSelections();\n var target = buildTargetUrl(input.value);\n navigator.clipboard.writeText(target).then(function() {\n showCopyStatus('Preview URL copied to clipboard', true);\n });\n });\n\n // Preview button\n document.getElementById('preview-btn').addEventListener('click', function() {\n var input = getUrlInput();\n if (!input || !input.value) return;\n localStorage.setItem(STORAGE_KEY_URL, input.value);\n addToHistory(input.value);\n saveSelections();\n var target = buildTargetUrl(input.value);\n window.location.href = target;\n });\n <\/script>\n</main>\n</body>\n</html>"
|
|
@@ -50,21 +50,21 @@ function D(e) {
|
|
|
50
50
|
}
|
|
51
51
|
//#endregion
|
|
52
52
|
//#region src/log.ts
|
|
53
|
-
var O = "picked",
|
|
54
|
-
function
|
|
53
|
+
var O = "picked", ae = "\x1B[0m";
|
|
54
|
+
function oe() {
|
|
55
55
|
let e = process.env.NO_COLOR;
|
|
56
56
|
return e === "1" || e === "true";
|
|
57
57
|
}
|
|
58
58
|
function k(e) {
|
|
59
|
-
return (t) =>
|
|
59
|
+
return (t) => oe() ? t : `${e}${t}${ae}`;
|
|
60
60
|
}
|
|
61
|
-
var
|
|
61
|
+
var se = [
|
|
62
62
|
"debug",
|
|
63
63
|
"info",
|
|
64
64
|
"warn",
|
|
65
65
|
"error",
|
|
66
66
|
"silent"
|
|
67
|
-
],
|
|
67
|
+
], A = {
|
|
68
68
|
debug: {
|
|
69
69
|
color: k("\x1B[2m"),
|
|
70
70
|
log: console.debug,
|
|
@@ -90,49 +90,49 @@ var A = [
|
|
|
90
90
|
enabled: !1
|
|
91
91
|
}
|
|
92
92
|
};
|
|
93
|
-
function
|
|
93
|
+
function ce(e, t) {
|
|
94
94
|
return `${(/* @__PURE__ */ new Date()).toLocaleTimeString()} [${t ? `${O}:${t}` : O}] ${e}`;
|
|
95
95
|
}
|
|
96
|
-
function
|
|
96
|
+
function j(e, t, n, r) {
|
|
97
97
|
if (!e.enabled) return;
|
|
98
|
-
let i =
|
|
98
|
+
let i = ce(t, r);
|
|
99
99
|
e.log(e.color ? e.color(i) : i), n !== void 0 && e.log(n);
|
|
100
100
|
}
|
|
101
|
-
function
|
|
102
|
-
let t =
|
|
101
|
+
function M(e) {
|
|
102
|
+
let t = A[e], n = /* @__PURE__ */ new Set();
|
|
103
103
|
return Object.assign((e, n, r) => {
|
|
104
|
-
|
|
104
|
+
j(t, e, n, r);
|
|
105
105
|
}, { once(e, r, i) {
|
|
106
|
-
t.enabled && !n.has(e) && (n.add(e),
|
|
106
|
+
t.enabled && !n.has(e) && (n.add(e), j(t, e, r, i));
|
|
107
107
|
} });
|
|
108
108
|
}
|
|
109
|
-
function
|
|
110
|
-
let t =
|
|
111
|
-
if (t === -1)
|
|
112
|
-
else for (let [e, n] of
|
|
109
|
+
function le(e) {
|
|
110
|
+
let t = se.indexOf(e);
|
|
111
|
+
if (t === -1) j(A.error, `invalid log level: ${e}`);
|
|
112
|
+
else for (let [e, n] of se.entries()) A[n].enabled = e >= t;
|
|
113
113
|
}
|
|
114
|
-
var
|
|
115
|
-
function
|
|
114
|
+
var N = k("\x1B[34m"), P = k("\x1B[36m");
|
|
115
|
+
function ue() {
|
|
116
116
|
let e = [
|
|
117
|
-
` ${
|
|
118
|
-
`${
|
|
119
|
-
` ${
|
|
120
|
-
`${
|
|
117
|
+
` ${N("_")} ${P("_")} _ _ _`,
|
|
118
|
+
`${N("(_)")} ${P("(_)")} _ __(_)__| |_____ __| |`,
|
|
119
|
+
` ${N("_")} ${N("_")} | '_ \\ / _| / / -_) _\` |`,
|
|
120
|
+
`${N("(_)")} ${N("(_)")} | .__/_\\__|_\\_\\___\\__,_|`,
|
|
121
121
|
" |_|\n "
|
|
122
122
|
];
|
|
123
123
|
console.log(e.join("\n"));
|
|
124
124
|
}
|
|
125
|
-
var
|
|
126
|
-
banner:
|
|
127
|
-
debug:
|
|
128
|
-
info:
|
|
129
|
-
warn:
|
|
130
|
-
error:
|
|
131
|
-
setLevel:
|
|
125
|
+
var F = {
|
|
126
|
+
banner: ue,
|
|
127
|
+
debug: M("debug"),
|
|
128
|
+
info: M("info"),
|
|
129
|
+
warn: M("warn"),
|
|
130
|
+
error: M("error"),
|
|
131
|
+
setLevel: le
|
|
132
132
|
};
|
|
133
133
|
//#endregion
|
|
134
134
|
//#region src/middleware.ts
|
|
135
|
-
function
|
|
135
|
+
function de(e) {
|
|
136
136
|
return (t, n, r) => {
|
|
137
137
|
if (t.method !== "GET") {
|
|
138
138
|
r();
|
|
@@ -149,28 +149,28 @@ function le(e) {
|
|
|
149
149
|
}
|
|
150
150
|
//#endregion
|
|
151
151
|
//#region src/gitignore.ts
|
|
152
|
-
var
|
|
153
|
-
async function
|
|
152
|
+
var I = ".picked/";
|
|
153
|
+
async function fe(n, r) {
|
|
154
154
|
if (r) return;
|
|
155
155
|
let i = t(n, ".gitignore");
|
|
156
156
|
if (!e(i)) {
|
|
157
|
-
await
|
|
157
|
+
await y(i, `${I}
|
|
158
158
|
`);
|
|
159
159
|
return;
|
|
160
160
|
}
|
|
161
|
-
let a = await
|
|
162
|
-
if (
|
|
163
|
-
let o = `${a.length > 0 && !a.endsWith("\n") ? "\n" : ""}${
|
|
161
|
+
let a = await v(i, "utf8");
|
|
162
|
+
if (pe(a)) return;
|
|
163
|
+
let o = `${a.length > 0 && !a.endsWith("\n") ? "\n" : ""}${I}
|
|
164
164
|
`;
|
|
165
|
-
await
|
|
165
|
+
await g(i, o);
|
|
166
166
|
}
|
|
167
|
-
function
|
|
168
|
-
return e.split(/\r?\n/).map((e) => e.trim()).some((e) => e ===
|
|
167
|
+
function pe(e) {
|
|
168
|
+
return e.split(/\r?\n/).map((e) => e.trim()).some((e) => e === I || e === ".picked");
|
|
169
169
|
}
|
|
170
170
|
//#endregion
|
|
171
171
|
//#region src/retry.ts
|
|
172
|
-
var
|
|
173
|
-
function
|
|
172
|
+
var L = 6, me = 5e3;
|
|
173
|
+
function R(e) {
|
|
174
174
|
let t;
|
|
175
175
|
try {
|
|
176
176
|
t = new URL(e).hostname;
|
|
@@ -179,7 +179,7 @@ function pe(e) {
|
|
|
179
179
|
}
|
|
180
180
|
return t === "localhost" || t === "127.0.0.1" || t === "::1" || t === "[::1]" ? !0 : t === "api.picked.app" ? !1 : t.endsWith(".picked.app") || t.endsWith(".picked-dev.app");
|
|
181
181
|
}
|
|
182
|
-
function
|
|
182
|
+
function he(e) {
|
|
183
183
|
return new Promise((t) => {
|
|
184
184
|
setTimeout(t, e);
|
|
185
185
|
});
|
|
@@ -192,9 +192,9 @@ async function z(e, t) {
|
|
|
192
192
|
r = e;
|
|
193
193
|
}
|
|
194
194
|
if (n !== null) return n;
|
|
195
|
-
for (let i = 1; i <=
|
|
196
|
-
let a =
|
|
197
|
-
t(i,
|
|
195
|
+
for (let i = 1; i <= L; i++) {
|
|
196
|
+
let a = me * 2 ** (i - 1);
|
|
197
|
+
t(i, L, a), await he(a), r = null;
|
|
198
198
|
try {
|
|
199
199
|
n = await e();
|
|
200
200
|
} catch (e) {
|
|
@@ -210,7 +210,7 @@ async function z(e, t) {
|
|
|
210
210
|
function B(e) {
|
|
211
211
|
return Array.isArray(e) ? e : [];
|
|
212
212
|
}
|
|
213
|
-
function
|
|
213
|
+
function ge(e) {
|
|
214
214
|
let t = e.variants, n = (t ?? []).reduce((e, t) => e + t.weight, 0);
|
|
215
215
|
return !t || t.length === 0 || n === 0 ? `${e.weight.toString()}%` : t.map((e) => {
|
|
216
216
|
let t = Math.round(100 * e.weight / n);
|
|
@@ -229,19 +229,19 @@ function H(e) {
|
|
|
229
229
|
experiencesDir: t(n, "experiences")
|
|
230
230
|
};
|
|
231
231
|
}
|
|
232
|
-
async function
|
|
232
|
+
async function _e(t) {
|
|
233
233
|
if (!e(t)) return null;
|
|
234
234
|
try {
|
|
235
|
-
let e = await
|
|
236
|
-
return
|
|
235
|
+
let e = await v(t, "utf8"), n = JSON.parse(e);
|
|
236
|
+
return ve(n) ? n : null;
|
|
237
237
|
} catch {
|
|
238
238
|
return null;
|
|
239
239
|
}
|
|
240
240
|
}
|
|
241
|
-
function
|
|
241
|
+
function ve(e) {
|
|
242
242
|
return !(typeof e != "object" || !e || !("version" in e) || typeof e.version != "number" || !("projectVersionId" in e) || typeof e.projectVersionId != "string" || !("workspaceId" in e) || typeof e.workspaceId != "string" || !("experiences" in e) || !Array.isArray(e.experiences));
|
|
243
243
|
}
|
|
244
|
-
function
|
|
244
|
+
function ye(e) {
|
|
245
245
|
let t = /* @__PURE__ */ new Set();
|
|
246
246
|
for (let n of B(e.steps)) n.layoutContentId && t.add(n.id);
|
|
247
247
|
if (t.size === 0) return [];
|
|
@@ -249,10 +249,10 @@ function ve(e) {
|
|
|
249
249
|
for (let r of B(e.experiences)) B(r.nodes).some((e) => e.type === "step" && t.has(e.stepId)) && n.push(r.id);
|
|
250
250
|
return n;
|
|
251
251
|
}
|
|
252
|
-
async function
|
|
253
|
-
let { apiUrl: r, projectId: i, projectRoot: a, headers: o, previewToken: s, reuseWhenUnchanged: c = !0 } = n, l = H(a), u = await
|
|
254
|
-
if (await
|
|
255
|
-
let t = await
|
|
252
|
+
async function be(n) {
|
|
253
|
+
let { apiUrl: r, projectId: i, projectRoot: a, headers: o, previewToken: s, reuseWhenUnchanged: c = !0 } = n, l = H(a), u = await xe(r, i, o, s), d = ye(u);
|
|
254
|
+
if (await _(l.experiencesDir, { recursive: !0 }), await y(l.projectConfigPath, JSON.stringify(u, null, 2)), c) {
|
|
255
|
+
let t = await _e(l.manifestPath);
|
|
256
256
|
if (t?.version === V && t.projectVersionId === u.versionId && t.workspaceId === u.workspaceId) {
|
|
257
257
|
let n = U(l, d);
|
|
258
258
|
if (Object.values(n).every((t) => e(t))) return {
|
|
@@ -260,13 +260,13 @@ async function ye(n) {
|
|
|
260
260
|
manifest: t,
|
|
261
261
|
experienceContentPaths: n
|
|
262
262
|
};
|
|
263
|
-
|
|
263
|
+
F.info("a manifest-referenced content file is missing; refetching every experience");
|
|
264
264
|
}
|
|
265
265
|
}
|
|
266
266
|
let f = (/* @__PURE__ */ new Date()).toISOString(), p = [];
|
|
267
267
|
for (let e of d) {
|
|
268
|
-
let n = await
|
|
269
|
-
await
|
|
268
|
+
let n = await Se(r, i, e, o, s), a = t(l.experiencesDir, `${e}.json`);
|
|
269
|
+
await y(a, JSON.stringify(n, null, 2)), p.push({
|
|
270
270
|
id: e,
|
|
271
271
|
fetchedAt: f
|
|
272
272
|
});
|
|
@@ -279,7 +279,7 @@ async function ye(n) {
|
|
|
279
279
|
projectId: u.id,
|
|
280
280
|
experiences: p
|
|
281
281
|
};
|
|
282
|
-
return await
|
|
282
|
+
return await y(l.manifestPath, JSON.stringify(m, null, 2)), {
|
|
283
283
|
config: u,
|
|
284
284
|
manifest: m,
|
|
285
285
|
experienceContentPaths: U(l, d)
|
|
@@ -290,14 +290,14 @@ function U(e, n) {
|
|
|
290
290
|
for (let i of n) r[i] = t(e.experiencesDir, `${i}.json`);
|
|
291
291
|
return r;
|
|
292
292
|
}
|
|
293
|
-
async function
|
|
293
|
+
async function xe(e, t, n, r) {
|
|
294
294
|
let i = () => a(e, t, {
|
|
295
295
|
headers: n,
|
|
296
296
|
previewToken: r
|
|
297
297
|
}), o;
|
|
298
298
|
try {
|
|
299
|
-
o =
|
|
300
|
-
|
|
299
|
+
o = R(e) ? await z(i, (e, t, n) => {
|
|
300
|
+
F.info(`project config not ready, retrying in ${(n / 1e3).toString()}s (${e.toString()}/${t.toString()})`);
|
|
301
301
|
}) : await i();
|
|
302
302
|
} catch (n) {
|
|
303
303
|
throw Error(`[picked] Build-time fetch of project config failed for "${t}" at ${e}: ${W(n)}`);
|
|
@@ -305,7 +305,7 @@ async function be(e, t, n, r) {
|
|
|
305
305
|
if (!o) throw Error(`[picked] Build-time fetch of project config returned no usable response for "${t}" at ${e}. Confirm the API is reachable and the project ID is correct.`);
|
|
306
306
|
return o;
|
|
307
307
|
}
|
|
308
|
-
async function
|
|
308
|
+
async function Se(e, t, n, r, a) {
|
|
309
309
|
let o;
|
|
310
310
|
try {
|
|
311
311
|
o = await i(e, t, n, {
|
|
@@ -329,12 +329,12 @@ function W(e) {
|
|
|
329
329
|
}
|
|
330
330
|
//#endregion
|
|
331
331
|
//#region src/telemetry.ts
|
|
332
|
-
var
|
|
333
|
-
function
|
|
334
|
-
let t =
|
|
332
|
+
var Ce = /* @__PURE__ */ new Set(["resolveId", "load"]);
|
|
333
|
+
function we(e = S()) {
|
|
334
|
+
let t = b(), n = Date.now(), r = [], i = /* @__PURE__ */ new Map();
|
|
335
335
|
return {
|
|
336
336
|
record: (n, a) => {
|
|
337
|
-
if (
|
|
337
|
+
if (Ce.has(n)) {
|
|
338
338
|
let e = i.get(n) ?? {
|
|
339
339
|
calls: 0,
|
|
340
340
|
totalMs: 0
|
|
@@ -349,10 +349,10 @@ function Ce(e = x()) {
|
|
|
349
349
|
r.push({
|
|
350
350
|
name: `picked.vite.${n}`,
|
|
351
351
|
traceId: e,
|
|
352
|
-
spanId:
|
|
352
|
+
spanId: b(),
|
|
353
353
|
parentSpanId: t,
|
|
354
|
-
startTimeUnixNano:
|
|
355
|
-
endTimeUnixNano:
|
|
354
|
+
startTimeUnixNano: C(o - a),
|
|
355
|
+
endTimeUnixNano: C(o),
|
|
356
356
|
attributes: { "picked.vite.hook": n },
|
|
357
357
|
status: "ok"
|
|
358
358
|
});
|
|
@@ -365,8 +365,8 @@ function Ce(e = x()) {
|
|
|
365
365
|
name: "picked.vite.build",
|
|
366
366
|
traceId: e,
|
|
367
367
|
spanId: t,
|
|
368
|
-
startTimeUnixNano:
|
|
369
|
-
endTimeUnixNano:
|
|
368
|
+
startTimeUnixNano: C(n),
|
|
369
|
+
endTimeUnixNano: C(Date.now()),
|
|
370
370
|
attributes: {
|
|
371
371
|
"picked.env.provider": s.provider,
|
|
372
372
|
"picked.env.ci": s.ci,
|
|
@@ -376,7 +376,7 @@ function Ce(e = x()) {
|
|
|
376
376
|
status: "ok"
|
|
377
377
|
});
|
|
378
378
|
try {
|
|
379
|
-
let e =
|
|
379
|
+
let e = x({
|
|
380
380
|
resource: { "service.name": "picked-vite-plugin" },
|
|
381
381
|
headers: { "Picked-Telemetry": "vite-plugin" },
|
|
382
382
|
maxBatchSize: r.length
|
|
@@ -387,7 +387,7 @@ function Ce(e = x()) {
|
|
|
387
387
|
}
|
|
388
388
|
};
|
|
389
389
|
}
|
|
390
|
-
function
|
|
390
|
+
function Te(e) {
|
|
391
391
|
return typeof e == "object" && !!e && "then" in e;
|
|
392
392
|
}
|
|
393
393
|
function G(e, t, n) {
|
|
@@ -395,25 +395,25 @@ function G(e, t, n) {
|
|
|
395
395
|
let i = performance.now(), a = () => {
|
|
396
396
|
n.record(e, performance.now() - i);
|
|
397
397
|
}, o = t.apply(this, r);
|
|
398
|
-
return
|
|
398
|
+
return Te(o) ? Promise.resolve(o).then(a, a) : a(), o;
|
|
399
399
|
};
|
|
400
400
|
}
|
|
401
401
|
function K(e) {
|
|
402
402
|
return typeof e == "function";
|
|
403
403
|
}
|
|
404
|
-
function
|
|
404
|
+
function Ee(e, t) {
|
|
405
405
|
if (!e) return t;
|
|
406
406
|
for (let [n, r] of Object.entries(t)) n !== "name" && (K(r) ? Reflect.set(t, n, G(n, r, e)) : typeof r == "object" && r && "handler" in r && K(r.handler) && Reflect.set(r, "handler", G(n, r.handler, e)));
|
|
407
407
|
return t;
|
|
408
408
|
}
|
|
409
409
|
//#endregion
|
|
410
410
|
//#region src/virtual-module/api.ts
|
|
411
|
-
function
|
|
411
|
+
function De() {
|
|
412
412
|
return "export const manifestMetadata = {\n mode: 'api',\n fetchedAt: null,\n projectVersionId: null,\n workspaceId: null,\n}\n";
|
|
413
413
|
}
|
|
414
414
|
//#endregion
|
|
415
415
|
//#region src/virtual-module/build.ts
|
|
416
|
-
function
|
|
416
|
+
function Oe(e) {
|
|
417
417
|
let { projectConfigPath: t, experienceContentPaths: n, manifestMetadata: r } = e, i = (e) => JSON.stringify(e), a = Object.entries(n).map(([e, t]) => ` ${JSON.stringify(e)}: () => import(${i(t)}).then((m) => m.default ?? m),`).join("\n");
|
|
418
418
|
return `import { registerPickedBundle } from '@picked/client/plugins/dynamic-experiences'
|
|
419
419
|
import projectConfigJson from ${i(t)}
|
|
@@ -443,7 +443,7 @@ registerPickedBundle({ projectConfig, experienceContent, manifestMetadata })
|
|
|
443
443
|
}
|
|
444
444
|
//#endregion
|
|
445
445
|
//#region src/virtual-module/dev.ts
|
|
446
|
-
function
|
|
446
|
+
function ke(e) {
|
|
447
447
|
let { apiUrl: t, projectId: n, projectConfig: r, previewToken: i } = e, a = r ? "import { fetchExperienceContent, registerPickedBundle } from '@picked/client/plugins/dynamic-experiences'" : "import { fetchProject, fetchExperienceContent } from '@picked/client/plugins/dynamic-experiences'", o = r ? `export const projectConfig = ${JSON.stringify(r)}` : "export const projectConfig = await fetchProject(apiUrl, projectId, { previewToken: previewToken ?? undefined })", s = r ? "\nregisterPickedBundle({ projectConfig, experienceContent, manifestMetadata })\n" : "";
|
|
448
448
|
return `${a}
|
|
449
449
|
|
|
@@ -470,7 +470,7 @@ ${s}`;
|
|
|
470
470
|
//#endregion
|
|
471
471
|
//#region src/virtual-module/snapshot.ts
|
|
472
472
|
var q = "virtual:picked/data/experience/";
|
|
473
|
-
function
|
|
473
|
+
function Ae(e) {
|
|
474
474
|
let t = Object.keys(e.experiences).map((e, t) => {
|
|
475
475
|
let n = JSON.stringify(q + t.toString());
|
|
476
476
|
return ` ${JSON.stringify(e)}: () => import(${n}).then((m) => m.default),`;
|
|
@@ -500,16 +500,16 @@ export const manifestMetadata = ${JSON.stringify(n)}
|
|
|
500
500
|
registerPickedBundle({ projectConfig, experienceContent, manifestMetadata })
|
|
501
501
|
`;
|
|
502
502
|
}
|
|
503
|
-
function
|
|
503
|
+
function je(e, t) {
|
|
504
504
|
let n = /^\d+$/.test(t) ? Object.keys(e.experiences)[Number(t)] : void 0, r = n === void 0 ? null : e.experiences[n] ?? null;
|
|
505
505
|
return `export default ${JSON.stringify(r)}\n`;
|
|
506
506
|
}
|
|
507
507
|
//#endregion
|
|
508
508
|
//#region src/index.ts
|
|
509
|
-
var
|
|
509
|
+
var Me = 5;
|
|
510
510
|
function J(e, t, n) {
|
|
511
511
|
if (t.length === 0) return;
|
|
512
|
-
if (t.length >
|
|
512
|
+
if (t.length > Me) {
|
|
513
513
|
console.log(`\n ${e}: ${t.length.toString()} loaded\n`);
|
|
514
514
|
return;
|
|
515
515
|
}
|
|
@@ -524,10 +524,10 @@ function J(e, t, n) {
|
|
|
524
524
|
""
|
|
525
525
|
].join("\n"));
|
|
526
526
|
}
|
|
527
|
-
function
|
|
527
|
+
function Ne(e, t) {
|
|
528
528
|
t.length !== 0 && console.log(`\n ${e}: ${t.length.toString()} loaded\n`);
|
|
529
529
|
}
|
|
530
|
-
var
|
|
530
|
+
var Pe = [
|
|
531
531
|
{
|
|
532
532
|
header: "Name",
|
|
533
533
|
value: (e) => e.name
|
|
@@ -542,13 +542,13 @@ var Ne = [
|
|
|
542
542
|
},
|
|
543
543
|
{
|
|
544
544
|
header: "Split",
|
|
545
|
-
value: (e) =>
|
|
545
|
+
value: (e) => ge(e)
|
|
546
546
|
},
|
|
547
547
|
{
|
|
548
548
|
header: "Ver",
|
|
549
549
|
value: (e) => `v${e.version.toString()}`
|
|
550
550
|
}
|
|
551
|
-
],
|
|
551
|
+
], Fe = [
|
|
552
552
|
{
|
|
553
553
|
header: "Name",
|
|
554
554
|
value: (e) => e.name
|
|
@@ -569,7 +569,7 @@ var Ne = [
|
|
|
569
569
|
header: "Targets",
|
|
570
570
|
value: (e) => e.targets.length.toString()
|
|
571
571
|
}
|
|
572
|
-
],
|
|
572
|
+
], Ie = [
|
|
573
573
|
{
|
|
574
574
|
header: "Name",
|
|
575
575
|
value: (e) => e.name
|
|
@@ -582,7 +582,7 @@ var Ne = [
|
|
|
582
582
|
header: "Fields",
|
|
583
583
|
value: (e) => (e.fieldIds?.length ?? 0).toString()
|
|
584
584
|
}
|
|
585
|
-
],
|
|
585
|
+
], Le = [
|
|
586
586
|
{
|
|
587
587
|
header: "Name",
|
|
588
588
|
value: (e) => e.name
|
|
@@ -599,121 +599,125 @@ var Ne = [
|
|
|
599
599
|
header: "Required",
|
|
600
600
|
value: (e) => e.required ? "yes" : "no"
|
|
601
601
|
}
|
|
602
|
-
],
|
|
602
|
+
], Re = [{
|
|
603
603
|
header: "Name",
|
|
604
604
|
value: (e) => e.name
|
|
605
605
|
}, {
|
|
606
606
|
header: "Key",
|
|
607
607
|
value: (e) => e.key
|
|
608
608
|
}];
|
|
609
|
-
function
|
|
610
|
-
return "0.0.111-next.
|
|
609
|
+
function ze() {
|
|
610
|
+
return "0.0.111-next.4";
|
|
611
611
|
}
|
|
612
|
-
var
|
|
613
|
-
function
|
|
612
|
+
var Be = "https://api.picked.app", Y = "virtual:picked/data", X = `\0${Y}`, Ve = `\0${q}`;
|
|
613
|
+
function He(e) {
|
|
614
614
|
for (let t of Object.values(e)) if (t.type === "chunk" && t.moduleIds.includes(X)) return t.fileName;
|
|
615
615
|
}
|
|
616
|
-
function
|
|
616
|
+
function Ue(e, t) {
|
|
617
617
|
return e === "" || e.endsWith("/") ? `${e}${t}` : `${e}/${t}`;
|
|
618
618
|
}
|
|
619
|
-
async function
|
|
619
|
+
async function We(e) {
|
|
620
620
|
try {
|
|
621
621
|
let t = await o({
|
|
622
622
|
config: e,
|
|
623
623
|
onWarn: (e) => {
|
|
624
|
-
|
|
624
|
+
F.warn(e);
|
|
625
625
|
}
|
|
626
626
|
});
|
|
627
|
-
|
|
627
|
+
F.info(`generated types at ${t.typesOutput}`);
|
|
628
628
|
} catch (e) {
|
|
629
629
|
let t = e instanceof Error ? e.message : String(e);
|
|
630
630
|
throw Error(`type generation failed: ${t}. Fix the schema source, or set \`generateTypes: false\` on the picked plugin to skip it.`);
|
|
631
631
|
}
|
|
632
632
|
}
|
|
633
|
-
function
|
|
634
|
-
return e &&
|
|
633
|
+
function Ge(e, t, n) {
|
|
634
|
+
return e && u(t, n) ? e : null;
|
|
635
635
|
}
|
|
636
|
-
async function
|
|
637
|
-
let n = await
|
|
636
|
+
async function Ke(e, t) {
|
|
637
|
+
let n = await p(e, t);
|
|
638
638
|
if (!n) throw Error("picked.config.{ts,js,json} is required. Add a picked.config.ts with projectId and apiUrl.");
|
|
639
639
|
return n;
|
|
640
640
|
}
|
|
641
|
-
function
|
|
641
|
+
function Z(e, t, n, r) {
|
|
642
642
|
if (t === void 0 || n === void 0 || t === n) return;
|
|
643
643
|
let i = r === void 0 ? `picked.config says "${n}"` : `picked.config \`${r}\` is "${n}"`;
|
|
644
644
|
throw Error(`picked plugin option \`${e}\` is "${t}", and ${i}. Remove the plugin option; picked.config is the one place this belongs.`);
|
|
645
645
|
}
|
|
646
|
-
function
|
|
647
|
-
|
|
646
|
+
async function qe(e) {
|
|
647
|
+
let t = await f(e);
|
|
648
|
+
return t && l(t) ? t : null;
|
|
649
|
+
}
|
|
650
|
+
function Je(e) {
|
|
651
|
+
e.data !== void 0 && F.warn("picked plugin option `mode` is deprecated, and a future release drops it. Set `data` in picked.config instead, which the CLI and the type generator read from too.");
|
|
648
652
|
let t = [];
|
|
649
653
|
if (e.projectId !== void 0 && t.push("`projectId`"), e.apiUrl !== void 0 && t.push("`apiUrl`"), t.length === 0) return;
|
|
650
654
|
let n = t.length > 1;
|
|
651
|
-
|
|
655
|
+
F.warn(`picked plugin option${n ? "s" : ""} ${t.join(" and ")} ${n ? "are" : "is"} deprecated, and a future release drops ${n ? "them" : "it"}. Move ${n ? "them" : "it"} to picked.config, which the CLI and the type generator read from too.`);
|
|
652
656
|
}
|
|
653
|
-
async function
|
|
654
|
-
let n = await
|
|
655
|
-
n && n.projectId !== t &&
|
|
657
|
+
async function Ye(e, t) {
|
|
658
|
+
let n = await qe(e);
|
|
659
|
+
n && n.projectId !== t && F.warn(`using project "${t}" (picked.config default: "${n.projectId}") — run 'picked status' to inspect`);
|
|
656
660
|
}
|
|
657
|
-
async function
|
|
658
|
-
let n = await
|
|
659
|
-
return
|
|
661
|
+
async function Xe(e, t) {
|
|
662
|
+
let n = await qe(e);
|
|
663
|
+
return Z("projectId", t.projectId, n?.projectId), Z("apiUrl", t.apiUrl, n?.apiUrl), Z("mode", t.data, n?.data, "data"), Je(t), Ke(e, t);
|
|
660
664
|
}
|
|
661
|
-
async function
|
|
662
|
-
if (t.data !== "snapshot") return e(
|
|
663
|
-
let n = await
|
|
664
|
-
return
|
|
665
|
+
async function Ze(t) {
|
|
666
|
+
if (t.data !== "snapshot") return e(h(t.projectRoot)) && F.warn(`${s} is ignored: the data mode in force is '${t.data}'. Set \`data: 'snapshot'\` in picked.config to build from it, or delete it.`), null;
|
|
667
|
+
let n = await m(t);
|
|
668
|
+
return F.info(`serving ${s}: project "${n.projectId}", version ${n.projectVersionId ?? "none (preview)"} — run \`picked pull\` to refresh`), n.source === "preview" ? F.warn(`${s} holds preview data, so this run serves unpublished content. Run \`picked pull\` against the published workspace before you release.`) : t.source === "preview" && F.warn(`the preview workspace in force is not read: ${s} holds published data. Run \`picked pull --allow-preview\` to serve the preview.`), n;
|
|
665
669
|
}
|
|
666
|
-
async function
|
|
670
|
+
async function Qe(e, t, n, r) {
|
|
667
671
|
let i = () => a(e, t, {
|
|
668
672
|
headers: n,
|
|
669
673
|
previewToken: r ?? void 0
|
|
670
674
|
});
|
|
671
|
-
return
|
|
672
|
-
|
|
675
|
+
return R(e) ? z(i, (e, t, n) => {
|
|
676
|
+
F.info(`local API not ready, retrying in ${(n / 1e3).toString()}s (${e.toString()}/${t.toString()})`);
|
|
673
677
|
}) : i();
|
|
674
678
|
}
|
|
675
|
-
var
|
|
676
|
-
function
|
|
679
|
+
var Q = /* @__PURE__ */ new Map();
|
|
680
|
+
function $e(e, t, n) {
|
|
677
681
|
return JSON.stringify([
|
|
678
682
|
e,
|
|
679
683
|
t,
|
|
680
684
|
n
|
|
681
685
|
]);
|
|
682
686
|
}
|
|
683
|
-
function
|
|
684
|
-
let i = t.mode, a = i ?? "bundle", o = null, c = t.generateTypes ?? !0, l = [],
|
|
685
|
-
return
|
|
687
|
+
function et(t = {}) {
|
|
688
|
+
let i = t.mode, a = i ?? "bundle", o = null, c = t.generateTypes ?? !0, l = [], u = process.cwd(), f = "serve", p = "/", g = null, _ = !1, v, y, b = null, x = d() ? null : we();
|
|
689
|
+
return Ee(x, {
|
|
686
690
|
name: "picked",
|
|
687
|
-
config: async (s,
|
|
688
|
-
f =
|
|
691
|
+
config: async (s, d) => {
|
|
692
|
+
f = d.command, u = s.root === void 0 ? process.cwd() : n(process.cwd(), s.root);
|
|
689
693
|
let { projectId: p, apiUrl: m } = t;
|
|
690
|
-
g = await
|
|
694
|
+
g = await Xe(u, {
|
|
691
695
|
projectId: p,
|
|
692
696
|
apiUrl: m,
|
|
693
697
|
data: i
|
|
694
698
|
});
|
|
695
699
|
let { projectId: h, apiUrl: S, previewToken: C } = g;
|
|
696
|
-
if (a = g.data, x =
|
|
697
|
-
S !==
|
|
698
|
-
let w = r("vite-plugin",
|
|
699
|
-
if (a === "api")
|
|
700
|
-
else if (
|
|
701
|
-
let t =
|
|
700
|
+
if (a = g.data, x = Ge(x, g, t.telemetry), F.banner(), o = await Ze(g), o && (l = B(o.projectConfig.features)), c && !_ && (_ = !0, await We(g)), a === "snapshot") return;
|
|
701
|
+
S !== Be && F.warn(`using custom API URL: ${S}`), await Ye(u, h);
|
|
702
|
+
let w = r("vite-plugin", ze());
|
|
703
|
+
if (a === "api") F.debug("data is 'api': skipping the project-config prefetch");
|
|
704
|
+
else if (d.command === "build") {
|
|
705
|
+
let t = $e(S, h, u);
|
|
702
706
|
v = t;
|
|
703
|
-
let n =
|
|
707
|
+
let n = Q.get(t);
|
|
704
708
|
n === void 0 && (n = (async () => {
|
|
705
|
-
|
|
706
|
-
let t = H(
|
|
709
|
+
F.info(`prefetching project config + content for "${h}"`);
|
|
710
|
+
let t = H(u), n = e(t.pickedDir), r = performance.now(), i = await be({
|
|
707
711
|
apiUrl: S,
|
|
708
712
|
projectId: h,
|
|
709
|
-
projectRoot:
|
|
713
|
+
projectRoot: u,
|
|
710
714
|
headers: w,
|
|
711
715
|
previewToken: C ?? void 0
|
|
712
716
|
}), a = (performance.now() - r).toFixed(0);
|
|
713
|
-
await
|
|
717
|
+
await fe(u, n);
|
|
714
718
|
let o = i.config;
|
|
715
|
-
return
|
|
716
|
-
virtualSource:
|
|
719
|
+
return $(o, a), {
|
|
720
|
+
virtualSource: Oe({
|
|
717
721
|
projectConfigPath: t.projectConfigPath,
|
|
718
722
|
experienceContentPaths: i.experienceContentPaths,
|
|
719
723
|
manifestMetadata: {
|
|
@@ -725,24 +729,24 @@ function Ze(t = {}) {
|
|
|
725
729
|
}),
|
|
726
730
|
features: B(o.features)
|
|
727
731
|
};
|
|
728
|
-
})(), n.catch(() =>
|
|
732
|
+
})(), n.catch(() => Q.delete(t)), Q.set(t, n));
|
|
729
733
|
let r = await n;
|
|
730
734
|
y = r.virtualSource, l = r.features;
|
|
731
|
-
} else if (
|
|
735
|
+
} else if (d.mode === "production") F.debug("skipping the dev project-config fetch for a production serve resolution");
|
|
732
736
|
else {
|
|
733
|
-
|
|
734
|
-
let e = performance.now(), t = await
|
|
735
|
-
b = t, t ? (l = B(t.features),
|
|
737
|
+
F.info(`fetching project config for "${h}" (dev)`);
|
|
738
|
+
let e = performance.now(), t = await Qe(S, h, w, C), n = (performance.now() - e).toFixed(0);
|
|
739
|
+
b = t, t ? (l = B(t.features), $(t, n)) : F.warn(`failed to fetch project config for "${h}" (${n}ms)`);
|
|
736
740
|
}
|
|
737
741
|
},
|
|
738
742
|
configResolved(e) {
|
|
739
|
-
|
|
743
|
+
p = e.base;
|
|
740
744
|
},
|
|
741
745
|
async buildStart() {
|
|
742
|
-
a === "snapshot" && g && f === "build" && (o = await
|
|
746
|
+
a === "snapshot" && g && f === "build" && (o = await m(g));
|
|
743
747
|
},
|
|
744
748
|
closeBundle() {
|
|
745
|
-
v !== void 0 &&
|
|
749
|
+
v !== void 0 && Q.delete(v), x?.flush({
|
|
746
750
|
"picked.vite.command": f,
|
|
747
751
|
"picked.data.mode": a,
|
|
748
752
|
"picked.source": g?.source ?? "unknown"
|
|
@@ -752,9 +756,9 @@ function Ze(t = {}) {
|
|
|
752
756
|
order: "post",
|
|
753
757
|
handler(e, t) {
|
|
754
758
|
if (a === "api" || t.bundle === void 0) return;
|
|
755
|
-
let n =
|
|
759
|
+
let n = He(t.bundle);
|
|
756
760
|
if (n === void 0) return;
|
|
757
|
-
let r =
|
|
761
|
+
let r = Ue(p, n);
|
|
758
762
|
if (!e.includes(`"${r}"`)) return [{
|
|
759
763
|
tag: "link",
|
|
760
764
|
attrs: {
|
|
@@ -770,16 +774,16 @@ function Ze(t = {}) {
|
|
|
770
774
|
if (e === Y || e.startsWith("virtual:picked/data/experience/")) return `\0${e}`;
|
|
771
775
|
},
|
|
772
776
|
load(e) {
|
|
773
|
-
if (e.startsWith(
|
|
777
|
+
if (e.startsWith(Ve) && o && g) return this.addWatchFile(h(g.projectRoot)), je(o, e.slice(Ve.length));
|
|
774
778
|
if (e === X) {
|
|
775
|
-
if (a === "api") return
|
|
779
|
+
if (a === "api") return De();
|
|
776
780
|
if (a === "snapshot") {
|
|
777
781
|
if (!o || !g) throw Error("picked plugin config hook must run before virtual module load");
|
|
778
|
-
return this.addWatchFile(
|
|
782
|
+
return this.addWatchFile(h(g.projectRoot)), Ae(o);
|
|
779
783
|
}
|
|
780
784
|
if (f === "build") return y;
|
|
781
785
|
if (!g) throw Error("picked plugin config hook must run before virtual module load");
|
|
782
|
-
return
|
|
786
|
+
return ke({
|
|
783
787
|
apiUrl: g.apiUrl,
|
|
784
788
|
projectId: g.projectId,
|
|
785
789
|
projectConfig: b,
|
|
@@ -789,13 +793,13 @@ function Ze(t = {}) {
|
|
|
789
793
|
},
|
|
790
794
|
configureServer(e) {
|
|
791
795
|
if (a === "snapshot" && g) {
|
|
792
|
-
let t =
|
|
793
|
-
n === t && (
|
|
796
|
+
let t = h(g.projectRoot), n = (n) => {
|
|
797
|
+
n === t && (F.info(`${s} changed; restarting the dev server`), e.restart());
|
|
794
798
|
};
|
|
795
799
|
e.watcher.add(t), e.watcher.on("add", n), e.watcher.on("change", n), e.watcher.on("unlink", n);
|
|
796
800
|
}
|
|
797
801
|
if (t.disableLauncher) return;
|
|
798
|
-
e.middlewares.use(
|
|
802
|
+
e.middlewares.use(de(() => T(l)));
|
|
799
803
|
let n = e.printUrls.bind(e);
|
|
800
804
|
e.printUrls = () => {
|
|
801
805
|
let t = e.resolvedUrls?.local[0];
|
|
@@ -809,7 +813,7 @@ function Ze(t = {}) {
|
|
|
809
813
|
generateBundle: {
|
|
810
814
|
order: "post",
|
|
811
815
|
handler(e, n) {
|
|
812
|
-
t.disableLauncher || ("index.html" in n ?
|
|
816
|
+
t.disableLauncher || ("index.html" in n ? F.debug("index.html came from the build; skipping the launcher page") : this.emitFile({
|
|
813
817
|
type: "asset",
|
|
814
818
|
fileName: "index.html",
|
|
815
819
|
source: T(l)
|
|
@@ -818,7 +822,7 @@ function Ze(t = {}) {
|
|
|
818
822
|
}
|
|
819
823
|
});
|
|
820
824
|
}
|
|
821
|
-
function
|
|
825
|
+
function $(e, t) {
|
|
822
826
|
let n = B(e.features), r = B(e.experiences), i = B(e.steps), a = B(e.fields), o = B(e.conditions), s = B(e.actions), c = JSON.stringify(e).length, l = [
|
|
823
827
|
`${n.length.toString()} features`,
|
|
824
828
|
`${r.length.toString()} experiences`,
|
|
@@ -827,7 +831,7 @@ function Qe(e, t) {
|
|
|
827
831
|
`${o.length.toString()} conditions`,
|
|
828
832
|
`${s.length.toString()} actions`
|
|
829
833
|
].join(", ");
|
|
830
|
-
|
|
834
|
+
F.info(`fetched config in ${t}ms (${l})`), J("Features", n, Pe), J("Experiences", r, Fe), J("Steps", i, Ie), J("Fields", a, Le), J("Conditions", o, Re), Ne("Actions", s), F.debug(`config size: ${c.toString()} bytes`);
|
|
831
835
|
}
|
|
832
836
|
//#endregion
|
|
833
|
-
export {
|
|
837
|
+
export { et as picked };
|