@aidc-toolkit/core 1.0.40-beta → 1.0.41

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 (77) hide show
  1. package/dist/browser-app-data-storage-G62WSQ5Z.js +1 -0
  2. package/dist/chunk-FIUBVWNN.js +1 -0
  3. package/dist/file-app-data-storage-Y5AB6YOB.js +1 -0
  4. package/dist/index.cjs +18 -0
  5. package/dist/index.d.cts +761 -0
  6. package/dist/index.d.ts +761 -29
  7. package/dist/index.js +2 -11
  8. package/package.json +4 -4
  9. package/tsconfig-src.json +7 -1
  10. package/tsconfig-src.tsbuildinfo +1 -0
  11. package/tsconfig-tsup.json +7 -0
  12. package/dist/app-data-storage.d.ts +0 -118
  13. package/dist/app-data-storage.d.ts.map +0 -1
  14. package/dist/app-data-storage.js +0 -117
  15. package/dist/app-data-storage.js.map +0 -1
  16. package/dist/app-data.d.ts +0 -26
  17. package/dist/app-data.d.ts.map +0 -1
  18. package/dist/app-data.js +0 -79
  19. package/dist/app-data.js.map +0 -1
  20. package/dist/browser-app-data-storage.d.ts +0 -26
  21. package/dist/browser-app-data-storage.d.ts.map +0 -1
  22. package/dist/browser-app-data-storage.js +0 -34
  23. package/dist/browser-app-data-storage.js.map +0 -1
  24. package/dist/cache.d.ts +0 -58
  25. package/dist/cache.d.ts.map +0 -1
  26. package/dist/cache.js +0 -12
  27. package/dist/cache.js.map +0 -1
  28. package/dist/file-app-data-storage.d.ts +0 -26
  29. package/dist/file-app-data-storage.d.ts.map +0 -1
  30. package/dist/file-app-data-storage.js +0 -40
  31. package/dist/file-app-data-storage.js.map +0 -1
  32. package/dist/hyperlink.d.ts +0 -18
  33. package/dist/hyperlink.d.ts.map +0 -1
  34. package/dist/hyperlink.js +0 -2
  35. package/dist/hyperlink.js.map +0 -1
  36. package/dist/index.d.ts.map +0 -1
  37. package/dist/index.js.map +0 -1
  38. package/dist/local-app-data-storage.d.ts +0 -8
  39. package/dist/local-app-data-storage.d.ts.map +0 -1
  40. package/dist/local-app-data-storage.js +0 -11
  41. package/dist/local-app-data-storage.js.map +0 -1
  42. package/dist/locale/en/locale-resources.d.ts +0 -10
  43. package/dist/locale/en/locale-resources.d.ts.map +0 -1
  44. package/dist/locale/en/locale-resources.js +0 -9
  45. package/dist/locale/en/locale-resources.js.map +0 -1
  46. package/dist/locale/fr/locale-resources.d.ts +0 -10
  47. package/dist/locale/fr/locale-resources.d.ts.map +0 -1
  48. package/dist/locale/fr/locale-resources.js +0 -9
  49. package/dist/locale/fr/locale-resources.js.map +0 -1
  50. package/dist/locale/i18n.d.ts +0 -83
  51. package/dist/locale/i18n.d.ts.map +0 -1
  52. package/dist/locale/i18n.js +0 -157
  53. package/dist/locale/i18n.js.map +0 -1
  54. package/dist/logger.d.ts +0 -136
  55. package/dist/logger.d.ts.map +0 -1
  56. package/dist/logger.js +0 -256
  57. package/dist/logger.js.map +0 -1
  58. package/dist/parse-version.d.ts +0 -36
  59. package/dist/parse-version.d.ts.map +0 -1
  60. package/dist/parse-version.js +0 -23
  61. package/dist/parse-version.js.map +0 -1
  62. package/dist/remote-app-data-storage.d.ts +0 -18
  63. package/dist/remote-app-data-storage.d.ts.map +0 -1
  64. package/dist/remote-app-data-storage.js +0 -37
  65. package/dist/remote-app-data-storage.js.map +0 -1
  66. package/dist/type-helper.d.ts +0 -115
  67. package/dist/type-helper.d.ts.map +0 -1
  68. package/dist/type-helper.js +0 -163
  69. package/dist/type-helper.js.map +0 -1
  70. package/dist/type.d.ts +0 -111
  71. package/dist/type.d.ts.map +0 -1
  72. package/dist/type.js +0 -2
  73. package/dist/type.js.map +0 -1
  74. package/dist/website-url.d.ts +0 -29
  75. package/dist/website-url.d.ts.map +0 -1
  76. package/dist/website-url.js +0 -60
  77. package/dist/website-url.js.map +0 -1
package/dist/cache.d.ts DELETED
@@ -1,58 +0,0 @@
1
- import type { Promisable } from "./type.js";
2
- /**
3
- * Generic cache. Typically used to manage a local copy of remote data that is not refreshed regularly.
4
- *
5
- * @template TCache
6
- * Type of cached data.
7
- *
8
- * @template TSource
9
- * Type of source data. The type may be different from the cached data type if a transformation is required.
10
- */
11
- export declare abstract class Cache<TCache, TSource = TCache> {
12
- /**
13
- * Get the date/time at or after which the source should be checked for updates. If the value is undefined, this is
14
- * the first usage.
15
- */
16
- abstract get nextCheckDateTime(): Promisable<Date | undefined>;
17
- /**
18
- * Get the date/time at which the cache was last updated. This may more accurately reflect the date/time at which
19
- * the last source retrieved was updated. If the value is undefined, there is no data in the cache.
20
- */
21
- abstract get cacheDateTime(): Promisable<Date | undefined>;
22
- /**
23
- * Get the cache data. This should only ever be called if the cache date/time is defined.
24
- */
25
- abstract get cacheData(): Promisable<TCache>;
26
- /**
27
- * Get the date/time at which the source was last updated. This should not be called unless the next check date/time
28
- * has passed, as it may trigger an expensive remote retrieval.
29
- */
30
- abstract get sourceDateTime(): Promisable<Date>;
31
- /**
32
- * Get the source data. This should not be called unless the next check date/time has passed, as it may trigger an
33
- * expensive remote retrieval.
34
- */
35
- abstract get sourceData(): Promisable<TSource>;
36
- /**
37
- * Update the cache with only the next check date/time. The cache date/time and cache data must not be modified.
38
- * This is typically called when the cache is up to date with the source or source retrieval has failed.
39
- *
40
- * @param nextCheckDateTime
41
- * Next check date/time.
42
- */
43
- abstract update(nextCheckDateTime: Date): Promisable<void>;
44
- /**
45
- * Update all cache parameters. This is typically called when the cache is updated from the source.
46
- *
47
- * @param nextCheckDateTime
48
- * Next check date/time.
49
- *
50
- * @param cacheDateTime
51
- * Cache date/time.
52
- *
53
- * @param cacheData
54
- * Cache data.
55
- */
56
- abstract update(nextCheckDateTime: Date, cacheDateTime: Date, cacheData: TCache): Promisable<void>;
57
- }
58
- //# sourceMappingURL=cache.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../src/cache.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAE5C;;;;;;;;GAQG;AACH,8BAAsB,KAAK,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM;IAChD;;;OAGG;IACH,QAAQ,KAAK,iBAAiB,IAAI,UAAU,CAAC,IAAI,GAAG,SAAS,CAAC,CAAC;IAE/D;;;OAGG;IACH,QAAQ,KAAK,aAAa,IAAI,UAAU,CAAC,IAAI,GAAG,SAAS,CAAC,CAAC;IAE3D;;OAEG;IACH,QAAQ,KAAK,SAAS,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC;IAE7C;;;OAGG;IACH,QAAQ,KAAK,cAAc,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC;IAEhD;;;OAGG;IACH,QAAQ,KAAK,UAAU,IAAI,UAAU,CAAC,OAAO,CAAC,CAAC;IAE/C;;;;;;OAMG;IACH,QAAQ,CAAC,MAAM,CAAC,iBAAiB,EAAE,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC;IAE1D;;;;;;;;;;;OAWG;IACH,QAAQ,CAAC,MAAM,CAAC,iBAAiB,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,GAAG,UAAU,CAAC,IAAI,CAAC;CACrG"}
package/dist/cache.js DELETED
@@ -1,12 +0,0 @@
1
- /**
2
- * Generic cache. Typically used to manage a local copy of remote data that is not refreshed regularly.
3
- *
4
- * @template TCache
5
- * Type of cached data.
6
- *
7
- * @template TSource
8
- * Type of source data. The type may be different from the cached data type if a transformation is required.
9
- */
10
- export class Cache {
11
- }
12
- //# sourceMappingURL=cache.js.map
package/dist/cache.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"cache.js","sourceRoot":"","sources":["../src/cache.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,MAAM,OAAgB,KAAK;CAoD1B"}
@@ -1,26 +0,0 @@
1
- import { AppDataStorage } from "./app-data-storage.js";
2
- /**
3
- * Application data storage using the file system.
4
- */
5
- export declare class FileAppDataStorage extends AppDataStorage<true> {
6
- /**
7
- * Constructor.
8
- *
9
- * @param path
10
- * Storage path prepended to each key along with '/' if defined, empty string if not.
11
- */
12
- constructor(path?: string);
13
- /**
14
- * @inheritDoc
15
- */
16
- protected doRead(key: string, asBinary: boolean | undefined): Promise<string | Uint8Array | undefined>;
17
- /**
18
- * @inheritDoc
19
- */
20
- protected doWrite(key: string, data: string | Uint8Array): Promise<void>;
21
- /**
22
- * @inheritDoc
23
- */
24
- protected doDelete(key: string): Promise<void>;
25
- }
26
- //# sourceMappingURL=file-app-data-storage.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"file-app-data-storage.d.ts","sourceRoot":"","sources":["../src/file-app-data-storage.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,cAAc,CAAC,IAAI,CAAC;IACxD;;;;;OAKG;gBACS,IAAI,CAAC,EAAE,MAAM;IAIzB;;OAEG;cACsB,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,GAAG,SAAS,GAAG,OAAO,CAAC,MAAM,GAAG,UAAU,GAAG,SAAS,CAAC;IAQrH;;OAEG;cACsB,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;IAQvF;;OAEG;cACsB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAKhE"}
@@ -1,40 +0,0 @@
1
- import * as fs from "node:fs";
2
- import * as path from "node:path";
3
- import { AppDataStorage } from "./app-data-storage.js";
4
- /**
5
- * Application data storage using the file system.
6
- */
7
- export class FileAppDataStorage extends AppDataStorage {
8
- /**
9
- * Constructor.
10
- *
11
- * @param path
12
- * Storage path prepended to each key along with '/' if defined, empty string if not.
13
- */
14
- constructor(path) {
15
- super(true, path);
16
- }
17
- /**
18
- * @inheritDoc
19
- */
20
- async doRead(key, asBinary) {
21
- return fs.promises.readFile(key).then(buffer => asBinary === true ? buffer : buffer.toString()).catch(() => undefined);
22
- }
23
- /**
24
- * @inheritDoc
25
- */
26
- async doWrite(key, data) {
27
- return fs.promises.mkdir(path.dirname(key), {
28
- recursive: true
29
- }).then(async () => fs.promises.writeFile(key, data));
30
- }
31
- /**
32
- * @inheritDoc
33
- */
34
- async doDelete(key) {
35
- return fs.promises.rm(key, {
36
- force: true
37
- });
38
- }
39
- }
40
- //# sourceMappingURL=file-app-data-storage.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"file-app-data-storage.js","sourceRoot":"","sources":["../src/file-app-data-storage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD;;GAEG;AACH,MAAM,OAAO,kBAAmB,SAAQ,cAAoB;IACxD;;;;;OAKG;IACH,YAAY,IAAa;QACrB,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACtB,CAAC;IAED;;OAEG;IACgB,KAAK,CAAC,MAAM,CAAC,GAAW,EAAE,QAA6B;QACtE,OAAO,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAC3C,QAAQ,KAAK,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,EAAE,CACjD,CAAC,KAAK,CAAC,GAAG,EAAE,CACT,SAAS,CACZ,CAAC;IACN,CAAC;IAED;;OAEG;IACgB,KAAK,CAAC,OAAO,CAAC,GAAW,EAAE,IAAyB;QACnE,OAAO,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;YACxC,SAAS,EAAE,IAAI;SAClB,CAAC,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE,CACf,EAAE,CAAC,QAAQ,CAAC,SAAS,CAAC,GAAG,EAAE,IAAI,CAAC,CACnC,CAAC;IACN,CAAC;IAED;;OAEG;IACgB,KAAK,CAAC,QAAQ,CAAC,GAAW;QACzC,OAAO,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE;YACvB,KAAK,EAAE,IAAI;SACd,CAAC,CAAC;IACP,CAAC;CACJ"}
@@ -1,18 +0,0 @@
1
- /**
2
- * Hyperlink.
3
- */
4
- export interface Hyperlink {
5
- /**
6
- * Reference, relative or absolute depending on the application.
7
- */
8
- readonly reference: string;
9
- /**
10
- * Human-readable text.
11
- */
12
- readonly text?: string | undefined;
13
- /**
14
- * Additional details.
15
- */
16
- readonly details?: string | undefined;
17
- }
18
- //# sourceMappingURL=hyperlink.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"hyperlink.d.ts","sourceRoot":"","sources":["../src/hyperlink.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,SAAS;IACtB;;OAEG;IACH,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAE3B;;OAEG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAEnC;;OAEG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACzC"}
package/dist/hyperlink.js DELETED
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=hyperlink.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"hyperlink.js","sourceRoot":"","sources":["../src/hyperlink.ts"],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,mBAAmB,WAAW,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AAEjC,cAAc,aAAa,CAAC;AAE5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AAEjC,cAAc,eAAe,CAAC;AAC9B,cAAc,uBAAuB,CAAC;AACtC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,YAAY,CAAC;AAE3B,mBAAmB,gBAAgB,CAAC;AAEpC,cAAc,kBAAkB,CAAC"}
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,cAAc,kBAAkB,CAAC;AAEjC,cAAc,aAAa,CAAC;AAE5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AAEjC,cAAc,eAAe,CAAC;AAC9B,cAAc,uBAAuB,CAAC;AACtC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,YAAY,CAAC;AAI3B,cAAc,kBAAkB,CAAC"}
@@ -1,8 +0,0 @@
1
- import type { AppDataStorage } from "./app-data-storage.js";
2
- /**
3
- * Local application data storage class for the current environment. This is a variable representing a `Promise` as the
4
- * implementing class is loaded dynamically to prevent the inclusion of unnecessary node dependencies in a browser
5
- * environment.
6
- */
7
- export declare const LocalAppDataStorage: Promise<new (path?: string) => AppDataStorage<boolean>>;
8
- //# sourceMappingURL=local-app-data-storage.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"local-app-data-storage.d.ts","sourceRoot":"","sources":["../src/local-app-data-storage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE5D;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC,EAAE,MAAM,KAAK,cAAc,CAAC,OAAO,CAAC,CAII,CAAC"}
@@ -1,11 +0,0 @@
1
- /**
2
- * Local application data storage class for the current environment. This is a variable representing a `Promise` as the
3
- * implementing class is loaded dynamically to prevent the inclusion of unnecessary node dependencies in a browser
4
- * environment.
5
- */
6
- export const LocalAppDataStorage =
7
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- localStorage is undefined when running under Node.js.
8
- globalThis.localStorage === undefined ?
9
- import("./file-app-data-storage.js").then(module => module.FileAppDataStorage) :
10
- import("./browser-app-data-storage.js").then(module => module.BrowserAppDataStorage);
11
- //# sourceMappingURL=local-app-data-storage.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"local-app-data-storage.js","sourceRoot":"","sources":["../src/local-app-data-storage.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB;AAC5B,gIAAgI;AAChI,UAAU,CAAC,YAAY,KAAK,SAAS,CAAC,CAAC;IACnC,MAAM,CAAC,4BAA4B,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC,CAAC;IAChF,MAAM,CAAC,+BAA+B,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,qBAAqB,CAAC,CAAC"}
@@ -1,10 +0,0 @@
1
- declare const _default: {
2
- Logger: {
3
- unknownLogLevel: string;
4
- };
5
- RemoteAppDataStorage: {
6
- httpError: string;
7
- };
8
- };
9
- export default _default;
10
- //# sourceMappingURL=locale-resources.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"locale-resources.d.ts","sourceRoot":"","sources":["../../../src/locale/en/locale-resources.ts"],"names":[],"mappings":";;;;;;;;AAAA,wBAOE"}
@@ -1,9 +0,0 @@
1
- export default {
2
- Logger: {
3
- unknownLogLevel: "Unknown log level \"{{logLevel}}\""
4
- },
5
- RemoteAppDataStorage: {
6
- httpError: "HTTP error {{status, number}} retrieving file"
7
- }
8
- };
9
- //# sourceMappingURL=locale-resources.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"locale-resources.js","sourceRoot":"","sources":["../../../src/locale/en/locale-resources.ts"],"names":[],"mappings":"AAAA,eAAe;IACX,MAAM,EAAE;QACJ,eAAe,EAAE,oCAAoC;KACxD;IACD,oBAAoB,EAAE;QAClB,SAAS,EAAE,+CAA+C;KAC7D;CACJ,CAAC"}
@@ -1,10 +0,0 @@
1
- declare const _default: {
2
- Logger: {
3
- unknownLogLevel: string;
4
- };
5
- RemoteAppDataStorage: {
6
- httpError: string;
7
- };
8
- };
9
- export default _default;
10
- //# sourceMappingURL=locale-resources.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"locale-resources.d.ts","sourceRoot":"","sources":["../../../src/locale/fr/locale-resources.ts"],"names":[],"mappings":";;;;;;;;AAAA,wBAOE"}
@@ -1,9 +0,0 @@
1
- export default {
2
- Logger: {
3
- unknownLogLevel: "Niveau de journalisation inconnu «{{logLevel}}»"
4
- },
5
- RemoteAppDataStorage: {
6
- httpError: "Erreur HTTP {{status, number}} lors de la récupération du fichier"
7
- }
8
- };
9
- //# sourceMappingURL=locale-resources.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"locale-resources.js","sourceRoot":"","sources":["../../../src/locale/fr/locale-resources.ts"],"names":[],"mappings":"AAAA,eAAe;IACX,MAAM,EAAE;QACJ,eAAe,EAAE,iDAAiD;KACrE;IACD,oBAAoB,EAAE;QAClB,SAAS,EAAE,mEAAmE;KACjF;CACJ,CAAC"}
@@ -1,83 +0,0 @@
1
- import { type i18n, type Resource } from "i18next";
2
- import enLocaleResources from "./en/locale-resources.js";
3
- /**
4
- * Locale strings type for generic manipulation.
5
- */
6
- export interface LocaleResources {
7
- [key: string]: LocaleResources | string;
8
- }
9
- /**
10
- * Internationalization operating environments.
11
- */
12
- export declare const I18nEnvironments: {
13
- /**
14
- * Command-line interface (e.g., unit tests).
15
- */
16
- readonly CLI: 0;
17
- /**
18
- * Web server.
19
- */
20
- readonly Server: 1;
21
- /**
22
- * Web browser.
23
- */
24
- readonly Browser: 2;
25
- };
26
- /**
27
- * Internationalization operating environment key.
28
- */
29
- export type I18nEnvironmentKey = keyof typeof I18nEnvironments;
30
- /**
31
- * Internationalization operating environment.
32
- */
33
- export type I18nEnvironment = typeof I18nEnvironments[I18nEnvironmentKey];
34
- export declare const coreNS = "aidct_core";
35
- /**
36
- * Locale resources type is extracted from the English locale resources object.
37
- */
38
- export type CoreLocaleResources = typeof enLocaleResources;
39
- /**
40
- * Core resource bundle.
41
- */
42
- export declare const coreResourceBundle: Resource;
43
- export declare const i18nextCore: i18n;
44
- /**
45
- * Initialize internationalization.
46
- *
47
- * @param i18next
48
- * Internationalization object. As multiple objects exist, this parameter represents the one for the module for which
49
- * internationalization is being initialized.
50
- *
51
- * @param environment
52
- * Environment in which the application is running.
53
- *
54
- * @param debug
55
- * Debug setting.
56
- *
57
- * @param defaultNS
58
- * Default namespace.
59
- *
60
- * @param defaultResourceBundle
61
- * Default resource bundle.
62
- *
63
- * @param i18nDependencyInits
64
- * Dependency internationalization initialization functions.
65
- *
66
- * @returns
67
- * Default resource bundle.
68
- */
69
- export declare function i18nInit(i18next: i18n, environment: I18nEnvironment, debug: boolean, defaultNS: string, defaultResourceBundle: Resource, ...i18nDependencyInits: Array<(environment: I18nEnvironment, debug: boolean) => Promise<Resource>>): Promise<Resource>;
70
- /**
71
- * Initialize internationalization.
72
- *
73
- * @param environment
74
- * Environment in which the application is running.
75
- *
76
- * @param debug
77
- * Debug setting.
78
- *
79
- * @returns
80
- * Core resource bundle.
81
- */
82
- export declare function i18nCoreInit(environment: I18nEnvironment, debug?: boolean): Promise<Resource>;
83
- //# sourceMappingURL=i18n.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"i18n.d.ts","sourceRoot":"","sources":["../../src/locale/i18n.ts"],"names":[],"mappings":"AAAA,OAAgB,EACZ,KAAK,IAAI,EAKT,KAAK,QAAQ,EAChB,MAAM,SAAS,CAAC;AAGjB,OAAO,iBAAiB,MAAM,0BAA0B,CAAC;AAGzD;;GAEG;AACH,MAAM,WAAW,eAAe;IAC5B,CAAC,GAAG,EAAE,MAAM,GAAG,eAAe,GAAG,MAAM,CAAC;CAC3C;AAED;;GAEG;AACH,eAAO,MAAM,gBAAgB;IACzB;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;CAEG,CAAC;AAEX;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG,MAAM,OAAO,gBAAgB,CAAC;AAE/D;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,OAAO,gBAAgB,CAAC,kBAAkB,CAAC,CAAC;AAkB1E,eAAO,MAAM,MAAM,eAAe,CAAC;AAEnC;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG,OAAO,iBAAiB,CAAC;AAE3D;;GAEG;AACH,eAAO,MAAM,kBAAkB,EAAE,QAOhC,CAAC;AAGF,eAAO,MAAM,WAAW,EAAE,IAA+B,CAAC;AAE1D;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAsB,QAAQ,CAAC,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,eAAe,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,qBAAqB,EAAE,QAAQ,EAAE,GAAG,mBAAmB,EAAE,KAAK,CAAC,CAAC,WAAW,EAAE,eAAe,EAAE,KAAK,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CA4ErQ;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,YAAY,CAAC,WAAW,EAAE,eAAe,EAAE,KAAK,UAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,CAEjG"}
@@ -1,157 +0,0 @@
1
- import i18next from "i18next";
2
- import I18nextBrowserLanguageDetector from "i18next-browser-languagedetector";
3
- import I18nextCLILanguageDetector from "i18next-cli-language-detector";
4
- import enLocaleResources from "./en/locale-resources.js";
5
- import frLocaleResources from "./fr/locale-resources.js";
6
- /**
7
- * Internationalization operating environments.
8
- */
9
- export const I18nEnvironments = {
10
- /**
11
- * Command-line interface (e.g., unit tests).
12
- */
13
- CLI: 0,
14
- /**
15
- * Web server.
16
- */
17
- Server: 1,
18
- /**
19
- * Web browser.
20
- */
21
- Browser: 2
22
- };
23
- /**
24
- * Convert a string to lower case, skipping words that are all upper case.
25
- *
26
- * @param value
27
- * Value.
28
- *
29
- * @returns
30
- * Lower case string if value is a string. If not, value is returned as a string but not converted to lower case.
31
- */
32
- function toLowerCase(value) {
33
- return typeof value === "string" ?
34
- // Words with no lower case letters are preserved as they are likely mnemonics.
35
- value.split(" ").map(word => /[a-z]/u.test(word) ? word.toLowerCase() : word).join(" ") :
36
- String(value);
37
- }
38
- export const coreNS = "aidct_core";
39
- /**
40
- * Core resource bundle.
41
- */
42
- export const coreResourceBundle = {
43
- en: {
44
- aidct_core: enLocaleResources
45
- },
46
- fr: {
47
- aidct_core: frLocaleResources
48
- }
49
- };
50
- // Explicit type is necessary because type can't be inferred without additional references.
51
- export const i18nextCore = i18next.createInstance();
52
- /**
53
- * Initialize internationalization.
54
- *
55
- * @param i18next
56
- * Internationalization object. As multiple objects exist, this parameter represents the one for the module for which
57
- * internationalization is being initialized.
58
- *
59
- * @param environment
60
- * Environment in which the application is running.
61
- *
62
- * @param debug
63
- * Debug setting.
64
- *
65
- * @param defaultNS
66
- * Default namespace.
67
- *
68
- * @param defaultResourceBundle
69
- * Default resource bundle.
70
- *
71
- * @param i18nDependencyInits
72
- * Dependency internationalization initialization functions.
73
- *
74
- * @returns
75
- * Default resource bundle.
76
- */
77
- export async function i18nInit(i18next, environment, debug, defaultNS, defaultResourceBundle, ...i18nDependencyInits) {
78
- // Initialization may be called more than once.
79
- if (!i18next.isInitialized) {
80
- const mergedResourceBundle = {};
81
- /**
82
- * Merge a package resource bundle into the merged resource bundle.
83
- *
84
- * @param resourceBundle
85
- * Package resource bundle.
86
- */
87
- function mergeResourceBundle(resourceBundle) {
88
- // Merge languages.
89
- for (const [language, languageResourceBundle] of Object.entries(resourceBundle)) {
90
- if (!(language in mergedResourceBundle)) {
91
- mergedResourceBundle[language] = {};
92
- }
93
- const mergedLanguageResourceBundle = mergedResourceBundle[language];
94
- // Merge namespaces.
95
- for (const [namespace, resourceKey] of Object.entries(languageResourceBundle)) {
96
- if (namespace in mergedLanguageResourceBundle) {
97
- // Error prior to internationalization initialization; no localization possible.
98
- throw new Error(`Duplicate namespace ${namespace} in merged resource bundle for language ${language}`);
99
- }
100
- mergedLanguageResourceBundle[namespace] = resourceKey;
101
- }
102
- }
103
- }
104
- mergeResourceBundle(defaultResourceBundle);
105
- // Initialize dependencies and merge their resource bundles.
106
- for (const i18nDependencyInit of i18nDependencyInits) {
107
- // eslint-disable-next-line no-await-in-loop -- Dependencies must initialized first.
108
- await i18nDependencyInit(environment, debug).then(mergeResourceBundle);
109
- }
110
- let module;
111
- switch (environment) {
112
- case I18nEnvironments.CLI:
113
- // TODO Refactor when https://github.com/neet/i18next-cli-language-detector/issues/281 resolved.
114
- // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- Per above.
115
- module = I18nextCLILanguageDetector;
116
- break;
117
- case I18nEnvironments.Browser:
118
- module = I18nextBrowserLanguageDetector;
119
- break;
120
- default:
121
- throw new Error("Not supported");
122
- }
123
- await i18next.use(module).init({
124
- debug,
125
- defaultNS,
126
- resources: mergedResourceBundle,
127
- // Allow fallback by removing variant code then country code until match is found.
128
- nonExplicitSupportedLngs: true,
129
- // Fallback to first language defined.
130
- fallbackLng: Object.keys(mergedResourceBundle)[0],
131
- detection: {
132
- // Disabling cache allows read but requires explicit saving of i18nextLng attribute (e.g., via UI).
133
- caches: []
134
- }
135
- }).then(() => {
136
- // Add toLowerCase formatter.
137
- i18next.services.formatter?.add("toLowerCase", toLowerCase);
138
- });
139
- }
140
- return defaultResourceBundle;
141
- }
142
- /**
143
- * Initialize internationalization.
144
- *
145
- * @param environment
146
- * Environment in which the application is running.
147
- *
148
- * @param debug
149
- * Debug setting.
150
- *
151
- * @returns
152
- * Core resource bundle.
153
- */
154
- export async function i18nCoreInit(environment, debug = false) {
155
- return i18nInit(i18nextCore, environment, debug, coreNS, coreResourceBundle);
156
- }
157
- //# sourceMappingURL=i18n.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"i18n.js","sourceRoot":"","sources":["../../src/locale/i18n.ts"],"names":[],"mappings":"AAAA,OAAO,OAON,MAAM,SAAS,CAAC;AACjB,OAAO,8BAA8B,MAAM,kCAAkC,CAAC;AAC9E,OAAO,0BAA0B,MAAM,+BAA+B,CAAC;AACvE,OAAO,iBAAiB,MAAM,0BAA0B,CAAC;AACzD,OAAO,iBAAiB,MAAM,0BAA0B,CAAC;AASzD;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC5B;;OAEG;IACH,GAAG,EAAE,CAAC;IAEN;;OAEG;IACH,MAAM,EAAE,CAAC;IAET;;OAEG;IACH,OAAO,EAAE,CAAC;CACJ,CAAC;AAYX;;;;;;;;GAQG;AACH,SAAS,WAAW,CAAC,KAAc;IAC/B,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC;QAC9B,+EAA+E;QAC/E,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;QACzF,MAAM,CAAC,KAAK,CAAC,CAAC;AACtB,CAAC;AAED,MAAM,CAAC,MAAM,MAAM,GAAG,YAAY,CAAC;AAOnC;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAa;IACxC,EAAE,EAAE;QACA,UAAU,EAAE,iBAAiB;KAChC;IACD,EAAE,EAAE;QACA,UAAU,EAAE,iBAAiB;KAChC;CACJ,CAAC;AAEF,2FAA2F;AAC3F,MAAM,CAAC,MAAM,WAAW,GAAS,OAAO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