@calcit/procs 0.5.26 → 0.5.27
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 +30 -35
- package/lib/calcit.procs.js +3 -3
- package/lib/js-cirru.js +2 -2
- package/package.json +1 -1
- package/ts-src/calcit.procs.ts +3 -3
- package/ts-src/js-cirru.ts +2 -2
package/README.md
CHANGED
|
@@ -1,14 +1,22 @@
|
|
|
1
1
|
### Calcit Scripting Language
|
|
2
2
|
|
|
3
|
-
>
|
|
3
|
+
> Spiritually dialect of ClojureScript. Built with Rust. Also compiles to JavaScript ES Modules.
|
|
4
4
|
|
|
5
5
|
- Home http://calcit-lang.org/
|
|
6
|
-
- API Doc
|
|
7
|
-
-
|
|
8
|
-
- 视频记录 https://space.bilibili.com/14227306/channel/seriesdetail?sid=281171
|
|
6
|
+
- API Doc http://apis.calcit-lang.org/
|
|
7
|
+
- Guidebook http://guide.calcit-lang.org/
|
|
9
8
|
|
|
10
9
|
[Browse examples](https://github.com/calcit-lang/calcit/tree/main/calcit) or also [try WASM version online](https://github.com/calcit-lang/calcit-wasm-play).
|
|
11
10
|
|
|
11
|
+
Core design:
|
|
12
|
+
|
|
13
|
+
- Interpreter runs on Rust, extensible with Rust FFI
|
|
14
|
+
- Persistent Data Structure
|
|
15
|
+
- Structural Editor(with indentation-based syntax as a fallback)
|
|
16
|
+
- Lisp macros, functional style
|
|
17
|
+
- Compiles to JavaScript in ES Modules, JavaScript Interop
|
|
18
|
+
- Hot code swapping friendly
|
|
19
|
+
|
|
12
20
|
### Install
|
|
13
21
|
|
|
14
22
|
Build and install with Rust:
|
|
@@ -21,7 +29,7 @@ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
|
|
|
21
29
|
cargo install calcit
|
|
22
30
|
```
|
|
23
31
|
|
|
24
|
-
For Ubuntu
|
|
32
|
+
For Ubuntu latest, try binaries from http://bin.calcit-lang.org/linux/ , which are provided for [CI usages](https://github.com/calcit-lang/respo-calcit-workflow/blob/main/.github/workflows/upload.yaml#L28-L37).
|
|
25
33
|
|
|
26
34
|
### Usage
|
|
27
35
|
|
|
@@ -46,7 +54,7 @@ println "|a demo"
|
|
|
46
54
|
'
|
|
47
55
|
```
|
|
48
56
|
|
|
49
|
-
Run with a [compact.cirru](https://github.com/calcit-lang/lilac/blob/
|
|
57
|
+
Run with a [compact.cirru](https://github.com/calcit-lang/lilac/blob/main/compact.cirru):
|
|
50
58
|
|
|
51
59
|
```bash
|
|
52
60
|
cr compact.cirru -1 # run only once
|
|
@@ -56,13 +64,20 @@ cr compact.cirru # watch mode enabled by default
|
|
|
56
64
|
cr compact.cirru --init-fn='app.main/main!' # specifying init-fn
|
|
57
65
|
```
|
|
58
66
|
|
|
59
|
-
|
|
67
|
+
### JavaScript codegen
|
|
68
|
+
|
|
69
|
+
It compiles to JavaScript and runs in consistet semantics. However it might require a lot of JavaScript interop.
|
|
60
70
|
|
|
61
71
|
```bash
|
|
62
72
|
cr compact.cirru --emit-js # compile to js
|
|
63
73
|
cr compact.cirru --emit-js --emit-path=out/ # compile to js and save in `out/`
|
|
74
|
+
```
|
|
64
75
|
|
|
65
|
-
|
|
76
|
+
By default, js code is generated to `js-out/`. You will need Vite or Esbuild to run it, from an entry file:
|
|
77
|
+
|
|
78
|
+
```js
|
|
79
|
+
import { main_$x_, reload_$x_ } from "./js-out/app.main.js";
|
|
80
|
+
main_$x_();
|
|
66
81
|
```
|
|
67
82
|
|
|
68
83
|
### Calcit Editor & Bundler
|
|
@@ -92,33 +107,6 @@ Modules that ends with `/`s are automatically suffixed `compact.cirru` since it'
|
|
|
92
107
|
|
|
93
108
|
To load modules in CI environments, make use of `git clone`.
|
|
94
109
|
|
|
95
|
-
Web Frameworks:
|
|
96
|
-
|
|
97
|
-
- [Respo](https://github.com/Respo/respo.calcit) - tiny Virtual DOM library
|
|
98
|
-
- [Phlox](https://github.com/Phlox-GL/phlox) - wraps PIXI.js in Virtual DOM style
|
|
99
|
-
- [Quamolit](https://github.com/Quamolit/quamolit.calcit/) - wraps Three.js in Virtual DOM style
|
|
100
|
-
- [Quatrefoil](https://github.com/Quatrefoil-GL/quatrefoil) - Canvas API in virtual DOM style, with ticking rendering
|
|
101
|
-
|
|
102
|
-
Mini libraries:
|
|
103
|
-
|
|
104
|
-
- [Lilac](https://github.com/calcit-lang/lilac), data validation tool
|
|
105
|
-
- [Memof](https://github.com/calcit-lang/memof), caching tool
|
|
106
|
-
- [Recollect](https://github.com/calcit-lang/recollect), diffing tool
|
|
107
|
-
- [Calcit Test](https://github.com/calcit-lang/calcit-test), testing tool
|
|
108
|
-
- [Bisection Key](https://github.com/calcit-lang/bisection-key), ...
|
|
109
|
-
- [Lilac Parser](https://github.com/calcit-lang/lilac-parser), string parsing tool
|
|
110
|
-
|
|
111
|
-
### Extensions
|
|
112
|
-
|
|
113
|
-
Rust supports extending with dynamic libraries, found an example in [dylib-workflow](https://github.com/calcit-lang/dylib-workflow). Currently there are some early extensions:
|
|
114
|
-
|
|
115
|
-
- [Std](https://github.com/calcit-lang/calcit.std) - some collections of util functions
|
|
116
|
-
- [WebSocket server binding](https://github.com/calcit-lang/calcit-wss)
|
|
117
|
-
- [HTTP client binding](https://github.com/calcit-lang/calcit-fetch)
|
|
118
|
-
- [HTTP server binding](https://github.com/calcit-lang/calcit-http)
|
|
119
|
-
- [Wasmtime binding](https://github.com/calcit-lang/calcit_wasmtime)
|
|
120
|
-
- [Canvas demo](https://github.com/calcit-lang/calcit-paint)
|
|
121
|
-
|
|
122
110
|
### Development
|
|
123
111
|
|
|
124
112
|
I use these commands to run local examples:
|
|
@@ -132,6 +120,8 @@ cargo run --bin cr -- calcit/test.cirru --emit-js -1 && yarn try-js
|
|
|
132
120
|
|
|
133
121
|
# run snippet
|
|
134
122
|
cargo run --bin cr -- -e 'range 100'
|
|
123
|
+
|
|
124
|
+
cr compact.cirru --emit-ir # compiles intermediate representation into program-ir.cirru
|
|
135
125
|
```
|
|
136
126
|
|
|
137
127
|
- [Cirru Parser](https://github.com/Cirru/parser.rs) for indentation-based syntax parsing.
|
|
@@ -143,6 +133,11 @@ Other tools:
|
|
|
143
133
|
- [Error Viewer](https://github.com/calcit-lang/calcit-error-viewer) for displaying `.calcit-error.cirru`
|
|
144
134
|
- [IR Viewer](https://github.com/calcit-lang/calcit-ir-viewer) for rendering `program-ir.cirru`
|
|
145
135
|
|
|
136
|
+
Some resources:
|
|
137
|
+
|
|
138
|
+
- Dev Logs https://github.com/calcit-lang/calcit/discussions
|
|
139
|
+
- 视频记录 https://space.bilibili.com/14227306/channel/seriesdetail?sid=281171
|
|
140
|
+
|
|
146
141
|
### License
|
|
147
142
|
|
|
148
143
|
MIT
|
package/lib/calcit.procs.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
var _a;
|
|
2
2
|
// CALCIT VERSION
|
|
3
|
-
export const calcit_version = "0.5.
|
|
3
|
+
export const calcit_version = "0.5.27";
|
|
4
4
|
import "@calcit/ternary-tree";
|
|
5
5
|
import { parse } from "@cirru/parser.ts";
|
|
6
6
|
import { writeCirruCode } from "@cirru/writer.ts";
|
|
@@ -455,7 +455,7 @@ export let _$n_list_$o_rest = (xs) => {
|
|
|
455
455
|
};
|
|
456
456
|
export let _$n_str_$o_rest = (xs) => {
|
|
457
457
|
if (typeof xs === "string")
|
|
458
|
-
return xs.
|
|
458
|
+
return xs.slice(1);
|
|
459
459
|
console.error(xs);
|
|
460
460
|
throw new Error("Expects a string");
|
|
461
461
|
};
|
|
@@ -520,7 +520,7 @@ export let butlast = (xs) => {
|
|
|
520
520
|
return xs.slice(0, xs.len() - 1);
|
|
521
521
|
}
|
|
522
522
|
if (typeof xs === "string") {
|
|
523
|
-
return xs.
|
|
523
|
+
return xs.slice(0, -1);
|
|
524
524
|
}
|
|
525
525
|
console.error(xs);
|
|
526
526
|
throw new Error("Data not ready for butlast");
|
package/lib/js-cirru.js
CHANGED
|
@@ -108,10 +108,10 @@ export let extract_cirru_edn = (x) => {
|
|
|
108
108
|
return x.slice(1);
|
|
109
109
|
}
|
|
110
110
|
if (x[0] === ":") {
|
|
111
|
-
return kwd(x.
|
|
111
|
+
return kwd(x.slice(1));
|
|
112
112
|
}
|
|
113
113
|
if (x[0] === "'") {
|
|
114
|
-
return new CalcitSymbol(x.
|
|
114
|
+
return new CalcitSymbol(x.slice(1));
|
|
115
115
|
}
|
|
116
116
|
if (x.match(/^(-?)\d+(\.\d*$)?/)) {
|
|
117
117
|
return parseFloat(x);
|
package/package.json
CHANGED
package/ts-src/calcit.procs.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// CALCIT VERSION
|
|
2
|
-
export const calcit_version = "0.5.
|
|
2
|
+
export const calcit_version = "0.5.27";
|
|
3
3
|
|
|
4
4
|
import { overwriteComparator, initTernaryTreeMap } from "@calcit/ternary-tree";
|
|
5
5
|
import { parse, ICirruNode } from "@cirru/parser.ts";
|
|
@@ -499,7 +499,7 @@ export let _$n_list_$o_rest = (xs: CalcitValue): CalcitValue => {
|
|
|
499
499
|
};
|
|
500
500
|
|
|
501
501
|
export let _$n_str_$o_rest = (xs: CalcitValue): CalcitValue => {
|
|
502
|
-
if (typeof xs === "string") return xs.
|
|
502
|
+
if (typeof xs === "string") return xs.slice(1);
|
|
503
503
|
|
|
504
504
|
console.error(xs);
|
|
505
505
|
throw new Error("Expects a string");
|
|
@@ -571,7 +571,7 @@ export let butlast = (xs: CalcitValue): CalcitValue => {
|
|
|
571
571
|
return xs.slice(0, xs.len() - 1);
|
|
572
572
|
}
|
|
573
573
|
if (typeof xs === "string") {
|
|
574
|
-
return xs.
|
|
574
|
+
return xs.slice(0, -1);
|
|
575
575
|
}
|
|
576
576
|
console.error(xs);
|
|
577
577
|
throw new Error("Data not ready for butlast");
|
package/ts-src/js-cirru.ts
CHANGED
|
@@ -112,10 +112,10 @@ export let extract_cirru_edn = (x: CirruEdnFormat): CalcitValue => {
|
|
|
112
112
|
return x.slice(1);
|
|
113
113
|
}
|
|
114
114
|
if (x[0] === ":") {
|
|
115
|
-
return kwd(x.
|
|
115
|
+
return kwd(x.slice(1));
|
|
116
116
|
}
|
|
117
117
|
if (x[0] === "'") {
|
|
118
|
-
return new CalcitSymbol(x.
|
|
118
|
+
return new CalcitSymbol(x.slice(1));
|
|
119
119
|
}
|
|
120
120
|
if (x.match(/^(-?)\d+(\.\d*$)?/)) {
|
|
121
121
|
return parseFloat(x);
|