2022-01-22 12:57:05 +05:00
|
|
|
import { Platform } from 'react-native';
|
2022-02-28 13:48:59 +05:00
|
|
|
import filesystem from '../filesystem';
|
|
|
|
|
import EventSource from '../sse/even-source-ios';
|
|
|
|
|
import AndroidEventSource from '../sse/event-source';
|
2020-12-20 12:48:08 +05:00
|
|
|
import Storage from './storage';
|
2022-07-15 19:33:44 +05:00
|
|
|
import Database from '@streetwriters/notesnook-core/api/index';
|
2020-10-13 17:02:14 +05:00
|
|
|
|
2022-07-06 12:17:08 +05:00
|
|
|
/**
|
2022-07-15 19:33:44 +05:00
|
|
|
* @type {import("@streetwriters/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,
|
|
|
|
|
Platform.OS === 'ios' ? EventSource : AndroidEventSource,
|
|
|
|
|
filesystem
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
db.host(
|
|
|
|
|
__DEV__
|
|
|
|
|
? {
|
|
|
|
|
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'
|
|
|
|
|
// 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'
|
|
|
|
|
}
|
|
|
|
|
: {
|
|
|
|
|
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-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);
|
|
|
|
|
// //@ts-ignore
|
|
|
|
|
// if (DOMParser) {
|
|
|
|
|
// //@ts-ignore
|
|
|
|
|
// await DOMParser.prepare();
|
|
|
|
|
// }
|
2022-07-06 12:17:08 +05:00
|
|
|
}
|