@wordpress/server-side-render 6.16.1-next.v.202602241322.0 → 6.16.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.
@@ -0,0 +1,68 @@
1
+ export declare function rendererPath(block: string, attributes?: Record<string, unknown> | null, urlQueryArgs?: Record<string, unknown>): string;
2
+ export declare function removeBlockSupportAttributes(attributes: Record<string, unknown> & {
3
+ style?: Record<string, unknown>;
4
+ }): Record<string, unknown>;
5
+ /**
6
+ * Server-side render response object.
7
+ */
8
+ export interface ServerSideRenderResponse {
9
+ /** The current request status: 'idle', 'loading', 'success', or 'error'. */
10
+ status: 'idle' | 'loading' | 'success' | 'error';
11
+ /** The rendered block content (available when status is 'success'). */
12
+ content?: string;
13
+ /** The error message (available when status is 'error'). */
14
+ error?: string;
15
+ }
16
+ /**
17
+ * Configuration object for the useServerSideRender hook.
18
+ */
19
+ export interface UseServerSideRenderArgs {
20
+ /** The block attributes to be sent to the server for rendering. */
21
+ attributes: Record<string, unknown>;
22
+ /** The identifier of the block to be serverside rendered. Example: 'core/archives'. */
23
+ block: string;
24
+ /** Whether to remove block support attributes before sending. */
25
+ skipBlockSupportAttributes?: boolean;
26
+ /** The HTTP method to use ('GET' or 'POST'). Default is 'GET'. */
27
+ httpMethod?: 'GET' | 'POST';
28
+ /** Additional query arguments to append to the request URL. */
29
+ urlQueryArgs?: Record<string, unknown>;
30
+ }
31
+ /**
32
+ * A hook for server-side rendering a preview of dynamic blocks to display in the editor.
33
+ *
34
+ * Handles fetching server-rendered previews for blocks, managing loading states,
35
+ * and automatically debouncing requests to prevent excessive API calls. It supports both
36
+ * GET and POST requests, with POST requests used for larger attribute payloads.
37
+ *
38
+ * @example
39
+ * Basic usage:
40
+ *
41
+ * ```jsx
42
+ * import { RawHTML } from '@wordpress/element';
43
+ * import { useServerSideRender } from '@wordpress/server-side-render';
44
+ *
45
+ * function MyServerSideRender( { attributes, block } ) {
46
+ * const { content, status, error } = useServerSideRender( {
47
+ * attributes,
48
+ * block,
49
+ * } );
50
+ *
51
+ * if ( status === 'loading' ) {
52
+ * return <div>Loading...</div>;
53
+ * }
54
+ *
55
+ * if ( status === 'error' ) {
56
+ * return <div>Error: { error }</div>;
57
+ * }
58
+ *
59
+ * return <RawHTML>{ content }</RawHTML>;
60
+ * }
61
+ * ```
62
+ *
63
+ * @param args The hook configuration object.
64
+ *
65
+ * @return The server-side render response object.
66
+ */
67
+ export declare function useServerSideRender(args: UseServerSideRenderArgs): ServerSideRenderResponse;
68
+ //# sourceMappingURL=hook.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hook.d.ts","sourceRoot":"","sources":["../src/hook.ts"],"names":[],"mappings":"AAUA,wBAAgB,YAAY,CAC3B,KAAK,EAAE,MAAM,EACb,UAAU,GAAE,MAAM,CAAE,MAAM,EAAE,OAAO,CAAE,GAAG,IAAW,EACnD,YAAY,GAAE,MAAM,CAAE,MAAM,EAAE,OAAO,CAAO,GAC1C,MAAM,CAMR;AAED,wBAAgB,4BAA4B,CAC3C,UAAU,EAAE,MAAM,CAAE,MAAM,EAAE,OAAO,CAAE,GAAG;IACvC,KAAK,CAAC,EAAE,MAAM,CAAE,MAAM,EAAE,OAAO,CAAE,CAAC;CAClC,GACC,MAAM,CAAE,MAAM,EAAE,OAAO,CAAE,CA0B3B;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACxC,4EAA4E;IAC5E,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,CAAC;IACjD,uEAAuE;IACvE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,4DAA4D;IAC5D,KAAK,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACvC,mEAAmE;IACnE,UAAU,EAAE,MAAM,CAAE,MAAM,EAAE,OAAO,CAAE,CAAC;IACtC,uFAAuF;IACvF,KAAK,EAAE,MAAM,CAAC;IACd,iEAAiE;IACjE,0BAA0B,CAAC,EAAE,OAAO,CAAC;IACrC,kEAAkE;IAClE,UAAU,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;IAC5B,+DAA+D;IAC/D,YAAY,CAAC,EAAE,MAAM,CAAE,MAAM,EAAE,OAAO,CAAE,CAAC;CACzC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,wBAAgB,mBAAmB,CAClC,IAAI,EAAE,uBAAuB,GAC3B,wBAAwB,CA2F1B"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Internal dependencies
3
+ */
4
+ import { ServerSideRenderWithPostId } from './server-side-render';
5
+ import { useServerSideRender } from './hook';
6
+ /**
7
+ * A compatibility layer for the `ServerSideRender` component when used with `wp` global namespace.
8
+ *
9
+ * @deprecated Use `ServerSideRender` non-default export instead.
10
+ *
11
+ * @example
12
+ * ```js
13
+ * import ServerSideRender from '@wordpress/server-side-render';
14
+ * ```
15
+ */
16
+ declare const ServerSideRenderCompat: typeof ServerSideRenderWithPostId & {
17
+ ServerSideRender: typeof ServerSideRenderWithPostId;
18
+ useServerSideRender: typeof useServerSideRender;
19
+ };
20
+ export { ServerSideRenderWithPostId as ServerSideRender };
21
+ export { useServerSideRender };
22
+ export default ServerSideRenderCompat;
23
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAClE,OAAO,EAAE,mBAAmB,EAAE,MAAM,QAAQ,CAAC;AAE7C;;;;;;;;;GASG;AACH,QAAA,MAAM,sBAAsB,EACG,OAAO,0BAA0B,GAAG;IACjE,gBAAgB,EAAE,OAAO,0BAA0B,CAAC;IACpD,mBAAmB,EAAE,OAAO,mBAAmB,CAAC;CAChD,CAAC;AAKH,OAAO,EAAE,0BAA0B,IAAI,gBAAgB,EAAE,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,CAAC;eAChB,sBAAsB"}
@@ -0,0 +1,32 @@
1
+ import type { ServerSideRenderProps, ServerSideRenderWithPostIdProps } from './types';
2
+ export declare function ServerSideRender(props: ServerSideRenderProps): import("react").JSX.Element;
3
+ /**
4
+ * A component that renders server-side content for blocks.
5
+ *
6
+ * Note: URL query will include the current post ID when applicable.
7
+ * This is useful for blocks that depend on the context of the current post for rendering.
8
+ *
9
+ * @example
10
+ * ```jsx
11
+ * import { ServerSideRender } from '@wordpress/server-side-render';
12
+ * // Legacy import for WordPress 6.8 and earlier
13
+ * // import { default as ServerSideRender } from '@wordpress/server-side-render';
14
+ *
15
+ * function Example() {
16
+ * return (
17
+ * <ServerSideRender
18
+ * block="core/archives"
19
+ * attributes={ { showPostCounts: true } }
20
+ * urlQueryArgs={ { customArg: 'value' } }
21
+ * className="custom-class"
22
+ * />
23
+ * );
24
+ * }
25
+ * ```
26
+ *
27
+ * @param props Component props.
28
+ * @param props.urlQueryArgs Additional query arguments to append to the request URL.
29
+ * @return The rendered server-side content.
30
+ */
31
+ export declare function ServerSideRenderWithPostId({ urlQueryArgs, ...props }: ServerSideRenderWithPostIdProps): import("react").JSX.Element;
32
+ //# sourceMappingURL=server-side-render.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server-side-render.d.ts","sourceRoot":"","sources":["../src/server-side-render.tsx"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAIX,qBAAqB,EACrB,+BAA+B,EAC/B,MAAM,SAAS,CAAC;AA2DjB,wBAAgB,gBAAgB,CAAE,KAAK,EAAE,qBAAqB,+BA4C7D;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,0BAA0B,CAAE,EAC3C,YAA2B,EAC3B,GAAG,KAAK,EACR,EAAE,+BAA+B,+BA2BjC"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import type React from 'react';
5
+ /**
6
+ * Internal dependencies
7
+ */
8
+ import type { UseServerSideRenderArgs } from './hook';
9
+ export interface PlaceholderProps {
10
+ /** Additional classes to apply to the wrapper element. */
11
+ className?: string;
12
+ }
13
+ export interface ErrorPlaceholderProps extends PlaceholderProps {
14
+ /** Error message describing the problem. */
15
+ message?: string;
16
+ }
17
+ export interface LoadingPlaceholderProps {
18
+ children?: React.ReactNode;
19
+ }
20
+ export interface ServerSideRenderProps extends UseServerSideRenderArgs {
21
+ /** Additional classes to apply to the wrapper element. */
22
+ className?: string;
23
+ /** Component rendered when the API response is empty. */
24
+ EmptyResponsePlaceholder?: React.ComponentType<PlaceholderProps>;
25
+ /** Component rendered when the API response is an error. */
26
+ ErrorResponsePlaceholder?: React.ComponentType<ErrorPlaceholderProps>;
27
+ /** Component rendered while the API request is loading. */
28
+ LoadingResponsePlaceholder?: React.ComponentType<LoadingPlaceholderProps>;
29
+ }
30
+ export interface ServerSideRenderWithPostIdProps extends Omit<ServerSideRenderProps, 'urlQueryArgs'> {
31
+ /** Additional query arguments to append to the request URL. */
32
+ urlQueryArgs?: Record<string, unknown>;
33
+ }
34
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B;;GAEG;AACH,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,QAAQ,CAAC;AAEtD,MAAM,WAAW,gBAAgB;IAChC,0DAA0D;IAC1D,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,qBAAsB,SAAQ,gBAAgB;IAC9D,4CAA4C;IAC5C,OAAO,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,uBAAuB;IACvC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAED,MAAM,WAAW,qBAAsB,SAAQ,uBAAuB;IACrE,0DAA0D;IAC1D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,yDAAyD;IACzD,wBAAwB,CAAC,EAAE,KAAK,CAAC,aAAa,CAAE,gBAAgB,CAAE,CAAC;IACnE,4DAA4D;IAC5D,wBAAwB,CAAC,EAAE,KAAK,CAAC,aAAa,CAAE,qBAAqB,CAAE,CAAC;IACxE,2DAA2D;IAC3D,0BAA0B,CAAC,EAAE,KAAK,CAAC,aAAa,CAAE,uBAAuB,CAAE,CAAC;CAC5E;AAED,MAAM,WAAW,+BAChB,SAAQ,IAAI,CAAE,qBAAqB,EAAE,cAAc,CAAE;IACrD,+DAA+D;IAC/D,YAAY,CAAC,EAAE,MAAM,CAAE,MAAM,EAAE,OAAO,CAAE,CAAC;CACzC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/server-side-render",
3
- "version": "6.16.1-next.v.202602241322.0+bce7cff88",
3
+ "version": "6.16.1",
4
4
  "description": "The component used with WordPress to server-side render a preview of dynamic blocks to display in the editor.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -43,15 +43,15 @@
43
43
  "wpScript": true,
44
44
  "wpScriptDefaultExport": true,
45
45
  "dependencies": {
46
- "@wordpress/api-fetch": "^7.40.1-next.v.202602241322.0+bce7cff88",
47
- "@wordpress/blocks": "^15.13.1-next.v.202602241322.0+bce7cff88",
48
- "@wordpress/components": "^32.3.1-next.v.202602241322.0+bce7cff88",
49
- "@wordpress/compose": "^7.40.1-next.v.202602241322.0+bce7cff88",
50
- "@wordpress/data": "^10.40.1-next.v.202602241322.0+bce7cff88",
51
- "@wordpress/deprecated": "^4.40.1-next.v.202602241322.0+bce7cff88",
52
- "@wordpress/element": "^6.40.1-next.v.202602241322.0+bce7cff88",
53
- "@wordpress/i18n": "^6.13.1-next.v.202602241322.0+bce7cff88",
54
- "@wordpress/url": "^4.40.1-next.v.202602241322.0+bce7cff88"
46
+ "@wordpress/api-fetch": "^7.40.1",
47
+ "@wordpress/blocks": "^15.13.1",
48
+ "@wordpress/components": "^32.2.1",
49
+ "@wordpress/compose": "^7.40.1",
50
+ "@wordpress/data": "^10.40.1",
51
+ "@wordpress/deprecated": "^4.40.1",
52
+ "@wordpress/element": "^6.40.1",
53
+ "@wordpress/i18n": "^6.13.1",
54
+ "@wordpress/url": "^4.40.1"
55
55
  },
56
56
  "peerDependencies": {
57
57
  "react": "^18.0.0",
@@ -60,5 +60,5 @@
60
60
  "publishConfig": {
61
61
  "access": "public"
62
62
  },
63
- "gitHead": "943dde7f0b600ce238726c36284bc9f70ce0ffa4"
63
+ "gitHead": "adb6623c9f32490cfc73c7ac7f122578c1f10c65"
64
64
  }