@idlebox/browser 0.0.19 → 0.0.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "monorepo": "rush",
3
- "version": "0.0.19",
3
+ "version": "0.0.20",
4
4
  "license": "MIT",
5
5
  "name": "@idlebox/browser",
6
6
  "repository": "https://github.com/GongT/baobao",
@@ -22,17 +22,17 @@
22
22
  "watch": "build-script watch"
23
23
  },
24
24
  "dependencies": {
25
- "@idlebox/common": "^1.3.4",
25
+ "@idlebox/common": "workspace:^1.3.8",
26
26
  "source-map-support": "^0.5.21",
27
- "tslib": "^2.3.1"
27
+ "tslib": "^2.4.0"
28
28
  },
29
29
  "devDependencies": {
30
- "@build-script/builder": "^3.2.4",
31
- "@build-script/typescript-transformer-dual-package": "^1.0.25",
32
- "@build-script/export-all-in-one": "^3.1.2",
33
- "@build-script/single-dog-asset": "^1.0.16",
30
+ "@build-script/builder": "workspace:^3.2.5",
31
+ "@build-script/typescript-transformer-dual-package": "workspace:^1.0.26",
32
+ "@build-script/export-all-in-one": "workspace:^3.1.3",
33
+ "@build-script/single-dog-asset": "workspace:^1.0.18",
34
34
  "gulp": "^4.0.2",
35
- "typescript": "^4.6.2",
35
+ "typescript": "^4.7.4",
36
36
  "ttypescript": "^1.5.13"
37
37
  }
38
38
  }
@@ -1,36 +0,0 @@
1
- import { WrappedConsole, WrappedConsoleOptions } from '@idlebox/common';
2
-
3
- interface WebConsoleOptions {
4
- color?: boolean | Partial<typeof colorMap>;
5
- }
6
-
7
- const colorMap = {
8
- info: 'color:blue',
9
- success: 'color:green',
10
- debug: 'color:gray',
11
- error: 'color:red',
12
- trace: 'color:gray',
13
- warn: 'color:yellow',
14
- assert: 'background:red;color:white',
15
- };
16
-
17
- export class WrappedWebConsole extends WrappedConsole {
18
- private readonly colors: Record<string, string> = colorMap;
19
-
20
- constructor(title: string, { color, ...opt }: WrappedConsoleOptions & WebConsoleOptions = {}) {
21
- super(title, opt);
22
- if (color === false) {
23
- this.colors = {};
24
- } else if (typeof color === 'object') {
25
- this.colors = { ...colorMap, ...color };
26
- }
27
- }
28
-
29
- protected processColorLabel(msg: any[], pos: number, level: string, prefix: string): void {
30
- if (this.colors[level]) {
31
- msg.splice(pos, 1, `%c${prefix}${msg[pos]}`, this.colors[level]);
32
- } else {
33
- msg[pos] = `${prefix}${msg[pos]}`;
34
- }
35
- }
36
- }
@@ -1,60 +0,0 @@
1
- export class TimeoutStorage<T> {
2
- private readonly valueKey: string;
3
- private readonly expireKey: string;
4
-
5
- constructor(key: string, private readonly storage: Storage = localStorage) {
6
- this.valueKey = key + '::value';
7
- this.expireKey = key + '::expire';
8
- }
9
-
10
- save(data: Readonly<T>, expire: string | Date) {
11
- if (expire instanceof Date) {
12
- expire = expire.toUTCString();
13
- }
14
-
15
- // console.log('[%s] add [%s] %s', this.key, expire, data);
16
- this.storage.setItem(this.valueKey, JSON.stringify(data));
17
- this.storage.setItem(this.expireKey, expire);
18
- }
19
-
20
- forget() {
21
- // console.log('[%s] forget.', this.key);
22
- this.storage.removeItem(this.valueKey);
23
- }
24
-
25
- getExpire() {
26
- const o = this.storage.getItem(this.expireKey);
27
- if (!o || new Date(o) < new Date()) {
28
- // console.log('[%s] outdate.', this.key);
29
- this.forget();
30
- return null;
31
- }
32
-
33
- return new Date(o);
34
- }
35
-
36
- read(defaultVal: Readonly<T>): Readonly<T>;
37
- read(): Readonly<T> | undefined;
38
-
39
- read(defaultVal?: Readonly<T>): Readonly<T> | undefined {
40
- const json = this.storage.getItem(this.valueKey);
41
- if (!json) {
42
- return defaultVal;
43
- }
44
-
45
- const o = this.storage.getItem(this.expireKey);
46
- if (!o || new Date(o) < new Date()) {
47
- // console.log('[%s] outdate.', this.key);
48
- this.forget();
49
- return defaultVal;
50
- }
51
-
52
- try {
53
- return JSON.parse(json);
54
- } catch (e) {
55
- // console.warn('[%s] JSON %s', this.key, e.message);
56
- this.forget();
57
- return defaultVal;
58
- }
59
- }
60
- }
package/src/tsconfig.json DELETED
@@ -1,11 +0,0 @@
1
- {
2
- "extends": "../node_modules/@build-script/single-dog-asset/package/tsconfig.json",
3
- "compilerOptions": {
4
- "outDir": "../lib",
5
- "rootDir": ".",
6
- "declaration": false,
7
- "declarationMap": false,
8
- "lib": ["DOM", "ESNext", "ESNext.Array", "ESNext.AsyncIterable", "ESNext.Symbol"],
9
- "types": []
10
- }
11
- }