@pisell/utils 2.0.1 → 2.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -48,18 +48,15 @@ function _numToHexStr(n, bytes) {
48
48
  var v;
49
49
  for (var i = 0; i < bytes; i++) {
50
50
  v = n & 255;
51
- if (v < 16)
52
- str += "0" + v.toString(16);
53
- else
54
- str += v.toString(16);
51
+ if (v < 16) str += "0" + v.toString(16);
52
+ else str += v.toString(16);
55
53
  n >>= 8;
56
54
  }
57
55
  return str;
58
56
  }
59
57
  function _unicodeToUtf8(unicode) {
60
58
  var c1, c2, c3, c4;
61
- if (unicode < 0)
62
- return "";
59
+ if (unicode < 0) return "";
63
60
  if (unicode <= 127) {
64
61
  c1 = unicode & 127;
65
62
  return _numToHexStr(c1, 1);
@@ -133,8 +130,7 @@ EscPosPrinter.prototype.appendText = function(str) {
133
130
  this.orderData += _unicodeToUtf8(str.charCodeAt(i));
134
131
  };
135
132
  EscPosPrinter.prototype.lineFeed = function(n) {
136
- for (var i = 0; i < n; i++)
137
- this.orderData += "0a";
133
+ for (var i = 0; i < n; i++) this.orderData += "0a";
138
134
  };
139
135
  EscPosPrinter.prototype.restoreDefaultSettings = function() {
140
136
  this.charHSize = 1;
@@ -144,24 +140,19 @@ EscPosPrinter.prototype.restoreDefaultLineSpacing = function() {
144
140
  this.orderData += "1b32";
145
141
  };
146
142
  EscPosPrinter.prototype.setLineSpacing = function(n) {
147
- if (n >= 0 && n <= 255)
148
- this.orderData += "1b33" + _numToHexStr(n, 1);
143
+ if (n >= 0 && n <= 255) this.orderData += "1b33" + _numToHexStr(n, 1);
149
144
  };
150
145
  EscPosPrinter.prototype.setPrintModes = function(bold, double_h, double_w) {
151
146
  var n = 0;
152
- if (bold)
153
- n |= 8;
154
- if (double_h)
155
- n |= 16;
156
- if (double_w)
157
- n |= 32;
147
+ if (bold) n |= 8;
148
+ if (double_h) n |= 16;
149
+ if (double_w) n |= 32;
158
150
  this.charHSize = double_w ? 2 : 1;
159
151
  this.orderData += "1b21" + _numToHexStr(n, 1);
160
152
  };
161
153
  EscPosPrinter.prototype.setCharacterSize = function(h, w) {
162
154
  var n = 0;
163
- if (h >= 1 && h <= 8)
164
- n |= h - 1;
155
+ if (h >= 1 && h <= 8) n |= h - 1;
165
156
  if (w >= 1 && w <= 8) {
166
157
  n |= w - 1 << 4;
167
158
  this.charHSize = w;
@@ -169,20 +160,16 @@ EscPosPrinter.prototype.setCharacterSize = function(h, w) {
169
160
  this.orderData += "1d21" + _numToHexStr(n, 1);
170
161
  };
171
162
  EscPosPrinter.prototype.horizontalTab = function(n) {
172
- for (var i = 0; i < n; i++)
173
- this.orderData += "09";
163
+ for (var i = 0; i < n; i++) this.orderData += "09";
174
164
  };
175
165
  EscPosPrinter.prototype.setAbsolutePrintPosition = function(n) {
176
- if (n >= 0 && n <= 65535)
177
- this.orderData += "1b24" + _numToHexStr(n, 2);
166
+ if (n >= 0 && n <= 65535) this.orderData += "1b24" + _numToHexStr(n, 2);
178
167
  };
179
168
  EscPosPrinter.prototype.setRelativePrintPosition = function(n) {
180
- if (n >= -32768 && n <= 32767)
181
- this.orderData += "1b5c" + _numToHexStr(n, 2);
169
+ if (n >= -32768 && n <= 32767) this.orderData += "1b5c" + _numToHexStr(n, 2);
182
170
  };
183
171
  EscPosPrinter.prototype.setAlignment = function(n) {
184
- if (n >= 0 && n <= 2)
185
- this.orderData += "1b61" + _numToHexStr(n, 1);
172
+ if (n >= 0 && n <= 2) this.orderData += "1b61" + _numToHexStr(n, 1);
186
173
  };
187
174
  EscPosPrinter.prototype.cutPaper = function(fullCut) {
188
175
  this.orderData += "1d56" + (fullCut ? "30" : "31");
@@ -213,10 +200,8 @@ function _columnAlignment(v) {
213
200
  }
214
201
  EscPosPrinter.prototype.setColumnWidths = function() {
215
202
  var i, remain, width, alignment;
216
- if (arguments.length == 0)
217
- return;
218
- for (i = 0; i < MAX_COLUMNS; i++)
219
- this.widthOfColumns[i] = 0;
203
+ if (arguments.length == 0) return;
204
+ for (i = 0; i < MAX_COLUMNS; i++) this.widthOfColumns[i] = 0;
220
205
  remain = this.dotsPerLine;
221
206
  for (i = 0; i < arguments.length; i++) {
222
207
  if (i == MAX_COLUMNS)
@@ -237,12 +222,10 @@ EscPosPrinter.prototype.printInColumns = function() {
237
222
  var strwidth = new Array(MAX_COLUMNS);
238
223
  var i, j, c, w, columns, width, alignment, pos;
239
224
  var done;
240
- if (arguments.length == 0)
241
- return;
225
+ if (arguments.length == 0) return;
242
226
  columns = 0;
243
227
  for (i = 0; i < arguments.length; i++) {
244
- if (i == MAX_COLUMNS || this.widthOfColumns[i] == 0)
245
- break;
228
+ if (i == MAX_COLUMNS || this.widthOfColumns[i] == 0) break;
246
229
  strcurr[i] = "";
247
230
  strrem[i] = arguments[i];
248
231
  columns++;
@@ -279,10 +262,8 @@ EscPosPrinter.prototype.printInColumns = function() {
279
262
  }
280
263
  }
281
264
  }
282
- if (j < strrem[i].length)
283
- strrem[i] = strrem[i].substring(j);
284
- else
285
- strrem[i] = "";
265
+ if (j < strrem[i].length) strrem[i] = strrem[i].substring(j);
266
+ else strrem[i] = "";
286
267
  alignment = _columnAlignment(this.widthOfColumns[i]);
287
268
  switch (alignment) {
288
269
  case ALIGN_CENTER:
@@ -298,24 +279,17 @@ EscPosPrinter.prototype.printInColumns = function() {
298
279
  this.appendText(strcurr[i]);
299
280
  pos += width;
300
281
  }
301
- if (!done)
302
- this.lineFeed(1);
282
+ if (!done) this.lineFeed(1);
303
283
  } while (!done);
304
284
  };
305
285
  EscPosPrinter.prototype.appendBarcode = function(hri_pos, height, module_size, barcode_type, text) {
306
286
  var text_length = text.length;
307
- if (text_length == 0)
308
- return;
309
- if (text_length > 255)
310
- text_length = 255;
311
- if (height < 1)
312
- height = 1;
313
- else if (height > 255)
314
- height = 255;
315
- if (module_size < 1)
316
- module_size = 1;
317
- else if (module_size > 6)
318
- module_size = 6;
287
+ if (text_length == 0) return;
288
+ if (text_length > 255) text_length = 255;
289
+ if (height < 1) height = 1;
290
+ else if (height > 255) height = 255;
291
+ if (module_size < 1) module_size = 1;
292
+ else if (module_size > 6) module_size = 6;
319
293
  this.orderData += "1d48" + _numToHexStr(hri_pos & 3, 1);
320
294
  this.orderData += "1d6600";
321
295
  this.orderData += "1d68" + _numToHexStr(height, 1);
@@ -326,18 +300,12 @@ EscPosPrinter.prototype.appendBarcode = function(hri_pos, height, module_size, b
326
300
  };
327
301
  EscPosPrinter.prototype.appendQRcode = function(module_size, ec_level, text) {
328
302
  var text_length = text.length;
329
- if (text_length == 0)
330
- return;
331
- if (text_length > 65535)
332
- text_length = 65535;
333
- if (module_size < 1)
334
- module_size = 1;
335
- else if (module_size > 16)
336
- module_size = 16;
337
- if (ec_level < 0)
338
- ec_level = 0;
339
- else if (ec_level > 3)
340
- ec_level = 3;
303
+ if (text_length == 0) return;
304
+ if (text_length > 65535) text_length = 65535;
305
+ if (module_size < 1) module_size = 1;
306
+ else if (module_size > 16) module_size = 16;
307
+ if (ec_level < 0) ec_level = 0;
308
+ else if (ec_level > 3) ec_level = 3;
341
309
  this.orderData += "1d286b040031410000";
342
310
  this.orderData += "1d286b03003143" + _numToHexStr(module_size, 1);
343
311
  this.orderData += "1d286b03003145" + _numToHexStr(ec_level + 48, 1);
@@ -347,10 +315,8 @@ EscPosPrinter.prototype.appendQRcode = function(module_size, ec_level, text) {
347
315
  this.orderData += "1d286b0300315130";
348
316
  };
349
317
  function _diffuseDither(src_data, width, height) {
350
- if (width <= 0 || height <= 0)
351
- return null;
352
- if (src_data.length < width * height)
353
- return null;
318
+ if (width <= 0 || height <= 0) return null;
319
+ if (src_data.length < width * height) return null;
354
320
  var bmwidth = width + 7 >> 3;
355
321
  var dst_data = new Array(bmwidth * height);
356
322
  var line_buffer = new Array(2 * width);
@@ -404,14 +370,11 @@ function _diffuseDither(src_data, width, height) {
404
370
  e5 = err * 5 + 8 >> 4;
405
371
  e3 = err * 3 + 8 >> 4;
406
372
  e1 = err - (e7 + e5 + e3);
407
- if (x < width)
408
- line_buffer[line1 * width + b1] += e7;
373
+ if (x < width) line_buffer[line1 * width + b1] += e7;
409
374
  if (not_last_line) {
410
375
  line_buffer[line2 * width + b2] += e5;
411
- if (x > 1)
412
- line_buffer[line2 * width + b2 - 1] += e3;
413
- if (x < width)
414
- line_buffer[line2 * width + b2 + 1] += e1;
376
+ if (x > 1) line_buffer[line2 * width + b2 - 1] += e3;
377
+ if (x < width) line_buffer[line2 * width + b2 + 1] += e1;
415
378
  }
416
379
  b2++;
417
380
  }
@@ -419,10 +382,8 @@ function _diffuseDither(src_data, width, height) {
419
382
  return dst_data;
420
383
  }
421
384
  function _thresholdDither(src_data, width, height) {
422
- if (width <= 0 || height <= 0)
423
- return null;
424
- if (src_data.length < width * height)
425
- return null;
385
+ if (width <= 0 || height <= 0) return null;
386
+ if (src_data.length < width * height) return null;
426
387
  var bmwidth = width + 7 >> 3;
427
388
  var dst_data = new Array(bmwidth * height);
428
389
  var p, q, k, x, y, mask;
@@ -466,8 +427,7 @@ EscPosPrinter.prototype.appendImage = function(imgdata, dither) {
466
427
  var w = imgdata.width;
467
428
  var h = imgdata.height;
468
429
  gray_data = _convertToGray(imgdata, w, h);
469
- if (dither == "diffuse")
470
- mono_data = _diffuseDither(gray_data, w, h);
430
+ if (dither == "diffuse") mono_data = _diffuseDither(gray_data, w, h);
471
431
  else
472
432
  mono_data = _thresholdDither(gray_data, w, h);
473
433
  w = w + 7 >> 3;
@@ -488,16 +448,13 @@ EscPosPrinter.prototype.setPrintAreaInPageMode = function(x, y, w, h) {
488
448
  this.orderData += _numToHexStr(h, 2);
489
449
  };
490
450
  EscPosPrinter.prototype.setPrintDirectionInPageMode = function(dir) {
491
- if (dir >= 0 && dir <= 3)
492
- this.orderData += "1b54" + _numToHexStr(dir, 1);
451
+ if (dir >= 0 && dir <= 3) this.orderData += "1b54" + _numToHexStr(dir, 1);
493
452
  };
494
453
  EscPosPrinter.prototype.setAbsolutePrintPositionInPageMode = function(n) {
495
- if (n >= 0 && n <= 65535)
496
- this.orderData += "1d24" + _numToHexStr(n, 2);
454
+ if (n >= 0 && n <= 65535) this.orderData += "1d24" + _numToHexStr(n, 2);
497
455
  };
498
456
  EscPosPrinter.prototype.setRelativePrintPositionInPageMode = function(n) {
499
- if (n >= -32768 && n <= 32767)
500
- this.orderData += "1d5c" + _numToHexStr(n, 2);
457
+ if (n >= -32768 && n <= 32767) this.orderData += "1d5c" + _numToHexStr(n, 2);
501
458
  };
502
459
  EscPosPrinter.prototype.printAndExitPageMode = function() {
503
460
  this.orderData += "0c";
@@ -49,7 +49,7 @@ var preparing = async (ip, sn, params) => {
49
49
  printer.lineFeed(1);
50
50
  printer.setPrintModes(false, false, false);
51
51
  printer.setAlignment(import_EscPosPrinter.ALIGN_CENTER);
52
- printer.appendText("\u6253\u5370\u6D4B\u8BD5\n");
52
+ printer.appendText("打印测试\n");
53
53
  dividing(printer);
54
54
  printer.setAlignment(import_EscPosPrinter.ALIGN_LEFT);
55
55
  printer.appendText("Order time: 2023-10-19 14:15:50\n");
@@ -64,7 +64,7 @@ var preparing = async (ip, sn, params) => {
64
64
  printer.setPrintModes(true, true, true);
65
65
  printer.printInColumns(
66
66
  "1 x",
67
- "\u6211\u662F\u5F88\u957F\u7684\u5546\u54C1\u540D\u79F0\u6211\u662F\u5F88\u957F\u7684\u5546\u54C1\u540D\u79F0\u6211\u662F\u5F88\u957F\u7684\u5546\u54C1\u540D\u79F0\u6211\u662F\u5F88\u957F\u7684\u5546\u54C1\u540D\u79F0"
67
+ "我是很长的商品名称我是很长的商品名称我是很长的商品名称我是很长的商品名称"
68
68
  );
69
69
  printer.setPrintModes(false, false, false);
70
70
  dividing(printer);
@@ -46,10 +46,12 @@ var import_config = require("./config");
46
46
  var import_typeUtils = require("../typeUtils");
47
47
  var isClient = typeof window != "undefined" && window.document;
48
48
  var isDefaultInit = isClient && ((0, import_typeUtils.isUndefined)(window == null ? void 0 : window.__isDefaultInit) ? true : window == null ? void 0 : window.__isDefaultInit);
49
+ var isInitialized = false;
49
50
  var firebaseApp = {};
50
51
  var auth = {};
51
52
  var database = {};
52
53
  var initFirebase = (config) => {
54
+ isInitialized = true;
53
55
  firebaseApp = (0, import_app.initializeApp)(config || import_config.firebaseConfig);
54
56
  auth = (0, import_auth.getAuth)(firebaseApp);
55
57
  database = (0, import_database.getDatabase)(firebaseApp);
@@ -99,6 +101,9 @@ var signOutUser = async () => {
99
101
  };
100
102
  var readData = async (path) => {
101
103
  try {
104
+ if (!isInitialized) {
105
+ initFirebase();
106
+ }
102
107
  const dataSnapshot = await (0, import_database.get)((0, import_database.ref)(database, getPath(path)));
103
108
  return dataSnapshot.val();
104
109
  } catch (error) {
@@ -108,6 +113,9 @@ var readData = async (path) => {
108
113
  };
109
114
  var writeData = async (path, data) => {
110
115
  try {
116
+ if (!isInitialized) {
117
+ initFirebase();
118
+ }
111
119
  return (0, import_database.set)((0, import_database.ref)(database, getPath(path)), data);
112
120
  } catch (error) {
113
121
  console.error("Error writing data:", error);
@@ -115,11 +123,25 @@ var writeData = async (path, data) => {
115
123
  }
116
124
  };
117
125
  var onDataChange = (path, callback) => {
126
+ try {
127
+ if (!isInitialized) {
128
+ initFirebase();
129
+ }
130
+ } catch (error) {
131
+ console.error("init error", error);
132
+ }
118
133
  const databaseRef = (0, import_database.ref)(database, getPath(path));
119
134
  const listener = (0, import_database.onValue)(databaseRef, callback);
120
135
  return listener;
121
136
  };
122
137
  var onDataChanged = (path, callback) => {
138
+ try {
139
+ if (!isInitialized) {
140
+ initFirebase();
141
+ }
142
+ } catch (error) {
143
+ console.error("init error", error);
144
+ }
123
145
  const databaseRef = (0, import_database.ref)(database, getPath(path));
124
146
  const listener = (0, import_database.onChildChanged)(databaseRef, callback);
125
147
  return listener;
package/lib/image.js CHANGED
@@ -48,8 +48,7 @@ var getImageSize = (url) => {
48
48
  success: false,
49
49
  originRatio: 1
50
50
  };
51
- if (typeof url !== "string")
52
- return size;
51
+ if (typeof url !== "string") return size;
53
52
  try {
54
53
  let arr = url.split("__");
55
54
  if (arr[1]) {
package/lib/index.js CHANGED
@@ -2,6 +2,10 @@ var __defProp = Object.defineProperty;
2
2
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
4
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
5
9
  var __copyProps = (to, from, except, desc) => {
6
10
  if (from && typeof from === "object" || typeof from === "function") {
7
11
  for (let key of __getOwnPropNames(from))
@@ -15,6 +19,10 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
15
19
 
16
20
  // src/index.ts
17
21
  var src_exports = {};
22
+ __export(src_exports, {
23
+ getPisellUtilsConfig: () => getPisellUtilsConfig,
24
+ setPisellUtilsConfig: () => setPisellUtilsConfig
25
+ });
18
26
  module.exports = __toCommonJS(src_exports);
19
27
  __reExport(src_exports, require("./otherUtils"), module.exports);
20
28
  __reExport(src_exports, require("./typeUtils"), module.exports);
@@ -29,8 +37,22 @@ __reExport(src_exports, require("./jsBridge"), module.exports);
29
37
  __reExport(src_exports, require("./image"), module.exports);
30
38
  __reExport(src_exports, require("./locales"), module.exports);
31
39
  __reExport(src_exports, require("./arrayUtils"), module.exports);
40
+ __reExport(src_exports, require("./walletValidity"), module.exports);
41
+ var setPisellUtilsConfig = (config) => {
42
+ globalThis.pisellUtilsConfig = {
43
+ ...globalThis.pisellUtilsConfig || {},
44
+ ...config || {}
45
+ };
46
+ console.log("PisellUtilsConfig_set>>>>", config, globalThis);
47
+ };
48
+ var getPisellUtilsConfig = () => {
49
+ console.log("PisellUtilsConfig_get>>>>", globalThis);
50
+ return globalThis.pisellUtilsConfig || {};
51
+ };
32
52
  // Annotate the CommonJS export names for ESM import in node:
33
53
  0 && (module.exports = {
54
+ getPisellUtilsConfig,
55
+ setPisellUtilsConfig,
34
56
  ...require("./otherUtils"),
35
57
  ...require("./typeUtils"),
36
58
  ...require("./document"),
@@ -43,5 +65,6 @@ __reExport(src_exports, require("./arrayUtils"), module.exports);
43
65
  ...require("./jsBridge"),
44
66
  ...require("./image"),
45
67
  ...require("./locales"),
46
- ...require("./arrayUtils")
68
+ ...require("./arrayUtils"),
69
+ ...require("./walletValidity")
47
70
  });
@@ -29,11 +29,13 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
29
29
  // src/jsBridge/index.ts
30
30
  var jsBridge_exports = {};
31
31
  __export(jsBridge_exports, {
32
+ dataManager: () => dataManager,
33
+ webPayment: () => webPayment,
32
34
  webPrint: () => webPrint
33
35
  });
34
36
  module.exports = __toCommonJS(jsBridge_exports);
35
37
  var import_regDeviceApi = __toESM(require("./regDeviceApi"));
36
- function webPrint(params, callback) {
38
+ function webPrint(params, callback, onError) {
37
39
  (0, import_regDeviceApi.default)().then((jsBridge) => {
38
40
  jsBridge.callDeviceApi({
39
41
  apiName: "webPrint",
@@ -42,9 +44,39 @@ function webPrint(params, callback) {
42
44
  callback && callback(...arg);
43
45
  }
44
46
  });
47
+ }).catch((err) => {
48
+ onError == null ? void 0 : onError(err);
49
+ console.error("webPrint", err);
50
+ });
51
+ }
52
+ function dataManager(params, callback, onError) {
53
+ (0, import_regDeviceApi.default)().then((jsBridge) => {
54
+ jsBridge.callDeviceApi({
55
+ apiName: "dataManager",
56
+ params,
57
+ callback: (...arg) => {
58
+ callback && callback(...arg);
59
+ }
60
+ });
61
+ }).catch(onError);
62
+ }
63
+ function webPayment(params, callback, onError) {
64
+ (0, import_regDeviceApi.default)().then((jsBridge) => {
65
+ jsBridge.callDeviceApi({
66
+ apiName: "webPayment",
67
+ params,
68
+ callback: (...arg) => {
69
+ callback && callback(...arg);
70
+ }
71
+ });
72
+ }).catch((err) => {
73
+ onError == null ? void 0 : onError(err);
74
+ console.error("webPayment", err);
45
75
  });
46
76
  }
47
77
  // Annotate the CommonJS export names for ESM import in node:
48
78
  0 && (module.exports = {
79
+ dataManager,
80
+ webPayment,
49
81
  webPrint
50
82
  });
@@ -60,8 +60,7 @@ function regAndroidJsBridge(extraInit) {
60
60
  (event) => {
61
61
  const { bridge } = event;
62
62
  window._jsBridge = bridge;
63
- if (!bridge)
64
- return;
63
+ if (!bridge) return;
65
64
  bridge.init((message, responseCallback) => {
66
65
  if (responseCallback) {
67
66
  responseCallback("init responseCallback");
@@ -86,27 +85,20 @@ function getComposedBridge(deviceType) {
86
85
  } catch (error) {
87
86
  console.log(`error ${apiName}`, error);
88
87
  }
89
- if (result.code || result.code === 0) {
90
- result.code = `${result.code}`;
91
- }
92
88
  inCb(result, ...args);
93
89
  };
94
90
  if (deviceType === "iphone") {
95
91
  iosBridge.callHandler(apiName, params, callback, (e) => {
96
- console.log(e, "--- \u8C03\u7528ios api\u62A5\u9519\uFF1A", apiName);
92
+ console.log(e, "--- 调用ios api报错:", apiName);
97
93
  if (onError) {
98
94
  onError(e);
99
95
  }
100
96
  });
101
97
  } else if (deviceType === "android") {
102
- androidBridge.callHandler(apiName, params, callback, (e) => {
103
- console.log(e, "--- \u8C03\u7528android api\u62A5\u9519\uFF1A", apiName);
104
- if (onError) {
105
- onError(e);
106
- }
107
- });
98
+ const res = androidBridge.callHandler(apiName, JSON.stringify(params));
99
+ callback(res);
108
100
  } else {
109
- console.log("--- \u6CA1\u83B7\u53D6\u5230js bridge ---");
101
+ console.log("--- 没获取到js bridge ---");
110
102
  }
111
103
  },
112
104
  // 被设备调用的方法
@@ -0,0 +1,17 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __copyProps = (to, from, except, desc) => {
6
+ if (from && typeof from === "object" || typeof from === "function") {
7
+ for (let key of __getOwnPropNames(from))
8
+ if (!__hasOwnProp.call(to, key) && key !== except)
9
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
+ }
11
+ return to;
12
+ };
13
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
14
+
15
+ // src/jsBridge/types.ts
16
+ var types_exports = {};
17
+ module.exports = __toCommonJS(types_exports);
package/lib/locales.js CHANGED
@@ -50,7 +50,6 @@ var init = (_localeMaps, _locale) => {
50
50
  }
51
51
  localeMaps = allLocales;
52
52
  localeMap = localeMaps[locale];
53
- console.log("\u591A\u8BED\u8A00\u6CE8\u5165\u6210\u529F, \u5F53\u524D\u8BED\u8A00\u4E3A:" + locale);
54
53
  };
55
54
  var getText = (id) => {
56
55
  return localeMap[id] || id;
package/lib/log.js CHANGED
@@ -22,6 +22,7 @@ __export(log_exports, {
22
22
  sendWarningLog: () => sendWarningLog
23
23
  });
24
24
  module.exports = __toCommonJS(log_exports);
25
+ var import_index = require("./index");
25
26
  var import_constants = require("./constants");
26
27
  var createFeishuMessageContent = (contentArr) => {
27
28
  return JSON.stringify(
@@ -35,7 +36,15 @@ var createFeishuMessageContent = (contentArr) => {
35
36
  };
36
37
  var sendWarningLog = async ({ title, content }) => {
37
38
  const contentStr = createFeishuMessageContent(content);
38
- const response = await fetch(import_constants.webHookApi.warning_log, {
39
+ let apiUrl = "";
40
+ const config = (0, import_index.getPisellUtilsConfig)();
41
+ console.log("PISELL_UTILS_CONFIG>>>>", config);
42
+ if ((config == null ? void 0 : config.env) === "dev" || (config == null ? void 0 : config.env) === "pre" || (config == null ? void 0 : config.env) === "release") {
43
+ apiUrl = import_constants.webHookApi.warning_log.test;
44
+ } else {
45
+ apiUrl = import_constants.webHookApi.warning_log.prod;
46
+ }
47
+ const response = await fetch(apiUrl, {
39
48
  headers: {
40
49
  "Content-Type": "application/json"
41
50
  },
package/lib/miniRedux.js CHANGED
@@ -61,6 +61,10 @@ var miniRedux = ({
61
61
  dispatch({ type, payload });
62
62
  }
63
63
  }, []);
64
+ const contextValue = (0, import_react.useMemo)(() => ({
65
+ [namespace]: providerState,
66
+ dispatch: _dispatch
67
+ }), [providerState, _dispatch]);
64
68
  let _props = {
65
69
  ...props,
66
70
  [namespace]: providerState,
@@ -71,13 +75,7 @@ var miniRedux = ({
71
75
  _ref = _props.forwardedRef;
72
76
  delete _props.forwardedRef;
73
77
  }
74
- return /* @__PURE__ */ import_react.default.createElement(
75
- Context.Provider,
76
- {
77
- value: { [namespace]: providerState, dispatch: _dispatch }
78
- },
79
- /* @__PURE__ */ import_react.default.createElement(ComponentUi, { ..._props, ref })
80
- );
78
+ return /* @__PURE__ */ import_react.default.createElement(Context.Provider, { value: contextValue }, /* @__PURE__ */ import_react.default.createElement(ComponentUi, { ..._props, ref }));
81
79
  });
82
80
  return Components;
83
81
  };