@cortex-js/compute-engine 0.25.1 → 0.26.2

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.
Files changed (153) hide show
  1. package/README.md +5 -8
  2. package/dist/compute-engine.esm.js +26338 -22472
  3. package/dist/compute-engine.js +26348 -22470
  4. package/dist/compute-engine.min.esm.js +89 -23
  5. package/dist/compute-engine.min.js +89 -23
  6. package/dist/math-json.esm.js +22 -139
  7. package/dist/math-json.js +22 -139
  8. package/dist/math-json.min.esm.js +22 -139
  9. package/dist/math-json.min.js +2 -2
  10. package/dist/types/common/ansi-codes.d.ts +30 -4
  11. package/dist/types/common/buffer.d.ts +9 -0
  12. package/dist/types/common/grapheme-splitter.d.ts +1 -1
  13. package/dist/types/common/one-of.d.ts +9 -0
  14. package/dist/types/common/signals.d.ts +1 -1
  15. package/dist/types/common/styled-text.d.ts +28 -0
  16. package/dist/types/common/suggest.d.ts +1 -0
  17. package/dist/types/common/syntax-highlighter.d.ts +40 -0
  18. package/dist/types/common/terminal.d.ts +19 -0
  19. package/dist/types/common/type/parse.d.ts +4 -0
  20. package/dist/types/common/type/primitive.d.ts +8 -0
  21. package/dist/types/common/type/serialize.d.ts +2 -0
  22. package/dist/types/common/type/subtype.d.ts +6 -0
  23. package/dist/types/common/type/types.d.ts +249 -0
  24. package/dist/types/common/type/utils.d.ts +39 -0
  25. package/dist/types/common/utils.d.ts +2 -1
  26. package/dist/types/compute-engine/assume.d.ts +13 -13
  27. package/dist/types/compute-engine/boxed-expression/abstract-boxed-expression.d.ts +71 -47
  28. package/dist/types/compute-engine/boxed-expression/apply.d.ts +5 -0
  29. package/dist/types/compute-engine/boxed-expression/arithmetic-add.d.ts +15 -0
  30. package/dist/types/compute-engine/boxed-expression/arithmetic-divide.d.ts +12 -0
  31. package/dist/types/compute-engine/boxed-expression/arithmetic-multiply.d.ts +16 -0
  32. package/dist/types/compute-engine/boxed-expression/arithmetic-power.d.ts +20 -0
  33. package/dist/types/compute-engine/boxed-expression/ascii-math.d.ts +11 -0
  34. package/dist/types/compute-engine/boxed-expression/box.d.ts +13 -71
  35. package/dist/types/compute-engine/boxed-expression/boxed-function-definition.d.ts +31 -13
  36. package/dist/types/compute-engine/boxed-expression/boxed-function.d.ts +66 -45
  37. package/dist/types/compute-engine/boxed-expression/boxed-number.d.ts +42 -37
  38. package/dist/types/compute-engine/boxed-expression/boxed-patterns.d.ts +2 -2
  39. package/dist/types/compute-engine/boxed-expression/boxed-string.d.ts +13 -9
  40. package/dist/types/compute-engine/boxed-expression/boxed-symbol-definition.d.ts +34 -66
  41. package/dist/types/compute-engine/boxed-expression/boxed-symbol.d.ts +63 -41
  42. package/dist/types/compute-engine/boxed-expression/boxed-tensor.d.ts +44 -27
  43. package/dist/types/compute-engine/boxed-expression/cache.d.ts +6 -0
  44. package/dist/types/compute-engine/boxed-expression/canonical.d.ts +1 -1
  45. package/dist/types/compute-engine/boxed-expression/compare.d.ts +13 -0
  46. package/dist/types/compute-engine/boxed-expression/expand.d.ts +20 -0
  47. package/dist/types/compute-engine/boxed-expression/expression-map.d.ts +1 -1
  48. package/dist/types/compute-engine/boxed-expression/factor.d.ts +7 -6
  49. package/dist/types/compute-engine/boxed-expression/flatten.d.ts +25 -0
  50. package/dist/types/compute-engine/boxed-expression/hold.d.ts +9 -0
  51. package/dist/types/compute-engine/boxed-expression/match.d.ts +2 -4
  52. package/dist/types/compute-engine/{symbolic → boxed-expression}/negate.d.ts +4 -4
  53. package/dist/types/compute-engine/boxed-expression/numerics.d.ts +5 -39
  54. package/dist/types/compute-engine/boxed-expression/order.d.ts +26 -14
  55. package/dist/types/compute-engine/{symbolic → boxed-expression}/polynomials.d.ts +11 -15
  56. package/dist/types/compute-engine/{symbolic → boxed-expression}/product.d.ts +18 -24
  57. package/dist/types/compute-engine/boxed-expression/public.d.ts +911 -634
  58. package/dist/types/compute-engine/boxed-expression/rules.d.ts +129 -0
  59. package/dist/types/compute-engine/boxed-expression/serialize.d.ts +2 -2
  60. package/dist/types/compute-engine/boxed-expression/sgn.d.ts +6 -0
  61. package/dist/types/compute-engine/boxed-expression/simplify.d.ts +6 -0
  62. package/dist/types/compute-engine/{solve.d.ts → boxed-expression/solve.d.ts} +5 -5
  63. package/dist/types/compute-engine/{symbolic → boxed-expression}/tensor-fields.d.ts +3 -3
  64. package/dist/types/compute-engine/boxed-expression/terms.d.ts +10 -0
  65. package/dist/types/compute-engine/boxed-expression/trigonometry.d.ts +10 -0
  66. package/dist/types/compute-engine/boxed-expression/utils.d.ts +22 -16
  67. package/dist/types/compute-engine/boxed-expression/validate.d.ts +10 -7
  68. package/dist/types/compute-engine/collection-utils.d.ts +24 -2
  69. package/dist/types/compute-engine/compile.d.ts +3 -3
  70. package/dist/types/compute-engine/compute-engine.d.ts +132 -165
  71. package/dist/types/compute-engine/cost-function.d.ts +11 -1
  72. package/dist/types/compute-engine/function-utils.d.ts +5 -5
  73. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-algebra.d.ts +1 -1
  74. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-arithmetic.d.ts +1 -1
  75. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-calculus.d.ts +1 -1
  76. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-complex.d.ts +1 -1
  77. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-core.d.ts +1 -1
  78. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-linear-algebra.d.ts +1 -1
  79. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-logic.d.ts +1 -1
  80. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-other.d.ts +1 -1
  81. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-relational-operators.d.ts +1 -1
  82. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-sets.d.ts +1 -1
  83. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-statistics.d.ts +1 -1
  84. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-symbols.d.ts +1 -1
  85. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-trigonometry.d.ts +1 -1
  86. package/dist/types/compute-engine/latex-syntax/dictionary/definitions.d.ts +1 -1
  87. package/dist/types/compute-engine/latex-syntax/parse-identifier.d.ts +2 -2
  88. package/dist/types/compute-engine/latex-syntax/parse.d.ts +26 -31
  89. package/dist/types/compute-engine/latex-syntax/public.d.ts +24 -18
  90. package/dist/types/compute-engine/latex-syntax/serialize-number.d.ts +2 -2
  91. package/dist/types/compute-engine/latex-syntax/serializer-style.d.ts +1 -1
  92. package/dist/types/compute-engine/latex-syntax/serializer.d.ts +5 -8
  93. package/dist/types/compute-engine/latex-syntax/tokenizer.d.ts +1 -1
  94. package/dist/types/compute-engine/library/arithmetic.d.ts +4 -2
  95. package/dist/types/compute-engine/library/calculus.d.ts +1 -1
  96. package/dist/types/compute-engine/library/collections.d.ts +24 -1
  97. package/dist/types/compute-engine/library/complex.d.ts +1 -1
  98. package/dist/types/compute-engine/library/control-structures.d.ts +1 -1
  99. package/dist/types/compute-engine/library/core.d.ts +1 -3
  100. package/dist/types/compute-engine/library/invisible-operator.d.ts +4 -0
  101. package/dist/types/compute-engine/library/library.d.ts +2 -4
  102. package/dist/types/compute-engine/library/linear-algebra.d.ts +1 -1
  103. package/dist/types/compute-engine/library/logic.d.ts +5 -1
  104. package/dist/types/compute-engine/library/polynomials.d.ts +1 -1
  105. package/dist/types/compute-engine/library/random-expression.d.ts +1 -1
  106. package/dist/types/compute-engine/library/relational-operator.d.ts +1 -1
  107. package/dist/types/compute-engine/library/sets.d.ts +1 -1
  108. package/dist/types/compute-engine/library/statistics.d.ts +1 -1
  109. package/dist/types/compute-engine/library/trigonometry.d.ts +1 -1
  110. package/dist/types/compute-engine/library/utils.d.ts +46 -40
  111. package/dist/types/compute-engine/numeric-value/big-numeric-value.d.ts +59 -0
  112. package/dist/types/compute-engine/numeric-value/exact-numeric-value.d.ts +77 -0
  113. package/dist/types/compute-engine/numeric-value/machine-numeric-value.d.ts +58 -0
  114. package/dist/types/compute-engine/numeric-value/public.d.ts +110 -0
  115. package/dist/types/compute-engine/numerics/bigint.d.ts +2 -0
  116. package/dist/types/compute-engine/numerics/bignum.d.ts +12 -0
  117. package/dist/types/compute-engine/numerics/expression.d.ts +4 -0
  118. package/dist/types/compute-engine/numerics/interval.d.ts +12 -0
  119. package/dist/types/compute-engine/numerics/monte-carlo.d.ts +19 -0
  120. package/dist/types/compute-engine/numerics/numeric-bigint.d.ts +4 -14
  121. package/dist/types/compute-engine/numerics/numeric-bignum.d.ts +6 -9
  122. package/dist/types/compute-engine/numerics/numeric-complex.d.ts +1 -1
  123. package/dist/types/compute-engine/numerics/numeric.d.ts +9 -59
  124. package/dist/types/compute-engine/numerics/primes.d.ts +3 -3
  125. package/dist/types/compute-engine/numerics/rationals.d.ts +29 -13
  126. package/dist/types/compute-engine/numerics/richardson.d.ts +1 -1
  127. package/dist/types/compute-engine/numerics/special-functions.d.ts +28 -0
  128. package/dist/types/compute-engine/numerics/strings.d.ts +2 -0
  129. package/dist/types/compute-engine/public.d.ts +8 -4
  130. package/dist/types/compute-engine/symbolic/derivative.d.ts +2 -2
  131. package/dist/types/compute-engine/symbolic/distribute.d.ts +5 -0
  132. package/dist/types/compute-engine/{simplify-rules.d.ts → symbolic/simplify-rules.d.ts} +1 -1
  133. package/dist/types/compute-engine/{symbolic → tensor}/tensors.d.ts +3 -3
  134. package/dist/types/compute-engine.d.ts +4 -2
  135. package/dist/types/math-json/identifiers.d.ts +11 -0
  136. package/dist/types/math-json/{math-json-format.d.ts → types.d.ts} +4 -9
  137. package/dist/types/math-json/utils.d.ts +15 -23
  138. package/dist/types/math-json.d.ts +3 -3
  139. package/package.json +3 -3
  140. package/dist/types/compute-engine/boxed-expression/boxed-dictionary.d.ts +0 -48
  141. package/dist/types/compute-engine/boxed-expression/boxed-domain.d.ts +0 -40
  142. package/dist/types/compute-engine/boxed-expression/coefficient-field.d.ts +0 -56
  143. package/dist/types/compute-engine/domain-utils.d.ts +0 -19
  144. package/dist/types/compute-engine/library/arithmetic-add.d.ts +0 -21
  145. package/dist/types/compute-engine/library/arithmetic-divide.d.ts +0 -16
  146. package/dist/types/compute-engine/library/arithmetic-multiply.d.ts +0 -16
  147. package/dist/types/compute-engine/library/arithmetic-power.d.ts +0 -11
  148. package/dist/types/compute-engine/library/domains.d.ts +0 -16
  149. package/dist/types/compute-engine/numerics/terms.d.ts +0 -17
  150. package/dist/types/compute-engine/rules.d.ts +0 -20
  151. package/dist/types/compute-engine/symbolic/expand.d.ts +0 -23
  152. package/dist/types/compute-engine/symbolic/flatten.d.ts +0 -9
  153. package/dist/types/compute-engine/symbolic/utils.d.ts +0 -22
@@ -1,4 +1,4 @@
1
- /** MathJSON 0.25.1 */
1
+ /** MathJSON 0.26.2 */
2
2
  (function(global,factory){typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'],factory):(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.MathJson = {}));})(this, (function (exports) { 'use strict';
3
- var MathJson=(()=>{var f=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames;var k=Object.prototype.hasOwnProperty;var D=(n,t)=>{for(var e in t)f(n,e,{get:t[e],enumerable:!0})},F=(n,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of v(t))!k.call(n,r)&&r!==e&&f(n,r,{get:()=>t[r],enumerable:!(i=T(t,r))||i.enumerable});return n};var R=n=>F(f({},"__esModule",{value:!0}),n);var z={};D(z,{applyRecursively:()=>A,getDictionary:()=>y,getStringValue:()=>m,head:()=>l,headName:()=>j,isDictionaryObject:()=>S,isFunctionObject:()=>u,isStringObject:()=>M,isSymbolObject:()=>d,mapArgs:()=>$,nops:()=>E,op:()=>s,symbol:()=>O,version:()=>X});function d(n){return n!==null&&typeof n=="object"&&"sym"in n}function M(n){return n!==null&&typeof n=="object"&&"str"in n}function u(n){return n!==null&&typeof n=="object"&&"fn"in n}function S(n){return n!==null&&typeof n=="object"&&"dict"in n}var c;function I(n){if(!c){let e=`^[${["Zyyy","Zinh","Arab","Armn","Beng","Bopo","Cyrl","Deva","Ethi","Geor","Grek","Gujr","Guru","Hang","Hani","Hebr","Hira","Kana","Knda","Khmr","Laoo","Latn","Mlym","Mymr","Orya","Sinh","Taml","Telu","Thaa","Thai","Tibt"].map(i=>`\\p{Script=${i}}`).join("")}]*$`;c=new RegExp(e,"u")}return c.test(n)}function a(n){return/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(n)||N.test(n)?!0:I(n)?/^[\p{XIDS}_]\p{XIDC}*$/u.test(n):!1}var _="\\u{FE0F}",V="\\u{20E3}",L="\\u{200D}",P="\\p{RI}\\p{RI}",w="(?:[\\u{E0020}-\\u{E007E}]+\\u{E007F})",b=`(?:\\p{EMod}|${_}${V}?|${w})`,C="(?:(?=\\P{XIDC})\\p{Emoji})",h=`(?:${C}${b}*|\\p{Emoji}${b}+|${P})`,J=`(?:${h})(${L}${h})*`,G=new RegExp(`(?:${J})+`,"u"),N=new RegExp(`^(?:${J})+$`,"u");function q(n){return typeof n!="string"?"not-a-string":n===""?"empty-string":n.normalize()!==n?"expected-nfc":/[\u200E\u200F\u2066-\u2069\u202A-\u202E]/.test(n)?"unexpected-bidi-marker":N.test(n)?"valid":/\p{XIDC}/u.test(n)&&G.test(n)?"unexpected-mixed-emoji":I(n)?a(n)?"valid":a(n[0])?"invalid-char":"invalid-first-char":"unexpected-script"}function m(n){return n==null?null:typeof n=="object"&&"str"in n?n.str:typeof n!="string"||n.length<2||n[0]!=="'"||n[n.length-1]!=="'"?null:n.substring(1,n.length-1)}function l(n){return Array.isArray(n)?typeof n[0]=="string"&&!a(n[0])?(console.error(`Invalid identifier "${n[0]}": ${q(n[0])}`),null):n[0]:n==null?null:u(n)?n.fn[0]:null}function j(n){let t=l(n);return typeof t=="string"?t:""}function H(n){return Array.isArray(n)?n.slice(1):n==null?null:u(n)?n.fn.slice(1):null}function s(n,t){return Array.isArray(n)?n[t]??null:n==null?null:u(n)?n.fn[t]??null:null}function K(n){return s(n,1)}function Z(n){return s(n,2)}function E(n){return n==null?0:Array.isArray(n)?Math.max(0,n.length-1):u(n)?Math.max(0,n.fn.length-1):0}function O(n){if(typeof n=="string")return/^[+-]?[0-9\.]/.test(n)||n.length>=2&&n[0]==="'"&&n[n.length-1]==="'"?null:n;if(n==null)return null;let t=d(n)?n.sym:n;return typeof t!="string"?null:t}function p(n){let t=l(n);if(t==="KeyValuePair"||t==="Tuple"||t==="Pair"){let e=m(K(n));return e?[e,Z(n)??"Nothing"]:null}return null}function y(n){if(n===null)return null;if(typeof n=="object"&&"dict"in n)return n.dict;let t=p(n);if(t)return{[t[0]]:t[1]};if(l(n)==="Dictionary"){let i={};for(let r=1;r<E(n);r++){let o=p(s(n,r));o&&(i[o[0]]=o[1])}return i}return null}function A(n,t){let e=l(n);if(e!==null)return[t(e),...(H(n)??[]).map(t)];let i=y(n);if(i!==null){let r=Object.keys(i),o={};for(let g of r)o[g]=t(i[g]);return{dict:o}}return t(n)}function $(n,t){let e=null;if(Array.isArray(n)&&(e=n),u(n)&&(e=n.fn),e===null)return[];let i=1,r=[];for(;i<e.length;)r.push(t(e[i])),i+=1;return r}var X="0.25.1";return R(z);})();
3
+ var MathJson=(()=>{var f=Object.defineProperty;var M=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var N=Object.prototype.hasOwnProperty;var A=(n,t)=>{for(var e in t)f(n,e,{get:t[e],enumerable:!0})},p=(n,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of S(t))!N.call(n,i)&&i!==e&&f(n,i,{get:()=>t[i],enumerable:!(r=M(t,i))||r.enumerable});return n};var J=n=>p(f({},"__esModule",{value:!0}),n);var O={};A(O,{getDictionary:()=>g,getStringValue:()=>c,isFunctionObject:()=>u,isStringObject:()=>y,isSymbolObject:()=>a,mapArgs:()=>h,operand:()=>E,operator:()=>o,symbol:()=>b,version:()=>I});function a(n){return n!==null&&typeof n=="object"&&"sym"in n}function y(n){return n!==null&&typeof n=="object"&&"str"in n}function u(n){return n!==null&&typeof n=="object"&&"fn"in n}function c(n){return n==null?null:typeof n=="object"&&"str"in n?n.str:typeof n!="string"||n.length<2||n.at(0)!=="'"||n.at(-1)!=="'"?null:n.substring(1,n.length-1)}function o(n){return Array.isArray(n)?n[0]:n==null?"":u(n)?n.fn[0]:""}function m(n){return Array.isArray(n)?n.slice(1):n!==void 0&&u(n)?n.fn.slice(1):[]}function E(n,t){return Array.isArray(n)?n[t]??null:n===null||!u(n)?null:n.fn[t]??null}function j(n){return n==null?0:Array.isArray(n)?Math.max(0,n.length-1):u(n)?Math.max(0,n.fn.length-1):0}function b(n){if(typeof n=="string")return/^[+-]?[0-9\.]/.test(n)||n.length>=2&&n[0]==="'"&&n[n.length-1]==="'"?null:n;if(n==null)return null;let t=a(n)?n.sym:n;return typeof t!="string"?null:t}function d(n){let t=o(n);if(t==="KeyValuePair"||t==="Tuple"||t==="Pair"){let[e,r]=m(n),i=c(e);return i?[i,r??"Nothing"]:null}return null}function g(n){if(n===null)return null;let t=d(n);if(t)return{[t[0]]:t[1]};if(o(n)==="Dictionary"){let r={},i=m(n);for(let l=1;l<j(n);l++){let s=d(i[l]);s&&(r[s[0]]=s[1])}return r}return null}function h(n,t){let e=null;if(Array.isArray(n)&&(e=n),u(n)&&(e=n.fn),e===null)return[];let r=1,i=[];for(;r<e.length;)i.push(t(e[r])),r+=1;return i}var I="0.26.2";return J(O);})();
4
4
  Object.assign(exports, MathJson); Object.defineProperty(exports, '__esModule', { value: true });}));
@@ -1,6 +1,18 @@
1
- /* 0.25.1 */
2
- export declare const BLACK = "\u001B[30;1m${s}";
3
- export declare const GREY = "\u001B[30;1m${s}";
1
+ /* 0.26.2 */
2
+ export declare const DEFAULT_COLOR = "\u001B[39m";
3
+ export declare const DEFAULT_BG = "\u001B[49m";
4
+ export declare const WHITE_BG = "\u001B[47m";
5
+ export declare const BLACK_BG = "\u001B[40m";
6
+ export declare const GREY_BG = "\u001B[100m";
7
+ export declare const GREEN_BG = "\u001B[42m";
8
+ export declare const RED_BG = "\u001B[41m";
9
+ export declare const YELLOW_BG = "\u001B[43m";
10
+ export declare const BLUE_BG = "\u001B[44m";
11
+ export declare const MAGENTA_BG = "\u001B[45m";
12
+ export declare const CYAN_BG = "\u001B[46m";
13
+ export declare const WHITE = "\u001B[37;1m";
14
+ export declare const BLACK = "\u001B[30;1m";
15
+ export declare const GREY = "\u001B[30;1m";
4
16
  export declare const GREEN = "\u001B[32;1m";
5
17
  export declare const RED = "\u001B[31;1m";
6
18
  export declare const YELLOW = "\u001B[33m";
@@ -12,4 +24,18 @@ export declare const INVERSE_GREEN = "\u001B[102;97m";
12
24
  export declare const INVERSE_YELLOW = "\u001B[103;97m";
13
25
  export declare const INVERSE_BLUE = "\u001B[104;97m";
14
26
  export declare const BOLD = "\u001B[1m";
15
- export declare const GREY_BG = "\u001B[40;1m";
27
+ export declare const BOLD_OFF = "\u001B[22m";
28
+ export declare const DIM = "\u001B[2m";
29
+ export declare const DIM_OFF = "\u001B[22m";
30
+ export declare const ITALIC = "\u001B[3m";
31
+ export declare const ITALIC_OFF = "\u001B[23m";
32
+ export declare const UNDERLINE = "\u001B[4m";
33
+ export declare const UNDERLINE_OFF = "\u001B[24m";
34
+ export declare const BLINK = "\u001B[5m";
35
+ export declare const BLINK_OFF = "\u001B[25m";
36
+ export declare const INVERSE = "\u001B[7m";
37
+ export declare const INVERSE_OFF = "\u001B[27m";
38
+ export declare const HIDDEN = "\u001B[8m";
39
+ export declare const HIDDEN_OFF = "\u001B[28m";
40
+ export declare function ansiFgColor(color: string | number, mode: 'none' | 'basic' | 'full'): number[];
41
+ export declare function ansiBgColor(color: string, mode: 'none' | 'basic' | 'full'): number[];
@@ -0,0 +1,9 @@
1
+ /* 0.26.2 */
2
+ s: string;
3
+ pos: number;
4
+ constructor(s: string, pos?: number);
5
+ atEnd(): boolean;
6
+ peek(): string;
7
+ consume(): string;
8
+ match(s: string): boolean;
9
+ }
@@ -1,4 +1,4 @@
1
- /* 0.25.1 */
1
+ /* 0.26.2 */
2
2
  /**
3
3
  * Return a string or an array of graphemes.
4
4
  *
@@ -0,0 +1,9 @@
1
+ /* 0.26.2 */
2
+ infer Head,
3
+ ...infer Rem
4
+ ] ? MergeTypes<Rem, Res & Head> : Res;
5
+ export type OneOf<TypesArray extends any[], Res = never, AllProperties = MergeTypes<TypesArray>> = TypesArray extends [infer Head, ...infer Rem] ? OneOf<Rem, Res | OnlyFirst<Head, AllProperties>, AllProperties> : Res;
6
+ type OnlyFirst<F, S> = F & {
7
+ [Key in keyof Omit<S, keyof F>]?: never;
8
+ };
9
+ export {};
@@ -1,4 +1,4 @@
1
- /* 0.25.1 */
1
+ /* 0.26.2 */
2
2
  /** @category Error Handling */
3
3
  export type RuntimeSignalCode = 'timeout' | 'out-of-memory' | 'recursion-depth-exceeded' | 'iteration-limit-exceeded';
4
4
  /** @category Error Handling */
@@ -0,0 +1,28 @@
1
+ /* 0.26.2 */
2
+ fg?: string;
3
+ bg?: string;
4
+ weight?: 'bold' | 'normal' | 'thin';
5
+ italic?: boolean;
6
+ mono?: boolean;
7
+ content: string;
8
+ };
9
+ /** A paragraph block has a blank line before and after
10
+ * and is wrapped to the width of the terminal.
11
+ *
12
+ * A 'block' is rendered as is, with no wrapping, but possibly
13
+ * with an indent. Used for code blocks, tables.
14
+ *
15
+ * A `blockquote` is a block with a vertical bar on the left,
16
+ * and is wrapped to the available width.
17
+ *
18
+ * A `note`, `warning` or `error` is an admonition block with a
19
+ * colored background or border (blue, orange or red).
20
+ *
21
+ */
22
+ export type StyledBlock = {
23
+ tag: 'paragraph' | 'block';
24
+ spans: StyledSpan[];
25
+ } | {
26
+ tag: 'blockquote' | 'note' | 'warning' | 'error';
27
+ blocks: StyledBlock[];
28
+ };
@@ -0,0 +1 @@
1
+ /* 0.26.2 */
@@ -0,0 +1,40 @@
1
+ /* 0.26.2 */
2
+ import { StyledBlock, StyledSpan } from './styled-text';
3
+ export type CodeTag =
4
+ /** Plain text in default foreground/background color */
5
+ 'default'
6
+ /** A literal such as a number, string or regex */
7
+ | 'literal'
8
+ /** A comment */
9
+ | 'comment'
10
+ /** A language keyword: if, while, export */
11
+ | 'keyword'
12
+ /** An operator such as =, >=, +, etc... */
13
+ | 'operator'
14
+ /** A punctuation such as `;`, `,`, `:` */
15
+ | 'punctuation'
16
+ /** An identifier such as "foo" or "bar" */
17
+ | 'identifier'
18
+ /** A type such as `boolean` or `number` */
19
+ | 'type';
20
+ export type CodeSpan = {
21
+ tag: CodeTag;
22
+ content: string;
23
+ };
24
+ export type SyntaxGrammar = {
25
+ comment?: (buf: Buffer) => undefined | CodeSpan;
26
+ number?: (buf: Buffer) => undefined | CodeSpan;
27
+ string?: (buf: Buffer) => undefined | CodeSpan;
28
+ regex?: (buf: Buffer) => undefined | CodeSpan;
29
+ identifier?: (buf: Buffer) => undefined | CodeSpan;
30
+ keyword?: (buf: Buffer) => undefined | CodeSpan;
31
+ };
32
+ export declare function parseCode(text: string, grammar?: SyntaxGrammar, pos?: number): CodeSpan[];
33
+ /** Return a style span of the input code */
34
+ export declare function highlightCodeSpan(code: string, grammar?: SyntaxGrammar): StyledSpan[];
35
+ /** Return a style block of the input code, including a
36
+ * gutter with line numbers and an optional highlighted line
37
+ */
38
+ export declare function highlightCodeBlock(code: string, lineStart?: number | undefined, markIndicator?: string, grammar?: SyntaxGrammar): StyledBlock;
39
+ export declare function mark(line: StyledSpan[], mark: string): StyledSpan[];
40
+ /** JS sample */
@@ -0,0 +1,19 @@
1
+ /* 0.26.2 */
2
+ declare abstract class Terminal {
3
+ width: number | undefined;
4
+ indent: number;
5
+ constructor(options?: {
6
+ indent?: number;
7
+ width?: number;
8
+ });
9
+ renderBlock(block: StyledBlock): string;
10
+ abstract renderSpan(span: StyledSpan): string;
11
+ renderSpans(s: StyledSpan[]): string;
12
+ display(s: StyledSpan[] | StyledBlock): void;
13
+ }
14
+ export declare const terminal: Terminal;
15
+ /** Word-wrap a string that contains ANSI escape sequences.
16
+ * ANSI escape sequences do not add to the string length.
17
+ */
18
+ export declare const wrapAnsiString: (string: string, width: number | undefined) => string[];
19
+ export {};
@@ -0,0 +1,4 @@
1
+ /* 0.26.2 */
2
+ export declare function parseType(s: undefined): undefined;
3
+ export declare function parseType(s: string | Type): Type;
4
+ export declare function parseType(s: string | Type | undefined): Type | undefined;
@@ -0,0 +1,8 @@
1
+ /* 0.26.2 */
2
+ export declare const NUMERIC_TYPES: PrimitiveType[];
3
+ export declare const COLLECTION_TYPES: PrimitiveType[];
4
+ export declare const SCALAR_TYPES: PrimitiveType[];
5
+ export declare const VALUE_TYPES: PrimitiveType[];
6
+ export declare const EXPRESSION_TYPES: PrimitiveType[];
7
+ export declare const PRIMITIVE_TYPES: PrimitiveType[];
8
+ export declare function isValidPrimitiveType(s: any): s is PrimitiveType;
@@ -0,0 +1,2 @@
1
+ /* 0.26.2 */
2
+ export declare function typeToString(type: Type, precedence?: number): string;
@@ -0,0 +1,6 @@
1
+ /* 0.26.2 */
2
+ /** Return true if lhs is a subtype of rhs */
3
+ export declare function isPrimitiveSubtype(lhs: PrimitiveType, rhs: PrimitiveType): boolean;
4
+ /** Return true if lhs is a subtype of rhs */
5
+ export declare function isSubtype(lhs: Type | TypeString, rhs: Type | TypeString): boolean;
6
+ export declare function isCompatible(lhs: PrimitiveType, rhs: PrimitiveType, compatibility: TypeCompatibility): boolean;
@@ -0,0 +1,249 @@
1
+ /* 0.26.2 */
2
+ * A primitive type is a simple type that represents a concrete value.
3
+ *
4
+ * - `any`: the top type
5
+ * - `expression`
6
+ * - `error`: an invalid value, such as `["Error", "missing"]`
7
+ * - `nothing`: the type of the `Nothing` symbol, the unit type
8
+ * - `never`: the bottom type
9
+ * - `unknown`: a value whose type is not known
10
+ *
11
+ * - `expression`:
12
+ * - a symbolic expression, such as `["Add", "x", 1]`
13
+ * - <value>
14
+ * - `symbol`: a symbol, such as `x`.
15
+ * - `function`: a function expression
16
+ * such as `["Function", ["Add", "x", 1], "x"]`.
17
+ *
18
+ * - `value`
19
+ * - `scalar`
20
+ * - <number>
21
+ * - `boolean`: a boolean value: `True` or `False`.
22
+ * - `string`: a string of characters.
23
+ * - `collection`
24
+ * - `list`: a collection of expressions, possibly recursive,
25
+ * with optional dimensions, e.g. `[number]`, `[boolean^32]`,
26
+ * `[number^(2x3)]`. Used to represent a vector, a matrix or a
27
+ * tensor when the type of its elements is a number
28
+ * - `set`: a collection of unique expressions, e.g. `set<string>`.
29
+ * - `tuple`: a fixed-size collection of named or unnamed elements, e.g.
30
+ * `tuple<number, boolean>`, `tuple<x: number, y: boolean>`.
31
+ * - `map`: a set key-value pairs, e.g. `map<x: number, y: boolean>`.
32
+ *
33
+ * - `number`: any numeric value:
34
+ * - `finite_number`: <finite_complex> or <finite_imaginary> or
35
+ * <finite_real> or <finite_rational> or <finite_integer>
36
+ * - `non_finite_number`: `NaN`, `PositiveInfinity`, `NegativeInfinity` or
37
+ * `ComplexInfinity`
38
+ * - `complex` and `finite_complex`: a complex number, with non-zero real
39
+ * and imaginary parts.
40
+ * - `imaginary` and `finite_imaginary`: a complex number with a real part
41
+ * of 0 (pure imaginary).
42
+ * - `real` and `finite_real`: a complex number with an imaginary part of 0.
43
+ * - `rational` and `finite_rational`: a pure rational number
44
+ * (not an integer)
45
+ * - `integer` and `finite_integer`: a whole number
46
+ *
47
+ *
48
+ */
49
+ export type PrimitiveType = NumericType | 'collection' | 'list' | 'set' | 'map' | 'tuple' | 'value' | 'scalar' | 'function' | 'symbol' | 'boolean' | 'string' | 'expression' | 'unknown' | 'error' | 'nothing' | 'never' | 'any';
50
+ export type NumericType = 'number' | 'finite_number' | 'complex' | 'finite_complex' | 'imaginary' | 'finite_imaginary' | 'real' | 'finite_real' | 'rational' | 'finite_rational' | 'integer' | 'finite_integer' | 'non_finite_number';
51
+ export type NamedElement = {
52
+ name?: string;
53
+ type: Type;
54
+ };
55
+ export type FunctionSignature = {
56
+ kind: 'signature';
57
+ args?: NamedElement[];
58
+ optArgs?: NamedElement[];
59
+ restArg?: NamedElement;
60
+ result: Type;
61
+ };
62
+ export type AlgebraicType = {
63
+ kind: 'union' | 'intersection';
64
+ types: Type[];
65
+ };
66
+ export type NegationType = {
67
+ kind: 'negation';
68
+ type: Type;
69
+ };
70
+ export type ValueType = {
71
+ kind: 'value';
72
+ value: any;
73
+ };
74
+ /** Map is not a collection. It is a set of key/value pairs.
75
+ * An element of a map whose type is a subtype of `nothing` is optional.
76
+ * For example, in `{x: number, y: boolean | nothing}` the element `y` is optional.
77
+ */
78
+ export type MapType = {
79
+ kind: 'map';
80
+ elements: Record<string, Type>;
81
+ };
82
+ /** Collection, List, Set, Tuple and Map are collections.
83
+ *
84
+ * `CollectionType` is a generic collection of elements of a certain type.
85
+ */
86
+ export type CollectionType = {
87
+ kind: 'collection';
88
+ elements: Type;
89
+ };
90
+ /**
91
+ * The elements of a list are ordered.
92
+ *
93
+ * All elements of a list have the same type (but it can be a broad type,
94
+ * up to `any`).
95
+ *
96
+ * The same element can be present in the list more than once.
97
+ *
98
+ * A list can be multi-dimensional. For example, a list of integers with
99
+ * dimensions 2x3x4 is a 3D tensor with 2 layers, 3 rows and 4 columns.
100
+ *
101
+ */
102
+ export type ListType = {
103
+ kind: 'list';
104
+ elements: Type;
105
+ dimensions?: number[];
106
+ };
107
+ /** Each element of a set is unique (is not present in the set more than once).
108
+ * The elements of a set are not ordered.
109
+ */
110
+ export type SetType = {
111
+ kind: 'set';
112
+ elements: Type;
113
+ };
114
+ export type TupleType = {
115
+ kind: 'tuple';
116
+ elements: NamedElement[];
117
+ };
118
+ /** Nominal typing */
119
+ export type TypeReference = {
120
+ kind: 'reference';
121
+ ref: string;
122
+ };
123
+ export type Type = PrimitiveType | AlgebraicType | NegationType | CollectionType | ListType | SetType | MapType | TupleType | FunctionSignature | ValueType | TypeReference;
124
+ /**
125
+ * The type of a boxed expression indicates the kind of expression it is and
126
+ * the value it represents.
127
+ *
128
+ * The type is represented either by a primitive type (e.g. number, complex, collection, etc.), or a compound type (e.g. tuple, function signature, etc.).
129
+ *
130
+ * Types are described using the following BNF grammar:
131
+
132
+ ```bnf
133
+ <type> ::= <union_type>
134
+
135
+ <union_type> ::= <intersection_type> (" | " <intersection_type>)*
136
+
137
+ <intersection_type> ::= <primary_type> (" & " <primary_type>)*
138
+
139
+ <primary_type> ::= <primitive>
140
+ | <tuple_type>
141
+ | <function_type>
142
+ | <list_type>
143
+ | <wrapped_primary_type>
144
+
145
+ <wrapped_primary_type> ::= "(" <primary_type> ")"
146
+
147
+
148
+ <primitive> ::= "any" | "unknown" | <value-type> | <symbolic-type> | <numeric-type>
149
+
150
+ <numeric-type> ::= "number" | "complex" | "imaginary" | "real" | "rational" | "integer"
151
+
152
+ <value-type> ::= "value" | <numeric-type> | "collection" | "boolean" | "string"
153
+
154
+ <symbolic-type> ::= "expression" | "function" | "symbol"
155
+
156
+ <tuple_type> ::= "(" (<name> <type> "," <named_tuple_elements>*) ")"
157
+ | "(" (<type> "," <unnamed_tuple_elements>*) ")" |
158
+ | "tuple(" <tuple_elements> ")"
159
+
160
+ <tuple_elements> ::= <unnamed_tuple_elements> | <named_tuple_elements>
161
+
162
+ <unnamed_tuple_elements> ::= <type> ("," <type>)*
163
+
164
+ <named_tuple_elements> ::= <name> <type> ("," <name> <type>)*
165
+
166
+ <function_type> ::= <arguments> " -> " <type>
167
+
168
+ <arguments> ::= "()"
169
+ | <argument>
170
+ | "(" <argument-list> ")"
171
+ | <deferred_evaluation>
172
+
173
+ <deferred_evaluation> ::= "???" <argument>
174
+ | "???" "(" <argument-list> ")"
175
+
176
+ <argument> ::= <type>
177
+ | <name> <type>
178
+
179
+ <rest_argument> ::= "..." <type>
180
+ | <name> "..." <type>
181
+
182
+ <optional_argument> ::= <argument> "?"
183
+
184
+ <optional_arguments> ::= <optional_argument> ("," <optional_argument>)*
185
+
186
+ <required_arguments> ::= <argument> ("," <argument>)*
187
+
188
+ <argument-list> ::= <required_arguments> ("," <rest_argument>)?
189
+ | <required_arguments> <optional_arguments>?
190
+ | <optional_arguments>?
191
+ | <rest_argument>
192
+
193
+
194
+ <list_type> ::= "[" <type> <dimensions>? "]"
195
+
196
+ <dimensions> ::= "^" <fixed_size>
197
+ | "^(" <multi_dimensional_size> ")"
198
+
199
+ <fixed_size> ::= <positive-integer_literal>
200
+
201
+ <multi_dimensional_size> ::= <positive-integer_literal> "x" <positive-integer_literal> ("x" <positive-integer_literal>)*
202
+
203
+ <map> ::= "{}"
204
+ |"{" <map_elements> "}"
205
+ | "map(" <map_elements> ")"
206
+
207
+ <map_elements> ::= <name> <type> ("," <name> <type>)*
208
+
209
+ <set> ::= "set<" <type> ">"
210
+
211
+ <collection ::= "collection<" <type> ">"
212
+
213
+ <name> ::= <identifier> ":"
214
+
215
+ <identifier> ::= [a-zA-Z_][a-zA-Z0-9_]*
216
+
217
+ <positive-integer_literal> ::= [1-9][0-9]*
218
+ ```
219
+
220
+
221
+ Examples of types:
222
+ "number" -- a simple type primitive
223
+
224
+
225
+ "(number, boolean)" -- a tuple type
226
+ "(x: number, y:boolean)" -- a named tuple/record type. Either all arguments are named, or none are
227
+
228
+ "[any]" -- an arbitrary collection type, with no length or element type restrictions
229
+ "[integer]" -- a collection type where all the elements are integers
230
+ "[(number, boolean)]" -- a collection of tuples
231
+ "[(value:number, seen:boolean)]" -- a collection of named tuples
232
+ "[boolean]^32" -- a collection type with a fixed size of 32 elements
233
+ "[integer]^(2x3)" -- an integer matrix of 2 columns and 3 rows
234
+ "[integer]^(2x3x4)" -- a tensor of dimensions 2x3x4
235
+
236
+ "number -> number" -- a function type with a single argument
237
+ "(x: number, number) -> number" -- a function type with a named argument
238
+ "(number, y:number?) -> number" -- a function type with an optional named argument (can have several optional arguments, at the end)
239
+ "(number, ...number) -> number" -- a function type with a rest argument (can have only one, and no optional arguments if there is a rest argument).
240
+ "() -> number" -- a function type with an empty argument list
241
+
242
+ "number | boolean" -- a union type
243
+ "(x: number) & (y: number)" -- an intersection type
244
+ "number | ((x: number) & (y: number))" -- a union type with an intersection type
245
+ "(number -> number) | number" -- a union type with a function type
246
+ */
247
+ export type TypeString = string;
248
+ export type TypeCompatibility = 'covariant' | 'contravariant' | 'bivariant' | 'invariant';
249
+ export type TypeResolver = (name: string) => Type | undefined;
@@ -0,0 +1,39 @@
1
+ /* 0.26.2 */
2
+ /** Convert two or more types into a more specific type that is a subtype of
3
+ * all the input types. The resulting type is usually more constrained and
4
+ * only encompasses values that belong to both input types.
5
+ *
6
+ * Examples:
7
+ * narrow('integer', 'rational') => 'integer'
8
+ * narrow('number', 'complex') => 'complex'
9
+ * narrow('number', 'collection') => 'nothing'
10
+ * narrow('number', 'value') => 'value'
11
+ * narrow('number', 'expression') => 'expression'
12
+ * narrow('number', 'string') => 'nothing'
13
+ *
14
+ *
15
+ */
16
+ export declare function narrow(...types: Readonly<Type>[]): Type;
17
+ /**
18
+ * Convert two or more types into a broader, more general type that can
19
+ * accommodate all the input types. The resulting type is usually a supertype
20
+ * that encompasses the possible values of the input types
21
+ *
22
+ * Examples:
23
+ * widen('integer', 'rational') => 'rational'
24
+ * widen('number', 'complex') => 'complex'
25
+ * widen('number', 'collection') => 'collection'
26
+ * widen('number', 'value') => 'value'
27
+ * widen('number', 'expression') => 'expression'
28
+ * widen('number', 'string') => 'any'
29
+ */
30
+ export declare function widen(...types: Readonly<Type>[]): Type;
31
+ export declare function isSignatureType(type: Readonly<Type> | TypeString): type is FunctionSignature;
32
+ export declare function functionSignature(type: Readonly<Type>): Type | undefined;
33
+ export declare function functionResult(type: Readonly<Type>): Type | undefined;
34
+ export declare function collectionElementType(type: Readonly<Type>): Type | undefined;
35
+ export declare function isValidType(t: any): t is Readonly<Type>;
36
+ /**
37
+ * Add a `toString()` method to the type object
38
+ */
39
+ export declare function makeType(type: Type): Readonly<Type>;
@@ -1 +1,2 @@
1
- /* 0.25.1 */
1
+ /* 0.26.2 */
2
+ export declare function hidePrivateProperties(obj: any): void;
@@ -1,4 +1,4 @@
1
- /* 0.25.1 */
1
+ /* 0.26.2 */
2
2
  /**
3
3
  * Add an assumption, in the form of a predicate, for example:
4
4
  *
@@ -7,20 +7,20 @@
7
7
  * - `x > 3`
8
8
  * - `x + y = 5`
9
9
  *
10
- * Some assumptions are handled separately, specifically, those that can
11
- * be represented as a symbol definition (equality to an expression,
12
- * membership to Integers, RealNumbers, etc..., >0, <=0, etc...). The result
13
- * of these are stored directly in the current scope's symbols dictionary
14
- * (and an entry for the symbol is created if necessary).
15
- *
16
- * New assumptions can 'refine' previous assumptions, that is they are valid
17
- * if they don't contradict previous assumptions. To set new assumptions
18
- * that contradict previous ones, you must first `forget` about any symbols
19
- * in the new assumption.
10
+ * Assumptions that represent a symbol definition (equality to an expression,
11
+ * membership to a type, >0, <=0, etc...) are stored directly in the current
12
+ * scope's symbols dictionary, and an entry for the symbol is created if
13
+ * necessary.
20
14
  *
21
15
  * Predicates that involve multiple symbols are simplified (for example
22
- * `x + y = 5` becomes `x + y - 5 = 0`, then stored in the `assumptions` of the
23
- * current context).
16
+ * `x + y = 5` becomes `x + y - 5 = 0`), then stored in the `assumptions`
17
+ * record of the current context.
18
+ *
19
+ * New assumptions can 'refine' previous assumptions, if they don't contradict
20
+ * previous assumptions.
21
+ *
22
+ * To set new assumptions that contradict previous ones, you must first
23
+ * `forget` about any symbols in the new assumption.
24
24
  *
25
25
  */
26
26
  export declare function assume(proposition: BoxedExpression): AssumeResult;