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.
This updates
$inspect
to usesnapshot
directly rather thandeep_snapshot
(which is no longer required), and makes reactiveMap
,Set
,Date
andURL
snapshottable, which means that instead of seeing this sort of thing in your console......you see an actual
Map
instance:If the
Map
orSet
contains state proxies, these too will be snapshotted.One downside of the current implementation: the
snapshot
code is automatically bundled when you importMap
orSet
(this doesn't apply toDate
andURL
, since nothing inside them could need snapshotting). I'd like to make thesnapshot
code treeshakeable if you useMap
orSet
but not$state.snapshot
, which is one reason this is in draft.Another reason: it would be nice if we could do this for classes with state fields too. Today, if you inspect a class like
Counter
......you see this sort of thing:
Note that we're leaking the signal implementation behind those private fields. It would be nice if it looked like this instead:
We can do that, but we want to avoid making the generated code too bloaty. The best way is probably be to extend an internal class, i.e.
class Counter {...}
becomes something likeclass Counter extends $.Class {...}
, but that doesn't work if the user already extended a class. So there's three options:extends
when declaring classes with state fields. I don't hate this, but I suspect a lot of people wouldBefore submitting the PR, please make sure you do the following
feat:
,fix:
,chore:
, ordocs:
.Tests and linting
pnpm test
and lint the project withpnpm lint