@picked/vite-plugin-picked 0.0.1-dev.1786072899095 → 0.0.1-dev.1786601464574

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/esm/index.js CHANGED
@@ -1,28 +1,30 @@
1
1
  import { existsSync as e } from "node:fs";
2
- import { createClientHeaders as t, fetchExperienceContent as n, fetchProject as r } from "@picked/client/plugins/dynamic-experiences";
3
- import { appendFile as i, mkdir as a, readFile as o, writeFile as s } from "node:fs/promises";
4
- import { join as c } from "node:path";
2
+ import { join as t, resolve as n } from "node:path";
3
+ import { createClientHeaders as r, fetchExperienceContent as i, fetchProject as a } from "@picked/delivery-api-client";
4
+ import { generate as o } from "@picked/typegen";
5
+ import { loadPickedConfig as s, loadResolvedPickedConfig as c } from "@picked/config";
6
+ import { appendFile as l, mkdir as u, readFile as d, writeFile as f } from "node:fs/promises";
5
7
  //#region \0@oxc-project+runtime@0.142.0/helpers/esm/taggedTemplateLiteral.js
6
- function l(e, t) {
8
+ function p(e, t) {
7
9
  return t ||= e.slice(0), Object.freeze(Object.defineProperties(e, { raw: { value: Object.freeze(t) } }));
8
10
  }
9
11
  //#endregion
10
12
  //#region src/launcher.ts
11
- var u;
12
- function d(e) {
13
+ var m;
14
+ function h(e) {
13
15
  let t = JSON.stringify(e), n = e.length > 0 ? e.map((e) => `
14
16
  <div class="feature-row">
15
17
  <label>
16
- <input type="checkbox" data-feature-id="${p(e.id)}" checked>
17
- <span class="feature-name">${f(e.name)}</span>
18
- <span class="feature-id">${f(e.id)}</span>
18
+ <input type="checkbox" data-feature-id="${_(e.id)}" checked>
19
+ <span class="feature-name">${g(e.name)}</span>
20
+ <span class="feature-id">${g(e.id)}</span>
19
21
  </label>
20
- <select data-value-for="${p(e.id)}">
22
+ <select data-value-for="${_(e.id)}">
21
23
  <option value="true" selected>true</option>
22
24
  <option value="false">false</option>
23
25
  </select>
24
26
  </div>`).join("") : "<p class=\"text no-features\">No features configured for this project.</p>";
25
- return String.raw(u ||= l([
27
+ return String.raw(m ||= p([
26
28
  "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n <meta charset=\"UTF-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n <meta name=\"robots\" content=\"noindex, nofollow\">\n <title>Picked</title>\n <style>\n main {\n position: fixed;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n display: grid;\n align-items: center;\n justify-content: center;\n font-family: monospace;\n color: #4A4A4A\n }\n\n .wrap {\n padding-left: 1.5rem;\n padding-right: 1.5rem;\n max-width: 480px;\n width: 100%;\n }\n\n .title {\n font-size: 1.125rem;\n font-weight: 700;\n margin-bottom: 0;\n }\n\n .text {\n margin-top: .5rem;\n font-size: .875rem\n }\n\n .text a {\n color: #4A4A4A;\n text-decoration: none;\n }\n\n .text a:hover {\n cursor: pointer;\n text-decoration: underline\n }\n\n .preview-form {\n margin-top: 2rem;\n display: flex;\n flex-direction: column;\n gap: 0.5rem;\n }\n\n .preview-input {\n padding: 0.5rem;\n border: 1px solid #4A4A4A;\n border-radius: 0;\n font-family: monospace;\n }\n\n .preview-button {\n padding: 0.5rem;\n background: #4A4A4A;\n color: white;\n border: none;\n border-radius: 0;\n cursor: pointer;\n font-family: monospace;\n }\n\n .preview-button:hover {\n opacity: 0.9;\n }\n\n .buttons {\n display: grid;\n gap: 0.5em;\n grid-template-columns: 1fr 1fr;\n }\n\n #copy-status {\n font-size: 1em;\n text-align: right;\n margin-top: 0.5em;\n }\n\n .features-section {\n margin-top: 1.5rem;\n }\n\n .features-label {\n font-weight: 700;\n font-size: .875rem;\n margin-bottom: 0.5rem;\n }\n\n .feature-row {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 0.5rem;\n padding: 0.25rem 0;\n }\n\n .feature-row label {\n display: flex;\n align-items: center;\n gap: 0.5rem;\n cursor: pointer;\n min-width: 0;\n flex: 1;\n }\n\n .feature-name {\n font-size: .875rem;\n }\n\n .feature-id {\n font-size: .75rem;\n color: #888;\n }\n\n .feature-row select {\n font-family: monospace;\n font-size: .75rem;\n padding: 0.125rem 0.25rem;\n border: 1px solid #4A4A4A;\n border-radius: 0;\n background: white;\n flex-shrink: 0;\n }\n\n .no-features {\n color: #888;\n font-style: italic;\n }\n\n .url-history {\n margin-top: 0.5rem;\n font-size: .75rem;\n }\n\n .url-history-item {\n display: flex;\n align-items: center;\n gap: 0.25rem;\n padding: 0.125rem 0;\n }\n\n .url-history-item button {\n background: none;\n border: none;\n cursor: pointer;\n font-family: monospace;\n font-size: .75rem;\n color: #888;\n padding: 0;\n }\n\n .url-history-item button.url-link {\n color: #4A4A4A;\n text-decoration: none;\n text-align: left;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n flex: 1;\n min-width: 0;\n }\n\n .url-history-item button.url-link:hover {\n text-decoration: underline;\n }\n\n .url-history-item button.url-delete:hover {\n color: #b71c1c;\n }\n\n @media (min-width: 640px) {\n .title {\n font-size: 1.25rem\n }\n\n .text {\n font-size: 1rem\n }\n }\n </style>\n</head>\n<body>\n\n<main>\n <div class=\"wrap\">\n <p class=\"title\">Picked</p>\n <p class=\"text\">\n Learn more at\n <a href=\"https://picked.app\">\n https://picked.app\n </a>\n </p>\n <div class=\"preview-form\">\n <input type=\"text\" id=\"url-input\" pattern=\"^(https?://)?.+\" placeholder=\"Enter preview URL\" required\n class=\"preview-input\">\n <div id=\"url-history\" class=\"url-history\"></div>\n <div class=\"features-section\">\n <p class=\"features-label\">Features</p>\n ",
27
29
  "\n </div>\n <div class=\"buttons\">\n <button type=\"button\" class=\"preview-button\" id=\"copy-btn\">Copy</button>\n <button type=\"button\" class=\"preview-button\" id=\"preview-btn\">Preview</button>\n </div>\n <p class=\"text\" id=\"copy-status\" aria-live=\"polite\" style=\"visibility:hidden;\">\n &nbsp;\n </p>\n </div>\n </div>\n\n <script>\n var FEATURES = ",
28
30
  ";\n var STORAGE_KEY_URL = 'picked-launcher-url';\n var STORAGE_KEY_HISTORY = 'picked-launcher-history';\n var STORAGE_KEY_SELECTIONS = 'picked-launcher-selections';\n\n function getUrlInput() {\n return document.getElementById('url-input');\n }\n\n // URL history\n function getHistory() {\n try {\n var raw = localStorage.getItem(STORAGE_KEY_HISTORY);\n if (!raw) return [];\n var parsed = JSON.parse(raw);\n return Array.isArray(parsed) ? parsed : [];\n } catch (e) {\n return [];\n }\n }\n\n function saveHistory(history) {\n localStorage.setItem(STORAGE_KEY_HISTORY, JSON.stringify(history));\n }\n\n function addToHistory(url) {\n var history = getHistory().filter(function(h) { return h !== url; });\n history.unshift(url);\n if (history.length > 10) history = history.slice(0, 10);\n saveHistory(history);\n renderHistory();\n }\n\n function removeFromHistory(url) {\n var history = getHistory().filter(function(h) { return h !== url; });\n saveHistory(history);\n renderHistory();\n }\n\n function renderHistory() {\n var container = document.getElementById('url-history');\n if (!container) return;\n var history = getHistory();\n if (history.length === 0) {\n container.innerHTML = '';\n return;\n }\n container.innerHTML = history.map(function(url) {\n return '<div class=\"url-history-item\">' +\n '<button type=\"button\" class=\"url-link\" data-history-url=\"' + escapeAttr(url) + '\">' + escapeHtml(url) + '</button>' +\n '<button type=\"button\" class=\"url-delete\" data-history-delete=\"' + escapeAttr(url) + '\">x</button>' +\n '</div>';\n }).join('');\n }\n\n // Feature selection persistence\n function getSelections() {\n try {\n var raw = localStorage.getItem(STORAGE_KEY_SELECTIONS);\n if (!raw) return {};\n var parsed = JSON.parse(raw);\n return typeof parsed === 'object' && parsed !== null ? parsed : {};\n } catch (e) {\n return {};\n }\n }\n\n function saveSelections() {\n var selections = {};\n FEATURES.forEach(function(f) {\n var checkbox = document.querySelector('input[data-feature-id=\"' + f.id + '\"]');\n var select = document.querySelector('select[data-value-for=\"' + f.id + '\"]');\n if (checkbox && select) {\n selections[f.id] = { checked: checkbox.checked, value: select.value };\n }\n });\n localStorage.setItem(STORAGE_KEY_SELECTIONS, JSON.stringify(selections));\n }\n\n function restoreSelections() {\n var selections = getSelections();\n FEATURES.forEach(function(f) {\n var saved = selections[f.id];\n if (!saved) return;\n var checkbox = document.querySelector('input[data-feature-id=\"' + f.id + '\"]');\n var select = document.querySelector('select[data-value-for=\"' + f.id + '\"]');\n if (checkbox) checkbox.checked = saved.checked;\n if (select) select.value = saved.value;\n });\n }\n\n function escapeHtml(str) {\n var div = document.createElement('div');\n div.textContent = str;\n return div.innerHTML;\n }\n\n function escapeAttr(str) {\n return str.replace(/&/g, '&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>"
@@ -32,46 +34,46 @@ function d(e) {
32
34
  ";\n var STORAGE_KEY_URL = 'picked-launcher-url';\n var STORAGE_KEY_HISTORY = 'picked-launcher-history';\n var STORAGE_KEY_SELECTIONS = 'picked-launcher-selections';\n\n function getUrlInput() {\n return document.getElementById('url-input');\n }\n\n // URL history\n function getHistory() {\n try {\n var raw = localStorage.getItem(STORAGE_KEY_HISTORY);\n if (!raw) return [];\n var parsed = JSON.parse(raw);\n return Array.isArray(parsed) ? parsed : [];\n } catch (e) {\n return [];\n }\n }\n\n function saveHistory(history) {\n localStorage.setItem(STORAGE_KEY_HISTORY, JSON.stringify(history));\n }\n\n function addToHistory(url) {\n var history = getHistory().filter(function(h) { return h !== url; });\n history.unshift(url);\n if (history.length > 10) history = history.slice(0, 10);\n saveHistory(history);\n renderHistory();\n }\n\n function removeFromHistory(url) {\n var history = getHistory().filter(function(h) { return h !== url; });\n saveHistory(history);\n renderHistory();\n }\n\n function renderHistory() {\n var container = document.getElementById('url-history');\n if (!container) return;\n var history = getHistory();\n if (history.length === 0) {\n container.innerHTML = '';\n return;\n }\n container.innerHTML = history.map(function(url) {\n return '<div class=\"url-history-item\">' +\n '<button type=\"button\" class=\"url-link\" data-history-url=\"' + escapeAttr(url) + '\">' + escapeHtml(url) + '</button>' +\n '<button type=\"button\" class=\"url-delete\" data-history-delete=\"' + escapeAttr(url) + '\">x</button>' +\n '</div>';\n }).join('');\n }\n\n // Feature selection persistence\n function getSelections() {\n try {\n var raw = localStorage.getItem(STORAGE_KEY_SELECTIONS);\n if (!raw) return {};\n var parsed = JSON.parse(raw);\n return typeof parsed === 'object' && parsed !== null ? parsed : {};\n } catch (e) {\n return {};\n }\n }\n\n function saveSelections() {\n var selections = {};\n FEATURES.forEach(function(f) {\n var checkbox = document.querySelector('input[data-feature-id=\"' + f.id + '\"]');\n var select = document.querySelector('select[data-value-for=\"' + f.id + '\"]');\n if (checkbox && select) {\n selections[f.id] = { checked: checkbox.checked, value: select.value };\n }\n });\n localStorage.setItem(STORAGE_KEY_SELECTIONS, JSON.stringify(selections));\n }\n\n function restoreSelections() {\n var selections = getSelections();\n FEATURES.forEach(function(f) {\n var saved = selections[f.id];\n if (!saved) return;\n var checkbox = document.querySelector('input[data-feature-id=\"' + f.id + '\"]');\n var select = document.querySelector('select[data-value-for=\"' + f.id + '\"]');\n if (checkbox) checkbox.checked = saved.checked;\n if (select) select.value = saved.value;\n });\n }\n\n function escapeHtml(str) {\n var div = document.createElement('div');\n div.textContent = str;\n return div.innerHTML;\n }\n\n function escapeAttr(str) {\n return str.replace(/&/g, '&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>"
33
35
  ]), n, t);
34
36
  }
35
- function f(e) {
37
+ function g(e) {
36
38
  return e.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll("\"", "&quot;");
37
39
  }
38
- function p(e) {
40
+ function _(e) {
39
41
  return e.replaceAll("&", "&amp;").replaceAll("\"", "&quot;").replaceAll("<", "&lt;").replaceAll(">", "&gt;");
40
42
  }
41
43
  //#endregion
42
44
  //#region src/log.ts
43
- var m = "picked", ee = "\x1B[0m";
44
- function te() {
45
+ var v = "picked", y = "\x1B[0m";
46
+ function ee() {
45
47
  let e = process.env.NO_COLOR;
46
48
  return e === "1" || e === "true";
47
49
  }
48
- function h(e) {
49
- return (t) => te() ? t : `${e}${t}${ee}`;
50
+ function b(e) {
51
+ return (t) => ee() ? t : `${e}${t}${y}`;
50
52
  }
51
- var g = [
53
+ var x = [
52
54
  "debug",
53
55
  "info",
54
56
  "warn",
55
57
  "error",
56
58
  "silent"
57
- ], _ = {
59
+ ], S = {
58
60
  debug: {
59
- color: h("\x1B[2m"),
61
+ color: b("\x1B[2m"),
60
62
  log: console.debug,
61
63
  enabled: !1
62
64
  },
63
65
  info: {
64
- color: h("\x1B[36m"),
66
+ color: b("\x1B[36m"),
65
67
  log: console.log,
66
68
  enabled: !0
67
69
  },
68
70
  warn: {
69
- color: h("\x1B[33m"),
71
+ color: b("\x1B[33m"),
70
72
  log: console.warn,
71
73
  enabled: !0
72
74
  },
73
75
  error: {
74
- color: h("\x1B[31m"),
76
+ color: b("\x1B[31m"),
75
77
  log: console.error,
76
78
  enabled: !0
77
79
  },
@@ -80,52 +82,52 @@ var g = [
80
82
  enabled: !1
81
83
  }
82
84
  };
83
- function v(e, t) {
84
- return `${(/* @__PURE__ */ new Date()).toLocaleTimeString()} [${t ? `${m}:${t}` : m}] ${e}`;
85
+ function te(e, t) {
86
+ return `${(/* @__PURE__ */ new Date()).toLocaleTimeString()} [${t ? `${v}:${t}` : v}] ${e}`;
85
87
  }
86
- function y(e, t, n, r) {
88
+ function C(e, t, n, r) {
87
89
  if (!e.enabled) return;
88
- let i = v(t, r);
90
+ let i = te(t, r);
89
91
  e.log(e.color ? e.color(i) : i), n !== void 0 && e.log(n);
90
92
  }
91
- function b(e) {
92
- let t = _[e], n = /* @__PURE__ */ new Set();
93
+ function w(e) {
94
+ let t = S[e], n = /* @__PURE__ */ new Set();
93
95
  return Object.assign((e, n, r) => {
94
- y(t, e, n, r);
96
+ C(t, e, n, r);
95
97
  }, { once(e, r, i) {
96
- !t.enabled || n.has(e) || (n.add(e), y(t, e, r, i));
98
+ !t.enabled || n.has(e) || (n.add(e), C(t, e, r, i));
97
99
  } });
98
100
  }
99
- function x(e) {
100
- let t = g.indexOf(e);
101
+ function ne(e) {
102
+ let t = x.indexOf(e);
101
103
  if (t === -1) {
102
- y(_.error, `invalid log level: ${e}`);
104
+ C(S.error, `invalid log level: ${e}`);
103
105
  return;
104
106
  }
105
- for (let [e, n] of g.entries()) _[n].enabled = e >= t;
107
+ for (let [e, n] of x.entries()) S[n].enabled = e >= t;
106
108
  }
107
- var S = h("\x1B[34m"), C = h("\x1B[36m");
108
- function w() {
109
+ var T = b("\x1B[34m"), E = b("\x1B[36m");
110
+ function re() {
109
111
  let e = [
110
- ` ${S("_")} ${C("_")} _ _ _`,
111
- `${S("(_)")} ${C("(_)")} _ __(_)__| |_____ __| |`,
112
- ` ${S("_")} ${S("_")} | '_ \\ / _| / / -_) _\` |`,
113
- `${S("(_)")} ${S("(_)")} | .__/_\\__|_\\_\\___\\__,_|`,
112
+ ` ${T("_")} ${E("_")} _ _ _`,
113
+ `${T("(_)")} ${E("(_)")} _ __(_)__| |_____ __| |`,
114
+ ` ${T("_")} ${T("_")} | '_ \\ / _| / / -_) _\` |`,
115
+ `${T("(_)")} ${T("(_)")} | .__/_\\__|_\\_\\___\\__,_|`,
114
116
  " |_|\n "
115
117
  ];
116
118
  console.log(e.join("\n"));
117
119
  }
118
- var T = {
119
- banner: w,
120
- debug: b("debug"),
121
- info: b("info"),
122
- warn: b("warn"),
123
- error: b("error"),
124
- setLevel: x
120
+ var D = {
121
+ banner: re,
122
+ debug: w("debug"),
123
+ info: w("info"),
124
+ warn: w("warn"),
125
+ error: w("error"),
126
+ setLevel: ne
125
127
  };
126
128
  //#endregion
127
129
  //#region src/middleware.ts
128
- function E(e) {
130
+ function O(e) {
129
131
  return (t, n, r) => {
130
132
  if (t.method !== "GET") {
131
133
  r();
@@ -142,28 +144,28 @@ function E(e) {
142
144
  }
143
145
  //#endregion
144
146
  //#region src/gitignore.ts
145
- var D = ".picked/";
146
- async function ne(t, n) {
147
- if (n) return;
148
- let r = c(t, ".gitignore");
149
- if (!e(r)) {
150
- await s(r, `${D}
147
+ var k = ".picked/";
148
+ async function ie(n, r) {
149
+ if (r) return;
150
+ let i = t(n, ".gitignore");
151
+ if (!e(i)) {
152
+ await f(i, `${k}
151
153
  `);
152
154
  return;
153
155
  }
154
- let a = await o(r, "utf8");
155
- if (O(a)) return;
156
- let l = `${a.length > 0 && !a.endsWith("\n") ? "\n" : ""}${D}
156
+ let a = await d(i, "utf8");
157
+ if (A(a)) return;
158
+ let o = `${a.length > 0 && !a.endsWith("\n") ? "\n" : ""}${k}
157
159
  `;
158
- await i(r, l);
160
+ await l(i, o);
159
161
  }
160
- function O(e) {
161
- return e.split(/\r?\n/).map((e) => e.trim()).some((e) => e === D || e === ".picked");
162
+ function A(e) {
163
+ return e.split(/\r?\n/).map((e) => e.trim()).some((e) => e === k || e === ".picked");
162
164
  }
163
165
  //#endregion
164
166
  //#region src/retry.ts
165
- var k = 6, A = 5e3;
166
- function j(e) {
167
+ var j = 6, ae = 5e3;
168
+ function M(e) {
167
169
  let t;
168
170
  try {
169
171
  t = new URL(e).hostname;
@@ -172,12 +174,12 @@ function j(e) {
172
174
  }
173
175
  return t === "localhost" || t === "127.0.0.1" || t === "::1" || t === "[::1]" || t !== "api.picked.app" && t.endsWith(".picked.app");
174
176
  }
175
- function re(e) {
177
+ function N(e) {
176
178
  return new Promise((t) => {
177
179
  setTimeout(t, e);
178
180
  });
179
181
  }
180
- async function M(e, t) {
182
+ async function P(e, t) {
181
183
  let n = null, r = null;
182
184
  try {
183
185
  n = await e();
@@ -185,9 +187,9 @@ async function M(e, t) {
185
187
  r = e;
186
188
  }
187
189
  if (n !== null) return n;
188
- for (let i = 1; i <= k; i++) {
189
- let a = A * 2 ** (i - 1);
190
- t(i, k, a), await re(a), r = null;
190
+ for (let i = 1; i <= j; i++) {
191
+ let a = ae * 2 ** (i - 1);
192
+ t(i, j, a), await N(a), r = null;
191
193
  try {
192
194
  n = await e();
193
195
  } catch (e) {
@@ -200,102 +202,111 @@ async function M(e, t) {
200
202
  }
201
203
  //#endregion
202
204
  //#region src/util.ts
203
- function N(e) {
205
+ function F(e) {
204
206
  return Array.isArray(e) ? e : [];
205
207
  }
206
208
  //#endregion
207
209
  //#region src/prefetch.ts
208
- var P = 1;
209
- function F(e) {
210
- let t = c(e, ".picked");
210
+ var I = 2;
211
+ function L(e) {
212
+ let n = t(e, ".picked");
211
213
  return {
212
- pickedDir: t,
213
- manifestPath: c(t, "manifest.json"),
214
- projectConfigPath: c(t, "project-config.json"),
215
- experiencesDir: c(t, "experiences")
214
+ pickedDir: n,
215
+ manifestPath: t(n, "manifest.json"),
216
+ projectConfigPath: t(n, "project-config.json"),
217
+ experiencesDir: t(n, "experiences")
216
218
  };
217
219
  }
218
- async function I(t) {
220
+ async function R(t) {
219
221
  if (!e(t)) return null;
220
222
  try {
221
- let e = await o(t, "utf8"), n = JSON.parse(e);
222
- return L(n) ? n : null;
223
+ let e = await d(t, "utf8"), n = JSON.parse(e);
224
+ return z(n) ? n : null;
223
225
  } catch {
224
226
  return null;
225
227
  }
226
228
  }
227
- function L(e) {
229
+ function z(e) {
228
230
  return !(typeof e != "object" || !e || !("version" in e) || typeof e.version != "number" || !("projectVersionId" in e) || typeof e.projectVersionId != "string" || !("workspaceId" in e) || typeof e.workspaceId != "string" || !("experiences" in e) || !Array.isArray(e.experiences));
229
231
  }
230
- function R(e) {
232
+ function B(e) {
231
233
  let t = /* @__PURE__ */ new Set();
232
- for (let n of N(e.steps)) n.layoutContentId && t.add(n.id);
234
+ for (let n of F(e.steps)) n.layoutContentId && t.add(n.id);
233
235
  if (t.size === 0) return [];
234
236
  let n = [];
235
- for (let r of N(e.experiences)) N(r.nodes).some((e) => e.type === "step" && t.has(e.stepId)) && n.push(r.id);
237
+ for (let r of F(e.experiences)) F(r.nodes).some((e) => e.type === "step" && t.has(e.stepId)) && n.push(r.id);
236
238
  return n;
237
239
  }
238
- async function z(e) {
239
- let { apiUrl: t, projectId: n, projectRoot: r, headers: i, reuseWhenUnchanged: o = !0 } = e, l = F(r), u = await V(t, n, i), d = R(u);
240
- if (o) {
241
- let e = await I(l.manifestPath);
242
- if (e && e.projectVersionId === u.versionId && e.workspaceId === u.workspaceId) return {
243
- config: u,
244
- manifest: e,
245
- experienceContentPaths: B(l, d)
246
- };
240
+ async function V(n) {
241
+ let { apiUrl: r, projectId: i, projectRoot: a, headers: o, previewToken: s, reuseWhenUnchanged: c = !0 } = n, l = L(a), d = await U(r, i, o, s), p = B(d);
242
+ if (await u(l.experiencesDir, { recursive: !0 }), await f(l.projectConfigPath, JSON.stringify(d, null, 2)), c) {
243
+ let t = await R(l.manifestPath);
244
+ if (t?.version === I && t.projectVersionId === d.versionId && t.workspaceId === d.workspaceId) {
245
+ let n = H(l, p);
246
+ if (Object.values(n).every((t) => e(t))) return {
247
+ config: d,
248
+ manifest: t,
249
+ experienceContentPaths: n
250
+ };
251
+ D.info("a manifest-referenced content file is missing; refetching every experience");
252
+ }
247
253
  }
248
- await a(l.experiencesDir, { recursive: !0 }), await s(l.projectConfigPath, JSON.stringify(u, null, 2));
249
- let f = (/* @__PURE__ */ new Date()).toISOString(), p = [];
250
- for (let e of d) {
251
- let r = await H(t, n, e, i), a = c(l.experiencesDir, `${e}.json`);
252
- await s(a, JSON.stringify(r, null, 2)), p.push({
254
+ let m = (/* @__PURE__ */ new Date()).toISOString(), h = [];
255
+ for (let e of p) {
256
+ let n = await W(r, i, e, o, s), a = t(l.experiencesDir, `${e}.json`);
257
+ await f(a, JSON.stringify(n, null, 2)), h.push({
253
258
  id: e,
254
- fetchedAt: f
259
+ fetchedAt: m
255
260
  });
256
261
  }
257
- let m = {
258
- version: P,
259
- fetchedAt: f,
260
- projectVersionId: u.versionId,
261
- workspaceId: u.workspaceId,
262
- projectId: u.id,
263
- experiences: p
262
+ let g = {
263
+ version: I,
264
+ fetchedAt: m,
265
+ projectVersionId: d.versionId,
266
+ workspaceId: d.workspaceId,
267
+ projectId: d.id,
268
+ experiences: h
264
269
  };
265
- return await s(l.manifestPath, JSON.stringify(m, null, 2)), {
266
- config: u,
267
- manifest: m,
268
- experienceContentPaths: B(l, d)
270
+ return await f(l.manifestPath, JSON.stringify(g, null, 2)), {
271
+ config: d,
272
+ manifest: g,
273
+ experienceContentPaths: H(l, p)
269
274
  };
270
275
  }
271
- function B(e, t) {
272
- let n = {};
273
- for (let r of t) n[r] = c(e.experiencesDir, `${r}.json`);
274
- return n;
276
+ function H(e, n) {
277
+ let r = {};
278
+ for (let i of n) r[i] = t(e.experiencesDir, `${i}.json`);
279
+ return r;
275
280
  }
276
- async function V(e, t, n) {
277
- let i = () => r(e, t, { headers: n }), a;
281
+ async function U(e, t, n, r) {
282
+ let i = () => a(e, t, {
283
+ headers: n,
284
+ previewToken: r
285
+ }), o;
278
286
  try {
279
- a = j(e) ? await M(i, (e, t, n) => {
280
- T.info(`project config not ready, retrying in ${(n / 1e3).toString()}s (${e.toString()}/${t.toString()})`);
287
+ o = M(e) ? await P(i, (e, t, n) => {
288
+ D.info(`project config not ready, retrying in ${(n / 1e3).toString()}s (${e.toString()}/${t.toString()})`);
281
289
  }) : await i();
282
290
  } catch (n) {
283
- throw Error(`[picked] Build-time fetch of project config failed for "${t}" at ${e}: ${U(n)}`);
291
+ throw Error(`[picked] Build-time fetch of project config failed for "${t}" at ${e}: ${G(n)}`);
284
292
  }
285
- if (!a) 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.`);
286
- return a;
293
+ if (!o) throw Error(`[picked] Build-time fetch of project config returned no usable response for "${t}" at ${e}. Confirm the API is reachable and the project ID is correct.`);
294
+ return o;
287
295
  }
288
- async function H(e, t, r, i) {
289
- let a;
296
+ async function W(e, t, n, r, a) {
297
+ let o;
290
298
  try {
291
- a = await n(e, t, r, { headers: i });
299
+ o = await i(e, t, n, {
300
+ headers: r,
301
+ previewToken: a
302
+ });
292
303
  } catch (t) {
293
- throw Error(`[picked] Build-time fetch of content for experience "${r}" failed at ${e}: ${U(t)}`);
304
+ throw Error(`[picked] Build-time fetch of content for experience "${n}" failed at ${e}: ${G(t)}`);
294
305
  }
295
- if (!a) throw Error(`[picked] Build-time fetch of content for experience "${r}" returned no usable response. Confirm the experience id exists and the API is reachable.`);
296
- return a;
306
+ if (!o) throw Error(`[picked] Build-time fetch of content for experience "${n}" returned no usable response. Confirm the experience id exists and the API is reachable.`);
307
+ return o;
297
308
  }
298
- function U(e) {
309
+ function G(e) {
299
310
  if (e instanceof Error) return e.message;
300
311
  if (typeof e == "string") return e;
301
312
  try {
@@ -305,10 +316,16 @@ function U(e) {
305
316
  }
306
317
  }
307
318
  //#endregion
319
+ //#region src/virtual-module/api.ts
320
+ function K() {
321
+ return "export const manifestMetadata = {\n mode: 'api',\n fetchedAt: null,\n projectVersionId: null,\n workspaceId: null,\n}\n";
322
+ }
323
+ //#endregion
308
324
  //#region src/virtual-module/build.ts
309
- function W(e) {
325
+ function q(e) {
310
326
  let { projectConfigPath: t, experienceContentPaths: n, manifestMetadata: r } = e, i = (e) => JSON.stringify(e), a = Object.entries(n).map(([e, t]) => ` ${JSON.stringify(e)}: () => import(${i(t)}).then((m) => m.default ?? m),`).join("\n");
311
- return `import projectConfigJson from ${i(t)}
327
+ return `import { registerPickedBundle } from '@picked/client/plugins/dynamic-experiences'
328
+ import projectConfigJson from ${i(t)}
312
329
 
313
330
  const experienceImporters = {
314
331
  ${a}
@@ -329,23 +346,26 @@ export async function experienceContent(experience, _options) {
329
346
  }
330
347
 
331
348
  export const manifestMetadata = ${JSON.stringify(r)}
349
+
350
+ registerPickedBundle({ projectConfig, experienceContent, manifestMetadata })
332
351
  `;
333
352
  }
334
353
  //#endregion
335
354
  //#region src/virtual-module/dev.ts
336
- function G(e) {
337
- let { apiUrl: t, projectId: n } = e;
338
- return `import { fetchProject, fetchExperienceContent } from '@picked/client/plugins/dynamic-experiences'
355
+ function J(e) {
356
+ let { apiUrl: t, projectId: n, projectConfig: r, previewToken: i } = e, a = r ? "import { fetchExperienceContent, registerPickedBundle } from '@picked/client/plugins/dynamic-experiences'" : "import { fetchProject, fetchExperienceContent } from '@picked/client/plugins/dynamic-experiences'", o = r ? `export const projectConfig = ${JSON.stringify(r)}` : "export const projectConfig = await fetchProject(apiUrl, projectId, { previewToken: previewToken ?? undefined })", s = r ? "\nregisterPickedBundle({ projectConfig, experienceContent, manifestMetadata })\n" : "";
357
+ return `${a}
339
358
 
340
359
  const apiUrl = ${JSON.stringify(t)}
341
360
  const projectId = ${JSON.stringify(n)}
361
+ const previewToken = ${JSON.stringify(i ?? null)}
342
362
 
343
- export const projectConfig = await fetchProject(apiUrl, projectId)
363
+ ${o}
344
364
 
345
365
  export async function experienceContent(experience, options) {
346
366
  const id = typeof experience === 'string' ? experience : experience?.id
347
367
  if (!id) return null
348
- return await fetchExperienceContent(apiUrl, projectId, id, options)
368
+ return await fetchExperienceContent(apiUrl, projectId, id, { previewToken: previewToken ?? undefined, ...options })
349
369
  }
350
370
 
351
371
  export const manifestMetadata = {
@@ -354,14 +374,14 @@ export const manifestMetadata = {
354
374
  projectVersionId: projectConfig?.versionId ?? null,
355
375
  workspaceId: projectConfig?.workspaceId ?? null,
356
376
  }
357
- `;
377
+ ${s}`;
358
378
  }
359
379
  //#endregion
360
380
  //#region src/index.ts
361
- var K = 5;
362
- function q(e, t, n) {
381
+ var oe = 5;
382
+ function Y(e, t, n) {
363
383
  if (t.length === 0) return;
364
- if (t.length > K) {
384
+ if (t.length > oe) {
365
385
  console.log(`\n ${e}: ${t.length.toString()} loaded\n`);
366
386
  return;
367
387
  }
@@ -376,10 +396,10 @@ function q(e, t, n) {
376
396
  ""
377
397
  ].join("\n"));
378
398
  }
379
- function J(e, t) {
399
+ function se(e, t) {
380
400
  t.length !== 0 && console.log(`\n ${e}: ${t.length.toString()} loaded\n`);
381
401
  }
382
- var Y = [
402
+ var ce = [
383
403
  {
384
404
  header: "Name",
385
405
  value: (e) => e.name
@@ -400,7 +420,7 @@ var Y = [
400
420
  header: "Ver",
401
421
  value: (e) => `v${e.version.toString()}`
402
422
  }
403
- ], ie = [
423
+ ], le = [
404
424
  {
405
425
  header: "Name",
406
426
  value: (e) => e.name
@@ -421,7 +441,7 @@ var Y = [
421
441
  header: "Targets",
422
442
  value: (e) => e.targets.length.toString()
423
443
  }
424
- ], ae = [
444
+ ], ue = [
425
445
  {
426
446
  header: "Name",
427
447
  value: (e) => e.name
@@ -434,7 +454,7 @@ var Y = [
434
454
  header: "Fields",
435
455
  value: (e) => (e.fieldIds?.length ?? 0).toString()
436
456
  }
437
- ], oe = [
457
+ ], de = [
438
458
  {
439
459
  header: "Name",
440
460
  value: (e) => e.name
@@ -451,86 +471,175 @@ var Y = [
451
471
  header: "Required",
452
472
  value: (e) => e.required ? "yes" : "no"
453
473
  }
454
- ], se = [{
474
+ ], fe = [{
455
475
  header: "Name",
456
476
  value: (e) => e.name
457
477
  }, {
458
478
  header: "Key",
459
479
  value: (e) => e.key
460
480
  }];
461
- function ce() {
462
- return "0.0.1-dev.1786072899095";
481
+ function pe() {
482
+ return "0.0.1-dev.1786601464574";
483
+ }
484
+ var me = "https://api.picked.app", X = "virtual:picked/data", Z = `\0${X}`;
485
+ function he(e) {
486
+ for (let t of Object.values(e)) if (t.type === "chunk" && t.moduleIds.includes(Z)) return t.fileName;
487
+ }
488
+ function ge(e, t) {
489
+ return e === "" || e.endsWith("/") ? `${e}${t}` : `${e}/${t}`;
490
+ }
491
+ async function _e(e) {
492
+ try {
493
+ let t = await o({ config: e });
494
+ D.info(`generated types at ${t.typesOutput}`);
495
+ } catch (e) {
496
+ let t = e instanceof Error ? e.message : String(e);
497
+ D.warn(`type generation failed: ${t}`);
498
+ }
463
499
  }
464
- var X = "https://api.picked.app", Z = "virtual:picked/data", Q = `\0${Z}`;
465
- function le(n) {
466
- let i = n.apiUrl ?? X, a = [], o = process.cwd(), s = "serve", c, l = !1;
500
+ async function ve(e) {
501
+ let t = await c(e);
502
+ if (!t) throw Error("picked.config.{ts,js,json} is required. Add a picked.config.ts with projectId and apiUrl.");
503
+ return t;
504
+ }
505
+ async function ye(e, t) {
506
+ let n = await s(e);
507
+ n && n.projectId !== t && D.warn(`using project "${t}" (picked.config default: "${n.projectId}") — run 'picked status' to inspect`);
508
+ }
509
+ var Q = /* @__PURE__ */ new Map();
510
+ function be(e, t, n) {
511
+ return JSON.stringify([
512
+ e,
513
+ t,
514
+ n
515
+ ]);
516
+ }
517
+ function xe(t = {}) {
518
+ let i = t.mode ?? "bundle", o = t.generateTypes ?? !0, s = [], c = process.cwd(), l = "serve", u = "/", d = null, f = !1, p, m, g = null;
467
519
  return {
468
520
  name: "picked",
469
- config: async (u, d) => {
470
- s = d.command, o = process.cwd(), T.banner(), i !== X && T.warn(`using custom API URL: ${i}`);
471
- let f = t("vite-plugin", ce());
472
- if (d.command === "build") {
473
- if (l) return;
474
- l = !0, T.info(`prefetching project config + content for "${n.projectId}"`);
475
- let t = F(o), r = e(t.pickedDir), s = performance.now(), u = await z({
476
- apiUrl: i,
477
- projectId: n.projectId,
478
- projectRoot: o,
479
- headers: f
480
- }), d = (performance.now() - s).toFixed(0);
481
- await ne(o, r);
482
- let p = u.config;
483
- a = N(p.features), $(p, d), c = W({
484
- projectConfigPath: t.projectConfigPath,
485
- experienceContentPaths: u.experienceContentPaths,
486
- manifestMetadata: {
487
- mode: "build",
488
- fetchedAt: u.manifest.fetchedAt,
489
- projectVersionId: u.manifest.projectVersionId,
490
- workspaceId: u.manifest.workspaceId
491
- }
492
- });
493
- } else {
494
- T.info(`fetching project config for "${n.projectId}" (dev)`);
495
- let e = performance.now(), t = () => r(i, n.projectId, { headers: f }), o = j(i) ? await M(t, (e, t, n) => {
496
- T.info(`local API not ready, retrying in ${(n / 1e3).toString()}s (${e.toString()}/${t.toString()})`);
497
- }) : await t(), s = (performance.now() - e).toFixed(0);
498
- o ? (a = N(o.features), $(o, s)) : T.warn(`failed to fetch project config for "${n.projectId}" (${s}ms)`);
521
+ config: async (t, u) => {
522
+ l = u.command, c = t.root === void 0 ? process.cwd() : n(process.cwd(), t.root), d = await ve(c);
523
+ let { projectId: h, apiUrl: _, previewToken: v } = d;
524
+ D.banner(), o && !f && (f = !0, await _e(d)), _ !== me && D.warn(`using custom API URL: ${_}`), await ye(c, h);
525
+ let y = r("vite-plugin", pe());
526
+ if (i === "api") D.debug("mode is 'api': skipping the project-config prefetch");
527
+ else if (u.command === "build") {
528
+ let t = be(_, h, c);
529
+ p = t;
530
+ let n = Q.get(t);
531
+ n === void 0 && (n = (async () => {
532
+ D.info(`prefetching project config + content for "${h}"`);
533
+ let t = L(c), n = e(t.pickedDir), r = performance.now(), i = await V({
534
+ apiUrl: _,
535
+ projectId: h,
536
+ projectRoot: c,
537
+ headers: y,
538
+ previewToken: v ?? void 0
539
+ }), a = (performance.now() - r).toFixed(0);
540
+ await ie(c, n);
541
+ let o = i.config;
542
+ return $(o, a), {
543
+ virtualSource: q({
544
+ projectConfigPath: t.projectConfigPath,
545
+ experienceContentPaths: i.experienceContentPaths,
546
+ manifestMetadata: {
547
+ mode: "build",
548
+ fetchedAt: i.manifest.fetchedAt,
549
+ projectVersionId: i.manifest.projectVersionId,
550
+ workspaceId: i.manifest.workspaceId
551
+ }
552
+ }),
553
+ features: F(o.features)
554
+ };
555
+ })(), n.catch(() => Q.delete(t)), Q.set(t, n));
556
+ let r = await n;
557
+ m = r.virtualSource, s = r.features;
558
+ } else if (u.mode === "production") D.debug("skipping the dev project-config fetch for a production serve resolution");
559
+ else {
560
+ D.info(`fetching project config for "${h}" (dev)`);
561
+ let e = performance.now(), t = () => a(_, h, {
562
+ headers: y,
563
+ previewToken: v ?? void 0
564
+ }), n = M(_) ? await P(t, (e, t, n) => {
565
+ D.info(`local API not ready, retrying in ${(n / 1e3).toString()}s (${e.toString()}/${t.toString()})`);
566
+ }) : await t(), r = (performance.now() - e).toFixed(0);
567
+ g = n, n ? (s = F(n.features), $(n, r)) : D.warn(`failed to fetch project config for "${h}" (${r}ms)`);
568
+ }
569
+ },
570
+ configResolved(e) {
571
+ u = e.base;
572
+ },
573
+ closeBundle() {
574
+ p !== void 0 && Q.delete(p);
575
+ },
576
+ transformIndexHtml: {
577
+ order: "post",
578
+ handler(e, t) {
579
+ if (i === "api" || t.bundle === void 0) return;
580
+ let n = he(t.bundle);
581
+ if (n === void 0) return;
582
+ let r = ge(u, n);
583
+ if (!e.includes(`"${r}"`)) return [{
584
+ tag: "link",
585
+ attrs: {
586
+ rel: "modulepreload",
587
+ crossorigin: !0,
588
+ href: r
589
+ },
590
+ injectTo: "head"
591
+ }];
499
592
  }
500
593
  },
501
594
  resolveId(e) {
502
- if (e === Z) return Q;
595
+ if (e === X) return Z;
503
596
  },
504
597
  load(e) {
505
- if (e === Q) return s === "build" ? c : G({
506
- apiUrl: i,
507
- projectId: n.projectId
508
- });
598
+ if (e === Z) {
599
+ if (i === "api") return K();
600
+ if (l === "build") return m;
601
+ if (!d) throw Error("picked plugin config hook must run before virtual module load");
602
+ return J({
603
+ apiUrl: d.apiUrl,
604
+ projectId: d.projectId,
605
+ projectConfig: g,
606
+ previewToken: d.previewToken ?? void 0
607
+ });
608
+ }
509
609
  },
510
610
  configureServer(e) {
511
- if (n.disableLauncher) return;
512
- e.middlewares.use(E(() => d(a)));
513
- let t = e.printUrls.bind(e);
611
+ if (t.disableLauncher) return;
612
+ e.middlewares.use(O(() => h(s)));
613
+ let n = e.printUrls.bind(e);
514
614
  e.printUrls = () => {
515
- let n = e.resolvedUrls?.local[0];
516
- if (n) {
517
- let e = n.replace(/:(?<port>\d+)\//, (e, t) => `:\x1b[1m${t}\x1b[22m/`);
615
+ let t = e.resolvedUrls?.local[0];
616
+ if (t) {
617
+ let e = t.replace(/:(?<port>\d+)\//, (e, t) => `:\x1b[1m${t}\x1b[22m/`);
518
618
  console.log(` \x1b[32m➜\x1b[0m \x1b[1mPicked\x1b[22m: \x1b[36m${e}\x1b[0m`);
519
619
  }
520
- t();
620
+ n();
521
621
  };
522
622
  },
523
- generateBundle() {
524
- n.disableLauncher || this.emitFile({
525
- type: "asset",
526
- fileName: "index.html",
527
- source: d(a)
528
- });
623
+ generateBundle: {
624
+ order: "post",
625
+ handler(e, n) {
626
+ if (!t.disableLauncher) {
627
+ if ("index.html" in n) {
628
+ D.debug("index.html came from the build; skipping the launcher page");
629
+ return;
630
+ }
631
+ this.emitFile({
632
+ type: "asset",
633
+ fileName: "index.html",
634
+ source: h(s)
635
+ });
636
+ }
637
+ }
529
638
  }
530
639
  };
531
640
  }
532
641
  function $(e, t) {
533
- let n = N(e.features), r = N(e.experiences), i = N(e.steps), a = N(e.fields), o = N(e.conditions), s = N(e.actions), c = JSON.stringify(e).length, l = [
642
+ let n = F(e.features), r = F(e.experiences), i = F(e.steps), a = F(e.fields), o = F(e.conditions), s = F(e.actions), c = JSON.stringify(e).length, l = [
534
643
  `${n.length.toString()} features`,
535
644
  `${r.length.toString()} experiences`,
536
645
  `${i.length.toString()} steps`,
@@ -538,7 +647,7 @@ function $(e, t) {
538
647
  `${o.length.toString()} conditions`,
539
648
  `${s.length.toString()} actions`
540
649
  ].join(", ");
541
- T.info(`fetched config in ${t}ms (${l})`), q("Features", n, Y), q("Experiences", r, ie), q("Steps", i, ae), q("Fields", a, oe), q("Conditions", o, se), J("Actions", s), T.debug(`config size: ${c.toString()} bytes`);
650
+ D.info(`fetched config in ${t}ms (${l})`), Y("Features", n, ce), Y("Experiences", r, le), Y("Steps", i, ue), Y("Fields", a, de), Y("Conditions", o, fe), se("Actions", s), D.debug(`config size: ${c.toString()} bytes`);
542
651
  }
543
652
  //#endregion
544
- export { le as picked };
653
+ export { xe as picked };