@wp-typia/block-types 0.2.4 → 0.3.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 +309 -15
- package/dist/blocks/bindings-codegen.d.ts +13 -0
- package/dist/blocks/bindings-codegen.js +210 -0
- package/dist/blocks/bindings-core.d.ts +123 -0
- package/dist/blocks/bindings-core.js +351 -0
- package/dist/blocks/bindings.d.ts +2 -0
- package/dist/blocks/bindings.js +2 -0
- package/dist/blocks/compatibility.d.ts +296 -0
- package/dist/blocks/compatibility.js +338 -0
- package/dist/blocks/index.d.ts +3 -0
- package/dist/blocks/index.js +3 -0
- package/dist/blocks/shared/diagnostics.d.ts +13 -0
- package/dist/blocks/shared/diagnostics.js +19 -0
- package/dist/blocks/shared/object-utils.d.ts +2 -0
- package/dist/blocks/shared/object-utils.js +10 -0
- package/dist/blocks/shared/static-registration.d.ts +4 -0
- package/dist/blocks/shared/static-registration.js +32 -0
- package/dist/blocks/supports.d.ts +57 -2
- package/dist/blocks/supports.js +172 -0
- package/dist/blocks/variations.d.ts +87 -0
- package/dist/blocks/variations.js +258 -0
- package/package.json +16 -1
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
export type WordPressVersion = `${number}.${number}` | `${number}.${number}.${number}`;
|
|
2
|
+
export type WordPressBlockApiCompatibilityArea = 'blockSupports' | 'blockVariations' | 'blockBindings';
|
|
3
|
+
export type WordPressBlockApiRuntime = 'block-json' | 'editor-js' | 'php';
|
|
4
|
+
export type WordPressBlockApiCompatibilityStatus = 'supported' | 'unsupported' | 'unknown';
|
|
5
|
+
export type WordPressBlockApiCompatibilityDiagnosticSeverity = 'error' | 'warning';
|
|
6
|
+
export type WordPressBlockApiCompatibilityAction = 'generate' | 'guard' | 'skip' | 'pass-through';
|
|
7
|
+
export interface WordPressBlockApiCompatibilityEntry {
|
|
8
|
+
readonly since: WordPressVersion;
|
|
9
|
+
readonly label: string;
|
|
10
|
+
readonly runtime: readonly WordPressBlockApiRuntime[];
|
|
11
|
+
readonly source: keyof typeof WORDPRESS_BLOCK_API_COMPATIBILITY_SOURCES;
|
|
12
|
+
readonly derivedAttributes?: readonly string[];
|
|
13
|
+
readonly fallback?: string;
|
|
14
|
+
readonly notes?: string;
|
|
15
|
+
}
|
|
16
|
+
export interface WordPressCompatibilitySettings {
|
|
17
|
+
readonly minVersion?: WordPressVersion;
|
|
18
|
+
readonly strict?: boolean;
|
|
19
|
+
readonly allowUnknownFutureKeys?: boolean;
|
|
20
|
+
}
|
|
21
|
+
export interface WordPressBlockApiCompatibilityFeature {
|
|
22
|
+
readonly area: WordPressBlockApiCompatibilityArea;
|
|
23
|
+
readonly feature: string;
|
|
24
|
+
}
|
|
25
|
+
export interface WordPressBlockApiCompatibilityDiagnostic {
|
|
26
|
+
readonly area: WordPressBlockApiCompatibilityArea;
|
|
27
|
+
readonly code: 'unsupported-wordpress-block-api-feature' | 'unknown-wordpress-block-api-feature';
|
|
28
|
+
readonly feature: string;
|
|
29
|
+
readonly message: string;
|
|
30
|
+
readonly minVersion: WordPressVersion;
|
|
31
|
+
readonly requiredVersion?: WordPressVersion;
|
|
32
|
+
readonly severity: WordPressBlockApiCompatibilityDiagnosticSeverity;
|
|
33
|
+
}
|
|
34
|
+
export interface WordPressBlockApiCompatibilityEvaluation extends WordPressBlockApiCompatibilityFeature {
|
|
35
|
+
readonly action: WordPressBlockApiCompatibilityAction;
|
|
36
|
+
readonly entry?: WordPressBlockApiCompatibilityEntry | undefined;
|
|
37
|
+
readonly diagnostic?: WordPressBlockApiCompatibilityDiagnostic | undefined;
|
|
38
|
+
readonly minVersion: WordPressVersion;
|
|
39
|
+
readonly status: WordPressBlockApiCompatibilityStatus;
|
|
40
|
+
}
|
|
41
|
+
export interface WordPressBlockApiCompatibilityManifest {
|
|
42
|
+
readonly allowUnknownFutureKeys: boolean;
|
|
43
|
+
readonly diagnostics: readonly WordPressBlockApiCompatibilityDiagnostic[];
|
|
44
|
+
readonly evaluations: readonly WordPressBlockApiCompatibilityEvaluation[];
|
|
45
|
+
readonly minVersion: WordPressVersion;
|
|
46
|
+
readonly strict: boolean;
|
|
47
|
+
readonly supported: readonly WordPressBlockApiCompatibilityEvaluation[];
|
|
48
|
+
readonly unknown: readonly WordPressBlockApiCompatibilityEvaluation[];
|
|
49
|
+
readonly unsupported: readonly WordPressBlockApiCompatibilityEvaluation[];
|
|
50
|
+
}
|
|
51
|
+
export declare const DEFAULT_WORDPRESS_COMPATIBILITY_MIN_VERSION: "6.7";
|
|
52
|
+
export declare const WORDPRESS_VERSION_PATTERN: RegExp;
|
|
53
|
+
export declare const WORDPRESS_BLOCK_API_COMPATIBILITY_SOURCES: {
|
|
54
|
+
readonly blockBindingsHandbook: "https://developer.wordpress.org/block-editor/reference-guides/block-api/block-bindings/";
|
|
55
|
+
readonly blockBindingsReference: "https://developer.wordpress.org/reference/functions/register_block_bindings_source/";
|
|
56
|
+
readonly blockBindingsSupportedAttributes: "https://developer.wordpress.org/reference/functions/get_block_bindings_supported_attributes/";
|
|
57
|
+
readonly blockSupportsHandbook: "https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/";
|
|
58
|
+
readonly blockVariationsDevNote: "https://make.wordpress.org/core/2020/02/27/introduce-block-variations-api/";
|
|
59
|
+
readonly blockVariationsPhpDevNote: "https://make.wordpress.org/core/2024/02/29/performance-improvements-for-registering-block-variations-with-callbacks/";
|
|
60
|
+
readonly themeJsonStyleVersions: "https://developer.wordpress.org/block-editor/reference-guides/theme-json-reference/styles-versions/";
|
|
61
|
+
readonly wordpressBlocksPackage: "https://developer.wordpress.org/block-editor/reference-guides/packages/packages-blocks/";
|
|
62
|
+
};
|
|
63
|
+
export declare const WORDPRESS_BLOCK_API_COMPATIBILITY: {
|
|
64
|
+
readonly blockBindings: {
|
|
65
|
+
readonly 'metadata.bindings': {
|
|
66
|
+
readonly derivedAttributes: readonly ["metadata"];
|
|
67
|
+
readonly label: "block metadata.bindings";
|
|
68
|
+
readonly runtime: readonly ["block-json", "php"];
|
|
69
|
+
readonly since: "6.5";
|
|
70
|
+
readonly source: "blockBindingsHandbook";
|
|
71
|
+
};
|
|
72
|
+
readonly editorRegistration: {
|
|
73
|
+
readonly fallback: "Keep server-side registration only.";
|
|
74
|
+
readonly label: "registerBlockBindingsSource() editor registration";
|
|
75
|
+
readonly runtime: readonly ["editor-js"];
|
|
76
|
+
readonly since: "6.7";
|
|
77
|
+
readonly source: "wordpressBlocksPackage";
|
|
78
|
+
};
|
|
79
|
+
readonly editorFieldsList: {
|
|
80
|
+
readonly fallback: "Register the source without getFieldsList() or keep a custom editor UI.";
|
|
81
|
+
readonly label: "registerBlockBindingsSource() getFieldsList()";
|
|
82
|
+
readonly runtime: readonly ["editor-js"];
|
|
83
|
+
readonly since: "6.9";
|
|
84
|
+
readonly source: "blockBindingsHandbook";
|
|
85
|
+
};
|
|
86
|
+
readonly editorSourceLookup: {
|
|
87
|
+
readonly label: "getBlockBindingsSource() and getBlockBindingsSources()";
|
|
88
|
+
readonly runtime: readonly ["editor-js"];
|
|
89
|
+
readonly since: "6.7";
|
|
90
|
+
readonly source: "wordpressBlocksPackage";
|
|
91
|
+
};
|
|
92
|
+
readonly serverRegistration: {
|
|
93
|
+
readonly label: "register_block_bindings_source()";
|
|
94
|
+
readonly runtime: readonly ["php"];
|
|
95
|
+
readonly since: "6.5";
|
|
96
|
+
readonly source: "blockBindingsReference";
|
|
97
|
+
};
|
|
98
|
+
readonly supportedAttributesFilter: {
|
|
99
|
+
readonly fallback: "Keep the core supported-attributes list or guard the filter.";
|
|
100
|
+
readonly label: "block_bindings_supported_attributes filters";
|
|
101
|
+
readonly runtime: readonly ["php"];
|
|
102
|
+
readonly since: "6.9";
|
|
103
|
+
readonly source: "blockBindingsSupportedAttributes";
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
readonly blockSupports: {
|
|
107
|
+
readonly allowedBlocks: {
|
|
108
|
+
readonly derivedAttributes: readonly ["allowedBlocks"];
|
|
109
|
+
readonly fallback: "Pass allowedBlocks directly to useInnerBlocksProps() in custom editor code.";
|
|
110
|
+
readonly label: "supports.allowedBlocks";
|
|
111
|
+
readonly runtime: readonly ["block-json", "editor-js"];
|
|
112
|
+
readonly since: "6.9";
|
|
113
|
+
readonly source: "blockSupportsHandbook";
|
|
114
|
+
};
|
|
115
|
+
readonly background: {
|
|
116
|
+
readonly derivedAttributes: readonly ["style"];
|
|
117
|
+
readonly label: "supports.background";
|
|
118
|
+
readonly runtime: readonly ["block-json", "editor-js"];
|
|
119
|
+
readonly since: "6.5";
|
|
120
|
+
readonly source: "blockSupportsHandbook";
|
|
121
|
+
};
|
|
122
|
+
readonly 'color.button': {
|
|
123
|
+
readonly derivedAttributes: readonly ["style"];
|
|
124
|
+
readonly label: "supports.color.button";
|
|
125
|
+
readonly runtime: readonly ["block-json", "editor-js"];
|
|
126
|
+
readonly since: "6.5";
|
|
127
|
+
readonly source: "blockSupportsHandbook";
|
|
128
|
+
};
|
|
129
|
+
readonly 'color.enableContrastChecker': {
|
|
130
|
+
readonly label: "supports.color.enableContrastChecker";
|
|
131
|
+
readonly runtime: readonly ["block-json", "editor-js"];
|
|
132
|
+
readonly since: "6.5";
|
|
133
|
+
readonly source: "blockSupportsHandbook";
|
|
134
|
+
};
|
|
135
|
+
readonly 'color.heading': {
|
|
136
|
+
readonly derivedAttributes: readonly ["style"];
|
|
137
|
+
readonly label: "supports.color.heading";
|
|
138
|
+
readonly runtime: readonly ["block-json", "editor-js"];
|
|
139
|
+
readonly since: "6.5";
|
|
140
|
+
readonly source: "blockSupportsHandbook";
|
|
141
|
+
};
|
|
142
|
+
readonly contentRole: {
|
|
143
|
+
readonly label: "supports.contentRole";
|
|
144
|
+
readonly runtime: readonly ["block-json", "editor-js"];
|
|
145
|
+
readonly since: "6.9";
|
|
146
|
+
readonly source: "blockSupportsHandbook";
|
|
147
|
+
};
|
|
148
|
+
readonly dimensions: {
|
|
149
|
+
readonly derivedAttributes: readonly ["style"];
|
|
150
|
+
readonly label: "supports.dimensions";
|
|
151
|
+
readonly runtime: readonly ["block-json", "editor-js"];
|
|
152
|
+
readonly since: "6.2";
|
|
153
|
+
readonly source: "blockSupportsHandbook";
|
|
154
|
+
};
|
|
155
|
+
readonly 'filter.duotone': {
|
|
156
|
+
readonly derivedAttributes: readonly ["style"];
|
|
157
|
+
readonly label: "supports.filter.duotone";
|
|
158
|
+
readonly runtime: readonly ["block-json", "editor-js"];
|
|
159
|
+
readonly since: "5.9";
|
|
160
|
+
readonly source: "themeJsonStyleVersions";
|
|
161
|
+
};
|
|
162
|
+
readonly listView: {
|
|
163
|
+
readonly label: "supports.listView";
|
|
164
|
+
readonly runtime: readonly ["block-json", "editor-js"];
|
|
165
|
+
readonly since: "7.0";
|
|
166
|
+
readonly source: "blockSupportsHandbook";
|
|
167
|
+
};
|
|
168
|
+
readonly position: {
|
|
169
|
+
readonly derivedAttributes: readonly ["style"];
|
|
170
|
+
readonly label: "supports.position";
|
|
171
|
+
readonly runtime: readonly ["block-json", "editor-js"];
|
|
172
|
+
readonly since: "6.2";
|
|
173
|
+
readonly source: "blockSupportsHandbook";
|
|
174
|
+
};
|
|
175
|
+
readonly renaming: {
|
|
176
|
+
readonly label: "supports.renaming";
|
|
177
|
+
readonly runtime: readonly ["block-json", "editor-js"];
|
|
178
|
+
readonly since: "6.5";
|
|
179
|
+
readonly source: "blockSupportsHandbook";
|
|
180
|
+
};
|
|
181
|
+
readonly shadow: {
|
|
182
|
+
readonly derivedAttributes: readonly ["style"];
|
|
183
|
+
readonly label: "supports.shadow";
|
|
184
|
+
readonly runtime: readonly ["block-json", "editor-js"];
|
|
185
|
+
readonly since: "6.5";
|
|
186
|
+
readonly source: "blockSupportsHandbook";
|
|
187
|
+
};
|
|
188
|
+
readonly 'spacing.blockGap': {
|
|
189
|
+
readonly derivedAttributes: readonly ["style"];
|
|
190
|
+
readonly label: "supports.spacing.blockGap";
|
|
191
|
+
readonly runtime: readonly ["block-json", "editor-js"];
|
|
192
|
+
readonly since: "5.9";
|
|
193
|
+
readonly source: "themeJsonStyleVersions";
|
|
194
|
+
};
|
|
195
|
+
readonly 'spacing.margin': {
|
|
196
|
+
readonly derivedAttributes: readonly ["style"];
|
|
197
|
+
readonly label: "supports.spacing.margin";
|
|
198
|
+
readonly runtime: readonly ["block-json", "editor-js"];
|
|
199
|
+
readonly since: "5.9";
|
|
200
|
+
readonly source: "themeJsonStyleVersions";
|
|
201
|
+
};
|
|
202
|
+
readonly 'spacing.padding': {
|
|
203
|
+
readonly derivedAttributes: readonly ["style"];
|
|
204
|
+
readonly label: "supports.spacing.padding";
|
|
205
|
+
readonly runtime: readonly ["block-json", "editor-js"];
|
|
206
|
+
readonly since: "5.9";
|
|
207
|
+
readonly source: "themeJsonStyleVersions";
|
|
208
|
+
};
|
|
209
|
+
readonly 'typography.fontSize': {
|
|
210
|
+
readonly derivedAttributes: readonly ["fontSize", "style"];
|
|
211
|
+
readonly label: "supports.typography.fontSize";
|
|
212
|
+
readonly runtime: readonly ["block-json", "editor-js"];
|
|
213
|
+
readonly since: "5.8";
|
|
214
|
+
readonly source: "themeJsonStyleVersions";
|
|
215
|
+
};
|
|
216
|
+
readonly 'typography.letterSpacing': {
|
|
217
|
+
readonly derivedAttributes: readonly ["style"];
|
|
218
|
+
readonly label: "supports.typography.letterSpacing";
|
|
219
|
+
readonly runtime: readonly ["block-json", "editor-js"];
|
|
220
|
+
readonly since: "5.9";
|
|
221
|
+
readonly source: "themeJsonStyleVersions";
|
|
222
|
+
};
|
|
223
|
+
readonly 'typography.lineHeight': {
|
|
224
|
+
readonly derivedAttributes: readonly ["style"];
|
|
225
|
+
readonly label: "supports.typography.lineHeight";
|
|
226
|
+
readonly runtime: readonly ["block-json", "editor-js"];
|
|
227
|
+
readonly since: "5.8";
|
|
228
|
+
readonly source: "themeJsonStyleVersions";
|
|
229
|
+
};
|
|
230
|
+
readonly 'typography.textAlign': {
|
|
231
|
+
readonly derivedAttributes: readonly ["style"];
|
|
232
|
+
readonly label: "supports.typography.textAlign";
|
|
233
|
+
readonly runtime: readonly ["block-json", "editor-js"];
|
|
234
|
+
readonly since: "6.6";
|
|
235
|
+
readonly source: "blockSupportsHandbook";
|
|
236
|
+
};
|
|
237
|
+
readonly 'typography.textDecoration': {
|
|
238
|
+
readonly derivedAttributes: readonly ["style"];
|
|
239
|
+
readonly label: "supports.typography.textDecoration";
|
|
240
|
+
readonly runtime: readonly ["block-json", "editor-js"];
|
|
241
|
+
readonly since: "5.9";
|
|
242
|
+
readonly source: "themeJsonStyleVersions";
|
|
243
|
+
};
|
|
244
|
+
readonly 'typography.textTransform': {
|
|
245
|
+
readonly derivedAttributes: readonly ["style"];
|
|
246
|
+
readonly label: "supports.typography.textTransform";
|
|
247
|
+
readonly runtime: readonly ["block-json", "editor-js"];
|
|
248
|
+
readonly since: "5.9";
|
|
249
|
+
readonly source: "themeJsonStyleVersions";
|
|
250
|
+
};
|
|
251
|
+
readonly visibility: {
|
|
252
|
+
readonly fallback: "Keep the default block options menu behavior.";
|
|
253
|
+
readonly label: "supports.visibility";
|
|
254
|
+
readonly runtime: readonly ["block-json", "editor-js"];
|
|
255
|
+
readonly since: "6.9";
|
|
256
|
+
readonly source: "blockSupportsHandbook";
|
|
257
|
+
};
|
|
258
|
+
};
|
|
259
|
+
readonly blockVariations: {
|
|
260
|
+
readonly editorRegistration: {
|
|
261
|
+
readonly label: "registerBlockVariation() editor registration";
|
|
262
|
+
readonly runtime: readonly ["editor-js"];
|
|
263
|
+
readonly since: "5.4";
|
|
264
|
+
readonly source: "blockVariationsDevNote";
|
|
265
|
+
};
|
|
266
|
+
readonly phpVariationCallback: {
|
|
267
|
+
readonly fallback: "Build static variations or register them in editor JavaScript.";
|
|
268
|
+
readonly label: "WP_Block_Type variation_callback";
|
|
269
|
+
readonly runtime: readonly ["php"];
|
|
270
|
+
readonly since: "6.5";
|
|
271
|
+
readonly source: "blockVariationsPhpDevNote";
|
|
272
|
+
};
|
|
273
|
+
readonly phpVariationsFilter: {
|
|
274
|
+
readonly fallback: "Use JavaScript registration or guard the PHP filter path.";
|
|
275
|
+
readonly label: "get_block_type_variations filter";
|
|
276
|
+
readonly runtime: readonly ["php"];
|
|
277
|
+
readonly since: "6.5";
|
|
278
|
+
readonly source: "blockVariationsPhpDevNote";
|
|
279
|
+
};
|
|
280
|
+
readonly registrationMetadata: {
|
|
281
|
+
readonly label: "block registration variations metadata";
|
|
282
|
+
readonly runtime: readonly ["block-json", "editor-js"];
|
|
283
|
+
readonly since: "5.4";
|
|
284
|
+
readonly source: "blockVariationsDevNote";
|
|
285
|
+
};
|
|
286
|
+
};
|
|
287
|
+
};
|
|
288
|
+
export type WordPressBlockSupportCompatibilityFeature = keyof typeof WORDPRESS_BLOCK_API_COMPATIBILITY.blockSupports;
|
|
289
|
+
export type WordPressBlockVariationCompatibilityFeature = keyof typeof WORDPRESS_BLOCK_API_COMPATIBILITY.blockVariations;
|
|
290
|
+
export type WordPressBlockBindingCompatibilityFeature = keyof typeof WORDPRESS_BLOCK_API_COMPATIBILITY.blockBindings;
|
|
291
|
+
export declare function assertWordPressVersion(value: string): asserts value is WordPressVersion;
|
|
292
|
+
export declare function compareWordPressVersions(left: string, right: string): number;
|
|
293
|
+
export declare function isWordPressVersionAtLeast(version: string, minimum: string): boolean;
|
|
294
|
+
export declare function getWordPressBlockApiCompatibilityEntry(area: WordPressBlockApiCompatibilityArea, feature: string): WordPressBlockApiCompatibilityEntry | undefined;
|
|
295
|
+
export declare function evaluateWordPressBlockApiCompatibility(feature: WordPressBlockApiCompatibilityFeature, settings?: WordPressCompatibilitySettings): WordPressBlockApiCompatibilityEvaluation;
|
|
296
|
+
export declare function createWordPressBlockApiCompatibilityManifest(features: readonly WordPressBlockApiCompatibilityFeature[], settings?: WordPressCompatibilitySettings): WordPressBlockApiCompatibilityManifest;
|
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
export const DEFAULT_WORDPRESS_COMPATIBILITY_MIN_VERSION = '6.7';
|
|
2
|
+
export const WORDPRESS_VERSION_PATTERN = /^\d+\.\d+(?:\.\d+)?$/u;
|
|
3
|
+
export const WORDPRESS_BLOCK_API_COMPATIBILITY_SOURCES = {
|
|
4
|
+
blockBindingsHandbook: 'https://developer.wordpress.org/block-editor/reference-guides/block-api/block-bindings/',
|
|
5
|
+
blockBindingsReference: 'https://developer.wordpress.org/reference/functions/register_block_bindings_source/',
|
|
6
|
+
blockBindingsSupportedAttributes: 'https://developer.wordpress.org/reference/functions/get_block_bindings_supported_attributes/',
|
|
7
|
+
blockSupportsHandbook: 'https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/',
|
|
8
|
+
blockVariationsDevNote: 'https://make.wordpress.org/core/2020/02/27/introduce-block-variations-api/',
|
|
9
|
+
blockVariationsPhpDevNote: 'https://make.wordpress.org/core/2024/02/29/performance-improvements-for-registering-block-variations-with-callbacks/',
|
|
10
|
+
themeJsonStyleVersions: 'https://developer.wordpress.org/block-editor/reference-guides/theme-json-reference/styles-versions/',
|
|
11
|
+
wordpressBlocksPackage: 'https://developer.wordpress.org/block-editor/reference-guides/packages/packages-blocks/',
|
|
12
|
+
};
|
|
13
|
+
export const WORDPRESS_BLOCK_API_COMPATIBILITY = {
|
|
14
|
+
blockBindings: {
|
|
15
|
+
'metadata.bindings': {
|
|
16
|
+
derivedAttributes: ['metadata'],
|
|
17
|
+
label: 'block metadata.bindings',
|
|
18
|
+
runtime: ['block-json', 'php'],
|
|
19
|
+
since: '6.5',
|
|
20
|
+
source: 'blockBindingsHandbook',
|
|
21
|
+
},
|
|
22
|
+
editorRegistration: {
|
|
23
|
+
fallback: 'Keep server-side registration only.',
|
|
24
|
+
label: 'registerBlockBindingsSource() editor registration',
|
|
25
|
+
runtime: ['editor-js'],
|
|
26
|
+
since: '6.7',
|
|
27
|
+
source: 'wordpressBlocksPackage',
|
|
28
|
+
},
|
|
29
|
+
editorFieldsList: {
|
|
30
|
+
fallback: 'Register the source without getFieldsList() or keep a custom editor UI.',
|
|
31
|
+
label: 'registerBlockBindingsSource() getFieldsList()',
|
|
32
|
+
runtime: ['editor-js'],
|
|
33
|
+
since: '6.9',
|
|
34
|
+
source: 'blockBindingsHandbook',
|
|
35
|
+
},
|
|
36
|
+
editorSourceLookup: {
|
|
37
|
+
label: 'getBlockBindingsSource() and getBlockBindingsSources()',
|
|
38
|
+
runtime: ['editor-js'],
|
|
39
|
+
since: '6.7',
|
|
40
|
+
source: 'wordpressBlocksPackage',
|
|
41
|
+
},
|
|
42
|
+
serverRegistration: {
|
|
43
|
+
label: 'register_block_bindings_source()',
|
|
44
|
+
runtime: ['php'],
|
|
45
|
+
since: '6.5',
|
|
46
|
+
source: 'blockBindingsReference',
|
|
47
|
+
},
|
|
48
|
+
supportedAttributesFilter: {
|
|
49
|
+
fallback: 'Keep the core supported-attributes list or guard the filter.',
|
|
50
|
+
label: 'block_bindings_supported_attributes filters',
|
|
51
|
+
runtime: ['php'],
|
|
52
|
+
since: '6.9',
|
|
53
|
+
source: 'blockBindingsSupportedAttributes',
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
blockSupports: {
|
|
57
|
+
allowedBlocks: {
|
|
58
|
+
derivedAttributes: ['allowedBlocks'],
|
|
59
|
+
fallback: 'Pass allowedBlocks directly to useInnerBlocksProps() in custom editor code.',
|
|
60
|
+
label: 'supports.allowedBlocks',
|
|
61
|
+
runtime: ['block-json', 'editor-js'],
|
|
62
|
+
since: '6.9',
|
|
63
|
+
source: 'blockSupportsHandbook',
|
|
64
|
+
},
|
|
65
|
+
background: {
|
|
66
|
+
derivedAttributes: ['style'],
|
|
67
|
+
label: 'supports.background',
|
|
68
|
+
runtime: ['block-json', 'editor-js'],
|
|
69
|
+
since: '6.5',
|
|
70
|
+
source: 'blockSupportsHandbook',
|
|
71
|
+
},
|
|
72
|
+
'color.button': {
|
|
73
|
+
derivedAttributes: ['style'],
|
|
74
|
+
label: 'supports.color.button',
|
|
75
|
+
runtime: ['block-json', 'editor-js'],
|
|
76
|
+
since: '6.5',
|
|
77
|
+
source: 'blockSupportsHandbook',
|
|
78
|
+
},
|
|
79
|
+
'color.enableContrastChecker': {
|
|
80
|
+
label: 'supports.color.enableContrastChecker',
|
|
81
|
+
runtime: ['block-json', 'editor-js'],
|
|
82
|
+
since: '6.5',
|
|
83
|
+
source: 'blockSupportsHandbook',
|
|
84
|
+
},
|
|
85
|
+
'color.heading': {
|
|
86
|
+
derivedAttributes: ['style'],
|
|
87
|
+
label: 'supports.color.heading',
|
|
88
|
+
runtime: ['block-json', 'editor-js'],
|
|
89
|
+
since: '6.5',
|
|
90
|
+
source: 'blockSupportsHandbook',
|
|
91
|
+
},
|
|
92
|
+
contentRole: {
|
|
93
|
+
label: 'supports.contentRole',
|
|
94
|
+
runtime: ['block-json', 'editor-js'],
|
|
95
|
+
since: '6.9',
|
|
96
|
+
source: 'blockSupportsHandbook',
|
|
97
|
+
},
|
|
98
|
+
dimensions: {
|
|
99
|
+
derivedAttributes: ['style'],
|
|
100
|
+
label: 'supports.dimensions',
|
|
101
|
+
runtime: ['block-json', 'editor-js'],
|
|
102
|
+
since: '6.2',
|
|
103
|
+
source: 'blockSupportsHandbook',
|
|
104
|
+
},
|
|
105
|
+
'filter.duotone': {
|
|
106
|
+
derivedAttributes: ['style'],
|
|
107
|
+
label: 'supports.filter.duotone',
|
|
108
|
+
runtime: ['block-json', 'editor-js'],
|
|
109
|
+
since: '5.9',
|
|
110
|
+
source: 'themeJsonStyleVersions',
|
|
111
|
+
},
|
|
112
|
+
listView: {
|
|
113
|
+
label: 'supports.listView',
|
|
114
|
+
runtime: ['block-json', 'editor-js'],
|
|
115
|
+
since: '7.0',
|
|
116
|
+
source: 'blockSupportsHandbook',
|
|
117
|
+
},
|
|
118
|
+
position: {
|
|
119
|
+
derivedAttributes: ['style'],
|
|
120
|
+
label: 'supports.position',
|
|
121
|
+
runtime: ['block-json', 'editor-js'],
|
|
122
|
+
since: '6.2',
|
|
123
|
+
source: 'blockSupportsHandbook',
|
|
124
|
+
},
|
|
125
|
+
renaming: {
|
|
126
|
+
label: 'supports.renaming',
|
|
127
|
+
runtime: ['block-json', 'editor-js'],
|
|
128
|
+
since: '6.5',
|
|
129
|
+
source: 'blockSupportsHandbook',
|
|
130
|
+
},
|
|
131
|
+
shadow: {
|
|
132
|
+
derivedAttributes: ['style'],
|
|
133
|
+
label: 'supports.shadow',
|
|
134
|
+
runtime: ['block-json', 'editor-js'],
|
|
135
|
+
since: '6.5',
|
|
136
|
+
source: 'blockSupportsHandbook',
|
|
137
|
+
},
|
|
138
|
+
'spacing.blockGap': {
|
|
139
|
+
derivedAttributes: ['style'],
|
|
140
|
+
label: 'supports.spacing.blockGap',
|
|
141
|
+
runtime: ['block-json', 'editor-js'],
|
|
142
|
+
since: '5.9',
|
|
143
|
+
source: 'themeJsonStyleVersions',
|
|
144
|
+
},
|
|
145
|
+
'spacing.margin': {
|
|
146
|
+
derivedAttributes: ['style'],
|
|
147
|
+
label: 'supports.spacing.margin',
|
|
148
|
+
runtime: ['block-json', 'editor-js'],
|
|
149
|
+
since: '5.9',
|
|
150
|
+
source: 'themeJsonStyleVersions',
|
|
151
|
+
},
|
|
152
|
+
'spacing.padding': {
|
|
153
|
+
derivedAttributes: ['style'],
|
|
154
|
+
label: 'supports.spacing.padding',
|
|
155
|
+
runtime: ['block-json', 'editor-js'],
|
|
156
|
+
since: '5.9',
|
|
157
|
+
source: 'themeJsonStyleVersions',
|
|
158
|
+
},
|
|
159
|
+
'typography.fontSize': {
|
|
160
|
+
derivedAttributes: ['fontSize', 'style'],
|
|
161
|
+
label: 'supports.typography.fontSize',
|
|
162
|
+
runtime: ['block-json', 'editor-js'],
|
|
163
|
+
since: '5.8',
|
|
164
|
+
source: 'themeJsonStyleVersions',
|
|
165
|
+
},
|
|
166
|
+
'typography.letterSpacing': {
|
|
167
|
+
derivedAttributes: ['style'],
|
|
168
|
+
label: 'supports.typography.letterSpacing',
|
|
169
|
+
runtime: ['block-json', 'editor-js'],
|
|
170
|
+
since: '5.9',
|
|
171
|
+
source: 'themeJsonStyleVersions',
|
|
172
|
+
},
|
|
173
|
+
'typography.lineHeight': {
|
|
174
|
+
derivedAttributes: ['style'],
|
|
175
|
+
label: 'supports.typography.lineHeight',
|
|
176
|
+
runtime: ['block-json', 'editor-js'],
|
|
177
|
+
since: '5.8',
|
|
178
|
+
source: 'themeJsonStyleVersions',
|
|
179
|
+
},
|
|
180
|
+
'typography.textAlign': {
|
|
181
|
+
derivedAttributes: ['style'],
|
|
182
|
+
label: 'supports.typography.textAlign',
|
|
183
|
+
runtime: ['block-json', 'editor-js'],
|
|
184
|
+
since: '6.6',
|
|
185
|
+
source: 'blockSupportsHandbook',
|
|
186
|
+
},
|
|
187
|
+
'typography.textDecoration': {
|
|
188
|
+
derivedAttributes: ['style'],
|
|
189
|
+
label: 'supports.typography.textDecoration',
|
|
190
|
+
runtime: ['block-json', 'editor-js'],
|
|
191
|
+
since: '5.9',
|
|
192
|
+
source: 'themeJsonStyleVersions',
|
|
193
|
+
},
|
|
194
|
+
'typography.textTransform': {
|
|
195
|
+
derivedAttributes: ['style'],
|
|
196
|
+
label: 'supports.typography.textTransform',
|
|
197
|
+
runtime: ['block-json', 'editor-js'],
|
|
198
|
+
since: '5.9',
|
|
199
|
+
source: 'themeJsonStyleVersions',
|
|
200
|
+
},
|
|
201
|
+
visibility: {
|
|
202
|
+
fallback: 'Keep the default block options menu behavior.',
|
|
203
|
+
label: 'supports.visibility',
|
|
204
|
+
runtime: ['block-json', 'editor-js'],
|
|
205
|
+
since: '6.9',
|
|
206
|
+
source: 'blockSupportsHandbook',
|
|
207
|
+
},
|
|
208
|
+
},
|
|
209
|
+
blockVariations: {
|
|
210
|
+
editorRegistration: {
|
|
211
|
+
label: 'registerBlockVariation() editor registration',
|
|
212
|
+
runtime: ['editor-js'],
|
|
213
|
+
since: '5.4',
|
|
214
|
+
source: 'blockVariationsDevNote',
|
|
215
|
+
},
|
|
216
|
+
phpVariationCallback: {
|
|
217
|
+
fallback: 'Build static variations or register them in editor JavaScript.',
|
|
218
|
+
label: 'WP_Block_Type variation_callback',
|
|
219
|
+
runtime: ['php'],
|
|
220
|
+
since: '6.5',
|
|
221
|
+
source: 'blockVariationsPhpDevNote',
|
|
222
|
+
},
|
|
223
|
+
phpVariationsFilter: {
|
|
224
|
+
fallback: 'Use JavaScript registration or guard the PHP filter path.',
|
|
225
|
+
label: 'get_block_type_variations filter',
|
|
226
|
+
runtime: ['php'],
|
|
227
|
+
since: '6.5',
|
|
228
|
+
source: 'blockVariationsPhpDevNote',
|
|
229
|
+
},
|
|
230
|
+
registrationMetadata: {
|
|
231
|
+
label: 'block registration variations metadata',
|
|
232
|
+
runtime: ['block-json', 'editor-js'],
|
|
233
|
+
since: '5.4',
|
|
234
|
+
source: 'blockVariationsDevNote',
|
|
235
|
+
},
|
|
236
|
+
},
|
|
237
|
+
};
|
|
238
|
+
function normalizeCompatibilitySettings(settings) {
|
|
239
|
+
return {
|
|
240
|
+
allowUnknownFutureKeys: settings.allowUnknownFutureKeys ?? false,
|
|
241
|
+
minVersion: settings.minVersion ?? DEFAULT_WORDPRESS_COMPATIBILITY_MIN_VERSION,
|
|
242
|
+
strict: settings.strict ?? true,
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
export function assertWordPressVersion(value) {
|
|
246
|
+
if (!WORDPRESS_VERSION_PATTERN.test(value)) {
|
|
247
|
+
throw new Error(`Invalid WordPress version "${value}". Expected dotted numeric version such as "6.7" or "6.7.1".`);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
export function compareWordPressVersions(left, right) {
|
|
251
|
+
assertWordPressVersion(left);
|
|
252
|
+
assertWordPressVersion(right);
|
|
253
|
+
const leftParts = left.split('.').map((part) => Number.parseInt(part, 10));
|
|
254
|
+
const rightParts = right.split('.').map((part) => Number.parseInt(part, 10));
|
|
255
|
+
const length = Math.max(leftParts.length, rightParts.length);
|
|
256
|
+
for (let index = 0; index < length; index += 1) {
|
|
257
|
+
const leftValue = leftParts[index] ?? 0;
|
|
258
|
+
const rightValue = rightParts[index] ?? 0;
|
|
259
|
+
if (leftValue > rightValue) {
|
|
260
|
+
return 1;
|
|
261
|
+
}
|
|
262
|
+
if (leftValue < rightValue) {
|
|
263
|
+
return -1;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
return 0;
|
|
267
|
+
}
|
|
268
|
+
export function isWordPressVersionAtLeast(version, minimum) {
|
|
269
|
+
return compareWordPressVersions(version, minimum) >= 0;
|
|
270
|
+
}
|
|
271
|
+
export function getWordPressBlockApiCompatibilityEntry(area, feature) {
|
|
272
|
+
return WORDPRESS_BLOCK_API_COMPATIBILITY[area][feature];
|
|
273
|
+
}
|
|
274
|
+
export function evaluateWordPressBlockApiCompatibility(feature, settings = {}) {
|
|
275
|
+
const resolved = normalizeCompatibilitySettings(settings);
|
|
276
|
+
const entry = getWordPressBlockApiCompatibilityEntry(feature.area, feature.feature);
|
|
277
|
+
const severity = resolved.strict ? 'error' : 'warning';
|
|
278
|
+
if (!entry) {
|
|
279
|
+
const diagnostic = resolved.allowUnknownFutureKeys
|
|
280
|
+
? undefined
|
|
281
|
+
: {
|
|
282
|
+
area: feature.area,
|
|
283
|
+
code: 'unknown-wordpress-block-api-feature',
|
|
284
|
+
feature: feature.feature,
|
|
285
|
+
message: `Unknown WordPress block API feature "${feature.area}.${feature.feature}".`,
|
|
286
|
+
minVersion: resolved.minVersion,
|
|
287
|
+
severity,
|
|
288
|
+
};
|
|
289
|
+
return {
|
|
290
|
+
...feature,
|
|
291
|
+
action: resolved.allowUnknownFutureKeys ? 'pass-through' : 'guard',
|
|
292
|
+
diagnostic,
|
|
293
|
+
minVersion: resolved.minVersion,
|
|
294
|
+
status: 'unknown',
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
if (isWordPressVersionAtLeast(resolved.minVersion, entry.since)) {
|
|
298
|
+
return {
|
|
299
|
+
...feature,
|
|
300
|
+
action: 'generate',
|
|
301
|
+
entry,
|
|
302
|
+
minVersion: resolved.minVersion,
|
|
303
|
+
status: 'supported',
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
const diagnostic = {
|
|
307
|
+
area: feature.area,
|
|
308
|
+
code: 'unsupported-wordpress-block-api-feature',
|
|
309
|
+
feature: feature.feature,
|
|
310
|
+
message: `${entry.label} requires WordPress ${entry.since}+ but the configured minimum is ${resolved.minVersion}.`,
|
|
311
|
+
minVersion: resolved.minVersion,
|
|
312
|
+
requiredVersion: entry.since,
|
|
313
|
+
severity,
|
|
314
|
+
};
|
|
315
|
+
return {
|
|
316
|
+
...feature,
|
|
317
|
+
action: resolved.strict ? 'skip' : 'guard',
|
|
318
|
+
diagnostic,
|
|
319
|
+
entry,
|
|
320
|
+
minVersion: resolved.minVersion,
|
|
321
|
+
status: 'unsupported',
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
export function createWordPressBlockApiCompatibilityManifest(features, settings = {}) {
|
|
325
|
+
const resolved = normalizeCompatibilitySettings(settings);
|
|
326
|
+
const evaluations = features.map((feature) => evaluateWordPressBlockApiCompatibility(feature, resolved));
|
|
327
|
+
const diagnostics = evaluations.flatMap((evaluation) => evaluation.diagnostic ? [evaluation.diagnostic] : []);
|
|
328
|
+
return {
|
|
329
|
+
allowUnknownFutureKeys: resolved.allowUnknownFutureKeys,
|
|
330
|
+
diagnostics,
|
|
331
|
+
evaluations,
|
|
332
|
+
minVersion: resolved.minVersion,
|
|
333
|
+
strict: resolved.strict,
|
|
334
|
+
supported: evaluations.filter((evaluation) => evaluation.status === 'supported'),
|
|
335
|
+
unknown: evaluations.filter((evaluation) => evaluation.status === 'unknown'),
|
|
336
|
+
unsupported: evaluations.filter((evaluation) => evaluation.status === 'unsupported'),
|
|
337
|
+
};
|
|
338
|
+
}
|
package/dist/blocks/index.d.ts
CHANGED
package/dist/blocks/index.js
CHANGED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type DiagnosticSeverity = "error" | "warning";
|
|
2
|
+
export interface DiagnosticWithMessage {
|
|
3
|
+
readonly message: string;
|
|
4
|
+
readonly severity: DiagnosticSeverity;
|
|
5
|
+
}
|
|
6
|
+
export interface DiagnosticLogger<TDiagnostic extends DiagnosticWithMessage = DiagnosticWithMessage> {
|
|
7
|
+
readonly warn: (message: string, diagnostic: TDiagnostic) => void;
|
|
8
|
+
}
|
|
9
|
+
export declare function getDiagnosticSeverity(strict: boolean): DiagnosticSeverity;
|
|
10
|
+
export declare function handleDiagnostics<TDiagnostic extends DiagnosticWithMessage>(diagnostics: readonly TDiagnostic[], onDiagnostic: ((diagnostic: TDiagnostic) => void) | undefined, options: {
|
|
11
|
+
readonly failureHeading: string;
|
|
12
|
+
readonly logger?: DiagnosticLogger<TDiagnostic> | undefined;
|
|
13
|
+
}): void;
|