neutronium 3.3.8 → 3.4.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 +74 -39
- package/package.json +1 -1
- package/sandbox.mjs +1 -1
- package/neutronium.ico +0 -0
- package/neutronium.png +0 -0
- package/ts-neutronium/index.d.ts +0 -146
- package/ts-neutronium/package.json +0 -14
package/README.md
CHANGED
|
@@ -1,65 +1,75 @@
|
|
|
1
|
-
# ⚛️ Neutronium v3.
|
|
1
|
+
# ⚛️ Neutronium v3.4.0
|
|
2
2
|
|
|
3
3
|
**Ultra-dense JavaScript framework – maximum performance, minimal overhead**
|
|
4
4
|
|
|
5
|
-
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
[](https://www.npmjs.com/package/neutronium)
|
|
7
6
|
[](https://www.npmjs.com/package/neutronium)
|
|
8
|
-
[](https://opensource.org/licenses/MIT)
|
|
8
|
+
[](https://neutronium-website.onrender.com)
|
|
9
|
+
[](https://neutronium-website.onrender.com/Playground/)
|
|
10
|
+
[](https://neutronium-website.onrender.com/Documentation/)
|
|
11
|
+
|
|
11
12
|
---
|
|
12
13
|
|
|
13
|
-
## 🎉 What
|
|
14
|
-
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
-
|
|
18
|
-
-
|
|
14
|
+
## 🎉 What’s new in v3.4.0
|
|
15
|
+
|
|
16
|
+
- ⚡ Faster compilation for complex projects
|
|
17
|
+
- ✨ `useState` and `useEffect` hooks
|
|
18
|
+
- ⚛️ React-like JSX syntax for easier switching
|
|
19
|
+
- 🌐 **Browser-safe compilation** via `/sandbox.mjs`
|
|
20
|
+
- 🖼️ Apply favicon programmatically
|
|
21
|
+
- 📦 Massive package size reduction using `.npmignore`
|
|
22
|
+
|
|
19
23
|
---
|
|
20
24
|
|
|
21
25
|
## ℹ️ About
|
|
22
26
|
|
|
23
|
-
**Neutronium** is a lightweight,
|
|
27
|
+
**Neutronium** is a lightweight, high-performance JavaScript framework built for developers who want **explicit control**, **predictable behavior**, and **zero unnecessary abstractions**.
|
|
24
28
|
|
|
25
|
-
|
|
29
|
+
It offers **React-like ergonomics** without a virtual DOM, build step, or heavy runtime.
|
|
30
|
+
|
|
31
|
+
> Ultra-fast ⚡ · Tiny footprint 📦 · No build tools 🛠️ · Pure JavaScript ✨
|
|
26
32
|
|
|
27
33
|
---
|
|
28
34
|
|
|
29
35
|
## ✨ Features
|
|
30
36
|
|
|
31
|
-
-
|
|
32
|
-
- 🧠 **Simple component logic**
|
|
33
|
-
- 🔌 **No dependencies
|
|
34
|
-
- 📦 **
|
|
35
|
-
-
|
|
36
|
-
-
|
|
37
|
+
- ⚡ **Blazing fast rendering**
|
|
38
|
+
- 🧠 **Simple, predictable component logic**
|
|
39
|
+
- 🔌 **No dependencies and no virtual DOM**
|
|
40
|
+
- 📦 **Tiny footprint (~57.7 kB unpacked)**
|
|
41
|
+
- 🧩 **TypeScript types (~4.35 kB)**
|
|
42
|
+
- 🛠️ **Works directly in the browser**
|
|
43
|
+
- 🔁 **JSX-style component structure**
|
|
44
|
+
- 🌐 **Sandboxed browser compiler**
|
|
37
45
|
|
|
38
46
|
---
|
|
39
47
|
|
|
40
48
|
## 📦 Installation
|
|
41
49
|
|
|
50
|
+
Install the Neutronium runtime:
|
|
51
|
+
|
|
42
52
|
```bash
|
|
43
|
-
npm
|
|
53
|
+
npm install neutronium
|
|
44
54
|
```
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
## 🛠️ Setup
|
|
49
|
-
|
|
55
|
+
Install the CLI globally(optional, recommended):
|
|
56
|
+
```bash
|
|
57
|
+
npm install neutronium -g
|
|
50
58
|
```
|
|
59
|
+
---
|
|
60
|
+
## 🛠️ Create a Project
|
|
61
|
+
```bash
|
|
51
62
|
neu-cli create-app my-app
|
|
63
|
+
cd my-app
|
|
52
64
|
```
|
|
53
|
-
|
|
54
65
|
---
|
|
55
|
-
|
|
56
|
-
## Usage Example
|
|
66
|
+
## 🚀 Usage Example
|
|
57
67
|
```jsx
|
|
58
68
|
// App.js
|
|
59
|
-
import { createApp } from 'neutronium' // or ts-neutronium for
|
|
69
|
+
import { createApp } from 'neutronium' // or ts-neutronium for TypeScript
|
|
60
70
|
|
|
61
|
-
function Greeting(
|
|
62
|
-
return <h2>Hello, {
|
|
71
|
+
function Greeting({ name }) {
|
|
72
|
+
return <h2>Hello, {name}!</h2>;
|
|
63
73
|
}
|
|
64
74
|
|
|
65
75
|
export default function App() {
|
|
@@ -74,16 +84,41 @@ export default function App() {
|
|
|
74
84
|
createApp(App).mount('body');
|
|
75
85
|
```
|
|
76
86
|
|
|
77
|
-
|
|
78
|
-
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## 🧪 Result
|
|
90
|
+

|
|
91
|
+
|
|
92
|
+
## Browser Sandbox
|
|
93
|
+
Neutronium provides a **browser-safe compiler** for live environments such as playgrounds:
|
|
94
|
+
```javascript
|
|
95
|
+
import { compile } from "neutronium/sandbox.mjs";
|
|
96
|
+
|
|
97
|
+
const result = compile(code);
|
|
98
|
+
```
|
|
99
|
+
This allows Neutronium code to be compiled without Node.js, making it ideal for online editors and sandboxes.
|
|
100
|
+
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
## 📚 Documentation & Links
|
|
104
|
+
- 🌐 Website: https://neutronium-website.onrender.com/
|
|
105
|
+
- 📖 Docs: https://neutronium-website.onrender.com/Documentation/
|
|
106
|
+
- 🧪 Playground: https://neutronium-website.onrender.com/Playground/
|
|
107
|
+
- 🧠 GitHub: https://github.com/PFMCODES/neutronium
|
|
108
|
+
- 📦 NPM: https://www.npmjs.com/package/neutronium
|
|
79
109
|
|
|
80
110
|
---
|
|
81
111
|
|
|
82
|
-
##
|
|
83
|
-
|
|
84
|
-
|
|
112
|
+
## 📦 Packages Built with Neutronium
|
|
113
|
+
- [@neuhq/alert](https://www.npmjs.com/package/@neuhq/alert)
|
|
114
|
+
- [neutronium-alert](https://www.npmjs.com/package/neutronium-alert)
|
|
85
115
|
|
|
86
116
|
---
|
|
87
117
|
|
|
88
|
-
## Found a
|
|
89
|
-
|
|
118
|
+
## 🐞 Found a Bug or Issue?
|
|
119
|
+
Please report it here:
|
|
120
|
+
👉 https://github.com/PFMCODES/neutronium/issues/new
|
|
121
|
+
|
|
122
|
+
---
|
|
123
|
+
## License
|
|
124
|
+
MIT © PFMCODES
|
package/package.json
CHANGED
package/sandbox.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as Babel from "https://esm.sh/@babel/standalone@7.28.6/es2022/standalone.mjs";
|
|
2
2
|
import { basehtml } from "./template.js";
|
|
3
3
|
|
|
4
|
-
export function
|
|
4
|
+
export function compile(source) {
|
|
5
5
|
try {
|
|
6
6
|
console.log("⚙️ Babel transforming");
|
|
7
7
|
|
package/neutronium.ico
DELETED
|
Binary file
|
package/neutronium.png
DELETED
|
Binary file
|
package/ts-neutronium/index.d.ts
DELETED
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
// src/index.ts
|
|
2
|
-
|
|
3
|
-
type EffectFunction = () => void;
|
|
4
|
-
type StateGetter<T> = () => T;
|
|
5
|
-
type StateSetter<T> = (newVal: T) => void;
|
|
6
|
-
type StateEntry<T> = [StateGetter<T>, StateSetter<T>];
|
|
7
|
-
|
|
8
|
-
let globalState: StateEntry<any>[] = [];
|
|
9
|
-
let stateIndex = 0;
|
|
10
|
-
|
|
11
|
-
function resetStateIndex(): void {
|
|
12
|
-
stateIndex = 0;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
let currentEffect: EffectFunction | null = null;
|
|
16
|
-
|
|
17
|
-
function useEffect(fn: EffectFunction): void {
|
|
18
|
-
currentEffect = fn;
|
|
19
|
-
fn(); // run once to collect dependencies
|
|
20
|
-
currentEffect = null;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
function useState<T>(initialValue: T): StateEntry<T> {
|
|
24
|
-
const index = stateIndex;
|
|
25
|
-
|
|
26
|
-
if (!globalState[index]) {
|
|
27
|
-
let value = initialValue;
|
|
28
|
-
const subs = new Set<EffectFunction>();
|
|
29
|
-
|
|
30
|
-
function get(): T {
|
|
31
|
-
if (currentEffect) subs.add(currentEffect);
|
|
32
|
-
return value;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function set(newVal: T): void {
|
|
36
|
-
if (value !== newVal) {
|
|
37
|
-
value = newVal;
|
|
38
|
-
subs.forEach(fn => fn()); // re-run effects
|
|
39
|
-
if (typeof (window as any).__NEUTRONIUM_RENDER_FN__ === 'function') {
|
|
40
|
-
(window as any).__NEUTRONIUM_RENDER_FN__();
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
globalState[index] = [get, set];
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
const result = globalState[index] as StateEntry<T>;
|
|
49
|
-
stateIndex++;
|
|
50
|
-
return result;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
type VNode = Node;
|
|
54
|
-
type Child = VNode | string | number | null | undefined;
|
|
55
|
-
type Children = Child | Child[];
|
|
56
|
-
|
|
57
|
-
interface Props {
|
|
58
|
-
children?: Children;
|
|
59
|
-
ref?: (el: HTMLElement) => void;
|
|
60
|
-
[key: string]: any;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
type ComponentFunction = (props: Props) => VNode;
|
|
64
|
-
type ElementType = string | ComponentFunction;
|
|
65
|
-
|
|
66
|
-
function h(type: ElementType, props: Props | null = {}, ...children: Child[]): VNode {
|
|
67
|
-
props = props || {};
|
|
68
|
-
props.children = (props.children ? (Array.isArray(props.children) ? props.children : [props.children]) : [])
|
|
69
|
-
.concat(children)
|
|
70
|
-
.flat();
|
|
71
|
-
|
|
72
|
-
if (typeof type === 'function') {
|
|
73
|
-
return type(props);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
const el = document.createElement(type);
|
|
77
|
-
|
|
78
|
-
for (const [key, value] of Object.entries(props || {})) {
|
|
79
|
-
if (key === 'children') continue; // skip
|
|
80
|
-
if (key.startsWith('on') && typeof value === 'function') {
|
|
81
|
-
el.addEventListener(key.slice(2).toLowerCase(), value);
|
|
82
|
-
} else if (key === 'ref' && typeof value === 'function') {
|
|
83
|
-
value(el);
|
|
84
|
-
} else {
|
|
85
|
-
el.setAttribute(key, String(value));
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
props.children.forEach((child: Child) => {
|
|
90
|
-
if (typeof child === 'string' || typeof child === 'number') {
|
|
91
|
-
el.appendChild(document.createTextNode(String(child)));
|
|
92
|
-
} else if (child instanceof Node) {
|
|
93
|
-
el.appendChild(child);
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
return el;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
interface App {
|
|
101
|
-
mount(selector: string | HTMLElement): HTMLElement | null;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
function createApp(component: () => VNode): App {
|
|
105
|
-
return {
|
|
106
|
-
mount(selector: string | HTMLElement): HTMLElement | null {
|
|
107
|
-
const root = typeof selector === 'string' ? document.querySelector<HTMLElement>(selector) : selector;
|
|
108
|
-
if (!root) {
|
|
109
|
-
console.error(`❌ Root element '${selector}' not found`);
|
|
110
|
-
return null;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
(window as any).__NEUTRONIUM_ROOT__ = root;
|
|
114
|
-
|
|
115
|
-
function render(): void {
|
|
116
|
-
resetStateIndex();
|
|
117
|
-
const vnode = component();
|
|
118
|
-
root.innerHTML = '';
|
|
119
|
-
root.appendChild(vnode);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
(window as any).__NEUTRONIUM_RENDER_FN__ = render;
|
|
123
|
-
render();
|
|
124
|
-
|
|
125
|
-
return root;
|
|
126
|
-
}
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
function Fragment(props: Props = {}): DocumentFragment {
|
|
131
|
-
const frag = document.createDocumentFragment();
|
|
132
|
-
const children = props.children || [];
|
|
133
|
-
|
|
134
|
-
(Array.isArray(children) ? children : [children]).forEach((child: Child) => {
|
|
135
|
-
if (typeof child === 'string' || typeof child === 'number') {
|
|
136
|
-
frag.appendChild(document.createTextNode(String(child)));
|
|
137
|
-
} else if (child instanceof Node) {
|
|
138
|
-
frag.appendChild(child);
|
|
139
|
-
}
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
return frag;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
export { h, createApp, Fragment, useState, useEffect, resetStateIndex };
|
|
146
|
-
export type { Props, VNode, Child, Children, ComponentFunction, ElementType, StateEntry, EffectFunction };
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "ts-neutronium",
|
|
3
|
-
"version": "1.0.0",
|
|
4
|
-
"description": "",
|
|
5
|
-
"main": "index.ts",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"test": "echo \"Error: no test specified\" && exit 1"
|
|
8
|
-
},
|
|
9
|
-
"keywords": [],
|
|
10
|
-
"author": "",
|
|
11
|
-
"license": "ISC",
|
|
12
|
-
"type": "module",
|
|
13
|
-
"types": "./index.d.ts"
|
|
14
|
-
}
|