Skip to content

Commit

Permalink
FIX EXCALIDRAW I SWEAR
Browse files Browse the repository at this point in the history
  • Loading branch information
JCapucho committed Dec 11, 2023
1 parent c578844 commit 735b888
Show file tree
Hide file tree
Showing 9 changed files with 321 additions and 2 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: false
- name: Checkout excalidraw
run: git submodule update --init excalidraw
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@main
- name: Setup Nix Cache
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@
[submodule "MAS/Projeto (site)"]
path = MAS/Projeto (site)
url = https://github.com/JCapucho/mas-projeto-final.git
[submodule "excalidraw"]
path = excalidraw
url = https://github.com/excalidraw/excalidraw.git
Binary file modified bun.lockb
Binary file not shown.
1 change: 1 addition & 0 deletions excalidraw
Submodule excalidraw added at b7d7cc
237 changes: 237 additions & 0 deletions excalidraw.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,237 @@
diff --git a/src/packages/utils/index.js b/src/packages/utils/index.js
index 4dc03e93..c739646d 100644
--- a/src/packages/utils/index.js
+++ b/src/packages/utils/index.js
@@ -1 +1,6 @@
-export { exportToBlob, exportToSvg, exportToCanvas } from "../utils.ts";
+export {
+ loadFromBlob,
+ exportToBlob,
+ exportToSvg,
+ exportToCanvas,
+} from "../utils.ts";
diff --git a/src/packages/utils/package.json b/src/packages/utils/package.json
index 7375e8b5..c2ba6275 100644
--- a/src/packages/utils/package.json
+++ b/src/packages/utils/package.json
@@ -41,6 +41,7 @@
"@babel/plugin-transform-typescript": "7.18.8",
"@babel/preset-env": "7.18.9",
"@babel/preset-typescript": "7.18.6",
+ "autoprefixer": "10.4.7",
"babel-loader": "8.2.5",
"babel-plugin-transform-class-properties": "6.24.1",
"cross-env": "7.0.3",
@@ -50,7 +51,8 @@
"ts-loader": "9.3.1",
"webpack": "5.76.0",
"webpack-bundle-analyzer": "4.5.0",
- "webpack-cli": "4.10.0"
+ "webpack-cli": "4.10.0",
+ "import-meta-loader": "1.1.0"
},
"bugs": "https://github.com/excalidraw/excalidraw/issues",
"repository": "https://github.com/excalidraw/excalidraw",
diff --git a/src/packages/utils/webpack.prod.config.js b/src/packages/utils/webpack.prod.config.js
index 7238ad02..18f38dfd 100644
--- a/src/packages/utils/webpack.prod.config.js
+++ b/src/packages/utils/webpack.prod.config.js
@@ -1,4 +1,5 @@
const webpack = require("webpack");
+const autoprefixer = require("autoprefixer");
const path = require("path");
const BundleAnalyzerPlugin =
require("webpack-bundle-analyzer").BundleAnalyzerPlugin;
@@ -23,11 +24,38 @@ module.exports = {
{
test: /\.(sa|sc|c)ss$/,
exclude: /node_modules/,
- use: ["style-loader", { loader: "css-loader" }, "sass-loader"],
+ use: [
+ "style-loader",
+ {
+ loader: "css-loader",
+ },
+ {
+ loader: "postcss-loader",
+ options: {
+ postcssOptions: {
+ plugins: [autoprefixer()],
+ },
+ },
+ },
+ "sass-loader",
+ ],
},
+ // So that type module works with webpack
+ // https://github.com/webpack/webpack/issues/11467#issuecomment-691873586
{
- test: /\.(ts|tsx|js)$/,
+ test: /\.m?js/,
+ resolve: {
+ fullySpecified: false,
+ },
+ },
+ {
+ test: /\.(ts|tsx|js|jsx|mjs)$/,
+ exclude:
+ /node_modules[\\/](?!(browser-fs-access|canvas-roundrect-polyfill))/,
use: [
+ {
+ loader: "import-meta-loader",
+ },
{
loader: "ts-loader",
options: {
@@ -37,18 +65,24 @@ module.exports = {
},
{
loader: "babel-loader",
-
options: {
presets: [
"@babel/preset-env",
["@babel/preset-react", { runtime: "automatic" }],
"@babel/preset-typescript",
],
- plugins: [["@babel/plugin-transform-runtime"]],
+ plugins: [
+ "transform-class-properties",
+ "@babel/plugin-transform-runtime",
+ ],
},
},
],
},
+ {
+ test: /\.(woff|woff2|eot|ttf|otf)$/,
+ type: "asset/resource",
+ },
],
},
plugins: [
diff --git a/src/packages/utils/yarn.lock b/src/packages/utils/yarn.lock
index c10a5aed..10a3c51b 100644
--- a/src/packages/utils/yarn.lock
+++ b/src/packages/utils/yarn.lock
@@ -1231,6 +1231,18 @@ ansi-styles@^4.1.0:
dependencies:
color-convert "^2.0.1"

+[email protected]:
+ version "10.4.7"
+ resolved "https://registry.yarnpkg.com/autoprefixer/-/autoprefixer-10.4.7.tgz#1db8d195f41a52ca5069b7593be167618edbbedf"
+ integrity sha512-ypHju4Y2Oav95SipEcCcI5J7CGPuvz8oat7sUtYj3ClK44bldfvtvcxK6IEK++7rqB7YchDGzweZIBG+SD0ZAA==
+ dependencies:
+ browserslist "^4.20.3"
+ caniuse-lite "^1.0.30001335"
+ fraction.js "^4.2.0"
+ normalize-range "^0.1.2"
+ picocolors "^1.0.0"
+ postcss-value-parser "^4.2.0"
+
babel-code-frame@^6.26.0:
version "6.26.0"
resolved "https://registry.yarnpkg.com/babel-code-frame/-/babel-code-frame-6.26.0.tgz#63fd43f7dc1e3bb7ce35947db8fe369a3f58c74b"
@@ -1393,6 +1405,16 @@ browserslist@^4.14.5, browserslist@^4.20.2, browserslist@^4.21.2:
node-releases "^2.0.6"
update-browserslist-db "^1.0.4"

+browserslist@^4.20.3:
+ version "4.22.2"
+ resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.22.2.tgz#704c4943072bd81ea18997f3bd2180e89c77874b"
+ integrity sha512-0UgcrvQmBDvZHFGdYUehrCNIazki7/lUP3kkoi/r3YB2amZbFM9J43ZRkJTXBUZK4gmx56+Sqk9+Vs9mwZx9+A==
+ dependencies:
+ caniuse-lite "^1.0.30001565"
+ electron-to-chromium "^1.4.601"
+ node-releases "^2.0.14"
+ update-browserslist-db "^1.0.13"
+
buffer-from@^1.0.0:
version "1.1.2"
resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.2.tgz#2b146a6fd72e80b4f55d255f35ed59a3a9a41bd5"
@@ -1406,6 +1428,11 @@ call-bind@^1.0.0:
function-bind "^1.1.1"
get-intrinsic "^1.0.2"

+caniuse-lite@^1.0.30001335, caniuse-lite@^1.0.30001565:
+ version "1.0.30001568"
+ resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001568.tgz#53fa9297273c9a977a560663f48cbea1767518b7"
+ integrity sha512-vSUkH84HontZJ88MiNrOau1EBrCqEQYgkC5gIySiDlpsm8sGVrhU7Kx4V6h0tnqaHzIHZv08HlJIwPbL4XL9+A==
+
caniuse-lite@^1.0.30001366:
version "1.0.30001367"
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001367.tgz#2b97fe472e8fa29c78c5970615d7cd2ee414108a"
@@ -1585,6 +1612,11 @@ electron-to-chromium@^1.4.188:
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.195.tgz#139b2d95a42a3f17df217589723a1deac71d1473"
integrity sha512-vefjEh0sk871xNmR5whJf9TEngX+KTKS3hOHpjoMpauKkwlGwtMz1H8IaIjAT/GNnX0TbGwAdmVoXCAzXf+PPg==

+electron-to-chromium@^1.4.601:
+ version "1.4.610"
+ resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.610.tgz#e17b22203f4aa2e1ed77759c720546d95a51186f"
+ integrity sha512-mqi2oL1mfeHYtOdCxbPQYV/PL7YrQlxbvFEZ0Ee8GbDdShimqt2/S6z2RWqysuvlwdOrQdqvE0KZrBTipAeJzg==
+
emojis-list@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/emojis-list/-/emojis-list-3.0.0.tgz#5570662046ad29e2e916e71aae260abdff4f6a78"
@@ -1700,6 +1732,11 @@ find-up@^4.0.0:
locate-path "^5.0.0"
path-exists "^4.0.0"

+fraction.js@^4.2.0:
+ version "4.3.7"
+ resolved "https://registry.yarnpkg.com/fraction.js/-/fraction.js-4.3.7.tgz#06ca0085157e42fda7f9e726e79fefc4068840f7"
+ integrity sha512-ZsDfxO51wGAXREY55a7la9LScWpwv9RxIrYABrlvOFBlH/ShPnrtsXeuUIfXKKOVicNxQ+o8JTbJvjS4M89yew==
+
function-bind@^1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d"
@@ -1788,6 +1825,11 @@ import-local@^3.0.2:
pkg-dir "^4.2.0"
resolve-cwd "^3.0.0"

+[email protected]:
+ version "1.1.0"
+ resolved "https://registry.yarnpkg.com/import-meta-loader/-/import-meta-loader-1.1.0.tgz#927060305f2d0f88b495f2754aa33387ca6579d7"
+ integrity sha512-f96r2o8xT+b2KVlOY4x+1KTJmJiapZlf77j1WebR8NQgMG1dpdqijjGl4i/2jMoXch2CVqcQoTMfh5BR7bR8wA==
+
indexes-of@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/indexes-of/-/indexes-of-1.0.1.tgz#f30f716c8e2bd346c7b67d3df3915566a7c05607"
@@ -1990,11 +2032,21 @@ neo-async@^2.6.2:
resolved "https://registry.yarnpkg.com/neo-async/-/neo-async-2.6.2.tgz#b4aafb93e3aeb2d8174ca53cf163ab7d7308305f"
integrity sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==

+node-releases@^2.0.14:
+ version "2.0.14"
+ resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-2.0.14.tgz#2ffb053bceb8b2be8495ece1ab6ce600c4461b0b"
+ integrity sha512-y10wOWt8yZpqXmOgRo77WaHEmhYQYGNA6y421PKsKYWEK8aW+cqAphborZDhqfyKrbZEN92CN1X2KbafY2s7Yw==
+
node-releases@^2.0.6:
version "2.0.6"
resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-2.0.6.tgz#8a7088c63a55e493845683ebf3c828d8c51c5503"
integrity sha512-PiVXnNuFm5+iYkLBNeq5211hvO38y63T0i2KKh2KnUs3RpzJ+JtODFjkD8yjLwnDkTYF1eKXheUwdssR+NRZdg==

+normalize-range@^0.1.2:
+ version "0.1.2"
+ resolved "https://registry.yarnpkg.com/normalize-range/-/normalize-range-0.1.2.tgz#2d10c06bdfd312ea9777695a4d28439456b75942"
+ integrity sha512-bdok/XvKII3nUpklnV6P2hxtMNrCboOjAcyBuQnWEhO665FwrSNRxU+AqpsyvO6LgGYPspN+lu5CLtw4jPRKNA==
+
object-keys@^1.0.12, object-keys@^1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-1.1.1.tgz#1c47f272df277f3b1daf061677d9c82e2322c60e"
@@ -2448,6 +2500,14 @@ uniq@^1.0.1:
resolved "https://registry.yarnpkg.com/uniq/-/uniq-1.0.1.tgz#b31c5ae8254844a3a8281541ce2b04b865a734ff"
integrity sha1-sxxa6CVIRKOoKBVBzisEuGWnNP8=

+update-browserslist-db@^1.0.13:
+ version "1.0.13"
+ resolved "https://registry.yarnpkg.com/update-browserslist-db/-/update-browserslist-db-1.0.13.tgz#3c5e4f5c083661bd38ef64b6328c26ed6c8248c4"
+ integrity sha512-xebP81SNcPuNpPP3uzeW1NYXxI3rxyJzF3pD6sH4jE7o/IX+WtSpwnVU+qIsDPyk0d3hmFQ7mjqc6AtV604hbg==
+ dependencies:
+ escalade "^3.1.1"
+ picocolors "^1.0.0"
+
update-browserslist-db@^1.0.4:
version "1.0.5"
resolved "https://registry.yarnpkg.com/update-browserslist-db/-/update-browserslist-db-1.0.5.tgz#be06a5eedd62f107b7c19eb5bcefb194411abf38"
1 change: 1 addition & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@

base-pkgs = with pkgs; [
bun
yarn
nodejs_latest
pandoc
pandoc-norg-rs.packages.${system}.default
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
"scripts": {
"dev": "parcel index.eta",
"build": "parcel build index.eta",
"index": "pagefind --site dist"
"index": "pagefind --site dist",
"postinstall": "bun ./scripts/build-excalidraw.js"
},
"staticFiles": {
"staticPath": "public"
},
"devDependencies": {
"@excalidraw/excalidraw": "^0.17.2",
"@excalidraw/excalidraw": "file:./excalidraw/src/packages/utils",
"@parcel/config-default": "^2.10.0",
"@parcel/core": "^2.10.0",
"@parcel/plugin": "^2.10.0",
Expand All @@ -27,6 +28,7 @@
"posthtml": "^0.16.6",
"posthtml-parser": "^0.11.0",
"posthtml-toc": "posthtml/posthtml-toc#0c19ee4de97c5985fda86550d0590e29074191d4",
"rewire": "^7.0.0",
"tailwindcss": "^3.3.3"
},
"dependencies": {
Expand Down
3 changes: 3 additions & 0 deletions plugins/excalidrawSetupDom.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,8 @@ import "global-jsdom/register";
import excalidrawPkg from "@excalidraw/excalidraw/package.json" assert { type: "json" };
const excalidrawAssets = `https://unpkg.com/@excalidraw/excalidraw@${excalidrawPkg.version}`;

const localDistUrl = import.meta.resolve("@excalidraw/excalidraw/dist");

global.Path2D = Path2D;
global.window.EXCALIDRAW_ASSET_PATH = excalidrawAssets;
global.window.EXCALIDRAW_WEBPACK_ASSET_PATH = localDistUrl + "/";
68 changes: 68 additions & 0 deletions scripts/build-excalidraw.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import path from "node:path";
import { fileURLToPath } from "node:url";
import { spawnSync } from "node:child_process";

const __dirname = path.dirname(fileURLToPath(import.meta.url));
export const project_root = path.join(__dirname, "..");

const excalidrawDir = path.join(project_root, "excalidraw");
const excalidrawPkgDir = path.join(excalidrawDir, "src/packages/utils");

const gitRevCheck = spawnSync(
"git",
[
"apply",
"--reverse",
"--check",
path.join(project_root, "excalidraw.patch"),
],
{
cwd: excalidrawDir,
},
);

if (gitRevCheck.status != 0) {
spawnSync("git", ["apply", path.join(project_root, "excalidraw.patch")], {
cwd: excalidrawDir,
stdio: "inherit",
});
} else {
console.error("Excalidraw patch already applied");
}

let res = spawnSync("yarn", ["--frozen-lockfile"], {
stdio: "inherit",
cwd: excalidrawDir,
});

if (res.error) throw res.error;

res = spawnSync("yarn", ["--frozen-lockfile"], {
stdio: "inherit",
cwd: excalidrawPkgDir,
});

if (res.error) throw res.error;

res = spawnSync("rm", ["-rf", "dist"], {
stdio: "inherit",
cwd: excalidrawPkgDir,
});

if (res.error) throw res.error;

res = spawnSync("yarn", ["run", "build:umd"], {
stdio: "inherit",
cwd: excalidrawPkgDir,
env: {
NODE_ENV: "production",
},
});

if (res.error) throw res.error;

res = spawnSync("bun", ["install", "--ignore-scripts", "--frozen-lockfile"], {
stdio: "inherit",
});

if (res.error) throw res.error;

0 comments on commit 735b888

Please sign in to comment.