@intlayer/chokidar 8.12.4 → 9.0.0-canary.0

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 (88) hide show
  1. package/dist/cjs/buildIntlayerDictionary/buildIntlayerDictionary.cjs +21 -4
  2. package/dist/cjs/buildIntlayerDictionary/buildIntlayerDictionary.cjs.map +1 -1
  3. package/dist/cjs/buildIntlayerDictionary/writeDynamicDictionary.cjs +94 -0
  4. package/dist/cjs/buildIntlayerDictionary/writeDynamicDictionary.cjs.map +1 -1
  5. package/dist/cjs/buildIntlayerDictionary/writeMergedDictionary.cjs +1 -1
  6. package/dist/cjs/buildIntlayerDictionary/writeMergedDictionary.cjs.map +1 -1
  7. package/dist/cjs/createType/createType.cjs.map +1 -1
  8. package/dist/cjs/init/index.cjs +63 -9
  9. package/dist/cjs/init/index.cjs.map +1 -1
  10. package/dist/cjs/init/utils/configManipulation.cjs +196 -0
  11. package/dist/cjs/init/utils/configManipulation.cjs.map +1 -1
  12. package/dist/cjs/init/utils/fileSystem.cjs +84 -0
  13. package/dist/cjs/init/utils/fileSystem.cjs.map +1 -1
  14. package/dist/cjs/init/utils/index.cjs +12 -0
  15. package/dist/cjs/init/utils/packageManager.cjs +187 -0
  16. package/dist/cjs/init/utils/packageManager.cjs.map +1 -0
  17. package/dist/cjs/scan/analyzeBundleContent.cjs +182 -0
  18. package/dist/cjs/scan/analyzeBundleContent.cjs.map +1 -0
  19. package/dist/cjs/scan/calculateScore.cjs +65 -0
  20. package/dist/cjs/scan/calculateScore.cjs.map +1 -0
  21. package/dist/cjs/scan/checks.cjs +274 -0
  22. package/dist/cjs/scan/checks.cjs.map +1 -0
  23. package/dist/cjs/scan/index.cjs +31 -0
  24. package/dist/cjs/scan/parseHtml.cjs +127 -0
  25. package/dist/cjs/scan/parseHtml.cjs.map +1 -0
  26. package/dist/cjs/scan/scanWebsite.cjs +205 -0
  27. package/dist/cjs/scan/scanWebsite.cjs.map +1 -0
  28. package/dist/cjs/scan/types.cjs +0 -0
  29. package/dist/esm/buildIntlayerDictionary/buildIntlayerDictionary.mjs +22 -5
  30. package/dist/esm/buildIntlayerDictionary/buildIntlayerDictionary.mjs.map +1 -1
  31. package/dist/esm/buildIntlayerDictionary/writeDynamicDictionary.mjs +93 -1
  32. package/dist/esm/buildIntlayerDictionary/writeDynamicDictionary.mjs.map +1 -1
  33. package/dist/esm/buildIntlayerDictionary/writeMergedDictionary.mjs +2 -2
  34. package/dist/esm/buildIntlayerDictionary/writeMergedDictionary.mjs.map +1 -1
  35. package/dist/esm/createType/createType.mjs.map +1 -1
  36. package/dist/esm/init/index.mjs +65 -11
  37. package/dist/esm/init/index.mjs.map +1 -1
  38. package/dist/esm/init/utils/configManipulation.mjs +190 -1
  39. package/dist/esm/init/utils/configManipulation.mjs.map +1 -1
  40. package/dist/esm/init/utils/fileSystem.mjs +83 -1
  41. package/dist/esm/init/utils/fileSystem.mjs.map +1 -1
  42. package/dist/esm/init/utils/index.mjs +4 -3
  43. package/dist/esm/init/utils/packageManager.mjs +183 -0
  44. package/dist/esm/init/utils/packageManager.mjs.map +1 -0
  45. package/dist/esm/scan/analyzeBundleContent.mjs +180 -0
  46. package/dist/esm/scan/analyzeBundleContent.mjs.map +1 -0
  47. package/dist/esm/scan/calculateScore.mjs +61 -0
  48. package/dist/esm/scan/calculateScore.mjs.map +1 -0
  49. package/dist/esm/scan/checks.mjs +265 -0
  50. package/dist/esm/scan/checks.mjs.map +1 -0
  51. package/dist/esm/scan/index.mjs +7 -0
  52. package/dist/esm/scan/parseHtml.mjs +115 -0
  53. package/dist/esm/scan/parseHtml.mjs.map +1 -0
  54. package/dist/esm/scan/scanWebsite.mjs +203 -0
  55. package/dist/esm/scan/scanWebsite.mjs.map +1 -0
  56. package/dist/esm/scan/types.mjs +0 -0
  57. package/dist/types/buildIntlayerDictionary/buildIntlayerDictionary.d.ts.map +1 -1
  58. package/dist/types/buildIntlayerDictionary/writeDynamicDictionary.d.ts +31 -4
  59. package/dist/types/buildIntlayerDictionary/writeDynamicDictionary.d.ts.map +1 -1
  60. package/dist/types/buildIntlayerDictionary/writeMergedDictionary.d.ts +13 -3
  61. package/dist/types/buildIntlayerDictionary/writeMergedDictionary.d.ts.map +1 -1
  62. package/dist/types/createType/createType.d.ts +3 -3
  63. package/dist/types/createType/createType.d.ts.map +1 -1
  64. package/dist/types/formatDictionary.d.ts +9 -2
  65. package/dist/types/formatDictionary.d.ts.map +1 -1
  66. package/dist/types/init/index.d.ts.map +1 -1
  67. package/dist/types/init/utils/configManipulation.d.ts +42 -1
  68. package/dist/types/init/utils/configManipulation.d.ts.map +1 -1
  69. package/dist/types/init/utils/fileSystem.d.ts +31 -1
  70. package/dist/types/init/utils/fileSystem.d.ts.map +1 -1
  71. package/dist/types/init/utils/index.d.ts +4 -3
  72. package/dist/types/init/utils/packageManager.d.ts +59 -0
  73. package/dist/types/init/utils/packageManager.d.ts.map +1 -0
  74. package/dist/types/intlayer/dist/types/index.d.ts +4 -0
  75. package/dist/types/scan/analyzeBundleContent.d.ts +16 -0
  76. package/dist/types/scan/analyzeBundleContent.d.ts.map +1 -0
  77. package/dist/types/scan/calculateScore.d.ts +65 -0
  78. package/dist/types/scan/calculateScore.d.ts.map +1 -0
  79. package/dist/types/scan/checks.d.ts +38 -0
  80. package/dist/types/scan/checks.d.ts.map +1 -0
  81. package/dist/types/scan/index.d.ts +7 -0
  82. package/dist/types/scan/parseHtml.d.ts +54 -0
  83. package/dist/types/scan/parseHtml.d.ts.map +1 -0
  84. package/dist/types/scan/scanWebsite.d.ts +18 -0
  85. package/dist/types/scan/scanWebsite.d.ts.map +1 -0
  86. package/dist/types/scan/types.d.ts +76 -0
  87. package/dist/types/scan/types.d.ts.map +1 -0
  88. package/package.json +17 -9
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scanWebsite.mjs","names":[],"sources":["../../../src/scan/scanWebsite.ts"],"sourcesContent":["import { GREY, GREY_LIGHT } from '@intlayer/config/colors';\nimport { colorize, logger } from '@intlayer/config/logger';\nimport { mutateScore, type Score, toScorePercent } from './calculateScore';\nimport {\n checkBundleContent,\n checkCanonical,\n checkHtmlAttributes,\n checkLinguisticStructure,\n checkRobots,\n checkSitemap,\n checkUrlStructure,\n} from './checks';\nimport { byteLength, extractAnchors, extractScriptUrls } from './parseHtml';\nimport type {\n BundleChunkInput,\n ScanEvent,\n ScanOptions,\n ScanResult,\n} from './types';\n\nconst DEFAULT_USER_AGENT =\n 'Mozilla/5.0 (compatible; IntlayerScanBot/1.0; +https://intlayer.org)';\nconst DEFAULT_TIMEOUT_MS = 30_000;\n\n/**\n * Log a recommendation to install `puppeteer` for a deeper scan. Mirrors the\n * style used by other optional-dependency hints across the CLI.\n */\nconst logDeepScanRecommendation = (): void => {\n logger([\n colorize('Recommended: Install', GREY),\n colorize('puppeteer', GREY_LIGHT),\n colorize(\n 'package to enable a deeper scan (renders client-side content & lazy-loaded chunks). See documentation:',\n GREY\n ),\n colorize('https://intlayer.org/doc/concept/cli#scan', GREY_LIGHT),\n ]);\n};\n\n/** Outcome of a render-based deep scan. */\ntype DeepScanResult = {\n html: string;\n totalPageSize: number;\n chunks: BundleChunkInput[];\n};\n\n/**\n * Render the page with a locally installed `puppeteer` to capture\n * client-rendered content, the accurate transfer size, and lazy-loaded chunks.\n *\n * `puppeteer` is imported dynamically through a non-literal specifier so it is\n * never bundled and stays an optional dependency: when it is absent the import\n * rejects and the caller falls back to the basic scan.\n *\n * @returns The deep-scan result, or `null` when `puppeteer` is unavailable.\n */\nconst runDeepScan = async (\n targetUrl: string,\n userAgent: string,\n timeoutMs: number\n): Promise<DeepScanResult | null> => {\n const moduleName = 'puppeteer';\n // Optional dependency resolved at runtime — typed as `any` because it is not\n // a declared dependency of this package.\n let puppeteer: any;\n try {\n const mod: any = await import(moduleName);\n puppeteer = mod.default ?? mod;\n } catch {\n return null;\n }\n\n let browser: any;\n try {\n browser = await puppeteer.launch({\n headless: true,\n executablePath: process.env.PUPPETEER_EXECUTABLE_PATH,\n args: [\n '--no-sandbox',\n '--disable-setuid-sandbox',\n '--disable-dev-shm-usage',\n '--disable-gpu',\n ],\n });\n\n const page = await browser.newPage();\n await page.setUserAgent(userAgent);\n await page.setExtraHTTPHeaders({ 'Accept-Language': 'en-US,en;q=0.9' });\n\n const origin = new URL(targetUrl).origin;\n const jsResponseMap = new Map<string, string>();\n let totalPageSize = 0;\n const pendingResponses: Promise<void>[] = [];\n\n page.on('response', (response: any) => {\n pendingResponses.push(\n (async () => {\n try {\n if (response.status() !== 200) return;\n const buffer = await response.buffer();\n totalPageSize += buffer.length;\n\n const responseUrl: string = response.url();\n const contentType: string =\n response.headers()['content-type'] ?? '';\n const isJavaScript =\n contentType.includes('javascript') ||\n /\\.(js|mjs|cjs)(\\?|$)/.test(responseUrl);\n if (isJavaScript && responseUrl.startsWith(origin)) {\n jsResponseMap.set(responseUrl, buffer.toString('utf-8'));\n }\n } catch {\n /* response already consumed or aborted */\n }\n })()\n );\n });\n\n await page.goto(targetUrl, {\n waitUntil: 'domcontentloaded',\n timeout: timeoutMs,\n });\n await page\n .waitForNetworkIdle({ idleTime: 1000, timeout: 10_000 })\n .catch(() => {\n /* ok if it never fully idles */\n });\n await Promise.allSettled(pendingResponses);\n\n const html: string = await page.content();\n const mainBundleUrls = new Set(extractScriptUrls(html, targetUrl));\n const chunks: BundleChunkInput[] = Array.from(jsResponseMap.entries()).map(\n ([url, content]) => ({\n url,\n isMainBundle: mainBundleUrls.has(url),\n content,\n })\n );\n\n return { html, totalPageSize, chunks };\n } finally {\n if (browser) await browser.close();\n }\n};\n\n/** Fetch the raw HTML document, measuring its byte size. */\nconst fetchHtml = async (\n url: string,\n userAgent: string,\n timeoutMs: number\n): Promise<{ html: string; finalUrl: string }> => {\n const controller = new AbortController();\n const timer = setTimeout(() => controller.abort(), timeoutMs);\n try {\n const response = await fetch(url, {\n headers: { 'User-Agent': userAgent, 'Accept-Language': 'en-US,en;q=0.9' },\n signal: controller.signal,\n });\n const html = await response.text();\n return { html, finalUrl: response.url || url };\n } finally {\n clearTimeout(timer);\n }\n};\n\n/**\n * Fetch every eagerly-loaded script. Same-origin scripts keep their content so\n * their locale weight can be analyzed; third-party scripts only contribute to\n * the measured page size (their locale-like keys cause false positives).\n */\nconst fetchScripts = async (\n scriptUrls: string[],\n origin: string,\n userAgent: string\n): Promise<{ chunks: BundleChunkInput[]; scriptBytes: number }> => {\n const chunks: BundleChunkInput[] = [];\n let scriptBytes = 0;\n\n await Promise.all(\n scriptUrls.map(async (scriptUrl) => {\n try {\n const response = await fetch(scriptUrl, {\n headers: { 'User-Agent': userAgent },\n });\n if (!response.ok) return;\n const content = await response.text();\n scriptBytes += byteLength(content);\n if (scriptUrl.startsWith(origin)) {\n chunks.push({ url: scriptUrl, isMainBundle: true, content });\n }\n } catch {\n /* ignore unreachable scripts */\n }\n })\n );\n\n return { chunks, scriptBytes };\n};\n\n/**\n * Scan a single web page for i18n/SEO health and bundle weight.\n *\n * In `deep` mode (default) the page is rendered with a locally installed\n * `puppeteer`; when `puppeteer` is missing the scan transparently falls back to\n * a `basic` fetch-based pass and logs a recommendation to install it.\n *\n * @param targetUrl - The absolute URL to scan.\n * @param options - {@link ScanOptions} controlling depth, timeout and UA.\n * @returns The {@link ScanResult} including score, page size and per-check events.\n */\nexport const scanWebsite = async (\n targetUrl: string,\n options: ScanOptions = {}\n): Promise<ScanResult> => {\n const {\n deep = true,\n timeoutMs = DEFAULT_TIMEOUT_MS,\n userAgent = DEFAULT_USER_AGENT,\n } = options;\n\n const origin = new URL(targetUrl).origin;\n\n let mode: ScanResult['mode'] = 'basic';\n let html: string;\n let totalPageSize: number;\n let chunks: BundleChunkInput[];\n\n const deepResult = deep\n ? await runDeepScan(targetUrl, userAgent, timeoutMs)\n : null;\n\n if (deepResult) {\n mode = 'deep';\n html = deepResult.html;\n chunks = deepResult.chunks;\n totalPageSize = deepResult.totalPageSize;\n } else {\n if (deep) logDeepScanRecommendation();\n const { html: fetchedHtml, finalUrl } = await fetchHtml(\n targetUrl,\n userAgent,\n timeoutMs\n );\n html = fetchedHtml;\n const scriptUrls = extractScriptUrls(fetchedHtml, finalUrl);\n const { chunks: fetchedChunks, scriptBytes } = await fetchScripts(\n scriptUrls,\n origin,\n userAgent\n );\n chunks = fetchedChunks;\n totalPageSize = byteLength(fetchedHtml) + scriptBytes;\n }\n\n const htmlSize = byteLength(html);\n\n const events: ScanEvent[] = [];\n const localesSet = new Set<string>();\n\n const { langTag } = checkHtmlAttributes(html, targetUrl, events);\n checkCanonical(html, targetUrl, events);\n checkLinguisticStructure(html, targetUrl, localesSet, events);\n checkUrlStructure(extractAnchors(html), origin, targetUrl, events);\n const bundle = checkBundleContent(\n chunks,\n html,\n langTag,\n targetUrl,\n totalPageSize,\n events\n );\n await checkRobots(origin, localesSet, userAgent, events);\n await checkSitemap(origin, localesSet, userAgent, events);\n\n const rawScore = events.reduce<Score>(\n (score, event) => mutateScore(score, event),\n { score: 0, totalScore: 0 }\n );\n\n return {\n url: targetUrl,\n mode,\n totalPageSize,\n htmlSize,\n score: toScorePercent(rawScore),\n rawScore,\n events,\n locales: Array.from(localesSet),\n bundle,\n };\n};\n"],"mappings":"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"}
File without changes
@@ -1 +1 @@
1
- {"version":3,"file":"buildIntlayerDictionary.d.ts","names":[],"sources":["../../../src/buildIntlayerDictionary/buildIntlayerDictionary.ts"],"mappings":";;;;;;;;KAYY,wBAAA,GAA2B,OAAA;EACrC,OAAA,SAAgB,aAAA;EAChB,uBAAA;EACA,GAAA;AAAA;;;;cAYW,eAAA,GACX,wBAAA,EAA0B,UAAA,IAC1B,aAAA,EAAe,cAAA,EACf,OAAA,GAAU,wBAAA,KAAwB,OAAA;wBAAA,wBAAA"}
1
+ {"version":3,"file":"buildIntlayerDictionary.d.ts","names":[],"sources":["../../../src/buildIntlayerDictionary/buildIntlayerDictionary.ts"],"mappings":";;;;;;;;KAmBY,wBAAA,GAA2B,OAAA;EACrC,OAAA,SAAgB,aAAA;EAChB,uBAAA;EACA,GAAA;AAAA;;;;cAYW,eAAA,GACX,wBAAA,EAA0B,UAAA,IAC1B,aAAA,EAAe,cAAA,EACf,OAAA,GAAU,wBAAA,KAAwB,OAAA;wBAAA,wBAAA"}
@@ -1,6 +1,6 @@
1
- import { MergedDictionaryOutput } from "./writeMergedDictionary.js";
1
+ import { PlainMergedDictionaryOutput } from "./writeMergedDictionary.js";
2
2
  import { IntlayerConfig } from "@intlayer/types/config";
3
- import { Dictionary } from "@intlayer/types/dictionary";
3
+ import { Dictionary, DictionaryQualifierType, QualifiedDictionaryGroup } from "@intlayer/types/dictionary";
4
4
  import { Locale } from "@intlayer/types/allLocales";
5
5
 
6
6
  //#region src/buildIntlayerDictionary/writeDynamicDictionary.d.ts
@@ -14,6 +14,17 @@ type LocalizedDictionaryOutput = Record<string, LocalizedDictionaryResult>;
14
14
  * Generates the content of a dictionary entry point file.
15
15
  */
16
16
  declare const generateDictionaryEntryPoint: (key: string, locales: string[], format?: "cjs" | "esm") => string;
17
+ /**
18
+ * Generates the entry point of a qualified dictionary (collection / variant /
19
+ * meta record, possibly combined). Under each locale the loader map nests one
20
+ * level per declared dimension (canonical order) and carries a marker listing
21
+ * those dimensions so the runtime can walk the tree.
22
+ *
23
+ * One static `import()` is emitted per leaf `(locale, …segments)` chunk, which
24
+ * keeps the output compatible with bundlers that reject template-literal
25
+ * dynamic imports (Turbopack).
26
+ */
27
+ declare const generateQualifiedDictionaryEntryPoint: (key: string, qualifierTypes: DictionaryQualifierType[], entriesSegments: string[][], locales: string[], format?: "cjs" | "esm") => string;
17
28
  /**
18
29
  * Write the localized dictionaries to the dictionariesDir
19
30
  * @param mergedDictionaries - The merged dictionaries
@@ -30,7 +41,23 @@ declare const generateDictionaryEntryPoint: (key: string, locales: string[], for
30
41
  * // .intlayer/dynamic_dictionary/dictionaries/fr_home.json
31
42
  * ```
32
43
  */
33
- declare const writeDynamicDictionary: (mergedDictionaries: MergedDictionaryOutput, configuration: IntlayerConfig, formats?: ("cjs" | "esm")[]) => Promise<LocalizedDictionaryOutput>;
44
+ declare const writeDynamicDictionary: (mergedDictionaries: PlainMergedDictionaryOutput, configuration: IntlayerConfig, formats?: ("cjs" | "esm")[]) => Promise<LocalizedDictionaryOutput>;
45
+ type QualifiedMergedDictionaryResult = {
46
+ dictionaryPath: string;
47
+ dictionary: QualifiedDictionaryGroup;
48
+ };
49
+ type QualifiedMergedDictionaryOutput = Record<string, QualifiedMergedDictionaryResult>;
50
+ /**
51
+ * Writes the dynamic chunks and entry points of qualified dictionaries
52
+ * (collections, variants, meta records — possibly combined) in
53
+ * `importMode: 'dynamic'`.
54
+ *
55
+ * Each entry is reduced to one per-locale chunk written to a path nested by
56
+ * dimension — `json/{key}/{seg1}/{seg2}/{locale}.json` — and a single
57
+ * `{key}.{ext}` entry point exposes the matching nested loader tree, so the
58
+ * entry point is discovered and aggregated exactly like a plain dynamic one.
59
+ */
60
+ declare const writeDynamicQualifiedDictionaries: (qualifiedDictionaries: QualifiedMergedDictionaryOutput, configuration: IntlayerConfig, formats?: ("cjs" | "esm")[]) => Promise<void>;
34
61
  //#endregion
35
- export { DictionaryResult, LocalizedDictionaryOutput, LocalizedDictionaryResult, generateDictionaryEntryPoint, writeDynamicDictionary };
62
+ export { DictionaryResult, LocalizedDictionaryOutput, LocalizedDictionaryResult, QualifiedMergedDictionaryOutput, QualifiedMergedDictionaryResult, generateDictionaryEntryPoint, generateQualifiedDictionaryEntryPoint, writeDynamicDictionary, writeDynamicQualifiedDictionaries };
36
63
  //# sourceMappingURL=writeDynamicDictionary.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"writeDynamicDictionary.d.ts","names":[],"sources":["../../../src/buildIntlayerDictionary/writeDynamicDictionary.ts"],"mappings":";;;;;;KAcY,gBAAA;EACV,cAAA;EACA,UAAA,EAAY,UAAA;AAAA;AAAA,KAGF,yBAAA,GAA4B,OAAA,CACtC,MAAA,CAAO,MAAA,EAAQ,gBAAA;AAAA,KAGL,yBAAA,GAA4B,MAAA,SAEtC,yBAAA;;;;cAQW,4BAAA,GACX,GAAA,UACA,OAAA,YACA,MAAA;;AAjBF;;;;;;;;;;;;;;;cAwDa,sBAAA,GACX,kBAAA,EAAoB,sBAAA,EACpB,aAAA,EAAe,cAAA,EACf,OAAA,yBACC,OAAA,CAAQ,yBAAA"}
1
+ {"version":3,"file":"writeDynamicDictionary.d.ts","names":[],"sources":["../../../src/buildIntlayerDictionary/writeDynamicDictionary.ts"],"mappings":";;;;;;KAuBY,gBAAA;EACV,cAAA;EACA,UAAA,EAAY,UAAA;AAAA;AAAA,KAGF,yBAAA,GAA4B,OAAA,CACtC,MAAA,CAAO,MAAA,EAAQ,gBAAA;AAAA,KAGL,yBAAA,GAA4B,MAAA,SAEtC,yBAAA;;;;cAQW,4BAAA,GACX,GAAA,UACA,OAAA,YACA,MAAA;;AAjBF;;;;;;;;;cAiHa,qCAAA,GACX,GAAA,UACA,cAAA,EAAgB,uBAAA,IAChB,eAAA,cACA,OAAA,YACA,MAAA;;;;;;AAlHF;;;;;AAUA;;;;;;cAgJa,sBAAA,GACX,kBAAA,EAAoB,2BAAA,EACpB,aAAA,EAAe,cAAA,EACf,OAAA,yBACC,OAAA,CAAQ,yBAAA;AAAA,KAyEC,+BAAA;EACV,cAAA;EACA,UAAA,EAAY,wBAAA;AAAA;AAAA,KAGF,+BAAA,GAAkC,MAAA,SAE5C,+BAAA;;;;;;;;;;AApFF;cAiGa,iCAAA,GACX,qBAAA,EAAuB,+BAAA,EACvB,aAAA,EAAe,cAAA,EACf,OAAA,yBACC,OAAA"}
@@ -1,13 +1,23 @@
1
1
  import { UnmergedDictionaryOutput } from "./writeUnmergedDictionary.js";
2
2
  import { IntlayerConfig } from "@intlayer/types/config";
3
- import { Dictionary } from "@intlayer/types/dictionary";
3
+ import { Dictionary, QualifiedDictionaryGroup } from "@intlayer/types/dictionary";
4
4
 
5
5
  //#region src/buildIntlayerDictionary/writeMergedDictionary.d.ts
6
6
  type MergedDictionaryResult = {
7
7
  dictionaryPath: string;
8
- dictionary: Dictionary;
8
+ dictionary: Dictionary | QualifiedDictionaryGroup;
9
9
  };
10
10
  type MergedDictionaryOutput = Record<string, MergedDictionaryResult>;
11
+ /**
12
+ * Merged output restricted to plain (unqualified) dictionaries — qualified
13
+ * groups (collections, variants, meta records) are static-only and filtered
14
+ * out before the dynamic/fetch build steps.
15
+ */
16
+ type PlainMergedDictionaryResult = {
17
+ dictionaryPath: string;
18
+ dictionary: Dictionary;
19
+ };
20
+ type PlainMergedDictionaryOutput = Record<string, PlainMergedDictionaryResult>;
11
21
  /**
12
22
  * Write the merged dictionaries to the dictionariesDir
13
23
  * @param groupedDictionaries - The grouped dictionaries
@@ -26,5 +36,5 @@ type MergedDictionaryOutput = Record<string, MergedDictionaryResult>;
26
36
  */
27
37
  declare const writeMergedDictionaries: (groupedDictionaries: UnmergedDictionaryOutput, configuration: IntlayerConfig) => Promise<MergedDictionaryOutput>;
28
38
  //#endregion
29
- export { MergedDictionaryOutput, MergedDictionaryResult, writeMergedDictionaries };
39
+ export { MergedDictionaryOutput, MergedDictionaryResult, PlainMergedDictionaryOutput, PlainMergedDictionaryResult, writeMergedDictionaries };
30
40
  //# sourceMappingURL=writeMergedDictionary.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"writeMergedDictionary.d.ts","names":[],"sources":["../../../src/buildIntlayerDictionary/writeMergedDictionary.ts"],"mappings":";;;;;KAcY,sBAAA;EACV,cAAA;EACA,UAAA,EAAY,UAAA;AAAA;AAAA,KAGF,sBAAA,GAAyB,MAAA,SAAe,sBAAA;;;;;;;AAApD;;;;;AAkBA;;;;;cAAa,uBAAA,GACX,mBAAA,EAAqB,wBAAA,EACrB,aAAA,EAAe,cAAA,KACd,OAAA,CAAQ,sBAAA"}
1
+ {"version":3,"file":"writeMergedDictionary.d.ts","names":[],"sources":["../../../src/buildIntlayerDictionary/writeMergedDictionary.ts"],"mappings":";;;;;KAiBY,sBAAA;EACV,cAAA;EACA,UAAA,EAAY,UAAA,GAAa,wBAAA;AAAA;AAAA,KAGf,sBAAA,GAAyB,MAAA,SAAe,sBAAA;;;;;;KAOxC,2BAAA;EACV,cAAA;EACA,UAAA,EAAY,UAAA;AAAA;AAAA,KAGF,2BAAA,GAA8B,MAAA,SAExC,2BAAA;;;AAPF;;;;;;;;;AAKA;;;;;cAqBa,uBAAA,GACX,mBAAA,EAAqB,wBAAA,EACrB,aAAA,EAAe,cAAA,KACd,OAAA,CAAQ,sBAAA"}
@@ -1,12 +1,12 @@
1
1
  import { IntlayerConfig } from "@intlayer/types/config";
2
- import { Dictionary } from "@intlayer/types/dictionary";
2
+ import { Dictionary, QualifiedDictionaryGroup } from "@intlayer/types/dictionary";
3
3
 
4
4
  //#region src/createType/createType.d.ts
5
- declare const generateTypeScriptType: (dictionary: Dictionary) => string;
5
+ declare const generateTypeScriptType: (dictionary: Dictionary | QualifiedDictionaryGroup) => string;
6
6
  /**
7
7
  * This function generates a TypeScript type definition from a JSON object
8
8
  */
9
- declare const createTypes: (dictionaries: Dictionary[], configuration: IntlayerConfig) => Promise<string[]>;
9
+ declare const createTypes: (dictionaries: (Dictionary | QualifiedDictionaryGroup)[], configuration: IntlayerConfig) => Promise<string[]>;
10
10
  //#endregion
11
11
  export { createTypes, generateTypeScriptType };
12
12
  //# sourceMappingURL=createType.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"createType.d.ts","names":[],"sources":["../../../src/createType/createType.ts"],"mappings":";;;;cAMa,sBAAA,GAA0B,UAAA,EAAY,UAAA;;AAAnD;;cAQa,WAAA,GACX,YAAA,EAAc,UAAA,IACd,aAAA,EAAe,cAAA,KACd,OAAA"}
1
+ {"version":3,"file":"createType.d.ts","names":[],"sources":["../../../src/createType/createType.ts"],"mappings":";;;;cASa,sBAAA,GACX,UAAA,EAAY,UAAA,GAAa,wBAAA;;AAD3B;;cAUa,WAAA,GACX,YAAA,GAAe,UAAA,GAAa,wBAAA,KAC5B,aAAA,EAAe,cAAA,KACd,OAAA"}
@@ -1,3 +1,4 @@
1
+ import { LocalesValues } from "./intlayer/dist/types/index.js";
1
2
  import { Dictionary } from "@intlayer/types/dictionary";
2
3
  import * as _$_intlayer_types0 from "@intlayer/types";
3
4
  import * as _$_intlayer_core_messageFormat0 from "@intlayer/core/messageFormat";
@@ -20,7 +21,10 @@ declare const formatDictionaryOutput: (dictionary: Dictionary, format: Dictionar
20
21
  version?: string;
21
22
  filePath?: string;
22
23
  tags?: string[];
23
- locale?: _$_intlayer_types0.LocalesValues;
24
+ item?: number;
25
+ variant?: string;
26
+ meta?: _$_intlayer_types0.DictionaryMeta;
27
+ locale?: LocalesValues;
24
28
  contentAutoTransformation?: _$_intlayer_types0.ContentAutoTransformation;
25
29
  fill?: _$_intlayer_types0.Fill;
26
30
  filled?: true;
@@ -44,7 +48,10 @@ declare const formatDictionariesOutput: (dictionaries: Dictionary[], format: Dic
44
48
  version?: string;
45
49
  filePath?: string;
46
50
  tags?: string[];
47
- locale?: _$_intlayer_types0.LocalesValues;
51
+ item?: number;
52
+ variant?: string;
53
+ meta?: _$_intlayer_types0.DictionaryMeta;
54
+ locale?: LocalesValues;
48
55
  contentAutoTransformation?: _$_intlayer_types0.ContentAutoTransformation;
49
56
  fill?: _$_intlayer_types0.Fill;
50
57
  filled?: true;
@@ -1 +1 @@
1
- {"version":3,"file":"formatDictionary.d.ts","names":[],"sources":["../../src/formatDictionary.ts"],"mappings":";;;;;cAYa,gBAAA,GAAoB,UAAA,EAAY,UAAA,KAAa,UAAA;AAAA,cAoC7C,kBAAA,GACX,YAAA,EAAc,UAAA,OACb,OAAA,CAAQ,UAAA;AAAA,cAEE,sBAAA,GACX,UAAA,EAAY,UAAA,EACZ,MAAA,EAAQ,UAAA,eAAoB,UAAA;;WAAA,+BAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;;;;;;cAqCjB,wBAAA,GACX,YAAA,EAAc,UAAA,IACd,MAAA,EAAQ,UAAA,gBAAoB,UAAA;;WAAA,+BAAA,CAAA,SAAA"}
1
+ {"version":3,"file":"formatDictionary.d.ts","names":[],"sources":["../../src/formatDictionary.ts"],"mappings":";;;;;;cAYa,gBAAA,GAAoB,UAAA,EAAY,UAAA,KAAa,UAAA;AAAA,cAoC7C,kBAAA,GACX,YAAA,EAAc,UAAA,OACb,OAAA,CAAQ,UAAA;AAAA,cAEE,sBAAA,GACX,UAAA,EAAY,UAAA,EACZ,MAAA,EAAQ,UAAA,eAAoB,UAAA;;WAAA,+BAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;;;;;;;;;cAqCjB,wBAAA,GACX,YAAA,EAAc,UAAA,IACd,MAAA,EAAQ,UAAA,gBAAoB,UAAA;;WAAA,+BAAA,CAAA,SAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/init/index.ts"],"mappings":";;AAkKA;;KAAY,WAAA;EACV,WAAA;AAAA;AAMF;;;AAAA,cAAa,YAAA,GAAsB,OAAA,UAAiB,OAAA,GAAU,WAAA,KAAW,OAAA"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/init/index.ts"],"mappings":";;AA4KA;;KAAY,WAAA;EACV,WAAA;AAAA;AAMF;;;AAAA,cAAa,YAAA,GAAsB,OAAA,UAAiB,OAAA,GAAU,WAAA,KAAW,OAAA"}
@@ -1,8 +1,49 @@
1
+ import { CompatSyncConfig, CompatVitePluginConfig } from "./packageManager.js";
2
+
1
3
  //#region src/init/utils/configManipulation.d.ts
2
4
  declare const updateViteConfig: (content: string, extension: string) => string;
3
5
  declare const updateAstroConfig: (content: string, extension: string) => string;
4
6
  declare const updateNextConfig: (content: string, extension: string) => string;
5
7
  declare const updateNuxtConfig: (content: string) => string;
8
+ /**
9
+ * Updates a Vite config for vue-i18n compat: injects `vueI18nVitePlugin` from
10
+ * `@intlayer/vue-i18n/plugin` into the plugins array.
11
+ */
12
+ declare const updateViteConfigForVueI18n: (content: string, extension: string) => string;
13
+ /**
14
+ * Generic vite config updater for any compat plugin that uses alias injection.
15
+ * Injects the named import from `pluginPackageSource` and appends the plugin
16
+ * call to the `plugins` array.
17
+ */
18
+ declare const updateViteConfigForCompatPlugin: (content: string, extension: string, pluginConfig: CompatVitePluginConfig) => string;
19
+ /**
20
+ * Updates a Next.js config for next-translate compat: wraps the default export
21
+ * with `withNextTranslate` from `@intlayer/next-translate/plugin`.
22
+ */
23
+ declare const updateNextConfigForNextTranslate: (content: string, extension: string) => string;
24
+ /**
25
+ * Updates a Nuxt config for nuxtjs-i18n compat: adds `@intlayer/nuxtjs-i18n`
26
+ * to the `modules` array.
27
+ */
28
+ declare const updateNuxtConfigForNuxtjsI18n: (content: string) => string;
29
+ /**
30
+ * Updates a Next.js config for next-i18next compat: wraps the default export
31
+ * with `withI18next` from `@intlayer/next-i18next/plugin`.
32
+ */
33
+ declare const updateNextConfigForNextI18next: (content: string, extension: string) => string;
34
+ /**
35
+ * Updates a Next.js config for next-intl compat: replaces any existing
36
+ * `next-intl/plugin` import source with `@intlayer/next-intl/plugin`, or
37
+ * injects `createNextIntlPlugin` with a factory-call wrapper when no such
38
+ * import is present.
39
+ */
40
+ declare const updateNextConfigForNextIntl: (content: string, extension: string) => string;
41
+ /**
42
+ * Injects the syncJSON import and a configured syncJSON(...) call into the
43
+ * plugins array of an intlayer config file. Idempotent: skips when
44
+ * @intlayer/sync-json-plugin is already imported.
45
+ */
46
+ declare const updateIntlayerConfigWithSyncPlugin: (content: string, extension: string, syncConfig: CompatSyncConfig) => string;
6
47
  //#endregion
7
- export { updateAstroConfig, updateNextConfig, updateNuxtConfig, updateViteConfig };
48
+ export { updateAstroConfig, updateIntlayerConfigWithSyncPlugin, updateNextConfig, updateNextConfigForNextI18next, updateNextConfigForNextIntl, updateNextConfigForNextTranslate, updateNuxtConfig, updateNuxtConfigForNuxtjsI18n, updateViteConfig, updateViteConfigForCompatPlugin, updateViteConfigForVueI18n };
8
49
  //# sourceMappingURL=configManipulation.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"configManipulation.d.ts","names":[],"sources":["../../../../src/init/utils/configManipulation.ts"],"mappings":";cAoKa,gBAAA,GACX,OAAA,UACA,SAAA;AAAA,cAmBW,iBAAA,GACX,OAAA,UACA,SAAA;AAAA,cAmBW,gBAAA,GACX,OAAA,UACA,SAAA;AAAA,cAoDW,gBAAA,GAAoB,OAAA"}
1
+ {"version":3,"file":"configManipulation.d.ts","names":[],"sources":["../../../../src/init/utils/configManipulation.ts"],"mappings":";;;cAwKa,gBAAA,GACX,OAAA,UACA,SAAA;AAAA,cAmBW,iBAAA,GACX,OAAA,UACA,SAAA;AAAA,cAmBW,gBAAA,GACX,OAAA,UACA,SAAA;AAAA,cAoDW,gBAAA,GAAoB,OAAA;;;;AA3EjC;cAwIa,0BAAA,GACX,OAAA,UACA,SAAA;;;;AArHF;;cAkJa,+BAAA,GACX,OAAA,UACA,SAAA,UACA,YAAA,EAAc,sBAAA;;;AA/FhB;;cAyLa,gCAAA,GACX,OAAA,UACA,SAAA;;;AA9HF;;cA2Ia,6BAAA,GAAiC,OAAA;;;AA5G9C;;cA2Ka,8BAAA,GACX,OAAA,UACA,SAAA;;;;;;;cAeW,2BAAA,GACX,OAAA,UACA,SAAA;AAjGF;;;;;AAAA,cAsSa,kCAAA,GACX,OAAA,UACA,SAAA,UACA,UAAA,EAAY,gBAAA"}
@@ -15,6 +15,36 @@ declare const writeFileToRoot: (rootDir: string, filePath: string, content: stri
15
15
  * Helper to ensure a directory exists
16
16
  */
17
17
  declare const ensureDirectory: (rootDir: string, dirPath: string) => Promise<void>;
18
+ /**
19
+ * Pattern type for locale JSON file organisation.
20
+ * - 'nested': files are at `{base}/{locale}/{key}.json`
21
+ * - 'flat': files are at `{base}/{locale}.json`
22
+ */
23
+ type JsonLocalePatternType = 'nested' | 'flat';
24
+ /**
25
+ * Detected locale JSON file pattern and the corresponding source template.
26
+ * `template` uses `${locale}` and `${key}` as literal placeholders (not JS
27
+ * expressions) so it can be embedded directly in a template-literal string.
28
+ */
29
+ type JsonLocalePattern = {
30
+ type: JsonLocalePatternType;
31
+ /**
32
+ * Source path template for syncJSON `source` option.
33
+ * Example nested: `./locales/${locale}/${key}.json`
34
+ * Example flat: `./locales/${locale}.json`
35
+ */
36
+ template: string;
37
+ };
38
+ /**
39
+ * Scans the project for JSON files and determines whether locale files are
40
+ * organised as `{base}/{locale}/{key}.json` (nested) or `{base}/{locale}.json`
41
+ * (flat). Returns the most likely source template, or `null` when no locale
42
+ * JSON files are found.
43
+ *
44
+ * The returned `template` contains `${locale}` and `${key}` as **literal**
45
+ * placeholder strings so it can be embedded inside a JS template literal.
46
+ */
47
+ declare const detectJsonLocalePattern: (rootDir: string) => Promise<JsonLocalePattern | null>;
18
48
  //#endregion
19
- export { ensureDirectory, exists, readFileFromRoot, writeFileToRoot };
49
+ export { JsonLocalePattern, JsonLocalePatternType, detectJsonLocalePattern, ensureDirectory, exists, readFileFromRoot, writeFileToRoot };
20
50
  //# sourceMappingURL=fileSystem.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"fileSystem.d.ts","names":[],"sources":["../../../../src/init/utils/fileSystem.ts"],"mappings":";;AAMA;;cAAa,MAAA,GAAgB,OAAA,UAAiB,QAAA,aAAgB,OAAA;;;;cAYjD,gBAAA,GAA0B,OAAA,UAAiB,QAAA,aAAgB,OAAA;;;AAAxE;cAMa,eAAA,GACX,OAAA,UACA,QAAA,UACA,OAAA,aAAe,OAAA;;;;cAMJ,eAAA,GAAyB,OAAA,UAAiB,OAAA,aAAe,OAAA"}
1
+ {"version":3,"file":"fileSystem.d.ts","names":[],"sources":["../../../../src/init/utils/fileSystem.ts"],"mappings":";;AASA;;cAAa,MAAA,GAAgB,OAAA,UAAiB,QAAA,aAAgB,OAAA;;;;cAYjD,gBAAA,GAA0B,OAAA,UAAiB,QAAA,aAAgB,OAAA;;;AAAxE;cAMa,eAAA,GACX,OAAA,UACA,QAAA,UACA,OAAA,aAAe,OAAA;;;;cAMJ,eAAA,GAAyB,OAAA,UAAiB,OAAA,aAAe,OAAA;;;;AATtE;;KAsBY,qBAAA;;;;;;KAOA,iBAAA;EACV,IAAA,EAAM,qBAAA;EArBK;;;;;EA2BX,QAAA;AAAA;;;AAdF;;;;;AAOA;;cAmDa,uBAAA,GACX,OAAA,aACC,OAAA,CAAQ,iBAAA"}
@@ -1,5 +1,6 @@
1
- import { updateAstroConfig, updateNextConfig, updateNuxtConfig, updateViteConfig } from "./configManipulation.js";
2
- import { ensureDirectory, exists, readFileFromRoot, writeFileToRoot } from "./fileSystem.js";
1
+ import { CompatSyncConfig, CompatVitePluginConfig, IntlayerPackageAnalysis, PackageManager, detectMissingIntlayerPackages, detectPackageManager, installPackages } from "./packageManager.js";
2
+ import { updateAstroConfig, updateIntlayerConfigWithSyncPlugin, updateNextConfig, updateNextConfigForNextI18next, updateNextConfigForNextIntl, updateNextConfigForNextTranslate, updateNuxtConfig, updateNuxtConfigForNuxtjsI18n, updateViteConfig, updateViteConfigForCompatPlugin, updateViteConfigForVueI18n } from "./configManipulation.js";
3
+ import { JsonLocalePattern, JsonLocalePatternType, detectJsonLocalePattern, ensureDirectory, exists, readFileFromRoot, writeFileToRoot } from "./fileSystem.js";
3
4
  import { parseJSONWithComments } from "./jsonParser.js";
4
5
  import { findTsConfigFiles } from "./tsConfig.js";
5
- export { ensureDirectory, exists, findTsConfigFiles, parseJSONWithComments, readFileFromRoot, updateAstroConfig, updateNextConfig, updateNuxtConfig, updateViteConfig, writeFileToRoot };
6
+ export { CompatSyncConfig, CompatVitePluginConfig, IntlayerPackageAnalysis, JsonLocalePattern, JsonLocalePatternType, PackageManager, detectJsonLocalePattern, detectMissingIntlayerPackages, detectPackageManager, ensureDirectory, exists, findTsConfigFiles, installPackages, parseJSONWithComments, readFileFromRoot, updateAstroConfig, updateIntlayerConfigWithSyncPlugin, updateNextConfig, updateNextConfigForNextI18next, updateNextConfigForNextIntl, updateNextConfigForNextTranslate, updateNuxtConfig, updateNuxtConfigForNuxtjsI18n, updateViteConfig, updateViteConfigForCompatPlugin, updateViteConfigForVueI18n, writeFileToRoot };
@@ -0,0 +1,59 @@
1
+ //#region src/init/utils/packageManager.d.ts
2
+ /** Package managers supported for dependency installation. */
3
+ type PackageManager = 'bun' | 'pnpm' | 'yarn' | 'npm';
4
+ /**
5
+ * Configuration for the syncJSON plugin injected into intlayer.config
6
+ * when a compat i18n library is detected.
7
+ */
8
+ type CompatSyncConfig = {
9
+ /** JSON format matching the compat library's conventions. */format: 'icu' | 'i18next' | 'vue-i18n';
10
+ /**
11
+ * Source path template using ${locale} and ${key} placeholders.
12
+ * Rendered as a template literal in the generated config.
13
+ */
14
+ sourceTemplate: string;
15
+ };
16
+ /**
17
+ * Configuration for injecting a compat vite plugin into vite.config.
18
+ * The plugin replaces the generic `intlayer` plugin for libraries that
19
+ * require alias injection (e.g. `vue-i18n` → `@intlayer/vue-i18n`).
20
+ */
21
+ type CompatVitePluginConfig = {
22
+ /** Exported function name from the plugin package, e.g. `'vueI18nVitePlugin'`. */pluginFunctionName: string; /** Import path for the plugin package, e.g. `'@intlayer/vue-i18n/plugin'`. */
23
+ pluginPackageSource: string;
24
+ };
25
+ /** Result of analyzing project dependencies for intlayer package gaps. */
26
+ type IntlayerPackageAnalysis = {
27
+ /** Intlayer packages that are referenced but not yet installed. */packagesToInstall: string[];
28
+ /**
29
+ * syncJSON plugin configuration to inject when a compat i18n library is
30
+ * detected. Undefined when no compat library is present or format is not
31
+ * yet implemented.
32
+ */
33
+ compatSyncConfig: CompatSyncConfig | undefined;
34
+ /**
35
+ * Vite config plugin to inject when a vite-based compat library is
36
+ * detected. Undefined for Next.js/Nuxt-only compat libs or when no compat
37
+ * library requires alias injection.
38
+ */
39
+ compatVitePluginConfig: CompatVitePluginConfig | undefined;
40
+ };
41
+ /**
42
+ * Detects the package manager in use by checking for lock files in the
43
+ * project root. Falls back to npm when no lock file is found.
44
+ */
45
+ declare const detectPackageManager: (rootDir: string) => PackageManager;
46
+ /**
47
+ * Analyzes existing project dependencies to determine which intlayer packages
48
+ * are missing and what syncJSON configuration to inject when compat i18n
49
+ * libraries are present.
50
+ */
51
+ declare const detectMissingIntlayerPackages: (allDependencies: Record<string, string>) => IntlayerPackageAnalysis;
52
+ /**
53
+ * Runs the package install command synchronously.
54
+ * Throws if the install process exits with a non-zero code.
55
+ */
56
+ declare const installPackages: (rootDir: string, packages: string[], packageManager: PackageManager) => void;
57
+ //#endregion
58
+ export { CompatSyncConfig, CompatVitePluginConfig, IntlayerPackageAnalysis, PackageManager, detectMissingIntlayerPackages, detectPackageManager, installPackages };
59
+ //# sourceMappingURL=packageManager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"packageManager.d.ts","names":[],"sources":["../../../../src/init/utils/packageManager.ts"],"mappings":";;KAKY,cAAA;;;;;KAMA,gBAAA;EAAgB,6DAE1B,MAAA;EAAA;;AAaF;;EARE,cAAA;AAAA;;AAgBF;;;;KARY,sBAAA;EAgBV,kFAdA,kBAAA,UAoBA;EAlBA,mBAAA;AAAA;;KAIU,uBAAA;EAmCX,mEAjCC,iBAAA;EAmBmC;;AAyCrC;;;EAtDE,gBAAA,EAAkB,gBAAA;EAuDD;;;;;EAjDjB,sBAAA,EAAwB,sBAAA;AAAA;;;;;cAOb,oBAAA,GAAwB,OAAA,aAAkB,cAAA;;;;;;cAyC1C,6BAAA,GACX,eAAA,EAAiB,MAAA,qBAChB,uBAAA;;;;;cAwNU,eAAA,GACX,OAAA,UACA,QAAA,YACA,cAAA,EAAgB,cAAA"}
@@ -0,0 +1,4 @@
1
+ import { IntlayerConfig } from "@intlayer/types/config";
2
+ import { Dictionary } from "@intlayer/types/dictionary";
3
+ import { LocalesValues as LocalesValues$1 } from "@intlayer/types/module_augmentation";
4
+ export { type LocalesValues$1 as LocalesValues };
@@ -0,0 +1,16 @@
1
+ import { BundleChunkInput, BundleContentAnalysis } from "./types.js";
2
+
3
+ //#region src/scan/analyzeBundleContent.d.ts
4
+ /**
5
+ * Analyze the locale weight of a page's JavaScript bundles.
6
+ *
7
+ * @param chunks - The fetched JavaScript chunks (main + lazy).
8
+ * @param htmlContent - The page HTML, used to estimate rendered content size.
9
+ * @param currentLocale - The locale currently rendered by the page.
10
+ * @param totalPageSize - The total transferred bytes measured for the page.
11
+ * @returns The aggregated {@link BundleContentAnalysis}.
12
+ */
13
+ declare const analyzeBundleContent: (chunks: BundleChunkInput[], htmlContent: string, currentLocale: string, totalPageSize: number) => BundleContentAnalysis;
14
+ //#endregion
15
+ export { analyzeBundleContent };
16
+ //# sourceMappingURL=analyzeBundleContent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"analyzeBundleContent.d.ts","names":[],"sources":["../../../src/scan/analyzeBundleContent.ts"],"mappings":";;;;;AA6KA;;;;;;;cAAa,oBAAA,GACX,MAAA,EAAQ,gBAAA,IACR,WAAA,UACA,aAAA,UACA,aAAA,aACC,qBAAA"}
@@ -0,0 +1,65 @@
1
+ //#region src/scan/calculateScore.d.ts
2
+ /**
3
+ * Mutualized SEO/i18n scoring logic.
4
+ *
5
+ * This module is the single source of truth for turning audit/scan events into
6
+ * a weighted score. It is consumed both by the hosted backend SEO audit
7
+ * (`apps/backend`) and by the `intlayer scan` CLI command, so it must stay free
8
+ * of any server-only dependency (no Fastify, no Cheerio, no logger coupling).
9
+ */
10
+ /** Accumulated score across all checks that ran. */
11
+ type Score = {
12
+ /** Sum of points obtained (success = full, warning = half, error = none). */score: number; /** Maximum achievable points for the checks that ran. */
13
+ totalScore: number;
14
+ };
15
+ /**
16
+ * Minimal shape of an event needed to contribute to the score.
17
+ *
18
+ * The `type` is the check identifier. URL-scoped checks are suffixed with the
19
+ * URL using a backslash separator (e.g. `url_htmlLang\https://example.com`), so
20
+ * only the part before the first backslash is used to look up the weight.
21
+ */
22
+ type ScorableEvent = {
23
+ type?: string;
24
+ status?: string;
25
+ };
26
+ /** Weight (in points) of every scorable check. */
27
+ declare const scoreRecord: {
28
+ readonly robots_robotsPresent: 10;
29
+ readonly robots_noLocalizedUrlsForgotten: 8;
30
+ readonly sitemap_sitemapPresent: 10;
31
+ readonly sitemap_noLocalizedUrlsForgotten: 9;
32
+ readonly sitemap_hasAlternates: 8;
33
+ readonly sitemap_hasXDefault: 7;
34
+ readonly url_htmlLang: 9;
35
+ readonly url_htmlDir: 3;
36
+ readonly url_hasCanonical: 10;
37
+ readonly url_hreflang: 9;
38
+ readonly url_hasLocalizedLinks: 8;
39
+ readonly url_hasXDefault: 7;
40
+ readonly url_allAnchorsLocalized: 6;
41
+ readonly url_currentLocale: 3;
42
+ readonly url_unusedBundleContent: 8;
43
+ };
44
+ /** Identifier of a scorable check (without the URL suffix). */
45
+ type ScoreCheckType = keyof typeof scoreRecord;
46
+ /**
47
+ * Apply a single event to the running score, returning a new {@link Score}.
48
+ * Unknown check types are ignored so the function is safe to call on every
49
+ * emitted event.
50
+ *
51
+ * @param score - The current accumulated score.
52
+ * @param event - The event to fold into the score.
53
+ * @returns A new score with the event applied.
54
+ */
55
+ declare const mutateScore: (score: Score, event: ScorableEvent) => Score;
56
+ /**
57
+ * Convert a raw {@link Score} into a 0–100 percentage.
58
+ *
59
+ * @param score - The accumulated score.
60
+ * @returns The rounded percentage, or 0 when no check ran.
61
+ */
62
+ declare const toScorePercent: (score: Score) => number;
63
+ //#endregion
64
+ export { ScorableEvent, Score, ScoreCheckType, mutateScore, scoreRecord, toScorePercent };
65
+ //# sourceMappingURL=calculateScore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calculateScore.d.ts","names":[],"sources":["../../../src/scan/calculateScore.ts"],"mappings":";;AAUA;;;;;AAcA;;;KAdY,KAAA;EAgBJ,6EAdN,KAAA,UA8CQ;EA5CR,UAAA;AAAA;;;;;;;;KAUU,aAAA;EACV,IAAA;EACA,MAAA;AAAA;;cAgBW,WAAA;EAAA;;;;;;;;;;;;;;;;;KAmBD,cAAA,gBAA8B,WAAA;;;;;;;AAoC1C;;;cAzBa,WAAA,GAAe,KAAA,EAAO,KAAA,EAAO,KAAA,EAAO,aAAA,KAAgB,KAAA;;;;;;;cAyBpD,cAAA,GAAkB,KAAA,EAAO,KAAA"}
@@ -0,0 +1,38 @@
1
+ import { BundleChunkInput, BundleContentAnalysis, ScanEvent } from "./types.js";
2
+ import { Anchor } from "./parseHtml.js";
3
+
4
+ //#region src/scan/checks.d.ts
5
+ /** Format a byte count as a human-readable size. */
6
+ declare const formatSize: (bytes: number) => string;
7
+ /**
8
+ * Check the `<html>` element attributes (`lang`, `dir`) and the resulting
9
+ * current-locale signal. Returns the detected language tag.
10
+ */
11
+ declare const checkHtmlAttributes: (html: string, targetUrl: string, events: ScanEvent[]) => {
12
+ langTag: string | undefined;
13
+ };
14
+ /** Check the presence of a canonical link. */
15
+ declare const checkCanonical: (html: string, targetUrl: string, events: ScanEvent[]) => void;
16
+ /**
17
+ * Check the page's hreflang structure and collect discovered locales into
18
+ * `localesSet`.
19
+ */
20
+ declare const checkLinguisticStructure: (html: string, targetUrl: string, localesSet: Set<string>, events: ScanEvent[]) => void;
21
+ /**
22
+ * Check whether internal links carry a locale segment, mirroring the hosted
23
+ * audit's URL-structure analysis but operating on parsed anchors instead of a
24
+ * live DOM.
25
+ */
26
+ declare const checkUrlStructure: (anchors: Anchor[], origin: string, targetUrl: string, events: ScanEvent[]) => void;
27
+ /**
28
+ * Analyze the JavaScript bundles for unused locale content and emit the
29
+ * corresponding event. Returns the analysis so callers can report on it.
30
+ */
31
+ declare const checkBundleContent: (chunks: BundleChunkInput[], html: string, currentLocale: string | undefined, targetUrl: string, totalPageSize: number, events: ScanEvent[]) => BundleContentAnalysis | undefined;
32
+ /** Fetch and check `robots.txt`, emitting robots-related events. */
33
+ declare const checkRobots: (origin: string, discoveredLocales: Set<string>, userAgent: string, events: ScanEvent[]) => Promise<void>;
34
+ /** Fetch and check `sitemap.xml`, emitting sitemap-related events. */
35
+ declare const checkSitemap: (origin: string, discoveredLocales: Set<string>, userAgent: string, events: ScanEvent[]) => Promise<void>;
36
+ //#endregion
37
+ export { checkBundleContent, checkCanonical, checkHtmlAttributes, checkLinguisticStructure, checkRobots, checkSitemap, checkUrlStructure, formatSize };
38
+ //# sourceMappingURL=checks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checks.d.ts","names":[],"sources":["../../../src/scan/checks.ts"],"mappings":";;;;;cAgBa,UAAA,GAAc,KAAA;AAA3B;;;;AAAA,cAUa,mBAAA,GACX,IAAA,UACA,SAAA,UACA,MAAA,EAAQ,SAAA;EACL,OAAA;AAAA;;cAmCQ,cAAA,GACX,IAAA,UACA,SAAA,UACA,MAAA,EAAQ,SAAA;;;;;cAcG,wBAAA,GACX,IAAA,UACA,SAAA,UACA,UAAA,EAAY,GAAA,UACZ,MAAA,EAAQ,SAAA;;;AArBV;;;cA6Da,iBAAA,GACX,OAAA,EAAS,MAAA,IACT,MAAA,UACA,SAAA,UACA,MAAA,EAAQ,SAAA;;;;;cAwEG,kBAAA,GACX,MAAA,EAAQ,gBAAA,IACR,IAAA,UACA,aAAA,sBACA,SAAA,UACA,aAAA,UACA,MAAA,EAAQ,SAAA,OACP,qBAAA;;cA0CU,WAAA,GACX,MAAA,UACA,iBAAA,EAAmB,GAAA,UACnB,SAAA,UACA,MAAA,EAAQ,SAAA,OACP,OAAA;;cA0DU,YAAA,GACX,MAAA,UACA,iBAAA,EAAmB,GAAA,UACnB,SAAA,UACA,MAAA,EAAQ,SAAA,OACP,OAAA"}
@@ -0,0 +1,7 @@
1
+ import { ScorableEvent, Score, ScoreCheckType, mutateScore, scoreRecord, toScorePercent } from "./calculateScore.js";
2
+ import { BundleChunkInput, BundleContentAnalysis, ChunkAnalysis, ScanCheckStatus, ScanEvent, ScanEventDetails, ScanMode, ScanOptions, ScanResult } from "./types.js";
3
+ import { analyzeBundleContent } from "./analyzeBundleContent.js";
4
+ import { Anchor, HreflangLink, byteLength, extractAnchors, extractHreflangs, extractHtmlDir, extractHtmlLang, extractMetaDescription, extractOgImage, extractScriptUrls, extractTitle, extractVisibleTextStrings, hasCanonical } from "./parseHtml.js";
5
+ import { checkBundleContent, checkCanonical, checkHtmlAttributes, checkLinguisticStructure, checkRobots, checkSitemap, checkUrlStructure, formatSize } from "./checks.js";
6
+ import { scanWebsite } from "./scanWebsite.js";
7
+ export { Anchor, BundleChunkInput, BundleContentAnalysis, ChunkAnalysis, HreflangLink, ScanCheckStatus, ScanEvent, ScanEventDetails, ScanMode, ScanOptions, ScanResult, ScorableEvent, Score, ScoreCheckType, analyzeBundleContent, byteLength, checkBundleContent, checkCanonical, checkHtmlAttributes, checkLinguisticStructure, checkRobots, checkSitemap, checkUrlStructure, extractAnchors, extractHreflangs, extractHtmlDir, extractHtmlLang, extractMetaDescription, extractOgImage, extractScriptUrls, extractTitle, extractVisibleTextStrings, formatSize, hasCanonical, mutateScore, scanWebsite, scoreRecord, toScorePercent };
@@ -0,0 +1,54 @@
1
+ //#region src/scan/parseHtml.d.ts
2
+ /**
3
+ * Tiny dependency-free HTML extraction helpers.
4
+ *
5
+ * The hosted backend audit relies on Cheerio + a real browser, but the CLI scan
6
+ * must stay dependency-light. These regex-based helpers cover the handful of
7
+ * head/anchor signals the score needs. They are intentionally forgiving: when a
8
+ * tag can't be parsed it is simply skipped rather than throwing.
9
+ */
10
+ /** Compute the UTF-8 byte length of a string in both Node and browser builds. */
11
+ declare const byteLength: (text: string) => number;
12
+ /** Extract the `lang` attribute of the `<html>` element, if present. */
13
+ declare const extractHtmlLang: (html: string) => string | undefined;
14
+ /** Extract the `dir` attribute of the `<html>` element, if present. */
15
+ declare const extractHtmlDir: (html: string) => string | undefined;
16
+ /** Extract the document `<title>` text. */
17
+ declare const extractTitle: (html: string) => string;
18
+ /** Extract the `<meta name="description">` content. */
19
+ declare const extractMetaDescription: (html: string) => string;
20
+ /** Extract the `<meta property="og:image">` content. */
21
+ declare const extractOgImage: (html: string) => string | undefined;
22
+ /** Whether a `<link rel="canonical">` element is present. */
23
+ declare const hasCanonical: (html: string) => boolean;
24
+ /** A parsed `<link rel="alternate" hreflang>` element. */
25
+ type HreflangLink = {
26
+ hreflang: string;
27
+ href: string;
28
+ };
29
+ /** Extract every `<link rel="alternate" hreflang="…" href="…">` element. */
30
+ declare const extractHreflangs: (html: string) => HreflangLink[];
31
+ /**
32
+ * Extract every eagerly-loaded script URL: `<script src>`,
33
+ * `<link rel="modulepreload">` and `<link rel="preload" as="script">`.
34
+ *
35
+ * @param html - The raw HTML document.
36
+ * @param baseUrl - Base URL used to resolve relative script URLs.
37
+ * @returns Absolute, de-duplicated script URLs.
38
+ */
39
+ declare const extractScriptUrls: (html: string, baseUrl: string) => string[];
40
+ /** A parsed `<a href>` anchor. */
41
+ type Anchor = {
42
+ href: string;
43
+ text: string;
44
+ };
45
+ /** Extract every `<a href="…">text</a>` anchor from the document. */
46
+ declare const extractAnchors: (html: string) => Anchor[];
47
+ /**
48
+ * Extract visible text snippets from an HTML document (scripts, styles and
49
+ * tags stripped). Used to approximate the rendered content size without a DOM.
50
+ */
51
+ declare const extractVisibleTextStrings: (html: string) => string[];
52
+ //#endregion
53
+ export { Anchor, HreflangLink, byteLength, extractAnchors, extractHreflangs, extractHtmlDir, extractHtmlLang, extractMetaDescription, extractOgImage, extractScriptUrls, extractTitle, extractVisibleTextStrings, hasCanonical };
54
+ //# sourceMappingURL=parseHtml.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parseHtml.d.ts","names":[],"sources":["../../../src/scan/parseHtml.ts"],"mappings":";;AAUA;;;;;AAkBA;;;cAlBa,UAAA,GAAc,IAAA;;cAkBd,eAAA,GAAmB,IAAA;;cAMnB,cAAA,GAAkB,IAAA;;cAMlB,YAAA,GAAgB,IAAA;AAA7B;AAAA,cAMa,sBAAA,GAA0B,IAAA;;cAW1B,cAAA,GAAkB,IAAA;;cAWlB,YAAA,GAAgB,IAAA;;KAMjB,YAAA;EAAiB,QAAA;EAAkB,IAAA;AAAA;;cAGlC,gBAAA,GAAoB,IAAA,aAAe,YAAA;;;AAThD;;;;;AAMA;cAuBa,iBAAA,GAAqB,IAAA,UAAc,OAAA;;KA4BpC,MAAA;EAAW,IAAA;EAAc,IAAA;AAAA;;cAGxB,cAAA,GAAkB,IAAA,aAAe,MAAA;;AA/B9C;;;cAqDa,yBAAA,GAA6B,IAAA"}
@@ -0,0 +1,18 @@
1
+ import { ScanOptions, ScanResult } from "./types.js";
2
+
3
+ //#region src/scan/scanWebsite.d.ts
4
+ /**
5
+ * Scan a single web page for i18n/SEO health and bundle weight.
6
+ *
7
+ * In `deep` mode (default) the page is rendered with a locally installed
8
+ * `puppeteer`; when `puppeteer` is missing the scan transparently falls back to
9
+ * a `basic` fetch-based pass and logs a recommendation to install it.
10
+ *
11
+ * @param targetUrl - The absolute URL to scan.
12
+ * @param options - {@link ScanOptions} controlling depth, timeout and UA.
13
+ * @returns The {@link ScanResult} including score, page size and per-check events.
14
+ */
15
+ declare const scanWebsite: (targetUrl: string, options?: ScanOptions) => Promise<ScanResult>;
16
+ //#endregion
17
+ export { scanWebsite };
18
+ //# sourceMappingURL=scanWebsite.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scanWebsite.d.ts","names":[],"sources":["../../../src/scan/scanWebsite.ts"],"mappings":";;;;;AAmNA;;;;;;;;;cAAa,WAAA,GACX,SAAA,UACA,OAAA,GAAS,WAAA,KACR,OAAA,CAAQ,UAAA"}