@wp-typia/project-tools 0.16.11 → 0.16.12
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 +9 -3
- package/dist/runtime/built-in-block-artifact-documents.d.ts +3 -0
- package/dist/runtime/built-in-block-artifact-documents.js +2 -0
- package/dist/runtime/built-in-block-artifact-types.d.ts +51 -0
- package/dist/runtime/built-in-block-artifact-types.js +304 -0
- package/dist/runtime/built-in-block-artifacts.js +4 -803
- package/dist/runtime/built-in-block-attribute-emitters.d.ts +71 -0
- package/dist/runtime/built-in-block-attribute-emitters.js +176 -0
- package/dist/runtime/built-in-block-attribute-specs.d.ts +38 -0
- package/dist/runtime/built-in-block-attribute-specs.js +358 -0
- package/dist/runtime/built-in-block-code-templates/basic.d.ts +4 -0
- package/dist/runtime/built-in-block-code-templates/basic.js +249 -0
- package/dist/runtime/built-in-block-code-templates/compound-child.d.ts +4 -0
- package/dist/runtime/built-in-block-code-templates/compound-child.js +138 -0
- package/dist/runtime/built-in-block-code-templates/compound-parent.d.ts +6 -0
- package/dist/runtime/built-in-block-code-templates/compound-parent.js +227 -0
- package/dist/runtime/built-in-block-code-templates/compound-persistence.d.ts +4 -0
- package/dist/runtime/built-in-block-code-templates/compound-persistence.js +478 -0
- package/dist/runtime/built-in-block-code-templates/compound.d.ts +3 -0
- package/dist/runtime/built-in-block-code-templates/compound.js +3 -0
- package/dist/runtime/built-in-block-code-templates/interactivity.d.ts +5 -0
- package/dist/runtime/built-in-block-code-templates/interactivity.js +547 -0
- package/dist/runtime/built-in-block-code-templates/persistence.d.ts +5 -0
- package/dist/runtime/built-in-block-code-templates/persistence.js +550 -0
- package/dist/runtime/built-in-block-code-templates/shared.d.ts +16 -0
- package/dist/runtime/built-in-block-code-templates/shared.js +53 -0
- package/dist/runtime/built-in-block-code-templates.d.ts +5 -32
- package/dist/runtime/built-in-block-code-templates.js +5 -2230
- package/dist/runtime/cli-add-block-config.d.ts +6 -0
- package/dist/runtime/cli-add-block-config.js +143 -0
- package/dist/runtime/cli-add-block-legacy-validator.d.ts +4 -0
- package/dist/runtime/cli-add-block-legacy-validator.js +168 -0
- package/dist/runtime/cli-add-block.js +3 -301
- package/dist/runtime/cli-add-workspace-assets.d.ts +38 -0
- package/dist/runtime/cli-add-workspace-assets.js +399 -0
- package/dist/runtime/cli-add-workspace.d.ts +2 -38
- package/dist/runtime/cli-add-workspace.js +5 -396
- package/dist/runtime/cli-doctor-environment.d.ts +12 -0
- package/dist/runtime/cli-doctor-environment.js +123 -0
- package/dist/runtime/cli-doctor-workspace.d.ts +14 -0
- package/dist/runtime/cli-doctor-workspace.js +296 -0
- package/dist/runtime/cli-doctor.d.ts +4 -2
- package/dist/runtime/cli-doctor.js +10 -405
- package/dist/runtime/migration-command-surface.d.ts +67 -0
- package/dist/runtime/migration-command-surface.js +189 -0
- package/dist/runtime/migration-diff-rename.d.ts +13 -0
- package/dist/runtime/migration-diff-rename.js +192 -0
- package/dist/runtime/migration-diff-transform.d.ts +14 -0
- package/dist/runtime/migration-diff-transform.js +105 -0
- package/dist/runtime/migration-diff.js +12 -297
- package/dist/runtime/migration-generated-artifacts.d.ts +3 -0
- package/dist/runtime/migration-generated-artifacts.js +41 -0
- package/dist/runtime/migration-maintenance.d.ts +51 -0
- package/dist/runtime/migration-maintenance.js +380 -0
- package/dist/runtime/migration-planning.d.ts +23 -0
- package/dist/runtime/migration-planning.js +131 -0
- package/dist/runtime/migration-project-config-source.d.ts +6 -0
- package/dist/runtime/migration-project-config-source.js +424 -0
- package/dist/runtime/migration-project-layout-discovery.d.ts +61 -0
- package/dist/runtime/migration-project-layout-discovery.js +337 -0
- package/dist/runtime/migration-project-layout-paths.d.ts +135 -0
- package/dist/runtime/migration-project-layout-paths.js +288 -0
- package/dist/runtime/migration-project-layout.d.ts +3 -0
- package/dist/runtime/migration-project-layout.js +2 -0
- package/dist/runtime/migration-project-workspace.d.ts +47 -0
- package/dist/runtime/migration-project-workspace.js +212 -0
- package/dist/runtime/migration-project.d.ts +4 -94
- package/dist/runtime/migration-project.js +3 -1101
- package/dist/runtime/migration-render-diff-rule.d.ts +5 -0
- package/dist/runtime/migration-render-diff-rule.js +120 -0
- package/dist/runtime/migration-render-execution.d.ts +3 -0
- package/dist/runtime/migration-render-execution.js +428 -0
- package/dist/runtime/migration-render-generated.d.ts +27 -0
- package/dist/runtime/migration-render-generated.js +230 -0
- package/dist/runtime/migration-render-support.d.ts +3 -0
- package/dist/runtime/migration-render-support.js +16 -0
- package/dist/runtime/migration-render.d.ts +3 -33
- package/dist/runtime/migration-render.js +3 -789
- package/dist/runtime/migrations.d.ts +24 -118
- package/dist/runtime/migrations.js +12 -700
- package/dist/runtime/scaffold-bootstrap.d.ts +45 -0
- package/dist/runtime/scaffold-bootstrap.js +185 -0
- package/dist/runtime/scaffold-package-manager-files.d.ts +35 -0
- package/dist/runtime/scaffold-package-manager-files.js +79 -0
- package/dist/runtime/scaffold.d.ts +1 -12
- package/dist/runtime/scaffold.js +10 -393
- package/dist/runtime/template-source-contracts.d.ts +81 -0
- package/dist/runtime/template-source-contracts.js +1 -0
- package/dist/runtime/template-source-external.d.ts +21 -0
- package/dist/runtime/template-source-external.js +184 -0
- package/dist/runtime/template-source-locators.d.ts +4 -0
- package/dist/runtime/template-source-locators.js +72 -0
- package/dist/runtime/template-source-normalization.d.ts +7 -0
- package/dist/runtime/template-source-normalization.js +53 -0
- package/dist/runtime/template-source-remote.d.ts +23 -0
- package/dist/runtime/template-source-remote.js +336 -0
- package/dist/runtime/template-source-seeds.d.ts +12 -0
- package/dist/runtime/template-source-seeds.js +243 -0
- package/dist/runtime/template-source.d.ts +4 -86
- package/dist/runtime/template-source.js +9 -828
- package/package.json +4 -4
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type { JsonValue, ManifestAttribute, ManifestConstraints, ManifestDocument } from "./migration-types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Default placeholder copy used for generated compound child body fields.
|
|
4
|
+
*/
|
|
5
|
+
export declare const DEFAULT_COMPOUND_CHILD_BODY_PLACEHOLDER = "Add supporting details for this internal item.";
|
|
6
|
+
type StarterManifestSourceType = NonNullable<ManifestAttribute["wp"]["type"]>;
|
|
7
|
+
type WordPressAttributeSource = NonNullable<ManifestAttribute["wp"]["source"]>;
|
|
8
|
+
interface StarterManifestAttributeDefinition {
|
|
9
|
+
constraints?: Partial<ManifestConstraints>;
|
|
10
|
+
defaultValue?: JsonValue;
|
|
11
|
+
enumValues?: Array<string | number | boolean> | null;
|
|
12
|
+
kind: ManifestAttribute["ts"]["kind"];
|
|
13
|
+
required: boolean;
|
|
14
|
+
selector?: string | null;
|
|
15
|
+
source?: WordPressAttributeSource | null;
|
|
16
|
+
sourceType: StarterManifestSourceType;
|
|
17
|
+
}
|
|
18
|
+
interface BlockJsonAttributeDefinition {
|
|
19
|
+
defaultValue?: JsonValue;
|
|
20
|
+
enumValues?: Array<string | number | boolean> | null;
|
|
21
|
+
selector?: string;
|
|
22
|
+
source?: WordPressAttributeSource;
|
|
23
|
+
type: StarterManifestSourceType;
|
|
24
|
+
}
|
|
25
|
+
export interface AttributeDescription {
|
|
26
|
+
lines: string[];
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Emitted attribute metadata shared between block.json, manifest, and type emitters.
|
|
30
|
+
*/
|
|
31
|
+
export interface EmittedAttributeDefinition {
|
|
32
|
+
blockJson: BlockJsonAttributeDefinition;
|
|
33
|
+
description?: AttributeDescription;
|
|
34
|
+
manifest: StarterManifestAttributeDefinition;
|
|
35
|
+
name: string;
|
|
36
|
+
optional: boolean;
|
|
37
|
+
typeExpression: string;
|
|
38
|
+
}
|
|
39
|
+
type BuiltInAttributeValueResolver<TContext, TValue> = TValue | ((context: TContext) => TValue);
|
|
40
|
+
export interface BuiltInAttributeTemplateSpec<TContext> {
|
|
41
|
+
attributeType: "boolean" | "number" | "string";
|
|
42
|
+
blockJsonDefaultValue?: BuiltInAttributeValueResolver<TContext, JsonValue | undefined>;
|
|
43
|
+
constraints?: BuiltInAttributeValueResolver<TContext, Partial<ManifestConstraints> | undefined>;
|
|
44
|
+
defaultValue?: BuiltInAttributeValueResolver<TContext, JsonValue | undefined>;
|
|
45
|
+
description?: BuiltInAttributeValueResolver<TContext, AttributeDescription | undefined>;
|
|
46
|
+
enumValues?: BuiltInAttributeValueResolver<TContext, Array<string | number | boolean> | null | undefined>;
|
|
47
|
+
manifestDefaultValue?: BuiltInAttributeValueResolver<TContext, JsonValue | undefined>;
|
|
48
|
+
name: string;
|
|
49
|
+
optional: boolean;
|
|
50
|
+
selector?: BuiltInAttributeValueResolver<TContext, string | null | undefined>;
|
|
51
|
+
source?: BuiltInAttributeValueResolver<TContext, WordPressAttributeSource | null | undefined>;
|
|
52
|
+
typeExpression: BuiltInAttributeValueResolver<TContext, string>;
|
|
53
|
+
}
|
|
54
|
+
export declare function describe(...lines: string[]): AttributeDescription;
|
|
55
|
+
export declare function buildAttributesFromSpecs<TContext>(specs: readonly BuiltInAttributeTemplateSpec<TContext>[], context: TContext): EmittedAttributeDefinition[];
|
|
56
|
+
/**
|
|
57
|
+
* Builds the manifest document for a generated built-in block artifact.
|
|
58
|
+
*
|
|
59
|
+
* @param sourceType Generated TypeScript source type name referenced by the manifest.
|
|
60
|
+
* @param attributes Emitted attribute definitions used to populate the manifest.
|
|
61
|
+
* @returns A starter manifest document for the generated block.
|
|
62
|
+
*/
|
|
63
|
+
export declare function buildManifestDocument(sourceType: string, attributes: readonly EmittedAttributeDefinition[]): ManifestDocument;
|
|
64
|
+
/**
|
|
65
|
+
* Builds the block.json attributes object for a generated built-in block artifact.
|
|
66
|
+
*
|
|
67
|
+
* @param attributes Emitted attribute definitions used to populate block.json.
|
|
68
|
+
* @returns A block.json-compatible attributes record.
|
|
69
|
+
*/
|
|
70
|
+
export declare function buildBlockJsonAttributes(attributes: readonly EmittedAttributeDefinition[]): Record<string, Record<string, unknown>>;
|
|
71
|
+
export {};
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default placeholder copy used for generated compound child body fields.
|
|
3
|
+
*/
|
|
4
|
+
export const DEFAULT_COMPOUND_CHILD_BODY_PLACEHOLDER = "Add supporting details for this internal item.";
|
|
5
|
+
function createConstraints(overrides = {}) {
|
|
6
|
+
return {
|
|
7
|
+
exclusiveMaximum: null,
|
|
8
|
+
exclusiveMinimum: null,
|
|
9
|
+
format: null,
|
|
10
|
+
maxLength: null,
|
|
11
|
+
maxItems: null,
|
|
12
|
+
maximum: null,
|
|
13
|
+
minLength: null,
|
|
14
|
+
minItems: null,
|
|
15
|
+
minimum: null,
|
|
16
|
+
multipleOf: null,
|
|
17
|
+
pattern: null,
|
|
18
|
+
typeTag: null,
|
|
19
|
+
...overrides,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function createManifestAttribute({ constraints, defaultValue, enumValues = null, kind, required, selector = null, source = null, sourceType, }) {
|
|
23
|
+
const hasDefault = defaultValue !== undefined;
|
|
24
|
+
return {
|
|
25
|
+
ts: {
|
|
26
|
+
items: null,
|
|
27
|
+
kind,
|
|
28
|
+
properties: null,
|
|
29
|
+
required,
|
|
30
|
+
union: null,
|
|
31
|
+
},
|
|
32
|
+
typia: {
|
|
33
|
+
constraints: createConstraints(constraints),
|
|
34
|
+
defaultValue: hasDefault ? defaultValue : null,
|
|
35
|
+
hasDefault,
|
|
36
|
+
},
|
|
37
|
+
wp: {
|
|
38
|
+
defaultValue: hasDefault ? defaultValue : null,
|
|
39
|
+
enum: enumValues,
|
|
40
|
+
hasDefault,
|
|
41
|
+
...(selector ? { selector } : {}),
|
|
42
|
+
...(source ? { source } : {}),
|
|
43
|
+
type: sourceType,
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
function createBlockJsonAttribute({ defaultValue, enumValues = null, selector, source, type, }) {
|
|
48
|
+
const attribute = {
|
|
49
|
+
type,
|
|
50
|
+
};
|
|
51
|
+
if (defaultValue !== undefined) {
|
|
52
|
+
attribute.default = defaultValue;
|
|
53
|
+
}
|
|
54
|
+
if (enumValues !== null && enumValues.length > 0) {
|
|
55
|
+
attribute.enum = enumValues;
|
|
56
|
+
}
|
|
57
|
+
if (source) {
|
|
58
|
+
attribute.source = source;
|
|
59
|
+
}
|
|
60
|
+
if (selector) {
|
|
61
|
+
attribute.selector = selector;
|
|
62
|
+
}
|
|
63
|
+
return attribute;
|
|
64
|
+
}
|
|
65
|
+
export function describe(...lines) {
|
|
66
|
+
return {
|
|
67
|
+
lines,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
function defineAttribute({ blockJsonDefaultValue, constraints, defaultValue, description, enumValues = null, kind, manifestDefaultValue, name, optional, selector = null, source = null, sourceType, typeExpression, }) {
|
|
71
|
+
const resolvedBlockJsonDefaultValue = blockJsonDefaultValue !== undefined ? blockJsonDefaultValue : defaultValue;
|
|
72
|
+
const resolvedManifestDefaultValue = manifestDefaultValue !== undefined ? manifestDefaultValue : defaultValue;
|
|
73
|
+
return {
|
|
74
|
+
blockJson: {
|
|
75
|
+
defaultValue: resolvedBlockJsonDefaultValue,
|
|
76
|
+
enumValues,
|
|
77
|
+
...(selector ? { selector } : {}),
|
|
78
|
+
...(source ? { source } : {}),
|
|
79
|
+
type: sourceType,
|
|
80
|
+
},
|
|
81
|
+
description,
|
|
82
|
+
manifest: {
|
|
83
|
+
constraints,
|
|
84
|
+
defaultValue: resolvedManifestDefaultValue,
|
|
85
|
+
enumValues,
|
|
86
|
+
kind,
|
|
87
|
+
required: !optional,
|
|
88
|
+
selector,
|
|
89
|
+
source,
|
|
90
|
+
sourceType,
|
|
91
|
+
},
|
|
92
|
+
name,
|
|
93
|
+
optional,
|
|
94
|
+
typeExpression,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
function defineStringAttribute(spec) {
|
|
98
|
+
return defineAttribute({
|
|
99
|
+
...spec,
|
|
100
|
+
kind: "string",
|
|
101
|
+
sourceType: "string",
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
function defineBooleanAttribute(spec) {
|
|
105
|
+
return defineAttribute({
|
|
106
|
+
...spec,
|
|
107
|
+
kind: "boolean",
|
|
108
|
+
sourceType: "boolean",
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
function defineNumberAttribute(spec) {
|
|
112
|
+
return defineAttribute({
|
|
113
|
+
...spec,
|
|
114
|
+
kind: "number",
|
|
115
|
+
sourceType: "number",
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
function resolveBuiltInAttributeValue(value, context) {
|
|
119
|
+
if (typeof value === "function") {
|
|
120
|
+
return value(context);
|
|
121
|
+
}
|
|
122
|
+
return value;
|
|
123
|
+
}
|
|
124
|
+
export function buildAttributesFromSpecs(specs, context) {
|
|
125
|
+
return specs.map((spec) => {
|
|
126
|
+
const resolvedSpec = {
|
|
127
|
+
blockJsonDefaultValue: resolveBuiltInAttributeValue(spec.blockJsonDefaultValue, context),
|
|
128
|
+
constraints: resolveBuiltInAttributeValue(spec.constraints, context),
|
|
129
|
+
defaultValue: resolveBuiltInAttributeValue(spec.defaultValue, context),
|
|
130
|
+
description: resolveBuiltInAttributeValue(spec.description, context),
|
|
131
|
+
enumValues: resolveBuiltInAttributeValue(spec.enumValues, context),
|
|
132
|
+
manifestDefaultValue: resolveBuiltInAttributeValue(spec.manifestDefaultValue, context),
|
|
133
|
+
name: spec.name,
|
|
134
|
+
optional: spec.optional,
|
|
135
|
+
selector: resolveBuiltInAttributeValue(spec.selector, context),
|
|
136
|
+
source: resolveBuiltInAttributeValue(spec.source, context),
|
|
137
|
+
typeExpression: resolveBuiltInAttributeValue(spec.typeExpression, context) ?? "unknown",
|
|
138
|
+
};
|
|
139
|
+
if (spec.attributeType === "boolean") {
|
|
140
|
+
return defineBooleanAttribute(resolvedSpec);
|
|
141
|
+
}
|
|
142
|
+
if (spec.attributeType === "number") {
|
|
143
|
+
return defineNumberAttribute(resolvedSpec);
|
|
144
|
+
}
|
|
145
|
+
return defineStringAttribute(resolvedSpec);
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Builds the manifest document for a generated built-in block artifact.
|
|
150
|
+
*
|
|
151
|
+
* @param sourceType Generated TypeScript source type name referenced by the manifest.
|
|
152
|
+
* @param attributes Emitted attribute definitions used to populate the manifest.
|
|
153
|
+
* @returns A starter manifest document for the generated block.
|
|
154
|
+
*/
|
|
155
|
+
export function buildManifestDocument(sourceType, attributes) {
|
|
156
|
+
return {
|
|
157
|
+
attributes: Object.fromEntries(attributes.map((attribute) => [
|
|
158
|
+
attribute.name,
|
|
159
|
+
createManifestAttribute(attribute.manifest),
|
|
160
|
+
])),
|
|
161
|
+
manifestVersion: 2,
|
|
162
|
+
sourceType,
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Builds the block.json attributes object for a generated built-in block artifact.
|
|
167
|
+
*
|
|
168
|
+
* @param attributes Emitted attribute definitions used to populate block.json.
|
|
169
|
+
* @returns A block.json-compatible attributes record.
|
|
170
|
+
*/
|
|
171
|
+
export function buildBlockJsonAttributes(attributes) {
|
|
172
|
+
return Object.fromEntries(attributes.map((attribute) => [
|
|
173
|
+
attribute.name,
|
|
174
|
+
createBlockJsonAttribute(attribute.blockJson),
|
|
175
|
+
]));
|
|
176
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { ScaffoldTemplateVariables } from "./scaffold.js";
|
|
2
|
+
import type { EmittedAttributeDefinition } from "./built-in-block-attribute-emitters.js";
|
|
3
|
+
/**
|
|
4
|
+
* Builds the emitted attribute set for the basic built-in block family.
|
|
5
|
+
*
|
|
6
|
+
* @returns Emitted attribute definitions for the basic template family.
|
|
7
|
+
*/
|
|
8
|
+
export declare function buildBasicAttributes(): EmittedAttributeDefinition[];
|
|
9
|
+
/**
|
|
10
|
+
* Builds the emitted attribute set for the interactivity built-in block family.
|
|
11
|
+
*
|
|
12
|
+
* @param variables Resolved scaffold template variables for the generated block.
|
|
13
|
+
* @returns Emitted attribute definitions for the interactivity template family.
|
|
14
|
+
*/
|
|
15
|
+
export declare function buildInteractivityAttributes(variables: ScaffoldTemplateVariables): EmittedAttributeDefinition[];
|
|
16
|
+
/**
|
|
17
|
+
* Builds the emitted attribute set for the persistence built-in block family.
|
|
18
|
+
*
|
|
19
|
+
* @param variables Resolved scaffold template variables for the generated block.
|
|
20
|
+
* @returns Emitted attribute definitions for the persistence template family.
|
|
21
|
+
*/
|
|
22
|
+
export declare function buildPersistenceAttributes(variables: ScaffoldTemplateVariables): EmittedAttributeDefinition[];
|
|
23
|
+
/**
|
|
24
|
+
* Builds the emitted attribute set for the compound parent built-in block family.
|
|
25
|
+
*
|
|
26
|
+
* @param variables Resolved scaffold template variables for the generated block.
|
|
27
|
+
* @returns Emitted attribute definitions for the compound parent artifact.
|
|
28
|
+
*/
|
|
29
|
+
export declare function buildCompoundParentAttributes(variables: ScaffoldTemplateVariables): EmittedAttributeDefinition[];
|
|
30
|
+
/**
|
|
31
|
+
* Builds the emitted attribute set for the compound child built-in block family.
|
|
32
|
+
*
|
|
33
|
+
* @param bodyPlaceholder Placeholder text for the child body field.
|
|
34
|
+
* @param childTitle Default title used by the child block.
|
|
35
|
+
* @param childCssClassName Optional CSS class used for HTML-backed selectors.
|
|
36
|
+
* @returns Emitted attribute definitions for the compound child artifact.
|
|
37
|
+
*/
|
|
38
|
+
export declare function buildCompoundChildAttributes(childTitle: string, childCssClassName?: string | null, bodyPlaceholder?: string): EmittedAttributeDefinition[];
|
|
@@ -0,0 +1,358 @@
|
|
|
1
|
+
import { DEFAULT_COMPOUND_CHILD_BODY_PLACEHOLDER, buildAttributesFromSpecs, describe, } from "./built-in-block-attribute-emitters.js";
|
|
2
|
+
const ALIGNMENT_VALUES = ["left", "center", "right"];
|
|
3
|
+
const BASIC_ALIGNMENT_VALUES = ["left", "center", "right", "justify"];
|
|
4
|
+
const INTERACTIVE_MODE_VALUES = ["click", "hover"];
|
|
5
|
+
const ANIMATION_VALUES = ["none", "bounce", "pulse", "shake", "flip"];
|
|
6
|
+
const BASIC_ATTRIBUTE_SPECS = [
|
|
7
|
+
{
|
|
8
|
+
attributeType: "string",
|
|
9
|
+
constraints: {
|
|
10
|
+
maxLength: 1000,
|
|
11
|
+
},
|
|
12
|
+
defaultValue: "",
|
|
13
|
+
description: describe("Main block content"),
|
|
14
|
+
name: "content",
|
|
15
|
+
optional: false,
|
|
16
|
+
typeExpression: 'string & tags.MaxLength<1000> & tags.Default<"">',
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
attributeType: "string",
|
|
20
|
+
defaultValue: "left",
|
|
21
|
+
description: describe("Alignment"),
|
|
22
|
+
enumValues: [...BASIC_ALIGNMENT_VALUES],
|
|
23
|
+
name: "alignment",
|
|
24
|
+
optional: true,
|
|
25
|
+
typeExpression: 'TextAlignment & tags.Default<"left">',
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
attributeType: "boolean",
|
|
29
|
+
defaultValue: true,
|
|
30
|
+
description: describe("Visibility toggle"),
|
|
31
|
+
name: "isVisible",
|
|
32
|
+
optional: true,
|
|
33
|
+
typeExpression: "boolean & tags.Default<true>",
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
attributeType: "string",
|
|
37
|
+
constraints: {
|
|
38
|
+
maxLength: 100,
|
|
39
|
+
},
|
|
40
|
+
defaultValue: "",
|
|
41
|
+
description: describe("Custom CSS class"),
|
|
42
|
+
name: "className",
|
|
43
|
+
optional: true,
|
|
44
|
+
typeExpression: 'string & tags.MaxLength<100> & tags.Default<"">',
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
attributeType: "string",
|
|
48
|
+
constraints: {
|
|
49
|
+
format: "uuid",
|
|
50
|
+
},
|
|
51
|
+
description: describe("Generated runtime ID"),
|
|
52
|
+
name: "id",
|
|
53
|
+
optional: true,
|
|
54
|
+
typeExpression: 'string & tags.Format<"uuid">',
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
attributeType: "number",
|
|
58
|
+
constraints: {
|
|
59
|
+
typeTag: "uint32",
|
|
60
|
+
},
|
|
61
|
+
defaultValue: 1,
|
|
62
|
+
description: describe("Block version for migrations"),
|
|
63
|
+
name: "schemaVersion",
|
|
64
|
+
optional: true,
|
|
65
|
+
typeExpression: 'number & tags.Type<"uint32"> & tags.Default<1>',
|
|
66
|
+
},
|
|
67
|
+
];
|
|
68
|
+
const INTERACTIVITY_ATTRIBUTE_SPECS = [
|
|
69
|
+
{
|
|
70
|
+
attributeType: "string",
|
|
71
|
+
constraints: {
|
|
72
|
+
maxLength: 1000,
|
|
73
|
+
},
|
|
74
|
+
defaultValue: "",
|
|
75
|
+
name: "content",
|
|
76
|
+
optional: false,
|
|
77
|
+
selector: (variables) => `.${variables.cssClassName}__content`,
|
|
78
|
+
source: "html",
|
|
79
|
+
typeExpression: 'string & tags.MaxLength<1000> & tags.Default<"">',
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
attributeType: "string",
|
|
83
|
+
defaultValue: "left",
|
|
84
|
+
enumValues: [...ALIGNMENT_VALUES],
|
|
85
|
+
name: "alignment",
|
|
86
|
+
optional: true,
|
|
87
|
+
typeExpression: 'TextAlignment & tags.Default<"left">',
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
attributeType: "boolean",
|
|
91
|
+
defaultValue: true,
|
|
92
|
+
name: "isVisible",
|
|
93
|
+
optional: true,
|
|
94
|
+
typeExpression: "boolean & tags.Default<true>",
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
attributeType: "string",
|
|
98
|
+
defaultValue: "click",
|
|
99
|
+
enumValues: [...INTERACTIVE_MODE_VALUES],
|
|
100
|
+
name: "interactiveMode",
|
|
101
|
+
optional: true,
|
|
102
|
+
typeExpression: '("click" | "hover") & tags.Default<"click">',
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
attributeType: "string",
|
|
106
|
+
defaultValue: "none",
|
|
107
|
+
enumValues: [...ANIMATION_VALUES],
|
|
108
|
+
name: "animation",
|
|
109
|
+
optional: true,
|
|
110
|
+
typeExpression: '("none" | "bounce" | "pulse" | "shake" | "flip") & tags.Default<"none">',
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
attributeType: "number",
|
|
114
|
+
constraints: {
|
|
115
|
+
minimum: 0,
|
|
116
|
+
typeTag: "uint32",
|
|
117
|
+
},
|
|
118
|
+
defaultValue: 0,
|
|
119
|
+
name: "clickCount",
|
|
120
|
+
optional: true,
|
|
121
|
+
typeExpression: 'number & tags.Minimum<0> & tags.Type<"uint32"> & tags.Default<0>',
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
attributeType: "boolean",
|
|
125
|
+
defaultValue: false,
|
|
126
|
+
name: "isAnimating",
|
|
127
|
+
optional: true,
|
|
128
|
+
typeExpression: "boolean & tags.Default<false>",
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
attributeType: "boolean",
|
|
132
|
+
defaultValue: true,
|
|
133
|
+
name: "showCounter",
|
|
134
|
+
optional: true,
|
|
135
|
+
typeExpression: "boolean & tags.Default<true>",
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
attributeType: "number",
|
|
139
|
+
constraints: {
|
|
140
|
+
minimum: 0,
|
|
141
|
+
typeTag: "uint32",
|
|
142
|
+
},
|
|
143
|
+
defaultValue: 10,
|
|
144
|
+
name: "maxClicks",
|
|
145
|
+
optional: true,
|
|
146
|
+
typeExpression: 'number & tags.Minimum<0> & tags.Type<"uint32"> & tags.Default<10>',
|
|
147
|
+
},
|
|
148
|
+
];
|
|
149
|
+
const PERSISTENCE_ATTRIBUTE_SPECS = [
|
|
150
|
+
{
|
|
151
|
+
attributeType: "string",
|
|
152
|
+
constraints: {
|
|
153
|
+
maxLength: 250,
|
|
154
|
+
minLength: 1,
|
|
155
|
+
},
|
|
156
|
+
defaultValue: (variables) => `${variables.title} persistence block`,
|
|
157
|
+
name: "content",
|
|
158
|
+
optional: false,
|
|
159
|
+
selector: (variables) => `.${variables.cssClassName}__content`,
|
|
160
|
+
source: "html",
|
|
161
|
+
typeExpression: (variables) => `string & tags.MinLength<1> & tags.MaxLength<250> & tags.Default<${JSON.stringify(`${variables.title} persistence block`)}>`,
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
attributeType: "string",
|
|
165
|
+
defaultValue: "left",
|
|
166
|
+
enumValues: [...ALIGNMENT_VALUES],
|
|
167
|
+
name: "alignment",
|
|
168
|
+
optional: true,
|
|
169
|
+
typeExpression: 'TextAlignment & tags.Default<"left">',
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
attributeType: "boolean",
|
|
173
|
+
defaultValue: true,
|
|
174
|
+
name: "isVisible",
|
|
175
|
+
optional: true,
|
|
176
|
+
typeExpression: "boolean & tags.Default<true>",
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
attributeType: "boolean",
|
|
180
|
+
defaultValue: true,
|
|
181
|
+
name: "showCount",
|
|
182
|
+
optional: true,
|
|
183
|
+
typeExpression: "boolean & tags.Default<true>",
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
attributeType: "string",
|
|
187
|
+
constraints: {
|
|
188
|
+
maxLength: 40,
|
|
189
|
+
minLength: 1,
|
|
190
|
+
},
|
|
191
|
+
defaultValue: "Persist Count",
|
|
192
|
+
name: "buttonLabel",
|
|
193
|
+
optional: true,
|
|
194
|
+
typeExpression: 'string & tags.MinLength<1> & tags.MaxLength<40> & tags.Default<"Persist Count">',
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
attributeType: "string",
|
|
198
|
+
blockJsonDefaultValue: "",
|
|
199
|
+
constraints: {
|
|
200
|
+
maxLength: 100,
|
|
201
|
+
minLength: 1,
|
|
202
|
+
},
|
|
203
|
+
manifestDefaultValue: "primary",
|
|
204
|
+
name: "resourceKey",
|
|
205
|
+
optional: true,
|
|
206
|
+
typeExpression: 'string & tags.MinLength<1> & tags.MaxLength<100> & tags.Default<"primary">',
|
|
207
|
+
},
|
|
208
|
+
];
|
|
209
|
+
const COMPOUND_PARENT_BASE_ATTRIBUTE_SPECS = [
|
|
210
|
+
{
|
|
211
|
+
attributeType: "string",
|
|
212
|
+
constraints: {
|
|
213
|
+
maxLength: 80,
|
|
214
|
+
minLength: 1,
|
|
215
|
+
},
|
|
216
|
+
defaultValue: (variables) => variables.title,
|
|
217
|
+
name: "heading",
|
|
218
|
+
optional: false,
|
|
219
|
+
selector: (variables) => `.${variables.cssClassName}__heading`,
|
|
220
|
+
source: "html",
|
|
221
|
+
typeExpression: (variables) => `string & tags.MinLength<1> & tags.MaxLength<80> & tags.Default<${JSON.stringify(variables.title)}>`,
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
attributeType: "string",
|
|
225
|
+
constraints: {
|
|
226
|
+
maxLength: 180,
|
|
227
|
+
minLength: 1,
|
|
228
|
+
},
|
|
229
|
+
defaultValue: "Add and reorder internal items inside this compound block.",
|
|
230
|
+
name: "intro",
|
|
231
|
+
optional: true,
|
|
232
|
+
selector: (variables) => `.${variables.cssClassName}__intro`,
|
|
233
|
+
source: "html",
|
|
234
|
+
typeExpression: 'string & tags.MinLength<1> & tags.MaxLength<180> & tags.Default<"Add and reorder internal items inside this compound block.">',
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
attributeType: "boolean",
|
|
238
|
+
defaultValue: true,
|
|
239
|
+
name: "showDividers",
|
|
240
|
+
optional: true,
|
|
241
|
+
typeExpression: "boolean & tags.Default<true>",
|
|
242
|
+
},
|
|
243
|
+
];
|
|
244
|
+
const COMPOUND_PARENT_PERSISTENCE_ATTRIBUTE_SPECS = [
|
|
245
|
+
{
|
|
246
|
+
attributeType: "boolean",
|
|
247
|
+
defaultValue: true,
|
|
248
|
+
name: "showCount",
|
|
249
|
+
optional: true,
|
|
250
|
+
typeExpression: "boolean & tags.Default<true>",
|
|
251
|
+
},
|
|
252
|
+
{
|
|
253
|
+
attributeType: "string",
|
|
254
|
+
constraints: {
|
|
255
|
+
maxLength: 40,
|
|
256
|
+
minLength: 1,
|
|
257
|
+
},
|
|
258
|
+
defaultValue: "Persist Count",
|
|
259
|
+
name: "buttonLabel",
|
|
260
|
+
optional: true,
|
|
261
|
+
typeExpression: 'string & tags.MinLength<1> & tags.MaxLength<40> & tags.Default<"Persist Count">',
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
attributeType: "string",
|
|
265
|
+
blockJsonDefaultValue: "",
|
|
266
|
+
constraints: {
|
|
267
|
+
maxLength: 100,
|
|
268
|
+
minLength: 1,
|
|
269
|
+
},
|
|
270
|
+
manifestDefaultValue: "primary",
|
|
271
|
+
name: "resourceKey",
|
|
272
|
+
optional: true,
|
|
273
|
+
typeExpression: 'string & tags.MinLength<1> & tags.MaxLength<100> & tags.Default<"primary">',
|
|
274
|
+
},
|
|
275
|
+
];
|
|
276
|
+
const COMPOUND_CHILD_ATTRIBUTE_SPECS = [
|
|
277
|
+
{
|
|
278
|
+
attributeType: "string",
|
|
279
|
+
constraints: {
|
|
280
|
+
maxLength: 80,
|
|
281
|
+
minLength: 1,
|
|
282
|
+
},
|
|
283
|
+
defaultValue: ({ childTitle }) => childTitle,
|
|
284
|
+
name: "title",
|
|
285
|
+
optional: false,
|
|
286
|
+
selector: ({ childCssClassName }) => childCssClassName ? `.${childCssClassName}__title` : null,
|
|
287
|
+
source: ({ childCssClassName }) => childCssClassName ? "html" : null,
|
|
288
|
+
typeExpression: ({ childTitle }) => `string & tags.MinLength<1> & tags.MaxLength<80> & tags.Default<${JSON.stringify(childTitle)}>`,
|
|
289
|
+
},
|
|
290
|
+
{
|
|
291
|
+
attributeType: "string",
|
|
292
|
+
constraints: {
|
|
293
|
+
maxLength: 280,
|
|
294
|
+
minLength: 1,
|
|
295
|
+
},
|
|
296
|
+
defaultValue: ({ bodyPlaceholder }) => bodyPlaceholder,
|
|
297
|
+
name: "body",
|
|
298
|
+
optional: false,
|
|
299
|
+
selector: ({ childCssClassName }) => childCssClassName ? `.${childCssClassName}__body` : null,
|
|
300
|
+
source: ({ childCssClassName }) => childCssClassName ? "html" : null,
|
|
301
|
+
typeExpression: ({ bodyPlaceholder }) => `string & tags.MinLength<1> & tags.MaxLength<280> & tags.Default<${JSON.stringify(bodyPlaceholder)}>`,
|
|
302
|
+
},
|
|
303
|
+
];
|
|
304
|
+
/**
|
|
305
|
+
* Builds the emitted attribute set for the basic built-in block family.
|
|
306
|
+
*
|
|
307
|
+
* @returns Emitted attribute definitions for the basic template family.
|
|
308
|
+
*/
|
|
309
|
+
export function buildBasicAttributes() {
|
|
310
|
+
return buildAttributesFromSpecs(BASIC_ATTRIBUTE_SPECS, undefined);
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* Builds the emitted attribute set for the interactivity built-in block family.
|
|
314
|
+
*
|
|
315
|
+
* @param variables Resolved scaffold template variables for the generated block.
|
|
316
|
+
* @returns Emitted attribute definitions for the interactivity template family.
|
|
317
|
+
*/
|
|
318
|
+
export function buildInteractivityAttributes(variables) {
|
|
319
|
+
return buildAttributesFromSpecs(INTERACTIVITY_ATTRIBUTE_SPECS, variables);
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* Builds the emitted attribute set for the persistence built-in block family.
|
|
323
|
+
*
|
|
324
|
+
* @param variables Resolved scaffold template variables for the generated block.
|
|
325
|
+
* @returns Emitted attribute definitions for the persistence template family.
|
|
326
|
+
*/
|
|
327
|
+
export function buildPersistenceAttributes(variables) {
|
|
328
|
+
return buildAttributesFromSpecs(PERSISTENCE_ATTRIBUTE_SPECS, variables);
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* Builds the emitted attribute set for the compound parent built-in block family.
|
|
332
|
+
*
|
|
333
|
+
* @param variables Resolved scaffold template variables for the generated block.
|
|
334
|
+
* @returns Emitted attribute definitions for the compound parent artifact.
|
|
335
|
+
*/
|
|
336
|
+
export function buildCompoundParentAttributes(variables) {
|
|
337
|
+
return buildAttributesFromSpecs(variables.compoundPersistenceEnabled === "true"
|
|
338
|
+
? [
|
|
339
|
+
...COMPOUND_PARENT_BASE_ATTRIBUTE_SPECS,
|
|
340
|
+
...COMPOUND_PARENT_PERSISTENCE_ATTRIBUTE_SPECS,
|
|
341
|
+
]
|
|
342
|
+
: COMPOUND_PARENT_BASE_ATTRIBUTE_SPECS, variables);
|
|
343
|
+
}
|
|
344
|
+
/**
|
|
345
|
+
* Builds the emitted attribute set for the compound child built-in block family.
|
|
346
|
+
*
|
|
347
|
+
* @param bodyPlaceholder Placeholder text for the child body field.
|
|
348
|
+
* @param childTitle Default title used by the child block.
|
|
349
|
+
* @param childCssClassName Optional CSS class used for HTML-backed selectors.
|
|
350
|
+
* @returns Emitted attribute definitions for the compound child artifact.
|
|
351
|
+
*/
|
|
352
|
+
export function buildCompoundChildAttributes(childTitle, childCssClassName, bodyPlaceholder = DEFAULT_COMPOUND_CHILD_BODY_PLACEHOLDER) {
|
|
353
|
+
return buildAttributesFromSpecs(COMPOUND_CHILD_ATTRIBUTE_SPECS, {
|
|
354
|
+
bodyPlaceholder,
|
|
355
|
+
childCssClassName,
|
|
356
|
+
childTitle,
|
|
357
|
+
});
|
|
358
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const BASIC_EDIT_TEMPLATE = "/**\n * Editor component for {{title}} Block\n */\n\nimport type { BlockEditProps } from '@wp-typia/block-types/blocks/registration';\nimport {\n InspectorControls,\n RichText,\n useBlockProps,\n} from '@wordpress/block-editor';\nimport { Notice, PanelBody, TextControl } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport currentManifest from './manifest-document';\nimport {\n InspectorFromManifest,\n useEditorFields,\n useTypedAttributeUpdater,\n} from '@wp-typia/block-runtime/inspector';\nimport { {{pascalCase}}Attributes } from './types';\nimport {\n sanitize{{pascalCase}}Attributes,\n validate{{pascalCase}}Attributes,\n} from './validators';\nimport { useTypiaValidation } from './hooks';\n\ntype EditProps = BlockEditProps<{{pascalCase}}Attributes>;\n\nconst validationErrorItemStyle = { color: '#cc1818', fontSize: '12px' };\nconst validationListStyle = { margin: 0, paddingLeft: '1em' };\n\nfunction Edit({ attributes, setAttributes }: EditProps) {\n const isVisible = attributes.isVisible !== false;\n const blockProps = useBlockProps({\n className: `{{cssClassName}}${isVisible ? '' : ' is-hidden'}`,\n });\n const editorFields = useEditorFields(currentManifest, {\n hidden: ['id', 'schemaVersion'],\n manual: ['content'],\n labels: {\n alignment: __('Alignment', '{{textDomain}}'),\n className: __('CSS Class', '{{textDomain}}'),\n content: __('Content', '{{textDomain}}'),\n isVisible: __('Visible', '{{textDomain}}'),\n },\n });\n const classNameField = editorFields.getField('className');\n const { errorMessages, isValid } = useTypiaValidation(\n attributes,\n validate{{pascalCase}}Attributes\n );\n const validateEditorUpdate = (nextAttributes: {{pascalCase}}Attributes) => {\n try {\n return {\n data: sanitize{{pascalCase}}Attributes(nextAttributes),\n errors: [],\n isValid: true as const,\n };\n } catch {\n return validate{{pascalCase}}Attributes(nextAttributes);\n }\n };\n const { updateField } = useTypedAttributeUpdater(\n attributes,\n setAttributes,\n validateEditorUpdate\n );\n\n return (\n <>\n <InspectorControls>\n <InspectorFromManifest\n attributes={attributes}\n fieldLookup={editorFields}\n onChange={updateField}\n paths={['alignment', 'isVisible']}\n title={__('Settings', '{{textDomain}}')}\n >\n <TextControl\n label={__('Content', '{{textDomain}}')}\n value={attributes.content || ''}\n onChange={(value) => updateField('content', value)}\n help={__('Mirrors the main block content.', '{{textDomain}}')}\n />\n\n <TextControl\n label={classNameField?.label || __('CSS Class', '{{textDomain}}')}\n value={attributes.className || ''}\n onChange={(value) => updateField('className', value)}\n help={__('Add an optional CSS class name.', '{{textDomain}}')}\n />\n </InspectorFromManifest>\n\n {!isValid && (\n <PanelBody title={__('Validation Errors', '{{textDomain}}')} initialOpen>\n {errorMessages.map((error, index) => (\n <div key={index} style={validationErrorItemStyle}>\n \u2022 {error}\n </div>\n ))}\n </PanelBody>\n )}\n </InspectorControls>\n\n <div {...blockProps}>\n <div className=\"{{cssClassName}}__content\">\n <RichText\n tagName=\"p\"\n value={attributes.content || ''}\n onChange={(value) => updateField('content', value)}\n placeholder={__('Add your content...', '{{textDomain}}')}\n />\n </div>\n {!isValid && (\n <Notice status=\"error\" isDismissible={false}>\n <p>\n <strong>{__('Validation Errors', '{{textDomain}}')}</strong>\n </p>\n <ul style={validationListStyle}>\n {errorMessages.map((error, index) => (\n <li key={index}>{error}</li>\n ))}\n </ul>\n </Notice>\n )}\n </div>\n </>\n );\n}\n\nexport default Edit;\n";
|
|
2
|
+
export declare const BASIC_SAVE_TEMPLATE = "/**\n * Save/Frontend component for {{title}} Block\n */\n\nimport { RichText, useBlockProps } from '@wordpress/block-editor';\nimport { {{pascalCase}}Attributes } from './types';\n\ninterface SaveProps {\n attributes: {{pascalCase}}Attributes;\n}\n\nexport default function Save({ attributes }: SaveProps) {\n const isVisible = attributes.isVisible !== false;\n const blockProps = useBlockProps.save({\n className: `{{cssClassName}}${isVisible ? '' : ' is-hidden'}`,\n hidden: isVisible ? undefined : true,\n 'aria-hidden': isVisible ? undefined : 'true',\n });\n\n return (\n <div {...blockProps}>\n <div\n className=\"{{cssClassName}}__content\"\n data-align={attributes.alignment || 'left'}\n >\n <RichText.Content tagName=\"p\" value={attributes.content} />\n </div>\n </div>\n );\n}\n";
|
|
3
|
+
export declare const BASIC_INDEX_TEMPLATE = "/**\n * WordPress {{title}} Block\n *\n * Typia-powered type-safe block\n */\n\nimport {\n registerScaffoldBlockType,\n type BlockConfiguration,\n} from '@wp-typia/block-types/blocks/registration';\nimport type { BlockSupports } from '@wp-typia/block-types/blocks/supports';\nimport { __ } from '@wordpress/i18n';\nimport {\n buildScaffoldBlockRegistration,\n parseScaffoldBlockMetadata,\n} from '@wp-typia/block-runtime/blocks';\n\n// Import components\nimport Edit from './edit';\nimport Save from './save';\nimport metadata from './block-metadata';\nimport './editor.scss';\nimport './style.scss';\n\n// Import types\nimport { {{pascalCase}}Attributes } from './types';\nimport { validators } from './validators';\n\nconst scaffoldSupports = {\n html: false,\n multiple: true,\n align: ['wide', 'full'],\n} satisfies BlockSupports;\n\n// Register the block\nconst registration = buildScaffoldBlockRegistration(\n parseScaffoldBlockMetadata<BlockConfiguration<{{pascalCase}}Attributes>>(metadata),\n {\n supports: scaffoldSupports,\n example: {\n attributes: validators.random(),\n },\n edit: Edit,\n save: Save,\n }\n);\n\nregisterScaffoldBlockType(registration.name, registration.settings);\n";
|
|
4
|
+
export declare const BASIC_VALIDATORS_TEMPLATE = "import typia from 'typia';\nimport currentManifest from \"./manifest-defaults-document\";\nimport { {{pascalCase}}Attributes, {{pascalCase}}ValidationResult } from \"./types\";\nimport { generateBlockId } from \"@wp-typia/block-runtime/identifiers\";\nimport { createTemplateValidatorToolkit } from \"./validator-toolkit\";\n\nconst scaffoldValidators = createTemplateValidatorToolkit<{{pascalCase}}Attributes>({\n assert: typia.createAssert<{{pascalCase}}Attributes>(),\n clone: typia.misc.createClone<{{pascalCase}}Attributes>() as (\n value: {{pascalCase}}Attributes,\n ) => {{pascalCase}}Attributes,\n is: typia.createIs<{{pascalCase}}Attributes>(),\n manifest: currentManifest,\n prune: typia.misc.createPrune<{{pascalCase}}Attributes>(),\n random: typia.createRandom<{{pascalCase}}Attributes>() as (\n ...args: unknown[]\n ) => {{pascalCase}}Attributes,\n finalize: (normalized) => ({\n ...normalized,\n id: normalized.id && normalized.id.length > 0 ? normalized.id : generateBlockId(),\n }),\n validate: typia.createValidate<{{pascalCase}}Attributes>(),\n});\n\nexport const validate{{pascalCase}}Attributes =\n scaffoldValidators.validateAttributes as (\n attributes: unknown,\n ) => {{pascalCase}}ValidationResult;\n\nexport const validators = scaffoldValidators.validators;\n\nexport const sanitize{{pascalCase}}Attributes =\n scaffoldValidators.sanitizeAttributes as (\n attributes: Partial<{{pascalCase}}Attributes>,\n ) => {{pascalCase}}Attributes;\n\nexport const createAttributeUpdater = scaffoldValidators.createAttributeUpdater;\n";
|