@picked/vite-plugin-picked 0.0.1-dev.1786405786333 → 0.0.1-dev.1786675074931
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 +222 -183
- package/dist/types/index.d.ts +7 -6
- 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 +9 -3
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 ee() {
|
|
45
47
|
let e = process.env.NO_COLOR;
|
|
46
48
|
return e === "1" || e === "true";
|
|
47
49
|
}
|
|
48
|
-
function
|
|
49
|
-
return (t) =>
|
|
50
|
+
function b(e) {
|
|
51
|
+
return (t) => ee() ? t : `${e}${t}${y}`;
|
|
50
52
|
}
|
|
51
|
-
var
|
|
53
|
+
var x = [
|
|
52
54
|
"debug",
|
|
53
55
|
"info",
|
|
54
56
|
"warn",
|
|
55
57
|
"error",
|
|
56
58
|
"silent"
|
|
57
|
-
],
|
|
59
|
+
], S = {
|
|
58
60
|
debug: {
|
|
59
|
-
color:
|
|
61
|
+
color: b("\x1B[2m"),
|
|
60
62
|
log: console.debug,
|
|
61
63
|
enabled: !1
|
|
62
64
|
},
|
|
63
65
|
info: {
|
|
64
|
-
color:
|
|
66
|
+
color: b("\x1B[36m"),
|
|
65
67
|
log: console.log,
|
|
66
68
|
enabled: !0
|
|
67
69
|
},
|
|
68
70
|
warn: {
|
|
69
|
-
color:
|
|
71
|
+
color: b("\x1B[33m"),
|
|
70
72
|
log: console.warn,
|
|
71
73
|
enabled: !0
|
|
72
74
|
},
|
|
73
75
|
error: {
|
|
74
|
-
color:
|
|
76
|
+
color: b("\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 te(e, t) {
|
|
86
|
+
return `${(/* @__PURE__ */ new Date()).toLocaleTimeString()} [${t ? `${v}:${t}` : v}] ${e}`;
|
|
85
87
|
}
|
|
86
|
-
function
|
|
88
|
+
function C(e, t, n, r) {
|
|
87
89
|
if (!e.enabled) return;
|
|
88
|
-
let i =
|
|
90
|
+
let i = te(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 w(e) {
|
|
94
|
+
let t = S[e], n = /* @__PURE__ */ new Set();
|
|
93
95
|
return Object.assign((e, n, r) => {
|
|
94
|
-
|
|
96
|
+
C(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), C(t, e, r, i));
|
|
97
99
|
} });
|
|
98
100
|
}
|
|
99
|
-
function
|
|
100
|
-
let t =
|
|
101
|
+
function ne(e) {
|
|
102
|
+
let t = x.indexOf(e);
|
|
101
103
|
if (t === -1) {
|
|
102
|
-
|
|
104
|
+
C(S.error, `invalid log level: ${e}`);
|
|
103
105
|
return;
|
|
104
106
|
}
|
|
105
|
-
for (let [e, n] of
|
|
107
|
+
for (let [e, n] of x.entries()) S[n].enabled = e >= t;
|
|
106
108
|
}
|
|
107
|
-
var
|
|
108
|
-
function
|
|
109
|
+
var T = b("\x1B[34m"), E = b("\x1B[36m");
|
|
110
|
+
function re() {
|
|
109
111
|
let e = [
|
|
110
|
-
` ${
|
|
111
|
-
`${
|
|
112
|
-
` ${
|
|
113
|
-
`${
|
|
112
|
+
` ${T("_")} ${E("_")} _ _ _`,
|
|
113
|
+
`${T("(_)")} ${E("(_)")} _ __(_)__| |_____ __| |`,
|
|
114
|
+
` ${T("_")} ${T("_")} | '_ \\ / _| / / -_) _\` |`,
|
|
115
|
+
`${T("(_)")} ${T("(_)")} | .__/_\\__|_\\_\\___\\__,_|`,
|
|
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 D = {
|
|
121
|
+
banner: re,
|
|
122
|
+
debug: w("debug"),
|
|
123
|
+
info: w("info"),
|
|
124
|
+
warn: w("warn"),
|
|
125
|
+
error: w("error"),
|
|
126
|
+
setLevel: ne
|
|
125
127
|
};
|
|
126
128
|
//#endregion
|
|
127
129
|
//#region src/middleware.ts
|
|
128
|
-
function
|
|
130
|
+
function O(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 k = ".picked/";
|
|
148
|
+
async function ie(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, `${k}
|
|
151
153
|
`);
|
|
152
154
|
return;
|
|
153
155
|
}
|
|
154
|
-
let a = await
|
|
155
|
-
if (
|
|
156
|
-
let
|
|
156
|
+
let a = await d(i, "utf8");
|
|
157
|
+
if (A(a)) return;
|
|
158
|
+
let o = `${a.length > 0 && !a.endsWith("\n") ? "\n" : ""}${k}
|
|
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 A(e) {
|
|
163
|
+
return e.split(/\r?\n/).map((e) => e.trim()).some((e) => e === k || e === ".picked");
|
|
162
164
|
}
|
|
163
165
|
//#endregion
|
|
164
166
|
//#region src/retry.ts
|
|
165
|
-
var
|
|
166
|
-
function
|
|
167
|
+
var j = 6, ae = 5e3;
|
|
168
|
+
function M(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 N(e) {
|
|
176
178
|
return new Promise((t) => {
|
|
177
179
|
setTimeout(t, e);
|
|
178
180
|
});
|
|
179
181
|
}
|
|
180
|
-
async function
|
|
182
|
+
async function P(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 <= j; i++) {
|
|
191
|
+
let a = ae * 2 ** (i - 1);
|
|
192
|
+
t(i, j, a), await N(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 F(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 I = 2;
|
|
211
|
+
function L(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 R(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 z(n) ? n : null;
|
|
223
225
|
} catch {
|
|
224
226
|
return null;
|
|
225
227
|
}
|
|
226
228
|
}
|
|
227
|
-
function
|
|
229
|
+
function z(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 B(e) {
|
|
231
233
|
let t = /* @__PURE__ */ new Set();
|
|
232
|
-
for (let n of
|
|
234
|
+
for (let n of F(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 F(e.experiences)) F(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 V(n) {
|
|
241
|
+
let { apiUrl: r, projectId: i, projectRoot: a, headers: o, previewToken: s, reuseWhenUnchanged: c = !0 } = n, l = L(a), d = await U(r, i, o, s), p = B(d);
|
|
242
|
+
if (await u(l.experiencesDir, { recursive: !0 }), await f(l.projectConfigPath, JSON.stringify(d, null, 2)), c) {
|
|
243
|
+
let t = await R(l.manifestPath);
|
|
244
|
+
if (t?.version === I && t.projectVersionId === d.versionId && t.workspaceId === d.workspaceId) {
|
|
245
|
+
let n = H(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
|
+
D.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 W(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: I,
|
|
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: H(l, p)
|
|
272
274
|
};
|
|
273
275
|
}
|
|
274
|
-
function
|
|
276
|
+
function H(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 U(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 = M(e) ? await P(i, (e, t, n) => {
|
|
288
|
+
D.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}: ${G(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 W(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}: ${G(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 G(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 K() {
|
|
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 q(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 J(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 oe = 5;
|
|
382
|
+
function Y(e, t, n) {
|
|
374
383
|
if (t.length === 0) return;
|
|
375
|
-
if (t.length >
|
|
384
|
+
if (t.length > oe) {
|
|
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 se(e, t) {
|
|
391
400
|
t.length !== 0 && console.log(`\n ${e}: ${t.length.toString()} loaded\n`);
|
|
392
401
|
}
|
|
393
|
-
var
|
|
402
|
+
var ce = [
|
|
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
|
+
], le = [
|
|
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
|
+
], ue = [
|
|
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
|
+
], de = [
|
|
449
458
|
{
|
|
450
459
|
header: "Name",
|
|
451
460
|
value: (e) => e.name
|
|
@@ -462,91 +471,115 @@ var se = [
|
|
|
462
471
|
header: "Required",
|
|
463
472
|
value: (e) => e.required ? "yes" : "no"
|
|
464
473
|
}
|
|
465
|
-
],
|
|
474
|
+
], fe = [{
|
|
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.1-dev.
|
|
481
|
+
function pe() {
|
|
482
|
+
return "0.0.1-dev.1786675074931";
|
|
474
483
|
}
|
|
475
|
-
var
|
|
476
|
-
function
|
|
484
|
+
var me = "https://api.picked.app", X = "virtual:picked/data", Z = `\0${X}`;
|
|
485
|
+
function he(e) {
|
|
477
486
|
for (let t of Object.values(e)) if (t.type === "chunk" && t.moduleIds.includes(Z)) return t.fileName;
|
|
478
487
|
}
|
|
479
|
-
function
|
|
488
|
+
function ge(e, t) {
|
|
480
489
|
return e === "" || e.endsWith("/") ? `${e}${t}` : `${e}/${t}`;
|
|
481
490
|
}
|
|
491
|
+
async function _e(e) {
|
|
492
|
+
try {
|
|
493
|
+
let t = await o({ config: e });
|
|
494
|
+
D.info(`generated types at ${t.typesOutput}`);
|
|
495
|
+
} catch (e) {
|
|
496
|
+
let t = e instanceof Error ? e.message : String(e);
|
|
497
|
+
D.warn(`type generation failed: ${t}`);
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
async function ve(e) {
|
|
501
|
+
let t = await c(e);
|
|
502
|
+
if (!t) throw Error("picked.config.{ts,js,json} is required. Add a picked.config.ts with projectId and apiUrl.");
|
|
503
|
+
return t;
|
|
504
|
+
}
|
|
505
|
+
async function ye(e, t) {
|
|
506
|
+
let n = await s(e);
|
|
507
|
+
n && n.projectId !== t && D.warn(`using project "${t}" (picked.config default: "${n.projectId}") — run 'picked status' to inspect`);
|
|
508
|
+
}
|
|
482
509
|
var Q = /* @__PURE__ */ new Map();
|
|
483
|
-
function
|
|
510
|
+
function be(e, t, n) {
|
|
484
511
|
return JSON.stringify([
|
|
485
512
|
e,
|
|
486
513
|
t,
|
|
487
514
|
n
|
|
488
515
|
]);
|
|
489
516
|
}
|
|
490
|
-
function
|
|
491
|
-
let i = t.
|
|
517
|
+
function xe(t = {}) {
|
|
518
|
+
let i = t.mode ?? "bundle", o = t.generateTypes ?? !0, s = [], c = process.cwd(), l = "serve", u = "/", d = null, f = !1, p, m, g = null;
|
|
492
519
|
return {
|
|
493
520
|
name: "picked",
|
|
494
|
-
config: async (
|
|
495
|
-
l =
|
|
496
|
-
let h
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
let
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
521
|
+
config: async (t, u) => {
|
|
522
|
+
l = u.command, c = t.root === void 0 ? process.cwd() : n(process.cwd(), t.root), d = await ve(c);
|
|
523
|
+
let { projectId: h, apiUrl: _, previewToken: v } = d;
|
|
524
|
+
D.banner(), o && !f && (f = !0, await _e(d)), _ !== me && D.warn(`using custom API URL: ${_}`), await ye(c, h);
|
|
525
|
+
let y = r("vite-plugin", pe());
|
|
526
|
+
if (i === "api") D.debug("mode is 'api': skipping the project-config prefetch");
|
|
527
|
+
else if (u.command === "build") {
|
|
528
|
+
let t = be(_, h, c);
|
|
529
|
+
p = t;
|
|
530
|
+
let n = Q.get(t);
|
|
531
|
+
n === void 0 && (n = (async () => {
|
|
532
|
+
D.info(`prefetching project config + content for "${h}"`);
|
|
533
|
+
let t = L(c), n = e(t.pickedDir), r = performance.now(), i = await V({
|
|
534
|
+
apiUrl: _,
|
|
535
|
+
projectId: h,
|
|
507
536
|
projectRoot: c,
|
|
508
|
-
headers:
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
537
|
+
headers: y,
|
|
538
|
+
previewToken: v ?? void 0
|
|
539
|
+
}), a = (performance.now() - r).toFixed(0);
|
|
540
|
+
await ie(c, n);
|
|
541
|
+
let o = i.config;
|
|
542
|
+
return $(o, a), {
|
|
543
|
+
virtualSource: q({
|
|
544
|
+
projectConfigPath: t.projectConfigPath,
|
|
545
|
+
experienceContentPaths: i.experienceContentPaths,
|
|
516
546
|
manifestMetadata: {
|
|
517
547
|
mode: "build",
|
|
518
|
-
fetchedAt:
|
|
519
|
-
projectVersionId:
|
|
520
|
-
workspaceId:
|
|
548
|
+
fetchedAt: i.manifest.fetchedAt,
|
|
549
|
+
projectVersionId: i.manifest.projectVersionId,
|
|
550
|
+
workspaceId: i.manifest.workspaceId
|
|
521
551
|
}
|
|
522
552
|
}),
|
|
523
|
-
features:
|
|
553
|
+
features: F(o.features)
|
|
524
554
|
};
|
|
525
|
-
})(),
|
|
526
|
-
let
|
|
527
|
-
|
|
528
|
-
} else if (
|
|
555
|
+
})(), n.catch(() => Q.delete(t)), Q.set(t, n));
|
|
556
|
+
let r = await n;
|
|
557
|
+
m = r.virtualSource, s = r.features;
|
|
558
|
+
} else if (u.mode === "production") D.debug("skipping the dev project-config fetch for a production serve resolution");
|
|
529
559
|
else {
|
|
530
|
-
|
|
531
|
-
let e = performance.now(),
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
560
|
+
D.info(`fetching project config for "${h}" (dev)`);
|
|
561
|
+
let e = performance.now(), t = () => a(_, h, {
|
|
562
|
+
headers: y,
|
|
563
|
+
previewToken: v ?? void 0
|
|
564
|
+
}), n = M(_) ? await P(t, (e, t, n) => {
|
|
565
|
+
D.info(`local API not ready, retrying in ${(n / 1e3).toString()}s (${e.toString()}/${t.toString()})`);
|
|
566
|
+
}) : await t(), r = (performance.now() - e).toFixed(0);
|
|
567
|
+
g = n, n ? (s = F(n.features), $(n, r)) : D.warn(`failed to fetch project config for "${h}" (${r}ms)`);
|
|
535
568
|
}
|
|
536
569
|
},
|
|
537
570
|
configResolved(e) {
|
|
538
571
|
u = e.base;
|
|
539
572
|
},
|
|
540
573
|
closeBundle() {
|
|
541
|
-
|
|
574
|
+
p !== void 0 && Q.delete(p);
|
|
542
575
|
},
|
|
543
576
|
transformIndexHtml: {
|
|
544
577
|
order: "post",
|
|
545
578
|
handler(e, t) {
|
|
546
|
-
if (
|
|
547
|
-
let n =
|
|
579
|
+
if (i === "api" || t.bundle === void 0) return;
|
|
580
|
+
let n = he(t.bundle);
|
|
548
581
|
if (n === void 0) return;
|
|
549
|
-
let r =
|
|
582
|
+
let r = ge(u, n);
|
|
550
583
|
if (!e.includes(`"${r}"`)) return [{
|
|
551
584
|
tag: "link",
|
|
552
585
|
attrs: {
|
|
@@ -562,15 +595,21 @@ function he(t) {
|
|
|
562
595
|
if (e === X) return Z;
|
|
563
596
|
},
|
|
564
597
|
load(e) {
|
|
565
|
-
if (e === Z)
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
598
|
+
if (e === Z) {
|
|
599
|
+
if (i === "api") return K();
|
|
600
|
+
if (l === "build") return m;
|
|
601
|
+
if (!d) throw Error("picked plugin config hook must run before virtual module load");
|
|
602
|
+
return J({
|
|
603
|
+
apiUrl: d.apiUrl,
|
|
604
|
+
projectId: d.projectId,
|
|
605
|
+
projectConfig: g,
|
|
606
|
+
previewToken: d.previewToken ?? void 0
|
|
607
|
+
});
|
|
608
|
+
}
|
|
570
609
|
},
|
|
571
610
|
configureServer(e) {
|
|
572
611
|
if (t.disableLauncher) return;
|
|
573
|
-
e.middlewares.use(
|
|
612
|
+
e.middlewares.use(O(() => h(s)));
|
|
574
613
|
let n = e.printUrls.bind(e);
|
|
575
614
|
e.printUrls = () => {
|
|
576
615
|
let t = e.resolvedUrls?.local[0];
|
|
@@ -586,13 +625,13 @@ function he(t) {
|
|
|
586
625
|
handler(e, n) {
|
|
587
626
|
if (!t.disableLauncher) {
|
|
588
627
|
if ("index.html" in n) {
|
|
589
|
-
|
|
628
|
+
D.debug("index.html came from the build; skipping the launcher page");
|
|
590
629
|
return;
|
|
591
630
|
}
|
|
592
631
|
this.emitFile({
|
|
593
632
|
type: "asset",
|
|
594
633
|
fileName: "index.html",
|
|
595
|
-
source:
|
|
634
|
+
source: h(s)
|
|
596
635
|
});
|
|
597
636
|
}
|
|
598
637
|
}
|
|
@@ -600,7 +639,7 @@ function he(t) {
|
|
|
600
639
|
};
|
|
601
640
|
}
|
|
602
641
|
function $(e, t) {
|
|
603
|
-
let n =
|
|
642
|
+
let n = F(e.features), r = F(e.experiences), i = F(e.steps), a = F(e.fields), o = F(e.conditions), s = F(e.actions), c = JSON.stringify(e).length, l = [
|
|
604
643
|
`${n.length.toString()} features`,
|
|
605
644
|
`${r.length.toString()} experiences`,
|
|
606
645
|
`${i.length.toString()} steps`,
|
|
@@ -608,7 +647,7 @@ function $(e, t) {
|
|
|
608
647
|
`${o.length.toString()} conditions`,
|
|
609
648
|
`${s.length.toString()} actions`
|
|
610
649
|
].join(", ");
|
|
611
|
-
|
|
650
|
+
D.info(`fetched config in ${t}ms (${l})`), Y("Features", n, ce), Y("Experiences", r, le), Y("Steps", i, ue), Y("Fields", a, de), Y("Conditions", o, fe), se("Actions", s), D.debug(`config size: ${c.toString()} bytes`);
|
|
612
651
|
}
|
|
613
652
|
//#endregion
|
|
614
|
-
export {
|
|
653
|
+
export { xe as picked };
|