@gringow/gringow-vite 0.0.6 โ†’ 0.2.1

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
@@ -7,7 +7,7 @@ Vite plugin for Gringow that automatically extracts translation strings during d
7
7
 
8
8
  ## Features
9
9
 
10
- - ๐Ÿ” **Automatic Extraction** - Finds all `g` tagged templates in your code
10
+ - ๐Ÿ” **Automatic Extraction** - Finds `g` and `gid` tagged templates in your code
11
11
  - ๐Ÿ”„ **Cache Synchronization** - Keeps translations in sync with source code
12
12
  - ๐Ÿงน **Smart Cleanup** - Removes unused translations automatically
13
13
  - โšก **Build-Time Translation** - Generates cache during Vite builds
@@ -51,8 +51,9 @@ export default defineConfig({
51
51
  // gringow.config.js
52
52
  export default {
53
53
  llm: {
54
- choice: 'huggingface',
55
- model: 'Xenova/nllb-200-distilled-600M',
54
+ provider: 'openai',
55
+ apiKey: process.env.OPENAI_API_KEY,
56
+ model: 'gpt-4o-mini',
56
57
  },
57
58
  languages: ['pt-BR', 'es-ES', 'fr-CA'],
58
59
  sourceLanguage: 'en-US',
@@ -82,7 +83,7 @@ pnpm run build
82
83
  ```
83
84
 
84
85
  The plugin automatically:
85
- - Scans your source files for `g` tagged templates
86
+ - Scans your source files for `g` and `gid` tagged templates
86
87
  - Generates translations using configured LLM
87
88
  - Writes to `./gringow/gringow.json`
88
89
  - Updates cache as you code
@@ -164,7 +165,7 @@ The plugin hooks into Vite's transform pipeline:
164
165
  ### Transform Hook
165
166
 
166
167
  - **Scans modules** - Checks each transformed file for `g` tagged templates
167
- - **Extracts strings** - Parses template literals and dynamic values
168
+ - **Extracts strings** - Parses template literals from `g`/`gid` tags
168
169
  - **Generates IDs** - Creates content-based cache IDs
169
170
  - **Calls core library** - Invokes `@gringow/gringow` to translate and cache
170
171
 
@@ -228,14 +229,7 @@ export default function App() {
228
229
  export default {
229
230
  // Scan TypeScript files only
230
231
  globby: './src/**/*.{ts,tsx}',
231
-
232
- // Or include multiple patterns
233
- globby: [
234
- './src/**/*.{ts,tsx}',
235
- './components/**/*.{ts,tsx}',
236
- '!./src/**/*.test.tsx'
237
- ],
238
-
232
+
239
233
  languages: ['pt-BR', 'es-ES'],
240
234
  }
241
235
  ```
@@ -324,7 +318,7 @@ pnpm run watch
324
318
  - **[@gringow/gringow](https://www.npmjs.com/package/@gringow/gringow)** - Core translation library
325
319
  - **[@gringow/gringow-react](https://www.npmjs.com/package/@gringow/gringow-react)** - React bindings
326
320
  - **[@gringow/gringow-shadow](https://www.npmjs.com/package/@gringow/gringow-shadow)** - Web Component layer
327
- - **[@gringow/cli](https://www.npmjs.com/package/@gringow/gringow-cli)** - CLI tool
321
+ - **[@gringow/gringow-cli](https://www.npmjs.com/package/@gringow/gringow-cli)** - CLI tool
328
322
  - **[@gringow/gringow-nextjs](https://www.npmjs.com/package/@gringow/gringow-nextjs)** - Next.js plugin (experimental)
329
323
 
330
324
  ## Resources
@@ -6,7 +6,7 @@ import fs from 'fs/promises';
6
6
 
7
7
  // src/get-matches-in-code.ts
8
8
  function getMatchesInCode(code) {
9
- const regex = /g`((?:\\`|[^`])+)`/g;
9
+ const regex = /g(?:id)?`((?:\\`|[^`])+)`/g;
10
10
  return [...new Set([...code.matchAll(regex)].map(([, value = ""]) => value))];
11
11
  }
12
12
  async function getMatchesFromFile(filePath) {
@@ -4,7 +4,7 @@ import fs from 'fs/promises';
4
4
 
5
5
  // src/get-matches-in-code.ts
6
6
  function getMatchesInCode(code) {
7
- const regex = /g`((?:\\`|[^`])+)`/g;
7
+ const regex = /g(?:id)?`((?:\\`|[^`])+)`/g;
8
8
  return [...new Set([...code.matchAll(regex)].map(([, value = ""]) => value))];
9
9
  }
10
10
 
@@ -1,6 +1,6 @@
1
1
  // src/get-matches-in-code.ts
2
2
  function getMatchesInCode(code) {
3
- const regex = /g`((?:\\`|[^`])+)`/g;
3
+ const regex = /g(?:id)?`((?:\\`|[^`])+)`/g;
4
4
  return [...new Set([...code.matchAll(regex)].map(([, value = ""]) => value))];
5
5
  }
6
6
 
@@ -6,7 +6,7 @@ import fs from 'fs/promises';
6
6
 
7
7
  // src/get-matches-in-code.ts
8
8
  function getMatchesInCode(code) {
9
- const regex = /g`((?:\\`|[^`])+)`/g;
9
+ const regex = /g(?:id)?`((?:\\`|[^`])+)`/g;
10
10
  return [...new Set([...code.matchAll(regex)].map(([, value = ""]) => value))];
11
11
  }
12
12
 
package/dist/index.mjs CHANGED
@@ -6,7 +6,7 @@ import fs from 'fs/promises';
6
6
 
7
7
  // src/get-matches-in-code.ts
8
8
  function getMatchesInCode(code) {
9
- const regex = /g`((?:\\`|[^`])+)`/g;
9
+ const regex = /g(?:id)?`((?:\\`|[^`])+)`/g;
10
10
  return [...new Set([...code.matchAll(regex)].map(([, value = ""]) => value))];
11
11
  }
12
12
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gringow/gringow-vite",
3
- "version": "0.0.6",
3
+ "version": "0.2.1",
4
4
  "description": "A Vite plugin for Gringow AI-powered translation tool",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -40,7 +40,7 @@
40
40
  "dependencies": {
41
41
  "globby": "14.1.0",
42
42
  "vite": "7.0.0",
43
- "@gringow/gringow": "0.1.4"
43
+ "@gringow/gringow": "0.2.1"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@types/node": "22.15.0",