@picked/vite-plugin-picked 0.0.1-dev.1772152395613 → 0.0.1-dev.1772165084341

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
@@ -1,3 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("@picked/client/plugins/dynamic-experiences"),g="picked",L="\x1B[0m";function p(){const n=process.env.NO_COLOR;return n==="1"||n==="true"}function a(n){return e=>p()?e:`${n}${e}${L}`}const $=["debug","info","warn","error","silent"],_={debug:{color:a("\x1B[2m"),log:console.debug,enabled:!1},info:{color:a("\x1B[36m"),log:console.log,enabled:!0},warn:{color:a("\x1B[33m"),log:console.warn,enabled:!0},error:{color:a("\x1B[31m"),log:console.error,enabled:!0},silent:{log:()=>{},enabled:!1}};function y(n,e){const o=new Date().toLocaleTimeString(),t=e?`${g}:${e}`:g;return`${o} [${t}] ${n}`}function u(n,e,o,t){if(!n.enabled)return;const r=y(e,t);n.log(n.color?n.color(r):r),o!==void 0&&n.log(o)}function l(n){const e=_[n],o=new Set;return Object.assign((t,r,f)=>{u(e,t,r,f)},{once(t,r,f){!e.enabled||o.has(t)||(o.add(t),u(e,t,r,f))}})}function O(n){const e=$.indexOf(n);if(e===-1){u(_.error,`invalid log level: ${n}`);return}for(const[o,t]of $.entries())_[t].enabled=o>=e}const s=a("\x1B[34m"),c=a("\x1B[36m");function R(){const n=[` ${s("_")} ${c("_")} ${c("_ _ _")}`,`${s("(_)")} ${c("(_)")} ${c("_ __(_)__| |_____ __| |")}`,` ${s("_")} ${s("_")} ${c("| '_ \\ / _| / / -_) _` |")}`,`${s("(_)")} ${s("(_)")} ${c("| .__/_\\__|_\\_\\___\\__,_|")}`,` ${c("|_|")}
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const $=require("@picked/client/plugins/dynamic-experiences"),m="picked",x="\x1B[0m";function L(){const n=process.env.NO_COLOR;return n==="1"||n==="true"}function l(n){return e=>L()?e:`${n}${e}${x}`}const b=["debug","info","warn","error","silent"],_={debug:{color:l("\x1B[2m"),log:console.debug,enabled:!1},info:{color:l("\x1B[36m"),log:console.log,enabled:!0},warn:{color:l("\x1B[33m"),log:console.warn,enabled:!0},error:{color:l("\x1B[31m"),log:console.error,enabled:!0},silent:{log:()=>{},enabled:!1}};function y(n,e){const o=new Date().toLocaleTimeString(),t=e?`${m}:${e}`:m;return`${o} [${t}] ${n}`}function g(n,e,o,t){if(!n.enabled)return;const r=y(e,t);n.log(n.color?n.color(r):r),o!==void 0&&n.log(o)}function d(n){const e=_[n],o=new Set;return Object.assign((t,r,i)=>{g(e,t,r,i)},{once(t,r,i){!e.enabled||o.has(t)||(o.add(t),g(e,t,r,i))}})}function I(n){const e=b.indexOf(n);if(e===-1){g(_.error,`invalid log level: ${n}`);return}for(const[o,t]of b.entries())_[t].enabled=o>=e}const s=l("\x1B[34m"),h=l("\x1B[36m");function O(){const n=[` ${s("_")} ${h("_")} _ _ _`,`${s("(_)")} ${h("(_)")} _ __(_)__| |_____ __| |`,` ${s("_")} ${s("_")} | '_ \\ / _| / / -_) _\` |`,`${s("(_)")} ${s("(_)")} | .__/_\\__|_\\_\\___\\__,_|`,` |_|
2
2
  `];console.log(n.join(`
3
- `))}const i={banner:R,debug:l("debug"),info:l("info"),warn:l("warn"),error:l("error"),setLevel:O};function I(n){try{const e=new URL(n).hostname;return e==="localhost"||e==="127.0.0.1"||e==="::1"}catch{return!1}}function P(n){return new Promise(e=>{setTimeout(e,n)})}async function T(n,e){const o=await d.fetchProject(n,e);if(o||!I(n))return o;for(let t=1;t<=m;t++){i.info(`local API not ready, retrying in ${(h/1e3).toString()}s (${t.toString()}/${m.toString()})`),await P(h);const r=await d.fetchProject(n,e);if(r)return r}return null}const b="https://api.picked.app",j="__PICKED_PROJECT_CONFIG__",m=5,h=2e3;function x(n){const e=n.apiUrl??b;return{name:"picked",config:async()=>{i.banner(),i.info(`fetching project config for "${n.projectId}"`),e!==b&&i.warn(`using custom API URL: ${e}`);const o=performance.now(),t=await T(e,n.projectId),r=(performance.now()-o).toFixed(0);if(!t){i.warn(`failed to fetch project config for "${n.projectId}" (${r}ms)`);return}const f=t.features.length,w=t.features.filter(E=>E.enabled).length,S=JSON.stringify(t).length;return i.info(`fetched ${f.toString()} features (${w.toString()} enabled) for "${n.projectId}" in ${r}ms`,void 0,"fetch"),i.debug(`config size: ${S.toString()} bytes`),{define:{[j]:JSON.stringify(t)}}}}}exports.picked=x;
3
+ `))}const a={banner:O,debug:d("debug"),info:d("info"),warn:d("warn"),error:d("error"),setLevel:I};function R(n){if(n.length===0)return;const e=Math.max(4,...n.map(c=>c.name.length)),o=Math.max(2,...n.map(c=>c.id.length)),t=` ${"Name".padEnd(e)} ${"ID".padEnd(o)} Status Weight Ver`,r=` ${"─".repeat(e)} ${"─".repeat(o)} ──────── ────── ───`,i=n.map(c=>{const f=c.enabled?"\x1B[32m enabled\x1B[0m":"\x1B[2mdisabled\x1B[0m",u=`${c.weight.toString()}%`.padStart(6),E=`v${c.version.toString()}`;return` ${c.name.padEnd(e)} ${c.id.padEnd(o)} ${f} ${u} ${E}`});console.log([""," Features:","",t,r,...i,""].join(`
4
+ `))}function T(n){try{const e=new URL(n).hostname;return e==="localhost"||e==="127.0.0.1"||e==="::1"}catch{return!1}}function j(n){return new Promise(e=>{setTimeout(e,n)})}async function v(n,e){const o=await $.fetchProject(n,e);if(o||!T(n))return o;for(let t=1;t<=S;t++){a.info(`local API not ready, retrying in ${(w/1e3).toString()}s (${t.toString()}/${S.toString()})`),await j(w);const r=await $.fetchProject(n,e);if(r)return r}return null}const p="https://api.picked.app",B="__PICKED_PROJECT_CONFIG__",S=5,w=2e3;function P(n){const e=n.apiUrl??p;return{name:"picked",config:async()=>{a.banner(),a.info(`fetching project config for "${n.projectId}"`),e!==p&&a.warn(`using custom API URL: ${e}`);const o=performance.now(),t=await v(e,n.projectId),r=(performance.now()-o).toFixed(0);if(!t){a.warn(`failed to fetch project config for "${n.projectId}" (${r}ms)`);return}const i=t.features.length,c=t.features.filter(u=>u.enabled).length,f=JSON.stringify(t).length;return a.info(`fetched ${i.toString()} features (${c.toString()} enabled) for "${n.projectId}" in ${r}ms`),R(t.features),a.debug(`config size: ${f.toString()} bytes`),{define:{[B]:JSON.stringify(t)}}}}}exports.picked=P;
package/dist/esm/index.js CHANGED
@@ -1,30 +1,30 @@
1
- import { fetchProject as g } from "@picked/client/plugins/dynamic-experiences";
2
- const d = "picked", S = "\x1B[0m";
3
- function p() {
1
+ import { fetchProject as $ } from "@picked/client/plugins/dynamic-experiences";
2
+ const m = "picked", x = "\x1B[0m";
3
+ function L() {
4
4
  const n = process.env.NO_COLOR;
5
5
  return n === "1" || n === "true";
6
6
  }
7
- function f(n) {
8
- return (e) => p() ? e : `${n}${e}${S}`;
7
+ function l(n) {
8
+ return (e) => L() ? e : `${n}${e}${x}`;
9
9
  }
10
- const $ = ["debug", "info", "warn", "error", "silent"], _ = {
10
+ const b = ["debug", "info", "warn", "error", "silent"], u = {
11
11
  debug: {
12
- color: f("\x1B[2m"),
12
+ color: l("\x1B[2m"),
13
13
  log: console.debug,
14
14
  enabled: !1
15
15
  },
16
16
  info: {
17
- color: f("\x1B[36m"),
17
+ color: l("\x1B[36m"),
18
18
  log: console.log,
19
19
  enabled: !0
20
20
  },
21
21
  warn: {
22
- color: f("\x1B[33m"),
22
+ color: l("\x1B[33m"),
23
23
  log: console.warn,
24
24
  enabled: !0
25
25
  },
26
26
  error: {
27
- color: f("\x1B[31m"),
27
+ color: l("\x1B[31m"),
28
28
  log: console.error,
29
29
  enabled: !0
30
30
  },
@@ -34,59 +34,69 @@ const $ = ["debug", "info", "warn", "error", "silent"], _ = {
34
34
  enabled: !1
35
35
  }
36
36
  };
37
- function R(n, e) {
38
- const t = (/* @__PURE__ */ new Date()).toLocaleTimeString(), o = e ? `${d}:${e}` : d;
39
- return `${t} [${o}] ${n}`;
37
+ function I(n, e) {
38
+ const o = (/* @__PURE__ */ new Date()).toLocaleTimeString(), t = e ? `${m}:${e}` : m;
39
+ return `${o} [${t}] ${n}`;
40
40
  }
41
- function u(n, e, t, o) {
41
+ function g(n, e, o, t) {
42
42
  if (!n.enabled)
43
43
  return;
44
- const r = R(e, o);
45
- n.log(n.color ? n.color(r) : r), t !== void 0 && n.log(t);
44
+ const r = I(e, t);
45
+ n.log(n.color ? n.color(r) : r), o !== void 0 && n.log(o);
46
46
  }
47
- function l(n) {
48
- const e = _[n], t = /* @__PURE__ */ new Set();
47
+ function d(n) {
48
+ const e = u[n], o = /* @__PURE__ */ new Set();
49
49
  return Object.assign(
50
- (o, r, a) => {
51
- u(e, o, r, a);
50
+ (t, r, c) => {
51
+ g(e, t, r, c);
52
52
  },
53
53
  {
54
- once(o, r, a) {
55
- !e.enabled || t.has(o) || (t.add(o), u(e, o, r, a));
54
+ once(t, r, c) {
55
+ !e.enabled || o.has(t) || (o.add(t), g(e, t, r, c));
56
56
  }
57
57
  }
58
58
  );
59
59
  }
60
- function y(n) {
61
- const e = $.indexOf(n);
60
+ function R(n) {
61
+ const e = b.indexOf(n);
62
62
  if (e === -1) {
63
- u(_.error, `invalid log level: ${n}`);
63
+ g(u.error, `invalid log level: ${n}`);
64
64
  return;
65
65
  }
66
- for (const [t, o] of $.entries())
67
- _[o].enabled = t >= e;
66
+ for (const [o, t] of b.entries())
67
+ u[t].enabled = o >= e;
68
68
  }
69
- const s = f("\x1B[34m"), c = f("\x1B[36m");
70
- function I() {
69
+ const s = l("\x1B[34m"), h = l("\x1B[36m");
70
+ function y() {
71
71
  const n = [
72
- ` ${s("_")} ${c("_")} ${c("_ _ _")}`,
73
- `${s("(_)")} ${c("(_)")} ${c("_ __(_)__| |_____ __| |")}`,
74
- ` ${s("_")} ${s("_")} ${c("| '_ \\ / _| / / -_) _` |")}`,
75
- `${s("(_)")} ${s("(_)")} ${c("| .__/_\\__|_\\_\\___\\__,_|")}`,
76
- ` ${c("|_|")}
72
+ ` ${s("_")} ${h("_")} _ _ _`,
73
+ `${s("(_)")} ${h("(_)")} _ __(_)__| |_____ __| |`,
74
+ ` ${s("_")} ${s("_")} | '_ \\ / _| / / -_) _\` |`,
75
+ `${s("(_)")} ${s("(_)")} | .__/_\\__|_\\_\\___\\__,_|`,
76
+ ` |_|
77
77
  `
78
78
  ];
79
79
  console.log(n.join(`
80
80
  `));
81
81
  }
82
- const i = {
83
- banner: I,
84
- debug: l("debug"),
85
- info: l("info"),
86
- warn: l("warn"),
87
- error: l("error"),
88
- setLevel: y
82
+ const a = {
83
+ banner: y,
84
+ debug: d("debug"),
85
+ info: d("info"),
86
+ warn: d("warn"),
87
+ error: d("error"),
88
+ setLevel: R
89
89
  };
90
+ function B(n) {
91
+ if (n.length === 0)
92
+ return;
93
+ const e = Math.max(4, ...n.map((i) => i.name.length)), o = Math.max(2, ...n.map((i) => i.id.length)), t = ` ${"Name".padEnd(e)} ${"ID".padEnd(o)} Status Weight Ver`, r = ` ${"─".repeat(e)} ${"─".repeat(o)} ──────── ────── ───`, c = n.map((i) => {
94
+ const f = i.enabled ? "\x1B[32m enabled\x1B[0m" : "\x1B[2mdisabled\x1B[0m", _ = `${i.weight.toString()}%`.padStart(6), S = `v${i.version.toString()}`;
95
+ return ` ${i.name.padEnd(e)} ${i.id.padEnd(o)} ${f} ${_} ${S}`;
96
+ });
97
+ console.log(["", " Features:", "", t, r, ...c, ""].join(`
98
+ `));
99
+ }
90
100
  function O(n) {
91
101
  try {
92
102
  const e = new URL(n).hostname;
@@ -95,50 +105,48 @@ function O(n) {
95
105
  return !1;
96
106
  }
97
107
  }
98
- function x(n) {
108
+ function T(n) {
99
109
  return new Promise((e) => {
100
110
  setTimeout(e, n);
101
111
  });
102
112
  }
103
- async function C(n, e) {
104
- const t = await g(n, e);
105
- if (t || !O(n))
106
- return t;
107
- for (let o = 1; o <= m; o++) {
108
- i.info(
109
- `local API not ready, retrying in ${(w / 1e3).toString()}s (${o.toString()}/${m.toString()})`
110
- ), await x(w);
111
- const r = await g(n, e);
113
+ async function v(n, e) {
114
+ const o = await $(n, e);
115
+ if (o || !O(n))
116
+ return o;
117
+ for (let t = 1; t <= w; t++) {
118
+ a.info(
119
+ `local API not ready, retrying in ${(E / 1e3).toString()}s (${t.toString()}/${w.toString()})`
120
+ ), await T(E);
121
+ const r = await $(n, e);
112
122
  if (r)
113
123
  return r;
114
124
  }
115
125
  return null;
116
126
  }
117
- const b = "https://api.picked.app", T = "__PICKED_PROJECT_CONFIG__", m = 5, w = 2e3;
118
- function j(n) {
119
- const e = n.apiUrl ?? b;
127
+ const p = "https://api.picked.app", C = "__PICKED_PROJECT_CONFIG__", w = 5, E = 2e3;
128
+ function P(n) {
129
+ const e = n.apiUrl ?? p;
120
130
  return {
121
131
  name: "picked",
122
132
  config: async () => {
123
- i.banner(), i.info(`fetching project config for "${n.projectId}"`), e !== b && i.warn(`using custom API URL: ${e}`);
124
- const t = performance.now(), o = await C(e, n.projectId), r = (performance.now() - t).toFixed(0);
125
- if (!o) {
126
- i.warn(`failed to fetch project config for "${n.projectId}" (${r}ms)`);
133
+ a.banner(), a.info(`fetching project config for "${n.projectId}"`), e !== p && a.warn(`using custom API URL: ${e}`);
134
+ const o = performance.now(), t = await v(e, n.projectId), r = (performance.now() - o).toFixed(0);
135
+ if (!t) {
136
+ a.warn(`failed to fetch project config for "${n.projectId}" (${r}ms)`);
127
137
  return;
128
138
  }
129
- const a = o.features.length, h = o.features.filter((E) => E.enabled).length, L = JSON.stringify(o).length;
130
- return i.info(
131
- `fetched ${a.toString()} features (${h.toString()} enabled) for "${n.projectId}" in ${r}ms`,
132
- void 0,
133
- "fetch"
134
- ), i.debug(`config size: ${L.toString()} bytes`), {
139
+ const c = t.features.length, i = t.features.filter((_) => _.enabled).length, f = JSON.stringify(t).length;
140
+ return a.info(
141
+ `fetched ${c.toString()} features (${i.toString()} enabled) for "${n.projectId}" in ${r}ms`
142
+ ), B(t.features), a.debug(`config size: ${f.toString()} bytes`), {
135
143
  define: {
136
- [T]: JSON.stringify(o)
144
+ [C]: JSON.stringify(t)
137
145
  }
138
146
  };
139
147
  }
140
148
  };
141
149
  }
142
150
  export {
143
- j as picked
151
+ P as picked
144
152
  };
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AA6ClC,MAAM,WAAW,mBAAmB;IAClC,4BAA4B;IAC5B,SAAS,EAAE,MAAM,CAAA;IACjB,0DAA0D;IAC1D,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,MAAM,CAAC,OAAO,EAAE,mBAAmB,GAAG,MAAM,CAwC3D"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAoElC,MAAM,WAAW,mBAAmB;IAClC,4BAA4B;IAC5B,SAAS,EAAE,MAAM,CAAA;IACjB,0DAA0D;IAC1D,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,MAAM,CAAC,OAAO,EAAE,mBAAmB,GAAG,MAAM,CAuC3D"}
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.1-dev.1772152395613",
4
+ "version": "0.0.1-dev.1772165084341",
5
5
  "dependencies": {
6
- "@picked/client": "0.0.1-dev.1772152395613"
6
+ "@picked/client": "0.0.1-dev.1772165084341"
7
7
  },
8
8
  "devDependencies": {
9
9
  "@repo/eslint-config": "workspace:*",