Skip to content

Commit

Permalink
Merge pull request #44 from AliMD/feat/review
Browse files Browse the repository at this point in the history
Review and update documents for next release
  • Loading branch information
AliMD authored Mar 5, 2022
2 parents 92a3015 + b337d9a commit f249c41
Show file tree
Hide file tree
Showing 25 changed files with 106 additions and 231 deletions.
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
},
"cSpell.language": "en,fa",
"cSpell.words": [
"alvatr",
"khafan",
"mastmalize",
"Mihandoost",
Expand Down
11 changes: 11 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Contributor Code of Conduct

As contributors and maintainers of the AlVatr projects, we pledge to respect everyone who contributes by posting issues, updating documentation, submitting pull requests, providing feedback in comments, and any other activities.

Communication through any of AlVatr channels (GitHub, Telegram, Twitter, etc.) must be constructive and never resort to personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.

We promise to extend courtesy and respect to everyone involved in this project regardless of gender, gender identity, sexual orientation, disability, age, race, ethnicity, religion, or level of experience. We expect anyone contributing to the AlVatr projects to do the same.

If any member of the community violates this code of conduct, the maintainers of the AlVatr projects may take action, removing issues, comments, and PRs or blocking accounts as deemed appropriate.

If you are subject to or witness unacceptable behavior, or have any other concerns, please email us at [[email protected]](mailto:[email protected]).
27 changes: 0 additions & 27 deletions CONTRIBUTE.md

This file was deleted.

47 changes: 47 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Contributing to AlVatr projects

We would love for you to contribute to AlVatr projects and help make it even better than it is today!
As a contributor, here are the guidelines we would like you to follow:

## Code of Conduct

Help us keep AlVatr projects open and inclusive.
Please read and follow our [Code of Conduct][./CODE_OF_CONDUCT.md].

## Found a Bug?

If you find a bug in the source code, you can help us by *submitting an issue* to our GitHub Repository.
Even better, you can *submit a Pull Request* with a fix.

## Missing a Feature?

You can *request* a new feature by *submitting an issue* to our GitHub Repository.
After accepted issue, if you would like to *implement* the feature, you can *submit a Pull Request*.

## Commit Message Format

```txt
<type>(<scope>): <short summary>
│ │ │
│ │ └─⫸ Summary in present tense. Not capitalized. No period at the end.
│ │
│ └─⫸ Commit Scope: PackageName|Concept (optional)
└─⫸ Commit Type: fix|feat|refactor|perf|docs|lint|chore|merge|release
```

Example: `feat(signal): support signal providers`

## Type

Must be one of the following:

- **fix**: A bug fix
- **feat**: A new feature
- **refactor**: A code change that neither fixes a bug nor adds a feature
- **perf**: A code change that improves performance
- **docs**: Documentation only changes
- **lint**: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, lint rules, etc)
- **chore**: Other changes that don't modify `src`
- **merge**: Merge branches, solve conflict, etc
- **release**: Release new version
1 change: 0 additions & 1 deletion demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
</head>

<body>
<a href="./util/index.html">Util</a>
<a href="./logger/index.html">Logger</a>
</body>
</html>
1 change: 0 additions & 1 deletion demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
],
"dependencies": {
"@vatr/logger": "^0.1.2",
"@vatr/util": "^0.1.0",
"lit": "^2.1.3",
"tslib": "^2.2.0"
}
Expand Down
3 changes: 1 addition & 2 deletions demo/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
"**/*.ts"
],
"references": [
{"path": "../package/logger"},
{"path": "../package/util"},
{"path": "../package/logger"}
],
"exclude": [
"*.d.ts",
Expand Down
13 changes: 0 additions & 13 deletions demo/util/index.html

This file was deleted.

3 changes: 0 additions & 3 deletions demo/util/index.ts

This file was deleted.

2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"version": {
"conventionalCommits": true,
"changelogPreset": "angular",
"message": "chore(release): %s"
"message": "release: %s"
},
"publish": {
"conventionalCommits": true,
Expand Down
6 changes: 3 additions & 3 deletions package/fetch/README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# @vatr/fetch

Enhanced fetch api with timeout, promise and types.
Enhanced fetch api with timeout, helper methods and types written in tiny TypeScript, ES module.

## Example usage

```js
import { ... } from 'https://esm.run/@vatr/fetch';
import {getJson} from 'https://esm.run/@vatr/fetch';

...
const productList = await getJson('/api/products', {limit: 10}, {timeout: 5_000});
```
10 changes: 6 additions & 4 deletions package/fetch/package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
{
"name": "@vatr/fetch",
"version": "0.1.2",
"description": "Enhanced fetch api with timeout, promise and types.",
"description": "Enhanced fetch api with timeout, helper methods and types written in tiny TypeScript module.",
"keywords": [
"vatr",
"alvatr",
"fetch",
"request",
"api",
"timeout"
"timeout",
"typescript",
"esm",
"vatr",
"alvatr"
],
"main": "fetch.js",
"type": "module",
Expand Down
4 changes: 2 additions & 2 deletions package/fetch/src/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export function fetch(url: string, options?: FetchOptions): Promise<Response> {
log('fetch', url, options);

if (!navigator.onLine) {
throw new Error('vatr_fetch_offline');
throw new Error('fetch_offline');
}

options = {
Expand Down Expand Up @@ -115,7 +115,7 @@ export async function getJson<ResponseType extends Record<string | number, unkno
const response = await getData(url, queryParameters, options);

if (!response.ok) {
throw new Error('vatr_fetch_nok');
throw new Error('fetch_nok');
}

return response.json() as Promise<ResponseType>;
Expand Down
2 changes: 1 addition & 1 deletion package/logger/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# @vatr/logger

Create a logger function for fancy console debug with custom scope.
Fancy colorful console debugger with custom scope written in tiny TypeScript, ES module.

## Example usage

Expand Down
10 changes: 6 additions & 4 deletions package/logger/package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
{
"name": "@vatr/logger",
"version": "0.1.2",
"description": "Create a logger function for fancy console debug with custom scope.",
"description": "Fancy colorful console debugger with custom scope written in tiny TypeScript, ES module.",
"keywords": [
"vatr",
"alvatr",
"log",
"logger",
"console",
"debug"
"debug",
"typescript",
"esm",
"vatr",
"alvatr"
],
"main": "logger.js",
"type": "module",
Expand Down
2 changes: 1 addition & 1 deletion package/router/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# @vatr/router

Elegant powerful router module based on the simplicity of the signals.
Elegant powerful router (fundamental advance browser page routing) based on the simplicity of the signals written in tiny TypeScript module.

## Example usage

Expand Down
9 changes: 5 additions & 4 deletions package/router/package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
{
"name": "@vatr/router",
"version": "0.0.0",
"description": "Elegant powerful router module based on the simplicity of the signals.",
"description": "Elegant powerful router (fundamental advance browser page routing) based on the simplicity of the signals written in tiny TypeScript module.",
"keywords": [
"vatr",
"alvatr",
"router",
"route",
"khafan"
"typescript",
"esm",
"vatr",
"alvatr"
],
"main": "router.js",
"type": "module",
Expand Down
73 changes: 16 additions & 57 deletions package/signal/README.md
Original file line number Diff line number Diff line change
@@ -1,81 +1,40 @@
# @vatr/signal

A small and fast event system with `0` dependencies.
Elegant powerful event system for handle global signals and states written in tiny TypeScript module.

## Installation
Every signal has own value and can be used as a advance **state management** like redux and recoil without the complexities and unnecessary facilities of those libraries.

`npm install @vatr/signal`
## Example usage

## How to use

define a signal type on `VatrSignals` and listene to event with `addSignalListener` and trigger the event with `dispatchSignal`.
### Signal providers

```TypeScript
import { addSignalListener, dispatchSignal } from 'https://esm.run/@vatr/signal';

declare global {
interface VatrSignals {
readonly 'test-event': number;
readonly 'my-money-change': number;
}
}

addSignalListener('test-event', (value) => {
console.log(value);
});

dispatchSignal('test-event', 1);
dispatchSignal('my-money-change', 10);
// signal debounced with browser animation frame
dispatchSignal('my-money-change', 20);
```

Add multiple listene to the same event name:
### Signal receivers in another file *without any cohesion with providers*

```TypeScript
import { addSignalListener, dispatchSignal } from 'https://esm.run/@vatr/signal';

declare global {
interface VatrSignals {
readonly 'test-event': void;
}
}

addSignalListener('test-event', () => { console.log(1); });
addSignalListener('test-event', () => { console.log(2); });
addSignalListener('test-event', () => { console.log(3); });

dispatchSignal('test-event', void);
```

You can remove event from all sycle with `expireSignal`:
*Receive as a event:*

```TypeScript
import { addSignalListener, dispatchSignal, expireSignal } from 'https://esm.run/@vatr/signal';

declare global {
interface VatrSignals {
readonly 'test-event': void;
}
}

addSignalListener('test-event', () => { console.log(1); });
expireSignal('test-event');
dispatchSignal('test-event', void); // this line must make a Error
addSignalListener('my-money-change', (money) => {
// money type is automatically set to number.
console.log(money);
});
```

You can test a signal dispatch before now with `hasSignalDispatchedBefore`:
*Receive inside code as a promise:*

```TypeScript
import { addSignalListener, dispatchSignal, hasSignalDispatchedBefore } from 'https://esm.run/@vatr/signal';

declare global {
interface VatrSignals {
readonly 'test-event': number;
}
}

addSignalListener('test-event', (value) => {
console.log(value);
});

dispatchSignal('test-event', 1);

console.log(hasSignalDispatchedBefore('test-event'));
const money = await waitForSignal('my-money-change', {receivePrevious: true});
```
8 changes: 5 additions & 3 deletions package/signal/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
{
"name": "@vatr/signal",
"version": "0.1.2",
"description": "Manage and control all signals in your project.",
"description": "Elegant powerful event system for handle global signals and states written in tiny TypeScript module.",
"keywords": [
"signal",
"typescript",
"esm",
"vatr",
"alvatr",
"signal"
"alvatr"
],
"main": "signal.js",
"type": "module",
Expand Down
17 changes: 0 additions & 17 deletions package/util/CHANGELOG.md

This file was deleted.

Loading

0 comments on commit f249c41

Please sign in to comment.