strictjs-runtime 1.0.3 → 1.0.4
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 +189 -0
- package/package.json +17 -6
package/README.md
ADDED
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
|
|
2
|
+
# **StrictJS Runtime**
|
|
3
|
+
|
|
4
|
+
> ⚡ *StrictJS Runtime is an experimental, low-level JavaScript runtime powered by WebAssembly (WASM).*
|
|
5
|
+
>
|
|
6
|
+
> It’s built to give JavaScript **strict data handling**, **Rust-like safety**, and **C-like performance** — while staying fully compatible with any environment where JS runs: browser, Node.js, React Native, TensorFlow.js, and more.
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## **Why StrictJS?**
|
|
11
|
+
|
|
12
|
+
JavaScript is powerful but *loose*.
|
|
13
|
+
- Memory is garbage-collected and unpredictable.
|
|
14
|
+
- Numbers, arrays, and objects are dynamic but error-prone.
|
|
15
|
+
- Performance bottlenecks appear in **games**, **simulations**, **trading platforms**, and **AI applications**.
|
|
16
|
+
|
|
17
|
+
StrictJS Runtime solves these problems by introducing **strict, typed structures** running inside a **WebAssembly core** — without abandoning JavaScript.
|
|
18
|
+
|
|
19
|
+
**Think of it as:**
|
|
20
|
+
- The **discipline of Rust**,
|
|
21
|
+
- The **familiarity of JavaScript**,
|
|
22
|
+
- And the **flexibility to run anywhere**.
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## **Key Features**
|
|
27
|
+
|
|
28
|
+
- 🚀 **High performance** – WebAssembly core for heavy computation.
|
|
29
|
+
- 🧩 **Strict memory control** – Typed arrays and objects with predictable behavior.
|
|
30
|
+
- 🛡 **Runtime type safety** – Reduce hidden bugs and crashes.
|
|
31
|
+
- 🌐 **Cross-platform** – Works in browsers, Node.js, and other JS runtimes.
|
|
32
|
+
- ⚡ **Universal integration** – Plug it into Three.js, TensorFlow.js, React Native, or your backend logic.
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## **Installation**
|
|
37
|
+
|
|
38
|
+
Install via **npm**:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
npm install strictjs-runtime
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Or use **pnpm**:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
pnpm add strictjs-runtime
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Or **yarn**:
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
yarn add strictjs-runtime
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Or load directly from a **CDN** in the browser:
|
|
57
|
+
|
|
58
|
+
```html
|
|
59
|
+
<script src="https://unpkg.com/strictjs-runtime/pkg/strictjs_runtime.js"></script>
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## **Quick Start**
|
|
65
|
+
|
|
66
|
+
Here's a minimal example showing how to initialize StrictJS Runtime and work with strict arrays.
|
|
67
|
+
|
|
68
|
+
```js
|
|
69
|
+
import init, { HeapType, StrictArray, StrictFunction } from "strictjs-runtime/pkg/strictjs_runtime.js";
|
|
70
|
+
|
|
71
|
+
async function main() {
|
|
72
|
+
await init(); // Initialize the WebAssembly runtime
|
|
73
|
+
|
|
74
|
+
// Create a strict typed array
|
|
75
|
+
const numbers = new StrictArray(HeapType.U8, 3);
|
|
76
|
+
numbers.set(0, 42);
|
|
77
|
+
numbers.set(1, 99);
|
|
78
|
+
|
|
79
|
+
console.log("First number:", numbers.get(0)); // → 42
|
|
80
|
+
console.log("Second number:", numbers.get(1)); // → 99
|
|
81
|
+
|
|
82
|
+
// Wrap a JS function with type safety
|
|
83
|
+
const safeAdd = new StrictFunction(
|
|
84
|
+
(a, b) => a + b,
|
|
85
|
+
["u8", "u8"], // Input types
|
|
86
|
+
"u8" // Output type
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
console.log("200 + 100 =", safeAdd.call([200, 100])); // → 255 (clamped)
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
main();
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
## **Core APIs**
|
|
98
|
+
|
|
99
|
+
### **HeapType**
|
|
100
|
+
An enum representing different memory layouts for strict arrays.
|
|
101
|
+
|
|
102
|
+
| Type | Description |
|
|
103
|
+
|---------|--------------------------|
|
|
104
|
+
| `U8` | Unsigned 8-bit integer |
|
|
105
|
+
| `I32` | Signed 32-bit integer |
|
|
106
|
+
| `F32` | 32-bit floating-point |
|
|
107
|
+
| `F64` | 64-bit floating-point |
|
|
108
|
+
|
|
109
|
+
---
|
|
110
|
+
|
|
111
|
+
### **StrictArray**
|
|
112
|
+
A fixed-size, type-safe array backed by the WASM heap.
|
|
113
|
+
|
|
114
|
+
```js
|
|
115
|
+
const arr = new StrictArray(HeapType.U8, 3);
|
|
116
|
+
arr.set(0, 10);
|
|
117
|
+
console.log(arr.get(0)); // → 10
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
### **StrictFunction**
|
|
123
|
+
Wraps JavaScript functions with runtime type checking and strict argument enforcement.
|
|
124
|
+
|
|
125
|
+
```js
|
|
126
|
+
const multiply = new StrictFunction(
|
|
127
|
+
(a, b) => a * b,
|
|
128
|
+
["u8", "u8"], // Input types
|
|
129
|
+
"u8" // Output type
|
|
130
|
+
);
|
|
131
|
+
|
|
132
|
+
console.log(multiply.call([5, 6])); // → 30
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
## **Project Status**
|
|
138
|
+
|
|
139
|
+
StrictJS Runtime is **early stage and experimental**.
|
|
140
|
+
- ✅ Stable core runtime for strict arrays and functions.
|
|
141
|
+
- ⚠️ APIs are evolving — expect breaking changes before `v1.0`.
|
|
142
|
+
- 🧪 Best for experiments, demos, and learning how to integrate strict, low-level operations into your JS projects.
|
|
143
|
+
|
|
144
|
+
---
|
|
145
|
+
|
|
146
|
+
## **Roadmap**
|
|
147
|
+
|
|
148
|
+
- [ ] Strict object system
|
|
149
|
+
- [ ] Improved type inference and enforcement
|
|
150
|
+
- [ ] Developer tools & debugging support
|
|
151
|
+
- [ ] Performance benchmarks
|
|
152
|
+
- [ ] Integrations with React, TensorFlow.js, and Three.js
|
|
153
|
+
- [ ] Potential compiler to **StrictJS language** for low-level JS development
|
|
154
|
+
|
|
155
|
+
---
|
|
156
|
+
|
|
157
|
+
## **Contributing**
|
|
158
|
+
|
|
159
|
+
Contributions are welcome!
|
|
160
|
+
|
|
161
|
+
1. Fork the repo
|
|
162
|
+
2. Create a feature branch
|
|
163
|
+
3. Submit a pull request with clear explanations and tests
|
|
164
|
+
|
|
165
|
+
---
|
|
166
|
+
|
|
167
|
+
## **License**
|
|
168
|
+
|
|
169
|
+
This project is licensed under the **MIT License**.
|
|
170
|
+
See the [LICENSE](LICENSE) file for details.
|
|
171
|
+
|
|
172
|
+
---
|
|
173
|
+
|
|
174
|
+
## **Links**
|
|
175
|
+
|
|
176
|
+
- **GitHub:** [https://github.com/kennethmburu/strictjs-runtime](https://github.com/kennethmburu/strictjs-runtime)
|
|
177
|
+
- **NPM:** [https://www.npmjs.com/package/strictjs-runtime](https://www.npmjs.com/package/strictjs-runtime)
|
|
178
|
+
- **Issues / Bug Tracker:** [Open Issues](https://github.com/kennethmburu/strictjs-runtime/issues)
|
|
179
|
+
|
|
180
|
+
---
|
|
181
|
+
|
|
182
|
+
## **Vision**
|
|
183
|
+
|
|
184
|
+
StrictJS is starting small — just a runtime today — but it has **big potential**:
|
|
185
|
+
- It could grow into a **framework**, powering full apps like React or Vue.
|
|
186
|
+
- It could evolve into a **language**, compiling to strict, predictable JavaScript.
|
|
187
|
+
- It could remain a **universal tool**, dropped into any stack to bring low-level safety and performance.
|
|
188
|
+
|
|
189
|
+
*"Wherever JavaScript runs, StrictJS can run too."*
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "strictjs-runtime",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "A low-level runtime for StrictJS with WebAssembly support",
|
|
3
|
+
"version": "1.0.4",
|
|
4
|
+
"description": "A lightweight low-level runtime for StrictJS with WebAssembly support.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"files": [
|
|
@@ -9,15 +9,26 @@
|
|
|
9
9
|
"index.js"
|
|
10
10
|
],
|
|
11
11
|
"scripts": {
|
|
12
|
-
"build": "
|
|
13
|
-
"test": "node test.js"
|
|
12
|
+
"build": "wasm-pack build --target bundler --out-dir pkg",
|
|
13
|
+
"test": "node test.js",
|
|
14
|
+
"clean": "rm -rf pkg node_modules"
|
|
14
15
|
},
|
|
15
16
|
"keywords": [
|
|
16
17
|
"strictjs",
|
|
17
18
|
"wasm",
|
|
18
19
|
"runtime",
|
|
19
|
-
"lowlevel"
|
|
20
|
+
"lowlevel",
|
|
21
|
+
"javascript",
|
|
22
|
+
"webassembly"
|
|
20
23
|
],
|
|
21
|
-
"author": "
|
|
24
|
+
"author": "Kenneth Mburu kennethmburu21@gmail.com",
|
|
25
|
+
"repository": {
|
|
26
|
+
"type": "git",
|
|
27
|
+
"url": "https://github.com/Kenneth732/strictJS.git"
|
|
28
|
+
},
|
|
29
|
+
"bugs": {
|
|
30
|
+
"url": "https://github.com/Kenneth732/strictJS.git"
|
|
31
|
+
},
|
|
32
|
+
"homepage": "https://github.com/Kenneth732/strictJS.git",
|
|
22
33
|
"license": "MIT"
|
|
23
34
|
}
|