@kfiross44/valtio-inspector 0.9.0 → 0.9.1
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/.changeset/config.json +1 -1
- package/dist/attachInspector.d.ts +1 -9
- package/dist/attachInspector.d.ts.map +1 -1
- package/dist/attachInspector.js +3 -9
- package/dist/attachInspector.js.map +1 -1
- package/kfiross44-valtio-inspector-0.9.0.tgz +0 -0
- package/package.json +3 -3
- package/src/attachInspector.ts +7 -3
- package/kfiross44-valtio-inspector-1.0.0.tgz +0 -0
package/.changeset/config.json
CHANGED
|
@@ -6,14 +6,6 @@ type AttachOptions = {
|
|
|
6
6
|
/** Custom inspector URL (default: http://localhost:7777) */
|
|
7
7
|
inspectorUrl?: string;
|
|
8
8
|
};
|
|
9
|
-
|
|
10
|
-
* Attach a Valtio proxy store to the inspector.
|
|
11
|
-
*
|
|
12
|
-
* Usage:
|
|
13
|
-
* attachInspector(myStore, { name: 'auth' })
|
|
14
|
-
*
|
|
15
|
-
* ⚠️ Wrap in process.env.NODE_ENV !== 'production' to exclude from builds.
|
|
16
|
-
*/
|
|
17
|
-
export declare function attachInspector(state: object, options: AttachOptions): () => void;
|
|
9
|
+
export declare function attachInspector<T extends object>(state: T, options: AttachOptions): () => void;
|
|
18
10
|
export {};
|
|
19
11
|
//# sourceMappingURL=attachInspector.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attachInspector.d.ts","sourceRoot":"","sources":["../src/attachInspector.ts"],"names":[],"mappings":"AAEA,KAAK,aAAa,GAAG;IACnB,mDAAmD;IACnD,IAAI,EAAE,MAAM,CAAA;IACZ,0CAA0C;IAC1C,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,4DAA4D;IAC5D,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB,CAAA;
|
|
1
|
+
{"version":3,"file":"attachInspector.d.ts","sourceRoot":"","sources":["../src/attachInspector.ts"],"names":[],"mappings":"AAEA,KAAK,aAAa,GAAG;IACnB,mDAAmD;IACnD,IAAI,EAAE,MAAM,CAAA;IACZ,0CAA0C;IAC1C,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,4DAA4D;IAC5D,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB,CAAA;AAYD,wBAAgB,eAAe,CAAC,CAAC,SAAS,MAAM,EAC9C,KAAK,EAAE,CAAC,EACR,OAAO,EAAE,aAAa,GACrB,MAAM,IAAI,CAqFZ"}
|
package/dist/attachInspector.js
CHANGED
|
@@ -2,21 +2,15 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.attachInspector = attachInspector;
|
|
4
4
|
const valtio_1 = require("valtio");
|
|
5
|
-
/**
|
|
6
|
-
* Attach a Valtio proxy store to the inspector.
|
|
7
|
-
*
|
|
8
|
-
* Usage:
|
|
9
|
-
* attachInspector(myStore, { name: 'auth' })
|
|
10
|
-
*
|
|
11
|
-
* ⚠️ Wrap in process.env.NODE_ENV !== 'production' to exclude from builds.
|
|
12
|
-
*/
|
|
13
5
|
function attachInspector(state, options) {
|
|
14
6
|
if (typeof window === 'undefined' && typeof process !== 'undefined') {
|
|
15
7
|
// Node.js / SSR — skip silently
|
|
16
8
|
return () => { };
|
|
17
9
|
}
|
|
18
10
|
const { name, debounce = 100, inspectorUrl = 'http://localhost:7777' } = options;
|
|
19
|
-
const wsUrl = inspectorUrl.
|
|
11
|
+
const wsUrl = inspectorUrl.startsWith('https')
|
|
12
|
+
? inspectorUrl.replace('https', 'wss')
|
|
13
|
+
: inspectorUrl.replace('http', 'ws');
|
|
20
14
|
let timeout = null;
|
|
21
15
|
let ws = null;
|
|
22
16
|
let reconnectAttempts = 0;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attachInspector.js","sourceRoot":"","sources":["../src/attachInspector.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"attachInspector.js","sourceRoot":"","sources":["../src/attachInsp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;IACb,CAAC,CAAA;AACH,CAAC"}
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kfiross44/valtio-inspector",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.1",
|
|
4
4
|
"description": "A dev-only Valtio state inspector with WebSocket live updates",
|
|
5
5
|
"main": "dist/server/index.js",
|
|
6
6
|
"bin": {
|
|
7
7
|
"valtio-inspector": "dist/cli.js"
|
|
8
8
|
},
|
|
9
9
|
"scripts": {
|
|
10
|
-
"dev": "ts-node
|
|
10
|
+
"dev": "ts-node src/cli.ts",
|
|
11
11
|
"build": "tsc",
|
|
12
|
-
"release": "bun run build && changeset publish",
|
|
12
|
+
"release": "bun run build && changeset publish --access public",
|
|
13
13
|
"start": "node dist/server/index.js"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
package/src/attachInspector.ts
CHANGED
|
@@ -17,8 +17,10 @@ type AttachOptions = {
|
|
|
17
17
|
*
|
|
18
18
|
* ⚠️ Wrap in process.env.NODE_ENV !== 'production' to exclude from builds.
|
|
19
19
|
*/
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
import type { Snapshot } from 'valtio'
|
|
21
|
+
|
|
22
|
+
export function attachInspector<T extends object>(
|
|
23
|
+
state: T,
|
|
22
24
|
options: AttachOptions
|
|
23
25
|
): () => void {
|
|
24
26
|
if (typeof window === 'undefined' && typeof process !== 'undefined') {
|
|
@@ -32,7 +34,9 @@ export function attachInspector(
|
|
|
32
34
|
inspectorUrl = 'http://localhost:7777'
|
|
33
35
|
} = options
|
|
34
36
|
|
|
35
|
-
const wsUrl = inspectorUrl.
|
|
37
|
+
const wsUrl = inspectorUrl.startsWith('https')
|
|
38
|
+
? inspectorUrl.replace('https', 'wss')
|
|
39
|
+
: inspectorUrl.replace('http', 'ws')
|
|
36
40
|
|
|
37
41
|
let timeout: ReturnType<typeof setTimeout> | null = null
|
|
38
42
|
let ws: WebSocket | null = null
|
|
Binary file
|