@math.gl/core 5.0.0-alpha.2 → 5.0.0-alpha.20

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 (272) hide show
  1. package/APACHE-2.0-LICENSE.txt +55 -0
  2. package/ARROW-NOTICE.txt +18 -0
  3. package/LICENSE +149 -40
  4. package/PROJ4-LICENSE.md +29 -0
  5. package/README.md +14 -0
  6. package/THIRD-PARTY-NOTICES.md +16 -0
  7. package/dist/classes/base/math-array.d.ts +1 -1
  8. package/dist/classes/base/math-array.d.ts.map +1 -1
  9. package/dist/classes/base/math-array.js +1 -1
  10. package/dist/classes/base/math-array.js.map +1 -1
  11. package/dist/classes/base/matrix.d.ts +1 -1
  12. package/dist/classes/base/matrix.d.ts.map +1 -1
  13. package/dist/classes/base/matrix.js +2 -2
  14. package/dist/classes/base/matrix.js.map +1 -1
  15. package/dist/classes/base/vector.d.ts +1 -1
  16. package/dist/classes/base/vector.d.ts.map +1 -1
  17. package/dist/classes/base/vector.js +2 -2
  18. package/dist/classes/base/vector.js.map +1 -1
  19. package/dist/classes/euler-types.js +1 -1
  20. package/dist/classes/euler-types.js.map +1 -1
  21. package/dist/classes/euler.d.ts +1 -1
  22. package/dist/classes/euler.d.ts.map +1 -1
  23. package/dist/classes/euler.js +4 -2
  24. package/dist/classes/euler.js.map +1 -1
  25. package/dist/classes/matrix3.d.ts +1 -1
  26. package/dist/classes/matrix3.d.ts.map +1 -1
  27. package/dist/classes/matrix3.js +2 -2
  28. package/dist/classes/matrix3.js.map +1 -1
  29. package/dist/classes/matrix4.d.ts +1 -1
  30. package/dist/classes/matrix4.d.ts.map +1 -1
  31. package/dist/classes/matrix4.js +2 -2
  32. package/dist/classes/matrix4.js.map +1 -1
  33. package/dist/classes/pose.d.ts +1 -1
  34. package/dist/classes/pose.d.ts.map +1 -1
  35. package/dist/classes/pose.js +2 -2
  36. package/dist/classes/pose.js.map +1 -1
  37. package/dist/classes/quaternion.d.ts +1 -1
  38. package/dist/classes/quaternion.d.ts.map +1 -1
  39. package/dist/classes/quaternion.js +2 -2
  40. package/dist/classes/quaternion.js.map +1 -1
  41. package/dist/classes/spherical-coordinates.js +2 -2
  42. package/dist/classes/spherical-coordinates.js.map +1 -1
  43. package/dist/classes/vector2.d.ts +1 -1
  44. package/dist/classes/vector2.d.ts.map +1 -1
  45. package/dist/classes/vector2.js +2 -2
  46. package/dist/classes/vector2.js.map +1 -1
  47. package/dist/classes/vector3.d.ts +1 -1
  48. package/dist/classes/vector3.d.ts.map +1 -1
  49. package/dist/classes/vector3.js +2 -2
  50. package/dist/classes/vector3.js.map +1 -1
  51. package/dist/classes/vector4.d.ts +1 -1
  52. package/dist/classes/vector4.d.ts.map +1 -1
  53. package/dist/classes/vector4.js +2 -2
  54. package/dist/classes/vector4.js.map +1 -1
  55. package/dist/expressions/expression-eval.d.ts +98 -0
  56. package/dist/expressions/expression-eval.d.ts.map +1 -0
  57. package/dist/expressions/expression-eval.js +302 -0
  58. package/dist/expressions/expression-eval.js.map +1 -0
  59. package/dist/expressions/function-libraries.d.ts +60 -0
  60. package/dist/expressions/function-libraries.d.ts.map +1 -0
  61. package/dist/expressions/function-libraries.js +69 -0
  62. package/dist/expressions/function-libraries.js.map +1 -0
  63. package/dist/expressions/function-registry.d.ts +93 -0
  64. package/dist/expressions/function-registry.d.ts.map +1 -0
  65. package/dist/expressions/function-registry.js +139 -0
  66. package/dist/expressions/function-registry.js.map +1 -0
  67. package/dist/expressions/get.d.ts +9 -0
  68. package/dist/expressions/get.d.ts.map +1 -0
  69. package/dist/expressions/get.js +32 -0
  70. package/dist/expressions/get.js.map +1 -0
  71. package/dist/expressions/index.cjs +1491 -0
  72. package/dist/expressions/index.cjs.map +6 -0
  73. package/dist/expressions/index.d.ts +7 -0
  74. package/dist/expressions/index.d.ts.map +1 -0
  75. package/dist/expressions/index.js +8 -0
  76. package/dist/expressions/index.js.map +1 -0
  77. package/dist/expressions/parse-expression-string.d.ts +21 -0
  78. package/dist/expressions/parse-expression-string.d.ts.map +1 -0
  79. package/dist/expressions/parse-expression-string.js +61 -0
  80. package/dist/expressions/parse-expression-string.js.map +1 -0
  81. package/dist/expressions/vendor/jsep/runtime.d.ts +3 -0
  82. package/dist/expressions/vendor/jsep/runtime.d.ts.map +1 -0
  83. package/dist/expressions/vendor/jsep/runtime.js +972 -0
  84. package/dist/expressions/vendor/jsep/runtime.js.map +1 -0
  85. package/dist/expressions/vendor/jsep/types.d.ts +141 -0
  86. package/dist/expressions/vendor/jsep/types.d.ts.map +1 -0
  87. package/dist/expressions/vendor/jsep/types.js +4 -0
  88. package/dist/expressions/vendor/jsep/types.js.map +1 -0
  89. package/dist/gl-matrix/common.d.ts +1 -1
  90. package/dist/gl-matrix/common.d.ts.map +1 -1
  91. package/dist/gl-matrix/common.js +5 -0
  92. package/dist/gl-matrix/common.js.map +1 -1
  93. package/dist/gl-matrix/mat3.d.ts.map +1 -1
  94. package/dist/gl-matrix/mat3.js +5 -0
  95. package/dist/gl-matrix/mat3.js.map +1 -1
  96. package/dist/gl-matrix/mat4.d.ts.map +1 -1
  97. package/dist/gl-matrix/mat4.js +5 -0
  98. package/dist/gl-matrix/mat4.js.map +1 -1
  99. package/dist/gl-matrix/quat.d.ts.map +1 -1
  100. package/dist/gl-matrix/quat.js +5 -0
  101. package/dist/gl-matrix/quat.js.map +1 -1
  102. package/dist/gl-matrix/vec2.d.ts +1 -1
  103. package/dist/gl-matrix/vec2.d.ts.map +1 -1
  104. package/dist/gl-matrix/vec2.js +5 -0
  105. package/dist/gl-matrix/vec2.js.map +1 -1
  106. package/dist/gl-matrix/vec3.d.ts.map +1 -1
  107. package/dist/gl-matrix/vec3.js +5 -0
  108. package/dist/gl-matrix/vec3.js.map +1 -1
  109. package/dist/gl-matrix/vec4.d.ts.map +1 -1
  110. package/dist/gl-matrix/vec4.js +5 -0
  111. package/dist/gl-matrix/vec4.js.map +1 -1
  112. package/dist/gl-matrix/wip/index.d.ts.map +1 -1
  113. package/dist/gl-matrix/wip/index.js +3 -1
  114. package/dist/gl-matrix/wip/index.js.map +1 -1
  115. package/dist/gl-matrix/wip/mat2.d.ts.map +1 -1
  116. package/dist/gl-matrix/wip/mat2.js +3 -1
  117. package/dist/gl-matrix/wip/mat2.js.map +1 -1
  118. package/dist/gl-matrix/wip/mat2d.d.ts.map +1 -1
  119. package/dist/gl-matrix/wip/mat2d.js +3 -1
  120. package/dist/gl-matrix/wip/mat2d.js.map +1 -1
  121. package/dist/gl-matrix/wip/quat2.d.ts.map +1 -1
  122. package/dist/gl-matrix/wip/quat2.js +3 -1
  123. package/dist/gl-matrix/wip/quat2.js.map +1 -1
  124. package/dist/index.cjs.map +1 -1
  125. package/dist/index.d.ts +3 -2
  126. package/dist/index.d.ts.map +1 -1
  127. package/dist/index.js +1 -1
  128. package/dist/index.js.map +1 -1
  129. package/dist/lib/assert.js +1 -1
  130. package/dist/lib/assert.js.map +1 -1
  131. package/dist/lib/common.d.ts +1 -1
  132. package/dist/lib/common.d.ts.map +1 -1
  133. package/dist/lib/common.js +1 -1
  134. package/dist/lib/common.js.map +1 -1
  135. package/dist/lib/gl-matrix-extras.d.ts +1 -1
  136. package/dist/lib/gl-matrix-extras.d.ts.map +1 -1
  137. package/dist/lib/gl-matrix-extras.js +1 -1
  138. package/dist/lib/gl-matrix-extras.js.map +1 -1
  139. package/dist/lib/math-utils.d.ts.map +1 -1
  140. package/dist/lib/math-utils.js +2 -1
  141. package/dist/lib/math-utils.js.map +1 -1
  142. package/dist/lib/validators.d.ts +1 -1
  143. package/dist/lib/validators.d.ts.map +1 -1
  144. package/dist/lib/validators.js +1 -1
  145. package/dist/lib/validators.js.map +1 -1
  146. package/dist/local-frame.cjs +139 -0
  147. package/dist/local-frame.cjs.map +6 -0
  148. package/dist/local-frame.d.ts +39 -0
  149. package/dist/local-frame.d.ts.map +1 -0
  150. package/dist/local-frame.js +157 -0
  151. package/dist/local-frame.js.map +1 -0
  152. package/dist/mat3.cjs.map +1 -1
  153. package/dist/mat3.js +1 -1
  154. package/dist/mat3.js.map +1 -1
  155. package/dist/mat4.cjs.map +1 -1
  156. package/dist/mat4.js +1 -1
  157. package/dist/mat4.js.map +1 -1
  158. package/dist/quat.cjs.map +1 -1
  159. package/dist/quat.js +1 -1
  160. package/dist/quat.js.map +1 -1
  161. package/dist/spheroid.cjs +147 -0
  162. package/dist/spheroid.cjs.map +6 -0
  163. package/dist/spheroid.d.ts +21 -0
  164. package/dist/spheroid.d.ts.map +1 -0
  165. package/dist/spheroid.js +175 -0
  166. package/dist/spheroid.js.map +1 -0
  167. package/dist/types/array-types.d.ts +98 -0
  168. package/dist/types/array-types.d.ts.map +1 -0
  169. package/dist/types/array-types.js +6 -0
  170. package/dist/types/array-types.js.map +1 -0
  171. package/dist/types/bigint.d.ts +21 -0
  172. package/dist/types/bigint.d.ts.map +1 -0
  173. package/dist/types/bigint.js +65 -0
  174. package/dist/types/bigint.js.map +1 -0
  175. package/dist/types/bounds-types.d.ts +11 -0
  176. package/dist/types/bounds-types.d.ts.map +1 -0
  177. package/dist/types/bounds-types.js +17 -0
  178. package/dist/types/bounds-types.js.map +1 -0
  179. package/dist/types/float16.d.ts +32 -0
  180. package/dist/types/float16.d.ts.map +1 -0
  181. package/dist/types/float16.js +41 -0
  182. package/dist/types/float16.js.map +1 -0
  183. package/dist/types/index.d.ts +6 -0
  184. package/dist/types/index.d.ts.map +1 -0
  185. package/dist/types/index.js +6 -0
  186. package/dist/types/index.js.map +1 -0
  187. package/dist/types/is-array.d.ts +22 -0
  188. package/dist/types/is-array.d.ts.map +1 -0
  189. package/dist/types/is-array.js +36 -0
  190. package/dist/types/is-array.js.map +1 -0
  191. package/dist/types/spheroid.d.ts +8 -0
  192. package/dist/types/spheroid.d.ts.map +1 -0
  193. package/dist/types/spheroid.js +5 -0
  194. package/dist/types/spheroid.js.map +1 -0
  195. package/dist/types/typed-array-brand.d.ts +2 -0
  196. package/dist/types/typed-array-brand.d.ts.map +1 -0
  197. package/dist/types/typed-array-brand.js +10 -0
  198. package/dist/types/typed-array-brand.js.map +1 -0
  199. package/dist/types.cjs +67 -0
  200. package/dist/types.cjs.map +6 -0
  201. package/dist/types.d.ts +2 -0
  202. package/dist/types.d.ts.map +1 -0
  203. package/dist/types.js +5 -0
  204. package/dist/types.js.map +1 -0
  205. package/dist/vec2.cjs.map +1 -1
  206. package/dist/vec2.js +1 -1
  207. package/dist/vec2.js.map +1 -1
  208. package/dist/vec3.cjs.map +1 -1
  209. package/dist/vec3.js +1 -1
  210. package/dist/vec3.js.map +1 -1
  211. package/dist/vec4.cjs.map +1 -1
  212. package/dist/vec4.js +1 -1
  213. package/dist/vec4.js.map +1 -1
  214. package/package.json +28 -6
  215. package/src/classes/base/math-array.ts +2 -2
  216. package/src/classes/base/matrix.ts +3 -3
  217. package/src/classes/base/vector.ts +3 -3
  218. package/src/classes/euler-types.ts +1 -1
  219. package/src/classes/euler.ts +5 -3
  220. package/src/classes/matrix3.ts +3 -3
  221. package/src/classes/matrix4.ts +3 -3
  222. package/src/classes/pose.ts +3 -3
  223. package/src/classes/quaternion.ts +3 -3
  224. package/src/classes/spherical-coordinates.ts +2 -2
  225. package/src/classes/vector2.ts +3 -3
  226. package/src/classes/vector3.ts +3 -3
  227. package/src/classes/vector4.ts +3 -3
  228. package/src/expressions/expression-eval.ts +435 -0
  229. package/src/expressions/function-libraries.ts +123 -0
  230. package/src/expressions/function-registry.ts +171 -0
  231. package/src/expressions/get.ts +37 -0
  232. package/src/expressions/index.ts +22 -0
  233. package/src/expressions/parse-expression-string.ts +80 -0
  234. package/src/expressions/vendor/jsep/LICENSE.txt +23 -0
  235. package/src/expressions/vendor/jsep/README.md +22 -0
  236. package/src/expressions/vendor/jsep/runtime.ts +949 -0
  237. package/src/expressions/vendor/jsep/types.ts +179 -0
  238. package/src/gl-matrix/common.js +5 -0
  239. package/src/gl-matrix/mat3.ts +5 -0
  240. package/src/gl-matrix/mat4.ts +5 -0
  241. package/src/gl-matrix/quat.ts +5 -0
  242. package/src/gl-matrix/vec2.ts +6 -1
  243. package/src/gl-matrix/vec3.ts +5 -0
  244. package/src/gl-matrix/vec4.ts +5 -0
  245. package/src/gl-matrix/wip/index.js +3 -1
  246. package/src/gl-matrix/wip/mat2.js +3 -1
  247. package/src/gl-matrix/wip/mat2d.js +3 -1
  248. package/src/gl-matrix/wip/quat2.ts +3 -1
  249. package/src/index.ts +5 -3
  250. package/src/lib/assert.ts +1 -1
  251. package/src/lib/common.ts +2 -2
  252. package/src/lib/gl-matrix-extras.ts +2 -2
  253. package/src/lib/gl-matrix.d.ts +1 -1
  254. package/src/lib/math-utils.ts +2 -1
  255. package/src/lib/validators.ts +2 -2
  256. package/src/local-frame.ts +253 -0
  257. package/src/mat3.ts +1 -1
  258. package/src/mat4.ts +1 -1
  259. package/src/quat.ts +1 -1
  260. package/src/spheroid.ts +230 -0
  261. package/src/types/array-types.ts +148 -0
  262. package/src/types/bigint.ts +74 -0
  263. package/src/types/bounds-types.ts +29 -0
  264. package/src/types/float16.ts +47 -0
  265. package/src/types/index.ts +45 -0
  266. package/src/types/is-array.ts +41 -0
  267. package/src/types/spheroid.ts +11 -0
  268. package/src/types/typed-array-brand.ts +14 -0
  269. package/src/types.ts +5 -0
  270. package/src/vec2.ts +1 -1
  271. package/src/vec3.ts +1 -1
  272. package/src/vec4.ts +1 -1
@@ -0,0 +1,949 @@
1
+ // SPDX-License-Identifier: MIT
2
+ // SPDX-FileCopyrightText: Copyright (c) 2013 Stephen Oney
3
+ // @ts-nocheck
4
+ // Generated by scripts/vendor-expression-timezone-deps.mjs; see README.md and LICENSE files.
5
+
6
+ // jsep/dist/jsep.js
7
+ var Hooks = class {
8
+ /**
9
+ * @callback HookCallback
10
+ * @this {*|Jsep} this
11
+ * @param {Jsep} env
12
+ * @returns: void
13
+ */
14
+ /**
15
+ * Adds the given callback to the list of callbacks for the given hook.
16
+ *
17
+ * The callback will be invoked when the hook it is registered for is run.
18
+ *
19
+ * One callback function can be registered to multiple hooks and the same hook multiple times.
20
+ *
21
+ * @param {string|object} name The name of the hook, or an object of callbacks keyed by name
22
+ * @param {HookCallback|boolean} callback The callback function which is given environment variables.
23
+ * @param {?boolean} [first=false] Will add the hook to the top of the list (defaults to the bottom)
24
+ * @public
25
+ */
26
+ add(name, callback, first) {
27
+ if (typeof arguments[0] != "string") {
28
+ for (let name2 in arguments[0]) {
29
+ this.add(name2, arguments[0][name2], arguments[1]);
30
+ }
31
+ } else {
32
+ (Array.isArray(name) ? name : [name]).forEach(function(name2) {
33
+ this[name2] = this[name2] || [];
34
+ if (callback) {
35
+ this[name2][first ? "unshift" : "push"](callback);
36
+ }
37
+ }, this);
38
+ }
39
+ }
40
+ /**
41
+ * Runs a hook invoking all registered callbacks with the given environment variables.
42
+ *
43
+ * Callbacks will be invoked synchronously and in the order in which they were registered.
44
+ *
45
+ * @param {string} name The name of the hook.
46
+ * @param {Object<string, any>} env The environment variables of the hook passed to all callbacks registered.
47
+ * @public
48
+ */
49
+ run(name, env) {
50
+ this[name] = this[name] || [];
51
+ this[name].forEach(function(callback) {
52
+ callback.call(env && env.context ? env.context : env, env);
53
+ });
54
+ }
55
+ };
56
+ var Plugins = class {
57
+ constructor(jsep2) {
58
+ this.jsep = jsep2;
59
+ this.registered = {};
60
+ }
61
+ /**
62
+ * @callback PluginSetup
63
+ * @this {Jsep} jsep
64
+ * @returns: void
65
+ */
66
+ /**
67
+ * Adds the given plugin(s) to the registry
68
+ *
69
+ * @param {object} plugins
70
+ * @param {string} plugins.name The name of the plugin
71
+ * @param {PluginSetup} plugins.init The init function
72
+ * @public
73
+ */
74
+ register(...plugins) {
75
+ plugins.forEach((plugin) => {
76
+ if (typeof plugin !== "object" || !plugin.name || !plugin.init) {
77
+ throw new Error("Invalid JSEP plugin format");
78
+ }
79
+ if (this.registered[plugin.name]) {
80
+ return;
81
+ }
82
+ plugin.init(this.jsep);
83
+ this.registered[plugin.name] = plugin;
84
+ });
85
+ }
86
+ };
87
+ var Jsep = class _Jsep {
88
+ /**
89
+ * @returns {string}
90
+ */
91
+ static get version() {
92
+ return "1.4.0";
93
+ }
94
+ /**
95
+ * @returns {string}
96
+ */
97
+ static toString() {
98
+ return "JavaScript Expression Parser (JSEP) v" + _Jsep.version;
99
+ }
100
+ // ==================== CONFIG ================================
101
+ /**
102
+ * @method addUnaryOp
103
+ * @param {string} op_name The name of the unary op to add
104
+ * @returns {Jsep}
105
+ */
106
+ static addUnaryOp(op_name) {
107
+ _Jsep.max_unop_len = Math.max(op_name.length, _Jsep.max_unop_len);
108
+ _Jsep.unary_ops[op_name] = 1;
109
+ return _Jsep;
110
+ }
111
+ /**
112
+ * @method jsep.addBinaryOp
113
+ * @param {string} op_name The name of the binary op to add
114
+ * @param {number} precedence The precedence of the binary op (can be a float). Higher number = higher precedence
115
+ * @param {boolean} [isRightAssociative=false] whether operator is right-associative
116
+ * @returns {Jsep}
117
+ */
118
+ static addBinaryOp(op_name, precedence, isRightAssociative) {
119
+ _Jsep.max_binop_len = Math.max(op_name.length, _Jsep.max_binop_len);
120
+ _Jsep.binary_ops[op_name] = precedence;
121
+ if (isRightAssociative) {
122
+ _Jsep.right_associative.add(op_name);
123
+ } else {
124
+ _Jsep.right_associative.delete(op_name);
125
+ }
126
+ return _Jsep;
127
+ }
128
+ /**
129
+ * @method addIdentifierChar
130
+ * @param {string} char The additional character to treat as a valid part of an identifier
131
+ * @returns {Jsep}
132
+ */
133
+ static addIdentifierChar(char) {
134
+ _Jsep.additional_identifier_chars.add(char);
135
+ return _Jsep;
136
+ }
137
+ /**
138
+ * @method addLiteral
139
+ * @param {string} literal_name The name of the literal to add
140
+ * @param {*} literal_value The value of the literal
141
+ * @returns {Jsep}
142
+ */
143
+ static addLiteral(literal_name, literal_value) {
144
+ _Jsep.literals[literal_name] = literal_value;
145
+ return _Jsep;
146
+ }
147
+ /**
148
+ * @method removeUnaryOp
149
+ * @param {string} op_name The name of the unary op to remove
150
+ * @returns {Jsep}
151
+ */
152
+ static removeUnaryOp(op_name) {
153
+ delete _Jsep.unary_ops[op_name];
154
+ if (op_name.length === _Jsep.max_unop_len) {
155
+ _Jsep.max_unop_len = _Jsep.getMaxKeyLen(_Jsep.unary_ops);
156
+ }
157
+ return _Jsep;
158
+ }
159
+ /**
160
+ * @method removeAllUnaryOps
161
+ * @returns {Jsep}
162
+ */
163
+ static removeAllUnaryOps() {
164
+ _Jsep.unary_ops = {};
165
+ _Jsep.max_unop_len = 0;
166
+ return _Jsep;
167
+ }
168
+ /**
169
+ * @method removeIdentifierChar
170
+ * @param {string} char The additional character to stop treating as a valid part of an identifier
171
+ * @returns {Jsep}
172
+ */
173
+ static removeIdentifierChar(char) {
174
+ _Jsep.additional_identifier_chars.delete(char);
175
+ return _Jsep;
176
+ }
177
+ /**
178
+ * @method removeBinaryOp
179
+ * @param {string} op_name The name of the binary op to remove
180
+ * @returns {Jsep}
181
+ */
182
+ static removeBinaryOp(op_name) {
183
+ delete _Jsep.binary_ops[op_name];
184
+ if (op_name.length === _Jsep.max_binop_len) {
185
+ _Jsep.max_binop_len = _Jsep.getMaxKeyLen(_Jsep.binary_ops);
186
+ }
187
+ _Jsep.right_associative.delete(op_name);
188
+ return _Jsep;
189
+ }
190
+ /**
191
+ * @method removeAllBinaryOps
192
+ * @returns {Jsep}
193
+ */
194
+ static removeAllBinaryOps() {
195
+ _Jsep.binary_ops = {};
196
+ _Jsep.max_binop_len = 0;
197
+ return _Jsep;
198
+ }
199
+ /**
200
+ * @method removeLiteral
201
+ * @param {string} literal_name The name of the literal to remove
202
+ * @returns {Jsep}
203
+ */
204
+ static removeLiteral(literal_name) {
205
+ delete _Jsep.literals[literal_name];
206
+ return _Jsep;
207
+ }
208
+ /**
209
+ * @method removeAllLiterals
210
+ * @returns {Jsep}
211
+ */
212
+ static removeAllLiterals() {
213
+ _Jsep.literals = {};
214
+ return _Jsep;
215
+ }
216
+ // ==================== END CONFIG ============================
217
+ /**
218
+ * @returns {string}
219
+ */
220
+ get char() {
221
+ return this.expr.charAt(this.index);
222
+ }
223
+ /**
224
+ * @returns {number}
225
+ */
226
+ get code() {
227
+ return this.expr.charCodeAt(this.index);
228
+ }
229
+ /**
230
+ * @param {string} expr a string with the passed in express
231
+ * @returns Jsep
232
+ */
233
+ constructor(expr) {
234
+ this.expr = expr;
235
+ this.index = 0;
236
+ }
237
+ /**
238
+ * static top-level parser
239
+ * @returns {jsep.Expression}
240
+ */
241
+ static parse(expr) {
242
+ return new _Jsep(expr).parse();
243
+ }
244
+ /**
245
+ * Get the longest key length of any object
246
+ * @param {object} obj
247
+ * @returns {number}
248
+ */
249
+ static getMaxKeyLen(obj) {
250
+ return Math.max(0, ...Object.keys(obj).map((k) => k.length));
251
+ }
252
+ /**
253
+ * `ch` is a character code in the next three functions
254
+ * @param {number} ch
255
+ * @returns {boolean}
256
+ */
257
+ static isDecimalDigit(ch) {
258
+ return ch >= 48 && ch <= 57;
259
+ }
260
+ /**
261
+ * Returns the precedence of a binary operator or `0` if it isn't a binary operator. Can be float.
262
+ * @param {string} op_val
263
+ * @returns {number}
264
+ */
265
+ static binaryPrecedence(op_val) {
266
+ return _Jsep.binary_ops[op_val] || 0;
267
+ }
268
+ /**
269
+ * Looks for start of identifier
270
+ * @param {number} ch
271
+ * @returns {boolean}
272
+ */
273
+ static isIdentifierStart(ch) {
274
+ return ch >= 65 && ch <= 90 || // A...Z
275
+ ch >= 97 && ch <= 122 || // a...z
276
+ ch >= 128 && !_Jsep.binary_ops[String.fromCharCode(ch)] || // any non-ASCII that is not an operator
277
+ _Jsep.additional_identifier_chars.has(String.fromCharCode(ch));
278
+ }
279
+ /**
280
+ * @param {number} ch
281
+ * @returns {boolean}
282
+ */
283
+ static isIdentifierPart(ch) {
284
+ return _Jsep.isIdentifierStart(ch) || _Jsep.isDecimalDigit(ch);
285
+ }
286
+ /**
287
+ * throw error at index of the expression
288
+ * @param {string} message
289
+ * @throws
290
+ */
291
+ throwError(message) {
292
+ const error = new Error(message + " at character " + this.index);
293
+ error.index = this.index;
294
+ error.description = message;
295
+ throw error;
296
+ }
297
+ /**
298
+ * Run a given hook
299
+ * @param {string} name
300
+ * @param {jsep.Expression|false} [node]
301
+ * @returns {?jsep.Expression}
302
+ */
303
+ runHook(name, node) {
304
+ if (_Jsep.hooks[name]) {
305
+ const env = { context: this, node };
306
+ _Jsep.hooks.run(name, env);
307
+ return env.node;
308
+ }
309
+ return node;
310
+ }
311
+ /**
312
+ * Runs a given hook until one returns a node
313
+ * @param {string} name
314
+ * @returns {?jsep.Expression}
315
+ */
316
+ searchHook(name) {
317
+ if (_Jsep.hooks[name]) {
318
+ const env = { context: this };
319
+ _Jsep.hooks[name].find(function(callback) {
320
+ callback.call(env.context, env);
321
+ return env.node;
322
+ });
323
+ return env.node;
324
+ }
325
+ }
326
+ /**
327
+ * Push `index` up to the next non-space character
328
+ */
329
+ gobbleSpaces() {
330
+ let ch = this.code;
331
+ while (ch === _Jsep.SPACE_CODE || ch === _Jsep.TAB_CODE || ch === _Jsep.LF_CODE || ch === _Jsep.CR_CODE) {
332
+ ch = this.expr.charCodeAt(++this.index);
333
+ }
334
+ this.runHook("gobble-spaces");
335
+ }
336
+ /**
337
+ * Top-level method to parse all expressions and returns compound or single node
338
+ * @returns {jsep.Expression}
339
+ */
340
+ parse() {
341
+ this.runHook("before-all");
342
+ const nodes = this.gobbleExpressions();
343
+ const node = nodes.length === 1 ? nodes[0] : {
344
+ type: _Jsep.COMPOUND,
345
+ body: nodes
346
+ };
347
+ return this.runHook("after-all", node);
348
+ }
349
+ /**
350
+ * top-level parser (but can be reused within as well)
351
+ * @param {number} [untilICode]
352
+ * @returns {jsep.Expression[]}
353
+ */
354
+ gobbleExpressions(untilICode) {
355
+ let nodes = [], ch_i, node;
356
+ while (this.index < this.expr.length) {
357
+ ch_i = this.code;
358
+ if (ch_i === _Jsep.SEMCOL_CODE || ch_i === _Jsep.COMMA_CODE) {
359
+ this.index++;
360
+ } else {
361
+ if (node = this.gobbleExpression()) {
362
+ nodes.push(node);
363
+ } else if (this.index < this.expr.length) {
364
+ if (ch_i === untilICode) {
365
+ break;
366
+ }
367
+ this.throwError('Unexpected "' + this.char + '"');
368
+ }
369
+ }
370
+ }
371
+ return nodes;
372
+ }
373
+ /**
374
+ * The main parsing function.
375
+ * @returns {?jsep.Expression}
376
+ */
377
+ gobbleExpression() {
378
+ const node = this.searchHook("gobble-expression") || this.gobbleBinaryExpression();
379
+ this.gobbleSpaces();
380
+ return this.runHook("after-expression", node);
381
+ }
382
+ /**
383
+ * Search for the operation portion of the string (e.g. `+`, `===`)
384
+ * Start by taking the longest possible binary operations (3 characters: `===`, `!==`, `>>>`)
385
+ * and move down from 3 to 2 to 1 character until a matching binary operation is found
386
+ * then, return that binary operation
387
+ * @returns {string|boolean}
388
+ */
389
+ gobbleBinaryOp() {
390
+ this.gobbleSpaces();
391
+ let to_check = this.expr.substr(this.index, _Jsep.max_binop_len);
392
+ let tc_len = to_check.length;
393
+ while (tc_len > 0) {
394
+ if (_Jsep.binary_ops.hasOwnProperty(to_check) && (!_Jsep.isIdentifierStart(this.code) || this.index + to_check.length < this.expr.length && !_Jsep.isIdentifierPart(this.expr.charCodeAt(this.index + to_check.length)))) {
395
+ this.index += tc_len;
396
+ return to_check;
397
+ }
398
+ to_check = to_check.substr(0, --tc_len);
399
+ }
400
+ return false;
401
+ }
402
+ /**
403
+ * This function is responsible for gobbling an individual expression,
404
+ * e.g. `1`, `1+2`, `a+(b*2)-Math.sqrt(2)`
405
+ * @returns {?jsep.BinaryExpression}
406
+ */
407
+ gobbleBinaryExpression() {
408
+ let node, biop, prec, stack, biop_info, left, right, i, cur_biop;
409
+ left = this.gobbleToken();
410
+ if (!left) {
411
+ return left;
412
+ }
413
+ biop = this.gobbleBinaryOp();
414
+ if (!biop) {
415
+ return left;
416
+ }
417
+ biop_info = { value: biop, prec: _Jsep.binaryPrecedence(biop), right_a: _Jsep.right_associative.has(biop) };
418
+ right = this.gobbleToken();
419
+ if (!right) {
420
+ this.throwError("Expected expression after " + biop);
421
+ }
422
+ stack = [left, biop_info, right];
423
+ while (biop = this.gobbleBinaryOp()) {
424
+ prec = _Jsep.binaryPrecedence(biop);
425
+ if (prec === 0) {
426
+ this.index -= biop.length;
427
+ break;
428
+ }
429
+ biop_info = { value: biop, prec, right_a: _Jsep.right_associative.has(biop) };
430
+ cur_biop = biop;
431
+ const comparePrev = (prev) => biop_info.right_a && prev.right_a ? prec > prev.prec : prec <= prev.prec;
432
+ while (stack.length > 2 && comparePrev(stack[stack.length - 2])) {
433
+ right = stack.pop();
434
+ biop = stack.pop().value;
435
+ left = stack.pop();
436
+ node = {
437
+ type: _Jsep.BINARY_EXP,
438
+ operator: biop,
439
+ left,
440
+ right
441
+ };
442
+ stack.push(node);
443
+ }
444
+ node = this.gobbleToken();
445
+ if (!node) {
446
+ this.throwError("Expected expression after " + cur_biop);
447
+ }
448
+ stack.push(biop_info, node);
449
+ }
450
+ i = stack.length - 1;
451
+ node = stack[i];
452
+ while (i > 1) {
453
+ node = {
454
+ type: _Jsep.BINARY_EXP,
455
+ operator: stack[i - 1].value,
456
+ left: stack[i - 2],
457
+ right: node
458
+ };
459
+ i -= 2;
460
+ }
461
+ return node;
462
+ }
463
+ /**
464
+ * An individual part of a binary expression:
465
+ * e.g. `foo.bar(baz)`, `1`, `"abc"`, `(a % 2)` (because it's in parenthesis)
466
+ * @returns {boolean|jsep.Expression}
467
+ */
468
+ gobbleToken() {
469
+ let ch, to_check, tc_len, node;
470
+ this.gobbleSpaces();
471
+ node = this.searchHook("gobble-token");
472
+ if (node) {
473
+ return this.runHook("after-token", node);
474
+ }
475
+ ch = this.code;
476
+ if (_Jsep.isDecimalDigit(ch) || ch === _Jsep.PERIOD_CODE) {
477
+ return this.gobbleNumericLiteral();
478
+ }
479
+ if (ch === _Jsep.SQUOTE_CODE || ch === _Jsep.DQUOTE_CODE) {
480
+ node = this.gobbleStringLiteral();
481
+ } else if (ch === _Jsep.OBRACK_CODE) {
482
+ node = this.gobbleArray();
483
+ } else {
484
+ to_check = this.expr.substr(this.index, _Jsep.max_unop_len);
485
+ tc_len = to_check.length;
486
+ while (tc_len > 0) {
487
+ if (_Jsep.unary_ops.hasOwnProperty(to_check) && (!_Jsep.isIdentifierStart(this.code) || this.index + to_check.length < this.expr.length && !_Jsep.isIdentifierPart(this.expr.charCodeAt(this.index + to_check.length)))) {
488
+ this.index += tc_len;
489
+ const argument = this.gobbleToken();
490
+ if (!argument) {
491
+ this.throwError("missing unaryOp argument");
492
+ }
493
+ return this.runHook("after-token", {
494
+ type: _Jsep.UNARY_EXP,
495
+ operator: to_check,
496
+ argument,
497
+ prefix: true
498
+ });
499
+ }
500
+ to_check = to_check.substr(0, --tc_len);
501
+ }
502
+ if (_Jsep.isIdentifierStart(ch)) {
503
+ node = this.gobbleIdentifier();
504
+ if (_Jsep.literals.hasOwnProperty(node.name)) {
505
+ node = {
506
+ type: _Jsep.LITERAL,
507
+ value: _Jsep.literals[node.name],
508
+ raw: node.name
509
+ };
510
+ } else if (node.name === _Jsep.this_str) {
511
+ node = { type: _Jsep.THIS_EXP };
512
+ }
513
+ } else if (ch === _Jsep.OPAREN_CODE) {
514
+ node = this.gobbleGroup();
515
+ }
516
+ }
517
+ if (!node) {
518
+ return this.runHook("after-token", false);
519
+ }
520
+ node = this.gobbleTokenProperty(node);
521
+ return this.runHook("after-token", node);
522
+ }
523
+ /**
524
+ * Gobble properties of of identifiers/strings/arrays/groups.
525
+ * e.g. `foo`, `bar.baz`, `foo['bar'].baz`
526
+ * It also gobbles function calls:
527
+ * e.g. `Math.acos(obj.angle)`
528
+ * @param {jsep.Expression} node
529
+ * @returns {jsep.Expression}
530
+ */
531
+ gobbleTokenProperty(node) {
532
+ this.gobbleSpaces();
533
+ let ch = this.code;
534
+ while (ch === _Jsep.PERIOD_CODE || ch === _Jsep.OBRACK_CODE || ch === _Jsep.OPAREN_CODE || ch === _Jsep.QUMARK_CODE) {
535
+ let optional;
536
+ if (ch === _Jsep.QUMARK_CODE) {
537
+ if (this.expr.charCodeAt(this.index + 1) !== _Jsep.PERIOD_CODE) {
538
+ break;
539
+ }
540
+ optional = true;
541
+ this.index += 2;
542
+ this.gobbleSpaces();
543
+ ch = this.code;
544
+ }
545
+ this.index++;
546
+ if (ch === _Jsep.OBRACK_CODE) {
547
+ node = {
548
+ type: _Jsep.MEMBER_EXP,
549
+ computed: true,
550
+ object: node,
551
+ property: this.gobbleExpression()
552
+ };
553
+ if (!node.property) {
554
+ this.throwError('Unexpected "' + this.char + '"');
555
+ }
556
+ this.gobbleSpaces();
557
+ ch = this.code;
558
+ if (ch !== _Jsep.CBRACK_CODE) {
559
+ this.throwError("Unclosed [");
560
+ }
561
+ this.index++;
562
+ } else if (ch === _Jsep.OPAREN_CODE) {
563
+ node = {
564
+ type: _Jsep.CALL_EXP,
565
+ "arguments": this.gobbleArguments(_Jsep.CPAREN_CODE),
566
+ callee: node
567
+ };
568
+ } else if (ch === _Jsep.PERIOD_CODE || optional) {
569
+ if (optional) {
570
+ this.index--;
571
+ }
572
+ this.gobbleSpaces();
573
+ node = {
574
+ type: _Jsep.MEMBER_EXP,
575
+ computed: false,
576
+ object: node,
577
+ property: this.gobbleIdentifier()
578
+ };
579
+ }
580
+ if (optional) {
581
+ node.optional = true;
582
+ }
583
+ this.gobbleSpaces();
584
+ ch = this.code;
585
+ }
586
+ return node;
587
+ }
588
+ /**
589
+ * Parse simple numeric literals: `12`, `3.4`, `.5`. Do this by using a string to
590
+ * keep track of everything in the numeric literal and then calling `parseFloat` on that string
591
+ * @returns {jsep.Literal}
592
+ */
593
+ gobbleNumericLiteral() {
594
+ let number = "", ch, chCode;
595
+ while (_Jsep.isDecimalDigit(this.code)) {
596
+ number += this.expr.charAt(this.index++);
597
+ }
598
+ if (this.code === _Jsep.PERIOD_CODE) {
599
+ number += this.expr.charAt(this.index++);
600
+ while (_Jsep.isDecimalDigit(this.code)) {
601
+ number += this.expr.charAt(this.index++);
602
+ }
603
+ }
604
+ ch = this.char;
605
+ if (ch === "e" || ch === "E") {
606
+ number += this.expr.charAt(this.index++);
607
+ ch = this.char;
608
+ if (ch === "+" || ch === "-") {
609
+ number += this.expr.charAt(this.index++);
610
+ }
611
+ while (_Jsep.isDecimalDigit(this.code)) {
612
+ number += this.expr.charAt(this.index++);
613
+ }
614
+ if (!_Jsep.isDecimalDigit(this.expr.charCodeAt(this.index - 1))) {
615
+ this.throwError("Expected exponent (" + number + this.char + ")");
616
+ }
617
+ }
618
+ chCode = this.code;
619
+ if (_Jsep.isIdentifierStart(chCode)) {
620
+ this.throwError("Variable names cannot start with a number (" + number + this.char + ")");
621
+ } else if (chCode === _Jsep.PERIOD_CODE || number.length === 1 && number.charCodeAt(0) === _Jsep.PERIOD_CODE) {
622
+ this.throwError("Unexpected period");
623
+ }
624
+ return {
625
+ type: _Jsep.LITERAL,
626
+ value: parseFloat(number),
627
+ raw: number
628
+ };
629
+ }
630
+ /**
631
+ * Parses a string literal, staring with single or double quotes with basic support for escape codes
632
+ * e.g. `"hello world"`, `'this is\nJSEP'`
633
+ * @returns {jsep.Literal}
634
+ */
635
+ gobbleStringLiteral() {
636
+ let str = "";
637
+ const startIndex = this.index;
638
+ const quote = this.expr.charAt(this.index++);
639
+ let closed = false;
640
+ while (this.index < this.expr.length) {
641
+ let ch = this.expr.charAt(this.index++);
642
+ if (ch === quote) {
643
+ closed = true;
644
+ break;
645
+ } else if (ch === "\\") {
646
+ ch = this.expr.charAt(this.index++);
647
+ switch (ch) {
648
+ case "n":
649
+ str += "\n";
650
+ break;
651
+ case "r":
652
+ str += "\r";
653
+ break;
654
+ case "t":
655
+ str += " ";
656
+ break;
657
+ case "b":
658
+ str += "\b";
659
+ break;
660
+ case "f":
661
+ str += "\f";
662
+ break;
663
+ case "v":
664
+ str += "\v";
665
+ break;
666
+ default:
667
+ str += ch;
668
+ }
669
+ } else {
670
+ str += ch;
671
+ }
672
+ }
673
+ if (!closed) {
674
+ this.throwError('Unclosed quote after "' + str + '"');
675
+ }
676
+ return {
677
+ type: _Jsep.LITERAL,
678
+ value: str,
679
+ raw: this.expr.substring(startIndex, this.index)
680
+ };
681
+ }
682
+ /**
683
+ * Gobbles only identifiers
684
+ * e.g.: `foo`, `_value`, `$x1`
685
+ * Also, this function checks if that identifier is a literal:
686
+ * (e.g. `true`, `false`, `null`) or `this`
687
+ * @returns {jsep.Identifier}
688
+ */
689
+ gobbleIdentifier() {
690
+ let ch = this.code, start = this.index;
691
+ if (_Jsep.isIdentifierStart(ch)) {
692
+ this.index++;
693
+ } else {
694
+ this.throwError("Unexpected " + this.char);
695
+ }
696
+ while (this.index < this.expr.length) {
697
+ ch = this.code;
698
+ if (_Jsep.isIdentifierPart(ch)) {
699
+ this.index++;
700
+ } else {
701
+ break;
702
+ }
703
+ }
704
+ return {
705
+ type: _Jsep.IDENTIFIER,
706
+ name: this.expr.slice(start, this.index)
707
+ };
708
+ }
709
+ /**
710
+ * Gobbles a list of arguments within the context of a function call
711
+ * or array literal. This function also assumes that the opening character
712
+ * `(` or `[` has already been gobbled, and gobbles expressions and commas
713
+ * until the terminator character `)` or `]` is encountered.
714
+ * e.g. `foo(bar, baz)`, `my_func()`, or `[bar, baz]`
715
+ * @param {number} termination
716
+ * @returns {jsep.Expression[]}
717
+ */
718
+ gobbleArguments(termination) {
719
+ const args = [];
720
+ let closed = false;
721
+ let separator_count = 0;
722
+ while (this.index < this.expr.length) {
723
+ this.gobbleSpaces();
724
+ let ch_i = this.code;
725
+ if (ch_i === termination) {
726
+ closed = true;
727
+ this.index++;
728
+ if (termination === _Jsep.CPAREN_CODE && separator_count && separator_count >= args.length) {
729
+ this.throwError("Unexpected token " + String.fromCharCode(termination));
730
+ }
731
+ break;
732
+ } else if (ch_i === _Jsep.COMMA_CODE) {
733
+ this.index++;
734
+ separator_count++;
735
+ if (separator_count !== args.length) {
736
+ if (termination === _Jsep.CPAREN_CODE) {
737
+ this.throwError("Unexpected token ,");
738
+ } else if (termination === _Jsep.CBRACK_CODE) {
739
+ for (let arg = args.length; arg < separator_count; arg++) {
740
+ args.push(null);
741
+ }
742
+ }
743
+ }
744
+ } else if (args.length !== separator_count && separator_count !== 0) {
745
+ this.throwError("Expected comma");
746
+ } else {
747
+ const node = this.gobbleExpression();
748
+ if (!node || node.type === _Jsep.COMPOUND) {
749
+ this.throwError("Expected comma");
750
+ }
751
+ args.push(node);
752
+ }
753
+ }
754
+ if (!closed) {
755
+ this.throwError("Expected " + String.fromCharCode(termination));
756
+ }
757
+ return args;
758
+ }
759
+ /**
760
+ * Responsible for parsing a group of things within parentheses `()`
761
+ * that have no identifier in front (so not a function call)
762
+ * This function assumes that it needs to gobble the opening parenthesis
763
+ * and then tries to gobble everything within that parenthesis, assuming
764
+ * that the next thing it should see is the close parenthesis. If not,
765
+ * then the expression probably doesn't have a `)`
766
+ * @returns {boolean|jsep.Expression}
767
+ */
768
+ gobbleGroup() {
769
+ this.index++;
770
+ let nodes = this.gobbleExpressions(_Jsep.CPAREN_CODE);
771
+ if (this.code === _Jsep.CPAREN_CODE) {
772
+ this.index++;
773
+ if (nodes.length === 1) {
774
+ return nodes[0];
775
+ } else if (!nodes.length) {
776
+ return false;
777
+ } else {
778
+ return {
779
+ type: _Jsep.SEQUENCE_EXP,
780
+ expressions: nodes
781
+ };
782
+ }
783
+ } else {
784
+ this.throwError("Unclosed (");
785
+ }
786
+ }
787
+ /**
788
+ * Responsible for parsing Array literals `[1, 2, 3]`
789
+ * This function assumes that it needs to gobble the opening bracket
790
+ * and then tries to gobble the expressions as arguments.
791
+ * @returns {jsep.ArrayExpression}
792
+ */
793
+ gobbleArray() {
794
+ this.index++;
795
+ return {
796
+ type: _Jsep.ARRAY_EXP,
797
+ elements: this.gobbleArguments(_Jsep.CBRACK_CODE)
798
+ };
799
+ }
800
+ };
801
+ var hooks = new Hooks();
802
+ Object.assign(Jsep, {
803
+ hooks,
804
+ plugins: new Plugins(Jsep),
805
+ // Node Types
806
+ // ----------
807
+ // This is the full set of types that any JSEP node can be.
808
+ // Store them here to save space when minified
809
+ COMPOUND: "Compound",
810
+ SEQUENCE_EXP: "SequenceExpression",
811
+ IDENTIFIER: "Identifier",
812
+ MEMBER_EXP: "MemberExpression",
813
+ LITERAL: "Literal",
814
+ THIS_EXP: "ThisExpression",
815
+ CALL_EXP: "CallExpression",
816
+ UNARY_EXP: "UnaryExpression",
817
+ BINARY_EXP: "BinaryExpression",
818
+ ARRAY_EXP: "ArrayExpression",
819
+ TAB_CODE: 9,
820
+ LF_CODE: 10,
821
+ CR_CODE: 13,
822
+ SPACE_CODE: 32,
823
+ PERIOD_CODE: 46,
824
+ // '.'
825
+ COMMA_CODE: 44,
826
+ // ','
827
+ SQUOTE_CODE: 39,
828
+ // single quote
829
+ DQUOTE_CODE: 34,
830
+ // double quotes
831
+ OPAREN_CODE: 40,
832
+ // (
833
+ CPAREN_CODE: 41,
834
+ // )
835
+ OBRACK_CODE: 91,
836
+ // [
837
+ CBRACK_CODE: 93,
838
+ // ]
839
+ QUMARK_CODE: 63,
840
+ // ?
841
+ SEMCOL_CODE: 59,
842
+ // ;
843
+ COLON_CODE: 58,
844
+ // :
845
+ // Operations
846
+ // ----------
847
+ // Use a quickly-accessible map to store all of the unary operators
848
+ // Values are set to `1` (it really doesn't matter)
849
+ unary_ops: {
850
+ "-": 1,
851
+ "!": 1,
852
+ "~": 1,
853
+ "+": 1
854
+ },
855
+ // Also use a map for the binary operations but set their values to their
856
+ // binary precedence for quick reference (higher number = higher precedence)
857
+ // see [Order of operations](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence)
858
+ binary_ops: {
859
+ "||": 1,
860
+ "??": 1,
861
+ "&&": 2,
862
+ "|": 3,
863
+ "^": 4,
864
+ "&": 5,
865
+ "==": 6,
866
+ "!=": 6,
867
+ "===": 6,
868
+ "!==": 6,
869
+ "<": 7,
870
+ ">": 7,
871
+ "<=": 7,
872
+ ">=": 7,
873
+ "<<": 8,
874
+ ">>": 8,
875
+ ">>>": 8,
876
+ "+": 9,
877
+ "-": 9,
878
+ "*": 10,
879
+ "/": 10,
880
+ "%": 10,
881
+ "**": 11
882
+ },
883
+ // sets specific binary_ops as right-associative
884
+ right_associative: /* @__PURE__ */ new Set(["**"]),
885
+ // Additional valid identifier chars, apart from a-z, A-Z and 0-9 (except on the starting char)
886
+ additional_identifier_chars: /* @__PURE__ */ new Set(["$", "_"]),
887
+ // Literals
888
+ // ----------
889
+ // Store the values to return for the various literals we may encounter
890
+ literals: {
891
+ "true": true,
892
+ "false": false,
893
+ "null": null
894
+ },
895
+ // Except for `this`, which is special. This could be changed to something like `'self'` as well
896
+ this_str: "this"
897
+ });
898
+ Jsep.max_unop_len = Jsep.getMaxKeyLen(Jsep.unary_ops);
899
+ Jsep.max_binop_len = Jsep.getMaxKeyLen(Jsep.binary_ops);
900
+ var jsep = (expr) => new Jsep(expr).parse();
901
+ var stdClassProps = Object.getOwnPropertyNames(class Test {
902
+ });
903
+ Object.getOwnPropertyNames(Jsep).filter((prop) => !stdClassProps.includes(prop) && jsep[prop] === void 0).forEach((m) => {
904
+ jsep[m] = Jsep[m];
905
+ });
906
+ jsep.Jsep = Jsep;
907
+ var CONDITIONAL_EXP = "ConditionalExpression";
908
+ var ternary = {
909
+ name: "ternary",
910
+ init(jsep2) {
911
+ jsep2.hooks.add("after-expression", function gobbleTernary(env) {
912
+ if (env.node && this.code === jsep2.QUMARK_CODE) {
913
+ this.index++;
914
+ const test = env.node;
915
+ const consequent = this.gobbleExpression();
916
+ if (!consequent) {
917
+ this.throwError("Expected expression");
918
+ }
919
+ this.gobbleSpaces();
920
+ if (this.code === jsep2.COLON_CODE) {
921
+ this.index++;
922
+ const alternate = this.gobbleExpression();
923
+ if (!alternate) {
924
+ this.throwError("Expected expression");
925
+ }
926
+ env.node = {
927
+ type: CONDITIONAL_EXP,
928
+ test,
929
+ consequent,
930
+ alternate
931
+ };
932
+ if (test.operator && jsep2.binary_ops[test.operator] <= 0.9) {
933
+ let newTest = test;
934
+ while (newTest.right.operator && jsep2.binary_ops[newTest.right.operator] <= 0.9) {
935
+ newTest = newTest.right;
936
+ }
937
+ env.node.test = newTest.right;
938
+ newTest.right = env.node;
939
+ env.node = test;
940
+ }
941
+ } else {
942
+ this.throwError("Expected :");
943
+ }
944
+ }
945
+ });
946
+ }
947
+ };
948
+ jsep.plugins.register(ternary);
949
+ export default jsep as any;