@picked/vite-plugin-picked 0.0.1-dev.1789541668638 → 0.0.1-dev.1793756239746

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.
@@ -24,28 +24,28 @@ export interface PickedPluginOptions {
24
24
  /** Generate TypeScript types from the workspace schema on dev/build. Defaults to true. */
25
25
  generateTypes?: boolean;
26
26
  /**
27
- * Whether this build carries Picked data. Defaults to `'bundle'`.
28
- *
29
- * `'bundle'` prefetches the project config and each experience's content, writes `.picked/`, and
30
- * emits a module that registers itself with the SDK. `'api'` skips the prefetch altogether —
31
- * no build-time dependency on the Picked API and no `.picked/` directory — and emits a module
32
- * the SDK's shape guard refuses, which leaves every read on the API path.
27
+ * @deprecated Set `data` in `picked.config` instead, which the CLI and the type generator
28
+ * read from too. Still honoured when `picked.config` omits `data`, and a future release
29
+ * drops it. Setting both to different values is an error.
33
30
  */
34
31
  mode?: 'bundle' | 'api';
35
32
  }
36
33
  /**
37
- * Vite plugin that fetches Picked project config + per-experience CMS content at build time
38
- * and exposes both via the `virtual:picked/data` virtual module.
34
+ * Vite plugin that exposes Picked project config + per-experience CMS content via the
35
+ * `virtual:picked/data` virtual module.
39
36
  *
40
- * Build mode (`vite build`) prefetches every CMS-using experience, writes JSON artefacts
41
- * to `<root>/.picked/`, and synthesises a virtual module that statically imports the
42
- * project config (so it's bundled) and lazily imports each experience's content on demand.
37
+ * Under `data: 'bundle'`, build mode (`vite build`) prefetches every CMS-using experience,
38
+ * writes JSON artefacts to `<root>/.picked/`, and synthesises a virtual module that statically
39
+ * imports the project config (so it's bundled) and lazily imports each experience's content on
40
+ * demand. Dev mode (`vite serve`) writes nothing to disk; the synthesised virtual module inlines
41
+ * the config the plugin fetched and fetches content per call.
43
42
  *
44
- * Dev mode (`vite serve`) writes nothing to disk; the synthesised virtual module performs
45
- * runtime API fetches via top-level `await` for project config and per-call for content.
43
+ * Under `data: 'snapshot'`, build and dev serve the committed `picked.snapshot.json` and fetch
44
+ * nothing. Under `data: 'api'`, nothing is fetched or embedded.
46
45
  *
47
- * Project identity — `projectId` and `apiUrl` — comes from `picked.config.{ts,js,json}` at the
48
- * project root, which the CLI and the type generator read from the same place.
46
+ * Project identity — `projectId` and `apiUrl` — and the data mode come from
47
+ * `picked.config.{ts,js,json}` at the project root, which the CLI and the type generator read
48
+ * from the same place.
49
49
  *
50
50
  * @param {PickedPluginOptions} options - Plugin configuration.
51
51
  * @returns {Plugin} A Vite plugin instance.
@@ -1 +1 @@
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;;;;;OAKG;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"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EAAqB,MAAM,EAAU,MAAM,MAAM,CAAA;AAqb7D,MAAM,WAAW,mBAAmB;IAClC;;;;;OAKG;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;;;;OAIG;IACH,IAAI,CAAC,EAAE,QAAQ,GAAG,KAAK,CAAA;CACxB;AA+BD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,MAAM,CAAC,OAAO,GAAE,mBAAwB,GAAG,MAAM,CAuUhE"}
@@ -3,8 +3,9 @@
3
3
  *
4
4
  * Retries are auto-enabled when the configured `apiUrl` points at a host where
5
5
  * deploys can race ahead of the API: `localhost`/`127.0.0.1`/`::1` for local
6
- * development, or any `*.picked.app` host EXCEPT the canonical production host
7
- * `api.picked.app`. Production and external customer hosts continue to fail fast.
6
+ * development, any `*.picked-dev.app` staging or preview host, or any
7
+ * `*.picked.app` host EXCEPT the canonical production host `api.picked.app`.
8
+ * Production and external customer hosts continue to fail fast.
8
9
  *
9
10
  * The retry schedule is hardcoded — there is no public option. The behavior is
10
11
  * an internal deploy-ordering workaround for the Picked monorepo and is not
@@ -20,7 +21,7 @@
20
21
  * @returns {boolean} `true` when retries should be attempted, `false` otherwise.
21
22
  * @example
22
23
  * shouldRetryUrl('http://localhost:54321') // true
23
- * shouldRetryUrl('https://picked-api-git-foo.picked.app') // true
24
+ * shouldRetryUrl('https://picked-api-git-foo.picked-dev.app') // true
24
25
  * shouldRetryUrl('https://api.picked.app') // false
25
26
  */
26
27
  export declare function shouldRetryUrl(apiUrl: string): boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"retry.d.ts","sourceRoot":"","sources":["../../src/retry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAKH;;;;;;;;;;;;GAYG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAsBtD;AAgBD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAsB,SAAS,CAAC,CAAC,EAC/B,OAAO,EAAE,MAAM,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,EAChC,OAAO,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,KAAK,IAAI,GAC7E,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CA+BnB"}
1
+ {"version":3,"file":"retry.d.ts","sourceRoot":"","sources":["../../src/retry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAKH;;;;;;;;;;;;GAYG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAsBtD;AAgBD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAsB,SAAS,CAAC,CAAC,EAC/B,OAAO,EAAE,MAAM,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,EAChC,OAAO,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,KAAK,IAAI,GAC7E,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CA+BnB"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * @file Synthesis for `virtual:picked/data` when `picked.config` sets `data: 'snapshot'`.
3
+ *
4
+ * The module inlines the snapshot's project config and reaches each experience's content
5
+ * through its own virtual module, so build output keeps content in lazy chunks and nothing is
6
+ * written to disk. The same source serves build and serve.
7
+ */
8
+ import type { PickedSnapshot } from '@picked/config';
9
+ /** Prefix of the per-experience content modules the snapshot module imports. */
10
+ export declare const SNAPSHOT_EXPERIENCE_MODULE_PREFIX = "virtual:picked/data/experience/";
11
+ /**
12
+ * Synthesises the snapshot-mode `virtual:picked/data` module.
13
+ *
14
+ * @param {PickedSnapshot} snapshot - The snapshot the build serves.
15
+ * @returns {string} JavaScript source for Vite's `load` hook.
16
+ * @example
17
+ * const source = snapshotVirtualModuleSource(snapshot)
18
+ */
19
+ export declare function snapshotVirtualModuleSource(snapshot: PickedSnapshot): string;
20
+ /**
21
+ * Synthesises the module that exports the content of the experience at a position in
22
+ * `snapshot.experiences`.
23
+ *
24
+ * @param {PickedSnapshot} snapshot - The snapshot the build serves.
25
+ * @param {string} position - The module id's position segment.
26
+ * @returns {string} JavaScript source for Vite's `load` hook; it exports `null` for a position the snapshot does not hold.
27
+ * @example
28
+ * snapshotExperienceModuleSource(snapshot, '0')
29
+ */
30
+ export declare function snapshotExperienceModuleSource(snapshot: PickedSnapshot, position: string): string;
31
+ //# sourceMappingURL=snapshot.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"snapshot.d.ts","sourceRoot":"","sources":["../../../src/virtual-module/snapshot.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAGpD,gFAAgF;AAChF,eAAO,MAAM,iCAAiC,oCAAoC,CAAA;AAElF;;;;;;;GAOG;AACH,wBAAgB,2BAA2B,CAAC,QAAQ,EAAE,cAAc,GAAG,MAAM,CAmC5E;AAED;;;;;;;;;GASG;AACH,wBAAgB,8BAA8B,CAAC,QAAQ,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAQjG"}
package/package.json CHANGED
@@ -1,23 +1,24 @@
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.1789541668638",
4
+ "version": "0.0.1-dev.1793756239746",
5
5
  "dependencies": {
6
- "@picked/client": "0.0.1-dev.1789541668638",
7
- "@picked/config": "0.0.1-dev.1789541668638",
8
- "@picked/delivery-api-client": "0.0.1-dev.1789541668638",
9
- "@picked/telemetry": "0.0.1-dev.1789541668638",
10
- "@picked/typegen": "0.0.1-dev.1789541668638"
6
+ "@picked/client": "0.0.1-dev.1793756239746",
7
+ "@picked/config": "0.0.1-dev.1793756239746",
8
+ "@picked/delivery-api-client": "0.0.1-dev.1793756239746",
9
+ "@picked/telemetry": "0.0.1-dev.1793756239746",
10
+ "@picked/typegen": "0.0.1-dev.1793756239746"
11
11
  },
12
12
  "devDependencies": {
13
13
  "@repo/eslint-config": "workspace:*",
14
14
  "@repo/typescript-config": "workspace:*",
15
+ "@repo/vitest-config": "workspace:*",
15
16
  "@rollup/plugin-replace": "^6.0.3",
16
17
  "@types/node": "^24",
17
- "@vitest/coverage-v8": "^4.1.11",
18
+ "@vitest/coverage-v8": "^5.0.1",
18
19
  "tsx": "^4.23.1",
19
20
  "vite": "^8.2.0",
20
- "vitest": "^4.1.10"
21
+ "vitest": "^5.0.1"
21
22
  },
22
23
  "exports": {
23
24
  ".": {
@@ -46,31 +47,37 @@
46
47
  "@picked/client",
47
48
  "@picked/delivery-api-client",
48
49
  "@picked/typegen",
50
+ "@picked/telemetry",
49
51
  "@picked/config",
50
52
  "@repo/eslint-config",
51
53
  "@repo/typescript-config",
52
- "@vitest/coverage-v8"
54
+ "@repo/vitest-config"
53
55
  ],
54
56
  "ignore": [
55
- "eslint.config.js"
57
+ "eslint.config.js",
58
+ "src/__fixtures__/sdk-stub.ts"
56
59
  ]
57
60
  },
61
+ "license": "SEE LICENSE IN LICENSE",
58
62
  "main": "./dist/cjs/index.js",
59
63
  "module": "./dist/esm/index.js",
60
64
  "peerDependencies": {
61
65
  "vite": "^7.0.0 || ^8.0.0"
62
66
  },
63
67
  "private": false,
68
+ "publishConfig": {
69
+ "access": "public"
70
+ },
64
71
  "scripts": {
65
72
  "build": "vite build && tsgo -p tsconfig.build.json",
66
73
  "check": "pnpm type-check && pnpm lint && pnpm knip && pnpm jscpd",
67
74
  "dev": "node ../../scripts/sdk-watch-build.mjs",
68
75
  "jscpd": "jscpd src",
69
76
  "knip": "knip",
70
- "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 . --cache --cache-location node_modules/.cache/eslint",
77
+ "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 . --cache --cache-strategy content --cache-location node_modules/.cache/eslint",
71
78
  "lint-files": "eslint",
72
79
  "lint:format": "eslint . --fix",
73
- "lint:report": "eslint . --cache --cache-location node_modules/.cache/eslint -o './.reports/eslint.json' -f json || true",
80
+ "lint:report": "eslint . --cache --cache-strategy content --cache-location node_modules/.cache/eslint -o './.reports/eslint.json' -f json || true",
74
81
  "test": "vitest run",
75
82
  "test:coverage": "../../scripts/vitest-coverage.sh",
76
83
  "test:packaged-types": "attw --pack",