@canva/design 2.7.2 → 2.7.3
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/index.d.ts +14 -7
- package/lib/cjs/sdk/design/fake/fake_design_interaction_client.js +23 -11
- package/lib/cjs/sdk/design/index.js +2 -2
- package/lib/cjs/sdk/design/version.js +11 -0
- package/lib/cjs/sdk/utils/canva_sdk.js +2 -4
- package/lib/esm/sdk/design/fake/fake_design_interaction_client.js +10 -9
- package/lib/esm/sdk/design/index.js +2 -2
- package/lib/esm/sdk/design/version.js +1 -0
- package/lib/esm/sdk/utils/canva_sdk.js +2 -4
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -1582,9 +1582,9 @@ export declare namespace DesignEditing {
|
|
|
1582
1582
|
};
|
|
1583
1583
|
/**
|
|
1584
1584
|
* @public
|
|
1585
|
-
*
|
|
1585
|
+
* Session received by the `openDesign` callback when opening the current page.
|
|
1586
1586
|
*/
|
|
1587
|
-
export type
|
|
1587
|
+
export type CurrentPageSession<
|
|
1588
1588
|
Page = DesignEditing.Page,
|
|
1589
1589
|
Helpers = DesignEditing.PageHelpers,
|
|
1590
1590
|
> = Readonly<{
|
|
@@ -1597,7 +1597,7 @@ export declare namespace DesignEditing {
|
|
|
1597
1597
|
*/
|
|
1598
1598
|
helpers: Helpers;
|
|
1599
1599
|
/**
|
|
1600
|
-
* Saves any changes made during the session while keeping the
|
|
1600
|
+
* Saves any changes made during the session while keeping the session open.
|
|
1601
1601
|
*
|
|
1602
1602
|
* @remarks
|
|
1603
1603
|
* - Any changes in the session are only reflected in the design after this method is called.
|
|
@@ -1605,13 +1605,19 @@ export declare namespace DesignEditing {
|
|
|
1605
1605
|
*/
|
|
1606
1606
|
sync(): Promise<void>;
|
|
1607
1607
|
}>;
|
|
1608
|
+
/**
|
|
1609
|
+
* @deprecated The type has been superseded by `CurrentPageSession`.
|
|
1610
|
+
* @public
|
|
1611
|
+
* Session received by the `openDesign` callback when opening the current page.
|
|
1612
|
+
*/
|
|
1613
|
+
export type CurrentPageResult = CurrentPageSession;
|
|
1614
|
+
|
|
1608
1615
|
/**
|
|
1609
1616
|
* A function called for each item in the list.
|
|
1610
1617
|
*
|
|
1611
1618
|
* @param item - The current item in the list.
|
|
1612
|
-
* @param index - The index of the current item.
|
|
1613
1619
|
*/
|
|
1614
|
-
export type ForEachCallback<M> = (item: M
|
|
1620
|
+
export type ForEachCallback<M> = (item: M) => void;
|
|
1615
1621
|
/**
|
|
1616
1622
|
* A function that determines if an item should be included in the result.
|
|
1617
1623
|
*
|
|
@@ -1731,6 +1737,7 @@ export declare namespace DesignEditing {
|
|
|
1731
1737
|
): U[];
|
|
1732
1738
|
readonly length: number;
|
|
1733
1739
|
readonly [n: number]: T;
|
|
1740
|
+
at(index: number): T | undefined;
|
|
1734
1741
|
}
|
|
1735
1742
|
/**
|
|
1736
1743
|
* @public
|
|
@@ -2687,10 +2694,10 @@ export declare type DesignMetadata = {
|
|
|
2687
2694
|
/**
|
|
2688
2695
|
* @public
|
|
2689
2696
|
* A callback for reading and updating part of a design.
|
|
2690
|
-
* @param session -
|
|
2697
|
+
* @param session - Session received by the `openDesign` callback.
|
|
2691
2698
|
*/
|
|
2692
2699
|
export declare type DesignOpenCallback = (
|
|
2693
|
-
session: DesignEditing.
|
|
2700
|
+
session: DesignEditing.CurrentPageSession,
|
|
2694
2701
|
) => Promise<void>;
|
|
2695
2702
|
|
|
2696
2703
|
/**
|
|
@@ -2,10 +2,21 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
get FakeDesignInteractionClient () {
|
|
8
13
|
return FakeDesignInteractionClient;
|
|
14
|
+
},
|
|
15
|
+
get fakeOpenDesignHelpers () {
|
|
16
|
+
return fakeOpenDesignHelpers;
|
|
17
|
+
},
|
|
18
|
+
get fakePage () {
|
|
19
|
+
return fakePage;
|
|
9
20
|
}
|
|
10
21
|
});
|
|
11
22
|
class FakeDesignInteractionClient {
|
|
@@ -114,14 +125,7 @@ class FakeDesignInteractionClient {
|
|
|
114
125
|
sync: async ()=>{
|
|
115
126
|
await this.delay();
|
|
116
127
|
},
|
|
117
|
-
helpers:
|
|
118
|
-
elementStateBuilder: fakeElementStateBuilder,
|
|
119
|
-
group: fakeAsyncOperations.group,
|
|
120
|
-
ungroup: fakeAsyncOperations.ungroup,
|
|
121
|
-
snapshot: ()=>{
|
|
122
|
-
return {};
|
|
123
|
-
}
|
|
124
|
-
}
|
|
128
|
+
helpers: fakeOpenDesignHelpers
|
|
125
129
|
});
|
|
126
130
|
}
|
|
127
131
|
constructor(delay){
|
|
@@ -360,3 +364,11 @@ const fakeAsyncOperations = {
|
|
|
360
364
|
];
|
|
361
365
|
}
|
|
362
366
|
};
|
|
367
|
+
const fakeOpenDesignHelpers = {
|
|
368
|
+
elementStateBuilder: fakeElementStateBuilder,
|
|
369
|
+
group: fakeAsyncOperations.group,
|
|
370
|
+
ungroup: fakeAsyncOperations.ungroup,
|
|
371
|
+
snapshot: ()=>{
|
|
372
|
+
return {};
|
|
373
|
+
}
|
|
374
|
+
};
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
+
const _version = require("./version");
|
|
5
6
|
_export_star(require("./public"), exports);
|
|
6
7
|
function _export_star(from, to) {
|
|
7
8
|
Object.keys(from).forEach(function(k) {
|
|
@@ -16,5 +17,4 @@ function _export_star(from, to) {
|
|
|
16
17
|
});
|
|
17
18
|
return from;
|
|
18
19
|
}
|
|
19
|
-
|
|
20
|
-
(_window___canva__ = window.__canva__) === null || _window___canva__ === void 0 ? void 0 : (_window___canva___sdkRegistration = _window___canva__.sdkRegistration) === null || _window___canva___sdkRegistration === void 0 ? void 0 : _window___canva___sdkRegistration.registerPackageVersion('design', '2.7.2', 'ga');
|
|
20
|
+
window.__canva__?.sdkRegistration?.registerPackageVersion('design', _version.LATEST_VERSION, 'ga');
|
|
@@ -26,10 +26,8 @@ function getCanvaSdk() {
|
|
|
26
26
|
return window.canva_sdk;
|
|
27
27
|
}
|
|
28
28
|
function assertIsTestCanvaSdk() {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
var _getCanvaSdk_error, _getCanvaSdk;
|
|
32
|
-
const CanvaError = (_getCanvaSdk = getCanvaSdk()) === null || _getCanvaSdk === void 0 ? void 0 : (_getCanvaSdk_error = _getCanvaSdk.error) === null || _getCanvaSdk_error === void 0 ? void 0 : _getCanvaSdk_error.v2.CanvaError;
|
|
29
|
+
if (window.__canva__?.uiKit) {
|
|
30
|
+
const CanvaError = getCanvaSdk()?.error?.v2.CanvaError;
|
|
33
31
|
throw new CanvaError({
|
|
34
32
|
code: 'failed_precondition',
|
|
35
33
|
message: "Canva App SDK: You're attempting to call `initTestEnvironment` in a non-test environment, such as in production. This method should be called in test environments, once and only once. For more info refer to https://canva.dev/docs/apps/testing/"
|
|
@@ -104,14 +104,7 @@ export class FakeDesignInteractionClient {
|
|
|
104
104
|
sync: async ()=>{
|
|
105
105
|
await this.delay();
|
|
106
106
|
},
|
|
107
|
-
helpers:
|
|
108
|
-
elementStateBuilder: fakeElementStateBuilder,
|
|
109
|
-
group: fakeAsyncOperations.group,
|
|
110
|
-
ungroup: fakeAsyncOperations.ungroup,
|
|
111
|
-
snapshot: ()=>{
|
|
112
|
-
return {};
|
|
113
|
-
}
|
|
114
|
-
}
|
|
107
|
+
helpers: fakeOpenDesignHelpers
|
|
115
108
|
});
|
|
116
109
|
}
|
|
117
110
|
constructor(delay){
|
|
@@ -202,7 +195,7 @@ const fakeElementList = {
|
|
|
202
195
|
return fakeRectElement;
|
|
203
196
|
}
|
|
204
197
|
};
|
|
205
|
-
const fakePage = {
|
|
198
|
+
export const fakePage = {
|
|
206
199
|
type: 'absolute',
|
|
207
200
|
locked: false,
|
|
208
201
|
dimensions: fakePageDimensions,
|
|
@@ -350,3 +343,11 @@ const fakeAsyncOperations = {
|
|
|
350
343
|
];
|
|
351
344
|
}
|
|
352
345
|
};
|
|
346
|
+
export const fakeOpenDesignHelpers = {
|
|
347
|
+
elementStateBuilder: fakeElementStateBuilder,
|
|
348
|
+
group: fakeAsyncOperations.group,
|
|
349
|
+
ungroup: fakeAsyncOperations.ungroup,
|
|
350
|
+
snapshot: ()=>{
|
|
351
|
+
return {};
|
|
352
|
+
}
|
|
353
|
+
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
import { LATEST_VERSION } from './version';
|
|
2
2
|
export * from './public';
|
|
3
|
-
|
|
3
|
+
window.__canva__?.sdkRegistration?.registerPackageVersion('design', LATEST_VERSION, 'ga');
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const LATEST_VERSION = '2.7.3';
|
|
@@ -2,10 +2,8 @@ export function getCanvaSdk() {
|
|
|
2
2
|
return window.canva_sdk;
|
|
3
3
|
}
|
|
4
4
|
export function assertIsTestCanvaSdk() {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var _getCanvaSdk_error, _getCanvaSdk;
|
|
8
|
-
const CanvaError = (_getCanvaSdk = getCanvaSdk()) === null || _getCanvaSdk === void 0 ? void 0 : (_getCanvaSdk_error = _getCanvaSdk.error) === null || _getCanvaSdk_error === void 0 ? void 0 : _getCanvaSdk_error.v2.CanvaError;
|
|
5
|
+
if (window.__canva__?.uiKit) {
|
|
6
|
+
const CanvaError = getCanvaSdk()?.error?.v2.CanvaError;
|
|
9
7
|
throw new CanvaError({
|
|
10
8
|
code: 'failed_precondition',
|
|
11
9
|
message: "Canva App SDK: You're attempting to call `initTestEnvironment` in a non-test environment, such as in production. This method should be called in test environments, once and only once. For more info refer to https://canva.dev/docs/apps/testing/"
|