@fluenti/vite-plugin 0.2.1 → 0.3.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/types.d.ts CHANGED
@@ -1,55 +1,17 @@
1
- /** Options passed to RuntimeGenerator methods */
2
- export interface RuntimeGeneratorOptions {
3
- catalogDir: string;
4
- locales: string[];
5
- sourceLocale: string;
6
- defaultBuildLocale: string;
7
- }
8
- /** Framework-specific virtual module runtime generator */
9
- export interface RuntimeGenerator {
10
- /** Generate the main reactive runtime module (virtual:fluenti/runtime) */
11
- generateRuntime(options: RuntimeGeneratorOptions): string;
12
- /** Generate the per-route runtime module (virtual:fluenti/route-runtime) */
13
- generateRouteRuntime(options: RuntimeGeneratorOptions): string;
14
- }
1
+ import { FluentiBuildConfig } from '@fluenti/core/internal';
2
+ export type { RuntimeGeneratorOptions, RuntimeGenerator } from '@fluenti/core/transform';
3
+ /** Custom message ID generator function */
4
+ export type IdGenerator = (message: string, context?: string) => string;
15
5
  /** User-facing plugin options (framework packages expose this to consumers) */
16
6
  export interface FluentiPluginOptions {
17
- /** Directory containing compiled message catalogs */
18
- catalogDir?: string;
19
- /** Source locale */
20
- sourceLocale?: string;
21
- /** Available locales */
22
- locales?: string[];
23
- /** Code splitting strategy: 'dynamic' (reactive catalog), 'static' (direct imports), false (off) */
24
- splitting?: 'dynamic' | 'static' | false;
25
- /** Default locale for build-time static strategy */
26
- defaultBuildLocale?: string;
27
- /** Source file patterns for auto extract in dev */
28
- include?: string[];
29
- /** Auto extract+compile in dev mode (default: true) */
30
- devAutoCompile?: boolean;
31
- /** Auto extract+compile before production build (default: true) */
32
- buildAutoCompile?: boolean;
7
+ /** fluenti.config.ts path or inline config. Auto-discovered by default. */
8
+ config?: string | FluentiBuildConfig;
33
9
  }
34
10
  /** Internal options used by createFluentiPlugins (includes required framework field) */
35
11
  export interface FluentiCoreOptions {
36
- /** Directory containing compiled message catalogs */
37
- catalogDir?: string | undefined;
38
- /** Source locale */
39
- sourceLocale?: string | undefined;
40
- /** Available locales */
41
- locales?: string[] | undefined;
42
- /** Code splitting strategy: 'dynamic' (reactive catalog), 'static' (direct imports), false (off) */
43
- splitting?: 'dynamic' | 'static' | false | undefined;
44
- /** Default locale for build-time static strategy */
45
- defaultBuildLocale?: string | undefined;
46
- /** Source file patterns for auto extract in dev */
47
- include?: string[] | undefined;
48
- /** Auto extract+compile in dev mode (default: true) */
49
- devAutoCompile?: boolean | undefined;
50
- /** Auto extract+compile before production build (default: true) */
51
- buildAutoCompile?: boolean | undefined;
52
- /** Framework identifier for scope transform and runtime key */
53
- framework: 'vue' | 'solid' | 'react';
12
+ /** fluenti.config.ts path or inline config. Auto-discovered by default. */
13
+ config?: string | FluentiBuildConfig;
14
+ /** Framework identifier for scope transform and runtime key (e.g. 'vue', 'solid', 'react', 'svelte') */
15
+ framework: string;
54
16
  }
55
17
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,iDAAiD;AACjD,MAAM,WAAW,uBAAuB;IACtC,UAAU,EAAE,MAAM,CAAA;IAClB,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,YAAY,EAAE,MAAM,CAAA;IACpB,kBAAkB,EAAE,MAAM,CAAA;CAC3B;AAED,0DAA0D;AAC1D,MAAM,WAAW,gBAAgB;IAC/B,0EAA0E;IAC1E,eAAe,CAAC,OAAO,EAAE,uBAAuB,GAAG,MAAM,CAAA;IACzD,4EAA4E;IAC5E,oBAAoB,CAAC,OAAO,EAAE,uBAAuB,GAAG,MAAM,CAAA;CAC/D;AAED,+EAA+E;AAC/E,MAAM,WAAW,oBAAoB;IACnC,qDAAqD;IACrD,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,oBAAoB;IACpB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,wBAAwB;IACxB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;I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O,CAAC,EAAE,MAAM,KAAK,MAAM,CAAA;AAEvE,+EAA+E;AAC/E,MAAM,WAAW,oBAAoB;IACnC,2EAA2E;IAC3E,MAAM,CAAC,EAAE,MAAM,GAAG,kBAAkB,CAAA;CACrC;AAED,wFAAwF;AACxF,MAAM,WAAW,kBAAkB;IACjC,2EAA2E;IAC3E,MAAM,CAAC,EAAE,MAAM,GAAG,kBAAkB,CAAA;IACpC,wGAAwG;IACxG,SAAS,EAAE,MAAM,CAAA;CAClB"}
@@ -1,10 +1,12 @@
1
1
  import { RuntimeGenerator } from './types';
2
2
  export interface VirtualModuleOptions {
3
+ rootDir: string;
3
4
  catalogDir: string;
5
+ catalogExtension: string;
4
6
  locales: string[];
5
7
  sourceLocale: string;
6
8
  defaultBuildLocale: string;
7
- framework: 'vue' | 'solid' | 'react';
9
+ framework: string;
8
10
  runtimeGenerator?: RuntimeGenerator | undefined;
9
11
  }
10
12
  export declare function resolveVirtualSplitId(id: string): string | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"virtual-modules.d.ts","sourceRoot":"","sources":["../src/virtual-modules.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,KAAK,EAAE,gBAAgB,EAA2B,MAAM,SAAS,CAAA;AASxE,MAAM,WAAW,oBAAoB;IACnC,UAAU,EAAE,MAAM,CAAA;IAClB,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,YAAY,EAAE,MAAM,CAAA;IACpB,kBAAkB,EAAE,MAAM,CAAA;IAC1B,SAAS,EAAE,KAAK,GAAG,OAAO,GAAG,OAAO,CAAA;IACpC,gBAAgB,CAAC,EAAE,gBAAgB,GAAG,SAAS,CAAA;CAChD;AAED,wBAAgB,qBAAqB,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAKpE;AAED,wBAAgB,sBAAsB,CACpC,EAAE,EAAE,MAAM,EACV,OAAO,EAAE,oBAAoB,GAC5B,MAAM,GAAG,SAAS,CAWpB;AAwBD;;GAEG;AACH,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,oBAAoB,GAAG,MAAM,CAYhF"}
1
+ {"version":3,"file":"virtual-modules.d.ts","sourceRoot":"","sources":["../src/virtual-modules.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,KAAK,EAAE,gBAAgB,EAA2B,MAAM,SAAS,CAAA;AA8BxE,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,MAAM,CAAA;IACf,UAAU,EAAE,MAAM,CAAA;IAClB,gBAAgB,EAAE,MAAM,CAAA;IACxB,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,YAAY,EAAE,MAAM,CAAA;IACpB,kBAAkB,EAAE,MAAM,CAAA;IAC1B,SAAS,EAAE,MAAM,CAAA;IACjB,gBAAgB,CAAC,EAAE,gBAAgB,GAAG,SAAS,CAAA;CAChD;AAED,wBAAgB,qBAAqB,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAKpE;AAED,wBAAgB,sBAAsB,CACpC,EAAE,EAAE,MAAM,EACV,OAAO,EAAE,oBAAoB,GAC5B,MAAM,GAAG,SAAS,CAWpB;AA0BD;;GAEG;AACH,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,oBAAoB,GAAG,MAAM,CAYhF"}
package/llms-full.txt ADDED
@@ -0,0 +1,124 @@
1
+ # @fluenti/vite-plugin
2
+
3
+ > Internal Vite plugin core for Fluenti — provides `createFluentiPlugins()` factory used by framework packages.
4
+
5
+ Docs: https://fluenti.dev
6
+ GitHub: https://github.com/usefluenti/fluenti/tree/main/packages/vite-plugin
7
+ License: MIT
8
+
9
+ ## This is an internal package
10
+
11
+ Users should NOT install `@fluenti/vite-plugin` directly. It is automatically installed as a dependency of the framework packages. Use framework subpath exports instead:
12
+
13
+ ```ts
14
+ // Vue — vite.config.ts
15
+ import fluentiVue from '@fluenti/vue/vite-plugin'
16
+ export default { plugins: [vue(), fluentiVue()] }
17
+
18
+ // React — vite.config.ts
19
+ import fluentiReact from '@fluenti/react/vite-plugin'
20
+ export default { plugins: [fluentiReact(), react()] }
21
+
22
+ // Solid — vite.config.ts
23
+ import fluentiSolid from '@fluenti/solid/vite-plugin'
24
+ export default { plugins: [solidPlugin(), fluentiSolid()] }
25
+ ```
26
+
27
+ Peer dependency: `vite ^5 || ^6 || ^8`
28
+ Runtime dependency: `@fluenti/core`
29
+
30
+ ## Public Options
31
+
32
+ All framework plugins accept the same `FluentiPluginOptions`:
33
+
34
+ ```ts
35
+ interface FluentiPluginOptions {
36
+ catalogDir?: string // default: 'src/locales/compiled'
37
+ sourceLocale?: string // default: 'en'
38
+ locales?: string[] // default: [sourceLocale]
39
+ splitting?: 'dynamic' | 'static' | false // default: false
40
+ defaultBuildLocale?: string // default: sourceLocale
41
+ include?: string[] // default: ['src/**/*.{vue,tsx,jsx,ts,js}']
42
+ devAutoCompile?: boolean // default: true
43
+ }
44
+ ```
45
+
46
+ ## Architecture
47
+
48
+ `@fluenti/vite-plugin` provides a `createFluentiPlugins()` factory that assembles the Vite plugin pipeline:
49
+
50
+ 1. `fluenti:virtual` — resolves virtual modules (`virtual:fluenti/messages/*`, `virtual:fluenti/runtime`)
51
+ 2. Framework-specific plugins (injected by the calling framework package)
52
+ 3. `fluenti:script-transform` — AST-based `t`` ` tagged template and `<Trans>` compile-time transforms
53
+ 4. `fluenti:build-split` — build-time code splitting (dynamic/static/per-route)
54
+ 5. `fluenti:dev` — dev-mode auto-compile + HMR for catalog changes
55
+
56
+ Framework packages provide:
57
+ - A `RuntimeGenerator` that generates framework-specific reactive runtime code (Vue uses `shallowReactive`, Solid uses `createStore`, React uses plain objects)
58
+ - Framework-specific plugins (e.g., Vue's `v-t` template transform)
59
+
60
+ ## What The Plugin Transforms
61
+
62
+ ### direct-import `t`
63
+
64
+ ```ts
65
+ import { t } from '@fluenti/react'
66
+ t`Hello ${name}`
67
+ t({ message: 'Hello {name}', context: 'home.hero' }, { name })
68
+ ```
69
+
70
+ Rewritten to framework runtime `t` binding with stable IDs.
71
+
72
+ ### `useI18n().t`
73
+
74
+ ```ts
75
+ const { t } = useI18n()
76
+ const { t: translate } = useI18n()
77
+ ```
78
+
79
+ Runtime APIs that also participate in build-time chunk planning.
80
+
81
+ ### Vue template features (via `@fluenti/vue/vite-plugin`)
82
+
83
+ - `v-t` directive
84
+ - `v-t.plural`, `.alt`, `.placeholder`, `.title` modifiers
85
+ - `<Trans>`, `<Plural>`, `<Select>` components
86
+
87
+ ### JSX components (React & Solid)
88
+
89
+ `<Trans>`, `<Plural>`, and `<Select>` message usage collected for chunk splitting.
90
+
91
+ ## Chunk Splitting
92
+
93
+ ### `'dynamic'`
94
+
95
+ - Default locale in initial bundle
96
+ - Non-default locales loaded on demand via `switchLocale()`
97
+ - Transformed lookups read from an internal reactive catalog
98
+
99
+ ### `'static'`
100
+
101
+ - All lookups rewritten to statically imported catalog entries
102
+ - Ideal for SSR / SSG single-locale builds
103
+
104
+ ### `false`
105
+
106
+ Disables locale chunk splitting.
107
+
108
+ ## Exports
109
+
110
+ ```ts
111
+ // Named exports only — no default export
112
+ export function createFluentiPlugins(
113
+ options: FluentiCoreOptions,
114
+ frameworkPlugins: Plugin[],
115
+ runtimeGenerator?: RuntimeGenerator,
116
+ ): Plugin[]
117
+
118
+ export type { FluentiPluginOptions } // user-facing options
119
+ export type { FluentiCoreOptions } // internal options (includes framework field)
120
+ export type { RuntimeGenerator } // framework-specific runtime generator
121
+ export type { RuntimeGeneratorOptions } // options passed to generator methods
122
+ ```
123
+
124
+ The `sfc-transform` subpath export provides Vue SFC template transformation utilities used by `@fluenti/vue/vite-plugin`.
package/llms.txt ADDED
@@ -0,0 +1,57 @@
1
+ # @fluenti/vite-plugin
2
+
3
+ > Internal Vite plugin core for Fluenti — provides `createFluentiPlugins()` factory used by framework packages.
4
+
5
+ Docs: https://fluenti.dev
6
+ GitHub: https://github.com/usefluenti/fluenti/tree/main/packages/vite-plugin
7
+
8
+ ## This is an internal package
9
+
10
+ Users should NOT install this directly. Instead use framework subpath exports:
11
+
12
+ ```ts
13
+ // Vue
14
+ import fluentiVue from '@fluenti/vue/vite-plugin'
15
+
16
+ // React
17
+ import fluentiReact from '@fluenti/react/vite-plugin'
18
+
19
+ // Solid
20
+ import fluentiSolid from '@fluenti/solid/vite-plugin'
21
+ ```
22
+
23
+ ## Plugin Options
24
+
25
+ All framework plugins accept the same `FluentiPluginOptions`:
26
+
27
+ - `catalogDir`: path to compiled message catalogs (default: `'src/locales/compiled'`)
28
+ - `sourceLocale`: source locale (default: `'en'`)
29
+ - `locales`: available locales (default: `[sourceLocale]`)
30
+ - `splitting`: `'dynamic' | 'static' | false` (default: `false`)
31
+ - `defaultBuildLocale`: locale used for `'static'` builds (default: `sourceLocale`)
32
+
33
+ ## What It Transforms
34
+
35
+ - direct-import `t` from `@fluenti/vue`, `@fluenti/react`, or `@fluenti/solid`
36
+ - runtime `t` bindings from `useI18n()`
37
+ - Vue `v-t` (via `@fluenti/vue/vite-plugin`)
38
+ - `<Trans>`, `<Plural>`, and `<Select>`
39
+
40
+ ## Splitting Model
41
+
42
+ - `'dynamic'`: default locale stays in the initial bundle; other locales load on demand
43
+ - `'static'`: inline one locale at build time, ideal for SSR / SSG single-locale builds
44
+ - `false`: no locale chunk splitting
45
+
46
+ ## Exports
47
+
48
+ - `createFluentiPlugins(options, frameworkPlugins, runtimeGenerator): Plugin[]`
49
+ - `FluentiPluginOptions`: user-facing plugin options type
50
+ - `FluentiCoreOptions`: internal options type (includes `framework` field)
51
+ - `RuntimeGenerator`, `RuntimeGeneratorOptions`: interface for framework-specific runtime generation
52
+ - `resolveVirtualSplitId(id)`: Resolve a virtual split module ID to its `\0`-prefixed form
53
+ - `loadVirtualSplitModule(id, options)`: Load and generate code for a virtual split module
54
+ - `setResolvedMode(command)`: Set the resolved Vite command mode ('serve' | 'build')
55
+ - `isBuildMode(env?)`: Check if the current Vite environment is a production build
56
+ - `getPluginEnvironment(pluginContext)`: Get the plugin environment from a Vite plugin context
57
+ - `IdGenerator`: Type for custom message ID generation functions
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluenti/vite-plugin",
3
- "version": "0.2.1",
3
+ "version": "0.3.0",
4
4
  "type": "module",
5
5
  "description": "Vite plugin for Fluenti — build-time transforms, virtual modules, code splitting",
6
6
  "homepage": "https://fluenti.dev",
@@ -57,10 +57,11 @@
57
57
  },
58
58
  "files": [
59
59
  "dist",
60
- "client.d.ts"
60
+ "client.d.ts",
61
+ "llms*.txt"
61
62
  ],
62
63
  "dependencies": {
63
- "@fluenti/core": "0.2.1"
64
+ "@fluenti/core": "0.3.0"
64
65
  },
65
66
  "peerDependencies": {
66
67
  "vite": "^5 || ^6 || ^8"
@@ -1,3 +0,0 @@
1
- export { scopeTransform } from '@fluenti/core/internal';
2
- export type { ScopeTransformOptions, ScopeTransformResult, Replacement } from '@fluenti/core/internal';
3
- //# sourceMappingURL=scope-transform.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"scope-transform.d.ts","sourceRoot":"","sources":["../src/scope-transform.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AACvD,YAAY,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA"}
@@ -1,3 +0,0 @@
1
- export { transformTransComponents } from '@fluenti/core/internal';
2
- export type { TransTransformResult } from '@fluenti/core/internal';
3
- //# sourceMappingURL=trans-transform.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"trans-transform.d.ts","sourceRoot":"","sources":["../src/trans-transform.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAA;AACjE,YAAY,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA"}