@picked/vite-plugin-picked 0.0.120-next.1 → 0.0.120-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/.tsbuildinfo +1 -1
- package/dist/cjs/index.d.ts +2 -0
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +5 -5
- package/dist/esm/index.js +190 -187
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +6 -6
package/dist/esm/index.js
CHANGED
|
@@ -11,28 +11,28 @@ function w(e, t) {
|
|
|
11
11
|
}
|
|
12
12
|
//#endregion
|
|
13
13
|
//#region src/launcher.ts
|
|
14
|
-
var
|
|
15
|
-
function
|
|
14
|
+
var T, E = ["true", "false"], ee = "false";
|
|
15
|
+
function te(e) {
|
|
16
16
|
let t = e.variants;
|
|
17
|
-
return !t || t.length === 0 ?
|
|
17
|
+
return !t || t.length === 0 ? E : t.map((e) => String(e.value));
|
|
18
18
|
}
|
|
19
|
-
function
|
|
20
|
-
let t =
|
|
21
|
-
return t.map((e, t) => `<option value="${
|
|
19
|
+
function ne(e) {
|
|
20
|
+
let t = te(e), n = Math.max(0, t.findIndex((e) => e !== ee));
|
|
21
|
+
return t.map((e, t) => `<option value="${O(e)}"${t === n ? " selected" : ""}>${D(e)}</option>`).join("");
|
|
22
22
|
}
|
|
23
|
-
function
|
|
23
|
+
function re(e) {
|
|
24
24
|
let t = JSON.stringify(e).replaceAll("<", String.raw`\u003c`), n = e.length > 0 ? e.map((e) => `
|
|
25
25
|
<div class="feature-row">
|
|
26
26
|
<label>
|
|
27
|
-
<input type="checkbox" data-feature-id="${
|
|
28
|
-
<span class="feature-name">${
|
|
29
|
-
<span class="feature-id">${
|
|
27
|
+
<input type="checkbox" data-feature-id="${O(e.id)}" checked>
|
|
28
|
+
<span class="feature-name">${D(e.name)}</span>
|
|
29
|
+
<span class="feature-id">${D(e.id)}</span>
|
|
30
30
|
</label>
|
|
31
|
-
<select data-value-for="${
|
|
32
|
-
${
|
|
31
|
+
<select data-value-for="${O(e.id)}">
|
|
32
|
+
${ne(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(T ||= 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>"
|
|
@@ -42,46 +42,46 @@ function T(e) {
|
|
|
42
42
|
";\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>"
|
|
43
43
|
]), n, t);
|
|
44
44
|
}
|
|
45
|
-
function
|
|
45
|
+
function D(e) {
|
|
46
46
|
return e.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll("\"", """);
|
|
47
47
|
}
|
|
48
|
-
function
|
|
48
|
+
function O(e) {
|
|
49
49
|
return e.replaceAll("&", "&").replaceAll("\"", """).replaceAll("<", "<").replaceAll(">", ">");
|
|
50
50
|
}
|
|
51
51
|
//#endregion
|
|
52
52
|
//#region src/log.ts
|
|
53
|
-
var
|
|
54
|
-
function
|
|
53
|
+
var k = "picked", ie = "\x1B[0m";
|
|
54
|
+
function ae() {
|
|
55
55
|
let e = process.env.NO_COLOR;
|
|
56
56
|
return e === "1" || e === "true";
|
|
57
57
|
}
|
|
58
|
-
function
|
|
59
|
-
return (t) =>
|
|
58
|
+
function A(e) {
|
|
59
|
+
return (t) => ae() ? t : `${e}${t}${ie}`;
|
|
60
60
|
}
|
|
61
|
-
var
|
|
61
|
+
var oe = [
|
|
62
62
|
"debug",
|
|
63
63
|
"info",
|
|
64
64
|
"warn",
|
|
65
65
|
"error",
|
|
66
66
|
"silent"
|
|
67
|
-
],
|
|
67
|
+
], j = {
|
|
68
68
|
debug: {
|
|
69
|
-
color:
|
|
69
|
+
color: A("\x1B[2m"),
|
|
70
70
|
log: console.debug,
|
|
71
71
|
enabled: !1
|
|
72
72
|
},
|
|
73
73
|
info: {
|
|
74
|
-
color:
|
|
74
|
+
color: A("\x1B[36m"),
|
|
75
75
|
log: console.log,
|
|
76
76
|
enabled: !0
|
|
77
77
|
},
|
|
78
78
|
warn: {
|
|
79
|
-
color:
|
|
79
|
+
color: A("\x1B[33m"),
|
|
80
80
|
log: console.warn,
|
|
81
81
|
enabled: !0
|
|
82
82
|
},
|
|
83
83
|
error: {
|
|
84
|
-
color:
|
|
84
|
+
color: A("\x1B[31m"),
|
|
85
85
|
log: console.error,
|
|
86
86
|
enabled: !0
|
|
87
87
|
},
|
|
@@ -90,49 +90,49 @@ var se = [
|
|
|
90
90
|
enabled: !1
|
|
91
91
|
}
|
|
92
92
|
};
|
|
93
|
-
function
|
|
94
|
-
return `${(/* @__PURE__ */ new Date()).toLocaleTimeString()} [${t ? `${
|
|
93
|
+
function se(e, t) {
|
|
94
|
+
return `${(/* @__PURE__ */ new Date()).toLocaleTimeString()} [${t ? `${k}:${t}` : k}] ${e}`;
|
|
95
95
|
}
|
|
96
|
-
function
|
|
96
|
+
function M(e, t, n, r) {
|
|
97
97
|
if (!e.enabled) return;
|
|
98
|
-
let i =
|
|
98
|
+
let i = se(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 N(e) {
|
|
102
|
+
let t = j[e], n = /* @__PURE__ */ new Set();
|
|
103
103
|
return Object.assign((e, n, r) => {
|
|
104
|
-
|
|
104
|
+
M(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), M(t, e, r, i));
|
|
107
107
|
} });
|
|
108
108
|
}
|
|
109
|
-
function
|
|
110
|
-
let t =
|
|
111
|
-
if (t === -1) j
|
|
112
|
-
else for (let [e, n] of
|
|
109
|
+
function ce(e) {
|
|
110
|
+
let t = oe.indexOf(e);
|
|
111
|
+
if (t === -1) M(j.error, `invalid log level: ${e}`);
|
|
112
|
+
else for (let [e, n] of oe.entries()) j[n].enabled = e >= t;
|
|
113
113
|
}
|
|
114
|
-
var
|
|
115
|
-
function
|
|
114
|
+
var P = A("\x1B[34m"), F = A("\x1B[36m");
|
|
115
|
+
function le() {
|
|
116
116
|
let e = [
|
|
117
|
-
` ${
|
|
118
|
-
`${
|
|
119
|
-
` ${
|
|
120
|
-
`${
|
|
117
|
+
` ${P("_")} ${F("_")} _ _ _`,
|
|
118
|
+
`${P("(_)")} ${F("(_)")} _ __(_)__| |_____ __| |`,
|
|
119
|
+
` ${P("_")} ${P("_")} | '_ \\ / _| / / -_) _\` |`,
|
|
120
|
+
`${P("(_)")} ${P("(_)")} | .__/_\\__|_\\_\\___\\__,_|`,
|
|
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 I = {
|
|
126
|
+
banner: le,
|
|
127
|
+
debug: N("debug"),
|
|
128
|
+
info: N("info"),
|
|
129
|
+
warn: N("warn"),
|
|
130
|
+
error: N("error"),
|
|
131
|
+
setLevel: ce
|
|
132
132
|
};
|
|
133
133
|
//#endregion
|
|
134
134
|
//#region src/middleware.ts
|
|
135
|
-
function
|
|
135
|
+
function ue(e) {
|
|
136
136
|
return (t, n, r) => {
|
|
137
137
|
if (t.method !== "GET") {
|
|
138
138
|
r();
|
|
@@ -149,28 +149,28 @@ function de(e) {
|
|
|
149
149
|
}
|
|
150
150
|
//#endregion
|
|
151
151
|
//#region src/gitignore.ts
|
|
152
|
-
var
|
|
153
|
-
async function
|
|
152
|
+
var L = ".picked/";
|
|
153
|
+
async function de(n, r) {
|
|
154
154
|
if (r) return;
|
|
155
155
|
let i = t(n, ".gitignore");
|
|
156
156
|
if (!e(i)) {
|
|
157
|
-
await y(i, `${
|
|
157
|
+
await y(i, `${L}
|
|
158
158
|
`);
|
|
159
159
|
return;
|
|
160
160
|
}
|
|
161
161
|
let a = await v(i, "utf8");
|
|
162
|
-
if (
|
|
163
|
-
let o = `${a.length > 0 && !a.endsWith("\n") ? "\n" : ""}${
|
|
162
|
+
if (fe(a)) return;
|
|
163
|
+
let o = `${a.length > 0 && !a.endsWith("\n") ? "\n" : ""}${L}
|
|
164
164
|
`;
|
|
165
165
|
await g(i, o);
|
|
166
166
|
}
|
|
167
|
-
function
|
|
168
|
-
return e.split(/\r?\n/).map((e) => e.trim()).some((e) => e ===
|
|
167
|
+
function fe(e) {
|
|
168
|
+
return e.split(/\r?\n/).map((e) => e.trim()).some((e) => e === L || e === ".picked");
|
|
169
169
|
}
|
|
170
170
|
//#endregion
|
|
171
171
|
//#region src/retry.ts
|
|
172
|
-
var
|
|
173
|
-
function
|
|
172
|
+
var R = 6, pe = 5e3;
|
|
173
|
+
function z(e) {
|
|
174
174
|
let t;
|
|
175
175
|
try {
|
|
176
176
|
t = new URL(e).hostname;
|
|
@@ -179,12 +179,12 @@ function R(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 me(e) {
|
|
183
183
|
return new Promise((t) => {
|
|
184
184
|
setTimeout(t, e);
|
|
185
185
|
});
|
|
186
186
|
}
|
|
187
|
-
async function
|
|
187
|
+
async function B(e, t) {
|
|
188
188
|
let n = null, r = null;
|
|
189
189
|
try {
|
|
190
190
|
n = await e();
|
|
@@ -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 <= R; i++) {
|
|
196
|
+
let a = pe * 2 ** (i - 1);
|
|
197
|
+
t(i, R, a), await me(a), r = null;
|
|
198
198
|
try {
|
|
199
199
|
n = await e();
|
|
200
200
|
} catch (e) {
|
|
@@ -207,10 +207,10 @@ async function z(e, t) {
|
|
|
207
207
|
}
|
|
208
208
|
//#endregion
|
|
209
209
|
//#region src/util.ts
|
|
210
|
-
function
|
|
210
|
+
function V(e) {
|
|
211
211
|
return Array.isArray(e) ? e : [];
|
|
212
212
|
}
|
|
213
|
-
function
|
|
213
|
+
function he(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);
|
|
@@ -219,8 +219,8 @@ function ge(e) {
|
|
|
219
219
|
}
|
|
220
220
|
//#endregion
|
|
221
221
|
//#region src/prefetch.ts
|
|
222
|
-
var
|
|
223
|
-
function
|
|
222
|
+
var H = 2;
|
|
223
|
+
function U(e) {
|
|
224
224
|
let n = t(e, ".picked");
|
|
225
225
|
return {
|
|
226
226
|
pickedDir: n,
|
|
@@ -229,50 +229,50 @@ function H(e) {
|
|
|
229
229
|
experiencesDir: t(n, "experiences")
|
|
230
230
|
};
|
|
231
231
|
}
|
|
232
|
-
async function
|
|
232
|
+
async function ge(t) {
|
|
233
233
|
if (!e(t)) return null;
|
|
234
234
|
try {
|
|
235
235
|
let e = await v(t, "utf8"), n = JSON.parse(e);
|
|
236
|
-
return
|
|
236
|
+
return _e(n) ? n : null;
|
|
237
237
|
} catch {
|
|
238
238
|
return null;
|
|
239
239
|
}
|
|
240
240
|
}
|
|
241
|
-
function
|
|
241
|
+
function _e(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 ve(e) {
|
|
245
245
|
let t = /* @__PURE__ */ new Set();
|
|
246
|
-
for (let n of
|
|
246
|
+
for (let n of V(e.steps)) n.layoutContentId && t.add(n.id);
|
|
247
247
|
if (t.size === 0) return [];
|
|
248
248
|
let n = [];
|
|
249
|
-
for (let r of
|
|
249
|
+
for (let r of V(e.experiences)) V(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 =
|
|
252
|
+
async function ye(n) {
|
|
253
|
+
let { apiUrl: r, projectId: i, projectRoot: a, headers: o, previewToken: s, reuseWhenUnchanged: c = !0 } = n, l = U(a), u = await be(r, i, o, s), d = ve(u);
|
|
254
254
|
if (await _(l.experiencesDir, { recursive: !0 }), await y(l.projectConfigPath, JSON.stringify(u, null, 2)), c) {
|
|
255
|
-
let t = await
|
|
256
|
-
if (t?.version ===
|
|
257
|
-
let n =
|
|
255
|
+
let t = await ge(l.manifestPath);
|
|
256
|
+
if (t?.version === H && t.projectVersionId === u.versionId && t.workspaceId === u.workspaceId) {
|
|
257
|
+
let n = W(l, d);
|
|
258
258
|
if (Object.values(n).every((t) => e(t))) return {
|
|
259
259
|
config: u,
|
|
260
260
|
manifest: t,
|
|
261
261
|
experienceContentPaths: n
|
|
262
262
|
};
|
|
263
|
-
|
|
263
|
+
I.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
|
|
268
|
+
let n = await xe(r, i, e, o, s), a = t(l.experiencesDir, `${e}.json`);
|
|
269
269
|
await y(a, JSON.stringify(n, null, 2)), p.push({
|
|
270
270
|
id: e,
|
|
271
271
|
fetchedAt: f
|
|
272
272
|
});
|
|
273
273
|
}
|
|
274
274
|
let m = {
|
|
275
|
-
version:
|
|
275
|
+
version: H,
|
|
276
276
|
fetchedAt: f,
|
|
277
277
|
projectVersionId: u.versionId,
|
|
278
278
|
workspaceId: u.workspaceId,
|
|
@@ -282,30 +282,30 @@ async function be(n) {
|
|
|
282
282
|
return await y(l.manifestPath, JSON.stringify(m, null, 2)), {
|
|
283
283
|
config: u,
|
|
284
284
|
manifest: m,
|
|
285
|
-
experienceContentPaths:
|
|
285
|
+
experienceContentPaths: W(l, d)
|
|
286
286
|
};
|
|
287
287
|
}
|
|
288
|
-
function
|
|
288
|
+
function W(e, n) {
|
|
289
289
|
let r = {};
|
|
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 be(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 = z(e) ? await B(i, (e, t, n) => {
|
|
300
|
+
I.info(`project config not ready, retrying in ${(n / 1e3).toString()}s (${e.toString()}/${t.toString()})`);
|
|
301
301
|
}) : await i();
|
|
302
302
|
} catch (n) {
|
|
303
|
-
throw Error(`[picked] Build-time fetch of project config failed for "${t}" at ${e}: ${
|
|
303
|
+
throw Error(`[picked] Build-time fetch of project config failed for "${t}" at ${e}: ${G(n)}`);
|
|
304
304
|
}
|
|
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 xe(e, t, n, r, a) {
|
|
309
309
|
let o;
|
|
310
310
|
try {
|
|
311
311
|
o = await i(e, t, n, {
|
|
@@ -313,12 +313,12 @@ async function Se(e, t, n, r, a) {
|
|
|
313
313
|
previewToken: a
|
|
314
314
|
});
|
|
315
315
|
} catch (t) {
|
|
316
|
-
throw Error(`[picked] Build-time fetch of content for experience "${n}" failed at ${e}: ${
|
|
316
|
+
throw Error(`[picked] Build-time fetch of content for experience "${n}" failed at ${e}: ${G(t)}`);
|
|
317
317
|
}
|
|
318
318
|
if (!o) throw Error(`[picked] Build-time fetch of content for experience "${n}" returned no usable response. Confirm the experience id exists and the API is reachable.`);
|
|
319
319
|
return o;
|
|
320
320
|
}
|
|
321
|
-
function
|
|
321
|
+
function G(e) {
|
|
322
322
|
if (e instanceof Error) return e.message;
|
|
323
323
|
if (typeof e == "string") return e;
|
|
324
324
|
try {
|
|
@@ -329,12 +329,12 @@ function W(e) {
|
|
|
329
329
|
}
|
|
330
330
|
//#endregion
|
|
331
331
|
//#region src/telemetry.ts
|
|
332
|
-
var
|
|
333
|
-
function
|
|
332
|
+
var Se = /* @__PURE__ */ new Set(["resolveId", "load"]);
|
|
333
|
+
function Ce(e = S()) {
|
|
334
334
|
let t = b(), n = Date.now(), r = [], i = /* @__PURE__ */ new Map();
|
|
335
335
|
return {
|
|
336
336
|
record: (n, a) => {
|
|
337
|
-
if (
|
|
337
|
+
if (Se.has(n)) {
|
|
338
338
|
let e = i.get(n) ?? {
|
|
339
339
|
calls: 0,
|
|
340
340
|
totalMs: 0
|
|
@@ -387,33 +387,33 @@ function we(e = S()) {
|
|
|
387
387
|
}
|
|
388
388
|
};
|
|
389
389
|
}
|
|
390
|
-
function
|
|
390
|
+
function we(e) {
|
|
391
391
|
return typeof e == "object" && !!e && "then" in e;
|
|
392
392
|
}
|
|
393
|
-
function
|
|
393
|
+
function K(e, t, n) {
|
|
394
394
|
return function(...r) {
|
|
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 we(o) ? Promise.resolve(o).then(a, a) : a(), o;
|
|
399
399
|
};
|
|
400
400
|
}
|
|
401
|
-
function
|
|
401
|
+
function q(e) {
|
|
402
402
|
return typeof e == "function";
|
|
403
403
|
}
|
|
404
|
-
function
|
|
404
|
+
function Te(e, t) {
|
|
405
405
|
if (!e) return t;
|
|
406
|
-
for (let [n, r] of Object.entries(t)) n !== "name" && (
|
|
406
|
+
for (let [n, r] of Object.entries(t)) n !== "name" && (q(r) ? Reflect.set(t, n, K(n, r, e)) : typeof r == "object" && r && "handler" in r && q(r.handler) && Reflect.set(r, "handler", K(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 Ee() {
|
|
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 De(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 Oe(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
|
|
|
@@ -469,10 +469,10 @@ ${s}`;
|
|
|
469
469
|
}
|
|
470
470
|
//#endregion
|
|
471
471
|
//#region src/virtual-module/snapshot.ts
|
|
472
|
-
var
|
|
473
|
-
function
|
|
472
|
+
var J = "virtual:picked/data/experience/";
|
|
473
|
+
function ke(e) {
|
|
474
474
|
let t = Object.keys(e.experiences).map((e, t) => {
|
|
475
|
-
let n = JSON.stringify(
|
|
475
|
+
let n = JSON.stringify(J + t.toString());
|
|
476
476
|
return ` ${JSON.stringify(e)}: () => import(${n}).then((m) => m.default),`;
|
|
477
477
|
}).join("\n"), n = {
|
|
478
478
|
mode: "snapshot",
|
|
@@ -500,16 +500,16 @@ export const manifestMetadata = ${JSON.stringify(n)}
|
|
|
500
500
|
registerPickedBundle({ projectConfig, experienceContent, manifestMetadata })
|
|
501
501
|
`;
|
|
502
502
|
}
|
|
503
|
-
function
|
|
503
|
+
function Ae(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
|
|
510
|
-
function
|
|
509
|
+
var je = 5;
|
|
510
|
+
function Y(e, t, n) {
|
|
511
511
|
if (t.length === 0) return;
|
|
512
|
-
if (t.length >
|
|
512
|
+
if (t.length > je) {
|
|
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 Me(e, t) {
|
|
528
528
|
t.length !== 0 && console.log(`\n ${e}: ${t.length.toString()} loaded\n`);
|
|
529
529
|
}
|
|
530
|
-
var
|
|
530
|
+
var Ne = [
|
|
531
531
|
{
|
|
532
532
|
header: "Name",
|
|
533
533
|
value: (e) => e.name
|
|
@@ -542,13 +542,13 @@ var Pe = [
|
|
|
542
542
|
},
|
|
543
543
|
{
|
|
544
544
|
header: "Split",
|
|
545
|
-
value: (e) =>
|
|
545
|
+
value: (e) => he(e)
|
|
546
546
|
},
|
|
547
547
|
{
|
|
548
548
|
header: "Ver",
|
|
549
549
|
value: (e) => `v${e.version.toString()}`
|
|
550
550
|
}
|
|
551
|
-
],
|
|
551
|
+
], Pe = [
|
|
552
552
|
{
|
|
553
553
|
header: "Name",
|
|
554
554
|
value: (e) => e.name
|
|
@@ -569,7 +569,7 @@ var Pe = [
|
|
|
569
569
|
header: "Targets",
|
|
570
570
|
value: (e) => e.targets.length.toString()
|
|
571
571
|
}
|
|
572
|
-
],
|
|
572
|
+
], Fe = [
|
|
573
573
|
{
|
|
574
574
|
header: "Name",
|
|
575
575
|
value: (e) => e.name
|
|
@@ -582,7 +582,7 @@ var Pe = [
|
|
|
582
582
|
header: "Fields",
|
|
583
583
|
value: (e) => (e.fieldIds?.length ?? 0).toString()
|
|
584
584
|
}
|
|
585
|
-
],
|
|
585
|
+
], Ie = [
|
|
586
586
|
{
|
|
587
587
|
header: "Name",
|
|
588
588
|
value: (e) => e.name
|
|
@@ -599,125 +599,128 @@ var Pe = [
|
|
|
599
599
|
header: "Required",
|
|
600
600
|
value: (e) => e.required ? "yes" : "no"
|
|
601
601
|
}
|
|
602
|
-
],
|
|
602
|
+
], Le = [{
|
|
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.120-next.
|
|
609
|
+
function Re() {
|
|
610
|
+
return "0.0.120-next.2";
|
|
611
611
|
}
|
|
612
|
-
var
|
|
613
|
-
function
|
|
614
|
-
for (let t of Object.values(e)) if (t.type === "chunk" && t.moduleIds.includes(
|
|
612
|
+
var ze = "https://api.picked.app", X = "virtual:picked/data", Z = `\0${X}`, Be = `\0${J}`;
|
|
613
|
+
function Ve(e) {
|
|
614
|
+
for (let t of Object.values(e)) if (t.type === "chunk" && t.moduleIds.includes(Z)) return t.fileName;
|
|
615
615
|
}
|
|
616
|
-
function
|
|
616
|
+
function He(e, t) {
|
|
617
617
|
return e === "" || e.endsWith("/") ? `${e}${t}` : `${e}/${t}`;
|
|
618
618
|
}
|
|
619
|
-
async function
|
|
619
|
+
async function Ue(e) {
|
|
620
620
|
try {
|
|
621
621
|
let t = await o({
|
|
622
622
|
config: e,
|
|
623
623
|
onWarn: (e) => {
|
|
624
|
-
|
|
624
|
+
I.warn(e);
|
|
625
625
|
}
|
|
626
626
|
});
|
|
627
|
-
|
|
627
|
+
I.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
|
|
633
|
+
function We(e, t, n) {
|
|
634
634
|
return e && u(t, n) ? e : null;
|
|
635
635
|
}
|
|
636
|
-
async function
|
|
636
|
+
async function Ge(e, t) {
|
|
637
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 Q(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
|
-
async function
|
|
646
|
+
async function Ke(e) {
|
|
647
647
|
let t = await f(e);
|
|
648
648
|
return t && l(t) ? t : null;
|
|
649
649
|
}
|
|
650
|
-
function
|
|
651
|
-
e.data !== void 0 &&
|
|
650
|
+
function qe(e) {
|
|
651
|
+
e.data !== void 0 && I.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.");
|
|
652
652
|
let t = [];
|
|
653
653
|
if (e.projectId !== void 0 && t.push("`projectId`"), e.apiUrl !== void 0 && t.push("`apiUrl`"), t.length === 0) return;
|
|
654
654
|
let n = t.length > 1;
|
|
655
|
-
|
|
655
|
+
I.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.`);
|
|
656
656
|
}
|
|
657
|
-
async function
|
|
658
|
-
let n = await
|
|
659
|
-
n && n.projectId !== t &&
|
|
657
|
+
async function Je(e, t) {
|
|
658
|
+
let n = await Ke(e);
|
|
659
|
+
n && n.projectId !== t && I.warn(`using project "${t}" (picked.config default: "${n.projectId}") — run 'picked status' to inspect`);
|
|
660
660
|
}
|
|
661
|
-
async function
|
|
662
|
-
let n = await
|
|
663
|
-
return
|
|
661
|
+
async function Ye(e, t) {
|
|
662
|
+
let n = await Ke(e);
|
|
663
|
+
return Q("projectId", t.projectId, n?.projectId), Q("apiUrl", t.apiUrl, n?.apiUrl), Q("mode", t.data, n?.data, "data"), qe(t), Ge(e, t);
|
|
664
664
|
}
|
|
665
|
-
async function
|
|
666
|
-
if (t.data !== "snapshot") return e(h(t.projectRoot)) &&
|
|
665
|
+
async function Xe(t) {
|
|
666
|
+
if (t.data !== "snapshot") return e(h(t.projectRoot)) && I.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
667
|
let n = await m(t);
|
|
668
|
-
return
|
|
668
|
+
return I.info(`serving ${s}: project "${n.projectId}", version ${n.projectVersionId ?? "none (preview)"} — run \`picked pull\` to refresh`), n.source === "preview" ? I.warn(`${s} holds preview data, so this run serves unpublished content. Run \`picked pull\` against the published workspace before you release.`) : t.source === "preview" && I.warn(`the preview workspace in force is not read: ${s} holds published data. Run \`picked pull --allow-preview\` to serve the preview.`), n;
|
|
669
669
|
}
|
|
670
|
-
async function
|
|
670
|
+
async function Ze(e, t, n, r) {
|
|
671
671
|
let i = () => a(e, t, {
|
|
672
672
|
headers: n,
|
|
673
673
|
previewToken: r ?? void 0
|
|
674
674
|
});
|
|
675
|
-
return
|
|
676
|
-
|
|
675
|
+
return z(e) ? B(i, (e, t, n) => {
|
|
676
|
+
I.info(`local API not ready, retrying in ${(n / 1e3).toString()}s (${e.toString()}/${t.toString()})`);
|
|
677
677
|
}) : i();
|
|
678
678
|
}
|
|
679
|
-
var
|
|
680
|
-
function
|
|
679
|
+
var $ = /* @__PURE__ */ new Map();
|
|
680
|
+
function Qe(e, t, n) {
|
|
681
681
|
return JSON.stringify([
|
|
682
682
|
e,
|
|
683
683
|
t,
|
|
684
684
|
n
|
|
685
685
|
]);
|
|
686
686
|
}
|
|
687
|
-
function
|
|
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 :
|
|
689
|
-
return
|
|
687
|
+
function $e(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 : Ce();
|
|
689
|
+
return Te(x, {
|
|
690
690
|
name: "picked",
|
|
691
691
|
config: async (s, d) => {
|
|
692
692
|
f = d.command, u = s.root === void 0 ? process.cwd() : n(process.cwd(), s.root);
|
|
693
693
|
let { projectId: p, apiUrl: m } = t;
|
|
694
|
-
g = await
|
|
694
|
+
g = await Ye(u, {
|
|
695
695
|
projectId: p,
|
|
696
696
|
apiUrl: m,
|
|
697
697
|
data: i
|
|
698
698
|
});
|
|
699
699
|
let { projectId: h, apiUrl: S, previewToken: C } = g;
|
|
700
|
-
if (a = g.data, x =
|
|
701
|
-
S !==
|
|
702
|
-
let w = r("vite-plugin",
|
|
703
|
-
|
|
700
|
+
if (a = g.data, x = We(x, g, t.telemetry), I.banner(), o = await Xe(g), o && (l = V(o.projectConfig.features)), c && !_ && (_ = !0, await Ue(g)), a === "snapshot") return;
|
|
701
|
+
S !== ze && I.warn(`using custom API URL: ${S}`), await Je(u, h);
|
|
702
|
+
let w = r("vite-plugin", Re()), T = new Set(Object.keys(w).map((e) => e.toLowerCase())), E = {
|
|
703
|
+
...Object.fromEntries(Object.entries(t.customHeaders ?? {}).filter(([e]) => !T.has(e.toLowerCase()))),
|
|
704
|
+
...w
|
|
705
|
+
};
|
|
706
|
+
if (a === "api") I.debug("data is 'api': skipping the project-config prefetch");
|
|
704
707
|
else if (d.command === "build") {
|
|
705
|
-
let t =
|
|
708
|
+
let t = Qe(S, h, u);
|
|
706
709
|
v = t;
|
|
707
|
-
let n =
|
|
710
|
+
let n = $.get(t);
|
|
708
711
|
n === void 0 && (n = (async () => {
|
|
709
|
-
|
|
710
|
-
let t =
|
|
712
|
+
I.info(`prefetching project config + content for "${h}"`);
|
|
713
|
+
let t = U(u), n = e(t.pickedDir), r = performance.now(), i = await ye({
|
|
711
714
|
apiUrl: S,
|
|
712
715
|
projectId: h,
|
|
713
716
|
projectRoot: u,
|
|
714
|
-
headers:
|
|
717
|
+
headers: E,
|
|
715
718
|
previewToken: C ?? void 0
|
|
716
719
|
}), a = (performance.now() - r).toFixed(0);
|
|
717
|
-
await
|
|
720
|
+
await de(u, n);
|
|
718
721
|
let o = i.config;
|
|
719
|
-
return
|
|
720
|
-
virtualSource:
|
|
722
|
+
return et(o, a), {
|
|
723
|
+
virtualSource: De({
|
|
721
724
|
projectConfigPath: t.projectConfigPath,
|
|
722
725
|
experienceContentPaths: i.experienceContentPaths,
|
|
723
726
|
manifestMetadata: {
|
|
@@ -727,16 +730,16 @@ function et(t = {}) {
|
|
|
727
730
|
workspaceId: i.manifest.workspaceId
|
|
728
731
|
}
|
|
729
732
|
}),
|
|
730
|
-
features:
|
|
733
|
+
features: V(o.features)
|
|
731
734
|
};
|
|
732
|
-
})(), n.catch(() =>
|
|
735
|
+
})(), n.catch(() => $.delete(t)), $.set(t, n));
|
|
733
736
|
let r = await n;
|
|
734
737
|
y = r.virtualSource, l = r.features;
|
|
735
|
-
} else if (d.mode === "production")
|
|
738
|
+
} else if (d.mode === "production") I.debug("skipping the dev project-config fetch for a production serve resolution");
|
|
736
739
|
else {
|
|
737
|
-
|
|
738
|
-
let e = performance.now(), t = await
|
|
739
|
-
b = t, t ? (l =
|
|
740
|
+
I.info(`fetching project config for "${h}" (dev)`);
|
|
741
|
+
let e = performance.now(), t = await Ze(S, h, E, C), n = (performance.now() - e).toFixed(0);
|
|
742
|
+
b = t, t ? (l = V(t.features), et(t, n)) : I.warn(`failed to fetch project config for "${h}" (${n}ms)`);
|
|
740
743
|
}
|
|
741
744
|
},
|
|
742
745
|
configResolved(e) {
|
|
@@ -746,7 +749,7 @@ function et(t = {}) {
|
|
|
746
749
|
a === "snapshot" && g && f === "build" && (o = await m(g));
|
|
747
750
|
},
|
|
748
751
|
closeBundle() {
|
|
749
|
-
v !== void 0 &&
|
|
752
|
+
v !== void 0 && $.delete(v), x?.flush({
|
|
750
753
|
"picked.vite.command": f,
|
|
751
754
|
"picked.data.mode": a,
|
|
752
755
|
"picked.source": g?.source ?? "unknown"
|
|
@@ -756,9 +759,9 @@ function et(t = {}) {
|
|
|
756
759
|
order: "post",
|
|
757
760
|
handler(e, t) {
|
|
758
761
|
if (a === "api" || t.bundle === void 0) return;
|
|
759
|
-
let n =
|
|
762
|
+
let n = Ve(t.bundle);
|
|
760
763
|
if (n === void 0) return;
|
|
761
|
-
let r =
|
|
764
|
+
let r = He(p, n);
|
|
762
765
|
if (!e.includes(`"${r}"`)) return [{
|
|
763
766
|
tag: "link",
|
|
764
767
|
attrs: {
|
|
@@ -771,19 +774,19 @@ function et(t = {}) {
|
|
|
771
774
|
}
|
|
772
775
|
},
|
|
773
776
|
resolveId(e) {
|
|
774
|
-
if (e ===
|
|
777
|
+
if (e === X || e.startsWith("virtual:picked/data/experience/")) return `\0${e}`;
|
|
775
778
|
},
|
|
776
779
|
load(e) {
|
|
777
|
-
if (e.startsWith(
|
|
778
|
-
if (e ===
|
|
779
|
-
if (a === "api") return
|
|
780
|
+
if (e.startsWith(Be) && o && g) return this.addWatchFile(h(g.projectRoot)), Ae(o, e.slice(Be.length));
|
|
781
|
+
if (e === Z) {
|
|
782
|
+
if (a === "api") return Ee();
|
|
780
783
|
if (a === "snapshot") {
|
|
781
784
|
if (!o || !g) throw Error("picked plugin config hook must run before virtual module load");
|
|
782
|
-
return this.addWatchFile(h(g.projectRoot)),
|
|
785
|
+
return this.addWatchFile(h(g.projectRoot)), ke(o);
|
|
783
786
|
}
|
|
784
787
|
if (f === "build") return y;
|
|
785
788
|
if (!g) throw Error("picked plugin config hook must run before virtual module load");
|
|
786
|
-
return
|
|
789
|
+
return Oe({
|
|
787
790
|
apiUrl: g.apiUrl,
|
|
788
791
|
projectId: g.projectId,
|
|
789
792
|
projectConfig: b,
|
|
@@ -794,12 +797,12 @@ function et(t = {}) {
|
|
|
794
797
|
configureServer(e) {
|
|
795
798
|
if (a === "snapshot" && g) {
|
|
796
799
|
let t = h(g.projectRoot), n = (n) => {
|
|
797
|
-
n === t && (
|
|
800
|
+
n === t && (I.info(`${s} changed; restarting the dev server`), e.restart());
|
|
798
801
|
};
|
|
799
802
|
e.watcher.add(t), e.watcher.on("add", n), e.watcher.on("change", n), e.watcher.on("unlink", n);
|
|
800
803
|
}
|
|
801
804
|
if (t.disableLauncher) return;
|
|
802
|
-
e.middlewares.use(
|
|
805
|
+
e.middlewares.use(ue(() => re(l)));
|
|
803
806
|
let n = e.printUrls.bind(e);
|
|
804
807
|
e.printUrls = () => {
|
|
805
808
|
let t = e.resolvedUrls?.local[0];
|
|
@@ -813,17 +816,17 @@ function et(t = {}) {
|
|
|
813
816
|
generateBundle: {
|
|
814
817
|
order: "post",
|
|
815
818
|
handler(e, n) {
|
|
816
|
-
t.disableLauncher || ("index.html" in n ?
|
|
819
|
+
t.disableLauncher || ("index.html" in n ? I.debug("index.html came from the build; skipping the launcher page") : this.emitFile({
|
|
817
820
|
type: "asset",
|
|
818
821
|
fileName: "index.html",
|
|
819
|
-
source:
|
|
822
|
+
source: re(l)
|
|
820
823
|
}));
|
|
821
824
|
}
|
|
822
825
|
}
|
|
823
826
|
});
|
|
824
827
|
}
|
|
825
|
-
function
|
|
826
|
-
let n =
|
|
828
|
+
function et(e, t) {
|
|
829
|
+
let n = V(e.features), r = V(e.experiences), i = V(e.steps), a = V(e.fields), o = V(e.conditions), s = V(e.actions), c = JSON.stringify(e).length, l = [
|
|
827
830
|
`${n.length.toString()} features`,
|
|
828
831
|
`${r.length.toString()} experiences`,
|
|
829
832
|
`${i.length.toString()} steps`,
|
|
@@ -831,7 +834,7 @@ function $(e, t) {
|
|
|
831
834
|
`${o.length.toString()} conditions`,
|
|
832
835
|
`${s.length.toString()} actions`
|
|
833
836
|
].join(", ");
|
|
834
|
-
|
|
837
|
+
I.info(`fetched config in ${t}ms (${l})`), Y("Features", n, Ne), Y("Experiences", r, Pe), Y("Steps", i, Fe), Y("Fields", a, Ie), Y("Conditions", o, Le), Me("Actions", s), I.debug(`config size: ${c.toString()} bytes`);
|
|
835
838
|
}
|
|
836
839
|
//#endregion
|
|
837
|
-
export {
|
|
840
|
+
export { $e as picked };
|