diff --git a/angular.json b/angular.json index b0287d4..27ea6c2 100644 --- a/angular.json +++ b/angular.json @@ -117,6 +117,44 @@ } } }, + "web-socket": { + "projectType": "library", + "root": "projects/web-socket", + "sourceRoot": "projects/web-socket/src", + "prefix": "lib", + "architect": { + "build": { + "builder": "@angular-devkit/build-ng-packagr:build", + "options": { + "tsConfig": "projects/web-socket/tsconfig.lib.json", + "project": "projects/web-socket/ng-package.json" + }, + "configurations": { + "production": { + "tsConfig": "projects/web-socket/tsconfig.lib.prod.json" + } + } + }, + "test": { + "builder": "@angular-devkit/build-angular:karma", + "options": { + "main": "projects/web-socket/src/test.ts", + "tsConfig": "projects/web-socket/tsconfig.spec.json", + "karmaConfig": "projects/web-socket/karma.conf.js" + } + }, + "lint": { + "builder": "@angular-devkit/build-angular:tslint", + "options": { + "tsConfig": [ + "projects/web-socket/tsconfig.lib.json", + "projects/web-socket/tsconfig.spec.json" + ], + "exclude": ["**/node_modules/**"] + } + } + } + }, "i18n": { "projectType": "library", "schematics": { diff --git a/package-lock.json b/package-lock.json index 82d8828..df8b967 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2289,9 +2289,8 @@ "dev": true }, "@ucap/ng-protocol": { - "version": "file:pack/ucap-ng-protocol-0.0.2.tgz", - "integrity": "sha512-fNbmiIrXECeKowvjGflx2lOcOCykH42QKSZzciOeoSxHF8HiFT8ORN5BlR6GOknUCXvGwVPDccNwUs0t1QCnjg==", - "dev": true + "version": "file:pack/ucap-ng-protocol-0.0.3.tgz", + "integrity": "sha512-9aGv4bDKfOjDXWD56THW/KPDdAp2ytaWZSFnbw3PMy8bKiyfRQH/UXrj9c9jrf2aNhnSVvYjh1ol4oXNL8EYMg==" }, "@ucap/ng-protocol-authentication": { "version": "file:pack/ucap-ng-protocol-authentication-0.0.3.tgz", @@ -2375,7 +2374,8 @@ }, "@ucap/ng-store-chat": { "version": "file:pack/ucap-ng-store-chat-0.0.5.tgz", - "integrity": "sha512-FlvWI52w58jq/ZO8b8sk/MonY+TYKiEYlkyIfZWfFYOxlnKG0MkbpL0R+tiOFO9GLbBGEsXrzYtaDazrLk55ZQ==" + "integrity": "sha512-FlvWI52w58jq/ZO8b8sk/MonY+TYKiEYlkyIfZWfFYOxlnKG0MkbpL0R+tiOFO9GLbBGEsXrzYtaDazrLk55ZQ==", + "dev": true }, "@ucap/ng-store-group": { "version": "file:pack/ucap-ng-store-group-0.0.6.tgz", @@ -2407,6 +2407,11 @@ "integrity": "sha512-vtgJBOsJj/S2GjP02PpBz9ebGikNtzdsC7JQc5HKkCZRC6JKkzZmWzcaFGlLPsh9dcWEeZuNhwnAZfmPXgz6Aw==", "dev": true }, + "@ucap/ng-web-socket": { + "version": "file:pack/ucap-ng-web-socket-0.0.1.tgz", + "integrity": "sha512-8jJPuPfO9bqHeOMwNFg4+0nsuPyh5zL3c9z+Z/t02fx0CpXsFw30E6EU2fVi42w4JPC4B65MfIFJ2ai8KB9Org==", + "dev": true + }, "@ucap/ng-web-storage": { "version": "file:pack/ucap-ng-web-storage-0.0.3.tgz", "integrity": "sha512-ndPfCfmdARbeSnbFvagzKsIsjVmo1l0q6vSjFm9seUkZ7GkGyEdzD53XGmrfsO3WosC9uiL6z5etUcmkwJ0EaA==", @@ -2419,9 +2424,9 @@ "dev": true }, "@ucap/protocol": { - "version": "0.0.8", - "resolved": "http://10.81.13.221:8081/nexus/repository/npm-all/@ucap/protocol/-/protocol-0.0.8.tgz", - "integrity": "sha512-cLFryVjd3VLAEJScJiZ2Dm+Uuo5uqX0BHE9ZIdu99BSoDMyODOuBxPFBXAWaxiqX0H5jJHAU3m6leGVv1P2alg==", + "version": "0.0.10", + "resolved": "http://10.81.13.221:8081/nexus/repository/npm-all/@ucap/protocol/-/protocol-0.0.10.tgz", + "integrity": "sha512-tuH1S+K9bVCY2tu/+snHiffkFQLUyQfSWQMYEeMqomX3FiZTX6E9RtqgsxdQzCI/8RHHDUv9OHrIlDl20Aag7w==", "dev": true }, "@ucap/protocol-authentication": { @@ -2515,9 +2520,9 @@ "dev": true }, "@ucap/web-socket": { - "version": "0.0.2", - "resolved": "http://10.81.13.221:8081/nexus/repository/npm-all/@ucap/web-socket/-/web-socket-0.0.2.tgz", - "integrity": "sha512-hKAEsIzMhUuR8u26ENkuIAh4Xp8ltzBlZggxhqtLifP8KbgQdWD3w3+1M1697MPni8q42+Q/ZH/1IHLdi8KB7w==", + "version": "0.0.5", + "resolved": "http://10.81.13.221:8081/nexus/repository/npm-all/@ucap/web-socket/-/web-socket-0.0.5.tgz", + "integrity": "sha512-BsdH5llLxlFGPjER3rvSLaNKtdQyXhhVyAbPStYJPstBNfcyq0Al8/C97aXFWlpLrmvib+s3AT7o1OmPhv8ZWw==", "dev": true }, "@ucap/web-storage": { diff --git a/package.json b/package.json index fec8e44..f220c52 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,8 @@ "build:protocol-status": "node ./scripts/build.js protocol-status", "build:protocol-sync": "node ./scripts/build.js protocol-sync", "build:protocol-umg": "node ./scripts/build.js protocol-umg", - "build:util:all": "npm-run-all -s build:web-storage build:i18n", + "build:util:all": "npm-run-all -s build:web-socket build:web-storage build:i18n", + "build:web-socket": "node ./scripts/build.js web-socket", "build:web-storage": "node ./scripts/build.js web-storage", "build:i18n": "node ./scripts/build.js i18n", "build:store:all": "npm-run-all -s build:store-organization build:store-authentication build:store-group build:store-chat", @@ -80,7 +81,8 @@ "publish:protocol-status": "cd ./dist/protocol-status && npm publish", "publish:protocol-sync": "cd ./dist/protocol-sync && npm publish", "publish:protocol-umg": "cd ./dist/protocol-umg && npm publish", - "publish:util:all": "npm-run-all -s publish:web-storage publish:i18n", + "publish:util:all": "npm-run-all -s publish:web-socket publish:web-storage publish:i18n", + "publish:web-socket": "cd ./dist/web-socket && npm publish", "publish:web-storage": "cd ./dist/web-storage && npm publish", "publish:i18n": "cd ./dist/i18n && npm publish", "publish:store:all": "npm-run-all -s publish:store-organization publish:store-authentication publish:store-group publish:store-chat", @@ -149,7 +151,7 @@ "@ucap/ng-native": "file:pack/ucap-ng-native-0.0.1.tgz", "@ucap/ng-native-browser": "file:pack/ucap-ng-native-browser-0.0.1.tgz", "@ucap/ng-pi": "file:pack/ucap-ng-pi-0.0.1.tgz", - "@ucap/ng-protocol": "file:pack/ucap-ng-protocol-0.0.2.tgz", + "@ucap/ng-protocol": "file:pack/ucap-ng-protocol-0.0.3.tgz", "@ucap/ng-protocol-authentication": "file:pack/ucap-ng-protocol-authentication-0.0.3.tgz", "@ucap/ng-protocol-buddy": "file:pack/ucap-ng-protocol-buddy-0.0.3.tgz", "@ucap/ng-protocol-event": "file:pack/ucap-ng-protocol-event-0.0.3.tgz", @@ -173,9 +175,10 @@ "@ucap/ng-ui-authentication": "file:pack/ucap-ng-ui-authentication-0.0.15.tgz", "@ucap/ng-ui-organization": "file:pack/ucap-ng-ui-organization-0.0.2.tgz", "@ucap/ng-ui-skin-default": "file:pack/ucap-ng-ui-skin-default-0.0.1.tgz", + "@ucap/ng-web-socket": "file:pack/ucap-ng-web-socket-0.0.1.tgz", "@ucap/ng-web-storage": "file:pack/ucap-ng-web-storage-0.0.3.tgz", "@ucap/pi": "~0.0.5", - "@ucap/protocol": "~0.0.8", + "@ucap/protocol": "~0.0.10", "@ucap/protocol-authentication": "~0.0.5", "@ucap/protocol-buddy": "~0.0.5", "@ucap/protocol-event": "~0.0.5", @@ -191,7 +194,7 @@ "@ucap/protocol-status": "~0.0.5", "@ucap/protocol-sync": "~0.0.4", "@ucap/protocol-umg": "~0.0.5", - "@ucap/web-socket": "~0.0.2", + "@ucap/web-socket": "~0.0.5", "@ucap/web-storage": "~0.0.5", "autolinker": "^3.13.0", "axios": "^0.19.2", diff --git a/projects/protocol/package.json b/projects/protocol/package.json index d2579e6..111491c 100644 --- a/projects/protocol/package.json +++ b/projects/protocol/package.json @@ -1,6 +1,6 @@ { "name": "@ucap/ng-protocol", - "version": "0.0.2", + "version": "0.0.3", "publishConfig": { "registry": "http://10.81.13.221:8081/nexus/repository/npm-ucap/" }, diff --git a/projects/protocol/src/lib/services/protocol.service.ts b/projects/protocol/src/lib/services/protocol.service.ts index 94ceb50..91172e3 100644 --- a/projects/protocol/src/lib/services/protocol.service.ts +++ b/projects/protocol/src/lib/services/protocol.service.ts @@ -2,20 +2,22 @@ import { Injectable, Inject } from '@angular/core'; import { ModuleConfig, - ProtocolService as UcapProtocolService + ProtocolService as UCAPProtocolService } from '@ucap/protocol'; import { LogService } from '@ucap/ng-logger'; +import { WebSocketService } from '@ucap/ng-web-socket'; import { _MODULE_CONFIG } from '../config/token'; @Injectable({ providedIn: 'root' }) -export class ProtocolService extends UcapProtocolService { +export class ProtocolService extends UCAPProtocolService { constructor( @Inject(_MODULE_CONFIG) moduleConfig: ModuleConfig, + webSocketService: WebSocketService, logService: LogService ) { - super(moduleConfig, logService); + super(moduleConfig, webSocketService, logService); } } diff --git a/projects/web-socket/README.md b/projects/web-socket/README.md new file mode 100644 index 0000000..4ac2b95 --- /dev/null +++ b/projects/web-socket/README.md @@ -0,0 +1,24 @@ +# WebStorage + +This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 9.0.2. + +## Code scaffolding + +Run `ng generate component component-name --project web-storage` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module --project web-storage`. +> Note: Don't forget to add `--project web-storage` or else it will be added to the default project in your `angular.json` file. + +## Build + +Run `ng build web-storage` to build the project. The build artifacts will be stored in the `dist/` directory. + +## Publishing + +After building your library with `ng build web-storage`, go to the dist folder `cd dist/web-storage` and run `npm publish`. + +## Running unit tests + +Run `ng test web-storage` to execute the unit tests via [Karma](https://karma-runner.github.io). + +## Further help + +To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md). diff --git a/projects/web-socket/karma.conf.js b/projects/web-socket/karma.conf.js new file mode 100644 index 0000000..7d3447f --- /dev/null +++ b/projects/web-socket/karma.conf.js @@ -0,0 +1,32 @@ +// Karma configuration file, see link for more information +// https://karma-runner.github.io/1.0/config/configuration-file.html + +module.exports = function (config) { + config.set({ + basePath: '', + frameworks: ['jasmine', '@angular-devkit/build-angular'], + plugins: [ + require('karma-jasmine'), + require('karma-chrome-launcher'), + require('karma-jasmine-html-reporter'), + require('karma-coverage-istanbul-reporter'), + require('@angular-devkit/build-angular/plugins/karma') + ], + client: { + clearContext: false // leave Jasmine Spec Runner output visible in browser + }, + coverageIstanbulReporter: { + dir: require('path').join(__dirname, '../../coverage/web-storage'), + reports: ['html', 'lcovonly', 'text-summary'], + fixWebpackSourcePaths: true + }, + reporters: ['progress', 'kjhtml'], + port: 9876, + colors: true, + logLevel: config.LOG_INFO, + autoWatch: true, + browsers: ['Chrome'], + singleRun: false, + restartOnFileChange: true + }); +}; diff --git a/projects/web-socket/ng-package.json b/projects/web-socket/ng-package.json new file mode 100644 index 0000000..24af1e1 --- /dev/null +++ b/projects/web-socket/ng-package.json @@ -0,0 +1,11 @@ +{ + "$schema": "../../node_modules/ng-packagr/ng-package.schema.json", + "dest": "../../dist/web-socket", + "lib": { + "entryFile": "src/public-api.ts", + "umdModuleIds": { + "@ucap/ng-logger": "@ucap/ng-logger", + "@ucap/web-socket": "@ucap/web-socket" + } + } +} diff --git a/projects/web-socket/package.json b/projects/web-socket/package.json new file mode 100644 index 0000000..277398e --- /dev/null +++ b/projects/web-socket/package.json @@ -0,0 +1,13 @@ +{ + "name": "@ucap/ng-web-socket", + "version": "0.0.1", + "publishConfig": { + "registry": "http://10.81.13.221:8081/nexus/repository/npm-ucap/" + }, + "peerDependencies": { + "@angular/common": "^9.0.2", + "@angular/core": "^9.0.2", + "@ucap/web-socket": "~0.0.1", + "tslib": "^1.10.0" + } +} diff --git a/projects/web-socket/src/lib/config/token.ts b/projects/web-socket/src/lib/config/token.ts new file mode 100644 index 0000000..b27d22e --- /dev/null +++ b/projects/web-socket/src/lib/config/token.ts @@ -0,0 +1,5 @@ +import { InjectionToken } from '@angular/core'; + +export const _MODULE_CONFIG = new InjectionToken( + '@ucap/ng-web-socket config of module' +); diff --git a/projects/web-socket/src/lib/services/web-socket.service.spec.ts b/projects/web-socket/src/lib/services/web-socket.service.spec.ts new file mode 100644 index 0000000..ca8cdc7 --- /dev/null +++ b/projects/web-socket/src/lib/services/web-socket.service.spec.ts @@ -0,0 +1,12 @@ +import { TestBed } from '@angular/core/testing'; + +import { WebSocketService } from './web-socket.service'; + +describe('WebSocketService', () => { + beforeEach(() => TestBed.configureTestingModule({})); + + it('should be created', () => { + const service: WebSocketService = TestBed.inject(WebSocketService); + expect(service).toBeTruthy(); + }); +}); diff --git a/projects/web-socket/src/lib/services/web-socket.service.ts b/projects/web-socket/src/lib/services/web-socket.service.ts new file mode 100644 index 0000000..8248fc7 --- /dev/null +++ b/projects/web-socket/src/lib/services/web-socket.service.ts @@ -0,0 +1,22 @@ +import { Injectable, Inject } from '@angular/core'; + +import { + ModuleConfig, + WebSocketService as UCAPWebSocketService +} from '@ucap/web-socket'; + +import { LogService } from '@ucap/ng-logger'; + +import { _MODULE_CONFIG } from '../config/token'; + +@Injectable({ + providedIn: 'root' +}) +export class WebSocketService extends UCAPWebSocketService { + constructor( + @Inject(_MODULE_CONFIG) moduleConfig: ModuleConfig, + logService: LogService + ) { + super(moduleConfig, logService); + } +} diff --git a/projects/web-socket/src/lib/web-storage.module.ts b/projects/web-socket/src/lib/web-storage.module.ts new file mode 100644 index 0000000..97c940d --- /dev/null +++ b/projects/web-socket/src/lib/web-storage.module.ts @@ -0,0 +1,24 @@ +import { NgModule, ModuleWithProviders } from '@angular/core'; + +import { ModuleConfig } from '@ucap/web-storage'; + +import { _MODULE_CONFIG } from './config/token'; + +import { WebSocketService } from './services/web-socket.service'; + +const SERVICES = [WebSocketService]; + +@NgModule({}) +export class WebSocketRootModule {} + +@NgModule({}) +export class WebSocketModule { + public static forRoot( + config: ModuleConfig + ): ModuleWithProviders { + return { + ngModule: WebSocketRootModule, + providers: [{ provide: _MODULE_CONFIG, useValue: config }, ...SERVICES] + }; + } +} diff --git a/projects/web-socket/src/public-api.ts b/projects/web-socket/src/public-api.ts new file mode 100644 index 0000000..ffdbb2a --- /dev/null +++ b/projects/web-socket/src/public-api.ts @@ -0,0 +1,7 @@ +/* + * Public API Surface of web-socket + */ + +export * from './lib/services/web-socket.service'; + +export * from './lib/web-storage.module'; diff --git a/projects/web-socket/src/test.ts b/projects/web-socket/src/test.ts new file mode 100644 index 0000000..53298e5 --- /dev/null +++ b/projects/web-socket/src/test.ts @@ -0,0 +1,30 @@ +// This file is required by karma.conf.js and loads recursively all the .spec and framework files + +import 'zone.js/dist/zone'; +import 'zone.js/dist/zone-testing'; +import { getTestBed } from '@angular/core/testing'; +import { + BrowserDynamicTestingModule, + platformBrowserDynamicTesting +} from '@angular/platform-browser-dynamic/testing'; + +declare const require: { + context( + path: string, + deep?: boolean, + filter?: RegExp + ): { + keys(): string[]; + (id: string): T; + }; +}; + +// First, initialize the Angular testing environment. +getTestBed().initTestEnvironment( + BrowserDynamicTestingModule, + platformBrowserDynamicTesting() +); +// Then we find all the tests. +const context = require.context('./', true, /\.spec\.ts$/); +// And load the modules. +context.keys().map(context); diff --git a/projects/web-socket/tsconfig.lib.json b/projects/web-socket/tsconfig.lib.json new file mode 100644 index 0000000..4dee55f --- /dev/null +++ b/projects/web-socket/tsconfig.lib.json @@ -0,0 +1,17 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "outDir": "../../out-tsc/lib", + "target": "es2015", + "declaration": true, + "inlineSources": true, + "types": [], + "lib": ["dom", "es2018"] + }, + "angularCompilerOptions": { + "skipTemplateCodegen": true, + "strictMetadataEmit": true, + "enableResourceInlining": true + }, + "exclude": ["src/test.ts", "**/*.spec.ts"] +} diff --git a/projects/web-socket/tsconfig.lib.prod.json b/projects/web-socket/tsconfig.lib.prod.json new file mode 100644 index 0000000..cbae794 --- /dev/null +++ b/projects/web-socket/tsconfig.lib.prod.json @@ -0,0 +1,6 @@ +{ + "extends": "./tsconfig.lib.json", + "angularCompilerOptions": { + "enableIvy": false + } +} diff --git a/projects/web-socket/tsconfig.spec.json b/projects/web-socket/tsconfig.spec.json new file mode 100644 index 0000000..ec3528a --- /dev/null +++ b/projects/web-socket/tsconfig.spec.json @@ -0,0 +1,9 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "outDir": "../../out-tsc/spec", + "types": ["jasmine", "node"] + }, + "files": ["src/test.ts"], + "include": ["**/*.spec.ts", "**/*.d.ts"] +} diff --git a/projects/web-socket/tslint.json b/projects/web-socket/tslint.json new file mode 100644 index 0000000..205aeda --- /dev/null +++ b/projects/web-socket/tslint.json @@ -0,0 +1,7 @@ +{ + "extends": "../../tslint.json", + "rules": { + "directive-selector": [true, "attribute", "lib", "camelCase"], + "component-selector": [true, "element", "lib", "kebab-case"] + } +} diff --git a/tsconfig.json b/tsconfig.json index fd603f1..d368ee4 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -12,26 +12,18 @@ "importHelpers": true, "esModuleInterop": true, "target": "es2015", - "typeRoots": [ - "node_modules/@types" - ], - "lib": [ - "es2018", - "dom" - ], + "typeRoots": ["node_modules/@types"], + "lib": ["es2018", "dom"], "paths": { "ui-skin-default": [ "dist/ui-skin-default/ui-skin-default", "dist/ui-skin-default" ], - "logger": [ - "dist/logger/logger", - "dist/logger" - ] + "logger": ["dist/logger/logger", "dist/logger"] } }, "angularCompilerOptions": { "fullTemplateTypeCheck": true, "strictInjectionParameters": true } -} \ No newline at end of file +}