@holoscript/wasm 3.7.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 +21 -0
- package/README.md +157 -0
- package/package.json +37 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025-2026 HoloScript Contributors
|
|
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,157 @@
|
|
|
1
|
+
# @holoscript/wasm
|
|
2
|
+
|
|
3
|
+
High-performance HoloScript parser compiled to WebAssembly.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **10x faster parsing** compared to JavaScript implementation
|
|
8
|
+
- **Browser-native** - runs directly in the browser without server
|
|
9
|
+
- **Small footprint** - <500KB gzipped
|
|
10
|
+
- **Full HoloScript support** - all language features including Brittney AI constructs
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npm install @holoscript/wasm
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Usage
|
|
19
|
+
|
|
20
|
+
### Browser (ES Modules)
|
|
21
|
+
|
|
22
|
+
```javascript
|
|
23
|
+
import init, { parse, validate, version } from '@holoscript/wasm';
|
|
24
|
+
|
|
25
|
+
// Initialize the WASM module (required once)
|
|
26
|
+
await init();
|
|
27
|
+
|
|
28
|
+
// Parse HoloScript source code
|
|
29
|
+
const ast = JSON.parse(
|
|
30
|
+
parse(`
|
|
31
|
+
composition cube {
|
|
32
|
+
@grabbable
|
|
33
|
+
@physics { mass: 1.5 }
|
|
34
|
+
color: "red"
|
|
35
|
+
position: [0, 1, 0]
|
|
36
|
+
}
|
|
37
|
+
`)
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
console.log(ast);
|
|
41
|
+
|
|
42
|
+
// Validate without full parse
|
|
43
|
+
const isValid = validate(`composition test { color: "blue" }`);
|
|
44
|
+
console.log('Valid:', isValid);
|
|
45
|
+
|
|
46
|
+
// Get version
|
|
47
|
+
console.log('WASM Version:', version());
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Node.js
|
|
51
|
+
|
|
52
|
+
```javascript
|
|
53
|
+
const { parse, validate, version } = require('@holoscript/wasm');
|
|
54
|
+
|
|
55
|
+
const source = `
|
|
56
|
+
composition "My Scene" {
|
|
57
|
+
composition player {
|
|
58
|
+
@networked
|
|
59
|
+
position: [0, 0, 0]
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
`;
|
|
63
|
+
|
|
64
|
+
const ast = JSON.parse(parse(source));
|
|
65
|
+
console.log(JSON.stringify(ast, null, 2));
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Bundlers (Webpack, Vite, etc.)
|
|
69
|
+
|
|
70
|
+
```javascript
|
|
71
|
+
import init, * as holoscript from '@holoscript/wasm';
|
|
72
|
+
|
|
73
|
+
async function setupParser() {
|
|
74
|
+
await init();
|
|
75
|
+
|
|
76
|
+
return {
|
|
77
|
+
parse: (source) => JSON.parse(holoscript.parse(source)),
|
|
78
|
+
validate: holoscript.validate,
|
|
79
|
+
validateDetailed: (source) => JSON.parse(holoscript.validate_detailed(source)),
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const parser = await setupParser();
|
|
84
|
+
const ast = parser.parse(`composition test { color: "green" }`);
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## API
|
|
88
|
+
|
|
89
|
+
### `parse(source: string): string`
|
|
90
|
+
|
|
91
|
+
Parse HoloScript source code and return the AST as a JSON string.
|
|
92
|
+
|
|
93
|
+
**Returns:** JSON string containing the AST or an error object.
|
|
94
|
+
|
|
95
|
+
### `parse_pretty(source: string): string`
|
|
96
|
+
|
|
97
|
+
Same as `parse()` but with pretty-printed JSON output.
|
|
98
|
+
|
|
99
|
+
### `validate(source: string): boolean`
|
|
100
|
+
|
|
101
|
+
Quickly validate if the source code is syntactically correct.
|
|
102
|
+
|
|
103
|
+
**Returns:** `true` if valid, `false` otherwise.
|
|
104
|
+
|
|
105
|
+
### `validate_detailed(source: string): string`
|
|
106
|
+
|
|
107
|
+
Validate and return detailed error information.
|
|
108
|
+
|
|
109
|
+
**Returns:** JSON string with `{ valid: boolean, errors: [...] }`
|
|
110
|
+
|
|
111
|
+
### `version(): string`
|
|
112
|
+
|
|
113
|
+
Get the version of the WASM module.
|
|
114
|
+
|
|
115
|
+
## Building from Source
|
|
116
|
+
|
|
117
|
+
### Prerequisites
|
|
118
|
+
|
|
119
|
+
- [Rust](https://rustup.rs/) 1.70+
|
|
120
|
+
- [wasm-pack](https://rustwasm.github.io/wasm-pack/installer/)
|
|
121
|
+
|
|
122
|
+
### Build
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
# Build for web (ES modules)
|
|
126
|
+
npm run build
|
|
127
|
+
|
|
128
|
+
# Build for Node.js
|
|
129
|
+
npm run build:nodejs
|
|
130
|
+
|
|
131
|
+
# Build for bundlers
|
|
132
|
+
npm run build:bundler
|
|
133
|
+
|
|
134
|
+
# Run tests
|
|
135
|
+
npm run test
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
## Performance
|
|
139
|
+
|
|
140
|
+
Benchmarks on a typical development machine:
|
|
141
|
+
|
|
142
|
+
| Operation | JavaScript | WASM | Speedup |
|
|
143
|
+
| ------------------- | ---------- | ----- | ------- |
|
|
144
|
+
| Parse 100 lines | 5ms | 0.5ms | 10x |
|
|
145
|
+
| Parse 1000 lines | 50ms | 5ms | 10x |
|
|
146
|
+
| Validate 1000 lines | 30ms | 2ms | 15x |
|
|
147
|
+
|
|
148
|
+
## Browser Compatibility
|
|
149
|
+
|
|
150
|
+
- Chrome 57+
|
|
151
|
+
- Firefox 52+
|
|
152
|
+
- Safari 11+
|
|
153
|
+
- Edge 16+
|
|
154
|
+
|
|
155
|
+
## License
|
|
156
|
+
|
|
157
|
+
MIT License - see [LICENSE](../../LICENSE) for details.
|
package/package.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@holoscript/wasm",
|
|
3
|
+
"version": "3.7.0",
|
|
4
|
+
"description": "HoloScript parser compiled to WebAssembly for high-performance browser execution",
|
|
5
|
+
"main": "pkg/holoscript_wasm.js",
|
|
6
|
+
"types": "pkg/holoscript_wasm.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"pkg"
|
|
9
|
+
],
|
|
10
|
+
"keywords": [
|
|
11
|
+
"holoscript",
|
|
12
|
+
"wasm",
|
|
13
|
+
"webassembly",
|
|
14
|
+
"parser",
|
|
15
|
+
"vr",
|
|
16
|
+
"xr"
|
|
17
|
+
],
|
|
18
|
+
"author": "HoloScript Team",
|
|
19
|
+
"license": "MIT",
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "https://github.com/brianonbased-dev/HoloScript.git",
|
|
23
|
+
"directory": "packages/compiler-wasm"
|
|
24
|
+
},
|
|
25
|
+
"sideEffects": false,
|
|
26
|
+
"homepage": "https://github.com/brianonbased-dev/HoloScript#readme",
|
|
27
|
+
"bugs": {
|
|
28
|
+
"url": "https://github.com/brianonbased-dev/HoloScript/issues"
|
|
29
|
+
},
|
|
30
|
+
"scripts": {
|
|
31
|
+
"build": "echo 'WASM build requires wasm-pack (Rust toolchain) - skipping if not available' && wasm-pack build --target web --out-dir pkg || echo 'wasm-pack not installed, skipping WASM build'",
|
|
32
|
+
"build:nodejs": "wasm-pack build --target nodejs --out-dir pkg-node",
|
|
33
|
+
"build:bundler": "wasm-pack build --target bundler --out-dir pkg-bundler",
|
|
34
|
+
"test": "cargo test || echo 'cargo not installed, skipping WASM tests'",
|
|
35
|
+
"clean": "rm -rf pkg pkg-node pkg-bundler target"
|
|
36
|
+
}
|
|
37
|
+
}
|