@intlayer/engine 9.0.0-canary.12 → 9.0.0-canary.14
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/cjs/cli.cjs +1 -0
- package/dist/cjs/createType/createModuleAugmentation.cjs +1 -1
- package/dist/cjs/createType/createModuleAugmentation.cjs.map +1 -1
- package/dist/cjs/createType/createType.cjs +2 -1
- package/dist/cjs/createType/createType.cjs.map +1 -1
- package/dist/cjs/init/cms.cjs +18 -0
- package/dist/cjs/init/cms.cjs.map +1 -1
- package/dist/cjs/init/frameworkSetup/nextAppRouter/detect.cjs +2 -11
- package/dist/cjs/init/frameworkSetup/nextAppRouter/detect.cjs.map +1 -1
- package/dist/cjs/init/frameworkSetup/nextAppRouter/index.cjs +2 -1
- package/dist/cjs/init/frameworkSetup/nextAppRouter/index.cjs.map +1 -1
- package/dist/cjs/init/frameworkSetup/nextAppRouter/restructure.cjs +2 -1
- package/dist/cjs/init/frameworkSetup/nextAppRouter/restructure.cjs.map +1 -1
- package/dist/cjs/init/frameworkSetup/nextAppRouter/transforms.cjs +2 -1
- package/dist/cjs/init/frameworkSetup/nextAppRouter/transforms.cjs.map +1 -1
- package/dist/cjs/init/frameworkSetup/tanstackStart/transforms.cjs +2 -1
- package/dist/cjs/init/frameworkSetup/tanstackStart/transforms.cjs.map +1 -1
- package/dist/cjs/init/index.cjs +35 -11
- package/dist/cjs/init/index.cjs.map +1 -1
- package/dist/cjs/init/utils/configManipulation.cjs +43 -15
- package/dist/cjs/init/utils/configManipulation.cjs.map +1 -1
- package/dist/cjs/init/utils/index.cjs +3 -0
- package/dist/cjs/init/utils/version.cjs +17 -0
- package/dist/cjs/init/utils/version.cjs.map +1 -0
- package/dist/cjs/initConfig/index.cjs +6 -8
- package/dist/cjs/initConfig/index.cjs.map +1 -1
- package/dist/cjs/loadDictionaries/loadContentDeclaration.cjs +2 -2
- package/dist/cjs/loadDictionaries/loadContentDeclaration.cjs.map +1 -1
- package/dist/cjs/prepareIntlayer.cjs +11 -7
- package/dist/cjs/prepareIntlayer.cjs.map +1 -1
- package/dist/cjs/syncPluginKit/createFileAdapter.cjs +119 -0
- package/dist/cjs/syncPluginKit/createFileAdapter.cjs.map +1 -0
- package/dist/cjs/syncPluginKit/createSyncPlugin.cjs +154 -0
- package/dist/cjs/syncPluginKit/createSyncPlugin.cjs.map +1 -0
- package/dist/cjs/syncPluginKit/extractKeyAndLocaleFromPath.cjs +37 -0
- package/dist/cjs/syncPluginKit/extractKeyAndLocaleFromPath.cjs.map +1 -0
- package/dist/cjs/syncPluginKit/filePathPatternHelpers.cjs +20 -0
- package/dist/cjs/syncPluginKit/filePathPatternHelpers.cjs.map +1 -0
- package/dist/cjs/syncPluginKit/index.cjs +11 -0
- package/dist/cjs/syncPluginKit/types.cjs +0 -0
- package/dist/cjs/utils/recastBabelParser.cjs +67 -0
- package/dist/cjs/utils/recastBabelParser.cjs.map +1 -0
- package/dist/cjs/utils/runParallel/index.cjs +2 -2
- package/dist/cjs/utils/runParallel/index.cjs.map +1 -1
- package/dist/cjs/watcher.cjs +2 -3
- package/dist/cjs/watcher.cjs.map +1 -1
- package/dist/cjs/writeContentDeclaration/transformJSFile.cjs +2 -3
- package/dist/cjs/writeContentDeclaration/transformJSFile.cjs.map +1 -1
- package/dist/cjs/writeFileIfChanged.cjs +41 -17
- package/dist/cjs/writeFileIfChanged.cjs.map +1 -1
- package/dist/esm/cli.mjs +2 -2
- package/dist/esm/createType/createModuleAugmentation.mjs +1 -1
- package/dist/esm/createType/createModuleAugmentation.mjs.map +1 -1
- package/dist/esm/createType/createType.mjs +3 -2
- package/dist/esm/createType/createType.mjs.map +1 -1
- package/dist/esm/init/cms.mjs +19 -2
- package/dist/esm/init/cms.mjs.map +1 -1
- package/dist/esm/init/frameworkSetup/nextAppRouter/detect.mjs +1 -10
- package/dist/esm/init/frameworkSetup/nextAppRouter/detect.mjs.map +1 -1
- package/dist/esm/init/frameworkSetup/nextAppRouter/index.mjs +2 -1
- package/dist/esm/init/frameworkSetup/nextAppRouter/index.mjs.map +1 -1
- package/dist/esm/init/frameworkSetup/nextAppRouter/restructure.mjs +2 -2
- package/dist/esm/init/frameworkSetup/nextAppRouter/restructure.mjs.map +1 -1
- package/dist/esm/init/frameworkSetup/nextAppRouter/transforms.mjs +2 -2
- package/dist/esm/init/frameworkSetup/nextAppRouter/transforms.mjs.map +1 -1
- package/dist/esm/init/frameworkSetup/tanstackStart/transforms.mjs +2 -2
- package/dist/esm/init/frameworkSetup/tanstackStart/transforms.mjs.map +1 -1
- package/dist/esm/init/index.mjs +36 -13
- package/dist/esm/init/index.mjs.map +1 -1
- package/dist/esm/init/utils/configManipulation.mjs +43 -17
- package/dist/esm/init/utils/configManipulation.mjs.map +1 -1
- package/dist/esm/init/utils/index.mjs +3 -2
- package/dist/esm/init/utils/version.mjs +15 -0
- package/dist/esm/init/utils/version.mjs.map +1 -0
- package/dist/esm/initConfig/index.mjs +6 -8
- package/dist/esm/initConfig/index.mjs.map +1 -1
- package/dist/esm/loadDictionaries/loadContentDeclaration.mjs +2 -2
- package/dist/esm/loadDictionaries/loadContentDeclaration.mjs.map +1 -1
- package/dist/esm/prepareIntlayer.mjs +11 -7
- package/dist/esm/prepareIntlayer.mjs.map +1 -1
- package/dist/esm/syncPluginKit/createFileAdapter.mjs +115 -0
- package/dist/esm/syncPluginKit/createFileAdapter.mjs.map +1 -0
- package/dist/esm/syncPluginKit/createSyncPlugin.mjs +152 -0
- package/dist/esm/syncPluginKit/createSyncPlugin.mjs.map +1 -0
- package/dist/esm/syncPluginKit/extractKeyAndLocaleFromPath.mjs +35 -0
- package/dist/esm/syncPluginKit/extractKeyAndLocaleFromPath.mjs.map +1 -0
- package/dist/esm/syncPluginKit/filePathPatternHelpers.mjs +18 -0
- package/dist/esm/syncPluginKit/filePathPatternHelpers.mjs.map +1 -0
- package/dist/esm/syncPluginKit/index.mjs +6 -0
- package/dist/esm/syncPluginKit/types.mjs +0 -0
- package/dist/esm/utils/recastBabelParser.mjs +64 -0
- package/dist/esm/utils/recastBabelParser.mjs.map +1 -0
- package/dist/esm/utils/runParallel/index.mjs +2 -2
- package/dist/esm/utils/runParallel/index.mjs.map +1 -1
- package/dist/esm/watcher.mjs +2 -3
- package/dist/esm/watcher.mjs.map +1 -1
- package/dist/esm/writeContentDeclaration/transformJSFile.mjs +1 -1
- package/dist/esm/writeContentDeclaration/transformJSFile.mjs.map +1 -1
- package/dist/esm/writeFileIfChanged.mjs +44 -20
- package/dist/esm/writeFileIfChanged.mjs.map +1 -1
- package/dist/types/cli.d.ts +2 -2
- package/dist/types/createType/createType.d.ts.map +1 -1
- package/dist/types/init/cms.d.ts +7 -1
- package/dist/types/init/cms.d.ts.map +1 -1
- package/dist/types/init/frameworkSetup/nextAppRouter/detect.d.ts +2 -5
- package/dist/types/init/frameworkSetup/nextAppRouter/detect.d.ts.map +1 -1
- package/dist/types/init/frameworkSetup/nextAppRouter/restructure.d.ts.map +1 -1
- package/dist/types/init/frameworkSetup/nextAppRouter/transforms.d.ts.map +1 -1
- package/dist/types/init/frameworkSetup/tanstackStart/transforms.d.ts.map +1 -1
- package/dist/types/init/index.d.ts +25 -1
- package/dist/types/init/index.d.ts.map +1 -1
- package/dist/types/init/utils/configManipulation.d.ts +10 -1
- package/dist/types/init/utils/configManipulation.d.ts.map +1 -1
- package/dist/types/init/utils/index.d.ts +3 -2
- package/dist/types/init/utils/version.d.ts +9 -0
- package/dist/types/init/utils/version.d.ts.map +1 -0
- package/dist/types/initConfig/index.d.ts +13 -3
- package/dist/types/initConfig/index.d.ts.map +1 -1
- package/dist/types/syncPluginKit/createFileAdapter.d.ts +51 -0
- package/dist/types/syncPluginKit/createFileAdapter.d.ts.map +1 -0
- package/dist/types/syncPluginKit/createSyncPlugin.d.ts +18 -0
- package/dist/types/syncPluginKit/createSyncPlugin.d.ts.map +1 -0
- package/dist/types/syncPluginKit/extractKeyAndLocaleFromPath.d.ts +20 -0
- package/dist/types/syncPluginKit/extractKeyAndLocaleFromPath.d.ts.map +1 -0
- package/dist/types/syncPluginKit/filePathPatternHelpers.d.ts +16 -0
- package/dist/types/syncPluginKit/filePathPatternHelpers.d.ts.map +1 -0
- package/dist/types/syncPluginKit/index.d.ts +6 -0
- package/dist/types/syncPluginKit/types.d.ts +149 -0
- package/dist/types/syncPluginKit/types.d.ts.map +1 -0
- package/dist/types/utils/recastBabelParser.d.ts +12 -0
- package/dist/types/utils/recastBabelParser.d.ts.map +1 -0
- package/dist/types/utils/runParallel/index.d.ts +6 -1
- package/dist/types/utils/runParallel/index.d.ts.map +1 -1
- package/dist/types/watcher.d.ts.map +1 -1
- package/dist/types/writeFileIfChanged.d.ts +30 -6
- package/dist/types/writeFileIfChanged.d.ts.map +1 -1
- package/package.json +27 -10
- package/dist/esm/_virtual/_rolldown/runtime.mjs +0 -8
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.d.ts","names":[],"sources":["../../../../src/init/utils/version.ts"],"mappings":";;AAIA;;;cAAa,gBAAA,GACX,OAAA,sBACA,KAAA"}
|
|
@@ -1,10 +1,20 @@
|
|
|
1
1
|
import { configurationFilesCandidates } from "@intlayer/config/node";
|
|
2
2
|
|
|
3
3
|
//#region src/initConfig/index.d.ts
|
|
4
|
+
/** Values injected into the configuration file template. */
|
|
5
|
+
type InitConfigOptions = {
|
|
6
|
+
/** Locales detected in the project, inserted into `internationalization.locales`. */locales?: string[];
|
|
7
|
+
/**
|
|
8
|
+
* Dev-server URL of the detected framework, inserted as
|
|
9
|
+
* `editor.applicationURL` (the template defaults to `http://localhost:3000`).
|
|
10
|
+
*/
|
|
11
|
+
applicationURL?: string;
|
|
12
|
+
};
|
|
4
13
|
/**
|
|
5
|
-
* Initialize the Intlayer configuration file
|
|
14
|
+
* Initialize the Intlayer configuration file. No-ops when a configuration file
|
|
15
|
+
* already exists at `baseDir`.
|
|
6
16
|
*/
|
|
7
|
-
declare const initConfig: (format: (typeof configurationFilesCandidates)[number], baseDir: string,
|
|
17
|
+
declare const initConfig: (format: (typeof configurationFilesCandidates)[number], baseDir: string, options?: InitConfigOptions) => Promise<void>;
|
|
8
18
|
//#endregion
|
|
9
|
-
export { initConfig };
|
|
19
|
+
export { InitConfigOptions, initConfig };
|
|
10
20
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/initConfig/index.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/initConfig/index.ts"],"mappings":";;;;KA6BY,iBAAA;EAAA,qFAEV,OAAA;;;;AAYF;EAPE,cAAA;AAAA;;;;;cAOW,UAAA,GACX,MAAA,UAAgB,4BAAA,WAChB,OAAA,UACA,OAAA,GAAU,iBAAA,KAAiB,OAAA"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { ContentAdapter, FormatCodec, SyncContent, SyncPluginContext } from "./types.js";
|
|
2
|
+
import { FilePathPattern } from "@intlayer/types/filePathPattern";
|
|
3
|
+
|
|
4
|
+
//#region src/syncPluginKit/createFileAdapter.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Discovery strategy of the file adapter:
|
|
7
|
+
* - `strict`: keep only files whose path rebuilds identically from the source
|
|
8
|
+
* pattern, and fabricate entries for missing locales/keys so every declared
|
|
9
|
+
* locale has a write-back target (sync plugins).
|
|
10
|
+
* - `inclusive`: keep every glob match without fabricating missing entries
|
|
11
|
+
* (read-only load plugins, whose patterns may contain free `**` globs).
|
|
12
|
+
*/
|
|
13
|
+
type FileAdapterDiscovery = 'strict' | 'inclusive';
|
|
14
|
+
type CreateFileAdapterOptions = {
|
|
15
|
+
/**
|
|
16
|
+
* Location of the files, as a static string, a templated string
|
|
17
|
+
* (e.g. `./messages/{{locale}}/{{key}}.json`) or a function building the
|
|
18
|
+
* path from the key and locale.
|
|
19
|
+
*/
|
|
20
|
+
source: FilePathPattern;
|
|
21
|
+
/**
|
|
22
|
+
* Format of the files: string payload ↔ structured content.
|
|
23
|
+
*/
|
|
24
|
+
codec: FormatCodec;
|
|
25
|
+
/**
|
|
26
|
+
* Optional override of how one file is read and parsed. Defaults to a plain
|
|
27
|
+
* utf-8 read followed by `codec.parse`, returning `undefined` for missing or
|
|
28
|
+
* unreadable files. Adapters needing richer loading (e.g. JSON5 or
|
|
29
|
+
* transpiled TS sources) provide their own implementation here.
|
|
30
|
+
*/
|
|
31
|
+
readEntry?: (absoluteFilePath: string, context: SyncPluginContext) => Promise<SyncContent | undefined>;
|
|
32
|
+
/**
|
|
33
|
+
* Discovery strategy. Defaults to `'strict'`.
|
|
34
|
+
*/
|
|
35
|
+
discovery?: FileAdapterDiscovery;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Create a filesystem {@link ContentAdapter} for `createSyncPlugin`.
|
|
39
|
+
*
|
|
40
|
+
* Handles glob discovery of the source pattern, key/locale extraction from
|
|
41
|
+
* paths, base-directory resolution, and change-detected atomic writes.
|
|
42
|
+
*/
|
|
43
|
+
declare const createFileAdapter: (options: CreateFileAdapterOptions) => ContentAdapter;
|
|
44
|
+
/**
|
|
45
|
+
* Default `readEntry` implementation: plain utf-8 read followed by the given
|
|
46
|
+
* parser. Returns `undefined` for missing or unreadable files.
|
|
47
|
+
*/
|
|
48
|
+
declare const createFileReader: (parse: (raw: string) => SyncContent) => (absoluteFilePath: string) => Promise<SyncContent | undefined>;
|
|
49
|
+
//#endregion
|
|
50
|
+
export { CreateFileAdapterOptions, FileAdapterDiscovery, createFileAdapter, createFileReader };
|
|
51
|
+
//# sourceMappingURL=createFileAdapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createFileAdapter.d.ts","names":[],"sources":["../../../src/syncPluginKit/createFileAdapter.ts"],"mappings":";;;;;;AAyBA;;;;;AAEA;KAFY,oBAAA;AAAA,KAEA,wBAAA;EAMF;;;;;EAAR,MAAA,EAAQ,eAAA;EAqBwB;;;EAhBhC,KAAA,EAAO,WAAA;EAAP;;;;;;EAQA,SAAA,IACE,gBAAA,UACA,OAAA,EAAS,iBAAA,KACN,OAAA,CAAQ,WAAA;EAAA;;;EAKb,SAAA,GAAY,oBAAA;AAAA;AAYd;;;;;;AAAA,cAAa,iBAAA,GACX,OAAA,EAAS,wBAAA,KACR,cAAA;;;AAwNH;;cAAa,gBAAA,GACV,KAAA,GAAQ,GAAA,aAAgB,WAAA,MAClB,gBAAA,aAA2B,OAAA,CAAQ,WAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { CreateSyncPluginOptions } from "./types.js";
|
|
2
|
+
import { Plugin } from "@intlayer/types/plugin";
|
|
3
|
+
|
|
4
|
+
//#region src/syncPluginKit/createSyncPlugin.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Build an Intlayer {@link Plugin} from a transport adapter.
|
|
7
|
+
*
|
|
8
|
+
* The factory implements the three plugin hooks once — ingestion
|
|
9
|
+
* (`loadDictionaries`), content-declaration reformatting (`formatOutput`) and
|
|
10
|
+
* write-back (`afterBuild`) — so adapters only describe *where* content lives
|
|
11
|
+
* (filesystem, TMS such as Crowdin, extra CMS…) and codecs only describe the
|
|
12
|
+
* payload format. Write-back only processes dictionaries whose `location`
|
|
13
|
+
* matches this plugin instance, so adapters never see foreign content.
|
|
14
|
+
*/
|
|
15
|
+
declare const createSyncPlugin: (options: CreateSyncPluginOptions) => Plugin;
|
|
16
|
+
//#endregion
|
|
17
|
+
export { createSyncPlugin };
|
|
18
|
+
//# sourceMappingURL=createSyncPlugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createSyncPlugin.d.ts","names":[],"sources":["../../../src/syncPluginKit/createSyncPlugin.ts"],"mappings":";;;;;;AAuCA;;;;;;;;cAAa,gBAAA,GAAoB,OAAA,EAAS,uBAAA,KAA0B,MAAA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Locale } from "@intlayer/types/allLocales";
|
|
2
|
+
|
|
3
|
+
//#region src/syncPluginKit/extractKeyAndLocaleFromPath.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Extract the dictionary key and locale of a file path by matching it against
|
|
6
|
+
* a mask pattern where `{{__KEY__}}` and `{{__LOCALE__}}` mark the positions
|
|
7
|
+
* of the key and locale segments.
|
|
8
|
+
*
|
|
9
|
+
* Returns `null` when the path does not match the mask, or when the mask
|
|
10
|
+
* contains no placeholder at all (no named capture group can be produced).
|
|
11
|
+
* Missing placeholders fall back to `'index'` for the key and to
|
|
12
|
+
* `defaultLocale` for the locale.
|
|
13
|
+
*/
|
|
14
|
+
declare const extractKeyAndLocaleFromPath: (filePath: string, maskPattern: string, locales: Locale[], defaultLocale: Locale) => {
|
|
15
|
+
key: string;
|
|
16
|
+
locale: Locale;
|
|
17
|
+
} | null;
|
|
18
|
+
//#endregion
|
|
19
|
+
export { extractKeyAndLocaleFromPath };
|
|
20
|
+
//# sourceMappingURL=extractKeyAndLocaleFromPath.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extractKeyAndLocaleFromPath.d.ts","names":[],"sources":["../../../src/syncPluginKit/extractKeyAndLocaleFromPath.ts"],"mappings":";;;;;AAeA;;;;;;;;cAAa,2BAAA,GACX,QAAA,UACA,WAAA,UACA,OAAA,EAAS,MAAA,IACT,aAAA,EAAe,MAAA;EACZ,GAAA;EAAa,MAAA,EAAQ,MAAA;AAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { FilePathPatternContext } from "@intlayer/types/filePathPattern";
|
|
2
|
+
|
|
3
|
+
//#region src/syncPluginKit/filePathPatternHelpers.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Build the context handed to `parseFilePathPattern` from the only two
|
|
6
|
+
* variables sync plugins resolve: the dictionary key and the locale.
|
|
7
|
+
*
|
|
8
|
+
* `FilePathPatternContext` declares extra fields (`fileName`, `extension`,
|
|
9
|
+
* `format`…) that only apply to content-declaration paths; sync-plugin
|
|
10
|
+
* patterns never reference them, so this single cast keeps the partial
|
|
11
|
+
* context in one audited place instead of scattering `as any` at call sites.
|
|
12
|
+
*/
|
|
13
|
+
declare const buildFilePathPatternContext: (key: string, locale?: string) => FilePathPatternContext;
|
|
14
|
+
//#endregion
|
|
15
|
+
export { buildFilePathPatternContext };
|
|
16
|
+
//# sourceMappingURL=filePathPatternHelpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filePathPatternHelpers.d.ts","names":[],"sources":["../../../src/syncPluginKit/filePathPatternHelpers.ts"],"mappings":";;;;;AAWA;;;;;;;cAAa,2BAAA,GACX,GAAA,UACA,MAAA,cACC,sBAAA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ContentAdapter, ContentEntry, ContentTarget, CreateSyncPluginOptions, FormatCodec, SyncContent, SyncDirection, SyncPluginContext } from "./types.js";
|
|
2
|
+
import { CreateFileAdapterOptions, FileAdapterDiscovery, createFileAdapter, createFileReader } from "./createFileAdapter.js";
|
|
3
|
+
import { createSyncPlugin } from "./createSyncPlugin.js";
|
|
4
|
+
import { extractKeyAndLocaleFromPath } from "./extractKeyAndLocaleFromPath.js";
|
|
5
|
+
import { buildFilePathPatternContext } from "./filePathPatternHelpers.js";
|
|
6
|
+
export { type ContentAdapter, type ContentEntry, type ContentTarget, type CreateFileAdapterOptions, type CreateSyncPluginOptions, type FileAdapterDiscovery, type FormatCodec, type SyncContent, type SyncDirection, type SyncPluginContext, buildFilePathPatternContext, createFileAdapter, createFileReader, createSyncPlugin, extractKeyAndLocaleFromPath };
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { IntlayerConfig } from "@intlayer/types/config";
|
|
2
|
+
import { DictionaryFormat } from "@intlayer/types/dictionary";
|
|
3
|
+
import { Locale } from "@intlayer/types/allLocales";
|
|
4
|
+
|
|
5
|
+
//#region src/syncPluginKit/types.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* Structured dictionary content handled by sync plugins.
|
|
8
|
+
*/
|
|
9
|
+
type SyncContent = Record<string, unknown>;
|
|
10
|
+
/**
|
|
11
|
+
* Context handed to every {@link ContentAdapter} call.
|
|
12
|
+
*/
|
|
13
|
+
type SyncPluginContext = {
|
|
14
|
+
configuration: IntlayerConfig;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* One translatable resource discovered in the external system.
|
|
18
|
+
*/
|
|
19
|
+
type ContentEntry = {
|
|
20
|
+
/** Dictionary key the entry maps to. */key: string; /** Locale of the entry content. */
|
|
21
|
+
locale: Locale;
|
|
22
|
+
/**
|
|
23
|
+
* Transport-specific identifier of the entry: an absolute file path for the
|
|
24
|
+
* file adapter, a remote resource identifier for API-backed adapters.
|
|
25
|
+
*/
|
|
26
|
+
uri: string;
|
|
27
|
+
/**
|
|
28
|
+
* Absolute file path when the entry lives on the local filesystem.
|
|
29
|
+
* Leave undefined for remote entries (CMS, TMS…): the generated dictionary
|
|
30
|
+
* then carries no `filePath` and file-based hooks are skipped for it.
|
|
31
|
+
*/
|
|
32
|
+
filePath?: string;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Identifies where content must be written back by a {@link ContentAdapter}.
|
|
36
|
+
*/
|
|
37
|
+
type ContentTarget = {
|
|
38
|
+
key: string;
|
|
39
|
+
locale: Locale;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Transport layer of a sync plugin: where the entries live and how to
|
|
43
|
+
* enumerate, read and persist them (filesystem, TMS such as Crowdin, extra
|
|
44
|
+
* CMS…). Format concerns belong to {@link FormatCodec}, orchestration to
|
|
45
|
+
* `createSyncPlugin`.
|
|
46
|
+
*/
|
|
47
|
+
type ContentAdapter = {
|
|
48
|
+
/**
|
|
49
|
+
* Enumerate every entry available in the external system.
|
|
50
|
+
*/
|
|
51
|
+
list: (context: SyncPluginContext) => Promise<ContentEntry[]>;
|
|
52
|
+
/**
|
|
53
|
+
* Read and parse one entry.
|
|
54
|
+
* Return `undefined` when the entry is missing or unreadable — the plugin
|
|
55
|
+
* treats it as empty content instead of failing the build.
|
|
56
|
+
*/
|
|
57
|
+
read: (entry: ContentEntry, context: SyncPluginContext) => Promise<SyncContent | undefined>;
|
|
58
|
+
/**
|
|
59
|
+
* Serialize and persist the content of one key/locale back to the external
|
|
60
|
+
* system. Only called for plugins created with `direction: 'both'`.
|
|
61
|
+
*/
|
|
62
|
+
write: (target: ContentTarget, content: SyncContent, context: SyncPluginContext) => Promise<void>;
|
|
63
|
+
/**
|
|
64
|
+
* Resolve the canonical URI of a key/locale.
|
|
65
|
+
* Used by the plugin to verify ownership before reformatting a content
|
|
66
|
+
* declaration in the `formatOutput` hook. Optional: adapters without a
|
|
67
|
+
* local-file identity (remote systems) can omit it.
|
|
68
|
+
*/
|
|
69
|
+
resolveUri?: (target: ContentTarget, context: SyncPluginContext) => Promise<string>;
|
|
70
|
+
/**
|
|
71
|
+
* Template describing where entries live, with `{{key}}` / `{{locale}}`
|
|
72
|
+
* markers kept verbatim. Used as the `fill` field of generated dictionaries
|
|
73
|
+
* so Intlayer knows where translations flow back.
|
|
74
|
+
*/
|
|
75
|
+
getFillPattern?: (context: SyncPluginContext) => Promise<string>;
|
|
76
|
+
/**
|
|
77
|
+
* Human-readable description of the adapter source, used in log messages
|
|
78
|
+
* (e.g. the file path pattern for the file adapter).
|
|
79
|
+
*/
|
|
80
|
+
describeSource?: (context: SyncPluginContext) => Promise<string>;
|
|
81
|
+
/**
|
|
82
|
+
* Default value for the `splitKeys` behavior when the plugin options do not
|
|
83
|
+
* set it explicitly (e.g. the file adapter splits when the source pattern
|
|
84
|
+
* has no `{{key}}` segment).
|
|
85
|
+
*/
|
|
86
|
+
detectSplitKeys?: () => Promise<boolean>;
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* Format layer of a sync plugin: how a raw string payload maps to structured
|
|
90
|
+
* dictionary content and back (JSON, PO, XLIFF…).
|
|
91
|
+
*/
|
|
92
|
+
type FormatCodec = {
|
|
93
|
+
/**
|
|
94
|
+
* Parse a raw payload into dictionary content.
|
|
95
|
+
* May throw on malformed payloads — callers treat a throw as empty content.
|
|
96
|
+
*/
|
|
97
|
+
parse: (raw: string) => SyncContent;
|
|
98
|
+
/**
|
|
99
|
+
* Serialize dictionary content into the target format.
|
|
100
|
+
*/
|
|
101
|
+
serialize: (content: SyncContent, context: {
|
|
102
|
+
locale: Locale;
|
|
103
|
+
}) => string;
|
|
104
|
+
};
|
|
105
|
+
/**
|
|
106
|
+
* Direction of the synchronization:
|
|
107
|
+
* - `pull`: only ingest external content as dictionaries (read-only).
|
|
108
|
+
* - `both`: ingest and write the merged build output back to the source.
|
|
109
|
+
*/
|
|
110
|
+
type SyncDirection = 'pull' | 'both';
|
|
111
|
+
/**
|
|
112
|
+
* Options of `createSyncPlugin`.
|
|
113
|
+
*/
|
|
114
|
+
type CreateSyncPluginOptions = {
|
|
115
|
+
/** Plugin name reported to the Intlayer engine (e.g. `sync-json`). */name: string; /** Transport used to enumerate, read and write entries. */
|
|
116
|
+
adapter: ContentAdapter;
|
|
117
|
+
/**
|
|
118
|
+
* Synchronization direction. Defaults to `'both'`.
|
|
119
|
+
* With `'pull'` the plugin only implements `loadDictionaries`.
|
|
120
|
+
*/
|
|
121
|
+
direction?: SyncDirection;
|
|
122
|
+
/**
|
|
123
|
+
* Identifier of the plugin instance stored on each generated dictionary.
|
|
124
|
+
* Dictionaries are routed back to their owning plugin instance through this
|
|
125
|
+
* value during write-back, so it must be unique per instance.
|
|
126
|
+
*/
|
|
127
|
+
location: string;
|
|
128
|
+
/**
|
|
129
|
+
* Priority of the generated dictionaries when merging with other sources
|
|
130
|
+
* (`.content` files have priority 0). Defaults to 0.
|
|
131
|
+
*/
|
|
132
|
+
priority?: number; /** Content format of the dictionaries (e.g. `'icu'`, `'po'`). */
|
|
133
|
+
format?: DictionaryFormat;
|
|
134
|
+
/**
|
|
135
|
+
* Whether each top-level key of an entry becomes its own dictionary instead
|
|
136
|
+
* of a single dictionary holding the whole entry (the `next-intl` /
|
|
137
|
+
* `react-intl` namespace model). When omitted, falls back to
|
|
138
|
+
* {@link ContentAdapter.detectSplitKeys}, then to `false`.
|
|
139
|
+
*/
|
|
140
|
+
splitKeys?: boolean;
|
|
141
|
+
/**
|
|
142
|
+
* Fixed locale applied to every generated dictionary, overriding the locale
|
|
143
|
+
* discovered per entry.
|
|
144
|
+
*/
|
|
145
|
+
localeOverride?: Locale;
|
|
146
|
+
};
|
|
147
|
+
//#endregion
|
|
148
|
+
export { ContentAdapter, ContentEntry, ContentTarget, CreateSyncPluginOptions, FormatCodec, SyncContent, SyncDirection, SyncPluginContext };
|
|
149
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","names":[],"sources":["../../../src/syncPluginKit/types.ts"],"mappings":";;;;;;;AAOA;KAAY,WAAA,GAAc,MAAA;;;;KAKd,iBAAA;EACV,aAAA,EAAe,cAAA;AAAA;;;AAMjB;KAAY,YAAA;0CAEV,GAAA;EAEA,MAAA,EAAQ,MAAA;EAAA;;;;EAKR,GAAA;EAYU;;;;;EANV,QAAA;AAAA;;;AAiBF;KAXY,aAAA;EACV,GAAA;EACA,MAAA,EAAQ,MAAA;AAAA;;;;;;;KASE,cAAA;EAuBC;;;EAnBX,IAAA,GAAO,OAAA,EAAS,iBAAA,KAAsB,OAAA,CAAQ,YAAA;EA+BzC;;;;;EAxBL,IAAA,GACE,KAAA,EAAO,YAAA,EACP,OAAA,EAAS,iBAAA,KACN,OAAA,CAAQ,WAAA;EAyCkB;;;;EAnC/B,KAAA,GACE,MAAA,EAAQ,aAAA,EACR,OAAA,EAAS,WAAA,EACT,OAAA,EAAS,iBAAA,KACN,OAAA;EApBiC;;;;;;EA4BtC,UAAA,IACE,MAAA,EAAQ,aAAA,EACR,OAAA,EAAS,iBAAA,KACN,OAAA;EArBA;;;;;EA4BL,cAAA,IAAkB,OAAA,EAAS,iBAAA,KAAsB,OAAA;EApB/C;;;;EA0BF,cAAA,IAAkB,OAAA,EAAS,iBAAA,KAAsB,OAAA;EAfvC;;;;;EAsBV,eAAA,SAAwB,OAAA;AAAA;;;;;KAOd,WAAA;EAduC;;;;EAmBjD,KAAA,GAAQ,GAAA,aAAgB,WAAA;EALd;;;EAUV,SAAA,GAAY,OAAA,EAAS,WAAA,EAAa,OAAA;IAAW,MAAA,EAAQ,MAAA;EAAA;AAAA;;;;;;KAQ3C,aAAA;;;;KAKA,uBAAA;EAbmD,sEAe7D,IAAA,UAPU;EAUV,OAAA,EAAS,cAAA;;;;AALX;EAWE,SAAA,GAAY,aAAA;;;;;;EAOZ,QAAA;EAuBuB;;;;EAjBvB,QAAA,WAbY;EAgBZ,MAAA,GAAS,gBAAA;EAHT;;;;;;EAWA,SAAA;EAMuB;;;;EAAvB,cAAA,GAAiB,MAAA;AAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//#region src/utils/recastBabelParser.d.ts
|
|
2
|
+
/** A parser object accepted by `recast.parse`'s `parser` option. */
|
|
3
|
+
type RecastParser = {
|
|
4
|
+
parse: (source: string) => unknown;
|
|
5
|
+
};
|
|
6
|
+
/** Drop-in replacement for `recast/parsers/typescript` (TS without JSX). */
|
|
7
|
+
declare const typescriptParser: RecastParser;
|
|
8
|
+
/** Drop-in replacement for `recast/parsers/babel-ts` (TS *and* JSX). */
|
|
9
|
+
declare const babelTsParser: RecastParser;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { RecastParser, babelTsParser, typescriptParser };
|
|
12
|
+
//# sourceMappingURL=recastBabelParser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recastBabelParser.d.ts","names":[],"sources":["../../../src/utils/recastBabelParser.ts"],"mappings":";;KA2DY,YAAA;EACV,KAAA,GAAQ,MAAA;AAAA;;cAIG,gBAAA,EAAkB,YAAA;AAA/B;AAAA,cAMa,aAAA,EAAe,YAAA"}
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
//#region src/utils/runParallel/index.d.ts
|
|
2
2
|
type ParallelHandle = {
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Terminate the child and its whole process group.
|
|
5
|
+
* @param signal Signal to send (default `SIGTERM`). Pass `SIGKILL` to force-kill
|
|
6
|
+
* a child that ignores graceful termination.
|
|
7
|
+
*/
|
|
8
|
+
kill: (signal?: NodeJS.Signals) => void;
|
|
4
9
|
result: Promise<any>;
|
|
5
10
|
commandText: string;
|
|
6
11
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../../src/utils/runParallel/index.ts"],"mappings":";KAIY,cAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../../src/utils/runParallel/index.ts"],"mappings":";KAIY,cAAA;EAAA;;;;;EAMV,IAAA,GAAO,MAAA,GAAS,MAAA,CAAO,OAAA;EACvB,MAAA,EAAQ,OAAA;EACR,WAAA;AAAA;;;;;cAOW,WAAA,GAAe,IAAA,yBAA2B,cAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"watcher.d.ts","names":[],"sources":["../../src/watcher.ts"],"mappings":";;;;KAuDK,YAAA;EACH,aAAA,GAAgB,cAAA;EAChB,aAAA,GAAgB,uBAAA;EAChB,WAAA;EACA,UAAA;AAAA;AAAA,cAsBW,KAAA,GAAe,OAAA,GAAU,YAAA,KAAY,OAAA;qBAkDN,OAAA;AAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"watcher.d.ts","names":[],"sources":["../../src/watcher.ts"],"mappings":";;;;KAuDK,YAAA;EACH,aAAA,GAAgB,cAAA;EAChB,aAAA,GAAgB,uBAAA;EAChB,WAAA;EACA,UAAA;AAAA;AAAA,cAsBW,KAAA,GAAe,OAAA,GAAU,YAAA,KAAY,OAAA;qBAkDN,OAAA;AAAA;AAAA,cA8P/B,qBAAA,GAA+B,OAAA,GAAU,YAAA,KAAY,OAAA"}
|
|
@@ -1,11 +1,35 @@
|
|
|
1
1
|
//#region src/writeFileIfChanged.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Options for {@link writeFileIfChanged}.
|
|
4
|
+
*/
|
|
5
|
+
type WriteFileIfChangedOptions = {
|
|
6
|
+
/** Encoding used to turn `data` into bytes. Defaults to `'utf8'`. */encoding?: BufferEncoding; /** Directory to hold the temporary file used for the atomic swap. */
|
|
7
|
+
tempDir?: string;
|
|
8
|
+
/**
|
|
9
|
+
* Write atomically via a temp file + `rename` so readers never observe a
|
|
10
|
+
* half-written file. This creates a fresh inode on every write, which roughly
|
|
11
|
+
* doubles the cost of a changed write compared to overwriting in place. Set to
|
|
12
|
+
* `false` for callers whose consumers tolerate torn reads to write directly.
|
|
13
|
+
* Defaults to `true`.
|
|
14
|
+
*/
|
|
15
|
+
atomic?: boolean;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Write `data` to `path` only when it differs from the file already on disk,
|
|
19
|
+
* preserving the existing file's permission mode.
|
|
20
|
+
*
|
|
21
|
+
* The whole file is read back and byte-compared because the files written here
|
|
22
|
+
* (dictionaries, entry points, types) are small, so reading beats streaming a
|
|
23
|
+
* hash. When the content is unchanged the write is skipped entirely, which both
|
|
24
|
+
* avoids inode churn and prevents downstream watchers from rebuilding.
|
|
25
|
+
*
|
|
26
|
+
* @returns `true` when the file was written, `false` when it was already up to date.
|
|
27
|
+
*/
|
|
2
28
|
declare const writeFileIfChanged: (path: string, data: string, {
|
|
3
29
|
encoding,
|
|
4
|
-
tempDir
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
tempDir?: string;
|
|
8
|
-
}) => Promise<boolean>;
|
|
30
|
+
tempDir,
|
|
31
|
+
atomic
|
|
32
|
+
}?: WriteFileIfChangedOptions) => Promise<boolean>;
|
|
9
33
|
//#endregion
|
|
10
|
-
export { writeFileIfChanged };
|
|
34
|
+
export { WriteFileIfChangedOptions, writeFileIfChanged };
|
|
11
35
|
//# sourceMappingURL=writeFileIfChanged.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"writeFileIfChanged.d.ts","names":[],"sources":["../../src/writeFileIfChanged.ts"],"mappings":";
|
|
1
|
+
{"version":3,"file":"writeFileIfChanged.d.ts","names":[],"sources":["../../src/writeFileIfChanged.ts"],"mappings":";;AAoCA;;KAAY,yBAAA;EAEe,qEAAzB,QAAA,GAAW,cAAA,EAAA;EAEX,OAAA;EAQA;;;AAcF;;;;EAdE,MAAA;AAAA;;;;;;;;;;;;cAcW,kBAAA,GACX,IAAA,UACA,IAAA;EACA,QAAA;EAAA,OAAA;EAAA;AAAA,IAA+C,yBAAA,KAC9C,OAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intlayer/engine",
|
|
3
|
-
"version": "9.0.0-canary.
|
|
3
|
+
"version": "9.0.0-canary.14",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Scans and builds Intlayer declaration files into dictionaries based on Intlayer configuration.",
|
|
6
6
|
"keywords": [
|
|
@@ -50,11 +50,21 @@
|
|
|
50
50
|
"require": "./dist/cjs/cli.cjs",
|
|
51
51
|
"import": "./dist/esm/cli.mjs"
|
|
52
52
|
},
|
|
53
|
+
"./logConfigDetails": {
|
|
54
|
+
"types": "./dist/types/logConfigDetails.d.ts",
|
|
55
|
+
"require": "./dist/cjs/logConfigDetails.cjs",
|
|
56
|
+
"import": "./dist/esm/logConfigDetails.mjs"
|
|
57
|
+
},
|
|
53
58
|
"./utils": {
|
|
54
59
|
"types": "./dist/types/utils/index.d.ts",
|
|
55
60
|
"require": "./dist/cjs/utils/index.cjs",
|
|
56
61
|
"import": "./dist/esm/utils/index.mjs"
|
|
57
62
|
},
|
|
63
|
+
"./syncPluginKit": {
|
|
64
|
+
"types": "./dist/types/syncPluginKit/index.d.ts",
|
|
65
|
+
"require": "./dist/cjs/syncPluginKit/index.cjs",
|
|
66
|
+
"import": "./dist/esm/syncPluginKit/index.mjs"
|
|
67
|
+
},
|
|
58
68
|
"./listDictionaries": {
|
|
59
69
|
"types": "./dist/types/listDictionariesPath.d.ts",
|
|
60
70
|
"require": "./dist/cjs/listDictionariesPath.cjs",
|
|
@@ -86,9 +96,15 @@
|
|
|
86
96
|
"cli": [
|
|
87
97
|
"./dist/types/cli.d.ts"
|
|
88
98
|
],
|
|
99
|
+
"logConfigDetails": [
|
|
100
|
+
"./dist/types/logConfigDetails.d.ts"
|
|
101
|
+
],
|
|
89
102
|
"utils": [
|
|
90
103
|
"./dist/types/utils/index.d.ts"
|
|
91
104
|
],
|
|
105
|
+
"syncPluginKit": [
|
|
106
|
+
"./dist/types/syncPluginKit/index.d.ts"
|
|
107
|
+
],
|
|
92
108
|
"listDictionaries": [
|
|
93
109
|
"./dist/types/listDictionariesPath.d.ts"
|
|
94
110
|
],
|
|
@@ -125,19 +141,20 @@
|
|
|
125
141
|
"typecheck": "tsc --noEmit --project tsconfig.types.json"
|
|
126
142
|
},
|
|
127
143
|
"dependencies": {
|
|
128
|
-
"@
|
|
129
|
-
"@intlayer/
|
|
130
|
-
"@intlayer/
|
|
131
|
-
"@intlayer/
|
|
132
|
-
"@intlayer/
|
|
133
|
-
"@intlayer/
|
|
134
|
-
"@intlayer/
|
|
144
|
+
"@babel/parser": "7.29.7",
|
|
145
|
+
"@intlayer/api": "9.0.0-canary.14",
|
|
146
|
+
"@intlayer/config": "9.0.0-canary.14",
|
|
147
|
+
"@intlayer/core": "9.0.0-canary.14",
|
|
148
|
+
"@intlayer/dictionaries-entry": "9.0.0-canary.14",
|
|
149
|
+
"@intlayer/remote-dictionaries-entry": "9.0.0-canary.14",
|
|
150
|
+
"@intlayer/types": "9.0.0-canary.14",
|
|
151
|
+
"@intlayer/unmerged-dictionaries-entry": "9.0.0-canary.14",
|
|
135
152
|
"@parcel/watcher": "2.5.6",
|
|
136
153
|
"defu": "6.1.7",
|
|
137
154
|
"fast-glob": "3.3.3",
|
|
138
|
-
"recast": "0.23.
|
|
155
|
+
"recast": "0.23.12",
|
|
139
156
|
"simple-git": "3.36.0",
|
|
140
|
-
"zod-to-ts": "2.
|
|
157
|
+
"zod-to-ts": "2.1.0"
|
|
141
158
|
},
|
|
142
159
|
"devDependencies": {
|
|
143
160
|
"@types/node": "25.9.4",
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
//#region \0rolldown/runtime.js
|
|
2
|
-
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, { get: (a, b) => (typeof require !== "undefined" ? require : a)[b] }) : x)(function(x) {
|
|
3
|
-
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
4
|
-
throw Error("Calling `require` for \"" + x + "\" in an environment that doesn't expose the `require` function. See https://rolldown.rs/in-depth/bundling-cjs#require-external-modules for more details.");
|
|
5
|
-
});
|
|
6
|
-
|
|
7
|
-
//#endregion
|
|
8
|
-
export { __require };
|