nuxt-ai-ready 1.7.13 → 1.7.14

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.
@@ -137,38 +137,52 @@ async function initCrawler(state) {
137
137
  }
138
138
  state.initialized = true;
139
139
  }
140
- async function createPrerenderDatabase(dbPath) {
141
- const nodeVersion = Number.parseInt(process.versions.node?.split(".")[0] || "0");
142
- if (nodeVersion >= 22) {
143
- const { DatabaseSync } = await import('node:sqlite');
144
- const sqlite2 = new DatabaseSync(dbPath);
145
- return {
146
- all: async (sql, params = []) => sqlite2.prepare(sql).all(...params),
147
- first: async (sql, params = []) => sqlite2.prepare(sql).get(...params),
148
- exec: async (sql, params = []) => {
149
- if (params.length)
150
- sqlite2.prepare(sql).run(...params);
151
- else
152
- sqlite2.exec(sql);
153
- },
154
- close: async () => {
155
- sqlite2.close();
156
- }
157
- };
140
+ const PRERENDER_PRAGMAS = [
141
+ "PRAGMA synchronous = OFF",
142
+ "PRAGMA temp_store = MEMORY"
143
+ ];
144
+ function createSqliteAdapter(sqlite) {
145
+ const statements = /* @__PURE__ */ new Map();
146
+ function prepare(sql) {
147
+ let statement = statements.get(sql);
148
+ if (!statement) {
149
+ statement = sqlite.prepare(sql);
150
+ statements.set(sql, statement);
151
+ }
152
+ return statement;
158
153
  }
159
- const { default: Database } = await import('better-sqlite3');
160
- const sqlite = new Database(dbPath);
161
154
  return {
162
- all: async (sql, params = []) => sqlite.prepare(sql).all(...params),
163
- first: async (sql, params = []) => sqlite.prepare(sql).get(...params),
155
+ all: async (sql, params = []) => prepare(sql).all(...params),
156
+ first: async (sql, params = []) => prepare(sql).get(...params),
164
157
  exec: async (sql, params = []) => {
165
- sqlite.prepare(sql).run(...params);
158
+ if (params.length) {
159
+ prepare(sql).run(...params);
160
+ return;
161
+ }
162
+ statements.clear();
163
+ sqlite.exec(sql);
166
164
  },
167
165
  close: async () => {
166
+ statements.clear();
168
167
  sqlite.close();
169
168
  }
170
169
  };
171
170
  }
171
+ async function createPrerenderDatabase(dbPath) {
172
+ const nodeVersion = Number.parseInt(process.versions.node?.split(".")[0] || "0");
173
+ if (nodeVersion >= 22) {
174
+ const { DatabaseSync } = await import('node:sqlite');
175
+ const sqlite2 = new DatabaseSync(dbPath);
176
+ for (const pragma of PRERENDER_PRAGMAS)
177
+ sqlite2.exec(pragma);
178
+ return createSqliteAdapter(sqlite2);
179
+ }
180
+ const { default: Database } = await import('better-sqlite3');
181
+ const sqlite = new Database(dbPath);
182
+ for (const pragma of PRERENDER_PRAGMAS)
183
+ sqlite.exec(pragma);
184
+ return createSqliteAdapter(sqlite);
185
+ }
172
186
  function flattenHeadings(headings) {
173
187
  return (headings || []).map((h) => Object.entries(h).map(([tag, text]) => `${tag}:${text}`).join("")).join("|");
174
188
  }
package/dist/module.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "nuxt": ">=4.0.0"
5
5
  },
6
6
  "configKey": "aiReady",
7
- "version": "1.7.13",
7
+ "version": "1.7.14",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "1.0.3",
10
10
  "unbuild": "3.6.1"
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "nuxt-ai-ready",
3
3
  "type": "module",
4
- "version": "1.7.13",
4
+ "version": "1.7.14",
5
5
  "description": "Best practice AI & LLM discoverability for Nuxt sites.",
6
6
  "author": {
7
7
  "name": "Harlan Wilton",