@xuda.io/runtime-bundle 1.0.480 → 1.0.482

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.
@@ -1696,7 +1696,7 @@ func.datasource.create = async function (
1696
1696
  }
1697
1697
  }
1698
1698
 
1699
- var datasource_changes = {
1699
+ const datasource_changes = {
1700
1700
  [dsSessionP]: {
1701
1701
  ['datasource_main']: {
1702
1702
  stat: 'idle',
@@ -8095,7 +8095,7 @@ func.expression.get = async function (SESSION_ID, valP, dsSessionP, sourceP, row
8095
8095
  return new_class.get();
8096
8096
  };
8097
8097
 
8098
- func.expression.parse = function (strP) {
8098
+ func.expression.parse_org = function (strP) {
8099
8099
  var extract_str = function (strP, posP) {
8100
8100
  if (!posP) posP = 0;
8101
8101
  var clean_split_str = function (arrP) {
@@ -8190,6 +8190,119 @@ func.expression.parse = function (strP) {
8190
8190
  return res;
8191
8191
  };
8192
8192
 
8193
+ func.expression.parse_bad = function (strP) {
8194
+ const nonLettersPatt = /\W/;
8195
+ const validSymbolsNoArray = /[^.@\[]/;
8196
+ const validSymbolsWithArray = /[^.@"'\[\]]/;
8197
+
8198
+ function extractStr(str, startPos = 0) {
8199
+ const cleanSplit = (arr) => (arr?.length > 1 && arr[0] === '' && arr[1].includes('@') ? arr.slice(1) : arr);
8200
+
8201
+ const segments = cleanSplit(str.replace(/@/g, '^^@').split('^^'));
8202
+ const result = [];
8203
+
8204
+ for (const val of segments || []) {
8205
+ if (!val) continue;
8206
+ const pos = str.indexOf(val) + startPos;
8207
+
8208
+ if (val.startsWith('@')) {
8209
+ let tmpStr = '';
8210
+ let wordStart = null;
8211
+ let wordEnd = null;
8212
+ let validSymbols = validSymbolsNoArray;
8213
+
8214
+ for (let i = 0; i < val.length; i++) {
8215
+ const char = val[i];
8216
+
8217
+ if (char === '[') validSymbols = validSymbolsWithArray;
8218
+ if (char === '.' && wordStart === null) wordStart = i;
8219
+ else if (wordStart !== null && nonLettersPatt.test(char)) wordEnd = i;
8220
+
8221
+ if (wordStart !== null && wordEnd !== null) {
8222
+ const word = val.slice(wordStart + 1, wordEnd);
8223
+ tmpStr = tmpStr.slice(0, wordStart) + '^^' + tmpStr.slice(wordStart, wordEnd);
8224
+ wordStart = char === '.' ? wordEnd : null;
8225
+ wordEnd = null;
8226
+ }
8227
+
8228
+ tmpStr += nonLettersPatt.test(char) && validSymbols.test(char) && !tmpStr.includes('^^') ? '^^' + char : char;
8229
+ }
8230
+
8231
+ if (tmpStr.includes('^^')) {
8232
+ result.push(...extractStr(tmpStr, pos));
8233
+ } else {
8234
+ const fieldIdMatch = val.match(/^@([^.\[]+)/);
8235
+ result.push({
8236
+ value: val,
8237
+ fieldId: fieldIdMatch ? fieldIdMatch[1] : undefined,
8238
+ pos,
8239
+ });
8240
+ }
8241
+ } else {
8242
+ result.push({ value: val, pos });
8243
+ }
8244
+ }
8245
+ return result;
8246
+ }
8247
+
8248
+ return extractStr(strP);
8249
+ };
8250
+
8251
+ func.expression.parse = function (input) {
8252
+ if (typeof input !== 'string') return [];
8253
+
8254
+ const segments = [];
8255
+ let pos = 0;
8256
+
8257
+ const parts = input.split(/(@)/).filter(Boolean);
8258
+
8259
+ for (let i = 0; i < parts.length; i++) {
8260
+ const part = parts[i];
8261
+
8262
+ if (part === '@' && i + 1 < parts.length) {
8263
+ const nextPart = parts[i + 1];
8264
+ const varEnd = nextPart.search(/[.\[]/); // Split at first . or [
8265
+ let fieldId, remainder;
8266
+
8267
+ if (varEnd > 0) {
8268
+ fieldId = nextPart.slice(0, varEnd);
8269
+ remainder = nextPart.slice(varEnd);
8270
+ } else {
8271
+ fieldId = nextPart;
8272
+ remainder = '';
8273
+ }
8274
+
8275
+ // Add @variable segment
8276
+ const fullVarValue = `@${fieldId}`;
8277
+ segments.push({
8278
+ value: fullVarValue,
8279
+ fieldId,
8280
+ pos,
8281
+ });
8282
+ pos += fullVarValue.length;
8283
+
8284
+ // Add remainder as a separate segment, if any
8285
+ if (remainder) {
8286
+ segments.push({
8287
+ value: remainder,
8288
+ pos,
8289
+ });
8290
+ pos += remainder.length;
8291
+ }
8292
+
8293
+ i++; // Skip the next part since we consumed it
8294
+ } else if (part !== '@') {
8295
+ segments.push({
8296
+ value: part,
8297
+ pos,
8298
+ });
8299
+ pos += part.length;
8300
+ }
8301
+ }
8302
+
8303
+ return segments;
8304
+ };
8305
+
8193
8306
  func.expression.get_property = async function (valP) {
8194
8307
  async function secure_eval(val) {
8195
8308
  if (typeof IS_PROCESS_SERVER === 'undefined') {
@@ -1696,7 +1696,7 @@ func.datasource.create = async function (
1696
1696
  }
1697
1697
  }
1698
1698
 
1699
- var datasource_changes = {
1699
+ const datasource_changes = {
1700
1700
  [dsSessionP]: {
1701
1701
  ['datasource_main']: {
1702
1702
  stat: 'idle',
@@ -8095,7 +8095,7 @@ func.expression.get = async function (SESSION_ID, valP, dsSessionP, sourceP, row
8095
8095
  return new_class.get();
8096
8096
  };
8097
8097
 
8098
- func.expression.parse = function (strP) {
8098
+ func.expression.parse_org = function (strP) {
8099
8099
  var extract_str = function (strP, posP) {
8100
8100
  if (!posP) posP = 0;
8101
8101
  var clean_split_str = function (arrP) {
@@ -8190,6 +8190,119 @@ func.expression.parse = function (strP) {
8190
8190
  return res;
8191
8191
  };
8192
8192
 
8193
+ func.expression.parse_bad = function (strP) {
8194
+ const nonLettersPatt = /\W/;
8195
+ const validSymbolsNoArray = /[^.@\[]/;
8196
+ const validSymbolsWithArray = /[^.@"'\[\]]/;
8197
+
8198
+ function extractStr(str, startPos = 0) {
8199
+ const cleanSplit = (arr) => (arr?.length > 1 && arr[0] === '' && arr[1].includes('@') ? arr.slice(1) : arr);
8200
+
8201
+ const segments = cleanSplit(str.replace(/@/g, '^^@').split('^^'));
8202
+ const result = [];
8203
+
8204
+ for (const val of segments || []) {
8205
+ if (!val) continue;
8206
+ const pos = str.indexOf(val) + startPos;
8207
+
8208
+ if (val.startsWith('@')) {
8209
+ let tmpStr = '';
8210
+ let wordStart = null;
8211
+ let wordEnd = null;
8212
+ let validSymbols = validSymbolsNoArray;
8213
+
8214
+ for (let i = 0; i < val.length; i++) {
8215
+ const char = val[i];
8216
+
8217
+ if (char === '[') validSymbols = validSymbolsWithArray;
8218
+ if (char === '.' && wordStart === null) wordStart = i;
8219
+ else if (wordStart !== null && nonLettersPatt.test(char)) wordEnd = i;
8220
+
8221
+ if (wordStart !== null && wordEnd !== null) {
8222
+ const word = val.slice(wordStart + 1, wordEnd);
8223
+ tmpStr = tmpStr.slice(0, wordStart) + '^^' + tmpStr.slice(wordStart, wordEnd);
8224
+ wordStart = char === '.' ? wordEnd : null;
8225
+ wordEnd = null;
8226
+ }
8227
+
8228
+ tmpStr += nonLettersPatt.test(char) && validSymbols.test(char) && !tmpStr.includes('^^') ? '^^' + char : char;
8229
+ }
8230
+
8231
+ if (tmpStr.includes('^^')) {
8232
+ result.push(...extractStr(tmpStr, pos));
8233
+ } else {
8234
+ const fieldIdMatch = val.match(/^@([^.\[]+)/);
8235
+ result.push({
8236
+ value: val,
8237
+ fieldId: fieldIdMatch ? fieldIdMatch[1] : undefined,
8238
+ pos,
8239
+ });
8240
+ }
8241
+ } else {
8242
+ result.push({ value: val, pos });
8243
+ }
8244
+ }
8245
+ return result;
8246
+ }
8247
+
8248
+ return extractStr(strP);
8249
+ };
8250
+
8251
+ func.expression.parse = function (input) {
8252
+ if (typeof input !== 'string') return [];
8253
+
8254
+ const segments = [];
8255
+ let pos = 0;
8256
+
8257
+ const parts = input.split(/(@)/).filter(Boolean);
8258
+
8259
+ for (let i = 0; i < parts.length; i++) {
8260
+ const part = parts[i];
8261
+
8262
+ if (part === '@' && i + 1 < parts.length) {
8263
+ const nextPart = parts[i + 1];
8264
+ const varEnd = nextPart.search(/[.\[]/); // Split at first . or [
8265
+ let fieldId, remainder;
8266
+
8267
+ if (varEnd > 0) {
8268
+ fieldId = nextPart.slice(0, varEnd);
8269
+ remainder = nextPart.slice(varEnd);
8270
+ } else {
8271
+ fieldId = nextPart;
8272
+ remainder = '';
8273
+ }
8274
+
8275
+ // Add @variable segment
8276
+ const fullVarValue = `@${fieldId}`;
8277
+ segments.push({
8278
+ value: fullVarValue,
8279
+ fieldId,
8280
+ pos,
8281
+ });
8282
+ pos += fullVarValue.length;
8283
+
8284
+ // Add remainder as a separate segment, if any
8285
+ if (remainder) {
8286
+ segments.push({
8287
+ value: remainder,
8288
+ pos,
8289
+ });
8290
+ pos += remainder.length;
8291
+ }
8292
+
8293
+ i++; // Skip the next part since we consumed it
8294
+ } else if (part !== '@') {
8295
+ segments.push({
8296
+ value: part,
8297
+ pos,
8298
+ });
8299
+ pos += part.length;
8300
+ }
8301
+ }
8302
+
8303
+ return segments;
8304
+ };
8305
+
8193
8306
  func.expression.get_property = async function (valP) {
8194
8307
  async function secure_eval(val) {
8195
8308
  if (typeof IS_PROCESS_SERVER === 'undefined') {