@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,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,5 +1,5 @@
|
|
|
1
1
|
import type { DataTable } from "@canva/intents/data";
|
|
2
|
-
import {
|
|
2
|
+
import { type DataTableColumn, toDataTable } from "src/utils";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* This file defines types and classes related to data source configuration, fetching and outputting as a data table.
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
/* eslint-disable formatjs/no-literal-string-in-object */
|
|
2
|
-
import type { APIResponseItem, DataSourceConfig } from "../data_source";
|
|
3
|
-
import { DataAPIError, DataSourceHandler } from "../data_source";
|
|
4
|
-
import type { CanvaItemResponse } from "../connect_client";
|
|
5
2
|
|
|
6
3
|
import type { SelectOption } from "@canva/app-ui-kit";
|
|
7
4
|
import { Button, DatabaseIcon, HorizontalCard, Rows } from "@canva/app-ui-kit";
|
|
8
|
-
import {
|
|
5
|
+
import { useEffect, useState } from "react";
|
|
6
|
+
import { useIntl } from "react-intl";
|
|
7
|
+
import { useNavigate } from "react-router-dom";
|
|
9
8
|
import { Header } from "src/components";
|
|
10
9
|
import {
|
|
11
10
|
ownershipFilter,
|
|
12
11
|
sortOrderField,
|
|
13
12
|
} from "src/components/inputs/messages";
|
|
14
|
-
import {
|
|
13
|
+
import { SearchFilter } from "src/components/inputs/search_filter";
|
|
15
14
|
import { SelectField } from "src/components/inputs/select_field";
|
|
16
|
-
import {
|
|
15
|
+
import { useAppContext } from "src/context";
|
|
17
16
|
import { Paths } from "src/routes";
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
17
|
+
import { dateCell, numberCell, stringCell } from "src/utils";
|
|
18
|
+
import type { CanvaItemResponse } from "../connect_client";
|
|
19
|
+
import { DataAPIError, DataSourceHandler } from "../data_source";
|
|
20
|
+
import type { APIResponseItem, DataSourceConfig } from "../data_source";
|
|
21
21
|
|
|
22
22
|
export interface DesignsDataSource extends DataSourceConfig {
|
|
23
23
|
query: string;
|
|
@@ -1,9 +1,4 @@
|
|
|
1
1
|
/* eslint-disable formatjs/no-literal-string-in-object */
|
|
2
|
-
import { useAppContext } from "src/context";
|
|
3
|
-
import type { APIResponseItem, DataSourceConfig } from "../data_source";
|
|
4
|
-
import { DataAPIError, DataSourceHandler } from "../data_source";
|
|
5
|
-
import type { CanvaItemResponse } from "../connect_client";
|
|
6
|
-
import { dateCell, stringCell } from "src/utils";
|
|
7
2
|
import type { SelectOption } from "@canva/app-ui-kit";
|
|
8
3
|
import {
|
|
9
4
|
Button,
|
|
@@ -11,18 +6,23 @@ import {
|
|
|
11
6
|
Rows,
|
|
12
7
|
TableMergedHeaderCellsIcon,
|
|
13
8
|
} from "@canva/app-ui-kit";
|
|
9
|
+
import { useEffect, useState } from "react";
|
|
14
10
|
import { useIntl } from "react-intl";
|
|
11
|
+
import { useNavigate } from "react-router-dom";
|
|
12
|
+
import { Header } from "src/components";
|
|
15
13
|
import {
|
|
16
14
|
datasetFilter,
|
|
17
15
|
ownershipFilter,
|
|
18
16
|
sortOrderField,
|
|
19
17
|
} from "src/components/inputs/messages";
|
|
18
|
+
import { SearchFilter } from "src/components/inputs/search_filter";
|
|
20
19
|
import { SelectField } from "src/components/inputs/select_field";
|
|
21
|
-
import {
|
|
22
|
-
import { useNavigate } from "react-router-dom";
|
|
20
|
+
import { useAppContext } from "src/context";
|
|
23
21
|
import { Paths } from "src/routes";
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
22
|
+
import { dateCell, stringCell } from "src/utils";
|
|
23
|
+
import type { CanvaItemResponse } from "../connect_client";
|
|
24
|
+
import { DataAPIError, DataSourceHandler } from "../data_source";
|
|
25
|
+
import type { APIResponseItem, DataSourceConfig } from "../data_source";
|
|
26
26
|
|
|
27
27
|
export interface BrandTemplatesDataSource extends DataSourceConfig {
|
|
28
28
|
query: string;
|
|
@@ -2,13 +2,13 @@ import type {
|
|
|
2
2
|
GetDataTableRequest,
|
|
3
3
|
GetDataTableResponse,
|
|
4
4
|
} from "@canva/intents/data";
|
|
5
|
-
import { DATA_SOURCES } from "./data_sources";
|
|
6
5
|
import {
|
|
7
6
|
appError,
|
|
8
7
|
completeDataTable,
|
|
9
8
|
outdatedSourceRef,
|
|
10
9
|
remoteRequestFailed,
|
|
11
10
|
} from "src/utils/fetch_result";
|
|
11
|
+
import { DATA_SOURCES } from "./data_sources";
|
|
12
12
|
import { DataAPIError } from ".";
|
|
13
13
|
|
|
14
14
|
/**
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/* eslint-disable formatjs/no-literal-string-in-object */
|
|
2
2
|
/* eslint-disable formatjs/no-literal-string-in-jsx */
|
|
3
|
-
import type { DataSourceConfig, APIResponseItem } from "../data_source";
|
|
4
|
-
import { DataSourceHandler, DataAPIError } from "../data_source";
|
|
5
3
|
import { toDataTable } from "src/utils";
|
|
4
|
+
import type { APIResponseItem, DataSourceConfig } from "../data_source";
|
|
5
|
+
import { DataAPIError, DataSourceHandler } from "../data_source";
|
|
6
6
|
|
|
7
7
|
// Mock dependencies
|
|
8
8
|
jest.mock("src/utils", () => ({
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { createHashRouter, RouterProvider } from "react-router-dom";
|
|
2
|
-
import { ContextProvider } from "./context";
|
|
3
|
-
import { routes } from "./routes";
|
|
4
|
-
import { AppUiProvider } from "@canva/app-ui-kit";
|
|
5
1
|
import { AppI18nProvider } from "@canva/app-i18n-kit";
|
|
2
|
+
import { AppUiProvider } from "@canva/app-ui-kit";
|
|
3
|
+
import type { RenderSelectionUiRequest } from "@canva/intents/data";
|
|
6
4
|
import { ErrorBoundary } from "react-error-boundary";
|
|
5
|
+
import { createHashRouter, RouterProvider } from "react-router-dom";
|
|
6
|
+
import { ContextProvider } from "./context";
|
|
7
7
|
import { ErrorPage } from "./pages";
|
|
8
|
-
import
|
|
8
|
+
import { routes } from "./routes";
|
|
9
9
|
|
|
10
10
|
export const App = ({ request }: { request: RenderSelectionUiRequest }) => (
|
|
11
11
|
<AppI18nProvider>
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { useNavigate } from "react-router-dom";
|
|
2
1
|
import {
|
|
3
2
|
ArrowLeftIcon,
|
|
4
3
|
Box,
|
|
@@ -7,6 +6,7 @@ import {
|
|
|
7
6
|
Columns,
|
|
8
7
|
Title,
|
|
9
8
|
} from "@canva/app-ui-kit";
|
|
9
|
+
import { useNavigate } from "react-router-dom";
|
|
10
10
|
import { Paths } from "src/routes";
|
|
11
11
|
|
|
12
12
|
export const Header = ({
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { createContext, useState, useCallback } from "react";
|
|
2
1
|
import type { RenderSelectionUiRequest } from "@canva/intents/data";
|
|
3
2
|
import type { AccessTokenResponse } from "@canva/user";
|
|
4
3
|
import { auth } from "@canva/user";
|
|
4
|
+
import { createContext, useCallback, useState } from "react";
|
|
5
5
|
import type { APIResponseItem, DataSourceHandler } from "src/api/data_source";
|
|
6
6
|
import { type DataSourceConfig } from "src/api/data_source";
|
|
7
7
|
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { LoadingIndicator } from "@canva/app-ui-kit";
|
|
2
2
|
import { useEffect } from "react";
|
|
3
3
|
import { useNavigate } from "react-router-dom";
|
|
4
|
+
import type {
|
|
5
|
+
APIResponseItem,
|
|
6
|
+
DataSourceConfig,
|
|
7
|
+
DataSourceHandler,
|
|
8
|
+
} from "./api";
|
|
9
|
+
import { DATA_SOURCES } from "./api/data_sources";
|
|
4
10
|
import { useAppContext } from "./context";
|
|
11
|
+
import { Paths } from "./routes";
|
|
5
12
|
import {
|
|
6
13
|
isDataRefEmpty,
|
|
7
14
|
isLaunchedWithError,
|
|
8
15
|
isOutdatedSource,
|
|
9
16
|
} from "./utils/data_params";
|
|
10
|
-
import { Paths } from "./routes";
|
|
11
|
-
import { DATA_SOURCES } from "./api/data_sources";
|
|
12
|
-
import type {
|
|
13
|
-
APIResponseItem,
|
|
14
|
-
DataSourceConfig,
|
|
15
|
-
DataSourceHandler,
|
|
16
|
-
} from "./api";
|
|
17
17
|
|
|
18
18
|
const parseDataSource = (source: string) => {
|
|
19
19
|
try {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Outlet } from "react-router-dom";
|
|
2
1
|
import { Box, 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 { AppError } from "./components";
|
|
5
5
|
|
|
6
6
|
export const Home = () => (
|
|
7
7
|
<div className={styles.scrollContainer}>
|
|
@@ -1,16 +1,15 @@
|
|
|
1
|
+
import { Alert, AppUiProvider } from "@canva/app-ui-kit";
|
|
1
2
|
import type {
|
|
2
|
-
RenderSelectionUiRequest,
|
|
3
3
|
GetDataTableRequest,
|
|
4
4
|
GetDataTableResponse,
|
|
5
|
+
RenderSelectionUiRequest,
|
|
5
6
|
} from "@canva/intents/data";
|
|
6
7
|
import { prepareDataConnector } from "@canva/intents/data";
|
|
7
|
-
import { createRoot } from "react-dom/client";
|
|
8
|
-
import { App } from "./app";
|
|
9
8
|
import { auth } from "@canva/user";
|
|
9
|
+
import { createRoot } from "react-dom/client";
|
|
10
10
|
import { buildDataTableResult, scope } from "./api";
|
|
11
|
-
|
|
11
|
+
import { App } from "./app";
|
|
12
12
|
import "@canva/app-ui-kit/styles.css";
|
|
13
|
-
import { Alert, AppUiProvider } from "@canva/app-ui-kit";
|
|
14
13
|
|
|
15
14
|
const root = createRoot(document.getElementById("root") as Element);
|
|
16
15
|
prepareDataConnector({
|
|
@@ -63,7 +62,7 @@ root.render(
|
|
|
63
62
|
{/* eslint-disable-next-line formatjs/no-literal-string-in-jsx */}
|
|
64
63
|
<Alert tone="critical">
|
|
65
64
|
If you're seeing this, you need to turn on the data connector intent in
|
|
66
|
-
the
|
|
65
|
+
the Developer Portal for this app.
|
|
67
66
|
</Alert>
|
|
68
67
|
</AppUiProvider>,
|
|
69
68
|
);
|
|
@@ -1,8 +1,8 @@
|
|
|
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 { Paths } from "src/routes";
|
|
4
5
|
import * as styles from "styles/components.css";
|
|
5
|
-
import { FormattedMessage, useIntl } from "react-intl";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Bare bones Error Page, please add relevant information and behavior that your app requires.
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import {
|
|
2
|
+
Box,
|
|
2
3
|
Button,
|
|
3
4
|
LoadingIndicator,
|
|
4
5
|
Rows,
|
|
5
|
-
Title,
|
|
6
6
|
Text,
|
|
7
|
-
|
|
7
|
+
Title,
|
|
8
8
|
} from "@canva/app-ui-kit";
|
|
9
|
-
import {
|
|
9
|
+
import { useCallback, useEffect, useState } from "react";
|
|
10
|
+
import { defineMessages, FormattedMessage, useIntl } from "react-intl";
|
|
11
|
+
import { useNavigate } from "react-router-dom";
|
|
12
|
+
import { scope } from "src/api";
|
|
13
|
+
import { Header } from "src/components";
|
|
10
14
|
import * as styles from "styles/components.css";
|
|
11
15
|
import { useAppContext } from "../context";
|
|
12
|
-
import { useNavigate } from "react-router-dom";
|
|
13
16
|
import { Paths } from "../routes";
|
|
14
|
-
import { Header } from "src/components";
|
|
15
|
-
import { useIntl, FormattedMessage, defineMessages } from "react-intl";
|
|
16
|
-
import { scope } from "src/api";
|
|
17
17
|
|
|
18
18
|
export const Login = () => {
|
|
19
19
|
const intl = useIntl();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Entrypoint } from "src/entrypoint";
|
|
2
2
|
import { Home } from "src/home";
|
|
3
|
-
import { ErrorPage, Login,
|
|
3
|
+
import { DataSourceConfig, ErrorPage, Login, SelectSource } from "src/pages";
|
|
4
4
|
import { ProtectedRoute } from "./protected_route";
|
|
5
5
|
|
|
6
6
|
export enum Paths {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/* eslint-disable formatjs/no-literal-string-in-object */
|
|
2
|
+
import type { APIResponseItem } from "src/api";
|
|
2
3
|
import {
|
|
3
|
-
toDataTable,
|
|
4
|
-
stringCell,
|
|
5
|
-
numberCell,
|
|
6
|
-
dateCell,
|
|
7
4
|
booleanCell,
|
|
5
|
+
dateCell,
|
|
6
|
+
numberCell,
|
|
7
|
+
stringCell,
|
|
8
|
+
toDataTable,
|
|
8
9
|
} from "../data_table";
|
|
9
10
|
import type { DataTableColumn } from "../data_table";
|
|
10
|
-
import type { APIResponseItem } from "src/api";
|
|
11
11
|
|
|
12
12
|
describe("data table utils", () => {
|
|
13
13
|
interface TestItem extends APIResponseItem {
|
|
@@ -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,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"manifest_schema_version": 1,
|
|
3
|
+
"runtime": {
|
|
4
|
+
"permissions": [
|
|
5
|
+
{
|
|
6
|
+
"name": "canva:asset:private:write",
|
|
7
|
+
"type": "mandatory"
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"name": "canva:design:content:read",
|
|
11
|
+
"type": "mandatory"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"name": "canva:design:content:write",
|
|
15
|
+
"type": "mandatory"
|
|
16
|
+
}
|
|
17
|
+
],
|
|
18
|
+
"supported_devices": ["desktop", "mobile"]
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -18,38 +18,38 @@
|
|
|
18
18
|
"postinstall": "ts-node ./scripts/copy_env.ts"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@canva/app-i18n-kit": "^1.0.
|
|
21
|
+
"@canva/app-i18n-kit": "^1.0.3",
|
|
22
22
|
"@canva/app-ui-kit": "^4.10.0",
|
|
23
|
-
"@canva/asset": "^2.2.
|
|
24
|
-
"@canva/design": "^2.
|
|
23
|
+
"@canva/asset": "^2.2.1",
|
|
24
|
+
"@canva/design": "^2.7.0",
|
|
25
25
|
"@canva/error": "^2.1.0",
|
|
26
26
|
"@canva/platform": "^2.2.0",
|
|
27
|
-
"@canva/user": "^2.1.
|
|
27
|
+
"@canva/user": "^2.1.1",
|
|
28
28
|
"cookie-parser": "1.4.7",
|
|
29
29
|
"cors": "2.8.5",
|
|
30
|
-
"html-react-parser": "5.2.
|
|
31
|
-
"obscenity": "0.4.
|
|
30
|
+
"html-react-parser": "5.2.5",
|
|
31
|
+
"obscenity": "0.4.4",
|
|
32
32
|
"react": "18.3.1",
|
|
33
33
|
"react-dom": "18.3.1",
|
|
34
|
-
"react-error-boundary": "
|
|
34
|
+
"react-error-boundary": "6.0.0",
|
|
35
35
|
"react-intl": "6.8.7",
|
|
36
|
-
"react-router-dom": "6.
|
|
36
|
+
"react-router-dom": "7.6.3"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@canva/app-eslint-plugin": "^1.0.0-beta.3",
|
|
40
40
|
"@canva/cli": ">= 0.0.1-beta.13 < 0.0.2",
|
|
41
|
-
"@formatjs/cli": "6.
|
|
42
|
-
"@formatjs/ts-transformer": "3.
|
|
43
|
-
"@ngrok/ngrok": "1.
|
|
44
|
-
"@pmmmwh/react-refresh-webpack-plugin": "0.
|
|
41
|
+
"@formatjs/cli": "6.7.2",
|
|
42
|
+
"@formatjs/ts-transformer": "3.14.0",
|
|
43
|
+
"@ngrok/ngrok": "1.5.1",
|
|
44
|
+
"@pmmmwh/react-refresh-webpack-plugin": "0.6.1",
|
|
45
45
|
"@svgr/webpack": "8.1.0",
|
|
46
|
-
"@testing-library/react": "16.
|
|
46
|
+
"@testing-library/react": "16.3.0",
|
|
47
47
|
"@types/debug": "4.1.12",
|
|
48
48
|
"@types/express": "4.17.21",
|
|
49
|
-
"@types/express-serve-static-core": "
|
|
49
|
+
"@types/express-serve-static-core": "5.0.6",
|
|
50
50
|
"@types/jest": "29.5.14",
|
|
51
|
-
"@types/jsonwebtoken": "9.0.
|
|
52
|
-
"@types/node": "20.
|
|
51
|
+
"@types/jsonwebtoken": "9.0.10",
|
|
52
|
+
"@types/node": "20.19.2",
|
|
53
53
|
"@types/node-fetch": "2.6.12",
|
|
54
54
|
"@types/node-forge": "1.3.11",
|
|
55
55
|
"@types/nodemon": "1.19.6",
|
|
@@ -57,42 +57,42 @@
|
|
|
57
57
|
"@types/react": "18.3.12",
|
|
58
58
|
"@types/react-dom": "18.3.1",
|
|
59
59
|
"@types/webpack": "5.28.5",
|
|
60
|
-
"@types/webpack-dev-server": "4.7.
|
|
61
|
-
"@types/webpack-env": "1.18.
|
|
60
|
+
"@types/webpack-dev-server": "4.7.2",
|
|
61
|
+
"@types/webpack-env": "1.18.8",
|
|
62
62
|
"chalk": "4.1.2",
|
|
63
63
|
"cli-table3": "0.6.5",
|
|
64
64
|
"css-loader": "7.1.2",
|
|
65
65
|
"css-modules-typescript-loader": "4.0.1",
|
|
66
|
-
"cssnano": "7.0.
|
|
67
|
-
"debug": "4.4.
|
|
68
|
-
"dotenv": "16.
|
|
69
|
-
"exponential-backoff": "3.1.
|
|
66
|
+
"cssnano": "7.0.7",
|
|
67
|
+
"debug": "4.4.1",
|
|
68
|
+
"dotenv": "16.6.0",
|
|
69
|
+
"exponential-backoff": "3.1.2",
|
|
70
70
|
"express": "4.21.2",
|
|
71
71
|
"express-basic-auth": "1.2.1",
|
|
72
72
|
"jest": "29.7.0",
|
|
73
73
|
"jest-css-modules-transform": "4.4.2",
|
|
74
74
|
"jest-environment-jsdom": "29.7.0",
|
|
75
75
|
"jsonwebtoken": "9.0.2",
|
|
76
|
-
"jwks-rsa": "3.
|
|
76
|
+
"jwks-rsa": "3.2.0",
|
|
77
77
|
"mini-css-extract-plugin": "2.9.2",
|
|
78
78
|
"node-fetch": "3.3.2",
|
|
79
79
|
"node-forge": "1.3.1",
|
|
80
80
|
"nodemon": "3.0.1",
|
|
81
81
|
"open": "8.4.2",
|
|
82
82
|
"postcss-loader": "8.1.1",
|
|
83
|
-
"prettier": "3.
|
|
83
|
+
"prettier": "3.6.2",
|
|
84
84
|
"prompts": "2.4.2",
|
|
85
|
-
"react-refresh": "0.
|
|
85
|
+
"react-refresh": "0.17.0",
|
|
86
86
|
"style-loader": "4.0.0",
|
|
87
|
-
"terser-webpack-plugin": "5.3.
|
|
87
|
+
"terser-webpack-plugin": "5.3.14",
|
|
88
88
|
"tree-kill": "1.2.2",
|
|
89
|
-
"ts-jest": "29.
|
|
89
|
+
"ts-jest": "29.4.0",
|
|
90
90
|
"ts-loader": "9.5.2",
|
|
91
91
|
"ts-node": "10.9.2",
|
|
92
|
-
"typescript": "5.
|
|
92
|
+
"typescript": "5.8.2",
|
|
93
93
|
"url-loader": "4.1.1",
|
|
94
|
-
"webpack": "5.
|
|
95
|
-
"webpack-cli": "
|
|
94
|
+
"webpack": "5.99.9",
|
|
95
|
+
"webpack-cli": "6.0.1",
|
|
96
96
|
"webpack-dev-server": "5.2.2",
|
|
97
97
|
"yargs": "17.7.2"
|
|
98
98
|
}
|
|
@@ -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,10 +1,10 @@
|
|
|
1
|
-
import { createHashRouter, RouterProvider } from "react-router-dom";
|
|
2
|
-
import { ContextProvider } from "./context";
|
|
3
|
-
import { routes } from "./routes";
|
|
4
1
|
import { AppI18nProvider } from "@canva/app-i18n-kit";
|
|
5
2
|
import { AppUiProvider } from "@canva/app-ui-kit";
|
|
6
3
|
import { ErrorBoundary } from "react-error-boundary";
|
|
4
|
+
import { createHashRouter, RouterProvider } from "react-router-dom";
|
|
5
|
+
import { ContextProvider } from "./context";
|
|
7
6
|
import { ErrorPage } from "./pages";
|
|
7
|
+
import { routes } from "./routes";
|
|
8
8
|
|
|
9
9
|
export const App = () => (
|
|
10
10
|
<AppI18nProvider>
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { Button, Rows } from "@canva/app-ui-kit";
|
|
2
|
+
import { useIntl } from "react-intl";
|
|
3
|
+
import { useLocation, useNavigate } from "react-router-dom";
|
|
4
|
+
import { purchaseCredits, queueImageGeneration } from "src/api";
|
|
4
5
|
import { RemainingCredits } from "src/components";
|
|
5
6
|
import { NUMBER_OF_IMAGES_TO_GENERATE } from "src/config";
|
|
6
7
|
import { useAppContext } from "src/context";
|
|
7
8
|
import { Paths } from "src/routes";
|
|
8
9
|
import { getObsceneWords } from "src/utils";
|
|
9
|
-
import { useIntl } from "react-intl";
|
|
10
10
|
import { FooterMessages as Messages } from "./footer.messages";
|
|
11
11
|
|
|
12
12
|
export const Footer = () => {
|
|
@@ -2,10 +2,10 @@ import { Grid, ImageCard, Rows, Text } from "@canva/app-ui-kit";
|
|
|
2
2
|
import type { QueuedImage } from "@canva/asset";
|
|
3
3
|
import { upload } from "@canva/asset";
|
|
4
4
|
import { addElementAtPoint, ui } from "@canva/design";
|
|
5
|
+
import { FormattedMessage, useIntl } from "react-intl";
|
|
5
6
|
import type { ImageType } from "src/api";
|
|
6
7
|
import { useAppContext } from "src/context";
|
|
7
8
|
import * as styles from "styles/utils.css";
|
|
8
|
-
import { FormattedMessage, useIntl } from "react-intl";
|
|
9
9
|
|
|
10
10
|
const THUMBNAIL_HEIGHT = 150;
|
|
11
11
|
|