@patterkit/compiler 0.4.5 → 0.4.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -235,7 +235,11 @@ function validateConditions(input, options = {}) {
235
235
  function validateInterpolation(input, options = {}) {
236
236
  const issues = [];
237
237
  const voiced = input.project.voiced ?? false;
238
- const tables = (input.locales ?? []).map((l) => ({ locale: l.locale, strings: l.strings }));
238
+ const byLocale = /* @__PURE__ */ new Map();
239
+ for (const l of input.locales ?? []) {
240
+ const table = byLocale.get(l.locale) ?? byLocale.set(l.locale, /* @__PURE__ */ new Map()).get(l.locale);
241
+ for (const [id, text] of Object.entries(l.strings)) (table.get(id) ?? table.set(id, []).get(id)).push(text);
242
+ }
239
243
  const defaultLocale = input.project.locales.default;
240
244
  const { foreign, external, merged } = validationScopes(input.project, options);
241
245
  const opaqueForeign = opaqueForeignTokens(foreign);
@@ -249,11 +253,9 @@ function validateInterpolation(input, options = {}) {
249
253
  return schema.properties.get(scope)?.has(name) ?? false;
250
254
  };
251
255
  const checkString = (nodeId, id, voicedLine) => {
252
- for (const t of tables) {
253
- const text = t.strings[id];
254
- if (text === void 0) continue;
255
- const field = `text[${t.locale}]`;
256
- for (const slot of (0, import_dialect2.extractSlots)(text)) {
256
+ for (const [locale, table] of byLocale) {
257
+ const field = `text[${locale}]`;
258
+ for (const text of table.get(id) ?? []) for (const slot of (0, import_dialect2.extractSlots)(text)) {
257
259
  if (voicedLine) {
258
260
  issues.push({
259
261
  nodeId,
package/dist/index.js CHANGED
@@ -201,7 +201,11 @@ function validateConditions(input, options = {}) {
201
201
  function validateInterpolation(input, options = {}) {
202
202
  const issues = [];
203
203
  const voiced = input.project.voiced ?? false;
204
- const tables = (input.locales ?? []).map((l) => ({ locale: l.locale, strings: l.strings }));
204
+ const byLocale = /* @__PURE__ */ new Map();
205
+ for (const l of input.locales ?? []) {
206
+ const table = byLocale.get(l.locale) ?? byLocale.set(l.locale, /* @__PURE__ */ new Map()).get(l.locale);
207
+ for (const [id, text] of Object.entries(l.strings)) (table.get(id) ?? table.set(id, []).get(id)).push(text);
208
+ }
205
209
  const defaultLocale = input.project.locales.default;
206
210
  const { foreign, external, merged } = validationScopes(input.project, options);
207
211
  const opaqueForeign = opaqueForeignTokens(foreign);
@@ -215,11 +219,9 @@ function validateInterpolation(input, options = {}) {
215
219
  return schema.properties.get(scope)?.has(name) ?? false;
216
220
  };
217
221
  const checkString = (nodeId, id, voicedLine) => {
218
- for (const t of tables) {
219
- const text = t.strings[id];
220
- if (text === void 0) continue;
221
- const field = `text[${t.locale}]`;
222
- for (const slot of extractSlots(text)) {
222
+ for (const [locale, table] of byLocale) {
223
+ const field = `text[${locale}]`;
224
+ for (const text of table.get(id) ?? []) for (const slot of extractSlots(text)) {
223
225
  if (voicedLine) {
224
226
  issues.push({
225
227
  nodeId,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@patterkit/compiler",
3
- "version": "0.4.5",
3
+ "version": "0.4.7",
4
4
  "description": "Patter compiler: compile condition/effect expressions, validate them, and export source to the runtime bundle.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -34,9 +34,9 @@
34
34
  "build": "tsup src/index.ts --format esm,cjs --dts --clean"
35
35
  },
36
36
  "dependencies": {
37
- "@patterkit/model": "0.9.0",
38
- "@patterkit/core": "0.3.2",
39
- "@patterkit/dialect": "0.2.5",
37
+ "@patterkit/model": "0.10.0",
38
+ "@patterkit/core": "0.4.1",
39
+ "@patterkit/dialect": "0.2.6",
40
40
  "@wildwinter/expr": "^0.5.0"
41
41
  },
42
42
  "peerDependencies": {