@wp-typia/project-tools 0.13.2 → 0.13.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/dist/runtime/scaffold-onboarding.js +1 -1
- package/dist/runtime/scaffold.d.ts +5 -3
- package/dist/runtime/scaffold.js +8 -3
- package/package.json +2 -2
- package/templates/_shared/compound/core/scripts/add-compound-child.ts.mustache +4 -0
- package/templates/basic/src/edit.tsx.mustache +1 -1
- package/templates/basic/src/render.php.mustache +19 -0
- package/templates/basic/src/save.tsx.mustache +1 -1
|
@@ -44,7 +44,7 @@ export function getTemplateSourceOfTruthNote(templateId, { compoundPersistenceEn
|
|
|
44
44
|
if (templateId === "persistence") {
|
|
45
45
|
return "`src/types.ts` remains the source of truth for `block.json`, `typia.manifest.json`, and `typia-validator.php`. Fresh scaffolds include a starter `typia.manifest.json` so editor imports resolve before the first sync. `src/api-types.ts` remains the source of truth for `src/api-schemas/*` when you run `sync-rest`. This scaffold is intentionally server-rendered: `src/render.php` is the canonical frontend entry, and `src/save.tsx` returns `null` so PHP can inject post context, storage-backed state, and write-policy bootstrap data before hydration.";
|
|
46
46
|
}
|
|
47
|
-
return "`src/types.ts` remains the source of truth for `block.json`, `typia.manifest.json`, and `typia-validator.php`. Fresh scaffolds include a starter `typia.manifest.json` so editor imports resolve before the first sync. The basic scaffold stays static by design:
|
|
47
|
+
return "`src/types.ts` remains the source of truth for `block.json`, `typia.manifest.json`, and `typia-validator.php`. Fresh scaffolds include a starter `typia.manifest.json` so editor imports resolve before the first sync. The basic scaffold stays static by design: `src/render.php` is only an opt-in server placeholder, `src/save.tsx` remains the canonical frontend output, and the generated webpack config keeps the current `@wordpress/scripts` CommonJS baseline unless you intentionally add `render` to `block.json`.";
|
|
48
48
|
}
|
|
49
49
|
/**
|
|
50
50
|
* Returns the generated-project extension workflow for compound child blocks.
|
|
@@ -129,9 +129,11 @@ export interface ScaffoldProjectResult {
|
|
|
129
129
|
* Builds the generated WordPress wrapper CSS class for a scaffolded block.
|
|
130
130
|
*
|
|
131
131
|
* Returns `wp-block-{namespace}-{slug}` when a non-empty namespace is present,
|
|
132
|
-
* or `wp-block-{slug}` when the namespace is empty or undefined.
|
|
133
|
-
*
|
|
134
|
-
*
|
|
132
|
+
* or `wp-block-{slug}` when the namespace is empty or undefined. When the
|
|
133
|
+
* normalized namespace equals the normalized slug, appends `-block` so the
|
|
134
|
+
* generated class avoids repeated namespace segments without colliding with the
|
|
135
|
+
* default core wrapper classes. Both inputs are normalized and validated with
|
|
136
|
+
* the same scaffold identifier rules used for block names.
|
|
135
137
|
*/
|
|
136
138
|
export declare function buildBlockCssClassName(namespace: string | undefined, slug: string): string;
|
|
137
139
|
export declare function isDataStorageMode(value: string): value is DataStorageMode;
|
package/dist/runtime/scaffold.js
CHANGED
|
@@ -74,15 +74,20 @@ function resolveValidatedPhpPrefix(value) {
|
|
|
74
74
|
* Builds the generated WordPress wrapper CSS class for a scaffolded block.
|
|
75
75
|
*
|
|
76
76
|
* Returns `wp-block-{namespace}-{slug}` when a non-empty namespace is present,
|
|
77
|
-
* or `wp-block-{slug}` when the namespace is empty or undefined.
|
|
78
|
-
*
|
|
79
|
-
*
|
|
77
|
+
* or `wp-block-{slug}` when the namespace is empty or undefined. When the
|
|
78
|
+
* normalized namespace equals the normalized slug, appends `-block` so the
|
|
79
|
+
* generated class avoids repeated namespace segments without colliding with the
|
|
80
|
+
* default core wrapper classes. Both inputs are normalized and validated with
|
|
81
|
+
* the same scaffold identifier rules used for block names.
|
|
80
82
|
*/
|
|
81
83
|
export function buildBlockCssClassName(namespace, slug) {
|
|
82
84
|
const normalizedSlug = resolveValidatedBlockSlug(slug);
|
|
83
85
|
const normalizedNamespace = typeof namespace === "string" && namespace.trim().length > 0
|
|
84
86
|
? resolveValidatedNamespace(namespace)
|
|
85
87
|
: "";
|
|
88
|
+
if (normalizedNamespace === normalizedSlug) {
|
|
89
|
+
return `wp-block-${normalizedSlug}-block`;
|
|
90
|
+
}
|
|
86
91
|
return normalizedNamespace.length > 0
|
|
87
92
|
? `wp-block-${normalizedNamespace}-${normalizedSlug}`
|
|
88
93
|
: `wp-block-${normalizedSlug}`;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wp-typia/project-tools",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.4",
|
|
4
4
|
"description": "Project orchestration and programmatic tooling for wp-typia",
|
|
5
5
|
"packageManager": "bun@1.3.11",
|
|
6
6
|
"type": "module",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"dependencies": {
|
|
64
64
|
"@wp-typia/api-client": "^0.4.0",
|
|
65
65
|
"@wp-typia/block-runtime": "^0.4.0",
|
|
66
|
-
"@wp-typia/rest": "^0.3.
|
|
66
|
+
"@wp-typia/rest": "^0.3.4",
|
|
67
67
|
"@wp-typia/block-types": "^0.2.0",
|
|
68
68
|
"mustache": "^4.2.0",
|
|
69
69
|
"npm-package-arg": "^13.0.0",
|
|
@@ -108,6 +108,10 @@ function buildBlockCssClassName( namespace: string, slug: string ): string {
|
|
|
108
108
|
? resolveValidatedNamespace( namespace )
|
|
109
109
|
: '';
|
|
110
110
|
|
|
111
|
+
if ( normalizedNamespace === normalizedSlug ) {
|
|
112
|
+
return `wp-block-${ normalizedSlug }-block`;
|
|
113
|
+
}
|
|
114
|
+
|
|
111
115
|
return normalizedNamespace.length > 0
|
|
112
116
|
? `wp-block-${ normalizedNamespace }-${ normalizedSlug }`
|
|
113
117
|
: `wp-block-${ normalizedSlug }`;
|
|
@@ -29,7 +29,7 @@ type EditProps = BlockEditProps<{{pascalCase}}Attributes>;
|
|
|
29
29
|
function Edit({ attributes, setAttributes }: EditProps) {
|
|
30
30
|
const isVisible = attributes.isVisible !== false;
|
|
31
31
|
const blockProps = useBlockProps({
|
|
32
|
-
className: isVisible ?
|
|
32
|
+
className: `{{cssClassName}}${isVisible ? '' : ' is-hidden'}`,
|
|
33
33
|
});
|
|
34
34
|
const editorFields = useEditorFields(currentManifest as ManifestDocument, {
|
|
35
35
|
hidden: ['id', 'schemaVersion'],
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
/**
|
|
3
|
+
* Optional server render placeholder for {{title}}.
|
|
4
|
+
*
|
|
5
|
+
* The basic scaffold stays static by default. Keep `src/save.tsx` as the
|
|
6
|
+
* canonical frontend output unless you intentionally convert this block into a
|
|
7
|
+
* dynamic render path and add `render` to `block.json`.
|
|
8
|
+
*
|
|
9
|
+
* @package {{slug}}
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
if ( ! defined( 'ABSPATH' ) ) {
|
|
13
|
+
exit;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
?>
|
|
17
|
+
<div class="{{cssClassName}}__server-placeholder" hidden>
|
|
18
|
+
<?php esc_html_e( 'Server render placeholder.', '{{textDomain}}' ); ?>
|
|
19
|
+
</div>
|
|
@@ -12,7 +12,7 @@ interface SaveProps {
|
|
|
12
12
|
export default function Save({ attributes }: SaveProps) {
|
|
13
13
|
const isVisible = attributes.isVisible !== false;
|
|
14
14
|
const blockProps = useBlockProps.save({
|
|
15
|
-
className: isVisible ?
|
|
15
|
+
className: `{{cssClassName}}${isVisible ? '' : ' is-hidden'}`,
|
|
16
16
|
hidden: isVisible ? undefined : true,
|
|
17
17
|
'aria-hidden': isVisible ? undefined : 'true',
|
|
18
18
|
});
|