void 0.7.11 → 0.7.12

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/dist/cli/cli.mjs CHANGED
@@ -1519,7 +1519,7 @@ else if (command === "deploy") {
1519
1519
  else if (command === "project") runSubcommandGroup("project", projectSubcommands, parseProjectArgs, (root, parsed) => import("../project-cmd-CeXO06hG.mjs").then(({ runProjectCommand }) => runProjectCommand(root, parsed)));
1520
1520
  else if (command === "secret") runSubcommandGroup("secret", secretSubcommands, parseSecretArgs, (root, parsed) => import("../secret-NDvlqAN2.mjs").then(({ runSecretCommand }) => runSecretCommand(root, parsed)));
1521
1521
  else if (command === "domain") runSubcommandGroup("domain", domainSubcommands, parseDomainArgs, (root, parsed) => import("../domain-Dvj7u8tr.mjs").then(({ runDomainCommand }) => runDomainCommand(root, parsed)));
1522
- else if (command === "db") runSubcommandGroup("db", dbSubcommands, parseDbArgs, (root, parsed) => import("../db-j-XdTjQD.mjs").then(({ runDbCommand }) => runDbCommand(root, parsed)));
1522
+ else if (command === "db") runSubcommandGroup("db", dbSubcommands, parseDbArgs, (root, parsed) => import("../db-YEYSTfGw.mjs").then(({ runDbCommand }) => runDbCommand(root, parsed)));
1523
1523
  else if (command === "env") runSubcommandGroup("env", envSubcommands, parseEnvArgs, (root, parsed) => import("../env-Bjl0rzuf.mjs").then(({ runEnvCommand }) => runEnvCommand(root, parsed)));
1524
1524
  else if (command === "gen") runSubcommandGroup("gen", genSubcommands, parseGenArgs, (root, parsed) => import("../gen-DU8NIdrH.mjs").then(({ runGenCommand }) => runGenCommand(root, parsed)));
1525
1525
  else if (command === "prepare") {
@@ -1646,7 +1646,7 @@ else if (command === "-v" || command === "--version") {
1646
1646
  case "project": return runSubcommandGroup("project", projectSubcommands, parseProjectArgs, (r, p) => import("../project-cmd-CeXO06hG.mjs").then(({ runProjectCommand }) => runProjectCommand(r, p)));
1647
1647
  case "secret": return runSubcommandGroup("secret", secretSubcommands, parseSecretArgs, (r, p) => import("../secret-NDvlqAN2.mjs").then(({ runSecretCommand }) => runSecretCommand(r, p)));
1648
1648
  case "domain": return runSubcommandGroup("domain", domainSubcommands, parseDomainArgs, (r, p) => import("../domain-Dvj7u8tr.mjs").then(({ runDomainCommand }) => runDomainCommand(r, p)));
1649
- case "db": return runSubcommandGroup("db", dbSubcommands, parseDbArgs, (r, p) => import("../db-j-XdTjQD.mjs").then(({ runDbCommand }) => runDbCommand(r, p)));
1649
+ case "db": return runSubcommandGroup("db", dbSubcommands, parseDbArgs, (r, p) => import("../db-YEYSTfGw.mjs").then(({ runDbCommand }) => runDbCommand(r, p)));
1650
1650
  case "env": return runSubcommandGroup("env", envSubcommands, parseEnvArgs, (r, p) => import("../env-Bjl0rzuf.mjs").then(({ runEnvCommand }) => runEnvCommand(r, p)));
1651
1651
  case "gen": return runSubcommandGroup("gen", genSubcommands, parseGenArgs, (r, p) => import("../gen-DU8NIdrH.mjs").then(({ runGenCommand }) => runGenCommand(r, p)));
1652
1652
  case "prepare": {
@@ -100,7 +100,7 @@ async function runPush(root, dialect) {
100
100
  else {
101
101
  const { mkdirSync } = await import("node:fs");
102
102
  const { dirname } = await import("node:path");
103
- const { getMiniflareDatabasePath } = await import("./runner-BaWsik5f.mjs");
103
+ const { getMiniflareDatabasePath } = await import("./runner-C0d3lJo1.mjs");
104
104
  const dbPath = getMiniflareDatabasePath(getLocalD1PersistRoot(root), "local");
105
105
  mkdirSync(dirname(dbPath), { recursive: true });
106
106
  configPath = writeDrizzleConfig(root, dbPath);
@@ -157,7 +157,7 @@ async function runStatus(root, dialect) {
157
157
  localApplied = [];
158
158
  }
159
159
  else {
160
- const { getMiniflareDatabasePath, getAppliedMigrations } = await import("./runner-BaWsik5f.mjs");
160
+ const { getMiniflareDatabasePath, getAppliedMigrations } = await import("./runner-C0d3lJo1.mjs");
161
161
  localApplied = await getAppliedMigrations(getMiniflareDatabasePath(getLocalD1PersistRoot(root), "local"));
162
162
  }
163
163
  const localSet = new Set(localApplied.map((m) => m.name));
@@ -215,7 +215,7 @@ async function resetDatabase(root, dialect) {
215
215
  });
216
216
  return migrations.length;
217
217
  }
218
- const { getMiniflareDatabasePath, runMigrations } = await import("./runner-BaWsik5f.mjs");
218
+ const { getMiniflareDatabasePath, runMigrations } = await import("./runner-C0d3lJo1.mjs");
219
219
  const dbPath = getMiniflareDatabasePath(getLocalD1PersistRoot(root), "local");
220
220
  rmSync(dbPath, { force: true });
221
221
  rmSync(dbPath + "-wal", { force: true });
@@ -242,7 +242,7 @@ async function runSeed(root, file, dialect) {
242
242
  ye("Done.");
243
243
  return;
244
244
  }
245
- const { getMiniflareDatabasePath, openSqliteDatabase } = await import("./runner-BaWsik5f.mjs");
245
+ const { getMiniflareDatabasePath, openSqliteDatabase } = await import("./runner-C0d3lJo1.mjs");
246
246
  const db = await openSqliteDatabase(getMiniflareDatabasePath(getLocalD1PersistRoot(root), "local"));
247
247
  try {
248
248
  db.exec(sql);
@@ -265,7 +265,7 @@ async function runExecute(root, command, file, dialect) {
265
265
  ye("Done.");
266
266
  return;
267
267
  }
268
- const { getMiniflareDatabasePath, openSqliteDatabase } = await import("./runner-BaWsik5f.mjs");
268
+ const { getMiniflareDatabasePath, openSqliteDatabase } = await import("./runner-C0d3lJo1.mjs");
269
269
  const dbPath = getMiniflareDatabasePath(getLocalD1PersistRoot(root), "local");
270
270
  if (!existsSync(dbPath)) {
271
271
  R.error("No local database found. Run `void dev` first.");
@@ -386,7 +386,7 @@ async function runMigrate(root, dialect, remote) {
386
386
  ye("Done.");
387
387
  return;
388
388
  }
389
- const { getMiniflareDatabasePath, getAppliedMigrations, runMigrations } = await import("./runner-BaWsik5f.mjs");
389
+ const { getMiniflareDatabasePath, getAppliedMigrations, runMigrations } = await import("./runner-C0d3lJo1.mjs");
390
390
  const dbPath = getMiniflareDatabasePath(getLocalD1PersistRoot(root), "local");
391
391
  try {
392
392
  const existingRows = await getAppliedMigrations(dbPath);
@@ -421,7 +421,7 @@ async function runStudio(root, dialect) {
421
421
  return;
422
422
  }
423
423
  const { writeDrizzleConfig } = await import("./config-DyUSwbeX.mjs").then((n) => n.t);
424
- const { getMiniflareDatabasePath } = await import("./runner-BaWsik5f.mjs");
424
+ const { getMiniflareDatabasePath } = await import("./runner-C0d3lJo1.mjs");
425
425
  const dbPath = getMiniflareDatabasePath(getLocalD1PersistRoot(root), "local");
426
426
  if (!existsSync(dbPath)) {
427
427
  R.error("No local database found. Run `void dev` first.");
@@ -641,7 +641,7 @@ async function runRenameMigrations(root, dialect) {
641
641
  process.exit(1);
642
642
  }
643
643
  else {
644
- const { getMiniflareDatabasePath, openSqliteDatabase } = await import("./runner-BaWsik5f.mjs");
644
+ const { getMiniflareDatabasePath, openSqliteDatabase } = await import("./runner-C0d3lJo1.mjs");
645
645
  const dbPath = getMiniflareDatabasePath(getLocalD1PersistRoot(root), "local");
646
646
  if (existsSync(dbPath)) try {
647
647
  const db = await openSqliteDatabase(dbPath);
@@ -719,7 +719,7 @@ async function runExport(root, args, dialect) {
719
719
  } else process.stdout.write(output);
720
720
  return;
721
721
  }
722
- const { getMiniflareDatabasePath, openSqliteDatabase } = await import("./runner-BaWsik5f.mjs");
722
+ const { getMiniflareDatabasePath, openSqliteDatabase } = await import("./runner-C0d3lJo1.mjs");
723
723
  const dbPath = getMiniflareDatabasePath(getLocalD1PersistRoot(root), "local");
724
724
  if (!existsSync(dbPath)) {
725
725
  R.error("No local database found. Run `void dev` first.");
@@ -846,7 +846,7 @@ async function runSeedModule(root, seedPath, dialect) {
846
846
  return;
847
847
  }
848
848
  const { drizzle } = await import("drizzle-orm/better-sqlite3");
849
- const { getMiniflareDatabasePath, openSqliteDatabase } = await import("./runner-BaWsik5f.mjs");
849
+ const { getMiniflareDatabasePath, openSqliteDatabase } = await import("./runner-C0d3lJo1.mjs");
850
850
  const sqlite = await openSqliteDatabase(getMiniflareDatabasePath(getLocalD1PersistRoot(root), "local"));
851
851
  try {
852
852
  const options = getDrizzleSchemaOptions(schema);
package/dist/index.mjs CHANGED
@@ -163,6 +163,7 @@ var DevCssProvider = class {
163
163
  const seenCssUrls = /* @__PURE__ */ new Set();
164
164
  const cssUrls = [];
165
165
  const cssViteDevIds = /* @__PURE__ */ new Map();
166
+ const transformedCss = /* @__PURE__ */ new Map();
166
167
  const addByUrl = async (rawUrl) => {
167
168
  const url = normalizeDevCssUrl(rawUrl, this.root);
168
169
  if (isOptimizedDepUrl(url)) return;
@@ -185,8 +186,13 @@ var DevCssProvider = class {
185
186
  seenCssUrls.add(node.url);
186
187
  cssUrls.push(node.url);
187
188
  }
188
- const viteDevId = transformedCode ? extractViteDevId(transformedCode) : void 0;
189
- cssViteDevIds.set(node.url, viteDevId ?? node.id ?? node.url);
189
+ if (transformedCode) {
190
+ const viteDevId = extractViteDevId(transformedCode);
191
+ cssViteDevIds.set(node.url, viteDevId ?? node.id ?? node.url);
192
+ try {
193
+ transformedCss.set(node.url, extractInlineCss(transformedCode));
194
+ } catch {}
195
+ } else cssViteDevIds.set(node.url, node.id ?? node.url);
190
196
  return;
191
197
  }
192
198
  if (isOptimizedDepUrl(node.url)) return;
@@ -200,14 +206,33 @@ var DevCssProvider = class {
200
206
  for (const roots of normalizedPhases) for (const root of roots) await addByUrl(root);
201
207
  const assets = [];
202
208
  for (const url of cssUrls) {
209
+ const existingCss = transformedCss.get(url);
210
+ if (existingCss !== void 0) {
211
+ assets.push({
212
+ url,
213
+ id: cssViteDevIds.get(url) ?? url,
214
+ css: existingCss
215
+ });
216
+ continue;
217
+ }
203
218
  const inlineUrl = appendInlineQuery(url);
204
- const result = await environment.transformRequest(inlineUrl);
219
+ let result;
220
+ try {
221
+ result = await environment.transformRequest(inlineUrl);
222
+ } catch (error) {
223
+ this.server.config.logger.warnOnce(`[void] Skipping dev CSS asset for ${url}: ${error instanceof Error ? error.message : String(error)}`);
224
+ continue;
225
+ }
205
226
  if (!result) continue;
206
- assets.push({
207
- url,
208
- id: cssViteDevIds.get(url) ?? url,
209
- css: extractInlineCss(result.code)
210
- });
227
+ try {
228
+ assets.push({
229
+ url,
230
+ id: cssViteDevIds.get(url) ?? url,
231
+ css: extractInlineCss(result.code)
232
+ });
233
+ } catch (error) {
234
+ this.server.config.logger.warnOnce(`[void] Skipping dev CSS asset for ${url}: ${error instanceof Error ? error.message : String(error)}`);
235
+ }
211
236
  }
212
237
  this.cache.set(cacheKey, assets);
213
238
  if (this.cache.size > 100) {
@@ -564,10 +589,16 @@ export function createDb(d1) {
564
589
  `;
565
590
  }
566
591
  },
567
- configureServer(server) {
592
+ async configureServer(server) {
568
593
  if (!schema) return;
569
594
  const migrationsDir = join(root, "db", "migrations");
570
- if (!(existsSync(migrationsDir) && readdirSync(migrationsDir).some((f) => f.endsWith(".sql")))) voidWarn("Schema found but no migrations in db/migrations/.\n Run `void db push` to apply to local DB, or\n `void db generate` to create migration files.");
595
+ if (!(existsSync(migrationsDir) && readdirSync(migrationsDir).some((f) => f.endsWith(".sql")))) {
596
+ if (dialect === "sqlite") {
597
+ const { getApplicationTables, getMiniflareDatabasePath } = await import("./runner-C0d3lJo1.mjs");
598
+ if ((await getApplicationTables(getMiniflareDatabasePath(options.localD1PersistRoot ?? join(root, ".void"), options.localD1DatabaseId ?? "local")).catch(() => [])).length > 0) return;
599
+ }
600
+ voidWarn("Schema found but no migrations in db/migrations/.\n `void db push` syncs the schema to your local DB without creating migration files.\n Run `void db generate` to create migration files for dev startup and deploy.");
601
+ }
571
602
  const watchPath = schema.path;
572
603
  const regenerate = (path) => {
573
604
  if (path === watchPath || schema.type === "directory" && path.startsWith(watchPath)) generateDbDts(outDir, schema, dialect);
@@ -1551,7 +1582,7 @@ function migrationPlugin(root, dialect, databaseId = "local", persistRoot = join
1551
1582
  const applied = await runPgMigrations(migrationsDir, url);
1552
1583
  if (applied.length > 0) voidLog(`Applied ${applied.length} migration(s): ${applied.join(", ")}`);
1553
1584
  } else if (hasSqlMigrations) {
1554
- const { runMigrations, getMiniflareDatabasePath, getAppliedMigrations } = await import("./runner-BaWsik5f.mjs");
1585
+ const { runMigrations, getMiniflareDatabasePath, getAppliedMigrations } = await import("./runner-C0d3lJo1.mjs");
1555
1586
  const { collectMigrations } = await import("./collect-HqAuilH6.mjs").then((n) => n.n);
1556
1587
  const { validateMigrations } = await import("./validate-DW3ViKTA.mjs").then((n) => n.i);
1557
1588
  const dbPath = getMiniflareDatabasePath(persistRoot, databaseId);
@@ -1568,7 +1599,7 @@ function migrationPlugin(root, dialect, databaseId = "local", persistRoot = join
1568
1599
  if (applied.length > 0) voidLog(`Applied ${applied.length} migration(s): ${applied.join(", ")}`);
1569
1600
  }
1570
1601
  if (auth?.enabled) {
1571
- const { runLocalVoidAuthMigrations } = await import("./node-DDxMsKPm.mjs");
1602
+ const { runLocalVoidAuthMigrations } = await import("./node-gxRQXIRT.mjs");
1572
1603
  await runLocalVoidAuthMigrations(root, dialect, persistRoot, databaseId, auth.configPath);
1573
1604
  voidLog("Applied Better Auth migrations");
1574
1605
  }
@@ -4785,7 +4816,10 @@ function voidPlugin(options) {
4785
4816
  envSchemaPlugin(root),
4786
4817
  envClientGuardPlugin(root),
4787
4818
  envClientFoldPlugin(),
4788
- drizzlePlugin(root, false, dialect, { forceVirtualDb: authEnabled }),
4819
+ drizzlePlugin(root, false, dialect, {
4820
+ forceVirtualDb: authEnabled,
4821
+ localD1PersistRoot: frameworkPersistRoot
4822
+ }),
4789
4823
  migrationPlugin(root, dialect, "local", frameworkPersistRoot, { enabled: false }),
4790
4824
  devTriggersHintPlugin(root, {
4791
4825
  framework: true,
@@ -5061,6 +5095,7 @@ function voidPlugin(options) {
5061
5095
  clientStubsPlugin,
5062
5096
  drizzlePlugin(root, false, getDatabaseDialect(config), {
5063
5097
  forceVirtualDb: authEnabled,
5098
+ localD1PersistRoot: options?.persistTo ?? outDir,
5064
5099
  redirectDbTypePaths
5065
5100
  }),
5066
5101
  migrationPlugin(root, getDatabaseDialect(config)),
@@ -5145,7 +5180,10 @@ function voidPlugin(options) {
5145
5180
  sandboxClassName: sandboxConfig?.className,
5146
5181
  live: liveConfig
5147
5182
  }),
5148
- drizzlePlugin(root, true, dialect, { forceVirtualDb: authEnabled }),
5183
+ drizzlePlugin(root, true, dialect, {
5184
+ forceVirtualDb: authEnabled,
5185
+ localD1PersistRoot: options?.persistTo ?? outDir
5186
+ }),
5149
5187
  migrationPlugin(root, dialect, "local", join(root, ".void"), {
5150
5188
  enabled: authEnabled,
5151
5189
  configPath: authConfigPath
@@ -3,7 +3,7 @@ import { n as loadVoidAuthConfig, t as findVoidAuthConfig } from "./config-CvHtT
3
3
  import { f as readConfig } from "./config-CeRQg3Lz.mjs";
4
4
  import { r as resolveVoidAuthMigrationSchema } from "./drizzle-Cx7cVwrE.mjs";
5
5
  import { n as applySqliteAuthMigrations, t as applyPgAuthMigrations } from "./auth-migrations-BwLPwRgH.mjs";
6
- import { getMiniflareDatabasePath } from "./runner-BaWsik5f.mjs";
6
+ import { getMiniflareDatabasePath } from "./runner-C0d3lJo1.mjs";
7
7
  import { loadEnv } from "vite";
8
8
  //#region src/auth/node.ts
9
9
  async function runLocalVoidAuthMigrations(root, dialect, persistRoot = join(root, ".void"), databaseId = "local", configPath = findVoidAuthConfig(root)) {
@@ -3,6 +3,12 @@ import { t as collectMigrations } from "./collect-HqAuilH6.mjs";
3
3
  import { existsSync, mkdirSync } from "node:fs";
4
4
  import { createHash, createHmac } from "node:crypto";
5
5
  //#region src/migrations/runner.ts
6
+ const SQLITE_INTERNAL_TABLES = new Set([
7
+ "_cf_METADATA",
8
+ "_migrations",
9
+ "_void_migrations",
10
+ "__drizzle_migrations"
11
+ ]);
6
12
  function toBetterSqlite3Error(error) {
7
13
  const message = error instanceof Error ? error.message : String(error);
8
14
  if (!message.includes("Could not locate the bindings file")) return error instanceof Error ? error : new Error(message);
@@ -70,6 +76,39 @@ function upgradeTrackingTable(db) {
70
76
  db.exec(`DROP TABLE IF EXISTS _migrations`);
71
77
  }).immediate();
72
78
  }
79
+ function getApplicationTableNames(db) {
80
+ return db.prepare("SELECT name FROM sqlite_master WHERE type='table' ORDER BY name").all().map((row) => row.name).filter((name) => !name.startsWith("sqlite_") && !SQLITE_INTERNAL_TABLES.has(name));
81
+ }
82
+ async function getApplicationTables(dbPath) {
83
+ if (!existsSync(dbPath)) return [];
84
+ const db = await openSqliteDatabase(dbPath, { readonly: true });
85
+ try {
86
+ return getApplicationTableNames(db);
87
+ } finally {
88
+ db.close();
89
+ }
90
+ }
91
+ function assertLocalMigrationState(migrations, appliedNames, applicationTables) {
92
+ const migrationNames = new Set(migrations.map((migration) => migration.name));
93
+ const missingFiles = [...appliedNames].filter((name) => !migrationNames.has(name)).sort();
94
+ if (missingFiles.length > 0) throw new Error([
95
+ "Local database migration history does not match db/migrations/.",
96
+ "",
97
+ "These migrations are recorded as applied locally but no longer exist on disk:",
98
+ ...missingFiles.map((name) => ` - ${name}`),
99
+ "",
100
+ "If the migration files were renamed, run `void db rename-migrations`.",
101
+ "If the migration history was intentionally rewritten, run `void db reset` to recreate the local database from the current files."
102
+ ].join("\n"));
103
+ if (appliedNames.size === 0 && migrations.length > 0 && applicationTables.length > 0) throw new Error([
104
+ "Local database already has application tables but no Void migration history.",
105
+ "",
106
+ `Existing tables: ${applicationTables.join(", ")}`,
107
+ "",
108
+ "This usually means the schema was applied with `void db push` or the local database was created before migration tracking existed.",
109
+ "Run `void db reset` to recreate the local database from db/migrations/, or delete the local D1 state if you do not need its data."
110
+ ].join("\n"));
111
+ }
73
112
  /**
74
113
  * Apply unapplied SQL migrations from the migrations directory.
75
114
  * Tracks applied migrations in the `_void_migrations` table.
@@ -103,6 +142,7 @@ async function runMigrations(migrationsDir, dbPath) {
103
142
  )
104
143
  `);
105
144
  const appliedSet = new Set(db.prepare("SELECT name FROM _void_migrations").all().map((r) => r.name));
145
+ assertLocalMigrationState(allMigrations, appliedSet, getApplicationTableNames(db));
106
146
  const pending = allMigrations.filter((m) => !appliedSet.has(m.name));
107
147
  if (pending.length === 0) return [];
108
148
  const insertStmt = db.prepare("INSERT INTO _void_migrations (name) VALUES (?)");
@@ -120,4 +160,4 @@ async function runMigrations(migrationsDir, dbPath) {
120
160
  }
121
161
  }
122
162
  //#endregion
123
- export { getAppliedMigrations, getMiniflareDatabasePath, openSqliteDatabase, runMigrations };
163
+ export { getApplicationTables, getAppliedMigrations, getMiniflareDatabasePath, openSqliteDatabase, runMigrations };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "void",
3
- "version": "0.7.11",
3
+ "version": "0.7.12",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/voidzero-dev/void.git",
@@ -332,7 +332,7 @@
332
332
  "valibot": ">=1.0.0-beta.7",
333
333
  "vite": "^8.0.0",
334
334
  "zod": "^3.25.0 || ^4.0.0",
335
- "@void/md": "0.7.11"
335
+ "@void/md": "0.7.12"
336
336
  },
337
337
  "peerDependenciesMeta": {
338
338
  "@void/md": {