@jsverse/transloco 7.6.1 → 8.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (207) hide show
  1. package/CHANGELOG.md +48 -3
  2. package/README.md +2 -0
  3. package/esm2022/index.mjs +4 -5
  4. package/esm2022/lib/get-fallbacks-loaders.mjs +1 -1
  5. package/esm2022/lib/lang-resolver.mjs +3 -2
  6. package/esm2022/lib/resolve-loader.mjs +2 -2
  7. package/esm2022/lib/scope-resolver.mjs +3 -2
  8. package/esm2022/lib/template-handler.mjs +2 -2
  9. package/esm2022/lib/transloco-missing-handler.mjs +1 -1
  10. package/esm2022/lib/transloco-scope.mjs +1 -1
  11. package/esm2022/lib/transloco-testing.module.mjs +1 -1
  12. package/esm2022/lib/transloco.config.mjs +1 -1
  13. package/esm2022/lib/transloco.directive.mjs +4 -3
  14. package/esm2022/lib/transloco.interceptor.mjs +1 -1
  15. package/esm2022/lib/transloco.loader.mjs +1 -1
  16. package/esm2022/lib/transloco.pipe.mjs +4 -3
  17. package/esm2022/lib/transloco.providers.mjs +1 -1
  18. package/esm2022/lib/transloco.service.mjs +4 -3
  19. package/esm2022/lib/transloco.signal.mjs +1 -1
  20. package/esm2022/lib/transloco.transpiler.mjs +3 -2
  21. package/esm2022/lib/transloco.types.mjs +2 -0
  22. package/esm2022/lib/utils/browser.utils.mjs +30 -0
  23. package/esm2022/lib/utils/flat.utils.mjs +37 -0
  24. package/esm2022/lib/utils/lang.utils.mjs +15 -0
  25. package/esm2022/lib/utils/object.utils.mjs +28 -0
  26. package/esm2022/lib/utils/pipe.utils.mjs +17 -0
  27. package/esm2022/lib/utils/scope.utils.mjs +51 -0
  28. package/esm2022/lib/utils/type.utils.mjs +2 -0
  29. package/fesm2022/jsverse-transloco.mjs +156 -209
  30. package/fesm2022/jsverse-transloco.mjs.map +1 -1
  31. package/index.d.ts +3 -4
  32. package/lib/get-fallbacks-loaders.d.ts +1 -1
  33. package/lib/resolve-loader.d.ts +2 -2
  34. package/lib/scope-resolver.d.ts +2 -1
  35. package/lib/transloco-missing-handler.d.ts +1 -1
  36. package/lib/transloco-scope.d.ts +1 -1
  37. package/lib/transloco-testing.module.d.ts +2 -1
  38. package/lib/transloco.config.d.ts +1 -1
  39. package/lib/transloco.directive.d.ts +2 -2
  40. package/lib/transloco.interceptor.d.ts +1 -1
  41. package/lib/transloco.loader.d.ts +1 -1
  42. package/lib/transloco.pipe.d.ts +3 -1
  43. package/lib/transloco.providers.d.ts +1 -1
  44. package/lib/transloco.service.d.ts +2 -1
  45. package/lib/transloco.signal.d.ts +2 -1
  46. package/lib/transloco.transpiler.d.ts +2 -1
  47. package/lib/{types.d.ts → transloco.types.d.ts} +1 -2
  48. package/lib/{browser-lang.d.ts → utils/browser.utils.d.ts} +1 -0
  49. package/lib/utils/flat.utils.d.ts +3 -0
  50. package/lib/utils/lang.utils.d.ts +4 -0
  51. package/lib/utils/object.utils.d.ts +2 -0
  52. package/lib/utils/pipe.utils.d.ts +8 -0
  53. package/lib/utils/scope.utils.d.ts +7 -0
  54. package/lib/utils/type.utils.d.ts +1 -0
  55. package/package.json +14 -17
  56. package/schematics/collection.json +12 -0
  57. package/schematics/ng-add/generators/http-loader.gen.d.ts +5 -0
  58. package/schematics/{src/ng-add → ng-add}/generators/http-loader.gen.js +1 -0
  59. package/schematics/ng-add/generators/http-loader.gen.js.map +1 -0
  60. package/schematics/{src/ng-add → ng-add}/generators/root-module.gen.js +3 -3
  61. package/schematics/ng-add/generators/root-module.gen.js.map +1 -0
  62. package/schematics/{src/ng-migrate → ng-add}/index.d.ts +1 -1
  63. package/schematics/{src/ng-add → ng-add}/index.js +29 -19
  64. package/schematics/ng-add/index.js.map +1 -0
  65. package/schematics/ng-add/ng-add.spec.d.ts +1 -0
  66. package/schematics/ng-add/ng-add.spec.js +45 -0
  67. package/schematics/ng-add/ng-add.spec.js.map +1 -0
  68. package/schematics/{src/ng-add → ng-add}/schema.d.ts +0 -8
  69. package/schematics/ng-add/schema.js +9 -0
  70. package/schematics/ng-add/schema.js.map +1 -0
  71. package/schematics/{src/ng-add → ng-add}/schema.json +1 -1
  72. package/schematics-core/index.d.ts +9 -0
  73. package/schematics-core/index.js +36 -0
  74. package/schematics-core/index.js.map +1 -0
  75. package/schematics-core/testing/create-workspace.d.ts +11 -0
  76. package/schematics-core/testing/create-workspace.js +34 -0
  77. package/schematics-core/testing/create-workspace.js.map +1 -0
  78. package/schematics-core/testing/index.d.ts +2 -0
  79. package/schematics-core/testing/index.js +19 -0
  80. package/schematics-core/testing/index.js.map +1 -0
  81. package/schematics-core/testing/mocks.d.ts +14 -0
  82. package/schematics-core/testing/mocks.js +10 -0
  83. package/schematics-core/testing/mocks.js.map +1 -0
  84. package/{schematics/src/utils/array.js → schematics-core/utils/collections.js} +1 -1
  85. package/schematics-core/utils/collections.js.map +1 -0
  86. package/schematics-core/utils/file.d.ts +6 -0
  87. package/schematics-core/utils/file.js +21 -0
  88. package/schematics-core/utils/file.js.map +1 -0
  89. package/{schematics/src → schematics-core}/utils/find-module.js +2 -0
  90. package/schematics-core/utils/find-module.js.map +1 -0
  91. package/{schematics/src → schematics-core}/utils/package.d.ts +0 -3
  92. package/{schematics/src → schematics-core}/utils/package.js +2 -4
  93. package/schematics-core/utils/package.js.map +1 -0
  94. package/schematics-core/utils/schematic.d.ts +6 -0
  95. package/{schematics/src/schematics.utils.js → schematics-core/utils/schematic.js} +6 -6
  96. package/schematics-core/utils/schematic.js.map +1 -0
  97. package/schematics-core/utils/translation.d.ts +20 -0
  98. package/schematics-core/utils/translation.js +83 -0
  99. package/schematics-core/utils/translation.js.map +1 -0
  100. package/schematics-core/utils/transloco.d.ts +5 -0
  101. package/schematics-core/utils/transloco.js +31 -0
  102. package/schematics-core/utils/transloco.js.map +1 -0
  103. package/schematics-core/utils/workspace.d.ts +6 -0
  104. package/{schematics/src/utils/projects.js → schematics-core/utils/workspace.js} +1 -13
  105. package/schematics-core/utils/workspace.js.map +1 -0
  106. package/esm2022/lib/browser-lang.mjs +0 -28
  107. package/esm2022/lib/helpers.mjs +0 -129
  108. package/esm2022/lib/shared.mjs +0 -73
  109. package/esm2022/lib/types.mjs +0 -2
  110. package/lib/helpers.d.ts +0 -20
  111. package/lib/shared.d.ts +0 -17
  112. package/schematics/src/assets/i18n/en.json +0 -1
  113. package/schematics/src/collection.json +0 -59
  114. package/schematics/src/component/index.d.ts +0 -2
  115. package/schematics/src/component/index.js +0 -21
  116. package/schematics/src/component/index.js.map +0 -1
  117. package/schematics/src/join/index.d.ts +0 -3
  118. package/schematics/src/join/index.js +0 -79
  119. package/schematics/src/join/index.js.map +0 -1
  120. package/schematics/src/join/schema.d.ts +0 -28
  121. package/schematics/src/join/schema.js +0 -3
  122. package/schematics/src/join/schema.js.map +0 -1
  123. package/schematics/src/join/schema.json +0 -43
  124. package/schematics/src/keys-manager/index.d.ts +0 -5
  125. package/schematics/src/keys-manager/index.js +0 -96
  126. package/schematics/src/keys-manager/index.js.map +0 -1
  127. package/schematics/src/keys-manager/schema.d.ts +0 -19
  128. package/schematics/src/keys-manager/schema.js +0 -3
  129. package/schematics/src/keys-manager/schema.js.map +0 -1
  130. package/schematics/src/keys-manager/schema.json +0 -33
  131. package/schematics/src/migrate/index.d.ts +0 -3
  132. package/schematics/src/migrate/index.js +0 -21
  133. package/schematics/src/migrate/index.js.map +0 -1
  134. package/schematics/src/migrate/ngx-translate-migration.d.ts +0 -3
  135. package/schematics/src/migrate/ngx-translate-migration.js +0 -175
  136. package/schematics/src/migrate/ngx-translate-migration.js.map +0 -1
  137. package/schematics/src/migrate/schema.d.ts +0 -10
  138. package/schematics/src/migrate/schema.js +0 -3
  139. package/schematics/src/migrate/schema.js.map +0 -1
  140. package/schematics/src/migrate/schema.json +0 -23
  141. package/schematics/src/ng-add/generators/http-loader.gen.d.ts +0 -4
  142. package/schematics/src/ng-add/generators/http-loader.gen.js.map +0 -1
  143. package/schematics/src/ng-add/generators/root-module.gen.js.map +0 -1
  144. package/schematics/src/ng-add/generators/translation-files.gen.d.ts +0 -4
  145. package/schematics/src/ng-add/generators/translation-files.gen.js +0 -22
  146. package/schematics/src/ng-add/generators/translation-files.gen.js.map +0 -1
  147. package/schematics/src/ng-add/index.d.ts +0 -3
  148. package/schematics/src/ng-add/index.js.map +0 -1
  149. package/schematics/src/ng-add/schema.js +0 -14
  150. package/schematics/src/ng-add/schema.js.map +0 -1
  151. package/schematics/src/ng-migrate/index.js +0 -14
  152. package/schematics/src/ng-migrate/index.js.map +0 -1
  153. package/schematics/src/ng-migrate/ng-migrate.d.ts +0 -5
  154. package/schematics/src/ng-migrate/ng-migrate.js +0 -105
  155. package/schematics/src/ng-migrate/ng-migrate.js.map +0 -1
  156. package/schematics/src/ng-migrate/schema.d.ts +0 -14
  157. package/schematics/src/ng-migrate/schema.js +0 -3
  158. package/schematics/src/ng-migrate/schema.js.map +0 -1
  159. package/schematics/src/ng-migrate/schema.json +0 -27
  160. package/schematics/src/schematics.utils.d.ts +0 -6
  161. package/schematics/src/schematics.utils.js.map +0 -1
  162. package/schematics/src/scope/index.d.ts +0 -3
  163. package/schematics/src/scope/index.js +0 -101
  164. package/schematics/src/scope/index.js.map +0 -1
  165. package/schematics/src/scope/schema.d.ts +0 -28
  166. package/schematics/src/scope/schema.js +0 -3
  167. package/schematics/src/scope/schema.js.map +0 -1
  168. package/schematics/src/scope/schema.json +0 -84
  169. package/schematics/src/split/index.d.ts +0 -3
  170. package/schematics/src/split/index.js +0 -66
  171. package/schematics/src/split/index.js.map +0 -1
  172. package/schematics/src/split/schema.d.ts +0 -20
  173. package/schematics/src/split/schema.js +0 -3
  174. package/schematics/src/split/schema.js.map +0 -1
  175. package/schematics/src/split/schema.json +0 -35
  176. package/schematics/src/types.d.ts +0 -5
  177. package/schematics/src/types.js +0 -10
  178. package/schematics/src/types.js.map +0 -1
  179. package/schematics/src/upgrade/index.d.ts +0 -3
  180. package/schematics/src/upgrade/index.js +0 -19
  181. package/schematics/src/upgrade/index.js.map +0 -1
  182. package/schematics/src/upgrade/schema.d.ts +0 -6
  183. package/schematics/src/upgrade/schema.js +0 -3
  184. package/schematics/src/upgrade/schema.js.map +0 -1
  185. package/schematics/src/upgrade/schema.json +0 -16
  186. package/schematics/src/upgrade/v2.d.ts +0 -1
  187. package/schematics/src/upgrade/v2.js +0 -88
  188. package/schematics/src/upgrade/v2.js.map +0 -1
  189. package/schematics/src/utils/array.js.map +0 -1
  190. package/schematics/src/utils/config.d.ts +0 -2
  191. package/schematics/src/utils/config.js +0 -12
  192. package/schematics/src/utils/config.js.map +0 -1
  193. package/schematics/src/utils/find-module.js.map +0 -1
  194. package/schematics/src/utils/package.js.map +0 -1
  195. package/schematics/src/utils/projects.d.ts +0 -8
  196. package/schematics/src/utils/projects.js.map +0 -1
  197. package/schematics/src/utils/translations.d.ts +0 -7
  198. package/schematics/src/utils/translations.js +0 -30
  199. package/schematics/src/utils/translations.js.map +0 -1
  200. package/schematics/src/utils/transloco.d.ts +0 -24
  201. package/schematics/src/utils/transloco.js +0 -88
  202. package/schematics/src/utils/transloco.js.map +0 -1
  203. /package/schematics/{src/ng-add → ng-add}/files/transloco-loader/transloco-loader.__ts__ +0 -0
  204. /package/schematics/{src/ng-add → ng-add}/files/transloco-module/transloco-root.module.__ts__ +0 -0
  205. /package/schematics/{src/ng-add → ng-add}/generators/root-module.gen.d.ts +0 -0
  206. /package/{schematics/src/utils/array.d.ts → schematics-core/utils/collections.d.ts} +0 -0
  207. /package/{schematics/src → schematics-core}/utils/find-module.d.ts +0 -0
@@ -1,5 +1,5 @@
1
1
  import { TranslocoLoader, TranslocoLoaderData } from './transloco.loader';
2
- import { InlineLoader } from './types';
2
+ import { InlineLoader } from './transloco.types';
3
3
  interface Options {
4
4
  path: string;
5
5
  fallbackPath?: string;
@@ -1,10 +1,10 @@
1
1
  import { TranslocoLoader, TranslocoLoaderData } from './transloco.loader';
2
- import { InlineLoader } from './types';
2
+ import { InlineLoader } from './transloco.types';
3
3
  interface Options {
4
4
  inlineLoader?: InlineLoader;
5
5
  path: string;
6
6
  mainLoader: TranslocoLoader;
7
7
  data?: TranslocoLoaderData;
8
8
  }
9
- export declare function resolveLoader(options: Options): import("rxjs").Observable<import("./types").Translation> | Promise<any>;
9
+ export declare function resolveLoader(options: Options): Promise<any> | import("rxjs").Observable<import("./transloco.types").Translation>;
10
10
  export {};
@@ -1,4 +1,5 @@
1
- import { TranslocoScope, OrArray } from './types';
1
+ import { OrArray } from '@jsverse/utils';
2
+ import { TranslocoScope } from './transloco.types';
2
3
  import { TranslocoService } from './transloco.service';
3
4
  type ScopeResolverParams = {
4
5
  inline: string | undefined;
@@ -1,6 +1,6 @@
1
1
  import { InjectionToken } from '@angular/core';
2
2
  import { TranslocoConfig } from './transloco.config';
3
- import { HashMap } from './types';
3
+ import { HashMap } from './utils/type.utils';
4
4
  import * as i0 from "@angular/core";
5
5
  export declare const TRANSLOCO_MISSING_HANDLER: InjectionToken<TranslocoMissingHandlerData>;
6
6
  export interface TranslocoMissingHandlerData extends TranslocoConfig {
@@ -1,3 +1,3 @@
1
1
  import { InjectionToken } from '@angular/core';
2
- import { TranslocoScope } from './types';
2
+ import { TranslocoScope } from './transloco.types';
3
3
  export declare const TRANSLOCO_SCOPE: InjectionToken<TranslocoScope>;
@@ -1,9 +1,10 @@
1
1
  import { ModuleWithProviders } from '@angular/core';
2
2
  import { Observable } from 'rxjs';
3
3
  import { TranslocoLoader } from './transloco.loader';
4
- import { HashMap, Translation } from './types';
4
+ import { Translation } from './transloco.types';
5
5
  import { TranslocoConfig } from './transloco.config';
6
6
  import { TranslocoService } from './transloco.service';
7
+ import { HashMap } from './utils/type.utils';
7
8
  import * as i0 from "@angular/core";
8
9
  import * as i1 from "./transloco.module";
9
10
  export interface TranslocoTestingOptions {
@@ -1,5 +1,5 @@
1
1
  import { InjectionToken } from '@angular/core';
2
- import { AvailableLangs } from './types';
2
+ import { AvailableLangs } from './transloco.types';
3
3
  export interface TranslocoConfig {
4
4
  defaultLang: string;
5
5
  reRenderOnLangChange: boolean;
@@ -1,6 +1,6 @@
1
1
  import { EmbeddedViewRef, OnChanges, OnDestroy, OnInit, SimpleChanges } from '@angular/core';
2
2
  import { Content } from './template-handler';
3
- import { HashMap } from './types';
3
+ import { HashMap } from './utils/type.utils';
4
4
  import * as i0 from "@angular/core";
5
5
  type TranslateFn = (key: string, params?: HashMap) => any;
6
6
  interface ViewContext {
@@ -23,7 +23,7 @@ export declare class TranslocoDirective implements OnInit, OnDestroy, OnChanges
23
23
  key: string | undefined;
24
24
  params: HashMap;
25
25
  inlineScope: string | undefined;
26
- /** @deprecated use prefix instead, will be removed in Transloco v8 */
26
+ /** @deprecated use prefix instead, will be removed in Transloco v9 */
27
27
  inlineRead: string | undefined;
28
28
  prefix: string | undefined;
29
29
  inlineLang: string | undefined;
@@ -1,5 +1,5 @@
1
1
  import { InjectionToken } from '@angular/core';
2
- import { Translation } from './types';
2
+ import { Translation } from './transloco.types';
3
3
  import * as i0 from "@angular/core";
4
4
  export declare const TRANSLOCO_INTERCEPTOR: InjectionToken<TranslocoInterceptor>;
5
5
  export interface TranslocoInterceptor {
@@ -1,6 +1,6 @@
1
1
  import { InjectionToken } from '@angular/core';
2
2
  import { Observable } from 'rxjs';
3
- import { Translation } from './types';
3
+ import { Translation } from './transloco.types';
4
4
  export interface TranslocoLoader {
5
5
  getTranslation(lang: string, data?: TranslocoLoaderData): Observable<Translation> | Promise<Translation>;
6
6
  }
@@ -1,6 +1,8 @@
1
1
  import { ChangeDetectorRef, OnDestroy, PipeTransform } from '@angular/core';
2
+ import { OrArray } from '@jsverse/utils';
2
3
  import { TranslocoService } from './transloco.service';
3
- import { HashMap, OrArray, TranslocoScope } from './types';
4
+ import { TranslocoScope } from './transloco.types';
5
+ import { HashMap } from './utils/type.utils';
4
6
  import * as i0 from "@angular/core";
5
7
  export declare class TranslocoPipe implements PipeTransform, OnDestroy {
6
8
  private service;
@@ -1,7 +1,7 @@
1
1
  import { EnvironmentProviders, Provider, Type } from '@angular/core';
2
2
  import { TranslocoLoader } from './transloco.loader';
3
3
  import { PartialTranslocoConfig } from './transloco.config';
4
- import { TranslocoScope } from './types';
4
+ import { TranslocoScope } from './transloco.types';
5
5
  import { TranslocoTranspiler } from './transloco.transpiler';
6
6
  import { TranslocoMissingHandler } from './transloco-missing-handler';
7
7
  import { TranslocoInterceptor } from './transloco.interceptor';
@@ -1,11 +1,12 @@
1
1
  import { Observable } from 'rxjs';
2
2
  import { TranslocoLoader } from './transloco.loader';
3
3
  import { TranslocoTranspiler } from './transloco.transpiler';
4
- import { AvailableLangs, HashMap, InlineLoader, LoadOptions, SetTranslationOptions, TranslateParams, Translation, TranslocoEvents, TranslocoScope } from './types';
4
+ import { AvailableLangs, InlineLoader, LoadOptions, SetTranslationOptions, TranslateParams, Translation, TranslocoEvents, TranslocoScope } from './transloco.types';
5
5
  import { TranslocoConfig } from './transloco.config';
6
6
  import { TranslocoMissingHandler } from './transloco-missing-handler';
7
7
  import { TranslocoInterceptor } from './transloco.interceptor';
8
8
  import { TranslocoFallbackStrategy } from './transloco-fallback-strategy';
9
+ import { HashMap } from './utils/type.utils';
9
10
  import * as i0 from "@angular/core";
10
11
  export declare function translate<T = string>(key: TranslateParams, params?: HashMap, lang?: string): T;
11
12
  export declare function translateObject<T>(key: TranslateParams, params?: HashMap, lang?: string): T | T[];
@@ -1,5 +1,6 @@
1
1
  import { Injector, Signal } from '@angular/core';
2
- import { HashMap, Translation, TranslocoScope } from './types';
2
+ import { Translation, TranslocoScope } from './transloco.types';
3
+ import { HashMap } from './utils/type.utils';
3
4
  type ScopeType = string | TranslocoScope | TranslocoScope[];
4
5
  type SignalKey = Signal<string> | Signal<string[]> | Signal<string>[];
5
6
  type TranslateSignalKey = string | string[] | SignalKey;
@@ -1,6 +1,7 @@
1
1
  import { InjectionToken, Injector } from '@angular/core';
2
- import { HashMap, Translation } from './types';
2
+ import { Translation } from './transloco.types';
3
3
  import { TranslocoConfig } from './transloco.config';
4
+ import { HashMap } from './utils/type.utils';
4
5
  import * as i0 from "@angular/core";
5
6
  export declare const TRANSLOCO_TRANSPILER: InjectionToken<TranslocoTranspiler>;
6
7
  export interface TranslocoTranspiler {
@@ -1,4 +1,4 @@
1
- export type HashMap<T = any> = Record<string, T>;
1
+ import { HashMap } from './utils/type.utils';
2
2
  export interface LoadedEvent {
3
3
  type: 'translationLoadSuccess';
4
4
  wasFailure: boolean;
@@ -34,7 +34,6 @@ export interface ProviderScope {
34
34
  loader?: InlineLoader;
35
35
  alias?: string;
36
36
  }
37
- export type OrArray<T> = T | T[];
38
37
  export type TranslocoScope = ProviderScope | string | undefined;
39
38
  export type InlineLoader = HashMap<() => Promise<Translation>>;
40
39
  export interface LoadOptions {
@@ -1,3 +1,4 @@
1
+ export declare function isBrowser(): boolean;
1
2
  /**
2
3
  * Returns the language code name from the browser, e.g. "en"
3
4
  */
@@ -0,0 +1,3 @@
1
+ import { Translation } from '../transloco.types';
2
+ export declare function flatten(obj: Translation): Translation;
3
+ export declare function unflatten(obj: Translation): Translation;
@@ -0,0 +1,4 @@
1
+ import { OperatorFunction } from 'rxjs';
2
+ import { TranslocoService } from '../transloco.service';
3
+ export declare function shouldListenToLangChanges(service: TranslocoService, lang?: string): boolean;
4
+ export declare function listenOrNotOperator<T>(listenToLangChange?: boolean): OperatorFunction<T, T>;
@@ -0,0 +1,2 @@
1
+ export declare function getValue<T>(obj: T, path: keyof T): any;
2
+ export declare function setValue(obj: any, prop: string, val: any): any;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @example
3
+ *
4
+ * getPipeValue('todos|scoped', 'scoped') [true, 'todos']
5
+ * getPipeValue('en|static', 'static') [true, 'en']
6
+ * getPipeValue('en', 'static') [false, 'en']
7
+ */
8
+ export declare function getPipeValue(str: string | undefined, value: string, char?: string): [boolean, string];
@@ -0,0 +1,7 @@
1
+ import { InlineLoader, LoadedEvent, ProviderScope, TranslocoScope } from '../transloco.types';
2
+ export declare function getScopeFromLang(lang: string): string;
3
+ export declare function getLangFromScope(lang: string): string;
4
+ export declare function isScopeObject(item: any): item is ProviderScope;
5
+ export declare function hasInlineLoader(item: any): item is ProviderScope;
6
+ export declare function resolveInlineLoader(providerScope: TranslocoScope | null, scope?: string): InlineLoader | undefined;
7
+ export declare function getEventPayload(lang: string): LoadedEvent['payload'];
@@ -0,0 +1 @@
1
+ export type HashMap<T = any> = Record<string, T>;
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@jsverse/transloco",
3
- "version": "7.6.1",
3
+ "version": "8.0.1",
4
4
  "description": "The internationalization (i18n) library for Angular",
5
- "schematics": "./schematics/src/collection.json",
5
+ "schematics": "./schematics/collection.json",
6
6
  "publishConfig": {
7
7
  "access": "public"
8
8
  },
@@ -15,27 +15,25 @@
15
15
  "url": "https://github.com/jsverse/transloco"
16
16
  },
17
17
  "keywords": [
18
- "angular",
19
- "angular 2",
18
+ "Angular",
20
19
  "i18n",
21
- "translate",
22
- "angular translate",
23
- "angular i18n",
24
- "transloco"
20
+ "Translate",
21
+ "Angular Translate",
22
+ "Transloco",
23
+ "Schematics",
24
+ "Angular CLI"
25
25
  ],
26
26
  "license": "MIT",
27
27
  "peerDependencies": {
28
- "@angular/core": ">=16.0.0"
28
+ "@angular/core": ">=16.0.0",
29
+ "rxjs": ">=6.0.0"
29
30
  },
30
31
  "dependencies": {
31
- "fs-extra": "^11.0.0",
32
- "glob": "^10.0.0",
33
32
  "tslib": "^2.2.0",
34
- "@jsverse/transloco-utils": "^7.0.0",
35
- "replace-in-file": "^7.0.1",
36
- "ora": "^5.4.1",
37
- "lodash.kebabcase": "^4.1.1"
33
+ "@jsverse/utils": "1.0.0-beta.5",
34
+ "@jsverse/transloco-utils": "^8.0.1"
38
35
  },
36
+ "sideEffects": false,
39
37
  "module": "fesm2022/jsverse-transloco.mjs",
40
38
  "typings": "index.d.ts",
41
39
  "exports": {
@@ -48,6 +46,5 @@
48
46
  "esm": "./esm2022/jsverse-transloco.mjs",
49
47
  "default": "./fesm2022/jsverse-transloco.mjs"
50
48
  }
51
- },
52
- "sideEffects": false
49
+ }
53
50
  }
@@ -0,0 +1,12 @@
1
+ {
2
+ "extends": ["@schematics/angular"],
3
+ "$schema": "../../../node_modules/@angular-devkit/schematics/collection-schema.json",
4
+ "schematics": {
5
+ "ng-add": {
6
+ "save": "dependencies",
7
+ "factory": "./ng-add/index#ngAdd",
8
+ "schema": "./ng-add/schema.json",
9
+ "description": "Add Transloco to your project."
10
+ }
11
+ }
12
+ }
@@ -0,0 +1,5 @@
1
+ export interface CreateLoaderFileParams {
2
+ ssr: boolean;
3
+ loaderPath: string;
4
+ }
5
+ export declare function createLoaderFile({ ssr, loaderPath }: CreateLoaderFileParams): import("@angular-devkit/schematics").Source;
@@ -5,6 +5,7 @@ const schematics_1 = require("@angular-devkit/schematics");
5
5
  function createLoaderFile({ ssr, loaderPath }) {
6
6
  return (0, schematics_1.apply)((0, schematics_1.url)(`./files/transloco-loader`), [
7
7
  (0, schematics_1.template)({
8
+ // Replace the __ts__ with ts
8
9
  ts: 'ts',
9
10
  loaderPrefix: ssr ? '${environment.baseUrl}' : '',
10
11
  }),
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-loader.gen.js","sourceRoot":"","sources":["../../../../../../libs/transloco/schematics/ng-add/generators/http-loader.gen.ts"],"names":[],"mappings":";;AAOA,4CASC;AAhBD,2DAAwE;AAOxE,SAAgB,gBAAgB,CAAC,EAAE,GAAG,EAAE,UAAU,EAA0B;IAC1E,OAAO,IAAA,kBAAK,EAAC,IAAA,gBAAG,EAAC,0BAA0B,CAAC,EAAE;QAC5C,IAAA,qBAAQ,EAAC;YACP,6BAA6B;YAC7B,EAAE,EAAE,IAAI;YACR,YAAY,EAAE,GAAG,CAAC,CAAC,CAAC,wBAAwB,CAAC,CAAC,CAAC,EAAE;SAClD,CAAC;QACF,IAAA,iBAAI,EAAC,GAAG,EAAE,UAAU,CAAC;KACtB,CAAC,CAAC;AACL,CAAC"}
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createTranslocoModule = createTranslocoModule;
4
4
  const path = require("node:path");
5
5
  const schematics_1 = require("@angular-devkit/schematics");
6
- const array_1 = require("../../utils/array");
6
+ const schematics_core_1 = require("../../../schematics-core");
7
7
  function createTranslocoModule({ isLib, ssr, langs, modulePath, sourceRoot, host, }) {
8
8
  const envPath = path
9
9
  .relative(modulePath, `${sourceRoot}/environments/environment`)
@@ -16,9 +16,9 @@ function createTranslocoModule({ isLib, ssr, langs, modulePath, sourceRoot, host
16
16
  }
17
17
  return (0, schematics_1.apply)((0, schematics_1.url)(`./files/transloco-module`), [
18
18
  (0, schematics_1.template)({
19
+ // Replace the __ts__ with ts
19
20
  ts: 'ts',
20
- stringifyList: array_1.stringifyList,
21
- isLib,
21
+ stringifyList: schematics_core_1.stringifyList,
22
22
  langs,
23
23
  importEnv: ssr || envFileExists,
24
24
  envPath,
@@ -0,0 +1 @@
1
+ {"version":3,"file":"root-module.gen.js","sourceRoot":"","sources":["../../../../../../libs/transloco/schematics/ng-add/generators/root-module.gen.ts"],"names":[],"mappings":";;AAaA,sDAwCC;AArDD,kCAAkC;AAElC,2DAOoC;AAEpC,8DAAyD;AAEzD,SAAgB,qBAAqB,CAAC,EACpC,KAAK,EACL,GAAG,EACH,KAAK,EACL,UAAU,EACV,UAAU,EACV,IAAI,GAQL;IACC,MAAM,OAAO,GAAG,IAAI;SACjB,QAAQ,CAAC,UAAU,EAAE,GAAG,UAAU,2BAA2B,CAAC;SAC9D,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC;SACf,IAAI,CAAC,GAAG,CAAC,CAAC;IACb,MAAM,aAAa,GAAG,IAAI,CAAC,MAAM,CAC/B,GAAG,UAAU,8BAA8B,CAC5C,CAAC;IACF,IAAI,QAAQ,GAAG,aAAa,CAAC,CAAC,CAAC,wBAAwB,CAAC,CAAC,CAAC,cAAc,CAAC;IAEzE,IAAI,KAAK,EAAE,CAAC;QACV,QAAQ,GAAG,OAAO,CAAC;IACrB,CAAC;IAED,OAAO,IAAA,kBAAK,EAAC,IAAA,gBAAG,EAAC,0BAA0B,CAAC,EAAE;QAC5C,IAAA,qBAAQ,EAAC;YACP,6BAA6B;YAC7B,EAAE,EAAE,IAAI;YACR,aAAa,EAAb,+BAAa;YACb,KAAK;YACL,SAAS,EAAE,GAAG,IAAI,aAAa;YAC/B,OAAO;YACP,QAAQ;SACT,CAAC;QACF,IAAA,iBAAI,EAAC,GAAG,EAAE,UAAU,CAAC;KACtB,CAAC,CAAC;AACL,CAAC"}
@@ -1,3 +1,3 @@
1
1
  import { Rule } from '@angular-devkit/schematics';
2
2
  import { SchemaOptions } from './schema';
3
- export default function (options: SchemaOptions): Rule;
3
+ export declare function ngAdd(options: SchemaOptions): Rule;
@@ -1,45 +1,55 @@
1
1
  "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
2
11
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = default_1;
12
+ exports.ngAdd = ngAdd;
4
13
  const node_path_1 = require("node:path");
5
14
  const schematics_1 = require("@angular-devkit/schematics");
6
15
  const ng_ast_utils_1 = require("@schematics/angular/utility/ng-ast-utils");
7
16
  const util_1 = require("@schematics/angular/utility/standalone/util");
8
17
  const rules_1 = require("@schematics/angular/utility/standalone/rules");
9
18
  const app_config_1 = require("@schematics/angular/utility/standalone/app_config");
10
- const array_1 = require("../utils/array");
11
- const projects_1 = require("../utils/projects");
12
- const translations_1 = require("../utils/translations");
13
- const transloco_1 = require("../utils/transloco");
19
+ const schematics_core_1 = require("../../schematics-core");
14
20
  const schema_1 = require("./schema");
15
21
  const http_loader_gen_1 = require("./generators/http-loader.gen");
16
- const translation_files_gen_1 = require("./generators/translation-files.gen");
17
22
  const root_module_gen_1 = require("./generators/root-module.gen");
18
23
  function updateEnvironmentBaseUrl(host, sourceRoot, defaultValue) {
19
24
  const template = `$1{
20
25
  baseUrl: '${defaultValue}',`;
21
- (0, projects_1.setEnvironments)(host, sourceRoot, (env) => env.indexOf('baseUrl') === -1
26
+ (0, schematics_core_1.setEnvironments)(host, sourceRoot, (env) => env.indexOf('baseUrl') === -1
22
27
  ? env.replace(/(environment.*=*)\{/, template)
23
28
  : env);
24
29
  }
25
- function resolveLoaderPath({ host, mainPath, isStandalone, modulePath }) {
30
+ function resolveLoaderPath({ host, mainPath, isStandalone, modulePath, }) {
31
+ var _a;
26
32
  let resolved = modulePath;
27
33
  if (isStandalone) {
28
34
  const bootstrapCall = (0, util_1.findBootstrapApplicationCall)(host, mainPath);
29
35
  resolved =
30
- (0, app_config_1.findAppConfig)(bootstrapCall, host, mainPath)?.filePath || mainPath;
36
+ ((_a = (0, app_config_1.findAppConfig)(bootstrapCall, host, mainPath)) === null || _a === void 0 ? void 0 : _a.filePath) || mainPath;
31
37
  resolved = (0, node_path_1.dirname)(resolved);
32
38
  }
33
39
  return resolved;
34
40
  }
35
- function default_1(options) {
36
- return async (host, context) => {
41
+ function ngAdd(options) {
42
+ return (host, context) => __awaiter(this, void 0, void 0, function* () {
43
+ var _a;
37
44
  const langs = options.langs.split(',').map((l) => l.trim());
38
- const project = (0, projects_1.getProject)(host, options.project);
39
- const sourceRoot = project.sourceRoot ?? 'src';
45
+ if (!options.project) {
46
+ throw new schematics_1.SchematicsException('Project name is required. Are you using Nx? In Nx you must explicitly provide the project name using --project=<project-name>');
47
+ }
48
+ const project = (0, schematics_core_1.getProject)(host, options.project);
49
+ const sourceRoot = (_a = project.sourceRoot) !== null && _a !== void 0 ? _a : 'src';
40
50
  const isLib = project.projectType === 'library';
41
51
  const assetsPath = `${sourceRoot}/${options.path}`;
42
- const mainPath = await (0, util_1.getMainFilePath)(host, options.project);
52
+ const mainPath = yield (0, util_1.getMainFilePath)(host, options.project);
43
53
  const isStandalone = (0, ng_ast_utils_1.isStandaloneApp)(host, mainPath);
44
54
  const modulePath = isStandalone
45
55
  ? ''
@@ -63,9 +73,9 @@ function default_1(options) {
63
73
  loaderPath,
64
74
  })));
65
75
  }
66
- const hasTranslationFiles = (0, translations_1.checkIfTranslationFilesExist)(assetsPath, langs, '.json', true);
76
+ const hasTranslationFiles = (0, schematics_core_1.checkIfTranslationFilesExist)(assetsPath, langs, '.json', true);
67
77
  if (!hasTranslationFiles) {
68
- actions.push((0, schematics_1.mergeWith)((0, translation_files_gen_1.createTranslateFiles)(langs, translation_files_gen_1.jsonTranslationFileCreator, assetsPath)));
78
+ actions.push((0, schematics_1.mergeWith)((0, schematics_core_1.createTranslateFiles)(langs, assetsPath)));
69
79
  }
70
80
  if (isStandalone) {
71
81
  actions.push((0, rules_1.addRootProvider)(options.project, ({ code, external }) => {
@@ -73,7 +83,7 @@ function default_1(options) {
73
83
  external('TranslocoHttpLoader', './transloco-loader');
74
84
  return code `${external('provideTransloco', '@jsverse/transloco')}({
75
85
  config: {
76
- availableLangs: [${(0, array_1.stringifyList)(langs)}],
86
+ availableLangs: [${(0, schematics_core_1.stringifyList)(langs)}],
77
87
  defaultLang: '${langs[0]}',
78
88
  // Remove this option if your application doesn't support changing language in runtime.
79
89
  reRenderOnLangChange: true,
@@ -96,8 +106,8 @@ function default_1(options) {
96
106
  if (options.ssr) {
97
107
  updateEnvironmentBaseUrl(host, sourceRoot, 'http://localhost:4200');
98
108
  }
99
- (0, transloco_1.createConfig)(host, langs, assetsPath);
109
+ (0, schematics_core_1.createGlobalConfig)(host, langs, assetsPath);
100
110
  return (0, schematics_1.chain)(actions)(host, context);
101
- };
111
+ });
102
112
  }
103
113
  //# sourceMappingURL=index.js.map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ACf,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,CACrB,IAAI,CAAA,GAAG,QAAQ,CAAC,qBAAqB,EAAE,yBAAyB,CAAC,EAAE,CACtE,EACD,IAAA,sBAAS,EACP,IAAA,uCAAqB,EAAC;gBACpB,UAAU;gBACV,KAAK;gBACL,GAAG,EAAE,OAAO,CAAC,GAAG;gBAChB,KAAK;gBACL,UAAU;gBACV,IAAI;aACL,CAAC,CACH,CACF,CAAC;QACJ,CAAC;QAED,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;YAChB,wBAAwB,CAAC,IAAI,EAAE,UAAU,EAAE,uBAAuB,CAAC,CAAC;QACtE,CAAC;QAED,IAAA,oCAAkB,EAAC,IAAI,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC;QAE5C,OAAO,IAAA,kBAAK,EAAC,OAAO,CAAC,CAAC,IAAI,EAAE,OAAO,CAAS,CAAC;IAC/C,CAAC,CAAA,CAAC;AACJ,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ const nodePath = require("node:path");
13
+ const testing_1 = require("@angular-devkit/schematics/testing");
14
+ const testing_2 = require("../../schematics-core/testing");
15
+ const collectionPath = nodePath.join(__dirname, '../collection.json');
16
+ describe('ng add', () => {
17
+ const schematicRunner = new testing_1.SchematicTestRunner('schematics', collectionPath);
18
+ describe('Ng module', () => {
19
+ it('should add transloco to specified project', () => __awaiter(void 0, void 0, void 0, function* () {
20
+ const options = { project: 'bar' };
21
+ const tree = yield schematicRunner.runSchematic('ng-add', options, yield (0, testing_2.createWorkspace)(schematicRunner, {
22
+ appOptions: { standalone: false },
23
+ }));
24
+ expect(tree).toBeDefined();
25
+ expect(tree.files).toContain('/transloco.config.ts');
26
+ expect(tree.files).toContain('/projects/bar/src/app/transloco-loader.ts');
27
+ expect(tree.files).toContain('/projects/bar/src/app/transloco-root.module.ts');
28
+ expect(readFile(tree, 'app/transloco-root.module.ts')).toContain("from './transloco-loader'");
29
+ }));
30
+ });
31
+ describe('Standalone', () => {
32
+ it('should add transloco to specified standalone project', () => __awaiter(void 0, void 0, void 0, function* () {
33
+ const options = { project: 'bar' };
34
+ const tree = yield schematicRunner.runSchematic('ng-add', options, yield (0, testing_2.createWorkspace)(schematicRunner));
35
+ expect(tree).toBeDefined();
36
+ expect(tree.files).toContain('/transloco.config.ts');
37
+ expect(tree.files).toContain('/projects/bar/src/app/transloco-loader.ts');
38
+ expect(readFile(tree, 'app/app.config.ts')).toContain('provideTransloco(');
39
+ }));
40
+ });
41
+ });
42
+ function readFile(host, path) {
43
+ return host.get(`/projects/bar/src/${path}`).content.toString();
44
+ }
45
+ //# sourceMappingURL=ng-add.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ng-add.spec.js","sourceRoot":"","sources":["../../../../../libs/transloco/schematics/ng-add/ng-add.spec.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,sCAAsC;AAEtC,gEAG4C;AAE5C,2DAAgE;AAIhE,MAAM,cAAc,GAAG,QAAQ,CAAC,IAAI,CAAC,SAAS,EAAE,oBAAoB,CAAC,CAAC;AAEtE,QAAQ,CAAC,QAAQ,EAAE,GAAG,EAAE;IACtB,MAAM,eAAe,GAAG,IAAI,6BAAmB,CAAC,YAAY,EAAE,cAAc,CAAC,CAAC;IAE9E,QAAQ,CAAC,WAA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SAAS,CAAC,2CAA2C,CAAC,CAAC;YAC1E,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,mBAAmB,CAAC,CAAC,CAAC,SAAS,CACnD,mBAAmB,CACpB,CAAC;QACJ,CAAC,CAAA,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,SAAS,QAAQ,CAAC,IAAkB,EAAE,IAAY;IAChD,OAAO,IAAI,CAAC,GAAG,CAAC,qBAAqB,IAAI,EAAE,CAAE,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC;AACnE,CAAC"}
@@ -2,10 +2,6 @@ export declare enum Loaders {
2
2
  Http = "Http",
3
3
  Webpack = "Webpack"
4
4
  }
5
- export declare enum TranslationFileTypes {
6
- Typescript = "Typescript",
7
- JSON = "JSON"
8
- }
9
5
  export interface SchemaOptions {
10
6
  /**
11
7
  * The languages of the project.
@@ -15,10 +11,6 @@ export interface SchemaOptions {
15
11
  * The translations loader
16
12
  */
17
13
  loader: Loaders;
18
- /**
19
- * The translation files type.
20
- */
21
- translateType: TranslationFileTypes;
22
14
  /**
23
15
  * The translation files folder.
24
16
  */
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Loaders = void 0;
4
+ var Loaders;
5
+ (function (Loaders) {
6
+ Loaders["Http"] = "Http";
7
+ Loaders["Webpack"] = "Webpack";
8
+ })(Loaders || (exports.Loaders = Loaders = {}));
9
+ //# sourceMappingURL=schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../../../libs/transloco/schematics/ng-add/schema.ts"],"names":[],"mappings":";;;AAAA,IAAY,OAGX;AAHD,WAAY,OAAO;IACjB,wBAAa,CAAA;IACb,8BAAmB,CAAA;AACrB,CAAC,EAHW,OAAO,uBAAP,OAAO,QAGlB"}
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "http://json-schema.org/schema",
3
- "$id": "transloco-ng-add",
3
+ "$id": "SchematicsTransloco",
4
4
  "title": "Adds Transloco to a project",
5
5
  "type": "object",
6
6
  "properties": {
@@ -0,0 +1,9 @@
1
+ export { stringifyList, coerceArray } from './utils/collections';
2
+ export { addScriptToPackageJson } from './utils/package';
3
+ export { getProject, setEnvironments, getWorkspace, setWorkspace, } from './utils/workspace';
4
+ export { createGlobalConfig, getGlobalConfig, updateGlobalConfig, } from './utils/transloco';
5
+ export { createTranslateFiles, checkIfTranslationFilesExist, } from './utils/translation';
6
+ export { getTranslationEntryPaths, getTranslationFiles, getTranslationKey, getTranslationsRoot, createTranslateFilesFromOptions, } from './utils/translation';
7
+ export { hasFiles, hasSubdirs, getJsonFileContent, writeToJson, } from './utils/file';
8
+ export { NAMES } from './utils/schematic';
9
+ export { findModuleFromOptions } from './utils/find-module';
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.findModuleFromOptions = exports.NAMES = exports.writeToJson = exports.getJsonFileContent = exports.hasSubdirs = exports.hasFiles = exports.createTranslateFilesFromOptions = exports.getTranslationsRoot = exports.getTranslationKey = exports.getTranslationFiles = exports.getTranslationEntryPaths = exports.checkIfTranslationFilesExist = exports.createTranslateFiles = exports.updateGlobalConfig = exports.getGlobalConfig = exports.createGlobalConfig = exports.setWorkspace = exports.getWorkspace = exports.setEnvironments = exports.getProject = exports.addScriptToPackageJson = exports.coerceArray = exports.stringifyList = void 0;
4
+ var collections_1 = require("./utils/collections");
5
+ Object.defineProperty(exports, "stringifyList", { enumerable: true, get: function () { return collections_1.stringifyList; } });
6
+ Object.defineProperty(exports, "coerceArray", { enumerable: true, get: function () { return collections_1.coerceArray; } });
7
+ var package_1 = require("./utils/package");
8
+ Object.defineProperty(exports, "addScriptToPackageJson", { enumerable: true, get: function () { return package_1.addScriptToPackageJson; } });
9
+ var workspace_1 = require("./utils/workspace");
10
+ Object.defineProperty(exports, "getProject", { enumerable: true, get: function () { return workspace_1.getProject; } });
11
+ Object.defineProperty(exports, "setEnvironments", { enumerable: true, get: function () { return workspace_1.setEnvironments; } });
12
+ Object.defineProperty(exports, "getWorkspace", { enumerable: true, get: function () { return workspace_1.getWorkspace; } });
13
+ Object.defineProperty(exports, "setWorkspace", { enumerable: true, get: function () { return workspace_1.setWorkspace; } });
14
+ var transloco_1 = require("./utils/transloco");
15
+ Object.defineProperty(exports, "createGlobalConfig", { enumerable: true, get: function () { return transloco_1.createGlobalConfig; } });
16
+ Object.defineProperty(exports, "getGlobalConfig", { enumerable: true, get: function () { return transloco_1.getGlobalConfig; } });
17
+ Object.defineProperty(exports, "updateGlobalConfig", { enumerable: true, get: function () { return transloco_1.updateGlobalConfig; } });
18
+ var translation_1 = require("./utils/translation");
19
+ Object.defineProperty(exports, "createTranslateFiles", { enumerable: true, get: function () { return translation_1.createTranslateFiles; } });
20
+ Object.defineProperty(exports, "checkIfTranslationFilesExist", { enumerable: true, get: function () { return translation_1.checkIfTranslationFilesExist; } });
21
+ var translation_2 = require("./utils/translation");
22
+ Object.defineProperty(exports, "getTranslationEntryPaths", { enumerable: true, get: function () { return translation_2.getTranslationEntryPaths; } });
23
+ Object.defineProperty(exports, "getTranslationFiles", { enumerable: true, get: function () { return translation_2.getTranslationFiles; } });
24
+ Object.defineProperty(exports, "getTranslationKey", { enumerable: true, get: function () { return translation_2.getTranslationKey; } });
25
+ Object.defineProperty(exports, "getTranslationsRoot", { enumerable: true, get: function () { return translation_2.getTranslationsRoot; } });
26
+ Object.defineProperty(exports, "createTranslateFilesFromOptions", { enumerable: true, get: function () { return translation_2.createTranslateFilesFromOptions; } });
27
+ var file_1 = require("./utils/file");
28
+ Object.defineProperty(exports, "hasFiles", { enumerable: true, get: function () { return file_1.hasFiles; } });
29
+ Object.defineProperty(exports, "hasSubdirs", { enumerable: true, get: function () { return file_1.hasSubdirs; } });
30
+ Object.defineProperty(exports, "getJsonFileContent", { enumerable: true, get: function () { return file_1.getJsonFileContent; } });
31
+ Object.defineProperty(exports, "writeToJson", { enumerable: true, get: function () { return file_1.writeToJson; } });
32
+ var schematic_1 = require("./utils/schematic");
33
+ Object.defineProperty(exports, "NAMES", { enumerable: true, get: function () { return schematic_1.NAMES; } });
34
+ var find_module_1 = require("./utils/find-module");
35
+ Object.defineProperty(exports, "findModuleFromOptions", { enumerable: true, get: function () { return find_module_1.findModuleFromOptions; } });
36
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../libs/transloco/schematics-core/index.ts"],"names":[],"mappings":";;;AAAA,mDAAiE;AAAxD,4GAAA,aAAa,OAAA;AAAE,0GAAA,WAAW,OAAA;AACnC,2CAAyD;AAAhD,iHAAA,sBAAsB,OAAA;AAC/B,+CAK2B;AAJzB,uGAAA,UAAU,OAAA;AACV,4GAAA,eAAe,OAAA;AACf,yGAAA,YAAY,OAAA;AACZ,yGAAA,YAAY,OAAA;AAEd,+CAI2B;AAHzB,+GAAA,kBAAkB,OAAA;AAClB,4GAAA,eAAe,OAAA;AACf,+GAAA,kBAAkB,OAAA;AAEpB,mDAG6B;AAF3B,mHAAA,oBAAoB,OAAA;AACpB,2HAAA,4BAA4B,OAAA;AAG9B,mDAM6B;AAL3B,uHAAA,wBAAwB,OAAA;AACxB,kHAAA,mBAAmB,OAAA;AACnB,gHAAA,iBAAiB,OAAA;AACjB,kHAAA,mBAAmB,OAAA;AACnB,8HAAA,+BAA+B,OAAA;AAEjC,qCAKsB;AAJpB,gGAAA,QAAQ,OAAA;AACR,kGAAA,UAAU,OAAA;AACV,0GAAA,kBAAkB,OAAA;AAClB,mGAAA,WAAW,OAAA;AAEb,+CAA0C;AAAjC,kGAAA,KAAK,OAAA;AACd,mDAA4D;AAAnD,oHAAA,qBAAqB,OAAA"}