@skgo/sveltekit-adapter 0.22.1 → 0.28.2

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.22.1",
3
+ "version": "0.28.2",
4
4
  "description": "SvelteKit adapter for skgo: builds a frontend that a Go binary renders and answers",
5
5
  "keywords": [
6
6
  "adapter",
@@ -1067,7 +1067,12 @@ export function gojaDevUnchangedFiles({ out = 'build' } = {}) {
1067
1067
 
1068
1068
  config(config) {
1069
1069
  const emitted = posix(resolve(config.root ?? process.cwd(), out));
1070
- return { server: { watch: { ignored: [emitted, `${emitted}/**`] } } };
1070
+ // Chokidar's ordinary change path drops a second edit inside 50 ms.
1071
+ // Its supported pending-write path instead delivers settled contents.
1072
+ const stability = config.server?.watch?.awaitWriteFinish === undefined
1073
+ ? { awaitWriteFinish: { stabilityThreshold: 200, pollInterval: 25 } }
1074
+ : {};
1075
+ return { server: { watch: { ...stability, ignored: [emitted, `${emitted}/**`] } } };
1071
1076
  },
1072
1077
 
1073
1078
  configureServer(server) {
@@ -1087,13 +1092,18 @@ export function gojaDevUnchangedFiles({ out = 'build' } = {}) {
1087
1092
  // Kit validates templates synchronously from its watcher. An in-place
1088
1093
  // save can expose truncated bytes; report that validation error but
1089
1094
  // keep the watcher alive so the completed save can regenerate Kit.
1095
+ // Kit's listener was registered before this post plugin; wrapping emit
1096
+ // catches its synchronous throw before it escapes the filesystem callback.
1090
1097
  const notify = (receiver, event, args, file) => {
1091
1098
  try {
1092
1099
  return emit.call(receiver, event, ...args);
1093
1100
  } catch (error) {
1094
1101
  const authored = typeof file === 'string' ? relative(server.config.root, file) : null;
1095
- if (!(error instanceof Error) || authored === null ||
1096
- !['%sveltekit.head%', '%sveltekit.body%'].some(tag => error.message === `${authored} is missing ${tag}`)) throw error;
1102
+ const [code, body] = error instanceof Error ? error.message.split('\n') : [];
1103
+ const templateError = code === 'app_template_missing'
1104
+ ? body === `${authored} does not exist`
1105
+ : code === 'app_template_tag_missing' && ['%sveltekit.head%', '%sveltekit.body%'].some(tag => body === `${authored} is missing \`${tag}\``);
1106
+ if (!(error instanceof Error) || error.name !== 'SvelteKit error' || authored === null || !templateError) throw error;
1097
1107
  known.delete(posix(file));
1098
1108
  server.config.logger.error(error.stack ?? error.message);
1099
1109
  server.ws.send({ type: 'error', err: { message: error.message, stack: error.stack ?? '', plugin: 'skgo-dev-unchanged-files' } });