@verbaly/compiler 0.50.0 → 0.51.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.
package/dist/cli.js CHANGED
@@ -793,7 +793,7 @@ function renderParamType(types) {
793
793
  ]) members.add(m);
794
794
  return [...members].join(" | ");
795
795
  }
796
- function generateDts(catalog) {
796
+ function generateDts(catalog, options = {}) {
797
797
  const lines = [];
798
798
  for (const [key, message] of Object.entries(catalog).sort(([a], [b]) => a.localeCompare(b))) {
799
799
  const params = collectParams(message);
@@ -826,7 +826,7 @@ ${lines.join("\n")}
826
826
  path?: string;
827
827
  base?: string;
828
828
  }): string | undefined;
829
- export function loadMessages(locale: string): Promise<Record<string, string>>;
829
+ export function loadMessages(locale: string): Promise<Record<string, string>>;${options.inlineCatalog ? "\n export function adoptPage(options?: {\n root?: ParentNode;\n path?: string;\n }): string | undefined;" : ""}
830
830
  export function createInstance(
831
831
  options?: import('verbaly').VerbalyOptions<VerbalyKey>,
832
832
  ): import('verbaly').Verbaly<VerbalyKey>;
@@ -865,7 +865,7 @@ declare module 'virtual:verbaly/locale/*' {
865
865
  }
866
866
  function writeDts(cfg, catalog, file) {
867
867
  file ??= join(cfg.root, "verbaly.d.ts");
868
- const content = generateDts(catalog);
868
+ const content = generateDts(catalog, { inlineCatalog: cfg.render.inlineCatalog === true });
869
869
  try {
870
870
  if (readFileSync(file, "utf8") === content) return;
871
871
  } catch {}
@@ -1584,7 +1584,7 @@ async function doctor(cfg) {
1584
1584
  if (source && scanning && cfg.dts !== false) {
1585
1585
  const dtsPath = cfg.dts ?? join(cfg.root, "verbaly.d.ts");
1586
1586
  if (!existsSync(dtsPath)) warn("types", "verbaly.d.ts has not been generated", "run `npx verbaly extract`");
1587
- else if (readFileSync(dtsPath, "utf8") !== generateDts(source)) warn("types", "verbaly.d.ts is stale", "run `npx verbaly extract`");
1587
+ else if (readFileSync(dtsPath, "utf8") !== generateDts(source, { inlineCatalog: cfg.render.inlineCatalog === true })) warn("types", "verbaly.d.ts is stale", "run `npx verbaly extract`");
1588
1588
  else ok("types", "verbaly.d.ts is up to date");
1589
1589
  }
1590
1590
  const registry = await extractProject(cfg);
@@ -2549,7 +2549,7 @@ function pageSlice(v, locale, used) {
2549
2549
  const slice = {};
2550
2550
  for (const key of used) {
2551
2551
  const found = v.inspect(key);
2552
- if (found?.from === locale) slice[key] = found.source;
2552
+ slice[key] = found?.from === locale ? found.source : "";
2553
2553
  }
2554
2554
  return slice;
2555
2555
  }