@intlayer/babel 9.4.3 → 9.5.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 +0 -2
- package/dist/cjs/analyzeContentUsage.cjs +301 -0
- package/dist/cjs/analyzeContentUsage.cjs.map +1 -0
- package/dist/cjs/babel-plugin-intlayer-field-rename.cjs +5 -4
- package/dist/cjs/babel-plugin-intlayer-field-rename.cjs.map +1 -1
- package/dist/cjs/babel-plugin-intlayer-optimize.cjs +173 -282
- package/dist/cjs/babel-plugin-intlayer-optimize.cjs.map +1 -1
- package/dist/cjs/babel-plugin-intlayer-purge.cjs +4 -3
- package/dist/cjs/babel-plugin-intlayer-purge.cjs.map +1 -1
- package/dist/cjs/babel-plugin-intlayer-usage-analyzer.cjs +49 -699
- package/dist/cjs/babel-plugin-intlayer-usage-analyzer.cjs.map +1 -1
- package/dist/cjs/compat/namespaceResolution.cjs +124 -0
- package/dist/cjs/compat/namespaceResolution.cjs.map +1 -0
- package/dist/cjs/compat/optimizePass.cjs +144 -0
- package/dist/cjs/compat/optimizePass.cjs.map +1 -0
- package/dist/cjs/compat/usageAnalysis.cjs +195 -0
- package/dist/cjs/compat/usageAnalysis.cjs.map +1 -0
- package/dist/cjs/dictionaryImports.cjs +40 -0
- package/dist/cjs/dictionaryImports.cjs.map +1 -0
- package/dist/cjs/extractContent/utils/extractDictionaryInfo.cjs +1 -1
- package/dist/cjs/getExtractPluginOptions.cjs +1 -1
- package/dist/cjs/getOptimizePluginOptions.cjs +1 -1
- package/dist/cjs/getPurgePluginOptions.cjs +1 -1
- package/dist/cjs/index.cjs +9 -5
- package/dist/cjs/nativeCallers.cjs +41 -0
- package/dist/cjs/nativeCallers.cjs.map +1 -0
- package/dist/cjs/pruneContext.cjs +79 -0
- package/dist/cjs/pruneContext.cjs.map +1 -0
- package/dist/cjs/staticAstReaders.cjs +140 -0
- package/dist/cjs/staticAstReaders.cjs.map +1 -0
- package/dist/cjs/transformers.cjs +2 -1
- package/dist/cjs/transformers.cjs.map +1 -1
- package/dist/esm/analyzeContentUsage.mjs +300 -0
- package/dist/esm/analyzeContentUsage.mjs.map +1 -0
- package/dist/esm/babel-plugin-intlayer-field-rename.mjs +3 -2
- package/dist/esm/babel-plugin-intlayer-field-rename.mjs.map +1 -1
- package/dist/esm/babel-plugin-intlayer-optimize.mjs +173 -282
- package/dist/esm/babel-plugin-intlayer-optimize.mjs.map +1 -1
- package/dist/esm/babel-plugin-intlayer-purge.mjs +3 -2
- package/dist/esm/babel-plugin-intlayer-purge.mjs.map +1 -1
- package/dist/esm/babel-plugin-intlayer-usage-analyzer.mjs +43 -694
- package/dist/esm/babel-plugin-intlayer-usage-analyzer.mjs.map +1 -1
- package/dist/esm/compat/namespaceResolution.mjs +120 -0
- package/dist/esm/compat/namespaceResolution.mjs.map +1 -0
- package/dist/esm/compat/optimizePass.mjs +143 -0
- package/dist/esm/compat/optimizePass.mjs.map +1 -0
- package/dist/esm/compat/usageAnalysis.mjs +193 -0
- package/dist/esm/compat/usageAnalysis.mjs.map +1 -0
- package/dist/esm/dictionaryImports.mjs +38 -0
- package/dist/esm/dictionaryImports.mjs.map +1 -0
- package/dist/esm/extractContent/utils/extractDictionaryInfo.mjs +1 -1
- package/dist/esm/getExtractPluginOptions.mjs +1 -1
- package/dist/esm/getOptimizePluginOptions.mjs +1 -1
- package/dist/esm/getPurgePluginOptions.mjs +1 -1
- package/dist/esm/index.mjs +5 -2
- package/dist/esm/nativeCallers.mjs +38 -0
- package/dist/esm/nativeCallers.mjs.map +1 -0
- package/dist/esm/pruneContext.mjs +76 -0
- package/dist/esm/pruneContext.mjs.map +1 -0
- package/dist/esm/staticAstReaders.mjs +129 -0
- package/dist/esm/staticAstReaders.mjs.map +1 -0
- package/dist/esm/transformers.mjs +2 -1
- package/dist/esm/transformers.mjs.map +1 -1
- package/dist/types/analyzeContentUsage.d.ts +18 -0
- package/dist/types/analyzeContentUsage.d.ts.map +1 -0
- package/dist/types/babel-plugin-intlayer-extract.d.ts +3 -4
- package/dist/types/babel-plugin-intlayer-extract.d.ts.map +1 -1
- package/dist/types/babel-plugin-intlayer-field-rename.d.ts +10 -10
- package/dist/types/babel-plugin-intlayer-field-rename.d.ts.map +1 -1
- package/dist/types/babel-plugin-intlayer-minify.d.ts +2 -3
- package/dist/types/babel-plugin-intlayer-minify.d.ts.map +1 -1
- package/dist/types/babel-plugin-intlayer-optimize.d.ts +11 -18
- package/dist/types/babel-plugin-intlayer-optimize.d.ts.map +1 -1
- package/dist/types/babel-plugin-intlayer-purge.d.ts +7 -7
- package/dist/types/babel-plugin-intlayer-purge.d.ts.map +1 -1
- package/dist/types/babel-plugin-intlayer-usage-analyzer.d.ts +22 -189
- package/dist/types/babel-plugin-intlayer-usage-analyzer.d.ts.map +1 -1
- package/dist/types/babelParser.d.ts +3 -4
- package/dist/types/babelParser.d.ts.map +1 -1
- package/dist/types/compat/namespaceResolution.d.ts +66 -0
- package/dist/types/compat/namespaceResolution.d.ts.map +1 -0
- package/dist/types/compat/optimizePass.d.ts +58 -0
- package/dist/types/compat/optimizePass.d.ts.map +1 -0
- package/dist/types/compat/usageAnalysis.d.ts +75 -0
- package/dist/types/compat/usageAnalysis.d.ts.map +1 -0
- package/dist/types/dictionaryImports.d.ts +46 -0
- package/dist/types/dictionaryImports.d.ts.map +1 -0
- package/dist/types/extractContent/babelProcessor.d.ts +4 -5
- package/dist/types/extractContent/babelProcessor.d.ts.map +1 -1
- package/dist/types/extractContent/contentWriter.d.ts +3 -4
- package/dist/types/extractContent/contentWriter.d.ts.map +1 -1
- package/dist/types/extractContent/extractContent.d.ts +3 -4
- package/dist/types/extractContent/extractContent.d.ts.map +1 -1
- package/dist/types/extractContent/processTsxFile.d.ts +2 -3
- package/dist/types/extractContent/processTsxFile.d.ts.map +1 -1
- package/dist/types/extractContent/utils/constants.d.ts +3 -4
- package/dist/types/extractContent/utils/constants.d.ts.map +1 -1
- package/dist/types/extractContent/utils/detectPackageName.d.ts +1 -2
- package/dist/types/extractContent/utils/detectPackageName.d.ts.map +1 -1
- package/dist/types/extractContent/utils/extractDictionaryInfo.d.ts +5 -6
- package/dist/types/extractContent/utils/extractDictionaryInfo.d.ts.map +1 -1
- package/dist/types/extractContent/utils/extractDictionaryKey.d.ts +2 -3
- package/dist/types/extractContent/utils/extractDictionaryKey.d.ts.map +1 -1
- package/dist/types/extractContent/utils/generateKey.d.ts +1 -2
- package/dist/types/extractContent/utils/generateKey.d.ts.map +1 -1
- package/dist/types/extractContent/utils/getComponentName.d.ts +1 -2
- package/dist/types/extractContent/utils/getComponentName.d.ts.map +1 -1
- package/dist/types/extractContent/utils/getExistingIntlayerInfo.d.ts +2 -3
- package/dist/types/extractContent/utils/getExistingIntlayerInfo.d.ts.map +1 -1
- package/dist/types/extractContent/utils/getOrGenerateKey.d.ts +1 -2
- package/dist/types/extractContent/utils/getOrGenerateKey.d.ts.map +1 -1
- package/dist/types/extractContent/utils/resolveDictionaryKey.d.ts +1 -2
- package/dist/types/extractContent/utils/resolveDictionaryKey.d.ts.map +1 -1
- package/dist/types/extractScriptBlocks.d.ts +3 -4
- package/dist/types/extractScriptBlocks.d.ts.map +1 -1
- package/dist/types/getExtractPluginOptions.d.ts +2 -3
- package/dist/types/getExtractPluginOptions.d.ts.map +1 -1
- package/dist/types/getOptimizePluginOptions.d.ts +1 -2
- package/dist/types/getOptimizePluginOptions.d.ts.map +1 -1
- package/dist/types/getPurgePluginOptions.d.ts +2 -3
- package/dist/types/getPurgePluginOptions.d.ts.map +1 -1
- package/dist/types/index.d.ts +5 -2
- package/dist/types/nativeCallers.d.ts +33 -0
- package/dist/types/nativeCallers.d.ts.map +1 -0
- package/dist/types/normalizedFilesList.d.ts +1 -2
- package/dist/types/normalizedFilesList.d.ts.map +1 -1
- package/dist/types/pruneContext.d.ts +152 -0
- package/dist/types/pruneContext.d.ts.map +1 -0
- package/dist/types/staticAstReaders.d.ts +84 -0
- package/dist/types/staticAstReaders.d.ts.map +1 -0
- package/dist/types/transformers.d.ts +11 -11
- package/dist/types/transformers.d.ts.map +1 -1
- package/package.json +12 -12
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
//#region src/babelParser.d.ts
|
|
2
2
|
/** A parser object accepted by `recast.parse`'s `parser` option. */
|
|
3
|
-
type RecastParser = {
|
|
3
|
+
export type RecastParser = {
|
|
4
4
|
parse: (source: string) => unknown;
|
|
5
5
|
};
|
|
6
6
|
/** Drop-in replacement for `recast/parsers/typescript` (TS without JSX). */
|
|
7
|
-
declare const typescriptParser: RecastParser;
|
|
7
|
+
export declare const typescriptParser: RecastParser;
|
|
8
8
|
/** Drop-in replacement for `recast/parsers/babel-ts` (TS *and* JSX). */
|
|
9
|
-
declare const babelTsParser: RecastParser;
|
|
9
|
+
export declare const babelTsParser: RecastParser;
|
|
10
10
|
//#endregion
|
|
11
|
-
export { RecastParser, babelTsParser, typescriptParser };
|
|
12
11
|
//# sourceMappingURL=babelParser.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"babelParser.d.ts","names":[],"sources":["../../src/babelParser.ts"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"babelParser.d.ts","names":[],"sources":["../../src/babelParser.ts"],"mappings":";;YAuDY;EACV,QAAQ;;;qBAIG,kBAAkB;;qBAMlB,eAAe"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { StaticOrAbsent } from "../staticAstReaders.js";
|
|
2
|
+
import * as BabelTypes from "@babel/types";
|
|
3
|
+
import { CallerDescriptor, CallerValueSource } from "@intlayer/config/callers";
|
|
4
|
+
//#region src/compat/namespaceResolution.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Resolution of a compat caller's namespace from its
|
|
7
|
+
* {@link CallerValueSource} list.
|
|
8
|
+
*
|
|
9
|
+
* Two flavours coexist on purpose, because the two passes ask different
|
|
10
|
+
* questions of the same descriptor:
|
|
11
|
+
*
|
|
12
|
+
* - {@link resolveNamespaceForAnalysis} answers *which dictionary does this
|
|
13
|
+
* call read* — used by the usage analyser, which only needs to attribute a
|
|
14
|
+
* call to a dictionary and may fall back to the caller's default namespace.
|
|
15
|
+
* - {@link resolveNamespaceForRewrite} answers *can this call be rewritten,
|
|
16
|
+
* and where do I edit it* — used by the optimize pass, which needs an exact
|
|
17
|
+
* static namespace plus a handle on the node it must replace. It has no
|
|
18
|
+
* default-namespace fallback: rewriting a call whose namespace is only
|
|
19
|
+
* implied would bind the wrong dictionary.
|
|
20
|
+
*/
|
|
21
|
+
/** Namespace used by compat callers when no namespace argument is given. */
|
|
22
|
+
export declare const DEFAULT_COMPAT_NAMESPACE = "translation";
|
|
23
|
+
/**
|
|
24
|
+
* Resolves the namespace from a list of `CallerValueSource`s, tried in
|
|
25
|
+
* declaration order. The first source yielding a static string wins.
|
|
26
|
+
* Returns {@link ABSENT_VALUE} when every source reports an absent value, and
|
|
27
|
+
* `undefined` when the namespace is present somewhere but dynamic.
|
|
28
|
+
*/
|
|
29
|
+
export declare const resolveNamespaceForAnalysis: (babelTypes: typeof BabelTypes, callArguments: BabelTypes.CallExpression['arguments'], sources: CallerValueSource[]) => StaticOrAbsent<string>;
|
|
30
|
+
/**
|
|
31
|
+
* Resolves an optional `keyPrefix` for a compat caller. Returns the static
|
|
32
|
+
* prefix string, `null` when no prefix is configured/present, or `undefined`
|
|
33
|
+
* when a prefix is present but dynamic.
|
|
34
|
+
*/
|
|
35
|
+
export declare const resolveKeyPrefixForAnalysis: (babelTypes: typeof BabelTypes, callArguments: BabelTypes.CallExpression['arguments'], sources: CallerValueSource[] | undefined) => string | null | undefined;
|
|
36
|
+
/**
|
|
37
|
+
* Result of statically resolving the namespace of a compat caller call-site
|
|
38
|
+
* for rewriting, carrying the handles the optimize pass mutates.
|
|
39
|
+
*/
|
|
40
|
+
export type RewritableNamespaceMatch = {
|
|
41
|
+
/** The full namespace string, e.g. `'about.counter'`. */
|
|
42
|
+
fullNamespace: string;
|
|
43
|
+
/** Index of the positional namespace argument, when read from an argument. */
|
|
44
|
+
argumentIndex?: number;
|
|
45
|
+
/**
|
|
46
|
+
* The options-object property holding the namespace, when read from an
|
|
47
|
+
* option. The rewrite mutates it in place (key-prefix remainder) or removes
|
|
48
|
+
* it from `optionsObject`.
|
|
49
|
+
*/
|
|
50
|
+
optionProperty?: BabelTypes.ObjectProperty;
|
|
51
|
+
/** The options object owning `optionProperty`. */
|
|
52
|
+
optionsObject?: BabelTypes.ObjectExpression;
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Statically resolves the namespace of a compat caller call-site for the
|
|
56
|
+
* optimize pass. Only the `argument` / `option` / `fixed` sources qualify: the
|
|
57
|
+
* per-message-id `path-first-segment` form cannot bind one dictionary to the
|
|
58
|
+
* call site and is skipped.
|
|
59
|
+
*
|
|
60
|
+
* Returns `undefined` when the namespace is absent or dynamic, in which case
|
|
61
|
+
* the call is left untouched and resolves through the runtime dictionary
|
|
62
|
+
* registry.
|
|
63
|
+
*/
|
|
64
|
+
export declare const resolveNamespaceForRewrite: (babelTypes: typeof BabelTypes, callArguments: BabelTypes.CallExpression['arguments'], descriptor: CallerDescriptor) => RewritableNamespaceMatch | undefined;
|
|
65
|
+
//#endregion
|
|
66
|
+
//# sourceMappingURL=namespaceResolution.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"namespaceResolution.d.ts","names":[],"sources":["../../../src/compat/namespaceResolution.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;qBAiCa;;;;;;;qBAoEA,8BAA2B,mBACnB,YAAU,eACd,WAAW,6BAA2B,SAC5C,wBACR;;;;;;qBAuBU,8BAA2B,mBACnB,YAAU,eACd,WAAW,6BAA2B,SAC5C;;;;;YAiBC;;EAEV;;EAEA;;;;;;EAMA,iBAAiB,WAAW;;EAE5B,gBAAgB,WAAW;;;;;;;;;;;;qBAahB,6BAA0B,mBAClB,YAAU,eACd,WAAW,6BAA2B,YACzC,qBACX"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { DictionaryImportRegistry, ImportMode } from "../dictionaryImports.js";
|
|
2
|
+
import * as BabelTypes from "@babel/types";
|
|
3
|
+
import { CallerDescriptor } from "@intlayer/config/callers";
|
|
4
|
+
//#region src/compat/optimizePass.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Compat half of the optimize pass.
|
|
7
|
+
*
|
|
8
|
+
* Every adapter-specific behaviour of the build-time rewrite lives here:
|
|
9
|
+
* matching a compat caller's import, resolving its namespace, and re-pointing
|
|
10
|
+
* the import specifier at the dictionary-accepting helper.
|
|
11
|
+
*
|
|
12
|
+
* The pass works on plain AST nodes rather than `NodePath`s: the optimize
|
|
13
|
+
* plugin collects the call sites in its single traversal and hands them over,
|
|
14
|
+
* so nothing here walks the tree.
|
|
15
|
+
*
|
|
16
|
+
* It is created only when compat descriptors were injected by a compat
|
|
17
|
+
* package's bundler plugin, so a plain intlayer build never allocates it —
|
|
18
|
+
* {@link createCompatOptimizePass} returns `null` for an empty registry.
|
|
19
|
+
*/
|
|
20
|
+
export type CompatOptimizePass = {
|
|
21
|
+
/**
|
|
22
|
+
* Whether `importSource` exports at least one rewritable compat caller, so
|
|
23
|
+
* the optimize plugin knows the import is worth inspecting even though it is
|
|
24
|
+
* not a native intlayer package.
|
|
25
|
+
*/
|
|
26
|
+
ownsImportSource: (importSource: string) => boolean;
|
|
27
|
+
/** Records the local alias one import specifier introduces. */
|
|
28
|
+
noteImport: (importSource: string, importedName: string, localName: string) => void;
|
|
29
|
+
/** Whether `localName` was bound to a compat caller by an import. */
|
|
30
|
+
ownsLocalName: (localName: string) => boolean;
|
|
31
|
+
/** Whether the file imported any compat caller at all. */
|
|
32
|
+
hasCallers: () => boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Resolves the namespace of every collected call, dropping the callers that
|
|
35
|
+
* cannot be rewritten and deciding the file-level helper family. Must run
|
|
36
|
+
* after every import was noted and before any rewrite.
|
|
37
|
+
*/
|
|
38
|
+
analyzeCalls: (callNodes: readonly BabelTypes.CallExpression[]) => void;
|
|
39
|
+
/** Rewrites one compat call site, if its caller survived {@link analyzeCalls}. */
|
|
40
|
+
rewriteCall: (callNode: BabelTypes.CallExpression) => void;
|
|
41
|
+
/** Re-points the compat specifiers of one import declaration. */
|
|
42
|
+
rewriteImportSpecifiers: (importNode: BabelTypes.ImportDeclaration) => void;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Builds the compat optimize pass for one source file, or `null` when no
|
|
46
|
+
* compat caller was injected.
|
|
47
|
+
*
|
|
48
|
+
* @param babelTypes - Babel's type helpers.
|
|
49
|
+
* @param compatCallers - Descriptors injected by the compat packages' plugins.
|
|
50
|
+
* @param imports - Shared dictionary-import registry for the file.
|
|
51
|
+
* @param buildModes - The file's global import mode and per-dictionary overrides.
|
|
52
|
+
*/
|
|
53
|
+
export declare const createCompatOptimizePass: (babelTypes: typeof BabelTypes, compatCallers: readonly CallerDescriptor[], imports: DictionaryImportRegistry, buildModes: {
|
|
54
|
+
importMode: ImportMode | undefined;
|
|
55
|
+
dictionaryModeMap?: Record<string, ImportMode | undefined>;
|
|
56
|
+
}) => CompatOptimizePass | null;
|
|
57
|
+
//#endregion
|
|
58
|
+
//# sourceMappingURL=optimizePass.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"optimizePass.d.ts","names":[],"sources":["../../../src/compat/optimizePass.ts"],"mappings":";;;;;;;;;;;;;;;;;;;YA2BY;;;;;;EAMV,mBAAmB;;EAEnB,aACE,sBACA,sBACA;;EAGF,gBAAgB;;EAEhB;;;;;;EAMA,eAAe,oBAAoB,WAAW;;EAE9C,cAAc,UAAU,WAAW;;EAEnC,0BAA0B,YAAY,WAAW;;;;;;;;;;;qBA4EtC,2BAAwB,mBAChB,YAAU,wBACL,oBAAkB,SACjC,0BAAwB;EAE/B,YAAY;EACZ,oBAAoB,eAAe;MAEpC"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { PruneContext } from "../pruneContext.js";
|
|
2
|
+
import { NodePath } from "@babel/core";
|
|
3
|
+
import * as BabelTypes from "@babel/types";
|
|
4
|
+
import { CallerDescriptor } from "@intlayer/config/callers";
|
|
5
|
+
//#region src/compat/usageAnalysis.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* Analyses how the translation function produced by a compat namespace caller
|
|
8
|
+
* (`useTranslation`, `useTranslations`, `getTranslations`, `getFixedT`,
|
|
9
|
+
* `useI18n`) is consumed, then records the accessed top-level dictionary fields
|
|
10
|
+
* into `pruneContext`.
|
|
11
|
+
*
|
|
12
|
+
* Dictionaries consumed this way are always added to
|
|
13
|
+
* `dictionariesSkippingFieldRename`: the field accesses are string-literal
|
|
14
|
+
* dot-paths inside `t()` calls, which the field-rename plugin cannot rewrite,
|
|
15
|
+
* so renaming the compiled JSON keys would break runtime lookups. Pruning
|
|
16
|
+
* (top-level field removal) remains safe because it preserves field names.
|
|
17
|
+
*/
|
|
18
|
+
export declare const analyzeNamespaceCallerUsage: (babelTypes: typeof BabelTypes, pruneContext: PruneContext, callArguments: BabelTypes.CallExpression['arguments'], callerConfig: CallerDescriptor, isSfcFile: boolean,
|
|
19
|
+
/** Absolute path of the analysed file (for untracked-binding reporting). */
|
|
20
|
+
currentSourceFilePath: string,
|
|
21
|
+
/**
|
|
22
|
+
* The call-expression path, when the caller was matched as a call. Omitted
|
|
23
|
+
* for JSX-element matches (`<FormattedMessage id>`), where only the static
|
|
24
|
+
* `'self'` / `'all'` analysis paths apply — the binding-based
|
|
25
|
+
* `'destructured-t'` / `'return-value'` paths require a call site.
|
|
26
|
+
*/
|
|
27
|
+
callExpressionPath?: NodePath<BabelTypes.CallExpression>,
|
|
28
|
+
/**
|
|
29
|
+
* Pre-resolved namespace bypassing `namespaceSources`, e.g. the `ns`
|
|
30
|
+
* attribute of react-i18next's `<Trans ns="home" i18nKey="title" />`.
|
|
31
|
+
*/
|
|
32
|
+
namespaceOverride?: string) => void;
|
|
33
|
+
/**
|
|
34
|
+
* Compat half of the usage analyser, kept behind one object so the native
|
|
35
|
+
* plugin body contains no adapter-specific branching.
|
|
36
|
+
*
|
|
37
|
+
* The analyser is created only when compat callers were injected, so a plain
|
|
38
|
+
* intlayer build never allocates it and never pays for its lookups —
|
|
39
|
+
* {@link createCompatUsageAnalyzer} returns `null` for an empty registry.
|
|
40
|
+
*/
|
|
41
|
+
export type CompatUsageAnalyzer = {
|
|
42
|
+
/**
|
|
43
|
+
* Records the local aliases one import declaration introduces. Called for
|
|
44
|
+
* every import of the file, before any call site is inspected.
|
|
45
|
+
*/
|
|
46
|
+
noteImport: (importSource: string, importedName: string, localName: string) => void;
|
|
47
|
+
/**
|
|
48
|
+
* Whether any compat caller can match in this file — either an imported
|
|
49
|
+
* alias was recorded, or a method-matched caller is active. Checked after
|
|
50
|
+
* every import was noted, so the plugin can skip the call traversal.
|
|
51
|
+
*/
|
|
52
|
+
hasMatchableCallers: () => boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Analyses one call site. Returns `true` when the call belonged to a compat
|
|
55
|
+
* caller and was handled, `false` when the native path should look at it.
|
|
56
|
+
*/
|
|
57
|
+
analyzeCall: (callExpressionPath: NodePath<BabelTypes.CallExpression>, localCallerName: string, isMethodCall: boolean) => boolean;
|
|
58
|
+
/** Analyses one JSX element, e.g. `<Trans i18nKey="…" />`. */
|
|
59
|
+
analyzeJsxElement: (jsxOpeningElementPath: NodePath<BabelTypes.JSXOpeningElement>) => void;
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Builds the compat analyser for one source file, or `null` when no compat
|
|
63
|
+
* caller was injected — the base intlayer pipeline then runs untouched.
|
|
64
|
+
*
|
|
65
|
+
* @param babelTypes - Babel's type helpers.
|
|
66
|
+
* @param pruneContext - Shared analysis state to write into.
|
|
67
|
+
* @param compatCallers - Descriptors injected by the compat packages' plugins.
|
|
68
|
+
* @param fileContext - Path of the analysed file and whether it is an SFC.
|
|
69
|
+
*/
|
|
70
|
+
export declare const createCompatUsageAnalyzer: (babelTypes: typeof BabelTypes, pruneContext: PruneContext, compatCallers: readonly CallerDescriptor[], fileContext: {
|
|
71
|
+
sourceFilePath: string;
|
|
72
|
+
isSfcFile: boolean;
|
|
73
|
+
}) => CompatUsageAnalyzer | null;
|
|
74
|
+
//#endregion
|
|
75
|
+
//# sourceMappingURL=usageAnalysis.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usageAnalysis.d.ts","names":[],"sources":["../../../src/compat/usageAnalysis.ts"],"mappings":";;;;;;;;;;;;;;;;;qBAgCa,8BAA2B,mBACnB,YAAU,cACf,cAAY,eACX,WAAW,6BAA2B,cACvC,kBAAgB,oBAGP;;AAAA,+BAOF;;;;;;;AAAA,qBAAA,SAAS,WAAW,iBAKrB;;;;;AAAA;;;;;;;;;YAgRV;;;;;EAKV,aACE,sBACA,sBACA;;;;;;EAOF;;;;;EAKA,cACE,oBAAoB,SAAS,WAAW,iBACxC,yBACA;;EAGF,oBACE,uBAAuB,SAAS,WAAW;;;;;;;;;;;qBAalC,4BAAyB,mBACjB,YAAU,cACf,cAAY,wBACF,oBAAkB;EAC3B;EAAwB;MACtC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import * as BabelTypes from "@babel/types";
|
|
2
|
+
//#region src/dictionaryImports.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* How a dictionary reaches a call site.
|
|
5
|
+
*
|
|
6
|
+
* - `static` — the compiled JSON is imported directly.
|
|
7
|
+
* - `dynamic` — a generated per-locale loader is imported and resolved at
|
|
8
|
+
* runtime (Suspense).
|
|
9
|
+
* - `fetch` — same as `dynamic`, but the loader fetches remote content.
|
|
10
|
+
*/
|
|
11
|
+
export type ImportMode = 'static' | 'dynamic' | 'fetch';
|
|
12
|
+
/**
|
|
13
|
+
* Builds the generated identifier for a dictionary key.
|
|
14
|
+
*
|
|
15
|
+
* Replicates the xxHash64 → Base-62 algorithm used by the SWC version and
|
|
16
|
+
* prefixes an underscore so the generated identifiers never collide with
|
|
17
|
+
* user-defined ones.
|
|
18
|
+
*/
|
|
19
|
+
export declare const makeDictionaryIdent: (babelTypes: typeof BabelTypes, key: string, mode: ImportMode) => BabelTypes.Identifier;
|
|
20
|
+
/**
|
|
21
|
+
* The dictionary imports one file needs, accumulated while its call sites are
|
|
22
|
+
* rewritten and injected in one pass at the end.
|
|
23
|
+
*
|
|
24
|
+
* Both the native and the compat rewrites write here, so a dictionary read
|
|
25
|
+
* through `useIntlayer('about')` and through `useTranslation('about')` in the
|
|
26
|
+
* same file shares a single import.
|
|
27
|
+
*
|
|
28
|
+
* `dynamic` and `fetch` share one map because they occupy the same import
|
|
29
|
+
* slot, distinguished only by their identifier suffix — mirroring
|
|
30
|
+
* `InjectedImports` in the SWC plugin.
|
|
31
|
+
*/
|
|
32
|
+
export type DictionaryImportRegistry = {
|
|
33
|
+
/** Dictionary key → identifier of the static JSON (or nested companion) import. */
|
|
34
|
+
readonly staticImports: Map<string, BabelTypes.Identifier>;
|
|
35
|
+
/** Dictionary key → identifier of the dynamic / fetch loader import. */
|
|
36
|
+
readonly dynamicImports: Map<string, BabelTypes.Identifier>;
|
|
37
|
+
/**
|
|
38
|
+
* Returns the identifier for `key` in `mode`, creating and registering it on
|
|
39
|
+
* first use.
|
|
40
|
+
*/
|
|
41
|
+
identFor: (key: string, mode: ImportMode) => BabelTypes.Identifier;
|
|
42
|
+
};
|
|
43
|
+
/** Creates an empty registry for one source file. */
|
|
44
|
+
export declare const createDictionaryImportRegistry: (babelTypes: typeof BabelTypes) => DictionaryImportRegistry;
|
|
45
|
+
//#endregion
|
|
46
|
+
//# sourceMappingURL=dictionaryImports.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dictionaryImports.d.ts","names":[],"sources":["../../src/dictionaryImports.ts"],"mappings":";;;;;;;;;;YAWY;;;;;;;;qBAgBC,sBAAmB,mBACX,YAAU,aAClB,MACL,eACL,WAAW;;;;;;;;;;;;;YAeF;;WAED,eAAe,YAAY,WAAW;;WAEtC,gBAAgB,YAAY,WAAW;;;;;EAKhD,WAAW,aAAa,MAAM,eAAe,WAAW;;;qBAI7C,iCAA8B,mBACtB,eAClB"}
|
|
@@ -4,7 +4,7 @@ import * as t from "@babel/types";
|
|
|
4
4
|
import { IntlayerConfig } from "@intlayer/types/config";
|
|
5
5
|
import { NodePath } from "@babel/traverse";
|
|
6
6
|
//#region src/extractContent/babelProcessor.d.ts
|
|
7
|
-
type BabelReplacement = {
|
|
7
|
+
export type BabelReplacement = {
|
|
8
8
|
path: NodePath;
|
|
9
9
|
key: string;
|
|
10
10
|
type: 'jsx-text' | 'jsx-attribute' | 'string-literal' | 'jsx-insertion' | 'jsx-text-combined' | 'template-literal';
|
|
@@ -16,12 +16,12 @@ type BabelReplacement = {
|
|
|
16
16
|
* Handles JSX insertions (elements with multiple children, including expressions).
|
|
17
17
|
* Replaces complex JSX structures with variable-based translations.
|
|
18
18
|
*/
|
|
19
|
-
declare const handleJsxInsertionBabel: (path: NodePath<t.JSXElement | t.JSXFragment>, fileCode: string, existingKeys: Set<string>, getComponentKeyForPath: (path: NodePath) => string, extractedContent: Record<string, Record<string, string>>, replacements: BabelReplacement[], handledNodes: Set<t.Node>) => boolean;
|
|
19
|
+
export declare const handleJsxInsertionBabel: (path: NodePath<t.JSXElement | t.JSXFragment>, fileCode: string, existingKeys: Set<string>, getComponentKeyForPath: (path: NodePath) => string, extractedContent: Record<string, Record<string, string>>, replacements: BabelReplacement[], handledNodes: Set<t.Node>) => boolean;
|
|
20
20
|
/**
|
|
21
21
|
* Traverses the AST to identify components and extract content.
|
|
22
22
|
* Returns extraction results and metadata about which components need Intlayer hooks.
|
|
23
23
|
*/
|
|
24
|
-
declare const extractBabelContentForComponents: (ast: t.File, fileCode: string, existingKeys: Set<string>, defaultKey: string, configuration: IntlayerConfig, filePath: string, unmergedDictionaries?: Record<string, unknown>) => {
|
|
24
|
+
export declare const extractBabelContentForComponents: (ast: t.File, fileCode: string, existingKeys: Set<string>, defaultKey: string, configuration: IntlayerConfig, filePath: string, unmergedDictionaries?: Record<string, unknown>) => {
|
|
25
25
|
extractedContent: Record<string, Record<string, string>>;
|
|
26
26
|
replacements: BabelReplacement[];
|
|
27
27
|
componentsNeedingHooks: Set<NodePath>;
|
|
@@ -35,10 +35,9 @@ declare const extractBabelContentForComponents: (ast: t.File, fileCode: string,
|
|
|
35
35
|
/**
|
|
36
36
|
* High-level function to extract content from TS/JS/JSX/TSX AST.
|
|
37
37
|
*/
|
|
38
|
-
declare const extractTsContent: (ast: t.File, fileCode: string, existingKeys: Set<string>, configuration: IntlayerConfig, filePath: string, unmergedDictionaries?: Record<string, unknown>) => {
|
|
38
|
+
export declare const extractTsContent: (ast: t.File, fileCode: string, existingKeys: Set<string>, configuration: IntlayerConfig, filePath: string, unmergedDictionaries?: Record<string, unknown>) => {
|
|
39
39
|
extractedContent: Record<string, string>;
|
|
40
40
|
replacements: BabelReplacement[];
|
|
41
41
|
};
|
|
42
42
|
//#endregion
|
|
43
|
-
export { BabelReplacement, extractBabelContentForComponents, extractTsContent, handleJsxInsertionBabel };
|
|
44
43
|
//# sourceMappingURL=babelProcessor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"babelProcessor.d.ts","names":[],"sources":["../../../src/extractContent/babelProcessor.ts"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"babelProcessor.d.ts","names":[],"sources":["../../../src/extractContent/babelProcessor.ts"],"mappings":";;;;;;YAYY;EACV,MAAM;EACN;EACA;EAOA;EACA,oBAAoB,EAAE;EACtB;;;;;;qBA4IW,0BAAuB,MAC5B,SAAS,EAAE,aAAa,EAAE,cAAY,kBAC5B,cACF,aAAW,yBACA,MAAM,qBAAmB,kBAChC,eAAe,yBAAuB,cAC1C,oBAAkB,cAClB,IAAI,EAAE;;;;;qBAwIT,mCAAgC,KACtC,EAAE,MAAI,kBACK,cACF,aAAW,oBACP,eACH,gBAAc,kBACb,uBACM;EAEtB,kBAAkB,eAAe;EACjC,cAAc;EACd,wBAAwB,IAAI;EAC5B,iBAAiB,IAAI,EAAE;EACvB,gBAAgB;EAChB,SAAS,IAAI,EAAE;;EAEf,oBAAoB,IAAI,EAAE,MAAM;EAChC;;;;;qBA6ZW,mBAAgB,KACtB,EAAE,MAAI,kBACK,cACF,aAAW,eACV,gBAAc,kBACb,uBACM;EAEtB,kBAAkB;EAClB,cAAc"}
|
|
@@ -18,18 +18,17 @@ type DictionaryContentMap = Record<string, TranslationNode>;
|
|
|
18
18
|
* - Keys in both: preserve existing translations, update default locale value
|
|
19
19
|
* - Keys in existing but not in extracted: removed (no longer in source)
|
|
20
20
|
*/
|
|
21
|
-
declare const mergeWithExistingMultilingualDictionary: (extractedContent: Record<string, string>, existingDictionary: Dictionary | null, defaultLocale: string) => DictionaryContentMap;
|
|
21
|
+
export declare const mergeWithExistingMultilingualDictionary: (extractedContent: Record<string, string>, existingDictionary: Dictionary | null, defaultLocale: string) => DictionaryContentMap;
|
|
22
22
|
/**
|
|
23
23
|
* Merge extracted content with existing dictionary for per-locale format.
|
|
24
24
|
* - Keys in extracted but not in existing: added
|
|
25
25
|
* - Keys in both: update value
|
|
26
26
|
* - Keys in existing but not in extracted: removed (no longer in source)
|
|
27
27
|
*/
|
|
28
|
-
declare const mergeWithExistingPerLocaleDictionary: (extractedContent: Record<string, string>, existingDictionary: Dictionary | null) => Record<string, string>;
|
|
28
|
+
export declare const mergeWithExistingPerLocaleDictionary: (extractedContent: Record<string, string>, existingDictionary: Dictionary | null) => Record<string, string>;
|
|
29
29
|
/**
|
|
30
30
|
* Helper to write extracted content to dictionary file(s).
|
|
31
31
|
*/
|
|
32
|
-
declare const writeContentHelper: (extractedContent: Record<string, string>, dictionaryKey: DictionaryKey, filePath: string, configuration: IntlayerConfig) => Promise<string>;
|
|
32
|
+
export declare const writeContentHelper: (extractedContent: Record<string, string>, dictionaryKey: DictionaryKey, filePath: string, configuration: IntlayerConfig) => Promise<string>;
|
|
33
33
|
//#endregion
|
|
34
|
-
export { mergeWithExistingMultilingualDictionary, mergeWithExistingPerLocaleDictionary, writeContentHelper };
|
|
35
34
|
//# sourceMappingURL=contentWriter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contentWriter.d.ts","names":[],"sources":["../../../src/extractContent/contentWriter.ts"],"mappings":";;;;;;KAmCK;EACH;EACA,aAAa;;;;;KAMV,uBAAuB,eAAe;;;;;;;
|
|
1
|
+
{"version":3,"file":"contentWriter.d.ts","names":[],"sources":["../../../src/extractContent/contentWriter.ts"],"mappings":";;;;;;KAmCK;EACH;EACA,aAAa;;;;;KAMV,uBAAuB,eAAe;;;;;;;qBAa9B,0CAAuC,kBAChC,wBAAsB,oBACpB,mBAAiB,0BAEpC;;;;;;;qBAkDU,uCAAoC,kBAC7B,wBAAsB,oBACpB,sBACnB;;;;qBA8CU,qBAAkB,kBACX,wBAAsB,eACzB,eAAa,kBACZ,eACD,mBACd"}
|
|
@@ -3,7 +3,7 @@ import "./utils/index.js";
|
|
|
3
3
|
import { IntlayerConfig } from "@intlayer/types/config";
|
|
4
4
|
import { GetConfigurationOptions } from "@intlayer/config/node";
|
|
5
5
|
//#region src/extractContent/extractContent.d.ts
|
|
6
|
-
type ExtractIntlayerOptions = {
|
|
6
|
+
export type ExtractIntlayerOptions = {
|
|
7
7
|
configOptions?: GetConfigurationOptions;
|
|
8
8
|
codeOnly?: boolean;
|
|
9
9
|
declarationOnly?: boolean;
|
|
@@ -20,7 +20,7 @@ type ExtractResult = {
|
|
|
20
20
|
transformedCode: string | null;
|
|
21
21
|
extractedContentMap: Record<string, Record<string, string>>;
|
|
22
22
|
};
|
|
23
|
-
declare const extractContent: (filePath: string, packageName: PackageName, options?: ExtractIntlayerOptions) => Promise<ExtractResult | undefined>;
|
|
23
|
+
export declare const extractContent: (filePath: string, packageName: PackageName, options?: ExtractIntlayerOptions) => Promise<ExtractResult | undefined>;
|
|
24
24
|
/**
|
|
25
25
|
* Synchronous variant of `extractContent` — used by the Babel plugin which
|
|
26
26
|
* runs in a sync transform context (e.g. Next.js / Webpack).
|
|
@@ -31,7 +31,6 @@ declare const extractContent: (filePath: string, packageName: PackageName, optio
|
|
|
31
31
|
* - Does NOT write dictionary files or run the code formatter; callers that
|
|
32
32
|
* need persistence should supply an `onExtract` callback
|
|
33
33
|
*/
|
|
34
|
-
declare const extractContentSync: (filePath: string, packageName: PackageName, options?: ExtractIntlayerOptions) => ExtractResult | undefined;
|
|
34
|
+
export declare const extractContentSync: (filePath: string, packageName: PackageName, options?: ExtractIntlayerOptions) => ExtractResult | undefined;
|
|
35
35
|
//#endregion
|
|
36
|
-
export { ExtractIntlayerOptions, extractContent, extractContentSync };
|
|
37
36
|
//# sourceMappingURL=extractContent.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extractContent.d.ts","names":[],"sources":["../../../src/extractContent/extractContent.ts"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"extractContent.d.ts","names":[],"sources":["../../../src/extractContent/extractContent.ts"],"mappings":";;;;;YAsBY;EACV,gBAAgB;EAChB;EACA;EACA,uBAAuB;EACvB,gBAAgB;EAChB;EACA,aAAa;IACX;IACA,SAAS;IACT;eACW;;KAsRV;EACH;EACA,qBAAqB,eAAe;;qBAmCzB,iBAAc,kBACT,aACH,aAAW,UACd,2BACT,QAAQ;;;;;;;;;;;qBA8EE,qBAAkB,kBACb,aACH,aAAW,UACd,2BACT"}
|
|
@@ -2,7 +2,7 @@ import { PackageName } from "./utils/constants.js";
|
|
|
2
2
|
import "./utils/index.js";
|
|
3
3
|
import { IntlayerConfig } from "@intlayer/types/config";
|
|
4
4
|
//#region src/extractContent/processTsxFile.d.ts
|
|
5
|
-
type TextEdit = {
|
|
5
|
+
export type TextEdit = {
|
|
6
6
|
start: number;
|
|
7
7
|
end: number;
|
|
8
8
|
replacement: string;
|
|
@@ -10,10 +10,9 @@ type TextEdit = {
|
|
|
10
10
|
/**
|
|
11
11
|
* Processes a TSX/JSX/TS/JS file to extract content and inject Intlayer hooks/calls.
|
|
12
12
|
*/
|
|
13
|
-
declare const processTsxFile: (filePath: string, componentKey: string, packageName: PackageName, configuration: IntlayerConfig, save?: boolean, unmergedDictionaries?: Record<string, unknown>, providedFileCode?: string) => {
|
|
13
|
+
export declare const processTsxFile: (filePath: string, componentKey: string, packageName: PackageName, configuration: IntlayerConfig, save?: boolean, unmergedDictionaries?: Record<string, unknown>, providedFileCode?: string) => {
|
|
14
14
|
extractedContent: Record<string, Record<string, string>>;
|
|
15
15
|
modifiedCode: string;
|
|
16
16
|
} | null;
|
|
17
17
|
//#endregion
|
|
18
|
-
export { TextEdit, processTsxFile };
|
|
19
18
|
//# sourceMappingURL=processTsxFile.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"processTsxFile.d.ts","names":[],"sources":["../../../src/extractContent/processTsxFile.ts"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"processTsxFile.d.ts","names":[],"sources":["../../../src/extractContent/processTsxFile.ts"],"mappings":";;;;YAcY;EACV;EACA;EACA;;;;;qBA4BW,iBAAc,kBACT,sBACI,aACP,aAAW,eACT,gBAAc,gBAChB,uBACS,yBAAuB;EAG7C,kBAAkB,eAAe;EACjC"}
|
|
@@ -5,10 +5,9 @@
|
|
|
5
5
|
*
|
|
6
6
|
* Order matter for resolution
|
|
7
7
|
*/
|
|
8
|
-
declare const packageList: readonly ['next-intlayer', 'react-intlayer', 'vue-intlayer', 'svelte-intlayer', 'preact-intlayer', 'solid-intlayer', 'angular-intlayer', 'lit-intlayer', 'express-intlayer', 'hono-intlayer', 'fastify-intlayer', 'adonis-intlayer', 'intlayer'];
|
|
8
|
+
export declare const packageList: readonly ['next-intlayer', 'react-intlayer', 'vue-intlayer', 'svelte-intlayer', 'preact-intlayer', 'solid-intlayer', 'angular-intlayer', 'lit-intlayer', 'express-intlayer', 'hono-intlayer', 'fastify-intlayer', 'adonis-intlayer', 'intlayer'];
|
|
9
9
|
/** Packages that support a `/server` sub-path for React Server Components. */
|
|
10
|
-
declare const SERVER_CAPABLE_PACKAGES: ReadonlySet<string>;
|
|
11
|
-
type PackageName = (typeof packageList)[number];
|
|
10
|
+
export declare const SERVER_CAPABLE_PACKAGES: ReadonlySet<string>;
|
|
11
|
+
export type PackageName = (typeof packageList)[number];
|
|
12
12
|
//#endregion
|
|
13
|
-
export { PackageName, SERVER_CAPABLE_PACKAGES, packageList };
|
|
14
13
|
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","names":[],"sources":["../../../../src/extractContent/utils/constants.ts"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"constants.d.ts","names":[],"sources":["../../../../src/extractContent/utils/constants.ts"],"mappings":";;;;;;;qBAMa;;qBAiBA,yBAAyB;YAI1B,sBAAsB"}
|
|
@@ -3,7 +3,6 @@ import { PackageName } from "./constants.js";
|
|
|
3
3
|
/**
|
|
4
4
|
* Detects which intlayer package is used in the project by reading package.json.
|
|
5
5
|
*/
|
|
6
|
-
declare const detectPackageName: (searchDir: string) => PackageName;
|
|
6
|
+
export declare const detectPackageName: (searchDir: string) => PackageName;
|
|
7
7
|
//#endregion
|
|
8
|
-
export { detectPackageName };
|
|
9
8
|
//# sourceMappingURL=detectPackageName.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"detectPackageName.d.ts","names":[],"sources":["../../../../src/extractContent/utils/detectPackageName.ts"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"detectPackageName.d.ts","names":[],"sources":["../../../../src/extractContent/utils/detectPackageName.ts"],"mappings":";;;;;qBAOa,oBAAiB,sBAAwB"}
|
|
@@ -2,8 +2,8 @@ import { Locale } from "@intlayer/types/allLocales";
|
|
|
2
2
|
import { IntlayerConfig } from "@intlayer/types/config";
|
|
3
3
|
import { FilePathPatternFunction } from "@intlayer/types/filePathPattern";
|
|
4
4
|
//#region src/extractContent/utils/extractDictionaryInfo.d.ts
|
|
5
|
-
declare const getOutput: (configuration: IntlayerConfig, locale?: Locale) => FilePathPatternFunction | false;
|
|
6
|
-
type ResolveContentFilePaths = {
|
|
5
|
+
export declare const getOutput: (configuration: IntlayerConfig, locale?: Locale) => FilePathPatternFunction | false;
|
|
6
|
+
export type ResolveContentFilePaths = {
|
|
7
7
|
absolutePath: string;
|
|
8
8
|
relativePath: string;
|
|
9
9
|
isPerLocale: boolean;
|
|
@@ -12,16 +12,15 @@ type ResolveContentFilePaths = {
|
|
|
12
12
|
* Resolves the paths for the content files associated with a component.
|
|
13
13
|
* Checks for existing dictionaries first.
|
|
14
14
|
*/
|
|
15
|
-
declare const resolveContentFilePaths: (filePath: string, componentKey: string, configuration: IntlayerConfig, locale?: Locale) => Promise<ResolveContentFilePaths>;
|
|
16
|
-
type ExtractDictionaryInfoOptions = {
|
|
15
|
+
export declare const resolveContentFilePaths: (filePath: string, componentKey: string, configuration: IntlayerConfig, locale?: Locale) => Promise<ResolveContentFilePaths>;
|
|
16
|
+
export type ExtractDictionaryInfoOptions = {
|
|
17
17
|
configuration?: IntlayerConfig;
|
|
18
18
|
};
|
|
19
19
|
/**
|
|
20
20
|
* Extracts the dictionary key and dictionary file path for a given component file.
|
|
21
21
|
*/
|
|
22
|
-
declare const extractDictionaryInfo: (filePath: string, fileText: string, configuration: IntlayerConfig) => Promise<{
|
|
22
|
+
export declare const extractDictionaryInfo: (filePath: string, fileText: string, configuration: IntlayerConfig) => Promise<{
|
|
23
23
|
dictionaryKey: string;
|
|
24
24
|
} & ResolveContentFilePaths>;
|
|
25
25
|
//#endregion
|
|
26
|
-
export { ExtractDictionaryInfoOptions, ResolveContentFilePaths, extractDictionaryInfo, getOutput, resolveContentFilePaths };
|
|
27
26
|
//# sourceMappingURL=extractDictionaryInfo.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extractDictionaryInfo.d.ts","names":[],"sources":["../../../../src/extractContent/utils/extractDictionaryInfo.ts"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"extractDictionaryInfo.d.ts","names":[],"sources":["../../../../src/extractContent/utils/extractDictionaryInfo.ts"],"mappings":";;;;qBAmBa,YAAS,eACL,gBAAc,SACpB,WACR;YA0CS;EACV;EACA;EACA;;;;;;qBAOW,0BAAuB,kBAClB,sBACI,eACL,gBAAc,SACpB,WACR,QAAQ;YA+GC;EACV,gBAAgB;;;;;qBAML,wBAAqB,kBAChB,kBACA,eACD,mBACd;EAEC;IACE"}
|
|
@@ -4,8 +4,7 @@
|
|
|
4
4
|
*
|
|
5
5
|
* Example: "src/components/MyComponent/index.tsx" -> "comp-my-component"
|
|
6
6
|
*/
|
|
7
|
-
declare const extractDictionaryKeyFromPath: (filePath: string, prefix?: string) => string;
|
|
8
|
-
declare const extractDictionaryKey: (filePath: string, fileText: string, prefix?: string) => string;
|
|
7
|
+
export declare const extractDictionaryKeyFromPath: (filePath: string, prefix?: string) => string;
|
|
8
|
+
export declare const extractDictionaryKey: (filePath: string, fileText: string, prefix?: string) => string;
|
|
9
9
|
//#endregion
|
|
10
|
-
export { extractDictionaryKey, extractDictionaryKeyFromPath };
|
|
11
10
|
//# sourceMappingURL=extractDictionaryKey.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extractDictionaryKey.d.ts","names":[],"sources":["../../../../src/extractContent/utils/extractDictionaryKey.ts"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"extractDictionaryKey.d.ts","names":[],"sources":["../../../../src/extractContent/utils/extractDictionaryKey.ts"],"mappings":";;;;;;qBASa,+BAA4B,kBACvB;qBAkBL,uBAAoB,kBACf,kBACA"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
//#region src/extractContent/utils/generateKey.d.ts
|
|
2
|
-
declare const generateKey: (text: string, existingKeys: Set<string>) => string;
|
|
2
|
+
export declare const generateKey: (text: string, existingKeys: Set<string>) => string;
|
|
3
3
|
//#endregion
|
|
4
|
-
export { generateKey };
|
|
5
4
|
//# sourceMappingURL=generateKey.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateKey.d.ts","names":[],"sources":["../../../../src/extractContent/utils/generateKey.ts"],"mappings":";
|
|
1
|
+
{"version":3,"file":"generateKey.d.ts","names":[],"sources":["../../../../src/extractContent/utils/generateKey.ts"],"mappings":";qBAAa,cAAW,cACV,cACE"}
|
|
@@ -3,7 +3,6 @@ import { NodePath } from "@babel/traverse";
|
|
|
3
3
|
/**
|
|
4
4
|
* Resolves the name of the component from various function declaration types.
|
|
5
5
|
*/
|
|
6
|
-
declare const getComponentName: (path: NodePath) => string | undefined;
|
|
6
|
+
export declare const getComponentName: (path: NodePath) => string | undefined;
|
|
7
7
|
//#endregion
|
|
8
|
-
export { getComponentName };
|
|
9
8
|
//# sourceMappingURL=getComponentName.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getComponentName.d.ts","names":[],"sources":["../../../../src/extractContent/utils/getComponentName.ts"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"getComponentName.d.ts","names":[],"sources":["../../../../src/extractContent/utils/getComponentName.ts"],"mappings":";;;;;qBAMa,mBAAgB,MAAU"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as t from "@babel/types";
|
|
2
2
|
import { NodePath } from "@babel/traverse";
|
|
3
3
|
//#region src/extractContent/utils/getExistingIntlayerInfo.d.ts
|
|
4
|
-
type ExistingIntlayerInfo = {
|
|
4
|
+
export type ExistingIntlayerInfo = {
|
|
5
5
|
key: string;
|
|
6
6
|
hook: 'useIntlayer' | 'getIntlayer';
|
|
7
7
|
/** The variable name used to store the call result (e.g. `t` in `const t = useIntlayer(...)`) */
|
|
@@ -16,7 +16,6 @@ type ExistingIntlayerInfo = {
|
|
|
16
16
|
/**
|
|
17
17
|
* Searches for an existing useIntlayer or getIntlayer call in the function body.
|
|
18
18
|
*/
|
|
19
|
-
declare const getExistingIntlayerInfo: (path: NodePath) => ExistingIntlayerInfo | undefined;
|
|
19
|
+
export declare const getExistingIntlayerInfo: (path: NodePath) => ExistingIntlayerInfo | undefined;
|
|
20
20
|
//#endregion
|
|
21
|
-
export { ExistingIntlayerInfo, getExistingIntlayerInfo };
|
|
22
21
|
//# sourceMappingURL=getExistingIntlayerInfo.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getExistingIntlayerInfo.d.ts","names":[],"sources":["../../../../src/extractContent/utils/getExistingIntlayerInfo.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"getExistingIntlayerInfo.d.ts","names":[],"sources":["../../../../src/extractContent/utils/getExistingIntlayerInfo.ts"],"mappings":";;;YAGY;EACV;EACA;;EAEA;;EAEA;;EAEA;;EAEA,oBAAoB,EAAE;;;;;qBAMX,0BAAuB,MAC5B,aACL"}
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* Gets an existing key for a given text or generates a new one.
|
|
4
4
|
*/
|
|
5
|
-
declare const getOrGenerateKey: (text: string, componentKey: string, existingKeys: Set<string>, extractedContent: Record<string, Record<string, string>>) => string;
|
|
5
|
+
export declare const getOrGenerateKey: (text: string, componentKey: string, existingKeys: Set<string>, extractedContent: Record<string, Record<string, string>>) => string;
|
|
6
6
|
//#endregion
|
|
7
|
-
export { getOrGenerateKey };
|
|
8
7
|
//# sourceMappingURL=getOrGenerateKey.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getOrGenerateKey.d.ts","names":[],"sources":["../../../../src/extractContent/utils/getOrGenerateKey.ts"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"getOrGenerateKey.d.ts","names":[],"sources":["../../../../src/extractContent/utils/getOrGenerateKey.ts"],"mappings":";;;;qBAKa,mBAAgB,cACf,sBACQ,cACN,aAAW,kBACP,eAAe"}
|
|
@@ -5,7 +5,6 @@ import { IntlayerConfig } from "@intlayer/types/config";
|
|
|
5
5
|
* Note: this chokidar-specific variant fetches unmergedDictionaries internally
|
|
6
6
|
* from the configuration (unlike the `@intlayer/babel` version which takes it as a parameter).
|
|
7
7
|
*/
|
|
8
|
-
declare const resolveDictionaryKey: (initialKey: string, filePath: string, configuration: IntlayerConfig, unmergedDictionaries?: Record<string, unknown>, usedKeys?: Set<string>) => string;
|
|
8
|
+
export declare const resolveDictionaryKey: (initialKey: string, filePath: string, configuration: IntlayerConfig, unmergedDictionaries?: Record<string, unknown>, usedKeys?: Set<string>) => string;
|
|
9
9
|
//#endregion
|
|
10
|
-
export { resolveDictionaryKey };
|
|
11
10
|
//# sourceMappingURL=resolveDictionaryKey.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveDictionaryKey.d.ts","names":[],"sources":["../../../../src/extractContent/utils/resolveDictionaryKey.ts"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"resolveDictionaryKey.d.ts","names":[],"sources":["../../../../src/extractContent/utils/resolveDictionaryKey.ts"],"mappings":";;;;;;;qBAYa,uBAAoB,oBACb,kBACF,eACD,gBAAc,uBACN,yBAAuB,WACpC"}
|