From decf13f3027be5127a2cd2f1132226c2b7cf5530 Mon Sep 17 00:00:00 2001 From: Xiao Gui <xgui3783@gmail.com> Date: Wed, 7 Jun 2023 15:04:03 +0200 Subject: [PATCH] fix: filter by message namespace maint: update CI version maint: remove deprecated use of cmpfactory --- .github/workflows/ci.yml | 8 ++++---- .github/workflows/docker_img.yml | 4 ++-- .github/workflows/e2e.yml | 2 +- .github/workflows/manual_e2e.yml | 4 ++-- .github/workflows/release.yml | 2 +- .github/workflows/repo_sync_ebrains.yml | 2 +- docs/releases/v2.11.2.md | 1 + src/messaging/service.ts | 13 +++++++++++-- src/widget/service.ts | 10 +++------- 9 files changed, 26 insertions(+), 20 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e092ca43f..25a2cd761 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,7 +14,7 @@ jobs: # runs-on: ubuntu-latest # steps: - # - uses: actions/checkout@v2 + # - uses: actions/checkout@v3 # - uses: actions/setup-node@v1 # with: # node-version: '16.x' @@ -25,7 +25,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Use Node.js 16.x for lint uses: actions/setup-node@v1 with: @@ -41,7 +41,7 @@ jobs: NODE_ENV: test steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Use Node.js 16.x uses: actions/setup-node@v1 with: @@ -63,7 +63,7 @@ jobs: NODE_ENV: test steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Use Node.js 16.x uses: actions/setup-node@v1 with: diff --git a/.github/workflows/docker_img.yml b/.github/workflows/docker_img.yml index 5dd8db789..eb5368f03 100644 --- a/.github/workflows/docker_img.yml +++ b/.github/workflows/docker_img.yml @@ -30,7 +30,7 @@ jobs: build: [ 'local', 'prod' ] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: 'Set matomo env var' # if matrix.build is local, only run if master or dev if: ${{ !(matrix.build == 'local' && github.ref != 'refs/heads/master' && github.ref != 'refs/heads/dev') }} @@ -120,7 +120,7 @@ jobs: needs: build-docker-img steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Set env var run: | echo "Using github.ref: $GITHUB_REF" diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 9203ddec1..ec46c942a 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -59,7 +59,7 @@ jobs: failure-state: ${{ steps.failure-state-step.outputs.failure-state }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: ref: ${{ github.event.ref }} diff --git a/.github/workflows/manual_e2e.yml b/.github/workflows/manual_e2e.yml index 9829d7053..a55bd1e16 100644 --- a/.github/workflows/manual_e2e.yml +++ b/.github/workflows/manual_e2e.yml @@ -9,7 +9,7 @@ jobs: hide_previous_if_exists: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: ref: 'master' - uses: actions/github-script@v5 @@ -23,7 +23,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: 'Add checklist comment' uses: actions/github-script@v5 with: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 42fc00b29..211fd6d9e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -24,7 +24,7 @@ jobs: if: success() runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Create Release id: create_release uses: actions/create-release@v1 diff --git a/.github/workflows/repo_sync_ebrains.yml b/.github/workflows/repo_sync_ebrains.yml index 548b768b0..e29122fa0 100644 --- a/.github/workflows/repo_sync_ebrains.yml +++ b/.github/workflows/repo_sync_ebrains.yml @@ -9,7 +9,7 @@ jobs: sync: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: wei/git-sync@v3 with: source_repo: ${GITHUB_REPOSITORY} diff --git a/docs/releases/v2.11.2.md b/docs/releases/v2.11.2.md index 33f38116d..7ad012150 100644 --- a/docs/releases/v2.11.2.md +++ b/docs/releases/v2.11.2.md @@ -13,3 +13,4 @@ - Pass messages to plugin API when not handled - Fix lint +- Update CI \ No newline at end of file diff --git a/src/messaging/service.ts b/src/messaging/service.ts index 3e9ecc618..48dc941bb 100644 --- a/src/messaging/service.ts +++ b/src/messaging/service.ts @@ -9,10 +9,15 @@ import { TYPE as NMV_TYPE, processJsonLd as nmvProcess } from './nmvSwc/index' import { TYPE as NATIVE_TYPE, processJsonLd as nativeProcess } from './native' import { BoothVisitor, JRPCRequest, ListenerChannel } from "src/api/jsonrpc" import { ApiService } from "src/api"; -import { ApiBoothEvents } from "src/api/service"; +import { ApiBoothEvents, namespace as apiNameSpace } from "src/api/service"; export const IAV_POSTMESSAGE_NAMESPACE = `ebrains:iav:` +const RECOGNISED_NAMESPACES = [ + IAV_POSTMESSAGE_NAMESPACE, + apiNameSpace +] + export const MANAGED_METHODS = [ 'openminds:nmv:loadSwc', 'openminds:nmv:unloadSwc' @@ -69,7 +74,11 @@ export class MessagingService { window.addEventListener('message', async ({ data, origin, source }) => { if (/^webpack/.test(data.type)) return - if (data === '') return + if (!data) return + const { method } = data + if (RECOGNISED_NAMESPACES.every(namespace => method.indexOf(namespace) !== 0)) { + return + } const src = source as Window const { id } = data try { diff --git a/src/widget/service.ts b/src/widget/service.ts index 943026941..67856fb1f 100644 --- a/src/widget/service.ts +++ b/src/widget/service.ts @@ -1,5 +1,5 @@ import { ComponentPortal } from "@angular/cdk/portal"; -import { ComponentFactory, ComponentFactoryResolver, ComponentRef, Injectable, Injector, ViewContainerRef } from "@angular/core"; +import { ComponentRef, Injectable, Injector, ViewContainerRef } from "@angular/core"; import { RM_WIDGET } from "./constants"; import { WidgetPortal } from "./widgetPortal/widgetPortal.component"; @@ -12,11 +12,6 @@ export class WidgetService { public vcr: ViewContainerRef private viewRefMap = new Map<WidgetPortal<unknown>, ComponentRef<WidgetPortal<unknown>>>() - private cf: ComponentFactory<WidgetPortal<unknown>> - - constructor(cfr: ComponentFactoryResolver){ - this.cf = cfr.resolveComponentFactory(WidgetPortal) - } public addNewWidget<T>(Component: new (...arg: any) => T, injector: Injector): WidgetPortal<T> { const inj = Injector.create({ @@ -26,7 +21,8 @@ export class WidgetService { }], parent: injector }) - const widgetPortal = this.vcr.createComponent(this.cf, 0, inj) as ComponentRef<WidgetPortal<T>> + + const widgetPortal = this.vcr.createComponent(WidgetPortal, {index: 0, injector: inj}) as ComponentRef<WidgetPortal<T>> const cmpPortal = new ComponentPortal<T>(Component, this.vcr, inj) this.viewRefMap.set(widgetPortal.instance, widgetPortal) -- GitLab