@teardown/navigation-metro 2.0.75 → 2.0.76

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/index.d.ts CHANGED
@@ -32,6 +32,12 @@ export interface TeardownNavigationOptions {
32
32
  * @default true
33
33
  */
34
34
  autoTemplate?: boolean;
35
+ /**
36
+ * Use polling mode instead of native file events
37
+ * Enable this for VMs, network drives, or systems where fsevents doesn't work reliably
38
+ * @default false
39
+ */
40
+ usePolling?: boolean;
35
41
  }
36
42
  /**
37
43
  * Metro configuration type (simplified)
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA0EH;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACzC;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IAEpB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;CACvB;AAED;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,QAAQ,CAAC,EAAE;QACV,cAAc,CAAC,EAAE,CAChB,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,GAAG,IAAI,KACnB;YAAE,QAAQ,EAAE,MAAM,CAAC;YAAC,IAAI,EAAE,MAAM,CAAA;SAAE,GAAG,IAAI,CAAC;QAC/C,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;KACvB,CAAC;IACF,WAAW,CAAC,EAAE;QACb,4BAA4B,CAAC,EAAE,OAAO,CAAC;QACvC,CA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eAAe,EACf,WAAW,EACX,iBAAiB,GACjB,MAAM,6BAA6B,CAAC;AACrC,YAAY,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,YAAY,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC"}
package/dist/index.js CHANGED
@@ -96,6 +96,7 @@ function withTeardownNavigation(config, options = {}) {
96
96
  const generatedDir = options.generatedDir ?? teardownConfig?.generatedDir ?? "./.teardown";
97
97
  const autoTemplate = options.autoTemplate ?? teardownConfig?.autoTemplate ?? true;
98
98
  const verbose = options.verbose ?? false;
99
+ const usePolling = options.usePolling ?? false;
99
100
  const absoluteRoutesDir = (0, node_path_1.resolve)(projectRoot, routesDir);
100
101
  const absoluteGeneratedDir = (0, node_path_1.resolve)(projectRoot, generatedDir);
101
102
  // If no prefixes provided, try to read slug from teardown config
@@ -132,6 +133,7 @@ function withTeardownNavigation(config, options = {}) {
132
133
  prefixes,
133
134
  verbose,
134
135
  autoTemplate,
136
+ usePolling,
135
137
  onRegenerate: () => {
136
138
  if (verbose) {
137
139
  console.log("[teardown/navigation] Routes regenerated");
@@ -13,8 +13,14 @@ export interface WatcherOptions {
13
13
  * @default true
14
14
  */
15
15
  autoTemplate?: boolean;
16
+ /**
17
+ * Use polling mode instead of native events (for VMs, network drives)
18
+ * @default false
19
+ */
20
+ usePolling?: boolean;
16
21
  onRegenerate?: () => void;
17
22
  onError?: (errors: ValidationError[]) => void;
23
+ onReady?: () => void;
18
24
  }
19
25
  /**
20
26
  * Starts watching the routes directory for changes
@@ -1 +1 @@
1
- {"version":3,"file":"file-watcher.d.ts","sourceRoot":"","sources":["../../src/watcher/file-watcher.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,OAAO,EAAE,KAAK,eAAe,EAAkB,MAAM,8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I,CAKvC;AAED;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,OAAO,CAE1C"}
@@ -19,13 +19,20 @@ let watcherInstance = null;
19
19
  * Returns a cleanup function to stop watching
20
20
  */
21
21
  function startRouteWatcher(options) {
22
- const { routesDir, generatedDir, prefixes, verbose, autoTemplate = true, onRegenerate, onError } = options;
22
+ const { routesDir, generatedDir, prefixes, verbose, autoTemplate = true, usePolling = false, onRegenerate, onError, onReady, } = options;
23
23
  // Close existing watcher if any
24
24
  if (watcherInstance) {
25
25
  watcherInstance.close();
26
26
  }
27
27
  const watcher = (0, chokidar_1.watch)((0, node_path_1.join)(routesDir, "**/*.{ts,tsx}"), {
28
28
  ignoreInitial: true,
29
+ persistent: true,
30
+ usePolling,
31
+ interval: usePolling ? 100 : undefined,
32
+ awaitWriteFinish: {
33
+ stabilityThreshold: 100,
34
+ pollInterval: 50,
35
+ },
29
36
  ignored: [
30
37
  /(^|[/\\])\../, // Dotfiles
31
38
  /node_modules/,
@@ -33,6 +40,13 @@ function startRouteWatcher(options) {
33
40
  /\.spec\./,
34
41
  ],
35
42
  });
43
+ // Log when watcher is ready
44
+ watcher.on("ready", () => {
45
+ if (verbose) {
46
+ console.log("[teardown/navigation] Watcher ready and watching for changes");
47
+ }
48
+ onReady?.();
49
+ });
36
50
  let debounceTimer = null;
37
51
  const regenerate = () => {
38
52
  if (debounceTimer) {
@@ -73,27 +87,23 @@ function startRouteWatcher(options) {
73
87
  if (verbose) {
74
88
  console.log(`[teardown/navigation] File added: ${relativePath}`);
75
89
  }
76
- // Add delay to let filesystem settle before checking if file is empty
77
- // This prevents race conditions where the file hasn't finished being created
78
- // biome-ignore lint/complexity/noExcessiveCognitiveComplexity: template generation with error handling
79
- setTimeout(() => {
80
- // Auto-populate empty files with template content
81
- if (autoTemplate && (0, route_templates_1.isFileEmpty)(filePath)) {
82
- try {
83
- const templateContent = (0, route_templates_1.generateRouteTemplate)(relativePath);
84
- (0, node_fs_1.writeFileSync)(filePath, templateContent);
85
- if (verbose) {
86
- console.log(`[teardown/navigation] Generated template for: ${relativePath}`);
87
- }
90
+ // awaitWriteFinish handles waiting for file stability, so no setTimeout needed
91
+ // Auto-populate empty files with template content
92
+ if (autoTemplate && (0, route_templates_1.isFileEmpty)(filePath)) {
93
+ try {
94
+ const templateContent = (0, route_templates_1.generateRouteTemplate)(relativePath);
95
+ (0, node_fs_1.writeFileSync)(filePath, templateContent);
96
+ if (verbose) {
97
+ console.log(`[teardown/navigation] Generated template for: ${relativePath}`);
88
98
  }
89
- catch (error) {
90
- if (verbose) {
91
- console.error(`[teardown/navigation] Failed to generate template for ${relativePath}:`, error);
92
- }
99
+ }
100
+ catch (error) {
101
+ if (verbose) {
102
+ console.error(`[teardown/navigation] Failed to generate template for ${relativePath}:`, error);
93
103
  }
94
104
  }
95
- regenerate();
96
- }, 50);
105
+ }
106
+ regenerate();
97
107
  });
98
108
  watcher.on("unlink", (filePath) => {
99
109
  if (verbose) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teardown/navigation-metro",
3
- "version": "2.0.75",
3
+ "version": "2.0.76",
4
4
  "description": "Metro plugin for @teardown/navigation type generation",
5
5
  "private": false,
6
6
  "publishConfig": {
@@ -42,7 +42,7 @@
42
42
  },
43
43
  "devDependencies": {
44
44
  "@biomejs/biome": "2.3.11",
45
- "@teardown/tsconfig": "2.0.75",
45
+ "@teardown/tsconfig": "2.0.76",
46
46
  "@types/node": "24.10.1",
47
47
  "typescript": "5.9.3"
48
48
  }