@virtualdisplay.io/client 3.7.0 → 4.0.0-alpha.1
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/CHANGELOG.md +38 -76
- package/LICENSE +1 -1
- package/README.md +374 -31
- package/dist/index.d.ts +151 -557
- package/dist/virtualdisplay.client.cjs.js +1 -7
- package/dist/virtualdisplay.client.cjs.js.map +1 -1
- package/dist/virtualdisplay.client.es.js +1 -8025
- package/dist/virtualdisplay.client.es.js.map +1 -1
- package/dist/virtualdisplay.client.umd.js +1 -7
- package/dist/virtualdisplay.client.umd.js.map +1 -1
- package/package.json +14 -98
- package/README.npm.md +0 -78
- package/node_modules/@virtualdisplay-io/logger/CHANGELOG.md +0 -82
- package/node_modules/@virtualdisplay-io/logger/LICENSE +0 -21
- package/node_modules/@virtualdisplay-io/logger/README.md +0 -314
- package/node_modules/@virtualdisplay-io/logger/dist/index.d.ts +0 -167
- package/node_modules/@virtualdisplay-io/logger/dist/virtualdisplay.logger.cjs.js +0 -4
- package/node_modules/@virtualdisplay-io/logger/dist/virtualdisplay.logger.cjs.js.map +0 -1
- package/node_modules/@virtualdisplay-io/logger/dist/virtualdisplay.logger.es.js +0 -377
- package/node_modules/@virtualdisplay-io/logger/dist/virtualdisplay.logger.es.js.map +0 -1
- package/node_modules/@virtualdisplay-io/logger/package.json +0 -79
package/package.json
CHANGED
|
@@ -1,57 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@virtualdisplay.io/client",
|
|
3
3
|
"description": "TypeScript-first 3D model integration library with iframe-based architecture",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "4.0.0-alpha.1",
|
|
5
5
|
"author": "Virtualdisplay <support@virtualdisplay.io>",
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
"last 2 Safari versions",
|
|
10
|
-
"last 2 Edge versions"
|
|
11
|
-
],
|
|
12
|
-
"bugs": {
|
|
13
|
-
"url": "https://github.com/virtualdisplay-io/client/issues"
|
|
14
|
-
},
|
|
15
|
-
"bundledDependencies": [
|
|
16
|
-
"@virtualdisplay-io/logger"
|
|
17
|
-
],
|
|
18
|
-
"dependencies": {
|
|
19
|
-
"@virtualdisplay-io/logger": "1.2.0",
|
|
20
|
-
"ajv": "8.17.1"
|
|
21
|
-
},
|
|
22
|
-
"devDependencies": {
|
|
23
|
-
"@eslint/js": "^9.32.0",
|
|
24
|
-
"@semantic-release/changelog": "^6.0.3",
|
|
25
|
-
"@semantic-release/commit-analyzer": "^13.0.1",
|
|
26
|
-
"@semantic-release/exec": "7.1.0",
|
|
27
|
-
"@semantic-release/git": "^10.0.1",
|
|
28
|
-
"@semantic-release/github": "^11.0.3",
|
|
29
|
-
"@semantic-release/npm": "^12.0.2",
|
|
30
|
-
"@semantic-release/release-notes-generator": "^14.0.3",
|
|
31
|
-
"@types/node": "^24.1.0",
|
|
32
|
-
"@typescript-eslint/eslint-plugin": "^8.38.0",
|
|
33
|
-
"@typescript-eslint/parser": "^8.38.0",
|
|
34
|
-
"@virtualdisplay-io/shared-config": "^1.4.0",
|
|
35
|
-
"@vitest/coverage-v8": "^3.2.4",
|
|
36
|
-
"conventional-changelog-conventionalcommits": "9.1.0",
|
|
37
|
-
"eslint": "^9.32.0",
|
|
38
|
-
"eslint-plugin-import": "^2.32.0",
|
|
39
|
-
"eslint-plugin-jsx-a11y": "^6.10.2",
|
|
40
|
-
"eslint-plugin-prettier": "^5.5.3",
|
|
41
|
-
"eslint-plugin-unicorn": "^60.0.0",
|
|
42
|
-
"globals": "^16.3.0",
|
|
43
|
-
"jsdom": "^26.1.0",
|
|
44
|
-
"markdownlint-cli2": "^0.18.1",
|
|
45
|
-
"markdownlint-cli2-formatter-pretty": "^0.0.8",
|
|
46
|
-
"prettier": "^3.6.2",
|
|
47
|
-
"semantic-release": "^24.2.7",
|
|
48
|
-
"terser": "^5.43.1",
|
|
49
|
-
"typescript": "^5.8.3",
|
|
50
|
-
"vite": "^7.0.6",
|
|
51
|
-
"vite-bundle-visualizer": "^1.2.1",
|
|
52
|
-
"vite-plugin-dts": "^4.5.4",
|
|
53
|
-
"vitest": "^3.2.4"
|
|
54
|
-
},
|
|
6
|
+
"homepage": "https://virtualdisplay.io",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"type": "module",
|
|
55
9
|
"exports": {
|
|
56
10
|
".": {
|
|
57
11
|
"types": "./dist/index.d.ts",
|
|
@@ -59,14 +13,17 @@
|
|
|
59
13
|
"require": "./dist/virtualdisplay.client.cjs.js"
|
|
60
14
|
}
|
|
61
15
|
},
|
|
16
|
+
"main": "dist/virtualdisplay.client.cjs.js",
|
|
17
|
+
"module": "dist/virtualdisplay.client.es.js",
|
|
18
|
+
"types": "dist/index.d.ts",
|
|
62
19
|
"files": [
|
|
63
20
|
"dist",
|
|
64
|
-
"
|
|
65
|
-
"README.md",
|
|
66
|
-
"CHANGELOG.md",
|
|
67
|
-
"LICENSE"
|
|
21
|
+
"CHANGELOG.md"
|
|
68
22
|
],
|
|
69
|
-
"
|
|
23
|
+
"publishConfig": {
|
|
24
|
+
"registry": "https://registry.npmjs.org/",
|
|
25
|
+
"access": "public"
|
|
26
|
+
},
|
|
70
27
|
"keywords": [
|
|
71
28
|
"3d",
|
|
72
29
|
"iframe",
|
|
@@ -74,46 +31,5 @@
|
|
|
74
31
|
"typescript",
|
|
75
32
|
"visualization",
|
|
76
33
|
"webgl"
|
|
77
|
-
]
|
|
78
|
-
|
|
79
|
-
"main": "dist/virtualdisplay.client.cjs.js",
|
|
80
|
-
"module": "dist/virtualdisplay.client.es.js",
|
|
81
|
-
"publishConfig": {
|
|
82
|
-
"registry": "https://registry.npmjs.org/",
|
|
83
|
-
"access": "public"
|
|
84
|
-
},
|
|
85
|
-
"repository": {
|
|
86
|
-
"type": "git",
|
|
87
|
-
"url": "git+https://github.com/virtualdisplay-io/client.git"
|
|
88
|
-
},
|
|
89
|
-
"scripts": {
|
|
90
|
-
"analyze": "vite-bundle-visualizer --template treemap --output stats.html --open false",
|
|
91
|
-
"build": "tsc -p tsconfig.build.json && vite build",
|
|
92
|
-
"coverage": "vitest run --coverage --reporter=verbose",
|
|
93
|
-
"coverage:feature": "vitest run test/feature --coverage --reporter=verbose",
|
|
94
|
-
"coverage:integration": "vitest run test/integration --coverage --reporter=verbose",
|
|
95
|
-
"coverage:unit": "vitest run test/unit --coverage --reporter=verbose",
|
|
96
|
-
"dev": "vite build --watch",
|
|
97
|
-
"format": "prettier --write .",
|
|
98
|
-
"format:check": "prettier --check .",
|
|
99
|
-
"lint": "pnpm run lint:eslint && pnpm run lint:md && pnpm run lint:types && pnpm run lint:format",
|
|
100
|
-
"lint:eslint": "eslint .",
|
|
101
|
-
"lint:eslint:fix": "eslint . --fix",
|
|
102
|
-
"lint:fix": "pnpm run lint:eslint:fix && pnpm run lint:md:fix && pnpm run lint:format:fix && npx fixpack",
|
|
103
|
-
"lint:format": "prettier --check .",
|
|
104
|
-
"lint:format:fix": "prettier --write .",
|
|
105
|
-
"lint:md": "markdownlint-cli2 '**/*.md' --config .markdownlint-cli2.jsonc",
|
|
106
|
-
"lint:md:fix": "markdownlint-cli2 '**/*.md' --config .markdownlint-cli2.jsonc --fix",
|
|
107
|
-
"lint:types": "tsc --noEmit",
|
|
108
|
-
"prepare": "node -e \"if (!process.env.CI) require('child_process').execSync('pnpm build', {stdio: 'inherit'})\"",
|
|
109
|
-
"release": "semantic-release",
|
|
110
|
-
"test": "vitest run",
|
|
111
|
-
"test:feature": "vitest run test/feature",
|
|
112
|
-
"test:integration": "vitest run test/integration",
|
|
113
|
-
"test:unit": "vitest run test/unit",
|
|
114
|
-
"test:watch": "vitest",
|
|
115
|
-
"type-check": "tsc --noEmit"
|
|
116
|
-
},
|
|
117
|
-
"type": "module",
|
|
118
|
-
"types": "dist/index.d.ts"
|
|
119
|
-
}
|
|
34
|
+
]
|
|
35
|
+
}
|
package/README.npm.md
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
# Virtualdisplay client
|
|
2
|
-
|
|
3
|
-
TypeScript library for embedding interactive 3D product models in web applications.
|
|
4
|
-
|
|
5
|
-
## Installation
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
npm install @virtualdisplay.io/client
|
|
9
|
-
# or
|
|
10
|
-
pnpm add @virtualdisplay.io/client
|
|
11
|
-
# or
|
|
12
|
-
yarn add @virtualdisplay.io/client
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
## Quick start
|
|
16
|
-
|
|
17
|
-
### Simple product (no options)
|
|
18
|
-
|
|
19
|
-
```typescript
|
|
20
|
-
import { VirtualdisplayClient } from '@virtualdisplay.io/client';
|
|
21
|
-
|
|
22
|
-
// That's it! Your 3D model is now displayed
|
|
23
|
-
const client = new VirtualdisplayClient({
|
|
24
|
-
parent: '#product-container',
|
|
25
|
-
license: 'your-license-key',
|
|
26
|
-
model: 'statue-model',
|
|
27
|
-
});
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
### Configurable product (with options)
|
|
31
|
-
|
|
32
|
-
```typescript
|
|
33
|
-
import { VirtualdisplayClient } from '@virtualdisplay.io/client';
|
|
34
|
-
|
|
35
|
-
// Create client instance
|
|
36
|
-
const client = new VirtualdisplayClient({
|
|
37
|
-
parent: '#product-container',
|
|
38
|
-
license: 'your-license-key',
|
|
39
|
-
model: 'sneaker',
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
// Map product options to 3D parts
|
|
43
|
-
client.setMapping({
|
|
44
|
-
attributes: [
|
|
45
|
-
{
|
|
46
|
-
name: 'Color',
|
|
47
|
-
values: [
|
|
48
|
-
{ value: 'Red', nodeIds: ['laces_red', 'sole_red'], isSelected: true },
|
|
49
|
-
{ value: 'Blue', nodeIds: ['laces_blue', 'sole_blue'] },
|
|
50
|
-
],
|
|
51
|
-
},
|
|
52
|
-
],
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
// Control via product options
|
|
56
|
-
client.getAttribute('Color')?.select('Red');
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
## Key features
|
|
60
|
-
|
|
61
|
-
- **Simple API**: Attribute-based product configuration
|
|
62
|
-
- **Fire-and-forget**: Send commands without waiting for responses
|
|
63
|
-
- **State sync**: Automatic synchronization between client and 3D viewer
|
|
64
|
-
- **Framework-agnostic**: Works with React, Vue, Angular, or vanilla JS
|
|
65
|
-
- **TypeScript first**: Full type safety and IntelliSense support
|
|
66
|
-
- **Minimal dependencies**: Only essential validation and logging included
|
|
67
|
-
|
|
68
|
-
## Documentation
|
|
69
|
-
|
|
70
|
-
For complete documentation including:
|
|
71
|
-
|
|
72
|
-
- API reference
|
|
73
|
-
- Advanced examples
|
|
74
|
-
- Integration guides
|
|
75
|
-
- Architecture diagrams
|
|
76
|
-
- Troubleshooting
|
|
77
|
-
|
|
78
|
-
Visit our [GitHub repository](https://github.com/virtualdisplay-io/client)
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
# [1.2.0](https://github.com/virtualdisplay-io/logger/compare/v1.1.2...v1.2.0) (2025-06-13)
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
### Features
|
|
5
|
-
|
|
6
|
-
* simplify logger API by removing environment detection ([#11](https://github.com/virtualdisplay-io/logger/issues/11)) ([8580f93](https://github.com/virtualdisplay-io/logger/commit/8580f93eb2b9eb7dd6fc6b4ae90b5512ac9b55bc))
|
|
7
|
-
|
|
8
|
-
## [1.1.2](https://github.com/virtualdisplay-io/logger/compare/v1.1.1...v1.1.2) (2025-06-08)
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
### Bug Fixes
|
|
12
|
-
|
|
13
|
-
* resolve linting issues in console-transport ([#8](https://github.com/virtualdisplay-io/logger/issues/8)) ([10b8f1a](https://github.com/virtualdisplay-io/logger/commit/10b8f1adaf3ed04efb6c46ace9194f39c8d60b00))
|
|
14
|
-
|
|
15
|
-
## [1.1.1](https://github.com/virtualdisplay-io/logger/compare/v1.1.0...v1.1.1) (2025-06-08)
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
### Bug Fixes
|
|
19
|
-
|
|
20
|
-
* remove hardcoded VirtualDisplay prefix from console transport ([f3734d5](https://github.com/virtualdisplay-io/logger/commit/f3734d5f3b66c9a1e190a13e7c91f9021543324c))
|
|
21
|
-
|
|
22
|
-
# [1.1.0](https://github.com/virtualdisplay-io/logger/compare/v1.0.1...v1.1.0) (2025-06-08)
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
### Features
|
|
26
|
-
|
|
27
|
-
* update semantic-release config to match client library ([ec76794](https://github.com/virtualdisplay-io/logger/commit/ec7679460926ec5423fad52a9859ef34d547a9ef))
|
|
28
|
-
|
|
29
|
-
## [1.0.1](https://github.com/virtualdisplay-io/logger/compare/v1.0.0...v1.0.1) (2025-06-08)
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
### Bug Fixes
|
|
33
|
-
|
|
34
|
-
* ensure production build is created before release ([#7](https://github.com/virtualdisplay-io/logger/issues/7)) ([459af10](https://github.com/virtualdisplay-io/logger/commit/459af105c3e6e123b75f4cb96bbaa5c89722fdb8))
|
|
35
|
-
|
|
36
|
-
# 1.0.0 (2025-06-08)
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
### Features
|
|
40
|
-
|
|
41
|
-
* initial Virtual Display Logger implementation ([dcbda81](https://github.com/virtualdisplay-io/logger/commit/dcbda81cf31a097eed8df61a6d5294a8b0d9f1c4))
|
|
42
|
-
|
|
43
|
-
# Changelog
|
|
44
|
-
|
|
45
|
-
All notable changes to this project will be documented in this file.
|
|
46
|
-
|
|
47
|
-
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
48
|
-
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
49
|
-
|
|
50
|
-
## [Unreleased]
|
|
51
|
-
|
|
52
|
-
### Added
|
|
53
|
-
- Initial release of @virtualdisplay-io/logger
|
|
54
|
-
- Core logging functionality with debug, info, warn, error levels
|
|
55
|
-
- Singleton pattern with Logger.getInstance()
|
|
56
|
-
- Child logger support with context inheritance
|
|
57
|
-
- Multiple transport system (Console, Memory)
|
|
58
|
-
- Formatter system (Context, JSON)
|
|
59
|
-
- Environment-aware logging
|
|
60
|
-
- Test environment auto-detection
|
|
61
|
-
- TypeScript support with full type definitions
|
|
62
|
-
- Comprehensive test suite with 100% coverage
|
|
63
|
-
- Zero dependencies
|
|
64
|
-
- Browser and Node.js compatibility
|
|
65
|
-
- Memory transport with querying and export capabilities
|
|
66
|
-
- Global muting functionality
|
|
67
|
-
- Configurable log levels and filtering
|
|
68
|
-
|
|
69
|
-
### Features
|
|
70
|
-
- **ConsoleTransport**: Console output with colors and timestamps
|
|
71
|
-
- **MemoryTransport**: In-memory log storage with search and export
|
|
72
|
-
- **ContextFormatter**: Appends context data to messages
|
|
73
|
-
- **JSONFormatter**: Full JSON serialization of log entries
|
|
74
|
-
- **Child Loggers**: Hierarchical logging with context merging
|
|
75
|
-
- **Smart Environment Detection**: Automatic test environment detection
|
|
76
|
-
- **Performance Optimized**: Zero runtime dependencies, efficient memory usage
|
|
77
|
-
- **Developer Experience**: Comprehensive TypeScript types, clear API
|
|
78
|
-
|
|
79
|
-
## [1.0.0] - 2025-01-XX
|
|
80
|
-
|
|
81
|
-
### Added
|
|
82
|
-
- Initial stable release
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2025 Virtual Display
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
@@ -1,314 +0,0 @@
|
|
|
1
|
-
# @virtualdisplay-io/logger
|
|
2
|
-
|
|
3
|
-
A simple, TypeScript-first logging library for browser and Node.js applications.
|
|
4
|
-
|
|
5
|
-
[](https://github.com/virtualdisplay-io/logger/packages)
|
|
6
|
-
[](https://opensource.org/licenses/MIT)
|
|
7
|
-
[](https://www.typescriptlang.org/)
|
|
8
|
-
|
|
9
|
-
## Features
|
|
10
|
-
|
|
11
|
-
- **Simple API** - Just `enabled` and `level`, no complex configuration
|
|
12
|
-
- **TypeScript Native** - Full type safety and autocompletion
|
|
13
|
-
- **Lightweight** - ~3KB gzipped, zero dependencies
|
|
14
|
-
- **Visual Clarity** - Emoji indicators and colors for log levels (📘 ⚠️ ❌ 🐛)
|
|
15
|
-
- **Universal** - Works in Node.js, browsers, and workers
|
|
16
|
-
- **Extensible** - Custom transports and formatters
|
|
17
|
-
- **Memory Transport** - Built-in log analysis and debugging
|
|
18
|
-
- **Child Loggers** - Contextual logging with inherited settings
|
|
19
|
-
|
|
20
|
-
## Installation
|
|
21
|
-
|
|
22
|
-
This package is published to GitHub Packages. First, configure your npm to use the GitHub Package Registry:
|
|
23
|
-
|
|
24
|
-
```bash
|
|
25
|
-
echo "@virtualdisplay-io:registry=https://npm.pkg.github.com" >> .npmrc
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
Then install the package:
|
|
29
|
-
|
|
30
|
-
```bash
|
|
31
|
-
npm install @virtualdisplay-io/logger
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
```bash
|
|
35
|
-
yarn add @virtualdisplay-io/logger
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
```bash
|
|
39
|
-
pnpm add @virtualdisplay-io/logger
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
## Quick Start
|
|
43
|
-
|
|
44
|
-
```typescript
|
|
45
|
-
import { logger } from '@virtualdisplay-io/logger';
|
|
46
|
-
|
|
47
|
-
// The default logger has no prefix - clean and neutral
|
|
48
|
-
logger.info('Application started'); // 📘 Application started
|
|
49
|
-
logger.warn('This is a warning'); // ⚠️ This is a warning
|
|
50
|
-
logger.error('Something went wrong', { userId: '123' }); // ❌ Something went wrong
|
|
51
|
-
|
|
52
|
-
// Create a logger with your own prefix
|
|
53
|
-
import { Logger } from '@virtualdisplay-io/logger';
|
|
54
|
-
|
|
55
|
-
const appLogger = new Logger({ prefix: 'MyApp' });
|
|
56
|
-
appLogger.info('Application started'); // 📘 [MyApp] Application started
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
## Advanced Usage
|
|
60
|
-
|
|
61
|
-
### Simple Configuration
|
|
62
|
-
|
|
63
|
-
```typescript
|
|
64
|
-
import { Logger } from '@virtualdisplay-io/logger';
|
|
65
|
-
|
|
66
|
-
const logger = new Logger({
|
|
67
|
-
prefix: 'MyApp',
|
|
68
|
-
level: 'info', // Only show info, warn, and error
|
|
69
|
-
enabled: true, // Turn logging on/off
|
|
70
|
-
colors: true, // Enable colors in browser (default: true)
|
|
71
|
-
context: { version: '1.0.0' }
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
logger.info('Server started'); // Shows (info level or higher)
|
|
75
|
-
logger.debug('Cache cleared'); // Hidden (below info level)
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
### Control Log Levels
|
|
79
|
-
|
|
80
|
-
```typescript
|
|
81
|
-
// Set level dynamically
|
|
82
|
-
logger.setLevel('debug'); // Now debug messages will show
|
|
83
|
-
logger.setLevel('error'); // Only errors will show
|
|
84
|
-
|
|
85
|
-
// Turn logging on/off
|
|
86
|
-
logger.setEnabled(false); // All logging disabled
|
|
87
|
-
logger.setEnabled(true); // Logging re-enabled
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
### Child Loggers
|
|
91
|
-
|
|
92
|
-
```typescript
|
|
93
|
-
import { Logger } from '@virtualdisplay-io/logger';
|
|
94
|
-
|
|
95
|
-
// Create a base logger without prefix
|
|
96
|
-
const baseLogger = new Logger();
|
|
97
|
-
|
|
98
|
-
// Create child logger with additional context
|
|
99
|
-
const authLogger = baseLogger.child({
|
|
100
|
-
prefix: 'Auth',
|
|
101
|
-
context: { module: 'authentication' },
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
const userLogger = authLogger.child({
|
|
105
|
-
context: { userId: '123', action: 'login' },
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
userLogger.info('User login attempt');
|
|
109
|
-
// Output: [timestamp] [Auth] INFO: User login attempt {module="authentication" userId="123" action="login"}
|
|
110
|
-
|
|
111
|
-
// Or add a prefix to the default logger
|
|
112
|
-
import { logger } from '@virtualdisplay-io/logger';
|
|
113
|
-
const apiLogger = logger.child({ prefix: 'API', context: { service: 'users' } });
|
|
114
|
-
// Output will have [API] prefix
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
### Custom Formatters
|
|
119
|
-
|
|
120
|
-
```typescript
|
|
121
|
-
import { Logger } from '@virtualdisplay-io/logger';
|
|
122
|
-
import type { LogFormatter, LogEntry } from '@virtualdisplay-io/logger';
|
|
123
|
-
|
|
124
|
-
class CustomFormatter implements LogFormatter {
|
|
125
|
-
name = 'custom';
|
|
126
|
-
|
|
127
|
-
format(entry: LogEntry): LogEntry {
|
|
128
|
-
return {
|
|
129
|
-
...entry,
|
|
130
|
-
message: `🎯 ${entry.message.toUpperCase()}`,
|
|
131
|
-
};
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
const logger = new Logger({
|
|
136
|
-
formatters: [new CustomFormatter()],
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
logger.info('hello world'); // Output: 🎯 HELLO WORLD
|
|
140
|
-
```
|
|
141
|
-
|
|
142
|
-
### Memory Transport for Log Analysis
|
|
143
|
-
|
|
144
|
-
```typescript
|
|
145
|
-
import { Logger } from '@virtualdisplay-io/logger';
|
|
146
|
-
|
|
147
|
-
// Memory transport is loaded dynamically to keep bundle size small
|
|
148
|
-
const logger = new Logger();
|
|
149
|
-
|
|
150
|
-
// Enable memory logging when needed
|
|
151
|
-
await logger.enableMemoryLogging(500); // Store max 500 entries
|
|
152
|
-
|
|
153
|
-
// Log some events
|
|
154
|
-
logger.info('User created', { userId: '123' });
|
|
155
|
-
logger.warn('Rate limit exceeded', { ip: '192.168.1.1' });
|
|
156
|
-
logger.error('Database connection failed');
|
|
157
|
-
|
|
158
|
-
// Use the logger's debug methods to analyze logs
|
|
159
|
-
const allLogs = JSON.parse(logger.exportLogs());
|
|
160
|
-
const errors = logger.getRecentErrors();
|
|
161
|
-
const searchResults = logger.searchLogs(/database/i);
|
|
162
|
-
|
|
163
|
-
// Export logs
|
|
164
|
-
console.log(logger.exportLogs()); // JSON format
|
|
165
|
-
console.log(logger.exportLogsCSV()); // CSV format
|
|
166
|
-
```
|
|
167
|
-
|
|
168
|
-
### Global Muting
|
|
169
|
-
|
|
170
|
-
```typescript
|
|
171
|
-
import { Logger } from '@virtualdisplay-io/logger';
|
|
172
|
-
|
|
173
|
-
// Mute all logger instances
|
|
174
|
-
Logger.setMute(true);
|
|
175
|
-
logger.info('This will not be logged');
|
|
176
|
-
|
|
177
|
-
// Unmute
|
|
178
|
-
Logger.setMute(false);
|
|
179
|
-
logger.info('This will be logged');
|
|
180
|
-
```
|
|
181
|
-
|
|
182
|
-
## API Reference
|
|
183
|
-
|
|
184
|
-
### Logger Class
|
|
185
|
-
|
|
186
|
-
#### Basic methods:
|
|
187
|
-
- `debug(message: string, ...args: unknown[]): void`
|
|
188
|
-
- `info(message: string, ...args: unknown[]): void`
|
|
189
|
-
- `warn(message: string, ...args: unknown[]): void`
|
|
190
|
-
- `error(message: string, ...args: unknown[]): void`
|
|
191
|
-
- `child(options?: Partial<LoggerOptions>): Logger`
|
|
192
|
-
|
|
193
|
-
#### Configuration methods:
|
|
194
|
-
- `setLevel(level: LogLevel): void` - Set the minimum log level
|
|
195
|
-
- `getLevel(): LogLevel` - Get the current log level
|
|
196
|
-
- `setEnabled(enabled: boolean): void` - Enable/disable logging
|
|
197
|
-
- `isEnabled(): boolean` - Check if logging is enabled
|
|
198
|
-
|
|
199
|
-
#### Transport & Formatter methods:
|
|
200
|
-
- `addTransport(transport: LogTransport): void`
|
|
201
|
-
- `removeTransport(name: string): void`
|
|
202
|
-
- `getTransport(name: string): LogTransport | undefined`
|
|
203
|
-
- `addFormatter(formatter: LogFormatter): void`
|
|
204
|
-
- `removeFormatter(name: string): void`
|
|
205
|
-
- `getFormatter(name: string): LogFormatter | undefined`
|
|
206
|
-
|
|
207
|
-
#### Debug methods (when memory transport is added):
|
|
208
|
-
- `enableMemoryLogging(maxSize?: number): Promise<void>`
|
|
209
|
-
- `exportLogs(): string` - Export logs as JSON
|
|
210
|
-
- `exportLogsCSV(): string` - Export logs as CSV
|
|
211
|
-
- `getRecentErrors(minutes?: number): LogEntry[]`
|
|
212
|
-
- `searchLogs(query: string | RegExp): LogEntry[]`
|
|
213
|
-
- `clearLogs(): void`
|
|
214
|
-
|
|
215
|
-
### Log Levels
|
|
216
|
-
|
|
217
|
-
- `debug` (0) - Detailed debugging information
|
|
218
|
-
- `info` (1) - General information
|
|
219
|
-
- `warn` (2) - Warning messages
|
|
220
|
-
- `error` (3) - Error messages
|
|
221
|
-
|
|
222
|
-
### Built-in Transports
|
|
223
|
-
|
|
224
|
-
- **ConsoleTransport** - Outputs to console with colors, emojis, and grouped logging
|
|
225
|
-
- Colors for visual clarity (can be disabled)
|
|
226
|
-
- Collapsible groups showing origin and arguments
|
|
227
|
-
- Automatic fallback for environments without color support
|
|
228
|
-
- **MemoryTransport** - Stores logs in memory with query capabilities (loaded on-demand)
|
|
229
|
-
|
|
230
|
-
### Built-in Formatters
|
|
231
|
-
|
|
232
|
-
- **ContextFormatter** - Appends context data to log messages
|
|
233
|
-
- **JSONFormatter** - Converts log entries to JSON format
|
|
234
|
-
|
|
235
|
-
## Browser Support
|
|
236
|
-
|
|
237
|
-
- **Modern browsers** (ES2022+)
|
|
238
|
-
- **Node.js** 18+
|
|
239
|
-
|
|
240
|
-
## Debug Features
|
|
241
|
-
|
|
242
|
-
The logger includes some basic debug features when using the memory transport:
|
|
243
|
-
|
|
244
|
-
```typescript
|
|
245
|
-
import { logger } from '@virtualdisplay-io/logger';
|
|
246
|
-
|
|
247
|
-
// Enable memory logging to store logs
|
|
248
|
-
await logger.enableMemoryLogging(1000); // Store max 1000 log entries
|
|
249
|
-
|
|
250
|
-
// Export logs as JSON
|
|
251
|
-
const logs = logger.exportLogs();
|
|
252
|
-
|
|
253
|
-
// Export logs as CSV
|
|
254
|
-
const csv = logger.exportLogsCSV();
|
|
255
|
-
|
|
256
|
-
// Get recent errors
|
|
257
|
-
const errors = logger.getRecentErrors();
|
|
258
|
-
|
|
259
|
-
// Search logs
|
|
260
|
-
const searchResults = logger.searchLogs('search term');
|
|
261
|
-
```
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
## Basic Example
|
|
265
|
-
|
|
266
|
-
```typescript
|
|
267
|
-
import { Logger } from '@virtualdisplay-io/logger';
|
|
268
|
-
|
|
269
|
-
// Create a logger for your application
|
|
270
|
-
const appLogger = new Logger({ prefix: 'MyApp' });
|
|
271
|
-
|
|
272
|
-
// Log some messages
|
|
273
|
-
appLogger.info('Application started');
|
|
274
|
-
appLogger.warn('This is a warning');
|
|
275
|
-
appLogger.error('An error occurred');
|
|
276
|
-
|
|
277
|
-
// Create child loggers with context
|
|
278
|
-
const userLogger = appLogger.child({
|
|
279
|
-
context: { userId: '123', module: 'auth' }
|
|
280
|
-
});
|
|
281
|
-
|
|
282
|
-
userLogger.info('User logged in');
|
|
283
|
-
```
|
|
284
|
-
|
|
285
|
-
## Examples
|
|
286
|
-
|
|
287
|
-
The `examples/` directory contains focused examples for each feature:
|
|
288
|
-
|
|
289
|
-
- **`basic-usage.ts`** - Getting started, log levels, prefixes
|
|
290
|
-
- **`child-loggers.ts`** - Hierarchical logging with context inheritance
|
|
291
|
-
- **`memory-transport.ts`** - Log analysis and debugging commands
|
|
292
|
-
- **`custom-colors.ts`** - Customize visual appearance
|
|
293
|
-
- **`custom-transports.ts`** - Create your own logging destinations
|
|
294
|
-
- **`formatters.ts`** - Transform log messages before output
|
|
295
|
-
- **`grouped-logging.ts`** - Collapsible browser console groups
|
|
296
|
-
- **`advanced-usage.ts`** - Multiple features working together
|
|
297
|
-
- **`production-setup.ts`** - Real-world production configuration
|
|
298
|
-
|
|
299
|
-
Run any example with:
|
|
300
|
-
```bash
|
|
301
|
-
npx tsx examples/basic-usage.ts
|
|
302
|
-
```
|
|
303
|
-
|
|
304
|
-
## Contributing
|
|
305
|
-
|
|
306
|
-
Contributions are welcome! Please read our [Contributing Guide](CONTRIBUTING.md) for details.
|
|
307
|
-
|
|
308
|
-
## License
|
|
309
|
-
|
|
310
|
-
MIT © [Virtual Display](LICENSE)
|
|
311
|
-
|
|
312
|
-
---
|
|
313
|
-
|
|
314
|
-
Built with ❤️ by the Virtual Display team
|