@livestore/utils 0.0.58-dev.0 → 0.0.58-dev.10
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/dist/.tsbuildinfo.json +1 -1
- package/dist/cuid/cuid.browser.d.ts.map +1 -1
- package/dist/cuid/cuid.browser.js +1 -0
- package/dist/cuid/cuid.browser.js.map +1 -1
- package/dist/effect/Effect.d.ts.map +1 -1
- package/dist/effect/Effect.js +4 -3
- package/dist/effect/Effect.js.map +1 -1
- package/dist/effect/Error.d.ts +1 -1
- package/dist/effect/Error.d.ts.map +1 -1
- package/dist/effect/Error.js +1 -1
- package/dist/effect/Error.js.map +1 -1
- package/dist/effect/Schema/debug-diff.d.ts +2 -3
- package/dist/effect/Schema/debug-diff.d.ts.map +1 -1
- package/dist/effect/Schema/debug-diff.js +8 -8
- package/dist/effect/Schema/debug-diff.js.map +1 -1
- package/dist/effect/Schema/debug-diff.test.js +1 -1
- package/dist/effect/Schema/debug-diff.test.js.map +1 -1
- package/dist/effect/Schema/index.d.ts +11 -5
- package/dist/effect/Schema/index.d.ts.map +1 -1
- package/dist/effect/Schema/index.js +3 -3
- package/dist/effect/Schema/index.js.map +1 -1
- package/dist/effect/Schema/msgpack.d.ts +1 -1
- package/dist/effect/Schema/msgpack.d.ts.map +1 -1
- package/dist/effect/Schema/msgpack.js +1 -1
- package/dist/effect/Schema/msgpack.js.map +1 -1
- package/dist/effect/WebChannel.d.ts +1 -2
- package/dist/effect/WebChannel.d.ts.map +1 -1
- package/dist/effect/WebChannel.js.map +1 -1
- package/dist/effect/index.d.ts +6 -3
- package/dist/effect/index.d.ts.map +1 -1
- package/dist/effect/index.js +5 -3
- package/dist/effect/index.js.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/misc.d.ts.map +1 -1
- package/dist/misc.js +1 -0
- package/dist/misc.js.map +1 -1
- package/dist/nanoid/index.d.ts +2 -0
- package/dist/nanoid/index.d.ts.map +1 -0
- package/dist/nanoid/index.js +2 -0
- package/dist/nanoid/index.js.map +1 -0
- package/dist/string.d.ts +2 -0
- package/dist/string.d.ts.map +1 -1
- package/dist/string.js +5 -0
- package/dist/string.js.map +1 -1
- package/package.json +27 -21
- package/src/cuid/cuid.browser.ts +1 -0
- package/src/effect/Effect.ts +2 -1
- package/src/effect/Error.ts +1 -1
- package/src/effect/Schema/debug-diff.test.ts +1 -1
- package/src/effect/Schema/debug-diff.ts +11 -12
- package/src/effect/Schema/index.ts +19 -5
- package/src/effect/Schema/msgpack.ts +1 -1
- package/src/effect/WebChannel.ts +1 -2
- package/src/effect/index.ts +7 -9
- package/src/index.ts +0 -2
- package/src/misc.ts +1 -0
- package/src/nanoid/index.ts +1 -0
- package/src/string.ts +7 -0
- package/tsconfig.json +1 -1
package/package.json
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@livestore/utils",
|
|
3
|
-
"version": "0.0.58-dev.
|
|
4
|
-
"sideEffects":
|
|
3
|
+
"version": "0.0.58-dev.10",
|
|
4
|
+
"sideEffects": [
|
|
5
|
+
"./dist/global.js"
|
|
6
|
+
],
|
|
5
7
|
"type": "module",
|
|
6
8
|
"exports": {
|
|
7
9
|
".": {
|
|
@@ -14,6 +16,10 @@
|
|
|
14
16
|
"react-native": "./dist/cuid/cuid.browser.js",
|
|
15
17
|
"browser": "./dist/cuid/cuid.browser.js"
|
|
16
18
|
},
|
|
19
|
+
"./nanoid": {
|
|
20
|
+
"types": "./dist/nanoid/index.d.ts",
|
|
21
|
+
"default": "./dist/nanoid/index.js"
|
|
22
|
+
},
|
|
17
23
|
"./effect": {
|
|
18
24
|
"types": "./dist/effect/index.d.ts",
|
|
19
25
|
"default": "./dist/effect/index.js"
|
|
@@ -26,38 +32,38 @@
|
|
|
26
32
|
"./cuid": [
|
|
27
33
|
"./dist/cuid/cuid.node.d.ts"
|
|
28
34
|
],
|
|
35
|
+
"./nanoid": [
|
|
36
|
+
"./dist/nanoid/index.d.ts"
|
|
37
|
+
],
|
|
29
38
|
"effect": [
|
|
30
39
|
"./dist/effect"
|
|
31
40
|
]
|
|
32
41
|
}
|
|
33
42
|
},
|
|
34
43
|
"dependencies": {
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"otel-websocket-exporter": "^0.0.29",
|
|
44
|
+
"msgpackr": "^1.11.2",
|
|
45
|
+
"nanoid": "^5.0.7",
|
|
38
46
|
"pretty-bytes": "^6.1.1",
|
|
39
|
-
"
|
|
47
|
+
"@livestore/db-schema": "0.0.58-dev.10"
|
|
40
48
|
},
|
|
41
49
|
"peerDependencies": {
|
|
42
|
-
"@effect/experimental": "^0.
|
|
43
|
-
"@effect/opentelemetry": "^0.
|
|
44
|
-
"@effect/platform": "^0.
|
|
45
|
-
"@effect/platform-browser": "^0.
|
|
46
|
-
"@effect/schema": "^0.72.2",
|
|
50
|
+
"@effect/experimental": "^0.30.13",
|
|
51
|
+
"@effect/opentelemetry": "^0.39.7",
|
|
52
|
+
"@effect/platform": "^0.69.12",
|
|
53
|
+
"@effect/platform-browser": "^0.48.12",
|
|
47
54
|
"@opentelemetry/api": "^1.9.0",
|
|
48
|
-
"effect": "^3.7
|
|
55
|
+
"effect": "^3.10.7"
|
|
49
56
|
},
|
|
50
57
|
"devDependencies": {
|
|
51
|
-
"@effect/experimental": "0.
|
|
52
|
-
"@effect/opentelemetry": "0.
|
|
53
|
-
"@effect/platform": "0.
|
|
54
|
-
"@effect/platform-browser": "0.
|
|
55
|
-
"@effect/schema": "0.72.2",
|
|
58
|
+
"@effect/experimental": "0.30.13",
|
|
59
|
+
"@effect/opentelemetry": "0.39.7",
|
|
60
|
+
"@effect/platform": "0.69.12",
|
|
61
|
+
"@effect/platform-browser": "0.48.12",
|
|
56
62
|
"@opentelemetry/api": "^1.9.0",
|
|
57
|
-
"@types/node": "^22.
|
|
58
|
-
"@types/web": "^0.0.
|
|
59
|
-
"effect": "3.7
|
|
60
|
-
"vitest": "^2.
|
|
63
|
+
"@types/node": "^22.8.5",
|
|
64
|
+
"@types/web": "^0.0.175",
|
|
65
|
+
"effect": "3.10.7",
|
|
66
|
+
"vitest": "^2.1.4"
|
|
61
67
|
},
|
|
62
68
|
"publishConfig": {
|
|
63
69
|
"access": "public"
|
package/src/cuid/cuid.browser.ts
CHANGED
package/src/effect/Effect.ts
CHANGED
|
@@ -47,7 +47,8 @@ const getThreadName = () => {
|
|
|
47
47
|
const globalName = globalThis.name
|
|
48
48
|
return isNonEmptyString(globalName)
|
|
49
49
|
? globalName
|
|
50
|
-
:
|
|
50
|
+
: // eslint-disable-next-line unicorn/prefer-global-this
|
|
51
|
+
typeof window === 'object'
|
|
51
52
|
? 'Browser Main Thread'
|
|
52
53
|
: 'unknown-thread'
|
|
53
54
|
}
|
package/src/effect/Error.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { AST, Equivalence } from '@effect/schema'
|
|
1
|
+
import { Schema, SchemaAST } from 'effect'
|
|
3
2
|
|
|
4
3
|
export type DiffItem = {
|
|
5
4
|
path: string
|
|
6
5
|
a: any
|
|
7
6
|
b: any
|
|
8
|
-
ast:
|
|
7
|
+
ast: SchemaAST.AST
|
|
9
8
|
}
|
|
10
9
|
|
|
11
10
|
/**
|
|
@@ -19,12 +18,12 @@ export const debugDiff =
|
|
|
19
18
|
return bag
|
|
20
19
|
}
|
|
21
20
|
|
|
22
|
-
const debugDiffImpl = (ast:
|
|
23
|
-
const eq =
|
|
21
|
+
const debugDiffImpl = (ast: SchemaAST.AST, a: any, b: any, path: string, bag: DiffItem[]) => {
|
|
22
|
+
const eq = Schema.equivalence({ ast } as any)
|
|
24
23
|
if (eq(a, b) === false) {
|
|
25
24
|
// bag.push({ path, a, b, ast })
|
|
26
25
|
|
|
27
|
-
if (
|
|
26
|
+
if (SchemaAST.isUnion(ast)) {
|
|
28
27
|
if (isTaggedUnion(ast)) {
|
|
29
28
|
bag.push({ path, a, b, ast })
|
|
30
29
|
return
|
|
@@ -36,8 +35,8 @@ const debugDiffImpl = (ast: AST.AST, a: any, b: any, path: string, bag: DiffItem
|
|
|
36
35
|
} catch {}
|
|
37
36
|
}
|
|
38
37
|
}
|
|
39
|
-
} else if (
|
|
40
|
-
const props =
|
|
38
|
+
} else if (SchemaAST.isTypeLiteral(ast)) {
|
|
39
|
+
const props = SchemaAST.getPropertySignatures(ast)
|
|
41
40
|
for (const prop of props) {
|
|
42
41
|
debugDiffImpl(prop.type, a[prop.name], b[prop.name], `${path}.${prop.name.toString()}`, bag)
|
|
43
42
|
}
|
|
@@ -48,11 +47,11 @@ const debugDiffImpl = (ast: AST.AST, a: any, b: any, path: string, bag: DiffItem
|
|
|
48
47
|
}
|
|
49
48
|
}
|
|
50
49
|
|
|
51
|
-
const isTaggedUnion = (ast:
|
|
52
|
-
if (
|
|
50
|
+
const isTaggedUnion = (ast: SchemaAST.AST) => {
|
|
51
|
+
if (SchemaAST.isUnion(ast)) {
|
|
53
52
|
return ast.types.every((type) => {
|
|
54
|
-
if (
|
|
55
|
-
const props =
|
|
53
|
+
if (SchemaAST.isTypeLiteral(type) === false) return false
|
|
54
|
+
const props = SchemaAST.getPropertySignatures(type)
|
|
56
55
|
return props.some((prop) => prop.name.toString() === '_tag')
|
|
57
56
|
})
|
|
58
57
|
}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { Transferable } from '@effect/platform'
|
|
2
|
-
import { ParseResult, Schema } from '
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
5
|
-
import { Effect, Hash } from 'effect'
|
|
2
|
+
import { Effect, Hash, ParseResult, Schema } from 'effect'
|
|
3
|
+
import type { ParseError } from 'effect/ParseResult'
|
|
4
|
+
import type { ParseOptions } from 'effect/SchemaAST'
|
|
6
5
|
|
|
7
|
-
export * from '
|
|
6
|
+
export * from 'effect/Schema'
|
|
8
7
|
export * from './debug-diff.js'
|
|
9
8
|
export * from './msgpack.js'
|
|
10
9
|
|
|
@@ -42,3 +41,18 @@ export const swap = <A, I, R>(schema: Schema.Schema<A, I, R>): Schema.Schema<I,
|
|
|
42
41
|
})
|
|
43
42
|
|
|
44
43
|
export const Base64FromUint8Array: Schema.Schema<string, Uint8Array> = swap(Schema.Uint8ArrayFromBase64)
|
|
44
|
+
|
|
45
|
+
export interface JsonArray extends ReadonlyArray<JsonValue> {}
|
|
46
|
+
export interface JsonObject {
|
|
47
|
+
[key: string]: JsonValue
|
|
48
|
+
}
|
|
49
|
+
export type JsonValue = string | number | boolean | null | JsonObject | JsonArray
|
|
50
|
+
|
|
51
|
+
export const JsonValue: Schema.Schema<JsonValue> = Schema.Union(
|
|
52
|
+
Schema.String,
|
|
53
|
+
Schema.Number,
|
|
54
|
+
Schema.Boolean,
|
|
55
|
+
Schema.Null,
|
|
56
|
+
Schema.Array(Schema.suspend(() => JsonValue)),
|
|
57
|
+
Schema.Record({ key: Schema.String, value: Schema.suspend(() => JsonValue) }),
|
|
58
|
+
)
|
package/src/effect/WebChannel.ts
CHANGED
package/src/effect/index.ts
CHANGED
|
@@ -38,6 +38,7 @@ export {
|
|
|
38
38
|
HashMap,
|
|
39
39
|
HashSet,
|
|
40
40
|
MutableHashSet,
|
|
41
|
+
MutableHashMap,
|
|
41
42
|
Option,
|
|
42
43
|
LogLevel,
|
|
43
44
|
Logger,
|
|
@@ -47,6 +48,7 @@ export {
|
|
|
47
48
|
Channel,
|
|
48
49
|
pipe,
|
|
49
50
|
identity,
|
|
51
|
+
GlobalValue,
|
|
50
52
|
Match,
|
|
51
53
|
} from 'effect'
|
|
52
54
|
|
|
@@ -58,15 +60,10 @@ export * as SubscriptionRef from './SubscriptionRef.js'
|
|
|
58
60
|
|
|
59
61
|
export * as WebChannel from './WebChannel.js'
|
|
60
62
|
|
|
61
|
-
export
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
Equivalence as SchemaEquivalence,
|
|
66
|
-
Serializable,
|
|
67
|
-
JSONSchema,
|
|
68
|
-
ParseResult,
|
|
69
|
-
} from '@effect/schema'
|
|
63
|
+
export * as SchemaAST from 'effect/SchemaAST'
|
|
64
|
+
export { TreeFormatter } from 'effect/ParseResult'
|
|
65
|
+
export { ParseResult, Pretty } from 'effect'
|
|
66
|
+
export type { Serializable, SerializableWithResult } from 'effect/Schema'
|
|
70
67
|
export * as Schema from './Schema/index.js'
|
|
71
68
|
export * as OtelTracer from '@effect/opentelemetry/Tracer'
|
|
72
69
|
|
|
@@ -82,6 +79,7 @@ export {
|
|
|
82
79
|
HttpClientError,
|
|
83
80
|
HttpClientRequest,
|
|
84
81
|
HttpClientResponse,
|
|
82
|
+
FetchHttpClient,
|
|
85
83
|
} from '@effect/platform'
|
|
86
84
|
export { BrowserWorker, BrowserWorkerRunner } from '@effect/platform-browser'
|
|
87
85
|
|
package/src/index.ts
CHANGED
|
@@ -16,8 +16,6 @@ import type * as otel from '@opentelemetry/api'
|
|
|
16
16
|
|
|
17
17
|
import { objectToString } from './misc.js'
|
|
18
18
|
|
|
19
|
-
export * as dateFns from 'date-fns'
|
|
20
|
-
|
|
21
19
|
export type Prettify<T> = T extends infer U ? { [K in keyof U]: Prettify<U[K]> } : never
|
|
22
20
|
export type PrettifyFlat<T> = T extends infer U ? { [K in keyof U]: U[K] } : never
|
|
23
21
|
|
package/src/misc.ts
CHANGED
|
@@ -18,6 +18,7 @@ export const tryAsFunctionAndNew = <TArg, TResult>(
|
|
|
18
18
|
try {
|
|
19
19
|
// @ts-expect-error try out as constructor
|
|
20
20
|
return new fnOrConstructor(arg)
|
|
21
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
21
22
|
} catch (e) {
|
|
22
23
|
// @ts-expect-error try out as function
|
|
23
24
|
return fnOrConstructor(arg)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { nanoid } from 'nanoid'
|
package/src/string.ts
CHANGED
|
@@ -1,2 +1,9 @@
|
|
|
1
1
|
export const lowercaseFirstChar = (str: string) => str.charAt(0).toLowerCase() + str.slice(1)
|
|
2
2
|
export const uppercaseFirstChar = (str: string) => str.charAt(0).toUpperCase() + str.slice(1)
|
|
3
|
+
|
|
4
|
+
/** Indents a string each line by `n` characters (default: spaces) */
|
|
5
|
+
export const indent = (str: string, n: number, char = ' '): string =>
|
|
6
|
+
str
|
|
7
|
+
.split('\n')
|
|
8
|
+
.map((line) => char.repeat(n) + line)
|
|
9
|
+
.join('\n')
|
package/tsconfig.json
CHANGED