@verbaly/vite 0.81.0 → 0.83.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/README.md CHANGED
@@ -6,6 +6,10 @@
6
6
 
7
7
  <p align="center">
8
8
  <a href="https://www.npmjs.com/package/@verbaly/vite"><img src="https://img.shields.io/npm/v/@verbaly/vite?logo=npm&color=cb3837" alt="npm version" /></a>
9
+ <a href="https://verbaly-web.vercel.app/docs/frameworks/vite"><img src="https://img.shields.io/npm/dependency-version/@verbaly/vite/peer/vite?logo=vite&logoColor=646CFF&label=Vite&color=1B1C2E" alt="supported Vite versions" /></a>
10
+ <a href="https://github.com/AronSoto/verbaly/actions/workflows/ci.yml"><img src="https://img.shields.io/github/actions/workflow/status/AronSoto/verbaly/ci.yml?logo=github&label=CI" alt="CI" /></a>
11
+ <a href="https://scorecard.dev/viewer/?uri=github.com/AronSoto/verbaly"><img src="https://api.scorecard.dev/projects/github.com/AronSoto/verbaly/badge" alt="OpenSSF Scorecard" /></a>
12
+ <a href="https://www.npmjs.com/package/@verbaly/vite#provenance"><img src="https://img.shields.io/badge/provenance-SLSA%20v1-3fb950?logo=npm" alt="published with npm provenance" /></a>
9
13
  <a href="https://github.com/AronSoto/verbaly/blob/develop/LICENSE"><img src="https://img.shields.io/npm/l/@verbaly/vite?color=blue" alt="MIT" /></a>
10
14
  </p>
11
15
 
package/dist/index.js CHANGED
@@ -1,5 +1,6 @@
1
- import { APP_ID, LOCALE_IMPORT, LOCALE_MODULE_PREFIX, MessageRegistry, RESOLVED_VIRTUAL_ID, SOURCE_FILE_RE, createDevReporter, createSourceFilter, extractProject, formatCliError, isTransformTarget, loadCatalogs, loadConfig, loadVirtualModule, outdatedTranslations, reportOutsideInclude, resolveVirtualId, runBuildGate, shippedCatalogs, syncCatalogs, syncProject, transformSource, writeBuildTypes, writeDts } from "@verbaly/compiler";
1
+ import { APP_ID, LOCALE_IMPORT, LOCALE_MODULE_PREFIX, MessageRegistry, RESOLVED_VIRTUAL_ID, SOURCE_FILE_RE, createDevReporter, createSourceFilter, extractProject, formatCliError, isTransformTarget, loadCatalogs, loadConfig, loadVirtualModule, reportOutsideInclude, resolveVirtualId, runBuildGate, shippedCatalogs, syncCatalogs, syncProject, transformSource, writeBuildTypes, writeDts } from "@verbaly/compiler";
2
2
  import { readFileSync } from "node:fs";
3
+ import { dirname, resolve } from "node:path";
3
4
  // src/index.ts
4
5
  function safeRead(file) {
5
6
  try {
@@ -19,7 +20,6 @@ function verbaly(options = {}) {
19
20
  let writeTimer;
20
21
  let included;
21
22
  let reporter;
22
- let stateBroken = false;
23
23
  let scan;
24
24
  let writing = Promise.resolve();
25
25
  let registry = new MessageRegistry();
@@ -38,25 +38,7 @@ function verbaly(options = {}) {
38
38
  }
39
39
  function report(result, catalogEdit) {
40
40
  reporter ??= createDevReporter(cfg.root);
41
- const replaced = [];
42
- const code = [];
43
- const lock = [];
44
- for (const finding of result.findings) if (finding.kind === "collision" || finding.kind === "renamed") code.push(finding);
45
- else if (finding.kind === "lock") lock.push(finding);
46
- else if (finding.kind === "replaced" && catalogEdit) replaced.push({
47
- ...finding,
48
- edited: true
49
- });
50
- reporter.report("replaced", replaced);
51
- reporter.report("code", code);
52
- reporter.report("lock", lock);
53
- const outdated = result.state ? outdatedTranslations(cfg, result.catalogs, result.state.fingerprints) : [];
54
- reporter.report("outdated", outdated.map((entry) => ({
55
- kind: "outdated",
56
- ...entry
57
- })));
58
- if (result.stateProblem && !stateBroken) console.warn(`[verbaly] ${result.stateProblem}, so drafts are not tracked`);
59
- stateBroken = Boolean(result.stateProblem);
41
+ reporter.sync(cfg, result, () => catalogEdit ? true : void 0);
60
42
  }
61
43
  async function writeBack(catalogEdit) {
62
44
  if (catalogEdit) cfg = await loadConfig(cfg.root, options, { plugin: true });
@@ -97,7 +79,7 @@ function verbaly(options = {}) {
97
79
  server = devServer;
98
80
  devServer.watcher.add(cfg.dir);
99
81
  const onCatalogFile = (file) => {
100
- if (!file.startsWith(cfg.dir) || !file.endsWith(".json")) return;
82
+ if (resolve(dirname(file)) !== resolve(cfg.dir) || !file.endsWith(".json")) return;
101
83
  const locale = file.split(/[\\/]/).pop().slice(0, -5);
102
84
  if (locale.startsWith(".")) return;
103
85
  const expected = selfWrites.get(locale);
@@ -145,7 +127,7 @@ function verbaly(options = {}) {
145
127
  const { messages, result } = transformSource(code, id, registry, scan);
146
128
  const found = Object.entries(messages);
147
129
  if (!isBuild && found.length > 0) {
148
- const source = catalogs[cfg.sourceLocale] ??= {};
130
+ const source = catalogs[cfg.sourceLocale] ??= Object.create(null);
149
131
  let changed = false;
150
132
  for (const [key, message] of found) if (source[key] !== message) {
151
133
  source[key] = message;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@verbaly/vite",
3
- "version": "0.81.0",
3
+ "version": "0.83.0",
4
4
  "description": "Zero-config Vite plugin for Verbaly: extraction, codegen and HMR.",
5
5
  "keywords": [
6
6
  "i18n",
@@ -42,15 +42,15 @@
42
42
  "access": "public"
43
43
  },
44
44
  "dependencies": {
45
- "@verbaly/compiler": "0.81.0"
45
+ "@verbaly/compiler": "0.83.0"
46
46
  },
47
47
  "peerDependencies": {
48
- "verbaly": "^0.81.0",
48
+ "verbaly": "^0.83.0",
49
49
  "vite": "^7.0.0 || ^8.0.0"
50
50
  },
51
51
  "devDependencies": {
52
- "verbaly": "^0.81.0",
53
- "vite": "^8.3.6"
52
+ "verbaly": "^0.83.0",
53
+ "vite": "^8.3.8"
54
54
  },
55
55
  "scripts": {
56
56
  "build": "tsdown",