@flowlist/js-core 4.0.7-beta.0 → 4.0.8-beta.0

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.
package/dist/index.d.mts CHANGED
@@ -191,6 +191,38 @@ declare const initData: <P extends RequestParams, R>({ getter, setter, func, que
191
191
  declare const loadMore: <P extends RequestParams, R>({ getter, setter, query, func, errorRetry, callback }: LoadMoreType<P, R>) => Promise<void>;
192
192
  declare const updateState: <P extends RequestParams, R>({ getter, setter, func, query, method, id, value, changeKey }: UpdateStateType<P, R>) => Promise<unknown>;
193
193
 
194
+ declare const _default: {
195
+ readonly SETTER_TYPE: {
196
+ readonly RESET: 0;
197
+ readonly MERGE: 1;
198
+ };
199
+ readonly FETCH_TYPE_ARRAY: readonly ["jump", "sinceId", "page", "seenIds", "auto"];
200
+ readonly FETCH_TYPE: {
201
+ readonly PAGINATION: "jump";
202
+ readonly SINCE_FIRST_OR_END_ID: "sinceId";
203
+ readonly SCROLL_LOAD_MORE: "page";
204
+ readonly HAS_LOADED_IDS: "seenIds";
205
+ readonly AUTO: "auto";
206
+ };
207
+ readonly CHANGE_TYPE: {
208
+ readonly SEARCH_FIELD: "search";
209
+ readonly RESET_FIELD: "reset";
210
+ readonly RESULT_UPDATE_KV: "update";
211
+ readonly RESULT_ADD_AFTER: "push";
212
+ readonly RESULT_ADD_BEFORE: "unshift";
213
+ readonly RESULT_REMOVE_BY_ID: "delete";
214
+ readonly RESULT_INSERT_TO_BEFORE: "insert-before";
215
+ readonly RESULT_INSERT_TO_AFTER: "insert-after";
216
+ readonly RESULT_LIST_MERGE: "patch";
217
+ readonly RESULT_ITEM_MERGE: "merge";
218
+ };
219
+ readonly FIELD_DATA: {
220
+ readonly RESULT_KEY: "result";
221
+ readonly EXTRA_KEY: "extra";
222
+ };
223
+ readonly DEFAULT_UNIQUE_KEY_NAME: "id";
224
+ };
225
+
194
226
  declare const isArray: (data: unknown) => data is any[];
195
227
  /**
196
228
  * 检查是否为对象结果
@@ -206,10 +238,12 @@ declare const isObjectKey: (value: unknown) => value is ObjectKey;
206
238
  declare const isKeyMap: (value: unknown) => value is KeyMap;
207
239
  /**
208
240
  * 检查是否为 KeyMap 数组
241
+ * 性能优化:使用 for 循环替代 every,提前退出
209
242
  */
210
243
  declare const isKeyMapArray: (value: unknown) => value is KeyMap[];
211
244
  /**
212
245
  * 检查是否为 ObjectKey 数组
246
+ * 性能优化:使用 for 循环替代 every,提前退出
213
247
  */
214
248
  declare const isObjectKeyArray: (value: unknown) => value is ObjectKey[];
215
249
  declare const stableSerialize: (value: unknown) => string;
@@ -222,8 +256,29 @@ declare const generateFieldName: <P extends RequestParams, R>({ func, query }: {
222
256
  declare const getObjectDeepValue: (field: unknown, keys: string | string[]) => unknown;
223
257
  declare const updateObjectDeepValue: (field: KeyMap, changeKey: string, value: unknown) => void;
224
258
  declare const searchValueByKey: (result: any[] | Record<string, any>, id: ObjectKey, key: string) => unknown;
259
+ /**
260
+ * 查找匹配项的索引
261
+ * 性能优化:
262
+ * 1. 提前字符串化避免重复转换
263
+ * 2. 优化简单 key 的访问路径(无需 split)
264
+ * 3. 减少函数调用开销
265
+ */
225
266
  declare const computeMatchedItemIndex: (itemId: ObjectKey, fieldArr: any[], changingKey: string) => number;
267
+ /**
268
+ * 合并数组数据
269
+ * 性能优化:
270
+ * 1. 使用 Map 进行 O(1) 查找
271
+ * 2. 创建新对象确保响应式
272
+ * 3. 缓存 changingKey 的解析结果
273
+ */
226
274
  declare const combineArrayData: (fieldArray: any[], value: any[] | Record<ObjectKey, KeyMap>, changingKey: string) => void;
275
+ /**
276
+ * 设置响应式字段
277
+ * 性能优化:
278
+ * 1. 快速路径优化常见场景
279
+ * 2. 减少条件判断
280
+ * 3. 使用原生方法 concat 而非展开运算符(在大数组时性能更好)
281
+ */
227
282
  declare const setReactivityField: (field: DefaultField, key: FieldKeys, value: unknown, type: FetchType, insertBefore: boolean) => void;
228
283
  declare const computeResultLength: (data: unknown) => number;
229
284
  declare const generateRequestParams: ({ field, uniqueKey, query, is_up, type }: GenerateParamsType) => GenerateParamsResp;
@@ -256,36 +311,4 @@ declare namespace utils {
256
311
  export { utils_combineArrayData as combineArrayData, utils_computeMatchedItemIndex as computeMatchedItemIndex, utils_computeResultLength as computeResultLength, utils_generateDefaultField as generateDefaultField, utils_generateFieldName as generateFieldName, utils_generateRequestParams as generateRequestParams, utils_getObjectDeepValue as getObjectDeepValue, utils_getResultAsArray as getResultAsArray, utils_isArray as isArray, utils_isKeyMap as isKeyMap, utils_isKeyMapArray as isKeyMapArray, utils_isObjectKey as isObjectKey, utils_isObjectKeyArray as isObjectKeyArray, utils_isObjectResult as isObjectResult, utils_isResultObject as isResultObject, utils_searchValueByKey as searchValueByKey, utils_setReactivityField as setReactivityField, utils_stableSerialize as stableSerialize, utils_toObjectKey as toObjectKey, utils_updateArrayItem as updateArrayItem, utils_updateObjectDeepValue as updateObjectDeepValue };
257
312
  }
258
313
 
259
- declare const _default: {
260
- readonly SETTER_TYPE: {
261
- readonly RESET: 0;
262
- readonly MERGE: 1;
263
- };
264
- readonly FETCH_TYPE_ARRAY: readonly ["jump", "sinceId", "page", "seenIds", "auto"];
265
- readonly FETCH_TYPE: {
266
- readonly PAGINATION: "jump";
267
- readonly SINCE_FIRST_OR_END_ID: "sinceId";
268
- readonly SCROLL_LOAD_MORE: "page";
269
- readonly HAS_LOADED_IDS: "seenIds";
270
- readonly AUTO: "auto";
271
- };
272
- readonly CHANGE_TYPE: {
273
- readonly SEARCH_FIELD: "search";
274
- readonly RESET_FIELD: "reset";
275
- readonly RESULT_UPDATE_KV: "update";
276
- readonly RESULT_ADD_AFTER: "push";
277
- readonly RESULT_ADD_BEFORE: "unshift";
278
- readonly RESULT_REMOVE_BY_ID: "delete";
279
- readonly RESULT_INSERT_TO_BEFORE: "insert-before";
280
- readonly RESULT_INSERT_TO_AFTER: "insert-after";
281
- readonly RESULT_LIST_MERGE: "patch";
282
- readonly RESULT_ITEM_MERGE: "merge";
283
- };
284
- readonly FIELD_DATA: {
285
- readonly RESULT_KEY: "result";
286
- readonly EXTRA_KEY: "extra";
287
- };
288
- readonly DEFAULT_UNIQUE_KEY_NAME: "id";
289
- };
290
-
291
314
  export { type ApiContract, type BaseApiResponse, type DefaultField, _default as ENUM, type FetchResultCallback, type FetchType, type FieldGetter, type FieldKeys, type FieldSetter, type GenerateParamsResp, type GenerateParamsType, type InitDataParams, type InitDataType, type InitStateParams, type InitStateType, type KeyMap, type LoadMoreParams, type LoadMoreType, type ObjectKey, type RequestParams, type SetDataType, type SetErrorType, type SetterFuncParams, type UpdateStateParams, type UpdateStateType, createApi, generateFieldName$1 as generateFieldName, initData, initState, loadMore, updateState, utils };
package/dist/index.d.ts CHANGED
@@ -191,6 +191,38 @@ declare const initData: <P extends RequestParams, R>({ getter, setter, func, que
191
191
  declare const loadMore: <P extends RequestParams, R>({ getter, setter, query, func, errorRetry, callback }: LoadMoreType<P, R>) => Promise<void>;
192
192
  declare const updateState: <P extends RequestParams, R>({ getter, setter, func, query, method, id, value, changeKey }: UpdateStateType<P, R>) => Promise<unknown>;
193
193
 
194
+ declare const _default: {
195
+ readonly SETTER_TYPE: {
196
+ readonly RESET: 0;
197
+ readonly MERGE: 1;
198
+ };
199
+ readonly FETCH_TYPE_ARRAY: readonly ["jump", "sinceId", "page", "seenIds", "auto"];
200
+ readonly FETCH_TYPE: {
201
+ readonly PAGINATION: "jump";
202
+ readonly SINCE_FIRST_OR_END_ID: "sinceId";
203
+ readonly SCROLL_LOAD_MORE: "page";
204
+ readonly HAS_LOADED_IDS: "seenIds";
205
+ readonly AUTO: "auto";
206
+ };
207
+ readonly CHANGE_TYPE: {
208
+ readonly SEARCH_FIELD: "search";
209
+ readonly RESET_FIELD: "reset";
210
+ readonly RESULT_UPDATE_KV: "update";
211
+ readonly RESULT_ADD_AFTER: "push";
212
+ readonly RESULT_ADD_BEFORE: "unshift";
213
+ readonly RESULT_REMOVE_BY_ID: "delete";
214
+ readonly RESULT_INSERT_TO_BEFORE: "insert-before";
215
+ readonly RESULT_INSERT_TO_AFTER: "insert-after";
216
+ readonly RESULT_LIST_MERGE: "patch";
217
+ readonly RESULT_ITEM_MERGE: "merge";
218
+ };
219
+ readonly FIELD_DATA: {
220
+ readonly RESULT_KEY: "result";
221
+ readonly EXTRA_KEY: "extra";
222
+ };
223
+ readonly DEFAULT_UNIQUE_KEY_NAME: "id";
224
+ };
225
+
194
226
  declare const isArray: (data: unknown) => data is any[];
195
227
  /**
196
228
  * 检查是否为对象结果
@@ -206,10 +238,12 @@ declare const isObjectKey: (value: unknown) => value is ObjectKey;
206
238
  declare const isKeyMap: (value: unknown) => value is KeyMap;
207
239
  /**
208
240
  * 检查是否为 KeyMap 数组
241
+ * 性能优化:使用 for 循环替代 every,提前退出
209
242
  */
210
243
  declare const isKeyMapArray: (value: unknown) => value is KeyMap[];
211
244
  /**
212
245
  * 检查是否为 ObjectKey 数组
246
+ * 性能优化:使用 for 循环替代 every,提前退出
213
247
  */
214
248
  declare const isObjectKeyArray: (value: unknown) => value is ObjectKey[];
215
249
  declare const stableSerialize: (value: unknown) => string;
@@ -222,8 +256,29 @@ declare const generateFieldName: <P extends RequestParams, R>({ func, query }: {
222
256
  declare const getObjectDeepValue: (field: unknown, keys: string | string[]) => unknown;
223
257
  declare const updateObjectDeepValue: (field: KeyMap, changeKey: string, value: unknown) => void;
224
258
  declare const searchValueByKey: (result: any[] | Record<string, any>, id: ObjectKey, key: string) => unknown;
259
+ /**
260
+ * 查找匹配项的索引
261
+ * 性能优化:
262
+ * 1. 提前字符串化避免重复转换
263
+ * 2. 优化简单 key 的访问路径(无需 split)
264
+ * 3. 减少函数调用开销
265
+ */
225
266
  declare const computeMatchedItemIndex: (itemId: ObjectKey, fieldArr: any[], changingKey: string) => number;
267
+ /**
268
+ * 合并数组数据
269
+ * 性能优化:
270
+ * 1. 使用 Map 进行 O(1) 查找
271
+ * 2. 创建新对象确保响应式
272
+ * 3. 缓存 changingKey 的解析结果
273
+ */
226
274
  declare const combineArrayData: (fieldArray: any[], value: any[] | Record<ObjectKey, KeyMap>, changingKey: string) => void;
275
+ /**
276
+ * 设置响应式字段
277
+ * 性能优化:
278
+ * 1. 快速路径优化常见场景
279
+ * 2. 减少条件判断
280
+ * 3. 使用原生方法 concat 而非展开运算符(在大数组时性能更好)
281
+ */
227
282
  declare const setReactivityField: (field: DefaultField, key: FieldKeys, value: unknown, type: FetchType, insertBefore: boolean) => void;
228
283
  declare const computeResultLength: (data: unknown) => number;
229
284
  declare const generateRequestParams: ({ field, uniqueKey, query, is_up, type }: GenerateParamsType) => GenerateParamsResp;
@@ -256,36 +311,4 @@ declare namespace utils {
256
311
  export { utils_combineArrayData as combineArrayData, utils_computeMatchedItemIndex as computeMatchedItemIndex, utils_computeResultLength as computeResultLength, utils_generateDefaultField as generateDefaultField, utils_generateFieldName as generateFieldName, utils_generateRequestParams as generateRequestParams, utils_getObjectDeepValue as getObjectDeepValue, utils_getResultAsArray as getResultAsArray, utils_isArray as isArray, utils_isKeyMap as isKeyMap, utils_isKeyMapArray as isKeyMapArray, utils_isObjectKey as isObjectKey, utils_isObjectKeyArray as isObjectKeyArray, utils_isObjectResult as isObjectResult, utils_isResultObject as isResultObject, utils_searchValueByKey as searchValueByKey, utils_setReactivityField as setReactivityField, utils_stableSerialize as stableSerialize, utils_toObjectKey as toObjectKey, utils_updateArrayItem as updateArrayItem, utils_updateObjectDeepValue as updateObjectDeepValue };
257
312
  }
258
313
 
259
- declare const _default: {
260
- readonly SETTER_TYPE: {
261
- readonly RESET: 0;
262
- readonly MERGE: 1;
263
- };
264
- readonly FETCH_TYPE_ARRAY: readonly ["jump", "sinceId", "page", "seenIds", "auto"];
265
- readonly FETCH_TYPE: {
266
- readonly PAGINATION: "jump";
267
- readonly SINCE_FIRST_OR_END_ID: "sinceId";
268
- readonly SCROLL_LOAD_MORE: "page";
269
- readonly HAS_LOADED_IDS: "seenIds";
270
- readonly AUTO: "auto";
271
- };
272
- readonly CHANGE_TYPE: {
273
- readonly SEARCH_FIELD: "search";
274
- readonly RESET_FIELD: "reset";
275
- readonly RESULT_UPDATE_KV: "update";
276
- readonly RESULT_ADD_AFTER: "push";
277
- readonly RESULT_ADD_BEFORE: "unshift";
278
- readonly RESULT_REMOVE_BY_ID: "delete";
279
- readonly RESULT_INSERT_TO_BEFORE: "insert-before";
280
- readonly RESULT_INSERT_TO_AFTER: "insert-after";
281
- readonly RESULT_LIST_MERGE: "patch";
282
- readonly RESULT_ITEM_MERGE: "merge";
283
- };
284
- readonly FIELD_DATA: {
285
- readonly RESULT_KEY: "result";
286
- readonly EXTRA_KEY: "extra";
287
- };
288
- readonly DEFAULT_UNIQUE_KEY_NAME: "id";
289
- };
290
-
291
314
  export { type ApiContract, type BaseApiResponse, type DefaultField, _default as ENUM, type FetchResultCallback, type FetchType, type FieldGetter, type FieldKeys, type FieldSetter, type GenerateParamsResp, type GenerateParamsType, type InitDataParams, type InitDataType, type InitStateParams, type InitStateType, type KeyMap, type LoadMoreParams, type LoadMoreType, type ObjectKey, type RequestParams, type SetDataType, type SetErrorType, type SetterFuncParams, type UpdateStateParams, type UpdateStateType, createApi, generateFieldName$1 as generateFieldName, initData, initState, loadMore, updateState, utils };
@@ -70,8 +70,29 @@ var FlowList = (function (exports) {
70
70
  var isResultObject = (data) => !isArray(data) && typeof data === "object" && data !== null;
71
71
  var isObjectKey = (value) => typeof value === "string" || typeof value === "number";
72
72
  var isKeyMap = (value) => typeof value === "object" && value !== null && !isArray(value);
73
- var isKeyMapArray = (value) => isArray(value) && value.every((item) => typeof item === "object" && item !== null);
74
- var isObjectKeyArray = (value) => isArray(value) && value.every((item) => typeof item === "string" || typeof item === "number");
73
+ var isKeyMapArray = (value) => {
74
+ if (!isArray(value)) return false;
75
+ const len = value.length;
76
+ for (let i = 0; i < len; i++) {
77
+ const item = value[i];
78
+ if (typeof item !== "object" || item === null) {
79
+ return false;
80
+ }
81
+ }
82
+ return true;
83
+ };
84
+ var isObjectKeyArray = (value) => {
85
+ if (!isArray(value)) return false;
86
+ const len = value.length;
87
+ for (let i = 0; i < len; i++) {
88
+ const item = value[i];
89
+ const itemType = typeof item;
90
+ if (itemType !== "string" && itemType !== "number") {
91
+ return false;
92
+ }
93
+ }
94
+ return true;
95
+ };
75
96
  var stableSerialize = (value) => {
76
97
  if (value === null || typeof value !== "object") {
77
98
  return String(value);
@@ -132,16 +153,25 @@ var FlowList = (function (exports) {
132
153
  func,
133
154
  query
134
155
  }) => {
135
- let result = func.id;
136
156
  if (!query) {
137
- return result;
157
+ return func.id;
138
158
  }
139
- const queryObj = query;
140
- const filteredKeys = Object.keys(queryObj).filter((key) => !func.paramsIgnore.includes(key)).sort();
159
+ let result = func.id;
160
+ const keys = Object.keys(query);
161
+ const paramsIgnore = func.paramsIgnore;
162
+ const filteredKeys = [];
163
+ const keysLen = keys.length;
164
+ for (let i = 0; i < keysLen; i++) {
165
+ const key = keys[i];
166
+ if (!paramsIgnore.includes(key)) {
167
+ filteredKeys.push(key);
168
+ }
169
+ }
170
+ filteredKeys.sort();
141
171
  const len = filteredKeys.length;
142
172
  for (let i = 0; i < len; i++) {
143
173
  const key = filteredKeys[i];
144
- const value = queryObj[key];
174
+ const value = query[key];
145
175
  let safeValue;
146
176
  if (typeof value === "object" && value !== null) {
147
177
  safeValue = stableSerialize(value);
@@ -154,19 +184,15 @@ var FlowList = (function (exports) {
154
184
  return result;
155
185
  };
156
186
  var getObjectDeepValue = (field, keys) => {
157
- if (!keys || isArray(keys) && keys.length === 0) {
187
+ if (!keys || Array.isArray(keys) && keys.length === 0)
158
188
  return field;
189
+ const keysArr = Array.isArray(keys) ? keys : keys.split(".");
190
+ let cur = field;
191
+ for (let i = 0, n = keysArr.length; i < n; ++i) {
192
+ if (cur == null || typeof cur !== "object") return void 0;
193
+ cur = cur[keysArr[i]];
159
194
  }
160
- const keysArr = isArray(keys) ? keys : keys.split(".");
161
- let result = field;
162
- const len = keysArr.length;
163
- for (let i = 0; i < len; i++) {
164
- if (result == null || typeof result !== "object") {
165
- return void 0;
166
- }
167
- result = result[keysArr[i]];
168
- }
169
- return result;
195
+ return cur;
170
196
  };
171
197
  var updateObjectDeepValue = (field, changeKey, value) => {
172
198
  if (!changeKey) return;
@@ -205,12 +231,23 @@ var FlowList = (function (exports) {
205
231
  var computeMatchedItemIndex = (itemId, fieldArr, changingKey) => {
206
232
  const stringifiedItemId = String(itemId);
207
233
  const len = fieldArr.length;
208
- for (let i = 0; i < len; i++) {
209
- const item = fieldArr[i];
210
- if (!isKeyMap(item)) continue;
211
- const itemValue = getObjectDeepValue(item, changingKey);
212
- if (String(itemValue) === stringifiedItemId) {
213
- return i;
234
+ const isSimpleKey = !changingKey.includes(".");
235
+ if (isSimpleKey) {
236
+ for (let i = 0; i < len; i++) {
237
+ const item = fieldArr[i];
238
+ if (!isKeyMap(item)) continue;
239
+ if (String(item[changingKey]) === stringifiedItemId) {
240
+ return i;
241
+ }
242
+ }
243
+ } else {
244
+ for (let i = 0; i < len; i++) {
245
+ const item = fieldArr[i];
246
+ if (!isKeyMap(item)) continue;
247
+ const itemValue = getObjectDeepValue(item, changingKey);
248
+ if (String(itemValue) === stringifiedItemId) {
249
+ return i;
250
+ }
214
251
  }
215
252
  }
216
253
  return -1;
@@ -236,7 +273,7 @@ var FlowList = (function (exports) {
236
273
  if (index !== void 0) {
237
274
  const existingItem = fieldArray[index];
238
275
  if (isKeyMap(existingItem)) {
239
- Object.assign(existingItem, col);
276
+ fieldArray[index] = { ...existingItem, ...col };
240
277
  }
241
278
  }
242
279
  }
@@ -250,7 +287,7 @@ var FlowList = (function (exports) {
250
287
  if (index !== void 0) {
251
288
  const existingItem = fieldArray[index];
252
289
  if (isKeyMap(existingItem)) {
253
- Object.assign(existingItem, col);
290
+ fieldArray[index] = { ...existingItem, ...col };
254
291
  }
255
292
  }
256
293
  }
@@ -266,40 +303,29 @@ var FlowList = (function (exports) {
266
303
  if (isArray(value)) {
267
304
  const current = fieldAny[key];
268
305
  const currentArr = isArray(current) ? current : [];
269
- const newValue = insertBefore ? [...value, ...currentArr] : [...currentArr, ...value];
270
- fieldAny[key] = newValue;
306
+ fieldAny[key] = insertBefore ? value.concat(currentArr) : currentArr.concat(value);
271
307
  } else {
272
308
  fieldAny[key] = value;
273
309
  }
274
310
  return;
275
311
  }
276
312
  const resultField = field.result;
277
- const valueObj = value;
278
313
  if (isArray(value)) {
279
- const currentArr = isArray(resultField) ? resultField : [];
280
314
  const valueArr = value;
281
- if (insertBefore) {
282
- if (valueArr.length === 0) return;
283
- if (currentArr.length === 0) {
284
- field.result = valueArr;
285
- return;
286
- }
287
- field.result = valueArr.concat(currentArr);
288
- } else {
289
- if (valueArr.length === 0) return;
290
- if (currentArr.length === 0) {
291
- field.result = valueArr;
292
- return;
293
- }
294
- field.result = currentArr.concat(valueArr);
315
+ const valueLen = valueArr.length;
316
+ if (valueLen === 0) return;
317
+ const currentArr = isArray(resultField) ? resultField : [];
318
+ const currentLen = currentArr.length;
319
+ if (currentLen === 0) {
320
+ field.result = valueArr;
321
+ return;
295
322
  }
323
+ field.result = insertBefore ? valueArr.concat(currentArr) : currentArr.concat(valueArr);
296
324
  return;
297
325
  }
326
+ const valueObj = value;
298
327
  let target = resultField;
299
- if (isArray(resultField)) {
300
- target = {};
301
- field.result = target;
302
- } else if (typeof resultField !== "object" || resultField === null) {
328
+ if (isArray(resultField) || typeof resultField !== "object" || resultField === null) {
303
329
  target = {};
304
330
  field.result = target;
305
331
  }
@@ -310,10 +336,10 @@ var FlowList = (function (exports) {
310
336
  const existing = target[subKey];
311
337
  const incoming = valueObj[subKey];
312
338
  if (existing !== void 0) {
313
- if (insertBefore) {
314
- target[subKey] = isArray(incoming) && isArray(existing) ? [...incoming, ...existing] : incoming;
339
+ if (isArray(existing) && isArray(incoming)) {
340
+ target[subKey] = insertBefore ? incoming.concat(existing) : existing.concat(incoming);
315
341
  } else {
316
- target[subKey] = isArray(existing) && isArray(incoming) ? [...existing, ...incoming] : incoming;
342
+ target[subKey] = incoming;
317
343
  }
318
344
  } else {
319
345
  target[subKey] = incoming;
@@ -700,7 +726,11 @@ var FlowList = (function (exports) {
700
726
  fieldData[enum_default.FIELD_DATA.RESULT_KEY]
701
727
  );
702
728
  const newFieldData = { ...fieldData };
703
- const resultArray = getResultAsArray(newFieldData);
729
+ let resultArray = getResultAsArray(fieldData);
730
+ if (resultArray) {
731
+ resultArray = [...resultArray];
732
+ newFieldData.result = resultArray;
733
+ }
704
734
  if (method === enum_default.CHANGE_TYPE.SEARCH_FIELD) {
705
735
  const objectKeyId = toObjectKey(_id);
706
736
  if (objectKeyId === void 0) {
@@ -723,7 +753,9 @@ var FlowList = (function (exports) {
723
753
  _uniqueKey
724
754
  );
725
755
  if (matchedIndex >= 0 && isKeyMap(resultArray[matchedIndex])) {
726
- updateObjectDeepValue(resultArray[matchedIndex], _changeKey, value);
756
+ const newItem = { ...resultArray[matchedIndex] };
757
+ updateObjectDeepValue(newItem, _changeKey, value);
758
+ resultArray[matchedIndex] = newItem;
727
759
  }
728
760
  }
729
761
  resolve(null);
@@ -755,7 +787,7 @@ var FlowList = (function (exports) {
755
787
  } else {
756
788
  let modifyValue;
757
789
  if (_changeKey === enum_default.FIELD_DATA.RESULT_KEY) {
758
- modifyValue = newFieldData.result;
790
+ modifyValue = resultArray || newFieldData.result;
759
791
  } else if (_changeKey === enum_default.FIELD_DATA.EXTRA_KEY) {
760
792
  modifyValue = newFieldData.extra;
761
793
  } else {
@@ -780,7 +812,9 @@ var FlowList = (function (exports) {
780
812
  case enum_default.CHANGE_TYPE.RESULT_REMOVE_BY_ID:
781
813
  if (isKeyMapArray(modifyValue)) {
782
814
  if (matchedIndex >= 0) {
783
- modifyValue.splice(matchedIndex, 1);
815
+ const newArray = [...modifyValue];
816
+ newArray.splice(matchedIndex, 1);
817
+ modifyValue = newArray;
784
818
  } else if (isObjectKeyArray(_id)) {
785
819
  const idSet = new Set(_id);
786
820
  modifyValue = modifyValue.filter((item) => {
@@ -792,18 +826,23 @@ var FlowList = (function (exports) {
792
826
  break;
793
827
  case enum_default.CHANGE_TYPE.RESULT_INSERT_TO_BEFORE:
794
828
  if (isArray(modifyValue) && matchedIndex >= 0) {
795
- modifyValue.splice(matchedIndex, 0, value);
829
+ const newArray = [...modifyValue];
830
+ newArray.splice(matchedIndex, 0, value);
831
+ modifyValue = newArray;
796
832
  }
797
833
  break;
798
834
  case enum_default.CHANGE_TYPE.RESULT_INSERT_TO_AFTER:
799
835
  if (isArray(modifyValue) && matchedIndex >= 0) {
800
- modifyValue.splice(matchedIndex + 1, 0, value);
836
+ const newArray = [...modifyValue];
837
+ newArray.splice(matchedIndex + 1, 0, value);
838
+ modifyValue = newArray;
801
839
  }
802
840
  break;
803
841
  case enum_default.CHANGE_TYPE.RESULT_LIST_MERGE:
804
842
  if (isKeyMapArray(modifyValue)) {
843
+ const newArray = [...modifyValue];
805
844
  if (isKeyMapArray(value)) {
806
- combineArrayData(modifyValue, value, _uniqueKey);
845
+ combineArrayData(newArray, value, _uniqueKey);
807
846
  } else if (isKeyMap(value)) {
808
847
  const valueAsRecord = {};
809
848
  for (const [k, v] of Object.entries(value)) {
@@ -811,8 +850,9 @@ var FlowList = (function (exports) {
811
850
  valueAsRecord[k] = v;
812
851
  }
813
852
  }
814
- combineArrayData(modifyValue, valueAsRecord, _uniqueKey);
853
+ combineArrayData(newArray, valueAsRecord, _uniqueKey);
815
854
  }
855
+ modifyValue = newArray;
816
856
  }
817
857
  break;
818
858
  default: