diff --git a/packages/editor-mobile/.env-cmdrc.js b/packages/editor-mobile/.env-cmdrc.js deleted file mode 100644 index 1777bf737..000000000 --- a/packages/editor-mobile/.env-cmdrc.js +++ /dev/null @@ -1,7 +0,0 @@ -module.exports = { - all: { - DISABLE_ESLINT_PLUGIN: true, - GENERATE_SOURCEMAP: true, - BROWSER: "none" - } -}; diff --git a/packages/editor-mobile/package-lock.json b/packages/editor-mobile/package-lock.json index 71fbd1846..e4de89845 100644 --- a/packages/editor-mobile/package-lock.json +++ b/packages/editor-mobile/package-lock.json @@ -29,17 +29,16 @@ "@playwright/test": "^1.37.1", "@types/react": "^18.2.39", "@types/react-dom": "^18.2.17", - "env-cmd": "^10.1.0", "react-scripts": "^5.0.1" } }, "../editor": { "name": "@notesnook/editor", - "version": "2.0.7", + "version": "2.1.1", "hasInstallScript": true, "license": "GPL-3.0-or-later", "dependencies": { - "@notesnook/core": "file:../core", + "@notesnook/common": "file:../common", "@notesnook/theme": "file:../theme", "@notesnook/ui": "file:../ui", "@social-embed/lib": "^0.1.0-next.7", @@ -129,14 +128,14 @@ }, "../theme": { "name": "@notesnook/theme", - "version": "2.0.7", + "version": "2.1.1", "license": "GPL-3.0-or-later", "devDependencies": { "@emotion/react": "11.11.1", "@theme-ui/color": "^0.16.1", "@theme-ui/components": "^0.16.1", "@theme-ui/core": "^0.16.1", - "@trpc/server": "^10.31.0", + "@trpc/server": "^10.45.2", "@types/react": "^18.2.39", "@types/tinycolor2": "^1.4.3", "isomorphic-fetch": "^3.0.0", @@ -4382,7 +4381,7 @@ "version": "15.7.11", "resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.11.tgz", "integrity": "sha512-ga8y9v9uyeiLdpKddhxYQkxNDrfvuPrlFb0N1qnZZByvcElJaXthF1UhvCh9TLWJBEHeNtdnbysW7Y6Uq8CVng==", - "dev": true + "devOptional": true }, "node_modules/@types/q": { "version": "1.5.8", @@ -4406,7 +4405,7 @@ "version": "18.2.39", "resolved": "https://registry.npmjs.org/@types/react/-/react-18.2.39.tgz", "integrity": "sha512-Oiw+ppED6IremMInLV4HXGbfbG6GyziY3kqAwJYOR0PNbkYDmLWQA3a95EhdSmamsvbkJN96ZNN+YD+fGjzSBA==", - "dev": true, + "devOptional": true, "dependencies": { "@types/prop-types": "*", "@types/scheduler": "*", @@ -4441,7 +4440,7 @@ "version": "0.16.8", "resolved": "https://registry.npmjs.org/@types/scheduler/-/scheduler-0.16.8.tgz", "integrity": "sha512-WZLiwShhwLRmeV6zH+GkbOFT6Z6VklCItrDioxUnv+u4Ll+8vKeFySoFyK/0ctcRpOmwAicELfmys1sDc/Rw+A==", - "dev": true + "devOptional": true }, "node_modules/@types/semver": { "version": "7.5.6", @@ -7421,22 +7420,6 @@ "url": "https://github.com/fb55/entities?sponsor=1" } }, - "node_modules/env-cmd": { - "version": "10.1.0", - "resolved": "https://registry.npmjs.org/env-cmd/-/env-cmd-10.1.0.tgz", - "integrity": "sha512-mMdWTT9XKN7yNth/6N6g2GuKuJTsKMDHlQFUDacb/heQRRWOTIZ42t1rMHnQu4jYxU1ajdTeJM+9eEETlqToMA==", - "dev": true, - "dependencies": { - "commander": "^4.0.0", - "cross-spawn": "^7.0.0" - }, - "bin": { - "env-cmd": "bin/env-cmd.js" - }, - "engines": { - "node": ">=8.0.0" - } - }, "node_modules/error-ex": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz", @@ -9742,7 +9725,7 @@ "version": "9.0.21", "resolved": "https://registry.npmjs.org/immer/-/immer-9.0.21.tgz", "integrity": "sha512-bc4NBHqOqSfRW7POMkHd51LvClaeMXpm8dx0e8oE2GORbq5aRK7Bxl4FyzVLdGtLmvLKL7BTDBG5ACQm4HWjTA==", - "dev": true, + "devOptional": true, "funding": { "type": "opencollective", "url": "https://opencollective.com/immer" @@ -17828,6 +17811,20 @@ "is-typedarray": "^1.0.0" } }, + "node_modules/typescript": { + "version": "4.9.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz", + "integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==", + "dev": true, + "peer": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=4.2.0" + } + }, "node_modules/unbox-primitive": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.2.tgz", diff --git a/packages/editor-mobile/package.json b/packages/editor-mobile/package.json index 078f3946c..3a0a7b725 100644 --- a/packages/editor-mobile/package.json +++ b/packages/editor-mobile/package.json @@ -23,12 +23,12 @@ "@playwright/test": "^1.37.1", "@types/react": "^18.2.39", "@types/react-dom": "^18.2.17", - "env-cmd": "^10.1.0", "react-scripts": "^5.0.1" }, "scripts": { - "start": "env-cmd -e all react-scripts start", - "build": "env-cmd -e all react-scripts build && rm -rf build.bundle && rm -rf sourcemaps && mv build build.bundle && cp -r ./build.bundle/static/js/ sourcemaps && rm -r ./build.bundle/static/js/*.map", + "start": "cross-env DISABLE_ESLINT_PLUGIN=true GENERATE_SOURCEMAP=true BROWSER=none react-scripts start", + "build": "cross-env DISABLE_ESLINT_PLUGIN=true GENERATE_SOURCEMAP=true BROWSER=none react-scripts build", + "postbuild": "node scripts/build.mjs", "test": "react-scripts test", "eject": "react-scripts eject", "postinstall": "patch-package" diff --git a/packages/editor-mobile/scripts/build.mjs b/packages/editor-mobile/scripts/build.mjs new file mode 100644 index 000000000..981da3939 --- /dev/null +++ b/packages/editor-mobile/scripts/build.mjs @@ -0,0 +1,39 @@ +/* +This file is part of the Notesnook project (https://notesnook.com/) + +Copyright (C) 2023 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 . +*/ + +import { rm, cp, readdir } from "fs/promises"; +import path from "path"; + +await rm("build.bundle", { recursive: true, force: true }); +await rm("sourcemaps", { recursive: true, force: true }); + +await cp("build", "build.bundle", { recursive: true }); +await rm("build", { recursive: true, force: true }); + +await cp(path.join("build.bundle", "static", "js"), "sourcemaps", { + recursive: true +}); + +for (const dirent of await readdir(path.join("build.bundle", "static", "js"), { + withFileTypes: true +})) { + if (dirent.isFile() && dirent.name.endsWith(".map")) { + await rm(path.join("build.bundle", "static", "js", dirent.name)); + } +} diff --git a/packages/editor-mobile/src/App.tsx b/packages/editor-mobile/src/App.tsx index 22a4877fc..0a840e3ae 100644 --- a/packages/editor-mobile/src/App.tsx +++ b/packages/editor-mobile/src/App.tsx @@ -17,6 +17,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +import "./polyfill"; import { Global, css } from "@emotion/react"; import { ScopedThemeProvider, diff --git a/packages/editor-mobile/src/components/editor.tsx b/packages/editor-mobile/src/components/editor.tsx index 190fd44d4..06b77bdfa 100644 --- a/packages/editor-mobile/src/components/editor.tsx +++ b/packages/editor-mobile/src/components/editor.tsx @@ -24,7 +24,7 @@ import { TiptapOptions, usePermissionHandler } from "@notesnook/editor"; -import { toBlobURL } from "@notesnook/editor/dist/utils/downloader"; +import { toBlobURL } from "@notesnook/editor"; import { useThemeColors } from "@notesnook/theme"; import FingerprintIcon from "mdi-react/FingerprintIcon"; import { diff --git a/packages/editor-mobile/src/components/title.tsx b/packages/editor-mobile/src/components/title.tsx index 756f3107c..751122c5f 100644 --- a/packages/editor-mobile/src/components/title.tsx +++ b/packages/editor-mobile/src/components/title.tsx @@ -18,7 +18,7 @@ along with this program. If not, see . */ import { getFontById } from "@notesnook/editor"; -import { replaceDateTime } from "@notesnook/editor/dist/extensions/date-time"; +import { replaceDateTime } from "@notesnook/editor"; import React, { RefObject, useCallback, useEffect, useRef } from "react"; import { EditorController } from "../hooks/useEditorController"; import { useTabContext } from "../hooks/useTabStore"; diff --git a/packages/editor-mobile/src/polyfill.ts b/packages/editor-mobile/src/polyfill.ts new file mode 100644 index 000000000..316cfff28 --- /dev/null +++ b/packages/editor-mobile/src/polyfill.ts @@ -0,0 +1,24 @@ +/* +This file is part of the Notesnook project (https://notesnook.com/) + +Copyright (C) 2023 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 . +*/ + +import { Buffer } from "buffer/"; + +// eslint-disable-next-line @typescript-eslint/ban-ts-comment +// @ts-expect-error +globalThis.Buffer = Buffer;