illimi-runtime 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 +130 -0
- package/dist/directives/bind.d.ts +8 -0
- package/dist/directives/bind.d.ts.map +1 -0
- package/dist/directives/bind.js +69 -0
- package/dist/directives/bind.js.map +1 -0
- package/dist/directives/evaluator.d.ts +40 -0
- package/dist/directives/evaluator.d.ts.map +1 -0
- package/dist/directives/evaluator.js +125 -0
- package/dist/directives/evaluator.js.map +1 -0
- package/dist/directives/for.d.ts +9 -0
- package/dist/directives/for.d.ts.map +1 -0
- package/dist/directives/for.js +67 -0
- package/dist/directives/for.js.map +1 -0
- package/dist/directives/html.d.ts +8 -0
- package/dist/directives/html.d.ts.map +1 -0
- package/dist/directives/html.js +11 -0
- package/dist/directives/html.js.map +1 -0
- package/dist/directives/if.d.ts +12 -0
- package/dist/directives/if.d.ts.map +1 -0
- package/dist/directives/if.js +15 -0
- package/dist/directives/if.js.map +1 -0
- package/dist/directives/index.d.ts +16 -0
- package/dist/directives/index.d.ts.map +1 -0
- package/dist/directives/index.js +16 -0
- package/dist/directives/index.js.map +1 -0
- package/dist/directives/model.d.ts +8 -0
- package/dist/directives/model.d.ts.map +1 -0
- package/dist/directives/model.js +38 -0
- package/dist/directives/model.js.map +1 -0
- package/dist/directives/on.d.ts +8 -0
- package/dist/directives/on.d.ts.map +1 -0
- package/dist/directives/on.js +50 -0
- package/dist/directives/on.js.map +1 -0
- package/dist/directives/show.d.ts +8 -0
- package/dist/directives/show.d.ts.map +1 -0
- package/dist/directives/show.js +11 -0
- package/dist/directives/show.js.map +1 -0
- package/dist/directives/text.d.ts +12 -0
- package/dist/directives/text.d.ts.map +1 -0
- package/dist/directives/text.js +15 -0
- package/dist/directives/text.js.map +1 -0
- package/dist/directives/types.d.ts +27 -0
- package/dist/directives/types.d.ts.map +1 -0
- package/dist/directives/types.js +7 -0
- package/dist/directives/types.js.map +1 -0
- package/dist/dom/createNode.d.ts +14 -0
- package/dist/dom/createNode.d.ts.map +1 -0
- package/dist/dom/createNode.js +304 -0
- package/dist/dom/createNode.js.map +1 -0
- package/dist/dom/events.d.ts +22 -0
- package/dist/dom/events.d.ts.map +1 -0
- package/dist/dom/events.js +104 -0
- package/dist/dom/events.js.map +1 -0
- package/dist/dom/updateProps.d.ts +15 -0
- package/dist/dom/updateProps.d.ts.map +1 -0
- package/dist/dom/updateProps.js +51 -0
- package/dist/dom/updateProps.js.map +1 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -0
- package/dist/jquery/bridge.d.ts +39 -0
- package/dist/jquery/bridge.d.ts.map +1 -0
- package/dist/jquery/bridge.js +59 -0
- package/dist/jquery/bridge.js.map +1 -0
- package/dist/providers/storage.d.ts +24 -0
- package/dist/providers/storage.d.ts.map +1 -0
- package/dist/providers/storage.js +126 -0
- package/dist/providers/storage.js.map +1 -0
- package/dist/renderer/hydrate.d.ts +22 -0
- package/dist/renderer/hydrate.d.ts.map +1 -0
- package/dist/renderer/hydrate.js +105 -0
- package/dist/renderer/hydrate.js.map +1 -0
- package/dist/renderer/mount.d.ts +15 -0
- package/dist/renderer/mount.d.ts.map +1 -0
- package/dist/renderer/mount.js +70 -0
- package/dist/renderer/mount.js.map +1 -0
- package/dist/renderer/patch.d.ts +15 -0
- package/dist/renderer/patch.d.ts.map +1 -0
- package/dist/renderer/patch.js +147 -0
- package/dist/renderer/patch.js.map +1 -0
- package/dist/router/index.d.ts +15 -0
- package/dist/router/index.d.ts.map +1 -0
- package/dist/router/index.js +263 -0
- package/dist/router/index.js.map +1 -0
- package/dist/router/types.d.ts +67 -0
- package/dist/router/types.d.ts.map +1 -0
- package/dist/router/types.js +5 -0
- package/dist/router/types.js.map +1 -0
- package/dist/state/store.d.ts +15 -0
- package/dist/state/store.d.ts.map +1 -0
- package/dist/state/store.js +36 -0
- package/dist/state/store.js.map +1 -0
- package/package.json +42 -0
- package/tsconfig.base.json +28 -0
- package/tsconfig.json +7 -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,130 @@
|
|
|
1
|
+
# FeedJS Runtime
|
|
2
|
+
|
|
3
|
+
FeedJS Runtime provides the browser-side functionality to render FeedJS templates. It handles DOM creation, event binding, state management, and client-side routing.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **DOM Rendering**: Creates actual DOM elements from VNodes
|
|
8
|
+
- **Event Binding**: Handles `f-on:*` directives for DOM events
|
|
9
|
+
- **State Reactivity**: Simple reactive state management
|
|
10
|
+
- **Client-Side Router**: History-based routing with component-level hot module replacement
|
|
11
|
+
- **jQuery Bridge**: Optional integration with jQuery
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install @illimi/runtime
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
### Basic Rendering
|
|
22
|
+
|
|
23
|
+
```typescript
|
|
24
|
+
import { mount } from '@illimi/runtime';
|
|
25
|
+
import { createVDOM } from '@illimi/core';
|
|
26
|
+
|
|
27
|
+
const state = {
|
|
28
|
+
message: 'Hello, World!',
|
|
29
|
+
items: ['Apple', 'Banana', 'Cherry']
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const vnode = createVDOM(templateIR, state);
|
|
33
|
+
mount(document.getElementById('app')!, vnode, state);
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Router Setup
|
|
37
|
+
|
|
38
|
+
```typescript
|
|
39
|
+
import { createRouter } from '@illimi/runtime';
|
|
40
|
+
|
|
41
|
+
const router = createRouter({
|
|
42
|
+
root: document.getElementById('app')!,
|
|
43
|
+
getState: () => window.__STATE__,
|
|
44
|
+
routes: [
|
|
45
|
+
{ path: '/', page: () => import('./pages/home.feedjs.html') },
|
|
46
|
+
{ path: '/about', page: () => import('./pages/about.feedjs.html') },
|
|
47
|
+
{ path: '/users/:id', page: () => import('./pages/user.feedjs.html') }
|
|
48
|
+
]
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
router.start();
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### State Management
|
|
55
|
+
|
|
56
|
+
```typescript
|
|
57
|
+
// Define reactive state
|
|
58
|
+
const state = {
|
|
59
|
+
count: 0,
|
|
60
|
+
increment() {
|
|
61
|
+
this.count++;
|
|
62
|
+
notify(); // Trigger re-render
|
|
63
|
+
},
|
|
64
|
+
subscribe(fn) {
|
|
65
|
+
subscribers.add(fn);
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
function notify() {
|
|
70
|
+
subscribers.forEach(fn => fn());
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## API
|
|
75
|
+
|
|
76
|
+
### `mount(container: Element, vnode: VNode, state: object): void`
|
|
77
|
+
|
|
78
|
+
Mounts a VNode tree to a DOM container with the given state.
|
|
79
|
+
|
|
80
|
+
### `createRouter(options: RouterOptions): Router`
|
|
81
|
+
|
|
82
|
+
Creates a client-side router instance.
|
|
83
|
+
|
|
84
|
+
**Router Options:**
|
|
85
|
+
- `root` - Root DOM element for mounting pages
|
|
86
|
+
- `getState` - Function that returns the current application state
|
|
87
|
+
- `routes` - Array of route definitions
|
|
88
|
+
|
|
89
|
+
**Route Definition:**
|
|
90
|
+
```typescript
|
|
91
|
+
interface Route {
|
|
92
|
+
path: string; // Route path (supports :param for params)
|
|
93
|
+
page: () => Promise<any>; // Function that returns a page module
|
|
94
|
+
}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Router Methods
|
|
98
|
+
|
|
99
|
+
- `start()` - Start the router and navigate to the initial path
|
|
100
|
+
- `navigate(path: string)` - Navigate to a path programmatically
|
|
101
|
+
- `getCurrentPath()` - Get the current route path
|
|
102
|
+
|
|
103
|
+
## Event Binding
|
|
104
|
+
|
|
105
|
+
The runtime handles `f-on:*` directives automatically:
|
|
106
|
+
|
|
107
|
+
```html
|
|
108
|
+
<button f-on:click="increment">Click me</button>
|
|
109
|
+
<input f-on:input="handleInput">
|
|
110
|
+
<form f-on:submit="handleSubmit">
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## Direct Runtime Evaluation
|
|
114
|
+
|
|
115
|
+
The evaluator function can be used to evaluate expressions at runtime:
|
|
116
|
+
|
|
117
|
+
```typescript
|
|
118
|
+
import { evaluate } from '@illimi/runtime';
|
|
119
|
+
|
|
120
|
+
const scope = {
|
|
121
|
+
state: { price: 100, quantity: 2 },
|
|
122
|
+
locals: {}
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
const result = evaluate('price * quantity', scope); // Returns 200
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## License
|
|
129
|
+
|
|
130
|
+
MIT
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FeedJS Runtime - f-bind Directive
|
|
3
|
+
*
|
|
4
|
+
* Handles attribute/property binding.
|
|
5
|
+
*/
|
|
6
|
+
import type { Directive, Scope } from './types.js';
|
|
7
|
+
export declare function executeBind(el: HTMLElement, dir: Directive, scope: Scope): void;
|
|
8
|
+
//# sourceMappingURL=bind.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bind.d.ts","sourceRoot":"","sources":["../../src/directives/bind.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAoCnD,wBAAgB,WAAW,CACzB,EAAE,EAAE,WAAW,EACf,GAAG,EAAE,SAAS,EACd,KAAK,EAAE,KAAK,GACX,IAAI,CAyCN"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FeedJS Runtime - f-bind Directive
|
|
3
|
+
*
|
|
4
|
+
* Handles attribute/property binding.
|
|
5
|
+
*/
|
|
6
|
+
import { evaluate, extractBindProperty } from './evaluator.js';
|
|
7
|
+
function normalizeClass(value) {
|
|
8
|
+
if (Array.isArray(value)) {
|
|
9
|
+
return value.filter(Boolean).map(String).join(' ');
|
|
10
|
+
}
|
|
11
|
+
if (value && typeof value === 'object') {
|
|
12
|
+
return Object.entries(value)
|
|
13
|
+
.filter(([, enabled]) => Boolean(enabled))
|
|
14
|
+
.map(([className]) => className)
|
|
15
|
+
.join(' ');
|
|
16
|
+
}
|
|
17
|
+
return String(value ?? '');
|
|
18
|
+
}
|
|
19
|
+
function applyStyle(el, value) {
|
|
20
|
+
if (value == null) {
|
|
21
|
+
el.removeAttribute('style');
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
if (typeof value === 'string') {
|
|
25
|
+
el.style.cssText = value;
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
if (typeof value === 'object') {
|
|
29
|
+
for (const [prop, styleValue] of Object.entries(value)) {
|
|
30
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
31
|
+
el.style[prop] = styleValue == null ? '' : String(styleValue);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
export function executeBind(el, dir, scope) {
|
|
36
|
+
const prop = extractBindProperty(dir.name);
|
|
37
|
+
const value = evaluate(dir.expression, scope);
|
|
38
|
+
if (prop === 'className' || prop === 'class') {
|
|
39
|
+
el.className = normalizeClass(value);
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
if (prop === 'style') {
|
|
43
|
+
applyStyle(el, value);
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
if (prop === 'value') {
|
|
47
|
+
el.value = String(value ?? '');
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
if (prop === 'checked') {
|
|
51
|
+
el.checked = Boolean(value);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
if (value === true) {
|
|
55
|
+
el.setAttribute(prop, '');
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
if (value === false || value === null || value === undefined) {
|
|
59
|
+
el.removeAttribute(prop);
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
if (prop in el) {
|
|
63
|
+
// Keep DOM properties in sync when possible (value, disabled, etc).
|
|
64
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
65
|
+
el[prop] = value;
|
|
66
|
+
}
|
|
67
|
+
el.setAttribute(prop, String(value));
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=bind.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E,EAAE,CAAC;QACf,oEAAoE;QACpE,8DAA8D;QAC7D,EAAU,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC;IAC5B,CAAC;IAED,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;AACvC,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FeedJS Runtime - Expression Evaluator
|
|
3
|
+
*
|
|
4
|
+
* Expression evaluation utility used by directives/interpolation.
|
|
5
|
+
*/
|
|
6
|
+
import type { Scope } from './types.js';
|
|
7
|
+
/**
|
|
8
|
+
* Evaluate an expression within a scope.
|
|
9
|
+
*/
|
|
10
|
+
export declare function evaluate(expr: string, scope: Scope): unknown;
|
|
11
|
+
/**
|
|
12
|
+
* Execute an expression as a statement.
|
|
13
|
+
* Useful for inline event expressions: count++, todos.push(item), etc.
|
|
14
|
+
*/
|
|
15
|
+
export declare function execute(expr: string, scope: Scope): unknown;
|
|
16
|
+
/**
|
|
17
|
+
* Extract property name from bind directive.
|
|
18
|
+
*/
|
|
19
|
+
export declare function extractBindProperty(name: string): string;
|
|
20
|
+
/**
|
|
21
|
+
* Extract event name from on directive.
|
|
22
|
+
*/
|
|
23
|
+
export declare function extractEventName(name: string): string;
|
|
24
|
+
/**
|
|
25
|
+
* Parse for loop expressions.
|
|
26
|
+
* Supported:
|
|
27
|
+
* - item in items
|
|
28
|
+
* - item of items
|
|
29
|
+
* - (item, index) in items
|
|
30
|
+
*/
|
|
31
|
+
export declare function parseForExpression(expr: string): {
|
|
32
|
+
item: string;
|
|
33
|
+
index?: string;
|
|
34
|
+
source: string;
|
|
35
|
+
} | null;
|
|
36
|
+
/**
|
|
37
|
+
* Assign a value to a dotted path on an object (state.foo.bar).
|
|
38
|
+
*/
|
|
39
|
+
export declare function assignPath(target: Record<string, unknown>, path: string, value: unknown): void;
|
|
40
|
+
//# sourceMappingURL=evaluator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evaluator.d.ts","sourceRoot":"","sources":["../../src/directives/evaluator.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAUxC;;GAEG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,GAAG,OAAO,CA6B5D;AAED;;;GAGG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,GAAG,OAAO,CAwB3D;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAIxD;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAErD;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAmBxG;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CA0B9F"}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FeedJS Runtime - Expression Evaluator
|
|
3
|
+
*
|
|
4
|
+
* Expression evaluation utility used by directives/interpolation.
|
|
5
|
+
*/
|
|
6
|
+
const fnCache = new Map();
|
|
7
|
+
function buildCacheKey(expr, keys) {
|
|
8
|
+
return `${expr}::${keys.join('|')}`;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Evaluate an expression within a scope.
|
|
12
|
+
*/
|
|
13
|
+
export function evaluate(expr, scope) {
|
|
14
|
+
if (!expr)
|
|
15
|
+
return undefined;
|
|
16
|
+
const context = {
|
|
17
|
+
...scope.state,
|
|
18
|
+
...scope.locals,
|
|
19
|
+
$state: scope.state,
|
|
20
|
+
$locals: scope.locals,
|
|
21
|
+
};
|
|
22
|
+
try {
|
|
23
|
+
const keys = Object.keys(context);
|
|
24
|
+
const values = keys.map((key) => context[key]);
|
|
25
|
+
const cacheKey = buildCacheKey(expr, keys);
|
|
26
|
+
let fn = fnCache.get(cacheKey);
|
|
27
|
+
if (!fn) {
|
|
28
|
+
fn = new Function(...keys, `"use strict"; return (${expr});`);
|
|
29
|
+
fnCache.set(cacheKey, fn);
|
|
30
|
+
}
|
|
31
|
+
return fn(...values);
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
console.error(`[Illimi] Expression evaluation error: ${expr}`, error);
|
|
35
|
+
return undefined;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Execute an expression as a statement.
|
|
40
|
+
* Useful for inline event expressions: count++, todos.push(item), etc.
|
|
41
|
+
*/
|
|
42
|
+
export function execute(expr, scope) {
|
|
43
|
+
if (!expr)
|
|
44
|
+
return undefined;
|
|
45
|
+
const context = {
|
|
46
|
+
...scope.state,
|
|
47
|
+
...scope.locals,
|
|
48
|
+
$state: scope.state,
|
|
49
|
+
$locals: scope.locals,
|
|
50
|
+
};
|
|
51
|
+
try {
|
|
52
|
+
const keys = Object.keys(context);
|
|
53
|
+
const values = Object.values(context);
|
|
54
|
+
const fn = new Function(...keys, `"use strict"; ${expr}`);
|
|
55
|
+
return fn(...values);
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
console.error(`[Illimi] Expression execution error: ${expr}`, error);
|
|
59
|
+
return undefined;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Extract property name from bind directive.
|
|
64
|
+
*/
|
|
65
|
+
export function extractBindProperty(name) {
|
|
66
|
+
const prop = name.replace(/^(?:x|f)-bind:/, '');
|
|
67
|
+
if (prop === 'class')
|
|
68
|
+
return 'className';
|
|
69
|
+
return prop;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Extract event name from on directive.
|
|
73
|
+
*/
|
|
74
|
+
export function extractEventName(name) {
|
|
75
|
+
return name.replace(/^(?:x|f)-on:/, '').split('.')[0] || '';
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Parse for loop expressions.
|
|
79
|
+
* Supported:
|
|
80
|
+
* - item in items
|
|
81
|
+
* - item of items
|
|
82
|
+
* - (item, index) in items
|
|
83
|
+
*/
|
|
84
|
+
export function parseForExpression(expr) {
|
|
85
|
+
const trimmed = expr.trim();
|
|
86
|
+
const match = trimmed.match(/^(?:\(\s*([A-Za-z_$][\w$]*)(?:\s*,\s*([A-Za-z_$][\w$]*))?\s*\)|([A-Za-z_$][\w$]*))\s+(?:in|of)\s+([\s\S]+)$/);
|
|
87
|
+
if (!match)
|
|
88
|
+
return null;
|
|
89
|
+
const item = match[1] || match[3] || '';
|
|
90
|
+
const index = match[2] || undefined;
|
|
91
|
+
const source = (match[4] || '').trim();
|
|
92
|
+
if (!item || !source)
|
|
93
|
+
return null;
|
|
94
|
+
if (index) {
|
|
95
|
+
return { item, index, source };
|
|
96
|
+
}
|
|
97
|
+
return { item, source };
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Assign a value to a dotted path on an object (state.foo.bar).
|
|
101
|
+
*/
|
|
102
|
+
export function assignPath(target, path, value) {
|
|
103
|
+
const segments = path
|
|
104
|
+
.split('.')
|
|
105
|
+
.map((segment) => segment.trim())
|
|
106
|
+
.filter(Boolean);
|
|
107
|
+
if (segments.length === 0)
|
|
108
|
+
return;
|
|
109
|
+
let cursor = target;
|
|
110
|
+
for (let i = 0; i < segments.length - 1; i++) {
|
|
111
|
+
const key = segments[i];
|
|
112
|
+
if (!key)
|
|
113
|
+
return;
|
|
114
|
+
const current = cursor[key];
|
|
115
|
+
if (!current || typeof current !== 'object') {
|
|
116
|
+
cursor[key] = {};
|
|
117
|
+
}
|
|
118
|
+
cursor = cursor[key];
|
|
119
|
+
}
|
|
120
|
+
const last = segments[segments.length - 1];
|
|
121
|
+
if (!last)
|
|
122
|
+
return;
|
|
123
|
+
cursor[last] = value;
|
|
124
|
+
}
|
|
125
|
+
//# sourceMappingURL=evaluator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evaluator.js","sourceRoot":"","sources":["../../src/directives/evaluator.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,MAAM,OAAO,GAAG,IAAI,GAAG,EAAwB,CAAC;AAEhD,SAAS,aAAa,CAAC,IAAY,EAAE,IAAc;IACjD,OAAO,GAAG,IAAI,KAAK,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;AACtC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,QAAQ,CAAC,IAAY,EAAE,KAAY;IACjD,IAAI,CAAC,IAAI;QAAE,OAAO,SAAS,CAAC;IAE5B,MAAM,OAAO,GAAG;QACd,GAAG,KAAK,CAAC,KAAK;QACd,GAAG,KAAK,CAAC,MAAM;QACf,MAAM,EAAE,KAAK,CAAC,KAAK;QACnB,OAAO,EAAE,KAAK,CAAC,MAAM;KACK,CAAC;IAE7B,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAClC,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC;QAC/C,MAAM,QAAQ,GAAG,aAAa,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAE3C,IAAI,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAC/B,IAAI,CAAC,EAAE,EAAE,CAAC;YACR,EAAE,GAAG,IAAI,QAAQ,CACf,GAAG,IAAI,EACP,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E,OAAO;IAElC,IAAI,MAAM,GAA4B,MAAM,CAAC;IAE7C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAC7C,MAAM,GAAG,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;QACxB,IAAI,CAAC,GAAG;YAAE,OAAO;QAEjB,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;QAC5B,IAAI,CAAC,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;YAC5C,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC;QACnB,CAAC;QAED,MAAM,GAAG,MAAM,CAAC,GAAG,CAA4B,CAAC;IAClD,CAAC;IAED,MAAM,IAAI,GAAG,QAAQ,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAC3C,IAAI,CAAC,IAAI;QAAE,OAAO;IAElB,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC;AACvB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FeedJS Runtime - f-for Directive
|
|
3
|
+
*
|
|
4
|
+
* Handles list/object rendering.
|
|
5
|
+
*/
|
|
6
|
+
import type { Directive, Scope } from './types.js';
|
|
7
|
+
import type { VNode as FeedVNode } from '@illimi/core';
|
|
8
|
+
export declare function executeFor(vnode: FeedVNode, dir: Directive, scope: Scope): Node[];
|
|
9
|
+
//# sourceMappingURL=for.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"for.d.ts","sourceRoot":"","sources":["../../src/directives/for.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,KAAK,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,cAAc,CAAC;AAiBvD,wBAAgB,UAAU,CACxB,KAAK,EAAE,SAAS,EAChB,GAAG,EAAE,SAAS,EACd,KAAK,EAAE,KAAK,GACX,IAAI,EAAE,CAwDR"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FeedJS Runtime - f-for Directive
|
|
3
|
+
*
|
|
4
|
+
* Handles list/object rendering.
|
|
5
|
+
*/
|
|
6
|
+
import { evaluate, parseForExpression } from './evaluator.js';
|
|
7
|
+
import { createNode } from '../dom/createNode.js';
|
|
8
|
+
function cloneWithoutFor(vnode) {
|
|
9
|
+
const clonedChildren = Array.isArray(vnode.children)
|
|
10
|
+
? vnode.children.map((child) => cloneWithoutFor(child))
|
|
11
|
+
: vnode.children;
|
|
12
|
+
const directives = (vnode.directives || []).filter((d) => d.type !== 'for');
|
|
13
|
+
return {
|
|
14
|
+
...vnode,
|
|
15
|
+
children: clonedChildren,
|
|
16
|
+
directives,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export function executeFor(vnode, dir, scope) {
|
|
20
|
+
const parsed = parseForExpression(dir.expression);
|
|
21
|
+
if (!parsed) {
|
|
22
|
+
console.error(`[Illimi] Invalid f-for expression: ${dir.expression}`);
|
|
23
|
+
return [];
|
|
24
|
+
}
|
|
25
|
+
const { item, index, source } = parsed;
|
|
26
|
+
const collection = evaluate(source, scope);
|
|
27
|
+
const fragment = document.createDocumentFragment();
|
|
28
|
+
if (Array.isArray(collection)) {
|
|
29
|
+
for (let i = 0; i < collection.length; i++) {
|
|
30
|
+
const childScope = {
|
|
31
|
+
state: scope.state,
|
|
32
|
+
locals: {
|
|
33
|
+
...scope.locals,
|
|
34
|
+
[item]: collection[i],
|
|
35
|
+
[index || '$index']: i,
|
|
36
|
+
$index: i,
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
const node = createNode(cloneWithoutFor(vnode), childScope);
|
|
40
|
+
if (node)
|
|
41
|
+
fragment.appendChild(node);
|
|
42
|
+
}
|
|
43
|
+
return [fragment];
|
|
44
|
+
}
|
|
45
|
+
if (collection && typeof collection === 'object') {
|
|
46
|
+
const entries = Object.entries(collection);
|
|
47
|
+
for (let i = 0; i < entries.length; i++) {
|
|
48
|
+
const [key, value] = entries[i] || [];
|
|
49
|
+
const childScope = {
|
|
50
|
+
state: scope.state,
|
|
51
|
+
locals: {
|
|
52
|
+
...scope.locals,
|
|
53
|
+
[item]: value,
|
|
54
|
+
[index || '$index']: key,
|
|
55
|
+
$index: i,
|
|
56
|
+
$key: key,
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
const node = createNode(cloneWithoutFor(vnode), childScope);
|
|
60
|
+
if (node)
|
|
61
|
+
fragment.appendChild(node);
|
|
62
|
+
}
|
|
63
|
+
return [fragment];
|
|
64
|
+
}
|
|
65
|
+
return [];
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=for.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"for.js","sourceRoot":"","sources":["../../src/directives/for.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,QAAQ,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAG9D,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD,SAAS,eAAe,CAAC,KAAgB;IACvC,MAAM,cAAc,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC;QAClD,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,KAAgB,EAAE,EAAE,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;QAClE,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC;IAEnB,MAAM,UAAU,GAAG,CAAE,KAAa,CAAC,UAAU,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAY,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,KAAK,CAAC,CAAC;IAEhG,OAAO;QACL,GAAG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CAAC;QACjD,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,UAAqC,CAAC,CAAC;QAEtE,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACxC,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;YAEtC,MAAM,UAAU,GAAU;gBACxB,KAAK,EAAE,KAAK,CAAC,KAAK;gBAClB,MAAM,EAAE;oBACN,GAAG,KAAK,CAAC,MAAM;oBACf,CAAC,IAAI,CAAC,EAAE,KAAK;oBACb,CAAC,KAAK,IAAI,QAAQ,CAAC,EAAE,GAAG;oBACxB,MAAM,EAAE,CAAC;oBACT,IAAI,EAAE,GAAG;iBACV;aACF,CAAC;YAEF,MAAM,IAAI,GAAG,UAAU,CAAC,eAAe,CAAC,KAAK,CAAC,EAAE,UAAU,CAAC,CAAC;YAC5D,IAAI,IAAI;gBAAE,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QACvC,CAAC;QAED,OAAO,CAAC,QAAQ,CAAC,CAAC;IACpB,CAAC;IAED,OAAO,EAAE,CAAC;AACZ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"html.d.ts","sourceRoot":"","sources":["../../src/directives/html.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnD,wBAAgB,WAAW,CAAC,EAAE,EAAE,WAAW,EAAE,GAAG,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,GAAG,IAAI,CAG/E"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FeedJS Runtime - f-html Directive
|
|
3
|
+
*
|
|
4
|
+
* Sets raw HTML content.
|
|
5
|
+
*/
|
|
6
|
+
import { evaluate } from './evaluator.js';
|
|
7
|
+
export function executeHtml(el, dir, scope) {
|
|
8
|
+
const value = evaluate(dir.expression, scope);
|
|
9
|
+
el.innerHTML = String(value ?? '');
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=html.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"html.js","sourceRoot":"","sources":["../../src/directives/html.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAG1C,MAAM,UAAU,WAAW,CAAC,EAAe,EAAE,GAAc,EAAE,KAAY;IACvE,MAAM,KAAK,GAAG,QAAQ,CAAC,GAAG,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;IAC9C,EAAE,CAAC,SAAS,GAAG,MAAM,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;AACrC,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FeedJS Runtime - f-if Directive
|
|
3
|
+
*
|
|
4
|
+
* Handles conditional rendering.
|
|
5
|
+
*/
|
|
6
|
+
import type { Directive, Scope } from './types.js';
|
|
7
|
+
/**
|
|
8
|
+
* Execute f-if directive
|
|
9
|
+
* Returns whether to render the node
|
|
10
|
+
*/
|
|
11
|
+
export declare function executeIf(dir: Directive, scope: Scope): boolean;
|
|
12
|
+
//# sourceMappingURL=if.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"if.d.ts","sourceRoot":"","sources":["../../src/directives/if.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnD;;;GAGG;AACH,wBAAgB,SAAS,CACvB,GAAG,EAAE,SAAS,EACd,KAAK,EAAE,KAAK,GACX,OAAO,CAGT"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FeedJS Runtime - f-if Directive
|
|
3
|
+
*
|
|
4
|
+
* Handles conditional rendering.
|
|
5
|
+
*/
|
|
6
|
+
import { evaluate } from './evaluator.js';
|
|
7
|
+
/**
|
|
8
|
+
* Execute f-if directive
|
|
9
|
+
* Returns whether to render the node
|
|
10
|
+
*/
|
|
11
|
+
export function executeIf(dir, scope) {
|
|
12
|
+
const result = evaluate(dir.expression, scope);
|
|
13
|
+
return !!result;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=if.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"if.js","sourceRoot":"","sources":["../../src/directives/if.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAG1C;;;GAGG;AACH,MAAM,UAAU,SAAS,CACvB,GAAc,EACd,KAAY;IAEZ,MAAM,MAAM,GAAG,QAAQ,CAAC,GAAG,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;IAC/C,OAAO,CAAC,CAAC,MAAM,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FeedJS Runtime - Directives
|
|
3
|
+
*
|
|
4
|
+
* Directive execution engine for the FeedJS runtime.
|
|
5
|
+
*/
|
|
6
|
+
export * from './types.js';
|
|
7
|
+
export * from './evaluator.js';
|
|
8
|
+
export { executeText } from './text.js';
|
|
9
|
+
export { executeHtml } from './html.js';
|
|
10
|
+
export { executeBind } from './bind.js';
|
|
11
|
+
export { executeOn } from './on.js';
|
|
12
|
+
export { executeIf } from './if.js';
|
|
13
|
+
export { executeFor } from './for.js';
|
|
14
|
+
export { executeShow } from './show.js';
|
|
15
|
+
export { executeModel } from './model.js';
|
|
16
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/directives/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FeedJS Runtime - Directives
|
|
3
|
+
*
|
|
4
|
+
* Directive execution engine for the FeedJS runtime.
|
|
5
|
+
*/
|
|
6
|
+
export * from './types.js';
|
|
7
|
+
export * from './evaluator.js';
|
|
8
|
+
export { executeText } from './text.js';
|
|
9
|
+
export { executeHtml } from './html.js';
|
|
10
|
+
export { executeBind } from './bind.js';
|
|
11
|
+
export { executeOn } from './on.js';
|
|
12
|
+
export { executeIf } from './if.js';
|
|
13
|
+
export { executeFor } from './for.js';
|
|
14
|
+
export { executeShow } from './show.js';
|
|
15
|
+
export { executeModel } from './model.js';
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/directives/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FeedJS Runtime - f-model Directive
|
|
3
|
+
*
|
|
4
|
+
* Two-way binding for input/select/textarea-like elements.
|
|
5
|
+
*/
|
|
6
|
+
import type { Directive, Scope } from './types.js';
|
|
7
|
+
export declare function executeModel(el: HTMLElement, dir: Directive, scope: Scope): void;
|
|
8
|
+
//# sourceMappingURL=model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../src/directives/model.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAmBnD,wBAAgB,YAAY,CAAC,EAAE,EAAE,WAAW,EAAE,GAAG,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,GAAG,IAAI,CAmBhF"}
|