-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Interactivity API: Refactor internal proxy and signals system (#62734)
* WIP * More WIP * Restore previous packages * Fix current tests * Add computation tests * Fix getter call * Fix for..in on new properties * Refactor code a little * Add tests for getters with scope * Move namespaces to properties * Fix a problem with object references * Add store handlers * Add signals-core dependency * Rename Property to PropSignal * Move withScope inside PropSignal logic * Create proxies folder * Attempt to make the context work * Reorganize code * Make peek() return only the value inside signalValue * A bit of refactoring * Return the computed value with `peek()` * Rename DEFAULT_SCOPE to NO_SCOPE * Remove deepsignal * Handle functions inside state * Fix withScope in this PR * Fix context proxification * Move store root logic to store proxy handlers * Move store initialization inside init * Add TODO comment inside `peek()` * Fix store root assignments * Fix lint error * Enable skipped test for non-initialized getters * Rename get(State|Store)Proxy to proxify(State|Store) * Make `getContext` throw when there is no scope * Fix `proxifyState` types * Rename some variables in tests * Add test for object reference keeping * Rename test suite for state proxy * Add tests for getters and functions with scope * Add tests for prop subscription inside functions * Allow functions to use `this` * Minor fixes * Add tests to store proxies * Throw an error when an object cannot be proxified * Change peek implementation * Add tests for peek and unsupported structures * Test peeking getters that access scope or other namespaces * Ignore well-known symbols * Minor comment format fix * Move namespace arg to first position in proxify functions * chore: Update jest.config.js to stop ignoring deepsignal because we removed it as dependency * Add comments to proxy registry * Remove namespace from PropSignal * Remove unused `peekValueSignal` method * Simplify PropSignal methods * Add TSDocs to PropSignal * Disable unused vars lint rule in state-proxy tests * Remove descriptor alias * Expand `getProxyNs` docs * Add more comments in `state` * Refactor state functions and add tsdocs * Fix some grammar issues * Fix default namespace for setters * Replace `isNotRoot` with `isRoot` * Update comments in store.ts * Move `isPlainObject` to utils * Remove remaining deepSignal references * Delete unnecessary @ts-ignore-next-line * Use `isPlainObject` from utils inside store * Move scopes and namespaces to separate files * Call `init` outside `DOMContentLoaded` * Replace `signals-core` imports with `signals` * Rename `proxiedStore` to `proxifiedStore` Co-authored-by: Luis Herranz <luisherranz@gmail.com> * Remove unnecessary `peek()` call * Throw more descriptive errors from getContext and getElement * Use more descriptive name for proxy functions * Use destructured `get` inside `setGetter` call * Add comment to explain `objToIterable` signals subscription Co-authored-by: Luis Herranz <luisherranz@gmail.com> * Change line comment to block comment * Replace `?` with `!` operator * Wrap Interactivity API tests with appropriate `describe` * Remove unnecessary `setNamespace` calls in tests * Remove duplicated test * Fix typo * Add extra tests for getter modification * Test the right namespace is used inside getters * Fix test name * Check if length's PropSignal exists before updating its value * Add deepMerge tests and prevent server overwritting * Make sure context inheritance is shallow and server props don't overwrite * Refactor wp-each to use new proxifyContext structure --------- Co-authored-by: DAreRodz <darerodz@git.wordpress.org> Co-authored-by: michalczaplinski <czapla@git.wordpress.org> Co-authored-by: luisherranz <luisherranz@git.wordpress.org> Co-authored-by: gziolo <gziolo@git.wordpress.org> Co-authored-by: otakupahp <otakupahp@git.wordpress.org> Co-authored-by: sirreal <jonsurrell@git.wordpress.org>
- Loading branch information
1 parent
c384bb6
commit bd9ba41
Showing
26 changed files
with
2,571 additions
and
434 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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.