Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exclude wrong version of angular plugins by checking entrypoint content #104

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 25 additions & 2 deletions base/src/plugin-manager/plugin-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,33 @@ export class PluginManager {
try {
var result = JSON.parse(this.responseText);
let allPlugins = PluginManager.parsePluginDefinitions(result);
const searchParams = new URLSearchParams(window.location.search);
const useV2Desktop = searchParams.has("use-v2-desktop") && (searchParams.get("use-v2-desktop") == 'true');
let validPlugins = allPlugins.filter((plugin) => {
if (plugin.type != 'application') {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be plugin?.type if parsePluginDefinitions(result) method returns an array that has undefined values

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

preferably with an error log in case plugin response text could not be parsed (may be done already upstream in PluginManager)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you dont have a plugin type, you'll fail startup.

return true;
} else {
const webContent = plugin.getWebContent();
if (!webContent) {
return true;
} else if ((webContent.framework != 'angular') && (webContent.framework != 'angular2')) {
return true;
} else {
//exclude apps incompatible with the given desktop environment, depending upon their entryPoint content.
if (useV2Desktop && (!webContent.entryPoint || webContent.entryPoint['2.0'])) {
return true;
} else if (!useV2Desktop && webContent.entryPoint && webContent.entryPoint['3.0']) {
return true;
} else {
return false;
}
}
}
});
if (!pluginType) {
resolve(allPlugins);
resolve(validPlugins);
} else {
const filtered = allPlugins.filter(plugin => plugin.getType() == pluginType)
const filtered = validPlugins.filter(plugin => plugin.getType() == pluginType)
resolve(filtered);
}
} catch (error) {
Expand Down
16 changes: 16 additions & 0 deletions base/src/plugin-manager/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,22 @@ class Plugin_2 extends Plugin_1 {
super(definition);
}

getWebEntrypoint():string|undefined {
let entryPoint = this.webContent?.entryPoint;
if (entryPoint) {
const searchParams = new URLSearchParams(window.location.search);
const useV2Desktop = searchParams.has("use-v2-desktop") && (searchParams.get("use-v2-desktop") == 'true');
if (useV2Desktop || !entryPoint['3.0']) {
return 'main.js';
} else {
return ''+entryPoint['3.0'];
}
} else if (this.webContent) {
return 'main.js';
}
return undefined;
}

}


Expand Down
4 changes: 4 additions & 0 deletions interface/src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,10 @@ declare namespace ZLUX {
getBasePlugin(): any;
}

interface PluginV2 extends Plugin {
getWebEntryPoint():string|undefined;
}

interface ContainerPluginDefinition {
getBasePlugin():Plugin;
}
Expand Down
Loading