remove import()

This commit is contained in:
Ammar Ahmed
2022-07-08 18:24:31 +05:00
parent cf4ce36480
commit fe1592e97c
3 changed files with 41 additions and 36 deletions

View File

@@ -117,7 +117,7 @@ const Input = ({
break;
case 'phonenumber':
// eslint-disable-next-line no-case-declarations
const phone = await (await import('phone')).default;
const phone = require('phone').default;
// eslint-disable-next-line no-case-declarations
let result = phone(value, {
strictDetection: true,

View File

@@ -3,44 +3,49 @@ import filesystem from '../filesystem';
import EventSource from '../sse/even-source-ios';
import AndroidEventSource from '../sse/event-source';
import Storage from './storage';
import Database from 'notes-core/api/index';
/**
* @type {import("notes-core/api/index").default}
*/
export var db;
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'
}
);
let DB = null;
export async function loadDatabase() {
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();
}
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'
}
);
// 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();
// }
}

View File

@@ -126,7 +126,7 @@ export async function toTXT(note, notitle) {
} else {
text = await db.notes.note(note.id).content();
}
htmlToText = htmlToText || (await import('html-to-text'));
htmlToText = htmlToText || require('html-to-text');
text = htmlToText.convert(text, {
selectors: [{ selector: 'img', format: 'skip' }]
});