Merge branch 'master' into dev

dev
Nick O'Leary 2025-04-14 11:04:06 +01:00
commit 20fae98ecd
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9
8 changed files with 51 additions and 10 deletions

View File

@ -49,7 +49,7 @@
"hash-sum": "2.0.0",
"hpagent": "1.2.0",
"https-proxy-agent": "5.0.1",
"i18next": "21.10.0",
"i18next": "24.2.3",
"iconv-lite": "0.6.3",
"is-utf8": "0.2.1",
"js-yaml": "4.1.0",

View File

@ -27,7 +27,6 @@ RED.i18n = (function() {
apiRootUrl = options.apiRootUrl||"";
var preferredLanguage = localStorage.getItem("editor-language") || detectLanguage();
var opts = {
compatibilityJSON: 'v3',
backend: {
loadPath: apiRootUrl+'locales/__ns__?lng=__lng__',
},

View File

@ -401,7 +401,7 @@ RED.palette = (function() {
} else {
// Firefox doesn't do getIntersectionList and that
// makes us sad
nodes = RED.view.getLinksAtPoint(mouseX,mouseY);
nodes = RED.view.getLinksAtPoint(mouseX / RED.view.scale(), mouseY / RED.view.scale());
}
var mx = mouseX / RED.view.scale();
var my = mouseY / RED.view.scale();

View File

@ -1908,7 +1908,7 @@ RED.view = (function() {
} else {
// Firefox doesn"t do getIntersectionList and that
// makes us sad
nodes = RED.view.getLinksAtPoint(mouseX*scaleFactor,mouseY*scaleFactor);
nodes = RED.view.getLinksAtPoint(mouseX, mouseY);
}
for (var i=0;i<nodes.length;i++) {
if (d3.select(nodes[i]).classed("red-ui-flow-link-background")) {
@ -6333,6 +6333,12 @@ RED.view = (function() {
var links = outer.selectAll(".red-ui-flow-link-background")[0];
for (var i=0;i<links.length;i++) {
var bb = links[i].getBBox();
if (bb.height === 0) {
// For horizontal links, add some real height to make them easier
// to hit.
bb.y -= Math.max(5, 5 / scaleFactor);
bb.height = Math.max(10, 10 / scaleFactor);
}
if (x >= bb.x && y >= bb.y && x <= bb.x+bb.width && y <= bb.y+bb.height) {
result.push(links[i])
}

View File

@ -675,6 +675,9 @@ class Flow {
count: count
}
};
if (logMessage.hasOwnProperty('code')) {
errorMessage.error.code = logMessage.code;
}
if (logMessage.hasOwnProperty('stack')) {
errorMessage.error.stack = logMessage.stack;
}

View File

@ -80,6 +80,21 @@ function mergeCatalog(fallback,catalog) {
}
}
function migrateMessageCatalogV3toV4(catalog) {
const keys = Object.keys(catalog)
keys.forEach(key => {
if (typeof catalog[key] === 'object') {
catalog[key] = migrateMessageCatalogV3toV4(catalog[key])
} else if (key.endsWith('_plural')) {
const otherKey = key.replace('_plural', '_other')
if (!catalog[otherKey]) {
catalog[otherKey] = catalog[key]
}
delete catalog[key]
}
})
return catalog
}
async function readFile(lng, ns) {
if (/[^a-z\-]/i.test(lng)) {
@ -92,6 +107,12 @@ async function readFile(lng, ns) {
const content = await fs.promises.readFile(file, "utf8");
resourceCache[ns] = resourceCache[ns] || {};
resourceCache[ns][lng] = JSON.parse(content.replace(/^\uFEFF/, ''));
// Message catalogues are in i18next v3 format. That is no longer supported
// by i18next so we need to migrate any catalog to the v4 format.
// This primarily means mapping `FOO_plural` to `FOO_other`
resourceCache[ns][lng] = migrateMessageCatalogV3toV4(resourceCache[ns][lng])
var baseLng = lng.split('-')[0];
if (baseLng !== lng && resourceCache[ns][baseLng]) {
mergeCatalog(resourceCache[ns][baseLng], resourceCache[ns][lng]);
@ -139,7 +160,6 @@ function init(settings) {
initPromise = new Promise((resolve,reject) => {
i18n.use(MessageFileLoader);
var opt = {
compatibilityJSON: 'v3',
// debug: true,
defaultNS: "runtime",
ns: [],

View File

@ -838,14 +838,20 @@ function encodeObject(msg,opts) {
data: {
name: msg.msg.name,
message: hasOwnProperty.call(msg.msg, 'message') ? msg.msg.message : msg.msg.toString(),
code: msg.msg.code,
cause: cause + "",
stack: msg.msg.stack,
}
}
// Remove cause if not defined
if (!cause) {
// We optimistically added these properties to the object
// to ensure they are shown above 'stack'. But we don't want
// to include them if they are undefined
if (cause === undefined) {
delete value.data.cause
}
if (msg.msg.code === undefined) {
delete value.data.code
}
msg.msg = JSON.stringify(value);
} else if (msg.msg instanceof Buffer) {
msg.format = "buffer["+msg.msg.length+"]";
@ -914,20 +920,27 @@ function encodeObject(msg,opts) {
}
} else if (value instanceof Error || /Error/.test(value?.__proto__?.name)) {
const cause = value.cause
const code = value.code
value = {
__enc__: true,
type: 'error',
data: {
name: value.name,
message: hasOwnProperty.call(value, 'message') ? value.message : value.toString(),
code,
cause: cause + "",
stack: value.stack,
}
}
// Remove cause if not defined
if (!cause) {
// We optimistically added these properties to the object
// to ensure they are shown above 'stack'. But we don't want
// to include them if they are undefined
if (cause === undefined) {
delete value.data.cause
}
if (code === undefined) {
delete value.data.code
}
} else if (Array.isArray(value) && value.length > debuglength) {
value = {
__enc__: true,

View File

@ -16,7 +16,7 @@
],
"dependencies": {
"fs-extra": "11.2.0",
"i18next": "21.10.0",
"i18next": "24.2.3",
"json-stringify-safe": "5.0.1",
"jsonata": "2.0.5",
"lodash.clonedeep": "^4.5.0",