@pisell/utils 3.0.5 → 3.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (158) hide show
  1. package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js +27 -0
  2. package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/defineProperty.js +12 -0
  3. package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js +25 -0
  4. package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPrimitive.js +14 -0
  5. package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPropertyKey.js +9 -0
  6. package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/typeof.js +11 -0
  7. package/es/arrayUtils.d.ts +76 -1
  8. package/es/arrayUtils.js +103 -24
  9. package/es/common/stateHelper.d.ts +22 -0
  10. package/es/common/stateHelper.js +23 -0
  11. package/es/common/types.d.ts +31 -0
  12. package/es/componentStorage.d.ts +38 -0
  13. package/es/componentStorage.js +106 -0
  14. package/es/constants/index.js +7 -9
  15. package/es/date.d.ts +6 -3
  16. package/es/date.js +36 -53
  17. package/es/document.d.ts +6 -3
  18. package/es/document.js +43 -67
  19. package/es/escPosPrinter/EscPosPrinter.js +353 -490
  20. package/es/escPosPrinter/index.d.ts +9 -9
  21. package/es/escPosPrinter/index.js +37 -52
  22. package/es/format.d.ts +12 -11
  23. package/es/format.js +90 -112
  24. package/es/image.d.ts +13 -10
  25. package/es/image.js +48 -60
  26. package/es/index.d.ts +39 -18
  27. package/es/index.js +40 -29
  28. package/es/jsBridge/index.d.ts +14 -106
  29. package/es/jsBridge/index.js +57 -40
  30. package/es/jsBridge/regDeviceApi.js +87 -126
  31. package/es/jsBridge/types.d.ts +129 -0
  32. package/es/locales.d.ts +11 -11
  33. package/es/locales.js +79 -69
  34. package/es/log.d.ts +11 -6
  35. package/es/log.js +37 -59
  36. package/es/miniRedux.d.ts +20 -13
  37. package/es/miniRedux.js +42 -71
  38. package/es/number-input/hooks/useNumberInputState.d.ts +29 -0
  39. package/es/number-input/hooks/useNumberInputState.js +72 -0
  40. package/es/number-input/types.d.ts +96 -0
  41. package/es/number-input/utils/formatter.d.ts +56 -0
  42. package/es/number-input/utils/formatter.js +56 -0
  43. package/es/number-input/utils/validation.d.ts +32 -0
  44. package/es/number-input/utils/validation.js +52 -0
  45. package/es/otherUtils.d.ts +51 -0
  46. package/es/otherUtils.js +71 -129
  47. package/es/platform.d.ts +12 -9
  48. package/es/platform.js +61 -85
  49. package/es/select/hooks/useDebouncedSearch.d.ts +23 -0
  50. package/es/select/hooks/useDebouncedSearch.js +41 -0
  51. package/es/select/hooks/useSelectState.d.ts +19 -0
  52. package/es/select/hooks/useSelectState.js +60 -0
  53. package/es/select/index.d.ts +7 -0
  54. package/es/select/types.d.ts +256 -0
  55. package/es/select/utils/filterOptions.d.ts +23 -0
  56. package/es/select/utils/filterOptions.js +29 -0
  57. package/es/select/utils/helpers.d.ts +43 -0
  58. package/es/select/utils/helpers.js +51 -0
  59. package/es/select/utils/index.d.ts +4 -0
  60. package/es/select/utils/sortOptions.d.ts +13 -0
  61. package/es/select/utils/sortOptions.js +20 -0
  62. package/es/select/utils/tagAggregation.d.ts +25 -0
  63. package/es/select/utils/tagAggregation.js +35 -0
  64. package/es/text-input/hooks/useTextInputState.d.ts +28 -0
  65. package/es/text-input/hooks/useTextInputState.js +70 -0
  66. package/es/text-input/types.d.ts +56 -0
  67. package/es/text-input/utils/validation.d.ts +28 -0
  68. package/es/text-input/utils/validation.js +51 -0
  69. package/es/typeUtils.d.ts +11 -8
  70. package/es/typeUtils.js +61 -84
  71. package/es/walletValidity.d.ts +57 -0
  72. package/es/walletValidity.js +404 -460
  73. package/es/weighing.d.ts +65 -0
  74. package/es/weighing.js +96 -0
  75. package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js +27 -0
  76. package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/defineProperty.js +12 -0
  77. package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js +25 -0
  78. package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPrimitive.js +14 -0
  79. package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPropertyKey.js +9 -0
  80. package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/typeof.js +16 -0
  81. package/lib/_virtual/_rolldown/runtime.js +23 -0
  82. package/lib/arrayUtils.d.ts +76 -1
  83. package/lib/arrayUtils.js +102 -37
  84. package/lib/common/stateHelper.d.ts +22 -0
  85. package/lib/common/stateHelper.js +23 -0
  86. package/lib/common/types.d.ts +31 -0
  87. package/lib/componentStorage.d.ts +38 -0
  88. package/lib/componentStorage.js +114 -0
  89. package/lib/constants/index.js +7 -36
  90. package/lib/date.d.ts +6 -3
  91. package/lib/date.js +43 -65
  92. package/lib/document.d.ts +6 -3
  93. package/lib/document.js +46 -62
  94. package/lib/escPosPrinter/EscPosPrinter.js +327 -403
  95. package/lib/escPosPrinter/index.d.ts +9 -9
  96. package/lib/escPosPrinter/index.js +38 -84
  97. package/lib/format.d.ts +12 -11
  98. package/lib/format.js +91 -93
  99. package/lib/image.d.ts +13 -10
  100. package/lib/image.js +48 -74
  101. package/lib/index.d.ts +39 -18
  102. package/lib/index.js +137 -68
  103. package/lib/jsBridge/index.d.ts +14 -106
  104. package/lib/jsBridge/index.js +60 -60
  105. package/lib/jsBridge/regDeviceApi.js +86 -133
  106. package/lib/jsBridge/types.d.ts +129 -0
  107. package/lib/locales.d.ts +11 -11
  108. package/lib/locales.js +79 -63
  109. package/lib/log.d.ts +11 -6
  110. package/lib/log.js +37 -61
  111. package/lib/miniRedux.d.ts +20 -13
  112. package/lib/miniRedux.js +43 -91
  113. package/lib/number-input/hooks/useNumberInputState.d.ts +29 -0
  114. package/lib/number-input/hooks/useNumberInputState.js +73 -0
  115. package/lib/number-input/types.d.ts +96 -0
  116. package/lib/number-input/utils/formatter.d.ts +56 -0
  117. package/lib/number-input/utils/formatter.js +58 -0
  118. package/lib/number-input/utils/validation.d.ts +32 -0
  119. package/lib/number-input/utils/validation.js +52 -0
  120. package/lib/otherUtils.d.ts +51 -0
  121. package/lib/otherUtils.js +86 -98
  122. package/lib/platform.d.ts +12 -9
  123. package/lib/platform.js +68 -123
  124. package/lib/select/hooks/useDebouncedSearch.d.ts +23 -0
  125. package/lib/select/hooks/useDebouncedSearch.js +42 -0
  126. package/lib/select/hooks/useSelectState.d.ts +19 -0
  127. package/lib/select/hooks/useSelectState.js +62 -0
  128. package/lib/select/index.d.ts +7 -0
  129. package/lib/select/types.d.ts +256 -0
  130. package/lib/select/utils/filterOptions.d.ts +23 -0
  131. package/lib/select/utils/filterOptions.js +30 -0
  132. package/lib/select/utils/helpers.d.ts +43 -0
  133. package/lib/select/utils/helpers.js +55 -0
  134. package/lib/select/utils/index.d.ts +4 -0
  135. package/lib/select/utils/sortOptions.d.ts +13 -0
  136. package/lib/select/utils/sortOptions.js +20 -0
  137. package/lib/select/utils/tagAggregation.d.ts +25 -0
  138. package/lib/select/utils/tagAggregation.js +35 -0
  139. package/lib/text-input/hooks/useTextInputState.d.ts +28 -0
  140. package/lib/text-input/hooks/useTextInputState.js +71 -0
  141. package/lib/text-input/types.d.ts +56 -0
  142. package/lib/text-input/utils/validation.d.ts +28 -0
  143. package/lib/text-input/utils/validation.js +51 -0
  144. package/lib/typeUtils.d.ts +11 -8
  145. package/lib/typeUtils.js +68 -73
  146. package/lib/walletValidity.d.ts +57 -0
  147. package/lib/walletValidity.js +420 -323
  148. package/lib/weighing.d.ts +65 -0
  149. package/lib/weighing.js +114 -0
  150. package/package.json +1 -1
  151. package/es/firebase/config/index.d.ts +0 -13
  152. package/es/firebase/config/index.js +0 -54
  153. package/es/firebase/index.d.ts +0 -28
  154. package/es/firebase/index.js +0 -232
  155. package/lib/firebase/config/index.d.ts +0 -13
  156. package/lib/firebase/config/index.js +0 -79
  157. package/lib/firebase/index.d.ts +0 -28
  158. package/lib/firebase/index.js +0 -180
@@ -0,0 +1,65 @@
1
+ //#region src/weighing.d.ts
2
+ /** 商品配置与 NativeScale 使用的重量单位。 */
3
+ type WeightUnitName = 'KILOGRAMS' | 'GRAMS' | 'POUNDS' | 'OUNCES';
4
+ /** 订单快照与 UI 使用的标准单位符号。 */
5
+ type WeightUnitSymbol = 'kg' | 'g' | 'lb' | 'oz';
6
+ type WeightUnit = WeightUnitName | WeightUnitSymbol;
7
+ /**
8
+ * Pisell 的标准重量单位。目录单价、缺省秤单位和缺省展示均以它为准。
9
+ * 后续标准单位变化时,应优先只修改此处。
10
+ */
11
+ declare const STANDARD_WEIGHT_UNIT: WeightUnitName;
12
+ declare const WEIGHT_PRECISION = 3;
13
+ declare const UNIT_PRICE_PRECISION = 2;
14
+ declare const MAX_RETAIL_SCALE_WEIGHT_KG = 1000;
15
+ declare const WEIGHT_UNIT_SYMBOLS: Record<WeightUnitName, WeightUnitSymbol>;
16
+ declare const WEIGHT_UNIT_NAMES: Record<WeightUnitSymbol, WeightUnitName>;
17
+ /** 单位对应的克数,作为不依赖 NativeScale 的目录价格换算基准。 */
18
+ declare const WEIGHT_UNIT_GRAMS: Record<WeightUnit, number>;
19
+ declare const STANDARD_WEIGHT_UNIT_SYMBOL: WeightUnitSymbol;
20
+ declare const normalizeWeightUnit: (unit?: string | null, fallback?: WeightUnitName) => WeightUnitName;
21
+ declare const getWeightUnitSymbol: (unit?: string | null) => string;
22
+ declare const getWeightUnitGrams: (unit?: string | null) => number | undefined;
23
+ /**
24
+ * 将“每 sourceUnitValue 个 sourceUnit 的价格”换算到每 1 个目标单位的倍率。
25
+ * 这里只处理目录单价的单位关系;实际秤读数计价仍应使用 NativeScale。
26
+ */
27
+ declare const getWeightUnitPriceConversionFactor: (params: {
28
+ sourceUnit?: string | null;
29
+ sourceUnitValue?: string | number | null;
30
+ targetUnit?: string | null;
31
+ }) => number | undefined;
32
+ declare const isSupportedWeightUnit: (unit?: unknown) => unit is WeightUnit;
33
+ declare const formatWeightValue: (value: unknown, precision?: number) => string;
34
+ declare const formatUnitPriceValue: (value: unknown, precision?: number) => string;
35
+ type ScaleReadingStatus = 'stable' | 'unstable' | 'overload' | 'negative' | string | null;
36
+ declare const INVALID_SCALE_READING_STATUSES: readonly ["overload", "negative"];
37
+ declare const isInvalidScaleReadingStatus: (status?: ScaleReadingStatus) => boolean;
38
+ declare const getUsableScaleWeight: (status: ScaleReadingStatus | undefined, weight: number) => number;
39
+ interface WeighingSnapshot {
40
+ open_sold_weight?: number | string | boolean;
41
+ mode?: 'auto' | 'manual' | string;
42
+ weight_source?: 'auto' | 'manual' | string;
43
+ weight?: string | number;
44
+ tare?: {
45
+ id?: string;
46
+ label?: string;
47
+ value?: string | number;
48
+ unit?: WeightUnit | string;
49
+ };
50
+ tare_name?: string;
51
+ tare_weight?: string | number;
52
+ net_weight?: string | number;
53
+ unit_price?: string | number;
54
+ unit?: WeightUnit | string;
55
+ unit_weight?: string | number;
56
+ unit_data_snapshot?: unknown;
57
+ scalePriceProduct?: unknown;
58
+ total_amount?: string | number;
59
+ }
60
+ /**
61
+ * 解析订单行称重快照:product_sku 是权威源,_extend.weighing 仅用于旧流程兼容。
62
+ */
63
+ declare const resolveWeighingSnapshot: (dataSource?: Record<string, any> | null) => WeighingSnapshot | undefined;
64
+ //#endregion
65
+ export { INVALID_SCALE_READING_STATUSES, MAX_RETAIL_SCALE_WEIGHT_KG, STANDARD_WEIGHT_UNIT, STANDARD_WEIGHT_UNIT_SYMBOL, ScaleReadingStatus, UNIT_PRICE_PRECISION, WEIGHT_PRECISION, WEIGHT_UNIT_GRAMS, WEIGHT_UNIT_NAMES, WEIGHT_UNIT_SYMBOLS, WeighingSnapshot, WeightUnit, WeightUnitName, WeightUnitSymbol, formatUnitPriceValue, formatWeightValue, getUsableScaleWeight, getWeightUnitGrams, getWeightUnitPriceConversionFactor, getWeightUnitSymbol, isInvalidScaleReadingStatus, isSupportedWeightUnit, normalizeWeightUnit, resolveWeighingSnapshot };
@@ -0,0 +1,114 @@
1
+ //#region src/weighing.ts
2
+ /**
3
+ * Pisell 的标准重量单位。目录单价、缺省秤单位和缺省展示均以它为准。
4
+ * 后续标准单位变化时,应优先只修改此处。
5
+ */
6
+ const STANDARD_WEIGHT_UNIT = "KILOGRAMS";
7
+ const WEIGHT_PRECISION = 3;
8
+ const UNIT_PRICE_PRECISION = 2;
9
+ const MAX_RETAIL_SCALE_WEIGHT_KG = 1e3;
10
+ const WEIGHT_UNIT_SYMBOLS = {
11
+ KILOGRAMS: "kg",
12
+ GRAMS: "g",
13
+ POUNDS: "lb",
14
+ OUNCES: "oz"
15
+ };
16
+ const WEIGHT_UNIT_NAMES = {
17
+ kg: "KILOGRAMS",
18
+ g: "GRAMS",
19
+ lb: "POUNDS",
20
+ oz: "OUNCES"
21
+ };
22
+ /** 单位对应的克数,作为不依赖 NativeScale 的目录价格换算基准。 */
23
+ const WEIGHT_UNIT_GRAMS = {
24
+ KILOGRAMS: 1e3,
25
+ GRAMS: 1,
26
+ POUNDS: 453.59237,
27
+ OUNCES: 28.349523125,
28
+ kg: 1e3,
29
+ g: 1,
30
+ lb: 453.59237,
31
+ oz: 28.349523125
32
+ };
33
+ const STANDARD_WEIGHT_UNIT_SYMBOL = WEIGHT_UNIT_SYMBOLS[STANDARD_WEIGHT_UNIT];
34
+ const normalizeWeightUnit = (unit, fallback = STANDARD_WEIGHT_UNIT) => {
35
+ if (unit && unit in WEIGHT_UNIT_SYMBOLS) return unit;
36
+ if (unit && unit in WEIGHT_UNIT_NAMES) return WEIGHT_UNIT_NAMES[unit];
37
+ return fallback;
38
+ };
39
+ const getWeightUnitSymbol = (unit) => {
40
+ if (unit && unit in WEIGHT_UNIT_SYMBOLS) return WEIGHT_UNIT_SYMBOLS[unit];
41
+ if (unit && unit in WEIGHT_UNIT_NAMES) return unit;
42
+ return unit || STANDARD_WEIGHT_UNIT_SYMBOL;
43
+ };
44
+ const getWeightUnitGrams = (unit) => unit ? WEIGHT_UNIT_GRAMS[unit] : WEIGHT_UNIT_GRAMS[STANDARD_WEIGHT_UNIT];
45
+ /**
46
+ * 将“每 sourceUnitValue 个 sourceUnit 的价格”换算到每 1 个目标单位的倍率。
47
+ * 这里只处理目录单价的单位关系;实际秤读数计价仍应使用 NativeScale。
48
+ */
49
+ const getWeightUnitPriceConversionFactor = (params) => {
50
+ var _params$sourceUnitVal;
51
+ const sourceGrams = getWeightUnitGrams(params.sourceUnit || "KILOGRAMS");
52
+ const targetGrams = getWeightUnitGrams(params.targetUnit || "KILOGRAMS");
53
+ const sourceUnitValue = Number((_params$sourceUnitVal = params.sourceUnitValue) !== null && _params$sourceUnitVal !== void 0 ? _params$sourceUnitVal : 1);
54
+ if (!sourceGrams || !targetGrams || !Number.isFinite(sourceUnitValue) || sourceUnitValue <= 0) return;
55
+ return targetGrams / (sourceGrams * sourceUnitValue);
56
+ };
57
+ const isSupportedWeightUnit = (unit) => typeof unit === "string" && unit in WEIGHT_UNIT_GRAMS;
58
+ const formatWeightValue = (value, precision = 3) => {
59
+ const parsedValue = Number(value);
60
+ return (Number.isFinite(parsedValue) ? parsedValue : 0).toFixed(precision);
61
+ };
62
+ const formatUnitPriceValue = (value, precision = 2) => {
63
+ const parsedValue = Number(value);
64
+ return (Number.isFinite(parsedValue) ? parsedValue : 0).toFixed(precision);
65
+ };
66
+ const INVALID_SCALE_READING_STATUSES = ["overload", "negative"];
67
+ const isInvalidScaleReadingStatus = (status) => INVALID_SCALE_READING_STATUSES.includes(status);
68
+ const getUsableScaleWeight = (status, weight) => isInvalidScaleReadingStatus(status) ? 0 : weight;
69
+ const hasDisplayWeight = (value) => Boolean(value && (Number(value.weight) > 0 || Number(value.net_weight) > 0));
70
+ const resolveProductSkuSnapshot = (value) => {
71
+ const snapshot = value;
72
+ return Number(snapshot === null || snapshot === void 0 ? void 0 : snapshot.open_sold_weight) === 1 && hasDisplayWeight(snapshot) ? snapshot : void 0;
73
+ };
74
+ /**
75
+ * 解析订单行称重快照:product_sku 是权威源,_extend.weighing 仅用于旧流程兼容。
76
+ */
77
+ const resolveWeighingSnapshot = (dataSource) => {
78
+ var _dataSource$_origin, _dataSource$metadata, _dataSource$_origin2, _dataSource$_extend, _dataSource$metadata2;
79
+ if (!dataSource) return void 0;
80
+ const productSkuCandidates = [
81
+ dataSource.product_sku,
82
+ (_dataSource$_origin = dataSource._origin) === null || _dataSource$_origin === void 0 ? void 0 : _dataSource$_origin.product_sku,
83
+ (_dataSource$metadata = dataSource.metadata) === null || _dataSource$metadata === void 0 || (_dataSource$metadata = _dataSource$metadata.origin) === null || _dataSource$metadata === void 0 ? void 0 : _dataSource$metadata.product_sku
84
+ ];
85
+ for (const candidate of productSkuCandidates) {
86
+ const snapshot = resolveProductSkuSnapshot(candidate);
87
+ if (snapshot) return snapshot;
88
+ }
89
+ return [
90
+ (_dataSource$_origin2 = dataSource._origin) === null || _dataSource$_origin2 === void 0 || (_dataSource$_origin2 = _dataSource$_origin2._extend) === null || _dataSource$_origin2 === void 0 ? void 0 : _dataSource$_origin2.weighing,
91
+ (_dataSource$_extend = dataSource._extend) === null || _dataSource$_extend === void 0 ? void 0 : _dataSource$_extend.weighing,
92
+ (_dataSource$metadata2 = dataSource.metadata) === null || _dataSource$metadata2 === void 0 || (_dataSource$metadata2 = _dataSource$metadata2.origin) === null || _dataSource$metadata2 === void 0 || (_dataSource$metadata2 = _dataSource$metadata2._extend) === null || _dataSource$metadata2 === void 0 ? void 0 : _dataSource$metadata2.weighing
93
+ ].find((candidate) => hasDisplayWeight(candidate));
94
+ };
95
+ //#endregion
96
+ exports.INVALID_SCALE_READING_STATUSES = INVALID_SCALE_READING_STATUSES;
97
+ exports.MAX_RETAIL_SCALE_WEIGHT_KG = MAX_RETAIL_SCALE_WEIGHT_KG;
98
+ exports.STANDARD_WEIGHT_UNIT = STANDARD_WEIGHT_UNIT;
99
+ exports.STANDARD_WEIGHT_UNIT_SYMBOL = STANDARD_WEIGHT_UNIT_SYMBOL;
100
+ exports.UNIT_PRICE_PRECISION = UNIT_PRICE_PRECISION;
101
+ exports.WEIGHT_PRECISION = WEIGHT_PRECISION;
102
+ exports.WEIGHT_UNIT_GRAMS = WEIGHT_UNIT_GRAMS;
103
+ exports.WEIGHT_UNIT_NAMES = WEIGHT_UNIT_NAMES;
104
+ exports.WEIGHT_UNIT_SYMBOLS = WEIGHT_UNIT_SYMBOLS;
105
+ exports.formatUnitPriceValue = formatUnitPriceValue;
106
+ exports.formatWeightValue = formatWeightValue;
107
+ exports.getUsableScaleWeight = getUsableScaleWeight;
108
+ exports.getWeightUnitGrams = getWeightUnitGrams;
109
+ exports.getWeightUnitPriceConversionFactor = getWeightUnitPriceConversionFactor;
110
+ exports.getWeightUnitSymbol = getWeightUnitSymbol;
111
+ exports.isInvalidScaleReadingStatus = isInvalidScaleReadingStatus;
112
+ exports.isSupportedWeightUnit = isSupportedWeightUnit;
113
+ exports.normalizeWeightUnit = normalizeWeightUnit;
114
+ exports.resolveWeighingSnapshot = resolveWeighingSnapshot;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pisell/utils",
3
- "version": "3.0.5",
3
+ "version": "3.0.6",
4
4
  "sideEffects": false,
5
5
  "main": "./lib/index.js",
6
6
  "module": "./es/index.js",
@@ -1,13 +0,0 @@
1
- declare type InjectedConfigType = {
2
- apiKey: string;
3
- authDomain: string;
4
- projectId: string;
5
- storageBucket: string;
6
- messagingSenderId: string;
7
- appId: string;
8
- databaseURL: string;
9
- };
10
- export declare const injectConfig: (context: InjectedConfigType) => void;
11
- export declare const firebaseConfig: any;
12
- declare const _default: any;
13
- export default _default;
@@ -1,54 +0,0 @@
1
- // @ts-ignore
2
- var REACT_APP_API_ENV = process.env.REACT_APP_API_ENV;
3
- var _firebaseConfig = {
4
- 'release': {
5
- apiKey: "AIzaSyBhWzh3z3eGW08oeUH6jKNP_H3msyuBEQc",
6
- authDomain: "pisell-dev-d6421.firebaseapp.com",
7
- databaseURL: "https://pisell-dev-d6421-default-rtdb.asia-southeast1.firebasedatabase.app",
8
- projectId: "pisell-dev-d6421",
9
- storageBucket: "pisell-dev-d6421.appspot.com",
10
- messagingSenderId: "426955619429",
11
- appId: "1:426955619429:web:17b5fc88934bebb6dc1a8c",
12
- measurementId: "G-YJ5G113V4L"
13
- },
14
- 'dev': {
15
- apiKey: "AIzaSyBhWzh3z3eGW08oeUH6jKNP_H3msyuBEQc",
16
- authDomain: "pisell-dev-d6421.firebaseapp.com",
17
- databaseURL: "https://pisell-dev-d6421-default-rtdb.asia-southeast1.firebasedatabase.app",
18
- projectId: "pisell-dev-d6421",
19
- storageBucket: "pisell-dev-d6421.appspot.com",
20
- messagingSenderId: "426955619429",
21
- appId: "1:426955619429:web:17b5fc88934bebb6dc1a8c",
22
- measurementId: "G-YJ5G113V4L"
23
- },
24
- 'pre': {
25
- apiKey: "AIzaSyBhWzh3z3eGW08oeUH6jKNP_H3msyuBEQc",
26
- authDomain: "pisell-dev-d6421.firebaseapp.com",
27
- databaseURL: "https://pisell-dev-d6421-default-rtdb.asia-southeast1.firebasedatabase.app",
28
- projectId: "pisell-dev-d6421",
29
- storageBucket: "pisell-dev-d6421.appspot.com",
30
- messagingSenderId: "426955619429",
31
- appId: "1:426955619429:web:17b5fc88934bebb6dc1a8c",
32
- measurementId: "G-YJ5G113V4L"
33
- },
34
- 'prod': {
35
- apiKey: "AIzaSyBhWzh3z3eGW08oeUH6jKNP_H3msyuBEQc",
36
- authDomain: "pisell-dev-d6421.firebaseapp.com",
37
- databaseURL: "https://pisell-dev-product-test.asia-southeast1.firebasedatabase.app",
38
- projectId: "pisell-dev-d6421",
39
- storageBucket: "pisell-dev-d6421.appspot.com",
40
- messagingSenderId: "426955619429",
41
- appId: "1:426955619429:web:17b5fc88934bebb6dc1a8c",
42
- measurementId: "G-YJ5G113V4L"
43
- }
44
- };
45
- export var injectConfig = function injectConfig(context) {
46
- // @ts-ignore
47
- _firebaseConfig[REACT_APP_API_ENV] = context;
48
- };
49
-
50
- // @ts-ignore
51
- export var firebaseConfig = _firebaseConfig[REACT_APP_API_ENV];
52
-
53
- // @ts-ignore
54
- export default _firebaseConfig[REACT_APP_API_ENV];
@@ -1,28 +0,0 @@
1
- import { FirebaseApp } from 'firebase/app';
2
- import { Auth } from 'firebase/auth';
3
- import { ref, Database, goOnline, goOffline } from 'firebase/database';
4
- declare let firebaseApp: FirebaseApp;
5
- declare let auth: Auth;
6
- declare let database: Database;
7
- export declare const initFirebase: (config?: any) => void;
8
- export { database, firebaseApp, auth, ref, goOnline, goOffline };
9
- export declare const getPath: (path: string) => string;
10
- export declare const setAuthStateChangeCallback: (callback: (user: any) => void) => void;
11
- export declare const signUp: (email: string, password: string) => Promise<import("firebase/auth").User>;
12
- export declare const signInUser: (email: string, password: string) => Promise<import("firebase/auth").User>;
13
- export declare const signOutUser: () => Promise<void>;
14
- export declare const readData: (path: string) => Promise<any>;
15
- export declare const writeData: (path: string, data: any) => Promise<void>;
16
- export declare const onDataChange: (path: string, callback: (snapshot: any) => void) => import("firebase/database").Unsubscribe;
17
- export declare const onDataChanged: (path: string, callback: (snapshot: any) => void) => import("firebase/database").Unsubscribe;
18
- export declare const removeDataListener: (listener: any) => void;
19
- declare const _default: {
20
- signInUser: (email: string, password: string) => Promise<import("firebase/auth").User>;
21
- signOutUser: () => Promise<void>;
22
- readData: (path: string) => Promise<any>;
23
- writeData: (path: string, data: any) => Promise<void>;
24
- onDataChange: (path: string, callback: (snapshot: any) => void) => import("firebase/database").Unsubscribe;
25
- removeDataListener: (listener: any) => void;
26
- onDataChanged: (path: string, callback: (snapshot: any) => void) => import("firebase/database").Unsubscribe;
27
- };
28
- export default _default;
@@ -1,232 +0,0 @@
1
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
- var _window, _window2;
3
- function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
4
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
5
- function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
6
- import { initializeApp } from 'firebase/app';
7
- import { getAuth, createUserWithEmailAndPassword, signInWithEmailAndPassword, signOut } from 'firebase/auth';
8
- import { getDatabase, ref, set, get, off, onValue, onChildChanged, goOnline, goOffline } from 'firebase/database';
9
- import { firebaseConfig } from "./config";
10
- import { isUndefined } from "../typeUtils";
11
- var isClient = typeof window != "undefined" && window.document;
12
-
13
- // 是否默认初始化firebase erp_admin默认不初始化
14
- var isDefaultInit = isClient && (isUndefined((_window = window) === null || _window === void 0 ? void 0 : _window.__isDefaultInit) ? true : (_window2 = window) === null || _window2 === void 0 ? void 0 : _window2.__isDefaultInit);
15
- var isInitialized = false;
16
- var firebaseApp = {};
17
- var auth = {};
18
- var database = {};
19
- export var initFirebase = function initFirebase(config) {
20
- isInitialized = true;
21
- // 初始化 Firebase
22
- firebaseApp = initializeApp(config || firebaseConfig);
23
- // 获取 Firebase Auth 实例
24
- auth = getAuth(firebaseApp);
25
- // 获取 Firebase Database 实例
26
- database = getDatabase(firebaseApp);
27
- };
28
-
29
- //@ts-ignore 如果在客户端并且不是微信小程序的环境下初始化
30
- if (isClient && window.__wxjs_environment !== "miniprogram" && isDefaultInit) {
31
- initFirebase();
32
- }
33
-
34
- // 导出 Firebase 配置,以便在需要时进行访问
35
- export { database, firebaseApp, auth, ref, goOnline, goOffline };
36
-
37
- // 配置化 Firebase 路径
38
- export var getPath = function getPath(path) {
39
- return path;
40
- };
41
-
42
- // 设置 Firebase 用户身份认证状态变更回调
43
- export var setAuthStateChangeCallback = function setAuthStateChangeCallback(callback) {
44
- auth.onAuthStateChanged(callback);
45
- };
46
-
47
- // 用户注册
48
- export var signUp = /*#__PURE__*/function () {
49
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(email, password) {
50
- var userCredential;
51
- return _regeneratorRuntime().wrap(function _callee$(_context) {
52
- while (1) switch (_context.prev = _context.next) {
53
- case 0:
54
- _context.prev = 0;
55
- _context.next = 3;
56
- return createUserWithEmailAndPassword(auth, email, password);
57
- case 3:
58
- userCredential = _context.sent;
59
- return _context.abrupt("return", userCredential.user);
60
- case 7:
61
- _context.prev = 7;
62
- _context.t0 = _context["catch"](0);
63
- console.error("Error signing up:", _context.t0);
64
- throw _context.t0;
65
- case 11:
66
- case "end":
67
- return _context.stop();
68
- }
69
- }, _callee, null, [[0, 7]]);
70
- }));
71
- return function signUp(_x, _x2) {
72
- return _ref.apply(this, arguments);
73
- };
74
- }();
75
-
76
- // 用户登录
77
- export var signInUser = /*#__PURE__*/function () {
78
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(email, password) {
79
- var userCredential;
80
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
81
- while (1) switch (_context2.prev = _context2.next) {
82
- case 0:
83
- _context2.prev = 0;
84
- _context2.next = 3;
85
- return signInWithEmailAndPassword(auth, email, password);
86
- case 3:
87
- userCredential = _context2.sent;
88
- return _context2.abrupt("return", userCredential.user);
89
- case 7:
90
- _context2.prev = 7;
91
- _context2.t0 = _context2["catch"](0);
92
- console.error("Error signing in:", _context2.t0);
93
- throw _context2.t0;
94
- case 11:
95
- case "end":
96
- return _context2.stop();
97
- }
98
- }, _callee2, null, [[0, 7]]);
99
- }));
100
- return function signInUser(_x3, _x4) {
101
- return _ref2.apply(this, arguments);
102
- };
103
- }();
104
-
105
- // 用户登出
106
- export var signOutUser = /*#__PURE__*/function () {
107
- var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
108
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
109
- while (1) switch (_context3.prev = _context3.next) {
110
- case 0:
111
- _context3.prev = 0;
112
- return _context3.abrupt("return", signOut(auth));
113
- case 4:
114
- _context3.prev = 4;
115
- _context3.t0 = _context3["catch"](0);
116
- console.error("Error signing out:", _context3.t0);
117
- throw _context3.t0;
118
- case 8:
119
- case "end":
120
- return _context3.stop();
121
- }
122
- }, _callee3, null, [[0, 4]]);
123
- }));
124
- return function signOutUser() {
125
- return _ref3.apply(this, arguments);
126
- };
127
- }();
128
-
129
- // 读取数据 单次数据
130
- export var readData = /*#__PURE__*/function () {
131
- var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(path) {
132
- var dataSnapshot;
133
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
134
- while (1) switch (_context4.prev = _context4.next) {
135
- case 0:
136
- _context4.prev = 0;
137
- if (!isInitialized) {
138
- initFirebase();
139
- }
140
- _context4.next = 4;
141
- return get(ref(database, getPath(path)));
142
- case 4:
143
- dataSnapshot = _context4.sent;
144
- return _context4.abrupt("return", dataSnapshot.val());
145
- case 8:
146
- _context4.prev = 8;
147
- _context4.t0 = _context4["catch"](0);
148
- console.error("Error reading data:", _context4.t0);
149
- throw _context4.t0;
150
- case 12:
151
- case "end":
152
- return _context4.stop();
153
- }
154
- }, _callee4, null, [[0, 8]]);
155
- }));
156
- return function readData(_x5) {
157
- return _ref4.apply(this, arguments);
158
- };
159
- }();
160
-
161
- // 写入数据
162
- export var writeData = /*#__PURE__*/function () {
163
- var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(path, data) {
164
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
165
- while (1) switch (_context5.prev = _context5.next) {
166
- case 0:
167
- _context5.prev = 0;
168
- if (!isInitialized) {
169
- initFirebase();
170
- }
171
- return _context5.abrupt("return", set(ref(database, getPath(path)), data));
172
- case 5:
173
- _context5.prev = 5;
174
- _context5.t0 = _context5["catch"](0);
175
- console.error("Error writing data:", _context5.t0);
176
- throw _context5.t0;
177
- case 9:
178
- case "end":
179
- return _context5.stop();
180
- }
181
- }, _callee5, null, [[0, 5]]);
182
- }));
183
- return function writeData(_x6, _x7) {
184
- return _ref5.apply(this, arguments);
185
- };
186
- }();
187
-
188
- // onValue 方法 实现监听
189
- export var onDataChange = function onDataChange(path, callback) {
190
- try {
191
- if (!isInitialized) {
192
- initFirebase();
193
- }
194
- } catch (error) {
195
- console.error('init error', error);
196
- }
197
- var databaseRef = ref(database, getPath(path));
198
- var listener = onValue(databaseRef, callback);
199
-
200
- // 返回实例,用于移除监听器
201
- return listener;
202
- };
203
-
204
- // onChildChanged 方法 实现监听变化的key
205
- export var onDataChanged = function onDataChanged(path, callback) {
206
- try {
207
- if (!isInitialized) {
208
- initFirebase();
209
- }
210
- } catch (error) {
211
- console.error('init error', error);
212
- }
213
- var databaseRef = ref(database, getPath(path));
214
- var listener = onChildChanged(databaseRef, callback);
215
-
216
- // 返回实例,用于移除监听器
217
- return listener;
218
- };
219
-
220
- // 移除监听器
221
- export var removeDataListener = function removeDataListener(listener) {
222
- off(listener); // 移除监听器
223
- };
224
- export default {
225
- signInUser: signInUser,
226
- signOutUser: signOutUser,
227
- readData: readData,
228
- writeData: writeData,
229
- onDataChange: onDataChange,
230
- removeDataListener: removeDataListener,
231
- onDataChanged: onDataChanged
232
- };
@@ -1,13 +0,0 @@
1
- declare type InjectedConfigType = {
2
- apiKey: string;
3
- authDomain: string;
4
- projectId: string;
5
- storageBucket: string;
6
- messagingSenderId: string;
7
- appId: string;
8
- databaseURL: string;
9
- };
10
- export declare const injectConfig: (context: InjectedConfigType) => void;
11
- export declare const firebaseConfig: any;
12
- declare const _default: any;
13
- export default _default;
@@ -1,79 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // src/firebase/config/index.ts
20
- var config_exports = {};
21
- __export(config_exports, {
22
- default: () => config_default,
23
- firebaseConfig: () => firebaseConfig,
24
- injectConfig: () => injectConfig
25
- });
26
- module.exports = __toCommonJS(config_exports);
27
- var { REACT_APP_API_ENV } = process.env;
28
- var _firebaseConfig = {
29
- "release": {
30
- apiKey: "AIzaSyBhWzh3z3eGW08oeUH6jKNP_H3msyuBEQc",
31
- authDomain: "pisell-dev-d6421.firebaseapp.com",
32
- databaseURL: "https://pisell-dev-d6421-default-rtdb.asia-southeast1.firebasedatabase.app",
33
- projectId: "pisell-dev-d6421",
34
- storageBucket: "pisell-dev-d6421.appspot.com",
35
- messagingSenderId: "426955619429",
36
- appId: "1:426955619429:web:17b5fc88934bebb6dc1a8c",
37
- measurementId: "G-YJ5G113V4L"
38
- },
39
- "dev": {
40
- apiKey: "AIzaSyBhWzh3z3eGW08oeUH6jKNP_H3msyuBEQc",
41
- authDomain: "pisell-dev-d6421.firebaseapp.com",
42
- databaseURL: "https://pisell-dev-d6421-default-rtdb.asia-southeast1.firebasedatabase.app",
43
- projectId: "pisell-dev-d6421",
44
- storageBucket: "pisell-dev-d6421.appspot.com",
45
- messagingSenderId: "426955619429",
46
- appId: "1:426955619429:web:17b5fc88934bebb6dc1a8c",
47
- measurementId: "G-YJ5G113V4L"
48
- },
49
- "pre": {
50
- apiKey: "AIzaSyBhWzh3z3eGW08oeUH6jKNP_H3msyuBEQc",
51
- authDomain: "pisell-dev-d6421.firebaseapp.com",
52
- databaseURL: "https://pisell-dev-d6421-default-rtdb.asia-southeast1.firebasedatabase.app",
53
- projectId: "pisell-dev-d6421",
54
- storageBucket: "pisell-dev-d6421.appspot.com",
55
- messagingSenderId: "426955619429",
56
- appId: "1:426955619429:web:17b5fc88934bebb6dc1a8c",
57
- measurementId: "G-YJ5G113V4L"
58
- },
59
- "prod": {
60
- apiKey: "AIzaSyBhWzh3z3eGW08oeUH6jKNP_H3msyuBEQc",
61
- authDomain: "pisell-dev-d6421.firebaseapp.com",
62
- databaseURL: "https://pisell-dev-product-test.asia-southeast1.firebasedatabase.app",
63
- projectId: "pisell-dev-d6421",
64
- storageBucket: "pisell-dev-d6421.appspot.com",
65
- messagingSenderId: "426955619429",
66
- appId: "1:426955619429:web:17b5fc88934bebb6dc1a8c",
67
- measurementId: "G-YJ5G113V4L"
68
- }
69
- };
70
- var injectConfig = (context) => {
71
- _firebaseConfig[REACT_APP_API_ENV] = context;
72
- };
73
- var firebaseConfig = _firebaseConfig[REACT_APP_API_ENV];
74
- var config_default = _firebaseConfig[REACT_APP_API_ENV];
75
- // Annotate the CommonJS export names for ESM import in node:
76
- 0 && (module.exports = {
77
- firebaseConfig,
78
- injectConfig
79
- });
@@ -1,28 +0,0 @@
1
- import { FirebaseApp } from 'firebase/app';
2
- import { Auth } from 'firebase/auth';
3
- import { ref, Database, goOnline, goOffline } from 'firebase/database';
4
- declare let firebaseApp: FirebaseApp;
5
- declare let auth: Auth;
6
- declare let database: Database;
7
- export declare const initFirebase: (config?: any) => void;
8
- export { database, firebaseApp, auth, ref, goOnline, goOffline };
9
- export declare const getPath: (path: string) => string;
10
- export declare const setAuthStateChangeCallback: (callback: (user: any) => void) => void;
11
- export declare const signUp: (email: string, password: string) => Promise<import("firebase/auth").User>;
12
- export declare const signInUser: (email: string, password: string) => Promise<import("firebase/auth").User>;
13
- export declare const signOutUser: () => Promise<void>;
14
- export declare const readData: (path: string) => Promise<any>;
15
- export declare const writeData: (path: string, data: any) => Promise<void>;
16
- export declare const onDataChange: (path: string, callback: (snapshot: any) => void) => import("firebase/database").Unsubscribe;
17
- export declare const onDataChanged: (path: string, callback: (snapshot: any) => void) => import("firebase/database").Unsubscribe;
18
- export declare const removeDataListener: (listener: any) => void;
19
- declare const _default: {
20
- signInUser: (email: string, password: string) => Promise<import("firebase/auth").User>;
21
- signOutUser: () => Promise<void>;
22
- readData: (path: string) => Promise<any>;
23
- writeData: (path: string, data: any) => Promise<void>;
24
- onDataChange: (path: string, callback: (snapshot: any) => void) => import("firebase/database").Unsubscribe;
25
- removeDataListener: (listener: any) => void;
26
- onDataChanged: (path: string, callback: (snapshot: any) => void) => import("firebase/database").Unsubscribe;
27
- };
28
- export default _default;