diff --git a/.env.development b/.env.development index eb640e55..c56b62b3 100644 --- a/.env.development +++ b/.env.development @@ -1,30 +1,30 @@ -VITE_APP_BACKEND_V2_GET_URL=https://json-dev.excalidraw.com/api/v2/ -VITE_APP_BACKEND_V2_POST_URL=https://json-dev.excalidraw.com/api/v2/post/ +REACT_APP_BACKEND_V2_GET_URL=https://json-dev.excalidraw.com/api/v2/ +REACT_APP_BACKEND_V2_POST_URL=https://json-dev.excalidraw.com/api/v2/post/ -VITE_APP_LIBRARY_URL=https://libraries.excalidraw.com -VITE_APP_LIBRARY_BACKEND=https://us-central1-excalidraw-room-persistence.cloudfunctions.net/libraries +REACT_APP_LIBRARY_URL=https://libraries.excalidraw.com +REACT_APP_LIBRARY_BACKEND=https://us-central1-excalidraw-room-persistence.cloudfunctions.net/libraries # collaboration WebSocket server (https://github.com/excalidraw/excalidraw-room) -VITE_APP_WS_SERVER_URL=http://localhost:3002 +REACT_APP_WS_SERVER_URL=http://localhost:3002 # set this only if using the collaboration workflow we use on excalidraw.com -VITE_APP_PORTAL_URL= +REACT_APP_PORTAL_URL= -VITE_APP_FIREBASE_CONFIG='{"apiKey":"AIzaSyCMkxA60XIW8KbqMYL7edC4qT5l4qHX2h8","authDomain":"excalidraw-oss-dev.firebaseapp.com","projectId":"excalidraw-oss-dev","storageBucket":"excalidraw-oss-dev.appspot.com","messagingSenderId":"664559512677","appId":"1:664559512677:web:a385181f2928d328a7aa8c"}' +REACT_APP_FIREBASE_CONFIG='{"apiKey":"AIzaSyCMkxA60XIW8KbqMYL7edC4qT5l4qHX2h8","authDomain":"excalidraw-oss-dev.firebaseapp.com","projectId":"excalidraw-oss-dev","storageBucket":"excalidraw-oss-dev.appspot.com","messagingSenderId":"664559512677","appId":"1:664559512677:web:a385181f2928d328a7aa8c"}' # put these in your .env.local, or make sure you don't commit! # must be lowercase `true` when turned on # # whether to enable Service Workers in development -VITE_APP_DEV_ENABLE_SW= +REACT_APP_DEV_ENABLE_SW= # whether to disable live reload / HMR. Usuaully what you want to do when # debugging Service Workers. -VITE_APP_DEV_DISABLE_LIVE_RELOAD= -VITE_APP_DISABLE_TRACKING=true +REACT_APP_DEV_DISABLE_LIVE_RELOAD= +REACT_APP_DISABLE_TRACKING=true FAST_REFRESH=false #Debug flags # To enable bounding box for text containers -VITE_APP_DEBUG_ENABLE_TEXT_CONTAINER_BOUNDING_BOX= +REACT_APP_DEBUG_ENABLE_TEXT_CONTAINER_BOUNDING_BOX= diff --git a/.env.production b/.env.production index e3ece6df..b86aa4bc 100644 --- a/.env.production +++ b/.env.production @@ -1,15 +1,15 @@ REACT_APP_BACKEND_V2_GET_URL=https://json.excalidraw.com/api/v2/ REACT_APP_BACKEND_V2_POST_URL=https://json.excalidraw.com/api/v2/post/ -VITE_APP_LIBRARY_URL=https://libraries.excalidraw.com -VITE_APP_LIBRARY_BACKEND=https://us-central1-excalidraw-room-persistence.cloudfunctions.net/libraries +REACT_APP_LIBRARY_URL=https://libraries.excalidraw.com +REACT_APP_LIBRARY_BACKEND=https://us-central1-excalidraw-room-persistence.cloudfunctions.net/libraries -VITE_APP_PORTAL_URL=https://portal.excalidraw.com +REACT_APP_PORTAL_URL=https://portal.excalidraw.com # Fill to set socket server URL used for collaboration. -# Meant for forks only: excalidraw.com uses custom VITE_APP_PORTAL_URL flow -VITE_APP_WS_SERVER_URL= +# Meant for forks only: excalidraw.com uses custom REACT_APP_PORTAL_URL flow +REACT_APP_WS_SERVER_URL= -VITE_APP_FIREBASE_CONFIG='{"apiKey":"AIzaSyAd15pYlMci_xIp9ko6wkEsDzAAA0Dn0RU","authDomain":"excalidraw-room-persistence.firebaseapp.com","databaseURL":"https://excalidraw-room-persistence.firebaseio.com","projectId":"excalidraw-room-persistence","storageBucket":"excalidraw-room-persistence.appspot.com","messagingSenderId":"654800341332","appId":"1:654800341332:web:4a692de832b55bd57ce0c1"}' +REACT_APP_FIREBASE_CONFIG='{"apiKey":"AIzaSyAd15pYlMci_xIp9ko6wkEsDzAAA0Dn0RU","authDomain":"excalidraw-room-persistence.firebaseapp.com","databaseURL":"https://excalidraw-room-persistence.firebaseio.com","projectId":"excalidraw-room-persistence","storageBucket":"excalidraw-room-persistence.appspot.com","messagingSenderId":"654800341332","appId":"1:654800341332:web:4a692de832b55bd57ce0c1"}' -VITE_APP_PLUS_APP=https://app.excalidraw.com -VITE_APP_DISABLE_TRACKING= +REACT_APP_PLUS_APP=https://app.excalidraw.com +REACT_APP_DISABLE_TRACKING= diff --git a/.github/workflows/autorelease-excalidraw.yml b/.github/workflows/autorelease-excalidraw.yml index 4eaeb11f..ad0a0a7e 100644 --- a/.github/workflows/autorelease-excalidraw.yml +++ b/.github/workflows/autorelease-excalidraw.yml @@ -12,10 +12,10 @@ jobs: - uses: actions/checkout@v2 with: fetch-depth: 2 - - name: Setup Node.js 18.x + - name: Setup Node.js 14.x uses: actions/setup-node@v2 with: - node-version: 18.x + node-version: 14.x - name: Set up publish access run: | npm config set //registry.npmjs.org/:_authToken ${NPM_TOKEN} diff --git a/.github/workflows/autorelease-preview.yml b/.github/workflows/autorelease-preview.yml index bcd50188..8fe7f40b 100644 --- a/.github/workflows/autorelease-preview.yml +++ b/.github/workflows/autorelease-preview.yml @@ -32,10 +32,10 @@ jobs: with: ref: ${{ steps.sha.outputs.result }} fetch-depth: 2 - - name: Setup Node.js 18.x + - name: Setup Node.js 14.x uses: actions/setup-node@v2 with: - node-version: 18.x + node-version: 14.x - name: Set up publish access run: | npm config set //registry.npmjs.org/:_authToken ${NPM_TOKEN} diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index d42f8f63..77d2ef4d 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -9,10 +9,10 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Setup Node.js 18.x + - name: Setup Node.js 14.x uses: actions/setup-node@v2 with: - node-version: 18.x + node-version: 14.x - name: Install and lint run: | diff --git a/.github/workflows/locales-coverage.yml b/.github/workflows/locales-coverage.yml index 822af06e..924dc9e9 100644 --- a/.github/workflows/locales-coverage.yml +++ b/.github/workflows/locales-coverage.yml @@ -14,10 +14,10 @@ jobs: with: token: ${{ secrets.PUSH_TRANSLATIONS_COVERAGE_PAT }} - - name: Setup Node.js 18.x + - name: Setup Node.js 14.x uses: actions/setup-node@v2 with: - node-version: 18.x + node-version: 14.x - name: Create report file run: | diff --git a/.github/workflows/sentry-production.yml b/.github/workflows/sentry-production.yml index cea4cf63..6f53f91e 100644 --- a/.github/workflows/sentry-production.yml +++ b/.github/workflows/sentry-production.yml @@ -10,10 +10,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - name: Setup Node.js 18.x + - name: Setup Node.js 14.x uses: actions/setup-node@v2 with: - node-version: 18.x + node-version: 14.x - name: Install and build run: | yarn --frozen-lockfile diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5c4584e8..b64ea473 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -7,10 +7,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - name: Setup Node.js 18.x + - name: Setup Node.js 14.x uses: actions/setup-node@v2 with: - node-version: 18.x + node-version: 14.x - name: Install and test run: | yarn --frozen-lockfile diff --git a/.gitignore b/.gitignore index 6e430f4e..e637a8c0 100644 --- a/.gitignore +++ b/.gitignore @@ -26,5 +26,3 @@ src/packages/excalidraw/example/public/bundle.js src/packages/excalidraw/example/public/excalidraw-assets-dev src/packages/excalidraw/example/public/excalidraw.development.js coverage -dev-dist -html diff --git a/package.json b/package.json index 162a8ebb..d1198fa2 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,6 @@ "canvas-roundrect-polyfill": "0.0.1", "clsx": "1.1.1", "cross-env": "7.0.3", - "eslint-plugin-react": "7.32.2", "fake-indexeddb": "3.1.7", "firebase": "8.3.3", "i18next-browser-languagedetector": "6.1.4", @@ -52,13 +51,26 @@ "pwacompat": "2.0.17", "react": "18.2.0", "react-dom": "18.2.0", + "react-scripts": "5.0.1", "roughjs": "4.5.2", "sass": "1.51.0", "socket.io-client": "2.3.1", - "tunnel-rat": "0.1.2" + "tunnel-rat": "0.1.2", + "workbox-background-sync": "^6.5.4", + "workbox-broadcast-update": "^6.5.4", + "workbox-cacheable-response": "^6.5.4", + "workbox-core": "^6.5.4", + "workbox-expiration": "^6.5.4", + "workbox-google-analytics": "^6.5.4", + "workbox-navigation-preload": "^6.5.4", + "workbox-precaching": "^6.5.4", + "workbox-range-requests": "^6.5.4", + "workbox-routing": "^6.5.4", + "workbox-strategies": "^6.5.4", + "workbox-streams": "^6.5.4" }, "devDependencies": { - "@excalidraw/eslint-config": "1.0.3", + "@excalidraw/eslint-config": "1.0.0", "@excalidraw/prettier-config": "1.0.2", "@types/chai": "4.3.0", "@types/jest": "27.4.0", @@ -69,42 +81,48 @@ "@types/react-dom": "18.0.6", "@types/resize-observer-browser": "0.1.7", "@types/socket.io-client": "1.4.36", - "@vitejs/plugin-react": "3.1.0", - "@vitest/ui": "0.32.2", "chai": "4.3.6", "dotenv": "16.0.1", "eslint-config-prettier": "8.5.0", - "eslint-config-react-app": "7.0.1", "eslint-plugin-prettier": "3.3.1", "http-server": "14.1.1", "husky": "7.0.4", - "jsdom": "22.1.0", + "jest-canvas-mock": "2.4.0", "lint-staged": "12.3.7", "pepjs": "0.5.3", "prettier": "2.6.2", "rewire": "6.0.0", - "typescript": "4.9.4", - "vite": "4.4.2", - "vite-plugin-ejs": "1.6.4", - "vite-plugin-eslint": "1.8.1", - "vite-plugin-pwa": "0.16.4", - "vite-plugin-svgr": "2.4.0", - "vitest": "0.32.2", - "vitest-canvas-mock": "0.3.2" + "typescript": "4.9.4" }, "engines": { - "node": ">=18.0.0" + "node": ">=14.0.0" }, "homepage": ".", + "jest": { + "collectCoverageFrom": [ + "src/**/*.{js,jsx,ts,tsx}" + ], + "coveragePathIgnorePatterns": [ + "/locales", + "/src/packages/excalidraw/dist/", + "/src/packages/excalidraw/types", + "/src/packages/excalidraw/example" + ], + "transformIgnorePatterns": [ + "node_modules/(?!(roughjs|points-on-curve|path-data-parser|points-on-path|browser-fs-access|canvas-roundrect-polyfill)/)" + ], + "resetMocks": false + }, "name": "excalidraw", "prettier": "@excalidraw/prettier-config", "private": true, "scripts": { "build-node": "node ./scripts/build-node.js", - "build:app:docker": "cross-env REACT_APP_DISABLE_SENTRY=true REACT_APP_DISABLE_TRACKING=true vite build", - "build:app": "cross-env REACT_APP_GIT_SHA=$VERCEL_GIT_COMMIT_SHA vite build", + "build:app:docker": "cross-env REACT_APP_DISABLE_SENTRY=true REACT_APP_DISABLE_TRACKING=true react-scripts build", + "build:app": "cross-env REACT_APP_GIT_SHA=$VERCEL_GIT_COMMIT_SHA react-scripts build", "build:version": "node ./scripts/build-version.js", "build": "yarn build:app && yarn build:version", + "eject": "react-scripts eject", "fix:code": "yarn test:code --fix", "fix:other": "yarn prettier --write", "fix": "yarn fix:other && yarn fix:code", @@ -112,20 +130,19 @@ "locales-coverage:description": "node scripts/locales-coverage-description.js", "prepare": "husky install", "prettier": "prettier \"**/*.{css,scss,json,md,html,yml}\" --ignore-path=.eslintignore", - "start": "vite --port 3000", + "start": "react-scripts start", "start:production": "npm run build && npx http-server build -a localhost -p 5001 -o", "test:all": "yarn test:typecheck && yarn test:code && yarn test:other && yarn test:app --watchAll=false", - "test:app": "vitest --config vitest.config.ts", + "test:app": "react-scripts test --passWithNoTests", "test:code": "eslint --max-warnings=0 --ext .js,.ts,.tsx .", + "test:debug": "react-scripts --inspect-brk test --runInBand --no-cache", "test:other": "yarn prettier --list-different", "test:typecheck": "tsc", - "test:update": "yarn test:app --update --watch=false", + "test:update": "yarn test:app --updateSnapshot --watchAll=false", "test": "yarn test:app", - "test:coverage": "vitest --coverage --watchAll", - "test:ui": "yarn test --ui", + "test:coverage": "react-scripts test --passWithNoTests --coverage --watchAll", "autorelease": "node scripts/autorelease.js", "prerelease": "node scripts/prerelease.js", - "build:preview": "yarn build && vite preview --port 5000", "release": "node scripts/release.js" } } diff --git a/index.html b/public/index.html similarity index 91% rename from index.html rename to public/index.html index cbdc7706..5509ded8 100644 --- a/index.html +++ b/public/index.html @@ -78,7 +78,8 @@ } - <% if ("%PROD%" === "true") { %> + + <% if (process.env.NODE_ENV === "production") { %> <% } %> - + - - <% if ("%VITE_APP_DEV_DISABLE_LIVE_RELOAD%"==="true" ) { %> + + + + <% if (process.env.REACT_APP_DEV_DISABLE_LIVE_RELOAD==="true" ) { %> - <% if ("%VITE_APP_DEV_DISABLE_LIVE_RELOAD%" !== 'true') { %> + <% if (process.env.REACT_APP_DISABLE_TRACKING !== 'true') { %>