@visactor/vseed 0.4.2 → 0.4.3

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/dist/cjs/index.cjs +646 -1
  2. package/dist/cjs/index.cjs.map +1 -1
  3. package/dist/esm/builder/builder/buildSpec.d.ts +1 -2
  4. package/dist/esm/builder/builder/buildSpec.js.map +1 -1
  5. package/dist/esm/builder/builder/builder.d.ts +1116 -106
  6. package/dist/esm/builder/builder/builder.js +10 -0
  7. package/dist/esm/builder/builder/builder.js.map +1 -1
  8. package/dist/esm/builder/builder/prepare.d.ts +12 -0
  9. package/dist/esm/builder/builder/prepare.js +269 -0
  10. package/dist/esm/builder/builder/prepare.js.map +1 -0
  11. package/dist/esm/dataReshape/constant.d.ts +1 -0
  12. package/dist/esm/dataReshape/constant.js +2 -1
  13. package/dist/esm/dataReshape/constant.js.map +1 -1
  14. package/dist/esm/dataSelector/selector.d.ts +71 -2
  15. package/dist/esm/dataSelector/selector.js +96 -32
  16. package/dist/esm/dataSelector/selector.js.map +1 -1
  17. package/dist/esm/pipeline/advanced/chart/pipes/default/defaultMeasures.js +2 -1
  18. package/dist/esm/pipeline/advanced/chart/pipes/default/defaultMeasures.js.map +1 -1
  19. package/dist/esm/pipeline/advanced/table/pipes/default/defaultMeasures.js +2 -1
  20. package/dist/esm/pipeline/advanced/table/pipes/default/defaultMeasures.js.map +1 -1
  21. package/dist/esm/pipeline/spec/chart/pipes/annotation/annotationHorizontalLine.js +10 -4
  22. package/dist/esm/pipeline/spec/chart/pipes/annotation/annotationHorizontalLine.js.map +1 -1
  23. package/dist/esm/pipeline/spec/chart/pipes/annotation/annotationPointCommon.d.ts +8 -2
  24. package/dist/esm/pipeline/spec/chart/pipes/annotation/annotationPointCommon.js +13 -4
  25. package/dist/esm/pipeline/spec/chart/pipes/annotation/annotationPointCommon.js.map +1 -1
  26. package/dist/esm/pipeline/spec/chart/pipes/annotation/annotationPointOfDualAxis.js +8 -4
  27. package/dist/esm/pipeline/spec/chart/pipes/annotation/annotationPointOfDualAxis.js.map +1 -1
  28. package/dist/esm/pipeline/spec/chart/pipes/annotation/annotationVerticalLine.js +10 -4
  29. package/dist/esm/pipeline/spec/chart/pipes/annotation/annotationVerticalLine.js.map +1 -1
  30. package/dist/esm/pipeline/spec/chart/pipes/annotation/utils.d.ts +9 -1
  31. package/dist/esm/pipeline/spec/chart/pipes/annotation/utils.js +7 -1
  32. package/dist/esm/pipeline/spec/chart/pipes/annotation/utils.js.map +1 -1
  33. package/dist/esm/pipeline/spec/chart/pipes/markStyle/barStyle.js +3 -2
  34. package/dist/esm/pipeline/spec/chart/pipes/markStyle/barStyle.js.map +1 -1
  35. package/dist/esm/pipeline/spec/chart/pipes/markStyle/lineStyle.js +5 -2
  36. package/dist/esm/pipeline/spec/chart/pipes/markStyle/lineStyle.js.map +1 -1
  37. package/dist/esm/pipeline/spec/chart/pipes/markStyle/pointStyle.js +3 -2
  38. package/dist/esm/pipeline/spec/chart/pipes/markStyle/pointStyle.js.map +1 -1
  39. package/dist/esm/pipeline/spec/table/pipes/cellStyle/common.d.ts +4 -1
  40. package/dist/esm/pipeline/spec/table/pipes/cellStyle/common.js +12 -1
  41. package/dist/esm/pipeline/spec/table/pipes/cellStyle/common.js.map +1 -1
  42. package/dist/esm/pipeline/spec/table/pipes/cellStyle/pivot.js +6 -3
  43. package/dist/esm/pipeline/spec/table/pipes/cellStyle/pivot.js.map +1 -1
  44. package/dist/esm/pipeline/spec/table/pipes/cellStyle/table.js +7 -3
  45. package/dist/esm/pipeline/spec/table/pipes/cellStyle/table.js.map +1 -1
  46. package/dist/esm/pipeline/utils/index.d.ts +1 -0
  47. package/dist/esm/pipeline/utils/index.js +1 -0
  48. package/dist/esm/pipeline/utils/sandbox/builtin-utils.d.ts +6 -0
  49. package/dist/esm/pipeline/utils/sandbox/builtin-utils.js +337 -0
  50. package/dist/esm/pipeline/utils/sandbox/builtin-utils.js.map +1 -0
  51. package/dist/esm/pipeline/utils/sandbox/execute.d.ts +73 -0
  52. package/dist/esm/pipeline/utils/sandbox/execute.js +716 -0
  53. package/dist/esm/pipeline/utils/sandbox/execute.js.map +1 -0
  54. package/dist/esm/pipeline/utils/sandbox/index.d.ts +7 -0
  55. package/dist/esm/pipeline/utils/sandbox/index.js +3 -0
  56. package/dist/esm/types/builder/builder.d.ts +1 -0
  57. package/dist/esm/types/builder/builder.js.map +1 -1
  58. package/dist/esm/types/chartType/area/zArea.d.ts +682 -18
  59. package/dist/esm/types/chartType/areaPercent/zAreaPercent.d.ts +682 -18
  60. package/dist/esm/types/chartType/bar/zBar.d.ts +362 -10
  61. package/dist/esm/types/chartType/barParallel/zBarParallel.d.ts +362 -10
  62. package/dist/esm/types/chartType/barPercent/zBarPercent.d.ts +362 -10
  63. package/dist/esm/types/chartType/boxPlot/zBoxPlot.d.ts +210 -14
  64. package/dist/esm/types/chartType/circlePacking/zCirclePacking.d.ts +2 -2
  65. package/dist/esm/types/chartType/column/zColumn.d.ts +362 -10
  66. package/dist/esm/types/chartType/columnParallel/zColumnParallel.d.ts +362 -10
  67. package/dist/esm/types/chartType/columnPercent/zColumnPercent.d.ts +362 -10
  68. package/dist/esm/types/chartType/donut/zDonut.d.ts +2 -2
  69. package/dist/esm/types/chartType/dualAxis/zDualAxis.d.ts +842 -22
  70. package/dist/esm/types/chartType/funnel/zFunnel.d.ts +2 -2
  71. package/dist/esm/types/chartType/heatmap/zHeatmap.d.ts +2 -2
  72. package/dist/esm/types/chartType/histogram/zHistogram.d.ts +362 -10
  73. package/dist/esm/types/chartType/line/zLine.d.ts +522 -14
  74. package/dist/esm/types/chartType/pie/zPie.d.ts +2 -2
  75. package/dist/esm/types/chartType/pivotTable/zPivotTable.d.ts +241 -4
  76. package/dist/esm/types/chartType/pivotTable/zPivotTable.js +1 -1
  77. package/dist/esm/types/chartType/pivotTable/zPivotTable.js.map +1 -1
  78. package/dist/esm/types/chartType/raceBar/zRaceBar.d.ts +362 -10
  79. package/dist/esm/types/chartType/raceColumn/zRaceColumn.d.ts +362 -10
  80. package/dist/esm/types/chartType/raceScatter/zRaceScatter.d.ts +362 -10
  81. package/dist/esm/types/chartType/radar/zRadar.d.ts +2 -2
  82. package/dist/esm/types/chartType/rose/zRose.d.ts +2 -2
  83. package/dist/esm/types/chartType/roseParallel/zRoseParallel.d.ts +2 -2
  84. package/dist/esm/types/chartType/scatter/zScatter.d.ts +362 -10
  85. package/dist/esm/types/chartType/sunburst/zSunburst.d.ts +2 -2
  86. package/dist/esm/types/chartType/table/zTable.d.ts +241 -4
  87. package/dist/esm/types/chartType/table/zTable.js +1 -1
  88. package/dist/esm/types/chartType/table/zTable.js.map +1 -1
  89. package/dist/esm/types/chartType/treeMap/zTreeMap.d.ts +2 -2
  90. package/dist/esm/types/dataSelector/selector.d.ts +594 -3
  91. package/dist/esm/types/dataSelector/selector.js +58 -2
  92. package/dist/esm/types/dataSelector/selector.js.map +1 -1
  93. package/dist/esm/types/properties/annotation/annotation.d.ts +200 -4
  94. package/dist/esm/types/properties/annotation/annotationHorizontalLine.d.ts +12 -0
  95. package/dist/esm/types/properties/annotation/annotationPoint.d.ts +19 -0
  96. package/dist/esm/types/properties/annotation/annotationVerticalLine.d.ts +12 -0
  97. package/dist/esm/types/properties/annotation/zAnnotationHorizontalLine.d.ts +10 -0
  98. package/dist/esm/types/properties/annotation/zAnnotationHorizontalLine.js +2 -0
  99. package/dist/esm/types/properties/annotation/zAnnotationHorizontalLine.js.map +1 -1
  100. package/dist/esm/types/properties/annotation/zAnnotationPoint.d.ts +80 -2
  101. package/dist/esm/types/properties/annotation/zAnnotationPoint.js +2 -1
  102. package/dist/esm/types/properties/annotation/zAnnotationPoint.js.map +1 -1
  103. package/dist/esm/types/properties/annotation/zAnnotationVerticalLine.d.ts +10 -0
  104. package/dist/esm/types/properties/annotation/zAnnotationVerticalLine.js +2 -0
  105. package/dist/esm/types/properties/annotation/zAnnotationVerticalLine.js.map +1 -1
  106. package/dist/esm/types/properties/cellStyle/bodyCellStyle.d.ts +105 -2
  107. package/dist/esm/types/properties/cellStyle/bodyCellStyle.js +2 -1
  108. package/dist/esm/types/properties/cellStyle/bodyCellStyle.js.map +1 -1
  109. package/dist/esm/types/properties/cellStyle/cellStyle.d.ts +83 -2
  110. package/dist/esm/types/properties/config/annotation/zAnnotation.d.ts +156 -0
  111. package/dist/esm/types/properties/config/area.d.ts +160 -4
  112. package/dist/esm/types/properties/config/bar.d.ts +240 -6
  113. package/dist/esm/types/properties/config/boxplot.d.ts +80 -2
  114. package/dist/esm/types/properties/config/circlePacking.d.ts +2 -2
  115. package/dist/esm/types/properties/config/column.d.ts +240 -6
  116. package/dist/esm/types/properties/config/config.d.ts +1300 -52
  117. package/dist/esm/types/properties/config/dualAxis.d.ts +80 -2
  118. package/dist/esm/types/properties/config/funnel.d.ts +2 -2
  119. package/dist/esm/types/properties/config/heatmap.d.ts +2 -2
  120. package/dist/esm/types/properties/config/histogram.d.ts +80 -2
  121. package/dist/esm/types/properties/config/label/zLabel.d.ts +2 -2
  122. package/dist/esm/types/properties/config/label/zPieLabel.d.ts +2 -2
  123. package/dist/esm/types/properties/config/line.d.ts +80 -2
  124. package/dist/esm/types/properties/config/pie.d.ts +6 -6
  125. package/dist/esm/types/properties/config/race.d.ts +240 -6
  126. package/dist/esm/types/properties/config/rose.d.ts +4 -4
  127. package/dist/esm/types/properties/config/scatter.d.ts +80 -2
  128. package/dist/esm/types/properties/config/sunburst.d.ts +2 -2
  129. package/dist/esm/types/properties/config/treeMap.d.ts +2 -2
  130. package/dist/esm/types/properties/markStyle/areaStyle.d.ts +19 -0
  131. package/dist/esm/types/properties/markStyle/barStyle.d.ts +99 -2
  132. package/dist/esm/types/properties/markStyle/barStyle.js +2 -1
  133. package/dist/esm/types/properties/markStyle/barStyle.js.map +1 -1
  134. package/dist/esm/types/properties/markStyle/boxPlotStyle.d.ts +2 -2
  135. package/dist/esm/types/properties/markStyle/lineStyle.d.ts +99 -2
  136. package/dist/esm/types/properties/markStyle/lineStyle.js +2 -1
  137. package/dist/esm/types/properties/markStyle/lineStyle.js.map +1 -1
  138. package/dist/esm/types/properties/markStyle/markStyle.d.ts +648 -24
  139. package/dist/esm/types/properties/markStyle/outlierStyle.d.ts +2 -2
  140. package/dist/esm/types/properties/markStyle/pointStyle.d.ts +99 -2
  141. package/dist/esm/types/properties/markStyle/pointStyle.js +2 -1
  142. package/dist/esm/types/properties/markStyle/pointStyle.js.map +1 -1
  143. package/dist/esm/types/properties/markStyle/zAreaStyle.d.ts +80 -2
  144. package/dist/esm/types/properties/markStyle/zAreaStyle.js +2 -1
  145. package/dist/esm/types/properties/markStyle/zAreaStyle.js.map +1 -1
  146. package/dist/esm/types/properties/theme/customTheme.d.ts +2600 -104
  147. package/dist/esm/types/sandbox.d.ts +19 -0
  148. package/dist/esm/types/sandbox.js +0 -0
  149. package/dist/esm/types/zVseed.d.ts +7 -25058
  150. package/dist/esm/types/zVseed.js.map +1 -1
  151. package/dist/umd/index.js +1772 -259
  152. package/dist/umd/index.js.map +1 -1
  153. package/package.json +1 -1
@@ -0,0 +1,337 @@
1
+ const BUILTIN_UTILS_SOURCE = `
2
+ // ============================================
3
+ // 内置工具库 - 与 lodash/Ramda 兼容
4
+ // ============================================
5
+
6
+ const _ = {
7
+ // ========== 数组操作 ==========
8
+
9
+ map: (array, iteratee) => {
10
+ if (!Array.isArray(array)) return [];
11
+ return array.map(typeof iteratee === 'function'
12
+ ? iteratee
13
+ : item => item?.[iteratee]);
14
+ },
15
+
16
+ filter: (array, predicate) => {
17
+ if (!Array.isArray(array)) return [];
18
+ if (typeof predicate === 'function') return array.filter(predicate);
19
+ if (typeof predicate === 'object') {
20
+ return array.filter(item =>
21
+ Object.entries(predicate).every(([key, val]) => item?.[key] === val)
22
+ );
23
+ }
24
+ return array.filter(item => item?.[predicate]);
25
+ },
26
+
27
+ find: (array, predicate) => {
28
+ if (!Array.isArray(array)) return undefined;
29
+ if (typeof predicate === 'function') return array.find(predicate);
30
+ if (typeof predicate === 'object') {
31
+ return array.find(item =>
32
+ Object.entries(predicate).every(([key, val]) => item?.[key] === val)
33
+ );
34
+ }
35
+ return array.find(item => item?.[predicate]);
36
+ },
37
+
38
+ some: (array, predicate) => {
39
+ if (!Array.isArray(array)) return false;
40
+ if (typeof predicate === 'function') return array.some(predicate);
41
+ return array.some(item => item?.[predicate]);
42
+ },
43
+
44
+ every: (array, predicate) => {
45
+ if (!Array.isArray(array)) return true;
46
+ if (typeof predicate === 'function') return array.every(predicate);
47
+ return array.every(item => item?.[predicate]);
48
+ },
49
+
50
+ reduce: (array, iteratee, accumulator) => {
51
+ if (!Array.isArray(array)) return accumulator;
52
+ return accumulator !== undefined
53
+ ? array.reduce(iteratee, accumulator)
54
+ : array.reduce(iteratee);
55
+ },
56
+
57
+ groupBy: (array, iteratee) => {
58
+ if (!Array.isArray(array)) return {};
59
+ const fn = typeof iteratee === 'function' ? iteratee : item => item?.[iteratee];
60
+ return array.reduce((result, item) => {
61
+ const key = fn(item);
62
+ (result[key] = result[key] || []).push(item);
63
+ return result;
64
+ }, {});
65
+ },
66
+
67
+ sortBy: (array, iteratees) => {
68
+ if (!Array.isArray(array)) return [];
69
+ const arr = [...array];
70
+ const fns = Array.isArray(iteratees) ? iteratees : [iteratees];
71
+ return arr.sort((a, b) => {
72
+ for (const fn of fns) {
73
+ const getVal = typeof fn === 'function' ? fn : item => item?.[fn];
74
+ const valA = getVal(a);
75
+ const valB = getVal(b);
76
+ if (valA < valB) return -1;
77
+ if (valA > valB) return 1;
78
+ }
79
+ return 0;
80
+ });
81
+ },
82
+
83
+ uniq: (array) => {
84
+ if (!Array.isArray(array)) return [];
85
+ return [...new Set(array)];
86
+ },
87
+
88
+ uniqBy: (array, iteratee) => {
89
+ if (!Array.isArray(array)) return [];
90
+ const seen = new Set();
91
+ const fn = typeof iteratee === 'function' ? iteratee : item => item?.[iteratee];
92
+ return array.filter(item => {
93
+ const key = fn(item);
94
+ if (seen.has(key)) return false;
95
+ seen.add(key);
96
+ return true;
97
+ });
98
+ },
99
+
100
+ flatten: (array) => {
101
+ if (!Array.isArray(array)) return [];
102
+ return array.flat();
103
+ },
104
+
105
+ flattenDeep: (array) => {
106
+ if (!Array.isArray(array)) return [];
107
+ return array.flat(Infinity);
108
+ },
109
+
110
+ chunk: (array, size = 1) => {
111
+ if (!Array.isArray(array) || size < 1) return [];
112
+ const result = [];
113
+ for (let i = 0; i < array.length; i += size) {
114
+ result.push(array.slice(i, i + size));
115
+ }
116
+ return result;
117
+ },
118
+
119
+ take: (array, n = 1) => {
120
+ if (!Array.isArray(array)) return [];
121
+ return array.slice(0, n);
122
+ },
123
+
124
+ drop: (array, n = 1) => {
125
+ if (!Array.isArray(array)) return [];
126
+ return array.slice(n);
127
+ },
128
+
129
+ compact: (array) => {
130
+ if (!Array.isArray(array)) return [];
131
+ return array.filter(Boolean);
132
+ },
133
+
134
+ // ========== 对象操作 ==========
135
+
136
+ keys: (obj) => {
137
+ if (!obj || typeof obj !== 'object') return [];
138
+ return Object.keys(obj);
139
+ },
140
+
141
+ values: (obj) => {
142
+ if (!obj || typeof obj !== 'object') return [];
143
+ return Object.values(obj);
144
+ },
145
+
146
+ entries: (obj) => {
147
+ if (!obj || typeof obj !== 'object') return [];
148
+ return Object.entries(obj);
149
+ },
150
+
151
+ pick: (obj, keys) => {
152
+ if (!obj || typeof obj !== 'object') return {};
153
+ const picked = {};
154
+ const keyArray = Array.isArray(keys) ? keys : [keys];
155
+ keyArray.forEach(key => {
156
+ if (key in obj) picked[key] = obj[key];
157
+ });
158
+ return picked;
159
+ },
160
+
161
+ omit: (obj, keys) => {
162
+ if (!obj || typeof obj !== 'object') return {};
163
+ const result = { ...obj };
164
+ const keyArray = Array.isArray(keys) ? keys : [keys];
165
+ keyArray.forEach(key => delete result[key]);
166
+ return result;
167
+ },
168
+
169
+ mapValues: (obj, iteratee) => {
170
+ if (!obj || typeof obj !== 'object') return {};
171
+ const result = {};
172
+ const fn = typeof iteratee === 'function' ? iteratee : () => iteratee;
173
+ Object.entries(obj).forEach(([key, value]) => {
174
+ result[key] = fn(value, key, obj);
175
+ });
176
+ return result;
177
+ },
178
+
179
+ get: (obj, path, defaultValue) => {
180
+ if (!obj) return defaultValue;
181
+ const keys = Array.isArray(path) ? path : path.split('.');
182
+ let result = obj;
183
+ for (const key of keys) {
184
+ result = result?.[key];
185
+ if (result === undefined) return defaultValue;
186
+ }
187
+ return result;
188
+ },
189
+
190
+ // ========== 数据判断 ==========
191
+
192
+ isArray: (value) => Array.isArray(value),
193
+
194
+ isObject: (value) => {
195
+ return value !== null && typeof value === 'object' && !Array.isArray(value);
196
+ },
197
+
198
+ isString: (value) => typeof value === 'string',
199
+
200
+ isNumber: (value) => typeof value === 'number' && !isNaN(value),
201
+
202
+ isBoolean: (value) => typeof value === 'boolean',
203
+
204
+ isFunction: (value) => typeof value === 'function',
205
+
206
+ isNil: (value) => value === null || value === undefined,
207
+
208
+ isEmpty: (value) => {
209
+ if (value == null) return true;
210
+ if (Array.isArray(value) || typeof value === 'string') return value.length === 0;
211
+ if (typeof value === 'object') return Object.keys(value).length === 0;
212
+ return false;
213
+ },
214
+
215
+ // ========== 数学统计 ==========
216
+
217
+ sum: (array) => {
218
+ if (!Array.isArray(array)) return 0;
219
+ return array.reduce((sum, n) => sum + (Number(n) || 0), 0);
220
+ },
221
+
222
+ sumBy: (array, iteratee) => {
223
+ if (!Array.isArray(array)) return 0;
224
+ const fn = typeof iteratee === 'function' ? iteratee : item => item?.[iteratee];
225
+ return array.reduce((sum, item) => sum + (Number(fn(item)) || 0), 0);
226
+ },
227
+
228
+ mean: (array) => {
229
+ if (!Array.isArray(array) || array.length === 0) return 0;
230
+ return _.sum(array) / array.length;
231
+ },
232
+
233
+ meanBy: (array, iteratee) => {
234
+ if (!Array.isArray(array) || array.length === 0) return 0;
235
+ return _.sumBy(array, iteratee) / array.length;
236
+ },
237
+
238
+ max: (array) => {
239
+ if (!Array.isArray(array) || array.length === 0) return undefined;
240
+ return Math.max(...array.map(Number).filter(n => !isNaN(n)));
241
+ },
242
+
243
+ maxBy: (array, iteratee) => {
244
+ if (!Array.isArray(array) || array.length === 0) return undefined;
245
+ const fn = typeof iteratee === 'function' ? iteratee : item => item?.[iteratee];
246
+ return array.reduce((max, item) => {
247
+ const val = fn(item);
248
+ return max === undefined || val > fn(max) ? item : max;
249
+ }, undefined);
250
+ },
251
+
252
+ min: (array) => {
253
+ if (!Array.isArray(array) || array.length === 0) return undefined;
254
+ return Math.min(...array.map(Number).filter(n => !isNaN(n)));
255
+ },
256
+
257
+ minBy: (array, iteratee) => {
258
+ if (!Array.isArray(array) || array.length === 0) return undefined;
259
+ const fn = typeof iteratee === 'function' ? iteratee : item => item?.[iteratee];
260
+ return array.reduce((min, item) => {
261
+ const val = fn(item);
262
+ return min === undefined || val < fn(min) ? item : min;
263
+ }, undefined);
264
+ },
265
+
266
+ count: (array) => {
267
+ if (!Array.isArray(array)) return 0;
268
+ return array.length;
269
+ },
270
+
271
+ countBy: (array, iteratee) => {
272
+ if (!Array.isArray(array)) return {};
273
+ const fn = typeof iteratee === 'function' ? iteratee : item => item?.[iteratee];
274
+ return array.reduce((result, item) => {
275
+ const key = fn(item);
276
+ result[key] = (result[key] || 0) + 1;
277
+ return result;
278
+ }, {});
279
+ },
280
+
281
+ // ========== 其他工具 ==========
282
+
283
+ cloneDeep: (value) => {
284
+ if (value === null || typeof value !== 'object') return value;
285
+ if (Array.isArray(value)) return value.map(_.cloneDeep);
286
+ return Object.fromEntries(
287
+ Object.entries(value).map(([k, v]) => [k, _.cloneDeep(v)])
288
+ );
289
+ },
290
+
291
+ merge: (...objects) => {
292
+ return Object.assign({}, ...objects);
293
+ },
294
+
295
+ debounce: (func, wait = 0) => {
296
+ let timeout;
297
+ return function(...args) {
298
+ clearTimeout(timeout);
299
+ timeout = setTimeout(() => func.apply(this, args), wait);
300
+ };
301
+ },
302
+
303
+ throttle: (func, wait = 0) => {
304
+ let lastTime = 0;
305
+ return function(...args) {
306
+ const now = Date.now();
307
+ if (now - lastTime >= wait) {
308
+ lastTime = now;
309
+ return func.apply(this, args);
310
+ }
311
+ };
312
+ },
313
+
314
+ range: (start, end, step = 1) => {
315
+ if (end === undefined) {
316
+ end = start;
317
+ start = 0;
318
+ }
319
+ const result = [];
320
+ for (let i = start; i < end; i += step) {
321
+ result.push(i);
322
+ }
323
+ return result;
324
+ },
325
+ };
326
+
327
+ // 同时暴露为 R (Ramda 风格)
328
+ const R = _;
329
+
330
+ // 暴露到全局
331
+ self._ = _;
332
+ self.R = R;
333
+ `.trim();
334
+ const HAS_BUILTIN_UTILS = BUILTIN_UTILS_SOURCE.length > 100;
335
+ export { BUILTIN_UTILS_SOURCE, HAS_BUILTIN_UTILS };
336
+
337
+ //# sourceMappingURL=builtin-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pipeline/utils/sandbox/builtin-utils.js","sources":["webpack://@visactor/vseed/./src/pipeline/utils/sandbox/builtin-utils.ts"],"sourcesContent":["/**\n * 内置工具函数库\n * @description 提供数据筛选、统计、转换等常用功能,API 与 lodash/Ramda 兼容\n */\n\nexport const BUILTIN_UTILS_SOURCE = `\n// ============================================\n// 内置工具库 - 与 lodash/Ramda 兼容\n// ============================================\n\nconst _ = {\n // ========== 数组操作 ==========\n \n map: (array, iteratee) => {\n if (!Array.isArray(array)) return [];\n return array.map(typeof iteratee === 'function' \n ? iteratee \n : item => item?.[iteratee]);\n },\n \n filter: (array, predicate) => {\n if (!Array.isArray(array)) return [];\n if (typeof predicate === 'function') return array.filter(predicate);\n if (typeof predicate === 'object') {\n return array.filter(item => \n Object.entries(predicate).every(([key, val]) => item?.[key] === val)\n );\n }\n return array.filter(item => item?.[predicate]);\n },\n \n find: (array, predicate) => {\n if (!Array.isArray(array)) return undefined;\n if (typeof predicate === 'function') return array.find(predicate);\n if (typeof predicate === 'object') {\n return array.find(item => \n Object.entries(predicate).every(([key, val]) => item?.[key] === val)\n );\n }\n return array.find(item => item?.[predicate]);\n },\n \n some: (array, predicate) => {\n if (!Array.isArray(array)) return false;\n if (typeof predicate === 'function') return array.some(predicate);\n return array.some(item => item?.[predicate]);\n },\n \n every: (array, predicate) => {\n if (!Array.isArray(array)) return true;\n if (typeof predicate === 'function') return array.every(predicate);\n return array.every(item => item?.[predicate]);\n },\n \n reduce: (array, iteratee, accumulator) => {\n if (!Array.isArray(array)) return accumulator;\n return accumulator !== undefined \n ? array.reduce(iteratee, accumulator)\n : array.reduce(iteratee);\n },\n \n groupBy: (array, iteratee) => {\n if (!Array.isArray(array)) return {};\n const fn = typeof iteratee === 'function' ? iteratee : item => item?.[iteratee];\n return array.reduce((result, item) => {\n const key = fn(item);\n (result[key] = result[key] || []).push(item);\n return result;\n }, {});\n },\n \n sortBy: (array, iteratees) => {\n if (!Array.isArray(array)) return [];\n const arr = [...array];\n const fns = Array.isArray(iteratees) ? iteratees : [iteratees];\n return arr.sort((a, b) => {\n for (const fn of fns) {\n const getVal = typeof fn === 'function' ? fn : item => item?.[fn];\n const valA = getVal(a);\n const valB = getVal(b);\n if (valA < valB) return -1;\n if (valA > valB) return 1;\n }\n return 0;\n });\n },\n \n uniq: (array) => {\n if (!Array.isArray(array)) return [];\n return [...new Set(array)];\n },\n \n uniqBy: (array, iteratee) => {\n if (!Array.isArray(array)) return [];\n const seen = new Set();\n const fn = typeof iteratee === 'function' ? iteratee : item => item?.[iteratee];\n return array.filter(item => {\n const key = fn(item);\n if (seen.has(key)) return false;\n seen.add(key);\n return true;\n });\n },\n \n flatten: (array) => {\n if (!Array.isArray(array)) return [];\n return array.flat();\n },\n \n flattenDeep: (array) => {\n if (!Array.isArray(array)) return [];\n return array.flat(Infinity);\n },\n \n chunk: (array, size = 1) => {\n if (!Array.isArray(array) || size < 1) return [];\n const result = [];\n for (let i = 0; i < array.length; i += size) {\n result.push(array.slice(i, i + size));\n }\n return result;\n },\n \n take: (array, n = 1) => {\n if (!Array.isArray(array)) return [];\n return array.slice(0, n);\n },\n \n drop: (array, n = 1) => {\n if (!Array.isArray(array)) return [];\n return array.slice(n);\n },\n \n compact: (array) => {\n if (!Array.isArray(array)) return [];\n return array.filter(Boolean);\n },\n \n // ========== 对象操作 ==========\n \n keys: (obj) => {\n if (!obj || typeof obj !== 'object') return [];\n return Object.keys(obj);\n },\n \n values: (obj) => {\n if (!obj || typeof obj !== 'object') return [];\n return Object.values(obj);\n },\n \n entries: (obj) => {\n if (!obj || typeof obj !== 'object') return [];\n return Object.entries(obj);\n },\n \n pick: (obj, keys) => {\n if (!obj || typeof obj !== 'object') return {};\n const picked = {};\n const keyArray = Array.isArray(keys) ? keys : [keys];\n keyArray.forEach(key => {\n if (key in obj) picked[key] = obj[key];\n });\n return picked;\n },\n \n omit: (obj, keys) => {\n if (!obj || typeof obj !== 'object') return {};\n const result = { ...obj };\n const keyArray = Array.isArray(keys) ? keys : [keys];\n keyArray.forEach(key => delete result[key]);\n return result;\n },\n \n mapValues: (obj, iteratee) => {\n if (!obj || typeof obj !== 'object') return {};\n const result = {};\n const fn = typeof iteratee === 'function' ? iteratee : () => iteratee;\n Object.entries(obj).forEach(([key, value]) => {\n result[key] = fn(value, key, obj);\n });\n return result;\n },\n \n get: (obj, path, defaultValue) => {\n if (!obj) return defaultValue;\n const keys = Array.isArray(path) ? path : path.split('.');\n let result = obj;\n for (const key of keys) {\n result = result?.[key];\n if (result === undefined) return defaultValue;\n }\n return result;\n },\n \n // ========== 数据判断 ==========\n \n isArray: (value) => Array.isArray(value),\n \n isObject: (value) => {\n return value !== null && typeof value === 'object' && !Array.isArray(value);\n },\n \n isString: (value) => typeof value === 'string',\n \n isNumber: (value) => typeof value === 'number' && !isNaN(value),\n \n isBoolean: (value) => typeof value === 'boolean',\n \n isFunction: (value) => typeof value === 'function',\n \n isNil: (value) => value === null || value === undefined,\n \n isEmpty: (value) => {\n if (value == null) return true;\n if (Array.isArray(value) || typeof value === 'string') return value.length === 0;\n if (typeof value === 'object') return Object.keys(value).length === 0;\n return false;\n },\n \n // ========== 数学统计 ==========\n \n sum: (array) => {\n if (!Array.isArray(array)) return 0;\n return array.reduce((sum, n) => sum + (Number(n) || 0), 0);\n },\n \n sumBy: (array, iteratee) => {\n if (!Array.isArray(array)) return 0;\n const fn = typeof iteratee === 'function' ? iteratee : item => item?.[iteratee];\n return array.reduce((sum, item) => sum + (Number(fn(item)) || 0), 0);\n },\n \n mean: (array) => {\n if (!Array.isArray(array) || array.length === 0) return 0;\n return _.sum(array) / array.length;\n },\n \n meanBy: (array, iteratee) => {\n if (!Array.isArray(array) || array.length === 0) return 0;\n return _.sumBy(array, iteratee) / array.length;\n },\n \n max: (array) => {\n if (!Array.isArray(array) || array.length === 0) return undefined;\n return Math.max(...array.map(Number).filter(n => !isNaN(n)));\n },\n \n maxBy: (array, iteratee) => {\n if (!Array.isArray(array) || array.length === 0) return undefined;\n const fn = typeof iteratee === 'function' ? iteratee : item => item?.[iteratee];\n return array.reduce((max, item) => {\n const val = fn(item);\n return max === undefined || val > fn(max) ? item : max;\n }, undefined);\n },\n \n min: (array) => {\n if (!Array.isArray(array) || array.length === 0) return undefined;\n return Math.min(...array.map(Number).filter(n => !isNaN(n)));\n },\n \n minBy: (array, iteratee) => {\n if (!Array.isArray(array) || array.length === 0) return undefined;\n const fn = typeof iteratee === 'function' ? iteratee : item => item?.[iteratee];\n return array.reduce((min, item) => {\n const val = fn(item);\n return min === undefined || val < fn(min) ? item : min;\n }, undefined);\n },\n \n count: (array) => {\n if (!Array.isArray(array)) return 0;\n return array.length;\n },\n \n countBy: (array, iteratee) => {\n if (!Array.isArray(array)) return {};\n const fn = typeof iteratee === 'function' ? iteratee : item => item?.[iteratee];\n return array.reduce((result, item) => {\n const key = fn(item);\n result[key] = (result[key] || 0) + 1;\n return result;\n }, {});\n },\n \n // ========== 其他工具 ==========\n \n cloneDeep: (value) => {\n if (value === null || typeof value !== 'object') return value;\n if (Array.isArray(value)) return value.map(_.cloneDeep);\n return Object.fromEntries(\n Object.entries(value).map(([k, v]) => [k, _.cloneDeep(v)])\n );\n },\n \n merge: (...objects) => {\n return Object.assign({}, ...objects);\n },\n \n debounce: (func, wait = 0) => {\n let timeout;\n return function(...args) {\n clearTimeout(timeout);\n timeout = setTimeout(() => func.apply(this, args), wait);\n };\n },\n \n throttle: (func, wait = 0) => {\n let lastTime = 0;\n return function(...args) {\n const now = Date.now();\n if (now - lastTime >= wait) {\n lastTime = now;\n return func.apply(this, args);\n }\n };\n },\n \n range: (start, end, step = 1) => {\n if (end === undefined) {\n end = start;\n start = 0;\n }\n const result = [];\n for (let i = start; i < end; i += step) {\n result.push(i);\n }\n return result;\n },\n};\n\n// 同时暴露为 R (Ramda 风格)\nconst R = _;\n\n// 暴露到全局\nself._ = _;\nself.R = R;\n`.trim()\n\nexport const HAS_BUILTIN_UTILS = BUILTIN_UTILS_SOURCE.length > 100\n"],"names":["BUILTIN_UTILS_SOURCE","HAS_BUILTIN_UTILS"],"mappings":"AAKO,MAAMA,uBAAuB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4UrC,CAAC,CAAC,IAAI;AAEC,MAAMC,oBAAoBD,qBAAqB,MAAM,GAAG"}
@@ -0,0 +1,73 @@
1
+ /**
2
+ * 增强的安全代码执行器
3
+ * @description 专为 AI 生成代码设计的安全沙箱
4
+ * @module enhancedSecureCodeExecutor
5
+ */
6
+ import type { CodeExecutionOptions, CodeExecutionResult } from '../../../types/sandbox';
7
+ /**
8
+ * 初始化 Worker 池
9
+ * @description 预热 Worker 实例,提升首次执行性能
10
+ *
11
+ * **⚠️ 注意:这是一个可选的性能优化方法**
12
+ *
13
+ * - **懒加载模式**:如果不调用此方法,Worker 池会在首次使用时自动初始化
14
+ * - **推荐场景**:应用启动时预热,避免首次筛选时的冷启动延迟
15
+ * - **配置选项**:
16
+ * - `poolSize`: Worker 池大小(默认 2)
17
+ *
18
+ * @param options - 初始化选项
19
+ * @param options.poolSize - Worker 池大小,默认为 2
20
+ *
21
+ * @example
22
+ * ```typescript
23
+ * // ✅ 推荐:应用启动时预热(可选)
24
+ * import { initializeWorkerPool } from '@visactor/vseed'
25
+ *
26
+ * // 在 main.ts 或入口文件中
27
+ * await initializeWorkerPool({ poolSize: 2 })
28
+ *
29
+ * // ✅ 也可以:不做任何事,让 Worker 池自动初始化
30
+ * // 首次调用 dynamicFilter 时会自动创建
31
+ * ```
32
+ */
33
+ export declare function initializeWorkerPool(options?: {
34
+ utilityLibUrl?: string;
35
+ utilityLibSource?: string;
36
+ poolSize?: number;
37
+ }): Promise<void>;
38
+ /**
39
+ * 销毁 Worker 池
40
+ * @description 终止所有 Worker 实例并清理全局状态
41
+ *
42
+ * **⚠️ 注意:大多数情况下不需要手动调用此方法**
43
+ *
44
+ * - **一般使用**:浏览器会在页面卸载时自动清理 Worker 资源
45
+ * - **建议场景**:
46
+ * - 单元测试的清理阶段(`afterAll` 钩子)
47
+ * - 开发环境热重载时清理旧实例
48
+ * - 动态卸载整个图表库模块(极少见)
49
+ *
50
+ * @example
51
+ * ```typescript
52
+ * // ✅ 推荐:测试环境
53
+ * afterAll(() => {
54
+ * terminateWorkerPool()
55
+ * })
56
+ *
57
+ * // ❌ 不推荐:组件卸载时(Worker 池是全局的,其他组件可能还在使用)
58
+ * onUnmounted(() => {
59
+ * terminateWorkerPool() // 不要这样做!
60
+ * })
61
+ * ```
62
+ */
63
+ export declare function terminateWorkerPool(): void;
64
+ /**
65
+ * 增强的安全验证
66
+ * @description 针对 AI 生成代码的特定模式检查
67
+ */
68
+ export declare function validateCodeSafety(code: string): void;
69
+ /**
70
+ * 代码执行函数
71
+ * @description 使用 Worker 池和增强安全检查
72
+ */
73
+ export declare function executeFilterCode(options: CodeExecutionOptions): Promise<CodeExecutionResult>;