@teardown/navigation-metro 2.0.75 → 2.0.77
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 +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +46 -15
- package/dist/scanner/file-scanner.d.ts +4 -0
- package/dist/scanner/file-scanner.d.ts.map +1 -1
- package/dist/scanner/file-scanner.js +1 -0
- package/dist/scanner/index.d.ts +1 -1
- package/dist/scanner/index.d.ts.map +1 -1
- package/dist/scanner/index.js +2 -1
- package/dist/watcher/file-watcher.d.ts +6 -0
- package/dist/watcher/file-watcher.d.ts.map +1 -1
- package/dist/watcher/file-watcher.js +29 -19
- package/package.json +2 -2
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)
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAoGH;;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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B,EACtB,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
|
@@ -9,6 +9,8 @@ exports.withTeardownNavigation = withTeardownNavigation;
|
|
|
9
9
|
const node_fs_1 = require("node:fs");
|
|
10
10
|
const node_path_1 = require("node:path");
|
|
11
11
|
const route_generator_1 = require("./generator/route-generator");
|
|
12
|
+
const file_scanner_1 = require("./scanner/file-scanner");
|
|
13
|
+
const route_templates_1 = require("./templates/route-templates");
|
|
12
14
|
const file_watcher_1 = require("./watcher/file-watcher");
|
|
13
15
|
/**
|
|
14
16
|
* Config file names to search for (in order of priority)
|
|
@@ -59,6 +61,29 @@ function readSlugFromConfig(projectRoot) {
|
|
|
59
61
|
const config = readTeardownConfig(projectRoot);
|
|
60
62
|
return config?.slug ?? null;
|
|
61
63
|
}
|
|
64
|
+
/**
|
|
65
|
+
* Scans routes directory for empty files and populates them with templates
|
|
66
|
+
*/
|
|
67
|
+
function populateEmptyRouteFiles(routesDir, verbose) {
|
|
68
|
+
const files = (0, file_scanner_1.findRouteFiles)(routesDir);
|
|
69
|
+
for (const file of files) {
|
|
70
|
+
const absolutePath = (0, node_path_1.join)(routesDir, file);
|
|
71
|
+
if ((0, route_templates_1.isFileEmpty)(absolutePath)) {
|
|
72
|
+
try {
|
|
73
|
+
const templateContent = (0, route_templates_1.generateRouteTemplate)(file);
|
|
74
|
+
(0, node_fs_1.writeFileSync)(absolutePath, templateContent);
|
|
75
|
+
if (verbose) {
|
|
76
|
+
console.log(`[teardown/navigation] Generated template for: ${file}`);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
catch (error) {
|
|
80
|
+
if (verbose) {
|
|
81
|
+
console.error(`[teardown/navigation] Failed to generate template for ${file}:`, error);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
62
87
|
/**
|
|
63
88
|
* Wraps a Metro configuration with Teardown Navigation support
|
|
64
89
|
*
|
|
@@ -96,6 +121,7 @@ function withTeardownNavigation(config, options = {}) {
|
|
|
96
121
|
const generatedDir = options.generatedDir ?? teardownConfig?.generatedDir ?? "./.teardown";
|
|
97
122
|
const autoTemplate = options.autoTemplate ?? teardownConfig?.autoTemplate ?? true;
|
|
98
123
|
const verbose = options.verbose ?? false;
|
|
124
|
+
const usePolling = options.usePolling ?? false;
|
|
99
125
|
const absoluteRoutesDir = (0, node_path_1.resolve)(projectRoot, routesDir);
|
|
100
126
|
const absoluteGeneratedDir = (0, node_path_1.resolve)(projectRoot, generatedDir);
|
|
101
127
|
// If no prefixes provided, try to read slug from teardown config
|
|
@@ -109,6 +135,10 @@ function withTeardownNavigation(config, options = {}) {
|
|
|
109
135
|
}
|
|
110
136
|
}
|
|
111
137
|
}
|
|
138
|
+
// Auto-populate empty route files before generation
|
|
139
|
+
if (autoTemplate) {
|
|
140
|
+
populateEmptyRouteFiles(absoluteRoutesDir, verbose);
|
|
141
|
+
}
|
|
112
142
|
// Generate types on startup
|
|
113
143
|
try {
|
|
114
144
|
(0, route_generator_1.generateAllRouteFiles)({
|
|
@@ -132,6 +162,7 @@ function withTeardownNavigation(config, options = {}) {
|
|
|
132
162
|
prefixes,
|
|
133
163
|
verbose,
|
|
134
164
|
autoTemplate,
|
|
165
|
+
usePolling,
|
|
135
166
|
onRegenerate: () => {
|
|
136
167
|
if (verbose) {
|
|
137
168
|
console.log("[teardown/navigation] Routes regenerated");
|
|
@@ -161,21 +192,21 @@ function withTeardownNavigation(config, options = {}) {
|
|
|
161
192
|
// Re-export modules
|
|
162
193
|
var route_generator_2 = require("./generator/route-generator");
|
|
163
194
|
Object.defineProperty(exports, "generateAllRouteFiles", { enumerable: true, get: function () { return route_generator_2.generateAllRouteFiles; } });
|
|
164
|
-
var
|
|
165
|
-
Object.defineProperty(exports, "buildUrlPath", { enumerable: true, get: function () { return
|
|
166
|
-
Object.defineProperty(exports, "extractParams", { enumerable: true, get: function () { return
|
|
167
|
-
Object.defineProperty(exports, "filePathToScreenName", { enumerable: true, get: function () { return
|
|
168
|
-
Object.defineProperty(exports, "flattenRoutes", { enumerable: true, get: function () { return
|
|
169
|
-
Object.defineProperty(exports, "scanRoutesDirectory", { enumerable: true, get: function () { return
|
|
170
|
-
var
|
|
171
|
-
Object.defineProperty(exports, "extractParamsFromPath", { enumerable: true, get: function () { return
|
|
172
|
-
Object.defineProperty(exports, "fileNameToScreenName", { enumerable: true, get: function () { return
|
|
173
|
-
Object.defineProperty(exports, "generateLayoutTemplate", { enumerable: true, get: function () { return
|
|
174
|
-
Object.defineProperty(exports, "generateRouteTemplate", { enumerable: true, get: function () { return
|
|
175
|
-
Object.defineProperty(exports, "generateScreenTemplate", { enumerable: true, get: function () { return
|
|
176
|
-
Object.defineProperty(exports, "getTemplateType", { enumerable: true, get: function () { return
|
|
177
|
-
Object.defineProperty(exports, "isFileEmpty", { enumerable: true, get: function () { return
|
|
178
|
-
Object.defineProperty(exports, "screenNameToTitle", { enumerable: true, get: function () { return
|
|
195
|
+
var file_scanner_2 = require("./scanner/file-scanner");
|
|
196
|
+
Object.defineProperty(exports, "buildUrlPath", { enumerable: true, get: function () { return file_scanner_2.buildUrlPath; } });
|
|
197
|
+
Object.defineProperty(exports, "extractParams", { enumerable: true, get: function () { return file_scanner_2.extractParams; } });
|
|
198
|
+
Object.defineProperty(exports, "filePathToScreenName", { enumerable: true, get: function () { return file_scanner_2.filePathToScreenName; } });
|
|
199
|
+
Object.defineProperty(exports, "flattenRoutes", { enumerable: true, get: function () { return file_scanner_2.flattenRoutes; } });
|
|
200
|
+
Object.defineProperty(exports, "scanRoutesDirectory", { enumerable: true, get: function () { return file_scanner_2.scanRoutesDirectory; } });
|
|
201
|
+
var route_templates_2 = require("./templates/route-templates");
|
|
202
|
+
Object.defineProperty(exports, "extractParamsFromPath", { enumerable: true, get: function () { return route_templates_2.extractParamsFromPath; } });
|
|
203
|
+
Object.defineProperty(exports, "fileNameToScreenName", { enumerable: true, get: function () { return route_templates_2.fileNameToScreenName; } });
|
|
204
|
+
Object.defineProperty(exports, "generateLayoutTemplate", { enumerable: true, get: function () { return route_templates_2.generateLayoutTemplate; } });
|
|
205
|
+
Object.defineProperty(exports, "generateRouteTemplate", { enumerable: true, get: function () { return route_templates_2.generateRouteTemplate; } });
|
|
206
|
+
Object.defineProperty(exports, "generateScreenTemplate", { enumerable: true, get: function () { return route_templates_2.generateScreenTemplate; } });
|
|
207
|
+
Object.defineProperty(exports, "getTemplateType", { enumerable: true, get: function () { return route_templates_2.getTemplateType; } });
|
|
208
|
+
Object.defineProperty(exports, "isFileEmpty", { enumerable: true, get: function () { return route_templates_2.isFileEmpty; } });
|
|
209
|
+
Object.defineProperty(exports, "screenNameToTitle", { enumerable: true, get: function () { return route_templates_2.screenNameToTitle; } });
|
|
179
210
|
var route_validator_1 = require("./validator/route-validator");
|
|
180
211
|
Object.defineProperty(exports, "validateRoutes", { enumerable: true, get: function () { return route_validator_1.validateRoutes; } });
|
|
181
212
|
var file_watcher_2 = require("./watcher/file-watcher");
|
|
@@ -43,6 +43,10 @@ export interface ScanError {
|
|
|
43
43
|
* Scans a routes directory and builds a route tree
|
|
44
44
|
*/
|
|
45
45
|
export declare function scanRoutesDirectory(routesDir: string): ScanResult;
|
|
46
|
+
/**
|
|
47
|
+
* Recursively finds all route files in a directory
|
|
48
|
+
*/
|
|
49
|
+
export declare function findRouteFiles(dir: string, prefix?: string): string[];
|
|
46
50
|
/**
|
|
47
51
|
* Extracts dynamic parameters from a filename
|
|
48
52
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-scanner.d.ts","sourceRoot":"","sources":["../../src/scanner/file-scanner.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,MAAM,WAAW,SAAS;IACzB,yCAAyC;IACzC,IAAI,EAAE,MAAM,CAAC;IACb,8BAA8B;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,yBAAyB;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,yCAAyC;IACzC,YAAY,EAAE,MAAM,CAAC;IACrB,+BAA+B;IAC/B,MAAM,EAAE,eAAe,EAAE,CAAC;IAC1B,mBAAmB;IACnB,QAAQ,EAAE,SAAS,EAAE,CAAC;IACtB,sCAAsC;IACtC,UAAU,EAAE,OAAO,GAAG,MAAM,GAAG,QAAQ,GAAG,MAAM,CAAC;IACjD,6BAA6B;IAC7B,OAAO,EAAE,OAAO,CAAC;IACjB,4BAA4B;IAC5B,QAAQ,EAAE,OAAO,CAAC;IAClB,gCAAgC;IAChC,UAAU,EAAE,OAAO,CAAC;IACpB,0CAA0C;IAC1C,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB;AAED,MAAM,WAAW,eAAe;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,OAAO,CAAC;IACpB,UAAU,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,UAAU;IAC1B,MAAM,EAAE,SAAS,EAAE,CAAC;IACpB,MAAM,EAAE,SAAS,EAAE,CAAC;CACpB;AAED,MAAM,WAAW,SAAS;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM,GAAG,UAAU,CAwCjE;
|
|
1
|
+
{"version":3,"file":"file-scanner.d.ts","sourceRoot":"","sources":["../../src/scanner/file-scanner.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,MAAM,WAAW,SAAS;IACzB,yCAAyC;IACzC,IAAI,EAAE,MAAM,CAAC;IACb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H,wBAAgB,oBAAoB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAGjE;AAsFD;;GAEG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,SAAS,EAAE,GAAG,SAAS,EAAE,CAY9D"}
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.scanRoutesDirectory = scanRoutesDirectory;
|
|
8
|
+
exports.findRouteFiles = findRouteFiles;
|
|
8
9
|
exports.extractParams = extractParams;
|
|
9
10
|
exports.buildUrlPath = buildUrlPath;
|
|
10
11
|
exports.filePathToScreenName = filePathToScreenName;
|
package/dist/scanner/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Scanner module for @teardown/navigation-metro
|
|
3
3
|
*/
|
|
4
|
-
export { buildUrlPath, extractParams, filePathToScreenName, flattenRoutes, type ParamDefinition, type RouteNode, type ScanError, type ScanResult, scanRoutesDirectory, } from "./file-scanner";
|
|
4
|
+
export { buildUrlPath, extractParams, filePathToScreenName, findRouteFiles, flattenRoutes, type ParamDefinition, type RouteNode, type ScanError, type ScanResult, scanRoutesDirectory, } from "./file-scanner";
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/scanner/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACN,YAAY,EACZ,aAAa,EACb,oBAAoB,EACpB,aAAa,EACb,KAAK,eAAe,EACpB,KAAK,SAAS,EACd,KAAK,SAAS,EACd,KAAK,UAAU,EACf,mBAAmB,GACnB,MAAM,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/scanner/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACN,YAAY,EACZ,aAAa,EACb,oBAAoB,EACpB,cAAc,EACd,aAAa,EACb,KAAK,eAAe,EACpB,KAAK,SAAS,EACd,KAAK,SAAS,EACd,KAAK,UAAU,EACf,mBAAmB,GACnB,MAAM,gBAAgB,CAAC"}
|
package/dist/scanner/index.js
CHANGED
|
@@ -3,10 +3,11 @@
|
|
|
3
3
|
* Scanner module for @teardown/navigation-metro
|
|
4
4
|
*/
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.scanRoutesDirectory = exports.flattenRoutes = exports.filePathToScreenName = exports.extractParams = exports.buildUrlPath = void 0;
|
|
6
|
+
exports.scanRoutesDirectory = exports.flattenRoutes = exports.findRouteFiles = exports.filePathToScreenName = exports.extractParams = exports.buildUrlPath = void 0;
|
|
7
7
|
var file_scanner_1 = require("./file-scanner");
|
|
8
8
|
Object.defineProperty(exports, "buildUrlPath", { enumerable: true, get: function () { return file_scanner_1.buildUrlPath; } });
|
|
9
9
|
Object.defineProperty(exports, "extractParams", { enumerable: true, get: function () { return file_scanner_1.extractParams; } });
|
|
10
10
|
Object.defineProperty(exports, "filePathToScreenName", { enumerable: true, get: function () { return file_scanner_1.filePathToScreenName; } });
|
|
11
|
+
Object.defineProperty(exports, "findRouteFiles", { enumerable: true, get: function () { return file_scanner_1.findRouteFiles; } });
|
|
11
12
|
Object.defineProperty(exports, "flattenRoutes", { enumerable: true, get: function () { return file_scanner_1.flattenRoutes; } });
|
|
12
13
|
Object.defineProperty(exports, "scanRoutesDirectory", { enumerable: true, get: function () { return file_scanner_1.scanRoutesDirectory; } });
|
|
@@ -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,8BAA8B,CAAC;AAEpF,MAAM,WAAW,cAAc;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,YAAY,CAAC,EAAE,MAAM,IAAI,CAAC;IAC1B,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,eAAe,EAAE,KAAK,IAAI,CAAC;
|
|
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,8BAA8B,CAAC;AAEpF,MAAM,WAAW,cAAc;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,IAAI,CAAC;IAC1B,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,eAAe,EAAE,KAAK,IAAI,CAAC;IAC9C,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACrB;AAID;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,cAAc,GAAG,MAAM,IAAI,CAoIrE;AAED;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,IAAI,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
|
-
//
|
|
77
|
-
//
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
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
|
-
|
|
90
|
-
|
|
91
|
-
|
|
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
|
-
|
|
96
|
-
|
|
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.
|
|
3
|
+
"version": "2.0.77",
|
|
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.
|
|
45
|
+
"@teardown/tsconfig": "2.0.77",
|
|
46
46
|
"@types/node": "24.10.1",
|
|
47
47
|
"typescript": "5.9.3"
|
|
48
48
|
}
|