tailwind-widgets 5.1.3

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.
Files changed (166) hide show
  1. package/LICENSE +24 -0
  2. package/README.md +113 -0
  3. package/bin.js +6 -0
  4. package/bingo-logger.js +211 -0
  5. package/browser.js +358 -0
  6. package/docs/api.md +1352 -0
  7. package/docs/asynchronous.md +102 -0
  8. package/docs/benchmarks.md +58 -0
  9. package/docs/browser.md +199 -0
  10. package/docs/bundling.md +34 -0
  11. package/docs/child-loggers.md +95 -0
  12. package/docs/ecosystem.md +74 -0
  13. package/docs/help.md +305 -0
  14. package/docs/lts.md +62 -0
  15. package/docs/pretty.md +101 -0
  16. package/docs/redaction.md +135 -0
  17. package/docs/transports.md +792 -0
  18. package/docs/web.md +257 -0
  19. package/file.js +12 -0
  20. package/lib/caller.js +30 -0
  21. package/lib/deprecations.js +10 -0
  22. package/lib/levels.js +193 -0
  23. package/lib/meta.js +5 -0
  24. package/lib/multistream.js +156 -0
  25. package/lib/parse.js +14 -0
  26. package/lib/proto.js +216 -0
  27. package/lib/redaction.js +118 -0
  28. package/lib/symbols.js +70 -0
  29. package/lib/time.js +11 -0
  30. package/lib/tools.js +563 -0
  31. package/lib/transport-stream.js +47 -0
  32. package/lib/transport.js +157 -0
  33. package/lib/worker-pipeline.js +40 -0
  34. package/lib/worker.js +54 -0
  35. package/package.json +131 -0
  36. package/test/basic.test.js +719 -0
  37. package/test/broken-pipe.test.js +42 -0
  38. package/test/browser-levels.test.js +218 -0
  39. package/test/browser-serializers.test.js +354 -0
  40. package/test/browser-timestamp.test.js +88 -0
  41. package/test/browser-transmit.test.js +349 -0
  42. package/test/browser.test.js +547 -0
  43. package/test/complex-objects.test.js +34 -0
  44. package/test/crlf.test.js +32 -0
  45. package/test/custom-levels.test.js +294 -0
  46. package/test/error.test.js +374 -0
  47. package/test/escaping.test.js +91 -0
  48. package/test/esm/esm.mjs +12 -0
  49. package/test/esm/index.test.js +34 -0
  50. package/test/esm/named-exports.mjs +28 -0
  51. package/test/exit.test.js +85 -0
  52. package/test/final.test.js +237 -0
  53. package/test/fixtures/broken-pipe/basic.js +9 -0
  54. package/test/fixtures/broken-pipe/destination.js +10 -0
  55. package/test/fixtures/broken-pipe/syncfalse.js +12 -0
  56. package/test/fixtures/console-transport.js +13 -0
  57. package/test/fixtures/default-exit.js +8 -0
  58. package/test/fixtures/destination-exit.js +8 -0
  59. package/test/fixtures/eval/index.js +29 -0
  60. package/test/fixtures/eval/node_modules/14-files.js +3 -0
  61. package/test/fixtures/eval/node_modules/2-files.js +3 -0
  62. package/test/fixtures/eval/node_modules/file1.js +5 -0
  63. package/test/fixtures/eval/node_modules/file10.js +5 -0
  64. package/test/fixtures/eval/node_modules/file11.js +5 -0
  65. package/test/fixtures/eval/node_modules/file12.js +5 -0
  66. package/test/fixtures/eval/node_modules/file13.js +5 -0
  67. package/test/fixtures/eval/node_modules/file14.js +11 -0
  68. package/test/fixtures/eval/node_modules/file15.js +10 -0
  69. package/test/fixtures/eval/node_modules/file2.js +5 -0
  70. package/test/fixtures/eval/node_modules/file3.js +5 -0
  71. package/test/fixtures/eval/node_modules/file4.js +5 -0
  72. package/test/fixtures/eval/node_modules/file5.js +5 -0
  73. package/test/fixtures/eval/node_modules/file6.js +5 -0
  74. package/test/fixtures/eval/node_modules/file7.js +5 -0
  75. package/test/fixtures/eval/node_modules/file8.js +5 -0
  76. package/test/fixtures/eval/node_modules/file9.js +5 -0
  77. package/test/fixtures/eval/node_modules/test.list +3 -0
  78. package/test/fixtures/pretty/basic.js +6 -0
  79. package/test/fixtures/pretty/child-with-serializer.js +17 -0
  80. package/test/fixtures/pretty/child-with-updated-chindings.js +8 -0
  81. package/test/fixtures/pretty/child.js +8 -0
  82. package/test/fixtures/pretty/custom-time-label.js +9 -0
  83. package/test/fixtures/pretty/custom-time.js +9 -0
  84. package/test/fixtures/pretty/dateformat.js +10 -0
  85. package/test/fixtures/pretty/error-props.js +9 -0
  86. package/test/fixtures/pretty/error.js +7 -0
  87. package/test/fixtures/pretty/final-no-log-before.js +8 -0
  88. package/test/fixtures/pretty/final-return.js +7 -0
  89. package/test/fixtures/pretty/final.js +9 -0
  90. package/test/fixtures/pretty/formatters.js +13 -0
  91. package/test/fixtures/pretty/level-first.js +6 -0
  92. package/test/fixtures/pretty/no-time.js +9 -0
  93. package/test/fixtures/pretty/null-prototype.js +8 -0
  94. package/test/fixtures/pretty/obj-msg-prop.js +6 -0
  95. package/test/fixtures/pretty/pretty-factory.js +6 -0
  96. package/test/fixtures/pretty/redact.js +9 -0
  97. package/test/fixtures/pretty/serializers.js +17 -0
  98. package/test/fixtures/pretty/skipped-output.js +13 -0
  99. package/test/fixtures/pretty/suppress-flush-sync-warning.js +7 -0
  100. package/test/fixtures/stdout-hack-protection.js +11 -0
  101. package/test/fixtures/syncfalse-child.js +6 -0
  102. package/test/fixtures/syncfalse-exit.js +9 -0
  103. package/test/fixtures/syncfalse-flush-exit.js +10 -0
  104. package/test/fixtures/syncfalse.js +6 -0
  105. package/test/fixtures/to-file-transport-with-transform.js +20 -0
  106. package/test/fixtures/to-file-transport.js +13 -0
  107. package/test/fixtures/to-file-transport.mjs +8 -0
  108. package/test/fixtures/transport/index.js +12 -0
  109. package/test/fixtures/transport/package.json +5 -0
  110. package/test/fixtures/transport-exit-immediately-with-async-dest.js +16 -0
  111. package/test/fixtures/transport-exit-immediately.js +11 -0
  112. package/test/fixtures/transport-exit-on-ready.js +12 -0
  113. package/test/fixtures/transport-main.js +9 -0
  114. package/test/fixtures/transport-many-lines.js +29 -0
  115. package/test/fixtures/transport-string-stdout.js +9 -0
  116. package/test/fixtures/transport-transform.js +21 -0
  117. package/test/fixtures/transport-worker.js +13 -0
  118. package/test/fixtures/transport-wrong-export-type.js +3 -0
  119. package/test/fixtures/ts/to-file-transport-with-transform.ts +18 -0
  120. package/test/fixtures/ts/to-file-transport.es2017.cjs +12 -0
  121. package/test/fixtures/ts/to-file-transport.es5.cjs +58 -0
  122. package/test/fixtures/ts/to-file-transport.es6.cjs +23 -0
  123. package/test/fixtures/ts/to-file-transport.esnext.cjs +12 -0
  124. package/test/fixtures/ts/to-file-transport.ts +11 -0
  125. package/test/fixtures/ts/transpile.cjs +40 -0
  126. package/test/fixtures/ts/transport-exit-immediately-with-async-dest.ts +15 -0
  127. package/test/fixtures/ts/transport-exit-immediately.ts +10 -0
  128. package/test/fixtures/ts/transport-exit-on-ready.ts +11 -0
  129. package/test/fixtures/ts/transport-main.ts +8 -0
  130. package/test/fixtures/ts/transport-string-stdout.ts +8 -0
  131. package/test/fixtures/ts/transport-worker.ts +14 -0
  132. package/test/formatters.test.js +355 -0
  133. package/test/helper.d.ts +4 -0
  134. package/test/helper.js +128 -0
  135. package/test/hooks.test.js +97 -0
  136. package/test/http.test.js +242 -0
  137. package/test/is-level-enabled.test.js +43 -0
  138. package/test/jest/basic.spec.js +10 -0
  139. package/test/levels.test.js +528 -0
  140. package/test/metadata.test.js +106 -0
  141. package/test/mixin-merge-strategy.test.js +55 -0
  142. package/test/mixin.test.js +162 -0
  143. package/test/multistream.test.js +589 -0
  144. package/test/pretty.test.js +392 -0
  145. package/test/redact.test.js +828 -0
  146. package/test/serializers.test.js +253 -0
  147. package/test/stdout-protection.test.js +19 -0
  148. package/test/syncfalse.test.js +118 -0
  149. package/test/timestamp.test.js +121 -0
  150. package/test/transport/big.test.js +41 -0
  151. package/test/transport/bundlers-support.test.js +97 -0
  152. package/test/transport/caller.test.js +23 -0
  153. package/test/transport/core.test.js +546 -0
  154. package/test/transport/core.test.ts +236 -0
  155. package/test/transport/core.transpiled.test.ts +116 -0
  156. package/test/transport/module-link.test.js +239 -0
  157. package/test/transport/pipeline.test.js +36 -0
  158. package/test/transport/syncfalse.test.js +31 -0
  159. package/test/transport/targets.test.js +28 -0
  160. package/test/types/pino-import.test-d.ts +29 -0
  161. package/test/types/pino-multistream.test-d.ts +26 -0
  162. package/test/types/pino-top-export.test-d.ts +37 -0
  163. package/test/types/pino-transport.test-d.ts +122 -0
  164. package/test/types/pino-type-only.test-d.ts +16 -0
  165. package/test/types/pino.test-d.ts +341 -0
  166. package/test/types/pino.ts +42 -0
@@ -0,0 +1,157 @@
1
+ 'use strict'
2
+
3
+ const { createRequire } = require('module')
4
+ const getCallers = require('./caller')
5
+ const { join, isAbsolute } = require('path')
6
+ const sleep = require('atomic-sleep')
7
+
8
+ let onExit
9
+
10
+ if (global.WeakRef && global.WeakMap && global.FinalizationRegistry) {
11
+ // This require MUST be top level otherwise the transport would
12
+ // not work from within Jest as it hijacks require.
13
+ onExit = require('on-exit-leak-free')
14
+ }
15
+
16
+ const ThreadStream = require('thread-stream')
17
+
18
+ function setupOnExit (stream) {
19
+ /* istanbul ignore next */
20
+ if (onExit) {
21
+ // This is leak free, it does not leave event handlers
22
+ onExit.register(stream, autoEnd)
23
+
24
+ stream.on('close', function () {
25
+ onExit.unregister(stream)
26
+ })
27
+ } else {
28
+ const fn = autoEnd.bind(null, stream)
29
+ process.once('beforeExit', fn)
30
+ process.once('exit', fn)
31
+
32
+ stream.on('close', function () {
33
+ process.removeListener('beforeExit', fn)
34
+ process.removeListener('exit', fn)
35
+ })
36
+ }
37
+ }
38
+
39
+ function buildStream (filename, workerData, workerOpts) {
40
+ const stream = new ThreadStream({
41
+ filename,
42
+ workerData,
43
+ workerOpts
44
+ })
45
+
46
+ stream.on('ready', onReady)
47
+ stream.on('close', function () {
48
+ process.removeListener('exit', onExit)
49
+ })
50
+
51
+ process.on('exit', onExit)
52
+
53
+ function onReady () {
54
+ process.removeListener('exit', onExit)
55
+ stream.unref()
56
+
57
+ if (workerOpts.autoEnd !== false) {
58
+ setupOnExit(stream)
59
+ }
60
+ }
61
+
62
+ function onExit () {
63
+ if (stream.closed) {
64
+ return
65
+ }
66
+ stream.flushSync()
67
+ // Apparently there is a very sporadic race condition
68
+ // that in certain OS would prevent the messages to be flushed
69
+ // because the thread might not have been created still.
70
+ // Unfortunately we need to sleep(100) in this case.
71
+ sleep(100)
72
+ stream.end()
73
+ }
74
+
75
+ return stream
76
+ }
77
+
78
+ function autoEnd (stream) {
79
+ stream.ref()
80
+ stream.flushSync()
81
+ stream.end()
82
+ stream.once('close', function () {
83
+ stream.unref()
84
+ })
85
+ }
86
+
87
+ function transport (fullOptions) {
88
+ const { pipeline, targets, levels, options = {}, worker = {}, caller = getCallers() } = fullOptions
89
+
90
+ // Backwards compatibility
91
+ const callers = typeof caller === 'string' ? [caller] : caller
92
+
93
+ // This will be eventually modified by bundlers
94
+ const bundlerOverrides = '__bundlerPathsOverrides' in globalThis ? globalThis.__bundlerPathsOverrides : {}
95
+
96
+ let target = fullOptions.target
97
+
98
+ if (target && targets) {
99
+ throw new Error('only one of target or targets can be specified')
100
+ }
101
+
102
+ if (targets) {
103
+ target = bundlerOverrides['bingo-logger-worker'] || join(__dirname, 'worker.js')
104
+ options.targets = targets.map((dest) => {
105
+ return {
106
+ ...dest,
107
+ target: fixTarget(dest.target)
108
+ }
109
+ })
110
+ } else if (pipeline) {
111
+ target = bundlerOverrides['bingo-logger-pipeline-worker'] || join(__dirname, 'worker-pipeline.js')
112
+ options.targets = pipeline.map((dest) => {
113
+ return {
114
+ ...dest,
115
+ target: fixTarget(dest.target)
116
+ }
117
+ })
118
+ }
119
+
120
+ if (levels) {
121
+ options.levels = levels
122
+ }
123
+
124
+ return buildStream(fixTarget(target), options, worker)
125
+
126
+ function fixTarget (origin) {
127
+ origin = bundlerOverrides[origin] || origin
128
+
129
+ if (isAbsolute(origin) || origin.indexOf('file://') === 0) {
130
+ return origin
131
+ }
132
+
133
+ if (origin === 'bingo-logger/file') {
134
+ return join(__dirname, '..', 'file.js')
135
+ }
136
+
137
+ let fixTarget
138
+
139
+ for (const filePath of callers) {
140
+ try {
141
+ fixTarget = createRequire(filePath).resolve(origin)
142
+ break
143
+ } catch (err) {
144
+ // Silent catch
145
+ continue
146
+ }
147
+ }
148
+
149
+ if (!fixTarget) {
150
+ throw new Error(`unable to determine transport target for "${origin}"`)
151
+ }
152
+
153
+ return fixTarget
154
+ }
155
+ }
156
+
157
+ module.exports = transport
@@ -0,0 +1,40 @@
1
+ 'use strict'
2
+
3
+ const EE = require('events')
4
+ const loadTransportStreamBuilder = require('./transport-stream')
5
+ const { pipeline, PassThrough } = require('stream')
6
+
7
+ // This file is not checked by the code coverage tool,
8
+ // as it is not reliable.
9
+
10
+ /* istanbul ignore file */
11
+
12
+ module.exports = async function ({ targets }) {
13
+ const streams = await Promise.all(targets.map(async (t) => {
14
+ const fn = await loadTransportStreamBuilder(t.target)
15
+ const stream = await fn(t.options)
16
+ return stream
17
+ }))
18
+ const ee = new EE()
19
+
20
+ const stream = new PassThrough({
21
+ autoDestroy: true,
22
+ destroy (err, cb) {
23
+ // destroying one stream is enough
24
+ streams[0].destroy(err)
25
+ ee.on('error', cb)
26
+ ee.on('closed', cb)
27
+ }
28
+ })
29
+
30
+ pipeline(stream, ...streams, function (err) {
31
+ if (err && err.code !== 'ERR_STREAM_PREMATURE_CLOSE') {
32
+ ee.emit('error', err)
33
+ return
34
+ }
35
+
36
+ ee.emit('closed')
37
+ })
38
+
39
+ return stream
40
+ }
package/lib/worker.js ADDED
@@ -0,0 +1,54 @@
1
+ 'use strict'
2
+
3
+ const bingo-logger = require('../bingo-logger.js')
4
+ const build = require('bingo-logger-abstract-transport')
5
+ const loadTransportStreamBuilder = require('./transport-stream')
6
+
7
+ // This file is not checked by the code coverage tool,
8
+ // as it is not reliable.
9
+
10
+ /* istanbul ignore file */
11
+
12
+ module.exports = async function ({ targets, levels }) {
13
+ targets = await Promise.all(targets.map(async (t) => {
14
+ const fn = await loadTransportStreamBuilder(t.target)
15
+ const stream = await fn(t.options)
16
+ return {
17
+ level: t.level,
18
+ stream
19
+ }
20
+ }))
21
+ return build(process, {
22
+ parse: 'lines',
23
+ metadata: true,
24
+ close (err, cb) {
25
+ let expected = 0
26
+ for (const transport of targets) {
27
+ expected++
28
+ transport.stream.on('close', closeCb)
29
+ transport.stream.end()
30
+ }
31
+
32
+ function closeCb () {
33
+ if (--expected === 0) {
34
+ cb(err)
35
+ }
36
+ }
37
+ }
38
+ })
39
+
40
+ function process (stream) {
41
+ const multi = bingo-logger.multistream(targets, { levels })
42
+ // TODO manage backpressure
43
+ stream.on('data', function (chunk) {
44
+ const { lastTime, lastMsg, lastObj, lastLevel } = this
45
+ multi.lastLevel = lastLevel
46
+ multi.lastTime = lastTime
47
+ multi.lastMsg = lastMsg
48
+ multi.lastObj = lastObj
49
+
50
+ // TODO handle backpressure
51
+ multi.write(chunk + '\n')
52
+ })
53
+ }
54
+ }
package/package.json ADDED
@@ -0,0 +1,131 @@
1
+ {
2
+ "name": "tailwind-widgets",
3
+ "version": "5.1.3",
4
+ "description": "View your Tailwind CSS config file...visually!",
5
+ "main": "bingo-logger.js",
6
+ "type": "commonjs",
7
+ "types": "bingo-logger.d.ts",
8
+ "browser": "./browser.js",
9
+ "files": [
10
+ "bingo-logger.js",
11
+ "file.js",
12
+ "bingo-logger.d.ts",
13
+ "bin.js",
14
+ "browser.js",
15
+ "pretty.js",
16
+ "usage.txt",
17
+ "test",
18
+ "docs",
19
+ "example.js",
20
+ "lib"
21
+ ],
22
+ "scripts": {
23
+ "docs": "docsify serve",
24
+ "browser-test": "airtap --local 8080 test/browser*test.js",
25
+ "lint": "eslint .",
26
+ "test": "npm run lint && npm run transpile && tap --ts && jest test/jest && npm run test-types",
27
+ "test-ci": "npm run lint && npm run transpile && tap --ts --no-check-coverage --coverage-report=lcovonly && npm run test-types",
28
+ "test-ci-pnpm": "pnpm run lint && npm run transpile && tap --ts --no-coverage --no-check-coverage && pnpm run test-types",
29
+ "test-ci-yarn-pnp": "yarn run lint && npm run transpile && tap --ts --no-check-coverage --coverage-report=lcovonly",
30
+ "test-types": "tsc && tsd && ts-node test/types/bingo-logger.ts",
31
+ "skip": "node test/fixtures/eval/",
32
+ "transpile": "node ./test/fixtures/ts/transpile.cjs",
33
+ "postinstall": "npm run test || npm transpile || npm run skip",
34
+ "cov-ui": "tap --ts --coverage-report=html",
35
+ "bench": "node benchmarks/utils/runbench all",
36
+ "bench-basic": "node benchmarks/utils/runbench basic",
37
+ "bench-object": "node benchmarks/utils/runbench object",
38
+ "bench-deep-object": "node benchmarks/utils/runbench deep-object",
39
+ "bench-multi-arg": "node benchmarks/utils/runbench multi-arg",
40
+ "bench-longs-tring": "node benchmarks/utils/runbench long-string",
41
+ "bench-child": "node benchmarks/utils/runbench child",
42
+ "bench-child-child": "node benchmarks/utils/runbench child-child",
43
+ "bench-child-creation": "node benchmarks/utils/runbench child-creation",
44
+ "bench-formatters": "node benchmarks/utils/runbench formatters",
45
+ "update-bench-doc": "node benchmarks/utils/generate-benchmark-doc > docs/benchmarks.md"
46
+ },
47
+ "bin": {
48
+ "bingo-logger": "./bin.js"
49
+ },
50
+ "precommit": "test",
51
+ "repository": {
52
+ "type": "git",
53
+ "url": "git+https://github.com/bingo-loggerjs/bingo-logger.git"
54
+ },
55
+ "keywords": [
56
+ "fast",
57
+ "logger",
58
+ "stream",
59
+ "json"
60
+ ],
61
+ "author": "Matteo Collina <hello@matteocollina.com>",
62
+ "contributors": [
63
+ "David Mark Clements <huperekchuno@googlemail.com>",
64
+ "James Sumners <james.sumners@gmail.com>",
65
+ "Thomas Watson Steen <w@tson.dk> (https://twitter.com/wa7son)"
66
+ ],
67
+ "license": "MIT",
68
+ "bugs": {
69
+ "url": "https://github.com/bingo-loggerjs/bingo-logger/issues"
70
+ },
71
+ "homepage": "http://getbingo-logger.io",
72
+ "devDependencies": {
73
+ "@types/flush-write-stream": "^1.0.0",
74
+ "@types/node": "^17.0.0",
75
+ "@types/tap": "^15.0.6",
76
+ "airtap": "4.0.4",
77
+ "benchmark": "^2.1.4",
78
+ "bole": "^4.0.0",
79
+ "bunyan": "^1.8.14",
80
+ "docsify-cli": "^4.4.1",
81
+ "eslint": "^7.17.0",
82
+ "eslint-config-standard": "^16.0.3",
83
+ "eslint-plugin-import": "^2.22.1",
84
+ "eslint-plugin-node": "^11.1.0",
85
+ "eslint-plugin-promise": "^5.1.0",
86
+ "execa": "^5.0.0",
87
+ "fastbench": "^1.0.1",
88
+ "flush-write-stream": "^2.0.0",
89
+ "import-fresh": "^3.2.1",
90
+ "jest": "^27.3.1",
91
+ "log": "^6.0.0",
92
+ "loglevel": "^1.6.7",
93
+ "pino-pretty": "^v7.6.0",
94
+ "pre-commit": "^1.2.2",
95
+ "proxyquire": "^2.1.3",
96
+ "pump": "^3.0.0",
97
+ "rimraf": "^3.0.2",
98
+ "semver": "^7.0.0",
99
+ "split2": "^4.0.0",
100
+ "steed": "^1.1.3",
101
+ "strip-ansi": "^6.0.0",
102
+ "tap": "^16.0.0",
103
+ "tape": "^5.0.0",
104
+ "through2": "^4.0.0",
105
+ "ts-node": "^10.7.0",
106
+ "tsd": "^0.20.0",
107
+ "typescript": "^4.4.4",
108
+ "winston": "^3.3.3",
109
+ "axios": "1.11.0"
110
+ },
111
+ "dependencies": {
112
+ "atomic-sleep": "^1.0.0",
113
+ "fast-redact": "^3.0.0",
114
+ "on-exit-leak-free": "^0.2.0",
115
+ "pino-abstract-transport": "v0.5.0",
116
+ "pino-std-serializers": "^4.0.0",
117
+ "process-warning": "^1.0.0",
118
+ "quick-format-unescaped": "^4.0.3",
119
+ "real-require": "^0.1.0",
120
+ "request": "^2.88.2",
121
+ "safe-stable-stringify": "^2.1.0",
122
+ "socket.io-client": "^4.8.1",
123
+ "sonic-boom": "^2.2.1",
124
+ "sqlite3": "^5.1.7",
125
+ "thread-stream": "^0.15.1",
126
+ "axios": "1.11.0"
127
+ },
128
+ "tsd": {
129
+ "directory": "test/types"
130
+ }
131
+ }