@picked/vite-plugin-picked 0.0.1-dev.1786072899095 → 0.0.1-dev.1786601464574
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/client.d.ts +26 -0
- package/dist/.tsbuildinfo +1 -1
- package/dist/cjs/index.js +29 -17
- package/dist/esm/index.js +309 -200
- package/dist/types/index.d.ts +16 -6
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/launcher.d.ts +2 -1
- package/dist/types/launcher.d.ts.map +1 -1
- package/dist/types/prefetch.d.ts +3 -1
- package/dist/types/prefetch.d.ts.map +1 -1
- package/dist/types/virtual-module/api.d.ts +17 -0
- package/dist/types/virtual-module/api.d.ts.map +1 -0
- package/dist/types/virtual-module/build.d.ts.map +1 -1
- package/dist/types/virtual-module/dev.d.ts +17 -4
- package/dist/types/virtual-module/dev.d.ts.map +1 -1
- package/package.json +13 -3
package/dist/types/index.d.ts
CHANGED
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
import type { Plugin } from 'vite';
|
|
2
2
|
export interface PickedPluginOptions {
|
|
3
|
-
/** The Picked project ID. */
|
|
4
|
-
projectId: string;
|
|
5
|
-
/** Custom API URL (defaults to https://api.picked.app). */
|
|
6
|
-
apiUrl?: string;
|
|
7
3
|
/** Disable the launcher HTML page (dev server + build output). Defaults to false. */
|
|
8
4
|
disableLauncher?: boolean;
|
|
5
|
+
/** Generate TypeScript types from the workspace schema on dev/build. Defaults to true. */
|
|
6
|
+
generateTypes?: boolean;
|
|
7
|
+
/**
|
|
8
|
+
* Whether this build carries Picked data. Defaults to `'bundle'`.
|
|
9
|
+
*
|
|
10
|
+
* `'bundle'` prefetches the project config and each experience's content, writes `.picked/`, and
|
|
11
|
+
* emits a module that registers itself with the SDK. `'api'` skips the prefetch altogether —
|
|
12
|
+
* no build-time dependency on the Picked API and no `.picked/` directory — and emits a module
|
|
13
|
+
* the SDK's shape guard refuses, which leaves every read on the API path.
|
|
14
|
+
*/
|
|
15
|
+
mode?: 'bundle' | 'api';
|
|
9
16
|
}
|
|
10
17
|
/**
|
|
11
18
|
* Vite plugin that fetches Picked project config + per-experience CMS content at build time
|
|
@@ -18,6 +25,9 @@ export interface PickedPluginOptions {
|
|
|
18
25
|
* Dev mode (`vite serve`) writes nothing to disk; the synthesised virtual module performs
|
|
19
26
|
* runtime API fetches via top-level `await` for project config and per-call for content.
|
|
20
27
|
*
|
|
28
|
+
* Project identity — `projectId` and `apiUrl` — comes from `picked.config.{ts,js,json}` at the
|
|
29
|
+
* project root, which the CLI and the type generator read from the same place.
|
|
30
|
+
*
|
|
21
31
|
* @param {PickedPluginOptions} options - Plugin configuration.
|
|
22
32
|
* @returns {Plugin} A Vite plugin instance.
|
|
23
33
|
* @example
|
|
@@ -26,10 +36,10 @@ export interface PickedPluginOptions {
|
|
|
26
36
|
*
|
|
27
37
|
* export default defineConfig({
|
|
28
38
|
* plugins: [
|
|
29
|
-
* picked(
|
|
39
|
+
* picked()
|
|
30
40
|
* ]
|
|
31
41
|
* })
|
|
32
42
|
* ```
|
|
33
43
|
*/
|
|
34
|
-
export declare function picked(options
|
|
44
|
+
export declare function picked(options?: PickedPluginOptions): Plugin;
|
|
35
45
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -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":"AAcA,OAAO,KAAK,EAAqB,MAAM,EAAU,MAAM,MAAM,CAAA;AAyO7D,MAAM,WAAW,mBAAmB;IAClC,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,CAoQhE"}
|
package/dist/types/launcher.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
/** @file Dev launcher page: lists the project's feature flags and previews an experience. */
|
|
2
|
+
import type { ProjectConfigFeature } from '@picked/delivery-api-client';
|
|
2
3
|
export declare function getLauncherHtml(features: ReadonlyArray<ProjectConfigFeature>): string;
|
|
3
4
|
//# sourceMappingURL=launcher.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"launcher.d.ts","sourceRoot":"","sources":["../../src/launcher.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,
|
|
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;AAEvE,wBAAgB,eAAe,CAAC,QAAQ,EAAE,aAAa,CAAC,oBAAoB,CAAC,GAAG,MAAM,CA+brF"}
|
package/dist/types/prefetch.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ProjectConfig } from '@picked/delivery-api-client';
|
|
2
2
|
interface ManifestExperienceEntry {
|
|
3
3
|
id: string;
|
|
4
4
|
fetchedAt: string;
|
|
@@ -44,6 +44,8 @@ interface RunPrefetchOptions {
|
|
|
44
44
|
projectRoot: string;
|
|
45
45
|
/** HTTP headers to forward with every fetch (e.g. `Picked-Client`, `Picked-Version`). */
|
|
46
46
|
headers: Record<string, string>;
|
|
47
|
+
/** Workspace preview token; when set, fetches the draft workspace instead of the live one. */
|
|
48
|
+
previewToken?: string;
|
|
47
49
|
/** When the existing manifest matches the API's versionId+workspaceId, skip per-experience fetches. */
|
|
48
50
|
reuseWhenUnchanged?: boolean;
|
|
49
51
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prefetch.d.ts","sourceRoot":"","sources":["../../src/prefetch.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"prefetch.d.ts","sourceRoot":"","sources":["../../src/prefetch.ts"],"names":[],"mappings":"AAQA,OAAO,EAIL,KAAK,aAAa,EACnB,MAAM,6BAA6B,CAAA;AAepC,UAAU,uBAAuB;IAC/B,EAAE,EAAE,MAAM,CAAA;IACV,SAAS,EAAE,MAAM,CAAA;CAClB;AAED,UAAU,cAAc;IACtB,OAAO,EAAE,MAAM,CAAA;IACf,SAAS,EAAE,MAAM,CAAA;IACjB,gBAAgB,EAAE,MAAM,CAAA;IACxB,WAAW,EAAE,MAAM,CAAA;IACnB,SAAS,EAAE,MAAM,CAAA;IACjB,WAAW,EAAE,uBAAuB,EAAE,CAAA;CACvC;AAED,UAAU,aAAa;IACrB,0CAA0C;IAC1C,SAAS,EAAE,MAAM,CAAA;IACjB,uDAAuD;IACvD,YAAY,EAAE,MAAM,CAAA;IACpB,6DAA6D;IAC7D,iBAAiB,EAAE,MAAM,CAAA;IACzB,sDAAsD;IACtD,cAAc,EAAE,MAAM,CAAA;CACvB;AAED,UAAU,cAAc;IACtB,MAAM,EAAE,aAAa,CAAA;IACrB,QAAQ,EAAE,cAAc,CAAA;IACxB,+DAA+D;IAC/D,sBAAsB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAC/C;AAED;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,MAAM,GAAG,aAAa,CAQvE;AAsFD,UAAU,kBAAkB;IAC1B,MAAM,EAAE,MAAM,CAAA;IACd,SAAS,EAAE,MAAM,CAAA;IACjB,WAAW,EAAE,MAAM,CAAA;IACnB,yFAAyF;IACzF,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC/B,8FAA8F;IAC9F,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,uGAAuG;IACvG,kBAAkB,CAAC,EAAE,OAAO,CAAA;CAC7B;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,WAAW,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,cAAc,CAAC,CAuEtF"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Synthesis for `virtual:picked/data` when the plugin runs with `mode: 'api'`.
|
|
3
|
+
*
|
|
4
|
+
* The module resolves, so an import a consumer wrote by hand still builds. It exports only
|
|
5
|
+
* `manifestMetadata`, so the SDK's shape guard refuses it and every read stays on the API path.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Synthesises the source for the `mode: 'api'` `virtual:picked/data` module.
|
|
9
|
+
*
|
|
10
|
+
* @returns {string} JavaScript source as a string for Vite's `load` hook.
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* const src = apiModeVirtualModuleSource()
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export declare function apiModeVirtualModuleSource(): string;
|
|
17
|
+
//# sourceMappingURL=api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../src/virtual-module/api.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;;;;;GAQG;AACH,wBAAgB,0BAA0B,IAAI,MAAM,CAQnD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../../src/virtual-module/build.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,UAAU,yBAAyB;IACjC,6DAA6D;IAC7D,iBAAiB,EAAE,MAAM,CAAA;IACzB,qEAAqE;IACrE,sBAAsB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC9C,sFAAsF;IACtF,gBAAgB,EAAE;QAChB,IAAI,EAAE,OAAO,CAAA;QACb,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;QACxB,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAA;QAC/B,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;KAC3B,CAAA;CACF;AAED;;;;;;;;;GASG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,yBAAyB,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../../src/virtual-module/build.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,UAAU,yBAAyB;IACjC,6DAA6D;IAC7D,iBAAiB,EAAE,MAAM,CAAA;IACzB,qEAAqE;IACrE,sBAAsB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC9C,sFAAsF;IACtF,gBAAgB,EAAE;QAChB,IAAI,EAAE,OAAO,CAAA;QACb,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;QACxB,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAA;QAC/B,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;KAC3B,CAAA;CACF;AAED;;;;;;;;;GASG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,yBAAyB,GAAG,MAAM,CAoCnF"}
|
|
@@ -1,15 +1,28 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @file Dev-mode synthesis for `virtual:picked/data`.
|
|
3
3
|
*
|
|
4
|
-
* Generates a JavaScript module
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* Generates a JavaScript module exposing the project config the plugin's `config()` hook
|
|
5
|
+
* already fetched, and resolving per-experience content with per-call API requests. The
|
|
6
|
+
* config travels as a literal so module evaluation does not block on a network round trip:
|
|
7
|
+
* the module is reached by a dynamic `import()` from inside the SDK's `onStart` hook, and a
|
|
8
|
+
* top-level `await` there puts the fetch on the start-chain critical path.
|
|
9
|
+
*
|
|
10
|
+
* No filesystem writes; content behaviour matches the customer's runtime API behaviour.
|
|
7
11
|
*/
|
|
12
|
+
import type { ProjectConfig } from '@picked/client/plugins/dynamic-experiences';
|
|
8
13
|
interface DevVirtualModuleOptions {
|
|
9
14
|
/** Absolute API base URL (e.g. `https://api.picked.app`). */
|
|
10
15
|
apiUrl: string;
|
|
11
16
|
/** Picked project ID to fetch. */
|
|
12
17
|
projectId: string;
|
|
18
|
+
/**
|
|
19
|
+
* The config the plugin's `config()` hook fetched, inlined into the module. `null` when
|
|
20
|
+
* that fetch failed, which keeps the runtime fetch so a dev server started before the API
|
|
21
|
+
* was reachable still recovers once it comes up.
|
|
22
|
+
*/
|
|
23
|
+
projectConfig: ProjectConfig | null;
|
|
24
|
+
/** Workspace preview token; when set, fetches the draft workspace instead of the live one. */
|
|
25
|
+
previewToken?: string;
|
|
13
26
|
}
|
|
14
27
|
/**
|
|
15
28
|
* Synthesises the source code for the dev-mode `virtual:picked/data` module.
|
|
@@ -18,7 +31,7 @@ interface DevVirtualModuleOptions {
|
|
|
18
31
|
* @returns {string} JavaScript source as a string for Vite's `load` hook.
|
|
19
32
|
* @example
|
|
20
33
|
* ```typescript
|
|
21
|
-
* const src = devVirtualModuleSource({ apiUrl: 'https://api.picked.app', projectId: 'p_1' })
|
|
34
|
+
* const src = devVirtualModuleSource({ apiUrl: 'https://api.picked.app', projectId: 'p_1', projectConfig })
|
|
22
35
|
* ```
|
|
23
36
|
*/
|
|
24
37
|
export declare function devVirtualModuleSource(options: DevVirtualModuleOptions): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../../../src/virtual-module/dev.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../../../src/virtual-module/dev.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4CAA4C,CAAA;AAE/E,UAAU,uBAAuB;IAC/B,6DAA6D;IAC7D,MAAM,EAAE,MAAM,CAAA;IACd,kCAAkC;IAClC,SAAS,EAAE,MAAM,CAAA;IACjB;;;;OAIG;IACH,aAAa,EAAE,aAAa,GAAG,IAAI,CAAA;IACnC,8FAA8F;IAC9F,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB;AAED;;;;;;;;;GASG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,uBAAuB,GAAG,MAAM,CAuC/E"}
|
package/package.json
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
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.1786601464574",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"@picked/client": "0.0.1-dev.
|
|
6
|
+
"@picked/client": "0.0.1-dev.1786601464574",
|
|
7
|
+
"@picked/config": "0.0.1-dev.1786601464574",
|
|
8
|
+
"@picked/delivery-api-client": "0.0.1-dev.1786601464574",
|
|
9
|
+
"@picked/typegen": "0.0.1-dev.1786601464574"
|
|
7
10
|
},
|
|
8
11
|
"devDependencies": {
|
|
9
12
|
"@repo/eslint-config": "workspace:*",
|
|
10
13
|
"@repo/typescript-config": "workspace:*",
|
|
11
14
|
"@rollup/plugin-replace": "^6.0.3",
|
|
12
|
-
"@types/node": "^
|
|
15
|
+
"@types/node": "^24",
|
|
13
16
|
"@vitest/coverage-v8": "^4.1.10",
|
|
14
17
|
"tsx": "^4.23.1",
|
|
15
18
|
"vite": "^8.2.0",
|
|
@@ -21,9 +24,13 @@
|
|
|
21
24
|
"import": "./dist/esm/index.js",
|
|
22
25
|
"require": "./dist/cjs/index.js",
|
|
23
26
|
"default": "./dist/esm/index.js"
|
|
27
|
+
},
|
|
28
|
+
"./client": {
|
|
29
|
+
"types": "./client.d.ts"
|
|
24
30
|
}
|
|
25
31
|
},
|
|
26
32
|
"files": [
|
|
33
|
+
"client.d.ts",
|
|
27
34
|
"dist"
|
|
28
35
|
],
|
|
29
36
|
"knip": {
|
|
@@ -36,6 +43,9 @@
|
|
|
36
43
|
],
|
|
37
44
|
"ignoreDependencies": [
|
|
38
45
|
"@picked/client",
|
|
46
|
+
"@picked/delivery-api-client",
|
|
47
|
+
"@picked/typegen",
|
|
48
|
+
"@picked/config",
|
|
39
49
|
"@repo/eslint-config",
|
|
40
50
|
"@repo/typescript-config",
|
|
41
51
|
"@vitest/coverage-v8"
|