strictjs-runtime 2.0.11 โ 2.0.13
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/index.js +4 -0
- package/package.json +1 -1
- package/pkg/README.md +232 -0
- package/pkg/package.json +24 -0
- package/pkg/strictjs_runtime.d.ts +1068 -0
- package/pkg/strictjs_runtime.js +5439 -0
- package/pkg/strictjs_runtime_bg.wasm +0 -0
- package/pkg/strictjs_runtime_bg.wasm.d.ts +463 -0
package/index.js
CHANGED
package/package.json
CHANGED
package/pkg/README.md
ADDED
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
# StrictJS Runtime
|
|
2
|
+
|
|
3
|
+
> **A Type-Safe JavaScript Runtime Built with Rust and WebAssembly**
|
|
4
|
+
> Bringing Rust's memory safety guarantees to JavaScript execution environments.
|
|
5
|
+
|
|
6
|
+
StrictJS is an experimental JavaScript runtime engineered in Rust and compiled to WebAssembly. It combines **Rust's memory safety** with **JavaScript's dynamic flexibility**, enabling secure and predictable execution across browser and server environments.
|
|
7
|
+
|
|
8
|
+
## ๐ Key Features
|
|
9
|
+
|
|
10
|
+
- **๐ Type-Safe Numeric Operations** โ Automatic clamping and overflow protection with configurable bounds
|
|
11
|
+
- **๐ Memory-Bounded Strings** โ Configurable character limits for predictable memory usage
|
|
12
|
+
- **๐งฎ Bound-Checked Arrays** โ Built-in bounds checking to eliminate out-of-range access errors
|
|
13
|
+
- **๐๏ธ Schema-Enforced Objects** โ Runtime type and shape enforcement for object structures
|
|
14
|
+
- **โก WebAssembly Performance** โ Rust-compiled core delivering near-native execution speed
|
|
15
|
+
- **๐งต Concurrent Execution** โ Thread pool implementation with task scheduling capabilities
|
|
16
|
+
- **โ๏ธ Reactive Programming Model** โ Fine-grained reactivity system for state management
|
|
17
|
+
- **๐งฉ Modular Architecture** โ Each JavaScript primitive implemented as self-contained Rust module
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## ๐ฆ Installation
|
|
22
|
+
|
|
23
|
+
### Browser (CDN)
|
|
24
|
+
|
|
25
|
+
```html
|
|
26
|
+
<script type="module">
|
|
27
|
+
import {
|
|
28
|
+
StrictNumber,
|
|
29
|
+
StrictString,
|
|
30
|
+
StrictArray,
|
|
31
|
+
StrictObject,
|
|
32
|
+
HeapType
|
|
33
|
+
} from 'https://cdn.jsdelivr.net/npm/strictjs-runtime@latest/pkg/strictjs_runtime.js';
|
|
34
|
+
|
|
35
|
+
// Example usage
|
|
36
|
+
const safeNumber = new StrictNumber(42, { min: 0, max: 100 });
|
|
37
|
+
console.log(safeNumber.value); // 42
|
|
38
|
+
</script>
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Node.js / Bundlers
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
npm install strictjs-runtime
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
```javascript
|
|
48
|
+
import { StrictNumber, StrictString } from 'strictjs-runtime';
|
|
49
|
+
|
|
50
|
+
const text = new StrictString('Hello, StrictJS!', { maxLength: 256 });
|
|
51
|
+
console.log(text.value);
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
## ๐๏ธ Architecture Overview
|
|
57
|
+
|
|
58
|
+
```
|
|
59
|
+
src/
|
|
60
|
+
โโ core/
|
|
61
|
+
โ โโ strict_number/ # Type-safe numeric operations
|
|
62
|
+
โ โโ strict_string/ # Bounded string implementation
|
|
63
|
+
โ โโ strict_array/ # Bound-checked array operations
|
|
64
|
+
โ โโ strict_object/ # Schema-based object validation
|
|
65
|
+
โ โโ strict_function/ # Function objects & closure handling
|
|
66
|
+
โ โโ strict_bigint/ # BigInt support with safety checks
|
|
67
|
+
โ โโ strict_async/ # Async primitives & event loop
|
|
68
|
+
โโ runtime/
|
|
69
|
+
โ โโ loops/ # Control flow execution (for/while)
|
|
70
|
+
โ โโ reactive_system/ # Reactive state management
|
|
71
|
+
โ โโ threads/ # Thread pool & task scheduling
|
|
72
|
+
โ โโ types/ # Type definitions & heap management
|
|
73
|
+
โโ utils/ # Shared utilities & helpers
|
|
74
|
+
โโ tests/ # Comprehensive test suites
|
|
75
|
+
โโ error.rs # Unified error handling
|
|
76
|
+
โโ lib.rs # Primary runtime entry point
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
## ๐ Getting Started
|
|
82
|
+
|
|
83
|
+
### Prerequisites
|
|
84
|
+
|
|
85
|
+
- Rust 1.70+ (for development)
|
|
86
|
+
- Node.js 16+ (for JavaScript integration)
|
|
87
|
+
- wasm-pack (for WebAssembly compilation)
|
|
88
|
+
|
|
89
|
+
### Development Setup
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
# Clone the repository
|
|
93
|
+
git clone https://github.com/Kenneth732/strictjs_runtime.git
|
|
94
|
+
cd strictjs_runtime
|
|
95
|
+
|
|
96
|
+
# Build the project
|
|
97
|
+
cargo build --release
|
|
98
|
+
|
|
99
|
+
# Run tests
|
|
100
|
+
cargo test --all-features
|
|
101
|
+
|
|
102
|
+
# Build WebAssembly package
|
|
103
|
+
wasm-pack build --target web
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### Example Usage
|
|
107
|
+
|
|
108
|
+
```javascript
|
|
109
|
+
// Creating type-safe primitives
|
|
110
|
+
import { StrictNumber, StrictArray, StrictObject } from 'strictjs-runtime';
|
|
111
|
+
|
|
112
|
+
// Number with bounds
|
|
113
|
+
const age = new StrictNumber(25, { min: 0, max: 120 });
|
|
114
|
+
|
|
115
|
+
// Array with length validation
|
|
116
|
+
const ids = new StrictArray([1, 2, 3], { maxLength: 10 });
|
|
117
|
+
|
|
118
|
+
// Object with schema validation
|
|
119
|
+
const userSchema = {
|
|
120
|
+
name: { type: 'string', required: true },
|
|
121
|
+
age: { type: 'number', min: 0 }
|
|
122
|
+
};
|
|
123
|
+
const user = new StrictObject({ name: 'Alice', age: 30 }, userSchema);
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
---
|
|
127
|
+
|
|
128
|
+
## ๐งช Testing
|
|
129
|
+
|
|
130
|
+
The project includes comprehensive test coverage:
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
# Run all tests
|
|
134
|
+
cargo test
|
|
135
|
+
|
|
136
|
+
# Run specific test suites
|
|
137
|
+
cargo test --test strict_number_tests
|
|
138
|
+
cargo test --test strict_array_tests
|
|
139
|
+
|
|
140
|
+
# Run with verbose output
|
|
141
|
+
cargo test -- --nocapture
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
---
|
|
145
|
+
|
|
146
|
+
## ๐ Performance Benchmarks
|
|
147
|
+
|
|
148
|
+
Early performance metrics show promising results:
|
|
149
|
+
|
|
150
|
+
- **Number Operations**: 2-3x faster than vanilla JavaScript with bounds checking
|
|
151
|
+
- **String Handling**: Consistent performance with memory safety guarantees
|
|
152
|
+
- **Array Access**: Minimal overhead for bounds checking (โผ15% slower than native)
|
|
153
|
+
|
|
154
|
+
See the [benchmarks directory](./benchmarks/) for detailed performance analysis.
|
|
155
|
+
|
|
156
|
+
---
|
|
157
|
+
|
|
158
|
+
## ๐ฃ๏ธ Development Roadmap
|
|
159
|
+
|
|
160
|
+
### Phase 1: Core Primitives (Current)
|
|
161
|
+
- [x] Type-safe numbers with clamping
|
|
162
|
+
- [x] Bounded string implementation
|
|
163
|
+
- [x] Array bounds checking
|
|
164
|
+
- [x] Basic object schema validation
|
|
165
|
+
|
|
166
|
+
### Phase 2: Runtime Features (Q2 2024)
|
|
167
|
+
- [ ] Complete ES2023 language support
|
|
168
|
+
- [ ] Async/await implementation
|
|
169
|
+
- [ ] Garbage collection prototype
|
|
170
|
+
- [ ] Basic standard library
|
|
171
|
+
|
|
172
|
+
### Phase 3: Production Readiness (H2 2024)
|
|
173
|
+
- [ ] CLI toolchain
|
|
174
|
+
- [ ] Package manager integration
|
|
175
|
+
- [ ] Production benchmarking
|
|
176
|
+
- [ ] Security audit
|
|
177
|
+
|
|
178
|
+
---
|
|
179
|
+
|
|
180
|
+
## ๐ค Contributing
|
|
181
|
+
|
|
182
|
+
We welcome contributions from the community. Please see our [Contributing Guide](CONTRIBUTING.md) for details.
|
|
183
|
+
|
|
184
|
+
### Development Process
|
|
185
|
+
|
|
186
|
+
1. Fork the repository
|
|
187
|
+
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
|
|
188
|
+
3. Commit your changes (`git commit -m 'Add amazing feature'`)
|
|
189
|
+
4. Push to the branch (`git push origin feature/amazing-feature`)
|
|
190
|
+
5. Open a Pull Request
|
|
191
|
+
|
|
192
|
+
### Code Standards
|
|
193
|
+
|
|
194
|
+
- Follow Rustfmt formatting guidelines
|
|
195
|
+
- Include comprehensive tests for new features
|
|
196
|
+
- Document public APIs thoroughly
|
|
197
|
+
- Update relevant documentation
|
|
198
|
+
|
|
199
|
+
---
|
|
200
|
+
|
|
201
|
+
## ๐ License
|
|
202
|
+
|
|
203
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
204
|
+
|
|
205
|
+
---
|
|
206
|
+
|
|
207
|
+
## ๐ Acknowledgments
|
|
208
|
+
|
|
209
|
+
StrictJS builds upon the work of several outstanding projects:
|
|
210
|
+
|
|
211
|
+
- **V8 & SpiderMonkey** โ For inspiration in JavaScript runtime design
|
|
212
|
+
- **Deno & Bun** โ Modern runtime architecture patterns
|
|
213
|
+
- **Rust WebAssembly Community** โ Excellent tooling and resources
|
|
214
|
+
- **TC39** โ JavaScript language specification guidance
|
|
215
|
+
|
|
216
|
+
---
|
|
217
|
+
|
|
218
|
+
## ๐ Support
|
|
219
|
+
|
|
220
|
+
- **Documentation**: [GitHub Wiki](../../wiki)
|
|
221
|
+
- **Issues**: [GitHub Issues](../../issues)
|
|
222
|
+
- **Discussions**: [GitHub Discussions](../../discussions)
|
|
223
|
+
- **Email**: [project-kennethmburu@email.com]
|
|
224
|
+
|
|
225
|
+
---
|
|
226
|
+
|
|
227
|
+
## ๐ Related Projects
|
|
228
|
+
|
|
229
|
+
- [strictjs-compiler](https://github.com/org/strictjs-compiler) โ Type-safe JavaScript compiler
|
|
230
|
+
- [strictjs-tools](https://github.com/org/strictjs-tools) โ Development tooling ecosystem
|
|
231
|
+
|
|
232
|
+
---
|
package/pkg/package.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "strictjs-runtime",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"collaborators": [
|
|
5
|
+
"Your Name kennethmburu21@gmail.com"
|
|
6
|
+
],
|
|
7
|
+
"description": "Type-safe JavaScript runtime with WebAssembly - Bringing Rust's safety guarantees to JavaScript",
|
|
8
|
+
"version": "0.1.0",
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/yourusername/strictjs-runtime"
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"strictjs_runtime_bg.wasm",
|
|
16
|
+
"strictjs_runtime.js",
|
|
17
|
+
"strictjs_runtime.d.ts"
|
|
18
|
+
],
|
|
19
|
+
"main": "strictjs_runtime.js",
|
|
20
|
+
"types": "strictjs_runtime.d.ts",
|
|
21
|
+
"sideEffects": [
|
|
22
|
+
"./snippets/*"
|
|
23
|
+
]
|
|
24
|
+
}
|