@vocab/core 1.1.2 → 1.2.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.
@@ -11,21 +11,18 @@ var IntlMessageFormat__default = /*#__PURE__*/_interopDefault(IntlMessageFormat)
11
11
  const moduleCache = new WeakMap();
12
12
  const getParsedICUMessages = (m, locale) => {
13
13
  const moduleCachedResult = moduleCache.get(m);
14
-
15
14
  if (moduleCachedResult && moduleCachedResult[locale]) {
16
15
  return moduleCachedResult[locale];
17
16
  }
18
-
19
17
  const parsedICUMessages = {};
20
-
21
18
  for (const translation of Object.keys(m)) {
22
- const intlMessageFormat = new IntlMessageFormat__default['default'](m[translation], locale);
19
+ const intlMessageFormat = new IntlMessageFormat__default["default"](m[translation], locale);
23
20
  parsedICUMessages[translation] = {
24
21
  format: params => intlMessageFormat.format(params)
25
22
  };
26
23
  }
27
-
28
- moduleCache.set(m, { ...moduleCachedResult,
24
+ moduleCache.set(m, {
25
+ ...moduleCachedResult,
29
26
  [locale]: parsedICUMessages
30
27
  });
31
28
  return parsedICUMessages;
@@ -11,21 +11,18 @@ var IntlMessageFormat__default = /*#__PURE__*/_interopDefault(IntlMessageFormat)
11
11
  const moduleCache = new WeakMap();
12
12
  const getParsedICUMessages = (m, locale) => {
13
13
  const moduleCachedResult = moduleCache.get(m);
14
-
15
14
  if (moduleCachedResult && moduleCachedResult[locale]) {
16
15
  return moduleCachedResult[locale];
17
16
  }
18
-
19
17
  const parsedICUMessages = {};
20
-
21
18
  for (const translation of Object.keys(m)) {
22
- const intlMessageFormat = new IntlMessageFormat__default['default'](m[translation], locale);
19
+ const intlMessageFormat = new IntlMessageFormat__default["default"](m[translation], locale);
23
20
  parsedICUMessages[translation] = {
24
21
  format: params => intlMessageFormat.format(params)
25
22
  };
26
23
  }
27
-
28
- moduleCache.set(m, { ...moduleCachedResult,
24
+ moduleCache.set(m, {
25
+ ...moduleCachedResult,
29
26
  [locale]: parsedICUMessages
30
27
  });
31
28
  return parsedICUMessages;
@@ -3,21 +3,18 @@ import IntlMessageFormat from 'intl-messageformat';
3
3
  const moduleCache = new WeakMap();
4
4
  const getParsedICUMessages = (m, locale) => {
5
5
  const moduleCachedResult = moduleCache.get(m);
6
-
7
6
  if (moduleCachedResult && moduleCachedResult[locale]) {
8
7
  return moduleCachedResult[locale];
9
8
  }
10
-
11
9
  const parsedICUMessages = {};
12
-
13
10
  for (const translation of Object.keys(m)) {
14
11
  const intlMessageFormat = new IntlMessageFormat(m[translation], locale);
15
12
  parsedICUMessages[translation] = {
16
13
  format: params => intlMessageFormat.format(params)
17
14
  };
18
15
  }
19
-
20
- moduleCache.set(m, { ...moduleCachedResult,
16
+ moduleCache.set(m, {
17
+ ...moduleCachedResult,
21
18
  [locale]: parsedICUMessages
22
19
  });
23
20
  return parsedICUMessages;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vocab/core",
3
- "version": "1.1.2",
3
+ "version": "1.2.1",
4
4
  "main": "dist/vocab-core.cjs.js",
5
5
  "module": "dist/vocab-core.esm.js",
6
6
  "exports": {
@@ -40,7 +40,7 @@
40
40
  ],
41
41
  "dependencies": {
42
42
  "@formatjs/icu-messageformat-parser": "^2.0.10",
43
- "@vocab/types": "^1.1.1",
43
+ "@vocab/types": "^1.1.2",
44
44
  "chalk": "^4.1.0",
45
45
  "chokidar": "^3.4.3",
46
46
  "debug": "^4.3.1",
@@ -54,4 +54,4 @@
54
54
  "@types/debug": "^4.1.5",
55
55
  "@types/prettier": "^2.1.5"
56
56
  }
57
- }
57
+ }
@@ -5,38 +5,30 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  function createTranslationFile(translationsByLanguage) {
6
6
  function getByLanguage(language) {
7
7
  const translationModule = translationsByLanguage[language];
8
-
9
8
  if (!translationModule) {
10
9
  throw new Error(`Attempted to retrieve translations for unknown language "${language}"`);
11
10
  }
12
-
13
11
  return translationModule;
14
12
  }
15
-
16
13
  return {
17
14
  getLoadedMessages(language, locale) {
18
15
  const translationModule = getByLanguage(language);
19
16
  return translationModule.getValue(locale || language) || null;
20
17
  },
21
-
22
18
  getMessages(language, locale) {
23
19
  const translationModule = getByLanguage(language);
24
20
  return translationModule.load().then(() => {
25
21
  const result = translationModule.getValue(locale || language);
26
-
27
22
  if (!result) {
28
23
  throw new Error(`Unable to find translations for ${language} after attempting to load. Module may have failed to load or an internal error may have occurred.`);
29
24
  }
30
-
31
25
  return result;
32
26
  });
33
27
  },
34
-
35
28
  load(language) {
36
29
  const translationModule = getByLanguage(language);
37
30
  return translationModule.load();
38
31
  }
39
-
40
32
  };
41
33
  }
42
34
 
@@ -5,38 +5,30 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  function createTranslationFile(translationsByLanguage) {
6
6
  function getByLanguage(language) {
7
7
  const translationModule = translationsByLanguage[language];
8
-
9
8
  if (!translationModule) {
10
9
  throw new Error(`Attempted to retrieve translations for unknown language "${language}"`);
11
10
  }
12
-
13
11
  return translationModule;
14
12
  }
15
-
16
13
  return {
17
14
  getLoadedMessages(language, locale) {
18
15
  const translationModule = getByLanguage(language);
19
16
  return translationModule.getValue(locale || language) || null;
20
17
  },
21
-
22
18
  getMessages(language, locale) {
23
19
  const translationModule = getByLanguage(language);
24
20
  return translationModule.load().then(() => {
25
21
  const result = translationModule.getValue(locale || language);
26
-
27
22
  if (!result) {
28
23
  throw new Error(`Unable to find translations for ${language} after attempting to load. Module may have failed to load or an internal error may have occurred.`);
29
24
  }
30
-
31
25
  return result;
32
26
  });
33
27
  },
34
-
35
28
  load(language) {
36
29
  const translationModule = getByLanguage(language);
37
30
  return translationModule.load();
38
31
  }
39
-
40
32
  };
41
33
  }
42
34
 
@@ -1,38 +1,30 @@
1
1
  function createTranslationFile(translationsByLanguage) {
2
2
  function getByLanguage(language) {
3
3
  const translationModule = translationsByLanguage[language];
4
-
5
4
  if (!translationModule) {
6
5
  throw new Error(`Attempted to retrieve translations for unknown language "${language}"`);
7
6
  }
8
-
9
7
  return translationModule;
10
8
  }
11
-
12
9
  return {
13
10
  getLoadedMessages(language, locale) {
14
11
  const translationModule = getByLanguage(language);
15
12
  return translationModule.getValue(locale || language) || null;
16
13
  },
17
-
18
14
  getMessages(language, locale) {
19
15
  const translationModule = getByLanguage(language);
20
16
  return translationModule.load().then(() => {
21
17
  const result = translationModule.getValue(locale || language);
22
-
23
18
  if (!result) {
24
19
  throw new Error(`Unable to find translations for ${language} after attempting to load. Module may have failed to load or an internal error may have occurred.`);
25
20
  }
26
-
27
21
  return result;
28
22
  });
29
23
  },
30
-
31
24
  load(language) {
32
25
  const translationModule = getByLanguage(language);
33
26
  return translationModule.load();
34
27
  }
35
-
36
28
  };
37
29
  }
38
30
 
package/CHANGELOG.md DELETED
@@ -1,204 +0,0 @@
1
- # @vocab/core
2
-
3
- ## 1.1.2
4
-
5
- ### Patch Changes
6
-
7
- - [`e5a066c`](https://github.com/seek-oss/vocab/commit/e5a066c8a7539a62a9c1c4d813aa87461ba43cdc) [#96](https://github.com/seek-oss/vocab/pull/96) Thanks [@askoufis](https://github.com/askoufis)! - Update `intl-messageformat` dependencies
8
-
9
- - Updated dependencies [[`e5a066c`](https://github.com/seek-oss/vocab/commit/e5a066c8a7539a62a9c1c4d813aa87461ba43cdc)]:
10
- - @vocab/types@1.1.1
11
-
12
- ## 1.1.1
13
-
14
- ### Patch Changes
15
-
16
- - [`09a698a`](https://github.com/seek-oss/vocab/commit/09a698af6aff86a851e4f829916b8f1f6beaca58) [#89](https://github.com/seek-oss/vocab/pull/89) Thanks [@mikebarkmin](https://github.com/mikebarkmin)! - Add exports to packages with multiple entry points. This fixes
17
- `ERR_UNSUPPORTED_DIR_IMPORT` issues e.g. with NextJS or other setups, which
18
- rely on the new node resolver when using ESM packages.
19
-
20
- ## 1.1.0
21
-
22
- ### Minor Changes
23
-
24
- - [`87333d7`](https://github.com/seek-oss/vocab/commit/87333d79c4a883b07d7d8f2c272b16e2243c49bd) [#80](https://github.com/seek-oss/vocab/pull/80) Thanks [@askoufis](https://github.com/askoufis)! - Enable the creation of generated languages via the `generatedLanguages` config.
25
- See [the docs] for more information and examples.
26
-
27
- [the docs]: https://github.com/seek-oss/vocab#generated-languages
28
-
29
- ### Patch Changes
30
-
31
- - Updated dependencies [[`87333d7`](https://github.com/seek-oss/vocab/commit/87333d79c4a883b07d7d8f2c272b16e2243c49bd)]:
32
- - @vocab/types@1.1.0
33
-
34
- ## 1.0.4
35
-
36
- ### Patch Changes
37
-
38
- - [`206c0fa`](https://github.com/seek-oss/vocab/commit/206c0fa36b05f23da593ebed801197c523477af6) [#78](https://github.com/seek-oss/vocab/pull/78) Thanks [@askoufis](https://github.com/askoufis)! - Fix incorrect language hierarchy when an extended language extends another language
39
-
40
- ## 1.0.3
41
-
42
- ### Patch Changes
43
-
44
- - [`78e874f`](https://github.com/seek-oss/vocab/commit/78e874f720ca34d771072c09fe55b57ff3158e02) [#71](https://github.com/seek-oss/vocab/pull/71) Thanks [@mattcompiles](https://github.com/mattcompiles)! - Only write compiled runtime files to disk if they have been changed
45
-
46
- ## 1.0.2
47
-
48
- ### Patch Changes
49
-
50
- - [`3ec6dba`](https://github.com/seek-oss/vocab/commit/3ec6dbaad590299cc33e2d9d4a877576eb05853a) [#63](https://github.com/seek-oss/vocab/pull/63) Thanks [@jahredhope](https://github.com/jahredhope)! - Migrate to new @formatjs/icu-messageformat-parser as intl-messageformat-parser has been deprecated
51
-
52
- - Updated dependencies [[`3ec6dba`](https://github.com/seek-oss/vocab/commit/3ec6dbaad590299cc33e2d9d4a877576eb05853a)]:
53
- - @vocab/types@1.0.1
54
-
55
- ## 1.0.1
56
-
57
- ### Patch Changes
58
-
59
- - [`c9a38dd`](https://github.com/seek-oss/vocab/commit/c9a38dd15e2c2a47fc4d5eb2348fdd08a6982768) [#54](https://github.com/seek-oss/vocab/pull/54) Thanks [@jahredhope](https://github.com/jahredhope)! - Allow special characters within translation keys and messages
60
-
61
- ## 1.0.0
62
-
63
- ### Major Changes
64
-
65
- - [`3031054`](https://github.com/seek-oss/vocab/commit/303105440851db6126f0606e1607745b27dd981c) [#51](https://github.com/seek-oss/vocab/pull/51) Thanks [@jahredhope](https://github.com/jahredhope)! - Release v1.0.0
66
-
67
- Release Vocab as v1.0.0 to signify a stable API and support future [semver versioning](https://semver.org/) releases.
68
-
69
- Vocab has seen a lot of iteration and changes since it was first published on 20 November 2020. We are now confident with the API and believe Vocab is ready for common use.
70
-
71
- ### Patch Changes
72
-
73
- - [`0074382`](https://github.com/seek-oss/vocab/commit/007438273ef70f5d5ded45777933651ad8df36f6) [#52](https://github.com/seek-oss/vocab/pull/52) Thanks [@jahredhope](https://github.com/jahredhope)! - Remove React dependency on core types.
74
-
75
- Direct use of tags in Translations now have stricter type definitions.
76
-
77
- - Updated dependencies [[`0074382`](https://github.com/seek-oss/vocab/commit/007438273ef70f5d5ded45777933651ad8df36f6), [`3031054`](https://github.com/seek-oss/vocab/commit/303105440851db6126f0606e1607745b27dd981c)]:
78
- - @vocab/types@1.0.0
79
-
80
- ## 0.0.11
81
-
82
- ### Patch Changes
83
-
84
- - [`5b1fdc0`](https://github.com/seek-oss/vocab/commit/5b1fdc019522b12e7ef94b2fec57b54a9310d41c) [#46](https://github.com/seek-oss/vocab/pull/46) Thanks [@jahredhope](https://github.com/jahredhope)! - Enable the use of translation files directly with 3 new documented methods for working with translations.
85
-
86
- ```typescript
87
- /**
88
- * Retrieve messages. If not available, will attempt to load messages and resolve once complete.
89
- */
90
- translations.getMessages(language);
91
- /**
92
- * Retrieve already loaded messages. Will return null if messages haven't been loaded.
93
- */
94
- translations.getLoadedMessages(language);
95
- /**
96
- * Load messages for the given language. Resolving once complete.
97
- */
98
- translations.load(language);
99
- ```
100
-
101
- - Updated dependencies [[`5b1fdc0`](https://github.com/seek-oss/vocab/commit/5b1fdc019522b12e7ef94b2fec57b54a9310d41c)]:
102
- - @vocab/types@0.0.9
103
-
104
- ## 0.0.10
105
-
106
- ### Patch Changes
107
-
108
- - [`7c96a14`](https://github.com/seek-oss/vocab/commit/7c96a142f602132d38c1df1a47a1f4657dc5c94c) [#43](https://github.com/seek-oss/vocab/pull/43) Thanks [@mattcompiles](https://github.com/mattcompiles)! - Return `NonNullable<ReactNode>` instead of `ReactNode` from translation function
109
-
110
- ## 0.0.9
111
-
112
- ### Patch Changes
113
-
114
- - [`3034bd3`](https://github.com/seek-oss/vocab/commit/3034bd3de610a9d1f3bfbd8caefa27064dee2710) [#40](https://github.com/seek-oss/vocab/pull/40) Thanks [@jahredhope](https://github.com/jahredhope)! - Fix .vocab files with no prefix not compiling
115
-
116
- * [`c110745`](https://github.com/seek-oss/vocab/commit/c110745b79df1a8ade6b1d8a49e798b04a7b95e1) [#42](https://github.com/seek-oss/vocab/pull/42) Thanks [@jahredhope](https://github.com/jahredhope)! - Avoid overriding existing translations files for new directories
117
-
118
- ## 0.0.8
119
-
120
- ### Patch Changes
121
-
122
- - [`f2fca67`](https://github.com/seek-oss/vocab/commit/f2fca679c66ae65405a0aa24f0a0e472026aad0d) [#36](https://github.com/seek-oss/vocab/pull/36) Thanks [@mattcompiles](https://github.com/mattcompiles)! - Support custom locales for ICU message parsing
123
-
124
- - Updated dependencies [[`f2fca67`](https://github.com/seek-oss/vocab/commit/f2fca679c66ae65405a0aa24f0a0e472026aad0d)]:
125
- - @vocab/types@0.0.8
126
-
127
- ## 0.0.7
128
-
129
- ### Patch Changes
130
-
131
- - [`283bcad`](https://github.com/seek-oss/vocab/commit/283bcada06e622ab14ed891743ed3f55cf09e245) [#33](https://github.com/seek-oss/vocab/pull/33) Thanks [@mattcompiles](https://github.com/mattcompiles)! - Move all vocab files to single directory with configurable suffix
132
-
133
- * [`ad0d240`](https://github.com/seek-oss/vocab/commit/ad0d2404545ded8e11621eae8f29467ff3352366) [#31](https://github.com/seek-oss/vocab/pull/31) Thanks [@mattcompiles](https://github.com/mattcompiles)! - Move the node runtime from @vocab/webpack to @vocab/core
134
-
135
- - [`f3992ef`](https://github.com/seek-oss/vocab/commit/f3992efbf08939ebf853fac650a49cc46dc51dfb) [#34](https://github.com/seek-oss/vocab/pull/34) Thanks [@jahredhope](https://github.com/jahredhope)! - Create translation files for newly created vocab directories
136
-
137
- * [`f3992ef`](https://github.com/seek-oss/vocab/commit/f3992efbf08939ebf853fac650a49cc46dc51dfb) [#34](https://github.com/seek-oss/vocab/pull/34) Thanks [@jahredhope](https://github.com/jahredhope)! - Validate translation files as loaded. Providing additional error messaging.
138
-
139
- * Updated dependencies [[`283bcad`](https://github.com/seek-oss/vocab/commit/283bcada06e622ab14ed891743ed3f55cf09e245), [`f3992ef`](https://github.com/seek-oss/vocab/commit/f3992efbf08939ebf853fac650a49cc46dc51dfb)]:
140
- - @vocab/types@0.0.7
141
-
142
- ## 0.0.6
143
-
144
- ### Patch Changes
145
-
146
- - [`80a46c0`](https://github.com/seek-oss/vocab/commit/80a46c01a55408675f5822c3618519f80136c3ab) [#27](https://github.com/seek-oss/vocab/pull/27) Thanks [@mattcompiles](https://github.com/mattcompiles)! - Add `ignore` config for ignoring files/folders from cli scripts
147
-
148
- * [`80a46c0`](https://github.com/seek-oss/vocab/commit/80a46c01a55408675f5822c3618519f80136c3ab) [#27](https://github.com/seek-oss/vocab/pull/27) Thanks [@mattcompiles](https://github.com/mattcompiles)! - Ignore node_modules from push, pull and compile scripts
149
-
150
- * Updated dependencies [[`80a46c0`](https://github.com/seek-oss/vocab/commit/80a46c01a55408675f5822c3618519f80136c3ab)]:
151
- - @vocab/types@0.0.6
152
-
153
- ## 0.0.5
154
-
155
- ### Patch Changes
156
-
157
- - [`371ed16`](https://github.com/seek-oss/vocab/commit/371ed16a232a04dab13afa7e2b352dfb6724eea4) [#25](https://github.com/seek-oss/vocab/pull/25) Thanks [@mattcompiles](https://github.com/mattcompiles)! - Watch alt language files as well as dev language
158
-
159
- * [`c222d68`](https://github.com/seek-oss/vocab/commit/c222d68a3c0c24723a338eccb959798881f6a118) [#24](https://github.com/seek-oss/vocab/pull/24) Thanks [@mattcompiles](https://github.com/mattcompiles)! - Changed glob constants to functions
160
-
161
- ## 0.0.4
162
-
163
- ### Patch Changes
164
-
165
- - [`5f5c581`](https://github.com/seek-oss/vocab/commit/5f5c581a65bff28729ee19e1ec0bdea488a9d6c2) [#19](https://github.com/seek-oss/vocab/pull/19) Thanks [@jahredhope](https://github.com/jahredhope)! - Compile useable TypeScript importable files with `vocab compile`.
166
-
167
- The new `vocab compile` step replaces `vocab generate-types` in creating a fully functional **translations.ts** file.
168
-
169
- This allows vocab to be used **without the Webpack Plugin**, however use of the plugin is still heavily advised to ensure optimal loading of translation content on the web.
170
-
171
- Support for unit testing is now better than ever! The newly created **translations.ts** means your unit test code will see the same code as available while rendering.
172
-
173
- See the [documentation](https://github.com/seek-oss/vocab) for further usage details.
174
-
175
- * [`02f943c`](https://github.com/seek-oss/vocab/commit/02f943ca892913b41f9e4720a72400777cf14b3d) [#17](https://github.com/seek-oss/vocab/pull/17) Thanks [@jahredhope](https://github.com/jahredhope)! - Add additional debug traces
176
-
177
- * Updated dependencies [[`5f5c581`](https://github.com/seek-oss/vocab/commit/5f5c581a65bff28729ee19e1ec0bdea488a9d6c2)]:
178
- - @vocab/types@0.0.5
179
-
180
- ## 0.0.3
181
-
182
- ### Patch Changes
183
-
184
- - [`08de30d`](https://github.com/seek-oss/vocab/commit/08de30d338c2a5ebdcf14da7c736dddf22e7ca9e) [#14](https://github.com/seek-oss/vocab/pull/14) Thanks [@mattcompiles](https://github.com/mattcompiles)! - Add ability to override files namespace with \$namespace
185
-
186
- * [`ed6cf40`](https://github.com/seek-oss/vocab/commit/ed6cf408973f2e9c4d07a71fcb52f40294ebaf65) [#13](https://github.com/seek-oss/vocab/pull/13) Thanks [@mattcompiles](https://github.com/mattcompiles)! - Add validation script for identifying missing keys
187
-
188
- - [`26b52f4`](https://github.com/seek-oss/vocab/commit/26b52f4878ded440841e08c858bdc9e685500c2a) [#16](https://github.com/seek-oss/vocab/pull/16) Thanks [@jahredhope](https://github.com/jahredhope)! - Enable debugging with DEBUG environment variable
189
-
190
- * [`b5a5a05`](https://github.com/seek-oss/vocab/commit/b5a5a05a5bb87b48e6e9160af75f555728143ea2) [#15](https://github.com/seek-oss/vocab/pull/15) Thanks [@mattcompiles](https://github.com/mattcompiles)! - Added watch mode to generate-types
191
-
192
- * Updated dependencies [[`08de30d`](https://github.com/seek-oss/vocab/commit/08de30d338c2a5ebdcf14da7c736dddf22e7ca9e)]:
193
- - @vocab/types@0.0.4
194
-
195
- ## 0.0.2
196
-
197
- ### Patch Changes
198
-
199
- - [`4710f34`](https://github.com/seek-oss/vocab/commit/4710f341f2827643e3eff69ef7e26d44ec6e8a2b) [#8](https://github.com/seek-oss/vocab/pull/8) Thanks [@mattcompiles](https://github.com/mattcompiles)! - Infer `t` return type more intelligently
200
-
201
- The translate key function (`t`) will now infer the return type as ReactNode only when the tag syntax is used.
202
-
203
- - Updated dependencies [[`4710f34`](https://github.com/seek-oss/vocab/commit/4710f341f2827643e3eff69ef7e26d44ec6e8a2b)]:
204
- - @vocab/types@0.0.3