@picked/vite-plugin-picked 0.0.1-dev.1787019239195 → 0.0.1-dev.1787537193674
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 +15 -15
- package/dist/esm/index.js +282 -188
- package/dist/types/index.d.ts +6 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/telemetry.d.ts +44 -0
- package/dist/types/telemetry.d.ts.map +1 -0
- 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"}
|
|
@@ -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/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.1787537193674",
|
|
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.1787537193674",
|
|
7
|
+
"@picked/config": "0.0.1-dev.1787537193674",
|
|
8
|
+
"@picked/delivery-api-client": "0.0.1-dev.1787537193674",
|
|
9
|
+
"@picked/telemetry": "0.0.1-dev.1787537193674",
|
|
10
|
+
"@picked/typegen": "0.0.1-dev.1787537193674"
|
|
10
11
|
},
|
|
11
12
|
"devDependencies": {
|
|
12
13
|
"@repo/eslint-config": "workspace:*",
|