-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Cut deprecated exports/methods to save a few kilobytes (#250)
- Loading branch information
Showing
15 changed files
with
31,699 additions
and
14,532 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,50 @@ | ||
build/* | ||
dist/* | ||
dist-esm/* | ||
dist-es6/* | ||
dist-min/* | ||
dist-buble/* | ||
**/dist/* | ||
website*/public/* | ||
dist.min.js | ||
|
||
node_modules/ | ||
coverage/ | ||
_docs/ | ||
.nyc_output/ | ||
.reify-cache/ | ||
|
||
coverage/ | ||
node_modules/ | ||
npm-debug.log | ||
stats.json | ||
.reify-cache | ||
.cache | ||
jscpd-report.md | ||
|
||
tsconfig.tsbuildinfo | ||
|
||
test/data/test.png | ||
|
||
package-lock.json | ||
lerna-debug.log | ||
|
||
*/**/yarn.lock | ||
yarn-error.log | ||
!website/yarn.lock | ||
|
||
.yarn/* | ||
!.yarn/cache | ||
!.yarn/patches | ||
!.yarn/plugins | ||
!.yarn/releases | ||
!.yarn/sdks | ||
!.yarn/versions | ||
|
||
tsconfig.tsbuildinfo | ||
|
||
# editor files | ||
.project | ||
.DS_Store | ||
.idea | ||
*.zip | ||
*.rar | ||
TODO | ||
|
||
.docusaurus | ||
|
||
# editor files | ||
.idea | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
nodeLinker: node-modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,15 @@ | ||
export {VERSION} from './utils/globals'; | ||
// Extract injected version from package.json (injected by babel plugin) | ||
// @ts-expect-error | ||
export const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'untranspiled source'; | ||
|
||
// ENVIRONMENT | ||
export {self, window, global, document, process, console} from './lib/globals'; | ||
export {default as isBrowser, isBrowserMainThread} from './lib/is-browser'; | ||
export {default as getBrowser, isMobile} from './lib/get-browser'; | ||
export {default as isElectron} from './lib/is-electron'; | ||
export {isBrowser} from './lib/is-browser'; | ||
export {getBrowser, isMobile} from './lib/get-browser'; | ||
export {isElectron} from './lib/is-electron'; | ||
|
||
// ENVIRONMENT'S ASSERT IS 5-15KB, SO WE PROVIDE OUR OWN | ||
export {default as assert} from './utils/assert'; | ||
export {assert} from './utils/assert'; | ||
|
||
// TODO - wish we could just export a constant | ||
// export const isBrowser = checkIfBrowser(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,11 @@ | ||
// This function is needed in initialization stages, | ||
// make sure it can be imported in isolation | ||
|
||
import isElectron from './is-electron'; | ||
|
||
export default function isBrowser(): boolean { | ||
// Check if in browser by duck-typing Node context | ||
const isNode = | ||
// @ts-expect-error | ||
typeof process === 'object' && String(process) === '[object process]' && !process.browser; | ||
import {isElectron} from './is-electron'; | ||
|
||
/** Check if in browser by duck-typing Node context */ | ||
export function isBrowser(): boolean { | ||
// @ts-expect-error | ||
const isNode = typeof process === 'object' && !process?.browser; | ||
This comment has been minimized.
Sorry, something went wrong. |
||
return !isNode || isElectron(); | ||
} | ||
|
||
// document does not exist on worker thread | ||
export function isBrowserMainThread(): boolean { | ||
return isBrowser() && typeof document !== 'undefined'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,19 @@ | ||
// based on https://github.com/cheton/is-electron | ||
// https://github.com/electron/electron/issues/2288 | ||
/* eslint-disable complexity */ | ||
export default function isElectron(mockUserAgent?: string): boolean { | ||
export function isElectron(mockUserAgent?: string): boolean { | ||
// Renderer process | ||
if ( | ||
typeof window !== 'undefined' && | ||
typeof window.process === 'object' && | ||
// @ts-expect-error | ||
window.process.type === 'renderer' | ||
) { | ||
// @ts-expect-error | ||
if (typeof window !== 'undefined' && window.process?.type === 'renderer') { | ||
return true; | ||
} | ||
// Main process | ||
if ( | ||
typeof process !== 'undefined' && | ||
typeof process.versions === 'object' && | ||
// eslint-disable-next-line | ||
Boolean(process.versions['electron']) | ||
) { | ||
// eslint-disable-next-line | ||
if (typeof process !== 'undefined' && Boolean(process.versions?.['electron'])) { | ||
return true; | ||
} | ||
// Detect the user agent when the `nodeIntegration` option is set to true | ||
const realUserAgent = | ||
typeof navigator === 'object' && typeof navigator.userAgent === 'string' && navigator.userAgent; | ||
const realUserAgent = typeof navigator !== 'undefined' && navigator.userAgent; | ||
const userAgent = mockUserAgent || realUserAgent; | ||
if (userAgent && userAgent.indexOf('Electron') >= 0) { | ||
return true; | ||
} | ||
return false; | ||
return Boolean(userAgent && userAgent.indexOf('Electron') >= 0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
@ibgreen was removing the check for
String(process) === '[object process]'
intentional here?In a local demo running under
deck.gl/examples/experimental
I'm seeingisBrowser()
return false inside the browser, then luma takes the wrong path incanvas-context.ts
. Ok for me to add the expression back?