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