@intlayer/engine 9.5.10 → 9.5.11

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 (188) hide show
  1. package/dist/cjs/docReview/alignBlocks.cjs +53 -36
  2. package/dist/cjs/docReview/alignBlocks.cjs.map +1 -1
  3. package/dist/cjs/docReview/rebuildDocument.cjs +3 -1
  4. package/dist/cjs/docReview/rebuildDocument.cjs.map +1 -1
  5. package/dist/cjs/docReview/segmentDocument.cjs +8 -5
  6. package/dist/cjs/docReview/segmentDocument.cjs.map +1 -1
  7. package/dist/cjs/init/frameworkSetup/nextAppRouter/transforms.cjs +4 -1
  8. package/dist/cjs/init/frameworkSetup/nextAppRouter/transforms.cjs.map +1 -1
  9. package/dist/cjs/installMCP/installMCP.cjs +1 -1
  10. package/dist/cjs/installMCP/installMCP.cjs.map +1 -1
  11. package/dist/cjs/loadDictionaries/loadLocalDictionaries.cjs +3 -1
  12. package/dist/cjs/loadDictionaries/loadLocalDictionaries.cjs.map +1 -1
  13. package/dist/cjs/loadDictionaries/loadRemoteDictionaries.cjs +1 -1
  14. package/dist/cjs/loadDictionaries/loadRemoteDictionaries.cjs.map +1 -1
  15. package/dist/cjs/loadDictionaries/log.cjs +1 -1
  16. package/dist/cjs/loadDictionaries/log.cjs.map +1 -1
  17. package/dist/cjs/loadDictionaries/logTypeScriptErrors.cjs +19 -12
  18. package/dist/cjs/loadDictionaries/logTypeScriptErrors.cjs.map +1 -1
  19. package/dist/cjs/scan/analyzeBundleContent.cjs +26 -12
  20. package/dist/cjs/scan/analyzeBundleContent.cjs.map +1 -1
  21. package/dist/cjs/scan/calculateScore.cjs +4 -1
  22. package/dist/cjs/scan/calculateScore.cjs.map +1 -1
  23. package/dist/cjs/scan/checks.cjs +394 -221
  24. package/dist/cjs/scan/checks.cjs.map +1 -1
  25. package/dist/cjs/scan/detection/checkDetails.cjs +56 -0
  26. package/dist/cjs/scan/detection/checkDetails.cjs.map +1 -0
  27. package/dist/cjs/scan/detection/classifyInternalLinks.cjs +47 -0
  28. package/dist/cjs/scan/detection/classifyInternalLinks.cjs.map +1 -0
  29. package/dist/cjs/scan/detection/detectRoutingStrategy.cjs +143 -0
  30. package/dist/cjs/scan/detection/detectRoutingStrategy.cjs.map +1 -0
  31. package/dist/cjs/scan/detection/detectTechnologies.cjs +89 -0
  32. package/dist/cjs/scan/detection/detectTechnologies.cjs.map +1 -0
  33. package/dist/cjs/scan/detection/index.cjs +36 -0
  34. package/dist/cjs/scan/detection/localeCode.cjs +118 -0
  35. package/dist/cjs/scan/detection/localeCode.cjs.map +1 -0
  36. package/dist/cjs/scan/detection/localizedPages.cjs +48 -0
  37. package/dist/cjs/scan/detection/localizedPages.cjs.map +1 -0
  38. package/dist/cjs/scan/detection/technologySignatures.cjs +564 -0
  39. package/dist/cjs/scan/detection/technologySignatures.cjs.map +1 -0
  40. package/dist/cjs/scan/detection/url.cjs +53 -0
  41. package/dist/cjs/scan/detection/url.cjs.map +1 -0
  42. package/dist/cjs/scan/fetchText.cjs +56 -0
  43. package/dist/cjs/scan/fetchText.cjs.map +1 -0
  44. package/dist/cjs/scan/index.cjs +59 -3
  45. package/dist/cjs/scan/parseHtml.cjs +55 -10
  46. package/dist/cjs/scan/parseHtml.cjs.map +1 -1
  47. package/dist/cjs/scan/robots.cjs +65 -0
  48. package/dist/cjs/scan/robots.cjs.map +1 -0
  49. package/dist/cjs/scan/runScanChecks.cjs +89 -0
  50. package/dist/cjs/scan/runScanChecks.cjs.map +1 -0
  51. package/dist/cjs/scan/scanWebsite.cjs +58 -52
  52. package/dist/cjs/scan/scanWebsite.cjs.map +1 -1
  53. package/dist/cjs/scan/sitemap.cjs +109 -0
  54. package/dist/cjs/scan/sitemap.cjs.map +1 -0
  55. package/dist/cjs/utils/chunkJSON.cjs +24 -9
  56. package/dist/cjs/utils/chunkJSON.cjs.map +1 -1
  57. package/dist/cjs/utils/getChunk.cjs +2 -2
  58. package/dist/cjs/utils/getChunk.cjs.map +1 -1
  59. package/dist/cjs/utils/runParallel/index.cjs +1 -1
  60. package/dist/cjs/utils/runParallel/index.cjs.map +1 -1
  61. package/dist/cjs/utils/runParallel/pidTree.cjs +23 -11
  62. package/dist/cjs/utils/runParallel/pidTree.cjs.map +1 -1
  63. package/dist/cjs/utils/runParallel/ps.cjs +8 -3
  64. package/dist/cjs/utils/runParallel/ps.cjs.map +1 -1
  65. package/dist/cjs/utils/runParallel/runTask.cjs +2 -1
  66. package/dist/cjs/utils/runParallel/runTask.cjs.map +1 -1
  67. package/dist/cjs/utils/runParallel/wmic.cjs +8 -3
  68. package/dist/cjs/utils/runParallel/wmic.cjs.map +1 -1
  69. package/dist/cjs/writeContentDeclaration/detectExportedComponentName.cjs +7 -4
  70. package/dist/cjs/writeContentDeclaration/detectExportedComponentName.cjs.map +1 -1
  71. package/dist/cjs/writeContentDeclaration/writeMarkdownFile.cjs +2 -2
  72. package/dist/cjs/writeContentDeclaration/writeMarkdownFile.cjs.map +1 -1
  73. package/dist/esm/docReview/alignBlocks.mjs +53 -36
  74. package/dist/esm/docReview/alignBlocks.mjs.map +1 -1
  75. package/dist/esm/docReview/rebuildDocument.mjs +3 -1
  76. package/dist/esm/docReview/rebuildDocument.mjs.map +1 -1
  77. package/dist/esm/docReview/segmentDocument.mjs +8 -5
  78. package/dist/esm/docReview/segmentDocument.mjs.map +1 -1
  79. package/dist/esm/init/frameworkSetup/nextAppRouter/transforms.mjs +4 -1
  80. package/dist/esm/init/frameworkSetup/nextAppRouter/transforms.mjs.map +1 -1
  81. package/dist/esm/installMCP/installMCP.mjs +1 -1
  82. package/dist/esm/installMCP/installMCP.mjs.map +1 -1
  83. package/dist/esm/loadDictionaries/loadLocalDictionaries.mjs +3 -1
  84. package/dist/esm/loadDictionaries/loadLocalDictionaries.mjs.map +1 -1
  85. package/dist/esm/loadDictionaries/loadRemoteDictionaries.mjs +1 -1
  86. package/dist/esm/loadDictionaries/loadRemoteDictionaries.mjs.map +1 -1
  87. package/dist/esm/loadDictionaries/log.mjs +1 -1
  88. package/dist/esm/loadDictionaries/log.mjs.map +1 -1
  89. package/dist/esm/loadDictionaries/logTypeScriptErrors.mjs +19 -12
  90. package/dist/esm/loadDictionaries/logTypeScriptErrors.mjs.map +1 -1
  91. package/dist/esm/scan/analyzeBundleContent.mjs +26 -12
  92. package/dist/esm/scan/analyzeBundleContent.mjs.map +1 -1
  93. package/dist/esm/scan/calculateScore.mjs +4 -1
  94. package/dist/esm/scan/calculateScore.mjs.map +1 -1
  95. package/dist/esm/scan/checks.mjs +387 -220
  96. package/dist/esm/scan/checks.mjs.map +1 -1
  97. package/dist/esm/scan/detection/checkDetails.mjs +54 -0
  98. package/dist/esm/scan/detection/checkDetails.mjs.map +1 -0
  99. package/dist/esm/scan/detection/classifyInternalLinks.mjs +46 -0
  100. package/dist/esm/scan/detection/classifyInternalLinks.mjs.map +1 -0
  101. package/dist/esm/scan/detection/detectRoutingStrategy.mjs +141 -0
  102. package/dist/esm/scan/detection/detectRoutingStrategy.mjs.map +1 -0
  103. package/dist/esm/scan/detection/detectTechnologies.mjs +87 -0
  104. package/dist/esm/scan/detection/detectTechnologies.mjs.map +1 -0
  105. package/dist/esm/scan/detection/index.mjs +10 -0
  106. package/dist/esm/scan/detection/localeCode.mjs +108 -0
  107. package/dist/esm/scan/detection/localeCode.mjs.map +1 -0
  108. package/dist/esm/scan/detection/localizedPages.mjs +46 -0
  109. package/dist/esm/scan/detection/localizedPages.mjs.map +1 -0
  110. package/dist/esm/scan/detection/technologySignatures.mjs +563 -0
  111. package/dist/esm/scan/detection/technologySignatures.mjs.map +1 -0
  112. package/dist/esm/scan/detection/url.mjs +47 -0
  113. package/dist/esm/scan/detection/url.mjs.map +1 -0
  114. package/dist/esm/scan/fetchText.mjs +55 -0
  115. package/dist/esm/scan/fetchText.mjs.map +1 -0
  116. package/dist/esm/scan/index.mjs +15 -3
  117. package/dist/esm/scan/parseHtml.mjs +52 -11
  118. package/dist/esm/scan/parseHtml.mjs.map +1 -1
  119. package/dist/esm/scan/robots.mjs +63 -0
  120. package/dist/esm/scan/robots.mjs.map +1 -0
  121. package/dist/esm/scan/runScanChecks.mjs +88 -0
  122. package/dist/esm/scan/runScanChecks.mjs.map +1 -0
  123. package/dist/esm/scan/scanWebsite.mjs +59 -53
  124. package/dist/esm/scan/scanWebsite.mjs.map +1 -1
  125. package/dist/esm/scan/sitemap.mjs +105 -0
  126. package/dist/esm/scan/sitemap.mjs.map +1 -0
  127. package/dist/esm/utils/chunkJSON.mjs +24 -9
  128. package/dist/esm/utils/chunkJSON.mjs.map +1 -1
  129. package/dist/esm/utils/getChunk.mjs +2 -2
  130. package/dist/esm/utils/getChunk.mjs.map +1 -1
  131. package/dist/esm/utils/runParallel/index.mjs +1 -1
  132. package/dist/esm/utils/runParallel/index.mjs.map +1 -1
  133. package/dist/esm/utils/runParallel/pidTree.mjs +23 -11
  134. package/dist/esm/utils/runParallel/pidTree.mjs.map +1 -1
  135. package/dist/esm/utils/runParallel/ps.mjs +8 -3
  136. package/dist/esm/utils/runParallel/ps.mjs.map +1 -1
  137. package/dist/esm/utils/runParallel/runTask.mjs +2 -1
  138. package/dist/esm/utils/runParallel/runTask.mjs.map +1 -1
  139. package/dist/esm/utils/runParallel/wmic.mjs +8 -3
  140. package/dist/esm/utils/runParallel/wmic.mjs.map +1 -1
  141. package/dist/esm/writeContentDeclaration/detectExportedComponentName.mjs +7 -4
  142. package/dist/esm/writeContentDeclaration/detectExportedComponentName.mjs.map +1 -1
  143. package/dist/esm/writeContentDeclaration/writeMarkdownFile.mjs +2 -2
  144. package/dist/esm/writeContentDeclaration/writeMarkdownFile.mjs.map +1 -1
  145. package/dist/types/docReview/rebuildDocument.d.ts.map +1 -1
  146. package/dist/types/docReview/segmentDocument.d.ts.map +1 -1
  147. package/dist/types/init/frameworkSetup/nextAppRouter/transforms.d.ts.map +1 -1
  148. package/dist/types/loadDictionaries/logTypeScriptErrors.d.ts.map +1 -1
  149. package/dist/types/scan/analyzeBundleContent.d.ts.map +1 -1
  150. package/dist/types/scan/calculateScore.d.ts +4 -1
  151. package/dist/types/scan/calculateScore.d.ts.map +1 -1
  152. package/dist/types/scan/checks.d.ts +114 -21
  153. package/dist/types/scan/checks.d.ts.map +1 -1
  154. package/dist/types/scan/detection/checkDetails.d.ts +29 -0
  155. package/dist/types/scan/detection/checkDetails.d.ts.map +1 -0
  156. package/dist/types/scan/detection/classifyInternalLinks.d.ts +44 -0
  157. package/dist/types/scan/detection/classifyInternalLinks.d.ts.map +1 -0
  158. package/dist/types/scan/detection/detectRoutingStrategy.d.ts +60 -0
  159. package/dist/types/scan/detection/detectRoutingStrategy.d.ts.map +1 -0
  160. package/dist/types/scan/detection/detectTechnologies.d.ts +60 -0
  161. package/dist/types/scan/detection/detectTechnologies.d.ts.map +1 -0
  162. package/dist/types/scan/detection/index.d.ts +9 -0
  163. package/dist/types/scan/detection/localeCode.d.ts +49 -0
  164. package/dist/types/scan/detection/localeCode.d.ts.map +1 -0
  165. package/dist/types/scan/detection/localizedPages.d.ts +40 -0
  166. package/dist/types/scan/detection/localizedPages.d.ts.map +1 -0
  167. package/dist/types/scan/detection/technologySignatures.d.ts +48 -0
  168. package/dist/types/scan/detection/technologySignatures.d.ts.map +1 -0
  169. package/dist/types/scan/detection/url.d.ts +27 -0
  170. package/dist/types/scan/detection/url.d.ts.map +1 -0
  171. package/dist/types/scan/fetchText.d.ts +30 -0
  172. package/dist/types/scan/fetchText.d.ts.map +1 -0
  173. package/dist/types/scan/index.d.ts +16 -4
  174. package/dist/types/scan/parseHtml.d.ts +17 -0
  175. package/dist/types/scan/parseHtml.d.ts.map +1 -1
  176. package/dist/types/scan/robots.d.ts +23 -0
  177. package/dist/types/scan/robots.d.ts.map +1 -0
  178. package/dist/types/scan/runScanChecks.d.ts +43 -0
  179. package/dist/types/scan/runScanChecks.d.ts.map +1 -0
  180. package/dist/types/scan/scanWebsite.d.ts.map +1 -1
  181. package/dist/types/scan/sitemap.d.ts +49 -0
  182. package/dist/types/scan/sitemap.d.ts.map +1 -0
  183. package/dist/types/scan/types.d.ts +15 -0
  184. package/dist/types/scan/types.d.ts.map +1 -1
  185. package/dist/types/utils/chunkJSON.d.ts.map +1 -1
  186. package/dist/types/utils/runParallel/pidTree.d.ts.map +1 -1
  187. package/dist/types/writeContentDeclaration/writeMarkdownFile.d.ts.map +1 -1
  188. package/package.json +15 -7
@@ -1 +1 @@
1
- {"version":3,"file":"ps.mjs","names":["os"],"sources":["../../../../src/utils/runParallel/ps.ts"],"sourcesContent":["import * as os from 'node:os';\nimport { run } from './bin';\n\ntype ProcessList = [number, number][]; // [PPID, PID][]\ntype ProcessListCallback = (err: Error | null, list?: ProcessList) => void;\n\n/**\n * Gets the list of all the pids of the system through the ps command.\n * @param callback Callback function with error and process list.\n */\nexport const ps = (callback: ProcessListCallback): void => {\n const args = ['-A', '-o', 'ppid,pid'];\n\n run('ps', args, (err, stdout, code) => {\n if (err) {\n callback(err);\n return;\n }\n if (code !== 0) {\n callback(new Error(`pidtree ps command exited with code ${code}`));\n return;\n }\n\n // Example of stdout\n //\n // PPID PID\n // 1 430\n // 430 432\n // 1 727\n // 1 7166\n\n if (!stdout) {\n callback(new Error('No stdout received from ps command'));\n return;\n }\n\n try {\n const lines = stdout.split(os.EOL);\n\n const list: ProcessList = [];\n for (let i = 1; i < lines.length; i++) {\n const trimmed = lines[i].trim();\n if (!trimmed) continue;\n const parts = trimmed.split(/\\s+/);\n const ppid = parseInt(parts[0], 10); // PPID\n const pid = parseInt(parts[1], 10); // PID\n if (!Number.isNaN(ppid) && !Number.isNaN(pid)) {\n list.push([ppid, pid]);\n }\n }\n\n callback(null, list);\n } catch (error) {\n callback(error instanceof Error ? error : new Error(String(error)));\n }\n });\n};\n"],"mappings":";;;;;;;;AAUA,MAAa,MAAM,aAAwC;CAGzD,IAAI,MAAM;EAFI;EAAM;EAAM;CAEb,IAAI,KAAK,QAAQ,SAAS;EACrC,IAAI,KAAK;GACP,SAAS,GAAG;GACZ;EACF;EACA,IAAI,SAAS,GAAG;GACd,yBAAS,IAAI,MAAM,uCAAuC,MAAM,CAAC;GACjE;EACF;EAUA,IAAI,CAAC,QAAQ;GACX,yBAAS,IAAI,MAAM,oCAAoC,CAAC;GACxD;EACF;EAEA,IAAI;GACF,MAAM,QAAQ,OAAO,MAAMA,KAAG,GAAG;GAEjC,MAAM,OAAoB,CAAC;GAC3B,KAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;IACrC,MAAM,UAAU,MAAM,EAAE,CAAC,KAAK;IAC9B,IAAI,CAAC,SAAS;IACd,MAAM,QAAQ,QAAQ,MAAM,KAAK;IACjC,MAAM,OAAO,SAAS,MAAM,IAAI,EAAE;IAClC,MAAM,MAAM,SAAS,MAAM,IAAI,EAAE;IACjC,IAAI,CAAC,OAAO,MAAM,IAAI,KAAK,CAAC,OAAO,MAAM,GAAG,GAC1C,KAAK,KAAK,CAAC,MAAM,GAAG,CAAC;GAEzB;GAEA,SAAS,MAAM,IAAI;EACrB,SAAS,OAAO;GACd,SAAS,iBAAiB,QAAQ,QAAQ,IAAI,MAAM,OAAO,KAAK,CAAC,CAAC;EACpE;CACF,CAAC;AACH"}
1
+ {"version":3,"file":"ps.mjs","names":["os"],"sources":["../../../../src/utils/runParallel/ps.ts"],"sourcesContent":["import * as os from 'node:os';\nimport { run } from './bin';\n\ntype ProcessList = [number, number][]; // [PPID, PID][]\ntype ProcessListCallback = (err: Error | null, list?: ProcessList) => void;\n\n/**\n * Gets the list of all the pids of the system through the ps command.\n * @param callback Callback function with error and process list.\n */\nexport const ps = (callback: ProcessListCallback): void => {\n const args = ['-A', '-o', 'ppid,pid'];\n\n run('ps', args, (err, stdout, code) => {\n if (err) {\n callback(err);\n return;\n }\n if (code !== 0) {\n callback(new Error(`pidtree ps command exited with code ${code}`));\n return;\n }\n\n // Example of stdout\n //\n // PPID PID\n // 1 430\n // 430 432\n // 1 727\n // 1 7166\n\n if (!stdout) {\n callback(new Error('No stdout received from ps command'));\n return;\n }\n\n try {\n const lines = stdout.split(os.EOL);\n\n const list: ProcessList = [];\n for (let i = 1; i < lines.length; i++) {\n const line = lines[i];\n\n if (!line) continue;\n\n const trimmed = line.trim();\n\n if (!trimmed) continue;\n\n const parts = trimmed.split(/\\s+/);\n const p0 = parts[0];\n const p1 = parts[1];\n\n if (!p0 || !p1) continue;\n\n const ppid = parseInt(p0, 10); // PPID\n const pid = parseInt(p1, 10); // PID\n\n if (!Number.isNaN(ppid) && !Number.isNaN(pid)) {\n list.push([ppid, pid]);\n }\n }\n\n callback(null, list);\n } catch (error) {\n callback(error instanceof Error ? error : new Error(String(error)));\n }\n });\n};\n"],"mappings":";;;;;;;;AAUA,MAAa,MAAM,aAAwC;CAGzD,IAAI,MAAM;EAFI;EAAM;EAAM;CAEb,IAAI,KAAK,QAAQ,SAAS;EACrC,IAAI,KAAK;GACP,SAAS,GAAG;GACZ;EACF;EACA,IAAI,SAAS,GAAG;GACd,yBAAS,IAAI,MAAM,uCAAuC,MAAM,CAAC;GACjE;EACF;EAUA,IAAI,CAAC,QAAQ;GACX,yBAAS,IAAI,MAAM,oCAAoC,CAAC;GACxD;EACF;EAEA,IAAI;GACF,MAAM,QAAQ,OAAO,MAAMA,KAAG,GAAG;GAEjC,MAAM,OAAoB,CAAC;GAC3B,KAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;IACrC,MAAM,OAAO,MAAM;IAEnB,IAAI,CAAC,MAAM;IAEX,MAAM,UAAU,KAAK,KAAK;IAE1B,IAAI,CAAC,SAAS;IAEd,MAAM,QAAQ,QAAQ,MAAM,KAAK;IACjC,MAAM,KAAK,MAAM;IACjB,MAAM,KAAK,MAAM;IAEjB,IAAI,CAAC,MAAM,CAAC,IAAI;IAEhB,MAAM,OAAO,SAAS,IAAI,EAAE;IAC5B,MAAM,MAAM,SAAS,IAAI,EAAE;IAE3B,IAAI,CAAC,OAAO,MAAM,IAAI,KAAK,CAAC,OAAO,MAAM,GAAG,GAC1C,KAAK,KAAK,CAAC,MAAM,GAAG,CAAC;GAEzB;GAEA,SAAS,MAAM,IAAI;EACrB,SAAS,OAAO;GACd,SAAS,iBAAiB,QAAQ,QAAQ,IAAI,MAAM,OAAO,KAAK,CAAC,CAAC;EACpE;CACF,CAAC;AACH"}
@@ -119,7 +119,8 @@ const runTasks = (tasks, options) => {
119
119
  if (aborted) return;
120
120
  if (options.aggregateOutput) originalOutputStream.write(writer.toString());
121
121
  if (result.code === null && result.signal !== null && result.signal !== void 0) result.code = 128 + convert(result.signal);
122
- results[task.index].code = result.code;
122
+ const taskResult = results[task.index];
123
+ if (taskResult) taskResult.code = result.code;
123
124
  if (result.code) {
124
125
  error = /* @__PURE__ */ new Error(`Task ${result.name} failed with code ${result.code}`);
125
126
  if (!options.continueOnError) {
@@ -1 +1 @@
1
- {"version":3,"file":"runTask.mjs","names":[],"sources":["../../../../src/utils/runParallel/runTask.ts"],"sourcesContent":["//------------------------------------------------------------------------------\n// Requirements\n//------------------------------------------------------------------------------\n\nimport { Writable } from 'node:stream';\n\n//------------------------------------------------------------------------------\n// Helpers\n//------------------------------------------------------------------------------\n\n/**\n * Remove the given value from the array.\n */\nconst remove = <T>(array: T[], x: T): void => {\n const index = array.indexOf(x);\n if (index !== -1) {\n array.splice(index, 1);\n }\n};\n\nconst signals: Record<string, number> = {\n // Signal name mappings to their respective standard numeric codes.\n // See: https://man7.org/linux/man-pages/man7/signal.7.html\n\n SIGABRT: 6, // Abort signal from abort(3)\n SIGALRM: 14, // Timer signal from alarm(2)\n SIGBUS: 10, // Bus error (bad memory access)\n SIGCHLD: 20, // Child stopped or terminated\n SIGCONT: 19, // Continue if stopped\n SIGFPE: 8, // Floating point exception\n SIGHUP: 1, // Hangup detected on controlling terminal or death of controlling process\n SIGILL: 4, // Illegal Instruction\n SIGINT: 2, // Interrupt from keyboard (Ctrl+C)\n SIGKILL: 9, // Kill signal (cannot be caught or ignored)\n SIGPIPE: 13, // Broken pipe: write to pipe with no readers\n SIGQUIT: 3, // Quit from keyboard (Ctrl+\\)\n SIGSEGV: 11, // Invalid memory reference (segmentation fault)\n SIGSTOP: 17, // Stop process (cannot be caught or ignored)\n SIGTERM: 15, // Termination signal\n SIGTRAP: 5, // Trace/breakpoint trap\n SIGTSTP: 18, // Stop typed at tty (Ctrl+Z)\n SIGTTIN: 21, // tty input for background process\n SIGTTOU: 22, // tty output for background process\n SIGUSR1: 30, // User-defined signal 1\n SIGUSR2: 31, // User-defined signal 2\n};\n\n/**\n * Converts a signal name to a number.\n */\nconst convert = (signal: string): number => {\n return signals[signal] || 0;\n};\n\n/**\n * Simple in-memory writable stream\n */\nclass MemoryStream extends Writable {\n private chunks: Buffer[] = [];\n\n _write(\n chunk: Buffer,\n _encoding: string,\n callback: (error?: Error | null) => void\n ): void {\n this.chunks.push(chunk);\n callback();\n }\n\n toString(): string {\n return Buffer.concat(this.chunks).toString('utf8');\n }\n}\n\n//------------------------------------------------------------------------------\n// Types\n//------------------------------------------------------------------------------\n\ninterface TaskResult {\n name: string;\n code: number | null;\n signal?: string | null;\n}\n\ninterface TaskQueueItem {\n name: string;\n index: number;\n}\n\ninterface RunTaskOptions {\n stdout: NodeJS.WritableStream;\n stderr?: NodeJS.WritableStream;\n aggregateOutput?: boolean;\n continueOnError?: boolean;\n race?: boolean;\n maxParallel?: number;\n}\n\ninterface TaskPromise extends Promise<TaskResult> {\n abort?: () => void;\n}\n\n//------------------------------------------------------------------------------\n// Public Interface\n//------------------------------------------------------------------------------\n\n/**\n * Run npm-scripts of given names in parallel.\n *\n * If a npm-script exited with a non-zero code, this aborts other all npm-scripts.\n *\n * Note: This is a simplified version for our use case.\n * The full implementation would require the actual runTask function from npm-run-all.\n */\nexport const runTasks = (\n tasks: string[],\n options: RunTaskOptions\n): Promise<TaskResult[]> => {\n return new Promise((resolve, reject) => {\n if (tasks.length === 0) {\n resolve([]);\n return;\n }\n\n const results: TaskResult[] = tasks.map((task) => ({\n name: task,\n code: undefined as any,\n }));\n const queue: TaskQueueItem[] = tasks.map((task, index) => ({\n name: task,\n index,\n }));\n const promises: TaskPromise[] = [];\n let error: Error | null = null;\n let aborted = false;\n\n /**\n * Done.\n */\n const done = (): void => {\n if (error == null) {\n resolve(results);\n } else {\n reject(error);\n }\n };\n\n /**\n * Aborts all tasks.\n */\n const abort = (): void => {\n if (aborted) {\n return;\n }\n aborted = true;\n\n if (promises.length === 0) {\n done();\n } else {\n for (const p of promises) {\n p.abort?.();\n }\n Promise.all(promises).then(done, reject);\n }\n };\n\n /**\n * Runs a next task.\n */\n const next = (): void => {\n if (aborted) {\n return;\n }\n if (queue.length === 0) {\n if (promises.length === 0) {\n done();\n }\n return;\n }\n\n const originalOutputStream = options.stdout;\n const optionsClone = { ...options };\n const writer = new MemoryStream();\n\n if (options.aggregateOutput) {\n optionsClone.stdout = writer as any;\n }\n\n const task = queue.shift()!;\n\n // Note: This requires the actual runTask implementation from npm-run-all\n // For now, this is a placeholder that would need to be implemented\n const promise = Promise.resolve({\n name: task.name,\n code: 0,\n signal: null,\n }) as TaskPromise;\n\n promises.push(promise);\n promise.then(\n (result) => {\n remove(promises, promise);\n if (aborted) {\n return;\n }\n\n if (options.aggregateOutput) {\n originalOutputStream.write(writer.toString());\n }\n\n // Check if the task failed as a result of a signal, and\n // amend the exit code as a result.\n if (\n result.code === null &&\n result.signal !== null &&\n result.signal !== undefined\n ) {\n // An exit caused by a signal must return a status code\n // of 128 plus the value of the signal code.\n // Ref: https://nodejs.org/api/process.html#process_exit_codes\n result.code = 128 + convert(result.signal);\n }\n\n // Save the result.\n results[task.index].code = result.code;\n\n // Aborts all tasks if it's an error.\n if (result.code) {\n error = new Error(\n `Task ${result.name} failed with code ${result.code}`\n );\n if (!options.continueOnError) {\n abort();\n return;\n }\n }\n\n // Aborts all tasks if options.race is true.\n if (options.race && !result.code) {\n abort();\n return;\n }\n\n // Call the next task.\n next();\n },\n (thisError: Error) => {\n remove(promises, promise);\n if (!options.continueOnError || options.race) {\n error = thisError;\n abort();\n return;\n }\n next();\n }\n );\n };\n\n const max = options.maxParallel;\n const end =\n typeof max === 'number' && max > 0\n ? Math.min(tasks.length, max)\n : tasks.length;\n for (let i = 0; i < end; ++i) {\n next();\n }\n });\n};\n"],"mappings":";;;;;;AAaA,MAAM,UAAa,OAAY,MAAe;CAC5C,MAAM,QAAQ,MAAM,QAAQ,CAAC;CAC7B,IAAI,UAAU,IACZ,MAAM,OAAO,OAAO,CAAC;AAEzB;AAEA,MAAM,UAAkC;CAItC,SAAS;CACT,SAAS;CACT,QAAQ;CACR,SAAS;CACT,SAAS;CACT,QAAQ;CACR,QAAQ;CACR,QAAQ;CACR,QAAQ;CACR,SAAS;CACT,SAAS;CACT,SAAS;CACT,SAAS;CACT,SAAS;CACT,SAAS;CACT,SAAS;CACT,SAAS;CACT,SAAS;CACT,SAAS;CACT,SAAS;CACT,SAAS;AACX;;;;AAKA,MAAM,WAAW,WAA2B;CAC1C,OAAO,QAAQ,WAAW;AAC5B;;;;AAKA,IAAM,eAAN,cAA2B,SAAS;CAClC,AAAQ,SAAmB,CAAC;CAE5B,OACE,OACA,WACA,UACM;EACN,KAAK,OAAO,KAAK,KAAK;EACtB,SAAS;CACX;CAEA,WAAmB;EACjB,OAAO,OAAO,OAAO,KAAK,MAAM,CAAC,CAAC,SAAS,MAAM;CACnD;AACF;;;;;;;;;AA0CA,MAAa,YACX,OACA,YAC0B;CAC1B,OAAO,IAAI,SAAS,SAAS,WAAW;EACtC,IAAI,MAAM,WAAW,GAAG;GACtB,QAAQ,CAAC,CAAC;GACV;EACF;EAEA,MAAM,UAAwB,MAAM,KAAK,UAAU;GACjD,MAAM;GACN,MAAM;EACR,EAAE;EACF,MAAM,QAAyB,MAAM,KAAK,MAAM,WAAW;GACzD,MAAM;GACN;EACF,EAAE;EACF,MAAM,WAA0B,CAAC;EACjC,IAAI,QAAsB;EAC1B,IAAI,UAAU;;;;EAKd,MAAM,aAAmB;GACvB,IAAI,SAAS,MACX,QAAQ,OAAO;QAEf,OAAO,K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AAK;GACP,CACF;EACF;EAEA,MAAM,MAAM,QAAQ;EACpB,MAAM,MACJ,OAAO,QAAQ,YAAY,MAAM,IAC7B,KAAK,IAAI,MAAM,QAAQ,GAAG,IAC1B,MAAM;EACZ,KAAK,IAAI,IAAI,GAAG,IAAI,KAAK,EAAE,GACzB,KAAK;CAET,CAAC;AACH"}
1
+ {"version":3,"file":"runTask.mjs","names":[],"sources":["../../../../src/utils/runParallel/runTask.ts"],"sourcesContent":["//------------------------------------------------------------------------------\n// Requirements\n//------------------------------------------------------------------------------\n\nimport { Writable } from 'node:stream';\n\n//------------------------------------------------------------------------------\n// Helpers\n//------------------------------------------------------------------------------\n\n/**\n * Remove the given value from the array.\n */\nconst remove = <T>(array: T[], x: T): void => {\n const index = array.indexOf(x);\n if (index !== -1) {\n array.splice(index, 1);\n }\n};\n\nconst signals: Record<string, number> = {\n // Signal name mappings to their respective standard numeric codes.\n // See: https://man7.org/linux/man-pages/man7/signal.7.html\n\n SIGABRT: 6, // Abort signal from abort(3)\n SIGALRM: 14, // Timer signal from alarm(2)\n SIGBUS: 10, // Bus error (bad memory access)\n SIGCHLD: 20, // Child stopped or terminated\n SIGCONT: 19, // Continue if stopped\n SIGFPE: 8, // Floating point exception\n SIGHUP: 1, // Hangup detected on controlling terminal or death of controlling process\n SIGILL: 4, // Illegal Instruction\n SIGINT: 2, // Interrupt from keyboard (Ctrl+C)\n SIGKILL: 9, // Kill signal (cannot be caught or ignored)\n SIGPIPE: 13, // Broken pipe: write to pipe with no readers\n SIGQUIT: 3, // Quit from keyboard (Ctrl+\\)\n SIGSEGV: 11, // Invalid memory reference (segmentation fault)\n SIGSTOP: 17, // Stop process (cannot be caught or ignored)\n SIGTERM: 15, // Termination signal\n SIGTRAP: 5, // Trace/breakpoint trap\n SIGTSTP: 18, // Stop typed at tty (Ctrl+Z)\n SIGTTIN: 21, // tty input for background process\n SIGTTOU: 22, // tty output for background process\n SIGUSR1: 30, // User-defined signal 1\n SIGUSR2: 31, // User-defined signal 2\n};\n\n/**\n * Converts a signal name to a number.\n */\nconst convert = (signal: string): number => {\n return signals[signal] || 0;\n};\n\n/**\n * Simple in-memory writable stream\n */\nclass MemoryStream extends Writable {\n private chunks: Buffer[] = [];\n\n _write(\n chunk: Buffer,\n _encoding: string,\n callback: (error?: Error | null) => void\n ): void {\n this.chunks.push(chunk);\n callback();\n }\n\n toString(): string {\n return Buffer.concat(this.chunks).toString('utf8');\n }\n}\n\n//------------------------------------------------------------------------------\n// Types\n//------------------------------------------------------------------------------\n\ninterface TaskResult {\n name: string;\n code: number | null;\n signal?: string | null;\n}\n\ninterface TaskQueueItem {\n name: string;\n index: number;\n}\n\ninterface RunTaskOptions {\n stdout: NodeJS.WritableStream;\n stderr?: NodeJS.WritableStream;\n aggregateOutput?: boolean;\n continueOnError?: boolean;\n race?: boolean;\n maxParallel?: number;\n}\n\ninterface TaskPromise extends Promise<TaskResult> {\n abort?: () => void;\n}\n\n//------------------------------------------------------------------------------\n// Public Interface\n//------------------------------------------------------------------------------\n\n/**\n * Run npm-scripts of given names in parallel.\n *\n * If a npm-script exited with a non-zero code, this aborts other all npm-scripts.\n *\n * Note: This is a simplified version for our use case.\n * The full implementation would require the actual runTask function from npm-run-all.\n */\nexport const runTasks = (\n tasks: string[],\n options: RunTaskOptions\n): Promise<TaskResult[]> => {\n return new Promise((resolve, reject) => {\n if (tasks.length === 0) {\n resolve([]);\n return;\n }\n\n const results: TaskResult[] = tasks.map((task) => ({\n name: task,\n code: undefined as any,\n }));\n const queue: TaskQueueItem[] = tasks.map((task, index) => ({\n name: task,\n index,\n }));\n const promises: TaskPromise[] = [];\n let error: Error | null = null;\n let aborted = false;\n\n /**\n * Done.\n */\n const done = (): void => {\n if (error == null) {\n resolve(results);\n } else {\n reject(error);\n }\n };\n\n /**\n * Aborts all tasks.\n */\n const abort = (): void => {\n if (aborted) {\n return;\n }\n aborted = true;\n\n if (promises.length === 0) {\n done();\n } else {\n for (const p of promises) {\n p.abort?.();\n }\n Promise.all(promises).then(done, reject);\n }\n };\n\n /**\n * Runs a next task.\n */\n const next = (): void => {\n if (aborted) {\n return;\n }\n if (queue.length === 0) {\n if (promises.length === 0) {\n done();\n }\n return;\n }\n\n const originalOutputStream = options.stdout;\n const optionsClone = { ...options };\n const writer = new MemoryStream();\n\n if (options.aggregateOutput) {\n optionsClone.stdout = writer as any;\n }\n\n const task = queue.shift()!;\n\n // Note: This requires the actual runTask implementation from npm-run-all\n // For now, this is a placeholder that would need to be implemented\n const promise = Promise.resolve({\n name: task.name,\n code: 0,\n signal: null,\n }) as TaskPromise;\n\n promises.push(promise);\n promise.then(\n (result) => {\n remove(promises, promise);\n if (aborted) {\n return;\n }\n\n if (options.aggregateOutput) {\n originalOutputStream.write(writer.toString());\n }\n\n // Check if the task failed as a result of a signal, and\n // amend the exit code as a result.\n if (\n result.code === null &&\n result.signal !== null &&\n result.signal !== undefined\n ) {\n // An exit caused by a signal must return a status code\n // of 128 plus the value of the signal code.\n // Ref: https://nodejs.org/api/process.html#process_exit_codes\n result.code = 128 + convert(result.signal);\n }\n\n // Save the result.\n const taskResult = results[task.index];\n\n if (taskResult) {\n taskResult.code = result.code;\n }\n\n // Aborts all tasks if it's an error.\n if (result.code) {\n error = new Error(\n `Task ${result.name} failed with code ${result.code}`\n );\n if (!options.continueOnError) {\n abort();\n return;\n }\n }\n\n // Aborts all tasks if options.race is true.\n if (options.race && !result.code) {\n abort();\n return;\n }\n\n // Call the next task.\n next();\n },\n (thisError: Error) => {\n remove(promises, promise);\n if (!options.continueOnError || options.race) {\n error = thisError;\n abort();\n return;\n }\n next();\n }\n );\n };\n\n const max = options.maxParallel;\n const end =\n typeof max === 'number' && max > 0\n ? Math.min(tasks.length, max)\n : tasks.length;\n for (let i = 0; i < end; ++i) {\n next();\n }\n });\n};\n"],"mappings":";;;;;;AAaA,MAAM,UAAa,OAAY,MAAe;CAC5C,MAAM,QAAQ,MAAM,QAAQ,CAAC;CAC7B,IAAI,UAAU,IACZ,MAAM,OAA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,16 @@ const wmic = (callback) => {
31
31
  const lines = stdout.split(os$1.EOL);
32
32
  const list = [];
33
33
  for (let i = 1; i < lines.length; i++) {
34
- const trimmed = lines[i].trim();
34
+ const line = lines[i];
35
+ if (!line) continue;
36
+ const trimmed = line.trim();
35
37
  if (!trimmed) continue;
36
38
  const parts = trimmed.split(/\s+/);
37
- const ppid = parseInt(parts[0], 10);
38
- const pid = parseInt(parts[1], 10);
39
+ const p0 = parts[0];
40
+ const p1 = parts[1];
41
+ if (!p0 || !p1) continue;
42
+ const ppid = parseInt(p0, 10);
43
+ const pid = parseInt(p1, 10);
39
44
  if (!Number.isNaN(ppid) && !Number.isNaN(pid)) list.push([ppid, pid]);
40
45
  }
41
46
  callback(null, list);
@@ -1 +1 @@
1
- {"version":3,"file":"wmic.mjs","names":["os"],"sources":["../../../../src/utils/runParallel/wmic.ts"],"sourcesContent":["import type { SpawnOptions } from 'node:child_process';\nimport * as os from 'node:os';\nimport { run } from './bin';\n\ntype ProcessList = [number, number][]; // [PPID, PID][]\ntype ProcessListCallback = (err: Error | null, list?: ProcessList) => void;\n\n/**\n * Gets the list of all the pids of the system through the wmic command.\n * @param callback Callback function with error and process list.\n */\nexport const wmic = (callback: ProcessListCallback): void => {\n const args = ['PROCESS', 'get', 'ParentProcessId,ProcessId'];\n const options: SpawnOptions = {\n windowsHide: true,\n windowsVerbatimArguments: true,\n };\n run('wmic', args, options, (err, stdout, code) => {\n if (err) {\n callback(err);\n return;\n }\n\n if (code !== 0) {\n callback(new Error(`pidtree wmic command exited with code ${code}`));\n return;\n }\n\n // Example of stdout\n //\n // ParentProcessId ProcessId\n // 0 777\n\n if (!stdout) {\n callback(new Error('No stdout received from wmic command'));\n return;\n }\n\n try {\n const lines = stdout.split(os.EOL);\n\n const list: ProcessList = [];\n for (let i = 1; i < lines.length; i++) {\n const trimmed = lines[i].trim();\n if (!trimmed) continue;\n const parts = trimmed.split(/\\s+/);\n const ppid = parseInt(parts[0], 10); // PPID\n const pid = parseInt(parts[1], 10); // PID\n if (!Number.isNaN(ppid) && !Number.isNaN(pid)) {\n list.push([ppid, pid]);\n }\n }\n\n callback(null, list);\n } catch (error) {\n callback(error instanceof Error ? error : new Error(String(error)));\n }\n });\n};\n"],"mappings":";;;;;;;;AAWA,MAAa,QAAQ,aAAwC;CAM3D,IAAI,QAAQ;EALE;EAAW;EAAO;CAKjB,GAAG;EAHhB,aAAa;EACb,0BAA0B;CAEJ,IAAI,KAAK,QAAQ,SAAS;EAChD,IAAI,KAAK;GACP,SAAS,GAAG;GACZ;EACF;EAEA,IAAI,SAAS,GAAG;GACd,yBAAS,IAAI,MAAM,yCAAyC,MAAM,CAAC;GACnE;EACF;EAOA,IAAI,CAAC,QAAQ;GACX,yBAAS,IAAI,MAAM,sCAAsC,CAAC;GAC1D;EACF;EAEA,IAAI;GACF,MAAM,QAAQ,OAAO,MAAMA,KAAG,GAAG;GAEjC,MAAM,OAAoB,CAAC;GAC3B,KAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;IACrC,MAAM,UAAU,MAAM,EAAE,CAAC,KAAK;IAC9B,IAAI,CAAC,SAAS;IACd,MAAM,QAAQ,QAAQ,MAAM,KAAK;IACjC,MAAM,OAAO,SAAS,MAAM,IAAI,EAAE;IAClC,MAAM,MAAM,SAAS,MAAM,IAAI,EAAE;IACjC,IAAI,CAAC,OAAO,MAAM,IAAI,KAAK,CAAC,OAAO,MAAM,GAAG,GAC1C,KAAK,KAAK,CAAC,MAAM,GAAG,CAAC;GAEzB;GAEA,SAAS,MAAM,IAAI;EACrB,SAAS,OAAO;GACd,SAAS,iBAAiB,QAAQ,QAAQ,IAAI,MAAM,OAAO,KAAK,CAAC,CAAC;EACpE;CACF,CAAC;AACH"}
1
+ {"version":3,"file":"wmic.mjs","names":["os"],"sources":["../../../../src/utils/runParallel/wmic.ts"],"sourcesContent":["import type { SpawnOptions } from 'node:child_process';\nimport * as os from 'node:os';\nimport { run } from './bin';\n\ntype ProcessList = [number, number][]; // [PPID, PID][]\ntype ProcessListCallback = (err: Error | null, list?: ProcessList) => void;\n\n/**\n * Gets the list of all the pids of the system through the wmic command.\n * @param callback Callback function with error and process list.\n */\nexport const wmic = (callback: ProcessListCallback): void => {\n const args = ['PROCESS', 'get', 'ParentProcessId,ProcessId'];\n const options: SpawnOptions = {\n windowsHide: true,\n windowsVerbatimArguments: true,\n };\n run('wmic', args, options, (err, stdout, code) => {\n if (err) {\n callback(err);\n return;\n }\n\n if (code !== 0) {\n callback(new Error(`pidtree wmic command exited with code ${code}`));\n return;\n }\n\n // Example of stdout\n //\n // ParentProcessId ProcessId\n // 0 777\n\n if (!stdout) {\n callback(new Error('No stdout received from wmic command'));\n return;\n }\n\n try {\n const lines = stdout.split(os.EOL);\n\n const list: ProcessList = [];\n for (let i = 1; i < lines.length; i++) {\n const line = lines[i];\n\n if (!line) continue;\n const trimmed = line.trim();\n\n if (!trimmed) continue;\n\n const parts = trimmed.split(/\\s+/);\n const p0 = parts[0];\n const p1 = parts[1];\n\n if (!p0 || !p1) continue;\n\n const ppid = parseInt(p0, 10); // PPID\n const pid = parseInt(p1, 10); // PID\n\n if (!Number.isNaN(ppid) && !Number.isNaN(pid)) {\n list.push([ppid, pid]);\n }\n }\n\n callback(null, list);\n } catch (error) {\n callback(error instanceof Error ? error : new Error(String(error)));\n }\n });\n};\n"],"mappings":";;;;;;;;AAWA,MAAa,QAAQ,aAAwC;CAM3D,IAAI,QAAQ;EALE;EAAW;EAAO;CAKjB,GAAG;EAHhB,aAAa;EACb,0BAA0B;CAEJ,IAAI,KAAK,QAAQ,SAAS;EAChD,IAAI,KAAK;GACP,SAAS,GAAG;GACZ;EACF;EAEA,IAAI,SAAS,GAAG;GACd,yBAAS,IAAI,MAAM,yCAAyC,MAAM,CAAC;GACnE;EACF;EAOA,IAAI,CAAC,QAAQ;GACX,yBAAS,IAAI,MAAM,sCAAsC,CAAC;GAC1D;EACF;EAEA,IAAI;GACF,MAAM,QAAQ,OAAO,MAAMA,KAAG,GAAG;GAEjC,MAAM,OAAoB,CAAC;GAC3B,KAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;IACrC,MAAM,OAAO,MAAM;IAEnB,IAAI,CAAC,MAAM;IACX,MAAM,UAAU,KAAK,KAAK;IAE1B,IAAI,CAAC,SAAS;IAEd,MAAM,QAAQ,QAAQ,MAAM,KAAK;IACjC,MAAM,KAAK,MAAM;IACjB,MAAM,KAAK,MAAM;IAEjB,IAAI,CAAC,MAAM,CAAC,IAAI;IAEhB,MAAM,OAAO,SAAS,IAAI,EAAE;IAC5B,MAAM,MAAM,SAAS,IAAI,EAAE;IAE3B,IAAI,CAAC,OAAO,MAAM,IAAI,KAAK,CAAC,OAAO,MAAM,GAAG,GAC1C,KAAK,KAAK,CAAC,MAAM,GAAG,CAAC;GAEzB;GAEA,SAAS,MAAM,IAAI;EACrB,SAAS,OAAO;GACd,SAAS,iBAAiB,QAAQ,QAAQ,IAAI,MAAM,OAAO,KAAK,CAAC,CAAC;EACpE;CACF,CAAC;AACH"}
@@ -13,12 +13,15 @@ const detectExportedComponentName = (fileText) => {
13
13
  const cjsDefaultVarRegex = /exports\.default\s*=\s*(\w+)/;
14
14
  const namedExportRegex = /export\s+(?:const|function)\s+(\w+)/g;
15
15
  const defaultEsmFnMatch = fileText.match(defaultEsmFnRegex);
16
- if (defaultEsmFnMatch) return defaultEsmFnMatch[1];
16
+ if (defaultEsmFnMatch?.[1]) return defaultEsmFnMatch[1];
17
17
  const defaultEsmVarMatch = fileText.match(defaultEsmVarRegex);
18
- if (defaultEsmVarMatch) return defaultEsmVarMatch[1];
18
+ if (defaultEsmVarMatch?.[1]) return defaultEsmVarMatch[1];
19
19
  const cjsDefaultMatch = fileText.match(cjsDefaultRegex) || fileText.match(cjsDefaultVarRegex);
20
- if (cjsDefaultMatch) return cjsDefaultMatch[1];
21
- for (const match of fileText.matchAll(namedExportRegex)) if (/^[A-Z]/.test(match[1])) return match[1];
20
+ if (cjsDefaultMatch?.[1]) return cjsDefaultMatch[1];
21
+ for (const match of fileText.matchAll(namedExportRegex)) {
22
+ const name = match[1];
23
+ if (name && /^[A-Z]/.test(name)) return name;
24
+ }
22
25
  return null;
23
26
  };
24
27
 
@@ -1 +1 @@
1
- {"version":3,"file":"detectExportedComponentName.mjs","names":[],"sources":["../../../src/writeContentDeclaration/detectExportedComponentName.ts"],"sourcesContent":["/**\n * Attempt to detect an exported React component name in the file text.\n * Looks for patterns like:\n * - export const MyComponent = ...\n * - export function MyComponent(...)\n * - export default function MyComponent(...)\n */\nexport const detectExportedComponentName = (\n fileText: string\n): string | null => {\n // Added regexes for default ESM, default CJS, and named exports\n const defaultEsmFnRegex = /export\\s+default\\s+function\\s+(\\w+)/;\n const defaultEsmVarRegex = /export\\s+default\\s+(\\w+)/;\n const cjsDefaultRegex = /module\\.exports\\s*=\\s*(\\w+)/;\n const cjsDefaultVarRegex = /exports\\.default\\s*=\\s*(\\w+)/;\n const namedExportRegex = /export\\s+(?:const|function)\\s+(\\w+)/g;\n\n // Check for default ESM function or variable\n const defaultEsmFnMatch = fileText.match(defaultEsmFnRegex);\n if (defaultEsmFnMatch) {\n return defaultEsmFnMatch[1];\n }\n\n const defaultEsmVarMatch = fileText.match(defaultEsmVarRegex);\n if (defaultEsmVarMatch) {\n return defaultEsmVarMatch[1];\n }\n\n // Check for default CJS\n const cjsDefaultMatch =\n fileText.match(cjsDefaultRegex) || fileText.match(cjsDefaultVarRegex);\n\n if (cjsDefaultMatch) return cjsDefaultMatch[1];\n\n // Otherwise, look for capitalized named exports\n for (const match of fileText.matchAll(namedExportRegex)) {\n if (/^[A-Z]/.test(match[1])) return match[1];\n }\n\n // If we can’t find it, return null\n return null;\n};\n"],"mappings":";;;;;;;;AAOA,MAAa,+BACX,aACkB;CAElB,MAAM,oBAAoB;CAC1B,MAAM,qBAAqB;CAC3B,MAAM,kBAAkB;CACxB,MAAM,qBAAqB;CAC3B,MAAM,mBAAmB;CAGzB,MAAM,oBAAoB,SAAS,MAAM,iBAAiB;CAC1D,IAAI,mBACF,OAAO,kBAAkB;CAG3B,MAAM,qBAAqB,SAAS,MAAM,kBAAkB;CAC5D,IAAI,oBACF,OAAO,mBAAmB;CAI5B,MAAM,kBACJ,SAAS,MAAM,eAAe,KAAK,SAAS,MAAM,kBAAkB;CAEtE,IAAI,iBAAiB,OAAO,gBAAgB;CAG5C,KAAK,MAAM,SAAS,SAAS,SAAS,gBAAgB,GACpD,IAAI,SAAS,KAAK,MAAM,EAAE,GAAG,OAAO,MAAM;CAI5C,OAAO;AACT"}
1
+ {"version":3,"file":"detectExportedComponentName.mjs","names":[],"sources":["../../../src/writeContentDeclaration/detectExportedComponentName.ts"],"sourcesContent":["/**\n * Attempt to detect an exported React component name in the file text.\n * Looks for patterns like:\n * - export const MyComponent = ...\n * - export function MyComponent(...)\n * - export default function MyComponent(...)\n */\nexport const detectExportedComponentName = (\n fileText: string\n): string | null => {\n // Added regexes for default ESM, default CJS, and named exports\n const defaultEsmFnRegex = /export\\s+default\\s+function\\s+(\\w+)/;\n const defaultEsmVarRegex = /export\\s+default\\s+(\\w+)/;\n const cjsDefaultRegex = /module\\.exports\\s*=\\s*(\\w+)/;\n const cjsDefaultVarRegex = /exports\\.default\\s*=\\s*(\\w+)/;\n const namedExportRegex = /export\\s+(?:const|function)\\s+(\\w+)/g;\n\n // Check for default ESM function or variable\n const defaultEsmFnMatch = fileText.match(defaultEsmFnRegex);\n\n if (defaultEsmFnMatch?.[1]) {\n return defaultEsmFnMatch[1];\n }\n\n const defaultEsmVarMatch = fileText.match(defaultEsmVarRegex);\n if (defaultEsmVarMatch?.[1]) {\n return defaultEsmVarMatch[1];\n }\n\n // Check for default CJS\n const cjsDefaultMatch =\n fileText.match(cjsDefaultRegex) || fileText.match(cjsDefaultVarRegex);\n\n if (cjsDefaultMatch?.[1]) return cjsDefaultMatch[1];\n\n // Otherwise, look for capitalized named exports\n for (const match of fileText.matchAll(namedExportRegex)) {\n const name = match[1];\n if (name && /^[A-Z]/.test(name)) return name;\n }\n\n // If we can’t find it, return null\n return null;\n};\n"],"mappings":";;;;;;;;AAOA,MAAa,+BACX,aACkB;CAElB,MAAM,oBAAoB;CAC1B,MAAM,qBAAqB;CAC3B,MAAM,kBAAkB;CACxB,MAAM,qBAAqB;CAC3B,MAAM,mBAAmB;CAGzB,MAAM,oBAAoB,SAAS,MAAM,iBAAiB;CAE1D,IAAI,oBAAoB,IACtB,OAAO,kBAAkB;CAG3B,MAAM,qBAAqB,SAAS,MAAM,kBAAkB;CAC5D,IAAI,qBAAqB,IACvB,OAAO,mBAAmB;CAI5B,MAAM,kBACJ,SAAS,MAAM,eAAe,KAAK,SAAS,MAAM,kBAAkB;CAEtE,IAAI,kBAAkB,IAAI,OAAO,gBAAgB;CAGjD,KAAK,MAAM,SAAS,SAAS,SAAS,gBAAgB,GAAG;EACvD,MAAM,OAAO,MAAM;EACnB,IAAI,QAAQ,SAAS,KAAK,IAAI,GAAG,OAAO;CAC1C;CAGA,OAAO;AACT"}
@@ -13,9 +13,9 @@ const stringifyYamlFrontmatter = (fields) => Object.entries(fields).filter(([, v
13
13
  const getMarkdownBody = (content) => {
14
14
  const lines = content.split(/\r?\n/);
15
15
  const firstNonEmptyIndex = lines.findIndex((line) => line.trim() !== "");
16
- if (firstNonEmptyIndex === -1 || lines[firstNonEmptyIndex].trim() !== "---") return content;
16
+ if (firstNonEmptyIndex === -1 || lines[firstNonEmptyIndex]?.trim() !== "---") return content;
17
17
  let endIndex = -1;
18
- for (let i = firstNonEmptyIndex + 1; i < lines.length; i++) if (lines[i].trim() === "---") {
18
+ for (let i = firstNonEmptyIndex + 1; i < lines.length; i++) if (lines[i]?.trim() === "---") {
19
19
  endIndex = i;
20
20
  break;
21
21
  }
@@ -1 +1 @@
1
- {"version":3,"file":"writeMarkdownFile.mjs","names":[],"sources":["../../../src/writeContentDeclaration/writeMarkdownFile.ts"],"sourcesContent":["import { execSync } from 'node:child_process';\nimport { mkdir, rename, rm, writeFile } from 'node:fs/promises';\nimport { basename, dirname, join } from 'node:path';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport { MARKDOWN } from '@intlayer/types/nodeType';\nimport { detectFormatCommand } from '../detectFormatCommand';\n\nconst stringifyYamlFrontmatter = (fields: Record<string, any>): string =>\n Object.entries(fields)\n .filter(([, value]) => value !== undefined && value !== null)\n .map(([key, value]) => {\n if (Array.isArray(value)) {\n return `${key}:\\n${value.map((item) => ` - ${JSON.stringify(item)}`).join('\\n')}`;\n }\n if (\n typeof value === 'string' &&\n (value.includes(':') || value.includes('\\n') || value.includes('#'))\n ) {\n return `${key}: ${JSON.stringify(value)}`;\n }\n return `${key}: ${value}`;\n })\n .join('\\n');\n\n// Strips YAML frontmatter from a markdown string, returning only the body\nconst getMarkdownBody = (content: string): string => {\n const lines = content.split(/\\r?\\n/);\n const firstNonEmptyIndex = lines.findIndex((line) => line.trim() !== '');\n\n if (firstNonEmptyIndex === -1 || lines[firstNonEmptyIndex].trim() !== '---') {\n return content;\n }\n\n let endIndex = -1;\n for (let i = firstNonEmptyIndex + 1; i < lines.length; i++) {\n if (lines[i].trim() === '---') {\n endIndex = i;\n break;\n }\n }\n\n if (endIndex === -1) return content;\n\n return lines\n .slice(endIndex + 1)\n .join('\\n')\n .trimStart();\n};\n\n// Fields that are auto-generated / internal and must not appear in frontmatter\nconst EXCLUDED_FRONTMATTER_KEYS = new Set<string>([\n 'content',\n '$schema',\n 'filePath',\n 'localId',\n 'localIds',\n 'projectIds',\n]);\n\nexport const writeMarkdownFile = async (\n absoluteFilePath: string,\n dictionary: Dictionary,\n configuration: IntlayerConfig\n): Promise<void> => {\n const content = dictionary.content as any;\n const markdownRaw =\n typeof content === 'object' && content?.nodeType === MARKDOWN\n ? (content[MARKDOWN] ?? '')\n : '';\n // content.markdown now stores the full file (frontmatter + body); extract only the body\n const markdownBody = getMarkdownBody(markdownRaw);\n\n const frontmatterFields = Object.fromEntries(\n Object.entries(dictionary).filter(\n ([k, v]) => !EXCLUDED_FRONTMATTER_KEYS.has(k) && v !== undefined\n )\n );\n\n const frontmatterStr = stringifyYamlFrontmatter(frontmatterFields);\n const fileContent = `---\\n${frontmatterStr}\\n---\\n\\n${markdownBody}`;\n\n const dir = dirname(absoluteFilePath);\n await mkdir(dir, { recursive: true });\n\n const tempDir = configuration.system?.tempDir;\n if (tempDir) await mkdir(tempDir, { recursive: true });\n\n const tempFileName = `${basename(absoluteFilePath)}.${Date.now()}-${Math.random().toString(36).slice(2)}.tmp`;\n const tempPath = tempDir\n ? join(tempDir, tempFileName)\n : `${absoluteFilePath}.${tempFileName}`;\n\n try {\n await writeFile(tempPath, fileContent, 'utf-8');\n await rename(tempPath, absoluteFilePath);\n } catch (error) {\n try {\n await rm(tempPath, { force: true });\n } catch {\n // ignore\n }\n throw error;\n }\n\n const formatCommand = detectFormatCommand(configuration);\n if (formatCommand) {\n try {\n execSync(formatCommand.replace('{{file}}', absoluteFilePath), {\n stdio: 'inherit',\n cwd: configuration.system.baseDir,\n });\n } catch (error) {\n console.error(error);\n }\n }\n};\n"],"mappings":";;;;;;;AAQA,MAAM,4BAA4B,WAChC,OAAO,QAAQ,MAAM,CAAC,CACnB,QAAQ,GAAG,WAAW,UAAU,UAAa,UAAU,IAAI,CAAC,CAC5D,KAAK,CAAC,KAAK,WAAW;CACrB,IAAI,MAAM,QAAQ,KAAK,GACrB,OAAO,GAAG,IAAI,KAAK,MAAM,KAAK,SAAS,OAAO,KAAK,UAAU,IAAI,GAAG,CAAC,CAAC,KAAK,IAAI;CAEjF,IACE,OAAO,UAAU,aAChB,MAAM,SAAS,GAAG,KAAK,MAAM,SAAS,IAAI,KAAK,MAAM,SAAS,GAAG,IAElE,OAAO,GAAG,IAAI,IAAI,KAAK,UAAU,KAAK;CAExC,OAAO,GAAG,IAAI,IAAI;AACpB,CAAC,CAAC,CACD,KAAK,IAAI;AAGd,MAAM,mBAAmB,YAA4B;CACnD,MAAM,QAAQ,QAAQ,M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B,IAAI;EACF,MAAM,UAAU,UAAU,aAAa,OAAO;EAC9C,MAAM,OAAO,UAAU,gBAAgB;CACzC,SAAS,OAAO;EACd,IAAI;GACF,MAAM,GAAG,UAAU,EAAE,OAAO,KAAK,CAAC;EACpC,QAAQ,CAER;EACA,MAAM;CACR;CAEA,MAAM,gBAAgB,oBAAoB,aAAa;CACvD,IAAI,eACF,IAAI;EACF,SAAS,cAAc,QAAQ,YAAY,gBAAgB,GAAG;GAC5D,OAAO;GACP,KAAK,cAAc,OAAO;EAC5B,CAAC;CACH,SAAS,OAAO;EACd,QAAQ,MAAM,KAAK;CACrB;AAEJ"}
1
+ {"version":3,"file":"writeMarkdownFile.mjs","names":[],"sources":["../../../src/writeContentDeclaration/writeMarkdownFile.ts"],"sourcesContent":["import { execSync } from 'node:child_process';\nimport { mkdir, rename, rm, writeFile } from 'node:fs/promises';\nimport { basename, dirname, join } from 'node:path';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport { MARKDOWN } from '@intlayer/types/nodeType';\nimport { detectFormatCommand } from '../detectFormatCommand';\n\nconst stringifyYamlFrontmatter = (fields: Record<string, any>): string =>\n Object.entries(fields)\n .filter(([, value]) => value !== undefined && value !== null)\n .map(([key, value]) => {\n if (Array.isArray(value)) {\n return `${key}:\\n${value.map((item) => ` - ${JSON.stringify(item)}`).join('\\n')}`;\n }\n if (\n typeof value === 'string' &&\n (value.includes(':') || value.includes('\\n') || value.includes('#'))\n ) {\n return `${key}: ${JSON.stringify(value)}`;\n }\n return `${key}: ${value}`;\n })\n .join('\\n');\n\n// Strips YAML frontmatter from a markdown string, returning only the body\nconst getMarkdownBody = (content: string): string => {\n const lines = content.split(/\\r?\\n/);\n const firstNonEmptyIndex = lines.findIndex((line) => line.trim() !== '');\n\n if (\n firstNonEmptyIndex === -1 ||\n lines[firstNonEmptyIndex]?.trim() !== '---'\n ) {\n return content;\n }\n\n let endIndex = -1;\n for (let i = firstNonEmptyIndex + 1; i < lines.length; i++) {\n if (lines[i]?.trim() === '---') {\n endIndex = i;\n break;\n }\n }\n\n if (endIndex === -1) return content;\n\n return lines\n .slice(endIndex + 1)\n .join('\\n')\n .trimStart();\n};\n\n// Fields that are auto-generated / internal and must not appear in frontmatter\nconst EXCLUDED_FRONTMATTER_KEYS = new Set<string>([\n 'content',\n '$schema',\n 'filePath',\n 'localId',\n 'localIds',\n 'projectIds',\n]);\n\nexport const writeMarkdownFile = async (\n absoluteFilePath: string,\n dictionary: Dictionary,\n configuration: IntlayerConfig\n): Promise<void> => {\n const content = dictionary.content as any;\n const markdownRaw =\n typeof content === 'object' && content?.nodeType === MARKDOWN\n ? (content[MARKDOWN] ?? '')\n : '';\n // content.markdown now stores the full file (frontmatter + body); extract only the body\n const markdownBody = getMarkdownBody(markdownRaw);\n\n const frontmatterFields = Object.fromEntries(\n Object.entries(dictionary).filter(\n ([k, v]) => !EXCLUDED_FRONTMATTER_KEYS.has(k) && v !== undefined\n )\n );\n\n const frontmatterStr = stringifyYamlFrontmatter(frontmatterFields);\n const fileContent = `---\\n${frontmatterStr}\\n---\\n\\n${markdownBody}`;\n\n const dir = dirname(absoluteFilePath);\n await mkdir(dir, { recursive: true });\n\n const tempDir = configuration.system?.tempDir;\n if (tempDir) await mkdir(tempDir, { recursive: true });\n\n const tempFileName = `${basename(absoluteFilePath)}.${Date.now()}-${Math.random().toString(36).slice(2)}.tmp`;\n const tempPath = tempDir\n ? join(tempDir, tempFileName)\n : `${absoluteFilePath}.${tempFileName}`;\n\n try {\n await writeFile(tempPath, fileContent, 'utf-8');\n await rename(tempPath, absoluteFilePath);\n } catch (error) {\n try {\n await rm(tempPath, { force: true });\n } catch {\n // ignore\n }\n throw error;\n }\n\n const formatCommand = detectFormatCommand(configuration);\n if (formatCommand) {\n try {\n execSync(formatCommand.replace('{{file}}', absoluteFilePath), {\n stdio: 'inherit',\n cwd: configuration.system.baseDir,\n });\n } catch (error) {\n console.error(error);\n }\n }\n};\n"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ACL,sBAAoB,kBAChB"}
1
+ {"version":3,"file":"rebuildDocument.d.ts","names":[],"sources":["../../../src/docReview/rebuildDocument.ts"],"mappings":";;;;;;YAMY;;EAEV,WAAW;;EAEX;;EAEA;;YAGU;EACV,YAAY;EACZ,cAAc;EACd,MAAM;;YAGI;EACV,kBAAkB;;;;;;;;;;qBAWP,6BAAwB,YAAA,cAAA,QAIlC,iBAAe;;;;;;;;;;qBAwDL,wBAAqB,MAC1B,eAAa,cACL,sBAAoB,kBAChB"}
@@ -1 +1 @@
1
- {"version":3,"file":"segmentDocument.d.ts","names":[],"sources":["../../../src/docReview/segmentDocument.ts"],"mappings":";;;;;;;;;;;;;;;;qBAoDa,kBAAe,iBAAmB;;;;;;;;;;;;;;;;;;;qBAuIlC,kBAAe,iBAAmB"}
1
+ {"version":3,"file":"segmentDocument.d.ts","names":[],"sources":["../../../src/docReview/segmentDocument.ts"],"mappings":";;;;;;;;;;;;;;;;qBAuDa,kBAAe,iBAAmB;;;;;;;;;;;;;;;;;;;qBAwIlC,kBAAe,iBAAmB"}
@@ -1 +1 @@
1
- {"version":3,"file":"transforms.d.ts","names":[],"sources":["../../../../../src/init/frameworkSetup/nextAppRouter/transforms.ts"],"mappings":";;YAWY;EACV;EACA;;;YA4KU;;;;;;EAMV;;;;;;;;;;;;;qBAcW,yBAAsB,gBACrB,uBACmB,sBAC9B"}
1
+ {"version":3,"file":"transforms.d.ts","names":[],"sources":["../../../../../src/init/frameworkSetup/nextAppRouter/transforms.ts"],"mappings":";;YAWY;EACV;EACA;;;YA6KU;;;;;;EAMV;;;;;;;;;;;;;qBAcW,yBAAsB,gBACrB,uBACmB,sBAC9B"}
@@ -1 +1 @@
1
- {"version":3,"file":"logTypeScriptErrors.d.ts","names":[],"sources":["../../../src/loadDictionaries/logTypeScriptErrors.ts"],"mappings":";;;;;;qBAoQa,sBAAmB,qBACX,eACJ,mBACd"}
1
+ {"version":3,"file":"logTypeScriptErrors.d.ts","names":[],"sources":["../../../src/loadDictionaries/logTypeScriptErrors.ts"],"mappings":";;;;;;qBAsRa,sBAAmB,qBACX,eACJ,mBACd"}
@@ -1 +1 @@
1
- {"version":3,"file":"analyzeBundleContent.d.ts","names":[],"sources":["../../../src/scan/analyzeBundleContent.ts"],"mappings":";;;;;;;;;;;qBA6Ka,uBAAoB,QACvB,oBAAkB,qBACP,uBACE,0BAEpB"}
1
+ {"version":3,"file":"analyzeBundleContent.d.ts","names":[],"sources":["../../../src/scan/analyzeBundleContent.ts"],"mappings":";;;;;;;;;;;qBAkNa,uBAAoB,QACvB,oBAAkB,qBACP,uBACE,0BAEpB"}
@@ -37,10 +37,13 @@ export declare const scoreRecord: {
37
37
  readonly url_htmlDir: 3;
38
38
  readonly url_hasCanonical: 10;
39
39
  readonly url_hreflang: 9;
40
+ readonly url_hreflangReciprocal: 8;
40
41
  readonly url_hasLocalizedLinks: 8;
41
42
  readonly url_hasXDefault: 7;
42
43
  readonly url_allAnchorsLocalized: 6;
43
- readonly url_currentLocale: 3;
44
+ readonly url_hasLangSelector: 6;
45
+ readonly url_currentLocale: 5;
46
+ readonly url_ogLocale: 3;
44
47
  readonly url_unusedBundleContent: 8;
45
48
  };
46
49
  /** Identifier of a scorable check (without the URL suffix). */
@@ -1 +1 @@
1
- {"version":3,"file":"calculateScore.d.ts","names":[],"sources":["../../../src/scan/calculateScore.ts"],"mappings":";;;;;;;;;;YAUY;;EAEV;;EAEA;;;;;;;;;YAUU;EACV;EACA;;;qBAgBW;WACX;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;;YAIU,8BAA8B;;;;;;;;;;qBAW7B,cAAW,OAAW,OAAK,OAAS,kBAAgB;;;;;;;qBAyBpD,iBAAc,OAAW"}
1
+ {"version":3,"file":"calculateScore.d.ts","names":[],"sources":["../../../src/scan/calculateScore.ts"],"mappings":";;;;;;;;;;YAUY;;EAEV;;EAEA;;;;;;;;;YAUU;EACV;EACA;;;qBAgBW;WACX;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;;YAIU,8BAA8B;;;;;;;;;;qBAW7B,cAAW,OAAW,OAAK,OAAS,kBAAgB;;;;;;;qBAyBpD,iBAAc,OAAW"}
@@ -1,36 +1,129 @@
1
+ import { RoutingDetection } from "./detection/detectRoutingStrategy.js";
1
2
  import { BundleChunkInput, BundleContentAnalysis, ScanEvent } from "./types.js";
2
- import { Anchor } from "./parseHtml.js";
3
+ import { ScanFetchOptions } from "./fetchText.js";
4
+ import { Anchor, HreflangLink } from "./parseHtml.js";
3
5
  //#region src/scan/checks.d.ts
6
+ /** Receives every check result as soon as it is produced. */
7
+ export type EmitScanEvent = (event: ScanEvent) => void;
8
+ /** Signals of the scanned page shared by the page-level checks. */
9
+ export type PageSignals = {
10
+ targetUrl: string;
11
+ langTag?: string;
12
+ dirTag?: string;
13
+ ogLocale?: string;
14
+ /** `og:locale:alternate` values. */
15
+ ogLocaleAlternates?: string[];
16
+ /** Raw `href` of the canonical link (`''` when present but empty). */
17
+ canonicalHref?: string;
18
+ hreflangs: HreflangLink[];
19
+ anchors: Anchor[];
20
+ routing: RoutingDetection;
21
+ /** Locale of the page: from its URL when possible, else `<html lang>`. */
22
+ pageLocale?: string;
23
+ };
4
24
  /** Format a byte count as a human-readable size. */
5
25
  export declare const formatSize: (bytes: number) => string;
26
+ /** `url_htmlLang`: `<html lang>` is present and a valid BCP 47 tag. */
27
+ export declare const checkHtmlLang: ({ targetUrl, langTag }: PageSignals, emit: EmitScanEvent) => void;
28
+ /**
29
+ * `url_htmlDir`: the text direction matches the language. `dir` is only
30
+ * required for right-to-left languages, `ltr` being the browser default.
31
+ */
32
+ export declare const checkHtmlDir: ({ targetUrl, langTag, dirTag }: PageSignals, emit: EmitScanEvent) => void;
33
+ /**
34
+ * `url_currentLocale`: the locale announced by `<html lang>`, the URL and the
35
+ * self hreflang entry agree.
36
+ */
37
+ export declare const checkLocaleConsistency: ({ targetUrl, langTag, hreflangs, routing }: PageSignals, emit: EmitScanEvent) => void;
38
+ /**
39
+ * `url_ogLocale`: `og:locale` is set, uses the Open Graph `language_TERRITORY`
40
+ * format (`en_GB`, not `en` nor `en-GB`) and matches `<html lang>`.
41
+ * `og:locale:alternate` values must use the same format.
42
+ */
43
+ export declare const checkOgLocale: ({ targetUrl, ogLocale, ogLocaleAlternates, langTag }: PageSignals, emit: EmitScanEvent) => void;
44
+ /**
45
+ * `url_hasCanonical`: a canonical link exists and does not point to another
46
+ * locale version (which would de-index the current one).
47
+ */
48
+ export declare const checkCanonical: ({ targetUrl, canonicalHref, hreflangs, routing, pageLocale }: PageSignals, emit: EmitScanEvent) => void;
49
+ /**
50
+ * `url_hreflang`: hreflang tags exist, use valid codes and absolute URLs, have
51
+ * no duplicates, and include a self reference.
52
+ */
53
+ export declare const checkHreflang: ({ targetUrl, hreflangs, canonicalHref }: PageSignals, emit: EmitScanEvent) => void;
54
+ /** `url_hasXDefault`: an `x-default` hreflang is declared. */
55
+ export declare const checkXDefault: ({ targetUrl, hreflangs }: PageSignals, emit: EmitScanEvent) => void;
56
+ /**
57
+ * `url_hreflangReciprocal`: every alternate answers with a 200, is not
58
+ * redirected, links back to this page and declares the expected language.
59
+ * Search engines ignore hreflang pairs without a return link.
60
+ */
61
+ export declare const checkHreflangReciprocity: ({ targetUrl, hreflangs, canonicalHref }: PageSignals, fetchOptions: ScanFetchOptions, emit: EmitScanEvent) => Promise<void>;
6
62
  /**
7
- * Check the `<html>` element attributes (`lang`, `dir`) and the resulting
8
- * current-locale signal. Returns the detected language tag.
63
+ * Link checks, interpreted through the detected routing strategy (so an
64
+ * unprefixed link is correct on the default locale of a `prefix-no-default`
65
+ * site, and `?lang=` links are understood on `search-params` sites):
66
+ *
67
+ * - `url_hasLocalizedLinks`: internal links keep the page locale
68
+ * - `url_allAnchorsLocalized`: no internal link loses or switches the locale
69
+ * - `url_hasLangSelector`: crawlable links to the other locale versions exist
9
70
  */
10
- export declare const checkHtmlAttributes: (html: string, targetUrl: string, events: ScanEvent[]) => {
11
- langTag: string | undefined;
71
+ export declare const checkInternalLinks: (signals: PageSignals, emit: EmitScanEvent) => void;
72
+ /** Human-readable version of a {@link BundleContentAnalysis}, for display. */
73
+ export declare const formatBundleAnalysis: (analysis: BundleContentAnalysis) => {
74
+ currentLocale: string;
75
+ totalPageSize: string;
76
+ renderedContentSize: string;
77
+ contentSize: string;
78
+ totalLocaleSize: string;
79
+ totalUnusedLocaleSize: string;
80
+ unusedPercentOfLocale: string;
81
+ mainBundleChunks: {
82
+ filename: string;
83
+ url: string;
84
+ fileSize: string;
85
+ totalLocaleSize: string;
86
+ usedLocaleSize: string;
87
+ unusedLocaleSize: string;
88
+ dictionariesFound: number;
89
+ unusedPercent: string;
90
+ }[];
91
+ lazyBundleChunks: {
92
+ filename: string;
93
+ url: string;
94
+ fileSize: string;
95
+ totalLocaleSize: string;
96
+ usedLocaleSize: string;
97
+ unusedLocaleSize: string;
98
+ dictionariesFound: number;
99
+ unusedPercent: string;
100
+ }[];
12
101
  };
13
- /** Check the presence of a canonical link. */
14
- export declare const checkCanonical: (html: string, targetUrl: string, events: ScanEvent[]) => void;
15
102
  /**
16
- * Check the page's hreflang structure and collect discovered locales into
17
- * `localesSet`.
103
+ * `url_unusedBundleContent`: share of other-locale translations shipped in the
104
+ * eagerly loaded bundles. Returns the raw analysis for reporting.
18
105
  */
19
- export declare const checkLinguisticStructure: (html: string, targetUrl: string, localesSet: Set<string>, events: ScanEvent[]) => void;
106
+ export declare const checkBundleContent: (chunks: BundleChunkInput[], html: string, currentLocale: string | undefined, targetUrl: string, totalPageSize: number, emit: EmitScanEvent) => BundleContentAnalysis | undefined;
20
107
  /**
21
- * Check whether internal links carry a locale segment, mirroring the hosted
22
- * audit's URL-structure analysis but operating on parsed anchors instead of a
23
- * live DOM.
108
+ * Fetch `robots.txt` and check that neither the site nor its localized URLs
109
+ * are blocked for Googlebot.
110
+ *
111
+ * - `robots_robotsPresent`
112
+ * - `robots_noLocalizedUrlsForgotten`
113
+ *
114
+ * @param localizedUrls - URLs of every locale version (hreflang alternates).
115
+ * @returns The sitemaps declared in `robots.txt`.
24
116
  */
25
- export declare const checkUrlStructure: (anchors: Anchor[], origin: string, targetUrl: string, events: ScanEvent[]) => void;
117
+ export declare const checkRobots: (origin: string, localizedUrls: string[], fetchOptions: ScanFetchOptions, emit: EmitScanEvent) => Promise<string[]>;
26
118
  /**
27
- * Analyze the JavaScript bundles for unused locale content and emit the
28
- * corresponding event. Returns the analysis so callers can report on it.
119
+ * Read the sitemaps (declared in `robots.txt`, else the default locations,
120
+ * following sitemap indexes) and check their locale coverage.
121
+ *
122
+ * - `sitemap_sitemapPresent`
123
+ * - `sitemap_noLocalizedUrlsForgotten`: every locale is listed, and entries
124
+ * declaring alternates declare all of them
125
+ * - `sitemap_hasAlternates` / `sitemap_hasXDefault`
29
126
  */
30
- export declare const checkBundleContent: (chunks: BundleChunkInput[], html: string, currentLocale: string | undefined, targetUrl: string, totalPageSize: number, events: ScanEvent[]) => BundleContentAnalysis | undefined;
31
- /** Fetch and check `robots.txt`, emitting robots-related events. */
32
- export declare const checkRobots: (origin: string, discoveredLocales: Set<string>, userAgent: string, events: ScanEvent[]) => Promise<void>;
33
- /** Fetch and check `sitemap.xml`, emitting sitemap-related events. */
34
- export declare const checkSitemap: (origin: string, discoveredLocales: Set<string>, userAgent: string, events: ScanEvent[]) => Promise<void>;
127
+ export declare const checkSitemap: (origin: string, declaredSitemapUrls: string[], routing: RoutingDetection, fetchOptions: ScanFetchOptions, emit: EmitScanEvent) => Promise<void>;
35
128
  //#endregion
36
129
  //# sourceMappingURL=checks.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"checks.d.ts","names":[],"sources":["../../../src/scan/checks.ts"],"mappings":";;;;qBAgBa,aAAU;;;;;qBAUV,sBAAmB,cAClB,mBACK,QACT;EACL;;;qBAmCQ,iBAAc,cACb,mBACK,QACT;;;;;qBAcG,2BAAwB,cACvB,mBACK,YACL,aAAW,QACf;;;;;;qBAwCG,oBAAiB,SACnB,UAAQ,gBACH,mBACG,QACT;;;;;qBAwEG,qBAAkB,QACrB,oBAAkB,cACd,mCACqB,mBAChB,uBACI,QACb,gBACP;;qBA0CU,cAAW,gBACR,mBACK,aAAW,mBACb,QACT,gBACP;;qBA0DU,eAAY,gBACT,mBACK,aAAW,mBACb,QACT,gBACP"}
1
+ {"version":3,"file":"checks.d.ts","names":[],"sources":["../../../src/scan/checks.ts"],"mappings":";;;;;;YAkCY,iBAAiB,OAAO;;YAGxB;EACV;EACA;EACA;EACA;;EAEA;;EAEA;EACA,WAAW;EACX,SAAS;EACT,SAAS;;EAET;;;qBAWW,aAAU;;qBAgCV,kBAAa,WAAA,WACA,aAAW,MAC7B;;;;;qBAqBK,iBAAY,WAAA,SAAA,UACS,aAAW,MACrC;;;;;qBAuCK,2BAAsB,WAAA,SAAA,WAAA,WACW,aAAW,MACjD;;;;;;qBA4DK,kBAAa,WAAA,UAAA,oBAAA,WACmC,aAAW,MAChE;;;;;qBAmEK,mBAAc,WAAA,eAAA,WAAA,SAAA,cACqC,aAAW,MACnE;;;;;qBAgDK,kBAAa,WAAA,WAAA,iBACiB,aAAW,MAC9C;;qBAgFK,kBAAa,WAAA,aACE,aAAW,MAC/B;;;;;;qBA4EK,6BAAwB,WAAA,WAAA,iBACM,aAAW,cACtC,kBAAgB,MACxB,kBACL;;;;;;;;;;qBAkFU,qBAAkB,SACpB,aAAW,MACd;;qBAwFK,uBAAoB,UAAc;EAC7C;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;;;;;;;;EACA;;;;;;;;;;;;;;;qBAOW,qBAAkB,QACrB,oBAAkB,cACd,mCACqB,mBAChB,uBACI,MACf,kBACL;;;;;;;;;;;qBAoDU,cAAW,gBACR,yBACS,cACT,kBAAgB,MACxB,kBACL;;;;;;;;;;qBAwDU,eAAY,gBACT,+BACe,SACpB,kBAAgB,cACX,kBAAgB,MACxB,kBACL"}
@@ -0,0 +1,29 @@
1
+ //#region src/scan/detection/checkDetails.d.ts
2
+ /** Details of a scan check, split for display. */
3
+ export type CheckDetailParts = {
4
+ /** Explanation of the check result. */
5
+ message?: string;
6
+ /** Offending `<a>` elements, as HTML source. */
7
+ links: string[];
8
+ /** Other listed items: issues, hreflang alternates, URLs… */
9
+ items: string[];
10
+ };
11
+ /**
12
+ * Split the details attached to a scan check into its message, the listed
13
+ * links (HTML source) and the other listed items. Shapes without any of them
14
+ * (bundle summaries, hreflang lists…) return empty lists.
15
+ *
16
+ * @param details - The `success` / `warning` / `error` payload of a check.
17
+ */
18
+ export declare const splitCheckDetails: (details: unknown) => CheckDetailParts;
19
+ /**
20
+ * Turn the details attached to a scan check into short printable lines: its
21
+ * message, then the listed issues / links / URLs. Shared by the CLI report and
22
+ * the Chrome extension popup.
23
+ *
24
+ * @param details - The `success` / `warning` / `error` payload of a check.
25
+ * @returns The message first, then one line per listed item.
26
+ */
27
+ export declare const getCheckDetailLines: (details: unknown) => string[];
28
+ //#endregion
29
+ //# sourceMappingURL=checkDetails.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checkDetails.d.ts","names":[],"sources":["../../../../src/scan/detection/checkDetails.ts"],"mappings":";;YACY;;EAEV;;EAEA;;EAEA;;;;;;;;;qBAUW,oBAAiB,qBAAuB;;;;;;;;;qBAkCxC,sBAAmB"}
@@ -0,0 +1,44 @@
1
+ import { RoutingDetection } from "./detectRoutingStrategy.js";
2
+ //#region src/scan/detection/classifyInternalLinks.d.ts
3
+ /** A page anchor, as parsed from HTML or read from a live DOM. */
4
+ export type LinkAnchor = {
5
+ href: string;
6
+ text: string;
7
+ /** `hreflang` attribute, set on language-switcher links. */
8
+ hreflang?: string;
9
+ };
10
+ /** Input of {@link classifyInternalLinks}. */
11
+ export type LinkClassificationInput<Anchor extends LinkAnchor> = {
12
+ /** Absolute URL of the page holding the anchors. */
13
+ targetUrl: string;
14
+ anchors: Anchor[];
15
+ hreflangs: {
16
+ hreflang: string;
17
+ href: string;
18
+ }[];
19
+ routing: RoutingDetection;
20
+ /** Locale of the page. */
21
+ pageLocale?: string;
22
+ };
23
+ /** Internal anchors of a page, grouped by the locale they lead to. */
24
+ export type LinkClassification<Anchor extends LinkAnchor> = {
25
+ /** Internal page links, language-switcher links excluded. */
26
+ internalLinks: Anchor[];
27
+ /** Internal links keeping the page locale. */
28
+ sameLocaleLinks: Anchor[];
29
+ /** Internal links leading to another locale. */
30
+ otherLocaleLinks: Anchor[];
31
+ /** Internal links whose URL carries no locale. */
32
+ unlocalizedLinks: Anchor[];
33
+ /** Links to the other locale versions (hreflang alternates). */
34
+ switcherLinks: Anchor[];
35
+ };
36
+ /**
37
+ * Group the internal anchors of a page by the locale they lead to, reading
38
+ * each URL through the detected routing strategy (so unprefixed links count as
39
+ * the default locale on a `prefix-no-default` site, and `?lang=` is understood
40
+ * on a `search-params` site).
41
+ */
42
+ export declare const classifyInternalLinks: <Anchor extends LinkAnchor>({ targetUrl, anchors, hreflangs, routing, pageLocale }: LinkClassificationInput<Anchor>) => LinkClassification<Anchor>;
43
+ //#endregion
44
+ //# sourceMappingURL=classifyInternalLinks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"classifyInternalLinks.d.ts","names":[],"sources":["../../../../src/scan/detection/classifyInternalLinks.ts"],"mappings":";;;YAKY;EACV;EACA;;EAEA;;;YAIU,wBAAwB,eAAe;;EAEjD;EACA,SAAS;EACT;IAAa;IAAkB;;EAC/B,SAAS;;EAET;;;YAIU,mBAAmB,eAAe;;EAE5C,eAAe;;EAEf,iBAAiB;;EAEjB,kBAAkB;;EAElB,kBAAkB;;EAElB,eAAe;;;;;;;;qBAYJ,wBAAyB,eAAe,cAAU,WAAA,SAAA,WAAA,SAAA,cAM5D,wBAAwB,YAAU,mBAAmB"}
@@ -0,0 +1,60 @@
1
+ //#region src/scan/detection/detectRoutingStrategy.d.ts
2
+ /**
3
+ * How a website exposes its locales in URLs. Mirrors Intlayer's
4
+ * `routing.mode` values, plus the domain-based strategies.
5
+ *
6
+ * - `prefix-all`: every locale is prefixed (`/en/about`, `/fr/about`)
7
+ * - `prefix-no-default`: the default locale is not prefixed (`/about`, `/fr/about`)
8
+ * - `search-params`: the locale is a query parameter (`/about?lang=fr`)
9
+ * - `subdomain`: the locale is a subdomain (`fr.example.com`)
10
+ * - `domain`: one domain per locale (`example.fr`, `example.de`)
11
+ * - `no-prefix`: a single URL serves every locale (cookie / header based)
12
+ * - `unknown`: not enough signals to decide
13
+ */
14
+ export type RoutingStrategy = 'prefix-all' | 'prefix-no-default' | 'search-params' | 'subdomain' | 'domain' | 'no-prefix' | 'unknown';
15
+ /** Result of {@link detectRoutingStrategy}. */
16
+ export type RoutingDetection = {
17
+ strategy: RoutingStrategy;
18
+ /**
19
+ * `high` when inferred from the hreflang alternates, `low` when guessed from
20
+ * the scanned URL alone.
21
+ */
22
+ confidence: 'high' | 'low';
23
+ /** Locales known to the site (hreflang values, else the page `lang`). */
24
+ locales: string[];
25
+ /** Locale served without any marker (`prefix-no-default`, `search-params`…). */
26
+ defaultLocale?: string;
27
+ /** Query parameter carrying the locale, for `search-params`. */
28
+ searchParamName?: string;
29
+ /** Hostname → locale map, for `subdomain` / `domain`. */
30
+ hostLocales?: Record<string, string>;
31
+ /** Locale of the scanned page according to its URL alone. */
32
+ urlLocale?: string;
33
+ /** Human-readable explanation of the decision. */
34
+ evidence: string;
35
+ };
36
+ /** Input of {@link detectRoutingStrategy}. */
37
+ export type RoutingDetectionInput = {
38
+ /** Absolute URL of the scanned page. */
39
+ pageUrl: string;
40
+ /** Value of `<html lang>`, when present. */
41
+ htmlLang?: string;
42
+ /** `<link rel="alternate" hreflang>` entries of the page. */
43
+ hreflangs: {
44
+ hreflang: string;
45
+ href: string;
46
+ }[];
47
+ };
48
+ /** Locale of a URL according to an already-detected routing strategy. */
49
+ export declare const getUrlLocale: (url: string, routing: RoutingDetection) => string | undefined;
50
+ /**
51
+ * Detect how the site encodes the locale in its URLs (path prefix, query
52
+ * parameter, subdomain, domain or nothing).
53
+ *
54
+ * The hreflang alternates are the most reliable signal: each one pairs a
55
+ * locale with its URL, so the shared pattern reveals the strategy. Without
56
+ * alternates the scanned URL alone is used, with `confidence: 'low'`.
57
+ */
58
+ export declare const detectRoutingStrategy: ({ pageUrl, htmlLang, hreflangs }: RoutingDetectionInput) => RoutingDetection;
59
+ //#endregion
60
+ //# sourceMappingURL=detectRoutingStrategy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"detectRoutingStrategy.d.ts","names":[],"sources":["../../../../src/scan/detection/detectRoutingStrategy.ts"],"mappings":";;;;;;;;;;;;;YAoBY;;YAUA;EACV,UAAU;;;;;EAKV;;EAEA;;EAEA;;EAEA;;EAEA,cAAc;;EAEd;;EAEA;;;YAIU;;EAEV;;EAEA;;EAEA;IAAa;IAAkB;;;;qBAMpB,eAAY,aACZ,SACF;;;;;;;;;qBA+ME,0BAAqB,SAAA,UAAA,aAI/B,0BAAwB"}
@@ -0,0 +1,60 @@
1
+ import { TechnologyCategory, TechnologySignature } from "./technologySignatures.js";
2
+ //#region src/scan/detection/detectTechnologies.d.ts
3
+ /** A technology detected on the scanned page. */
4
+ export type DetectedTechnology = {
5
+ /** Stable identifier, e.g. `nextjs`, `crowdin`. */
6
+ id: string;
7
+ /** Human-readable name, e.g. `Next.js`. */
8
+ name: string;
9
+ category: TechnologyCategory;
10
+ /** Version when it can be read from the page, e.g. `14.2.3`. */
11
+ version?: string;
12
+ /** Short explanation of the signal that triggered the detection. */
13
+ evidence: string;
14
+ };
15
+ /**
16
+ * Raw signals collected from a page. Every field is optional so each consumer
17
+ * provides what it can: the CLI basic mode only has HTML + scripts, the
18
+ * backend and the extension also read window globals and storage keys.
19
+ */
20
+ export type TechnologyDetectionInput = {
21
+ /**
22
+ * URL of the scanned page. Resource URLs on its own site are ignored for
23
+ * third-party services, so the Crowdin website is not reported as using
24
+ * Crowdin because it loads its own favicon.
25
+ */
26
+ pageUrl?: string;
27
+ /** HTML document, inline scripts included. */
28
+ html?: string;
29
+ /** Script / stylesheet / iframe / network request URLs. */
30
+ resourceUrls?: string[];
31
+ /** Contents of the same-origin JavaScript chunks. */
32
+ scripts?: string[];
33
+ /** Names of the window globals that exist on the page. */
34
+ globals?: string[];
35
+ /** Cookie / web-storage keys found on the page. */
36
+ storageKeys?: string[];
37
+ /** Live-DOM markers, see {@link TechnologySignature.domMarkers}. */
38
+ domMarkers?: string[];
39
+ /** Values read from {@link TechnologySignature.versionGlobal} paths. */
40
+ globalVersions?: Record<string, string>;
41
+ };
42
+ /**
43
+ * Every window global and version path referenced by the signatures. Live-page
44
+ * collectors (extension, puppeteer) read these and pass back the ones present.
45
+ */
46
+ export declare const getTechnologyGlobalNames: () => {
47
+ globals: string[];
48
+ versionGlobals: string[];
49
+ };
50
+ /**
51
+ * Detect the frameworks, i18n libraries, TMS and translation proxies used by a
52
+ * page from the raw signals collected on it.
53
+ *
54
+ * @param input - The {@link TechnologyDetectionInput} signals.
55
+ * @param signatures - Fingerprints to test, defaults to {@link technologySignatures}.
56
+ * @returns Detected technologies, in signature order.
57
+ */
58
+ export declare const detectTechnologies: (input: TechnologyDetectionInput, signatures?: readonly TechnologySignature[]) => DetectedTechnology[];
59
+ //#endregion
60
+ //# sourceMappingURL=detectTechnologies.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"detectTechnologies.d.ts","names":[],"sources":["../../../../src/scan/detection/detectTechnologies.ts"],"mappings":";;;YAQY;;EAEV;;EAEA;EACA,UAAU;;EAEV;;EAEA;;;;;;;YAQU;;;;;;EAMV;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA,iBAAiB;;;;;;qBAmGN;EACX;EACA;;;;;;;;;;qBAoBW,qBAAkB,OACtB,0BAAwB,sBACV,0BACpB"}