@rettangoli/fe 0.0.14 → 1.0.0-rc1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,10 +1,10 @@
1
1
  # Rettangoli Frontend
2
2
 
3
- A modern frontend framework that uses YAML for view definitions, web components for composition, and Immer for state management. Build reactive applications with minimal complexity using just 3 types of files.
3
+ A modern frontend framework that uses YAML for view definitions, web components for composition, and Immer for state management. Build reactive applications with minimal complexity using 4 types of files.
4
4
 
5
5
  ## Features
6
6
 
7
- - **🗂️ Three-File Architecture** - `.view.yaml`, `.store.js`, `.handlers.js` files scale from single page to complex applications
7
+ - **🗂️ Four-File Architecture** - `.view.yaml`, `.store.js`, `.handlers.js`, `.schema.yaml` scale from single page to complex applications
8
8
  - **📝 YAML Views** - Declarative UI definitions that compile to virtual DOM
9
9
  - **🧩 Web Components** - Standards-based component architecture
10
10
  - **🔄 Reactive State** - Immer-powered immutable state management
@@ -23,6 +23,7 @@ rtgl fe watch # Start dev server
23
23
 
24
24
  - **[Developer Quickstart](./docs/overview.md)** - Complete introduction and examples
25
25
  - **[View System](./docs/view.md)** - Complete YAML syntax
26
+ - **[Schema System](./docs/schema.md)** - Component API and metadata
26
27
  - **[Store Management](./docs/store.md)** - State patterns
27
28
  - **[Event Handlers](./docs/handlers.md)** - Event handling
28
29
 
@@ -38,7 +39,6 @@ rtgl fe watch # Start dev server
38
39
 
39
40
  **Build & Development:**
40
41
  - [ESBuild](https://esbuild.github.io/) - Fast bundling
41
- - [Vite](https://vite.dev/) - Development server with hot reload
42
42
 
43
43
  **Browser Native:**
44
44
  - Web Components - Component encapsulation
@@ -60,7 +60,7 @@ bun install
60
60
  2. **Create project structure**:
61
61
  ```bash
62
62
  # Scaffold a new component
63
- node ../rettangoli-cli/cli.js fe scaffold --category components --name MyButton
63
+ node ../rettangoli-cli/cli.js fe scaffold --category components --component-name MyButton
64
64
  ```
65
65
 
66
66
  3. **Start development**:
@@ -106,15 +106,31 @@ fe:
106
106
 
107
107
  ## Testing
108
108
 
109
- ### View Components
109
+ ### Unit and Contract Tests
110
110
 
111
- Use visual testing with `rtgl vt`:
111
+ - **Puty contract tests** (`spec/`) — YAML-driven pure-function specs for view, store, schema, and handler contracts.
112
+ - **Vitest integration tests** (`test/`) — runtime behavior tests for component lifecycle, props, events, and DOM.
112
113
 
113
114
  ```bash
114
- rtgl vt generate
115
- rtgl vt report
115
+ bun run test # all tests
116
+ bun run test:puty # contract tests only
117
+ bun run test:vitest # integration tests only
116
118
  ```
117
119
 
120
+ ### End-to-End Testing
121
+
122
+ E2E tests run against real example apps in `examples/` using `@rettangoli/vt`. VT specs define interaction steps (click, write, keypress, etc.) and capture screenshots via Playwright. Assertions are done by comparing candidate screenshots against reference baselines with pixelmatch.
123
+
124
+ ```bash
125
+ # In an example project (e.g. examples/example1/)
126
+ rtgl fe build # build components
127
+ rtgl vt generate # capture screenshots (runs Playwright)
128
+ rtgl vt report # compare against reference — fails on mismatch
129
+ rtgl vt accept # update baselines when changes are intentional
130
+ ```
131
+
132
+ VT specs live in each example's `vt/specs/` directory. See `examples/example1/` for the full setup.
133
+
118
134
  ## Examples
119
135
 
120
136
  For a complete working example, see the todos app in `examples/example1/`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rettangoli/fe",
3
- "version": "0.0.14",
3
+ "version": "1.0.0-rc1",
4
4
  "description": "Frontend framework for building reactive web components",
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
@@ -25,7 +25,10 @@
25
25
  ".": "./src/index.js",
26
26
  "./cli": "./src/cli/index.js"
27
27
  },
28
- "devDependencies": {},
28
+ "devDependencies": {
29
+ "puty": "^0.1.1",
30
+ "vitest": "^4.0.15"
31
+ },
29
32
  "dependencies": {
30
33
  "esbuild": "^0.25.5",
31
34
  "immer": "^10.1.1",
@@ -36,6 +39,9 @@
36
39
  "vite": "^6.3.5"
37
40
  },
38
41
  "scripts": {
39
- "dev": "node watch.js --watch"
42
+ "dev": "node watch.js --watch",
43
+ "test": "vitest run --reporter=verbose",
44
+ "test:puty": "vitest run puty.spec.js --reporter=verbose",
45
+ "test:vitest": "vitest run test/**/*.test.js --reporter=verbose"
40
46
  }
41
47
  }
@@ -1,8 +1,11 @@
1
+ export const handleBeforeMount = (deps, payload) => {
2
+ //
3
+ }
1
4
 
2
- export const handleOnMount = (deps, event) => {
5
+ export const handleAfterMount = async (deps, payload) => {
3
6
  //
4
7
  }
5
8
 
6
- export const handlerSomeEvent = (deps, event) => {
9
+ export const handleSomeEvent = (deps, payload) => {
7
10
  //
8
11
  }
@@ -0,0 +1,11 @@
1
+ componentName: custom-blank
2
+
3
+ description: Blank component scaffold
4
+
5
+ propsSchema:
6
+ type: object
7
+ properties: {}
8
+
9
+ events: []
10
+
11
+ methods: []
@@ -1,16 +1,5 @@
1
- elementName: custom-blank
2
-
3
- viewDataSchema:
4
- type: object
5
-
6
- propsSchema:
7
- type: object
8
- properties: {}
9
-
10
1
  refs: {}
11
2
 
12
- events: {}
13
-
14
3
  template:
15
4
  - rtgl-view w=f h=f p=md:
16
5
  - rtgl-text s=h2: blank
package/src/cli/build.js CHANGED
@@ -10,24 +10,32 @@ import { load as loadYaml } from "js-yaml";
10
10
  import { parse } from 'jempl';
11
11
  import { extractCategoryAndComponent } from '../commonBuild.js';
12
12
  import { getAllFiles } from '../commonBuild.js';
13
+ import {
14
+ isSupportedComponentFile,
15
+ validateComponentEntries,
16
+ } from "./contracts.js";
13
17
  import path from "node:path";
14
18
 
15
19
  function capitalize(word) {
16
20
  return word ? word[0].toUpperCase() + word.slice(1) : word;
17
21
  }
18
22
 
19
- // Function to process view files - loads YAML and creates temporary JS file
20
- export const writeViewFile = (view, category, component, tempDir) => {
23
+ const writeYamlModuleFile = (yamlObject, category, component, fileType, tempDir = path.resolve(process.cwd(), ".temp")) => {
21
24
  const dir = path.join(tempDir, category);
22
25
  if (!existsSync(dir)) {
23
26
  mkdirSync(dir, { recursive: true });
24
27
  }
25
28
  writeFileSync(
26
- path.join(dir, `${component}.view.js`),
27
- `export default ${JSON.stringify(view)};`,
29
+ path.join(dir, `${component}.${fileType}.js`),
30
+ `export default ${JSON.stringify(yamlObject)};`,
28
31
  );
29
32
  };
30
33
 
34
+ // Function to process view files - loads YAML and creates temporary JS file
35
+ export const writeViewFile = (view, category, component, tempDir = path.resolve(process.cwd(), ".temp")) => {
36
+ writeYamlModuleFile(view, category, component, "view", tempDir);
37
+ };
38
+
31
39
  export const bundleFile = async (options) => {
32
40
  const { outfile, tempDir, development = false } = options;
33
41
  await esbuild.build({
@@ -66,18 +74,13 @@ const buildRettangoliFrontend = async (options) => {
66
74
  mkdirSync(tempDir, { recursive: true });
67
75
  }
68
76
 
69
- const allFiles = getAllFiles(resolvedDirs).filter((filePath) => {
70
- return (
71
- filePath.endsWith(".store.js") ||
72
- filePath.endsWith(".handlers.js") ||
73
- filePath.endsWith(".view.yaml")
74
- );
75
- });
77
+ const allFiles = getAllFiles(resolvedDirs).filter((filePath) => isSupportedComponentFile(filePath));
76
78
 
77
79
  let output = "";
78
80
 
79
81
  const categories = [];
80
82
  const imports = {};
83
+ const componentContractEntries = [];
81
84
 
82
85
  // unique identifier needed for replacing
83
86
  let count = 10000000000;
@@ -101,7 +104,14 @@ const buildRettangoliFrontend = async (options) => {
101
104
  }
102
105
 
103
106
 
104
- if (["handlers", "store"].includes(fileType)) {
107
+ const componentContractEntry = {
108
+ category,
109
+ component,
110
+ fileType,
111
+ filePath,
112
+ };
113
+
114
+ if (["handlers", "store", "methods"].includes(fileType)) {
105
115
  const relativePath = path.relative(tempDir, filePath).replaceAll(path.sep, "/");
106
116
  output += `import * as ${component}${capitalize(
107
117
  fileType,
@@ -110,25 +120,42 @@ const buildRettangoliFrontend = async (options) => {
110
120
  replaceMap[count] = `${component}${capitalize(fileType)}`;
111
121
  imports[category][component][fileType] = count;
112
122
  count++;
113
- } else if (["view"].includes(fileType)) {
114
- const view = loadYaml(readFileSync(filePath, "utf8"));
115
- try {
116
- view.template = parse(view.template);
117
- } catch (error) {
118
- console.error(`Error parsing template in file: ${filePath}`);
119
- throw error;
123
+ } else if (["view", "constants", "schema"].includes(fileType)) {
124
+ const yamlObject = loadYaml(readFileSync(filePath, "utf8")) ?? {};
125
+ componentContractEntry.yamlObject = yamlObject;
126
+ if (fileType === "view") {
127
+ try {
128
+ yamlObject.template = parse(yamlObject.template);
129
+ } catch (error) {
130
+ console.error(`Error parsing template in file: ${filePath}`);
131
+ throw error;
132
+ }
120
133
  }
121
- writeViewFile(view, category, component, tempDir);
134
+ if (
135
+ fileType === "constants" &&
136
+ (yamlObject === null || typeof yamlObject !== "object" || Array.isArray(yamlObject))
137
+ ) {
138
+ throw new Error(`[Build] ${filePath} must contain a YAML object at the root.`);
139
+ }
140
+
141
+ writeYamlModuleFile(yamlObject, category, component, fileType, tempDir);
122
142
  output += `import ${component}${capitalize(
123
143
  fileType,
124
- )} from './${category}/${component}.view.js';\n`;
144
+ )} from './${category}/${component}.${fileType}.js';\n`;
125
145
  replaceMap[count] = `${component}${capitalize(fileType)}`;
126
146
 
127
147
  imports[category][component][fileType] = count;
128
148
  count++;
129
149
  }
150
+
151
+ componentContractEntries.push(componentContractEntry);
130
152
  }
131
153
 
154
+ validateComponentEntries({
155
+ entries: componentContractEntries,
156
+ errorPrefix: "[Build]",
157
+ });
158
+
132
159
  const relativeSetup = path.relative(tempDir, resolvedSetup).replaceAll(path.sep, "/");
133
160
  output += `
134
161
  import { createComponent } from '@rettangoli/fe';
@@ -137,8 +164,13 @@ const imports = ${JSON.stringify(imports, null, 2)};
137
164
 
138
165
  Object.keys(imports).forEach(category => {
139
166
  Object.keys(imports[category]).forEach(component => {
140
- const webComponent = createComponent({ ...imports[category][component], patch, h }, deps[category])
141
- customElements.define(imports[category][component].view.elementName, webComponent);
167
+ const componentConfig = imports[category][component];
168
+ const webComponent = createComponent({ ...componentConfig, patch, h }, deps[category])
169
+ const elementName = componentConfig.schema?.componentName;
170
+ if (!elementName) {
171
+ throw new Error(\`[Build] Missing schema.componentName for \${category}/\${component}. Define it in .schema.yaml.\`);
172
+ }
173
+ customElements.define(elementName, webComponent);
142
174
  })
143
175
  })
144
176
 
@@ -0,0 +1,53 @@
1
+ import path from "node:path";
2
+ import {
3
+ analyzeComponentDirs,
4
+ formatContractFailureReport,
5
+ } from "./contracts.js";
6
+
7
+ const checkRettangoliFrontend = (options = {}) => {
8
+ const {
9
+ cwd = process.cwd(),
10
+ dirs = ["./example"],
11
+ format = "text",
12
+ } = options;
13
+ const outputFormat = format === "json" ? "json" : "text";
14
+
15
+ const resolvedDirs = dirs.map((dir) => path.resolve(cwd, dir));
16
+ const { errors, summary, index } = analyzeComponentDirs({ dirs: resolvedDirs });
17
+
18
+ if (errors.length > 0) {
19
+ if (outputFormat === "json") {
20
+ console.log(JSON.stringify({
21
+ ok: false,
22
+ prefix: "[Check]",
23
+ summary,
24
+ errors,
25
+ }, null, 2));
26
+ } else {
27
+ console.error(formatContractFailureReport({
28
+ errorPrefix: "[Check]",
29
+ errors,
30
+ }));
31
+ }
32
+ process.exitCode = 1;
33
+ return;
34
+ }
35
+
36
+ const componentCount = Object.values(index).reduce((count, categoryComponents) => {
37
+ return count + Object.keys(categoryComponents).length;
38
+ }, 0);
39
+
40
+ if (outputFormat === "json") {
41
+ console.log(JSON.stringify({
42
+ ok: true,
43
+ prefix: "[Check]",
44
+ componentCount,
45
+ summary,
46
+ }, null, 2));
47
+ return;
48
+ }
49
+
50
+ console.log(`[Check] Component contracts passed for ${componentCount} component(s).`);
51
+ };
52
+
53
+ export default checkRettangoliFrontend;
@@ -0,0 +1,143 @@
1
+ import { readFileSync } from "node:fs";
2
+ import { load as loadYaml } from "js-yaml";
3
+ import { extractCategoryAndComponent, getAllFiles } from "../commonBuild.js";
4
+ import {
5
+ buildComponentContractIndex,
6
+ formatContractErrors as formatContractErrorLines,
7
+ validateComponentContractIndex,
8
+ } from "../core/contracts/componentFiles.js";
9
+
10
+ export const SUPPORTED_COMPONENT_FILE_SUFFIXES = Object.freeze([
11
+ ".store.js",
12
+ ".handlers.js",
13
+ ".methods.js",
14
+ ".constants.yaml",
15
+ ".schema.yaml",
16
+ ".view.yaml",
17
+ ]);
18
+
19
+ export const isSupportedComponentFile = (filePath) => {
20
+ return SUPPORTED_COMPONENT_FILE_SUFFIXES.some((suffix) => filePath.endsWith(suffix));
21
+ };
22
+
23
+ export const collectComponentContractEntriesFromFiles = (allFiles = []) => {
24
+ return allFiles
25
+ .filter((filePath) => isSupportedComponentFile(filePath))
26
+ .map((filePath) => {
27
+ const { category, component, fileType } = extractCategoryAndComponent(filePath);
28
+ const entry = {
29
+ category,
30
+ component,
31
+ fileType,
32
+ filePath,
33
+ };
34
+
35
+ if (["view", "schema"].includes(fileType)) {
36
+ entry.yamlObject = loadYaml(readFileSync(filePath, "utf8")) ?? {};
37
+ }
38
+
39
+ return entry;
40
+ });
41
+ };
42
+
43
+ export const collectComponentContractEntriesFromDirs = (dirs = []) => {
44
+ const allFiles = getAllFiles(dirs);
45
+ return collectComponentContractEntriesFromFiles(allFiles);
46
+ };
47
+
48
+ export const validateComponentEntries = ({
49
+ entries = [],
50
+ errorPrefix = "[Check]",
51
+ }) => {
52
+ const index = buildComponentContractIndex(entries);
53
+ const errors = validateComponentContractIndex(index);
54
+ if (errors.length > 0) {
55
+ throw new Error(
56
+ `${errorPrefix} Component contract validation failed:\n${formatContractErrors(errors).join("\n")}`,
57
+ );
58
+ }
59
+ return {
60
+ index,
61
+ errors,
62
+ };
63
+ };
64
+
65
+ export const validateComponentDirs = ({
66
+ dirs = [],
67
+ errorPrefix = "[Check]",
68
+ }) => {
69
+ const entries = collectComponentContractEntriesFromDirs(dirs);
70
+ const validationResult = validateComponentEntries({ entries, errorPrefix });
71
+ return {
72
+ entries,
73
+ ...validationResult,
74
+ };
75
+ };
76
+
77
+ export const summarizeContractErrors = (errors = []) => {
78
+ const byCode = {};
79
+ const byComponent = {};
80
+
81
+ errors.forEach((error) => {
82
+ const code = error?.code || "UNKNOWN";
83
+ byCode[code] = (byCode[code] || 0) + 1;
84
+
85
+ const componentLabelMatch = String(error?.message || "").match(/^([^:]+):\s/);
86
+ const componentLabel = componentLabelMatch ? componentLabelMatch[1] : "unknown";
87
+ byComponent[componentLabel] = (byComponent[componentLabel] || 0) + 1;
88
+ });
89
+
90
+ const byCodeSorted = Object.entries(byCode)
91
+ .map(([code, count]) => ({ code, count }))
92
+ .sort((a, b) => a.code.localeCompare(b.code));
93
+
94
+ const byComponentSorted = Object.entries(byComponent)
95
+ .map(([component, count]) => ({ component, count }))
96
+ .sort((a, b) => b.count - a.count || a.component.localeCompare(b.component));
97
+
98
+ return {
99
+ total: errors.length,
100
+ byCode: byCodeSorted,
101
+ byComponent: byComponentSorted,
102
+ };
103
+ };
104
+
105
+ export const formatContractFailureReport = ({
106
+ errorPrefix = "[Check]",
107
+ errors = [],
108
+ }) => {
109
+ const summary = summarizeContractErrors(errors);
110
+ const header = `${errorPrefix} Component contract validation failed: ${summary.total} issue(s)`;
111
+ const byCodeLines = summary.byCode.map(({ code, count }) => `- ${code}: ${count}`);
112
+ const byComponentLines = summary.byComponent.map(
113
+ ({ component, count }) => `- ${component}: ${count}`,
114
+ );
115
+ const detailLines = formatContractErrorLines(errors);
116
+
117
+ return [
118
+ header,
119
+ "By rule:",
120
+ ...(byCodeLines.length > 0 ? byCodeLines : ["- none"]),
121
+ "By component:",
122
+ ...(byComponentLines.length > 0 ? byComponentLines : ["- none"]),
123
+ "Details:",
124
+ ...(detailLines.length > 0 ? detailLines : ["- none"]),
125
+ ].join("\n");
126
+ };
127
+
128
+ export const analyzeComponentEntries = ({ entries = [] }) => {
129
+ const index = buildComponentContractIndex(entries);
130
+ const errors = validateComponentContractIndex(index);
131
+ const summary = summarizeContractErrors(errors);
132
+ return {
133
+ entries,
134
+ index,
135
+ errors,
136
+ summary,
137
+ };
138
+ };
139
+
140
+ export const analyzeComponentDirs = ({ dirs = [] }) => {
141
+ const entries = collectComponentContractEntriesFromDirs(dirs);
142
+ return analyzeComponentEntries({ entries });
143
+ };
package/src/cli/index.js CHANGED
@@ -1,11 +1,5 @@
1
- import build from './build.js';
2
- import scaffold from './scaffold.js';
3
- import watch from './watch.js';
4
- import examples from './examples.js';
5
-
6
- export {
7
- build,
8
- scaffold,
9
- watch,
10
- examples
11
- }
1
+ export { default as build } from "./build.js";
2
+ export { default as check } from "./check.js";
3
+ export { default as scaffold } from "./scaffold.js";
4
+ export { default as watch } from "./watch.js";
5
+ export { default as examples } from "./examples.js";
@@ -1,5 +1,6 @@
1
1
  import fs from 'node:fs';
2
2
  import path from 'node:path';
3
+ import { validateComponentDirs } from './contracts.js';
3
4
 
4
5
  const __dirname = path.dirname(new URL(import.meta.url).pathname);
5
6
 
@@ -37,6 +38,11 @@ const scaffoldPage = (options) => {
37
38
  }
38
39
  });
39
40
 
41
+ validateComponentDirs({
42
+ dirs: [path.resolve(targetDir)],
43
+ errorPrefix: "[Scaffold]",
44
+ });
45
+
40
46
  console.log(`Successfully scaffolded ${targetDir} from template`);
41
47
  }
42
48
 
package/src/cli/watch.js CHANGED
@@ -20,9 +20,10 @@ const setupWatcher = (directory, options) => {
20
20
  console.log(`Detected ${event} in ${directory}/${filename}`);
21
21
  if (filename) {
22
22
  try {
23
+ const changedFilePath = path.join(directory, filename);
23
24
  if (filename.endsWith('.view.yaml')) {
24
- const view = loadYaml(readFileSync(path.join(directory, filename), "utf8"));
25
- const { category, component } = extractCategoryAndComponent(filename);
25
+ const view = loadYaml(readFileSync(changedFilePath, "utf8"));
26
+ const { category, component } = extractCategoryAndComponent(changedFilePath);
26
27
  await writeViewFile(view, category, component);
27
28
  }
28
29
 
@@ -0,0 +1,119 @@
1
+ export const FORBIDDEN_VIEW_KEYS = Object.freeze([
2
+ "elementName",
3
+ "viewDataSchema",
4
+ "propsSchema",
5
+ "events",
6
+ "methods",
7
+ "attrsSchema",
8
+ ]);
9
+
10
+ const LEGACY_PROP_BINDING_REGEX = /(^|\s)\.[A-Za-z_][A-Za-z0-9_-]*\s*=/;
11
+
12
+ const hasLegacyDotPropBinding = (node) => {
13
+ if (Array.isArray(node)) {
14
+ return node.some((item) => hasLegacyDotPropBinding(item));
15
+ }
16
+ if (!node || typeof node !== "object") {
17
+ return false;
18
+ }
19
+
20
+ return Object.entries(node).some(([key, value]) => {
21
+ if (LEGACY_PROP_BINDING_REGEX.test(key)) {
22
+ return true;
23
+ }
24
+ return hasLegacyDotPropBinding(value);
25
+ });
26
+ };
27
+
28
+ export const buildComponentContractIndex = (entries = []) => {
29
+ const index = {};
30
+
31
+ entries.forEach((entry) => {
32
+ const {
33
+ category,
34
+ component,
35
+ fileType,
36
+ filePath,
37
+ yamlObject,
38
+ } = entry || {};
39
+
40
+ if (!category || !component || !fileType || !filePath) {
41
+ return;
42
+ }
43
+
44
+ if (!index[category]) {
45
+ index[category] = {};
46
+ }
47
+
48
+ if (!index[category][component]) {
49
+ index[category][component] = {
50
+ fileTypes: new Set(),
51
+ files: [],
52
+ viewFilePath: null,
53
+ viewYaml: null,
54
+ };
55
+ }
56
+
57
+ const componentEntry = index[category][component];
58
+ componentEntry.fileTypes.add(fileType);
59
+ componentEntry.files.push(filePath);
60
+
61
+ if (fileType === "view") {
62
+ componentEntry.viewFilePath = filePath;
63
+ componentEntry.viewYaml = yamlObject;
64
+ }
65
+ });
66
+
67
+ return index;
68
+ };
69
+
70
+ export const validateComponentContractIndex = (index = {}) => {
71
+ const errors = [];
72
+
73
+ Object.entries(index).forEach(([category, components]) => {
74
+ Object.entries(components).forEach(([component, componentEntry]) => {
75
+ const componentLabel = `${category}/${component}`;
76
+ const representativeFile = componentEntry.files[0] || componentLabel;
77
+
78
+ if (!componentEntry.fileTypes.has("schema")) {
79
+ errors.push({
80
+ code: "RTGL-CONTRACT-001",
81
+ message: `${componentLabel}: missing required .schema.yaml file.`,
82
+ filePath: representativeFile,
83
+ });
84
+ }
85
+
86
+ const { viewYaml, viewFilePath } = componentEntry;
87
+ if (!viewYaml || typeof viewYaml !== "object" || Array.isArray(viewYaml)) {
88
+ return;
89
+ }
90
+
91
+ FORBIDDEN_VIEW_KEYS.forEach((forbiddenKey) => {
92
+ if (!Object.prototype.hasOwnProperty.call(viewYaml, forbiddenKey)) {
93
+ return;
94
+ }
95
+ errors.push({
96
+ code: "RTGL-CONTRACT-002",
97
+ message: `${componentLabel}: '${forbiddenKey}' is not allowed in .view.yaml. Move API metadata to .schema.yaml.`,
98
+ filePath: viewFilePath || representativeFile,
99
+ });
100
+ });
101
+
102
+ if (hasLegacyDotPropBinding(viewYaml.template)) {
103
+ errors.push({
104
+ code: "RTGL-CONTRACT-003",
105
+ message: `${componentLabel}: legacy '.prop=' binding is not supported. Use ':prop=' in .view.yaml.`,
106
+ filePath: viewFilePath || representativeFile,
107
+ });
108
+ }
109
+ });
110
+ });
111
+
112
+ return errors;
113
+ };
114
+
115
+ export const formatContractErrors = (errors = []) => {
116
+ return errors.map((error) => {
117
+ return `${error.code} ${error.message} [${error.filePath}]`;
118
+ });
119
+ };