@wp-typia/block-types 0.2.3 → 0.3.0
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 +278 -15
- package/dist/block-editor/index.d.ts +7 -7
- package/dist/block-editor/index.js +7 -7
- package/dist/block-editor/style-attributes.d.ts +5 -5
- package/dist/blocks/bindings.d.ts +132 -0
- package/dist/blocks/bindings.js +598 -0
- package/dist/blocks/compatibility.d.ts +296 -0
- package/dist/blocks/compatibility.js +338 -0
- package/dist/blocks/index.d.ts +5 -2
- package/dist/blocks/index.js +5 -2
- package/dist/blocks/supports.d.ts +57 -5
- package/dist/blocks/supports.js +182 -0
- package/dist/blocks/variations.d.ts +84 -0
- package/dist/blocks/variations.js +298 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/package.json +18 -1
package/README.md
CHANGED
|
@@ -18,8 +18,11 @@ Shared WordPress block semantic types derived from Gutenberg source and unoffici
|
|
|
18
18
|
- `@wp-typia/block-types/block-editor/style-attributes`
|
|
19
19
|
- `@wp-typia/block-types/block-editor/typography`
|
|
20
20
|
- `@wp-typia/block-types/blocks`
|
|
21
|
+
- `@wp-typia/block-types/blocks/bindings`
|
|
22
|
+
- `@wp-typia/block-types/blocks/compatibility`
|
|
21
23
|
- `@wp-typia/block-types/blocks/registration`
|
|
22
24
|
- `@wp-typia/block-types/blocks/supports`
|
|
25
|
+
- `@wp-typia/block-types/blocks/variations`
|
|
23
26
|
|
|
24
27
|
## Current policy
|
|
25
28
|
|
|
@@ -43,6 +46,12 @@ Shared WordPress block semantic types derived from Gutenberg source and unoffici
|
|
|
43
46
|
migration-facing `BlockInstance`
|
|
44
47
|
- additive stable Core coverage for drop caps, spacing sizes, layout gaps,
|
|
45
48
|
duotone, per-side border widths, and `js` / `locking`
|
|
49
|
+
- a WordPress block API compatibility matrix for Supports, Variations, and
|
|
50
|
+
Bindings features that codegen and diagnostics can share
|
|
51
|
+
- typed Block Variations authoring helpers with static JavaScript registration
|
|
52
|
+
source generation
|
|
53
|
+
- typed Block Bindings source helpers with PHP/editor source generation and
|
|
54
|
+
`metadata.bindings` type helpers
|
|
46
55
|
|
|
47
56
|
## Registration facade
|
|
48
57
|
|
|
@@ -71,37 +80,118 @@ TypeScript installs surface the requirement explicitly.
|
|
|
71
80
|
Compatibility should track that floor unless the generated project dependency
|
|
72
81
|
matrix changes in the same release.
|
|
73
82
|
|
|
83
|
+
## WordPress block API compatibility
|
|
84
|
+
|
|
85
|
+
`@wp-typia/block-types/blocks/compatibility` exposes the shared compatibility
|
|
86
|
+
foundation used by future block Supports, Variations, and Bindings helpers.
|
|
87
|
+
The matrix records documented WordPress version floors, runtime surfaces, derived
|
|
88
|
+
attributes, fallback hints, and source URLs for feature checks.
|
|
89
|
+
|
|
90
|
+
```ts
|
|
91
|
+
import { createWordPressBlockApiCompatibilityManifest } from '@wp-typia/block-types/blocks/compatibility';
|
|
92
|
+
|
|
93
|
+
const manifest = createWordPressBlockApiCompatibilityManifest(
|
|
94
|
+
[
|
|
95
|
+
{ area: 'blockSupports', feature: 'allowedBlocks' },
|
|
96
|
+
{ area: 'blockBindings', feature: 'editorRegistration' },
|
|
97
|
+
],
|
|
98
|
+
{
|
|
99
|
+
minVersion: '6.7',
|
|
100
|
+
strict: true,
|
|
101
|
+
allowUnknownFutureKeys: false,
|
|
102
|
+
},
|
|
103
|
+
);
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Strict mode marks known unsupported features as errors and recommends skipping
|
|
107
|
+
generation. Non-strict mode downgrades them to warnings and recommends guarded
|
|
108
|
+
generation. Unknown future keys are guarded by default, or passed through only
|
|
109
|
+
when `allowUnknownFutureKeys` is enabled.
|
|
110
|
+
|
|
111
|
+
## Validation coverage
|
|
112
|
+
|
|
113
|
+
`@wp-typia/block-types` now validates itself with a mixed strategy that matches
|
|
114
|
+
the package surface:
|
|
115
|
+
|
|
116
|
+
- runtime/export-contract tests verify the published subpath map, ESM-safe
|
|
117
|
+
built re-exports, and the tuple/helper values that downstream packages import
|
|
118
|
+
at runtime
|
|
119
|
+
- compile-time fixture tests verify the most-used public type surfaces through
|
|
120
|
+
package-style imports, including block registration facades and style/support
|
|
121
|
+
helpers
|
|
122
|
+
|
|
123
|
+
This keeps the package failing fast on its own instead of relying on downstream
|
|
124
|
+
breakage in scaffold or runtime packages.
|
|
125
|
+
|
|
74
126
|
## WordPress style support helpers
|
|
75
127
|
|
|
76
|
-
The package now exposes
|
|
128
|
+
The package now exposes three complementary surfaces:
|
|
77
129
|
|
|
78
|
-
- `@wp-typia/block-types/blocks/supports` for typed `block.json` `supports
|
|
130
|
+
- `@wp-typia/block-types/blocks/supports` for typed `block.json` `supports`,
|
|
131
|
+
the `defineSupports()` helper, and `SupportAttributes<typeof supports>`
|
|
79
132
|
- `@wp-typia/block-types/block-editor/style-attributes` for the attribute and `style` shapes WordPress injects when those supports are enabled
|
|
133
|
+
- `@wp-typia/block-types/blocks/compatibility` for version-aware diagnostics
|
|
134
|
+
when a support key requires a newer WordPress floor
|
|
80
135
|
|
|
81
136
|
Example:
|
|
82
137
|
|
|
83
138
|
```ts
|
|
84
|
-
import
|
|
85
|
-
|
|
139
|
+
import {
|
|
140
|
+
defineSupports,
|
|
141
|
+
type SupportAttributes,
|
|
142
|
+
} from '@wp-typia/block-types/blocks/supports';
|
|
86
143
|
|
|
87
|
-
const supports
|
|
88
|
-
|
|
144
|
+
const supports = defineSupports({
|
|
145
|
+
minWordPress: '6.6',
|
|
146
|
+
color: { text: true, background: true },
|
|
89
147
|
spacing: {
|
|
90
148
|
padding: true,
|
|
91
|
-
|
|
92
|
-
|
|
149
|
+
margin: true,
|
|
150
|
+
blockGap: true,
|
|
151
|
+
},
|
|
152
|
+
typography: {
|
|
153
|
+
fontSize: true,
|
|
154
|
+
lineHeight: true,
|
|
155
|
+
letterSpacing: true,
|
|
156
|
+
textAlign: ['left', 'center'],
|
|
157
|
+
},
|
|
158
|
+
layout: {
|
|
159
|
+
default: {
|
|
160
|
+
type: 'constrained',
|
|
161
|
+
},
|
|
93
162
|
},
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
163
|
+
anchor: true,
|
|
164
|
+
html: false,
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
type OwnAttributes = {
|
|
168
|
+
content: string;
|
|
169
|
+
density: 'compact' | 'balanced' | 'airy';
|
|
97
170
|
};
|
|
98
171
|
|
|
99
|
-
type
|
|
100
|
-
BlockStyleSupportAttributes,
|
|
101
|
-
'backgroundColor' | 'fontSize' | 'style' | 'textColor'
|
|
102
|
-
>;
|
|
172
|
+
type BlockAttributes = OwnAttributes & SupportAttributes<typeof supports>;
|
|
103
173
|
```
|
|
104
174
|
|
|
175
|
+
`defineSupports()` returns a plain object that can be written directly to
|
|
176
|
+
`block.json.supports`; inline helper controls such as `minWordPress`, `strict`,
|
|
177
|
+
and `allowUnknownFutureKeys` are stripped from the returned metadata. The helper
|
|
178
|
+
stores its compatibility manifest on a non-enumerable symbol so generated JSON
|
|
179
|
+
stays clean while tests and codegen can still inspect diagnostics through
|
|
180
|
+
`getDefinedSupportsCompatibilityManifest()`.
|
|
181
|
+
|
|
182
|
+
Strict mode is enabled by default. Known support keys that require a newer
|
|
183
|
+
WordPress version throw, while `strict: false` reports warnings through
|
|
184
|
+
`onDiagnostic` and keeps the metadata pass-through. Unknown future top-level
|
|
185
|
+
support keys are rejected unless `allowUnknownFutureKeys` is enabled.
|
|
186
|
+
|
|
187
|
+
`SupportAttributes<typeof supports>` is intentionally conservative where
|
|
188
|
+
Gutenberg behavior is broad. Enabling color, spacing, typography, border,
|
|
189
|
+
dimensions, background, filter duotone, position, or shadow includes the shared
|
|
190
|
+
`style` attribute shape. Typography also exposes slug attributes such as
|
|
191
|
+
`fontSize` and `fontFamily` when typography support is enabled; the compatibility
|
|
192
|
+
matrix tracks version-gated typography keys like `textAlign` separately from
|
|
193
|
+
longstanding keys such as `dropCap`.
|
|
194
|
+
|
|
105
195
|
Stable Core coverage now also includes support/style helpers for layout
|
|
106
196
|
`rowGap` / `columnGap`, color `duotone`, per-side border widths, and other
|
|
107
197
|
recently stabilized support keys.
|
|
@@ -111,6 +201,179 @@ for blocks that compute style output on the server. This follows Gutenberg's
|
|
|
111
201
|
current experimental surface and should not be treated as a long-term
|
|
112
202
|
stability guarantee.
|
|
113
203
|
|
|
204
|
+
## WordPress block variation helpers
|
|
205
|
+
|
|
206
|
+
`@wp-typia/block-types/blocks/variations` provides a type-first layer over the
|
|
207
|
+
native Block Variations API. `defineVariation()` returns a plain variation
|
|
208
|
+
metadata object suitable for `registerBlockVariation(...)`; the target block name
|
|
209
|
+
and compatibility manifest are stored on a non-enumerable symbol so generated
|
|
210
|
+
registration code can still recover the block target.
|
|
211
|
+
|
|
212
|
+
Static registration source generation serializes JSON-compatible variation
|
|
213
|
+
metadata. Function-based `isActive` callbacks are accepted by the type helper,
|
|
214
|
+
but `createStaticBlockVariationRegistrationSource()` rejects them; use a dynamic
|
|
215
|
+
registration path aligned with the `blockVariations.phpVariationCallback`
|
|
216
|
+
compatibility entry when callbacks must stay executable.
|
|
217
|
+
|
|
218
|
+
```ts
|
|
219
|
+
import {
|
|
220
|
+
createStaticBlockVariationRegistrationSource,
|
|
221
|
+
defineVariation,
|
|
222
|
+
defineVariations,
|
|
223
|
+
} from '@wp-typia/block-types/blocks/variations';
|
|
224
|
+
|
|
225
|
+
type HeadingVariationAttributes = {
|
|
226
|
+
className?: string;
|
|
227
|
+
level?: number;
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
const paragraphVariation = defineVariation('core/paragraph', {
|
|
231
|
+
name: 'example-balanced-paragraph',
|
|
232
|
+
title: 'Balanced Paragraph',
|
|
233
|
+
attributes: {
|
|
234
|
+
className: 'is-style-example-balanced',
|
|
235
|
+
},
|
|
236
|
+
scope: ['inserter', 'transform'],
|
|
237
|
+
isActive: ['className'],
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
const headingVariation = defineVariation<HeadingVariationAttributes>(
|
|
241
|
+
'core/heading',
|
|
242
|
+
{
|
|
243
|
+
name: 'example-balanced-heading',
|
|
244
|
+
title: 'Balanced Heading',
|
|
245
|
+
attributes: {
|
|
246
|
+
className: 'is-style-example-heading',
|
|
247
|
+
level: 2,
|
|
248
|
+
},
|
|
249
|
+
scope: ['inserter', 'transform'],
|
|
250
|
+
isActive: ['className', 'level'],
|
|
251
|
+
},
|
|
252
|
+
);
|
|
253
|
+
|
|
254
|
+
const variations = defineVariations([
|
|
255
|
+
paragraphVariation,
|
|
256
|
+
headingVariation,
|
|
257
|
+
] as const);
|
|
258
|
+
|
|
259
|
+
const registrationSource =
|
|
260
|
+
createStaticBlockVariationRegistrationSource(variations);
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
Custom block variations use the same helper. Pass the custom block name and a
|
|
264
|
+
local attribute type when the variation should be checked against project-owned
|
|
265
|
+
metadata:
|
|
266
|
+
|
|
267
|
+
```ts
|
|
268
|
+
type TestimonialAttributes = {
|
|
269
|
+
className?: string;
|
|
270
|
+
layout?: 'quote' | 'card';
|
|
271
|
+
};
|
|
272
|
+
|
|
273
|
+
export const featuredTestimonialVariation =
|
|
274
|
+
defineVariation<TestimonialAttributes>('acme/testimonial', {
|
|
275
|
+
name: 'acme-featured-testimonial',
|
|
276
|
+
title: 'Featured Testimonial',
|
|
277
|
+
attributes: {
|
|
278
|
+
className: 'is-style-acme-featured',
|
|
279
|
+
layout: 'card',
|
|
280
|
+
},
|
|
281
|
+
isActive: ['className', 'layout'],
|
|
282
|
+
});
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
`defineVariation()` warns when active-state detection is missing or points at an
|
|
286
|
+
attribute not present in the variation metadata. Use `allowMissingIsActive: true`
|
|
287
|
+
for intentionally passive/default-style variations. `defineVariations()` detects
|
|
288
|
+
duplicate variation names and shared active discriminators for the same target
|
|
289
|
+
block.
|
|
290
|
+
|
|
291
|
+
Static code generation currently targets editor-side
|
|
292
|
+
`registerBlockVariation(...)` calls. Function-based `isActive` callbacks are
|
|
293
|
+
accepted by the type helper, but static source generation rejects them because
|
|
294
|
+
they cannot be represented safely as JSON-backed registration metadata. PHP or
|
|
295
|
+
dynamic variation registration remains scoped to a future helper built on the
|
|
296
|
+
existing `blockVariations.phpVariationCallback` compatibility entry.
|
|
297
|
+
|
|
298
|
+
## WordPress block binding helpers
|
|
299
|
+
|
|
300
|
+
`@wp-typia/block-types/blocks/bindings` provides a type-first layer for the
|
|
301
|
+
Block Bindings API. `defineBindingSource()` returns a plain source metadata
|
|
302
|
+
object, while compatibility diagnostics and codegen metadata are stored on a
|
|
303
|
+
non-enumerable symbol.
|
|
304
|
+
|
|
305
|
+
The helper tracks the documented WordPress floors for server registration
|
|
306
|
+
(`6.5`), editor registration (`6.7`), and editor field lists/custom bindable
|
|
307
|
+
attribute filters (`6.9`). Strict mode throws for unsupported combinations;
|
|
308
|
+
`strict: false` reports diagnostics and omits unsupported editor-only output.
|
|
309
|
+
|
|
310
|
+
```ts
|
|
311
|
+
import {
|
|
312
|
+
createEditorBindingSourceRegistrationSource,
|
|
313
|
+
createPhpBindingSourceRegistrationSource,
|
|
314
|
+
defineBindableAttributes,
|
|
315
|
+
defineBindingSource,
|
|
316
|
+
defineBlockMetadataBindings,
|
|
317
|
+
type Binding,
|
|
318
|
+
} from '@wp-typia/block-types/blocks/bindings';
|
|
319
|
+
|
|
320
|
+
type ProfileCardAttributes = {
|
|
321
|
+
imageUrl?: string;
|
|
322
|
+
};
|
|
323
|
+
|
|
324
|
+
const profileSource = defineBindingSource({
|
|
325
|
+
name: 'example/profile-data',
|
|
326
|
+
label: 'Profile Data',
|
|
327
|
+
getValueCallback: 'example_get_profile_binding_value',
|
|
328
|
+
usesContext: ['postId'],
|
|
329
|
+
minWordPress: {
|
|
330
|
+
server: '6.5',
|
|
331
|
+
editor: '6.7',
|
|
332
|
+
fieldsList: '6.9',
|
|
333
|
+
supportedAttributesFilter: '6.9',
|
|
334
|
+
},
|
|
335
|
+
args: {
|
|
336
|
+
field: 'image_url' as 'display_name' | 'image_url',
|
|
337
|
+
},
|
|
338
|
+
fields: [
|
|
339
|
+
{
|
|
340
|
+
name: 'display_name',
|
|
341
|
+
label: 'Display name',
|
|
342
|
+
args: { field: 'display_name' },
|
|
343
|
+
type: 'string',
|
|
344
|
+
},
|
|
345
|
+
{
|
|
346
|
+
name: 'image_url',
|
|
347
|
+
label: 'Image URL',
|
|
348
|
+
args: { field: 'image_url' },
|
|
349
|
+
type: 'string',
|
|
350
|
+
},
|
|
351
|
+
],
|
|
352
|
+
bindableAttributes: [
|
|
353
|
+
defineBindableAttributes<ProfileCardAttributes>('example/profile-card', [
|
|
354
|
+
'imageUrl',
|
|
355
|
+
] as const),
|
|
356
|
+
],
|
|
357
|
+
});
|
|
358
|
+
|
|
359
|
+
const metadata = defineBlockMetadataBindings({
|
|
360
|
+
imageUrl: {
|
|
361
|
+
source: profileSource.name,
|
|
362
|
+
args: { field: 'image_url' },
|
|
363
|
+
} satisfies Binding<typeof profileSource, { field: 'image_url' }>,
|
|
364
|
+
});
|
|
365
|
+
|
|
366
|
+
const phpSource = createPhpBindingSourceRegistrationSource(profileSource);
|
|
367
|
+
const editorSource = createEditorBindingSourceRegistrationSource(profileSource);
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
The generated PHP registers `register_block_bindings_source()` on `init` and,
|
|
371
|
+
when custom bindable attributes are declared, adds the
|
|
372
|
+
`block_bindings_supported_attributes_{$block_type}` filter behind a WordPress
|
|
373
|
+
6.9-compatible guard. The generated editor source registers
|
|
374
|
+
`registerBlockBindingsSource()` and emits `getFieldsList()` only when the
|
|
375
|
+
source compatibility manifest marks field lists as supported.
|
|
376
|
+
|
|
114
377
|
## Typia pipeline notes
|
|
115
378
|
|
|
116
379
|
- `CssColorValue` and `MinHeightValue` are richer DX aliases that currently rely on template literal types.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export * from "./alignment";
|
|
2
|
-
export * from "./color";
|
|
3
|
-
export * from "./dimensions";
|
|
4
|
-
export * from "./layout";
|
|
5
|
-
export * from "./spacing";
|
|
6
|
-
export * from "./style-attributes";
|
|
7
|
-
export * from "./typography";
|
|
1
|
+
export * from "./alignment.js";
|
|
2
|
+
export * from "./color.js";
|
|
3
|
+
export * from "./dimensions.js";
|
|
4
|
+
export * from "./layout.js";
|
|
5
|
+
export * from "./spacing.js";
|
|
6
|
+
export * from "./style-attributes.js";
|
|
7
|
+
export * from "./typography.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export * from "./alignment";
|
|
2
|
-
export * from "./color";
|
|
3
|
-
export * from "./dimensions";
|
|
4
|
-
export * from "./layout";
|
|
5
|
-
export * from "./spacing";
|
|
6
|
-
export * from "./style-attributes";
|
|
7
|
-
export * from "./typography";
|
|
1
|
+
export * from "./alignment.js";
|
|
2
|
+
export * from "./color.js";
|
|
3
|
+
export * from "./dimensions.js";
|
|
4
|
+
export * from "./layout.js";
|
|
5
|
+
export * from "./spacing.js";
|
|
6
|
+
export * from "./style-attributes.js";
|
|
7
|
+
export * from "./typography.js";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { TextAlignment } from
|
|
2
|
-
import type { CssColorValue } from
|
|
3
|
-
import type { AspectRatio, MinHeightKeyword, MinHeightValue } from
|
|
4
|
-
import type { SpacingDimension } from
|
|
5
|
-
import type { FontStyle, TextDecoration, TextTransform, WritingMode } from
|
|
1
|
+
import type { TextAlignment } from "./alignment.js";
|
|
2
|
+
import type { CssColorValue } from "./color.js";
|
|
3
|
+
import type { AspectRatio, MinHeightKeyword, MinHeightValue } from "./dimensions.js";
|
|
4
|
+
import type { SpacingDimension } from "./spacing.js";
|
|
5
|
+
import type { FontStyle, TextDecoration, TextTransform, WritingMode } from "./typography.js";
|
|
6
6
|
export type PresetColorReference = `var:preset|color|${string}`;
|
|
7
7
|
export type PresetDuotoneReference = `var:preset|duotone|${string}`;
|
|
8
8
|
export type PresetGradientReference = `var:preset|gradient|${string}`;
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import type { BlockAttributes } from "./registration.js";
|
|
2
|
+
import { type WordPressBlockApiCompatibilityDiagnostic, type WordPressBlockApiCompatibilityFeature, type WordPressBlockApiCompatibilityManifest, type WordPressCompatibilitySettings, type WordPressVersion } from "./compatibility.js";
|
|
3
|
+
export type BindingSourceName = `${string}/${string}`;
|
|
4
|
+
export type BindingSourceArgs = Readonly<Record<string, unknown>>;
|
|
5
|
+
export type BindingFieldType = "array" | "boolean" | "integer" | "number" | "object" | "string";
|
|
6
|
+
export interface BindingSourceField<TArgs extends BindingSourceArgs = BindingSourceArgs> {
|
|
7
|
+
readonly args?: TArgs;
|
|
8
|
+
readonly label: string;
|
|
9
|
+
readonly name: string;
|
|
10
|
+
readonly type?: BindingFieldType;
|
|
11
|
+
}
|
|
12
|
+
export type BlockBindingAttributeName<TAttributes extends BlockAttributes = BlockAttributes> = Extract<Exclude<keyof TAttributes, "metadata">, string>;
|
|
13
|
+
export interface BindingSourceBindableAttributes<TAttributes extends BlockAttributes = BlockAttributes, TBlockName extends string = string, TAttributesList extends readonly BlockBindingAttributeName<TAttributes>[] = readonly BlockBindingAttributeName<TAttributes>[]> {
|
|
14
|
+
readonly attributes: TAttributesList;
|
|
15
|
+
readonly blockName: TBlockName;
|
|
16
|
+
}
|
|
17
|
+
export interface BindingSourceDefinition<TName extends string = string, TArgs extends BindingSourceArgs = BindingSourceArgs, TFields extends readonly BindingSourceField[] = readonly BindingSourceField[]> {
|
|
18
|
+
readonly args?: TArgs;
|
|
19
|
+
readonly bindableAttributes?: readonly BindingSourceBindableAttributes[];
|
|
20
|
+
readonly fields?: TFields;
|
|
21
|
+
readonly getValueCallback?: string;
|
|
22
|
+
readonly label?: string;
|
|
23
|
+
readonly name: TName;
|
|
24
|
+
readonly usesContext?: readonly string[];
|
|
25
|
+
}
|
|
26
|
+
export interface BindingSourceVersionGates {
|
|
27
|
+
readonly editor?: WordPressVersion;
|
|
28
|
+
readonly fieldsList?: WordPressVersion;
|
|
29
|
+
readonly server?: WordPressVersion;
|
|
30
|
+
readonly supportedAttributesFilter?: WordPressVersion;
|
|
31
|
+
}
|
|
32
|
+
export interface DefineBindingSourceInlineOptions {
|
|
33
|
+
readonly allowUnknownFutureKeys?: boolean;
|
|
34
|
+
readonly editor?: boolean;
|
|
35
|
+
readonly fieldsList?: boolean;
|
|
36
|
+
readonly minVersion?: WordPressVersion;
|
|
37
|
+
readonly minWordPress?: WordPressVersion | BindingSourceVersionGates;
|
|
38
|
+
readonly minWordPressEditor?: WordPressVersion;
|
|
39
|
+
readonly minWordPressFieldsList?: WordPressVersion;
|
|
40
|
+
readonly minWordPressServer?: WordPressVersion;
|
|
41
|
+
readonly minWordPressSupportedAttributesFilter?: WordPressVersion;
|
|
42
|
+
readonly onDiagnostic?: (diagnostic: BindingSourceDiagnostic) => void;
|
|
43
|
+
readonly server?: boolean;
|
|
44
|
+
readonly strict?: boolean;
|
|
45
|
+
readonly supportedAttributesFilter?: boolean;
|
|
46
|
+
}
|
|
47
|
+
export interface DefineBindingSourceOptions extends WordPressCompatibilitySettings {
|
|
48
|
+
readonly editor?: boolean;
|
|
49
|
+
readonly fieldsList?: boolean;
|
|
50
|
+
readonly minWordPress?: WordPressVersion | BindingSourceVersionGates;
|
|
51
|
+
readonly minWordPressEditor?: WordPressVersion;
|
|
52
|
+
readonly minWordPressFieldsList?: WordPressVersion;
|
|
53
|
+
readonly minWordPressServer?: WordPressVersion;
|
|
54
|
+
readonly minWordPressSupportedAttributesFilter?: WordPressVersion;
|
|
55
|
+
readonly onDiagnostic?: (diagnostic: BindingSourceDiagnostic) => void;
|
|
56
|
+
readonly server?: boolean;
|
|
57
|
+
readonly supportedAttributesFilter?: boolean;
|
|
58
|
+
}
|
|
59
|
+
export type StripDefineBindingSourceOptions<TSource> = Omit<TSource, keyof DefineBindingSourceInlineOptions>;
|
|
60
|
+
export declare const DEFINED_BLOCK_BINDING_SOURCE_METADATA: unique symbol;
|
|
61
|
+
export type DefinedBlockBindingSourceMetadataKey = typeof DEFINED_BLOCK_BINDING_SOURCE_METADATA;
|
|
62
|
+
export interface DefinedBlockBindingSourceMetadata {
|
|
63
|
+
readonly diagnostics: readonly BindingSourceDiagnostic[];
|
|
64
|
+
readonly features: readonly WordPressBlockApiCompatibilityFeature[];
|
|
65
|
+
readonly manifest: WordPressBlockApiCompatibilityManifest;
|
|
66
|
+
}
|
|
67
|
+
export type DefinedBindingSource<TName extends string = string, TArgs extends BindingSourceArgs = BindingSourceArgs, TFields extends readonly BindingSourceField[] = readonly BindingSourceField[], TSource extends BindingSourceDefinition = BindingSourceDefinition> = Readonly<StripDefineBindingSourceOptions<TSource>> & {
|
|
68
|
+
readonly [DEFINED_BLOCK_BINDING_SOURCE_METADATA]?: DefinedBlockBindingSourceMetadata | undefined;
|
|
69
|
+
readonly __wpTypiaBindingSourceArgs?: TArgs;
|
|
70
|
+
readonly __wpTypiaBindingSourceFields?: TFields;
|
|
71
|
+
readonly name: TName;
|
|
72
|
+
};
|
|
73
|
+
export interface BlockBinding<TSourceName extends string = string, TArgs extends BindingSourceArgs = BindingSourceArgs> {
|
|
74
|
+
readonly args?: TArgs;
|
|
75
|
+
readonly source: TSourceName;
|
|
76
|
+
}
|
|
77
|
+
type BindingSourceInferredArgs<TSource> = TSource extends {
|
|
78
|
+
readonly __wpTypiaBindingSourceArgs?: infer TArgs extends BindingSourceArgs;
|
|
79
|
+
} ? TArgs : BindingSourceArgs;
|
|
80
|
+
export type Binding<TSource extends DefinedBindingSource | string, TArgs extends BindingSourceArgs = BindingSourceInferredArgs<TSource>> = TSource extends DefinedBindingSource<infer TName, infer TSourceArgs> ? TArgs extends TSourceArgs ? BlockBinding<TName, TArgs> : never : TSource extends string ? BlockBinding<TSource, TArgs> : never;
|
|
81
|
+
export type BlockBindingMap<TAttributes extends BlockAttributes = BlockAttributes> = Readonly<Partial<Record<BlockBindingAttributeName<TAttributes>, BlockBinding>>>;
|
|
82
|
+
export interface BlockMetadataBindings<TBindings extends Readonly<Record<string, BlockBinding | undefined>> = Readonly<Record<string, BlockBinding>>> {
|
|
83
|
+
readonly bindings?: TBindings;
|
|
84
|
+
}
|
|
85
|
+
export type TypedBlockMetadataBindings<TAttributes extends BlockAttributes, TBindings extends BlockBindingMap<TAttributes> = BlockBindingMap<TAttributes>> = BlockMetadataBindings<TBindings>;
|
|
86
|
+
export type BindingSourceDiagnosticCode = "duplicate-bindable-attribute" | "duplicate-field-name" | "fields-list-requires-editor" | "invalid-bindable-attribute" | "invalid-block-name" | "invalid-field-name" | "invalid-source-name" | "missing-php-callback";
|
|
87
|
+
export interface BindingSourceAuthoringDiagnostic {
|
|
88
|
+
readonly attribute?: string | undefined;
|
|
89
|
+
readonly blockName?: string | undefined;
|
|
90
|
+
readonly code: BindingSourceDiagnosticCode;
|
|
91
|
+
readonly fieldName?: string | undefined;
|
|
92
|
+
readonly message: string;
|
|
93
|
+
readonly severity: "error" | "warning";
|
|
94
|
+
readonly sourceName: string;
|
|
95
|
+
}
|
|
96
|
+
export type BindingSourceDiagnostic = BindingSourceAuthoringDiagnostic | WordPressBlockApiCompatibilityDiagnostic;
|
|
97
|
+
export interface BindingSourceRegistrationEntry {
|
|
98
|
+
readonly metadata: DefinedBlockBindingSourceMetadata;
|
|
99
|
+
readonly source: DefinedBindingSource;
|
|
100
|
+
}
|
|
101
|
+
export interface CreatePhpBindingSourceRegistrationSourceOptions {
|
|
102
|
+
readonly functionName?: string;
|
|
103
|
+
readonly hook?: string;
|
|
104
|
+
readonly includeOpeningTag?: boolean;
|
|
105
|
+
readonly textDomain?: string;
|
|
106
|
+
}
|
|
107
|
+
export interface CreateEditorBindingSourceRegistrationSourceOptions {
|
|
108
|
+
readonly functionName?: string;
|
|
109
|
+
readonly importSource?: string;
|
|
110
|
+
}
|
|
111
|
+
export declare function collectBindingSourceCompatibilityFeatures(settings?: {
|
|
112
|
+
readonly editor?: boolean;
|
|
113
|
+
readonly fieldsList?: boolean;
|
|
114
|
+
readonly metadata?: boolean;
|
|
115
|
+
readonly server?: boolean;
|
|
116
|
+
readonly supportedAttributesFilter?: boolean;
|
|
117
|
+
}): readonly WordPressBlockApiCompatibilityFeature[];
|
|
118
|
+
export declare function createBindingSourceCompatibilityManifest(settings?: DefineBindingSourceOptions): WordPressBlockApiCompatibilityManifest;
|
|
119
|
+
export declare function getDefinedBindingSourceMetadata(source: unknown): DefinedBlockBindingSourceMetadata | undefined;
|
|
120
|
+
export declare function getDefinedBindingSourceCompatibilityManifest(source: unknown): WordPressBlockApiCompatibilityManifest | undefined;
|
|
121
|
+
export declare function defineBindingSource<const TSource extends BindingSourceDefinition & DefineBindingSourceInlineOptions>(source: TSource, options?: DefineBindingSourceOptions): DefinedBindingSource<Extract<TSource["name"], string>, TSource extends {
|
|
122
|
+
readonly args: infer TArgs extends BindingSourceArgs;
|
|
123
|
+
} ? TArgs : BindingSourceArgs, TSource extends {
|
|
124
|
+
readonly fields: infer TFields extends readonly BindingSourceField[];
|
|
125
|
+
} ? TFields : readonly BindingSourceField[], TSource>;
|
|
126
|
+
export declare function defineBindableAttributes<TAttributes extends BlockAttributes = BlockAttributes, const TBlockName extends string = string, const TAttributesList extends readonly BlockBindingAttributeName<TAttributes>[] = readonly BlockBindingAttributeName<TAttributes>[]>(blockName: TBlockName, attributes: TAttributesList): BindingSourceBindableAttributes<TAttributes, TBlockName, TAttributesList>;
|
|
127
|
+
export declare function defineBlockMetadataBindings<const TBindings extends Readonly<Record<string, BlockBinding | undefined>>>(bindings: TBindings): BlockMetadataBindings<TBindings>;
|
|
128
|
+
export declare function defineTypedBlockMetadataBindings<TAttributes extends BlockAttributes, const TBindings extends BlockBindingMap<TAttributes> = BlockBindingMap<TAttributes>>(bindings: TBindings): TypedBlockMetadataBindings<TAttributes, TBindings>;
|
|
129
|
+
export declare function createBindingSourceRegistrationPlan(sources: readonly DefinedBindingSource[]): readonly BindingSourceRegistrationEntry[];
|
|
130
|
+
export declare function createPhpBindingSourceRegistrationSource(sources: DefinedBindingSource | readonly DefinedBindingSource[], options?: CreatePhpBindingSourceRegistrationSourceOptions): string;
|
|
131
|
+
export declare function createEditorBindingSourceRegistrationSource(sources: DefinedBindingSource | readonly DefinedBindingSource[], options?: CreateEditorBindingSourceRegistrationSourceOptions): string;
|
|
132
|
+
export {};
|