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