amis-formula 1.3.3 → 1.3.4

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 (2) hide show
  1. package/dist/index.js +17 -63
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-formula v1.3.3
2
+ * amis-formula v1.3.4
3
3
  * Copyright 2021 fex
4
4
  */
5
5
 
@@ -1654,13 +1654,11 @@ var rawStates = {
1654
1654
  };
1655
1655
  var numberStates = {
1656
1656
  START: 0,
1657
- MINUS: 1,
1658
- ZERO: 2,
1659
- DIGIT: 3,
1660
- POINT: 4,
1661
- DIGIT_FRACTION: 5,
1662
- EXP: 6,
1663
- EXP_DIGIT_OR_SIGN: 7
1657
+ ZERO: 1,
1658
+ DIGIT: 2,
1659
+ POINT: 3,
1660
+ DIGIT_FRACTION: 4,
1661
+ EXP: 5
1664
1662
  };
1665
1663
  var stringStates = {
1666
1664
  START: 0,
@@ -2134,23 +2132,6 @@ function lexer(input, options) {
2134
2132
  var char_1 = input.charAt(i);
2135
2133
  switch (state) {
2136
2134
  case numberStates.START: {
2137
- if (char_1 === '-') {
2138
- state = numberStates.MINUS;
2139
- }
2140
- else if (char_1 === '0') {
2141
- passedValueIndex = i + 1;
2142
- state = numberStates.ZERO;
2143
- }
2144
- else if (isDigit1to9(char_1)) {
2145
- passedValueIndex = i + 1;
2146
- state = numberStates.DIGIT;
2147
- }
2148
- else {
2149
- return null;
2150
- }
2151
- break;
2152
- }
2153
- case numberStates.MINUS: {
2154
2135
  if (char_1 === '0') {
2155
2136
  passedValueIndex = i + 1;
2156
2137
  state = numberStates.ZERO;
@@ -2213,28 +2194,6 @@ function lexer(input, options) {
2213
2194
  }
2214
2195
  break;
2215
2196
  }
2216
- case numberStates.EXP: {
2217
- if (char_1 === '+' || char_1 === '-') {
2218
- state = numberStates.EXP_DIGIT_OR_SIGN;
2219
- }
2220
- else if (isDigit(char_1)) {
2221
- passedValueIndex = i + 1;
2222
- state = numberStates.EXP_DIGIT_OR_SIGN;
2223
- }
2224
- else {
2225
- break iterator;
2226
- }
2227
- break;
2228
- }
2229
- case numberStates.EXP_DIGIT_OR_SIGN: {
2230
- if (isDigit(char_1)) {
2231
- passedValueIndex = i + 1;
2232
- }
2233
- else {
2234
- break iterator;
2235
- }
2236
- break;
2237
- }
2238
2197
  }
2239
2198
  i++;
2240
2199
  }
@@ -2301,25 +2260,20 @@ function lexer(input, options) {
2301
2260
  return null;
2302
2261
  }
2303
2262
  function identifier() {
2304
- var i = index;
2305
- var chunk = '';
2306
- while (i < input.length) {
2307
- var ch = input[i];
2308
- if (/^[\u4e00-\u9fa5A-Za-z_$@][\u4e00-\u9fa5A-Za-z0-9_\-]*$/.test(chunk + ch)) {
2309
- chunk += ch;
2310
- i++;
2311
- }
2312
- else {
2313
- break;
2314
- }
2315
- }
2316
- if (i > index) {
2317
- var value = input.substring(index, i);
2263
+ // 变量模式是 resolveVariable 的时候使用的
2264
+ // 这个纯变量获取模式,不支持其他什么表达式
2265
+ // 仅仅支持 xxx.xxx 或者 xxx[ exression ] 这类语法
2266
+ var reg = (options === null || options === void 0 ? void 0 : options.variableMode)
2267
+ ? /^[\u4e00-\u9fa5A-Za-z0-9_$@][\u4e00-\u9fa5A-Za-z0-9_\-]*/
2268
+ : /^(?:[\u4e00-\u9fa5A-Za-z_$@][\u4e00-\u9fa5A-Za-z0-9_\-]*|\d+[\u4e00-\u9fa5A-Za-z_][\u4e00-\u9fa5A-Za-z0-9_\-]*)/;
2269
+ var match = reg.exec(input.substring(index, index + 256) // 变量长度不能超过 256
2270
+ );
2271
+ if (match) {
2318
2272
  return {
2319
2273
  type: TokenName[TokenEnum.Identifier],
2320
- value: value,
2274
+ value: match[0],
2321
2275
  start: position(),
2322
- end: position(value)
2276
+ end: position(match[0])
2323
2277
  };
2324
2278
  }
2325
2279
  return null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "amis-formula",
3
- "version": "1.3.3",
3
+ "version": "1.3.4",
4
4
  "description": "负责 amis 里面的表达式实现,内置公式,编辑器等",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {