2022-08-31 06:33:37 +05:00
|
|
|
/*
|
|
|
|
|
This file is part of the Notesnook project (https://notesnook.com/)
|
|
|
|
|
|
|
|
|
|
Copyright (C) 2022 Streetwriters (Private) Limited
|
|
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
2022-08-30 16:13:11 +05:00
|
|
|
|
2022-08-30 09:59:53 +05:00
|
|
|
import Database from "@notesnook/core/api/index";
|
|
|
|
|
import { initalize, logger as dbLogger } from "@notesnook/core/logger";
|
2022-08-26 16:19:39 +05:00
|
|
|
import { Platform } from "react-native";
|
|
|
|
|
import { MMKVLoader } from "react-native-mmkv-storage";
|
|
|
|
|
import filesystem from "../filesystem";
|
|
|
|
|
import EventSource from "../../utils/sse/even-source-ios";
|
|
|
|
|
import AndroidEventSource from "../../utils/sse/event-source";
|
|
|
|
|
import Storage, { KV } from "./storage";
|
|
|
|
|
const LoggerStorage = new MMKVLoader()
|
|
|
|
|
.withInstanceID("notesnook_logs")
|
|
|
|
|
.initialize();
|
2022-07-19 13:36:45 +05:00
|
|
|
initalize(new KV(LoggerStorage));
|
|
|
|
|
export const DatabaseLogger = dbLogger;
|
2020-10-13 17:02:14 +05:00
|
|
|
|
2022-07-06 12:17:08 +05:00
|
|
|
/**
|
2022-08-30 09:59:53 +05:00
|
|
|
* @type {import("@notesnook/core/api/index").default}
|
2022-07-06 12:17:08 +05:00
|
|
|
*/
|
2022-07-08 18:24:31 +05:00
|
|
|
export var db = new Database(
|
|
|
|
|
Storage,
|
2022-08-26 16:19:39 +05:00
|
|
|
Platform.OS === "ios" ? EventSource : AndroidEventSource,
|
2022-07-08 18:24:31 +05:00
|
|
|
filesystem
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
db.host(
|
|
|
|
|
__DEV__
|
|
|
|
|
? {
|
2022-08-26 16:19:39 +05:00
|
|
|
API_HOST: "https://api.notesnook.com",
|
|
|
|
|
AUTH_HOST: "https://auth.streetwriters.co",
|
|
|
|
|
SSE_HOST: "https://events.streetwriters.co",
|
|
|
|
|
SUBSCRIPTIONS_HOST: "https://subscriptions.streetwriters.co",
|
|
|
|
|
ISSUES_HOST: "https://issues.streetwriters.co"
|
2022-07-08 18:24:31 +05:00
|
|
|
// API_HOST: 'http://192.168.10.29:5264',
|
|
|
|
|
// AUTH_HOST: 'http://192.168.10.29:8264',
|
|
|
|
|
// SSE_HOST: 'http://192.168.10.29:7264',
|
|
|
|
|
// SUBSCRIPTIONS_HOST: 'http://192.168.10.29:9264',
|
|
|
|
|
// ISSUES_HOST: 'http://192.168.10.29:2624'
|
|
|
|
|
}
|
|
|
|
|
: {
|
2022-08-26 16:19:39 +05:00
|
|
|
API_HOST: "https://api.notesnook.com",
|
|
|
|
|
AUTH_HOST: "https://auth.streetwriters.co",
|
|
|
|
|
SSE_HOST: "https://events.streetwriters.co",
|
|
|
|
|
SUBSCRIPTIONS_HOST: "https://subscriptions.streetwriters.co",
|
|
|
|
|
ISSUES_HOST: "https://issues.streetwriters.co"
|
2022-07-08 18:24:31 +05:00
|
|
|
}
|
|
|
|
|
);
|
2022-07-06 12:17:08 +05:00
|
|
|
|
|
|
|
|
export async function loadDatabase() {
|
2022-07-08 18:24:31 +05:00
|
|
|
// if (!DB) {
|
|
|
|
|
// let module = await import(/* webpackChunkName: "notes-core" */ 'notes-core/api/index');
|
|
|
|
|
// DB = module.default;
|
|
|
|
|
// }
|
|
|
|
|
// db = new DB(Storage, Platform.OS === 'ios' ? EventSource : AndroidEventSource, filesystem);
|
|
|
|
|
// if (DOMParser) {
|
|
|
|
|
// await DOMParser.prepare();
|
|
|
|
|
// }
|
2022-07-06 12:17:08 +05:00
|
|
|
}
|