lucid-package 0.0.67 → 0.0.69
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 +1 -1
- package/src/cors.js +1 -2
- package/src/editorextension.js +18 -29
- package/src/index.js +2 -3
- package/src/package.js +1 -1
- package/src/shapelibrary.js +5 -7
package/package.json
CHANGED
package/src/cors.js
CHANGED
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.corsAllowLucid = void 0;
|
|
4
4
|
function corsAllowLucid(req, res, next) {
|
|
5
|
-
|
|
6
|
-
if ((_b = (_a = req.headers) === null || _a === void 0 ? void 0 : _a.origin) === null || _b === void 0 ? void 0 : _b.match(/.lucid(dev|staging|preprod|).app$/)) {
|
|
5
|
+
if (req.headers?.origin?.match(/.lucid(dev|staging|preprod|).app$/)) {
|
|
7
6
|
res.header('Access-Control-Allow-Origin', req.headers.origin);
|
|
8
7
|
res.header('Vary', 'Origin');
|
|
9
8
|
res.header('Access-Control-Allow-Methods', 'GET, OPTIONS');
|
package/src/editorextension.js
CHANGED
|
@@ -101,8 +101,7 @@ async function debugEditorExtension(extensionNames, quiet = false, pickAnyPort =
|
|
|
101
101
|
const app = express();
|
|
102
102
|
app.use(cors_1.corsAllowLucid);
|
|
103
103
|
app.get(['/extension.js', '/editorextension/:name/extension.js'], async (req, res) => {
|
|
104
|
-
|
|
105
|
-
const name = (_a = req.params['name']) !== null && _a !== void 0 ? _a : extensionNames[0];
|
|
104
|
+
const name = req.params['name'] ?? extensionNames[0];
|
|
106
105
|
const directory = await getExtensionCodeDirectoryName(name);
|
|
107
106
|
//Give it several seconds for the extension to finish generating before failing.
|
|
108
107
|
const before = Date.now();
|
|
@@ -112,19 +111,16 @@ async function debugEditorExtension(extensionNames, quiet = false, pickAnyPort =
|
|
|
112
111
|
res.send((await fs.readFile(`editorextensions/${directory}/bin/extension.js`)).toString());
|
|
113
112
|
});
|
|
114
113
|
app.get(['/scopes', '/editorextension/:name/scopes'], async (req, res) => {
|
|
115
|
-
|
|
116
|
-
const name = (_a = req.params['name']) !== null && _a !== void 0 ? _a : extensionNames[0];
|
|
114
|
+
const name = req.params['name'] ?? extensionNames[0];
|
|
117
115
|
const manifest = await (0, packagemanifest_1.readManifest)('local');
|
|
118
|
-
res.send(JSON.stringify(
|
|
116
|
+
res.send(JSON.stringify(manifest['extensions']?.find((extension) => extension['name'] === name)?.scopes));
|
|
119
117
|
});
|
|
120
118
|
app.get('/packageId', async (req, res) => {
|
|
121
|
-
var _a;
|
|
122
119
|
const manifest = await (0, packagemanifest_1.readManifest)('local');
|
|
123
|
-
res.send(
|
|
120
|
+
res.send(manifest['id'] ?? '__local__');
|
|
124
121
|
});
|
|
125
122
|
app.get(['/editorextension', '/editorextension/:name'], async (req, res) => {
|
|
126
|
-
|
|
127
|
-
const name = (_a = req.params['name']) !== null && _a !== void 0 ? _a : extensionNames[0];
|
|
123
|
+
const name = req.params['name'] ?? extensionNames[0];
|
|
128
124
|
const rawExtension = await getRawEditorExtension(name, port);
|
|
129
125
|
res.send(rawExtension);
|
|
130
126
|
});
|
|
@@ -132,9 +128,8 @@ async function debugEditorExtension(extensionNames, quiet = false, pickAnyPort =
|
|
|
132
128
|
res.send(await Promise.all(extensionNames.map((name) => getRawEditorExtension(name, port))));
|
|
133
129
|
});
|
|
134
130
|
app.get('/settings', async (req, res) => {
|
|
135
|
-
var _a;
|
|
136
131
|
const manifest = await (0, packagemanifest_1.readManifest)('local');
|
|
137
|
-
const settings =
|
|
132
|
+
const settings = manifest.settings ?? [];
|
|
138
133
|
res.send(JSON.stringify(settings.map((setting, index) => {
|
|
139
134
|
return {
|
|
140
135
|
'Id': '__local__' + index,
|
|
@@ -148,11 +143,10 @@ async function debugEditorExtension(extensionNames, quiet = false, pickAnyPort =
|
|
|
148
143
|
})));
|
|
149
144
|
});
|
|
150
145
|
app.get('/dataConnector/:name', async (req, res) => {
|
|
151
|
-
var _a;
|
|
152
146
|
const name = req.params['name'];
|
|
153
147
|
if (name) {
|
|
154
148
|
const manifest = await (0, packagemanifest_1.readManifest)('local');
|
|
155
|
-
const connector =
|
|
149
|
+
const connector = manifest['dataConnectors']?.find((one) => one.name === name);
|
|
156
150
|
if (connector) {
|
|
157
151
|
res.send(JSON.stringify(connector));
|
|
158
152
|
}
|
|
@@ -165,14 +159,13 @@ async function debugEditorExtension(extensionNames, quiet = false, pickAnyPort =
|
|
|
165
159
|
}
|
|
166
160
|
});
|
|
167
161
|
app.get('/oauthCredentials/:name', async (req, res) => {
|
|
168
|
-
var _a;
|
|
169
162
|
const name = req.params['name'];
|
|
170
163
|
if (name) {
|
|
171
164
|
const manifest = await (0, packagemanifest_1.readManifest)('local');
|
|
172
|
-
const provider =
|
|
165
|
+
const provider = manifest['oauthProviders']?.find((one) => one.name === name);
|
|
173
166
|
if (provider && oldFs.existsSync(`${name}.credentials.local`)) {
|
|
174
167
|
const credentials = JSON.parse((await fs.readFile(`${name}.credentials.local`)).toString());
|
|
175
|
-
res.send(JSON.stringify(
|
|
168
|
+
res.send(JSON.stringify({ ...provider, ...credentials }));
|
|
176
169
|
}
|
|
177
170
|
else {
|
|
178
171
|
res.sendStatus(404);
|
|
@@ -208,9 +201,8 @@ async function debugEditorExtension(extensionNames, quiet = false, pickAnyPort =
|
|
|
208
201
|
}
|
|
209
202
|
exports.debugEditorExtension = debugEditorExtension;
|
|
210
203
|
async function getExtensionManifest(name) {
|
|
211
|
-
var _a;
|
|
212
204
|
const manifest = await (0, packagemanifest_1.readManifest)('local');
|
|
213
|
-
return { manifest, extensionManifest:
|
|
205
|
+
return { manifest, extensionManifest: manifest['extensions']?.find((one) => one['name'] === name) };
|
|
214
206
|
}
|
|
215
207
|
/**
|
|
216
208
|
* We allow the creation of editor extensions that use the same code as a different editor extension in the same
|
|
@@ -219,40 +211,37 @@ async function getExtensionManifest(name) {
|
|
|
219
211
|
* the same codePath for the chart extension as the spark extension.
|
|
220
212
|
*/
|
|
221
213
|
async function getExtensionCodeDirectoryName(name) {
|
|
222
|
-
var _a;
|
|
223
214
|
const extensionManifest = (await getExtensionManifest(name)).extensionManifest;
|
|
224
|
-
const codePath = extensionManifest
|
|
225
|
-
return codePath ? (
|
|
215
|
+
const codePath = extensionManifest?.['codePath'];
|
|
216
|
+
return codePath ? (await getExtensionCodeDirectoryNameFromCodePath(codePath)) ?? name : name;
|
|
226
217
|
}
|
|
227
218
|
/**
|
|
228
219
|
* Our codePath has the form '/editorextensions/{extensionName}/bin/extension.js'. This function returns the
|
|
229
220
|
* extensionName.
|
|
230
221
|
*/
|
|
231
222
|
async function getExtensionCodeDirectoryNameFromCodePath(codePath) {
|
|
232
|
-
|
|
233
|
-
const parts = (_a = codePath.split('/')) !== null && _a !== void 0 ? _a : [];
|
|
223
|
+
const parts = codePath.split('/') ?? [];
|
|
234
224
|
if (parts[0] === 'editorextensions' && parts[1]) {
|
|
235
225
|
return `${parts[1]}`;
|
|
236
226
|
}
|
|
237
227
|
return undefined;
|
|
238
228
|
}
|
|
239
229
|
async function getRawEditorExtension(name, port) {
|
|
240
|
-
var _a, _b, _c;
|
|
241
230
|
const { manifest, extensionManifest } = await getExtensionManifest(name);
|
|
242
|
-
const codePath = extensionManifest
|
|
243
|
-
const directory = codePath ? (
|
|
231
|
+
const codePath = extensionManifest?.['codePath'];
|
|
232
|
+
const directory = codePath ? (await getExtensionCodeDirectoryNameFromCodePath(codePath)) ?? name : name;
|
|
244
233
|
const products = extensionManifest
|
|
245
234
|
? getExtensionProducts(extensionManifest['product'], extensionManifest['products'])
|
|
246
235
|
: [supportedproduct_1.SupportedProduct.Chart];
|
|
247
236
|
return {
|
|
248
237
|
id: '__local__',
|
|
249
|
-
packageId:
|
|
238
|
+
packageId: manifest['id'] ?? '__local__',
|
|
250
239
|
packageVersionId: '__local__',
|
|
251
240
|
version: manifest['version'],
|
|
252
241
|
name: name,
|
|
253
|
-
title:
|
|
242
|
+
title: extensionManifest?.['title'] ?? 'Local dev extension',
|
|
254
243
|
products: products,
|
|
255
|
-
scopes: extensionManifest
|
|
244
|
+
scopes: extensionManifest?.['scopes'],
|
|
256
245
|
codeUrl: `http://localhost:${port}/editorextension/${directory}/extension.js`,
|
|
257
246
|
};
|
|
258
247
|
}
|
package/src/index.js
CHANGED
|
@@ -6,7 +6,6 @@ const package_1 = require("./package");
|
|
|
6
6
|
const shapelibrary_1 = require("./shapelibrary");
|
|
7
7
|
class LucidSuiteExtensionCLI {
|
|
8
8
|
async run(args) {
|
|
9
|
-
var _a, _b;
|
|
10
9
|
const parser = new argparse_1.ArgumentParser({
|
|
11
10
|
description: 'Create and manage Lucid extension packages',
|
|
12
11
|
});
|
|
@@ -167,8 +166,8 @@ class LucidSuiteExtensionCLI {
|
|
|
167
166
|
break;
|
|
168
167
|
case 'create-image-shape-library':
|
|
169
168
|
if ((0, package_1.currentlyInPackage)()) {
|
|
170
|
-
const width =
|
|
171
|
-
const height =
|
|
169
|
+
const width = Number(parsed['width']) ?? undefined;
|
|
170
|
+
const height = Number(parsed['height']) ?? undefined;
|
|
172
171
|
const config = {
|
|
173
172
|
width: width,
|
|
174
173
|
height: height,
|
package/src/package.js
CHANGED
|
@@ -19,7 +19,7 @@ function currentlyInPackage() {
|
|
|
19
19
|
return (fsOld.existsSync('editorextensions') && fsOld.existsSync('shapelibraries') && fsOld.existsSync('manifest.json'));
|
|
20
20
|
}
|
|
21
21
|
exports.currentlyInPackage = currentlyInPackage;
|
|
22
|
-
const allScopes = new Set(['DOWNLOAD', 'NETWORK', 'READ', 'SHOW_MODAL', 'CUSTOM_UI', 'WRITE']);
|
|
22
|
+
const allScopes = new Set(['DOWNLOAD', 'NETWORK', 'READ', 'SHOW_MODAL', 'CUSTOM_UI', 'WRITE', 'USER_INFO']);
|
|
23
23
|
const uuidRegex = /^[a-f\d]{8}-[a-f\d]{4}-[a-f\d]{4}-[a-f\d]{4}-[a-f\d]{12}$/i;
|
|
24
24
|
async function modifyManifest(callback, manifestOverrideEnv) {
|
|
25
25
|
const manifest = await (0, packagemanifest_1.readManifest)(manifestOverrideEnv);
|
package/src/shapelibrary.js
CHANGED
|
@@ -139,7 +139,6 @@ async function getShapeListJson(name, packagePath, port = 9901) {
|
|
|
139
139
|
const manifest = hjson.parse(rawManifest.toString());
|
|
140
140
|
const usedNames = new Set(manifest['shapes'].map((shape) => shape['key']).filter((key) => key !== undefined));
|
|
141
141
|
return JSON.stringify(await Promise.all(manifest['shapes'].map(async (shapeManifest, index) => {
|
|
142
|
-
var _a, _b, _c, _d;
|
|
143
142
|
const rawShapeData = await fs.readFile(packagePath + `/shapelibraries/${name}/shapes/${shapeManifest['shape']}.shape`);
|
|
144
143
|
const shapeData = hjson.parse(rawShapeData.toString());
|
|
145
144
|
let shapeName = shapeManifest['key'];
|
|
@@ -170,7 +169,7 @@ async function getShapeListJson(name, packagePath, port = 9901) {
|
|
|
170
169
|
'i18n': {},
|
|
171
170
|
'locked': shapeData['locked'],
|
|
172
171
|
'sourcePackage': {
|
|
173
|
-
'packageId':
|
|
172
|
+
'packageId': packageManifest['id'] ?? '__local__',
|
|
174
173
|
'version': packageManifest['version'],
|
|
175
174
|
'library': name,
|
|
176
175
|
'shape': shapeManifest['shape'],
|
|
@@ -208,13 +207,13 @@ async function getShapeListJson(name, packagePath, port = 9901) {
|
|
|
208
207
|
}
|
|
209
208
|
for (var key in shapeManifest['defaults']) {
|
|
210
209
|
if (key !== 'width' && key !== 'height') {
|
|
211
|
-
const outName =
|
|
210
|
+
const outName = defaultNameMap.get(key) ?? key;
|
|
212
211
|
properties[outName] = shapeManifest['defaults'][key];
|
|
213
212
|
}
|
|
214
213
|
}
|
|
215
|
-
if (
|
|
214
|
+
if (shapeData['locked']?.includes('aspectRatio') && !properties['AspectRatio']) {
|
|
216
215
|
properties['AspectRatio'] =
|
|
217
|
-
|
|
216
|
+
shapeManifest['defaults']['width'] / shapeManifest['defaults']['height'] ?? 1;
|
|
218
217
|
}
|
|
219
218
|
return {
|
|
220
219
|
'class': 'CustomBlock',
|
|
@@ -263,9 +262,8 @@ async function debugShapeLibraries(packagePath = '.', pickAnyPort = false) {
|
|
|
263
262
|
//shape library, the toolbox doesn't update.
|
|
264
263
|
let shapeLibraryVersion = Date.now();
|
|
265
264
|
app.get('/shapeLibraries', async (req, res) => {
|
|
266
|
-
var _a;
|
|
267
265
|
const manifest = await (0, packagemanifest_1.readManifest)('local', packagePath + '/');
|
|
268
|
-
const libraries =
|
|
266
|
+
const libraries = manifest['shapeLibraries'] ?? [];
|
|
269
267
|
const output = await Promise.all(libraries.map(async (libraryManifest) => {
|
|
270
268
|
const libraryDefinitionContent = await fs.readFile(packagePath + '/shapelibraries/' + libraryManifest['name'] + '/library.manifest');
|
|
271
269
|
const libraryDefinition = JSON.parse(libraryDefinitionContent.toString());
|