@preprio/toolkit 0.5.0-rc.2 → 0.5.0-rc.4
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 +209 -10
- package/dist/astro/index.cjs +1194 -1
- package/dist/astro/index.d.cts +47 -1
- package/dist/astro/index.d.ts +47 -1
- package/dist/astro/index.js +1197 -1
- package/dist/chunk-46ISDRHT.js +26 -0
- package/dist/chunk-74KY5EAM.js +1219 -0
- package/dist/chunk-AHBN6FQP.js +184 -0
- package/dist/{chunk-FLPNN3CV.js → chunk-PDNCNTDB.js} +1370 -623
- package/dist/chunk-S3VT4UWM.js +75 -0
- package/dist/chunk-TG6N3C22.js +246 -0
- package/dist/chunk-URXSDJOU.js +356 -0
- package/dist/index.cjs +3166 -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-H4643QYF.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 +1085 -6
- package/dist/nextjs/index.d.cts +73 -1
- package/dist/nextjs/index.d.ts +73 -1
- package/dist/nextjs/index.js +1079 -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 +1896 -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-O2ZTJNW4.js +1520 -0
- package/dist/nuxt/live.cjs +1720 -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/astro/index.d.cts
CHANGED
|
@@ -79,6 +79,17 @@ interface PreprMiddlewareOptions {
|
|
|
79
79
|
version?: string;
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
+
/**
|
|
83
|
+
* What `normalizeQuery` accepts as the query: GraphQL source text, a parsed
|
|
84
|
+
* `DocumentNode` (from `graphql-tag`, Apollo or GraphQL Code Generator), or a
|
|
85
|
+
* string-like object such as codegen's `TypedDocumentString`.
|
|
86
|
+
*/
|
|
87
|
+
type QueryInput = string | {
|
|
88
|
+
kind: 'Document';
|
|
89
|
+
} | {
|
|
90
|
+
toString(): string;
|
|
91
|
+
};
|
|
92
|
+
|
|
82
93
|
/**
|
|
83
94
|
* Structural stand-in for Astro's `APIContext`, so this package needs no
|
|
84
95
|
* build-time dependency on `astro`. Only the fields `onPreprRequest` uses.
|
|
@@ -87,6 +98,8 @@ interface AstroLikeContext {
|
|
|
87
98
|
request: Request;
|
|
88
99
|
/** Unused; typed loosely so passing the real Astro context still checks. */
|
|
89
100
|
cookies?: unknown;
|
|
101
|
+
/** Per-request storage; carries the editor's unsaved changes in preview. */
|
|
102
|
+
locals?: object;
|
|
90
103
|
}
|
|
91
104
|
/** Astro middleware's `next()` — resolves to the `Response` from downstream. */
|
|
92
105
|
type AstroNext = () => Promise<Response>;
|
|
@@ -116,5 +129,38 @@ declare function getPreprHeaders(headers: Headers): PreprHeaders;
|
|
|
116
129
|
* its own.
|
|
117
130
|
*/
|
|
118
131
|
declare function getToolbarProps(headers: Headers, token: string, features?: PreprFeatures): Promise<PreprToolbarProps>;
|
|
132
|
+
interface AstroNormalizeQueryOptions {
|
|
133
|
+
/**
|
|
134
|
+
* Whether this render may show unsaved editor changes. Pass your preview
|
|
135
|
+
* flag, and never `true` on a production deployment. When false (the
|
|
136
|
+
* default) the result is returned untouched.
|
|
137
|
+
*/
|
|
138
|
+
enabled?: boolean;
|
|
139
|
+
/** `Astro.locals`, where `onPreprRequest` leaves the editor's changes. */
|
|
140
|
+
locals?: object;
|
|
141
|
+
/** Which operation to use when the document holds more than one. */
|
|
142
|
+
operationName?: string;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Show the Prepr editor's unsaved changes on a server-rendered Astro page:
|
|
146
|
+
* pass the query and the result you fetched (with any client), and render
|
|
147
|
+
* what comes back.
|
|
148
|
+
*
|
|
149
|
+
* ```astro
|
|
150
|
+
* ---
|
|
151
|
+
* const data = await fetchFromPrepr(GetPageDocument, { slug });
|
|
152
|
+
* const page = normalizeQuery(GetPageDocument, data, {
|
|
153
|
+
* enabled: preview,
|
|
154
|
+
* locals: Astro.locals,
|
|
155
|
+
* });
|
|
156
|
+
* ---
|
|
157
|
+
* ```
|
|
158
|
+
*
|
|
159
|
+
* Needs `onPreprRequest` with `preview: true` in your middleware and
|
|
160
|
+
* `PreprToolbar.astro` on the page; the toolbar re-requests the page with
|
|
161
|
+
* the editor's changes while they type. Select `_id` on every item and
|
|
162
|
+
* component that should update.
|
|
163
|
+
*/
|
|
164
|
+
declare function normalizeQuery<T>(query: QueryInput, result: T, options?: AstroNormalizeQueryOptions): T;
|
|
119
165
|
|
|
120
|
-
export { type AstroLikeContext, type AstroNext, type PreprMiddlewareOptions, getActiveSegment, getActiveVariant, getPreprHeaders, getPreprUUID, getToolbarProps, onPreprRequest };
|
|
166
|
+
export { type AstroLikeContext, type AstroNext, type AstroNormalizeQueryOptions, type PreprMiddlewareOptions, getActiveSegment, getActiveVariant, getPreprHeaders, getPreprUUID, getToolbarProps, normalizeQuery, onPreprRequest };
|
package/dist/astro/index.d.ts
CHANGED
|
@@ -79,6 +79,17 @@ interface PreprMiddlewareOptions {
|
|
|
79
79
|
version?: string;
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
+
/**
|
|
83
|
+
* What `normalizeQuery` accepts as the query: GraphQL source text, a parsed
|
|
84
|
+
* `DocumentNode` (from `graphql-tag`, Apollo or GraphQL Code Generator), or a
|
|
85
|
+
* string-like object such as codegen's `TypedDocumentString`.
|
|
86
|
+
*/
|
|
87
|
+
type QueryInput = string | {
|
|
88
|
+
kind: 'Document';
|
|
89
|
+
} | {
|
|
90
|
+
toString(): string;
|
|
91
|
+
};
|
|
92
|
+
|
|
82
93
|
/**
|
|
83
94
|
* Structural stand-in for Astro's `APIContext`, so this package needs no
|
|
84
95
|
* build-time dependency on `astro`. Only the fields `onPreprRequest` uses.
|
|
@@ -87,6 +98,8 @@ interface AstroLikeContext {
|
|
|
87
98
|
request: Request;
|
|
88
99
|
/** Unused; typed loosely so passing the real Astro context still checks. */
|
|
89
100
|
cookies?: unknown;
|
|
101
|
+
/** Per-request storage; carries the editor's unsaved changes in preview. */
|
|
102
|
+
locals?: object;
|
|
90
103
|
}
|
|
91
104
|
/** Astro middleware's `next()` — resolves to the `Response` from downstream. */
|
|
92
105
|
type AstroNext = () => Promise<Response>;
|
|
@@ -116,5 +129,38 @@ declare function getPreprHeaders(headers: Headers): PreprHeaders;
|
|
|
116
129
|
* its own.
|
|
117
130
|
*/
|
|
118
131
|
declare function getToolbarProps(headers: Headers, token: string, features?: PreprFeatures): Promise<PreprToolbarProps>;
|
|
132
|
+
interface AstroNormalizeQueryOptions {
|
|
133
|
+
/**
|
|
134
|
+
* Whether this render may show unsaved editor changes. Pass your preview
|
|
135
|
+
* flag, and never `true` on a production deployment. When false (the
|
|
136
|
+
* default) the result is returned untouched.
|
|
137
|
+
*/
|
|
138
|
+
enabled?: boolean;
|
|
139
|
+
/** `Astro.locals`, where `onPreprRequest` leaves the editor's changes. */
|
|
140
|
+
locals?: object;
|
|
141
|
+
/** Which operation to use when the document holds more than one. */
|
|
142
|
+
operationName?: string;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Show the Prepr editor's unsaved changes on a server-rendered Astro page:
|
|
146
|
+
* pass the query and the result you fetched (with any client), and render
|
|
147
|
+
* what comes back.
|
|
148
|
+
*
|
|
149
|
+
* ```astro
|
|
150
|
+
* ---
|
|
151
|
+
* const data = await fetchFromPrepr(GetPageDocument, { slug });
|
|
152
|
+
* const page = normalizeQuery(GetPageDocument, data, {
|
|
153
|
+
* enabled: preview,
|
|
154
|
+
* locals: Astro.locals,
|
|
155
|
+
* });
|
|
156
|
+
* ---
|
|
157
|
+
* ```
|
|
158
|
+
*
|
|
159
|
+
* Needs `onPreprRequest` with `preview: true` in your middleware and
|
|
160
|
+
* `PreprToolbar.astro` on the page; the toolbar re-requests the page with
|
|
161
|
+
* the editor's changes while they type. Select `_id` on every item and
|
|
162
|
+
* component that should update.
|
|
163
|
+
*/
|
|
164
|
+
declare function normalizeQuery<T>(query: QueryInput, result: T, options?: AstroNormalizeQueryOptions): T;
|
|
119
165
|
|
|
120
|
-
export { type AstroLikeContext, type AstroNext, type PreprMiddlewareOptions, getActiveSegment, getActiveVariant, getPreprHeaders, getPreprUUID, getToolbarProps, onPreprRequest };
|
|
166
|
+
export { type AstroLikeContext, type AstroNext, type AstroNormalizeQueryOptions, type PreprMiddlewareOptions, getActiveSegment, getActiveVariant, getPreprHeaders, getPreprUUID, getToolbarProps, normalizeQuery, onPreprRequest };
|