Compare commits
129 Commits
Author | SHA1 | Date | |
---|---|---|---|
b0116a7967 | |||
6dfdfd41b9 | |||
2e9bc0db42 | |||
af837f5303 | |||
9145cc890c | |||
e3fa407c1c | |||
865e58b190 | |||
66d00d938c | |||
5c3e165625 | |||
82e282a19f | |||
16ca87923d | |||
62676cf816 | |||
c88bb03e6c | |||
98f9c51613 | |||
a0b237ca8c | |||
4a7139b6f8 | |||
48f9249313 | |||
278eda4869 | |||
ce99e04b45 | |||
c0a1e0a14f | |||
83392d18f6 | |||
270cb2533e | |||
fad367ca0b | |||
836f8d18b0 | |||
ce269ae337 | |||
727d26fae4 | |||
0f2b71ebc3 | |||
638c1a8c8c | |||
c54644949e | |||
53c26d4634 | |||
e3b1ec0633 | |||
1892bd6df1 | |||
20bdf70686 | |||
7787330d63 | |||
67c3efdd59 | |||
7655ba749a | |||
0a089b6f10 | |||
29bf694db6 | |||
019d8deadd | |||
bfef45cab3 | |||
eddc64b891 | |||
e47df19015 | |||
af96ab531b | |||
b96206e8f7 | |||
f96bfc0875 | |||
62f3dbabda | |||
5486e268ed | |||
6d61043379 | |||
ac92f355d4 | |||
140bfb4f5e | |||
4ed87cac7e | |||
d2182a6d0f | |||
b7e48313e1 | |||
9f8e30526f | |||
8dd5c97f3b | |||
58b6a9a328 | |||
1c4020824d | |||
521e5740e5 | |||
ce76702d53 | |||
4590c8f64e | |||
ab7155f198 | |||
feba451f90 | |||
1ba1b0447b | |||
e4db3ba7ee | |||
da209ecc06 | |||
e010b01c42 | |||
225c46a788 | |||
7883f1cb7d | |||
394dd88a1d | |||
1d8fee1506 | |||
88d5409c40 | |||
b8c9508d21 | |||
59f97c3254 | |||
0491493b2e | |||
aca45165f8 | |||
569c597f8b | |||
5f17ea48ed | |||
6a9cdd297a | |||
0a363b441c | |||
3af6edd5e6 | |||
9a26f1367d | |||
15dd17e7a7 | |||
3b704dbde5 | |||
48aeb16dfd | |||
b40d8452ec | |||
d8281f098a | |||
3ffee9d0d6 | |||
03dfdda812 | |||
24cce5d9b2 | |||
295e568097 | |||
846bcf66db | |||
fc7d7fd27f | |||
9829c7bb1e | |||
6827999cf8 | |||
b318fa2076 | |||
0c751e1bca | |||
cb489552f2 | |||
addd66091f | |||
c2f8199f0b | |||
5e5696cce1 | |||
44d9782487 | |||
41592a4d2f | |||
23367249ec | |||
b415bf4ee7 | |||
86b6a6c3c4 | |||
ffbfc29628 | |||
9c6e452801 | |||
96c421e96e | |||
84af99ba80 | |||
6bb20dbc7b | |||
66a7fc2afe | |||
a42faf36d2 | |||
6db7cc0e14 | |||
102d384de5 | |||
1ceae01a49 | |||
7f4adbfe9f | |||
eb72e2dccc | |||
839c80f5dd | |||
e7e96972ad | |||
799c2a58ca | |||
1955dadba3 | |||
c14fadadf7 | |||
3f1a05d3e0 | |||
5908dc8b6f | |||
d7ecf8e320 | |||
8b73f7a6bb | |||
00d9ad0af1 | |||
ef20c00999 | |||
4dab0f250a |
20
.gitignore
vendored
Normal file
20
.gitignore
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
.nogit/
|
||||
|
||||
# artifacts
|
||||
coverage/
|
||||
public/
|
||||
pages/
|
||||
|
||||
# installs
|
||||
node_modules/
|
||||
|
||||
# caches
|
||||
.yarn/
|
||||
.cache/
|
||||
.rpt2_cache
|
||||
|
||||
# builds
|
||||
dist/
|
||||
dist_*/
|
||||
|
||||
# custom
|
140
.gitlab-ci.yml
Normal file
140
.gitlab-ci.yml
Normal file
@ -0,0 +1,140 @@
|
||||
# gitzone ci_default
|
||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||
|
||||
cache:
|
||||
paths:
|
||||
- .npmci_cache/
|
||||
key: '$CI_BUILD_STAGE'
|
||||
|
||||
stages:
|
||||
- security
|
||||
- test
|
||||
- release
|
||||
- metadata
|
||||
|
||||
before_script:
|
||||
- npm install -g @shipzone/npmci
|
||||
|
||||
# ====================
|
||||
# security stage
|
||||
# ====================
|
||||
mirror:
|
||||
stage: security
|
||||
script:
|
||||
- npmci git mirror
|
||||
only:
|
||||
- tags
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
auditProductionDependencies:
|
||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||
stage: security
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci command npm install --production --ignore-scripts
|
||||
- npmci command npm config set registry https://registry.npmjs.org
|
||||
- npmci command npm audit --audit-level=high --only=prod --production
|
||||
tags:
|
||||
- docker
|
||||
allow_failure: true
|
||||
|
||||
auditDevDependencies:
|
||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||
stage: security
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci command npm install --ignore-scripts
|
||||
- npmci command npm config set registry https://registry.npmjs.org
|
||||
- npmci command npm audit --audit-level=high --only=dev
|
||||
tags:
|
||||
- docker
|
||||
allow_failure: true
|
||||
|
||||
# ====================
|
||||
# test stage
|
||||
# ====================
|
||||
|
||||
testStable:
|
||||
stage: test
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci node install stable
|
||||
- npmci npm install
|
||||
- npmci npm test
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- docker
|
||||
|
||||
testBuild:
|
||||
stage: test
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci node install stable
|
||||
- npmci npm install
|
||||
- npmci command npm run build
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- docker
|
||||
|
||||
release:
|
||||
stage: release
|
||||
script:
|
||||
- npmci node install stable
|
||||
- npmci npm publish
|
||||
only:
|
||||
- tags
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
# ====================
|
||||
# metadata stage
|
||||
# ====================
|
||||
codequality:
|
||||
stage: metadata
|
||||
allow_failure: true
|
||||
only:
|
||||
- tags
|
||||
script:
|
||||
- npmci command npm install -g typescript
|
||||
- npmci npm prepare
|
||||
- npmci npm install
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- priv
|
||||
|
||||
trigger:
|
||||
stage: metadata
|
||||
script:
|
||||
- npmci trigger
|
||||
only:
|
||||
- tags
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
pages:
|
||||
stage: metadata
|
||||
script:
|
||||
- npmci node install lts
|
||||
- npmci command npm install -g @gitzone/tsdoc
|
||||
- npmci npm prepare
|
||||
- npmci npm install
|
||||
- npmci command tsdoc
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
only:
|
||||
- tags
|
||||
artifacts:
|
||||
expire_in: 1 week
|
||||
paths:
|
||||
- public
|
||||
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"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
2
LICENSE
2
LICENSE
@ -1,6 +1,6 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2016 Push.Rocks
|
||||
Copyright (c) 2016 Lossless GmbH
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
12
README.md
12
README.md
@ -1,12 +0,0 @@
|
||||
# early
|
||||
nice module loading animation for modules that need a little starting time.
|
||||
|
||||
> **note: this package is NOT READY YET**
|
||||
|
||||
```typscript
|
||||
import * as early from "early";
|
||||
early.start();
|
||||
// do your loading stuff
|
||||
early.stop();
|
||||
```
|
||||
|
17
npmextra.json
Normal file
17
npmextra.json
Normal file
@ -0,0 +1,17 @@
|
||||
{
|
||||
"npmci": {
|
||||
"npmGlobalTools": [],
|
||||
"npmAccessLevel": "public"
|
||||
},
|
||||
"gitzone": {
|
||||
"projectType": "npm",
|
||||
"module": {
|
||||
"githost": "gitlab.com",
|
||||
"gitscope": "pushrocks",
|
||||
"gitrepo": "early",
|
||||
"description": "minimal and fast loading plugin for startup time measuring",
|
||||
"npmPackagename": "@pushrocks/early",
|
||||
"license": "MIT"
|
||||
}
|
||||
}
|
||||
}
|
18433
package-lock.json
generated
Normal file
18433
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
46
package.json
46
package.json
@ -1,14 +1,18 @@
|
||||
{
|
||||
"name": "early",
|
||||
"version": "1.0.1",
|
||||
"description": "nice module loading animation for modules that need a little starting time.",
|
||||
"main": "dist/index.js",
|
||||
"name": "@pushrocks/early",
|
||||
"version": "4.0.1",
|
||||
"private": false,
|
||||
"description": "minimal and fast loading plugin for startup time measuring",
|
||||
"main": "dist_ts/index.js",
|
||||
"typings": "dist_ts/index.d.ts",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"test": "(npmts)"
|
||||
"test": "(tstest test/)",
|
||||
"build": "(tsbuild --web)"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/pushrocks/early.git"
|
||||
"url": "git+https://gitlab.com/pushrocks/early.git"
|
||||
},
|
||||
"keywords": [
|
||||
"preloader"
|
||||
@ -16,7 +20,33 @@
|
||||
"author": "Lossless GmbH",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/pushrocks/early/issues"
|
||||
"url": "https://gitlab.com/pushrocks/early/issues"
|
||||
},
|
||||
"homepage": "https://github.com/pushrocks/early#readme"
|
||||
"homepage": "https://gitlab.com/pushrocks/early#readme",
|
||||
"devDependencies": {
|
||||
"@gitzone/tsrun": "^1.2.31",
|
||||
"@gitzone/tstest": "^1.0.69",
|
||||
"@pushrocks/smartdelay": "^2.0.13",
|
||||
"@pushrocks/tapbundle": "^5.0.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"@gitzone/tsbuild": "^2.1.60",
|
||||
"@pushrocks/consolecolor": "^2.0.1",
|
||||
"@pushrocks/smartpromise": "^3.1.7"
|
||||
},
|
||||
"files": [
|
||||
"ts/**/*",
|
||||
"ts_web/**/*",
|
||||
"dist/**/*",
|
||||
"dist_*/**/*",
|
||||
"dist_ts/**/*",
|
||||
"dist_ts_web/**/*",
|
||||
"assets/**/*",
|
||||
"cli.js",
|
||||
"npmextra.json",
|
||||
"readme.md"
|
||||
],
|
||||
"browserslist": [
|
||||
"last 1 chrome versions"
|
||||
]
|
||||
}
|
||||
|
51
readme.md
Normal file
51
readme.md
Normal file
@ -0,0 +1,51 @@
|
||||
# @pushrocks/early
|
||||
minimal and fast loading plugin for startup time measuring
|
||||
|
||||
## Availabililty and Links
|
||||
* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/early)
|
||||
* [gitlab.com (source)](https://gitlab.com/pushrocks/early)
|
||||
* [github.com (source mirror)](https://github.com/pushrocks/early)
|
||||
* [docs (typedoc)](https://pushrocks.gitlab.io/early/)
|
||||
|
||||
## Status for master
|
||||
|
||||
Status Category | Status Badge
|
||||
-- | --
|
||||
GitLab Pipelines | [](https://lossless.cloud)
|
||||
GitLab Pipline Test Coverage | [](https://lossless.cloud)
|
||||
npm | [](https://lossless.cloud)
|
||||
Snyk | [](https://lossless.cloud)
|
||||
TypeScript Support | [](https://lossless.cloud)
|
||||
node Support | [](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||
Code Style | [](https://lossless.cloud)
|
||||
PackagePhobia (total standalone install weight) | [](https://lossless.cloud)
|
||||
PackagePhobia (package size on registry) | [](https://lossless.cloud)
|
||||
BundlePhobia (total size when bundled) | [](https://lossless.cloud)
|
||||
Platform support | [](https://lossless.cloud) [](https://lossless.cloud)
|
||||
|
||||
## Usage
|
||||
|
||||
Use TypeScript for best in class instellisense.
|
||||
|
||||
```javascript
|
||||
// Put the following at the start of your module
|
||||
import * as early from 'early';
|
||||
early.start('myModuleName');
|
||||
/*
|
||||
do your loading stuff
|
||||
*/
|
||||
early.stop().then((loadingTime: number) => {
|
||||
// loadingTime in milliseconds
|
||||
}); // stop "early" when your module is ready
|
||||
```
|
||||
|
||||
## Contribution
|
||||
|
||||
We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :)
|
||||
|
||||
For further information read the linked docs at the top of this readme.
|
||||
|
||||
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
||||
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
|
||||
|
||||
[](https://maintainedby.lossless.com)
|
25
test/test.ts
Normal file
25
test/test.ts
Normal file
@ -0,0 +1,25 @@
|
||||
import { expect, expectAsync, tap } from '@pushrocks/tapbundle';
|
||||
import * as smartdelay from '@pushrocks/smartdelay';
|
||||
|
||||
import * as early from '../ts/index.js';
|
||||
|
||||
tap.test('.start()', async () => {
|
||||
process.env.CLI_CALL_MODULENAME = 'early';
|
||||
early.start('early');
|
||||
await smartdelay.delayFor(2000);
|
||||
});
|
||||
|
||||
tap.test('.stop()', async () => {
|
||||
await early.stop();
|
||||
});
|
||||
|
||||
tap.test('hrTime Measurement', async () => {
|
||||
let earlyHr = new early.HrtMeasurement();
|
||||
earlyHr.start();
|
||||
await smartdelay.delayFor(1000);
|
||||
let measuredTime = earlyHr.stop();
|
||||
console.log(measuredTime);
|
||||
return expect(measuredTime.milliSeconds).toBeGreaterThan(999);
|
||||
});
|
||||
|
||||
tap.start();
|
45
ts/early.hrtMeasurement.ts
Normal file
45
ts/early.hrtMeasurement.ts
Normal file
@ -0,0 +1,45 @@
|
||||
import * as process from 'process';
|
||||
|
||||
/**
|
||||
* easy high resolution time measurement
|
||||
*/
|
||||
export class HrtMeasurement {
|
||||
nanoSeconds: number = null;
|
||||
milliSeconds: number = null;
|
||||
private _hrTimeStart = null;
|
||||
private _hrTimeStopDiff = null;
|
||||
private _started: boolean = false;
|
||||
|
||||
/**
|
||||
* start the measurement
|
||||
*/
|
||||
start() {
|
||||
this._started = true;
|
||||
this._hrTimeStart = process.hrtime();
|
||||
}
|
||||
|
||||
/**
|
||||
* stop the measurement
|
||||
*/
|
||||
stop() {
|
||||
if (this._started === false) {
|
||||
console.log("Hasn't started yet");
|
||||
return;
|
||||
}
|
||||
this._hrTimeStopDiff = process.hrtime(this._hrTimeStart);
|
||||
this.nanoSeconds = this._hrTimeStopDiff[0] * 1e9 + this._hrTimeStopDiff[1];
|
||||
this.milliSeconds = this.nanoSeconds / 1000000;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* reset the measurement
|
||||
*/
|
||||
reset() {
|
||||
this.nanoSeconds = null;
|
||||
this.milliSeconds = null;
|
||||
this._hrTimeStart = null;
|
||||
this._hrTimeStopDiff = null;
|
||||
this._started = false;
|
||||
}
|
||||
}
|
42
ts/index.ts
Normal file
42
ts/index.ts
Normal file
@ -0,0 +1,42 @@
|
||||
import * as consolecolor from '@pushrocks/consolecolor';
|
||||
import * as smartpromise from '@pushrocks/smartpromise';
|
||||
import { HrtMeasurement } from './early.hrtMeasurement.js';
|
||||
|
||||
export { HrtMeasurement };
|
||||
|
||||
let doText: boolean = false;
|
||||
let moduleName: string = 'undefined module name';
|
||||
let startHrt: HrtMeasurement;
|
||||
|
||||
if (process.argv.indexOf('-v') === -1) {
|
||||
doText = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* start the loading
|
||||
*/
|
||||
export let start = function (moduleNameArg: string = '', loaderLengthArg: string = '10') {
|
||||
moduleName = moduleNameArg;
|
||||
startHrt = new HrtMeasurement();
|
||||
startHrt.start();
|
||||
if (doText && process.env.CLI_CALL_MODULENAME === moduleName) {
|
||||
console.log(`**** starting ${consolecolor.coloredString(moduleNameArg, 'green')} ****`);
|
||||
}
|
||||
};
|
||||
|
||||
export let stop = (): Promise<number> => {
|
||||
let done = smartpromise.defer<number>();
|
||||
let earlyExecutionTime = startHrt.stop().milliSeconds;
|
||||
let earlyExecutionTimeString: string = (earlyExecutionTime / 1000).toString();
|
||||
if (doText && process.env.CLI_CALL_MODULENAME === moduleName) {
|
||||
console.log(
|
||||
`OK! -> finished loading within ${consolecolor.coloredString(
|
||||
earlyExecutionTimeString,
|
||||
'blue'
|
||||
)}`
|
||||
);
|
||||
}
|
||||
|
||||
done.resolve(earlyExecutionTime);
|
||||
return done.promise;
|
||||
};
|
7
tsconfig.json
Normal file
7
tsconfig.json
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2022",
|
||||
"module": "ES2022",
|
||||
"moduleResolution": "nodenext"
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user