Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

monograph: use public url

Abdullah Atta9bf490bcb418
diff --git a/apps/monograph/app/global.d.ts b/apps/monograph/app/global.d.ts
new file mode 100644
index 000000000..f3dae195f
--- /dev/null
+++ b/apps/monograph/app/global.d.ts
@@ -0,0 +1,23 @@
+/*
+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 <http://www.gnu.org/licenses/>.
+*/
+/* eslint-disable no-var */
+
+declare global {
+ var PUBLIC_URL: string;
+}
diff --git a/apps/monograph/app/routes/$id.tsx b/apps/monograph/app/routes/$id.tsx
index 6e24ea32d..1233aea69 100644
--- a/apps/monograph/app/routes/$id.tsx
+++ b/apps/monograph/app/routes/$id.tsx
@@ -44,7 +44,7 @@ type Monograph = {
type MonographResponse = Omit<Monograph, "content"> & { content: string };
export const meta: MetaFunction<typeof loader> = ({ data }) => {
- const imageUrl = `/og.png?${new URLSearchParams({
+ const imageUrl = `${PUBLIC_URL}/og.png?${new URLSearchParams({
title: data?.metadata?.title || "",
description: Buffer.from(
data?.metadata?.fullDescription || "",
diff --git a/apps/monograph/package-lock.json b/apps/monograph/package-lock.json
index bec433bc3..2bca6d961 100644
--- a/apps/monograph/package-lock.json
+++ b/apps/monograph/package-lock.json
@@ -7,12 +7,12 @@
"": {
"name": "monograph",
"version": "1.0.0",
+ "hasInstallScript": true,
"dependencies": {
"@emotion/cache": "11.11.0",
"@emotion/react": "11.11.1",
"@emotion/server": "11.11.0",
"@mdi/js": "^7.4.47",
- "@mdi/react": "^1.6.1",
"@notesnook/core": "file:../../packages/core",
"@notesnook/crypto": "file:../../packages/crypto",
"@notesnook/editor": "file:../../packages/editor",
@@ -215,7 +215,6 @@
"devDependencies": {
"@emotion/react": "11.11.1",
"@mdi/js": "^7.4.47",
- "@mdi/react": "^1.6.1",
"@theme-ui/components": "^0.16.2",
"@theme-ui/core": "^0.16.2",
"@types/katex": "^0.16.7",
@@ -240,7 +239,6 @@
"peerDependencies": {
"@emotion/react": ">=11",
"@mdi/js": ">=7.2.96",
- "@mdi/react": ">=1.6.1",
"@theme-ui/components": ">=0.16.0",
"@theme-ui/core": ">=0.16.0",
"framer-motion": ">=11",
@@ -289,7 +287,6 @@
"devDependencies": {
"@emotion/react": "11.11.1",
"@mdi/js": "^7.2.96",
- "@mdi/react": "^1.6.1",
"@theme-ui/components": "^0.16.1",
"@theme-ui/core": "^0.16.1",
"@types/react": "^18.2.39",
@@ -304,7 +301,6 @@
"peerDependencies": {
"@emotion/react": ">=11",
"@mdi/js": ">=7",
- "@mdi/react": ">=1",
"@theme-ui/components": ">=0.16",
"@theme-ui/core": ">=0.16",
"framer-motion": ">=10",
@@ -1635,14 +1631,6 @@
"integrity": "sha512-KPnNOtm5i2pMabqZxpUz7iQf+mfrYZyKCZ8QNz85czgEt7cuHcGorWfdzUMWYA0SD+a6Hn4FmJ+YhzzzjkTZrQ==",
"license": "Apache-2.0"
},
- "node_modules/@mdi/react": {
- "version": "1.6.1",
- "resolved": "https://registry.npmjs.org/@mdi/react/-/react-1.6.1.tgz",
- "integrity": "sha512-4qZeDcluDFGFTWkHs86VOlHkm6gnKaMql13/gpIcUQ8kzxHgpj31NuCkD8abECVfbULJ3shc7Yt4HJ6Wu6SN4w==",
- "dependencies": {
- "prop-types": "^15.7.2"
- }
- },
"node_modules/@mdx-js/mdx": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/@mdx-js/mdx/-/mdx-2.3.0.tgz",
diff --git a/apps/monograph/package.json b/apps/monograph/package.json
index 76054d203..4e4a71e04 100644
--- a/apps/monograph/package.json
+++ b/apps/monograph/package.json
@@ -13,7 +13,8 @@
"typegen": "wrangler types",
"dev:express": "node server.js",
"start:express": "cross-env NODE_ENV=production node server.js",
- "build:express": "remix vite:build"
+ "build:express": "remix vite:build",
+ "postinstall": "patch-package"
},
"dependencies": {
"@emotion/cache": "11.11.0",
diff --git a/apps/monograph/patches/duplexer2+0.1.4.patch b/apps/monograph/patches/duplexer2+0.1.4.patch
new file mode 100644
index 000000000..3770bc5bf
--- /dev/null
+++ b/apps/monograph/patches/duplexer2+0.1.4.patch
@@ -0,0 +1,79 @@
+diff --git a/node_modules/duplexer2/node_modules/readable-stream/lib/_stream_duplex.js b/node_modules/duplexer2/node_modules/readable-stream/lib/_stream_duplex.js
+index 57003c3..0a0aa7e 100644
+--- a/node_modules/duplexer2/node_modules/readable-stream/lib/_stream_duplex.js
++++ b/node_modules/duplexer2/node_modules/readable-stream/lib/_stream_duplex.js
+@@ -44,7 +44,8 @@ module.exports = Duplex;
+
+ /*<replacement>*/
+ var util = Object.create(require('core-util-is'));
+-util.inherits = require('inherits');
++const inherits = require('inherits');
++util.inherits = "default" in inherits ? inherits.default : inherits;
+ /*</replacement>*/
+
+ var Readable = require('./_stream_readable');
+diff --git a/node_modules/duplexer2/node_modules/readable-stream/lib/_stream_passthrough.js b/node_modules/duplexer2/node_modules/readable-stream/lib/_stream_passthrough.js
+index 612edb4..c7be040 100644
+--- a/node_modules/duplexer2/node_modules/readable-stream/lib/_stream_passthrough.js
++++ b/node_modules/duplexer2/node_modules/readable-stream/lib/_stream_passthrough.js
+@@ -31,7 +31,8 @@ var Transform = require('./_stream_transform');
+
+ /*<replacement>*/
+ var util = Object.create(require('core-util-is'));
+-util.inherits = require('inherits');
++const inherits = require('inherits');
++util.inherits = "default" in inherits ? inherits.default : inherits;
+ /*</replacement>*/
+
+ util.inherits(PassThrough, Transform);
+diff --git a/node_modules/duplexer2/node_modules/readable-stream/lib/_stream_readable.js b/node_modules/duplexer2/node_modules/readable-stream/lib/_stream_readable.js
+index 3af95cb..d0bd956 100644
+--- a/node_modules/duplexer2/node_modules/readable-stream/lib/_stream_readable.js
++++ b/node_modules/duplexer2/node_modules/readable-stream/lib/_stream_readable.js
+@@ -39,7 +39,7 @@ var Duplex;
+ Readable.ReadableState = ReadableState;
+
+ /*<replacement>*/
+-var EE = require('events').EventEmitter;
++var EE = require('node:events').EventEmitter;
+
+ var EElistenerCount = function (emitter, type) {
+ return emitter.listeners(type).length;
+@@ -65,7 +65,8 @@ function _isUint8Array(obj) {
+
+ /*<replacement>*/
+ var util = Object.create(require('core-util-is'));
+-util.inherits = require('inherits');
++const inherits = require('inherits');
++util.inherits = "default" in inherits ? inherits.default : inherits;
+ /*</replacement>*/
+
+ /*<replacement>*/
+diff --git a/node_modules/duplexer2/node_modules/readable-stream/lib/_stream_transform.js b/node_modules/duplexer2/node_modules/readable-stream/lib/_stream_transform.js
+index fcfc105..9782b44 100644
+--- a/node_modules/duplexer2/node_modules/readable-stream/lib/_stream_transform.js
++++ b/node_modules/duplexer2/node_modules/readable-stream/lib/_stream_transform.js
+@@ -69,7 +69,8 @@ var Duplex = require('./_stream_duplex');
+
+ /*<replacement>*/
+ var util = Object.create(require('core-util-is'));
+-util.inherits = require('inherits');
++const inherits = require('inherits');
++util.inherits = "default" in inherits ? inherits.default : inherits;
+ /*</replacement>*/
+
+ util.inherits(Transform, Duplex);
+diff --git a/node_modules/duplexer2/node_modules/readable-stream/lib/_stream_writable.js b/node_modules/duplexer2/node_modules/readable-stream/lib/_stream_writable.js
+index e1e897f..df0ca6d 100644
+--- a/node_modules/duplexer2/node_modules/readable-stream/lib/_stream_writable.js
++++ b/node_modules/duplexer2/node_modules/readable-stream/lib/_stream_writable.js
+@@ -65,7 +65,8 @@ Writable.WritableState = WritableState;
+
+ /*<replacement>*/
+ var util = Object.create(require('core-util-is'));
+-util.inherits = require('inherits');
++const inherits = require('inherits');
++util.inherits = "default" in inherits ? inherits.default : inherits;
+ /*</replacement>*/
+
+ /*<replacement>*/
\ No newline at end of file
diff --git a/apps/monograph/tsconfig.json b/apps/monograph/tsconfig.json
index 8d0b09d0d..437386be7 100644
--- a/apps/monograph/tsconfig.json
+++ b/apps/monograph/tsconfig.json
@@ -1,5 +1,6 @@
{
"include": [
+ "app/global.d.ts",
"**/*.ts",
"**/*.tsx",
"**/.server/**/*.ts",
diff --git a/apps/monograph/vite.config.ts b/apps/monograph/vite.config.ts
index b725af4dc..a47942c32 100644
--- a/apps/monograph/vite.config.ts
+++ b/apps/monograph/vite.config.ts
@@ -53,6 +53,11 @@ export default defineConfig({
external: ["svg2png-wasm/svg2png_wasm_bg.wasm"]
}
},
+ define: {
+ PUBLIC_URL: JSON.stringify(
+ process.env.PUBLIC_URL || `http://localhost:${process.env.PORT || 5017}`
+ )
+ },
resolve: {
dedupe: [
"react",