Skip to content

Commit

Permalink
Merge branch 'release/v0.24.18'
Browse files Browse the repository at this point in the history
  • Loading branch information
holtwick committed Sep 16, 2024
2 parents a0359ef + 20b69ba commit ba37687
Show file tree
Hide file tree
Showing 64 changed files with 152 additions and 119 deletions.
2 changes: 1 addition & 1 deletion demos/logging/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/* eslint-disable no-console */

import process from 'node:process'
import { Logger, logCaptureConsole, setupEnv } from 'zeed'
import { logCaptureConsole, Logger, setupEnv } from 'zeed'

// Read .env file

Expand Down
2 changes: 1 addition & 1 deletion demos/node/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import process from 'node:process'

import { Logger, digest, setupEnv, stringToUInt8Array, toUint8Array, uuid } from 'zeed'
import { digest, Logger, setupEnv, stringToUInt8Array, toUint8Array, uuid } from 'zeed'

// Some basic logging

Expand Down
2 changes: 1 addition & 1 deletion demos/sideeffects/index-with-log.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { LoggerInterface } from 'zeed'
import { Logger, arrayUnion } from 'zeed'
import { arrayUnion, Logger } from 'zeed'

const log: LoggerInterface = Logger('test')

Expand Down
4 changes: 2 additions & 2 deletions demos/tests/src/jest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
/* eslint-disable no-console */
/* eslint-disable eqeqeq */

import { format } from 'pretty-format'
import { fn } from 'jest-mock'
import { Logger, deepEqual, isPromise } from '../../../src/index.browser'
import { format } from 'pretty-format'
import { deepEqual, isPromise, Logger } from '../../../src/index.browser'

const log = Logger('zeed:jest')

Expand Down
2 changes: 1 addition & 1 deletion demos/tests/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { defineConfig } from 'vite'

// https://vitejs.dev/config/
export default defineConfig({
Expand Down
2 changes: 1 addition & 1 deletion demos/vite/src/log-test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable no-console */
import type { LogMessage } from '../../../src/common'
import { LogLevelAll, LoggerMemoryHandler, getGlobalLogger, logCaptureConsole } from '../../../src/common'
import { getGlobalLogger, logCaptureConsole, LoggerMemoryHandler, LogLevelAll } from '../../../src/common'
import { Logger } from '../../../src/index.browser'

export function logTest() {
Expand Down
2 changes: 1 addition & 1 deletion demos/vite/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { createApp } from 'vue'

// import { Logger } from 'zeed'
import { Logger, LoggerConsoleHandler, getGlobalLogger } from '../../../src/index.browser'
import { getGlobalLogger, Logger, LoggerConsoleHandler } from '../../../src/index.browser'
import App from './App.vue'

if (!localStorage.zeed) {
Expand Down
2 changes: 1 addition & 1 deletion demos/vite/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { defineConfig } from 'vite'

// https://vitejs.dev/config/
export default defineConfig({
Expand Down
18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "zeed",
"type": "module",
"version": "0.24.17",
"version": "0.24.18",
"description": "🌱 Simple foundation library",
"author": {
"name": "Dirk Holtwick",
Expand Down Expand Up @@ -69,19 +69,19 @@
"watch": "nr build -- --watch src"
},
"devDependencies": {
"@antfu/eslint-config": "^3.2",
"@antfu/eslint-config": "^3.6",
"@antfu/ni": "^0.23.0",
"@types/node": "^22.5.4",
"@types/node": "^22.5.5",
"@vitejs/plugin-vue": "^5.1.3",
"@vitest/browser": "^2.0.5",
"@vitest/coverage-v8": "^2.0.5",
"@vitest/browser": "^2.1.1",
"@vitest/coverage-v8": "^2.1.1",
"esbuild": "^0.23.1",
"eslint": "^9",
"playwright": "^1.46.1",
"playwright": "^1.47.1",
"tsup": "^8.2.4",
"typescript": "^5.5.4",
"vite": "^5.4.3",
"vitest": "^2.0.5"
"typescript": "^5.6.2",
"vite": "^5.4.5",
"vitest": "^2.1.1"
},
"pnpm": {
"overrides": {
Expand Down
2 changes: 1 addition & 1 deletion src/browser/log/log-browser-factory.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { LogHandlerOptions, LogLevel, LogLevelAliasType, LoggerInterface } from '../../common/log/log-base'
import type { LoggerInterface, LogHandlerOptions, LogLevel, LogLevelAliasType } from '../../common/log/log-base'
import { LogLevelAll, LogLevelDebug, LogLevelError, LogLevelFatal, LogLevelInfo, LogLevelOff, LogLevelWarn } from '../../common/log/log-base'
import { browserSelectColorByName } from '../../common/log/log-colors'
import { getGlobalConsole } from '../../common/log/log-console-original'
Expand Down
34 changes: 17 additions & 17 deletions src/browser/log/log-colors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,28 +28,28 @@ export function browserSupportsColors(): boolean {
// document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
return (
(typeof document !== 'undefined'
&& document.documentElement
&& document.documentElement.style
&& document.documentElement
&& document.documentElement.style
// @ts-expect-error xxx
&& document.documentElement.style.WebkitAppearance)
&& document.documentElement.style.WebkitAppearance)
// Is firebug? http://stackoverflow.com/a/398120/376773
|| (typeof window !== 'undefined'
&& window.console
// @ts-expect-error xxx
&& (window.console.firebug
// @ts-expect-error xxx
|| (typeof window !== 'undefined'
&& window.console
// @ts-expect-error xxx
&& (window.console.firebug
// @ts-expect-error xxx

|| (window.console.exception && window.console.table)))
|| (window.console.exception && window.console.table)))
// Is firefox >= v31?
// https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
|| (typeof navigator !== 'undefined'
&& navigator.userAgent
&& navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)
// eslint-disable-next-line regexp/no-legacy-features
&& Number.parseInt(RegExp.$1, 10) >= 31)
|| (typeof navigator !== 'undefined'
&& navigator.userAgent
&& navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)
// eslint-disable-next-line regexp/no-legacy-features
&& Number.parseInt(RegExp.$1, 10) >= 31)
// Double check webkit in userAgent just in case we are in a worker
|| (typeof navigator !== 'undefined'
&& navigator.userAgent
&& navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))
|| (typeof navigator !== 'undefined'
&& navigator.userAgent
&& navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))
)
}
4 changes: 2 additions & 2 deletions src/browser/log/log-context-browser.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { LoggerInterface, LogLevelAliasType } from '../../common/log/log-base'
import type { LogConfig } from '../../common/log/log-config'
import { isEmpty } from '../../common/data/is'
import { getGlobalLogger } from '../../common/log/log'
import type { LogLevelAliasType, LoggerInterface } from '../../common/log/log-base'
import type { LogConfig } from '../../common/log/log-config'
import { _LoggerFromConfig } from '../../common/log/log-config'
import { isBrowser } from '../../common/platform'
import { LoggerBrowserHandler } from './log-browser'
Expand Down
2 changes: 1 addition & 1 deletion src/common/assert.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getGlobalLoggerIfExists } from './log'
import { getGlobalLoggerIfExists } from './log/log'

/** Always throws. */
export function fatal(...messages: any[]): never {
Expand Down
2 changes: 1 addition & 1 deletion src/common/bin/index.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Uint8ArrayToHexDump, equalBinary, toHex } from '..'
import { bitfield, createBinaryStreamDecoder, createBinaryStreamEncoder, encodeJson } from '.'
import { equalBinary, toHex, Uint8ArrayToHexDump } from '..'

describe('encoder', () => {
it('should write a stream', () => {
Expand Down
6 changes: 3 additions & 3 deletions src/common/bin/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type { BinInput } from '../data/bin'
import type { Encoder } from '../msg/encoder'
import { assertCondition } from '../assert'
import type { BinInput } from '../data/bin'
import { toUint8Array } from '../data/bin'
import { createBinEncoder, encodeToUint8Array, length, writeAny, writeFloat32, writeUint16, writeUint32, writeUint8, writeUint8Array, writeVarInt, writeVarString, writeVarUint, writeVarUint8Array } from './lib0/encoding'
import { createDecoder, readAny, readFloat32, readUint16, readUint32, readUint8, readUint8Array, readVarInt, readVarString, readVarUint, readVarUint8Array } from './lib0/decoding'
import { createDecoder, readAny, readFloat32, readUint8, readUint8Array, readUint16, readUint32, readVarInt, readVarString, readVarUint, readVarUint8Array } from './lib0/decoding'
import { createBinEncoder, encodeToUint8Array, length, writeAny, writeFloat32, writeUint8, writeUint8Array, writeUint16, writeUint32, writeVarInt, writeVarString, writeVarUint, writeVarUint8Array } from './lib0/encoding'

// Use in Zeed channels

Expand Down
2 changes: 1 addition & 1 deletion src/common/bin/lib0/encoding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
* ```
*/

import { BIT7, BIT8, BITS31, BITS6, BITS7, BITS8 } from './binary'
import { BIT7, BIT8, BITS6, BITS7, BITS8, BITS31 } from './binary'
import { createUint8ArrayViewFromArrayBuffer } from './create'
import { encodeUtf8, getUtf8TextEncoder } from './string'

Expand Down
2 changes: 1 addition & 1 deletion src/common/crypto.spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/* eslint-disable prefer-spread */
/* eslint-disable no-cond-assign */

import { DefaultLogger } from '.'
import { decrypt, deriveKeyPbkdf2, digest, encrypt, randomUint8Array } from './crypto'
import { equalBinary, toHex } from './data/bin'
import { DefaultLogger } from '.'

const log = DefaultLogger('crypto.spec')

Expand Down
4 changes: 3 additions & 1 deletion src/common/csv.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { escapeRegExp, isArray, isBoolean, isRecord, jsonStringifySafe } from './data'
import { isArray, isBoolean, isRecord } from './data/is'
import { jsonStringifySafe } from './data/json'
import { escapeRegExp } from './data/regexp'

const defaultSeparator = ','

Expand Down
2 changes: 1 addition & 1 deletion src/common/dispose-defer.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { DefaultLogger } from './log'
import { useDefer, useDispose } from './dispose-defer'
import { sleep } from './exec'
import { DefaultLogger } from './log'

const log = DefaultLogger('dispose-test')

Expand Down
8 changes: 4 additions & 4 deletions src/common/dispose-defer.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { isString } from './data'
import { arrayFilterInPlace } from './data/array'
import type { Disposer, DisposerFunction } from './dispose-types'
import { isPromise } from './exec/promise'
import { DefaultLogger } from './log'
import type { LoggerInterface } from './log/log-base'
import { arrayFilterInPlace } from './data/array'
import { isString } from './data/is'
import { isPromise } from './exec/promise'
import { DefaultLogger } from './log/log'

export function polyfillUsing() {
try {
Expand Down
2 changes: 1 addition & 1 deletion src/common/dispose-utils.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { vi as jest } from 'vitest'
import { useDisposeWithUtils, useEventListener, useTimeout } from './dispose-utils'
import { polyfillUsing } from './dispose-defer'
import { useDisposeWithUtils, useEventListener, useTimeout } from './dispose-utils'

describe('useTimeout', () => {
it('should call the provided function after the specified timeout', () => {
Expand Down
4 changes: 2 additions & 2 deletions src/common/dispose-utils.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { UseDisposeConfig } from './dispose-defer'
import { useDispose } from './dispose-defer'
import type { DisposerFunction } from './dispose-types'
import { promisify } from './exec'
import type { LoggerInterface } from './log/log-base'
import { useDispose } from './dispose-defer'
import { promisify } from './exec/promise'

export type TimerExecFunction = () => void | Promise<void>

Expand Down
4 changes: 4 additions & 0 deletions src/common/eslint-defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ export function eslintIgnoreDefaults() {
/// Very much opiniated ESLint setting! Details to rules see https://eslint.org/docs/latest/rules/
export function eslintRulesDefaults() {
return {
// for some old third party code a `eslint-disable` does wonders :)
'eslint-comments/no-unlimited-disable': 'off',

'unused-imports/no-unused-vars': 'off',
'ts/no-unsafe-assignment': 'off',
'ts/no-unsafe-return': 'off',
Expand All @@ -36,6 +39,7 @@ export function eslintRulesDefaults() {
'ts/restrict-template-expressions': 'off',
'ts/no-misused-promises': 'off',

// await / async
// 'ts/no-floating-promises': 'error',
// 'ts/require-await': 'error',

Expand Down
4 changes: 2 additions & 2 deletions src/common/exec/progress.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Inspired by https://developer.apple.com/documentation/foundation/progress

import { arrayRemoveElement } from '../data/array'
import { useDispose } from '../dispose-defer'
import { arrayRemoveElement } from '../data'
import { Emitter } from '../msg'
import { Emitter } from '../msg/emitter'
import { uname } from '../uuid'

interface ProgressOptions {
Expand Down
4 changes: 2 additions & 2 deletions src/common/exec/queue.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Can learn from here https://github.com/sindresorhus/p-queue

import { DefaultLogger } from '../log'
import type { LogLevel, LoggerInterface } from '../log/log-base'
import type { LoggerInterface, LogLevel } from '../log/log-base'
import { DefaultLogger } from '../log/log'
import { LogLevelOff } from '../log/log-base'
import { Emitter } from '../msg/emitter'
import { uname } from '../uuid'
Expand Down
5 changes: 2 additions & 3 deletions src/common/log/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
export * from './log'
export * from './log-base'
export * from './log-colors'
export type { LogConfig } from './log-config'
export * from './log-console'
export * from './log-console-original'
export * from './log-console-capture'
export * from './log-console-original'
export * from './log-context'
export * from './log-filter'
export * from './log-memory'

export type { LogConfig } from './log-config'
2 changes: 1 addition & 1 deletion src/common/log/log-config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { LoggerInterface, LogLevelAliasType } from './log-base'
import { isNumber, isString } from '../data/is'
import type { LogLevelAliasType, LoggerInterface } from './log-base'

/**
* Simple log configuration for use in modular scenarios.
Expand Down
2 changes: 1 addition & 1 deletion src/common/log/log-context.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { LoggerContextInterface, LoggerInterface, LogHandler, LogLevel, LogLevelAliasType, LogMessage } from './log-base'
import { isNotNull } from '../data/is'
import type { LogHandler, LogLevel, LogLevelAliasType, LogMessage, LoggerContextInterface, LoggerInterface } from './log-base'
import { LogLevelAll, LogLevelDebug, LogLevelError, LogLevelFatal, LogLevelInfo, LogLevelWarn } from './log-base'
import { LoggerConsoleHandler } from './log-console'
import { parseLogLevel, useNamespaceFilter } from './log-filter'
Expand Down
2 changes: 1 addition & 1 deletion src/common/log/log-filter.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// (C)opyright 2021-07-15 Dirk Holtwick, holtwick.it. All rights reserved.
/* eslint-disable node/prefer-global/process */

import { isString } from '../data'
import type { LogLevel, LogLevelAliasType } from './log-base'
import { isString } from '../data/is'
import { LogLevelAlias, LogLevelAll, LogLevelOff } from './log-base'

interface NamespaceFilter {
Expand Down
2 changes: 1 addition & 1 deletion src/common/log/log-memory.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { LogMessage, LoggerInterface } from './log-base'
import type { LoggerInterface, LogMessage } from './log-base'
import { LogLevelAll } from './log-base'
import { LoggerContext } from './log-context'
import { LoggerMemoryHandler } from './log-memory'
Expand Down
4 changes: 2 additions & 2 deletions src/common/log/log-memory.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { objectPlain } from '../data'
import { getTimestamp } from '../time'
import type { LogHandler, LogHandlerOptions, LogMessage, LogMessageCompact } from './log-base'
import { objectPlain } from '../data/object'
import { getTimestamp } from '../time'
import { useLevelFilter, useNamespaceFilter } from './log-filter'

export function logMessageFromCompact(m: LogMessageCompact): LogMessage {
Expand Down
2 changes: 1 addition & 1 deletion src/common/log/log.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { LogMessage, LoggerInterface } from './log-base'
import type { LoggerInterface, LogMessage } from './log-base'
import { LoggerContext } from './log-context'

describe('logger', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/common/log/log.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { LoggerContextInterface, LoggerInterface, LogLevelAliasType } from './log-base'
import { getGlobalContext } from '../global'
import type { LogLevelAliasType, LoggerContextInterface, LoggerInterface } from './log-base'
import { LoggerConsoleHandler } from './log-console'
import { getGlobalConsole } from './log-console-original'
import { LoggerContext } from './log-context'
Expand Down
4 changes: 2 additions & 2 deletions src/common/msg/emitter.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { vi } from 'vitest'
import { sleep, waitOn } from '../exec/promise'
import { getSecureRandomIfPossible } from '../data/math'
import { sleep, waitOn } from '../exec/promise'
import { Emitter, getGlobalEmitter } from './emitter'

declare global {
Expand Down Expand Up @@ -31,7 +31,7 @@ function lazyListener(
const ev = { key, obj }
// debug(name, " lazy push", ev)
events.push(ev)
// eslint-disable-next-line ts/no-unused-expressions

lazyResolve && lazyResolve()
}

Expand Down
2 changes: 1 addition & 1 deletion src/common/msg/emitter.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { DisposerFunction } from '../dispose-types'
import { getGlobalContext } from '../global'
import { DefaultLogger } from '../log'
import { DefaultLogger } from '../log/log'
import { safeTimeout } from '../timeout'

export type EmitterHandler = (...objs: any[]) => void
Expand Down
2 changes: 1 addition & 1 deletion src/common/msg/encoder.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { deriveKeyPbkdf2, randomUint8Array } from '..'
import { CryptoEncoder, JsonEncoder } from '.'
import { deriveKeyPbkdf2, randomUint8Array } from '..'

describe('encoder', () => {
it('should encode json', async () => {
Expand Down
Loading

0 comments on commit ba37687

Please sign in to comment.