@preprio/toolkit 0.5.0-rc.2 → 0.5.0-rc.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/README.md +207 -10
- package/dist/astro/index.cjs +1174 -1
- package/dist/astro/index.d.cts +47 -1
- package/dist/astro/index.d.ts +47 -1
- package/dist/astro/index.js +1177 -1
- package/dist/chunk-42Z2VW7G.js +1161 -0
- package/dist/chunk-6WY3MWCX.js +246 -0
- package/dist/chunk-MDAV2FLM.js +26 -0
- package/dist/{chunk-FLPNN3CV.js → chunk-PP3O7RB4.js} +1370 -623
- package/dist/chunk-S3VT4UWM.js +75 -0
- package/dist/chunk-SXUDBGLZ.js +184 -0
- package/dist/chunk-URXSDJOU.js +356 -0
- package/dist/index.cjs +3108 -392
- package/dist/index.d.cts +238 -4
- package/dist/index.d.ts +238 -4
- package/dist/index.js +189 -149
- package/dist/live-preview-EADA3ZL4.js +18 -0
- package/dist/nextjs/components.cjs +1522 -359
- package/dist/nextjs/components.d.cts +1 -1
- package/dist/nextjs/components.d.ts +1 -1
- package/dist/nextjs/components.js +4 -1
- package/dist/nextjs/index.cjs +1065 -6
- package/dist/nextjs/index.d.cts +73 -1
- package/dist/nextjs/index.d.ts +73 -1
- package/dist/nextjs/index.js +1059 -7
- package/dist/nextjs/live-action.cjs +285 -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 +1838 -0
- package/dist/nextjs/live.d.cts +52 -0
- package/dist/nextjs/live.d.ts +52 -0
- package/dist/nextjs/live.js +265 -0
- package/dist/nuxt/index.cjs +1 -1
- package/dist/nuxt/index.js +1 -1
- package/dist/nuxt/live-preview-PTEC3GPC.js +1462 -0
- package/dist/nuxt/live.cjs +1662 -0
- package/dist/nuxt/live.d.cts +43 -0
- package/dist/nuxt/live.d.ts +43 -0
- package/dist/nuxt/live.js +94 -0
- package/dist/{pixel-B3oQNbZ3.d.cts → pixel-CX422dCO.d.cts} +10 -1
- package/dist/{pixel-B3oQNbZ3.d.ts → pixel-CX422dCO.d.ts} +10 -1
- package/dist/react/components.cjs +1522 -359
- package/dist/react/components.d.cts +9 -0
- package/dist/react/components.d.ts +9 -0
- package/dist/react/components.js +1522 -359
- package/dist/sveltekit/index.cjs +1 -1
- package/dist/sveltekit/index.js +1 -1
- package/package.json +12 -1
- package/src/astro/PreprToolbar.astro +7 -1
package/dist/nextjs/index.d.cts
CHANGED
|
@@ -4,6 +4,8 @@ type Dictionary = Record<string, unknown>;
|
|
|
4
4
|
declare const dictionaries: {
|
|
5
5
|
en: Dictionary;
|
|
6
6
|
nl: Dictionary;
|
|
7
|
+
fr: Dictionary;
|
|
8
|
+
de: Dictionary;
|
|
7
9
|
};
|
|
8
10
|
type Locale = keyof typeof dictionaries;
|
|
9
11
|
|
|
@@ -70,6 +72,13 @@ interface PreprPreviewOptions extends PreprToolbarOptions {
|
|
|
70
72
|
* receives the field-edit events, which carry content item ids.
|
|
71
73
|
*/
|
|
72
74
|
allowedEditorOrigins?: string[];
|
|
75
|
+
/**
|
|
76
|
+
* Set when your preview token uses GraphQL strict mode, where required
|
|
77
|
+
* fields are never null. The editor then holds back new entries until
|
|
78
|
+
* their required fields are filled, and never sends a cleared required
|
|
79
|
+
* field as null.
|
|
80
|
+
*/
|
|
81
|
+
strictMode?: boolean;
|
|
73
82
|
/**
|
|
74
83
|
* Strip the invisible stega characters out of visible text at runtime.
|
|
75
84
|
* Default `true`.
|
|
@@ -154,6 +163,17 @@ interface PreprMiddlewareOptions {
|
|
|
154
163
|
declare function createPreprMiddleware(request: NextRequest, options?: PreprMiddlewareOptions): NextResponse;
|
|
155
164
|
declare function createPreprMiddleware(request: NextRequest, response: NextResponse, options?: PreprMiddlewareOptions): NextResponse;
|
|
156
165
|
|
|
166
|
+
/**
|
|
167
|
+
* What `normalizeQuery` accepts as the query: GraphQL source text, a parsed
|
|
168
|
+
* `DocumentNode` (from `graphql-tag`, Apollo or GraphQL Code Generator), or a
|
|
169
|
+
* string-like object such as codegen's `TypedDocumentString`.
|
|
170
|
+
*/
|
|
171
|
+
type QueryInput = string | {
|
|
172
|
+
kind: 'Document';
|
|
173
|
+
} | {
|
|
174
|
+
toString(): string;
|
|
175
|
+
};
|
|
176
|
+
|
|
157
177
|
/** Prepr Customer ID for the current request. Server-only. */
|
|
158
178
|
declare function getPreprUUID(): Promise<string | null>;
|
|
159
179
|
/** Active segment for the current request. Server-only. */
|
|
@@ -174,6 +194,28 @@ declare function getPreprHeaders(): Promise<PreprHeaders>;
|
|
|
174
194
|
* bad or missing token can't crash the host app.
|
|
175
195
|
*/
|
|
176
196
|
declare function getToolbarProps(token: string, features?: PreprFeatures): Promise<PreprToolbarProps>;
|
|
197
|
+
interface NextNormalizeQueryOptions {
|
|
198
|
+
/**
|
|
199
|
+
* Pass the same preview flag as the middleware; never `true` on a
|
|
200
|
+
* production deployment. When false (the default) the request is not read,
|
|
201
|
+
* so static and ISR pages stay static.
|
|
202
|
+
*/
|
|
203
|
+
enabled?: boolean;
|
|
204
|
+
/** Which operation to use when the document holds more than one. */
|
|
205
|
+
operationName?: string;
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Show the Prepr editor's unsaved changes in server components: pass the
|
|
209
|
+
* query and its result, and render what comes back.
|
|
210
|
+
*
|
|
211
|
+
* ```ts
|
|
212
|
+
* const page = await normalizeQuery(GetPageDocument, data, { enabled: isPreview });
|
|
213
|
+
* ```
|
|
214
|
+
*
|
|
215
|
+
* Needs `PreprRefresh` mounted, and `_id` selected on every item and
|
|
216
|
+
* component that should update. Server-only; Next.js 16+.
|
|
217
|
+
*/
|
|
218
|
+
declare function normalizeQuery<T>(query: QueryInput, result: T, options?: NextNormalizeQueryOptions): Promise<T>;
|
|
177
219
|
|
|
178
220
|
/** Error thrown by the token helpers and the segments fetch. */
|
|
179
221
|
declare class PreprError extends Error {
|
|
@@ -248,4 +290,34 @@ declare function PreprTrackingPixel({ id, config, }: PreprTrackingPixelProps): n
|
|
|
248
290
|
*/
|
|
249
291
|
declare function PreprToolbar({ options, ...props }: PreprToolbarComponentProps): null;
|
|
250
292
|
|
|
251
|
-
|
|
293
|
+
/** Executes a registered query. `query` is opaque — string or DocumentNode. */
|
|
294
|
+
interface LiveFetcher {
|
|
295
|
+
(query: unknown, variables?: Record<string, unknown>): Promise<unknown>;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
interface LivePreviewConfig {
|
|
299
|
+
/**
|
|
300
|
+
* Pass your preview flag; never `true` on a production deployment.
|
|
301
|
+
* Defaults to false: nothing starts and `useLive` is a passthrough.
|
|
302
|
+
*/
|
|
303
|
+
enabled?: boolean;
|
|
304
|
+
/** Runs registered queries against Prepr GraphQL in preview mode. */
|
|
305
|
+
fetcher?: LiveFetcher;
|
|
306
|
+
/** Exact editor origins, replacing the `*.prepr.io` default. */
|
|
307
|
+
allowedEditorOrigins?: string[];
|
|
308
|
+
/** Your preview token uses GraphQL strict mode; see the toolbar option. */
|
|
309
|
+
strictMode?: boolean;
|
|
310
|
+
}
|
|
311
|
+
interface PreprRefreshProps {
|
|
312
|
+
/** Pass your preview flag; never `true` on a production deployment. */
|
|
313
|
+
enabled?: boolean;
|
|
314
|
+
/** Your preview token uses GraphQL strict mode; see the toolbar option. */
|
|
315
|
+
strictMode?: boolean;
|
|
316
|
+
}
|
|
317
|
+
interface UseLiveOptions {
|
|
318
|
+
/** Query (string or DocumentNode) passed as-is to the fetcher. */
|
|
319
|
+
query?: unknown;
|
|
320
|
+
variables?: Record<string, unknown>;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
export { type LiveFetcher, type LivePreviewConfig, type NextNormalizeQueryOptions, PreprError, type PreprMiddlewareOptions, type PreprRefreshProps, PreprToolbar, PreprTrackingPixel, type PreprTrackingPixelProps, type UseLiveOptions, createPreprMiddleware, extractAccessToken, getActiveSegment, getActiveVariant, getPreprHeaders, getPreprUUID, getToolbarProps, normalizeQuery, validatePreprToken };
|
package/dist/nextjs/index.d.ts
CHANGED
|
@@ -4,6 +4,8 @@ type Dictionary = Record<string, unknown>;
|
|
|
4
4
|
declare const dictionaries: {
|
|
5
5
|
en: Dictionary;
|
|
6
6
|
nl: Dictionary;
|
|
7
|
+
fr: Dictionary;
|
|
8
|
+
de: Dictionary;
|
|
7
9
|
};
|
|
8
10
|
type Locale = keyof typeof dictionaries;
|
|
9
11
|
|
|
@@ -70,6 +72,13 @@ interface PreprPreviewOptions extends PreprToolbarOptions {
|
|
|
70
72
|
* receives the field-edit events, which carry content item ids.
|
|
71
73
|
*/
|
|
72
74
|
allowedEditorOrigins?: string[];
|
|
75
|
+
/**
|
|
76
|
+
* Set when your preview token uses GraphQL strict mode, where required
|
|
77
|
+
* fields are never null. The editor then holds back new entries until
|
|
78
|
+
* their required fields are filled, and never sends a cleared required
|
|
79
|
+
* field as null.
|
|
80
|
+
*/
|
|
81
|
+
strictMode?: boolean;
|
|
73
82
|
/**
|
|
74
83
|
* Strip the invisible stega characters out of visible text at runtime.
|
|
75
84
|
* Default `true`.
|
|
@@ -154,6 +163,17 @@ interface PreprMiddlewareOptions {
|
|
|
154
163
|
declare function createPreprMiddleware(request: NextRequest, options?: PreprMiddlewareOptions): NextResponse;
|
|
155
164
|
declare function createPreprMiddleware(request: NextRequest, response: NextResponse, options?: PreprMiddlewareOptions): NextResponse;
|
|
156
165
|
|
|
166
|
+
/**
|
|
167
|
+
* What `normalizeQuery` accepts as the query: GraphQL source text, a parsed
|
|
168
|
+
* `DocumentNode` (from `graphql-tag`, Apollo or GraphQL Code Generator), or a
|
|
169
|
+
* string-like object such as codegen's `TypedDocumentString`.
|
|
170
|
+
*/
|
|
171
|
+
type QueryInput = string | {
|
|
172
|
+
kind: 'Document';
|
|
173
|
+
} | {
|
|
174
|
+
toString(): string;
|
|
175
|
+
};
|
|
176
|
+
|
|
157
177
|
/** Prepr Customer ID for the current request. Server-only. */
|
|
158
178
|
declare function getPreprUUID(): Promise<string | null>;
|
|
159
179
|
/** Active segment for the current request. Server-only. */
|
|
@@ -174,6 +194,28 @@ declare function getPreprHeaders(): Promise<PreprHeaders>;
|
|
|
174
194
|
* bad or missing token can't crash the host app.
|
|
175
195
|
*/
|
|
176
196
|
declare function getToolbarProps(token: string, features?: PreprFeatures): Promise<PreprToolbarProps>;
|
|
197
|
+
interface NextNormalizeQueryOptions {
|
|
198
|
+
/**
|
|
199
|
+
* Pass the same preview flag as the middleware; never `true` on a
|
|
200
|
+
* production deployment. When false (the default) the request is not read,
|
|
201
|
+
* so static and ISR pages stay static.
|
|
202
|
+
*/
|
|
203
|
+
enabled?: boolean;
|
|
204
|
+
/** Which operation to use when the document holds more than one. */
|
|
205
|
+
operationName?: string;
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Show the Prepr editor's unsaved changes in server components: pass the
|
|
209
|
+
* query and its result, and render what comes back.
|
|
210
|
+
*
|
|
211
|
+
* ```ts
|
|
212
|
+
* const page = await normalizeQuery(GetPageDocument, data, { enabled: isPreview });
|
|
213
|
+
* ```
|
|
214
|
+
*
|
|
215
|
+
* Needs `PreprRefresh` mounted, and `_id` selected on every item and
|
|
216
|
+
* component that should update. Server-only; Next.js 16+.
|
|
217
|
+
*/
|
|
218
|
+
declare function normalizeQuery<T>(query: QueryInput, result: T, options?: NextNormalizeQueryOptions): Promise<T>;
|
|
177
219
|
|
|
178
220
|
/** Error thrown by the token helpers and the segments fetch. */
|
|
179
221
|
declare class PreprError extends Error {
|
|
@@ -248,4 +290,34 @@ declare function PreprTrackingPixel({ id, config, }: PreprTrackingPixelProps): n
|
|
|
248
290
|
*/
|
|
249
291
|
declare function PreprToolbar({ options, ...props }: PreprToolbarComponentProps): null;
|
|
250
292
|
|
|
251
|
-
|
|
293
|
+
/** Executes a registered query. `query` is opaque — string or DocumentNode. */
|
|
294
|
+
interface LiveFetcher {
|
|
295
|
+
(query: unknown, variables?: Record<string, unknown>): Promise<unknown>;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
interface LivePreviewConfig {
|
|
299
|
+
/**
|
|
300
|
+
* Pass your preview flag; never `true` on a production deployment.
|
|
301
|
+
* Defaults to false: nothing starts and `useLive` is a passthrough.
|
|
302
|
+
*/
|
|
303
|
+
enabled?: boolean;
|
|
304
|
+
/** Runs registered queries against Prepr GraphQL in preview mode. */
|
|
305
|
+
fetcher?: LiveFetcher;
|
|
306
|
+
/** Exact editor origins, replacing the `*.prepr.io` default. */
|
|
307
|
+
allowedEditorOrigins?: string[];
|
|
308
|
+
/** Your preview token uses GraphQL strict mode; see the toolbar option. */
|
|
309
|
+
strictMode?: boolean;
|
|
310
|
+
}
|
|
311
|
+
interface PreprRefreshProps {
|
|
312
|
+
/** Pass your preview flag; never `true` on a production deployment. */
|
|
313
|
+
enabled?: boolean;
|
|
314
|
+
/** Your preview token uses GraphQL strict mode; see the toolbar option. */
|
|
315
|
+
strictMode?: boolean;
|
|
316
|
+
}
|
|
317
|
+
interface UseLiveOptions {
|
|
318
|
+
/** Query (string or DocumentNode) passed as-is to the fetcher. */
|
|
319
|
+
query?: unknown;
|
|
320
|
+
variables?: Record<string, unknown>;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
export { type LiveFetcher, type LivePreviewConfig, type NextNormalizeQueryOptions, PreprError, type PreprMiddlewareOptions, type PreprRefreshProps, PreprToolbar, PreprTrackingPixel, type PreprTrackingPixelProps, type UseLiveOptions, createPreprMiddleware, extractAccessToken, getActiveSegment, getActiveVariant, getPreprHeaders, getPreprUUID, getToolbarProps, normalizeQuery, validatePreprToken };
|