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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/esm/index.js CHANGED
@@ -43,37 +43,37 @@ function _(e) {
43
43
  //#endregion
44
44
  //#region src/log.ts
45
45
  var v = "picked", y = "\x1B[0m";
46
- function ee() {
46
+ function b() {
47
47
  let e = process.env.NO_COLOR;
48
48
  return e === "1" || e === "true";
49
49
  }
50
- function b(e) {
51
- return (t) => ee() ? t : `${e}${t}${y}`;
50
+ function x(e) {
51
+ return (t) => b() ? t : `${e}${t}${y}`;
52
52
  }
53
- var x = [
53
+ var S = [
54
54
  "debug",
55
55
  "info",
56
56
  "warn",
57
57
  "error",
58
58
  "silent"
59
- ], S = {
59
+ ], C = {
60
60
  debug: {
61
- color: b("\x1B[2m"),
61
+ color: x("\x1B[2m"),
62
62
  log: console.debug,
63
63
  enabled: !1
64
64
  },
65
65
  info: {
66
- color: b("\x1B[36m"),
66
+ color: x("\x1B[36m"),
67
67
  log: console.log,
68
68
  enabled: !0
69
69
  },
70
70
  warn: {
71
- color: b("\x1B[33m"),
71
+ color: x("\x1B[33m"),
72
72
  log: console.warn,
73
73
  enabled: !0
74
74
  },
75
75
  error: {
76
- color: b("\x1B[31m"),
76
+ color: x("\x1B[31m"),
77
77
  log: console.error,
78
78
  enabled: !0
79
79
  },
@@ -82,52 +82,52 @@ var x = [
82
82
  enabled: !1
83
83
  }
84
84
  };
85
- function te(e, t) {
85
+ function w(e, t) {
86
86
  return `${(/* @__PURE__ */ new Date()).toLocaleTimeString()} [${t ? `${v}:${t}` : v}] ${e}`;
87
87
  }
88
- function C(e, t, n, r) {
88
+ function T(e, t, n, r) {
89
89
  if (!e.enabled) return;
90
- let i = te(t, r);
90
+ let i = w(t, r);
91
91
  e.log(e.color ? e.color(i) : i), n !== void 0 && e.log(n);
92
92
  }
93
- function w(e) {
94
- let t = S[e], n = /* @__PURE__ */ new Set();
93
+ function E(e) {
94
+ let t = C[e], n = /* @__PURE__ */ new Set();
95
95
  return Object.assign((e, n, r) => {
96
- C(t, e, n, r);
96
+ T(t, e, n, r);
97
97
  }, { once(e, r, i) {
98
- !t.enabled || n.has(e) || (n.add(e), C(t, e, r, i));
98
+ !t.enabled || n.has(e) || (n.add(e), T(t, e, r, i));
99
99
  } });
100
100
  }
101
- function ne(e) {
102
- let t = x.indexOf(e);
101
+ function D(e) {
102
+ let t = S.indexOf(e);
103
103
  if (t === -1) {
104
- C(S.error, `invalid log level: ${e}`);
104
+ T(C.error, `invalid log level: ${e}`);
105
105
  return;
106
106
  }
107
- for (let [e, n] of x.entries()) S[n].enabled = e >= t;
107
+ for (let [e, n] of S.entries()) C[n].enabled = e >= t;
108
108
  }
109
- var T = b("\x1B[34m"), E = b("\x1B[36m");
110
- function re() {
109
+ var O = x("\x1B[34m"), k = x("\x1B[36m");
110
+ function A() {
111
111
  let e = [
112
- ` ${T("_")} ${E("_")} _ _ _`,
113
- `${T("(_)")} ${E("(_)")} _ __(_)__| |_____ __| |`,
114
- ` ${T("_")} ${T("_")} | '_ \\ / _| / / -_) _\` |`,
115
- `${T("(_)")} ${T("(_)")} | .__/_\\__|_\\_\\___\\__,_|`,
112
+ ` ${O("_")} ${k("_")} _ _ _`,
113
+ `${O("(_)")} ${k("(_)")} _ __(_)__| |_____ __| |`,
114
+ ` ${O("_")} ${O("_")} | '_ \\ / _| / / -_) _\` |`,
115
+ `${O("(_)")} ${O("(_)")} | .__/_\\__|_\\_\\___\\__,_|`,
116
116
  " |_|\n "
117
117
  ];
118
118
  console.log(e.join("\n"));
119
119
  }
120
- var D = {
121
- banner: re,
122
- debug: w("debug"),
123
- info: w("info"),
124
- warn: w("warn"),
125
- error: w("error"),
126
- setLevel: ne
120
+ var j = {
121
+ banner: A,
122
+ debug: E("debug"),
123
+ info: E("info"),
124
+ warn: E("warn"),
125
+ error: E("error"),
126
+ setLevel: D
127
127
  };
128
128
  //#endregion
129
129
  //#region src/middleware.ts
130
- function O(e) {
130
+ function ee(e) {
131
131
  return (t, n, r) => {
132
132
  if (t.method !== "GET") {
133
133
  r();
@@ -144,28 +144,28 @@ function O(e) {
144
144
  }
145
145
  //#endregion
146
146
  //#region src/gitignore.ts
147
- var k = ".picked/";
148
- async function ie(n, r) {
147
+ var M = ".picked/";
148
+ async function te(n, r) {
149
149
  if (r) return;
150
150
  let i = t(n, ".gitignore");
151
151
  if (!e(i)) {
152
- await f(i, `${k}
152
+ await f(i, `${M}
153
153
  `);
154
154
  return;
155
155
  }
156
156
  let a = await d(i, "utf8");
157
- if (A(a)) return;
158
- let o = `${a.length > 0 && !a.endsWith("\n") ? "\n" : ""}${k}
157
+ if (ne(a)) return;
158
+ let o = `${a.length > 0 && !a.endsWith("\n") ? "\n" : ""}${M}
159
159
  `;
160
160
  await l(i, o);
161
161
  }
162
- function A(e) {
163
- return e.split(/\r?\n/).map((e) => e.trim()).some((e) => e === k || e === ".picked");
162
+ function ne(e) {
163
+ return e.split(/\r?\n/).map((e) => e.trim()).some((e) => e === M || e === ".picked");
164
164
  }
165
165
  //#endregion
166
166
  //#region src/retry.ts
167
- var j = 6, ae = 5e3;
168
- function M(e) {
167
+ var N = 6, re = 5e3;
168
+ function P(e) {
169
169
  let t;
170
170
  try {
171
171
  t = new URL(e).hostname;
@@ -174,12 +174,12 @@ function M(e) {
174
174
  }
175
175
  return t === "localhost" || t === "127.0.0.1" || t === "::1" || t === "[::1]" || t !== "api.picked.app" && t.endsWith(".picked.app");
176
176
  }
177
- function N(e) {
177
+ function ie(e) {
178
178
  return new Promise((t) => {
179
179
  setTimeout(t, e);
180
180
  });
181
181
  }
182
- async function P(e, t) {
182
+ async function F(e, t) {
183
183
  let n = null, r = null;
184
184
  try {
185
185
  n = await e();
@@ -187,9 +187,9 @@ async function P(e, t) {
187
187
  r = e;
188
188
  }
189
189
  if (n !== null) return n;
190
- for (let i = 1; i <= j; i++) {
191
- let a = ae * 2 ** (i - 1);
192
- t(i, j, a), await N(a), r = null;
190
+ for (let i = 1; i <= N; i++) {
191
+ let a = re * 2 ** (i - 1);
192
+ t(i, N, a), await ie(a), r = null;
193
193
  try {
194
194
  n = await e();
195
195
  } catch (e) {
@@ -202,13 +202,13 @@ async function P(e, t) {
202
202
  }
203
203
  //#endregion
204
204
  //#region src/util.ts
205
- function F(e) {
205
+ function I(e) {
206
206
  return Array.isArray(e) ? e : [];
207
207
  }
208
208
  //#endregion
209
209
  //#region src/prefetch.ts
210
- var I = 2;
211
- function L(e) {
210
+ var L = 2;
211
+ function R(e) {
212
212
  let n = t(e, ".picked");
213
213
  return {
214
214
  pickedDir: n,
@@ -217,50 +217,50 @@ function L(e) {
217
217
  experiencesDir: t(n, "experiences")
218
218
  };
219
219
  }
220
- async function R(t) {
220
+ async function ae(t) {
221
221
  if (!e(t)) return null;
222
222
  try {
223
223
  let e = await d(t, "utf8"), n = JSON.parse(e);
224
- return z(n) ? n : null;
224
+ return oe(n) ? n : null;
225
225
  } catch {
226
226
  return null;
227
227
  }
228
228
  }
229
- function z(e) {
229
+ function oe(e) {
230
230
  return !(typeof e != "object" || !e || !("version" in e) || typeof e.version != "number" || !("projectVersionId" in e) || typeof e.projectVersionId != "string" || !("workspaceId" in e) || typeof e.workspaceId != "string" || !("experiences" in e) || !Array.isArray(e.experiences));
231
231
  }
232
- function B(e) {
232
+ function z(e) {
233
233
  let t = /* @__PURE__ */ new Set();
234
- for (let n of F(e.steps)) n.layoutContentId && t.add(n.id);
234
+ for (let n of I(e.steps)) n.layoutContentId && t.add(n.id);
235
235
  if (t.size === 0) return [];
236
236
  let n = [];
237
- for (let r of F(e.experiences)) F(r.nodes).some((e) => e.type === "step" && t.has(e.stepId)) && n.push(r.id);
237
+ for (let r of I(e.experiences)) I(r.nodes).some((e) => e.type === "step" && t.has(e.stepId)) && n.push(r.id);
238
238
  return n;
239
239
  }
240
- async function V(n) {
241
- let { apiUrl: r, projectId: i, projectRoot: a, headers: o, previewToken: s, reuseWhenUnchanged: c = !0 } = n, l = L(a), d = await U(r, i, o, s), p = B(d);
240
+ async function B(n) {
241
+ let { apiUrl: r, projectId: i, projectRoot: a, headers: o, previewToken: s, reuseWhenUnchanged: c = !0 } = n, l = R(a), d = await H(r, i, o, s), p = z(d);
242
242
  if (await u(l.experiencesDir, { recursive: !0 }), await f(l.projectConfigPath, JSON.stringify(d, null, 2)), c) {
243
- let t = await R(l.manifestPath);
244
- if (t?.version === I && t.projectVersionId === d.versionId && t.workspaceId === d.workspaceId) {
245
- let n = H(l, p);
243
+ let t = await ae(l.manifestPath);
244
+ if (t?.version === L && t.projectVersionId === d.versionId && t.workspaceId === d.workspaceId) {
245
+ let n = V(l, p);
246
246
  if (Object.values(n).every((t) => e(t))) return {
247
247
  config: d,
248
248
  manifest: t,
249
249
  experienceContentPaths: n
250
250
  };
251
- D.info("a manifest-referenced content file is missing; refetching every experience");
251
+ j.info("a manifest-referenced content file is missing; refetching every experience");
252
252
  }
253
253
  }
254
254
  let m = (/* @__PURE__ */ new Date()).toISOString(), h = [];
255
255
  for (let e of p) {
256
- let n = await W(r, i, e, o, s), a = t(l.experiencesDir, `${e}.json`);
256
+ let n = await U(r, i, e, o, s), a = t(l.experiencesDir, `${e}.json`);
257
257
  await f(a, JSON.stringify(n, null, 2)), h.push({
258
258
  id: e,
259
259
  fetchedAt: m
260
260
  });
261
261
  }
262
262
  let g = {
263
- version: I,
263
+ version: L,
264
264
  fetchedAt: m,
265
265
  projectVersionId: d.versionId,
266
266
  workspaceId: d.workspaceId,
@@ -270,30 +270,30 @@ async function V(n) {
270
270
  return await f(l.manifestPath, JSON.stringify(g, null, 2)), {
271
271
  config: d,
272
272
  manifest: g,
273
- experienceContentPaths: H(l, p)
273
+ experienceContentPaths: V(l, p)
274
274
  };
275
275
  }
276
- function H(e, n) {
276
+ function V(e, n) {
277
277
  let r = {};
278
278
  for (let i of n) r[i] = t(e.experiencesDir, `${i}.json`);
279
279
  return r;
280
280
  }
281
- async function U(e, t, n, r) {
281
+ async function H(e, t, n, r) {
282
282
  let i = () => a(e, t, {
283
283
  headers: n,
284
284
  previewToken: r
285
285
  }), o;
286
286
  try {
287
- o = M(e) ? await P(i, (e, t, n) => {
288
- D.info(`project config not ready, retrying in ${(n / 1e3).toString()}s (${e.toString()}/${t.toString()})`);
287
+ o = P(e) ? await F(i, (e, t, n) => {
288
+ j.info(`project config not ready, retrying in ${(n / 1e3).toString()}s (${e.toString()}/${t.toString()})`);
289
289
  }) : await i();
290
290
  } catch (n) {
291
- throw Error(`[picked] Build-time fetch of project config failed for "${t}" at ${e}: ${G(n)}`);
291
+ throw Error(`[picked] Build-time fetch of project config failed for "${t}" at ${e}: ${W(n)}`);
292
292
  }
293
293
  if (!o) throw Error(`[picked] Build-time fetch of project config returned no usable response for "${t}" at ${e}. Confirm the API is reachable and the project ID is correct.`);
294
294
  return o;
295
295
  }
296
- async function W(e, t, n, r, a) {
296
+ async function U(e, t, n, r, a) {
297
297
  let o;
298
298
  try {
299
299
  o = await i(e, t, n, {
@@ -301,12 +301,12 @@ async function W(e, t, n, r, a) {
301
301
  previewToken: a
302
302
  });
303
303
  } catch (t) {
304
- throw Error(`[picked] Build-time fetch of content for experience "${n}" failed at ${e}: ${G(t)}`);
304
+ throw Error(`[picked] Build-time fetch of content for experience "${n}" failed at ${e}: ${W(t)}`);
305
305
  }
306
306
  if (!o) throw Error(`[picked] Build-time fetch of content for experience "${n}" returned no usable response. Confirm the experience id exists and the API is reachable.`);
307
307
  return o;
308
308
  }
309
- function G(e) {
309
+ function W(e) {
310
310
  if (e instanceof Error) return e.message;
311
311
  if (typeof e == "string") return e;
312
312
  try {
@@ -317,12 +317,12 @@ function G(e) {
317
317
  }
318
318
  //#endregion
319
319
  //#region src/virtual-module/api.ts
320
- function K() {
320
+ function G() {
321
321
  return "export const manifestMetadata = {\n mode: 'api',\n fetchedAt: null,\n projectVersionId: null,\n workspaceId: null,\n}\n";
322
322
  }
323
323
  //#endregion
324
324
  //#region src/virtual-module/build.ts
325
- function q(e) {
325
+ function K(e) {
326
326
  let { projectConfigPath: t, experienceContentPaths: n, manifestMetadata: r } = e, i = (e) => JSON.stringify(e), a = Object.entries(n).map(([e, t]) => ` ${JSON.stringify(e)}: () => import(${i(t)}).then((m) => m.default ?? m),`).join("\n");
327
327
  return `import { registerPickedBundle } from '@picked/client/plugins/dynamic-experiences'
328
328
  import projectConfigJson from ${i(t)}
@@ -352,7 +352,7 @@ registerPickedBundle({ projectConfig, experienceContent, manifestMetadata })
352
352
  }
353
353
  //#endregion
354
354
  //#region src/virtual-module/dev.ts
355
- function J(e) {
355
+ function se(e) {
356
356
  let { apiUrl: t, projectId: n, projectConfig: r, previewToken: i } = e, a = r ? "import { fetchExperienceContent, registerPickedBundle } from '@picked/client/plugins/dynamic-experiences'" : "import { fetchProject, fetchExperienceContent } from '@picked/client/plugins/dynamic-experiences'", o = r ? `export const projectConfig = ${JSON.stringify(r)}` : "export const projectConfig = await fetchProject(apiUrl, projectId, { previewToken: previewToken ?? undefined })", s = r ? "\nregisterPickedBundle({ projectConfig, experienceContent, manifestMetadata })\n" : "";
357
357
  return `${a}
358
358
 
@@ -378,10 +378,10 @@ ${s}`;
378
378
  }
379
379
  //#endregion
380
380
  //#region src/index.ts
381
- var oe = 5;
382
- function Y(e, t, n) {
381
+ var q = 5;
382
+ function J(e, t, n) {
383
383
  if (t.length === 0) return;
384
- if (t.length > oe) {
384
+ if (t.length > q) {
385
385
  console.log(`\n ${e}: ${t.length.toString()} loaded\n`);
386
386
  return;
387
387
  }
@@ -396,10 +396,10 @@ function Y(e, t, n) {
396
396
  ""
397
397
  ].join("\n"));
398
398
  }
399
- function se(e, t) {
399
+ function ce(e, t) {
400
400
  t.length !== 0 && console.log(`\n ${e}: ${t.length.toString()} loaded\n`);
401
401
  }
402
- var ce = [
402
+ var le = [
403
403
  {
404
404
  header: "Name",
405
405
  value: (e) => e.name
@@ -420,7 +420,7 @@ var ce = [
420
420
  header: "Ver",
421
421
  value: (e) => `v${e.version.toString()}`
422
422
  }
423
- ], le = [
423
+ ], ue = [
424
424
  {
425
425
  header: "Name",
426
426
  value: (e) => e.name
@@ -441,7 +441,7 @@ var ce = [
441
441
  header: "Targets",
442
442
  value: (e) => e.targets.length.toString()
443
443
  }
444
- ], ue = [
444
+ ], de = [
445
445
  {
446
446
  header: "Name",
447
447
  value: (e) => e.name
@@ -454,7 +454,7 @@ var ce = [
454
454
  header: "Fields",
455
455
  value: (e) => (e.fieldIds?.length ?? 0).toString()
456
456
  }
457
- ], de = [
457
+ ], fe = [
458
458
  {
459
459
  header: "Name",
460
460
  value: (e) => e.name
@@ -471,76 +471,98 @@ var ce = [
471
471
  header: "Required",
472
472
  value: (e) => e.required ? "yes" : "no"
473
473
  }
474
- ], fe = [{
474
+ ], pe = [{
475
475
  header: "Name",
476
476
  value: (e) => e.name
477
477
  }, {
478
478
  header: "Key",
479
479
  value: (e) => e.key
480
480
  }];
481
- function pe() {
482
- return "0.0.1-dev.1786601464574";
481
+ function me() {
482
+ return "0.0.1-dev.1787019239195";
483
483
  }
484
- var me = "https://api.picked.app", X = "virtual:picked/data", Z = `\0${X}`;
485
- function he(e) {
486
- for (let t of Object.values(e)) if (t.type === "chunk" && t.moduleIds.includes(Z)) return t.fileName;
484
+ var he = "https://api.picked.app", Y = "virtual:picked/data", X = `\0${Y}`;
485
+ function ge(e) {
486
+ for (let t of Object.values(e)) if (t.type === "chunk" && t.moduleIds.includes(X)) return t.fileName;
487
487
  }
488
- function ge(e, t) {
488
+ function _e(e, t) {
489
489
  return e === "" || e.endsWith("/") ? `${e}${t}` : `${e}/${t}`;
490
490
  }
491
- async function _e(e) {
491
+ async function ve(e) {
492
492
  try {
493
- let t = await o({ config: e });
494
- D.info(`generated types at ${t.typesOutput}`);
493
+ let t = await o({
494
+ config: e,
495
+ onWarn: (e) => {
496
+ j.warn(e);
497
+ }
498
+ });
499
+ j.info(`generated types at ${t.typesOutput}`);
495
500
  } catch (e) {
496
501
  let t = e instanceof Error ? e.message : String(e);
497
- D.warn(`type generation failed: ${t}`);
502
+ throw Error(`type generation failed: ${t}. Fix the schema source, or set \`generateTypes: false\` on the picked plugin to skip it.`);
498
503
  }
499
504
  }
500
- async function ve(e) {
501
- let t = await c(e);
502
- if (!t) throw Error("picked.config.{ts,js,json} is required. Add a picked.config.ts with projectId and apiUrl.");
503
- return t;
504
- }
505
505
  async function ye(e, t) {
506
+ let n = await c(e, t);
507
+ if (!n) throw Error("picked.config.{ts,js,json} is required. Add a picked.config.ts with projectId and apiUrl.");
508
+ return n;
509
+ }
510
+ function Z(e, t, n) {
511
+ 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.`);
512
+ }
513
+ function be(e) {
514
+ let t = [];
515
+ if (e.projectId !== void 0 && t.push("`projectId`"), e.apiUrl !== void 0 && t.push("`apiUrl`"), t.length === 0) return;
516
+ let n = t.length > 1;
517
+ j.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.`);
518
+ }
519
+ async function xe(e, t) {
506
520
  let n = await s(e);
507
- n && n.projectId !== t && D.warn(`using project "${t}" (picked.config default: "${n.projectId}") — run 'picked status' to inspect`);
521
+ n && n.projectId !== t && j.warn(`using project "${t}" (picked.config default: "${n.projectId}") — run 'picked status' to inspect`);
508
522
  }
509
523
  var Q = /* @__PURE__ */ new Map();
510
- function be(e, t, n) {
524
+ function Se(e, t, n) {
511
525
  return JSON.stringify([
512
526
  e,
513
527
  t,
514
528
  n
515
529
  ]);
516
530
  }
517
- function xe(t = {}) {
518
- let i = t.mode ?? "bundle", o = t.generateTypes ?? !0, s = [], c = process.cwd(), l = "serve", u = "/", d = null, f = !1, p, m, g = null;
531
+ function Ce(t = {}) {
532
+ let i = t.mode ?? "bundle", o = t.generateTypes ?? !0, c = [], l = process.cwd(), u = "serve", d = "/", f = null, p = !1, m, g, _ = null;
519
533
  return {
520
534
  name: "picked",
521
- config: async (t, u) => {
522
- l = u.command, c = t.root === void 0 ? process.cwd() : n(process.cwd(), t.root), d = await ve(c);
523
- let { projectId: h, apiUrl: _, previewToken: v } = d;
524
- D.banner(), o && !f && (f = !0, await _e(d)), _ !== me && D.warn(`using custom API URL: ${_}`), await ye(c, h);
525
- let y = r("vite-plugin", pe());
526
- if (i === "api") D.debug("mode is 'api': skipping the project-config prefetch");
527
- else if (u.command === "build") {
528
- let t = be(_, h, c);
529
- p = t;
535
+ config: async (d, h) => {
536
+ u = h.command, l = d.root === void 0 ? process.cwd() : n(process.cwd(), d.root);
537
+ let { projectId: v, apiUrl: y } = t, b = await s(l);
538
+ Z("projectId", v, b?.projectId), Z("apiUrl", y, b?.apiUrl), be({
539
+ projectId: v,
540
+ apiUrl: y
541
+ }), f = await ye(l, {
542
+ projectId: v,
543
+ apiUrl: y
544
+ });
545
+ let { projectId: x, apiUrl: S, previewToken: C } = f;
546
+ j.banner(), o && !p && (p = !0, await ve(f)), S !== he && j.warn(`using custom API URL: ${S}`), await xe(l, x);
547
+ let w = r("vite-plugin", me());
548
+ if (i === "api") j.debug("mode is 'api': skipping the project-config prefetch");
549
+ else if (h.command === "build") {
550
+ let t = Se(S, x, l);
551
+ m = t;
530
552
  let n = Q.get(t);
531
553
  n === void 0 && (n = (async () => {
532
- D.info(`prefetching project config + content for "${h}"`);
533
- let t = L(c), n = e(t.pickedDir), r = performance.now(), i = await V({
534
- apiUrl: _,
535
- projectId: h,
536
- projectRoot: c,
537
- headers: y,
538
- previewToken: v ?? void 0
554
+ j.info(`prefetching project config + content for "${x}"`);
555
+ let t = R(l), n = e(t.pickedDir), r = performance.now(), i = await B({
556
+ apiUrl: S,
557
+ projectId: x,
558
+ projectRoot: l,
559
+ headers: w,
560
+ previewToken: C ?? void 0
539
561
  }), a = (performance.now() - r).toFixed(0);
540
- await ie(c, n);
562
+ await te(l, n);
541
563
  let o = i.config;
542
564
  return $(o, a), {
543
- virtualSource: q({
565
+ virtualSource: K({
544
566
  projectConfigPath: t.projectConfigPath,
545
567
  experienceContentPaths: i.experienceContentPaths,
546
568
  manifestMetadata: {
@@ -550,36 +572,36 @@ function xe(t = {}) {
550
572
  workspaceId: i.manifest.workspaceId
551
573
  }
552
574
  }),
553
- features: F(o.features)
575
+ features: I(o.features)
554
576
  };
555
577
  })(), n.catch(() => Q.delete(t)), Q.set(t, n));
556
578
  let r = await n;
557
- m = r.virtualSource, s = r.features;
558
- } else if (u.mode === "production") D.debug("skipping the dev project-config fetch for a production serve resolution");
579
+ g = r.virtualSource, c = r.features;
580
+ } else if (h.mode === "production") j.debug("skipping the dev project-config fetch for a production serve resolution");
559
581
  else {
560
- D.info(`fetching project config for "${h}" (dev)`);
561
- let e = performance.now(), t = () => a(_, h, {
562
- headers: y,
563
- previewToken: v ?? void 0
564
- }), n = M(_) ? await P(t, (e, t, n) => {
565
- D.info(`local API not ready, retrying in ${(n / 1e3).toString()}s (${e.toString()}/${t.toString()})`);
582
+ j.info(`fetching project config for "${x}" (dev)`);
583
+ let e = performance.now(), t = () => a(S, x, {
584
+ headers: w,
585
+ previewToken: C ?? void 0
586
+ }), n = P(S) ? await F(t, (e, t, n) => {
587
+ j.info(`local API not ready, retrying in ${(n / 1e3).toString()}s (${e.toString()}/${t.toString()})`);
566
588
  }) : await t(), r = (performance.now() - e).toFixed(0);
567
- g = n, n ? (s = F(n.features), $(n, r)) : D.warn(`failed to fetch project config for "${h}" (${r}ms)`);
589
+ _ = n, n ? (c = I(n.features), $(n, r)) : j.warn(`failed to fetch project config for "${x}" (${r}ms)`);
568
590
  }
569
591
  },
570
592
  configResolved(e) {
571
- u = e.base;
593
+ d = e.base;
572
594
  },
573
595
  closeBundle() {
574
- p !== void 0 && Q.delete(p);
596
+ m !== void 0 && Q.delete(m);
575
597
  },
576
598
  transformIndexHtml: {
577
599
  order: "post",
578
600
  handler(e, t) {
579
601
  if (i === "api" || t.bundle === void 0) return;
580
- let n = he(t.bundle);
602
+ let n = ge(t.bundle);
581
603
  if (n === void 0) return;
582
- let r = ge(u, n);
604
+ let r = _e(d, n);
583
605
  if (!e.includes(`"${r}"`)) return [{
584
606
  tag: "link",
585
607
  attrs: {
@@ -592,24 +614,24 @@ function xe(t = {}) {
592
614
  }
593
615
  },
594
616
  resolveId(e) {
595
- if (e === X) return Z;
617
+ if (e === Y) return X;
596
618
  },
597
619
  load(e) {
598
- if (e === Z) {
599
- if (i === "api") return K();
600
- if (l === "build") return m;
601
- if (!d) throw Error("picked plugin config hook must run before virtual module load");
602
- return J({
603
- apiUrl: d.apiUrl,
604
- projectId: d.projectId,
605
- projectConfig: g,
606
- previewToken: d.previewToken ?? void 0
620
+ if (e === X) {
621
+ if (i === "api") return G();
622
+ if (u === "build") return g;
623
+ if (!f) throw Error("picked plugin config hook must run before virtual module load");
624
+ return se({
625
+ apiUrl: f.apiUrl,
626
+ projectId: f.projectId,
627
+ projectConfig: _,
628
+ previewToken: f.previewToken ?? void 0
607
629
  });
608
630
  }
609
631
  },
610
632
  configureServer(e) {
611
633
  if (t.disableLauncher) return;
612
- e.middlewares.use(O(() => h(s)));
634
+ e.middlewares.use(ee(() => h(c)));
613
635
  let n = e.printUrls.bind(e);
614
636
  e.printUrls = () => {
615
637
  let t = e.resolvedUrls?.local[0];
@@ -625,13 +647,13 @@ function xe(t = {}) {
625
647
  handler(e, n) {
626
648
  if (!t.disableLauncher) {
627
649
  if ("index.html" in n) {
628
- D.debug("index.html came from the build; skipping the launcher page");
650
+ j.debug("index.html came from the build; skipping the launcher page");
629
651
  return;
630
652
  }
631
653
  this.emitFile({
632
654
  type: "asset",
633
655
  fileName: "index.html",
634
- source: h(s)
656
+ source: h(c)
635
657
  });
636
658
  }
637
659
  }
@@ -639,7 +661,7 @@ function xe(t = {}) {
639
661
  };
640
662
  }
641
663
  function $(e, t) {
642
- let n = F(e.features), r = F(e.experiences), i = F(e.steps), a = F(e.fields), o = F(e.conditions), s = F(e.actions), c = JSON.stringify(e).length, l = [
664
+ let n = I(e.features), r = I(e.experiences), i = I(e.steps), a = I(e.fields), o = I(e.conditions), s = I(e.actions), c = JSON.stringify(e).length, l = [
643
665
  `${n.length.toString()} features`,
644
666
  `${r.length.toString()} experiences`,
645
667
  `${i.length.toString()} steps`,
@@ -647,7 +669,7 @@ function $(e, t) {
647
669
  `${o.length.toString()} conditions`,
648
670
  `${s.length.toString()} actions`
649
671
  ].join(", ");
650
- D.info(`fetched config in ${t}ms (${l})`), Y("Features", n, ce), Y("Experiences", r, le), Y("Steps", i, ue), Y("Fields", a, de), Y("Conditions", o, fe), se("Actions", s), D.debug(`config size: ${c.toString()} bytes`);
672
+ j.info(`fetched config in ${t}ms (${l})`), J("Features", n, le), J("Experiences", r, ue), J("Steps", i, de), J("Fields", a, fe), J("Conditions", o, pe), ce("Actions", s), j.debug(`config size: ${c.toString()} bytes`);
651
673
  }
652
674
  //#endregion
653
- export { xe as picked };
675
+ export { Ce as picked };
@@ -1,5 +1,17 @@
1
1
  import type { Plugin } from 'vite';
2
2
  export interface PickedPluginOptions {
3
+ /**
4
+ * @deprecated Set `projectId` in `picked.config` instead, which the CLI and the type
5
+ * generator read from too. Still honoured when `picked.config` omits it, and a future
6
+ * release drops it. Setting both to different values is an error.
7
+ */
8
+ projectId?: string;
9
+ /**
10
+ * @deprecated Set `apiUrl` in `picked.config` instead, which the CLI and the type
11
+ * generator read from too. Still honoured when `picked.config` omits it, and a future
12
+ * release drops it. Setting both to different values is an error.
13
+ */
14
+ apiUrl?: string;
3
15
  /** Disable the launcher HTML page (dev server + build output). Defaults to false. */
4
16
  disableLauncher?: boolean;
5
17
  /** Generate TypeScript types from the workspace schema on dev/build. Defaults to true. */