lucid-package 0.0.90 → 0.0.92
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/package.json +6 -1
- package/src/angularframeworkutils.d.ts +1 -0
- package/src/angularframeworkutils.js +29 -0
- package/src/dataconnector.js +2 -1
- package/src/editorextension.d.ts +2 -1
- package/src/editorextension.js +60 -7
- package/src/index.js +50 -2
- package/src/installationutil.d.ts +3 -1
- package/src/installationutil.js +15 -3
- package/src/interactibilityutil.d.ts +4 -0
- package/src/interactibilityutil.js +29 -0
- package/src/package.d.ts +1 -0
- package/src/package.js +10 -5
- package/src/reactframeworkutils.d.ts +1 -0
- package/src/reactframeworkutils.js +66 -0
- package/src/shapelibrary.js +6 -5
- package/src/shellutil.js +3 -2
- package/src/theme.d.ts +3 -0
- package/src/theme.js +7 -0
- package/templates/editorextension/angular/skeleton/package.json +8 -0
- package/templates/editorextension/angular/skeleton/src/extension.ts +18 -0
- package/templates/editorextension/{tsconfig.json → angular/skeleton/tsconfig.json} +12 -8
- package/templates/editorextension/angular/skeleton/webpack.config.js +59 -0
- package/templates/editorextension/react/skeleton/package.json +8 -0
- package/templates/editorextension/react/skeleton/resources/resource.d.ts +9 -0
- package/templates/editorextension/react/skeleton/src/extension.ts +18 -0
- package/templates/editorextension/react/skeleton/src/interop.d.ts +61 -0
- package/templates/editorextension/react/skeleton/tsconfig.json +38 -0
- package/templates/editorextension/react/skeleton/webpack.config.js +57 -0
- package/templates/editorextension/vanilla/resources/resource.d.ts +9 -0
- package/templates/editorextension/vanilla/src/interop.d.ts +61 -0
- package/templates/editorextension/vanilla/tsconfig.json +38 -0
- package/templates/package/package.json +16 -0
- /package/templates/editorextension/{resources → angular/skeleton/resources}/resource.d.ts +0 -0
- /package/templates/editorextension/{src → angular/skeleton/src}/interop.d.ts +0 -0
- /package/templates/editorextension/{package.json → vanilla/package.json} +0 -0
- /package/templates/editorextension/{src → vanilla/src}/extension.ts +0 -0
- /package/templates/editorextension/{src → vanilla/src}/importmodal.ts +0 -0
- /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.
|
|
3
|
+
"version": "0.0.92",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
@@ -21,7 +21,12 @@
|
|
|
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",
|
|
29
|
+
"chalk": "4.1.2",
|
|
25
30
|
"chokidar": "^3.5.3",
|
|
26
31
|
"express": "^4.17.1",
|
|
27
32
|
"hjson": "^3.2.2",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function createAngularEditorExtension(name: string, isInternalTesting: boolean, skipSDKDependency: boolean): Promise<void>;
|
|
@@ -0,0 +1,29 @@
|
|
|
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
|
+
const theme_1 = require("./theme");
|
|
10
|
+
async function createAngularEditorExtension(name, isInternalTesting, skipSDKDependency) {
|
|
11
|
+
await (0, editorextension_1.createEditorExtension)(name, isInternalTesting, skipSDKDependency, path.join('angular', 'skeleton'), [
|
|
12
|
+
'webpack-shell-plugin-next',
|
|
13
|
+
]);
|
|
14
|
+
const angularProjectName = name;
|
|
15
|
+
const angularEditorExtensionTargetFolder = path.join(process.cwd(), angularProjectName);
|
|
16
|
+
console.log((0, theme_1.success)('Creating Angular project in ' + angularEditorExtensionTargetFolder));
|
|
17
|
+
(0, installationutil_1.installAngularProject)(angularProjectName);
|
|
18
|
+
const webpackConfig = (await fs.readFile('webpack.config.js', 'utf8')).replace('<<dynamicname>>', angularProjectName);
|
|
19
|
+
const extensionTemplateCode = (await fs.readFile(path.join('src', 'extension.ts'), 'utf8')).replace('<<dynamicname>>', angularProjectName);
|
|
20
|
+
await fs.writeFile(path.join(process.cwd(), 'webpack.config.js'), webpackConfig);
|
|
21
|
+
await fs.writeFile(path.join('src', 'extension.ts'), extensionTemplateCode);
|
|
22
|
+
process.chdir(path.join(angularProjectName));
|
|
23
|
+
const packageJson = await (0, package_1.readJson)('package.json');
|
|
24
|
+
packageJson.name = angularProjectName;
|
|
25
|
+
await fs.writeFile('package.json', JSON.stringify(packageJson, null, 4));
|
|
26
|
+
console.log('Installing Angular dependencies');
|
|
27
|
+
(0, installationutil_1.installDependenciesIfNeeded)(isInternalTesting, skipSDKDependency);
|
|
28
|
+
}
|
|
29
|
+
exports.createAngularEditorExtension = createAngularEditorExtension;
|
package/src/dataconnector.js
CHANGED
|
@@ -5,8 +5,9 @@ const path = require("path");
|
|
|
5
5
|
const filesystemutil_1 = require("./filesystemutil");
|
|
6
6
|
const installationutil_1 = require("./installationutil");
|
|
7
7
|
const package_1 = require("./package");
|
|
8
|
+
const theme_1 = require("./theme");
|
|
8
9
|
async function createDataConnector(name, isInternalTesting, skipSDKDependency) {
|
|
9
|
-
console.log('Creating data connector in dataconnectors/' + name);
|
|
10
|
+
console.log((0, theme_1.success)('Creating data connector in dataconnectors/' + name));
|
|
10
11
|
const source = path.join(__dirname, '..', 'templates', 'dataconnector');
|
|
11
12
|
const targetFolder = path.join('dataconnectors', name);
|
|
12
13
|
(0, filesystemutil_1.copyFolderRecursiveSync)(source, targetFolder);
|
package/src/editorextension.d.ts
CHANGED
|
@@ -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,3 +17,4 @@ export declare function watchEditorExtension(name: string, isInternalTesting: bo
|
|
|
17
17
|
* @param quiet If true, will only show errors in output
|
|
18
18
|
*/
|
|
19
19
|
export declare function debugEditorExtension(extensionNames: string[], isInternalTesting: boolean, quiet?: boolean, pickAnyPort?: boolean): Promise<void>;
|
|
20
|
+
export declare function getAllExtensionNames(): Promise<string[]>;
|
package/src/editorextension.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.debugEditorExtension = exports.watchEditorExtension = exports.updateExtensionSDK = exports.buildEditorExtension = exports.createEditorExtension = void 0;
|
|
3
|
+
exports.getAllExtensionNames = exports.debugEditorExtension = exports.watchEditorExtension = exports.updateExtensionSDK = exports.buildEditorExtension = exports.createEditorExtension = void 0;
|
|
4
4
|
const express = require("express");
|
|
5
5
|
const oldFs = require("fs");
|
|
6
6
|
const fs = require("fs/promises");
|
|
@@ -13,17 +13,19 @@ const packagemanifest_1 = require("./packagemanifest");
|
|
|
13
13
|
const shapelibrary_1 = require("./shapelibrary");
|
|
14
14
|
const shellutil_1 = require("./shellutil");
|
|
15
15
|
const supportedproduct_1 = require("./supportedproduct");
|
|
16
|
+
const child_process_1 = require("child_process");
|
|
17
|
+
const theme_1 = require("./theme");
|
|
16
18
|
const webpack = require('webpack');
|
|
17
19
|
const WebPackCLI = require('webpack-cli');
|
|
18
20
|
const ws = require('ws');
|
|
19
21
|
const chokidar = require('chokidar');
|
|
20
|
-
async function createEditorExtension(name, isInternalTesting, skipSDKDependency) {
|
|
21
|
-
const editorExtensionSource = path.join(__dirname, '..', 'templates', 'editorextension');
|
|
22
|
+
async function createEditorExtension(name, isInternalTesting, skipSDKDependency, source = 'vanilla', deps = []) {
|
|
23
|
+
const editorExtensionSource = path.join(__dirname, '..', 'templates', 'editorextension', source);
|
|
22
24
|
const editorExtensionTargetFolder = path.join('editorextensions', name);
|
|
23
25
|
const publicSource = path.join(__dirname, '..', 'templates', 'public');
|
|
24
26
|
const publicTargetFolder = 'public';
|
|
25
27
|
const codePath = path.join('editorextensions', name, 'bin', 'extension.js');
|
|
26
|
-
console.log('Creating empty editor extension in ' + editorExtensionTargetFolder);
|
|
28
|
+
console.log((0, theme_1.success)('Creating empty editor extension in ' + editorExtensionTargetFolder));
|
|
27
29
|
(0, filesystemutil_1.copyFolderRecursiveSync)(editorExtensionSource, editorExtensionTargetFolder);
|
|
28
30
|
(0, filesystemutil_1.copyFolderRecursiveSync)(publicSource, publicTargetFolder);
|
|
29
31
|
await (0, package_1.modifyManifest)((manifest) => {
|
|
@@ -40,7 +42,7 @@ async function createEditorExtension(name, isInternalTesting, skipSDKDependency)
|
|
|
40
42
|
});
|
|
41
43
|
console.log(`Installing dependencies`);
|
|
42
44
|
process.chdir(editorExtensionTargetFolder);
|
|
43
|
-
(0, installationutil_1.installDependenciesIfNeeded)(isInternalTesting, skipSDKDependency);
|
|
45
|
+
(0, installationutil_1.installDependenciesIfNeeded)(isInternalTesting, skipSDKDependency, deps);
|
|
44
46
|
}
|
|
45
47
|
exports.createEditorExtension = createEditorExtension;
|
|
46
48
|
async function buildEditorExtension(name, isInternalTesting, quiet = false) {
|
|
@@ -54,7 +56,7 @@ exports.buildEditorExtension = buildEditorExtension;
|
|
|
54
56
|
async function updateExtensionSDK(name) {
|
|
55
57
|
const extensionCodePath = path.join('editorextensions', await getExtensionCodeDirectoryName(name));
|
|
56
58
|
process.chdir(extensionCodePath);
|
|
57
|
-
console.log('Installing latest SDK in extension ' + name);
|
|
59
|
+
console.log((0, theme_1.success)('Installing latest SDK in extension ' + name));
|
|
58
60
|
console.log((0, shellutil_1.execSyncLoggingOutputOnError)('npm install lucid-extension-sdk@latest').toString());
|
|
59
61
|
}
|
|
60
62
|
exports.updateExtensionSDK = updateExtensionSDK;
|
|
@@ -91,6 +93,7 @@ exports.watchEditorExtension = watchEditorExtension;
|
|
|
91
93
|
async function debugEditorExtension(extensionNames, isInternalTesting, quiet = false, pickAnyPort = false) {
|
|
92
94
|
const port = 9900;
|
|
93
95
|
const watchers = await Promise.all(extensionNames.map(async (name) => watchEditorExtension(name, isInternalTesting, quiet)));
|
|
96
|
+
startCustomUIServers(extensionNames);
|
|
94
97
|
const app = express();
|
|
95
98
|
const server = listen(app, port, pickAnyPort);
|
|
96
99
|
setupWebSockets(server);
|
|
@@ -203,7 +206,7 @@ exports.debugEditorExtension = debugEditorExtension;
|
|
|
203
206
|
function listen(app, port, pickAnyPort) {
|
|
204
207
|
return app
|
|
205
208
|
.listen(port, 'localhost', () => {
|
|
206
|
-
console.log('Listening at http://localhost:' + port + '/extension.js');
|
|
209
|
+
console.log((0, theme_1.success)('Listening at http://localhost:' + port + '/extension.js'));
|
|
207
210
|
(0, shapelibrary_1.debugShapeLibraries)(undefined, pickAnyPort);
|
|
208
211
|
})
|
|
209
212
|
.on('error', (err) => {
|
|
@@ -309,3 +312,53 @@ function getExtensionProducts(product, products) {
|
|
|
309
312
|
}
|
|
310
313
|
throw new Error('Either "product" or "products" must be spcified for the editor extension in the package manifest');
|
|
311
314
|
}
|
|
315
|
+
async function getAllExtensionNames() {
|
|
316
|
+
const manifest = await (0, packagemanifest_1.readManifest)('local');
|
|
317
|
+
if (manifest.extensions) {
|
|
318
|
+
return manifest.extensions.map(extn => extn.name);
|
|
319
|
+
}
|
|
320
|
+
else {
|
|
321
|
+
return [];
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
exports.getAllExtensionNames = getAllExtensionNames;
|
|
325
|
+
async function startCustomUIServers(extensionNames) {
|
|
326
|
+
for (let extensionName of extensionNames) {
|
|
327
|
+
const extensionCodePath = path.resolve(path.join('editorextensions', await getExtensionCodeDirectoryName(extensionName)));
|
|
328
|
+
const potentialCustomUIServer = (await fs.readdir(extensionCodePath, { withFileTypes: true })).filter(dirent => dirent.isDirectory()).map(dirent => path.join(extensionCodePath, dirent.name));
|
|
329
|
+
for (let potentialPaths of potentialCustomUIServer) {
|
|
330
|
+
runNpmStartIfExists(potentialPaths);
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
async function runNpmStartIfExists(directoryPath) {
|
|
335
|
+
try {
|
|
336
|
+
// Read the package.json file
|
|
337
|
+
const packageJsonPath = path.join(directoryPath, 'package.json');
|
|
338
|
+
if (oldFs.existsSync(packageJsonPath)) {
|
|
339
|
+
const packageJson = await fs.readFile(packageJsonPath, 'utf-8');
|
|
340
|
+
const packageData = JSON.parse(packageJson);
|
|
341
|
+
// Check if package.json has "scripts" object and it contains "start"
|
|
342
|
+
if (packageData && packageData.scripts && packageData.scripts.start) {
|
|
343
|
+
console.log((0, theme_1.success)(`Found npm start script in ${directoryPath}.`));
|
|
344
|
+
// Execute npm start
|
|
345
|
+
const npmStart = (0, child_process_1.spawn)('npm', ['start'], { cwd: directoryPath, stdio: ['inherit', 'pipe', 'pipe'] });
|
|
346
|
+
npmStart.stdout.on('data', (data) => {
|
|
347
|
+
process.stdout.write(data);
|
|
348
|
+
});
|
|
349
|
+
npmStart.stderr.on('data', (data) => {
|
|
350
|
+
process.stderr.write(data);
|
|
351
|
+
});
|
|
352
|
+
npmStart.on('exit', (code) => {
|
|
353
|
+
console.log(`npm start process exited with code ${code}`);
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
else {
|
|
357
|
+
console.log(`No npm start script found in ${directoryPath}.`);
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
catch (error) {
|
|
362
|
+
console.error(error(`Error occurred: ${error.message}`));
|
|
363
|
+
}
|
|
364
|
+
}
|
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
|
-
|
|
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
|
|
@@ -174,6 +219,9 @@ class LucidSuiteExtensionCLI {
|
|
|
174
219
|
await (0, shapelibrary_1.debugShapeLibraries)();
|
|
175
220
|
break;
|
|
176
221
|
case 'test-editor-extension':
|
|
222
|
+
if (parsed['name'].length === 0) {
|
|
223
|
+
parsed['name'] = await (0, editorextension_1.getAllExtensionNames)();
|
|
224
|
+
}
|
|
177
225
|
await (0, editorextension_1.debugEditorExtension)(parsed['name'], isInternalTesting, parsed['quiet'], parsed['anyport']);
|
|
178
226
|
break;
|
|
179
227
|
case 'watch-editor-extension':
|
|
@@ -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;
|
package/src/installationutil.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
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
|
-
|
|
7
|
+
const theme_1 = require("./theme");
|
|
8
|
+
function installDependenciesIfNeeded(isInternalTesting, skipSDKDependency = false, additionalDependencies = []) {
|
|
8
9
|
if (!oldFs.existsSync('node_modules')) {
|
|
9
10
|
console.log((0, shellutil_1.execSyncLoggingOutputOnError)('npm install --silent').toString());
|
|
10
11
|
}
|
|
@@ -14,8 +15,19 @@ function installDependenciesIfNeeded(isInternalTesting, skipSDKDependency = fals
|
|
|
14
15
|
oldFs.rmSync(sdkDir, { recursive: true, force: true });
|
|
15
16
|
}
|
|
16
17
|
else if (!oldFs.existsSync(sdkDir) && !skipSDKDependency) {
|
|
17
|
-
console.log('Adding dependency on SDK');
|
|
18
|
+
console.log((0, theme_1.success)('Adding dependency on SDK'));
|
|
18
19
|
console.log((0, shellutil_1.execSyncLoggingOutputOnError)('npm install --save lucid-extension-sdk').toString());
|
|
19
20
|
}
|
|
21
|
+
if (additionalDependencies.length) {
|
|
22
|
+
console.log((0, shellutil_1.execSyncLoggingOutputOnError)(`npm install --silent ${additionalDependencies.reduce((acc, current) => `${acc} ${current}`, '')}`).toString());
|
|
23
|
+
}
|
|
20
24
|
}
|
|
21
25
|
exports.installDependenciesIfNeeded = installDependenciesIfNeeded;
|
|
26
|
+
function installReactProject(reactProjectName, typescript) {
|
|
27
|
+
console.log((0, shellutil_1.execSyncLoggingOutputOnError)(`npm install create-react-app && npx create-react-app ${reactProjectName} ${typescript ? '--template typescript' : ''}`).toString());
|
|
28
|
+
}
|
|
29
|
+
exports.installReactProject = installReactProject;
|
|
30
|
+
function installAngularProject(angularProjectName) {
|
|
31
|
+
console.log((0, shellutil_1.execSyncLoggingOutputOnError)(`npm install @angular/cli && npx ng new ${angularProjectName}`).toString());
|
|
32
|
+
}
|
|
33
|
+
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");
|
|
@@ -11,8 +11,9 @@ const filesystemutil_1 = require("./filesystemutil");
|
|
|
11
11
|
const packagemanifest_1 = require("./packagemanifest");
|
|
12
12
|
const shapelibrary_1 = require("./shapelibrary");
|
|
13
13
|
const shellutil_1 = require("./shellutil");
|
|
14
|
+
const theme_1 = require("./theme");
|
|
14
15
|
async function createEmptyPackage(root) {
|
|
15
|
-
console.log('Creating
|
|
16
|
+
console.log((0, theme_1.success)('Creating Lucid Suite package in ' + root));
|
|
16
17
|
const source = path.join(__dirname, '..', 'templates', 'package');
|
|
17
18
|
(0, filesystemutil_1.copyFolderRecursiveSync)(source, root);
|
|
18
19
|
}
|
|
@@ -22,6 +23,10 @@ function currentlyInPackage() {
|
|
|
22
23
|
fsOld.existsSync('manifest.json'));
|
|
23
24
|
}
|
|
24
25
|
exports.currentlyInPackage = currentlyInPackage;
|
|
26
|
+
async function readJson(path) {
|
|
27
|
+
return JSON.parse(await fs.readFile(path, 'utf8'));
|
|
28
|
+
}
|
|
29
|
+
exports.readJson = readJson;
|
|
25
30
|
const allScopes = new Set([
|
|
26
31
|
'DOWNLOAD',
|
|
27
32
|
'NETWORK',
|
|
@@ -77,7 +82,7 @@ async function writePackage(quiet = false, manifestOverrideEnv) {
|
|
|
77
82
|
const parts = extension['codePath'].split(path.sep);
|
|
78
83
|
if (parts[0] === 'editorextensions') {
|
|
79
84
|
//Can't just call the method, as the WebpackCLI class does process.exit(2) :facepalm:
|
|
80
|
-
console.log(`Compiling editor extension ${parts[1]}`);
|
|
85
|
+
console.log((0, theme_1.success)(`Compiling editor extension ${parts[1]}`));
|
|
81
86
|
// Quotes are needed around every use of a path to deal with spaces
|
|
82
87
|
const cmd = '"' +
|
|
83
88
|
process.argv[0] +
|
|
@@ -97,7 +102,7 @@ async function writePackage(quiet = false, manifestOverrideEnv) {
|
|
|
97
102
|
for (const library of manifest['shapeLibraries'] || []) {
|
|
98
103
|
const parts = library['lcszPath'].split(path.sep);
|
|
99
104
|
if (parts[0] === 'shapelibraries') {
|
|
100
|
-
console.log(`Building shape library ${parts[1]}`);
|
|
105
|
+
console.log((0, theme_1.success)(`Building shape library ${parts[1]}`));
|
|
101
106
|
await (0, shapelibrary_1.buildShapeLibrary)(parts[1].replace('.lcsz', ''));
|
|
102
107
|
}
|
|
103
108
|
zip.file(library['lcszPath'], await fs.readFile(library['lcszPath']));
|
|
@@ -139,7 +144,7 @@ async function writePackage(quiet = false, manifestOverrideEnv) {
|
|
|
139
144
|
compression: 'DEFLATE',
|
|
140
145
|
compressionOptions: { level: 9 },
|
|
141
146
|
});
|
|
142
|
-
console.log('Writing file package.zip');
|
|
147
|
+
console.log((0, theme_1.success)('Writing file package.zip'));
|
|
143
148
|
const fileName = `package${manifestOverrideEnv ? `-${manifestOverrideEnv}` : ''}.zip`;
|
|
144
149
|
await fs.writeFile(fileName, zipBytes);
|
|
145
150
|
}, manifestOverrideEnv);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function createReactEditorExtension(name: string, flavor: string, isInternalTesting: boolean, skipSDKDependency: boolean): Promise<void>;
|
|
@@ -0,0 +1,66 @@
|
|
|
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
|
+
const theme_1 = require("./theme");
|
|
10
|
+
async function createReactEditorExtension(name, flavor, isInternalTesting, skipSDKDependency) {
|
|
11
|
+
await (0, editorextension_1.createEditorExtension)(name, isInternalTesting, skipSDKDependency, path.join('react', 'skeleton'), [
|
|
12
|
+
'webpack-shell-plugin-next',
|
|
13
|
+
]);
|
|
14
|
+
let typescript = false;
|
|
15
|
+
if (flavor === 'Javascript') {
|
|
16
|
+
typescript = false;
|
|
17
|
+
}
|
|
18
|
+
else if (flavor === 'Typescript') {
|
|
19
|
+
typescript = true;
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
console.log((0, theme_1.error)('Unexpected flavor type'));
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
const reactProjectName = name;
|
|
26
|
+
const reactEditorExtensionTargetFolder = path.join(process.cwd(), reactProjectName);
|
|
27
|
+
const publicTargetFolder = path.join(process.cwd(), '..', '..', 'public');
|
|
28
|
+
console.log((0, theme_1.success)('Creating React project in ' + reactEditorExtensionTargetFolder));
|
|
29
|
+
(0, installationutil_1.installReactProject)(reactProjectName, typescript);
|
|
30
|
+
await fs.mkdir(path.join(publicTargetFolder, name));
|
|
31
|
+
await copyFilesTo(path.join(reactEditorExtensionTargetFolder, 'public'), path.join(publicTargetFolder, name), [
|
|
32
|
+
'.png',
|
|
33
|
+
'.svg',
|
|
34
|
+
'.ico',
|
|
35
|
+
]);
|
|
36
|
+
await copyFilesTo(path.join(reactEditorExtensionTargetFolder, 'src'), path.join(publicTargetFolder, name), [
|
|
37
|
+
'.png',
|
|
38
|
+
'.svg',
|
|
39
|
+
'.ico',
|
|
40
|
+
]);
|
|
41
|
+
const webpackConfig = (await fs.readFile('webpack.config.js', 'utf8')).replace('<<dynamicname>>', reactProjectName);
|
|
42
|
+
const extensionTemplateCode = (await fs.readFile(path.join('src', 'extension.ts'), 'utf8')).replace('<<dynamicname>>', reactProjectName);
|
|
43
|
+
await fs.writeFile(path.join(process.cwd(), 'webpack.config.js'), webpackConfig);
|
|
44
|
+
await fs.writeFile(path.join('src', 'extension.ts'), extensionTemplateCode);
|
|
45
|
+
process.chdir(path.join(reactProjectName));
|
|
46
|
+
const packageJson = await (0, package_1.readJson)('package.json');
|
|
47
|
+
packageJson.name = reactProjectName;
|
|
48
|
+
await fs.writeFile('package.json', JSON.stringify(packageJson, null, 4));
|
|
49
|
+
/*
|
|
50
|
+
Hacky solution to change react template from create-react-app; susceptible to changes in create-react-app;
|
|
51
|
+
Out of the box, the logo from create-react-app uses the typescript imported .png file which does not work in our
|
|
52
|
+
extension since we need to specify the location of the image w.r.t the public folder of lucid-package.
|
|
53
|
+
The following lines replace that image location with that of copied image location in the package's public folder.
|
|
54
|
+
*/
|
|
55
|
+
const appName = typescript ? 'App.tsx' : 'App.js';
|
|
56
|
+
const apptsx = (await fs.readFile(path.join('src', appName), 'utf8')).replace('{logo}', '"logo.svg"');
|
|
57
|
+
await fs.writeFile(path.join('src', appName), apptsx);
|
|
58
|
+
console.log('Installing React dependencies');
|
|
59
|
+
(0, installationutil_1.installDependenciesIfNeeded)(isInternalTesting, skipSDKDependency);
|
|
60
|
+
}
|
|
61
|
+
exports.createReactEditorExtension = createReactEditorExtension;
|
|
62
|
+
async function copyFilesTo(sourceFolder, destFolder, endingWith) {
|
|
63
|
+
(await fs.readdir(sourceFolder))
|
|
64
|
+
.filter((filename) => endingWith.some((ext) => filename.endsWith(ext)))
|
|
65
|
+
.forEach((source) => fs.copyFile(path.join(sourceFolder, source), path.join(destFolder, source)));
|
|
66
|
+
}
|
package/src/shapelibrary.js
CHANGED
|
@@ -10,6 +10,7 @@ const cors_1 = require("./cors");
|
|
|
10
10
|
const filesystemutil_1 = require("./filesystemutil");
|
|
11
11
|
const package_1 = require("./package");
|
|
12
12
|
const packagemanifest_1 = require("./packagemanifest");
|
|
13
|
+
const theme_1 = require("./theme");
|
|
13
14
|
const hjson = require('hjson');
|
|
14
15
|
const ws = require('ws');
|
|
15
16
|
const chokidar = require('chokidar');
|
|
@@ -17,7 +18,7 @@ const sizeOf = require('image-size');
|
|
|
17
18
|
async function createEmptyShapeLibrary(name) {
|
|
18
19
|
const source = path.join(__dirname, '..', 'templates', 'shapelibrary');
|
|
19
20
|
const targetFolder = path.join('shapelibraries', name);
|
|
20
|
-
console.log('Creating shape library in ' + targetFolder);
|
|
21
|
+
console.log((0, theme_1.success)('Creating shape library in ' + targetFolder));
|
|
21
22
|
(0, filesystemutil_1.copyFolderRecursiveSync)(source, targetFolder);
|
|
22
23
|
await (0, package_1.modifyManifest)((manifest) => {
|
|
23
24
|
if (!manifest['shapeLibraries']) {
|
|
@@ -32,7 +33,7 @@ async function createEmptyShapeLibrary(name) {
|
|
|
32
33
|
}
|
|
33
34
|
exports.createEmptyShapeLibrary = createEmptyShapeLibrary;
|
|
34
35
|
async function createImageShapeLibrary(name, imagePath, config) {
|
|
35
|
-
console.log('Creating image shape library in ' + path.join('shapelibraries', name));
|
|
36
|
+
console.log((0, theme_1.success)('Creating image shape library in ' + path.join('shapelibraries', name)));
|
|
36
37
|
if (!fsSync.lstatSync(imagePath).isDirectory()) {
|
|
37
38
|
console.error('The provided path `' + imagePath + '` is not a folder');
|
|
38
39
|
return;
|
|
@@ -58,7 +59,7 @@ async function createImageShapeLibrary(name, imagePath, config) {
|
|
|
58
59
|
console.log('dimen of ' + file + ': ' + dimen + ' - ' + JSON.stringify(dimen));
|
|
59
60
|
}
|
|
60
61
|
catch (e) {
|
|
61
|
-
console.log('No dimensions found for ' + file);
|
|
62
|
+
console.log((0, theme_1.error)('No dimensions found for ' + file));
|
|
62
63
|
}
|
|
63
64
|
}
|
|
64
65
|
const lockedArray = [];
|
|
@@ -249,7 +250,7 @@ async function buildShapeLibrary(name) {
|
|
|
249
250
|
};
|
|
250
251
|
await addToZip(`shapelibraries/${name}`);
|
|
251
252
|
const zipBytes = await zip.generateAsync({ type: 'uint8array' });
|
|
252
|
-
console.log(`Writing file ${name}.lcsz`);
|
|
253
|
+
console.log((0, theme_1.success)(`Writing file ${name}.lcsz`));
|
|
253
254
|
await fs.writeFile(`shapelibraries/${name}.lcsz`, zipBytes);
|
|
254
255
|
}
|
|
255
256
|
exports.buildShapeLibrary = buildShapeLibrary;
|
|
@@ -305,7 +306,7 @@ async function debugShapeLibraries(packagePath = '.', pickAnyPort = false) {
|
|
|
305
306
|
});
|
|
306
307
|
const listen = () => {
|
|
307
308
|
const server = app.listen(port, 'localhost', () => {
|
|
308
|
-
console.log('Listening at http://localhost:' + port + '/shapeLibraries');
|
|
309
|
+
console.log((0, theme_1.success)('Listening at http://localhost:' + port + '/shapeLibraries'));
|
|
309
310
|
//Watch for any shape library changes, and inform watchers that they need to refresh them.
|
|
310
311
|
const wss = new ws.Server({ server, path: '/shapeLibraries/changes' });
|
|
311
312
|
const sockets = [];
|
package/src/shellutil.js
CHANGED
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.execSyncLoggingOutputOnError = void 0;
|
|
4
4
|
const child_process = require("child_process");
|
|
5
|
+
const theme_1 = require("./theme");
|
|
5
6
|
function execSyncLoggingOutputOnError(cmd) {
|
|
6
7
|
try {
|
|
7
8
|
return child_process.execSync(cmd);
|
|
8
9
|
}
|
|
9
10
|
catch (e) {
|
|
10
|
-
console.log(String(e.stdout));
|
|
11
|
-
console.error(String(e.stderr));
|
|
11
|
+
console.log((0, theme_1.error)(String(e.stdout)));
|
|
12
|
+
console.error((0, theme_1.error)(String(e.stderr)));
|
|
12
13
|
throw e;
|
|
13
14
|
}
|
|
14
15
|
}
|
package/src/theme.d.ts
ADDED
package/src/theme.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.success = exports.warning = exports.error = void 0;
|
|
4
|
+
const chalk = require("chalk");
|
|
5
|
+
exports.error = chalk.bold.red;
|
|
6
|
+
exports.warning = chalk.hex('#FFA500');
|
|
7
|
+
exports.success = chalk.greenBright;
|
|
@@ -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": [
|
|
26
|
-
|
|
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
|
-
|
|
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,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,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,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"scripts": {
|
|
3
|
+
"create-editor-extension":"npx lucid-package create-editor-extension",
|
|
4
|
+
"create-shape-library":"npx lucid-package create-shape-library",
|
|
5
|
+
"create-data-connector":"npx lucid-package create-data-connector",
|
|
6
|
+
"create-image-shape-library":"npx lucid-package create-image-shape-library",
|
|
7
|
+
|
|
8
|
+
"test-editor-extension":"npx lucid-package test-editor-extension",
|
|
9
|
+
"test-shape-libraries":"npx lucid-package test-shape-libraries",
|
|
10
|
+
"test": "npx lucid-package test-editor-extension",
|
|
11
|
+
|
|
12
|
+
"start": "npx lucid-package test-editor-extension",
|
|
13
|
+
|
|
14
|
+
"bundle":"npx lucid-package bundle"
|
|
15
|
+
}
|
|
16
|
+
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|