@boteteam/utils 0.0.34 → 0.0.35
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/README.md +175 -9
- package/dist/cjs/aiGenerateFill.d.ts +2 -0
- package/dist/cjs/aiGenerateFill.js +44 -0
- package/dist/cjs/aiGenerateFill.js.map +7 -0
- package/dist/cjs/copyToClipboard.d.ts +6 -0
- package/dist/cjs/copyToClipboard.js +55 -0
- package/dist/cjs/copyToClipboard.js.map +7 -0
- package/dist/cjs/dealStorageData.d.ts +35 -0
- package/dist/cjs/dealStorageData.js +331 -0
- package/dist/cjs/dealStorageData.js.map +7 -0
- package/dist/cjs/docchainContextFill.d.ts +2 -0
- package/dist/cjs/docchainContextFill.js +38 -0
- package/dist/cjs/docchainContextFill.js.map +7 -0
- package/dist/cjs/formatModule/formatModuleData.js +53 -10
- package/dist/cjs/formatModule/formatModuleData.js.map +2 -2
- package/dist/cjs/formatModule/helpers/formatDescriptionsProps.js +13 -2
- package/dist/cjs/formatModule/helpers/formatDescriptionsProps.js.map +3 -3
- package/dist/cjs/formatModule/helpers/formatEchartLineProps.js +12 -5
- package/dist/cjs/formatModule/helpers/formatEchartLineProps.js.map +3 -3
- package/dist/cjs/formatModule/helpers/formatEchartPieProps.d.ts +1 -0
- package/dist/cjs/formatModule/helpers/formatEchartPieProps.js +26 -2
- package/dist/cjs/formatModule/helpers/formatEchartPieProps.js.map +3 -3
- package/dist/cjs/formatModule/helpers/formatFormProps.js +11 -0
- package/dist/cjs/formatModule/helpers/formatFormProps.js.map +3 -3
- package/dist/cjs/formatModule/helpers/formatHighCodeProps.js +3 -0
- package/dist/cjs/formatModule/helpers/formatHighCodeProps.js.map +2 -2
- package/dist/cjs/formatModule/helpers/formatImageProps.js +9 -3
- package/dist/cjs/formatModule/helpers/formatImageProps.js.map +2 -2
- package/dist/cjs/getClassPrefix.d.ts +2 -0
- package/dist/cjs/getClassPrefix.js +43 -0
- package/dist/cjs/getClassPrefix.js.map +7 -0
- package/dist/cjs/http.d.ts +10 -0
- package/dist/cjs/http.js +18 -0
- package/dist/cjs/http.js.map +2 -2
- package/dist/cjs/index.d.ts +10 -2
- package/dist/cjs/index.js +33 -4
- package/dist/cjs/index.js.map +3 -3
- package/dist/cjs/onCallSkillEvent.d.ts +21 -0
- package/dist/cjs/onCallSkillEvent.js +81 -0
- package/dist/cjs/onCallSkillEvent.js.map +7 -0
- package/dist/cjs/treeUtils.js +1 -1
- package/dist/cjs/treeUtils.js.map +2 -2
- package/dist/cjs/unitConversion.d.ts +2 -0
- package/dist/cjs/unitConversion.js +45 -0
- package/dist/cjs/unitConversion.js.map +7 -0
- package/dist/cjs/watermark.d.ts +0 -28
- package/dist/cjs/watermark.js +4 -277
- package/dist/cjs/watermark.js.map +2 -2
- package/dist/esm/aiGenerateFill.d.ts +2 -0
- package/dist/esm/aiGenerateFill.js +17 -0
- package/dist/esm/aiGenerateFill.js.map +1 -0
- package/dist/esm/copyToClipboard.d.ts +6 -0
- package/dist/esm/copyToClipboard.js +23 -0
- package/dist/esm/copyToClipboard.js.map +1 -0
- package/dist/esm/dealStorageData.d.ts +35 -0
- package/dist/esm/dealStorageData.js +441 -0
- package/dist/esm/dealStorageData.js.map +1 -0
- package/dist/esm/docchainContextFill.d.ts +2 -0
- package/dist/esm/docchainContextFill.js +17 -0
- package/dist/esm/docchainContextFill.js.map +1 -0
- package/dist/esm/formatModule/formatModuleData.js +58 -11
- package/dist/esm/formatModule/formatModuleData.js.map +1 -1
- package/dist/esm/formatModule/helpers/formatDescriptionsProps.js +20 -3
- package/dist/esm/formatModule/helpers/formatDescriptionsProps.js.map +1 -1
- package/dist/esm/formatModule/helpers/formatEchartLineProps.js +12 -5
- package/dist/esm/formatModule/helpers/formatEchartLineProps.js.map +1 -1
- package/dist/esm/formatModule/helpers/formatEchartPieProps.d.ts +1 -0
- package/dist/esm/formatModule/helpers/formatEchartPieProps.js +30 -5
- package/dist/esm/formatModule/helpers/formatEchartPieProps.js.map +1 -1
- package/dist/esm/formatModule/helpers/formatFormProps.js +8 -0
- package/dist/esm/formatModule/helpers/formatFormProps.js.map +1 -1
- package/dist/esm/formatModule/helpers/formatHighCodeProps.js +6 -1
- package/dist/esm/formatModule/helpers/formatHighCodeProps.js.map +1 -1
- package/dist/esm/formatModule/helpers/formatImageProps.js +9 -3
- package/dist/esm/formatModule/helpers/formatImageProps.js.map +1 -1
- package/dist/esm/getClassPrefix.d.ts +2 -0
- package/dist/esm/getClassPrefix.js +15 -0
- package/dist/esm/getClassPrefix.js.map +1 -0
- package/dist/esm/http.d.ts +10 -0
- package/dist/esm/http.js +90 -58
- package/dist/esm/http.js.map +1 -1
- package/dist/esm/index.d.ts +10 -2
- package/dist/esm/index.js +9 -3
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/onCallSkillEvent.d.ts +21 -0
- package/dist/esm/onCallSkillEvent.js +90 -0
- package/dist/esm/onCallSkillEvent.js.map +1 -0
- package/dist/esm/treeUtils.js +1 -3
- package/dist/esm/treeUtils.js.map +1 -1
- package/dist/esm/unitConversion.d.ts +2 -0
- package/dist/esm/unitConversion.js +21 -0
- package/dist/esm/unitConversion.js.map +1 -0
- package/dist/esm/watermark.d.ts +0 -28
- package/dist/esm/watermark.js +2 -411
- package/dist/esm/watermark.js.map +1 -1
- package/dist/umd/index.min.js +1 -1
- package/dist/umd/index.min.js.map +1 -1
- package/package.json +8 -3
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/dealStorageData.ts
|
|
20
|
+
var dealStorageData_exports = {};
|
|
21
|
+
__export(dealStorageData_exports, {
|
|
22
|
+
fetchClientIp: () => fetchClientIp,
|
|
23
|
+
getClientIp: () => getClientIp,
|
|
24
|
+
getDriverInfoFromStorage: () => getDriverInfoFromStorage,
|
|
25
|
+
getUserInfoFromStorage: () => getUserInfoFromStorage,
|
|
26
|
+
getVariableRealValue: () => getVariableRealValue,
|
|
27
|
+
parseContentVariables: () => parseContentVariables
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(dealStorageData_exports);
|
|
30
|
+
function getVariableRealValue(key) {
|
|
31
|
+
const sessionInfo = getUserInfoFromStorage();
|
|
32
|
+
const contextParams = getContextParamsFromStorage();
|
|
33
|
+
const clientIp = getClientIp();
|
|
34
|
+
const now = /* @__PURE__ */ new Date();
|
|
35
|
+
const systemMatch = key.match(/^\$\{system\.(\w+)\}$/);
|
|
36
|
+
if (systemMatch) {
|
|
37
|
+
const systemKey = systemMatch[1];
|
|
38
|
+
switch (systemKey) {
|
|
39
|
+
case "now": {
|
|
40
|
+
const year = now.getFullYear();
|
|
41
|
+
const month = String(now.getMonth() + 1).padStart(2, "0");
|
|
42
|
+
const day = String(now.getDate()).padStart(2, "0");
|
|
43
|
+
const hours = String(now.getHours()).padStart(2, "0");
|
|
44
|
+
const minutes = String(now.getMinutes()).padStart(2, "0");
|
|
45
|
+
const seconds = String(now.getSeconds()).padStart(2, "0");
|
|
46
|
+
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
|
|
47
|
+
}
|
|
48
|
+
case "today": {
|
|
49
|
+
const year = now.getFullYear();
|
|
50
|
+
const month = String(now.getMonth() + 1).padStart(2, "0");
|
|
51
|
+
const day = String(now.getDate()).padStart(2, "0");
|
|
52
|
+
return `${year}-${month}-${day}`;
|
|
53
|
+
}
|
|
54
|
+
case "ip":
|
|
55
|
+
return clientIp;
|
|
56
|
+
default:
|
|
57
|
+
return "";
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
const sessionMatch = key.match(/^\$\{session\.(\w+)\}$/);
|
|
61
|
+
if (sessionMatch) {
|
|
62
|
+
const sessionKey = sessionMatch[1];
|
|
63
|
+
switch (sessionKey) {
|
|
64
|
+
case "userId":
|
|
65
|
+
return sessionInfo.userId || "";
|
|
66
|
+
case "userName":
|
|
67
|
+
return sessionInfo.userName || "";
|
|
68
|
+
case "realName":
|
|
69
|
+
return sessionInfo.realName || "";
|
|
70
|
+
default:
|
|
71
|
+
return "";
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
const contextParamsMatch = key.match(/^\$\{contextParams\.(\w+)\}$/);
|
|
75
|
+
if (contextParamsMatch) {
|
|
76
|
+
const contextParamsKey = contextParamsMatch[1];
|
|
77
|
+
if (contextParams && typeof contextParams === "object") {
|
|
78
|
+
const value = contextParams[contextParamsKey];
|
|
79
|
+
return value != null ? String(value) : "";
|
|
80
|
+
}
|
|
81
|
+
return "";
|
|
82
|
+
}
|
|
83
|
+
return "";
|
|
84
|
+
}
|
|
85
|
+
function getUserInfoFromStorage() {
|
|
86
|
+
var _a;
|
|
87
|
+
try {
|
|
88
|
+
if (typeof window === "undefined") {
|
|
89
|
+
return {};
|
|
90
|
+
}
|
|
91
|
+
let userStoresStr = null;
|
|
92
|
+
if (window.sessionStorage) {
|
|
93
|
+
userStoresStr = window.sessionStorage.getItem("userStores");
|
|
94
|
+
}
|
|
95
|
+
if (!userStoresStr && window.localStorage) {
|
|
96
|
+
userStoresStr = window.localStorage.getItem("userStores");
|
|
97
|
+
}
|
|
98
|
+
if (!userStoresStr) {
|
|
99
|
+
return {};
|
|
100
|
+
}
|
|
101
|
+
const userStores = JSON.parse(userStoresStr);
|
|
102
|
+
const userInfo = (_a = userStores == null ? void 0 : userStores.state) == null ? void 0 : _a.userInfo;
|
|
103
|
+
if (!userInfo) {
|
|
104
|
+
return {};
|
|
105
|
+
}
|
|
106
|
+
return {
|
|
107
|
+
userId: userInfo.userId || "",
|
|
108
|
+
userName: userInfo.userName || "",
|
|
109
|
+
realName: userInfo.realName || ""
|
|
110
|
+
};
|
|
111
|
+
} catch (e) {
|
|
112
|
+
console.warn("Failed to get user info from storage:", e);
|
|
113
|
+
return {};
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
function getDriverInfoFromStorage() {
|
|
117
|
+
try {
|
|
118
|
+
if (typeof window === "undefined") {
|
|
119
|
+
return null;
|
|
120
|
+
}
|
|
121
|
+
let driverStoresStr = null;
|
|
122
|
+
if (window.sessionStorage) {
|
|
123
|
+
driverStoresStr = window.sessionStorage.getItem("driverStores");
|
|
124
|
+
}
|
|
125
|
+
if (!driverStoresStr && window.localStorage) {
|
|
126
|
+
driverStoresStr = window.localStorage.getItem("driverStores");
|
|
127
|
+
}
|
|
128
|
+
if (!driverStoresStr) {
|
|
129
|
+
return null;
|
|
130
|
+
}
|
|
131
|
+
const driverStores = JSON.parse(driverStoresStr) || null;
|
|
132
|
+
const { activeSession, selectedScene } = (driverStores == null ? void 0 : driverStores.state) || {};
|
|
133
|
+
return {
|
|
134
|
+
activeSession,
|
|
135
|
+
selectedScene
|
|
136
|
+
};
|
|
137
|
+
} catch (e) {
|
|
138
|
+
console.warn("Failed to get contextParams from storage:", e);
|
|
139
|
+
return null;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
function getContextParamsFromStorage() {
|
|
143
|
+
try {
|
|
144
|
+
if (typeof window === "undefined") {
|
|
145
|
+
return null;
|
|
146
|
+
}
|
|
147
|
+
let contextParamsStr = null;
|
|
148
|
+
if (window.sessionStorage) {
|
|
149
|
+
contextParamsStr = window.sessionStorage.getItem("contextParams");
|
|
150
|
+
}
|
|
151
|
+
if (!contextParamsStr && window.localStorage) {
|
|
152
|
+
contextParamsStr = window.localStorage.getItem("contextParams");
|
|
153
|
+
}
|
|
154
|
+
if (!contextParamsStr) {
|
|
155
|
+
return null;
|
|
156
|
+
}
|
|
157
|
+
return JSON.parse(contextParamsStr) || null;
|
|
158
|
+
} catch (e) {
|
|
159
|
+
console.warn("Failed to get contextParams from storage:", e);
|
|
160
|
+
return null;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
function getClientIpFromStorage() {
|
|
164
|
+
try {
|
|
165
|
+
if (typeof window === "undefined") {
|
|
166
|
+
return null;
|
|
167
|
+
}
|
|
168
|
+
let cachedIp = null;
|
|
169
|
+
if (window.sessionStorage) {
|
|
170
|
+
cachedIp = window.sessionStorage.getItem("clientIp");
|
|
171
|
+
}
|
|
172
|
+
if (!cachedIp && window.localStorage) {
|
|
173
|
+
cachedIp = window.localStorage.getItem("clientIp");
|
|
174
|
+
}
|
|
175
|
+
return cachedIp;
|
|
176
|
+
} catch (e) {
|
|
177
|
+
console.warn("Failed to get client IP from storage:", e);
|
|
178
|
+
return null;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
function setClientIpToStorage(ip) {
|
|
182
|
+
try {
|
|
183
|
+
if (typeof window === "undefined") {
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
if (window.sessionStorage) {
|
|
187
|
+
window.sessionStorage.setItem("clientIp", ip);
|
|
188
|
+
}
|
|
189
|
+
if (window.localStorage) {
|
|
190
|
+
window.localStorage.setItem("clientIp", ip);
|
|
191
|
+
}
|
|
192
|
+
} catch (e) {
|
|
193
|
+
console.warn("Failed to save client IP to storage:", e);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
async function fetchClientIp() {
|
|
197
|
+
const cachedIp = getClientIpFromStorage();
|
|
198
|
+
if (cachedIp) {
|
|
199
|
+
return cachedIp;
|
|
200
|
+
}
|
|
201
|
+
const ipServices = [
|
|
202
|
+
"https://api.ipify.org?format=json",
|
|
203
|
+
"https://api.ip.sb/ip",
|
|
204
|
+
"https://api.ipify.org"
|
|
205
|
+
];
|
|
206
|
+
for (const serviceUrl of ipServices) {
|
|
207
|
+
try {
|
|
208
|
+
const response = await fetch(serviceUrl, {
|
|
209
|
+
method: "GET",
|
|
210
|
+
headers: {
|
|
211
|
+
Accept: "application/json"
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
if (response.ok) {
|
|
215
|
+
let ip;
|
|
216
|
+
const contentType = response.headers.get("content-type");
|
|
217
|
+
if (contentType && contentType.includes("application/json")) {
|
|
218
|
+
const data = await response.json();
|
|
219
|
+
ip = data.ip || data.query || data.origin || "";
|
|
220
|
+
} else {
|
|
221
|
+
ip = (await response.text()).trim();
|
|
222
|
+
}
|
|
223
|
+
if (ip && /^(\d{1,3}\.){3}\d{1,3}$/.test(ip)) {
|
|
224
|
+
setClientIpToStorage(ip);
|
|
225
|
+
return ip;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
} catch (e) {
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
const defaultIp = "127.0.0.1";
|
|
232
|
+
console.warn("Failed to fetch client IP, using default:", defaultIp);
|
|
233
|
+
return defaultIp;
|
|
234
|
+
}
|
|
235
|
+
function getClientIp() {
|
|
236
|
+
const cachedIp = getClientIpFromStorage();
|
|
237
|
+
if (cachedIp) {
|
|
238
|
+
return cachedIp;
|
|
239
|
+
}
|
|
240
|
+
if (typeof window !== "undefined") {
|
|
241
|
+
fetchClientIp().catch(() => {
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
return "127.0.0.1";
|
|
245
|
+
}
|
|
246
|
+
function parseContentVariables(content) {
|
|
247
|
+
const variableRegex = /\$\{(system|session|contextParams)\.(\w+)\}/g;
|
|
248
|
+
let cachedSessionInfo = null;
|
|
249
|
+
let cachedContextParams = null;
|
|
250
|
+
let contextParamsRead = false;
|
|
251
|
+
return content.replace(variableRegex, (match, type, key) => {
|
|
252
|
+
const variableKey = `\${${type}.${key}}`;
|
|
253
|
+
if (type === "session" && cachedSessionInfo === null) {
|
|
254
|
+
cachedSessionInfo = getUserInfoFromStorage();
|
|
255
|
+
}
|
|
256
|
+
if (type === "contextParams" && !contextParamsRead) {
|
|
257
|
+
cachedContextParams = getContextParamsFromStorage();
|
|
258
|
+
contextParamsRead = true;
|
|
259
|
+
}
|
|
260
|
+
if (type === "session" || type === "contextParams") {
|
|
261
|
+
return getVariableRealValueWithCache(variableKey, cachedSessionInfo, cachedContextParams);
|
|
262
|
+
}
|
|
263
|
+
return getVariableRealValue(variableKey);
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
function getVariableRealValueWithCache(key, sessionInfo, contextParams) {
|
|
267
|
+
const clientIp = getClientIp();
|
|
268
|
+
const now = /* @__PURE__ */ new Date();
|
|
269
|
+
const systemMatch = key.match(/^\$\{system\.(\w+)\}$/);
|
|
270
|
+
if (systemMatch) {
|
|
271
|
+
const systemKey = systemMatch[1];
|
|
272
|
+
switch (systemKey) {
|
|
273
|
+
case "now": {
|
|
274
|
+
const year = now.getFullYear();
|
|
275
|
+
const month = String(now.getMonth() + 1).padStart(2, "0");
|
|
276
|
+
const day = String(now.getDate()).padStart(2, "0");
|
|
277
|
+
const hours = String(now.getHours()).padStart(2, "0");
|
|
278
|
+
const minutes = String(now.getMinutes()).padStart(2, "0");
|
|
279
|
+
const seconds = String(now.getSeconds()).padStart(2, "0");
|
|
280
|
+
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
|
|
281
|
+
}
|
|
282
|
+
case "today": {
|
|
283
|
+
const year = now.getFullYear();
|
|
284
|
+
const month = String(now.getMonth() + 1).padStart(2, "0");
|
|
285
|
+
const day = String(now.getDate()).padStart(2, "0");
|
|
286
|
+
return `${year}-${month}-${day}`;
|
|
287
|
+
}
|
|
288
|
+
case "ip":
|
|
289
|
+
return clientIp;
|
|
290
|
+
default:
|
|
291
|
+
return "";
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
const sessionMatch = key.match(/^\$\{session\.(\w+)\}$/);
|
|
295
|
+
if (sessionMatch) {
|
|
296
|
+
const sessionKey = sessionMatch[1];
|
|
297
|
+
if (sessionInfo) {
|
|
298
|
+
switch (sessionKey) {
|
|
299
|
+
case "userId":
|
|
300
|
+
return sessionInfo.userId || "";
|
|
301
|
+
case "userName":
|
|
302
|
+
return sessionInfo.userName || "";
|
|
303
|
+
case "realName":
|
|
304
|
+
return sessionInfo.realName || "";
|
|
305
|
+
default:
|
|
306
|
+
return "";
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
return "";
|
|
310
|
+
}
|
|
311
|
+
const contextParamsMatch = key.match(/^\$\{contextParams\.(\w+)\}$/);
|
|
312
|
+
if (contextParamsMatch) {
|
|
313
|
+
const contextParamsKey = contextParamsMatch[1];
|
|
314
|
+
if (contextParams && typeof contextParams === "object") {
|
|
315
|
+
const value = contextParams[contextParamsKey];
|
|
316
|
+
return value != null ? String(value) : "";
|
|
317
|
+
}
|
|
318
|
+
return "";
|
|
319
|
+
}
|
|
320
|
+
return "";
|
|
321
|
+
}
|
|
322
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
323
|
+
0 && (module.exports = {
|
|
324
|
+
fetchClientIp,
|
|
325
|
+
getClientIp,
|
|
326
|
+
getDriverInfoFromStorage,
|
|
327
|
+
getUserInfoFromStorage,
|
|
328
|
+
getVariableRealValue,
|
|
329
|
+
parseContentVariables
|
|
330
|
+
});
|
|
331
|
+
//# sourceMappingURL=dealStorageData.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/dealStorageData.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * 会话信息类型\n */\nexport interface SessionInfo {\n userId?: string;\n userName?: string;\n realName?: string;\n}\n\n\n/**\n * 根据 key 获取变量的真实值\n * @param key 变量 key,支持格式:${system.now}、${system.today}、${system.ip}、${session.userId}、${session.userName}、${session.realName}、${contextParams.xxx}\n */\nexport function getVariableRealValue(\n key: string,\n): string {\n // 从 sessionStorage 获取用户信息\n const sessionInfo = getUserInfoFromStorage();\n \n // 从 storage 获取 contextParams\n const contextParams = getContextParamsFromStorage();\n \n // 获取客户端 IP(从缓存读取,如果没有则返回默认值)\n const clientIp = getClientIp();\n\n const now = new Date();\n\n // 处理 ${system.xxx} 格式\n const systemMatch = key.match(/^\\$\\{system\\.(\\w+)\\}$/);\n if (systemMatch) {\n const systemKey = systemMatch[1];\n switch (systemKey) {\n case 'now': {\n // 当前时间:格式为 YYYY-MM-DD HH:mm:ss\n const year = now.getFullYear();\n const month = String(now.getMonth() + 1).padStart(2, '0');\n const day = String(now.getDate()).padStart(2, '0');\n const hours = String(now.getHours()).padStart(2, '0');\n const minutes = String(now.getMinutes()).padStart(2, '0');\n const seconds = String(now.getSeconds()).padStart(2, '0');\n return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;\n }\n case 'today': {\n // 当前日期:格式为 YYYY-MM-DD\n const year = now.getFullYear();\n const month = String(now.getMonth() + 1).padStart(2, '0');\n const day = String(now.getDate()).padStart(2, '0');\n return `${year}-${month}-${day}`;\n }\n case 'ip':\n return clientIp;\n default:\n return '';\n }\n }\n\n // 处理 ${session.xxx} 格式\n const sessionMatch = key.match(/^\\$\\{session\\.(\\w+)\\}$/);\n if (sessionMatch) {\n const sessionKey = sessionMatch[1];\n switch (sessionKey) {\n case 'userId':\n return sessionInfo.userId || '';\n case 'userName':\n return sessionInfo.userName || '';\n case 'realName':\n return sessionInfo.realName || '';\n default:\n return '';\n }\n }\n\n // 处理 ${contextParams.xxx} 格式\n const contextParamsMatch = key.match(/^\\$\\{contextParams\\.(\\w+)\\}$/);\n if (contextParamsMatch) {\n const contextParamsKey = contextParamsMatch[1];\n if (contextParams && typeof contextParams === 'object') {\n const value = contextParams[contextParamsKey];\n // 如果值是 null 或 undefined,返回空字符串;否则转换为字符串\n return value != null ? String(value) : '';\n }\n return '';\n }\n return '';\n}\n\n/**\n * 从 storage 获取用户信息(优先从 sessionStorage,其次从 localStorage)\n */\nexport function getUserInfoFromStorage(): SessionInfo {\n try {\n if (typeof window === 'undefined') {\n return {};\n }\n\n // 优先从 sessionStorage 读取,如果没有则从 localStorage 读取\n let userStoresStr = null;\n if (window.sessionStorage) {\n userStoresStr = window.sessionStorage.getItem('userStores');\n }\n if (!userStoresStr && window.localStorage) {\n userStoresStr = window.localStorage.getItem('userStores');\n }\n\n if (!userStoresStr) {\n return {};\n }\n\n const userStores = JSON.parse(userStoresStr);\n const userInfo = userStores?.state?.userInfo;\n if (!userInfo) {\n return {};\n }\n return {\n userId: userInfo.userId || '',\n userName: userInfo.userName || '',\n realName: userInfo.realName || '',\n };\n } catch (e) {\n console.warn('Failed to get user info from storage:', e);\n return {};\n }\n}\n\nexport function getDriverInfoFromStorage(): { [key: string]: any } | null {\n try {\n if (typeof window === 'undefined') {\n return null;\n }\n\n // 优先从 sessionStorage 读取,如果没有则从 localStorage 读取\n let driverStoresStr = null;\n if (window.sessionStorage) {\n driverStoresStr = window.sessionStorage.getItem('driverStores');\n }\n if (!driverStoresStr && window.localStorage) {\n driverStoresStr = window.localStorage.getItem('driverStores');\n }\n\n if (!driverStoresStr) {\n return null;\n }\n\n const driverStores = JSON.parse(driverStoresStr) || null;\n const { activeSession, selectedScene } = driverStores?.state || {};\n \n return {\n activeSession,\n selectedScene,\n };\n } catch (e) {\n console.warn('Failed to get contextParams from storage:', e);\n return null;\n }\n}\n\n/**\n * 从 storage 获取 contextParams(优先从 sessionStorage,其次从 localStorage)\n */\nfunction getContextParamsFromStorage(): { [key: string]: any } | null {\n try {\n if (typeof window === 'undefined') {\n return null;\n }\n\n // 优先从 sessionStorage 读取,如果没有则从 localStorage 读取\n let contextParamsStr = null;\n if (window.sessionStorage) {\n contextParamsStr = window.sessionStorage.getItem('contextParams');\n }\n if (!contextParamsStr && window.localStorage) {\n contextParamsStr = window.localStorage.getItem('contextParams');\n }\n\n if (!contextParamsStr) {\n return null;\n }\n\n return JSON.parse(contextParamsStr) || null;\n } catch (e) {\n console.warn('Failed to get contextParams from storage:', e);\n return null;\n }\n}\n\n/**\n * 从 storage 获取缓存的客户端 IP\n */\nfunction getClientIpFromStorage(): string | null {\n try {\n if (typeof window === 'undefined') {\n return null;\n }\n\n // 优先从 sessionStorage 读取,如果没有则从 localStorage 读取\n let cachedIp = null;\n if (window.sessionStorage) {\n cachedIp = window.sessionStorage.getItem('clientIp');\n }\n if (!cachedIp && window.localStorage) {\n cachedIp = window.localStorage.getItem('clientIp');\n }\n\n return cachedIp;\n } catch (e) {\n console.warn('Failed to get client IP from storage:', e);\n return null;\n }\n}\n\n/**\n * 缓存客户端 IP 到 storage\n */\nfunction setClientIpToStorage(ip: string): void {\n try {\n if (typeof window === 'undefined') {\n return;\n }\n\n // 优先保存到 sessionStorage,同时保存到 localStorage 作为备份\n if (window.sessionStorage) {\n window.sessionStorage.setItem('clientIp', ip);\n }\n if (window.localStorage) {\n window.localStorage.setItem('clientIp', ip);\n }\n } catch (e) {\n console.warn('Failed to save client IP to storage:', e);\n }\n}\n\n/**\n * 异步获取客户端 IP(通过第三方 API)\n * @returns Promise<string> 返回客户端 IP 地址\n */\nexport async function fetchClientIp(): Promise<string> {\n // 先检查缓存\n const cachedIp = getClientIpFromStorage();\n if (cachedIp) {\n return cachedIp;\n }\n\n // 尝试多个 IP 查询服务(按优先级)\n const ipServices = [\n 'https://api.ipify.org?format=json',\n 'https://api.ip.sb/ip',\n 'https://api.ipify.org',\n ];\n\n for (const serviceUrl of ipServices) {\n try {\n const response = await fetch(serviceUrl, {\n method: 'GET',\n headers: {\n Accept: 'application/json',\n },\n });\n\n if (response.ok) {\n let ip: string;\n const contentType = response.headers.get('content-type');\n \n if (contentType && contentType.includes('application/json')) {\n const data = await response.json();\n ip = data.ip || data.query || data.origin || '';\n } else {\n ip = (await response.text()).trim();\n }\n\n // 验证 IP 格式\n if (ip && /^(\\d{1,3}\\.){3}\\d{1,3}$/.test(ip)) {\n // 缓存 IP\n setClientIpToStorage(ip);\n return ip;\n }\n }\n } catch (e) {\n // 继续尝试下一个服务(静默失败)\n }\n }\n\n // 所有服务都失败,返回默认值\n const defaultIp = '127.0.0.1';\n console.warn('Failed to fetch client IP, using default:', defaultIp);\n return defaultIp;\n}\n\n/**\n * 获取客户端 IP(同步方法,从缓存读取)\n * @returns string 返回客户端 IP 地址,如果缓存中没有则返回默认值 '127.0.0.1'\n */\nexport function getClientIp(): string {\n const cachedIp = getClientIpFromStorage();\n if (cachedIp) {\n return cachedIp;\n }\n\n // 如果没有缓存,尝试异步获取(不阻塞当前调用)\n // 下次调用时会使用缓存的 IP\n if (typeof window !== 'undefined') {\n fetchClientIp().catch(() => {\n // 静默失败,不影响当前调用\n });\n }\n\n return '127.0.0.1';\n}\n\n/**\n * 解析 content 中的所有变量并替换为真实值\n * @param content 原始内容,可能包含变量如 ${system.now}、${session.userId}、${contextParams.userName} 等\n */\nexport function parseContentVariables(\n content: string,\n): string {\n // 匹配所有变量:${system.xxx}、${session.xxx} 或 ${contextParams.xxx}\n const variableRegex = /\\$\\{(system|session|contextParams)\\.(\\w+)\\}/g;\n \n // 缓存 storage 读取结果,避免在解析多个变量时重复读取\n let cachedSessionInfo: SessionInfo | null = null;\n let cachedContextParams: { [key: string]: any } | null = null;\n let contextParamsRead = false; // 标记是否已读取 contextParams\n \n return content.replace(variableRegex, (match, type, key) => {\n const variableKey = `\\${${type}.${key}}`;\n \n // 对于需要 storage 数据的变量类型,使用缓存\n if (type === 'session' && cachedSessionInfo === null) {\n cachedSessionInfo = getUserInfoFromStorage();\n }\n if (type === 'contextParams' && !contextParamsRead) {\n cachedContextParams = getContextParamsFromStorage();\n contextParamsRead = true;\n }\n \n // 如果变量需要 session 或 contextParams,使用缓存的版本\n if (type === 'session' || type === 'contextParams') {\n return getVariableRealValueWithCache(variableKey, cachedSessionInfo, cachedContextParams);\n }\n \n // 其他类型(system)直接调用\n return getVariableRealValue(variableKey);\n });\n}\n\n/**\n * 带缓存的变量值获取(内部使用)\n */\nfunction getVariableRealValueWithCache(\n key: string,\n sessionInfo: SessionInfo | null,\n contextParams: { [key: string]: any } | null\n): string {\n // 获取客户端 IP(从缓存读取,如果没有则返回默认值)\n const clientIp = getClientIp();\n const now = new Date();\n\n // 处理 ${system.xxx} 格式\n const systemMatch = key.match(/^\\$\\{system\\.(\\w+)\\}$/);\n if (systemMatch) {\n const systemKey = systemMatch[1];\n switch (systemKey) {\n case 'now': {\n const year = now.getFullYear();\n const month = String(now.getMonth() + 1).padStart(2, '0');\n const day = String(now.getDate()).padStart(2, '0');\n const hours = String(now.getHours()).padStart(2, '0');\n const minutes = String(now.getMinutes()).padStart(2, '0');\n const seconds = String(now.getSeconds()).padStart(2, '0');\n return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;\n }\n case 'today': {\n const year = now.getFullYear();\n const month = String(now.getMonth() + 1).padStart(2, '0');\n const day = String(now.getDate()).padStart(2, '0');\n return `${year}-${month}-${day}`;\n }\n case 'ip':\n return clientIp;\n default:\n return '';\n }\n }\n\n // 处理 ${session.xxx} 格式\n const sessionMatch = key.match(/^\\$\\{session\\.(\\w+)\\}$/);\n if (sessionMatch) {\n const sessionKey = sessionMatch[1];\n if (sessionInfo) {\n switch (sessionKey) {\n case 'userId':\n return sessionInfo.userId || '';\n case 'userName':\n return sessionInfo.userName || '';\n case 'realName':\n return sessionInfo.realName || '';\n default:\n return '';\n }\n }\n return '';\n }\n\n // 处理 ${contextParams.xxx} 格式\n const contextParamsMatch = key.match(/^\\$\\{contextParams\\.(\\w+)\\}$/);\n if (contextParamsMatch) {\n const contextParamsKey = contextParamsMatch[1];\n if (contextParams && typeof contextParams === 'object') {\n const value = contextParams[contextParamsKey];\n return value != null ? String(value) : '';\n }\n return '';\n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AAA,MACxD;AAAA,MACA,KAAK,SAAS;AACZ,cAAM,OAAO,IAAI,YAAY;AAC7B,cAAM,QAAQ,OAAO,IAAI,SAAS,IAAI,CAAC,EAAE,SAAS,GAAG,GAAG;AACxD,cAAM,MAAM,OAAO,IAAI,QAAQ,CAAC,EAAE,SAAS,GAAG,GAAG;AACjD,eAAO,GAAG,QAAQ,SAAS;AAAA,MAC7B;AAAA,MACA,KAAK;AACH,eAAO;AAAA,MACT;AACE,eAAO;AAAA,IACX;AAAA,EACF;AAGA,QAAM,eAAe,IAAI,MAAM,wBAAwB;AACvD,MAAI,cAAc;AAChB,UAAM,aAAa,aAAa,CAAC;AACjC,QAAI,aAAa;AACf,cAAQ,YAAY;AAAA,QAClB,KAAK;AACH,iBAAO,YAAY,UAAU;AAAA,QAC/B,KAAK;AACH,iBAAO,YAAY,YAAY;AAAA,QACjC,KAAK;AACH,iBAAO,YAAY,YAAY;AAAA,QACjC;AACE,iBAAO;AAAA,MACX;AAAA,IACF;AACA,WAAO;AAAA,EACT;AAGA,QAAM,qBAAqB,IAAI,MAAM,8BAA8B;AACnE,MAAI,oBAAoB;AACtB,UAAM,mBAAmB,mBAAmB,CAAC;AAC7C,QAAI,iBAAiB,OAAO,kBAAkB,UAAU;AACtD,YAAM,QAAQ,cAAc,gBAAgB;AAC5C,aAAO,SAAS,OAAO,OAAO,KAAK,IAAI;AAAA,IACzC;AACA,WAAO;AAAA,EACT;AACA,SAAO;AACT;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/docchainContextFill.ts
|
|
20
|
+
var docchainContextFill_exports = {};
|
|
21
|
+
__export(docchainContextFill_exports, {
|
|
22
|
+
default: () => docchainContextFill_default
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(docchainContextFill_exports);
|
|
25
|
+
var docchainContextFill = () => {
|
|
26
|
+
const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
27
|
+
svg.style.position = "absolute";
|
|
28
|
+
svg.style.width = "0";
|
|
29
|
+
svg.style.height = "0";
|
|
30
|
+
svg.style.visibility = "hidden";
|
|
31
|
+
svg.style.overflow = "hidden";
|
|
32
|
+
svg.innerHTML = `
|
|
33
|
+
<defs><linearGradient id="ico-docchain-context_svg__a" x1="8" x2="8" y1="2.867" y2="15.401" gradientUnits="userSpaceOnUse"><stop stop-color="#7570E7" style="stop-color: color(display-p3 0.4588 0.4392 0.9059); stop-opacity: 1;"></stop><stop offset="1" stop-color="#B9B5FF" style="stop-color: color(display-p3 0.7272 0.7099 1); stop-opacity: 1;"></stop></linearGradient></defs>
|
|
34
|
+
`;
|
|
35
|
+
document.body.appendChild(svg);
|
|
36
|
+
};
|
|
37
|
+
var docchainContextFill_default = docchainContextFill;
|
|
38
|
+
//# sourceMappingURL=docchainContextFill.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/docchainContextFill.ts"],
|
|
4
|
+
"sourcesContent": ["const docchainContextFill = () => {\n // 使用 SVG 命名空间创建 SVG 元素,确保正确的 SVG 上下文\n const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\n // 设置 SVG 为隐藏,作为渐变定义的容器(outlet)\n svg.style.position = 'absolute';\n svg.style.width = '0';\n svg.style.height = '0';\n svg.style.visibility = 'hidden';\n svg.style.overflow = 'hidden';\n \n svg.innerHTML = `\n <defs><linearGradient id=\"ico-docchain-context_svg__a\" x1=\"8\" x2=\"8\" y1=\"2.867\" y2=\"15.401\" gradientUnits=\"userSpaceOnUse\"><stop stop-color=\"#7570E7\" style=\"stop-color: color(display-p3 0.4588 0.4392 0.9059); stop-opacity: 1;\"></stop><stop offset=\"1\" stop-color=\"#B9B5FF\" style=\"stop-color: color(display-p3 0.7272 0.7099 1); stop-opacity: 1;\"></stop></linearGradient></defs>\n `;\n \n // 将 SVG 元素添加到 body,作为渐变定义的出口(outlet)\n // 这样其他 SVG 元素就可以通过 ID 引用其中的渐变\n document.body.appendChild(svg);\n};\n\nexport default docchainContextFill;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAM,sBAAsB,MAAM;AAEhC,QAAM,MAAM,SAAS,gBAAgB,8BAA8B,KAAK;AAExE,MAAI,MAAM,WAAW;AACrB,MAAI,MAAM,QAAQ;AAClB,MAAI,MAAM,SAAS;AACnB,MAAI,MAAM,aAAa;AACvB,MAAI,MAAM,WAAW;AAErB,MAAI,YAAY;AAAA;AAAA;AAMhB,WAAS,KAAK,YAAY,GAAG;AAC/B;AAEA,IAAO,8BAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -27,6 +27,36 @@ var import_lodash = require("lodash");
|
|
|
27
27
|
var import_treeUtils = require("../treeUtils");
|
|
28
28
|
var import_helpers = require("./helpers");
|
|
29
29
|
var import_formatStyleProps = require("./helpers/formatStyleProps");
|
|
30
|
+
var handleLegacyEventCompatibility = (compType, events, compProps) => {
|
|
31
|
+
var _a, _b;
|
|
32
|
+
if (compType === "page" && events && events.length > 0) {
|
|
33
|
+
events.forEach((event) => {
|
|
34
|
+
if (event.key === "pageLoad") {
|
|
35
|
+
event.key = "onLoad";
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
if (["loop", "list", "recommendList"].includes(compType) && ((_a = compProps.event) == null ? void 0 : _a.length) > 0) {
|
|
40
|
+
compProps.events = [
|
|
41
|
+
{
|
|
42
|
+
key: "onItemClick",
|
|
43
|
+
name: "点击当前项",
|
|
44
|
+
event: compProps.event
|
|
45
|
+
}
|
|
46
|
+
];
|
|
47
|
+
delete compProps.event;
|
|
48
|
+
}
|
|
49
|
+
if (["image", "div", "typography"].includes(compType) && ((_b = compProps.event) == null ? void 0 : _b.length) > 0) {
|
|
50
|
+
compProps.events = [
|
|
51
|
+
{
|
|
52
|
+
key: "onClick",
|
|
53
|
+
name: "点击当前区域",
|
|
54
|
+
event: compProps.event
|
|
55
|
+
}
|
|
56
|
+
];
|
|
57
|
+
delete compProps.event;
|
|
58
|
+
}
|
|
59
|
+
};
|
|
30
60
|
var formatModuleData = ({
|
|
31
61
|
moduleData,
|
|
32
62
|
parentModuleData,
|
|
@@ -160,15 +190,18 @@ var formatModuleData = ({
|
|
|
160
190
|
});
|
|
161
191
|
}
|
|
162
192
|
moduleDataRes.parentCompProps = (parentModuleData == null ? void 0 : parentModuleData.compProps) || {};
|
|
193
|
+
if (events && (events == null ? void 0 : events.length) > 0) {
|
|
194
|
+
events.forEach((item) => {
|
|
195
|
+
moduleDataRes.compProps[item == null ? void 0 : item.key] = item == null ? void 0 : item.event;
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
handleLegacyEventCompatibility(compType, events, compProps);
|
|
199
|
+
if (events && (events == null ? void 0 : events.length) > 0) {
|
|
200
|
+
events.forEach((item) => {
|
|
201
|
+
moduleDataRes.compProps[item == null ? void 0 : item.key] = item == null ? void 0 : item.event;
|
|
202
|
+
});
|
|
203
|
+
}
|
|
163
204
|
if (compType === "page") {
|
|
164
|
-
if (events && (events == null ? void 0 : events.length) > 0) {
|
|
165
|
-
const onLoadEvent = events.find(
|
|
166
|
-
(item) => (item == null ? void 0 : item.key) === "pageLoad"
|
|
167
|
-
);
|
|
168
|
-
if (onLoadEvent) {
|
|
169
|
-
moduleDataRes.compProps.onLoad = onLoadEvent == null ? void 0 : onLoadEvent.event;
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
205
|
if (eventFlag) {
|
|
173
206
|
moduleDataRes.compProps.eventFlag = { checked: true };
|
|
174
207
|
}
|
|
@@ -285,9 +318,18 @@ var formatModuleData = ({
|
|
|
285
318
|
};
|
|
286
319
|
}
|
|
287
320
|
if (compType === "txt") {
|
|
321
|
+
let txtContent = "";
|
|
322
|
+
if ((0, import_helpers.checkDataSourceOfFn)(compProps == null ? void 0 : compProps.content)) {
|
|
323
|
+
const sctripTxtContent = (0, import_helpers.stringScriptExecution)(compProps == null ? void 0 : compProps.content, allParametrs);
|
|
324
|
+
if (typeof sctripTxtContent === "string" && sctripTxtContent) {
|
|
325
|
+
txtContent = sctripTxtContent;
|
|
326
|
+
}
|
|
327
|
+
} else {
|
|
328
|
+
txtContent = (0, import_helpers.stringPramarsValTransition)(compProps == null ? void 0 : compProps.content, allParametrs);
|
|
329
|
+
}
|
|
288
330
|
moduleDataRes.compProps = {
|
|
289
331
|
...(moduleDataRes == null ? void 0 : moduleDataRes.compProps) || {},
|
|
290
|
-
content:
|
|
332
|
+
content: txtContent
|
|
291
333
|
};
|
|
292
334
|
}
|
|
293
335
|
if (compType === "image" && compDataSource && (compDataSource == null ? void 0 : compDataSource.dataType)) {
|
|
@@ -349,7 +391,8 @@ var formatModuleData = ({
|
|
|
349
391
|
const descriptionsProps = (0, import_helpers.formatDescriptionsProps)({
|
|
350
392
|
options: {
|
|
351
393
|
column,
|
|
352
|
-
attrs
|
|
394
|
+
attrs,
|
|
395
|
+
dataSource: compDataSource
|
|
353
396
|
},
|
|
354
397
|
parameters: allParametrs,
|
|
355
398
|
staticCodeMap
|