Fixes#16134
* Add a warning when the misuse of `reset` in an `error:boundary` causes an error to be thrown when flushing the boundary content
* Prevent uncaught errors to make test fails when they are expected and are fired during template effects flush
* reset should just be a noop after the first call
* correctly handle errors inside boundary during reset
* handle errors in the correct boundary
---------
Co-authored-by: Rich Harris <rich.harris@vercel.com>
* tidy
* tidy
* yes it can, apparently
* tidy up
* unused
* complete merge
* WIP
* simplify
* debugging help
* WIP
* unused
* partial merge
* WIP
* fix
* add test
* rename
* fix
* unused
* oops
* chore: merge main into async branch (#16197)
* chore: merge main into async branch
* adjust test
* fix: make effects depend on state created inside them (#16198)
* make effects depend on state created inside them
* fix, add github action
* disable test in async mode
* make batch.#deferred private
* fix settled when awaits occur inside pending boundary
* tweak
* change behaviour of `tick()` to be requestAnimationFrame-based
* get rid of a bunch of Promise.resolve chains
* more
* more
* fix test
* disallow `flushSync()` inside effects
* regenerate
* handle errors in block expressions
* make validate_each_keys async-aware
* for unowned deriveds, throw errors lazily
* rename ASYNC_ERROR -> ERROR_VALUE, and avoid conflicts with other flags now that it's used with deriveds as well as sources
* invoke boundary directly
* local effect pending
* update test
* fix
* fix
* fix weird bug in tests
* delete old changeset that somehow got left over here
* Update .changeset/eleven-weeks-dance.md
* update error details
* unused
* simplify
* tweak
* tweak
* tweak
* tweak
* tidy up
* handle errors in async block expressions
* tweak
* groundwork for async attribute_effect
* dry out
* fix async directives
* tidy up
* initialize option values before initing select values
* simplify init_select
* simplify
* tweak
* tidy up
* tweak
* on second thoughts just simplify it here
* tidy
* handle awaits in `<slot>`
* unused
* tidy up
* tidy up
* dry out
* dry out
* Revert "dry out"
This reverts commit 25855163bf.
* dry out
* dry out
* use let for block-scoped stuff
* dry out
* dry out
* tidy up
* only wrap awaits in `$.save` when necessary
* oops
* remove TODO comment (just checked)
* oops, leftover
* simplify
* unused
* remove logging
* tweak
* unused
* unused
* remove logging
* partial fix
* fix
* remove unused EFFECT_HAS_DERIVED
* Update packages/svelte/src/reactivity/create-subscriber.js
Co-authored-by: Elliott Johnson <sejohnson@torchcloudconsulting.com>
* Update packages/svelte/src/index-client.js
Co-authored-by: Elliott Johnson <sejohnson@torchcloudconsulting.com>
* Update packages/svelte/src/internal/client/runtime.js
Co-authored-by: Elliott Johnson <sejohnson@torchcloudconsulting.com>
* unused
* Update packages/svelte/src/internal/client/reactivity/sources.js
Co-authored-by: Elliott Johnson <sejohnson@torchcloudconsulting.com>
* Update packages/svelte/src/internal/client/reactivity/deriveds.js
Co-authored-by: Elliott Johnson <sejohnson@torchcloudconsulting.com>
* Update packages/svelte/src/internal/client/reactivity/deriveds.js
Co-authored-by: Elliott Johnson <sejohnson@torchcloudconsulting.com>
* prettier
* unused
* fix flags
* tweak
* tweak
* unused
* fix
* no idea what a 'boundary micro task' is or why it was deemed necessary but evidently it isn't
* remove queue_boundary_micro_task
* oops
* note
* tidy up
* remove TODO
* make method private
* simplify
* flesh out await_reactivity_loss warning
* tweak
* update test
* fix
* null out from_async_derived in more places
* tidy up test
* failing test
* unused
* fix test
* fix
* simplify. no idea what the async_mode_flag stuff is about, but it appears unnecessary
* add async_derived_orphan error
* regenerate
* flesh out await_outside_boundary message
* add some JSDoc
* only update `$effect.pending()` if someone is listening, since it causes a double flush and makes debugging harder
* tweak logic to make it clearer why and when we commit a batch
* add a couple of comments
* false -> 0
* add comment
* unused
* silence warning
* add effect_pending_outside_reaction error
* Update packages/svelte/src/compiler/types/index.d.ts
Co-authored-by: Elliott Johnson <sejohnson@torchcloudconsulting.com>
* suspend batch, not boundary
* rename from_async_derived -> current_async_derived
* tweak
* remove TODO - this method is only called when pending snippet exists
* use error boundary for test - vitest does some weird error swallowing afaict
* flush less often
* restore -> activate
* remove TODO
* move batch-related code into batch.js
* make flush_queued_root_effects a method of batch
* make process_effects a method of batch
* make stuff private
* unused
* regenerate
* update test
* more JSDoc
* add more JSDoc
* branch and block effects do not also need to be render effects
* tidy up
* simplify
* unused
* move code where it belongs
* remove, for now
* fix
* only apply error adjustments when error escapes boundaries
* remove EFFECT_IS_UPDATING
* is_dirty is a better name than check_dirtiness
* duplicates are rare and harmless
* apparently we no longer need the merging logic? we can simplify and fix stuff by removing it
* tidy
* don't commit stale batches
* add skipped failing test
* partial merge
* WIP
* WIP
* WIP
* tweak
* tidy up
* dont update derived status when time-travelling
* tidy up
* tidy up
* tag async deriveds
* tweak
* bail out of secondary flushes
* re-run blocks on subsequent flushes
* add test
* fix
* add tests, one failing
* fix
* flesh out await_waterfall message
* tidy up
* dry out
* unused
* tweak
* tidy up
* TODO
* tweak
* tidy up
* remove TODO
* unused export
* add optimisation back
* revert unneeded changes
* revert
* update some tests
* more
* more
* move some code
* rename
* WIP
* unset context synchronously
* remove unused argument
* Apply suggestions from code review
Co-authored-by: Simon H <5968653+dummdidumm@users.noreply.github.com>
* add comment
* add comment
* use queue_micro_task in createSubscriber
* Update packages/svelte/src/compiler/phases/3-transform/client/visitors/AwaitExpression.js
Co-authored-by: Elliott Johnson <sejohnson@torchcloudconsulting.com>
* prettier
---------
Co-authored-by: Simon H <5968653+dummdidumm@users.noreply.github.com>
Co-authored-by: Simon Holthausen <simon.holthausen@vercel.com>
Co-authored-by: Elliott Johnson <sejohnson@torchcloudconsulting.com>
* fix: warn when using rest or identifier in custom elements without props option
* chore: update message
* tweak message
* update tests
---------
Co-authored-by: Rich Harris <rich.harris@vercel.com>
* feat: State declarations in class constructors
* feat: Analysis phase
* misc
* feat: client
* improvements
* feat: It is now at least backwards compatible. though the new stuff may still be wrong
* feat: It works I think?
* final cleanup??
* tests
* test for better types
* changeset
* rename functions (the function doesn't test call-expression-ness)
* small readability tweak
* failing test
* fix
* disallow computed state fields
* tweak message to better accommodate the case in which state is declared after a regular property
* failing test
* wildly confusing to have so many things called 'class analysis' - rename the transform-phrase ones to transformers
* missed a spot
* and another
* store analysis for use during transformation
* move code to where it is used
* do the analysis upfront, it's way simpler
* skip failing test for now
* simplify
* get rid of the class
* on second thoughts
* reduce indirection
* make analysis available at transform time
* WIP
* WIP
* WIP
* fix
* remove unused stuff
* revert snapshot tests
* unused
* note to self
* fix
* unused
* unused
* remove some unused stuff
* unused
* lint, tidy up
* reuse helper
* tweak
* simplify/DRY
* unused
* tweak
* unused
* more
* tweak
* tweak
* fix proxying logic
* tweak
* tweak
* adjust message to accommodate more cases
* unskip and fix test
* fix
* move
* revert unneeded drive-by change
* fix
* fix
* update docs
---------
Co-authored-by: Rich Harris <rich.harris@vercel.com>
* fix: warn on bidirectional control characters
* check evaluated values as well, fix minor issue
* fix failing tests
* lint
* fix
* shrink warning code
* use validator test suite rather than snapshot (which should be used sparingly as it creates more git noise)
* show ranges during parsing, and warn on all occurrences rather than just the first
* fix lint
* move check into Text visitor so it happens in expected order
* unused
* add svelte-ignore test
* ignore control characters following a svelte-ignore comment
* tweak message
* no need to test evaluations, since we are already testing the literals that they are composed of
---------
Co-authored-by: Rich Harris <rich.harris@vercel.com>
* init
* fix
* make `Payload` a class
* doh
* lint
* tweak changeset
* fix
* only export things that should be available on $
* tweak message
* fix
---------
Co-authored-by: Rich Harris <rich.harris@vercel.com>
* remove old validation
* fix: rework binding ownership validation
Previously we were doing stack-based retrieval of the owner, which while catching more cases was costly (performance-wise) and prone to errors (as shown by many issues over the months).
This drastically simplifies the ownership validation - we now only do simple static analysis to check which props are mutated and wrap them with runtime checks to see if a binding was established.
Besides making the implementation simpler and more performant, this also follows an insight we had over the months: Most people don't really know what to do with this warning when it's shown beyond very simple cases. Either it's not actionable because they don't really know how to fix it or they question if they should at all (in some cases rightfully so). Now that the warning is only shown in simple and easy-to-reason-about cases, it has a much better signal-to-noise-ratio and will hopefully guide people in the right direction early on (learn from the obvious cases to not write spaghetti code in more complex cases).
closes#15532closes#15210closes#14893closes#13607closes#13139closes#11861
* remove some now obsolete tests
* fix
* better warnings now that we have more info
* fix
* hoist
* we only care about mutation, not reassignment
* tidy
* handle prop aliases
* mutation validation is only tangentially linked to context requirement
* no need for two vars, one will do
* update warning, include mutation location
* tweak
---------
Co-authored-by: Rich Harris <rich.harris@vercel.com>
* fix: prevent state runes from being called with spread
* prevent spread arguments for all runes except $inspect
---------
Co-authored-by: Rich Harris <rich.harris@vercel.com>
* move parent property onto Signal
* don't self-invalidate when updating a source create inside current reaction
* lazily create deep state with parent reaction
* no need to push_derived_source with mutable_state, as it never coexists with $.derived
* reduce indirection
* remove state_unsafe_local_read error
* changeset
* tests
* fix test
* inelegant fix
* remove arg
* tweak
* some progress
* more
* tidy up
* parent -> p
* tmp
* alternative approach
* tidy up
* reduce diff size
* more
* update comment
fixes#14532
This removes the `reactive_declaration_non_reactive_property` warning altogether. The first version caused many false positives at compile time. The refined runtime version (introduced in #14192) was hoped to fix this, but it turns out we now get loads of false positives at runtime.
* docs: more details for errors/warnings on the site
Related to #11305
* Apply suggestions from code review
Co-authored-by: Rich Harris <rich.harris@vercel.com>
* fix in correct place
* tab not spaces
* tweaks
* fix
* Apply suggestions from code review
* regenerate
---------
Co-authored-by: Rich Harris <rich.harris@vercel.com>
* fix: better error messages for invalid HTML trees
closes#13331
* fix test
* more concise
* tweak
* tweak messages
* adjust tests
* tweak message slightly, so it doesn't sound like the bad element is the one we're currently encountering
* put locations in generated message
* tidy up
* consistency
* fix
---------
Co-authored-by: Rich Harris <rich.harris@vercel.com>
* add failing test for #14268
* simplify
* proxify values when using ||=, &&= and ??= assignment operators
* proxify values assigned to private state fields
* changeset
* fix
* fix
* add warning
* update test
* turn `reactive_declaration_non_reactive_property` into a runtime warning
* ignore warning
* Update packages/svelte/src/internal/client/reactivity/effects.js
Co-authored-by: Simon H <5968653+dummdidumm@users.noreply.github.com>
* Update packages/svelte/src/internal/client/runtime.js
Co-authored-by: Simon H <5968653+dummdidumm@users.noreply.github.com>
* fix
* test
* changeset
* Update .changeset/witty-turtles-bake.md
Co-authored-by: Simon H <5968653+dummdidumm@users.noreply.github.com>
* add some details
* check
* regenerate
---------
Co-authored-by: Simon H <5968653+dummdidumm@users.noreply.github.com>