@canva/design 2.7.6-beta.2 → 2.8.0
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/CHANGELOG.md +143 -10
- package/index.d.ts +5049 -1
- package/lib/cjs/sdk/design/fake/create.js +27 -0
- package/lib/cjs/sdk/design/index.js +4 -2
- package/lib/cjs/sdk/design/test/index.js +12 -14
- package/lib/cjs/sdk/design/version.js +2 -2
- package/lib/esm/sdk/design/fake/create.js +17 -0
- package/lib/esm/sdk/design/index.js +3 -1
- package/lib/esm/sdk/design/test/index.js +6 -1
- package/lib/esm/sdk/design/version.js +2 -2
- package/package.json +11 -11
- package/test/index.d.ts +11 -1
- package/beta.d.ts +0 -5366
- package/lib/cjs/sdk/design/beta.js +0 -47
- package/lib/cjs/sdk/design/fake/create_beta.js +0 -96
- package/lib/cjs/sdk/design/test/beta.js +0 -16
- package/lib/esm/sdk/design/beta.js +0 -10
- package/lib/esm/sdk/design/fake/create_beta.js +0 -86
- package/lib/esm/sdk/design/test/beta.js +0 -6
- package/test/beta.d.ts +0 -11
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
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 editContent () {
|
|
13
|
-
return editContent;
|
|
14
|
-
},
|
|
15
|
-
get getDesignMetadata () {
|
|
16
|
-
return getDesignMetadata;
|
|
17
|
-
},
|
|
18
|
-
get getDesignTemplateMetadata () {
|
|
19
|
-
return getDesignTemplateMetadata;
|
|
20
|
-
},
|
|
21
|
-
get openDesign () {
|
|
22
|
-
return openDesign;
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
const _version = require("./version");
|
|
26
|
-
_export_star(require("./public"), exports);
|
|
27
|
-
function _export_star(from, to) {
|
|
28
|
-
Object.keys(from).forEach(function(k) {
|
|
29
|
-
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
30
|
-
Object.defineProperty(to, k, {
|
|
31
|
-
enumerable: true,
|
|
32
|
-
get: function() {
|
|
33
|
-
return from[k];
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
return from;
|
|
39
|
-
}
|
|
40
|
-
const { canva_sdk } = window;
|
|
41
|
-
const getDesignMetadata = canva_sdk.design.v2.designInteraction.getDesignMetadata;
|
|
42
|
-
function editContent(options, callback) {
|
|
43
|
-
return canva_sdk.design.v2.designInteraction.editContent(options, (session)=>callback(session));
|
|
44
|
-
}
|
|
45
|
-
const openDesign = canva_sdk.design.v2.designInteraction.openDesign;
|
|
46
|
-
const getDesignTemplateMetadata = canva_sdk.design.v2.designInteraction.getDesignTemplateMetadata;
|
|
47
|
-
window.__canva__?.sdkRegistration?.registerPackageVersion('design', _version.LATEST_VERSION_BETA, 'beta');
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "createBetaFakeDesignClients", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return createBetaFakeDesignClients;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const _synthetic_delay = require('../../utils/synthetic_delay');
|
|
12
|
-
const _fake_design_interaction_client = require("./fake_design_interaction_client");
|
|
13
|
-
const _fake_drag_and_drop_client = require("./fake_drag_and_drop_client");
|
|
14
|
-
const _fake_export_client = require("./fake_export_client");
|
|
15
|
-
function createBetaFakeDesignClients() {
|
|
16
|
-
const syntheticDelay = (0, _synthetic_delay.createSyntheticDelay)(10);
|
|
17
|
-
const v2 = {
|
|
18
|
-
designInteraction: new FakeBetaDesignInteractionClient(syntheticDelay),
|
|
19
|
-
dragAndDrop: new _fake_drag_and_drop_client.FakeDragAndDropClient(syntheticDelay),
|
|
20
|
-
export: new _fake_export_client.FakeExportClient(syntheticDelay)
|
|
21
|
-
};
|
|
22
|
-
return {
|
|
23
|
-
design: {
|
|
24
|
-
v2
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
class FakeBetaDesignInteractionClient extends _fake_design_interaction_client.FakeDesignInteractionClient {
|
|
29
|
-
async editContent(options, callback) {
|
|
30
|
-
await this.delay();
|
|
31
|
-
await callback({
|
|
32
|
-
contents: [],
|
|
33
|
-
sync: async ()=>{
|
|
34
|
-
await this.delay();
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
async openDesign(options, callback) {
|
|
39
|
-
await this.delay();
|
|
40
|
-
await callback({
|
|
41
|
-
page: _fake_design_interaction_client.fakePage,
|
|
42
|
-
pageRefs: fakePageRefList,
|
|
43
|
-
sync: async ()=>{
|
|
44
|
-
await this.delay();
|
|
45
|
-
},
|
|
46
|
-
helpers: {
|
|
47
|
-
..._fake_design_interaction_client.fakeOpenDesignHelpers,
|
|
48
|
-
openPage: async (_, callback)=>{
|
|
49
|
-
await callback({
|
|
50
|
-
page: _fake_design_interaction_client.fakePage,
|
|
51
|
-
helpers: _fake_design_interaction_client.fakeOpenDesignHelpers
|
|
52
|
-
});
|
|
53
|
-
return {
|
|
54
|
-
status: 'executed'
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
getDesignMetadata() {
|
|
61
|
-
return Promise.resolve({
|
|
62
|
-
title: 'title',
|
|
63
|
-
defaultPageDimensions: {
|
|
64
|
-
width: 800,
|
|
65
|
-
height: 600
|
|
66
|
-
},
|
|
67
|
-
pageMetadata: [
|
|
68
|
-
{
|
|
69
|
-
title: 'title',
|
|
70
|
-
type: 'absolute',
|
|
71
|
-
pageDimensions: {
|
|
72
|
-
width: 800,
|
|
73
|
-
height: 600
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
],
|
|
77
|
-
durationInSeconds: 30
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
const fakePageRef = {
|
|
82
|
-
type: 'absolute',
|
|
83
|
-
locked: false
|
|
84
|
-
};
|
|
85
|
-
const fakePageRefList = {
|
|
86
|
-
forEach (callback) {},
|
|
87
|
-
toArray () {
|
|
88
|
-
return [
|
|
89
|
-
fakePageRef
|
|
90
|
-
];
|
|
91
|
-
},
|
|
92
|
-
count () {
|
|
93
|
-
return 0;
|
|
94
|
-
},
|
|
95
|
-
filter (filter) {}
|
|
96
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict"
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "initTestEnvironment", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return initTestEnvironment;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const _create_beta = require('../fake/create_beta');
|
|
12
|
-
const _canva_sdk = require('../../utils/canva_sdk');
|
|
13
|
-
function initTestEnvironment() {
|
|
14
|
-
(0, _canva_sdk.assertIsTestCanvaSdk)();
|
|
15
|
-
(0, _canva_sdk.injectFakeAPIClients)((0, _create_beta.createBetaFakeDesignClients)());
|
|
16
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { LATEST_VERSION_BETA } from './version';
|
|
2
|
-
const { canva_sdk } = window;
|
|
3
|
-
export const getDesignMetadata = canva_sdk.design.v2.designInteraction.getDesignMetadata;
|
|
4
|
-
export function editContent(options, callback) {
|
|
5
|
-
return canva_sdk.design.v2.designInteraction.editContent(options, (session)=>callback(session));
|
|
6
|
-
}
|
|
7
|
-
export const openDesign = canva_sdk.design.v2.designInteraction.openDesign;
|
|
8
|
-
export const getDesignTemplateMetadata = canva_sdk.design.v2.designInteraction.getDesignTemplateMetadata;
|
|
9
|
-
export * from './public';
|
|
10
|
-
window.__canva__?.sdkRegistration?.registerPackageVersion('design', LATEST_VERSION_BETA, 'beta');
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import { createSyntheticDelay } from '../../utils/synthetic_delay';
|
|
2
|
-
import { FakeDesignInteractionClient, fakeOpenDesignHelpers, fakePage } from './fake_design_interaction_client';
|
|
3
|
-
import { FakeDragAndDropClient } from './fake_drag_and_drop_client';
|
|
4
|
-
import { FakeExportClient } from './fake_export_client';
|
|
5
|
-
export function createBetaFakeDesignClients() {
|
|
6
|
-
const syntheticDelay = createSyntheticDelay(10);
|
|
7
|
-
const v2 = {
|
|
8
|
-
designInteraction: new FakeBetaDesignInteractionClient(syntheticDelay),
|
|
9
|
-
dragAndDrop: new FakeDragAndDropClient(syntheticDelay),
|
|
10
|
-
export: new FakeExportClient(syntheticDelay)
|
|
11
|
-
};
|
|
12
|
-
return {
|
|
13
|
-
design: {
|
|
14
|
-
v2
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
class FakeBetaDesignInteractionClient extends FakeDesignInteractionClient {
|
|
19
|
-
async editContent(options, callback) {
|
|
20
|
-
await this.delay();
|
|
21
|
-
await callback({
|
|
22
|
-
contents: [],
|
|
23
|
-
sync: async ()=>{
|
|
24
|
-
await this.delay();
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
async openDesign(options, callback) {
|
|
29
|
-
await this.delay();
|
|
30
|
-
await callback({
|
|
31
|
-
page: fakePage,
|
|
32
|
-
pageRefs: fakePageRefList,
|
|
33
|
-
sync: async ()=>{
|
|
34
|
-
await this.delay();
|
|
35
|
-
},
|
|
36
|
-
helpers: {
|
|
37
|
-
...fakeOpenDesignHelpers,
|
|
38
|
-
openPage: async (_, callback)=>{
|
|
39
|
-
await callback({
|
|
40
|
-
page: fakePage,
|
|
41
|
-
helpers: fakeOpenDesignHelpers
|
|
42
|
-
});
|
|
43
|
-
return {
|
|
44
|
-
status: 'executed'
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
getDesignMetadata() {
|
|
51
|
-
return Promise.resolve({
|
|
52
|
-
title: 'title',
|
|
53
|
-
defaultPageDimensions: {
|
|
54
|
-
width: 800,
|
|
55
|
-
height: 600
|
|
56
|
-
},
|
|
57
|
-
pageMetadata: [
|
|
58
|
-
{
|
|
59
|
-
title: 'title',
|
|
60
|
-
type: 'absolute',
|
|
61
|
-
pageDimensions: {
|
|
62
|
-
width: 800,
|
|
63
|
-
height: 600
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
],
|
|
67
|
-
durationInSeconds: 30
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
const fakePageRef = {
|
|
72
|
-
type: 'absolute',
|
|
73
|
-
locked: false
|
|
74
|
-
};
|
|
75
|
-
const fakePageRefList = {
|
|
76
|
-
forEach (callback) {},
|
|
77
|
-
toArray () {
|
|
78
|
-
return [
|
|
79
|
-
fakePageRef
|
|
80
|
-
];
|
|
81
|
-
},
|
|
82
|
-
count () {
|
|
83
|
-
return 0;
|
|
84
|
-
},
|
|
85
|
-
filter (filter) {}
|
|
86
|
-
};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { createBetaFakeDesignClients } from '../fake/create_beta';
|
|
2
|
-
import { assertIsTestCanvaSdk, injectFakeAPIClients } from '../../utils/canva_sdk';
|
|
3
|
-
export function initTestEnvironment() {
|
|
4
|
-
assertIsTestCanvaSdk();
|
|
5
|
-
injectFakeAPIClients(createBetaFakeDesignClients());
|
|
6
|
-
}
|
package/test/beta.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @beta
|
|
3
|
-
* Initializes a test environment for the `@canva/design` package, enabling unit tests to mock Canva's APIs.
|
|
4
|
-
* @remarks
|
|
5
|
-
* This method should only be called once in a test environment, such as in a Jest setup file.
|
|
6
|
-
* @see
|
|
7
|
-
* https://www.canva.dev/docs/apps/testing/
|
|
8
|
-
*/
|
|
9
|
-
export declare function initTestEnvironment(): void;
|
|
10
|
-
|
|
11
|
-
export { }
|