A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
lazy load components
Ammar Ahmed5ecf2929c6db
diff --git a/apps/mobile/android/app/src/main/java/com/streetwriters/notesnook/MainApplication.java b/apps/mobile/android/app/src/main/java/com/streetwriters/notesnook/MainApplication.javaindex 48b14ecb4..723e0d71a 100644--- a/apps/mobile/android/app/src/main/java/com/streetwriters/notesnook/MainApplication.java+++ b/apps/mobile/android/app/src/main/java/com/streetwriters/notesnook/MainApplication.java@@ -2,6 +2,7 @@ package com.streetwriters.notesnook;import android.app.Application;import android.content.Context;+import android.util.Log;import com.dooboolab.RNIap.RNIapModule;import com.facebook.react.PackageList;@@ -34,6 +35,7 @@ import com.streetwriters.notesnook.newarchitecture.MainApplicationReactNativeHosimport cl.json.RNShareModule;import px.tooltips.RNTooltipsModule;import io.csie.kudo.reactnative.v8.executor.V8ExecutorFactory;+import androidx.annotation.Nullable;public class MainApplication extends MultiDexApplication implements ReactApplication {@@ -47,6 +49,17 @@ public class MainApplication extends MultiDexApplication implements ReactApplicareturn BuildConfig.DEBUG;}+ @Nullable+ @Override+ protected String getBundleAssetName() {+ final String v8BundleAssetName = V8ExecutorFactory.getBundleAssetName(getApplicationContext(), getUseDeveloperSupport());+ if (v8BundleAssetName != null) {+ return v8BundleAssetName;+ }+ Log.d("Notesnook:::", "LOADED" + v8BundleAssetName + super.getBundleAssetName());+ return super.getBundleAssetName();+ }+@Overrideprotected JavaScriptExecutorFactory getJavaScriptExecutorFactory() {return new V8ExecutorFactory(diff --git a/apps/mobile/android/app/src/main/res/values/styles.xml b/apps/mobile/android/app/src/main/res/values/styles.xmlindex 4c4efa2a6..8355e1210 100644--- a/apps/mobile/android/app/src/main/res/values/styles.xml+++ b/apps/mobile/android/app/src/main/res/values/styles.xml@@ -6,9 +6,7 @@<item name="android:windowDisablePreview">true</item><item name="android:editTextBackground">@drawable/edit_text</item>- <item name="android:windowTranslucentStatus">true</item><item name="android:statusBarColor">@android:color/transparent</item>- <item name="android:windowDrawsSystemBarBackgrounds">true</item></style><style name="Share.Window" parent="Theme.AppCompat">diff --git a/apps/mobile/android/gradle.properties b/apps/mobile/android/gradle.propertiesindex 4ea2f8902..574487592 100644--- a/apps/mobile/android/gradle.properties+++ b/apps/mobile/android/gradle.properties@@ -41,5 +41,5 @@ reactNativeArchitectures=armeabi-v7a,arm64-v8a,x86,x86_64newArchEnabled=false# V8 Cache Mode Config-v8.cacheMode=normal+v8.cacheMode=normalWithStubBundlev8.android.tools.dir=/home/ammarahm-ed/Repos/notesnook-mobile/node_modules/v8-android-jit-nointl/dist/tools/android\ No newline at end of filediff --git a/apps/mobile/babel.config.js b/apps/mobile/babel.config.jsindex bdb2635e9..51103124f 100644--- a/apps/mobile/babel.config.js+++ b/apps/mobile/babel.config.js@@ -18,7 +18,7 @@ const configs = {production: {presets: ['module:metro-react-native-babel-preset'],plugins: [- 'transform-remove-console',+ //'transform-remove-console','@babel/plugin-transform-named-capturing-groups-regex','react-native-reanimated/plugin']diff --git a/apps/mobile/globals.js b/apps/mobile/globals.jsindex 34b36639a..e27c07cd5 100644--- a/apps/mobile/globals.js+++ b/apps/mobile/globals.js@@ -1,5 +1,63 @@/* eslint-disable @typescript-eslint/no-var-requires */global.Buffer = require('buffer').Buffer;-import { DOMParser } from './worker';+import { ScriptManager, Script } from '@callstack/repack/client';import './src/utils/logger/index';-global.DOMParser = DOMParser;++class DOM {+ static domparser;++ parseFromString(markupLanguage, mimeType, globals) {+ return DOM.domparser?.parseFromString(markupLanguage, mimeType, globals);+ }++ static async prepare() {+ if (!DOM.domparser) {+ let module = await import('./worker.js');+ DOM.domparser = new module.DOMParser();+ }+ }+}+global.DOMParser = DOM;++try {+ const shared = ScriptManager.shared;+} catch (e) {+ new ScriptManager({+ resolve: async (scriptId, caller) => {+ if (__DEV__) {+ return {+ url: Script.getDevServerURL(scriptId),+ cache: false+ };+ }++ return {+ url: Script.getFileSystemURL(scriptId)+ };+ }+ });+}++ScriptManager.shared.on('resolving', (...args) => {+ console.log('DEBUG/resolving', ...args);+});++ScriptManager.shared.on('resolved', (...args) => {+ console.log('DEBUG/resolved', ...args);+});++ScriptManager.shared.on('prefetching', (...args) => {+ console.log('DEBUG/prefetching', ...args);+});++ScriptManager.shared.on('loading', (...args) => {+ console.log('DEBUG/loading', ...args);+});++ScriptManager.shared.on('loaded', (...args) => {+ console.log('DEBUG/loaded', ...args);+});++ScriptManager.shared.on('error', (...args) => {+ console.log('DEBUG/error', ...args);+});diff --git a/apps/mobile/index.js b/apps/mobile/index.jsindex 69bc2c4cc..6c98182fb 100644--- a/apps/mobile/index.js+++ b/apps/mobile/index.js@@ -10,7 +10,6 @@ import { SafeAreaProvider } from 'react-native-safe-area-context';import { enableScreens } from 'react-native-screens';import appJson from './app.json';import Notifications from './src/services/notifications';-enableLayoutAnimations(true);const appName = appJson.name;if (Config.isTesting) {diff --git a/apps/mobile/src/components/attachments/attachmentitem.js b/apps/mobile/src/components/attachments/attachmentitem.jsindex 73bc3d744..f3e09f95a 100644--- a/apps/mobile/src/components/attachments/attachmentitem.js+++ b/apps/mobile/src/components/attachments/attachmentitem.js@@ -1,6 +1,5 @@import React from 'react';import { TouchableOpacity, View } from 'react-native';-import * as Progress from 'react-native-progress';import Icon from 'react-native-vector-icons/MaterialCommunityIcons';import { useAttachmentStore } from '../../stores/use-attachment-store';import { useThemeStore } from '../../stores/use-theme-store';@@ -10,6 +9,7 @@ import { useAttachmentProgress } from '../../utils/hooks/use-attachment-progressimport { SIZE } from '../../utils/size';import SheetProvider from '../sheet-provider';import { IconButton } from '../ui/icon-button';+import { ProgressCircleComponent } from '../ui/svg/lazy';import Paragraph from '../ui/typography/paragraph';import Actions from './actions';@@ -113,24 +113,26 @@ export const AttachmentItem = ({ attachment, encryption, setAttachments }) => {marginRight: -5}}>- <Progress.Circle- size={SIZE.xxl}- progress={- encryptionProgress- ? encryptionProgress- : currentProgress?.value- ? currentProgress?.value / 100- : 0- }- showsText- textStyle={{- fontSize: 10- }}- color={colors.accent}- formatText={progress => (progress * 100).toFixed(0)}- borderWidth={0}- thickness={2}- />+ <React.Suspense fallback={<View />}>+ <ProgressCircleComponent+ size={SIZE.xxl}+ progress={+ encryptionProgress+ ? encryptionProgress+ : currentProgress?.value+ ? currentProgress?.value / 100+ : 0+ }+ showsText+ textStyle={{+ fontSize: 10+ }}+ color={colors.accent}+ formatText={progress => (progress * 100).toFixed(0)}+ borderWidth={0}+ thickness={2}+ />+ </React.Suspense></TouchableOpacity>) : (<>diff --git a/apps/mobile/src/components/auth/authmodal.js b/apps/mobile/src/components/auth/authmodal.jsindex a747c3def..9e6b59ab1 100644--- a/apps/mobile/src/components/auth/authmodal.js+++ b/apps/mobile/src/components/auth/authmodal.js@@ -1,14 +1,14 @@import React, { useEffect, useRef, useState } from 'react';-import { Platform, StatusBar } from 'react-native';+import { Platform } from 'react-native';import { useSafeAreaInsets } from 'react-native-safe-area-context';-import { eSendEvent, eSubscribeEvent, eUnSubscribeEvent } from '../../services/event-manager';+import { eSubscribeEvent, eUnSubscribeEvent } from '../../services/event-manager';import { useThemeStore } from '../../stores/use-theme-store';import { eCloseLoginDialog, eOpenLoginDialog } from '../../utils/events';import { sleep } from '../../utils/time';import BaseDialog from '../dialog/base-dialog';import { Toast } from '../toast';import { IconButton } from '../ui/icon-button';-import { initialAuthMode } from './common';+import { hideAuth, initialAuthMode } from './common';import { Login } from './login';import { Signup } from './signup';@@ -37,7 +37,7 @@ const AuthModal = () => {async function open(mode) {setCurrentAuthMode(mode ? mode : AuthMode.login);- initialAuthMode.current = -1;+ initialAuthMode.current = mode ? mode : AuthMode.login;setVisible(true);await sleep(10);actionSheetRef.current?.show();@@ -60,30 +60,36 @@ const AuthModal = () => {bounce={false}background={colors.bg}transparent={false}+ animated={false}>{currentAuthMode !== AuthMode.login ? (<SignupchangeMode={mode => setCurrentAuthMode(mode)}trial={AuthMode.trialSignup === currentAuthMode}- welcome={currentAuthMode === AuthMode.welcomeSignup}+ welcome={initialAuthMode.current === AuthMode.welcomeSignup}/>) : (- <Login changeMode={mode => setCurrentAuthMode(mode)} />+ <Login+ welcome={initialAuthMode.current === AuthMode.welcomeSignup}+ changeMode={mode => setCurrentAuthMode(mode)}+ />)}- <IconButton- name="arrow-left"- onPress={() => {- eSendEvent(eCloseLoginDialog);- }}- color={colors.pri}- customStyle={{- position: 'absolute',- zIndex: 999,- left: 12,- top: Platform.OS === 'ios' ? 12 + insets.top : 12- }}- />+ {initialAuthMode.current === AuthMode.welcomeSignup ? null : (+ <IconButton+ name="arrow-left"+ onPress={() => {+ hideAuth();+ }}+ color={colors.pri}+ customStyle={{+ position: 'absolute',+ zIndex: 999,+ left: 12,+ top: Platform.OS === 'ios' ? 12 + insets.top : insets.top+ }}+ />+ )}<Toast context="local" /></BaseDialog>diff --git a/apps/mobile/src/components/auth/common.js b/apps/mobile/src/components/auth/common.jsindex f1b148bf3..b5e91d4b9 100644--- a/apps/mobile/src/components/auth/common.js+++ b/apps/mobile/src/components/auth/common.js@@ -7,27 +7,20 @@ import { tabBarRef } from '../../utils/global-refs';export const initialAuthMode = createRef(0);export function hideAuth() {- if (initialAuthMode.current === -1) {- eSendEvent(eCloseLoginDialog);- return;- }- if (initialAuthMode.current === 2) {- Navigation.replace(- {- name: 'Notes'- },- {- menu: true- }- );- } else {- Navigation.goBack();- }+ eSendEvent(eCloseLoginDialog);- tabBarRef.current?.unlock();- if (!SettingsService.get().introCompleted) {- SettingsService.set({- introCompleted: true- });- }+ // if (initialAuthMode.current === 2) {+ // Navigation.replace(+ // {+ // name: 'Notes'+ // },+ // {+ // menu: true+ // }+ // );+ // } else {+ // Navigation.goBack();+ // }++ // tabBarRef.current?.unlock();}diff --git a/apps/mobile/src/components/auth/index.js b/apps/mobile/src/components/auth/index.jsindex 69b01f422..732a229cf 100644--- a/apps/mobile/src/components/auth/index.js+++ b/apps/mobile/src/components/auth/index.js@@ -23,7 +23,7 @@ const Auth = ({ navigation, route }) => {initialAuthMode.current = route?.params.mode || AuthMode.login;useNavigationFocus(navigation, {onFocus: () => {- tabBarRef?.current.lock();+ //tabBarRef?.current.lock();initialAuthMode.current = route?.params.mode || AuthMode.login;}});diff --git a/apps/mobile/src/components/header/rightmenus.js b/apps/mobile/src/components/header/rightmenus.jsindex 6148fe33b..73e89bf09 100644--- a/apps/mobile/src/components/header/rightmenus.js+++ b/apps/mobile/src/components/header/rightmenus.js@@ -20,10 +20,7 @@ export const RightMenus = () => {return (<View style={styles.rightBtnContainer}>- {!currentScreen.startsWith('Settings') &&- currentScreen !== 'Auth' &&- currentScreen !== 'Signup' &&- currentScreen !== 'Login' ? (+ {!currentScreen.startsWith('Settings') ? (<IconButtononPress={async () => {SearchService.prepareSearch();diff --git a/apps/mobile/src/components/intro/welcome.js b/apps/mobile/src/components/intro/welcome.jsindex 39b0b9909..d5be4f764 100644--- a/apps/mobile/src/components/intro/welcome.js+++ b/apps/mobile/src/components/intro/welcome.js@@ -1,9 +1,12 @@import React from 'react';import Animated, { FadeInDown } from 'react-native-reanimated';+import { eSendEvent } from '../../services/event-manager';import Navigation from '../../services/navigation';+import SettingsService from '../../services/settings';import { useThemeStore } from '../../stores/use-theme-store';import { getElevation } from '../../utils';import umami from '../../utils/analytics';+import { eOpenLoginDialog } from '../../utils/events';import { SIZE } from '../../utils/size';import { AuthMode } from '../auth';import { Button } from '../ui/button';@@ -44,14 +47,20 @@ export const WelcomeNotice = () => {height={45}width={250}onPress={async () => {- Navigation.navigate(- {- name: 'Auth'- },- {- mode: AuthMode.welcomeSignup- }- );+ eSendEvent(eOpenLoginDialog, AuthMode.welcomeSignup);+ SettingsService.set({+ introCompleted: true+ });+ setTimeout(() => {+ Navigation.replace(+ {+ name: 'Notes'+ },+ {+ canGoBack: false+ }+ );+ }, 1000);umami.pageView('/encryptionnotice', '/welcome/privacymode');}}style={{diff --git a/apps/mobile/src/components/launcher/index.js b/apps/mobile/src/components/launcher/index.jsindex 325c548da..f0c8d2a72 100644--- a/apps/mobile/src/components/launcher/index.js+++ b/apps/mobile/src/components/launcher/index.js@@ -16,7 +16,7 @@ import { useNoteStore } from '../../stores/use-notes-store';import { useSettingStore } from '../../stores/use-setting-store';import { useThemeStore } from '../../stores/use-theme-store';import { useUserStore } from '../../stores/use-user-store';-import { db } from '../../utils/database';+import { db, loadDatabase } from '../../utils/database';import { MMKV } from '../../utils/database/mmkv';import { eOpenAnnouncementDialog } from '../../utils/events';import { tabBarRef } from '../../utils/global-refs';@@ -68,7 +68,8 @@ const Launcher = React.memo(const init = async () => {if (!dbInitCompleted.current) {- await RNBootSplash.hide();+ if (!verifyUser) await RNBootSplash.hide({ fade: true });+ await loadDatabase();await db.init();dbInitCompleted.current = true;}@@ -125,18 +126,16 @@ const Launcher = React.memo(};const checkAppUpdateAvailable = async () => {- return;- // try {- // const version = await checkVersion();- // if (!version.needsUpdate) return false;- // presentSheet({- // component: ref => <Update version={version} fwdRef={ref} />- // });-- // return true;- // } catch (e) {- // return false;- // }+ try {+ const version = await checkVersion();+ if (!version.needsUpdate) return false;+ presentSheet({+ component: ref => <Update version={version} fwdRef={ref} />+ });+ return true;+ } catch (e) {+ return false;+ }};const restoreEditorState = async () => {diff --git a/apps/mobile/src/components/sheets/progress/index.tsx b/apps/mobile/src/components/sheets/progress/index.tsxindex 40d616dea..44f2fa80d 100644--- a/apps/mobile/src/components/sheets/progress/index.tsx+++ b/apps/mobile/src/components/sheets/progress/index.tsx@@ -1,11 +1,11 @@import React, { useEffect, useState } from 'react';import { View } from 'react-native';-import * as ProgressBar from 'react-native-progress';import { presentSheet } from '../../../services/event-manager';import { useThemeStore } from '../../../stores/use-theme-store';import useSyncProgress from '../../../utils/hooks/use-sync-progress';import { SIZE } from '../../../utils/size';import Seperator from '../../ui/seperator';+import { ProgressBarComponent } from '../../ui/svg/lazy';import Heading from '../../ui/typography/heading';import Paragraph from '../../ui/typography/paragraph';@@ -41,16 +41,18 @@ export const Progress = () => {width: 200}}>- <ProgressBar.Bar- height={5}- width={null}- animated={true}- useNativeDriver- progress={currentProgress || 0.1}- unfilledColor={colors.nav}- color={colors.accent}- borderWidth={0}- />+ <React.Suspense fallback={<View />}>+ <ProgressBarComponent+ height={5}+ width={null}+ animated={true}+ useNativeDriver+ progress={currentProgress || 0.1}+ unfilledColor={colors.nav}+ color={colors.accent}+ borderWidth={0}+ />+ </React.Suspense></View>{progress ? (diff --git a/apps/mobile/src/components/sheets/recoverykey/index.js b/apps/mobile/src/components/sheets/recoverykey/index.jsindex 04eedb17b..d4406b8da 100644--- a/apps/mobile/src/components/sheets/recoverykey/index.js+++ b/apps/mobile/src/components/sheets/recoverykey/index.js@@ -2,7 +2,6 @@ import Clipboard from '@react-native-clipboard/clipboard';import React, { createRef } from 'react';import { Platform, View } from 'react-native';import FileViewer from 'react-native-file-viewer';-import QRCode from 'react-native-qrcode-svg';import * as ScopedStorage from 'react-native-scoped-storage';import Share from 'react-native-share';//import { LOGO_BASE64 } from '../../../assets/images/assets';@@ -19,6 +18,7 @@ import DialogHeader from '../../dialog/dialog-header';import { Button } from '../../ui/button';import Seperator from '../../ui/seperator';import SheetWrapper from '../../ui/sheet';+import { QRCode } from '../../ui/svg/lazy';import Paragraph from '../../ui/typography/paragraph';let RNFetchBlob;@@ -241,13 +241,15 @@ class RecoveryKeySheet extends React.Component {}}>{this.state.key ? (- <QRCode- getRef={this.svg}- size={500}- value={this.state.key}- //logo={{ uri: LOGO_BASE64 }}- logoBorderRadius={10}- />+ <React.Suspense>+ <QRCode+ getRef={this.svg}+ size={500}+ value={this.state.key}+ //logo={{ uri: LOGO_BASE64 }}+ logoBorderRadius={10}+ />+ </React.Suspense>) : null}</View>diff --git a/apps/mobile/src/components/sheets/update/index.js b/apps/mobile/src/components/sheets/update/index.jsindex 1d5f7cb9d..7d6d8c509 100644--- a/apps/mobile/src/components/sheets/update/index.js+++ b/apps/mobile/src/components/sheets/update/index.js@@ -12,7 +12,7 @@ import Paragraph from '../../ui/typography/paragraph';import Config from 'react-native-config';import deviceInfoModule from 'react-native-device-info';import { checkVersion } from 'react-native-check-version';-import * as Progress from 'react-native-progress';+import { ProgressBarComponent } from '../../ui/svg/lazy';const UPDATE_SVG = color =>`<svg data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" width="774" height="669.5" viewBox="0 0 774 669.5" xmlns:xlink="http://www.w3.org/1999/xlink"><path d="M938.2145,322.3829C936.73266,207.5841,878.16775,115.25,806.13079,115.25c-43.29082,0-81.71777,33.346-105.81477,84.87331l28.33157,71.08654-39.15446-43.81576c-9.876,29.64743-15.48115,63.49569-15.48115,99.44475a324.20917,324.20917,0,0,0,9.98686,80.80891l75.92761-12.24058-67.9507,37.99628c22.13728,60.69069,62.59851,102.1414,109.23586,104.87608l-8.988,244.5184,27.81449.99338-5.94527-245.75716c66.41162-6.32443,119.60967-91.20375,123.8712-197.42794l-45.89372-25.66252Z" transform="translate(-213 -115.25)" fill="#f0f0f0"/><rect x="157.51532" y="354.40187" width="6.60151" height="49.25266" fill="${color}"/><polygon points="187.815 376.276 182.98 380.779 160.823 356.936 138.658 380.779 133.823 376.276 160.823 347.243 187.815 376.276" fill="${color}"/><path d="M371.9876,543.6602a52.8121,52.8121,0,1,1,52.8121-52.81209A52.87183,52.87183,0,0,1,371.9876,543.6602Zm0-99.02268a46.21059,46.21059,0,1,0,46.21058,46.21059A46.26275,46.26275,0,0,0,371.9876,444.63752Z" transform="translate(-213 -115.25)" fill="${color}"/><rect x="212.75248" y="253.9314" width="3.63974" height="27.15545" fill="#e4e4e4"/><polygon points="229.458 265.992 226.793 268.475 214.576 255.328 202.356 268.475 199.69 265.992 214.576 249.984 229.458 265.992" fill="#e4e4e4"/><path d="M426.56422,409.9859a29.118,29.118,0,1,1,29.118-29.118A29.15089,29.15089,0,0,1,426.56422,409.9859Zm0-54.59616A25.47821,25.47821,0,1,0,452.04243,380.868,25.507,25.507,0,0,0,426.56422,355.38974Z" transform="translate(-213 -115.25)" fill="#e4e4e4"/><rect x="99.52274" y="186.73872" width="3.63974" height="27.15545" fill="#e4e4e4"/><polygon points="116.229 198.799 113.563 201.282 101.346 188.136 89.126 201.282 86.46 198.799 101.346 182.792 116.229 198.799" fill="#e4e4e4"/><path d="M313.33448,342.79321a29.118,29.118,0,1,1,29.118-29.118A29.15088,29.15088,0,0,1,313.33448,342.79321Zm0-54.59615a25.47821,25.47821,0,1,0,25.47821,25.4782A25.507,25.507,0,0,0,313.33448,288.19706Z" transform="translate(-213 -115.25)" fill="#e4e4e4"/><path d="M518.7325,635.91942a8.22484,8.22484,0,0,1,.958-12.302,9.56322,9.56322,0,0,1,1.26081-.83521l-6.99347-30.13439,16.26512,5.84042,4.14749,27.72073a8.21849,8.21849,0,0,1-2.21462,10.58849A10.12952,10.12952,0,0,1,518.7325,635.91942Z" transform="translate(-213 -115.25)" fill="#ffb8b8"/><path d="M516.88531,612.40706l-.08727-.29605c-8.79267-29.805-17.88169-60.6154-28.97824-94.16236l-.0728-.21977.2448-.13088c6.18493-3.30762,15.48114-3.08736,21.62358.51183,5.68293,3.33,8.55569,9.77159,7.0024,15.68347l8.09328,38.67327c3.29039,12.64158,6.69574,25.72668,9.95036,38.62892l.09229.36576-.504.0295c-5.92592.34536-12.04821.70254-16.95322.89973Z" transform="translate(-213 -115.25)" fill="#ccc"/><polygon points="229.16 657.57 217.627 657.57 212.138 616.801 229.16 616.801 229.16 657.57" fill="#ffb8b8"/><path d="M445.10175,783.06559H407.9141v-.43107c0-7.31472,6.49345-13.26551,14.47493-13.26551h22.71272Z" transform="translate(-213 -115.25)" fill="#2f2e41"/><polygon points="337.837 648.851 326.848 652.06 308.113 614.743 324.331 610.006 337.837 648.851" fill="#ffb8b8"/><path d="M521.60173,783.39141l-.14262-.41086c-2.42325-6.96953,1.79234-14.4459,9.39693-16.66692l21.64062-6.31955,4.53736,13.05Z" transform="translate(-213 -115.25)" fill="#2f2e41"/><ellipse cx="279.46347" cy="354.21043" rx="23.10522" ry="21.17504" fill="#ffb8b8"/><path d="M502.83713,465.536c.13132-8.54065-3.76885-16.99907-9.79916-21.25171a16.77762,16.77762,0,0,0-19.87954.322c-5.937,4.44645-9.65428,13.02823-9.33974,21.56167C477.12124,466.20257,490.42379,466.23726,502.83713,465.536Z" transform="translate(-213 -115.25)" fill="#2f2e41"/><path d="M448.74454,759.69687l-.46255-.04125c-10.03358-.90255-20.40891-1.83457-30.21419-1.9415l-.5333-.00589.07281-.48411c2.32311-15.42,3.30793-31.45044,4.26037-46.9538.9405-15.308,1.91269-31.13682,4.17769-46.17039.95818-4.0257,1.892-8.00342,2.82264-11.96682,7.70037-32.79837,14.97378-63.77816,29.98728-94.44433l.14194-.28963.34381.03789c14.08679,1.56221,27.62283,6.27241,38.11391,13.26256l.20326.13513-.00988.23027a131.25944,131.25944,0,0,0-.10174,14.17269,44.82523,44.82523,0,0,1,7.48241,42.489c4.13084,12.65215,8.40154,25.73075,12.75907,38.63212,10.5818,26.587,21.53153,54.10056,32.75594,81.99045l.1842.45717-.51791.11114c-8.07587,1.73775-16.40668,3.52938-24.62518,4.22482l-.31028.0261-.14745-.25174a587.30717,587.30717,0,0,1-50.88262-112.12662c-2.80473,7.83882-6.84508,14.91443-10.75934,21.76819a157.11556,157.11556,0,0,0-9.86087,19.31354c-1.73239,13.0365-2.192,27.16078-2.63591,40.81947-.42007,12.91442-.81671,25.11236-2.19312,36.582Z" transform="translate(-213 -115.25)" fill="#2f2e41"/><path d="M484.57528,444.67592c10.01507-1.97751,21.093-.09617,28.95819,6.09651s11.85919,16.9058,8.62805,26.09364-14.20114,15.65236-24.12,13.27969c2.84131-7.33881-.35623-16.34918-7.302-20.57639C482.50242,464.55626,480.23475,452.58775,484.57528,444.67592Z" transform="translate(-213 -115.25)" fill="#2f2e41"/><path d="M496.73471,571.62025l-.36633-.15281c-12.77629-5.34207-25.30408-9.441-37.04181-13.18089l-.35989-.07114-.00092-.95644.23358.07451c.04915-.09935.1045-.21217.16008-.32456.16031-.325.26963-.54642.36264-.69292l-.00252-.00126c.97862-1.82742,1.75651-3.59337,2.50868-5.30123.77628-1.76259,1.5776-3.58243,2.61295-5.50793a15.68833,15.68833,0,0,1-4.02289-17.95719c2.593-5.63211,9.20424-10.01859,16.15083-10.74644,2.54543-6.42185,8.21712-19.91552,8.21712-19.91552s11.92674-.30015,16.72316-.85793l.08062-.00926.07923.016c10.4711,2.10273,19.213,11.1834,21.25846,22.08265,1.72665,9.199-.89525,19.721-7.38227,29.62807A128.7532,128.7532,0,0,1,504.93,561.61682c-2.92186,3.34837-5.68157,6.51067-7.97367,9.69571Z" transform="translate(-213 -115.25)" fill="#ccc"/><path d="M519.3919,459.10521v0Z" transform="translate(-213 -115.25)" fill="#2f2e41"/><path d="M519.861,457.22412c-7.01076-.95907-12.51527-7.52688-11.71835-13.982s7.76344-11.72977,14.83079-11.22907,13.06654,6.694,12.77147,13.18459S528.81221,458.44864,519.861,457.22412Z" transform="translate(-213 -115.25)" fill="#2f2e41"/><path d="M518.76646,453.03852c-7.01067-.95906-12.51516-7.52688-11.71821-13.98194.54524-4.41578,3.9788-8.27657,8.35539-10.11667-5.65378,1.13408-10.51956,5.64916-11.17757,10.97881-.79695,6.45506,4.70754,13.02288,11.71821,13.98195a14.465,14.465,0,0,0,7.6875-.98538A14.866,14.866,0,0,1,518.76646,453.03852Z" transform="translate(-213 -115.25)" fill="#2f2e41"/><path d="M382.77632,566.82181a9.99626,9.99626,0,0,1,12.97554-3.271,9.61149,9.61149,0,0,1,1.27935.81118l28.67233-16.08336-.58936,16.00057-27.13738,12.82a10.15042,10.15042,0,0,1-11.63139,1.61428A8.34216,8.34216,0,0,1,382.77632,566.82181Z" transform="translate(-213 -115.25)" fill="#ffb8b8"/><path d="M406.35053,557.3917l.2755-.17406c27.73394-17.52829,56.40359-35.64765,87.2197-56.41349l.20185-.13613.21621.16792c5.46363,4.24233,8.33439,12.34854,6.67808,18.85539-1.5324,6.02009-7.20243,10.64869-13.80215,11.27624L450.049,550.84631c-11.90943,7.05521-24.23685,14.35751-36.42636,21.46865l-.34555.20162-.19828-.42571c-2.32974-5.0055-4.73707-10.17674-6.57422-14.34943Z" transform="translate(-213 -115.25)" fill="#ccc"/><path d="M986,784.75H214a1,1,0,0,1,0-2H986a1,1,0,0,1,0,2Z" transform="translate(-213 -115.25)" fill="#cacaca"/></svg>`;@@ -82,14 +82,16 @@ export const Update = ({ version: appVersion, fwdRef }) => {>{!version ? (<>- <Progress.Bar- size={SIZE.xxl}- indeterminate={true}- color={colors.accent}- borderWidth={0}- height={5}- width={250}- />+ <React.Suspense fallback={<View />}>+ <ProgressBarComponent+ size={SIZE.xxl}+ indeterminate={true}+ color={colors.accent}+ borderWidth={0}+ height={5}+ width={250}+ />+ </React.Suspense><Paragraphstyle={{marginTop: 5diff --git a/apps/mobile/src/components/sidemenu/userstatus.js b/apps/mobile/src/components/sidemenu/userstatus.jsindex 846e33a6b..e052ad753 100644--- a/apps/mobile/src/components/sidemenu/userstatus.js+++ b/apps/mobile/src/components/sidemenu/userstatus.js@@ -13,9 +13,9 @@ import Heading from '../ui/typography/heading';import Paragraph from '../ui/typography/paragraph';import { TimeSince } from '../ui/time-since';import useSyncProgress from '../../utils/hooks/use-sync-progress';-import * as Progress from 'react-native-progress';import Navigation from '../../services/navigation';import { tabBarRef } from '../../utils/global-refs';+import { ProgressCircleComponent } from '../ui/svg/lazy';export const UserStatus = () => {const colors = useThemeStore(state => state.colors);@@ -48,15 +48,7 @@ export const UserStatus = () => {await Sync.run();} else {tabBarRef.current?.closeDrawer();- Navigation.navigate(- {- name: 'Login'- },- {- mode: 0,- canGoBack: true- }- );+ eSendEvent(eOpenLoginDialog);}}}type="gray"@@ -118,18 +110,20 @@ export const UserStatus = () => {{user ? (syncing ? (<>- <Progress.Circle- size={SIZE.xl}- progress={progress ? progress.current / progress.total : 0.1}- textStyle={{- fontSize: 8- }}- animated={true}- color={colors.accent}- unfilledColor={colors.nav}- borderWidth={0}- thickness={2}- />+ <React.Suspense fallback={<View />}>+ <ProgressCircleComponent+ size={SIZE.xl}+ progress={progress ? progress.current / progress.total : 0.1}+ textStyle={{+ fontSize: 8+ }}+ animated={true}+ color={colors.accent}+ unfilledColor={colors.nav}+ borderWidth={0}+ thickness={2}+ />+ </React.Suspense></>) : (<Icon color={colors.accent} name="sync" size={SIZE.lg} />diff --git a/apps/mobile/src/components/ui/input/index.tsx b/apps/mobile/src/components/ui/input/index.tsxindex 1fa49fb15..11d978698 100644--- a/apps/mobile/src/components/ui/input/index.tsx+++ b/apps/mobile/src/components/ui/input/index.tsx@@ -21,7 +21,6 @@ import { getElevation } from '../../../utils';import { SIZE } from '../../../utils/size';import { IconButton } from '../icon-button';import Paragraph from '../typography/paragraph';-import phone from 'phone';interface InputProps extends TextInputProps {fwdRef?: RefObject<any>;@@ -91,7 +90,7 @@ const Input = ({const color = error ? colors.red : focus ? customColor || colors.accent : colors.nav;- const validate = (value: string) => {+ const validate = async (value: string) => {if (!validationType) return;if (!value || value?.length === 0) {setError(false);@@ -117,6 +116,8 @@ const Input = ({isError = customValidator && value === customValidator();break;case 'phonenumber':+ // eslint-disable-next-line no-case-declarations+ const phone = await (await import('phone')).default;// eslint-disable-next-line no-case-declarationslet result = phone(value, {strictDetection: true,diff --git a/apps/mobile/src/components/ui/svg/index.tsx b/apps/mobile/src/components/ui/svg/index.tsxindex 2eb57bebe..613f4c01d 100644--- a/apps/mobile/src/components/ui/svg/index.tsx+++ b/apps/mobile/src/components/ui/svg/index.tsx@@ -1,6 +1,6 @@import React from 'react';import { View } from 'react-native';-import { SvgXml } from 'react-native-svg';+import { SvgXml } from './lazy';export const SvgView = ({width = 250,@@ -19,7 +19,9 @@ export const SvgView = ({width: height || 250}}>- <SvgXml xml={src} width="100%" height="100%" />+ <React.Suspense fallback={<View />}>+ <SvgXml xml={src} width="100%" height="100%" />+ </React.Suspense></View>);};diff --git a/apps/mobile/src/components/ui/svg/lazy.js b/apps/mobile/src/components/ui/svg/lazy.jsnew file mode 100644index 000000000..ed60ba072--- /dev/null+++ b/apps/mobile/src/components/ui/svg/lazy.js@@ -0,0 +1,29 @@+import React from 'react';++export const QRCode = React.lazy(async () => {+ const module = await (await import('./module-svg')).default;+ return {+ default: module.QRCode+ };+});++export const SvgXml = React.lazy(async () => {+ const module = await (await import('./module-svg')).default;+ return {+ default: module.SvgXml+ };+});++export const ProgressBarComponent = React.lazy(async () => {+ const module = await (await import('./module-svg')).default;+ return {+ default: module.Progress.Bar+ };+});++export const ProgressCircleComponent = React.lazy(async () => {+ const module = await (await import('./module-svg')).default;+ return {+ default: module.Progress.Circle+ };+});diff --git a/apps/mobile/src/components/ui/svg/module_svg.js b/apps/mobile/src/components/ui/svg/module_svg.jsnew file mode 100644index 000000000..6a34cac0f--- /dev/null+++ b/apps/mobile/src/components/ui/svg/module_svg.js@@ -0,0 +1,11 @@+/* eslint-disable @typescript-eslint/no-var-requires */+import { Bar, Circle } from 'react-native-progress';+import QRCode from 'react-native-qrcode-svg';+import { SvgXml } from 'react-native-svg';++const Progress = {+ Bar,+ Circle+};++export default { Progress, QRCode, SvgXml };diff --git a/apps/mobile/src/navigation/index.js b/apps/mobile/src/navigation/index.jsindex 3ed07be37..4b2b93ea3 100644--- a/apps/mobile/src/navigation/index.js+++ b/apps/mobile/src/navigation/index.js@@ -1,17 +1,18 @@import React from 'react';+import { View } from 'react-native';import DelayLayout from '../components/delay-layout';-import DialogProvider from '../components/dialog-provider';import { Header } from '../components/header';-import Intro from '../components/intro';import { Toast } from '../components/toast';-import SettingsService from '../services/settings';import { useNoteStore } from '../stores/use-notes-store';+import { useSettingStore } from '../stores/use-setting-store';import { TabsHolder } from './tabs-holder';+const DialogProvider = React.lazy(() => import('../components/dialogprovider'));+export const ApplicationHolder = React.memo(() => {const loading = useNoteStore(state => state.loading);- const introCompleted = SettingsService.get().introCompleted;+ const introCompleted = useSettingStore(state => state.settings.introCompleted);return loading && introCompleted ? (<><Header />@@ -21,7 +22,9 @@ export const ApplicationHolder = React.memo(<><TabsHolder /><Toast />- <DialogProvider />+ <React.Suspense fallback={<View />}>+ <DialogProvider />+ </React.Suspense></>);},diff --git a/apps/mobile/src/navigation/navigationstack.js b/apps/mobile/src/navigation/navigationstack.jsindex 70a3a717d..7a4564acc 100644--- a/apps/mobile/src/navigation/navigationstack.js+++ b/apps/mobile/src/navigation/navigationstack.js@@ -1,9 +1,6 @@import { NavigationContainer } from '@react-navigation/native';import { createNativeStackNavigator } from '@react-navigation/native-stack';import * as React from 'react';-import Auth from '../components/auth';-import { Login } from '../components/auth/login';-import { Signup } from '../components/auth/signup';import Container from '../components/container';import Intro from '../components/intro';import Favorites from '../screens/favorites';@@ -41,7 +38,6 @@ const IntroStack = createNativeStackNavigator();const IntroStackNavigator = () => {const colors = useThemeStore(state => state.colors);- const introCompleted = SettingsService.get().introCompleted;return (<IntroStack.NavigatorscreenOptions={{@@ -56,13 +52,6 @@ const IntroStackNavigator = () => {><NativeStack.Screen name="Intro" component={Intro} /><NativeStack.Screen name="AppLock" component={AppLock} />- <NativeStack.Screen- name="Auth"- initialParams={{- mode: 0- }}- component={Auth}- /></IntroStack.Navigator>);};@@ -92,20 +81,6 @@ const Tabs = React.memo(}}}>- <NativeStack.Screen- name="Signup"- initialParams={{- mode: 1- }}- component={Auth}- />- <NativeStack.Screen- name="Login"- initialParams={{- mode: 0- }}- component={Auth}- /><NativeStack.Screen name="Welcome" component={IntroStackNavigator} /><NativeStack.Screen name="Notes" component={Home} /><NativeStack.Screen name="Notebooks" component={Notebooks} />diff --git a/apps/mobile/src/screens/editor/progress.js b/apps/mobile/src/screens/editor/progress.jsindex f4a1ff2dc..9059c6cc2 100644--- a/apps/mobile/src/screens/editor/progress.js+++ b/apps/mobile/src/screens/editor/progress.js@@ -1,10 +1,10 @@import React, { useEffect, useRef, useState } from 'react';import { View } from 'react-native';-import * as Progress from 'react-native-progress';import { useThemeStore } from '../../stores/use-theme-store';import { useAttachmentStore } from '../../stores/use-attachment-store';import { SIZE } from '../../utils/size';import { useSafeAreaInsets } from 'react-native-safe-area-context';+import { ProgressBarComponent } from '../../components/ui/svg/lazy';export const ProgressBar = () => {const colors = useThemeStore(state => state.colors);@@ -50,14 +50,16 @@ export const ProgressBar = () => {}}onLayout={event => setWidth(event.nativeEvent.layout.width)}>- <Progress.Bar- size={SIZE.xxl}- progress={prog}- color={colors.accent}- borderWidth={0}- height={1}- width={width || 400}- />+ <React.Suspense fallback={<View />}>+ <ProgressBarComponent+ size={SIZE.xxl}+ progress={prog}+ color={colors.accent}+ borderWidth={0}+ height={1}+ width={width || 400}+ />+ </React.Suspense></View>) : null;};diff --git a/apps/mobile/src/screens/editor/tiptap/useEditor.ts b/apps/mobile/src/screens/editor/tiptap/useEditor.tsindex 839f5353f..9873373c3 100644--- a/apps/mobile/src/screens/editor/tiptap/useEditor.ts+++ b/apps/mobile/src/screens/editor/tiptap/useEditor.ts@@ -72,8 +72,8 @@ export const useEditor = (editorId = '', readonly?: boolean) => {useEffect(() => {console.log('sessionId:', sessionId);async () => {- await commands.setSessionId(sessionId);- if (sessionId) {+ await commands.setSessionId(sessionIdRef.current);+ if (sessionIdRef.current) {if (!state.current?.ready) return;await onReady();}@@ -88,7 +88,7 @@ export const useEditor = (editorId = '', readonly?: boolean) => {};const onReady = useCallback(async () => {- if (!(await isEditorLoaded(editorRef, sessionId))) {+ if (!(await isEditorLoaded(editorRef, sessionIdRef.current))) {console.log('reload editor');overlay(true);setLoading(true);diff --git a/apps/mobile/src/screens/notebooks/index.tsx b/apps/mobile/src/screens/notebooks/index.tsxindex 5c0f96b31..0a8106d28 100644--- a/apps/mobile/src/screens/notebooks/index.tsx+++ b/apps/mobile/src/screens/notebooks/index.tsx@@ -47,21 +47,18 @@ export const Notebooks = ({ navigation, route }: NavigationProps<'Notebooks'>) =});SearchService.prepareSearch = prepareSearch;RightMenus.floatingButtonAction = onPressFloatingButton;- return !prev?.current;- },- onBlur: () => false,- delay: SettingsService.get().homepage === route.name ? 1 : -1- });- useEffect(() => {- if (navigation.isFocused()) {if (notebooks.length === 0) {Walkthrough.present('notebooks');} else {Walkthrough.update('notebooks');}- }- }, [notebooks]);++ return !prev?.current;+ },+ onBlur: () => false,+ delay: SettingsService.get().homepage === route.name ? 1 : -1+ });return (<DelayLayout>diff --git a/apps/mobile/src/screens/settings/home.tsx b/apps/mobile/src/screens/settings/home.tsxindex 7247f1320..dc6d80364 100644--- a/apps/mobile/src/screens/settings/home.tsx+++ b/apps/mobile/src/screens/settings/home.tsx@@ -1,10 +1,10 @@import { NativeStackScreenProps } from '@react-navigation/native-stack';import React, { useEffect, useRef, useState } from 'react';import { FlatList, View } from 'react-native';-import { Bar } from 'react-native-progress';import Animated, { FadeInDown, FadeOutDown } from 'react-native-reanimated';import DelayLayout from '../../components/delay-layout';import BaseDialog from '../../components/dialog/base-dialog';+import { ProgressBarComponent } from '../../components/ui/svg/lazy';import Heading from '../../components/ui/typography/heading';import Paragraph from '../../components/ui/typography/paragraph';import { eSubscribeEvent, eUnSubscribeEvent } from '../../services/event-manager';@@ -71,17 +71,19 @@ const Home = ({ navigation, route }: NativeStackScreenProps<RouteParams, 'SettinmarginTop: 15}}>- <Bar- height={5}- width={100}- animated={true}- useNativeDriver- indeterminate- indeterminateAnimationDuration={2000}- unfilledColor={colors.nav}- color={colors.accent}- borderWidth={0}- />+ <React.Suspense fallback={<View />}>+ <ProgressBarComponent+ height={5}+ width={100}+ animated={true}+ useNativeDriver+ indeterminate+ indeterminateAnimationDuration={2000}+ unfilledColor={colors.nav}+ color={colors.accent}+ borderWidth={0}+ />+ </React.Suspense></View></View></BaseDialog>diff --git a/apps/mobile/src/screens/settings/index.tsx b/apps/mobile/src/screens/settings/index.tsxindex 706424769..1aba06011 100644--- a/apps/mobile/src/screens/settings/index.tsx+++ b/apps/mobile/src/screens/settings/index.tsx@@ -1,9 +1,10 @@-import { createNativeStackNavigator } from '@react-navigation/native-stack';+import { createNativeStackNavigator, NativeStackScreenProps } from '@react-navigation/native-stack';import React from 'react';+import DelayLayout from '../../components/delay-layout';+import { Header } from '../../components/header';import useNavigationStore from '../../stores/use-navigation-store';import { useThemeStore } from '../../stores/use-theme-store';-import Group from './group';-import Home from './home';+import { RouteParams } from './types';const SettingsStack = createNativeStackNavigator();const screenListeners = {@@ -15,6 +16,34 @@ const screenListeners = {}};+const Home = React.lazy(() => import(/* webpackChunkName: "settings-home" */ './home'));+const Group = React.lazy(() => import(/* webpackChunkName: "settings-group" */ './group'));++const Fallback = () => {+ return (+ <>+ <Header />+ <DelayLayout wait={true} type="settings" />+ </>+ );+};++const HomeScreen = (props: NativeStackScreenProps<RouteParams, 'SettingsHome'>) => {+ return (+ <React.Suspense fallback={<Fallback />}>+ <Home {...props} />+ </React.Suspense>+ );+};++const GroupScreen = (props: NativeStackScreenProps<RouteParams, 'SettingsGroup'>) => {+ return (+ <React.Suspense fallback={<Fallback />}>+ <Group {...props} />+ </React.Suspense>+ );+};+export const Settings = () => {const colors = useThemeStore(state => state.colors);return (@@ -29,8 +58,8 @@ export const Settings = () => {}}}>- <SettingsStack.Screen name="SettingsHome" component={Home} />- <SettingsStack.Screen name="SettingsGroup" component={Group} />+ <SettingsStack.Screen name="SettingsHome" component={HomeScreen} />+ <SettingsStack.Screen name="SettingsGroup" component={GroupScreen} /></SettingsStack.Navigator>);};diff --git a/apps/mobile/src/utils/database/index.js b/apps/mobile/src/utils/database/index.jsindex 65aad2740..ce0be4425 100644--- a/apps/mobile/src/utils/database/index.js+++ b/apps/mobile/src/utils/database/index.js@@ -1,34 +1,46 @@-import Database from 'notes-core/api/index';import { Platform } from 'react-native';import filesystem from '../filesystem';import EventSource from '../sse/even-source-ios';import AndroidEventSource from '../sse/event-source';import Storage from './storage';-export const 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'- }-);+/**+ * @type {import("notes-core/api/index").default}+ */+export var db;++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'+ }+ );+}diff --git a/apps/mobile/src/utils/hooks/useActions.js b/apps/mobile/src/utils/hooks/useActions.jsindex f5d813095..33f806d7e 100644--- a/apps/mobile/src/utils/hooks/useActions.js+++ b/apps/mobile/src/utils/hooks/useActions.js@@ -233,15 +233,7 @@ export const useActions = ({ close = () => {}, item }) => {message: 'Login to publish note',context: 'local',func: () => {- Navigation.navigate(- {- name: 'Login'- },- {- mode: AuthMode.login,- canGoBack: true- }- );+ eSendEvent(eOpenLoginDialog);},actionText: 'Login'});diff --git a/apps/mobile/src/utils/index.js b/apps/mobile/src/utils/index.jsindex b14361442..dfac923a2 100755--- a/apps/mobile/src/utils/index.js+++ b/apps/mobile/src/utils/index.js@@ -126,7 +126,7 @@ export async function toTXT(note, notitle) {} else {text = await db.notes.note(note.id).content();}- htmlToText = htmlToText || require('html-to-text');+ htmlToText = htmlToText || (await import('html-to-text'));text = htmlToText.convert(text, {selectors: [{ selector: 'img', format: 'skip' }]});diff --git a/apps/mobile/webpack.config.cjs b/apps/mobile/webpack.config.cjsnew file mode 100644index 000000000..41e13c3ad--- /dev/null+++ b/apps/mobile/webpack.config.cjs@@ -0,0 +1,271 @@+/* eslint-disable @typescript-eslint/no-var-requires */+const path = require('path');+const TerserPlugin = require('terser-webpack-plugin');+const Repack = require('@callstack/repack');++/**+ * More documentation, installation, usage, motivation and differences with Metro is available at:+ * https://github.com/callstack/repack/blob/main/README.md+ *+ * The API documentation for the functions and plugins used in this file is available at:+ * https://re-pack.netlify.app/+ */++/**+ * Webpack configuration.+ * You can also export a static object or a function returning a Promise.+ *+ * @param env Environment options passed from either Webpack CLI or React Native CLI+ * when running with `react-native start/bundle`.+ */+module.exports = env => {+ const {+ mode = 'development',+ context = __dirname,+ entry = './index.js',+ platform,+ minimize = mode === 'production',+ devServer = undefined,+ bundleFilename = undefined,+ sourceMapFilename = undefined,+ assetsPath = undefined,+ reactNativePath = require.resolve('react-native')+ } = env;++ if (!platform) {+ throw new Error('Missing platform');+ }++ /**+ * Depending on your Babel configuration you might want to keep it.+ * If you don't use `env` in your Babel config, you can remove it.+ *+ * Keep in mind that if you remove it you should set `BABEL_ENV` or `NODE_ENV`+ * to `development` or `production`. Otherwise your production code might be compiled with+ * in development mode by Babel.+ */+ process.env.BABEL_ENV = mode;++ return {+ mode,+ /**+ * This should be always `false`, since the Source Map configuration is done+ * by `SourceMapDevToolPlugin`.+ */+ devtool: false,+ context,+ /**+ * `getInitializationEntries` will return necessary entries with setup and initialization code.+ * If you don't want to use Hot Module Replacement, set `hmr` option to `false`. By default,+ * HMR will be enabled in development mode.+ */+ entry: [+ ...Repack.getInitializationEntries(reactNativePath, {+ hmr: devServer && devServer.hmr+ }),+ entry+ ],+ resolve: {+ /**+ * `getResolveOptions` returns additional resolution configuration for React Native.+ * If it's removed, you won't be able to use `<file>.<platform>.<ext>` (eg: `file.ios.js`)+ * convention and some 3rd-party libraries that specify `react-native` field+ * in their `package.json` might not work correctly.+ */+ ...Repack.getResolveOptions(platform)++ /**+ * Uncomment this to ensure all `react-native*` imports will resolve to the same React Native+ * dependency. You might need it when using workspaces/monorepos or unconventional project+ * structure. For simple/typical project you won't need it.+ */+ // alias: {+ // 'react-native': reactNativePath,+ // },+ },+ /**+ * Configures output.+ * It's recommended to leave it as it is unless you know what you're doing.+ * By default Webpack will emit files into the directory specified under `path`. In order for the+ * React Native app use them when bundling the `.ipa`/`.apk`, they need to be copied over with+ * `Repack.OutputPlugin`, which is configured by default inside `Repack.RepackPlugin`.+ */+ output: {+ clean: true,+ path: path.join(__dirname, 'build/generated', platform),+ filename: 'index.bundle',+ chunkFilename: '[name].chunk.bundle',+ publicPath: Repack.getPublicPath({ platform, devServer })+ },+ /**+ * Configures optimization of the built bundle.+ */+ optimization: {+ /** Enables minification based on values passed from React Native CLI or from fallback. */+ minimize,+ /** Configure minimizer to process the bundle. */+ minimizer: [+ new TerserPlugin({+ test: /\.(js)?bundle(\?.*)?$/i,+ /**+ * Prevents emitting text file with comments, licenses etc.+ * If you want to gather in-file licenses, feel free to remove this line or configure it+ * differently.+ */+ extractComments: false,+ terserOptions: {+ format: {+ comments: false+ }+ }+ })+ ],+ chunkIds: 'named'+ },+ module: {+ /**+ * This rule will process all React Native related dependencies with Babel.+ * If you have a 3rd-party dependency that you need to transpile, you can add it to the+ * `include` list.+ *+ * You can also enable persistent caching with `cacheDirectory` - please refer to:+ * https://github.com/babel/babel-loader#options+ */+ rules: [+ {+ test: /\.[jt]sx?$/,+ include: [+ /node_modules(.*[/\\])+react/,+ /node_modules(.*[/\\])+@react-native/,+ /node_modules(.*[/\\])+@react-navigation/,+ /node_modules(.*[/\\])+@react-native-community/,+ /node_modules(.*[/\\])+@expo/,+ /node_modules(.*[/\\])+pretty-format/,+ /node_modules(.*[/\\])+metro/,+ /node_modules(.*[/\\])+abort-controller/,+ /node_modules(.*[/\\])+@callstack[/\\]repack/,+ /node_modules(.*[/\\])+pretty-format/,+ /node_modules(.*[/\\])+@react-native-masked-view\/masked-view/,+ /node_modules(.*[/\\])+toggle-switch-react-native/,+ /node_modules(.*[/\\])+rn-fetch-blob/,+ /node_modules(.*[/\\])+notes-core/,+ /node_modules(.*[/\\])+@microsoft/,+ /node_modules(.*[/\\])+@msgpack/,+ /node_modules(.*[/\\])+liqe/+ ],+ use: {+ loader: 'babel-loader',+ options: {+ configFile: false,+ cacheDirectory: path.join(__dirname, 'node_modules/.webpack-cache'),+ babelrc: false,+ presets: ['module:metro-react-native-babel-preset'],+ plugins: [+ 'react-native-reanimated/plugin',+ '@babel/plugin-transform-named-capturing-groups-regex'+ ]+ }+ }+ },+ /**+ * Here you can adjust loader that will process your files.+ *+ * You can also enable persistent caching with `cacheDirectory` - please refer to:+ * https://github.com/babel/babel-loader#options+ */+ {+ test: /\.[jt]sx?$/,+ exclude: /node_modules/,+ use: {+ loader: 'babel-loader',+ options: {+ /** Add React Refresh transform only when HMR is enabled. */+ configFile: false,+ cacheDirectory: path.join(__dirname, 'node_modules/.webpack-cache'),+ babelrc: false,+ presets: [+ ['module:metro-react-native-babel-preset', { disableImportExportTransform: true }]+ ],+ plugins:+ devServer && devServer.hmr+ ? ['module:react-refresh/babel', 'react-native-reanimated/plugin']+ : [+ 'react-native-reanimated/plugin',+ `@babel/plugin-transform-named-capturing-groups-regex`+ //'transform-remove-console'+ ]+ }+ }+ },+ /**+ * This loader handles all static assets (images, video, audio and others), so that you can+ * use (reference) them inside your application.+ *+ * If you wan to handle specific asset type manually, filter out the extension+ * from `ASSET_EXTENSIONS`, for example:+ * ```+ * Repack.ASSET_EXTENSIONS.filter((ext) => ext !== 'svg')+ * ```+ */+ {+ test: Repack.getAssetExtensionsRegExp(+ Repack.ASSET_EXTENSIONS.filter(ext => ext !== 'svg')+ ),+ use: {+ loader: '@callstack/repack/assets-loader',+ options: {+ platform,+ devServerEnabled: Boolean(devServer),+ /**+ * Defines which assets are scalable - which assets can have+ * scale suffixes: `@1x`, `@2x` and so on.+ * By default all images are scalable.+ */+ scalableAssetExtensions: Repack.SCALABLE_ASSETS+ }+ }+ },+ {+ test: /\.svg$/,+ use: [+ {+ loader: '@svgr/webpack',+ options: {+ native: true,+ dimensions: false+ }+ }+ ]+ }+ ]+ },+ plugins: [+ /**+ * Configure other required and additional plugins to make the bundle+ * work in React Native and provide good development experience with+ * sensible defaults.+ *+ * `Repack.RepackPlugin` provides some degree of customization, but if you+ * need more control, you can replace `Repack.RepackPlugin` with plugins+ * from `Repack.plugins`.+ */+ new Repack.RepackPlugin({+ context,+ mode,+ platform,+ devServer,+ output: {+ bundleFilename,+ sourceMapFilename,+ assetsPath+ },+ extraChunks: [+ {+ type: 'local',+ include: /.*/+ }+ ]+ })+ ]+ };+};diff --git a/apps/mobile/webpack.config.js b/apps/mobile/webpack_old_configsimilarity index 100%rename from apps/mobile/webpack.config.jsrename to apps/mobile/webpack_old_config