@calcit/procs 0.8.10 → 0.8.12

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.
@@ -1,6 +1,6 @@
1
- var _a;
2
- // CALCIT VERSION
3
- export const calcit_version = "0.8.10";
1
+ import pkg from "./package.json" assert { type: "json" };
2
+ export const calcit_version = pkg.version;
3
+ export const calcit_package_json = pkg;
4
4
  import { parse } from "@cirru/parser.ts";
5
5
  import { writeCirruCode } from "@cirru/writer.ts";
6
6
  import { CalcitSymbol, CalcitTag, CalcitRef, CalcitRecur, newTag, refsRegistry, toString, getStringName, _$n__$e_, hashFunction, } from "./calcit-data.mjs";
@@ -20,7 +20,7 @@ import { CalcitMap, CalcitSliceMap } from "./js-map.mjs";
20
20
  import { CalcitSet } from "./js-set.mjs";
21
21
  import { CalcitTuple } from "./js-tuple.mjs";
22
22
  import { to_calcit_data, extract_cirru_edn, CalcitCirruQuote } from "./js-cirru.mjs";
23
- let inNodeJs = typeof process !== "undefined" && ((_a = process === null || process === void 0 ? void 0 : process.release) === null || _a === void 0 ? void 0 : _a.name) === "node";
23
+ let inNodeJs = typeof process !== "undefined" && process?.release?.name === "node";
24
24
  export let type_of = (x) => {
25
25
  if (typeof x === "string") {
26
26
  return newTag("string");
@@ -904,7 +904,7 @@ export let get_env = (name, v0) => {
904
904
  if (v == null && v0 == null) {
905
905
  console.warn(`(get-env "${name}"): config not found`);
906
906
  }
907
- return v !== null && v !== void 0 ? v : v0;
907
+ return v ?? v0;
908
908
  };
909
909
  export let turn_tag = (x) => {
910
910
  if (typeof x === "string") {
@@ -1014,7 +1014,7 @@ export let _$n_str_$o_compare = (x, y) => {
1014
1014
  return 0;
1015
1015
  };
1016
1016
  export let arrayToList = (xs) => {
1017
- return new CalcitSliceList(xs !== null && xs !== void 0 ? xs : []);
1017
+ return new CalcitSliceList(xs ?? []);
1018
1018
  };
1019
1019
  export let listToArray = (xs) => {
1020
1020
  if (xs == null) {
@@ -1069,14 +1069,13 @@ export let buffer_$q_ = (x) => {
1069
1069
  };
1070
1070
  export let _$n_str_$o_escape = (x) => JSON.stringify(x);
1071
1071
  export let read_file = (path) => {
1072
- var _a;
1073
1072
  if (inNodeJs) {
1074
1073
  // TODO
1075
1074
  globalThis["__calcit_injections__"].read_file(path);
1076
1075
  }
1077
1076
  else {
1078
1077
  // no actual File API in browser
1079
- return (_a = localStorage.get(path)) !== null && _a !== void 0 ? _a : "";
1078
+ return localStorage.get(path) ?? "";
1080
1079
  }
1081
1080
  };
1082
1081
  export let write_file = (path, content) => {
@@ -1258,12 +1257,16 @@ function lookup_class(obj) {
1258
1257
  klass = calcit_builtin_classes.map;
1259
1258
  }
1260
1259
  else {
1261
- throw new Error("Cannot find class for this object for invoking");
1260
+ return null;
1262
1261
  }
1263
1262
  return [klass, tag];
1264
1263
  }
1265
1264
  export function invoke_method(p, obj, ...args) {
1266
- let [klass, tag] = lookup_class(obj);
1265
+ let pair = lookup_class(obj);
1266
+ if (pair == null) {
1267
+ throw new Error(`No class for ${obj?.toString() || JSON.stringify(obj)} to lookup .${p}`);
1268
+ }
1269
+ let [klass, tag] = pair;
1267
1270
  let method = klass.getOrNil(p);
1268
1271
  if (method == null) {
1269
1272
  throw new Error(`No method '.${p}' for '${tag}' object '${obj}'.\navailable fields are: ${klass.fields.map((fd) => fd.value).join(" ")}`);
@@ -0,0 +1,27 @@
1
+ {
2
+ "name": "@calcit/procs",
3
+ "version": "0.8.12",
4
+ "main": "./lib/calcit.procs.mjs",
5
+ "devDependencies": {
6
+ "@types/node": "^20.9.4",
7
+ "typescript": "^5.3.2"
8
+ },
9
+ "scripts": {
10
+ "compile": "rm -rfv lib/* && tsc",
11
+ "procs-link": "ln -s ../../ node_modules/@calcit/procs",
12
+ "cp-mac": "cargo build --release && rm -rfv builds/* && node scripts/cp-version.js && scp builds/* rsync-user@calcit-lang.org:/web-assets/repo/calcit-lang/binaries/macos/",
13
+ "eval": "cargo run --bin cr -- -e",
14
+ "try-rs": "cargo run --bin cr -- calcit/test.cirru -1",
15
+ "try-js-brk": "cargo run --bin cr -- calcit/test.cirru --emit-js -1 && node --inspect-brk js-out/main.mjs",
16
+ "try-js": "cargo run --bin cr -- calcit/test.cirru --emit-js -1 && node js-out/main.mjs"
17
+ },
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "https://github.com/calcit-lang/calcit"
21
+ },
22
+ "dependencies": {
23
+ "@calcit/ternary-tree": "0.0.23",
24
+ "@cirru/parser.ts": "^0.0.6",
25
+ "@cirru/writer.ts": "^0.1.4"
26
+ }
27
+ }
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@calcit/procs",
3
- "version": "0.8.10",
3
+ "version": "0.8.12",
4
4
  "main": "./lib/calcit.procs.mjs",
5
5
  "devDependencies": {
6
- "@types/node": "^20.9.0",
7
- "typescript": "^5.2.2"
6
+ "@types/node": "^20.9.4",
7
+ "typescript": "^5.3.2"
8
8
  },
9
9
  "scripts": {
10
10
  "compile": "rm -rfv lib/* && tsc",
@@ -1,5 +1,7 @@
1
- // CALCIT VERSION
2
- export const calcit_version = "0.8.10";
1
+ import pkg from "./package.json" assert { type: "json" };
2
+
3
+ export const calcit_version = pkg.version;
4
+ export const calcit_package_json = pkg;
3
5
 
4
6
  import { parse, ICirruNode } from "@cirru/parser.ts";
5
7
  import { writeCirruCode } from "@cirru/writer.ts";
@@ -1348,13 +1350,17 @@ function lookup_class(obj: CalcitValue): [CalcitRecord, string] {
1348
1350
  tag = "&core-map-class";
1349
1351
  klass = calcit_builtin_classes.map;
1350
1352
  } else {
1351
- throw new Error("Cannot find class for this object for invoking");
1353
+ return null;
1352
1354
  }
1353
1355
  return [klass, tag];
1354
1356
  }
1355
1357
 
1356
1358
  export function invoke_method(p: string, obj: CalcitValue, ...args: CalcitValue[]) {
1357
- let [klass, tag] = lookup_class(obj);
1359
+ let pair = lookup_class(obj);
1360
+ if (pair == null) {
1361
+ throw new Error(`No class for ${obj?.toString() || JSON.stringify(obj)} to lookup .${p}`);
1362
+ }
1363
+ let [klass, tag] = pair;
1358
1364
  let method = klass.getOrNil(p);
1359
1365
  if (method == null) {
1360
1366
  throw new Error(`No method '.${p}' for '${tag}' object '${obj}'.\navailable fields are: ${klass.fields.map((fd: CalcitTag) => fd.value).join(" ")}`);