@canva/cli 0.0.1-beta.34 → 0.0.1-beta.36
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/README.md +4 -9
- package/cli.js +682 -600
- package/lib/cjs/index.cjs +4 -4
- package/lib/esm/index.mjs +4 -4
- package/package.json +3 -3
- package/templates/base/backend/routers/auth.ts +4 -4
- package/templates/base/backend/routers/oauth.ts +3 -3
- package/templates/base/package.json +19 -19
- package/templates/base/scripts/ssl/ssl.ts +1 -1
- package/templates/base/scripts/start/app_runner.ts +6 -6
- package/templates/base/scripts/start/start.ts +1 -1
- package/templates/base/utils/backend/base_backend/create.ts +3 -3
- package/templates/base/utils/backend/bearer_middleware/bearer_middleware.ts +2 -2
- package/templates/base/utils/backend/jwt_middleware/jwt_middleware.ts +4 -4
- package/templates/base/utils/backend/jwt_middleware/tests/jwt_middleware.tests.ts +1 -1
- package/templates/base/utils/use_add_element.ts +1 -1
- package/templates/base/utils/use_feature_support.ts +1 -1
- package/templates/base/webpack.config.ts +2 -20
- package/templates/common/jest.config.mjs +1 -1
- package/templates/common/utils/backend/base_backend/create.ts +3 -3
- package/templates/common/utils/backend/jwt_middleware/jwt_middleware.ts +4 -4
- package/templates/common/utils/backend/jwt_middleware/tests/jwt_middleware.tests.ts +1 -1
- package/templates/common/utils/tests/table_wrapper.tests.ts +1 -1
- package/templates/common/utils/use_add_element.ts +1 -1
- package/templates/common/utils/use_feature_support.ts +1 -1
- package/templates/dam/backend/routers/dam.ts +2 -2
- package/templates/dam/backend/server.ts +1 -1
- package/templates/dam/canva-app.json +16 -0
- package/templates/dam/package.json +26 -26
- package/templates/dam/scripts/ssl/ssl.ts +1 -1
- package/templates/dam/scripts/start/app_runner.ts +6 -6
- package/templates/dam/scripts/start/start.ts +1 -1
- package/templates/dam/src/app.tsx +1 -1
- package/templates/dam/src/index.tsx +1 -1
- package/templates/dam/utils/backend/base_backend/create.ts +3 -3
- package/templates/dam/utils/backend/jwt_middleware/jwt_middleware.ts +4 -4
- package/templates/dam/utils/backend/jwt_middleware/tests/jwt_middleware.tests.ts +1 -1
- package/templates/dam/webpack.config.ts +2 -20
- package/templates/data_connector/README.md +2 -2
- package/templates/data_connector/canva-app.json +21 -0
- package/templates/data_connector/package.json +26 -26
- package/templates/data_connector/scripts/ssl/ssl.ts +1 -1
- package/templates/data_connector/scripts/start/app_runner.ts +6 -6
- package/templates/data_connector/scripts/start/start.ts +1 -1
- package/templates/data_connector/src/api/data_source.ts +1 -1
- package/templates/data_connector/src/api/data_sources/designs.tsx +9 -9
- package/templates/data_connector/src/api/data_sources/templates.tsx +9 -9
- package/templates/data_connector/src/api/fetch_data_table.ts +1 -1
- package/templates/data_connector/src/api/tests/data_source.test.tsx +2 -2
- package/templates/data_connector/src/app.tsx +5 -5
- package/templates/data_connector/src/components/footer.tsx +1 -1
- package/templates/data_connector/src/components/header.tsx +1 -1
- package/templates/data_connector/src/context/app_context.tsx +1 -1
- package/templates/data_connector/src/entrypoint.tsx +7 -7
- package/templates/data_connector/src/home.tsx +2 -2
- package/templates/data_connector/src/index.tsx +5 -6
- package/templates/data_connector/src/pages/error.tsx +2 -2
- package/templates/data_connector/src/pages/login.tsx +7 -7
- package/templates/data_connector/src/routes/routes.tsx +1 -1
- package/templates/data_connector/src/utils/data_table.ts +1 -1
- package/templates/data_connector/src/utils/fetch_result.ts +1 -1
- package/templates/data_connector/src/utils/tests/data_table.test.ts +5 -5
- package/templates/data_connector/webpack.config.ts +2 -20
- package/templates/gen_ai/backend/server.ts +1 -1
- package/templates/gen_ai/canva-app.json +20 -0
- package/templates/gen_ai/package.json +30 -30
- package/templates/gen_ai/scripts/ssl/ssl.ts +1 -1
- package/templates/gen_ai/scripts/start/app_runner.ts +6 -6
- package/templates/gen_ai/scripts/start/start.ts +1 -1
- package/templates/gen_ai/src/app.tsx +3 -3
- package/templates/gen_ai/src/components/footer.tsx +4 -4
- package/templates/gen_ai/src/components/image_grid.tsx +1 -1
- package/templates/gen_ai/src/components/loading_results.tsx +8 -8
- package/templates/gen_ai/src/components/prompt_input.tsx +3 -3
- package/templates/gen_ai/src/components/remaining_credits.tsx +1 -1
- package/templates/gen_ai/src/components/report_box.tsx +1 -1
- package/templates/gen_ai/src/components/tests/remaining_credit.tests.tsx +2 -2
- package/templates/gen_ai/src/home.tsx +2 -2
- package/templates/gen_ai/src/pages/error.tsx +2 -2
- package/templates/gen_ai/src/pages/results.tsx +1 -1
- package/templates/gen_ai/utils/backend/base_backend/create.ts +3 -3
- package/templates/gen_ai/utils/backend/bearer_middleware/bearer_middleware.ts +2 -2
- package/templates/gen_ai/webpack.config.ts +2 -20
- package/templates/hello_world/canva-app.json +16 -0
- package/templates/hello_world/package.json +24 -24
- package/templates/hello_world/scripts/ssl/ssl.ts +1 -1
- package/templates/hello_world/scripts/start/app_runner.ts +6 -6
- package/templates/hello_world/scripts/start/start.ts +1 -1
- package/templates/hello_world/src/app.tsx +1 -1
- package/templates/hello_world/src/index.tsx +1 -1
- package/templates/hello_world/src/tests/app.tests.tsx +3 -3
- package/templates/hello_world/utils/use_add_element.ts +1 -1
- package/templates/hello_world/utils/use_feature_support.ts +1 -1
- package/templates/hello_world/webpack.config.ts +2 -20
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { useEffect, useState } from "react";
|
|
2
|
-
import { useNavigate } from "react-router-dom";
|
|
3
1
|
import {
|
|
4
|
-
|
|
2
|
+
Box,
|
|
3
|
+
Button,
|
|
5
4
|
Grid,
|
|
6
5
|
Placeholder,
|
|
7
6
|
ProgressBar,
|
|
7
|
+
Rows,
|
|
8
8
|
Text,
|
|
9
|
-
Button,
|
|
10
|
-
Box,
|
|
11
9
|
} from "@canva/app-ui-kit";
|
|
12
|
-
import {
|
|
13
|
-
import { useAppContext } from "src/context";
|
|
14
|
-
import { cancelImageGenerationJob, getImageGenerationJobStatus } from "src/api";
|
|
10
|
+
import { useEffect, useState } from "react";
|
|
15
11
|
import { FormattedMessage, useIntl } from "react-intl";
|
|
12
|
+
import { useNavigate } from "react-router-dom";
|
|
13
|
+
import { cancelImageGenerationJob, getImageGenerationJobStatus } from "src/api";
|
|
14
|
+
import { useAppContext } from "src/context";
|
|
15
|
+
import { Paths } from "src/routes";
|
|
16
16
|
|
|
17
17
|
const INTERVAL_DURATION_IN_MS = 100;
|
|
18
18
|
const TOTAL_PROGRESS_PERCENTAGE = 100;
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { useState } from "react";
|
|
2
|
-
import { useLocation } from "react-router-dom";
|
|
3
1
|
import {
|
|
4
2
|
Box,
|
|
5
3
|
Button,
|
|
@@ -7,10 +5,12 @@ import {
|
|
|
7
5
|
LightBulbIcon,
|
|
8
6
|
MultilineInput,
|
|
9
7
|
} from "@canva/app-ui-kit";
|
|
8
|
+
import { useState } from "react";
|
|
9
|
+
import { useIntl } from "react-intl";
|
|
10
|
+
import { useLocation } from "react-router-dom";
|
|
10
11
|
import { useAppContext } from "src/context";
|
|
11
12
|
import { Paths } from "src/routes";
|
|
12
13
|
import { PromptInputMessages as Messages } from "./prompt_input.messages";
|
|
13
|
-
import { useIntl } from "react-intl";
|
|
14
14
|
|
|
15
15
|
// @TODO: Adjust according to your specific requirements.
|
|
16
16
|
const MAX_INPUT_LENGTH = 280;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Link, Rows, Text, TextPlaceholder } from "@canva/app-ui-kit";
|
|
2
2
|
import { requestOpenExternalUrl } from "@canva/platform";
|
|
3
|
-
import { useAppContext } from "src/context";
|
|
4
3
|
import { FormattedMessage, useIntl } from "react-intl";
|
|
4
|
+
import { useAppContext } from "src/context";
|
|
5
5
|
|
|
6
6
|
// @TODO: Replace this URL with your custom upselling link.
|
|
7
7
|
const PURCHASE_URL = "https://example.com";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Box,
|
|
1
|
+
import { Box, Column, Columns, FlagIcon, Link, Text } from "@canva/app-ui-kit";
|
|
2
2
|
import { requestOpenExternalUrl } from "@canva/platform";
|
|
3
3
|
import { FormattedMessage, useIntl } from "react-intl";
|
|
4
4
|
import { APP_NAME } from "src/config";
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/* eslint-disable formatjs/no-literal-string-in-jsx */
|
|
2
|
-
import { TestAppUiProvider } from "@canva/app-ui-kit";
|
|
3
2
|
import { TestAppI18nProvider } from "@canva/app-i18n-kit";
|
|
3
|
+
import { TestAppUiProvider } from "@canva/app-ui-kit";
|
|
4
|
+
import { requestOpenExternalUrl } from "@canva/platform";
|
|
4
5
|
import type { RenderResult } from "@testing-library/react";
|
|
5
6
|
import { fireEvent, render } from "@testing-library/react";
|
|
6
7
|
import React from "react";
|
|
7
8
|
import { RemainingCredits } from "../remaining_credits";
|
|
8
|
-
import { requestOpenExternalUrl } from "@canva/platform";
|
|
9
9
|
|
|
10
10
|
function renderInTestProvider(node: React.ReactNode): RenderResult {
|
|
11
11
|
return render(
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Outlet } from "react-router-dom";
|
|
2
1
|
import { Rows } from "@canva/app-ui-kit";
|
|
3
|
-
import {
|
|
2
|
+
import { Outlet } from "react-router-dom";
|
|
4
3
|
import * as styles from "styles/components.css";
|
|
4
|
+
import { Footer } from "./components";
|
|
5
5
|
|
|
6
6
|
export const Home = () => (
|
|
7
7
|
<div className={styles.scrollContainer}>
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { useNavigate } from "react-router-dom";
|
|
2
1
|
import { Button, Rows, Text } from "@canva/app-ui-kit";
|
|
2
|
+
import { FormattedMessage, useIntl } from "react-intl";
|
|
3
|
+
import { useNavigate } from "react-router-dom";
|
|
3
4
|
import { useAppContext } from "src/context";
|
|
4
5
|
import { Paths } from "src/routes";
|
|
5
6
|
import * as styles from "styles/components.css";
|
|
6
|
-
import { FormattedMessage, useIntl } from "react-intl";
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Bare bones Error Page, please add relevant information and behavior that your app requires.
|
|
@@ -6,8 +6,8 @@ import {
|
|
|
6
6
|
PromptInput,
|
|
7
7
|
ReportBox,
|
|
8
8
|
} from "src/components";
|
|
9
|
-
import { useAppContext } from "src/context";
|
|
10
9
|
import { EXPECTED_LOADING_TIME_IN_SECONDS } from "src/config";
|
|
10
|
+
import { useAppContext } from "src/context";
|
|
11
11
|
|
|
12
12
|
export const ResultsPage = () => {
|
|
13
13
|
const { isLoadingImages } = useAppContext();
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/* eslint-disable no-console */
|
|
2
|
+
import debug from "debug";
|
|
2
3
|
import * as express from "express";
|
|
4
|
+
import type { NextFunction, Request, Response } from "express";
|
|
5
|
+
import * as fs from "fs";
|
|
3
6
|
import * as http from "http";
|
|
4
7
|
import * as https from "https";
|
|
5
|
-
import * as fs from "fs";
|
|
6
|
-
import type { Request, Response, NextFunction } from "express";
|
|
7
|
-
import debug from "debug";
|
|
8
8
|
|
|
9
9
|
const serverDebug = debug("server");
|
|
10
10
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* eslint-disable no-console */
|
|
2
2
|
import * as debug from "debug";
|
|
3
|
-
import type { Request, Response
|
|
3
|
+
import type { NextFunction, Request, Response } from "express";
|
|
4
4
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
5
5
|
import Express from "express-serve-static-core";
|
|
6
6
|
|
|
@@ -45,7 +45,7 @@ export function createBearerMiddleware(
|
|
|
45
45
|
throw new AuthorizationError("Token is invalid");
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
req
|
|
48
|
+
req["user_id"] = user;
|
|
49
49
|
|
|
50
50
|
next();
|
|
51
51
|
} catch (e) {
|
|
@@ -24,7 +24,7 @@ export function buildConfig({
|
|
|
24
24
|
appEntry = path.join(process.cwd(), "src", "index.tsx"),
|
|
25
25
|
backendHost = process.env.CANVA_BACKEND_HOST,
|
|
26
26
|
// For IN_HARNESS, refer to the following docs for more information: https://www.canva.dev/docs/apps/test-harness/
|
|
27
|
-
inHarness = process.env.IN_HARNESS === "true",
|
|
27
|
+
inHarness = process.env.IN_HARNESS?.toLowerCase() === "true",
|
|
28
28
|
}: {
|
|
29
29
|
devConfig?: DevConfig;
|
|
30
30
|
appEntry?: string;
|
|
@@ -182,7 +182,7 @@ export function buildConfig({
|
|
|
182
182
|
new DefinePlugin({
|
|
183
183
|
BACKEND_HOST: JSON.stringify(backendHost),
|
|
184
184
|
}),
|
|
185
|
-
// Apps can only submit a single JS file via the
|
|
185
|
+
// Apps can only submit a single JS file via the Developer Portal
|
|
186
186
|
new optimize.LimitChunkCountPlugin({ maxChunks: 1 }),
|
|
187
187
|
].filter(Boolean),
|
|
188
188
|
...buildDevConfig(devConfig),
|
|
@@ -236,24 +236,6 @@ function buildDevConfig(options?: DevConfig): {
|
|
|
236
236
|
"Access-Control-Allow-Private-Network": "true",
|
|
237
237
|
},
|
|
238
238
|
};
|
|
239
|
-
} else if (enableHmr && appId) {
|
|
240
|
-
// Deprecated - App ID should not be used to configure HMR in the future and can be safely removed
|
|
241
|
-
// after a few months.
|
|
242
|
-
|
|
243
|
-
console.warn(
|
|
244
|
-
"Enabling Hot Module Replacement (HMR) with an App ID is deprecated, please see the README.md on how to update.",
|
|
245
|
-
);
|
|
246
|
-
|
|
247
|
-
const appDomain = `app-${appId.toLowerCase().trim()}.canva-apps.com`;
|
|
248
|
-
devServer = {
|
|
249
|
-
...devServer,
|
|
250
|
-
allowedHosts: [host, appDomain],
|
|
251
|
-
headers: {
|
|
252
|
-
"Access-Control-Allow-Origin": `https://${appDomain}`,
|
|
253
|
-
"Access-Control-Allow-Credentials": "true",
|
|
254
|
-
"Access-Control-Allow-Private-Network": "true",
|
|
255
|
-
},
|
|
256
|
-
};
|
|
257
239
|
} else {
|
|
258
240
|
if (enableHmr && !appOrigin) {
|
|
259
241
|
console.warn(
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"manifest_schema_version": 1,
|
|
3
|
+
"runtime": {
|
|
4
|
+
"permissions": [
|
|
5
|
+
{
|
|
6
|
+
"name": "canva:design:content:read",
|
|
7
|
+
"type": "mandatory"
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"name": "canva:design:content:write",
|
|
11
|
+
"type": "mandatory"
|
|
12
|
+
}
|
|
13
|
+
],
|
|
14
|
+
"supported_devices": ["desktop", "mobile"]
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -19,13 +19,13 @@
|
|
|
19
19
|
"postinstall": "ts-node ./scripts/copy_env.ts"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@canva/app-i18n-kit": "^1.0.
|
|
22
|
+
"@canva/app-i18n-kit": "^1.0.3",
|
|
23
23
|
"@canva/app-ui-kit": "^4.10.0",
|
|
24
|
-
"@canva/asset": "^2.2.
|
|
25
|
-
"@canva/design": "^2.
|
|
24
|
+
"@canva/asset": "^2.2.1",
|
|
25
|
+
"@canva/design": "^2.7.0",
|
|
26
26
|
"@canva/error": "^2.1.0",
|
|
27
27
|
"@canva/platform": "^2.2.0",
|
|
28
|
-
"@canva/user": "^2.1.
|
|
28
|
+
"@canva/user": "^2.1.1",
|
|
29
29
|
"react": "18.3.1",
|
|
30
30
|
"react-dom": "18.3.1",
|
|
31
31
|
"react-intl": "6.8.7"
|
|
@@ -33,55 +33,55 @@
|
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@canva/app-eslint-plugin": "^1.0.0-beta.3",
|
|
35
35
|
"@canva/cli": ">= 0.0.1-beta.13 < 0.0.2",
|
|
36
|
-
"@formatjs/cli": "6.
|
|
37
|
-
"@formatjs/ts-transformer": "3.
|
|
38
|
-
"@ngrok/ngrok": "1.
|
|
39
|
-
"@pmmmwh/react-refresh-webpack-plugin": "0.
|
|
36
|
+
"@formatjs/cli": "6.7.2",
|
|
37
|
+
"@formatjs/ts-transformer": "3.14.0",
|
|
38
|
+
"@ngrok/ngrok": "1.5.1",
|
|
39
|
+
"@pmmmwh/react-refresh-webpack-plugin": "0.6.1",
|
|
40
40
|
"@svgr/webpack": "8.1.0",
|
|
41
|
-
"@testing-library/react": "16.
|
|
41
|
+
"@testing-library/react": "16.3.0",
|
|
42
42
|
"@types/express": "4.17.21",
|
|
43
|
-
"@types/express-serve-static-core": "
|
|
43
|
+
"@types/express-serve-static-core": "5.0.6",
|
|
44
44
|
"@types/jest": "29.5.14",
|
|
45
|
-
"@types/jsonwebtoken": "9.0.
|
|
46
|
-
"@types/node": "20.
|
|
45
|
+
"@types/jsonwebtoken": "9.0.10",
|
|
46
|
+
"@types/node": "20.19.2",
|
|
47
47
|
"@types/node-fetch": "2.6.12",
|
|
48
48
|
"@types/node-forge": "1.3.11",
|
|
49
49
|
"@types/nodemon": "1.19.6",
|
|
50
50
|
"@types/react": "18.3.12",
|
|
51
51
|
"@types/react-dom": "18.3.1",
|
|
52
|
-
"@types/webpack-env": "1.18.
|
|
52
|
+
"@types/webpack-env": "1.18.8",
|
|
53
53
|
"chalk": "4.1.2",
|
|
54
54
|
"cli-table3": "0.6.5",
|
|
55
55
|
"css-loader": "7.1.2",
|
|
56
56
|
"css-modules-typescript-loader": "4.0.1",
|
|
57
|
-
"cssnano": "7.0.
|
|
58
|
-
"debug": "4.4.
|
|
59
|
-
"dotenv": "16.
|
|
57
|
+
"cssnano": "7.0.7",
|
|
58
|
+
"debug": "4.4.1",
|
|
59
|
+
"dotenv": "16.6.0",
|
|
60
60
|
"express": "4.21.2",
|
|
61
61
|
"express-basic-auth": "1.2.1",
|
|
62
62
|
"jest": "29.7.0",
|
|
63
63
|
"jest-css-modules-transform": "4.4.2",
|
|
64
64
|
"jest-environment-jsdom": "29.7.0",
|
|
65
65
|
"jsonwebtoken": "9.0.2",
|
|
66
|
-
"jwks-rsa": "3.
|
|
66
|
+
"jwks-rsa": "3.2.0",
|
|
67
67
|
"mini-css-extract-plugin": "2.9.2",
|
|
68
68
|
"node-fetch": "3.3.2",
|
|
69
69
|
"node-forge": "1.3.1",
|
|
70
70
|
"nodemon": "3.0.1",
|
|
71
71
|
"open": "8.4.2",
|
|
72
72
|
"postcss-loader": "8.1.1",
|
|
73
|
-
"prettier": "3.
|
|
74
|
-
"react-refresh": "0.
|
|
73
|
+
"prettier": "3.6.2",
|
|
74
|
+
"react-refresh": "0.17.0",
|
|
75
75
|
"style-loader": "4.0.0",
|
|
76
|
-
"terser-webpack-plugin": "5.3.
|
|
76
|
+
"terser-webpack-plugin": "5.3.14",
|
|
77
77
|
"tree-kill": "1.2.2",
|
|
78
|
-
"ts-jest": "29.
|
|
78
|
+
"ts-jest": "29.4.0",
|
|
79
79
|
"ts-loader": "9.5.2",
|
|
80
80
|
"ts-node": "10.9.2",
|
|
81
|
-
"typescript": "5.
|
|
81
|
+
"typescript": "5.8.2",
|
|
82
82
|
"url-loader": "4.1.1",
|
|
83
|
-
"webpack": "5.
|
|
84
|
-
"webpack-cli": "
|
|
83
|
+
"webpack": "5.99.9",
|
|
84
|
+
"webpack-cli": "6.0.1",
|
|
85
85
|
"webpack-dev-server": "5.2.2",
|
|
86
86
|
"yargs": "17.7.2"
|
|
87
87
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as crypto from "crypto";
|
|
2
|
+
import * as fs from "fs/promises";
|
|
2
3
|
import { pki } from "node-forge";
|
|
3
4
|
import * as path from "path";
|
|
4
|
-
import * as fs from "fs/promises";
|
|
5
5
|
|
|
6
6
|
const SSL_CERT_DIR = path.resolve(process.cwd(), "..", "..", ".ssl");
|
|
7
7
|
const CERT_FILE = path.resolve(SSL_CERT_DIR, "certificate.pem");
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
/* eslint-disable no-console */
|
|
2
|
-
import
|
|
3
|
-
import * as chalk from "chalk";
|
|
4
|
-
import { buildConfig } from "../../webpack.config";
|
|
2
|
+
import { generatePreviewUrl } from "@canva/cli";
|
|
5
3
|
import * as ngrok from "@ngrok/ngrok";
|
|
6
|
-
import * as
|
|
4
|
+
import * as chalk from "chalk";
|
|
7
5
|
import * as Table from "cli-table3";
|
|
6
|
+
import * as nodemon from "nodemon";
|
|
7
|
+
import * as open from "open";
|
|
8
8
|
import * as webpack from "webpack";
|
|
9
9
|
import * as WebpackDevServer from "webpack-dev-server";
|
|
10
|
-
import
|
|
11
|
-
import { generatePreviewUrl } from "@canva/cli";
|
|
10
|
+
import { buildConfig } from "../../webpack.config";
|
|
12
11
|
import type { Certificate } from "../ssl/ssl";
|
|
13
12
|
import { createOrRetrieveCertificate } from "../ssl/ssl";
|
|
13
|
+
import type { Context } from "./context";
|
|
14
14
|
|
|
15
15
|
export const infoChalk = chalk.blue.bold;
|
|
16
16
|
export const warnChalk = chalk.bgYellow.bold;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Button, Rows, Text } from "@canva/app-ui-kit";
|
|
2
2
|
import { requestOpenExternalUrl } from "@canva/platform";
|
|
3
3
|
import { FormattedMessage, useIntl } from "react-intl";
|
|
4
|
-
import * as styles from "styles/components.css";
|
|
5
4
|
import { useAddElement } from "utils/use_add_element";
|
|
5
|
+
import * as styles from "styles/components.css";
|
|
6
6
|
|
|
7
7
|
export const DOCS_URL = "https://www.canva.dev/docs/apps/";
|
|
8
8
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { AppI18nProvider } from "@canva/app-i18n-kit";
|
|
1
2
|
import { AppUiProvider } from "@canva/app-ui-kit";
|
|
2
3
|
import { createRoot } from "react-dom/client";
|
|
3
4
|
import { App } from "./app";
|
|
4
5
|
import "@canva/app-ui-kit/styles.css";
|
|
5
|
-
import { AppI18nProvider } from "@canva/app-i18n-kit";
|
|
6
6
|
|
|
7
7
|
const root = createRoot(document.getElementById("root") as Element);
|
|
8
8
|
function render() {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/* eslint-disable formatjs/no-literal-string-in-jsx */
|
|
2
|
-
import React from "react";
|
|
3
|
-
import type { RenderResult } from "@testing-library/react";
|
|
4
|
-
import { fireEvent, render } from "@testing-library/react";
|
|
5
2
|
import { TestAppI18nProvider } from "@canva/app-i18n-kit";
|
|
6
3
|
import { TestAppUiProvider } from "@canva/app-ui-kit";
|
|
7
4
|
import { requestOpenExternalUrl } from "@canva/platform";
|
|
5
|
+
import { fireEvent, render } from "@testing-library/react";
|
|
6
|
+
import type { RenderResult } from "@testing-library/react";
|
|
7
|
+
import React from "react";
|
|
8
8
|
import { useAddElement } from "utils/use_add_element";
|
|
9
9
|
import { App, DOCS_URL } from "../app";
|
|
10
10
|
|
|
@@ -7,9 +7,9 @@ import type {
|
|
|
7
7
|
VideoElement,
|
|
8
8
|
} from "@canva/design";
|
|
9
9
|
import { addElementAtCursor, addElementAtPoint } from "@canva/design";
|
|
10
|
-
import { useFeatureSupport } from "./use_feature_support";
|
|
11
10
|
import { features } from "@canva/platform";
|
|
12
11
|
import { useEffect, useState } from "react";
|
|
12
|
+
import { useFeatureSupport } from "./use_feature_support";
|
|
13
13
|
|
|
14
14
|
type AddElementParams =
|
|
15
15
|
| ImageElement
|
|
@@ -24,7 +24,7 @@ export function buildConfig({
|
|
|
24
24
|
appEntry = path.join(process.cwd(), "src", "index.tsx"),
|
|
25
25
|
backendHost = process.env.CANVA_BACKEND_HOST,
|
|
26
26
|
// For IN_HARNESS, refer to the following docs for more information: https://www.canva.dev/docs/apps/test-harness/
|
|
27
|
-
inHarness = process.env.IN_HARNESS === "true",
|
|
27
|
+
inHarness = process.env.IN_HARNESS?.toLowerCase() === "true",
|
|
28
28
|
}: {
|
|
29
29
|
devConfig?: DevConfig;
|
|
30
30
|
appEntry?: string;
|
|
@@ -182,7 +182,7 @@ export function buildConfig({
|
|
|
182
182
|
new DefinePlugin({
|
|
183
183
|
BACKEND_HOST: JSON.stringify(backendHost),
|
|
184
184
|
}),
|
|
185
|
-
// Apps can only submit a single JS file via the
|
|
185
|
+
// Apps can only submit a single JS file via the Developer Portal
|
|
186
186
|
new optimize.LimitChunkCountPlugin({ maxChunks: 1 }),
|
|
187
187
|
].filter(Boolean),
|
|
188
188
|
...buildDevConfig(devConfig),
|
|
@@ -236,24 +236,6 @@ function buildDevConfig(options?: DevConfig): {
|
|
|
236
236
|
"Access-Control-Allow-Private-Network": "true",
|
|
237
237
|
},
|
|
238
238
|
};
|
|
239
|
-
} else if (enableHmr && appId) {
|
|
240
|
-
// Deprecated - App ID should not be used to configure HMR in the future and can be safely removed
|
|
241
|
-
// after a few months.
|
|
242
|
-
|
|
243
|
-
console.warn(
|
|
244
|
-
"Enabling Hot Module Replacement (HMR) with an App ID is deprecated, please see the README.md on how to update.",
|
|
245
|
-
);
|
|
246
|
-
|
|
247
|
-
const appDomain = `app-${appId.toLowerCase().trim()}.canva-apps.com`;
|
|
248
|
-
devServer = {
|
|
249
|
-
...devServer,
|
|
250
|
-
allowedHosts: [host, appDomain],
|
|
251
|
-
headers: {
|
|
252
|
-
"Access-Control-Allow-Origin": `https://${appDomain}`,
|
|
253
|
-
"Access-Control-Allow-Credentials": "true",
|
|
254
|
-
"Access-Control-Allow-Private-Network": "true",
|
|
255
|
-
},
|
|
256
|
-
};
|
|
257
239
|
} else {
|
|
258
240
|
if (enableHmr && !appOrigin) {
|
|
259
241
|
console.warn(
|