@picked/client 0.0.72-next.1 → 0.0.72-next.3
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/{api-B9DDtylO.cjs → api-B4qxWoQN.cjs} +1 -1
- package/dist/{api-BmzHzzpu.js → api-DNvaLWw_.js} +1 -1
- package/dist/cjs/index.js +2 -2
- package/dist/cjs/plugins/dynamic-experiences/index.js +1 -1
- package/dist/cjs/server/index.js +1 -1
- package/dist/docs/explanation/content-references.md +99 -0
- package/dist/docs/explanation/how-picked-works.md +25 -3
- package/dist/docs/explanation/the-content-model.md +38 -28
- package/dist/docs/how-to/create-a-content-entry.md +48 -0
- package/dist/docs/how-to/define-a-page-layout.md +12 -5
- package/dist/docs/how-to/point-one-entry-at-another.md +61 -0
- package/dist/docs/how-to/read-a-referenced-entry.md +111 -0
- package/dist/docs/how-to/reuse-a-section.md +26 -10
- package/dist/docs/index.md +1 -1
- package/dist/docs/reference/dashboard/content/blocks.mdx +57 -0
- package/dist/docs/reference/dashboard/content/content-entries.mdx +61 -10
- package/dist/docs/reference/dashboard/content/models.mdx +108 -0
- package/dist/docs/reference/dashboard/content/pages.mdx +4 -3
- package/dist/docs/reference/dashboard/fields.mdx +1 -1
- package/dist/docs/reference/dashboard/steps.mdx +2 -2
- package/dist/docs/reference/delivery-api/experience-content.md +68 -13
- package/dist/docs/reference/glossary.md +13 -5
- package/dist/docs/reference/management-api/error-handling.md +2 -2
- package/dist/docs/reference/sdk/content.md +216 -0
- package/dist/docs/reference/sdk/plugins/dynamic-experiences.md +51 -3
- package/dist/docs/reference/sdk/ssr/serialize.md +6 -3
- package/dist/docs/reference/tools/vite-plugin.md +90 -8
- package/dist/docs/tutorials/first-api-call.md +1 -1
- package/dist/docs/tutorials/first-server-rendered-page.mdx +1 -1
- package/dist/esm/index.js +484 -429
- package/dist/esm/plugins/dynamic-experiences/index.js +4 -3
- package/dist/esm/server/index.js +43 -46
- package/dist/plugin-DkSWIASL.cjs +1 -0
- package/dist/plugin-DviILBha.js +153 -0
- package/dist/provider-Bskcgd6U.js +68 -0
- package/dist/provider-Bv5nM3So.cjs +1 -0
- package/dist/registry-BMXsAEbZ.cjs +1 -0
- package/dist/registry-DjBZ8upD.js +74 -0
- package/dist/types/data-source/api.d.ts +60 -0
- package/dist/types/data-source/api.d.ts.map +1 -0
- package/dist/types/data-source/provider.d.ts +90 -0
- package/dist/types/data-source/provider.d.ts.map +1 -0
- package/dist/types/data-source/registry.d.ts +26 -0
- package/dist/types/data-source/registry.d.ts.map +1 -0
- package/dist/types/data-source/virtual-data.d.ts +19 -0
- package/dist/types/data-source/virtual-data.d.ts.map +1 -0
- package/dist/types/entities/content/reference.d.ts +101 -0
- package/dist/types/entities/content/reference.d.ts.map +1 -0
- package/dist/types/exports.d.ts +2 -0
- package/dist/types/exports.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/picked.d.ts +65 -1
- package/dist/types/picked.d.ts.map +1 -1
- package/dist/types/plugins/dynamic-experiences/index.d.ts +1 -0
- package/dist/types/plugins/dynamic-experiences/index.d.ts.map +1 -1
- package/dist/types/plugins/dynamic-experiences/plugin.d.ts +9 -40
- package/dist/types/plugins/dynamic-experiences/plugin.d.ts.map +1 -1
- package/dist/types/plugins/dynamic-experiences/types.d.ts +25 -23
- package/dist/types/plugins/dynamic-experiences/types.d.ts.map +1 -1
- package/dist/types/server/index.d.ts +1 -1
- package/dist/types/server/index.d.ts.map +1 -1
- package/dist/types/server/serialize.d.ts +27 -34
- package/dist/types/server/serialize.d.ts.map +1 -1
- package/package.json +3 -3
- package/dist/docs/reference/dashboard/content/layouts.mdx +0 -62
- package/dist/docs/reference/dashboard/content/sections.mdx +0 -28
- package/dist/plugin-CZN0_kqv.js +0 -252
- package/dist/plugin-SFx511s_.cjs +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
|
|
10
|
-
|
|
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
|
|
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,11 +19,75 @@ 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
|
|
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.
|
|
23
27
|
|
|
24
28
|
When a preview token is there at runtime, the SDK ignores the embedded configuration and
|
|
25
29
|
reads fresh data from the API.
|
|
26
30
|
|
|
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
|
+
|
|
27
91
|
### Dev launcher
|
|
28
92
|
|
|
29
93
|
In development, the plugin serves an HTML page at `/`. On that page you can:
|
|
@@ -42,11 +106,23 @@ After the dev server starts, the launcher URL appears next to the Vite output:
|
|
|
42
106
|
|
|
43
107
|
## Options
|
|
44
108
|
|
|
45
|
-
| Option | Type
|
|
46
|
-
| ---------------- |
|
|
47
|
-
| `projectId` | `string`
|
|
48
|
-
| `apiUrl` | `string`
|
|
49
|
-
| `disableLauncher`| `boolean`
|
|
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.
|
|
50
126
|
|
|
51
127
|
## Build output
|
|
52
128
|
|
|
@@ -54,6 +130,12 @@ For a production build, `vite build`, the plugin writes an `index.html` file tha
|
|
|
54
130
|
holds the launcher page. Set `disableLauncher` to stop this. The file lets you deploy
|
|
55
131
|
the launcher next to your application, so that a stakeholder can see a preview.
|
|
56
132
|
|
|
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
|
+
|
|
57
139
|
## Related
|
|
58
140
|
|
|
59
141
|
- [How to install the Vite plugin](/how-to/install-the-vite-plugin)
|
|
@@ -118,7 +118,7 @@ When `requiresMfa` is `true`, you must complete the MFA challenge before you rec
|
|
|
118
118
|
a session. See the [Authentication](/reference/management-api/authentication) guide.
|
|
119
119
|
|
|
120
120
|
For a server-to-server integration, use
|
|
121
|
-
[API key authentication](/
|
|
121
|
+
[API key authentication](/how-to/authenticate-with-an-api-key) and not a
|
|
122
122
|
session token.
|
|
123
123
|
|
|
124
124
|
## Make an authenticated query
|
|
@@ -181,6 +181,6 @@ new content on the next request, and you deploy nothing.
|
|
|
181
181
|
- [About server-side rendering](/explanation/why-server-side-rendering) — why the
|
|
182
182
|
snapshot exists, and what it carries.
|
|
183
183
|
- [Server snapshot](/reference/sdk/ssr/serialize) — every `serialize()` parameter.
|
|
184
|
-
- [
|
|
184
|
+
- [Models](/reference/dashboard/content/models) — every field type.
|
|
185
185
|
- [Preview, cache, and crawlers](/reference/delivery-api/preview-caching-crawling) — how
|
|
186
186
|
a draft stays out of the search index.
|