@fluxstack/live-client 0.6.0 → 0.7.0
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/index.cjs +27 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +27 -2
- package/dist/index.js.map +1 -1
- package/dist/live-client.browser.global.js +27 -3
- package/dist/live-client.browser.global.js.map +1 -1
- package/package.json +49 -49
- package/src/component.ts +22 -1
- package/src/rooms.ts +22 -1
package/package.json
CHANGED
|
@@ -1,49 +1,49 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@fluxstack/live-client",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Browser WebSocket client for @fluxstack/live — connection, state sync, rooms, and file upload (framework-agnostic)",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"main": "./dist/index.cjs",
|
|
7
|
-
"module": "./dist/index.js",
|
|
8
|
-
"types": "./dist/index.d.ts",
|
|
9
|
-
"sideEffects": false,
|
|
10
|
-
"exports": {
|
|
11
|
-
".": {
|
|
12
|
-
"types": "./dist/index.d.ts",
|
|
13
|
-
"bun": "./src/index.ts",
|
|
14
|
-
"import": "./dist/index.js",
|
|
15
|
-
"require": "./dist/index.cjs"
|
|
16
|
-
},
|
|
17
|
-
"./browser": "./dist/live-client.browser.global.js"
|
|
18
|
-
},
|
|
19
|
-
"files": [
|
|
20
|
-
"dist",
|
|
21
|
-
"src"
|
|
22
|
-
],
|
|
23
|
-
"scripts": {
|
|
24
|
-
"build": "tsup",
|
|
25
|
-
"dev": "tsup --watch",
|
|
26
|
-
"clean": "rm -rf dist",
|
|
27
|
-
"typecheck": "tsc --noEmit"
|
|
28
|
-
},
|
|
29
|
-
"dependencies": {
|
|
30
|
-
"@fluxstack/live": "^0.
|
|
31
|
-
},
|
|
32
|
-
"devDependencies": {
|
|
33
|
-
"tsup": "^8.4.0",
|
|
34
|
-
"typescript": "^5.8.3"
|
|
35
|
-
},
|
|
36
|
-
"publishConfig": {
|
|
37
|
-
"access": "public"
|
|
38
|
-
},
|
|
39
|
-
"repository": {
|
|
40
|
-
"type": "git",
|
|
41
|
-
"url": "https://github.com/FluxStackCore/fluxstack-live",
|
|
42
|
-
"directory": "packages/client"
|
|
43
|
-
},
|
|
44
|
-
"license": "MIT",
|
|
45
|
-
"keywords": ["websocket", "client", "realtime", "state-sync", "live-components", "fluxstack"],
|
|
46
|
-
"engines": {
|
|
47
|
-
"node": ">=18.0.0"
|
|
48
|
-
}
|
|
49
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@fluxstack/live-client",
|
|
3
|
+
"version": "0.7.0",
|
|
4
|
+
"description": "Browser WebSocket client for @fluxstack/live — connection, state sync, rooms, and file upload (framework-agnostic)",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.cjs",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"sideEffects": false,
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"bun": "./src/index.ts",
|
|
14
|
+
"import": "./dist/index.js",
|
|
15
|
+
"require": "./dist/index.cjs"
|
|
16
|
+
},
|
|
17
|
+
"./browser": "./dist/live-client.browser.global.js"
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"dist",
|
|
21
|
+
"src"
|
|
22
|
+
],
|
|
23
|
+
"scripts": {
|
|
24
|
+
"build": "tsup",
|
|
25
|
+
"dev": "tsup --watch",
|
|
26
|
+
"clean": "rm -rf dist",
|
|
27
|
+
"typecheck": "tsc --noEmit"
|
|
28
|
+
},
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"@fluxstack/live": "^0.7.0"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"tsup": "^8.4.0",
|
|
34
|
+
"typescript": "^5.8.3"
|
|
35
|
+
},
|
|
36
|
+
"publishConfig": {
|
|
37
|
+
"access": "public"
|
|
38
|
+
},
|
|
39
|
+
"repository": {
|
|
40
|
+
"type": "git",
|
|
41
|
+
"url": "https://github.com/FluxStackCore/fluxstack-live",
|
|
42
|
+
"directory": "packages/client"
|
|
43
|
+
},
|
|
44
|
+
"license": "MIT",
|
|
45
|
+
"keywords": ["websocket", "client", "realtime", "state-sync", "live-components", "fluxstack"],
|
|
46
|
+
"engines": {
|
|
47
|
+
"node": ">=18.0.0"
|
|
48
|
+
}
|
|
49
|
+
}
|
package/src/component.ts
CHANGED
|
@@ -20,7 +20,19 @@ function isPlainObject(v: unknown): v is Record<string, any> {
|
|
|
20
20
|
&& Object.getPrototypeOf(v) === Object.prototype
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
/**
|
|
24
|
+
* Apply a STATE_DELTA coming from the server (component state).
|
|
25
|
+
*
|
|
26
|
+
* Semantics (matches core's `deepAssign`, fixes #6):
|
|
27
|
+
* - Top-level `null` is a real value (set to null).
|
|
28
|
+
* - Nested `null` is the deletion sentinel from `computeDeepDiff`.
|
|
29
|
+
* - `undefined` is skipped — it never crosses the wire.
|
|
30
|
+
*/
|
|
23
31
|
function deepMerge<T extends Record<string, any>>(target: T, source: Partial<T>, seen?: Set<object>): T {
|
|
32
|
+
return deepMergeImpl(target, source, 0, seen)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function deepMergeImpl<T extends Record<string, any>>(target: T, source: Partial<T>, depth: number, seen?: Set<object>): T {
|
|
24
36
|
if (!seen) seen = new Set()
|
|
25
37
|
if (seen.has(source as object)) return target
|
|
26
38
|
seen.add(source as object)
|
|
@@ -28,9 +40,18 @@ function deepMerge<T extends Record<string, any>>(target: T, source: Partial<T>,
|
|
|
28
40
|
const result = { ...target }
|
|
29
41
|
for (const key of Object.keys(source) as Array<keyof T>) {
|
|
30
42
|
const newVal = source[key]
|
|
43
|
+
if (newVal === undefined) continue
|
|
44
|
+
if (newVal === null) {
|
|
45
|
+
if (depth === 0) {
|
|
46
|
+
result[key] = null as T[keyof T]
|
|
47
|
+
} else {
|
|
48
|
+
delete result[key]
|
|
49
|
+
}
|
|
50
|
+
continue
|
|
51
|
+
}
|
|
31
52
|
const oldVal = result[key]
|
|
32
53
|
if (isPlainObject(oldVal) && isPlainObject(newVal)) {
|
|
33
|
-
result[key] =
|
|
54
|
+
result[key] = deepMergeImpl(oldVal as any, newVal as any, depth + 1, seen) as T[keyof T]
|
|
34
55
|
} else {
|
|
35
56
|
result[key] = newVal as T[keyof T]
|
|
36
57
|
}
|
package/src/rooms.ts
CHANGED
|
@@ -10,7 +10,19 @@ function isPlainObject(v: unknown): v is Record<string, any> {
|
|
|
10
10
|
&& Object.getPrototypeOf(v) === Object.prototype
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
+
/**
|
|
14
|
+
* Apply a room STATE_DELTA coming from the server.
|
|
15
|
+
*
|
|
16
|
+
* Semantics (matches core's `deepAssign`, fixes #6):
|
|
17
|
+
* - Top-level `null` is a real value (set to null).
|
|
18
|
+
* - Nested `null` is the deletion sentinel from `computeDeepDiff`.
|
|
19
|
+
* - `undefined` is skipped — it never crosses the wire.
|
|
20
|
+
*/
|
|
13
21
|
function deepMerge<T extends Record<string, any>>(target: T, source: Partial<T>, seen?: Set<object>): T {
|
|
22
|
+
return deepMergeImpl(target, source, 0, seen)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function deepMergeImpl<T extends Record<string, any>>(target: T, source: Partial<T>, depth: number, seen?: Set<object>): T {
|
|
14
26
|
if (!seen) seen = new Set()
|
|
15
27
|
if (seen.has(source as object)) return target
|
|
16
28
|
seen.add(source as object)
|
|
@@ -18,9 +30,18 @@ function deepMerge<T extends Record<string, any>>(target: T, source: Partial<T>,
|
|
|
18
30
|
const result = { ...target }
|
|
19
31
|
for (const key of Object.keys(source) as Array<keyof T>) {
|
|
20
32
|
const newVal = source[key]
|
|
33
|
+
if (newVal === undefined) continue
|
|
34
|
+
if (newVal === null) {
|
|
35
|
+
if (depth === 0) {
|
|
36
|
+
result[key] = null as T[keyof T]
|
|
37
|
+
} else {
|
|
38
|
+
delete result[key]
|
|
39
|
+
}
|
|
40
|
+
continue
|
|
41
|
+
}
|
|
21
42
|
const oldVal = result[key]
|
|
22
43
|
if (isPlainObject(oldVal) && isPlainObject(newVal)) {
|
|
23
|
-
result[key] =
|
|
44
|
+
result[key] = deepMergeImpl(oldVal as any, newVal as any, depth + 1, seen) as T[keyof T]
|
|
24
45
|
} else {
|
|
25
46
|
result[key] = newVal as T[keyof T]
|
|
26
47
|
}
|