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