ngx-emfular-integration 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"ngx-emfular-integration.mjs","sources":["../../../projects/ngx-emfular-integration/src/lib/ngx-emfular-integration.service.ts","../../../projects/ngx-emfular-integration/src/lib/ngx-emfular-integration.component.ts","../../../projects/ngx-emfular-integration/src/lib/model.service.ts","../../../projects/ngx-emfular-integration/src/public-api.ts","../../../projects/ngx-emfular-integration/src/ngx-emfular-integration.ts"],"sourcesContent":["import { Injectable } from '@angular/core';\n\n@Injectable({\n providedIn: 'root'\n})\nexport class NgxEmfularIntegrationService {\n\n constructor() { }\n}\n","import { Component } from '@angular/core';\n\n@Component({\n selector: 'lib-ngx-emfular-integration',\n imports: [],\n template: `\n <p>\n ngx-emfular-integration works!\n </p>\n `,\n styles: ``\n})\nexport class NgxEmfularIntegrationComponent {\n\n}\n","import {Inject, Injectable, InjectionToken} from '@angular/core';\nimport {JsonOf, Referencable} from \"emfular\";\nimport {HistoryService, IoService} from \"ngx-emfular-helper\";\n\nexport const HISTORY_SERVICE = new InjectionToken<HistoryService<any>>(\n 'HistoryService'\n);\nexport function provideHistoryForModel<M>(\n prefix: string = 'history_',\n bufferSize: number = 50\n) {\n return {\n provide: HISTORY_SERVICE,\n useFactory: () => new HistoryService<JsonOf<M>>(prefix, bufferSize)\n };\n}\n\n\n@Injectable({\n providedIn: 'root'\n})\nexport abstract class ModelService<M extends Referencable<any>> {\n\n protected _model!: M\n get model(): M {\n return this._model;\n }\n\n abstract fileTitle(): string // either a fixed string or sth from the current model itself\n\n // M.fromJson(modelJson) plus any convenience /graphical organization necessary\n abstract deserialize(modelJson: JsonOf<M>): M\n\n protected constructor(\n @Inject(HISTORY_SERVICE) private readonly historyService: HistoryService<JsonOf<M>>,\n private ioService: IoService\n ) {\n //should actually initialize a model:this._model = new M;\n this.historyService.state$.subscribe(state => {\n if (state) {\n this.deserialize(state);\n }\n });\n }\n\n serialize(): JsonOf<M> {\n return this.model.toJson()\n }\n\n saveCurrentState() {\n this.historyService.save(this.serialize())\n }\n\n protected applyModel(modelJson: JsonOf<M>): M {\n let m: M = this.deserialize(modelJson);\n this._model = m;\n return m;\n }\n\n load(modelJson: JsonOf<M>): M {\n const model = this.applyModel(modelJson);\n this.saveCurrentState()\n return model;\n }\n\n loadFromFile(event: Event) {\n this.ioService.loadStringFromFile(event).then(txt => {\n //todo insert detection code for wrong files (no json, not appropriately structured\n this.load(JSON.parse(txt));\n });\n }\n\n save() {\n const jsonString = JSON.stringify(this.serialize());\n this.ioService.saveJson(jsonString, this.fileTitle())\n }\n\n}\n","/*\n * Public API Surface of ngx-emfular-integration\n */\n\nexport * from './lib/ngx-emfular-integration.service';\nexport * from './lib/ngx-emfular-integration.component';\nexport * from './lib/model.service';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;MAKa,4BAA4B,CAAA;AAEvC,IAAA,WAAA,GAAA;uGAFW,4BAA4B,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA;AAA5B,IAAA,OAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,4BAA4B,cAF3B,MAAM,EAAA,CAAA;;2FAEP,4BAA4B,EAAA,UAAA,EAAA,CAAA;kBAHxC,UAAU;AAAC,YAAA,IAAA,EAAA,CAAA;AACV,oBAAA,UAAU,EAAE;AACb,iBAAA;;;MCQY,8BAA8B,CAAA;uGAA9B,8BAA8B,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA;AAA9B,IAAA,OAAA,IAAA,GAAA,EAAA,CAAA,oBAA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AC,YAAA,IAAA,EAAA,CAAA;AACV,oBAAA,UAAU,EAAE;AACb,iBAAA;;0BAcM,MAAM;2BAAC,eAAe;;;AClC7B;;AAEG;;ACFH;;AAEG;;;;"}
1
+ {"version":3,"file":"ngx-emfular-integration.mjs","sources":["../../../projects/ngx-emfular-integration/src/lib/ngx-emfular-integration.service.ts","../../../projects/ngx-emfular-integration/src/lib/ngx-emfular-integration.component.ts","../../../projects/ngx-emfular-integration/src/lib/model.service.ts","../../../projects/ngx-emfular-integration/src/public-api.ts","../../../projects/ngx-emfular-integration/src/ngx-emfular-integration.ts"],"sourcesContent":["import { Injectable } from '@angular/core';\n\n@Injectable({\n providedIn: 'root'\n})\nexport class NgxEmfularIntegrationService {\n\n constructor() { }\n}\n","import { Component } from '@angular/core';\n\n@Component({\n selector: 'lib-ngx-emfular-integration',\n imports: [],\n template: `\n <p>\n ngx-emfular-integration works!\n </p>\n `,\n styles: ``\n})\nexport class NgxEmfularIntegrationComponent {\n\n}\n","import {Inject, Injectable, InjectionToken} from '@angular/core';\nimport {JsonOf, Referencable} from \"emfular\";\nimport {HistoryService, IoService} from \"ngx-emfular-helper\";\n\nexport const HISTORY_SERVICE = new InjectionToken<HistoryService<any>>(\n 'HistoryService'\n);\nexport function provideHistoryForModel<M>(\n prefix: string = 'history_',\n bufferSize: number = 50\n) {\n return {\n provide: HISTORY_SERVICE,\n useFactory: () => new HistoryService<JsonOf<M>>(prefix, bufferSize)\n };\n}\n\n\n@Injectable({\n providedIn: 'root'\n})\nexport abstract class ModelService<M extends Referencable<any>> {\n\n protected _model!: M\n get model(): M {\n return this._model;\n }\n\n abstract fileTitle(): string // either a fixed string or sth from the current model itself\n\n // M.fromJson(modelJson) plus any convenience /graphical organization necessary\n abstract deserialize(modelJson: JsonOf<M>): M\n\n protected constructor(\n @Inject(HISTORY_SERVICE) readonly historyService: HistoryService<JsonOf<M>>,\n readonly ioService: IoService\n ) {\n //should actually initialize a model:this._model = new M;\n this.historyService.state$.subscribe(state => {\n if (state) {\n this.deserialize(state);\n }\n });\n }\n\n serialize(): JsonOf<M> {\n return this.model.toJson()\n }\n\n saveCurrentState() {\n this.historyService.save(this.serialize())\n }\n\n protected applyModel(modelJson: JsonOf<M>): M {\n let m: M = this.deserialize(modelJson);\n this._model = m;\n return m;\n }\n\n load(modelJson: JsonOf<M>): M {\n const model = this.applyModel(modelJson);\n this.saveCurrentState()\n return model;\n }\n\n loadFromFile(event: Event) {\n this.ioService.loadStringFromFile(event).then(txt => {\n //todo insert detection code for wrong files (no json, not appropriately structured\n this.load(JSON.parse(txt));\n });\n }\n\n save() {\n const jsonString = JSON.stringify(this.serialize());\n this.ioService.saveJson(jsonString, this.fileTitle())\n }\n\n}\n","/*\n * Public API Surface of ngx-emfular-integration\n */\n\nexport * from './lib/ngx-emfular-integration.service';\nexport * from './lib/ngx-emfular-integration.component';\nexport * from './lib/model.service';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;MAKa,4BAA4B,CAAA;AAEvC,IAAA,WAAA,GAAA;uGAFW,4BAA4B,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA;AAA5B,IAAA,OAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,4BAA4B,cAF3B,MAAM,EAAA,CAAA;;2FAEP,4BAA4B,EAAA,UAAA,EAAA,CAAA;kBAHxC,UAAU;AAAC,YAAA,IAAA,EAAA,CAAA;AACV,oBAAA,UAAU,EAAE;AACb,iBAAA;;;MCQY,8BAA8B,CAAA;uGAA9B,8BAA8B,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA;AAA9B,IAAA,OAAA,IAAA,GAAA,EAAA,CAAA,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;AAAC,YAAA,IAAA,EAAA,CAAA;AACV,oBAAA,UAAU,EAAE;AACb,iBAAA;;0BAcM,MAAM;2BAAC,eAAe;;;AClC7B;;AAEG;;ACFH;;AAEG;;;;"}
@@ -8,8 +8,8 @@ export declare function provideHistoryForModel<M>(prefix?: string, bufferSize?:
8
8
  useFactory: () => HistoryService<JsonOf<M>>;
9
9
  };
10
10
  export declare abstract class ModelService<M extends Referencable<any>> {
11
- private readonly historyService;
12
- private ioService;
11
+ readonly historyService: HistoryService<JsonOf<M>>;
12
+ readonly ioService: IoService;
13
13
  protected _model: M;
14
14
  get model(): M;
15
15
  abstract fileTitle(): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ngx-emfular-integration",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "Integrates emfular with its ngx-helper to provide modeling services",
5
5
  "keywords": [
6
6
  "EMFular",