@uniformdev/tms-sdk 19.154.1-alpha.22 → 19.154.1-alpha.24
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.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.esm.js +108 -58
- package/dist/index.js +117 -69
- package/dist/index.mjs +108 -58
- package/package.json +4 -4
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ComponentInstance, RootComponentInstance, EntryData, CanvasClient, CompositionGetResponse, ContentClient, Entry } from '@uniformdev/canvas';
|
|
2
2
|
|
|
3
|
-
type ComponentTranslationPayload = Pick<ComponentInstance, 'type' | 'parameters' | '_overrides'>;
|
|
3
|
+
type ComponentTranslationPayload = Pick<ComponentInstance, '_id' | 'type' | 'parameters' | 'slots' | '_overrides'>;
|
|
4
4
|
type TranslationPayload = {
|
|
5
5
|
schemaVersion: number;
|
|
6
6
|
metadata: {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ComponentInstance, RootComponentInstance, EntryData, CanvasClient, CompositionGetResponse, ContentClient, Entry } from '@uniformdev/canvas';
|
|
2
2
|
|
|
3
|
-
type ComponentTranslationPayload = Pick<ComponentInstance, 'type' | 'parameters' | '_overrides'>;
|
|
3
|
+
type ComponentTranslationPayload = Pick<ComponentInstance, '_id' | 'type' | 'parameters' | 'slots' | '_overrides'>;
|
|
4
4
|
type TranslationPayload = {
|
|
5
5
|
schemaVersion: number;
|
|
6
6
|
metadata: {
|
package/dist/index.esm.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// src/collectTranslationPayload.ts
|
|
2
2
|
import {
|
|
3
3
|
bindVariables,
|
|
4
|
-
walkNodeTree
|
|
4
|
+
walkNodeTree as walkNodeTree2
|
|
5
5
|
} from "@uniformdev/canvas";
|
|
6
6
|
import { isRichTextValue, isRichTextValueConsideredEmpty as isRichTextValueConsideredEmpty2 } from "@uniformdev/richtext";
|
|
7
7
|
|
|
@@ -15,6 +15,9 @@ var SUPPORTED_PARAM_TYPES = {
|
|
|
15
15
|
};
|
|
16
16
|
|
|
17
17
|
// src/translationHelpers.ts
|
|
18
|
+
import {
|
|
19
|
+
walkNodeTree
|
|
20
|
+
} from "@uniformdev/canvas";
|
|
18
21
|
import { isRichTextValueConsideredEmpty } from "@uniformdev/richtext";
|
|
19
22
|
import { dequal } from "dequal/lite";
|
|
20
23
|
var MERGE_TRANSLATION_ERRORS = {
|
|
@@ -156,22 +159,33 @@ var processOverrideTranslation = ({
|
|
|
156
159
|
if (!slotComponent.type || !slotComponent._id) {
|
|
157
160
|
return;
|
|
158
161
|
}
|
|
159
|
-
const
|
|
162
|
+
const originalSlotComponent = originalSlotComponents.find(
|
|
160
163
|
(x) => x._id === slotComponent._id && x.type === slotComponent.type
|
|
161
164
|
);
|
|
162
|
-
if (!
|
|
165
|
+
if (!originalSlotComponent) {
|
|
163
166
|
return;
|
|
164
167
|
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
168
|
+
walkNodeTree(slotComponent, ({ node: component, type, actions }) => {
|
|
169
|
+
if (type !== "component" || !component._id || !component.type) {
|
|
170
|
+
actions.stopProcessingDescendants();
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
const originalComponent = findComponentInNodeTree(originalSlotComponent, component._id);
|
|
174
|
+
if (!originalComponent || originalComponent.type !== component.type) {
|
|
175
|
+
actions.stopProcessingDescendants();
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
const { updated: isComponentUpdated } = processComponentTranslation({
|
|
179
|
+
uniformSourceLocale,
|
|
180
|
+
uniformTargetLocale,
|
|
181
|
+
overrideModifiedTargetLocale,
|
|
182
|
+
originalNode: originalComponent,
|
|
183
|
+
translatedComponent: component
|
|
184
|
+
});
|
|
185
|
+
if (isComponentUpdated) {
|
|
186
|
+
updated = true;
|
|
187
|
+
}
|
|
171
188
|
});
|
|
172
|
-
if (isComponentUpdated) {
|
|
173
|
-
updated = true;
|
|
174
|
-
}
|
|
175
189
|
});
|
|
176
190
|
});
|
|
177
191
|
return { updated };
|
|
@@ -195,6 +209,16 @@ var isSameParameterValue = ({
|
|
|
195
209
|
return left === right;
|
|
196
210
|
}
|
|
197
211
|
};
|
|
212
|
+
var findComponentInNodeTree = (root, id) => {
|
|
213
|
+
let result;
|
|
214
|
+
walkNodeTree(root, ({ node, actions }) => {
|
|
215
|
+
if (node._id === id) {
|
|
216
|
+
result = node;
|
|
217
|
+
actions.stopProcessingDescendants();
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
return result;
|
|
221
|
+
};
|
|
198
222
|
|
|
199
223
|
// src/collectTranslationPayload.ts
|
|
200
224
|
var MERGE_TRANSLATION_ERRORS2 = {
|
|
@@ -238,20 +262,22 @@ var collectTranslationPayload = ({
|
|
|
238
262
|
},
|
|
239
263
|
components: {}
|
|
240
264
|
};
|
|
241
|
-
|
|
265
|
+
walkNodeTree2(entity, ({ node, actions }) => {
|
|
242
266
|
if (!node.type || !node._id) {
|
|
243
267
|
actions.stopProcessingDescendants();
|
|
244
268
|
return;
|
|
245
269
|
}
|
|
246
|
-
const { parameters, _overrides } = collectFromNode({
|
|
270
|
+
const { _id, type, parameters, _overrides } = collectFromNode({
|
|
247
271
|
uniformSourceLocale,
|
|
248
272
|
uniformTargetLocale,
|
|
249
273
|
overrideModifiedTargetLocale,
|
|
250
|
-
node
|
|
274
|
+
node,
|
|
275
|
+
deep: false
|
|
251
276
|
});
|
|
252
277
|
if (parameters || _overrides) {
|
|
253
278
|
payload.components[node._id] = {
|
|
254
|
-
|
|
279
|
+
_id,
|
|
280
|
+
type,
|
|
255
281
|
parameters,
|
|
256
282
|
_overrides
|
|
257
283
|
};
|
|
@@ -260,14 +286,16 @@ var collectTranslationPayload = ({
|
|
|
260
286
|
return { payload };
|
|
261
287
|
};
|
|
262
288
|
var collectFromNode = ({
|
|
263
|
-
node,
|
|
264
289
|
uniformSourceLocale,
|
|
265
290
|
uniformTargetLocale,
|
|
266
|
-
overrideModifiedTargetLocale
|
|
291
|
+
overrideModifiedTargetLocale,
|
|
292
|
+
node,
|
|
293
|
+
deep
|
|
267
294
|
}) => {
|
|
268
|
-
var _a, _b;
|
|
269
|
-
const
|
|
270
|
-
const
|
|
295
|
+
var _a, _b, _c;
|
|
296
|
+
const collectedParameters = {};
|
|
297
|
+
const collectedSlots = {};
|
|
298
|
+
const collectedOverrides = {};
|
|
271
299
|
const componentParameters = "parameters" in node ? node.parameters : void 0;
|
|
272
300
|
const entryFields = "fields" in node ? node.fields : void 0;
|
|
273
301
|
Object.entries((_a = componentParameters != null ? componentParameters : entryFields) != null ? _a : {}).forEach(([paramKey, param]) => {
|
|
@@ -280,7 +308,7 @@ var collectFromNode = ({
|
|
|
280
308
|
if (!overrideModifiedTargetLocale && !isTargetLocaleUntouched(param.type, sourceLocaleValue, targetLocaleValue)) {
|
|
281
309
|
return;
|
|
282
310
|
}
|
|
283
|
-
|
|
311
|
+
collectedParameters[paramKey] = {
|
|
284
312
|
type: param.type,
|
|
285
313
|
locales: {
|
|
286
314
|
[TRANSLATION_PAYLOAD_SOURCE_KEY]: sourceLocaleValue,
|
|
@@ -289,10 +317,32 @@ var collectFromNode = ({
|
|
|
289
317
|
}
|
|
290
318
|
};
|
|
291
319
|
});
|
|
292
|
-
|
|
320
|
+
if (deep) {
|
|
321
|
+
Object.entries((_b = "slots" in node ? node.slots : null) != null ? _b : {}).forEach(([slotKey, slotComponents]) => {
|
|
322
|
+
slotComponents.map((slotComponent) => {
|
|
323
|
+
var _a2;
|
|
324
|
+
if (!slotComponent.type || !slotComponent._id) {
|
|
325
|
+
return;
|
|
326
|
+
}
|
|
327
|
+
const collectedNode = collectFromNode({
|
|
328
|
+
uniformSourceLocale,
|
|
329
|
+
uniformTargetLocale,
|
|
330
|
+
overrideModifiedTargetLocale,
|
|
331
|
+
node: slotComponent,
|
|
332
|
+
deep: true
|
|
333
|
+
});
|
|
334
|
+
const hasContent = collectedNode.parameters || collectedNode._overrides || collectedNode.slots;
|
|
335
|
+
if (hasContent) {
|
|
336
|
+
(_a2 = collectedSlots[slotKey]) != null ? _a2 : collectedSlots[slotKey] = [];
|
|
337
|
+
collectedSlots[slotKey].push(collectedNode);
|
|
338
|
+
}
|
|
339
|
+
});
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
Object.entries((_c = node._overrides) != null ? _c : {}).forEach(([overrideKey, override]) => {
|
|
293
343
|
var _a2, _b2;
|
|
294
344
|
Object.entries((_a2 = override.parameters) != null ? _a2 : {}).forEach(([paramKey, param]) => {
|
|
295
|
-
var _a3, _b3,
|
|
345
|
+
var _a3, _b3, _c2, _d, _e;
|
|
296
346
|
const sourceLocaleValue = (_a3 = param.locales) == null ? void 0 : _a3[uniformSourceLocale];
|
|
297
347
|
const targetLocaleValue = (_b3 = param.locales) == null ? void 0 : _b3[uniformTargetLocale];
|
|
298
348
|
if (!canTranslateParameterValue(param, sourceLocaleValue)) {
|
|
@@ -301,9 +351,9 @@ var collectFromNode = ({
|
|
|
301
351
|
if (!overrideModifiedTargetLocale && !isTargetLocaleUntouched(param.type, sourceLocaleValue, targetLocaleValue)) {
|
|
302
352
|
return;
|
|
303
353
|
}
|
|
304
|
-
(
|
|
305
|
-
(_e = (_d =
|
|
306
|
-
|
|
354
|
+
(_c2 = collectedOverrides[overrideKey]) != null ? _c2 : collectedOverrides[overrideKey] = {};
|
|
355
|
+
(_e = (_d = collectedOverrides[overrideKey]).parameters) != null ? _e : _d.parameters = {};
|
|
356
|
+
collectedOverrides[overrideKey].parameters[paramKey] = {
|
|
307
357
|
type: param.type,
|
|
308
358
|
locales: {
|
|
309
359
|
[TRANSLATION_PAYLOAD_SOURCE_KEY]: sourceLocaleValue,
|
|
@@ -314,38 +364,38 @@ var collectFromNode = ({
|
|
|
314
364
|
});
|
|
315
365
|
Object.entries((_b2 = override.slots) != null ? _b2 : {}).forEach(([slotKey, slotComponents]) => {
|
|
316
366
|
slotComponents.map((slotComponent) => {
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
if (parameters2 || _overrides) {
|
|
330
|
-
(_a3 = overrides[overrideKey]) != null ? _a3 : overrides[overrideKey] = {};
|
|
331
|
-
(_c = (_b3 = overrides[overrideKey]).slots) != null ? _c : _b3.slots = {};
|
|
332
|
-
(_e = (_d = overrides[overrideKey].slots)[slotKey]) != null ? _e : _d[slotKey] = [];
|
|
333
|
-
overrides[overrideKey].slots[slotKey].push({
|
|
334
|
-
_id: node2._id,
|
|
335
|
-
type: node2.type,
|
|
336
|
-
parameters: parameters2,
|
|
337
|
-
_overrides
|
|
338
|
-
});
|
|
339
|
-
}
|
|
367
|
+
var _a3, _b3, _c2, _d, _e;
|
|
368
|
+
if (!slotComponent.type || !slotComponent._id) {
|
|
369
|
+
return;
|
|
370
|
+
}
|
|
371
|
+
const collectedNode = collectFromNode({
|
|
372
|
+
uniformSourceLocale,
|
|
373
|
+
uniformTargetLocale,
|
|
374
|
+
overrideModifiedTargetLocale,
|
|
375
|
+
node: slotComponent,
|
|
376
|
+
// keep tree structure for `Slot Sections`
|
|
377
|
+
// to store whole `override` content in scope of current component
|
|
378
|
+
deep: true
|
|
340
379
|
});
|
|
380
|
+
const hasContent = collectedNode.parameters || collectedNode._overrides || collectedNode.slots;
|
|
381
|
+
if (hasContent) {
|
|
382
|
+
(_a3 = collectedOverrides[overrideKey]) != null ? _a3 : collectedOverrides[overrideKey] = {};
|
|
383
|
+
(_c2 = (_b3 = collectedOverrides[overrideKey]).slots) != null ? _c2 : _b3.slots = {};
|
|
384
|
+
(_e = (_d = collectedOverrides[overrideKey].slots)[slotKey]) != null ? _e : _d[slotKey] = [];
|
|
385
|
+
collectedOverrides[overrideKey].slots[slotKey].push(collectedNode);
|
|
386
|
+
}
|
|
341
387
|
});
|
|
342
388
|
});
|
|
343
389
|
});
|
|
344
|
-
const hasParameters = Object.keys(
|
|
345
|
-
const
|
|
390
|
+
const hasParameters = Object.keys(collectedParameters).length > 0;
|
|
391
|
+
const hasSlots = Object.keys(collectedSlots).length > 0;
|
|
392
|
+
const hasOverrides = Object.keys(collectedOverrides).length > 0;
|
|
346
393
|
return {
|
|
347
|
-
|
|
348
|
-
|
|
394
|
+
_id: node._id,
|
|
395
|
+
type: node.type,
|
|
396
|
+
parameters: hasParameters ? collectedParameters : void 0,
|
|
397
|
+
slots: hasSlots ? collectedSlots : void 0,
|
|
398
|
+
_overrides: hasOverrides ? collectedOverrides : void 0
|
|
349
399
|
};
|
|
350
400
|
};
|
|
351
401
|
var canTranslateParameterValue = (parameter, value) => {
|
|
@@ -442,7 +492,7 @@ var getEntryForTranslation = async ({
|
|
|
442
492
|
import { CANVAS_DRAFT_STATE as CANVAS_DRAFT_STATE4 } from "@uniformdev/canvas";
|
|
443
493
|
|
|
444
494
|
// src/translateComposition.ts
|
|
445
|
-
import { CANVAS_DRAFT_STATE as CANVAS_DRAFT_STATE3, walkNodeTree as
|
|
495
|
+
import { CANVAS_DRAFT_STATE as CANVAS_DRAFT_STATE3, walkNodeTree as walkNodeTree3 } from "@uniformdev/canvas";
|
|
446
496
|
import { produce } from "immer";
|
|
447
497
|
var translateComposition = ({
|
|
448
498
|
composition,
|
|
@@ -473,7 +523,7 @@ var translateComposition = ({
|
|
|
473
523
|
(_b = (_a2 = draft.composition)._locales) != null ? _b : _a2._locales = [];
|
|
474
524
|
draft.composition._locales.push(uniformTargetLocale);
|
|
475
525
|
}
|
|
476
|
-
|
|
526
|
+
walkNodeTree3(draft.composition, ({ node: component, type, actions }) => {
|
|
477
527
|
if (type !== "component") {
|
|
478
528
|
actions.stopProcessingDescendants();
|
|
479
529
|
return;
|
|
@@ -572,7 +622,7 @@ var defaultUpdateComposition = async ({
|
|
|
572
622
|
import { CANVAS_DRAFT_STATE as CANVAS_DRAFT_STATE6 } from "@uniformdev/canvas";
|
|
573
623
|
|
|
574
624
|
// src/translateEntry.ts
|
|
575
|
-
import { CANVAS_DRAFT_STATE as CANVAS_DRAFT_STATE5, walkNodeTree as
|
|
625
|
+
import { CANVAS_DRAFT_STATE as CANVAS_DRAFT_STATE5, walkNodeTree as walkNodeTree4 } from "@uniformdev/canvas";
|
|
576
626
|
import { produce as produce2 } from "immer";
|
|
577
627
|
var translateEntry = ({
|
|
578
628
|
entry,
|
|
@@ -603,7 +653,7 @@ var translateEntry = ({
|
|
|
603
653
|
(_b = (_a2 = draft.entry)._locales) != null ? _b : _a2._locales = [];
|
|
604
654
|
draft.entry._locales.push(uniformTargetLocale);
|
|
605
655
|
}
|
|
606
|
-
|
|
656
|
+
walkNodeTree4(draft.entry, ({ node: component, type, actions }) => {
|
|
607
657
|
if (type !== "entry") {
|
|
608
658
|
actions.stopProcessingDescendants();
|
|
609
659
|
return;
|
package/dist/index.js
CHANGED
|
@@ -32,7 +32,7 @@ __export(src_exports, {
|
|
|
32
32
|
module.exports = __toCommonJS(src_exports);
|
|
33
33
|
|
|
34
34
|
// src/collectTranslationPayload.ts
|
|
35
|
-
var
|
|
35
|
+
var import_canvas2 = require("@uniformdev/canvas");
|
|
36
36
|
var import_richtext2 = require("@uniformdev/richtext");
|
|
37
37
|
|
|
38
38
|
// src/constants.ts
|
|
@@ -45,6 +45,7 @@ var SUPPORTED_PARAM_TYPES = {
|
|
|
45
45
|
};
|
|
46
46
|
|
|
47
47
|
// src/translationHelpers.ts
|
|
48
|
+
var import_canvas = require("@uniformdev/canvas");
|
|
48
49
|
var import_richtext = require("@uniformdev/richtext");
|
|
49
50
|
var import_lite = require("dequal/lite");
|
|
50
51
|
var MERGE_TRANSLATION_ERRORS = {
|
|
@@ -186,22 +187,33 @@ var processOverrideTranslation = ({
|
|
|
186
187
|
if (!slotComponent.type || !slotComponent._id) {
|
|
187
188
|
return;
|
|
188
189
|
}
|
|
189
|
-
const
|
|
190
|
+
const originalSlotComponent = originalSlotComponents.find(
|
|
190
191
|
(x) => x._id === slotComponent._id && x.type === slotComponent.type
|
|
191
192
|
);
|
|
192
|
-
if (!
|
|
193
|
+
if (!originalSlotComponent) {
|
|
193
194
|
return;
|
|
194
195
|
}
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
196
|
+
(0, import_canvas.walkNodeTree)(slotComponent, ({ node: component, type, actions }) => {
|
|
197
|
+
if (type !== "component" || !component._id || !component.type) {
|
|
198
|
+
actions.stopProcessingDescendants();
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
const originalComponent = findComponentInNodeTree(originalSlotComponent, component._id);
|
|
202
|
+
if (!originalComponent || originalComponent.type !== component.type) {
|
|
203
|
+
actions.stopProcessingDescendants();
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
const { updated: isComponentUpdated } = processComponentTranslation({
|
|
207
|
+
uniformSourceLocale,
|
|
208
|
+
uniformTargetLocale,
|
|
209
|
+
overrideModifiedTargetLocale,
|
|
210
|
+
originalNode: originalComponent,
|
|
211
|
+
translatedComponent: component
|
|
212
|
+
});
|
|
213
|
+
if (isComponentUpdated) {
|
|
214
|
+
updated = true;
|
|
215
|
+
}
|
|
201
216
|
});
|
|
202
|
-
if (isComponentUpdated) {
|
|
203
|
-
updated = true;
|
|
204
|
-
}
|
|
205
217
|
});
|
|
206
218
|
});
|
|
207
219
|
return { updated };
|
|
@@ -225,6 +237,16 @@ var isSameParameterValue = ({
|
|
|
225
237
|
return left === right;
|
|
226
238
|
}
|
|
227
239
|
};
|
|
240
|
+
var findComponentInNodeTree = (root, id) => {
|
|
241
|
+
let result;
|
|
242
|
+
(0, import_canvas.walkNodeTree)(root, ({ node, actions }) => {
|
|
243
|
+
if (node._id === id) {
|
|
244
|
+
result = node;
|
|
245
|
+
actions.stopProcessingDescendants();
|
|
246
|
+
}
|
|
247
|
+
});
|
|
248
|
+
return result;
|
|
249
|
+
};
|
|
228
250
|
|
|
229
251
|
// src/collectTranslationPayload.ts
|
|
230
252
|
var MERGE_TRANSLATION_ERRORS2 = {
|
|
@@ -268,20 +290,22 @@ var collectTranslationPayload = ({
|
|
|
268
290
|
},
|
|
269
291
|
components: {}
|
|
270
292
|
};
|
|
271
|
-
(0,
|
|
293
|
+
(0, import_canvas2.walkNodeTree)(entity, ({ node, actions }) => {
|
|
272
294
|
if (!node.type || !node._id) {
|
|
273
295
|
actions.stopProcessingDescendants();
|
|
274
296
|
return;
|
|
275
297
|
}
|
|
276
|
-
const { parameters, _overrides } = collectFromNode({
|
|
298
|
+
const { _id, type, parameters, _overrides } = collectFromNode({
|
|
277
299
|
uniformSourceLocale,
|
|
278
300
|
uniformTargetLocale,
|
|
279
301
|
overrideModifiedTargetLocale,
|
|
280
|
-
node
|
|
302
|
+
node,
|
|
303
|
+
deep: false
|
|
281
304
|
});
|
|
282
305
|
if (parameters || _overrides) {
|
|
283
306
|
payload.components[node._id] = {
|
|
284
|
-
|
|
307
|
+
_id,
|
|
308
|
+
type,
|
|
285
309
|
parameters,
|
|
286
310
|
_overrides
|
|
287
311
|
};
|
|
@@ -290,14 +314,16 @@ var collectTranslationPayload = ({
|
|
|
290
314
|
return { payload };
|
|
291
315
|
};
|
|
292
316
|
var collectFromNode = ({
|
|
293
|
-
node,
|
|
294
317
|
uniformSourceLocale,
|
|
295
318
|
uniformTargetLocale,
|
|
296
|
-
overrideModifiedTargetLocale
|
|
319
|
+
overrideModifiedTargetLocale,
|
|
320
|
+
node,
|
|
321
|
+
deep
|
|
297
322
|
}) => {
|
|
298
|
-
var _a, _b;
|
|
299
|
-
const
|
|
300
|
-
const
|
|
323
|
+
var _a, _b, _c;
|
|
324
|
+
const collectedParameters = {};
|
|
325
|
+
const collectedSlots = {};
|
|
326
|
+
const collectedOverrides = {};
|
|
301
327
|
const componentParameters = "parameters" in node ? node.parameters : void 0;
|
|
302
328
|
const entryFields = "fields" in node ? node.fields : void 0;
|
|
303
329
|
Object.entries((_a = componentParameters != null ? componentParameters : entryFields) != null ? _a : {}).forEach(([paramKey, param]) => {
|
|
@@ -310,7 +336,7 @@ var collectFromNode = ({
|
|
|
310
336
|
if (!overrideModifiedTargetLocale && !isTargetLocaleUntouched(param.type, sourceLocaleValue, targetLocaleValue)) {
|
|
311
337
|
return;
|
|
312
338
|
}
|
|
313
|
-
|
|
339
|
+
collectedParameters[paramKey] = {
|
|
314
340
|
type: param.type,
|
|
315
341
|
locales: {
|
|
316
342
|
[TRANSLATION_PAYLOAD_SOURCE_KEY]: sourceLocaleValue,
|
|
@@ -319,10 +345,32 @@ var collectFromNode = ({
|
|
|
319
345
|
}
|
|
320
346
|
};
|
|
321
347
|
});
|
|
322
|
-
|
|
348
|
+
if (deep) {
|
|
349
|
+
Object.entries((_b = "slots" in node ? node.slots : null) != null ? _b : {}).forEach(([slotKey, slotComponents]) => {
|
|
350
|
+
slotComponents.map((slotComponent) => {
|
|
351
|
+
var _a2;
|
|
352
|
+
if (!slotComponent.type || !slotComponent._id) {
|
|
353
|
+
return;
|
|
354
|
+
}
|
|
355
|
+
const collectedNode = collectFromNode({
|
|
356
|
+
uniformSourceLocale,
|
|
357
|
+
uniformTargetLocale,
|
|
358
|
+
overrideModifiedTargetLocale,
|
|
359
|
+
node: slotComponent,
|
|
360
|
+
deep: true
|
|
361
|
+
});
|
|
362
|
+
const hasContent = collectedNode.parameters || collectedNode._overrides || collectedNode.slots;
|
|
363
|
+
if (hasContent) {
|
|
364
|
+
(_a2 = collectedSlots[slotKey]) != null ? _a2 : collectedSlots[slotKey] = [];
|
|
365
|
+
collectedSlots[slotKey].push(collectedNode);
|
|
366
|
+
}
|
|
367
|
+
});
|
|
368
|
+
});
|
|
369
|
+
}
|
|
370
|
+
Object.entries((_c = node._overrides) != null ? _c : {}).forEach(([overrideKey, override]) => {
|
|
323
371
|
var _a2, _b2;
|
|
324
372
|
Object.entries((_a2 = override.parameters) != null ? _a2 : {}).forEach(([paramKey, param]) => {
|
|
325
|
-
var _a3, _b3,
|
|
373
|
+
var _a3, _b3, _c2, _d, _e;
|
|
326
374
|
const sourceLocaleValue = (_a3 = param.locales) == null ? void 0 : _a3[uniformSourceLocale];
|
|
327
375
|
const targetLocaleValue = (_b3 = param.locales) == null ? void 0 : _b3[uniformTargetLocale];
|
|
328
376
|
if (!canTranslateParameterValue(param, sourceLocaleValue)) {
|
|
@@ -331,9 +379,9 @@ var collectFromNode = ({
|
|
|
331
379
|
if (!overrideModifiedTargetLocale && !isTargetLocaleUntouched(param.type, sourceLocaleValue, targetLocaleValue)) {
|
|
332
380
|
return;
|
|
333
381
|
}
|
|
334
|
-
(
|
|
335
|
-
(_e = (_d =
|
|
336
|
-
|
|
382
|
+
(_c2 = collectedOverrides[overrideKey]) != null ? _c2 : collectedOverrides[overrideKey] = {};
|
|
383
|
+
(_e = (_d = collectedOverrides[overrideKey]).parameters) != null ? _e : _d.parameters = {};
|
|
384
|
+
collectedOverrides[overrideKey].parameters[paramKey] = {
|
|
337
385
|
type: param.type,
|
|
338
386
|
locales: {
|
|
339
387
|
[TRANSLATION_PAYLOAD_SOURCE_KEY]: sourceLocaleValue,
|
|
@@ -344,38 +392,38 @@ var collectFromNode = ({
|
|
|
344
392
|
});
|
|
345
393
|
Object.entries((_b2 = override.slots) != null ? _b2 : {}).forEach(([slotKey, slotComponents]) => {
|
|
346
394
|
slotComponents.map((slotComponent) => {
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
if (parameters2 || _overrides) {
|
|
360
|
-
(_a3 = overrides[overrideKey]) != null ? _a3 : overrides[overrideKey] = {};
|
|
361
|
-
(_c = (_b3 = overrides[overrideKey]).slots) != null ? _c : _b3.slots = {};
|
|
362
|
-
(_e = (_d = overrides[overrideKey].slots)[slotKey]) != null ? _e : _d[slotKey] = [];
|
|
363
|
-
overrides[overrideKey].slots[slotKey].push({
|
|
364
|
-
_id: node2._id,
|
|
365
|
-
type: node2.type,
|
|
366
|
-
parameters: parameters2,
|
|
367
|
-
_overrides
|
|
368
|
-
});
|
|
369
|
-
}
|
|
395
|
+
var _a3, _b3, _c2, _d, _e;
|
|
396
|
+
if (!slotComponent.type || !slotComponent._id) {
|
|
397
|
+
return;
|
|
398
|
+
}
|
|
399
|
+
const collectedNode = collectFromNode({
|
|
400
|
+
uniformSourceLocale,
|
|
401
|
+
uniformTargetLocale,
|
|
402
|
+
overrideModifiedTargetLocale,
|
|
403
|
+
node: slotComponent,
|
|
404
|
+
// keep tree structure for `Slot Sections`
|
|
405
|
+
// to store whole `override` content in scope of current component
|
|
406
|
+
deep: true
|
|
370
407
|
});
|
|
408
|
+
const hasContent = collectedNode.parameters || collectedNode._overrides || collectedNode.slots;
|
|
409
|
+
if (hasContent) {
|
|
410
|
+
(_a3 = collectedOverrides[overrideKey]) != null ? _a3 : collectedOverrides[overrideKey] = {};
|
|
411
|
+
(_c2 = (_b3 = collectedOverrides[overrideKey]).slots) != null ? _c2 : _b3.slots = {};
|
|
412
|
+
(_e = (_d = collectedOverrides[overrideKey].slots)[slotKey]) != null ? _e : _d[slotKey] = [];
|
|
413
|
+
collectedOverrides[overrideKey].slots[slotKey].push(collectedNode);
|
|
414
|
+
}
|
|
371
415
|
});
|
|
372
416
|
});
|
|
373
417
|
});
|
|
374
|
-
const hasParameters = Object.keys(
|
|
375
|
-
const
|
|
418
|
+
const hasParameters = Object.keys(collectedParameters).length > 0;
|
|
419
|
+
const hasSlots = Object.keys(collectedSlots).length > 0;
|
|
420
|
+
const hasOverrides = Object.keys(collectedOverrides).length > 0;
|
|
376
421
|
return {
|
|
377
|
-
|
|
378
|
-
|
|
422
|
+
_id: node._id,
|
|
423
|
+
type: node.type,
|
|
424
|
+
parameters: hasParameters ? collectedParameters : void 0,
|
|
425
|
+
slots: hasSlots ? collectedSlots : void 0,
|
|
426
|
+
_overrides: hasOverrides ? collectedOverrides : void 0
|
|
379
427
|
};
|
|
380
428
|
};
|
|
381
429
|
var canTranslateParameterValue = (parameter, value) => {
|
|
@@ -386,7 +434,7 @@ var canTranslateParameterValue = (parameter, value) => {
|
|
|
386
434
|
if (value.trim().length === 0) {
|
|
387
435
|
return false;
|
|
388
436
|
}
|
|
389
|
-
const bindResult = (0,
|
|
437
|
+
const bindResult = (0, import_canvas2.bindVariables)({
|
|
390
438
|
variables: {},
|
|
391
439
|
value,
|
|
392
440
|
handleBinding: () => ""
|
|
@@ -419,12 +467,12 @@ var isTargetLocaleUntouched = (parameterType, sourceLocaleValue, targetLocaleVal
|
|
|
419
467
|
};
|
|
420
468
|
|
|
421
469
|
// src/getCompositionForTranslation.ts
|
|
422
|
-
var
|
|
470
|
+
var import_canvas3 = require("@uniformdev/canvas");
|
|
423
471
|
var getCompositionForTranslation = async ({
|
|
424
472
|
canvasClient,
|
|
425
473
|
compositionId,
|
|
426
474
|
releaseId,
|
|
427
|
-
state =
|
|
475
|
+
state = import_canvas3.CANVAS_DRAFT_STATE
|
|
428
476
|
}) => {
|
|
429
477
|
if (!compositionId) {
|
|
430
478
|
return void 0;
|
|
@@ -442,13 +490,13 @@ var getCompositionForTranslation = async ({
|
|
|
442
490
|
};
|
|
443
491
|
|
|
444
492
|
// src/getEntryForTranslation.ts
|
|
445
|
-
var
|
|
493
|
+
var import_canvas4 = require("@uniformdev/canvas");
|
|
446
494
|
var getEntryForTranslation = async ({
|
|
447
495
|
contentClient,
|
|
448
496
|
entryId,
|
|
449
497
|
releaseId,
|
|
450
498
|
pattern,
|
|
451
|
-
state =
|
|
499
|
+
state = import_canvas4.CANVAS_DRAFT_STATE
|
|
452
500
|
}) => {
|
|
453
501
|
if (!entryId) {
|
|
454
502
|
return void 0;
|
|
@@ -469,10 +517,10 @@ var getEntryForTranslation = async ({
|
|
|
469
517
|
};
|
|
470
518
|
|
|
471
519
|
// src/mergeCompositionTranslationToUniform.ts
|
|
472
|
-
var
|
|
520
|
+
var import_canvas6 = require("@uniformdev/canvas");
|
|
473
521
|
|
|
474
522
|
// src/translateComposition.ts
|
|
475
|
-
var
|
|
523
|
+
var import_canvas5 = require("@uniformdev/canvas");
|
|
476
524
|
var import_immer = require("immer");
|
|
477
525
|
var translateComposition = ({
|
|
478
526
|
composition,
|
|
@@ -498,12 +546,12 @@ var translateComposition = ({
|
|
|
498
546
|
let updated = false;
|
|
499
547
|
const translatedComposition = (0, import_immer.produce)(composition, (draft) => {
|
|
500
548
|
var _a2, _b;
|
|
501
|
-
draft.state =
|
|
549
|
+
draft.state = import_canvas5.CANVAS_DRAFT_STATE;
|
|
502
550
|
if (!compositionLocales.includes(uniformTargetLocale)) {
|
|
503
551
|
(_b = (_a2 = draft.composition)._locales) != null ? _b : _a2._locales = [];
|
|
504
552
|
draft.composition._locales.push(uniformTargetLocale);
|
|
505
553
|
}
|
|
506
|
-
(0,
|
|
554
|
+
(0, import_canvas5.walkNodeTree)(draft.composition, ({ node: component, type, actions }) => {
|
|
507
555
|
if (type !== "component") {
|
|
508
556
|
actions.stopProcessingDescendants();
|
|
509
557
|
return;
|
|
@@ -586,7 +634,7 @@ var getCurrentCompositionFromPayload = async ({
|
|
|
586
634
|
canvasClient,
|
|
587
635
|
compositionId,
|
|
588
636
|
releaseId,
|
|
589
|
-
state:
|
|
637
|
+
state: import_canvas6.CANVAS_DRAFT_STATE
|
|
590
638
|
});
|
|
591
639
|
return currentComposition;
|
|
592
640
|
};
|
|
@@ -599,10 +647,10 @@ var defaultUpdateComposition = async ({
|
|
|
599
647
|
};
|
|
600
648
|
|
|
601
649
|
// src/mergeEntryTranslationToUniform.ts
|
|
602
|
-
var
|
|
650
|
+
var import_canvas8 = require("@uniformdev/canvas");
|
|
603
651
|
|
|
604
652
|
// src/translateEntry.ts
|
|
605
|
-
var
|
|
653
|
+
var import_canvas7 = require("@uniformdev/canvas");
|
|
606
654
|
var import_immer2 = require("immer");
|
|
607
655
|
var translateEntry = ({
|
|
608
656
|
entry,
|
|
@@ -628,12 +676,12 @@ var translateEntry = ({
|
|
|
628
676
|
let updated = false;
|
|
629
677
|
const translatedEntry = (0, import_immer2.produce)(entry, (draft) => {
|
|
630
678
|
var _a2, _b;
|
|
631
|
-
draft.state =
|
|
679
|
+
draft.state = import_canvas7.CANVAS_DRAFT_STATE;
|
|
632
680
|
if (!entryLocales.includes(uniformTargetLocale)) {
|
|
633
681
|
(_b = (_a2 = draft.entry)._locales) != null ? _b : _a2._locales = [];
|
|
634
682
|
draft.entry._locales.push(uniformTargetLocale);
|
|
635
683
|
}
|
|
636
|
-
(0,
|
|
684
|
+
(0, import_canvas7.walkNodeTree)(draft.entry, ({ node: component, type, actions }) => {
|
|
637
685
|
if (type !== "entry") {
|
|
638
686
|
actions.stopProcessingDescendants();
|
|
639
687
|
return;
|
|
@@ -718,7 +766,7 @@ var getCurrentEntryFromPayload = async ({
|
|
|
718
766
|
entryId,
|
|
719
767
|
releaseId,
|
|
720
768
|
pattern: entityType === "entryPattern",
|
|
721
|
-
state:
|
|
769
|
+
state: import_canvas8.CANVAS_DRAFT_STATE
|
|
722
770
|
});
|
|
723
771
|
return currentEntry;
|
|
724
772
|
};
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// src/collectTranslationPayload.ts
|
|
2
2
|
import {
|
|
3
3
|
bindVariables,
|
|
4
|
-
walkNodeTree
|
|
4
|
+
walkNodeTree as walkNodeTree2
|
|
5
5
|
} from "@uniformdev/canvas";
|
|
6
6
|
import { isRichTextValue, isRichTextValueConsideredEmpty as isRichTextValueConsideredEmpty2 } from "@uniformdev/richtext";
|
|
7
7
|
|
|
@@ -15,6 +15,9 @@ var SUPPORTED_PARAM_TYPES = {
|
|
|
15
15
|
};
|
|
16
16
|
|
|
17
17
|
// src/translationHelpers.ts
|
|
18
|
+
import {
|
|
19
|
+
walkNodeTree
|
|
20
|
+
} from "@uniformdev/canvas";
|
|
18
21
|
import { isRichTextValueConsideredEmpty } from "@uniformdev/richtext";
|
|
19
22
|
import { dequal } from "dequal/lite";
|
|
20
23
|
var MERGE_TRANSLATION_ERRORS = {
|
|
@@ -156,22 +159,33 @@ var processOverrideTranslation = ({
|
|
|
156
159
|
if (!slotComponent.type || !slotComponent._id) {
|
|
157
160
|
return;
|
|
158
161
|
}
|
|
159
|
-
const
|
|
162
|
+
const originalSlotComponent = originalSlotComponents.find(
|
|
160
163
|
(x) => x._id === slotComponent._id && x.type === slotComponent.type
|
|
161
164
|
);
|
|
162
|
-
if (!
|
|
165
|
+
if (!originalSlotComponent) {
|
|
163
166
|
return;
|
|
164
167
|
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
168
|
+
walkNodeTree(slotComponent, ({ node: component, type, actions }) => {
|
|
169
|
+
if (type !== "component" || !component._id || !component.type) {
|
|
170
|
+
actions.stopProcessingDescendants();
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
const originalComponent = findComponentInNodeTree(originalSlotComponent, component._id);
|
|
174
|
+
if (!originalComponent || originalComponent.type !== component.type) {
|
|
175
|
+
actions.stopProcessingDescendants();
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
const { updated: isComponentUpdated } = processComponentTranslation({
|
|
179
|
+
uniformSourceLocale,
|
|
180
|
+
uniformTargetLocale,
|
|
181
|
+
overrideModifiedTargetLocale,
|
|
182
|
+
originalNode: originalComponent,
|
|
183
|
+
translatedComponent: component
|
|
184
|
+
});
|
|
185
|
+
if (isComponentUpdated) {
|
|
186
|
+
updated = true;
|
|
187
|
+
}
|
|
171
188
|
});
|
|
172
|
-
if (isComponentUpdated) {
|
|
173
|
-
updated = true;
|
|
174
|
-
}
|
|
175
189
|
});
|
|
176
190
|
});
|
|
177
191
|
return { updated };
|
|
@@ -195,6 +209,16 @@ var isSameParameterValue = ({
|
|
|
195
209
|
return left === right;
|
|
196
210
|
}
|
|
197
211
|
};
|
|
212
|
+
var findComponentInNodeTree = (root, id) => {
|
|
213
|
+
let result;
|
|
214
|
+
walkNodeTree(root, ({ node, actions }) => {
|
|
215
|
+
if (node._id === id) {
|
|
216
|
+
result = node;
|
|
217
|
+
actions.stopProcessingDescendants();
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
return result;
|
|
221
|
+
};
|
|
198
222
|
|
|
199
223
|
// src/collectTranslationPayload.ts
|
|
200
224
|
var MERGE_TRANSLATION_ERRORS2 = {
|
|
@@ -238,20 +262,22 @@ var collectTranslationPayload = ({
|
|
|
238
262
|
},
|
|
239
263
|
components: {}
|
|
240
264
|
};
|
|
241
|
-
|
|
265
|
+
walkNodeTree2(entity, ({ node, actions }) => {
|
|
242
266
|
if (!node.type || !node._id) {
|
|
243
267
|
actions.stopProcessingDescendants();
|
|
244
268
|
return;
|
|
245
269
|
}
|
|
246
|
-
const { parameters, _overrides } = collectFromNode({
|
|
270
|
+
const { _id, type, parameters, _overrides } = collectFromNode({
|
|
247
271
|
uniformSourceLocale,
|
|
248
272
|
uniformTargetLocale,
|
|
249
273
|
overrideModifiedTargetLocale,
|
|
250
|
-
node
|
|
274
|
+
node,
|
|
275
|
+
deep: false
|
|
251
276
|
});
|
|
252
277
|
if (parameters || _overrides) {
|
|
253
278
|
payload.components[node._id] = {
|
|
254
|
-
|
|
279
|
+
_id,
|
|
280
|
+
type,
|
|
255
281
|
parameters,
|
|
256
282
|
_overrides
|
|
257
283
|
};
|
|
@@ -260,14 +286,16 @@ var collectTranslationPayload = ({
|
|
|
260
286
|
return { payload };
|
|
261
287
|
};
|
|
262
288
|
var collectFromNode = ({
|
|
263
|
-
node,
|
|
264
289
|
uniformSourceLocale,
|
|
265
290
|
uniformTargetLocale,
|
|
266
|
-
overrideModifiedTargetLocale
|
|
291
|
+
overrideModifiedTargetLocale,
|
|
292
|
+
node,
|
|
293
|
+
deep
|
|
267
294
|
}) => {
|
|
268
|
-
var _a, _b;
|
|
269
|
-
const
|
|
270
|
-
const
|
|
295
|
+
var _a, _b, _c;
|
|
296
|
+
const collectedParameters = {};
|
|
297
|
+
const collectedSlots = {};
|
|
298
|
+
const collectedOverrides = {};
|
|
271
299
|
const componentParameters = "parameters" in node ? node.parameters : void 0;
|
|
272
300
|
const entryFields = "fields" in node ? node.fields : void 0;
|
|
273
301
|
Object.entries((_a = componentParameters != null ? componentParameters : entryFields) != null ? _a : {}).forEach(([paramKey, param]) => {
|
|
@@ -280,7 +308,7 @@ var collectFromNode = ({
|
|
|
280
308
|
if (!overrideModifiedTargetLocale && !isTargetLocaleUntouched(param.type, sourceLocaleValue, targetLocaleValue)) {
|
|
281
309
|
return;
|
|
282
310
|
}
|
|
283
|
-
|
|
311
|
+
collectedParameters[paramKey] = {
|
|
284
312
|
type: param.type,
|
|
285
313
|
locales: {
|
|
286
314
|
[TRANSLATION_PAYLOAD_SOURCE_KEY]: sourceLocaleValue,
|
|
@@ -289,10 +317,32 @@ var collectFromNode = ({
|
|
|
289
317
|
}
|
|
290
318
|
};
|
|
291
319
|
});
|
|
292
|
-
|
|
320
|
+
if (deep) {
|
|
321
|
+
Object.entries((_b = "slots" in node ? node.slots : null) != null ? _b : {}).forEach(([slotKey, slotComponents]) => {
|
|
322
|
+
slotComponents.map((slotComponent) => {
|
|
323
|
+
var _a2;
|
|
324
|
+
if (!slotComponent.type || !slotComponent._id) {
|
|
325
|
+
return;
|
|
326
|
+
}
|
|
327
|
+
const collectedNode = collectFromNode({
|
|
328
|
+
uniformSourceLocale,
|
|
329
|
+
uniformTargetLocale,
|
|
330
|
+
overrideModifiedTargetLocale,
|
|
331
|
+
node: slotComponent,
|
|
332
|
+
deep: true
|
|
333
|
+
});
|
|
334
|
+
const hasContent = collectedNode.parameters || collectedNode._overrides || collectedNode.slots;
|
|
335
|
+
if (hasContent) {
|
|
336
|
+
(_a2 = collectedSlots[slotKey]) != null ? _a2 : collectedSlots[slotKey] = [];
|
|
337
|
+
collectedSlots[slotKey].push(collectedNode);
|
|
338
|
+
}
|
|
339
|
+
});
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
Object.entries((_c = node._overrides) != null ? _c : {}).forEach(([overrideKey, override]) => {
|
|
293
343
|
var _a2, _b2;
|
|
294
344
|
Object.entries((_a2 = override.parameters) != null ? _a2 : {}).forEach(([paramKey, param]) => {
|
|
295
|
-
var _a3, _b3,
|
|
345
|
+
var _a3, _b3, _c2, _d, _e;
|
|
296
346
|
const sourceLocaleValue = (_a3 = param.locales) == null ? void 0 : _a3[uniformSourceLocale];
|
|
297
347
|
const targetLocaleValue = (_b3 = param.locales) == null ? void 0 : _b3[uniformTargetLocale];
|
|
298
348
|
if (!canTranslateParameterValue(param, sourceLocaleValue)) {
|
|
@@ -301,9 +351,9 @@ var collectFromNode = ({
|
|
|
301
351
|
if (!overrideModifiedTargetLocale && !isTargetLocaleUntouched(param.type, sourceLocaleValue, targetLocaleValue)) {
|
|
302
352
|
return;
|
|
303
353
|
}
|
|
304
|
-
(
|
|
305
|
-
(_e = (_d =
|
|
306
|
-
|
|
354
|
+
(_c2 = collectedOverrides[overrideKey]) != null ? _c2 : collectedOverrides[overrideKey] = {};
|
|
355
|
+
(_e = (_d = collectedOverrides[overrideKey]).parameters) != null ? _e : _d.parameters = {};
|
|
356
|
+
collectedOverrides[overrideKey].parameters[paramKey] = {
|
|
307
357
|
type: param.type,
|
|
308
358
|
locales: {
|
|
309
359
|
[TRANSLATION_PAYLOAD_SOURCE_KEY]: sourceLocaleValue,
|
|
@@ -314,38 +364,38 @@ var collectFromNode = ({
|
|
|
314
364
|
});
|
|
315
365
|
Object.entries((_b2 = override.slots) != null ? _b2 : {}).forEach(([slotKey, slotComponents]) => {
|
|
316
366
|
slotComponents.map((slotComponent) => {
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
if (parameters2 || _overrides) {
|
|
330
|
-
(_a3 = overrides[overrideKey]) != null ? _a3 : overrides[overrideKey] = {};
|
|
331
|
-
(_c = (_b3 = overrides[overrideKey]).slots) != null ? _c : _b3.slots = {};
|
|
332
|
-
(_e = (_d = overrides[overrideKey].slots)[slotKey]) != null ? _e : _d[slotKey] = [];
|
|
333
|
-
overrides[overrideKey].slots[slotKey].push({
|
|
334
|
-
_id: node2._id,
|
|
335
|
-
type: node2.type,
|
|
336
|
-
parameters: parameters2,
|
|
337
|
-
_overrides
|
|
338
|
-
});
|
|
339
|
-
}
|
|
367
|
+
var _a3, _b3, _c2, _d, _e;
|
|
368
|
+
if (!slotComponent.type || !slotComponent._id) {
|
|
369
|
+
return;
|
|
370
|
+
}
|
|
371
|
+
const collectedNode = collectFromNode({
|
|
372
|
+
uniformSourceLocale,
|
|
373
|
+
uniformTargetLocale,
|
|
374
|
+
overrideModifiedTargetLocale,
|
|
375
|
+
node: slotComponent,
|
|
376
|
+
// keep tree structure for `Slot Sections`
|
|
377
|
+
// to store whole `override` content in scope of current component
|
|
378
|
+
deep: true
|
|
340
379
|
});
|
|
380
|
+
const hasContent = collectedNode.parameters || collectedNode._overrides || collectedNode.slots;
|
|
381
|
+
if (hasContent) {
|
|
382
|
+
(_a3 = collectedOverrides[overrideKey]) != null ? _a3 : collectedOverrides[overrideKey] = {};
|
|
383
|
+
(_c2 = (_b3 = collectedOverrides[overrideKey]).slots) != null ? _c2 : _b3.slots = {};
|
|
384
|
+
(_e = (_d = collectedOverrides[overrideKey].slots)[slotKey]) != null ? _e : _d[slotKey] = [];
|
|
385
|
+
collectedOverrides[overrideKey].slots[slotKey].push(collectedNode);
|
|
386
|
+
}
|
|
341
387
|
});
|
|
342
388
|
});
|
|
343
389
|
});
|
|
344
|
-
const hasParameters = Object.keys(
|
|
345
|
-
const
|
|
390
|
+
const hasParameters = Object.keys(collectedParameters).length > 0;
|
|
391
|
+
const hasSlots = Object.keys(collectedSlots).length > 0;
|
|
392
|
+
const hasOverrides = Object.keys(collectedOverrides).length > 0;
|
|
346
393
|
return {
|
|
347
|
-
|
|
348
|
-
|
|
394
|
+
_id: node._id,
|
|
395
|
+
type: node.type,
|
|
396
|
+
parameters: hasParameters ? collectedParameters : void 0,
|
|
397
|
+
slots: hasSlots ? collectedSlots : void 0,
|
|
398
|
+
_overrides: hasOverrides ? collectedOverrides : void 0
|
|
349
399
|
};
|
|
350
400
|
};
|
|
351
401
|
var canTranslateParameterValue = (parameter, value) => {
|
|
@@ -442,7 +492,7 @@ var getEntryForTranslation = async ({
|
|
|
442
492
|
import { CANVAS_DRAFT_STATE as CANVAS_DRAFT_STATE4 } from "@uniformdev/canvas";
|
|
443
493
|
|
|
444
494
|
// src/translateComposition.ts
|
|
445
|
-
import { CANVAS_DRAFT_STATE as CANVAS_DRAFT_STATE3, walkNodeTree as
|
|
495
|
+
import { CANVAS_DRAFT_STATE as CANVAS_DRAFT_STATE3, walkNodeTree as walkNodeTree3 } from "@uniformdev/canvas";
|
|
446
496
|
import { produce } from "immer";
|
|
447
497
|
var translateComposition = ({
|
|
448
498
|
composition,
|
|
@@ -473,7 +523,7 @@ var translateComposition = ({
|
|
|
473
523
|
(_b = (_a2 = draft.composition)._locales) != null ? _b : _a2._locales = [];
|
|
474
524
|
draft.composition._locales.push(uniformTargetLocale);
|
|
475
525
|
}
|
|
476
|
-
|
|
526
|
+
walkNodeTree3(draft.composition, ({ node: component, type, actions }) => {
|
|
477
527
|
if (type !== "component") {
|
|
478
528
|
actions.stopProcessingDescendants();
|
|
479
529
|
return;
|
|
@@ -572,7 +622,7 @@ var defaultUpdateComposition = async ({
|
|
|
572
622
|
import { CANVAS_DRAFT_STATE as CANVAS_DRAFT_STATE6 } from "@uniformdev/canvas";
|
|
573
623
|
|
|
574
624
|
// src/translateEntry.ts
|
|
575
|
-
import { CANVAS_DRAFT_STATE as CANVAS_DRAFT_STATE5, walkNodeTree as
|
|
625
|
+
import { CANVAS_DRAFT_STATE as CANVAS_DRAFT_STATE5, walkNodeTree as walkNodeTree4 } from "@uniformdev/canvas";
|
|
576
626
|
import { produce as produce2 } from "immer";
|
|
577
627
|
var translateEntry = ({
|
|
578
628
|
entry,
|
|
@@ -603,7 +653,7 @@ var translateEntry = ({
|
|
|
603
653
|
(_b = (_a2 = draft.entry)._locales) != null ? _b : _a2._locales = [];
|
|
604
654
|
draft.entry._locales.push(uniformTargetLocale);
|
|
605
655
|
}
|
|
606
|
-
|
|
656
|
+
walkNodeTree4(draft.entry, ({ node: component, type, actions }) => {
|
|
607
657
|
if (type !== "entry") {
|
|
608
658
|
actions.stopProcessingDescendants();
|
|
609
659
|
return;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniformdev/tms-sdk",
|
|
3
|
-
"version": "19.154.1-alpha.
|
|
3
|
+
"version": "19.154.1-alpha.24+6b5f73fb09",
|
|
4
4
|
"description": "Uniform Translation Management System SDK",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -33,10 +33,10 @@
|
|
|
33
33
|
"access": "public"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@uniformdev/canvas": "19.154.1-alpha.
|
|
37
|
-
"@uniformdev/richtext": "19.154.1-alpha.
|
|
36
|
+
"@uniformdev/canvas": "19.154.1-alpha.24+6b5f73fb09",
|
|
37
|
+
"@uniformdev/richtext": "19.154.1-alpha.24+6b5f73fb09",
|
|
38
38
|
"dequal": "2.0.3",
|
|
39
39
|
"immer": "10.0.4"
|
|
40
40
|
},
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "6b5f73fb09a0f75fb549cdc6ed754da016b7b345"
|
|
42
42
|
}
|