@picked/vite-plugin-picked 0.0.1-dev.1788925875333 → 0.0.1-dev.1793753513002
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/LICENSE +1 -0
- package/README.md +52 -0
- package/dist/.tsbuildinfo +1 -1
- package/dist/cjs/index.js +26 -7
- package/dist/esm/index.js +284 -233
- package/dist/types/index.d.ts +15 -15
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/retry.d.ts +4 -3
- package/dist/types/retry.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 +19 -12
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
|
|
8
|
-
//#region \0@oxc-project+runtime@0.
|
|
9
|
-
function
|
|
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
|
+
//#region \0@oxc-project+runtime@0.154.0/helpers/esm/taggedTemplateLiteral.js
|
|
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,52 +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
|
-
|
|
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
|
-
|
|
113
|
-
return;
|
|
114
|
-
}
|
|
115
|
-
for (let [e, n] of j.entries()) M[n].enabled = e >= t;
|
|
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;
|
|
116
113
|
}
|
|
117
|
-
var
|
|
118
|
-
function
|
|
114
|
+
var P = k("\x1B[34m"), F = k("\x1B[36m");
|
|
115
|
+
function ce() {
|
|
119
116
|
let e = [
|
|
120
|
-
` ${
|
|
121
|
-
`${
|
|
122
|
-
` ${
|
|
123
|
-
`${
|
|
117
|
+
` ${P("_")} ${F("_")} _ _ _`,
|
|
118
|
+
`${P("(_)")} ${F("(_)")} _ __(_)__| |_____ __| |`,
|
|
119
|
+
` ${P("_")} ${P("_")} | '_ \\ / _| / / -_) _\` |`,
|
|
120
|
+
`${P("(_)")} ${P("(_)")} | .__/_\\__|_\\_\\___\\__,_|`,
|
|
124
121
|
" |_|\n "
|
|
125
122
|
];
|
|
126
123
|
console.log(e.join("\n"));
|
|
127
124
|
}
|
|
128
125
|
var I = {
|
|
129
|
-
banner:
|
|
130
|
-
debug:
|
|
131
|
-
info:
|
|
132
|
-
warn:
|
|
133
|
-
error:
|
|
134
|
-
setLevel:
|
|
126
|
+
banner: ce,
|
|
127
|
+
debug: N("debug"),
|
|
128
|
+
info: N("info"),
|
|
129
|
+
warn: N("warn"),
|
|
130
|
+
error: N("error"),
|
|
131
|
+
setLevel: se
|
|
135
132
|
};
|
|
136
133
|
//#endregion
|
|
137
134
|
//#region src/middleware.ts
|
|
138
|
-
function
|
|
135
|
+
function le(e) {
|
|
139
136
|
return (t, n, r) => {
|
|
140
137
|
if (t.method !== "GET") {
|
|
141
138
|
r();
|
|
@@ -153,41 +150,41 @@ function oe(e) {
|
|
|
153
150
|
//#endregion
|
|
154
151
|
//#region src/gitignore.ts
|
|
155
152
|
var L = ".picked/";
|
|
156
|
-
async function
|
|
153
|
+
async function ue(n, r) {
|
|
157
154
|
if (r) return;
|
|
158
155
|
let i = t(n, ".gitignore");
|
|
159
156
|
if (!e(i)) {
|
|
160
|
-
await
|
|
157
|
+
await v(i, `${L}
|
|
161
158
|
`);
|
|
162
159
|
return;
|
|
163
160
|
}
|
|
164
|
-
let a = await
|
|
165
|
-
if (
|
|
161
|
+
let a = await _(i, "utf8");
|
|
162
|
+
if (de(a)) return;
|
|
166
163
|
let o = `${a.length > 0 && !a.endsWith("\n") ? "\n" : ""}${L}
|
|
167
164
|
`;
|
|
168
|
-
await
|
|
165
|
+
await h(i, o);
|
|
169
166
|
}
|
|
170
|
-
function
|
|
167
|
+
function de(e) {
|
|
171
168
|
return e.split(/\r?\n/).map((e) => e.trim()).some((e) => e === L || e === ".picked");
|
|
172
169
|
}
|
|
173
170
|
//#endregion
|
|
174
171
|
//#region src/retry.ts
|
|
175
|
-
var R = 6,
|
|
176
|
-
function
|
|
172
|
+
var R = 6, fe = 5e3;
|
|
173
|
+
function pe(e) {
|
|
177
174
|
let t;
|
|
178
175
|
try {
|
|
179
176
|
t = new URL(e).hostname;
|
|
180
177
|
} catch {
|
|
181
178
|
return !1;
|
|
182
179
|
}
|
|
183
|
-
return t === "localhost" || t === "127.0.0.1" || t === "::1" || t === "[::1]"
|
|
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");
|
|
184
181
|
}
|
|
185
|
-
function
|
|
182
|
+
function me(e) {
|
|
186
183
|
return new Promise((t) => {
|
|
187
184
|
setTimeout(t, e);
|
|
188
185
|
});
|
|
189
186
|
}
|
|
190
|
-
async function
|
|
187
|
+
async function z(e, t) {
|
|
191
188
|
let n = null, r = null;
|
|
192
189
|
try {
|
|
193
190
|
n = await e();
|
|
@@ -196,8 +193,8 @@ async function B(e, t) {
|
|
|
196
193
|
}
|
|
197
194
|
if (n !== null) return n;
|
|
198
195
|
for (let i = 1; i <= R; i++) {
|
|
199
|
-
let a =
|
|
200
|
-
t(i, R, a), await
|
|
196
|
+
let a = fe * 2 ** (i - 1);
|
|
197
|
+
t(i, R, a), await me(a), r = null;
|
|
201
198
|
try {
|
|
202
199
|
n = await e();
|
|
203
200
|
} catch (e) {
|
|
@@ -210,10 +207,10 @@ async function B(e, t) {
|
|
|
210
207
|
}
|
|
211
208
|
//#endregion
|
|
212
209
|
//#region src/util.ts
|
|
213
|
-
function
|
|
210
|
+
function B(e) {
|
|
214
211
|
return Array.isArray(e) ? e : [];
|
|
215
212
|
}
|
|
216
|
-
function
|
|
213
|
+
function he(e) {
|
|
217
214
|
let t = e.variants, n = (t ?? []).reduce((e, t) => e + t.weight, 0);
|
|
218
215
|
return !t || t.length === 0 || n === 0 ? `${e.weight.toString()}%` : t.map((e) => {
|
|
219
216
|
let t = Math.round(100 * e.weight / n);
|
|
@@ -222,8 +219,8 @@ function de(e) {
|
|
|
222
219
|
}
|
|
223
220
|
//#endregion
|
|
224
221
|
//#region src/prefetch.ts
|
|
225
|
-
var
|
|
226
|
-
function
|
|
222
|
+
var V = 2;
|
|
223
|
+
function H(e) {
|
|
227
224
|
let n = t(e, ".picked");
|
|
228
225
|
return {
|
|
229
226
|
pickedDir: n,
|
|
@@ -232,32 +229,32 @@ function U(e) {
|
|
|
232
229
|
experiencesDir: t(n, "experiences")
|
|
233
230
|
};
|
|
234
231
|
}
|
|
235
|
-
async function
|
|
232
|
+
async function ge(t) {
|
|
236
233
|
if (!e(t)) return null;
|
|
237
234
|
try {
|
|
238
|
-
let e = await
|
|
239
|
-
return
|
|
235
|
+
let e = await _(t, "utf8"), n = JSON.parse(e);
|
|
236
|
+
return _e(n) ? n : null;
|
|
240
237
|
} catch {
|
|
241
238
|
return null;
|
|
242
239
|
}
|
|
243
240
|
}
|
|
244
|
-
function
|
|
241
|
+
function _e(e) {
|
|
245
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));
|
|
246
243
|
}
|
|
247
|
-
function
|
|
244
|
+
function ve(e) {
|
|
248
245
|
let t = /* @__PURE__ */ new Set();
|
|
249
|
-
for (let n of
|
|
246
|
+
for (let n of B(e.steps)) n.layoutContentId && t.add(n.id);
|
|
250
247
|
if (t.size === 0) return [];
|
|
251
248
|
let n = [];
|
|
252
|
-
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);
|
|
253
250
|
return n;
|
|
254
251
|
}
|
|
255
|
-
async function
|
|
256
|
-
let { apiUrl: r, projectId: i, projectRoot: a, headers: o, previewToken: s, reuseWhenUnchanged: c = !0 } = n, l =
|
|
257
|
-
if (await
|
|
258
|
-
let t = await
|
|
259
|
-
if (t?.version ===
|
|
260
|
-
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);
|
|
261
258
|
if (Object.values(n).every((t) => e(t))) return {
|
|
262
259
|
config: u,
|
|
263
260
|
manifest: t,
|
|
@@ -266,49 +263,49 @@ async function he(n) {
|
|
|
266
263
|
I.info("a manifest-referenced content file is missing; refetching every experience");
|
|
267
264
|
}
|
|
268
265
|
}
|
|
269
|
-
let f = (/* @__PURE__ */ new Date()).toISOString(),
|
|
266
|
+
let f = (/* @__PURE__ */ new Date()).toISOString(), p = [];
|
|
270
267
|
for (let e of d) {
|
|
271
|
-
let n = await
|
|
272
|
-
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({
|
|
273
270
|
id: e,
|
|
274
271
|
fetchedAt: f
|
|
275
272
|
});
|
|
276
273
|
}
|
|
277
|
-
let
|
|
278
|
-
version:
|
|
274
|
+
let m = {
|
|
275
|
+
version: V,
|
|
279
276
|
fetchedAt: f,
|
|
280
277
|
projectVersionId: u.versionId,
|
|
281
278
|
workspaceId: u.workspaceId,
|
|
282
279
|
projectId: u.id,
|
|
283
|
-
experiences:
|
|
280
|
+
experiences: p
|
|
284
281
|
};
|
|
285
|
-
return await
|
|
282
|
+
return await v(l.manifestPath, JSON.stringify(m, null, 2)), {
|
|
286
283
|
config: u,
|
|
287
|
-
manifest:
|
|
288
|
-
experienceContentPaths:
|
|
284
|
+
manifest: m,
|
|
285
|
+
experienceContentPaths: U(l, d)
|
|
289
286
|
};
|
|
290
287
|
}
|
|
291
|
-
function
|
|
288
|
+
function U(e, n) {
|
|
292
289
|
let r = {};
|
|
293
290
|
for (let i of n) r[i] = t(e.experiencesDir, `${i}.json`);
|
|
294
291
|
return r;
|
|
295
292
|
}
|
|
296
|
-
async function
|
|
293
|
+
async function be(e, t, n, r) {
|
|
297
294
|
let i = () => a(e, t, {
|
|
298
295
|
headers: n,
|
|
299
296
|
previewToken: r
|
|
300
297
|
}), o;
|
|
301
298
|
try {
|
|
302
|
-
o =
|
|
299
|
+
o = pe(e) ? await z(i, (e, t, n) => {
|
|
303
300
|
I.info(`project config not ready, retrying in ${(n / 1e3).toString()}s (${e.toString()}/${t.toString()})`);
|
|
304
301
|
}) : await i();
|
|
305
302
|
} catch (n) {
|
|
306
|
-
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)}`);
|
|
307
304
|
}
|
|
308
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.`);
|
|
309
306
|
return o;
|
|
310
307
|
}
|
|
311
|
-
async function
|
|
308
|
+
async function xe(e, t, n, r, a) {
|
|
312
309
|
let o;
|
|
313
310
|
try {
|
|
314
311
|
o = await i(e, t, n, {
|
|
@@ -316,12 +313,12 @@ async function _e(e, t, n, r, a) {
|
|
|
316
313
|
previewToken: a
|
|
317
314
|
});
|
|
318
315
|
} catch (t) {
|
|
319
|
-
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)}`);
|
|
320
317
|
}
|
|
321
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.`);
|
|
322
319
|
return o;
|
|
323
320
|
}
|
|
324
|
-
function
|
|
321
|
+
function W(e) {
|
|
325
322
|
if (e instanceof Error) return e.message;
|
|
326
323
|
if (typeof e == "string") return e;
|
|
327
324
|
try {
|
|
@@ -332,12 +329,12 @@ function G(e) {
|
|
|
332
329
|
}
|
|
333
330
|
//#endregion
|
|
334
331
|
//#region src/telemetry.ts
|
|
335
|
-
var
|
|
336
|
-
function
|
|
337
|
-
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();
|
|
338
335
|
return {
|
|
339
336
|
record: (n, a) => {
|
|
340
|
-
if (
|
|
337
|
+
if (Se.has(n)) {
|
|
341
338
|
let e = i.get(n) ?? {
|
|
342
339
|
calls: 0,
|
|
343
340
|
totalMs: 0
|
|
@@ -352,10 +349,10 @@ function ye(e = v()) {
|
|
|
352
349
|
r.push({
|
|
353
350
|
name: `picked.vite.${n}`,
|
|
354
351
|
traceId: e,
|
|
355
|
-
spanId:
|
|
352
|
+
spanId: y(),
|
|
356
353
|
parentSpanId: t,
|
|
357
|
-
startTimeUnixNano:
|
|
358
|
-
endTimeUnixNano:
|
|
354
|
+
startTimeUnixNano: S(o - a),
|
|
355
|
+
endTimeUnixNano: S(o),
|
|
359
356
|
attributes: { "picked.vite.hook": n },
|
|
360
357
|
status: "ok"
|
|
361
358
|
});
|
|
@@ -363,23 +360,23 @@ function ye(e = v()) {
|
|
|
363
360
|
flush: async (a) => {
|
|
364
361
|
let o = {};
|
|
365
362
|
for (let [e, t] of i) o[`picked.vite.${e}.calls`] = t.calls, o[`picked.vite.${e}.total_ms`] = Math.round(t.totalMs);
|
|
366
|
-
let
|
|
363
|
+
let s = c();
|
|
367
364
|
r.push({
|
|
368
365
|
name: "picked.vite.build",
|
|
369
366
|
traceId: e,
|
|
370
367
|
spanId: t,
|
|
371
|
-
startTimeUnixNano:
|
|
372
|
-
endTimeUnixNano:
|
|
368
|
+
startTimeUnixNano: S(n),
|
|
369
|
+
endTimeUnixNano: S(Date.now()),
|
|
373
370
|
attributes: {
|
|
374
|
-
"picked.env.provider":
|
|
375
|
-
"picked.env.ci":
|
|
371
|
+
"picked.env.provider": s.provider,
|
|
372
|
+
"picked.env.ci": s.ci,
|
|
376
373
|
...a,
|
|
377
374
|
...o
|
|
378
375
|
},
|
|
379
376
|
status: "ok"
|
|
380
377
|
});
|
|
381
378
|
try {
|
|
382
|
-
let e =
|
|
379
|
+
let e = b({
|
|
383
380
|
resource: { "service.name": "picked-vite-plugin" },
|
|
384
381
|
headers: { "Picked-Telemetry": "vite-plugin" },
|
|
385
382
|
maxBatchSize: r.length
|
|
@@ -390,39 +387,33 @@ function ye(e = v()) {
|
|
|
390
387
|
}
|
|
391
388
|
};
|
|
392
389
|
}
|
|
393
|
-
function
|
|
390
|
+
function we(e) {
|
|
394
391
|
return typeof e == "object" && !!e && "then" in e;
|
|
395
392
|
}
|
|
396
|
-
function
|
|
393
|
+
function G(e, t, n) {
|
|
397
394
|
return function(...r) {
|
|
398
395
|
let i = performance.now(), a = () => {
|
|
399
396
|
n.record(e, performance.now() - i);
|
|
400
397
|
}, o = t.apply(this, r);
|
|
401
|
-
return
|
|
398
|
+
return we(o) ? Promise.resolve(o).then(a, a) : a(), o;
|
|
402
399
|
};
|
|
403
400
|
}
|
|
404
|
-
function
|
|
401
|
+
function K(e) {
|
|
405
402
|
return typeof e == "function";
|
|
406
403
|
}
|
|
407
|
-
function
|
|
404
|
+
function Te(e, t) {
|
|
408
405
|
if (!e) return t;
|
|
409
|
-
for (let [n, r] of Object.entries(t))
|
|
410
|
-
if (q(r)) {
|
|
411
|
-
Reflect.set(t, n, K(n, r, e));
|
|
412
|
-
continue;
|
|
413
|
-
}
|
|
414
|
-
typeof r == "object" && r && "handler" in r && q(r.handler) && Reflect.set(r, "handler", K(n, r.handler, e));
|
|
415
|
-
}
|
|
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)));
|
|
416
407
|
return t;
|
|
417
408
|
}
|
|
418
409
|
//#endregion
|
|
419
410
|
//#region src/virtual-module/api.ts
|
|
420
|
-
function
|
|
411
|
+
function Ee() {
|
|
421
412
|
return "export const manifestMetadata = {\n mode: 'api',\n fetchedAt: null,\n projectVersionId: null,\n workspaceId: null,\n}\n";
|
|
422
413
|
}
|
|
423
414
|
//#endregion
|
|
424
415
|
//#region src/virtual-module/build.ts
|
|
425
|
-
function
|
|
416
|
+
function De(e) {
|
|
426
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");
|
|
427
418
|
return `import { registerPickedBundle } from '@picked/client/plugins/dynamic-experiences'
|
|
428
419
|
import projectConfigJson from ${i(t)}
|
|
@@ -452,7 +443,7 @@ registerPickedBundle({ projectConfig, experienceContent, manifestMetadata })
|
|
|
452
443
|
}
|
|
453
444
|
//#endregion
|
|
454
445
|
//#region src/virtual-module/dev.ts
|
|
455
|
-
function
|
|
446
|
+
function Oe(e) {
|
|
456
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" : "";
|
|
457
448
|
return `${a}
|
|
458
449
|
|
|
@@ -477,11 +468,48 @@ export const manifestMetadata = {
|
|
|
477
468
|
${s}`;
|
|
478
469
|
}
|
|
479
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
|
|
480
508
|
//#region src/index.ts
|
|
481
|
-
var
|
|
509
|
+
var je = 5;
|
|
482
510
|
function J(e, t, n) {
|
|
483
511
|
if (t.length === 0) return;
|
|
484
|
-
if (t.length >
|
|
512
|
+
if (t.length > je) {
|
|
485
513
|
console.log(`\n ${e}: ${t.length.toString()} loaded\n`);
|
|
486
514
|
return;
|
|
487
515
|
}
|
|
@@ -496,10 +524,10 @@ function J(e, t, n) {
|
|
|
496
524
|
""
|
|
497
525
|
].join("\n"));
|
|
498
526
|
}
|
|
499
|
-
function
|
|
527
|
+
function Me(e, t) {
|
|
500
528
|
t.length !== 0 && console.log(`\n ${e}: ${t.length.toString()} loaded\n`);
|
|
501
529
|
}
|
|
502
|
-
var
|
|
530
|
+
var Ne = [
|
|
503
531
|
{
|
|
504
532
|
header: "Name",
|
|
505
533
|
value: (e) => e.name
|
|
@@ -514,13 +542,13 @@ var De = [
|
|
|
514
542
|
},
|
|
515
543
|
{
|
|
516
544
|
header: "Split",
|
|
517
|
-
value: (e) =>
|
|
545
|
+
value: (e) => he(e)
|
|
518
546
|
},
|
|
519
547
|
{
|
|
520
548
|
header: "Ver",
|
|
521
549
|
value: (e) => `v${e.version.toString()}`
|
|
522
550
|
}
|
|
523
|
-
],
|
|
551
|
+
], Pe = [
|
|
524
552
|
{
|
|
525
553
|
header: "Name",
|
|
526
554
|
value: (e) => e.name
|
|
@@ -541,7 +569,7 @@ var De = [
|
|
|
541
569
|
header: "Targets",
|
|
542
570
|
value: (e) => e.targets.length.toString()
|
|
543
571
|
}
|
|
544
|
-
],
|
|
572
|
+
], Fe = [
|
|
545
573
|
{
|
|
546
574
|
header: "Name",
|
|
547
575
|
value: (e) => e.name
|
|
@@ -554,7 +582,7 @@ var De = [
|
|
|
554
582
|
header: "Fields",
|
|
555
583
|
value: (e) => (e.fieldIds?.length ?? 0).toString()
|
|
556
584
|
}
|
|
557
|
-
],
|
|
585
|
+
], Ie = [
|
|
558
586
|
{
|
|
559
587
|
header: "Name",
|
|
560
588
|
value: (e) => e.name
|
|
@@ -571,24 +599,24 @@ var De = [
|
|
|
571
599
|
header: "Required",
|
|
572
600
|
value: (e) => e.required ? "yes" : "no"
|
|
573
601
|
}
|
|
574
|
-
],
|
|
602
|
+
], Le = [{
|
|
575
603
|
header: "Name",
|
|
576
604
|
value: (e) => e.name
|
|
577
605
|
}, {
|
|
578
606
|
header: "Key",
|
|
579
607
|
value: (e) => e.key
|
|
580
608
|
}];
|
|
581
|
-
function
|
|
582
|
-
return "0.0.1-dev.
|
|
609
|
+
function Re() {
|
|
610
|
+
return "0.0.1-dev.1793753513002";
|
|
583
611
|
}
|
|
584
|
-
var
|
|
585
|
-
function
|
|
612
|
+
var ze = "https://api.picked.app", Y = "virtual:picked/data", X = `\0${Y}`, Z = `\0${q}`;
|
|
613
|
+
function Be(e) {
|
|
586
614
|
for (let t of Object.values(e)) if (t.type === "chunk" && t.moduleIds.includes(X)) return t.fileName;
|
|
587
615
|
}
|
|
588
|
-
function
|
|
616
|
+
function Ve(e, t) {
|
|
589
617
|
return e === "" || e.endsWith("/") ? `${e}${t}` : `${e}/${t}`;
|
|
590
618
|
}
|
|
591
|
-
async function
|
|
619
|
+
async function He(e) {
|
|
592
620
|
try {
|
|
593
621
|
let t = await o({
|
|
594
622
|
config: e,
|
|
@@ -602,70 +630,90 @@ async function Ie(e) {
|
|
|
602
630
|
throw Error(`type generation failed: ${t}. Fix the schema source, or set \`generateTypes: false\` on the picked plugin to skip it.`);
|
|
603
631
|
}
|
|
604
632
|
}
|
|
605
|
-
function
|
|
606
|
-
return e &&
|
|
633
|
+
function Ue(e, t, n) {
|
|
634
|
+
return e && l(t, n) ? e : null;
|
|
607
635
|
}
|
|
608
|
-
async function
|
|
609
|
-
let n = await
|
|
636
|
+
async function We(e, t) {
|
|
637
|
+
let n = await f(e, t);
|
|
610
638
|
if (!n) throw Error("picked.config.{ts,js,json} is required. Add a picked.config.ts with projectId and apiUrl.");
|
|
611
639
|
return n;
|
|
612
640
|
}
|
|
613
|
-
function
|
|
614
|
-
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.`);
|
|
615
645
|
}
|
|
616
|
-
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.");
|
|
617
648
|
let t = [];
|
|
618
649
|
if (e.projectId !== void 0 && t.push("`projectId`"), e.apiUrl !== void 0 && t.push("`apiUrl`"), t.length === 0) return;
|
|
619
650
|
let n = t.length > 1;
|
|
620
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.`);
|
|
621
652
|
}
|
|
622
|
-
async function
|
|
623
|
-
let n = await
|
|
653
|
+
async function Ke(e, t) {
|
|
654
|
+
let n = await d(e);
|
|
624
655
|
n && n.projectId !== t && I.warn(`using project "${t}" (picked.config default: "${n.projectId}") — run 'picked status' to inspect`);
|
|
625
656
|
}
|
|
626
|
-
|
|
627
|
-
|
|
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) {
|
|
628
677
|
return JSON.stringify([
|
|
629
678
|
e,
|
|
630
679
|
t,
|
|
631
680
|
n
|
|
632
681
|
]);
|
|
633
682
|
}
|
|
634
|
-
function
|
|
635
|
-
let i = t.mode ?? "bundle", o = t.generateTypes ?? !0,
|
|
636
|
-
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, {
|
|
637
686
|
name: "picked",
|
|
638
|
-
config: async (
|
|
639
|
-
|
|
640
|
-
let { projectId:
|
|
641
|
-
|
|
642
|
-
projectId:
|
|
643
|
-
apiUrl:
|
|
644
|
-
|
|
645
|
-
projectId: y,
|
|
646
|
-
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
|
|
647
694
|
});
|
|
648
|
-
let { projectId:
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
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);
|
|
656
704
|
n === void 0 && (n = (async () => {
|
|
657
|
-
I.info(`prefetching project config + content for "${
|
|
658
|
-
let t =
|
|
659
|
-
apiUrl:
|
|
660
|
-
projectId:
|
|
661
|
-
projectRoot:
|
|
662
|
-
headers:
|
|
663
|
-
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
|
|
664
712
|
}), a = (performance.now() - r).toFixed(0);
|
|
665
|
-
await
|
|
713
|
+
await ue(d, n);
|
|
666
714
|
let o = i.config;
|
|
667
|
-
return
|
|
668
|
-
virtualSource:
|
|
715
|
+
return Qe(o, a), {
|
|
716
|
+
virtualSource: De({
|
|
669
717
|
projectConfigPath: t.projectConfigPath,
|
|
670
718
|
experienceContentPaths: i.experienceContentPaths,
|
|
671
719
|
manifestMetadata: {
|
|
@@ -675,40 +723,38 @@ function He(t = {}) {
|
|
|
675
723
|
workspaceId: i.manifest.workspaceId
|
|
676
724
|
}
|
|
677
725
|
}),
|
|
678
|
-
features:
|
|
726
|
+
features: B(o.features)
|
|
679
727
|
};
|
|
680
|
-
})(), n.catch(() =>
|
|
728
|
+
})(), n.catch(() => $.delete(t)), $.set(t, n));
|
|
681
729
|
let r = await n;
|
|
682
|
-
|
|
683
|
-
} 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");
|
|
684
732
|
else {
|
|
685
|
-
I.info(`fetching project config for "${
|
|
686
|
-
let e = performance.now(), t = (
|
|
687
|
-
|
|
688
|
-
previewToken: w ?? void 0
|
|
689
|
-
}), n = z(C) ? await B(t, (e, t, n) => {
|
|
690
|
-
I.info(`local API not ready, retrying in ${(n / 1e3).toString()}s (${e.toString()}/${t.toString()})`);
|
|
691
|
-
}) : await t(), r = (performance.now() - e).toFixed(0);
|
|
692
|
-
_ = 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)`);
|
|
693
736
|
}
|
|
694
737
|
},
|
|
695
738
|
configResolved(e) {
|
|
696
|
-
|
|
739
|
+
h = e.base;
|
|
740
|
+
},
|
|
741
|
+
async buildStart() {
|
|
742
|
+
a === "snapshot" && g && f === "build" && (o = await p(g));
|
|
697
743
|
},
|
|
698
744
|
closeBundle() {
|
|
699
|
-
|
|
700
|
-
"picked.vite.command":
|
|
701
|
-
"picked.data.mode":
|
|
702
|
-
"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"
|
|
703
749
|
});
|
|
704
750
|
},
|
|
705
751
|
transformIndexHtml: {
|
|
706
752
|
order: "post",
|
|
707
753
|
handler(e, t) {
|
|
708
|
-
if (
|
|
709
|
-
let n =
|
|
754
|
+
if (a === "api" || t.bundle === void 0) return;
|
|
755
|
+
let n = Be(t.bundle);
|
|
710
756
|
if (n === void 0) return;
|
|
711
|
-
let r =
|
|
757
|
+
let r = Ve(h, n);
|
|
712
758
|
if (!e.includes(`"${r}"`)) return [{
|
|
713
759
|
tag: "link",
|
|
714
760
|
attrs: {
|
|
@@ -721,24 +767,35 @@ function He(t = {}) {
|
|
|
721
767
|
}
|
|
722
768
|
},
|
|
723
769
|
resolveId(e) {
|
|
724
|
-
if (e === Y) return
|
|
770
|
+
if (e === Y || e.startsWith("virtual:picked/data/experience/")) return `\0${e}`;
|
|
725
771
|
},
|
|
726
772
|
load(e) {
|
|
773
|
+
if (e.startsWith(Z) && o && g) return this.addWatchFile(m(g.projectRoot)), Ae(o, e.slice(Z.length));
|
|
727
774
|
if (e === X) {
|
|
728
|
-
if (
|
|
729
|
-
if (
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
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
|
|
736
787
|
});
|
|
737
788
|
}
|
|
738
789
|
},
|
|
739
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
|
+
}
|
|
740
797
|
if (t.disableLauncher) return;
|
|
741
|
-
e.middlewares.use(
|
|
798
|
+
e.middlewares.use(le(() => T(l)));
|
|
742
799
|
let n = e.printUrls.bind(e);
|
|
743
800
|
e.printUrls = () => {
|
|
744
801
|
let t = e.resolvedUrls?.local[0];
|
|
@@ -752,23 +809,17 @@ function He(t = {}) {
|
|
|
752
809
|
generateBundle: {
|
|
753
810
|
order: "post",
|
|
754
811
|
handler(e, n) {
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
this.emitFile({
|
|
761
|
-
type: "asset",
|
|
762
|
-
fileName: "index.html",
|
|
763
|
-
source: E(s)
|
|
764
|
-
});
|
|
765
|
-
}
|
|
812
|
+
t.disableLauncher || ("index.html" in n ? I.debug("index.html came from the build; skipping the launcher page") : this.emitFile({
|
|
813
|
+
type: "asset",
|
|
814
|
+
fileName: "index.html",
|
|
815
|
+
source: T(l)
|
|
816
|
+
}));
|
|
766
817
|
}
|
|
767
818
|
}
|
|
768
819
|
});
|
|
769
820
|
}
|
|
770
|
-
function
|
|
771
|
-
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 = [
|
|
772
823
|
`${n.length.toString()} features`,
|
|
773
824
|
`${r.length.toString()} experiences`,
|
|
774
825
|
`${i.length.toString()} steps`,
|
|
@@ -776,7 +827,7 @@ function $(e, t) {
|
|
|
776
827
|
`${o.length.toString()} conditions`,
|
|
777
828
|
`${s.length.toString()} actions`
|
|
778
829
|
].join(", ");
|
|
779
|
-
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`);
|
|
780
831
|
}
|
|
781
832
|
//#endregion
|
|
782
|
-
export {
|
|
833
|
+
export { Ze as picked };
|