@picked/vite-plugin-picked 0.0.1-dev.1787019239195 → 0.0.1-dev.1787543060859
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.tsbuildinfo +1 -1
- package/dist/cjs/index.js +16 -17
- package/dist/esm/index.js +300 -192
- package/dist/types/index.d.ts +6 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/launcher.d.ts +8 -0
- package/dist/types/launcher.d.ts.map +1 -1
- package/dist/types/telemetry.d.ts +44 -0
- package/dist/types/telemetry.d.ts.map +1 -0
- package/dist/types/util.d.ts +19 -3
- package/dist/types/util.d.ts.map +1 -1
- package/package.json +6 -5
package/dist/esm/index.js
CHANGED
|
@@ -2,29 +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
|
|
5
|
+
import { detectHostEnvironment as s, isTelemetryEnabled as c, isTelemetryForcedOffByEnvironment as l, loadPickedConfig as u, loadResolvedPickedConfig as d } from "@picked/config";
|
|
6
|
+
import { appendFile as f, mkdir as p, readFile as m, writeFile as h } from "node:fs/promises";
|
|
7
|
+
import { createSpanId as g, createTelemetryEmitter as _, createTraceId as v, toUnixNano as y } from "@picked/telemetry";
|
|
7
8
|
//#region \0@oxc-project+runtime@0.142.0/helpers/esm/taggedTemplateLiteral.js
|
|
8
|
-
function
|
|
9
|
+
function b(e, t) {
|
|
9
10
|
return t ||= e.slice(0), Object.freeze(Object.defineProperties(e, { raw: { value: Object.freeze(t) } }));
|
|
10
11
|
}
|
|
11
12
|
//#endregion
|
|
12
13
|
//#region src/launcher.ts
|
|
13
|
-
var
|
|
14
|
-
function
|
|
15
|
-
let t =
|
|
14
|
+
var x, S = ["true", "false"], C = "false";
|
|
15
|
+
function w(e) {
|
|
16
|
+
let t = e.variants;
|
|
17
|
+
return !t || t.length === 0 ? S : t.map((e) => String(e.value));
|
|
18
|
+
}
|
|
19
|
+
function T(e) {
|
|
20
|
+
let t = w(e), n = Math.max(0, t.findIndex((e) => e !== C));
|
|
21
|
+
return t.map((e, t) => `<option value="${O(e)}"${t === n ? " selected" : ""}>${D(e)}</option>`).join("");
|
|
22
|
+
}
|
|
23
|
+
function E(e) {
|
|
24
|
+
let t = JSON.stringify(e).replaceAll("<", String.raw`\u003c`), n = e.length > 0 ? e.map((e) => `
|
|
16
25
|
<div class="feature-row">
|
|
17
26
|
<label>
|
|
18
|
-
<input type="checkbox" data-feature-id="${
|
|
19
|
-
<span class="feature-name">${
|
|
20
|
-
<span class="feature-id">${
|
|
27
|
+
<input type="checkbox" data-feature-id="${O(e.id)}" checked>
|
|
28
|
+
<span class="feature-name">${D(e.name)}</span>
|
|
29
|
+
<span class="feature-id">${D(e.id)}</span>
|
|
21
30
|
</label>
|
|
22
|
-
<select data-value-for="${
|
|
23
|
-
|
|
24
|
-
<option value="false">false</option>
|
|
31
|
+
<select data-value-for="${O(e.id)}">
|
|
32
|
+
${T(e)}
|
|
25
33
|
</select>
|
|
26
34
|
</div>`).join("") : "<p class=\"text no-features\">No features configured for this project.</p>";
|
|
27
|
-
return String.raw(
|
|
35
|
+
return String.raw(x ||= b([
|
|
28
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 ",
|
|
29
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 = ",
|
|
30
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>"
|
|
@@ -34,46 +42,46 @@ function h(e) {
|
|
|
34
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>"
|
|
35
43
|
]), n, t);
|
|
36
44
|
}
|
|
37
|
-
function
|
|
45
|
+
function D(e) {
|
|
38
46
|
return e.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll("\"", """);
|
|
39
47
|
}
|
|
40
|
-
function
|
|
48
|
+
function O(e) {
|
|
41
49
|
return e.replaceAll("&", "&").replaceAll("\"", """).replaceAll("<", "<").replaceAll(">", ">");
|
|
42
50
|
}
|
|
43
51
|
//#endregion
|
|
44
52
|
//#region src/log.ts
|
|
45
|
-
var
|
|
46
|
-
function
|
|
53
|
+
var k = "picked", ee = "\x1B[0m";
|
|
54
|
+
function te() {
|
|
47
55
|
let e = process.env.NO_COLOR;
|
|
48
56
|
return e === "1" || e === "true";
|
|
49
57
|
}
|
|
50
|
-
function
|
|
51
|
-
return (t) =>
|
|
58
|
+
function A(e) {
|
|
59
|
+
return (t) => te() ? t : `${e}${t}${ee}`;
|
|
52
60
|
}
|
|
53
|
-
var
|
|
61
|
+
var j = [
|
|
54
62
|
"debug",
|
|
55
63
|
"info",
|
|
56
64
|
"warn",
|
|
57
65
|
"error",
|
|
58
66
|
"silent"
|
|
59
|
-
],
|
|
67
|
+
], M = {
|
|
60
68
|
debug: {
|
|
61
|
-
color:
|
|
69
|
+
color: A("\x1B[2m"),
|
|
62
70
|
log: console.debug,
|
|
63
71
|
enabled: !1
|
|
64
72
|
},
|
|
65
73
|
info: {
|
|
66
|
-
color:
|
|
74
|
+
color: A("\x1B[36m"),
|
|
67
75
|
log: console.log,
|
|
68
76
|
enabled: !0
|
|
69
77
|
},
|
|
70
78
|
warn: {
|
|
71
|
-
color:
|
|
79
|
+
color: A("\x1B[33m"),
|
|
72
80
|
log: console.warn,
|
|
73
81
|
enabled: !0
|
|
74
82
|
},
|
|
75
83
|
error: {
|
|
76
|
-
color:
|
|
84
|
+
color: A("\x1B[31m"),
|
|
77
85
|
log: console.error,
|
|
78
86
|
enabled: !0
|
|
79
87
|
},
|
|
@@ -82,52 +90,52 @@ var S = [
|
|
|
82
90
|
enabled: !1
|
|
83
91
|
}
|
|
84
92
|
};
|
|
85
|
-
function
|
|
86
|
-
return `${(/* @__PURE__ */ new Date()).toLocaleTimeString()} [${t ? `${
|
|
93
|
+
function ne(e, t) {
|
|
94
|
+
return `${(/* @__PURE__ */ new Date()).toLocaleTimeString()} [${t ? `${k}:${t}` : k}] ${e}`;
|
|
87
95
|
}
|
|
88
|
-
function
|
|
96
|
+
function N(e, t, n, r) {
|
|
89
97
|
if (!e.enabled) return;
|
|
90
|
-
let i =
|
|
98
|
+
let i = ne(t, r);
|
|
91
99
|
e.log(e.color ? e.color(i) : i), n !== void 0 && e.log(n);
|
|
92
100
|
}
|
|
93
|
-
function
|
|
94
|
-
let t =
|
|
101
|
+
function P(e) {
|
|
102
|
+
let t = M[e], n = /* @__PURE__ */ new Set();
|
|
95
103
|
return Object.assign((e, n, r) => {
|
|
96
|
-
|
|
104
|
+
N(t, e, n, r);
|
|
97
105
|
}, { once(e, r, i) {
|
|
98
|
-
!t.enabled || n.has(e) || (n.add(e),
|
|
106
|
+
!t.enabled || n.has(e) || (n.add(e), N(t, e, r, i));
|
|
99
107
|
} });
|
|
100
108
|
}
|
|
101
|
-
function
|
|
102
|
-
let t =
|
|
109
|
+
function re(e) {
|
|
110
|
+
let t = j.indexOf(e);
|
|
103
111
|
if (t === -1) {
|
|
104
|
-
|
|
112
|
+
N(M.error, `invalid log level: ${e}`);
|
|
105
113
|
return;
|
|
106
114
|
}
|
|
107
|
-
for (let [e, n] of
|
|
115
|
+
for (let [e, n] of j.entries()) M[n].enabled = e >= t;
|
|
108
116
|
}
|
|
109
|
-
var
|
|
110
|
-
function
|
|
117
|
+
var F = A("\x1B[34m"), ie = A("\x1B[36m");
|
|
118
|
+
function ae() {
|
|
111
119
|
let e = [
|
|
112
|
-
` ${
|
|
113
|
-
`${
|
|
114
|
-
` ${
|
|
115
|
-
`${
|
|
120
|
+
` ${F("_")} ${ie("_")} _ _ _`,
|
|
121
|
+
`${F("(_)")} ${ie("(_)")} _ __(_)__| |_____ __| |`,
|
|
122
|
+
` ${F("_")} ${F("_")} | '_ \\ / _| / / -_) _\` |`,
|
|
123
|
+
`${F("(_)")} ${F("(_)")} | .__/_\\__|_\\_\\___\\__,_|`,
|
|
116
124
|
" |_|\n "
|
|
117
125
|
];
|
|
118
126
|
console.log(e.join("\n"));
|
|
119
127
|
}
|
|
120
|
-
var
|
|
121
|
-
banner:
|
|
122
|
-
debug:
|
|
123
|
-
info:
|
|
124
|
-
warn:
|
|
125
|
-
error:
|
|
126
|
-
setLevel:
|
|
128
|
+
var I = {
|
|
129
|
+
banner: ae,
|
|
130
|
+
debug: P("debug"),
|
|
131
|
+
info: P("info"),
|
|
132
|
+
warn: P("warn"),
|
|
133
|
+
error: P("error"),
|
|
134
|
+
setLevel: re
|
|
127
135
|
};
|
|
128
136
|
//#endregion
|
|
129
137
|
//#region src/middleware.ts
|
|
130
|
-
function
|
|
138
|
+
function oe(e) {
|
|
131
139
|
return (t, n, r) => {
|
|
132
140
|
if (t.method !== "GET") {
|
|
133
141
|
r();
|
|
@@ -144,28 +152,28 @@ function ee(e) {
|
|
|
144
152
|
}
|
|
145
153
|
//#endregion
|
|
146
154
|
//#region src/gitignore.ts
|
|
147
|
-
var
|
|
148
|
-
async function
|
|
155
|
+
var L = ".picked/";
|
|
156
|
+
async function se(n, r) {
|
|
149
157
|
if (r) return;
|
|
150
158
|
let i = t(n, ".gitignore");
|
|
151
159
|
if (!e(i)) {
|
|
152
|
-
await
|
|
160
|
+
await h(i, `${L}
|
|
153
161
|
`);
|
|
154
162
|
return;
|
|
155
163
|
}
|
|
156
|
-
let a = await
|
|
157
|
-
if (
|
|
158
|
-
let o = `${a.length > 0 && !a.endsWith("\n") ? "\n" : ""}${
|
|
164
|
+
let a = await m(i, "utf8");
|
|
165
|
+
if (ce(a)) return;
|
|
166
|
+
let o = `${a.length > 0 && !a.endsWith("\n") ? "\n" : ""}${L}
|
|
159
167
|
`;
|
|
160
|
-
await
|
|
168
|
+
await f(i, o);
|
|
161
169
|
}
|
|
162
|
-
function
|
|
163
|
-
return e.split(/\r?\n/).map((e) => e.trim()).some((e) => e ===
|
|
170
|
+
function ce(e) {
|
|
171
|
+
return e.split(/\r?\n/).map((e) => e.trim()).some((e) => e === L || e === ".picked");
|
|
164
172
|
}
|
|
165
173
|
//#endregion
|
|
166
174
|
//#region src/retry.ts
|
|
167
|
-
var
|
|
168
|
-
function
|
|
175
|
+
var R = 6, le = 5e3;
|
|
176
|
+
function z(e) {
|
|
169
177
|
let t;
|
|
170
178
|
try {
|
|
171
179
|
t = new URL(e).hostname;
|
|
@@ -174,12 +182,12 @@ function P(e) {
|
|
|
174
182
|
}
|
|
175
183
|
return t === "localhost" || t === "127.0.0.1" || t === "::1" || t === "[::1]" || t !== "api.picked.app" && t.endsWith(".picked.app");
|
|
176
184
|
}
|
|
177
|
-
function
|
|
185
|
+
function ue(e) {
|
|
178
186
|
return new Promise((t) => {
|
|
179
187
|
setTimeout(t, e);
|
|
180
188
|
});
|
|
181
189
|
}
|
|
182
|
-
async function
|
|
190
|
+
async function B(e, t) {
|
|
183
191
|
let n = null, r = null;
|
|
184
192
|
try {
|
|
185
193
|
n = await e();
|
|
@@ -187,9 +195,9 @@ async function F(e, t) {
|
|
|
187
195
|
r = e;
|
|
188
196
|
}
|
|
189
197
|
if (n !== null) return n;
|
|
190
|
-
for (let i = 1; i <=
|
|
191
|
-
let a =
|
|
192
|
-
t(i,
|
|
198
|
+
for (let i = 1; i <= R; i++) {
|
|
199
|
+
let a = le * 2 ** (i - 1);
|
|
200
|
+
t(i, R, a), await ue(a), r = null;
|
|
193
201
|
try {
|
|
194
202
|
n = await e();
|
|
195
203
|
} catch (e) {
|
|
@@ -202,13 +210,20 @@ async function F(e, t) {
|
|
|
202
210
|
}
|
|
203
211
|
//#endregion
|
|
204
212
|
//#region src/util.ts
|
|
205
|
-
function
|
|
213
|
+
function V(e) {
|
|
206
214
|
return Array.isArray(e) ? e : [];
|
|
207
215
|
}
|
|
216
|
+
function de(e) {
|
|
217
|
+
let t = e.variants, n = (t ?? []).reduce((e, t) => e + t.weight, 0);
|
|
218
|
+
return !t || t.length === 0 || n === 0 ? `${e.weight.toString()}%` : t.map((e) => {
|
|
219
|
+
let t = Math.round(100 * e.weight / n);
|
|
220
|
+
return `${String(e.value)} ${t.toString()}%`;
|
|
221
|
+
}).join(", ");
|
|
222
|
+
}
|
|
208
223
|
//#endregion
|
|
209
224
|
//#region src/prefetch.ts
|
|
210
|
-
var
|
|
211
|
-
function
|
|
225
|
+
var H = 2;
|
|
226
|
+
function U(e) {
|
|
212
227
|
let n = t(e, ".picked");
|
|
213
228
|
return {
|
|
214
229
|
pickedDir: n,
|
|
@@ -217,83 +232,83 @@ function R(e) {
|
|
|
217
232
|
experiencesDir: t(n, "experiences")
|
|
218
233
|
};
|
|
219
234
|
}
|
|
220
|
-
async function
|
|
235
|
+
async function fe(t) {
|
|
221
236
|
if (!e(t)) return null;
|
|
222
237
|
try {
|
|
223
|
-
let e = await
|
|
224
|
-
return
|
|
238
|
+
let e = await m(t, "utf8"), n = JSON.parse(e);
|
|
239
|
+
return pe(n) ? n : null;
|
|
225
240
|
} catch {
|
|
226
241
|
return null;
|
|
227
242
|
}
|
|
228
243
|
}
|
|
229
|
-
function
|
|
244
|
+
function pe(e) {
|
|
230
245
|
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));
|
|
231
246
|
}
|
|
232
|
-
function
|
|
247
|
+
function me(e) {
|
|
233
248
|
let t = /* @__PURE__ */ new Set();
|
|
234
|
-
for (let n of
|
|
249
|
+
for (let n of V(e.steps)) n.layoutContentId && t.add(n.id);
|
|
235
250
|
if (t.size === 0) return [];
|
|
236
251
|
let n = [];
|
|
237
|
-
for (let r of
|
|
252
|
+
for (let r of V(e.experiences)) V(r.nodes).some((e) => e.type === "step" && t.has(e.stepId)) && n.push(r.id);
|
|
238
253
|
return n;
|
|
239
254
|
}
|
|
240
|
-
async function
|
|
241
|
-
let { apiUrl: r, projectId: i, projectRoot: a, headers: o, previewToken: s, reuseWhenUnchanged: c = !0 } = n, l =
|
|
242
|
-
if (await
|
|
243
|
-
let t = await
|
|
244
|
-
if (t?.version ===
|
|
245
|
-
let n =
|
|
255
|
+
async function he(n) {
|
|
256
|
+
let { apiUrl: r, projectId: i, projectRoot: a, headers: o, previewToken: s, reuseWhenUnchanged: c = !0 } = n, l = U(a), u = await ge(r, i, o, s), d = me(u);
|
|
257
|
+
if (await p(l.experiencesDir, { recursive: !0 }), await h(l.projectConfigPath, JSON.stringify(u, null, 2)), c) {
|
|
258
|
+
let t = await fe(l.manifestPath);
|
|
259
|
+
if (t?.version === H && t.projectVersionId === u.versionId && t.workspaceId === u.workspaceId) {
|
|
260
|
+
let n = W(l, d);
|
|
246
261
|
if (Object.values(n).every((t) => e(t))) return {
|
|
247
|
-
config:
|
|
262
|
+
config: u,
|
|
248
263
|
manifest: t,
|
|
249
264
|
experienceContentPaths: n
|
|
250
265
|
};
|
|
251
|
-
|
|
266
|
+
I.info("a manifest-referenced content file is missing; refetching every experience");
|
|
252
267
|
}
|
|
253
268
|
}
|
|
254
|
-
let
|
|
255
|
-
for (let e of
|
|
256
|
-
let n = await
|
|
257
|
-
await
|
|
269
|
+
let f = (/* @__PURE__ */ new Date()).toISOString(), m = [];
|
|
270
|
+
for (let e of d) {
|
|
271
|
+
let n = await _e(r, i, e, o, s), a = t(l.experiencesDir, `${e}.json`);
|
|
272
|
+
await h(a, JSON.stringify(n, null, 2)), m.push({
|
|
258
273
|
id: e,
|
|
259
|
-
fetchedAt:
|
|
274
|
+
fetchedAt: f
|
|
260
275
|
});
|
|
261
276
|
}
|
|
262
277
|
let g = {
|
|
263
|
-
version:
|
|
264
|
-
fetchedAt:
|
|
265
|
-
projectVersionId:
|
|
266
|
-
workspaceId:
|
|
267
|
-
projectId:
|
|
268
|
-
experiences:
|
|
278
|
+
version: H,
|
|
279
|
+
fetchedAt: f,
|
|
280
|
+
projectVersionId: u.versionId,
|
|
281
|
+
workspaceId: u.workspaceId,
|
|
282
|
+
projectId: u.id,
|
|
283
|
+
experiences: m
|
|
269
284
|
};
|
|
270
|
-
return await
|
|
271
|
-
config:
|
|
285
|
+
return await h(l.manifestPath, JSON.stringify(g, null, 2)), {
|
|
286
|
+
config: u,
|
|
272
287
|
manifest: g,
|
|
273
|
-
experienceContentPaths:
|
|
288
|
+
experienceContentPaths: W(l, d)
|
|
274
289
|
};
|
|
275
290
|
}
|
|
276
|
-
function
|
|
291
|
+
function W(e, n) {
|
|
277
292
|
let r = {};
|
|
278
293
|
for (let i of n) r[i] = t(e.experiencesDir, `${i}.json`);
|
|
279
294
|
return r;
|
|
280
295
|
}
|
|
281
|
-
async function
|
|
296
|
+
async function ge(e, t, n, r) {
|
|
282
297
|
let i = () => a(e, t, {
|
|
283
298
|
headers: n,
|
|
284
299
|
previewToken: r
|
|
285
300
|
}), o;
|
|
286
301
|
try {
|
|
287
|
-
o =
|
|
288
|
-
|
|
302
|
+
o = z(e) ? await B(i, (e, t, n) => {
|
|
303
|
+
I.info(`project config not ready, retrying in ${(n / 1e3).toString()}s (${e.toString()}/${t.toString()})`);
|
|
289
304
|
}) : await i();
|
|
290
305
|
} catch (n) {
|
|
291
|
-
throw Error(`[picked] Build-time fetch of project config failed for "${t}" at ${e}: ${
|
|
306
|
+
throw Error(`[picked] Build-time fetch of project config failed for "${t}" at ${e}: ${G(n)}`);
|
|
292
307
|
}
|
|
293
308
|
if (!o) throw Error(`[picked] Build-time fetch of project config returned no usable response for "${t}" at ${e}. Confirm the API is reachable and the project ID is correct.`);
|
|
294
309
|
return o;
|
|
295
310
|
}
|
|
296
|
-
async function
|
|
311
|
+
async function _e(e, t, n, r, a) {
|
|
297
312
|
let o;
|
|
298
313
|
try {
|
|
299
314
|
o = await i(e, t, n, {
|
|
@@ -301,12 +316,12 @@ async function U(e, t, n, r, a) {
|
|
|
301
316
|
previewToken: a
|
|
302
317
|
});
|
|
303
318
|
} catch (t) {
|
|
304
|
-
throw Error(`[picked] Build-time fetch of content for experience "${n}" failed at ${e}: ${
|
|
319
|
+
throw Error(`[picked] Build-time fetch of content for experience "${n}" failed at ${e}: ${G(t)}`);
|
|
305
320
|
}
|
|
306
321
|
if (!o) throw Error(`[picked] Build-time fetch of content for experience "${n}" returned no usable response. Confirm the experience id exists and the API is reachable.`);
|
|
307
322
|
return o;
|
|
308
323
|
}
|
|
309
|
-
function
|
|
324
|
+
function G(e) {
|
|
310
325
|
if (e instanceof Error) return e.message;
|
|
311
326
|
if (typeof e == "string") return e;
|
|
312
327
|
try {
|
|
@@ -316,13 +331,99 @@ function W(e) {
|
|
|
316
331
|
}
|
|
317
332
|
}
|
|
318
333
|
//#endregion
|
|
334
|
+
//#region src/telemetry.ts
|
|
335
|
+
var ve = "https://production.otel.picked.app/v1/traces", ye = /* @__PURE__ */ new Set(["resolveId", "load"]);
|
|
336
|
+
function be(e = v()) {
|
|
337
|
+
let t = g(), n = Date.now(), r = [], i = /* @__PURE__ */ new Map();
|
|
338
|
+
return {
|
|
339
|
+
record: (n, a) => {
|
|
340
|
+
if (ye.has(n)) {
|
|
341
|
+
let e = i.get(n) ?? {
|
|
342
|
+
calls: 0,
|
|
343
|
+
totalMs: 0
|
|
344
|
+
};
|
|
345
|
+
i.set(n, {
|
|
346
|
+
calls: e.calls + 1,
|
|
347
|
+
totalMs: e.totalMs + a
|
|
348
|
+
});
|
|
349
|
+
return;
|
|
350
|
+
}
|
|
351
|
+
let o = Date.now();
|
|
352
|
+
r.push({
|
|
353
|
+
name: `picked.vite.${n}`,
|
|
354
|
+
traceId: e,
|
|
355
|
+
spanId: g(),
|
|
356
|
+
parentSpanId: t,
|
|
357
|
+
startTimeUnixNano: y(o - a),
|
|
358
|
+
endTimeUnixNano: y(o),
|
|
359
|
+
attributes: { "picked.vite.hook": n },
|
|
360
|
+
status: "ok"
|
|
361
|
+
});
|
|
362
|
+
},
|
|
363
|
+
flush: async (a) => {
|
|
364
|
+
let o = {};
|
|
365
|
+
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 c = s();
|
|
367
|
+
r.push({
|
|
368
|
+
name: "picked.vite.build",
|
|
369
|
+
traceId: e,
|
|
370
|
+
spanId: t,
|
|
371
|
+
startTimeUnixNano: y(n),
|
|
372
|
+
endTimeUnixNano: y(Date.now()),
|
|
373
|
+
attributes: {
|
|
374
|
+
"picked.env.provider": c.provider,
|
|
375
|
+
"picked.env.ci": c.ci,
|
|
376
|
+
...a,
|
|
377
|
+
...o
|
|
378
|
+
},
|
|
379
|
+
status: "ok"
|
|
380
|
+
});
|
|
381
|
+
try {
|
|
382
|
+
let e = _({
|
|
383
|
+
endpoint: ve,
|
|
384
|
+
resource: { "service.name": "picked-vite-plugin" },
|
|
385
|
+
headers: { "Picked-Telemetry": "vite-plugin" },
|
|
386
|
+
maxBatchSize: r.length
|
|
387
|
+
});
|
|
388
|
+
for (let t of r) e.record(t);
|
|
389
|
+
await e.flush();
|
|
390
|
+
} catch {}
|
|
391
|
+
}
|
|
392
|
+
};
|
|
393
|
+
}
|
|
394
|
+
function xe(e) {
|
|
395
|
+
return typeof e == "object" && !!e && "then" in e;
|
|
396
|
+
}
|
|
397
|
+
function K(e, t, n) {
|
|
398
|
+
return function(...r) {
|
|
399
|
+
let i = performance.now(), a = () => {
|
|
400
|
+
n.record(e, performance.now() - i);
|
|
401
|
+
}, o = t.apply(this, r);
|
|
402
|
+
return xe(o) ? Promise.resolve(o).then(a, a) : a(), o;
|
|
403
|
+
};
|
|
404
|
+
}
|
|
405
|
+
function q(e) {
|
|
406
|
+
return typeof e == "function";
|
|
407
|
+
}
|
|
408
|
+
function Se(e, t) {
|
|
409
|
+
if (!e) return t;
|
|
410
|
+
for (let [n, r] of Object.entries(t)) if (n !== "name") {
|
|
411
|
+
if (q(r)) {
|
|
412
|
+
Reflect.set(t, n, K(n, r, e));
|
|
413
|
+
continue;
|
|
414
|
+
}
|
|
415
|
+
typeof r == "object" && r && "handler" in r && q(r.handler) && Reflect.set(r, "handler", K(n, r.handler, e));
|
|
416
|
+
}
|
|
417
|
+
return t;
|
|
418
|
+
}
|
|
419
|
+
//#endregion
|
|
319
420
|
//#region src/virtual-module/api.ts
|
|
320
|
-
function
|
|
421
|
+
function Ce() {
|
|
321
422
|
return "export const manifestMetadata = {\n mode: 'api',\n fetchedAt: null,\n projectVersionId: null,\n workspaceId: null,\n}\n";
|
|
322
423
|
}
|
|
323
424
|
//#endregion
|
|
324
425
|
//#region src/virtual-module/build.ts
|
|
325
|
-
function
|
|
426
|
+
function we(e) {
|
|
326
427
|
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");
|
|
327
428
|
return `import { registerPickedBundle } from '@picked/client/plugins/dynamic-experiences'
|
|
328
429
|
import projectConfigJson from ${i(t)}
|
|
@@ -352,7 +453,7 @@ registerPickedBundle({ projectConfig, experienceContent, manifestMetadata })
|
|
|
352
453
|
}
|
|
353
454
|
//#endregion
|
|
354
455
|
//#region src/virtual-module/dev.ts
|
|
355
|
-
function
|
|
456
|
+
function Te(e) {
|
|
356
457
|
let { apiUrl: t, projectId: n, projectConfig: r, previewToken: i } = e, a = r ? "import { fetchExperienceContent, registerPickedBundle } from '@picked/client/plugins/dynamic-experiences'" : "import { fetchProject, fetchExperienceContent } from '@picked/client/plugins/dynamic-experiences'", o = r ? `export const projectConfig = ${JSON.stringify(r)}` : "export const projectConfig = await fetchProject(apiUrl, projectId, { previewToken: previewToken ?? undefined })", s = r ? "\nregisterPickedBundle({ projectConfig, experienceContent, manifestMetadata })\n" : "";
|
|
357
458
|
return `${a}
|
|
358
459
|
|
|
@@ -378,10 +479,10 @@ ${s}`;
|
|
|
378
479
|
}
|
|
379
480
|
//#endregion
|
|
380
481
|
//#region src/index.ts
|
|
381
|
-
var
|
|
482
|
+
var Ee = 5;
|
|
382
483
|
function J(e, t, n) {
|
|
383
484
|
if (t.length === 0) return;
|
|
384
|
-
if (t.length >
|
|
485
|
+
if (t.length > Ee) {
|
|
385
486
|
console.log(`\n ${e}: ${t.length.toString()} loaded\n`);
|
|
386
487
|
return;
|
|
387
488
|
}
|
|
@@ -396,10 +497,10 @@ function J(e, t, n) {
|
|
|
396
497
|
""
|
|
397
498
|
].join("\n"));
|
|
398
499
|
}
|
|
399
|
-
function
|
|
500
|
+
function De(e, t) {
|
|
400
501
|
t.length !== 0 && console.log(`\n ${e}: ${t.length.toString()} loaded\n`);
|
|
401
502
|
}
|
|
402
|
-
var
|
|
503
|
+
var Oe = [
|
|
403
504
|
{
|
|
404
505
|
header: "Name",
|
|
405
506
|
value: (e) => e.name
|
|
@@ -413,14 +514,14 @@ var le = [
|
|
|
413
514
|
value: (e) => e.enabled ? "\x1B[32m enabled\x1B[0m" : "\x1B[2mdisabled\x1B[0m"
|
|
414
515
|
},
|
|
415
516
|
{
|
|
416
|
-
header: "
|
|
417
|
-
value: (e) =>
|
|
517
|
+
header: "Split",
|
|
518
|
+
value: (e) => de(e)
|
|
418
519
|
},
|
|
419
520
|
{
|
|
420
521
|
header: "Ver",
|
|
421
522
|
value: (e) => `v${e.version.toString()}`
|
|
422
523
|
}
|
|
423
|
-
],
|
|
524
|
+
], ke = [
|
|
424
525
|
{
|
|
425
526
|
header: "Name",
|
|
426
527
|
value: (e) => e.name
|
|
@@ -441,7 +542,7 @@ var le = [
|
|
|
441
542
|
header: "Targets",
|
|
442
543
|
value: (e) => e.targets.length.toString()
|
|
443
544
|
}
|
|
444
|
-
],
|
|
545
|
+
], Ae = [
|
|
445
546
|
{
|
|
446
547
|
header: "Name",
|
|
447
548
|
value: (e) => e.name
|
|
@@ -454,7 +555,7 @@ var le = [
|
|
|
454
555
|
header: "Fields",
|
|
455
556
|
value: (e) => (e.fieldIds?.length ?? 0).toString()
|
|
456
557
|
}
|
|
457
|
-
],
|
|
558
|
+
], je = [
|
|
458
559
|
{
|
|
459
560
|
header: "Name",
|
|
460
561
|
value: (e) => e.name
|
|
@@ -471,98 +572,101 @@ var le = [
|
|
|
471
572
|
header: "Required",
|
|
472
573
|
value: (e) => e.required ? "yes" : "no"
|
|
473
574
|
}
|
|
474
|
-
],
|
|
575
|
+
], Me = [{
|
|
475
576
|
header: "Name",
|
|
476
577
|
value: (e) => e.name
|
|
477
578
|
}, {
|
|
478
579
|
header: "Key",
|
|
479
580
|
value: (e) => e.key
|
|
480
581
|
}];
|
|
481
|
-
function
|
|
482
|
-
return "0.0.1-dev.
|
|
582
|
+
function Ne() {
|
|
583
|
+
return "0.0.1-dev.1787543060859";
|
|
483
584
|
}
|
|
484
|
-
var
|
|
485
|
-
function
|
|
585
|
+
var Pe = "https://api.picked.app", Y = "virtual:picked/data", X = `\0${Y}`;
|
|
586
|
+
function Fe(e) {
|
|
486
587
|
for (let t of Object.values(e)) if (t.type === "chunk" && t.moduleIds.includes(X)) return t.fileName;
|
|
487
588
|
}
|
|
488
|
-
function
|
|
589
|
+
function Ie(e, t) {
|
|
489
590
|
return e === "" || e.endsWith("/") ? `${e}${t}` : `${e}/${t}`;
|
|
490
591
|
}
|
|
491
|
-
async function
|
|
592
|
+
async function Le(e) {
|
|
492
593
|
try {
|
|
493
594
|
let t = await o({
|
|
494
595
|
config: e,
|
|
495
596
|
onWarn: (e) => {
|
|
496
|
-
|
|
597
|
+
I.warn(e);
|
|
497
598
|
}
|
|
498
599
|
});
|
|
499
|
-
|
|
600
|
+
I.info(`generated types at ${t.typesOutput}`);
|
|
500
601
|
} catch (e) {
|
|
501
602
|
let t = e instanceof Error ? e.message : String(e);
|
|
502
603
|
throw Error(`type generation failed: ${t}. Fix the schema source, or set \`generateTypes: false\` on the picked plugin to skip it.`);
|
|
503
604
|
}
|
|
504
605
|
}
|
|
505
|
-
|
|
506
|
-
|
|
606
|
+
function Re(e, t, n) {
|
|
607
|
+
return e && c(t, n) ? e : null;
|
|
608
|
+
}
|
|
609
|
+
async function ze(e, t) {
|
|
610
|
+
let n = await d(e, t);
|
|
507
611
|
if (!n) throw Error("picked.config.{ts,js,json} is required. Add a picked.config.ts with projectId and apiUrl.");
|
|
508
612
|
return n;
|
|
509
613
|
}
|
|
510
614
|
function Z(e, t, n) {
|
|
511
615
|
if (t !== void 0 && n !== void 0 && t !== n) throw Error(`picked plugin option \`${e}\` is "${t}", and picked.config says "${n}". Remove the plugin option; picked.config is the one place this belongs.`);
|
|
512
616
|
}
|
|
513
|
-
function
|
|
617
|
+
function Be(e) {
|
|
514
618
|
let t = [];
|
|
515
619
|
if (e.projectId !== void 0 && t.push("`projectId`"), e.apiUrl !== void 0 && t.push("`apiUrl`"), t.length === 0) return;
|
|
516
620
|
let n = t.length > 1;
|
|
517
|
-
|
|
621
|
+
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.`);
|
|
518
622
|
}
|
|
519
|
-
async function
|
|
520
|
-
let n = await
|
|
521
|
-
n && n.projectId !== t &&
|
|
623
|
+
async function Ve(e, t) {
|
|
624
|
+
let n = await u(e);
|
|
625
|
+
n && n.projectId !== t && I.warn(`using project "${t}" (picked.config default: "${n.projectId}") — run 'picked status' to inspect`);
|
|
522
626
|
}
|
|
523
627
|
var Q = /* @__PURE__ */ new Map();
|
|
524
|
-
function
|
|
628
|
+
function He(e, t, n) {
|
|
525
629
|
return JSON.stringify([
|
|
526
630
|
e,
|
|
527
631
|
t,
|
|
528
632
|
n
|
|
529
633
|
]);
|
|
530
634
|
}
|
|
531
|
-
function
|
|
532
|
-
let i = t.mode ?? "bundle", o = t.generateTypes ?? !0,
|
|
533
|
-
return {
|
|
635
|
+
function Ue(t = {}) {
|
|
636
|
+
let i = t.mode ?? "bundle", o = t.generateTypes ?? !0, s = [], c = process.cwd(), d = "serve", f = "/", p = null, m = !1, h, g, _ = null, v = l() ? null : be();
|
|
637
|
+
return Se(v, {
|
|
534
638
|
name: "picked",
|
|
535
|
-
config: async (
|
|
536
|
-
|
|
537
|
-
let { projectId:
|
|
538
|
-
Z("projectId",
|
|
539
|
-
projectId:
|
|
540
|
-
apiUrl:
|
|
541
|
-
}),
|
|
542
|
-
projectId:
|
|
543
|
-
apiUrl:
|
|
639
|
+
config: async (l, f) => {
|
|
640
|
+
d = f.command, c = l.root === void 0 ? process.cwd() : n(process.cwd(), l.root);
|
|
641
|
+
let { projectId: y, apiUrl: b } = t, x = await u(c);
|
|
642
|
+
Z("projectId", y, x?.projectId), Z("apiUrl", b, x?.apiUrl), Be({
|
|
643
|
+
projectId: y,
|
|
644
|
+
apiUrl: b
|
|
645
|
+
}), p = await ze(c, {
|
|
646
|
+
projectId: y,
|
|
647
|
+
apiUrl: b
|
|
544
648
|
});
|
|
545
|
-
let { projectId:
|
|
546
|
-
|
|
547
|
-
let
|
|
548
|
-
if (i === "api")
|
|
549
|
-
else if (
|
|
550
|
-
let t =
|
|
551
|
-
|
|
649
|
+
let { projectId: S, apiUrl: C, previewToken: w } = p;
|
|
650
|
+
v = Re(v, p, t.telemetry), I.banner(), o && !m && (m = !0, await Le(p)), C !== Pe && I.warn(`using custom API URL: ${C}`), await Ve(c, S);
|
|
651
|
+
let T = r("vite-plugin", Ne());
|
|
652
|
+
if (i === "api") I.debug("mode is 'api': skipping the project-config prefetch");
|
|
653
|
+
else if (f.command === "build") {
|
|
654
|
+
let t = He(C, S, c);
|
|
655
|
+
h = t;
|
|
552
656
|
let n = Q.get(t);
|
|
553
657
|
n === void 0 && (n = (async () => {
|
|
554
|
-
|
|
555
|
-
let t =
|
|
556
|
-
apiUrl:
|
|
557
|
-
projectId:
|
|
558
|
-
projectRoot:
|
|
559
|
-
headers:
|
|
560
|
-
previewToken:
|
|
658
|
+
I.info(`prefetching project config + content for "${S}"`);
|
|
659
|
+
let t = U(c), n = e(t.pickedDir), r = performance.now(), i = await he({
|
|
660
|
+
apiUrl: C,
|
|
661
|
+
projectId: S,
|
|
662
|
+
projectRoot: c,
|
|
663
|
+
headers: T,
|
|
664
|
+
previewToken: w ?? void 0
|
|
561
665
|
}), a = (performance.now() - r).toFixed(0);
|
|
562
|
-
await
|
|
666
|
+
await se(c, n);
|
|
563
667
|
let o = i.config;
|
|
564
668
|
return $(o, a), {
|
|
565
|
-
virtualSource:
|
|
669
|
+
virtualSource: we({
|
|
566
670
|
projectConfigPath: t.projectConfigPath,
|
|
567
671
|
experienceContentPaths: i.experienceContentPaths,
|
|
568
672
|
manifestMetadata: {
|
|
@@ -572,36 +676,40 @@ function Ce(t = {}) {
|
|
|
572
676
|
workspaceId: i.manifest.workspaceId
|
|
573
677
|
}
|
|
574
678
|
}),
|
|
575
|
-
features:
|
|
679
|
+
features: V(o.features)
|
|
576
680
|
};
|
|
577
681
|
})(), n.catch(() => Q.delete(t)), Q.set(t, n));
|
|
578
682
|
let r = await n;
|
|
579
|
-
g = r.virtualSource,
|
|
580
|
-
} else if (
|
|
683
|
+
g = r.virtualSource, s = r.features;
|
|
684
|
+
} else if (f.mode === "production") I.debug("skipping the dev project-config fetch for a production serve resolution");
|
|
581
685
|
else {
|
|
582
|
-
|
|
583
|
-
let e = performance.now(), t = () => a(
|
|
584
|
-
headers:
|
|
585
|
-
previewToken:
|
|
586
|
-
}), n =
|
|
587
|
-
|
|
686
|
+
I.info(`fetching project config for "${S}" (dev)`);
|
|
687
|
+
let e = performance.now(), t = () => a(C, S, {
|
|
688
|
+
headers: T,
|
|
689
|
+
previewToken: w ?? void 0
|
|
690
|
+
}), n = z(C) ? await B(t, (e, t, n) => {
|
|
691
|
+
I.info(`local API not ready, retrying in ${(n / 1e3).toString()}s (${e.toString()}/${t.toString()})`);
|
|
588
692
|
}) : await t(), r = (performance.now() - e).toFixed(0);
|
|
589
|
-
_ = n, n ? (
|
|
693
|
+
_ = n, n ? (s = V(n.features), $(n, r)) : I.warn(`failed to fetch project config for "${S}" (${r}ms)`);
|
|
590
694
|
}
|
|
591
695
|
},
|
|
592
696
|
configResolved(e) {
|
|
593
|
-
|
|
697
|
+
f = e.base;
|
|
594
698
|
},
|
|
595
699
|
closeBundle() {
|
|
596
|
-
|
|
700
|
+
h !== void 0 && Q.delete(h), v?.flush({
|
|
701
|
+
"picked.vite.command": d,
|
|
702
|
+
"picked.data.mode": i,
|
|
703
|
+
"picked.source": p?.source ?? "unknown"
|
|
704
|
+
});
|
|
597
705
|
},
|
|
598
706
|
transformIndexHtml: {
|
|
599
707
|
order: "post",
|
|
600
708
|
handler(e, t) {
|
|
601
709
|
if (i === "api" || t.bundle === void 0) return;
|
|
602
|
-
let n =
|
|
710
|
+
let n = Fe(t.bundle);
|
|
603
711
|
if (n === void 0) return;
|
|
604
|
-
let r =
|
|
712
|
+
let r = Ie(f, n);
|
|
605
713
|
if (!e.includes(`"${r}"`)) return [{
|
|
606
714
|
tag: "link",
|
|
607
715
|
attrs: {
|
|
@@ -618,20 +726,20 @@ function Ce(t = {}) {
|
|
|
618
726
|
},
|
|
619
727
|
load(e) {
|
|
620
728
|
if (e === X) {
|
|
621
|
-
if (i === "api") return
|
|
622
|
-
if (
|
|
623
|
-
if (!
|
|
624
|
-
return
|
|
625
|
-
apiUrl:
|
|
626
|
-
projectId:
|
|
729
|
+
if (i === "api") return Ce();
|
|
730
|
+
if (d === "build") return g;
|
|
731
|
+
if (!p) throw Error("picked plugin config hook must run before virtual module load");
|
|
732
|
+
return Te({
|
|
733
|
+
apiUrl: p.apiUrl,
|
|
734
|
+
projectId: p.projectId,
|
|
627
735
|
projectConfig: _,
|
|
628
|
-
previewToken:
|
|
736
|
+
previewToken: p.previewToken ?? void 0
|
|
629
737
|
});
|
|
630
738
|
}
|
|
631
739
|
},
|
|
632
740
|
configureServer(e) {
|
|
633
741
|
if (t.disableLauncher) return;
|
|
634
|
-
e.middlewares.use(
|
|
742
|
+
e.middlewares.use(oe(() => E(s)));
|
|
635
743
|
let n = e.printUrls.bind(e);
|
|
636
744
|
e.printUrls = () => {
|
|
637
745
|
let t = e.resolvedUrls?.local[0];
|
|
@@ -647,21 +755,21 @@ function Ce(t = {}) {
|
|
|
647
755
|
handler(e, n) {
|
|
648
756
|
if (!t.disableLauncher) {
|
|
649
757
|
if ("index.html" in n) {
|
|
650
|
-
|
|
758
|
+
I.debug("index.html came from the build; skipping the launcher page");
|
|
651
759
|
return;
|
|
652
760
|
}
|
|
653
761
|
this.emitFile({
|
|
654
762
|
type: "asset",
|
|
655
763
|
fileName: "index.html",
|
|
656
|
-
source:
|
|
764
|
+
source: E(s)
|
|
657
765
|
});
|
|
658
766
|
}
|
|
659
767
|
}
|
|
660
768
|
}
|
|
661
|
-
};
|
|
769
|
+
});
|
|
662
770
|
}
|
|
663
771
|
function $(e, t) {
|
|
664
|
-
let n =
|
|
772
|
+
let n = V(e.features), r = V(e.experiences), i = V(e.steps), a = V(e.fields), o = V(e.conditions), s = V(e.actions), c = JSON.stringify(e).length, l = [
|
|
665
773
|
`${n.length.toString()} features`,
|
|
666
774
|
`${r.length.toString()} experiences`,
|
|
667
775
|
`${i.length.toString()} steps`,
|
|
@@ -669,7 +777,7 @@ function $(e, t) {
|
|
|
669
777
|
`${o.length.toString()} conditions`,
|
|
670
778
|
`${s.length.toString()} actions`
|
|
671
779
|
].join(", ");
|
|
672
|
-
|
|
780
|
+
I.info(`fetched config in ${t}ms (${l})`), J("Features", n, Oe), J("Experiences", r, ke), J("Steps", i, Ae), J("Fields", a, je), J("Conditions", o, Me), De("Actions", s), I.debug(`config size: ${c.toString()} bytes`);
|
|
673
781
|
}
|
|
674
782
|
//#endregion
|
|
675
|
-
export {
|
|
783
|
+
export { Ue as picked };
|