@pisell/utils 1.0.24 → 1.0.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/firebase/config/index.d.ts +1 -0
- package/es/firebase/config/index.js +6 -3
- package/es/firebase/index.d.ts +1 -0
- package/es/firebase/index.js +19 -11
- package/lib/firebase/config/index.d.ts +1 -0
- package/lib/firebase/config/index.js +6 -3
- package/lib/firebase/index.d.ts +1 -0
- package/lib/firebase/index.js +10 -13
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @ts-ignore
|
|
2
2
|
var REACT_APP_API_ENV = process.env.REACT_APP_API_ENV;
|
|
3
|
-
var
|
|
3
|
+
var _firebaseConfig = {
|
|
4
4
|
'release': {
|
|
5
5
|
apiKey: "AIzaSyBhWzh3z3eGW08oeUH6jKNP_H3msyuBEQc",
|
|
6
6
|
authDomain: "pisell-dev-d6421.firebaseapp.com",
|
|
@@ -44,8 +44,11 @@ var firebaseConfig = {
|
|
|
44
44
|
};
|
|
45
45
|
export var injectConfig = function injectConfig(context) {
|
|
46
46
|
// @ts-ignore
|
|
47
|
-
|
|
47
|
+
_firebaseConfig[REACT_APP_API_ENV] = context;
|
|
48
48
|
};
|
|
49
49
|
|
|
50
50
|
// @ts-ignore
|
|
51
|
-
export
|
|
51
|
+
export var firebaseConfig = _firebaseConfig[REACT_APP_API_ENV];
|
|
52
|
+
|
|
53
|
+
// @ts-ignore
|
|
54
|
+
export default _firebaseConfig[REACT_APP_API_ENV];
|
package/es/firebase/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { FirebaseApp } from 'firebase/app';
|
|
2
2
|
declare let firebaseApp: FirebaseApp;
|
|
3
|
+
export declare const initFirebase: (config?: any) => void;
|
|
3
4
|
export { firebaseApp };
|
|
4
5
|
export declare const getPath: (path: string) => string;
|
|
5
6
|
export declare const setAuthStateChangeCallback: (callback: (user: any) => void) => void;
|
package/es/firebase/index.js
CHANGED
|
@@ -1,24 +1,32 @@
|
|
|
1
1
|
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2
|
+
var _window, _window2;
|
|
2
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 exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
3
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); } }
|
|
4
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); }); }; }
|
|
5
6
|
import { initializeApp } from 'firebase/app';
|
|
6
7
|
import { getAuth, createUserWithEmailAndPassword, signInWithEmailAndPassword, signOut } from 'firebase/auth';
|
|
7
8
|
import { getDatabase, ref, set, get, off, onValue, onChildChanged } from 'firebase/database';
|
|
8
|
-
import firebaseConfig from "./config";
|
|
9
|
-
|
|
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 = isUndefined((_window = window) === null || _window === void 0 ? void 0 : _window.__isDefaultInit) ? true : (_window2 = window) === null || _window2 === void 0 ? void 0 : _window2.__isDefaultInit;
|
|
10
15
|
var firebaseApp = {};
|
|
11
16
|
var auth = {};
|
|
12
17
|
var database = {};
|
|
13
|
-
|
|
14
|
-
//@ts-ignore 如果在客户端并且不是微信小程序的环境下初始化
|
|
15
|
-
if (isClient && window.__wxjs_environment !== 'miniprogram') {
|
|
18
|
+
export var initFirebase = function initFirebase(config) {
|
|
16
19
|
// 初始化 Firebase
|
|
17
|
-
firebaseApp = initializeApp(firebaseConfig);
|
|
20
|
+
firebaseApp = initializeApp(config || firebaseConfig);
|
|
18
21
|
// 获取 Firebase Auth 实例
|
|
19
22
|
auth = getAuth(firebaseApp);
|
|
20
23
|
// 获取 Firebase Database 实例
|
|
21
24
|
database = getDatabase(firebaseApp);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
//@ts-ignore 如果在客户端并且不是微信小程序的环境下初始化
|
|
28
|
+
if (isClient && window.__wxjs_environment !== "miniprogram" && isDefaultInit) {
|
|
29
|
+
initFirebase();
|
|
22
30
|
}
|
|
23
31
|
|
|
24
32
|
// 导出 Firebase 配置,以便在需要时进行访问
|
|
@@ -50,7 +58,7 @@ export var signUp = /*#__PURE__*/function () {
|
|
|
50
58
|
case 7:
|
|
51
59
|
_context.prev = 7;
|
|
52
60
|
_context.t0 = _context["catch"](0);
|
|
53
|
-
console.error(
|
|
61
|
+
console.error("Error signing up:", _context.t0);
|
|
54
62
|
throw _context.t0;
|
|
55
63
|
case 11:
|
|
56
64
|
case "end":
|
|
@@ -79,7 +87,7 @@ export var signInUser = /*#__PURE__*/function () {
|
|
|
79
87
|
case 7:
|
|
80
88
|
_context2.prev = 7;
|
|
81
89
|
_context2.t0 = _context2["catch"](0);
|
|
82
|
-
console.error(
|
|
90
|
+
console.error("Error signing in:", _context2.t0);
|
|
83
91
|
throw _context2.t0;
|
|
84
92
|
case 11:
|
|
85
93
|
case "end":
|
|
@@ -103,7 +111,7 @@ export var signOutUser = /*#__PURE__*/function () {
|
|
|
103
111
|
case 4:
|
|
104
112
|
_context3.prev = 4;
|
|
105
113
|
_context3.t0 = _context3["catch"](0);
|
|
106
|
-
console.error(
|
|
114
|
+
console.error("Error signing out:", _context3.t0);
|
|
107
115
|
throw _context3.t0;
|
|
108
116
|
case 8:
|
|
109
117
|
case "end":
|
|
@@ -132,7 +140,7 @@ export var readData = /*#__PURE__*/function () {
|
|
|
132
140
|
case 7:
|
|
133
141
|
_context4.prev = 7;
|
|
134
142
|
_context4.t0 = _context4["catch"](0);
|
|
135
|
-
console.error(
|
|
143
|
+
console.error("Error reading data:", _context4.t0);
|
|
136
144
|
throw _context4.t0;
|
|
137
145
|
case 11:
|
|
138
146
|
case "end":
|
|
@@ -156,7 +164,7 @@ export var writeData = /*#__PURE__*/function () {
|
|
|
156
164
|
case 4:
|
|
157
165
|
_context5.prev = 4;
|
|
158
166
|
_context5.t0 = _context5["catch"](0);
|
|
159
|
-
console.error(
|
|
167
|
+
console.error("Error writing data:", _context5.t0);
|
|
160
168
|
throw _context5.t0;
|
|
161
169
|
case 8:
|
|
162
170
|
case "end":
|
|
@@ -20,11 +20,12 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
var config_exports = {};
|
|
21
21
|
__export(config_exports, {
|
|
22
22
|
default: () => config_default,
|
|
23
|
+
firebaseConfig: () => firebaseConfig,
|
|
23
24
|
injectConfig: () => injectConfig
|
|
24
25
|
});
|
|
25
26
|
module.exports = __toCommonJS(config_exports);
|
|
26
27
|
var { REACT_APP_API_ENV } = process.env;
|
|
27
|
-
var
|
|
28
|
+
var _firebaseConfig = {
|
|
28
29
|
"release": {
|
|
29
30
|
apiKey: "AIzaSyBhWzh3z3eGW08oeUH6jKNP_H3msyuBEQc",
|
|
30
31
|
authDomain: "pisell-dev-d6421.firebaseapp.com",
|
|
@@ -67,10 +68,12 @@ var firebaseConfig = {
|
|
|
67
68
|
}
|
|
68
69
|
};
|
|
69
70
|
var injectConfig = (context) => {
|
|
70
|
-
|
|
71
|
+
_firebaseConfig[REACT_APP_API_ENV] = context;
|
|
71
72
|
};
|
|
72
|
-
var
|
|
73
|
+
var firebaseConfig = _firebaseConfig[REACT_APP_API_ENV];
|
|
74
|
+
var config_default = _firebaseConfig[REACT_APP_API_ENV];
|
|
73
75
|
// Annotate the CommonJS export names for ESM import in node:
|
|
74
76
|
0 && (module.exports = {
|
|
77
|
+
firebaseConfig,
|
|
75
78
|
injectConfig
|
|
76
79
|
});
|
package/lib/firebase/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { FirebaseApp } from 'firebase/app';
|
|
2
2
|
declare let firebaseApp: FirebaseApp;
|
|
3
|
+
export declare const initFirebase: (config?: any) => void;
|
|
3
4
|
export { firebaseApp };
|
|
4
5
|
export declare const getPath: (path: string) => string;
|
|
5
6
|
export declare const setAuthStateChangeCallback: (callback: (user: any) => void) => void;
|
package/lib/firebase/index.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
1
|
var __defProp = Object.defineProperty;
|
|
3
2
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
5
|
var __export = (target, all) => {
|
|
8
6
|
for (var name in all)
|
|
@@ -16,14 +14,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
14
|
}
|
|
17
15
|
return to;
|
|
18
16
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
-
mod
|
|
26
|
-
));
|
|
27
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
18
|
|
|
29
19
|
// src/firebase/index.ts
|
|
@@ -32,6 +22,7 @@ __export(firebase_exports, {
|
|
|
32
22
|
default: () => firebase_default,
|
|
33
23
|
firebaseApp: () => firebaseApp,
|
|
34
24
|
getPath: () => getPath,
|
|
25
|
+
initFirebase: () => initFirebase,
|
|
35
26
|
onDataChange: () => onDataChange,
|
|
36
27
|
onDataChanged: () => onDataChanged,
|
|
37
28
|
readData: () => readData,
|
|
@@ -46,15 +37,20 @@ module.exports = __toCommonJS(firebase_exports);
|
|
|
46
37
|
var import_app = require("firebase/app");
|
|
47
38
|
var import_auth = require("firebase/auth");
|
|
48
39
|
var import_database = require("firebase/database");
|
|
49
|
-
var import_config =
|
|
40
|
+
var import_config = require("./config");
|
|
41
|
+
var import_typeUtils = require("../typeUtils");
|
|
50
42
|
var isClient = typeof window != "undefined" && window.document;
|
|
43
|
+
var isDefaultInit = (0, import_typeUtils.isUndefined)(window == null ? void 0 : window.__isDefaultInit) ? true : window == null ? void 0 : window.__isDefaultInit;
|
|
51
44
|
var firebaseApp = {};
|
|
52
45
|
var auth = {};
|
|
53
46
|
var database = {};
|
|
54
|
-
|
|
55
|
-
firebaseApp = (0, import_app.initializeApp)(import_config.
|
|
47
|
+
var initFirebase = (config) => {
|
|
48
|
+
firebaseApp = (0, import_app.initializeApp)(config || import_config.firebaseConfig);
|
|
56
49
|
auth = (0, import_auth.getAuth)(firebaseApp);
|
|
57
50
|
database = (0, import_database.getDatabase)(firebaseApp);
|
|
51
|
+
};
|
|
52
|
+
if (isClient && window.__wxjs_environment !== "miniprogram" && isDefaultInit) {
|
|
53
|
+
initFirebase();
|
|
58
54
|
}
|
|
59
55
|
var getPath = (path) => {
|
|
60
56
|
return path;
|
|
@@ -139,6 +135,7 @@ var firebase_default = {
|
|
|
139
135
|
0 && (module.exports = {
|
|
140
136
|
firebaseApp,
|
|
141
137
|
getPath,
|
|
138
|
+
initFirebase,
|
|
142
139
|
onDataChange,
|
|
143
140
|
onDataChanged,
|
|
144
141
|
readData,
|