@yapyak/vite 0.0.18 → 0.0.19

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/index.d.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import { Plugin } from "vite";
2
- //#region src/plugin.d.ts
3
2
  /**
4
3
  * Options for {@link yapyak}.
5
4
  */
@@ -48,5 +47,4 @@ type YapyakOptions = {
48
47
  * ```
49
48
  */
50
49
  export declare function yapyak(options?: YapyakOptions): Plugin[];
51
- //#endregion
52
50
  export type { YapyakOptions };
package/dist/index.js CHANGED
@@ -3,19 +3,17 @@ import { CorruptLocaleFileError, YAP_COMPILE, YAP_RUNTIME, autoTranslate, detect
3
3
  import { createFilter, defineRuntime, loadYapyakConfig } from "yapyak/config/internal";
4
4
  import { buildPatches } from "yapyak/internal";
5
5
  import { readFileSync } from "node:fs";
6
- //#region src/plugin/file-id.ts
6
+ // src/plugin/file-id.ts
7
7
  function toFileId(projectRoot, id) {
8
8
  const path = id.split("?")[0] ?? id;
9
9
  return relative(projectRoot, path).replaceAll("\\", "/");
10
10
  }
11
- //#endregion
12
- //#region src/plugin/candidate-id.ts
11
+ // src/plugin/candidate-id.ts
13
12
  function isCandidateId(id, filter, projectRoot) {
14
13
  if (id.startsWith("\0")) return false;
15
14
  return filter(toFileId(projectRoot, id));
16
15
  }
17
- //#endregion
18
- //#region src/plugin/state.ts
16
+ // src/plugin/state.ts
19
17
  function createState(options = {}) {
20
18
  return {
21
19
  command: "serve",
@@ -58,8 +56,7 @@ function createConsoleLogger() {
58
56
  }
59
57
  };
60
58
  }
61
- //#endregion
62
- //#region src/plugin/compiler-runtime.ts
59
+ // src/plugin/compiler-runtime.ts
63
60
  function createCompilerRuntimePlugin(state) {
64
61
  return {
65
62
  enforce: "pre",
@@ -79,8 +76,7 @@ function findCompilerRuntime(processors, source) {
79
76
  if (compilerRuntime?.specifiers.includes(source)) return compilerRuntime;
80
77
  }
81
78
  }
82
- //#endregion
83
- //#region src/locale-resolver.ts
79
+ // src/locale-resolver.ts
84
80
  function createLocaleResolver(config, projectRoot, options) {
85
81
  const fixedLocale = options?.fixedLocale;
86
82
  let discovery;
@@ -136,8 +132,7 @@ function createLocaleResolver(config, projectRoot, options) {
136
132
  }
137
133
  };
138
134
  }
139
- //#endregion
140
- //#region src/virtual-runtime.ts
135
+ // src/virtual-runtime.ts
141
136
  const RUNTIME_ID = "yapyak/runtime";
142
137
  const RUNTIME_CORE_IDS = ["yapyak", "yapyak/internal"];
143
138
  const RUNTIME_RESOLVED = "\0yapyak:runtime";
@@ -145,16 +140,14 @@ const RUNTIME_NO_EXTERNAL = ["yapyak", /^@yapyak\//];
145
140
  function isRuntimeExternal(id) {
146
141
  return RUNTIME_NO_EXTERNAL.some((pattern) => typeof pattern === "string" ? pattern === id : pattern.test(id));
147
142
  }
148
- //#endregion
149
- //#region src/plugin/locale-warning.ts
143
+ // src/plugin/locale-warning.ts
150
144
  function renderLocaleWarning(warning, localesDir) {
151
145
  const reason = warning.issue === "invalid-structure" ? "does not look like a BCP 47 locale tag" : "is not a recognized ISO 639-1 language code";
152
146
  const action = "yapyak will skip syncing stubs and translating for this locale.";
153
147
  const hint = warning.suggestion ? ` Did you mean '${warning.suggestion}'? Rename \`${localesDir}/${warning.code}.json\` to \`${localesDir}/${warning.suggestion}.json\` to enable.` : ` Rename \`${localesDir}/${warning.code}.json\` to a valid locale code, or remove the file.`;
154
148
  return `[yapyak] locale '${warning.code}' ${reason}. ${action}${hint}`;
155
149
  }
156
- //#endregion
157
- //#region src/plugin/config.ts
150
+ // src/plugin/config.ts
158
151
  function createConfigPlugin(state) {
159
152
  const loads = /* @__PURE__ */ new Map();
160
153
  return {
@@ -218,8 +211,7 @@ function toRuntimeModules(processors) {
218
211
  }
219
212
  return modules;
220
213
  }
221
- //#endregion
222
- //#region src/plugin/error-diagnostic.ts
214
+ // src/plugin/error-diagnostic.ts
223
215
  function renderErrorDiagnostics(logger, result) {
224
216
  const errors = [];
225
217
  for (const diagnostic of result.diagnostics) {
@@ -236,8 +228,7 @@ function formatDiagnostic(diagnostic) {
236
228
  const location = `${diagnostic.fileId}:${diagnostic.range.start.line}:${diagnostic.range.start.column}`;
237
229
  return `[yapyak] ${diagnostic.code} ${location}: ${diagnostic.message}\nSee ${getDocsUrl(diagnostic.code)}`;
238
230
  }
239
- //#endregion
240
- //#region src/plugin/extraction.ts
231
+ // src/plugin/extraction.ts
241
232
  function resolveExtraction(state, fileId, source) {
242
233
  const { processors } = getNormalized(state);
243
234
  if (!source.includes("yapyak") && !hasAmbientBindings(processors)) {
@@ -266,16 +257,14 @@ function resolveExtraction(state, fileId, source) {
266
257
  function hasAmbientBindings(processors) {
267
258
  return processors.some((processor) => processor.ambientBindings !== void 0 && processor.ambientBindings.length > 0);
268
259
  }
269
- //#endregion
270
- //#region src/plugin/locale-file.ts
260
+ // src/plugin/locale-file.ts
271
261
  function isLocaleFile(state, path) {
272
262
  const directory = join(state.projectRoot, getNormalized(state).localesDir);
273
263
  const relativePath = relative(directory, path);
274
264
  if (relativePath === "" || relativePath.startsWith("..") || relativePath.includes(sep)) return false;
275
265
  return extname(relativePath) === ".json";
276
266
  }
277
- //#endregion
278
- //#region src/plugin/yapyak-command.ts
267
+ // src/plugin/yapyak-command.ts
279
268
  function runYapyakCommand(args) {
280
269
  const userAgent = process.env.npm_config_user_agent ?? "";
281
270
  if (userAgent.startsWith("pnpm/")) return `pnpm yapyak ${args}`;
@@ -283,8 +272,7 @@ function runYapyakCommand(args) {
283
272
  if (userAgent.startsWith("bun/")) return `bunx yapyak ${args}`;
284
273
  return `npx yapyak ${args}`;
285
274
  }
286
- //#endregion
287
- //#region src/plugin/stub.ts
275
+ // src/plugin/stub.ts
288
276
  function fillStubs(state) {
289
277
  state.autoTranslateController?.abort();
290
278
  state.autoTranslateController = void 0;
@@ -400,8 +388,7 @@ function formatElapsed(ms) {
400
388
  if (ms < 1e3) return `${ms}ms`;
401
389
  return `${(ms / 1e3).toFixed(1)}s`;
402
390
  }
403
- //#endregion
404
- //#region src/plugin/sync.ts
391
+ // src/plugin/sync.ts
405
392
  function syncAll(state) {
406
393
  const allMessages = [];
407
394
  for (const list of state.messagesByFile.values()) allMessages.push(...list);
@@ -424,8 +411,7 @@ function emitSyncDiagnostics(state, result) {
424
411
  for (const entry of result.orphaned) state.logger.warn(`[yapyak] preserved '${entry.source}' (${entry.locale}) — call site removed from ${entry.fileId}, translation saved in case it returns.`);
425
412
  for (const entry of result.restored) state.logger.info(`[yapyak] restored '${entry.source}' (${entry.locale}) in ${entry.fileId} — translation kept from when the call site was removed earlier.`);
426
413
  }
427
- //#endregion
428
- //#region src/plugin/dev-server.ts
414
+ // src/plugin/dev-server.ts
429
415
  function createDevServerPlugin(state) {
430
416
  return {
431
417
  buildEnd() {
@@ -697,8 +683,7 @@ function debounce(fn, milliseconds, logger) {
697
683
  };
698
684
  return debounced;
699
685
  }
700
- //#endregion
701
- //#region src/plugin/scan.ts
686
+ // src/plugin/scan.ts
702
687
  function createScanPlugin(state) {
703
688
  return {
704
689
  buildStart() {
@@ -719,8 +704,7 @@ function scanAllSources(state) {
719
704
  }
720
705
  syncAll(state);
721
706
  }
722
- //#endregion
723
- //#region src/plugin/transform.ts
707
+ // src/plugin/transform.ts
724
708
  function createTransformPlugin(state) {
725
709
  return {
726
710
  enforce: "pre",
@@ -816,8 +800,7 @@ function buildTranslations(input) {
816
800
  }
817
801
  return translations;
818
802
  }
819
- //#endregion
820
- //#region src/plugin/virtual-module.ts
803
+ // src/plugin/virtual-module.ts
821
804
  function createVirtualModulePlugin(state) {
822
805
  return {
823
806
  enforce: "pre",
@@ -826,6 +809,7 @@ function createVirtualModulePlugin(state) {
826
809
  const normalized = getNormalized(state);
827
810
  const emitted = getResolver(state).getEmittedLocales();
828
811
  return defineRuntime({
812
+ adoptDocumentLocale: normalized.adoptDocumentLocale,
829
813
  defaultLocale: emitted.defaultLocale,
830
814
  detectUserLocale: normalized.detectUserLocale,
831
815
  locales: emitted.locales,
@@ -842,8 +826,7 @@ function createVirtualModulePlugin(state) {
842
826
  }
843
827
  };
844
828
  }
845
- //#endregion
846
- //#region src/plugin.ts
829
+ // src/plugin.ts
847
830
  /**
848
831
  * Creates the yapyak Vite plugin.
849
832
  *
@@ -886,5 +869,4 @@ function yapyak(options = {}) {
886
869
  createDevServerPlugin(state)
887
870
  ];
888
871
  }
889
- //#endregion
890
872
  export { yapyak };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yapyak/vite",
3
- "version": "0.0.18",
3
+ "version": "0.0.19",
4
4
  "description": "Vite plugin for yapyak.",
5
5
  "keywords": [
6
6
  "i18n",
@@ -32,20 +32,20 @@
32
32
  "dist"
33
33
  ],
34
34
  "devDependencies": {
35
- "@types/node": "26.6.2",
36
- "tsdown": "0.23.0",
35
+ "@types/node": "26.6.5",
36
+ "tsdown": "0.23.2",
37
37
  "typescript": "6.0.3",
38
- "vite": "8.3.1",
39
- "vitest": "5.0.1",
40
- "@yapyak/typescript-config": "0.0.0",
41
- "@yapyak/tsdown-config": "0.0.0"
38
+ "vite": "8.3.5",
39
+ "vitest": "5.0.5",
40
+ "@yapyak/tsdown-config": "0.0.0",
41
+ "@yapyak/typescript-config": "0.0.0"
42
42
  },
43
43
  "peerDependencies": {
44
44
  "vite": ">=8",
45
- "yapyak": "0.0.18"
45
+ "yapyak": "0.0.19"
46
46
  },
47
47
  "engines": {
48
- "node": ">=22.22"
48
+ "node": ">=22.23.4"
49
49
  },
50
50
  "publishConfig": {
51
51
  "access": "public"