@canva/design 2.8.0 → 2.8.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.
@@ -0,0 +1,11 @@
1
+ "use strict"
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "ResetToDefault", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return ResetToDefault;
9
+ }
10
+ });
11
+ const ResetToDefault = Symbol.for('$$canva_reset_to_default');
@@ -0,0 +1,56 @@
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 ResetToDefault () {
13
+ return _alpha.ResetToDefault;
14
+ },
15
+ get applyTemplate () {
16
+ return applyTemplate;
17
+ },
18
+ get getBrandTemplateMetadata () {
19
+ return getBrandTemplateMetadata;
20
+ },
21
+ get initAppElement () {
22
+ return initAppElement;
23
+ },
24
+ get openDesign () {
25
+ return openDesign;
26
+ },
27
+ get requestAutofillDesign () {
28
+ return requestAutofillDesign;
29
+ },
30
+ get requestBrandTemplates () {
31
+ return requestBrandTemplates;
32
+ }
33
+ });
34
+ const _version = require("./version");
35
+ const _alpha = require('../../api/design/types/design_interaction/document/alpha');
36
+ _export_star(require("./public"), exports);
37
+ function _export_star(from, to) {
38
+ Object.keys(from).forEach(function(k) {
39
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
40
+ Object.defineProperty(to, k, {
41
+ enumerable: true,
42
+ get: function() {
43
+ return from[k];
44
+ }
45
+ });
46
+ }
47
+ });
48
+ return from;
49
+ }
50
+ const initAppElement = canva_sdk.design.v2.designInteraction.initAppElement;
51
+ const requestAutofillDesign = canva_sdk.design.v2.autofill.requestAutofillDesign;
52
+ const requestBrandTemplates = canva_sdk.design.v2.designInteraction.requestBrandTemplates;
53
+ const getBrandTemplateMetadata = canva_sdk.design.v2.designInteraction.getBrandTemplateMetadata;
54
+ const openDesign = canva_sdk.design.v2.designInteraction.openDesign;
55
+ const applyTemplate = canva_sdk.design.v2.designInteraction.applyTemplate;
56
+ window.__canva__?.sdkRegistration?.registerPackageVersion('design', _version.LATEST_VERSION_ALPHA, 'alpha');
@@ -0,0 +1,98 @@
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_autofill_client = require("./fake_autofill_client");
13
+ const _fake_design_interaction_client = require("./fake_design_interaction_client");
14
+ const _fake_drag_and_drop_client = require("./fake_drag_and_drop_client");
15
+ const _fake_export_client = require("./fake_export_client");
16
+ function createBetaFakeDesignClients() {
17
+ const syntheticDelay = (0, _synthetic_delay.createSyntheticDelay)(10);
18
+ const v2 = {
19
+ designInteraction: new FakeBetaDesignInteractionClient(syntheticDelay),
20
+ dragAndDrop: new _fake_drag_and_drop_client.FakeDragAndDropClient(syntheticDelay),
21
+ export: new _fake_export_client.FakeExportClient(syntheticDelay),
22
+ autofill: new _fake_autofill_client.FakeAutofillClient(syntheticDelay)
23
+ };
24
+ return {
25
+ design: {
26
+ v2
27
+ }
28
+ };
29
+ }
30
+ class FakeBetaDesignInteractionClient extends _fake_design_interaction_client.FakeDesignInteractionClient {
31
+ async editContent(options, callback) {
32
+ await this.delay();
33
+ await callback({
34
+ contents: [],
35
+ sync: async ()=>{
36
+ await this.delay();
37
+ }
38
+ });
39
+ }
40
+ async openDesign(options, callback) {
41
+ await this.delay();
42
+ await callback({
43
+ page: _fake_design_interaction_client.fakePage,
44
+ pageRefs: fakePageRefList,
45
+ sync: async ()=>{
46
+ await this.delay();
47
+ },
48
+ helpers: {
49
+ ..._fake_design_interaction_client.fakeOpenDesignHelpers,
50
+ openPage: async (_, callback)=>{
51
+ await callback({
52
+ page: _fake_design_interaction_client.fakePage,
53
+ helpers: _fake_design_interaction_client.fakeOpenDesignHelpers
54
+ });
55
+ return {
56
+ status: 'executed'
57
+ };
58
+ }
59
+ }
60
+ });
61
+ }
62
+ getDesignMetadata() {
63
+ return Promise.resolve({
64
+ title: 'title',
65
+ defaultPageDimensions: {
66
+ width: 800,
67
+ height: 600
68
+ },
69
+ pageMetadata: [
70
+ {
71
+ title: 'title',
72
+ type: 'absolute',
73
+ pageDimensions: {
74
+ width: 800,
75
+ height: 600
76
+ }
77
+ }
78
+ ],
79
+ durationInSeconds: 30
80
+ });
81
+ }
82
+ }
83
+ const fakePageRef = {
84
+ type: 'absolute',
85
+ locked: false
86
+ };
87
+ const fakePageRefList = {
88
+ forEach (callback) {},
89
+ toArray () {
90
+ return [
91
+ fakePageRef
92
+ ];
93
+ },
94
+ count () {
95
+ return 0;
96
+ },
97
+ filter (filter) {}
98
+ };
@@ -0,0 +1,21 @@
1
+ "use strict"
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "FakeAutofillClient", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return FakeAutofillClient;
9
+ }
10
+ });
11
+ class FakeAutofillClient {
12
+ async requestAutofillDesign(opts) {
13
+ await this.delay();
14
+ return {
15
+ status: 'success'
16
+ };
17
+ }
18
+ constructor(delay){
19
+ this.delay = delay;
20
+ }
21
+ }
@@ -26,6 +26,34 @@ class FakeDesignInteractionClient {
26
26
  token: 'token'
27
27
  };
28
28
  }
29
+ async requestBrandTemplates() {
30
+ await this.delay();
31
+ return {
32
+ status: 'completed',
33
+ brandTemplates: [
34
+ {
35
+ token: 'token'
36
+ }
37
+ ]
38
+ };
39
+ }
40
+ async applyTemplate(options) {
41
+ await this.delay();
42
+ return {
43
+ status: 'completed'
44
+ };
45
+ }
46
+ async getBrandTemplateMetadata(id) {
47
+ await this.delay();
48
+ return {
49
+ domain: 'brand',
50
+ keywords: [
51
+ 'word1',
52
+ 'word2'
53
+ ],
54
+ dataset: undefined
55
+ };
56
+ }
29
57
  async getDesignMetadata() {
30
58
  await this.delay();
31
59
  return {
@@ -388,10 +416,18 @@ const fakeAsyncOperations = {
388
416
  ];
389
417
  }
390
418
  };
419
+ const fakeTimingAccessor = {
420
+ get: ()=>({
421
+ delayInSeconds: 0,
422
+ durationInSeconds: 'until_end_of_page'
423
+ }),
424
+ set: async ()=>{}
425
+ };
391
426
  const fakeOpenDesignHelpers = {
392
427
  elementStateBuilder: fakeElementStateBuilder,
393
428
  group: fakeAsyncOperations.group,
394
429
  ungroup: fakeAsyncOperations.ungroup,
430
+ timingFor: (_elementRef)=>fakeTimingAccessor,
395
431
  snapshot: ()=>{
396
432
  return {};
397
433
  }
@@ -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("./alpha"), 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');
@@ -70,7 +70,6 @@ _export(exports, {
70
70
  return ui;
71
71
  }
72
72
  });
73
- const { canva_sdk } = window;
74
73
  const selection = canva_sdk.design.v2.designInteraction.selection;
75
74
  const overlay = canva_sdk.design.v2.designInteraction.overlay;
76
75
  const addPage = canva_sdk.design.v2.designInteraction.addPage;
@@ -0,0 +1,18 @@
1
+ "use strict"
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
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;
18
+ }
@@ -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("./alpha"), 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
  }
@@ -20,5 +20,5 @@ _export(exports, {
20
20
  }
21
21
  });
22
22
  const LATEST_VERSION = '2.8.0';
23
- const LATEST_VERSION_BETA = '2.7.6-beta.1';
24
- const LATEST_VERSION_ALPHA = 'NONE';
23
+ const LATEST_VERSION_BETA = '2.7.6-beta.2';
24
+ const LATEST_VERSION_ALPHA = '2.8.1-alpha.1';
@@ -0,0 +1 @@
1
+ export const ResetToDefault = Symbol.for('$$canva_reset_to_default');
@@ -0,0 +1,10 @@
1
+ import { LATEST_VERSION_ALPHA } from './version';
2
+ export const initAppElement = canva_sdk.design.v2.designInteraction.initAppElement;
3
+ export const requestAutofillDesign = canva_sdk.design.v2.autofill.requestAutofillDesign;
4
+ export const requestBrandTemplates = canva_sdk.design.v2.designInteraction.requestBrandTemplates;
5
+ export const getBrandTemplateMetadata = canva_sdk.design.v2.designInteraction.getBrandTemplateMetadata;
6
+ export const openDesign = canva_sdk.design.v2.designInteraction.openDesign;
7
+ export const applyTemplate = canva_sdk.design.v2.designInteraction.applyTemplate;
8
+ export { ResetToDefault } from '../../api/design/types/design_interaction/document/alpha';
9
+ export * from './public';
10
+ window.__canva__?.sdkRegistration?.registerPackageVersion('design', LATEST_VERSION_ALPHA, 'alpha');
@@ -0,0 +1,88 @@
1
+ import { createSyntheticDelay } from '../../utils/synthetic_delay';
2
+ import { FakeAutofillClient } from './fake_autofill_client';
3
+ import { FakeDesignInteractionClient, fakeOpenDesignHelpers, fakePage } from './fake_design_interaction_client';
4
+ import { FakeDragAndDropClient } from './fake_drag_and_drop_client';
5
+ import { FakeExportClient } from './fake_export_client';
6
+ export function createBetaFakeDesignClients() {
7
+ const syntheticDelay = createSyntheticDelay(10);
8
+ const v2 = {
9
+ designInteraction: new FakeBetaDesignInteractionClient(syntheticDelay),
10
+ dragAndDrop: new FakeDragAndDropClient(syntheticDelay),
11
+ export: new FakeExportClient(syntheticDelay),
12
+ autofill: new FakeAutofillClient(syntheticDelay)
13
+ };
14
+ return {
15
+ design: {
16
+ v2
17
+ }
18
+ };
19
+ }
20
+ class FakeBetaDesignInteractionClient extends FakeDesignInteractionClient {
21
+ async editContent(options, callback) {
22
+ await this.delay();
23
+ await callback({
24
+ contents: [],
25
+ sync: async ()=>{
26
+ await this.delay();
27
+ }
28
+ });
29
+ }
30
+ async openDesign(options, callback) {
31
+ await this.delay();
32
+ await callback({
33
+ page: fakePage,
34
+ pageRefs: fakePageRefList,
35
+ sync: async ()=>{
36
+ await this.delay();
37
+ },
38
+ helpers: {
39
+ ...fakeOpenDesignHelpers,
40
+ openPage: async (_, callback)=>{
41
+ await callback({
42
+ page: fakePage,
43
+ helpers: fakeOpenDesignHelpers
44
+ });
45
+ return {
46
+ status: 'executed'
47
+ };
48
+ }
49
+ }
50
+ });
51
+ }
52
+ getDesignMetadata() {
53
+ return Promise.resolve({
54
+ title: 'title',
55
+ defaultPageDimensions: {
56
+ width: 800,
57
+ height: 600
58
+ },
59
+ pageMetadata: [
60
+ {
61
+ title: 'title',
62
+ type: 'absolute',
63
+ pageDimensions: {
64
+ width: 800,
65
+ height: 600
66
+ }
67
+ }
68
+ ],
69
+ durationInSeconds: 30
70
+ });
71
+ }
72
+ }
73
+ const fakePageRef = {
74
+ type: 'absolute',
75
+ locked: false
76
+ };
77
+ const fakePageRefList = {
78
+ forEach (callback) {},
79
+ toArray () {
80
+ return [
81
+ fakePageRef
82
+ ];
83
+ },
84
+ count () {
85
+ return 0;
86
+ },
87
+ filter (filter) {}
88
+ };
@@ -0,0 +1,11 @@
1
+ export class FakeAutofillClient {
2
+ async requestAutofillDesign(opts) {
3
+ await this.delay();
4
+ return {
5
+ status: 'success'
6
+ };
7
+ }
8
+ constructor(delay){
9
+ this.delay = delay;
10
+ }
11
+ }
@@ -5,6 +5,34 @@ export class FakeDesignInteractionClient {
5
5
  token: 'token'
6
6
  };
7
7
  }
8
+ async requestBrandTemplates() {
9
+ await this.delay();
10
+ return {
11
+ status: 'completed',
12
+ brandTemplates: [
13
+ {
14
+ token: 'token'
15
+ }
16
+ ]
17
+ };
18
+ }
19
+ async applyTemplate(options) {
20
+ await this.delay();
21
+ return {
22
+ status: 'completed'
23
+ };
24
+ }
25
+ async getBrandTemplateMetadata(id) {
26
+ await this.delay();
27
+ return {
28
+ domain: 'brand',
29
+ keywords: [
30
+ 'word1',
31
+ 'word2'
32
+ ],
33
+ dataset: undefined
34
+ };
35
+ }
8
36
  async getDesignMetadata() {
9
37
  await this.delay();
10
38
  return {
@@ -367,10 +395,18 @@ const fakeAsyncOperations = {
367
395
  ];
368
396
  }
369
397
  };
398
+ const fakeTimingAccessor = {
399
+ get: ()=>({
400
+ delayInSeconds: 0,
401
+ durationInSeconds: 'until_end_of_page'
402
+ }),
403
+ set: async ()=>{}
404
+ };
370
405
  export const fakeOpenDesignHelpers = {
371
406
  elementStateBuilder: fakeElementStateBuilder,
372
407
  group: fakeAsyncOperations.group,
373
408
  ungroup: fakeAsyncOperations.ungroup,
409
+ timingFor: (_elementRef)=>fakeTimingAccessor,
374
410
  snapshot: ()=>{
375
411
  return {};
376
412
  }
@@ -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 './alpha';
@@ -1,4 +1,3 @@
1
- const { canva_sdk } = window;
2
1
  export const selection = canva_sdk.design.v2.designInteraction.selection;
3
2
  export const overlay = canva_sdk.design.v2.designInteraction.overlay;
4
3
  export const addPage = canva_sdk.design.v2.designInteraction.addPage;
@@ -0,0 +1 @@
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 './alpha';
@@ -1,3 +1,3 @@
1
1
  export const LATEST_VERSION = '2.8.0';
2
- export const LATEST_VERSION_BETA = '2.7.6-beta.1';
3
- export const LATEST_VERSION_ALPHA = 'NONE';
2
+ export const LATEST_VERSION_BETA = '2.7.6-beta.2';
3
+ export const LATEST_VERSION_ALPHA = '2.8.1-alpha.1';
package/package.json CHANGED
@@ -1,25 +1,25 @@
1
1
  {
2
2
  "name": "@canva/design",
3
- "version": "2.8.0",
3
+ "version": "2.8.1-alpha.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/alpha.js",
11
+ "module": "./lib/esm/sdk/design/alpha.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": "./alpha.d.ts",
15
+ "require": "./lib/cjs/sdk/design/alpha.js",
16
+ "import": "./lib/esm/sdk/design/alpha.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/alpha.d.ts",
20
+ "require": "./lib/cjs/sdk/design/test/alpha.js",
21
+ "import": "./lib/esm/sdk/design/test/alpha.js"
22
22
  }
23
23
  },
24
- "typings": "./index.d.ts"
25
- }
24
+ "typings": "./alpha.d.ts"
25
+ }
@@ -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 "./alpha";
@@ -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
- }