From 04b049f39fd60698588a5e2800fd5093b2142413 Mon Sep 17 00:00:00 2001 From: Michael Czechowski Date: Fri, 31 Aug 2018 15:05:12 +0200 Subject: [PATCH] prepared library publishing --- package.json | 2 +- projects/nls-guilloche/package.json | 3 ++ .../lib}/directives/guilloche.directive.ts | 49 ++++--------------- .../src/lib}/models/config.model.ts | 0 .../src/lib}/models/graph.model.ts | 0 .../src/lib}/models/param.model.ts | 0 .../src/lib}/models/point.model.ts | 0 .../src/lib/nls-guilloche.component.spec.ts | 25 ---------- .../src/lib/nls-guilloche.component.ts | 19 ------- .../src/lib/nls-guilloche.module.ts | 10 ---- .../src/lib/nls-guilloche.service.spec.ts | 15 ------ .../src/lib/nls-guilloche.service.ts | 9 ---- .../src/lib}/services/animation.service.ts | 10 ++-- .../src/lib}/services/canvas.service.ts | 2 +- .../src/lib}/services/graph.service.ts | 6 +-- .../src/lib}/services/history.service.ts | 2 +- .../src/lib}/services/math.service.ts | 2 +- projects/nls-guilloche/src/public_api.ts | 13 +++-- src/app/app.component.ts | 20 ++++---- src/app/app.module.ts | 24 ++++----- src/app/components/graphs.component.html | 6 +-- src/app/components/graphs.component.scss | 6 +-- src/app/components/graphs.component.ts | 24 +++++---- yarn.lock | 10 ++++ 24 files changed, 82 insertions(+), 175 deletions(-) rename {src/app => projects/nls-guilloche/src/lib}/directives/guilloche.directive.ts (80%) rename {src/app => projects/nls-guilloche/src/lib}/models/config.model.ts (100%) rename {src/app => projects/nls-guilloche/src/lib}/models/graph.model.ts (100%) rename {src/app => projects/nls-guilloche/src/lib}/models/param.model.ts (100%) rename {src/app => projects/nls-guilloche/src/lib}/models/point.model.ts (100%) delete mode 100644 projects/nls-guilloche/src/lib/nls-guilloche.component.spec.ts delete mode 100644 projects/nls-guilloche/src/lib/nls-guilloche.component.ts delete mode 100644 projects/nls-guilloche/src/lib/nls-guilloche.module.ts delete mode 100644 projects/nls-guilloche/src/lib/nls-guilloche.service.spec.ts delete mode 100644 projects/nls-guilloche/src/lib/nls-guilloche.service.ts rename {src/app => projects/nls-guilloche/src/lib}/services/animation.service.ts (88%) rename {src/app => projects/nls-guilloche/src/lib}/services/canvas.service.ts (97%) rename {src/app => projects/nls-guilloche/src/lib}/services/graph.service.ts (94%) rename {src/app => projects/nls-guilloche/src/lib}/services/history.service.ts (97%) rename {src/app => projects/nls-guilloche/src/lib}/services/math.service.ts (99%) diff --git a/package.json b/package.json index f3df2d0..49296b8 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "nls-guilloche", + "name": "nls-guilloche-generator", "version": "0.2.0", "repository": { "type": "git", diff --git a/projects/nls-guilloche/package.json b/projects/nls-guilloche/package.json index bff6543..39065c2 100644 --- a/projects/nls-guilloche/package.json +++ b/projects/nls-guilloche/package.json @@ -26,6 +26,9 @@ "url": "https://dailysh.it" } ], + "dependencies": { + "d3": "^5.3.0" + }, "peerDependencies": { "@angular/common": "^6.0.0-rc.0 || ^6.0.0", "@angular/core": "^6.0.0-rc.0 || ^6.0.0" diff --git a/src/app/directives/guilloche.directive.ts b/projects/nls-guilloche/src/lib/directives/guilloche.directive.ts similarity index 80% rename from src/app/directives/guilloche.directive.ts rename to projects/nls-guilloche/src/lib/directives/guilloche.directive.ts index 5a1433a..9b3f355 100644 --- a/src/app/directives/guilloche.directive.ts +++ b/projects/nls-guilloche/src/lib/directives/guilloche.directive.ts @@ -14,7 +14,7 @@ * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import { ElementRef, HostListener, Output, EventEmitter, Input, Directive, OnChanges, OnDestroy, SimpleChanges } from '@angular/core'; +import { ElementRef, HostListener, Input, Directive, OnChanges, OnDestroy, SimpleChanges } from '@angular/core'; import * as Selection from 'd3-selection'; import * as Shape from 'd3-shape'; import * as Random from 'd3-random'; @@ -22,22 +22,20 @@ import * as Drag from 'd3-drag'; import * as Ease from 'd3-ease'; import * as Timer from 'd3-timer'; -import { environment as env } from './../../environments/environment'; import { Config } from './../models/config.model'; import { Graph } from './../models/graph.model'; import { Point } from './../models/point.model'; import { Param } from './../models/param.model'; -import { CanvasService } from './../services/canvas.service'; -import { MathService } from './../services/math.service'; -import { GraphService } from '../services/graph.service'; -import { AnimationService } from './../services/animation.service'; +import { NlsCanvasService } from './../services/canvas.service'; +import { NlsMathService } from './../services/math.service'; +import { NlsGraphService } from '../services/graph.service'; const ANIMATION_INTERVAL = 60; @Directive({ - selector: '[guilloche]' + selector: '[nlsGuilloche]' }) -export class GuillocheDirective implements OnChanges, OnDestroy { +export class NlsGuillocheDirective implements OnChanges, OnDestroy { private canvas: any; private group: any; @@ -55,14 +53,11 @@ export class GuillocheDirective implements OnChanges, OnDestroy { @Input() config: any; @Input() animate: boolean; - @Output() guillocheChange = new EventEmitter(); - constructor( - private canvasService: CanvasService, + private canvasService: NlsCanvasService, private el: ElementRef, - private math: MathService, - private graphService: GraphService, - private animationService: AnimationService + private math: NlsMathService, + private graphService: NlsGraphService ) { } @@ -121,7 +116,6 @@ export class GuillocheDirective implements OnChanges, OnDestroy { this.graph.end.direction, this.graph.end.point, ]).forEach((points, index) => this.drawGraph(points)); - this.guillocheChanged(); } private animateGraph(x) { @@ -160,12 +154,6 @@ export class GuillocheDirective implements OnChanges, OnDestroy { .x(p => p.x) .y(p => p.y) .curve(Shape.curveBasis)(points)); - - // if (env.debug) { - // this.group.selectAll('circle').remove(); - // this.group.selectAll('text').remove(); - // // this.debugGraph(points); - // } } private drawGraph(points: Point[]): void { @@ -180,14 +168,6 @@ export class GuillocheDirective implements OnChanges, OnDestroy { .x(p => p.x) .y(p => p.y) .curve(Shape.curveBasis)(points))); - - if (env.debug) { - this.debugGraph(points); - } - } - - public guillocheChanged() { - this.guillocheChange.emit(this.el.nativeElement); } private debugGraph(points: Point[]) { @@ -210,15 +190,4 @@ export class GuillocheDirective implements OnChanges, OnDestroy { .text(index); }); } - - private debugBounce(point: Point): void { - if (env.debug) { - this.group.append('circle') - .attr('cx', point.x) - .attr('cy', point.y) - .attr('r', 2) - .attr('fill-opacity', 0.4) - .attr('fill', 'darkgray'); - } - } } diff --git a/src/app/models/config.model.ts b/projects/nls-guilloche/src/lib/models/config.model.ts similarity index 100% rename from src/app/models/config.model.ts rename to projects/nls-guilloche/src/lib/models/config.model.ts diff --git a/src/app/models/graph.model.ts b/projects/nls-guilloche/src/lib/models/graph.model.ts similarity index 100% rename from src/app/models/graph.model.ts rename to projects/nls-guilloche/src/lib/models/graph.model.ts diff --git a/src/app/models/param.model.ts b/projects/nls-guilloche/src/lib/models/param.model.ts similarity index 100% rename from src/app/models/param.model.ts rename to projects/nls-guilloche/src/lib/models/param.model.ts diff --git a/src/app/models/point.model.ts b/projects/nls-guilloche/src/lib/models/point.model.ts similarity index 100% rename from src/app/models/point.model.ts rename to projects/nls-guilloche/src/lib/models/point.model.ts diff --git a/projects/nls-guilloche/src/lib/nls-guilloche.component.spec.ts b/projects/nls-guilloche/src/lib/nls-guilloche.component.spec.ts deleted file mode 100644 index 5a89e8e..0000000 --- a/projects/nls-guilloche/src/lib/nls-guilloche.component.spec.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; - -import { NlsGuillocheComponent } from './nls-guilloche.component'; - -describe('NlsGuillocheComponent', () => { - let component: NlsGuillocheComponent; - let fixture: ComponentFixture; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [ NlsGuillocheComponent ] - }) - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(NlsGuillocheComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/projects/nls-guilloche/src/lib/nls-guilloche.component.ts b/projects/nls-guilloche/src/lib/nls-guilloche.component.ts deleted file mode 100644 index 0790d6e..0000000 --- a/projects/nls-guilloche/src/lib/nls-guilloche.component.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { Component, OnInit } from '@angular/core'; - -@Component({ - selector: 'lib-nls-guilloche', - template: ` -

- nls-guilloche works! -

- `, - styles: [] -}) -export class NlsGuillocheComponent implements OnInit { - - constructor() { } - - ngOnInit() { - } - -} diff --git a/projects/nls-guilloche/src/lib/nls-guilloche.module.ts b/projects/nls-guilloche/src/lib/nls-guilloche.module.ts deleted file mode 100644 index c9a6fef..0000000 --- a/projects/nls-guilloche/src/lib/nls-guilloche.module.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { NgModule } from '@angular/core'; -import { NlsGuillocheComponent } from './nls-guilloche.component'; - -@NgModule({ - imports: [ - ], - declarations: [NlsGuillocheComponent], - exports: [NlsGuillocheComponent] -}) -export class NlsGuillocheModule { } diff --git a/projects/nls-guilloche/src/lib/nls-guilloche.service.spec.ts b/projects/nls-guilloche/src/lib/nls-guilloche.service.spec.ts deleted file mode 100644 index e0dda3e..0000000 --- a/projects/nls-guilloche/src/lib/nls-guilloche.service.spec.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { TestBed, inject } from '@angular/core/testing'; - -import { NlsGuillocheService } from './nls-guilloche.service'; - -describe('NlsGuillocheService', () => { - beforeEach(() => { - TestBed.configureTestingModule({ - providers: [NlsGuillocheService] - }); - }); - - it('should be created', inject([NlsGuillocheService], (service: NlsGuillocheService) => { - expect(service).toBeTruthy(); - })); -}); diff --git a/projects/nls-guilloche/src/lib/nls-guilloche.service.ts b/projects/nls-guilloche/src/lib/nls-guilloche.service.ts deleted file mode 100644 index a409ef3..0000000 --- a/projects/nls-guilloche/src/lib/nls-guilloche.service.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { Injectable } from '@angular/core'; - -@Injectable({ - providedIn: 'root' -}) -export class NlsGuillocheService { - - constructor() { } -} diff --git a/src/app/services/animation.service.ts b/projects/nls-guilloche/src/lib/services/animation.service.ts similarity index 88% rename from src/app/services/animation.service.ts rename to projects/nls-guilloche/src/lib/services/animation.service.ts index 4251f39..22acbc6 100644 --- a/src/app/services/animation.service.ts +++ b/projects/nls-guilloche/src/lib/services/animation.service.ts @@ -19,11 +19,11 @@ import { interval, Observable } from 'rxjs'; import * as Selection from 'd3-selection'; import { Graph } from '../models/graph.model'; -import { MathService } from './math.service'; -import { HistoryService } from './history.service'; +import { NlsMathService } from './math.service'; +import { NlsHistoryService } from './history.service'; @Injectable() -export class AnimationService { +export class NlsAnimationService { public graphs: Graph[]; public speed: number; @@ -33,8 +33,8 @@ export class AnimationService { // private subscribtion: any; constructor( - private math: MathService, - private historyService: HistoryService, + private math: NlsMathService, + private historyService: NlsHistoryService, ) { } diff --git a/src/app/services/canvas.service.ts b/projects/nls-guilloche/src/lib/services/canvas.service.ts similarity index 97% rename from src/app/services/canvas.service.ts rename to projects/nls-guilloche/src/lib/services/canvas.service.ts index 7c218f1..8135c07 100644 --- a/src/app/services/canvas.service.ts +++ b/projects/nls-guilloche/src/lib/services/canvas.service.ts @@ -18,7 +18,7 @@ import { Inject, Injectable, Renderer2, RendererFactory2 } from '@angular/core'; import * as Selection from 'd3-selection'; @Injectable() -export class CanvasService { +export class NlsCanvasService { private renderer: Renderer2; public canvas: any; diff --git a/src/app/services/graph.service.ts b/projects/nls-guilloche/src/lib/services/graph.service.ts similarity index 94% rename from src/app/services/graph.service.ts rename to projects/nls-guilloche/src/lib/services/graph.service.ts index 724b573..64be2c2 100644 --- a/src/app/services/graph.service.ts +++ b/projects/nls-guilloche/src/lib/services/graph.service.ts @@ -18,17 +18,17 @@ import { Validators } from '@angular/forms'; import { Inject, Injectable, Renderer2, RendererFactory2 } from '@angular/core'; import * as Selection from 'd3-selection'; -import { MathService } from './math.service'; +import { NlsMathService } from './math.service'; import { Graph } from './../models/graph.model'; import { Point } from './../models/point.model'; @Injectable() -export class GraphService { +export class NlsGraphService { private graphs: Graph[]; private animation: boolean | null; constructor( - private math: MathService + private math: NlsMathService ) {} public get() { diff --git a/src/app/services/history.service.ts b/projects/nls-guilloche/src/lib/services/history.service.ts similarity index 97% rename from src/app/services/history.service.ts rename to projects/nls-guilloche/src/lib/services/history.service.ts index 5693e91..5540295 100644 --- a/src/app/services/history.service.ts +++ b/projects/nls-guilloche/src/lib/services/history.service.ts @@ -20,7 +20,7 @@ import * as Selection from 'd3-selection'; import { Graph } from '../models/graph.model'; @Injectable() -export class HistoryService { +export class NlsHistoryService { public history: any[]; diff --git a/src/app/services/math.service.ts b/projects/nls-guilloche/src/lib/services/math.service.ts similarity index 99% rename from src/app/services/math.service.ts rename to projects/nls-guilloche/src/lib/services/math.service.ts index aa78182..96fe454 100644 --- a/src/app/services/math.service.ts +++ b/projects/nls-guilloche/src/lib/services/math.service.ts @@ -22,7 +22,7 @@ import { Point } from './../models/point.model'; import { Graph } from './../models/graph.model'; @Injectable() -export class MathService { +export class NlsMathService { /** * Calculate distance between to points with coordinates. diff --git a/projects/nls-guilloche/src/public_api.ts b/projects/nls-guilloche/src/public_api.ts index f18df4f..d463f5a 100644 --- a/projects/nls-guilloche/src/public_api.ts +++ b/projects/nls-guilloche/src/public_api.ts @@ -2,6 +2,13 @@ * Public API Surface of nls-guilloche */ -export * from './lib/nls-guilloche.service'; -export * from './lib/nls-guilloche.component'; -export * from './lib/nls-guilloche.module'; +export * from './lib/directives/guilloche.directive'; +export * from './lib/models/config.model'; +export * from './lib/models/graph.model'; +export * from './lib/models/param.model'; +export * from './lib/models/point.model'; +export * from './lib/services/animation.service'; +export * from './lib/services/canvas.service'; +export * from './lib/services/graph.service'; +export * from './lib/services/history.service'; +export * from './lib/services/math.service'; diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 89a616b..54f2d98 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -18,18 +18,16 @@ import { ConfigForm } from './forms/config.form'; import { Component, OnInit, HostListener } from '@angular/core'; import { FormGroup } from '@angular/forms'; import { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser'; -// import { Moment } from 'moment'; import * as moment from 'moment'; import 'moment/min/locales'; import { environment as env } from '../environments/environment'; -import { Param } from './models/param.model'; -import { Config } from './models/config.model'; -import { CanvasService } from './services/canvas.service'; -import { HistoryService } from './services/history.service'; -import { Graph } from './models/graph.model'; -import { GraphService } from './services/graph.service'; -import { AnimationService } from './services/animation.service'; +import { Param } from './../../projects/nls-guilloche/src/lib/models/param.model'; +import { Config } from './../../projects/nls-guilloche/src/lib/models/config.model'; +import { Graph } from './../../projects/nls-guilloche/src/lib/models/graph.model'; +import { NlsCanvasService } from './../../projects/nls-guilloche/src/lib/services/canvas.service'; +import { NlsHistoryService } from './../../projects/nls-guilloche/src/lib/services/history.service'; +import { NlsGraphService } from './../../projects/nls-guilloche/src/lib/services/graph.service'; @Component({ selector: 'app-root', @@ -48,9 +46,9 @@ export class AppComponent implements OnInit { public animationActive: boolean; constructor( - private canvasService: CanvasService, - private historyService: HistoryService, - private graphService: GraphService, + private canvasService: NlsCanvasService, + private historyService: NlsHistoryService, + private graphService: NlsGraphService, ) { moment.locale('de'); diff --git a/src/app/app.module.ts b/src/app/app.module.ts index e835da3..97b240f 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -22,18 +22,18 @@ import { MomentModule } from 'ngx-moment'; import { AppComponent } from './app.component'; import { GraphsComponent } from './components/graphs.component'; -import { GuillocheDirective } from './directives/guilloche.directive'; -import { CanvasService } from './services/canvas.service'; -import { HistoryService } from './services/history.service'; -import { AnimationService } from './services/animation.service'; -import { MathService } from './services/math.service'; -import { GraphService } from './services/graph.service'; +import { NlsGuillocheDirective } from './../../projects/nls-guilloche/src/lib/directives/guilloche.directive'; +import { NlsCanvasService } from './../../projects/nls-guilloche/src/lib/services/canvas.service'; +import { NlsHistoryService } from './../../projects/nls-guilloche/src/lib/services/history.service'; +import { NlsAnimationService } from './../../projects/nls-guilloche/src/lib/services/animation.service'; +import { NlsMathService } from './../../projects/nls-guilloche/src/lib/services/math.service'; +import { NlsGraphService } from './../../projects/nls-guilloche/src/lib/services/graph.service'; @NgModule({ declarations: [ AppComponent, GraphsComponent, - GuillocheDirective + NlsGuillocheDirective ], imports: [ BrowserModule, @@ -43,11 +43,11 @@ import { GraphService } from './services/graph.service'; MomentModule, ], providers: [ - CanvasService, - HistoryService, - AnimationService, - MathService, - GraphService, + NlsCanvasService, + NlsHistoryService, + NlsAnimationService, + NlsMathService, + NlsGraphService, ], bootstrap: [AppComponent] }) diff --git a/src/app/components/graphs.component.html b/src/app/components/graphs.component.html index af23d1d..6466de1 100644 --- a/src/app/components/graphs.component.html +++ b/src/app/components/graphs.component.html @@ -1,6 +1,6 @@ - - - + + + diff --git a/src/app/components/graphs.component.scss b/src/app/components/graphs.component.scss index 7dec0f1..355bcc2 100644 --- a/src/app/components/graphs.component.scss +++ b/src/app/components/graphs.component.scss @@ -14,9 +14,9 @@ * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -svg { - // opacity: 0.4; -} +// svg { +// // opacity: 0.4; +// } // svg { // stroke-dasharray: 1000px; diff --git a/src/app/components/graphs.component.ts b/src/app/components/graphs.component.ts index 8e1c6ea..26ca08c 100644 --- a/src/app/components/graphs.component.ts +++ b/src/app/components/graphs.component.ts @@ -22,14 +22,13 @@ import * as Random from 'd3-random'; import * as Drag from 'd3-drag'; import { environment as env } from '../../environments/environment'; -import { CanvasService } from './../services/canvas.service'; -import { HistoryService } from './../services/history.service'; -import { AnimationService } from '../services/animation.service'; -import { MathService } from '../services/math.service'; -import { GuillocheDirective } from './../directives/guilloche.directive'; -import { Graph } from '../models/graph.model'; -import { Point } from '../models/point.model'; -import { GraphService } from '../services/graph.service'; +import { Graph } from './../../../projects/nls-guilloche/src/lib/models/graph.model'; +import { Point } from './../../../projects/nls-guilloche/src/lib/models/point.model'; +import { NlsCanvasService } from './../../../projects/nls-guilloche/src/lib/services/canvas.service'; +import { NlsHistoryService } from './../../../projects/nls-guilloche/src/lib/services/history.service'; +import { NlsMathService } from './../../../projects/nls-guilloche/src/lib/services/math.service'; +import { NlsGuillocheDirective } from './../../../projects/nls-guilloche/src/lib/directives/guilloche.directive'; +import { NlsGraphService } from './../../../projects/nls-guilloche/src/lib/services/graph.service'; @Component({ selector: 'app-graphs', @@ -63,11 +62,10 @@ export class GraphsComponent implements OnChanges, OnInit { } constructor( - private canvasService: CanvasService, - private historyService: HistoryService, - private animationService: AnimationService, - private math: MathService, - private graphService: GraphService + private canvasService: NlsCanvasService, + private historyService: NlsHistoryService, + private math: NlsMathService, + private graphService: NlsGraphService ) { this.genLoadedAllGraphs = this.countLoadedGraphs(); this.timer = interval(500); diff --git a/yarn.lock b/yarn.lock index 25274e3..2eea7fd 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4288,6 +4288,10 @@ mkdirp@0.5.x, "mkdirp@>=0.5 0", mkdirp@^0.5.0, mkdirp@^0.5.1, mkdirp@~0.5.0: dependencies: minimist "0.0.8" +moment@^2.22.2: + version "2.22.2" + resolved "https://registry.yarnpkg.com/moment/-/moment-2.22.2.tgz#3c257f9839fc0e93ff53149632239eb90783ff66" + move-concurrently@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/move-concurrently/-/move-concurrently-1.0.1.tgz#be2c005fda32e0b29af1f05d7c4b33214c701f92" @@ -4394,6 +4398,12 @@ ng-packagr@^3.0.0-rc.2: uglify-js "^3.0.7" update-notifier "^2.3.0" +ngx-moment@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/ngx-moment/-/ngx-moment-3.1.0.tgz#41380b4dd8b68e7bd6d17cc6fe7f703ae506dc3a" + dependencies: + tslib "^1.9.0" + no-case@^2.2.0: version "2.3.2" resolved "https://registry.yarnpkg.com/no-case/-/no-case-2.3.2.tgz#60b813396be39b3f1288a4c1ed5d1e7d28b464ac"