@wp-typia/project-tools 0.22.2 → 0.22.3
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/built-in-block-code-templates/interactivity.d.ts +1 -1
- package/dist/runtime/built-in-block-code-templates/interactivity.js +4 -2
- package/dist/runtime/cli-add-shared.d.ts +49 -0
- package/dist/runtime/cli-add-shared.js +204 -71
- package/dist/runtime/cli-add-workspace-ability-scaffold.d.ts +5 -0
- package/dist/runtime/cli-add-workspace-ability-scaffold.js +392 -0
- package/dist/runtime/cli-add-workspace-ability-templates.d.ts +34 -0
- package/dist/runtime/cli-add-workspace-ability-templates.js +500 -0
- package/dist/runtime/cli-add-workspace-ability-types.d.ts +27 -0
- package/dist/runtime/cli-add-workspace-ability-types.js +14 -0
- package/dist/runtime/cli-add-workspace-ability.js +12 -852
- package/dist/runtime/cli-add-workspace-ai-scaffold.d.ts +21 -0
- package/dist/runtime/cli-add-workspace-ai-scaffold.js +91 -0
- package/dist/runtime/cli-add-workspace-ai-templates.d.ts +4 -0
- package/dist/runtime/cli-add-workspace-ai-templates.js +605 -0
- package/dist/runtime/cli-add-workspace-ai.js +15 -688
- package/dist/runtime/cli-add-workspace-assets.js +7 -4
- package/dist/runtime/cli-add-workspace.js +1 -19
- package/dist/runtime/cli-doctor-workspace-bindings.d.ts +11 -0
- package/dist/runtime/cli-doctor-workspace-bindings.js +134 -0
- package/dist/runtime/cli-doctor-workspace-blocks.d.ts +11 -0
- package/dist/runtime/cli-doctor-workspace-blocks.js +504 -0
- package/dist/runtime/cli-doctor-workspace-features.d.ts +11 -0
- package/dist/runtime/cli-doctor-workspace-features.js +383 -0
- package/dist/runtime/cli-doctor-workspace-package.d.ts +18 -0
- package/dist/runtime/cli-doctor-workspace-package.js +59 -0
- package/dist/runtime/cli-doctor-workspace-shared.d.ts +69 -0
- package/dist/runtime/cli-doctor-workspace-shared.js +87 -0
- package/dist/runtime/cli-doctor-workspace.js +25 -1062
- package/package.json +3 -3
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare const INTERACTIVITY_EDIT_TEMPLATE = "import type { BlockEditProps } from '@wp-typia/block-types/blocks/registration';\nimport { __ } from '@wordpress/i18n';\nimport { useBlockProps, InspectorControls, RichText, BlockControls, AlignmentToolbar } from '@wordpress/block-editor';\nimport { PanelBody, RangeControl, Button, Notice } from '@wordpress/components';\nimport { useState } from '@wordpress/element';\nimport currentManifest from './manifest-document';\nimport { {{slugCamelCase}}Store } from './interactivity-store';\nimport {\n InspectorFromManifest,\n useEditorFields,\n useTypedAttributeUpdater,\n} from '@wp-typia/block-runtime/inspector';\nimport type { {{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 actionButtonRowStyle = { display: 'flex', gap: '8px', marginTop: '16px' };\nconst validationListStyle = { margin: 0, paddingLeft: '1em' };\n\nexport default function Edit({ attributes, setAttributes, isSelected }: EditProps) {\n const [isPreviewing, setIsPreviewing] = useState(false);\n const editorFields = useEditorFields(currentManifest, {\n manual: ['content', 'clickCount', 'maxClicks'],\n labels: {\n alignment: __('Alignment', '{{textDomain}}'),\n animation: __('Animation', '{{textDomain}}'),\n interactiveMode: __('Interactive Mode', '{{textDomain}}'),\n isVisible: __('Visible', '{{textDomain}}'),\n showCounter: __('Show Counter', '{{textDomain}}'),\n },\n });\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 const alignmentValue = editorFields.getStringValue(\n attributes,\n 'alignment',\n 'left'\n ) as NonNullable<{{pascalCase}}Attributes['alignment']>;\n const clickCount = attributes.clickCount ?? 0;\n const isVisible = editorFields.getBooleanValue(\n attributes,\n 'isVisible',\n true\n );\n const isAnimating = attributes.isAnimating ?? false;\n const maxClicks = attributes.maxClicks ?? 0;\n const showCounter = editorFields.getBooleanValue(\n attributes,\n 'showCounter',\n true\n );\n const interactiveMode = editorFields.getStringValue(\n attributes,\n 'interactiveMode',\n 'click'\n ) as NonNullable<{{pascalCase}}Attributes['interactiveMode']>;\n const animation = editorFields.getStringValue(\n attributes,\n 'animation',\n 'none'\n ) as NonNullable<{{pascalCase}}Attributes['animation']>;\n\n const blockProps = useBlockProps({\n className: `{{cssClassName}} {{cssClassName}}--${interactiveMode}`,\n 'data-wp-interactive': {{slugCamelCase}}Store.directive.interactive,\n 'data-wp-context': JSON.stringify(\n {{slugCamelCase}}Store.createContext({\n clicks: clickCount,\n isAnimating,\n isVisible,\n animation,\n maxClicks,\n })\n )\n });\n const previewContentStyle = { textAlign: alignmentValue };\n const progressBarStyle = { width: `${(clickCount / maxClicks) * 100}%` };\n const clicksDirective = {{slugCamelCase}}Store.directive.state('clicks');\n const isAnimatingDirective = {{slugCamelCase}}Store.directive.state('isAnimating');\n const progressDirective = {{slugCamelCase}}Store.directive.state('progress') + \" + '%'\";\n\n const resetCounter = () => {\n updateField('clickCount', 0);\n updateField('isAnimating', false);\n };\n\n const testAnimation = () => {\n updateField('isAnimating', true);\n setTimeout(() => {\n updateField('isAnimating', false);\n }, 1000);\n };\n\n return (\n <>\n <BlockControls>\n <AlignmentToolbar\n value={alignmentValue}\n onChange={(value) => updateField('alignment', (value || alignmentValue) as NonNullable<{{pascalCase}}Attributes['alignment']>)}\n />\n </BlockControls>\n\n <InspectorControls>\n <InspectorFromManifest\n attributes={attributes}\n fieldLookup={editorFields}\n onChange={updateField}\n paths={['alignment', 'interactiveMode', 'animation', 'showCounter', 'isVisible']}\n title={__('Interactive Settings', '{{textDomain}}')}\n />\n\n <PanelBody title={__('Counter Settings', '{{textDomain}}')}>\n <RangeControl\n label={__('Max Clicks', '{{textDomain}}')}\n value={maxClicks}\n onChange={(value) => updateField('maxClicks', value ?? maxClicks)}\n min={0}\n max={100}\n help={__('Set to 0 for unlimited clicks', '{{textDomain}}')}\n />\n\n <div style={actionButtonRowStyle}>\n <Button\n variant=\"secondary\"\n onClick={resetCounter}\n isSmall\n >\n {__('Reset Counter', '{{textDomain}}')}\n </Button>\n <Button\n variant=\"secondary\"\n onClick={testAnimation}\n isSmall\n >\n {__('Test Animation', '{{textDomain}}')}\n </Button>\n </div>\n </PanelBody>\n\n {!isValid && (\n <PanelBody title={__('Validation Errors', '{{textDomain}}')} initialOpen>\n {errorMessages.map((error, index) => (\n <Notice key={index} status=\"error\" isDismissible={false}>\n {error}\n </Notice>\n ))}\n </PanelBody>\n )}\n\n {isSelected && (\n <PanelBody title={__('Preview', '{{textDomain}}')}>\n <Button\n variant={isPreviewing ? 'primary' : 'secondary'}\n onClick={() => setIsPreviewing(!isPreviewing)}\n aria-pressed={isPreviewing}\n isSmall\n >\n {isPreviewing\n ? __('Disable Preview Mode', '{{textDomain}}')\n : __('Enable Preview Mode', '{{textDomain}}')}\n </Button>\n\n {clickCount > 0 && (\n <Notice status=\"info\" isDismissible={false}>\n {__('Current clicks:', '{{textDomain}}')} {clickCount}\n {maxClicks > 0 && ` / ${maxClicks}`}\n </Notice>\n )}\n </PanelBody>\n )}\n </InspectorControls>\n\n <div {...blockProps}>\n <div\n className={`{{cssClassName}}__content ${isAnimating ? 'is-animating' : ''}`}\n style={previewContentStyle}\n data-wp-on--click={isPreviewing ? {{slugCamelCase}}Store.directive.action('handleClick') : undefined}\n data-wp-on--mouseenter={isPreviewing && interactiveMode === 'hover' ? {{slugCamelCase}}Store.directive.action('handleMouseEnter') : undefined}\n data-wp-on--mouseleave={isPreviewing && interactiveMode === 'hover' ? {{slugCamelCase}}Store.directive.action('handleMouseLeave') : undefined}\n >\n <RichText\n tagName=\"p\"\n value={attributes.content}\n onChange={(value) => updateField('content', value)}\n placeholder={__( {{titleJson}} + ' \u2013 click me to interact!', '{{textDomain}}')}\n />\n\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\n {showCounter && (\n <div className=\"{{cssClassName}}__counter\">\n <span className=\"{{cssClassName}}__counter-label\">\n {__('Clicks:', '{{textDomain}}')}\n </span>\n <span\n className=\"{{cssClassName}}__counter-value\"\n data-wp-text={clicksDirective}\n >\n {clickCount}\n </span>\n </div>\n )}\n\n {maxClicks > 0 && (\n <div className=\"{{cssClassName}}__progress\">\n <div\n className=\"{{cssClassName}}__progress-bar\"\n style={progressBarStyle}\n data-wp-style--width={progressDirective}\n />\n </div>\n )}\n\n {animation !== 'none' && (\n <div\n className={`{{cssClassName}}__animation ${isAnimating ? 'is-active' : ''}`}\n data-wp-class--is-active={isAnimatingDirective}\n >\n {animation}\n </div>\n )}\n </div>\n </div>\n </>\n );\n}\n";
|
|
2
2
|
export declare const INTERACTIVITY_SAVE_TEMPLATE = "import { useBlockProps, RichText } from '@wordpress/block-editor';\nimport { __ } from '@wordpress/i18n';\nimport { {{slugCamelCase}}Store } from './interactivity-store';\nimport type { {{pascalCase}}Attributes } from './types';\n\nexport default function Save({ attributes }: { attributes: {{pascalCase}}Attributes }) {\n const clickCount = attributes.clickCount ?? 0;\n const interactiveMode = attributes.interactiveMode ?? 'click';\n const animation = attributes.animation ?? 'none';\n const isAnimating = attributes.isAnimating ?? false;\n const isVisible = attributes.isVisible ?? true;\n const maxClicks = attributes.maxClicks ?? 0;\n const showCounter = attributes.showCounter ?? true;\n const contentStyle = { textAlign: attributes.alignment };\n const clickActionDirective = {{slugCamelCase}}Store.directive.action('handleClick');\n const visibilityHiddenDirective = {{slugCamelCase}}Store.directive.negate(\n {{slugCamelCase}}Store.directive.state('isVisible')\n );\n const clicksDirective = {{slugCamelCase}}Store.directive.state('clicks');\n const clampedClicksDirective = {{slugCamelCase}}Store.directive.state('clampedClicks');\n const isAnimatingDirective = {{slugCamelCase}}Store.directive.state('isAnimating');\n const completionHiddenDirective = {{slugCamelCase}}Store.directive.negate(\n {{slugCamelCase}}Store.directive.state('isComplete')\n );\n const resetActionDirective = {{slugCamelCase}}Store.directive.action('reset');\n const blockProps = useBlockProps.save({\n className: `{{cssClassName}} {{cssClassName}}--${interactiveMode}`,\n 'data-wp-interactive': {{slugCamelCase}}Store.directive.interactive,\n 'data-wp-context': JSON.stringify(\n {{slugCamelCase}}Store.createContext({\n clicks: clickCount,\n isAnimating,\n isVisible,\n animation,\n maxClicks,\n })\n )\n });\n const progressDirective = {{slugCamelCase}}Store.directive.state('progress') + \" + '%'\";\n\n return (\n <div {...blockProps}>\n <div\n className={`{{cssClassName}}__content ${isAnimating ? 'is-animating' : ''}`}\n style={contentStyle}\n data-wp-on--click={clickActionDirective}\n data-wp-on--mouseenter={interactiveMode === 'hover' ? {{slugCamelCase}}Store.directive.action('handleMouseEnter') : undefined}\n data-wp-on--mouseleave={interactiveMode === 'hover' ? {{slugCamelCase}}Store.directive.action('handleMouseLeave') : undefined}\n data-wp-bind--hidden={visibilityHiddenDirective}\n >\n <RichText.Content\n tagName=\"p\"\n value={attributes.content}\n className=\"{{cssClassName}}__text\"\n />\n\n {showCounter && (\n <div\n className=\"{{cssClassName}}__counter\"\n role=\"status\"\n aria-live=\"polite\"\n aria-atomic=\"true\"\n >\n <span className=\"{{cssClassName}}__counter-label\">\n { __( 'Clicks:', '{{textDomain}}' ) }\n </span>\n <span\n className=\"{{cssClassName}}__counter-value\"\n data-wp-text={clicksDirective}\n >\n {clickCount}\n </span>\n </div>\n )}\n\n {maxClicks > 0 && (\n <div className=\"{{cssClassName}}__progress\">\n <div\n className=\"{{cssClassName}}__progress-bar\"\n role=\"progressbar\"\n aria-label={ __( 'Click progress', '{{textDomain}}' ) }\n aria-valuemin={0}\n aria-valuemax={maxClicks}\n aria-valuenow={Math.min(clickCount, maxClicks)}\n data-wp-bind--aria-valuenow={clampedClicksDirective}\n data-wp-style--width={progressDirective}\n />\n </div>\n )}\n\n <div\n className={`{{cssClassName}}__animation ${animation}`}\n aria-hidden=\"true\"\n data-wp-class--is-active={isAnimatingDirective}\n />\n\n {maxClicks > 0 && (\n <div\n className=\"{{cssClassName}}__completion\"\n role=\"status\"\n aria-live=\"polite\"\n aria-atomic=\"true\"\n data-wp-bind--hidden={completionHiddenDirective}\n >\n { __( '\uD83C\uDF89 Complete!', '{{textDomain}}' ) }\n </div>\n )}\n\n <button\n className=\"{{cssClassName}}__reset\"\n data-wp-on--click={resetActionDirective}\n aria-label={ __( 'Reset counter', '{{textDomain}}' ) }\n >\n <span aria-hidden=\"true\">\u21BB</span>\n <span className=\"screen-reader-text\">\n { __( 'Reset counter', '{{textDomain}}' ) }\n </span>\n </button>\n </div>\n </div>\n );\n}\n";
|
|
3
3
|
export declare const INTERACTIVITY_INDEX_TEMPLATE = "import {\n registerScaffoldBlockType,\n type BlockConfiguration,\n} from '@wp-typia/block-types/blocks/registration';\nimport type { BlockSupports } from '@wp-typia/block-types/blocks/supports';\nimport {\n buildScaffoldBlockRegistration,\n parseScaffoldBlockMetadata,\n} from '@wp-typia/block-runtime/blocks';\n\nimport Edit from './edit';\nimport Save from './save';\nimport metadata from './block-metadata';\nimport './editor.scss';\nimport './style.scss';\n\nimport type { {{pascalCase}}Attributes } from './types';\n\nconst scaffoldSupports = {\n html: false,\n align: true,\n anchor: true,\n className: true,\n interactivity: true,\n} satisfies BlockSupports;\n\nconst registration = buildScaffoldBlockRegistration(\n parseScaffoldBlockMetadata<BlockConfiguration<{{pascalCase}}Attributes>>(metadata),\n {\n supports: scaffoldSupports,\n edit: Edit,\n save: Save,\n }\n);\n\nregisterScaffoldBlockType(registration.name, registration.settings);\n";
|
|
4
|
-
export declare const INTERACTIVITY_STORE_TEMPLATE = "import type {\n {{pascalCase}}Context,\n {{pascalCase}}State,\n} from './types';\n\ntype InteractivityActionShape = object;\ntype InteractivityCallbackShape = object;\ntype InteractivityContextShape = object;\ntype InteractivityStateShape = object;\ntype InteractivityCallable
|
|
4
|
+
export declare const INTERACTIVITY_STORE_TEMPLATE = "import type {\n {{pascalCase}}Context,\n {{pascalCase}}State,\n} from './types';\n\ntype InteractivityActionShape = object;\ntype InteractivityCallbackShape = object;\ntype InteractivityContextShape = object;\ntype InteractivityStateShape = object;\ntype InteractivityCallable =\n | ((...args: unknown[]) => unknown)\n | ReturnType<typeof import('@wordpress/interactivity').withSyncEvent>;\ntype InteractivityKey<T extends object> = Extract<keyof T, string>;\ntype InteractivityMethodKey<T extends object> = {\n [Key in InteractivityKey<T>]: T[Key] extends InteractivityCallable ? Key : never;\n}[InteractivityKey<T>];\n\ntype InteractivityDirectivePath<\n Root extends string,\n Key extends string,\n> = `${Root}.${Key}`;\n\ntype NegatedInteractivityDirectivePath<Path extends string> = `!${Path}`;\n\nexport interface TypedInteractivityDirectiveHelpers<\n State extends InteractivityStateShape,\n Context extends InteractivityContextShape,\n Actions extends InteractivityActionShape,\n Callbacks extends InteractivityCallbackShape,\n Namespace extends string,\n> {\n readonly interactive: Namespace;\n action<Key extends InteractivityMethodKey<Actions>>(\n key: Key,\n ): InteractivityDirectivePath<'actions', Key>;\n callback<Key extends InteractivityMethodKey<Callbacks>>(\n key: Key,\n ): InteractivityDirectivePath<'callbacks', Key>;\n state<Key extends InteractivityKey<State>>(\n key: Key,\n ): InteractivityDirectivePath<'state', Key>;\n context<Key extends InteractivityKey<Context>>(\n key: Key,\n ): InteractivityDirectivePath<'context', Key>;\n negate<Path extends string>(\n path: Path,\n ): NegatedInteractivityDirectivePath<Path>;\n}\n\nexport interface TypedInteractivityStore<\n Namespace extends string,\n State extends InteractivityStateShape,\n Context extends InteractivityContextShape,\n Actions extends InteractivityActionShape,\n Callbacks extends InteractivityCallbackShape,\n> {\n readonly namespace: Namespace;\n readonly state: State;\n readonly context: Context;\n readonly actions: Actions;\n readonly callbacks: Callbacks;\n readonly directive: TypedInteractivityDirectiveHelpers<\n State,\n Context,\n Actions,\n Callbacks,\n Namespace\n >;\n createContext(value: Context): Context;\n}\n\nexport function defineInteractivityStore<\n Namespace extends string,\n State extends InteractivityStateShape,\n Context extends InteractivityContextShape,\n Actions extends InteractivityActionShape,\n Callbacks extends InteractivityCallbackShape,\n>(config: {\n readonly namespace: Namespace;\n readonly state: State;\n readonly context: Context;\n readonly actions: Actions;\n readonly callbacks: Callbacks;\n}): TypedInteractivityStore<Namespace, State, Context, Actions, Callbacks> {\n return {\n namespace: config.namespace,\n state: config.state,\n context: config.context,\n actions: config.actions,\n callbacks: config.callbacks,\n directive: {\n interactive: config.namespace,\n action<Key extends InteractivityMethodKey<Actions>>(key: Key) {\n return `actions.${key}` as InteractivityDirectivePath<'actions', Key>;\n },\n callback<Key extends InteractivityMethodKey<Callbacks>>(key: Key) {\n return `callbacks.${key}` as InteractivityDirectivePath<'callbacks', Key>;\n },\n state<Key extends InteractivityKey<State>>(key: Key) {\n return `state.${key}` as InteractivityDirectivePath<'state', Key>;\n },\n context<Key extends InteractivityKey<Context>>(key: Key) {\n return `context.${key}` as InteractivityDirectivePath<'context', Key>;\n },\n negate<Path extends string>(path: Path) {\n return `!${path}` as NegatedInteractivityDirectivePath<Path>;\n },\n },\n createContext(value) {\n return value;\n },\n };\n}\n\ntype InteractivityActionHandler = InteractivityCallable;\n\nexport interface {{pascalCase}}StoreActions {\n handleClick: InteractivityActionHandler;\n handleMouseEnter: InteractivityActionHandler;\n handleMouseLeave: InteractivityActionHandler;\n reset: InteractivityActionHandler;\n}\n\nexport interface {{pascalCase}}StoreCallbacks {}\n\nexport const {{slugCamelCase}}Store = defineInteractivityStore({\n namespace: '{{slugKebabCase}}',\n state: {} as {{pascalCase}}State,\n context: {} as {{pascalCase}}Context,\n actions: {} as {{pascalCase}}StoreActions,\n callbacks: {} as {{pascalCase}}StoreCallbacks,\n});\n";
|
|
5
5
|
export declare const INTERACTIVITY_SCRIPT_TEMPLATE = "/**\n * WordPress Interactivity API implementation for {{title}} block\n */\nimport { store, getContext, getElement, withSyncEvent } from '@wordpress/interactivity';\nimport {\n {{slugCamelCase}}Store,\n type {{pascalCase}}StoreActions,\n} from './interactivity-store';\nimport type { {{pascalCase}}Context, {{pascalCase}}State } from './types';\n\nfunction getBlockContext() {\n return getContext<{{pascalCase}}Context>();\n}\n\nconst actions: {{pascalCase}}StoreActions = {\n // Handle block click\n handleClick: () => {\n const context = getBlockContext();\n const { ref } = getElement();\n\n if (!ref) {\n return;\n }\n\n if (context.maxClicks > 0 && context.clicks >= context.maxClicks) {\n return;\n }\n\n const previousClicks = context.clicks;\n\n // Increment click counter\n context.clicks += 1;\n\n // Trigger animation\n if (context.animation !== 'none') {\n context.isAnimating = true;\n setTimeout(() => {\n context.isAnimating = false;\n }, 1000);\n }\n\n // Emit custom event\n ref.dispatchEvent(new CustomEvent('{{slugKebabCase}}:click', {\n detail: { clicks: context.clicks }\n }));\n\n // Check if max clicks reached\n if (context.maxClicks > 0 && previousClicks < context.maxClicks && context.clicks === context.maxClicks) {\n ref.dispatchEvent(new CustomEvent('{{slugKebabCase}}:complete', {\n detail: { totalClicks: context.clicks }\n }));\n }\n },\n\n // Handle hover events\n handleMouseEnter: () => {\n const context = getBlockContext();\n if (context.animation === 'none') return;\n context.isAnimating = true;\n },\n\n handleMouseLeave: () => {\n const context = getBlockContext();\n if (context.animation === 'none') return;\n context.isAnimating = false;\n },\n\n // Reset counter\n reset: withSyncEvent((event: Event) => {\n event.stopPropagation();\n const context = getBlockContext();\n context.clicks = 0;\n context.isAnimating = false;\n })\n};\n\nconst state = {\n get clicks() {\n return getBlockContext().clicks;\n },\n get isAnimating() {\n return getBlockContext().isAnimating;\n },\n get isVisible() {\n return getBlockContext().isVisible;\n },\n get progress() {\n const context = getBlockContext();\n const clampedClicks =\n context.maxClicks > 0\n ? Math.min(context.clicks, context.maxClicks)\n : context.clicks;\n return context.maxClicks > 0 ? (clampedClicks / context.maxClicks) * 100 : 0;\n },\n get clampedClicks() {\n const context = getBlockContext();\n return context.maxClicks > 0\n ? Math.min(context.clicks, context.maxClicks)\n : context.clicks;\n },\n get isComplete() {\n const context = getBlockContext();\n return context.clicks >= context.maxClicks && context.maxClicks > 0;\n }\n} satisfies {{pascalCase}}State;\n\n// Store configuration\nstore({{slugCamelCase}}Store.namespace, {\n // State - reactive data that updates the UI\n state,\n actions,\n callbacks: {{slugCamelCase}}Store.callbacks,\n});\n";
|
|
6
6
|
export declare const INTERACTIVITY_VALIDATORS_TEMPLATE = "import typia from 'typia';\nimport currentManifest from \"./manifest-defaults-document\";\nimport { {{pascalCase}}Attributes, {{pascalCase}}ValidationResult } from \"./types\";\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 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\n/**\n * Runtime type guard for checking if an object is {{pascalCase}}Attributes.\n */\nexport const is{{pascalCase}}Attributes = (obj: unknown): obj is {{pascalCase}}Attributes => {\n return validators.is(obj);\n};\n\nexport const createAttributeUpdater = scaffoldValidators.createAttributeUpdater;\n";
|
|
@@ -428,7 +428,9 @@ type InteractivityActionShape = object;
|
|
|
428
428
|
type InteractivityCallbackShape = object;
|
|
429
429
|
type InteractivityContextShape = object;
|
|
430
430
|
type InteractivityStateShape = object;
|
|
431
|
-
type InteractivityCallable =
|
|
431
|
+
type InteractivityCallable =
|
|
432
|
+
| ((...args: unknown[]) => unknown)
|
|
433
|
+
| ReturnType<typeof import('@wordpress/interactivity').withSyncEvent>;
|
|
432
434
|
type InteractivityKey<T extends object> = Extract<keyof T, string>;
|
|
433
435
|
type InteractivityMethodKey<T extends object> = {
|
|
434
436
|
[Key in InteractivityKey<T>]: T[Key] extends InteractivityCallable ? Key : never;
|
|
@@ -531,7 +533,7 @@ export function defineInteractivityStore<
|
|
|
531
533
|
};
|
|
532
534
|
}
|
|
533
535
|
|
|
534
|
-
type InteractivityActionHandler =
|
|
536
|
+
type InteractivityActionHandler = InteractivityCallable;
|
|
535
537
|
|
|
536
538
|
export interface {{pascalCase}}StoreActions {
|
|
537
539
|
handleClick: InteractivityActionHandler;
|
|
@@ -212,7 +212,56 @@ export declare function readWorkspaceBlockJson(projectDir: string, blockSlug: st
|
|
|
212
212
|
blockJsonPath: string;
|
|
213
213
|
};
|
|
214
214
|
export declare function getMutableBlockHooks(blockJson: Record<string, unknown>, blockJsonRelativePath: string): Record<string, string>;
|
|
215
|
+
type ScaffoldFilesystemCollision = {
|
|
216
|
+
label: string;
|
|
217
|
+
relativePath: string;
|
|
218
|
+
};
|
|
219
|
+
type ScaffoldInventoryCollision<TEntry> = {
|
|
220
|
+
entries: readonly TEntry[];
|
|
221
|
+
exists: (entry: TEntry) => boolean;
|
|
222
|
+
message: string;
|
|
223
|
+
};
|
|
224
|
+
/**
|
|
225
|
+
* Ensure scaffold targets do not already exist on disk or in workspace inventory.
|
|
226
|
+
*
|
|
227
|
+
* @param options Collision checks to run before writing scaffold files.
|
|
228
|
+
* @throws {Error} When a filesystem path or inventory entry already exists.
|
|
229
|
+
*/
|
|
230
|
+
export declare function assertScaffoldDoesNotExist<TEntry>(options: {
|
|
231
|
+
projectDir: string;
|
|
232
|
+
filesystemCollisions: readonly ScaffoldFilesystemCollision[];
|
|
233
|
+
inventoryCollision?: ScaffoldInventoryCollision<TEntry>;
|
|
234
|
+
}): void;
|
|
235
|
+
/**
|
|
236
|
+
* Ensure a block variation scaffold does not already exist.
|
|
237
|
+
*
|
|
238
|
+
* @param projectDir Absolute workspace root used to resolve scaffold paths.
|
|
239
|
+
* @param blockSlug Existing workspace block slug that owns the variation.
|
|
240
|
+
* @param variationSlug Normalized variation slug that would be created.
|
|
241
|
+
* @param inventory Current workspace inventory used for duplicate detection.
|
|
242
|
+
* @throws {Error} When the variation file or inventory entry already exists.
|
|
243
|
+
*/
|
|
215
244
|
export declare function assertVariationDoesNotExist(projectDir: string, blockSlug: string, variationSlug: string, inventory: WorkspaceInventory): void;
|
|
245
|
+
/**
|
|
246
|
+
* Ensure a block style scaffold does not already exist.
|
|
247
|
+
*
|
|
248
|
+
* @param projectDir Absolute workspace root used to resolve scaffold paths.
|
|
249
|
+
* @param blockSlug Existing workspace block slug that owns the style.
|
|
250
|
+
* @param styleSlug Normalized style slug that would be created.
|
|
251
|
+
* @param inventory Current workspace inventory used for duplicate detection.
|
|
252
|
+
* @throws {Error} When the style file or inventory entry already exists.
|
|
253
|
+
*/
|
|
254
|
+
export declare function assertBlockStyleDoesNotExist(projectDir: string, blockSlug: string, styleSlug: string, inventory: WorkspaceInventory): void;
|
|
255
|
+
/**
|
|
256
|
+
* Ensure a block transform scaffold does not already exist.
|
|
257
|
+
*
|
|
258
|
+
* @param projectDir Absolute workspace root used to resolve scaffold paths.
|
|
259
|
+
* @param blockSlug Existing workspace block slug that owns the transform.
|
|
260
|
+
* @param transformSlug Normalized transform slug that would be created.
|
|
261
|
+
* @param inventory Current workspace inventory used for duplicate detection.
|
|
262
|
+
* @throws {Error} When the transform file or inventory entry already exists.
|
|
263
|
+
*/
|
|
264
|
+
export declare function assertBlockTransformDoesNotExist(projectDir: string, blockSlug: string, transformSlug: string, inventory: WorkspaceInventory): void;
|
|
216
265
|
export declare function assertPatternDoesNotExist(projectDir: string, patternSlug: string, inventory: WorkspaceInventory): void;
|
|
217
266
|
export declare function assertBindingSourceDoesNotExist(projectDir: string, bindingSourceSlug: string, inventory: WorkspaceInventory): void;
|
|
218
267
|
export declare function assertRestResourceDoesNotExist(projectDir: string, restResourceSlug: string, inventory: WorkspaceInventory): void;
|
|
@@ -234,45 +234,150 @@ export function getMutableBlockHooks(blockJson, blockJsonRelativePath) {
|
|
|
234
234
|
}
|
|
235
235
|
return blockHooks;
|
|
236
236
|
}
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
237
|
+
/**
|
|
238
|
+
* Ensure scaffold targets do not already exist on disk or in workspace inventory.
|
|
239
|
+
*
|
|
240
|
+
* @param options Collision checks to run before writing scaffold files.
|
|
241
|
+
* @throws {Error} When a filesystem path or inventory entry already exists.
|
|
242
|
+
*/
|
|
243
|
+
export function assertScaffoldDoesNotExist(options) {
|
|
244
|
+
for (const collision of options.filesystemCollisions) {
|
|
245
|
+
const targetPath = path.join(options.projectDir, collision.relativePath);
|
|
246
|
+
if (fs.existsSync(targetPath)) {
|
|
247
|
+
throw new Error(`${collision.label} already exists at ${path.relative(options.projectDir, targetPath)}. Choose a different name.`);
|
|
248
|
+
}
|
|
241
249
|
}
|
|
242
|
-
if (
|
|
243
|
-
|
|
250
|
+
if (options.inventoryCollision &&
|
|
251
|
+
options.inventoryCollision.entries.some(options.inventoryCollision.exists)) {
|
|
252
|
+
throw new Error(options.inventoryCollision.message);
|
|
244
253
|
}
|
|
245
254
|
}
|
|
255
|
+
/**
|
|
256
|
+
* Ensure a block variation scaffold does not already exist.
|
|
257
|
+
*
|
|
258
|
+
* @param projectDir Absolute workspace root used to resolve scaffold paths.
|
|
259
|
+
* @param blockSlug Existing workspace block slug that owns the variation.
|
|
260
|
+
* @param variationSlug Normalized variation slug that would be created.
|
|
261
|
+
* @param inventory Current workspace inventory used for duplicate detection.
|
|
262
|
+
* @throws {Error} When the variation file or inventory entry already exists.
|
|
263
|
+
*/
|
|
264
|
+
export function assertVariationDoesNotExist(projectDir, blockSlug, variationSlug, inventory) {
|
|
265
|
+
assertScaffoldDoesNotExist({
|
|
266
|
+
filesystemCollisions: [
|
|
267
|
+
{
|
|
268
|
+
label: "A variation",
|
|
269
|
+
relativePath: path.join("src", "blocks", blockSlug, "variations", `${variationSlug}.ts`),
|
|
270
|
+
},
|
|
271
|
+
],
|
|
272
|
+
inventoryCollision: {
|
|
273
|
+
entries: inventory.variations,
|
|
274
|
+
exists: (entry) => entry.block === blockSlug && entry.slug === variationSlug,
|
|
275
|
+
message: `A variation inventory entry already exists for ${blockSlug}/${variationSlug}. Choose a different name.`,
|
|
276
|
+
},
|
|
277
|
+
projectDir,
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Ensure a block style scaffold does not already exist.
|
|
282
|
+
*
|
|
283
|
+
* @param projectDir Absolute workspace root used to resolve scaffold paths.
|
|
284
|
+
* @param blockSlug Existing workspace block slug that owns the style.
|
|
285
|
+
* @param styleSlug Normalized style slug that would be created.
|
|
286
|
+
* @param inventory Current workspace inventory used for duplicate detection.
|
|
287
|
+
* @throws {Error} When the style file or inventory entry already exists.
|
|
288
|
+
*/
|
|
289
|
+
export function assertBlockStyleDoesNotExist(projectDir, blockSlug, styleSlug, inventory) {
|
|
290
|
+
assertScaffoldDoesNotExist({
|
|
291
|
+
filesystemCollisions: [
|
|
292
|
+
{
|
|
293
|
+
label: "A block style",
|
|
294
|
+
relativePath: path.join("src", "blocks", blockSlug, "styles", `${styleSlug}.ts`),
|
|
295
|
+
},
|
|
296
|
+
],
|
|
297
|
+
inventoryCollision: {
|
|
298
|
+
entries: inventory.blockStyles,
|
|
299
|
+
exists: (entry) => entry.block === blockSlug && entry.slug === styleSlug,
|
|
300
|
+
message: `A block style inventory entry already exists for ${blockSlug}/${styleSlug}. Choose a different name.`,
|
|
301
|
+
},
|
|
302
|
+
projectDir,
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* Ensure a block transform scaffold does not already exist.
|
|
307
|
+
*
|
|
308
|
+
* @param projectDir Absolute workspace root used to resolve scaffold paths.
|
|
309
|
+
* @param blockSlug Existing workspace block slug that owns the transform.
|
|
310
|
+
* @param transformSlug Normalized transform slug that would be created.
|
|
311
|
+
* @param inventory Current workspace inventory used for duplicate detection.
|
|
312
|
+
* @throws {Error} When the transform file or inventory entry already exists.
|
|
313
|
+
*/
|
|
314
|
+
export function assertBlockTransformDoesNotExist(projectDir, blockSlug, transformSlug, inventory) {
|
|
315
|
+
assertScaffoldDoesNotExist({
|
|
316
|
+
filesystemCollisions: [
|
|
317
|
+
{
|
|
318
|
+
label: "A block transform",
|
|
319
|
+
relativePath: path.join("src", "blocks", blockSlug, "transforms", `${transformSlug}.ts`),
|
|
320
|
+
},
|
|
321
|
+
],
|
|
322
|
+
inventoryCollision: {
|
|
323
|
+
entries: inventory.blockTransforms,
|
|
324
|
+
exists: (entry) => entry.block === blockSlug && entry.slug === transformSlug,
|
|
325
|
+
message: `A block transform inventory entry already exists for ${blockSlug}/${transformSlug}. Choose a different name.`,
|
|
326
|
+
},
|
|
327
|
+
projectDir,
|
|
328
|
+
});
|
|
329
|
+
}
|
|
246
330
|
export function assertPatternDoesNotExist(projectDir, patternSlug, inventory) {
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
331
|
+
assertScaffoldDoesNotExist({
|
|
332
|
+
filesystemCollisions: [
|
|
333
|
+
{
|
|
334
|
+
label: "A pattern",
|
|
335
|
+
relativePath: path.join("src", "patterns", `${patternSlug}.php`),
|
|
336
|
+
},
|
|
337
|
+
],
|
|
338
|
+
inventoryCollision: {
|
|
339
|
+
entries: inventory.patterns,
|
|
340
|
+
exists: (entry) => entry.slug === patternSlug,
|
|
341
|
+
message: `A pattern inventory entry already exists for ${patternSlug}. Choose a different name.`,
|
|
342
|
+
},
|
|
343
|
+
projectDir,
|
|
344
|
+
});
|
|
254
345
|
}
|
|
255
346
|
export function assertBindingSourceDoesNotExist(projectDir, bindingSourceSlug, inventory) {
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
347
|
+
assertScaffoldDoesNotExist({
|
|
348
|
+
filesystemCollisions: [
|
|
349
|
+
{
|
|
350
|
+
label: "A binding source",
|
|
351
|
+
relativePath: path.join("src", "bindings", bindingSourceSlug),
|
|
352
|
+
},
|
|
353
|
+
],
|
|
354
|
+
inventoryCollision: {
|
|
355
|
+
entries: inventory.bindingSources,
|
|
356
|
+
exists: (entry) => entry.slug === bindingSourceSlug,
|
|
357
|
+
message: `A binding source inventory entry already exists for ${bindingSourceSlug}. Choose a different name.`,
|
|
358
|
+
},
|
|
359
|
+
projectDir,
|
|
360
|
+
});
|
|
263
361
|
}
|
|
264
362
|
export function assertRestResourceDoesNotExist(projectDir, restResourceSlug, inventory) {
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
363
|
+
assertScaffoldDoesNotExist({
|
|
364
|
+
filesystemCollisions: [
|
|
365
|
+
{
|
|
366
|
+
label: "A REST resource",
|
|
367
|
+
relativePath: path.join("src", "rest", restResourceSlug),
|
|
368
|
+
},
|
|
369
|
+
{
|
|
370
|
+
label: "A REST resource bootstrap",
|
|
371
|
+
relativePath: path.join("inc", "rest", `${restResourceSlug}.php`),
|
|
372
|
+
},
|
|
373
|
+
],
|
|
374
|
+
inventoryCollision: {
|
|
375
|
+
entries: inventory.restResources,
|
|
376
|
+
exists: (entry) => entry.slug === restResourceSlug,
|
|
377
|
+
message: `A REST resource inventory entry already exists for ${restResourceSlug}. Choose a different name.`,
|
|
378
|
+
},
|
|
379
|
+
projectDir,
|
|
380
|
+
});
|
|
276
381
|
}
|
|
277
382
|
/**
|
|
278
383
|
* Ensure a DataViews admin screen scaffold does not already exist on disk or in
|
|
@@ -284,17 +389,24 @@ export function assertRestResourceDoesNotExist(projectDir, restResourceSlug, inv
|
|
|
284
389
|
* @throws {Error} When the directory, PHP bootstrap, or inventory entry already exists.
|
|
285
390
|
*/
|
|
286
391
|
export function assertAdminViewDoesNotExist(projectDir, adminViewSlug, inventory) {
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
392
|
+
assertScaffoldDoesNotExist({
|
|
393
|
+
filesystemCollisions: [
|
|
394
|
+
{
|
|
395
|
+
label: "An admin view",
|
|
396
|
+
relativePath: path.join("src", "admin-views", adminViewSlug),
|
|
397
|
+
},
|
|
398
|
+
{
|
|
399
|
+
label: "An admin view bootstrap",
|
|
400
|
+
relativePath: path.join("inc", "admin-views", `${adminViewSlug}.php`),
|
|
401
|
+
},
|
|
402
|
+
],
|
|
403
|
+
inventoryCollision: {
|
|
404
|
+
entries: inventory.adminViews,
|
|
405
|
+
exists: (entry) => entry.slug === adminViewSlug,
|
|
406
|
+
message: `An admin view inventory entry already exists for ${adminViewSlug}. Choose a different name.`,
|
|
407
|
+
},
|
|
408
|
+
projectDir,
|
|
409
|
+
});
|
|
298
410
|
}
|
|
299
411
|
/**
|
|
300
412
|
* Ensure a workflow ability scaffold does not already exist on disk or in the
|
|
@@ -309,30 +421,44 @@ export function assertAdminViewDoesNotExist(projectDir, adminViewSlug, inventory
|
|
|
309
421
|
* @throws {Error} When the ability directory, PHP bootstrap, or inventory entry already exists.
|
|
310
422
|
*/
|
|
311
423
|
export function assertAbilityDoesNotExist(projectDir, abilitySlug, inventory) {
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
424
|
+
assertScaffoldDoesNotExist({
|
|
425
|
+
filesystemCollisions: [
|
|
426
|
+
{
|
|
427
|
+
label: "An ability scaffold",
|
|
428
|
+
relativePath: path.join("src", "abilities", abilitySlug),
|
|
429
|
+
},
|
|
430
|
+
{
|
|
431
|
+
label: "An ability bootstrap",
|
|
432
|
+
relativePath: path.join("inc", "abilities", `${abilitySlug}.php`),
|
|
433
|
+
},
|
|
434
|
+
],
|
|
435
|
+
inventoryCollision: {
|
|
436
|
+
entries: inventory.abilities,
|
|
437
|
+
exists: (entry) => entry.slug === abilitySlug,
|
|
438
|
+
message: `An ability inventory entry already exists for ${abilitySlug}. Choose a different name.`,
|
|
439
|
+
},
|
|
440
|
+
projectDir,
|
|
441
|
+
});
|
|
323
442
|
}
|
|
324
443
|
export function assertAiFeatureDoesNotExist(projectDir, aiFeatureSlug, inventory) {
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
444
|
+
assertScaffoldDoesNotExist({
|
|
445
|
+
filesystemCollisions: [
|
|
446
|
+
{
|
|
447
|
+
label: "An AI feature",
|
|
448
|
+
relativePath: path.join("src", "ai-features", aiFeatureSlug),
|
|
449
|
+
},
|
|
450
|
+
{
|
|
451
|
+
label: "An AI feature bootstrap",
|
|
452
|
+
relativePath: path.join("inc", "ai-features", `${aiFeatureSlug}.php`),
|
|
453
|
+
},
|
|
454
|
+
],
|
|
455
|
+
inventoryCollision: {
|
|
456
|
+
entries: inventory.aiFeatures,
|
|
457
|
+
exists: (entry) => entry.slug === aiFeatureSlug,
|
|
458
|
+
message: `An AI feature inventory entry already exists for ${aiFeatureSlug}. Choose a different name.`,
|
|
459
|
+
},
|
|
460
|
+
projectDir,
|
|
461
|
+
});
|
|
336
462
|
}
|
|
337
463
|
/**
|
|
338
464
|
* Ensure an editor plugin scaffold does not already exist on disk or in the
|
|
@@ -344,13 +470,20 @@ export function assertAiFeatureDoesNotExist(projectDir, aiFeatureSlug, inventory
|
|
|
344
470
|
* @throws {Error} When the directory or inventory entry already exists.
|
|
345
471
|
*/
|
|
346
472
|
export function assertEditorPluginDoesNotExist(projectDir, editorPluginSlug, inventory) {
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
473
|
+
assertScaffoldDoesNotExist({
|
|
474
|
+
filesystemCollisions: [
|
|
475
|
+
{
|
|
476
|
+
label: "An editor plugin",
|
|
477
|
+
relativePath: path.join("src", "editor-plugins", editorPluginSlug),
|
|
478
|
+
},
|
|
479
|
+
],
|
|
480
|
+
inventoryCollision: {
|
|
481
|
+
entries: inventory.editorPlugins,
|
|
482
|
+
exists: (entry) => entry.slug === editorPluginSlug,
|
|
483
|
+
message: `An editor plugin inventory entry already exists for ${editorPluginSlug}. Choose a different name.`,
|
|
484
|
+
},
|
|
485
|
+
projectDir,
|
|
486
|
+
});
|
|
354
487
|
}
|
|
355
488
|
/**
|
|
356
489
|
* Returns help text for the canonical `wp-typia add` subcommands.
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type ScaffoldAbilityWorkspaceOptions } from "./cli-add-workspace-ability-types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Write generated workflow ability sources and patch shared workspace anchors.
|
|
4
|
+
*/
|
|
5
|
+
export declare function scaffoldAbilityWorkspace({ abilitySlug, compatibilityPolicy, workspace, }: ScaffoldAbilityWorkspaceOptions): Promise<void>;
|