Skip to content

Commit

Permalink
feat: move base component to core package (#118)
Browse files Browse the repository at this point in the history
* feat: move basecomponent to core

* fix:  coverageThreshold
  • Loading branch information
Arne Vandoorslaer authored Jul 8, 2021
1 parent 1854e81 commit 04da689
Show file tree
Hide file tree
Showing 16 changed files with 50 additions and 29 deletions.
5 changes: 2 additions & 3 deletions packages/semcom-components/lib/components/input.component.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { css, html, PropertyValues, query, state } from 'lit-element';
import { ComponentResponseEvent } from '@digita-ai/semcom-sdk';
import { css, html, query, state } from 'lit-element';
import { BaseComponent, ComponentResponseEvent } from '@digita-ai/semcom-core';
import { Literal, NamedNode, Quad } from 'n3';
import { BaseComponent } from './base.component';

export default class InputComponent extends BaseComponent {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
/* eslint-disable no-console -- is a web component */
import { NamedNode, Store } from 'n3';
import { css, html, property, PropertyValues } from 'lit-element';
import { ComponentResponseEvent } from '@digita-ai/semcom-sdk';
import { BaseComponent } from './base.component';
import { BaseComponent, ComponentResponseEvent } from '@digita-ai/semcom-core';

export default class PayslipComponent extends BaseComponent {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { NamedNode, Store } from 'n3';
import { css, html, property, PropertyValues } from 'lit-element';
import { ComponentResponseEvent } from '@digita-ai/semcom-sdk';
import { BaseComponent } from './base.component';
import { BaseComponent, ComponentResponseEvent } from '@digita-ai/semcom-core';

export class ProfileComponent extends BaseComponent {

Expand Down
4 changes: 2 additions & 2 deletions packages/semcom-components/lib/demo.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Parser } from 'n3';
import { ComponentEventType, ComponentReadEvent, ComponentResponseEvent, ComponentWriteEvent } from '@digita-ai/semcom-sdk';
import ProfileComponent from './components/profile.component';
import { ComponentEventType, ComponentReadEvent, ComponentResponseEvent, ComponentWriteEvent } from '@digita-ai/semcom-core';
import PayslipComponent from './components/payslip.component';
import InputComponent from './components/input.component';
import ProfileComponent from './components/profile.component';

customElements.define('profile-component', ProfileComponent);
customElements.define('payslip-component', PayslipComponent);
Expand Down
2 changes: 1 addition & 1 deletion packages/semcom-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
],
"scripts": {
"clean": "rimraf ./dist && rimraf ./package-lock.json && rimraf ./node_modules",
"start": "npm run start:watch",
"start": "npm run start:dev",
"start:dev": "vite",
"build": "rimraf ./dist && npm run build:bundle && npm run build:ts",
"build:bundle": "vite build",
Expand Down
1 change: 0 additions & 1 deletion packages/semcom-components/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ export default ({ command, mode }) => {
rollupOptions: {
input: {
input: path.resolve(__dirname, 'lib/components/input.component.ts'),
base: path.resolve(__dirname, 'lib/components/base.component.ts'),
payslip: path.resolve(__dirname, 'lib/components/payslip.component.ts'),
profile: path.resolve(__dirname, 'lib/components/profile.component.ts'),
},
Expand Down
3 changes: 2 additions & 1 deletion packages/semcom-core/.componentsignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"Error",
"EventEmitter",
"Partial",
"CustomEvent"
"CustomEvent",
"LitElement"
]
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* eslint-disable no-console */
import { Component } from '@digita-ai/semcom-core';
import { ComponentAppendEvent, ComponentEventType, ComponentReadEvent, ComponentResponseEvent, ComponentWriteEvent } from '@digita-ai/semcom-sdk';
import { LitElement, property } from 'lit-element';
import { Quad } from 'rdf-js';
import { Component } from './models/component.model';
import { ComponentEventType, ComponentResponseEvent, ComponentReadEvent, ComponentWriteEvent, ComponentAppendEvent } from './models/component-events.model';

/**
* A base component which implements the Semcom-standard by using Lit.
Expand Down Expand Up @@ -105,31 +105,31 @@ export abstract class BaseComponent extends LitElement implements Component {
*/

// Invoked each time the element is appended into a DOM (i.e. when node is added or moved).
connectedCallback() {
connectedCallback(): void {

super.connectedCallback();
console.debug(`[${this.tagName}] Element connected`);

}

// Invoked each time the element is disconnected from a DOM.
disconnectedCallback() {
disconnectedCallback(): void {

super.disconnectedCallback();
console.debug(`[${this.tagName}] Element disconnected`);

}

// Invoked each time the custom element is moved to a new DOM.
adoptedCallback() {
adoptedCallback(): void {

// super.adoptedCallback();
console.debug(`[${this.tagName}] Element moved to other DOM`);

}

// Invoked each time one of the element's attributes specified in observedAttributes is changed.
attributeChangedCallback(name: string, oldValue: string, newValue: string) {
attributeChangedCallback(name: string, oldValue: string, newValue: string): void {

super.attributeChangedCallback(name, oldValue, newValue);
console.debug(`[${this.tagName}] Changed ${name} attribute from "${oldValue}" to "${newValue}"`);
Expand Down
3 changes: 3 additions & 0 deletions packages/semcom-core/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ export * from './logger/services/logger-console.service';
export * from './component/services/manage.service';
export * from './component/services/query.service';
export * from './mock/initial-components';
export * from './component/base.component';
export * from './component/models/component-events.model';

15 changes: 15 additions & 0 deletions packages/semcom-core/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions packages/semcom-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@
"https://linkedsoftwaredependencies.org/bundles/npm/@digita-ai/semcom-core/^0.0.0/components/": "dist/components/",
"https://linkedsoftwaredependencies.org/bundles/npm/@digita-ai/semcom-core/^0.0.0/dist/": "dist/"
},
"dependencies": {
"lit-element": "^2.4.0"
},
"devDependencies": {
"@digita-ai/typescript-config": "^0.3.4",
"@types/jest": "^26.0.19",
Expand All @@ -76,9 +79,9 @@
"coverageThreshold": {
"global": {
"branches": 0,
"functions": 50,
"lines": 41.38,
"statements": 41.38
"functions": 6.67,
"lines": 17.14,
"statements": 17.14
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions packages/semcom-demo-app/src/demo.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ import { from } from 'rxjs';
import { RxLitElement } from 'rx-lit';
import { map } from 'rxjs/operators';
import { AuthenticateComponent, LoadingComponent, ProviderListComponent, ProviderListItemComponent, Session, SolidSDKService } from '@digita-ai/ui-transfer-components';
import { ComponentMetadata } from '@digita-ai/semcom-core';
import { ComponentMetadata, ComponentEventType, ComponentReadEvent, ComponentResponseEvent, ComponentWriteEvent } from '@digita-ai/semcom-core';
import { Theme } from '@digita-ai/ui-transfer-theme';
import { ComponentEventType, ComponentReadEvent, ComponentResponseEvent, ComponentWriteEvent } from '@digita-ai/semcom-sdk';
import { Parser } from 'n3';
import { fetch } from '@digita-ai/inrupt-solid-client';
import { demoMachine, DemoContext, DemoEvent, DemoState, DemoStates, AuthenticatedEvent } from './demo.machine';
Expand Down
5 changes: 5 additions & 0 deletions packages/semcom-node/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion packages/semcom-sdk/lib/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export * from './discovery';
export * from './component/services/query-component-remote.service';
export * from './component/models/component-events.model';
export * from './component/services/register-component.service';
10 changes: 5 additions & 5 deletions packages/semcom-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,11 @@
],
"coverageThreshold": {
"global": {
"branches": 47.83,
"functions": 26.67,
"lines": 41.82,
"statements": 39.66
"branches": 56.52,
"functions": 40,
"lines": 58.14,
"statements": 54.35
}
}
}
}
}

0 comments on commit 04da689

Please sign in to comment.