one 1.17.3 → 1.17.5

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.
Files changed (94) hide show
  1. package/dist/cjs/metro-config/withOne.test.cjs +8 -0
  2. package/dist/cjs/metro-config/withOne.test.native.js +8 -0
  3. package/dist/cjs/metro-config/withOne.test.native.js.map +1 -1
  4. package/dist/cjs/typed-routes/generateRouteTypes.cjs +12 -2
  5. package/dist/cjs/typed-routes/generateRouteTypes.native.js +12 -2
  6. package/dist/cjs/typed-routes/generateRouteTypes.native.js.map +1 -1
  7. package/dist/cjs/typed-routes/generateRouteTypes.test.cjs +58 -0
  8. package/dist/cjs/typed-routes/generateRouteTypes.test.native.js +61 -0
  9. package/dist/cjs/typed-routes/generateRouteTypes.test.native.js.map +1 -0
  10. package/dist/cjs/typed-routes/getTypedRoutesDeclarationFile.cjs +5 -5
  11. package/dist/cjs/typed-routes/getTypedRoutesDeclarationFile.native.js +5 -5
  12. package/dist/cjs/typed-routes/getTypedRoutesDeclarationFile.native.js.map +1 -1
  13. package/dist/cjs/typed-routes/getTypedRoutesDeclarationFile.test.cjs +18 -0
  14. package/dist/cjs/typed-routes/getTypedRoutesDeclarationFile.test.native.js +25 -0
  15. package/dist/cjs/typed-routes/getTypedRoutesDeclarationFile.test.native.js.map +1 -0
  16. package/dist/cjs/utils/routeFileWatch.cjs +58 -0
  17. package/dist/cjs/utils/routeFileWatch.native.js +62 -0
  18. package/dist/cjs/utils/routeFileWatch.native.js.map +1 -0
  19. package/dist/cjs/utils/routeFileWatch.test.cjs +92 -0
  20. package/dist/cjs/utils/routeFileWatch.test.native.js +95 -0
  21. package/dist/cjs/utils/routeFileWatch.test.native.js.map +1 -0
  22. package/dist/cjs/vite/plugins/fileSystemRouterPlugin.cjs +16 -7
  23. package/dist/cjs/vite/plugins/fileSystemRouterPlugin.native.js +16 -7
  24. package/dist/cjs/vite/plugins/fileSystemRouterPlugin.native.js.map +1 -1
  25. package/dist/cjs/vite/plugins/fileSystemRouterPlugin.test.cjs +111 -0
  26. package/dist/cjs/vite/plugins/fileSystemRouterPlugin.test.native.js +116 -0
  27. package/dist/cjs/vite/plugins/fileSystemRouterPlugin.test.native.js.map +1 -0
  28. package/dist/cjs/vite/plugins/generateFileSystemRouteTypesPlugin.cjs +9 -9
  29. package/dist/cjs/vite/plugins/generateFileSystemRouteTypesPlugin.native.js +10 -10
  30. package/dist/cjs/vite/plugins/generateFileSystemRouteTypesPlugin.native.js.map +1 -1
  31. package/dist/esm/metro-config/withOne.test.mjs +8 -0
  32. package/dist/esm/metro-config/withOne.test.mjs.map +1 -1
  33. package/dist/esm/metro-config/withOne.test.native.js +8 -0
  34. package/dist/esm/metro-config/withOne.test.native.js.map +1 -1
  35. package/dist/esm/typed-routes/generateRouteTypes.mjs +13 -3
  36. package/dist/esm/typed-routes/generateRouteTypes.mjs.map +1 -1
  37. package/dist/esm/typed-routes/generateRouteTypes.native.js +13 -3
  38. package/dist/esm/typed-routes/generateRouteTypes.native.js.map +1 -1
  39. package/dist/esm/typed-routes/generateRouteTypes.test.mjs +35 -0
  40. package/dist/esm/typed-routes/generateRouteTypes.test.mjs.map +1 -0
  41. package/dist/esm/typed-routes/generateRouteTypes.test.native.js +35 -0
  42. package/dist/esm/typed-routes/generateRouteTypes.test.native.js.map +1 -0
  43. package/dist/esm/typed-routes/getTypedRoutesDeclarationFile.mjs +5 -5
  44. package/dist/esm/typed-routes/getTypedRoutesDeclarationFile.mjs.map +1 -1
  45. package/dist/esm/typed-routes/getTypedRoutesDeclarationFile.native.js +5 -5
  46. package/dist/esm/typed-routes/getTypedRoutesDeclarationFile.native.js.map +1 -1
  47. package/dist/esm/typed-routes/getTypedRoutesDeclarationFile.test.mjs +19 -0
  48. package/dist/esm/typed-routes/getTypedRoutesDeclarationFile.test.mjs.map +1 -0
  49. package/dist/esm/typed-routes/getTypedRoutesDeclarationFile.test.native.js +23 -0
  50. package/dist/esm/typed-routes/getTypedRoutesDeclarationFile.test.native.js.map +1 -0
  51. package/dist/esm/utils/routeFileWatch.mjs +20 -0
  52. package/dist/esm/utils/routeFileWatch.mjs.map +1 -0
  53. package/dist/esm/utils/routeFileWatch.native.js +21 -0
  54. package/dist/esm/utils/routeFileWatch.native.js.map +1 -0
  55. package/dist/esm/utils/routeFileWatch.test.mjs +69 -0
  56. package/dist/esm/utils/routeFileWatch.test.mjs.map +1 -0
  57. package/dist/esm/utils/routeFileWatch.test.native.js +69 -0
  58. package/dist/esm/utils/routeFileWatch.test.native.js.map +1 -0
  59. package/dist/esm/vite/plugins/fileSystemRouterPlugin.mjs +16 -7
  60. package/dist/esm/vite/plugins/fileSystemRouterPlugin.mjs.map +1 -1
  61. package/dist/esm/vite/plugins/fileSystemRouterPlugin.native.js +16 -7
  62. package/dist/esm/vite/plugins/fileSystemRouterPlugin.native.js.map +1 -1
  63. package/dist/esm/vite/plugins/fileSystemRouterPlugin.test.mjs +88 -0
  64. package/dist/esm/vite/plugins/fileSystemRouterPlugin.test.mjs.map +1 -0
  65. package/dist/esm/vite/plugins/fileSystemRouterPlugin.test.native.js +90 -0
  66. package/dist/esm/vite/plugins/fileSystemRouterPlugin.test.native.js.map +1 -0
  67. package/dist/esm/vite/plugins/generateFileSystemRouteTypesPlugin.mjs +9 -9
  68. package/dist/esm/vite/plugins/generateFileSystemRouteTypesPlugin.mjs.map +1 -1
  69. package/dist/esm/vite/plugins/generateFileSystemRouteTypesPlugin.native.js +10 -10
  70. package/dist/esm/vite/plugins/generateFileSystemRouteTypesPlugin.native.js.map +1 -1
  71. package/package.json +10 -10
  72. package/src/metro-config/withOne.test.ts +14 -0
  73. package/src/typed-routes/generateRouteTypes.test.ts +53 -0
  74. package/src/typed-routes/generateRouteTypes.ts +14 -3
  75. package/src/typed-routes/getTypedRoutesDeclarationFile.test.ts +22 -0
  76. package/src/typed-routes/getTypedRoutesDeclarationFile.ts +5 -5
  77. package/src/utils/routeFileWatch.test.ts +94 -0
  78. package/src/utils/routeFileWatch.ts +40 -0
  79. package/src/vite/plugins/fileSystemRouterPlugin.test.ts +106 -0
  80. package/src/vite/plugins/fileSystemRouterPlugin.tsx +21 -13
  81. package/src/vite/plugins/generateFileSystemRouteTypesPlugin.tsx +16 -17
  82. package/types/typed-routes/generateRouteTypes.d.ts.map +1 -1
  83. package/types/typed-routes/generateRouteTypes.test.d.ts +2 -0
  84. package/types/typed-routes/generateRouteTypes.test.d.ts.map +1 -0
  85. package/types/typed-routes/getTypedRoutesDeclarationFile.test.d.ts +2 -0
  86. package/types/typed-routes/getTypedRoutesDeclarationFile.test.d.ts.map +1 -0
  87. package/types/utils/routeFileWatch.d.ts +9 -0
  88. package/types/utils/routeFileWatch.d.ts.map +1 -0
  89. package/types/utils/routeFileWatch.test.d.ts +2 -0
  90. package/types/utils/routeFileWatch.test.d.ts.map +1 -0
  91. package/types/vite/plugins/fileSystemRouterPlugin.d.ts.map +1 -1
  92. package/types/vite/plugins/fileSystemRouterPlugin.test.d.ts +2 -0
  93. package/types/vite/plugins/fileSystemRouterPlugin.test.d.ts.map +1 -0
  94. package/types/vite/plugins/generateFileSystemRouteTypesPlugin.d.ts.map +1 -1
@@ -126,4 +126,12 @@ export default {
126
126
  (0, import_vitest.expect)(config.resolver.extraNodeModules["fixture-singleton"]).toBe(fixtureRoot);
127
127
  (0, import_vitest.expect)(config.watchFolders).toContain(import_node_path.default.join(fixtureRoot, "shared"));
128
128
  });
129
+ (0, import_vitest.it)("rewrites native default index bundle requests to the One entry", async () => {
130
+ const config = await (0, import_withOne.withOne)(projectRoot, {
131
+ loadViteConfig: false
132
+ });
133
+ const rewriteRequestUrl = config.server.rewriteRequestUrl;
134
+ (0, import_vitest.expect)(rewriteRequestUrl("/.expo/.virtual-metro-entry.bundle?platform=ios&dev=true")).toContain("/packages/one/metro-entry.bundle?platform=ios&dev=true");
135
+ (0, import_vitest.expect)(rewriteRequestUrl("/index.bundle?platform=ios&dev=true&hot=true&minify=false")).toContain("/packages/one/metro-entry.bundle?platform=ios&dev=true&hot=true&minify=false");
136
+ });
129
137
  });
@@ -152,5 +152,13 @@ export default {
152
152
  (0, import_vitest.expect)(config.resolver.extraNodeModules["fixture-singleton"]).toBe(fixtureRoot);
153
153
  (0, import_vitest.expect)(config.watchFolders).toContain(import_path.default.join(fixtureRoot, "shared"));
154
154
  });
155
+ (0, import_vitest.it)("rewrites native default index bundle requests to the One entry", async function () {
156
+ var config = await (0, import_withOne.withOne)(projectRoot, {
157
+ loadViteConfig: false
158
+ });
159
+ var rewriteRequestUrl = config.server.rewriteRequestUrl;
160
+ (0, import_vitest.expect)(rewriteRequestUrl("/.expo/.virtual-metro-entry.bundle?platform=ios&dev=true")).toContain("/packages/one/metro-entry.bundle?platform=ios&dev=true");
161
+ (0, import_vitest.expect)(rewriteRequestUrl("/index.bundle?platform=ios&dev=true&hot=true&minify=false")).toContain("/packages/one/metro-entry.bundle?platform=ios&dev=true&hot=true&minify=false");
162
+ });
155
163
  });
156
164
  //# sourceMappingURL=withOne.test.native.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["import_path","__toESM","require","import_fs","import_vitest","import_withOne","_type_of","obj","Symbol","constructor","projectRoot","default","resolve","__dirname","tmpDirs","createOneFixtureProject","workspaceRoot","tmpDir","mkdtempSync","join","push","writeFileSync","JSON","stringify","name","private","compilerOptions","paths","mkdirSync","afterAll","_iteratorNormalCompletion","_didIteratorError","_iteratorError","_iterator","iterator","_step","next","done","value","rmSync","recursive","force","err","return","describe","it","config","withOne","loadViteConfig","expect","toBeTruthy"],"sources":["../../../src/metro-config/withOne.test.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;gBAAA;AACA,IAAAA,WAAA,GAAAC,OAAe,CAAAC,OAAA;AACf,IAAAC,SAAA,GAAAF,OAA+C,CAAAC,OAAA;AAC/C,IAAAE,aAAA,GAAAF,OAAwB;AAExB,IAAAG,cAAM,GAAcH,OAAA;AACpB,SAAMI,QAAqBA,CAAAC,GAAA;EAE3B,uBAAS;;E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":3,"names":["import_path","__toESM","require","import_fs","import_vitest","import_withOne","_type_of","obj","Symbol","constructor","projectRoot","default","resolve","__dirname","tmpDirs","createOneFixtureProject","workspaceRoot","tmpDir","mkdtempSync","join","push","writeFileSync","JSON","stringify","name","private","compilerOptions","paths","mkdirSync","afterAll","_iteratorNormalCompletion","_didIteratorError","_iteratorError","_iterator","iterator","_step","next","done","value","rmSync","recursive","force","err","return","describe","it","config","withOne","loadViteConfig","expect","toBeTruthy","resolver","resolveRequest","toBe","transformer","babelTransformerPath","toMatch","exts","sourceExts","toContain"],"sources":["../../../src/metro-config/withOne.test.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;gBAAA;AACA,IAAAA,WAAA,GAAAC,OAAe,CAAAC,OAAA;AACf,IAAAC,SAAA,GAAAF,OAA+C,CAAAC,OAAA;AAC/C,IAAAE,aAAA,GAAAF,OAAwB;AAExB,IAAAG,cAAM,GAAcH,OAAA;AACpB,SAAMI,QAAqBA,CAAAC,GAAA;EAE3B,uBAAS;;EACP,OAAMA,GAAA,WAAAC,MAAgB,oBAAKD,GAAA,CAAAE,WAAQ,KAAWD,MAAA,WAAc,UAAAD,GAAA;AAC5D;AACA,IAAAG,WAAa,GAAAV,WAAM,CAAAW,OAAA,CAAAC,OAAA,CAAAC,SAAA;AAEnB,IAAAC,OAAA;AAAG,SACDC,uBAAKA,CAAA,EAAK;EAAsB,IAChCC,aAAe,GAAEhB,WAAM,CAAAW,OAAA,CAAAC,OAAgB,CAAAC,SAAe;EACxD,IAAAI,MAAA,GAAAd,SAAA,CAAAQ,OAAA,CAAAO,WAAA,CAAAlB,WAAA,CAAAW,OAAA,CAAAQ,IAAA,CAAAH,aAAA;EACAF,OAAA,CAAAM,IAAA,CAAAH,MAAA;EAAGd,SACD,CAAAQ,OAAA,CAAAU,aAAK,CAAKrB,WAAQ,CAAAW,OAAA,CAAAQ,IAAe,CAAAF,MAAA,mBAAAK,IAAA,CAAAC,SAAA;IACjCC,I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,EAAAE,SAAA;IACF,IAAAvD,aAAA,CAAA6C,MAAA,EAAAQ,IAAA,EAAAE,SAAA","ignoreList":[]}
@@ -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
- await import_fs_extra.default.ensureDir(outDir);
65
- await (0, import_promises.writeFile)(outFile, declarations);
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
- await import_fs_extra.default.ensureDir(outDir);
67
- await (0, import_promises.writeFile)(outFile, declarations);
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,YAA0B,CAAAK,0BAAA;AAC1B,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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Q,IAAY,KACpBF,SAAQ,CAAAG,QAAU,CAAE;UACnB;QAGJ;QACE,IAAAC,QAAA,KAAiB,EAAA/C,WAAM,CAAAgD,IAAA,EAAAC,OAAA,CAAAC,GAAA,IAAAxC,UAAA,EAAAiC,SAAA;QACzB,IAAAQ,SAAA,GAAAR,SAAA,CAAAnB,OAAA,cAAAA,OAAA,iBAAAA,OAAA,iBAAAA,OAAA;QAGA,IAAK4B,cAAe,OAAAhD,eAAe,CAAAiD,yBAAA,EAAAF,SAAA,EAAA3B,OAAA;QACjC,KAAA4B,cAAA,CAAAP,UAAA;UACFO,cAAA,SAAAA,cAAA;QAEA;QACF,KAAAA,cAAA,CAAAR,QAAA;UACF;QACF","ignoreList":[]}
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,G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AAAD,KAAA;IACF;EAEA;EACE,IAAAF,mBAAM,KAAAJ,YAAQ,EAAU;IACxB,MAAA1B,eAAM,CAAAe,OAAA,CAAAmB,SAAU,CAAAN,MAAS;IAC3B,UAAA/B,eAAA,CAAAsC,SAAA,EAAA3B,OAAA,EAAAkB,YAAA;EAGA;EACE,IAAAf,eAAyB;IAGzB,IAAAyB,IAAA,GAAWzB,eAAa,WAAY;IAElC,IAAA0B,yBACqB,OAAS;MAAAC,iBAClB,GAAS;MAAMC,cACf;IAGV;MACF,SAAAC,SAAA,GAAA5B,UAAA,CAAA6B,MAAA,CAAAC,QAAA,KAAAC,KAAA,IAAAN,yBAAA,IAAAM,KAAA,GAAAH,SAAA,CAAAI,IAAA,IAAAC,IAAA,GAAAR,yBAAA;QAIA,IAAMS,SAAA,GAAAH,KAAW,CAAApD,KAAA;QACjB,IAAMuD,SAAA,CAAAC,QAAY,UACf,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: ${setToUnionType(staticRoutes)}
53
- DynamicRoutes: ${setToUnionType(dynamicRoutes)}
54
- DynamicRouteTemplate: ${setToUnionType(dynamicRouteContextKeys)}
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 `\`${sorted[0]}\``;
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: ${setToUnionType(staticRoutes)}
56
- DynamicRoutes: ${setToUnionType(dynamicRoutes)}
57
- DynamicRouteTemplate: ${setToUnionType(dynamicRouteContextKeys)}
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 `\`${sorted[0]}\``;
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;AAQyC,sBAAAC,cAC3B,CAAAX,YAAe;AAAc,uBAAAW,cACtB,CAAAT,aAAe;AAAwB,8BAAAS,cAAA,CAAAR,uBAAA;AAAA;AAEmB,QAAAM,SAAA,kBAAAG,qBAAA,CAAAT,uBAAA;AAAA;AAAA;AAAA;AAMlF,EAAAM,SAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASN,EACE,KAAK;AACP,EAAAI,IAAA;AAMA;AACE,SAAID,qBAAwBA,CAAAT,uBAAY;EACtC,IAAAA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AA;QACFe,uBAAA,CAAAsD,GAAA,CAAAD,IAAA;QAMMtD,aAAA,CAAAuD,GAAqB;QACjB;QACF,GAAAD,IAAS,CAACE,UAAQ,CAAA7D,SAAK,eAAA6D,UAAA,CAAA5D,IAAA,sCACzB;MAEJ;IACF,SAAAoD,GAAA;MAEAV,iBAAS,OAAqB;MAC5BC,cAAe,GAAAS,GACZ;IAEH,UAAM;MAEN;QACM,KAAAX,yBAAwB,IAAQG,SAAA,CAAAS,MAAA;UAClCT,SAAa,CAAAS,MAAK;QAClB;MACF;QAEA,IAAMX,iBAAe;UACf,MAAAC,cAAe;QACrB;MACA;IACF;EAEA;IACA,IAAAkB,0BAAO;MAAAC,kBAAA;MAAAC,eAAA;IACT","ignoreList":[]}
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;E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AAX,yBAAwB,IAAQG,SAAA,CAAAS,MAAA;UAClCT,SAAa,CAAAS,MAAK;QAClB;MACF;QAEA,IAAMX,iBAAe;UACf,MAAAC,cAAe;QACrB;MACA;IACF;EAEA;IACA,IAAAkB,0BAAO;MAAAC,kBAAA;MAAAC,eAAA;IACT","ignoreList":[]}
@@ -0,0 +1,18 @@
1
+ var import_vitest = require("vitest");
2
+ var import_getTypedRoutesDeclarationFile = 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
+ });