@skgo/sveltekit-adapter 0.17.0 → 0.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skgo/sveltekit-adapter",
3
- "version": "0.17.0",
3
+ "version": "0.18.0",
4
4
  "description": "SvelteKit adapter for skgo: builds a frontend that a Go binary renders and answers",
5
5
  "keywords": [
6
6
  "adapter",
@@ -752,9 +752,18 @@ export async function remoteLoad(module, source, event) {
752
752
  if (cookies.length) {
753
753
  headers.cookie = [cookies.map(({ name, value }) => `${encodeURIComponent(name)}=${encodeURIComponent(value)}`).join('; ')];
754
754
  }
755
+ // Kit's JS matcher results cannot construct named Go values. Send its
756
+ // actual route metadata and the unconverted path to the build-only Go load.
757
+ const { manifest } = await import(pathToFileURL(join(appRoot(), '.svelte-kit/output/server/manifest-full.js')).href);
758
+ const route = manifest.routes.find((candidate) => candidate.id === event.route.id);
759
+ const prefix = manifest.app_path.slice(0, -manifest.app_dir.length);
760
+ const base = prefix ? '/' + prefix.slice(0, -1) : '';
761
+ const { decode_pathname } = await import(pathToFileURL(join(kitRootFor(appRoot()), 'src/utils/url.js')).href);
755
762
  const request = {
756
763
  kind: 'load', module, url: event.url.href, routeId: event.route.id,
757
- params: Object.fromEntries(Object.entries(event.params)), parent: await event.parent(), headers
764
+ params: {}, parent: await event.parent(), headers,
765
+ ...(route ? { routePattern: route.pattern.source, routeParams: route.params,
766
+ routePath: decode_pathname(event.url.pathname).slice(base.length) || '/' } : {})
758
767
  };
759
768
  const raw = await invokeWorker(request);
760
769
  const answer = JSON.parse(raw);