@picked/vite-plugin-picked 0.0.1-dev.1786675074931 → 0.0.1-dev.1787537193674

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