@snack-kit/core 0.1.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/README.md +514 -0
- package/dist/cjs/index.js +4877 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/class/snack.d.ts +164 -0
- package/dist/class/snackSetting.d.ts +32 -0
- package/dist/class/snackVue.d.ts +27 -0
- package/dist/class/snackVueSetting.d.ts +30 -0
- package/dist/components/error/index.d.ts +9 -0
- package/dist/components/loading/index.d.ts +9 -0
- package/dist/core/index.d.ts +150 -0
- package/dist/core.js +4 -0
- package/dist/es/index.mjs +4760 -0
- package/dist/es/index.mjs.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +22 -0
- package/dist/interface.d.ts +416 -0
- package/dist/lib/require.d.ts +5 -0
- package/dist/sdk/index.d.ts +277 -0
- package/dist/sdk/renderSnack.d.ts +57 -0
- package/dist/sdk.js +22 -0
- package/dist/types/index.d.ts +1236 -0
- package/dist/utils/common.d.ts +33 -0
- package/dist/utils/evalJS.d.ts +151 -0
- package/dist/utils/i18n.d.ts +13 -0
- package/dist/utils/verifyJS.d.ts +42 -0
- package/package.json +62 -0
|
@@ -0,0 +1,4760 @@
|
|
|
1
|
+
function _array_like_to_array(arr, len) {
|
|
2
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
3
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
4
|
+
return arr2;
|
|
5
|
+
}
|
|
6
|
+
function _array_with_holes(arr) {
|
|
7
|
+
if (Array.isArray(arr)) return arr;
|
|
8
|
+
}
|
|
9
|
+
function _array_without_holes(arr) {
|
|
10
|
+
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
11
|
+
}
|
|
12
|
+
function _assert_this_initialized(self) {
|
|
13
|
+
if (self === void 0) {
|
|
14
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
15
|
+
}
|
|
16
|
+
return self;
|
|
17
|
+
}
|
|
18
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
19
|
+
try {
|
|
20
|
+
var info = gen[key](arg);
|
|
21
|
+
var value = info.value;
|
|
22
|
+
} catch (error) {
|
|
23
|
+
reject(error);
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
if (info.done) {
|
|
27
|
+
resolve(value);
|
|
28
|
+
} else {
|
|
29
|
+
Promise.resolve(value).then(_next, _throw);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
function _async_to_generator(fn) {
|
|
33
|
+
return function() {
|
|
34
|
+
var self = this, args = arguments;
|
|
35
|
+
return new Promise(function(resolve, reject) {
|
|
36
|
+
var gen = fn.apply(self, args);
|
|
37
|
+
function _next(value) {
|
|
38
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
39
|
+
}
|
|
40
|
+
function _throw(err) {
|
|
41
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
42
|
+
}
|
|
43
|
+
_next(undefined);
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
function _call_super(_this, derived, args) {
|
|
48
|
+
derived = _get_prototype_of(derived);
|
|
49
|
+
return _possible_constructor_return(_this, _is_native_reflect_construct() ? Reflect.construct(derived, args || [], _get_prototype_of(_this).constructor) : derived.apply(_this, args));
|
|
50
|
+
}
|
|
51
|
+
function _class_call_check(instance, Constructor) {
|
|
52
|
+
if (!(instance instanceof Constructor)) {
|
|
53
|
+
throw new TypeError("Cannot call a class as a function");
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
function _construct(Parent, args, Class) {
|
|
57
|
+
if (_is_native_reflect_construct()) {
|
|
58
|
+
_construct = Reflect.construct;
|
|
59
|
+
} else {
|
|
60
|
+
_construct = function construct(Parent, args, Class) {
|
|
61
|
+
var a = [
|
|
62
|
+
null
|
|
63
|
+
];
|
|
64
|
+
a.push.apply(a, args);
|
|
65
|
+
var Constructor = Function.bind.apply(Parent, a);
|
|
66
|
+
var instance = new Constructor();
|
|
67
|
+
if (Class) _set_prototype_of(instance, Class.prototype);
|
|
68
|
+
return instance;
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
return _construct.apply(null, arguments);
|
|
72
|
+
}
|
|
73
|
+
function _defineProperties(target, props) {
|
|
74
|
+
for(var i = 0; i < props.length; i++){
|
|
75
|
+
var descriptor = props[i];
|
|
76
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
77
|
+
descriptor.configurable = true;
|
|
78
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
79
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
function _create_class(Constructor, protoProps, staticProps) {
|
|
83
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
84
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
85
|
+
return Constructor;
|
|
86
|
+
}
|
|
87
|
+
function _define_property(obj, key, value) {
|
|
88
|
+
if (key in obj) {
|
|
89
|
+
Object.defineProperty(obj, key, {
|
|
90
|
+
value: value,
|
|
91
|
+
enumerable: true,
|
|
92
|
+
configurable: true,
|
|
93
|
+
writable: true
|
|
94
|
+
});
|
|
95
|
+
} else {
|
|
96
|
+
obj[key] = value;
|
|
97
|
+
}
|
|
98
|
+
return obj;
|
|
99
|
+
}
|
|
100
|
+
function _get_prototype_of(o) {
|
|
101
|
+
_get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
|
|
102
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
103
|
+
};
|
|
104
|
+
return _get_prototype_of(o);
|
|
105
|
+
}
|
|
106
|
+
function _inherits(subClass, superClass) {
|
|
107
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
108
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
109
|
+
}
|
|
110
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
111
|
+
constructor: {
|
|
112
|
+
value: subClass,
|
|
113
|
+
writable: true,
|
|
114
|
+
configurable: true
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
if (superClass) _set_prototype_of(subClass, superClass);
|
|
118
|
+
}
|
|
119
|
+
function _instanceof(left, right) {
|
|
120
|
+
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
121
|
+
return !!right[Symbol.hasInstance](left);
|
|
122
|
+
} else {
|
|
123
|
+
return left instanceof right;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
function _iterable_to_array(iter) {
|
|
127
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
128
|
+
}
|
|
129
|
+
function _iterable_to_array_limit(arr, i) {
|
|
130
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
131
|
+
if (_i == null) return;
|
|
132
|
+
var _arr = [];
|
|
133
|
+
var _n = true;
|
|
134
|
+
var _d = false;
|
|
135
|
+
var _s, _e;
|
|
136
|
+
try {
|
|
137
|
+
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
138
|
+
_arr.push(_s.value);
|
|
139
|
+
if (i && _arr.length === i) break;
|
|
140
|
+
}
|
|
141
|
+
} catch (err) {
|
|
142
|
+
_d = true;
|
|
143
|
+
_e = err;
|
|
144
|
+
} finally{
|
|
145
|
+
try {
|
|
146
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
147
|
+
} finally{
|
|
148
|
+
if (_d) throw _e;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
return _arr;
|
|
152
|
+
}
|
|
153
|
+
function _non_iterable_rest() {
|
|
154
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
155
|
+
}
|
|
156
|
+
function _non_iterable_spread() {
|
|
157
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
158
|
+
}
|
|
159
|
+
function _object_spread(target) {
|
|
160
|
+
for(var i = 1; i < arguments.length; i++){
|
|
161
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
162
|
+
var ownKeys = Object.keys(source);
|
|
163
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
164
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
165
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
166
|
+
}));
|
|
167
|
+
}
|
|
168
|
+
ownKeys.forEach(function(key) {
|
|
169
|
+
_define_property(target, key, source[key]);
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
return target;
|
|
173
|
+
}
|
|
174
|
+
function ownKeys(object, enumerableOnly) {
|
|
175
|
+
var keys = Object.keys(object);
|
|
176
|
+
if (Object.getOwnPropertySymbols) {
|
|
177
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
178
|
+
if (enumerableOnly) {
|
|
179
|
+
symbols = symbols.filter(function(sym) {
|
|
180
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
keys.push.apply(keys, symbols);
|
|
184
|
+
}
|
|
185
|
+
return keys;
|
|
186
|
+
}
|
|
187
|
+
function _object_spread_props(target, source) {
|
|
188
|
+
source = source != null ? source : {};
|
|
189
|
+
if (Object.getOwnPropertyDescriptors) {
|
|
190
|
+
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
191
|
+
} else {
|
|
192
|
+
ownKeys(Object(source)).forEach(function(key) {
|
|
193
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
return target;
|
|
197
|
+
}
|
|
198
|
+
function _possible_constructor_return(self, call) {
|
|
199
|
+
if (call && (_type_of(call) === "object" || typeof call === "function")) {
|
|
200
|
+
return call;
|
|
201
|
+
}
|
|
202
|
+
return _assert_this_initialized(self);
|
|
203
|
+
}
|
|
204
|
+
function _set_prototype_of(o, p) {
|
|
205
|
+
_set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
|
|
206
|
+
o.__proto__ = p;
|
|
207
|
+
return o;
|
|
208
|
+
};
|
|
209
|
+
return _set_prototype_of(o, p);
|
|
210
|
+
}
|
|
211
|
+
function _sliced_to_array(arr, i) {
|
|
212
|
+
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
213
|
+
}
|
|
214
|
+
function _to_consumable_array(arr) {
|
|
215
|
+
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
216
|
+
}
|
|
217
|
+
function _type_of(obj) {
|
|
218
|
+
"@swc/helpers - typeof";
|
|
219
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
220
|
+
}
|
|
221
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
222
|
+
if (!o) return;
|
|
223
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
224
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
225
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
226
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
227
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
228
|
+
}
|
|
229
|
+
function _is_native_reflect_construct() {
|
|
230
|
+
try {
|
|
231
|
+
var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
232
|
+
} catch (_) {}
|
|
233
|
+
return (_is_native_reflect_construct = function() {
|
|
234
|
+
return !!result;
|
|
235
|
+
})();
|
|
236
|
+
}
|
|
237
|
+
function _ts_generator(thisArg, body) {
|
|
238
|
+
var f, y, t, _ = {
|
|
239
|
+
label: 0,
|
|
240
|
+
sent: function() {
|
|
241
|
+
if (t[0] & 1) throw t[1];
|
|
242
|
+
return t[1];
|
|
243
|
+
},
|
|
244
|
+
trys: [],
|
|
245
|
+
ops: []
|
|
246
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
|
|
247
|
+
return d(g, "next", {
|
|
248
|
+
value: verb(0)
|
|
249
|
+
}), d(g, "throw", {
|
|
250
|
+
value: verb(1)
|
|
251
|
+
}), d(g, "return", {
|
|
252
|
+
value: verb(2)
|
|
253
|
+
}), typeof Symbol === "function" && d(g, Symbol.iterator, {
|
|
254
|
+
value: function() {
|
|
255
|
+
return this;
|
|
256
|
+
}
|
|
257
|
+
}), g;
|
|
258
|
+
function verb(n) {
|
|
259
|
+
return function(v) {
|
|
260
|
+
return step([
|
|
261
|
+
n,
|
|
262
|
+
v
|
|
263
|
+
]);
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
function step(op) {
|
|
267
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
268
|
+
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
269
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
270
|
+
if (y = 0, t) op = [
|
|
271
|
+
op[0] & 2,
|
|
272
|
+
t.value
|
|
273
|
+
];
|
|
274
|
+
switch(op[0]){
|
|
275
|
+
case 0:
|
|
276
|
+
case 1:
|
|
277
|
+
t = op;
|
|
278
|
+
break;
|
|
279
|
+
case 4:
|
|
280
|
+
_.label++;
|
|
281
|
+
return {
|
|
282
|
+
value: op[1],
|
|
283
|
+
done: false
|
|
284
|
+
};
|
|
285
|
+
case 5:
|
|
286
|
+
_.label++;
|
|
287
|
+
y = op[1];
|
|
288
|
+
op = [
|
|
289
|
+
0
|
|
290
|
+
];
|
|
291
|
+
continue;
|
|
292
|
+
case 7:
|
|
293
|
+
op = _.ops.pop();
|
|
294
|
+
_.trys.pop();
|
|
295
|
+
continue;
|
|
296
|
+
default:
|
|
297
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
298
|
+
_ = 0;
|
|
299
|
+
continue;
|
|
300
|
+
}
|
|
301
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
302
|
+
_.label = op[1];
|
|
303
|
+
break;
|
|
304
|
+
}
|
|
305
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
306
|
+
_.label = t[1];
|
|
307
|
+
t = op;
|
|
308
|
+
break;
|
|
309
|
+
}
|
|
310
|
+
if (t && _.label < t[2]) {
|
|
311
|
+
_.label = t[2];
|
|
312
|
+
_.ops.push(op);
|
|
313
|
+
break;
|
|
314
|
+
}
|
|
315
|
+
if (t[2]) _.ops.pop();
|
|
316
|
+
_.trys.pop();
|
|
317
|
+
continue;
|
|
318
|
+
}
|
|
319
|
+
op = body.call(thisArg, _);
|
|
320
|
+
} catch (e) {
|
|
321
|
+
op = [
|
|
322
|
+
6,
|
|
323
|
+
e
|
|
324
|
+
];
|
|
325
|
+
y = 0;
|
|
326
|
+
} finally{
|
|
327
|
+
f = t = 0;
|
|
328
|
+
}
|
|
329
|
+
if (op[0] & 5) throw op[1];
|
|
330
|
+
return {
|
|
331
|
+
value: op[0] ? op[1] : void 0,
|
|
332
|
+
done: true
|
|
333
|
+
};
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
function _ts_values(o) {
|
|
337
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
338
|
+
if (m) return m.call(o);
|
|
339
|
+
if (o && typeof o.length === "number") return {
|
|
340
|
+
next: function() {
|
|
341
|
+
if (o && i >= o.length) o = void 0;
|
|
342
|
+
return {
|
|
343
|
+
value: o && o[i++],
|
|
344
|
+
done: !o
|
|
345
|
+
};
|
|
346
|
+
}
|
|
347
|
+
};
|
|
348
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
349
|
+
}
|
|
350
|
+
// src/class/snack.tsx
|
|
351
|
+
import React3, { useState } from "react";
|
|
352
|
+
import { DeepClone } from "@snack-kit/lib";
|
|
353
|
+
// src/utils/common.tsx
|
|
354
|
+
import React from "react";
|
|
355
|
+
var GetLanguage = function GetLanguage1() {
|
|
356
|
+
return window.localStorage.getItem("language") || "zh";
|
|
357
|
+
};
|
|
358
|
+
function i18nIntl(sdk, ops, i18nData, params, lang, defI18nData) {
|
|
359
|
+
var locale2 = getLocale(sdk, lang);
|
|
360
|
+
var text2, key;
|
|
361
|
+
if (typeof ops === "string") {
|
|
362
|
+
key = ops;
|
|
363
|
+
} else if ((typeof ops === "undefined" ? "undefined" : _type_of(ops)) === "object") {
|
|
364
|
+
if (typeof ops.id !== "string") return 'i18n intl object "id" is missing';
|
|
365
|
+
key = ops.id;
|
|
366
|
+
}
|
|
367
|
+
if (key !== void 0) {
|
|
368
|
+
var data = i18nData[locale2] || i18nData[sdk.localeDefault];
|
|
369
|
+
if ((typeof data === "undefined" ? "undefined" : _type_of(data)) === "object") text2 = data[key];
|
|
370
|
+
if (text2 === void 0 && defI18nData) {
|
|
371
|
+
var _defI18nData_locale2, _defI18nData_sdk_localeDefault;
|
|
372
|
+
text2 = ((_defI18nData_locale2 = defI18nData[locale2]) === null || _defI18nData_locale2 === void 0 ? void 0 : _defI18nData_locale2[key]) || ((_defI18nData_sdk_localeDefault = defI18nData[sdk.localeDefault]) === null || _defI18nData_sdk_localeDefault === void 0 ? void 0 : _defI18nData_sdk_localeDefault[key]);
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
if (typeof text2 !== "string") return "{".concat(key, "}");
|
|
376
|
+
return replaceStrTemplateVars(text2, params);
|
|
377
|
+
}
|
|
378
|
+
function getLocale(sdk, lang) {
|
|
379
|
+
var localeMapping = sdk === null || sdk === void 0 ? void 0 : sdk.localeMapping;
|
|
380
|
+
var locale2 = lang || GetLanguage();
|
|
381
|
+
if (!localeMapping) return locale2;
|
|
382
|
+
if (localeMapping[locale2] !== void 0) return localeMapping[locale2];
|
|
383
|
+
return locale2;
|
|
384
|
+
}
|
|
385
|
+
var get = function get1(obj, path, defaultValue) {
|
|
386
|
+
var pathArr = path.replace(/\[(\d+)\]/g, ".$1").split(".");
|
|
387
|
+
var result = obj;
|
|
388
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
389
|
+
try {
|
|
390
|
+
for(var _iterator = pathArr[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
391
|
+
var p = _step.value;
|
|
392
|
+
result = Object(result)[p];
|
|
393
|
+
if (result === void 0) {
|
|
394
|
+
return defaultValue;
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
} catch (err) {
|
|
398
|
+
_didIteratorError = true;
|
|
399
|
+
_iteratorError = err;
|
|
400
|
+
} finally{
|
|
401
|
+
try {
|
|
402
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
403
|
+
_iterator.return();
|
|
404
|
+
}
|
|
405
|
+
} finally{
|
|
406
|
+
if (_didIteratorError) {
|
|
407
|
+
throw _iteratorError;
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
return result;
|
|
412
|
+
};
|
|
413
|
+
var replaceStrTemplateVars = function replaceStrTemplateVars1(str, vars) {
|
|
414
|
+
if (!vars) return str;
|
|
415
|
+
str = str.replace(/\"/g, '\\"');
|
|
416
|
+
var strTemplateReg = /({[^{}]+})/g;
|
|
417
|
+
var parts = str.split(strTemplateReg);
|
|
418
|
+
var isJsx = false;
|
|
419
|
+
var valArr = parts.map(function(part) {
|
|
420
|
+
if (part.match(strTemplateReg)) {
|
|
421
|
+
var key = part.replace(/({|})/g, "");
|
|
422
|
+
var val = get(vars, key);
|
|
423
|
+
if (val && (typeof val === "undefined" ? "undefined" : _type_of(val)) === "object" && "$$typeof" in val) isJsx = true;
|
|
424
|
+
return val === void 0 ? key : val;
|
|
425
|
+
}
|
|
426
|
+
return part;
|
|
427
|
+
});
|
|
428
|
+
if (valArr.length && isJsx) return /* @__PURE__ */ React.createElement(React.Fragment, null, valArr);
|
|
429
|
+
return valArr.join("");
|
|
430
|
+
};
|
|
431
|
+
var isEmptyObject = function isEmptyObject1(value) {
|
|
432
|
+
if (value && (typeof value === "undefined" ? "undefined" : _type_of(value)) === "object") {
|
|
433
|
+
try {
|
|
434
|
+
var val = JSON.stringify(value);
|
|
435
|
+
if (val === "[]" || val === "{}") return true;
|
|
436
|
+
} catch (e) {}
|
|
437
|
+
}
|
|
438
|
+
return false;
|
|
439
|
+
};
|
|
440
|
+
// src/utils/evalJS.ts
|
|
441
|
+
import React2 from "react";
|
|
442
|
+
import * as http from "@snack-kit/lib";
|
|
443
|
+
import * as utils from "@snack-kit/lib";
|
|
444
|
+
var types = {
|
|
445
|
+
// 自定义入参转换脚本参数
|
|
446
|
+
inFormatJS: [
|
|
447
|
+
"$verify"
|
|
448
|
+
],
|
|
449
|
+
// 自定义出参转换脚本参数
|
|
450
|
+
outFormatJS: [
|
|
451
|
+
"$verify"
|
|
452
|
+
],
|
|
453
|
+
// 自定义校验脚本参数
|
|
454
|
+
verifyJS: [
|
|
455
|
+
"$cb"
|
|
456
|
+
],
|
|
457
|
+
// 自定义事件脚本
|
|
458
|
+
eventJS: [
|
|
459
|
+
"$verify"
|
|
460
|
+
],
|
|
461
|
+
// 初始化之前事件
|
|
462
|
+
onCreateBefore: [
|
|
463
|
+
"$defaultStyle",
|
|
464
|
+
"$defaultDisplay",
|
|
465
|
+
"$defaultModuleData"
|
|
466
|
+
]
|
|
467
|
+
};
|
|
468
|
+
var defTypes = [
|
|
469
|
+
"$this",
|
|
470
|
+
"$key",
|
|
471
|
+
"$field",
|
|
472
|
+
"$fields",
|
|
473
|
+
"$children",
|
|
474
|
+
"$value",
|
|
475
|
+
"$defaultValue",
|
|
476
|
+
"$defaultData",
|
|
477
|
+
"$val",
|
|
478
|
+
"$getData",
|
|
479
|
+
"$display",
|
|
480
|
+
"$disable",
|
|
481
|
+
"$http",
|
|
482
|
+
"$utils",
|
|
483
|
+
"$message"
|
|
484
|
+
];
|
|
485
|
+
function evalJS_default(type, code, data) {
|
|
486
|
+
try {
|
|
487
|
+
var _M_data_formAttr, _M_data, _$fields_$field_D_data, _$fields_$field_D, _$fields_$field, _M_data1, _M_data2;
|
|
488
|
+
var M = data.$this;
|
|
489
|
+
var $field = M === null || M === void 0 ? void 0 : (_M_data = M.data) === null || _M_data === void 0 ? void 0 : (_M_data_formAttr = _M_data.formAttr) === null || _M_data_formAttr === void 0 ? void 0 : _M_data_formAttr.field;
|
|
490
|
+
var $fields = data.$fields;
|
|
491
|
+
var $verify = data.$verify;
|
|
492
|
+
var $children = data.$children;
|
|
493
|
+
var $message = data.$message;
|
|
494
|
+
var params = types[type];
|
|
495
|
+
if (!params) return console.error("SnackCore: the type(".concat(type, ") is unrealized"));
|
|
496
|
+
var evalArgs = _to_consumable_array(params).concat(_to_consumable_array(defTypes));
|
|
497
|
+
var evalFunc2 = _construct(Function, _to_consumable_array(evalArgs).concat([
|
|
498
|
+
" with (".concat(evalArgs.join(", "), ") {\n ").concat(code, "\n }")
|
|
499
|
+
]));
|
|
500
|
+
var args = [];
|
|
501
|
+
for(var i = 0, l = params.length; i < l; i++){
|
|
502
|
+
var param = params[i];
|
|
503
|
+
args[i] = data[param] || null;
|
|
504
|
+
}
|
|
505
|
+
var getModule = function getModule(key) {
|
|
506
|
+
return $fields[key] || $children[key];
|
|
507
|
+
};
|
|
508
|
+
args.push(M);
|
|
509
|
+
args.push($field && ((_$fields_$field = $fields[$field]) === null || _$fields_$field === void 0 ? void 0 : (_$fields_$field_D = _$fields_$field.D) === null || _$fields_$field_D === void 0 ? void 0 : (_$fields_$field_D_data = _$fields_$field_D.data) === null || _$fields_$field_D_data === void 0 ? void 0 : _$fields_$field_D_data.key));
|
|
510
|
+
args.push($field);
|
|
511
|
+
args.push($fields);
|
|
512
|
+
args.push($children);
|
|
513
|
+
args.push(M === null || M === void 0 ? void 0 : (_M_data1 = M.data) === null || _M_data1 === void 0 ? void 0 : _M_data1.value);
|
|
514
|
+
args.push(M === null || M === void 0 ? void 0 : (_M_data2 = M.data) === null || _M_data2 === void 0 ? void 0 : _M_data2.__defaultvalue);
|
|
515
|
+
args.push(data.$defaultData);
|
|
516
|
+
args.push(function(key, value) {
|
|
517
|
+
return $val(getModule(key), value, $verify);
|
|
518
|
+
});
|
|
519
|
+
args.push(function(key) {
|
|
520
|
+
var _getModule_M, _getModule;
|
|
521
|
+
return (_getModule = getModule(key)) === null || _getModule === void 0 ? void 0 : (_getModule_M = _getModule.M) === null || _getModule_M === void 0 ? void 0 : _getModule_M.data;
|
|
522
|
+
});
|
|
523
|
+
args.push(function(key) {
|
|
524
|
+
var show = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : true;
|
|
525
|
+
return $display(getModule(key), show);
|
|
526
|
+
});
|
|
527
|
+
args.push(function(key) {
|
|
528
|
+
var disable = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : true;
|
|
529
|
+
return $disable(getModule(key), disable);
|
|
530
|
+
});
|
|
531
|
+
args.push(http);
|
|
532
|
+
args.push(utils);
|
|
533
|
+
args.push($message);
|
|
534
|
+
return evalFunc2.apply(window, args);
|
|
535
|
+
} catch (err) {
|
|
536
|
+
console.error("`SnackCore: run js error", err);
|
|
537
|
+
}
|
|
538
|
+
return null;
|
|
539
|
+
}
|
|
540
|
+
function $val(child, value, verify) {
|
|
541
|
+
var _M_data_formAttr, _M_data;
|
|
542
|
+
if (!child) return void 0;
|
|
543
|
+
var M = child.M;
|
|
544
|
+
if (value === void 0) return M.data.value;
|
|
545
|
+
if (M.data.value === value) return M.data.value;
|
|
546
|
+
M.data.value = value;
|
|
547
|
+
M.$forceUpdate();
|
|
548
|
+
if (verify) verify((_M_data = M.data) === null || _M_data === void 0 ? void 0 : (_M_data_formAttr = _M_data.formAttr) === null || _M_data_formAttr === void 0 ? void 0 : _M_data_formAttr.field);
|
|
549
|
+
return value;
|
|
550
|
+
}
|
|
551
|
+
function $display(child) {
|
|
552
|
+
var show = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : true;
|
|
553
|
+
if (!child) return child;
|
|
554
|
+
if (show) {
|
|
555
|
+
if (child.D.data.style.display !== "none") return child;
|
|
556
|
+
if (child.D.__display__ !== void 0) {
|
|
557
|
+
child.D.data.style.display = child.D.__display__;
|
|
558
|
+
delete child.D.__display__;
|
|
559
|
+
} else child.D.data.style.display = "block";
|
|
560
|
+
if (child.M.__disabled__ !== void 0) {
|
|
561
|
+
child.M.data.formAttr.disabled = child.M.__disabled__;
|
|
562
|
+
delete child.M.__disabled__;
|
|
563
|
+
} else if (child.M.data.formAttr) child.M.data.formAttr.disabled = false;
|
|
564
|
+
} else {
|
|
565
|
+
if (child.D.data.style.display === "none") return child;
|
|
566
|
+
child.D.__display__ = child.D.data.style.display;
|
|
567
|
+
child.D.data.style.display = "none";
|
|
568
|
+
if (child.M.data.formAttr && child.M.data.formAttr.disabled !== void 0) {
|
|
569
|
+
child.M.__disabled__ = child.M.data.formAttr.disabled;
|
|
570
|
+
child.M.data.formAttr.disabled = true;
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
child.D.$forceUpdate();
|
|
574
|
+
return child;
|
|
575
|
+
}
|
|
576
|
+
var DisplayModule = $display;
|
|
577
|
+
function $disable(child) {
|
|
578
|
+
var disabled = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
|
|
579
|
+
var _child_M_data, _child_M;
|
|
580
|
+
if (!child) return child;
|
|
581
|
+
if ((_child_M = child.M) === null || _child_M === void 0 ? void 0 : (_child_M_data = _child_M.data) === null || _child_M_data === void 0 ? void 0 : _child_M_data.formAttr) {
|
|
582
|
+
child.M.data.formAttr.disabled = disabled;
|
|
583
|
+
child.M.$forceUpdate();
|
|
584
|
+
}
|
|
585
|
+
return child;
|
|
586
|
+
}
|
|
587
|
+
var GetParamsDetails = function GetParamsDetails1(monaco, event, locale2) {
|
|
588
|
+
var _ParamsDetails = locale2 === "en-US" ? enParamsDetails : ParamsDetails;
|
|
589
|
+
var list = [];
|
|
590
|
+
for(var i = 0, l = _ParamsDetails.length; i < l; i++){
|
|
591
|
+
var _monaco_languages_CompletionItemKind, _monaco_languages;
|
|
592
|
+
var item = _ParamsDetails[i];
|
|
593
|
+
if (event) {
|
|
594
|
+
if (item.filterEvents && item.filterEvents.indexOf(event) !== -1) continue;
|
|
595
|
+
if (item.events && item.events.indexOf(event) === -1) continue;
|
|
596
|
+
}
|
|
597
|
+
list.push({
|
|
598
|
+
label: item.label,
|
|
599
|
+
insertText: item.insertText,
|
|
600
|
+
detail: item.detail,
|
|
601
|
+
documentation: item.documentation,
|
|
602
|
+
kind: monaco === null || monaco === void 0 ? void 0 : (_monaco_languages = monaco.languages) === null || _monaco_languages === void 0 ? void 0 : (_monaco_languages_CompletionItemKind = _monaco_languages.CompletionItemKind) === null || _monaco_languages_CompletionItemKind === void 0 ? void 0 : _monaco_languages_CompletionItemKind["Keyword"]
|
|
603
|
+
});
|
|
604
|
+
}
|
|
605
|
+
return list;
|
|
606
|
+
};
|
|
607
|
+
window.GetParamsDetails = GetParamsDetails;
|
|
608
|
+
var ParamsDetails = [
|
|
609
|
+
{
|
|
610
|
+
label: "$this",
|
|
611
|
+
insertText: "$this",
|
|
612
|
+
detail: "\u5F53\u524D\u9009\u4E2D\u7684\u7EC4\u4EF6\u5BF9\u8C61,\uFF08\u5F53\u5728onCreateBefore\u4E8B\u4EF6\u65F6\uFF0C\u8BE5\u5BF9\u8C61\u4EC5\u53EA\u6709\u5165\u53C2\u6570\u636E\uFF0C\u5E76\u4E0D\u662F\u4E00\u4E2A\u7EC4\u4EF6\u5B9E\u4F8B\uFF09"
|
|
613
|
+
},
|
|
614
|
+
{
|
|
615
|
+
filterEvents: [
|
|
616
|
+
"onCreateBefore"
|
|
617
|
+
],
|
|
618
|
+
label: "$key",
|
|
619
|
+
insertText: "$key",
|
|
620
|
+
detail: "\u5F53\u524D\u9009\u4E2D\u7EC4\u4EF6\u7684\u552F\u4E00key\u503C"
|
|
621
|
+
},
|
|
622
|
+
{
|
|
623
|
+
label: "$field",
|
|
624
|
+
insertText: "$field",
|
|
625
|
+
detail: "\u5F53\u524D\u9009\u4E2D\u7EC4\u4EF6\u6240\u7ED1\u5B9A\u5B57\u6BB5\u540D"
|
|
626
|
+
},
|
|
627
|
+
{
|
|
628
|
+
label: "$fields",
|
|
629
|
+
insertText: "$fields",
|
|
630
|
+
detail: "\u5F53\u524D\u8868\u5355\u6240\u6709\u5B57\u6BB5\u4E0E\u7EC4\u4EF6\u5BF9\u8C61\u7684\u952E\u503C\u5BF9"
|
|
631
|
+
},
|
|
632
|
+
{
|
|
633
|
+
label: "$children",
|
|
634
|
+
insertText: "$children",
|
|
635
|
+
detail: "\u5F53\u524D\u9875\u9762\u6240\u6709\u5143\u7D20\u7684\u5BF9\u8C61\u952E\u503C\u5BF9"
|
|
636
|
+
},
|
|
637
|
+
{
|
|
638
|
+
filterEvents: [
|
|
639
|
+
"onCreateBefore"
|
|
640
|
+
],
|
|
641
|
+
label: "$verify",
|
|
642
|
+
insertText: '$verify("")',
|
|
643
|
+
detail: '\u5B57\u6BB5\u6821\u9A8C\u65B9\u6CD5\uFF0C\u6307\u5B9A\u6821\u9A8C\u67D0\u4E2A\u5B57\u6BB5\uFF1A$verify("$field")\uFF0C\u5426\u5219\u5168\u91CF\u5B57\u6BB5\u6821\u9A8C\uFF08\u81EA\u5B9A\u4E49\u6821\u9A8C\u811A\u672C\u8BE5\u65B9\u6CD5\u65E0\u6548\uFF09'
|
|
644
|
+
},
|
|
645
|
+
{
|
|
646
|
+
events: [
|
|
647
|
+
"verifyJS"
|
|
648
|
+
],
|
|
649
|
+
label: "$cb",
|
|
650
|
+
insertText: '$cb({error: true, helperText: "error msg"})',
|
|
651
|
+
detail: "\u6821\u9A8C\u5B8C\u6210\u7684\u56DE\u8C03\u51FD\u6570\uFF08\u4EC5\u81EA\u5B9A\u6821\u9A8C\u811A\u672C\u6709\u6548\uFF09"
|
|
652
|
+
},
|
|
653
|
+
{
|
|
654
|
+
label: "$value",
|
|
655
|
+
insertText: "$value",
|
|
656
|
+
detail: "\u5F53\u524D\u7EC4\u4EF6\u7684value\u503C"
|
|
657
|
+
},
|
|
658
|
+
{
|
|
659
|
+
label: "$defaultValue",
|
|
660
|
+
insertText: "$defaultValue",
|
|
661
|
+
detail: "\u5F53\u524D\u7EC4\u4EF6\u521D\u59CB\u7684value\u503C"
|
|
662
|
+
},
|
|
663
|
+
{
|
|
664
|
+
label: "$defaultData",
|
|
665
|
+
insertText: "$defaultData",
|
|
666
|
+
detail: "\u5F53\u524D\u8868\u5355\u521D\u59CB\u4F20\u5165\u7684data\u6570\u636E\u586B\u5145\u5BF9\u8C61"
|
|
667
|
+
},
|
|
668
|
+
{
|
|
669
|
+
label: "$val",
|
|
670
|
+
insertText: '$val("")',
|
|
671
|
+
detail: "\u6307\u5B9A\u83B7\u53D6\u7EC4\u4EF6\u6216\u8BBE\u7F6E\u7EC4\u4EF6\u7684value\u503C",
|
|
672
|
+
documentation: "\u83B7\u53D6\u7EC4\u4EF6\u503C\uFF1A $val(key)\uFF1B\u8BBE\u7F6E\u7EC4\u4EF6\u503C\uFF1A$val(key, value);"
|
|
673
|
+
},
|
|
674
|
+
{
|
|
675
|
+
label: "$getData",
|
|
676
|
+
insertText: '$getData("")',
|
|
677
|
+
detail: "\u83B7\u53D6\u6307\u5B9A\u5B57\u6BB5\u7EC4\u4EF6\u7684data\u5BF9\u8C61",
|
|
678
|
+
documentation: "$val(key, value)"
|
|
679
|
+
},
|
|
680
|
+
{
|
|
681
|
+
label: "$display",
|
|
682
|
+
insertText: '$display("", true);',
|
|
683
|
+
detail: "\u6307\u5B9A\u5B57\u6BB5\u7684\u7EC4\u4EF6\u662F\u5426\u663E\u793A",
|
|
684
|
+
documentation: "\u663E\u793A\u7EC4\u4EF6\uFF1A$display(key, true)\uFF1B\u9690\u85CF\u7EC4\u4EF6\uFF1A$display(key, false)"
|
|
685
|
+
},
|
|
686
|
+
{
|
|
687
|
+
label: "$disable",
|
|
688
|
+
insertText: '$disable("", true);',
|
|
689
|
+
detail: "\u6307\u5B9A\u8BBE\u7F6E\u652F\u6301\u7981\u7528\u529F\u80FD\u7684\u7EC4\u4EF6\u72B6\u6001",
|
|
690
|
+
documentation: "\u7981\u7528\u7EC4\u4EF6\uFF1A$disable(key, true)\uFF1B\u53D6\u6D88\u7981\u7528\uFF1A$disable(key, false)"
|
|
691
|
+
},
|
|
692
|
+
{
|
|
693
|
+
label: "$http",
|
|
694
|
+
insertText: "$http",
|
|
695
|
+
detail: "paralib http\u8BF7\u6C42\u6A21\u5757"
|
|
696
|
+
},
|
|
697
|
+
{
|
|
698
|
+
label: "$utils",
|
|
699
|
+
insertText: "$utils",
|
|
700
|
+
detail: "paralib \u5DE5\u5177\u65B9\u6CD5\u6A21\u5757"
|
|
701
|
+
},
|
|
702
|
+
{
|
|
703
|
+
label: "$message",
|
|
704
|
+
insertText: "$message",
|
|
705
|
+
detail: "paraUi message\u63D0\u793A\u7EC4\u4EF6,\u9700\u5728\u521D\u59CB\u5316sdk\u65F6\u4F20\u5165message\u5BF9\u8C61\u65B9\u53EF\u4F7F\u7528"
|
|
706
|
+
},
|
|
707
|
+
{
|
|
708
|
+
events: [
|
|
709
|
+
"onCreateBefore"
|
|
710
|
+
],
|
|
711
|
+
label: "$defaultModuleData",
|
|
712
|
+
insertText: "$defaultModuleData",
|
|
713
|
+
detail: "\u9ED8\u8BA4\u5F53\u524D\u7EC4\u4EF6\u521D\u59CB\u5316\u53C2\u6570\u5BF9\u8C61\uFF0C\u4EC5onCreateBefore\u4E8B\u4EF6\u6709\u6548"
|
|
714
|
+
},
|
|
715
|
+
{
|
|
716
|
+
events: [
|
|
717
|
+
"onCreateBefore"
|
|
718
|
+
],
|
|
719
|
+
label: "$defaultStyle",
|
|
720
|
+
insertText: "$defaultStyle",
|
|
721
|
+
detail: "\u9ED8\u8BA4\u5F53\u524D\u7EC4\u4EF6\u6E32\u67D3\u6837\u5F0F\u5BF9\u8C61\uFF0C\u4EC5onCreateBefore\u4E8B\u4EF6\u6709\u6548"
|
|
722
|
+
},
|
|
723
|
+
{
|
|
724
|
+
events: [
|
|
725
|
+
"onCreateBefore"
|
|
726
|
+
],
|
|
727
|
+
label: "$defaultDisplay",
|
|
728
|
+
insertText: "$defaultDisplay(true);",
|
|
729
|
+
detail: "\u9ED8\u8BA4\u5F53\u524D\u7EC4\u4EF6\u663E\u793A\u6216\u5F71\u85CF\u72B6\u6001\u8BBE\u7F6E\uFF0C\u4EC5onCreateBefore\u4E8B\u4EF6\u6709\u6548",
|
|
730
|
+
documentation: "\u9ED8\u8BA4\u663E\u793A\u7EC4\u4EF6\uFF1A$defaultDisplay(true)\uFF1B\u9690\u85CF\u7EC4\u4EF6\uFF1A$defaultDisplay(false);"
|
|
731
|
+
}
|
|
732
|
+
];
|
|
733
|
+
var enParamsDetails = [
|
|
734
|
+
{
|
|
735
|
+
label: "$this",
|
|
736
|
+
insertText: "$this",
|
|
737
|
+
detail: "current component object, (when in onCreateBefore event, this object only has input data, not a component instance)"
|
|
738
|
+
},
|
|
739
|
+
{
|
|
740
|
+
filterEvents: [
|
|
741
|
+
"onCreateBefore"
|
|
742
|
+
],
|
|
743
|
+
label: "$key",
|
|
744
|
+
insertText: "$key",
|
|
745
|
+
detail: "unique key of current component"
|
|
746
|
+
},
|
|
747
|
+
{
|
|
748
|
+
label: "$field",
|
|
749
|
+
insertText: "$field",
|
|
750
|
+
detail: "The name of the field bound to the currently selected component"
|
|
751
|
+
},
|
|
752
|
+
{
|
|
753
|
+
label: "$fields",
|
|
754
|
+
insertText: "$fields",
|
|
755
|
+
detail: "field name bound to current component"
|
|
756
|
+
},
|
|
757
|
+
{
|
|
758
|
+
label: "$children",
|
|
759
|
+
insertText: "$children",
|
|
760
|
+
detail: "key-value pairs of all elements in current page"
|
|
761
|
+
},
|
|
762
|
+
{
|
|
763
|
+
filterEvents: [
|
|
764
|
+
"onCreateBefore"
|
|
765
|
+
],
|
|
766
|
+
label: "$verify",
|
|
767
|
+
insertText: '$verify("")',
|
|
768
|
+
detail: 'field validation method, specify validation for a field: $verify("$field"), otherwise validate all fields (custom validation script invalid for this method)'
|
|
769
|
+
},
|
|
770
|
+
{
|
|
771
|
+
events: [
|
|
772
|
+
"verifyJS"
|
|
773
|
+
],
|
|
774
|
+
label: "$cb",
|
|
775
|
+
insertText: '$cb({error: true, helperText: "error msg"})',
|
|
776
|
+
detail: "Verified callback function (only custom verification scripts are valid)"
|
|
777
|
+
},
|
|
778
|
+
{
|
|
779
|
+
label: "$value",
|
|
780
|
+
insertText: "$value",
|
|
781
|
+
detail: "The value of the current component"
|
|
782
|
+
},
|
|
783
|
+
{
|
|
784
|
+
label: "$defaultValue",
|
|
785
|
+
insertText: "$defaultValue",
|
|
786
|
+
detail: "The initial value of the current component"
|
|
787
|
+
},
|
|
788
|
+
{
|
|
789
|
+
label: "$defaultData",
|
|
790
|
+
insertText: "$defaultData",
|
|
791
|
+
detail: "The data data that is initially passed in to fill the object of the current form"
|
|
792
|
+
},
|
|
793
|
+
{
|
|
794
|
+
label: "$val",
|
|
795
|
+
insertText: '$val("")',
|
|
796
|
+
detail: "Specify the value of the component to be obtained or set",
|
|
797
|
+
documentation: "Get component value: $val (key); Set component value: $val (key, value);"
|
|
798
|
+
},
|
|
799
|
+
{
|
|
800
|
+
label: "$getData",
|
|
801
|
+
insertText: '$getData("")',
|
|
802
|
+
detail: "Obtain the data object of the specified field component",
|
|
803
|
+
documentation: "$val(key, value)"
|
|
804
|
+
},
|
|
805
|
+
{
|
|
806
|
+
label: "$display",
|
|
807
|
+
insertText: '$display("", true);',
|
|
808
|
+
detail: "Specifies whether the portlet of the field is displayed",
|
|
809
|
+
documentation: "Display component: $display (key, true); Hidden component: $display (key, false)"
|
|
810
|
+
},
|
|
811
|
+
{
|
|
812
|
+
label: "$disable",
|
|
813
|
+
insertText: '$disable("", true);',
|
|
814
|
+
detail: "Specifies the status of the component that sets the support for disabling the feature",
|
|
815
|
+
documentation: "Disable component: $disable(key, true); Disable: $disable (key, false)"
|
|
816
|
+
},
|
|
817
|
+
{
|
|
818
|
+
label: "$http",
|
|
819
|
+
insertText: "$http",
|
|
820
|
+
detail: "paralib http request module"
|
|
821
|
+
},
|
|
822
|
+
{
|
|
823
|
+
label: "$utils",
|
|
824
|
+
insertText: "$utils",
|
|
825
|
+
detail: "paralib tool method module"
|
|
826
|
+
},
|
|
827
|
+
{
|
|
828
|
+
label: "$message",
|
|
829
|
+
insertText: "$message",
|
|
830
|
+
detail: "paraUi message components,You need to pass in a message object when initializing the SDK to use it"
|
|
831
|
+
},
|
|
832
|
+
{
|
|
833
|
+
events: [
|
|
834
|
+
"onCreateBefore"
|
|
835
|
+
],
|
|
836
|
+
label: "$defaultModuleData",
|
|
837
|
+
insertText: "$defaultModuleData",
|
|
838
|
+
detail: "By default, the current component initializes the parameter object, and only the onCreateBefore event is valid"
|
|
839
|
+
},
|
|
840
|
+
{
|
|
841
|
+
events: [
|
|
842
|
+
"onCreateBefore"
|
|
843
|
+
],
|
|
844
|
+
label: "$defaultStyle",
|
|
845
|
+
insertText: "$defaultStyle",
|
|
846
|
+
detail: "By default, the current component renders the style object, and only the onCreateBefore event is valid"
|
|
847
|
+
},
|
|
848
|
+
{
|
|
849
|
+
events: [
|
|
850
|
+
"onCreateBefore"
|
|
851
|
+
],
|
|
852
|
+
label: "$defaultDisplay",
|
|
853
|
+
insertText: "$defaultDisplay(true);",
|
|
854
|
+
detail: "By default, the current component display or shadow status is set, and only the onCreateBefore event is valid",
|
|
855
|
+
documentation: "Default display component: $defaultDisplay (true); Hidden component: $defaultDisplay (false);"
|
|
856
|
+
}
|
|
857
|
+
];
|
|
858
|
+
var evalFunc = function evalFunc1(args, code) {
|
|
859
|
+
var isSync = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : false;
|
|
860
|
+
if (_instanceof(args, Array)) args = "{ ".concat(args.join(","), " }");
|
|
861
|
+
if (isSync) {
|
|
862
|
+
var AsyncFunction = Object.getPrototypeOf(function() {
|
|
863
|
+
return _async_to_generator(function() {
|
|
864
|
+
return _ts_generator(this, function(_state) {
|
|
865
|
+
return [
|
|
866
|
+
2
|
|
867
|
+
];
|
|
868
|
+
});
|
|
869
|
+
})();
|
|
870
|
+
}).constructor;
|
|
871
|
+
return new AsyncFunction(args, code);
|
|
872
|
+
} else {
|
|
873
|
+
return new Function(args, code);
|
|
874
|
+
}
|
|
875
|
+
};
|
|
876
|
+
var VerRegx = /(\{\{\s*.*?\s*\}\})/;
|
|
877
|
+
var replaceVars = function replaceVars1(data, srcData) {
|
|
878
|
+
if (!data || (typeof data === "undefined" ? "undefined" : _type_of(data)) !== "object") return srcData;
|
|
879
|
+
var vars = Object.keys(data);
|
|
880
|
+
var ops = {
|
|
881
|
+
vars: vars,
|
|
882
|
+
data: data
|
|
883
|
+
};
|
|
884
|
+
if ((typeof srcData === "undefined" ? "undefined" : _type_of(srcData)) === "object") {
|
|
885
|
+
traversalObject(ops, srcData, [
|
|
886
|
+
srcData
|
|
887
|
+
]);
|
|
888
|
+
return srcData;
|
|
889
|
+
} else if (typeof srcData === "string") return replaceValue(ops, srcData);
|
|
890
|
+
else return srcData;
|
|
891
|
+
};
|
|
892
|
+
function replaceValue(ops, value) {
|
|
893
|
+
try {
|
|
894
|
+
if (!VerRegx.test(value)) return value;
|
|
895
|
+
var vars = ops.vars, data = ops.data;
|
|
896
|
+
var strArr = value.split(VerRegx);
|
|
897
|
+
var jsx = false;
|
|
898
|
+
if (_instanceof(strArr, Array) && strArr.length > 0) {
|
|
899
|
+
for(var i = 0; i < strArr.length; i++){
|
|
900
|
+
var item = strArr[i];
|
|
901
|
+
if (!item || typeof item !== "string") continue;
|
|
902
|
+
var matched = item.match(/\{\{\s*(.*?)\s*\}\}/);
|
|
903
|
+
if (matched && matched[1]) {
|
|
904
|
+
var nv = evalFunc(vars, "try {return ".concat(matched[1], "} catch (err) { console.error('SnackCore replace vars error: ', \"").concat(matched[0], '", err); return }'))(data);
|
|
905
|
+
if (nv !== void 0) {
|
|
906
|
+
if (nv && nv.$$typeof) jsx = true;
|
|
907
|
+
strArr[i] = nv;
|
|
908
|
+
} else {
|
|
909
|
+
console.error('SnackCore replace vars "'.concat(value, '" is undefined'));
|
|
910
|
+
}
|
|
911
|
+
}
|
|
912
|
+
}
|
|
913
|
+
}
|
|
914
|
+
if (jsx) {
|
|
915
|
+
var children = strArr.map(function(item, index) {
|
|
916
|
+
if (typeof item === "string") return item;
|
|
917
|
+
return React2.createElement(React2.Fragment, {
|
|
918
|
+
key: index
|
|
919
|
+
}, item);
|
|
920
|
+
});
|
|
921
|
+
return React2.createElement(React2.Fragment, null, children);
|
|
922
|
+
} else return strArr.join("");
|
|
923
|
+
} catch (err) {
|
|
924
|
+
console.error('SnackCore replace vars("'.concat(value, '") error:'), err);
|
|
925
|
+
return value;
|
|
926
|
+
}
|
|
927
|
+
}
|
|
928
|
+
function traversalObject(ops) {
|
|
929
|
+
var obj = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : null, traversaled = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : [];
|
|
930
|
+
try {
|
|
931
|
+
if (!obj || obj.$$typeof) return;
|
|
932
|
+
for(var key in obj){
|
|
933
|
+
var value = obj[key];
|
|
934
|
+
if ((typeof value === "undefined" ? "undefined" : _type_of(value)) == "object") {
|
|
935
|
+
if (traversaled.indexOf(value) !== -1) continue;
|
|
936
|
+
traversaled.push(value);
|
|
937
|
+
traversalObject(ops, value, traversaled);
|
|
938
|
+
} else if (typeof value === "string") {
|
|
939
|
+
obj[key] = replaceValue(ops, value);
|
|
940
|
+
}
|
|
941
|
+
}
|
|
942
|
+
} catch (err) {
|
|
943
|
+
console.error("SnackCore replace vars traversal error:", err);
|
|
944
|
+
}
|
|
945
|
+
}
|
|
946
|
+
// src/class/snack.tsx
|
|
947
|
+
var Snack = /*#__PURE__*/ function() {
|
|
948
|
+
"use strict";
|
|
949
|
+
function Snack1(data, defData) {
|
|
950
|
+
_class_call_check(this, Snack1);
|
|
951
|
+
var _this_sdk;
|
|
952
|
+
this.data = data;
|
|
953
|
+
/**
|
|
954
|
+
* 当前模块名称
|
|
955
|
+
*/ this.$name = "";
|
|
956
|
+
// 页面事件对象
|
|
957
|
+
/**
|
|
958
|
+
* 当前模块唯一id,每次实例化随机生成
|
|
959
|
+
*/ this.$id = "snack_" + String(Math.random() * 1e7 | 0);
|
|
960
|
+
// 模块实例唯一id 每次new都随机生成
|
|
961
|
+
/**
|
|
962
|
+
* 国际化语言map集合
|
|
963
|
+
*/ this.$i18nMap = {};
|
|
964
|
+
/**
|
|
965
|
+
* 重绘标识,每次 reload 重绘时更新
|
|
966
|
+
*/ this.$forceUpdateId = Math.random();
|
|
967
|
+
/**
|
|
968
|
+
* 是否基础模块
|
|
969
|
+
*/ this.isBasic = false;
|
|
970
|
+
/**
|
|
971
|
+
* 是否容器
|
|
972
|
+
*/ this.isContainer = false;
|
|
973
|
+
/**
|
|
974
|
+
* 是否放置容器
|
|
975
|
+
*/ this.isDrop = false;
|
|
976
|
+
/**
|
|
977
|
+
* 是否拖拽容器
|
|
978
|
+
*/ this.isDrag = false;
|
|
979
|
+
/**
|
|
980
|
+
* 是否页面模版容器
|
|
981
|
+
*/ this.isTemplate = false;
|
|
982
|
+
/**
|
|
983
|
+
* 是否form组件
|
|
984
|
+
*/ this.isForm = false;
|
|
985
|
+
/**
|
|
986
|
+
* 设置模式
|
|
987
|
+
*/ this.settingMode = false;
|
|
988
|
+
/**
|
|
989
|
+
* React组件方法
|
|
990
|
+
* @param data 统一数据管理对象(解构覆盖构造函数data参数)
|
|
991
|
+
* @return FunctionComponent
|
|
992
|
+
*/ this.$lastUpdateId = 0;
|
|
993
|
+
if (data) {
|
|
994
|
+
var _ref;
|
|
995
|
+
var _data_parent;
|
|
996
|
+
if (data["$snackSDK"]) {
|
|
997
|
+
this.sdk = data["$snackSDK"];
|
|
998
|
+
delete data["$snackSDK"];
|
|
999
|
+
} else this.sdk = (_ref = (_data_parent = data.parent) === null || _data_parent === void 0 ? void 0 : _data_parent.sdk) !== null && _ref !== void 0 ? _ref : window.SnackSDK;
|
|
1000
|
+
if (this.sdk) {
|
|
1001
|
+
this.sdk.moduleMaps[this.$id] = this;
|
|
1002
|
+
}
|
|
1003
|
+
if (_type_of(data["$i18n"]) === "object") {
|
|
1004
|
+
this.$i18nMapExternal = data["$i18n"];
|
|
1005
|
+
delete data["$i18n"];
|
|
1006
|
+
}
|
|
1007
|
+
if (defData && _type_of(defData["$i18n"]) === "object") {
|
|
1008
|
+
this.$i18n = defData["$i18n"];
|
|
1009
|
+
delete defData["$i18n"];
|
|
1010
|
+
}
|
|
1011
|
+
if ((typeof defData === "undefined" ? "undefined" : _type_of(defData)) === "object") this.data = _object_spread({}, defData, this.data);
|
|
1012
|
+
} else if ((typeof defData === "undefined" ? "undefined" : _type_of(defData)) === "object") this.data = DeepClone(defData);
|
|
1013
|
+
else this.data = {};
|
|
1014
|
+
if (((_this_sdk = this.sdk) === null || _this_sdk === void 0 ? void 0 : _this_sdk.runtime) === false && this.data) {
|
|
1015
|
+
var _this_sdk1, _this_sdk2;
|
|
1016
|
+
this.props = this.cloneData(this.data);
|
|
1017
|
+
if (this.props) (_this_sdk2 = this.sdk) === null || _this_sdk2 === void 0 ? void 0 : _this_sdk2.recursiveParseJson(this.props, (_this_sdk1 = this.sdk) === null || _this_sdk1 === void 0 ? void 0 : _this_sdk1.getExprArgv({}), true);
|
|
1018
|
+
}
|
|
1019
|
+
}
|
|
1020
|
+
_create_class(Snack1, [
|
|
1021
|
+
{
|
|
1022
|
+
/**
|
|
1023
|
+
* 浅克隆数据对象(JSON可序列化的字段深克隆,不可序列化的字段浅引用)
|
|
1024
|
+
* @param obj 待克隆的数据对象
|
|
1025
|
+
*/ key: "cloneData",
|
|
1026
|
+
value: function cloneData(obj) {
|
|
1027
|
+
if (Array.isArray(obj)) {
|
|
1028
|
+
try {
|
|
1029
|
+
var s2 = JSON.stringify(obj);
|
|
1030
|
+
return JSON.parse(s2);
|
|
1031
|
+
} catch (unused) {
|
|
1032
|
+
return obj;
|
|
1033
|
+
}
|
|
1034
|
+
}
|
|
1035
|
+
var clone = {};
|
|
1036
|
+
var prototype = {};
|
|
1037
|
+
var keys = Object.keys(obj);
|
|
1038
|
+
for(var i = 0; i < keys.length; i++){
|
|
1039
|
+
var key = keys[i];
|
|
1040
|
+
try {
|
|
1041
|
+
var s21 = JSON.stringify(obj[key]);
|
|
1042
|
+
clone[key] = JSON.parse(s21);
|
|
1043
|
+
} catch (unused) {
|
|
1044
|
+
prototype[key] = obj[key];
|
|
1045
|
+
}
|
|
1046
|
+
}
|
|
1047
|
+
return _object_spread({}, clone, prototype);
|
|
1048
|
+
}
|
|
1049
|
+
},
|
|
1050
|
+
{
|
|
1051
|
+
// 上次更新id
|
|
1052
|
+
key: "FC",
|
|
1053
|
+
value: function FC(data) {
|
|
1054
|
+
var _this_sdk;
|
|
1055
|
+
var _useState = _sliced_to_array(useState(0), 2), update = _useState[0], setUpdate = _useState[1];
|
|
1056
|
+
this.$forceUpdateHook = setUpdate;
|
|
1057
|
+
if (this.$lastUpdateId !== update) {
|
|
1058
|
+
if ((typeof data === "undefined" ? "undefined" : _type_of(data)) === "object") {
|
|
1059
|
+
var _this_sdk1;
|
|
1060
|
+
this.data = _object_spread({}, data, this.data);
|
|
1061
|
+
if (((_this_sdk1 = this.sdk) === null || _this_sdk1 === void 0 ? void 0 : _this_sdk1.runtime) === false) this.props = _object_spread({}, data, this.props);
|
|
1062
|
+
}
|
|
1063
|
+
this.$lastUpdateId = update;
|
|
1064
|
+
} else if ((typeof data === "undefined" ? "undefined" : _type_of(data)) === "object") {
|
|
1065
|
+
var _this_sdk2;
|
|
1066
|
+
this.data = _object_spread({}, this.data, data);
|
|
1067
|
+
if (((_this_sdk2 = this.sdk) === null || _this_sdk2 === void 0 ? void 0 : _this_sdk2.runtime) === false) this.props = _object_spread({}, this.props, data);
|
|
1068
|
+
}
|
|
1069
|
+
var props;
|
|
1070
|
+
if (((_this_sdk = this.sdk) === null || _this_sdk === void 0 ? void 0 : _this_sdk.runtime) === false) {
|
|
1071
|
+
if (this.props && this.data && (this.isDrop || this.isDrag)) {
|
|
1072
|
+
if (this.data.parent) this.props.parent = this.data.parent;
|
|
1073
|
+
if (this.data.children) this.props.children = this.data.children;
|
|
1074
|
+
if (this.isDrag && this.data.content) this.props.content = this.data.content;
|
|
1075
|
+
}
|
|
1076
|
+
props = this.props;
|
|
1077
|
+
} else {
|
|
1078
|
+
props = this.data;
|
|
1079
|
+
}
|
|
1080
|
+
return /* @__PURE__ */ React3.createElement(React3.Fragment, {
|
|
1081
|
+
key: this.$forceUpdateId
|
|
1082
|
+
}, this.$component.call(this, props));
|
|
1083
|
+
}
|
|
1084
|
+
},
|
|
1085
|
+
{
|
|
1086
|
+
/**
|
|
1087
|
+
* 模块渲染方法,子类重写此方法实现 UI
|
|
1088
|
+
* @param data 当前数据对象
|
|
1089
|
+
*/ key: "$component",
|
|
1090
|
+
value: function $component(data) {
|
|
1091
|
+
var _this_data;
|
|
1092
|
+
if ("JSX" in this && typeof this.JSX === "function") return /* @__PURE__ */ React3.createElement("h2", null, " JSX \u65B9\u6CD5\u5DF2\u7ECF\u5E9F\u5F03\uFF0C\u8BF7\u4F7F\u7528\u65B0\u65B9\u6CD5 $component \u4EE3\u66FFJSX");
|
|
1093
|
+
return ((_this_data = this.data) === null || _this_data === void 0 ? void 0 : _this_data.jsx) || /* @__PURE__ */ React3.createElement("div", null, "no data");
|
|
1094
|
+
}
|
|
1095
|
+
},
|
|
1096
|
+
{
|
|
1097
|
+
/**
|
|
1098
|
+
* 强制渲染JSX内容
|
|
1099
|
+
* @param reload 是否强制重绘
|
|
1100
|
+
*/ key: "$forceUpdate",
|
|
1101
|
+
value: function $forceUpdate() {
|
|
1102
|
+
var reload = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : false;
|
|
1103
|
+
try {
|
|
1104
|
+
if (typeof this.$forceUpdateHook !== "function") return;
|
|
1105
|
+
if (reload) this.$forceUpdateId = Math.random();
|
|
1106
|
+
this.$forceUpdateHook(Math.random());
|
|
1107
|
+
} catch (e) {
|
|
1108
|
+
console.warn("Snack forceUpdate Error", e);
|
|
1109
|
+
}
|
|
1110
|
+
}
|
|
1111
|
+
},
|
|
1112
|
+
{
|
|
1113
|
+
/**
|
|
1114
|
+
* this.style 样式赋值方法,同时渲染页面
|
|
1115
|
+
* @param key
|
|
1116
|
+
* @param value
|
|
1117
|
+
*/ key: "$style",
|
|
1118
|
+
value: function $style(key, value) {
|
|
1119
|
+
if (!this.data) return {};
|
|
1120
|
+
var style = this.data.style || {};
|
|
1121
|
+
if (key) {
|
|
1122
|
+
if ((typeof key === "undefined" ? "undefined" : _type_of(key)) === "object") {
|
|
1123
|
+
Object.keys(key).forEach(function(css) {
|
|
1124
|
+
style[css] = key[css];
|
|
1125
|
+
});
|
|
1126
|
+
this.$forceUpdate();
|
|
1127
|
+
} else if (typeof key === "string" && value) {
|
|
1128
|
+
style[key] = value;
|
|
1129
|
+
this.$forceUpdate();
|
|
1130
|
+
} else return style[key];
|
|
1131
|
+
}
|
|
1132
|
+
return style;
|
|
1133
|
+
}
|
|
1134
|
+
},
|
|
1135
|
+
{
|
|
1136
|
+
/**
|
|
1137
|
+
* 外部复写,统一销毁方法
|
|
1138
|
+
*/ key: "$destroy",
|
|
1139
|
+
value: function $destroy() {
|
|
1140
|
+
if (!this.sdk) return;
|
|
1141
|
+
delete this.sdk.moduleMaps[this.$id];
|
|
1142
|
+
}
|
|
1143
|
+
},
|
|
1144
|
+
{
|
|
1145
|
+
/**
|
|
1146
|
+
* 国际化切换方法
|
|
1147
|
+
* @param lang 语言
|
|
1148
|
+
*/ key: "$language",
|
|
1149
|
+
value: function $language(lang) {
|
|
1150
|
+
this.$lang = lang;
|
|
1151
|
+
if (this.isDrop || this.isDrag || this.isTemplate) return;
|
|
1152
|
+
this.$forceUpdate(true);
|
|
1153
|
+
}
|
|
1154
|
+
},
|
|
1155
|
+
{
|
|
1156
|
+
key: "$lang",
|
|
1157
|
+
get: function get1() {
|
|
1158
|
+
if (!this.sdk) return window.localStorage.getItem("language") || "zh";
|
|
1159
|
+
return getLocale(this.sdk);
|
|
1160
|
+
},
|
|
1161
|
+
set: function set(lang) {
|
|
1162
|
+
window.localStorage.setItem("language", lang);
|
|
1163
|
+
}
|
|
1164
|
+
},
|
|
1165
|
+
{
|
|
1166
|
+
key: "$i18n",
|
|
1167
|
+
get: /**
|
|
1168
|
+
* 国际化语言包返回
|
|
1169
|
+
*/ function get1() {
|
|
1170
|
+
return this.$i18nMap;
|
|
1171
|
+
},
|
|
1172
|
+
set: /**
|
|
1173
|
+
* 国际化语言包设置
|
|
1174
|
+
* @param map 语言包对象
|
|
1175
|
+
*/ function set(map) {
|
|
1176
|
+
if (!map) return;
|
|
1177
|
+
this.$i18nMap = map;
|
|
1178
|
+
}
|
|
1179
|
+
},
|
|
1180
|
+
{
|
|
1181
|
+
/**
|
|
1182
|
+
* 返回外部导入与默认国际化数据
|
|
1183
|
+
*/ key: "$getI18n",
|
|
1184
|
+
value: function $getI18n() {
|
|
1185
|
+
return {
|
|
1186
|
+
external: this.$i18nMapExternal || null,
|
|
1187
|
+
default: this.$i18nMap || null
|
|
1188
|
+
};
|
|
1189
|
+
}
|
|
1190
|
+
},
|
|
1191
|
+
{
|
|
1192
|
+
/**
|
|
1193
|
+
* 国际化语言获取
|
|
1194
|
+
* @param ops 语言变量
|
|
1195
|
+
*/ key: "$intl",
|
|
1196
|
+
value: function $intl(ops, params) {
|
|
1197
|
+
return i18nIntl(this.sdk, ops, this.$i18nMapExternal || this.$i18n, params, this.$lang, this.$i18n);
|
|
1198
|
+
}
|
|
1199
|
+
},
|
|
1200
|
+
{
|
|
1201
|
+
key: "$display",
|
|
1202
|
+
value: function $display1(b) {
|
|
1203
|
+
var _this_data;
|
|
1204
|
+
var _this = this.isDrag ? this : this.$parent;
|
|
1205
|
+
if (!_this || !_this.$page || !((_this_data = _this.data) === null || _this_data === void 0 ? void 0 : _this_data.key)) return;
|
|
1206
|
+
var child = _this.$page.childrenMaps[_this.data.key];
|
|
1207
|
+
if (!child) return;
|
|
1208
|
+
return DisplayModule(child, b);
|
|
1209
|
+
}
|
|
1210
|
+
},
|
|
1211
|
+
{
|
|
1212
|
+
key: "cloneDeep",
|
|
1213
|
+
value: function cloneDeep(data, re) {
|
|
1214
|
+
if (!data) return re || null;
|
|
1215
|
+
try {
|
|
1216
|
+
return JSON.parse(JSON.stringify(data));
|
|
1217
|
+
} catch (e) {
|
|
1218
|
+
return data || re;
|
|
1219
|
+
}
|
|
1220
|
+
}
|
|
1221
|
+
}
|
|
1222
|
+
]);
|
|
1223
|
+
return Snack1;
|
|
1224
|
+
}();
|
|
1225
|
+
var snack_default = Snack;
|
|
1226
|
+
// src/utils/pathAccess.ts
|
|
1227
|
+
function parsePath(path) {
|
|
1228
|
+
var tokens = [];
|
|
1229
|
+
var normalized = path.replace(/\[/g, ".[");
|
|
1230
|
+
var re = /([^.[\]'"]+)|['"]([^'"]*)['"]/g;
|
|
1231
|
+
var m;
|
|
1232
|
+
while((m = re.exec(normalized)) !== null){
|
|
1233
|
+
var _m_;
|
|
1234
|
+
var token = (_m_ = m[1]) !== null && _m_ !== void 0 ? _m_ : m[2];
|
|
1235
|
+
if (token !== void 0 && token !== "") tokens.push(token);
|
|
1236
|
+
}
|
|
1237
|
+
return tokens;
|
|
1238
|
+
}
|
|
1239
|
+
function safeGet(obj, path) {
|
|
1240
|
+
return parsePath(path).reduce(function(acc, key) {
|
|
1241
|
+
if (acc !== null && (typeof acc === "undefined" ? "undefined" : _type_of(acc)) === "object") {
|
|
1242
|
+
return acc[key];
|
|
1243
|
+
}
|
|
1244
|
+
return void 0;
|
|
1245
|
+
}, obj);
|
|
1246
|
+
}
|
|
1247
|
+
function safeSet(obj, path, value) {
|
|
1248
|
+
var keys = parsePath(path);
|
|
1249
|
+
if (!keys.length) return false;
|
|
1250
|
+
var lastKey = keys.pop();
|
|
1251
|
+
var target = keys.reduce(function(acc, key) {
|
|
1252
|
+
if (acc !== null && (typeof acc === "undefined" ? "undefined" : _type_of(acc)) === "object") {
|
|
1253
|
+
return acc[key];
|
|
1254
|
+
}
|
|
1255
|
+
return void 0;
|
|
1256
|
+
}, obj);
|
|
1257
|
+
if (target == null || (typeof target === "undefined" ? "undefined" : _type_of(target)) !== "object") return false;
|
|
1258
|
+
target[lastKey] = value;
|
|
1259
|
+
return true;
|
|
1260
|
+
}
|
|
1261
|
+
// src/class/snackSetting.tsx
|
|
1262
|
+
var SnackSetting = /*#__PURE__*/ function(snack_default1) {
|
|
1263
|
+
"use strict";
|
|
1264
|
+
_inherits(SnackSetting1, snack_default1);
|
|
1265
|
+
function SnackSetting1() {
|
|
1266
|
+
_class_call_check(this, SnackSetting1);
|
|
1267
|
+
var _this;
|
|
1268
|
+
_this = _call_super(this, SnackSetting1, arguments);
|
|
1269
|
+
/**
|
|
1270
|
+
* 属性模型,键为数据字段名,值描述该字段的元数据与当前值
|
|
1271
|
+
*/ _this.model = {};
|
|
1272
|
+
/**
|
|
1273
|
+
* 是否将当前设置按照普通模式渲染,为 `true` 则不以弹窗模式渲染
|
|
1274
|
+
*/ _this.$normal = false;
|
|
1275
|
+
return _this;
|
|
1276
|
+
}
|
|
1277
|
+
_create_class(SnackSetting1, [
|
|
1278
|
+
{
|
|
1279
|
+
key: "$model",
|
|
1280
|
+
value: function $model() {
|
|
1281
|
+
var _this = this;
|
|
1282
|
+
var data = this.main.data;
|
|
1283
|
+
if (!this.main || !data) return null;
|
|
1284
|
+
Object.keys(this.model).forEach(function(key) {
|
|
1285
|
+
if (data[key] !== void 0) _this.model[key].value = data[key];
|
|
1286
|
+
});
|
|
1287
|
+
return this.cloneDeep(this.model, {});
|
|
1288
|
+
}
|
|
1289
|
+
},
|
|
1290
|
+
{
|
|
1291
|
+
/**
|
|
1292
|
+
* this.data 数据赋值,同时渲染页面
|
|
1293
|
+
* @param field 字段名字,支持 . 操作符
|
|
1294
|
+
* @param value
|
|
1295
|
+
* @param isRefresh
|
|
1296
|
+
*/ key: "$setData",
|
|
1297
|
+
value: function $setData(field, value) {
|
|
1298
|
+
var isRefresh = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : true;
|
|
1299
|
+
if (!this.main || !this.main.data) return false;
|
|
1300
|
+
if (this.sdk && this.sdk.runtime) {
|
|
1301
|
+
this.sdk.runtime = false;
|
|
1302
|
+
this.main.props = this.cloneData(this.main.data);
|
|
1303
|
+
}
|
|
1304
|
+
if (value === void 0) {
|
|
1305
|
+
var data = this.cloneDeep(this.main.data, {});
|
|
1306
|
+
return data[field];
|
|
1307
|
+
} else {
|
|
1308
|
+
var ok1 = this.setFieldValue(this.main.data, field, value);
|
|
1309
|
+
if (this.main.props) this.setFieldValue(this.main.props, field, value, true);
|
|
1310
|
+
if (!ok1) return false;
|
|
1311
|
+
if (isRefresh) {
|
|
1312
|
+
this.main.$forceUpdate();
|
|
1313
|
+
}
|
|
1314
|
+
this.$forceUpdate();
|
|
1315
|
+
}
|
|
1316
|
+
return true;
|
|
1317
|
+
}
|
|
1318
|
+
},
|
|
1319
|
+
{
|
|
1320
|
+
/**
|
|
1321
|
+
* 支持 . 操作符设置对象数据
|
|
1322
|
+
* @param data
|
|
1323
|
+
* @param field
|
|
1324
|
+
* @param value
|
|
1325
|
+
* @param parseExpr 是否解析表达式
|
|
1326
|
+
* @private
|
|
1327
|
+
*/ key: "setFieldValue",
|
|
1328
|
+
value: function setFieldValue(data, field, value) {
|
|
1329
|
+
var parseExpr = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : false;
|
|
1330
|
+
if (field.indexOf(";") !== -1) {
|
|
1331
|
+
console.warn('SnackCore: "'.concat(field, '"字段存在非法字符";",无法正常通过解析。'));
|
|
1332
|
+
return false;
|
|
1333
|
+
}
|
|
1334
|
+
var change;
|
|
1335
|
+
if (parseExpr) {
|
|
1336
|
+
var _this_sdk, _this_sdk1, _this_sdk2, _this_sdk3;
|
|
1337
|
+
if ((typeof value === "undefined" ? "undefined" : _type_of(value)) === "object" && value !== null) change = (_this_sdk1 = this.sdk) === null || _this_sdk1 === void 0 ? void 0 : _this_sdk1.recursiveParseJson(this.cloneData(value), (_this_sdk = this.sdk) === null || _this_sdk === void 0 ? void 0 : _this_sdk.getExprArgv({}));
|
|
1338
|
+
else if (typeof value === "string") change = (_this_sdk3 = this.sdk) === null || _this_sdk3 === void 0 ? void 0 : _this_sdk3.processTemplateString(value, (_this_sdk2 = this.sdk) === null || _this_sdk2 === void 0 ? void 0 : _this_sdk2.getExprArgv({}));
|
|
1339
|
+
}
|
|
1340
|
+
if (field.indexOf(".") === -1 || data[field] !== void 0) {
|
|
1341
|
+
data[field] = change || value;
|
|
1342
|
+
return true;
|
|
1343
|
+
}
|
|
1344
|
+
return safeSet(data, field, change || value);
|
|
1345
|
+
}
|
|
1346
|
+
}
|
|
1347
|
+
]);
|
|
1348
|
+
return SnackSetting1;
|
|
1349
|
+
}(snack_default);
|
|
1350
|
+
// src/lib/require.js
|
|
1351
|
+
Object.defineProperty(exports, "__esModule", {
|
|
1352
|
+
value: true
|
|
1353
|
+
});
|
|
1354
|
+
function _default(global, importMaps) {
|
|
1355
|
+
function _instanceof(left, right) {
|
|
1356
|
+
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
1357
|
+
return !!right[Symbol.hasInstance](left);
|
|
1358
|
+
} else {
|
|
1359
|
+
return _instanceof(left, right);
|
|
1360
|
+
}
|
|
1361
|
+
}
|
|
1362
|
+
function _typeof(obj) {
|
|
1363
|
+
"@babel/helpers - typeof";
|
|
1364
|
+
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
|
|
1365
|
+
_typeof = function _typeof2(obj2) {
|
|
1366
|
+
return typeof obj2;
|
|
1367
|
+
};
|
|
1368
|
+
} else {
|
|
1369
|
+
_typeof = function _typeof2(obj2) {
|
|
1370
|
+
return obj2 && typeof Symbol === "function" && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
|
|
1371
|
+
};
|
|
1372
|
+
}
|
|
1373
|
+
return _typeof(obj);
|
|
1374
|
+
}
|
|
1375
|
+
var requirejs, require, define;
|
|
1376
|
+
var req, s, head, baseElement, dataMain, src, interactiveScript, currentlyAddingScript, mainScript, subPath, version = "2.3.6", commentRegExp = /\/\*[\s\S]*?\*\/|([^:"'=]|^)\/\/.*$/mg, cjsRequireRegExp = /[^.]\s*require\s*\(\s*["']([^'"\s]+)["']\s*\)/g, jsSuffixRegExp = /\.js$/, currDirRegExp = /^\.\//, op = Object.prototype, ostring = op.toString, hasOwn = op.hasOwnProperty, isBrowser = !!(typeof window !== "undefined" && typeof navigator !== "undefined" && window.document), isWebWorker = !isBrowser && typeof importScripts !== "undefined", readyRegExp = isBrowser && navigator.platform === "PLAYSTATION 3" ? /^complete$/ : /^(complete|loaded)$/, defContextName = "_", isOpera = typeof opera !== "undefined" && opera.toString() === "[object Opera]", contexts = {}, cfg = {}, globalDefQueue = [], useInteractive = false;
|
|
1377
|
+
function commentReplace(match, singlePrefix) {
|
|
1378
|
+
return singlePrefix || "";
|
|
1379
|
+
}
|
|
1380
|
+
function isFunction(it) {
|
|
1381
|
+
return ostring.call(it) === "[object Function]";
|
|
1382
|
+
}
|
|
1383
|
+
function isArray(it) {
|
|
1384
|
+
return ostring.call(it) === "[object Array]";
|
|
1385
|
+
}
|
|
1386
|
+
function each(ary, func) {
|
|
1387
|
+
if (ary) {
|
|
1388
|
+
var i;
|
|
1389
|
+
for(i = 0; i < ary.length; i += 1){
|
|
1390
|
+
if (ary[i] && func(ary[i], i, ary)) {
|
|
1391
|
+
break;
|
|
1392
|
+
}
|
|
1393
|
+
}
|
|
1394
|
+
}
|
|
1395
|
+
}
|
|
1396
|
+
function eachReverse(ary, func) {
|
|
1397
|
+
if (ary) {
|
|
1398
|
+
var i;
|
|
1399
|
+
for(i = ary.length - 1; i > -1; i -= 1){
|
|
1400
|
+
if (ary[i] && func(ary[i], i, ary)) {
|
|
1401
|
+
break;
|
|
1402
|
+
}
|
|
1403
|
+
}
|
|
1404
|
+
}
|
|
1405
|
+
}
|
|
1406
|
+
function hasProp(obj, prop) {
|
|
1407
|
+
return hasOwn.call(obj, prop);
|
|
1408
|
+
}
|
|
1409
|
+
function getOwn(obj, prop) {
|
|
1410
|
+
return hasProp(obj, prop) && obj[prop];
|
|
1411
|
+
}
|
|
1412
|
+
function eachProp(obj, func) {
|
|
1413
|
+
var prop;
|
|
1414
|
+
for(prop in obj){
|
|
1415
|
+
if (hasProp(obj, prop)) {
|
|
1416
|
+
if (func(obj[prop], prop)) {
|
|
1417
|
+
break;
|
|
1418
|
+
}
|
|
1419
|
+
}
|
|
1420
|
+
}
|
|
1421
|
+
}
|
|
1422
|
+
function mixin(target, source, force, deepStringMixin) {
|
|
1423
|
+
if (source) {
|
|
1424
|
+
eachProp(source, function(value, prop) {
|
|
1425
|
+
if (force || !hasProp(target, prop)) {
|
|
1426
|
+
if (deepStringMixin && _typeof(value) === "object" && value && !isArray(value) && !isFunction(value) && !_instanceof(value, RegExp)) {
|
|
1427
|
+
if (!target[prop]) {
|
|
1428
|
+
target[prop] = {};
|
|
1429
|
+
}
|
|
1430
|
+
mixin(target[prop], value, force, deepStringMixin);
|
|
1431
|
+
} else {
|
|
1432
|
+
target[prop] = value;
|
|
1433
|
+
}
|
|
1434
|
+
}
|
|
1435
|
+
});
|
|
1436
|
+
}
|
|
1437
|
+
return target;
|
|
1438
|
+
}
|
|
1439
|
+
function bind(obj, fn) {
|
|
1440
|
+
return function() {
|
|
1441
|
+
return fn.apply(obj, arguments);
|
|
1442
|
+
};
|
|
1443
|
+
}
|
|
1444
|
+
function scripts() {
|
|
1445
|
+
return document.getElementsByTagName("script");
|
|
1446
|
+
}
|
|
1447
|
+
function defaultOnError(err) {
|
|
1448
|
+
throw err;
|
|
1449
|
+
}
|
|
1450
|
+
function getGlobal(value) {
|
|
1451
|
+
if (!value) {
|
|
1452
|
+
return value;
|
|
1453
|
+
}
|
|
1454
|
+
var g = global;
|
|
1455
|
+
each(value.split("."), function(part) {
|
|
1456
|
+
g = g[part];
|
|
1457
|
+
});
|
|
1458
|
+
return g;
|
|
1459
|
+
}
|
|
1460
|
+
function makeError(id, msg, err, requireModules) {
|
|
1461
|
+
var e = new Error(msg + id);
|
|
1462
|
+
e.requireType = id;
|
|
1463
|
+
e.requireModules = requireModules;
|
|
1464
|
+
if (err) {
|
|
1465
|
+
e.originalError = err;
|
|
1466
|
+
}
|
|
1467
|
+
return e;
|
|
1468
|
+
}
|
|
1469
|
+
if (typeof define !== "undefined") {
|
|
1470
|
+
return;
|
|
1471
|
+
}
|
|
1472
|
+
if (typeof requirejs !== "undefined") {
|
|
1473
|
+
if (isFunction(requirejs)) {
|
|
1474
|
+
return;
|
|
1475
|
+
}
|
|
1476
|
+
cfg = requirejs;
|
|
1477
|
+
requirejs = void 0;
|
|
1478
|
+
}
|
|
1479
|
+
if (typeof require !== "undefined" && !isFunction(require)) {
|
|
1480
|
+
cfg = require;
|
|
1481
|
+
require = void 0;
|
|
1482
|
+
}
|
|
1483
|
+
function newContext(contextName) {
|
|
1484
|
+
var inCheckLoaded, Module, context, handlers, checkLoadedTimeoutId, _config = {
|
|
1485
|
+
//Defaults. Do not set a default for map
|
|
1486
|
+
//config to speed up normalize(), which
|
|
1487
|
+
//will run faster if there is no default.
|
|
1488
|
+
waitSeconds: 50,
|
|
1489
|
+
baseUrl: "./",
|
|
1490
|
+
paths: {},
|
|
1491
|
+
bundles: {},
|
|
1492
|
+
pkgs: {},
|
|
1493
|
+
shim: {},
|
|
1494
|
+
config: {}
|
|
1495
|
+
}, registry = {}, enabledRegistry = {}, undefEvents = {}, defQueue = [], _defined = {}, urlFetched = {}, bundlesMap = {}, requireCounter = 1, unnormalizedCounter = 1;
|
|
1496
|
+
function trimDots(ary) {
|
|
1497
|
+
var i, part;
|
|
1498
|
+
for(i = 0; i < ary.length; i++){
|
|
1499
|
+
part = ary[i];
|
|
1500
|
+
if (part === ".") {
|
|
1501
|
+
ary.splice(i, 1);
|
|
1502
|
+
i -= 1;
|
|
1503
|
+
} else if (part === "..") {
|
|
1504
|
+
if (i === 0 || i === 1 && ary[2] === ".." || ary[i - 1] === "..") {
|
|
1505
|
+
continue;
|
|
1506
|
+
} else if (i > 0) {
|
|
1507
|
+
ary.splice(i - 1, 2);
|
|
1508
|
+
i -= 2;
|
|
1509
|
+
}
|
|
1510
|
+
}
|
|
1511
|
+
}
|
|
1512
|
+
}
|
|
1513
|
+
function normalize(name, baseName, applyMap) {
|
|
1514
|
+
var pkgMain, mapValue, nameParts, i, j, nameSegment, lastIndex, foundMap, foundI, foundStarMap, starI, normalizedBaseParts, baseParts = baseName && baseName.split("/"), map = _config.map, starMap = map && map["*"];
|
|
1515
|
+
if (name) {
|
|
1516
|
+
name = name.split("/");
|
|
1517
|
+
lastIndex = name.length - 1;
|
|
1518
|
+
if (_config.nodeIdCompat && jsSuffixRegExp.test(name[lastIndex])) {
|
|
1519
|
+
name[lastIndex] = name[lastIndex].replace(jsSuffixRegExp, "");
|
|
1520
|
+
}
|
|
1521
|
+
if (name[0].charAt(0) === "." && baseParts) {
|
|
1522
|
+
normalizedBaseParts = baseParts.slice(0, baseParts.length - 1);
|
|
1523
|
+
name = normalizedBaseParts.concat(name);
|
|
1524
|
+
}
|
|
1525
|
+
trimDots(name);
|
|
1526
|
+
name = name.join("/");
|
|
1527
|
+
}
|
|
1528
|
+
if (applyMap && map && (baseParts || starMap)) {
|
|
1529
|
+
nameParts = name.split("/");
|
|
1530
|
+
outerLoop: for(i = nameParts.length; i > 0; i -= 1){
|
|
1531
|
+
nameSegment = nameParts.slice(0, i).join("/");
|
|
1532
|
+
if (baseParts) {
|
|
1533
|
+
for(j = baseParts.length; j > 0; j -= 1){
|
|
1534
|
+
mapValue = getOwn(map, baseParts.slice(0, j).join("/"));
|
|
1535
|
+
if (mapValue) {
|
|
1536
|
+
mapValue = getOwn(mapValue, nameSegment);
|
|
1537
|
+
if (mapValue) {
|
|
1538
|
+
foundMap = mapValue;
|
|
1539
|
+
foundI = i;
|
|
1540
|
+
break outerLoop;
|
|
1541
|
+
}
|
|
1542
|
+
}
|
|
1543
|
+
}
|
|
1544
|
+
}
|
|
1545
|
+
if (!foundStarMap && starMap && getOwn(starMap, nameSegment)) {
|
|
1546
|
+
foundStarMap = getOwn(starMap, nameSegment);
|
|
1547
|
+
starI = i;
|
|
1548
|
+
}
|
|
1549
|
+
}
|
|
1550
|
+
if (!foundMap && foundStarMap) {
|
|
1551
|
+
foundMap = foundStarMap;
|
|
1552
|
+
foundI = starI;
|
|
1553
|
+
}
|
|
1554
|
+
if (foundMap) {
|
|
1555
|
+
nameParts.splice(0, foundI, foundMap);
|
|
1556
|
+
name = nameParts.join("/");
|
|
1557
|
+
}
|
|
1558
|
+
}
|
|
1559
|
+
pkgMain = getOwn(_config.pkgs, name);
|
|
1560
|
+
return pkgMain ? pkgMain : name;
|
|
1561
|
+
}
|
|
1562
|
+
function removeScript(name) {
|
|
1563
|
+
if (isBrowser) {
|
|
1564
|
+
each(scripts(), function(scriptNode) {
|
|
1565
|
+
if (scriptNode.getAttribute("data-requiremodule") === name && scriptNode.getAttribute("data-requirecontext") === context.contextName) {
|
|
1566
|
+
scriptNode.parentNode.removeChild(scriptNode);
|
|
1567
|
+
return true;
|
|
1568
|
+
}
|
|
1569
|
+
});
|
|
1570
|
+
}
|
|
1571
|
+
}
|
|
1572
|
+
function hasPathFallback(id) {
|
|
1573
|
+
var pathConfig = getOwn(_config.paths, id);
|
|
1574
|
+
if (pathConfig && isArray(pathConfig) && pathConfig.length > 1) {
|
|
1575
|
+
pathConfig.shift();
|
|
1576
|
+
context.require.undef(id);
|
|
1577
|
+
context.makeRequire(null, {
|
|
1578
|
+
skipMap: true
|
|
1579
|
+
})([
|
|
1580
|
+
id
|
|
1581
|
+
]);
|
|
1582
|
+
return true;
|
|
1583
|
+
}
|
|
1584
|
+
}
|
|
1585
|
+
function splitPrefix(name) {
|
|
1586
|
+
var prefix, index = name ? name.indexOf("!") : -1;
|
|
1587
|
+
if (index > -1) {
|
|
1588
|
+
prefix = name.substring(0, index);
|
|
1589
|
+
name = name.substring(index + 1, name.length);
|
|
1590
|
+
}
|
|
1591
|
+
return [
|
|
1592
|
+
prefix,
|
|
1593
|
+
name
|
|
1594
|
+
];
|
|
1595
|
+
}
|
|
1596
|
+
function makeModuleMap(name, parentModuleMap, isNormalized, applyMap) {
|
|
1597
|
+
var url, pluginModule, suffix, nameParts, prefix = null, parentName = parentModuleMap ? parentModuleMap.name : null, originalName = name, isDefine = true, normalizedName = "";
|
|
1598
|
+
if (!name) {
|
|
1599
|
+
isDefine = false;
|
|
1600
|
+
name = "_@r" + (requireCounter += 1);
|
|
1601
|
+
}
|
|
1602
|
+
nameParts = splitPrefix(name);
|
|
1603
|
+
prefix = nameParts[0];
|
|
1604
|
+
name = nameParts[1];
|
|
1605
|
+
if (prefix) {
|
|
1606
|
+
prefix = normalize(prefix, parentName, applyMap);
|
|
1607
|
+
pluginModule = getOwn(_defined, prefix);
|
|
1608
|
+
}
|
|
1609
|
+
if (name) {
|
|
1610
|
+
if (prefix) {
|
|
1611
|
+
if (isNormalized) {
|
|
1612
|
+
normalizedName = name;
|
|
1613
|
+
} else if (pluginModule && pluginModule.normalize) {
|
|
1614
|
+
normalizedName = pluginModule.normalize(name, function(name2) {
|
|
1615
|
+
return normalize(name2, parentName, applyMap);
|
|
1616
|
+
});
|
|
1617
|
+
} else {
|
|
1618
|
+
normalizedName = name.indexOf("!") === -1 ? normalize(name, parentName, applyMap) : name;
|
|
1619
|
+
}
|
|
1620
|
+
} else {
|
|
1621
|
+
normalizedName = normalize(name, parentName, applyMap);
|
|
1622
|
+
nameParts = splitPrefix(normalizedName);
|
|
1623
|
+
prefix = nameParts[0];
|
|
1624
|
+
normalizedName = nameParts[1];
|
|
1625
|
+
isNormalized = true;
|
|
1626
|
+
url = context.nameToUrl(normalizedName);
|
|
1627
|
+
}
|
|
1628
|
+
}
|
|
1629
|
+
suffix = prefix && !pluginModule && !isNormalized ? "_unnormalized" + (unnormalizedCounter += 1) : "";
|
|
1630
|
+
return {
|
|
1631
|
+
prefix: prefix,
|
|
1632
|
+
name: normalizedName,
|
|
1633
|
+
parentMap: parentModuleMap,
|
|
1634
|
+
unnormalized: !!suffix,
|
|
1635
|
+
url: url,
|
|
1636
|
+
originalName: originalName,
|
|
1637
|
+
isDefine: isDefine,
|
|
1638
|
+
id: (prefix ? prefix + "!" + normalizedName : normalizedName) + suffix
|
|
1639
|
+
};
|
|
1640
|
+
}
|
|
1641
|
+
function getModule(depMap) {
|
|
1642
|
+
var id = depMap.id, mod = getOwn(registry, id);
|
|
1643
|
+
if (!mod) {
|
|
1644
|
+
mod = registry[id] = new context.Module(depMap);
|
|
1645
|
+
}
|
|
1646
|
+
return mod;
|
|
1647
|
+
}
|
|
1648
|
+
function on(depMap, name, fn) {
|
|
1649
|
+
var id = depMap.id, mod = getOwn(registry, id);
|
|
1650
|
+
if (hasProp(_defined, id) && (!mod || mod.defineEmitComplete)) {
|
|
1651
|
+
if (name === "defined") {
|
|
1652
|
+
fn(_defined[id]);
|
|
1653
|
+
}
|
|
1654
|
+
} else {
|
|
1655
|
+
mod = getModule(depMap);
|
|
1656
|
+
if (mod.error && name === "error") {
|
|
1657
|
+
fn(mod.error);
|
|
1658
|
+
} else {
|
|
1659
|
+
mod.on(name, fn);
|
|
1660
|
+
}
|
|
1661
|
+
}
|
|
1662
|
+
}
|
|
1663
|
+
function onError(err, errback) {
|
|
1664
|
+
var ids = err.requireModules, notified = false;
|
|
1665
|
+
if (errback) {
|
|
1666
|
+
errback(err);
|
|
1667
|
+
} else {
|
|
1668
|
+
each(ids, function(id) {
|
|
1669
|
+
var mod = getOwn(registry, id);
|
|
1670
|
+
if (mod) {
|
|
1671
|
+
mod.error = err;
|
|
1672
|
+
if (mod.events.error) {
|
|
1673
|
+
notified = true;
|
|
1674
|
+
mod.emit("error", err);
|
|
1675
|
+
}
|
|
1676
|
+
}
|
|
1677
|
+
});
|
|
1678
|
+
if (!notified) {
|
|
1679
|
+
req.onError(err);
|
|
1680
|
+
}
|
|
1681
|
+
}
|
|
1682
|
+
}
|
|
1683
|
+
function takeGlobalQueue() {
|
|
1684
|
+
if (globalDefQueue.length) {
|
|
1685
|
+
each(globalDefQueue, function(queueItem) {
|
|
1686
|
+
var id = queueItem[0];
|
|
1687
|
+
if (typeof id === "string") {
|
|
1688
|
+
context.defQueueMap[id] = true;
|
|
1689
|
+
}
|
|
1690
|
+
defQueue.push(queueItem);
|
|
1691
|
+
});
|
|
1692
|
+
globalDefQueue = [];
|
|
1693
|
+
}
|
|
1694
|
+
}
|
|
1695
|
+
handlers = {
|
|
1696
|
+
"require": function require2(mod) {
|
|
1697
|
+
if (mod.require) {
|
|
1698
|
+
return mod.require;
|
|
1699
|
+
} else {
|
|
1700
|
+
return mod.require = context.makeRequire(mod.map);
|
|
1701
|
+
}
|
|
1702
|
+
},
|
|
1703
|
+
"exports": function exports2(mod) {
|
|
1704
|
+
mod.usingExports = true;
|
|
1705
|
+
if (mod.map.isDefine) {
|
|
1706
|
+
if (mod.exports) {
|
|
1707
|
+
return _defined[mod.map.id] = mod.exports;
|
|
1708
|
+
} else {
|
|
1709
|
+
return mod.exports = _defined[mod.map.id] = {};
|
|
1710
|
+
}
|
|
1711
|
+
}
|
|
1712
|
+
},
|
|
1713
|
+
"module": function module(mod) {
|
|
1714
|
+
if (mod.module) {
|
|
1715
|
+
return mod.module;
|
|
1716
|
+
} else {
|
|
1717
|
+
return mod.module = {
|
|
1718
|
+
id: mod.map.id,
|
|
1719
|
+
uri: mod.map.url,
|
|
1720
|
+
config: function config() {
|
|
1721
|
+
return getOwn(_config.config, mod.map.id) || {};
|
|
1722
|
+
},
|
|
1723
|
+
exports: mod.exports || (mod.exports = {})
|
|
1724
|
+
};
|
|
1725
|
+
}
|
|
1726
|
+
}
|
|
1727
|
+
};
|
|
1728
|
+
function cleanRegistry(id) {
|
|
1729
|
+
delete registry[id];
|
|
1730
|
+
delete enabledRegistry[id];
|
|
1731
|
+
}
|
|
1732
|
+
function breakCycle(mod, traced, processed) {
|
|
1733
|
+
var id = mod.map.id;
|
|
1734
|
+
if (mod.error) {
|
|
1735
|
+
mod.emit("error", mod.error);
|
|
1736
|
+
} else {
|
|
1737
|
+
traced[id] = true;
|
|
1738
|
+
each(mod.depMaps, function(depMap, i) {
|
|
1739
|
+
var depId = depMap.id, dep = getOwn(registry, depId);
|
|
1740
|
+
if (dep && !mod.depMatched[i] && !processed[depId]) {
|
|
1741
|
+
if (getOwn(traced, depId)) {
|
|
1742
|
+
mod.defineDep(i, _defined[depId]);
|
|
1743
|
+
mod.check();
|
|
1744
|
+
} else {
|
|
1745
|
+
breakCycle(dep, traced, processed);
|
|
1746
|
+
}
|
|
1747
|
+
}
|
|
1748
|
+
});
|
|
1749
|
+
processed[id] = true;
|
|
1750
|
+
}
|
|
1751
|
+
}
|
|
1752
|
+
function checkLoaded(moduleName) {
|
|
1753
|
+
var err, usingPathFallback, waitInterval = _config.waitSeconds * 1e3, expired = waitInterval && context.startTime + waitInterval < /* @__PURE__ */ new Date().getTime(), noLoads = [], reqCalls = [], stillLoading = false, needCycleCheck = true;
|
|
1754
|
+
if (inCheckLoaded) {
|
|
1755
|
+
return;
|
|
1756
|
+
}
|
|
1757
|
+
inCheckLoaded = true;
|
|
1758
|
+
eachProp(enabledRegistry, function(mod) {
|
|
1759
|
+
var map = mod.map, modId = map.id;
|
|
1760
|
+
if (!mod.enabled) {
|
|
1761
|
+
return;
|
|
1762
|
+
}
|
|
1763
|
+
if (!map.isDefine) {
|
|
1764
|
+
reqCalls.push(mod);
|
|
1765
|
+
}
|
|
1766
|
+
if (!mod.error) {
|
|
1767
|
+
if (!mod.inited && expired) {
|
|
1768
|
+
if (hasPathFallback(modId)) {
|
|
1769
|
+
usingPathFallback = true;
|
|
1770
|
+
stillLoading = true;
|
|
1771
|
+
} else {
|
|
1772
|
+
noLoads.push(modId);
|
|
1773
|
+
removeScript(modId);
|
|
1774
|
+
}
|
|
1775
|
+
} else if (!mod.inited && mod.fetched && map.isDefine) {
|
|
1776
|
+
stillLoading = true;
|
|
1777
|
+
if (!map.prefix) {
|
|
1778
|
+
return needCycleCheck = false;
|
|
1779
|
+
}
|
|
1780
|
+
}
|
|
1781
|
+
}
|
|
1782
|
+
});
|
|
1783
|
+
if (expired && noLoads.length) {
|
|
1784
|
+
err = makeError("timeout", "Load timeout for modules: " + noLoads, null, noLoads);
|
|
1785
|
+
err.contextName = context.contextName;
|
|
1786
|
+
return onError(err);
|
|
1787
|
+
}
|
|
1788
|
+
if (needCycleCheck) {
|
|
1789
|
+
each(reqCalls, function(mod) {
|
|
1790
|
+
breakCycle(mod, {}, {});
|
|
1791
|
+
});
|
|
1792
|
+
}
|
|
1793
|
+
if ((!expired || usingPathFallback) && stillLoading) {
|
|
1794
|
+
if ((isBrowser || isWebWorker) && !checkLoadedTimeoutId) {
|
|
1795
|
+
checkLoadedTimeoutId = setTimeout(function() {
|
|
1796
|
+
checkLoadedTimeoutId = 0;
|
|
1797
|
+
checkLoaded();
|
|
1798
|
+
}, 50);
|
|
1799
|
+
}
|
|
1800
|
+
}
|
|
1801
|
+
inCheckLoaded = false;
|
|
1802
|
+
}
|
|
1803
|
+
Module = function Module2(map) {
|
|
1804
|
+
this.events = getOwn(undefEvents, map.id) || {};
|
|
1805
|
+
this.map = map;
|
|
1806
|
+
this.shim = getOwn(_config.shim, map.id);
|
|
1807
|
+
this.depExports = [];
|
|
1808
|
+
this.depMaps = [];
|
|
1809
|
+
this.depMatched = [];
|
|
1810
|
+
this.pluginMaps = {};
|
|
1811
|
+
this.depCount = 0;
|
|
1812
|
+
};
|
|
1813
|
+
Module.prototype = {
|
|
1814
|
+
init: function init(depMaps, factory, errback, options) {
|
|
1815
|
+
options = options || {};
|
|
1816
|
+
if (this.inited) {
|
|
1817
|
+
return;
|
|
1818
|
+
}
|
|
1819
|
+
this.factory = factory;
|
|
1820
|
+
if (errback) {
|
|
1821
|
+
this.on("error", errback);
|
|
1822
|
+
} else if (this.events.error) {
|
|
1823
|
+
errback = bind(this, function(err) {
|
|
1824
|
+
this.emit("error", err);
|
|
1825
|
+
});
|
|
1826
|
+
}
|
|
1827
|
+
this.depMaps = depMaps && depMaps.slice(0);
|
|
1828
|
+
this.errback = errback;
|
|
1829
|
+
this.inited = true;
|
|
1830
|
+
this.ignore = options.ignore;
|
|
1831
|
+
if (options.enabled || this.enabled) {
|
|
1832
|
+
this.enable();
|
|
1833
|
+
} else {
|
|
1834
|
+
this.check();
|
|
1835
|
+
}
|
|
1836
|
+
},
|
|
1837
|
+
defineDep: function defineDep(i, depExports) {
|
|
1838
|
+
if (!this.depMatched[i]) {
|
|
1839
|
+
this.depMatched[i] = true;
|
|
1840
|
+
this.depCount -= 1;
|
|
1841
|
+
this.depExports[i] = depExports;
|
|
1842
|
+
}
|
|
1843
|
+
},
|
|
1844
|
+
fetch: function fetch() {
|
|
1845
|
+
if (this.fetched) {
|
|
1846
|
+
return;
|
|
1847
|
+
}
|
|
1848
|
+
this.fetched = true;
|
|
1849
|
+
context.startTime = /* @__PURE__ */ new Date().getTime();
|
|
1850
|
+
var map = this.map;
|
|
1851
|
+
if (this.shim) {
|
|
1852
|
+
context.makeRequire(this.map, {
|
|
1853
|
+
enableBuildCallback: true
|
|
1854
|
+
})(this.shim.deps || [], bind(this, function() {
|
|
1855
|
+
return map.prefix ? this.callPlugin() : this.load();
|
|
1856
|
+
}));
|
|
1857
|
+
} else {
|
|
1858
|
+
return map.prefix ? this.callPlugin() : this.load();
|
|
1859
|
+
}
|
|
1860
|
+
},
|
|
1861
|
+
load: function load() {
|
|
1862
|
+
var url = this.map.url;
|
|
1863
|
+
if (!urlFetched[url]) {
|
|
1864
|
+
urlFetched[url] = true;
|
|
1865
|
+
context.load(this.map.id, url);
|
|
1866
|
+
}
|
|
1867
|
+
},
|
|
1868
|
+
/**
|
|
1869
|
+
* Checks if the module is ready to define itself, and if so,
|
|
1870
|
+
* define it.
|
|
1871
|
+
*/ check: function check() {
|
|
1872
|
+
if (!this.enabled || this.enabling) {
|
|
1873
|
+
return;
|
|
1874
|
+
}
|
|
1875
|
+
var err, cjsModule, id = this.map.id, depExports = this.depExports, exports2 = this.exports, factory = this.factory;
|
|
1876
|
+
if (!this.inited) {
|
|
1877
|
+
if (!hasProp(context.defQueueMap, id)) {
|
|
1878
|
+
this.fetch();
|
|
1879
|
+
}
|
|
1880
|
+
} else if (this.error) {
|
|
1881
|
+
this.emit("error", this.error);
|
|
1882
|
+
} else if (!this.defining) {
|
|
1883
|
+
this.defining = true;
|
|
1884
|
+
if (this.depCount < 1 && !this.defined) {
|
|
1885
|
+
if (isFunction(factory)) {
|
|
1886
|
+
if (this.events.error && this.map.isDefine || req.onError !== defaultOnError) {
|
|
1887
|
+
try {
|
|
1888
|
+
exports2 = context.execCb(id, factory, depExports, exports2);
|
|
1889
|
+
} catch (e) {
|
|
1890
|
+
err = e;
|
|
1891
|
+
}
|
|
1892
|
+
} else {
|
|
1893
|
+
exports2 = context.execCb(id, factory, depExports, exports2);
|
|
1894
|
+
}
|
|
1895
|
+
if (this.map.isDefine && exports2 === void 0) {
|
|
1896
|
+
cjsModule = this.module;
|
|
1897
|
+
if (cjsModule) {
|
|
1898
|
+
exports2 = cjsModule.exports;
|
|
1899
|
+
} else if (this.usingExports) {
|
|
1900
|
+
exports2 = this.exports;
|
|
1901
|
+
}
|
|
1902
|
+
}
|
|
1903
|
+
if (err) {
|
|
1904
|
+
err.requireMap = this.map;
|
|
1905
|
+
err.requireModules = this.map.isDefine ? [
|
|
1906
|
+
this.map.id
|
|
1907
|
+
] : null;
|
|
1908
|
+
err.requireType = this.map.isDefine ? "define" : "require";
|
|
1909
|
+
return onError(this.error = err);
|
|
1910
|
+
}
|
|
1911
|
+
} else {
|
|
1912
|
+
exports2 = factory;
|
|
1913
|
+
}
|
|
1914
|
+
this.exports = exports2;
|
|
1915
|
+
if (this.map.isDefine && !this.ignore) {
|
|
1916
|
+
_defined[id] = exports2;
|
|
1917
|
+
if (req.onResourceLoad) {
|
|
1918
|
+
var resLoadMaps = [];
|
|
1919
|
+
each(this.depMaps, function(depMap) {
|
|
1920
|
+
resLoadMaps.push(depMap.normalizedMap || depMap);
|
|
1921
|
+
});
|
|
1922
|
+
req.onResourceLoad(context, this.map, resLoadMaps);
|
|
1923
|
+
}
|
|
1924
|
+
}
|
|
1925
|
+
cleanRegistry(id);
|
|
1926
|
+
this.defined = true;
|
|
1927
|
+
}
|
|
1928
|
+
this.defining = false;
|
|
1929
|
+
if (this.defined && !this.defineEmitted) {
|
|
1930
|
+
this.defineEmitted = true;
|
|
1931
|
+
this.emit("defined", this.exports);
|
|
1932
|
+
this.defineEmitComplete = true;
|
|
1933
|
+
}
|
|
1934
|
+
}
|
|
1935
|
+
},
|
|
1936
|
+
callPlugin: function callPlugin() {
|
|
1937
|
+
var map = this.map, id = map.id, pluginMap = makeModuleMap(map.prefix);
|
|
1938
|
+
this.depMaps.push(pluginMap);
|
|
1939
|
+
on(pluginMap, "defined", bind(this, function(plugin) {
|
|
1940
|
+
var load, normalizedMap, normalizedMod, bundleId = getOwn(bundlesMap, this.map.id), name = this.map.name, parentName = this.map.parentMap ? this.map.parentMap.name : null, localRequire = context.makeRequire(map.parentMap, {
|
|
1941
|
+
enableBuildCallback: true
|
|
1942
|
+
});
|
|
1943
|
+
if (this.map.unnormalized) {
|
|
1944
|
+
if (plugin.normalize) {
|
|
1945
|
+
name = plugin.normalize(name, function(name2) {
|
|
1946
|
+
return normalize(name2, parentName, true);
|
|
1947
|
+
}) || "";
|
|
1948
|
+
}
|
|
1949
|
+
normalizedMap = makeModuleMap(map.prefix + "!" + name, this.map.parentMap, true);
|
|
1950
|
+
on(normalizedMap, "defined", bind(this, function(value) {
|
|
1951
|
+
this.map.normalizedMap = normalizedMap;
|
|
1952
|
+
this.init([], function() {
|
|
1953
|
+
return value;
|
|
1954
|
+
}, null, {
|
|
1955
|
+
enabled: true,
|
|
1956
|
+
ignore: true
|
|
1957
|
+
});
|
|
1958
|
+
}));
|
|
1959
|
+
normalizedMod = getOwn(registry, normalizedMap.id);
|
|
1960
|
+
if (normalizedMod) {
|
|
1961
|
+
this.depMaps.push(normalizedMap);
|
|
1962
|
+
if (this.events.error) {
|
|
1963
|
+
normalizedMod.on("error", bind(this, function(err) {
|
|
1964
|
+
this.emit("error", err);
|
|
1965
|
+
}));
|
|
1966
|
+
}
|
|
1967
|
+
normalizedMod.enable();
|
|
1968
|
+
}
|
|
1969
|
+
return;
|
|
1970
|
+
}
|
|
1971
|
+
if (bundleId) {
|
|
1972
|
+
this.map.url = context.nameToUrl(bundleId);
|
|
1973
|
+
this.load();
|
|
1974
|
+
return;
|
|
1975
|
+
}
|
|
1976
|
+
load = bind(this, function(value) {
|
|
1977
|
+
this.init([], function() {
|
|
1978
|
+
return value;
|
|
1979
|
+
}, null, {
|
|
1980
|
+
enabled: true
|
|
1981
|
+
});
|
|
1982
|
+
});
|
|
1983
|
+
load.error = bind(this, function(err) {
|
|
1984
|
+
this.inited = true;
|
|
1985
|
+
this.error = err;
|
|
1986
|
+
err.requireModules = [
|
|
1987
|
+
id
|
|
1988
|
+
];
|
|
1989
|
+
eachProp(registry, function(mod) {
|
|
1990
|
+
if (mod.map.id.indexOf(id + "_unnormalized") === 0) {
|
|
1991
|
+
cleanRegistry(mod.map.id);
|
|
1992
|
+
}
|
|
1993
|
+
});
|
|
1994
|
+
onError(err);
|
|
1995
|
+
});
|
|
1996
|
+
load.fromText = bind(this, function(text2, textAlt) {
|
|
1997
|
+
var moduleName = map.name, moduleMap = makeModuleMap(moduleName), hasInteractive = useInteractive;
|
|
1998
|
+
if (textAlt) {
|
|
1999
|
+
text2 = textAlt;
|
|
2000
|
+
}
|
|
2001
|
+
if (hasInteractive) {
|
|
2002
|
+
useInteractive = false;
|
|
2003
|
+
}
|
|
2004
|
+
getModule(moduleMap);
|
|
2005
|
+
if (hasProp(_config.config, id)) {
|
|
2006
|
+
_config.config[moduleName] = _config.config[id];
|
|
2007
|
+
}
|
|
2008
|
+
try {
|
|
2009
|
+
req.exec(text2);
|
|
2010
|
+
} catch (e) {
|
|
2011
|
+
return onError(makeError("fromtexteval", "fromText eval for " + id + " failed: " + e, e, [
|
|
2012
|
+
id
|
|
2013
|
+
]));
|
|
2014
|
+
}
|
|
2015
|
+
if (hasInteractive) {
|
|
2016
|
+
useInteractive = true;
|
|
2017
|
+
}
|
|
2018
|
+
this.depMaps.push(moduleMap);
|
|
2019
|
+
context.completeLoad(moduleName);
|
|
2020
|
+
localRequire([
|
|
2021
|
+
moduleName
|
|
2022
|
+
], load);
|
|
2023
|
+
});
|
|
2024
|
+
plugin.load(map.name, localRequire, load, _config);
|
|
2025
|
+
}));
|
|
2026
|
+
context.enable(pluginMap, this);
|
|
2027
|
+
this.pluginMaps[pluginMap.id] = pluginMap;
|
|
2028
|
+
},
|
|
2029
|
+
enable: function enable() {
|
|
2030
|
+
enabledRegistry[this.map.id] = this;
|
|
2031
|
+
this.enabled = true;
|
|
2032
|
+
this.enabling = true;
|
|
2033
|
+
each(this.depMaps, bind(this, function(depMap, i) {
|
|
2034
|
+
var id, mod, handler;
|
|
2035
|
+
if (typeof depMap === "string") {
|
|
2036
|
+
depMap = makeModuleMap(depMap, this.map.isDefine ? this.map : this.map.parentMap, false, !this.skipMap);
|
|
2037
|
+
this.depMaps[i] = depMap;
|
|
2038
|
+
handler = getOwn(handlers, depMap.id);
|
|
2039
|
+
if (handler) {
|
|
2040
|
+
this.depExports[i] = handler(this);
|
|
2041
|
+
return;
|
|
2042
|
+
}
|
|
2043
|
+
this.depCount += 1;
|
|
2044
|
+
on(depMap, "defined", bind(this, function(depExports) {
|
|
2045
|
+
if (this.undefed) {
|
|
2046
|
+
return;
|
|
2047
|
+
}
|
|
2048
|
+
this.defineDep(i, depExports);
|
|
2049
|
+
this.check();
|
|
2050
|
+
}));
|
|
2051
|
+
if (this.errback) {
|
|
2052
|
+
on(depMap, "error", bind(this, this.errback));
|
|
2053
|
+
} else if (this.events.error) {
|
|
2054
|
+
on(depMap, "error", bind(this, function(err) {
|
|
2055
|
+
this.emit("error", err);
|
|
2056
|
+
}));
|
|
2057
|
+
}
|
|
2058
|
+
}
|
|
2059
|
+
id = depMap.id;
|
|
2060
|
+
mod = registry[id];
|
|
2061
|
+
if (!hasProp(handlers, id) && mod && !mod.enabled) {
|
|
2062
|
+
context.enable(depMap, this);
|
|
2063
|
+
}
|
|
2064
|
+
}));
|
|
2065
|
+
eachProp(this.pluginMaps, bind(this, function(pluginMap) {
|
|
2066
|
+
var mod = getOwn(registry, pluginMap.id);
|
|
2067
|
+
if (mod && !mod.enabled) {
|
|
2068
|
+
context.enable(pluginMap, this);
|
|
2069
|
+
}
|
|
2070
|
+
}));
|
|
2071
|
+
this.enabling = false;
|
|
2072
|
+
this.check();
|
|
2073
|
+
},
|
|
2074
|
+
on: function on2(name, cb) {
|
|
2075
|
+
var cbs = this.events[name];
|
|
2076
|
+
if (!cbs) {
|
|
2077
|
+
cbs = this.events[name] = [];
|
|
2078
|
+
}
|
|
2079
|
+
cbs.push(cb);
|
|
2080
|
+
},
|
|
2081
|
+
emit: function emit(name, evt) {
|
|
2082
|
+
each(this.events[name], function(cb) {
|
|
2083
|
+
cb(evt);
|
|
2084
|
+
});
|
|
2085
|
+
if (name === "error") {
|
|
2086
|
+
delete this.events[name];
|
|
2087
|
+
}
|
|
2088
|
+
}
|
|
2089
|
+
};
|
|
2090
|
+
function callGetModule(args) {
|
|
2091
|
+
if (!hasProp(_defined, args[0])) {
|
|
2092
|
+
getModule(makeModuleMap(args[0], null, true)).init(args[1], args[2]);
|
|
2093
|
+
}
|
|
2094
|
+
}
|
|
2095
|
+
function removeListener(node, func, name, ieName) {
|
|
2096
|
+
if (node.detachEvent && !isOpera) {
|
|
2097
|
+
if (ieName) {
|
|
2098
|
+
node.detachEvent(ieName, func);
|
|
2099
|
+
}
|
|
2100
|
+
} else {
|
|
2101
|
+
node.removeEventListener(name, func, false);
|
|
2102
|
+
}
|
|
2103
|
+
}
|
|
2104
|
+
function getScriptData(evt) {
|
|
2105
|
+
var node = evt.currentTarget || evt.srcElement;
|
|
2106
|
+
removeListener(node, context.onScriptLoad, "load", "onreadystatechange");
|
|
2107
|
+
removeListener(node, context.onScriptError, "error");
|
|
2108
|
+
return {
|
|
2109
|
+
node: node,
|
|
2110
|
+
id: node && node.getAttribute("data-requiremodule")
|
|
2111
|
+
};
|
|
2112
|
+
}
|
|
2113
|
+
function intakeDefines() {
|
|
2114
|
+
var args;
|
|
2115
|
+
takeGlobalQueue();
|
|
2116
|
+
while(defQueue.length){
|
|
2117
|
+
args = defQueue.shift();
|
|
2118
|
+
if (args[0] === null) {
|
|
2119
|
+
return onError(makeError("mismatch", "Mismatched anonymous define() module: " + args[args.length - 1]));
|
|
2120
|
+
} else {
|
|
2121
|
+
callGetModule(args);
|
|
2122
|
+
}
|
|
2123
|
+
}
|
|
2124
|
+
context.defQueueMap = {};
|
|
2125
|
+
}
|
|
2126
|
+
context = {
|
|
2127
|
+
config: _config,
|
|
2128
|
+
contextName: contextName,
|
|
2129
|
+
registry: registry,
|
|
2130
|
+
defined: _defined,
|
|
2131
|
+
urlFetched: urlFetched,
|
|
2132
|
+
defQueue: defQueue,
|
|
2133
|
+
defQueueMap: {},
|
|
2134
|
+
Module: Module,
|
|
2135
|
+
makeModuleMap: makeModuleMap,
|
|
2136
|
+
nextTick: req.nextTick,
|
|
2137
|
+
onError: onError,
|
|
2138
|
+
/**
|
|
2139
|
+
* Set a configuration for the context.
|
|
2140
|
+
* @param {Object} cfg config object to integrate.
|
|
2141
|
+
*/ configure: function configure(cfg2) {
|
|
2142
|
+
if (cfg2.baseUrl) {
|
|
2143
|
+
if (cfg2.baseUrl.charAt(cfg2.baseUrl.length - 1) !== "/") {
|
|
2144
|
+
cfg2.baseUrl += "/";
|
|
2145
|
+
}
|
|
2146
|
+
}
|
|
2147
|
+
if (typeof cfg2.urlArgs === "string") {
|
|
2148
|
+
var urlArgs = cfg2.urlArgs;
|
|
2149
|
+
cfg2.urlArgs = function(id, url) {
|
|
2150
|
+
return (url.indexOf("?") === -1 ? "?" : "&") + urlArgs;
|
|
2151
|
+
};
|
|
2152
|
+
}
|
|
2153
|
+
var shim = _config.shim, objs = {
|
|
2154
|
+
paths: true,
|
|
2155
|
+
bundles: true,
|
|
2156
|
+
config: true,
|
|
2157
|
+
map: true
|
|
2158
|
+
};
|
|
2159
|
+
eachProp(cfg2, function(value, prop) {
|
|
2160
|
+
if (objs[prop]) {
|
|
2161
|
+
if (!_config[prop]) {
|
|
2162
|
+
_config[prop] = {};
|
|
2163
|
+
}
|
|
2164
|
+
mixin(_config[prop], value, true, true);
|
|
2165
|
+
} else {
|
|
2166
|
+
_config[prop] = value;
|
|
2167
|
+
}
|
|
2168
|
+
});
|
|
2169
|
+
if (cfg2.bundles) {
|
|
2170
|
+
eachProp(cfg2.bundles, function(value, prop) {
|
|
2171
|
+
each(value, function(v) {
|
|
2172
|
+
if (v !== prop) {
|
|
2173
|
+
bundlesMap[v] = prop;
|
|
2174
|
+
}
|
|
2175
|
+
});
|
|
2176
|
+
});
|
|
2177
|
+
}
|
|
2178
|
+
if (cfg2.shim) {
|
|
2179
|
+
eachProp(cfg2.shim, function(value, id) {
|
|
2180
|
+
if (isArray(value)) {
|
|
2181
|
+
value = {
|
|
2182
|
+
deps: value
|
|
2183
|
+
};
|
|
2184
|
+
}
|
|
2185
|
+
if ((value.exports || value.init) && !value.exportsFn) {
|
|
2186
|
+
value.exportsFn = context.makeShimExports(value);
|
|
2187
|
+
}
|
|
2188
|
+
shim[id] = value;
|
|
2189
|
+
});
|
|
2190
|
+
_config.shim = shim;
|
|
2191
|
+
}
|
|
2192
|
+
if (cfg2.packages) {
|
|
2193
|
+
each(cfg2.packages, function(pkgObj) {
|
|
2194
|
+
var location, name;
|
|
2195
|
+
pkgObj = typeof pkgObj === "string" ? {
|
|
2196
|
+
name: pkgObj
|
|
2197
|
+
} : pkgObj;
|
|
2198
|
+
name = pkgObj.name;
|
|
2199
|
+
location = pkgObj.location;
|
|
2200
|
+
if (location) {
|
|
2201
|
+
_config.paths[name] = pkgObj.location;
|
|
2202
|
+
}
|
|
2203
|
+
_config.pkgs[name] = pkgObj.name + "/" + (pkgObj.main || "main").replace(currDirRegExp, "").replace(jsSuffixRegExp, "");
|
|
2204
|
+
});
|
|
2205
|
+
}
|
|
2206
|
+
eachProp(registry, function(mod, id) {
|
|
2207
|
+
if (!mod.inited && !mod.map.unnormalized) {
|
|
2208
|
+
mod.map = makeModuleMap(id, null, true);
|
|
2209
|
+
}
|
|
2210
|
+
});
|
|
2211
|
+
if (cfg2.deps || cfg2.callback) {
|
|
2212
|
+
context.require(cfg2.deps || [], cfg2.callback);
|
|
2213
|
+
}
|
|
2214
|
+
},
|
|
2215
|
+
makeShimExports: function makeShimExports(value) {
|
|
2216
|
+
function fn() {
|
|
2217
|
+
var ret;
|
|
2218
|
+
if (value.init) {
|
|
2219
|
+
ret = value.init.apply(global, arguments);
|
|
2220
|
+
}
|
|
2221
|
+
return ret || value.exports && getGlobal(value.exports);
|
|
2222
|
+
}
|
|
2223
|
+
return fn;
|
|
2224
|
+
},
|
|
2225
|
+
makeRequire: function makeRequire(relMap, options) {
|
|
2226
|
+
options = options || {};
|
|
2227
|
+
function localRequire(deps, callback, errback) {
|
|
2228
|
+
var id, map, requireMod;
|
|
2229
|
+
if (options.enableBuildCallback && callback && isFunction(callback)) {
|
|
2230
|
+
callback.__requireJsBuild = true;
|
|
2231
|
+
}
|
|
2232
|
+
if (typeof deps === "string") {
|
|
2233
|
+
if (isFunction(callback)) {
|
|
2234
|
+
return onError(makeError("requireargs", "Invalid require call"), errback);
|
|
2235
|
+
}
|
|
2236
|
+
if (relMap && hasProp(handlers, deps)) {
|
|
2237
|
+
return handlers[deps](registry[relMap.id]);
|
|
2238
|
+
}
|
|
2239
|
+
if (req.get) {
|
|
2240
|
+
return req.get(context, deps, relMap, localRequire);
|
|
2241
|
+
}
|
|
2242
|
+
map = makeModuleMap(deps, relMap, false, true);
|
|
2243
|
+
id = map.id;
|
|
2244
|
+
if (!hasProp(_defined, id)) {
|
|
2245
|
+
return onError(makeError("notloaded", 'Module name "' + id + '" has not been loaded yet for context: ' + contextName + (relMap ? "" : ". Use require([])")));
|
|
2246
|
+
}
|
|
2247
|
+
return _defined[id];
|
|
2248
|
+
}
|
|
2249
|
+
intakeDefines();
|
|
2250
|
+
context.nextTick(function() {
|
|
2251
|
+
intakeDefines();
|
|
2252
|
+
requireMod = getModule(makeModuleMap(null, relMap));
|
|
2253
|
+
requireMod.skipMap = options.skipMap;
|
|
2254
|
+
requireMod.init(deps, callback, errback, {
|
|
2255
|
+
enabled: true
|
|
2256
|
+
});
|
|
2257
|
+
checkLoaded();
|
|
2258
|
+
});
|
|
2259
|
+
return localRequire;
|
|
2260
|
+
}
|
|
2261
|
+
mixin(localRequire, {
|
|
2262
|
+
isBrowser: isBrowser,
|
|
2263
|
+
/**
|
|
2264
|
+
* Converts a module name + .extension into an URL path.
|
|
2265
|
+
* *Requires* the use of a module name. It does not support using
|
|
2266
|
+
* plain URLs like nameToUrl.
|
|
2267
|
+
*/ toUrl: function toUrl(moduleNamePlusExt) {
|
|
2268
|
+
var ext, index = moduleNamePlusExt.lastIndexOf("."), segment = moduleNamePlusExt.split("/")[0], isRelative = segment === "." || segment === "..";
|
|
2269
|
+
if (index !== -1 && (!isRelative || index > 1)) {
|
|
2270
|
+
ext = moduleNamePlusExt.substring(index, moduleNamePlusExt.length);
|
|
2271
|
+
moduleNamePlusExt = moduleNamePlusExt.substring(0, index);
|
|
2272
|
+
}
|
|
2273
|
+
return context.nameToUrl(normalize(moduleNamePlusExt, relMap && relMap.id, true), ext, true);
|
|
2274
|
+
},
|
|
2275
|
+
defined: function defined(id) {
|
|
2276
|
+
return hasProp(_defined, makeModuleMap(id, relMap, false, true).id);
|
|
2277
|
+
},
|
|
2278
|
+
specified: function specified(id) {
|
|
2279
|
+
id = makeModuleMap(id, relMap, false, true).id;
|
|
2280
|
+
return hasProp(_defined, id) || hasProp(registry, id);
|
|
2281
|
+
}
|
|
2282
|
+
});
|
|
2283
|
+
if (!relMap) {
|
|
2284
|
+
localRequire.undef = function(id) {
|
|
2285
|
+
takeGlobalQueue();
|
|
2286
|
+
var map = makeModuleMap(id, relMap, true), mod = getOwn(registry, id);
|
|
2287
|
+
mod.undefed = true;
|
|
2288
|
+
removeScript(id);
|
|
2289
|
+
delete _defined[id];
|
|
2290
|
+
delete urlFetched[map.url];
|
|
2291
|
+
delete undefEvents[id];
|
|
2292
|
+
eachReverse(defQueue, function(args, i) {
|
|
2293
|
+
if (args[0] === id) {
|
|
2294
|
+
defQueue.splice(i, 1);
|
|
2295
|
+
}
|
|
2296
|
+
});
|
|
2297
|
+
delete context.defQueueMap[id];
|
|
2298
|
+
if (mod) {
|
|
2299
|
+
if (mod.events.defined) {
|
|
2300
|
+
undefEvents[id] = mod.events;
|
|
2301
|
+
}
|
|
2302
|
+
cleanRegistry(id);
|
|
2303
|
+
}
|
|
2304
|
+
};
|
|
2305
|
+
}
|
|
2306
|
+
return localRequire;
|
|
2307
|
+
},
|
|
2308
|
+
/**
|
|
2309
|
+
* Called to enable a module if it is still in the registry
|
|
2310
|
+
* awaiting enablement. A second arg, parent, the parent module,
|
|
2311
|
+
* is passed in for context, when this method is overridden by
|
|
2312
|
+
* the optimizer. Not shown here to keep code compact.
|
|
2313
|
+
*/ enable: function enable(depMap) {
|
|
2314
|
+
var mod = getOwn(registry, depMap.id);
|
|
2315
|
+
if (mod) {
|
|
2316
|
+
getModule(depMap).enable();
|
|
2317
|
+
}
|
|
2318
|
+
},
|
|
2319
|
+
/**
|
|
2320
|
+
* Internal method used by environment adapters to complete a load event.
|
|
2321
|
+
* A load event could be a script load or just a load pass from a synchronous
|
|
2322
|
+
* load call.
|
|
2323
|
+
* @param {String} moduleName the name of the module to potentially complete.
|
|
2324
|
+
*/ completeLoad: function completeLoad(moduleName) {
|
|
2325
|
+
var found, args, mod, shim = getOwn(_config.shim, moduleName) || {}, shExports = shim.exports;
|
|
2326
|
+
takeGlobalQueue();
|
|
2327
|
+
while(defQueue.length){
|
|
2328
|
+
args = defQueue.shift();
|
|
2329
|
+
if (args[0] === null) {
|
|
2330
|
+
args[0] = moduleName;
|
|
2331
|
+
if (found) {
|
|
2332
|
+
break;
|
|
2333
|
+
}
|
|
2334
|
+
found = true;
|
|
2335
|
+
} else if (args[0] === moduleName) {
|
|
2336
|
+
found = true;
|
|
2337
|
+
}
|
|
2338
|
+
callGetModule(args);
|
|
2339
|
+
}
|
|
2340
|
+
context.defQueueMap = {};
|
|
2341
|
+
mod = getOwn(registry, moduleName);
|
|
2342
|
+
if (!found && !hasProp(_defined, moduleName) && mod && !mod.inited) {
|
|
2343
|
+
if (_config.enforceDefine && (!shExports || !getGlobal(shExports))) {
|
|
2344
|
+
if (hasPathFallback(moduleName)) {
|
|
2345
|
+
return;
|
|
2346
|
+
} else {
|
|
2347
|
+
return onError(makeError("nodefine", "No define call for " + moduleName, null, [
|
|
2348
|
+
moduleName
|
|
2349
|
+
]));
|
|
2350
|
+
}
|
|
2351
|
+
} else {
|
|
2352
|
+
callGetModule([
|
|
2353
|
+
moduleName,
|
|
2354
|
+
shim.deps || [],
|
|
2355
|
+
shim.exportsFn
|
|
2356
|
+
]);
|
|
2357
|
+
}
|
|
2358
|
+
}
|
|
2359
|
+
checkLoaded(moduleName);
|
|
2360
|
+
},
|
|
2361
|
+
/**
|
|
2362
|
+
* Converts a module name to a file path. Supports cases where
|
|
2363
|
+
* moduleName may actually be just an URL.
|
|
2364
|
+
* Note that it **does not** call normalize on the moduleName,
|
|
2365
|
+
* it is assumed to have already been normalized. This is an
|
|
2366
|
+
* internal API, not a public one. Use toUrl for the public API.
|
|
2367
|
+
*/ nameToUrl: function nameToUrl(moduleName, ext, skipExt) {
|
|
2368
|
+
var paths, syms, i, parentModule, url, parentPath, bundleId, pkgMain = getOwn(_config.pkgs, moduleName);
|
|
2369
|
+
if (pkgMain) {
|
|
2370
|
+
moduleName = pkgMain;
|
|
2371
|
+
}
|
|
2372
|
+
bundleId = getOwn(bundlesMap, moduleName);
|
|
2373
|
+
if (bundleId) {
|
|
2374
|
+
return context.nameToUrl(bundleId, ext, skipExt);
|
|
2375
|
+
}
|
|
2376
|
+
if (req.jsExtRegExp.test(moduleName)) {
|
|
2377
|
+
url = moduleName + (ext || "");
|
|
2378
|
+
} else {
|
|
2379
|
+
paths = _config.paths;
|
|
2380
|
+
syms = moduleName.split("/");
|
|
2381
|
+
for(i = syms.length; i > 0; i -= 1){
|
|
2382
|
+
parentModule = syms.slice(0, i).join("/");
|
|
2383
|
+
parentPath = getOwn(paths, parentModule);
|
|
2384
|
+
if (parentPath) {
|
|
2385
|
+
if (isArray(parentPath)) {
|
|
2386
|
+
parentPath = parentPath[0];
|
|
2387
|
+
}
|
|
2388
|
+
syms.splice(0, i, parentPath);
|
|
2389
|
+
break;
|
|
2390
|
+
}
|
|
2391
|
+
}
|
|
2392
|
+
url = syms.join("/");
|
|
2393
|
+
url += ext || (/^data\:|^blob\:|\?/.test(url) || skipExt ? "" : ".js");
|
|
2394
|
+
url = (url.charAt(0) === "/" || url.match(/^[\w\+\.\-]+:/) ? "" : _config.baseUrl) + url;
|
|
2395
|
+
}
|
|
2396
|
+
return _config.urlArgs && !/^blob\:/.test(url) ? url + _config.urlArgs(moduleName, url) : url;
|
|
2397
|
+
},
|
|
2398
|
+
//Delegates to req.load. Broken out as a separate function to
|
|
2399
|
+
//allow overriding in the optimizer.
|
|
2400
|
+
load: function load(id, url) {
|
|
2401
|
+
req.load(context, id, url);
|
|
2402
|
+
},
|
|
2403
|
+
/**
|
|
2404
|
+
* Executes a module callback function. Broken out as a separate function
|
|
2405
|
+
* solely to allow the build system to sequence the files in the built
|
|
2406
|
+
* layer in the right sequence.
|
|
2407
|
+
*
|
|
2408
|
+
* @private
|
|
2409
|
+
*/ execCb: function execCb(name, callback, args, exports2, maps) {
|
|
2410
|
+
return callback.apply(exports2, args);
|
|
2411
|
+
},
|
|
2412
|
+
/**
|
|
2413
|
+
* callback for script loads, used to check status of loading.
|
|
2414
|
+
*
|
|
2415
|
+
* @param {Event} evt the event from the browser for the script
|
|
2416
|
+
* that was loaded.
|
|
2417
|
+
*/ onScriptLoad: function onScriptLoad(evt) {
|
|
2418
|
+
if (evt.type === "noload") {
|
|
2419
|
+
context.completeLoad(evt.id);
|
|
2420
|
+
return;
|
|
2421
|
+
}
|
|
2422
|
+
if (evt.type === "load" || readyRegExp.test((evt.currentTarget || evt.srcElement).readyState)) {
|
|
2423
|
+
interactiveScript = null;
|
|
2424
|
+
var data = getScriptData(evt);
|
|
2425
|
+
context.completeLoad(data.id);
|
|
2426
|
+
}
|
|
2427
|
+
},
|
|
2428
|
+
/**
|
|
2429
|
+
* Callback for script errors.
|
|
2430
|
+
*/ onScriptError: function onScriptError(evt) {
|
|
2431
|
+
var data = getScriptData(evt);
|
|
2432
|
+
if (!hasPathFallback(data.id)) {
|
|
2433
|
+
var parents = [];
|
|
2434
|
+
eachProp(registry, function(value, key) {
|
|
2435
|
+
if (key.indexOf("_@r") !== 0) {
|
|
2436
|
+
each(value.depMaps, function(depMap) {
|
|
2437
|
+
if (depMap.id === data.id) {
|
|
2438
|
+
parents.push(key);
|
|
2439
|
+
return true;
|
|
2440
|
+
}
|
|
2441
|
+
});
|
|
2442
|
+
}
|
|
2443
|
+
});
|
|
2444
|
+
return onError(makeError("scripterror", 'Script error for "' + data.id + (parents.length ? '", needed by: ' + parents.join(", ") : '"'), evt, [
|
|
2445
|
+
data.id
|
|
2446
|
+
]));
|
|
2447
|
+
}
|
|
2448
|
+
}
|
|
2449
|
+
};
|
|
2450
|
+
context.require = context.makeRequire();
|
|
2451
|
+
return context;
|
|
2452
|
+
}
|
|
2453
|
+
req = requirejs = function requirejs2(deps, callback, errback, optional) {
|
|
2454
|
+
var context, config, contextName = defContextName;
|
|
2455
|
+
if (!isArray(deps) && typeof deps !== "string") {
|
|
2456
|
+
config = deps;
|
|
2457
|
+
if (isArray(callback)) {
|
|
2458
|
+
deps = callback;
|
|
2459
|
+
callback = errback;
|
|
2460
|
+
errback = optional;
|
|
2461
|
+
} else {
|
|
2462
|
+
deps = [];
|
|
2463
|
+
}
|
|
2464
|
+
}
|
|
2465
|
+
if (config && config.context) {
|
|
2466
|
+
contextName = config.context;
|
|
2467
|
+
}
|
|
2468
|
+
context = getOwn(contexts, contextName);
|
|
2469
|
+
if (!context) {
|
|
2470
|
+
context = contexts[contextName] = req.s.newContext(contextName);
|
|
2471
|
+
}
|
|
2472
|
+
if (config) {
|
|
2473
|
+
context.configure(config);
|
|
2474
|
+
}
|
|
2475
|
+
return context.require(deps, callback, errback);
|
|
2476
|
+
};
|
|
2477
|
+
req.config = function(config) {
|
|
2478
|
+
return req(config);
|
|
2479
|
+
};
|
|
2480
|
+
req.nextTick = typeof setTimeout !== "undefined" ? function(fn) {
|
|
2481
|
+
setTimeout(fn, 4);
|
|
2482
|
+
} : function(fn) {
|
|
2483
|
+
fn();
|
|
2484
|
+
};
|
|
2485
|
+
if (!require) {
|
|
2486
|
+
require = req;
|
|
2487
|
+
}
|
|
2488
|
+
req.version = version;
|
|
2489
|
+
req.jsExtRegExp = /^\/|:|\?|\.js$/;
|
|
2490
|
+
req.isBrowser = isBrowser;
|
|
2491
|
+
s = req.s = {
|
|
2492
|
+
contexts: contexts,
|
|
2493
|
+
newContext: newContext
|
|
2494
|
+
};
|
|
2495
|
+
req({});
|
|
2496
|
+
each([
|
|
2497
|
+
"toUrl",
|
|
2498
|
+
"undef",
|
|
2499
|
+
"defined",
|
|
2500
|
+
"specified"
|
|
2501
|
+
], function(prop) {
|
|
2502
|
+
req[prop] = function() {
|
|
2503
|
+
var ctx = contexts[defContextName];
|
|
2504
|
+
return ctx.require[prop].apply(ctx, arguments);
|
|
2505
|
+
};
|
|
2506
|
+
});
|
|
2507
|
+
if (isBrowser) {
|
|
2508
|
+
head = s.head = document.getElementsByTagName("head")[0];
|
|
2509
|
+
baseElement = document.getElementsByTagName("base")[0];
|
|
2510
|
+
if (baseElement) {
|
|
2511
|
+
head = s.head = baseElement.parentNode;
|
|
2512
|
+
}
|
|
2513
|
+
}
|
|
2514
|
+
req.onError = defaultOnError;
|
|
2515
|
+
req.createNode = function(config, moduleName, url) {
|
|
2516
|
+
var node = config.xhtml ? document.createElementNS("http://www.w3.org/1999/xhtml", "html:script") : document.createElement("script");
|
|
2517
|
+
node.type = config.scriptType || "text/javascript";
|
|
2518
|
+
node.charset = "utf-8";
|
|
2519
|
+
node.async = true;
|
|
2520
|
+
return node;
|
|
2521
|
+
};
|
|
2522
|
+
req.load = function(context, moduleName, url) {
|
|
2523
|
+
var config = context && context.config || {}, node;
|
|
2524
|
+
if (isBrowser) {
|
|
2525
|
+
node = req.createNode(config, moduleName, url);
|
|
2526
|
+
node.setAttribute("data-requirecontext", context.contextName);
|
|
2527
|
+
node.setAttribute("data-requiremodule", moduleName);
|
|
2528
|
+
if (node.attachEvent && //Check if node.attachEvent is artificially added by custom script or
|
|
2529
|
+
//natively supported by browser
|
|
2530
|
+
//read https://github.com/requirejs/requirejs/issues/187
|
|
2531
|
+
//if we can NOT find [native code] then it must NOT natively supported.
|
|
2532
|
+
//in IE8, node.attachEvent does not have toString()
|
|
2533
|
+
//Note the test for "[native code" with no closing brace, see:
|
|
2534
|
+
//https://github.com/requirejs/requirejs/issues/273
|
|
2535
|
+
!(node.attachEvent.toString && node.attachEvent.toString().indexOf("[native code") < 0) && !isOpera) {
|
|
2536
|
+
useInteractive = true;
|
|
2537
|
+
node.attachEvent("onreadystatechange", context.onScriptLoad);
|
|
2538
|
+
} else {
|
|
2539
|
+
node.addEventListener("load", context.onScriptLoad, false);
|
|
2540
|
+
node.addEventListener("error", context.onScriptError, false);
|
|
2541
|
+
}
|
|
2542
|
+
if (importMaps[moduleName]) {
|
|
2543
|
+
context.onScriptLoad({
|
|
2544
|
+
id: moduleName,
|
|
2545
|
+
node: req.createNode(config, moduleName, url),
|
|
2546
|
+
type: "noload"
|
|
2547
|
+
});
|
|
2548
|
+
} else node.src = url;
|
|
2549
|
+
if (config.onNodeCreated) {
|
|
2550
|
+
config.onNodeCreated(node, config, moduleName, url);
|
|
2551
|
+
}
|
|
2552
|
+
currentlyAddingScript = node;
|
|
2553
|
+
if (baseElement) {
|
|
2554
|
+
head.insertBefore(node, baseElement);
|
|
2555
|
+
} else {
|
|
2556
|
+
head.appendChild(node);
|
|
2557
|
+
}
|
|
2558
|
+
currentlyAddingScript = null;
|
|
2559
|
+
return node;
|
|
2560
|
+
} else if (isWebWorker) {
|
|
2561
|
+
try {
|
|
2562
|
+
setTimeout(function() {}, 0);
|
|
2563
|
+
importScripts(url);
|
|
2564
|
+
context.completeLoad(moduleName);
|
|
2565
|
+
} catch (e) {
|
|
2566
|
+
context.onError(makeError("importscripts", "importScripts failed for " + moduleName + " at " + url, e, [
|
|
2567
|
+
moduleName
|
|
2568
|
+
]));
|
|
2569
|
+
}
|
|
2570
|
+
}
|
|
2571
|
+
};
|
|
2572
|
+
function getInteractiveScript() {
|
|
2573
|
+
if (interactiveScript && interactiveScript.readyState === "interactive") {
|
|
2574
|
+
return interactiveScript;
|
|
2575
|
+
}
|
|
2576
|
+
eachReverse(scripts(), function(script) {
|
|
2577
|
+
if (script.readyState === "interactive") {
|
|
2578
|
+
return interactiveScript = script;
|
|
2579
|
+
}
|
|
2580
|
+
});
|
|
2581
|
+
return interactiveScript;
|
|
2582
|
+
}
|
|
2583
|
+
if (isBrowser && !cfg.skipDataMain) {
|
|
2584
|
+
eachReverse(scripts(), function(script) {
|
|
2585
|
+
if (!head) {
|
|
2586
|
+
head = script.parentNode;
|
|
2587
|
+
}
|
|
2588
|
+
dataMain = script.getAttribute("data-main");
|
|
2589
|
+
if (dataMain) {
|
|
2590
|
+
mainScript = dataMain;
|
|
2591
|
+
if (!cfg.baseUrl && mainScript.indexOf("!") === -1) {
|
|
2592
|
+
src = mainScript.split("/");
|
|
2593
|
+
mainScript = src.pop();
|
|
2594
|
+
subPath = src.length ? src.join("/") + "/" : "./";
|
|
2595
|
+
cfg.baseUrl = subPath;
|
|
2596
|
+
}
|
|
2597
|
+
mainScript = mainScript.replace(jsSuffixRegExp, "");
|
|
2598
|
+
if (req.jsExtRegExp.test(mainScript)) {
|
|
2599
|
+
mainScript = dataMain;
|
|
2600
|
+
}
|
|
2601
|
+
cfg.deps = cfg.deps ? cfg.deps.concat(mainScript) : [
|
|
2602
|
+
mainScript
|
|
2603
|
+
];
|
|
2604
|
+
return true;
|
|
2605
|
+
}
|
|
2606
|
+
});
|
|
2607
|
+
}
|
|
2608
|
+
define = function define2(name, re, callback) {
|
|
2609
|
+
var _deps = function deps() {
|
|
2610
|
+
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
2611
|
+
args[_key] = arguments[_key];
|
|
2612
|
+
}
|
|
2613
|
+
_deps.forEach(function(k, i) {
|
|
2614
|
+
if (importMaps[k]) {
|
|
2615
|
+
var r = importMaps[k];
|
|
2616
|
+
args[i] = r;
|
|
2617
|
+
}
|
|
2618
|
+
});
|
|
2619
|
+
return re.apply(this, args);
|
|
2620
|
+
};
|
|
2621
|
+
var node, context;
|
|
2622
|
+
if (typeof name !== "string") {
|
|
2623
|
+
callback = _deps;
|
|
2624
|
+
_deps = name;
|
|
2625
|
+
name = null;
|
|
2626
|
+
}
|
|
2627
|
+
if (!isArray(_deps)) {
|
|
2628
|
+
callback = _deps;
|
|
2629
|
+
_deps = null;
|
|
2630
|
+
}
|
|
2631
|
+
if (!_deps && isFunction(callback)) {
|
|
2632
|
+
_deps = [];
|
|
2633
|
+
if (callback.length) {
|
|
2634
|
+
callback.toString().replace(commentRegExp, commentReplace).replace(cjsRequireRegExp, function(match, dep) {
|
|
2635
|
+
_deps.push(dep);
|
|
2636
|
+
});
|
|
2637
|
+
_deps = (callback.length === 1 ? [
|
|
2638
|
+
"require"
|
|
2639
|
+
] : [
|
|
2640
|
+
"require",
|
|
2641
|
+
"exports",
|
|
2642
|
+
"module"
|
|
2643
|
+
]).concat(_deps);
|
|
2644
|
+
}
|
|
2645
|
+
}
|
|
2646
|
+
if (useInteractive) {
|
|
2647
|
+
node = currentlyAddingScript || getInteractiveScript();
|
|
2648
|
+
if (node) {
|
|
2649
|
+
if (!name) {
|
|
2650
|
+
name = node.getAttribute("data-requiremodule");
|
|
2651
|
+
}
|
|
2652
|
+
context = contexts[node.getAttribute("data-requirecontext")];
|
|
2653
|
+
}
|
|
2654
|
+
}
|
|
2655
|
+
if (context) {
|
|
2656
|
+
context.defQueue.push([
|
|
2657
|
+
name,
|
|
2658
|
+
_deps,
|
|
2659
|
+
callback
|
|
2660
|
+
]);
|
|
2661
|
+
context.defQueueMap[name] = true;
|
|
2662
|
+
} else {
|
|
2663
|
+
globalDefQueue.push([
|
|
2664
|
+
name,
|
|
2665
|
+
_deps,
|
|
2666
|
+
callback
|
|
2667
|
+
]);
|
|
2668
|
+
}
|
|
2669
|
+
};
|
|
2670
|
+
define.amd = {
|
|
2671
|
+
jQuery: true
|
|
2672
|
+
};
|
|
2673
|
+
req.exec = function(text) {
|
|
2674
|
+
return eval(text);
|
|
2675
|
+
};
|
|
2676
|
+
req(cfg);
|
|
2677
|
+
return {
|
|
2678
|
+
requirejs: requirejs,
|
|
2679
|
+
require: require,
|
|
2680
|
+
define: define
|
|
2681
|
+
};
|
|
2682
|
+
}
|
|
2683
|
+
// src/utils/i18n.ts
|
|
2684
|
+
var locale = {
|
|
2685
|
+
zh: {
|
|
2686
|
+
require: "{label}\u4E0D\u80FD\u4E3A\u7A7A",
|
|
2687
|
+
noErrorMsg: "\u672A\u8BBE\u7F6E\u9519\u8BEF\u63D0\u793A"
|
|
2688
|
+
},
|
|
2689
|
+
en: {
|
|
2690
|
+
require: "{label} is required",
|
|
2691
|
+
noErrorMsg: "Error message not set"
|
|
2692
|
+
}
|
|
2693
|
+
};
|
|
2694
|
+
locale.zh_CN = locale.zh;
|
|
2695
|
+
locale.en_US = locale.en;
|
|
2696
|
+
locale["zh-CN"] = locale.zh;
|
|
2697
|
+
locale["en-US"] = locale.en;
|
|
2698
|
+
var i18n_default = locale;
|
|
2699
|
+
// src/core/index.ts
|
|
2700
|
+
var Core = /*#__PURE__*/ function() {
|
|
2701
|
+
"use strict";
|
|
2702
|
+
function Core1(param) {
|
|
2703
|
+
var runtime = param.runtime, runtimeMapping = param.runtimeMapping, service = param.service, cdnUrl = param.cdnUrl, cdnPath = param.cdnPath, modUrl = param.modUrl, modPath = param.modPath, pageUrl = param.pageUrl, pagePath = param.pagePath, staticUrl = param.staticUrl, importMaps2 = param.importMaps, basicsType = param.basicsType, defaultFormAttr = param.defaultFormAttr, importModules = param.importModules, i18n = param.i18n, localeMapping = param.localeMapping, localeDefault = param.localeDefault, _param_message = param.message, message = _param_message === void 0 ? {} : _param_message, argv = param.argv;
|
|
2704
|
+
var _this = this;
|
|
2705
|
+
_class_call_check(this, Core1);
|
|
2706
|
+
// 全局配置
|
|
2707
|
+
this.runtime = true;
|
|
2708
|
+
this.runtimeMapping = {
|
|
2709
|
+
drop: "dropruntime",
|
|
2710
|
+
drag: "dragruntime"
|
|
2711
|
+
};
|
|
2712
|
+
this.service = "";
|
|
2713
|
+
this.cdnPath = "/lib";
|
|
2714
|
+
this.modPath = "/package";
|
|
2715
|
+
this.pageUrl = "";
|
|
2716
|
+
this.pagePath = "/page";
|
|
2717
|
+
this.importMaps = {};
|
|
2718
|
+
// 基础模块分类名
|
|
2719
|
+
this.basicsType = "basics";
|
|
2720
|
+
// 全局组件map对象,同一个core实例加载的snack模块都将在此对象中
|
|
2721
|
+
this.moduleMaps = {};
|
|
2722
|
+
// 全局公共存储对象,不同组件内可共享数据
|
|
2723
|
+
this.global = {};
|
|
2724
|
+
this.message = {};
|
|
2725
|
+
// 国际化数据
|
|
2726
|
+
this.i18n = i18n_default;
|
|
2727
|
+
// 全局默认配置
|
|
2728
|
+
this.defaultFormAttr = {
|
|
2729
|
+
passwordFlag: true,
|
|
2730
|
+
hideNoSubmit: true,
|
|
2731
|
+
verifyOnEvents: [
|
|
2732
|
+
"onChange",
|
|
2733
|
+
"onBlur"
|
|
2734
|
+
],
|
|
2735
|
+
verifyASTime: 300
|
|
2736
|
+
};
|
|
2737
|
+
// 本地缓存snack模块class
|
|
2738
|
+
this.importModules = {};
|
|
2739
|
+
// 国际化转换关系
|
|
2740
|
+
this.localeMapping = {};
|
|
2741
|
+
this.localeDefault = "zh";
|
|
2742
|
+
this.argv = {};
|
|
2743
|
+
/**
|
|
2744
|
+
* 事件存储对象
|
|
2745
|
+
* @private
|
|
2746
|
+
*/ this.eventList = {};
|
|
2747
|
+
this.loadingPromises = /* @__PURE__ */ new Map();
|
|
2748
|
+
/**
|
|
2749
|
+
* 全局Snack模块语言切换方法
|
|
2750
|
+
* @param l 语言,默认 'zh'
|
|
2751
|
+
*/ this.language = function() {
|
|
2752
|
+
var l = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : window.localStorage.getItem("language") || "zh";
|
|
2753
|
+
Object.values(_this.moduleMaps).forEach(function(item) {
|
|
2754
|
+
return item === null || item === void 0 ? void 0 : item.$language(l);
|
|
2755
|
+
});
|
|
2756
|
+
};
|
|
2757
|
+
this.exprRegx = /{{(.*?)}}/g;
|
|
2758
|
+
if (runtime !== void 0) this.runtime = runtime;
|
|
2759
|
+
if (runtimeMapping !== void 0) this.runtimeMapping = runtimeMapping;
|
|
2760
|
+
if (service !== void 0) this.service = service;
|
|
2761
|
+
if (cdnPath !== void 0) this.cdnPath = cdnPath;
|
|
2762
|
+
if (modPath !== void 0) this.modPath = modPath;
|
|
2763
|
+
if (pagePath !== void 0) this.pagePath = pagePath;
|
|
2764
|
+
if (defaultFormAttr !== void 0) this.defaultFormAttr = _object_spread({}, this.defaultFormAttr, defaultFormAttr);
|
|
2765
|
+
this.pageUrl = pageUrl || this.service + this.pagePath;
|
|
2766
|
+
this.staticUrl = staticUrl;
|
|
2767
|
+
if (importMaps2) this.importMaps = importMaps2;
|
|
2768
|
+
if (basicsType !== void 0) this.basicsType = basicsType;
|
|
2769
|
+
if ((typeof importModules === "undefined" ? "undefined" : _type_of(importModules)) === "object") this.importModules = importModules;
|
|
2770
|
+
if ((typeof i18n === "undefined" ? "undefined" : _type_of(i18n)) === "object") this.setI18n(i18n);
|
|
2771
|
+
if ((typeof localeMapping === "undefined" ? "undefined" : _type_of(localeMapping)) === "object") this.localeMapping = localeMapping;
|
|
2772
|
+
if (typeof localeDefault === "string") this.localeDefault = localeDefault;
|
|
2773
|
+
if ((typeof localeMapping === "undefined" ? "undefined" : _type_of(localeMapping)) === "object") this.message = message;
|
|
2774
|
+
if ((typeof argv === "undefined" ? "undefined" : _type_of(argv)) === "object") this.argv = argv;
|
|
2775
|
+
var rjs = _default(this, importMaps2);
|
|
2776
|
+
this.require = rjs.require;
|
|
2777
|
+
this.define = rjs.define;
|
|
2778
|
+
window.snackdefine = rjs.define;
|
|
2779
|
+
}
|
|
2780
|
+
_create_class(Core1, [
|
|
2781
|
+
{
|
|
2782
|
+
/**
|
|
2783
|
+
* 注册事件
|
|
2784
|
+
* @param eventName 事件名称
|
|
2785
|
+
* @param cb 事件回调函数
|
|
2786
|
+
*/ key: "addEvent",
|
|
2787
|
+
value: function addEvent(eventName, cb) {
|
|
2788
|
+
if (!this.eventList[eventName]) this.eventList[eventName] = [];
|
|
2789
|
+
if (this.eventList[eventName].indexOf(cb) === -1) {
|
|
2790
|
+
this.eventList[eventName].push(cb);
|
|
2791
|
+
return true;
|
|
2792
|
+
}
|
|
2793
|
+
return false;
|
|
2794
|
+
}
|
|
2795
|
+
},
|
|
2796
|
+
{
|
|
2797
|
+
/**
|
|
2798
|
+
* 移除事件
|
|
2799
|
+
* @param eventName 事件名称
|
|
2800
|
+
* @param cb 解除绑定的事件回调
|
|
2801
|
+
*/ key: "removeEvent",
|
|
2802
|
+
value: function removeEvent(eventName, cb) {
|
|
2803
|
+
if (!this.eventList[eventName]) return false;
|
|
2804
|
+
if (!cb) delete this.eventList[eventName];
|
|
2805
|
+
var index = this.eventList[eventName].indexOf(cb);
|
|
2806
|
+
if (index === -1) return false;
|
|
2807
|
+
this.eventList[eventName].splice(index, 1);
|
|
2808
|
+
return true;
|
|
2809
|
+
}
|
|
2810
|
+
},
|
|
2811
|
+
{
|
|
2812
|
+
/**
|
|
2813
|
+
* 发送事件
|
|
2814
|
+
* @param eventName 事件名称
|
|
2815
|
+
* @param args 事件方法参数
|
|
2816
|
+
*/ key: "sendEvent",
|
|
2817
|
+
value: function sendEvent(eventName, args) {
|
|
2818
|
+
var _this = this;
|
|
2819
|
+
if (_instanceof(this.eventList[eventName], Array)) {
|
|
2820
|
+
this.eventList[eventName].forEach(function(cb) {
|
|
2821
|
+
cb.apply(_this, args !== null && args !== void 0 ? args : []);
|
|
2822
|
+
return true;
|
|
2823
|
+
});
|
|
2824
|
+
}
|
|
2825
|
+
return false;
|
|
2826
|
+
}
|
|
2827
|
+
},
|
|
2828
|
+
{
|
|
2829
|
+
key: "module",
|
|
2830
|
+
value: /**
|
|
2831
|
+
* 按模块名称加载模块
|
|
2832
|
+
* @param {LoadModuleConfig}
|
|
2833
|
+
* @param callback 回调方法,存在该参数则Promises失效
|
|
2834
|
+
* @return Snack 模块键值对 {snackName:snackClass}
|
|
2835
|
+
*/ function module(_0, _1) {
|
|
2836
|
+
return _async_to_generator(function(param, callback) {
|
|
2837
|
+
var module, _param_service, service, cdnUrl, _param_cdnPath, cdnPath, modUrl, _param_modPath, modPath, _param_staticUrl, staticUrl, importMaps2, _param_config, config, _this_cdnUrl, _this_modUrl, snack, i, l, _this_importModules_type, _module_i, _module_i_type, type, name, setting, modConfig, cache, _this_importModules_type1, cacheSetting, mods;
|
|
2838
|
+
return _ts_generator(this, function(_state) {
|
|
2839
|
+
switch(_state.label){
|
|
2840
|
+
case 0:
|
|
2841
|
+
module = param.module, _param_service = param.service, service = _param_service === void 0 ? this.service : _param_service, cdnUrl = param.cdnUrl, _param_cdnPath = param.cdnPath, cdnPath = _param_cdnPath === void 0 ? this.cdnPath : _param_cdnPath, modUrl = param.modUrl, _param_modPath = param.modPath, modPath = _param_modPath === void 0 ? this.modPath : _param_modPath, _param_staticUrl = param.staticUrl, staticUrl = _param_staticUrl === void 0 ? this.staticUrl : _param_staticUrl, importMaps2 = param.importMaps, _param_config = param.config, config = _param_config === void 0 ? {} : _param_config;
|
|
2842
|
+
if (!_instanceof(module, Array) && (typeof module === "undefined" ? "undefined" : _type_of(module)) === "object") module = [
|
|
2843
|
+
module
|
|
2844
|
+
];
|
|
2845
|
+
if (cdnUrl === void 0) cdnUrl = (_this_cdnUrl = this.cdnUrl) !== null && _this_cdnUrl !== void 0 ? _this_cdnUrl : service + cdnPath;
|
|
2846
|
+
if (modUrl === void 0) modUrl = (_this_modUrl = this.modUrl) !== null && _this_modUrl !== void 0 ? _this_modUrl : service + modPath;
|
|
2847
|
+
if (modUrl === void 0) return [
|
|
2848
|
+
2,
|
|
2849
|
+
console.error('SnackCore: param "modUrl" is missing')
|
|
2850
|
+
];
|
|
2851
|
+
if (cdnUrl !== void 0) config.baseUrl = cdnUrl;
|
|
2852
|
+
if (staticUrl !== void 0) config.staticUrl = staticUrl;
|
|
2853
|
+
snack = {};
|
|
2854
|
+
i = 0, l = module.length;
|
|
2855
|
+
_state.label = 1;
|
|
2856
|
+
case 1:
|
|
2857
|
+
if (!(i < l)) return [
|
|
2858
|
+
3,
|
|
2859
|
+
5
|
|
2860
|
+
];
|
|
2861
|
+
_module_i = module[i], _module_i_type = _module_i.type, type = _module_i_type === void 0 ? "" : _module_i_type, name = _module_i.name, setting = _module_i.setting, modConfig = _module_i.config;
|
|
2862
|
+
name = name.toLowerCase();
|
|
2863
|
+
cache = (_this_importModules_type = this.importModules[type]) === null || _this_importModules_type === void 0 ? void 0 : _this_importModules_type[name];
|
|
2864
|
+
if (!cache) return [
|
|
2865
|
+
3,
|
|
2866
|
+
2
|
|
2867
|
+
];
|
|
2868
|
+
snack[name] = cache;
|
|
2869
|
+
if (setting) {
|
|
2870
|
+
;
|
|
2871
|
+
cacheSetting = (_this_importModules_type1 = this.importModules[type]) === null || _this_importModules_type1 === void 0 ? void 0 : _this_importModules_type1[name + "setting"];
|
|
2872
|
+
if (cacheSetting) snack[name + "setting"] = cacheSetting;
|
|
2873
|
+
}
|
|
2874
|
+
return [
|
|
2875
|
+
3,
|
|
2876
|
+
4
|
|
2877
|
+
];
|
|
2878
|
+
case 2:
|
|
2879
|
+
if (type && typeof type === "string") type = "/".concat(type);
|
|
2880
|
+
if (modConfig) modConfig = _object_spread({}, config, modConfig);
|
|
2881
|
+
else modConfig = config;
|
|
2882
|
+
return [
|
|
2883
|
+
4,
|
|
2884
|
+
this.load({
|
|
2885
|
+
url: "".concat(modUrl).concat(type || "", "/").concat(this.runtime ? this.runtimeMapping[name] || name : name).concat(setting ? "/setting" : "", "/index.js"),
|
|
2886
|
+
config: modConfig,
|
|
2887
|
+
importMaps: importMaps2
|
|
2888
|
+
})
|
|
2889
|
+
];
|
|
2890
|
+
case 3:
|
|
2891
|
+
mods = _state.sent();
|
|
2892
|
+
if (_instanceof(mods, Error)) return [
|
|
2893
|
+
3,
|
|
2894
|
+
4
|
|
2895
|
+
];
|
|
2896
|
+
snack = this.addSnack(snack, mods);
|
|
2897
|
+
_state.label = 4;
|
|
2898
|
+
case 4:
|
|
2899
|
+
i++;
|
|
2900
|
+
return [
|
|
2901
|
+
3,
|
|
2902
|
+
1
|
|
2903
|
+
];
|
|
2904
|
+
case 5:
|
|
2905
|
+
if (callback) callback(snack);
|
|
2906
|
+
return [
|
|
2907
|
+
2,
|
|
2908
|
+
snack
|
|
2909
|
+
];
|
|
2910
|
+
}
|
|
2911
|
+
});
|
|
2912
|
+
}).apply(this, arguments);
|
|
2913
|
+
}
|
|
2914
|
+
},
|
|
2915
|
+
{
|
|
2916
|
+
key: "moduleURL",
|
|
2917
|
+
value: /**
|
|
2918
|
+
* 按模块地址加载模块
|
|
2919
|
+
* @param {LoadModuleURLConfig}
|
|
2920
|
+
* @param callback 回调方法,存在该参数则Promises失效
|
|
2921
|
+
* @return Snack 模块键值对 {snackName:snackClass}
|
|
2922
|
+
*/ function moduleURL(_0, _1) {
|
|
2923
|
+
return _async_to_generator(function(param, callback) {
|
|
2924
|
+
var urls, cdnUrl, _param_staticUrl, staticUrl, importMaps2, _param_config, config, _this_cdnUrl, snack, i, l, url, mods;
|
|
2925
|
+
return _ts_generator(this, function(_state) {
|
|
2926
|
+
switch(_state.label){
|
|
2927
|
+
case 0:
|
|
2928
|
+
urls = param.urls, cdnUrl = param.cdnUrl, _param_staticUrl = param.staticUrl, staticUrl = _param_staticUrl === void 0 ? this.staticUrl : _param_staticUrl, importMaps2 = param.importMaps, _param_config = param.config, config = _param_config === void 0 ? {} : _param_config;
|
|
2929
|
+
if (typeof urls === "string") urls = [
|
|
2930
|
+
urls
|
|
2931
|
+
];
|
|
2932
|
+
if (cdnUrl === void 0) cdnUrl = (_this_cdnUrl = this.cdnUrl) !== null && _this_cdnUrl !== void 0 ? _this_cdnUrl : this.service + this.cdnPath;
|
|
2933
|
+
if (cdnUrl !== void 0) config.baseUrl = cdnUrl;
|
|
2934
|
+
if (staticUrl !== void 0) config.staticUrl = staticUrl;
|
|
2935
|
+
snack = {};
|
|
2936
|
+
i = 0, l = urls.length;
|
|
2937
|
+
_state.label = 1;
|
|
2938
|
+
case 1:
|
|
2939
|
+
if (!(i < l)) return [
|
|
2940
|
+
3,
|
|
2941
|
+
4
|
|
2942
|
+
];
|
|
2943
|
+
url = urls[i];
|
|
2944
|
+
return [
|
|
2945
|
+
4,
|
|
2946
|
+
this.load({
|
|
2947
|
+
url: url,
|
|
2948
|
+
config: config,
|
|
2949
|
+
importMaps: importMaps2
|
|
2950
|
+
})
|
|
2951
|
+
];
|
|
2952
|
+
case 2:
|
|
2953
|
+
mods = _state.sent();
|
|
2954
|
+
if (_instanceof(mods, Error)) return [
|
|
2955
|
+
2,
|
|
2956
|
+
null
|
|
2957
|
+
];
|
|
2958
|
+
snack = this.addSnack(snack, mods);
|
|
2959
|
+
_state.label = 3;
|
|
2960
|
+
case 3:
|
|
2961
|
+
i++;
|
|
2962
|
+
return [
|
|
2963
|
+
3,
|
|
2964
|
+
1
|
|
2965
|
+
];
|
|
2966
|
+
case 4:
|
|
2967
|
+
if (callback) callback(snack);
|
|
2968
|
+
return [
|
|
2969
|
+
2,
|
|
2970
|
+
snack
|
|
2971
|
+
];
|
|
2972
|
+
}
|
|
2973
|
+
});
|
|
2974
|
+
}).apply(this, arguments);
|
|
2975
|
+
}
|
|
2976
|
+
},
|
|
2977
|
+
{
|
|
2978
|
+
// 合并模块类对象,所有模块key均为小写
|
|
2979
|
+
key: "addSnack",
|
|
2980
|
+
value: function addSnack(snack, e) {
|
|
2981
|
+
Object.keys(e).forEach(function(name) {
|
|
2982
|
+
if (name === "default") return true;
|
|
2983
|
+
var key = name.toLowerCase();
|
|
2984
|
+
if (snack[key]) {
|
|
2985
|
+
console.warn("Warn Snack-Core Module: ".concat(name, " has existed "));
|
|
2986
|
+
return true;
|
|
2987
|
+
}
|
|
2988
|
+
snack[key] = e[name];
|
|
2989
|
+
});
|
|
2990
|
+
return snack;
|
|
2991
|
+
}
|
|
2992
|
+
},
|
|
2993
|
+
{
|
|
2994
|
+
/**
|
|
2995
|
+
* umd模块加载方法
|
|
2996
|
+
* @param {LoadConfig} snack模块js地址
|
|
2997
|
+
* @return Snack 模块类对象
|
|
2998
|
+
*/ key: "load",
|
|
2999
|
+
value: function load(param) {
|
|
3000
|
+
var _this = this;
|
|
3001
|
+
var url = param.url, config = param.config, importMaps2 = param.importMaps;
|
|
3002
|
+
var cacheKey = url;
|
|
3003
|
+
if (this.loadingPromises.has(cacheKey)) {
|
|
3004
|
+
return this.loadingPromises.get(cacheKey);
|
|
3005
|
+
}
|
|
3006
|
+
var promise = new Promise(function(callback) {
|
|
3007
|
+
try {
|
|
3008
|
+
var require2;
|
|
3009
|
+
if (importMaps2) {
|
|
3010
|
+
var newRjs = _default(_this, _this.importMaps);
|
|
3011
|
+
require2 = newRjs.require;
|
|
3012
|
+
} else require2 = _this.require;
|
|
3013
|
+
if (config) require2.config(config);
|
|
3014
|
+
var pathArr = url.split("/");
|
|
3015
|
+
pathArr.pop();
|
|
3016
|
+
if (/setting\/index.js$/.test(url)) pathArr.pop();
|
|
3017
|
+
var modName = pathArr.pop();
|
|
3018
|
+
var modType = pathArr.pop();
|
|
3019
|
+
window["__snack_static_".concat(modType, "__")] = (config === null || config === void 0 ? void 0 : config.staticUrl) || "".concat(pathArr.join("/"), "/").concat(modType, "/");
|
|
3020
|
+
require2([
|
|
3021
|
+
url
|
|
3022
|
+
], function(e) {
|
|
3023
|
+
if (!e) console.error("SnackCore load module fail: ", url);
|
|
3024
|
+
callback(e);
|
|
3025
|
+
}, function(err) {
|
|
3026
|
+
console.error("SnackCore load module error: ", err);
|
|
3027
|
+
callback(err);
|
|
3028
|
+
});
|
|
3029
|
+
} catch (e) {
|
|
3030
|
+
callback({});
|
|
3031
|
+
}
|
|
3032
|
+
}).finally(function() {
|
|
3033
|
+
_this.loadingPromises.delete(cacheKey);
|
|
3034
|
+
});
|
|
3035
|
+
this.loadingPromises.set(cacheKey, promise);
|
|
3036
|
+
return promise;
|
|
3037
|
+
}
|
|
3038
|
+
},
|
|
3039
|
+
{
|
|
3040
|
+
/**
|
|
3041
|
+
* 移除模块
|
|
3042
|
+
* @param id snack模块的 $id
|
|
3043
|
+
* @param forceUpdate 是否调用$forceUpdate
|
|
3044
|
+
*/ key: "remove",
|
|
3045
|
+
value: function remove(id) {
|
|
3046
|
+
var forceUpdate = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : true;
|
|
3047
|
+
var _this_moduleMaps_id_data, _this_moduleMaps_id;
|
|
3048
|
+
if (!id || !this.moduleMaps[id]) return false;
|
|
3049
|
+
var parent = (_this_moduleMaps_id = this.moduleMaps[id]) === null || _this_moduleMaps_id === void 0 ? void 0 : (_this_moduleMaps_id_data = _this_moduleMaps_id.data) === null || _this_moduleMaps_id_data === void 0 ? void 0 : _this_moduleMaps_id_data.parent;
|
|
3050
|
+
if (this.moduleMaps[id]) {
|
|
3051
|
+
var _this_moduleMaps_id1;
|
|
3052
|
+
(_this_moduleMaps_id1 = this.moduleMaps[id]) === null || _this_moduleMaps_id1 === void 0 ? void 0 : _this_moduleMaps_id1.$destroy();
|
|
3053
|
+
this.moduleMaps[id] = null;
|
|
3054
|
+
delete this.moduleMaps[id];
|
|
3055
|
+
}
|
|
3056
|
+
if (parent) {
|
|
3057
|
+
var _parent_removeChild, _parent_$forceUpdate;
|
|
3058
|
+
(_parent_removeChild = parent.removeChild) === null || _parent_removeChild === void 0 ? void 0 : _parent_removeChild.call(parent, id);
|
|
3059
|
+
if (forceUpdate) (_parent_$forceUpdate = parent.$forceUpdate) === null || _parent_$forceUpdate === void 0 ? void 0 : _parent_$forceUpdate.call(parent);
|
|
3060
|
+
}
|
|
3061
|
+
this.sendEvent("onRemove", [
|
|
3062
|
+
id
|
|
3063
|
+
]);
|
|
3064
|
+
}
|
|
3065
|
+
},
|
|
3066
|
+
{
|
|
3067
|
+
/**
|
|
3068
|
+
* 清空挂载在sdk内的所有模块
|
|
3069
|
+
* @param forceUpdate 是否调用$forceUpdate
|
|
3070
|
+
*/ key: "empty",
|
|
3071
|
+
value: function empty() {
|
|
3072
|
+
var _this = this;
|
|
3073
|
+
var forceUpdate = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : true;
|
|
3074
|
+
Object.keys(this.moduleMaps).forEach(function(id) {
|
|
3075
|
+
_this.remove(id, forceUpdate);
|
|
3076
|
+
});
|
|
3077
|
+
}
|
|
3078
|
+
},
|
|
3079
|
+
{
|
|
3080
|
+
/**
|
|
3081
|
+
* 国际化数据导入
|
|
3082
|
+
* @param data
|
|
3083
|
+
*/ key: "setI18n",
|
|
3084
|
+
value: function setI18n(data) {
|
|
3085
|
+
var _this = this;
|
|
3086
|
+
Object.keys(data).forEach(function(lang) {
|
|
3087
|
+
if (!_this.i18n[lang]) _this.i18n[lang] = data[lang];
|
|
3088
|
+
else _this.i18n[lang] = _object_spread({}, _this.i18n[lang], data[lang]);
|
|
3089
|
+
});
|
|
3090
|
+
}
|
|
3091
|
+
},
|
|
3092
|
+
{
|
|
3093
|
+
/**
|
|
3094
|
+
* 获取国际化文本
|
|
3095
|
+
* @param ops
|
|
3096
|
+
* @param params
|
|
3097
|
+
*/ key: "intl",
|
|
3098
|
+
value: function intl(ops, params) {
|
|
3099
|
+
return i18nIntl(this, ops, this.i18n, params, void 0, this.i18n);
|
|
3100
|
+
}
|
|
3101
|
+
},
|
|
3102
|
+
{
|
|
3103
|
+
/**
|
|
3104
|
+
* 组件数据解析表达式
|
|
3105
|
+
* @param data
|
|
3106
|
+
*/ key: "exprParseByData",
|
|
3107
|
+
value: function exprParseByData(data) {
|
|
3108
|
+
var _data_data, _data_data1;
|
|
3109
|
+
if (!data) return data;
|
|
3110
|
+
if (data === null || data === void 0 ? void 0 : (_data_data = data.data) === null || _data_data === void 0 ? void 0 : _data_data.D) {
|
|
3111
|
+
var _this_checkHasExpr = this.checkHasExpr(data.data.D), expr = _this_checkHasExpr.expr, D = _this_checkHasExpr.data;
|
|
3112
|
+
if (expr) {
|
|
3113
|
+
this.recursiveParseJson(D, this.getExprArgv(data.data.D.style));
|
|
3114
|
+
data.data.D = D;
|
|
3115
|
+
}
|
|
3116
|
+
}
|
|
3117
|
+
if (data === null || data === void 0 ? void 0 : (_data_data1 = data.data) === null || _data_data1 === void 0 ? void 0 : _data_data1.M) {
|
|
3118
|
+
var _this_checkHasExpr1 = this.checkHasExpr(data.data.M), expr1 = _this_checkHasExpr1.expr, M = _this_checkHasExpr1.data;
|
|
3119
|
+
if (expr1) {
|
|
3120
|
+
this.recursiveParseJson(M, this.getExprArgv(data.data.M));
|
|
3121
|
+
data.data.M = M;
|
|
3122
|
+
}
|
|
3123
|
+
}
|
|
3124
|
+
return data;
|
|
3125
|
+
}
|
|
3126
|
+
},
|
|
3127
|
+
{
|
|
3128
|
+
key: "checkHasExpr",
|
|
3129
|
+
value: function checkHasExpr(data) {
|
|
3130
|
+
if ((typeof data === "undefined" ? "undefined" : _type_of(data)) !== "object") return {
|
|
3131
|
+
expr: false,
|
|
3132
|
+
data: data
|
|
3133
|
+
};
|
|
3134
|
+
try {
|
|
3135
|
+
var str = JSON.stringify(data);
|
|
3136
|
+
if (this.exprRegx.test(str)) return {
|
|
3137
|
+
expr: true,
|
|
3138
|
+
data: JSON.parse(str)
|
|
3139
|
+
};
|
|
3140
|
+
} catch (unused) {}
|
|
3141
|
+
return {
|
|
3142
|
+
expr: false,
|
|
3143
|
+
data: data
|
|
3144
|
+
};
|
|
3145
|
+
}
|
|
3146
|
+
},
|
|
3147
|
+
{
|
|
3148
|
+
key: "evaluateExpression",
|
|
3149
|
+
value: function evaluateExpression(expression, context) {
|
|
3150
|
+
try {
|
|
3151
|
+
return new Function("$", "var data = $.data; return ".concat(expression))(context);
|
|
3152
|
+
} catch (error) {
|
|
3153
|
+
console.error("Error evaluating expression: ".concat(expression), error);
|
|
3154
|
+
return "".concat(expression, ":").concat(error.message);
|
|
3155
|
+
}
|
|
3156
|
+
}
|
|
3157
|
+
},
|
|
3158
|
+
{
|
|
3159
|
+
key: "processTemplateString",
|
|
3160
|
+
value: function processTemplateString(template, context) {
|
|
3161
|
+
var _this = this;
|
|
3162
|
+
var regex = this.exprRegx;
|
|
3163
|
+
return template.replace(regex, function(_, expr) {
|
|
3164
|
+
var result = _this.evaluateExpression(expr.trim(), context);
|
|
3165
|
+
return result !== void 0 ? result : "";
|
|
3166
|
+
});
|
|
3167
|
+
}
|
|
3168
|
+
},
|
|
3169
|
+
{
|
|
3170
|
+
key: "recursiveParseJson",
|
|
3171
|
+
value: function recursiveParseJson(obj, context) {
|
|
3172
|
+
var filterPrototype = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : false;
|
|
3173
|
+
for(var key in obj){
|
|
3174
|
+
if (obj.hasOwnProperty(key)) {
|
|
3175
|
+
if (filterPrototype) {
|
|
3176
|
+
try {
|
|
3177
|
+
JSON.stringify(obj[key]);
|
|
3178
|
+
} catch (unused) {
|
|
3179
|
+
continue;
|
|
3180
|
+
}
|
|
3181
|
+
}
|
|
3182
|
+
if (_type_of(obj[key]) === "object" && obj[key] !== null) {
|
|
3183
|
+
this.recursiveParseJson(obj[key], context, filterPrototype);
|
|
3184
|
+
} else if (typeof obj[key] === "string") {
|
|
3185
|
+
try {
|
|
3186
|
+
obj[key] = this.processTemplateString(obj[key], context);
|
|
3187
|
+
} catch (unused) {}
|
|
3188
|
+
}
|
|
3189
|
+
}
|
|
3190
|
+
}
|
|
3191
|
+
return obj;
|
|
3192
|
+
}
|
|
3193
|
+
},
|
|
3194
|
+
{
|
|
3195
|
+
/**
|
|
3196
|
+
* 表达式入参
|
|
3197
|
+
*/ key: "getExprArgv",
|
|
3198
|
+
value: function getExprArgv(data) {
|
|
3199
|
+
return {
|
|
3200
|
+
argv: this.argv,
|
|
3201
|
+
sdk: this,
|
|
3202
|
+
data: data
|
|
3203
|
+
};
|
|
3204
|
+
}
|
|
3205
|
+
}
|
|
3206
|
+
]);
|
|
3207
|
+
return Core1;
|
|
3208
|
+
}();
|
|
3209
|
+
var core_default = Core;
|
|
3210
|
+
// src/sdk/index.tsx
|
|
3211
|
+
import React5 from "react";
|
|
3212
|
+
import { Get, DeepClone as DeepClone2 } from "@snack-kit/lib";
|
|
3213
|
+
// src/sdk/renderSnack.tsx
|
|
3214
|
+
var renderSnackPage = function renderSnackPage1(props, formatData, onComplete) {
|
|
3215
|
+
var root = props.root, filter = props.filter, drop = props.drop, sdk = props.sdk, content = props.content;
|
|
3216
|
+
var _props_config = props.config, rootProps = _props_config.rootProps, rules = _props_config.rules, data = _props_config.data, snackPageEvent = _props_config.snackPageEvent;
|
|
3217
|
+
if (!root) {
|
|
3218
|
+
var _content_module_data_M, _content_module_data, _content_module, _content_module_data_M1, _content_module_data1, _content_module1;
|
|
3219
|
+
if (!drop || typeof drop !== "function") return null;
|
|
3220
|
+
var props2 = rootProps || {};
|
|
3221
|
+
if (!props2.$snackSDK) props2.$snackSDK = sdk;
|
|
3222
|
+
if (props2.style && (content === null || content === void 0 ? void 0 : (_content_module = content.module) === null || _content_module === void 0 ? void 0 : (_content_module_data = _content_module.data) === null || _content_module_data === void 0 ? void 0 : (_content_module_data_M = _content_module_data.M) === null || _content_module_data_M === void 0 ? void 0 : _content_module_data_M.style)) {
|
|
3223
|
+
var _content_module_data_M2, _content_module_data2, _content_module2;
|
|
3224
|
+
props2.style = _object_spread({}, props2.style, content === null || content === void 0 ? void 0 : (_content_module2 = content.module) === null || _content_module2 === void 0 ? void 0 : (_content_module_data2 = _content_module2.data) === null || _content_module_data2 === void 0 ? void 0 : (_content_module_data_M2 = _content_module_data2.M) === null || _content_module_data_M2 === void 0 ? void 0 : _content_module_data_M2.style);
|
|
3225
|
+
} else props2.style = content === null || content === void 0 ? void 0 : (_content_module1 = content.module) === null || _content_module1 === void 0 ? void 0 : (_content_module_data1 = _content_module1.data) === null || _content_module_data1 === void 0 ? void 0 : (_content_module_data_M1 = _content_module_data1.M) === null || _content_module_data_M1 === void 0 ? void 0 : _content_module_data_M1.style;
|
|
3226
|
+
root = new drop(props2);
|
|
3227
|
+
}
|
|
3228
|
+
var children = [];
|
|
3229
|
+
var childrenMaps = {};
|
|
3230
|
+
var fields = {};
|
|
3231
|
+
var completeEvent = {
|
|
3232
|
+
fields: fields,
|
|
3233
|
+
children: children,
|
|
3234
|
+
childrenMaps: childrenMaps
|
|
3235
|
+
};
|
|
3236
|
+
if (!content) {
|
|
3237
|
+
setTimeout(function() {
|
|
3238
|
+
return onComplete && onComplete(completeEvent);
|
|
3239
|
+
}, 0);
|
|
3240
|
+
return null;
|
|
3241
|
+
}
|
|
3242
|
+
var childCount = 0;
|
|
3243
|
+
var loopRender = function loopRender1(parentObj, arr) {
|
|
3244
|
+
return _async_to_generator(function() {
|
|
3245
|
+
var _loop, i, l;
|
|
3246
|
+
return _ts_generator(this, function(_state) {
|
|
3247
|
+
switch(_state.label){
|
|
3248
|
+
case 0:
|
|
3249
|
+
_loop = function(i, l) {
|
|
3250
|
+
var _item_module_data, _item_module, _moduleData_data_M_eventScripts, _moduleData_data, item, formAttr, field, rule, moduleData, exprParseData, onCreateBeforeEvent, _moduleData_data_D;
|
|
3251
|
+
return _ts_generator(this, function(_state) {
|
|
3252
|
+
switch(_state.label){
|
|
3253
|
+
case 0:
|
|
3254
|
+
item = arr[i];
|
|
3255
|
+
formAttr = (_item_module = item.module) === null || _item_module === void 0 ? void 0 : (_item_module_data = _item_module.data) === null || _item_module_data === void 0 ? void 0 : _item_module_data.M.formAttr;
|
|
3256
|
+
if (sdk.defaultFormAttr && formAttr) {
|
|
3257
|
+
item.module.data.M.formAttr = formAttr = _object_spread({}, sdk.defaultFormAttr, formAttr);
|
|
3258
|
+
}
|
|
3259
|
+
if (formAttr) {
|
|
3260
|
+
field = formAttr.field;
|
|
3261
|
+
if (filter && filter.indexOf(String(formAttr.field)) !== -1) {
|
|
3262
|
+
if (childCount === 0) {
|
|
3263
|
+
onComplete && onComplete(completeEvent);
|
|
3264
|
+
}
|
|
3265
|
+
return [
|
|
3266
|
+
2,
|
|
3267
|
+
"continue"
|
|
3268
|
+
];
|
|
3269
|
+
}
|
|
3270
|
+
if (rules && field && rules[field] !== void 0) {
|
|
3271
|
+
rule = rules[field];
|
|
3272
|
+
if (rule.hide === true) return [
|
|
3273
|
+
2,
|
|
3274
|
+
"continue"
|
|
3275
|
+
];
|
|
3276
|
+
if (rule.disabled === true) formAttr.disabled = true;
|
|
3277
|
+
}
|
|
3278
|
+
}
|
|
3279
|
+
moduleData = formatData ? formatData(item.module, fields) || item.module : item.module;
|
|
3280
|
+
childCount++;
|
|
3281
|
+
if (!moduleData.data) moduleData.data = {
|
|
3282
|
+
D: {},
|
|
3283
|
+
M: {}
|
|
3284
|
+
};
|
|
3285
|
+
if (!moduleData.data.D) moduleData.data.D = {};
|
|
3286
|
+
moduleData.data.D.key = item.key;
|
|
3287
|
+
if (sdk.runtime) {
|
|
3288
|
+
exprParseData = sdk.exprParseByData(moduleData);
|
|
3289
|
+
if (exprParseData) moduleData = exprParseData;
|
|
3290
|
+
}
|
|
3291
|
+
onCreateBeforeEvent = (_moduleData_data = moduleData.data) === null || _moduleData_data === void 0 ? void 0 : (_moduleData_data_M_eventScripts = _moduleData_data.M.eventScripts) === null || _moduleData_data_M_eventScripts === void 0 ? void 0 : _moduleData_data_M_eventScripts.onCreateBefore;
|
|
3292
|
+
if (onCreateBeforeEvent && sdk.runtime && moduleData.data) {
|
|
3293
|
+
;
|
|
3294
|
+
evalJS_default.call(sdk, "onCreateBefore", onCreateBeforeEvent.script, {
|
|
3295
|
+
$this: {
|
|
3296
|
+
data: moduleData.data.M
|
|
3297
|
+
},
|
|
3298
|
+
$fields: snackPageEvent === null || snackPageEvent === void 0 ? void 0 : snackPageEvent.fields,
|
|
3299
|
+
$children: snackPageEvent === null || snackPageEvent === void 0 ? void 0 : snackPageEvent.childrenMaps,
|
|
3300
|
+
$verify: snackPageEvent === null || snackPageEvent === void 0 ? void 0 : snackPageEvent.verify,
|
|
3301
|
+
$defaultData: data,
|
|
3302
|
+
$defaultModuleData: moduleData.data.M,
|
|
3303
|
+
$defaultStyle: ((_moduleData_data_D = moduleData.data.D) === null || _moduleData_data_D === void 0 ? void 0 : _moduleData_data_D.style) || {},
|
|
3304
|
+
$defaultDisplay: function $defaultDisplay() {
|
|
3305
|
+
var b = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : true;
|
|
3306
|
+
if (!moduleData.data) return;
|
|
3307
|
+
if (!b) {
|
|
3308
|
+
var _moduleData_data_M;
|
|
3309
|
+
moduleData.data.D.style.display = "none";
|
|
3310
|
+
if ((_moduleData_data_M = moduleData.data.M) === null || _moduleData_data_M === void 0 ? void 0 : _moduleData_data_M.formAttr) moduleData.data.M.formAttr.disabled = true;
|
|
3311
|
+
} else {
|
|
3312
|
+
var _moduleData_data_M1;
|
|
3313
|
+
moduleData.data.D.style.display = "";
|
|
3314
|
+
if ((_moduleData_data_M1 = moduleData.data.M) === null || _moduleData_data_M1 === void 0 ? void 0 : _moduleData_data_M1.formAttr) moduleData.data.M.formAttr.disabled = false;
|
|
3315
|
+
}
|
|
3316
|
+
},
|
|
3317
|
+
$message: sdk.message
|
|
3318
|
+
});
|
|
3319
|
+
}
|
|
3320
|
+
return [
|
|
3321
|
+
4,
|
|
3322
|
+
parentObj.append(moduleData, function(child) {
|
|
3323
|
+
var _child_D_data, _child_D;
|
|
3324
|
+
if (!child || !child.M) {
|
|
3325
|
+
var _ref, _item_key;
|
|
3326
|
+
var _item_module_data_M_formAttr, _item_module_data_M, _item_module_data, _item_module;
|
|
3327
|
+
var key2 = (_ref = (_item_key = item.key) !== null && _item_key !== void 0 ? _item_key : (_item_module = item.module) === null || _item_module === void 0 ? void 0 : (_item_module_data = _item_module.data) === null || _item_module_data === void 0 ? void 0 : (_item_module_data_M = _item_module_data.M) === null || _item_module_data_M === void 0 ? void 0 : (_item_module_data_M_formAttr = _item_module_data_M.formAttr) === null || _item_module_data_M_formAttr === void 0 ? void 0 : _item_module_data_M_formAttr.field) !== null && _ref !== void 0 ? _ref : "(unknown)";
|
|
3328
|
+
console.error("SnackCore render module error — key: ".concat(key2), moduleData);
|
|
3329
|
+
childCount--;
|
|
3330
|
+
if (childCount === 0) onComplete && onComplete(completeEvent);
|
|
3331
|
+
return;
|
|
3332
|
+
}
|
|
3333
|
+
var _child_M_data = child.M.data, formAttr2 = _child_M_data.formAttr;
|
|
3334
|
+
child.M.$parent = child.D;
|
|
3335
|
+
child.M.$page = snackPageEvent;
|
|
3336
|
+
child.D.$page = snackPageEvent;
|
|
3337
|
+
childCount--;
|
|
3338
|
+
children.push(child);
|
|
3339
|
+
var key = (_child_D = child.D) === null || _child_D === void 0 ? void 0 : (_child_D_data = _child_D.data) === null || _child_D_data === void 0 ? void 0 : _child_D_data.key;
|
|
3340
|
+
if (key) childrenMaps[key] = child;
|
|
3341
|
+
if (formAttr2 && formAttr2.field) fields[formAttr2.field] = child;
|
|
3342
|
+
if (item.isContainer) {
|
|
3343
|
+
var _child_M;
|
|
3344
|
+
var parentBoxArr = (child === null || child === void 0 ? void 0 : (_child_M = child.M) === null || _child_M === void 0 ? void 0 : _child_M.children) || [];
|
|
3345
|
+
var boxConfig = item.children || [];
|
|
3346
|
+
for(var j = 0, k = parentBoxArr.length; j < k; j++){
|
|
3347
|
+
var parentBoxDetail = parentBoxArr[j];
|
|
3348
|
+
var boxConfigDetail = boxConfig[j];
|
|
3349
|
+
if (boxConfigDetail.children && boxConfigDetail.children.length > 0) loopRender(parentBoxDetail, boxConfigDetail.children);
|
|
3350
|
+
else if (childCount === 0) {
|
|
3351
|
+
onComplete && onComplete(completeEvent);
|
|
3352
|
+
}
|
|
3353
|
+
}
|
|
3354
|
+
} else if (childCount === 0) {
|
|
3355
|
+
onComplete && onComplete(completeEvent);
|
|
3356
|
+
}
|
|
3357
|
+
})
|
|
3358
|
+
];
|
|
3359
|
+
case 1:
|
|
3360
|
+
_state.sent();
|
|
3361
|
+
return [
|
|
3362
|
+
2
|
|
3363
|
+
];
|
|
3364
|
+
}
|
|
3365
|
+
});
|
|
3366
|
+
};
|
|
3367
|
+
if (!arr || arr.length === 0) return [
|
|
3368
|
+
2
|
|
3369
|
+
];
|
|
3370
|
+
i = 0, l = arr.length;
|
|
3371
|
+
_state.label = 1;
|
|
3372
|
+
case 1:
|
|
3373
|
+
if (!(i < l)) return [
|
|
3374
|
+
3,
|
|
3375
|
+
4
|
|
3376
|
+
];
|
|
3377
|
+
return [
|
|
3378
|
+
5,
|
|
3379
|
+
_ts_values(_loop(i, l))
|
|
3380
|
+
];
|
|
3381
|
+
case 2:
|
|
3382
|
+
_state.sent();
|
|
3383
|
+
_state.label = 3;
|
|
3384
|
+
case 3:
|
|
3385
|
+
i++;
|
|
3386
|
+
return [
|
|
3387
|
+
3,
|
|
3388
|
+
1
|
|
3389
|
+
];
|
|
3390
|
+
case 4:
|
|
3391
|
+
parentObj.$forceUpdate();
|
|
3392
|
+
return [
|
|
3393
|
+
2
|
|
3394
|
+
];
|
|
3395
|
+
}
|
|
3396
|
+
});
|
|
3397
|
+
})();
|
|
3398
|
+
};
|
|
3399
|
+
setTimeout(function() {
|
|
3400
|
+
return _async_to_generator(function() {
|
|
3401
|
+
var children2;
|
|
3402
|
+
return _ts_generator(this, function(_state) {
|
|
3403
|
+
if (root) {
|
|
3404
|
+
children2 = content && content.children;
|
|
3405
|
+
if (!children2 || children2.length === 0) {
|
|
3406
|
+
return [
|
|
3407
|
+
2,
|
|
3408
|
+
onComplete && onComplete(completeEvent)
|
|
3409
|
+
];
|
|
3410
|
+
}
|
|
3411
|
+
loopRender(root, children2);
|
|
3412
|
+
}
|
|
3413
|
+
return [
|
|
3414
|
+
2
|
|
3415
|
+
];
|
|
3416
|
+
});
|
|
3417
|
+
})();
|
|
3418
|
+
}, 0);
|
|
3419
|
+
return root;
|
|
3420
|
+
};
|
|
3421
|
+
// src/utils/verifyJS.tsx
|
|
3422
|
+
function verifyJS_default(formatAargs, M) {
|
|
3423
|
+
return _async_to_generator(function() {
|
|
3424
|
+
var _M_data_formAttr, _M_data, sdk, fields, defaultData, childrenMaps, value, _ref, verifyRules, // 正则校验
|
|
3425
|
+
verifyJS, // 自定义js脚本校验
|
|
3426
|
+
required, // 是否必填
|
|
3427
|
+
notEmptyObject, // 非空对象
|
|
3428
|
+
disabled, // 是否禁用
|
|
3429
|
+
trimValue, _ref_skipRegx, // 是否trim value
|
|
3430
|
+
skipRegx, locale2, label, field, values, isEmpty, requireText, passCount, errorTexts, mustMatchErrorTexts, i, l, rule, error, baseLocale, errorText, e;
|
|
3431
|
+
return _ts_generator(this, function(_state) {
|
|
3432
|
+
switch(_state.label){
|
|
3433
|
+
case 0:
|
|
3434
|
+
sdk = this;
|
|
3435
|
+
fields = formatAargs.fields, defaultData = formatAargs.defaultData, childrenMaps = formatAargs.childrenMaps;
|
|
3436
|
+
if (M.data.error) {
|
|
3437
|
+
M.data.error = false;
|
|
3438
|
+
M.data.helperText = "";
|
|
3439
|
+
M.$forceUpdate();
|
|
3440
|
+
}
|
|
3441
|
+
value = (M.data || {}).value;
|
|
3442
|
+
_ref = M.data.formAttr || {}, verifyRules = _ref.verifyRules, verifyJS = _ref.verifyJS, required = _ref.required, notEmptyObject = _ref.notEmptyObject, disabled = _ref.disabled, trimValue = _ref.trimValue, _ref_skipRegx = _ref.skipRegx, skipRegx = _ref_skipRegx === void 0 ? false : _ref_skipRegx;
|
|
3443
|
+
if (typeof value === "string" && trimValue !== false) value = value.trim();
|
|
3444
|
+
if (disabled === true) return [
|
|
3445
|
+
2,
|
|
3446
|
+
true
|
|
3447
|
+
];
|
|
3448
|
+
locale2 = getLocale(sdk);
|
|
3449
|
+
label = "";
|
|
3450
|
+
field = (_M_data = M.data) === null || _M_data === void 0 ? void 0 : (_M_data_formAttr = _M_data.formAttr) === null || _M_data_formAttr === void 0 ? void 0 : _M_data_formAttr.field;
|
|
3451
|
+
switch(_type_of(M.data.label)){
|
|
3452
|
+
case "object":
|
|
3453
|
+
label = M.data.label[locale2] || M.data.label["zh"] || M.data.label["zh-CN"];
|
|
3454
|
+
if (!label) {
|
|
3455
|
+
values = Object.values(M.data.label);
|
|
3456
|
+
if (values.length === 1 && typeof values[0] === "string") label = values[0];
|
|
3457
|
+
else if (field) label = field;
|
|
3458
|
+
else {
|
|
3459
|
+
label = "";
|
|
3460
|
+
console.warn("SnackCore: \u6821\u9A8C\u5B57\u6BB5\u56FD\u9645\u5316\u6807\u9898\u672A\u5339\u914D\u5230\u53EF\u7528\u7684\u6587\u672C", M.data);
|
|
3461
|
+
}
|
|
3462
|
+
}
|
|
3463
|
+
break;
|
|
3464
|
+
case "string":
|
|
3465
|
+
label = M.data.label;
|
|
3466
|
+
break;
|
|
3467
|
+
}
|
|
3468
|
+
isEmpty = value === void 0 || value === null || value === "";
|
|
3469
|
+
if (required === true) {
|
|
3470
|
+
if (!isEmpty && notEmptyObject) isEmpty = isEmptyObject(value);
|
|
3471
|
+
if (isEmpty) {
|
|
3472
|
+
requireText = sdk.intl({
|
|
3473
|
+
id: "require"
|
|
3474
|
+
}, {
|
|
3475
|
+
label: label
|
|
3476
|
+
});
|
|
3477
|
+
M.data.error = true;
|
|
3478
|
+
M.data.helperText = requireText;
|
|
3479
|
+
M.$forceUpdate();
|
|
3480
|
+
return [
|
|
3481
|
+
2,
|
|
3482
|
+
false
|
|
3483
|
+
];
|
|
3484
|
+
}
|
|
3485
|
+
}
|
|
3486
|
+
if (!isEmpty && !skipRegx && verifyRules && verifyRules.length > 0) {
|
|
3487
|
+
passCount = 0;
|
|
3488
|
+
errorTexts = [];
|
|
3489
|
+
mustMatchErrorTexts = [];
|
|
3490
|
+
for(i = 0, l = verifyRules.length; i < l; i++){
|
|
3491
|
+
rule = verifyRules[i];
|
|
3492
|
+
error = false;
|
|
3493
|
+
if (rule.regExp) {
|
|
3494
|
+
try {
|
|
3495
|
+
error = !new RegExp(rule.regExp).test(value);
|
|
3496
|
+
} catch (err) {
|
|
3497
|
+
console.error("SnackCore: verify 'rule.regExp' is Error:", rule);
|
|
3498
|
+
}
|
|
3499
|
+
}
|
|
3500
|
+
if (error) {
|
|
3501
|
+
baseLocale = locale2 === null || locale2 === void 0 ? void 0 : locale2.split("-")[0];
|
|
3502
|
+
errorText = _type_of(rule.erorText) === "object" ? rule.erorText[locale2] || rule.erorText[baseLocale] || rule.erorText["zh"] || "" : rule.erorText || sdk.intl("noErrorMsg");
|
|
3503
|
+
if (rule.mustMatch) mustMatchErrorTexts.push(errorText);
|
|
3504
|
+
else errorTexts.push(errorText);
|
|
3505
|
+
} else if (!rule.mustMatch) passCount++;
|
|
3506
|
+
}
|
|
3507
|
+
if (mustMatchErrorTexts.length > 0) {
|
|
3508
|
+
M.data.error = true;
|
|
3509
|
+
M.data.helperText = mustMatchErrorTexts.join("\u3001");
|
|
3510
|
+
M.$forceUpdate();
|
|
3511
|
+
return [
|
|
3512
|
+
2,
|
|
3513
|
+
false
|
|
3514
|
+
];
|
|
3515
|
+
}
|
|
3516
|
+
if (passCount === 0 && errorTexts.length > 0) {
|
|
3517
|
+
M.data.error = true;
|
|
3518
|
+
M.data.helperText = errorTexts.join("\u3001");
|
|
3519
|
+
M.$forceUpdate();
|
|
3520
|
+
return [
|
|
3521
|
+
2,
|
|
3522
|
+
false
|
|
3523
|
+
];
|
|
3524
|
+
}
|
|
3525
|
+
}
|
|
3526
|
+
if (!(verifyJS && typeof verifyJS === "string")) return [
|
|
3527
|
+
3,
|
|
3528
|
+
2
|
|
3529
|
+
];
|
|
3530
|
+
return [
|
|
3531
|
+
4,
|
|
3532
|
+
new Promise(function($cb) {
|
|
3533
|
+
evalJS_default.call(sdk, "verifyJS", String(verifyJS), // 脚本参数
|
|
3534
|
+
{
|
|
3535
|
+
$cb: $cb,
|
|
3536
|
+
$this: M,
|
|
3537
|
+
$fields: fields,
|
|
3538
|
+
$children: childrenMaps,
|
|
3539
|
+
$defaultData: defaultData,
|
|
3540
|
+
$message: sdk.message
|
|
3541
|
+
});
|
|
3542
|
+
})
|
|
3543
|
+
];
|
|
3544
|
+
case 1:
|
|
3545
|
+
e = _state.sent();
|
|
3546
|
+
if (typeof e === "boolean") {
|
|
3547
|
+
if (!e) {
|
|
3548
|
+
M.data.error = true;
|
|
3549
|
+
M.data.helperText = "";
|
|
3550
|
+
M.$forceUpdate();
|
|
3551
|
+
}
|
|
3552
|
+
return [
|
|
3553
|
+
2,
|
|
3554
|
+
e
|
|
3555
|
+
];
|
|
3556
|
+
}
|
|
3557
|
+
if ((typeof e === "undefined" ? "undefined" : _type_of(e)) === "object" && e.error !== void 0) {
|
|
3558
|
+
M.data.error = e.error;
|
|
3559
|
+
M.data.helperText = e.helperText || "";
|
|
3560
|
+
M.$forceUpdate();
|
|
3561
|
+
return [
|
|
3562
|
+
2,
|
|
3563
|
+
!e.error
|
|
3564
|
+
];
|
|
3565
|
+
}
|
|
3566
|
+
_state.label = 2;
|
|
3567
|
+
case 2:
|
|
3568
|
+
return [
|
|
3569
|
+
2,
|
|
3570
|
+
true
|
|
3571
|
+
];
|
|
3572
|
+
}
|
|
3573
|
+
});
|
|
3574
|
+
}).call(this);
|
|
3575
|
+
}
|
|
3576
|
+
// src/components/error/index.tsx
|
|
3577
|
+
import React4 from "react";
|
|
3578
|
+
var icon = /* @__PURE__ */ React4.createElement("svg", {
|
|
3579
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
3580
|
+
width: "45",
|
|
3581
|
+
height: "45",
|
|
3582
|
+
viewBox: "0 0 60 60"
|
|
3583
|
+
}, /* @__PURE__ */ React4.createElement("g", {
|
|
3584
|
+
id: "\u7EC4_6340",
|
|
3585
|
+
"data-name": "\u7EC4 6340",
|
|
3586
|
+
transform: "translate(-148.761 -452.761)"
|
|
3587
|
+
}, /* @__PURE__ */ React4.createElement("path", {
|
|
3588
|
+
id: "\u8DEF\u5F84_4067",
|
|
3589
|
+
"data-name": "\u8DEF\u5F84 4067",
|
|
3590
|
+
d: "M215.4,636.518s7.916-2.192,8.4,4.872-6.516,9.073-1.035,10.474",
|
|
3591
|
+
transform: "translate(-65.631 -152.87)",
|
|
3592
|
+
fill: "none",
|
|
3593
|
+
stroke: "#1890ff"
|
|
3594
|
+
}), /* @__PURE__ */ React4.createElement("path", {
|
|
3595
|
+
id: "\u8DEF\u5F84_4068",
|
|
3596
|
+
"data-name": "\u8DEF\u5F84 4068",
|
|
3597
|
+
d: "M341,354.932s25.071-4.858,26.613,10.8-20.635,20.106-3.278,23.21",
|
|
3598
|
+
transform: "translate(-161.052 113.005)",
|
|
3599
|
+
fill: "none",
|
|
3600
|
+
stroke: "#1890ff"
|
|
3601
|
+
}), /* @__PURE__ */ React4.createElement("g", {
|
|
3602
|
+
id: "\u7EC4_6339",
|
|
3603
|
+
"data-name": "\u7EC4 6339",
|
|
3604
|
+
transform: "translate(152.898 457.351)"
|
|
3605
|
+
}, /* @__PURE__ */ React4.createElement("circle", {
|
|
3606
|
+
id: "\u692D\u5706_122",
|
|
3607
|
+
"data-name": "\u692D\u5706 122",
|
|
3608
|
+
cx: "20.43",
|
|
3609
|
+
cy: "20.43",
|
|
3610
|
+
r: "20.43",
|
|
3611
|
+
transform: "translate(6.239 4.274)",
|
|
3612
|
+
fill: "#2f2e43"
|
|
3613
|
+
}), /* @__PURE__ */ React4.createElement("rect", {
|
|
3614
|
+
id: "\u77E9\u5F62_19572",
|
|
3615
|
+
"data-name": "\u77E9\u5F62 19572",
|
|
3616
|
+
width: "6.207",
|
|
3617
|
+
height: "11.12",
|
|
3618
|
+
transform: "translate(17.359 37.479)",
|
|
3619
|
+
fill: "#2f2e43"
|
|
3620
|
+
}), /* @__PURE__ */ React4.createElement("rect", {
|
|
3621
|
+
id: "\u77E9\u5F62_19573",
|
|
3622
|
+
"data-name": "\u77E9\u5F62 19573",
|
|
3623
|
+
width: "6.207",
|
|
3624
|
+
height: "11.12",
|
|
3625
|
+
transform: "translate(29.773 37.479)",
|
|
3626
|
+
fill: "#2f2e43"
|
|
3627
|
+
}), /* @__PURE__ */ React4.createElement("ellipse", {
|
|
3628
|
+
id: "\u692D\u5706_123",
|
|
3629
|
+
"data-name": "\u692D\u5706 123",
|
|
3630
|
+
cx: "5.172",
|
|
3631
|
+
cy: "1.94",
|
|
3632
|
+
rx: "5.172",
|
|
3633
|
+
ry: "1.94",
|
|
3634
|
+
transform: "translate(17.359 46.789)",
|
|
3635
|
+
fill: "#2f2e43"
|
|
3636
|
+
}), /* @__PURE__ */ React4.createElement("ellipse", {
|
|
3637
|
+
id: "\u692D\u5706_124",
|
|
3638
|
+
"data-name": "\u692D\u5706 124",
|
|
3639
|
+
cx: "5.172",
|
|
3640
|
+
cy: "1.94",
|
|
3641
|
+
rx: "5.172",
|
|
3642
|
+
ry: "1.94",
|
|
3643
|
+
transform: "translate(29.773 46.53)",
|
|
3644
|
+
fill: "#2f2e43"
|
|
3645
|
+
}), /* @__PURE__ */ React4.createElement("circle", {
|
|
3646
|
+
id: "\u692D\u5706_125",
|
|
3647
|
+
"data-name": "\u692D\u5706 125",
|
|
3648
|
+
cx: "6.983",
|
|
3649
|
+
cy: "6.983",
|
|
3650
|
+
r: "6.983",
|
|
3651
|
+
transform: "translate(20.204 12.55)",
|
|
3652
|
+
fill: "#fff"
|
|
3653
|
+
}), /* @__PURE__ */ React4.createElement("circle", {
|
|
3654
|
+
id: "\u692D\u5706_126",
|
|
3655
|
+
"data-name": "\u692D\u5706 126",
|
|
3656
|
+
cx: "2.328",
|
|
3657
|
+
cy: "2.328",
|
|
3658
|
+
r: "2.328",
|
|
3659
|
+
transform: "translate(24.859 17.205)",
|
|
3660
|
+
fill: "#2f2e43"
|
|
3661
|
+
}), /* @__PURE__ */ React4.createElement("path", {
|
|
3662
|
+
id: "\u8DEF\u5F84_4065",
|
|
3663
|
+
"data-name": "\u8DEF\u5F84 4065",
|
|
3664
|
+
d: "M.151,8.554c-.826-3.7,1.815-7.44,5.9-8.352s8.066,1.349,8.892,5.049-1.881,5.066-5.966,5.978S.978,12.255.151,8.554Z",
|
|
3665
|
+
transform: "matrix(0.978, -0.208, 0.208, 0.978, 7.651, 3.138)",
|
|
3666
|
+
fill: "#1890ff"
|
|
3667
|
+
}), /* @__PURE__ */ React4.createElement("ellipse", {
|
|
3668
|
+
id: "\u692D\u5706_127",
|
|
3669
|
+
"data-name": "\u692D\u5706 127",
|
|
3670
|
+
cx: "10.215",
|
|
3671
|
+
cy: "3.207",
|
|
3672
|
+
rx: "10.215",
|
|
3673
|
+
ry: "3.207",
|
|
3674
|
+
transform: "translate(33.916 18.752) rotate(-23.171)",
|
|
3675
|
+
fill: "#2f2e43"
|
|
3676
|
+
}), /* @__PURE__ */ React4.createElement("ellipse", {
|
|
3677
|
+
id: "\u692D\u5706_128",
|
|
3678
|
+
"data-name": "\u692D\u5706 128",
|
|
3679
|
+
cx: "7.845",
|
|
3680
|
+
cy: "3.207",
|
|
3681
|
+
rx: "7.845",
|
|
3682
|
+
ry: "3.207",
|
|
3683
|
+
transform: "translate(0 30.593) rotate(-23.171)",
|
|
3684
|
+
fill: "#2f2e43"
|
|
3685
|
+
}), /* @__PURE__ */ React4.createElement("path", {
|
|
3686
|
+
id: "\u8DEF\u5F84_4070",
|
|
3687
|
+
"data-name": "\u8DEF\u5F84 4070",
|
|
3688
|
+
d: "M6158.75,270.307s2.22-3.117,7.245-1.386",
|
|
3689
|
+
transform: "translate(-6131.563 -236.834)",
|
|
3690
|
+
fill: "none",
|
|
3691
|
+
stroke: "#fff"
|
|
3692
|
+
})), /* @__PURE__ */ React4.createElement("rect", {
|
|
3693
|
+
id: "\u77E9\u5F62_19576",
|
|
3694
|
+
"data-name": "\u77E9\u5F62 19576",
|
|
3695
|
+
width: "60",
|
|
3696
|
+
height: "60",
|
|
3697
|
+
transform: "translate(148.761 452.761)",
|
|
3698
|
+
fill: "none"
|
|
3699
|
+
})));
|
|
3700
|
+
var Error2 = function Error21(props) {
|
|
3701
|
+
return /* @__PURE__ */ React4.createElement("div", {
|
|
3702
|
+
className: "snack-core-error"
|
|
3703
|
+
}, /* @__PURE__ */ React4.createElement("span", {
|
|
3704
|
+
className: "snack-core-error-icon"
|
|
3705
|
+
}, icon), /* @__PURE__ */ React4.createElement("div", {
|
|
3706
|
+
className: "snack-core-error-content"
|
|
3707
|
+
}, /* @__PURE__ */ React4.createElement("div", {
|
|
3708
|
+
className: "snack-core-error-msg"
|
|
3709
|
+
}, props.content || "\u62B1\u6B49\uFF0C\u9875\u9762\u6216\u6A21\u5757\u6E32\u67D3\u51FA\u73B0\u4E86\u9519\u8BEF"), props.sub ? /* @__PURE__ */ React4.createElement("div", {
|
|
3710
|
+
className: "snack-core-error-sub"
|
|
3711
|
+
}, props.sub) : null));
|
|
3712
|
+
};
|
|
3713
|
+
var error_default = Error2;
|
|
3714
|
+
// src/sdk/index.tsx
|
|
3715
|
+
import { createRoot } from "react-dom/client";
|
|
3716
|
+
var base64Decode = function base64Decode1(str) {
|
|
3717
|
+
try {
|
|
3718
|
+
return decodeURIComponent(escape(atob(str)));
|
|
3719
|
+
} catch (unused) {
|
|
3720
|
+
return atob(str);
|
|
3721
|
+
}
|
|
3722
|
+
};
|
|
3723
|
+
var toObject = function toObject1(str, fallback) {
|
|
3724
|
+
if (typeof str !== "string") return str !== null && str !== void 0 ? str : fallback;
|
|
3725
|
+
try {
|
|
3726
|
+
return JSON.parse(str);
|
|
3727
|
+
} catch (unused) {
|
|
3728
|
+
return fallback;
|
|
3729
|
+
}
|
|
3730
|
+
};
|
|
3731
|
+
var SnackSDK = /*#__PURE__*/ function(core_default1) {
|
|
3732
|
+
"use strict";
|
|
3733
|
+
_inherits(SnackSDK1, core_default1);
|
|
3734
|
+
function SnackSDK1(config) {
|
|
3735
|
+
_class_call_check(this, SnackSDK1);
|
|
3736
|
+
var _this;
|
|
3737
|
+
_this = _call_super(this, SnackSDK1, [
|
|
3738
|
+
config
|
|
3739
|
+
]);
|
|
3740
|
+
/** 校验防抖计时器 Map,key 为组件 $id */ _this.verifyTimeout = {};
|
|
3741
|
+
return _this;
|
|
3742
|
+
}
|
|
3743
|
+
_create_class(SnackSDK1, [
|
|
3744
|
+
{
|
|
3745
|
+
key: "createModule",
|
|
3746
|
+
value: /**
|
|
3747
|
+
* 创建Snack模块实例
|
|
3748
|
+
* @param snackClass Snack模块Class
|
|
3749
|
+
* @param main 如果创建的是setting模块则需要传入main主模块Snack对象
|
|
3750
|
+
* @param data
|
|
3751
|
+
*/ function createModule(_0) {
|
|
3752
|
+
return _async_to_generator(function(param) {
|
|
3753
|
+
var main, name, type, _param_setting, setting, data, e, mod;
|
|
3754
|
+
var _arguments = arguments;
|
|
3755
|
+
return _ts_generator(this, function(_state) {
|
|
3756
|
+
switch(_state.label){
|
|
3757
|
+
case 0:
|
|
3758
|
+
main = param.main, name = param.name, type = param.type, _param_setting = param.setting, setting = _param_setting === void 0 ? false : _param_setting, data = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : {};
|
|
3759
|
+
return [
|
|
3760
|
+
4,
|
|
3761
|
+
this.module({
|
|
3762
|
+
module: [
|
|
3763
|
+
{
|
|
3764
|
+
name: name,
|
|
3765
|
+
type: type,
|
|
3766
|
+
setting: setting
|
|
3767
|
+
}
|
|
3768
|
+
]
|
|
3769
|
+
})
|
|
3770
|
+
];
|
|
3771
|
+
case 1:
|
|
3772
|
+
e = _state.sent();
|
|
3773
|
+
if (setting) name += "setting";
|
|
3774
|
+
if (!e[name]) return [
|
|
3775
|
+
2,
|
|
3776
|
+
null
|
|
3777
|
+
];
|
|
3778
|
+
if (!data.$snackSDK) data.$snackSDK = this;
|
|
3779
|
+
if (setting || main) mod = new e[name](main, data);
|
|
3780
|
+
else mod = new e[name](data);
|
|
3781
|
+
return [
|
|
3782
|
+
2,
|
|
3783
|
+
mod
|
|
3784
|
+
];
|
|
3785
|
+
}
|
|
3786
|
+
});
|
|
3787
|
+
}).apply(this, arguments);
|
|
3788
|
+
}
|
|
3789
|
+
},
|
|
3790
|
+
{
|
|
3791
|
+
key: "createPage",
|
|
3792
|
+
value: /**
|
|
3793
|
+
* 渲染设计器页面
|
|
3794
|
+
* @param params {SnackPageParams | SnackPageData} 页面加载参数 参数非法则创建空容器
|
|
3795
|
+
* @param config {RenderPageConfig} 页面渲染参数
|
|
3796
|
+
* @param root 根容器
|
|
3797
|
+
* @param filter 过滤渲染组件列表
|
|
3798
|
+
* @private
|
|
3799
|
+
*/ function createPage(_0, _1, _2) {
|
|
3800
|
+
return _async_to_generator(function(params) {
|
|
3801
|
+
var _this, config, root, filter, pageData, pageContent, drop, ops, content;
|
|
3802
|
+
var _arguments = arguments;
|
|
3803
|
+
return _ts_generator(this, function(_state) {
|
|
3804
|
+
switch(_state.label){
|
|
3805
|
+
case 0:
|
|
3806
|
+
_this = this;
|
|
3807
|
+
config = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : {}, root = _arguments.length > 2 ? _arguments[2] : void 0, filter = _arguments.length > 3 ? _arguments[3] : void 0;
|
|
3808
|
+
return [
|
|
3809
|
+
4,
|
|
3810
|
+
this.module({
|
|
3811
|
+
module: [
|
|
3812
|
+
{
|
|
3813
|
+
name: "drop",
|
|
3814
|
+
type: this.basicsType
|
|
3815
|
+
}
|
|
3816
|
+
]
|
|
3817
|
+
})
|
|
3818
|
+
];
|
|
3819
|
+
case 1:
|
|
3820
|
+
drop = _state.sent().drop;
|
|
3821
|
+
if (!drop || typeof drop !== "function") {
|
|
3822
|
+
console.error("SnackCore\uFF1Adrop \u6A21\u5757\u52A0\u8F7D\u5931\u8D25");
|
|
3823
|
+
return [
|
|
3824
|
+
2,
|
|
3825
|
+
{
|
|
3826
|
+
content: {
|
|
3827
|
+
FC: function FC() {
|
|
3828
|
+
return /* @__PURE__ */ React5.createElement(error_default, {
|
|
3829
|
+
content: "drop \u6A21\u5757\u52A0\u8F7D\u5931\u8D25",
|
|
3830
|
+
sub: "type: ".concat(_this.basicsType)
|
|
3831
|
+
});
|
|
3832
|
+
}
|
|
3833
|
+
}
|
|
3834
|
+
}
|
|
3835
|
+
];
|
|
3836
|
+
}
|
|
3837
|
+
if (!params) return [
|
|
3838
|
+
3,
|
|
3839
|
+
5
|
|
3840
|
+
];
|
|
3841
|
+
if (!params.content) return [
|
|
3842
|
+
3,
|
|
3843
|
+
2
|
|
3844
|
+
];
|
|
3845
|
+
pageData = this.pageContentDecode(params);
|
|
3846
|
+
return [
|
|
3847
|
+
3,
|
|
3848
|
+
4
|
|
3849
|
+
];
|
|
3850
|
+
case 2:
|
|
3851
|
+
if (!params.id) return [
|
|
3852
|
+
3,
|
|
3853
|
+
4
|
|
3854
|
+
];
|
|
3855
|
+
return [
|
|
3856
|
+
4,
|
|
3857
|
+
this.getPage(params)
|
|
3858
|
+
];
|
|
3859
|
+
case 3:
|
|
3860
|
+
pageData = _state.sent();
|
|
3861
|
+
if (pageData) pageData = this.pageContentDecode(pageData);
|
|
3862
|
+
else {
|
|
3863
|
+
pageData = {
|
|
3864
|
+
content: {
|
|
3865
|
+
children: []
|
|
3866
|
+
},
|
|
3867
|
+
id: "err",
|
|
3868
|
+
name: "err page"
|
|
3869
|
+
};
|
|
3870
|
+
console.error("SnackCore\uFF1A\u9875\u9762\u6E32\u67D3\u5931\u8D25\uFF0Cid:", params.id, "type:", params.type);
|
|
3871
|
+
}
|
|
3872
|
+
_state.label = 4;
|
|
3873
|
+
case 4:
|
|
3874
|
+
if (pageData) pageContent = pageData.content;
|
|
3875
|
+
_state.label = 5;
|
|
3876
|
+
case 5:
|
|
3877
|
+
ops = {
|
|
3878
|
+
root: root,
|
|
3879
|
+
config: config,
|
|
3880
|
+
filter: filter,
|
|
3881
|
+
drop: drop,
|
|
3882
|
+
sdk: this,
|
|
3883
|
+
content: pageContent
|
|
3884
|
+
};
|
|
3885
|
+
content = renderSnackPage(ops, function(moduleData, fields) {
|
|
3886
|
+
return config.data && _this.formatData(config.data, moduleData, fields);
|
|
3887
|
+
}, config.onComplete);
|
|
3888
|
+
if (!content && params) return [
|
|
3889
|
+
2,
|
|
3890
|
+
{
|
|
3891
|
+
content: {
|
|
3892
|
+
FC: function FC() {
|
|
3893
|
+
return /* @__PURE__ */ React5.createElement(error_default, {
|
|
3894
|
+
content: "\u9875\u9762\u6E32\u67D3\u5931\u8D25\u4E86",
|
|
3895
|
+
sub: "id: ".concat(params === null || params === void 0 ? void 0 : params.id, " type: ").concat(params === null || params === void 0 ? void 0 : params.type)
|
|
3896
|
+
});
|
|
3897
|
+
}
|
|
3898
|
+
}
|
|
3899
|
+
}
|
|
3900
|
+
];
|
|
3901
|
+
return [
|
|
3902
|
+
2,
|
|
3903
|
+
{
|
|
3904
|
+
content: content,
|
|
3905
|
+
pageData: pageData
|
|
3906
|
+
}
|
|
3907
|
+
];
|
|
3908
|
+
}
|
|
3909
|
+
});
|
|
3910
|
+
}).apply(this, arguments);
|
|
3911
|
+
}
|
|
3912
|
+
},
|
|
3913
|
+
{
|
|
3914
|
+
key: "renderPage",
|
|
3915
|
+
value: /**
|
|
3916
|
+
* 渲染多个页面,当页面为表单时会过滤相同字段的表单组件
|
|
3917
|
+
* @param params
|
|
3918
|
+
* @param config
|
|
3919
|
+
*/ function renderPage(_0) {
|
|
3920
|
+
return _async_to_generator(function(params) {
|
|
3921
|
+
var _this, config, pages, i, event, root, loadPage;
|
|
3922
|
+
var _arguments = arguments;
|
|
3923
|
+
return _ts_generator(this, function(_state) {
|
|
3924
|
+
switch(_state.label){
|
|
3925
|
+
case 0:
|
|
3926
|
+
_this = this;
|
|
3927
|
+
config = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : {};
|
|
3928
|
+
pages = _instanceof(params, Array) ? params : [
|
|
3929
|
+
params
|
|
3930
|
+
];
|
|
3931
|
+
i = 0;
|
|
3932
|
+
event = {
|
|
3933
|
+
children: [],
|
|
3934
|
+
fields: {},
|
|
3935
|
+
childrenMaps: {}
|
|
3936
|
+
};
|
|
3937
|
+
root = null;
|
|
3938
|
+
loadPage = function loadPage1(filter) {
|
|
3939
|
+
return _async_to_generator(function() {
|
|
3940
|
+
var _this, param, _ref, content, pageData;
|
|
3941
|
+
return _ts_generator(this, function(_state) {
|
|
3942
|
+
switch(_state.label){
|
|
3943
|
+
case 0:
|
|
3944
|
+
_this = this;
|
|
3945
|
+
param = pages[i];
|
|
3946
|
+
return [
|
|
3947
|
+
4,
|
|
3948
|
+
this.createPage(param, _object_spread_props(_object_spread({
|
|
3949
|
+
snackPageEvent: event
|
|
3950
|
+
}, config), {
|
|
3951
|
+
onComplete: function onComplete(e) {
|
|
3952
|
+
event.pageData = pageData;
|
|
3953
|
+
event.children = _to_consumable_array(event.children).concat(_to_consumable_array(e.children));
|
|
3954
|
+
event.fields = _object_spread({}, event.fields, e.fields);
|
|
3955
|
+
event.childrenMaps = _object_spread({}, event.childrenMaps, e.childrenMaps);
|
|
3956
|
+
i++;
|
|
3957
|
+
if (pages[i]) {
|
|
3958
|
+
loadPage(Object.keys(e.fields));
|
|
3959
|
+
} else {
|
|
3960
|
+
var _config_onComplete;
|
|
3961
|
+
var formatArag = {
|
|
3962
|
+
rules: config.rules,
|
|
3963
|
+
fields: event.fields,
|
|
3964
|
+
childrenMaps: event.childrenMaps,
|
|
3965
|
+
defaultData: config.data,
|
|
3966
|
+
verify: function verify(key) {
|
|
3967
|
+
return _this.formVerify(formatArag, key, pageData);
|
|
3968
|
+
}
|
|
3969
|
+
};
|
|
3970
|
+
event.setData = function(key, value) {
|
|
3971
|
+
return _this.formSetData(formatArag, key, value);
|
|
3972
|
+
};
|
|
3973
|
+
event.getData = function(key) {
|
|
3974
|
+
return _this.formGetData(formatArag, key);
|
|
3975
|
+
};
|
|
3976
|
+
event.verify = formatArag.verify;
|
|
3977
|
+
event.empty = function() {
|
|
3978
|
+
return _this.formEmpty(event.children);
|
|
3979
|
+
};
|
|
3980
|
+
setTimeout(function() {
|
|
3981
|
+
_this.sendEvent("onComplete", [
|
|
3982
|
+
content,
|
|
3983
|
+
params
|
|
3984
|
+
]);
|
|
3985
|
+
}, 50);
|
|
3986
|
+
event.snackEventCallback = function(e2) {
|
|
3987
|
+
var _e2_target_$parent_data, _e2_target_$parent, _e2_target_data, _e2_target_data1;
|
|
3988
|
+
var parentKey = (_e2_target_$parent = e2.target.$parent) === null || _e2_target_$parent === void 0 ? void 0 : (_e2_target_$parent_data = _e2_target_$parent.data) === null || _e2_target_$parent_data === void 0 ? void 0 : _e2_target_$parent_data.key;
|
|
3989
|
+
if (!event.childrenMaps[parentKey]) return;
|
|
3990
|
+
var eventScripts = (_e2_target_data = e2.target.data) === null || _e2_target_data === void 0 ? void 0 : _e2_target_data.eventScripts;
|
|
3991
|
+
if (eventScripts && eventScripts[e2.name]) {
|
|
3992
|
+
var script = eventScripts[e2.name].script;
|
|
3993
|
+
evalJS_default.call(_this, "eventJS", script, {
|
|
3994
|
+
$this: e2.target,
|
|
3995
|
+
$fields: event.fields,
|
|
3996
|
+
$children: event.childrenMaps,
|
|
3997
|
+
$verify: event.verify,
|
|
3998
|
+
$defaultData: config.data,
|
|
3999
|
+
$message: _this.message
|
|
4000
|
+
});
|
|
4001
|
+
}
|
|
4002
|
+
var _ref = ((_e2_target_data1 = e2.target.data) === null || _e2_target_data1 === void 0 ? void 0 : _e2_target_data1.formAttr) || {}, field = _ref.field, verifyOnEvents = _ref.verifyOnEvents, verifyASTime = _ref.verifyASTime;
|
|
4003
|
+
if (!field || !event.verify) return;
|
|
4004
|
+
if (verifyOnEvents.indexOf(e2.name) !== -1) {
|
|
4005
|
+
if (_this.verifyTimeout[e2.target.$id]) clearTimeout(_this.verifyTimeout[e2.target.$id]);
|
|
4006
|
+
_this.verifyTimeout[e2.target.$id] = setTimeout(function() {
|
|
4007
|
+
var _event_verify;
|
|
4008
|
+
event === null || event === void 0 ? void 0 : (_event_verify = event.verify) === null || _event_verify === void 0 ? void 0 : _event_verify.call(event, field);
|
|
4009
|
+
delete _this.verifyTimeout[e2.target.$id];
|
|
4010
|
+
}, verifyASTime || 300);
|
|
4011
|
+
}
|
|
4012
|
+
};
|
|
4013
|
+
event.destroy = function() {
|
|
4014
|
+
return _this.destroy(event, content);
|
|
4015
|
+
};
|
|
4016
|
+
_this.addEvent("snack-event", event.snackEventCallback);
|
|
4017
|
+
if (_this.runtime) {
|
|
4018
|
+
for(var i2 = 0, l = event.children.length; i2 < l; i2++){
|
|
4019
|
+
var child = event.children[i2];
|
|
4020
|
+
if (child.M) {
|
|
4021
|
+
var _child_M_data, _child_M;
|
|
4022
|
+
_this.sendEvent("snack-event", [
|
|
4023
|
+
{
|
|
4024
|
+
name: "onCreate",
|
|
4025
|
+
target: child.M,
|
|
4026
|
+
value: (_child_M = child.M) === null || _child_M === void 0 ? void 0 : (_child_M_data = _child_M.data) === null || _child_M_data === void 0 ? void 0 : _child_M_data.value
|
|
4027
|
+
}
|
|
4028
|
+
]);
|
|
4029
|
+
}
|
|
4030
|
+
}
|
|
4031
|
+
}
|
|
4032
|
+
(_config_onComplete = config.onComplete) === null || _config_onComplete === void 0 ? void 0 : _config_onComplete.call(config, event, params);
|
|
4033
|
+
}
|
|
4034
|
+
}
|
|
4035
|
+
}), root, filter)
|
|
4036
|
+
];
|
|
4037
|
+
case 1:
|
|
4038
|
+
_ref = _state.sent(), content = _ref.content, pageData = _ref.pageData;
|
|
4039
|
+
if (!root) root = content !== null && content !== void 0 ? content : null;
|
|
4040
|
+
return [
|
|
4041
|
+
2,
|
|
4042
|
+
root
|
|
4043
|
+
];
|
|
4044
|
+
}
|
|
4045
|
+
});
|
|
4046
|
+
}).call(_this);
|
|
4047
|
+
};
|
|
4048
|
+
return [
|
|
4049
|
+
4,
|
|
4050
|
+
loadPage()
|
|
4051
|
+
];
|
|
4052
|
+
case 1:
|
|
4053
|
+
return [
|
|
4054
|
+
2,
|
|
4055
|
+
_state.sent()
|
|
4056
|
+
];
|
|
4057
|
+
}
|
|
4058
|
+
});
|
|
4059
|
+
}).apply(this, arguments);
|
|
4060
|
+
}
|
|
4061
|
+
},
|
|
4062
|
+
{
|
|
4063
|
+
/**
|
|
4064
|
+
* 卸载页面
|
|
4065
|
+
* @private
|
|
4066
|
+
*/ key: "destroy",
|
|
4067
|
+
value: function destroy(event, root) {
|
|
4068
|
+
var _this = this;
|
|
4069
|
+
if (!event) return;
|
|
4070
|
+
Object.keys(this.verifyTimeout).forEach(function(key) {
|
|
4071
|
+
return clearTimeout(_this.verifyTimeout[key]);
|
|
4072
|
+
});
|
|
4073
|
+
this.verifyTimeout = {};
|
|
4074
|
+
if (event.snackEventCallback) this.removeEvent("snack-event", event.snackEventCallback);
|
|
4075
|
+
Object.keys(event.childrenMaps).forEach(function(id) {
|
|
4076
|
+
if (!event) return true;
|
|
4077
|
+
var child = event.childrenMaps[id];
|
|
4078
|
+
if (child.D) {
|
|
4079
|
+
_this.remove(child.D.$id, false);
|
|
4080
|
+
child.D = null;
|
|
4081
|
+
child.DFC = null;
|
|
4082
|
+
}
|
|
4083
|
+
if (child.M) {
|
|
4084
|
+
_this.remove(child.M.$id, false);
|
|
4085
|
+
child.M = null;
|
|
4086
|
+
child.MFC = null;
|
|
4087
|
+
}
|
|
4088
|
+
if (child.S) {
|
|
4089
|
+
_this.remove(child.S.$id);
|
|
4090
|
+
child.S = null;
|
|
4091
|
+
child.SFC = null;
|
|
4092
|
+
}
|
|
4093
|
+
delete event.childrenMaps[id];
|
|
4094
|
+
});
|
|
4095
|
+
if (!root) return;
|
|
4096
|
+
this.remove(root.$id, false);
|
|
4097
|
+
root.data.children = [];
|
|
4098
|
+
root.$forceUpdate();
|
|
4099
|
+
event = null;
|
|
4100
|
+
root = null;
|
|
4101
|
+
}
|
|
4102
|
+
},
|
|
4103
|
+
{
|
|
4104
|
+
/**
|
|
4105
|
+
* 设置表单字段数据
|
|
4106
|
+
* @param formatArag
|
|
4107
|
+
* @param kv 所要设置的字段名,当value为空,key为对象则覆盖整个data对象
|
|
4108
|
+
* @param value 所要设置的字段值
|
|
4109
|
+
* @private
|
|
4110
|
+
*/ key: "formSetData",
|
|
4111
|
+
value: function formSetData(formatArag, kv, value) {
|
|
4112
|
+
var _this = this;
|
|
4113
|
+
var fields = formatArag.fields;
|
|
4114
|
+
var setValue = function setValue(f, value2) {
|
|
4115
|
+
if (!kv || !fields[f]) return;
|
|
4116
|
+
var M = fields[f].M;
|
|
4117
|
+
M.data.value = value2;
|
|
4118
|
+
M.data.value = _this.formFormatValue(M, formatArag);
|
|
4119
|
+
M.$forceUpdate();
|
|
4120
|
+
};
|
|
4121
|
+
if ((typeof kv === "undefined" ? "undefined" : _type_of(kv)) === "object") {
|
|
4122
|
+
Object.keys(fields).forEach(function(field) {
|
|
4123
|
+
var val = kv[field];
|
|
4124
|
+
if (val !== void 0) setValue(field, val);
|
|
4125
|
+
});
|
|
4126
|
+
} else if (typeof kv === "string") setValue(kv, value);
|
|
4127
|
+
return true;
|
|
4128
|
+
}
|
|
4129
|
+
},
|
|
4130
|
+
{
|
|
4131
|
+
/**
|
|
4132
|
+
* 表单入参转换
|
|
4133
|
+
* @param M
|
|
4134
|
+
* @param verify
|
|
4135
|
+
* @param fields
|
|
4136
|
+
* @param defaultData
|
|
4137
|
+
* @param childrenMaps
|
|
4138
|
+
* @private
|
|
4139
|
+
*/ key: "formFormatValue",
|
|
4140
|
+
value: function formFormatValue(M, param) {
|
|
4141
|
+
var verify = param.verify, fields = param.fields, _param_defaultData = param.defaultData, defaultData = _param_defaultData === void 0 ? {} : _param_defaultData, childrenMaps = param.childrenMaps;
|
|
4142
|
+
var _ref = M.data || {}, formAttr = _ref.formAttr, value = _ref.value;
|
|
4143
|
+
var inFormatJS = (formAttr || {}).inFormatJS;
|
|
4144
|
+
if (inFormatJS) value = evalJS_default.call(this, "inFormatJS", inFormatJS, {
|
|
4145
|
+
$this: M,
|
|
4146
|
+
$fields: fields,
|
|
4147
|
+
$verify: verify,
|
|
4148
|
+
$children: childrenMaps,
|
|
4149
|
+
$defaultData: defaultData,
|
|
4150
|
+
$message: this.message
|
|
4151
|
+
});
|
|
4152
|
+
return value;
|
|
4153
|
+
}
|
|
4154
|
+
},
|
|
4155
|
+
{
|
|
4156
|
+
/**
|
|
4157
|
+
* 获取表单数据
|
|
4158
|
+
* @param verify
|
|
4159
|
+
* @param childrenMaps
|
|
4160
|
+
* @param fields 表单字段对象
|
|
4161
|
+
* @param defaultData
|
|
4162
|
+
* @param key 指定获取字段值
|
|
4163
|
+
* @private
|
|
4164
|
+
*/ key: "formGetData",
|
|
4165
|
+
value: function formGetData(param, key) {
|
|
4166
|
+
var _this = this;
|
|
4167
|
+
var verify = param.verify, childrenMaps = param.childrenMaps, fields = param.fields, _param_defaultData = param.defaultData, defaultData = _param_defaultData === void 0 ? {} : _param_defaultData;
|
|
4168
|
+
var getValue = function getValue(f) {
|
|
4169
|
+
var M = fields[f].M;
|
|
4170
|
+
var _ref = M.data || {}, formAttr = _ref.formAttr, value = _ref.value;
|
|
4171
|
+
var _ref1 = formAttr || {}, field = _ref1.field, noSubmit = _ref1.noSubmit, outFormatJS = _ref1.outFormatJS;
|
|
4172
|
+
if (noSubmit || !field) return true;
|
|
4173
|
+
if (outFormatJS) value = evalJS_default.call(_this, "outFormatJS", outFormatJS, {
|
|
4174
|
+
$this: M,
|
|
4175
|
+
$fields: fields,
|
|
4176
|
+
$verify: verify,
|
|
4177
|
+
$children: childrenMaps,
|
|
4178
|
+
$defaultData: defaultData,
|
|
4179
|
+
$message: _this.message
|
|
4180
|
+
});
|
|
4181
|
+
if (typeof value === "string" && formAttr.trimValue !== false) value = value.trim();
|
|
4182
|
+
return value;
|
|
4183
|
+
};
|
|
4184
|
+
if (key) return getValue(key);
|
|
4185
|
+
var keys = Object.keys(fields);
|
|
4186
|
+
var newFormData = {};
|
|
4187
|
+
var password = [];
|
|
4188
|
+
keys.forEach(function(f) {
|
|
4189
|
+
var _M_data, _fields_f_M_data, _fields_f_M;
|
|
4190
|
+
var _ref = fields[f] || {}, M = _ref.M, D = _ref.D;
|
|
4191
|
+
if (!M || !D) return true;
|
|
4192
|
+
var _ref1 = ((_M_data = M.data) === null || _M_data === void 0 ? void 0 : _M_data.formAttr) || {}, noSubmit = _ref1.noSubmit, passwordFlag = _ref1.passwordFlag, hideNoSubmit = _ref1.hideNoSubmit;
|
|
4193
|
+
if (noSubmit === true) return true;
|
|
4194
|
+
var isHide = D.data.style.display === "none";
|
|
4195
|
+
if (isHide && hideNoSubmit) return true;
|
|
4196
|
+
var value = getValue(f);
|
|
4197
|
+
if (passwordFlag === true && typeof value === "string" && ((_fields_f_M = fields[f].M) === null || _fields_f_M === void 0 ? void 0 : (_fields_f_M_data = _fields_f_M.data) === null || _fields_f_M_data === void 0 ? void 0 : _fields_f_M_data.type) === "password") password.push(f);
|
|
4198
|
+
if (f.indexOf(".") !== -1) {
|
|
4199
|
+
var farr = f.split(".");
|
|
4200
|
+
var last = newFormData;
|
|
4201
|
+
farr.forEach(function(f1, index) {
|
|
4202
|
+
var isEnd = index === farr.length - 1;
|
|
4203
|
+
if ((typeof last === "undefined" ? "undefined" : _type_of(last)) === "object" && !_instanceof(last, Array)) {
|
|
4204
|
+
if (last[f1] === void 0 || last[f1] === null) last[f1] = {};
|
|
4205
|
+
if (isEnd) last[f1] = value;
|
|
4206
|
+
else last = last[f1];
|
|
4207
|
+
}
|
|
4208
|
+
});
|
|
4209
|
+
} else newFormData[f] = value;
|
|
4210
|
+
});
|
|
4211
|
+
if (password.length > 0) newFormData["@password"] = password;
|
|
4212
|
+
return newFormData;
|
|
4213
|
+
}
|
|
4214
|
+
},
|
|
4215
|
+
{
|
|
4216
|
+
key: "formVerify",
|
|
4217
|
+
value: /**
|
|
4218
|
+
* 表单校验
|
|
4219
|
+
* @private
|
|
4220
|
+
* @param formatArag
|
|
4221
|
+
* @param key
|
|
4222
|
+
* @param pageData
|
|
4223
|
+
*/ function formVerify(formatArag, key, pageData) {
|
|
4224
|
+
return _async_to_generator(function() {
|
|
4225
|
+
var _this, fields, verify, pass, keys, i, l, check;
|
|
4226
|
+
return _ts_generator(this, function(_state) {
|
|
4227
|
+
switch(_state.label){
|
|
4228
|
+
case 0:
|
|
4229
|
+
_this = this;
|
|
4230
|
+
fields = formatArag.fields;
|
|
4231
|
+
verify = function verify(f) {
|
|
4232
|
+
return _async_to_generator(function() {
|
|
4233
|
+
var _fields_f, M, D, hideNoSubmit, isHide;
|
|
4234
|
+
return _ts_generator(this, function(_state) {
|
|
4235
|
+
switch(_state.label){
|
|
4236
|
+
case 0:
|
|
4237
|
+
_fields_f = fields[f], M = _fields_f.M, D = _fields_f.D;
|
|
4238
|
+
hideNoSubmit = (M.data.formAttr || {}).hideNoSubmit;
|
|
4239
|
+
isHide = D.data.style.display === "none";
|
|
4240
|
+
if (isHide && hideNoSubmit === true) return [
|
|
4241
|
+
2,
|
|
4242
|
+
true
|
|
4243
|
+
];
|
|
4244
|
+
if (!M.data.formAttr) {
|
|
4245
|
+
console.error("SnackCore: the SnackModule 'data.formAttr' is undefind", M);
|
|
4246
|
+
return [
|
|
4247
|
+
2,
|
|
4248
|
+
true
|
|
4249
|
+
];
|
|
4250
|
+
}
|
|
4251
|
+
return [
|
|
4252
|
+
4,
|
|
4253
|
+
verifyJS_default.call(this, formatArag, M)
|
|
4254
|
+
];
|
|
4255
|
+
case 1:
|
|
4256
|
+
return [
|
|
4257
|
+
2,
|
|
4258
|
+
_state.sent()
|
|
4259
|
+
];
|
|
4260
|
+
}
|
|
4261
|
+
});
|
|
4262
|
+
}).call(_this);
|
|
4263
|
+
};
|
|
4264
|
+
if (!key) return [
|
|
4265
|
+
3,
|
|
4266
|
+
2
|
|
4267
|
+
];
|
|
4268
|
+
return [
|
|
4269
|
+
4,
|
|
4270
|
+
verify(key)
|
|
4271
|
+
];
|
|
4272
|
+
case 1:
|
|
4273
|
+
return [
|
|
4274
|
+
2,
|
|
4275
|
+
_state.sent()
|
|
4276
|
+
];
|
|
4277
|
+
case 2:
|
|
4278
|
+
pass = true;
|
|
4279
|
+
keys = Object.keys(fields);
|
|
4280
|
+
i = 0, l = keys.length;
|
|
4281
|
+
_state.label = 3;
|
|
4282
|
+
case 3:
|
|
4283
|
+
if (!(i < l)) return [
|
|
4284
|
+
3,
|
|
4285
|
+
6
|
|
4286
|
+
];
|
|
4287
|
+
return [
|
|
4288
|
+
4,
|
|
4289
|
+
verify(keys[i])
|
|
4290
|
+
];
|
|
4291
|
+
case 4:
|
|
4292
|
+
check = _state.sent();
|
|
4293
|
+
if (!check) pass = false;
|
|
4294
|
+
_state.label = 5;
|
|
4295
|
+
case 5:
|
|
4296
|
+
i++;
|
|
4297
|
+
return [
|
|
4298
|
+
3,
|
|
4299
|
+
3
|
|
4300
|
+
];
|
|
4301
|
+
case 6:
|
|
4302
|
+
return [
|
|
4303
|
+
2,
|
|
4304
|
+
pass
|
|
4305
|
+
];
|
|
4306
|
+
}
|
|
4307
|
+
});
|
|
4308
|
+
}).call(this);
|
|
4309
|
+
}
|
|
4310
|
+
},
|
|
4311
|
+
{
|
|
4312
|
+
/**
|
|
4313
|
+
* 清空表单填充数据
|
|
4314
|
+
* @param children
|
|
4315
|
+
* @private
|
|
4316
|
+
*/ key: "formEmpty",
|
|
4317
|
+
value: function formEmpty(children) {
|
|
4318
|
+
for(var i = 0, l = children.length; i < l; i++){
|
|
4319
|
+
try {
|
|
4320
|
+
var child = children[i];
|
|
4321
|
+
var value = void 0;
|
|
4322
|
+
switch(_type_of(child.M.data.value)){
|
|
4323
|
+
case "string":
|
|
4324
|
+
value = "";
|
|
4325
|
+
break;
|
|
4326
|
+
case "number":
|
|
4327
|
+
value = 0;
|
|
4328
|
+
break;
|
|
4329
|
+
case "object":
|
|
4330
|
+
if (_instanceof(child.M.data.value, Array)) value = [];
|
|
4331
|
+
else value = {};
|
|
4332
|
+
break;
|
|
4333
|
+
case "boolean":
|
|
4334
|
+
value = false;
|
|
4335
|
+
break;
|
|
4336
|
+
default:
|
|
4337
|
+
value = null;
|
|
4338
|
+
}
|
|
4339
|
+
child.M.data.value = value;
|
|
4340
|
+
child.M.$forceUpdate();
|
|
4341
|
+
} catch (e) {
|
|
4342
|
+
console.warn("SnackCore empty form error", e);
|
|
4343
|
+
return false;
|
|
4344
|
+
}
|
|
4345
|
+
}
|
|
4346
|
+
return true;
|
|
4347
|
+
}
|
|
4348
|
+
},
|
|
4349
|
+
{
|
|
4350
|
+
/**
|
|
4351
|
+
* 格式化Form入参数据
|
|
4352
|
+
* @param defaultData
|
|
4353
|
+
* @param moduleData 组件初始化入参
|
|
4354
|
+
* @param fields
|
|
4355
|
+
* @private
|
|
4356
|
+
*/ key: "formatData",
|
|
4357
|
+
value: function formatData(defaultData, moduleData, fields) {
|
|
4358
|
+
var _moduleData_data_M_formAttr, _moduleData_data_M, _moduleData_data;
|
|
4359
|
+
var field = (_moduleData_data = moduleData.data) === null || _moduleData_data === void 0 ? void 0 : (_moduleData_data_M = _moduleData_data.M) === null || _moduleData_data_M === void 0 ? void 0 : (_moduleData_data_M_formAttr = _moduleData_data_M.formAttr) === null || _moduleData_data_M_formAttr === void 0 ? void 0 : _moduleData_data_M_formAttr.field;
|
|
4360
|
+
if (field !== void 0) {
|
|
4361
|
+
var value;
|
|
4362
|
+
if (field.indexOf(".") === -1) value = defaultData[field];
|
|
4363
|
+
else value = safeGet(defaultData, field);
|
|
4364
|
+
if (value !== void 0 && moduleData.data) {
|
|
4365
|
+
var _moduleData_data1;
|
|
4366
|
+
var defaultValue = value === "object" ? DeepClone2(value) : value;
|
|
4367
|
+
moduleData.data.M.__defaultvalue = defaultValue;
|
|
4368
|
+
moduleData.data.M.value = value;
|
|
4369
|
+
moduleData.data.M.value = this.formFormatValue({
|
|
4370
|
+
data: (_moduleData_data1 = moduleData.data) === null || _moduleData_data1 === void 0 ? void 0 : _moduleData_data1.M
|
|
4371
|
+
}, {
|
|
4372
|
+
fields: fields,
|
|
4373
|
+
defaultData: defaultData,
|
|
4374
|
+
childrenMaps: {}
|
|
4375
|
+
});
|
|
4376
|
+
}
|
|
4377
|
+
}
|
|
4378
|
+
return moduleData;
|
|
4379
|
+
}
|
|
4380
|
+
},
|
|
4381
|
+
{
|
|
4382
|
+
/**
|
|
4383
|
+
* 解码页面内容base64
|
|
4384
|
+
* @param data
|
|
4385
|
+
*/ key: "pageContentDecode",
|
|
4386
|
+
value: function pageContentDecode(data) {
|
|
4387
|
+
if (typeof data.content === "string") data.content = toObject(base64Decode(data.content), null);
|
|
4388
|
+
return data;
|
|
4389
|
+
}
|
|
4390
|
+
},
|
|
4391
|
+
{
|
|
4392
|
+
key: "getPage",
|
|
4393
|
+
value: /**
|
|
4394
|
+
* 获取页面数据
|
|
4395
|
+
*/ function getPage(params) {
|
|
4396
|
+
return _async_to_generator(function() {
|
|
4397
|
+
var _ref, error, data;
|
|
4398
|
+
return _ts_generator(this, function(_state) {
|
|
4399
|
+
switch(_state.label){
|
|
4400
|
+
case 0:
|
|
4401
|
+
return [
|
|
4402
|
+
4,
|
|
4403
|
+
Get({
|
|
4404
|
+
url: "".concat(this.pageUrl, "/").concat(params.type || "_", "/").concat(params.id, ".json")
|
|
4405
|
+
})
|
|
4406
|
+
];
|
|
4407
|
+
case 1:
|
|
4408
|
+
_ref = _state.sent(), error = _ref.error, data = _ref.data;
|
|
4409
|
+
if (error) {
|
|
4410
|
+
console.error("Snack SDK: Get Page Data Error ", error);
|
|
4411
|
+
return [
|
|
4412
|
+
2,
|
|
4413
|
+
null
|
|
4414
|
+
];
|
|
4415
|
+
}
|
|
4416
|
+
return [
|
|
4417
|
+
2,
|
|
4418
|
+
data !== null && data !== void 0 ? data : null
|
|
4419
|
+
];
|
|
4420
|
+
}
|
|
4421
|
+
});
|
|
4422
|
+
}).call(this);
|
|
4423
|
+
}
|
|
4424
|
+
},
|
|
4425
|
+
{
|
|
4426
|
+
key: "createPageComponent",
|
|
4427
|
+
value: /**
|
|
4428
|
+
* 渲染设计器页面 - React FC组件
|
|
4429
|
+
* @param params {SnackPageConfig}
|
|
4430
|
+
* @param config {RenderPageConfig}
|
|
4431
|
+
*/ function createPageComponent(_0) {
|
|
4432
|
+
return _async_to_generator(function(params) {
|
|
4433
|
+
var config, root;
|
|
4434
|
+
var _arguments = arguments;
|
|
4435
|
+
return _ts_generator(this, function(_state) {
|
|
4436
|
+
switch(_state.label){
|
|
4437
|
+
case 0:
|
|
4438
|
+
config = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : {};
|
|
4439
|
+
return [
|
|
4440
|
+
4,
|
|
4441
|
+
this.renderPage(params, config)
|
|
4442
|
+
];
|
|
4443
|
+
case 1:
|
|
4444
|
+
root = _state.sent();
|
|
4445
|
+
if (!root) {
|
|
4446
|
+
console.error("SnackSDK: Create Page Error", params);
|
|
4447
|
+
return [
|
|
4448
|
+
2,
|
|
4449
|
+
function() {
|
|
4450
|
+
return /* @__PURE__ */ React5.createElement(error_default, {
|
|
4451
|
+
content: "\u9875\u9762\u6E32\u67D3\u5931\u8D25",
|
|
4452
|
+
info: JSON.stringify(params, null, 4)
|
|
4453
|
+
});
|
|
4454
|
+
}
|
|
4455
|
+
];
|
|
4456
|
+
}
|
|
4457
|
+
return [
|
|
4458
|
+
2,
|
|
4459
|
+
function(e) {
|
|
4460
|
+
return root.FC(e);
|
|
4461
|
+
}
|
|
4462
|
+
];
|
|
4463
|
+
}
|
|
4464
|
+
});
|
|
4465
|
+
}).apply(this, arguments);
|
|
4466
|
+
}
|
|
4467
|
+
},
|
|
4468
|
+
{
|
|
4469
|
+
key: "createPageForElement",
|
|
4470
|
+
value: /**
|
|
4471
|
+
* 渲染页面到dom元素内
|
|
4472
|
+
* @param el
|
|
4473
|
+
* @param params
|
|
4474
|
+
* @param config
|
|
4475
|
+
*/ function createPageForElement(_0, _1) {
|
|
4476
|
+
return _async_to_generator(function(el, params) {
|
|
4477
|
+
var config, root, Page, parent;
|
|
4478
|
+
var _arguments = arguments;
|
|
4479
|
+
return _ts_generator(this, function(_state) {
|
|
4480
|
+
switch(_state.label){
|
|
4481
|
+
case 0:
|
|
4482
|
+
config = _arguments.length > 2 && _arguments[2] !== void 0 ? _arguments[2] : {};
|
|
4483
|
+
return [
|
|
4484
|
+
4,
|
|
4485
|
+
this.renderPage(params, config)
|
|
4486
|
+
];
|
|
4487
|
+
case 1:
|
|
4488
|
+
root = _state.sent();
|
|
4489
|
+
if (!root) {
|
|
4490
|
+
console.error("SnackSDK: Create Page Error", params);
|
|
4491
|
+
el.innerHTML = "<div>\u9875\u9762\u6E32\u67D3\u5931\u8D25</div>";
|
|
4492
|
+
return [
|
|
4493
|
+
2,
|
|
4494
|
+
null
|
|
4495
|
+
];
|
|
4496
|
+
}
|
|
4497
|
+
Page = function Page(e) {
|
|
4498
|
+
return root.FC(e);
|
|
4499
|
+
};
|
|
4500
|
+
parent = createRoot(el);
|
|
4501
|
+
parent.render(/* @__PURE__ */ React5.createElement(Page, _object_spread({}, {})));
|
|
4502
|
+
return [
|
|
4503
|
+
2,
|
|
4504
|
+
root
|
|
4505
|
+
];
|
|
4506
|
+
}
|
|
4507
|
+
});
|
|
4508
|
+
}).apply(this, arguments);
|
|
4509
|
+
}
|
|
4510
|
+
},
|
|
4511
|
+
{
|
|
4512
|
+
key: "createModuleComponent",
|
|
4513
|
+
value: /**
|
|
4514
|
+
* 渲染模块 - React FC组件
|
|
4515
|
+
* @param args 模块装载参数
|
|
4516
|
+
* @param data 模块初始数据
|
|
4517
|
+
*/ function createModuleComponent(args, data) {
|
|
4518
|
+
return _async_to_generator(function() {
|
|
4519
|
+
var mod;
|
|
4520
|
+
return _ts_generator(this, function(_state) {
|
|
4521
|
+
switch(_state.label){
|
|
4522
|
+
case 0:
|
|
4523
|
+
return [
|
|
4524
|
+
4,
|
|
4525
|
+
this.createModule(args, data)
|
|
4526
|
+
];
|
|
4527
|
+
case 1:
|
|
4528
|
+
mod = _state.sent();
|
|
4529
|
+
if (!mod) {
|
|
4530
|
+
console.error("SnackSDK: Create Page Error", args);
|
|
4531
|
+
return [
|
|
4532
|
+
2,
|
|
4533
|
+
function() {
|
|
4534
|
+
return /* @__PURE__ */ React5.createElement(error_default, {
|
|
4535
|
+
content: "\u6A21\u5757\u6E32\u67D3\u5931\u8D25",
|
|
4536
|
+
info: JSON.stringify(args, null, 4)
|
|
4537
|
+
});
|
|
4538
|
+
}
|
|
4539
|
+
];
|
|
4540
|
+
}
|
|
4541
|
+
return [
|
|
4542
|
+
2,
|
|
4543
|
+
function(e) {
|
|
4544
|
+
return mod.FC(e);
|
|
4545
|
+
}
|
|
4546
|
+
];
|
|
4547
|
+
}
|
|
4548
|
+
});
|
|
4549
|
+
}).call(this);
|
|
4550
|
+
}
|
|
4551
|
+
},
|
|
4552
|
+
{
|
|
4553
|
+
key: "createModuleForElement",
|
|
4554
|
+
value: /**
|
|
4555
|
+
* 渲染模块到dom元素内
|
|
4556
|
+
* @param el 所要渲染模块的容器
|
|
4557
|
+
* @param args 模块装载参数
|
|
4558
|
+
* @param data 模块初始数据
|
|
4559
|
+
*/ function createModuleForElement(el, args, data) {
|
|
4560
|
+
return _async_to_generator(function() {
|
|
4561
|
+
var mod, Module, parent;
|
|
4562
|
+
return _ts_generator(this, function(_state) {
|
|
4563
|
+
switch(_state.label){
|
|
4564
|
+
case 0:
|
|
4565
|
+
return [
|
|
4566
|
+
4,
|
|
4567
|
+
this.createModule(args, data)
|
|
4568
|
+
];
|
|
4569
|
+
case 1:
|
|
4570
|
+
mod = _state.sent();
|
|
4571
|
+
if (!mod) {
|
|
4572
|
+
console.error("SnackSDK: Create Page Error", args);
|
|
4573
|
+
el.innerHTML = "<div>\u6A21\u5757\u6E32\u67D3\u5931\u8D25</div>";
|
|
4574
|
+
return [
|
|
4575
|
+
2,
|
|
4576
|
+
null
|
|
4577
|
+
];
|
|
4578
|
+
}
|
|
4579
|
+
Module = function Module(e) {
|
|
4580
|
+
return mod.FC(e);
|
|
4581
|
+
};
|
|
4582
|
+
parent = createRoot(el);
|
|
4583
|
+
parent.render(/* @__PURE__ */ React5.createElement(Module, _object_spread({}, {})));
|
|
4584
|
+
return [
|
|
4585
|
+
2,
|
|
4586
|
+
mod
|
|
4587
|
+
];
|
|
4588
|
+
}
|
|
4589
|
+
});
|
|
4590
|
+
}).call(this);
|
|
4591
|
+
}
|
|
4592
|
+
},
|
|
4593
|
+
{
|
|
4594
|
+
/**
|
|
4595
|
+
* 通过模块Class渲染模块
|
|
4596
|
+
* @param SnackClass sanck 模块 Class
|
|
4597
|
+
* @param data snack对象参数
|
|
4598
|
+
* @param main 如果为设置模块,传入主模块对象
|
|
4599
|
+
*/ key: "createClassModule",
|
|
4600
|
+
value: function createClassModule(SnackClass, data, main) {
|
|
4601
|
+
if (data && !data.$snackSDK) data.$snackSDK = this;
|
|
4602
|
+
else if (!data) {
|
|
4603
|
+
data = {
|
|
4604
|
+
$snackSDK: this
|
|
4605
|
+
};
|
|
4606
|
+
}
|
|
4607
|
+
var mod;
|
|
4608
|
+
if (main !== void 0) mod = new SnackClass(main, data);
|
|
4609
|
+
else mod = new SnackClass(data);
|
|
4610
|
+
return mod;
|
|
4611
|
+
}
|
|
4612
|
+
},
|
|
4613
|
+
{
|
|
4614
|
+
/**
|
|
4615
|
+
* 通过模块Class渲染模块
|
|
4616
|
+
* @param SnackClass snack 模块 Class
|
|
4617
|
+
* @param data snack对象参数
|
|
4618
|
+
* @param main 如果为设置模块,传入主模块对象
|
|
4619
|
+
*/ key: "createClassModuleComponent",
|
|
4620
|
+
value: function createClassModuleComponent(SnackClass, data, main) {
|
|
4621
|
+
var mod = this.createClassModule(SnackClass, data, main);
|
|
4622
|
+
return function(e) {
|
|
4623
|
+
return mod.FC(e);
|
|
4624
|
+
};
|
|
4625
|
+
}
|
|
4626
|
+
}
|
|
4627
|
+
]);
|
|
4628
|
+
return SnackSDK1;
|
|
4629
|
+
}(core_default);
|
|
4630
|
+
var GetDefaultEvents = function GetDefaultEvents1(language) {
|
|
4631
|
+
return [
|
|
4632
|
+
{
|
|
4633
|
+
name: "onCreateBefore",
|
|
4634
|
+
label: language === "en-US" ? "Before the component is initialized" : "\u7EC4\u4EF6\u521D\u59CB\u5316\u4E4B\u524D",
|
|
4635
|
+
default: true,
|
|
4636
|
+
verify: false
|
|
4637
|
+
},
|
|
4638
|
+
{
|
|
4639
|
+
name: "onCreate",
|
|
4640
|
+
label: language === "en-US" ? "Component initialization" : "\u7EC4\u4EF6\u521D\u59CB\u5316",
|
|
4641
|
+
default: true
|
|
4642
|
+
},
|
|
4643
|
+
{
|
|
4644
|
+
name: "onClick",
|
|
4645
|
+
label: language === "en-US" ? "click" : "\u70B9\u51FB"
|
|
4646
|
+
},
|
|
4647
|
+
{
|
|
4648
|
+
name: "onChange",
|
|
4649
|
+
label: language === "en-US" ? "Numeric changes" : "\u6570\u503C\u53D8\u66F4"
|
|
4650
|
+
},
|
|
4651
|
+
{
|
|
4652
|
+
name: "onFocus",
|
|
4653
|
+
label: language === "en-US" ? "Get focused" : "\u83B7\u5F97\u7126\u70B9"
|
|
4654
|
+
},
|
|
4655
|
+
{
|
|
4656
|
+
name: "onBlur",
|
|
4657
|
+
label: language === "en-US" ? "Loss of focus" : "\u5931\u53BB\u7126\u70B9"
|
|
4658
|
+
},
|
|
4659
|
+
{
|
|
4660
|
+
name: "onEnter",
|
|
4661
|
+
label: language === "en-US" ? "Enter" : "\u56DE\u8F66"
|
|
4662
|
+
}
|
|
4663
|
+
];
|
|
4664
|
+
};
|
|
4665
|
+
// src/components/loading/index.tsx
|
|
4666
|
+
import React6 from "react";
|
|
4667
|
+
var Loading = function Loading1(props) {
|
|
4668
|
+
var ref = React6.useRef(null);
|
|
4669
|
+
var _React6_useState = _sliced_to_array(React6.useState(0), 2), opacity = _React6_useState[0], setOpacity = _React6_useState[1];
|
|
4670
|
+
React6.useEffect(function() {
|
|
4671
|
+
var timeout = setTimeout(function() {
|
|
4672
|
+
setOpacity(1);
|
|
4673
|
+
}, 500);
|
|
4674
|
+
return function() {
|
|
4675
|
+
return clearTimeout(timeout);
|
|
4676
|
+
};
|
|
4677
|
+
}, []);
|
|
4678
|
+
return /* @__PURE__ */ React6.createElement("div", {
|
|
4679
|
+
className: "snack-core-loading ".concat(props.className || ""),
|
|
4680
|
+
ref: ref,
|
|
4681
|
+
style: {
|
|
4682
|
+
opacity: opacity
|
|
4683
|
+
}
|
|
4684
|
+
}, /* @__PURE__ */ React6.createElement("div", {
|
|
4685
|
+
className: "spinner"
|
|
4686
|
+
}));
|
|
4687
|
+
};
|
|
4688
|
+
// package.json
|
|
4689
|
+
var package_default = {
|
|
4690
|
+
name: "@snack-kit/core",
|
|
4691
|
+
version: "0.1.0",
|
|
4692
|
+
main: "dist/cjs/index.js",
|
|
4693
|
+
module: "dist/es/index.js",
|
|
4694
|
+
typings: "dist/types/index.d.ts",
|
|
4695
|
+
exports: {
|
|
4696
|
+
".": {
|
|
4697
|
+
types: "./dist/types/index.d.ts",
|
|
4698
|
+
import: "./dist/es/index.js",
|
|
4699
|
+
require: "./dist/cjs/index.js"
|
|
4700
|
+
}
|
|
4701
|
+
},
|
|
4702
|
+
description: "Snack by Para FED",
|
|
4703
|
+
scripts: {
|
|
4704
|
+
dev: "webpack serve --mode=development --config=webpack.dev.config.js",
|
|
4705
|
+
build: "tsup",
|
|
4706
|
+
"build:watch": "tsup --watch",
|
|
4707
|
+
test: "vitest run",
|
|
4708
|
+
"test:watch": "vitest",
|
|
4709
|
+
"test:coverage": "vitest run --coverage",
|
|
4710
|
+
docs: "typedoc",
|
|
4711
|
+
lint: "tsc --noEmit",
|
|
4712
|
+
clean: "rimraf ./dist",
|
|
4713
|
+
prepublishOnly: "npm run build",
|
|
4714
|
+
release: "npm run build && npm publish --access public"
|
|
4715
|
+
},
|
|
4716
|
+
snack: {},
|
|
4717
|
+
files: [
|
|
4718
|
+
"dist",
|
|
4719
|
+
"package.json"
|
|
4720
|
+
],
|
|
4721
|
+
author: "",
|
|
4722
|
+
license: "ISC",
|
|
4723
|
+
dependencies: {
|
|
4724
|
+
"@snack-kit/lib": "^0.6.0",
|
|
4725
|
+
react: "^19.2.0",
|
|
4726
|
+
"react-dom": "^19.2.0"
|
|
4727
|
+
},
|
|
4728
|
+
devDependencies: {
|
|
4729
|
+
"@swc/core": "^1.15.18",
|
|
4730
|
+
"@types/react": "^19.2.7",
|
|
4731
|
+
"@types/react-dom": "^19.2.3",
|
|
4732
|
+
"@vitest/coverage-v8": "^2.0.0",
|
|
4733
|
+
"css-loader": "^7.1.4",
|
|
4734
|
+
"html-webpack-plugin": "^5.6.6",
|
|
4735
|
+
jsdom: "^24.0.0",
|
|
4736
|
+
minimist: "^1.2.8",
|
|
4737
|
+
rimraf: "^5.0.0",
|
|
4738
|
+
sass: "^1.97.3",
|
|
4739
|
+
"sass-loader": "^16.0.7",
|
|
4740
|
+
"style-loader": "^4.0.0",
|
|
4741
|
+
"swc-loader": "^0.2.7",
|
|
4742
|
+
tsup: "^8.0.0",
|
|
4743
|
+
typedoc: "^0.26.0",
|
|
4744
|
+
typescript: "^5.0.0",
|
|
4745
|
+
vitest: "^2.0.0",
|
|
4746
|
+
webpack: "^5.105.3",
|
|
4747
|
+
"webpack-cli": "^6.0.1",
|
|
4748
|
+
"webpack-dev-server": "^5.2.3"
|
|
4749
|
+
}
|
|
4750
|
+
};
|
|
4751
|
+
// src/index.ts
|
|
4752
|
+
var version2 = package_default.version;
|
|
4753
|
+
var src_default = {
|
|
4754
|
+
version: version2
|
|
4755
|
+
};
|
|
4756
|
+
console.log("\n ____ __ _______ __ __\n / __/__ ___ _____/ /__ / __/ _ \\/ //_/\n _\\ \\/ _ \\/ _ `/ __/ '_/_\\ \\/ // / ,< \n/___/_//_/\\_,_/\\__/_/\\_\\/___/____/_/|_| v.".concat(version2, "\n \n"));
|
|
4757
|
+
export { Core, DisplayModule, Error2 as Error, GetDefaultEvents, GetParamsDetails, Loading, ParamsDetails, Snack, SnackSDK, SnackSetting, src_default as default, enParamsDetails, evalFunc, replaceVars }; /**
|
|
4758
|
+
* @license Snack RequireJS 2.3.6
|
|
4759
|
+
*/
|
|
4760
|
+
//# sourceMappingURL=index.mjs.map
|