illimi-core 1.0.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/LICENSE +21 -0
- package/README.md +135 -0
- package/dist/ast/nodes.d.ts +91 -0
- package/dist/ast/nodes.d.ts.map +1 -0
- package/dist/ast/nodes.js +8 -0
- package/dist/ast/nodes.js.map +1 -0
- package/dist/compiler/mergeSlots.d.ts +31 -0
- package/dist/compiler/mergeSlots.d.ts.map +1 -0
- package/dist/compiler/mergeSlots.js +85 -0
- package/dist/compiler/mergeSlots.js.map +1 -0
- package/dist/compiler/resolveLayout.d.ts +22 -0
- package/dist/compiler/resolveLayout.d.ts.map +1 -0
- package/dist/compiler/resolveLayout.js +212 -0
- package/dist/compiler/resolveLayout.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -0
- package/dist/ir/transform.d.ts +50 -0
- package/dist/ir/transform.d.ts.map +1 -0
- package/dist/ir/transform.js +128 -0
- package/dist/ir/transform.js.map +1 -0
- package/dist/parser/directiveParser.d.ts +34 -0
- package/dist/parser/directiveParser.d.ts.map +1 -0
- package/dist/parser/directiveParser.js +131 -0
- package/dist/parser/directiveParser.js.map +1 -0
- package/dist/parser/htmlParser.d.ts +13 -0
- package/dist/parser/htmlParser.d.ts.map +1 -0
- package/dist/parser/htmlParser.js +350 -0
- package/dist/parser/htmlParser.js.map +1 -0
- package/dist/vdom/diff.d.ts +33 -0
- package/dist/vdom/diff.d.ts.map +1 -0
- package/dist/vdom/diff.js +259 -0
- package/dist/vdom/diff.js.map +1 -0
- package/dist/vdom/vnode.d.ts +52 -0
- package/dist/vdom/vnode.d.ts.map +1 -0
- package/dist/vdom/vnode.js +206 -0
- package/dist/vdom/vnode.js.map +1 -0
- package/package.json +38 -0
- package/tsconfig.base.json +28 -0
- package/tsconfig.json +8 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Codizium
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
# Illimi Core
|
|
2
|
+
|
|
3
|
+
Illimi Core is the heart of the Illimi template engine. It provides the parser, AST (Abstract Syntax Tree), IR (Intermediate Representation), and VDOM (Virtual DOM) components needed to compile and render templates.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **HTML Parser**: Parses `.illimi.html` templates into an AST
|
|
8
|
+
- **Template Directives**: Built-in support for:
|
|
9
|
+
- `f-if` / `f-else` - Conditional rendering
|
|
10
|
+
- `f-for` - List rendering with iteration
|
|
11
|
+
- `f-text` - Text content binding
|
|
12
|
+
- `f-html` - HTML content binding
|
|
13
|
+
- `f-bind:*` - Attribute binding
|
|
14
|
+
- `f-on:*` - Event handling
|
|
15
|
+
- **Interpolation**: `{{ expression }}` syntax for inline expressions
|
|
16
|
+
- **Layout System**: `<layout src="...">` and `<slot>` support for template inheritance
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
npm install @illimi/core
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Usage
|
|
25
|
+
|
|
26
|
+
### Parse a Template
|
|
27
|
+
|
|
28
|
+
```typescript
|
|
29
|
+
import { parseTemplate, transformAST, createVDOM } from '@illimi/core';
|
|
30
|
+
|
|
31
|
+
const template = `
|
|
32
|
+
<div>
|
|
33
|
+
<h1 f-text="title"></h1>
|
|
34
|
+
<p>{{ message }}</p>
|
|
35
|
+
<ul>
|
|
36
|
+
<li f-for="item in items" f-text="item.name"></li>
|
|
37
|
+
</ul>
|
|
38
|
+
</div>
|
|
39
|
+
`;
|
|
40
|
+
|
|
41
|
+
const ast = parseTemplate(template);
|
|
42
|
+
const ir = transformAST(ast);
|
|
43
|
+
const vnode = createVDOM(ir, { title: 'Hello', message: 'World', items: [{ name: 'Item 1' }] });
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Template Syntax
|
|
47
|
+
|
|
48
|
+
#### Text Binding
|
|
49
|
+
|
|
50
|
+
```html
|
|
51
|
+
<span f-text="username"></span>
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
#### Interpolation
|
|
55
|
+
|
|
56
|
+
```html
|
|
57
|
+
<p>Hello, {{ username }}!</p>
|
|
58
|
+
<p>Total: {{ price * quantity }}</p>
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
#### Attribute Binding
|
|
62
|
+
|
|
63
|
+
```html
|
|
64
|
+
<input f-bind:value="inputValue">
|
|
65
|
+
<input f-bind:checked="isSelected">
|
|
66
|
+
<img f-bind:src="imageUrl">
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
#### Event Handling
|
|
70
|
+
|
|
71
|
+
```html
|
|
72
|
+
<button f-on:click="handleClick">Click Me</button>
|
|
73
|
+
<form f-on:submit="handleSubmit">
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
#### Conditionals
|
|
77
|
+
|
|
78
|
+
```html
|
|
79
|
+
<div f-if="isLoggedIn">
|
|
80
|
+
Welcome, {{ username }}!
|
|
81
|
+
</div>
|
|
82
|
+
<div f-else>
|
|
83
|
+
Please log in.
|
|
84
|
+
</div>
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
#### Loops
|
|
88
|
+
|
|
89
|
+
```html
|
|
90
|
+
<ul>
|
|
91
|
+
<li f-for="item in items" f-key="item.id">
|
|
92
|
+
{{ item.name }}
|
|
93
|
+
</li>
|
|
94
|
+
</ul>
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
#### Layouts
|
|
98
|
+
|
|
99
|
+
**Layout file (layout.illimi.html):**
|
|
100
|
+
```html
|
|
101
|
+
<header>
|
|
102
|
+
<h1>My App</h1>
|
|
103
|
+
</header>
|
|
104
|
+
<main>
|
|
105
|
+
<slot></slot>
|
|
106
|
+
</main>
|
|
107
|
+
<footer>
|
|
108
|
+
© 2026
|
|
109
|
+
</footer>
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
**Page file (page.illimi.html):**
|
|
113
|
+
```html
|
|
114
|
+
<layout src="./layout.illimi.html">
|
|
115
|
+
<p>This content goes into the slot!</p>
|
|
116
|
+
</layout>
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
## API
|
|
120
|
+
|
|
121
|
+
### `parseTemplate(html: string): FeedAST`
|
|
122
|
+
|
|
123
|
+
Parses an HTML template string into an Abstract Syntax Tree.
|
|
124
|
+
|
|
125
|
+
### `transformAST(ast: FeedAST): IRNode[]`
|
|
126
|
+
|
|
127
|
+
Transforms the AST into an Intermediate Representation.
|
|
128
|
+
|
|
129
|
+
### `createVDOM(ir: IRNode | IRNode[], state: object): VNode`
|
|
130
|
+
|
|
131
|
+
Creates a Virtual DOM tree from the IR using the provided state.
|
|
132
|
+
|
|
133
|
+
## License
|
|
134
|
+
|
|
135
|
+
MIT
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FeedJS Core - AST Node Types
|
|
3
|
+
*
|
|
4
|
+
* Defines the formal AST (Abstract Syntax Tree) for Feed templates.
|
|
5
|
+
* This is the intermediate representation after parsing HTML templates.
|
|
6
|
+
*/
|
|
7
|
+
export type FeedASTNodeType = 'Element' | 'Text' | 'Comment' | 'Fragment' | 'Slot' | 'SlotPlaceholder' | 'TemplateBlock';
|
|
8
|
+
export type DirectiveType = 'if' | 'else-if' | 'else' | 'for' | 'items' | 'key' | 'text' | 'html' | 'bind' | 'on' | 'show' | 'model';
|
|
9
|
+
export interface BaseFeedASTNode {
|
|
10
|
+
type: FeedASTNodeType;
|
|
11
|
+
}
|
|
12
|
+
export interface FeedElementNode extends BaseFeedASTNode {
|
|
13
|
+
type: 'Element';
|
|
14
|
+
tag: string;
|
|
15
|
+
attributes: Record<string, string>;
|
|
16
|
+
directives: FeedDirective[];
|
|
17
|
+
children: FeedASTNode[];
|
|
18
|
+
}
|
|
19
|
+
export interface FeedTextNode extends BaseFeedASTNode {
|
|
20
|
+
type: 'Text';
|
|
21
|
+
value: string;
|
|
22
|
+
interpolation?: string;
|
|
23
|
+
}
|
|
24
|
+
export interface FeedCommentNode extends BaseFeedASTNode {
|
|
25
|
+
type: 'Comment';
|
|
26
|
+
value: string;
|
|
27
|
+
}
|
|
28
|
+
export interface FeedFragmentNode extends BaseFeedASTNode {
|
|
29
|
+
type: 'Fragment';
|
|
30
|
+
children: FeedASTNode[];
|
|
31
|
+
}
|
|
32
|
+
export interface FeedSlotNode extends BaseFeedASTNode {
|
|
33
|
+
type: 'Slot';
|
|
34
|
+
name: string;
|
|
35
|
+
fallback: FeedASTNode[];
|
|
36
|
+
}
|
|
37
|
+
export interface FeedSlotPlaceholderNode extends BaseFeedASTNode {
|
|
38
|
+
type: 'SlotPlaceholder';
|
|
39
|
+
name: string;
|
|
40
|
+
children: FeedASTNode[];
|
|
41
|
+
}
|
|
42
|
+
export interface FeedTemplateBlockNode extends BaseFeedASTNode {
|
|
43
|
+
type: 'TemplateBlock';
|
|
44
|
+
name: string;
|
|
45
|
+
children: FeedASTNode[];
|
|
46
|
+
}
|
|
47
|
+
export type FeedASTNode = FeedElementNode | FeedTextNode | FeedCommentNode | FeedFragmentNode | FeedSlotNode | FeedSlotPlaceholderNode | FeedTemplateBlockNode;
|
|
48
|
+
export interface FeedDirective {
|
|
49
|
+
type: DirectiveType;
|
|
50
|
+
name: string;
|
|
51
|
+
value: string;
|
|
52
|
+
expression?: string;
|
|
53
|
+
modifiers?: string[];
|
|
54
|
+
}
|
|
55
|
+
export interface ForLoopData {
|
|
56
|
+
item: string;
|
|
57
|
+
index: string;
|
|
58
|
+
collection: string;
|
|
59
|
+
}
|
|
60
|
+
export interface IfData {
|
|
61
|
+
condition: string;
|
|
62
|
+
branches: IfBranch[];
|
|
63
|
+
}
|
|
64
|
+
export interface IfBranch {
|
|
65
|
+
condition: string | null;
|
|
66
|
+
nodes: FeedASTNode[];
|
|
67
|
+
}
|
|
68
|
+
export interface KeyData {
|
|
69
|
+
expression: string;
|
|
70
|
+
}
|
|
71
|
+
export interface TextData {
|
|
72
|
+
expression: string;
|
|
73
|
+
}
|
|
74
|
+
export interface HtmlData {
|
|
75
|
+
expression: string;
|
|
76
|
+
}
|
|
77
|
+
export interface BindData {
|
|
78
|
+
attribute: string;
|
|
79
|
+
expression: string;
|
|
80
|
+
}
|
|
81
|
+
export interface OnData {
|
|
82
|
+
event: string;
|
|
83
|
+
expression: string;
|
|
84
|
+
modifiers?: string[];
|
|
85
|
+
}
|
|
86
|
+
export interface FeedAST {
|
|
87
|
+
type: 'FeedAST';
|
|
88
|
+
nodes: FeedASTNode[];
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CAAC;CACpB;AAGD,MAAM,WAAW,MAAM;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;CACtB;AAGD,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,SAAS,CAAC;IAChB,KAAK,EAAE,WAAW,EAAE,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;CAChB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nodes.js","sourceRoot":"","sources":["../../src/ast/nodes.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FeedJS Core - Slot Merging
|
|
3
|
+
*
|
|
4
|
+
* Pure slot substitution logic.
|
|
5
|
+
* This module handles the merging of slot content into layouts.
|
|
6
|
+
*/
|
|
7
|
+
import type { FeedASTNode } from '../ast/nodes.js';
|
|
8
|
+
/**
|
|
9
|
+
* Slot content map
|
|
10
|
+
*/
|
|
11
|
+
export type SlotContentMap = Map<string, FeedASTNode[]>;
|
|
12
|
+
/**
|
|
13
|
+
* Merge slot content into layout nodes
|
|
14
|
+
*
|
|
15
|
+
* @param layoutNodes - The layout AST nodes
|
|
16
|
+
* @param slots - Map of slot name to content
|
|
17
|
+
* @returns Merged AST nodes
|
|
18
|
+
*/
|
|
19
|
+
export declare function mergeSlots(layoutNodes: FeedASTNode[], slots: SlotContentMap): FeedASTNode[];
|
|
20
|
+
/**
|
|
21
|
+
* Validate slot usage for errors
|
|
22
|
+
*/
|
|
23
|
+
export declare function validateSlots(layoutNodes: FeedASTNode[], providedSlots: SlotContentMap): void;
|
|
24
|
+
/**
|
|
25
|
+
* Extract slots from a page AST
|
|
26
|
+
*
|
|
27
|
+
* @param nodes - AST nodes to extract from
|
|
28
|
+
* @returns Map of slot name to content
|
|
29
|
+
*/
|
|
30
|
+
export declare function extractSlots(nodes: FeedASTNode[]): SlotContentMap;
|
|
31
|
+
//# sourceMappingURL=mergeSlots.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mergeSlots.d.ts","sourceRoot":"","sources":["../../src/compiler/mergeSlots.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAiF,MAAM,iBAAiB,CAAC;AAElI;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,GAAG,CAAC,MAAM,EAAE,WAAW,EAAE,CAAC,CAAC;AAExD;;;;;;GAMG;AACH,wBAAgB,UAAU,CACxB,WAAW,EAAE,WAAW,EAAE,EAC1B,KAAK,EAAE,cAAc,GACpB,WAAW,EAAE,CAgCf;AAED;;GAEG;AACH,wBAAgB,aAAa,CAC3B,WAAW,EAAE,WAAW,EAAE,EAC1B,aAAa,EAAE,cAAc,GAC5B,IAAI,CAgBN;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,WAAW,EAAE,GAAG,cAAc,CAgBjE"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FeedJS Core - Slot Merging
|
|
3
|
+
*
|
|
4
|
+
* Pure slot substitution logic.
|
|
5
|
+
* This module handles the merging of slot content into layouts.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Merge slot content into layout nodes
|
|
9
|
+
*
|
|
10
|
+
* @param layoutNodes - The layout AST nodes
|
|
11
|
+
* @param slots - Map of slot name to content
|
|
12
|
+
* @returns Merged AST nodes
|
|
13
|
+
*/
|
|
14
|
+
export function mergeSlots(layoutNodes, slots) {
|
|
15
|
+
const result = [];
|
|
16
|
+
for (const node of layoutNodes) {
|
|
17
|
+
if (node.type === 'Slot') {
|
|
18
|
+
const slotNode = node;
|
|
19
|
+
const slotName = slotNode.name || 'default';
|
|
20
|
+
if (slots.has(slotName)) {
|
|
21
|
+
// Use provided content
|
|
22
|
+
result.push(...slots.get(slotName));
|
|
23
|
+
}
|
|
24
|
+
else if (slotNode.fallback && slotNode.fallback.length > 0) {
|
|
25
|
+
// Use fallback content
|
|
26
|
+
result.push(...slotNode.fallback);
|
|
27
|
+
}
|
|
28
|
+
else if (slotName !== 'default') {
|
|
29
|
+
// Named slot with no content - error should be handled by caller
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
else if (node.type === 'Element' && node.children && node.children.length > 0) {
|
|
34
|
+
// Recursively process children
|
|
35
|
+
const processedChildren = mergeSlots(node.children, slots);
|
|
36
|
+
result.push({
|
|
37
|
+
...node,
|
|
38
|
+
children: processedChildren,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
result.push(node);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return result;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Validate slot usage for errors
|
|
49
|
+
*/
|
|
50
|
+
export function validateSlots(layoutNodes, providedSlots) {
|
|
51
|
+
// Check for missing required slots
|
|
52
|
+
for (const node of layoutNodes) {
|
|
53
|
+
if (node.type === 'Slot') {
|
|
54
|
+
const slotNode = node;
|
|
55
|
+
const slotName = slotNode.name || 'default';
|
|
56
|
+
if (!providedSlots.has(slotName) && !slotNode.fallback) {
|
|
57
|
+
// This will be handled as an error by the caller
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
if (node.type === 'Element' && node.children) {
|
|
61
|
+
validateSlots(node.children, providedSlots);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Extract slots from a page AST
|
|
67
|
+
*
|
|
68
|
+
* @param nodes - AST nodes to extract from
|
|
69
|
+
* @returns Map of slot name to content
|
|
70
|
+
*/
|
|
71
|
+
export function extractSlots(nodes) {
|
|
72
|
+
const slots = new Map();
|
|
73
|
+
for (const node of nodes) {
|
|
74
|
+
if (node.type === 'TemplateBlock') {
|
|
75
|
+
const templateNode = node;
|
|
76
|
+
slots.set(templateNode.name, templateNode.children);
|
|
77
|
+
}
|
|
78
|
+
if (node.type === 'SlotPlaceholder') {
|
|
79
|
+
const slotNode = node;
|
|
80
|
+
slots.set(slotNode.name, slotNode.children);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return slots;
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=mergeSlots.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mergeSlots.js","sourceRoot":"","sources":["../../src/compiler/mergeSlots.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AASH;;;;;;GAMG;AACH,MAAM,UAAU,UAAU,CACxB,WAA0B,EAC1B,KAAqB;IAErB,MAAM,MAAM,GAAkB,EAAE,CAAC;IAEjC,KAAK,MAAM,IAAI,IAAI,WAAW,EAAE,CAAC;QAC/B,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;YACzB,MAAM,QAAQ,GAAG,IAA+B,CAAC;YACjD,MAAM,QAAQ,GAAG,QAAQ,CAAC,IAAI,IAAI,SAAS,CAAC;YAE5C,IAAI,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;gBACxB,uBAAuB;gBACvB,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAE,CAAC,CAAC;YACvC,CAAC;iBAAM,IAAI,QAAQ,CAAC,QAAQ,IAAI,QAAQ,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAC7D,uBAAuB;gBACvB,MAAM,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC,QAAQ,CAAC,CAAC;YACpC,CAAC;iBAAM,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;gBAClC,iEAAiE;gBACjE,SAAS;YACX,CAAC;QACH,CAAC;aAAM,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,IAAI,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,Q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C,YAAY,CAAC,IAAI,EAAE,YAAY,CAAC,QAAQ,CAAC,CAAC;QACtD,CAAC;QAED,IAAI,IAAI,CAAC,IAAI,KAAK,iBAAiB,EAAE,CAAC;YACpC,MAAM,QAAQ,GAAG,IAA+B,CAAC;YACjD,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAC9C,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FeedJS Core - Layout Resolution
|
|
3
|
+
*
|
|
4
|
+
* Resolves compile-time layout/template inheritance.
|
|
5
|
+
* Supports:
|
|
6
|
+
* - Page level: <layout src="...">, <extends src="...">, and f:inherit/inherit/extends attrs
|
|
7
|
+
* - Element level inheritance: inherit/extends/f:inherit attributes
|
|
8
|
+
* - Slot/template merging via <slot>, <template name="..."> and <template #name>
|
|
9
|
+
*/
|
|
10
|
+
import type { FeedAST } from '../ast/nodes.js';
|
|
11
|
+
/**
|
|
12
|
+
* Detect and resolve layout/inheritance features.
|
|
13
|
+
*/
|
|
14
|
+
export declare function resolveLayout(ast: FeedAST, resolveLayoutFile: (src: string) => string): FeedAST;
|
|
15
|
+
/**
|
|
16
|
+
* Compile error class
|
|
17
|
+
*/
|
|
18
|
+
export declare class CompileError extends Error {
|
|
19
|
+
source: string;
|
|
20
|
+
constructor(message: string, source: string);
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=resolveLayout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveLayout.d.ts","sourceRoot":"","sources":["../../src/compiler/resolveLayout.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,KAAK,EACV,OAAO,EAOR,MAAM,iBAAiB,CAAC;AAYzB;;GAEG;AACH,wBAAgB,aAAa,CAC3B,GAAG,EAAE,OAAO,EACZ,iBAAiB,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,GACzC,OAAO,CAgCT;AAyND;;GAEG;AACH,qBAAa,YAAa,SAAQ,KAAK;IACD,MAAM,EAAE,MAAM;gBAAtC,OAAO,EAAE,MAAM,EAAS,MAAM,EAAE,MAAM;CAInD"}
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FeedJS Core - Layout Resolution
|
|
3
|
+
*
|
|
4
|
+
* Resolves compile-time layout/template inheritance.
|
|
5
|
+
* Supports:
|
|
6
|
+
* - Page level: <layout src="...">, <extends src="...">, and f:inherit/inherit/extends attrs
|
|
7
|
+
* - Element level inheritance: inherit/extends/f:inherit attributes
|
|
8
|
+
* - Slot/template merging via <slot>, <template name="..."> and <template #name>
|
|
9
|
+
*/
|
|
10
|
+
import { parseTemplate } from '../parser/htmlParser.js';
|
|
11
|
+
const INHERIT_ATTRS = ['inherit', 'extends', 'f:inherit'];
|
|
12
|
+
/**
|
|
13
|
+
* Detect and resolve layout/inheritance features.
|
|
14
|
+
*/
|
|
15
|
+
export function resolveLayout(ast, resolveLayoutFile) {
|
|
16
|
+
const inheritedNodes = processInherit(ast.nodes, resolveLayoutFile);
|
|
17
|
+
const binding = findLayoutBinding(inheritedNodes);
|
|
18
|
+
if (!binding) {
|
|
19
|
+
return {
|
|
20
|
+
type: 'FeedAST',
|
|
21
|
+
nodes: inheritedNodes,
|
|
22
|
+
source: ast.source,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
const layoutContent = loadTemplate(binding.src, ast.source, resolveLayoutFile);
|
|
26
|
+
const parsedLayout = parseTemplate(layoutContent);
|
|
27
|
+
// Resolve nested layout chains in the base layout itself.
|
|
28
|
+
const resolvedBase = resolveLayout(parsedLayout, resolveLayoutFile);
|
|
29
|
+
const siblingContent = inheritedNodes.filter((_, i) => i !== binding.index);
|
|
30
|
+
const slotMap = collectSlotContent(binding.children);
|
|
31
|
+
const defaultContent = [
|
|
32
|
+
...siblingContent,
|
|
33
|
+
...stripSlotDeclarationNodes(binding.children),
|
|
34
|
+
];
|
|
35
|
+
const mergedNodes = injectSlots(resolvedBase.nodes, slotMap, defaultContent, ast.source);
|
|
36
|
+
return {
|
|
37
|
+
type: 'FeedAST',
|
|
38
|
+
nodes: mergedNodes,
|
|
39
|
+
source: ast.source,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
function loadTemplate(src, source, resolveLayoutFile) {
|
|
43
|
+
try {
|
|
44
|
+
return resolveLayoutFile(src);
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
console.error(`Error resolving template file: ${src}`, error);
|
|
48
|
+
throw new CompileError(`Failed to load template file: ${src}`, source);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
function findLayoutBinding(nodes) {
|
|
52
|
+
for (let i = 0; i < nodes.length; i++) {
|
|
53
|
+
const node = nodes[i];
|
|
54
|
+
if (!node || node.type !== 'Element')
|
|
55
|
+
continue;
|
|
56
|
+
const src = getLayoutSrcFromTag(node) ??
|
|
57
|
+
node.attributes['layout'] ??
|
|
58
|
+
node.attributes['extends'] ??
|
|
59
|
+
node.attributes['f:inherit'];
|
|
60
|
+
if (!src)
|
|
61
|
+
continue;
|
|
62
|
+
if (isLayoutTag(node.tag) || node.attributes['layout'] || node.attributes['extends'] || node.attributes['f:inherit']) {
|
|
63
|
+
return {
|
|
64
|
+
src,
|
|
65
|
+
children: node.children || [],
|
|
66
|
+
index: i,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
function isLayoutTag(tag) {
|
|
73
|
+
return tag === 'layout' || tag === 'feedjs-layout' || tag === 'extends';
|
|
74
|
+
}
|
|
75
|
+
function getLayoutSrcFromTag(node) {
|
|
76
|
+
if (!isLayoutTag(node.tag))
|
|
77
|
+
return undefined;
|
|
78
|
+
return node.attributes['src'];
|
|
79
|
+
}
|
|
80
|
+
function processInherit(nodes, resolveLayoutFile) {
|
|
81
|
+
return nodes.map((node) => processNodeInherit(node, resolveLayoutFile));
|
|
82
|
+
}
|
|
83
|
+
function processNodeInherit(node, resolveLayoutFile) {
|
|
84
|
+
if (node.type !== 'Element') {
|
|
85
|
+
return node;
|
|
86
|
+
}
|
|
87
|
+
const processedChildren = processInherit(node.children || [], resolveLayoutFile);
|
|
88
|
+
const currentNode = {
|
|
89
|
+
...node,
|
|
90
|
+
children: processedChildren,
|
|
91
|
+
};
|
|
92
|
+
const inheritSrc = getInheritSrc(currentNode);
|
|
93
|
+
if (!inheritSrc) {
|
|
94
|
+
return currentNode;
|
|
95
|
+
}
|
|
96
|
+
const inheritedContent = loadTemplate(inheritSrc, '', resolveLayoutFile);
|
|
97
|
+
const inheritedAST = resolveLayout(parseTemplate(inheritedContent), resolveLayoutFile);
|
|
98
|
+
const inheritedRoot = inheritedAST.nodes.find((n) => n.type === 'Element' && n.tag === currentNode.tag) ??
|
|
99
|
+
inheritedAST.nodes.find((n) => n.type === 'Element');
|
|
100
|
+
if (!inheritedRoot) {
|
|
101
|
+
throw new CompileError(`Inherited template has no root element: ${inheritSrc}`, '');
|
|
102
|
+
}
|
|
103
|
+
const inheritedProcessed = {
|
|
104
|
+
...inheritedRoot,
|
|
105
|
+
children: processInherit(inheritedRoot.children || [], resolveLayoutFile),
|
|
106
|
+
};
|
|
107
|
+
return mergeInheritedElement(inheritedProcessed, currentNode);
|
|
108
|
+
}
|
|
109
|
+
function getInheritSrc(node) {
|
|
110
|
+
for (const attr of INHERIT_ATTRS) {
|
|
111
|
+
const value = node.attributes[attr];
|
|
112
|
+
if (value)
|
|
113
|
+
return value;
|
|
114
|
+
}
|
|
115
|
+
return undefined;
|
|
116
|
+
}
|
|
117
|
+
function mergeInheritedElement(base, current) {
|
|
118
|
+
const attributes = {
|
|
119
|
+
...base.attributes,
|
|
120
|
+
...current.attributes,
|
|
121
|
+
};
|
|
122
|
+
for (const attr of INHERIT_ATTRS) {
|
|
123
|
+
delete attributes[attr];
|
|
124
|
+
}
|
|
125
|
+
const directives = mergeDirectives(base.directives || [], current.directives || []);
|
|
126
|
+
const providedSlots = collectSlotContent(current.children || []);
|
|
127
|
+
const defaultContent = stripSlotDeclarationNodes(current.children || []);
|
|
128
|
+
let children = injectSlots(base.children || [], providedSlots, defaultContent, '');
|
|
129
|
+
if (children.length === 0) {
|
|
130
|
+
children = defaultContent.length > 0 ? defaultContent : (base.children || []);
|
|
131
|
+
}
|
|
132
|
+
return {
|
|
133
|
+
type: 'Element',
|
|
134
|
+
tag: base.tag,
|
|
135
|
+
attributes,
|
|
136
|
+
directives,
|
|
137
|
+
children,
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
function mergeDirectives(base, current) {
|
|
141
|
+
const merged = new Map();
|
|
142
|
+
for (const dir of base) {
|
|
143
|
+
merged.set(dir.name, dir);
|
|
144
|
+
}
|
|
145
|
+
for (const dir of current) {
|
|
146
|
+
merged.set(dir.name, dir);
|
|
147
|
+
}
|
|
148
|
+
return Array.from(merged.values());
|
|
149
|
+
}
|
|
150
|
+
function collectSlotContent(nodes) {
|
|
151
|
+
const slots = new Map();
|
|
152
|
+
for (const node of nodes) {
|
|
153
|
+
if (node.type === 'TemplateBlock') {
|
|
154
|
+
const block = node;
|
|
155
|
+
slots.set(block.name || 'default', block.children || []);
|
|
156
|
+
continue;
|
|
157
|
+
}
|
|
158
|
+
if (node.type === 'SlotPlaceholder') {
|
|
159
|
+
const placeholder = node;
|
|
160
|
+
slots.set(placeholder.name || 'default', placeholder.children || []);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
return slots;
|
|
164
|
+
}
|
|
165
|
+
function stripSlotDeclarationNodes(nodes) {
|
|
166
|
+
return nodes.filter((node) => node.type !== 'TemplateBlock' && node.type !== 'SlotPlaceholder');
|
|
167
|
+
}
|
|
168
|
+
function injectSlots(layoutNodes, slots, defaultContent, source) {
|
|
169
|
+
const result = [];
|
|
170
|
+
for (const node of layoutNodes) {
|
|
171
|
+
if (node.type === 'Slot') {
|
|
172
|
+
const slot = node;
|
|
173
|
+
const slotName = slot.name || 'default';
|
|
174
|
+
if (slots.has(slotName)) {
|
|
175
|
+
result.push(...(slots.get(slotName) || []));
|
|
176
|
+
continue;
|
|
177
|
+
}
|
|
178
|
+
if (slotName === 'default' && defaultContent.length > 0) {
|
|
179
|
+
result.push(...defaultContent);
|
|
180
|
+
continue;
|
|
181
|
+
}
|
|
182
|
+
if (slot.fallback && slot.fallback.length > 0) {
|
|
183
|
+
result.push(...slot.fallback);
|
|
184
|
+
continue;
|
|
185
|
+
}
|
|
186
|
+
if (slotName !== 'default') {
|
|
187
|
+
throw new CompileError(`Missing slot content for: ${slotName}`, source);
|
|
188
|
+
}
|
|
189
|
+
continue;
|
|
190
|
+
}
|
|
191
|
+
if (node.type === 'Element') {
|
|
192
|
+
result.push({
|
|
193
|
+
...node,
|
|
194
|
+
children: injectSlots(node.children || [], slots, defaultContent, source),
|
|
195
|
+
});
|
|
196
|
+
continue;
|
|
197
|
+
}
|
|
198
|
+
result.push(node);
|
|
199
|
+
}
|
|
200
|
+
return result;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Compile error class
|
|
204
|
+
*/
|
|
205
|
+
export class CompileError extends Error {
|
|
206
|
+
constructor(message, source) {
|
|
207
|
+
super(message);
|
|
208
|
+
this.source = source;
|
|
209
|
+
this.name = 'CompileError';
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
//# sourceMappingURL=resolveLayout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveLayout.js","sourceRoot":"","sources":["../../src/compiler/resolveLayout.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAWxD,MAAM,aAAa,GAAG,CAAC,SAAS,EAAE,SAAS,EAAE,WAAW,CAAU,CAAC;AAUnE;;GAEG;AACH,MAAM,UAAU,a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AY,CAAC,6BAA6B,QAAQ,EAAE,EAAE,MAAM,CAAC,CAAC;YAC1E,CAAC;YAED,SAAS;QACX,CAAC;QAED,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;YAC5B,MAAM,CAAC,IAAI,CAAC;gBACV,GAAG,IAAI;gBACP,QAAQ,EAAE,WAAW,CAAC,IAAI,CAAC,QAAQ,IAAI,EAAE,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,CAAC;aAC1E,CAAC,CAAC;YACH,SAAS;QACX,CAAC;QAED,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACpB,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;GAEG;AACH,MAAM,OAAO,YAAa,SAAQ,KAAK;IACrC,YAAY,OAAe,EAAS,MAAc;QAChD,KAAK,CAAC,OAAO,CAAC,CAAC;QADmB,WAAM,GAAN,MAAM,CAAQ;QAEhD,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;IAC7B,CAAC;CACF"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { parseTemplate } from './parser/htmlParser.js';
|
|
2
|
+
export type { FeedAST, FeedASTNode, FeedASTNodeType, DirectiveType, BaseFeedASTNode, FeedElementNode, FeedTextNode, FeedCommentNode, FeedFragmentNode, FeedSlotNode, FeedSlotPlaceholderNode, FeedTemplateBlockNode, } from './ast/nodes.js';
|
|
3
|
+
export { transformAST, type IRNode, type IRNodeKind, type IRProps, type IRDirective, } from './ir/transform.js';
|
|
4
|
+
export { createVDOM, FragmentSymbol, TextSymbol, isTextVNode, isFragment, getVNodeType, type VNode, type VNodeProps, type VNodePropValue, type VNodeChild, type VNodeState, } from './vdom/vnode.js';
|
|
5
|
+
export { diff, applyPatches, type Patch, type PatchType, type PatchList } from './vdom/diff.js';
|
|
6
|
+
export { resolveLayout, CompileError } from './compiler/resolveLayout.js';
|
|
7
|
+
export { mergeSlots, extractSlots } from './compiler/mergeSlots.js';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAGvD,YAAY,EACV,OAAO,EACP,WAAW,EACX,eAAe,EACf,aAAa,EACb,eAAe,EACf,eAAe,EACf,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,YAAY,EACZ,uBAAuB,EACvB,qBAAqB,GACtB,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EACL,YAAY,EACZ,KAAK,MAAM,EACX,KAAK,UAAU,EACf,KAAK,OAAO,EACZ,KAAK,WAAW,GACjB,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EACL,UAAU,EACV,cAAc,EACd,UAAU,EACV,WAAW,EACX,UAAU,EACV,YAAY,EACZ,KAAK,KAAK,EACV,KAAK,UAAU,EACf,KAAK,cAAc,EACnB,KAAK,UAAU,EACf,KAAK,UAAU,GAChB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,KAAK,KAAK,EAAE,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAGhG,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC1E,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC"}
|