koguma 2.3.2 → 2.3.3

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/src/vite.js CHANGED
@@ -2,11 +2,11 @@
2
2
  import { createHash } from "node:crypto";
3
3
  import { readFileSync, writeFileSync, existsSync, mkdirSync } from "node:fs";
4
4
  import { join } from "node:path";
5
- function kogumaHMR() {
5
+ function kogumaHMR(options = {}) {
6
6
  const HASH_FILENAME = "dbhash";
7
- const HASH_DIR = ".koguma";
7
+ const HASH_DIR = options.kogumaDir ?? ".koguma";
8
8
  const HASH_SUBPATH = `${HASH_DIR}/${HASH_FILENAME}`;
9
- const SQLITE_GLOB = "**/.koguma/.wrangler/state/v3/d1/**/*.sqlite";
9
+ const SQLITE_GLOB = `**/${HASH_DIR}/.wrangler/state/v3/d1/**/*.sqlite`;
10
10
  return {
11
11
  name: "koguma-hmr",
12
12
  configureServer(server) {
package/src/vite.ts CHANGED
@@ -27,13 +27,22 @@ import type { Plugin } from 'vite';
27
27
  * Pair with the `server.proxy` pointing `/api` to `http://localhost:8787` so the
28
28
  * browser refetches fresh content on each reload.
29
29
  */
30
- export function kogumaHMR(): Plugin {
30
+ export interface KogumaHMROptions {
31
+ /**
32
+ * Path to the .koguma directory, relative to the Vite project root.
33
+ * Defaults to '.koguma'. Set this if your Vite config lives in a
34
+ * subdirectory of the repo (e.g. '../../.koguma').
35
+ */
36
+ kogumaDir?: string;
37
+ }
38
+
39
+ export function kogumaHMR(options: KogumaHMROptions = {}): Plugin {
31
40
  const HASH_FILENAME = 'dbhash';
32
- const HASH_DIR = '.koguma';
41
+ const HASH_DIR = options.kogumaDir ?? '.koguma';
33
42
  const HASH_SUBPATH = `${HASH_DIR}/${HASH_FILENAME}`;
34
43
 
35
44
  // Glob passed to chokidar — must NOT go through path.resolve or the ** breaks
36
- const SQLITE_GLOB = '**/.koguma/.wrangler/state/v3/d1/**/*.sqlite';
45
+ const SQLITE_GLOB = `**/${HASH_DIR}/.wrangler/state/v3/d1/**/*.sqlite`;
37
46
 
38
47
  return {
39
48
  name: 'koguma-hmr',