@idlebox/browser 0.0.23 → 0.0.25

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.
@@ -0,0 +1,36 @@
1
+ import { WrappedConsole } from '@idlebox/common';
2
+ import { WrappedConsoleOptions } from '@idlebox/common';
3
+
4
+ declare const colorMap: {
5
+ info: string;
6
+ success: string;
7
+ debug: string;
8
+ error: string;
9
+ trace: string;
10
+ warn: string;
11
+ assert: string;
12
+ };
13
+
14
+ export declare class TimeoutStorage<T> {
15
+ private readonly storage;
16
+ private readonly valueKey;
17
+ private readonly expireKey;
18
+ constructor(key: string, storage?: Storage);
19
+ save(data: Readonly<T>, expire: string | Date): void;
20
+ forget(): void;
21
+ getExpire(): Date | null;
22
+ read(defaultVal: Readonly<T>): Readonly<T>;
23
+ read(): Readonly<T> | undefined;
24
+ }
25
+
26
+ declare interface WebConsoleOptions {
27
+ color?: boolean | Partial<typeof colorMap>;
28
+ }
29
+
30
+ export declare class WrappedWebConsole extends WrappedConsole {
31
+ private readonly colors;
32
+ constructor(title: string, { color, ...opt }?: WrappedConsoleOptions & WebConsoleOptions);
33
+ protected processColorLabel(msg: any[], pos: number, level: string, prefix: string): void;
34
+ }
35
+
36
+ export { }
@@ -0,0 +1,36 @@
1
+ import { WrappedConsole } from '@idlebox/common';
2
+ import { WrappedConsoleOptions } from '@idlebox/common';
3
+
4
+ declare const colorMap: {
5
+ info: string;
6
+ success: string;
7
+ debug: string;
8
+ error: string;
9
+ trace: string;
10
+ warn: string;
11
+ assert: string;
12
+ };
13
+
14
+ export declare class TimeoutStorage<T> {
15
+ private readonly storage;
16
+ private readonly valueKey;
17
+ private readonly expireKey;
18
+ constructor(key: string, storage?: Storage);
19
+ save(data: Readonly<T>, expire: string | Date): void;
20
+ forget(): void;
21
+ getExpire(): Date | null;
22
+ read(defaultVal: Readonly<T>): Readonly<T>;
23
+ read(): Readonly<T> | undefined;
24
+ }
25
+
26
+ declare interface WebConsoleOptions {
27
+ color?: boolean | Partial<typeof colorMap>;
28
+ }
29
+
30
+ export declare class WrappedWebConsole extends WrappedConsole {
31
+ private readonly colors;
32
+ constructor(title: string, { color, ...opt }?: WrappedConsoleOptions & WebConsoleOptions);
33
+ protected processColorLabel(msg: any[], pos: number, level: string, prefix: string): void;
34
+ }
35
+
36
+ export { }
@@ -0,0 +1,36 @@
1
+ import { WrappedConsole } from '@idlebox/common';
2
+ import { WrappedConsoleOptions } from '@idlebox/common';
3
+
4
+ declare const colorMap: {
5
+ info: string;
6
+ success: string;
7
+ debug: string;
8
+ error: string;
9
+ trace: string;
10
+ warn: string;
11
+ assert: string;
12
+ };
13
+
14
+ export declare class TimeoutStorage<T> {
15
+ private readonly storage;
16
+ private readonly valueKey;
17
+ private readonly expireKey;
18
+ constructor(key: string, storage?: Storage);
19
+ save(data: Readonly<T>, expire: string | Date): void;
20
+ forget(): void;
21
+ getExpire(): Date | null;
22
+ read(defaultVal: Readonly<T>): Readonly<T>;
23
+ read(): Readonly<T> | undefined;
24
+ }
25
+
26
+ declare interface WebConsoleOptions {
27
+ color?: boolean | Partial<typeof colorMap>;
28
+ }
29
+
30
+ export declare class WrappedWebConsole extends WrappedConsole {
31
+ private readonly colors;
32
+ constructor(title: string, { color, ...opt }?: WrappedConsoleOptions & WebConsoleOptions);
33
+ protected processColorLabel(msg: any[], pos: number, level: string, prefix: string): void;
34
+ }
35
+
36
+ export { }
@@ -32,4 +32,4 @@ class WrappedWebConsole extends common_1.WrappedConsole {
32
32
  }
33
33
  }
34
34
  exports.WrappedWebConsole = WrappedWebConsole;
35
- //# sourceMappingURL=logger.cjs.map
35
+ //# sourceMappingURL=logger.js.map
@@ -1,10 +1 @@
1
- {
2
- "version": 3,
3
- "file": "logger.cjs",
4
- "sourceRoot": "",
5
- "sources": [
6
- "../../src/debug/logger.ts"
7
- ],
8
- "names": [],
9
- "mappings": ";;;AAAA,4CAAwE;AAMxE,MAAM,QAAQ,GAAG;IAChB,IAAI,EAAE,YAAY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AAE,cAAc;IACpB,MAAM,EAAE,4BAA4B;CACpC,CAAC;AAEF,MAAa,iBAAkB,SAAQ,uBAAc;IACnC,MAAM,GAA2B,QAAQ,CAAC;IAE3D,YAAY,KAAa,EAAE,EAAE,KAAK,EAAE,GAAG,GAAG,KAAgD,EAAE;QAC3F,KAAK,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QAClB,IAAI,KAAK,KAAK,KAAK,EAAE;YACpB,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;SACjB;aAAM,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;YACrC,IAAI,CAAC,MAAM,GAAG,EAAE,GAAG,QAAQ,EAAE,GAAG,KAAK,EAAE,CAAC;SACxC;IACF,CAAC;IAES,iBAAiB,CAAC,GAAU,EAAE,GAAW,EAAE,KAAa,EAAE,MAAc;QACjF,IAAI,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;YACvB,GAAG,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,EAAE,KAAK,MAAM,GAAG,GAAG,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;SACjE;aAAM;YACN,GAAG,CAAC,GAAG,CAAC,GAAG,GAAG,MAAM,GAAG,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;SAClC;IACF,CAAC;CACD;AAnBD,8CAmBC"}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ // DO NOT EDIT THIS FILE
3
+ // @ts-ignore
4
+ /* eslint-disable */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.TimeoutStorage = exports.WrappedWebConsole = void 0;
7
+ /* debug/logger.ts */
8
+ // Identifiers
9
+ var logger_1 = require("./debug/logger.cjs");
10
+ Object.defineProperty(exports, "WrappedWebConsole", { enumerable: true, get: function () { return logger_1.WrappedWebConsole; } });
11
+ /* storage/timeoutStorage.ts */
12
+ // Identifiers
13
+ var timeoutStorage_1 = require("./storage/timeoutStorage.cjs");
14
+ Object.defineProperty(exports, "TimeoutStorage", { enumerable: true, get: function () { return timeoutStorage_1.TimeoutStorage; } });
15
+ //# sourceMappingURL=index.generated.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.generated.js","sourceRoot":"","sources":["../src/index.generated.ts"],"names":[],"mappings":";AAAA,wBAAwB;AACxB,aAAa;AACb,oBAAoB;;;AAEpB,qBAAqB;AACpB,cAAc;AACb,6CAAiD;AAAzC,2GAAA,iBAAiB,OAAA;AAC3B,+BAA+B;AAC9B,cAAc;AACb,+DAAwD;AAAhD,gHAAA,cAAc,OAAA"}
@@ -0,0 +1,10 @@
1
+ // DO NOT EDIT THIS FILE
2
+ // @ts-ignore
3
+ /* eslint-disable */
4
+ /* debug/logger.ts */
5
+ // Identifiers
6
+ export { WrappedWebConsole } from "./debug/logger.js";
7
+ /* storage/timeoutStorage.ts */
8
+ // Identifiers
9
+ export { TimeoutStorage } from "./storage/timeoutStorage.js";
10
+ //# sourceMappingURL=index.generated.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.generated.js","sourceRoot":"","sources":["../src/index.generated.ts"],"names":[],"mappings":"AAAA,wBAAwB;AACxB,aAAa;AACb,oBAAoB;AAEpB,qBAAqB;AACpB,cAAc;AACb,OAAO,EAAC,iBAAiB,EAAC,0BAAuB;AACnD,+BAA+B;AAC9B,cAAc;AACb,OAAO,EAAC,cAAc,EAAC,oCAAiC"}
@@ -53,4 +53,4 @@ class TimeoutStorage {
53
53
  }
54
54
  }
55
55
  exports.TimeoutStorage = TimeoutStorage;
56
- //# sourceMappingURL=timeoutStorage.cjs.map
56
+ //# sourceMappingURL=timeoutStorage.js.map
@@ -1,10 +1 @@
1
- {
2
- "version": 3,
3
- "file": "timeoutStorage.cjs",
4
- "sourceRoot": "",
5
- "sources": [
6
- "../../src/storage/timeoutStorage.ts"
7
- ],
8
- "names": [],
9
- "mappings": ";;;AAAA,MAAa,cAAc;IAIgB;IAHzB,QAAQ,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IACxC,CAAC;IAED,SAAS;QACR,MAAM,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAC/C,IAAI,CAAC,CAAC,IAAI,IAAI,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,EAAE,EAAE;YACnC,0CAA0C;YAC1C,IAAI,CAAC,MAAM,EAAE,CAAC;YACd,OAAO,IAAI,CAAC;SACZ;QAED,OAAO,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC;IACpB,CAAC;IAKD,IAAI,CAAC,UAAwB;QAC5B,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACjD,IAAI,CAAC,IAAI,EAAE;YACV,OAAO,UAAU,CAAC;SAClB;QAED,MAAM,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAC/C,IAAI,CAAC,CAAC,IAAI,IAAI,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,EAAE,EAAE;YACnC,0CAA0C;YAC1C,IAAI,CAAC,MAAM,EAAE,CAAC;YACd,OAAO,UAAU,CAAC;SAClB;QAED,IAAI;YACH,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;SACxB;QAAC,OAAO,CAAC,EAAE;YACX,qDAAqD;YACrD,IAAI,CAAC,MAAM,EAAE,CAAC;YACd,OAAO,UAAU,CAAC;SAClB;IACF,CAAC;CACD;AA3DD,wCA2DC"}
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.28.3"
8
+ "packageVersion": "7.33.6"
9
9
  }
10
10
  ]
11
11
  }
package/package.json CHANGED
@@ -1,38 +1,37 @@
1
1
  {
2
2
  "name": "@idlebox/browser",
3
3
  "type": "module",
4
- "version": "0.0.23",
4
+ "version": "0.0.25",
5
5
  "license": "MIT",
6
- "main": "./lib/_export_all_in_one_index.cjs",
6
+ "main": "./lib/index.generated.cjs",
7
+ "module": "./lib/index.generated.js",
7
8
  "exports": {
8
9
  ".": {
9
- "import": "./lib/_export_all_in_one_index.js",
10
- "require": "./lib/_export_all_in_one_index.cjs"
11
- }
10
+ "import": "./lib/index.generated.js",
11
+ "require": "./lib/index.generated.cjs"
12
+ },
13
+ "./package.json": "./package.json"
12
14
  },
13
- "typings": "docs/package-public.d.ts",
15
+ "typings": "./lib/package-public.d.ts",
14
16
  "repository": "https://github.com/GongT/baobao",
15
17
  "dependencies": {
16
- "@idlebox/common": "^1.3.11",
17
18
  "source-map-support": "^0.5.21",
18
- "tslib": "^2.4.0"
19
+ "tslib": "^2.4.1",
20
+ "@idlebox/common": "1.3.16"
19
21
  },
20
22
  "devDependencies": {
21
- "@build-script/builder": "^3.2.8",
22
- "@build-script/export-all-in-one": "^3.1.6",
23
- "@build-script/single-dog-asset": "^1.0.22",
24
- "@build-script/typescript-transformer-dual-package": "^2.0.1",
25
- "gulp": "^4.0.2",
26
- "local-rig": "^1.0.0",
27
- "ttypescript": "^1.5.13",
28
- "typescript": "^4.7.4"
23
+ "@rushstack/heft": "^0.48.8",
24
+ "typescript": "^4.8.4",
25
+ "@build-script/single-dog-asset": "1.0.23",
26
+ "local-rig": "1.0.1",
27
+ "@build-script/heft-duel-stack": "1.0.7"
29
28
  },
30
29
  "monorepo": "rush",
31
30
  "scripts": {
32
- "test": "build-script test",
33
- "build": "build-script build",
34
- "clean": "rimraf lib dist .rush temp",
35
- "distclean": "build-script distclean",
36
- "watch": "build-script watch"
31
+ "lint": "heft build",
32
+ "build": "heft build --production",
33
+ "build:watch": "heft build --lite",
34
+ "watch": "heft build --watch",
35
+ "clean": "heft clean"
37
36
  }
38
37
  }
@@ -0,0 +1,36 @@
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
+ }
@@ -0,0 +1,10 @@
1
+ // DO NOT EDIT THIS FILE
2
+ // @ts-ignore
3
+ /* eslint-disable */
4
+
5
+ /* debug/logger.ts */
6
+ // Identifiers
7
+ export {WrappedWebConsole} from "./debug/logger";
8
+ /* storage/timeoutStorage.ts */
9
+ // Identifiers
10
+ export {TimeoutStorage} from "./storage/timeoutStorage";
@@ -0,0 +1,60 @@
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
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "extends": "local-rig/profiles/default/tsconfig.json",
3
+ "compilerOptions": {
4
+ "typeRoots": ["../node_modules/@types", "../node_modules"],
5
+ "tsBuildInfoFile": "../temp/tsbuildinfo.json",
6
+ "outDir": "../lib",
7
+ "declarationDir": "../temp/dts",
8
+ "rootDir": "./",
9
+ "lib": ["DOM", "ESNext", "ESNext.Array", "ESNext.AsyncIterable", "ESNext.Symbol"],
10
+ "types": []
11
+ }
12
+ }
@@ -1,670 +0,0 @@
1
- {
2
- "metadata": {
3
- "toolPackage": "@microsoft/api-extractor",
4
- "toolVersion": "7.28.3",
5
- "schemaVersion": 1009,
6
- "oldestForwardsCompatibleVersion": 1001,
7
- "tsdocConfig": {
8
- "$schema": "https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json",
9
- "noStandardTags": true,
10
- "tagDefinitions": [
11
- {
12
- "tagName": "@alpha",
13
- "syntaxKind": "modifier"
14
- },
15
- {
16
- "tagName": "@beta",
17
- "syntaxKind": "modifier"
18
- },
19
- {
20
- "tagName": "@defaultValue",
21
- "syntaxKind": "block"
22
- },
23
- {
24
- "tagName": "@decorator",
25
- "syntaxKind": "block",
26
- "allowMultiple": true
27
- },
28
- {
29
- "tagName": "@deprecated",
30
- "syntaxKind": "block"
31
- },
32
- {
33
- "tagName": "@eventProperty",
34
- "syntaxKind": "modifier"
35
- },
36
- {
37
- "tagName": "@example",
38
- "syntaxKind": "block",
39
- "allowMultiple": true
40
- },
41
- {
42
- "tagName": "@experimental",
43
- "syntaxKind": "modifier"
44
- },
45
- {
46
- "tagName": "@inheritDoc",
47
- "syntaxKind": "inline"
48
- },
49
- {
50
- "tagName": "@internal",
51
- "syntaxKind": "modifier"
52
- },
53
- {
54
- "tagName": "@label",
55
- "syntaxKind": "inline"
56
- },
57
- {
58
- "tagName": "@link",
59
- "syntaxKind": "inline",
60
- "allowMultiple": true
61
- },
62
- {
63
- "tagName": "@override",
64
- "syntaxKind": "modifier"
65
- },
66
- {
67
- "tagName": "@packageDocumentation",
68
- "syntaxKind": "modifier"
69
- },
70
- {
71
- "tagName": "@param",
72
- "syntaxKind": "block",
73
- "allowMultiple": true
74
- },
75
- {
76
- "tagName": "@privateRemarks",
77
- "syntaxKind": "block"
78
- },
79
- {
80
- "tagName": "@public",
81
- "syntaxKind": "modifier"
82
- },
83
- {
84
- "tagName": "@readonly",
85
- "syntaxKind": "modifier"
86
- },
87
- {
88
- "tagName": "@remarks",
89
- "syntaxKind": "block"
90
- },
91
- {
92
- "tagName": "@returns",
93
- "syntaxKind": "block"
94
- },
95
- {
96
- "tagName": "@sealed",
97
- "syntaxKind": "modifier"
98
- },
99
- {
100
- "tagName": "@see",
101
- "syntaxKind": "block"
102
- },
103
- {
104
- "tagName": "@throws",
105
- "syntaxKind": "block",
106
- "allowMultiple": true
107
- },
108
- {
109
- "tagName": "@typeParam",
110
- "syntaxKind": "block",
111
- "allowMultiple": true
112
- },
113
- {
114
- "tagName": "@virtual",
115
- "syntaxKind": "modifier"
116
- },
117
- {
118
- "tagName": "@betaDocumentation",
119
- "syntaxKind": "modifier"
120
- },
121
- {
122
- "tagName": "@internalRemarks",
123
- "syntaxKind": "block"
124
- },
125
- {
126
- "tagName": "@preapproved",
127
- "syntaxKind": "modifier"
128
- }
129
- ],
130
- "supportForTags": {
131
- "@alpha": true,
132
- "@beta": true,
133
- "@defaultValue": true,
134
- "@decorator": true,
135
- "@deprecated": true,
136
- "@eventProperty": true,
137
- "@example": true,
138
- "@experimental": true,
139
- "@inheritDoc": true,
140
- "@internal": true,
141
- "@label": true,
142
- "@link": true,
143
- "@override": true,
144
- "@packageDocumentation": true,
145
- "@param": true,
146
- "@privateRemarks": true,
147
- "@public": true,
148
- "@readonly": true,
149
- "@remarks": true,
150
- "@returns": true,
151
- "@sealed": true,
152
- "@see": true,
153
- "@throws": true,
154
- "@typeParam": true,
155
- "@virtual": true,
156
- "@betaDocumentation": true,
157
- "@internalRemarks": true,
158
- "@preapproved": true
159
- },
160
- "reportUnsupportedHtmlElements": false
161
- }
162
- },
163
- "kind": "Package",
164
- "canonicalReference": "@idlebox/browser!",
165
- "docComment": "",
166
- "name": "@idlebox/browser",
167
- "preserveMemberOrder": false,
168
- "members": [
169
- {
170
- "kind": "EntryPoint",
171
- "canonicalReference": "@idlebox/browser!",
172
- "name": "",
173
- "preserveMemberOrder": false,
174
- "members": [
175
- {
176
- "kind": "Class",
177
- "canonicalReference": "@idlebox/browser!TimeoutStorage:class",
178
- "docComment": "",
179
- "excerptTokens": [
180
- {
181
- "kind": "Content",
182
- "text": "export declare class TimeoutStorage<T> "
183
- }
184
- ],
185
- "releaseTag": "Public",
186
- "typeParameters": [
187
- {
188
- "typeParameterName": "T",
189
- "constraintTokenRange": {
190
- "startIndex": 0,
191
- "endIndex": 0
192
- },
193
- "defaultTypeTokenRange": {
194
- "startIndex": 0,
195
- "endIndex": 0
196
- }
197
- }
198
- ],
199
- "name": "TimeoutStorage",
200
- "preserveMemberOrder": false,
201
- "members": [
202
- {
203
- "kind": "Constructor",
204
- "canonicalReference": "@idlebox/browser!TimeoutStorage:constructor(1)",
205
- "docComment": "/**\n * Constructs a new instance of the `TimeoutStorage` class\n */\n",
206
- "excerptTokens": [
207
- {
208
- "kind": "Content",
209
- "text": "constructor(key: "
210
- },
211
- {
212
- "kind": "Content",
213
- "text": "string"
214
- },
215
- {
216
- "kind": "Content",
217
- "text": ", storage?: "
218
- },
219
- {
220
- "kind": "Reference",
221
- "text": "Storage",
222
- "canonicalReference": "!Storage:interface"
223
- },
224
- {
225
- "kind": "Content",
226
- "text": ");"
227
- }
228
- ],
229
- "releaseTag": "Public",
230
- "isProtected": false,
231
- "overloadIndex": 1,
232
- "parameters": [
233
- {
234
- "parameterName": "key",
235
- "parameterTypeTokenRange": {
236
- "startIndex": 1,
237
- "endIndex": 2
238
- },
239
- "isOptional": false
240
- },
241
- {
242
- "parameterName": "storage",
243
- "parameterTypeTokenRange": {
244
- "startIndex": 3,
245
- "endIndex": 4
246
- },
247
- "isOptional": true
248
- }
249
- ]
250
- },
251
- {
252
- "kind": "Method",
253
- "canonicalReference": "@idlebox/browser!TimeoutStorage#forget:member(1)",
254
- "docComment": "",
255
- "excerptTokens": [
256
- {
257
- "kind": "Content",
258
- "text": "forget(): "
259
- },
260
- {
261
- "kind": "Content",
262
- "text": "void"
263
- },
264
- {
265
- "kind": "Content",
266
- "text": ";"
267
- }
268
- ],
269
- "isStatic": false,
270
- "returnTypeTokenRange": {
271
- "startIndex": 1,
272
- "endIndex": 2
273
- },
274
- "releaseTag": "Public",
275
- "isProtected": false,
276
- "overloadIndex": 1,
277
- "parameters": [],
278
- "isOptional": false,
279
- "name": "forget"
280
- },
281
- {
282
- "kind": "Method",
283
- "canonicalReference": "@idlebox/browser!TimeoutStorage#getExpire:member(1)",
284
- "docComment": "",
285
- "excerptTokens": [
286
- {
287
- "kind": "Content",
288
- "text": "getExpire(): "
289
- },
290
- {
291
- "kind": "Reference",
292
- "text": "Date",
293
- "canonicalReference": "!Date:interface"
294
- },
295
- {
296
- "kind": "Content",
297
- "text": " | null"
298
- },
299
- {
300
- "kind": "Content",
301
- "text": ";"
302
- }
303
- ],
304
- "isStatic": false,
305
- "returnTypeTokenRange": {
306
- "startIndex": 1,
307
- "endIndex": 3
308
- },
309
- "releaseTag": "Public",
310
- "isProtected": false,
311
- "overloadIndex": 1,
312
- "parameters": [],
313
- "isOptional": false,
314
- "name": "getExpire"
315
- },
316
- {
317
- "kind": "Method",
318
- "canonicalReference": "@idlebox/browser!TimeoutStorage#read:member(1)",
319
- "docComment": "",
320
- "excerptTokens": [
321
- {
322
- "kind": "Content",
323
- "text": "read(defaultVal: "
324
- },
325
- {
326
- "kind": "Reference",
327
- "text": "Readonly",
328
- "canonicalReference": "!Readonly:type"
329
- },
330
- {
331
- "kind": "Content",
332
- "text": "<T>"
333
- },
334
- {
335
- "kind": "Content",
336
- "text": "): "
337
- },
338
- {
339
- "kind": "Reference",
340
- "text": "Readonly",
341
- "canonicalReference": "!Readonly:type"
342
- },
343
- {
344
- "kind": "Content",
345
- "text": "<T>"
346
- },
347
- {
348
- "kind": "Content",
349
- "text": ";"
350
- }
351
- ],
352
- "isStatic": false,
353
- "returnTypeTokenRange": {
354
- "startIndex": 4,
355
- "endIndex": 6
356
- },
357
- "releaseTag": "Public",
358
- "isProtected": false,
359
- "overloadIndex": 1,
360
- "parameters": [
361
- {
362
- "parameterName": "defaultVal",
363
- "parameterTypeTokenRange": {
364
- "startIndex": 1,
365
- "endIndex": 3
366
- },
367
- "isOptional": false
368
- }
369
- ],
370
- "isOptional": false,
371
- "name": "read"
372
- },
373
- {
374
- "kind": "Method",
375
- "canonicalReference": "@idlebox/browser!TimeoutStorage#read:member(2)",
376
- "docComment": "",
377
- "excerptTokens": [
378
- {
379
- "kind": "Content",
380
- "text": "read(): "
381
- },
382
- {
383
- "kind": "Reference",
384
- "text": "Readonly",
385
- "canonicalReference": "!Readonly:type"
386
- },
387
- {
388
- "kind": "Content",
389
- "text": "<T> | undefined"
390
- },
391
- {
392
- "kind": "Content",
393
- "text": ";"
394
- }
395
- ],
396
- "isStatic": false,
397
- "returnTypeTokenRange": {
398
- "startIndex": 1,
399
- "endIndex": 3
400
- },
401
- "releaseTag": "Public",
402
- "isProtected": false,
403
- "overloadIndex": 2,
404
- "parameters": [],
405
- "isOptional": false,
406
- "name": "read"
407
- },
408
- {
409
- "kind": "Method",
410
- "canonicalReference": "@idlebox/browser!TimeoutStorage#save:member(1)",
411
- "docComment": "",
412
- "excerptTokens": [
413
- {
414
- "kind": "Content",
415
- "text": "save(data: "
416
- },
417
- {
418
- "kind": "Reference",
419
- "text": "Readonly",
420
- "canonicalReference": "!Readonly:type"
421
- },
422
- {
423
- "kind": "Content",
424
- "text": "<T>"
425
- },
426
- {
427
- "kind": "Content",
428
- "text": ", expire: "
429
- },
430
- {
431
- "kind": "Content",
432
- "text": "string | "
433
- },
434
- {
435
- "kind": "Reference",
436
- "text": "Date",
437
- "canonicalReference": "!Date:interface"
438
- },
439
- {
440
- "kind": "Content",
441
- "text": "): "
442
- },
443
- {
444
- "kind": "Content",
445
- "text": "void"
446
- },
447
- {
448
- "kind": "Content",
449
- "text": ";"
450
- }
451
- ],
452
- "isStatic": false,
453
- "returnTypeTokenRange": {
454
- "startIndex": 7,
455
- "endIndex": 8
456
- },
457
- "releaseTag": "Public",
458
- "isProtected": false,
459
- "overloadIndex": 1,
460
- "parameters": [
461
- {
462
- "parameterName": "data",
463
- "parameterTypeTokenRange": {
464
- "startIndex": 1,
465
- "endIndex": 3
466
- },
467
- "isOptional": false
468
- },
469
- {
470
- "parameterName": "expire",
471
- "parameterTypeTokenRange": {
472
- "startIndex": 4,
473
- "endIndex": 6
474
- },
475
- "isOptional": false
476
- }
477
- ],
478
- "isOptional": false,
479
- "name": "save"
480
- }
481
- ],
482
- "implementsTokenRanges": []
483
- },
484
- {
485
- "kind": "Class",
486
- "canonicalReference": "@idlebox/browser!WrappedWebConsole:class",
487
- "docComment": "",
488
- "excerptTokens": [
489
- {
490
- "kind": "Content",
491
- "text": "export declare class WrappedWebConsole extends "
492
- },
493
- {
494
- "kind": "Reference",
495
- "text": "WrappedConsole",
496
- "canonicalReference": "@idlebox/common!WrappedConsole:class"
497
- },
498
- {
499
- "kind": "Content",
500
- "text": " "
501
- }
502
- ],
503
- "releaseTag": "Public",
504
- "name": "WrappedWebConsole",
505
- "preserveMemberOrder": false,
506
- "members": [
507
- {
508
- "kind": "Constructor",
509
- "canonicalReference": "@idlebox/browser!WrappedWebConsole:constructor(1)",
510
- "docComment": "/**\n * Constructs a new instance of the `WrappedWebConsole` class\n */\n",
511
- "excerptTokens": [
512
- {
513
- "kind": "Content",
514
- "text": "constructor(title: "
515
- },
516
- {
517
- "kind": "Content",
518
- "text": "string"
519
- },
520
- {
521
- "kind": "Content",
522
- "text": ", { color, ...opt }?: "
523
- },
524
- {
525
- "kind": "Reference",
526
- "text": "WrappedConsoleOptions",
527
- "canonicalReference": "@idlebox/common!WrappedConsoleOptions:interface"
528
- },
529
- {
530
- "kind": "Content",
531
- "text": " & "
532
- },
533
- {
534
- "kind": "Reference",
535
- "text": "WebConsoleOptions",
536
- "canonicalReference": "@idlebox/browser!~WebConsoleOptions:interface"
537
- },
538
- {
539
- "kind": "Content",
540
- "text": ");"
541
- }
542
- ],
543
- "releaseTag": "Public",
544
- "isProtected": false,
545
- "overloadIndex": 1,
546
- "parameters": [
547
- {
548
- "parameterName": "title",
549
- "parameterTypeTokenRange": {
550
- "startIndex": 1,
551
- "endIndex": 2
552
- },
553
- "isOptional": false
554
- },
555
- {
556
- "parameterName": "{ color, ...opt }",
557
- "parameterTypeTokenRange": {
558
- "startIndex": 3,
559
- "endIndex": 6
560
- },
561
- "isOptional": true
562
- }
563
- ]
564
- },
565
- {
566
- "kind": "Method",
567
- "canonicalReference": "@idlebox/browser!WrappedWebConsole#processColorLabel:member(1)",
568
- "docComment": "",
569
- "excerptTokens": [
570
- {
571
- "kind": "Content",
572
- "text": "protected processColorLabel(msg: "
573
- },
574
- {
575
- "kind": "Content",
576
- "text": "any[]"
577
- },
578
- {
579
- "kind": "Content",
580
- "text": ", pos: "
581
- },
582
- {
583
- "kind": "Content",
584
- "text": "number"
585
- },
586
- {
587
- "kind": "Content",
588
- "text": ", level: "
589
- },
590
- {
591
- "kind": "Content",
592
- "text": "string"
593
- },
594
- {
595
- "kind": "Content",
596
- "text": ", prefix: "
597
- },
598
- {
599
- "kind": "Content",
600
- "text": "string"
601
- },
602
- {
603
- "kind": "Content",
604
- "text": "): "
605
- },
606
- {
607
- "kind": "Content",
608
- "text": "void"
609
- },
610
- {
611
- "kind": "Content",
612
- "text": ";"
613
- }
614
- ],
615
- "isStatic": false,
616
- "returnTypeTokenRange": {
617
- "startIndex": 9,
618
- "endIndex": 10
619
- },
620
- "releaseTag": "Public",
621
- "isProtected": true,
622
- "overloadIndex": 1,
623
- "parameters": [
624
- {
625
- "parameterName": "msg",
626
- "parameterTypeTokenRange": {
627
- "startIndex": 1,
628
- "endIndex": 2
629
- },
630
- "isOptional": false
631
- },
632
- {
633
- "parameterName": "pos",
634
- "parameterTypeTokenRange": {
635
- "startIndex": 3,
636
- "endIndex": 4
637
- },
638
- "isOptional": false
639
- },
640
- {
641
- "parameterName": "level",
642
- "parameterTypeTokenRange": {
643
- "startIndex": 5,
644
- "endIndex": 6
645
- },
646
- "isOptional": false
647
- },
648
- {
649
- "parameterName": "prefix",
650
- "parameterTypeTokenRange": {
651
- "startIndex": 7,
652
- "endIndex": 8
653
- },
654
- "isOptional": false
655
- }
656
- ],
657
- "isOptional": false,
658
- "name": "processColorLabel"
659
- }
660
- ],
661
- "extendsTokenRange": {
662
- "startIndex": 1,
663
- "endIndex": 2
664
- },
665
- "implementsTokenRanges": []
666
- }
667
- ]
668
- }
669
- ]
670
- }
@@ -1,39 +0,0 @@
1
- ## API Report File for "@idlebox/browser"
2
-
3
- > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
4
-
5
- ```ts
6
-
7
- import { WrappedConsole } from '@idlebox/common';
8
- import { WrappedConsoleOptions } from '@idlebox/common';
9
-
10
- // Warning: (ae-missing-release-tag) "TimeoutStorage" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
11
- //
12
- // @public (undocumented)
13
- export class TimeoutStorage<T> {
14
- constructor(key: string, storage?: Storage);
15
- // (undocumented)
16
- forget(): void;
17
- // (undocumented)
18
- getExpire(): Date | null;
19
- // (undocumented)
20
- read(defaultVal: Readonly<T>): Readonly<T>;
21
- // (undocumented)
22
- read(): Readonly<T> | undefined;
23
- // (undocumented)
24
- save(data: Readonly<T>, expire: string | Date): void;
25
- }
26
-
27
- // Warning: (ae-missing-release-tag) "WrappedWebConsole" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
28
- //
29
- // @public (undocumented)
30
- export class WrappedWebConsole extends WrappedConsole {
31
- // Warning: (ae-forgotten-export) The symbol "WebConsoleOptions" needs to be exported by the entry point _export_all_in_one_index.d.ts
32
- constructor(title: string, { color, ...opt }?: WrappedConsoleOptions & WebConsoleOptions);
33
- // (undocumented)
34
- protected processColorLabel(msg: any[], pos: number, level: string, prefix: string): void;
35
- }
36
-
37
- // (No @packageDocumentation comment for this package)
38
-
39
- ```