@geajs/vite-plugin 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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2017-present Armagan Amcalar
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,91 @@
1
+ # @geajs/vite-plugin
2
+
3
+ [![npm version](https://badge.fury.io/js/%40geajs%2Fvite-plugin.svg)](https://www.npmjs.com/package/@geajs/vite-plugin)
4
+ [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/dashersw/gea/blob/master/LICENSE)
5
+
6
+ Vite plugin that powers [Gea](https://www.npmjs.com/package/@geajs/core)'s compile-time JSX transforms, reactive binding generation, event delegation wiring, and hot module replacement.
7
+
8
+ ## Installation
9
+
10
+ ```bash
11
+ npm install -D @geajs/vite-plugin
12
+ ```
13
+
14
+ Requires `vite` ^7.3.1 as a peer dependency.
15
+
16
+ ## Configuration
17
+
18
+ ```ts
19
+ // vite.config.ts
20
+ import { defineConfig } from 'vite'
21
+ import { geaPlugin } from '@geajs/vite-plugin'
22
+
23
+ export default defineConfig({
24
+ plugins: [geaPlugin()]
25
+ })
26
+ ```
27
+
28
+ That's it. No configuration options are needed — the plugin handles everything automatically.
29
+
30
+ ## What It Does
31
+
32
+ ### JSX to HTML String Compilation
33
+
34
+ The plugin transforms JSX in your `.jsx` and `.tsx` files into HTML template strings at build time. This means there is no `createElement` call at runtime — templates compile down to plain strings that are inserted into the DOM.
35
+
36
+ - `className` is automatically converted to `class`
37
+ - React-style event names are converted to Gea's lowercase attributes (`onClick` becomes `click`)
38
+ - Component tags are converted to kebab-case custom elements with `data-prop-*` attributes
39
+
40
+ ### Reactive Binding Generation
41
+
42
+ The plugin analyzes which state paths your template reads (e.g., `counterStore.count`) and generates `observe()` calls that surgically update only the DOM nodes that depend on changed state. No virtual DOM diffing required.
43
+
44
+ ### Event Delegation Wiring
45
+
46
+ Event handlers declared in JSX (`click={fn}`, `input={fn}`, etc.) are compiled into an `events` getter that uses event delegation — a single global listener per event type on `document.body`, rather than individual listeners on each element.
47
+
48
+ ### Function-to-Class Conversion
49
+
50
+ Function components are automatically converted to class components at build time. You write simple functions; the plugin handles the rest:
51
+
52
+ ```jsx
53
+ // What you write
54
+ export default function Greeting({ name }) {
55
+ return <h1>Hello, {name}!</h1>
56
+ }
57
+
58
+ // What the plugin produces (conceptually)
59
+ class Greeting extends Component {
60
+ template({ name }) {
61
+ return `<h1>Hello, ${name}!</h1>`
62
+ }
63
+ }
64
+ ```
65
+
66
+ ### Conditional and List Rendering
67
+
68
+ - Conditional expressions (`cond && <X />`) are compiled into `<template>` markers with efficient swap logic
69
+ - `.map()` calls with `key` props are compiled into `applyListChanges` calls that handle adds, deletes, reorders, and swaps without touching unchanged items
70
+
71
+ ### Hot Module Replacement
72
+
73
+ The plugin injects HMR support that preserves component state across edits. When you save a file, only the changed components are updated — no full page reload.
74
+
75
+ ### TypeScript Setup
76
+
77
+ When a `tsconfig.json` is present, the plugin automatically adds `gea-env.d.ts` to the `compilerOptions.types` array, providing JSX type definitions for Gea.
78
+
79
+ ### Virtual Module
80
+
81
+ The plugin provides a `virtual:gea-reconcile` module used internally for keyed list reconciliation.
82
+
83
+ ## Related Packages
84
+
85
+ - **[@geajs/core](https://www.npmjs.com/package/@geajs/core)** — Core framework
86
+ - **[@geajs/mobile](https://www.npmjs.com/package/@geajs/mobile)** — Mobile UI primitives
87
+ - **[create-gea](https://www.npmjs.com/package/create-gea)** — Project scaffolder
88
+
89
+ ## License
90
+
91
+ [MIT](LICENSE) — Copyright (c) 2017-present Armagan Amcalar
@@ -0,0 +1,5 @@
1
+ import { Plugin } from 'vite';
2
+
3
+ declare function geaPlugin(): Plugin;
4
+
5
+ export { geaPlugin };