@calcit/procs 0.9.5 → 0.9.7

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.
@@ -9,6 +9,7 @@ import { CalcitList, CalcitSliceList } from "./js-list.mjs";
9
9
  import { CalcitSet, overwriteSetComparator } from "./js-set.mjs";
10
10
  import { CalcitTuple } from "./js-tuple.mjs";
11
11
  import { CalcitCirruQuote, cirru_deep_equal } from "./js-cirru.mjs";
12
+ import { CalcitRef } from "./js-ref.mjs";
12
13
  // we have to inject cache in a dirty way in some cases
13
14
  const calcit_dirty_hash_key = "_calcit_cached_hash";
14
15
  let tagIdx = 0;
@@ -82,17 +83,6 @@ export let tipNestedCalcitData = (x) => {
82
83
  }
83
84
  return x.toString();
84
85
  };
85
- export class CalcitRef {
86
- constructor(x, path) {
87
- this.value = x;
88
- this.path = path;
89
- this.listeners = new Map();
90
- this.cachedHash = null;
91
- }
92
- toString() {
93
- return `(&ref ${this.value.toString()})`;
94
- }
95
- }
96
86
  export let getStringName = (x) => {
97
87
  if (typeof x === "string") {
98
88
  return x;
@@ -3,7 +3,8 @@ export const calcit_version = pkg.version;
3
3
  export const calcit_package_json = pkg;
4
4
  import { parse } from "@cirru/parser.ts";
5
5
  import { writeCirruCode } from "@cirru/writer.ts";
6
- import { CalcitSymbol, CalcitTag, CalcitRef, CalcitRecur, newTag, refsRegistry, toString, getStringName, _$n__$e_, hashFunction, } from "./calcit-data.mjs";
6
+ import { CalcitSymbol, CalcitTag, CalcitRecur, newTag, refsRegistry, toString, getStringName, _$n__$e_, hashFunction } from "./calcit-data.mjs";
7
+ import { CalcitRef } from "./js-ref.mjs";
7
8
  import { CalcitRecord } from "./js-record.mjs";
8
9
  export * from "./calcit-data.mjs";
9
10
  export * from "./js-record.mjs";
@@ -120,12 +121,7 @@ export let defatom = (path, x) => {
120
121
  refsRegistry.set(path, v);
121
122
  return v;
122
123
  };
123
- var atomCounter = 0;
124
- export let atom = (x) => {
125
- atomCounter = atomCounter + 1;
126
- let v = new CalcitRef(x, `atom-${atomCounter}`);
127
- return v;
128
- };
124
+ export { atom } from "./js-ref.mjs";
129
125
  export let peekDefatom = (path) => {
130
126
  return refsRegistry.get(path);
131
127
  };
@@ -1,5 +1,6 @@
1
1
  import { isLiteral } from "./js-primes.mjs";
2
- import { CalcitRef, CalcitSymbol, CalcitTag } from "./calcit-data.mjs";
2
+ import { CalcitSymbol, CalcitTag } from "./calcit-data.mjs";
3
+ import { CalcitRef } from "./js-ref.mjs";
3
4
  import { CalcitRecord } from "./js-record.mjs";
4
5
  import { CalcitMap, CalcitSliceMap } from "./js-map.mjs";
5
6
  import { CalcitList, CalcitSliceList } from "./js-list.mjs";
package/lib/js-cirru.mjs CHANGED
@@ -4,9 +4,11 @@ import { CalcitList, CalcitSliceList } from "./js-list.mjs";
4
4
  import { CalcitRecord } from "./js-record.mjs";
5
5
  import { CalcitMap, CalcitSliceMap } from "./js-map.mjs";
6
6
  import { CalcitSet } from "./js-set.mjs";
7
- import { CalcitTag, CalcitSymbol, CalcitRecur, CalcitRef, newTag } from "./calcit-data.mjs";
7
+ import { CalcitTag, CalcitSymbol, CalcitRecur, newTag } from "./calcit-data.mjs";
8
8
  import { CalcitTuple } from "./js-tuple.mjs";
9
+ import { CalcitRef } from "./js-ref.mjs";
9
10
  import { deepEqual } from "@calcit/ternary-tree/lib/utils.mjs";
11
+ import { atom } from "./js-ref.mjs";
10
12
  export class CalcitCirruQuote {
11
13
  constructor(value) {
12
14
  if (value == null) {
@@ -168,6 +170,9 @@ export let to_cirru_edn = (x) => {
168
170
  throw new Error(`Unsupported tag for EDN: ${x.tag}`);
169
171
  }
170
172
  }
173
+ if (x instanceof CalcitRef) {
174
+ return ["atom", to_cirru_edn(x.value)];
175
+ }
171
176
  console.error(x);
172
177
  throw new Error("Unexpected data to to-cirru-edn");
173
178
  };
@@ -334,6 +339,12 @@ export let extract_cirru_edn = (x, options) => {
334
339
  .filter(notComment)
335
340
  .map((x) => extract_cirru_edn(x, options)), undefined);
336
341
  }
342
+ if (x[0] === "atom") {
343
+ if (x.length !== 2) {
344
+ throw new Error(`atom expects 1 argument, got: ${x}`);
345
+ }
346
+ return atom(extract_cirru_edn(x[1], options));
347
+ }
337
348
  }
338
349
  console.error(x);
339
350
  throw new Error(`Unexpected data from EDN: ${x}`);
package/lib/js-primes.mjs CHANGED
@@ -1,4 +1,5 @@
1
- import { CalcitTag, CalcitSymbol, CalcitRef, CalcitRecur } from "./calcit-data.mjs";
1
+ import { CalcitTag, CalcitSymbol, CalcitRecur } from "./calcit-data.mjs";
2
+ import { CalcitRef } from "./js-ref.mjs";
2
3
  import { CalcitList, CalcitSliceList } from "./js-list.mjs";
3
4
  import { CalcitRecord } from "./js-record.mjs";
4
5
  import { CalcitMap, CalcitSliceMap } from "./js-map.mjs";
package/lib/js-ref.mjs ADDED
@@ -0,0 +1,17 @@
1
+ export class CalcitRef {
2
+ constructor(x, path) {
3
+ this.value = x;
4
+ this.path = path;
5
+ this.listeners = new Map();
6
+ this.cachedHash = null;
7
+ }
8
+ toString() {
9
+ return `(&ref ${this.value.toString()})`;
10
+ }
11
+ }
12
+ var atomCounter = 0;
13
+ export let atom = (x) => {
14
+ atomCounter = atomCounter + 1;
15
+ let v = new CalcitRef(x, `atom-${atomCounter}`);
16
+ return v;
17
+ };
package/lib/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@calcit/procs",
3
- "version": "0.9.5",
3
+ "version": "0.9.7",
4
4
  "main": "./lib/calcit.procs.mjs",
5
5
  "devDependencies": {
6
- "@types/node": "^22.1.0",
7
- "typescript": "^5.5.4"
6
+ "@types/node": "^22.10.5",
7
+ "typescript": "^5.7.2"
8
8
  },
9
9
  "scripts": {
10
10
  "compile": "rm -rfv lib/* && tsc",
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@calcit/procs",
3
- "version": "0.9.5",
3
+ "version": "0.9.7",
4
4
  "main": "./lib/calcit.procs.mjs",
5
5
  "devDependencies": {
6
- "@types/node": "^22.1.0",
7
- "typescript": "^5.5.4"
6
+ "@types/node": "^22.10.5",
7
+ "typescript": "^5.7.2"
8
8
  },
9
9
  "scripts": {
10
10
  "compile": "rm -rfv lib/* && tsc",
@@ -12,6 +12,7 @@ import { CalcitSet, overwriteSetComparator } from "./js-set.mjs";
12
12
  import { CalcitTuple } from "./js-tuple.mjs";
13
13
  import { CalcitCirruQuote, cirru_deep_equal } from "./js-cirru.mjs";
14
14
  import { CirruWriterNode } from "@cirru/writer.ts";
15
+ import { CalcitRef } from "./js-ref.mjs";
15
16
 
16
17
  // we have to inject cache in a dirty way in some cases
17
18
  const calcit_dirty_hash_key = "_calcit_cached_hash";
@@ -100,22 +101,6 @@ export let tipNestedCalcitData = (x: CalcitValue): string => {
100
101
  return x.toString();
101
102
  };
102
103
 
103
- export class CalcitRef {
104
- value: CalcitValue;
105
- path: string;
106
- listeners: Map<CalcitValue, CalcitFn>;
107
- cachedHash: Hash;
108
- constructor(x: CalcitValue, path: string) {
109
- this.value = x;
110
- this.path = path;
111
- this.listeners = new Map();
112
- this.cachedHash = null;
113
- }
114
- toString(): string {
115
- return `(&ref ${this.value.toString()})`;
116
- }
117
- }
118
-
119
104
  export type CalcitFn = (...xs: CalcitValue[]) => CalcitValue;
120
105
 
121
106
  export let getStringName = (x: CalcitValue): string => {
@@ -7,21 +7,9 @@ import { parse, ICirruNode } from "@cirru/parser.ts";
7
7
  import { writeCirruCode } from "@cirru/writer.ts";
8
8
 
9
9
  import { CalcitValue } from "./js-primes.mjs";
10
- import {
11
- CalcitSymbol,
12
- CalcitTag,
13
- CalcitRef,
14
- CalcitFn,
15
- CalcitRecur,
16
- newTag,
17
- refsRegistry,
18
- toString,
19
- getStringName,
20
- to_js_data,
21
- _$n__$e_,
22
- hashFunction,
23
- } from "./calcit-data.mjs";
10
+ import { CalcitSymbol, CalcitTag, CalcitFn, CalcitRecur, newTag, refsRegistry, toString, getStringName, _$n__$e_, hashFunction } from "./calcit-data.mjs";
24
11
 
12
+ import { CalcitRef } from "./js-ref.mjs";
25
13
  import { fieldsEqual, CalcitRecord } from "./js-record.mjs";
26
14
 
27
15
  export * from "./calcit-data.mjs";
@@ -148,13 +136,7 @@ export let defatom = (path: string, x: CalcitValue): CalcitValue => {
148
136
  return v;
149
137
  };
150
138
 
151
- var atomCounter = 0;
152
-
153
- export let atom = (x: CalcitValue): CalcitValue => {
154
- atomCounter = atomCounter + 1;
155
- let v = new CalcitRef(x, `atom-${atomCounter}`);
156
- return v;
157
- };
139
+ export { atom } from "./js-ref.mjs";
158
140
 
159
141
  export let peekDefatom = (path: string): CalcitRef => {
160
142
  return refsRegistry.get(path);
@@ -1,5 +1,6 @@
1
1
  import { CalcitValue, isLiteral } from "./js-primes.mjs";
2
- import { CalcitRef, CalcitSymbol, CalcitTag } from "./calcit-data.mjs";
2
+ import { CalcitSymbol, CalcitTag } from "./calcit-data.mjs";
3
+ import { CalcitRef } from "./js-ref.mjs";
3
4
 
4
5
  import { CalcitRecord } from "./js-record.mjs";
5
6
  import { CalcitMap, CalcitSliceMap } from "./js-map.mjs";
@@ -6,9 +6,11 @@ import { CalcitList, CalcitSliceList } from "./js-list.mjs";
6
6
  import { CalcitRecord } from "./js-record.mjs";
7
7
  import { CalcitMap, CalcitSliceMap } from "./js-map.mjs";
8
8
  import { CalcitSet } from "./js-set.mjs";
9
- import { CalcitTag, CalcitSymbol, CalcitRecur, CalcitRef, newTag } from "./calcit-data.mjs";
9
+ import { CalcitTag, CalcitSymbol, CalcitRecur, newTag } from "./calcit-data.mjs";
10
10
  import { CalcitTuple } from "./js-tuple.mjs";
11
+ import { CalcitRef } from "./js-ref.mjs";
11
12
  import { deepEqual } from "@calcit/ternary-tree/lib/utils.mjs";
13
+ import { atom } from "./js-ref.mjs";
12
14
 
13
15
  type CirruEdnFormat = string | CirruEdnFormat[];
14
16
 
@@ -165,6 +167,9 @@ export let to_cirru_edn = (x: CalcitValue): CirruEdnFormat => {
165
167
  throw new Error(`Unsupported tag for EDN: ${x.tag}`);
166
168
  }
167
169
  }
170
+ if (x instanceof CalcitRef) {
171
+ return ["atom", to_cirru_edn(x.value)];
172
+ }
168
173
  console.error(x);
169
174
  throw new Error("Unexpected data to to-cirru-edn");
170
175
  };
@@ -335,6 +340,12 @@ export let extract_cirru_edn = (x: CirruEdnFormat, options: CalcitValue): Calcit
335
340
  undefined
336
341
  );
337
342
  }
343
+ if (x[0] === "atom") {
344
+ if (x.length !== 2) {
345
+ throw new Error(`atom expects 1 argument, got: ${x}`);
346
+ }
347
+ return atom(extract_cirru_edn(x[1], options));
348
+ }
338
349
  }
339
350
  console.error(x);
340
351
  throw new Error(`Unexpected data from EDN: ${x}`);
@@ -1,4 +1,5 @@
1
- import { CalcitTag, CalcitSymbol, CalcitRef, CalcitFn, CalcitRecur } from "./calcit-data.mjs";
1
+ import { CalcitTag, CalcitSymbol, CalcitFn, CalcitRecur } from "./calcit-data.mjs";
2
+ import { CalcitRef } from "./js-ref.mjs";
2
3
  import { CalcitList, CalcitSliceList } from "./js-list.mjs";
3
4
  import { CalcitRecord } from "./js-record.mjs";
4
5
  import { CalcitMap, CalcitSliceMap } from "./js-map.mjs";
@@ -0,0 +1,27 @@
1
+ import { Hash } from "@calcit/ternary-tree";
2
+ import type { CalcitFn } from "./calcit-data.mjs";
3
+ import type { CalcitValue } from "./js-primes.mts";
4
+
5
+ export class CalcitRef {
6
+ value: CalcitValue;
7
+ path: string;
8
+ listeners: Map<CalcitValue, CalcitFn>;
9
+ cachedHash: Hash;
10
+ constructor(x: CalcitValue, path: string) {
11
+ this.value = x;
12
+ this.path = path;
13
+ this.listeners = new Map();
14
+ this.cachedHash = null;
15
+ }
16
+ toString(): string {
17
+ return `(&ref ${this.value.toString()})`;
18
+ }
19
+ }
20
+
21
+ var atomCounter = 0;
22
+
23
+ export let atom = (x: CalcitValue): CalcitValue => {
24
+ atomCounter = atomCounter + 1;
25
+ let v = new CalcitRef(x, `atom-${atomCounter}`);
26
+ return v;
27
+ };