@preprio/toolkit 0.6.0-alpha.9 → 1.0.0-rc.1
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/README.md +111 -1363
- package/dist/astro/index.cjs +1555 -182
- package/dist/astro/index.d.cts +201 -1
- package/dist/astro/index.d.ts +201 -1
- package/dist/astro/index.js +1557 -29
- package/dist/{chunk-5QIWVDP2.js → chunk-33GWVTRJ.js} +1 -1
- package/dist/chunk-A2J7R4LR.js +256 -0
- package/dist/{chunk-WQBKQG4R.js → chunk-DSJ22P6J.js} +6 -1
- package/dist/chunk-KM2GME62.js +1255 -0
- package/dist/chunk-UTKH7DOI.js +58 -0
- package/dist/chunk-V7MCHPE7.js +85 -0
- package/dist/{chunk-J66UOCK6.js → chunk-WBMN4L7G.js} +1680 -579
- package/dist/chunk-Y7JWV7WV.js +374 -0
- package/dist/codegen/index.cjs +82 -0
- package/dist/codegen/index.d.cts +70 -0
- package/dist/codegen/index.d.ts +70 -0
- package/dist/codegen/index.js +64 -0
- package/dist/index.cjs +3729 -553
- package/dist/index.d.cts +403 -19
- package/dist/index.d.ts +403 -19
- package/dist/index.js +345 -24
- package/dist/live-preview-HCBNBC6C.js +19 -0
- package/dist/nextjs/components.cjs +1872 -754
- package/dist/nextjs/components.d.cts +5 -51
- package/dist/nextjs/components.d.ts +5 -51
- package/dist/nextjs/components.js +8 -299
- package/dist/nextjs/index.cjs +1228 -181
- package/dist/nextjs/index.d.cts +247 -92
- package/dist/nextjs/index.d.ts +247 -92
- package/dist/nextjs/index.js +1629 -111
- package/dist/nextjs/live-action.cjs +298 -0
- package/dist/nextjs/live-action.d.cts +12 -0
- package/dist/nextjs/live-action.d.ts +12 -0
- package/dist/nextjs/live-action.js +68 -0
- package/dist/nextjs/live.cjs +2010 -0
- package/dist/nextjs/live.d.cts +54 -0
- package/dist/nextjs/live.d.ts +54 -0
- package/dist/nextjs/live.js +287 -0
- package/dist/nuxt/chunk-5RBZPRQN.js +350 -0
- package/dist/nuxt/chunk-LUKVPOJ2.js +32 -0
- package/dist/nuxt/index.cjs +15 -16
- package/dist/nuxt/index.d.cts +167 -6
- package/dist/nuxt/index.d.ts +167 -6
- package/dist/nuxt/index.js +402 -15
- package/dist/nuxt/live-preview-KO4IKWTX.js +1234 -0
- package/dist/nuxt/live.cjs +1928 -0
- package/dist/nuxt/live.d.cts +45 -0
- package/dist/nuxt/live.d.ts +45 -0
- package/dist/nuxt/live.js +216 -0
- package/dist/{types-BYH9XqmN.d.cts → pixel-DqU7NvgW.d.cts} +102 -5
- package/dist/{types-BYH9XqmN.d.ts → pixel-DqU7NvgW.d.ts} +102 -5
- package/dist/react/components.cjs +1865 -480
- package/dist/react/components.d.cts +43 -8
- package/dist/react/components.d.ts +43 -8
- package/dist/react/components.js +1865 -480
- package/dist/sveltekit/chunk-5RBZPRQN.js +350 -0
- package/dist/sveltekit/chunk-LUKVPOJ2.js +32 -0
- package/dist/sveltekit/index.cjs +15 -16
- package/dist/sveltekit/index.d.cts +111 -10
- package/dist/sveltekit/index.d.ts +111 -10
- package/dist/sveltekit/index.js +398 -15
- package/dist/sveltekit/live-preview-KO4IKWTX.js +1234 -0
- package/dist/sveltekit/live.cjs +1940 -0
- package/dist/sveltekit/live.d.cts +61 -0
- package/dist/sveltekit/live.d.ts +61 -0
- package/dist/sveltekit/live.js +220 -0
- package/package.json +132 -71
- package/src/astro/PreprToolbar.astro +7 -1
- package/src/astro/PreprTrackingPixel.astro +2 -4
- package/src/nuxt/PreprToolbar.vue +12 -1
- package/src/nuxt/PreprTrackingPixel.vue +2 -4
- package/src/sveltekit/PreprToolbar.svelte +17 -2
- package/src/sveltekit/PreprTrackingPixel.svelte +2 -4
- package/dist/astro/chunk-UN4JADNU.js +0 -173
- package/dist/astro/graphql.cjs +0 -1078
- package/dist/astro/graphql.d.cts +0 -300
- package/dist/astro/graphql.d.ts +0 -300
- package/dist/astro/graphql.js +0 -984
- package/dist/astro/index-XT_z-RYT.d.cts +0 -130
- package/dist/astro/index-XT_z-RYT.d.ts +0 -130
- package/dist/chunk-3NCEVJJ3.js +0 -10
- package/dist/chunk-S5RWVMDJ.js +0 -148
- package/dist/chunk-XL4Y7FGW.js +0 -499
- package/dist/graphql/codegen.cjs +0 -557
- package/dist/graphql/codegen.d.cts +0 -23
- package/dist/graphql/codegen.d.ts +0 -23
- package/dist/graphql/codegen.js +0 -99
- package/dist/graphql.cjs +0 -1020
- package/dist/graphql.d.cts +0 -335
- package/dist/graphql.d.ts +0 -335
- package/dist/graphql.js +0 -448
- package/dist/nextjs/chunk-CMV6ZP6E.js +0 -549
- package/dist/nextjs/graphql.cjs +0 -1836
- package/dist/nextjs/graphql.d.cts +0 -498
- package/dist/nextjs/graphql.d.ts +0 -498
- package/dist/nextjs/graphql.js +0 -1422
- package/dist/nextjs/server-BL-sqZvu.d.cts +0 -156
- package/dist/nextjs/server-BL-sqZvu.d.ts +0 -156
- package/dist/nuxt/chunk-XWOABVMW.js +0 -417
- package/dist/nuxt/graphql.cjs +0 -1085
- package/dist/nuxt/graphql.d.cts +0 -297
- package/dist/nuxt/graphql.d.ts +0 -297
- package/dist/nuxt/graphql.js +0 -985
- package/dist/nuxt/server-8v6OHbsw.d.cts +0 -158
- package/dist/nuxt/server-8v6OHbsw.d.ts +0 -158
- package/dist/pixel-DwW7cXJm.d.cts +0 -49
- package/dist/pixel-DwW7cXJm.d.ts +0 -49
- package/dist/server-Brr1UgtW.d.ts +0 -59
- package/dist/server-DJuS3YU0.d.cts +0 -59
- package/dist/sveltekit/chunk-3S5RA6G5.js +0 -413
- package/dist/sveltekit/graphql.cjs +0 -1091
- package/dist/sveltekit/graphql.d.cts +0 -302
- package/dist/sveltekit/graphql.d.ts +0 -302
- package/dist/sveltekit/graphql.js +0 -991
- package/dist/sveltekit/server-CO847mEV.d.cts +0 -98
- package/dist/sveltekit/server-CO847mEV.d.ts +0 -98
|
@@ -2,9 +2,12 @@ type Dictionary = Record<string, unknown>;
|
|
|
2
2
|
declare const dictionaries: {
|
|
3
3
|
en: Dictionary;
|
|
4
4
|
nl: Dictionary;
|
|
5
|
+
fr: Dictionary;
|
|
6
|
+
de: Dictionary;
|
|
5
7
|
};
|
|
6
8
|
type Locale = keyof typeof dictionaries;
|
|
7
9
|
|
|
10
|
+
/** A segment from Prepr, as listed in the toolbar's segment picker. */
|
|
8
11
|
interface PreprSegment {
|
|
9
12
|
readonly _id: string;
|
|
10
13
|
readonly name: string;
|
|
@@ -33,8 +36,14 @@ interface PreprFeatures {
|
|
|
33
36
|
*/
|
|
34
37
|
editMode?: PreprFeatureConfig;
|
|
35
38
|
}
|
|
39
|
+
/** Options shared by the toolbar and the preview runtime. */
|
|
36
40
|
interface PreprToolbarOptions {
|
|
41
|
+
/** Log what the toolkit does to the browser console. Default `false`. */
|
|
37
42
|
debug?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Language of the toolbar and the visual editor labels. Defaults to the
|
|
45
|
+
* first supported browser language, then English.
|
|
46
|
+
*/
|
|
38
47
|
locale?: Locale;
|
|
39
48
|
/** Disable features app-wide. Pass the same object to the middleware. */
|
|
40
49
|
features?: PreprFeatures;
|
|
@@ -58,10 +67,24 @@ interface PreprPreviewOptions extends PreprToolbarOptions {
|
|
|
58
67
|
*/
|
|
59
68
|
ui?: boolean;
|
|
60
69
|
/**
|
|
61
|
-
* Replace the `*.prepr.io` editor-origin wildcard with an exact list.
|
|
62
|
-
* Intended for self-hosted
|
|
70
|
+
* Replace the `*.prepr.io` editor-origin wildcard with an exact list, e.g.
|
|
71
|
+
* `['http://acme.localhost:8000']`. Intended for self-hosted or locally run
|
|
72
|
+
* editors; when set, the wildcard no longer applies. Entries are compared to
|
|
73
|
+
* the editor's origin exactly: scheme, host and port.
|
|
74
|
+
*
|
|
75
|
+
* `['*']` accepts any editor origin. Use it for development only: any page
|
|
76
|
+
* that frames the preview can then switch on preview and edit mode and
|
|
77
|
+
* receives the field-edit events, which carry content item ids.
|
|
63
78
|
*/
|
|
64
79
|
allowedEditorOrigins?: string[];
|
|
80
|
+
/**
|
|
81
|
+
* Set when your preview token uses GraphQL strict mode, where required
|
|
82
|
+
* fields are never null. The editor then holds back new entries until
|
|
83
|
+
* their required fields are filled, and never sends a cleared required
|
|
84
|
+
* field as null. Applies to live preview on the same page as well, so the
|
|
85
|
+
* live preview helpers do not need their own `strictMode`.
|
|
86
|
+
*/
|
|
87
|
+
strictMode?: boolean;
|
|
65
88
|
/**
|
|
66
89
|
* Strip the invisible stega characters out of visible text at runtime.
|
|
67
90
|
* Default `true`.
|
|
@@ -77,6 +100,10 @@ interface PreprPreviewOptions extends PreprToolbarOptions {
|
|
|
77
100
|
*/
|
|
78
101
|
autoClean?: boolean;
|
|
79
102
|
}
|
|
103
|
+
/**
|
|
104
|
+
* The data the toolbar shows. `getToolbarProps` builds it on the server from
|
|
105
|
+
* the request headers.
|
|
106
|
+
*/
|
|
80
107
|
interface PreprToolbarProps {
|
|
81
108
|
/**
|
|
82
109
|
* Server-resolved active segment. Optional: omit it with `segments`
|
|
@@ -104,11 +131,14 @@ interface PreprToolbarComponentProps extends PreprToolbarProps {
|
|
|
104
131
|
}
|
|
105
132
|
|
|
106
133
|
/**
|
|
107
|
-
*
|
|
108
|
-
*
|
|
134
|
+
* How the toolbar changes the URL when a segment or variant is picked. The
|
|
135
|
+
* default does a full page load through `window.location`; pass the app's
|
|
136
|
+
* router for a soft navigation.
|
|
109
137
|
*/
|
|
110
138
|
interface PreprNavigationAdapter {
|
|
139
|
+
/** Go to `url`, a path with query string on the current origin. */
|
|
111
140
|
navigate(url: string): void;
|
|
141
|
+
/** The current path including its query string. */
|
|
112
142
|
currentPath(): string;
|
|
113
143
|
/**
|
|
114
144
|
* Refresh after a preview-mode toggle. Defaults to `window.location.reload()`;
|
|
@@ -130,11 +160,16 @@ interface PreprNavigationAdapter {
|
|
|
130
160
|
* - The tag is inserted async, `src` cache-busted every 24h via
|
|
131
161
|
* `Math.ceil(Date.now() / cacheTime) * cacheTime`.
|
|
132
162
|
*/
|
|
133
|
-
/** Config
|
|
163
|
+
/** Config for the Prepr tracking pixel, passed to `loadTrackingPixel`. */
|
|
134
164
|
interface PreprPixelConfig {
|
|
135
165
|
destinations?: {
|
|
166
|
+
/** Also push tracked events to Google Tag Manager's `dataLayer`. */
|
|
136
167
|
googleTagManager?: boolean;
|
|
137
168
|
};
|
|
169
|
+
/**
|
|
170
|
+
* How much of a personalized or A/B element must be in view to count as an
|
|
171
|
+
* impression, as the pixel defines it.
|
|
172
|
+
*/
|
|
138
173
|
variantImpressionThreshold?: number;
|
|
139
174
|
}
|
|
140
175
|
type PreprQueueArgs = unknown[];
|
|
@@ -182,9 +217,9 @@ interface PreprTrackingPixelProps {
|
|
|
182
217
|
/**
|
|
183
218
|
* Loads Prepr's CDN tracking pixel on mount. Renders nothing.
|
|
184
219
|
*
|
|
185
|
-
* The pixel
|
|
186
|
-
*
|
|
187
|
-
*
|
|
220
|
+
* The pixel counts a view for the content item named by the page's
|
|
221
|
+
* `<meta property="prepr:id">` tag, and a new one when a client-side route
|
|
222
|
+
* change points that tag at another item.
|
|
188
223
|
*/
|
|
189
224
|
declare function PreprTrackingPixel({ id, config, }: PreprTrackingPixelProps): null;
|
|
190
225
|
|
|
@@ -2,9 +2,12 @@ type Dictionary = Record<string, unknown>;
|
|
|
2
2
|
declare const dictionaries: {
|
|
3
3
|
en: Dictionary;
|
|
4
4
|
nl: Dictionary;
|
|
5
|
+
fr: Dictionary;
|
|
6
|
+
de: Dictionary;
|
|
5
7
|
};
|
|
6
8
|
type Locale = keyof typeof dictionaries;
|
|
7
9
|
|
|
10
|
+
/** A segment from Prepr, as listed in the toolbar's segment picker. */
|
|
8
11
|
interface PreprSegment {
|
|
9
12
|
readonly _id: string;
|
|
10
13
|
readonly name: string;
|
|
@@ -33,8 +36,14 @@ interface PreprFeatures {
|
|
|
33
36
|
*/
|
|
34
37
|
editMode?: PreprFeatureConfig;
|
|
35
38
|
}
|
|
39
|
+
/** Options shared by the toolbar and the preview runtime. */
|
|
36
40
|
interface PreprToolbarOptions {
|
|
41
|
+
/** Log what the toolkit does to the browser console. Default `false`. */
|
|
37
42
|
debug?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Language of the toolbar and the visual editor labels. Defaults to the
|
|
45
|
+
* first supported browser language, then English.
|
|
46
|
+
*/
|
|
38
47
|
locale?: Locale;
|
|
39
48
|
/** Disable features app-wide. Pass the same object to the middleware. */
|
|
40
49
|
features?: PreprFeatures;
|
|
@@ -58,10 +67,24 @@ interface PreprPreviewOptions extends PreprToolbarOptions {
|
|
|
58
67
|
*/
|
|
59
68
|
ui?: boolean;
|
|
60
69
|
/**
|
|
61
|
-
* Replace the `*.prepr.io` editor-origin wildcard with an exact list.
|
|
62
|
-
* Intended for self-hosted
|
|
70
|
+
* Replace the `*.prepr.io` editor-origin wildcard with an exact list, e.g.
|
|
71
|
+
* `['http://acme.localhost:8000']`. Intended for self-hosted or locally run
|
|
72
|
+
* editors; when set, the wildcard no longer applies. Entries are compared to
|
|
73
|
+
* the editor's origin exactly: scheme, host and port.
|
|
74
|
+
*
|
|
75
|
+
* `['*']` accepts any editor origin. Use it for development only: any page
|
|
76
|
+
* that frames the preview can then switch on preview and edit mode and
|
|
77
|
+
* receives the field-edit events, which carry content item ids.
|
|
63
78
|
*/
|
|
64
79
|
allowedEditorOrigins?: string[];
|
|
80
|
+
/**
|
|
81
|
+
* Set when your preview token uses GraphQL strict mode, where required
|
|
82
|
+
* fields are never null. The editor then holds back new entries until
|
|
83
|
+
* their required fields are filled, and never sends a cleared required
|
|
84
|
+
* field as null. Applies to live preview on the same page as well, so the
|
|
85
|
+
* live preview helpers do not need their own `strictMode`.
|
|
86
|
+
*/
|
|
87
|
+
strictMode?: boolean;
|
|
65
88
|
/**
|
|
66
89
|
* Strip the invisible stega characters out of visible text at runtime.
|
|
67
90
|
* Default `true`.
|
|
@@ -77,6 +100,10 @@ interface PreprPreviewOptions extends PreprToolbarOptions {
|
|
|
77
100
|
*/
|
|
78
101
|
autoClean?: boolean;
|
|
79
102
|
}
|
|
103
|
+
/**
|
|
104
|
+
* The data the toolbar shows. `getToolbarProps` builds it on the server from
|
|
105
|
+
* the request headers.
|
|
106
|
+
*/
|
|
80
107
|
interface PreprToolbarProps {
|
|
81
108
|
/**
|
|
82
109
|
* Server-resolved active segment. Optional: omit it with `segments`
|
|
@@ -104,11 +131,14 @@ interface PreprToolbarComponentProps extends PreprToolbarProps {
|
|
|
104
131
|
}
|
|
105
132
|
|
|
106
133
|
/**
|
|
107
|
-
*
|
|
108
|
-
*
|
|
134
|
+
* How the toolbar changes the URL when a segment or variant is picked. The
|
|
135
|
+
* default does a full page load through `window.location`; pass the app's
|
|
136
|
+
* router for a soft navigation.
|
|
109
137
|
*/
|
|
110
138
|
interface PreprNavigationAdapter {
|
|
139
|
+
/** Go to `url`, a path with query string on the current origin. */
|
|
111
140
|
navigate(url: string): void;
|
|
141
|
+
/** The current path including its query string. */
|
|
112
142
|
currentPath(): string;
|
|
113
143
|
/**
|
|
114
144
|
* Refresh after a preview-mode toggle. Defaults to `window.location.reload()`;
|
|
@@ -130,11 +160,16 @@ interface PreprNavigationAdapter {
|
|
|
130
160
|
* - The tag is inserted async, `src` cache-busted every 24h via
|
|
131
161
|
* `Math.ceil(Date.now() / cacheTime) * cacheTime`.
|
|
132
162
|
*/
|
|
133
|
-
/** Config
|
|
163
|
+
/** Config for the Prepr tracking pixel, passed to `loadTrackingPixel`. */
|
|
134
164
|
interface PreprPixelConfig {
|
|
135
165
|
destinations?: {
|
|
166
|
+
/** Also push tracked events to Google Tag Manager's `dataLayer`. */
|
|
136
167
|
googleTagManager?: boolean;
|
|
137
168
|
};
|
|
169
|
+
/**
|
|
170
|
+
* How much of a personalized or A/B element must be in view to count as an
|
|
171
|
+
* impression, as the pixel defines it.
|
|
172
|
+
*/
|
|
138
173
|
variantImpressionThreshold?: number;
|
|
139
174
|
}
|
|
140
175
|
type PreprQueueArgs = unknown[];
|
|
@@ -182,9 +217,9 @@ interface PreprTrackingPixelProps {
|
|
|
182
217
|
/**
|
|
183
218
|
* Loads Prepr's CDN tracking pixel on mount. Renders nothing.
|
|
184
219
|
*
|
|
185
|
-
* The pixel
|
|
186
|
-
*
|
|
187
|
-
*
|
|
220
|
+
* The pixel counts a view for the content item named by the page's
|
|
221
|
+
* `<meta property="prepr:id">` tag, and a new one when a client-side route
|
|
222
|
+
* change points that tag at another item.
|
|
188
223
|
*/
|
|
189
224
|
declare function PreprTrackingPixel({ id, config, }: PreprTrackingPixelProps): null;
|
|
190
225
|
|