@jsverse/transloco 7.1.0 → 7.2.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/CHANGELOG.md +6 -0
- package/esm2022/lib/transloco.providers.mjs +4 -4
- package/fesm2022/jsverse-transloco.mjs +3 -3
- package/fesm2022/jsverse-transloco.mjs.map +1 -1
- package/lib/resolve-loader.d.ts +1 -1
- package/lib/transloco.providers.d.ts +2 -2
- package/package.json +1 -1
- package/schematics/src/assets/i18n/en.json +0 -1
- package/schematics/src/collection.json +0 -59
- package/schematics/src/component/index.d.ts +0 -2
- package/schematics/src/component/index.js +0 -21
- package/schematics/src/component/index.js.map +0 -1
- package/schematics/src/join/index.d.ts +0 -3
- package/schematics/src/join/index.js +0 -79
- package/schematics/src/join/index.js.map +0 -1
- package/schematics/src/join/schema.d.ts +0 -28
- package/schematics/src/join/schema.js +0 -3
- package/schematics/src/join/schema.js.map +0 -1
- package/schematics/src/join/schema.json +0 -43
- package/schematics/src/keys-manager/index.d.ts +0 -5
- package/schematics/src/keys-manager/index.js +0 -97
- package/schematics/src/keys-manager/index.js.map +0 -1
- package/schematics/src/keys-manager/schema.d.ts +0 -19
- package/schematics/src/keys-manager/schema.js +0 -3
- package/schematics/src/keys-manager/schema.js.map +0 -1
- package/schematics/src/keys-manager/schema.json +0 -33
- package/schematics/src/migrate/index.d.ts +0 -3
- package/schematics/src/migrate/index.js +0 -21
- package/schematics/src/migrate/index.js.map +0 -1
- package/schematics/src/migrate/ngx-translate-migration.d.ts +0 -3
- package/schematics/src/migrate/ngx-translate-migration.js +0 -169
- package/schematics/src/migrate/ngx-translate-migration.js.map +0 -1
- package/schematics/src/migrate/schema.d.ts +0 -10
- package/schematics/src/migrate/schema.js +0 -3
- package/schematics/src/migrate/schema.js.map +0 -1
- package/schematics/src/migrate/schema.json +0 -23
- package/schematics/src/ng-add/files/transloco-loader/transloco-loader.__ts__ +0 -12
- package/schematics/src/ng-add/files/transloco-module/transloco-root.module.__ts__ +0 -24
- package/schematics/src/ng-add/generators/http-loader.gen.d.ts +0 -4
- package/schematics/src/ng-add/generators/http-loader.gen.js +0 -15
- package/schematics/src/ng-add/generators/http-loader.gen.js.map +0 -1
- package/schematics/src/ng-add/generators/root-module.gen.d.ts +0 -9
- package/schematics/src/ng-add/generators/root-module.gen.js +0 -31
- package/schematics/src/ng-add/generators/root-module.gen.js.map +0 -1
- package/schematics/src/ng-add/generators/translation-files.gen.d.ts +0 -4
- package/schematics/src/ng-add/generators/translation-files.gen.js +0 -23
- package/schematics/src/ng-add/generators/translation-files.gen.js.map +0 -1
- package/schematics/src/ng-add/index.d.ts +0 -3
- package/schematics/src/ng-add/index.js +0 -103
- package/schematics/src/ng-add/index.js.map +0 -1
- package/schematics/src/ng-add/schema.d.ts +0 -42
- package/schematics/src/ng-add/schema.js +0 -14
- package/schematics/src/ng-add/schema.js.map +0 -1
- package/schematics/src/ng-add/schema.json +0 -53
- package/schematics/src/ng-migrate/index.d.ts +0 -3
- package/schematics/src/ng-migrate/index.js +0 -14
- package/schematics/src/ng-migrate/index.js.map +0 -1
- package/schematics/src/ng-migrate/ng-migrate.d.ts +0 -5
- package/schematics/src/ng-migrate/ng-migrate.js +0 -106
- package/schematics/src/ng-migrate/ng-migrate.js.map +0 -1
- package/schematics/src/ng-migrate/schema.d.ts +0 -14
- package/schematics/src/ng-migrate/schema.js +0 -3
- package/schematics/src/ng-migrate/schema.js.map +0 -1
- package/schematics/src/ng-migrate/schema.json +0 -27
- package/schematics/src/schematics.consts.d.ts +0 -4
- package/schematics/src/schematics.consts.js +0 -8
- package/schematics/src/schematics.consts.js.map +0 -1
- package/schematics/src/scope/index.d.ts +0 -3
- package/schematics/src/scope/index.js +0 -101
- package/schematics/src/scope/index.js.map +0 -1
- package/schematics/src/scope/schema.d.ts +0 -28
- package/schematics/src/scope/schema.js +0 -3
- package/schematics/src/scope/schema.js.map +0 -1
- package/schematics/src/scope/schema.json +0 -84
- package/schematics/src/split/index.d.ts +0 -3
- package/schematics/src/split/index.js +0 -66
- package/schematics/src/split/index.js.map +0 -1
- package/schematics/src/split/schema.d.ts +0 -20
- package/schematics/src/split/schema.js +0 -3
- package/schematics/src/split/schema.js.map +0 -1
- package/schematics/src/split/schema.json +0 -35
- package/schematics/src/types.d.ts +0 -5
- package/schematics/src/types.js +0 -10
- package/schematics/src/types.js.map +0 -1
- package/schematics/src/upgrade/index.d.ts +0 -3
- package/schematics/src/upgrade/index.js +0 -19
- package/schematics/src/upgrade/index.js.map +0 -1
- package/schematics/src/upgrade/schema.d.ts +0 -6
- package/schematics/src/upgrade/schema.js +0 -3
- package/schematics/src/upgrade/schema.js.map +0 -1
- package/schematics/src/upgrade/schema.json +0 -16
- package/schematics/src/upgrade/v2.d.ts +0 -1
- package/schematics/src/upgrade/v2.js +0 -89
- package/schematics/src/upgrade/v2.js.map +0 -1
- package/schematics/src/utils/array.d.ts +0 -3
- package/schematics/src/utils/array.js +0 -12
- package/schematics/src/utils/array.js.map +0 -1
- package/schematics/src/utils/config.d.ts +0 -2
- package/schematics/src/utils/config.js +0 -13
- package/schematics/src/utils/config.js.map +0 -1
- package/schematics/src/utils/find-module.d.ts +0 -23
- package/schematics/src/utils/find-module.js +0 -110
- package/schematics/src/utils/find-module.js.map +0 -1
- package/schematics/src/utils/package.d.ts +0 -5
- package/schematics/src/utils/package.js +0 -19
- package/schematics/src/utils/package.js.map +0 -1
- package/schematics/src/utils/projects.d.ts +0 -8
- package/schematics/src/utils/projects.js +0 -56
- package/schematics/src/utils/projects.js.map +0 -1
- package/schematics/src/utils/translations.d.ts +0 -7
- package/schematics/src/utils/translations.js +0 -31
- package/schematics/src/utils/translations.js.map +0 -1
- package/schematics/src/utils/transloco.d.ts +0 -24
- package/schematics/src/utils/transloco.js +0 -93
- package/schematics/src/utils/transloco.js.map +0 -1
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CONFIG_FILE = exports.LIB_NAME = exports.NPM_SCOPE = exports.PROJECT_NAME = void 0;
|
|
4
|
-
exports.PROJECT_NAME = 'transloco';
|
|
5
|
-
exports.NPM_SCOPE = '@jsverse';
|
|
6
|
-
exports.LIB_NAME = `${exports.NPM_SCOPE}/transloco`;
|
|
7
|
-
exports.CONFIG_FILE = 'transloco.config.js';
|
|
8
|
-
//# sourceMappingURL=schematics.consts.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"schematics.consts.js","sourceRoot":"","sources":["../../../../../libs/transloco-schematics/src/schematics.consts.ts"],"names":[],"mappings":";;;AAAa,QAAA,YAAY,GAAG,WAAW,CAAC;AAC3B,QAAA,SAAS,GAAG,UAAU,CAAC;AACvB,QAAA,QAAQ,GAAG,GAAG,iBAAS,YAAY,CAAC;AACpC,QAAA,WAAW,GAAG,qBAAqB,CAAC"}
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const node_path_1 = require("node:path");
|
|
4
|
-
const strings_1 = require("@angular-devkit/core/src/utils/strings");
|
|
5
|
-
const schematics_1 = require("@angular-devkit/schematics");
|
|
6
|
-
const typescript_1 = require("typescript");
|
|
7
|
-
const ast_utils_1 = require("@schematics/angular/utility/ast-utils");
|
|
8
|
-
const util_1 = require("@schematics/angular/utility/standalone/util");
|
|
9
|
-
const schematics_consts_1 = require("../schematics.consts");
|
|
10
|
-
const array_1 = require("../utils/array");
|
|
11
|
-
const find_module_1 = require("../utils/find-module");
|
|
12
|
-
const projects_1 = require("../utils/projects");
|
|
13
|
-
const translations_1 = require("../utils/translations");
|
|
14
|
-
const config_1 = require("../utils/config");
|
|
15
|
-
function getProviderValue(options) {
|
|
16
|
-
const name = (0, strings_1.dasherize)(options.name);
|
|
17
|
-
if (!options.inlineLoader)
|
|
18
|
-
return `'${name}'`;
|
|
19
|
-
return `{ scope: '${name}', loader }`;
|
|
20
|
-
}
|
|
21
|
-
function addScopeToModule(tree, modulePath, options) {
|
|
22
|
-
const module = tree.read(modulePath);
|
|
23
|
-
const moduleSource = (0, typescript_1.createSourceFile)(modulePath, module.toString('utf-8'), typescript_1.ScriptTarget.Latest, true);
|
|
24
|
-
const provider = `provideTranslocoScope(${getProviderValue(options)})`;
|
|
25
|
-
const changes = [];
|
|
26
|
-
changes.push((0, ast_utils_1.addProviderToModule)(moduleSource, modulePath, provider, schematics_consts_1.LIB_NAME)[0]);
|
|
27
|
-
changes.push((0, ast_utils_1.addImportToModule)(moduleSource, modulePath, 'TranslocoModule', schematics_consts_1.LIB_NAME)[0]);
|
|
28
|
-
changes.push((0, ast_utils_1.insertImport)(moduleSource, modulePath, 'provideTranslocoScope, TranslocoModule', schematics_consts_1.LIB_NAME));
|
|
29
|
-
if (options.inlineLoader) {
|
|
30
|
-
changes.push((0, ast_utils_1.insertImport)(moduleSource, modulePath, 'loader', './transloco.loader'));
|
|
31
|
-
}
|
|
32
|
-
(0, util_1.applyChangesToFile)(tree, modulePath, changes);
|
|
33
|
-
}
|
|
34
|
-
function getTranslationFilesFromAssets(host, translationsPath) {
|
|
35
|
-
const langFiles = host.root.dir(translationsPath).subfiles;
|
|
36
|
-
return Array.from(new Set(langFiles.map((file) => file.split('.')[0])));
|
|
37
|
-
}
|
|
38
|
-
function getTranslationFiles(options, host, translationsPath) {
|
|
39
|
-
return (options.langs ||
|
|
40
|
-
(0, config_1.getConfig)().langs ||
|
|
41
|
-
getTranslationFilesFromAssets(host, translationsPath));
|
|
42
|
-
}
|
|
43
|
-
function addInlineLoader(tree, modulePath, name, langs) {
|
|
44
|
-
const loader = `export const loader = [${(0, array_1.stringifyList)((0, array_1.coerceArray)(langs))}].reduce((acc: any, lang: string) => {
|
|
45
|
-
acc[lang] = () => import(\`./i18n/\${lang}.json\`);
|
|
46
|
-
return acc;
|
|
47
|
-
}, {});
|
|
48
|
-
|
|
49
|
-
`;
|
|
50
|
-
const path = (0, node_path_1.join)((0, node_path_1.dirname)(modulePath), 'transloco.loader.ts');
|
|
51
|
-
tree.create(path, loader);
|
|
52
|
-
}
|
|
53
|
-
function createTranslationFiles(options, rootPath, modulePath, host) {
|
|
54
|
-
if (options.skipCreation) {
|
|
55
|
-
return (0, schematics_1.empty)();
|
|
56
|
-
}
|
|
57
|
-
const defaultPath = options.inlineLoader
|
|
58
|
-
? (0, node_path_1.join)((0, node_path_1.dirname)(modulePath), 'i18n')
|
|
59
|
-
: (0, node_path_1.join)(rootPath, 'assets', 'i18n', (0, strings_1.dasherize)(options.name));
|
|
60
|
-
const translationsPath = options.translationPath
|
|
61
|
-
? (0, node_path_1.join)(rootPath, options.translationPath)
|
|
62
|
-
: defaultPath;
|
|
63
|
-
return (0, translations_1.createTranslateFilesFromOptions)(host, options, translationsPath);
|
|
64
|
-
}
|
|
65
|
-
function extractModuleOptions({ path, project, routing, flat, commonModule, }) {
|
|
66
|
-
return { path, project, routing, flat, commonModule };
|
|
67
|
-
}
|
|
68
|
-
function default_1(options) {
|
|
69
|
-
return (host, context) => {
|
|
70
|
-
const project = (0, projects_1.getProject)(host, options.project);
|
|
71
|
-
const rootPath = project?.sourceRoot ?? 'src';
|
|
72
|
-
const assetsPath = (0, node_path_1.join)(rootPath, 'assets', 'i18n');
|
|
73
|
-
options.langs = getTranslationFiles(options, host, assetsPath);
|
|
74
|
-
if (options.module) {
|
|
75
|
-
const projectPath = (0, projects_1.getProjectPath)(host, project, options);
|
|
76
|
-
const modulePath = (0, find_module_1.findModuleFromOptions)(host, options, projectPath);
|
|
77
|
-
if (options.inlineLoader) {
|
|
78
|
-
addInlineLoader(host, modulePath, options.name, options.langs);
|
|
79
|
-
}
|
|
80
|
-
if (modulePath) {
|
|
81
|
-
addScopeToModule(host, modulePath, options);
|
|
82
|
-
return (0, schematics_1.mergeWith)(createTranslationFiles(options, rootPath, modulePath, host))(host, context);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
return (0, schematics_1.chain)([
|
|
86
|
-
(0, schematics_1.externalSchematic)('@schematics/angular', 'module', extractModuleOptions(options)),
|
|
87
|
-
(tree) => {
|
|
88
|
-
const modulePath = tree.actions.find((action) => !!action.path.match(/\.module\.ts/) &&
|
|
89
|
-
!action.path.match(/-routing\.module\.ts/)).path;
|
|
90
|
-
addScopeToModule(tree, modulePath, options);
|
|
91
|
-
if (options.inlineLoader) {
|
|
92
|
-
addInlineLoader(tree, modulePath, options.name, options.langs);
|
|
93
|
-
}
|
|
94
|
-
const translationRule = createTranslationFiles(options, rootPath, modulePath, host);
|
|
95
|
-
return (0, schematics_1.mergeWith)(translationRule);
|
|
96
|
-
},
|
|
97
|
-
]);
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
exports.default = default_1;
|
|
101
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../libs/transloco-schematics/src/scope/index.ts"],"names":[],"mappings":";;AAAA,yCAA0C;AAE1C,oEAAmE;AACnE,2DAQoC;AACpC,2CAA4D;AAC5D,qEAI+C;AAC/C,sEAAiF;AAGjF,4DAAgD;AAChD,0CAA4D;AAC5D,sDAA6D;AAC7D,gDAA+D;AAC/D,wDAAwE;AACxE,4CAA4C;AAI5C,SAAS,gBAAgB,CAAC,OAAsB;IAC9C,MAAM,IAAI,GAAG,IAAA,mBAAS,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACrC,IAAI,CAAC,OAAO,CAAC,YAAY;QAAE,OAAO,IAAI,IAAI,GAAG,CAAC;IAC9C,OAAO,aAAa,IAAI,aAAa,CAAC;AACxC,CAAC;AAED,SAAS,gBAAgB,CACvB,IAAU,EACV,UAAkB,EAClB,OAAsB;IAEtB,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAErC,MAAM,YAAY,GAAG,IAAA,6BAAgB,EACnC,UAAU,EACV,MAAM,CAAC,Q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AM,EAAE,EAAE,CACT,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC;oBACnC,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,sBAAsB,CAAC,CAC7C,CAAC,IAAI,CAAC;gBACP,gBAAgB,CAAC,IAAI,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;gBAC5C,IAAI,OAAO,CAAC,YAAY,EAAE;oBACxB,eAAe,CAAC,IAAI,EAAE,UAAU,EAAE,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;iBAChE;gBACD,MAAM,eAAe,GAAG,sBAAsB,CAC5C,OAAO,EACP,QAAQ,EACR,UAAU,EACV,IAAI,CACL,CAAC;gBAEF,OAAO,IAAA,sBAAS,EAAC,eAAe,CAAC,CAAC;YACpC,CAAC;SACF,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC;AA/CD,4BA+CC"}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { Schema } from '@schematics/angular/module/schema';
|
|
2
|
-
export interface SchemaOptions extends Schema {
|
|
3
|
-
name: string;
|
|
4
|
-
/**
|
|
5
|
-
* The languages of the project.
|
|
6
|
-
*/
|
|
7
|
-
langs: string | string[];
|
|
8
|
-
/**
|
|
9
|
-
* Skip the creation of the translation files.
|
|
10
|
-
*/
|
|
11
|
-
skipCreation: boolean;
|
|
12
|
-
/**
|
|
13
|
-
* The path of the translation files.
|
|
14
|
-
*/
|
|
15
|
-
translationPath: string;
|
|
16
|
-
/**
|
|
17
|
-
* Specification of the declaring module..
|
|
18
|
-
*/
|
|
19
|
-
module: string;
|
|
20
|
-
/**
|
|
21
|
-
* The root project name.
|
|
22
|
-
*/
|
|
23
|
-
project: string;
|
|
24
|
-
/**
|
|
25
|
-
* Should create scope with inline loader.
|
|
26
|
-
*/
|
|
27
|
-
inlineLoader: boolean;
|
|
28
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../../../../libs/transloco-schematics/src/scope/schema.ts"],"names":[],"mappings":""}
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "http://json-schema.org/schema",
|
|
3
|
-
"$id": "transloco-scope",
|
|
4
|
-
"title": "Add new transloco scope module, along with translation files.",
|
|
5
|
-
"type": "object",
|
|
6
|
-
"properties": {
|
|
7
|
-
"name": {
|
|
8
|
-
"type": "string",
|
|
9
|
-
"description": "The scope name.",
|
|
10
|
-
"$default": {
|
|
11
|
-
"$source": "argv",
|
|
12
|
-
"index": 0
|
|
13
|
-
},
|
|
14
|
-
"x-prompt": "What scope name would you like?"
|
|
15
|
-
},
|
|
16
|
-
"module": {
|
|
17
|
-
"type": "string",
|
|
18
|
-
"description": "The path at which module to add scope to, relative to the workspace root."
|
|
19
|
-
},
|
|
20
|
-
"inlineLoader": {
|
|
21
|
-
"description": "Should create scope with inline loader.",
|
|
22
|
-
"type": "boolean",
|
|
23
|
-
"alias": "il"
|
|
24
|
-
},
|
|
25
|
-
"langs": {
|
|
26
|
-
"description": "The languages of the project.",
|
|
27
|
-
"type": "string",
|
|
28
|
-
"alias": "la"
|
|
29
|
-
},
|
|
30
|
-
"skipCreation": {
|
|
31
|
-
"type": "boolean",
|
|
32
|
-
"description": "Skip the translation files creation."
|
|
33
|
-
},
|
|
34
|
-
"translationPath": {
|
|
35
|
-
"description": "The to the translation files, relative to the project's root.",
|
|
36
|
-
"type": "string"
|
|
37
|
-
},
|
|
38
|
-
"lintFix": {
|
|
39
|
-
"type": "boolean",
|
|
40
|
-
"default": false,
|
|
41
|
-
"description": "When true, applies lint fixes after generating the module."
|
|
42
|
-
},
|
|
43
|
-
|
|
44
|
-
"path": {
|
|
45
|
-
"type": "string",
|
|
46
|
-
"format": "path",
|
|
47
|
-
"$default": {
|
|
48
|
-
"$source": "workingDirectory"
|
|
49
|
-
},
|
|
50
|
-
"description": "The path at which to create the NgModule, relative to the workspace root.",
|
|
51
|
-
"visible": false
|
|
52
|
-
},
|
|
53
|
-
"project": {
|
|
54
|
-
"type": "string",
|
|
55
|
-
"description": "The name of the project.",
|
|
56
|
-
"$default": {
|
|
57
|
-
"$source": "projectName"
|
|
58
|
-
}
|
|
59
|
-
},
|
|
60
|
-
"routing": {
|
|
61
|
-
"type": "boolean",
|
|
62
|
-
"description": "Create a routing module.",
|
|
63
|
-
"default": false
|
|
64
|
-
},
|
|
65
|
-
"routingScope": {
|
|
66
|
-
"enum": ["Child", "Root"],
|
|
67
|
-
"type": "string",
|
|
68
|
-
"description": "The scope for the new routing module.",
|
|
69
|
-
"default": "Child"
|
|
70
|
-
},
|
|
71
|
-
"flat": {
|
|
72
|
-
"type": "boolean",
|
|
73
|
-
"description": "Create the new files at the top level of the current project root. ",
|
|
74
|
-
"default": false
|
|
75
|
-
},
|
|
76
|
-
"commonModule": {
|
|
77
|
-
"type": "boolean",
|
|
78
|
-
"description": "The new NgModule imports \"CommonModule\". ",
|
|
79
|
-
"default": true,
|
|
80
|
-
"visible": false
|
|
81
|
-
}
|
|
82
|
-
},
|
|
83
|
-
"required": []
|
|
84
|
-
}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const types_1 = require("../types");
|
|
4
|
-
const transloco_1 = require("../utils/transloco");
|
|
5
|
-
function reduceTranslations(host, dirPath, translationJson, lang, key = '') {
|
|
6
|
-
const dir = host.getDir(dirPath);
|
|
7
|
-
if (!(0, transloco_1.hasFiles)(dir))
|
|
8
|
-
return translationJson;
|
|
9
|
-
if ((0, transloco_1.hasSubdirs)(dir)) {
|
|
10
|
-
dir.subdirs.forEach((subDirName) => {
|
|
11
|
-
const subDir = dir.dir(subDirName);
|
|
12
|
-
const nestedKeyPath = (0, transloco_1.getTranslationKey)(key, subDirName);
|
|
13
|
-
const nestedKey = nestedKeyPath.split('.').at(-1);
|
|
14
|
-
const subTranslationJson = translationJson[key];
|
|
15
|
-
if (subTranslationJson) {
|
|
16
|
-
reduceTranslations(host, subDir.path, subTranslationJson, lang, nestedKey);
|
|
17
|
-
delete translationJson[key][nestedKey];
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
dir.subfiles
|
|
22
|
-
.filter((fileName) => fileName.includes(`${lang}.json`))
|
|
23
|
-
.forEach((fileName) => {
|
|
24
|
-
if (!translationJson[key]) {
|
|
25
|
-
return translationJson;
|
|
26
|
-
}
|
|
27
|
-
(0, transloco_1.setFileContent)(host, dir.path, fileName, translationJson[key]);
|
|
28
|
-
});
|
|
29
|
-
delete translationJson[key];
|
|
30
|
-
return translationJson;
|
|
31
|
-
}
|
|
32
|
-
function parserFactory(format) {
|
|
33
|
-
switch (format) {
|
|
34
|
-
case types_1.TranslationFileFormat.JSON:
|
|
35
|
-
return JSON.parse;
|
|
36
|
-
case types_1.TranslationFileFormat.PO:
|
|
37
|
-
// TODO:
|
|
38
|
-
return JSON.parse;
|
|
39
|
-
case types_1.TranslationFileFormat.XLIFF:
|
|
40
|
-
// TODO:
|
|
41
|
-
return JSON.parse;
|
|
42
|
-
default:
|
|
43
|
-
return JSON.parse;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
function default_1(options) {
|
|
47
|
-
return (host) => {
|
|
48
|
-
const root = (0, transloco_1.getTranslationsRoot)(host, options);
|
|
49
|
-
const parser = parserFactory(options.format);
|
|
50
|
-
const translatedFiles = (0, transloco_1.getTranslationFiles)(host, options.source, parser);
|
|
51
|
-
const translationEntryPaths = (0, transloco_1.getTranslationEntryPaths)(host, root);
|
|
52
|
-
const newTranslation = {};
|
|
53
|
-
for (const { lang, translation } of translatedFiles) {
|
|
54
|
-
newTranslation[lang] = translationEntryPaths.reduce((acc, { scope, path }) => {
|
|
55
|
-
return reduceTranslations(host, path, translation, lang, scope);
|
|
56
|
-
}, translation);
|
|
57
|
-
}
|
|
58
|
-
host.getDir(root).subfiles.forEach((fileName) => {
|
|
59
|
-
const lang = fileName.split('.')[0];
|
|
60
|
-
(0, transloco_1.setFileContent)(host, root, fileName, newTranslation[lang]);
|
|
61
|
-
});
|
|
62
|
-
return host;
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
exports.default = default_1;
|
|
66
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../libs/transloco-schematics/src/split/index.ts"],"names":[],"mappings":";;AAEA,oCAAiD;AACjD,kDAQ4B;AAM5B,SAAS,kBAAkB,CACzB,IAAU,EACV,OAAe,EACf,eAAe,EACf,IAAY,EACZ,GAAG,GAAG,EAAE;IAER,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACjC,IAAI,CAAC,IAAA,oBAAQ,EAAC,GAAG,CAAC;QAAE,OAAO,eAAe,CAAC;IAE3C,IAAI,IAAA,sBAAU,EAAC,GAAG,CAAC,EAAE;QACnB,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,EAAE;YACjC,MAAM,MAAM,GAAG,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;YACnC,MAAM,aAAa,GAAG,IAAA,6BAAiB,EAAC,GAAG,EAAE,UAAU,CAAC,CAAC;YACzD,MAAM,SAAS,GAAG,aAAa,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;YAClD,MAAM,kBAAkB,GAAG,eAAe,CAAC,GAAG,CAAC,CAAC;YAChD,IAAI,kBAAkB,EAAE;gBACtB,kBAAkB,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,kBAAkB,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC;gBAC3E,OAAO,eAAe,CAAC,GAAG,CAAC,CAAC,SAAS,CAAC,CAAA;aACvC;QACH,CAAC,CAAC,CAAC;KACJ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KAAK,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,eAAe,EAAE;YACnD,cAAc,CAAC,IAAI,CAAC,GAAG,qBAAqB,CAAC,MAAM,CACjD,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE;gBACvB,OAAO,kBAAkB,CAAC,IAAI,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;YAClE,CAAC,EACD,WAAW,CACZ,CAAC;SACH;QAED,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE;YAC9C,MAAM,IAAI,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;YACpC,IAAA,0BAAc,EAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC;QAC7D,CAAC,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;AACJ,CAAC;AAzBD,4BAyBC"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { Schema } from '@schematics/angular/module/schema';
|
|
2
|
-
import { TranslationFileFormat } from '../types';
|
|
3
|
-
export interface SchemaOptions extends Schema {
|
|
4
|
-
/**
|
|
5
|
-
* The folder that contain the root translation files.
|
|
6
|
-
*/
|
|
7
|
-
translationPath: string;
|
|
8
|
-
/**
|
|
9
|
-
* The translated files format.
|
|
10
|
-
*/
|
|
11
|
-
format: TranslationFileFormat;
|
|
12
|
-
/**
|
|
13
|
-
* The source directory that contain the translated files.
|
|
14
|
-
*/
|
|
15
|
-
source: string;
|
|
16
|
-
/**
|
|
17
|
-
* The root project name.
|
|
18
|
-
*/
|
|
19
|
-
project: string;
|
|
20
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../../../../libs/transloco-schematics/src/split/schema.ts"],"names":[],"mappings":""}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "http://json-schema.org/schema",
|
|
3
|
-
"$id": "transloco-split",
|
|
4
|
-
"title": "Split translated files between the project's translation files.",
|
|
5
|
-
"type": "object",
|
|
6
|
-
"properties": {
|
|
7
|
-
"translationPath": {
|
|
8
|
-
"type": "string",
|
|
9
|
-
"description": "The folder that contain the root translation files.",
|
|
10
|
-
"default": "src/assets/i18n",
|
|
11
|
-
"alias": "root"
|
|
12
|
-
},
|
|
13
|
-
"source": {
|
|
14
|
-
"type": "string",
|
|
15
|
-
"description": "The path of the source directory that contain the translated files.",
|
|
16
|
-
"default": "dist-i18n",
|
|
17
|
-
"alias": "o"
|
|
18
|
-
},
|
|
19
|
-
"format": {
|
|
20
|
-
"description": "The translated files format.",
|
|
21
|
-
"type": "string",
|
|
22
|
-
"default": "JSON",
|
|
23
|
-
"enum": ["JSON", "xliff", "po"],
|
|
24
|
-
"alias": "f"
|
|
25
|
-
},
|
|
26
|
-
"project": {
|
|
27
|
-
"type": "string",
|
|
28
|
-
"description": "The root project name.",
|
|
29
|
-
"$default": {
|
|
30
|
-
"$source": "projectName"
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
},
|
|
34
|
-
"required": []
|
|
35
|
-
}
|
package/schematics/src/types.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TranslationFileFormat = void 0;
|
|
4
|
-
var TranslationFileFormat;
|
|
5
|
-
(function (TranslationFileFormat) {
|
|
6
|
-
TranslationFileFormat["JSON"] = "JSON";
|
|
7
|
-
TranslationFileFormat["XLIFF"] = "xliff";
|
|
8
|
-
TranslationFileFormat["PO"] = "po";
|
|
9
|
-
})(TranslationFileFormat || (exports.TranslationFileFormat = TranslationFileFormat = {}));
|
|
10
|
-
//# sourceMappingURL=types.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../libs/transloco-schematics/src/types.ts"],"names":[],"mappings":";;;AAAA,IAAY,qBAIX;AAJD,WAAY,qBAAqB;IAC/B,sCAAa,CAAA;IACb,wCAAe,CAAA;IACf,kCAAS,CAAA;AACX,CAAC,EAJW,qBAAqB,qCAArB,qBAAqB,QAIhC"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const process_1 = require("process");
|
|
4
|
-
const schematics_1 = require("@angular-devkit/schematics");
|
|
5
|
-
const v2_1 = require("./v2");
|
|
6
|
-
function default_1(options) {
|
|
7
|
-
return () => {
|
|
8
|
-
if (!options.path) {
|
|
9
|
-
throw new schematics_1.SchematicsException(`
|
|
10
|
-
Please specify the root source of your project.
|
|
11
|
-
(e.g. --path ./src/app)
|
|
12
|
-
`);
|
|
13
|
-
}
|
|
14
|
-
(0, v2_1.run)(options.path);
|
|
15
|
-
(0, process_1.exit)();
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
exports.default = default_1;
|
|
19
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../libs/transloco-schematics/src/upgrade/index.ts"],"names":[],"mappings":";;AAAA,qCAA+B;AAE/B,2DAAuE;AAGvE,6BAA2B;AAE3B,mBAAyB,OAAsB;IAC7C,OAAO,GAAG,EAAE;QACV,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE;YACjB,MAAM,IAAI,gCAAmB,CAAC;;;OAG7B,CAAC,CAAC;SACJ;QAED,IAAA,QAAG,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAClB,IAAA,cAAI,GAAE,CAAC;IACT,CAAC,CAAC;AACJ,CAAC;AAZD,4BAYC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../../../../libs/transloco-schematics/src/upgrade/schema.ts"],"names":[],"mappings":""}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "http://json-schema.org/schema",
|
|
3
|
-
"$id": "transloco-upgrade",
|
|
4
|
-
"title": "Run an upgrade script [Legacy and will be removed in v7]",
|
|
5
|
-
"type": "object",
|
|
6
|
-
"properties": {
|
|
7
|
-
"path": {
|
|
8
|
-
"description": "The entry path of the upgrade script.",
|
|
9
|
-
"x-prompt": "✍ Which folder should be the entry path for the script?",
|
|
10
|
-
"type": "string",
|
|
11
|
-
"default": "./src/app",
|
|
12
|
-
"alias": "p"
|
|
13
|
-
}
|
|
14
|
-
},
|
|
15
|
-
"required": []
|
|
16
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function run(path: any): void;
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.run = void 0;
|
|
4
|
-
const p = require("node:path");
|
|
5
|
-
const fs = require("node:fs");
|
|
6
|
-
const glob_1 = require("glob");
|
|
7
|
-
function run(path) {
|
|
8
|
-
console.log('\x1b[4m%s\x1b[0m', '⬆️ Starting v2 upgrade script ⬆️');
|
|
9
|
-
const dir = p.resolve(process.cwd());
|
|
10
|
-
path = p.join(dir, path, '/**/*');
|
|
11
|
-
const htmlFiles = (0, glob_1.sync)(`${path}.html`);
|
|
12
|
-
const templateRegex = /<ng-template[^>]*transloco[^>]*>[^]+?<\/ng-template>/g;
|
|
13
|
-
const structuralRegex = /<([a-zA-Z-]*)[^*>]*\*transloco=('|")\s*let\s+(?<varName>\w*)[^>]*\2>[^]+?<\/\1\s*>/g;
|
|
14
|
-
const coreKeyRegex = (varName) => `(?<rawKey>${varName}(?:(?:\\[('|").+\\1\\])|(?:\\.\\w+))+)(?<param>[\\s\\w|:{}'"$&!?%@#^)(]*)`;
|
|
15
|
-
const bindingKey = (varName) => new RegExp(`("|')\\s*${coreKeyRegex(varName)}\\1`, 'g');
|
|
16
|
-
const templateKey = (varName) => new RegExp(`{{\\s*${coreKeyRegex(varName)}}}`, 'g');
|
|
17
|
-
for (const file of htmlFiles) {
|
|
18
|
-
let str = fs.readFileSync(file).toString('utf8');
|
|
19
|
-
if (!str.includes('transloco'))
|
|
20
|
-
continue;
|
|
21
|
-
[structuralRegex, templateRegex].forEach((rgx, index) => {
|
|
22
|
-
let containerSearch = rgx.exec(str);
|
|
23
|
-
while (containerSearch) {
|
|
24
|
-
const [matchedStr] = containerSearch;
|
|
25
|
-
const { varName } = index === 0
|
|
26
|
-
? containerSearch.groups
|
|
27
|
-
: matchedStr.match(/let-(?<varName>\w*)/).groups;
|
|
28
|
-
let newStructuralStr = matchedStr;
|
|
29
|
-
let hasMatches;
|
|
30
|
-
[templateKey(varName), bindingKey(varName)].forEach((keyRegex) => {
|
|
31
|
-
let keySearch = keyRegex.exec(matchedStr);
|
|
32
|
-
hasMatches = hasMatches || !!keySearch;
|
|
33
|
-
while (keySearch) {
|
|
34
|
-
const { rawKey, param } = keySearch.groups;
|
|
35
|
-
/** The raw key may contain square braces we need to align it to '.' */
|
|
36
|
-
// eslint-disable-next-line prefer-const
|
|
37
|
-
let [key, ...inner] = rawKey
|
|
38
|
-
.trim()
|
|
39
|
-
.replace(/\[/g, '.')
|
|
40
|
-
.replace(/'|"|\]|\?/g, '')
|
|
41
|
-
.replace(`${varName}.`, '')
|
|
42
|
-
.split('.');
|
|
43
|
-
let callEnd = ')';
|
|
44
|
-
const pipes = (param && param.split('|')) || [];
|
|
45
|
-
const [paramsPipe] = pipes.filter((pipe) => pipe.includes('translocoParams'));
|
|
46
|
-
if (paramsPipe) {
|
|
47
|
-
const paramValue = paramsPipe.substring(paramsPipe.indexOf('{'), paramsPipe.lastIndexOf('}') + 1);
|
|
48
|
-
if (paramValue) {
|
|
49
|
-
callEnd = `, ${paramValue})`;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
if (inner.length) {
|
|
53
|
-
key = `${key}.${inner.join('.')}`;
|
|
54
|
-
}
|
|
55
|
-
newStructuralStr = paramsPipe
|
|
56
|
-
? newStructuralStr.replace(`${rawKey}${param}`, `${varName}('${key}'${callEnd} ${pipes
|
|
57
|
-
.filter((pipe) => !pipe.includes('translocoParams'))
|
|
58
|
-
.join('|')}`)
|
|
59
|
-
: newStructuralStr.replace(rawKey, `${varName}('${key}'${callEnd}`);
|
|
60
|
-
keySearch = keyRegex.exec(matchedStr);
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
if (hasMatches) {
|
|
64
|
-
str = str.replace(matchedStr, newStructuralStr);
|
|
65
|
-
}
|
|
66
|
-
containerSearch = rgx.exec(str);
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
fs.writeFileSync(file, str, { encoding: 'utf8' });
|
|
70
|
-
}
|
|
71
|
-
const modules = (0, glob_1.sync)(`${path}.module.ts`);
|
|
72
|
-
for (const file of modules) {
|
|
73
|
-
let str = fs.readFileSync(file).toString('utf8');
|
|
74
|
-
if (!str.includes('@jsverse/transloco'))
|
|
75
|
-
continue;
|
|
76
|
-
/** change listenToLangChange to renderOnce */
|
|
77
|
-
str = str.replace('listenToLangChange', 'reRenderOnLangChange');
|
|
78
|
-
/** Remove scopeStrategy */
|
|
79
|
-
str = str.replace(/\s*scopeStrategy:.*?,/, '');
|
|
80
|
-
/** Add availableLangs */
|
|
81
|
-
if (!str.includes('availableLangs')) {
|
|
82
|
-
str = str.replace(/((\s*)defaultLang:(.*?),)/, (str, g1, g2, g3) => `${g1}${g2}availableLangs: [${g3.trim()}],`);
|
|
83
|
-
}
|
|
84
|
-
fs.writeFileSync(file, str, { encoding: 'utf8' });
|
|
85
|
-
}
|
|
86
|
-
console.log(`Done! Welcome to Transloco v2 😎`);
|
|
87
|
-
}
|
|
88
|
-
exports.run = run;
|
|
89
|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AE,MAAM,EAAE,CAAC,CAAC;KACnD;IACD,MAAM,OAAO,GAAG,IAAA,WAAQ,EAAC,GAAG,IAAI,YAAY,CAAC,CAAC;IAC9C,KAAK,MAAM,IAAI,IAAI,OAAO,EAAE;QAC1B,IAAI,GAAG,GAAG,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QACjD,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,oBAAoB,CAAC;YAAE,SAAS;QAClD,8CAA8C;QAC9C,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,oBAAoB,EAAE,sBAAsB,CAAC,CAAC;QAChE,2BAA2B;QAC3B,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,uBAAuB,EAAE,EAAE,CAAC,CAAC;QAC/C,yBAAyB;QACzB,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,gBAAgB,CAAC,EAAE;YACnC,GAAG,GAAG,GAAG,CAAC,OAAO,CACf,2BAA2B,EAC3B,CAAC,GAAG,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,oBAAoB,EAAE,CAAC,IAAI,EAAE,IAAI,CACjE,CAAC;SACH;QACD,EAAE,CAAC,aAAa,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC;KACnD;IACD,OAAO,CAAC,GAAG,CAAC,kCAAkC,CAAC,CAAC;AAClD,CAAC;AAjGD,kBAiGC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.coerceArray = exports.stringifyList = void 0;
|
|
4
|
-
function stringifyList(list, separator = ', ') {
|
|
5
|
-
return list.map((item) => `'${item}'`).join(separator);
|
|
6
|
-
}
|
|
7
|
-
exports.stringifyList = stringifyList;
|
|
8
|
-
function coerceArray(value) {
|
|
9
|
-
return Array.isArray(value) ? value : [value];
|
|
10
|
-
}
|
|
11
|
-
exports.coerceArray = coerceArray;
|
|
12
|
-
//# sourceMappingURL=array.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"array.js","sourceRoot":"","sources":["../../../../../../libs/transloco-schematics/src/utils/array.ts"],"names":[],"mappings":";;;AAAA,SAAgB,aAAa,CAAI,IAAS,EAAE,SAAS,GAAG,IAAI;IAC1D,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;AACzD,CAAC;AAFD,sCAEC;AAID,SAAgB,WAAW,CAAI,KAAc;IAC3C,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;AAChD,CAAC;AAFD,kCAEC"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getConfig = void 0;
|
|
4
|
-
const transloco_utils_1 = require("@jsverse/transloco-utils");
|
|
5
|
-
let config;
|
|
6
|
-
function getConfig() {
|
|
7
|
-
if (config)
|
|
8
|
-
return config;
|
|
9
|
-
config = (0, transloco_utils_1.getGlobalConfig)();
|
|
10
|
-
return config;
|
|
11
|
-
}
|
|
12
|
-
exports.getConfig = getConfig;
|
|
13
|
-
//# sourceMappingURL=config.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../../../../libs/transloco-schematics/src/utils/config.ts"],"names":[],"mappings":";;;AAAA,8DAGkC;AAElC,IAAI,MAA6B,CAAC;AAElC,SAAgB,SAAS;IACvB,IAAI,MAAM;QAAE,OAAO,MAAM,CAAC;IAC1B,MAAM,GAAG,IAAA,iCAAe,GAAE,CAAC;IAE3B,OAAO,MAAM,CAAC;AAChB,CAAC;AALD,8BAKC"}
|