@wp-typia/project-tools 0.16.2 → 0.16.5

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.
Files changed (80) hide show
  1. package/README.md +13 -0
  2. package/dist/runtime/block-generator-service.d.ts +102 -0
  3. package/dist/runtime/block-generator-service.js +268 -0
  4. package/dist/runtime/built-in-block-artifacts.d.ts +37 -0
  5. package/dist/runtime/built-in-block-artifacts.js +1203 -0
  6. package/dist/runtime/built-in-block-code-artifacts.d.ts +31 -0
  7. package/dist/runtime/built-in-block-code-artifacts.js +137 -0
  8. package/dist/runtime/built-in-block-non-ts-artifacts.d.ts +18 -0
  9. package/dist/runtime/built-in-block-non-ts-artifacts.js +563 -0
  10. package/dist/runtime/cli-doctor.js +10 -5
  11. package/dist/runtime/index.d.ts +2 -0
  12. package/dist/runtime/index.js +1 -0
  13. package/dist/runtime/scaffold-apply-utils.d.ts +47 -0
  14. package/dist/runtime/scaffold-apply-utils.js +405 -0
  15. package/dist/runtime/scaffold-identifiers.d.ts +34 -0
  16. package/dist/runtime/scaffold-identifiers.js +82 -0
  17. package/dist/runtime/scaffold.js +33 -0
  18. package/dist/runtime/starter-manifests.d.ts +3 -2
  19. package/dist/runtime/starter-manifests.js +15 -365
  20. package/dist/runtime/template-builtins.d.ts +9 -0
  21. package/dist/runtime/template-builtins.js +31 -1
  22. package/dist/runtime/template-render.d.ts +5 -0
  23. package/dist/runtime/template-render.js +13 -3
  24. package/dist/runtime/template-source.js +9 -3
  25. package/package.json +2 -2
  26. package/templates/_shared/compound/persistence/scripts/block-config.ts.mustache +4 -4
  27. package/templates/_shared/persistence/core/scripts/sync-rest-contracts.ts.mustache +4 -4
  28. package/templates/_shared/base/src/hooks.ts.mustache +0 -19
  29. package/templates/_shared/compound/persistence/src/blocks/{{slugKebabCase}}/block.json.mustache +0 -52
  30. package/templates/_shared/compound/persistence/src/blocks/{{slugKebabCase}}/edit.tsx.mustache +0 -123
  31. package/templates/_shared/compound/persistence/src/blocks/{{slugKebabCase}}/hooks.ts.mustache +0 -11
  32. package/templates/_shared/compound/persistence/src/blocks/{{slugKebabCase}}/interactivity.ts.mustache +0 -305
  33. package/templates/_shared/compound/persistence/src/blocks/{{slugKebabCase}}/render.php.mustache +0 -152
  34. package/templates/_shared/compound/persistence/src/blocks/{{slugKebabCase}}/save.tsx.mustache +0 -3
  35. package/templates/_shared/compound/persistence/src/blocks/{{slugKebabCase}}/types.ts.mustache +0 -61
  36. package/templates/_shared/compound/persistence/src/blocks/{{slugKebabCase}}/validators.ts.mustache +0 -43
  37. package/templates/_shared/persistence/core/src/index.tsx.mustache +0 -25
  38. package/templates/_shared/persistence/core/src/interactivity.ts.mustache +0 -308
  39. package/templates/_shared/persistence/core/src/save.tsx.mustache +0 -5
  40. package/templates/_shared/persistence/core/src/validators.ts.mustache +0 -43
  41. package/templates/basic/src/block.json.mustache +0 -51
  42. package/templates/basic/src/edit.tsx.mustache +0 -128
  43. package/templates/basic/src/editor.scss.mustache +0 -8
  44. package/templates/basic/src/hooks.ts.mustache +0 -18
  45. package/templates/basic/src/index.tsx.mustache +0 -45
  46. package/templates/basic/src/render.php.mustache +0 -19
  47. package/templates/basic/src/save.tsx.mustache +0 -30
  48. package/templates/basic/src/style.scss.mustache +0 -40
  49. package/templates/basic/src/types.ts.mustache +0 -56
  50. package/templates/basic/src/validators.ts.mustache +0 -37
  51. package/templates/compound/src/blocks/{{slugKebabCase}}/block.json.mustache +0 -37
  52. package/templates/compound/src/blocks/{{slugKebabCase}}/children.ts.mustache +0 -25
  53. package/templates/compound/src/blocks/{{slugKebabCase}}/edit.tsx.mustache +0 -93
  54. package/templates/compound/src/blocks/{{slugKebabCase}}/hooks.ts.mustache +0 -11
  55. package/templates/compound/src/blocks/{{slugKebabCase}}/index.tsx.mustache +0 -25
  56. package/templates/compound/src/blocks/{{slugKebabCase}}/save.tsx.mustache +0 -32
  57. package/templates/compound/src/blocks/{{slugKebabCase}}/style.scss.mustache +0 -31
  58. package/templates/compound/src/blocks/{{slugKebabCase}}/types.ts.mustache +0 -18
  59. package/templates/compound/src/blocks/{{slugKebabCase}}/validators.ts.mustache +0 -35
  60. package/templates/compound/src/blocks/{{slugKebabCase}}-item/block.json.mustache +0 -35
  61. package/templates/compound/src/blocks/{{slugKebabCase}}-item/edit.tsx.mustache +0 -50
  62. package/templates/compound/src/blocks/{{slugKebabCase}}-item/hooks.ts.mustache +0 -11
  63. package/templates/compound/src/blocks/{{slugKebabCase}}-item/index.tsx.mustache +0 -25
  64. package/templates/compound/src/blocks/{{slugKebabCase}}-item/save.tsx.mustache +0 -24
  65. package/templates/compound/src/blocks/{{slugKebabCase}}-item/types.ts.mustache +0 -17
  66. package/templates/compound/src/blocks/{{slugKebabCase}}-item/validators.ts.mustache +0 -35
  67. package/templates/interactivity/src/block.json.mustache +0 -74
  68. package/templates/interactivity/src/edit.tsx.mustache +0 -270
  69. package/templates/interactivity/src/editor.scss.mustache +0 -8
  70. package/templates/interactivity/src/index.tsx.mustache +0 -33
  71. package/templates/interactivity/src/interactivity.ts.mustache +0 -152
  72. package/templates/interactivity/src/save.tsx.mustache +0 -101
  73. package/templates/interactivity/src/style.scss.mustache +0 -60
  74. package/templates/interactivity/src/types.ts.mustache +0 -32
  75. package/templates/interactivity/src/validators.ts.mustache +0 -47
  76. package/templates/persistence/src/block.json.mustache +0 -52
  77. package/templates/persistence/src/edit.tsx.mustache +0 -165
  78. package/templates/persistence/src/render.php.mustache +0 -120
  79. package/templates/persistence/src/style.scss.mustache +0 -46
  80. package/templates/persistence/src/types.ts.mustache +0 -59
@@ -1,32 +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 { TypiaValidationError, ValidationResult } from "@wp-typia/block-runtime/validation";
9
-
10
- export interface {{pascalCase}}Attributes {
11
- content: string & tags.MinLength<1> & tags.MaxLength<1000> & tags.Default<"">;
12
- alignment?: TextAlignment & tags.Default<"left">;
13
- isVisible?: boolean & tags.Default<true>;
14
- interactiveMode?: ('click' | 'hover' | 'auto') & tags.Default<"click">;
15
- animation?: ('none' | 'bounce' | 'pulse' | 'shake' | 'flip') & tags.Default<"none">;
16
- clickCount?: number & tags.Minimum<0> & tags.Type<"uint32"> & tags.Default<0>;
17
- isAnimating?: boolean & tags.Default<false>;
18
- showCounter?: boolean & tags.Default<true>;
19
- maxClicks?: number & tags.Minimum<0> & tags.Type<"uint32"> & tags.Default<10>;
20
- autoPlayInterval?: number & tags.Minimum<0> & tags.Type<"uint32"> & tags.Default<0>;
21
- uniqueId?: string & tags.Default<"">;
22
- }
23
-
24
- export interface {{pascalCase}}Context {
25
- clicks: number;
26
- isAnimating: boolean;
27
- isVisible: boolean;
28
- lastInteraction: string;
29
- animationClass: string;
30
- }
31
-
32
- export type {{pascalCase}}ValidationResult = ValidationResult<{{pascalCase}}Attributes>;
@@ -1,47 +0,0 @@
1
- import typia from 'typia';
2
- import currentManifest from "./typia.manifest.json";
3
- import { {{pascalCase}}Attributes, {{pascalCase}}ValidationResult } from "./types";
4
- import { generateScopedClientId } from "@wp-typia/block-runtime/identifiers";
5
- import { createTemplateValidatorToolkit } from "./validator-toolkit";
6
-
7
- const scaffoldValidators = createTemplateValidatorToolkit<{{pascalCase}}Attributes>({
8
- assert: typia.createAssert<{{pascalCase}}Attributes>(),
9
- clone: typia.misc.createClone<{{pascalCase}}Attributes>() as (
10
- value: {{pascalCase}}Attributes,
11
- ) => {{pascalCase}}Attributes,
12
- is: typia.createIs<{{pascalCase}}Attributes>(),
13
- manifest: currentManifest,
14
- prune: typia.misc.createPrune<{{pascalCase}}Attributes>(),
15
- random: typia.createRandom<{{pascalCase}}Attributes>() as (
16
- ...args: unknown[]
17
- ) => {{pascalCase}}Attributes,
18
- finalize: (normalized) => ({
19
- ...normalized,
20
- uniqueId:
21
- normalized.uniqueId && normalized.uniqueId.length > 0
22
- ? normalized.uniqueId
23
- : generateScopedClientId("{{slugKebabCase}}"),
24
- }),
25
- validate: typia.createValidate<{{pascalCase}}Attributes>(),
26
- });
27
-
28
- export const validate{{pascalCase}}Attributes =
29
- scaffoldValidators.validateAttributes as (
30
- attributes: unknown,
31
- ) => {{pascalCase}}ValidationResult;
32
-
33
- export const validators = scaffoldValidators.validators;
34
-
35
- export const sanitize{{pascalCase}}Attributes =
36
- scaffoldValidators.sanitizeAttributes as (
37
- attributes: Partial<{{pascalCase}}Attributes>,
38
- ) => {{pascalCase}}Attributes;
39
-
40
- /**
41
- * Runtime type guard for checking if an object is {{pascalCase}}Attributes.
42
- */
43
- export const is{{pascalCase}}Attributes = (obj: unknown): obj is {{pascalCase}}Attributes => {
44
- return validators.is(obj);
45
- };
46
-
47
- export const createAttributeUpdater = scaffoldValidators.createAttributeUpdater;
@@ -1,52 +0,0 @@
1
- {
2
- "$schema": "https://schemas.wp.org/trunk/block.json",
3
- "apiVersion": 3,
4
- "name": "{{namespace}}/{{slugKebabCase}}",
5
- "version": "{{blockMetadataVersion}}",
6
- "title": "{{title}}",
7
- "category": "{{category}}",
8
- "icon": "{{icon}}",
9
- "description": "{{description}}",
10
- "example": {},
11
- "supports": {
12
- "html": false,
13
- "align": true,
14
- "anchor": true,
15
- "className": true,
16
- "interactivity": true
17
- },
18
- "attributes": {
19
- "content": {
20
- "type": "string",
21
- "source": "html",
22
- "selector": ".{{cssClassName}}__content",
23
- "default": "{{title}} persistence block"
24
- },
25
- "alignment": {
26
- "type": "string",
27
- "enum": ["left", "center", "right"],
28
- "default": "left"
29
- },
30
- "isVisible": {
31
- "type": "boolean",
32
- "default": true
33
- },
34
- "showCount": {
35
- "type": "boolean",
36
- "default": true
37
- },
38
- "buttonLabel": {
39
- "type": "string",
40
- "default": "Persist Count"
41
- },
42
- "resourceKey": {
43
- "type": "string",
44
- "default": ""
45
- }
46
- },
47
- "textdomain": "{{textDomain}}",
48
- "editorScript": "file:./index.js",
49
- "style": "file:./style-index.css",
50
- "viewScriptModule": "file:./interactivity.js",
51
- "render": "file:./render.php"
52
- }
@@ -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,120 +0,0 @@
1
- <?php
2
- /**
3
- * Dynamic render entry for the {{title}} block.
4
- *
5
- * @package {{pascalCase}}
6
- */
7
-
8
- if ( ! defined( 'ABSPATH' ) ) {
9
- exit;
10
- }
11
-
12
- $validator_path = __DIR__ . '/typia-validator.php';
13
- if ( ! file_exists( $validator_path ) ) {
14
- return '';
15
- }
16
-
17
- $validator = require $validator_path;
18
- if ( ! is_object( $validator ) || ! method_exists( $validator, 'apply_defaults' ) || ! method_exists( $validator, 'validate' ) ) {
19
- return '';
20
- }
21
-
22
- $normalized = $validator->apply_defaults( is_array( $attributes ) ? $attributes : array() );
23
- $validation = $validator->validate( $normalized );
24
- $resource_key = isset( $normalized['resourceKey'] ) ? (string) $normalized['resourceKey'] : '';
25
-
26
- if ( empty( $validation['valid'] ) || '' === $resource_key ) {
27
- return '';
28
- }
29
-
30
- $alignment = isset( $normalized['alignment'] ) ? (string) $normalized['alignment'] : 'left';
31
- $button_label = isset( $normalized['buttonLabel'] ) ? (string) $normalized['buttonLabel'] : 'Persist Count';
32
- $content = isset( $normalized['content'] ) ? (string) $normalized['content'] : '';
33
- $post_id = is_object( $block ) && isset( $block->context['postId'] )
34
- ? (int) $block->context['postId']
35
- : (int) get_queried_object_id();
36
- $storage_mode = '{{dataStorageMode}}';
37
- $persistence_policy = '{{persistencePolicy}}';
38
-
39
- {{phpPrefix}}_record_rendered_block_instance(
40
- (int) $post_id,
41
- '{{namespace}}/{{slugKebabCase}}',
42
- $resource_key
43
- );
44
-
45
- $notice_message = 'authenticated' === $persistence_policy
46
- ? __( 'Sign in to persist this counter.', '{{textDomain}}' )
47
- : __( 'Public writes are temporarily unavailable.', '{{textDomain}}' );
48
- $context = array(
49
- 'bootstrapReady' => false,
50
- 'buttonLabel' => $button_label,
51
- 'canWrite' => false,
52
- 'client' => array(
53
- 'writeExpiry' => 0,
54
- 'writeNonce' => '',
55
- 'writeToken' => '',
56
- ),
57
- 'count' => 0,
58
- 'error' => '',
59
- 'isBootstrapping' => false,
60
- 'isLoading' => false,
61
- 'isSaving' => false,
62
- 'isVisible' => ! empty( $normalized['isVisible'] ),
63
- 'persistencePolicy' => $persistence_policy,
64
- 'postId' => (int) $post_id,
65
- 'resourceKey' => $resource_key,
66
- 'storage' => $storage_mode,
67
- );
68
-
69
- $wrapper_attributes = get_block_wrapper_attributes(
70
- array(
71
- 'data-wp-context' => wp_json_encode( $context ),
72
- 'data-wp-interactive' => '{{slugKebabCase}}',
73
- 'data-wp-init' => 'callbacks.init',
74
- 'data-wp-run--mounted' => 'callbacks.mounted',
75
- )
76
- );
77
- ?>
78
-
79
- <div <?php echo $wrapper_attributes; ?>>
80
- <div class="{{frontendCssClassName}}">
81
- <p class="{{frontendCssClassName}}__content" style="<?php echo esc_attr( 'text-align:' . $alignment ); ?>">
82
- <?php echo esc_html( $content ); ?>
83
- </p>
84
- <p
85
- class="{{frontendCssClassName}}__notice"
86
- data-wp-bind--hidden="!context.bootstrapReady || context.canWrite"
87
- hidden
88
- >
89
- <?php echo esc_html( $notice_message ); ?>
90
- </p>
91
- <p
92
- class="{{frontendCssClassName}}__error"
93
- role="status"
94
- aria-live="polite"
95
- aria-atomic="true"
96
- data-wp-bind--hidden="!context.error"
97
- data-wp-text="context.error"
98
- hidden
99
- ></p>
100
- <?php if ( ! empty( $normalized['showCount'] ) ) : ?>
101
- <span
102
- class="{{frontendCssClassName}}__count"
103
- role="status"
104
- aria-live="polite"
105
- aria-atomic="true"
106
- data-wp-text="context.count"
107
- >
108
- 0
109
- </span>
110
- <?php endif; ?>
111
- <button
112
- type="button"
113
- disabled
114
- data-wp-bind--disabled="!context.canWrite"
115
- data-wp-on--click="actions.increment"
116
- >
117
- <?php echo esc_html( $button_label ); ?>
118
- </button>
119
- </div>
120
- </div>
@@ -1,46 +0,0 @@
1
- .{{cssClassName}} {
2
- border: 1px solid #dcdcde;
3
- border-radius: 12px;
4
- padding: 16px;
5
- background: #fff;
6
-
7
- &__meta {
8
- color: #50575e;
9
- font-size: 13px;
10
- margin: 8px 0 0;
11
- }
12
- }
13
-
14
- .{{frontendCssClassName}} {
15
- display: grid;
16
- gap: 12px;
17
- border: 1px solid #dcdcde;
18
- border-radius: 12px;
19
- padding: 16px;
20
- background: #f6f7f7;
21
-
22
- &__count {
23
- display: inline-flex;
24
- min-width: 3rem;
25
- justify-content: center;
26
- font-weight: 700;
27
- }
28
-
29
- &__notice,
30
- &__error {
31
- margin: 0;
32
- font-size: 13px;
33
- }
34
-
35
- &__notice {
36
- color: #50575e;
37
- }
38
-
39
- &__error {
40
- color: #b32d2e;
41
- }
42
-
43
- button {
44
- width: fit-content;
45
- }
46
- }
@@ -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 >;