@adobe/create-ccweb-add-on 1.3.0 → 2.0.0

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.
Files changed (149) hide show
  1. package/dist/app/WxpAddOnFactory.js +1 -1
  2. package/dist/commands/create.d.ts +0 -3
  3. package/dist/commands/create.d.ts.map +1 -1
  4. package/dist/commands/create.js +1 -17
  5. package/dist/constants.d.ts.map +1 -1
  6. package/dist/constants.js +6 -3
  7. package/dist/templates/javascript-with-document-sandbox/template/src/sandbox/tsconfig.json +1 -1
  8. package/dist/templates/react-javascript-with-document-sandbox/template/src/sandbox/tsconfig.json +1 -1
  9. package/dist/templates/react-typescript/template/src/index.html +2 -2
  10. package/dist/templates/react-typescript-with-document-sandbox/template/src/sandbox/tsconfig.json +1 -1
  11. package/dist/templates/swc-javascript/template/.babelrc +6 -0
  12. package/dist/templates/{typescript-with-document-sandbox → swc-javascript}/template/README.md +3 -2
  13. package/dist/templates/swc-javascript/template/src/components/App.js +42 -0
  14. package/dist/templates/{typescript-with-document-sandbox → swc-javascript}/template/src/index.html +2 -2
  15. package/dist/templates/swc-javascript/template/src/index.js +23 -0
  16. package/dist/templates/swc-javascript/template/tsconfig.json +14 -0
  17. package/dist/templates/swc-javascript/template/webpack.config.js +46 -0
  18. package/dist/templates/swc-javascript/template.json +24 -0
  19. package/dist/templates/swc-javascript-with-document-sandbox/template/.babelrc +6 -0
  20. package/dist/templates/swc-javascript-with-document-sandbox/template/README.md +16 -0
  21. package/dist/templates/swc-javascript-with-document-sandbox/template/src/index.html +19 -0
  22. package/dist/templates/swc-javascript-with-document-sandbox/template/src/sandbox/code.js +38 -0
  23. package/{templates/typescript-with-document-sandbox → dist/templates/swc-javascript-with-document-sandbox}/template/src/sandbox/tsconfig.json +1 -1
  24. package/dist/templates/swc-javascript-with-document-sandbox/template/src/ui/components/App.js +54 -0
  25. package/dist/templates/swc-javascript-with-document-sandbox/template/src/ui/index.js +23 -0
  26. package/dist/templates/swc-javascript-with-document-sandbox/template/tsconfig.json +14 -0
  27. package/dist/templates/swc-javascript-with-document-sandbox/template/webpack.config.js +54 -0
  28. package/dist/templates/swc-javascript-with-document-sandbox/template.json +24 -0
  29. package/{templates/typescript-with-document-sandbox → dist/templates/swc-typescript}/template/README.md +2 -1
  30. package/dist/templates/swc-typescript/template/gitignore +3 -0
  31. package/{templates/typescript-with-document-sandbox → dist/templates/swc-typescript}/template/src/index.html +2 -2
  32. package/dist/templates/swc-typescript-with-document-sandbox/template/README.md +16 -0
  33. package/dist/templates/swc-typescript-with-document-sandbox/template/src/index.html +19 -0
  34. package/dist/templates/{typescript-with-document-sandbox → swc-typescript-with-document-sandbox}/template/src/sandbox/tsconfig.json +1 -1
  35. package/dist/tsconfig.tsbuildinfo +1 -1
  36. package/dist/validators/AddOnDirectoryValidator.d.ts.map +1 -1
  37. package/dist/validators/AddOnDirectoryValidator.js +2 -1
  38. package/package.json +78 -79
  39. package/src/app/WxpAddOnFactory.ts +1 -1
  40. package/src/commands/create.ts +2 -23
  41. package/src/constants.ts +6 -3
  42. package/src/test/app/WxpAddOnFactory.spec.ts +1 -1
  43. package/src/test/commands/create.spec.ts +2 -26
  44. package/src/test/validators/AddOnDirectoryValidator.spec.ts +6 -3
  45. package/src/validators/AddOnDirectoryValidator.ts +2 -1
  46. package/templates/javascript-with-document-sandbox/template/src/sandbox/tsconfig.json +1 -1
  47. package/templates/react-javascript-with-document-sandbox/template/src/sandbox/tsconfig.json +1 -1
  48. package/templates/react-typescript/template/src/index.html +2 -2
  49. package/templates/react-typescript-with-document-sandbox/template/src/sandbox/tsconfig.json +1 -1
  50. package/templates/swc-javascript/template/.babelrc +6 -0
  51. package/templates/{typescript → swc-javascript}/template/README.md +3 -3
  52. package/templates/swc-javascript/template/gitignore +3 -0
  53. package/templates/swc-javascript/template/src/components/App.css.js +9 -0
  54. package/templates/swc-javascript/template/src/components/App.js +42 -0
  55. package/{dist/templates/typescript → templates/swc-javascript}/template/src/index.html +5 -2
  56. package/templates/swc-javascript/template/src/index.js +23 -0
  57. package/templates/swc-javascript/template/src/manifest.json +21 -0
  58. package/templates/swc-javascript/template/tsconfig.json +14 -0
  59. package/templates/swc-javascript/template/webpack.config.js +46 -0
  60. package/templates/swc-javascript/template.json +24 -0
  61. package/templates/swc-javascript-with-document-sandbox/template/.babelrc +6 -0
  62. package/templates/swc-javascript-with-document-sandbox/template/README.md +16 -0
  63. package/templates/swc-javascript-with-document-sandbox/template/gitignore +3 -0
  64. package/templates/swc-javascript-with-document-sandbox/template/src/index.html +19 -0
  65. package/templates/swc-javascript-with-document-sandbox/template/src/manifest.json +22 -0
  66. package/templates/swc-javascript-with-document-sandbox/template/src/models/DocumentSandboxApi.ts +4 -0
  67. package/templates/swc-javascript-with-document-sandbox/template/src/sandbox/code.js +38 -0
  68. package/templates/swc-javascript-with-document-sandbox/template/src/sandbox/tsconfig.json +10 -0
  69. package/templates/swc-javascript-with-document-sandbox/template/src/ui/components/App.css.js +9 -0
  70. package/templates/swc-javascript-with-document-sandbox/template/src/ui/components/App.js +54 -0
  71. package/templates/swc-javascript-with-document-sandbox/template/src/ui/index.js +23 -0
  72. package/templates/swc-javascript-with-document-sandbox/template/src/ui/tsconfig.json +7 -0
  73. package/templates/swc-javascript-with-document-sandbox/template/tsconfig.json +14 -0
  74. package/templates/swc-javascript-with-document-sandbox/template/webpack.config.js +54 -0
  75. package/templates/swc-javascript-with-document-sandbox/template.json +24 -0
  76. package/{dist/templates/typescript → templates/swc-typescript}/template/README.md +2 -2
  77. package/templates/swc-typescript/template/gitignore +3 -0
  78. package/templates/swc-typescript/template/src/components/App.css.ts +9 -0
  79. package/templates/{typescript → swc-typescript}/template/src/index.html +5 -2
  80. package/templates/swc-typescript/template/src/manifest.json +21 -0
  81. package/templates/swc-typescript-with-document-sandbox/template/README.md +16 -0
  82. package/templates/swc-typescript-with-document-sandbox/template/src/index.html +19 -0
  83. package/templates/swc-typescript-with-document-sandbox/template/src/manifest.json +22 -0
  84. package/templates/swc-typescript-with-document-sandbox/template/src/models/DocumentSandboxApi.ts +4 -0
  85. package/templates/swc-typescript-with-document-sandbox/template/src/sandbox/tsconfig.json +10 -0
  86. package/templates/swc-typescript-with-document-sandbox/template/src/ui/components/App.css.ts +9 -0
  87. package/templates/swc-typescript-with-document-sandbox/template/src/ui/tsconfig.json +7 -0
  88. package/dist/templates/javascript/template/src/add-on-ui-sdk.d.ts +0 -7
  89. package/dist/templates/javascript-with-document-sandbox/template/src/sandbox/add-on-sandbox-sdk.d.ts +0 -11
  90. package/dist/templates/javascript-with-document-sandbox/template/src/ui/add-on-ui-sdk.d.ts +0 -7
  91. package/dist/templates/react-javascript/template/src/add-on-ui-sdk.d.ts +0 -7
  92. package/dist/templates/react-javascript-with-document-sandbox/template/src/sandbox/add-on-sandbox-sdk.d.ts +0 -11
  93. package/dist/templates/react-javascript-with-document-sandbox/template/src/ui/add-on-ui-sdk.d.ts +0 -7
  94. package/dist/templates/react-typescript/template/src/add-on-ui-sdk.d.ts +0 -7
  95. package/dist/templates/react-typescript-with-document-sandbox/template/src/sandbox/add-on-sandbox-sdk.d.ts +0 -11
  96. package/dist/templates/react-typescript-with-document-sandbox/template/src/ui/add-on-ui-sdk.d.ts +0 -7
  97. package/dist/templates/typescript/template/src/add-on-ui-sdk.d.ts +0 -7
  98. package/dist/templates/typescript-with-document-sandbox/template/src/sandbox/add-on-sandbox-sdk.d.ts +0 -11
  99. package/dist/templates/typescript-with-document-sandbox/template/src/ui/add-on-ui-sdk.d.ts +0 -7
  100. package/templates/javascript/template/src/add-on-ui-sdk.d.ts +0 -7
  101. package/templates/javascript-with-document-sandbox/template/src/sandbox/add-on-sandbox-sdk.d.ts +0 -11
  102. package/templates/javascript-with-document-sandbox/template/src/ui/add-on-ui-sdk.d.ts +0 -7
  103. package/templates/react-javascript/template/src/add-on-ui-sdk.d.ts +0 -7
  104. package/templates/react-javascript-with-document-sandbox/template/src/sandbox/add-on-sandbox-sdk.d.ts +0 -11
  105. package/templates/react-javascript-with-document-sandbox/template/src/ui/add-on-ui-sdk.d.ts +0 -7
  106. package/templates/react-typescript/template/src/add-on-ui-sdk.d.ts +0 -7
  107. package/templates/react-typescript-with-document-sandbox/template/src/sandbox/add-on-sandbox-sdk.d.ts +0 -11
  108. package/templates/react-typescript-with-document-sandbox/template/src/ui/add-on-ui-sdk.d.ts +0 -7
  109. package/templates/typescript/template/src/add-on-ui-sdk.d.ts +0 -7
  110. package/templates/typescript-with-document-sandbox/template/src/sandbox/add-on-sandbox-sdk.d.ts +0 -11
  111. package/templates/typescript-with-document-sandbox/template/src/ui/add-on-ui-sdk.d.ts +0 -7
  112. /package/{templates/typescript → dist/templates/swc-javascript}/template/gitignore +0 -0
  113. /package/dist/templates/{typescript/template/src/components/App.css.ts → swc-javascript/template/src/components/App.css.js} +0 -0
  114. /package/dist/templates/{typescript → swc-javascript}/template/src/manifest.json +0 -0
  115. /package/dist/templates/{typescript → swc-javascript-with-document-sandbox}/template/gitignore +0 -0
  116. /package/dist/templates/{typescript-with-document-sandbox → swc-javascript-with-document-sandbox}/template/src/manifest.json +0 -0
  117. /package/dist/templates/{typescript-with-document-sandbox → swc-javascript-with-document-sandbox}/template/src/models/DocumentSandboxApi.ts +0 -0
  118. /package/dist/templates/{typescript-with-document-sandbox/template/src/ui/components/App.css.ts → swc-javascript-with-document-sandbox/template/src/ui/components/App.css.js} +0 -0
  119. /package/dist/templates/{typescript-with-document-sandbox → swc-javascript-with-document-sandbox}/template/src/ui/tsconfig.json +0 -0
  120. /package/{templates/typescript → dist/templates/swc-typescript}/template/src/components/App.css.ts +0 -0
  121. /package/dist/templates/{typescript → swc-typescript}/template/src/components/App.ts +0 -0
  122. /package/dist/templates/{typescript → swc-typescript}/template/src/index.ts +0 -0
  123. /package/{templates/typescript → dist/templates/swc-typescript}/template/src/manifest.json +0 -0
  124. /package/dist/templates/{typescript → swc-typescript}/template/tsconfig.json +0 -0
  125. /package/dist/templates/{typescript → swc-typescript}/template/webpack.config.js +0 -0
  126. /package/dist/templates/{typescript → swc-typescript}/template.json +0 -0
  127. /package/dist/templates/{typescript-with-document-sandbox → swc-typescript-with-document-sandbox}/template/gitignore +0 -0
  128. /package/{templates/typescript-with-document-sandbox → dist/templates/swc-typescript-with-document-sandbox}/template/src/manifest.json +0 -0
  129. /package/{templates/typescript-with-document-sandbox → dist/templates/swc-typescript-with-document-sandbox}/template/src/models/DocumentSandboxApi.ts +0 -0
  130. /package/dist/templates/{typescript-with-document-sandbox → swc-typescript-with-document-sandbox}/template/src/sandbox/code.ts +0 -0
  131. /package/{templates/typescript-with-document-sandbox → dist/templates/swc-typescript-with-document-sandbox}/template/src/ui/components/App.css.ts +0 -0
  132. /package/dist/templates/{typescript-with-document-sandbox → swc-typescript-with-document-sandbox}/template/src/ui/components/App.ts +0 -0
  133. /package/dist/templates/{typescript-with-document-sandbox → swc-typescript-with-document-sandbox}/template/src/ui/index.ts +0 -0
  134. /package/{templates/typescript-with-document-sandbox → dist/templates/swc-typescript-with-document-sandbox}/template/src/ui/tsconfig.json +0 -0
  135. /package/dist/templates/{typescript-with-document-sandbox → swc-typescript-with-document-sandbox}/template/tsconfig.json +0 -0
  136. /package/dist/templates/{typescript-with-document-sandbox → swc-typescript-with-document-sandbox}/template/webpack.config.js +0 -0
  137. /package/dist/templates/{typescript-with-document-sandbox → swc-typescript-with-document-sandbox}/template.json +0 -0
  138. /package/templates/{typescript → swc-typescript}/template/src/components/App.ts +0 -0
  139. /package/templates/{typescript → swc-typescript}/template/src/index.ts +0 -0
  140. /package/templates/{typescript → swc-typescript}/template/tsconfig.json +0 -0
  141. /package/templates/{typescript → swc-typescript}/template/webpack.config.js +0 -0
  142. /package/templates/{typescript → swc-typescript}/template.json +0 -0
  143. /package/templates/{typescript-with-document-sandbox → swc-typescript-with-document-sandbox}/template/gitignore +0 -0
  144. /package/templates/{typescript-with-document-sandbox → swc-typescript-with-document-sandbox}/template/src/sandbox/code.ts +0 -0
  145. /package/templates/{typescript-with-document-sandbox → swc-typescript-with-document-sandbox}/template/src/ui/components/App.ts +0 -0
  146. /package/templates/{typescript-with-document-sandbox → swc-typescript-with-document-sandbox}/template/src/ui/index.ts +0 -0
  147. /package/templates/{typescript-with-document-sandbox → swc-typescript-with-document-sandbox}/template/tsconfig.json +0 -0
  148. /package/templates/{typescript-with-document-sandbox → swc-typescript-with-document-sandbox}/template/webpack.config.js +0 -0
  149. /package/templates/{typescript-with-document-sandbox → swc-typescript-with-document-sandbox}/template.json +0 -0
@@ -0,0 +1,46 @@
1
+ const path = require("path");
2
+ const HtmlWebpackPlugin = require("html-webpack-plugin");
3
+ const CopyWebpackPlugin = require("copy-webpack-plugin");
4
+
5
+ const isEnvProduction = process.env.NODE_ENV === "production";
6
+
7
+ module.exports = {
8
+ mode: isEnvProduction ? "production" : "development",
9
+ devtool: isEnvProduction ? "source-map" : "eval-source-map",
10
+ entry: "./src/index.js",
11
+ experiments: {
12
+ outputModule: true
13
+ },
14
+ output: {
15
+ path: path.resolve(__dirname, "dist"),
16
+ module: true,
17
+ filename: "index.js"
18
+ },
19
+ externalsType: "module",
20
+ externalsPresets: { web: true },
21
+ plugins: [
22
+ new HtmlWebpackPlugin({
23
+ template: "src/index.html",
24
+ scriptLoading: "module"
25
+ }),
26
+ new CopyWebpackPlugin({
27
+ patterns: [{ from: "src/*.json", to: "[name][ext]" }]
28
+ })
29
+ ],
30
+ module: {
31
+ rules: [
32
+ {
33
+ test: /\.(js)$/,
34
+ exclude: /node_modules/,
35
+ use: ["babel-loader"]
36
+ },
37
+ {
38
+ test: /(\.css)$/,
39
+ use: ["style-loader", "css-loader"]
40
+ }
41
+ ]
42
+ },
43
+ resolve: {
44
+ extensions: [".js", ".css"]
45
+ }
46
+ };
@@ -0,0 +1,24 @@
1
+ {
2
+ "scripts": {
3
+ "clean": "ccweb-add-on-scripts clean",
4
+ "build": "ccweb-add-on-scripts build --use webpack",
5
+ "start": "ccweb-add-on-scripts start --use webpack",
6
+ "package": "ccweb-add-on-scripts package --use webpack"
7
+ },
8
+ "dependencies": {
9
+ "@spectrum-web-components/button": "0.39.4",
10
+ "@spectrum-web-components/theme": "0.39.4",
11
+ "lit": "2.8.0"
12
+ },
13
+ "devDependencies": {
14
+ "@babel/plugin-proposal-decorators": "7.24.1",
15
+ "@babel/plugin-transform-class-properties": "7.24.1",
16
+ "babel-loader": "9.1.3",
17
+ "copy-webpack-plugin": "11.0.0",
18
+ "css-loader": "6.8.1",
19
+ "html-webpack-plugin": "5.5.3",
20
+ "style-loader": "3.3.3",
21
+ "webpack-cli": "5.1.4",
22
+ "webpack": "5.89.0"
23
+ }
24
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "plugins": [
3
+ ["@babel/plugin-proposal-decorators", { "decoratorsBeforeExport": true }],
4
+ ["@babel/plugin-transform-class-properties"]
5
+ ]
6
+ }
@@ -0,0 +1,16 @@
1
+ ## About
2
+
3
+ This project has been created with _@adobe/create-ccweb-add-on_. As an example, this Add-on demonstrates how to get started with Add-on development using Spectrum Web Components and JavaScript with Document Sandbox Runtime.
4
+
5
+ ## Tools
6
+
7
+ - HTML
8
+ - CSS
9
+ - Spectrum Web Components
10
+ - JavaScript
11
+
12
+ ## Setup
13
+
14
+ 1. To install the dependencies, run `npm install`.
15
+ 2. To build the application, run `npm run build`.
16
+ 3. To start the application, run `npm run start`.
@@ -0,0 +1,3 @@
1
+ .DS_Store
2
+ dist/
3
+ node_modules/
@@ -0,0 +1,19 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta
6
+ name="description"
7
+ content="Get started with Add-on development using Spectrum Web Components and JavaScript with Document Sandbox Runtime"
8
+ />
9
+ <meta
10
+ name="keywords"
11
+ content="Adobe, Express, Add-On, Spectrum Web Components, JavaScript, Document Sandbox Runtime"
12
+ />
13
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
14
+ <title>Get Started</title>
15
+ </head>
16
+ <body>
17
+ <add-on-root></add-on-root>
18
+ </body>
19
+ </html>
@@ -0,0 +1,22 @@
1
+ {
2
+ "testId": "",
3
+ "name": "",
4
+ "version": "1.0.0",
5
+ "manifestVersion": 2,
6
+ "requirements": {
7
+ "apps": [
8
+ {
9
+ "name": "Express",
10
+ "apiVersion": 1
11
+ }
12
+ ]
13
+ },
14
+ "entryPoints": [
15
+ {
16
+ "type": "panel",
17
+ "id": "panel1",
18
+ "main": "index.html",
19
+ "documentSandbox": "code.js"
20
+ }
21
+ ]
22
+ }
@@ -0,0 +1,4 @@
1
+ // This interface declares all the APIs that the document sandbox runtime ( i.e. code.ts ) exposes to the UI/iframe runtime
2
+ export interface DocumentSandboxApi {
3
+ createRectangle(): void;
4
+ }
@@ -0,0 +1,38 @@
1
+ import addOnSandboxSdk from "add-on-sdk-document-sandbox";
2
+ import { editor } from "express-document-sdk";
3
+
4
+ // Get the document sandbox runtime.
5
+ const { runtime } = addOnSandboxSdk.instance;
6
+
7
+ function start() {
8
+ // APIs to be exposed to the UI runtime
9
+ // i.e., to the `App.js` file of this add-on.
10
+ const sandboxApi = {
11
+ createRectangle: () => {
12
+ const rectangle = editor.createRectangle();
13
+
14
+ // Define rectangle dimensions.
15
+ rectangle.width = 240;
16
+ rectangle.height = 180;
17
+
18
+ // Define rectangle position.
19
+ rectangle.translation = { x: 10, y: 10 };
20
+
21
+ // Define rectangle color.
22
+ const color = { red: 0.32, green: 0.34, blue: 0.89, alpha: 1 };
23
+
24
+ // Fill the rectangle with the color.
25
+ const rectangleFill = editor.makeColorFill(color);
26
+ rectangle.fill = rectangleFill;
27
+
28
+ // Add the rectangle to the document.
29
+ const insertionParent = editor.context.insertionParent;
30
+ insertionParent.children.append(rectangle);
31
+ }
32
+ };
33
+
34
+ // Expose `sandboxApi` to the UI runtime.
35
+ runtime.exposeApi(sandboxApi);
36
+ }
37
+
38
+ start();
@@ -0,0 +1,10 @@
1
+ {
2
+ "extends": "../../tsconfig.json",
3
+ "compilerOptions": {
4
+ "lib": ["ES2020"],
5
+ "module": "ES2020",
6
+ "target": "ES2020",
7
+ "types": ["@types/adobe__ccweb-add-on-sdk"]
8
+ },
9
+ "include": ["./**/*"]
10
+ }
@@ -0,0 +1,9 @@
1
+ import { css } from "lit";
2
+
3
+ export const style = css`
4
+ .container {
5
+ margin: 24px;
6
+ display: flex;
7
+ flex-direction: column;
8
+ }
9
+ `;
@@ -0,0 +1,54 @@
1
+ // To support: theme="express" scale="medium" color="light"
2
+ // import these spectrum web components modules:
3
+ import "@spectrum-web-components/theme/express/scale-medium.js";
4
+ import "@spectrum-web-components/theme/express/theme-light.js";
5
+ import "@spectrum-web-components/theme/scale-medium.js";
6
+ import "@spectrum-web-components/theme/theme-light.js";
7
+
8
+ // To learn more about using "spectrum web components" visit:
9
+ // https://opensource.adobe.com/spectrum-web-components/
10
+ import "@spectrum-web-components/button/sp-button.js";
11
+ import "@spectrum-web-components/theme/sp-theme.js";
12
+
13
+ import { LitElement, html } from "lit";
14
+ import { customElement, property, state } from "lit/decorators.js";
15
+ import { style } from "./App.css";
16
+
17
+ import { RuntimeType } from "https://new.express.adobe.com/static/add-on-sdk/sdk.js";
18
+
19
+ @customElement("add-on-app")
20
+ export class App extends LitElement {
21
+ @property({ type: Object })
22
+ addOnUISdk;
23
+
24
+ @state()
25
+ _sandboxProxy;
26
+
27
+ static get styles() {
28
+ return style;
29
+ }
30
+
31
+ async firstUpdated() {
32
+ // Get the UI runtime.
33
+ const { runtime } = this.addOnUISdk.instance;
34
+
35
+ // Get the proxy object, which is required
36
+ // to call the APIs defined in the Document Sandbox runtime
37
+ // i.e., in the `code.ts` file of this add-on.
38
+ this._sandboxProxy = await runtime.apiProxy(RuntimeType.documentSandbox);
39
+ }
40
+
41
+ _handleClick() {
42
+ this._sandboxProxy.createRectangle();
43
+ }
44
+
45
+ render() {
46
+ // Please note that the below "<sp-theme>" component does not react to theme changes in Express.
47
+ // You may use "this.addOnUISdk.app.ui.theme" to get the current theme and react accordingly.
48
+ return html` <sp-theme theme="express" color="light" scale="medium">
49
+ <div class="container">
50
+ <sp-button size="m" @click=${this._handleClick}>Create Rectangle</sp-button>
51
+ </div>
52
+ </sp-theme>`;
53
+ }
54
+ }
@@ -0,0 +1,23 @@
1
+ import { LitElement, html } from "lit";
2
+ import { customElement, state } from "lit/decorators.js";
3
+ import { until } from "lit/directives/until.js";
4
+ import "./components/App";
5
+
6
+ import addOnUISdk from "https://new.express.adobe.com/static/add-on-sdk/sdk.js";
7
+
8
+ @customElement("add-on-root")
9
+ export class Root extends LitElement {
10
+ @state()
11
+ _isAddOnUISdkReady = addOnUISdk.ready;
12
+
13
+ render() {
14
+ return html`
15
+ ${until(
16
+ this._isAddOnUISdkReady.then(async () => {
17
+ console.log("addOnUISdk is ready for use.");
18
+ return html`<add-on-app .addOnUISdk=${addOnUISdk}></add-on-app>`;
19
+ })
20
+ )}
21
+ `;
22
+ }
23
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "extends": "../../tsconfig.json",
3
+ "compilerOptions": {
4
+ "lib": ["dom"]
5
+ },
6
+ "include": ["./**/*"]
7
+ }
@@ -0,0 +1,14 @@
1
+ {
2
+ "compilerOptions": {
3
+ "allowJs": true,
4
+ "allowSyntheticDefaultImports": true,
5
+ "experimentalDecorators": true,
6
+ "module": "ESNext",
7
+ "moduleResolution": "node",
8
+ "outDir": "dist",
9
+ "target": "ESNext",
10
+ "useDefineForClassFields": false
11
+ },
12
+ "exclude": ["node_modules"],
13
+ "include": ["src/**/*"]
14
+ }
@@ -0,0 +1,54 @@
1
+ const path = require("path");
2
+ const HtmlWebpackPlugin = require("html-webpack-plugin");
3
+ const CopyWebpackPlugin = require("copy-webpack-plugin");
4
+
5
+ const isEnvProduction = process.env.NODE_ENV === "production";
6
+
7
+ module.exports = {
8
+ mode: isEnvProduction ? "production" : "development",
9
+ devtool: "source-map",
10
+ entry: {
11
+ index: "./src/ui/index.js",
12
+ code: "./src/sandbox/code.js"
13
+ },
14
+ experiments: {
15
+ outputModule: true
16
+ },
17
+ output: {
18
+ path: path.resolve(__dirname, "dist"),
19
+ module: true,
20
+ filename: "[name].js"
21
+ },
22
+ externalsType: "module",
23
+ externalsPresets: { web: true },
24
+ externals: {
25
+ "add-on-sdk-document-sandbox": "add-on-sdk-document-sandbox",
26
+ "express-document-sdk": "express-document-sdk"
27
+ },
28
+ plugins: [
29
+ new HtmlWebpackPlugin({
30
+ template: "src/index.html",
31
+ scriptLoading: "module",
32
+ excludeChunks: ["code"]
33
+ }),
34
+ new CopyWebpackPlugin({
35
+ patterns: [{ from: "src/*.json", to: "[name][ext]" }]
36
+ })
37
+ ],
38
+ module: {
39
+ rules: [
40
+ {
41
+ test: /\.(js)$/,
42
+ use: ["babel-loader"],
43
+ exclude: /node_modules/
44
+ },
45
+ {
46
+ test: /(\.css)$/,
47
+ use: ["style-loader", "css-loader"]
48
+ }
49
+ ]
50
+ },
51
+ resolve: {
52
+ extensions: [".js", ".css"]
53
+ }
54
+ };
@@ -0,0 +1,24 @@
1
+ {
2
+ "scripts": {
3
+ "clean": "ccweb-add-on-scripts clean",
4
+ "build": "ccweb-add-on-scripts build --use webpack",
5
+ "start": "ccweb-add-on-scripts start --use webpack",
6
+ "package": "ccweb-add-on-scripts package --use webpack"
7
+ },
8
+ "dependencies": {
9
+ "@spectrum-web-components/button": "0.39.4",
10
+ "@spectrum-web-components/theme": "0.39.4",
11
+ "lit": "2.8.0"
12
+ },
13
+ "devDependencies": {
14
+ "@babel/plugin-proposal-decorators": "7.24.1",
15
+ "@babel/plugin-transform-class-properties": "7.24.1",
16
+ "babel-loader": "9.1.3",
17
+ "copy-webpack-plugin": "11.0.0",
18
+ "css-loader": "6.8.1",
19
+ "html-webpack-plugin": "5.5.3",
20
+ "style-loader": "3.3.3",
21
+ "webpack-cli": "5.1.4",
22
+ "webpack": "5.89.0"
23
+ }
24
+ }
@@ -1,12 +1,12 @@
1
1
  ## About
2
2
 
3
- This project has been created with _@adobe/create-ccweb-add-on_. As an example, this Add-on demonstrates how to get started with Add-on development using React and TypeScript.
3
+ This project has been created with _@adobe/create-ccweb-add-on_. As an example, this Add-on demonstrates how to get started with Add-on development using Spectrum Web Components and TypeScript.
4
4
 
5
5
  ## Tools
6
6
 
7
7
  - HTML
8
8
  - CSS
9
- - React
9
+ - Spectrum Web Components
10
10
  - TypeScript
11
11
 
12
12
  ## Setup
@@ -0,0 +1,3 @@
1
+ .DS_Store
2
+ dist/
3
+ node_modules/
@@ -0,0 +1,9 @@
1
+ import { css } from "lit";
2
+
3
+ export const style = css`
4
+ .container {
5
+ margin: 24px;
6
+ display: flex;
7
+ flex-direction: column;
8
+ }
9
+ `;
@@ -2,8 +2,11 @@
2
2
  <html lang="en">
3
3
  <head>
4
4
  <meta charset="UTF-8" />
5
- <meta name="description" content="Get started with Add-on development using TypeScript" />
6
- <meta name="keywords" content="Adobe, Express, Add-On, TypeScript" />
5
+ <meta
6
+ name="description"
7
+ content="Get started with Add-on development using Spectrum Web Components and TypeScript"
8
+ />
9
+ <meta name="keywords" content="Adobe, Express, Add-On, Spectrum Web Components, TypeScript" />
7
10
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
8
11
  <title>Get Started</title>
9
12
  </head>
@@ -0,0 +1,21 @@
1
+ {
2
+ "testId": "",
3
+ "name": "",
4
+ "version": "1.0.0",
5
+ "manifestVersion": 2,
6
+ "requirements": {
7
+ "apps": [
8
+ {
9
+ "name": "Express",
10
+ "apiVersion": 1
11
+ }
12
+ ]
13
+ },
14
+ "entryPoints": [
15
+ {
16
+ "type": "panel",
17
+ "id": "panel1",
18
+ "main": "index.html"
19
+ }
20
+ ]
21
+ }
@@ -0,0 +1,16 @@
1
+ ## About
2
+
3
+ This project has been created with _@adobe/create-ccweb-add-on_. As an example, this Add-on demonstrates how to get started with Add-on development using Spectrum Web Components and TypeScript with Document Sandbox Runtime.
4
+
5
+ ## Tools
6
+
7
+ - HTML
8
+ - CSS
9
+ - Spectrum Web Components
10
+ - TypeScript
11
+
12
+ ## Setup
13
+
14
+ 1. To install the dependencies, run `npm install`.
15
+ 2. To build the application, run `npm run build`.
16
+ 3. To start the application, run `npm run start`.
@@ -0,0 +1,19 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta
6
+ name="description"
7
+ content="Get started with Add-on development using Spectrum Web Components and TypeScript with Document Sandbox Runtime"
8
+ />
9
+ <meta
10
+ name="keywords"
11
+ content="Adobe, Express, Add-On, Spectrum Web Components, TypeScript, Document Sandbox Runtime"
12
+ />
13
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
14
+ <title>Get Started</title>
15
+ </head>
16
+ <body>
17
+ <add-on-root></add-on-root>
18
+ </body>
19
+ </html>
@@ -0,0 +1,22 @@
1
+ {
2
+ "testId": "",
3
+ "name": "",
4
+ "version": "1.0.0",
5
+ "manifestVersion": 2,
6
+ "requirements": {
7
+ "apps": [
8
+ {
9
+ "name": "Express",
10
+ "apiVersion": 1
11
+ }
12
+ ]
13
+ },
14
+ "entryPoints": [
15
+ {
16
+ "type": "panel",
17
+ "id": "panel1",
18
+ "main": "index.html",
19
+ "documentSandbox": "code.js"
20
+ }
21
+ ]
22
+ }
@@ -0,0 +1,4 @@
1
+ // This interface declares all the APIs that the document sandbox runtime ( i.e. code.ts ) exposes to the UI/iframe runtime
2
+ export interface DocumentSandboxApi {
3
+ createRectangle(): void;
4
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "extends": "../../tsconfig.json",
3
+ "compilerOptions": {
4
+ "lib": ["ES2020"],
5
+ "module": "ES2020",
6
+ "target": "ES2020",
7
+ "types": ["@types/adobe__ccweb-add-on-sdk"]
8
+ },
9
+ "include": ["./**/*"]
10
+ }
@@ -0,0 +1,9 @@
1
+ import { css } from "lit";
2
+
3
+ export const style = css`
4
+ .container {
5
+ margin: 24px;
6
+ display: flex;
7
+ flex-direction: column;
8
+ }
9
+ `;
@@ -0,0 +1,7 @@
1
+ {
2
+ "extends": "../../tsconfig.json",
3
+ "compilerOptions": {
4
+ "lib": ["dom"]
5
+ },
6
+ "include": ["./**/*"]
7
+ }
@@ -1,7 +0,0 @@
1
- // DO NOT modify this file.
2
-
3
- declare module "https://new.express.adobe.com/static/add-on-sdk/sdk.js" {
4
- import { AddOnUISdkTypes } from "@adobe/ccweb-add-on-sdk-types";
5
- export default AddOnUISdkTypes.default;
6
- export * from "@adobe/ccweb-add-on-sdk-types/ui/ui-sdk";
7
- }
@@ -1,11 +0,0 @@
1
- // DO NOT modify this file.
2
-
3
- declare module "add-on-sdk-document-sandbox" {
4
- import { AddOnDocumentSandboxSdkTypes } from "@adobe/ccweb-add-on-sdk-types";
5
- export default AddOnDocumentSandboxSdkTypes.default;
6
- export * from "@adobe/ccweb-add-on-sdk-types/sandbox/add-on-sdk-document-sandbox";
7
- }
8
-
9
- declare module "express-document-sdk" {
10
- export * from "@adobe/ccweb-add-on-sdk-types/sandbox/express-document-sdk";
11
- }
@@ -1,7 +0,0 @@
1
- // DO NOT modify this file.
2
-
3
- declare module "https://new.express.adobe.com/static/add-on-sdk/sdk.js" {
4
- import { AddOnUISdkTypes } from "@adobe/ccweb-add-on-sdk-types";
5
- export default AddOnUISdkTypes.default;
6
- export * from "@adobe/ccweb-add-on-sdk-types/ui/ui-sdk";
7
- }
@@ -1,7 +0,0 @@
1
- // DO NOT modify this file.
2
-
3
- declare module "https://new.express.adobe.com/static/add-on-sdk/sdk.js" {
4
- import { AddOnUISdkTypes } from "@adobe/ccweb-add-on-sdk-types";
5
- export default AddOnUISdkTypes.default;
6
- export * from "@adobe/ccweb-add-on-sdk-types/ui/ui-sdk";
7
- }
@@ -1,11 +0,0 @@
1
- // DO NOT modify this file.
2
-
3
- declare module "add-on-sdk-document-sandbox" {
4
- import { AddOnDocumentSandboxSdkTypes } from "@adobe/ccweb-add-on-sdk-types";
5
- export default AddOnDocumentSandboxSdkTypes.default;
6
- export * from "@adobe/ccweb-add-on-sdk-types/sandbox/add-on-sdk-document-sandbox";
7
- }
8
-
9
- declare module "express-document-sdk" {
10
- export * from "@adobe/ccweb-add-on-sdk-types/sandbox/express-document-sdk";
11
- }
@@ -1,7 +0,0 @@
1
- // DO NOT modify this file.
2
-
3
- declare module "https://new.express.adobe.com/static/add-on-sdk/sdk.js" {
4
- import { AddOnUISdkTypes } from "@adobe/ccweb-add-on-sdk-types";
5
- export default AddOnUISdkTypes.default;
6
- export * from "@adobe/ccweb-add-on-sdk-types/ui/ui-sdk";
7
- }
@@ -1,7 +0,0 @@
1
- // DO NOT modify this file.
2
-
3
- declare module "https://new.express.adobe.com/static/add-on-sdk/sdk.js" {
4
- import { AddOnUISdkTypes } from "@adobe/ccweb-add-on-sdk-types";
5
- export default AddOnUISdkTypes.default;
6
- export * from "@adobe/ccweb-add-on-sdk-types/ui/ui-sdk";
7
- }
@@ -1,11 +0,0 @@
1
- // DO NOT modify this file.
2
-
3
- declare module "add-on-sdk-document-sandbox" {
4
- import { AddOnDocumentSandboxSdkTypes } from "@adobe/ccweb-add-on-sdk-types";
5
- export default AddOnDocumentSandboxSdkTypes.default;
6
- export * from "@adobe/ccweb-add-on-sdk-types/sandbox/add-on-sdk-document-sandbox";
7
- }
8
-
9
- declare module "express-document-sdk" {
10
- export * from "@adobe/ccweb-add-on-sdk-types/sandbox/express-document-sdk";
11
- }