@picked/client 0.0.1-dev.1786065500148 → 0.0.1-dev.1786072899095

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.
Files changed (41) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/api-BzK4kXRt.js +38 -0
  3. package/dist/api-CgENjKwJ.cjs +1 -0
  4. package/dist/cjs/index.js +2 -2
  5. package/dist/cjs/plugins/dynamic-experiences/index.js +1 -1
  6. package/dist/cjs/server/index.js +1 -1
  7. package/dist/docs/explanation/how-picked-works.md +3 -25
  8. package/dist/docs/reference/sdk/plugins/dynamic-experiences.md +2 -50
  9. package/dist/docs/reference/tools/vite-plugin.md +8 -90
  10. package/dist/esm/index.js +452 -499
  11. package/dist/esm/plugins/dynamic-experiences/index.js +3 -3
  12. package/dist/esm/server/index.js +46 -43
  13. package/dist/plugin-DJjtc5df.js +252 -0
  14. package/dist/plugin-jHxSAqGG.cjs +1 -0
  15. package/dist/types/entities/feature/feature.d.ts +9 -2
  16. package/dist/types/entities/feature/feature.d.ts.map +1 -1
  17. package/dist/types/picked.d.ts +3 -66
  18. package/dist/types/picked.d.ts.map +1 -1
  19. package/dist/types/plugins/dynamic-experiences/index.d.ts +0 -1
  20. package/dist/types/plugins/dynamic-experiences/index.d.ts.map +1 -1
  21. package/dist/types/plugins/dynamic-experiences/plugin.d.ts +40 -9
  22. package/dist/types/plugins/dynamic-experiences/plugin.d.ts.map +1 -1
  23. package/dist/types/plugins/dynamic-experiences/types.d.ts +23 -15
  24. package/dist/types/plugins/dynamic-experiences/types.d.ts.map +1 -1
  25. package/dist/types/server/index.d.ts +1 -1
  26. package/dist/types/server/index.d.ts.map +1 -1
  27. package/dist/types/server/serialize.d.ts +19 -7
  28. package/dist/types/server/serialize.d.ts.map +1 -1
  29. package/package.json +1 -1
  30. package/dist/plugin-EFn9ALEF.cjs +0 -1
  31. package/dist/plugin-YytfMG0n.js +0 -153
  32. package/dist/registry-BYtEBdL1.js +0 -111
  33. package/dist/registry-DtmKJre-.cjs +0 -1
  34. package/dist/types/data-source/api.d.ts +0 -60
  35. package/dist/types/data-source/api.d.ts.map +0 -1
  36. package/dist/types/data-source/provider.d.ts +0 -91
  37. package/dist/types/data-source/provider.d.ts.map +0 -1
  38. package/dist/types/data-source/registry.d.ts +0 -27
  39. package/dist/types/data-source/registry.d.ts.map +0 -1
  40. package/dist/types/data-source/virtual-data.d.ts +0 -19
  41. package/dist/types/data-source/virtual-data.d.ts.map +0 -1
@@ -6,8 +6,8 @@ layout: docs
6
6
  # Vite Plugin
7
7
 
8
8
  `@picked/vite-plugin-picked` adds Picked to your Vite project. It reads the options
9
- of your project at build time. It then puts them in a module that gives them to the
10
- SDK, so the SDK makes no API request at runtime. In development it also serves a
9
+ of your project at build time. It then injects them through the Vite `define`
10
+ option, so the SDK makes no API request at runtime. In development it also serves a
11
11
  launcher page. On that page you can see a preview of an experience with your own
12
12
  feature flag values.
13
13
 
@@ -19,75 +19,11 @@ When Vite starts, in both `dev` and `build`, the plugin does this:
19
19
 
20
20
  1. It reads the configuration of your project from the Picked API.
21
21
  2. It embeds those options in your bundle.
22
- 3. The module gives the options to the SDK as the browser loads it.
23
- 4. The SDK reads the embedded configuration at runtime and makes no network request.
24
-
25
- Step 3 is a function call. The module gives the options to the SDK as it loads, and does
26
- not wait for the SDK to ask.
22
+ 3. The SDK reads the embedded configuration at runtime and makes no network request.
27
23
 
28
24
  When a preview token is there at runtime, the SDK ignores the embedded configuration and
29
25
  reads fresh data from the API.
30
26
 
31
- ### Preload of the data file
32
-
33
- Vite puts the options of your project in their own JavaScript file. For each HTML page
34
- in your build, the plugin adds a `<link rel="modulepreload">` for that file. The
35
- browser then gets it while it reads the page, and not later when the SDK starts.
36
-
37
- The CMS content of an experience stays in its own file and gets no preload. The
38
- browser gets it only when an experience needs it.
39
-
40
- Some applications make their HTML from the code, and not from an HTML file in your
41
- project. React Router in server mode is one of these. Such a build has no page for the
42
- plugin to add the link to. Add this line to the code that runs in the browser instead:
43
-
44
- :::code-group
45
-
46
- ```ts [entry.client.ts]
47
- import 'virtual:picked/data'
48
- ```
49
-
50
- :::
51
-
52
- Your framework then sees the file in its own list and adds the preload for you.
53
-
54
- The line reads no value from the module. It is there for the work the module does as it
55
- loads. A bundler removes a module that only declares values, and removes the line with
56
- it. This module gives your project options to the SDK, which is work, so the bundler
57
- keeps both.
58
-
59
- Your application is correct without this line. The SDK gets the same data later, as it
60
- starts. The line moves that work earlier.
61
-
62
- ### Types for the data file
63
-
64
- The plugin makes `virtual:picked/data` at build time. Because the module is not a file in
65
- your project, TypeScript cannot find its types. The plugin gives you a type file for the
66
- module. Point your project at that type file to import from the module:
67
-
68
- :::code-group
69
-
70
- ```json [tsconfig.json]
71
- {
72
- "compilerOptions": {
73
- "types": ["@picked/vite-plugin-picked/client"]
74
- }
75
- }
76
- ```
77
-
78
- ```ts [picked-data.ts]
79
- /// <reference types="@picked/vite-plugin-picked/client" />
80
- ```
81
-
82
- :::
83
-
84
- Use one of the two. The `types` option applies to all files in your project. The
85
- `reference` comment applies to one file.
86
-
87
- The module gives three values: `projectConfig`, `experienceContent` and
88
- `manifestMetadata`. You do not give these values to the SDK. The module gives them to
89
- the SDK itself as the browser loads it.
90
-
91
27
  ### Dev launcher
92
28
 
93
29
  In development, the plugin serves an HTML page at `/`. On that page you can:
@@ -106,23 +42,11 @@ After the dev server starts, the launcher URL appears next to the Vite output:
106
42
 
107
43
  ## Options
108
44
 
109
- | Option | Type | Default | Description |
110
- | ---------------- | --------------------- | ------------------------ | --------------------------------------------------------- |
111
- | `projectId` | `string` | — | **Required.** The ID of your Picked project. |
112
- | `apiUrl` | `string` | `https://api.picked.app` | Your own API URL, for a self-hosted or local API. |
113
- | `disableLauncher`| `boolean` | `false` | Turns the launcher page off in both dev and build output. |
114
- | `mode` | `'bundle' \| 'api'` | `'bundle'` | Whether the build carries your project data. |
115
-
116
- ### mode
117
-
118
- `'bundle'` reads your project options at build time and puts them in your bundle.
119
-
120
- `'api'` does not read them. Your build then makes no request to the Picked API, and
121
- writes no `.picked` directory. The SDK reads your project options from the API at
122
- runtime instead. Use this when your build must not depend on the Picked API.
123
-
124
- The SDK has no equivalent option. It uses the data your build gives it, and the API when
125
- your build gives none.
45
+ | Option | Type | Default | Description |
46
+ | ---------------- | --------- | ---------------------------- | -------------------------------------------------------- |
47
+ | `projectId` | `string` | — | **Required.** The ID of your Picked project. |
48
+ | `apiUrl` | `string` | `https://api.picked.app` | Your own API URL, for a self-hosted or local API. |
49
+ | `disableLauncher`| `boolean` | `false` | Turns the launcher page off in both dev and build output.|
126
50
 
127
51
  ## Build output
128
52
 
@@ -130,12 +54,6 @@ For a production build, `vite build`, the plugin writes an `index.html` file tha
130
54
  holds the launcher page. Set `disableLauncher` to stop this. The file lets you deploy
131
55
  the launcher next to your application, so that a stakeholder can see a preview.
132
56
 
133
- The plugin writes that file only when your build made no `index.html` of its own. An
134
- application that has an HTML entry keeps its own page at the root of the output.
135
-
136
- The plugin also writes a `.picked` directory next to your Vite `root`. It holds the
137
- options of your project and the CMS content of each experience.
138
-
139
57
  ## Related
140
58
 
141
59
  - [How to install the Vite plugin](/how-to/install-the-vite-plugin)