@uniformdev/canvas 18.38.2-alpha.6 → 19.1.1-alpha.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.
- package/dist/index.d.ts +790 -543
- package/dist/index.esm.js +99 -16
- package/dist/index.js +106 -19
- package/dist/index.mjs +99 -16
- package/package.json +3 -3
package/dist/index.esm.js
CHANGED
@@ -470,17 +470,9 @@ var CanvasClient = class extends ApiClient {
|
|
470
470
|
getCompositionByNodePath(options) {
|
471
471
|
return this.getOneComposition(options);
|
472
472
|
}
|
473
|
-
/** @deprecated use getCompositionByNodePath instead */
|
474
|
-
unstable_getCompositionByNodePath(options) {
|
475
|
-
return this.getOneComposition(options);
|
476
|
-
}
|
477
473
|
getCompositionByNodeId(options) {
|
478
474
|
return this.getOneComposition(options);
|
479
475
|
}
|
480
|
-
/** @deprecated Use getCompositionByNodeId instead */
|
481
|
-
unstable_getCompositionByNodeId(options) {
|
482
|
-
return this.getOneComposition(options);
|
483
|
-
}
|
484
476
|
getCompositionBySlug(options) {
|
485
477
|
return this.getOneComposition(options);
|
486
478
|
}
|
@@ -488,13 +480,13 @@ var CanvasClient = class extends ApiClient {
|
|
488
480
|
return this.getOneComposition(options);
|
489
481
|
}
|
490
482
|
getOneComposition({
|
491
|
-
|
483
|
+
skipDataResolution,
|
492
484
|
unstable_dynamicVariables: dynamicVariables,
|
493
|
-
|
485
|
+
diagnostics,
|
494
486
|
...params
|
495
487
|
}) {
|
496
488
|
const { projectId } = this.options;
|
497
|
-
if (
|
489
|
+
if (skipDataResolution) {
|
498
490
|
return this.apiClient(this.createUrl(CANVAS_URL, { ...params, projectId }));
|
499
491
|
}
|
500
492
|
const edgeParams = {
|
@@ -556,11 +548,74 @@ var UncachedCanvasClient = class extends CanvasClient {
|
|
556
548
|
}
|
557
549
|
};
|
558
550
|
|
559
|
-
// src/
|
551
|
+
// src/CompositionRelationshipClient.ts
|
560
552
|
import { ApiClient as ApiClient2 } from "@uniformdev/context/api";
|
553
|
+
var COMPOSITION_RELATIONSHIP_URL = "/api/v1/composition-relationships";
|
554
|
+
var unstable_CompositionRelationshipClient = class extends ApiClient2 {
|
555
|
+
constructor(options) {
|
556
|
+
super(options);
|
557
|
+
this.getDefinitionsRelationships = async ({
|
558
|
+
definitionIds,
|
559
|
+
withCompositions
|
560
|
+
}) => {
|
561
|
+
const url = this.createUrl(COMPOSITION_RELATIONSHIP_URL, {
|
562
|
+
type: "definition",
|
563
|
+
projectId: this._options.projectId,
|
564
|
+
definitionIds: definitionIds.join(","),
|
565
|
+
withCompositions
|
566
|
+
});
|
567
|
+
return this.apiClient(url);
|
568
|
+
};
|
569
|
+
this.clearAllRelationships = async () => {
|
570
|
+
const url = this.createUrl(COMPOSITION_RELATIONSHIP_URL);
|
571
|
+
return this.apiClient(url, {
|
572
|
+
method: "POST",
|
573
|
+
body: JSON.stringify({
|
574
|
+
type: "clear",
|
575
|
+
projectId: this._options.projectId
|
576
|
+
})
|
577
|
+
});
|
578
|
+
};
|
579
|
+
this.indexCompositionRelationships = async ({
|
580
|
+
state,
|
581
|
+
compositionId
|
582
|
+
}) => {
|
583
|
+
const url = this.createUrl(COMPOSITION_RELATIONSHIP_URL);
|
584
|
+
return this.apiClient(url, {
|
585
|
+
method: "POST",
|
586
|
+
body: JSON.stringify({
|
587
|
+
type: "index",
|
588
|
+
projectId: this._options.projectId,
|
589
|
+
state,
|
590
|
+
compositionId
|
591
|
+
})
|
592
|
+
});
|
593
|
+
};
|
594
|
+
this.getVersion = async () => {
|
595
|
+
const url = this.createUrl("/api/v1/usage-tracking", {
|
596
|
+
projectId: this._options.projectId
|
597
|
+
});
|
598
|
+
return this.apiClient(url).then((response) => response.version);
|
599
|
+
};
|
600
|
+
this.setVersion = async (version) => {
|
601
|
+
const url = this.createUrl("/api/v1/usage-tracking");
|
602
|
+
return this.apiClient(url, {
|
603
|
+
method: "POST",
|
604
|
+
body: JSON.stringify({
|
605
|
+
projectId: this._options.projectId,
|
606
|
+
version
|
607
|
+
})
|
608
|
+
});
|
609
|
+
};
|
610
|
+
this._options = options;
|
611
|
+
}
|
612
|
+
};
|
613
|
+
|
614
|
+
// src/DataSourceClient.ts
|
615
|
+
import { ApiClient as ApiClient3 } from "@uniformdev/context/api";
|
561
616
|
var dataSourceUrl = "/api/v1/data-source";
|
562
617
|
var dataSourcesUrl = "/api/v1/data-sources";
|
563
|
-
var DataSourceClient = class extends
|
618
|
+
var DataSourceClient = class extends ApiClient3 {
|
564
619
|
constructor(options) {
|
565
620
|
super(options);
|
566
621
|
}
|
@@ -597,9 +652,9 @@ var DataSourceClient = class extends ApiClient2 {
|
|
597
652
|
};
|
598
653
|
|
599
654
|
// src/DataTypeClient.ts
|
600
|
-
import { ApiClient as
|
655
|
+
import { ApiClient as ApiClient4 } from "@uniformdev/context/api";
|
601
656
|
var _url;
|
602
|
-
var _DataTypeClient = class extends
|
657
|
+
var _DataTypeClient = class extends ApiClient4 {
|
603
658
|
constructor(options) {
|
604
659
|
super(options);
|
605
660
|
}
|
@@ -1129,6 +1184,7 @@ var IN_CONTEXT_EDITOR_QUERY_STRING_PARAM = "is_incontext_editing_mode";
|
|
1129
1184
|
var IN_CONTEXT_EDITOR_COMPONENT_START_ROLE = "uniform-component-start";
|
1130
1185
|
var IN_CONTEXT_EDITOR_COMPONENT_END_ROLE = "uniform-component-end";
|
1131
1186
|
var IN_CONTEXT_EDITOR_EMBED_SCRIPT_ID = "uniform-canvas-preview-script";
|
1187
|
+
var IS_RENDERED_BY_UNIFORM_ATTRIBUTE = "data-is-rendered-by-uniform";
|
1132
1188
|
var PLACEHOLDER_ID = "placeholder";
|
1133
1189
|
var EMPTY_COMPOSITION = {
|
1134
1190
|
_id: "_empty_composition_id",
|
@@ -1238,12 +1294,18 @@ var isReadyMessage = (message) => {
|
|
1238
1294
|
var isUpdateCompositionMessage = (message) => {
|
1239
1295
|
return message.type === "update-composition";
|
1240
1296
|
};
|
1297
|
+
var isUpdateCompositionInternalMessage = (message) => {
|
1298
|
+
return message.type === "update-composition-internal";
|
1299
|
+
};
|
1241
1300
|
var isAddComponentMessage = (message) => {
|
1242
1301
|
return message.type === "add-component";
|
1243
1302
|
};
|
1244
1303
|
var isMovingComponentMessage = (message) => {
|
1245
1304
|
return message.type === "move-component";
|
1246
1305
|
};
|
1306
|
+
var isUpdateComponentParameterMessage = (message) => {
|
1307
|
+
return message.type === "update-component-parameter";
|
1308
|
+
};
|
1247
1309
|
var isDismissPlaceholderMessage = (message) => {
|
1248
1310
|
return message.type === "dismiss-placeholder";
|
1249
1311
|
};
|
@@ -1305,6 +1367,14 @@ var createCanvasChannel = ({
|
|
1305
1367
|
};
|
1306
1368
|
postMessage(message);
|
1307
1369
|
};
|
1370
|
+
const updateCompositionInternal = (composition, hash) => {
|
1371
|
+
const message = {
|
1372
|
+
type: "update-composition-internal",
|
1373
|
+
composition,
|
1374
|
+
hash
|
1375
|
+
};
|
1376
|
+
postMessage(message);
|
1377
|
+
};
|
1308
1378
|
const addComponent = (options) => {
|
1309
1379
|
const message = {
|
1310
1380
|
...options,
|
@@ -1319,6 +1389,13 @@ var createCanvasChannel = ({
|
|
1319
1389
|
};
|
1320
1390
|
postMessage(message);
|
1321
1391
|
};
|
1392
|
+
const updateComponentParameter = (options) => {
|
1393
|
+
const message = {
|
1394
|
+
...options,
|
1395
|
+
type: "update-component-parameter"
|
1396
|
+
};
|
1397
|
+
postMessage(message);
|
1398
|
+
};
|
1322
1399
|
const dismissPlaceholder = (options) => {
|
1323
1400
|
const message = {
|
1324
1401
|
...options,
|
@@ -1341,7 +1418,7 @@ var createCanvasChannel = ({
|
|
1341
1418
|
postMessage(message);
|
1342
1419
|
};
|
1343
1420
|
const messageEventListener = (event) => {
|
1344
|
-
if (typeof event.data !== "string"
|
1421
|
+
if (typeof event.data !== "string") {
|
1345
1422
|
return;
|
1346
1423
|
}
|
1347
1424
|
let message = null;
|
@@ -1371,9 +1448,11 @@ var createCanvasChannel = ({
|
|
1371
1448
|
destroy,
|
1372
1449
|
selectComponent,
|
1373
1450
|
updateComposition,
|
1451
|
+
updateCompositionInternal,
|
1374
1452
|
on,
|
1375
1453
|
addComponent,
|
1376
1454
|
moveComponent,
|
1455
|
+
updateComponentParameter,
|
1377
1456
|
dismissPlaceholder,
|
1378
1457
|
updatePreviewSettings,
|
1379
1458
|
reportRenderedCompositions
|
@@ -1554,6 +1633,7 @@ export {
|
|
1554
1633
|
IN_CONTEXT_EDITOR_COMPONENT_START_ROLE,
|
1555
1634
|
IN_CONTEXT_EDITOR_EMBED_SCRIPT_ID,
|
1556
1635
|
IN_CONTEXT_EDITOR_QUERY_STRING_PARAM,
|
1636
|
+
IS_RENDERED_BY_UNIFORM_ATTRIBUTE,
|
1557
1637
|
PLACEHOLDER_ID,
|
1558
1638
|
UncachedCanvasClient,
|
1559
1639
|
UniqueBatchEntries,
|
@@ -1576,6 +1656,8 @@ export {
|
|
1576
1656
|
isReportRenderedCompositionsMessage,
|
1577
1657
|
isSelectComponentMessage,
|
1578
1658
|
isSystemComponentDefinition,
|
1659
|
+
isUpdateComponentParameterMessage,
|
1660
|
+
isUpdateCompositionInternalMessage,
|
1579
1661
|
isUpdateCompositionMessage,
|
1580
1662
|
isUpdatePreviewSettingsMessage,
|
1581
1663
|
localize,
|
@@ -1583,5 +1665,6 @@ export {
|
|
1583
1665
|
mapSlotToTestVariations,
|
1584
1666
|
nullLimitPolicy,
|
1585
1667
|
subscribeToComposition,
|
1668
|
+
unstable_CompositionRelationshipClient,
|
1586
1669
|
walkComponentTree
|
1587
1670
|
};
|
package/dist/index.js
CHANGED
@@ -274,7 +274,7 @@ var require_retry2 = __commonJS({
|
|
274
274
|
// src/index.ts
|
275
275
|
var src_exports = {};
|
276
276
|
__export(src_exports, {
|
277
|
-
ApiClientError: () =>
|
277
|
+
ApiClientError: () => import_api5.ApiClientError,
|
278
278
|
BatchEntry: () => BatchEntry,
|
279
279
|
CANVAS_DRAFT_STATE: () => CANVAS_DRAFT_STATE,
|
280
280
|
CANVAS_ENRICHMENT_TAG_PARAM: () => CANVAS_ENRICHMENT_TAG_PARAM,
|
@@ -307,6 +307,7 @@ __export(src_exports, {
|
|
307
307
|
IN_CONTEXT_EDITOR_COMPONENT_START_ROLE: () => IN_CONTEXT_EDITOR_COMPONENT_START_ROLE,
|
308
308
|
IN_CONTEXT_EDITOR_EMBED_SCRIPT_ID: () => IN_CONTEXT_EDITOR_EMBED_SCRIPT_ID,
|
309
309
|
IN_CONTEXT_EDITOR_QUERY_STRING_PARAM: () => IN_CONTEXT_EDITOR_QUERY_STRING_PARAM,
|
310
|
+
IS_RENDERED_BY_UNIFORM_ATTRIBUTE: () => IS_RENDERED_BY_UNIFORM_ATTRIBUTE,
|
310
311
|
PLACEHOLDER_ID: () => PLACEHOLDER_ID,
|
311
312
|
UncachedCanvasClient: () => UncachedCanvasClient,
|
312
313
|
UniqueBatchEntries: () => UniqueBatchEntries,
|
@@ -329,6 +330,8 @@ __export(src_exports, {
|
|
329
330
|
isReportRenderedCompositionsMessage: () => isReportRenderedCompositionsMessage,
|
330
331
|
isSelectComponentMessage: () => isSelectComponentMessage,
|
331
332
|
isSystemComponentDefinition: () => isSystemComponentDefinition,
|
333
|
+
isUpdateComponentParameterMessage: () => isUpdateComponentParameterMessage,
|
334
|
+
isUpdateCompositionInternalMessage: () => isUpdateCompositionInternalMessage,
|
332
335
|
isUpdateCompositionMessage: () => isUpdateCompositionMessage,
|
333
336
|
isUpdatePreviewSettingsMessage: () => isUpdatePreviewSettingsMessage,
|
334
337
|
localize: () => localize,
|
@@ -336,6 +339,7 @@ __export(src_exports, {
|
|
336
339
|
mapSlotToTestVariations: () => mapSlotToTestVariations,
|
337
340
|
nullLimitPolicy: () => nullLimitPolicy,
|
338
341
|
subscribeToComposition: () => subscribeToComposition,
|
342
|
+
unstable_CompositionRelationshipClient: () => unstable_CompositionRelationshipClient,
|
339
343
|
walkComponentTree: () => walkComponentTree
|
340
344
|
});
|
341
345
|
module.exports = __toCommonJS(src_exports);
|
@@ -545,17 +549,9 @@ var CanvasClient = class extends import_api.ApiClient {
|
|
545
549
|
getCompositionByNodePath(options) {
|
546
550
|
return this.getOneComposition(options);
|
547
551
|
}
|
548
|
-
/** @deprecated use getCompositionByNodePath instead */
|
549
|
-
unstable_getCompositionByNodePath(options) {
|
550
|
-
return this.getOneComposition(options);
|
551
|
-
}
|
552
552
|
getCompositionByNodeId(options) {
|
553
553
|
return this.getOneComposition(options);
|
554
554
|
}
|
555
|
-
/** @deprecated Use getCompositionByNodeId instead */
|
556
|
-
unstable_getCompositionByNodeId(options) {
|
557
|
-
return this.getOneComposition(options);
|
558
|
-
}
|
559
555
|
getCompositionBySlug(options) {
|
560
556
|
return this.getOneComposition(options);
|
561
557
|
}
|
@@ -563,13 +559,13 @@ var CanvasClient = class extends import_api.ApiClient {
|
|
563
559
|
return this.getOneComposition(options);
|
564
560
|
}
|
565
561
|
getOneComposition({
|
566
|
-
|
562
|
+
skipDataResolution,
|
567
563
|
unstable_dynamicVariables: dynamicVariables,
|
568
|
-
|
564
|
+
diagnostics,
|
569
565
|
...params
|
570
566
|
}) {
|
571
567
|
const { projectId } = this.options;
|
572
|
-
if (
|
568
|
+
if (skipDataResolution) {
|
573
569
|
return this.apiClient(this.createUrl(CANVAS_URL, { ...params, projectId }));
|
574
570
|
}
|
575
571
|
const edgeParams = {
|
@@ -631,11 +627,74 @@ var UncachedCanvasClient = class extends CanvasClient {
|
|
631
627
|
}
|
632
628
|
};
|
633
629
|
|
634
|
-
// src/
|
630
|
+
// src/CompositionRelationshipClient.ts
|
635
631
|
var import_api2 = require("@uniformdev/context/api");
|
632
|
+
var COMPOSITION_RELATIONSHIP_URL = "/api/v1/composition-relationships";
|
633
|
+
var unstable_CompositionRelationshipClient = class extends import_api2.ApiClient {
|
634
|
+
constructor(options) {
|
635
|
+
super(options);
|
636
|
+
this.getDefinitionsRelationships = async ({
|
637
|
+
definitionIds,
|
638
|
+
withCompositions
|
639
|
+
}) => {
|
640
|
+
const url = this.createUrl(COMPOSITION_RELATIONSHIP_URL, {
|
641
|
+
type: "definition",
|
642
|
+
projectId: this._options.projectId,
|
643
|
+
definitionIds: definitionIds.join(","),
|
644
|
+
withCompositions
|
645
|
+
});
|
646
|
+
return this.apiClient(url);
|
647
|
+
};
|
648
|
+
this.clearAllRelationships = async () => {
|
649
|
+
const url = this.createUrl(COMPOSITION_RELATIONSHIP_URL);
|
650
|
+
return this.apiClient(url, {
|
651
|
+
method: "POST",
|
652
|
+
body: JSON.stringify({
|
653
|
+
type: "clear",
|
654
|
+
projectId: this._options.projectId
|
655
|
+
})
|
656
|
+
});
|
657
|
+
};
|
658
|
+
this.indexCompositionRelationships = async ({
|
659
|
+
state,
|
660
|
+
compositionId
|
661
|
+
}) => {
|
662
|
+
const url = this.createUrl(COMPOSITION_RELATIONSHIP_URL);
|
663
|
+
return this.apiClient(url, {
|
664
|
+
method: "POST",
|
665
|
+
body: JSON.stringify({
|
666
|
+
type: "index",
|
667
|
+
projectId: this._options.projectId,
|
668
|
+
state,
|
669
|
+
compositionId
|
670
|
+
})
|
671
|
+
});
|
672
|
+
};
|
673
|
+
this.getVersion = async () => {
|
674
|
+
const url = this.createUrl("/api/v1/usage-tracking", {
|
675
|
+
projectId: this._options.projectId
|
676
|
+
});
|
677
|
+
return this.apiClient(url).then((response) => response.version);
|
678
|
+
};
|
679
|
+
this.setVersion = async (version) => {
|
680
|
+
const url = this.createUrl("/api/v1/usage-tracking");
|
681
|
+
return this.apiClient(url, {
|
682
|
+
method: "POST",
|
683
|
+
body: JSON.stringify({
|
684
|
+
projectId: this._options.projectId,
|
685
|
+
version
|
686
|
+
})
|
687
|
+
});
|
688
|
+
};
|
689
|
+
this._options = options;
|
690
|
+
}
|
691
|
+
};
|
692
|
+
|
693
|
+
// src/DataSourceClient.ts
|
694
|
+
var import_api3 = require("@uniformdev/context/api");
|
636
695
|
var dataSourceUrl = "/api/v1/data-source";
|
637
696
|
var dataSourcesUrl = "/api/v1/data-sources";
|
638
|
-
var DataSourceClient = class extends
|
697
|
+
var DataSourceClient = class extends import_api3.ApiClient {
|
639
698
|
constructor(options) {
|
640
699
|
super(options);
|
641
700
|
}
|
@@ -672,9 +731,9 @@ var DataSourceClient = class extends import_api2.ApiClient {
|
|
672
731
|
};
|
673
732
|
|
674
733
|
// src/DataTypeClient.ts
|
675
|
-
var
|
734
|
+
var import_api4 = require("@uniformdev/context/api");
|
676
735
|
var _url;
|
677
|
-
var _DataTypeClient = class extends
|
736
|
+
var _DataTypeClient = class extends import_api4.ApiClient {
|
678
737
|
constructor(options) {
|
679
738
|
super(options);
|
680
739
|
}
|
@@ -1204,6 +1263,7 @@ var IN_CONTEXT_EDITOR_QUERY_STRING_PARAM = "is_incontext_editing_mode";
|
|
1204
1263
|
var IN_CONTEXT_EDITOR_COMPONENT_START_ROLE = "uniform-component-start";
|
1205
1264
|
var IN_CONTEXT_EDITOR_COMPONENT_END_ROLE = "uniform-component-end";
|
1206
1265
|
var IN_CONTEXT_EDITOR_EMBED_SCRIPT_ID = "uniform-canvas-preview-script";
|
1266
|
+
var IS_RENDERED_BY_UNIFORM_ATTRIBUTE = "data-is-rendered-by-uniform";
|
1207
1267
|
var PLACEHOLDER_ID = "placeholder";
|
1208
1268
|
var EMPTY_COMPOSITION = {
|
1209
1269
|
_id: "_empty_composition_id",
|
@@ -1313,12 +1373,18 @@ var isReadyMessage = (message) => {
|
|
1313
1373
|
var isUpdateCompositionMessage = (message) => {
|
1314
1374
|
return message.type === "update-composition";
|
1315
1375
|
};
|
1376
|
+
var isUpdateCompositionInternalMessage = (message) => {
|
1377
|
+
return message.type === "update-composition-internal";
|
1378
|
+
};
|
1316
1379
|
var isAddComponentMessage = (message) => {
|
1317
1380
|
return message.type === "add-component";
|
1318
1381
|
};
|
1319
1382
|
var isMovingComponentMessage = (message) => {
|
1320
1383
|
return message.type === "move-component";
|
1321
1384
|
};
|
1385
|
+
var isUpdateComponentParameterMessage = (message) => {
|
1386
|
+
return message.type === "update-component-parameter";
|
1387
|
+
};
|
1322
1388
|
var isDismissPlaceholderMessage = (message) => {
|
1323
1389
|
return message.type === "dismiss-placeholder";
|
1324
1390
|
};
|
@@ -1380,6 +1446,14 @@ var createCanvasChannel = ({
|
|
1380
1446
|
};
|
1381
1447
|
postMessage(message);
|
1382
1448
|
};
|
1449
|
+
const updateCompositionInternal = (composition, hash) => {
|
1450
|
+
const message = {
|
1451
|
+
type: "update-composition-internal",
|
1452
|
+
composition,
|
1453
|
+
hash
|
1454
|
+
};
|
1455
|
+
postMessage(message);
|
1456
|
+
};
|
1383
1457
|
const addComponent = (options) => {
|
1384
1458
|
const message = {
|
1385
1459
|
...options,
|
@@ -1394,6 +1468,13 @@ var createCanvasChannel = ({
|
|
1394
1468
|
};
|
1395
1469
|
postMessage(message);
|
1396
1470
|
};
|
1471
|
+
const updateComponentParameter = (options) => {
|
1472
|
+
const message = {
|
1473
|
+
...options,
|
1474
|
+
type: "update-component-parameter"
|
1475
|
+
};
|
1476
|
+
postMessage(message);
|
1477
|
+
};
|
1397
1478
|
const dismissPlaceholder = (options) => {
|
1398
1479
|
const message = {
|
1399
1480
|
...options,
|
@@ -1416,7 +1497,7 @@ var createCanvasChannel = ({
|
|
1416
1497
|
postMessage(message);
|
1417
1498
|
};
|
1418
1499
|
const messageEventListener = (event) => {
|
1419
|
-
if (typeof event.data !== "string"
|
1500
|
+
if (typeof event.data !== "string") {
|
1420
1501
|
return;
|
1421
1502
|
}
|
1422
1503
|
let message = null;
|
@@ -1446,9 +1527,11 @@ var createCanvasChannel = ({
|
|
1446
1527
|
destroy,
|
1447
1528
|
selectComponent,
|
1448
1529
|
updateComposition,
|
1530
|
+
updateCompositionInternal,
|
1449
1531
|
on,
|
1450
1532
|
addComponent,
|
1451
1533
|
moveComponent,
|
1534
|
+
updateComponentParameter,
|
1452
1535
|
dismissPlaceholder,
|
1453
1536
|
updatePreviewSettings,
|
1454
1537
|
reportRenderedCompositions
|
@@ -1593,8 +1676,8 @@ function mapSlotToTestVariations(slot) {
|
|
1593
1676
|
}
|
1594
1677
|
|
1595
1678
|
// src/index.ts
|
1596
|
-
var
|
1597
|
-
var CanvasClientError =
|
1679
|
+
var import_api5 = require("@uniformdev/context/api");
|
1680
|
+
var CanvasClientError = import_api5.ApiClientError;
|
1598
1681
|
// Annotate the CommonJS export names for ESM import in node:
|
1599
1682
|
0 && (module.exports = {
|
1600
1683
|
ApiClientError,
|
@@ -1630,6 +1713,7 @@ var CanvasClientError = import_api4.ApiClientError;
|
|
1630
1713
|
IN_CONTEXT_EDITOR_COMPONENT_START_ROLE,
|
1631
1714
|
IN_CONTEXT_EDITOR_EMBED_SCRIPT_ID,
|
1632
1715
|
IN_CONTEXT_EDITOR_QUERY_STRING_PARAM,
|
1716
|
+
IS_RENDERED_BY_UNIFORM_ATTRIBUTE,
|
1633
1717
|
PLACEHOLDER_ID,
|
1634
1718
|
UncachedCanvasClient,
|
1635
1719
|
UniqueBatchEntries,
|
@@ -1652,6 +1736,8 @@ var CanvasClientError = import_api4.ApiClientError;
|
|
1652
1736
|
isReportRenderedCompositionsMessage,
|
1653
1737
|
isSelectComponentMessage,
|
1654
1738
|
isSystemComponentDefinition,
|
1739
|
+
isUpdateComponentParameterMessage,
|
1740
|
+
isUpdateCompositionInternalMessage,
|
1655
1741
|
isUpdateCompositionMessage,
|
1656
1742
|
isUpdatePreviewSettingsMessage,
|
1657
1743
|
localize,
|
@@ -1659,5 +1745,6 @@ var CanvasClientError = import_api4.ApiClientError;
|
|
1659
1745
|
mapSlotToTestVariations,
|
1660
1746
|
nullLimitPolicy,
|
1661
1747
|
subscribeToComposition,
|
1748
|
+
unstable_CompositionRelationshipClient,
|
1662
1749
|
walkComponentTree
|
1663
1750
|
});
|
package/dist/index.mjs
CHANGED
@@ -470,17 +470,9 @@ var CanvasClient = class extends ApiClient {
|
|
470
470
|
getCompositionByNodePath(options) {
|
471
471
|
return this.getOneComposition(options);
|
472
472
|
}
|
473
|
-
/** @deprecated use getCompositionByNodePath instead */
|
474
|
-
unstable_getCompositionByNodePath(options) {
|
475
|
-
return this.getOneComposition(options);
|
476
|
-
}
|
477
473
|
getCompositionByNodeId(options) {
|
478
474
|
return this.getOneComposition(options);
|
479
475
|
}
|
480
|
-
/** @deprecated Use getCompositionByNodeId instead */
|
481
|
-
unstable_getCompositionByNodeId(options) {
|
482
|
-
return this.getOneComposition(options);
|
483
|
-
}
|
484
476
|
getCompositionBySlug(options) {
|
485
477
|
return this.getOneComposition(options);
|
486
478
|
}
|
@@ -488,13 +480,13 @@ var CanvasClient = class extends ApiClient {
|
|
488
480
|
return this.getOneComposition(options);
|
489
481
|
}
|
490
482
|
getOneComposition({
|
491
|
-
|
483
|
+
skipDataResolution,
|
492
484
|
unstable_dynamicVariables: dynamicVariables,
|
493
|
-
|
485
|
+
diagnostics,
|
494
486
|
...params
|
495
487
|
}) {
|
496
488
|
const { projectId } = this.options;
|
497
|
-
if (
|
489
|
+
if (skipDataResolution) {
|
498
490
|
return this.apiClient(this.createUrl(CANVAS_URL, { ...params, projectId }));
|
499
491
|
}
|
500
492
|
const edgeParams = {
|
@@ -556,11 +548,74 @@ var UncachedCanvasClient = class extends CanvasClient {
|
|
556
548
|
}
|
557
549
|
};
|
558
550
|
|
559
|
-
// src/
|
551
|
+
// src/CompositionRelationshipClient.ts
|
560
552
|
import { ApiClient as ApiClient2 } from "@uniformdev/context/api";
|
553
|
+
var COMPOSITION_RELATIONSHIP_URL = "/api/v1/composition-relationships";
|
554
|
+
var unstable_CompositionRelationshipClient = class extends ApiClient2 {
|
555
|
+
constructor(options) {
|
556
|
+
super(options);
|
557
|
+
this.getDefinitionsRelationships = async ({
|
558
|
+
definitionIds,
|
559
|
+
withCompositions
|
560
|
+
}) => {
|
561
|
+
const url = this.createUrl(COMPOSITION_RELATIONSHIP_URL, {
|
562
|
+
type: "definition",
|
563
|
+
projectId: this._options.projectId,
|
564
|
+
definitionIds: definitionIds.join(","),
|
565
|
+
withCompositions
|
566
|
+
});
|
567
|
+
return this.apiClient(url);
|
568
|
+
};
|
569
|
+
this.clearAllRelationships = async () => {
|
570
|
+
const url = this.createUrl(COMPOSITION_RELATIONSHIP_URL);
|
571
|
+
return this.apiClient(url, {
|
572
|
+
method: "POST",
|
573
|
+
body: JSON.stringify({
|
574
|
+
type: "clear",
|
575
|
+
projectId: this._options.projectId
|
576
|
+
})
|
577
|
+
});
|
578
|
+
};
|
579
|
+
this.indexCompositionRelationships = async ({
|
580
|
+
state,
|
581
|
+
compositionId
|
582
|
+
}) => {
|
583
|
+
const url = this.createUrl(COMPOSITION_RELATIONSHIP_URL);
|
584
|
+
return this.apiClient(url, {
|
585
|
+
method: "POST",
|
586
|
+
body: JSON.stringify({
|
587
|
+
type: "index",
|
588
|
+
projectId: this._options.projectId,
|
589
|
+
state,
|
590
|
+
compositionId
|
591
|
+
})
|
592
|
+
});
|
593
|
+
};
|
594
|
+
this.getVersion = async () => {
|
595
|
+
const url = this.createUrl("/api/v1/usage-tracking", {
|
596
|
+
projectId: this._options.projectId
|
597
|
+
});
|
598
|
+
return this.apiClient(url).then((response) => response.version);
|
599
|
+
};
|
600
|
+
this.setVersion = async (version) => {
|
601
|
+
const url = this.createUrl("/api/v1/usage-tracking");
|
602
|
+
return this.apiClient(url, {
|
603
|
+
method: "POST",
|
604
|
+
body: JSON.stringify({
|
605
|
+
projectId: this._options.projectId,
|
606
|
+
version
|
607
|
+
})
|
608
|
+
});
|
609
|
+
};
|
610
|
+
this._options = options;
|
611
|
+
}
|
612
|
+
};
|
613
|
+
|
614
|
+
// src/DataSourceClient.ts
|
615
|
+
import { ApiClient as ApiClient3 } from "@uniformdev/context/api";
|
561
616
|
var dataSourceUrl = "/api/v1/data-source";
|
562
617
|
var dataSourcesUrl = "/api/v1/data-sources";
|
563
|
-
var DataSourceClient = class extends
|
618
|
+
var DataSourceClient = class extends ApiClient3 {
|
564
619
|
constructor(options) {
|
565
620
|
super(options);
|
566
621
|
}
|
@@ -597,9 +652,9 @@ var DataSourceClient = class extends ApiClient2 {
|
|
597
652
|
};
|
598
653
|
|
599
654
|
// src/DataTypeClient.ts
|
600
|
-
import { ApiClient as
|
655
|
+
import { ApiClient as ApiClient4 } from "@uniformdev/context/api";
|
601
656
|
var _url;
|
602
|
-
var _DataTypeClient = class extends
|
657
|
+
var _DataTypeClient = class extends ApiClient4 {
|
603
658
|
constructor(options) {
|
604
659
|
super(options);
|
605
660
|
}
|
@@ -1129,6 +1184,7 @@ var IN_CONTEXT_EDITOR_QUERY_STRING_PARAM = "is_incontext_editing_mode";
|
|
1129
1184
|
var IN_CONTEXT_EDITOR_COMPONENT_START_ROLE = "uniform-component-start";
|
1130
1185
|
var IN_CONTEXT_EDITOR_COMPONENT_END_ROLE = "uniform-component-end";
|
1131
1186
|
var IN_CONTEXT_EDITOR_EMBED_SCRIPT_ID = "uniform-canvas-preview-script";
|
1187
|
+
var IS_RENDERED_BY_UNIFORM_ATTRIBUTE = "data-is-rendered-by-uniform";
|
1132
1188
|
var PLACEHOLDER_ID = "placeholder";
|
1133
1189
|
var EMPTY_COMPOSITION = {
|
1134
1190
|
_id: "_empty_composition_id",
|
@@ -1238,12 +1294,18 @@ var isReadyMessage = (message) => {
|
|
1238
1294
|
var isUpdateCompositionMessage = (message) => {
|
1239
1295
|
return message.type === "update-composition";
|
1240
1296
|
};
|
1297
|
+
var isUpdateCompositionInternalMessage = (message) => {
|
1298
|
+
return message.type === "update-composition-internal";
|
1299
|
+
};
|
1241
1300
|
var isAddComponentMessage = (message) => {
|
1242
1301
|
return message.type === "add-component";
|
1243
1302
|
};
|
1244
1303
|
var isMovingComponentMessage = (message) => {
|
1245
1304
|
return message.type === "move-component";
|
1246
1305
|
};
|
1306
|
+
var isUpdateComponentParameterMessage = (message) => {
|
1307
|
+
return message.type === "update-component-parameter";
|
1308
|
+
};
|
1247
1309
|
var isDismissPlaceholderMessage = (message) => {
|
1248
1310
|
return message.type === "dismiss-placeholder";
|
1249
1311
|
};
|
@@ -1305,6 +1367,14 @@ var createCanvasChannel = ({
|
|
1305
1367
|
};
|
1306
1368
|
postMessage(message);
|
1307
1369
|
};
|
1370
|
+
const updateCompositionInternal = (composition, hash) => {
|
1371
|
+
const message = {
|
1372
|
+
type: "update-composition-internal",
|
1373
|
+
composition,
|
1374
|
+
hash
|
1375
|
+
};
|
1376
|
+
postMessage(message);
|
1377
|
+
};
|
1308
1378
|
const addComponent = (options) => {
|
1309
1379
|
const message = {
|
1310
1380
|
...options,
|
@@ -1319,6 +1389,13 @@ var createCanvasChannel = ({
|
|
1319
1389
|
};
|
1320
1390
|
postMessage(message);
|
1321
1391
|
};
|
1392
|
+
const updateComponentParameter = (options) => {
|
1393
|
+
const message = {
|
1394
|
+
...options,
|
1395
|
+
type: "update-component-parameter"
|
1396
|
+
};
|
1397
|
+
postMessage(message);
|
1398
|
+
};
|
1322
1399
|
const dismissPlaceholder = (options) => {
|
1323
1400
|
const message = {
|
1324
1401
|
...options,
|
@@ -1341,7 +1418,7 @@ var createCanvasChannel = ({
|
|
1341
1418
|
postMessage(message);
|
1342
1419
|
};
|
1343
1420
|
const messageEventListener = (event) => {
|
1344
|
-
if (typeof event.data !== "string"
|
1421
|
+
if (typeof event.data !== "string") {
|
1345
1422
|
return;
|
1346
1423
|
}
|
1347
1424
|
let message = null;
|
@@ -1371,9 +1448,11 @@ var createCanvasChannel = ({
|
|
1371
1448
|
destroy,
|
1372
1449
|
selectComponent,
|
1373
1450
|
updateComposition,
|
1451
|
+
updateCompositionInternal,
|
1374
1452
|
on,
|
1375
1453
|
addComponent,
|
1376
1454
|
moveComponent,
|
1455
|
+
updateComponentParameter,
|
1377
1456
|
dismissPlaceholder,
|
1378
1457
|
updatePreviewSettings,
|
1379
1458
|
reportRenderedCompositions
|
@@ -1554,6 +1633,7 @@ export {
|
|
1554
1633
|
IN_CONTEXT_EDITOR_COMPONENT_START_ROLE,
|
1555
1634
|
IN_CONTEXT_EDITOR_EMBED_SCRIPT_ID,
|
1556
1635
|
IN_CONTEXT_EDITOR_QUERY_STRING_PARAM,
|
1636
|
+
IS_RENDERED_BY_UNIFORM_ATTRIBUTE,
|
1557
1637
|
PLACEHOLDER_ID,
|
1558
1638
|
UncachedCanvasClient,
|
1559
1639
|
UniqueBatchEntries,
|
@@ -1576,6 +1656,8 @@ export {
|
|
1576
1656
|
isReportRenderedCompositionsMessage,
|
1577
1657
|
isSelectComponentMessage,
|
1578
1658
|
isSystemComponentDefinition,
|
1659
|
+
isUpdateComponentParameterMessage,
|
1660
|
+
isUpdateCompositionInternalMessage,
|
1579
1661
|
isUpdateCompositionMessage,
|
1580
1662
|
isUpdatePreviewSettingsMessage,
|
1581
1663
|
localize,
|
@@ -1583,5 +1665,6 @@ export {
|
|
1583
1665
|
mapSlotToTestVariations,
|
1584
1666
|
nullLimitPolicy,
|
1585
1667
|
subscribeToComposition,
|
1668
|
+
unstable_CompositionRelationshipClient,
|
1586
1669
|
walkComponentTree
|
1587
1670
|
};
|