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