@teardown/navigation-metro 2.0.73 → 2.0.75
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route-generator.d.ts","sourceRoot":"","sources":["../../src/generator/route-generator.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAiB,KAAK,eAAe,EAAE,KAAK,SAAS,EAAuB,MAAM,yBAAyB,CAAC;AAEnH,MAAM,WAAW,eAAe;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,WAAW,eAAe;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,eAAe,EAAE,CAAC;CAC1B;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,eAAe,GAAG,IAAI,CAiCpE;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,SAAS,EAAE,GAAG,eAAe,EAAE,CAwBhF;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,CAgDrE;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,SAAS,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,MAAM,CAkC1F;AAED;;GAEG;AACH,wBAAgB,2BAA2B,IAAI,MAAM,CAepD;AA4ED,MAAM,WAAW,cAAc;IAC9B,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,OAAO,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,sBAAsB,EAAE,MAAM,GAAG,IAAI,CAAC;CACtC;AAED;;GAEG;AAEH,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AAqB,CAAC,MAAM,EAAE,SAAS,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,cAAc,EAAE,CAqDpH;AAgLD;;;GAGG;AACH,wBAAgB,4BAA4B,CAAC,MAAM,EAAE,SAAS,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM,CA4EjH"}
|
|
@@ -292,10 +292,8 @@ function buildNavigatorHierarchy(routes, routesDir, generatedDir) {
|
|
|
292
292
|
screens: [],
|
|
293
293
|
nestedNavigators: [],
|
|
294
294
|
};
|
|
295
|
-
//
|
|
296
|
-
|
|
297
|
-
if (node.isLayout)
|
|
298
|
-
continue;
|
|
295
|
+
// Helper to process a single screen node
|
|
296
|
+
function processScreenNode(node) {
|
|
299
297
|
const importName = pathToImportName(node.relativePath);
|
|
300
298
|
const importPath = getImportPath(routesDir, generatedDir, node.relativePath);
|
|
301
299
|
allImports.push({ name: importName, path: importPath });
|
|
@@ -326,6 +324,24 @@ function buildNavigatorHierarchy(routes, routesDir, generatedDir) {
|
|
|
326
324
|
});
|
|
327
325
|
}
|
|
328
326
|
}
|
|
327
|
+
// Process children
|
|
328
|
+
for (const node of nodes) {
|
|
329
|
+
if (node.isLayout) {
|
|
330
|
+
// Process layout's children as screens in this navigator
|
|
331
|
+
for (const child of node.children) {
|
|
332
|
+
if (child.isLayout) {
|
|
333
|
+
// Nested layout - recurse
|
|
334
|
+
const nestedNav = processNode([child], child.name);
|
|
335
|
+
navigatorInfo.nestedNavigators.push(nestedNav);
|
|
336
|
+
}
|
|
337
|
+
else {
|
|
338
|
+
processScreenNode(child);
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
continue;
|
|
342
|
+
}
|
|
343
|
+
processScreenNode(node);
|
|
344
|
+
}
|
|
329
345
|
return navigatorInfo;
|
|
330
346
|
}
|
|
331
347
|
function collectScreens(nodes, rDir, gDir, imports) {
|
package/dist/index.d.ts
CHANGED
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
export interface TeardownNavigationOptions {
|
|
9
9
|
/**
|
|
10
10
|
* Path to routes directory relative to project root
|
|
11
|
-
*
|
|
11
|
+
* If not provided, reads from teardown.config.ts navigation.routesDir
|
|
12
|
+
* @default './src/_routes'
|
|
12
13
|
*/
|
|
13
14
|
routesDir?: string;
|
|
14
15
|
/**
|
|
@@ -63,13 +64,17 @@ export interface MetroConfig {
|
|
|
63
64
|
* @example
|
|
64
65
|
* ```js
|
|
65
66
|
* // metro.config.js
|
|
66
|
-
* const { getDefaultConfig } = require('
|
|
67
|
+
* const { getDefaultConfig } = require('@react-native/metro-config');
|
|
67
68
|
* const { withTeardownNavigation } = require('@teardown/navigation-metro');
|
|
68
69
|
*
|
|
69
70
|
* const config = getDefaultConfig(__dirname);
|
|
70
71
|
*
|
|
72
|
+
* // Options are read from teardown.config.ts navigation section by default
|
|
73
|
+
* module.exports = withTeardownNavigation(config);
|
|
74
|
+
*
|
|
75
|
+
* // Or override with explicit options:
|
|
71
76
|
* module.exports = withTeardownNavigation(config, {
|
|
72
|
-
* routesDir: './src/
|
|
77
|
+
* routesDir: './src/_routes',
|
|
73
78
|
* generatedDir: './.teardown',
|
|
74
79
|
* prefixes: ['myapp://', 'https://myapp.com'],
|
|
75
80
|
* verbose: true,
|
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;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;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ACjB,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
|
@@ -15,20 +15,35 @@ const file_watcher_1 = require("./watcher/file-watcher");
|
|
|
15
15
|
*/
|
|
16
16
|
const CONFIG_FILE_NAMES = ["teardown.config.ts", "teardown.config.js", "teardown.config.mjs", "launchpad.config.ts"];
|
|
17
17
|
/**
|
|
18
|
-
* Read the
|
|
19
|
-
* This is a simple synchronous parser that extracts
|
|
18
|
+
* Read the navigation config from the Teardown config file
|
|
19
|
+
* This is a simple synchronous parser that extracts values using regex
|
|
20
20
|
*/
|
|
21
|
-
function
|
|
21
|
+
function readTeardownConfig(projectRoot) {
|
|
22
22
|
for (const fileName of CONFIG_FILE_NAMES) {
|
|
23
23
|
const configPath = (0, node_path_1.resolve)(projectRoot, fileName);
|
|
24
24
|
if ((0, node_fs_1.existsSync)(configPath)) {
|
|
25
25
|
try {
|
|
26
26
|
const content = (0, node_fs_1.readFileSync)(configPath, "utf-8");
|
|
27
|
+
const config = {};
|
|
27
28
|
// Extract slug using regex - handles both single and double quotes
|
|
28
29
|
const slugMatch = content.match(/slug:\s*['"]([^'"]+)['"]/);
|
|
29
30
|
if (slugMatch) {
|
|
30
|
-
|
|
31
|
+
config.slug = slugMatch[1];
|
|
32
|
+
}
|
|
33
|
+
// Extract navigation config values
|
|
34
|
+
const routesDirMatch = content.match(/routesDir:\s*['"]([^'"]+)['"]/);
|
|
35
|
+
if (routesDirMatch) {
|
|
36
|
+
config.routesDir = routesDirMatch[1];
|
|
37
|
+
}
|
|
38
|
+
const generatedDirMatch = content.match(/generatedDir:\s*['"]([^'"]+)['"]/);
|
|
39
|
+
if (generatedDirMatch) {
|
|
40
|
+
config.generatedDir = generatedDirMatch[1];
|
|
31
41
|
}
|
|
42
|
+
const autoTemplateMatch = content.match(/autoTemplate:\s*(true|false)/);
|
|
43
|
+
if (autoTemplateMatch) {
|
|
44
|
+
config.autoTemplate = autoTemplateMatch[1] === "true";
|
|
45
|
+
}
|
|
46
|
+
return config;
|
|
32
47
|
}
|
|
33
48
|
catch {
|
|
34
49
|
// Ignore read errors and try next config file
|
|
@@ -37,6 +52,13 @@ function readSlugFromConfig(projectRoot) {
|
|
|
37
52
|
}
|
|
38
53
|
return null;
|
|
39
54
|
}
|
|
55
|
+
/**
|
|
56
|
+
* Read the slug from the Teardown config file (legacy helper)
|
|
57
|
+
*/
|
|
58
|
+
function readSlugFromConfig(projectRoot) {
|
|
59
|
+
const config = readTeardownConfig(projectRoot);
|
|
60
|
+
return config?.slug ?? null;
|
|
61
|
+
}
|
|
40
62
|
/**
|
|
41
63
|
* Wraps a Metro configuration with Teardown Navigation support
|
|
42
64
|
*
|
|
@@ -48,13 +70,17 @@ function readSlugFromConfig(projectRoot) {
|
|
|
48
70
|
* @example
|
|
49
71
|
* ```js
|
|
50
72
|
* // metro.config.js
|
|
51
|
-
* const { getDefaultConfig } = require('
|
|
73
|
+
* const { getDefaultConfig } = require('@react-native/metro-config');
|
|
52
74
|
* const { withTeardownNavigation } = require('@teardown/navigation-metro');
|
|
53
75
|
*
|
|
54
76
|
* const config = getDefaultConfig(__dirname);
|
|
55
77
|
*
|
|
78
|
+
* // Options are read from teardown.config.ts navigation section by default
|
|
79
|
+
* module.exports = withTeardownNavigation(config);
|
|
80
|
+
*
|
|
81
|
+
* // Or override with explicit options:
|
|
56
82
|
* module.exports = withTeardownNavigation(config, {
|
|
57
|
-
* routesDir: './src/
|
|
83
|
+
* routesDir: './src/_routes',
|
|
58
84
|
* generatedDir: './.teardown',
|
|
59
85
|
* prefixes: ['myapp://', 'https://myapp.com'],
|
|
60
86
|
* verbose: true,
|
|
@@ -62,8 +88,14 @@ function readSlugFromConfig(projectRoot) {
|
|
|
62
88
|
* ```
|
|
63
89
|
*/
|
|
64
90
|
function withTeardownNavigation(config, options = {}) {
|
|
65
|
-
const { routesDir = "./src/routes", generatedDir = "./.teardown", verbose = false, autoTemplate = true } = options;
|
|
66
91
|
const projectRoot = config.projectRoot ?? process.cwd();
|
|
92
|
+
// Read from teardown.config.ts if options not provided
|
|
93
|
+
const teardownConfig = readTeardownConfig(projectRoot);
|
|
94
|
+
// Use options if provided, fallback to teardown.config.ts, then defaults
|
|
95
|
+
const routesDir = options.routesDir ?? teardownConfig?.routesDir ?? "./src/_routes";
|
|
96
|
+
const generatedDir = options.generatedDir ?? teardownConfig?.generatedDir ?? "./.teardown";
|
|
97
|
+
const autoTemplate = options.autoTemplate ?? teardownConfig?.autoTemplate ?? true;
|
|
98
|
+
const verbose = options.verbose ?? false;
|
|
67
99
|
const absoluteRoutesDir = (0, node_path_1.resolve)(projectRoot, routesDir);
|
|
68
100
|
const absoluteGeneratedDir = (0, node_path_1.resolve)(projectRoot, generatedDir);
|
|
69
101
|
// If no prefixes provided, try to read slug from teardown config
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teardown/navigation-metro",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.75",
|
|
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.75",
|
|
46
46
|
"@types/node": "24.10.1",
|
|
47
47
|
"typescript": "5.9.3"
|
|
48
48
|
}
|