neutronium 1.9.5 → 2.0.1

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 CHANGED
@@ -6,84 +6,16 @@ Neutronium is a lightweight, efficient JavaScript framework designed for buildin
6
6
 
7
7
  ## Features
8
8
 
9
- - 🚀 **Ultra-fast** - Optimized for performance
10
- - 📦 **Minimal bundle size** - Dense with features, light on complexity
11
- - 🎯 **Simple API** - Easy to learn and use
12
- - 🔧 **Flexible** - Adaptable to your project needs
13
- - 🌟 **Modern** - Built with current JavaScript standards
9
+ * 🚀 **Ultra-fast** - Optimized for performance
10
+ * 📦 **Minimal bundle size** - Dense with features, light on complexity
11
+ * 🎯 **Simple API** - Easy to learn and use
12
+ * 🔧 **Flexible** - Adaptable to your project needs
13
+ * 🌟 **Modern** - Built with current JavaScript standards
14
14
 
15
- ## Installation
15
+ ## Installation and Setup
16
16
 
17
17
  ```bash
18
- npm install neutronium
19
- ```
20
-
21
- ## Quick Start
22
-
23
- ```javascript
24
- import { createComponent, render } from 'neutronium';
25
-
26
- // Create a simple component
27
- const HelloWorld = createComponent({
28
- template: '<h1>Hello, {{name}}!</h1>',
29
- props: { name: 'World' }
30
- });
31
-
32
- // Render to DOM
33
- render(HelloWorld, document.getElementById('app'));
34
- ```
35
-
36
- ## API Reference
37
-
38
- ### `createComponent(options)`
39
-
40
- Creates a new component with the specified options.
41
-
42
- **Parameters:**
43
- - `options` (Object): Component configuration
44
- - `template` (String): HTML template
45
- - `props` (Object): Component properties
46
- - `methods` (Object): Component methods
47
-
48
- **Returns:** Component instance
49
-
50
- ### `render(component, target)`
51
-
52
- Renders a component to the specified DOM element.
53
-
54
- **Parameters:**
55
- - `component`: Component instance
56
- - `target`: DOM element to render into
57
-
58
- ## Examples
59
-
60
- ### Basic Component
61
-
62
- ```javascript
63
- import { createComponent, render } from 'neutronium';
64
-
65
- const Counter = createComponent({
66
- template: `
67
- <div>
68
- <h2>Count: {{count}}</h2>
69
- <button onclick="increment()">+</button>
70
- <button onclick="decrement()">-</button>
71
- </div>
72
- `,
73
- props: {
74
- count: 0
75
- },
76
- methods: {
77
- increment() {
78
- this.props.count++;
79
- },
80
- decrement() {
81
- this.props.count--;
82
- }
83
- }
84
- });
85
-
86
- render(Counter, document.getElementById('app'));
18
+ npm i neutronium -g && npm i neutronium && neu-cli create-app && neu-cli start --watch
87
19
  ```
88
20
 
89
21
  ### Component with State
@@ -122,10 +54,10 @@ render(TodoList, document.getElementById('app'));
122
54
 
123
55
  ## Browser Support
124
56
 
125
- - Chrome 60+
126
- - Firefox 60+
127
- - Safari 12+
128
- - Edge 79+
57
+ * Chrome 60+
58
+ * Firefox 60+
59
+ * Safari 12+
60
+ * Edge 79+
129
61
 
130
62
  ## Development
131
63
 
@@ -145,7 +77,7 @@ npm run build
145
77
 
146
78
  ## Contributing
147
79
 
148
- We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.
80
+ We welcome contributions!
149
81
 
150
82
  1. Fork the repository
151
83
  2. Create your feature branch (`git checkout -b feature/amazing-feature`)
@@ -157,21 +89,12 @@ We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) f
157
89
 
158
90
  MIT License - see the [LICENSE](LICENSE) file for details.
159
91
 
160
- ## Roadmap
161
-
162
- - [ ] Server-side rendering support
163
- - [ ] TypeScript definitions
164
- - [ ] Developer tools integration
165
- - [ ] Plugin system
166
- - [ ] Performance optimizations
167
- - [ ] Advanced component lifecycle methods
168
-
169
92
  ## Why Neutronium?
170
93
 
171
94
  Just like neutronium is the densest stable matter in the universe, Neutronium framework packs maximum functionality into minimal code. It's designed for developers who want powerful features without the bloat.
172
95
 
173
96
  ---
174
97
 
175
- **Built with ⚛️ by [Your Name]**
98
+ **Built with by PFMCODES Org.**
176
99
 
177
- *"Dense with features, light on complexity"*
100
+ *"Dense with features, light on complexity"*
package/cli/index.js CHANGED
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env node
1
+ #!/usr/bin/env node
2
2
  const { default: inquirer } = require('inquirer');
3
3
  const fs = require('fs');
4
4
  const path = require('path');
@@ -22,14 +22,19 @@ function compileProject(projectDir = process.cwd()) {
22
22
 
23
23
  log('⚙️ Compiling JSX with Babel...');
24
24
  let { code: transpiled } = babel.transformSync(sourceCode, {
25
- filename: 'App.js',
26
- presets: [],
27
- plugins: [
28
- ['@babel/plugin-transform-react-jsx', { pragma: '_neutronium.h' }]
29
- ],
30
- babelrc: false,
31
- configFile: false,
32
- });
25
+ filename: 'App.js', // or use path.basename(appJsPath)
26
+ babelrc: false,
27
+ configFile: false,
28
+ presets: [],
29
+ plugins: [
30
+ ['@babel/plugin-transform-react-jsx', {
31
+ pragma: '_neutronium.h',
32
+ pragmaFrag: '_neutronium.Fragment',
33
+ runtime: 'classic',
34
+ useBuiltIns: false // <- IMPORTANT
35
+ }]
36
+ ]
37
+ });
33
38
 
34
39
  // Remove CommonJS require if present
35
40
  transpiled = transpiled.replace(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "neutronium",
3
- "version": "1.9.5",
3
+ "version": "2.0.1",
4
4
  "description": "A dense, efficient JavaScript framework for building modern web applications",
5
5
  "main": "src/index.js",
6
6
  "type": "commonjs",
package/src/index.js CHANGED
@@ -1,14 +1,17 @@
1
1
  // src/index.js
2
2
 
3
- function h(type, props = {}, ...children) {
3
+ export function h(type, props = {}, ...children) {
4
+ if (typeof type === 'function') {
5
+ return type(props || {});
6
+ }
7
+
4
8
  const el = document.createElement(type);
5
9
 
6
10
  for (const [key, value] of Object.entries(props || {})) {
7
- if (key === 'ref' && typeof value === 'function') {
8
- // Delay to ensure element is mounted
9
- setTimeout(() => value(el), 0);
10
- } else if (key.startsWith('on') && typeof value === 'function') {
11
+ if (key.startsWith('on') && typeof value === 'function') {
11
12
  el.addEventListener(key.slice(2).toLowerCase(), value);
13
+ } else if (key === 'ref' && typeof value === 'function') {
14
+ value(el);
12
15
  } else {
13
16
  el.setAttribute(key, value);
14
17
  }
@@ -25,6 +28,34 @@ function h(type, props = {}, ...children) {
25
28
  return el;
26
29
  }
27
30
 
31
+ export function Fragment(_, ...children) {
32
+ const frag = document.createDocumentFragment();
33
+ children.flat().forEach(child => {
34
+ if (typeof child === 'string') {
35
+ frag.appendChild(document.createTextNode(child));
36
+ } else {
37
+ frag.appendChild(child);
38
+ }
39
+ });
40
+ return frag;
41
+ }
42
+
43
+ export function createApp(component) {
44
+ return {
45
+ mount(selector) {
46
+ const root = typeof selector === 'string' ? document.querySelector(selector) : selector;
47
+ if (!root) {
48
+ console.error(`❌ Root element '${selector}' not found`);
49
+ return;
50
+ }
51
+
52
+ const vnode = component();
53
+ root.innerHTML = '';
54
+ root.appendChild(vnode);
55
+ }
56
+ };
57
+ }
58
+
28
59
  function createApp(component) {
29
60
  return {
30
61
  mount(selector) {
@@ -41,4 +72,16 @@ function createApp(component) {
41
72
  };
42
73
  }
43
74
 
44
- export { h, createApp };
75
+ export function Fragment(_, ...children) {
76
+ const frag = document.createDocumentFragment();
77
+ children.flat().forEach(child => {
78
+ if (typeof child === 'string') {
79
+ frag.appendChild(document.createTextNode(child));
80
+ } else if (child instanceof Node) {
81
+ frag.appendChild(child);
82
+ }
83
+ });
84
+ return frag;
85
+ }
86
+
87
+ export { h, createApp, Fragment };