-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: Cut deprecated exports/methods to save a few kilobytes #250
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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; | ||
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is this from and why do we need it?