@calcit/procs 0.12.51 → 0.12.52
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/.yarn/install-state.gz +0 -0
- package/README.md +1 -2
- package/editing-history/2026-07-26-1220-to-js-data-options.md +14 -0
- package/editing-history/2026-07-26-1244-release-0.12.52.md +12 -0
- package/editing-history/202607221613-remove-bundle-calcit-cli.md +7 -0
- package/editing-history/202607221944-replace-cr-sync-with-script.md +7 -0
- package/lib/calcit-data.d.mts +1 -1
- package/lib/calcit-data.mjs +39 -8
- package/lib/package.json +1 -1
- package/package.json +1 -1
- package/ts-src/calcit-data.mts +40 -8
package/.yarn/install-state.gz
CHANGED
|
Binary file
|
package/README.md
CHANGED
|
@@ -40,12 +40,11 @@ Installed binaries:
|
|
|
40
40
|
- `calcit`, the runtime and js compiler
|
|
41
41
|
- `cr-wasm`, standalone WASM codegen tool
|
|
42
42
|
- `caps`, for downloading dependencies declared in `deps.cirru`
|
|
43
|
-
- `bundle_calcit`, bundle code for distribution
|
|
44
43
|
|
|
45
44
|
When installing from source, explicitly include both runners:
|
|
46
45
|
|
|
47
46
|
```bash
|
|
48
|
-
cargo install --path . --bin cr --bin cr-wasm --bin caps
|
|
47
|
+
cargo install --path . --bin cr --bin cr-wasm --bin caps
|
|
49
48
|
```
|
|
50
49
|
|
|
51
50
|
To use Calcit in GitHub Actions, try [setup-cr](https://github.com/calcit-lang/setup-cr).
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# 2026-07-26 12:20 to-js-data options validation
|
|
2
|
+
|
|
3
|
+
## 修改概要
|
|
4
|
+
|
|
5
|
+
- 将 `to-js-data` 的第二参数改为 options map,并保留旧 boolean `addColon` 参数的兼容警告。
|
|
6
|
+
- 支持 `{} (:js-array true)`、`:js-object`、`:js-string`、`:js-number` 作为转换结果验证标记。
|
|
7
|
+
- 为 JS 集成测试和 `cr query examples calcit.core/to-js-data` 增加 options 示例。
|
|
8
|
+
|
|
9
|
+
## 验证
|
|
10
|
+
|
|
11
|
+
- `yarn compile`
|
|
12
|
+
- `cargo test -q --bin cr`
|
|
13
|
+
- `yarn try-js`
|
|
14
|
+
- `cr calcit/test.cirru query examples calcit.core/to-js-data`
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# Replace the legacy bundle CLI with a Calcit script
|
|
2
|
+
|
|
3
|
+
- Removed the deprecated `bundle_calcit` Rust binary and its release artifact.
|
|
4
|
+
- Added the recursive `read-dir` Calcit runtime API so filesystem workflows can be implemented in Calcit.
|
|
5
|
+
- Added `calcit/bundle-calcit.cirru` as a directly executable snapshot that bundles indentation-based source files into a runnable snapshot.
|
|
6
|
+
- Updated installation and bundle-mode documentation to use the script-based workflow.
|
|
7
|
+
- Verified the script against `minimal-calcit`, including loading and running the generated snapshot.
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# Replace the legacy cr-sync binary with a Calcit script
|
|
2
|
+
|
|
3
|
+
- Removed the `cr-sync` Rust binary and its installation documentation.
|
|
4
|
+
- Moved the bundle script to `calcit/scripts/` and added `sync-calcit.cirru` beside it.
|
|
5
|
+
- Added `unix-time-ms` for script-generated snapshot metadata.
|
|
6
|
+
- Reused `bisection-key` lexical-key APIs; `bisection-key` 0.0.18 fixes string-key append support.
|
|
7
|
+
- Verified synchronization against the editor repository's real `compact.cirru` and `calcit.cirru` fixtures, then checked the output with the legacy dry-run binary.
|
package/lib/calcit-data.d.mts
CHANGED
|
@@ -32,7 +32,7 @@ export declare let castTag: (x: CalcitValue) => CalcitTag;
|
|
|
32
32
|
export declare var refsRegistry: Map<string, CalcitRef>;
|
|
33
33
|
export declare let hashFunction: (x: CalcitValue) => Hash;
|
|
34
34
|
export declare let toString: (x: CalcitValue, escaped: boolean, disableJsDataWarning?: boolean) => string;
|
|
35
|
-
export declare let to_js_data: (x: CalcitValue,
|
|
35
|
+
export declare let to_js_data: (x: CalcitValue, options?: CalcitValue | boolean) => any;
|
|
36
36
|
export declare let _$n_map_$o_get: (xs: CalcitValue, k: CalcitValue) => CalcitValue;
|
|
37
37
|
export declare let _$n__$e_: (x: CalcitValue, y: CalcitValue) => boolean;
|
|
38
38
|
/** special trick for disabling ternary tree list check */
|
package/lib/calcit-data.mjs
CHANGED
|
@@ -441,7 +441,38 @@ export let toString = (x, escaped, disableJsDataWarning = false) => {
|
|
|
441
441
|
}
|
|
442
442
|
return `(#js ${JSON.stringify(x)})`;
|
|
443
443
|
};
|
|
444
|
-
export let to_js_data = (x,
|
|
444
|
+
export let to_js_data = (x, options) => {
|
|
445
|
+
let addColon = false;
|
|
446
|
+
if (typeof options === "boolean") {
|
|
447
|
+
console.warn("to-js-data: the addColon boolean argument is deprecated; pass an options map instead");
|
|
448
|
+
addColon = options;
|
|
449
|
+
}
|
|
450
|
+
else if (options !== undefined) {
|
|
451
|
+
let jsOptions = to_js_data_inner(options, false);
|
|
452
|
+
addColon = jsOptions[":add-colon"] === true || jsOptions["add-colon"] === true;
|
|
453
|
+
let value = to_js_data_inner(x, addColon);
|
|
454
|
+
let expectedType = jsOptions[":type"] ??
|
|
455
|
+
jsOptions.type ??
|
|
456
|
+
(jsOptions[":js-array"] || jsOptions["js-array"] ? "js-array" : undefined) ??
|
|
457
|
+
(jsOptions[":js-string"] || jsOptions["js-string"] ? "js-string" : undefined) ??
|
|
458
|
+
(jsOptions[":js-number"] || jsOptions["js-number"] ? "js-number" : undefined) ??
|
|
459
|
+
(jsOptions[":js-object"] || jsOptions["js-object"] ? "js-object" : undefined) ??
|
|
460
|
+
"js-object";
|
|
461
|
+
let valid = (expectedType === "js-array" && Array.isArray(value)) ||
|
|
462
|
+
(expectedType === "js-object" &&
|
|
463
|
+
value !== null &&
|
|
464
|
+
typeof value === "object" &&
|
|
465
|
+
!Array.isArray(value) &&
|
|
466
|
+
!(value instanceof Set)) ||
|
|
467
|
+
(expectedType === "js-string" && typeof value === "string") ||
|
|
468
|
+
(expectedType === "js-number" && typeof value === "number");
|
|
469
|
+
if (!valid)
|
|
470
|
+
throw new Error(`to-js-data expects ${expectedType}`);
|
|
471
|
+
return value;
|
|
472
|
+
}
|
|
473
|
+
return to_js_data_inner(x, addColon);
|
|
474
|
+
};
|
|
475
|
+
let to_js_data_inner = (x, addColon) => {
|
|
445
476
|
if (x == null) {
|
|
446
477
|
return null;
|
|
447
478
|
}
|
|
@@ -470,17 +501,17 @@ export let to_js_data = (x, addColon = false) => {
|
|
|
470
501
|
return Symbol(x.value);
|
|
471
502
|
}
|
|
472
503
|
if (x instanceof CalcitTuple) {
|
|
473
|
-
var result = [
|
|
504
|
+
var result = [to_js_data_inner(x.tag, false)];
|
|
474
505
|
for (let i = 0; i < x.extra.length; i++) {
|
|
475
506
|
let item = x.extra[i];
|
|
476
|
-
result.push(
|
|
507
|
+
result.push(to_js_data_inner(item, false));
|
|
477
508
|
}
|
|
478
509
|
return result;
|
|
479
510
|
}
|
|
480
511
|
if (x instanceof CalcitList || x instanceof CalcitSliceList) {
|
|
481
512
|
var result = [];
|
|
482
513
|
for (let item of x.items()) {
|
|
483
|
-
result.push(
|
|
514
|
+
result.push(to_js_data_inner(item, addColon));
|
|
484
515
|
}
|
|
485
516
|
return result;
|
|
486
517
|
}
|
|
@@ -490,22 +521,22 @@ export let to_js_data = (x, addColon = false) => {
|
|
|
490
521
|
for (let idx = 0; idx < pairs.length; idx++) {
|
|
491
522
|
let k = pairs[idx][0];
|
|
492
523
|
let v = pairs[idx][1];
|
|
493
|
-
var key =
|
|
494
|
-
result[key] =
|
|
524
|
+
var key = to_js_data_inner(k, addColon);
|
|
525
|
+
result[key] = to_js_data_inner(v, addColon);
|
|
495
526
|
}
|
|
496
527
|
return result;
|
|
497
528
|
}
|
|
498
529
|
if (x instanceof CalcitSet) {
|
|
499
530
|
let result = new Set();
|
|
500
531
|
x.values().forEach((v) => {
|
|
501
|
-
result.add(
|
|
532
|
+
result.add(to_js_data_inner(v, addColon));
|
|
502
533
|
});
|
|
503
534
|
return result;
|
|
504
535
|
}
|
|
505
536
|
if (x instanceof CalcitRecord) {
|
|
506
537
|
let result = {};
|
|
507
538
|
for (let idx = 0; idx < x.fields.length; idx++) {
|
|
508
|
-
result[x.fields[idx].value] =
|
|
539
|
+
result[x.fields[idx].value] = to_js_data_inner(x.values[idx], false);
|
|
509
540
|
}
|
|
510
541
|
return result;
|
|
511
542
|
}
|
package/lib/package.json
CHANGED
package/package.json
CHANGED
package/ts-src/calcit-data.mts
CHANGED
|
@@ -472,7 +472,39 @@ export let toString = (x: CalcitValue, escaped: boolean, disableJsDataWarning: b
|
|
|
472
472
|
return `(#js ${JSON.stringify(x)})`;
|
|
473
473
|
};
|
|
474
474
|
|
|
475
|
-
export let to_js_data = (x: CalcitValue,
|
|
475
|
+
export let to_js_data = (x: CalcitValue, options?: CalcitValue | boolean): any => {
|
|
476
|
+
let addColon = false;
|
|
477
|
+
if (typeof options === "boolean") {
|
|
478
|
+
console.warn("to-js-data: the addColon boolean argument is deprecated; pass an options map instead");
|
|
479
|
+
addColon = options;
|
|
480
|
+
} else if (options !== undefined) {
|
|
481
|
+
let jsOptions = to_js_data_inner(options, false) as Record<string, any>;
|
|
482
|
+
addColon = jsOptions[":add-colon"] === true || jsOptions["add-colon"] === true;
|
|
483
|
+
let value = to_js_data_inner(x, addColon);
|
|
484
|
+
let expectedType =
|
|
485
|
+
jsOptions[":type"] ??
|
|
486
|
+
jsOptions.type ??
|
|
487
|
+
(jsOptions[":js-array"] || jsOptions["js-array"] ? "js-array" : undefined) ??
|
|
488
|
+
(jsOptions[":js-string"] || jsOptions["js-string"] ? "js-string" : undefined) ??
|
|
489
|
+
(jsOptions[":js-number"] || jsOptions["js-number"] ? "js-number" : undefined) ??
|
|
490
|
+
(jsOptions[":js-object"] || jsOptions["js-object"] ? "js-object" : undefined) ??
|
|
491
|
+
"js-object";
|
|
492
|
+
let valid =
|
|
493
|
+
(expectedType === "js-array" && Array.isArray(value)) ||
|
|
494
|
+
(expectedType === "js-object" &&
|
|
495
|
+
value !== null &&
|
|
496
|
+
typeof value === "object" &&
|
|
497
|
+
!Array.isArray(value) &&
|
|
498
|
+
!(value instanceof Set)) ||
|
|
499
|
+
(expectedType === "js-string" && typeof value === "string") ||
|
|
500
|
+
(expectedType === "js-number" && typeof value === "number");
|
|
501
|
+
if (!valid) throw new Error(`to-js-data expects ${expectedType}`);
|
|
502
|
+
return value;
|
|
503
|
+
}
|
|
504
|
+
return to_js_data_inner(x, addColon);
|
|
505
|
+
};
|
|
506
|
+
|
|
507
|
+
let to_js_data_inner = (x: CalcitValue, addColon: boolean): any => {
|
|
476
508
|
if (x == null) {
|
|
477
509
|
return null;
|
|
478
510
|
}
|
|
@@ -501,17 +533,17 @@ export let to_js_data = (x: CalcitValue, addColon: boolean = false): any => {
|
|
|
501
533
|
return Symbol(x.value);
|
|
502
534
|
}
|
|
503
535
|
if (x instanceof CalcitTuple) {
|
|
504
|
-
var result: any[] = [
|
|
536
|
+
var result: any[] = [to_js_data_inner(x.tag, false)];
|
|
505
537
|
for (let i = 0; i < x.extra.length; i++) {
|
|
506
538
|
let item = x.extra[i];
|
|
507
|
-
result.push(
|
|
539
|
+
result.push(to_js_data_inner(item, false));
|
|
508
540
|
}
|
|
509
541
|
return result;
|
|
510
542
|
}
|
|
511
543
|
if (x instanceof CalcitList || x instanceof CalcitSliceList) {
|
|
512
544
|
var result: any[] = [];
|
|
513
545
|
for (let item of x.items()) {
|
|
514
|
-
result.push(
|
|
546
|
+
result.push(to_js_data_inner(item, addColon));
|
|
515
547
|
}
|
|
516
548
|
return result;
|
|
517
549
|
}
|
|
@@ -521,22 +553,22 @@ export let to_js_data = (x: CalcitValue, addColon: boolean = false): any => {
|
|
|
521
553
|
for (let idx = 0; idx < pairs.length; idx++) {
|
|
522
554
|
let k = pairs[idx][0];
|
|
523
555
|
let v = pairs[idx][1];
|
|
524
|
-
var key =
|
|
525
|
-
result[key] =
|
|
556
|
+
var key = to_js_data_inner(k, addColon);
|
|
557
|
+
result[key] = to_js_data_inner(v, addColon);
|
|
526
558
|
}
|
|
527
559
|
return result;
|
|
528
560
|
}
|
|
529
561
|
if (x instanceof CalcitSet) {
|
|
530
562
|
let result = new Set();
|
|
531
563
|
x.values().forEach((v) => {
|
|
532
|
-
result.add(
|
|
564
|
+
result.add(to_js_data_inner(v, addColon));
|
|
533
565
|
});
|
|
534
566
|
return result;
|
|
535
567
|
}
|
|
536
568
|
if (x instanceof CalcitRecord) {
|
|
537
569
|
let result: Record<string, CalcitValue> = {};
|
|
538
570
|
for (let idx = 0; idx < x.fields.length; idx++) {
|
|
539
|
-
result[x.fields[idx].value] =
|
|
571
|
+
result[x.fields[idx].value] = to_js_data_inner(x.values[idx], false);
|
|
540
572
|
}
|
|
541
573
|
return result;
|
|
542
574
|
}
|