@picked/vite-plugin-picked 0.0.1-dev.1787019239195 → 0.0.1-dev.1787543060859
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/.tsbuildinfo +1 -1
- package/dist/cjs/index.js +16 -17
- package/dist/esm/index.js +300 -192
- package/dist/types/index.d.ts +6 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/launcher.d.ts +8 -0
- package/dist/types/launcher.d.ts.map +1 -1
- package/dist/types/telemetry.d.ts +44 -0
- package/dist/types/telemetry.d.ts.map +1 -0
- package/dist/types/util.d.ts +19 -3
- package/dist/types/util.d.ts.map +1 -1
- package/package.json +6 -5
package/dist/types/index.d.ts
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import type { Plugin } from 'vite';
|
|
2
2
|
export interface PickedPluginOptions {
|
|
3
|
+
/**
|
|
4
|
+
* Send anonymous telemetry about the time this plugin adds to your build. Off unless
|
|
5
|
+
* set here, by `telemetry` in `picked.config`, or by `PICKED_TELEMETRY=1`. This option
|
|
6
|
+
* beats both; `PICKED_TELEMETRY=0` and `DO_NOT_TRACK=1` force it off.
|
|
7
|
+
*/
|
|
8
|
+
telemetry?: boolean;
|
|
3
9
|
/**
|
|
4
10
|
* @deprecated Set `projectId` in `picked.config` instead, which the CLI and the type
|
|
5
11
|
* generator read from too. Still honoured when `picked.config` omits it, and a future
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAqB,MAAM,EAAU,MAAM,MAAM,CAAA;AAsU7D,MAAM,WAAW,mBAAmB;IAClC;;;;OAIG;IACH,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,qFAAqF;IACrF,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,0FAA0F;IAC1F,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB;;;;;;;OAOG;IACH,IAAI,CAAC,EAAE,QAAQ,GAAG,KAAK,CAAA;CACxB;AA+BD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,MAAM,CAAC,OAAO,GAAE,mBAAwB,GAAG,MAAM,CA4RhE"}
|
package/dist/types/launcher.d.ts
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
/** @file Dev launcher page: lists the project's feature flags and previews an experience. */
|
|
2
2
|
import type { ProjectConfigFeature } from '@picked/delivery-api-client';
|
|
3
|
+
/**
|
|
4
|
+
* Renders the dev launcher page: a URL box, the project's feature flags with an
|
|
5
|
+
* override picker each, and the script that assembles them into a preview URL.
|
|
6
|
+
*
|
|
7
|
+
* @param {ReadonlyArray<ProjectConfigFeature>} features - The project's features, in wire order.
|
|
8
|
+
* @returns {string} The complete HTML document.
|
|
9
|
+
* @example getLauncherHtml(config.features)
|
|
10
|
+
*/
|
|
3
11
|
export declare function getLauncherHtml(features: ReadonlyArray<ProjectConfigFeature>): string;
|
|
4
12
|
//# sourceMappingURL=launcher.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"launcher.d.ts","sourceRoot":"","sources":["../../src/launcher.ts"],"names":[],"mappings":"AAAA,6FAA6F;AAC7F,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAA;
|
|
1
|
+
{"version":3,"file":"launcher.d.ts","sourceRoot":"","sources":["../../src/launcher.ts"],"names":[],"mappings":"AAAA,6FAA6F;AAC7F,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAA;AAkDvE;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,aAAa,CAAC,oBAAoB,CAAC,GAAG,MAAM,CAgcrF"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { Plugin } from 'vite';
|
|
2
|
+
import { type SpanAttributes } from '@picked/telemetry';
|
|
3
|
+
/** Collects hook timings and sends them when the build ends. */
|
|
4
|
+
export interface BuildTelemetry {
|
|
5
|
+
/** Records one hook invocation. */
|
|
6
|
+
record: (hook: string, durationMs: number) => void;
|
|
7
|
+
/** Sends everything collected. Always resolves. */
|
|
8
|
+
flush: (attributes: SpanAttributes) => Promise<void>;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Creates a telemetry collector for one build.
|
|
12
|
+
*
|
|
13
|
+
* @param {string} traceId - Trace all of this build's spans belong to.
|
|
14
|
+
* @returns {BuildTelemetry} A collector bound to that trace.
|
|
15
|
+
* @example const telemetry = createBuildTelemetry(createTraceId())
|
|
16
|
+
*/
|
|
17
|
+
export declare function createBuildTelemetry(traceId?: string): BuildTelemetry;
|
|
18
|
+
/**
|
|
19
|
+
* Wraps a hook so its duration is recorded, preserving its return value.
|
|
20
|
+
*
|
|
21
|
+
* @template Args - The hook's argument tuple.
|
|
22
|
+
* @template Result - What the hook returns.
|
|
23
|
+
* @param {string} hook - The hook's name.
|
|
24
|
+
* @param {(...args: Args) => Result} handler - The original hook.
|
|
25
|
+
* @param {BuildTelemetry} telemetry - Where to record the timing.
|
|
26
|
+
* @returns {(...args: Args) => Result} The wrapped hook.
|
|
27
|
+
* @example instrumentHook('config', original, telemetry)
|
|
28
|
+
*/
|
|
29
|
+
export declare function instrumentHook<Args extends unknown[], Result>(hook: string, handler: (...args: Args) => Result, telemetry: BuildTelemetry): (...args: Args) => Result;
|
|
30
|
+
/**
|
|
31
|
+
* Wraps every hook on the plugin so its duration is recorded.
|
|
32
|
+
*
|
|
33
|
+
* Applied to the whole object, so a hook added later is covered automatically.
|
|
34
|
+
* Vite accepts a hook as a function or as `{ order, handler }`, and both shapes
|
|
35
|
+
* are handled. Hooks are mutated in place and never bound, so Rollup's plugin
|
|
36
|
+
* context reaches them as `this`.
|
|
37
|
+
*
|
|
38
|
+
* @param {BuildTelemetry | null} telemetry - Collector, or `null` when telemetry is off.
|
|
39
|
+
* @param {Plugin} plugin - The plugin object to wrap.
|
|
40
|
+
* @returns {Plugin} The same plugin, with its hooks instrumented.
|
|
41
|
+
* @example instrumentPlugin(telemetry, { name: 'picked', config: async () => {} })
|
|
42
|
+
*/
|
|
43
|
+
export declare function instrumentPlugin(telemetry: BuildTelemetry | null, plugin: Plugin): Plugin;
|
|
44
|
+
//# sourceMappingURL=telemetry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"telemetry.d.ts","sourceRoot":"","sources":["../../src/telemetry.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAClC,OAAO,EAKL,KAAK,cAAc,EAEpB,MAAM,mBAAmB,CAAA;AAc1B,gEAAgE;AAChE,MAAM,WAAW,cAAc;IAC7B,mCAAmC;IACnC,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,KAAK,IAAI,CAAA;IAClD,mDAAmD;IACnD,KAAK,EAAE,CAAC,UAAU,EAAE,cAAc,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;CACrD;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,SAAkB,GAAG,cAAc,CAgE9E;AAaD;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAAC,IAAI,SAAS,OAAO,EAAE,EAAE,MAAM,EAC3D,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,MAAM,EAClC,SAAS,EAAE,cAAc,GACxB,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,MAAM,CA4B3B;AAgBD;;;;;;;;;;;;GAYG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,cAAc,GAAG,IAAI,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAwBzF"}
|
package/dist/types/util.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @file Shared utilities for the Picked Vite plugin
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* @file Shared utilities for the Picked Vite plugin: a defensive helper for API
|
|
3
|
+
* entity arrays that may be omitted at runtime despite being typed as required,
|
|
4
|
+
* and the console rendering of a feature's traffic split.
|
|
5
5
|
*/
|
|
6
|
+
import type { ProjectConfigFeature } from '@picked/delivery-api-client';
|
|
6
7
|
/**
|
|
7
8
|
* Safely coerce a value to an array, returning an empty array for nullish inputs.
|
|
8
9
|
* Needed because the API response may omit entity arrays at runtime even though
|
|
@@ -15,4 +16,19 @@
|
|
|
15
16
|
* toArray(undefined) // []
|
|
16
17
|
*/
|
|
17
18
|
export declare function toArray<T>(value: ReadonlyArray<T> | null | undefined): ReadonlyArray<T>;
|
|
19
|
+
/**
|
|
20
|
+
* Renders a feature's traffic split for the dev-server console.
|
|
21
|
+
*
|
|
22
|
+
* A boolean feature reports `weight`, which is already a percentage. A text feature
|
|
23
|
+
* reports each arm against the total of the arms, since an arm's `weight` is a share
|
|
24
|
+
* relative to its siblings: `1` against `1, 2` is a quarter of the traffic.
|
|
25
|
+
*
|
|
26
|
+
* A feature whose arms are absent or all weigh zero reports its own weight.
|
|
27
|
+
*
|
|
28
|
+
* @param {ProjectConfigFeature} feature - The feature to describe.
|
|
29
|
+
* @returns {string} The split, as a percentage or a comma-separated list of arms.
|
|
30
|
+
* @example
|
|
31
|
+
* formatFeatureSplit({ valueType: 'text', variants: [{ key: 'a', value: 'a', weight: 1 }] })
|
|
32
|
+
*/
|
|
33
|
+
export declare function formatFeatureSplit(feature: ProjectConfigFeature): string;
|
|
18
34
|
//# sourceMappingURL=util.d.ts.map
|
package/dist/types/util.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../src/util.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../src/util.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAA;AAEvE;;;;;;;;;;GAUG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,IAAI,GAAG,SAAS,GAAG,aAAa,CAAC,CAAC,CAAC,CAEvF;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,oBAAoB,GAAG,MAAM,CAcxE"}
|
package/package.json
CHANGED
|
@@ -1,12 +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.1-dev.
|
|
4
|
+
"version": "0.0.1-dev.1787543060859",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"@picked/client": "0.0.1-dev.
|
|
7
|
-
"@picked/config": "0.0.1-dev.
|
|
8
|
-
"@picked/delivery-api-client": "0.0.1-dev.
|
|
9
|
-
"@picked/
|
|
6
|
+
"@picked/client": "0.0.1-dev.1787543060859",
|
|
7
|
+
"@picked/config": "0.0.1-dev.1787543060859",
|
|
8
|
+
"@picked/delivery-api-client": "0.0.1-dev.1787543060859",
|
|
9
|
+
"@picked/telemetry": "0.0.1-dev.1787543060859",
|
|
10
|
+
"@picked/typegen": "0.0.1-dev.1787543060859"
|
|
10
11
|
},
|
|
11
12
|
"devDependencies": {
|
|
12
13
|
"@repo/eslint-config": "workspace:*",
|