Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: update imports and packages based on the latest changes of nanolib #214

Merged
merged 6 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"Exir",
"jfsm",
"Mihandoost",
"nanolib",
"tsbuildinfo"
]
}
2 changes: 1 addition & 1 deletion .yarn/sdks/typescript/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "typescript",
"version": "5.6.2-sdk",
"version": "5.6.3-sdk",
"main": "./lib/typescript.js",
"type": "commonjs",
"bin": {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
},
"devDependencies": {
"@alwatr/eslint-config": "^1.2.9",
"@alwatr/prettier-config": "^1.0.5",
"@alwatr/prettier-config": "^1.0.6",
"@lerna-lite/changed": "^3.9.3",
"@lerna-lite/cli": "^3.9.3",
"@lerna-lite/diff": "^3.9.3",
Expand Down
10 changes: 5 additions & 5 deletions packages/context/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,14 @@
"clean": "rm -rfv dist *.tsbuildinfo"
},
"dependencies": {
"@alwatr/logger": "^4.0.3",
"@alwatr/nanolib": "^1.2.0",
"@alwatr/observable": "workspace:^"
},
"devDependencies": {
"@alwatr/nano-build": "^2.0.0",
"@alwatr/prettier-config": "^1.0.5",
"@alwatr/tsconfig-base": "^1.3.1",
"@alwatr/type-helper": "^2.0.1",
"@alwatr/nano-build": "^2.0.1",
"@alwatr/prettier-config": "^1.0.6",
"@alwatr/tsconfig-base": "^1.3.2",
"@alwatr/type-helper": "^2.0.2",
"@types/node": "^22.7.5",
"jest": "^29.7.0",
"typescript": "^5.6.3"
Expand Down
10 changes: 3 additions & 7 deletions packages/context/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
import {definePackage} from '@alwatr/logger';
import {packageTracer} from '@alwatr/nanolib';
import {AlwatrObservable, type AlwatrObservableConfig} from '@alwatr/observable';

import type {} from '@alwatr/nano-build';
import type {Dictionary} from '@alwatr/type-helper';


definePackage('@alwatr/context', __package_version__);
__dev_mode__: packageTracer.add(__package_name__, __package_version__);

/**
* Alwatr Context.
*/
export class AlwatrContext<T extends Dictionary> extends AlwatrObservable<T> {
export class AlwatrContext<T extends DictionaryOpt> extends AlwatrObservable<T> {
constructor(config: AlwatrObservableConfig) {
config.loggerPrefix ??= 'context-signal';
super(config);
Expand Down
1 change: 1 addition & 0 deletions packages/context/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"outDir": "dist",
"emitDeclarationOnly": true,
"composite": true,
"types": ["@alwatr/nano-build", "@alwatr/type-helper"]
},
"include": ["src/**/*.ts"],
"references": [{"path": "../observable"}],
Expand Down
11 changes: 5 additions & 6 deletions packages/fetch-state-machine/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,14 @@
"clean": "rm -rfv dist *.tsbuildinfo"
},
"dependencies": {
"@alwatr/fetch": "^4.1.3",
"@alwatr/fsm": "workspace:^",
"@alwatr/logger": "^4.0.3"
"@alwatr/nanolib": "^1.2.0"
},
"devDependencies": {
"@alwatr/nano-build": "^2.0.0",
"@alwatr/prettier-config": "^1.0.5",
"@alwatr/tsconfig-base": "^1.3.1",
"@alwatr/type-helper": "^2.0.1",
"@alwatr/nano-build": "^2.0.1",
"@alwatr/prettier-config": "^1.0.6",
"@alwatr/tsconfig-base": "^1.3.2",
"@alwatr/type-helper": "^2.0.2",
"@types/node": "^22.7.5",
"jest": "^29.7.0",
"typescript": "^5.6.3"
Expand Down
16 changes: 9 additions & 7 deletions packages/fetch-state-machine/src/base.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import {fetch, type FetchOptions} from '@alwatr/fetch';
import {AlwatrFluxStateMachineBase, type StateRecord, type ActionRecord, type AlwatrFluxStateMachineConfig} from '@alwatr/fsm';
import {definePackage} from '@alwatr/logger';

import type {} from '@alwatr/nano-build';

definePackage('@alwatr/fetch-state-machine', __package_version__);
import {
AlwatrFluxStateMachineBase,
type StateRecord,
type ActionRecord,
type AlwatrFluxStateMachineConfig
} from '@alwatr/fsm';
import {packageTracer, fetch, type FetchOptions} from '@alwatr/nanolib';

__dev_mode__: packageTracer.add(__package_name__, __package_version__);

export type ServerRequestState = 'initial' | 'loading' | 'failed' | 'complete';
export type ServerRequestEvent = 'request' | 'requestFailed' | 'requestSucceeded';
Expand Down
2 changes: 0 additions & 2 deletions packages/fetch-state-machine/src/jfsm-base.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import {AlwatrFetchStateMachineBase, type FetchOptions} from './base.js';

import type {Json} from '@alwatr/type-helper';

export abstract class AlwatrJsonFetchStateMachineBase<
T extends Json = Json,
ExtraState extends string = never,
Expand Down
1 change: 0 additions & 1 deletion packages/fetch-state-machine/src/jfsm.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {AlwatrJsonFetchStateMachineBase} from './jfsm-base.js';

import type {FetchOptions, ServerRequestState} from './base.js';
import type {Json} from '@alwatr/type-helper';

export class AlwatrJsonFetchStateMachine<T extends Json = Json> extends AlwatrJsonFetchStateMachineBase<T> {
/**
Expand Down
1 change: 1 addition & 0 deletions packages/fetch-state-machine/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"outDir": "dist",
"emitDeclarationOnly": true,
"composite": true,
"types": ["@alwatr/nano-build", "@alwatr/type-helper"]
},
"include": ["src/**/*.ts"],
"references": [{"path": "../fsm"}]
Expand Down
8 changes: 4 additions & 4 deletions packages/flux/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@
"@alwatr/signal": "workspace:^"
},
"devDependencies": {
"@alwatr/nano-build": "^2.0.0",
"@alwatr/prettier-config": "^1.0.5",
"@alwatr/tsconfig-base": "^1.3.1",
"@alwatr/type-helper": "^2.0.1",
"@alwatr/nano-build": "^2.0.1",
"@alwatr/prettier-config": "^1.0.6",
"@alwatr/tsconfig-base": "^1.3.2",
"@alwatr/type-helper": "^2.0.2",
"@types/node": "^22.7.5",
"jest": "^29.7.0",
"typescript": "^5.6.3"
Expand Down
13 changes: 6 additions & 7 deletions packages/fsm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,14 @@
"clean": "rm -rfv dist *.tsbuildinfo"
},
"dependencies": {
"@alwatr/logger": "^4.0.3",
"@alwatr/observable": "workspace:^",
"@alwatr/polyfill-has-own": "^1.1.3"
"@alwatr/nanolib": "^1.2.0",
"@alwatr/observable": "workspace:^"
},
"devDependencies": {
"@alwatr/nano-build": "^2.0.0",
"@alwatr/prettier-config": "^1.0.5",
"@alwatr/tsconfig-base": "^1.3.1",
"@alwatr/type-helper": "^2.0.1",
"@alwatr/nano-build": "^2.0.1",
"@alwatr/prettier-config": "^1.0.6",
"@alwatr/tsconfig-base": "^1.3.2",
"@alwatr/type-helper": "^2.0.2",
"@types/node": "^22.7.5",
"jest": "^29.7.0",
"typescript": "^5.6.3"
Expand Down
7 changes: 2 additions & 5 deletions packages/fsm/src/base.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import {definePackage} from '@alwatr/logger';
import {packageTracer} from '@alwatr/nanolib';
import {AlwatrObservable, type AlwatrObservableConfig} from '@alwatr/observable';
import '@alwatr/polyfill-has-own';

import type {ActionName, ActionRecord, StateEventDetail, StateRecord} from './type.js';
import type {} from '@alwatr/nano-build';
import type {MaybePromise} from '@alwatr/type-helper';

definePackage('@alwatr/fsm', __package_version__);
__dev_mode__: packageTracer.add(__package_name__, __package_version__);

export interface AlwatrFluxStateMachineConfig<S extends string> extends AlwatrObservableConfig {
initialState: S;
Expand Down
2 changes: 0 additions & 2 deletions packages/fsm/src/type.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import type {MaybePromise} from '@alwatr/type-helper';

export interface StateEventDetail<S, E> {
from: S;
event: E;
Expand Down
1 change: 1 addition & 0 deletions packages/fsm/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"outDir": "dist",
"emitDeclarationOnly": true,
"composite": true,
"types": ["@alwatr/nano-build", "@alwatr/type-helper"]
},
"include": ["src/**/*.ts"],
"references": [{"path": "../observable"}],
Expand Down
10 changes: 5 additions & 5 deletions packages/observable/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@
"clean": "rm -rfv dist *.tsbuildinfo"
},
"dependencies": {
"@alwatr/logger": "^4.0.3"
"@alwatr/nanolib": "^1.2.0"
},
"devDependencies": {
"@alwatr/nano-build": "^2.0.0",
"@alwatr/prettier-config": "^1.0.5",
"@alwatr/tsconfig-base": "^1.3.1",
"@alwatr/type-helper": "^2.0.1",
"@alwatr/nano-build": "^2.0.1",
"@alwatr/prettier-config": "^1.0.6",
"@alwatr/tsconfig-base": "^1.3.2",
"@alwatr/type-helper": "^2.0.2",
"@types/node": "^22.7.5",
"jest": "^29.7.0",
"typescript": "^5.6.3"
Expand Down
8 changes: 3 additions & 5 deletions packages/observable/src/observable.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
import {createLogger, definePackage} from '@alwatr/logger';
import {createLogger, packageTracer} from '@alwatr/nanolib';

import type {SubscribeOptions, ListenerCallback, Observer, SubscribeResult, AlwatrObservableInterface} from './type.js';
import type {} from '@alwatr/nano-build';
import type {Dictionary} from '@alwatr/type-helper';

definePackage('@alwatr/observable', __package_version__);
__dev_mode__: packageTracer.add(__package_name__, __package_version__);

export interface AlwatrObservableConfig {
name: string;
loggerPrefix?: string;
}

export abstract class AlwatrObservable<T extends Dictionary = Dictionary> implements AlwatrObservableInterface<T> {
export abstract class AlwatrObservable<T extends DictionaryOpt = DictionaryOpt> implements AlwatrObservableInterface<T> {
protected name_;
protected logger_;
protected message_?: T;
Expand Down
8 changes: 3 additions & 5 deletions packages/observable/src/type.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import type {Dictionary, MaybePromise} from '@alwatr/type-helper';

/**
* Subscribe options type.
*/
Expand Down Expand Up @@ -30,9 +28,9 @@ export interface SubscribeOptions {
// debounce?: 'AnimationFrame' | number;
}

export type ListenerCallback<T, M extends Dictionary = Dictionary> = (this: T, message: M) => MaybePromise<void>;
export type ListenerCallback<T, M extends DictionaryOpt = DictionaryOpt> = (this: T, message: M) => MaybePromise<void>;

export interface Observer<T, M extends Dictionary = Dictionary> {
export interface Observer<T, M extends DictionaryOpt = DictionaryOpt> {
callback: ListenerCallback<T, M>;
options: SubscribeOptions;
}
Expand All @@ -41,7 +39,7 @@ export interface SubscribeResult {
unsubscribe: () => void;
}

export interface AlwatrObservableInterface<T extends Dictionary = Dictionary> {
export interface AlwatrObservableInterface<T extends DictionaryOpt = DictionaryOpt> {
subscribe(listenerCallback: ListenerCallback<this, T>, options?: SubscribeOptions): SubscribeResult;
unsubscribe(listenerCallback: ListenerCallback<this, T>): void;
}
1 change: 1 addition & 0 deletions packages/observable/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"outDir": "dist",
"emitDeclarationOnly": true,
"composite": true,
"types": ["@alwatr/nano-build", "@alwatr/type-helper"]
},
"include": ["src/**/*.ts"],
"references": [],
Expand Down
10 changes: 5 additions & 5 deletions packages/remote-context/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@
},
"dependencies": {
"@alwatr/fetch-state-machine": "workspace:^",
"@alwatr/logger": "^4.0.3"
"@alwatr/nanolib": "^1.2.0"
},
"devDependencies": {
"@alwatr/nano-build": "^2.0.0",
"@alwatr/prettier-config": "^1.0.5",
"@alwatr/tsconfig-base": "^1.3.1",
"@alwatr/type-helper": "^2.0.1",
"@alwatr/nano-build": "^2.0.1",
"@alwatr/prettier-config": "^1.0.6",
"@alwatr/tsconfig-base": "^1.3.2",
"@alwatr/type-helper": "^2.0.2",
"@types/node": "^22.7.5",
"jest": "^29.7.0",
"typescript": "^5.6.3"
Expand Down
3 changes: 2 additions & 1 deletion packages/remote-context/src/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import {
type ServerRequestEvent,
type ServerRequestState,
} from '@alwatr/fetch-state-machine';
import {packageTracer} from '@alwatr/nanolib';

import type {Json} from '@alwatr/type-helper';
__dev_mode__: packageTracer.add(__package_name__, __package_version__);

type ExtraState = 'offlineCheck' | 'reloading' | 'reloadingFailed';
export type ServerContextState = ServerRequestState | ExtraState;
Expand Down
3 changes: 1 addition & 2 deletions packages/remote-context/src/remote-context.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {AlwatrRemoteContextStateMachineBase, type ServerContextState} from './base.js';

import type {FetchOptions} from '@alwatr/fetch-state-machine';
import type {Json} from '@alwatr/type-helper';
import type {FetchOptions} from '@alwatr/nanolib';

export class AlwatrRemoteContextStateMachine<T extends Json = Json> extends AlwatrRemoteContextStateMachineBase<T> {
/**
Expand Down
1 change: 1 addition & 0 deletions packages/remote-context/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"outDir": "dist",
"emitDeclarationOnly": true,
"composite": true,
"types": ["@alwatr/nano-build", "@alwatr/type-helper"]
},
"include": ["src/**/*.ts"],
"references": [{"path": "../fetch-state-machine"}]
Expand Down
10 changes: 5 additions & 5 deletions packages/signal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,14 @@
"clean": "rm -rfv dist *.tsbuildinfo"
},
"dependencies": {
"@alwatr/logger": "^4.0.3",
"@alwatr/nanolib": "^1.2.0",
"@alwatr/observable": "workspace:^"
},
"devDependencies": {
"@alwatr/nano-build": "^2.0.0",
"@alwatr/prettier-config": "^1.0.5",
"@alwatr/tsconfig-base": "^1.3.1",
"@alwatr/type-helper": "^2.0.1",
"@alwatr/nano-build": "^2.0.1",
"@alwatr/prettier-config": "^1.0.6",
"@alwatr/tsconfig-base": "^1.3.2",
"@alwatr/type-helper": "^2.0.2",
"@types/node": "^22.7.5",
"jest": "^29.7.0",
"typescript": "^5.6.3"
Expand Down
6 changes: 2 additions & 4 deletions packages/signal/src/logger.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import {definePackage} from '@alwatr/logger';
import {createLogger} from '@alwatr/nanolib';

import type {} from '@alwatr/nano-build';

export const logger = definePackage('@alwatr/signal', __package_version__);
export const logger = /* #__PURE__ */ createLogger(__package_name__);
6 changes: 2 additions & 4 deletions packages/signal/src/signal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@ import {AlwatrObservable, type AlwatrObservableConfig} from '@alwatr/observable'

import {logger} from './logger.js';

import type {Dictionary} from '@alwatr/type-helper';

logger.logModule?.('signal');
__dev_mode__: logger.logFileModule?.('signal');

/**
* Alwatr event signal with special message (event detail).
*/
export class AlwatrSignal<T extends Dictionary = Dictionary> extends AlwatrObservable<T> {
export class AlwatrSignal<T extends DictionaryOpt = DictionaryOpt> extends AlwatrObservable<T> {
constructor(config: AlwatrObservableConfig) {
config.loggerPrefix ??= 'signal';
super(config);
Expand Down
2 changes: 1 addition & 1 deletion packages/signal/src/trigger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {AlwatrObservable, type AlwatrObservableConfig} from '@alwatr/observable'

import {logger} from './logger.js';

logger.logModule?.('trigger');
__dev_mode__: logger.logFileModule?.('trigger');

/**
* Alwatr event signal without any message (no event detail).
Expand Down
1 change: 1 addition & 0 deletions packages/signal/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"outDir": "dist",
"emitDeclarationOnly": true,
"composite": true,
"types": ["@alwatr/nano-build", "@alwatr/type-helper"]
},
"include": ["src/**/*.ts"],
"references": [{"path": "../observable"}],
Expand Down
Loading