@picked/vite-plugin-picked 0.0.108-next.2 → 0.0.109-next.1

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 CHANGED
@@ -933,4 +933,4 @@ export const manifestMetadata = ${JSON.stringify(n)}
933
933
 
934
934
  registerPickedBundle({ projectConfig, experienceContent, manifestMetadata })
935
935
  `}function ge(e,t){let n=/^\d+$/.test(t)?Object.keys(e.experiences)[Number(t)]:void 0,r=n===void 0?null:e.experiences[n]??null;return`export default ${JSON.stringify(r)}\n`}var _e=5;function K(e,t,n){if(t.length===0)return;if(t.length>_e){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(`
936
- `))}function ve(e,t){t.length!==0&&console.log(`\n ${e}: ${t.length.toString()} loaded\n`)}var ye=[{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=>ae(e)},{header:`Ver`,value:e=>`v${e.version.toString()}`}],be=[{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()}],xe=[{header:`Name`,value:e=>e.name},{header:`Key`,value:e=>e.key},{header:`Fields`,value:e=>(e.fieldIds?.length??0).toString()}],Se=[{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`}],Ce=[{header:`Name`,value:e=>e.name},{header:`Key`,value:e=>e.key}];function we(){return`0.0.108-next.2`}var Te=`https://api.picked.app`,q=`virtual:picked/data`,J=`\0${q}`,Y=`\0${G}`;function Ee(e){for(let t of Object.values(e))if(t.type===`chunk`&&t.moduleIds.includes(J))return t.fileName}function De(e,t){return e===``||e.endsWith(`/`)?`${e}${t}`:`${e}/${t}`}async function Oe(e){try{let t=await(0,r.generate)({config:e,onWarn:e=>{D.warn(e)}});D.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 ke(e,t,n){return e&&(0,i.isTelemetryEnabled)(t,n)?e:null}async function Ae(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 X(e,t,n,r){if(t===void 0||n===void 0||t===n)return;let i=r===void 0?`picked.config says "${n}"`:`picked.config \`${r}\` is "${n}"`;throw Error(`picked plugin option \`${e}\` is "${t}", and ${i}. Remove the plugin option; picked.config is the one place this belongs.`)}function je(e){e.data!==void 0&&D.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.");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;D.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 Me(e,t){let n=await(0,i.loadPickedConfig)(e);n&&n.projectId!==t&&D.warn(`using project "${t}" (picked.config default: "${n.projectId}") — run 'picked status' to inspect`)}async function Z(e,t){let n=await(0,i.loadPickedConfig)(e);return X(`projectId`,t.projectId,n?.projectId),X(`apiUrl`,t.apiUrl,n?.apiUrl),X(`mode`,t.data,n?.data,`data`),je(t),Ae(e,t)}async function Ne(t){if(t.data!==`snapshot`)return(0,e.existsSync)((0,i.resolveSnapshotPath)(t.projectRoot))&&D.warn(`${i.SNAPSHOT_FILENAME} is ignored: the data mode in force is '${t.data}'. Set \`data: 'snapshot'\` in picked.config to build from it, or delete it.`),null;let n=await(0,i.requireSnapshot)(t);return D.info(`serving ${i.SNAPSHOT_FILENAME}: project "${n.projectId}", version ${n.projectVersionId??`none (preview)`} — run \`picked pull\` to refresh`),n.source===`preview`?D.warn(`${i.SNAPSHOT_FILENAME} holds preview data, so this run serves unpublished content. Run \`picked pull\` against the published workspace before you release.`):t.source===`preview`&&D.warn(`the preview workspace in force is not read: ${i.SNAPSHOT_FILENAME} holds published data. Run \`picked pull --allow-preview\` to serve the preview.`),n}async function Pe(e,t,r,i){let a=()=>(0,n.fetchProject)(e,t,{headers:r,previewToken:i??void 0});return j(e)?N(a,(e,t,n)=>{D.info(`local API not ready, retrying in ${(n/1e3).toString()}s (${e.toString()}/${t.toString()})`)}):a()}var Q=new Map;function Fe(e,t,n){return JSON.stringify([e,t,n])}function Ie(r={}){let a=r.mode,o=a??`bundle`,s=null,c=r.generateTypes??!0,l=[],u=process.cwd(),d=`serve`,f=`/`,m=null,h=!1,g,_,v=null,y=(0,i.isTelemetryForcedOffByEnvironment)()?null:V();return de(y,{name:`picked`,config:async(i,f)=>{d=f.command,u=i.root===void 0?process.cwd():(0,t.resolve)(process.cwd(),i.root);let{projectId:p,apiUrl:b}=r;m=await Z(u,{projectId:p,apiUrl:b,data:a});let{projectId:x,apiUrl:S,previewToken:C}=m;if(o=m.data,y=ke(y,m,r.telemetry),D.banner(),s=await Ne(m),s&&(l=P(s.projectConfig.features)),c&&!h&&(h=!0,await Oe(m)),o===`snapshot`)return;S!==Te&&D.warn(`using custom API URL: ${S}`),await Me(u,x);let w=(0,n.createClientHeaders)(`vite-plugin`,we());if(o===`api`)D.debug(`data is 'api': skipping the project-config prefetch`);else if(f.command===`build`){let t=Fe(S,x,u);g=t;let n=Q.get(t);n===void 0&&(n=(async()=>{D.info(`prefetching project config + content for "${x}"`);let t=I(u),n=(0,e.existsSync)(t.pickedDir),r=performance.now(),i=await le({apiUrl:S,projectId:x,projectRoot:u,headers:w,previewToken:C??void 0}),a=(performance.now()-r).toFixed(0);await ne(u,n);let o=i.config;return $(o,a),{virtualSource:pe({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;_=r.virtualSource,l=r.features}else if(f.mode===`production`)D.debug(`skipping the dev project-config fetch for a production serve resolution`);else{D.info(`fetching project config for "${x}" (dev)`);let e=performance.now(),t=await Pe(S,x,w,C),n=(performance.now()-e).toFixed(0);v=t,t?(l=P(t.features),$(t,n)):D.warn(`failed to fetch project config for "${x}" (${n}ms)`)}},configResolved(e){f=e.base},async buildStart(){o===`snapshot`&&m&&d===`build`&&(s=await(0,i.requireSnapshot)(m))},closeBundle(){g!==void 0&&Q.delete(g),y?.flush({"picked.vite.command":d,"picked.data.mode":o,"picked.source":m?.source??`unknown`})},transformIndexHtml:{order:`post`,handler(e,t){if(o===`api`||t.bundle===void 0)return;let n=Ee(t.bundle);if(n===void 0)return;let r=De(f,n);if(!e.includes(`"${r}"`))return[{tag:`link`,attrs:{rel:`modulepreload`,crossorigin:!0,href:r},injectTo:`head`}]}},resolveId(e){if(e===q||e.startsWith(`virtual:picked/data/experience/`))return`\0${e}`},load(e){if(e.startsWith(Y)&&s&&m)return this.addWatchFile((0,i.resolveSnapshotPath)(m.projectRoot)),ge(s,e.slice(Y.length));if(e===J){if(o===`api`)return fe();if(o===`snapshot`){if(!s||!m)throw Error(`picked plugin config hook must run before virtual module load`);return this.addWatchFile((0,i.resolveSnapshotPath)(m.projectRoot)),he(s)}if(d===`build`)return _;if(!m)throw Error(`picked plugin config hook must run before virtual module load`);return me({apiUrl:m.apiUrl,projectId:m.projectId,projectConfig:v,previewToken:m.previewToken??void 0})}},configureServer(e){if(o===`snapshot`&&m){let t=(0,i.resolveSnapshotPath)(m.projectRoot),n=n=>{n===t&&(D.info(`${i.SNAPSHOT_FILENAME} changed; restarting the dev server`),e.restart())};e.watcher.add(t),e.watcher.on(`add`,n),e.watcher.on(`change`,n),e.watcher.on(`unlink`,n)}if(r.disableLauncher)return;e.middlewares.use(O(()=>p(l)));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){r.disableLauncher||(`index.html`in t?D.debug(`index.html came from the build; skipping the launcher page`):this.emitFile({type:`asset`,fileName:`index.html`,source:p(l)}))}}})}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(`, `);D.info(`fetched config in ${t}ms (${l})`),K(`Features`,n,ye),K(`Experiences`,r,be),K(`Steps`,i,xe),K(`Fields`,a,Se),K(`Conditions`,o,Ce),ve(`Actions`,s),D.debug(`config size: ${c.toString()} bytes`)}exports.picked=Ie;
936
+ `))}function ve(e,t){t.length!==0&&console.log(`\n ${e}: ${t.length.toString()} loaded\n`)}var ye=[{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=>ae(e)},{header:`Ver`,value:e=>`v${e.version.toString()}`}],be=[{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()}],xe=[{header:`Name`,value:e=>e.name},{header:`Key`,value:e=>e.key},{header:`Fields`,value:e=>(e.fieldIds?.length??0).toString()}],Se=[{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`}],Ce=[{header:`Name`,value:e=>e.name},{header:`Key`,value:e=>e.key}];function we(){return`0.0.109-next.1`}var Te=`https://api.picked.app`,q=`virtual:picked/data`,J=`\0${q}`,Y=`\0${G}`;function Ee(e){for(let t of Object.values(e))if(t.type===`chunk`&&t.moduleIds.includes(J))return t.fileName}function De(e,t){return e===``||e.endsWith(`/`)?`${e}${t}`:`${e}/${t}`}async function Oe(e){try{let t=await(0,r.generate)({config:e,onWarn:e=>{D.warn(e)}});D.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 ke(e,t,n){return e&&(0,i.isTelemetryEnabled)(t,n)?e:null}async function Ae(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 X(e,t,n,r){if(t===void 0||n===void 0||t===n)return;let i=r===void 0?`picked.config says "${n}"`:`picked.config \`${r}\` is "${n}"`;throw Error(`picked plugin option \`${e}\` is "${t}", and ${i}. Remove the plugin option; picked.config is the one place this belongs.`)}function je(e){e.data!==void 0&&D.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.");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;D.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 Me(e,t){let n=await(0,i.loadPickedConfig)(e);n&&n.projectId!==t&&D.warn(`using project "${t}" (picked.config default: "${n.projectId}") — run 'picked status' to inspect`)}async function Z(e,t){let n=await(0,i.loadPickedConfig)(e);return X(`projectId`,t.projectId,n?.projectId),X(`apiUrl`,t.apiUrl,n?.apiUrl),X(`mode`,t.data,n?.data,`data`),je(t),Ae(e,t)}async function Ne(t){if(t.data!==`snapshot`)return(0,e.existsSync)((0,i.resolveSnapshotPath)(t.projectRoot))&&D.warn(`${i.SNAPSHOT_FILENAME} is ignored: the data mode in force is '${t.data}'. Set \`data: 'snapshot'\` in picked.config to build from it, or delete it.`),null;let n=await(0,i.requireSnapshot)(t);return D.info(`serving ${i.SNAPSHOT_FILENAME}: project "${n.projectId}", version ${n.projectVersionId??`none (preview)`} — run \`picked pull\` to refresh`),n.source===`preview`?D.warn(`${i.SNAPSHOT_FILENAME} holds preview data, so this run serves unpublished content. Run \`picked pull\` against the published workspace before you release.`):t.source===`preview`&&D.warn(`the preview workspace in force is not read: ${i.SNAPSHOT_FILENAME} holds published data. Run \`picked pull --allow-preview\` to serve the preview.`),n}async function Pe(e,t,r,i){let a=()=>(0,n.fetchProject)(e,t,{headers:r,previewToken:i??void 0});return j(e)?N(a,(e,t,n)=>{D.info(`local API not ready, retrying in ${(n/1e3).toString()}s (${e.toString()}/${t.toString()})`)}):a()}var Q=new Map;function Fe(e,t,n){return JSON.stringify([e,t,n])}function Ie(r={}){let a=r.mode,o=a??`bundle`,s=null,c=r.generateTypes??!0,l=[],u=process.cwd(),d=`serve`,f=`/`,m=null,h=!1,g,_,v=null,y=(0,i.isTelemetryForcedOffByEnvironment)()?null:V();return de(y,{name:`picked`,config:async(i,f)=>{d=f.command,u=i.root===void 0?process.cwd():(0,t.resolve)(process.cwd(),i.root);let{projectId:p,apiUrl:b}=r;m=await Z(u,{projectId:p,apiUrl:b,data:a});let{projectId:x,apiUrl:S,previewToken:C}=m;if(o=m.data,y=ke(y,m,r.telemetry),D.banner(),s=await Ne(m),s&&(l=P(s.projectConfig.features)),c&&!h&&(h=!0,await Oe(m)),o===`snapshot`)return;S!==Te&&D.warn(`using custom API URL: ${S}`),await Me(u,x);let w=(0,n.createClientHeaders)(`vite-plugin`,we());if(o===`api`)D.debug(`data is 'api': skipping the project-config prefetch`);else if(f.command===`build`){let t=Fe(S,x,u);g=t;let n=Q.get(t);n===void 0&&(n=(async()=>{D.info(`prefetching project config + content for "${x}"`);let t=I(u),n=(0,e.existsSync)(t.pickedDir),r=performance.now(),i=await le({apiUrl:S,projectId:x,projectRoot:u,headers:w,previewToken:C??void 0}),a=(performance.now()-r).toFixed(0);await ne(u,n);let o=i.config;return $(o,a),{virtualSource:pe({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;_=r.virtualSource,l=r.features}else if(f.mode===`production`)D.debug(`skipping the dev project-config fetch for a production serve resolution`);else{D.info(`fetching project config for "${x}" (dev)`);let e=performance.now(),t=await Pe(S,x,w,C),n=(performance.now()-e).toFixed(0);v=t,t?(l=P(t.features),$(t,n)):D.warn(`failed to fetch project config for "${x}" (${n}ms)`)}},configResolved(e){f=e.base},async buildStart(){o===`snapshot`&&m&&d===`build`&&(s=await(0,i.requireSnapshot)(m))},closeBundle(){g!==void 0&&Q.delete(g),y?.flush({"picked.vite.command":d,"picked.data.mode":o,"picked.source":m?.source??`unknown`})},transformIndexHtml:{order:`post`,handler(e,t){if(o===`api`||t.bundle===void 0)return;let n=Ee(t.bundle);if(n===void 0)return;let r=De(f,n);if(!e.includes(`"${r}"`))return[{tag:`link`,attrs:{rel:`modulepreload`,crossorigin:!0,href:r},injectTo:`head`}]}},resolveId(e){if(e===q||e.startsWith(`virtual:picked/data/experience/`))return`\0${e}`},load(e){if(e.startsWith(Y)&&s&&m)return this.addWatchFile((0,i.resolveSnapshotPath)(m.projectRoot)),ge(s,e.slice(Y.length));if(e===J){if(o===`api`)return fe();if(o===`snapshot`){if(!s||!m)throw Error(`picked plugin config hook must run before virtual module load`);return this.addWatchFile((0,i.resolveSnapshotPath)(m.projectRoot)),he(s)}if(d===`build`)return _;if(!m)throw Error(`picked plugin config hook must run before virtual module load`);return me({apiUrl:m.apiUrl,projectId:m.projectId,projectConfig:v,previewToken:m.previewToken??void 0})}},configureServer(e){if(o===`snapshot`&&m){let t=(0,i.resolveSnapshotPath)(m.projectRoot),n=n=>{n===t&&(D.info(`${i.SNAPSHOT_FILENAME} changed; restarting the dev server`),e.restart())};e.watcher.add(t),e.watcher.on(`add`,n),e.watcher.on(`change`,n),e.watcher.on(`unlink`,n)}if(r.disableLauncher)return;e.middlewares.use(O(()=>p(l)));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){r.disableLauncher||(`index.html`in t?D.debug(`index.html came from the build; skipping the launcher page`):this.emitFile({type:`asset`,fileName:`index.html`,source:p(l)}))}}})}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(`, `);D.info(`fetched config in ${t}ms (${l})`),K(`Features`,n,ye),K(`Experiences`,r,be),K(`Steps`,i,xe),K(`Fields`,a,Se),K(`Conditions`,o,Ce),ve(`Actions`,s),D.debug(`config size: ${c.toString()} bytes`)}exports.picked=Ie;
package/dist/esm/index.js CHANGED
@@ -607,7 +607,7 @@ var Ne = [
607
607
  value: (e) => e.key
608
608
  }];
609
609
  function Re() {
610
- return "0.0.108-next.2";
610
+ return "0.0.109-next.1";
611
611
  }
612
612
  var ze = "https://api.picked.app", Y = "virtual:picked/data", X = `\0${Y}`, Z = `\0${q}`;
613
613
  function Be(e) {
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@picked/vite-plugin-picked",
3
3
  "description": "Vite plugin for build-time config injection",
4
- "version": "0.0.108-next.2",
4
+ "version": "0.0.109-next.1",
5
5
  "dependencies": {
6
- "@picked/client": "0.0.108-next.2",
7
- "@picked/config": "0.0.108-next.2",
8
- "@picked/delivery-api-client": "0.0.108-next.2",
9
- "@picked/telemetry": "0.0.108-next.2",
10
- "@picked/typegen": "0.0.108-next.2"
6
+ "@picked/client": "0.0.109-next.1",
7
+ "@picked/config": "0.0.109-next.1",
8
+ "@picked/delivery-api-client": "0.0.109-next.1",
9
+ "@picked/telemetry": "0.0.109-next.1",
10
+ "@picked/typegen": "0.0.109-next.1"
11
11
  },
12
12
  "devDependencies": {
13
13
  "@repo/eslint-config": "workspace:*",