lucid-package 0.0.75 → 0.0.77

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.75",
3
+ "version": "0.0.77",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -164,6 +164,13 @@ async function debugEditorExtension(extensionNames, quiet = false, pickAnyPort =
164
164
  res.send(req.query['source']);
165
165
  });
166
166
  // Static resources in the "public" directory of the package
167
+ const manifest = await (0, packagemanifest_1.readManifest)('local');
168
+ if (manifest['public']) {
169
+ for (const url in manifest['public']) {
170
+ const source = manifest['public'][url];
171
+ app.use('/resources/' + url, express.static(source));
172
+ }
173
+ }
167
174
  app.use('/resources', express.static('public'));
168
175
  const listen = () => {
169
176
  app.listen(port, 'localhost', () => {
package/src/package.js CHANGED
@@ -17,10 +17,20 @@ async function createEmptyPackage(root) {
17
17
  }
18
18
  exports.createEmptyPackage = createEmptyPackage;
19
19
  function currentlyInPackage() {
20
- return (fsOld.existsSync('editorextensions') && fsOld.existsSync('shapelibraries') && fsOld.existsSync('manifest.json'));
20
+ return ((fsOld.existsSync('editorextensions') || fsOld.existsSync('shapelibraries')) &&
21
+ fsOld.existsSync('manifest.json'));
21
22
  }
22
23
  exports.currentlyInPackage = currentlyInPackage;
23
- const allScopes = new Set(['DOWNLOAD', 'NETWORK', 'READ', 'SHOW_MODAL', 'CUSTOM_UI', 'WRITE', 'USER_INFO', 'OAUTH_TOKEN']);
24
+ const allScopes = new Set([
25
+ 'DOWNLOAD',
26
+ 'NETWORK',
27
+ 'READ',
28
+ 'SHOW_MODAL',
29
+ 'CUSTOM_UI',
30
+ 'WRITE',
31
+ 'USER_INFO',
32
+ 'OAUTH_TOKEN',
33
+ ]);
24
34
  const uuidRegex = /^[a-f\d]{8}-[a-f\d]{4}-[a-f\d]{4}-[a-f\d]{4}-[a-f\d]{12}$/i;
25
35
  async function modifyManifest(callback, manifestOverrideEnv) {
26
36
  const manifest = await (0, packagemanifest_1.readManifest)(manifestOverrideEnv);
@@ -90,7 +100,7 @@ async function writePackage(quiet = false, manifestOverrideEnv) {
90
100
  zip.file(library['lcszPath'], await fs.readFile(library['lcszPath']));
91
101
  }
92
102
  //Add any static resources
93
- const checkDirForResources = async (directory) => {
103
+ const checkDirForResources = async (directory, zipDirectory) => {
94
104
  if (!fsOld.existsSync(directory)) {
95
105
  return;
96
106
  }
@@ -98,15 +108,25 @@ async function writePackage(quiet = false, manifestOverrideEnv) {
98
108
  const filePath = path.join(directory, fileName);
99
109
  const stat = await fs.stat(filePath);
100
110
  if (stat.isFile()) {
101
- console.log('Adding resource file: ', filePath);
102
- zip.file(filePath, await fs.readFile(filePath));
111
+ let zipPath = filePath;
112
+ if (zipDirectory != null) {
113
+ zipPath = zipDirectory + filePath.substring(directory.length);
114
+ }
115
+ console.log('Adding resource file: ' + filePath + ' -> ' + zipPath);
116
+ zip.file(zipPath, await fs.readFile(filePath));
103
117
  }
104
118
  else if (stat.isDirectory()) {
105
- await checkDirForResources(filePath);
119
+ await checkDirForResources(filePath, zipDirectory ? path.join(zipDirectory, fileName) : undefined);
106
120
  }
107
121
  }
108
122
  };
109
123
  await checkDirForResources('public');
124
+ if (manifest['public']) {
125
+ for (const url in manifest['public']) {
126
+ const source = manifest['public'][url];
127
+ await checkDirForResources(source, path.join('public', url));
128
+ }
129
+ }
110
130
  //Add the manifest itself
111
131
  zip.file('manifest.json', JSON.stringify(manifest, undefined, 2));
112
132
  //Write out the zip file
@@ -45,6 +45,7 @@ export type PackageManifest = {
45
45
  'description': string;
46
46
  'type': SettingType;
47
47
  }[];
48
+ 'public'?: Record<string, string>;
48
49
  };
49
50
  /**
50
51
  * @param manifestOverrideEnv The environment to override the manifest with
@@ -184,6 +184,11 @@ function validateManifestOrThrow(manifest) {
184
184
  }
185
185
  }
186
186
  }
187
+ if (manifest['public']) {
188
+ if (!(0, lucid_extension_sdk_1.objectOfValidator)(lucid_extension_sdk_1.isString)(manifest['public'])) {
189
+ throw new Error('manifest.json: "public" must be an object of strings');
190
+ }
191
+ }
187
192
  }
188
193
  function deepMixin(target, mixin) {
189
194
  if ((0, lucid_extension_sdk_1.isArray)(target) && (0, lucid_extension_sdk_1.isArray)(mixin)) {