Stefan Huber

chore: changed build environment

This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
1 +export * from './player';
2 +export * from './program-manager';
3 +export * from './program-item/program-item';
4 +export * from './program-item/program-item-factory';
1 +"use strict";
2 +function __export(m) {
3 + for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
4 +}
5 +Object.defineProperty(exports, "__esModule", { value: true });
6 +__export(require("./player"));
7 +__export(require("./program-manager"));
8 +__export(require("./program-item/program-item"));
9 +__export(require("./program-item/program-item-factory"));
10 +//# sourceMappingURL=index.js.map
...\ No newline at end of file ...\ No newline at end of file
1 +{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;AAAA,8BAAyB;AACzB,uCAAkC;AAClC,iDAA4C;AAC5C,yDAAoD"}
...\ No newline at end of file ...\ No newline at end of file
1 +/// <reference types="node" />
2 +import { EventEmitter } from 'events';
3 +import { ProgramRepository } from './program-repository';
4 +import { ProgramManager } from './program-manager';
5 +export declare class Player extends EventEmitter {
6 + constructor();
7 + protected _programRepository: ProgramRepository;
8 + protected _programManager: ProgramManager;
9 + protected _minutesReplication: number;
10 + protected _replicationRetry: number;
11 + protected _currentProgramItemId: string;
12 + protected _currentReplicationCounter: number;
13 + protected _state: string;
14 + state: string;
15 + programManager: ProgramManager;
16 + programRepository: ProgramRepository;
17 + minutesReplication: number;
18 + replicationRetry: number;
19 + triggerReplication(): Promise<void>;
20 + triggerProgramItemId(changes?: boolean): void;
21 + trigger(func: Function, milliseconds?: number): void;
22 + start(): void;
23 + stop(): void;
24 +}
1 +"use strict";
2 +var __extends = (this && this.__extends) || (function () {
3 + var extendStatics = Object.setPrototypeOf ||
4 + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5 + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
6 + return function (d, b) {
7 + extendStatics(d, b);
8 + function __() { this.constructor = d; }
9 + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
10 + };
11 +})();
12 +Object.defineProperty(exports, "__esModule", { value: true });
13 +var events_1 = require("events");
14 +var util_1 = require("./util");
15 +var STATE_START = "start";
16 +var STATE_STOP = "stop";
17 +var Player = (function (_super) {
18 + __extends(Player, _super);
19 + function Player() {
20 + var _this = _super.call(this) || this;
21 + _this._minutesReplication = 3;
22 + _this._replicationRetry = 10000;
23 + _this._currentProgramItemId = '';
24 + _this._currentReplicationCounter = 0;
25 + _this._state = STATE_STOP;
26 + return _this;
27 + }
28 + Object.defineProperty(Player.prototype, "state", {
29 + set: function (st) {
30 + this._state = st;
31 + },
32 + enumerable: true,
33 + configurable: true
34 + });
35 + Object.defineProperty(Player.prototype, "programManager", {
36 + get: function () {
37 + return this._programManager;
38 + },
39 + set: function (pm) {
40 + this._programManager = pm;
41 + },
42 + enumerable: true,
43 + configurable: true
44 + });
45 + Object.defineProperty(Player.prototype, "programRepository", {
46 + get: function () {
47 + return this._programRepository;
48 + },
49 + set: function (pr) {
50 + this._programRepository = pr;
51 + },
52 + enumerable: true,
53 + configurable: true
54 + });
55 + Object.defineProperty(Player.prototype, "minutesReplication", {
56 + get: function () {
57 + return this._minutesReplication;
58 + },
59 + set: function (mr) {
60 + this._minutesReplication = mr;
61 + },
62 + enumerable: true,
63 + configurable: true
64 + });
65 + Object.defineProperty(Player.prototype, "replicationRetry", {
66 + get: function () {
67 + return this._replicationRetry;
68 + },
69 + set: function (rr) {
70 + this._replicationRetry = rr;
71 + },
72 + enumerable: true,
73 + configurable: true
74 + });
75 + Player.prototype.triggerReplication = function () {
76 + var _this = this;
77 + console.info("digsig-player-service: trigger replication");
78 + return this.programRepository.replicate()
79 + .then(function (changes) {
80 + _this._currentReplicationCounter = 0;
81 + _this.trigger(function () { _this.triggerProgramItemId(changes); });
82 + })
83 + .catch(function (error) {
84 + _this.trigger(function () { _this.triggerReplication(); }, _this.replicationRetry);
85 + _this.emit('error', error);
86 + });
87 + };
88 + Player.prototype.triggerProgramItemId = function (changes) {
89 + var _this = this;
90 + if (changes === void 0) { changes = false; }
91 + console.info("digsig-player-service: trigger program item id");
92 + this.programManager.getCurrentProgramItemId()
93 + .then(function (programItemId) {
94 + _this._currentReplicationCounter++;
95 + // if there is a new program item id trigger play
96 + // else (1) calculate next potential program change point
97 + // or (2) trigger replication
98 + if (programItemId && (programItemId != _this._currentProgramItemId || changes)) {
99 + _this._currentProgramItemId = programItemId;
100 + _this.emit('play', programItemId);
101 + }
102 + if (_this._currentReplicationCounter >= _this._minutesReplication) {
103 + _this.triggerReplication();
104 + }
105 + else {
106 + _this.trigger(function () { _this.triggerProgramItemId(); }, util_1.Util.calculateNextMinute());
107 + }
108 + });
109 + };
110 + Player.prototype.trigger = function (func, milliseconds) {
111 + if (milliseconds === void 0) { milliseconds = 0; }
112 + if (this._state === STATE_START) {
113 + setTimeout(function () { func(); }, milliseconds);
114 + }
115 + };
116 + Player.prototype.start = function () {
117 + if (this._state === STATE_STOP) {
118 + this.triggerReplication();
119 + this._state = STATE_START;
120 + }
121 + };
122 + Player.prototype.stop = function () {
123 + this._state = STATE_STOP;
124 + };
125 + return Player;
126 +}(events_1.EventEmitter));
127 +exports.Player = Player;
128 +//# sourceMappingURL=player.js.map
...\ No newline at end of file ...\ No newline at end of file
1 +{"version":3,"file":"player.js","sourceRoot":"","sources":["../src/player.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,iCAAsC;AAGtC,+BAA4B;AAE5B,IAAM,WAAW,GAAG,OAAO,CAAC;AAC5B,IAAM,UAAU,GAAI,MAAM,CAAC;AAE3B;IAA4B,0BAAY;IAEpC;QAAA,YACI,iBAAO,SACV;QAIS,yBAAmB,GAAU,CAAC,CAAC;QAC/B,uBAAiB,GAAU,KAAK,CAAC;QAEjC,2BAAqB,GAAU,EAAE,CAAC;QAClC,gCAA0B,GAAU,CAAC,CAAC;QACtC,YAAM,GAAG,UAAU,CAAC;;IAT9B,CAAC;IAWD,sBAAI,yBAAK;aAAT,UAAU,EAAS;Y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AI,CAAC,MAAM,KAAK,UAAU,CAAC,CAAC,CAAC;YAC7B,IAAI,CAAC,kBAAkB,EAAE,CAAC;YAC1B,IAAI,CAAC,MAAM,GAAG,WAAW,CAAC;QAC9B,CAAC;IACL,CAAC;IAED,qBAAI,GAAJ;QACI,IAAI,CAAC,MAAM,GAAG,UAAU,CAAC;IAC7B,CAAC;IAEL,aAAC;AAAD,CAAC,AA1GD,CAA4B,qBAAY,GA0GvC;AA1GY,wBAAM"}
...\ No newline at end of file ...\ No newline at end of file
1 +import { ProgramItem } from './program-item';
2 +import { ProgramRepository } from './../program-repository';
3 +export declare class ProgramItemFactory {
4 + protected _programRepository: ProgramRepository;
5 + protected _basePath: string;
6 + basePath: string;
7 + programRepository: ProgramRepository;
8 + getProgramItem(programItemId: string): Promise<ProgramItem>;
9 + prepareProgramItem(type: string, data: any): Promise<ProgramItem>;
10 + prepareSlideshowItem(programItem: ProgramItem, data: any): Promise<ProgramItem>;
11 + prepareVideoItem(programItem: ProgramItem, data: any): Promise<ProgramItem>;
12 +}
1 +"use strict";
2 +Object.defineProperty(exports, "__esModule", { value: true });
3 +var program_item_1 = require("./program-item");
4 +var ProgramItemFactory = (function () {
5 + function ProgramItemFactory() {
6 + }
7 + Object.defineProperty(ProgramItemFactory.prototype, "basePath", {
8 + get: function () {
9 + return this._basePath;
10 + },
11 + set: function (bp) {
12 + this._basePath = bp;
13 + },
14 + enumerable: true,
15 + configurable: true
16 + });
17 + Object.defineProperty(ProgramItemFactory.prototype, "programRepository", {
18 + get: function () {
19 + return this._programRepository;
20 + },
21 + set: function (pr) {
22 + this._programRepository = pr;
23 + },
24 + enumerable: true,
25 + configurable: true
26 + });
27 + ProgramItemFactory.prototype.getProgramItem = function (programItemId) {
28 + var _this = this;
29 + return this.programRepository
30 + .findById(programItemId)
31 + .then(function (programItem) {
32 + return _this.prepareProgramItem(programItem.program_item_type, programItem);
33 + });
34 + };
35 + ProgramItemFactory.prototype.prepareProgramItem = function (type, data) {
36 + var programItem = new program_item_1.ProgramItem();
37 + programItem.type = type;
38 + if (data.infoboxes) {
39 + programItem.data.infoboxes = data.infoboxes;
40 + }
41 + if (type === program_item_1.PROGRAM_ITEM_TYPE_VIDEO) {
42 + return this.prepareVideoItem(programItem, data);
43 + }
44 + else if (type === program_item_1.PROGRAM_ITEM_TYPE_SLIDESHOW) {
45 + return this.prepareSlideshowItem(programItem, data);
46 + }
47 + else {
48 + return null;
49 + }
50 + };
51 + ProgramItemFactory.prototype.prepareSlideshowItem = function (programItem, data) {
52 + var _this = this;
53 + return this._programRepository.findByIds(data.images)
54 + .then(function (images) {
55 + programItem.data.speed = data.settings.speed;
56 + programItem.data.effect = data.settings.effect;
57 + programItem.data.images = [];
58 + if (images && images.length > 0) {
59 + for (var _i = 0, images_1 = images; _i < images_1.length; _i++) {
60 + var image = images_1[_i];
61 + if (image && image.filename) {
62 + programItem.data.images.push(_this.basePath + image.filename);
63 + }
64 + }
65 + }
66 + return programItem;
67 + });
68 + };
69 + ProgramItemFactory.prototype.prepareVideoItem = function (programItem, data) {
70 + var _this = this;
71 + return this._programRepository.findById(data.video)
72 + .then(function (data) {
73 + programItem.data.video = _this.basePath + data['filename'];
74 + return programItem;
75 + });
76 + };
77 + return ProgramItemFactory;
78 +}());
79 +exports.ProgramItemFactory = ProgramItemFactory;
80 +//# sourceMappingURL=program-item-factory.js.map
...\ No newline at end of file ...\ No newline at end of file
1 +{"version":3,"file":"program-item-factory.js","sourceRoot":"","sources":["../../src/program-item/program-item-factory.ts"],"names":[],"mappings":";;AAAA,+CAAkG;AAGlG;IAAA;IAyEA,CAAC;IApEG,sBAAI,wCAAQ;aAIZ;YACI,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC;QAC1B,CAAC;aAND,UAAa,EAAS;YAClB,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;QACxB,CAAC;;;OAAA;IAMD,sBAAI,iDAAiB;aAIrB;YACI,MAAM,CAAC,IAAI,CAAC,kBAAkB,CAAC;QACnC,C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GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC;YAC7C,WAAW,CAAC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;YAC/C,WAAW,CAAC,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;YAE7B,EAAE,CAAC,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;gBAC9B,GAAG,CAAC,CAAc,UAAM,EAAN,iBAAM,EAAN,oBAAM,EAAN,IAAM;oBAAnB,IAAI,KAAK,eAAA;oBACV,EAAE,CAAC,CAAC,KAAK,IAAI,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;wBAC1B,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAI,CAAC,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAC;oBACjE,CAAC;iBACJ;YACL,CAAC;YAED,MAAM,CAAC,WAAW,CAAC;QACvB,CAAC,CAAC,CAAC;IACX,CAAC;IAED,6CAAgB,GAAhB,UAAiB,WAAuB,EAAE,IAAQ;QAAlD,iBAMC;QALG,MAAM,CAAC,IAAI,CAAC,kBAAkB,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC;aAC9C,IAAI,CAAC,UAAC,IAAI;YACP,WAAW,CAAC,IAAI,CAAC,KAAK,GAAG,KAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC;YAC1D,MAAM,CAAC,WAAW,CAAC;QACvB,CAAC,CAAC,CAAC;IACX,CAAC;IAEL,yBAAC;AAAD,CAAC,AAzED,IAyEC;AAzEY,gDAAkB"}
...\ No newline at end of file ...\ No newline at end of file
1 +export declare const PROGRAM_ITEM_TYPE_SLIDESHOW = "slideshow";
2 +export declare const PROGRAM_ITEM_TYPE_VIDEO = "video";
3 +export declare class ProgramItem {
4 + protected _type: string;
5 + protected _data: any;
6 + type: string;
7 + data: any;
8 +}
1 +"use strict";
2 +Object.defineProperty(exports, "__esModule", { value: true });
3 +exports.PROGRAM_ITEM_TYPE_SLIDESHOW = "slideshow";
4 +exports.PROGRAM_ITEM_TYPE_VIDEO = "video";
5 +var ProgramItem = (function () {
6 + function ProgramItem() {
7 + this._type = "";
8 + this._data = {};
9 + }
10 + Object.defineProperty(ProgramItem.prototype, "type", {
11 + get: function () {
12 + return this._type;
13 + },
14 + set: function (t) {
15 + this._type = t;
16 + },
17 + enumerable: true,
18 + configurable: true
19 + });
20 + Object.defineProperty(ProgramItem.prototype, "data", {
21 + get: function () {
22 + return this._data;
23 + },
24 + set: function (d) {
25 + this._data = d;
26 + },
27 + enumerable: true,
28 + configurable: true
29 + });
30 + return ProgramItem;
31 +}());
32 +exports.ProgramItem = ProgramItem;
33 +//# sourceMappingURL=program-item.js.map
...\ No newline at end of file ...\ No newline at end of file
1 +{"version":3,"file":"program-item.js","sourceRoot":"","sources":["../../src/program-item/program-item.ts"],"names":[],"mappings":";;AAAa,QAAA,2BAA2B,GAAG,WAAW,CAAC;AAC1C,QAAA,uBAAuB,GAAG,OAAO,CAAC;AAE/C;IAAA;QAEc,UAAK,GAAU,EAAE,CAAC;QAClB,UAAK,GAAO,EAAE,CAAC;IAkB7B,CAAC;IAhBG,sBAAI,6BAAI;aAIR;YACI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC;QACtB,CAAC;aAND,UAAS,CAAQ;YACb,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;QACnB,CAAC;;;OAAA;IAMD,sBAAI,6BAAI;aAIR;YACI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC;QACtB,CAAC;aAND,UAAS,CAAK;YACV,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;QACnB,CAAC;;;OAAA;IAML,kBAAC;AAAD,CAAC,AArBD,IAqBC;AArBY,kCAAW"}
...\ No newline at end of file ...\ No newline at end of file
1 +import { ProgramRepository } from './program-repository';
2 +export declare class ProgramManager {
3 + protected _programRepository: ProgramRepository;
4 + programRepository: ProgramRepository;
5 + getCurrentProgramItemId(): Promise<string>;
6 + /**
7 + * find program item in schedule, which fits
8 + * according to current hh:mm
9 + */
10 + findCurrentProgramItem(schedule: any, dateInMinutes: number): string;
11 + /**
12 + * Find the program segment
13 + * This is dependent on the date set on the device
14 + */
15 + findCurrentProgramSegment(): Promise<any>;
16 +}
1 +"use strict";
2 +Object.defineProperty(exports, "__esModule", { value: true });
3 +var util_1 = require("./util");
4 +var ProgramManager = (function () {
5 + function ProgramManager() {
6 + }
7 + Object.defineProperty(ProgramManager.prototype, "programRepository", {
8 + get: function () {
9 + return this._programRepository;
10 + },
11 + set: function (pr) {
12 + this._programRepository = pr;
13 + },
14 + enumerable: true,
15 + configurable: true
16 + });
17 + ProgramManager.prototype.getCurrentProgramItemId = function () {
18 + var _this = this;
19 + return new Promise(function (resolve, reject) {
20 + _this.findCurrentProgramSegment().then(function (programSegment) {
21 + var currentProgramItemId = programSegment.default;
22 + if (programSegment.schedule) {
23 + currentProgramItemId = _this.findCurrentProgramItem(programSegment.schedule, util_1.Util.getDateInMinutes());
24 + }
25 + resolve(currentProgramItemId);
26 + });
27 + });
28 + };
29 + /**
30 + * find program item in schedule, which fits
31 + * according to current hh:mm
32 + */
33 + ProgramManager.prototype.findCurrentProgramItem = function (schedule, dateInMinutes) {
34 + var timeList = [];
35 + var tmpSchedule = {};
36 + dateInMinutes--; // make it not so strict, which will start one minute earlier
37 + for (var startTime in schedule) {
38 + if (schedule.hasOwnProperty(startTime)) {
39 + var minutes = util_1.Util.convertToMinutes(startTime);
40 + timeList.push(minutes);
41 + tmpSchedule[minutes] = schedule[startTime];
42 + }
43 + }
44 + // sort ascending (-)
45 + timeList.sort(function (a, b) { return a - b; });
46 + var last = 0;
47 + for (var i = 0; i < timeList.length; i++) {
48 + if (timeList[i] <= dateInMinutes) {
49 + last = timeList[i];
50 + }
51 + else {
52 + break;
53 + }
54 + }
55 + return tmpSchedule[last];
56 + };
57 + /**
58 + * Find the program segment
59 + * This is dependent on the date set on the device
60 + */
61 + ProgramManager.prototype.findCurrentProgramSegment = function () {
62 + var _this = this;
63 + return new Promise(function (resolve, reject) {
64 + var today = util_1.Util.getISODate();
65 + _this.programRepository.findByType('program')
66 + .then(function (programs) {
67 + if (programs.length > 0) {
68 + var program = programs[0];
69 + var programSegmentId = void 0;
70 + // if there is a program_segment for today else default
71 + if (program.schedule && program.schedule[today]) {
72 + programSegmentId = program.schedule[today];
73 + }
74 + else {
75 + programSegmentId = program.default;
76 + }
77 + _this.programRepository
78 + .findById(programSegmentId)
79 + .then(function (programSegment) {
80 + resolve(programSegment);
81 + }).catch(function (error) {
82 + reject("program segment not found");
83 + });
84 + }
85 + else {
86 + reject('No Program found');
87 + }
88 + }).catch(function (error) {
89 + reject(error);
90 + });
91 + });
92 + };
93 + return ProgramManager;
94 +}());
95 +exports.ProgramManager = ProgramManager;
96 +//# sourceMappingURL=program-manager.js.map
...\ No newline at end of file ...\ No newline at end of file
1 +{"version":3,"file":"program-manager.js","sourceRoot":"","sources":["../src/program-manager.ts"],"names":[],"mappings":";;AACA,+BAA4B;AAG5B;IAAA;IA+FA,CAAC;IA3FG,sBAAI,6CAAiB;aAIrB;YACI,MAAM,CAAC,IAAI,CAAC,kBAAkB,CAAC;QACnC,CAAC;aAND,UAAsB,EAAoB;YACtC,IAAI,CAAC,kBAAkB,GAAG,EAAE,CAAC;QACjC,CAAC;;;OAAA;IAMD,gDAAuB,GAAvB;QAAA,iBAUC;QATG,MAAM,CAAC,IAAI,OAAO,CAAU,UAAC,OAAO,EAAE,MAAM;YACxC,KAAI,CAAC,yBAAyB,EAAE,CAAC,IAAI,CAAC,UAAA,cAAc;gBAChD,IAAI,oBAAoB,GAAG,cAAc,CAAC,OAAO,CAAC;gBAClD,EAAE,CAAC,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,CAAC;oBAC1B,oBAAoB,GAAG,KAAI,CAAC,sBAAsB,CAAC,cAAc,CAAC,QAAQ,EAAE,WAAI,CAAC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"}
...\ No newline at end of file ...\ No newline at end of file
1 +export interface ProgramRepository {
2 + findById(id: string): Promise<any>;
3 + findByIds(ids: Array<string>): Promise<Array<any>>;
4 + findByType(type: string): Promise<Array<any>>;
5 + /**
6 + * returns true / false depending on if there where any changes to download
7 + */
8 + replicate(): Promise<boolean>;
9 +}
1 +"use strict";
2 +Object.defineProperty(exports, "__esModule", { value: true });
3 +//# sourceMappingURL=program-repository.js.map
...\ No newline at end of file ...\ No newline at end of file
1 +{"version":3,"file":"program-repository.js","sourceRoot":"","sources":["../src/program-repository.ts"],"names":[],"mappings":""}
...\ No newline at end of file ...\ No newline at end of file
1 +export declare class Util {
2 + static getISODate(): string;
3 + static getDateInMinutes(): number;
4 + /**
5 + * convert a time input to minutes
6 + * e.g. 23:59 = 1439
7 + */
8 + static convertToMinutes(time: string): number;
9 + static calculateNextMinute(): number;
10 +}
1 +"use strict";
2 +Object.defineProperty(exports, "__esModule", { value: true });
3 +var Util = (function () {
4 + function Util() {
5 + }
6 + Util.getISODate = function () {
7 + return (new Date()).toISOString().slice(0, 10);
8 + };
9 + Util.getDateInMinutes = function () {
10 + var now = new Date();
11 + return (now.getHours() * 60) + now.getMinutes();
12 + };
13 + /**
14 + * convert a time input to minutes
15 + * e.g. 23:59 = 1439
16 + */
17 + Util.convertToMinutes = function (time) {
18 + var times = time.split(":");
19 + var convered = (parseInt(times[0]) * 60) + parseInt(times[1]);
20 + return (convered >= 0 && convered <= 1439) ? convered : 0;
21 + };
22 + Util.calculateNextMinute = function () {
23 + return (60 - (Math.round((new Date()).getTime() / 1000) % 60)) * 1000;
24 + };
25 + return Util;
26 +}());
27 +exports.Util = Util;
28 +//# sourceMappingURL=util.js.map
...\ No newline at end of file ...\ No newline at end of file
1 +{"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":";;AAAA;IAAA;IAyBA,CAAC;IAvBU,eAAU,GAAjB;QACI,MAAM,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,CAAC,EAAC,EAAE,CAAC,CAAC;IAClD,CAAC;IAEM,qBAAgB,GAAvB;QACI,IAAI,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;QACrB,MAAM,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,GAAG,EAAE,CAAC,GAAG,GAAG,CAAC,UAAU,EAAE,CAAC;IACpD,CAAC;IAED;;;OAGG;IACI,qBAAgB,GAAvB,UAAwB,IAAW;QAC/B,IAAI,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC5B,IAAI,QAAQ,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QAC9D,MAAM,CAAC,CAAC,QAAQ,IAAI,CAAC,IAAI,QAAQ,IAAI,IAAI,CAAC,GAAG,QAAQ,GAAG,CAAC,CAAC;IAC9D,CAAC;IAEM,wBAAmB,GAA1B;QACI,MAAM,CAAC,CAAC,EAAE,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC;IAC1E,CAAC;IAEL,WAAC;AAAD,CAAC,AAzBD,IAyBC;AAzBY,oBAAI"}
...\ No newline at end of file ...\ No newline at end of file
1 -interface ProgramRepository {
2 - findById(id:string) : Promise<any>;
3 - findByIds(ids:Array<string>) : Promise<Array<any>>;
4 - findByType(type:string) : Promise<Array<any>>;
5 - replicate() : Promise<boolean>;
6 -}
7 -
8 -interface Player {
9 - new() : Player;
10 -
11 - on(name:string, any);
12 - once(name:string, any);
13 -
14 - start() : void;
15 - stop() : void;
16 -
17 - programRepository: ProgramRepository;
18 - programManager: ProgramManager;
19 -}
20 -
21 -interface ProgramManager {
22 - new() : ProgramManager;
23 -
24 - programRepository: ProgramRepository;
25 -}
26 -
27 -interface ProgramItemFactory {
28 - new() : ProgramItemFactory;
29 - getProgramItem(programItemId:string) : Promise<any>;
30 -
31 - basePath: string;
32 - programRepository: ProgramRepository;
33 -}
34 -
35 -declare var digsigPlayer: {
36 - ProgramRepository: ProgramRepository,
37 - ProgramManager: ProgramManager,
38 - Player : Player,
39 - ProgramItemFactory: ProgramItemFactory
40 -};
41 -
42 -declare module "digsig-player-service" {
43 - export = digsigPlayer;
44 -}
...\ No newline at end of file ...\ No newline at end of file
...@@ -2,26 +2,22 @@ ...@@ -2,26 +2,22 @@
2 "name": "digsig-player-service", 2 "name": "digsig-player-service",
3 "version": "1.0.0", 3 "version": "1.0.0",
4 "description": "", 4 "description": "",
5 - "main": "build/bundle.js", 5 + "main": "dist/index.js",
6 - "types": "index.d.ts", 6 + "module": "dist/index.js",
7 + "typings": "dist/index.d.ts",
7 "scripts": { 8 "scripts": {
8 - "pretest": "tsc --target es5 --outDir .tmp spec/index.ts", 9 + "pretest": "tsc --noImplicitAny false -p ./spec",
9 "test": "jasmine .tmp/spec/index.js", 10 "test": "jasmine .tmp/spec/index.js",
10 - "posttest": "rm -rf .tmp", 11 + "posttest": "npm run clean",
11 - "build:tsc": "rollup -c rollup.config.js" 12 + "build": "npm run clean && tsc",
13 + "clean": "rm -rf .tmp && rm -rf dist"
12 }, 14 },
13 "author": "Stefan Huber <stefan.huber@beyondit.at>", 15 "author": "Stefan Huber <stefan.huber@beyondit.at>",
14 "license": "ISC", 16 "license": "ISC",
15 "devDependencies": { 17 "devDependencies": {
16 - "@types/es6-promise": "0.0.32", 18 + "@types/jasmine": "^2.5.47",
17 - "@types/jasmine": "^2.5.41", 19 + "@types/node": "^7.0.22",
18 - "@types/node": "^7.0.0", 20 + "jasmine": "^2.6.0",
19 - "jasmine": "^2.5.3", 21 + "typescript": "^2.3.3"
20 - "rollup": "^0.41.4",
21 - "rollup-plugin-commonjs": "^7.0.0",
22 - "rollup-plugin-node-builtins": "^2.0.0",
23 - "rollup-plugin-node-globals": "^1.1.0",
24 - "rollup-plugin-typescript": "^0.8.1",
25 - "typescript": "^2.1.5"
26 } 22 }
27 } 23 }
......
1 -var typescript = require('rollup-plugin-typescript');
2 -var builtins = require('rollup-plugin-node-builtins');
3 -var globals = require('rollup-plugin-node-globals');
4 -
5 -var rollupConfig = {
6 -
7 - moduleName : 'digsig',
8 -
9 - entry: 'src/index.ts',
10 -
11 - sourceMap: true,
12 -
13 - format: 'cjs',
14 -
15 - dest: 'build/bundle.js',
16 -
17 - plugins: [
18 - // builtins(),
19 - // globals(),
20 - typescript()
21 - ]
22 -
23 -};
24 -
25 -module.exports = rollupConfig;
...\ No newline at end of file ...\ No newline at end of file
1 +{
2 + "compilerOptions": {
3 + "target": "es5",
4 + "module": "commonjs",
5 + "moduleResolution": "node",
6 + "sourceMap": false,
7 + "emitDecoratorMetadata": true,
8 + "experimentalDecorators": true,
9 + "lib": [ "es2015", "dom" ],
10 + "noImplicitAny": true,
11 + "suppressImplicitAnyIndexErrors": true,
12 + "outDir": "../.tmp"
13 + }
14 +}
...\ No newline at end of file ...\ No newline at end of file
1 +{
2 + "compilerOptions": {
3 + "allowSyntheticDefaultImports": true,
4 + "declaration": true,
5 + "experimentalDecorators": true,
6 + "emitDecoratorMetadata": true,
7 + "lib": ["dom", "es2015"],
8 + "noImplicitAny": false,
9 + "outDir": "./dist/",
10 + "target": "es5",
11 + "sourceMap": true
12 + },
13 + "exclude": [
14 + "node_modules",
15 + "spec"
16 + ]
17 +}
...\ No newline at end of file ...\ No newline at end of file