lucid-package 0.0.90 → 0.0.91

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 (33) hide show
  1. package/package.json +5 -1
  2. package/src/angularframeworkutils.d.ts +1 -0
  3. package/src/angularframeworkutils.js +28 -0
  4. package/src/editorextension.d.ts +1 -1
  5. package/src/editorextension.js +3 -3
  6. package/src/index.js +47 -2
  7. package/src/installationutil.d.ts +3 -1
  8. package/src/installationutil.js +13 -2
  9. package/src/interactibilityutil.d.ts +4 -0
  10. package/src/interactibilityutil.js +29 -0
  11. package/src/package.d.ts +1 -0
  12. package/src/package.js +6 -2
  13. package/src/reactframeworkutils.d.ts +1 -0
  14. package/src/reactframeworkutils.js +65 -0
  15. package/templates/editorextension/angular/skeleton/package.json +8 -0
  16. package/templates/editorextension/angular/skeleton/src/extension.ts +18 -0
  17. package/templates/editorextension/{tsconfig.json → angular/skeleton/tsconfig.json} +12 -8
  18. package/templates/editorextension/angular/skeleton/webpack.config.js +59 -0
  19. package/templates/editorextension/react/skeleton/package.json +8 -0
  20. package/templates/editorextension/react/skeleton/resources/resource.d.ts +9 -0
  21. package/templates/editorextension/react/skeleton/src/extension.ts +18 -0
  22. package/templates/editorextension/react/skeleton/src/interop.d.ts +61 -0
  23. package/templates/editorextension/react/skeleton/tsconfig.json +38 -0
  24. package/templates/editorextension/react/skeleton/webpack.config.js +57 -0
  25. package/templates/editorextension/vanilla/resources/resource.d.ts +9 -0
  26. package/templates/editorextension/vanilla/src/interop.d.ts +61 -0
  27. package/templates/editorextension/vanilla/tsconfig.json +38 -0
  28. /package/templates/editorextension/{resources → angular/skeleton/resources}/resource.d.ts +0 -0
  29. /package/templates/editorextension/{src → angular/skeleton/src}/interop.d.ts +0 -0
  30. /package/templates/editorextension/{package.json → vanilla/package.json} +0 -0
  31. /package/templates/editorextension/{src → vanilla/src}/extension.ts +0 -0
  32. /package/templates/editorextension/{src → vanilla/src}/importmodal.ts +0 -0
  33. /package/templates/editorextension/{webpack.config.js → vanilla/webpack.config.js} +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lucid-package",
3
- "version": "0.0.90",
3
+ "version": "0.0.91",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -21,6 +21,10 @@
21
21
  "access": "public"
22
22
  },
23
23
  "dependencies": {
24
+ "@inquirer/checkbox": "^1.5.0",
25
+ "@inquirer/confirm": "^2.0.15",
26
+ "@inquirer/input": "^1.2.14",
27
+ "@inquirer/select": "^1.3.1",
24
28
  "argparse": "^2.0.1",
25
29
  "chokidar": "^3.5.3",
26
30
  "express": "^4.17.1",
@@ -0,0 +1 @@
1
+ export declare function createAngularEditorExtension(name: string, isInternalTesting: boolean, skipSDKDependency: boolean): Promise<void>;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createAngularEditorExtension = void 0;
4
+ const fs = require("fs/promises");
5
+ const path = require("path");
6
+ const editorextension_1 = require("./editorextension");
7
+ const installationutil_1 = require("./installationutil");
8
+ const package_1 = require("./package");
9
+ async function createAngularEditorExtension(name, isInternalTesting, skipSDKDependency) {
10
+ await (0, editorextension_1.createEditorExtension)(name, isInternalTesting, skipSDKDependency, path.join('angular', 'skeleton'), [
11
+ 'webpack-shell-plugin-next',
12
+ ]);
13
+ const angularProjectName = name;
14
+ const angularEditorExtensionTargetFolder = path.join(process.cwd(), angularProjectName);
15
+ console.log('Creating Angular project in ' + angularEditorExtensionTargetFolder);
16
+ (0, installationutil_1.installAngularProject)(angularProjectName);
17
+ const webpackConfig = (await fs.readFile('webpack.config.js', 'utf8')).replace('<<dynamicname>>', angularProjectName);
18
+ const extensionTemplateCode = (await fs.readFile(path.join('src', 'extension.ts'), 'utf8')).replace('<<dynamicname>>', angularProjectName);
19
+ await fs.writeFile(path.join(process.cwd(), 'webpack.config.js'), webpackConfig);
20
+ await fs.writeFile(path.join('src', 'extension.ts'), extensionTemplateCode);
21
+ process.chdir(path.join(angularProjectName));
22
+ const packageJson = await (0, package_1.readJson)('package.json');
23
+ packageJson.name = angularProjectName;
24
+ await fs.writeFile('package.json', JSON.stringify(packageJson, null, 4));
25
+ console.log('Installing Angular dependencies');
26
+ (0, installationutil_1.installDependenciesIfNeeded)(isInternalTesting, skipSDKDependency);
27
+ }
28
+ exports.createAngularEditorExtension = createAngularEditorExtension;
@@ -1,5 +1,5 @@
1
1
  import { Compiler } from 'webpack';
2
- export declare function createEditorExtension(name: string, isInternalTesting: boolean, skipSDKDependency: boolean): Promise<void>;
2
+ export declare function createEditorExtension(name: string, isInternalTesting: boolean, skipSDKDependency: boolean, source?: string, deps?: string[]): Promise<void>;
3
3
  export declare function buildEditorExtension(name: string, isInternalTesting: boolean, quiet?: boolean): Promise<void>;
4
4
  export declare function updateExtensionSDK(name: string): Promise<void>;
5
5
  /**
@@ -17,8 +17,8 @@ const webpack = require('webpack');
17
17
  const WebPackCLI = require('webpack-cli');
18
18
  const ws = require('ws');
19
19
  const chokidar = require('chokidar');
20
- async function createEditorExtension(name, isInternalTesting, skipSDKDependency) {
21
- const editorExtensionSource = path.join(__dirname, '..', 'templates', 'editorextension');
20
+ async function createEditorExtension(name, isInternalTesting, skipSDKDependency, source = 'vanilla', deps = []) {
21
+ const editorExtensionSource = path.join(__dirname, '..', 'templates', 'editorextension', source);
22
22
  const editorExtensionTargetFolder = path.join('editorextensions', name);
23
23
  const publicSource = path.join(__dirname, '..', 'templates', 'public');
24
24
  const publicTargetFolder = 'public';
@@ -40,7 +40,7 @@ async function createEditorExtension(name, isInternalTesting, skipSDKDependency)
40
40
  });
41
41
  console.log(`Installing dependencies`);
42
42
  process.chdir(editorExtensionTargetFolder);
43
- (0, installationutil_1.installDependenciesIfNeeded)(isInternalTesting, skipSDKDependency);
43
+ (0, installationutil_1.installDependenciesIfNeeded)(isInternalTesting, skipSDKDependency, deps);
44
44
  }
45
45
  exports.createEditorExtension = createEditorExtension;
46
46
  async function buildEditorExtension(name, isInternalTesting, quiet = false) {
package/src/index.js CHANGED
@@ -2,9 +2,12 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const argparse_1 = require("argparse");
4
4
  const path = require("path");
5
+ const angularframeworkutils_1 = require("./angularframeworkutils");
5
6
  const dataconnector_1 = require("./dataconnector");
6
7
  const editorextension_1 = require("./editorextension");
8
+ const interactive = require("./interactibilityutil");
7
9
  const package_1 = require("./package");
10
+ const reactframeworkutils_1 = require("./reactframeworkutils");
8
11
  const shapelibrary_1 = require("./shapelibrary");
9
12
  class LucidSuiteExtensionCLI {
10
13
  async run(args) {
@@ -22,7 +25,7 @@ class LucidSuiteExtensionCLI {
22
25
  const createParser = subparsers.add_parser('create', {
23
26
  help: 'Create a new Lucid extension package in a new directory',
24
27
  });
25
- createParser.add_argument('name', { type: 'str' });
28
+ createParser.add_argument('name', { nargs: '?', type: 'str' });
26
29
  const packageParser = subparsers.add_parser('bundle', {
27
30
  help: 'Prepare the current package for upload to the developer dashboard',
28
31
  });
@@ -133,7 +136,49 @@ class LucidSuiteExtensionCLI {
133
136
  }
134
137
  switch (parsed['command']) {
135
138
  case 'create':
136
- (0, package_1.createEmptyPackage)(parsed['name']);
139
+ if (parsed['name'] == null) {
140
+ parsed['name'] = await interactive.inputPrompt('Please enter the name of the Lucid Package');
141
+ }
142
+ await (0, package_1.createEmptyPackage)(parsed['name']);
143
+ const options = ['Editor Extension', 'Shape Library', 'Data Connector'];
144
+ const choices = await interactive.multiSelect('Select components to add to package (can select none or more than one)', options);
145
+ const packagePath = path.join(process.cwd(), parsed['name']);
146
+ for (let choice of choices) {
147
+ switch (choice) {
148
+ case 0:
149
+ process.chdir(packagePath);
150
+ const editorExtensionName = await interactive.inputPrompt('Please enter the name of the editor extension');
151
+ const wantFramework = await interactive.confirmPrompt('Do you want to use a framework for custom UI?');
152
+ if (wantFramework) {
153
+ const options = ['Angular', 'React'];
154
+ const choice = await interactive.selectPrompt('Please select a framework', options);
155
+ switch (choice) {
156
+ case 0:
157
+ await (0, angularframeworkutils_1.createAngularEditorExtension)(editorExtensionName, isInternalTesting, false);
158
+ break;
159
+ case 1:
160
+ const options = ['Javascript', 'Typescript'];
161
+ const choice = await interactive.selectPrompt('Please select flavor', options);
162
+ await (0, reactframeworkutils_1.createReactEditorExtension)(editorExtensionName, options[choice], isInternalTesting, false);
163
+ break;
164
+ }
165
+ }
166
+ else {
167
+ await (0, editorextension_1.createEditorExtension)(editorExtensionName, isInternalTesting, false);
168
+ }
169
+ break;
170
+ case 1:
171
+ process.chdir(packagePath);
172
+ const shapeLibraryName = await interactive.inputPrompt('Please enter the name of the shape library');
173
+ await (0, shapelibrary_1.createEmptyShapeLibrary)(shapeLibraryName);
174
+ break;
175
+ case 2:
176
+ process.chdir(packagePath);
177
+ const dataConnectorName = await interactive.inputPrompt('Please enter the name of the data connector');
178
+ await (0, dataconnector_1.createDataConnector)(dataConnectorName, isInternalTesting, false);
179
+ break;
180
+ }
181
+ }
137
182
  break;
138
183
  default:
139
184
  // All the following commands can only be executed inside a Lucid extension package folder
@@ -1 +1,3 @@
1
- export declare function installDependenciesIfNeeded(isInternalTesting: boolean, skipSDKDependency?: boolean): void;
1
+ export declare function installDependenciesIfNeeded(isInternalTesting: boolean, skipSDKDependency?: boolean, additionalDependencies?: string[]): void;
2
+ export declare function installReactProject(reactProjectName: string, typescript: boolean): void;
3
+ export declare function installAngularProject(angularProjectName: string): void;
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.installDependenciesIfNeeded = void 0;
3
+ exports.installAngularProject = exports.installReactProject = exports.installDependenciesIfNeeded = void 0;
4
4
  const oldFs = require("fs");
5
5
  const path = require("path");
6
6
  const shellutil_1 = require("./shellutil");
7
- function installDependenciesIfNeeded(isInternalTesting, skipSDKDependency = false) {
7
+ function installDependenciesIfNeeded(isInternalTesting, skipSDKDependency = false, additionalDependencies = []) {
8
8
  if (!oldFs.existsSync('node_modules')) {
9
9
  console.log((0, shellutil_1.execSyncLoggingOutputOnError)('npm install --silent').toString());
10
10
  }
@@ -17,5 +17,16 @@ function installDependenciesIfNeeded(isInternalTesting, skipSDKDependency = fals
17
17
  console.log('Adding dependency on SDK');
18
18
  console.log((0, shellutil_1.execSyncLoggingOutputOnError)('npm install --save lucid-extension-sdk').toString());
19
19
  }
20
+ if (additionalDependencies.length) {
21
+ console.log((0, shellutil_1.execSyncLoggingOutputOnError)(`npm install --silent ${additionalDependencies.reduce((acc, current) => `${acc} ${current}`, '')}`).toString());
22
+ }
20
23
  }
21
24
  exports.installDependenciesIfNeeded = installDependenciesIfNeeded;
25
+ function installReactProject(reactProjectName, typescript) {
26
+ console.log((0, shellutil_1.execSyncLoggingOutputOnError)(`npm install create-react-app && npx create-react-app ${reactProjectName} ${typescript ? '--template typescript' : ''}`).toString());
27
+ }
28
+ exports.installReactProject = installReactProject;
29
+ function installAngularProject(angularProjectName) {
30
+ console.log((0, shellutil_1.execSyncLoggingOutputOnError)(`npm install @angular/cli && npx ng new ${angularProjectName}`).toString());
31
+ }
32
+ exports.installAngularProject = installAngularProject;
@@ -0,0 +1,4 @@
1
+ export declare function selectPrompt(message: string, options: string[]): Promise<number>;
2
+ export declare function inputPrompt(message: string): Promise<string>;
3
+ export declare function confirmPrompt(message: string): Promise<boolean>;
4
+ export declare function multiSelect(message: string, options: string[]): Promise<number[]>;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.multiSelect = exports.confirmPrompt = exports.inputPrompt = exports.selectPrompt = void 0;
4
+ const checkbox_1 = require("@inquirer/checkbox");
5
+ const confirm_1 = require("@inquirer/confirm");
6
+ const input_1 = require("@inquirer/input");
7
+ const select_1 = require("@inquirer/select");
8
+ async function selectPrompt(message, options) {
9
+ return await (0, select_1.default)({
10
+ message: message,
11
+ choices: options.map((option, index) => ({ name: option, value: index })),
12
+ });
13
+ }
14
+ exports.selectPrompt = selectPrompt;
15
+ async function inputPrompt(message) {
16
+ return await (0, input_1.default)({ message: message });
17
+ }
18
+ exports.inputPrompt = inputPrompt;
19
+ async function confirmPrompt(message) {
20
+ return await (0, confirm_1.default)({ message: message });
21
+ }
22
+ exports.confirmPrompt = confirmPrompt;
23
+ async function multiSelect(message, options) {
24
+ return await (0, checkbox_1.default)({
25
+ message: message,
26
+ choices: options.map((option, index) => ({ name: option, value: index })),
27
+ });
28
+ }
29
+ exports.multiSelect = multiSelect;
package/src/package.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { PackageManifest } from './packagemanifest';
2
2
  export declare function createEmptyPackage(root: string): Promise<void>;
3
3
  export declare function currentlyInPackage(): boolean;
4
+ export declare function readJson(path: string): Promise<unknown>;
4
5
  export declare function modifyManifest(callback: (manifest: PackageManifest) => void | Promise<void>, manifestOverrideEnv?: string): Promise<void>;
5
6
  export declare function updateAllExtensionSDK(): Promise<void>;
6
7
  /**
package/src/package.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.writePackage = exports.updateAllExtensionSDK = exports.modifyManifest = exports.currentlyInPackage = exports.createEmptyPackage = void 0;
3
+ exports.writePackage = exports.updateAllExtensionSDK = exports.modifyManifest = exports.readJson = exports.currentlyInPackage = exports.createEmptyPackage = void 0;
4
4
  const fsOld = require("fs");
5
5
  const fs = require("fs/promises");
6
6
  const JSZip = require("jszip");
@@ -12,7 +12,7 @@ const packagemanifest_1 = require("./packagemanifest");
12
12
  const shapelibrary_1 = require("./shapelibrary");
13
13
  const shellutil_1 = require("./shellutil");
14
14
  async function createEmptyPackage(root) {
15
- console.log('Creating empty Lucid Suite package in ' + root);
15
+ console.log('Creating Lucid Suite package in ' + root);
16
16
  const source = path.join(__dirname, '..', 'templates', 'package');
17
17
  (0, filesystemutil_1.copyFolderRecursiveSync)(source, root);
18
18
  }
@@ -22,6 +22,10 @@ function currentlyInPackage() {
22
22
  fsOld.existsSync('manifest.json'));
23
23
  }
24
24
  exports.currentlyInPackage = currentlyInPackage;
25
+ async function readJson(path) {
26
+ return JSON.parse(await fs.readFile(path, 'utf8'));
27
+ }
28
+ exports.readJson = readJson;
25
29
  const allScopes = new Set([
26
30
  'DOWNLOAD',
27
31
  'NETWORK',
@@ -0,0 +1 @@
1
+ export declare function createReactEditorExtension(name: string, flavor: string, isInternalTesting: boolean, skipSDKDependency: boolean): Promise<void>;
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createReactEditorExtension = void 0;
4
+ const fs = require("fs/promises");
5
+ const path = require("path");
6
+ const editorextension_1 = require("./editorextension");
7
+ const installationutil_1 = require("./installationutil");
8
+ const package_1 = require("./package");
9
+ async function createReactEditorExtension(name, flavor, isInternalTesting, skipSDKDependency) {
10
+ await (0, editorextension_1.createEditorExtension)(name, isInternalTesting, skipSDKDependency, path.join('react', 'skeleton'), [
11
+ 'webpack-shell-plugin-next',
12
+ ]);
13
+ let typescript = false;
14
+ if (flavor === 'Javascript') {
15
+ typescript = false;
16
+ }
17
+ else if (flavor === 'Typescript') {
18
+ typescript = true;
19
+ }
20
+ else {
21
+ console.log('Unexpected flavor type');
22
+ return;
23
+ }
24
+ const reactProjectName = name;
25
+ const reactEditorExtensionTargetFolder = path.join(process.cwd(), reactProjectName);
26
+ const publicTargetFolder = path.join(process.cwd(), '..', '..', 'public');
27
+ console.log('Creating React project in ' + reactEditorExtensionTargetFolder);
28
+ (0, installationutil_1.installReactProject)(reactProjectName, typescript);
29
+ await fs.mkdir(path.join(publicTargetFolder, name));
30
+ await copyFilesTo(path.join(reactEditorExtensionTargetFolder, 'public'), path.join(publicTargetFolder, name), [
31
+ '.png',
32
+ '.svg',
33
+ '.ico',
34
+ ]);
35
+ await copyFilesTo(path.join(reactEditorExtensionTargetFolder, 'src'), path.join(publicTargetFolder, name), [
36
+ '.png',
37
+ '.svg',
38
+ '.ico',
39
+ ]);
40
+ const webpackConfig = (await fs.readFile('webpack.config.js', 'utf8')).replace('<<dynamicname>>', reactProjectName);
41
+ const extensionTemplateCode = (await fs.readFile(path.join('src', 'extension.ts'), 'utf8')).replace('<<dynamicname>>', reactProjectName);
42
+ await fs.writeFile(path.join(process.cwd(), 'webpack.config.js'), webpackConfig);
43
+ await fs.writeFile(path.join('src', 'extension.ts'), extensionTemplateCode);
44
+ process.chdir(path.join(reactProjectName));
45
+ const packageJson = await (0, package_1.readJson)('package.json');
46
+ packageJson.name = reactProjectName;
47
+ await fs.writeFile('package.json', JSON.stringify(packageJson, null, 4));
48
+ /*
49
+ Hacky solution to change react template from create-react-app; susceptible to changes in create-react-app;
50
+ Out of the box, the logo from create-react-app uses the typescript imported .png file which does not work in our
51
+ extension since we need to specify the location of the image w.r.t the public folder of lucid-package.
52
+ The following lines replace that image location with that of copied image location in the package's public folder.
53
+ */
54
+ const appName = typescript ? 'App.tsx' : 'App.js';
55
+ const apptsx = (await fs.readFile(path.join('src', appName), 'utf8')).replace('{logo}', '"logo.svg"');
56
+ await fs.writeFile(path.join('src', appName), apptsx);
57
+ console.log('Installing React dependencies');
58
+ (0, installationutil_1.installDependenciesIfNeeded)(isInternalTesting, skipSDKDependency);
59
+ }
60
+ exports.createReactEditorExtension = createReactEditorExtension;
61
+ async function copyFilesTo(sourceFolder, destFolder, endingWith) {
62
+ (await fs.readdir(sourceFolder))
63
+ .filter((filename) => endingWith.some((ext) => filename.endsWith(ext)))
64
+ .forEach((source) => fs.copyFile(path.join(sourceFolder, source), path.join(destFolder, source)));
65
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "devDependencies": {
3
+ "raw-loader": "^4.0.2",
4
+ "ts-loader": "^9.2.6",
5
+ "typescript": "^4.5.2",
6
+ "webpack": "^5.64.4"
7
+ }
8
+ }
@@ -0,0 +1,18 @@
1
+ import {EditorClient, Panel, PanelLocation} from 'lucid-extension-sdk';
2
+
3
+ const client = new EditorClient();
4
+
5
+ export class RightPanel extends Panel {
6
+ private static icon = 'https://lucid.app/favicon.ico';
7
+
8
+ constructor(client: EditorClient) {
9
+ super(client, {
10
+ title: 'From Angular',
11
+ url: '<<dynamicname>>/index.html',
12
+ location: PanelLocation.RightDock,
13
+ iconUrl: RightPanel.icon,
14
+ });
15
+ }
16
+ }
17
+
18
+ const rightPanel = new RightPanel(client);
@@ -22,13 +22,17 @@
22
22
  "strictPropertyInitialization": true,
23
23
  "target": "ES2017",
24
24
  "types": [],
25
- "lib": ["es5", "es6", "ES2016.Array.Include", "ES2017.String", "ES2018.Promise", "ES2017.Object", "esnext.asynciterable"],
26
- "outDir": "bin",
25
+ "lib": [
26
+ "es5",
27
+ "es6",
28
+ "ES2016.Array.Include",
29
+ "ES2017.String",
30
+ "ES2018.Promise",
31
+ "ES2017.Object",
32
+ "esnext.asynciterable"
33
+ ],
34
+ "outDir": "bin"
27
35
  },
28
- "files":[
29
- "resources/resource.d.ts",
30
- ],
31
- "include": [
32
- "src/**/*"
33
- ]
36
+ "files": ["resources/resource.d.ts"],
37
+ "include": ["src/**/*"]
34
38
  }
@@ -0,0 +1,59 @@
1
+ const path = require('path');
2
+ const WebpackShellPluginNext = require('webpack-shell-plugin-next');
3
+
4
+ const angularTargets = [{name: '<<dynamicname>>', port: 4200}];
5
+
6
+ module.exports = {
7
+ entry: './src/extension.ts',
8
+ module: {
9
+ rules: [
10
+ {
11
+ test: /\.tsx?$/,
12
+ use: 'ts-loader',
13
+ exclude: /node_modules/,
14
+ },
15
+ {
16
+ test: /[\\\/]resources[\\\/]/,
17
+ use: 'raw-loader',
18
+ exclude: /\.json$/,
19
+ },
20
+ ],
21
+ },
22
+ resolve: {
23
+ extensions: ['.ts', '.js'],
24
+ },
25
+ output: {
26
+ filename: 'bin/extension.js',
27
+ path: __dirname,
28
+ },
29
+ plugins: [
30
+ new WebpackShellPluginNext({
31
+ //When doing a watch build, run "ng serve" and update the html file to prefix http://localhost:4200/ to all the resource URLs
32
+ onWatchRun: {
33
+ scripts: angularTargets.map(
34
+ (target) =>
35
+ `mkdir -p ../../public/${target.name} &&` +
36
+ `curl http://localhost:${target.port} | ` +
37
+ `sed -E "s/(src|href)=\\"/\\\\1=\\"http:\\/\\/localhost:${target.port}\\//gi" > ` +
38
+ `../../public/${target.name}/index.html`,
39
+ ),
40
+ blocking: true,
41
+ },
42
+ //When doing a full build, run "ng build" and then copy all the assets to the root level public folder
43
+ onBeforeNormalRun: {
44
+ scripts: angularTargets.map(
45
+ (target) =>
46
+ `mkdir -p ../../public/${target.name} &&` +
47
+ `cd ${target.name} && ` +
48
+ // `npx ng build` usually works, but this is more reliable when used with build tools such as bazel
49
+ `./node_modules/.bin/ng build && ` +
50
+ `cp -r dist/${target.name}/* ../../../public/${target.name}`,
51
+ ),
52
+ blocking: true,
53
+ swallowError: false,
54
+ safe: true,
55
+ },
56
+ }),
57
+ ],
58
+ mode: 'development',
59
+ };
@@ -0,0 +1,8 @@
1
+ {
2
+ "devDependencies": {
3
+ "raw-loader": "^4.0.2",
4
+ "ts-loader": "^9.2.6",
5
+ "typescript": "^4.5.2",
6
+ "webpack": "^5.64.4"
7
+ }
8
+ }
@@ -0,0 +1,9 @@
1
+ declare module '*.html' {
2
+ const content: string;
3
+ export default content;
4
+ }
5
+
6
+ declare module '*.json' {
7
+ const content: Record<string, string>;
8
+ export default content;
9
+ }
@@ -0,0 +1,18 @@
1
+ import {EditorClient, Panel, PanelLocation} from 'lucid-extension-sdk';
2
+
3
+ const client = new EditorClient();
4
+
5
+ export class RightPanel extends Panel {
6
+ private static icon = 'https://lucid.app/favicon.ico';
7
+
8
+ constructor(client: EditorClient) {
9
+ super(client, {
10
+ title: 'From React',
11
+ url: '<<dynamicname>>/index.html',
12
+ location: PanelLocation.RightDock,
13
+ iconUrl: RightPanel.icon,
14
+ });
15
+ }
16
+ }
17
+
18
+ const rightPanel = new RightPanel(client);
@@ -0,0 +1,61 @@
1
+ /** @ignore */
2
+ declare namespace lucid {
3
+ export function executeCommand(name: string, params: any): any;
4
+ export function listen(msg: any): void;
5
+ export function getPackageId(): string;
6
+ export function getVersion(): string;
7
+ }
8
+
9
+ /** @ignore */
10
+ declare const console: Console;
11
+
12
+ // from lib.dom.d.ts
13
+ /** @ignore */
14
+ interface Console {
15
+ assert(condition?: boolean, ...data: any[]): void;
16
+ clear(): void;
17
+ count(label?: string): void;
18
+ countReset(label?: string): void;
19
+ debug(...data: any[]): void;
20
+ dir(item?: any, options?: any): void;
21
+ dirxml(...data: any[]): void;
22
+ error(...data: any[]): void;
23
+ group(...data: any[]): void;
24
+ groupCollapsed(...data: any[]): void;
25
+ groupEnd(): void;
26
+ info(...data: any[]): void;
27
+ log(...data: any[]): void;
28
+ table(tabularData?: any, properties?: string[]): void;
29
+ time(label?: string): void;
30
+ timeEnd(label?: string): void;
31
+ timeLog(label?: string, ...data: any[]): void;
32
+ timeStamp(label?: string): void;
33
+ trace(...data: any[]): void;
34
+ warn(...data: any[]): void;
35
+ }
36
+
37
+ declare class I18nSafeString {
38
+ public value: string;
39
+ constructor(str: string);
40
+ }
41
+
42
+ declare interface I18nFormattedNumberParams {
43
+ useGrouping?: boolean;
44
+ minimumIntegerDigits?: number;
45
+ minimumFractionDigits?: number;
46
+ maximumFractionDigits?: number;
47
+ }
48
+
49
+ declare class I18nFormattedNumber {}
50
+
51
+ declare interface I18nReplacement {
52
+ [s: string]: number | string | I18nSafeString | I18nFormattedNumber;
53
+ }
54
+
55
+ declare namespace i18n {
56
+ function setData(data: {[key: string]: string}, language: string): void;
57
+ function get(key: string, replacements?: I18nReplacement, wrappers?: string[], gender?: string): string;
58
+ function getLanguage(): string;
59
+ function getInLocale(locale: string, key: string, replacements?: I18nReplacement, wrappers?: string[]): string;
60
+ function formatNumber(value: number, params: I18nFormattedNumberParams): I18nFormattedNumber;
61
+ }
@@ -0,0 +1,38 @@
1
+ {
2
+ "compilerOptions": {
3
+ "declaration": true,
4
+ "emitDecoratorMetadata": true,
5
+ "experimentalDecorators": true,
6
+ "forceConsistentCasingInFileNames": true,
7
+ "module": "commonjs",
8
+ "moduleResolution": "node",
9
+ "newLine": "lf",
10
+ "noEmitOnError": false,
11
+ "noImplicitAny": true,
12
+ "noImplicitReturns": true,
13
+ "noImplicitThis": true,
14
+ "noUnusedLocals": false,
15
+ "pretty": true,
16
+ "removeComments": false,
17
+ "skipLibCheck": true,
18
+ "sourceMap": false,
19
+ "strictBindCallApply": true,
20
+ "strictFunctionTypes": true,
21
+ "strictNullChecks": true,
22
+ "strictPropertyInitialization": true,
23
+ "target": "ES2017",
24
+ "types": [],
25
+ "lib": [
26
+ "es5",
27
+ "es6",
28
+ "ES2016.Array.Include",
29
+ "ES2017.String",
30
+ "ES2018.Promise",
31
+ "ES2017.Object",
32
+ "esnext.asynciterable"
33
+ ],
34
+ "outDir": "bin"
35
+ },
36
+ "files": ["resources/resource.d.ts"],
37
+ "include": ["src/**/*"]
38
+ }
@@ -0,0 +1,57 @@
1
+ const path = require('path');
2
+ const WebpackShellPluginNext = require('webpack-shell-plugin-next');
3
+
4
+ const reactTargets = [{name: '<<dynamicname>>', port: 3000}];
5
+
6
+ module.exports = {
7
+ entry: './src/extension.ts',
8
+ module: {
9
+ rules: [
10
+ {
11
+ test: /\.tsx?$/,
12
+ use: 'ts-loader',
13
+ exclude: /node_modules/,
14
+ },
15
+ {
16
+ test: /[\\\/]resources[\\\/]/,
17
+ use: 'raw-loader',
18
+ exclude: /\.json$/,
19
+ },
20
+ ],
21
+ },
22
+ resolve: {
23
+ extensions: ['.ts', '.js'],
24
+ },
25
+ output: {
26
+ filename: 'bin/extension.js',
27
+ path: __dirname,
28
+ },
29
+ plugins: [
30
+ new WebpackShellPluginNext({
31
+ //When doing a watch build, run "npm start" and update the html file to prefix http://localhost:3000/ to all the resource URLs
32
+ onWatchRun: {
33
+ scripts: reactTargets.map(
34
+ (target) =>
35
+ `mkdir -p ../../public/${target.name} &&` +
36
+ `curl http://localhost:${target.port} | ` +
37
+ `sed -E "s/(src|href)=\\"/\\\\1=\\"http:\\/\\/localhost:${target.port}\/gi" > ` +
38
+ `../../public/${target.name}/index.html`,
39
+ ),
40
+ blocking: true,
41
+ },
42
+ // When doing a full build, run "npm run build" and then copy all the assets to the root level public folder
43
+ onBeforeNormalRun: {
44
+ scripts: reactTargets.map(
45
+ (target) =>
46
+ `mkdir -p ../../public/${target.name} &&` +
47
+ `cd ${target.name} && ` +
48
+ `npm run build && ` +
49
+ `sed -i -E "s/(src|href)=\\"\\//\\1=\\"\/gi" build/index.html &&` +
50
+ `cp -r build/* ../../../public/${target.name}`,
51
+ ),
52
+ blocking: true,
53
+ },
54
+ }),
55
+ ],
56
+ mode: 'development',
57
+ };
@@ -0,0 +1,9 @@
1
+ declare module '*.html' {
2
+ const content: string;
3
+ export default content;
4
+ }
5
+
6
+ declare module '*.json' {
7
+ const content: Record<string, string>;
8
+ export default content;
9
+ }
@@ -0,0 +1,61 @@
1
+ /** @ignore */
2
+ declare namespace lucid {
3
+ export function executeCommand(name: string, params: any): any;
4
+ export function listen(msg: any): void;
5
+ export function getPackageId(): string;
6
+ export function getVersion(): string;
7
+ }
8
+
9
+ /** @ignore */
10
+ declare const console: Console;
11
+
12
+ // from lib.dom.d.ts
13
+ /** @ignore */
14
+ interface Console {
15
+ assert(condition?: boolean, ...data: any[]): void;
16
+ clear(): void;
17
+ count(label?: string): void;
18
+ countReset(label?: string): void;
19
+ debug(...data: any[]): void;
20
+ dir(item?: any, options?: any): void;
21
+ dirxml(...data: any[]): void;
22
+ error(...data: any[]): void;
23
+ group(...data: any[]): void;
24
+ groupCollapsed(...data: any[]): void;
25
+ groupEnd(): void;
26
+ info(...data: any[]): void;
27
+ log(...data: any[]): void;
28
+ table(tabularData?: any, properties?: string[]): void;
29
+ time(label?: string): void;
30
+ timeEnd(label?: string): void;
31
+ timeLog(label?: string, ...data: any[]): void;
32
+ timeStamp(label?: string): void;
33
+ trace(...data: any[]): void;
34
+ warn(...data: any[]): void;
35
+ }
36
+
37
+ declare class I18nSafeString {
38
+ public value: string;
39
+ constructor(str: string);
40
+ }
41
+
42
+ declare interface I18nFormattedNumberParams {
43
+ useGrouping?: boolean;
44
+ minimumIntegerDigits?: number;
45
+ minimumFractionDigits?: number;
46
+ maximumFractionDigits?: number;
47
+ }
48
+
49
+ declare class I18nFormattedNumber {}
50
+
51
+ declare interface I18nReplacement {
52
+ [s: string]: number | string | I18nSafeString | I18nFormattedNumber;
53
+ }
54
+
55
+ declare namespace i18n {
56
+ function setData(data: {[key: string]: string}, language: string): void;
57
+ function get(key: string, replacements?: I18nReplacement, wrappers?: string[], gender?: string): string;
58
+ function getLanguage(): string;
59
+ function getInLocale(locale: string, key: string, replacements?: I18nReplacement, wrappers?: string[]): string;
60
+ function formatNumber(value: number, params: I18nFormattedNumberParams): I18nFormattedNumber;
61
+ }
@@ -0,0 +1,38 @@
1
+ {
2
+ "compilerOptions": {
3
+ "declaration": true,
4
+ "emitDecoratorMetadata": true,
5
+ "experimentalDecorators": true,
6
+ "forceConsistentCasingInFileNames": true,
7
+ "module": "commonjs",
8
+ "moduleResolution": "node",
9
+ "newLine": "lf",
10
+ "noEmitOnError": false,
11
+ "noImplicitAny": true,
12
+ "noImplicitReturns": true,
13
+ "noImplicitThis": true,
14
+ "noUnusedLocals": false,
15
+ "pretty": true,
16
+ "removeComments": false,
17
+ "skipLibCheck": true,
18
+ "sourceMap": false,
19
+ "strictBindCallApply": true,
20
+ "strictFunctionTypes": true,
21
+ "strictNullChecks": true,
22
+ "strictPropertyInitialization": true,
23
+ "target": "ES2017",
24
+ "types": [],
25
+ "lib": [
26
+ "es5",
27
+ "es6",
28
+ "ES2016.Array.Include",
29
+ "ES2017.String",
30
+ "ES2018.Promise",
31
+ "ES2017.Object",
32
+ "esnext.asynciterable"
33
+ ],
34
+ "outDir": "bin"
35
+ },
36
+ "files": ["resources/resource.d.ts"],
37
+ "include": ["src/**/*"]
38
+ }