@canva/intents 0.0.0-beta.2
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/LICENSE.md +48 -0
- package/README.md +119 -0
- package/asset/beta.d.ts +1 -0
- package/beta.d.ts +975 -0
- package/data/beta.d.ts +898 -0
- package/design/beta.d.ts +45 -0
- package/lib/cjs/sdk/intents/asset/beta.js +4 -0
- package/lib/cjs/sdk/intents/beta.js +63 -0
- package/lib/cjs/sdk/intents/data/beta.js +14 -0
- package/lib/cjs/sdk/intents/design/beta.js +14 -0
- package/lib/esm/sdk/intents/asset/beta.js +1 -0
- package/lib/esm/sdk/intents/beta.js +5 -0
- package/lib/esm/sdk/intents/data/beta.js +4 -0
- package/lib/esm/sdk/intents/design/beta.js +4 -0
- package/package.json +35 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# A message from Canva
|
|
2
|
+
|
|
3
|
+
By making these software components available to you, our goal is to give you
|
|
4
|
+
the right to use the components to build your apps for Canva's ecosystem. See
|
|
5
|
+
below for the specific licence terms that apply to your use.
|
|
6
|
+
|
|
7
|
+
# Licence
|
|
8
|
+
|
|
9
|
+
Canva Pty Ltd (ACN 158 929 938) ("Canva") owns the copyright in the software and
|
|
10
|
+
associated documentation files to which this Licence relates (each a "Software
|
|
11
|
+
Component"). Canva reserves all of its rights.
|
|
12
|
+
|
|
13
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
14
|
+
the Software Components ("You"), to use the Software Components, but strictly
|
|
15
|
+
subject to the following restrictions and conditions:
|
|
16
|
+
|
|
17
|
+
1. You must only use the Software Components and any Derivative on the Canva
|
|
18
|
+
Platform.
|
|
19
|
+
|
|
20
|
+
2. You must only use the Software Components and any Derivative for the purpose
|
|
21
|
+
of building or updating Permitted Apps, and for no other purpose.
|
|
22
|
+
|
|
23
|
+
3. You must include a copy of this Licence in all copies of any Software
|
|
24
|
+
Component and Derivative.
|
|
25
|
+
|
|
26
|
+
4. To the fullest extent permitted by law, the Software Components are provided
|
|
27
|
+
"as is", without warranty of any kind, express or implied, including but not
|
|
28
|
+
limited to the warranties of merchantability, fitness for a particular
|
|
29
|
+
purpose and non-infringement. To the fullest extent permitted by law, in no
|
|
30
|
+
event shall the authors or copyright holders be liable for any claim,
|
|
31
|
+
damages or other liability, whether in an action of contract, tort or
|
|
32
|
+
otherwise, arising from, out of or in connection with the Software Components
|
|
33
|
+
or any Derivative, or the use of or other dealings in the Software Components
|
|
34
|
+
or any Derivative.
|
|
35
|
+
|
|
36
|
+
5. In this Licence:
|
|
37
|
+
|
|
38
|
+
(a) "Canva Platform" means the visual communications platform owned and
|
|
39
|
+
operated by Canva that is made available on Canva.com (as well as any
|
|
40
|
+
sub-domains and international versions) and via mobile applications, desktop
|
|
41
|
+
applications, and in other forms provided or made available by Canva;
|
|
42
|
+
|
|
43
|
+
(b) "Derivative" means any software, document or other material that: (i)
|
|
44
|
+
contains any Software Component; and/or (ii) comprises or contains a
|
|
45
|
+
derivative, adaptation or substantial part of any Software Component; and
|
|
46
|
+
|
|
47
|
+
(c) "Permitted App" means a software application that is solely offered to
|
|
48
|
+
end-users on the Canva Platform.
|
package/README.md
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
# @canva/intents
|
|
2
|
+
|
|
3
|
+
> **_⚠️ This package is currently in beta_**
|
|
4
|
+
|
|
5
|
+
A package for Canva's Apps SDK that provides types and utilities for working with App Intents.
|
|
6
|
+
|
|
7
|
+

|
|
8
|
+
|
|
9
|
+
## Table of contents
|
|
10
|
+
|
|
11
|
+
- [Introduction](#introduction)
|
|
12
|
+
- [Installation](#installation)
|
|
13
|
+
- [Usage](#usage)
|
|
14
|
+
- [Related packages](#related-packages)
|
|
15
|
+
- [Contributing](#contributing)
|
|
16
|
+
- [License](#license)
|
|
17
|
+
|
|
18
|
+
## Introduction
|
|
19
|
+
|
|
20
|
+
`@canva/intents` is an npm package for Canva's [Apps SDK](https://www.canva.dev/docs/apps).
|
|
21
|
+
It provides intent-specific types and helpers that allow apps to integrate with specific surfaces within the Canva editor — such as the data connector panel or the design editor.
|
|
22
|
+
|
|
23
|
+
An "intent" represents a specific user workflow an app can support. For example:
|
|
24
|
+
|
|
25
|
+
- Users can select and import data from an app which implements the **Data Connector** intent.
|
|
26
|
+
- An app is able to present interactive and creative tooling alongside the Canva design surface by implementing the **Design Editor** intent.
|
|
27
|
+
|
|
28
|
+
The `@canva/intents` package encompasses **all available intents**, exporting each intent's type information and prepare function, grouped by domain.
|
|
29
|
+
This allows your app to prepare one or more intents while keeping each intent's implementation modular and type-safe.
|
|
30
|
+
|
|
31
|
+
Currently supported intents:
|
|
32
|
+
|
|
33
|
+
- [`Data Connector`](#data-connector-example)
|
|
34
|
+
- [`Design Editor`](#design-editor-example)
|
|
35
|
+
|
|
36
|
+
New intents will be added to this package in the future.
|
|
37
|
+
|
|
38
|
+
**Note:** To get up and running with the Apps SDK, check out [the quick start guide](https://www.canva.dev/docs/apps/quick-start).
|
|
39
|
+
|
|
40
|
+
## Installation
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
npm install @canva/intents
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Usage
|
|
47
|
+
|
|
48
|
+
### Preparing an intent
|
|
49
|
+
|
|
50
|
+
Each intent type has a corresponding `prepare` function in the `@canva/intents` package. You can implement any intent in your app code by calling the appropriate `prepare` function with the particular parameters it requires.
|
|
51
|
+
|
|
52
|
+
### Data Connector example
|
|
53
|
+
|
|
54
|
+
Here’s a full example of preparing a `data_connector` intent, which allows users to import tabular data from an app:
|
|
55
|
+
|
|
56
|
+
```ts
|
|
57
|
+
import { createRoot } from 'react-dom/client';
|
|
58
|
+
import { AppUiProvider } from '@canva/app-ui-kit';
|
|
59
|
+
import { prepareDataConnector } from '@canva/intents/data';
|
|
60
|
+
import { DataSelectionUI } from './data_selection_ui';
|
|
61
|
+
import { fetchData } from './fetch_data';
|
|
62
|
+
|
|
63
|
+
prepareDataConnector({
|
|
64
|
+
fetchDataTable: async (params) => {
|
|
65
|
+
try {
|
|
66
|
+
const dataTable = await fetchData(params); // your data fetching logic here
|
|
67
|
+
return {
|
|
68
|
+
status: 'completed',
|
|
69
|
+
dataTable,
|
|
70
|
+
};
|
|
71
|
+
} catch {
|
|
72
|
+
return {
|
|
73
|
+
status: 'app_error',
|
|
74
|
+
message: 'Failed to fetch data',
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
|
|
79
|
+
renderSelectionUi: (params) => {
|
|
80
|
+
const root = createRoot(document.getElementById('root') as Element);
|
|
81
|
+
root.render(
|
|
82
|
+
<AppUiProvider>
|
|
83
|
+
<DataSelectionUI {...params} />
|
|
84
|
+
</AppUiProvider>
|
|
85
|
+
);
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### Design Editor example
|
|
91
|
+
|
|
92
|
+
```ts
|
|
93
|
+
import { prepareDesignEditor } from '@canva/intents/design';
|
|
94
|
+
|
|
95
|
+
prepareDesignEditor({
|
|
96
|
+
render() {
|
|
97
|
+
// render logic
|
|
98
|
+
},
|
|
99
|
+
});
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## Related packages
|
|
103
|
+
|
|
104
|
+
The Apps SDK is made up of the following packages:
|
|
105
|
+
|
|
106
|
+
- [`@canva/app-ui-kit`](https://www.npmjs.com/package/@canva/app-ui-kit) - React-based component library for creating apps that mimic the look and feel of Canva.
|
|
107
|
+
- [`@canva/asset`](https://www.npmjs.com/package/@canva/asset) - Provides methods for working with assets, such as image and video files.
|
|
108
|
+
- [`@canva/design`](https://www.npmjs.com/package/@canva/design) - Provides methods for interacting with the user's design, such as creating elements.
|
|
109
|
+
- [`@canva/error`](https://www.npmjs.com/package/@canva/error) - Provides a `CanvaError` class for handling errors.
|
|
110
|
+
- [`@canva/platform`](https://www.npmjs.com/package/@canva/platform) - Provides utility methods, such as a method for opening external links.
|
|
111
|
+
- [`@canva/user`](https://www.npmjs.com/package/@canva/user) - Provides methods for accessing user data and authenticating users.
|
|
112
|
+
|
|
113
|
+
## Contributing
|
|
114
|
+
|
|
115
|
+
We're actively developing this package but are not currently accepting third-party contributions. If you'd like to request any changes or additions to the package, submit a feature request via the [Canva Developers Community](https://community.canva.dev/).
|
|
116
|
+
|
|
117
|
+
## License
|
|
118
|
+
|
|
119
|
+
See the `LICENSE.md` file.
|
package/asset/beta.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|