-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: multi effects, smaller size, better testing
- Loading branch information
Showing
25 changed files
with
6,006 additions
and
5,242 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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/sh | ||
. "$(dirname "$0")/_/husky.sh" | ||
|
||
yarn commitlint --edit "$1" |
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,4 @@ | ||
#!/bin/sh | ||
. "$(dirname "$0")/_/husky.sh" | ||
|
||
yarn lint-staged |
Large diffs are not rendered by default.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Large diffs are not rendered by default.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// from dequal/lite | ||
export let hasOwnProperty = Object.prototype.hasOwnProperty; | ||
|
||
export function dequal(foo: any, bar: any) { | ||
let ctor, len; | ||
if (foo === bar) return true; | ||
|
||
if (foo && bar && (ctor = foo.constructor) === bar.constructor) { | ||
if (ctor === Date) return foo.getTime() === bar.getTime(); | ||
if (ctor === RegExp) return foo.toString() === bar.toString(); | ||
|
||
if (ctor === Array) { | ||
if ((len = foo.length) === bar.length) { | ||
while (len-- && dequal(foo[len], bar[len])); | ||
} | ||
return len === -1; | ||
} | ||
|
||
if (!ctor || typeof foo === 'object') { | ||
len = 0; | ||
for (ctor in foo) { | ||
if ( | ||
hasOwnProperty.call(foo, ctor) && | ||
++len && | ||
!hasOwnProperty.call(bar, ctor) | ||
) | ||
return false; | ||
if (!(ctor in bar) || !dequal(foo[ctor], bar[ctor])) | ||
return false; | ||
} | ||
return Object.keys(bar).length === len; | ||
} | ||
} | ||
|
||
return foo !== foo && bar !== bar; | ||
} |
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,32 +1,23 @@ | ||
/* istanbul ignore file */ | ||
import type { StateAtom } from '.'; | ||
function serialize(state: any) { | ||
if (!state) return state; | ||
|
||
function getAtomState(atom: StateAtom<any>) { | ||
if (!atom.state) return atom.state; | ||
|
||
return JSON.parse(JSON.stringify(atom.state)); | ||
return JSON.parse(JSON.stringify(state)); | ||
} | ||
|
||
export function debugAtom(key: string, atom: StateAtom<any>) { | ||
postMessage( | ||
export function sendMessageToDevTools( | ||
key: string, | ||
type: 'NEW_ATOM' | 'UPDATE_ATOM', | ||
value: any | ||
) { | ||
if (typeof window === 'undefined') return; | ||
|
||
window.postMessage( | ||
{ | ||
from: 'state-atom', | ||
type: 'NEW_ATOM', | ||
type, | ||
key, | ||
value: getAtomState(atom), | ||
value: serialize(value), | ||
}, | ||
'*' | ||
); | ||
|
||
atom.add(() => { | ||
postMessage( | ||
{ | ||
from: 'state-atom', | ||
type: 'UPDATE_ATOM', | ||
key, | ||
value: getAtomState(atom), | ||
}, | ||
'*' | ||
); | ||
}); | ||
} |
Oops, something went wrong.