@heshammesalam/heshjs 0.3.0 → 0.5.0
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 +17 -18
- package/cli.js +8 -3
- package/dist/architecture/html.d.ts +2 -0
- package/dist/architecture/html.js +20 -2
- package/dist/architecture/html.js.map +1 -1
- package/dist/architecture/index.js +16 -6
- package/dist/architecture/index.js.map +1 -1
- package/dist/destinations/index.js +3 -2
- package/dist/destinations/index.js.map +1 -1
- package/dist/heshjs/index.d.ts +2 -0
- package/dist/heshjs/index.js +1 -0
- package/dist/heshjs/index.js.map +1 -1
- package/dist/hmvc/index.d.ts +2 -0
- package/dist/hmvc/index.js +11 -0
- package/dist/hmvc/index.js.map +1 -1
- package/dist/parser/index.js +1 -1
- package/dist/parser/index.js.map +1 -1
- package/dist/presentation/index.d.ts +3 -0
- package/dist/presentation/index.js +1 -0
- package/dist/presentation/index.js.map +1 -1
- package/dist/units/index.d.ts +13 -0
- package/dist/units/index.js +16 -0
- package/dist/units/index.js.map +1 -0
- package/docs/contracts.md +8 -1
- package/docs/units.md +71 -0
- package/package.json +4 -3
- package/scaffold/assets/hesh-icon.png +0 -0
- package/scaffold/create.js +78 -0
- package/scaffold/template.js +188 -0
- package/src/architecture/html.ts +15 -2
- package/src/architecture/index.ts +13 -5
- package/src/destinations/index.ts +3 -2
- package/src/heshjs/index.ts +2 -0
- package/src/hmvc/index.ts +7 -0
- package/src/parser/index.ts +1 -1
- package/src/presentation/index.ts +3 -1
- package/src/units/index.ts +23 -0
package/README.md
CHANGED
|
@@ -1,27 +1,26 @@
|
|
|
1
1
|
# HeshJS
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
Version 0.3 adds opt-in .hesh domain/presentation/destination contracts,
|
|
7
|
-
the Node-only `/architecture` compiler and `hesh check|graph` command, `/domains`,
|
|
8
|
-
`/presentation` and `/destinations` runtimes. See docs/contracts.md and
|
|
9
|
-
docs/domain-graph.md for the precise supported slice and its limits. The default
|
|
10
|
-
creator remains an HMVC starter; Domain Graph is enabled explicitly in Vite.
|
|
11
|
-
|
|
12
|
-
Requires Node.js 22.12 or later.
|
|
3
|
+
Version 0.5.0 unifies the creator, runtime, compiler and architecture tools in **one npm package**.
|
|
4
|
+
HTML is the default for every screen, including the persistent shell and nested parts.
|
|
13
5
|
|
|
14
6
|
```sh
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
npm install
|
|
18
|
-
npm run dev
|
|
7
|
+
npx @heshammesalam/heshjs@latest create
|
|
8
|
+
# or: npx @heshammesalam/heshjs@latest create my-project --ts
|
|
19
9
|
```
|
|
20
10
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
11
|
+
The wizard asks for your folder and JavaScript/TypeScript (JavaScript by default).
|
|
12
|
+
Then run cd YOUR_FOLDER, npm install, npm run dev.
|
|
13
|
+
Use npm run check, npm run graph and npm run build.
|
|
14
|
+
|
|
15
|
+
Hesh Units preserve hierarchical MVC lifetimes with Hesh-specific names:
|
|
16
|
+
state.js/ts for state, actions.js/ts for behavior, screen.html for views,
|
|
17
|
+
unit.hesh for Domain Graph contracts, and parts/ for nested units. Business units
|
|
18
|
+
live under src/hesh-units; foundation/shell owns the persistent HTML shell.
|
|
19
|
+
The supplied Hesh logo and favicon are bundled. See docs/contracts.md for HTML directives.
|
|
20
|
+
See docs/units.md for the complete structure and the `/units` API.
|
|
21
|
+
The legacy create-heshjs package is superseded; use the npx command above.
|
|
22
|
+
|
|
23
|
+
Requires Node.js 22.12 or later.
|
|
25
24
|
|
|
26
25
|
```hesh
|
|
27
26
|
export default view Counter {
|
package/cli.js
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { checkProject, writeProject, formatDiagnostic } from './dist/architecture/index.js';
|
|
3
2
|
const args = process.argv.slice(2);
|
|
4
3
|
const command = args.shift();
|
|
5
4
|
if (command === '--help' || command === '-h' || !command) {
|
|
6
|
-
console.log('Usage: hesh check|graph [project-root] [--entry app.hesh] [--tsconfig tsconfig.json] [--write]');
|
|
5
|
+
console.log('Usage: hesh create [directory] [--js | --ts]\n hesh check|graph [project-root] [--entry app.hesh] [--tsconfig tsconfig.json] [--write]\nAll commands are included in @heshammesalam/heshjs.');
|
|
7
6
|
process.exit(command ? 0 : 1);
|
|
8
7
|
}
|
|
9
|
-
if (
|
|
8
|
+
if (command === 'create') {
|
|
9
|
+
try { const { createProject } = await import('./scaffold/create.js'); await createProject(args); }
|
|
10
|
+
catch (error) { console.error(error.message); process.exitCode = error.exitCode ?? 1; }
|
|
11
|
+
} else if (!['check', 'graph'].includes(command)) { console.error(`Unknown command ${command}`); process.exitCode = 1; }
|
|
12
|
+
else {
|
|
10
13
|
const options = { root: process.cwd() }; let write = false;
|
|
11
14
|
if (args[0] && !args[0].startsWith('--')) options.root = args.shift();
|
|
12
15
|
while (args.length) {
|
|
@@ -16,6 +19,7 @@ while (args.length) {
|
|
|
16
19
|
options[flag.slice(2)] = args.shift();
|
|
17
20
|
}
|
|
18
21
|
try {
|
|
22
|
+
const { checkProject, writeProject, formatDiagnostic } = await import('./dist/architecture/index.js');
|
|
19
23
|
const result = checkProject(options);
|
|
20
24
|
for (const item of result.diagnostics) console.error(formatDiagnostic(item));
|
|
21
25
|
if (result.diagnostics.some(item => item.severity === 'error')) process.exitCode = 1;
|
|
@@ -24,3 +28,4 @@ try {
|
|
|
24
28
|
console.log(command === 'graph' ? JSON.stringify(result.graph, null, 2) : `Architecture valid: ${result.graph.domains.length} domains, ${result.graph.destinations.length} destinations${write ? '; generated JS/declarations written' : ''}.`);
|
|
25
29
|
}
|
|
26
30
|
} catch (error) { console.error(error instanceof Error ? error.message : String(error)); process.exitCode = 1; }
|
|
31
|
+
}
|
|
@@ -3,6 +3,8 @@ export interface HTMLContract {
|
|
|
3
3
|
filename: string;
|
|
4
4
|
bindings: string[];
|
|
5
5
|
actions: string[];
|
|
6
|
+
parts?: string[];
|
|
7
|
+
allowOutlet?: boolean;
|
|
6
8
|
destinations: Record<string, Record<string, string>>;
|
|
7
9
|
validateBinding?: (path: string, offset: number, expected?: string, writable?: boolean) => void;
|
|
8
10
|
}
|
|
@@ -73,9 +73,27 @@ export function compileHTML(source, contract) {
|
|
|
73
73
|
lines.push(`p.attribute(${id}, ${JSON.stringify(attr.name)}, () => ${wholeBinding ? path(attr.value.slice(1, -1), attrAt(attr.name) + 1) : interpolation(attr.value, attrAt(attr.name))});`);
|
|
74
74
|
}
|
|
75
75
|
for (const name of Object.keys(attributes))
|
|
76
|
-
if (name.startsWith('h-') && !['h-action', 'h-bind', 'h-value', 'h-destination'].includes(name) && !name.startsWith('h-input-'))
|
|
76
|
+
if (name.startsWith('h-') && !['h-action', 'h-bind', 'h-value', 'h-destination', 'h-part', 'h-outlet'].includes(name) && !name.startsWith('h-input-'))
|
|
77
77
|
report('HESH-HTML-004', `Unsupported directive ${name}`, attrAt(name), 'Use supported directives; keyed lists/scoped templates are a later milestone.');
|
|
78
|
-
|
|
78
|
+
const content = ['h-bind', 'h-part', 'h-outlet'].filter(name => attributes[name] !== undefined);
|
|
79
|
+
if (content.length > 1 || (content.length && node.childNodes.length))
|
|
80
|
+
report('HESH-HTML-005', 'Content directives require an empty container and cannot be combined', at, 'Choose one content directive and remove children.');
|
|
81
|
+
if (attributes['h-part'] !== undefined || attributes['h-outlet'] !== undefined) {
|
|
82
|
+
if (['area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'link', 'meta', 'param', 'source', 'track', 'wbr'].includes(node.tagName))
|
|
83
|
+
report('HESH-HTML-005', 'Parts and outlets require a container element', at, 'Use div, main, section or another container.');
|
|
84
|
+
if (attributes['h-part'] !== undefined) {
|
|
85
|
+
const name = attributes['h-part'];
|
|
86
|
+
if (!contract.parts?.includes(name))
|
|
87
|
+
report('HESH-PART-001', `Undeclared Hesh part ${name}`, at, 'Declare parts and return a Hesh Unit from parts.NAME.');
|
|
88
|
+
lines.push(`p.mountPart(${id}, state, ${JSON.stringify(name)});`);
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
if (!contract.allowOutlet || attributes['h-outlet'] !== '')
|
|
92
|
+
report('HESH-PART-002', 'h-outlet is only available on standalone shell screens', at, 'Use an empty h-outlet on the persistent shell.');
|
|
93
|
+
lines.push(`p.unitOutlet(${id});`);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
else if (attributes['h-bind'] !== undefined) {
|
|
79
97
|
if (node.childNodes.length)
|
|
80
98
|
report('HESH-BIND-003', 'h-bind cannot also contain children', at, 'Remove the children or use text interpolation.');
|
|
81
99
|
lines.push(`p.text(${id}, () => ${path(attributes['h-bind'], attrAt('h-bind'))});`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"html.js","sourceRoot":"","sources":["../../src/architecture/html.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAA8B,MAAM,QAAQ,CAAC;AACnE,OAAO,EAAE,UAAU,EAA+B,MAAM,kBAAkB,CAAC;AAO3E,MAAM,UAAU,WAAW,CAAC,MAAc,EAAE,QAAsB;IAChE,MAAM,WAAW,GAA6B,EAAE,EAAE,YAAY,GAAG,IAAI,GAAG,EAAU,EAAE,WAAW,GAAG,IAAI,GAAG,EAAU,CAAC;IACpH,MAAM,MAAM,GAAG,CAAC,IAAY,EAAE,OAAe,EAAE,EAAU,EAAE,UAAkB,EAAE,WAAgC,OAAO,EAAE,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC,CAAC;IAC5N,MAAM,QAAQ,GAAG,aAAa,CAAC,MAAM,EAAE,EAAE,sBAAsB,EAAE,IAAI,EAAE,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,MAAM,CAAC,eAAe,EAAE,KAAK,CA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nexport interface HTMLContract {\n filename: string; bindings: string[]; actions: string[];\n destinations: Record<string, Record<string, string>>;\n validateBinding?: (path: string, offset: number, expected?: string, writable?: boolean) => void;\n}\nexport interface HTMLResult { code: string; diagnostics: ArchitectureDiagnostic[]; usedBindings: string[]; usedActions: string[]; destinations: string[] }\nexport function compileHTML(source: string, contract: HTMLContract): HTMLResult {\n const diagnostics: ArchitectureDiagnostic[] = [], usedBindings = new Set<string>(), usedActions = new Set<string>();\n const report = (code: string, message: string, at: number, suggestion: string, severity: 'error' | 'warning' = 'error') => diagnostics.push(diagnostic(code, message, contract.filename, source, at, suggestion, severity));\n const fragment = parseFragment(source, { sourceCodeLocationInfo: true, onParseError: error => report('HESH-HTML-001', error.code, error.startOffset, 'Correct the HTML syntax.') });\n const lines = [\"import * as p from '@heshammesalam/heshjs/presentation';\", 'export default function render(parent, state, destinations) {'];\n let serial = 0;\n const linked = new Set<string>();\n const path = (value: string, offset: number, expected?: string, writable = false): string => {\n const pieces = value.trim().split('.');\n if (pieces.some(piece => !/^[$_\\p{ID_Start}][$_\\u200c\\u200d\\p{ID_Continue}]*$/u.test(piece) || ['constructor', '__proto__', 'prototype'].includes(piece))) report('HESH-BIND-001', `Invalid binding path ${value}`, offset, 'Use a declared dotted data path, not an expression.');\n if (!contract.bindings.includes(pieces[0]!)) report('HESH-BIND-002', `Missing data binding ${pieces[0]}`, offset, 'Declare the binding and return it from the presentation factory.');\n usedBindings.add(pieces[0]!); contract.validateBinding?.(value.trim(), offset, expected, writable);\n return `p.readBinding(state.bindings, ${JSON.stringify(value.trim())})`;\n };\n const interpolation = (value: string, offset: number): string => {\n const parts: string[] = []; let literal = '', cursor = 0;\n const emit = () => { if (literal) { parts.push(JSON.stringify(literal)); literal = ''; } };\n while (cursor < value.length) {\n if (value[cursor] === '\\\\' && ['{', '}'].includes(value[cursor + 1] ?? '')) { literal += value[cursor + 1]; cursor += 2; continue; }\n if (value[cursor] !== '{') { literal += value[cursor++]; continue; }\n emit(); const start = ++cursor, end = value.indexOf('}', start);\n if (end < 0) { report('HESH-BIND-001', 'Unterminated interpolation', offset + start - 1, 'Close the binding with }.'); break; }\n parts.push(`String(${path(value.slice(start, end), offset + start)} ?? '')`); cursor = end + 1;\n }\n emit(); return parts.join(' + ') || \"''\";\n };\n const visit = (node: DefaultTreeAdapterMap['childNode'], parent: string): void => {\n const at = node.sourceCodeLocation?.startOffset ?? 0;\n if (node.nodeName === '#text') { lines.push(`p.text(${parent}, () => ${interpolation((node as DefaultTreeAdapterMap['textNode']).value, at)});`); return; }\n if (!('tagName' in node)) return;\n if (node.namespaceURI !== 'http://www.w3.org/1999/xhtml' || ['script', 'iframe', 'object', 'embed', 'base', 'meta', 'link', 'style', 'template'].includes(node.tagName)) {\n report('HESH-HTML-002', `Unsupported active/foreign template element <${node.tagName}>`, at, 'Use semantic HTML and declared CSS/JS modules.'); return;\n }\n const id = `node${serial++}`;\n lines.push(`const ${id} = p.element(${parent}, ${JSON.stringify(node.tagName)});`);\n const attributes = Object.fromEntries(node.attrs.map(attr => [attr.name, attr.value]));\n const attrAt = (name: string) => node.sourceCodeLocation?.attrs?.[name]?.startOffset ?? at;\n for (const attr of node.attrs) {\n if (attr.name.startsWith('h-')) continue;\n if (/^on/i.test(attr.name) || ['srcdoc', 'innerhtml', 'outerhtml'].includes(attr.name)) { report('HESH-HTML-003', `Unsafe attribute ${attr.name}`, attrAt(attr.name), 'Use h-action and safe DOM bindings.'); continue; }\n const wholeBinding = attr.value.startsWith('{') && attr.value.endsWith('}') && !attr.value.slice(1, -1).includes('{') && !attr.value.slice(1, -1).includes('}');\n lines.push(`p.attribute(${id}, ${JSON.stringify(attr.name)}, () => ${wholeBinding ? path(attr.value.slice(1, -1), attrAt(attr.name) + 1) : interpolation(attr.value, attrAt(attr.name))});`);\n }\n for (const name of Object.keys(attributes)) if (name.startsWith('h-') && !['h-action', 'h-bind', 'h-value', 'h-destination'].includes(name) && !name.startsWith('h-input-')) report('HESH-HTML-004', `Unsupported directive ${name}`, attrAt(name), 'Use supported directives; keyed lists/scoped templates are a later milestone.');\n if (attributes['h-bind'] !== undefined) {\n if (node.childNodes.length) report('HESH-BIND-003', 'h-bind cannot also contain children', at, 'Remove the children or use text interpolation.');\n lines.push(`p.text(${id}, () => ${path(attributes['h-bind'], attrAt('h-bind'))});`);\n } else node.childNodes.forEach(child => visit(child, id));\n if (attributes['h-action'] !== undefined) {\n const name = attributes['h-action']; usedActions.add(name);\n if (!contract.actions.includes(name)) report('HESH-ACTION-001', `Missing action ${name}`, attrAt('h-action'), 'Declare and implement the action.');\n lines.push(`p.bindAction(${id}, state, ${JSON.stringify(name)});`);\n }\n if (attributes['h-value'] !== undefined) {\n const name = attributes['h-value'];\n if (!['input', 'textarea', 'select'].includes(node.tagName) || name.includes('.') || ['checkbox', 'radio', 'file'].includes(attributes.type ?? '') || attributes.multiple !== undefined) report('HESH-BIND-004', 'h-value requires a single-value text control and root writable signal', attrAt('h-value'), 'Use a text input/textarea/single select and a declared signal.');\n path(name, attrAt('h-value'), undefined, true);\n lines.push(`p.bindValue(${id}, state.bindings, ${JSON.stringify(name)});`);\n }\n const destination = attributes['h-destination'];\n const inputs = Object.keys(attributes).filter(name => name.startsWith('h-input-'));\n if (destination !== undefined) {\n linked.add(destination);\n const schema = contract.destinations[destination];\n if (!schema) report('HESH-NAV-001', `Unknown destination ${destination}`, attrAt('h-destination'), 'Declare this destination in the application.');\n if (node.tagName !== 'a' || attributes.href !== undefined) report('HESH-NAV-002', 'h-destination requires an anchor without an explicit href', at, 'Use <a h-destination=\"Name\" ...>.');\n for (const key of Object.keys(schema ?? {})) if (attributes[`h-input-${key.toLowerCase()}`] === undefined) report('HESH-NAV-003', `Missing destination input ${key}`, at, `Add h-input-${key} bound to a declared value.`);\n const entries = inputs.map(attr => {\n const key = Object.keys(schema ?? {}).find(key => key.toLowerCase() === attr.slice(8)) ?? attr.slice(8);\n if (!schema || !Object.hasOwn(schema, key)) report('HESH-NAV-003', `Unknown destination input ${key}`, attrAt(attr), 'Use only inputs declared by the destination.');\n return `${JSON.stringify(key)}: ${path(attributes[attr]!, attrAt(attr), schema?.[key])}`;\n });\n lines.push(`p.attribute(${id}, 'href', () => destinations[${JSON.stringify(destination)}].href({${entries.join(',')}}));`);\n } else if (inputs.length) report('HESH-NAV-003', 'h-input-* requires h-destination', at, 'Declare the destination on this anchor.');\n };\n fragment.childNodes.forEach(node => visit(node, 'parent')); lines.push('}');\n for (const name of contract.bindings) if (!usedBindings.has(name)) report('HESH-BIND-005', `Unused binding ${name}`, 0, 'Remove the declaration if it is not needed by this template.', 'warning');\n for (const name of contract.actions) if (!usedActions.has(name)) report('HESH-ACTION-002', `Unused action ${name}`, 0, 'Remove the declaration if it is not needed by this template.', 'warning');\n return { code: lines.join('\\n'), diagnostics, usedBindings: [...usedBindings], usedActions: [...usedActions], destinations: [...linked] };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"html.js","sourceRoot":"","sources":["../../src/architecture/html.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAA8B,MAAM,QAAQ,CAAC;AACnE,OAAO,EAAE,UAAU,EAA+B,MAAM,kBAAkB,CAAC;AAQ3E,MAAM,UAAU,WAAW,CAAC,MAAc,EAAE,QAAsB;IAChE,MAAM,WAAW,GAA6B,EAAE,EAAE,YAAY,GAAG,IAAI,GAAG,EAAU,EAAE,WAAW,GAAG,IAAI,GAAG,EAAU,CAAC;IACpH,MAAM,MAAM,GAAG,CAAC,IAAY,EAAE,OAAe,EAAE,EAAU,EAAE,UAAkB,EAAE,WAAgC,OAAO,EAAE,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC,CAAC;IAC5N,MAAM,QAAQ,GAAG,aAAa,CAAC,MAAM,EAAE,EAAE,sBAAsB,EAAE,IAAI,EAAE,YAAY,EAAE,K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AAC,IAAI,CAAC,EAAE,WAAW,EAAE,YAAY,EAAE,CAAC,GAAG,YAAY,CAAC,EAAE,WAAW,EAAE,CAAC,GAAG,WAAW,CAAC,EAAE,YAAY,EAAE,CAAC,GAAG,MAAM,CAAC,EAAE,CAAC;AAC5I,CAAC","sourcesContent":["import { parseFragment, type DefaultTreeAdapterMap } from 'parse5';\nimport { diagnostic, type ArchitectureDiagnostic } from './diagnostics.js';\nexport interface HTMLContract {\n filename: string; bindings: string[]; actions: string[];\n parts?: string[]; allowOutlet?: boolean;\n destinations: Record<string, Record<string, string>>;\n validateBinding?: (path: string, offset: number, expected?: string, writable?: boolean) => void;\n}\nexport interface HTMLResult { code: string; diagnostics: ArchitectureDiagnostic[]; usedBindings: string[]; usedActions: string[]; destinations: string[] }\nexport function compileHTML(source: string, contract: HTMLContract): HTMLResult {\n const diagnostics: ArchitectureDiagnostic[] = [], usedBindings = new Set<string>(), usedActions = new Set<string>();\n const report = (code: string, message: string, at: number, suggestion: string, severity: 'error' | 'warning' = 'error') => diagnostics.push(diagnostic(code, message, contract.filename, source, at, suggestion, severity));\n const fragment = parseFragment(source, { sourceCodeLocationInfo: true, onParseError: error => report('HESH-HTML-001', error.code, error.startOffset, 'Correct the HTML syntax.') });\n const lines = [\"import * as p from '@heshammesalam/heshjs/presentation';\", 'export default function render(parent, state, destinations) {'];\n let serial = 0;\n const linked = new Set<string>();\n const path = (value: string, offset: number, expected?: string, writable = false): string => {\n const pieces = value.trim().split('.');\n if (pieces.some(piece => !/^[$_\\p{ID_Start}][$_\\u200c\\u200d\\p{ID_Continue}]*$/u.test(piece) || ['constructor', '__proto__', 'prototype'].includes(piece))) report('HESH-BIND-001', `Invalid binding path ${value}`, offset, 'Use a declared dotted data path, not an expression.');\n if (!contract.bindings.includes(pieces[0]!)) report('HESH-BIND-002', `Missing data binding ${pieces[0]}`, offset, 'Declare the binding and return it from the presentation factory.');\n usedBindings.add(pieces[0]!); contract.validateBinding?.(value.trim(), offset, expected, writable);\n return `p.readBinding(state.bindings, ${JSON.stringify(value.trim())})`;\n };\n const interpolation = (value: string, offset: number): string => {\n const parts: string[] = []; let literal = '', cursor = 0;\n const emit = () => { if (literal) { parts.push(JSON.stringify(literal)); literal = ''; } };\n while (cursor < value.length) {\n if (value[cursor] === '\\\\' && ['{', '}'].includes(value[cursor + 1] ?? '')) { literal += value[cursor + 1]; cursor += 2; continue; }\n if (value[cursor] !== '{') { literal += value[cursor++]; continue; }\n emit(); const start = ++cursor, end = value.indexOf('}', start);\n if (end < 0) { report('HESH-BIND-001', 'Unterminated interpolation', offset + start - 1, 'Close the binding with }.'); break; }\n parts.push(`String(${path(value.slice(start, end), offset + start)} ?? '')`); cursor = end + 1;\n }\n emit(); return parts.join(' + ') || \"''\";\n };\n const visit = (node: DefaultTreeAdapterMap['childNode'], parent: string): void => {\n const at = node.sourceCodeLocation?.startOffset ?? 0;\n if (node.nodeName === '#text') { lines.push(`p.text(${parent}, () => ${interpolation((node as DefaultTreeAdapterMap['textNode']).value, at)});`); return; }\n if (!('tagName' in node)) return;\n if (node.namespaceURI !== 'http://www.w3.org/1999/xhtml' || ['script', 'iframe', 'object', 'embed', 'base', 'meta', 'link', 'style', 'template'].includes(node.tagName)) {\n report('HESH-HTML-002', `Unsupported active/foreign template element <${node.tagName}>`, at, 'Use semantic HTML and declared CSS/JS modules.'); return;\n }\n const id = `node${serial++}`;\n lines.push(`const ${id} = p.element(${parent}, ${JSON.stringify(node.tagName)});`);\n const attributes = Object.fromEntries(node.attrs.map(attr => [attr.name, attr.value]));\n const attrAt = (name: string) => node.sourceCodeLocation?.attrs?.[name]?.startOffset ?? at;\n for (const attr of node.attrs) {\n if (attr.name.startsWith('h-')) continue;\n if (/^on/i.test(attr.name) || ['srcdoc', 'innerhtml', 'outerhtml'].includes(attr.name)) { report('HESH-HTML-003', `Unsafe attribute ${attr.name}`, attrAt(attr.name), 'Use h-action and safe DOM bindings.'); continue; }\n const wholeBinding = attr.value.startsWith('{') && attr.value.endsWith('}') && !attr.value.slice(1, -1).includes('{') && !attr.value.slice(1, -1).includes('}');\n lines.push(`p.attribute(${id}, ${JSON.stringify(attr.name)}, () => ${wholeBinding ? path(attr.value.slice(1, -1), attrAt(attr.name) + 1) : interpolation(attr.value, attrAt(attr.name))});`);\n }\n for (const name of Object.keys(attributes)) if (name.startsWith('h-') && !['h-action', 'h-bind', 'h-value', 'h-destination', 'h-part', 'h-outlet'].includes(name) && !name.startsWith('h-input-')) report('HESH-HTML-004', `Unsupported directive ${name}`, attrAt(name), 'Use supported directives; keyed lists/scoped templates are a later milestone.');\n const content = ['h-bind', 'h-part', 'h-outlet'].filter(name => attributes[name] !== undefined);\n if (content.length > 1 || (content.length && node.childNodes.length)) report('HESH-HTML-005', 'Content directives require an empty container and cannot be combined', at, 'Choose one content directive and remove children.');\n if (attributes['h-part'] !== undefined || attributes['h-outlet'] !== undefined) {\n if (['area','base','br','col','embed','hr','img','input','link','meta','param','source','track','wbr'].includes(node.tagName)) report('HESH-HTML-005', 'Parts and outlets require a container element', at, 'Use div, main, section or another container.');\n if (attributes['h-part'] !== undefined) {\n const name = attributes['h-part'];\n if (!contract.parts?.includes(name)) report('HESH-PART-001', `Undeclared Hesh part ${name}`, at, 'Declare parts and return a Hesh Unit from parts.NAME.');\n lines.push(`p.mountPart(${id}, state, ${JSON.stringify(name)});`);\n } else {\n if (!contract.allowOutlet || attributes['h-outlet'] !== '') report('HESH-PART-002', 'h-outlet is only available on standalone shell screens', at, 'Use an empty h-outlet on the persistent shell.');\n lines.push(`p.unitOutlet(${id});`);\n }\n } else if (attributes['h-bind'] !== undefined) {\n if (node.childNodes.length) report('HESH-BIND-003', 'h-bind cannot also contain children', at, 'Remove the children or use text interpolation.');\n lines.push(`p.text(${id}, () => ${path(attributes['h-bind'], attrAt('h-bind'))});`);\n } else node.childNodes.forEach(child => visit(child, id));\n if (attributes['h-action'] !== undefined) {\n const name = attributes['h-action']; usedActions.add(name);\n if (!contract.actions.includes(name)) report('HESH-ACTION-001', `Missing action ${name}`, attrAt('h-action'), 'Declare and implement the action.');\n lines.push(`p.bindAction(${id}, state, ${JSON.stringify(name)});`);\n }\n if (attributes['h-value'] !== undefined) {\n const name = attributes['h-value'];\n if (!['input', 'textarea', 'select'].includes(node.tagName) || name.includes('.') || ['checkbox', 'radio', 'file'].includes(attributes.type ?? '') || attributes.multiple !== undefined) report('HESH-BIND-004', 'h-value requires a single-value text control and root writable signal', attrAt('h-value'), 'Use a text input/textarea/single select and a declared signal.');\n path(name, attrAt('h-value'), undefined, true);\n lines.push(`p.bindValue(${id}, state.bindings, ${JSON.stringify(name)});`);\n }\n const destination = attributes['h-destination'];\n const inputs = Object.keys(attributes).filter(name => name.startsWith('h-input-'));\n if (destination !== undefined) {\n linked.add(destination);\n const schema = contract.destinations[destination];\n if (!schema) report('HESH-NAV-001', `Unknown destination ${destination}`, attrAt('h-destination'), 'Declare this destination in the application.');\n if (node.tagName !== 'a' || attributes.href !== undefined) report('HESH-NAV-002', 'h-destination requires an anchor without an explicit href', at, 'Use <a h-destination=\"Name\" ...>.');\n for (const key of Object.keys(schema ?? {})) if (attributes[`h-input-${key.toLowerCase()}`] === undefined) report('HESH-NAV-003', `Missing destination input ${key}`, at, `Add h-input-${key} bound to a declared value.`);\n const entries = inputs.map(attr => {\n const key = Object.keys(schema ?? {}).find(key => key.toLowerCase() === attr.slice(8)) ?? attr.slice(8);\n if (!schema || !Object.hasOwn(schema, key)) report('HESH-NAV-003', `Unknown destination input ${key}`, attrAt(attr), 'Use only inputs declared by the destination.');\n return `${JSON.stringify(key)}: ${path(attributes[attr]!, attrAt(attr), schema?.[key])}`;\n });\n lines.push(`p.attribute(${id}, 'href', () => destinations[${JSON.stringify(destination)}].href({${entries.join(',')}}));`);\n } else if (inputs.length) report('HESH-NAV-003', 'h-input-* requires h-destination', at, 'Declare the destination on this anchor.');\n };\n fragment.childNodes.forEach(node => visit(node, 'parent')); lines.push('}');\n for (const name of contract.bindings) if (!usedBindings.has(name)) report('HESH-BIND-005', `Unused binding ${name}`, 0, 'Remove the declaration if it is not needed by this template.', 'warning');\n for (const name of contract.actions) if (!usedActions.has(name)) report('HESH-ACTION-002', `Unused action ${name}`, 0, 'Remove the declaration if it is not needed by this template.', 'warning');\n return { code: lines.join('\\n'), diagnostics, usedBindings: [...usedBindings], usedActions: [...usedActions], destinations: [...linked] };\n}\n"]}
|
|
@@ -215,11 +215,15 @@ export function createArchitectureCompiler() {
|
|
|
215
215
|
error('HESH-ARCH-003', `Unresolved callable implementation ${item.node.name}.${operation.name}`, item, operation.start, 'Return this operation from the declared implementation factory.');
|
|
216
216
|
}
|
|
217
217
|
else
|
|
218
|
-
for (const block of ['bindings', 'actions']) {
|
|
218
|
+
for (const block of ['bindings', 'actions', 'parts']) {
|
|
219
|
+
if (block === 'parts' && !list(item, block).length)
|
|
220
|
+
continue;
|
|
219
221
|
if (!getMember(result, [block]))
|
|
220
222
|
error('HESH-BIND-002', `Presentation factory must return a ${block} object`, item);
|
|
221
|
-
for (const binding of list(item, block,
|
|
223
|
+
for (const binding of list(item, block, block !== 'parts')) {
|
|
222
224
|
const target = getMember(result, [block, binding.name]);
|
|
225
|
+
if (block === 'parts' && !getMember(result, [block, binding.name, 'attach'])?.getCallSignatures().length)
|
|
226
|
+
error('HESH-PART-001', `Part ${binding.name} must be a Hesh Unit`, item, binding.start);
|
|
223
227
|
if (!target || (block === 'actions' && !checker.getSignaturesOfType(target, ts.SignatureKind.Call).length))
|
|
224
228
|
error(block === 'actions' ? 'HESH-ACTION-001' : 'HESH-BIND-002', `Missing ${block} implementation ${binding.name}`, item, binding.start, `Return ${block}.${binding.name} from the presentation factory.`);
|
|
225
229
|
}
|
|
@@ -273,8 +277,13 @@ export function createArchitectureCompiler() {
|
|
|
273
277
|
walk(syntax);
|
|
274
278
|
}
|
|
275
279
|
for (const failure of [...program.getSyntacticDiagnostics(), ...program.getSemanticDiagnostics()])
|
|
276
|
-
if (failure.file && inside(canonical(failure.file.fileName), root))
|
|
277
|
-
|
|
280
|
+
if (failure.file && inside(canonical(failure.file.fileName), root)) {
|
|
281
|
+
// Declared screen modules are produced by this compilation, including on a fresh checkout.
|
|
282
|
+
const missing = failure.code === 2307 && failure.file.text.slice(failure.start, (failure.start ?? 0) + (failure.length ?? 0)).replace(/^['"]|['"]$/g, '');
|
|
283
|
+
const generatedScreen = missing && presentations.some(item => canonical(resolve(dirname(failure.file.fileName), missing)) === canonical(join(outDir, `${item.node.name}.js`)));
|
|
284
|
+
if (!generatedScreen)
|
|
285
|
+
diagnostics.push(diagnostic('HESH-TYPE-001', ts.flattenDiagnosticMessageText(failure.messageText, '\n'), failure.file.fileName, failure.file.text, failure.start ?? 0, 'Correct the implementation type/syntax error.'));
|
|
286
|
+
}
|
|
278
287
|
const schemas = Object.create(null), urls = new Map();
|
|
279
288
|
const graph = { domains: domains.map(d => ({ name: d.node.name, exposes: list(d, 'exposes').map(e => e.name), consumes: list(d, 'consumes').map(e => e.name) })), destinations: [], links: [] };
|
|
280
289
|
const presentationFor = new Map();
|
|
@@ -316,14 +325,14 @@ export function createArchitectureCompiler() {
|
|
|
316
325
|
schemas[item.node.name] = inputs;
|
|
317
326
|
}
|
|
318
327
|
const outputs = {}, htmlModules = new Map();
|
|
319
|
-
for (const item of
|
|
328
|
+
for (const item of presentations) {
|
|
320
329
|
const html = canonical(resolve(dirname(item.file), field(item, 'html'))), stylePath = field(item, 'styles', false);
|
|
321
330
|
if (!isFile(html) || !html.endsWith('.html') || !inside(html, canonical(dirname(item.file)))) {
|
|
322
331
|
error('HESH-HTML-001', `Missing or private presentation HTML ${html}`, item);
|
|
323
332
|
continue;
|
|
324
333
|
}
|
|
325
334
|
const source = read(html), factory = resolvedFactories.get(item);
|
|
326
|
-
const compiled = compileHTML(source, { filename: html, bindings: list(item, 'bindings', true).map(e => e.name), actions: list(item, 'actions', true).map(e => e.name), destinations: schemas,
|
|
335
|
+
const compiled = compileHTML(source, { filename: html, bindings: list(item, 'bindings', true).map(e => e.name), actions: list(item, 'actions', true).map(e => e.name), parts: list(item, 'parts').map(e => e.name), allowOutlet: ![...presentationFor.values()].includes(item), destinations: schemas,
|
|
327
336
|
validateBinding(path, offset, expected, writable) {
|
|
328
337
|
if (!factory)
|
|
329
338
|
return;
|
|
@@ -362,6 +371,7 @@ export function createArchitectureCompiler() {
|
|
|
362
371
|
}
|
|
363
372
|
}
|
|
364
373
|
outputs[output] = css + compiled.code;
|
|
374
|
+
outputs[output.replace(/\.js$/, '.d.ts')] = "import type { PresentationState } from '@heshammesalam/heshjs/presentation';\nexport default function render(parent: Node, state: PresentationState, destinations?: object): void;\n";
|
|
365
375
|
}
|
|
366
376
|
const output = join(outDir, 'app.js'), types = join(outDir, 'app.d.ts');
|
|
367
377
|
const js = ["import { createGraphApplication, createDomainGraph } from '@heshammesalam/heshjs/destinations';"];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/architecture/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,SAAS,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACrG,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACtE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAkD,MAAM,oBAAoB,CAAC;AACtG,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAA+B,MAAM,kBAAkB,CAAC;AAC7F,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,CAAC;AAUzC,MAAM,SAAS,GAAG,CAAC,IAAY,EAAE,EAAE;IACjC,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAAC,MAAM,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC,CAA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;YACjH,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,CAAC,GAAG,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC;QACnG,CAAC,EAAE,CAAC;AACN,CAAC;AACD,MAAM,UAAU,YAAY,CAAC,OAAuB,IAAmB,OAAO,0BAA0B,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AAC5H,MAAM,UAAU,YAAY,CAAC,MAAqB;IAChD,IAAI,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,OAAO,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAC/H,KAAK,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC;QAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,KAAK,MAAM;YAAE,aAAa,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAAC,CAAC;AAC9M,CAAC","sourcesContent":["import ts from 'typescript';\nimport { readFileSync, existsSync, realpathSync, mkdirSync, writeFileSync, statSync } from 'node:fs';\nimport { resolve, dirname, relative, extname, join } from 'node:path';\nimport { parse, HeshError, type Module, type Contract, type ContractEntry } from '../parser/index.js';\nimport { compileHTML } from './html.js';\nimport { diagnostic, formatDiagnostic, type ArchitectureDiagnostic } from './diagnostics.js';\nexport { compileHTML, formatDiagnostic };\nexport type { ArchitectureDiagnostic };\nexport interface ProjectOptions { root: string; entry?: string; tsconfig?: string; outDir?: string }\nexport interface ProjectResult {\n diagnostics: ArchitectureDiagnostic[]; files: string[]; outputs: Record<string, string>;\n graph: { domains: { name: string; exposes: string[]; consumes: string[] }[]; destinations: { name: string; url: string; input: Record<string, string>; owner: string }[]; links: { from: string; to: string }[] };\n statistics: { parsed: number; reused: number };\n}\ninterface Located { node: Contract; file: string; source: string }\ninterface Factory { file: string; name: string; result: ts.Type }\nconst canonical = (file: string) => {\n const path = resolve(file); const real = existsSync(path) ? realpathSync(path) : path;\n return (ts.sys.useCaseSensitiveFileNames ? real : real.toLowerCase()).replace(/\\\\/g, '/');\n};\nconst inside = (file: string, folder: string) => file === folder || file.startsWith(folder + '/');\nconst isFile = (file: string) => existsSync(file) && statSync(file).isFile();\nconst modulePath = (from: string, to: string) => { const path = relative(dirname(from), to).replace(/\\\\/g, '/'); return path.startsWith('.') ? path : './' + path; };\nexport function createArchitectureCompiler() {\n const cache = new Map<string, { source: string; ast: Module }>();\n return { clear() { cache.clear(); }, check(options: ProjectOptions): ProjectResult {\n const root = canonical(options.root), entry = canonical(resolve(root, options.entry ?? 'app.hesh'));\n const outDir = resolve(root, options.outDir ?? '.hesh-generated');\n const diagnostics: ArchitectureDiagnostic[] = [], descriptors = new Map<string, Module>(), declarations = new Map<string, Located>();\n const files = new Set<string>(); let parsed = 0, reused = 0;\n const error = (code: string, message: string, item: Located, position = item.node.start, suggestion = 'Correct the declared contract.') => diagnostics.push(diagnostic(code, message, item.file, item.source, position, suggestion));\n const read = (file: string): string => { files.add(file); return readFileSync(file, 'utf8'); };\n const load = (file: string): void => {\n if (descriptors.has(file)) return;\n if (!inside(file, root) || !isFile(file)) { diagnostics.push(diagnostic('HESH-ARCH-001', 'Missing or out-of-project descriptor', file, '', 0, 'Import an existing .hesh file within the application root.')); return; }\n const source = read(file); let ast: Module;\n try {\n const saved = cache.get(file);\n if (saved?.source === source) { ast = saved.ast; reused++; }\n else { ast = parse(source, file); cache.set(file, { source, ast }); parsed++; }\n } catch (failure) {\n diagnostics.push(diagnostic('HESH-SYNTAX-001', failure instanceof Error ? failure.message : String(failure), file, source, failure instanceof HeshError ? failure.offset : 0, 'Fix the Hesh declaration syntax.')); return;\n }\n descriptors.set(file, ast);\n if (ast.views.length) diagnostics.push(diagnostic('HESH-ARCH-001', 'Architecture descriptor files cannot also contain view implementations', file, source, ast.views[0]!.start, 'Keep existing .hesh views in separate component files.'));\n for (const node of ast.contracts ?? []) {\n const item = { node, file, source };\n if (declarations.has(node.name)) error('HESH-ARCH-002', `Duplicate declaration ${node.name}`, item);\n else declarations.set(node.name, item);\n }\n for (const item of ast.imports) {\n const syntax = ts.createSourceFile(file, item.source, ts.ScriptTarget.Latest, true, ts.ScriptKind.JS);\n const statement = syntax.statements[0];\n if (!statement || !ts.isImportDeclaration(statement) || !ts.isStringLiteral(statement.moduleSpecifier) || statement.importClause || !statement.moduleSpecifier.text.endsWith('.hesh')) {\n diagnostics.push(diagnostic('HESH-ARCH-001', 'Architecture imports must be side-effect imports of .hesh descriptors', file, source, item.start, 'Use import \"./domains/inventory/domain.hesh\";.')); continue;\n }\n load(canonical(resolve(dirname(file), statement.moduleSpecifier.text)));\n }\n };\n load(entry);\n const all = [...declarations.values()];\n const applications = all.filter(d => d.node.kind === 'application');\n const app = applications[0];\n if (applications.length !== 1) diagnostics.push(diagnostic('HESH-ARCH-001', 'Exactly one application declaration is required', entry, descriptors.get(entry)?.source ?? '', 0, 'Declare one application listing domains and destinations.'));\n const select = (kind: Contract['kind'], names: ContractEntry[] | undefined) => (names ?? []).flatMap(name => {\n const target = declarations.get(name.name);\n if (!target || target.node.kind !== kind) { if (app) error('HESH-ARCH-003', `Missing ${kind} ${name.name}`, app, name.start); return []; }\n return [target];\n });\n const domains = select('domain', app?.node.blocks.domains), destinations = select('destination', app?.node.blocks.destinations);\n const presentations = all.filter(d => d.node.kind === 'presentation');\n const declaredDomains = all.filter(d => d.node.kind === 'domain');\n const owner = (file: string): Located | undefined => declaredDomains.filter(d => inside(file, canonical(dirname(d.file)))).sort((a, b) => dirname(b.file).length - dirname(a.file).length)[0];\n const field = (item: Located, name: string, required = true) => {\n const value = item.node.fields[name]?.value;\n if (required && !value) error('HESH-ARCH-003', `Missing field ${name} in ${item.node.name}`, item);\n return value ?? '';\n };\n const list = (item: Located, name: string, required = false): ContractEntry[] => {\n if (required && !item.node.blocks[name]) error('HESH-ARCH-003', `Missing block ${name}`, item);\n return item.node.blocks[name] ?? [];\n };\n if (app) { list(app, 'domains', true); list(app, 'destinations', true); }\n const factories = new Map<Located, { file: string; name: string }>();\n for (const item of [...domains, ...presentations]) {\n const specifier = field(item, item.node.kind === 'domain' ? 'implementation' : 'logic');\n const hash = specifier.lastIndexOf('#'), path = specifier.slice(0, hash), name = specifier.slice(hash + 1);\n if (hash < 1 || !/^[$_\\p{ID_Start}][$_\\u200c\\u200d\\p{ID_Continue}]*$/u.test(name) || !path.startsWith('.') || !['.js', '.ts', '.mjs'].includes(extname(path)) || path.endsWith('.d.ts')) { error('HESH-ARCH-003', `Invalid implementation reference ${specifier}`, item, item.node.start, 'Use ./module.js#exportName (or .ts/.mjs).'); continue; }\n const file = canonical(resolve(dirname(item.file), path));\n if (!existsSync(file) || !inside(file, root) || owner(file) !== owner(item.file)) { error('HESH-ARCH-004', `Implementation must exist inside its owning domain: ${specifier}`, item); continue; }\n factories.set(item, { file, name }); files.add(file);\n }\n const byDomain = new Map(domains.map(item => [item.node.name, item]));\n for (const item of declaredDomains) if (declaredDomains.some(other => other !== item && dirname(other.file) === dirname(item.file))) error('HESH-ARCH-002', 'Each domain needs its own directory boundary', item);\n const edges = new Map<string, string[]>();\n for (const item of domains) {\n const exposes = list(item, 'exposes', true).map(v => v.name);\n if (!exposes.length) error('HESH-ARCH-003', `Domain ${item.node.name} must expose at least one operation`, item);\n for (const name of exposes) if (exposes.some(other => other !== name && other.startsWith(name + '.'))) error('HESH-ARCH-003', `Overlapping public operation ${name}`, item);\n const dependencies: string[] = [];\n for (const consume of list(item, 'consumes')) {\n const [provider, ...path] = consume.name.split('.'), target = byDomain.get(provider!);\n if (!target || !path.length || !list(target, 'exposes').some(v => v.name === path.join('.'))) error('HESH-ARCH-003', `Unresolved consumed operation ${consume.name}`, item, consume.start, 'Consume an operation explicitly exposed by a selected domain.');\n dependencies.push(provider!);\n }\n for (const policy of list(item, 'access')) if (!exposes.includes(policy.name)) error('HESH-ARCH-003', `Access policy refers to unexposed operation ${policy.name}`, item, policy.start);\n edges.set(item.node.name, dependencies);\n }\n const visited = new Set<string>(), visiting: string[] = [];\n const visit = (name: string) => {\n if (visiting.includes(name)) { const item = byDomain.get(name); if (item) error('HESH-ARCH-005', `Circular dependency: ${[...visiting, name].join(' -> ')}`, item, item.node.start, 'Remove the cycle or extract an explicit shared contract.'); return; }\n if (visited.has(name)) return;\n visiting.push(name); for (const next of edges.get(name) ?? []) visit(next); visiting.pop(); visited.add(name);\n };\n for (const name of byDomain.keys()) visit(name);\n let settings: ts.CompilerOptions = { target: ts.ScriptTarget.ES2022, module: ts.ModuleKind.ESNext, moduleResolution: ts.ModuleResolutionKind.Bundler, allowJs: true, checkJs: true, noEmit: true, skipLibCheck: true, allowImportingTsExtensions: true, types: [] };\n if (options.tsconfig) {\n const configFile = resolve(root, options.tsconfig), config = ts.readConfigFile(configFile, ts.sys.readFile);\n if (config.error) diagnostics.push(diagnostic('HESH-ARCH-001', ts.flattenDiagnosticMessageText(config.error.messageText, '\\n'), configFile, '', 0, 'Correct the TypeScript project configuration.'));\n else settings = { ...settings, ...ts.parseJsonConfigFileContent(config.config, ts.sys, dirname(configFile)).options, noEmit: true, allowJs: true, checkJs: true };\n }\n const program = ts.createProgram([...factories.values()].map(f => f.file), settings);\n const checker = program.getTypeChecker();\n const resolvedFactories = new Map<Located, Factory>();\n const getMember = (type: ts.Type, path: string[], unwrap = false): ts.Type | undefined => {\n let current = type;\n const unwrapped = (value: ts.Type): ts.Type => {\n const get = checker.getPropertyOfType(value, 'get');\n const callable = get ? checker.getTypeOfSymbolAtLocation(get, get.valueDeclaration ?? program.getSourceFiles()[0]!) : value;\n return checker.getSignaturesOfType(callable, ts.SignatureKind.Call)[0]?.getReturnType() ?? value;\n };\n for (const piece of path) {\n if (unwrap) current = unwrapped(current);\n if (current.flags & ts.TypeFlags.Any) return current;\n const symbol = checker.getPropertyOfType(current, piece); if (!symbol) return;\n current = checker.getTypeOfSymbolAtLocation(symbol, symbol.valueDeclaration ?? program.getSourceFiles()[0]!);\n }\n return unwrap ? unwrapped(current) : current;\n };\n for (const [item, reference] of factories) {\n const sourceFile = program.getSourceFile(reference.file);\n const symbol = sourceFile && checker.getSymbolAtLocation(sourceFile);\n let exported = symbol && checker.getExportsOfModule(symbol).find(v => v.name === reference.name);\n if (exported?.flags && exported.flags & ts.SymbolFlags.Alias) exported = checker.getAliasedSymbol(exported);\n const type = exported && checker.getTypeOfSymbolAtLocation(exported, exported.valueDeclaration ?? sourceFile!);\n const signature = type && checker.getSignaturesOfType(type, ts.SignatureKind.Call)[0];\n if (!signature) { error('HESH-ARCH-003', `Missing callable export ${reference.name} in ${reference.file}`, item); continue; }\n const result = signature.getReturnType();\n if (result.flags & (ts.TypeFlags.Any | ts.TypeFlags.Unknown) || checker.getPropertyOfType(result, 'then')) { error('HESH-ARCH-003', `Factory ${reference.name} must return a statically inspectable synchronous object`, item); continue; }\n resolvedFactories.set(item, { ...reference, result });\n if (item.node.kind === 'domain') for (const operation of list(item, 'exposes')) {\n const target = getMember(result, operation.name.split('.'));\n if (!target || !checker.getSignaturesOfType(target, ts.SignatureKind.Call).length) error('HESH-ARCH-003', `Unresolved callable implementation ${item.node.name}.${operation.name}`, item, operation.start, 'Return this operation from the declared implementation factory.');\n }\n else for (const block of ['bindings', 'actions']) {\n if (!getMember(result, [block])) error('HESH-BIND-002', `Presentation factory must return a ${block} object`, item);\n for (const binding of list(item, block, true)) {\n const target = getMember(result, [block, binding.name]);\n if (!target || (block === 'actions' && !checker.getSignaturesOfType(target, ts.SignatureKind.Call).length)) error(block === 'actions' ? 'HESH-ACTION-001' : 'HESH-BIND-002', `Missing ${block} implementation ${binding.name}`, item, binding.start, `Return ${block}.${binding.name} from the presentation factory.`);\n }\n }\n }\n // Validate actual imports/re-exports, including aliases and files shared by domains.\n const sources = ts.sys.readDirectory(root, ['.ts', '.js', '.mjs'], ['**/node_modules/**', '**/dist/**', '**/.hesh-generated/**'], ['**/*']);\n for (const path of sources) {\n const file = canonical(path); if (inside(file, canonical(outDir))) continue;\n files.add(file); const source = read(file), syntax = ts.createSourceFile(file, source, ts.ScriptTarget.Latest, true, file.endsWith('.ts') ? ts.ScriptKind.TS : ts.ScriptKind.JS);\n const checkImport = (specifier: ts.Node | undefined): void => {\n if (!specifier) return;\n if (!ts.isStringLiteralLike(specifier)) { diagnostics.push(diagnostic('HESH-ARCH-007', 'Computed module imports cannot be architecture-validated', file, source, specifier.getStart(syntax), 'Use literal imports and explicit injected dependencies.')); return; }\n if (specifier.text.startsWith('node:') || ['fs', 'path', 'child_process', 'worker_threads', 'net', 'tls', 'http', 'https', 'os', 'module'].includes(specifier.text)) {\n diagnostics.push(diagnostic('HESH-SEC-001', `Node/server-only import in client code: ${specifier.text}`, file, source, specifier.getStart(syntax), 'Call server infrastructure through an API rather than bundling it.')); return;\n }\n const target = ts.resolveModuleName(specifier.text, file, settings, ts.sys).resolvedModule?.resolvedFileName;\n const generated = canonical(resolve(dirname(file), specifier.text));\n if (inside(generated, canonical(outDir))) return;\n if (!target) { if (!specifier.text.endsWith('.css') && !specifier.text.endsWith('.hesh')) diagnostics.push(diagnostic('HESH-ARCH-006', `Unresolved module ${specifier.text}`, file, source, specifier.getStart(syntax), 'Fix the path or supply the correct tsconfig alias.')); return; }\n const targetFile = canonical(target); files.add(targetFile);\n if (/(?:^|\\/)server(?:\\/|$)|\\.server\\.[cm]?[jt]s$/.test(targetFile)) diagnostics.push(diagnostic('HESH-SEC-001', `Server-only module in client graph: ${specifier.text}`, file, source, specifier.getStart(syntax), 'Move server calls behind a server API; never import server-only code into the browser.'));\n const targetDomain = owner(targetFile), sourceDomain = owner(file);\n if (targetDomain && targetDomain !== sourceDomain) diagnostics.push(diagnostic('HESH-ARCH-004', `Illegal cross-domain dependency. Source domain: ${sourceDomain?.node.name ?? 'shared/application'}. Target domain: ${targetDomain.node.name}. The imported module is private.`, file, source, specifier.getStart(syntax), `Use an explicitly exposed ${targetDomain.node.name} operation through declared dependency injection.`));\n };\n const walk = (node: ts.Node): void => {\n if (ts.isImportDeclaration(node) || ts.isExportDeclaration(node)) checkImport(node.moduleSpecifier);\n else if (ts.isImportTypeNode(node) && ts.isLiteralTypeNode(node.argument)) checkImport(node.argument.literal);\n else if (ts.isCallExpression(node) && (node.expression.kind === ts.SyntaxKind.ImportKeyword || (ts.isIdentifier(node.expression) && node.expression.text === 'require'))) checkImport(node.arguments[0]);\n ts.forEachChild(node, walk);\n };\n walk(syntax);\n }\n for (const failure of [...program.getSyntacticDiagnostics(), ...program.getSemanticDiagnostics()]) if (failure.file && inside(canonical(failure.file.fileName), root)) diagnostics.push(diagnostic('HESH-TYPE-001', ts.flattenDiagnosticMessageText(failure.messageText, '\\n'), failure.file.fileName, failure.file.text, failure.start ?? 0, 'Correct the implementation type/syntax error.'));\n const schemas: Record<string, Record<string, string>> = Object.create(null), urls = new Map<string, Located>();\n const graph: ProjectResult['graph'] = { domains: domains.map(d => ({ name: d.node.name, exposes: list(d, 'exposes').map(e => e.name), consumes: list(d, 'consumes').map(e => e.name) })), destinations: [], links: [] };\n const presentationFor = new Map<Located, Located>();\n for (const item of destinations) {\n const url = field(item, 'url'), inputs = Object.fromEntries(list(item, 'input', true).map(e => [e.name, e.value ?? '']));\n const segments = url.split('/').filter(Boolean), params = segments.filter(p => p.startsWith(':')).map(p => p.slice(1));\n if (!url.startsWith('/') || url.startsWith('//') || /[?#*%]/.test(url) || new Set(params).size !== params.length || params.some(p => !Object.hasOwn(inputs, p)) || Object.keys(inputs).some(p => !params.includes(p))) error('HESH-NAV-003', `URL/input mismatch for ${item.node.name}`, item, item.node.start, 'Use an absolute URL whose :params exactly match the input block; use plain static segments.');\n for (const input of list(item, 'input')) if (!['string', 'number', 'boolean'].includes(input.value ?? '') || input.name.includes('.')) error('HESH-NAV-003', `Invalid input schema ${input.name}`, item, input.start);\n for (const key of Object.keys(inputs)) if (!/^[A-Za-z_][A-Za-z\\d_]*$/.test(key)) error('HESH-NAV-003', `Unsupported URL parameter name ${key}`, item, item.node.start, 'Use ASCII letters/digits/underscore with a letter or underscore first.');\n if (new Set(Object.keys(inputs).map(key => key.toLowerCase())).size !== Object.keys(inputs).length) error('HESH-NAV-003', 'Destination input names must be unique ignoring case for HTML attributes', item);\n const signature = segments.map(p => p.startsWith(':') ? ':' : p).join('/');\n if (urls.has(signature)) error('HESH-NAV-004', `Conflicting destination URL ${url}`, item); else urls.set(signature, item);\n for (const previous of destinations.slice(0, destinations.indexOf(item))) {\n const other = (previous.node.fields.url?.value ?? '').split('/').filter(Boolean);\n if (other.length === segments.length && other.every((part, index) => part === segments[index] || part.startsWith(':') || segments[index]!.startsWith(':'))) error('HESH-NAV-004', `Overlapping destination URLs: ${url} and ${previous.node.fields.url?.value}`, item, item.node.start, 'Use non-overlapping addresses so destination input always resolves to the declared screen.');\n }\n const presentation = declarations.get(field(item, 'presentation'));\n if (!presentation || presentation.node.kind !== 'presentation') error('HESH-NAV-001', `Missing presentation for ${item.node.name}`, item);\n else {\n const own = owner(presentation.file);\n if (!own || !byDomain.has(own.node.name) || owner(item.file) !== own) error('HESH-ARCH-004', 'Destination and presentation must belong to the same selected domain', item);\n else { presentationFor.set(item, presentation); graph.destinations.push({ name: item.node.name, url, input: inputs, owner: own.node.name }); }\n }\n schemas[item.node.name] = inputs;\n }\n const outputs: Record<string, string> = {}, htmlModules = new Map<Located, string>();\n for (const item of new Set(presentationFor.values())) {\n const html = canonical(resolve(dirname(item.file), field(item, 'html'))), stylePath = field(item, 'styles', false);\n if (!isFile(html) || !html.endsWith('.html') || !inside(html, canonical(dirname(item.file)))) { error('HESH-HTML-001', `Missing or private presentation HTML ${html}`, item); continue; }\n const source = read(html), factory = resolvedFactories.get(item);\n const compiled = compileHTML(source, { filename: html, bindings: list(item, 'bindings', true).map(e => e.name), actions: list(item, 'actions', true).map(e => e.name), destinations: schemas,\n validateBinding(path, offset, expected, writable) {\n if (!factory) return;\n const type = getMember(factory.result, ['bindings', ...path.split('.')], true);\n if (type && type.flags & ts.TypeFlags.Any) diagnostics.push(diagnostic('HESH-TYPE-002', `Binding ${path} has a dynamic any type; its nested shape/input type cannot be proven`, html, source, offset, 'Add JSDoc or a TypeScript type if static checking is required; runtime destination validation still applies.', 'warning'));\n if (!type) diagnostics.push(diagnostic('HESH-BIND-002', `Missing nested data path ${path}`, html, source, offset, 'Return this field in the declared bindings.'));\n if (writable) {\n const raw = getMember(factory.result, ['bindings', path]);\n if (!raw || !checker.getPropertyOfType(raw, 'set')) diagnostics.push(diagnostic('HESH-BIND-004', `Binding ${path} is not writable`, html, source, offset, 'Use a writable signal for h-value.'));\n }\n if (expected && type && !(type.flags & ts.TypeFlags.Any)) {\n const actual = type.flags & ts.TypeFlags.StringLike ? 'string' : type.flags & ts.TypeFlags.NumberLike ? 'number' : type.flags & ts.TypeFlags.BooleanLike ? 'boolean' : 'object/unknown';\n if (actual !== expected) diagnostics.push(diagnostic('HESH-NAV-003', `Destination binding ${path} is ${actual}, expected ${expected}`, html, source, offset, 'Bind a value of the destination input type.'));\n }\n }\n });\n diagnostics.push(...compiled.diagnostics);\n for (const [destination, screen] of presentationFor) if (screen === item) for (const target of compiled.destinations) graph.links.push({ from: destination.node.name, to: target });\n const output = join(outDir, `${item.node.name}.js`); htmlModules.set(item, output);\n let css = '';\n if (stylePath) {\n const style = canonical(resolve(dirname(item.file), stylePath));\n if (!isFile(style) || !style.endsWith('.css') || !inside(style, canonical(dirname(item.file)))) error('HESH-HTML-001', `Missing/private CSS resource ${stylePath}`, item);\n else { files.add(style); css = `import ${JSON.stringify(modulePath(output, style))};\\n`; }\n }\n outputs[output] = css + compiled.code;\n }\n const output = join(outDir, 'app.js'), types = join(outDir, 'app.d.ts');\n const js = [\"import { createGraphApplication, createDomainGraph } from '@heshammesalam/heshjs/destinations';\"];\n const domainValues: string[] = [], pageValues: string[] = [], typeImports: string[] = [], domainTypes: string[] = [];\n let index = 0;\n for (const item of domains) {\n const factory = resolvedFactories.get(item); if (!factory) continue;\n const alias = `factory${index++}`, spec = modulePath(output, factory.file);\n js.push(`import { ${factory.name} as ${alias} } from ${JSON.stringify(spec)};`);\n typeImports.push(`import { ${factory.name} as ${alias} } from ${JSON.stringify(spec)};`);\n const operations = list(item, 'exposes').map(e => e.name);\n domainValues.push(`{name:${JSON.stringify(item.node.name)}, factory:${alias}, exposes:${JSON.stringify(operations)}, consumes:${JSON.stringify(list(item, 'consumes').map(e => e.name))}, access:${JSON.stringify(Object.fromEntries(list(item, 'access').map(e => [e.name, e.value])))}}`);\n const tree: Record<string, unknown> = {};\n for (const operation of operations) { let node = tree; const parts = operation.split('.'); parts.forEach((part, i) => { if (i === parts.length - 1) node[part] = `ReturnType<typeof ${alias}>${parts.map(p => `[${JSON.stringify(p)}]`).join('')}`; else node = (node[part] ??= {}) as Record<string, unknown>; }); }\n const typeTree = (value: Record<string, unknown>): string => '{' + Object.entries(value).map(([key, value]) => `readonly ${JSON.stringify(key)}:${typeof value === 'string' ? value : typeTree(value as Record<string, unknown>)}`).join(';') + '}';\n domainTypes.push(`${JSON.stringify(item.node.name)}:${typeTree(tree)}`);\n }\n for (const item of destinations) {\n const presentation = presentationFor.get(item), factory = presentation && resolvedFactories.get(presentation), html = presentation && htmlModules.get(presentation);\n const data = graph.destinations.find(d => d.name === item.node.name);\n if (!presentation || !factory || !html || !data) continue;\n pageValues.push(`{...${JSON.stringify({ ...data, access: item.node.fields.access?.value })}, load:async()=>{const [logic,template]=await Promise.all([import(${JSON.stringify(modulePath(output, factory.file))}),import(${JSON.stringify(modulePath(output, html))})]);return {create:logic[${JSON.stringify(factory.name)}],view:template.default};}}`);\n }\n js.push(`const domains = [${domainValues.join(',\\n')}];`, `const pages = [${pageValues.join(',\\n')}];`, 'export const metadata = ' + JSON.stringify(graph) + ';', 'export const createDomains = (options = {}) => createDomainGraph(domains, options);', 'export const createApplication = (options = {}) => createGraphApplication(domains, pages, options);');\n const destinationTypes = graph.destinations.map(d => `${JSON.stringify(d.name)}: Destination<${Object.keys(d.input).length ? '{' + Object.entries(d.input).map(([key, type]) => `${JSON.stringify(key)}:${type}`).join(';') + '}' : 'Record<string, never>'}>`);\n outputs[output] = js.join('\\n');\n outputs[types] = [\"import type { Destination, GraphApplication, ApplicationOptions, DomainGraph } from '@heshammesalam/heshjs/destinations';\", ...typeImports, `export interface DomainAPIs {${domainTypes.join(';')}}`, `export interface Destinations {${destinationTypes.join(';')}}`, 'export declare function createDomains(options?: ApplicationOptions): DomainGraph<DomainAPIs>;', 'export declare function createApplication(options?: ApplicationOptions): GraphApplication<Destinations, DomainAPIs>;', 'export declare const metadata: unknown;'].join('\\n');\n if (diagnostics.some(d => d.severity === 'error')) for (const name of Object.keys(outputs)) delete outputs[name];\n return { diagnostics, files: [...files].sort(), outputs, graph, statistics: { parsed, reused } };\n } };\n}\nexport function checkProject(options: ProjectOptions): ProjectResult { return createArchitectureCompiler().check(options); }\nexport function writeProject(result: ProjectResult): void {\n if (result.diagnostics.some(d => d.severity === 'error')) throw new Error(result.diagnostics.map(formatDiagnostic).join('\\n'));\n for (const [file, source] of Object.entries(result.outputs)) { mkdirSync(dirname(file), { recursive: true }); if (!existsSync(file) || readFileSync(file, 'utf8') !== source) writeFileSync(file, source); }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/architecture/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,SAAS,EAAE,aAAa,EAAE,QAAQ,EAAE,MAA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AO,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC;QAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,KAAK,MAAM;YAAE,aAAa,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAAC,CAAC;AAC9M,CAAC","sourcesContent":["import ts from 'typescript';\nimport { readFileSync, existsSync, realpathSync, mkdirSync, writeFileSync, statSync } from 'node:fs';\nimport { resolve, dirname, relative, extname, join } from 'node:path';\nimport { parse, HeshError, type Module, type Contract, type ContractEntry } from '../parser/index.js';\nimport { compileHTML } from './html.js';\nimport { diagnostic, formatDiagnostic, type ArchitectureDiagnostic } from './diagnostics.js';\nexport { compileHTML, formatDiagnostic };\nexport type { ArchitectureDiagnostic };\nexport interface ProjectOptions { root: string; entry?: string; tsconfig?: string; outDir?: string }\nexport interface ProjectResult {\n diagnostics: ArchitectureDiagnostic[]; files: string[]; outputs: Record<string, string>;\n graph: { domains: { name: string; exposes: string[]; consumes: string[] }[]; destinations: { name: string; url: string; input: Record<string, string>; owner: string }[]; links: { from: string; to: string }[] };\n statistics: { parsed: number; reused: number };\n}\ninterface Located { node: Contract; file: string; source: string }\ninterface Factory { file: string; name: string; result: ts.Type }\nconst canonical = (file: string) => {\n const path = resolve(file); const real = existsSync(path) ? realpathSync(path) : path;\n return (ts.sys.useCaseSensitiveFileNames ? real : real.toLowerCase()).replace(/\\\\/g, '/');\n};\nconst inside = (file: string, folder: string) => file === folder || file.startsWith(folder + '/');\nconst isFile = (file: string) => existsSync(file) && statSync(file).isFile();\nconst modulePath = (from: string, to: string) => { const path = relative(dirname(from), to).replace(/\\\\/g, '/'); return path.startsWith('.') ? path : './' + path; };\nexport function createArchitectureCompiler() {\n const cache = new Map<string, { source: string; ast: Module }>();\n return { clear() { cache.clear(); }, check(options: ProjectOptions): ProjectResult {\n const root = canonical(options.root), entry = canonical(resolve(root, options.entry ?? 'app.hesh'));\n const outDir = resolve(root, options.outDir ?? '.hesh-generated');\n const diagnostics: ArchitectureDiagnostic[] = [], descriptors = new Map<string, Module>(), declarations = new Map<string, Located>();\n const files = new Set<string>(); let parsed = 0, reused = 0;\n const error = (code: string, message: string, item: Located, position = item.node.start, suggestion = 'Correct the declared contract.') => diagnostics.push(diagnostic(code, message, item.file, item.source, position, suggestion));\n const read = (file: string): string => { files.add(file); return readFileSync(file, 'utf8'); };\n const load = (file: string): void => {\n if (descriptors.has(file)) return;\n if (!inside(file, root) || !isFile(file)) { diagnostics.push(diagnostic('HESH-ARCH-001', 'Missing or out-of-project descriptor', file, '', 0, 'Import an existing .hesh file within the application root.')); return; }\n const source = read(file); let ast: Module;\n try {\n const saved = cache.get(file);\n if (saved?.source === source) { ast = saved.ast; reused++; }\n else { ast = parse(source, file); cache.set(file, { source, ast }); parsed++; }\n } catch (failure) {\n diagnostics.push(diagnostic('HESH-SYNTAX-001', failure instanceof Error ? failure.message : String(failure), file, source, failure instanceof HeshError ? failure.offset : 0, 'Fix the Hesh declaration syntax.')); return;\n }\n descriptors.set(file, ast);\n if (ast.views.length) diagnostics.push(diagnostic('HESH-ARCH-001', 'Architecture descriptor files cannot also contain view implementations', file, source, ast.views[0]!.start, 'Keep existing .hesh views in separate component files.'));\n for (const node of ast.contracts ?? []) {\n const item = { node, file, source };\n if (declarations.has(node.name)) error('HESH-ARCH-002', `Duplicate declaration ${node.name}`, item);\n else declarations.set(node.name, item);\n }\n for (const item of ast.imports) {\n const syntax = ts.createSourceFile(file, item.source, ts.ScriptTarget.Latest, true, ts.ScriptKind.JS);\n const statement = syntax.statements[0];\n if (!statement || !ts.isImportDeclaration(statement) || !ts.isStringLiteral(statement.moduleSpecifier) || statement.importClause || !statement.moduleSpecifier.text.endsWith('.hesh')) {\n diagnostics.push(diagnostic('HESH-ARCH-001', 'Architecture imports must be side-effect imports of .hesh descriptors', file, source, item.start, 'Use import \"./domains/inventory/domain.hesh\";.')); continue;\n }\n load(canonical(resolve(dirname(file), statement.moduleSpecifier.text)));\n }\n };\n load(entry);\n const all = [...declarations.values()];\n const applications = all.filter(d => d.node.kind === 'application');\n const app = applications[0];\n if (applications.length !== 1) diagnostics.push(diagnostic('HESH-ARCH-001', 'Exactly one application declaration is required', entry, descriptors.get(entry)?.source ?? '', 0, 'Declare one application listing domains and destinations.'));\n const select = (kind: Contract['kind'], names: ContractEntry[] | undefined) => (names ?? []).flatMap(name => {\n const target = declarations.get(name.name);\n if (!target || target.node.kind !== kind) { if (app) error('HESH-ARCH-003', `Missing ${kind} ${name.name}`, app, name.start); return []; }\n return [target];\n });\n const domains = select('domain', app?.node.blocks.domains), destinations = select('destination', app?.node.blocks.destinations);\n const presentations = all.filter(d => d.node.kind === 'presentation');\n const declaredDomains = all.filter(d => d.node.kind === 'domain');\n const owner = (file: string): Located | undefined => declaredDomains.filter(d => inside(file, canonical(dirname(d.file)))).sort((a, b) => dirname(b.file).length - dirname(a.file).length)[0];\n const field = (item: Located, name: string, required = true) => {\n const value = item.node.fields[name]?.value;\n if (required && !value) error('HESH-ARCH-003', `Missing field ${name} in ${item.node.name}`, item);\n return value ?? '';\n };\n const list = (item: Located, name: string, required = false): ContractEntry[] => {\n if (required && !item.node.blocks[name]) error('HESH-ARCH-003', `Missing block ${name}`, item);\n return item.node.blocks[name] ?? [];\n };\n if (app) { list(app, 'domains', true); list(app, 'destinations', true); }\n const factories = new Map<Located, { file: string; name: string }>();\n for (const item of [...domains, ...presentations]) {\n const specifier = field(item, item.node.kind === 'domain' ? 'implementation' : 'logic');\n const hash = specifier.lastIndexOf('#'), path = specifier.slice(0, hash), name = specifier.slice(hash + 1);\n if (hash < 1 || !/^[$_\\p{ID_Start}][$_\\u200c\\u200d\\p{ID_Continue}]*$/u.test(name) || !path.startsWith('.') || !['.js', '.ts', '.mjs'].includes(extname(path)) || path.endsWith('.d.ts')) { error('HESH-ARCH-003', `Invalid implementation reference ${specifier}`, item, item.node.start, 'Use ./module.js#exportName (or .ts/.mjs).'); continue; }\n const file = canonical(resolve(dirname(item.file), path));\n if (!existsSync(file) || !inside(file, root) || owner(file) !== owner(item.file)) { error('HESH-ARCH-004', `Implementation must exist inside its owning domain: ${specifier}`, item); continue; }\n factories.set(item, { file, name }); files.add(file);\n }\n const byDomain = new Map(domains.map(item => [item.node.name, item]));\n for (const item of declaredDomains) if (declaredDomains.some(other => other !== item && dirname(other.file) === dirname(item.file))) error('HESH-ARCH-002', 'Each domain needs its own directory boundary', item);\n const edges = new Map<string, string[]>();\n for (const item of domains) {\n const exposes = list(item, 'exposes', true).map(v => v.name);\n if (!exposes.length) error('HESH-ARCH-003', `Domain ${item.node.name} must expose at least one operation`, item);\n for (const name of exposes) if (exposes.some(other => other !== name && other.startsWith(name + '.'))) error('HESH-ARCH-003', `Overlapping public operation ${name}`, item);\n const dependencies: string[] = [];\n for (const consume of list(item, 'consumes')) {\n const [provider, ...path] = consume.name.split('.'), target = byDomain.get(provider!);\n if (!target || !path.length || !list(target, 'exposes').some(v => v.name === path.join('.'))) error('HESH-ARCH-003', `Unresolved consumed operation ${consume.name}`, item, consume.start, 'Consume an operation explicitly exposed by a selected domain.');\n dependencies.push(provider!);\n }\n for (const policy of list(item, 'access')) if (!exposes.includes(policy.name)) error('HESH-ARCH-003', `Access policy refers to unexposed operation ${policy.name}`, item, policy.start);\n edges.set(item.node.name, dependencies);\n }\n const visited = new Set<string>(), visiting: string[] = [];\n const visit = (name: string) => {\n if (visiting.includes(name)) { const item = byDomain.get(name); if (item) error('HESH-ARCH-005', `Circular dependency: ${[...visiting, name].join(' -> ')}`, item, item.node.start, 'Remove the cycle or extract an explicit shared contract.'); return; }\n if (visited.has(name)) return;\n visiting.push(name); for (const next of edges.get(name) ?? []) visit(next); visiting.pop(); visited.add(name);\n };\n for (const name of byDomain.keys()) visit(name);\n let settings: ts.CompilerOptions = { target: ts.ScriptTarget.ES2022, module: ts.ModuleKind.ESNext, moduleResolution: ts.ModuleResolutionKind.Bundler, allowJs: true, checkJs: true, noEmit: true, skipLibCheck: true, allowImportingTsExtensions: true, types: [] };\n if (options.tsconfig) {\n const configFile = resolve(root, options.tsconfig), config = ts.readConfigFile(configFile, ts.sys.readFile);\n if (config.error) diagnostics.push(diagnostic('HESH-ARCH-001', ts.flattenDiagnosticMessageText(config.error.messageText, '\\n'), configFile, '', 0, 'Correct the TypeScript project configuration.'));\n else settings = { ...settings, ...ts.parseJsonConfigFileContent(config.config, ts.sys, dirname(configFile)).options, noEmit: true, allowJs: true, checkJs: true };\n }\n const program = ts.createProgram([...factories.values()].map(f => f.file), settings);\n const checker = program.getTypeChecker();\n const resolvedFactories = new Map<Located, Factory>();\n const getMember = (type: ts.Type, path: string[], unwrap = false): ts.Type | undefined => {\n let current = type;\n const unwrapped = (value: ts.Type): ts.Type => {\n const get = checker.getPropertyOfType(value, 'get');\n const callable = get ? checker.getTypeOfSymbolAtLocation(get, get.valueDeclaration ?? program.getSourceFiles()[0]!) : value;\n return checker.getSignaturesOfType(callable, ts.SignatureKind.Call)[0]?.getReturnType() ?? value;\n };\n for (const piece of path) {\n if (unwrap) current = unwrapped(current);\n if (current.flags & ts.TypeFlags.Any) return current;\n const symbol = checker.getPropertyOfType(current, piece); if (!symbol) return;\n current = checker.getTypeOfSymbolAtLocation(symbol, symbol.valueDeclaration ?? program.getSourceFiles()[0]!);\n }\n return unwrap ? unwrapped(current) : current;\n };\n for (const [item, reference] of factories) {\n const sourceFile = program.getSourceFile(reference.file);\n const symbol = sourceFile && checker.getSymbolAtLocation(sourceFile);\n let exported = symbol && checker.getExportsOfModule(symbol).find(v => v.name === reference.name);\n if (exported?.flags && exported.flags & ts.SymbolFlags.Alias) exported = checker.getAliasedSymbol(exported);\n const type = exported && checker.getTypeOfSymbolAtLocation(exported, exported.valueDeclaration ?? sourceFile!);\n const signature = type && checker.getSignaturesOfType(type, ts.SignatureKind.Call)[0];\n if (!signature) { error('HESH-ARCH-003', `Missing callable export ${reference.name} in ${reference.file}`, item); continue; }\n const result = signature.getReturnType();\n if (result.flags & (ts.TypeFlags.Any | ts.TypeFlags.Unknown) || checker.getPropertyOfType(result, 'then')) { error('HESH-ARCH-003', `Factory ${reference.name} must return a statically inspectable synchronous object`, item); continue; }\n resolvedFactories.set(item, { ...reference, result });\n if (item.node.kind === 'domain') for (const operation of list(item, 'exposes')) {\n const target = getMember(result, operation.name.split('.'));\n if (!target || !checker.getSignaturesOfType(target, ts.SignatureKind.Call).length) error('HESH-ARCH-003', `Unresolved callable implementation ${item.node.name}.${operation.name}`, item, operation.start, 'Return this operation from the declared implementation factory.');\n }\n else for (const block of ['bindings', 'actions', 'parts']) {\n if (block === 'parts' && !list(item, block).length) continue;\n if (!getMember(result, [block])) error('HESH-BIND-002', `Presentation factory must return a ${block} object`, item);\n for (const binding of list(item, block, block !== 'parts')) {\n const target = getMember(result, [block, binding.name]);\n if (block === 'parts' && !getMember(result, [block, binding.name, 'attach'])?.getCallSignatures().length) error('HESH-PART-001', `Part ${binding.name} must be a Hesh Unit`, item, binding.start);\n if (!target || (block === 'actions' && !checker.getSignaturesOfType(target, ts.SignatureKind.Call).length)) error(block === 'actions' ? 'HESH-ACTION-001' : 'HESH-BIND-002', `Missing ${block} implementation ${binding.name}`, item, binding.start, `Return ${block}.${binding.name} from the presentation factory.`);\n }\n }\n }\n // Validate actual imports/re-exports, including aliases and files shared by domains.\n const sources = ts.sys.readDirectory(root, ['.ts', '.js', '.mjs'], ['**/node_modules/**', '**/dist/**', '**/.hesh-generated/**'], ['**/*']);\n for (const path of sources) {\n const file = canonical(path); if (inside(file, canonical(outDir))) continue;\n files.add(file); const source = read(file), syntax = ts.createSourceFile(file, source, ts.ScriptTarget.Latest, true, file.endsWith('.ts') ? ts.ScriptKind.TS : ts.ScriptKind.JS);\n const checkImport = (specifier: ts.Node | undefined): void => {\n if (!specifier) return;\n if (!ts.isStringLiteralLike(specifier)) { diagnostics.push(diagnostic('HESH-ARCH-007', 'Computed module imports cannot be architecture-validated', file, source, specifier.getStart(syntax), 'Use literal imports and explicit injected dependencies.')); return; }\n if (specifier.text.startsWith('node:') || ['fs', 'path', 'child_process', 'worker_threads', 'net', 'tls', 'http', 'https', 'os', 'module'].includes(specifier.text)) {\n diagnostics.push(diagnostic('HESH-SEC-001', `Node/server-only import in client code: ${specifier.text}`, file, source, specifier.getStart(syntax), 'Call server infrastructure through an API rather than bundling it.')); return;\n }\n const target = ts.resolveModuleName(specifier.text, file, settings, ts.sys).resolvedModule?.resolvedFileName;\n const generated = canonical(resolve(dirname(file), specifier.text));\n if (inside(generated, canonical(outDir))) return;\n if (!target) { if (!specifier.text.endsWith('.css') && !specifier.text.endsWith('.hesh')) diagnostics.push(diagnostic('HESH-ARCH-006', `Unresolved module ${specifier.text}`, file, source, specifier.getStart(syntax), 'Fix the path or supply the correct tsconfig alias.')); return; }\n const targetFile = canonical(target); files.add(targetFile);\n if (/(?:^|\\/)server(?:\\/|$)|\\.server\\.[cm]?[jt]s$/.test(targetFile)) diagnostics.push(diagnostic('HESH-SEC-001', `Server-only module in client graph: ${specifier.text}`, file, source, specifier.getStart(syntax), 'Move server calls behind a server API; never import server-only code into the browser.'));\n const targetDomain = owner(targetFile), sourceDomain = owner(file);\n if (targetDomain && targetDomain !== sourceDomain) diagnostics.push(diagnostic('HESH-ARCH-004', `Illegal cross-domain dependency. Source domain: ${sourceDomain?.node.name ?? 'shared/application'}. Target domain: ${targetDomain.node.name}. The imported module is private.`, file, source, specifier.getStart(syntax), `Use an explicitly exposed ${targetDomain.node.name} operation through declared dependency injection.`));\n };\n const walk = (node: ts.Node): void => {\n if (ts.isImportDeclaration(node) || ts.isExportDeclaration(node)) checkImport(node.moduleSpecifier);\n else if (ts.isImportTypeNode(node) && ts.isLiteralTypeNode(node.argument)) checkImport(node.argument.literal);\n else if (ts.isCallExpression(node) && (node.expression.kind === ts.SyntaxKind.ImportKeyword || (ts.isIdentifier(node.expression) && node.expression.text === 'require'))) checkImport(node.arguments[0]);\n ts.forEachChild(node, walk);\n };\n walk(syntax);\n }\n for (const failure of [...program.getSyntacticDiagnostics(), ...program.getSemanticDiagnostics()]) if (failure.file && inside(canonical(failure.file.fileName), root)) {\n // Declared screen modules are produced by this compilation, including on a fresh checkout.\n const missing = failure.code === 2307 && failure.file.text.slice(failure.start, (failure.start ?? 0) + (failure.length ?? 0)).replace(/^['\"]|['\"]$/g, '');\n const generatedScreen = missing && presentations.some(item => canonical(resolve(dirname(failure.file!.fileName), missing)) === canonical(join(outDir, `${item.node.name}.js`)));\n if (!generatedScreen) diagnostics.push(diagnostic('HESH-TYPE-001', ts.flattenDiagnosticMessageText(failure.messageText, '\\n'), failure.file.fileName, failure.file.text, failure.start ?? 0, 'Correct the implementation type/syntax error.'));\n }\n const schemas: Record<string, Record<string, string>> = Object.create(null), urls = new Map<string, Located>();\n const graph: ProjectResult['graph'] = { domains: domains.map(d => ({ name: d.node.name, exposes: list(d, 'exposes').map(e => e.name), consumes: list(d, 'consumes').map(e => e.name) })), destinations: [], links: [] };\n const presentationFor = new Map<Located, Located>();\n for (const item of destinations) {\n const url = field(item, 'url'), inputs = Object.fromEntries(list(item, 'input', true).map(e => [e.name, e.value ?? '']));\n const segments = url.split('/').filter(Boolean), params = segments.filter(p => p.startsWith(':')).map(p => p.slice(1));\n if (!url.startsWith('/') || url.startsWith('//') || /[?#*%]/.test(url) || new Set(params).size !== params.length || params.some(p => !Object.hasOwn(inputs, p)) || Object.keys(inputs).some(p => !params.includes(p))) error('HESH-NAV-003', `URL/input mismatch for ${item.node.name}`, item, item.node.start, 'Use an absolute URL whose :params exactly match the input block; use plain static segments.');\n for (const input of list(item, 'input')) if (!['string', 'number', 'boolean'].includes(input.value ?? '') || input.name.includes('.')) error('HESH-NAV-003', `Invalid input schema ${input.name}`, item, input.start);\n for (const key of Object.keys(inputs)) if (!/^[A-Za-z_][A-Za-z\\d_]*$/.test(key)) error('HESH-NAV-003', `Unsupported URL parameter name ${key}`, item, item.node.start, 'Use ASCII letters/digits/underscore with a letter or underscore first.');\n if (new Set(Object.keys(inputs).map(key => key.toLowerCase())).size !== Object.keys(inputs).length) error('HESH-NAV-003', 'Destination input names must be unique ignoring case for HTML attributes', item);\n const signature = segments.map(p => p.startsWith(':') ? ':' : p).join('/');\n if (urls.has(signature)) error('HESH-NAV-004', `Conflicting destination URL ${url}`, item); else urls.set(signature, item);\n for (const previous of destinations.slice(0, destinations.indexOf(item))) {\n const other = (previous.node.fields.url?.value ?? '').split('/').filter(Boolean);\n if (other.length === segments.length && other.every((part, index) => part === segments[index] || part.startsWith(':') || segments[index]!.startsWith(':'))) error('HESH-NAV-004', `Overlapping destination URLs: ${url} and ${previous.node.fields.url?.value}`, item, item.node.start, 'Use non-overlapping addresses so destination input always resolves to the declared screen.');\n }\n const presentation = declarations.get(field(item, 'presentation'));\n if (!presentation || presentation.node.kind !== 'presentation') error('HESH-NAV-001', `Missing presentation for ${item.node.name}`, item);\n else {\n const own = owner(presentation.file);\n if (!own || !byDomain.has(own.node.name) || owner(item.file) !== own) error('HESH-ARCH-004', 'Destination and presentation must belong to the same selected domain', item);\n else { presentationFor.set(item, presentation); graph.destinations.push({ name: item.node.name, url, input: inputs, owner: own.node.name }); }\n }\n schemas[item.node.name] = inputs;\n }\n const outputs: Record<string, string> = {}, htmlModules = new Map<Located, string>();\n for (const item of presentations) {\n const html = canonical(resolve(dirname(item.file), field(item, 'html'))), stylePath = field(item, 'styles', false);\n if (!isFile(html) || !html.endsWith('.html') || !inside(html, canonical(dirname(item.file)))) { error('HESH-HTML-001', `Missing or private presentation HTML ${html}`, item); continue; }\n const source = read(html), factory = resolvedFactories.get(item);\n const compiled = compileHTML(source, { filename: html, bindings: list(item, 'bindings', true).map(e => e.name), actions: list(item, 'actions', true).map(e => e.name), parts: list(item, 'parts').map(e => e.name), allowOutlet: ![...presentationFor.values()].includes(item), destinations: schemas,\n validateBinding(path, offset, expected, writable) {\n if (!factory) return;\n const type = getMember(factory.result, ['bindings', ...path.split('.')], true);\n if (type && type.flags & ts.TypeFlags.Any) diagnostics.push(diagnostic('HESH-TYPE-002', `Binding ${path} has a dynamic any type; its nested shape/input type cannot be proven`, html, source, offset, 'Add JSDoc or a TypeScript type if static checking is required; runtime destination validation still applies.', 'warning'));\n if (!type) diagnostics.push(diagnostic('HESH-BIND-002', `Missing nested data path ${path}`, html, source, offset, 'Return this field in the declared bindings.'));\n if (writable) {\n const raw = getMember(factory.result, ['bindings', path]);\n if (!raw || !checker.getPropertyOfType(raw, 'set')) diagnostics.push(diagnostic('HESH-BIND-004', `Binding ${path} is not writable`, html, source, offset, 'Use a writable signal for h-value.'));\n }\n if (expected && type && !(type.flags & ts.TypeFlags.Any)) {\n const actual = type.flags & ts.TypeFlags.StringLike ? 'string' : type.flags & ts.TypeFlags.NumberLike ? 'number' : type.flags & ts.TypeFlags.BooleanLike ? 'boolean' : 'object/unknown';\n if (actual !== expected) diagnostics.push(diagnostic('HESH-NAV-003', `Destination binding ${path} is ${actual}, expected ${expected}`, html, source, offset, 'Bind a value of the destination input type.'));\n }\n }\n });\n diagnostics.push(...compiled.diagnostics);\n for (const [destination, screen] of presentationFor) if (screen === item) for (const target of compiled.destinations) graph.links.push({ from: destination.node.name, to: target });\n const output = join(outDir, `${item.node.name}.js`); htmlModules.set(item, output);\n let css = '';\n if (stylePath) {\n const style = canonical(resolve(dirname(item.file), stylePath));\n if (!isFile(style) || !style.endsWith('.css') || !inside(style, canonical(dirname(item.file)))) error('HESH-HTML-001', `Missing/private CSS resource ${stylePath}`, item);\n else { files.add(style); css = `import ${JSON.stringify(modulePath(output, style))};\\n`; }\n }\n outputs[output] = css + compiled.code;\n outputs[output.replace(/\\.js$/, '.d.ts')] = \"import type { PresentationState } from '@heshammesalam/heshjs/presentation';\\nexport default function render(parent: Node, state: PresentationState, destinations?: object): void;\\n\";\n }\n const output = join(outDir, 'app.js'), types = join(outDir, 'app.d.ts');\n const js = [\"import { createGraphApplication, createDomainGraph } from '@heshammesalam/heshjs/destinations';\"];\n const domainValues: string[] = [], pageValues: string[] = [], typeImports: string[] = [], domainTypes: string[] = [];\n let index = 0;\n for (const item of domains) {\n const factory = resolvedFactories.get(item); if (!factory) continue;\n const alias = `factory${index++}`, spec = modulePath(output, factory.file);\n js.push(`import { ${factory.name} as ${alias} } from ${JSON.stringify(spec)};`);\n typeImports.push(`import { ${factory.name} as ${alias} } from ${JSON.stringify(spec)};`);\n const operations = list(item, 'exposes').map(e => e.name);\n domainValues.push(`{name:${JSON.stringify(item.node.name)}, factory:${alias}, exposes:${JSON.stringify(operations)}, consumes:${JSON.stringify(list(item, 'consumes').map(e => e.name))}, access:${JSON.stringify(Object.fromEntries(list(item, 'access').map(e => [e.name, e.value])))}}`);\n const tree: Record<string, unknown> = {};\n for (const operation of operations) { let node = tree; const parts = operation.split('.'); parts.forEach((part, i) => { if (i === parts.length - 1) node[part] = `ReturnType<typeof ${alias}>${parts.map(p => `[${JSON.stringify(p)}]`).join('')}`; else node = (node[part] ??= {}) as Record<string, unknown>; }); }\n const typeTree = (value: Record<string, unknown>): string => '{' + Object.entries(value).map(([key, value]) => `readonly ${JSON.stringify(key)}:${typeof value === 'string' ? value : typeTree(value as Record<string, unknown>)}`).join(';') + '}';\n domainTypes.push(`${JSON.stringify(item.node.name)}:${typeTree(tree)}`);\n }\n for (const item of destinations) {\n const presentation = presentationFor.get(item), factory = presentation && resolvedFactories.get(presentation), html = presentation && htmlModules.get(presentation);\n const data = graph.destinations.find(d => d.name === item.node.name);\n if (!presentation || !factory || !html || !data) continue;\n pageValues.push(`{...${JSON.stringify({ ...data, access: item.node.fields.access?.value })}, load:async()=>{const [logic,template]=await Promise.all([import(${JSON.stringify(modulePath(output, factory.file))}),import(${JSON.stringify(modulePath(output, html))})]);return {create:logic[${JSON.stringify(factory.name)}],view:template.default};}}`);\n }\n js.push(`const domains = [${domainValues.join(',\\n')}];`, `const pages = [${pageValues.join(',\\n')}];`, 'export const metadata = ' + JSON.stringify(graph) + ';', 'export const createDomains = (options = {}) => createDomainGraph(domains, options);', 'export const createApplication = (options = {}) => createGraphApplication(domains, pages, options);');\n const destinationTypes = graph.destinations.map(d => `${JSON.stringify(d.name)}: Destination<${Object.keys(d.input).length ? '{' + Object.entries(d.input).map(([key, type]) => `${JSON.stringify(key)}:${type}`).join(';') + '}' : 'Record<string, never>'}>`);\n outputs[output] = js.join('\\n');\n outputs[types] = [\"import type { Destination, GraphApplication, ApplicationOptions, DomainGraph } from '@heshammesalam/heshjs/destinations';\", ...typeImports, `export interface DomainAPIs {${domainTypes.join(';')}}`, `export interface Destinations {${destinationTypes.join(';')}}`, 'export declare function createDomains(options?: ApplicationOptions): DomainGraph<DomainAPIs>;', 'export declare function createApplication(options?: ApplicationOptions): GraphApplication<Destinations, DomainAPIs>;', 'export declare const metadata: unknown;'].join('\\n');\n if (diagnostics.some(d => d.severity === 'error')) for (const name of Object.keys(outputs)) delete outputs[name];\n return { diagnostics, files: [...files].sort(), outputs, graph, statistics: { parsed, reused } };\n } };\n}\nexport function checkProject(options: ProjectOptions): ProjectResult { return createArchitectureCompiler().check(options); }\nexport function writeProject(result: ProjectResult): void {\n if (result.diagnostics.some(d => d.severity === 'error')) throw new Error(result.diagnostics.map(formatDiagnostic).join('\\n'));\n for (const [file, source] of Object.entries(result.outputs)) { mkdirSync(dirname(file), { recursive: true }); if (!existsSync(file) || readFileSync(file, 'utf8') !== source) writeFileSync(file, source); }\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRouter } from '../router/index.js';
|
|
2
|
-
import { defineModule, useController } from '../hmvc/index.js';
|
|
2
|
+
import { defineModule, useController, useModule, withModuleContext } from '../hmvc/index.js';
|
|
3
3
|
import { createDomainGraph, ClientPolicyDenied } from '../domains/index.js';
|
|
4
4
|
import { signal, effect, onCleanup, scope } from '../reactivity/index.js';
|
|
5
5
|
import { mount, element, text } from '../dom/index.js';
|
|
@@ -68,6 +68,7 @@ export function createGraphApplication(definitions, pages, options = {}) {
|
|
|
68
68
|
model: context => context.route,
|
|
69
69
|
controller: route => route,
|
|
70
70
|
view(parent) {
|
|
71
|
+
const parentContext = useModule();
|
|
71
72
|
const route = useController();
|
|
72
73
|
effect(() => {
|
|
73
74
|
const location = route.get();
|
|
@@ -105,7 +106,7 @@ export function createGraphApplication(definitions, pages, options = {}) {
|
|
|
105
106
|
const state = resources.create({ input, domains: graph.forDomain(page.owner), location, signal: abort.signal });
|
|
106
107
|
if (state && typeof state.then === 'function')
|
|
107
108
|
throw new Error('Presentation factories must be synchronous; use the provided AbortSignal for async work');
|
|
108
|
-
mount(() => resources.view(parent, state, destinations), parent, { onError: report });
|
|
109
|
+
mount(() => withModuleContext(parentContext, () => resources.view(parent, state, destinations)), parent, { onError: report });
|
|
109
110
|
});
|
|
110
111
|
dispose = owned.dispose;
|
|
111
112
|
if (abort.signal.aborted) {
|