Skip to content

Commit

Permalink
Update build
Browse files Browse the repository at this point in the history
  • Loading branch information
Raiondesu committed Dec 20, 2023
1 parent a662ff7 commit 9b972d0
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 31 deletions.
24 changes: 12 additions & 12 deletions packages/plugins/arrays/dist/index.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,18 @@ function match(value) {
return Array.isArray(value);
}
var ArraysPlugin = (defaultSeparator = " ") => (0, import_plugins.createPlugin)("ArraysPlugin", match, {
translate(referenceParams, separator = defaultSeparator) {
translate(referenceParamsByKey, separator = defaultSeparator) {
const startsWithIndex = /^.*?:/;
const processReference = (referencedKey) => {
if (startsWithIndex.test(referencedKey)) {
const [argIndexName, inputKey] = referencedKey.split(":");
const argIndex = isNaN(Number(argIndexName)) ? 0 : Number(argIndexName);
const references = normalizeRefs(referenceParams, inputKey);
const references = normalizeRefs(referenceParamsByKey, inputKey);
return [String(references[argIndex])];
}
const result2 = referencedKey in referenceParams ? this.translate(
const result2 = referencedKey in referenceParamsByKey ? this.translate(
referencedKey,
...normalizeRefs(referenceParams, referencedKey)
...normalizeRefs(referenceParamsByKey, referencedKey)
) : this.translate(referencedKey);
if (typeof result2 === "string") {
return [result2];
Expand All @@ -50,18 +50,18 @@ var ArraysPlugin = (defaultSeparator = " ") => (0, import_plugins.createPlugin)(
if (typeof refK === "string") {
return [...arr, ...processReference(refK)];
}
const refParamK = Object.keys(refK)[0];
if (typeof referenceParams[refParamK] === "undefined" && refParamK in refK) {
referenceParams[refParamK] = normalizeRefs(refK, refParamK);
} else if (refParamK in refK) {
const references = normalizeRefs(referenceParams, refParamK);
const inlineParams = normalizeRefs(refK, refParamK);
referenceParams[refParamK] = references.map((param, i) => {
const refParamKey = Object.keys(refK)[0];
if (typeof referenceParamsByKey[refParamKey] === "undefined" && refParamKey in refK) {
referenceParamsByKey[refParamKey] = normalizeRefs(refK, refParamKey);
} else if (refParamKey in refK) {
const referenceParams = normalizeRefs(referenceParamsByKey, refParamKey);
const inlineParams = normalizeRefs(refK, refParamKey);
referenceParamsByKey[refParamKey] = referenceParams.map((param, i) => {
const inlineParam = inlineParams[i];
return typeof param === "object" && typeof inlineParam === "object" ? { ...inlineParam, ...param } : param ?? inlineParam;
});
}
return [...arr, ...processReference(refParamK)];
return [...arr, ...processReference(refParamKey)];
}, []);
if (typeof separator === "string") {
return result.join(separator);
Expand Down
24 changes: 12 additions & 12 deletions packages/plugins/arrays/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ function match(value) {
return Array.isArray(value);
}
var ArraysPlugin = (defaultSeparator = " ") => createPlugin("ArraysPlugin", match, {
translate(referenceParams, separator = defaultSeparator) {
translate(referenceParamsByKey, separator = defaultSeparator) {
const startsWithIndex = /^.*?:/;
const processReference = (referencedKey) => {
if (startsWithIndex.test(referencedKey)) {
const [argIndexName, inputKey] = referencedKey.split(":");
const argIndex = isNaN(Number(argIndexName)) ? 0 : Number(argIndexName);
const references = normalizeRefs(referenceParams, inputKey);
const references = normalizeRefs(referenceParamsByKey, inputKey);
return [String(references[argIndex])];
}
const result2 = referencedKey in referenceParams ? this.translate(
const result2 = referencedKey in referenceParamsByKey ? this.translate(
referencedKey,
...normalizeRefs(referenceParams, referencedKey)
...normalizeRefs(referenceParamsByKey, referencedKey)
) : this.translate(referencedKey);
if (typeof result2 === "string") {
return [result2];
Expand All @@ -26,18 +26,18 @@ var ArraysPlugin = (defaultSeparator = " ") => createPlugin("ArraysPlugin", matc
if (typeof refK === "string") {
return [...arr, ...processReference(refK)];
}
const refParamK = Object.keys(refK)[0];
if (typeof referenceParams[refParamK] === "undefined" && refParamK in refK) {
referenceParams[refParamK] = normalizeRefs(refK, refParamK);
} else if (refParamK in refK) {
const references = normalizeRefs(referenceParams, refParamK);
const inlineParams = normalizeRefs(refK, refParamK);
referenceParams[refParamK] = references.map((param, i) => {
const refParamKey = Object.keys(refK)[0];
if (typeof referenceParamsByKey[refParamKey] === "undefined" && refParamKey in refK) {
referenceParamsByKey[refParamKey] = normalizeRefs(refK, refParamKey);
} else if (refParamKey in refK) {
const referenceParams = normalizeRefs(referenceParamsByKey, refParamKey);
const inlineParams = normalizeRefs(refK, refParamKey);
referenceParamsByKey[refParamKey] = referenceParams.map((param, i) => {
const inlineParam = inlineParams[i];
return typeof param === "object" && typeof inlineParam === "object" ? { ...inlineParam, ...param } : param ?? inlineParam;
});
}
return [...arr, ...processReference(refParamK)];
return [...arr, ...processReference(refParamKey)];
}, []);
if (typeof separator === "string") {
return result.join(separator);
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/arrays/dist/metafile-cjs.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"inputs":{"packages/plugins/arrays/src/index.ts":{"bytes":5879,"imports":[{"path":"intl-schematic","kind":"import-statement","external":true},{"path":"intl-schematic/plugins","kind":"import-statement","external":true}],"format":"esm"}},"outputs":{"packages/plugins/arrays/dist/index.cjs":{"imports":[{"path":"intl-schematic/plugins","kind":"require-call","external":true}],"exports":[],"entryPoint":"packages/plugins/arrays/src/index.ts","inputs":{"packages/plugins/arrays/src/index.ts":{"bytesInOutput":2283}},"bytes":3123}}}
{"inputs":{"packages/plugins/arrays/src/index.ts":{"bytes":5945,"imports":[{"path":"intl-schematic","kind":"import-statement","external":true},{"path":"intl-schematic/plugins","kind":"import-statement","external":true}],"format":"esm"}},"outputs":{"packages/plugins/arrays/dist/index.cjs":{"imports":[{"path":"intl-schematic/plugins","kind":"require-call","external":true}],"exports":[],"entryPoint":"packages/plugins/arrays/src/index.ts","inputs":{"packages/plugins/arrays/src/index.ts":{"bytesInOutput":2353}},"bytes":3193}}}
2 changes: 1 addition & 1 deletion packages/plugins/arrays/dist/metafile-esm.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"inputs":{"packages/plugins/arrays/src/index.ts":{"bytes":5879,"imports":[{"path":"intl-schematic","kind":"import-statement","external":true},{"path":"intl-schematic/plugins","kind":"import-statement","external":true}],"format":"esm"}},"outputs":{"packages/plugins/arrays/dist/index.js":{"imports":[{"path":"intl-schematic/plugins","kind":"import-statement","external":true}],"exports":["ArraysPlugin"],"entryPoint":"packages/plugins/arrays/src/index.ts","inputs":{"packages/plugins/arrays/src/index.ts":{"bytesInOutput":2133}},"bytes":2200}}}
{"inputs":{"packages/plugins/arrays/src/index.ts":{"bytes":5945,"imports":[{"path":"intl-schematic","kind":"import-statement","external":true},{"path":"intl-schematic/plugins","kind":"import-statement","external":true}],"format":"esm"}},"outputs":{"packages/plugins/arrays/dist/index.js":{"imports":[{"path":"intl-schematic/plugins","kind":"import-statement","external":true}],"exports":["ArraysPlugin"],"entryPoint":"packages/plugins/arrays/src/index.ts","inputs":{"packages/plugins/arrays/src/index.ts":{"bytesInOutput":2203}},"bytes":2270}}}
10 changes: 7 additions & 3 deletions packages/plugins/arrays/property.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"title": "Reference to an argument of another property processed by a plugin (parametrized translation property)",
"description": "Value must refer to a property that is already referenced in this array",
"type": "string",
"pattern": "\\d+:.+"
"pattern": "^\\d+:.+"
}, {
"title": "A single part of a plain-string translation property",
"description": "Can be a reference key of another translation property",
Expand All @@ -17,9 +17,13 @@
"description": "Inserts the parametrized value into the string, provide an object with key that references the property and a value to serve as parameters if applicable. If the key doesn't reference a parametrized property, simply leave the array empty - [].",
"type": "object",
"patternProperties": {
"^.+$": {
"^.+": {
"title": "A reference to a parametrized translation property",
"type": "array"
},
"^\\d:.+": {
"title": "A reference to an argument of another property processed by a plugin (parametrized translation property)",
"type": "array"
}
},
"maxProperties": 1,
Expand All @@ -28,7 +32,7 @@
},
"examples": [
"Translated text",
["Long", "translated", "text"],
["Multiline", "translated", "text"],
["Long", "translated", "text with", { "keys/reference-multiple": [] }, "to other translation propertys"]
]
}
2 changes: 1 addition & 1 deletion packages/plugins/defaults/dist/metafile-cjs.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"inputs":{"packages/plugins/defaults/src/index.ts":{"bytes":1185,"imports":[{"path":"@intl-schematic/plugin-locale","kind":"import-statement","external":true},{"path":"@intl-schematic/plugin-arrays","kind":"import-statement","external":true},{"path":"@intl-schematic/plugin-processors/default","kind":"import-statement","external":true},{"path":"@intl-schematic/plugin-processors","kind":"import-statement","external":true},{"path":"intl-schematic/plugins","kind":"import-statement","external":true},{"path":"@intl-schematic/plugin-arrays","kind":"import-statement","external":true},{"path":"@intl-schematic/plugin-locale","kind":"import-statement","external":true},{"path":"@intl-schematic/plugin-processors","kind":"import-statement","external":true},{"path":"@intl-schematic/plugin-processors/default","kind":"import-statement","external":true},{"path":"@intl-schematic/plugin-processors/dictionary","kind":"import-statement","external":true}],"format":"esm"}},"outputs":{"packages/plugins/defaults/dist/index.cjs":{"imports":[{"path":"@intl-schematic/plugin-locale","kind":"require-call","external":true},{"path":"@intl-schematic/plugin-arrays","kind":"require-call","external":true},{"path":"@intl-schematic/plugin-processors","kind":"require-call","external":true},{"path":"@intl-schematic/plugin-arrays","kind":"require-call","external":true},{"path":"@intl-schematic/plugin-locale","kind":"require-call","external":true},{"path":"@intl-schematic/plugin-processors","kind":"require-call","external":true},{"path":"@intl-schematic/plugin-processors/default","kind":"require-call","external":true},{"path":"@intl-schematic/plugin-processors/dictionary","kind":"require-call","external":true}],"exports":[],"entryPoint":"packages/plugins/defaults/src/index.ts","inputs":{"packages/plugins/defaults/src/index.ts":{"bytesInOutput":1059}},"bytes":2047}}}
{"inputs":{"packages/plugins/defaults/src/index.ts":{"bytes":1078,"imports":[{"path":"@intl-schematic/plugin-locale","kind":"import-statement","external":true},{"path":"@intl-schematic/plugin-arrays","kind":"import-statement","external":true},{"path":"@intl-schematic/plugin-processors","kind":"import-statement","external":true},{"path":"intl-schematic/plugins","kind":"import-statement","external":true},{"path":"@intl-schematic/plugin-arrays","kind":"import-statement","external":true},{"path":"@intl-schematic/plugin-locale","kind":"import-statement","external":true},{"path":"@intl-schematic/plugin-processors","kind":"import-statement","external":true},{"path":"@intl-schematic/plugin-processors/default","kind":"import-statement","external":true},{"path":"@intl-schematic/plugin-processors/dictionary","kind":"import-statement","external":true}],"format":"esm"}},"outputs":{"packages/plugins/defaults/dist/index.cjs":{"imports":[{"path":"@intl-schematic/plugin-locale","kind":"require-call","external":true},{"path":"@intl-schematic/plugin-arrays","kind":"require-call","external":true},{"path":"@intl-schematic/plugin-processors","kind":"require-call","external":true},{"path":"@intl-schematic/plugin-arrays","kind":"require-call","external":true},{"path":"@intl-schematic/plugin-locale","kind":"require-call","external":true},{"path":"@intl-schematic/plugin-processors","kind":"require-call","external":true},{"path":"@intl-schematic/plugin-processors/default","kind":"require-call","external":true},{"path":"@intl-schematic/plugin-processors/dictionary","kind":"require-call","external":true}],"exports":[],"entryPoint":"packages/plugins/defaults/src/index.ts","inputs":{"packages/plugins/defaults/src/index.ts":{"bytesInOutput":1059}},"bytes":2047}}}
2 changes: 1 addition & 1 deletion packages/plugins/defaults/dist/metafile-esm.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"inputs":{"packages/plugins/defaults/src/index.ts":{"bytes":1185,"imports":[{"path":"@intl-schematic/plugin-locale","kind":"import-statement","external":true},{"path":"@intl-schematic/plugin-arrays","kind":"import-statement","external":true},{"path":"@intl-schematic/plugin-processors/default","kind":"import-statement","external":true},{"path":"@intl-schematic/plugin-processors","kind":"import-statement","external":true},{"path":"intl-schematic/plugins","kind":"import-statement","external":true},{"path":"@intl-schematic/plugin-arrays","kind":"import-statement","external":true},{"path":"@intl-schematic/plugin-locale","kind":"import-statement","external":true},{"path":"@intl-schematic/plugin-processors","kind":"import-statement","external":true},{"path":"@intl-schematic/plugin-processors/default","kind":"import-statement","external":true},{"path":"@intl-schematic/plugin-processors/dictionary","kind":"import-statement","external":true}],"format":"esm"}},"outputs":{"packages/plugins/defaults/dist/index.js":{"imports":[{"path":"@intl-schematic/plugin-locale","kind":"import-statement","external":true},{"path":"@intl-schematic/plugin-arrays","kind":"import-statement","external":true},{"path":"@intl-schematic/plugin-processors","kind":"import-statement","external":true},{"path":"@intl-schematic/plugin-arrays","kind":"import-statement","external":true},{"path":"@intl-schematic/plugin-locale","kind":"import-statement","external":true},{"path":"@intl-schematic/plugin-processors","kind":"import-statement","external":true},{"path":"@intl-schematic/plugin-processors/default","kind":"import-statement","external":true},{"path":"@intl-schematic/plugin-processors/dictionary","kind":"import-statement","external":true}],"exports":["defaultPlugins"],"entryPoint":"packages/plugins/defaults/src/index.ts","inputs":{"packages/plugins/defaults/src/index.ts":{"bytesInOutput":651}},"bytes":722}}}
{"inputs":{"packages/plugins/defaults/src/index.ts":{"bytes":1078,"imports":[{"path":"@intl-schematic/plugin-locale","kind":"import-statement","external":true},{"path":"@intl-schematic/plugin-arrays","kind":"import-statement","external":true},{"path":"@intl-schematic/plugin-processors","kind":"import-statement","external":true},{"path":"intl-schematic/plugins","kind":"import-statement","external":true},{"path":"@intl-schematic/plugin-arrays","kind":"import-statement","external":true},{"path":"@intl-schematic/plugin-locale","kind":"import-statement","external":true},{"path":"@intl-schematic/plugin-processors","kind":"import-statement","external":true},{"path":"@intl-schematic/plugin-processors/default","kind":"import-statement","external":true},{"path":"@intl-schematic/plugin-processors/dictionary","kind":"import-statement","external":true}],"format":"esm"}},"outputs":{"packages/plugins/defaults/dist/index.js":{"imports":[{"path":"@intl-schematic/plugin-locale","kind":"import-statement","external":true},{"path":"@intl-schematic/plugin-arrays","kind":"import-statement","external":true},{"path":"@intl-schematic/plugin-processors","kind":"import-statement","external":true},{"path":"@intl-schematic/plugin-arrays","kind":"import-statement","external":true},{"path":"@intl-schematic/plugin-locale","kind":"import-statement","external":true},{"path":"@intl-schematic/plugin-processors","kind":"import-statement","external":true},{"path":"@intl-schematic/plugin-processors/default","kind":"import-statement","external":true},{"path":"@intl-schematic/plugin-processors/dictionary","kind":"import-statement","external":true}],"exports":["defaultPlugins"],"entryPoint":"packages/plugins/defaults/src/index.ts","inputs":{"packages/plugins/defaults/src/index.ts":{"bytesInOutput":651}},"bytes":722}}}

0 comments on commit 9b972d0

Please sign in to comment.