From e3f09260c0277df4d76ea560f7d7accb2413b57d Mon Sep 17 00:00:00 2001 From: Piotr Smialkowski Date: Sat, 10 Nov 2018 15:03:10 +0100 Subject: [PATCH] [all] Add command prepare and fix builids --- packages/sjs-core/package.json | 3 +- packages/sjs-di/package.json | 3 +- packages/sjs-dom/package.json | 3 +- packages/sjs-events/package.json | 3 +- packages/sjs-logging/package.json | 3 +- packages/sjs-logging/types/consts.d.ts | 10 +++--- packages/sjs-logging/types/filter.d.ts | 20 ++---------- packages/sjs-logging/types/handler.d.ts | 23 ------------- packages/sjs-logging/types/handlers.d.ts | 8 +---- packages/sjs-logging/types/index.d.ts | 2 +- packages/sjs-logging/types/logger.d.ts | 10 +++--- packages/sjs-logging/types/manager.d.ts | 2 +- packages/sjs-query/package.json | 3 +- packages/sjs-query/types/criterias.d.ts | 14 -------- packages/sjs-query/types/filters.d.ts | 2 +- packages/sjs-query/types/squery.d.ts | 1 - packages/sjs-sm/package.json | 3 +- packages/sjs-stream/package.json | 3 +- packages/sjs-stream/types/controller.d.ts | 23 +++++++++++++ packages/sjs-stream/types/index.d.ts | 11 +++++++ packages/sjs-stream/types/interfaces.d.ts | 39 +++++++++++++++++++++++ packages/sjs-stream/types/stream.d.ts | 21 ++++++++++++ packages/sjs-stream/types/utils.d.ts | 5 +++ 23 files changed, 131 insertions(+), 84 deletions(-) delete mode 100644 packages/sjs-logging/types/handler.d.ts delete mode 100644 packages/sjs-query/types/criterias.d.ts delete mode 100644 packages/sjs-query/types/squery.d.ts create mode 100644 packages/sjs-stream/types/controller.d.ts create mode 100644 packages/sjs-stream/types/index.d.ts create mode 100644 packages/sjs-stream/types/interfaces.d.ts create mode 100644 packages/sjs-stream/types/stream.d.ts create mode 100644 packages/sjs-stream/types/utils.d.ts diff --git a/packages/sjs-core/package.json b/packages/sjs-core/package.json index d1ef82b..f5656e9 100644 --- a/packages/sjs-core/package.json +++ b/packages/sjs-core/package.json @@ -18,7 +18,8 @@ "build:exts": "renamer --path-element ext --find js --replace mjs dist/esm/*", "test": "qunit --require ts-node/register tests/*", "karma": "karma start --single-run", - "lint": "eslint tests && tslint src/*" + "lint": "eslint tests && tslint src/*", + "prepare": "npm run build" }, "files": [ "README.md", diff --git a/packages/sjs-di/package.json b/packages/sjs-di/package.json index 32a24c0..fe2a848 100644 --- a/packages/sjs-di/package.json +++ b/packages/sjs-di/package.json @@ -18,7 +18,8 @@ "build:exts": "renamer --path-element ext --find js --replace mjs dist/esm/*", "test": "qunit --require ts-node/register tests/*", "karma": "karma start --single-run", - "lint": "eslint tests && tslint src/*" + "lint": "eslint tests && tslint src/*", + "prepare": "npm run build" }, "files": [ "README.md", diff --git a/packages/sjs-dom/package.json b/packages/sjs-dom/package.json index b1fb5a4..1c29cbb 100644 --- a/packages/sjs-dom/package.json +++ b/packages/sjs-dom/package.json @@ -16,7 +16,8 @@ "build:clean": "rm -rf dist/ && rm -rf types", "build:tsc": "tsc && tsc -p tsconfig.esm.json", "build:exts": "renamer --path-element ext --find js --replace mjs dist/esm/*", - "lint": "tslint src/*" + "lint": "tslint src/*", + "prepare": "npm run build" }, "files": [ "README.md", diff --git a/packages/sjs-events/package.json b/packages/sjs-events/package.json index 070ceec..ac4ff09 100644 --- a/packages/sjs-events/package.json +++ b/packages/sjs-events/package.json @@ -18,7 +18,8 @@ "build:exts": "renamer --path-element ext --find js --replace mjs dist/esm/*", "test": "qunit --require ts-node/register tests/*", "karma": "karma start --single-run", - "lint": "eslint tests && tslint src/*" + "lint": "eslint tests && tslint src/*", + "prepare": "npm run build" }, "files": [ "README.md", diff --git a/packages/sjs-logging/package.json b/packages/sjs-logging/package.json index 119de56..155b749 100644 --- a/packages/sjs-logging/package.json +++ b/packages/sjs-logging/package.json @@ -18,7 +18,8 @@ "build:exts": "renamer --path-element ext --find js --replace mjs dist/esm/*", "test": "qunit --require ts-node/register tests/*", "karma": "karma start --single-run", - "lint": "eslint tests && tslint src/*" + "lint": "eslint tests && tslint src/*", + "prepare": "npm run build" }, "files": [ "README.md", diff --git a/packages/sjs-logging/types/consts.d.ts b/packages/sjs-logging/types/consts.d.ts index 25690c7..8b39c81 100644 --- a/packages/sjs-logging/types/consts.d.ts +++ b/packages/sjs-logging/types/consts.d.ts @@ -1,8 +1,8 @@ -export declare type LevelsType = { +export interface ILevelsType { [key: string]: number; -}; -export declare const LEVELS: LevelsType; -export interface LevelsNamesType { +} +export declare const LEVELS: ILevelsType; +export interface ILevelsNamesType { [index: number]: string; } -export declare const LEVEL_NAMES: LevelsNamesType; +export declare const LEVEL_NAMES: ILevelsNamesType; diff --git a/packages/sjs-logging/types/filter.d.ts b/packages/sjs-logging/types/filter.d.ts index 80a8d55..66e5442 100644 --- a/packages/sjs-logging/types/filter.d.ts +++ b/packages/sjs-logging/types/filter.d.ts @@ -1,17 +1,11 @@ -import { IRecord, IFilter } from './interfaces'; -export interface FilterFunction { - (record: IRecord): boolean; -} +import { IFilter, IRecord } from './interfaces'; +export declare type FilterFunction = (record: IRecord) => boolean; export declare type FilterType = FilterFunction & IFilter; -/** - * Base class for all filters - */ export declare class Filter implements IFilter { private _name; constructor(name: string); /** * @param {Record} record - * @abstract */ filter(record: IRecord): boolean; } @@ -21,17 +15,7 @@ export declare class Filter implements IFilter { export declare class Filterer { private _filters; constructor(); - /** - * @param {Filter} filter - */ addFilter(filter: FilterType): boolean; - /** - * @param {Filter} filter - */ removeFilter(filter: FilterType): void; - /** - * @param {Record} record - * @return {boolean} - */ filter(record: IRecord): boolean; } diff --git a/packages/sjs-logging/types/handler.d.ts b/packages/sjs-logging/types/handler.d.ts deleted file mode 100644 index db53f3a..0000000 --- a/packages/sjs-logging/types/handler.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { IRecord, IHandler } from './interfaces'; -import { Filterer } from './filter'; -export declare abstract class Handler extends Filterer implements IHandler { - level: number; - /** - * @param {number} [level=LEVELS.NOTSET] - */ - constructor(level?: number); - setLevel(level: number): void; - /** - * @param {Record} record - */ - handle(record: IRecord): boolean; - emit(record: IRecord): void; - flush(): void; - close(): void; -} -export declare class ConsoleHandler extends Handler { - /** - * @param {Record} record Log object with all collected data - */ - emit(record: IRecord): void; -} diff --git a/packages/sjs-logging/types/handlers.d.ts b/packages/sjs-logging/types/handlers.d.ts index db53f3a..134ced3 100644 --- a/packages/sjs-logging/types/handlers.d.ts +++ b/packages/sjs-logging/types/handlers.d.ts @@ -1,15 +1,9 @@ -import { IRecord, IHandler } from './interfaces'; import { Filterer } from './filter'; +import { IHandler, IRecord } from './interfaces'; export declare abstract class Handler extends Filterer implements IHandler { level: number; - /** - * @param {number} [level=LEVELS.NOTSET] - */ constructor(level?: number); setLevel(level: number): void; - /** - * @param {Record} record - */ handle(record: IRecord): boolean; emit(record: IRecord): void; flush(): void; diff --git a/packages/sjs-logging/types/index.d.ts b/packages/sjs-logging/types/index.d.ts index 9d8fa55..ad4b258 100644 --- a/packages/sjs-logging/types/index.d.ts +++ b/packages/sjs-logging/types/index.d.ts @@ -1,5 +1,5 @@ -import { Manager } from './manager'; import { Logger } from './logger'; +import { Manager } from './manager'; declare const logger: Logger; export default logger; export declare function getLogger(name: string): Logger; diff --git a/packages/sjs-logging/types/logger.d.ts b/packages/sjs-logging/types/logger.d.ts index 1fbf9f0..120dab9 100644 --- a/packages/sjs-logging/types/logger.d.ts +++ b/packages/sjs-logging/types/logger.d.ts @@ -1,12 +1,12 @@ -import { IHandler, IRecord } from './interfaces'; import { Filterer } from './filter'; +import { IHandler, IRecord } from './interfaces'; export declare class Logger extends Filterer { - private level; - private propagate; - private _handlers; name: string; manager?: any; parent?: Logger; + private level; + private propagate; + private _handlers; /** * @param {string} name * @param {number} [level=LEVELS.NOTSET] level @@ -26,7 +26,7 @@ export declare class Logger extends Filterer { * @return {boolean} */ hasHandlers(): number; - getHandlers(): Array; + getHandlers(): IHandler[]; /** * * @param {string} msg diff --git a/packages/sjs-logging/types/manager.d.ts b/packages/sjs-logging/types/manager.d.ts index f5ee537..841a8d9 100644 --- a/packages/sjs-logging/types/manager.d.ts +++ b/packages/sjs-logging/types/manager.d.ts @@ -1,8 +1,8 @@ import { Logger } from './logger'; export declare class Manager { + disable: number; private _loggers; private _root; - disable: number; constructor(root?: null, level?: number); setDisable(level: number): void; /** diff --git a/packages/sjs-query/package.json b/packages/sjs-query/package.json index 7233e6c..ba841b0 100644 --- a/packages/sjs-query/package.json +++ b/packages/sjs-query/package.json @@ -18,7 +18,8 @@ "build:exts": "renamer --path-element ext --find js --replace mjs dist/esm/*", "test": "qunit --require ts-node/register tests/*", "karma": "karma start --single-run", - "lint": "eslint tests && tslint src/*" + "lint": "eslint tests && tslint src/*", + "prepare": "npm run build" }, "files": [ "README.md", diff --git a/packages/sjs-query/types/criterias.d.ts b/packages/sjs-query/types/criterias.d.ts deleted file mode 100644 index 81a0b91..0000000 --- a/packages/sjs-query/types/criterias.d.ts +++ /dev/null @@ -1,14 +0,0 @@ -declare const _default: { - eq: (params: any) => any; - lte: (params: any) => any; - gte: (params: any) => any; - approx: (params: any) => any; - present: (params: any) => any; - substring: (params: any) => any; - or: (params: any) => boolean; - and: (params: any) => boolean; - not: (params: any) => boolean; - all: () => boolean; - none: () => boolean; -}; -export default _default; diff --git a/packages/sjs-query/types/filters.d.ts b/packages/sjs-query/types/filters.d.ts index ec336c7..5aec5db 100644 --- a/packages/sjs-query/types/filters.d.ts +++ b/packages/sjs-query/types/filters.d.ts @@ -22,7 +22,7 @@ export declare class Filter { * @param {Array} list * @return {Array} */ - filter(list: Array): Array; + filter(list: any[]): any[]; tostring(): string; eq(params: any): boolean; lte(params: any): boolean; diff --git a/packages/sjs-query/types/squery.d.ts b/packages/sjs-query/types/squery.d.ts deleted file mode 100644 index dac2be0..0000000 --- a/packages/sjs-query/types/squery.d.ts +++ /dev/null @@ -1 +0,0 @@ -export default function squery(query: any): any; diff --git a/packages/sjs-sm/package.json b/packages/sjs-sm/package.json index 845a660..7a99593 100644 --- a/packages/sjs-sm/package.json +++ b/packages/sjs-sm/package.json @@ -18,7 +18,8 @@ "build:exts": "renamer --path-element ext --find js --replace mjs dist/esm/*", "test": "qunit --require ts-node/register tests/*", "karma": "karma start --single-run", - "lint": "eslint tests && tslint src/*" + "lint": "eslint tests && tslint src/*", + "prepare": "npm run build" }, "files": [ "README.md", diff --git a/packages/sjs-stream/package.json b/packages/sjs-stream/package.json index 0606be1..a661f4c 100644 --- a/packages/sjs-stream/package.json +++ b/packages/sjs-stream/package.json @@ -16,7 +16,8 @@ "build:clean": "rm -rf dist/ && rm -rf types", "build:tsc": "tsc && tsc -p tsconfig.esm.json", "build:exts": "renamer --path-element ext --find js --replace mjs dist/esm/*", - "lint": "tslint src/*" + "lint": "tslint src/*", + "prepare": "npm run build" }, "files": [ "README.md", diff --git a/packages/sjs-stream/types/controller.d.ts b/packages/sjs-stream/types/controller.d.ts new file mode 100644 index 0000000..1a50040 --- /dev/null +++ b/packages/sjs-stream/types/controller.d.ts @@ -0,0 +1,23 @@ +import { IControlerSubscribe, IControllerOptions, IObserverListener, IStream, IStreamSubscription } from './interfaces'; +export declare class StreamController implements IControlerSubscribe { + private _state; + private _subscription; + private _options; + constructor(options?: IControllerOptions); + add(value: T): void; + addError(error: any): void; + close(): void; + readonly stream: IStream; + _subscribe(listener: IObserverListener): IStreamSubscription; +} +export declare class EventController implements IControlerSubscribe { + private _state; + private _subscriptions; + private _options; + constructor(options: IControllerOptions); + add(value: T): void; + addError(error: any): void; + close(): void; + readonly stream: IStream; + _subscribe(listener: IObserverListener): IStreamSubscription; +} diff --git a/packages/sjs-stream/types/index.d.ts b/packages/sjs-stream/types/index.d.ts new file mode 100644 index 0000000..9b21662 --- /dev/null +++ b/packages/sjs-stream/types/index.d.ts @@ -0,0 +1,11 @@ +import { EventController, StreamController } from './controller'; +import { IStream } from './interfaces'; +import { Stream } from './stream'; +export { Stream, StreamController, EventController, }; +export declare function fromItem(input: any): IStream<{}> | undefined; +export declare function fromFunction(subscriber: (controller: StreamController) => void): IStream; +export declare function fromObservable(input: any): IStream; +export declare function fromArray(array: ArrayLike): IStream<{}>; +export declare function fromPromise(promise: Promise): IStream<{}>; +export declare function fromIterator(items: Iterable): IStream<{}>; +export declare function fromEvents(element: HTMLElement, eventName: string): IStream<{}>; diff --git a/packages/sjs-stream/types/interfaces.d.ts b/packages/sjs-stream/types/interfaces.d.ts new file mode 100644 index 0000000..79017a8 --- /dev/null +++ b/packages/sjs-stream/types/interfaces.d.ts @@ -0,0 +1,39 @@ +declare global { + interface ISymbolConstructor { + readonly observable: symbol; + } +} +export interface IObserver { + next(value: T): void; + error(error: any): void; + complete(): void; +} +export declare type ISubscriberFunction = ((observer: IObserver) => (() => void) | IStreamSubscription); +export interface IObserverListener { + onData(value: T): void; + onError(error: any): void; + onComplete(): void; +} +export interface IStreamSubscription { + cancel(): void; +} +export interface IStream { + listen(onData?: (value: T) => void, onError?: (error: any) => void, onComplete?: () => void): IStreamSubscription; + listen(listener?: IObserverListener): IStreamSubscription; + map(fn: () => void): IStream; + filter(fn: () => void): IStream; + pipe(...fns: Array<() => void>): IStream; +} +export interface IControllerOptions { + onListen?: () => void; + onCancel?: () => void; +} +export interface IController { + stream: IStream; + add(value: T): void; + addError(error: any): void; + close(): void; +} +export interface IControlerSubscribe extends IController { + _subscribe(listener: IObserverListener): IStreamSubscription; +} diff --git a/packages/sjs-stream/types/stream.d.ts b/packages/sjs-stream/types/stream.d.ts new file mode 100644 index 0000000..f0c5980 --- /dev/null +++ b/packages/sjs-stream/types/stream.d.ts @@ -0,0 +1,21 @@ +import { IObserverListener, IStream, IStreamSubscription } from './interfaces'; +export declare class BufferStreamSubscription implements IStreamSubscription { + private _listener; + private _cancelHandler?; + private _state; + private _buff; + constructor(_listener: IObserverListener, _cancelHandler?: ((sub: any) => void) | undefined); + _addData(data: T): void; + _addError(error: any): void; + _close(): void; + _flush(): void; + cancel(): void; +} +export declare abstract class Stream implements IStream { + listen(listener?: IObserverListener): IStreamSubscription; + listen(onData?: (value: T) => void, onError?: (error: any) => void, onComplete?: () => void): IStreamSubscription; + _createSubscription(listener: IObserverListener): IStreamSubscription; + map(fn: () => void): IStream; + filter(fn: () => void): IStream; + pipe(...fns: Array<() => void>): IStream; +} diff --git a/packages/sjs-stream/types/utils.d.ts b/packages/sjs-stream/types/utils.d.ts new file mode 100644 index 0000000..d8a17bd --- /dev/null +++ b/packages/sjs-stream/types/utils.d.ts @@ -0,0 +1,5 @@ +import { IObserverListener } from './interfaces'; +export declare const noop: () => void; +export declare function toObserver(onData?: IObserverListener | ((value: T) => void), onError?: (error: any) => void, onComplete?: () => void): IObserverListener; +export declare function runMethod(method?: (inputs?: any[]) => void, ...args: any[]): void; +export declare function enqueue(fn: () => void): void;