@wp-typia/project-tools 0.16.1 → 0.16.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -0
- package/dist/runtime/block-generator-service.d.ts +102 -0
- package/dist/runtime/block-generator-service.js +268 -0
- package/dist/runtime/built-in-block-artifacts.d.ts +37 -0
- package/dist/runtime/built-in-block-artifacts.js +1203 -0
- package/dist/runtime/built-in-block-code-artifacts.d.ts +30 -0
- package/dist/runtime/built-in-block-code-artifacts.js +122 -0
- package/dist/runtime/index.d.ts +2 -0
- package/dist/runtime/index.js +1 -0
- package/dist/runtime/package-versions.js +7 -2
- package/dist/runtime/scaffold-apply-utils.d.ts +47 -0
- package/dist/runtime/scaffold-apply-utils.js +405 -0
- package/dist/runtime/scaffold-identifiers.d.ts +34 -0
- package/dist/runtime/scaffold-identifiers.js +82 -0
- package/dist/runtime/scaffold.js +33 -0
- package/dist/runtime/schema-core.d.ts +5 -266
- package/dist/runtime/schema-core.js +5 -775
- package/dist/runtime/starter-manifests.d.ts +3 -2
- package/dist/runtime/starter-manifests.js +15 -365
- package/dist/runtime/template-render.d.ts +5 -0
- package/dist/runtime/template-render.js +13 -3
- package/package.json +56 -3
- package/templates/_shared/compound/persistence/scripts/block-config.ts.mustache +4 -4
- package/templates/_shared/persistence/core/scripts/sync-rest-contracts.ts.mustache +4 -4
- package/templates/_shared/base/src/hooks.ts.mustache +0 -19
- package/templates/_shared/compound/persistence/src/blocks/{{slugKebabCase}}/block.json.mustache +0 -52
- package/templates/_shared/compound/persistence/src/blocks/{{slugKebabCase}}/edit.tsx.mustache +0 -123
- package/templates/_shared/compound/persistence/src/blocks/{{slugKebabCase}}/hooks.ts.mustache +0 -11
- package/templates/_shared/compound/persistence/src/blocks/{{slugKebabCase}}/interactivity.ts.mustache +0 -305
- package/templates/_shared/compound/persistence/src/blocks/{{slugKebabCase}}/save.tsx.mustache +0 -3
- package/templates/_shared/compound/persistence/src/blocks/{{slugKebabCase}}/types.ts.mustache +0 -61
- package/templates/_shared/compound/persistence/src/blocks/{{slugKebabCase}}/validators.ts.mustache +0 -43
- package/templates/_shared/persistence/core/src/index.tsx.mustache +0 -25
- package/templates/_shared/persistence/core/src/interactivity.ts.mustache +0 -308
- package/templates/_shared/persistence/core/src/save.tsx.mustache +0 -5
- package/templates/_shared/persistence/core/src/validators.ts.mustache +0 -43
- package/templates/basic/src/block.json.mustache +0 -51
- package/templates/basic/src/edit.tsx.mustache +0 -128
- package/templates/basic/src/index.tsx.mustache +0 -45
- package/templates/basic/src/save.tsx.mustache +0 -30
- package/templates/basic/src/types.ts.mustache +0 -56
- package/templates/basic/src/validators.ts.mustache +0 -37
- package/templates/compound/src/blocks/{{slugKebabCase}}/block.json.mustache +0 -37
- package/templates/compound/src/blocks/{{slugKebabCase}}/children.ts.mustache +0 -25
- package/templates/compound/src/blocks/{{slugKebabCase}}/edit.tsx.mustache +0 -93
- package/templates/compound/src/blocks/{{slugKebabCase}}/hooks.ts.mustache +0 -11
- package/templates/compound/src/blocks/{{slugKebabCase}}/index.tsx.mustache +0 -25
- package/templates/compound/src/blocks/{{slugKebabCase}}/save.tsx.mustache +0 -32
- package/templates/compound/src/blocks/{{slugKebabCase}}/types.ts.mustache +0 -18
- package/templates/compound/src/blocks/{{slugKebabCase}}/validators.ts.mustache +0 -35
- package/templates/compound/src/blocks/{{slugKebabCase}}-item/block.json.mustache +0 -35
- package/templates/compound/src/blocks/{{slugKebabCase}}-item/edit.tsx.mustache +0 -50
- package/templates/compound/src/blocks/{{slugKebabCase}}-item/hooks.ts.mustache +0 -11
- package/templates/compound/src/blocks/{{slugKebabCase}}-item/index.tsx.mustache +0 -25
- package/templates/compound/src/blocks/{{slugKebabCase}}-item/save.tsx.mustache +0 -24
- package/templates/compound/src/blocks/{{slugKebabCase}}-item/types.ts.mustache +0 -17
- package/templates/compound/src/blocks/{{slugKebabCase}}-item/validators.ts.mustache +0 -35
- package/templates/interactivity/src/block.json.mustache +0 -74
- package/templates/interactivity/src/edit.tsx.mustache +0 -270
- package/templates/interactivity/src/index.tsx.mustache +0 -33
- package/templates/interactivity/src/interactivity.ts.mustache +0 -152
- package/templates/interactivity/src/save.tsx.mustache +0 -101
- package/templates/interactivity/src/types.ts.mustache +0 -32
- package/templates/interactivity/src/validators.ts.mustache +0 -47
- package/templates/persistence/src/block.json.mustache +0 -52
- package/templates/persistence/src/edit.tsx.mustache +0 -165
- package/templates/persistence/src/types.ts.mustache +0 -59
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
import { __ } from '@wordpress/i18n';
|
|
2
|
-
import {
|
|
3
|
-
AlignmentToolbar,
|
|
4
|
-
BlockControls,
|
|
5
|
-
InspectorControls,
|
|
6
|
-
RichText,
|
|
7
|
-
useBlockProps,
|
|
8
|
-
} from '@wordpress/block-editor';
|
|
9
|
-
import {
|
|
10
|
-
Notice,
|
|
11
|
-
PanelBody,
|
|
12
|
-
TextControl,
|
|
13
|
-
} from '@wordpress/components';
|
|
14
|
-
import currentManifest from './typia.manifest.json';
|
|
15
|
-
import {
|
|
16
|
-
InspectorFromManifest,
|
|
17
|
-
type ManifestDocument,
|
|
18
|
-
useEditorFields,
|
|
19
|
-
useTypedAttributeUpdater,
|
|
20
|
-
} from '@wp-typia/block-runtime/inspector';
|
|
21
|
-
import type { {{pascalCase}}Attributes } from './types';
|
|
22
|
-
import {
|
|
23
|
-
sanitize{{pascalCase}}Attributes,
|
|
24
|
-
validate{{pascalCase}}Attributes,
|
|
25
|
-
} from './validators';
|
|
26
|
-
import { useTypiaValidation } from './hooks';
|
|
27
|
-
|
|
28
|
-
export default function Edit( {
|
|
29
|
-
attributes,
|
|
30
|
-
setAttributes,
|
|
31
|
-
}: {
|
|
32
|
-
attributes: {{pascalCase}}Attributes;
|
|
33
|
-
setAttributes: ( attrs: Partial< {{pascalCase}}Attributes > ) => void;
|
|
34
|
-
} ) {
|
|
35
|
-
const editorFields = useEditorFields(
|
|
36
|
-
currentManifest as ManifestDocument,
|
|
37
|
-
{
|
|
38
|
-
manual: [ 'content', 'resourceKey' ],
|
|
39
|
-
labels: {
|
|
40
|
-
buttonLabel: __( 'Button Label', '{{textDomain}}' ),
|
|
41
|
-
resourceKey: __( 'Resource Key', '{{textDomain}}' ),
|
|
42
|
-
showCount: __( 'Show Count', '{{textDomain}}' ),
|
|
43
|
-
},
|
|
44
|
-
}
|
|
45
|
-
);
|
|
46
|
-
const { errorMessages, isValid } = useTypiaValidation(
|
|
47
|
-
attributes,
|
|
48
|
-
validate{{pascalCase}}Attributes
|
|
49
|
-
);
|
|
50
|
-
const validateEditorUpdate = (
|
|
51
|
-
nextAttributes: {{pascalCase}}Attributes
|
|
52
|
-
) => {
|
|
53
|
-
try {
|
|
54
|
-
return {
|
|
55
|
-
data: sanitize{{pascalCase}}Attributes( nextAttributes ),
|
|
56
|
-
errors: [],
|
|
57
|
-
isValid: true as const,
|
|
58
|
-
};
|
|
59
|
-
} catch {
|
|
60
|
-
return validate{{pascalCase}}Attributes( nextAttributes );
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
const { updateField } = useTypedAttributeUpdater(
|
|
64
|
-
attributes,
|
|
65
|
-
setAttributes,
|
|
66
|
-
validateEditorUpdate
|
|
67
|
-
);
|
|
68
|
-
const alignmentValue = editorFields.getStringValue(
|
|
69
|
-
attributes,
|
|
70
|
-
'alignment',
|
|
71
|
-
'left'
|
|
72
|
-
);
|
|
73
|
-
const persistencePolicy = '{{persistencePolicy}}';
|
|
74
|
-
const persistencePolicyDescription = __(
|
|
75
|
-
{{persistencePolicyDescriptionJson}},
|
|
76
|
-
'{{textDomain}}'
|
|
77
|
-
);
|
|
78
|
-
|
|
79
|
-
return (
|
|
80
|
-
<>
|
|
81
|
-
<BlockControls>
|
|
82
|
-
<AlignmentToolbar
|
|
83
|
-
value={ alignmentValue }
|
|
84
|
-
onChange={ ( value ) =>
|
|
85
|
-
updateField(
|
|
86
|
-
'alignment',
|
|
87
|
-
( value || alignmentValue ) as NonNullable< {{pascalCase}}Attributes[ 'alignment' ] >
|
|
88
|
-
)
|
|
89
|
-
}
|
|
90
|
-
/>
|
|
91
|
-
</BlockControls>
|
|
92
|
-
<InspectorControls>
|
|
93
|
-
<InspectorFromManifest
|
|
94
|
-
attributes={ attributes }
|
|
95
|
-
fieldLookup={ editorFields }
|
|
96
|
-
onChange={ updateField }
|
|
97
|
-
paths={ [ 'alignment', 'isVisible', 'showCount', 'buttonLabel' ] }
|
|
98
|
-
title={ __( 'Persistence Settings', '{{textDomain}}' ) }
|
|
99
|
-
>
|
|
100
|
-
<TextControl
|
|
101
|
-
label={ __( 'Resource Key', '{{textDomain}}' ) }
|
|
102
|
-
value={ attributes.resourceKey ?? '' }
|
|
103
|
-
onChange={ ( value ) => updateField( 'resourceKey', value ) }
|
|
104
|
-
help={ __( 'Stable persisted identifier used by the storage-backed counter endpoint.', '{{textDomain}}' ) }
|
|
105
|
-
/>
|
|
106
|
-
<Notice status="info" isDismissible={ false }>
|
|
107
|
-
{ __( 'Storage mode: {{dataStorageMode}}', '{{textDomain}}' ) }
|
|
108
|
-
</Notice>
|
|
109
|
-
<Notice status="info" isDismissible={ false }>
|
|
110
|
-
{ __( 'Persistence policy: {{persistencePolicy}}', '{{textDomain}}' ) }
|
|
111
|
-
<br />
|
|
112
|
-
{ persistencePolicyDescription }
|
|
113
|
-
</Notice>
|
|
114
|
-
<Notice status="info" isDismissible={ false }>
|
|
115
|
-
{ __( 'Render mode: dynamic. `render.php` bootstraps durable post context, while fresh session-only write data is loaded from the dedicated `/bootstrap` endpoint after hydration.', '{{textDomain}}' ) }
|
|
116
|
-
</Notice>
|
|
117
|
-
</InspectorFromManifest>
|
|
118
|
-
{ ! isValid && (
|
|
119
|
-
<PanelBody
|
|
120
|
-
title={ __( 'Validation Errors', '{{textDomain}}' ) }
|
|
121
|
-
initialOpen
|
|
122
|
-
>
|
|
123
|
-
{ errorMessages.map( ( error, index ) => (
|
|
124
|
-
<Notice key={ index } status="error" isDismissible={ false }>
|
|
125
|
-
{ error }
|
|
126
|
-
</Notice>
|
|
127
|
-
) ) }
|
|
128
|
-
</PanelBody>
|
|
129
|
-
) }
|
|
130
|
-
</InspectorControls>
|
|
131
|
-
<div
|
|
132
|
-
{ ...useBlockProps( {
|
|
133
|
-
className: '{{cssClassName}}',
|
|
134
|
-
style: {
|
|
135
|
-
textAlign:
|
|
136
|
-
alignmentValue as NonNullable< {{pascalCase}}Attributes[ 'alignment' ] >,
|
|
137
|
-
},
|
|
138
|
-
} ) }
|
|
139
|
-
>
|
|
140
|
-
<RichText
|
|
141
|
-
tagName="p"
|
|
142
|
-
value={ attributes.content }
|
|
143
|
-
onChange={ ( value ) => updateField( 'content', value ) }
|
|
144
|
-
placeholder={ __( '{{title}} persistence block', '{{textDomain}}' ) }
|
|
145
|
-
/>
|
|
146
|
-
<p className="{{cssClassName}}__meta">
|
|
147
|
-
{ __( 'Resource key:', '{{textDomain}}' ) } { attributes.resourceKey || '—' }
|
|
148
|
-
</p>
|
|
149
|
-
<p className="{{cssClassName}}__meta">
|
|
150
|
-
{ __( 'Storage mode:', '{{textDomain}}' ) } {{dataStorageMode}}
|
|
151
|
-
</p>
|
|
152
|
-
<p className="{{cssClassName}}__meta">
|
|
153
|
-
{ __( 'Persistence policy:', '{{textDomain}}' ) } {{persistencePolicy}}
|
|
154
|
-
</p>
|
|
155
|
-
{ ! isValid && (
|
|
156
|
-
<Notice status="error" isDismissible={ false }>
|
|
157
|
-
<ul>
|
|
158
|
-
{ errorMessages.map( ( error, index ) => <li key={ index }>{ error }</li> ) }
|
|
159
|
-
</ul>
|
|
160
|
-
</Notice>
|
|
161
|
-
) }
|
|
162
|
-
</div>
|
|
163
|
-
</>
|
|
164
|
-
);
|
|
165
|
-
}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import type { TextAlignment } from '@wp-typia/block-types/block-editor/alignment';
|
|
2
|
-
import type {
|
|
3
|
-
TypiaValidationError,
|
|
4
|
-
ValidationResult,
|
|
5
|
-
} from '@wp-typia/block-runtime/validation';
|
|
6
|
-
import { tags } from 'typia';
|
|
7
|
-
|
|
8
|
-
export type {
|
|
9
|
-
TypiaValidationError,
|
|
10
|
-
ValidationResult,
|
|
11
|
-
} from '@wp-typia/block-runtime/validation';
|
|
12
|
-
|
|
13
|
-
export interface {{pascalCase}}Attributes {
|
|
14
|
-
content: string &
|
|
15
|
-
tags.MinLength< 1 > &
|
|
16
|
-
tags.MaxLength< 250 > &
|
|
17
|
-
tags.Default< '{{title}} persistence block' >;
|
|
18
|
-
alignment?: TextAlignment & tags.Default< 'left' >;
|
|
19
|
-
isVisible?: boolean & tags.Default< true >;
|
|
20
|
-
showCount?: boolean & tags.Default< true >;
|
|
21
|
-
buttonLabel?: string &
|
|
22
|
-
tags.MinLength< 1 > &
|
|
23
|
-
tags.MaxLength< 40 > &
|
|
24
|
-
tags.Default< 'Persist Count' >;
|
|
25
|
-
resourceKey?: string &
|
|
26
|
-
tags.MinLength< 1 > &
|
|
27
|
-
tags.MaxLength< 100 > &
|
|
28
|
-
tags.Default< 'primary' >;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export interface {{pascalCase}}Context {
|
|
32
|
-
buttonLabel: string;
|
|
33
|
-
bootstrapReady: boolean;
|
|
34
|
-
canWrite: boolean;
|
|
35
|
-
count: number;
|
|
36
|
-
error: string;
|
|
37
|
-
isBootstrapping: boolean;
|
|
38
|
-
isLoading: boolean;
|
|
39
|
-
isSaving: boolean;
|
|
40
|
-
persistencePolicy: 'authenticated' | 'public';
|
|
41
|
-
postId: number;
|
|
42
|
-
resourceKey: string;
|
|
43
|
-
storage: 'post-meta' | 'custom-table';
|
|
44
|
-
isVisible: boolean;
|
|
45
|
-
client?: {{pascalCase}}ClientState;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export interface {{pascalCase}}State {
|
|
49
|
-
isHydrated: boolean;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export interface {{pascalCase}}ClientState {
|
|
53
|
-
bootstrapError: string;
|
|
54
|
-
writeExpiry: number;
|
|
55
|
-
writeNonce: string;
|
|
56
|
-
writeToken: string;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export type {{pascalCase}}ValidationResult = ValidationResult< {{pascalCase}}Attributes >;
|