@canva/design 2.7.4 → 2.7.5-beta.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.
@@ -0,0 +1,59 @@
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 addElementAtPoint () {
13
+ return addElementAtPoint;
14
+ },
15
+ get addPage () {
16
+ return addPage;
17
+ },
18
+ get bulkCreate () {
19
+ return bulkCreate;
20
+ },
21
+ get editContent () {
22
+ return editContent;
23
+ },
24
+ get initAppElement () {
25
+ return initAppElement;
26
+ },
27
+ get openDesign () {
28
+ return openDesign;
29
+ },
30
+ get publish () {
31
+ return publish;
32
+ }
33
+ });
34
+ const _version = require("./version");
35
+ _export_star(require("./public"), exports);
36
+ function _export_star(from, to) {
37
+ Object.keys(from).forEach(function(k) {
38
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
39
+ Object.defineProperty(to, k, {
40
+ enumerable: true,
41
+ get: function() {
42
+ return from[k];
43
+ }
44
+ });
45
+ }
46
+ });
47
+ return from;
48
+ }
49
+ const { canva_sdk } = window;
50
+ const publish = canva_sdk.design.v2.designInteraction.publish;
51
+ const bulkCreate = canva_sdk.design.v2.designInteraction.bulkCreate;
52
+ function editContent(options, callback) {
53
+ return canva_sdk.design.v2.designInteraction.editContent(options, (session)=>callback(session));
54
+ }
55
+ const openDesign = canva_sdk.design.v2.designInteraction.openDesign;
56
+ const addElementAtPoint = canva_sdk.design.v2.designInteraction.addElementAtPoint;
57
+ const initAppElement = canva_sdk.design.v2.designInteraction.initAppElement;
58
+ const addPage = canva_sdk.design.v2.designInteraction.addPage;
59
+ window.__canva__?.sdkRegistration?.registerPackageVersion('design', _version.LATEST_VERSION, 'beta');
@@ -0,0 +1,76 @@
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
+ }
61
+ const fakePageRef = {
62
+ type: 'absolute',
63
+ locked: false
64
+ };
65
+ const fakePageRefList = {
66
+ forEach (callback) {},
67
+ toArray () {
68
+ return [
69
+ fakePageRef
70
+ ];
71
+ },
72
+ count () {
73
+ return 0;
74
+ },
75
+ filter (filter) {}
76
+ };
@@ -140,6 +140,12 @@ class FakeDesignInteractionClient {
140
140
  return ()=>{};
141
141
  }
142
142
  };
143
+ this.publish = {
144
+ launch: ()=>this.delay()
145
+ };
146
+ this.bulkCreate = {
147
+ launch: ()=>this.delay()
148
+ };
143
149
  }
144
150
  }
145
151
  const fakeBounds = {
@@ -1,9 +1,8 @@
1
- "use strict"
1
+ "use strict";
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- const _version = require("./version");
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
- Object.defineProperty(exports, "initTestEnvironment", {
6
- enumerable: true,
7
- get: function() {
8
- return initTestEnvironment;
9
- }
10
- });
11
- const _create = require('../fake/create');
12
- const _canva_sdk = require('../../utils/canva_sdk');
13
- function initTestEnvironment() {
14
- (0, _canva_sdk.assertIsTestCanvaSdk)();
15
- (0, _canva_sdk.injectFakeAPIClients)((0, _create.createFakeDesignClients)());
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,13 @@
1
+ import { LATEST_VERSION } 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 const addElementAtPoint = canva_sdk.design.v2.designInteraction.addElementAtPoint;
10
+ export const initAppElement = canva_sdk.design.v2.designInteraction.initAppElement;
11
+ export const addPage = canva_sdk.design.v2.designInteraction.addPage;
12
+ export * from './public';
13
+ window.__canva__?.sdkRegistration?.registerPackageVersion('design', LATEST_VERSION, 'beta');
@@ -0,0 +1,66 @@
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
+ }
51
+ const fakePageRef = {
52
+ type: 'absolute',
53
+ locked: false
54
+ };
55
+ const fakePageRefList = {
56
+ forEach (callback) {},
57
+ toArray () {
58
+ return [
59
+ fakePageRef
60
+ ];
61
+ },
62
+ count () {
63
+ return 0;
64
+ },
65
+ filter (filter) {}
66
+ };
@@ -119,6 +119,12 @@ export class FakeDesignInteractionClient {
119
119
  return ()=>{};
120
120
  }
121
121
  };
122
+ this.publish = {
123
+ launch: ()=>this.delay()
124
+ };
125
+ this.bulkCreate = {
126
+ launch: ()=>this.delay()
127
+ };
122
128
  }
123
129
  }
124
130
  const fakeBounds = {
@@ -1,3 +1 @@
1
- import { LATEST_VERSION } from './version';
2
- export * from './public';
3
- window.__canva__?.sdkRegistration?.registerPackageVersion('design', LATEST_VERSION, 'ga');
1
+ export * from './beta';
@@ -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
- import { createFakeDesignClients } from '../fake/create';
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.4",
3
+ "version": "2.7.5-beta.1",
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/index.js",
11
- "module": "./lib/esm/sdk/design/index.js",
10
+ "main": "./lib/cjs/sdk/design/beta.js",
11
+ "module": "./lib/esm/sdk/design/beta.js",
12
12
  "exports": {
13
13
  ".": {
14
- "types": "./index.d.ts",
15
- "require": "./lib/cjs/sdk/design/index.js",
16
- "import": "./lib/esm/sdk/design/index.js"
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/index.d.ts",
20
- "require": "./lib/cjs/sdk/design/test/index.js",
21
- "import": "./lib/esm/sdk/design/test/index.js"
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": "./index.d.ts"
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
- }