lucid-package 0.0.76 → 0.0.78
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/editorextension.js +7 -0
- package/src/package.js +26 -6
- package/src/packagemanifest.d.ts +2 -0
- package/src/packagemanifest.js +8 -0
package/package.json
CHANGED
package/src/editorextension.js
CHANGED
|
@@ -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')) &&
|
|
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([
|
|
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
|
-
|
|
102
|
-
|
|
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
|
package/src/packagemanifest.d.ts
CHANGED
|
@@ -22,6 +22,7 @@ export type PackageManifest = {
|
|
|
22
22
|
'name': string;
|
|
23
23
|
'title': string;
|
|
24
24
|
'tokenUrl': string;
|
|
25
|
+
'refreshTokenUrl'?: string;
|
|
25
26
|
'authorizationUrl': string;
|
|
26
27
|
'scopes': string[];
|
|
27
28
|
'domainWhitelist': string[];
|
|
@@ -45,6 +46,7 @@ export type PackageManifest = {
|
|
|
45
46
|
'description': string;
|
|
46
47
|
'type': SettingType;
|
|
47
48
|
}[];
|
|
49
|
+
'public'?: Record<string, string>;
|
|
48
50
|
};
|
|
49
51
|
/**
|
|
50
52
|
* @param manifestOverrideEnv The environment to override the manifest with
|
package/src/packagemanifest.js
CHANGED
|
@@ -124,6 +124,9 @@ function validateManifestOrThrow(manifest) {
|
|
|
124
124
|
if (!(0, lucid_extension_sdk_1.isString)(provider['tokenUrl'])) {
|
|
125
125
|
throw new Error('manifest.json: OAuth provider "tokenUrl" must be a string');
|
|
126
126
|
}
|
|
127
|
+
if (provider['refreshTokenUrl'] && !(0, lucid_extension_sdk_1.isString)(provider['refreshTokenUrl'])) {
|
|
128
|
+
throw new Error('manifest.json: OAuth provider "refreshTokenUrl" must be a string');
|
|
129
|
+
}
|
|
127
130
|
if (!(0, lucid_extension_sdk_1.isTypedArray)(lucid_extension_sdk_1.isString)(provider['scopes'])) {
|
|
128
131
|
throw new Error('manifest.json: OAuth provider "scopes" must be a string array');
|
|
129
132
|
}
|
|
@@ -184,6 +187,11 @@ function validateManifestOrThrow(manifest) {
|
|
|
184
187
|
}
|
|
185
188
|
}
|
|
186
189
|
}
|
|
190
|
+
if (manifest['public']) {
|
|
191
|
+
if (!(0, lucid_extension_sdk_1.objectOfValidator)(lucid_extension_sdk_1.isString)(manifest['public'])) {
|
|
192
|
+
throw new Error('manifest.json: "public" must be an object of strings');
|
|
193
|
+
}
|
|
194
|
+
}
|
|
187
195
|
}
|
|
188
196
|
function deepMixin(target, mixin) {
|
|
189
197
|
if ((0, lucid_extension_sdk_1.isArray)(target) && (0, lucid_extension_sdk_1.isArray)(mixin)) {
|