@picked/vite-plugin-picked 0.0.73 → 0.0.74-next.1
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 +19 -18
- package/dist/esm/index.js +248 -187
- package/dist/types/index.d.ts +18 -5
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/launcher.d.ts +2 -1
- package/dist/types/launcher.d.ts.map +1 -1
- package/dist/types/prefetch.d.ts +3 -1
- package/dist/types/prefetch.d.ts.map +1 -1
- package/dist/types/virtual-module/dev.d.ts +2 -0
- package/dist/types/virtual-module/dev.d.ts.map +1 -1
- package/package.json +8 -2
package/dist/esm/index.js
CHANGED
|
@@ -1,28 +1,30 @@
|
|
|
1
1
|
import { existsSync as e } from "node:fs";
|
|
2
2
|
import { join as t, resolve as n } from "node:path";
|
|
3
|
-
import { createClientHeaders as r, fetchExperienceContent as i, fetchProject as a } from "@picked/client
|
|
4
|
-
import {
|
|
3
|
+
import { createClientHeaders as r, fetchExperienceContent as i, fetchProject as a } from "@picked/delivery-api-client";
|
|
4
|
+
import { generate as o } from "@picked/typegen";
|
|
5
|
+
import { loadPickedConfig as s, loadResolvedPickedConfig as c } from "@picked/config";
|
|
6
|
+
import { appendFile as l, mkdir as u, readFile as d, writeFile as f } from "node:fs/promises";
|
|
5
7
|
//#region \0@oxc-project+runtime@0.142.0/helpers/esm/taggedTemplateLiteral.js
|
|
6
|
-
function
|
|
8
|
+
function p(e, t) {
|
|
7
9
|
return t ||= e.slice(0), Object.freeze(Object.defineProperties(e, { raw: { value: Object.freeze(t) } }));
|
|
8
10
|
}
|
|
9
11
|
//#endregion
|
|
10
12
|
//#region src/launcher.ts
|
|
11
|
-
var
|
|
12
|
-
function
|
|
13
|
+
var m;
|
|
14
|
+
function h(e) {
|
|
13
15
|
let t = JSON.stringify(e), n = e.length > 0 ? e.map((e) => `
|
|
14
16
|
<div class="feature-row">
|
|
15
17
|
<label>
|
|
16
|
-
<input type="checkbox" data-feature-id="${
|
|
17
|
-
<span class="feature-name">${
|
|
18
|
-
<span class="feature-id">${
|
|
18
|
+
<input type="checkbox" data-feature-id="${_(e.id)}" checked>
|
|
19
|
+
<span class="feature-name">${g(e.name)}</span>
|
|
20
|
+
<span class="feature-id">${g(e.id)}</span>
|
|
19
21
|
</label>
|
|
20
|
-
<select data-value-for="${
|
|
22
|
+
<select data-value-for="${_(e.id)}">
|
|
21
23
|
<option value="true" selected>true</option>
|
|
22
24
|
<option value="false">false</option>
|
|
23
25
|
</select>
|
|
24
26
|
</div>`).join("") : "<p class=\"text no-features\">No features configured for this project.</p>";
|
|
25
|
-
return String.raw(
|
|
27
|
+
return String.raw(m ||= p([
|
|
26
28
|
"<!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 ",
|
|
27
29
|
"\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 = ",
|
|
28
30
|
";\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>"
|
|
@@ -32,46 +34,46 @@ function f(e) {
|
|
|
32
34
|
";\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>"
|
|
33
35
|
]), n, t);
|
|
34
36
|
}
|
|
35
|
-
function
|
|
37
|
+
function g(e) {
|
|
36
38
|
return e.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll("\"", """);
|
|
37
39
|
}
|
|
38
|
-
function
|
|
40
|
+
function _(e) {
|
|
39
41
|
return e.replaceAll("&", "&").replaceAll("\"", """).replaceAll("<", "<").replaceAll(">", ">");
|
|
40
42
|
}
|
|
41
43
|
//#endregion
|
|
42
44
|
//#region src/log.ts
|
|
43
|
-
var
|
|
44
|
-
function
|
|
45
|
+
var v = "picked", y = "\x1B[0m";
|
|
46
|
+
function b() {
|
|
45
47
|
let e = process.env.NO_COLOR;
|
|
46
48
|
return e === "1" || e === "true";
|
|
47
49
|
}
|
|
48
|
-
function
|
|
49
|
-
return (t) =>
|
|
50
|
+
function x(e) {
|
|
51
|
+
return (t) => b() ? t : `${e}${t}${y}`;
|
|
50
52
|
}
|
|
51
|
-
var
|
|
53
|
+
var S = [
|
|
52
54
|
"debug",
|
|
53
55
|
"info",
|
|
54
56
|
"warn",
|
|
55
57
|
"error",
|
|
56
58
|
"silent"
|
|
57
|
-
],
|
|
59
|
+
], C = {
|
|
58
60
|
debug: {
|
|
59
|
-
color:
|
|
61
|
+
color: x("\x1B[2m"),
|
|
60
62
|
log: console.debug,
|
|
61
63
|
enabled: !1
|
|
62
64
|
},
|
|
63
65
|
info: {
|
|
64
|
-
color:
|
|
66
|
+
color: x("\x1B[36m"),
|
|
65
67
|
log: console.log,
|
|
66
68
|
enabled: !0
|
|
67
69
|
},
|
|
68
70
|
warn: {
|
|
69
|
-
color:
|
|
71
|
+
color: x("\x1B[33m"),
|
|
70
72
|
log: console.warn,
|
|
71
73
|
enabled: !0
|
|
72
74
|
},
|
|
73
75
|
error: {
|
|
74
|
-
color:
|
|
76
|
+
color: x("\x1B[31m"),
|
|
75
77
|
log: console.error,
|
|
76
78
|
enabled: !0
|
|
77
79
|
},
|
|
@@ -80,52 +82,52 @@ var _ = [
|
|
|
80
82
|
enabled: !1
|
|
81
83
|
}
|
|
82
84
|
};
|
|
83
|
-
function
|
|
84
|
-
return `${(/* @__PURE__ */ new Date()).toLocaleTimeString()} [${t ? `${
|
|
85
|
+
function w(e, t) {
|
|
86
|
+
return `${(/* @__PURE__ */ new Date()).toLocaleTimeString()} [${t ? `${v}:${t}` : v}] ${e}`;
|
|
85
87
|
}
|
|
86
|
-
function
|
|
88
|
+
function T(e, t, n, r) {
|
|
87
89
|
if (!e.enabled) return;
|
|
88
|
-
let i =
|
|
90
|
+
let i = w(t, r);
|
|
89
91
|
e.log(e.color ? e.color(i) : i), n !== void 0 && e.log(n);
|
|
90
92
|
}
|
|
91
|
-
function
|
|
92
|
-
let t =
|
|
93
|
+
function E(e) {
|
|
94
|
+
let t = C[e], n = /* @__PURE__ */ new Set();
|
|
93
95
|
return Object.assign((e, n, r) => {
|
|
94
|
-
|
|
96
|
+
T(t, e, n, r);
|
|
95
97
|
}, { once(e, r, i) {
|
|
96
|
-
!t.enabled || n.has(e) || (n.add(e),
|
|
98
|
+
!t.enabled || n.has(e) || (n.add(e), T(t, e, r, i));
|
|
97
99
|
} });
|
|
98
100
|
}
|
|
99
|
-
function
|
|
100
|
-
let t =
|
|
101
|
+
function D(e) {
|
|
102
|
+
let t = S.indexOf(e);
|
|
101
103
|
if (t === -1) {
|
|
102
|
-
|
|
104
|
+
T(C.error, `invalid log level: ${e}`);
|
|
103
105
|
return;
|
|
104
106
|
}
|
|
105
|
-
for (let [e, n] of
|
|
107
|
+
for (let [e, n] of S.entries()) C[n].enabled = e >= t;
|
|
106
108
|
}
|
|
107
|
-
var
|
|
108
|
-
function
|
|
109
|
+
var O = x("\x1B[34m"), k = x("\x1B[36m");
|
|
110
|
+
function A() {
|
|
109
111
|
let e = [
|
|
110
|
-
` ${
|
|
111
|
-
`${
|
|
112
|
-
` ${
|
|
113
|
-
`${
|
|
112
|
+
` ${O("_")} ${k("_")} _ _ _`,
|
|
113
|
+
`${O("(_)")} ${k("(_)")} _ __(_)__| |_____ __| |`,
|
|
114
|
+
` ${O("_")} ${O("_")} | '_ \\ / _| / / -_) _\` |`,
|
|
115
|
+
`${O("(_)")} ${O("(_)")} | .__/_\\__|_\\_\\___\\__,_|`,
|
|
114
116
|
" |_|\n "
|
|
115
117
|
];
|
|
116
118
|
console.log(e.join("\n"));
|
|
117
119
|
}
|
|
118
|
-
var
|
|
119
|
-
banner:
|
|
120
|
-
debug:
|
|
121
|
-
info:
|
|
122
|
-
warn:
|
|
123
|
-
error:
|
|
124
|
-
setLevel:
|
|
120
|
+
var j = {
|
|
121
|
+
banner: A,
|
|
122
|
+
debug: E("debug"),
|
|
123
|
+
info: E("info"),
|
|
124
|
+
warn: E("warn"),
|
|
125
|
+
error: E("error"),
|
|
126
|
+
setLevel: D
|
|
125
127
|
};
|
|
126
128
|
//#endregion
|
|
127
129
|
//#region src/middleware.ts
|
|
128
|
-
function
|
|
130
|
+
function ee(e) {
|
|
129
131
|
return (t, n, r) => {
|
|
130
132
|
if (t.method !== "GET") {
|
|
131
133
|
r();
|
|
@@ -142,28 +144,28 @@ function re(e) {
|
|
|
142
144
|
}
|
|
143
145
|
//#endregion
|
|
144
146
|
//#region src/gitignore.ts
|
|
145
|
-
var
|
|
146
|
-
async function
|
|
147
|
+
var M = ".picked/";
|
|
148
|
+
async function te(n, r) {
|
|
147
149
|
if (r) return;
|
|
148
150
|
let i = t(n, ".gitignore");
|
|
149
151
|
if (!e(i)) {
|
|
150
|
-
await
|
|
152
|
+
await f(i, `${M}
|
|
151
153
|
`);
|
|
152
154
|
return;
|
|
153
155
|
}
|
|
154
|
-
let a = await
|
|
155
|
-
if (
|
|
156
|
-
let
|
|
156
|
+
let a = await d(i, "utf8");
|
|
157
|
+
if (ne(a)) return;
|
|
158
|
+
let o = `${a.length > 0 && !a.endsWith("\n") ? "\n" : ""}${M}
|
|
157
159
|
`;
|
|
158
|
-
await
|
|
160
|
+
await l(i, o);
|
|
159
161
|
}
|
|
160
|
-
function
|
|
161
|
-
return e.split(/\r?\n/).map((e) => e.trim()).some((e) => e ===
|
|
162
|
+
function ne(e) {
|
|
163
|
+
return e.split(/\r?\n/).map((e) => e.trim()).some((e) => e === M || e === ".picked");
|
|
162
164
|
}
|
|
163
165
|
//#endregion
|
|
164
166
|
//#region src/retry.ts
|
|
165
|
-
var
|
|
166
|
-
function
|
|
167
|
+
var N = 6, re = 5e3;
|
|
168
|
+
function P(e) {
|
|
167
169
|
let t;
|
|
168
170
|
try {
|
|
169
171
|
t = new URL(e).hostname;
|
|
@@ -172,12 +174,12 @@ function A(e) {
|
|
|
172
174
|
}
|
|
173
175
|
return t === "localhost" || t === "127.0.0.1" || t === "::1" || t === "[::1]" || t !== "api.picked.app" && t.endsWith(".picked.app");
|
|
174
176
|
}
|
|
175
|
-
function
|
|
177
|
+
function ie(e) {
|
|
176
178
|
return new Promise((t) => {
|
|
177
179
|
setTimeout(t, e);
|
|
178
180
|
});
|
|
179
181
|
}
|
|
180
|
-
async function
|
|
182
|
+
async function F(e, t) {
|
|
181
183
|
let n = null, r = null;
|
|
182
184
|
try {
|
|
183
185
|
n = await e();
|
|
@@ -185,9 +187,9 @@ async function j(e, t) {
|
|
|
185
187
|
r = e;
|
|
186
188
|
}
|
|
187
189
|
if (n !== null) return n;
|
|
188
|
-
for (let i = 1; i <=
|
|
189
|
-
let a =
|
|
190
|
-
t(i,
|
|
190
|
+
for (let i = 1; i <= N; i++) {
|
|
191
|
+
let a = re * 2 ** (i - 1);
|
|
192
|
+
t(i, N, a), await ie(a), r = null;
|
|
191
193
|
try {
|
|
192
194
|
n = await e();
|
|
193
195
|
} catch (e) {
|
|
@@ -200,13 +202,13 @@ async function j(e, t) {
|
|
|
200
202
|
}
|
|
201
203
|
//#endregion
|
|
202
204
|
//#region src/util.ts
|
|
203
|
-
function
|
|
205
|
+
function I(e) {
|
|
204
206
|
return Array.isArray(e) ? e : [];
|
|
205
207
|
}
|
|
206
208
|
//#endregion
|
|
207
209
|
//#region src/prefetch.ts
|
|
208
|
-
var
|
|
209
|
-
function
|
|
210
|
+
var L = 2;
|
|
211
|
+
function R(e) {
|
|
210
212
|
let n = t(e, ".picked");
|
|
211
213
|
return {
|
|
212
214
|
pickedDir: n,
|
|
@@ -215,90 +217,96 @@ function P(e) {
|
|
|
215
217
|
experiencesDir: t(n, "experiences")
|
|
216
218
|
};
|
|
217
219
|
}
|
|
218
|
-
async function
|
|
220
|
+
async function ae(t) {
|
|
219
221
|
if (!e(t)) return null;
|
|
220
222
|
try {
|
|
221
|
-
let e = await
|
|
222
|
-
return
|
|
223
|
+
let e = await d(t, "utf8"), n = JSON.parse(e);
|
|
224
|
+
return oe(n) ? n : null;
|
|
223
225
|
} catch {
|
|
224
226
|
return null;
|
|
225
227
|
}
|
|
226
228
|
}
|
|
227
|
-
function
|
|
229
|
+
function oe(e) {
|
|
228
230
|
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));
|
|
229
231
|
}
|
|
230
|
-
function
|
|
232
|
+
function z(e) {
|
|
231
233
|
let t = /* @__PURE__ */ new Set();
|
|
232
|
-
for (let n of
|
|
234
|
+
for (let n of I(e.steps)) n.layoutContentId && t.add(n.id);
|
|
233
235
|
if (t.size === 0) return [];
|
|
234
236
|
let n = [];
|
|
235
|
-
for (let r of
|
|
237
|
+
for (let r of I(e.experiences)) I(r.nodes).some((e) => e.type === "step" && t.has(e.stepId)) && n.push(r.id);
|
|
236
238
|
return n;
|
|
237
239
|
}
|
|
238
|
-
async function
|
|
239
|
-
let { apiUrl: r, projectId: i, projectRoot: a, headers: o, reuseWhenUnchanged: c = !0 } = n,
|
|
240
|
-
if (await
|
|
241
|
-
let t = await
|
|
242
|
-
if (t?.version ===
|
|
243
|
-
let n =
|
|
240
|
+
async function B(n) {
|
|
241
|
+
let { apiUrl: r, projectId: i, projectRoot: a, headers: o, previewToken: s, reuseWhenUnchanged: c = !0 } = n, l = R(a), d = await H(r, i, o, s), p = z(d);
|
|
242
|
+
if (await u(l.experiencesDir, { recursive: !0 }), await f(l.projectConfigPath, JSON.stringify(d, null, 2)), c) {
|
|
243
|
+
let t = await ae(l.manifestPath);
|
|
244
|
+
if (t?.version === L && t.projectVersionId === d.versionId && t.workspaceId === d.workspaceId) {
|
|
245
|
+
let n = V(l, p);
|
|
244
246
|
if (Object.values(n).every((t) => e(t))) return {
|
|
245
247
|
config: d,
|
|
246
248
|
manifest: t,
|
|
247
249
|
experienceContentPaths: n
|
|
248
250
|
};
|
|
249
|
-
|
|
251
|
+
j.info("a manifest-referenced content file is missing; refetching every experience");
|
|
250
252
|
}
|
|
251
253
|
}
|
|
252
|
-
let
|
|
253
|
-
for (let e of
|
|
254
|
-
let n = await
|
|
255
|
-
await
|
|
254
|
+
let m = (/* @__PURE__ */ new Date()).toISOString(), h = [];
|
|
255
|
+
for (let e of p) {
|
|
256
|
+
let n = await U(r, i, e, o, s), a = t(l.experiencesDir, `${e}.json`);
|
|
257
|
+
await f(a, JSON.stringify(n, null, 2)), h.push({
|
|
256
258
|
id: e,
|
|
257
|
-
fetchedAt:
|
|
259
|
+
fetchedAt: m
|
|
258
260
|
});
|
|
259
261
|
}
|
|
260
|
-
let
|
|
261
|
-
version:
|
|
262
|
-
fetchedAt:
|
|
262
|
+
let g = {
|
|
263
|
+
version: L,
|
|
264
|
+
fetchedAt: m,
|
|
263
265
|
projectVersionId: d.versionId,
|
|
264
266
|
workspaceId: d.workspaceId,
|
|
265
267
|
projectId: d.id,
|
|
266
|
-
experiences:
|
|
268
|
+
experiences: h
|
|
267
269
|
};
|
|
268
|
-
return await l
|
|
270
|
+
return await f(l.manifestPath, JSON.stringify(g, null, 2)), {
|
|
269
271
|
config: d,
|
|
270
|
-
manifest:
|
|
271
|
-
experienceContentPaths:
|
|
272
|
+
manifest: g,
|
|
273
|
+
experienceContentPaths: V(l, p)
|
|
272
274
|
};
|
|
273
275
|
}
|
|
274
|
-
function
|
|
276
|
+
function V(e, n) {
|
|
275
277
|
let r = {};
|
|
276
278
|
for (let i of n) r[i] = t(e.experiencesDir, `${i}.json`);
|
|
277
279
|
return r;
|
|
278
280
|
}
|
|
279
|
-
async function
|
|
280
|
-
let
|
|
281
|
+
async function H(e, t, n, r) {
|
|
282
|
+
let i = () => a(e, t, {
|
|
283
|
+
headers: n,
|
|
284
|
+
previewToken: r
|
|
285
|
+
}), o;
|
|
281
286
|
try {
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
}) : await
|
|
287
|
+
o = P(e) ? await F(i, (e, t, n) => {
|
|
288
|
+
j.info(`project config not ready, retrying in ${(n / 1e3).toString()}s (${e.toString()}/${t.toString()})`);
|
|
289
|
+
}) : await i();
|
|
285
290
|
} catch (n) {
|
|
286
|
-
throw Error(`[picked] Build-time fetch of project config failed for "${t}" at ${e}: ${
|
|
291
|
+
throw Error(`[picked] Build-time fetch of project config failed for "${t}" at ${e}: ${W(n)}`);
|
|
287
292
|
}
|
|
288
|
-
if (!
|
|
289
|
-
return
|
|
293
|
+
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.`);
|
|
294
|
+
return o;
|
|
290
295
|
}
|
|
291
|
-
async function
|
|
292
|
-
let
|
|
296
|
+
async function U(e, t, n, r, a) {
|
|
297
|
+
let o;
|
|
293
298
|
try {
|
|
294
|
-
|
|
299
|
+
o = await i(e, t, n, {
|
|
300
|
+
headers: r,
|
|
301
|
+
previewToken: a
|
|
302
|
+
});
|
|
295
303
|
} catch (t) {
|
|
296
|
-
throw Error(`[picked] Build-time fetch of content for experience "${n}" failed at ${e}: ${
|
|
304
|
+
throw Error(`[picked] Build-time fetch of content for experience "${n}" failed at ${e}: ${W(t)}`);
|
|
297
305
|
}
|
|
298
|
-
if (!
|
|
299
|
-
return
|
|
306
|
+
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.`);
|
|
307
|
+
return o;
|
|
300
308
|
}
|
|
301
|
-
function
|
|
309
|
+
function W(e) {
|
|
302
310
|
if (e instanceof Error) return e.message;
|
|
303
311
|
if (typeof e == "string") return e;
|
|
304
312
|
try {
|
|
@@ -309,12 +317,12 @@ function H(e) {
|
|
|
309
317
|
}
|
|
310
318
|
//#endregion
|
|
311
319
|
//#region src/virtual-module/api.ts
|
|
312
|
-
function
|
|
320
|
+
function G() {
|
|
313
321
|
return "export const manifestMetadata = {\n mode: 'api',\n fetchedAt: null,\n projectVersionId: null,\n workspaceId: null,\n}\n";
|
|
314
322
|
}
|
|
315
323
|
//#endregion
|
|
316
324
|
//#region src/virtual-module/build.ts
|
|
317
|
-
function
|
|
325
|
+
function K(e) {
|
|
318
326
|
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");
|
|
319
327
|
return `import { registerPickedBundle } from '@picked/client/plugins/dynamic-experiences'
|
|
320
328
|
import projectConfigJson from ${i(t)}
|
|
@@ -344,19 +352,20 @@ registerPickedBundle({ projectConfig, experienceContent, manifestMetadata })
|
|
|
344
352
|
}
|
|
345
353
|
//#endregion
|
|
346
354
|
//#region src/virtual-module/dev.ts
|
|
347
|
-
function
|
|
348
|
-
let { apiUrl: t, projectId: n, projectConfig: r } = e,
|
|
349
|
-
return `${
|
|
355
|
+
function se(e) {
|
|
356
|
+
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" : "";
|
|
357
|
+
return `${a}
|
|
350
358
|
|
|
351
359
|
const apiUrl = ${JSON.stringify(t)}
|
|
352
360
|
const projectId = ${JSON.stringify(n)}
|
|
361
|
+
const previewToken = ${JSON.stringify(i ?? null)}
|
|
353
362
|
|
|
354
|
-
${
|
|
363
|
+
${o}
|
|
355
364
|
|
|
356
365
|
export async function experienceContent(experience, options) {
|
|
357
366
|
const id = typeof experience === 'string' ? experience : experience?.id
|
|
358
367
|
if (!id) return null
|
|
359
|
-
return await fetchExperienceContent(apiUrl, projectId, id, options)
|
|
368
|
+
return await fetchExperienceContent(apiUrl, projectId, id, { previewToken: previewToken ?? undefined, ...options })
|
|
360
369
|
}
|
|
361
370
|
|
|
362
371
|
export const manifestMetadata = {
|
|
@@ -365,14 +374,14 @@ export const manifestMetadata = {
|
|
|
365
374
|
projectVersionId: projectConfig?.versionId ?? null,
|
|
366
375
|
workspaceId: projectConfig?.workspaceId ?? null,
|
|
367
376
|
}
|
|
368
|
-
${
|
|
377
|
+
${s}`;
|
|
369
378
|
}
|
|
370
379
|
//#endregion
|
|
371
380
|
//#region src/index.ts
|
|
372
|
-
var
|
|
373
|
-
function
|
|
381
|
+
var q = 5;
|
|
382
|
+
function J(e, t, n) {
|
|
374
383
|
if (t.length === 0) return;
|
|
375
|
-
if (t.length >
|
|
384
|
+
if (t.length > q) {
|
|
376
385
|
console.log(`\n ${e}: ${t.length.toString()} loaded\n`);
|
|
377
386
|
return;
|
|
378
387
|
}
|
|
@@ -387,10 +396,10 @@ function q(e, t, n) {
|
|
|
387
396
|
""
|
|
388
397
|
].join("\n"));
|
|
389
398
|
}
|
|
390
|
-
function
|
|
399
|
+
function ce(e, t) {
|
|
391
400
|
t.length !== 0 && console.log(`\n ${e}: ${t.length.toString()} loaded\n`);
|
|
392
401
|
}
|
|
393
|
-
var
|
|
402
|
+
var le = [
|
|
394
403
|
{
|
|
395
404
|
header: "Name",
|
|
396
405
|
value: (e) => e.name
|
|
@@ -411,7 +420,7 @@ var se = [
|
|
|
411
420
|
header: "Ver",
|
|
412
421
|
value: (e) => `v${e.version.toString()}`
|
|
413
422
|
}
|
|
414
|
-
],
|
|
423
|
+
], ue = [
|
|
415
424
|
{
|
|
416
425
|
header: "Name",
|
|
417
426
|
value: (e) => e.name
|
|
@@ -432,7 +441,7 @@ var se = [
|
|
|
432
441
|
header: "Targets",
|
|
433
442
|
value: (e) => e.targets.length.toString()
|
|
434
443
|
}
|
|
435
|
-
],
|
|
444
|
+
], de = [
|
|
436
445
|
{
|
|
437
446
|
header: "Name",
|
|
438
447
|
value: (e) => e.name
|
|
@@ -445,7 +454,7 @@ var se = [
|
|
|
445
454
|
header: "Fields",
|
|
446
455
|
value: (e) => (e.fieldIds?.length ?? 0).toString()
|
|
447
456
|
}
|
|
448
|
-
],
|
|
457
|
+
], fe = [
|
|
449
458
|
{
|
|
450
459
|
header: "Name",
|
|
451
460
|
value: (e) => e.name
|
|
@@ -462,91 +471,137 @@ var se = [
|
|
|
462
471
|
header: "Required",
|
|
463
472
|
value: (e) => e.required ? "yes" : "no"
|
|
464
473
|
}
|
|
465
|
-
],
|
|
474
|
+
], pe = [{
|
|
466
475
|
header: "Name",
|
|
467
476
|
value: (e) => e.name
|
|
468
477
|
}, {
|
|
469
478
|
header: "Key",
|
|
470
479
|
value: (e) => e.key
|
|
471
480
|
}];
|
|
472
|
-
function
|
|
473
|
-
return "0.0.
|
|
481
|
+
function me() {
|
|
482
|
+
return "0.0.74-next.1";
|
|
474
483
|
}
|
|
475
|
-
var
|
|
476
|
-
function
|
|
477
|
-
for (let t of Object.values(e)) if (t.type === "chunk" && t.moduleIds.includes(
|
|
484
|
+
var he = "https://api.picked.app", Y = "virtual:picked/data", X = `\0${Y}`;
|
|
485
|
+
function ge(e) {
|
|
486
|
+
for (let t of Object.values(e)) if (t.type === "chunk" && t.moduleIds.includes(X)) return t.fileName;
|
|
478
487
|
}
|
|
479
|
-
function
|
|
488
|
+
function _e(e, t) {
|
|
480
489
|
return e === "" || e.endsWith("/") ? `${e}${t}` : `${e}/${t}`;
|
|
481
490
|
}
|
|
491
|
+
async function ve(e) {
|
|
492
|
+
try {
|
|
493
|
+
let t = await o({
|
|
494
|
+
config: e,
|
|
495
|
+
onWarn: (e) => {
|
|
496
|
+
j.warn(e);
|
|
497
|
+
}
|
|
498
|
+
});
|
|
499
|
+
j.info(`generated types at ${t.typesOutput}`);
|
|
500
|
+
} catch (e) {
|
|
501
|
+
let t = e instanceof Error ? e.message : String(e);
|
|
502
|
+
throw Error(`type generation failed: ${t}. Fix the schema source, or set \`generateTypes: false\` on the picked plugin to skip it.`);
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
async function ye(e, t) {
|
|
506
|
+
let n = await c(e, t);
|
|
507
|
+
if (!n) throw Error("picked.config.{ts,js,json} is required. Add a picked.config.ts with projectId and apiUrl.");
|
|
508
|
+
return n;
|
|
509
|
+
}
|
|
510
|
+
function Z(e, t, n) {
|
|
511
|
+
if (t !== void 0 && n !== void 0 && t !== n) throw Error(`picked plugin option \`${e}\` is "${t}", and picked.config says "${n}". Remove the plugin option; picked.config is the one place this belongs.`);
|
|
512
|
+
}
|
|
513
|
+
function be(e) {
|
|
514
|
+
let t = [];
|
|
515
|
+
if (e.projectId !== void 0 && t.push("`projectId`"), e.apiUrl !== void 0 && t.push("`apiUrl`"), t.length === 0) return;
|
|
516
|
+
let n = t.length > 1;
|
|
517
|
+
j.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.`);
|
|
518
|
+
}
|
|
519
|
+
async function xe(e, t) {
|
|
520
|
+
let n = await s(e);
|
|
521
|
+
n && n.projectId !== t && j.warn(`using project "${t}" (picked.config default: "${n.projectId}") — run 'picked status' to inspect`);
|
|
522
|
+
}
|
|
482
523
|
var Q = /* @__PURE__ */ new Map();
|
|
483
|
-
function
|
|
524
|
+
function Se(e, t, n) {
|
|
484
525
|
return JSON.stringify([
|
|
485
526
|
e,
|
|
486
527
|
t,
|
|
487
528
|
n
|
|
488
529
|
]);
|
|
489
530
|
}
|
|
490
|
-
function
|
|
491
|
-
let i = t.
|
|
531
|
+
function Ce(t = {}) {
|
|
532
|
+
let i = t.mode ?? "bundle", o = t.generateTypes ?? !0, c = [], l = process.cwd(), u = "serve", d = "/", f = null, p = !1, m, g, _ = null;
|
|
492
533
|
return {
|
|
493
534
|
name: "picked",
|
|
494
|
-
config: async (
|
|
495
|
-
|
|
496
|
-
let
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
535
|
+
config: async (d, h) => {
|
|
536
|
+
u = h.command, l = d.root === void 0 ? process.cwd() : n(process.cwd(), d.root);
|
|
537
|
+
let { projectId: v, apiUrl: y } = t, b = await s(l);
|
|
538
|
+
Z("projectId", v, b?.projectId), Z("apiUrl", y, b?.apiUrl), be({
|
|
539
|
+
projectId: v,
|
|
540
|
+
apiUrl: y
|
|
541
|
+
}), f = await ye(l, {
|
|
542
|
+
projectId: v,
|
|
543
|
+
apiUrl: y
|
|
544
|
+
});
|
|
545
|
+
let { projectId: x, apiUrl: S, previewToken: C } = f;
|
|
546
|
+
j.banner(), o && !p && (p = !0, await ve(f)), S !== he && j.warn(`using custom API URL: ${S}`), await xe(l, x);
|
|
547
|
+
let w = r("vite-plugin", me());
|
|
548
|
+
if (i === "api") j.debug("mode is 'api': skipping the project-config prefetch");
|
|
549
|
+
else if (h.command === "build") {
|
|
550
|
+
let t = Se(S, x, l);
|
|
551
|
+
m = t;
|
|
552
|
+
let n = Q.get(t);
|
|
553
|
+
n === void 0 && (n = (async () => {
|
|
554
|
+
j.info(`prefetching project config + content for "${x}"`);
|
|
555
|
+
let t = R(l), n = e(t.pickedDir), r = performance.now(), i = await B({
|
|
556
|
+
apiUrl: S,
|
|
557
|
+
projectId: x,
|
|
558
|
+
projectRoot: l,
|
|
559
|
+
headers: w,
|
|
560
|
+
previewToken: C ?? void 0
|
|
561
|
+
}), a = (performance.now() - r).toFixed(0);
|
|
562
|
+
await te(l, n);
|
|
563
|
+
let o = i.config;
|
|
564
|
+
return $(o, a), {
|
|
565
|
+
virtualSource: K({
|
|
566
|
+
projectConfigPath: t.projectConfigPath,
|
|
567
|
+
experienceContentPaths: i.experienceContentPaths,
|
|
516
568
|
manifestMetadata: {
|
|
517
569
|
mode: "build",
|
|
518
|
-
fetchedAt:
|
|
519
|
-
projectVersionId:
|
|
520
|
-
workspaceId:
|
|
570
|
+
fetchedAt: i.manifest.fetchedAt,
|
|
571
|
+
projectVersionId: i.manifest.projectVersionId,
|
|
572
|
+
workspaceId: i.manifest.workspaceId
|
|
521
573
|
}
|
|
522
574
|
}),
|
|
523
|
-
features:
|
|
575
|
+
features: I(o.features)
|
|
524
576
|
};
|
|
525
|
-
})(),
|
|
526
|
-
let
|
|
527
|
-
|
|
528
|
-
} else if (
|
|
577
|
+
})(), n.catch(() => Q.delete(t)), Q.set(t, n));
|
|
578
|
+
let r = await n;
|
|
579
|
+
g = r.virtualSource, c = r.features;
|
|
580
|
+
} else if (h.mode === "production") j.debug("skipping the dev project-config fetch for a production serve resolution");
|
|
529
581
|
else {
|
|
530
|
-
|
|
531
|
-
let e = performance.now(),
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
582
|
+
j.info(`fetching project config for "${x}" (dev)`);
|
|
583
|
+
let e = performance.now(), t = () => a(S, x, {
|
|
584
|
+
headers: w,
|
|
585
|
+
previewToken: C ?? void 0
|
|
586
|
+
}), n = P(S) ? await F(t, (e, t, n) => {
|
|
587
|
+
j.info(`local API not ready, retrying in ${(n / 1e3).toString()}s (${e.toString()}/${t.toString()})`);
|
|
588
|
+
}) : await t(), r = (performance.now() - e).toFixed(0);
|
|
589
|
+
_ = n, n ? (c = I(n.features), $(n, r)) : j.warn(`failed to fetch project config for "${x}" (${r}ms)`);
|
|
535
590
|
}
|
|
536
591
|
},
|
|
537
592
|
configResolved(e) {
|
|
538
|
-
|
|
593
|
+
d = e.base;
|
|
539
594
|
},
|
|
540
595
|
closeBundle() {
|
|
541
|
-
|
|
596
|
+
m !== void 0 && Q.delete(m);
|
|
542
597
|
},
|
|
543
598
|
transformIndexHtml: {
|
|
544
599
|
order: "post",
|
|
545
600
|
handler(e, t) {
|
|
546
|
-
if (
|
|
547
|
-
let n =
|
|
601
|
+
if (i === "api" || t.bundle === void 0) return;
|
|
602
|
+
let n = ge(t.bundle);
|
|
548
603
|
if (n === void 0) return;
|
|
549
|
-
let r =
|
|
604
|
+
let r = _e(d, n);
|
|
550
605
|
if (!e.includes(`"${r}"`)) return [{
|
|
551
606
|
tag: "link",
|
|
552
607
|
attrs: {
|
|
@@ -559,18 +614,24 @@ function he(t) {
|
|
|
559
614
|
}
|
|
560
615
|
},
|
|
561
616
|
resolveId(e) {
|
|
562
|
-
if (e ===
|
|
617
|
+
if (e === Y) return X;
|
|
563
618
|
},
|
|
564
619
|
load(e) {
|
|
565
|
-
if (e ===
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
620
|
+
if (e === X) {
|
|
621
|
+
if (i === "api") return G();
|
|
622
|
+
if (u === "build") return g;
|
|
623
|
+
if (!f) throw Error("picked plugin config hook must run before virtual module load");
|
|
624
|
+
return se({
|
|
625
|
+
apiUrl: f.apiUrl,
|
|
626
|
+
projectId: f.projectId,
|
|
627
|
+
projectConfig: _,
|
|
628
|
+
previewToken: f.previewToken ?? void 0
|
|
629
|
+
});
|
|
630
|
+
}
|
|
570
631
|
},
|
|
571
632
|
configureServer(e) {
|
|
572
633
|
if (t.disableLauncher) return;
|
|
573
|
-
e.middlewares.use(
|
|
634
|
+
e.middlewares.use(ee(() => h(c)));
|
|
574
635
|
let n = e.printUrls.bind(e);
|
|
575
636
|
e.printUrls = () => {
|
|
576
637
|
let t = e.resolvedUrls?.local[0];
|
|
@@ -586,13 +647,13 @@ function he(t) {
|
|
|
586
647
|
handler(e, n) {
|
|
587
648
|
if (!t.disableLauncher) {
|
|
588
649
|
if ("index.html" in n) {
|
|
589
|
-
|
|
650
|
+
j.debug("index.html came from the build; skipping the launcher page");
|
|
590
651
|
return;
|
|
591
652
|
}
|
|
592
653
|
this.emitFile({
|
|
593
654
|
type: "asset",
|
|
594
655
|
fileName: "index.html",
|
|
595
|
-
source:
|
|
656
|
+
source: h(c)
|
|
596
657
|
});
|
|
597
658
|
}
|
|
598
659
|
}
|
|
@@ -600,7 +661,7 @@ function he(t) {
|
|
|
600
661
|
};
|
|
601
662
|
}
|
|
602
663
|
function $(e, t) {
|
|
603
|
-
let n =
|
|
664
|
+
let n = I(e.features), r = I(e.experiences), i = I(e.steps), a = I(e.fields), o = I(e.conditions), s = I(e.actions), c = JSON.stringify(e).length, l = [
|
|
604
665
|
`${n.length.toString()} features`,
|
|
605
666
|
`${r.length.toString()} experiences`,
|
|
606
667
|
`${i.length.toString()} steps`,
|
|
@@ -608,7 +669,7 @@ function $(e, t) {
|
|
|
608
669
|
`${o.length.toString()} conditions`,
|
|
609
670
|
`${s.length.toString()} actions`
|
|
610
671
|
].join(", ");
|
|
611
|
-
|
|
672
|
+
j.info(`fetched config in ${t}ms (${l})`), J("Features", n, le), J("Experiences", r, ue), J("Steps", i, de), J("Fields", a, fe), J("Conditions", o, pe), ce("Actions", s), j.debug(`config size: ${c.toString()} bytes`);
|
|
612
673
|
}
|
|
613
674
|
//#endregion
|
|
614
|
-
export {
|
|
675
|
+
export { Ce as picked };
|