lucid-package 0.0.71 → 0.0.72

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.71",
3
+ "version": "0.0.72",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -154,6 +154,16 @@ async function debugEditorExtension(extensionNames, quiet = false, pickAnyPort =
154
154
  const manifest = await (0, packagemanifest_1.readManifest)('local');
155
155
  res.send(JSON.stringify(manifest));
156
156
  });
157
+ // iframes (modals and panels) loaded in dev mode from a string (legacy style) will redirect here to get the
158
+ // iframe bootstrap code, so that any requests for static assets from localhost won't fail due to mixed
159
+ // HTTPS and HTTP. But to avoid duplicating the modal-frame.html source here, we just send it in the query
160
+ // string as part of the redirect.
161
+ app.get('/resources/modal-frame.html', async (req, res) => {
162
+ res.set({ 'Content-Type': 'text/html' });
163
+ res.send(req.query['source']);
164
+ });
165
+ // Static resources in the "public" directory of the package
166
+ app.use('/resources', express.static('public'));
157
167
  const listen = () => {
158
168
  app.listen(port, 'localhost', () => {
159
169
  console.log('Listening at http://localhost:' + port + '/extension.js');
package/src/package.js CHANGED
@@ -4,6 +4,7 @@ exports.writePackage = exports.updateAllExtensionSDK = exports.modifyManifest =
4
4
  const fsOld = require("fs");
5
5
  const fs = require("fs/promises");
6
6
  const JSZip = require("jszip");
7
+ const path = require("path");
7
8
  const lucid_extension_sdk_1 = require("lucid-extension-sdk");
8
9
  const editorextension_1 = require("./editorextension");
9
10
  const filesystemutil_1 = require("./filesystemutil");
@@ -88,10 +89,32 @@ async function writePackage(quiet = false, manifestOverrideEnv) {
88
89
  }
89
90
  zip.file(library['lcszPath'], await fs.readFile(library['lcszPath']));
90
91
  }
92
+ //Add any static resources
93
+ const checkDirForResources = async (directory) => {
94
+ if (!fsOld.existsSync(directory)) {
95
+ return;
96
+ }
97
+ for (const fileName of await fs.readdir(directory)) {
98
+ const filePath = path.join(directory, fileName);
99
+ const stat = await fs.stat(filePath);
100
+ if (stat.isFile()) {
101
+ console.log('Adding resource file: ', filePath);
102
+ zip.file(filePath, await fs.readFile(filePath));
103
+ }
104
+ else if (stat.isDirectory()) {
105
+ await checkDirForResources(filePath);
106
+ }
107
+ }
108
+ };
109
+ await checkDirForResources('public');
91
110
  //Add the manifest itself
92
111
  zip.file('manifest.json', JSON.stringify(manifest, undefined, 2));
93
112
  //Write out the zip file
94
- const zipBytes = await zip.generateAsync({ type: 'uint8array' });
113
+ const zipBytes = await zip.generateAsync({
114
+ type: 'uint8array',
115
+ compression: 'DEFLATE',
116
+ compressionOptions: { level: 9 },
117
+ });
95
118
  console.log('Writing file package.zip');
96
119
  const fileName = `package${manifestOverrideEnv ? `-${manifestOverrideEnv}` : ''}.zip`;
97
120
  await fs.writeFile(fileName, zipBytes);