Skip to content

Commit 793ae28

Browse files
dummdidummtrueadmRich-Harrispaoloricciutiottomated
authored
Remote Functions (#13986)
* Remote Functions Exploration PR (#13957) * initial commit * various fixes * tweak demo * fix * remove acorn-typescript * simplify * fix * generate, don't transform * use an x- header * regenerate manifest when remote files are added/removed * move RPC logic out of page, it belongs elsewhere * use _app/remote/x * tighten up error handling * unused * CSRF * smaller payloads * belt and braces * don't use 204, that only applies to DELETE/PUT requests * turn remote_call into a factory - more compact and gives us a lot more options * analyze exports of remotes dynamically, add query/action/formAction as different types of remotes * update playground * POC: hydrate query results * remote form actions that hydrate and work without JS * conditional * load fn WIP * rerun query on invalidation * make it possible to call invalidate in rpc functions * fix * adjust form API * fix dev stale bug * let rpc partake in prerendering * prerender POC * cache POC * simplify server remote logic by leveraging ESM self imports * cleanup server remote info * rename functions + some docs * move more stuff into functions to deduplicate/cleanup/make connections clearer * prerendering * hide remote url, avoid unnecessary work * cache refinement * various fixes * tests * don't call prerender function at runtime, tweak tests * tweak * tweak caching behavior * remove cache function from public API for now * add experimental flag * remove load helper function for now * move file * add refreshAll, related to #13139 * adjust overrides signature * query/redirect/form-fail handling * adjust caching behavior to cache until query is removed * disallow non-remote-function exports from .remote files * bump dts-buddy to be able to generate types without bugs again * handle query redirect without going through error boundaries * harmonize refresh with override signature * fixes * resolve cyclic import dependency * prerender treeshaking * refine API * refresh from the server * adjust tests, fix * adjust prerender * reorder functions * make query eager on the client if in reactive context * implement current/error/pending * remove optimistic in favor of override callback * add validate * form.for(...) * tweak api around redirects; allow single flight mutation redirect * implement stacking override API * fixes * deduplicate remote calls on the server during full page visits * rework to use resource class, fix some bugs * ensure refresh/then resolve in order * microtask tweaking * fix * cleanse event for remote functions * implement `updates` and `withOverride` for command * implement `updates` and `withOverride` for form * cleanup * Prevent state_unsafe_mutation error * restrict to 0 or 1 argument, enforce validation * validation tests * tweak * comment out for the time being * remove validate function * lint * guard * bump Svelte version * silence type errors * Update packages/kit/src/runtime/app/server/remote.js Co-authored-by: Paolo Ricciuti <[email protected]> * fix * update playground --------- Co-authored-by: Dominic Gannaway <[email protected]> Co-authored-by: Rich Harris <[email protected]> Co-authored-by: Paolo Ricciuti <[email protected]> * cleanup * remove cache code for now * handleValidationError * error property * code review * tweak / simplify * Apply suggestions from code review Co-authored-by: Rich Harris <[email protected]> * fix * fix params prop on leaf component * refresh queries after goto with invalidateAll * fix redirect logic * revert overrides on error * work around Svelte bug * lint * add names to error messages * put remote function id etc assignment into helper function and add original filename for better error messages * use cache API for prerendered functions * status/isLoading property * add set method to resource * tweak * more error message tweaks * regenerate * use tick() * Update packages/kit/src/runtime/client/remote.svelte.js * validationerror issues tweak * handle exotic characters when btoa encoding * prerender tweaks * make fn execution a method * changeset * Update packages/kit/src/runtime/client/remote.svelte.js * Add RemoteCommand type (#14020) * Add RemoteCommand type * fix async lint error * documentation * regenerate types * tweaks to `remote-functions` (#14034) * remove cache stuff for now as it seems likely we will go in a different direction * tweak error * put prerendered data in separate directory * fix * tweak some wording * tweak * tweak * simplify * lol whoops * tweak error message * entries -> inputs * update entries -> inputs in docs * write prerendered data to correct place * fix test * fix * jfc * remote functions: fix prerender types etc (#14037) * RemoteFormAction -> RemoteForm * fix types, separate query/prerender implementations * only refresh queries, not prerenders * fix * remove override from implementation and tests * remote functions: await form result (#14038) * docs * adjust docs example * turn RemoteQuery<Promise<Thing>> into RemoteQuery<Thing> * make forms non-callable (#14045) * make forms non-callable * regenerate * lint * Update packages/kit/src/runtime/app/server/remote.js Co-authored-by: Rich Harris <[email protected]> --------- Co-authored-by: Simon H <[email protected]> * get rid of status, add ready * remove fail() support from remote forms * fix types / lint * form doc tweaks * fix indentation * hash once * make remotes project-relative * fix * fix * uneval lazily * don't swallow errors * surface errors more reliably, prevent crashes * don't clear remote_responses cache on failure. embrace the failure * lint * simplify * typo * tweak * regenerate * lint * add some more explanatory comments * simplify * compute action/formaction lazily — this lets us initialize all remote functions the same way * remote function init is now simple enough that we can just inline it * WIP * WIP use existing metadata * no need for intermediate disk output * unused * bundle together * add explanatory comment * tweak comment * tweak * put functions in the order they are used * debug windows nonsense * more debugging * more debugging * more * gah * wtaf * come ON * so confused * ugh * more * howwwwwwww * stab in the dark * try this * fucking FINALLY * remove junk * remove outdated comment * tweak * tweak naming * separate blocks out * call functions directly * tweak some names * tweaks * capitalise Bad Request * tweaks, make cache key easier to split * tweak * simplify * tweak * make methods appear as methods rather than properties * WIP move to separate files * WIP extract shared logic * WIP more * WIP more * move remote functions into individual modules — will be easier to work with * hoist * hoist for property * add type safety, make `entry.count` (as opposed to `entry[0]`) a reality * simplify * typo * fix * same on server - move functions into their own modules * tweak * error eagerly - results in a much more useful stack trace * this always exists * generalize the concept of event-scoped state, since it is useful beyond remote functions * make form_instances lazy * make remote data lazy * simplify * repeat * tweak form docs * prerendering error is redundant, it's all covered under SSR * unused * oops * defer to the full docs - it's impossible to document these in isolation, and the current samples have issues with shadowing, missing auth etc * regenerate * make error handling consistent between enhanced and non-enhanced forms * remove form.error property * regenerate * tweak * make docs buildable * tabs * enumerable: false is redundant * WIP docs * update tests * remove this section for now * reuse login/register example * formAction -> buttonProps * tweak docs * more docs updates * more docs * already covered elsewhere * tweaks * docs * add missing since tags * regenerate --------- Co-authored-by: Dominic Gannaway <[email protected]> Co-authored-by: Rich Harris <[email protected]> Co-authored-by: Paolo Ricciuti <[email protected]> Co-authored-by: Rich Harris <[email protected]> Co-authored-by: ottomated <[email protected]>
1 parent a6f7259 commit 793ae28

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+4855
-164
lines changed

.changeset/heavy-insects-wash.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@sveltejs/kit': minor
3+
---
4+
5+
feat: remote functions

0 commit comments

Comments
 (0)