@picked/vite-plugin-picked 0.0.1-dev.1786072899095 → 0.0.1-dev.1786601464574
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/client.d.ts +26 -0
- package/dist/.tsbuildinfo +1 -1
- package/dist/cjs/index.js +29 -17
- package/dist/esm/index.js +309 -200
- package/dist/types/index.d.ts +16 -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/api.d.ts +17 -0
- package/dist/types/virtual-module/api.d.ts.map +1 -0
- package/dist/types/virtual-module/build.d.ts.map +1 -1
- package/dist/types/virtual-module/dev.d.ts +17 -4
- package/dist/types/virtual-module/dev.d.ts.map +1 -1
- package/package.json +13 -3
package/dist/esm/index.js
CHANGED
|
@@ -1,28 +1,30 @@
|
|
|
1
1
|
import { existsSync as e } from "node:fs";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { join as t, resolve as n } from "node:path";
|
|
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 d(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 g = [
|
|
|
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 E(e) {
|
|
|
142
144
|
}
|
|
143
145
|
//#endregion
|
|
144
146
|
//#region src/gitignore.ts
|
|
145
|
-
var
|
|
146
|
-
async function
|
|
147
|
-
if (
|
|
148
|
-
let
|
|
149
|
-
if (!e(
|
|
150
|
-
await
|
|
147
|
+
var k = ".picked/";
|
|
148
|
+
async function ie(n, r) {
|
|
149
|
+
if (r) return;
|
|
150
|
+
let i = t(n, ".gitignore");
|
|
151
|
+
if (!e(i)) {
|
|
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 i
|
|
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 j(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 M(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,102 +202,111 @@ async function M(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
|
-
let
|
|
210
|
+
var I = 2;
|
|
211
|
+
function L(e) {
|
|
212
|
+
let n = t(e, ".picked");
|
|
211
213
|
return {
|
|
212
|
-
pickedDir:
|
|
213
|
-
manifestPath:
|
|
214
|
-
projectConfigPath:
|
|
215
|
-
experiencesDir:
|
|
214
|
+
pickedDir: n,
|
|
215
|
+
manifestPath: t(n, "manifest.json"),
|
|
216
|
+
projectConfigPath: t(n, "project-config.json"),
|
|
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:
|
|
240
|
-
if (
|
|
241
|
-
let
|
|
242
|
-
if (
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
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);
|
|
246
|
+
if (Object.values(n).every((t) => e(t))) return {
|
|
247
|
+
config: d,
|
|
248
|
+
manifest: t,
|
|
249
|
+
experienceContentPaths: n
|
|
250
|
+
};
|
|
251
|
+
D.info("a manifest-referenced content file is missing; refetching every experience");
|
|
252
|
+
}
|
|
247
253
|
}
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
await s(a, JSON.stringify(r, null, 2)), p.push({
|
|
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({
|
|
253
258
|
id: e,
|
|
254
|
-
fetchedAt:
|
|
259
|
+
fetchedAt: m
|
|
255
260
|
});
|
|
256
261
|
}
|
|
257
|
-
let
|
|
258
|
-
version:
|
|
259
|
-
fetchedAt:
|
|
260
|
-
projectVersionId:
|
|
261
|
-
workspaceId:
|
|
262
|
-
projectId:
|
|
263
|
-
experiences:
|
|
262
|
+
let g = {
|
|
263
|
+
version: I,
|
|
264
|
+
fetchedAt: m,
|
|
265
|
+
projectVersionId: d.versionId,
|
|
266
|
+
workspaceId: d.workspaceId,
|
|
267
|
+
projectId: d.id,
|
|
268
|
+
experiences: h
|
|
264
269
|
};
|
|
265
|
-
return await
|
|
266
|
-
config:
|
|
267
|
-
manifest:
|
|
268
|
-
experienceContentPaths:
|
|
270
|
+
return await f(l.manifestPath, JSON.stringify(g, null, 2)), {
|
|
271
|
+
config: d,
|
|
272
|
+
manifest: g,
|
|
273
|
+
experienceContentPaths: H(l, p)
|
|
269
274
|
};
|
|
270
275
|
}
|
|
271
|
-
function
|
|
272
|
-
let
|
|
273
|
-
for (let
|
|
274
|
-
return
|
|
276
|
+
function H(e, n) {
|
|
277
|
+
let r = {};
|
|
278
|
+
for (let i of n) r[i] = t(e.experiencesDir, `${i}.json`);
|
|
279
|
+
return r;
|
|
275
280
|
}
|
|
276
|
-
async function
|
|
277
|
-
let i = () =>
|
|
281
|
+
async function U(e, t, n, r) {
|
|
282
|
+
let i = () => a(e, t, {
|
|
283
|
+
headers: n,
|
|
284
|
+
previewToken: r
|
|
285
|
+
}), o;
|
|
278
286
|
try {
|
|
279
|
-
|
|
280
|
-
|
|
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()})`);
|
|
281
289
|
}) : await i();
|
|
282
290
|
} catch (n) {
|
|
283
|
-
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)}`);
|
|
284
292
|
}
|
|
285
|
-
if (!
|
|
286
|
-
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;
|
|
287
295
|
}
|
|
288
|
-
async function
|
|
289
|
-
let
|
|
296
|
+
async function W(e, t, n, r, a) {
|
|
297
|
+
let o;
|
|
290
298
|
try {
|
|
291
|
-
|
|
299
|
+
o = await i(e, t, n, {
|
|
300
|
+
headers: r,
|
|
301
|
+
previewToken: a
|
|
302
|
+
});
|
|
292
303
|
} catch (t) {
|
|
293
|
-
throw Error(`[picked] Build-time fetch of content for experience "${
|
|
304
|
+
throw Error(`[picked] Build-time fetch of content for experience "${n}" failed at ${e}: ${G(t)}`);
|
|
294
305
|
}
|
|
295
|
-
if (!
|
|
296
|
-
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;
|
|
297
308
|
}
|
|
298
|
-
function
|
|
309
|
+
function G(e) {
|
|
299
310
|
if (e instanceof Error) return e.message;
|
|
300
311
|
if (typeof e == "string") return e;
|
|
301
312
|
try {
|
|
@@ -305,10 +316,16 @@ function U(e) {
|
|
|
305
316
|
}
|
|
306
317
|
}
|
|
307
318
|
//#endregion
|
|
319
|
+
//#region src/virtual-module/api.ts
|
|
320
|
+
function K() {
|
|
321
|
+
return "export const manifestMetadata = {\n mode: 'api',\n fetchedAt: null,\n projectVersionId: null,\n workspaceId: null,\n}\n";
|
|
322
|
+
}
|
|
323
|
+
//#endregion
|
|
308
324
|
//#region src/virtual-module/build.ts
|
|
309
|
-
function
|
|
325
|
+
function q(e) {
|
|
310
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");
|
|
311
|
-
return `import
|
|
327
|
+
return `import { registerPickedBundle } from '@picked/client/plugins/dynamic-experiences'
|
|
328
|
+
import projectConfigJson from ${i(t)}
|
|
312
329
|
|
|
313
330
|
const experienceImporters = {
|
|
314
331
|
${a}
|
|
@@ -329,23 +346,26 @@ export async function experienceContent(experience, _options) {
|
|
|
329
346
|
}
|
|
330
347
|
|
|
331
348
|
export const manifestMetadata = ${JSON.stringify(r)}
|
|
349
|
+
|
|
350
|
+
registerPickedBundle({ projectConfig, experienceContent, manifestMetadata })
|
|
332
351
|
`;
|
|
333
352
|
}
|
|
334
353
|
//#endregion
|
|
335
354
|
//#region src/virtual-module/dev.ts
|
|
336
|
-
function
|
|
337
|
-
let { apiUrl: t, projectId: n } = e;
|
|
338
|
-
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}
|
|
339
358
|
|
|
340
359
|
const apiUrl = ${JSON.stringify(t)}
|
|
341
360
|
const projectId = ${JSON.stringify(n)}
|
|
361
|
+
const previewToken = ${JSON.stringify(i ?? null)}
|
|
342
362
|
|
|
343
|
-
|
|
363
|
+
${o}
|
|
344
364
|
|
|
345
365
|
export async function experienceContent(experience, options) {
|
|
346
366
|
const id = typeof experience === 'string' ? experience : experience?.id
|
|
347
367
|
if (!id) return null
|
|
348
|
-
return await fetchExperienceContent(apiUrl, projectId, id, options)
|
|
368
|
+
return await fetchExperienceContent(apiUrl, projectId, id, { previewToken: previewToken ?? undefined, ...options })
|
|
349
369
|
}
|
|
350
370
|
|
|
351
371
|
export const manifestMetadata = {
|
|
@@ -354,14 +374,14 @@ export const manifestMetadata = {
|
|
|
354
374
|
projectVersionId: projectConfig?.versionId ?? null,
|
|
355
375
|
workspaceId: projectConfig?.workspaceId ?? null,
|
|
356
376
|
}
|
|
357
|
-
`;
|
|
377
|
+
${s}`;
|
|
358
378
|
}
|
|
359
379
|
//#endregion
|
|
360
380
|
//#region src/index.ts
|
|
361
|
-
var
|
|
362
|
-
function
|
|
381
|
+
var oe = 5;
|
|
382
|
+
function Y(e, t, n) {
|
|
363
383
|
if (t.length === 0) return;
|
|
364
|
-
if (t.length >
|
|
384
|
+
if (t.length > oe) {
|
|
365
385
|
console.log(`\n ${e}: ${t.length.toString()} loaded\n`);
|
|
366
386
|
return;
|
|
367
387
|
}
|
|
@@ -376,10 +396,10 @@ function q(e, t, n) {
|
|
|
376
396
|
""
|
|
377
397
|
].join("\n"));
|
|
378
398
|
}
|
|
379
|
-
function
|
|
399
|
+
function se(e, t) {
|
|
380
400
|
t.length !== 0 && console.log(`\n ${e}: ${t.length.toString()} loaded\n`);
|
|
381
401
|
}
|
|
382
|
-
var
|
|
402
|
+
var ce = [
|
|
383
403
|
{
|
|
384
404
|
header: "Name",
|
|
385
405
|
value: (e) => e.name
|
|
@@ -400,7 +420,7 @@ var Y = [
|
|
|
400
420
|
header: "Ver",
|
|
401
421
|
value: (e) => `v${e.version.toString()}`
|
|
402
422
|
}
|
|
403
|
-
],
|
|
423
|
+
], le = [
|
|
404
424
|
{
|
|
405
425
|
header: "Name",
|
|
406
426
|
value: (e) => e.name
|
|
@@ -421,7 +441,7 @@ var Y = [
|
|
|
421
441
|
header: "Targets",
|
|
422
442
|
value: (e) => e.targets.length.toString()
|
|
423
443
|
}
|
|
424
|
-
],
|
|
444
|
+
], ue = [
|
|
425
445
|
{
|
|
426
446
|
header: "Name",
|
|
427
447
|
value: (e) => e.name
|
|
@@ -434,7 +454,7 @@ var Y = [
|
|
|
434
454
|
header: "Fields",
|
|
435
455
|
value: (e) => (e.fieldIds?.length ?? 0).toString()
|
|
436
456
|
}
|
|
437
|
-
],
|
|
457
|
+
], de = [
|
|
438
458
|
{
|
|
439
459
|
header: "Name",
|
|
440
460
|
value: (e) => e.name
|
|
@@ -451,86 +471,175 @@ var Y = [
|
|
|
451
471
|
header: "Required",
|
|
452
472
|
value: (e) => e.required ? "yes" : "no"
|
|
453
473
|
}
|
|
454
|
-
],
|
|
474
|
+
], fe = [{
|
|
455
475
|
header: "Name",
|
|
456
476
|
value: (e) => e.name
|
|
457
477
|
}, {
|
|
458
478
|
header: "Key",
|
|
459
479
|
value: (e) => e.key
|
|
460
480
|
}];
|
|
461
|
-
function
|
|
462
|
-
return "0.0.1-dev.
|
|
481
|
+
function pe() {
|
|
482
|
+
return "0.0.1-dev.1786601464574";
|
|
483
|
+
}
|
|
484
|
+
var me = "https://api.picked.app", X = "virtual:picked/data", Z = `\0${X}`;
|
|
485
|
+
function he(e) {
|
|
486
|
+
for (let t of Object.values(e)) if (t.type === "chunk" && t.moduleIds.includes(Z)) return t.fileName;
|
|
487
|
+
}
|
|
488
|
+
function ge(e, t) {
|
|
489
|
+
return e === "" || e.endsWith("/") ? `${e}${t}` : `${e}/${t}`;
|
|
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
|
+
}
|
|
463
499
|
}
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
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
|
+
}
|
|
509
|
+
var Q = /* @__PURE__ */ new Map();
|
|
510
|
+
function be(e, t, n) {
|
|
511
|
+
return JSON.stringify([
|
|
512
|
+
e,
|
|
513
|
+
t,
|
|
514
|
+
n
|
|
515
|
+
]);
|
|
516
|
+
}
|
|
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;
|
|
467
519
|
return {
|
|
468
520
|
name: "picked",
|
|
469
|
-
config: async (
|
|
470
|
-
|
|
471
|
-
let
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
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,
|
|
536
|
+
projectRoot: c,
|
|
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,
|
|
546
|
+
manifestMetadata: {
|
|
547
|
+
mode: "build",
|
|
548
|
+
fetchedAt: i.manifest.fetchedAt,
|
|
549
|
+
projectVersionId: i.manifest.projectVersionId,
|
|
550
|
+
workspaceId: i.manifest.workspaceId
|
|
551
|
+
}
|
|
552
|
+
}),
|
|
553
|
+
features: F(o.features)
|
|
554
|
+
};
|
|
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");
|
|
559
|
+
else {
|
|
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)`);
|
|
568
|
+
}
|
|
569
|
+
},
|
|
570
|
+
configResolved(e) {
|
|
571
|
+
u = e.base;
|
|
572
|
+
},
|
|
573
|
+
closeBundle() {
|
|
574
|
+
p !== void 0 && Q.delete(p);
|
|
575
|
+
},
|
|
576
|
+
transformIndexHtml: {
|
|
577
|
+
order: "post",
|
|
578
|
+
handler(e, t) {
|
|
579
|
+
if (i === "api" || t.bundle === void 0) return;
|
|
580
|
+
let n = he(t.bundle);
|
|
581
|
+
if (n === void 0) return;
|
|
582
|
+
let r = ge(u, n);
|
|
583
|
+
if (!e.includes(`"${r}"`)) return [{
|
|
584
|
+
tag: "link",
|
|
585
|
+
attrs: {
|
|
586
|
+
rel: "modulepreload",
|
|
587
|
+
crossorigin: !0,
|
|
588
|
+
href: r
|
|
589
|
+
},
|
|
590
|
+
injectTo: "head"
|
|
591
|
+
}];
|
|
499
592
|
}
|
|
500
593
|
},
|
|
501
594
|
resolveId(e) {
|
|
502
|
-
if (e ===
|
|
595
|
+
if (e === X) return Z;
|
|
503
596
|
},
|
|
504
597
|
load(e) {
|
|
505
|
-
if (e ===
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
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
|
+
}
|
|
509
609
|
},
|
|
510
610
|
configureServer(e) {
|
|
511
|
-
if (
|
|
512
|
-
e.middlewares.use(
|
|
513
|
-
let
|
|
611
|
+
if (t.disableLauncher) return;
|
|
612
|
+
e.middlewares.use(O(() => h(s)));
|
|
613
|
+
let n = e.printUrls.bind(e);
|
|
514
614
|
e.printUrls = () => {
|
|
515
|
-
let
|
|
516
|
-
if (
|
|
517
|
-
let e =
|
|
615
|
+
let t = e.resolvedUrls?.local[0];
|
|
616
|
+
if (t) {
|
|
617
|
+
let e = t.replace(/:(?<port>\d+)\//, (e, t) => `:\x1b[1m${t}\x1b[22m/`);
|
|
518
618
|
console.log(` \x1b[32m➜\x1b[0m \x1b[1mPicked\x1b[22m: \x1b[36m${e}\x1b[0m`);
|
|
519
619
|
}
|
|
520
|
-
|
|
620
|
+
n();
|
|
521
621
|
};
|
|
522
622
|
},
|
|
523
|
-
generateBundle
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
623
|
+
generateBundle: {
|
|
624
|
+
order: "post",
|
|
625
|
+
handler(e, n) {
|
|
626
|
+
if (!t.disableLauncher) {
|
|
627
|
+
if ("index.html" in n) {
|
|
628
|
+
D.debug("index.html came from the build; skipping the launcher page");
|
|
629
|
+
return;
|
|
630
|
+
}
|
|
631
|
+
this.emitFile({
|
|
632
|
+
type: "asset",
|
|
633
|
+
fileName: "index.html",
|
|
634
|
+
source: h(s)
|
|
635
|
+
});
|
|
636
|
+
}
|
|
637
|
+
}
|
|
529
638
|
}
|
|
530
639
|
};
|
|
531
640
|
}
|
|
532
641
|
function $(e, t) {
|
|
533
|
-
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 = [
|
|
534
643
|
`${n.length.toString()} features`,
|
|
535
644
|
`${r.length.toString()} experiences`,
|
|
536
645
|
`${i.length.toString()} steps`,
|
|
@@ -538,7 +647,7 @@ function $(e, t) {
|
|
|
538
647
|
`${o.length.toString()} conditions`,
|
|
539
648
|
`${s.length.toString()} actions`
|
|
540
649
|
].join(", ");
|
|
541
|
-
|
|
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`);
|
|
542
651
|
}
|
|
543
652
|
//#endregion
|
|
544
|
-
export {
|
|
653
|
+
export { xe as picked };
|