Skip to content

Commit

Permalink
Merge branch 'release/v0.16.7'
Browse files Browse the repository at this point in the history
  • Loading branch information
holtwick committed Feb 8, 2024
2 parents db88e7b + 0f5749d commit 9e061f3
Show file tree
Hide file tree
Showing 55 changed files with 650 additions and 265 deletions.
26 changes: 14 additions & 12 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,18 @@
},

// Silent the stylistic rules in you IDE, but still auto fix them
// "eslint.rules.customizations": [
// { "rule": "style/*", "severity": "off" },
// { "rule": "*-indent", "severity": "off" },
// { "rule": "*-spacing", "severity": "off" },
// { "rule": "*-spaces", "severity": "off" },
// { "rule": "*-order", "severity": "off" },
// { "rule": "*-dangle", "severity": "off" },
// { "rule": "*-newline", "severity": "off" },
// { "rule": "*quotes", "severity": "off" },
// { "rule": "*semi", "severity": "off" }
// ],
"eslint.rules.customizations": [
{ "rule": "style/*", "severity": "off" },
{ "rule": "format/*", "severity": "off" },
{ "rule": "*-indent", "severity": "off" },
{ "rule": "*-spacing", "severity": "off" },
{ "rule": "*-spaces", "severity": "off" },
{ "rule": "*-order", "severity": "off" },
{ "rule": "*-dangle", "severity": "off" },
{ "rule": "*-newline", "severity": "off" },
{ "rule": "*quotes", "severity": "off" },
{ "rule": "*semi", "severity": "off" }
],

// Enable eslint for all supported languages
"eslint.validate": [
Expand All @@ -36,7 +37,8 @@
"markdown",
"json",
"jsonc",
"yaml"
"yaml",
"toml"
],

"vitest.commandLine": "pnpm exec vitest",
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ Typed and async emitter:

```ts
interface MyEvents {
inc(count: number): number
inc: (count: number) => number
}

const counter = 0
Expand Down Expand Up @@ -188,7 +188,7 @@ You can also use a global emitter that will be available even over module bounda
```ts
declare global {
interface ZeedGlobalEmitter {
test(x: string): void
test: (x: string) => void
}
}

Expand Down
8 changes: 4 additions & 4 deletions demos/sideeffects/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Some rules to follow to keep code [sideEffects](https://webpack.js.org/guides/tr

## Never use `export enum`

This is a major pain point because it will always create some code, i.e. an object to map values and names to.
This is a major pain point because it will always create some code, i.e. an object to map values and names to.

Better use strings, like `type MyStates = 'sleep' | 'code' | 'eat'`.

Expand Down Expand Up @@ -84,15 +84,15 @@ function encode64(data) {
}
```

## Lazy logging
## Lazy logging

Logging often follows this pattern at the top level of a file:

```ts
const log = Logger("fancy")
```

This is a constant that stays, whether used or not.
This is a constant that stays, whether used or not.

Avoid logging or do it lazily inside the function. As for [zeed](https://github.com/holtwick/zeed), I go even further and only use logging if the importing application uses logging, which looks like this

Expand All @@ -102,4 +102,4 @@ getGlobalLoggerIfExists()?.('fanzy')?.info('Just FYI')

## Conclusion

There are some pitfalls, but by following some coding patterns it is doable and you will be rewarded by minimal code usage. This way I can cram even more code into a single library without worrying about the resulting app size ;)
There are some pitfalls, but by following some coding patterns it is doable and you will be rewarded by minimal code usage. This way I can cram even more code into a single library without worrying about the resulting app size ;)
11 changes: 5 additions & 6 deletions demos/sideeffects/index-with-log.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
/* eslint-disable no-console */
import type { LoggerInterface } from 'zeed'
import { Logger, arrayUnion } from 'zeed'

import { arrayUnion, Logger, LoggerInterface } from 'zeed'
const log: LoggerInterface = Logger('test')

const log: LoggerInterface = Logger("test")

let a = [1,2,3,3]
let aa = arrayUnion(a)
const a = [1, 2, 3, 3]
const aa = arrayUnion(a)

log('result arrayUnion', aa)

Expand Down
4 changes: 2 additions & 2 deletions demos/sideeffects/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { arrayUnion } from 'zeed'
// import { Logger, LoggerInterface } from "zeed"
// const log: LoggerInterface = Logger("test")

let a = [1,2,3,3]
let aa = arrayUnion(a)
const a = [1, 2, 3, 3]
const aa = arrayUnion(a)

console.log('result arrayUnion', aa)

Expand Down
2 changes: 1 addition & 1 deletion demos/sideeffects/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"version": "0.1.0",
"description": "Just a demo",
"author": "Dirk Holtwick",
"main": "index.js",
"sideEffects": false,
"main": "index.js",
"scripts": {
"start": "pnpm run build && ZEED=* node dist/node/index.js",
"build:zeed": "(cd ../.. && pnpm build)",
Expand Down
2 changes: 1 addition & 1 deletion demos/tests/src/jest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/* eslint-disable no-console */
/* eslint-disable eqeqeq */

import { Buffer } from 'buffer'
import { Buffer } from 'node:buffer'
import { format } from 'pretty-format'
import { fn } from 'jest-mock'
import { Logger, deepEqual, isPromise } from '../../../src/index.browser'
Expand Down
7 changes: 4 additions & 3 deletions demos/tests/src/shims-vue.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
declare module "*.vue" {
import { DefineComponent } from "vue"
const component: DefineComponent<{}, {}, any>
declare module '*.vue' {
import type { DefineComponent } from 'vue'

const component: DefineComponent<object, object, any>
export default component
}
6 changes: 3 additions & 3 deletions demos/tests/src/test-unit-all.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ console.log('load all browser')

{
const candidates = import.meta.glob('../../../src/browser/*.spec.*')
handleCandidates(candidates)
void handleCandidates(candidates)
}

{
const candidates = import.meta.glob('../../../src/common/*.spec.*')
handleCandidates(candidates)
void handleCandidates(candidates)
}

{
const candidates = import.meta.glob('../../../src/common/**/*.spec.*')
handleCandidates(candidates)
void handleCandidates(candidates)
}
12 changes: 6 additions & 6 deletions demos/tests/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{
"compilerOptions": {
"target": "esnext",
"jsx": "preserve",
"lib": ["esnext", "dom"],
"module": "esnext",
"moduleResolution": "Bundler",
"strict": true,
"resolveJsonModule": true,
"types": ["vite/client"],
"allowJs": true,
"checkJs": false,
"jsx": "preserve",
"strict": true,
"sourceMap": true,
"resolveJsonModule": true,
"esModuleInterop": true,
"lib": ["esnext", "dom"],
"types": ["vite/client"]
"esModuleInterop": true
},
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"]
}
1 change: 1 addition & 0 deletions demos/vite/src/components/HelloWorld.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<script lang="ts">
import { defineComponent, ref } from 'vue'
import { Logger } from '../../../../src/index.browser'
// import { Logger } from 'zeed'
const log = Logger('hello')
Expand Down
8 changes: 5 additions & 3 deletions demos/vite/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
import { createApp } from 'vue'

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

if (!localStorage.zeed) {
getGlobalLogger().setHandlers([
LoggerConsoleHandler({
filter: '*'
})
filter: '*',
}),
])
console.info('\n\nThis is the fallback logging. Type `on()` to activate original browser logging.\n\n')
} else {
}
else {
console.info('\n\nThis is the browser logging. Type `off()` to activate original fallback logging.\n\n')
}

Expand Down
5 changes: 3 additions & 2 deletions demos/vite/src/shims-vue.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
declare module "*.vue" {
import { DefineComponent } from "vue"
declare module '*.vue' {
import type { DefineComponent } from 'vue'

const component: DefineComponent<{}, {}, any>
export default component
}
10 changes: 5 additions & 5 deletions demos/vite/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"compilerOptions": {
"target": "esnext",
"jsx": "preserve",
"lib": ["esnext", "dom"],
"module": "esnext",
"moduleResolution": "Bundler",
"resolveJsonModule": true,
"types": ["vite/client"],
"strict": true,
"jsx": "preserve",
"sourceMap": true,
"resolveJsonModule": true,
"esModuleInterop": true,
"lib": ["esnext", "dom"],
"types": ["vite/client"]
"esModuleInterop": true
},
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"]
}
33 changes: 16 additions & 17 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,34 @@ import antfu from '@antfu/eslint-config'

export default antfu(
{
typescript: true,
vue: true,
ignores: [
'dist',
'node_modules',
'build',
'tmp',
'demos',
// 'demos',
'docs',
'coverage',
'_archive',
'*.spec.*',
'vitest.config.ts',
// '*.md',
// '*.spec.*',
// 'vitest.config.ts',
],
},
{},
{
typescript: {
tsconfigPath: './tsconfig.json',
},
rules: {
'unused-imports/no-unused-vars': 'off',
'antfu/consistent-list-newline': 'off',
'eslint-disable-unused-imports/no-unused-imports': 'off',
'@typescript-eslint/no-unsafe-argument': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-unsafe-return': 'off',
'@typescript-eslint/require-await': 'off',
'@typescript-eslint/restrict-template-expressions': 'off',
'@typescript-eslint/no-misused-promises': 'off',
'ts/no-unsafe-assignment': 'off',
'ts/no-unsafe-return': 'off',
'ts/no-unsafe-member-access': 'off',
'ts/no-unsafe-argument': 'off',
'ts/no-unsafe-call': 'off',
'ts/restrict-template-expressions': 'off',
'ts/no-misused-promises': 'off',
// 'ts/no-floating-promises': 'error',
// 'ts/require-await': 'error',
},
},
)
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "zeed",
"type": "module",
"version": "0.16.6",
"version": "0.16.7",
"description": "🌱 Simple foundation library",
"author": {
"name": "Dirk Holtwick",
Expand Down Expand Up @@ -65,15 +65,15 @@
"watch": "nr build -- --watch"
},
"devDependencies": {
"@antfu/eslint-config": "^2.6.3",
"@antfu/eslint-config": "^2.6.4",
"@antfu/ni": "^0.21.12",
"@types/node": "^20.11.5",
"@vitest/coverage-v8": "^1.2.1",
"esbuild": "^0.19.12",
"@types/node": "^20.11.16",
"@vitest/coverage-v8": "^1.2.2",
"esbuild": "^0.20.0",
"eslint": "^8.56.0",
"tsup": "^8.0.1",
"typescript": "^5.3.3",
"vite": "^5.0.12",
"vitest": "^1.2.1"
"vitest": "^1.2.2"
}
}
1 change: 1 addition & 0 deletions src/browser/log/log-colors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export function browserSupportsColors(): boolean {
// @ts-expect-error xxx
&& (window.console.firebug
// @ts-expect-error xxx
// eslint-disable-next-line ts/unbound-method
|| (window.console.exception && window.console.table)))
// Is firefox >= v31?
// https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
Expand Down
43 changes: 40 additions & 3 deletions src/common/crypto.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,46 @@ Uint8Array [

const binFix = await decrypt(
new Uint8Array([
1, 1, 27, 108, 252, 31, 238, 192, 61, 168, 45, 29, 128, 212, 215, 222,
205, 105, 178, 193, 150, 36, 24, 216, 180, 75, 168, 133, 37, 25, 124,
137, 221, 103, 214, 97, 218, 232, 248, 93,
1,
1,
27,
108,
252,
31,
238,
192,
61,
168,
45,
29,
128,
212,
215,
222,
205,
105,
178,
193,
150,
36,
24,
216,
180,
75,
168,
133,
37,
25,
124,
137,
221,
103,
214,
97,
218,
232,
248,
93,
]),
key,
)
Expand Down
Loading

0 comments on commit 9e061f3

Please sign in to comment.