@picked/vite-plugin-picked 0.0.48 → 0.0.49
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 -1
- package/dist/esm/index.js +1 -1
- package/package.json +3 -3
package/dist/cjs/index.js
CHANGED
|
@@ -858,4 +858,4 @@
|
|
|
858
858
|
</html>`])),r,t)}function w(e){return e.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""")}function S(e){return e.replaceAll("&","&").replaceAll('"',""").replaceAll("<","<").replaceAll(">",">")}const E="picked",L="\x1B[0m";function O(){const e=process.env.NO_COLOR;return e==="1"||e==="true"}function c(e){return t=>O()?t:`${e}${t}${L}`}const x=["debug","info","warn","error","silent"],v={debug:{color:c("\x1B[2m"),log:console.debug,enabled:!1},info:{color:c("\x1B[36m"),log:console.log,enabled:!0},warn:{color:c("\x1B[33m"),log:console.warn,enabled:!0},error:{color:c("\x1B[31m"),log:console.error,enabled:!0},silent:{log:()=>{},enabled:!1}};function H(e,t){const r=new Date().toLocaleTimeString(),n=t?`${E}:${t}`:E;return`${r} [${n}] ${e}`}function g(e,t,r,n){if(!e.enabled)return;const o=H(t,n);e.log(e.color?e.color(o):o),r!==void 0&&e.log(r)}function p(e){const t=v[e],r=new Set;return Object.assign((n,o,i)=>{g(t,n,o,i)},{once(n,o,i){!t.enabled||r.has(n)||(r.add(n),g(t,n,o,i))}})}function $(e){const t=x.indexOf(e);if(t===-1){g(v.error,`invalid log level: ${e}`);return}for(const[r,n]of x.entries())v[n].enabled=r>=t}const s=c("\x1B[34m"),_=c("\x1B[36m");function C(){const e=[` ${s("_")} ${_("_")} _ _ _`,`${s("(_)")} ${_("(_)")} _ __(_)__| |_____ __| |`,` ${s("_")} ${s("_")} | '_ \\ / _| / / -_) _\` |`,`${s("(_)")} ${s("(_)")} | .__/_\\__|_\\_\\___\\__,_|`,` |_|
|
|
859
859
|
`];console.log(e.join(`
|
|
860
860
|
`))}const l={banner:C,debug:p("debug"),info:p("info"),warn:p("warn"),error:p("error"),setLevel:$};function Y(e){return(t,r,n)=>{if(t.method!=="GET"){n();return}const i=(t.url??"").split("?")[0];if(i!=="/"&&i!=="/index.html"){n();return}const a=e();r.setHeader("Content-Type","text/html"),r.statusCode=200,r.end(a)}}function B(e){if(e.length===0)return;const t=Math.max(4,...e.map(a=>a.name.length)),r=Math.max(2,...e.map(a=>a.id.length)),n=` ${"Name".padEnd(t)} ${"ID".padEnd(r)} Status Weight Ver`,o=` ${"─".repeat(t)} ${"─".repeat(r)} ──────── ────── ───`,i=e.map(a=>{const d=a.enabled?"\x1B[32m enabled\x1B[0m":"\x1B[2mdisabled\x1B[0m",u=`${a.weight.toString()}%`.padStart(6),f=`v${a.version.toString()}`;return` ${a.name.padEnd(t)} ${a.id.padEnd(r)} ${d} ${u} ${f}`});console.log([""," Features:","",n,o,...i,""].join(`
|
|
861
|
-
`))}function F(e){try{const t=new URL(e).hostname;return t==="localhost"||t==="127.0.0.1"||t==="::1"}catch{return!1}}function P(e){return new Promise(t=>{setTimeout(t,e)})}async function z(e,t,r){const n=await m.fetchProject(e,t,{headers:r});if(n||!F(e))return n;for(let o=1;o<=T;o++){l.info(`local API not ready, retrying in ${(k/1e3).toString()}s (${o.toString()}/${T.toString()})`),await P(k);const i=await m.fetchProject(e,t,{headers:r});if(i)return i}return null}function N(){return"0.0.
|
|
861
|
+
`))}function F(e){try{const t=new URL(e).hostname;return t==="localhost"||t==="127.0.0.1"||t==="::1"}catch{return!1}}function P(e){return new Promise(t=>{setTimeout(t,e)})}async function z(e,t,r){const n=await m.fetchProject(e,t,{headers:r});if(n||!F(e))return n;for(let o=1;o<=T;o++){l.info(`local API not ready, retrying in ${(k/1e3).toString()}s (${o.toString()}/${T.toString()})`),await P(k);const i=await m.fetchProject(e,t,{headers:r});if(i)return i}return null}function N(){return"0.0.49"}const A="https://api.picked.app",j="__PICKED_PROJECT_CONFIG__",T=5,k=2e3;function G(e){const t=e.apiUrl??A;let r=[];return{name:"picked",config:async()=>{l.banner(),l.info(`fetching project config for "${e.projectId}"`),t!==A&&l.warn(`using custom API URL: ${t}`);const n=m.createClientHeaders("vite-plugin",N()),o=performance.now(),i=await z(t,e.projectId,n),a=(performance.now()-o).toFixed(0);if(!i){l.warn(`failed to fetch project config for "${e.projectId}" (${a}ms)`);return}r=i.features;const d=i.features.length,u=i.features.filter(U=>U.enabled).length,f=JSON.stringify(i).length;return l.info(`fetched ${d.toString()} features (${u.toString()} enabled) for "${e.projectId}" in ${a}ms`),B(i.features),l.debug(`config size: ${f.toString()} bytes`),{define:{[j]:JSON.stringify(i)}}},configureServer(n){if(e.disableLauncher)return;n.middlewares.use(Y(()=>b(r)));const o=n.printUrls.bind(n);n.printUrls=()=>{const i=n.resolvedUrls?.local[0];if(i){const a=i.replace(/:(?<port>\d+)\//,(d,u)=>`:\x1B[1m${u}\x1B[22m/`);console.log(` \x1B[32m➜\x1B[0m \x1B[1mPicked\x1B[22m: \x1B[36m${a}\x1B[0m`)}o()}},generateBundle(){e.disableLauncher||this.emitFile({type:"asset",fileName:"index.html",source:b(r)})}}}exports.picked=G;
|
package/dist/esm/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@picked/vite-plugin-picked",
|
|
3
3
|
"description": "Vite plugin for build-time config injection",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.49",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"@picked/client": "0.0.
|
|
6
|
+
"@picked/client": "0.0.49"
|
|
7
7
|
},
|
|
8
8
|
"devDependencies": {
|
|
9
9
|
"@repo/eslint-config": "workspace:*",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"dev": "vite build --watch",
|
|
57
57
|
"jscpd": "jscpd src",
|
|
58
58
|
"knip": "knip",
|
|
59
|
-
"lint": "eslint .",
|
|
59
|
+
"lint": "if [ \"$AGENT\" = \"true\" ]; then echo \"[AGENT HINT] Prefer running lint on specific files from the repo root: node scripts/lint-files.js <files>\"; fi && eslint .",
|
|
60
60
|
"lint-files": "eslint",
|
|
61
61
|
"lint:format": "eslint . --fix",
|
|
62
62
|
"lint:report": "eslint . -o './.reports/eslint.json' -f json || true",
|