@developer_tribe/react-builder 1.2.34 → 1.2.36
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/RenderPage.d.ts +0 -12
- package/dist/attributes-editor/Field.d.ts +2 -1
- package/dist/attributes-editor/SizeField.d.ts +2 -1
- package/dist/attributes-editor/attributesEditorUtils.d.ts +2 -1
- package/dist/build-components/BIcon/BIcon.d.ts +0 -3
- package/dist/build-components/BIcon/BIconProps.generated.d.ts +1 -0
- package/dist/build-components/Button/Button.d.ts +0 -3
- package/dist/build-components/CarouselItem/CarouselItem.d.ts +0 -3
- package/dist/build-components/CountDown/CountDownProps.generated.d.ts +1 -1
- package/dist/build-components/OnboardButton/OnboardButton.d.ts +0 -3
- package/dist/build-components/OnboardDot/OnboardDot.d.ts +0 -3
- package/dist/build-components/OnboardFooter/OnboardFooterProps.generated.d.ts +1 -0
- package/dist/build-components/OnboardItem/OnboardItemProps.generated.d.ts +0 -3
- package/dist/build-components/OnboardSubtitle/OnboardSubtitleProps.generated.d.ts +1 -0
- package/dist/build-components/OnboardTitle/OnboardTitleProps.generated.d.ts +1 -0
- package/dist/build-components/PaywallCloseButton/PaywallCloseButton.d.ts +0 -3
- package/dist/build-components/PaywallCloseButton/PaywallCloseButtonProps.generated.d.ts +1 -0
- package/dist/build-components/PriceTag/PriceTagProps.generated.d.ts +1 -0
- package/dist/build-components/Pricing/PricingProps.generated.d.ts +1 -0
- package/dist/build-components/Promo/PromoProps.generated.d.ts +1 -0
- package/dist/build-components/Text/TextProps.generated.d.ts +1 -0
- package/dist/build-components/patterns.generated.d.ts +9798 -10468
- package/dist/components/Breadcrumb.d.ts +1 -1
- package/dist/index.cjs.js +1 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.web.cjs.js +3 -3
- package/dist/index.web.cjs.js.map +1 -1
- package/dist/index.web.esm.js +3 -3
- package/dist/index.web.esm.js.map +1 -1
- package/dist/migrations/migratePipe.d.ts +2 -1
- package/dist/migrations/semver.d.ts +0 -7
- package/dist/pages/DebugJsonPage.d.ts +2 -1
- package/dist/pages/ProjectDebug.d.ts +2 -1
- package/dist/pages/ProjectMigrationPage.d.ts +2 -1
- package/dist/pages/ProjectPage.d.ts +2 -1
- package/dist/pages/ProjectValidationPage.d.ts +2 -1
- package/dist/pages/tabs/SideTool.d.ts +0 -7
- package/dist/utils/parseColor.d.ts +1 -1
- package/package.json +1 -1
- package/scripts/prebuild/assets/prompt_scheme.md +5 -11
- package/scripts/prebuild/generate-prompt-schemes.js +11 -8
- package/scripts/prebuild/utils/validateAllComponentsOrThrow.js +50 -0
- package/scripts/prebuild/utils/validatePatternJson.js +73 -0
- package/src/RenderPage.tsx +1 -7
- package/src/assets/meta.json +1 -1
- package/src/assets/prompt-scheme-onboard.generated.ts +1 -1
- package/src/assets/prompt-scheme-paywall.generated.ts +1 -1
- package/src/attributes-editor/Field.tsx +1 -1
- package/src/attributes-editor/SizeField.tsx +1 -1
- package/src/attributes-editor/attributesEditorUtils.ts +1 -1
- package/src/attributes-editor/useAttributesEditorModel.ts +16 -15
- package/src/build-components/BIcon/BIcon.tsx +0 -2
- package/src/build-components/BIcon/BIconProps.generated.ts +1 -0
- package/src/build-components/BackgroundImage/pattern.json +8 -9
- package/src/build-components/Button/Button.tsx +0 -2
- package/src/build-components/CarouselDots/CarouselDots.tsx +1 -1
- package/src/build-components/CarouselDots/pattern.json +1 -1
- package/src/build-components/CarouselItem/CarouselItem.tsx +0 -2
- package/src/build-components/CountDown/CountDownProps.generated.ts +1 -1
- package/src/build-components/OnboardButton/OnboardButton.tsx +1 -4
- package/src/build-components/OnboardButtons/pattern.json +2 -4
- package/src/build-components/OnboardDot/OnboardDot.tsx +10 -10
- package/src/build-components/OnboardDot/pattern.json +2 -3
- package/src/build-components/OnboardFooter/OnboardFooter.tsx +8 -13
- package/src/build-components/OnboardFooter/OnboardFooterProps.generated.ts +1 -0
- package/src/build-components/OnboardItem/OnboardItemProps.generated.ts +0 -3
- package/src/build-components/OnboardItem/pattern.json +27 -23
- package/src/build-components/OnboardProvider/pattern.json +29 -27
- package/src/build-components/OnboardSubtitle/OnboardSubtitleProps.generated.ts +1 -0
- package/src/build-components/OnboardTitle/OnboardTitleProps.generated.ts +1 -0
- package/src/build-components/PaywallCloseButton/PaywallCloseButton.tsx +0 -2
- package/src/build-components/PaywallCloseButton/PaywallCloseButtonProps.generated.ts +1 -0
- package/src/build-components/PriceTag/PriceTagProps.generated.ts +1 -0
- package/src/build-components/Pricing/PricingProps.generated.ts +1 -0
- package/src/build-components/Promo/PromoProps.generated.ts +1 -0
- package/src/build-components/RadioButton/pattern.json +2 -4
- package/src/build-components/Separator/pattern.json +24 -24
- package/src/build-components/Text/TextProps.generated.ts +1 -0
- package/src/build-components/Text/pattern.json +2 -1
- package/src/build-components/View/pattern.json +265 -265
- package/src/build-components/patterns.generated.ts +10019 -10689
- package/src/components/Breadcrumb.tsx +1 -1
- package/src/migrations/migratePipe.ts +1 -1
- package/src/migrations/semver.ts +3 -3
- package/src/modals/MockableFeatureModal.tsx +3 -1
- package/src/modals/PromptManagerModal.tsx +1 -7
- package/src/pages/DebugJsonPage.tsx +1 -1
- package/src/pages/ProjectDebug.tsx +1 -1
- package/src/pages/ProjectMigrationPage.tsx +1 -1
- package/src/pages/ProjectPage.tsx +1 -1
- package/src/pages/ProjectValidationPage.tsx +1 -1
- package/src/pages/tabs/SideTool.tsx +1 -1
- package/src/utils/nodeXml.ts +2 -4
- package/src/utils/parseColor.ts +5 -6
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Project } from '../types/Project';
|
|
2
2
|
import type { Migration } from './types';
|
|
3
3
|
export declare const CURRENT_PROJECT_VERSION: string;
|
|
4
|
-
|
|
4
|
+
type MigrationPipe = {
|
|
5
5
|
projectVersion: string;
|
|
6
6
|
requiredVersion: string;
|
|
7
7
|
required: boolean;
|
|
@@ -12,3 +12,4 @@ export declare function runProjectMigrations(project: Project): {
|
|
|
12
12
|
project: Project;
|
|
13
13
|
applied: Migration[];
|
|
14
14
|
};
|
|
15
|
+
export {};
|
|
@@ -1,8 +1 @@
|
|
|
1
|
-
export type Semver = {
|
|
2
|
-
major: number;
|
|
3
|
-
minor: number;
|
|
4
|
-
patch: number;
|
|
5
|
-
};
|
|
6
|
-
export declare function parseSemver(input?: string | null): Semver;
|
|
7
|
-
export declare function compareSemver(a: string, b: string): number;
|
|
8
1
|
export declare function isSemverLess(a: string, b: string): boolean;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { Node } from '../types/Node';
|
|
3
|
-
|
|
3
|
+
type DebugJsonPageProps = {
|
|
4
4
|
data: Node | null | undefined;
|
|
5
5
|
setData: React.Dispatch<React.SetStateAction<Node>>;
|
|
6
6
|
project?: unknown;
|
|
@@ -12,3 +12,4 @@ export type DebugJsonPageProps = {
|
|
|
12
12
|
logLabel?: string;
|
|
13
13
|
};
|
|
14
14
|
export declare function DebugJsonPage({ data, setData, project, onClose, title, description, previewMode, setPreviewMode, logLabel, }: DebugJsonPageProps): import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type ReactNode } from 'react';
|
|
2
2
|
import type { Product } from '../paywall/types/paywall-types';
|
|
3
3
|
import type { PaywallBenefits } from '../paywall/types/benefits';
|
|
4
|
-
|
|
4
|
+
type ProjectDebugProps = {
|
|
5
5
|
name: string;
|
|
6
6
|
rawData: unknown;
|
|
7
7
|
validationError: string;
|
|
@@ -20,3 +20,4 @@ export type ProjectDebugProps = {
|
|
|
20
20
|
};
|
|
21
21
|
};
|
|
22
22
|
export declare function ProjectDebug({ name, rawData, validationError, validationErrorStack, products, benefits, canvasBg, belowName, jsonEditor, }: ProjectDebugProps): import("react/jsx-runtime").JSX.Element;
|
|
23
|
+
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
2
|
import type { Product } from '../paywall/types/paywall-types';
|
|
3
3
|
import type { PaywallBenefits } from '../paywall/types/benefits';
|
|
4
|
-
|
|
4
|
+
type ProjectMigrationPageProps = {
|
|
5
5
|
name: string;
|
|
6
6
|
rawData: unknown;
|
|
7
7
|
projectVersion: string;
|
|
@@ -23,3 +23,4 @@ export type ProjectMigrationPageProps = {
|
|
|
23
23
|
onFixVersionMeta?: () => void;
|
|
24
24
|
};
|
|
25
25
|
export declare function ProjectMigrationPage({ name, rawData, projectVersion, requiredVersion, showFixVersionMeta, pendingMigrations, products, benefits, canvasBg, belowName, migrating, onContinueWithoutValidation, onMigrateNow, onFixVersionMeta, }: ProjectMigrationPageProps): import("react/jsx-runtime").JSX.Element;
|
|
26
|
+
export {};
|
|
@@ -2,7 +2,7 @@ import type { Project, ProjectColors, ProjectMeta } from '../types/Project';
|
|
|
2
2
|
import { type Localication } from '../types/PreviewConfig';
|
|
3
3
|
import type { LogLevel } from '../types/Project';
|
|
4
4
|
import type { Fonts } from '../types/Fonts';
|
|
5
|
-
|
|
5
|
+
type ProjectPageProps = {
|
|
6
6
|
project: Project;
|
|
7
7
|
onSaveProject: (project: ProjectMeta) => void;
|
|
8
8
|
localization?: Localication;
|
|
@@ -21,3 +21,4 @@ export type ProjectPageProps = {
|
|
|
21
21
|
appFont?: string | undefined;
|
|
22
22
|
};
|
|
23
23
|
export declare function ProjectPage({ project, localization, onSaveProject, logLevel, projectColors, onSaveProjectColors, name, typography, appFont, }: ProjectPageProps): import("react/jsx-runtime").JSX.Element;
|
|
24
|
+
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type ReactNode } from 'react';
|
|
2
2
|
import type { Product } from '../paywall/types/paywall-types';
|
|
3
3
|
import type { PaywallBenefits } from '../paywall/types/benefits';
|
|
4
|
-
|
|
4
|
+
type ProjectValidationPageProps = {
|
|
5
5
|
name: string;
|
|
6
6
|
rawData: unknown;
|
|
7
7
|
validationError: string;
|
|
@@ -14,3 +14,4 @@ export type ProjectValidationPageProps = {
|
|
|
14
14
|
onSaveEditedRawData?: (nextRawData: unknown) => void;
|
|
15
15
|
};
|
|
16
16
|
export declare function ProjectValidationPage({ name, rawData, validationError, validationErrorStack, products, benefits, canvasBg, belowName, onContinueWithoutValidation, onSaveEditedRawData, }: ProjectValidationPageProps): import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
export {};
|
|
@@ -1,8 +1 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import type { Node } from '../../types/Node';
|
|
3
|
-
type SideToolProps = {
|
|
4
|
-
data: Node;
|
|
5
|
-
setData: React.Dispatch<React.SetStateAction<Node>>;
|
|
6
|
-
};
|
|
7
|
-
export declare function SideTool({ data, setData }: SideToolProps): import("react/jsx-runtime").JSX.Element;
|
|
8
1
|
export {};
|
|
@@ -3,4 +3,4 @@ export type ParseColorOptions = {
|
|
|
3
3
|
projectColors?: ProjectColors;
|
|
4
4
|
theme?: string;
|
|
5
5
|
};
|
|
6
|
-
export declare function parseColor(value?: string, options?: ParseColorOptions): string | undefined;
|
|
6
|
+
export declare function parseColor(value?: string, options?: ParseColorOptions): string | null | undefined;
|
package/package.json
CHANGED
|
@@ -2,12 +2,9 @@ You are a React Native UI builder assistant. Your goal is to generate a valid **
|
|
|
2
2
|
|
|
3
3
|
## Available Components & Their Props
|
|
4
4
|
|
|
5
|
-
Each component is listed as `ComponentName: {attr: TypeScriptType, styles: {prop: TypeScriptType}}`.
|
|
6
|
-
Use ONLY these component names and attribute names. Do NOT invent new components or attributes.
|
|
5
|
+
Each component is listed as `ComponentName: {attr: TypeScriptType, styles: {prop: TypeScriptType}}`. Use ONLY these component names and attribute names. Do NOT invent new components or attributes.
|
|
7
6
|
|
|
8
|
-
Union enum values must match exactly (e.g. `"expanding_dot"` not `expandingDot`).
|
|
9
|
-
Color values: prefer `THEME_COLORS.KEY` or `STATIC_COLORS.KEY` for theme-aware colors. Literal values like `"red"` or `"#000fff"` are also valid when a specific color is intended.
|
|
10
|
-
Localization string values should use a localization key from the **Available Localization Keys** section. Do NOT invent new keys.
|
|
7
|
+
Union enum values must match exactly (e.g. `"expanding_dot"` not `expandingDot`). Color values: prefer `THEME_COLORS.KEY` or `STATIC_COLORS.KEY` for theme-aware colors. Literal values like `"red"` or `"#000fff"` are also valid when a specific color is intended. Localization string values should use a localization key from the **Available Localization Keys** section. Do NOT invent new keys.
|
|
11
8
|
|
|
12
9
|
```
|
|
13
10
|
{patterns}
|
|
@@ -33,18 +30,15 @@ Use one of these values for `iconType` attributes:
|
|
|
33
30
|
|
|
34
31
|
## Embla Carousel Constraints
|
|
35
32
|
|
|
36
|
-
> **IMPORTANT – Web uses Embla carousel under the hood.**
|
|
37
|
-
> For `OnboardProvider` and `OnboardItem`, do **NOT** set any of the following outer layout styles via `styles`, because Embla manages them internally through its own CSS classes (`embla`, `embla__viewport`, `embla__slide`):
|
|
33
|
+
> **IMPORTANT – Web uses Embla carousel under the hood.** For `OnboardProvider` and `OnboardItem`, do **NOT** set any of the following outer layout styles via `styles`, because Embla manages them internally through its own CSS classes (`embla`, `embla__viewport`, `embla__slide`):
|
|
38
34
|
>
|
|
39
35
|
> `flex`, `flexGrow`, `flexShrink`, `margin`, `marginTop`, `marginBottom`, `marginLeft`, `marginRight`, `marginHorizontal`, `marginVertical`, `height`, `minHeight`, `maxHeight`, `width`, `minWidth`, `maxWidth`, `position`, `top`, `bottom`, `left`, `right`, `zIndex`, `display`
|
|
40
36
|
>
|
|
41
|
-
> Only **visual** styles are safe to set on `OnboardProvider` and `OnboardItem`:
|
|
42
|
-
> `padding`, `paddingTop`, `paddingBottom`, `paddingLeft`, `paddingRight`, `paddingHorizontal`, `paddingVertical`, `backgroundColor`, `borderRadius`, `gap`, `alignItems`, `justifyContent`, `flexDirection`, `flexWrap`
|
|
37
|
+
> Only **visual** styles are safe to set on `OnboardProvider` and `OnboardItem`: `padding`, `paddingTop`, `paddingBottom`, `paddingLeft`, `paddingRight`, `paddingHorizontal`, `paddingVertical`, `backgroundColor`, `borderRadius`, `gap`, `alignItems`, `justifyContent`, `flexDirection`, `flexWrap`
|
|
43
38
|
|
|
44
39
|
## Available Localization Keys
|
|
45
40
|
|
|
46
|
-
Use ONLY the keys listed below for localization attributes (`labelKey`, `textLocalizationKey`, etc.).
|
|
47
|
-
Do NOT invent new keys or use keys not in this list.
|
|
41
|
+
Use ONLY the keys listed below for localization attributes (`labelKey`, `textLocalizationKey`, etc.). Do NOT invent new keys or use keys not in this list.
|
|
48
42
|
|
|
49
43
|
```
|
|
50
44
|
{localization_keys}
|
|
@@ -93,7 +93,7 @@ function nodeToXmlInner(node, indent) {
|
|
|
93
93
|
if (typeof node === 'string') return `${pad}${node}`;
|
|
94
94
|
|
|
95
95
|
if (Array.isArray(node)) {
|
|
96
|
-
return node.map(
|
|
96
|
+
return node.map(child => nodeToXmlInner(child, indent)).join('\n');
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
if (typeof node !== 'object') return '';
|
|
@@ -157,13 +157,12 @@ function parsePropsFile(filePath, componentName) {
|
|
|
157
157
|
// ── Collect enum/union types ──────────────────────────────────────
|
|
158
158
|
// e.g. export type DotTypeOptionType = 'a' | 'b';
|
|
159
159
|
const enumMap = {};
|
|
160
|
-
const enumRe =
|
|
161
|
-
/export\s+type\s+(\w+)\s*=\s*((?:'[^']*'|\||\s)+);/g;
|
|
160
|
+
const enumRe = /export\s+type\s+(\w+)\s*=\s*((?:'[^']*'|\||\s)+);/g;
|
|
162
161
|
let m;
|
|
163
162
|
while ((m = enumRe.exec(src)) !== null) {
|
|
164
163
|
const typeName = m[1];
|
|
165
164
|
// Collect all quoted values
|
|
166
|
-
const values = [...m[2].matchAll(/'([^']*)'/g)].map(
|
|
165
|
+
const values = [...m[2].matchAll(/'([^']*)'/g)].map(x => `"${x[1]}"`);
|
|
167
166
|
if (values.length > 0) enumMap[typeName] = values.join('|');
|
|
168
167
|
}
|
|
169
168
|
|
|
@@ -213,7 +212,9 @@ function parsePropsFile(filePath, componentName) {
|
|
|
213
212
|
// ── Also check for child type ───────────────────────────────────
|
|
214
213
|
const childRe = /^\s+child\s*:\s*(.+?);/m;
|
|
215
214
|
const childMatch = childRe.exec(piMatch[1]);
|
|
216
|
-
const childType = childMatch
|
|
215
|
+
const childType = childMatch
|
|
216
|
+
? resolveType(childMatch[1].trim(), enumMap)
|
|
217
|
+
: null;
|
|
217
218
|
|
|
218
219
|
// ── Build compact string ────────────────────────────────────────
|
|
219
220
|
const parts = [];
|
|
@@ -319,7 +320,8 @@ function collectLocalizationAndColors() {
|
|
|
319
320
|
const previewConfigSrc = fs.readFileSync(previewConfigPath, 'utf8');
|
|
320
321
|
|
|
321
322
|
// Extract all string literal keys from the LocalizationKey type union
|
|
322
|
-
const locKeyTypeRe =
|
|
323
|
+
const locKeyTypeRe =
|
|
324
|
+
/export\s+type\s+LocalizationKey\s*=[\s\S]*?(?=export\s|$)/;
|
|
323
325
|
const locKeyTypeMatch = locKeyTypeRe.exec(previewConfigSrc);
|
|
324
326
|
const localizationKeys = [];
|
|
325
327
|
if (locKeyTypeMatch) {
|
|
@@ -387,8 +389,9 @@ function collectLocalizationAndColors() {
|
|
|
387
389
|
}
|
|
388
390
|
}
|
|
389
391
|
|
|
390
|
-
const defaultColors =
|
|
391
|
-
|
|
392
|
+
const defaultColors = [...staticLines, ...lightLines, ...darkLines].join(
|
|
393
|
+
'\n'
|
|
394
|
+
);
|
|
392
395
|
|
|
393
396
|
return {
|
|
394
397
|
localizationKeys: localizationKeys.join('\n'),
|
|
@@ -459,6 +459,56 @@ async function validatePatternJson(componentDir, componentName) {
|
|
|
459
459
|
};
|
|
460
460
|
}
|
|
461
461
|
|
|
462
|
+
// ── Meta alignment validation ─────────────────────────────────────────────
|
|
463
|
+
// meta must mirror the pattern.attributes structure (after extends merge):
|
|
464
|
+
// pattern.attributes.X → meta.attributes.X (NOT under meta.attributes.styles)
|
|
465
|
+
// pattern.attributes.styles.X → meta.attributes.styles.X (or meta.styles.X)
|
|
466
|
+
if (data.meta) {
|
|
467
|
+
const resolvedAttrs = data.pattern.attributes ?? {};
|
|
468
|
+
const styleKeys = new Set(
|
|
469
|
+
Object.keys(
|
|
470
|
+
isPlainObject(resolvedAttrs.styles) ? resolvedAttrs.styles : {}
|
|
471
|
+
)
|
|
472
|
+
);
|
|
473
|
+
|
|
474
|
+
// Check meta.attributes: flat keys must NOT belong to pattern.attributes.styles
|
|
475
|
+
const metaAttrFlat = data.meta?.attributes;
|
|
476
|
+
if (isPlainObject(metaAttrFlat)) {
|
|
477
|
+
for (const key of Object.keys(metaAttrFlat)) {
|
|
478
|
+
if (key === 'styles' || key === 'style') continue;
|
|
479
|
+
if (styleKeys.has(key)) {
|
|
480
|
+
return fail(
|
|
481
|
+
`[${componentName}] pattern.json -> meta.attributes.${key} should be meta.attributes.styles.${key} (key is defined under pattern.attributes.styles)`
|
|
482
|
+
);
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
// Check meta.attributes.styles: keys must be in pattern.attributes.styles
|
|
487
|
+
const metaAttrStyles = metaAttrFlat?.styles;
|
|
488
|
+
if (isPlainObject(metaAttrStyles)) {
|
|
489
|
+
for (const key of Object.keys(metaAttrStyles)) {
|
|
490
|
+
if (!styleKeys.has(key)) {
|
|
491
|
+
return fail(
|
|
492
|
+
`[${componentName}] pattern.json -> meta.attributes.styles.${key} should be meta.attributes.${key} (key is not defined under pattern.attributes.styles)`
|
|
493
|
+
);
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
// Check meta.styles (legacy shorthand): keys must be in pattern.attributes.styles
|
|
500
|
+
const metaStyles = data.meta?.styles;
|
|
501
|
+
if (isPlainObject(metaStyles)) {
|
|
502
|
+
for (const key of Object.keys(metaStyles)) {
|
|
503
|
+
if (!styleKeys.has(key)) {
|
|
504
|
+
return fail(
|
|
505
|
+
`[${componentName}] pattern.json -> meta.styles.${key} should be meta.attributes.${key} (key is not defined under pattern.attributes.styles)`
|
|
506
|
+
);
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
|
|
462
512
|
return data;
|
|
463
513
|
}
|
|
464
514
|
|
|
@@ -105,9 +105,82 @@ export async function validatePatternJson(componentDir, componentName) {
|
|
|
105
105
|
continue;
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
+
if (attrName === 'styles') {
|
|
109
|
+
if (!isPlainObject(attrType)) {
|
|
110
|
+
return fail(
|
|
111
|
+
`[${componentName}] pattern.json -> 'pattern.attributes.styles' must be an object`
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
for (const [styleKey, styleType] of Object.entries(attrType)) {
|
|
115
|
+
const res = validateAttrType(
|
|
116
|
+
styleKey,
|
|
117
|
+
styleType,
|
|
118
|
+
'pattern.attributes.styles'
|
|
119
|
+
);
|
|
120
|
+
if (res) return res;
|
|
121
|
+
}
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
124
|
+
|
|
108
125
|
const res = validateAttrType(attrName, attrType, 'pattern.attributes');
|
|
109
126
|
if (res) return res;
|
|
110
127
|
}
|
|
111
128
|
|
|
129
|
+
// ── Meta alignment validation ─────────────────────────────────────────────
|
|
130
|
+
// meta must mirror the pattern.attributes structure:
|
|
131
|
+
// pattern.attributes.X → meta under meta.attributes.X (NOT meta.attributes.styles.X)
|
|
132
|
+
// pattern.attributes.styles.X → meta under meta.attributes.styles.X (or meta.styles.X)
|
|
133
|
+
if (data.meta) {
|
|
134
|
+
const styleKeys = new Set(
|
|
135
|
+
Object.keys(
|
|
136
|
+
isPlainObject(pattern.attributes?.styles)
|
|
137
|
+
? pattern.attributes.styles
|
|
138
|
+
: {}
|
|
139
|
+
)
|
|
140
|
+
);
|
|
141
|
+
const topLevelKeys = new Set(
|
|
142
|
+
Object.keys(pattern.attributes ?? {}).filter(
|
|
143
|
+
k => k !== 'styles' && k !== 'style'
|
|
144
|
+
)
|
|
145
|
+
);
|
|
146
|
+
|
|
147
|
+
// Check meta.attributes: keys here must NOT be style keys
|
|
148
|
+
const metaAttrs = data.meta?.attributes;
|
|
149
|
+
if (isPlainObject(metaAttrs)) {
|
|
150
|
+
for (const key of Object.keys(metaAttrs)) {
|
|
151
|
+
if (key === 'styles' || key === 'style') continue; // nested object, skip
|
|
152
|
+
if (styleKeys.has(key)) {
|
|
153
|
+
return fail(
|
|
154
|
+
`[${componentName}] pattern.json -> meta.attributes.${key} should be meta.attributes.styles.${key} (it is defined under pattern.attributes.styles)`
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// Check meta.attributes.styles: keys here must be style keys
|
|
160
|
+
const metaAttrStyles = metaAttrs?.styles;
|
|
161
|
+
if (isPlainObject(metaAttrStyles)) {
|
|
162
|
+
for (const key of Object.keys(metaAttrStyles)) {
|
|
163
|
+
if (!styleKeys.has(key)) {
|
|
164
|
+
return fail(
|
|
165
|
+
`[${componentName}] pattern.json -> meta.attributes.styles.${key} should be meta.attributes.${key} (it is not defined under pattern.attributes.styles)`
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// Check meta.styles (legacy shorthand for meta.attributes.styles): keys must be style keys
|
|
173
|
+
const metaStyles = data.meta?.styles;
|
|
174
|
+
if (isPlainObject(metaStyles)) {
|
|
175
|
+
for (const key of Object.keys(metaStyles)) {
|
|
176
|
+
if (!styleKeys.has(key)) {
|
|
177
|
+
return fail(
|
|
178
|
+
`[${componentName}] pattern.json -> meta.styles.${key} should be meta.attributes.${key} (it is not defined under pattern.attributes.styles)`
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
112
185
|
return data;
|
|
113
186
|
}
|
package/src/RenderPage.tsx
CHANGED
|
@@ -12,7 +12,7 @@ import { RenderErrorBoundary } from './components/RenderErrorBoundary';
|
|
|
12
12
|
import { usePreviewSelection } from './hooks/usePreviewSelection';
|
|
13
13
|
import { defaultLocalization } from './types/PreviewConfig';
|
|
14
14
|
import { defaultProjectColors } from './utils/projectColors';
|
|
15
|
-
|
|
15
|
+
type ScreenStyle = {
|
|
16
16
|
light: { backgroundColor: string; color: string; seperatorColor?: string };
|
|
17
17
|
dark: { backgroundColor: string; color: string; seperatorColor?: string };
|
|
18
18
|
};
|
|
@@ -88,12 +88,6 @@ export function RenderPage({
|
|
|
88
88
|
const locKeys = overrideLocalization
|
|
89
89
|
? Object.keys(overrideLocalization)
|
|
90
90
|
: [];
|
|
91
|
-
const pcKeys = overrideProjectColors
|
|
92
|
-
? [
|
|
93
|
-
...Object.keys(overrideProjectColors.STATIC_COLORS ?? {}),
|
|
94
|
-
...Object.keys(overrideProjectColors.THEME_COLORS ?? {}),
|
|
95
|
-
]
|
|
96
|
-
: [];
|
|
97
91
|
|
|
98
92
|
const isDefaultLocalization =
|
|
99
93
|
!overrideLocalization ||
|
package/src/assets/meta.json
CHANGED