Compare commits
78 Commits
Author | SHA1 | Date | |
---|---|---|---|
4969a703da | |||
5e16294773 | |||
e0a4e5a076 | |||
23c6e17536 | |||
a0df30adf1 | |||
d4de9087d5 | |||
6c5a16bbdb | |||
4a03e952fc | |||
80b404a379 | |||
d7c1bd06f2 | |||
124400df69 | |||
84d3a6310d | |||
984f7e7bb6 | |||
f4e548aa2c | |||
3f85e9fa3c | |||
1b60ba805d | |||
ceddf45850 | |||
45fd82279e | |||
110a2e27cc | |||
a41652ba52 | |||
fad166c100 | |||
ed6db60055 | |||
0097f819a0 | |||
a3ed2e5dbd | |||
f9e43be46a | |||
ca22a417da | |||
093b1dd7a9 | |||
3c1bfaa1f7 | |||
83cd98022a | |||
b06ceaa9bf | |||
e8057c0c95 | |||
d389d180e5 | |||
d92123dcb9 | |||
5d8f569339 | |||
7168bd7ffd | |||
5031d28c32 | |||
4eaf91af3a | |||
511396894d | |||
a1bd0499a0 | |||
803c8a4d8f | |||
d5a2b0a78e | |||
5fdd756672 | |||
5f7580b28f | |||
bba7bb7eea | |||
552cae9755 | |||
610c1d6beb | |||
037e33caee | |||
2400e61024 | |||
0fe16f4fc4 | |||
fa8fb5b622 | |||
389f502dd0 | |||
ea3e7dd2ab | |||
e4ac6232b8 | |||
fd9c57dcd0 | |||
090142cb16 | |||
b05a8e4fa4 | |||
66ee8ba0df | |||
f9d8175c8c | |||
5e218e36a5 | |||
417772a1ec | |||
e34d9f7cad | |||
9908d759c6 | |||
c4d48b17e9 | |||
3cf9396773 | |||
3632941abc | |||
b8d7653434 | |||
f2b02a2f68 | |||
aa8e2a9ae4 | |||
bfff3b4da5 | |||
5e2d11980c | |||
71edd16d65 | |||
f572603e04 | |||
71a1cde491 | |||
487cd53c3b | |||
e050031313 | |||
cbbb31e0e7 | |||
a758196705 | |||
951d260103 |
66
.gitea/workflows/default_nottags.yaml
Normal file
66
.gitea/workflows/default_nottags.yaml
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
name: Default (not tags)
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags-ignore:
|
||||||
|
- '**'
|
||||||
|
|
||||||
|
env:
|
||||||
|
IMAGE: code.foss.global/host.today/ht-docker-node:npmci
|
||||||
|
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@/${{gitea.repository}}.git
|
||||||
|
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
|
||||||
|
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
|
||||||
|
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
|
||||||
|
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
security:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
continue-on-error: true
|
||||||
|
container:
|
||||||
|
image: ${{ env.IMAGE }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Install pnpm and npmci
|
||||||
|
run: |
|
||||||
|
pnpm install -g pnpm
|
||||||
|
pnpm install -g @ship.zone/npmci
|
||||||
|
|
||||||
|
- name: Run npm prepare
|
||||||
|
run: npmci npm prepare
|
||||||
|
|
||||||
|
- name: Audit production dependencies
|
||||||
|
run: |
|
||||||
|
npmci command npm config set registry https://registry.npmjs.org
|
||||||
|
npmci command pnpm audit --audit-level=high --prod
|
||||||
|
continue-on-error: true
|
||||||
|
|
||||||
|
- name: Audit development dependencies
|
||||||
|
run: |
|
||||||
|
npmci command npm config set registry https://registry.npmjs.org
|
||||||
|
npmci command pnpm audit --audit-level=high --dev
|
||||||
|
continue-on-error: true
|
||||||
|
|
||||||
|
test:
|
||||||
|
if: ${{ always() }}
|
||||||
|
needs: security
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: ${{ env.IMAGE }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Test stable
|
||||||
|
run: |
|
||||||
|
npmci node install stable
|
||||||
|
npmci npm install
|
||||||
|
npmci npm test
|
||||||
|
|
||||||
|
- name: Test build
|
||||||
|
run: |
|
||||||
|
npmci node install stable
|
||||||
|
npmci npm install
|
||||||
|
npmci npm build
|
124
.gitea/workflows/default_tags.yaml
Normal file
124
.gitea/workflows/default_tags.yaml
Normal file
@ -0,0 +1,124 @@
|
|||||||
|
name: Default (tags)
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- '*'
|
||||||
|
|
||||||
|
env:
|
||||||
|
IMAGE: code.foss.global/host.today/ht-docker-node:npmci
|
||||||
|
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@/${{gitea.repository}}.git
|
||||||
|
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
|
||||||
|
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
|
||||||
|
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
|
||||||
|
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
security:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
continue-on-error: true
|
||||||
|
container:
|
||||||
|
image: ${{ env.IMAGE }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Prepare
|
||||||
|
run: |
|
||||||
|
pnpm install -g pnpm
|
||||||
|
pnpm install -g @ship.zone/npmci
|
||||||
|
npmci npm prepare
|
||||||
|
|
||||||
|
- name: Audit production dependencies
|
||||||
|
run: |
|
||||||
|
npmci command npm config set registry https://registry.npmjs.org
|
||||||
|
npmci command pnpm audit --audit-level=high --prod
|
||||||
|
continue-on-error: true
|
||||||
|
|
||||||
|
- name: Audit development dependencies
|
||||||
|
run: |
|
||||||
|
npmci command npm config set registry https://registry.npmjs.org
|
||||||
|
npmci command pnpm audit --audit-level=high --dev
|
||||||
|
continue-on-error: true
|
||||||
|
|
||||||
|
test:
|
||||||
|
if: ${{ always() }}
|
||||||
|
needs: security
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: ${{ env.IMAGE }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Prepare
|
||||||
|
run: |
|
||||||
|
pnpm install -g pnpm
|
||||||
|
pnpm install -g @ship.zone/npmci
|
||||||
|
npmci npm prepare
|
||||||
|
|
||||||
|
- name: Test stable
|
||||||
|
run: |
|
||||||
|
npmci node install stable
|
||||||
|
npmci npm install
|
||||||
|
npmci npm test
|
||||||
|
|
||||||
|
- name: Test build
|
||||||
|
run: |
|
||||||
|
npmci node install stable
|
||||||
|
npmci npm install
|
||||||
|
npmci npm build
|
||||||
|
|
||||||
|
release:
|
||||||
|
needs: test
|
||||||
|
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: ${{ env.IMAGE }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Prepare
|
||||||
|
run: |
|
||||||
|
pnpm install -g pnpm
|
||||||
|
pnpm install -g @ship.zone/npmci
|
||||||
|
npmci npm prepare
|
||||||
|
|
||||||
|
- name: Release
|
||||||
|
run: |
|
||||||
|
npmci node install stable
|
||||||
|
npmci npm publish
|
||||||
|
|
||||||
|
metadata:
|
||||||
|
needs: test
|
||||||
|
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: ${{ env.IMAGE }}
|
||||||
|
continue-on-error: true
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Prepare
|
||||||
|
run: |
|
||||||
|
pnpm install -g pnpm
|
||||||
|
pnpm install -g @ship.zone/npmci
|
||||||
|
npmci npm prepare
|
||||||
|
|
||||||
|
- name: Code quality
|
||||||
|
run: |
|
||||||
|
npmci command npm install -g typescript
|
||||||
|
npmci npm install
|
||||||
|
|
||||||
|
- name: Trigger
|
||||||
|
run: npmci trigger
|
||||||
|
|
||||||
|
- name: Build docs and upload artifacts
|
||||||
|
run: |
|
||||||
|
npmci node install stable
|
||||||
|
npmci npm install
|
||||||
|
pnpm install -g @git.zone/tsdoc
|
||||||
|
npmci command tsdoc
|
||||||
|
continue-on-error: true
|
18
.gitignore
vendored
18
.gitignore
vendored
@ -1,5 +1,19 @@
|
|||||||
.nogit/
|
.nogit/
|
||||||
node_modules/
|
|
||||||
|
# artifacts
|
||||||
coverage/
|
coverage/
|
||||||
public/
|
public/
|
||||||
pages/
|
|
||||||
|
# installs
|
||||||
|
node_modules/
|
||||||
|
|
||||||
|
# caches
|
||||||
|
.yarn/
|
||||||
|
.cache/
|
||||||
|
.rpt2_cache
|
||||||
|
|
||||||
|
# builds
|
||||||
|
dist/
|
||||||
|
dist_*/
|
||||||
|
|
||||||
|
#------# custom
|
147
.gitlab-ci.yml
147
.gitlab-ci.yml
@ -1,147 +0,0 @@
|
|||||||
# gitzone standard
|
|
||||||
image: hosttoday/ht-docker-node:npmci
|
|
||||||
|
|
||||||
cache:
|
|
||||||
paths:
|
|
||||||
- .npmci_cache/
|
|
||||||
key: "$CI_BUILD_STAGE"
|
|
||||||
|
|
||||||
stages:
|
|
||||||
- security
|
|
||||||
- test
|
|
||||||
- release
|
|
||||||
- metadata
|
|
||||||
|
|
||||||
# ====================
|
|
||||||
# security stage
|
|
||||||
# ====================
|
|
||||||
mirror:
|
|
||||||
stage: security
|
|
||||||
script:
|
|
||||||
- npmci git mirror
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
- notpriv
|
|
||||||
|
|
||||||
snyk:
|
|
||||||
stage: security
|
|
||||||
script:
|
|
||||||
- npmci npm prepare
|
|
||||||
- npmci command npm install -g snyk
|
|
||||||
- npmci command npm install --ignore-scripts
|
|
||||||
- npmci command snyk test
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
- notpriv
|
|
||||||
|
|
||||||
# ====================
|
|
||||||
# test stage
|
|
||||||
# ====================
|
|
||||||
testLEGACY:
|
|
||||||
stage: test
|
|
||||||
script:
|
|
||||||
- npmci npm prepare
|
|
||||||
- npmci node install legacy
|
|
||||||
- npmci npm install
|
|
||||||
- npmci npm test
|
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
- notpriv
|
|
||||||
allow_failure: true
|
|
||||||
|
|
||||||
testLTS:
|
|
||||||
stage: test
|
|
||||||
script:
|
|
||||||
- npmci npm prepare
|
|
||||||
- npmci node install lts
|
|
||||||
- npmci npm install
|
|
||||||
- npmci npm test
|
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
- notpriv
|
|
||||||
|
|
||||||
testSTABLE:
|
|
||||||
stage: test
|
|
||||||
script:
|
|
||||||
- npmci npm prepare
|
|
||||||
- npmci node install stable
|
|
||||||
- npmci npm install
|
|
||||||
- npmci npm test
|
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
- notpriv
|
|
||||||
|
|
||||||
release:
|
|
||||||
stage: release
|
|
||||||
script:
|
|
||||||
- npmci node install stable
|
|
||||||
- npmci npm publish
|
|
||||||
only:
|
|
||||||
- tags
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
- notpriv
|
|
||||||
|
|
||||||
# ====================
|
|
||||||
# metadata stage
|
|
||||||
# ====================
|
|
||||||
codequality:
|
|
||||||
stage: metadata
|
|
||||||
image: docker:stable
|
|
||||||
allow_failure: true
|
|
||||||
services:
|
|
||||||
- docker:stable-dind
|
|
||||||
script:
|
|
||||||
- export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/')
|
|
||||||
- docker run
|
|
||||||
--env SOURCE_CODE="$PWD"
|
|
||||||
--volume "$PWD":/code
|
|
||||||
--volume /var/run/docker.sock:/var/run/docker.sock
|
|
||||||
"registry.gitlab.com/gitlab-org/security-products/codequality:$SP_VERSION" /code
|
|
||||||
artifacts:
|
|
||||||
paths: [codeclimate.json]
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
- priv
|
|
||||||
|
|
||||||
trigger:
|
|
||||||
stage: metadata
|
|
||||||
script:
|
|
||||||
- npmci trigger
|
|
||||||
only:
|
|
||||||
- tags
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
- notpriv
|
|
||||||
|
|
||||||
pages:
|
|
||||||
image: hosttoday/ht-docker-node:npmci
|
|
||||||
stage: metadata
|
|
||||||
script:
|
|
||||||
- npmci command npm install -g typedoc typescript
|
|
||||||
- npmci npm prepare
|
|
||||||
- npmci npm install
|
|
||||||
- npmci command typedoc --module "commonjs" --target "ES2016" --out public/ ts/
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
- notpriv
|
|
||||||
only:
|
|
||||||
- tags
|
|
||||||
artifacts:
|
|
||||||
expire_in: 1 week
|
|
||||||
paths:
|
|
||||||
- public
|
|
||||||
allow_failure: true
|
|
||||||
|
|
||||||
windowsCompatibility:
|
|
||||||
image: stefanscherer/node-windows:10-build-tools
|
|
||||||
stage: metadata
|
|
||||||
script:
|
|
||||||
- npm install & npm test
|
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
|
||||||
tags:
|
|
||||||
- windows
|
|
||||||
allow_failure: true
|
|
11
.vscode/launch.json
vendored
Normal file
11
.vscode/launch.json
vendored
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"command": "npm test",
|
||||||
|
"name": "Run npm test",
|
||||||
|
"request": "launch",
|
||||||
|
"type": "node-terminal"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
26
.vscode/settings.json
vendored
Normal file
26
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"json.schemas": [
|
||||||
|
{
|
||||||
|
"fileMatch": ["/npmextra.json"],
|
||||||
|
"schema": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"npmci": {
|
||||||
|
"type": "object",
|
||||||
|
"description": "settings for npmci"
|
||||||
|
},
|
||||||
|
"gitzone": {
|
||||||
|
"type": "object",
|
||||||
|
"description": "settings for gitzone",
|
||||||
|
"properties": {
|
||||||
|
"projectType": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": ["website", "element", "service", "npm", "wcc"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
146
changelog.md
Normal file
146
changelog.md
Normal file
@ -0,0 +1,146 @@
|
|||||||
|
# Changelog
|
||||||
|
|
||||||
|
## 2025-04-25 - 3.0.10 - fix(ci)
|
||||||
|
Update CI workflows, dependency versions, and TypeScript configuration
|
||||||
|
|
||||||
|
- Updated .gitea workflow files: changed IMAGE URL and npmci package name (@shipzone/npmci to @ship.zone/npmci)
|
||||||
|
- Upgraded development dependencies from @gitzone/* to @git.zone/* packages
|
||||||
|
- Enhanced tsconfig.json with emitDecoratorMetadata, baseUrl, and paths
|
||||||
|
- Minor code formatting improvements and trailing comma adjustments in TypeScript files
|
||||||
|
- Updated package.json homepage and added bugs/overrides configuration
|
||||||
|
|
||||||
|
## 2025-04-25 - 3.0.9 - fix(deps/ts_plugins)
|
||||||
|
Update @types/node dependency and adjust rxjs operator exports ordering
|
||||||
|
|
||||||
|
- Upgraded @types/node from ^20.8.10 to ^22.15.2 in package.json
|
||||||
|
- Reordered rxjs operator imports and exports in ts/smartrx.plugins.rxjs.ts for improved clarity
|
||||||
|
|
||||||
|
## 2024-05-29 - 3.0.8 - configuration updates
|
||||||
|
Updated project description and configuration files.
|
||||||
|
|
||||||
|
- Updated description.
|
||||||
|
- Revised tsconfig settings (2024-04-14 and 2024-04-01).
|
||||||
|
- Updated npmextra.json githost entries (2024-04-01 and 2024-03-30).
|
||||||
|
|
||||||
|
## 2023-11-04 - 3.0.7 - core
|
||||||
|
Fixed core functionality.
|
||||||
|
|
||||||
|
- Applied core fixes.
|
||||||
|
|
||||||
|
## 2023-11-01 - 3.0.6 - core
|
||||||
|
Fixed core functionality.
|
||||||
|
|
||||||
|
- Applied core fixes.
|
||||||
|
|
||||||
|
## 2023-07-24 - 3.0.5 - core
|
||||||
|
Fixed core functionality.
|
||||||
|
|
||||||
|
- Applied core fixes.
|
||||||
|
|
||||||
|
## 2023-07-24 - 3.0.4 - core
|
||||||
|
Fixed core functionality.
|
||||||
|
|
||||||
|
- Applied core fixes.
|
||||||
|
|
||||||
|
## 2023-07-24 - 3.0.3 - core
|
||||||
|
Fixed core functionality.
|
||||||
|
|
||||||
|
- Applied core fixes.
|
||||||
|
|
||||||
|
## 2023-07-12 - 3.0.2 - core
|
||||||
|
Fixed core functionality and organization scheme.
|
||||||
|
|
||||||
|
- Applied core fixes.
|
||||||
|
- Switched to new organization scheme (commit dated 2023-07-10).
|
||||||
|
|
||||||
|
## 2023-06-11 - 3.0.1 - core
|
||||||
|
Fixed core functionality.
|
||||||
|
|
||||||
|
- Applied core fixes.
|
||||||
|
|
||||||
|
## 2023-06-10 - 3.0.0 - core
|
||||||
|
Fixed core functionality.
|
||||||
|
|
||||||
|
- Applied core fixes.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 2022-08-05 - 2.0.26 to 2.0.25 - core
|
||||||
|
Included a breaking change alongside core fixes.
|
||||||
|
|
||||||
|
- BREAKING CHANGE: Switched to ESM.
|
||||||
|
- Applied core fixes.
|
||||||
|
|
||||||
|
## 2022-01-24 - 2.0.24 to 2.0.19 - core
|
||||||
|
Consolidated several minor core fixes.
|
||||||
|
|
||||||
|
- Applied multiple core update fixes.
|
||||||
|
|
||||||
|
## 2020-09-24 - 2.0.18 - core
|
||||||
|
Fixed core functionality.
|
||||||
|
|
||||||
|
- Applied core fix.
|
||||||
|
|
||||||
|
## 2020-07-12 - 2.0.17 - core
|
||||||
|
Fixed core functionality.
|
||||||
|
|
||||||
|
- Applied core fix.
|
||||||
|
|
||||||
|
## 2020-06-26 - 2.0.16 to 2.0.15 - core
|
||||||
|
Fixed core functionality.
|
||||||
|
|
||||||
|
- Applied core fixes.
|
||||||
|
|
||||||
|
## 2020-05-27 - 2.0.14 to 2.0.6 - core
|
||||||
|
Fixed core functionality across several releases.
|
||||||
|
|
||||||
|
- Applied core fixes.
|
||||||
|
|
||||||
|
## 2020-05-26 - 2.0.5 - core
|
||||||
|
Fixed core functionality.
|
||||||
|
|
||||||
|
- Applied core fix.
|
||||||
|
|
||||||
|
## 2019-09-10 - 2.0.4 to 2.0.3 - core
|
||||||
|
Fixed core functionality.
|
||||||
|
|
||||||
|
- Applied core fixes.
|
||||||
|
|
||||||
|
## 2018-12-10 to 2018-11-23 - 2.0.2 to 2.0.1 - core & dependencies
|
||||||
|
Fixed core functionality and updated dependencies.
|
||||||
|
|
||||||
|
- Applied core fixes (2.0.2).
|
||||||
|
- Updated dependencies (2.0.1 fix).
|
||||||
|
|
||||||
|
## 2018-10-10 - 2.0.0 - core
|
||||||
|
Fixed core functionality.
|
||||||
|
|
||||||
|
- Applied core fix.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 2018-10-10 - 1.0.5 - scope change
|
||||||
|
Introduced a breaking change in package scope.
|
||||||
|
|
||||||
|
- BREAKING CHANGE: Switched to the @pushrocks scope.
|
||||||
|
|
||||||
|
## 2017-11-01 - 1.0.4 - testing improvements
|
||||||
|
Enhanced test quality and intake functionality.
|
||||||
|
|
||||||
|
- Improved tests.
|
||||||
|
- Enabled working intake.
|
||||||
|
|
||||||
|
## 2017-10-30 - 1.0.3 - documentation
|
||||||
|
Updated project documentation.
|
||||||
|
|
||||||
|
- Revised docs.
|
||||||
|
|
||||||
|
## 2017-10-30 - 1.0.2 - documentation
|
||||||
|
Enhanced project information.
|
||||||
|
|
||||||
|
- Added README.
|
||||||
|
|
||||||
|
## 2017-10-26 - 1.0.1 - observable feature
|
||||||
|
Introduced observability features.
|
||||||
|
|
||||||
|
- Added observable functionality.
|
@ -5,5 +5,29 @@
|
|||||||
},
|
},
|
||||||
"npmdocker": {
|
"npmdocker": {
|
||||||
"command": "rm -r node_modules && yarn install && yarn test"
|
"command": "rm -r node_modules && yarn install && yarn test"
|
||||||
|
},
|
||||||
|
"gitzone": {
|
||||||
|
"projectType": "npm",
|
||||||
|
"module": {
|
||||||
|
"githost": "code.foss.global",
|
||||||
|
"gitscope": "push.rocks",
|
||||||
|
"gitrepo": "smartrx",
|
||||||
|
"description": "A smart wrapper for rxjs to manage and extend observables.",
|
||||||
|
"npmPackagename": "@push.rocks/smartrx",
|
||||||
|
"license": "MIT",
|
||||||
|
"keywords": [
|
||||||
|
"rxjs",
|
||||||
|
"wrapper",
|
||||||
|
"observables",
|
||||||
|
"event emitter",
|
||||||
|
"stream processing",
|
||||||
|
"reactive programming",
|
||||||
|
"backpressure",
|
||||||
|
"event handling"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"tsdoc": {
|
||||||
|
"legal": "\n## License and Legal Information\n\nThis repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository. \n\n**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.\n\n### Trademarks\n\nThis project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.\n\n### Company Information\n\nTask Venture Capital GmbH \nRegistered at District court Bremen HRB 35230 HB, Germany\n\nFor any legal inquiries or if you require further information, please contact us via email at hello@task.vc.\n\nBy using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.\n"
|
||||||
}
|
}
|
||||||
}
|
}
|
1016
package-lock.json
generated
1016
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
68
package.json
68
package.json
@ -1,27 +1,65 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartrx",
|
"name": "@push.rocks/smartrx",
|
||||||
"version": "2.0.1",
|
"version": "3.0.10",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "smart wrapper for rxjs",
|
"description": "A smart wrapper for rxjs to manage and extend observables.",
|
||||||
"main": "dist/index.js",
|
"main": "dist_ts/index.js",
|
||||||
"typings": "dist/index.d.ts",
|
"typings": "dist_ts/index.d.ts",
|
||||||
|
"type": "module",
|
||||||
"author": "Lossless GmbH",
|
"author": "Lossless GmbH",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "(tstest test/)",
|
"test": "(tstest test/)",
|
||||||
"build": "(tsbuild)"
|
"build": "(tsbuild --web && tsbundle npm)",
|
||||||
|
"buildDocs": "tsdoc"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@gitzone/tsbuild": "^2.0.22",
|
"@git.zone/tsbuild": "^2.3.2",
|
||||||
"@gitzone/tsrun": "^1.1.12",
|
"@git.zone/tsbundle": "^2.2.5",
|
||||||
"@gitzone/tstest": "^1.0.15",
|
"@git.zone/tsrun": "^1.3.3",
|
||||||
"@pushrocks/tapbundle": "^3.0.7",
|
"@git.zone/tstest": "^1.0.96",
|
||||||
"@types/node": "^10.11.6"
|
"@push.rocks/tapbundle": "^5.0.15",
|
||||||
|
"@types/node": "^22.15.2"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@pushrocks/lik": "^3.0.1",
|
"@push.rocks/smartpromise": "^4.0.2",
|
||||||
"@pushrocks/smartpromise": "^2.0.5",
|
"rxjs": "^7.8.1"
|
||||||
"rxjs": "^6.3.3",
|
},
|
||||||
"smartevent": "^1.0.1"
|
"files": [
|
||||||
|
"ts/**/*",
|
||||||
|
"ts_web/**/*",
|
||||||
|
"dist/**/*",
|
||||||
|
"dist_*/**/*",
|
||||||
|
"dist_ts/**/*",
|
||||||
|
"dist_ts_web/**/*",
|
||||||
|
"assets/**/*",
|
||||||
|
"cli.js",
|
||||||
|
"npmextra.json",
|
||||||
|
"readme.md"
|
||||||
|
],
|
||||||
|
"browserslist": [
|
||||||
|
"last 1 chrome versions"
|
||||||
|
],
|
||||||
|
"keywords": [
|
||||||
|
"rxjs",
|
||||||
|
"wrapper",
|
||||||
|
"observables",
|
||||||
|
"event emitter",
|
||||||
|
"stream processing",
|
||||||
|
"reactive programming",
|
||||||
|
"backpressure",
|
||||||
|
"event handling"
|
||||||
|
],
|
||||||
|
"homepage": "https://code.foss.global/push.rocks/smartrx#readme",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://code.foss.global/push.rocks/smartrx.git"
|
||||||
|
},
|
||||||
|
"packageManager": "pnpm@10.7.0+sha512.6b865ad4b62a1d9842b61d674a393903b871d9244954f652b8842c2b553c72176b278f64c463e52d40fff8aba385c235c8c9ecf5cc7de4fd78b8bb6d49633ab6",
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://code.foss.global/push.rocks/smartrx/issues"
|
||||||
|
},
|
||||||
|
"pnpm": {
|
||||||
|
"overrides": {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
9849
pnpm-lock.yaml
generated
Normal file
9849
pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
1
readme.hints.md
Normal file
1
readme.hints.md
Normal file
@ -0,0 +1 @@
|
|||||||
|
|
128
readme.md
128
readme.md
@ -1,33 +1,119 @@
|
|||||||
# smartrx
|
# @push.rocks/smartrx
|
||||||
|
|
||||||
smart wrapper for rxjs
|
smart wrapper for rxjs
|
||||||
|
|
||||||
## Availabililty
|
## Install
|
||||||
|
|
||||||
[](https://www.npmjs.com/package/smartrx)
|
To install `@push.rocks/smartrx`, run the following command in your terminal:
|
||||||
[](https://GitLab.com/pushrocks/smartrx)
|
|
||||||
[](https://github.com/pushrocks/smartrx)
|
|
||||||
[](https://pushrocks.gitlab.io/smartrx/)
|
|
||||||
|
|
||||||
## Status for master
|
```bash
|
||||||
|
npm install @push.rocks/smartrx --save
|
||||||
|
```
|
||||||
|
|
||||||
[](https://GitLab.com/pushrocks/smartrx/commits/master)
|
This package is distributed via npm and should be saved as a dependency in your project's `package.json` file once installed.
|
||||||
[](https://GitLab.com/pushrocks/smartrx/commits/master)
|
|
||||||
[](https://www.npmjs.com/package/smartrx)
|
|
||||||
[](https://david-dm.org/pushrocks/smartrx)
|
|
||||||
[](https://www.bithound.io/github/pushrocks/smartrx/master/dependencies/npm)
|
|
||||||
[](https://www.bithound.io/github/pushrocks/smartrx)
|
|
||||||
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
|
||||||
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
|
||||||
[](http://standardjs.com/)
|
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
Use TypeScript for best in class instellisense.
|
`@push.rocks/smartrx` provides a smart wrapper for working with RxJS, enhancing its already powerful reactive programming capabilities with additional functionalities, including easier observable map management and observable intake handling. We'll explore key features and how to use them in TypeScript.
|
||||||
|
|
||||||
For further information read the linked docs at the top of this README.
|
First, ensure you're working in an environment configured for TypeScript and modern JavaScript development.
|
||||||
|
|
||||||
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
### Basic Setup
|
||||||
> | By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
|
|
||||||
|
|
||||||
[](https://push.rocks)
|
To start using `@push.rocks/smartrx`, first, import what you need from the package:
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
import { Observablemap, ObservableIntake, rxjs } from '@push.rocks/smartrx';
|
||||||
|
```
|
||||||
|
|
||||||
|
### Observable Map Management
|
||||||
|
|
||||||
|
`Observablemap` helps manage observables efficiently, especially useful when you need to ensure a single observable per event or when working with event emitters.
|
||||||
|
|
||||||
|
#### Basic Observablemap Use
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
import { Observablemap } from '@push.rocks/smartrx';
|
||||||
|
import { EventEmitter } from 'events';
|
||||||
|
|
||||||
|
// Initialize Observablemap
|
||||||
|
const observableMap = new Observablemap();
|
||||||
|
|
||||||
|
// Your event emitter (node.js events in this case)
|
||||||
|
const myEmitter = new EventEmitter();
|
||||||
|
|
||||||
|
// Get a Subject for a specific event
|
||||||
|
const myEventSubject = observableMap.getSubjectForEmitterEvent(myEmitter, 'myEvent');
|
||||||
|
|
||||||
|
// Subscribe to the Subject
|
||||||
|
myEventSubject.subscribe({
|
||||||
|
next: (value) => console.log(`Received value: ${value}`),
|
||||||
|
});
|
||||||
|
|
||||||
|
// Emit events
|
||||||
|
myEmitter.emit('myEvent', 'Hello World!');
|
||||||
|
```
|
||||||
|
|
||||||
|
This approach ensures that you have a single observable (Subject in this case) per event, efficiently reusing existing observables instead of creating new ones for the same event.
|
||||||
|
|
||||||
|
### Observable Intake
|
||||||
|
|
||||||
|
`ObservableIntake` is designed for efficiently managing and controlling the flow of data through observables, offering features like buffering and intake requests.
|
||||||
|
|
||||||
|
#### Using ObservableIntake
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
import { ObservableIntake } from '@push.rocks/smartrx';
|
||||||
|
|
||||||
|
// Initialize ObservableIntake
|
||||||
|
const observableIntake = new ObservableIntake<string>();
|
||||||
|
|
||||||
|
// Listen to the observableIntake as you would with any RxJS Observable
|
||||||
|
observableIntake.subscribe({
|
||||||
|
next: (message) => console.log(message),
|
||||||
|
complete: () => console.log('No more messages'),
|
||||||
|
});
|
||||||
|
|
||||||
|
// Push messages into the observable intake
|
||||||
|
observableIntake.push('Hello');
|
||||||
|
observableIntake.push('World');
|
||||||
|
|
||||||
|
// Signal completion
|
||||||
|
observableIntake.signalComplete();
|
||||||
|
```
|
||||||
|
|
||||||
|
`ObservableIntake` offers the flexibility of adding values as they come and controlling when those values are emitted to subscribers, including buffering capabilities for managing backpressure.
|
||||||
|
|
||||||
|
#### Advanced Use-cases
|
||||||
|
|
||||||
|
`@push.rocks/smartrx` is built to handle more sophisticated scenarios like working with streams or handling events in a web environment.
|
||||||
|
|
||||||
|
- **From Streams with Backpressure**: Efficiently create observables from Node.js streams, applying backpressure as needed.
|
||||||
|
- **Event Management in Browsers**: Easily map browser events to observables, enabling reactive programming principles in frontend development.
|
||||||
|
|
||||||
|
### Conclusion
|
||||||
|
|
||||||
|
`@push.rocks/smartrx` significantly simplifies some of the more tedious aspects of working with RxJS, making it easier to manage observables related to event emitters and providing helpful utilities like observable intake for controlling data flow. With its smart wrappers, developers can focus more on business logic rather than boilerplate code for observable management.
|
||||||
|
|
||||||
|
For more complex use cases, such as integrating with external data sources or managing complex state with Redux, `@push.rocks/smartrx` offers a solid foundation for building reactive applications with ease and efficiency.
|
||||||
|
|
||||||
|
Remember, reactive programming with RxJS is a powerful paradigm that can make handling asynchronous data streams simpler and more maintainable. `@push.rocks/smartrx` enhances this paradigm by providing tools that make working with RxJS even more pleasant and productive.
|
||||||
|
|
||||||
|
## License and Legal Information
|
||||||
|
|
||||||
|
This repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository.
|
||||||
|
|
||||||
|
**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.
|
||||||
|
|
||||||
|
### Trademarks
|
||||||
|
|
||||||
|
This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.
|
||||||
|
|
||||||
|
### Company Information
|
||||||
|
|
||||||
|
Task Venture Capital GmbH
|
||||||
|
Registered at District court Bremen HRB 35230 HB, Germany
|
||||||
|
|
||||||
|
For any legal inquiries or if you require further information, please contact us via email at hello@task.vc.
|
||||||
|
|
||||||
|
By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
import { tap, expect } from '@pushrocks/tapbundle';
|
import { tap, expect } from '@push.rocks/tapbundle';
|
||||||
|
|
||||||
import * as smartrx from '../ts/index';
|
import * as smartrx from '../ts/index.js';
|
||||||
|
|
||||||
tap.test('should create a valid instance of observableinstake', async () => {
|
tap.test('should create a valid instance of observableinstake', async () => {
|
||||||
const testObservableIntake = new smartrx.ObservableIntake();
|
const testObservableIntake = new smartrx.ObservableIntake();
|
||||||
expect(testObservableIntake).to.be.instanceOf(smartrx.ObservableIntake);
|
expect(testObservableIntake).toBeInstanceOf(smartrx.ObservableIntake);
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.test('expect testObserservableIntake to push things', async tools => {
|
tap.test('expect testObserservableIntake to push things', async (tools) => {
|
||||||
const testObserservableIntake = new smartrx.ObservableIntake();
|
const testObserservableIntake = new smartrx.ObservableIntake();
|
||||||
testObserservableIntake.subscribe(value => {
|
testObserservableIntake.subscribe((value: any) => {
|
||||||
console.log(value);
|
console.log(value);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -19,13 +19,13 @@ tap.test('expect testObserservableIntake to push things', async tools => {
|
|||||||
await testObserservableIntake.completed;
|
await testObserservableIntake.completed;
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.test('expect testObserservableIntake to push things', async tools => {
|
tap.test('expect testObserservableIntake to push things', async (tools) => {
|
||||||
const testObserservableIntake = new smartrx.ObservableIntake();
|
const testObserservableIntake = new smartrx.ObservableIntake();
|
||||||
testObserservableIntake.push('hi');
|
testObserservableIntake.push('hi');
|
||||||
testObserservableIntake.push('wow');
|
testObserservableIntake.push('wow');
|
||||||
testObserservableIntake.makeBuffered();
|
testObserservableIntake.makeBuffered();
|
||||||
testObserservableIntake.push('jo');
|
testObserservableIntake.push('jo');
|
||||||
testObserservableIntake.subscribe(value => {
|
testObserservableIntake.subscribe((value: any) => {
|
||||||
console.log(value);
|
console.log(value);
|
||||||
testObserservableIntake.signalComplete();
|
testObserservableIntake.signalComplete();
|
||||||
});
|
});
|
@ -1,11 +1,11 @@
|
|||||||
// import test framework
|
// import test framework
|
||||||
import { expect, tap } from '@pushrocks/tapbundle';
|
import { expect, tap } from '@push.rocks/tapbundle';
|
||||||
import * as events from 'events';
|
import * as events from 'events';
|
||||||
import * as rx from 'rxjs';
|
import * as rx from 'rxjs';
|
||||||
import * as smartpromise from '@pushrocks/smartpromise';
|
import * as smartpromise from '@push.rocks/smartpromise';
|
||||||
|
|
||||||
// import the module
|
// import the module
|
||||||
import * as smartrx from '../ts/index';
|
import * as smartrx from '../ts/index.js';
|
||||||
|
|
||||||
let testObservablemap: smartrx.Observablemap;
|
let testObservablemap: smartrx.Observablemap;
|
||||||
let testObservable1: rx.Observable<any>;
|
let testObservable1: rx.Observable<any>;
|
||||||
@ -15,20 +15,20 @@ let testEmitter: events.EventEmitter;
|
|||||||
|
|
||||||
tap.test('should create an instance', async () => {
|
tap.test('should create an instance', async () => {
|
||||||
testObservablemap = new smartrx.Observablemap();
|
testObservablemap = new smartrx.Observablemap();
|
||||||
expect(testObservablemap).be.instanceof(smartrx.Observablemap);
|
expect(testObservablemap).toBeInstanceOf(smartrx.Observablemap);
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.test('should accept a new emitter', async () => {
|
tap.test('should accept a new emitter', async () => {
|
||||||
let done = smartpromise.defer();
|
let done = smartpromise.defer();
|
||||||
testEmitter = new events.EventEmitter();
|
testEmitter = new events.EventEmitter();
|
||||||
testObservable1 = testObservablemap.getObservableForEmitterEvent(testEmitter, 'event1');
|
testObservable1 = testObservablemap.getSubjectForEmitterEvent(testEmitter, 'event1');
|
||||||
testObservable1.subscribe(x => {
|
testObservable1.subscribe((x) => {
|
||||||
done.resolve();
|
done.resolve();
|
||||||
});
|
});
|
||||||
testObservable2 = testObservablemap.getObservableForEmitterEvent(testEmitter, 'event1');
|
testObservable2 = testObservablemap.getSubjectForEmitterEvent(testEmitter, 'event1');
|
||||||
testObservable3 = testObservablemap.getObservableForEmitterEvent(testEmitter, 'event2');
|
testObservable3 = testObservablemap.getSubjectForEmitterEvent(testEmitter, 'event2');
|
||||||
expect(testObservable1 === testObservable2).to.be.true;
|
expect(testObservable1 === testObservable2).toBeTrue();
|
||||||
expect(testObservable1 === testObservable3).to.be.false;
|
expect(testObservable1 === testObservable3).toBeFalse();
|
||||||
testEmitter.emit('event1');
|
testEmitter.emit('event1');
|
||||||
await done.promise;
|
await done.promise;
|
||||||
});
|
});
|
8
ts/00_commitinfo_data.ts
Normal file
8
ts/00_commitinfo_data.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
/**
|
||||||
|
* autocreated commitinfo by @push.rocks/commitinfo
|
||||||
|
*/
|
||||||
|
export const commitinfo = {
|
||||||
|
name: '@push.rocks/smartrx',
|
||||||
|
version: '3.0.10',
|
||||||
|
description: 'A smart wrapper for rxjs to manage and extend observables.'
|
||||||
|
}
|
13
ts/index.ts
13
ts/index.ts
@ -1,9 +1,6 @@
|
|||||||
import * as plugins from './smartrx.plugins';
|
import * as plugins from './smartrx.plugins.js';
|
||||||
|
export * from './smartrx.classes.observablemap.js';
|
||||||
export let standardExport = 'Hi there! :) This is a exported string';
|
export * from './smartrx.classes.observableintake.js';
|
||||||
export * from './smartrx.classes.observablemap';
|
export * from './smartrx.functions.js';
|
||||||
export * from './smartrx.classes.observableintake';
|
import * as rxjs from './smartrx.plugins.rxjs.js';
|
||||||
|
|
||||||
import * as rxjs from 'rxjs';
|
|
||||||
|
|
||||||
export { rxjs };
|
export { rxjs };
|
||||||
|
@ -1,45 +1,45 @@
|
|||||||
import * as plugins from './smartrx.plugins';
|
import * as plugins from './smartrx.plugins.js';
|
||||||
import { Observable, Subscription } from 'rxjs';
|
|
||||||
import { Deferred } from 'smartq';
|
import * as rxjs from './smartrx.plugins.rxjs.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ObservableIntake
|
* ObservableIntake
|
||||||
*/
|
*/
|
||||||
export class ObservableIntake<T> {
|
export class ObservableIntake<T> {
|
||||||
observable: Observable<T>;
|
public observable: rxjs.Observable<T>;
|
||||||
completed: Promise<void>;
|
public completed: Promise<void>;
|
||||||
private completedDeffered: Deferred<void>;
|
private completedDeffered: plugins.smartpromise.Deferred<void>;
|
||||||
private observableFunctions: any = {
|
private observableFunctions: any = {
|
||||||
next: payloadArg => {
|
next: (payloadArg: T) => {
|
||||||
// nothing
|
// nothing
|
||||||
},
|
},
|
||||||
complete: payloadArg => {
|
complete: (payloadArg: T) => {
|
||||||
// nothing
|
// nothing
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
private generator = null;
|
private generator: Generator<T> = null;
|
||||||
private buffered = false;
|
private buffered = false;
|
||||||
private payloadBuffer = [];
|
private payloadBuffer: any[] = [];
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this.observable = Observable.create(observerArg => {
|
this.observable = new rxjs.Observable((observerArg: rxjs.Observer<any>) => {
|
||||||
this.observableFunctions.next = (...args) => {
|
this.observableFunctions.next = (...args: any) => {
|
||||||
return observerArg.next(...args);
|
return observerArg.next(args);
|
||||||
};
|
};
|
||||||
this.observableFunctions.complete = (...args) => {
|
this.observableFunctions.complete = () => {
|
||||||
this.completedDeffered.resolve();
|
this.completedDeffered.resolve();
|
||||||
return observerArg.complete(...args);
|
return observerArg.complete();
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
this.completedDeffered = plugins.smartpromise.defer();
|
this.completedDeffered = plugins.smartpromise.defer();
|
||||||
this.completed = this.completedDeffered.promise;
|
this.completed = this.completedDeffered.promise;
|
||||||
}
|
}
|
||||||
|
|
||||||
setObservable(observableFunc) {
|
public setObservable(observableFunc: rxjs.Observable<any>) {
|
||||||
this.observable = observableFunc();
|
this.observable = observableFunc;
|
||||||
}
|
}
|
||||||
|
|
||||||
push(payloadArg: T) {
|
public push(payloadArg: T) {
|
||||||
if (this.buffered) {
|
if (this.buffered) {
|
||||||
this.payloadBuffer.push(payloadArg);
|
this.payloadBuffer.push(payloadArg);
|
||||||
} else {
|
} else {
|
||||||
@ -51,8 +51,8 @@ export class ObservableIntake<T> {
|
|||||||
* pushes many payloads as array
|
* pushes many payloads as array
|
||||||
* @param payloadArgArray
|
* @param payloadArgArray
|
||||||
*/
|
*/
|
||||||
pushMany(payloadArgArray: T[]) {
|
public pushMany(payloadArgArray: T[]) {
|
||||||
for (let item of payloadArgArray) {
|
for (const item of payloadArgArray) {
|
||||||
this.push(item);
|
this.push(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -61,15 +61,15 @@ export class ObservableIntake<T> {
|
|||||||
* sets a generator to query the next pushed value
|
* sets a generator to query the next pushed value
|
||||||
* @param generatorArg
|
* @param generatorArg
|
||||||
*/
|
*/
|
||||||
setGenerator(generatorArg) {
|
public setGenerator(generatorArg: Generator<T>) {
|
||||||
this.generator = generatorArg;
|
this.generator = generatorArg;
|
||||||
}
|
}
|
||||||
|
|
||||||
makeBuffered() {
|
public makeBuffered() {
|
||||||
this.buffered = true;
|
this.buffered = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
subscribe(...args) {
|
public subscribe(...args: any) {
|
||||||
return this.observable.subscribe(...args);
|
return this.observable.subscribe(...args);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,7 +77,7 @@ export class ObservableIntake<T> {
|
|||||||
* request the next values in the quantity specified
|
* request the next values in the quantity specified
|
||||||
* @param howManyArg if a generator is set, of a buffer exists, this allows retrieving values
|
* @param howManyArg if a generator is set, of a buffer exists, this allows retrieving values
|
||||||
*/
|
*/
|
||||||
request(howManyArg: number) {
|
public request(howManyArg: number) {
|
||||||
if (howManyArg === 0) {
|
if (howManyArg === 0) {
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
@ -85,8 +85,8 @@ export class ObservableIntake<T> {
|
|||||||
if (this.payloadBuffer.length > 0) {
|
if (this.payloadBuffer.length > 0) {
|
||||||
this.internalPush(this.payloadBuffer.shift());
|
this.internalPush(this.payloadBuffer.shift());
|
||||||
} else {
|
} else {
|
||||||
const nextPayload = this.generator();
|
const nextPayload = this.generator.next();
|
||||||
this.internalPush(nextPayload);
|
this.internalPush(nextPayload.value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -95,11 +95,11 @@ export class ObservableIntake<T> {
|
|||||||
/**
|
/**
|
||||||
* signals the completion of this observable
|
* signals the completion of this observable
|
||||||
*/
|
*/
|
||||||
signalComplete() {
|
public signalComplete() {
|
||||||
this.observableFunctions.complete();
|
this.observableFunctions.complete();
|
||||||
}
|
}
|
||||||
|
|
||||||
private internalPush(payloadArg) {
|
private internalPush(payloadArg: T) {
|
||||||
this.observableFunctions.next(payloadArg);
|
this.observableFunctions.next(payloadArg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,16 @@
|
|||||||
import * as plugins from './smartrx.plugins';
|
import * as plugins from './smartrx.plugins.js';
|
||||||
import { Observable, fromEvent } from 'rxjs';
|
import * as rxjs from './smartrx.plugins.rxjs.js';
|
||||||
import { Objectmap, Stringmap } from '@pushrocks/lik';
|
|
||||||
|
export interface IEventEmitter<T = any> {
|
||||||
|
on: (eventNameArg: string, eventHandlerArg: (eventPayload: T) => any) => void;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* bundles an observable with an emitter
|
* bundles an observable with an emitter
|
||||||
*/
|
*/
|
||||||
export interface ObservableEmitterBundle {
|
export interface IObservableEventBundle<T> {
|
||||||
observable: plugins.rxjs.Observable<any>;
|
subject: rxjs.Subject<any>;
|
||||||
emitter: plugins.events.EventEmitter;
|
eventRef: T;
|
||||||
event: string;
|
event: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -14,26 +18,56 @@ export interface ObservableEmitterBundle {
|
|||||||
* manages observables by making sure that only one observable is regsitered per event
|
* manages observables by making sure that only one observable is regsitered per event
|
||||||
*/
|
*/
|
||||||
export class Observablemap {
|
export class Observablemap {
|
||||||
ObservableEmitterBundleObjectmap = new Objectmap<ObservableEmitterBundle>();
|
public observableEventEmitterBundleArray = new Array<
|
||||||
|
IObservableEventBundle<IEventEmitter<unknown>>
|
||||||
|
>();
|
||||||
|
public observableEventTargetBundleArray = new Array<IObservableEventBundle<EventTarget>>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* creates a new observable if not yet registered for the same event.
|
* creates a hot subject if not yet registered for the event.
|
||||||
* In case event has been registered before the same observable is returned.
|
* In case event has been registered before the same observable is returned.
|
||||||
*/
|
*/
|
||||||
getObservableForEmitterEvent(emitterArg: plugins.events.EventEmitter, eventArg: string) {
|
public getSubjectForEmitterEvent<T>(
|
||||||
let existingBundle = this.ObservableEmitterBundleObjectmap.find(bundleArg => {
|
emitterArg: IEventEmitter<T>,
|
||||||
return bundleArg.emitter === emitterArg && bundleArg.event === eventArg;
|
eventArg: string,
|
||||||
|
): rxjs.Subject<T> {
|
||||||
|
const existingBundle = this.observableEventEmitterBundleArray.find((bundleArg) => {
|
||||||
|
return bundleArg.eventRef === emitterArg && bundleArg.event === eventArg;
|
||||||
});
|
});
|
||||||
if (existingBundle) {
|
if (existingBundle) {
|
||||||
return existingBundle.observable;
|
return existingBundle.subject;
|
||||||
} else {
|
} else {
|
||||||
let emitterObservable = fromEvent(emitterArg, eventArg);
|
const emitterObservable = rxjs.fromEvent<T>(emitterArg as any, eventArg);
|
||||||
this.ObservableEmitterBundleObjectmap.add({
|
const emitterSubject = new rxjs.Subject();
|
||||||
observable: emitterObservable,
|
emitterObservable.subscribe(emitterSubject);
|
||||||
emitter: emitterArg,
|
const newBundle: IObservableEventBundle<IEventEmitter> = {
|
||||||
event: eventArg
|
subject: emitterSubject,
|
||||||
});
|
eventRef: emitterArg,
|
||||||
return emitterObservable;
|
event: eventArg,
|
||||||
|
};
|
||||||
|
this.observableEventEmitterBundleArray.push(newBundle);
|
||||||
|
return newBundle.subject;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public getSubjectForEventTarget<T>(
|
||||||
|
eventTargetArg: EventTarget,
|
||||||
|
eventNameArg: string,
|
||||||
|
): rxjs.Subject<T> {
|
||||||
|
const existingBundle = this.observableEventTargetBundleArray.find((bundleArg) => {
|
||||||
|
return bundleArg.eventRef === eventTargetArg && bundleArg.event === eventNameArg;
|
||||||
|
});
|
||||||
|
if (existingBundle) {
|
||||||
|
return existingBundle.subject;
|
||||||
|
} else {
|
||||||
|
const emitterSubject = new rxjs.Subject();
|
||||||
|
const newBundle: IObservableEventBundle<EventTarget> = {
|
||||||
|
subject: emitterSubject,
|
||||||
|
eventRef: eventTargetArg,
|
||||||
|
event: eventNameArg,
|
||||||
|
};
|
||||||
|
this.observableEventTargetBundleArray.push(newBundle);
|
||||||
|
return newBundle.subject;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
32
ts/smartrx.functions.ts
Normal file
32
ts/smartrx.functions.ts
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
import { Observable } from 'rxjs';
|
||||||
|
import type { Readable } from 'stream';
|
||||||
|
|
||||||
|
export function fromStreamWithBackpressure<T>(stream: Readable): Observable<T> {
|
||||||
|
return new Observable<T>((subscriber) => {
|
||||||
|
const pauseStream = () => stream.pause();
|
||||||
|
const resumeStream = () => process.nextTick(() => stream.resume());
|
||||||
|
|
||||||
|
// Handler for each piece of data
|
||||||
|
const onData = (data: T) => {
|
||||||
|
// Pause the stream to apply backpressure
|
||||||
|
pauseStream();
|
||||||
|
// Emit data and resume the stream if the subscriber is ready
|
||||||
|
subscriber.next(data);
|
||||||
|
resumeStream();
|
||||||
|
};
|
||||||
|
|
||||||
|
// Subscribe to stream events
|
||||||
|
stream.on('data', onData);
|
||||||
|
stream.on('error', (error) => subscriber.error(error));
|
||||||
|
stream.on('end', () => subscriber.complete());
|
||||||
|
stream.on('close', () => subscriber.complete());
|
||||||
|
|
||||||
|
// If the subscriber unsubscribes, clean up the stream listeners
|
||||||
|
return () => {
|
||||||
|
stream.removeListener('data', onData);
|
||||||
|
stream.removeListener('error', subscriber.error);
|
||||||
|
stream.removeListener('end', subscriber.complete);
|
||||||
|
stream.removeListener('close', subscriber.complete);
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
31
ts/smartrx.plugins.rxjs.ts
Normal file
31
ts/smartrx.plugins.rxjs.ts
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
// this file is intended to keep the bundle size down
|
||||||
|
|
||||||
|
export { Observable, Subject, fromEvent, ReplaySubject, Subscription, from, of } from 'rxjs';
|
||||||
|
|
||||||
|
export type { Observer } from 'rxjs';
|
||||||
|
|
||||||
|
import {
|
||||||
|
buffer,
|
||||||
|
bufferCount,
|
||||||
|
bufferTime,
|
||||||
|
debounce,
|
||||||
|
debounceTime,
|
||||||
|
filter,
|
||||||
|
map,
|
||||||
|
startWith,
|
||||||
|
takeUntil,
|
||||||
|
throttleTime,
|
||||||
|
} from 'rxjs/operators';
|
||||||
|
|
||||||
|
export const ops = {
|
||||||
|
buffer,
|
||||||
|
bufferCount,
|
||||||
|
bufferTime,
|
||||||
|
debounce,
|
||||||
|
debounceTime,
|
||||||
|
filter,
|
||||||
|
map,
|
||||||
|
startWith,
|
||||||
|
takeUntil,
|
||||||
|
throttleTime,
|
||||||
|
};
|
@ -1,7 +1,3 @@
|
|||||||
import * as events from 'events';
|
import * as smartpromise from '@push.rocks/smartpromise';
|
||||||
import * as lik from '@pushrocks/lik';
|
|
||||||
import * as rxjs from 'rxjs';
|
|
||||||
import * as smartevent from 'smartevent';
|
|
||||||
import * as smartpromise from '@pushrocks/smartpromise';
|
|
||||||
|
|
||||||
export { events, lik, rxjs, smartevent, smartpromise };
|
export { smartpromise };
|
||||||
|
17
tsconfig.json
Normal file
17
tsconfig.json
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"experimentalDecorators": true,
|
||||||
|
"emitDecoratorMetadata": true,
|
||||||
|
"useDefineForClassFields": false,
|
||||||
|
"target": "ES2022",
|
||||||
|
"module": "NodeNext",
|
||||||
|
"moduleResolution": "NodeNext",
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"verbatimModuleSyntax": true,
|
||||||
|
"baseUrl": ".",
|
||||||
|
"paths": {}
|
||||||
|
},
|
||||||
|
"exclude": [
|
||||||
|
"dist_*/**/*.d.ts"
|
||||||
|
]
|
||||||
|
}
|
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"extends": "tslint-config-standard"
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user