illimi-vite 1.0.0-a

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 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,142 @@
1
+ # Illimi Vite Plugin
2
+
3
+ Illimi Vite Plugin integrates Illimi templates into the Vite build pipeline. It compiles `.illimi.html` files to JavaScript modules that can be rendered by the Illimi runtime.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install illimi-vite
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ### Basic Configuration
14
+
15
+ Create or update `vite.config.ts` in your project:
16
+
17
+ ```typescript
18
+ import { defineConfig } from 'vite';
19
+ import illimi from 'illimi-vite';
20
+
21
+ export default defineConfig({
22
+ plugins: [illimi()]
23
+ });
24
+ ```
25
+
26
+ ### With Options
27
+
28
+ ```typescript
29
+ import { defineConfig } from 'vite';
30
+ import illimi from 'illimi-vite';
31
+
32
+ export default defineConfig({
33
+ plugins: [
34
+ illimi({
35
+ debug: true // Enable debug logging
36
+ })
37
+ ]
38
+ });
39
+ ```
40
+
41
+ ### Project Structure
42
+
43
+ ```
44
+ my-app/
45
+ ├── src/
46
+ │ ├── pages/
47
+ │ │ ├── index.illimi.html
48
+ │ │ └── todo.illimi.html
49
+ │ ├── layout/
50
+ │ │ └── main.illimi.html
51
+ │ ├── main.ts
52
+ │ └── state.ts
53
+ ├── index.html
54
+ ├── vite.config.ts
55
+ └── package.json
56
+ ```
57
+
58
+ ## Features
59
+
60
+ ### Template Compilation
61
+
62
+ The plugin compiles `.illimi.html` files to JavaScript modules:
63
+
64
+ **Input (todo.illimi.html):**
65
+ ```html
66
+ <div class="todo">
67
+ <h1 f-text="title"></h1>
68
+ <ul>
69
+ <li f-for="todo in todos" f-key="todo.id">
70
+ {{ todo.text }}
71
+ </li>
72
+ </ul>
73
+ </div>
74
+ ```
75
+
76
+ **Output (compiled):**
77
+ ```javascript
78
+ import { createVDOM } from 'illimi-core';
79
+
80
+ export function render(state, context) {
81
+ return createVDOM([...IR nodes...], state);
82
+ }
83
+
84
+ export default render;
85
+ ```
86
+
87
+ ### Layout Resolution
88
+
89
+ The plugin resolves `<layout src="...">` elements and merges them with page content:
90
+
91
+ ```html
92
+ <!-- todo.illimi.html -->
93
+ <layout src="../layout/main.illimi.html">
94
+ <p>Page content goes here</p>
95
+ </layout>
96
+ ```
97
+
98
+ ### Hot Module Replacement (HMR)
99
+
100
+ The plugin supports HMR for rapid development. Templates will reload without losing state.
101
+
102
+ ### Style Extraction
103
+
104
+ Styles defined in `<style>` tags are automatically extracted and injected when the template loads.
105
+
106
+ ## Configuration Options
107
+
108
+ | Option | Type | Default | Description |
109
+ |--------|------|---------|-------------|
110
+ | `debug` | `boolean` | `false` | Enable debug logging |
111
+
112
+ ## TypeScript Support
113
+
114
+ The plugin includes TypeScript declarations. No additional `@types` package required.
115
+
116
+ ## Examples
117
+
118
+ ### Todo App
119
+
120
+ See the [illimi-todo-app](../illimi-todo-app/) example project for a complete implementation.
121
+
122
+ ### Router Integration
123
+
124
+ ```typescript
125
+ // main.ts
126
+ import { createRouter } from 'illimi-runtime';
127
+
128
+ const router = createRouter({
129
+ root: document.getElementById('app')!,
130
+ getState: () => window.__STATE__,
131
+ routes: [
132
+ { path: '/', page: () => import('./pages/index.illimi.html') },
133
+ { path: '/todo', page: () => import('./pages/todo.illimi.html') }
134
+ ]
135
+ });
136
+
137
+ router.start();
138
+ ```
139
+
140
+ ## License
141
+
142
+ MIT
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Illimi Vite Plugin - Template Compiler
3
+ *
4
+ * Compiles Feed templates to JavaScript modules.
5
+ */
6
+ /**
7
+ * Compile a Feed template to JavaScript module
8
+ */
9
+ export declare function compileTemplate(source: string, id: string, resolveLayoutFile?: (src: string) => string): {
10
+ code: string;
11
+ map?: unknown;
12
+ };
13
+ /**
14
+ * Check if a file should be processed
15
+ */
16
+ export declare function shouldProcess(id: string, source?: string): boolean;
17
+ //# sourceMappingURL=compileTemplate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compileTemplate.d.ts","sourceRoot":"","sources":["../../src/compiler/compileTemplate.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAqBH;;GAEG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,MAAM,EACd,EAAE,EAAE,MAAM,EACV,iBAAiB,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,GAC1C;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,OAAO,CAAA;CAAE,CAuBjC;AAmED;;GAEG;AACH,wBAAgB,aAAa,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAqBlE"}
@@ -0,0 +1,122 @@
1
+ /**
2
+ * Illimi Vite Plugin - Template Compiler
3
+ *
4
+ * Compiles Feed templates to JavaScript modules.
5
+ */
6
+ import { parseTemplate, transformAST, resolveLayout } from 'illimi-core';
7
+ /**
8
+ * Extract style tags from template source
9
+ */
10
+ function extractStyles(source) {
11
+ const styleRegex = /<style>([\s\S]*?)<\/style>/gi;
12
+ const styles = [];
13
+ let match;
14
+ while ((match = styleRegex.exec(source)) !== null) {
15
+ if (match[1]) {
16
+ styles.push(match[1]);
17
+ }
18
+ }
19
+ return styles.join('\n');
20
+ }
21
+ /**
22
+ * Compile a Feed template to JavaScript module
23
+ */
24
+ export function compileTemplate(source, id, resolveLayoutFile) {
25
+ // Extract styles before parsing
26
+ const styles = extractStyles(source);
27
+ // Parse template to AST (styles are removed by the parser)
28
+ const ast = parseTemplate(source);
29
+ // Resolve layout if resolver is provided
30
+ let processedAST = ast;
31
+ if (resolveLayoutFile) {
32
+ processedAST = resolveLayout(ast, resolveLayoutFile);
33
+ }
34
+ // Transform AST to IR
35
+ const irNodes = transformAST(processedAST);
36
+ // Generate JavaScript code
37
+ const code = generateModule(irNodes, id, styles);
38
+ return {
39
+ code,
40
+ map: undefined, // Source map would go here in production
41
+ };
42
+ }
43
+ /**
44
+ * Generate JavaScript module code from IR
45
+ */
46
+ function generateModule(irNodes, id, styles = '') {
47
+ // Get the template name from the file ID
48
+ const templateName = getTemplateName(id);
49
+ // Generate createVDOM calls
50
+ const vdomCreationCode = generateVDOMCreation(irNodes);
51
+ // If there are styles, create a function to inject them
52
+ const stylesCode = styles
53
+ ? `
54
+ export function injectStyles() {
55
+ if (document.getElementById('illimi-styles-${templateName}')) return;
56
+ const style = document.createElement('style');
57
+ style.id = 'illimi-styles-${templateName}';
58
+ style.textContent = ${JSON.stringify(styles)};
59
+ document.head.appendChild(style);
60
+ }`
61
+ : '';
62
+ return `// Compiled by Illimi - ${id}
63
+ // Template: ${templateName}
64
+
65
+ import { createVDOM } from 'illimi-core';
66
+
67
+ export function render(state, context) {
68
+ return createVDOM(${JSON.stringify(irNodes, null, 2)}, state);
69
+ }
70
+
71
+ export default render;
72
+ ${stylesCode}`;
73
+ }
74
+ /**
75
+ * Generate VDOM creation code
76
+ * This creates a runtime representation of the IR
77
+ */
78
+ function generateVDOMCreation(irNodes) {
79
+ // For now, we serialize the IR as JSON
80
+ // In production, this could generate more optimized code
81
+ return JSON.stringify(irNodes, null, 2);
82
+ }
83
+ /**
84
+ * Get template name from file ID
85
+ */
86
+ function getTemplateName(id) {
87
+ // Extract filename from path
88
+ const parts = id.split('/');
89
+ const filename = parts[parts.length - 1] ?? 'template';
90
+ // Remove extension and convert to camelCase
91
+ const name = filename.replace(/\.[^/.]+$/, '');
92
+ return toCamelCase(name);
93
+ }
94
+ /**
95
+ * Convert kebab-case to camelCase
96
+ */
97
+ function toCamelCase(str) {
98
+ return str.replace(/[-_](\w)/g, (_, c) => (c ? c.toUpperCase() : ''));
99
+ }
100
+ /**
101
+ * Check if a file should be processed
102
+ */
103
+ export function shouldProcess(id, source) {
104
+ // Process only .html and .ilm template files
105
+ const isTemplate = id.endsWith('.html') || id.endsWith('.ilm');
106
+ const isIgnored = id.includes('node_modules') || id.includes('public');
107
+ if (!isTemplate || isIgnored)
108
+ return false;
109
+ // Do not compile full HTML documents such as Vite app entry index.html.
110
+ // We only want fragment-like page/component templates.
111
+ if (source) {
112
+ const normalized = source.trim().toLowerCase();
113
+ if (normalized.startsWith('<!doctype html') ||
114
+ normalized.includes('<html') ||
115
+ normalized.includes('<head') ||
116
+ normalized.includes('<body')) {
117
+ return false;
118
+ }
119
+ }
120
+ return true;
121
+ }
122
+ //# sourceMappingURL=compileTemplate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compileTemplate.js","sourceRoot":"","sources":["../../src/compiler/compileTemplate.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,aAAa,EAAE,YAAY,EAAc,aAAa,EAAyC,MAAM,aAAa,CAAC;AAE5H;;GAEG;AACH,SAA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AAC,QAAQ,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC/D,MAAM,SAAS,GAAG,EAAE,CAAC,QAAQ,CAAC,cAAc,CAAC,IAAI,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACvE,IAAI,CAAC,UAAU,IAAI,SAAS;QAAE,OAAO,KAAK,CAAC;IAE3C,wEAAwE;IACxE,uDAAuD;IACvD,IAAI,MAAM,EAAE,CAAC;QACX,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;QAC/C,IACE,UAAU,CAAC,UAAU,CAAC,gBAAgB,CAAC;YACvC,UAAU,CAAC,QAAQ,CAAC,OAAO,CAAC;YAC5B,UAAU,CAAC,QAAQ,CAAC,OAAO,CAAC;YAC5B,UAAU,CAAC,QAAQ,CAAC,OAAO,CAAC,EAC5B,CAAC;YACD,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Illimi Vite Plugin - Public API
3
+ *
4
+ * @packageDocumentation
5
+ */
6
+ export { default as illimi } from './plugin/index.js';
7
+ export { default } from './plugin/index.js';
8
+ export { compileTemplate, shouldProcess } from './compiler/compileTemplate.js';
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAG5C,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Illimi Vite Plugin - Public API
3
+ *
4
+ * @packageDocumentation
5
+ */
6
+ // Re-export the main plugin
7
+ export { default as illimi } from './plugin/index.js';
8
+ export { default } from './plugin/index.js';
9
+ // Re-export compiler utilities
10
+ export { compileTemplate, shouldProcess } from './compiler/compileTemplate.js';
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,4BAA4B;AAC5B,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C,+BAA+B;AAC/B,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Illimi Vite Plugin - HMR
3
+ *
4
+ * Handles Hot Module Replacement for Feed templates.
5
+ */
6
+ /**
7
+ * Handle HMR updates for template files
8
+ */
9
+ export declare function handleHotUpdate(hot: any, file: string): void;
10
+ //# sourceMappingURL=hmr.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hmr.d.ts","sourceRoot":"","sources":["../../src/plugin/hmr.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,wBAAgB,eAAe,CAE7B,GAAG,EAAE,GAAG,EACR,IAAI,EAAE,MAAM,GACX,IAAI,CAeN"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Illimi Vite Plugin - HMR
3
+ *
4
+ * Handles Hot Module Replacement for Feed templates.
5
+ */
6
+ /**
7
+ * Handle HMR updates for template files
8
+ */
9
+ export function handleHotUpdate(
10
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
11
+ hot, file) {
12
+ // Handle only .html and .ilm template files
13
+ const isTemplate = file.endsWith('.html') || file.endsWith('.ilm');
14
+ const isIgnored = file.includes('node_modules') || file.includes('public');
15
+ if (!isTemplate || isIgnored) {
16
+ return;
17
+ }
18
+ // Accept HMR and trigger update
19
+ if (hot && hot.accept) {
20
+ hot.accept();
21
+ }
22
+ // Log HMR update
23
+ console.log(`[Illimi] HMR updated: ${file}`);
24
+ }
25
+ //# sourceMappingURL=hmr.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hmr.js","sourceRoot":"","sources":["../../src/plugin/hmr.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,MAAM,UAAU,eAAe;AAC7B,8DAA8D;AAC9D,GAAQ,EACR,IAAY;IAEZ,4CAA4C;IAC5C,MAAM,UAAU,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IACnE,MAAM,SAAS,GAAG,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAC3E,IAAI,CAAC,UAAU,IAAI,SAAS,EAAE,CAAC;QAC7B,OAAO;IACT,CAAC;IAED,gCAAgC;IAChC,IAAI,GAAG,IAAI,GAAG,CAAC,MAAM,EAAE,CAAC;QACtB,GAAG,CAAC,MAAM,EAAE,CAAC;IACf,CAAC;IAED,iBAAiB;IACjB,OAAO,CAAC,GAAG,CAAC,yBAAyB,IAAI,EAAE,CAAC,CAAC;AAC/C,CAAC"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Illimi Vite Plugin - Main Plugin
3
+ *
4
+ * Integrates Illimi into the Vite build pipeline.
5
+ */
6
+ interface IllimiPluginOptions {
7
+ /** Enable debug logging */
8
+ debug?: boolean;
9
+ }
10
+ /**
11
+ * Create Illimi Vite Plugin
12
+ */
13
+ export default function illimi(options?: IllimiPluginOptions): any;
14
+ export {};
15
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/plugin/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAQH,UAAU,mBAAmB;IAC3B,2BAA2B;IAC3B,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,OAAO,GAAE,mBAAwB,GAAG,GAAG,CA2DrE"}
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Illimi Vite Plugin - Main Plugin
3
+ *
4
+ * Integrates Illimi into the Vite build pipeline.
5
+ */
6
+ import { transform } from './transform.js';
7
+ import { handleHotUpdate } from './hmr.js';
8
+ import * as fs from 'fs';
9
+ import * as path from 'path';
10
+ /**
11
+ * Create Illimi Vite Plugin
12
+ */
13
+ export default function illimi(options = {}) {
14
+ const { debug = false } = options;
15
+ return {
16
+ name: 'illimi',
17
+ /**
18
+ * Transform handler - compiles templates
19
+ */
20
+ transform(code, id) {
21
+ if (debug) {
22
+ console.log(`[Illimi] Processing: ${id}`);
23
+ }
24
+ // Get the directory of the current file - handle both /home/... and C:\... paths
25
+ let fileDir = id.substring(0, id.lastIndexOf('/'));
26
+ // Handle Windows paths
27
+ if (fileDir.includes('\\')) {
28
+ fileDir = id.substring(0, id.lastIndexOf('\\'));
29
+ }
30
+ // Create a resolver function
31
+ const resolveLayoutFile = (src) => {
32
+ // Use path.join and path.resolve for proper path handling
33
+ let resolvedPath;
34
+ if (src.startsWith('../')) {
35
+ // Relative path - resolve from the file's directory
36
+ resolvedPath = path.resolve(fileDir, src);
37
+ }
38
+ else if (src.startsWith('./')) {
39
+ resolvedPath = path.resolve(fileDir, src);
40
+ }
41
+ else {
42
+ resolvedPath = path.resolve(fileDir, src);
43
+ }
44
+ // Load the file
45
+ if (!fs.existsSync(resolvedPath)) {
46
+ throw new Error(`Layout file not found: ${resolvedPath}`);
47
+ }
48
+ return fs.readFileSync(resolvedPath, 'utf-8');
49
+ };
50
+ if (debug) {
51
+ console.log(`Transforming ${id} with Illimi`);
52
+ }
53
+ return transform(code, id, resolveLayoutFile);
54
+ },
55
+ /**
56
+ * HMR handler - handles hot module replacement
57
+ */
58
+ handleHotUpdate({ file, hot }) {
59
+ if (debug) {
60
+ console.log(`[Illimi] HMR: ${file}`);
61
+ }
62
+ handleHotUpdate(hot, file);
63
+ },
64
+ };
65
+ }
66
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/plugin/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAQ7B;;GAEG;AACH,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,UAA+B,EAAE;IAC9D,MAAM,EAAE,KAAK,GAAG,KAAK,EAAE,GAAG,OAAO,CAAC;IAElC,OAAO;QACL,IAAI,EAAE,QAAQ;QAEd;;WAEG;QACH,SAAS,CAAC,IAAY,EAAE,EAAU;YAChC,IAAI,KAAK,EAAE,CAAC;gBACV,OAAO,CAAC,GAAG,CAAC,wBAAwB,EAAE,EAAE,CAAC,CAAC;YAC5C,CAAC;YAED,iFAAiF;YACjF,IAAI,OAAO,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC;YACnD,uBAAuB;YACvB,IAAI,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;gBAC3B,OAAO,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC;YAClD,CAAC;YAED,6BAA6B;YAC7B,MAAM,iBAAiB,GAAG,CAAC,GAAW,EAAU,EAAE;gBAChD,0DAA0D;gBAC1D,IAAI,YAAoB,CAAC;gBAEzB,IAAI,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;oBAC1B,oDAAoD;oBACpD,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;gBAC5C,CAAC;qBAAM,IAAI,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;oBAChC,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;gBAC5C,CAAC;qBAAM,CAAC;oBACN,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;gBAC5C,CAAC;gBAED,gBAAgB;gBAChB,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC;oBACjC,MAAM,IAAI,KAAK,CAAC,0BAA0B,YAAY,EAAE,CAAC,CAAC;gBAC5D,CAAC;gBACD,OAAO,EAAE,CAAC,YAAY,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;YAChD,CAAC,CAAC;YAEF,IAAI,KAAK,EAAE,CAAC;gBACV,OAAO,CAAC,GAAG,CAAC,gBAAgB,EAAE,cAAc,CAAC,CAAC;YAChD,CAAC;YAED,OAAO,SAAS,CAAC,IAAI,EAAE,EAAE,EAAE,iBAAiB,CAAC,CAAC;QAChD,CAAC;QAED;;WAEG;QACH,eAAe,CAAC,EAAE,IAAI,EAAE,GAAG,EAAkC;YAC3D,IAAI,KAAK,EAAE,CAAC;gBACV,OAAO,CAAC,GAAG,CAAC,iBAAiB,IAAI,EAAE,CAAC,CAAC;YACvC,CAAC;YACD,eAAe,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QAC7B,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Illimi Vite Plugin - Transform
3
+ *
4
+ * Transforms Feed template files to JavaScript modules.
5
+ */
6
+ /**
7
+ * Transform handler for Vite
8
+ */
9
+ export declare function transform(code: string, id: string, resolveLayout?: (src: string) => string): {
10
+ code: string;
11
+ map?: unknown;
12
+ } | null;
13
+ //# sourceMappingURL=transform.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../../src/plugin/transform.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH;;GAEG;AACH,wBAAgB,SAAS,CACvB,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM,EACV,aAAa,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,GACtC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,IAAI,CAcxC"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Illimi Vite Plugin - Transform
3
+ *
4
+ * Transforms Feed template files to JavaScript modules.
5
+ */
6
+ import { compileTemplate, shouldProcess } from '../compiler/compileTemplate.js';
7
+ /**
8
+ * Transform handler for Vite
9
+ */
10
+ export function transform(code, id, resolveLayout) {
11
+ // Check if we should process this file
12
+ if (!shouldProcess(id, code)) {
13
+ return null;
14
+ }
15
+ try {
16
+ // Compile the template
17
+ return compileTemplate(code, id, resolveLayout);
18
+ }
19
+ catch (error) {
20
+ // Log compilation errors
21
+ console.error(`Illimi: Error compiling ${id}:`, error);
22
+ throw error;
23
+ }
24
+ }
25
+ //# sourceMappingURL=transform.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transform.js","sourceRoot":"","sources":["../../src/plugin/transform.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAEhF;;GAEG;AACH,MAAM,UAAU,SAAS,CACvB,IAAY,EACZ,EAAU,EACV,aAAuC;IAEvC,uCAAuC;IACvC,IAAI,CAAC,aAAa,CAAC,EAAE,EAAE,IAAI,CAAC,EAAE,CAAC;QAC7B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,CAAC;QACH,uBAAuB;QACvB,OAAO,eAAe,CAAC,IAAI,EAAE,EAAE,EAAE,aAAa,CAAC,CAAC;IAClD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,yBAAyB;QACzB,OAAO,CAAC,KAAK,CAAC,2BAA2B,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;QACvD,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC"}
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "illimi-vite",
3
+ "version": "1.0.0a",
4
+ "description": "Illimi Vite Plugin - Build Integration",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "exports": {
8
+ ".": "./dist/index.js"
9
+ },
10
+ "authors": [
11
+ {
12
+ "name": "Rapha Panchi",
13
+ "email": "raphapanchi@gmail.com",
14
+ "url": "https://github.com/ralphxp"
15
+ },
16
+ {
17
+ "name": "Codizium Team",
18
+ "email": "hell.codizium@gmail.com",
19
+ "url": "https://github.com/codizium"
20
+ }
21
+ ],
22
+ "scripts": {
23
+ "build": "tsc"
24
+ },
25
+ "keywords": [],
26
+ "author": "",
27
+ "license": "MIT",
28
+ "devDependencies": {
29
+ "@types/node": "^25.3.3",
30
+ "vite": "^7.3.1"
31
+ },
32
+ "dependencies": {
33
+ "illimi-core": "~1.0.0a"
34
+ },
35
+ "repository": {
36
+ "type": "git",
37
+ "url": "git@github.com:codizium/illimi-vite.git"
38
+ },
39
+ "bugs": {
40
+ "url": "https://github.com/codizium/illimi-vite/issues"
41
+ },
42
+ "homepage": "https://github.com/codizium/illimi-vite#readme"
43
+ }
@@ -0,0 +1,28 @@
1
+ {
2
+ "compilerOptions": {
3
+ /* === Module System === */
4
+ "module": "NodeNext",
5
+ "moduleResolution": "NodeNext",
6
+
7
+ /* === Output === */
8
+ "target": "ES2020",
9
+ "outDir": "./dist",
10
+ "declaration": true,
11
+ "declarationMap": true,
12
+ "sourceMap": true,
13
+
14
+ /* === Project Structure === */
15
+ /* rootDir is set per-package in package tsconfigs */
16
+ "rootDir": "./src",
17
+
18
+ /* === Type Safety === */
19
+ "strict": true,
20
+ "noUncheckedIndexedAccess": true,
21
+ "exactOptionalPropertyTypes": true,
22
+
23
+ /* === Interop & Stability === */
24
+ "esModuleInterop": true,
25
+ "forceConsistentCasingInFileNames": true,
26
+ "skipLibCheck": true
27
+ }
28
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,7 @@
1
+ {
2
+ "extends": "./tsconfig.base.json",
3
+ "compilerOptions": {
4
+ "rootDir": "./src",
5
+ "outDir": "./dist"
6
+ }
7
+ }