one 1.17.3 → 1.17.4
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/cjs/typed-routes/generateRouteTypes.cjs +12 -2
- package/dist/cjs/typed-routes/generateRouteTypes.native.js +12 -2
- package/dist/cjs/typed-routes/generateRouteTypes.native.js.map +1 -1
- package/dist/cjs/typed-routes/generateRouteTypes.test.cjs +58 -0
- package/dist/cjs/typed-routes/generateRouteTypes.test.native.js +61 -0
- package/dist/cjs/typed-routes/generateRouteTypes.test.native.js.map +1 -0
- package/dist/cjs/typed-routes/getTypedRoutesDeclarationFile.cjs +5 -5
- package/dist/cjs/typed-routes/getTypedRoutesDeclarationFile.native.js +5 -5
- package/dist/cjs/typed-routes/getTypedRoutesDeclarationFile.native.js.map +1 -1
- package/dist/cjs/typed-routes/getTypedRoutesDeclarationFile.test.cjs +18 -0
- package/dist/cjs/typed-routes/getTypedRoutesDeclarationFile.test.native.js +25 -0
- package/dist/cjs/typed-routes/getTypedRoutesDeclarationFile.test.native.js.map +1 -0
- package/dist/cjs/utils/routeFileWatch.cjs +58 -0
- package/dist/cjs/utils/routeFileWatch.native.js +62 -0
- package/dist/cjs/utils/routeFileWatch.native.js.map +1 -0
- package/dist/cjs/utils/routeFileWatch.test.cjs +92 -0
- package/dist/cjs/utils/routeFileWatch.test.native.js +95 -0
- package/dist/cjs/utils/routeFileWatch.test.native.js.map +1 -0
- package/dist/cjs/vite/plugins/fileSystemRouterPlugin.cjs +16 -7
- package/dist/cjs/vite/plugins/fileSystemRouterPlugin.native.js +16 -7
- package/dist/cjs/vite/plugins/fileSystemRouterPlugin.native.js.map +1 -1
- package/dist/cjs/vite/plugins/fileSystemRouterPlugin.test.cjs +111 -0
- package/dist/cjs/vite/plugins/fileSystemRouterPlugin.test.native.js +116 -0
- package/dist/cjs/vite/plugins/fileSystemRouterPlugin.test.native.js.map +1 -0
- package/dist/cjs/vite/plugins/generateFileSystemRouteTypesPlugin.cjs +9 -9
- package/dist/cjs/vite/plugins/generateFileSystemRouteTypesPlugin.native.js +10 -10
- package/dist/cjs/vite/plugins/generateFileSystemRouteTypesPlugin.native.js.map +1 -1
- package/dist/esm/typed-routes/generateRouteTypes.mjs +13 -3
- package/dist/esm/typed-routes/generateRouteTypes.mjs.map +1 -1
- package/dist/esm/typed-routes/generateRouteTypes.native.js +13 -3
- package/dist/esm/typed-routes/generateRouteTypes.native.js.map +1 -1
- package/dist/esm/typed-routes/generateRouteTypes.test.mjs +35 -0
- package/dist/esm/typed-routes/generateRouteTypes.test.mjs.map +1 -0
- package/dist/esm/typed-routes/generateRouteTypes.test.native.js +35 -0
- package/dist/esm/typed-routes/generateRouteTypes.test.native.js.map +1 -0
- package/dist/esm/typed-routes/getTypedRoutesDeclarationFile.mjs +5 -5
- package/dist/esm/typed-routes/getTypedRoutesDeclarationFile.mjs.map +1 -1
- package/dist/esm/typed-routes/getTypedRoutesDeclarationFile.native.js +5 -5
- package/dist/esm/typed-routes/getTypedRoutesDeclarationFile.native.js.map +1 -1
- package/dist/esm/typed-routes/getTypedRoutesDeclarationFile.test.mjs +19 -0
- package/dist/esm/typed-routes/getTypedRoutesDeclarationFile.test.mjs.map +1 -0
- package/dist/esm/typed-routes/getTypedRoutesDeclarationFile.test.native.js +23 -0
- package/dist/esm/typed-routes/getTypedRoutesDeclarationFile.test.native.js.map +1 -0
- package/dist/esm/utils/routeFileWatch.mjs +20 -0
- package/dist/esm/utils/routeFileWatch.mjs.map +1 -0
- package/dist/esm/utils/routeFileWatch.native.js +21 -0
- package/dist/esm/utils/routeFileWatch.native.js.map +1 -0
- package/dist/esm/utils/routeFileWatch.test.mjs +69 -0
- package/dist/esm/utils/routeFileWatch.test.mjs.map +1 -0
- package/dist/esm/utils/routeFileWatch.test.native.js +69 -0
- package/dist/esm/utils/routeFileWatch.test.native.js.map +1 -0
- package/dist/esm/vite/plugins/fileSystemRouterPlugin.mjs +16 -7
- package/dist/esm/vite/plugins/fileSystemRouterPlugin.mjs.map +1 -1
- package/dist/esm/vite/plugins/fileSystemRouterPlugin.native.js +16 -7
- package/dist/esm/vite/plugins/fileSystemRouterPlugin.native.js.map +1 -1
- package/dist/esm/vite/plugins/fileSystemRouterPlugin.test.mjs +88 -0
- package/dist/esm/vite/plugins/fileSystemRouterPlugin.test.mjs.map +1 -0
- package/dist/esm/vite/plugins/fileSystemRouterPlugin.test.native.js +90 -0
- package/dist/esm/vite/plugins/fileSystemRouterPlugin.test.native.js.map +1 -0
- package/dist/esm/vite/plugins/generateFileSystemRouteTypesPlugin.mjs +9 -9
- package/dist/esm/vite/plugins/generateFileSystemRouteTypesPlugin.mjs.map +1 -1
- package/dist/esm/vite/plugins/generateFileSystemRouteTypesPlugin.native.js +10 -10
- package/dist/esm/vite/plugins/generateFileSystemRouteTypesPlugin.native.js.map +1 -1
- package/package.json +10 -10
- package/src/typed-routes/generateRouteTypes.test.ts +53 -0
- package/src/typed-routes/generateRouteTypes.ts +14 -3
- package/src/typed-routes/getTypedRoutesDeclarationFile.test.ts +22 -0
- package/src/typed-routes/getTypedRoutesDeclarationFile.ts +5 -5
- package/src/utils/routeFileWatch.test.ts +94 -0
- package/src/utils/routeFileWatch.ts +40 -0
- package/src/vite/plugins/fileSystemRouterPlugin.test.ts +106 -0
- package/src/vite/plugins/fileSystemRouterPlugin.tsx +21 -13
- package/src/vite/plugins/generateFileSystemRouteTypesPlugin.tsx +16 -17
- package/types/typed-routes/generateRouteTypes.d.ts.map +1 -1
- package/types/typed-routes/generateRouteTypes.test.d.ts +2 -0
- package/types/typed-routes/generateRouteTypes.test.d.ts.map +1 -0
- package/types/typed-routes/getTypedRoutesDeclarationFile.test.d.ts +2 -0
- package/types/typed-routes/getTypedRoutesDeclarationFile.test.d.ts.map +1 -0
- package/types/utils/routeFileWatch.d.ts +9 -0
- package/types/utils/routeFileWatch.d.ts.map +1 -0
- package/types/utils/routeFileWatch.test.d.ts +2 -0
- package/types/utils/routeFileWatch.test.d.ts.map +1 -0
- package/types/vite/plugins/fileSystemRouterPlugin.d.ts.map +1 -1
- package/types/vite/plugins/fileSystemRouterPlugin.test.d.ts +2 -0
- package/types/vite/plugins/fileSystemRouterPlugin.test.d.ts.map +1 -0
- package/types/vite/plugins/generateFileSystemRouteTypesPlugin.d.ts.map +1 -1
|
@@ -61,8 +61,18 @@ async function generateRouteTypes(outFile, routerRoot, ignoredRouteFiles, typedR
|
|
|
61
61
|
const context = (0, import_useViteRoutes.globbedRoutesToRouteContext)(routes, routerRoot);
|
|
62
62
|
const declarations = (0, import_getTypedRoutesDeclarationFile.getTypedRoutesDeclarationFile)(context);
|
|
63
63
|
const outDir = (0, import_node_path.dirname)(outFile);
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
let currentDeclarations;
|
|
65
|
+
try {
|
|
66
|
+
currentDeclarations = await (0, import_promises.readFile)(outFile, "utf8");
|
|
67
|
+
} catch (error) {
|
|
68
|
+
if (error.code !== "ENOENT") {
|
|
69
|
+
throw error;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
if (currentDeclarations !== declarations) {
|
|
73
|
+
await import_fs_extra.default.ensureDir(outDir);
|
|
74
|
+
await (0, import_promises.writeFile)(outFile, declarations);
|
|
75
|
+
}
|
|
66
76
|
if (typedRoutesMode) {
|
|
67
77
|
const mode = typedRoutesMode === "type" ? "type" : "runtime";
|
|
68
78
|
for (const routePath of routePaths) {
|
|
@@ -63,8 +63,18 @@ async function generateRouteTypes(outFile, routerRoot, ignoredRouteFiles, typedR
|
|
|
63
63
|
var context = (0, import_useViteRoutes.globbedRoutesToRouteContext)(routes, routerRoot);
|
|
64
64
|
var declarations = (0, import_getTypedRoutesDeclarationFile.getTypedRoutesDeclarationFile)(context);
|
|
65
65
|
var outDir = (0, import_path.dirname)(outFile);
|
|
66
|
-
|
|
67
|
-
|
|
66
|
+
var currentDeclarations;
|
|
67
|
+
try {
|
|
68
|
+
currentDeclarations = await (0, import_promises.readFile)(outFile, "utf8");
|
|
69
|
+
} catch (error) {
|
|
70
|
+
if (error.code !== "ENOENT") {
|
|
71
|
+
throw error;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
if (currentDeclarations !== declarations) {
|
|
75
|
+
await import_fs_extra.default.ensureDir(outDir);
|
|
76
|
+
await (0, import_promises.writeFile)(outFile, declarations);
|
|
77
|
+
}
|
|
68
78
|
if (typedRoutesMode) {
|
|
69
79
|
var mode = typedRoutesMode === "type" ? "type" : "runtime";
|
|
70
80
|
var _iteratorNormalCompletion = true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","generateRouteTypes_exports","__export","generateRouteTypes","module","exports","import_promises","require","import_path","import_fs_extra","__toESM","import_micromatch","import_matchers","import_useViteRoutes","import_globDir","import_getTypedRoutesDeclarationFile","import_injectRouteHelpers","outFile","routerRoot","ignoredRouteFiles","typedRoutesMode","routePaths","globDir","length","default","not","matchBase","routes","reduce","acc","cur","vitePath","replace","context","globbedRoutesToRouteContext","declarations","getTypedRoutesDeclarationFile","outDir","dirname","ensureDir","writeFile","mode","_iteratorNormalCompletion","_didIteratorError","_iteratorError","_iterator","Symbol","iterator","_step","next","done","routePath","includes","startsWith","endsWith","fullPath","join","process","cwd","routeName","cleanRouteName","removeSupportedExtensions"],"sources":["../../../src/typed-routes/generateRouteTypes.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,0BAAA;AAAAC,QAAA,CAAAD,0BAAA;EAAAE,kBAAA,EAAAA,CAAA,KAAAA;AAAA;AAAAC,MAAA,CAAAC,OAAA,GAAAT,
|
|
1
|
+
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","generateRouteTypes_exports","__export","generateRouteTypes","module","exports","import_promises","require","import_path","import_fs_extra","__toESM","import_micromatch","import_matchers","import_useViteRoutes","import_globDir","import_getTypedRoutesDeclarationFile","import_injectRouteHelpers","outFile","routerRoot","ignoredRouteFiles","typedRoutesMode","routePaths","globDir","length","default","not","matchBase","routes","reduce","acc","cur","vitePath","replace","context","globbedRoutesToRouteContext","declarations","getTypedRoutesDeclarationFile","outDir","dirname","currentDeclarations","readFile","error","code","ensureDir","writeFile","mode","_iteratorNormalCompletion","_didIteratorError","_iteratorError","_iterator","Symbol","iterator","_step","next","done","routePath","includes","startsWith","endsWith","fullPath","join","process","cwd","routeName","cleanRouteName","removeSupportedExtensions"],"sources":["../../../src/typed-routes/generateRouteTypes.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,0BAAA;AAAAC,QAAA,CAAAD,0BAAA;EAAAE,kBAAA,EAAAA,CAAA,KAAAA;AAAA;AAAAC,MAAA,CAAAC,OAAA,GAAAT,YAAoC,CAAAK,0BAAA;AACpC,IAAAK,eAAA,GAAAC,OAA8B;AAC9B,IAAAC,WAAA,GAAAD,OAAoB;AACpB,IAAAE,eAAA,GAAAC,OAAuB,CAAAH,OAAA;AACvB,IAAAI,iBAAA,GAA0CD,OAAA,CAAAH,OAAA;AAC1C,IAAAK,eAAA,GAAAL,OAA4C;AAC5C,IAAAM,oBAAwB,GAAAN,OAAA;AAExB,IAAAO,cAAA,GAAAP,OAAA,6BAA8C;AAC9C,IAAAQ,oCAAoD,GAAAR,OAAA;AAEpD,IAAAS,yBAAsB,GAAAT,OACpB,iCAEA;AAGA,eAAIJ,kBAAaA,CAAAc,OAAA,EAAAC,UAAQ,EAAAC,iBAAU,EAAAC,eAAA;EACnC,IAAIC,UAAA,OAAAP,cAAqB,CAAAQ,OAAkB,EAAAJ,UAAY;EACrD,IAAAC,iBAAa,IAAAA,iBAAW,C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,KAAQD,SAAW,CACnBC,QAAQ,YAAYD,SACpB,CAAAE,UAAQ,IAAY,KACpBF,SAAQ,CAAAG,QAAU,CAAE;UACnB;QAGJ;QACE,IAAAC,QAAA,KAAiB,EAAAnD,WAAM,CAAAoD,IAAA,EAAAC,OAAA,CAAAC,GAAA,IAAA5C,UAAA,EAAAqC,SAAA;QACzB,IAAAQ,SAAA,GAAAR,SAAA,CAAAvB,OAAA,cAAAA,OAAA,iBAAAA,OAAA,iBAAAA,OAAA;QAGA,IAAKgC,cAAe,OAAApD,eAAe,CAAAqD,yBAAA,EAAAF,SAAA,EAAA/B,OAAA;QACjC,KAAAgC,cAAA,CAAAP,UAAA;UACFO,cAAA,SAAAA,cAAA;QAEA;QACF,KAAAA,cAAA,CAAAR,QAAA;UACF;QACF","ignoreList":[]}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __copyProps = (to, from, except, desc) => {
|
|
8
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
9
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
10
|
+
get: () => from[key],
|
|
11
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
return to;
|
|
15
|
+
};
|
|
16
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
17
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
18
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
19
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
20
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
22
|
+
value: mod,
|
|
23
|
+
enumerable: true
|
|
24
|
+
}) : target, mod));
|
|
25
|
+
var import_node_fs = require("node:fs");
|
|
26
|
+
var import_node_os = require("node:os");
|
|
27
|
+
var import_node_path = __toESM(require("node:path"), 1);
|
|
28
|
+
var import_vitest = require("vitest");
|
|
29
|
+
var import_generateRouteTypes = require("./generateRouteTypes.cjs");
|
|
30
|
+
(0, import_vitest.describe)(import_generateRouteTypes.generateRouteTypes, () => {
|
|
31
|
+
const originalCwd = process.cwd();
|
|
32
|
+
let tempRoot;
|
|
33
|
+
(0, import_vitest.afterEach)(() => {
|
|
34
|
+
process.chdir(originalCwd);
|
|
35
|
+
if (tempRoot) {
|
|
36
|
+
(0, import_node_fs.rmSync)(tempRoot, {
|
|
37
|
+
recursive: true,
|
|
38
|
+
force: true
|
|
39
|
+
});
|
|
40
|
+
tempRoot = void 0;
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
(0, import_vitest.it)("does not rewrite routes declarations when contents are unchanged", async () => {
|
|
44
|
+
tempRoot = (0, import_node_fs.mkdtempSync)(import_node_path.default.join((0, import_node_os.tmpdir)(), "one-routes-types-"));
|
|
45
|
+
const appDir = import_node_path.default.join(tempRoot, "app");
|
|
46
|
+
(0, import_node_fs.mkdirSync)(appDir);
|
|
47
|
+
(0, import_node_fs.writeFileSync)(import_node_path.default.join(appDir, "index+ssg.tsx"), "export default function Index() { return null }\n");
|
|
48
|
+
(0, import_node_fs.writeFileSync)(import_node_path.default.join(appDir, "[slug]+ssg.tsx"), "export default function Slug() { return null }\n");
|
|
49
|
+
process.chdir(tempRoot);
|
|
50
|
+
const outFile = import_node_path.default.join("app", "routes.d.ts");
|
|
51
|
+
await (0, import_generateRouteTypes.generateRouteTypes)(outFile, "app");
|
|
52
|
+
const oldDate = /* @__PURE__ */new Date("2001-01-01T00:00:00.000Z");
|
|
53
|
+
(0, import_node_fs.utimesSync)(outFile, oldDate, oldDate);
|
|
54
|
+
const previousMtimeMs = (0, import_node_fs.statSync)(outFile).mtimeMs;
|
|
55
|
+
await (0, import_generateRouteTypes.generateRouteTypes)(outFile, "app");
|
|
56
|
+
(0, import_vitest.expect)((0, import_node_fs.statSync)(outFile).mtimeMs).toBe(previousMtimeMs);
|
|
57
|
+
});
|
|
58
|
+
});
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
12
|
+
get: () => from[key],
|
|
13
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
20
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
21
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
22
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
23
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
24
|
+
value: mod,
|
|
25
|
+
enumerable: true
|
|
26
|
+
}) : target, mod));
|
|
27
|
+
var import_fs = require("fs");
|
|
28
|
+
var import_os = require("os");
|
|
29
|
+
var import_path = __toESM(require("path"), 1);
|
|
30
|
+
var import_vitest = require("vitest");
|
|
31
|
+
var import_generateRouteTypes = require("./generateRouteTypes.native.js");
|
|
32
|
+
(0, import_vitest.describe)(import_generateRouteTypes.generateRouteTypes, function () {
|
|
33
|
+
var originalCwd = process.cwd();
|
|
34
|
+
var tempRoot;
|
|
35
|
+
(0, import_vitest.afterEach)(function () {
|
|
36
|
+
process.chdir(originalCwd);
|
|
37
|
+
if (tempRoot) {
|
|
38
|
+
(0, import_fs.rmSync)(tempRoot, {
|
|
39
|
+
recursive: true,
|
|
40
|
+
force: true
|
|
41
|
+
});
|
|
42
|
+
tempRoot = void 0;
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
(0, import_vitest.it)("does not rewrite routes declarations when contents are unchanged", async function () {
|
|
46
|
+
tempRoot = (0, import_fs.mkdtempSync)(import_path.default.join((0, import_os.tmpdir)(), "one-routes-types-"));
|
|
47
|
+
var appDir = import_path.default.join(tempRoot, "app");
|
|
48
|
+
(0, import_fs.mkdirSync)(appDir);
|
|
49
|
+
(0, import_fs.writeFileSync)(import_path.default.join(appDir, "index+ssg.tsx"), "export default function Index() { return null }\n");
|
|
50
|
+
(0, import_fs.writeFileSync)(import_path.default.join(appDir, "[slug]+ssg.tsx"), "export default function Slug() { return null }\n");
|
|
51
|
+
process.chdir(tempRoot);
|
|
52
|
+
var outFile = import_path.default.join("app", "routes.d.ts");
|
|
53
|
+
await (0, import_generateRouteTypes.generateRouteTypes)(outFile, "app");
|
|
54
|
+
var oldDate = /* @__PURE__ */new Date("2001-01-01T00:00:00.000Z");
|
|
55
|
+
(0, import_fs.utimesSync)(outFile, oldDate, oldDate);
|
|
56
|
+
var previousMtimeMs = (0, import_fs.statSync)(outFile).mtimeMs;
|
|
57
|
+
await (0, import_generateRouteTypes.generateRouteTypes)(outFile, "app");
|
|
58
|
+
(0, import_vitest.expect)((0, import_fs.statSync)(outFile).mtimeMs).toBe(previousMtimeMs);
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
//# sourceMappingURL=generateRouteTypes.test.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["import_fs","require","import_os","import_path","__toESM","import_vitest","import_generateRouteTypes","describe","generateRouteTypes","originalCwd","process","cwd","tempRoot","afterEach","chdir","rmSync","recursive","force","it","mkdtempSync","default","join","tmpdir","appDir","mkdirSync","writeFileSync","outFile","oldDate","Date","utimesSync","previousMtimeMs","statSync","mtimeMs","expect","toBe"],"sources":["../../../src/typed-routes/generateRouteTypes.test.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;gBAAA;AAQA,IAAAA,SAAA,GAAAC,OAAuB;AACvB,IAAAC,SAAA,GAAAD,OAAiB;AACjB,IAAAE,WAAA,GAAAC,OAAgD,CAAAH,OAAA;AAChD,IAAAI,aAAA,GAAAJ,OAAA,SAAmC;AAAA,IAEnCK,yBAAS,GAAAL,OAAA;AACP,IAAAI,aAAM,CAAAE,QAAc,EAAAD,yBAAY,CAAAE,kBAAA;EAChC,IAAIC,WAAA,GAAAC,OAAA,CAAAC,GAAA;EAEJ,IAAAC,QAAA;EACE,IAAAP,aAAc,CAAAQ,SAAW;IAEzBH,OAAI,CAAAI,KAAA,CAAUL,WAAA;IACZ,IAAAG,QAAA;MACA,IAAAZ,SAAW,CAAAe,MAAA,EAAAH,QAAA;QACbI,SAAA;QACDC,KAAA;MAED;MACEL,QAAA,QAAW;IACX;EACA;EACA,IAAAP,aAAA,CAAAa,EAAA;IAAAN,QACE,OAAAZ,SAAA,CAAAmB,WAAU,EAAAhB,WAAQ,CAAAiB,OAAe,CAAAC,IAAA,KAAAnB,SAAA,CAAAoB,MAAA;IAAA,IACjCC,MAAA,GAAApB,WAAA,CAAAiB,OAAA,CAAAC,IAAA,CAAAT,QAAA;IACF,IAAAZ,SAAA,CAAAwB,SAAA,EAAAD,MAAA;IACA,IAAAvB,SAAA,CAAAyB,aAAA,EAAAtB,WAAA,CAAAiB,OAAA,CAAAC,IAAA,CAAAE,MAAA;IAAA,EACE,EAAAvB,SAAA,CAAAyB,aAAK,EAAAtB,WAAa,CAAAiB,OAAA,CAAAC,IAAA,CAAAE,MAAgB;IAAAb,OAClC,CAAAI,KAAA,CAAAF,QAAA;IACF,IAAAc,OAAA,GAAAvB,WAAA,CAAAiB,OAAA,CAAAC,IAAA;IAEA,QAAQ,EAAAf,yBAAc,CAAAE,kBAAA,EAAAkB,OAAA;IAEtB,IAAAC,OAAM,kBAAU,IAAAC,IAAA,2BAAiB,CAAa;IAC9C,IAAA5B,SAAM,CAAA6B,UAAA,EAAAH,OAAA,EAAAC,OAAA,EAAAA,OAAA;IAEN,IAAAG,eAAgB,OAAA9B,SAAA,CAAI+B,QAAK,EAAAL,OAAA,EAAAM,OAAA;IACzB,UAAA1B,yBAAW,CAAAE,kBAAkB,EAAOkB,OAAA;IACpC,IAAArB,aAAM,CAAA4B,MAAA,IAAkB,EAAAjC,SAAA,CAAA+B,QAAA,EAAAL,OAAS,EAAAM,OAAS,EAAAE,IAAA,CAAAJ,eAAA;EAE1C;AAEA","ignoreList":[]}
|
|
@@ -49,9 +49,9 @@ import type { OneRouter } from 'one'
|
|
|
49
49
|
declare module 'one' {
|
|
50
50
|
export namespace OneRouter {
|
|
51
51
|
export interface __routes<T extends string = string> extends Record<string, unknown> {
|
|
52
|
-
StaticRoutes
|
|
53
|
-
DynamicRoutes
|
|
54
|
-
DynamicRouteTemplate
|
|
52
|
+
StaticRoutes:${setToUnionType(staticRoutes)}
|
|
53
|
+
DynamicRoutes:${setToUnionType(dynamicRoutes)}
|
|
54
|
+
DynamicRouteTemplate:${setToUnionType(dynamicRouteContextKeys)}
|
|
55
55
|
IsTyped: true
|
|
56
56
|
${hasRoutes ? `RouteTypes: ${generateRouteTypesMap(dynamicRouteContextKeys)}` : ""}
|
|
57
57
|
}
|
|
@@ -129,9 +129,9 @@ function addRouteNode(routeNode, parentRoutePath, staticRoutes, dynamicRoutes, d
|
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
131
|
const setToUnionType = set => {
|
|
132
|
-
if (set.size === 0) return "never";
|
|
132
|
+
if (set.size === 0) return " never";
|
|
133
133
|
const sorted = [...set].sort();
|
|
134
|
-
if (sorted.length === 1) return
|
|
134
|
+
if (sorted.length === 1) return ` \`${sorted[0]}\``;
|
|
135
135
|
return "\n | " + sorted.map(s => `\`${s}\``).join("\n | ");
|
|
136
136
|
};
|
|
137
137
|
function generateCombinations(pathname) {
|
|
@@ -52,9 +52,9 @@ import type { OneRouter } from 'one'
|
|
|
52
52
|
declare module 'one' {
|
|
53
53
|
export namespace OneRouter {
|
|
54
54
|
export interface __routes<T extends string = string> extends Record<string, unknown> {
|
|
55
|
-
StaticRoutes
|
|
56
|
-
DynamicRoutes
|
|
57
|
-
DynamicRouteTemplate
|
|
55
|
+
StaticRoutes:${setToUnionType(staticRoutes)}
|
|
56
|
+
DynamicRoutes:${setToUnionType(dynamicRoutes)}
|
|
57
|
+
DynamicRouteTemplate:${setToUnionType(dynamicRouteContextKeys)}
|
|
58
58
|
IsTyped: true
|
|
59
59
|
${hasRoutes ? `RouteTypes: ${generateRouteTypesMap(dynamicRouteContextKeys)}` : ""}
|
|
60
60
|
}
|
|
@@ -189,9 +189,9 @@ function addRouteNode(routeNode, parentRoutePath, staticRoutes, dynamicRoutes, d
|
|
|
189
189
|
}
|
|
190
190
|
}
|
|
191
191
|
var setToUnionType = function (set) {
|
|
192
|
-
if (set.size === 0) return "never";
|
|
192
|
+
if (set.size === 0) return " never";
|
|
193
193
|
var sorted = [...set].sort();
|
|
194
|
-
if (sorted.length === 1) return
|
|
194
|
+
if (sorted.length === 1) return ` \`${sorted[0]}\``;
|
|
195
195
|
return "\n | " + sorted.map(function (s) {
|
|
196
196
|
return `\`${s}\``;
|
|
197
197
|
}).join("\n | ");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","getTypedRoutesDeclarationFile_exports","__export","getTypedRoutesDeclarationFile","module","exports","import_getRoutes","require","import_matchers","CATCH_ALL","SLUG","ctx","staticRoutes","Set","dynamicRoutes","dynamicRouteContextKeys","walkRouteNode","getRoutes","platformRoutes","ignoreEntryPoints","ignoreRequireErrors","hasRoutes","size","setToUnionType","generateRouteTypesMap","trim","routes","sort","entries","map","routePath","params","extractParams","paramsType","length","generateInlineParamsType","join","paramRegex","match","exec","push","name","isCatchAll","p","type","routeNode","parentRoutePath","addRouteNode","removeSupportedExtensions","route","replace","_iteratorNormalCompletion","_didIteratorError","_iteratorError","_iterator","children","Symbol","iterator","_step","next","done","child","err","return","isTypedRoute","startsWith","dynamic","generateCombinations","path","add","replaceAll","_iteratorNormalCompletion1","_didIteratorError1","_iteratorError1"],"sources":["../../../src/typed-routes/getTypedRoutesDeclarationFile.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,qCAAA;AAAAC,QAAA,CAAAD,qCAAA;EAAAE,6BAAA,EAAAA,CAAA,KAAAA;AAAA;AAAAC,MAAA,CAAAC,OAAA,GAAAT,YAA0B,CAAAK,qCAAA;AAC1B,IAAAK,gBAAA,GAAwDC,OAAA;AAKxD,IAAAC,eAAkB,GAAAD,OAAA;AAElB,IAAAE,SAAa;AAEN,IAAAC,IAAA,GAAS;AACd,SAAMP,6BAAeA,CAAAQ,GAAA,EAAI;EACzB,IAAAC,YAAM,kBAAgB,IAAAC,GAAI;EAC1B,IAAAC,aAAM,kBAA0B,IAAAD,GAAA;EAEhC,IAAAE,uBAAA,sBAAAF,GAAA;EAAAG,aACE,CAAe,EACb,EAAAV,gBAAgB,CAAAW,SAAA,EAAAN,GAAA;IAAAO,cAAA;IAChB;IACAC,iBAAA,MAAqB;IAAAC,mBAAA;EAEvB,CAAC;EACD;EACA,IACAR,YAAA,EACAE,aAAA,EACFC,uBAEA;EAEA,IAAAM,SAAO,GAAAN,uBAAA,CAAAO,IAAA;EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
1
|
+
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","getTypedRoutesDeclarationFile_exports","__export","getTypedRoutesDeclarationFile","module","exports","import_getRoutes","require","import_matchers","CATCH_ALL","SLUG","ctx","staticRoutes","Set","dynamicRoutes","dynamicRouteContextKeys","walkRouteNode","getRoutes","platformRoutes","ignoreEntryPoints","ignoreRequireErrors","hasRoutes","size","setToUnionType","generateRouteTypesMap","trim","routes","sort","entries","map","routePath","params","extractParams","paramsType","length","generateInlineParamsType","join","paramRegex","match","exec","push","name","isCatchAll","p","type","routeNode","parentRoutePath","addRouteNode","removeSupportedExtensions","route","replace","_iteratorNormalCompletion","_didIteratorError","_iteratorError","_iterator","children","Symbol","iterator","_step","next","done","child","err","return","isTypedRoute","startsWith","dynamic","generateCombinations","path","add","replaceAll","_iteratorNormalCompletion1","_didIteratorError1","_iteratorError1"],"sources":["../../../src/typed-routes/getTypedRoutesDeclarationFile.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,qCAAA;AAAAC,QAAA,CAAAD,qCAAA;EAAAE,6BAAA,EAAAA,CAAA,KAAAA;AAAA;AAAAC,MAAA,CAAAC,OAAA,GAAAT,YAA0B,CAAAK,qCAAA;AAC1B,IAAAK,gBAAA,GAAwDC,OAAA;AAKxD,IAAAC,eAAkB,GAAAD,OAAA;AAElB,IAAAE,SAAa;AAEN,IAAAC,IAAA,GAAS;AACd,SAAMP,6BAAeA,CAAAQ,GAAA,EAAI;EACzB,IAAAC,YAAM,kBAAgB,IAA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DeclarationFile = require("./getTypedRoutesDeclarationFile.cjs");
|
|
3
|
+
function createRouteContext(paths) {
|
|
4
|
+
const context = () => ({
|
|
5
|
+
default() {}
|
|
6
|
+
});
|
|
7
|
+
Object.defineProperty(context, "keys", {
|
|
8
|
+
value: () => paths
|
|
9
|
+
});
|
|
10
|
+
return context;
|
|
11
|
+
}
|
|
12
|
+
(0, import_vitest.describe)(import_getTypedRoutesDeclarationFile.getTypedRoutesDeclarationFile, () => {
|
|
13
|
+
(0, import_vitest.it)("does not emit trailing whitespace for multi-line route unions", () => {
|
|
14
|
+
const declaration = (0, import_getTypedRoutesDeclarationFile.getTypedRoutesDeclarationFile)(createRouteContext(["./index+ssg.tsx", "./about+ssg.tsx", "./[slug]+ssg.tsx"]));
|
|
15
|
+
(0, import_vitest.expect)(declaration).toContain(" StaticRoutes:\n | `/`");
|
|
16
|
+
(0, import_vitest.expect)(declaration).not.toMatch(/[ \t]+$/m);
|
|
17
|
+
});
|
|
18
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var import_vitest = require("vitest");
|
|
4
|
+
var import_getTypedRoutesDeclarationFile = require("./getTypedRoutesDeclarationFile.native.js");
|
|
5
|
+
function createRouteContext(paths) {
|
|
6
|
+
var context = function () {
|
|
7
|
+
return {
|
|
8
|
+
default() {}
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(context, "keys", {
|
|
12
|
+
value: function () {
|
|
13
|
+
return paths;
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
return context;
|
|
17
|
+
}
|
|
18
|
+
(0, import_vitest.describe)(import_getTypedRoutesDeclarationFile.getTypedRoutesDeclarationFile, function () {
|
|
19
|
+
(0, import_vitest.it)("does not emit trailing whitespace for multi-line route unions", function () {
|
|
20
|
+
var declaration = (0, import_getTypedRoutesDeclarationFile.getTypedRoutesDeclarationFile)(createRouteContext(["./index+ssg.tsx", "./about+ssg.tsx", "./[slug]+ssg.tsx"]));
|
|
21
|
+
(0, import_vitest.expect)(declaration).toContain(" StaticRoutes:\n | `/`");
|
|
22
|
+
(0, import_vitest.expect)(declaration).not.toMatch(/[ \t]+$/m);
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
//# sourceMappingURL=getTypedRoutesDeclarationFile.test.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["import_vitest","require","import_getTypedRoutesDeclarationFile","createRouteContext","paths","context","default","Object","defineProperty","value","describe","getTypedRoutesDeclarationFile","it"],"sources":["../../../src/typed-routes/getTypedRoutesDeclarationFile.test.ts"],"sourcesContent":[null],"mappings":"AAAA;;AAEA,IAAAA,aAAA,GAAAC,OAAA;AAEA,IAAAC,oCAA6C,GAAAD,OAAA;AAC3C,SAAME,kBAAkBA,CAAEC,KAAA;EAAW,IAAEC,OAAA,YAAAA,CAAA;IACvC,OAAO;MACLC,OAAOA,CAAA,GACR;IACD;EACF;EAAAC,MAEA,CAAAC,cAAA,CAAAH,OAAS;IACPI,KAAA,WAAAA,CAAA;MACE,OAAML,KAAA;IAAc;EAC2D,EAC/E;EAEA,OAAAC,OAAA;AACA;AAA0C,EAC5C,EAACL,aAAA,CAAAU,QAAA,EAAAR,oCAAA,CAAAS,6BAAA;EACF,IAAAX,aAAA,CAAAY,EAAA","ignoreList":[]}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: true
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
16
|
+
get: () => from[key],
|
|
17
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
23
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
24
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
25
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
26
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
27
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
28
|
+
value: mod,
|
|
29
|
+
enumerable: true
|
|
30
|
+
}) : target, mod));
|
|
31
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
32
|
+
value: true
|
|
33
|
+
}), mod);
|
|
34
|
+
var routeFileWatch_exports = {};
|
|
35
|
+
__export(routeFileWatch_exports, {
|
|
36
|
+
isPathInsideDirectory: () => isPathInsideDirectory,
|
|
37
|
+
isRouteFilePath: () => isRouteFilePath,
|
|
38
|
+
isRouteFileWatchEvent: () => isRouteFileWatchEvent
|
|
39
|
+
});
|
|
40
|
+
module.exports = __toCommonJS(routeFileWatch_exports);
|
|
41
|
+
var import_node_path = __toESM(require("node:path"), 1);
|
|
42
|
+
const routeFileExtensionRe = /\.[jt]sx?$/;
|
|
43
|
+
function isRouteFilePath(filePath) {
|
|
44
|
+
return routeFileExtensionRe.test(filePath) && !filePath.endsWith(".d.ts");
|
|
45
|
+
}
|
|
46
|
+
function isPathInsideDirectory(filePath, directory) {
|
|
47
|
+
const relativePath = import_node_path.default.relative(import_node_path.default.resolve(directory), import_node_path.default.resolve(filePath));
|
|
48
|
+
return relativePath !== "" && !relativePath.startsWith("..") && !import_node_path.default.isAbsolute(relativePath);
|
|
49
|
+
}
|
|
50
|
+
function isRouteFileWatchEvent({
|
|
51
|
+
event,
|
|
52
|
+
filePath,
|
|
53
|
+
routerRoot,
|
|
54
|
+
includeChangeEvents = false
|
|
55
|
+
}) {
|
|
56
|
+
const isRouteFileEvent = event === "add" || event === "delete" || event === "unlink" || includeChangeEvents && event === "change";
|
|
57
|
+
return isRouteFileEvent && isPathInsideDirectory(filePath, routerRoot) && isRouteFilePath(filePath);
|
|
58
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all) __defProp(target, name, {
|
|
11
|
+
get: all[name],
|
|
12
|
+
enumerable: true
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
var __copyProps = (to, from, except, desc) => {
|
|
16
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
17
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
18
|
+
get: () => from[key],
|
|
19
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
return to;
|
|
23
|
+
};
|
|
24
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
25
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
26
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
27
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
28
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
29
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
30
|
+
value: mod,
|
|
31
|
+
enumerable: true
|
|
32
|
+
}) : target, mod));
|
|
33
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
34
|
+
value: true
|
|
35
|
+
}), mod);
|
|
36
|
+
var routeFileWatch_exports = {};
|
|
37
|
+
__export(routeFileWatch_exports, {
|
|
38
|
+
isPathInsideDirectory: () => isPathInsideDirectory,
|
|
39
|
+
isRouteFilePath: () => isRouteFilePath,
|
|
40
|
+
isRouteFileWatchEvent: () => isRouteFileWatchEvent
|
|
41
|
+
});
|
|
42
|
+
module.exports = __toCommonJS(routeFileWatch_exports);
|
|
43
|
+
var import_path = __toESM(require("path"), 1);
|
|
44
|
+
var routeFileExtensionRe = /\.[jt]sx?$/;
|
|
45
|
+
function isRouteFilePath(filePath) {
|
|
46
|
+
return routeFileExtensionRe.test(filePath) && !filePath.endsWith(".d.ts");
|
|
47
|
+
}
|
|
48
|
+
function isPathInsideDirectory(filePath, directory) {
|
|
49
|
+
var relativePath = import_path.default.relative(import_path.default.resolve(directory), import_path.default.resolve(filePath));
|
|
50
|
+
return relativePath !== "" && !relativePath.startsWith("..") && !import_path.default.isAbsolute(relativePath);
|
|
51
|
+
}
|
|
52
|
+
function isRouteFileWatchEvent(param) {
|
|
53
|
+
var {
|
|
54
|
+
event,
|
|
55
|
+
filePath,
|
|
56
|
+
routerRoot,
|
|
57
|
+
includeChangeEvents = false
|
|
58
|
+
} = param;
|
|
59
|
+
var isRouteFileEvent = event === "add" || event === "delete" || event === "unlink" || includeChangeEvents && event === "change";
|
|
60
|
+
return isRouteFileEvent && isPathInsideDirectory(filePath, routerRoot) && isRouteFilePath(filePath);
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=routeFileWatch.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","routeFileWatch_exports","__export","isPathInsideDirectory","isRouteFilePath","isRouteFileWatchEvent","module","exports","import_path","__toESM","require","routeFileExtensionRe","filePath","test","endsWith","directory","relativePath","default","relative","resolve","startsWith","isAbsolute","param","event","routerRoot","includeChangeEvents","isRouteFileEvent"],"sources":["../../../src/utils/routeFileWatch.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,sBAAA;AAAAC,QAAA,CAAAD,sBAAA;EAAAE,qBAAA,EAAAA,CAAA,KAAAA,qBAAA;EAAAC,eAAA,EAAAA,CAAA,KAAAA,eAAA;EAAAC,qBAAA,EAAAA,CAAA,KAAAA;AAAA;AAAAC,MAAA,CAAAC,OAAA,GAAAX,YAAiB,CAAAK,sBAAA;AAEjB,IAAAO,WAAM,GAAAC,OAAA,CAAAC,OAAuB;AAEtB,IAAAC,oBAAS,GAAgB,YAAkB;AAChD,SAAOP,gBAAAQ,QAAqB,EAAK;EACnC,OAAAD,oBAAA,CAAAE,IAAA,CAAAD,QAAA,MAAAA,QAAA,CAAAE,QAAA;AAEO;AACL,SAAMX,qBAAeA,CAAAS,QAAA,EAAAG,SAAK;EAC1B,IAAAC,YACE,GAAAR,WACA,CAACS,OAAA,CAAAC,QAAa,CAAAV,WAAe,CAAAS,OAC5B,CAAAE,OAAA,CAAAJ,SAAA,GAAAP,WAAK,CAAAS,OAAW,CAAAE,OAAY,CAAAP,QAAA;EAEjC,OAAAI,YAAA,YAAAA,YAAA,CAAAI,UAAA,WAAAZ,WAAA,CAAAS,OAAA,CAAAI,UAAA,CAAAL,YAAA;AAEO;AAA+B,SACpCX,sBAAAiB,KAAA;EACA;IAAAC,KAAA;IAAAX,QAAA;IAAAY,UAAA;IAAAC,mBAAA;EAAA,IAAAH,KAAA;EACA,IAAAI,gBAAA,GAAAH,KAAA,cAAAA,KAAA,iBAAAA,KAAA,iBAAAE,mBAAA,IAAAF,KAAA;EACA,OAAAG,gBAAsB,IAAAvB,qBAAA,CAAAS,QAAA,EAAAY,UAAA,KAAApB,eAAA,CAAAQ,QAAA;AACxB","ignoreList":[]}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __copyProps = (to, from, except, desc) => {
|
|
8
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
9
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
10
|
+
get: () => from[key],
|
|
11
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
return to;
|
|
15
|
+
};
|
|
16
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
17
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
18
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
19
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
20
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
22
|
+
value: mod,
|
|
23
|
+
enumerable: true
|
|
24
|
+
}) : target, mod));
|
|
25
|
+
var import_node_path = __toESM(require("node:path"), 1);
|
|
26
|
+
var import_vitest = require("vitest");
|
|
27
|
+
var import_routeFileWatch = require("./routeFileWatch.cjs");
|
|
28
|
+
(0, import_vitest.describe)(import_routeFileWatch.isRouteFilePath, () => {
|
|
29
|
+
(0, import_vitest.it)("matches route source files", () => {
|
|
30
|
+
(0, import_vitest.expect)((0, import_routeFileWatch.isRouteFilePath)("/project/app/index.ts")).toBe(true);
|
|
31
|
+
(0, import_vitest.expect)((0, import_routeFileWatch.isRouteFilePath)("/project/app/index.tsx")).toBe(true);
|
|
32
|
+
(0, import_vitest.expect)((0, import_routeFileWatch.isRouteFilePath)("/project/app/index.js")).toBe(true);
|
|
33
|
+
(0, import_vitest.expect)((0, import_routeFileWatch.isRouteFilePath)("/project/app/index.jsx")).toBe(true);
|
|
34
|
+
});
|
|
35
|
+
(0, import_vitest.it)("ignores non-route files", () => {
|
|
36
|
+
(0, import_vitest.expect)((0, import_routeFileWatch.isRouteFilePath)("/project/app/tamagui.generated.css")).toBe(false);
|
|
37
|
+
(0, import_vitest.expect)((0, import_routeFileWatch.isRouteFilePath)("/project/app/routes.d.ts")).toBe(false);
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
(0, import_vitest.describe)(import_routeFileWatch.isPathInsideDirectory, () => {
|
|
41
|
+
(0, import_vitest.it)("only matches real descendants of the router root", () => {
|
|
42
|
+
const routerRoot = import_node_path.default.resolve("/project/app");
|
|
43
|
+
(0, import_vitest.expect)((0, import_routeFileWatch.isPathInsideDirectory)("/project/app/index.tsx", routerRoot)).toBe(true);
|
|
44
|
+
(0, import_vitest.expect)((0, import_routeFileWatch.isPathInsideDirectory)("/project/app-copy/index.tsx", routerRoot)).toBe(false);
|
|
45
|
+
(0, import_vitest.expect)((0, import_routeFileWatch.isPathInsideDirectory)("/project/app", routerRoot)).toBe(false);
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
(0, import_vitest.describe)(import_routeFileWatch.isRouteFileWatchEvent, () => {
|
|
49
|
+
const routerRoot = import_node_path.default.resolve("/project/app");
|
|
50
|
+
(0, import_vitest.it)("matches route file add and delete events", () => {
|
|
51
|
+
(0, import_vitest.expect)((0, import_routeFileWatch.isRouteFileWatchEvent)({
|
|
52
|
+
event: "add",
|
|
53
|
+
filePath: "/project/app/index.tsx",
|
|
54
|
+
routerRoot
|
|
55
|
+
})).toBe(true);
|
|
56
|
+
(0, import_vitest.expect)((0, import_routeFileWatch.isRouteFileWatchEvent)({
|
|
57
|
+
event: "delete",
|
|
58
|
+
filePath: "/project/app/nested/page.jsx",
|
|
59
|
+
routerRoot
|
|
60
|
+
})).toBe(true);
|
|
61
|
+
(0, import_vitest.expect)((0, import_routeFileWatch.isRouteFileWatchEvent)({
|
|
62
|
+
event: "unlink",
|
|
63
|
+
filePath: "/project/app/nested/page.jsx",
|
|
64
|
+
routerRoot
|
|
65
|
+
})).toBe(true);
|
|
66
|
+
});
|
|
67
|
+
(0, import_vitest.it)("ignores non-route file add and delete events", () => {
|
|
68
|
+
(0, import_vitest.expect)((0, import_routeFileWatch.isRouteFileWatchEvent)({
|
|
69
|
+
event: "add",
|
|
70
|
+
filePath: "/project/app/tamagui.generated.css",
|
|
71
|
+
routerRoot
|
|
72
|
+
})).toBe(false);
|
|
73
|
+
(0, import_vitest.expect)((0, import_routeFileWatch.isRouteFileWatchEvent)({
|
|
74
|
+
event: "delete",
|
|
75
|
+
filePath: "/project/app/routes.d.ts",
|
|
76
|
+
routerRoot
|
|
77
|
+
})).toBe(false);
|
|
78
|
+
});
|
|
79
|
+
(0, import_vitest.it)("only matches change events when requested", () => {
|
|
80
|
+
(0, import_vitest.expect)((0, import_routeFileWatch.isRouteFileWatchEvent)({
|
|
81
|
+
event: "change",
|
|
82
|
+
filePath: "/project/app/index.tsx",
|
|
83
|
+
routerRoot
|
|
84
|
+
})).toBe(false);
|
|
85
|
+
(0, import_vitest.expect)((0, import_routeFileWatch.isRouteFileWatchEvent)({
|
|
86
|
+
event: "change",
|
|
87
|
+
filePath: "/project/app/index.tsx",
|
|
88
|
+
routerRoot,
|
|
89
|
+
includeChangeEvents: true
|
|
90
|
+
})).toBe(true);
|
|
91
|
+
});
|
|
92
|
+
});
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
12
|
+
get: () => from[key],
|
|
13
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
20
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
21
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
22
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
23
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
24
|
+
value: mod,
|
|
25
|
+
enumerable: true
|
|
26
|
+
}) : target, mod));
|
|
27
|
+
var import_path = __toESM(require("path"), 1);
|
|
28
|
+
var import_vitest = require("vitest");
|
|
29
|
+
var import_routeFileWatch = require("./routeFileWatch.native.js");
|
|
30
|
+
(0, import_vitest.describe)(import_routeFileWatch.isRouteFilePath, function () {
|
|
31
|
+
(0, import_vitest.it)("matches route source files", function () {
|
|
32
|
+
(0, import_vitest.expect)((0, import_routeFileWatch.isRouteFilePath)("/project/app/index.ts")).toBe(true);
|
|
33
|
+
(0, import_vitest.expect)((0, import_routeFileWatch.isRouteFilePath)("/project/app/index.tsx")).toBe(true);
|
|
34
|
+
(0, import_vitest.expect)((0, import_routeFileWatch.isRouteFilePath)("/project/app/index.js")).toBe(true);
|
|
35
|
+
(0, import_vitest.expect)((0, import_routeFileWatch.isRouteFilePath)("/project/app/index.jsx")).toBe(true);
|
|
36
|
+
});
|
|
37
|
+
(0, import_vitest.it)("ignores non-route files", function () {
|
|
38
|
+
(0, import_vitest.expect)((0, import_routeFileWatch.isRouteFilePath)("/project/app/tamagui.generated.css")).toBe(false);
|
|
39
|
+
(0, import_vitest.expect)((0, import_routeFileWatch.isRouteFilePath)("/project/app/routes.d.ts")).toBe(false);
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
(0, import_vitest.describe)(import_routeFileWatch.isPathInsideDirectory, function () {
|
|
43
|
+
(0, import_vitest.it)("only matches real descendants of the router root", function () {
|
|
44
|
+
var routerRoot = import_path.default.resolve("/project/app");
|
|
45
|
+
(0, import_vitest.expect)((0, import_routeFileWatch.isPathInsideDirectory)("/project/app/index.tsx", routerRoot)).toBe(true);
|
|
46
|
+
(0, import_vitest.expect)((0, import_routeFileWatch.isPathInsideDirectory)("/project/app-copy/index.tsx", routerRoot)).toBe(false);
|
|
47
|
+
(0, import_vitest.expect)((0, import_routeFileWatch.isPathInsideDirectory)("/project/app", routerRoot)).toBe(false);
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
(0, import_vitest.describe)(import_routeFileWatch.isRouteFileWatchEvent, function () {
|
|
51
|
+
var routerRoot = import_path.default.resolve("/project/app");
|
|
52
|
+
(0, import_vitest.it)("matches route file add and delete events", function () {
|
|
53
|
+
(0, import_vitest.expect)((0, import_routeFileWatch.isRouteFileWatchEvent)({
|
|
54
|
+
event: "add",
|
|
55
|
+
filePath: "/project/app/index.tsx",
|
|
56
|
+
routerRoot
|
|
57
|
+
})).toBe(true);
|
|
58
|
+
(0, import_vitest.expect)((0, import_routeFileWatch.isRouteFileWatchEvent)({
|
|
59
|
+
event: "delete",
|
|
60
|
+
filePath: "/project/app/nested/page.jsx",
|
|
61
|
+
routerRoot
|
|
62
|
+
})).toBe(true);
|
|
63
|
+
(0, import_vitest.expect)((0, import_routeFileWatch.isRouteFileWatchEvent)({
|
|
64
|
+
event: "unlink",
|
|
65
|
+
filePath: "/project/app/nested/page.jsx",
|
|
66
|
+
routerRoot
|
|
67
|
+
})).toBe(true);
|
|
68
|
+
});
|
|
69
|
+
(0, import_vitest.it)("ignores non-route file add and delete events", function () {
|
|
70
|
+
(0, import_vitest.expect)((0, import_routeFileWatch.isRouteFileWatchEvent)({
|
|
71
|
+
event: "add",
|
|
72
|
+
filePath: "/project/app/tamagui.generated.css",
|
|
73
|
+
routerRoot
|
|
74
|
+
})).toBe(false);
|
|
75
|
+
(0, import_vitest.expect)((0, import_routeFileWatch.isRouteFileWatchEvent)({
|
|
76
|
+
event: "delete",
|
|
77
|
+
filePath: "/project/app/routes.d.ts",
|
|
78
|
+
routerRoot
|
|
79
|
+
})).toBe(false);
|
|
80
|
+
});
|
|
81
|
+
(0, import_vitest.it)("only matches change events when requested", function () {
|
|
82
|
+
(0, import_vitest.expect)((0, import_routeFileWatch.isRouteFileWatchEvent)({
|
|
83
|
+
event: "change",
|
|
84
|
+
filePath: "/project/app/index.tsx",
|
|
85
|
+
routerRoot
|
|
86
|
+
})).toBe(false);
|
|
87
|
+
(0, import_vitest.expect)((0, import_routeFileWatch.isRouteFileWatchEvent)({
|
|
88
|
+
event: "change",
|
|
89
|
+
filePath: "/project/app/index.tsx",
|
|
90
|
+
routerRoot,
|
|
91
|
+
includeChangeEvents: true
|
|
92
|
+
})).toBe(true);
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
//# sourceMappingURL=routeFileWatch.test.native.js.map
|