lucid-package 0.0.111 → 0.0.113

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lucid-package",
3
- "version": "0.0.111",
3
+ "version": "0.0.113",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -5,6 +5,6 @@ export interface ImageShapeConfig {
5
5
  }
6
6
  export declare function createEmptyShapeLibrary(name: string): Promise<void>;
7
7
  export declare function createImageShapeLibrary(name: string, imagePath: string, config: ImageShapeConfig): Promise<void>;
8
- export declare function getShapeListJson(name: string, packagePath: string, port?: number): Promise<string>;
8
+ export declare function getShapeListJson(nameInPackageManifest: string, packagePath: string, port?: number): Promise<string>;
9
9
  export declare function buildShapeLibrary(name: string, quiet: boolean): Promise<void>;
10
10
  export declare function debugShapeLibraries(packagePath?: string, pickAnyPort?: boolean): Promise<void>;
@@ -136,14 +136,14 @@ const defaultNameMap = new Map([
136
136
  ]);
137
137
  //Produce JSON equivalent to the document service's
138
138
  // /shapeLibraries/:name/shapes endpoint
139
- async function getShapeListJson(name, packagePath, port = 9901) {
139
+ async function getShapeListJson(nameInPackageManifest, packagePath, port = 9901) {
140
140
  const packageManifest = await (0, packagemanifest_1.readManifest)('local', packagePath);
141
- const manifestPath = path.join(packagePath, 'shapelibraries', name, 'library.manifest');
141
+ const manifestPath = path.join(packagePath, 'shapelibraries', nameInPackageManifest, 'library.manifest');
142
142
  const rawManifest = await fs.readFile(manifestPath);
143
143
  const manifest = hjson.parse(rawManifest.toString());
144
144
  const usedNames = new Set(manifest['shapes'].map((shape) => shape['key']).filter((key) => key !== undefined));
145
145
  return JSON.stringify(await Promise.all(manifest['shapes'].map(async (shapeManifest, index) => {
146
- const shapeDataPath = path.join(packagePath, 'shapelibraries', name, 'shapes', `${shapeManifest['shape']}.shape`);
146
+ const shapeDataPath = path.join(packagePath, 'shapelibraries', nameInPackageManifest, 'shapes', `${shapeManifest['shape']}.shape`);
147
147
  const rawShapeData = await fs.readFile(shapeDataPath);
148
148
  const shapeData = hjson.parse(rawShapeData.toString());
149
149
  let shapeName = shapeManifest['key'];
@@ -176,7 +176,7 @@ async function getShapeListJson(name, packagePath, port = 9901) {
176
176
  'sourcePackage': {
177
177
  'packageId': packageManifest['id'] ?? '__local__',
178
178
  'version': packageManifest['version'],
179
- 'library': name,
179
+ 'library': nameInPackageManifest,
180
180
  'shape': shapeManifest['shape'],
181
181
  'name': shapeName,
182
182
  },
@@ -203,7 +203,7 @@ async function getShapeListJson(name, packagePath, port = 9901) {
203
203
  else if (imageMap[key]['type'] == 'file') {
204
204
  finalImageMap[key] =
205
205
  `http://localhost:${port}/shapeLibraries/` +
206
- encodeURIComponent(name) +
206
+ encodeURIComponent(nameInPackageManifest) +
207
207
  '/images/' +
208
208
  encodeURIComponent(imageMap[key]['path']);
209
209
  }
@@ -226,8 +226,8 @@ async function getShapeListJson(name, packagePath, port = 9901) {
226
226
  'name': shapeManifest['name'],
227
227
  'order': index,
228
228
  'properties': JSON.stringify(properties),
229
- 'shapeLibrary': `http://localhost:${port}/shapeLibraries/` + encodeURIComponent(name),
230
- 'uri': `http://localhost:${port}/shapeLibraries/${encodeURIComponent(name)}/shapes/${encodeURIComponent(shapeName)}`,
229
+ 'shapeLibrary': `http://localhost:${port}/shapeLibraries/` + encodeURIComponent(nameInPackageManifest),
230
+ 'uri': `http://localhost:${port}/shapeLibraries/${encodeURIComponent(nameInPackageManifest)}/shapes/${encodeURIComponent(shapeName)}`,
231
231
  };
232
232
  })));
233
233
  }
@@ -267,32 +267,39 @@ async function debugShapeLibraries(packagePath = '.', pickAnyPort = false) {
267
267
  //shape library, the toolbox doesn't update.
268
268
  let shapeLibraryVersion = Date.now();
269
269
  app.get('/shapeLibraries', async (req, res) => {
270
- const manifest = await (0, packagemanifest_1.readManifest)('local', packagePath);
271
- const libraries = manifest['shapeLibraries'] ?? [];
272
- const output = await Promise.all(libraries.map(async (libraryManifest) => {
273
- const libraryDefinitionContent = await fs.readFile(path.join(packagePath, 'shapelibraries', libraryManifest['name'], 'library.manifest'));
270
+ const packageManifest = await (0, packagemanifest_1.readManifest)('local', packagePath);
271
+ const librariesInPackageManifest = packageManifest['shapeLibraries'] ?? [];
272
+ const output = await Promise.all(librariesInPackageManifest.map(async (libraryInPackageManifest) => {
273
+ // Unique for each shape library within a package
274
+ const libraryNameInPackageManifest = libraryInPackageManifest['name'];
275
+ const libraryDefinitionContent = await fs.readFile(path.join(packagePath, 'shapelibraries', libraryNameInPackageManifest, 'library.manifest'));
274
276
  const libraryDefinition = JSON.parse(libraryDefinitionContent.toString());
275
277
  return {
276
278
  'uri': `http://localhost:${port}/shapeLibraries/` +
277
- encodeURIComponent(libraryManifest['name']) +
279
+ encodeURIComponent(libraryNameInPackageManifest) +
278
280
  '?version=' +
279
281
  shapeLibraryVersion,
280
282
  'user': '',
283
+ 'userId': 0,
284
+ // 'id' field must be unique across an entire package (required by the Lucid frontend).
285
+ // The only field that satisfies this requirement is this one.
286
+ // (On the other hand, the 'name' in the `library.manfiest` file is not unique across the package.)
287
+ 'id': libraryNameInPackageManifest,
281
288
  'created': new Date().toISOString(),
282
289
  'name': libraryDefinition['name'],
283
290
  'size': 0,
284
291
  'accountId': 0,
285
292
  'shapes': `http://localhost:${port}/shapeLibraries/` +
286
- encodeURIComponent(libraryManifest['name']) +
293
+ encodeURIComponent(libraryNameInPackageManifest) +
287
294
  '/shapes',
288
295
  'encryption': '',
289
296
  };
290
297
  }));
291
298
  res.send(JSON.stringify(output));
292
299
  });
293
- app.get('/shapeLibraries/:libraryName/shapes', async (req, res) => {
300
+ app.get('/shapeLibraries/:libraryNameInPackageManifest/shapes', async (req, res) => {
294
301
  //Find all the shapes in the given shape library, and produce JSON for the client
295
- res.send(await getShapeListJson(req.params.libraryName, packagePath, port));
302
+ res.send(await getShapeListJson(req.params.libraryNameInPackageManifest, packagePath, port));
296
303
  });
297
304
  app.get('/shapeLibraries/:libraryName/images/:image', async (req, res) => {
298
305
  const oldcwd = process.cwd();
@@ -5,13 +5,13 @@ const client = new EditorClient();
5
5
  const menu = new Menu(client);
6
6
  const viewport = new Viewport(client);
7
7
 
8
- client.registerAction('test', () => {
8
+ client.registerAction('show-import-modal', () => {
9
9
  const modal = new ImportModal(client);
10
10
  modal.show();
11
11
  });
12
12
 
13
13
  menu.addMenuItem({
14
- label: 'Test thing 2',
15
- action: 'test',
14
+ label: 'Show import modal',
15
+ action: 'show-import-modal',
16
16
  menuType: MenuType.Main,
17
17
  });