@canva/design 2.7.5 → 2.7.6-beta.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/beta.d.ts +5565 -0
- package/index.d.ts +1 -5177
- package/lib/cjs/sdk/design/beta.js +47 -0
- package/lib/cjs/sdk/design/fake/create_beta.js +83 -0
- package/lib/cjs/sdk/design/index.js +2 -4
- package/lib/cjs/sdk/design/test/beta.js +16 -0
- package/lib/cjs/sdk/design/test/index.js +14 -12
- package/lib/esm/sdk/design/beta.js +10 -0
- package/lib/esm/sdk/design/fake/create_beta.js +73 -0
- package/lib/esm/sdk/design/index.js +1 -3
- package/lib/esm/sdk/design/test/beta.js +6 -0
- package/lib/esm/sdk/design/test/index.js +1 -6
- package/package.json +10 -10
- package/test/beta.d.ts +11 -0
- package/test/index.d.ts +1 -11
- package/lib/cjs/sdk/design/fake/create.js +0 -27
- package/lib/esm/sdk/design/fake/create.js +0 -17
|
@@ -0,0 +1,47 @@
|
|
|
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 bulkCreate () {
|
|
13
|
+
return bulkCreate;
|
|
14
|
+
},
|
|
15
|
+
get editContent () {
|
|
16
|
+
return editContent;
|
|
17
|
+
},
|
|
18
|
+
get openDesign () {
|
|
19
|
+
return openDesign;
|
|
20
|
+
},
|
|
21
|
+
get publish () {
|
|
22
|
+
return publish;
|
|
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 publish = canva_sdk.design.v2.designInteraction.publish;
|
|
42
|
+
const bulkCreate = canva_sdk.design.v2.designInteraction.bulkCreate;
|
|
43
|
+
function editContent(options, callback) {
|
|
44
|
+
return canva_sdk.design.v2.designInteraction.editContent(options, (session)=>callback(session));
|
|
45
|
+
}
|
|
46
|
+
const openDesign = canva_sdk.design.v2.designInteraction.openDesign;
|
|
47
|
+
window.__canva__?.sdkRegistration?.registerPackageVersion('design', _version.LATEST_VERSION_BETA, 'beta');
|
|
@@ -0,0 +1,83 @@
|
|
|
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
|
+
constructor(...args){
|
|
61
|
+
super(...args), this.publish = {
|
|
62
|
+
launch: ()=>this.delay()
|
|
63
|
+
}, this.bulkCreate = {
|
|
64
|
+
launch: ()=>this.delay()
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
const fakePageRef = {
|
|
69
|
+
type: 'absolute',
|
|
70
|
+
locked: false
|
|
71
|
+
};
|
|
72
|
+
const fakePageRefList = {
|
|
73
|
+
forEach (callback) {},
|
|
74
|
+
toArray () {
|
|
75
|
+
return [
|
|
76
|
+
fakePageRef
|
|
77
|
+
];
|
|
78
|
+
},
|
|
79
|
+
count () {
|
|
80
|
+
return 0;
|
|
81
|
+
},
|
|
82
|
+
filter (filter) {}
|
|
83
|
+
};
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
"use strict"
|
|
1
|
+
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
|
|
6
|
-
_export_star(require("./public"), exports);
|
|
5
|
+
_export_star(require("./beta"), exports);
|
|
7
6
|
function _export_star(from, to) {
|
|
8
7
|
Object.keys(from).forEach(function(k) {
|
|
9
8
|
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
@@ -17,4 +16,3 @@ function _export_star(from, to) {
|
|
|
17
16
|
});
|
|
18
17
|
return from;
|
|
19
18
|
}
|
|
20
|
-
window.__canva__?.sdkRegistration?.registerPackageVersion('design', _version.LATEST_VERSION, 'ga');
|
|
@@ -0,0 +1,16 @@
|
|
|
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,16 +1,18 @@
|
|
|
1
|
-
"use strict"
|
|
1
|
+
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
5
|
+
_export_star(require("./beta"), exports);
|
|
6
|
+
function _export_star(from, to) {
|
|
7
|
+
Object.keys(from).forEach(function(k) {
|
|
8
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
9
|
+
Object.defineProperty(to, k, {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function() {
|
|
12
|
+
return from[k];
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
return from;
|
|
16
18
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { LATEST_VERSION_BETA } from './version';
|
|
2
|
+
const { canva_sdk } = window;
|
|
3
|
+
export const publish = canva_sdk.design.v2.designInteraction.publish;
|
|
4
|
+
export const bulkCreate = canva_sdk.design.v2.designInteraction.bulkCreate;
|
|
5
|
+
export function editContent(options, callback) {
|
|
6
|
+
return canva_sdk.design.v2.designInteraction.editContent(options, (session)=>callback(session));
|
|
7
|
+
}
|
|
8
|
+
export const openDesign = canva_sdk.design.v2.designInteraction.openDesign;
|
|
9
|
+
export * from './public';
|
|
10
|
+
window.__canva__?.sdkRegistration?.registerPackageVersion('design', LATEST_VERSION_BETA, 'beta');
|
|
@@ -0,0 +1,73 @@
|
|
|
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
|
+
constructor(...args){
|
|
51
|
+
super(...args), this.publish = {
|
|
52
|
+
launch: ()=>this.delay()
|
|
53
|
+
}, this.bulkCreate = {
|
|
54
|
+
launch: ()=>this.delay()
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
const fakePageRef = {
|
|
59
|
+
type: 'absolute',
|
|
60
|
+
locked: false
|
|
61
|
+
};
|
|
62
|
+
const fakePageRefList = {
|
|
63
|
+
forEach (callback) {},
|
|
64
|
+
toArray () {
|
|
65
|
+
return [
|
|
66
|
+
fakePageRef
|
|
67
|
+
];
|
|
68
|
+
},
|
|
69
|
+
count () {
|
|
70
|
+
return 0;
|
|
71
|
+
},
|
|
72
|
+
filter (filter) {}
|
|
73
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
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
|
+
}
|
|
@@ -1,6 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { assertIsTestCanvaSdk, injectFakeAPIClients } from '../../utils/canva_sdk';
|
|
3
|
-
export function initTestEnvironment() {
|
|
4
|
-
assertIsTestCanvaSdk();
|
|
5
|
-
injectFakeAPIClients(createFakeDesignClients());
|
|
6
|
-
}
|
|
1
|
+
export * from './beta';
|
package/package.json
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@canva/design",
|
|
3
|
-
"version": "2.7.
|
|
3
|
+
"version": "2.7.6-beta.0",
|
|
4
4
|
"description": "The Canva Apps SDK design library",
|
|
5
5
|
"author": "Canva Pty Ltd.",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE.md FILE",
|
|
7
7
|
"peerDependencies": {
|
|
8
8
|
"@canva/error": "^2.0.0"
|
|
9
9
|
},
|
|
10
|
-
"main": "./lib/cjs/sdk/design/
|
|
11
|
-
"module": "./lib/esm/sdk/design/
|
|
10
|
+
"main": "./lib/cjs/sdk/design/beta.js",
|
|
11
|
+
"module": "./lib/esm/sdk/design/beta.js",
|
|
12
12
|
"exports": {
|
|
13
13
|
".": {
|
|
14
|
-
"types": "./
|
|
15
|
-
"require": "./lib/cjs/sdk/design/
|
|
16
|
-
"import": "./lib/esm/sdk/design/
|
|
14
|
+
"types": "./beta.d.ts",
|
|
15
|
+
"require": "./lib/cjs/sdk/design/beta.js",
|
|
16
|
+
"import": "./lib/esm/sdk/design/beta.js"
|
|
17
17
|
},
|
|
18
18
|
"./test": {
|
|
19
|
-
"types": "./test/
|
|
20
|
-
"require": "./lib/cjs/sdk/design/test/
|
|
21
|
-
"import": "./lib/esm/sdk/design/test/
|
|
19
|
+
"types": "./test/beta.d.ts",
|
|
20
|
+
"require": "./lib/cjs/sdk/design/test/beta.js",
|
|
21
|
+
"import": "./lib/esm/sdk/design/test/beta.js"
|
|
22
22
|
}
|
|
23
23
|
},
|
|
24
|
-
"typings": "./
|
|
24
|
+
"typings": "./beta.d.ts"
|
|
25
25
|
}
|
package/test/beta.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
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 {};
|
package/test/index.d.ts
CHANGED
|
@@ -1,11 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* @public
|
|
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 {};
|
|
1
|
+
export * from "./beta";
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict"
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "createFakeDesignClients", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return createFakeDesignClients;
|
|
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 createFakeDesignClients() {
|
|
16
|
-
const syntheticDelay = (0, _synthetic_delay.createSyntheticDelay)(10);
|
|
17
|
-
const v2 = {
|
|
18
|
-
designInteraction: new _fake_design_interaction_client.FakeDesignInteractionClient(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
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { createSyntheticDelay } from '../../utils/synthetic_delay';
|
|
2
|
-
import { FakeDesignInteractionClient } from './fake_design_interaction_client';
|
|
3
|
-
import { FakeDragAndDropClient } from './fake_drag_and_drop_client';
|
|
4
|
-
import { FakeExportClient } from './fake_export_client';
|
|
5
|
-
export function createFakeDesignClients() {
|
|
6
|
-
const syntheticDelay = createSyntheticDelay(10);
|
|
7
|
-
const v2 = {
|
|
8
|
-
designInteraction: new FakeDesignInteractionClient(syntheticDelay),
|
|
9
|
-
dragAndDrop: new FakeDragAndDropClient(syntheticDelay),
|
|
10
|
-
export: new FakeExportClient(syntheticDelay)
|
|
11
|
-
};
|
|
12
|
-
return {
|
|
13
|
-
design: {
|
|
14
|
-
v2
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
}
|