@teardown/navigation-metro 2.0.74 → 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.
- package/dist/index.d.ts +8 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +39 -7
- package/package.json +2 -2
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":[],"mapp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AC;AAChG,OAAO,EACN,YAAY,EACZ,aAAa,EACb,oBAAoB,EACpB,aAAa,EACb,mBAAmB,GACnB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACN,qBAAqB,EACrB,oBAAoB,EACpB,sBAAsB,EACtB,qBAAqB,EACrB,sBAAsB,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
|
@@ -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
|
}
|