@picked/vite-plugin-picked 0.0.1-dev.1795388735478 → 0.0.1-dev.1795567554153
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 +117 -8
- package/dist/cjs/prefetch.d.ts +11 -0
- package/dist/cjs/prefetch.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 +410 -247
- 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/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,92 @@ 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 = {};
|
|
301
|
+
for (let [n, r] of i) {
|
|
302
|
+
let i = t(e.flowsDir, `${n}.json`);
|
|
303
|
+
await x(i, JSON.stringify(r, null, 2)), a[n] = i;
|
|
304
|
+
}
|
|
305
|
+
return a;
|
|
306
|
+
}
|
|
307
|
+
function K(e, n) {
|
|
289
308
|
let r = {};
|
|
290
309
|
for (let i of n) r[i] = t(e.experiencesDir, `${i}.json`);
|
|
291
310
|
return r;
|
|
@@ -296,11 +315,11 @@ async function xe(e, t, n, r) {
|
|
|
296
315
|
previewToken: r
|
|
297
316
|
}), o;
|
|
298
317
|
try {
|
|
299
|
-
o =
|
|
300
|
-
|
|
318
|
+
o = V(e) ? await H(i, (e, t, n) => {
|
|
319
|
+
R.info(`project config not ready, retrying in ${(n / 1e3).toString()}s (${e.toString()}/${t.toString()})`);
|
|
301
320
|
}) : await i();
|
|
302
321
|
} catch (n) {
|
|
303
|
-
throw Error(`[picked] Build-time fetch of project config failed for "${t}" at ${e}: ${
|
|
322
|
+
throw Error(`[picked] Build-time fetch of project config failed for "${t}" at ${e}: ${q(n)}`);
|
|
304
323
|
}
|
|
305
324
|
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
325
|
return o;
|
|
@@ -313,12 +332,12 @@ async function Se(e, t, n, r, a) {
|
|
|
313
332
|
previewToken: a
|
|
314
333
|
});
|
|
315
334
|
} catch (t) {
|
|
316
|
-
throw Error(`[picked] Build-time fetch of content for experience "${n}" failed at ${e}: ${
|
|
335
|
+
throw Error(`[picked] Build-time fetch of content for experience "${n}" failed at ${e}: ${q(t)}`);
|
|
317
336
|
}
|
|
318
337
|
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
338
|
return o;
|
|
320
339
|
}
|
|
321
|
-
function
|
|
340
|
+
function q(e) {
|
|
322
341
|
if (e instanceof Error) return e.message;
|
|
323
342
|
if (typeof e == "string") return e;
|
|
324
343
|
try {
|
|
@@ -330,8 +349,8 @@ function W(e) {
|
|
|
330
349
|
//#endregion
|
|
331
350
|
//#region src/telemetry.ts
|
|
332
351
|
var Ce = /* @__PURE__ */ new Set(["resolveId", "load"]);
|
|
333
|
-
function we(e =
|
|
334
|
-
let t =
|
|
352
|
+
function we(e = w()) {
|
|
353
|
+
let t = S(), n = Date.now(), r = [], i = /* @__PURE__ */ new Map();
|
|
335
354
|
return {
|
|
336
355
|
record: (n, a) => {
|
|
337
356
|
if (Ce.has(n)) {
|
|
@@ -349,10 +368,10 @@ function we(e = S()) {
|
|
|
349
368
|
r.push({
|
|
350
369
|
name: `picked.vite.${n}`,
|
|
351
370
|
traceId: e,
|
|
352
|
-
spanId:
|
|
371
|
+
spanId: S(),
|
|
353
372
|
parentSpanId: t,
|
|
354
|
-
startTimeUnixNano:
|
|
355
|
-
endTimeUnixNano:
|
|
373
|
+
startTimeUnixNano: T(o - a),
|
|
374
|
+
endTimeUnixNano: T(o),
|
|
356
375
|
attributes: { "picked.vite.hook": n },
|
|
357
376
|
status: "ok"
|
|
358
377
|
});
|
|
@@ -360,13 +379,13 @@ function we(e = S()) {
|
|
|
360
379
|
flush: async (a) => {
|
|
361
380
|
let o = {};
|
|
362
381
|
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 =
|
|
382
|
+
let s = l();
|
|
364
383
|
r.push({
|
|
365
384
|
name: "picked.vite.build",
|
|
366
385
|
traceId: e,
|
|
367
386
|
spanId: t,
|
|
368
|
-
startTimeUnixNano:
|
|
369
|
-
endTimeUnixNano:
|
|
387
|
+
startTimeUnixNano: T(n),
|
|
388
|
+
endTimeUnixNano: T(Date.now()),
|
|
370
389
|
attributes: {
|
|
371
390
|
"picked.env.provider": s.provider,
|
|
372
391
|
"picked.env.ci": s.ci,
|
|
@@ -376,7 +395,7 @@ function we(e = S()) {
|
|
|
376
395
|
status: "ok"
|
|
377
396
|
});
|
|
378
397
|
try {
|
|
379
|
-
let e =
|
|
398
|
+
let e = C({
|
|
380
399
|
resource: { "service.name": "picked-vite-plugin" },
|
|
381
400
|
headers: { "Picked-Telemetry": "vite-plugin" },
|
|
382
401
|
maxBatchSize: r.length
|
|
@@ -390,7 +409,7 @@ function we(e = S()) {
|
|
|
390
409
|
function Te(e) {
|
|
391
410
|
return typeof e == "object" && !!e && "then" in e;
|
|
392
411
|
}
|
|
393
|
-
function
|
|
412
|
+
function J(e, t, n) {
|
|
394
413
|
return function(...r) {
|
|
395
414
|
let i = performance.now(), a = () => {
|
|
396
415
|
n.record(e, performance.now() - i);
|
|
@@ -398,12 +417,12 @@ function G(e, t, n) {
|
|
|
398
417
|
return Te(o) ? Promise.resolve(o).then(a, a) : a(), o;
|
|
399
418
|
};
|
|
400
419
|
}
|
|
401
|
-
function
|
|
420
|
+
function Y(e) {
|
|
402
421
|
return typeof e == "function";
|
|
403
422
|
}
|
|
404
423
|
function Ee(e, t) {
|
|
405
424
|
if (!e) return t;
|
|
406
|
-
for (let [n, r] of Object.entries(t)) n !== "name" && (
|
|
425
|
+
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
426
|
return t;
|
|
408
427
|
}
|
|
409
428
|
//#endregion
|
|
@@ -441,9 +460,66 @@ export const manifestMetadata = ${JSON.stringify(r)}
|
|
|
441
460
|
registerPickedBundle({ projectConfig, experienceContent, manifestMetadata })
|
|
442
461
|
`;
|
|
443
462
|
}
|
|
463
|
+
function ke(e) {
|
|
464
|
+
return Object.entries(e).map(([e, t]) => ` ${JSON.stringify(e)}: () => import(${JSON.stringify(t)}).then((m) => m.default ?? m),`).join("\n");
|
|
465
|
+
}
|
|
466
|
+
function Ae(e) {
|
|
467
|
+
let { projectManifestPath: t, experienceFlowPaths: n, experienceContentPaths: r, manifestMetadata: i } = e;
|
|
468
|
+
return `import { registerPickedBundle } from '@picked/client/plugins/dynamic-experiences'
|
|
469
|
+
import projectManifestJson from ${JSON.stringify(t)}
|
|
470
|
+
|
|
471
|
+
const flowImporters = {
|
|
472
|
+
${ke(n)}
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
const experienceImporters = {
|
|
476
|
+
${ke(r)}
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
/**
|
|
480
|
+
* Loads one lazily imported JSON file for an experience, or resolves \`null\` when it has none.
|
|
481
|
+
*/
|
|
482
|
+
async function importFor(importers, experience) {
|
|
483
|
+
const id = typeof experience === 'string' ? experience : experience?.id
|
|
484
|
+
if (!id || !Object.hasOwn(importers, id)) return null
|
|
485
|
+
try {
|
|
486
|
+
return await importers[id]()
|
|
487
|
+
} catch {
|
|
488
|
+
return null
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
export const projectManifest = projectManifestJson
|
|
493
|
+
|
|
494
|
+
export async function experienceFlow(experience) {
|
|
495
|
+
return importFor(flowImporters, experience)
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
export async function experienceContent(experience, _options) {
|
|
499
|
+
return importFor(experienceImporters, experience)
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
export const manifestMetadata = ${JSON.stringify(i)}
|
|
503
|
+
|
|
504
|
+
registerPickedBundle({ projectManifest, experienceFlow, experienceContent, manifestMetadata })
|
|
505
|
+
`;
|
|
506
|
+
}
|
|
507
|
+
//#endregion
|
|
508
|
+
//#region src/virtual-module/flow.ts
|
|
509
|
+
var je = "virtual:picked/data/flow/";
|
|
510
|
+
function Me(e) {
|
|
511
|
+
return e.experiences.map((e, t) => {
|
|
512
|
+
let n = JSON.stringify(je + t.toString());
|
|
513
|
+
return ` ${JSON.stringify(e.id)}: () => import(${n}).then((m) => m.default),`;
|
|
514
|
+
}).join("\n");
|
|
515
|
+
}
|
|
516
|
+
function Ne(e, t) {
|
|
517
|
+
let n = e && /^\d+$/.test(t) ? e.experiences[Number(t)] : void 0, r = e && n ? o(e).flows.get(n.id) ?? null : null;
|
|
518
|
+
return `export default ${JSON.stringify(r)}\n`;
|
|
519
|
+
}
|
|
444
520
|
//#endregion
|
|
445
521
|
//#region src/virtual-module/dev.ts
|
|
446
|
-
function
|
|
522
|
+
function Pe(e) {
|
|
447
523
|
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
524
|
return `${a}
|
|
449
525
|
|
|
@@ -467,12 +543,46 @@ export const manifestMetadata = {
|
|
|
467
543
|
}
|
|
468
544
|
${s}`;
|
|
469
545
|
}
|
|
546
|
+
function Fe(e) {
|
|
547
|
+
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 = {
|
|
548
|
+
${Me(r)}
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
export async function experienceFlow(experience) {
|
|
552
|
+
const id = typeof experience === 'string' ? experience : experience?.id
|
|
553
|
+
if (!id || !Object.hasOwn(flowImporters, id)) return null
|
|
554
|
+
return await flowImporters[id]()
|
|
555
|
+
}` : "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" : "";
|
|
556
|
+
return `${s}
|
|
557
|
+
|
|
558
|
+
const apiUrl = ${JSON.stringify(t)}
|
|
559
|
+
const projectId = ${JSON.stringify(n)}
|
|
560
|
+
const previewToken = ${JSON.stringify(i ?? null)}
|
|
561
|
+
|
|
562
|
+
${c}
|
|
563
|
+
|
|
564
|
+
${l}
|
|
565
|
+
|
|
566
|
+
export async function experienceContent(experience, options) {
|
|
567
|
+
const id = typeof experience === 'string' ? experience : experience?.id
|
|
568
|
+
if (!id) return null
|
|
569
|
+
return await fetchExperienceContent(apiUrl, projectId, id, { previewToken: previewToken ?? undefined, ...options })
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
export const manifestMetadata = {
|
|
573
|
+
mode: 'dev',
|
|
574
|
+
fetchedAt: null,
|
|
575
|
+
projectVersionId: projectManifest?.versionId ?? null,
|
|
576
|
+
workspaceId: projectManifest?.workspaceId ?? null,
|
|
577
|
+
}
|
|
578
|
+
${u}`;
|
|
579
|
+
}
|
|
470
580
|
//#endregion
|
|
471
581
|
//#region src/virtual-module/snapshot.ts
|
|
472
|
-
var
|
|
473
|
-
function
|
|
582
|
+
var X = "virtual:picked/data/experience/";
|
|
583
|
+
function Ie(e) {
|
|
474
584
|
let t = Object.keys(e.experiences).map((e, t) => {
|
|
475
|
-
let n = JSON.stringify(
|
|
585
|
+
let n = JSON.stringify(X + t.toString());
|
|
476
586
|
return ` ${JSON.stringify(e)}: () => import(${n}).then((m) => m.default),`;
|
|
477
587
|
}).join("\n"), n = {
|
|
478
588
|
mode: "snapshot",
|
|
@@ -500,16 +610,57 @@ export const manifestMetadata = ${JSON.stringify(n)}
|
|
|
500
610
|
registerPickedBundle({ projectConfig, experienceContent, manifestMetadata })
|
|
501
611
|
`;
|
|
502
612
|
}
|
|
503
|
-
function
|
|
613
|
+
function Le(e, t) {
|
|
504
614
|
let n = /^\d+$/.test(t) ? Object.keys(e.experiences)[Number(t)] : void 0, r = n === void 0 ? null : e.experiences[n] ?? null;
|
|
505
615
|
return `export default ${JSON.stringify(r)}\n`;
|
|
506
616
|
}
|
|
617
|
+
function Re(e) {
|
|
618
|
+
let t = Object.keys(e.experiences).map((e, t) => {
|
|
619
|
+
let n = JSON.stringify(X + t.toString());
|
|
620
|
+
return ` ${JSON.stringify(e)}: () => import(${n}).then((m) => m.default),`;
|
|
621
|
+
}).join("\n"), n = Me(e.projectConfig), r = {
|
|
622
|
+
mode: "snapshot",
|
|
623
|
+
fetchedAt: null,
|
|
624
|
+
projectVersionId: e.projectVersionId,
|
|
625
|
+
workspaceId: e.workspaceId
|
|
626
|
+
};
|
|
627
|
+
return `import { registerPickedBundle } from '@picked/client/plugins/dynamic-experiences'
|
|
628
|
+
|
|
629
|
+
const experienceImporters = {
|
|
630
|
+
${t}
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
const flowImporters = {
|
|
634
|
+
${n}
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
export const projectManifest = ${JSON.stringify(o(e.projectConfig).manifest)}
|
|
638
|
+
|
|
639
|
+
export async function experienceFlow(experience) {
|
|
640
|
+
const id = typeof experience === 'string' ? experience : experience?.id
|
|
641
|
+
if (!id) return null
|
|
642
|
+
if (!Object.hasOwn(flowImporters, id)) return null
|
|
643
|
+
return await flowImporters[id]()
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
export async function experienceContent(experience, _options) {
|
|
647
|
+
const id = typeof experience === 'string' ? experience : experience?.id
|
|
648
|
+
if (!id) return null
|
|
649
|
+
if (!Object.hasOwn(experienceImporters, id)) return null
|
|
650
|
+
return await experienceImporters[id]()
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
export const manifestMetadata = ${JSON.stringify(r)}
|
|
654
|
+
|
|
655
|
+
registerPickedBundle({ projectManifest, experienceFlow, experienceContent, manifestMetadata })
|
|
656
|
+
`;
|
|
657
|
+
}
|
|
507
658
|
//#endregion
|
|
508
659
|
//#region src/index.ts
|
|
509
|
-
var
|
|
510
|
-
function
|
|
660
|
+
var ze = 5;
|
|
661
|
+
function Z(e, t, n) {
|
|
511
662
|
if (t.length === 0) return;
|
|
512
|
-
if (t.length >
|
|
663
|
+
if (t.length > ze) {
|
|
513
664
|
console.log(`\n ${e}: ${t.length.toString()} loaded\n`);
|
|
514
665
|
return;
|
|
515
666
|
}
|
|
@@ -524,10 +675,10 @@ function J(e, t, n) {
|
|
|
524
675
|
""
|
|
525
676
|
].join("\n"));
|
|
526
677
|
}
|
|
527
|
-
function
|
|
678
|
+
function Be(e, t) {
|
|
528
679
|
t.length !== 0 && console.log(`\n ${e}: ${t.length.toString()} loaded\n`);
|
|
529
680
|
}
|
|
530
|
-
var
|
|
681
|
+
var Ve = [
|
|
531
682
|
{
|
|
532
683
|
header: "Name",
|
|
533
684
|
value: (e) => e.name
|
|
@@ -542,13 +693,13 @@ var Pe = [
|
|
|
542
693
|
},
|
|
543
694
|
{
|
|
544
695
|
header: "Split",
|
|
545
|
-
value: (e) =>
|
|
696
|
+
value: (e) => he(e)
|
|
546
697
|
},
|
|
547
698
|
{
|
|
548
699
|
header: "Ver",
|
|
549
700
|
value: (e) => `v${e.version.toString()}`
|
|
550
701
|
}
|
|
551
|
-
],
|
|
702
|
+
], He = [
|
|
552
703
|
{
|
|
553
704
|
header: "Name",
|
|
554
705
|
value: (e) => e.name
|
|
@@ -569,7 +720,7 @@ var Pe = [
|
|
|
569
720
|
header: "Targets",
|
|
570
721
|
value: (e) => e.targets.length.toString()
|
|
571
722
|
}
|
|
572
|
-
],
|
|
723
|
+
], Ue = [
|
|
573
724
|
{
|
|
574
725
|
header: "Name",
|
|
575
726
|
value: (e) => e.name
|
|
@@ -582,7 +733,7 @@ var Pe = [
|
|
|
582
733
|
header: "Fields",
|
|
583
734
|
value: (e) => (e.fieldIds?.length ?? 0).toString()
|
|
584
735
|
}
|
|
585
|
-
],
|
|
736
|
+
], We = [
|
|
586
737
|
{
|
|
587
738
|
header: "Name",
|
|
588
739
|
value: (e) => e.name
|
|
@@ -599,166 +750,177 @@ var Pe = [
|
|
|
599
750
|
header: "Required",
|
|
600
751
|
value: (e) => e.required ? "yes" : "no"
|
|
601
752
|
}
|
|
602
|
-
],
|
|
753
|
+
], Ge = [{
|
|
603
754
|
header: "Name",
|
|
604
755
|
value: (e) => e.name
|
|
605
756
|
}, {
|
|
606
757
|
header: "Key",
|
|
607
758
|
value: (e) => e.key
|
|
608
759
|
}];
|
|
609
|
-
function
|
|
610
|
-
return "0.0.1-dev.
|
|
760
|
+
function Ke() {
|
|
761
|
+
return "0.0.1-dev.1795567554153";
|
|
611
762
|
}
|
|
612
|
-
var
|
|
613
|
-
function
|
|
614
|
-
for (let t of Object.values(e)) if (t.type === "chunk" && t.moduleIds.includes(
|
|
763
|
+
var qe = "https://api.picked.app", Je = "virtual:picked/data", Ye = `\0${Je}`, Xe = `\0${X}`, Ze = `\0${je}`;
|
|
764
|
+
function Qe(e) {
|
|
765
|
+
for (let t of Object.values(e)) if (t.type === "chunk" && t.moduleIds.includes(Ye)) return t.fileName;
|
|
615
766
|
}
|
|
616
|
-
function
|
|
767
|
+
function $e(e, t) {
|
|
617
768
|
return e === "" || e.endsWith("/") ? `${e}${t}` : `${e}/${t}`;
|
|
618
769
|
}
|
|
619
|
-
async function
|
|
770
|
+
async function et(e) {
|
|
620
771
|
try {
|
|
621
|
-
let t = await
|
|
772
|
+
let t = await s({
|
|
622
773
|
config: e,
|
|
623
774
|
onWarn: (e) => {
|
|
624
|
-
|
|
775
|
+
R.warn(e);
|
|
625
776
|
}
|
|
626
777
|
});
|
|
627
|
-
|
|
778
|
+
R.info(`generated types at ${t.typesOutput}`);
|
|
628
779
|
} catch (e) {
|
|
629
780
|
let t = e instanceof Error ? e.message : String(e);
|
|
630
781
|
throw Error(`type generation failed: ${t}. Fix the schema source, or set \`generateTypes: false\` on the picked plugin to skip it.`);
|
|
631
782
|
}
|
|
632
783
|
}
|
|
633
|
-
function
|
|
634
|
-
return e &&
|
|
784
|
+
function tt(e, t, n) {
|
|
785
|
+
return e && d(t, n) ? e : null;
|
|
635
786
|
}
|
|
636
|
-
async function
|
|
637
|
-
let n = await
|
|
787
|
+
async function nt(e, t) {
|
|
788
|
+
let n = await m(e, t);
|
|
638
789
|
if (!n) throw Error("picked.config.{ts,js,json} is required. Add a picked.config.ts with projectId and apiUrl.");
|
|
639
790
|
return n;
|
|
640
791
|
}
|
|
641
|
-
function
|
|
792
|
+
function Q(e, t, n, r) {
|
|
642
793
|
if (t === void 0 || n === void 0 || t === n) return;
|
|
643
794
|
let i = r === void 0 ? `picked.config says "${n}"` : `picked.config \`${r}\` is "${n}"`;
|
|
644
795
|
throw Error(`picked plugin option \`${e}\` is "${t}", and ${i}. Remove the plugin option; picked.config is the one place this belongs.`);
|
|
645
796
|
}
|
|
646
|
-
async function
|
|
647
|
-
let t = await
|
|
648
|
-
return t &&
|
|
797
|
+
async function rt(e) {
|
|
798
|
+
let t = await p(e);
|
|
799
|
+
return t && u(t) ? t : null;
|
|
649
800
|
}
|
|
650
|
-
function
|
|
651
|
-
e.data !== void 0 &&
|
|
801
|
+
function it(e) {
|
|
802
|
+
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
803
|
let t = [];
|
|
653
804
|
if (e.projectId !== void 0 && t.push("`projectId`"), e.apiUrl !== void 0 && t.push("`apiUrl`"), t.length === 0) return;
|
|
654
805
|
let n = t.length > 1;
|
|
655
|
-
|
|
806
|
+
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
807
|
}
|
|
657
|
-
async function
|
|
658
|
-
let n = await
|
|
659
|
-
n && n.projectId !== t &&
|
|
808
|
+
async function at(e, t) {
|
|
809
|
+
let n = await rt(e);
|
|
810
|
+
n && n.projectId !== t && R.warn(`using project "${t}" (picked.config default: "${n.projectId}") — run 'picked status' to inspect`);
|
|
660
811
|
}
|
|
661
|
-
async function
|
|
662
|
-
let n = await
|
|
663
|
-
return
|
|
812
|
+
async function ot(e, t) {
|
|
813
|
+
let n = await rt(e);
|
|
814
|
+
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
815
|
}
|
|
665
|
-
async function
|
|
666
|
-
if (t.data !== "snapshot") return e(
|
|
667
|
-
let n = await
|
|
668
|
-
return
|
|
816
|
+
async function st(t) {
|
|
817
|
+
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;
|
|
818
|
+
let n = await h(t);
|
|
819
|
+
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
820
|
}
|
|
670
|
-
async function
|
|
821
|
+
async function ct(e, t, n, r) {
|
|
671
822
|
let i = () => a(e, t, {
|
|
672
823
|
headers: n,
|
|
673
824
|
previewToken: r ?? void 0
|
|
674
825
|
});
|
|
675
|
-
return
|
|
676
|
-
|
|
826
|
+
return V(e) ? H(i, (e, t, n) => {
|
|
827
|
+
R.info(`local API not ready, retrying in ${(n / 1e3).toString()}s (${e.toString()}/${t.toString()})`);
|
|
677
828
|
}) : i();
|
|
678
829
|
}
|
|
679
|
-
var
|
|
680
|
-
function
|
|
830
|
+
var $ = /* @__PURE__ */ new Map();
|
|
831
|
+
function lt(e, t, n) {
|
|
681
832
|
return JSON.stringify([
|
|
682
833
|
e,
|
|
683
834
|
t,
|
|
684
835
|
n
|
|
685
836
|
]);
|
|
686
837
|
}
|
|
687
|
-
function
|
|
688
|
-
let i = t.mode, a = i ?? "bundle", o = null,
|
|
689
|
-
return Ee(
|
|
838
|
+
function ut(t = {}) {
|
|
839
|
+
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();
|
|
840
|
+
return Ee(S, {
|
|
690
841
|
name: "picked",
|
|
691
|
-
config: async (
|
|
692
|
-
|
|
693
|
-
let { projectId: p, apiUrl:
|
|
694
|
-
|
|
842
|
+
config: async (c, f) => {
|
|
843
|
+
d = f.command, u = c.root === void 0 ? process.cwd() : n(process.cwd(), c.root);
|
|
844
|
+
let { projectId: p, apiUrl: h } = t;
|
|
845
|
+
m = await ot(u, {
|
|
695
846
|
projectId: p,
|
|
696
|
-
apiUrl:
|
|
847
|
+
apiUrl: h,
|
|
697
848
|
data: i
|
|
698
849
|
});
|
|
699
|
-
let { projectId:
|
|
700
|
-
if (a =
|
|
701
|
-
|
|
702
|
-
let
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
850
|
+
let { projectId: g, apiUrl: x, previewToken: C, configLoading: w } = m;
|
|
851
|
+
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;
|
|
852
|
+
x !== qe && R.warn(`using custom API URL: ${x}`), await at(u, g);
|
|
853
|
+
let T = r("vite-plugin", Ke()), E = new Set(Object.keys(T).map((e) => e.toLowerCase())), D = {
|
|
854
|
+
...Object.fromEntries(Object.entries(t.customHeaders ?? {}).filter(([e]) => !E.has(e.toLowerCase()))),
|
|
855
|
+
...T
|
|
856
|
+
};
|
|
857
|
+
if (a === "api") R.debug("data is 'api': skipping the project-config prefetch");
|
|
858
|
+
else if (f.command === "build") {
|
|
859
|
+
let t = lt(x, g, u);
|
|
706
860
|
v = t;
|
|
707
|
-
let n =
|
|
861
|
+
let n = $.get(t);
|
|
708
862
|
n === void 0 && (n = (async () => {
|
|
709
|
-
|
|
710
|
-
let t =
|
|
711
|
-
apiUrl:
|
|
712
|
-
projectId:
|
|
863
|
+
R.info(`prefetching project config + content for "${g}"`);
|
|
864
|
+
let t = G(u), n = e(t.pickedDir), r = performance.now(), i = await ye({
|
|
865
|
+
apiUrl: x,
|
|
866
|
+
projectId: g,
|
|
713
867
|
projectRoot: u,
|
|
714
|
-
headers:
|
|
715
|
-
previewToken: C ?? void 0
|
|
868
|
+
headers: D,
|
|
869
|
+
previewToken: C ?? void 0,
|
|
870
|
+
configLoading: w
|
|
716
871
|
}), a = (performance.now() - r).toFixed(0);
|
|
717
|
-
await
|
|
872
|
+
await de(u, n);
|
|
718
873
|
let o = i.config;
|
|
719
|
-
|
|
720
|
-
|
|
874
|
+
dt(o, a);
|
|
875
|
+
let s = {
|
|
876
|
+
mode: "build",
|
|
877
|
+
fetchedAt: i.manifest.fetchedAt,
|
|
878
|
+
projectVersionId: i.manifest.projectVersionId,
|
|
879
|
+
workspaceId: i.manifest.workspaceId
|
|
880
|
+
};
|
|
881
|
+
return {
|
|
882
|
+
virtualSource: w === "manifest" ? Ae({
|
|
883
|
+
projectManifestPath: t.projectManifestPath,
|
|
884
|
+
experienceFlowPaths: i.experienceFlowPaths,
|
|
885
|
+
experienceContentPaths: i.experienceContentPaths,
|
|
886
|
+
manifestMetadata: s
|
|
887
|
+
}) : Oe({
|
|
721
888
|
projectConfigPath: t.projectConfigPath,
|
|
722
889
|
experienceContentPaths: i.experienceContentPaths,
|
|
723
|
-
manifestMetadata:
|
|
724
|
-
mode: "build",
|
|
725
|
-
fetchedAt: i.manifest.fetchedAt,
|
|
726
|
-
projectVersionId: i.manifest.projectVersionId,
|
|
727
|
-
workspaceId: i.manifest.workspaceId
|
|
728
|
-
}
|
|
890
|
+
manifestMetadata: s
|
|
729
891
|
}),
|
|
730
|
-
features:
|
|
892
|
+
features: U(o.features)
|
|
731
893
|
};
|
|
732
|
-
})(), n.catch(() =>
|
|
894
|
+
})(), n.catch(() => $.delete(t)), $.set(t, n));
|
|
733
895
|
let r = await n;
|
|
734
896
|
y = r.virtualSource, l = r.features;
|
|
735
|
-
} else if (
|
|
897
|
+
} else if (f.mode === "production") R.debug("skipping the dev project-config fetch for a production serve resolution");
|
|
736
898
|
else {
|
|
737
|
-
|
|
738
|
-
let e = performance.now(), t = await
|
|
739
|
-
b = t, t ? (l =
|
|
899
|
+
R.info(`fetching project config for "${g}" (dev)`);
|
|
900
|
+
let e = performance.now(), t = await ct(x, g, D, C), n = (performance.now() - e).toFixed(0);
|
|
901
|
+
b = t, t ? (l = U(t.features), dt(t, n)) : R.warn(`failed to fetch project config for "${g}" (${n}ms)`);
|
|
740
902
|
}
|
|
741
903
|
},
|
|
742
904
|
configResolved(e) {
|
|
743
905
|
p = e.base;
|
|
744
906
|
},
|
|
745
907
|
async buildStart() {
|
|
746
|
-
a === "snapshot" &&
|
|
908
|
+
a === "snapshot" && m && d === "build" && (o = await h(m));
|
|
747
909
|
},
|
|
748
910
|
closeBundle() {
|
|
749
|
-
v !== void 0 &&
|
|
750
|
-
"picked.vite.command":
|
|
911
|
+
v !== void 0 && $.delete(v), S?.flush({
|
|
912
|
+
"picked.vite.command": d,
|
|
751
913
|
"picked.data.mode": a,
|
|
752
|
-
"picked.source":
|
|
914
|
+
"picked.source": m?.source ?? "unknown"
|
|
753
915
|
});
|
|
754
916
|
},
|
|
755
917
|
transformIndexHtml: {
|
|
756
918
|
order: "post",
|
|
757
919
|
handler(e, t) {
|
|
758
920
|
if (a === "api" || t.bundle === void 0) return;
|
|
759
|
-
let n =
|
|
921
|
+
let n = Qe(t.bundle);
|
|
760
922
|
if (n === void 0) return;
|
|
761
|
-
let r =
|
|
923
|
+
let r = $e(p, n);
|
|
762
924
|
if (!e.includes(`"${r}"`)) return [{
|
|
763
925
|
tag: "link",
|
|
764
926
|
attrs: {
|
|
@@ -771,35 +933,36 @@ function et(t = {}) {
|
|
|
771
933
|
}
|
|
772
934
|
},
|
|
773
935
|
resolveId(e) {
|
|
774
|
-
if (e ===
|
|
936
|
+
if (e === Je || e.startsWith("virtual:picked/data/experience/") || e.startsWith("virtual:picked/data/flow/")) return `\0${e}`;
|
|
775
937
|
},
|
|
776
938
|
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
|
-
});
|
|
939
|
+
if (e.startsWith(Ze)) return x(this, e.slice(Ze.length));
|
|
940
|
+
if (e.startsWith(Xe) && o && m) return this.addWatchFile(g(m.projectRoot)), Le(o, e.slice(Xe.length));
|
|
941
|
+
if (e !== Ye) return;
|
|
942
|
+
if (a === "api") return De();
|
|
943
|
+
if (a === "snapshot") {
|
|
944
|
+
if (!o || !m) throw Error("picked plugin config hook must run before virtual module load");
|
|
945
|
+
return this.addWatchFile(g(m.projectRoot)), m.configLoading === "manifest" ? Re(o) : Ie(o);
|
|
792
946
|
}
|
|
947
|
+
if (d === "build") return y;
|
|
948
|
+
if (!m) throw Error("picked plugin config hook must run before virtual module load");
|
|
949
|
+
let t = {
|
|
950
|
+
apiUrl: m.apiUrl,
|
|
951
|
+
projectId: m.projectId,
|
|
952
|
+
projectConfig: b,
|
|
953
|
+
previewToken: m.previewToken ?? void 0
|
|
954
|
+
};
|
|
955
|
+
return m.configLoading === "manifest" ? Fe(t) : Pe(t);
|
|
793
956
|
},
|
|
794
957
|
configureServer(e) {
|
|
795
|
-
if (a === "snapshot" &&
|
|
796
|
-
let t =
|
|
797
|
-
n === t && (
|
|
958
|
+
if (a === "snapshot" && m) {
|
|
959
|
+
let t = g(m.projectRoot), n = (n) => {
|
|
960
|
+
n === t && (R.info(`${c} changed; restarting the dev server`), e.restart());
|
|
798
961
|
};
|
|
799
962
|
e.watcher.add(t), e.watcher.on("add", n), e.watcher.on("change", n), e.watcher.on("unlink", n);
|
|
800
963
|
}
|
|
801
964
|
if (t.disableLauncher) return;
|
|
802
|
-
e.middlewares.use(
|
|
965
|
+
e.middlewares.use(ue(() => O(l)));
|
|
803
966
|
let n = e.printUrls.bind(e);
|
|
804
967
|
e.printUrls = () => {
|
|
805
968
|
let t = e.resolvedUrls?.local[0];
|
|
@@ -813,17 +976,17 @@ function et(t = {}) {
|
|
|
813
976
|
generateBundle: {
|
|
814
977
|
order: "post",
|
|
815
978
|
handler(e, n) {
|
|
816
|
-
t.disableLauncher || ("index.html" in n ?
|
|
979
|
+
t.disableLauncher || ("index.html" in n ? R.debug("index.html came from the build; skipping the launcher page") : this.emitFile({
|
|
817
980
|
type: "asset",
|
|
818
981
|
fileName: "index.html",
|
|
819
|
-
source:
|
|
982
|
+
source: O(l)
|
|
820
983
|
}));
|
|
821
984
|
}
|
|
822
985
|
}
|
|
823
986
|
});
|
|
824
987
|
}
|
|
825
|
-
function
|
|
826
|
-
let n =
|
|
988
|
+
function dt(e, t) {
|
|
989
|
+
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
990
|
`${n.length.toString()} features`,
|
|
828
991
|
`${r.length.toString()} experiences`,
|
|
829
992
|
`${i.length.toString()} steps`,
|
|
@@ -831,7 +994,7 @@ function $(e, t) {
|
|
|
831
994
|
`${o.length.toString()} conditions`,
|
|
832
995
|
`${s.length.toString()} actions`
|
|
833
996
|
].join(", ");
|
|
834
|
-
|
|
997
|
+
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
998
|
}
|
|
836
999
|
//#endregion
|
|
837
|
-
export {
|
|
1000
|
+
export { ut as picked };
|