@forthix/forthic 0.3.0 → 0.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 +63 -73
- package/dist/cjs/common/temporal_utils.d.ts +36 -0
- package/dist/cjs/common/temporal_utils.js +80 -0
- package/dist/cjs/common/temporal_utils.js.map +1 -0
- package/dist/cjs/common/type_utils.d.ts +31 -0
- package/dist/cjs/common/type_utils.js +79 -0
- package/dist/cjs/common/type_utils.js.map +1 -0
- package/dist/cjs/forthic/decorators/word.d.ts +15 -7
- package/dist/cjs/forthic/decorators/word.js +52 -21
- package/dist/cjs/forthic/decorators/word.js.map +1 -1
- package/dist/cjs/forthic/execution_planner.d.ts +76 -0
- package/dist/cjs/forthic/execution_planner.js +125 -0
- package/dist/cjs/forthic/execution_planner.js.map +1 -0
- package/dist/cjs/forthic/interpreter.d.ts +12 -2
- package/dist/cjs/forthic/interpreter.js +95 -14
- package/dist/cjs/forthic/interpreter.js.map +1 -1
- package/dist/cjs/forthic/module.d.ts +28 -0
- package/dist/cjs/forthic/module.js +72 -8
- package/dist/cjs/forthic/module.js.map +1 -1
- package/dist/cjs/forthic/modules/{array_module.d.ts → standard/array_module.d.ts} +2 -2
- package/dist/cjs/forthic/modules/{array_module.js → standard/array_module.js} +32 -32
- package/dist/cjs/forthic/modules/standard/array_module.js.map +1 -0
- package/dist/{esm/forthic/modules → cjs/forthic/modules/standard}/boolean_module.d.ts +2 -2
- package/dist/cjs/forthic/modules/{boolean_module.js → standard/boolean_module.js} +17 -17
- package/dist/cjs/forthic/modules/standard/boolean_module.js.map +1 -0
- package/dist/cjs/forthic/modules/{core_module.d.ts → standard/core_module.d.ts} +2 -2
- package/dist/cjs/forthic/modules/{core_module.js → standard/core_module.js} +32 -32
- package/dist/cjs/forthic/modules/standard/core_module.js.map +1 -0
- package/dist/{esm/forthic/modules → cjs/forthic/modules/standard}/datetime_module.d.ts +2 -2
- package/dist/cjs/forthic/modules/{datetime_module.js → standard/datetime_module.js} +17 -17
- package/dist/cjs/forthic/modules/standard/datetime_module.js.map +1 -0
- package/dist/cjs/forthic/modules/{json_module.d.ts → standard/json_module.d.ts} +1 -1
- package/dist/cjs/forthic/modules/{json_module.js → standard/json_module.js} +4 -4
- package/dist/cjs/forthic/modules/standard/json_module.js.map +1 -0
- package/dist/cjs/forthic/modules/{math_module.d.ts → standard/math_module.d.ts} +2 -2
- package/dist/cjs/forthic/modules/{math_module.js → standard/math_module.js} +26 -26
- package/dist/cjs/forthic/modules/standard/math_module.js.map +1 -0
- package/dist/cjs/forthic/modules/{record_module.d.ts → standard/record_module.d.ts} +1 -1
- package/dist/cjs/forthic/modules/{record_module.js → standard/record_module.js} +11 -11
- package/dist/cjs/forthic/modules/standard/record_module.js.map +1 -0
- package/dist/cjs/forthic/modules/{string_module.d.ts → standard/string_module.d.ts} +2 -2
- package/dist/cjs/forthic/modules/{string_module.js → standard/string_module.js} +19 -19
- package/dist/cjs/forthic/modules/standard/string_module.js.map +1 -0
- package/dist/cjs/forthic/modules/typescript/fs_module.d.ts +17 -0
- package/dist/cjs/forthic/modules/typescript/fs_module.js +169 -0
- package/dist/cjs/forthic/modules/typescript/fs_module.js.map +1 -0
- package/dist/cjs/grpc/browser-stub.d.ts +26 -0
- package/dist/cjs/grpc/browser-stub.js +45 -0
- package/dist/cjs/grpc/browser-stub.js.map +1 -0
- package/dist/cjs/grpc/client.d.ts +53 -0
- package/dist/cjs/grpc/client.js +186 -0
- package/dist/cjs/grpc/client.js.map +1 -0
- package/dist/cjs/grpc/config_loader.d.ts +72 -0
- package/dist/cjs/grpc/config_loader.js +198 -0
- package/dist/cjs/grpc/config_loader.js.map +1 -0
- package/dist/cjs/grpc/errors.d.ts +55 -0
- package/dist/cjs/grpc/errors.js +126 -0
- package/dist/cjs/grpc/errors.js.map +1 -0
- package/dist/cjs/grpc/index.d.ts +15 -0
- package/dist/cjs/grpc/index.js +23 -0
- package/dist/cjs/grpc/index.js.map +1 -0
- package/dist/cjs/grpc/remote_module.d.ts +66 -0
- package/dist/cjs/grpc/remote_module.js +105 -0
- package/dist/cjs/grpc/remote_module.js.map +1 -0
- package/dist/cjs/grpc/remote_runtime_module.d.ts +33 -0
- package/dist/cjs/grpc/remote_runtime_module.js +171 -0
- package/dist/cjs/grpc/remote_runtime_module.js.map +1 -0
- package/dist/cjs/grpc/remote_word.d.ts +53 -0
- package/dist/cjs/grpc/remote_word.js +94 -0
- package/dist/cjs/grpc/remote_word.js.map +1 -0
- package/dist/cjs/grpc/runtime_manager.d.ts +63 -0
- package/dist/cjs/grpc/runtime_manager.js +100 -0
- package/dist/cjs/grpc/runtime_manager.js.map +1 -0
- package/dist/cjs/grpc/serializer.d.ts +45 -0
- package/dist/cjs/grpc/serializer.js +105 -0
- package/dist/cjs/grpc/serializer.js.map +1 -0
- package/dist/cjs/grpc/server.d.ts +14 -0
- package/dist/cjs/grpc/server.js +362 -0
- package/dist/cjs/grpc/server.js.map +1 -0
- package/dist/cjs/grpc/server.test.d.ts +1 -0
- package/dist/cjs/grpc/server.test.js +156 -0
- package/dist/cjs/grpc/server.test.js.map +1 -0
- package/dist/cjs/grpc/temporal_utils.d.ts +36 -0
- package/dist/cjs/grpc/temporal_utils.js +80 -0
- package/dist/cjs/grpc/temporal_utils.js.map +1 -0
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/websocket/action_cable/client.d.ts +106 -0
- package/dist/cjs/websocket/action_cable/client.js +269 -0
- package/dist/cjs/websocket/action_cable/client.js.map +1 -0
- package/dist/cjs/websocket/action_cable/index.d.ts +8 -0
- package/dist/cjs/websocket/action_cable/index.js +16 -0
- package/dist/cjs/websocket/action_cable/index.js.map +1 -0
- package/dist/cjs/websocket/action_cable/remote_module.d.ts +68 -0
- package/dist/cjs/websocket/action_cable/remote_module.js +107 -0
- package/dist/cjs/websocket/action_cable/remote_module.js.map +1 -0
- package/dist/cjs/websocket/action_cable/remote_word.d.ts +53 -0
- package/dist/cjs/websocket/action_cable/remote_word.js +93 -0
- package/dist/cjs/websocket/action_cable/remote_word.js.map +1 -0
- package/dist/cjs/websocket/action_cable/runtime_manager.d.ts +69 -0
- package/dist/cjs/websocket/action_cable/runtime_manager.js +112 -0
- package/dist/cjs/websocket/action_cable/runtime_manager.js.map +1 -0
- package/dist/cjs/websocket/action_cable_client.d.ts +106 -0
- package/dist/cjs/websocket/action_cable_client.js +269 -0
- package/dist/cjs/websocket/action_cable_client.js.map +1 -0
- package/dist/cjs/websocket/client.d.ts +103 -0
- package/dist/cjs/websocket/client.js +266 -0
- package/dist/cjs/websocket/client.js.map +1 -0
- package/dist/cjs/websocket/errors.d.ts +45 -0
- package/dist/cjs/websocket/errors.js +98 -0
- package/dist/cjs/websocket/errors.js.map +1 -0
- package/dist/cjs/websocket/index.d.ts +13 -0
- package/dist/cjs/websocket/index.js +28 -0
- package/dist/cjs/websocket/index.js.map +1 -0
- package/dist/cjs/websocket/remote_module.d.ts +68 -0
- package/dist/cjs/websocket/remote_module.js +107 -0
- package/dist/cjs/websocket/remote_module.js.map +1 -0
- package/dist/cjs/websocket/remote_word.d.ts +53 -0
- package/dist/cjs/websocket/remote_word.js +93 -0
- package/dist/cjs/websocket/remote_word.js.map +1 -0
- package/dist/cjs/websocket/runtime_manager.d.ts +69 -0
- package/dist/cjs/websocket/runtime_manager.js +112 -0
- package/dist/cjs/websocket/runtime_manager.js.map +1 -0
- package/dist/cjs/websocket/serializer.d.ts +27 -0
- package/dist/cjs/websocket/serializer.js +106 -0
- package/dist/cjs/websocket/serializer.js.map +1 -0
- package/dist/esm/common/temporal_utils.d.ts +36 -0
- package/dist/esm/common/temporal_utils.js +72 -0
- package/dist/esm/common/temporal_utils.js.map +1 -0
- package/dist/esm/common/type_utils.d.ts +31 -0
- package/dist/esm/common/type_utils.js +73 -0
- package/dist/esm/common/type_utils.js.map +1 -0
- package/dist/esm/forthic/decorators/word.d.ts +15 -7
- package/dist/esm/forthic/decorators/word.js +51 -20
- package/dist/esm/forthic/decorators/word.js.map +1 -1
- package/dist/esm/forthic/execution_planner.d.ts +76 -0
- package/dist/esm/forthic/execution_planner.js +121 -0
- package/dist/esm/forthic/execution_planner.js.map +1 -0
- package/dist/esm/forthic/interpreter.d.ts +12 -2
- package/dist/esm/forthic/interpreter.js +95 -14
- package/dist/esm/forthic/interpreter.js.map +1 -1
- package/dist/esm/forthic/module.d.ts +28 -0
- package/dist/esm/forthic/module.js +72 -8
- package/dist/esm/forthic/module.js.map +1 -1
- package/dist/esm/forthic/modules/{array_module.d.ts → standard/array_module.d.ts} +2 -2
- package/dist/esm/forthic/modules/{array_module.js → standard/array_module.js} +32 -32
- package/dist/esm/forthic/modules/standard/array_module.js.map +1 -0
- package/dist/{cjs/forthic/modules → esm/forthic/modules/standard}/boolean_module.d.ts +2 -2
- package/dist/esm/forthic/modules/{boolean_module.js → standard/boolean_module.js} +16 -16
- package/dist/esm/forthic/modules/standard/boolean_module.js.map +1 -0
- package/dist/esm/forthic/modules/{core_module.d.ts → standard/core_module.d.ts} +2 -2
- package/dist/esm/forthic/modules/{core_module.js → standard/core_module.js} +32 -32
- package/dist/esm/forthic/modules/standard/core_module.js.map +1 -0
- package/dist/{cjs/forthic/modules → esm/forthic/modules/standard}/datetime_module.d.ts +2 -2
- package/dist/esm/forthic/modules/{datetime_module.js → standard/datetime_module.js} +16 -16
- package/dist/esm/forthic/modules/standard/datetime_module.js.map +1 -0
- package/dist/esm/forthic/modules/{json_module.d.ts → standard/json_module.d.ts} +1 -1
- package/dist/esm/forthic/modules/{json_module.js → standard/json_module.js} +4 -4
- package/dist/esm/forthic/modules/standard/json_module.js.map +1 -0
- package/dist/esm/forthic/modules/{math_module.d.ts → standard/math_module.d.ts} +2 -2
- package/dist/esm/forthic/modules/{math_module.js → standard/math_module.js} +25 -25
- package/dist/esm/forthic/modules/standard/math_module.js.map +1 -0
- package/dist/esm/forthic/modules/{record_module.d.ts → standard/record_module.d.ts} +1 -1
- package/dist/esm/forthic/modules/{record_module.js → standard/record_module.js} +11 -11
- package/dist/esm/forthic/modules/standard/record_module.js.map +1 -0
- package/dist/esm/forthic/modules/{string_module.d.ts → standard/string_module.d.ts} +2 -2
- package/dist/esm/forthic/modules/{string_module.js → standard/string_module.js} +18 -18
- package/dist/esm/forthic/modules/standard/string_module.js.map +1 -0
- package/dist/esm/forthic/modules/typescript/fs_module.d.ts +17 -0
- package/dist/esm/forthic/modules/typescript/fs_module.js +102 -0
- package/dist/esm/forthic/modules/typescript/fs_module.js.map +1 -0
- package/dist/esm/grpc/browser-stub.d.ts +26 -0
- package/dist/esm/grpc/browser-stub.js +36 -0
- package/dist/esm/grpc/browser-stub.js.map +1 -0
- package/dist/esm/grpc/client.d.ts +53 -0
- package/dist/esm/grpc/client.js +149 -0
- package/dist/esm/grpc/client.js.map +1 -0
- package/dist/esm/grpc/config_loader.d.ts +72 -0
- package/dist/esm/grpc/config_loader.js +158 -0
- package/dist/esm/grpc/config_loader.js.map +1 -0
- package/dist/esm/grpc/errors.d.ts +55 -0
- package/dist/esm/grpc/errors.js +121 -0
- package/dist/esm/grpc/errors.js.map +1 -0
- package/dist/esm/grpc/index.d.ts +15 -0
- package/dist/esm/grpc/index.js +14 -0
- package/dist/esm/grpc/index.js.map +1 -0
- package/dist/esm/grpc/remote_module.d.ts +66 -0
- package/dist/esm/grpc/remote_module.js +101 -0
- package/dist/esm/grpc/remote_module.js.map +1 -0
- package/dist/esm/grpc/remote_runtime_module.d.ts +33 -0
- package/dist/esm/grpc/remote_runtime_module.js +149 -0
- package/dist/esm/grpc/remote_runtime_module.js.map +1 -0
- package/dist/esm/grpc/remote_word.d.ts +53 -0
- package/dist/esm/grpc/remote_word.js +90 -0
- package/dist/esm/grpc/remote_word.js.map +1 -0
- package/dist/esm/grpc/runtime_manager.d.ts +63 -0
- package/dist/esm/grpc/runtime_manager.js +96 -0
- package/dist/esm/grpc/runtime_manager.js.map +1 -0
- package/dist/esm/grpc/serializer.d.ts +45 -0
- package/dist/esm/grpc/serializer.js +101 -0
- package/dist/esm/grpc/serializer.js.map +1 -0
- package/dist/esm/grpc/server.d.ts +14 -0
- package/dist/esm/grpc/server.js +325 -0
- package/dist/esm/grpc/server.js.map +1 -0
- package/dist/esm/grpc/server.test.d.ts +1 -0
- package/dist/esm/grpc/server.test.js +121 -0
- package/dist/esm/grpc/server.test.js.map +1 -0
- package/dist/esm/grpc/temporal_utils.d.ts +36 -0
- package/dist/esm/grpc/temporal_utils.js +72 -0
- package/dist/esm/grpc/temporal_utils.js.map +1 -0
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/websocket/action_cable/client.d.ts +106 -0
- package/dist/esm/websocket/action_cable/client.js +265 -0
- package/dist/esm/websocket/action_cable/client.js.map +1 -0
- package/dist/esm/websocket/action_cable/index.d.ts +8 -0
- package/dist/esm/websocket/action_cable/index.js +9 -0
- package/dist/esm/websocket/action_cable/index.js.map +1 -0
- package/dist/esm/websocket/action_cable/remote_module.d.ts +68 -0
- package/dist/esm/websocket/action_cable/remote_module.js +103 -0
- package/dist/esm/websocket/action_cable/remote_module.js.map +1 -0
- package/dist/esm/websocket/action_cable/remote_word.d.ts +53 -0
- package/dist/esm/websocket/action_cable/remote_word.js +89 -0
- package/dist/esm/websocket/action_cable/remote_word.js.map +1 -0
- package/dist/esm/websocket/action_cable/runtime_manager.d.ts +69 -0
- package/dist/esm/websocket/action_cable/runtime_manager.js +108 -0
- package/dist/esm/websocket/action_cable/runtime_manager.js.map +1 -0
- package/dist/esm/websocket/action_cable_client.d.ts +106 -0
- package/dist/esm/websocket/action_cable_client.js +265 -0
- package/dist/esm/websocket/action_cable_client.js.map +1 -0
- package/dist/esm/websocket/client.d.ts +103 -0
- package/dist/esm/websocket/client.js +262 -0
- package/dist/esm/websocket/client.js.map +1 -0
- package/dist/esm/websocket/errors.d.ts +45 -0
- package/dist/esm/websocket/errors.js +94 -0
- package/dist/esm/websocket/errors.js.map +1 -0
- package/dist/esm/websocket/index.d.ts +13 -0
- package/dist/esm/websocket/index.js +16 -0
- package/dist/esm/websocket/index.js.map +1 -0
- package/dist/esm/websocket/remote_module.d.ts +68 -0
- package/dist/esm/websocket/remote_module.js +103 -0
- package/dist/esm/websocket/remote_module.js.map +1 -0
- package/dist/esm/websocket/remote_word.d.ts +53 -0
- package/dist/esm/websocket/remote_word.js +89 -0
- package/dist/esm/websocket/remote_word.js.map +1 -0
- package/dist/esm/websocket/runtime_manager.d.ts +69 -0
- package/dist/esm/websocket/runtime_manager.js +108 -0
- package/dist/esm/websocket/runtime_manager.js.map +1 -0
- package/dist/esm/websocket/serializer.d.ts +27 -0
- package/dist/esm/websocket/serializer.js +100 -0
- package/dist/esm/websocket/serializer.js.map +1 -0
- package/package.json +37 -6
- package/protos/README.md +45 -0
- package/protos/v1/forthic_runtime.proto +200 -0
- package/dist/cjs/forthic/modules/array_module.js.map +0 -1
- package/dist/cjs/forthic/modules/boolean_module.js.map +0 -1
- package/dist/cjs/forthic/modules/core_module.js.map +0 -1
- package/dist/cjs/forthic/modules/datetime_module.js.map +0 -1
- package/dist/cjs/forthic/modules/json_module.js.map +0 -1
- package/dist/cjs/forthic/modules/math_module.js.map +0 -1
- package/dist/cjs/forthic/modules/record_module.js.map +0 -1
- package/dist/cjs/forthic/modules/string_module.js.map +0 -1
- package/dist/esm/forthic/modules/array_module.js.map +0 -1
- package/dist/esm/forthic/modules/boolean_module.js.map +0 -1
- package/dist/esm/forthic/modules/core_module.js.map +0 -1
- package/dist/esm/forthic/modules/datetime_module.js.map +0 -1
- package/dist/esm/forthic/modules/json_module.js.map +0 -1
- package/dist/esm/forthic/modules/math_module.js.map +0 -1
- package/dist/esm/forthic/modules/record_module.js.map +0 -1
- package/dist/esm/forthic/modules/string_module.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
# Forthic TypeScript Runtime
|
|
2
2
|
|
|
3
|
-
**A TypeScript/JavaScript runtime for [Forthic](https://github.com/forthix/forthic)** - the stack-based, concatenative language for composable transformations.
|
|
3
|
+
**A TypeScript/JavaScript runtime for [Forthic](https://github.com/forthix/forthic)** - *the* stack-based, concatenative language for composable transformations.
|
|
4
4
|
|
|
5
|
-
Use Forthic to wrap your TypeScript/JavaScript code
|
|
5
|
+
Use Forthic to wrap your TypeScript/JavaScript code within composable words, leveraging categorical principles for clean, powerful abstractions.
|
|
6
6
|
|
|
7
|
-
**[
|
|
7
|
+
**[Forthic Parent Documentation](https://github.com/forthix/forthic)** | **[Getting Started with forthic-ts](#getting-started)** | **[Examples](examples/)** | **[API Docs](docs/)**
|
|
8
8
|
|
|
9
9
|
---
|
|
10
10
|
|
|
11
11
|
## What is Forthic?
|
|
12
12
|
|
|
13
|
-
Forthic enables **categorical coding** -
|
|
13
|
+
Forthic enables **categorical coding** - a way to solve problems by viewing them in terms of trasnformation rather than copmutation. This TypeScript runtime lets you:
|
|
14
14
|
|
|
15
15
|
1. **Wrap existing code** with simple decorators
|
|
16
16
|
2. **Compose transformations** cleanly using stack-based operations
|
|
@@ -55,9 +55,9 @@ const interp = new Interpreter();
|
|
|
55
55
|
interp.register_module(new AnalyticsModule());
|
|
56
56
|
|
|
57
57
|
await interp.run(`
|
|
58
|
-
["analytics"]
|
|
58
|
+
["analytics"] USE-MODULES
|
|
59
59
|
|
|
60
|
-
[1 2 3 100 4 5] 2 FILTER-OUTLIERS
|
|
60
|
+
[1 2 3 100 4 5] 2 FILTER-OUTLIERS AVERAGE
|
|
61
61
|
`);
|
|
62
62
|
|
|
63
63
|
const result = interp.stack_pop(); // Clean average without outliers
|
|
@@ -132,12 +132,12 @@ const interp = new Interpreter();
|
|
|
132
132
|
interp.register_module(new MyModule());
|
|
133
133
|
|
|
134
134
|
await interp.run(`
|
|
135
|
-
["mymodule"]
|
|
135
|
+
["mymodule"] USE-MODULES
|
|
136
136
|
SOME-DATA PROCESS
|
|
137
137
|
`);
|
|
138
138
|
```
|
|
139
139
|
|
|
140
|
-
See [
|
|
140
|
+
See [examples/README.md](examples/README.md) for detailed tutorials and examples.
|
|
141
141
|
|
|
142
142
|
---
|
|
143
143
|
|
|
@@ -162,7 +162,7 @@ See [docs/modules/](docs/modules/) for complete reference.
|
|
|
162
162
|
The `@Word` decorator makes wrapping code trivial:
|
|
163
163
|
|
|
164
164
|
```typescript
|
|
165
|
-
@Word("( input:type -- output:type )", "Description")
|
|
165
|
+
@Word("( input:type -- output:type )", "Description", "MY-WORD")
|
|
166
166
|
async MY_WORD(input: any) {
|
|
167
167
|
return yourLogic(input);
|
|
168
168
|
}
|
|
@@ -175,19 +175,27 @@ async MY_WORD(input: any) {
|
|
|
175
175
|
- Browser and Node.js compatible
|
|
176
176
|
- Supports async/await
|
|
177
177
|
|
|
178
|
-
|
|
178
|
+
|
|
179
|
+
### Package Exports
|
|
180
|
+
|
|
181
|
+
forthic-ts provides multiple import paths for different use cases:
|
|
179
182
|
|
|
180
183
|
```typescript
|
|
181
|
-
//
|
|
182
|
-
|
|
183
|
-
: CLEAN-AVERAGE 2 analytics.FILTER-OUTLIERS analytics.AVERAGE ;
|
|
184
|
+
// Main package - Core interpreter and standard library (works everywhere)
|
|
185
|
+
import { Interpreter, DecoratedModule, Word } from '@forthix/forthic';
|
|
184
186
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
187
|
+
// WebSocket support - Browser-compatible multi-runtime execution
|
|
188
|
+
import { ActionCableClient, WebSocketRemoteModule } from '@forthix/forthic/websocket';
|
|
189
|
+
|
|
190
|
+
// gRPC support - Node.js-only multi-runtime execution
|
|
191
|
+
import { GrpcClient, RemoteModule, startGrpcServer } from '@forthix/forthic/grpc';
|
|
189
192
|
```
|
|
190
193
|
|
|
194
|
+
**Environment Compatibility**:
|
|
195
|
+
- **Main package** (`@forthix/forthic`): Works in both Node.js and browsers
|
|
196
|
+
- **WebSocket** (`@forthix/forthic/websocket`): Works in both Node.js and browsers
|
|
197
|
+
- **gRPC** (`@forthix/forthic/grpc`): Node.js only (requires `@grpc/grpc-js`)
|
|
198
|
+
|
|
191
199
|
---
|
|
192
200
|
|
|
193
201
|
## Documentation
|
|
@@ -207,57 +215,7 @@ await interp.run(`
|
|
|
207
215
|
|
|
208
216
|
## Examples
|
|
209
217
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
```typescript
|
|
213
|
-
await interp.run(`
|
|
214
|
-
data-records
|
|
215
|
-
'DUP "score" REC@ 80 >' SELECT # Filter records with score > 80
|
|
216
|
-
'"name" REC@' MAP # Extract names
|
|
217
|
-
'UPPERCASE' MAP # Convert to uppercase
|
|
218
|
-
', ' JOIN # Join into comma-separated string
|
|
219
|
-
`);
|
|
220
|
-
```
|
|
221
|
-
|
|
222
|
-
### Wrapping Business Logic
|
|
223
|
-
|
|
224
|
-
```typescript
|
|
225
|
-
export class OrderModule extends DecoratedModule {
|
|
226
|
-
constructor(private orderService: OrderService) {
|
|
227
|
-
super("orders");
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
@Word("( order:object -- validatedOrder:object )", "Validate order")
|
|
231
|
-
async VALIDATE(order: any) {
|
|
232
|
-
return this.orderService.validate(order);
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
@Word("( order:object -- orderWithTax:object )", "Calculate tax")
|
|
236
|
-
async CALCULATE_TAX(order: any) {
|
|
237
|
-
return this.orderService.calculateTax(order);
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
@Word("( order:object -- submittedOrder:object )", "Submit order")
|
|
241
|
-
async SUBMIT(order: any) {
|
|
242
|
-
return this.orderService.submit(order);
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
// Compose into high-level workflow
|
|
247
|
-
await interp.run(`
|
|
248
|
-
["orders"] USE_MODULES
|
|
249
|
-
|
|
250
|
-
: PROCESS-ORDER
|
|
251
|
-
VALIDATE
|
|
252
|
-
CALCULATE-TAX
|
|
253
|
-
SUBMIT
|
|
254
|
-
;
|
|
255
|
-
|
|
256
|
-
new-order PROCESS-ORDER
|
|
257
|
-
`);
|
|
258
|
-
```
|
|
259
|
-
|
|
260
|
-
More examples in [examples/](examples/) directory.
|
|
218
|
+
See examples in the [examples](examples/) directory.
|
|
261
219
|
|
|
262
220
|
---
|
|
263
221
|
|
|
@@ -279,13 +237,45 @@ npm run docs:build
|
|
|
279
237
|
|
|
280
238
|
---
|
|
281
239
|
|
|
282
|
-
## Multi-Runtime
|
|
240
|
+
## Multi-Runtime Execution
|
|
241
|
+
|
|
242
|
+
Call code from other language runtimes seamlessly - use Python's pandas from TypeScript, or TypeScript's fs module from Ruby.
|
|
243
|
+
|
|
244
|
+
### Quick Example
|
|
245
|
+
|
|
246
|
+
```typescript
|
|
247
|
+
import { Interpreter } from '@forthix/forthic';
|
|
248
|
+
import { GrpcClient, RemoteModule } from '@forthix/forthic/grpc';
|
|
249
|
+
|
|
250
|
+
const interp = new Interpreter();
|
|
251
|
+
|
|
252
|
+
// Connect to Python runtime
|
|
253
|
+
const client = new GrpcClient('localhost:50051');
|
|
254
|
+
const pandas = new RemoteModule('pandas', client, 'python');
|
|
255
|
+
await pandas.initialize();
|
|
256
|
+
|
|
257
|
+
interp.register_module(pandas);
|
|
258
|
+
|
|
259
|
+
// Now use Python pandas from TypeScript!
|
|
260
|
+
await interp.run(`["pandas"] USE-MODULES [records] DF-FROM-RECORDS`);
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
### Approaches
|
|
264
|
+
|
|
265
|
+
- **gRPC** - Node.js ↔ Python ↔ Ruby (fast, server-to-server)
|
|
266
|
+
- **WebSocket** - Browser ↔ Rails (ActionCable, client-server)
|
|
267
|
+
|
|
268
|
+
### Learn More
|
|
283
269
|
|
|
284
|
-
|
|
270
|
+
📖 **[Complete Multi-Runtime Documentation](docs/multi-runtime/)**
|
|
285
271
|
|
|
286
|
-
|
|
272
|
+
- **[Overview](docs/multi-runtime/)** - When and how to use multi-runtime
|
|
273
|
+
- **[gRPC Setup](docs/multi-runtime/grpc.md)** - Server and client configuration
|
|
274
|
+
- **[WebSocket Setup](docs/multi-runtime/websocket.md)** - Browser-compatible communication
|
|
275
|
+
- **[Configuration](docs/multi-runtime/configuration.md)** - YAML config and connection management
|
|
276
|
+
- **[Examples](examples/)** - Working code samples (05-grpc-server.ts, 06-grpc-client.ts)
|
|
287
277
|
|
|
288
|
-
**Status:** TypeScript
|
|
278
|
+
**Runtime Status:** ✅ TypeScript, Python, Ruby | 🚧 Rust | 📋 Java, .NET
|
|
289
279
|
|
|
290
280
|
---
|
|
291
281
|
|
|
@@ -322,4 +312,4 @@ Also see the [main Forthic contributing guide](https://github.com/forthix/forthi
|
|
|
322
312
|
|
|
323
313
|
---
|
|
324
314
|
|
|
325
|
-
**Forthic
|
|
315
|
+
**Forthic**: Wrap. Compose. Abstract.
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Temporal Type Utilities
|
|
3
|
+
*
|
|
4
|
+
* Provides duck-typing helpers for checking Temporal types.
|
|
5
|
+
* Uses duck typing instead of instanceof to avoid issues with multiple
|
|
6
|
+
* instances of temporal-polyfill being loaded.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Check if a value is a Temporal.PlainDate
|
|
10
|
+
* PlainDate has year, month, day properties but no hour property
|
|
11
|
+
*/
|
|
12
|
+
export declare function isPlainDate(value: any): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Check if a value is a Temporal.Instant
|
|
15
|
+
* Instant has epochNanoseconds property as a bigint
|
|
16
|
+
*/
|
|
17
|
+
export declare function isInstant(value: any): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Check if a value is a Temporal.ZonedDateTime
|
|
20
|
+
* ZonedDateTime has a timeZoneId property
|
|
21
|
+
*/
|
|
22
|
+
export declare function isZonedDateTime(value: any): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Check if a value is a Temporal.PlainTime
|
|
25
|
+
* PlainTime has hour and minute properties but no year
|
|
26
|
+
*/
|
|
27
|
+
export declare function isPlainTime(value: any): boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Check if a value is a Temporal.PlainDateTime
|
|
30
|
+
* PlainDateTime has year, month, day, hour properties but no timeZoneId
|
|
31
|
+
*/
|
|
32
|
+
export declare function isPlainDateTime(value: any): boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Check if a value is any Temporal type
|
|
35
|
+
*/
|
|
36
|
+
export declare function isTemporal(value: any): boolean;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Temporal Type Utilities
|
|
4
|
+
*
|
|
5
|
+
* Provides duck-typing helpers for checking Temporal types.
|
|
6
|
+
* Uses duck typing instead of instanceof to avoid issues with multiple
|
|
7
|
+
* instances of temporal-polyfill being loaded.
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.isPlainDate = isPlainDate;
|
|
11
|
+
exports.isInstant = isInstant;
|
|
12
|
+
exports.isZonedDateTime = isZonedDateTime;
|
|
13
|
+
exports.isPlainTime = isPlainTime;
|
|
14
|
+
exports.isPlainDateTime = isPlainDateTime;
|
|
15
|
+
exports.isTemporal = isTemporal;
|
|
16
|
+
/**
|
|
17
|
+
* Check if a value is a Temporal.PlainDate
|
|
18
|
+
* PlainDate has year, month, day properties but no hour property
|
|
19
|
+
*/
|
|
20
|
+
function isPlainDate(value) {
|
|
21
|
+
return value && typeof value === 'object' &&
|
|
22
|
+
typeof value.year === 'number' &&
|
|
23
|
+
typeof value.month === 'number' &&
|
|
24
|
+
typeof value.day === 'number' &&
|
|
25
|
+
typeof value.toString === 'function' &&
|
|
26
|
+
!value.hour; // PlainDate doesn't have hour
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Check if a value is a Temporal.Instant
|
|
30
|
+
* Instant has epochNanoseconds property as a bigint
|
|
31
|
+
*/
|
|
32
|
+
function isInstant(value) {
|
|
33
|
+
return value && typeof value === 'object' &&
|
|
34
|
+
typeof value.epochNanoseconds === 'bigint' &&
|
|
35
|
+
typeof value.toString === 'function';
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Check if a value is a Temporal.ZonedDateTime
|
|
39
|
+
* ZonedDateTime has a timeZoneId property
|
|
40
|
+
*/
|
|
41
|
+
function isZonedDateTime(value) {
|
|
42
|
+
return value && typeof value === 'object' &&
|
|
43
|
+
typeof value.timeZoneId === 'string' &&
|
|
44
|
+
typeof value.toString === 'function';
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Check if a value is a Temporal.PlainTime
|
|
48
|
+
* PlainTime has hour and minute properties but no year
|
|
49
|
+
*/
|
|
50
|
+
function isPlainTime(value) {
|
|
51
|
+
return value && typeof value === 'object' &&
|
|
52
|
+
typeof value.hour === 'number' &&
|
|
53
|
+
typeof value.minute === 'number' &&
|
|
54
|
+
typeof value.toString === 'function' &&
|
|
55
|
+
!value.year; // PlainTime doesn't have year
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Check if a value is a Temporal.PlainDateTime
|
|
59
|
+
* PlainDateTime has year, month, day, hour properties but no timeZoneId
|
|
60
|
+
*/
|
|
61
|
+
function isPlainDateTime(value) {
|
|
62
|
+
return value && typeof value === 'object' &&
|
|
63
|
+
typeof value.year === 'number' &&
|
|
64
|
+
typeof value.month === 'number' &&
|
|
65
|
+
typeof value.day === 'number' &&
|
|
66
|
+
typeof value.hour === 'number' &&
|
|
67
|
+
typeof value.toString === 'function' &&
|
|
68
|
+
!value.timeZoneId; // PlainDateTime doesn't have timeZoneId
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Check if a value is any Temporal type
|
|
72
|
+
*/
|
|
73
|
+
function isTemporal(value) {
|
|
74
|
+
return isPlainDate(value) ||
|
|
75
|
+
isInstant(value) ||
|
|
76
|
+
isZonedDateTime(value) ||
|
|
77
|
+
isPlainTime(value) ||
|
|
78
|
+
isPlainDateTime(value);
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=temporal_utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"temporal_utils.js","sourceRoot":"","sources":["../../../src/common/temporal_utils.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;AAMH,kCAOC;AAMD,8BAIC;AAMD,0CAIC;AAMD,kCAMC;AAMD,0CAQC;AAKD,gCAMC;AApED;;;GAGG;AACH,SAAgB,WAAW,CAAC,KAAU;IACpC,OAAO,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ;QAClC,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ;QAC9B,OAAO,KAAK,CAAC,KAAK,KAAK,QAAQ;QAC/B,OAAO,KAAK,CAAC,GAAG,KAAK,QAAQ;QAC7B,OAAO,KAAK,CAAC,QAAQ,KAAK,UAAU;QACpC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAE,8BAA8B;AACrD,CAAC;AAED;;;GAGG;AACH,SAAgB,SAAS,CAAC,KAAU;IAClC,OAAO,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ;QAClC,OAAO,KAAK,CAAC,gBAAgB,KAAK,QAAQ;QAC1C,OAAO,KAAK,CAAC,QAAQ,KAAK,UAAU,CAAC;AAC9C,CAAC;AAED;;;GAGG;AACH,SAAgB,eAAe,CAAC,KAAU;IACxC,OAAO,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ;QAClC,OAAO,KAAK,CAAC,UAAU,KAAK,QAAQ;QACpC,OAAO,KAAK,CAAC,QAAQ,KAAK,UAAU,CAAC;AAC9C,CAAC;AAED;;;GAGG;AACH,SAAgB,WAAW,CAAC,KAAU;IACpC,OAAO,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ;QAClC,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ;QAC9B,OAAO,KAAK,CAAC,MAAM,KAAK,QAAQ;QAChC,OAAO,KAAK,CAAC,QAAQ,KAAK,UAAU;QACpC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAE,8BAA8B;AACrD,CAAC;AAED;;;GAGG;AACH,SAAgB,eAAe,CAAC,KAAU;IACxC,OAAO,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ;QAClC,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ;QAC9B,OAAO,KAAK,CAAC,KAAK,KAAK,QAAQ;QAC/B,OAAO,KAAK,CAAC,GAAG,KAAK,QAAQ;QAC7B,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ;QAC9B,OAAO,KAAK,CAAC,QAAQ,KAAK,UAAU;QACpC,CAAC,KAAK,CAAC,UAAU,CAAC,CAAE,wCAAwC;AACrE,CAAC;AAED;;GAEG;AACH,SAAgB,UAAU,CAAC,KAAU;IACnC,OAAO,WAAW,CAAC,KAAK,CAAC;QAClB,SAAS,CAAC,KAAK,CAAC;QAChB,eAAe,CAAC,KAAK,CAAC;QACtB,WAAW,CAAC,KAAK,CAAC;QAClB,eAAe,CAAC,KAAK,CAAC,CAAC;AAChC,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared type detection utilities for Forthic value serialization
|
|
3
|
+
* Used by both gRPC and WebSocket serializers
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Forthic value types
|
|
7
|
+
*/
|
|
8
|
+
export type ForthicType = 'null' | 'boolean' | 'integer' | 'float' | 'string' | 'array' | 'record' | 'instant' | 'plain_date' | 'zoned_datetime';
|
|
9
|
+
/**
|
|
10
|
+
* Get the Forthic type of a JavaScript value
|
|
11
|
+
* Determines the correct serialization type for a value
|
|
12
|
+
*
|
|
13
|
+
* IMPORTANT: Order matters!
|
|
14
|
+
* - Check temporal types BEFORE primitives (they're objects)
|
|
15
|
+
* - Check ZonedDateTime BEFORE Instant (ZonedDateTime may match isInstant)
|
|
16
|
+
* - Check boolean BEFORE number (to avoid typeof confusion)
|
|
17
|
+
* - Check array BEFORE object (arrays are objects)
|
|
18
|
+
*/
|
|
19
|
+
export declare function getForthicType(value: any): ForthicType;
|
|
20
|
+
/**
|
|
21
|
+
* Check if a value is a temporal type
|
|
22
|
+
*/
|
|
23
|
+
export declare function isTemporalType(value: any): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Check if a value is a primitive type (not array or record)
|
|
26
|
+
*/
|
|
27
|
+
export declare function isPrimitive(value: any): boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Check if a value is a container type (array or record)
|
|
30
|
+
*/
|
|
31
|
+
export declare function isContainer(value: any): boolean;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Shared type detection utilities for Forthic value serialization
|
|
4
|
+
* Used by both gRPC and WebSocket serializers
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.getForthicType = getForthicType;
|
|
8
|
+
exports.isTemporalType = isTemporalType;
|
|
9
|
+
exports.isPrimitive = isPrimitive;
|
|
10
|
+
exports.isContainer = isContainer;
|
|
11
|
+
const temporal_utils_js_1 = require("./temporal_utils.js");
|
|
12
|
+
/**
|
|
13
|
+
* Get the Forthic type of a JavaScript value
|
|
14
|
+
* Determines the correct serialization type for a value
|
|
15
|
+
*
|
|
16
|
+
* IMPORTANT: Order matters!
|
|
17
|
+
* - Check temporal types BEFORE primitives (they're objects)
|
|
18
|
+
* - Check ZonedDateTime BEFORE Instant (ZonedDateTime may match isInstant)
|
|
19
|
+
* - Check boolean BEFORE number (to avoid typeof confusion)
|
|
20
|
+
* - Check array BEFORE object (arrays are objects)
|
|
21
|
+
*/
|
|
22
|
+
function getForthicType(value) {
|
|
23
|
+
// Handle null/undefined
|
|
24
|
+
if (value === null || value === undefined) {
|
|
25
|
+
return 'null';
|
|
26
|
+
}
|
|
27
|
+
// Handle Temporal types (check ZonedDateTime BEFORE Instant)
|
|
28
|
+
if ((0, temporal_utils_js_1.isZonedDateTime)(value)) {
|
|
29
|
+
return 'zoned_datetime';
|
|
30
|
+
}
|
|
31
|
+
if ((0, temporal_utils_js_1.isInstant)(value)) {
|
|
32
|
+
return 'instant';
|
|
33
|
+
}
|
|
34
|
+
if ((0, temporal_utils_js_1.isPlainDate)(value)) {
|
|
35
|
+
return 'plain_date';
|
|
36
|
+
}
|
|
37
|
+
// Handle boolean (check before number)
|
|
38
|
+
if (typeof value === 'boolean') {
|
|
39
|
+
return 'boolean';
|
|
40
|
+
}
|
|
41
|
+
// Handle number (distinguish integer vs float)
|
|
42
|
+
if (typeof value === 'number') {
|
|
43
|
+
return Number.isInteger(value) ? 'integer' : 'float';
|
|
44
|
+
}
|
|
45
|
+
// Handle string
|
|
46
|
+
if (typeof value === 'string') {
|
|
47
|
+
return 'string';
|
|
48
|
+
}
|
|
49
|
+
// Handle array (check before object)
|
|
50
|
+
if (Array.isArray(value)) {
|
|
51
|
+
return 'array';
|
|
52
|
+
}
|
|
53
|
+
// Handle object/record
|
|
54
|
+
if (typeof value === 'object') {
|
|
55
|
+
return 'record';
|
|
56
|
+
}
|
|
57
|
+
throw new Error(`Unsupported value type: ${typeof value}`);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Check if a value is a temporal type
|
|
61
|
+
*/
|
|
62
|
+
function isTemporalType(value) {
|
|
63
|
+
return (0, temporal_utils_js_1.isInstant)(value) || (0, temporal_utils_js_1.isPlainDate)(value) || (0, temporal_utils_js_1.isZonedDateTime)(value);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Check if a value is a primitive type (not array or record)
|
|
67
|
+
*/
|
|
68
|
+
function isPrimitive(value) {
|
|
69
|
+
const type = getForthicType(value);
|
|
70
|
+
return type !== 'array' && type !== 'record';
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Check if a value is a container type (array or record)
|
|
74
|
+
*/
|
|
75
|
+
function isContainer(value) {
|
|
76
|
+
const type = getForthicType(value);
|
|
77
|
+
return type === 'array' || type === 'record';
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=type_utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type_utils.js","sourceRoot":"","sources":["../../../src/common/type_utils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AA8BH,wCA6CC;AAKD,wCAEC;AAKD,kCAGC;AAKD,kCAGC;AA/FD,2DAA8E;AAiB9E;;;;;;;;;GASG;AACH,SAAgB,cAAc,CAAC,KAAU;IACvC,wBAAwB;IACxB,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QAC1C,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,6DAA6D;IAC7D,IAAI,IAAA,mCAAe,EAAC,KAAK,CAAC,EAAE,CAAC;QAC3B,OAAO,gBAAgB,CAAC;IAC1B,CAAC;IAED,IAAI,IAAA,6BAAS,EAAC,KAAK,CAAC,EAAE,CAAC;QACrB,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,IAAI,IAAA,+BAAW,EAAC,KAAK,CAAC,EAAE,CAAC;QACvB,OAAO,YAAY,CAAC;IACtB,CAAC;IAED,uCAAuC;IACvC,IAAI,OAAO,KAAK,KAAK,SAAS,EAAE,CAAC;QAC/B,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,+CAA+C;IAC/C,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC;IACvD,CAAC;IAED,gBAAgB;IAChB,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,qCAAqC;IACrC,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,uBAAuB;IACvB,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,2BAA2B,OAAO,KAAK,EAAE,CAAC,CAAC;AAC7D,CAAC;AAED;;GAEG;AACH,SAAgB,cAAc,CAAC,KAAU;IACvC,OAAO,IAAA,6BAAS,EAAC,KAAK,CAAC,IAAI,IAAA,+BAAW,EAAC,KAAK,CAAC,IAAI,IAAA,mCAAe,EAAC,KAAK,CAAC,CAAC;AAC1E,CAAC;AAED;;GAEG;AACH,SAAgB,WAAW,CAAC,KAAU;IACpC,MAAM,IAAI,GAAG,cAAc,CAAC,KAAK,CAAC,CAAC;IACnC,OAAO,IAAI,KAAK,OAAO,IAAI,IAAI,KAAK,QAAQ,CAAC;AAC/C,CAAC;AAED;;GAEG;AACH,SAAgB,WAAW,CAAC,KAAU;IACpC,MAAM,IAAI,GAAG,cAAc,CAAC,KAAK,CAAC,CAAC;IACnC,OAAO,IAAI,KAAK,OAAO,IAAI,IAAI,KAAK,QAAQ,CAAC;AAC/C,CAAC"}
|
|
@@ -10,7 +10,7 @@ export interface ModuleMetadata {
|
|
|
10
10
|
examples: string[];
|
|
11
11
|
}
|
|
12
12
|
/**
|
|
13
|
-
* @
|
|
13
|
+
* @ForthicDirectWord Decorator
|
|
14
14
|
*
|
|
15
15
|
* Auto-registers word but does NOT handle stack marshalling.
|
|
16
16
|
* Use this for words that need direct interpreter access to manually manipulate the stack.
|
|
@@ -21,16 +21,16 @@ export interface ModuleMetadata {
|
|
|
21
21
|
* @param customWordName - Optional custom word name (defaults to method name)
|
|
22
22
|
*
|
|
23
23
|
* @example
|
|
24
|
-
* @
|
|
24
|
+
* @ForthicDirectWord("( item:any forthic:string num:number -- )", "Repeat execution num_times", "<REPEAT")
|
|
25
25
|
* async l_REPEAT(interp: Interpreter) {
|
|
26
26
|
* const num = interp.stack_pop();
|
|
27
27
|
* const forthic = interp.stack_pop();
|
|
28
28
|
* // ... manual stack manipulation
|
|
29
29
|
* }
|
|
30
30
|
*/
|
|
31
|
-
export declare function
|
|
31
|
+
export declare function ForthicDirectWord(stackEffect: string, description?: string, customWordName?: string): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
32
32
|
/**
|
|
33
|
-
* @
|
|
33
|
+
* @ForthicWord Decorator
|
|
34
34
|
*
|
|
35
35
|
* Auto-registers word and handles stack marshalling.
|
|
36
36
|
* Word name defaults to method name, but can be overridden.
|
|
@@ -40,18 +40,18 @@ export declare function DirectWord(stackEffect: string, description?: string, cu
|
|
|
40
40
|
* @param customWordName - Optional custom word name (defaults to method name)
|
|
41
41
|
*
|
|
42
42
|
* @example
|
|
43
|
-
* @
|
|
43
|
+
* @ForthicWord("( a:number b:number -- sum:number )", "Adds two numbers")
|
|
44
44
|
* async ADD(a: number, b: number) {
|
|
45
45
|
* return a + b;
|
|
46
46
|
* }
|
|
47
47
|
*
|
|
48
48
|
* @example
|
|
49
|
-
* @
|
|
49
|
+
* @ForthicWord("( rec:any field:any -- value:any )", "Get value from record", "REC@")
|
|
50
50
|
* async REC_at(rec: any, field: any) {
|
|
51
51
|
* // Word name will be "REC@" instead of "REC_at"
|
|
52
52
|
* }
|
|
53
53
|
*/
|
|
54
|
-
export declare function
|
|
54
|
+
export declare function ForthicWord(stackEffect: string, description?: string, customWordName?: string): (target: any, propertyKey: string, descriptor?: PropertyDescriptor) => PropertyDescriptor;
|
|
55
55
|
/**
|
|
56
56
|
* Helper function to register module documentation
|
|
57
57
|
*
|
|
@@ -78,6 +78,14 @@ export declare class DecoratedModule extends Module {
|
|
|
78
78
|
constructor(name: string);
|
|
79
79
|
set_interp(interp: Interpreter): void;
|
|
80
80
|
private registerDecoratedWords;
|
|
81
|
+
/**
|
|
82
|
+
* Add a standard library word that can execute in any runtime
|
|
83
|
+
*
|
|
84
|
+
* This creates a word marked with isStandard=true, allowing it to be
|
|
85
|
+
* included in batched remote execution (e.g., +, MAP, REVERSE can execute
|
|
86
|
+
* in Python runtime along with Python-specific words).
|
|
87
|
+
*/
|
|
88
|
+
private add_standard_word;
|
|
81
89
|
/**
|
|
82
90
|
* Get documentation for all words in this module
|
|
83
91
|
*
|