From 24e9be73cc6bc785f34fbd22971d2a2723174e24 Mon Sep 17 00:00:00 2001 From: Steve Ruiz Date: Sat, 4 Sep 2021 10:14:47 +0100 Subject: [PATCH] Let's try that again This reverts commit da0f8df4d77084c6cf335a5c9ab1bf444e2db455. Revert "Update package.json" This reverts commit 522f87c833f8efc0be48e0749b41ce749ad7c24c. Revert "removes custom document" This reverts commit 00d9146895a423558887474fcd6f695ba9ad7194. Revert "Remove a dep that may have been causing issues" This reverts commit 69462632a5f4600041d3ef929a1effb95f0732f3. Revert "Update index.tsx" This reverts commit d05807bbfbb350d83146120a5e4d93efac467405. Revert "Adds manifest" This reverts commit 1c305526432a2101ad00b3790f646db56c662500. --- package.json | 4 +- packages/core/package.json | 11 ++- packages/core/src/utils/utils.ts | 5 +- packages/tldraw/package.json | 3 +- packages/www/pages/_document.tsx | 76 ++++++++++++++++++ packages/www/pages/index.tsx | 34 ++++---- packages/www/public/manifest.json | 35 --------- packages/www/public/sw.js | 2 +- packages/www/public/sw.js.map | 2 +- ...L_0.js => worker-ZSKPWmeLuzbDpY-pLKFsC.js} | 0 packages/www/public/x_document.tsx | 78 ------------------- packages/www/tsconfig.json | 2 + 12 files changed, 111 insertions(+), 141 deletions(-) create mode 100644 packages/www/pages/_document.tsx delete mode 100644 packages/www/public/manifest.json rename packages/www/public/{worker-eJsZLpVkBbTZjjQcpsL_0.js => worker-ZSKPWmeLuzbDpY-pLKFsC.js} (100%) delete mode 100644 packages/www/public/x_document.tsx diff --git a/package.json b/package.json index c1531a01a..9e140df8a 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "lerna": "lerna", "start": "lerna run start:pre && lerna run start --stream --parallel", "start:www": "yarn build:packages && lerna run start --parallel & cd packages/www && yarn dev", - "build": "cd packages/www && yarn build", + "build": "yarn build:packages && cd packages/www && yarn build", "build:packages": "cd packages/core && yarn build && cd ../tldraw && yarn build", "publish:patch": "yarn build:packages && lerna publish patch", "docs": "lerna run docs --stream" @@ -113,4 +113,4 @@ "\\+(.*)": "/packages/core/src/$1" } } -} \ No newline at end of file +} diff --git a/packages/core/package.json b/packages/core/package.json index 225a49074..dd9536aa7 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -28,9 +28,6 @@ "docs": "typedoc --entryPoints src/index.ts" }, "devDependencies": { - "@babel/core": "^7.15.0", - "@babel/preset-env": "^7.15.0", - "@radix-ui/react-primitive": "^0.0.15", "@types/jest": "^27.0.1", "@types/node": "^16.7.6", "@types/react": "^17.0.16", @@ -51,7 +48,13 @@ "react-dom": "^17.0.2" }, "dependencies": { + "@babel/core": "^7.15.0", + "@babel/preset-env": "^7.15.0", + "@radix-ui/react-primitive": "^0.0.15", + "@typescript-eslint/eslint-plugin": "^4.19.0", + "@typescript-eslint/parser": "^4.19.0", "deepmerge": "^4.2.2", + "ismobilejs": "^1.1.1", "react-use-gesture": "^9.1.3" } -} \ No newline at end of file +} diff --git a/packages/core/src/utils/utils.ts b/packages/core/src/utils/utils.ts index 7566c52db..c1b700f85 100644 --- a/packages/core/src/utils/utils.ts +++ b/packages/core/src/utils/utils.ts @@ -4,6 +4,7 @@ /* eslint-disable no-redeclare */ import type React from 'react' import deepmerge from 'deepmerge' +import isMobilePkg from 'ismobilejs' import { TLBezierCurveSegment, TLBounds, TLBoundsCorner, TLBoundsEdge } from '../types' import vec from './vec' import './polyfills' @@ -1664,8 +1665,7 @@ left past the initial left edge) then swap points on that axis. /* -------------------------------------------------- */ static isMobile() { - if (typeof window === 'undefined') return false - return 'ontouchstart' in window || navigator?.maxTouchPoints > 0 + return isMobilePkg().any } // via https://github.com/bameyrick/throttle-typescript @@ -1702,7 +1702,6 @@ left past the initial left edge) then swap points on that axis. * Find whether the current device is a Mac / iOS / iPadOS. */ static isDarwin(): boolean { - if (typeof window === 'undefined') return false return /Mac|iPod|iPhone|iPad/.test(window.navigator.platform) } diff --git a/packages/tldraw/package.json b/packages/tldraw/package.json index 6067876d8..49143091d 100644 --- a/packages/tldraw/package.json +++ b/packages/tldraw/package.json @@ -59,8 +59,9 @@ "@radix-ui/react-tooltip": "^0.0.21", "@stitches/react": "^1.0.0", "@tldraw/core": "^0.0.57", + "ismobilejs": "^1.1.1", "perfect-freehand": "^0.5.3", "react-hotkeys-hook": "^3.4.0", "rko": "^0.5.19" } -} \ No newline at end of file +} diff --git a/packages/www/pages/_document.tsx b/packages/www/pages/_document.tsx new file mode 100644 index 000000000..210cdb86e --- /dev/null +++ b/packages/www/pages/_document.tsx @@ -0,0 +1,76 @@ +import NextDocument, { Html, Head, Main, NextScript, DocumentContext } from 'next/document' +import { getCssText } from '-styles' +import { GA_TRACKING_ID } from '-utils/gtag' + +class MyDocument extends NextDocument { + static async getInitialProps(ctx: DocumentContext) { + const initialProps = await NextDocument.getInitialProps(ctx) + + return { + ...initialProps, + styles: ( + <> + {initialProps.styles} +