@stagepass/cli 2.4.1 → 2.6.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.
@@ -37,6 +37,15 @@ export const BUILD_SCRIPT_MISSING_NOTE =
37
37
  'No scripts/build.mjs. stagepass build, stagepass watch and stagepass dev use the scaffold from stagepass new. See ' +
38
38
  BUILD_SCRIPT_DOC_URL;
39
39
 
40
+ /**
41
+ * Stock scaffold, no TTY, and no `--yes`. The file stays.
42
+ * @param {string} id known template id
43
+ * @returns {string}
44
+ */
45
+ export function buildScriptUnattendedHint(id) {
46
+ return `scripts/build.mjs matches the unmodified ${id} scaffold. No TTY and no --yes, so it was left unchanged. Run stagepass upgrade --yes to replace it.`;
47
+ }
48
+
40
49
  /**
41
50
  * Distinct blobs of the scaffold before the template bundled with this CLI.
42
51
  * @type {{ id: string, commit: string, sha256: string }[]}
@@ -209,12 +218,14 @@ export async function inspectProjectBuildScript(cwd, currentSource, fse = fs) {
209
218
 
210
219
  /**
211
220
  * Decide whether upgrade should replace scripts/build.mjs.
212
- * Does not write. `interactive` false (no TTY, or `--yes`) accepts a stock script.
221
+ * Does not write. `--yes` (`assumeYes`) replaces a stock script.
222
+ * A TTY (`interactive`) asks. Otherwise the file stays and the note names `--yes`.
213
223
  *
214
224
  * @param {object} options
215
225
  * @param {string} options.cwd
216
226
  * @param {string} options.currentSource
217
227
  * @param {boolean} options.interactive
228
+ * @param {boolean} [options.assumeYes]
218
229
  * @param {(question: string, defYes: boolean) => Promise<boolean>} [options.confirm]
219
230
  * @param {{ lstat: Function, readFile: Function }} [options.fse]
220
231
  */
@@ -236,14 +247,17 @@ export async function planBuildScriptUpgrade(options) {
236
247
  }
237
248
  if (found.status === 'custom') return { action: 'custom', note: BUILD_SCRIPT_CUSTOM_HINT };
238
249
  const content = renderCurrentBuildScript(options.currentSource, found.raw || '');
239
- if (!options.interactive) return { action: 'update', from: found.id, content };
240
- if (typeof options.confirm !== 'function') {
241
- throw new Error('confirm is required when upgrade asks about scripts/build.mjs');
250
+ if (options.assumeYes === true) return { action: 'update', from: found.id, content };
251
+ if (options.interactive) {
252
+ if (typeof options.confirm !== 'function') {
253
+ throw new Error('confirm is required when upgrade asks about scripts/build.mjs');
254
+ }
255
+ const yes = await options.confirm(
256
+ `Replace scripts/build.mjs with the current scaffold? It matches the unmodified ${found.id} template.`,
257
+ true
258
+ );
259
+ if (!yes) return { action: 'declined', note: 'scripts/build.mjs left unchanged.' };
260
+ return { action: 'update', from: found.id, content };
242
261
  }
243
- const yes = await options.confirm(
244
- `Replace scripts/build.mjs with the current scaffold? It matches the unmodified ${found.id} template.`,
245
- true
246
- );
247
- if (!yes) return { action: 'declined', note: 'scripts/build.mjs left unchanged.' };
248
- return { action: 'update', from: found.id, content };
262
+ return { action: 'hint', from: found.id, note: buildScriptUnattendedHint(found.id || 'scaffold') };
249
263
  }
@@ -0,0 +1,72 @@
1
+ /**
2
+ * Official loader/modules CDN.
3
+ *
4
+ * Default host is https://cdn.stagepass.one: exact pins, full file path,
5
+ * no `/dist/` segment. jsDelivr remains an alternative (npm package paths,
6
+ * often a major pin, `/dist/` segment). Do not recommend unpkg.
7
+ */
8
+ export const STAGEPASS_CDN_ORIGIN = 'https://cdn.stagepass.one';
9
+ export const STAGEPASS_JSDELIVR_CDN = 'https://cdn.jsdelivr.net/npm';
10
+ /** Default package CDN origin (Stagepass CDN). Prefer stagepassPackageUrl(). */
11
+ export const STAGEPASS_PACKAGE_CDN = STAGEPASS_CDN_ORIGIN;
12
+
13
+ /**
14
+ * Published npm versions for snippet exact pins (loader `latest`, modules `latest`).
15
+ * Literals only: not read from the CLI package version, and not copied
16
+ * automatically when the monorepo is ahead of npm.
17
+ */
18
+ export const SNIPPET_LOADER_VERSION = '2.5.0';
19
+ export const SNIPPET_MODULES_VERSION = '2.2.2';
20
+ export const SNIPPET_MAJOR_PIN = '@2';
21
+
22
+ /**
23
+ * @param {unknown} raw
24
+ * @returns {'stagepass' | 'jsdelivr' | null}
25
+ */
26
+ export function normalizeCdnChoice(raw) {
27
+ const v = String(raw == null ? '' : raw).trim().toLowerCase();
28
+ if (v === 'stagepass') return 'stagepass';
29
+ if (v === 'jsdelivr') return 'jsdelivr';
30
+ return null;
31
+ }
32
+
33
+ /**
34
+ * Pins used in generated Webflow snippets for a CDN host.
35
+ * Stagepass CDN uses exact pins from the resolved loader version (the same
36
+ * value as `data-stagepass-version`). jsDelivr keeps the major pin `@2`.
37
+ * @param {unknown} [cdn]
38
+ * @param {{ loaderVersion?: string, modulesVersion?: string }} [options]
39
+ * @returns {{ cdn: 'stagepass' | 'jsdelivr', loaderPin: string, modulesPin: string }}
40
+ */
41
+ export function defaultSnippetPins(cdn, options = {}) {
42
+ const host = normalizeCdnChoice(cdn) || 'stagepass';
43
+ if (host === 'jsdelivr') {
44
+ return {
45
+ cdn: host,
46
+ loaderPin: SNIPPET_MAJOR_PIN,
47
+ modulesPin: SNIPPET_MAJOR_PIN,
48
+ };
49
+ }
50
+ const loaderVersion = options.loaderVersion || SNIPPET_LOADER_VERSION;
51
+ const modulesVersion = options.modulesVersion || SNIPPET_MODULES_VERSION;
52
+ return {
53
+ cdn: host,
54
+ loaderPin: `@${loaderVersion}`,
55
+ modulesPin: `@${modulesVersion}`,
56
+ };
57
+ }
58
+
59
+ /**
60
+ * @param {string} name Package short name (`loader` or `modules`)
61
+ * @param {string} pin CDN pin including `@` (for example `@2` or `@2.5.0`)
62
+ * @param {string} file File under the host path (`loader.min.js`)
63
+ * @param {{ cdn?: string }} [options]
64
+ * @returns {string}
65
+ */
66
+ export function stagepassPackageUrl(name, pin, file, options = {}) {
67
+ const cdn = normalizeCdnChoice(options.cdn) || 'stagepass';
68
+ if (cdn === 'jsdelivr') {
69
+ return `${STAGEPASS_JSDELIVR_CDN}/@stagepass/${name}${pin}/dist/${file}`;
70
+ }
71
+ return `${STAGEPASS_CDN_ORIGIN}/${name}${pin}/${file}`;
72
+ }
@@ -1,16 +1,20 @@
1
1
  import fs from 'fs-extra';
2
2
  import path from 'node:path';
3
+ import { defaultSnippetPins, stagepassPackageUrl } from './cdn-base.js';
4
+
5
+ const pins = defaultSnippetPins('stagepass');
3
6
 
4
7
  /**
5
8
  * Canonical CDN embed snippets recommended by Stagepass docs.
6
9
  * Doctor checks these so generated / documented snippets never drift to @latest.
10
+ * Default host is the Stagepass CDN with exact pins.
7
11
  */
8
12
  export const RECOMMENDED_CDN_SNIPPETS = Object.freeze([
9
- 'https://cdn.jsdelivr.net/npm/@stagepass/loader@2/dist/loader.min.js',
10
- 'https://cdn.jsdelivr.net/npm/@stagepass/modules@2/dist/inject.min.js',
11
- 'https://cdn.jsdelivr.net/npm/@stagepass/modules@2/dist/cookies.min.js',
12
- 'https://cdn.jsdelivr.net/npm/@stagepass/modules@2/dist/maintenance.min.js',
13
- 'https://cdn.jsdelivr.net/npm/@stagepass/modules@2/dist/all.min.js',
13
+ stagepassPackageUrl('loader', pins.loaderPin, 'loader.min.js'),
14
+ stagepassPackageUrl('modules', pins.modulesPin, 'inject.min.js'),
15
+ stagepassPackageUrl('modules', pins.modulesPin, 'cookies.min.js'),
16
+ stagepassPackageUrl('modules', pins.modulesPin, 'maintenance.min.js'),
17
+ stagepassPackageUrl('modules', pins.modulesPin, 'all.min.js'),
14
18
  ]);
15
19
 
16
20
  /**
@@ -19,10 +23,10 @@ export const RECOMMENDED_CDN_SNIPPETS = Object.freeze([
19
23
  * - bare major `@1` (not `@1.2.0` exact pins)
20
24
  * - package URL with no `@version` at all
21
25
  *
22
- * Matches jsDelivr and unpkg-style paths.
26
+ * Matches the Stagepass CDN, jsDelivr, and existing unpkg paths.
23
27
  */
24
28
  export const UNPINNED_CDN_RE =
25
- /(?:cdn\.jsdelivr\.net\/npm|unpkg\.com)\/@stagepass\/(?:loader|modules)(?:@latest|@1(?![0-9.])|(?!@))(?=[/"'?\s]|$)/gi;
29
+ /(?:cdn\.stagepass\.one\/(?:loader|modules)|(?:cdn\.jsdelivr\.net\/npm|unpkg\.com)\/@stagepass\/(?:loader|modules))(?:@latest|@1(?![0-9.])|(?!@))(?=[/"'?\s]|$)/gi;
26
30
 
27
31
  /**
28
32
  * Test whether a single URL/snippet string is an unpinned Stagepass CDN reference.
@@ -52,7 +56,7 @@ export function findUnpinnedCdnSnippets(snippets = RECOMMENDED_CDN_SNIPPETS) {
52
56
  export function findUnpinnedCdnMatchesInText(content) {
53
57
  const text = String(content || '');
54
58
  const candidateRe =
55
- /(?:https?:\/\/)?(?:cdn\.jsdelivr\.net\/npm|unpkg\.com)\/@stagepass\/(?:loader|modules)[^"'<\s]*/gi;
59
+ /(?:https?:\/\/)?(?:cdn\.stagepass\.one\/(?:loader|modules)|(?:cdn\.jsdelivr\.net\/npm|unpkg\.com)\/@stagepass\/(?:loader|modules))[^"'<\s]*/gi;
56
60
  const matches = text.match(candidateRe);
57
61
  if (!matches) return [];
58
62
  const seen = new Set();
@@ -9,7 +9,9 @@ import path from 'node:path';
9
9
  import fs from 'fs-extra';
10
10
  import { detectSite, describeDetection } from './site-detect.js';
11
11
  import { formatModules, sameModules } from './project-modules.js';
12
+ import { assessCursorRule, CURSOR_RULE_PATH } from './ai-guide.js';
12
13
  import {
14
+ cursorDirPresent,
13
15
  declaredModules,
14
16
  phpFromStagepassConfig,
15
17
  readStagepassJson,
@@ -50,6 +52,21 @@ export async function runProjectSiteChecks(opts = {}) {
50
52
  checks.push({ id: 'project.modules', status: 'ok', message: `Declared modules: ${formatModules(declared)}` });
51
53
  }
52
54
 
55
+ if (await cursorDirPresent(cwd)) {
56
+ const rulePath = path.join(cwd, CURSOR_RULE_PATH);
57
+ /** @type {string | null} */
58
+ let rule = null;
59
+ if (await fs.pathExists(rulePath)) {
60
+ try {
61
+ rule = await fs.readFile(rulePath, 'utf8');
62
+ } catch {
63
+ rule = null;
64
+ }
65
+ }
66
+ const cursor = assessCursorRule({ cursorDirExists: true, rule });
67
+ if (cursor) checks.push({ id: 'project.cursor', ...cursor });
68
+ }
69
+
53
70
  const php = phpFromStagepassConfig(sp.data);
54
71
  if (php === false) {
55
72
  checks.push({
package/src/lib/doctor.js CHANGED
@@ -567,7 +567,7 @@ export async function runDoctor(opts = {}) {
567
567
  check(
568
568
  'cdn',
569
569
  'warn',
570
- 'Recommended CDN snippets include unpinned refs (@latest, @1, or bare package; prefer @2)',
570
+ 'Recommended CDN snippets include unpinned refs (@latest, @1, or bare package; use an exact version, or @2 on jsDelivr)',
571
571
  unpinned.offenders.join(', ')
572
572
  )
573
573
  );
@@ -576,7 +576,7 @@ export async function runDoctor(opts = {}) {
576
576
  check(
577
577
  'cdn',
578
578
  'ok',
579
- 'Recommended CDN snippets use a pinned major (@2), not @latest/@1/bare'
579
+ 'Recommended CDN snippets are pinned (exact version or major @2), not @latest/@1/bare'
580
580
  )
581
581
  );
582
582
  }
@@ -599,7 +599,7 @@ export async function runDoctor(opts = {}) {
599
599
  check(
600
600
  'cdn.project',
601
601
  'warn',
602
- 'Project files contain unpinned Stagepass CDN URLs (@latest, @1, or bare; prefer @2)',
602
+ 'Project files contain unpinned Stagepass CDN URLs (@latest, @1, or bare; use an exact version, or @2 on jsDelivr)',
603
603
  detail
604
604
  )
605
605
  );
@@ -6,7 +6,8 @@
6
6
  * Change classification is content-based: identical rewrites (same bytes) are
7
7
  * ignored. Only real CSS changes batch as `{type:'css'}`; any other real change
8
8
  * is `{type:'reload'}`. `manifest.json`, dotfiles, `~` backups and `.map` files
9
- * are ignored.
9
+ * are ignored. When `php` is set, `api/` and `.php/` share that debounce and
10
+ * stream. Secrets, rate-limit files, logs, pid files, and editor temps do not.
10
11
  */
11
12
 
12
13
  import http from 'node:http';
@@ -75,6 +76,32 @@ export function isIgnoredWatchBase(base) {
75
76
  );
76
77
  }
77
78
 
79
+ /** Extra project-root directories watched while `stagepass.json` has `"php": true`. */
80
+ export const PHP_WATCH_DIRS = Object.freeze(['api', '.php']);
81
+
82
+ const PHP_SECRET_EXT = /\.(pem|key|p12|pfx|crt|cer|sqlite|db)$/i;
83
+
84
+ /**
85
+ * Project-relative path (slashes) under `api/` or `.php/` that must not reload.
86
+ * Matches the publish skip for secrets, plus editor temp files.
87
+ * @param {string} rel
88
+ * @returns {boolean}
89
+ */
90
+ export function isIgnoredPhpRel(rel) {
91
+ const norm = String(rel || '').split('\\').join('/');
92
+ if (!norm || norm === '..' || norm.startsWith('../') || norm.includes('/../')) return true;
93
+ const parts = norm.split('/').filter((part) => part && part !== '.');
94
+ const base = parts[parts.length - 1] || '';
95
+ if (!base) return true;
96
+ if (base === '.env' || (base.startsWith('.env') && base !== '.env.example')) return true;
97
+ if (base.endsWith('~') || base.endsWith('.swp') || base === '.DS_Store') return true;
98
+ if (base.endsWith('.log') || base.endsWith('.pid')) return true;
99
+ if (PHP_SECRET_EXT.test(base)) return true;
100
+ const phpAt = parts.indexOf('.php');
101
+ if (phpAt !== -1 && parts[phpAt + 1] === 'rate-limit') return true;
102
+ return false;
103
+ }
104
+
78
105
  /**
79
106
  * Turn an absolute file path under outAbs into a site-relative URL path
80
107
  * (project-root relative, with leading slash). Returns null when outside or ignored.
@@ -174,6 +201,7 @@ function walkFiles(dirAbs, visit) {
174
201
  * @typedef {object} LiveServerOptions
175
202
  * @property {string} projectRoot
176
203
  * @property {string} [outDir]
204
+ * @property {boolean} [php] Also watch `api/` and `.php/` (missing dirs are skipped).
177
205
  * @property {number} [debounceMs]
178
206
  * @property {number} [maxConnections]
179
207
  * @property {number} [heartbeatMs]
@@ -211,12 +239,46 @@ export function createLiveServer(options) {
211
239
  const pending = new Set();
212
240
  /** @type {ReturnType<typeof setTimeout>|null} */
213
241
  let debounceTimer = null;
214
- /** @type {import('node:fs').FSWatcher|null} */
215
- let watcher = null;
242
+ /** @type {import('node:fs').FSWatcher[]} */
243
+ const watchers = [];
216
244
  /** @type {ReturnType<typeof setInterval>|null} */
217
245
  let heartbeat = null;
218
246
  /** @type {Map<string, string>} abs path → fingerprint token */
219
247
  const fileHashes = new Map();
248
+ const phpEnabled = options.php === true;
249
+ /** @type {{ rel: string, abs: string }[]} */
250
+ const phpRoots = phpEnabled
251
+ ? PHP_WATCH_DIRS.map((rel) => ({ rel, abs: path.resolve(projectRoot, rel) }))
252
+ : [];
253
+ /** Relative dirs that received a watcher (missing dirs stay off this list). */
254
+ const phpWatched = [];
255
+ let stopped = false;
256
+
257
+ /**
258
+ * Accept a path under the output dir (dist rules) or, when PHP is on, under api/ or .php/.
259
+ * @param {string} fileAbs
260
+ * @returns {{ abs: string, url: string } | null}
261
+ */
262
+ function describeWatched(fileAbs) {
263
+ const underOut = resolveUnderOutDir(fileAbs, outAbs);
264
+ if (underOut) {
265
+ const url = toUrlPath(underOut, projectRoot, outAbs);
266
+ if (!url) return null;
267
+ return { abs: underOut, url };
268
+ }
269
+ if (!phpEnabled) return null;
270
+ const file = path.resolve(fileAbs);
271
+ for (const root of phpRoots) {
272
+ const relRoot = path.relative(root.abs, file);
273
+ if (relRoot.startsWith('..') || path.isAbsolute(relRoot) || relRoot.includes('\0')) continue;
274
+ const relProject = path.relative(projectRoot, file);
275
+ if (relProject.startsWith('..') || path.isAbsolute(relProject)) return null;
276
+ const rel = relProject.split(path.sep).join('/');
277
+ if (!rel || isIgnoredPhpRel(rel)) return null;
278
+ return { abs: file, url: '/' + rel };
279
+ }
280
+ return null;
281
+ }
220
282
 
221
283
  function rememberHash(fileAbs, token) {
222
284
  if (fileHashes.has(fileAbs)) {
@@ -232,14 +294,16 @@ export function createLiveServer(options) {
232
294
 
233
295
  function seedHashes() {
234
296
  fileHashes.clear();
235
- walkFiles(outAbs, (fileAbs) => {
236
- const safe = resolveUnderOutDir(fileAbs, outAbs);
237
- if (!safe) return;
238
- if (isIgnoredWatchBase(path.basename(safe))) return;
239
- const fp = contentFingerprint(safe);
240
- if (fp.kind === 'hash') rememberHash(safe, fp.hash);
241
- else if (fp.kind === 'large') rememberHash(safe, fp.token);
242
- });
297
+ const roots = [outAbs, ...phpRoots.map((root) => root.abs)];
298
+ for (const root of roots) {
299
+ walkFiles(root, (fileAbs) => {
300
+ const described = describeWatched(fileAbs);
301
+ if (!described) return;
302
+ const fp = contentFingerprint(described.abs);
303
+ if (fp.kind === 'hash') rememberHash(described.abs, fp.hash);
304
+ else if (fp.kind === 'large') rememberHash(described.abs, fp.token);
305
+ });
306
+ }
243
307
  }
244
308
 
245
309
  /**
@@ -250,8 +314,16 @@ export function createLiveServer(options) {
250
314
  * @returns {boolean} true when content actually changed (or deleted)
251
315
  */
252
316
  function hasContentChanged(fileAbs) {
253
- const safe = resolveUnderOutDir(fileAbs, outAbs);
254
- if (!safe) return false;
317
+ const described = describeWatched(fileAbs);
318
+ if (!described) return false;
319
+ const safe = described.abs;
320
+ try {
321
+ if (!fs.statSync(safe).isFile()) return false;
322
+ } catch (err) {
323
+ if (!(err && typeof err === 'object' && 'code' in err && err.code === 'ENOENT')) {
324
+ return true;
325
+ }
326
+ }
255
327
 
256
328
  const fp = contentFingerprint(safe);
257
329
  if (fp.kind === 'missing') {
@@ -288,13 +360,16 @@ export function createLiveServer(options) {
288
360
 
289
361
  function flushPending() {
290
362
  debounceTimer = null;
291
- if (pending.size === 0) return;
363
+ if (stopped || pending.size === 0) {
364
+ pending.clear();
365
+ return;
366
+ }
292
367
  /** @type {string[]} */
293
368
  const changed = [];
294
369
  for (const fileAbs of pending) {
295
370
  if (!hasContentChanged(fileAbs)) continue;
296
- const urlPath = toUrlPath(fileAbs, projectRoot, outAbs);
297
- if (urlPath) changed.push(urlPath);
371
+ const described = describeWatched(fileAbs);
372
+ if (described) changed.push(described.url);
298
373
  }
299
374
  pending.clear();
300
375
  if (changed.length === 0) return;
@@ -304,54 +379,84 @@ export function createLiveServer(options) {
304
379
  }
305
380
 
306
381
  function noteChange(fileAbs) {
307
- const safe = resolveUnderOutDir(fileAbs, outAbs);
308
- if (!safe) return;
309
- // Ignore junk / manifest early; defer content compare until debounce flush
310
- // so identical rewrites (and mid-write watch races) do not false-trigger.
311
- if (!toUrlPath(safe, projectRoot, outAbs)) return;
312
- pending.add(safe);
382
+ if (stopped) return;
383
+ const described = describeWatched(fileAbs);
384
+ if (!described) return;
385
+ // Defer content compare until debounce flush so identical rewrites
386
+ // (and mid-write watch races) do not false-trigger.
387
+ pending.add(described.abs);
313
388
  if (debounceTimer) clearTimeout(debounceTimer);
314
389
  debounceTimer = setTimeout(flushPending, debounceMs);
315
390
  }
316
391
 
317
- function startWatch() {
392
+ /**
393
+ * @param {string} abs
394
+ * @param {string} label
395
+ * @returns {boolean}
396
+ */
397
+ function attachWatch(abs, label) {
318
398
  try {
319
- fs.mkdirSync(outAbs, { recursive: true });
320
- } catch {
321
- /* ignore */
399
+ const st = fs.statSync(abs);
400
+ if (!st.isDirectory()) return false;
401
+ } catch (err) {
402
+ const code = err && typeof err === 'object' && 'code' in err ? err.code : '';
403
+ if (code !== 'ENOENT') {
404
+ log(
405
+ `Live reload: could not watch ${label} (${err instanceof Error ? err.message : String(err)})`
406
+ );
407
+ }
408
+ return false;
322
409
  }
323
- seedHashes();
324
410
  try {
325
- watcher = fsWatch(outAbs, { recursive: true }, (_event, filename) => {
326
- if (!filename) return;
411
+ const watcher = fsWatch(abs, { recursive: true }, (_event, filename) => {
412
+ if (!filename || stopped) return;
327
413
  const name = typeof filename === 'string' ? filename : String(filename);
328
- // Join only; resolveUnderOutDir rejects escapes (including .. segments).
329
- noteChange(path.join(outAbs, name));
414
+ // Join only; describeWatched rejects escapes (including .. segments).
415
+ noteChange(path.join(abs, name));
330
416
  });
331
417
  watcher.on('error', () => {
332
418
  /* keep server up; next change may recover */
333
419
  });
420
+ watchers.push(watcher);
421
+ return true;
334
422
  } catch (err) {
335
423
  log(
336
- `Live reload: could not watch ${outAbs} (${err instanceof Error ? err.message : String(err)})`
424
+ `Live reload: could not watch ${label} (${err instanceof Error ? err.message : String(err)})`
337
425
  );
426
+ return false;
427
+ }
428
+ }
429
+
430
+ function startWatch() {
431
+ stopped = false;
432
+ try {
433
+ fs.mkdirSync(outAbs, { recursive: true });
434
+ } catch {
435
+ /* ignore */
436
+ }
437
+ seedHashes();
438
+ attachWatch(outAbs, outAbs);
439
+ phpWatched.length = 0;
440
+ for (const root of phpRoots) {
441
+ if (attachWatch(root.abs, `${root.rel}/`)) phpWatched.push(root.rel);
338
442
  }
339
443
  }
340
444
 
341
445
  function stopWatch() {
446
+ stopped = true;
342
447
  if (debounceTimer) {
343
448
  clearTimeout(debounceTimer);
344
449
  debounceTimer = null;
345
450
  }
346
451
  pending.clear();
347
452
  fileHashes.clear();
348
- if (watcher) {
453
+ while (watchers.length) {
454
+ const watcher = watchers.pop();
349
455
  try {
350
456
  watcher.close();
351
457
  } catch {
352
458
  /* ignore */
353
459
  }
354
- watcher = null;
355
460
  }
356
461
  }
357
462
 
@@ -478,6 +583,8 @@ export function createLiveServer(options) {
478
583
  _fileHashes: fileHashes,
479
584
  _seedHashes: seedHashes,
480
585
  _hasContentChanged: hasContentChanged,
586
+ _watchers: watchers,
587
+ phpWatched,
481
588
  outAbs,
482
589
  outRel: outResolved.rel,
483
590
  };
@@ -5,5 +5,5 @@
5
5
  * Sourced from packages/loader and packages/modules package.json at generate time.
6
6
  * The published CLI ships this snapshot; it cannot read the monorepo at runtime.
7
7
  */
8
- export const LOADER_VERSION = "2.5.0";
8
+ export const LOADER_VERSION = "2.5.1";
9
9
  export const MODULES_VERSION = "2.2.2";