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

multiple extensions, the console output affects each other #37

Open
xh4010 opened this issue Mar 24, 2021 · 1 comment
Open

multiple extensions, the console output affects each other #37

xh4010 opened this issue Mar 24, 2021 · 1 comment
Assignees
Labels
good first issue Good for newcomers

Comments

@xh4010
Copy link

xh4010 commented Mar 24, 2021

Hi

I am developing multiple extensions at the same time, but the console output will affect each other, all extensions will be received.

my solution is to add extensionId judgment, only output in the current extension.

JSXEvent:

function JSXEvent(payload, eventType) {
  try {
    var xLib = new ExternalObject("lib:PlugPlugExternalObject");
  } catch (e) {
    // JSXEvent(e, "console");
  }
  if (xLib) {
    var extensionId=arguments.callee.extensionId;
    var eventObj = new CSXSEvent();
    eventObj.type = eventType;
    eventObj.data = payload;
    eventObj.scope = "APPLICATION";
    if(!!extensionId)eventObj.extensionId = extensionId;
    eventObj.dispatch();
  }
  return;
}

Panel.vue

this.csInterface.addEventListener("console", (msg) => {
  if (msg.data && msg.data !== "undefined" && msg.extensionId===this.csInterface.getExtensionID()) console.log(msg.data);
});
this.csInterface.addEventListener("console_error", (msg) => {
  if (msg.data && msg.data !== "undefined" && msg.extensionId===this.csInterface.getExtensionID()) console.error(msg.data);
});
this.csInterface.addEventListener("console_debug", (msg) => {
  if (msg.data && msg.data !== "undefined" && msg.extensionId===this.csInterface.getExtensionID()) console.debug(msg.data);
});
this.csInterface.addEventListener("console_clear", () => {
  if (msg.extensionId===this.csInterface.getExtensionID()) console.clear();
});

Initialize extensionIId before console:

evalScript(`JSXEvent.extensionId=${new CSInterface().getExtensionID()};`)

Thank you again for your project and make my work more efficient;

@Inventsable
Copy link
Member

I'll merge and update this soon. Thanks!

@Inventsable Inventsable self-assigned this Apr 17, 2021
@Inventsable Inventsable added the good first issue Good for newcomers label Apr 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants