@pulse-js/react 0.1.2 → 0.1.4
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/README.md +29 -0
- package/dist/devtools.cjs +45 -0
- package/dist/devtools.d.cts +12 -0
- package/dist/devtools.d.ts +12 -0
- package/dist/devtools.js +19 -0
- package/package.json +16 -3
package/README.md
CHANGED
|
@@ -64,6 +64,35 @@ function ProtectedRoute() {
|
|
|
64
64
|
}
|
|
65
65
|
```
|
|
66
66
|
|
|
67
|
+
## Developer Tools
|
|
68
|
+
|
|
69
|
+
Pulse provides a dedicated inspector for debugging your reactive graph. In React applications, you can enable it with zero configuration.
|
|
70
|
+
|
|
71
|
+
### Auto-Injection (Recommended)
|
|
72
|
+
|
|
73
|
+
Simply import `@pulse-js/react/devtools` at the top of your main entry point (e.g., `main.tsx`). The inspector will automatically mount to the DOM only in development environments (`NODE_ENV === 'development'`).
|
|
74
|
+
|
|
75
|
+
```tsx
|
|
76
|
+
import "@pulse-js/react/devtools";
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### Manual Component
|
|
80
|
+
|
|
81
|
+
Alternatively, you can use the `PulseDevTools` component for more control:
|
|
82
|
+
|
|
83
|
+
```tsx
|
|
84
|
+
import { PulseDevTools } from "@pulse-js/react/devtools";
|
|
85
|
+
|
|
86
|
+
function App() {
|
|
87
|
+
return (
|
|
88
|
+
<>
|
|
89
|
+
<MyRoutes />
|
|
90
|
+
<PulseDevTools shortcut="Ctrl+D" />
|
|
91
|
+
</>
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
67
96
|
## API
|
|
68
97
|
|
|
69
98
|
### `usePulse<T>(unit: PulseUnit<T>): T | GuardState<T>`
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/devtools.tsx
|
|
21
|
+
var devtools_exports = {};
|
|
22
|
+
__export(devtools_exports, {
|
|
23
|
+
PulseDevTools: () => PulseDevTools
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(devtools_exports);
|
|
26
|
+
var import_tools = require("@pulse-js/tools");
|
|
27
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
28
|
+
var import_meta = {};
|
|
29
|
+
var isDev = typeof process !== "undefined" ? process.env.NODE_ENV === "development" : import_meta.env?.DEV || true;
|
|
30
|
+
if (isDev && typeof document !== "undefined") {
|
|
31
|
+
if (!document.querySelector("pulse-inspector")) {
|
|
32
|
+
const inspector = document.createElement("pulse-inspector");
|
|
33
|
+
document.body.appendChild(inspector);
|
|
34
|
+
console.log("\u{1F680} Pulse DevTools initialized");
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function PulseDevTools({ shortcut = "Ctrl+D" }) {
|
|
38
|
+
const PulseInspectorTag = "pulse-inspector";
|
|
39
|
+
if (!isDev) return null;
|
|
40
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PulseInspectorTag, { shortcut });
|
|
41
|
+
}
|
|
42
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
43
|
+
0 && (module.exports = {
|
|
44
|
+
PulseDevTools
|
|
45
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A React component wrapper for Pulse DevTools.
|
|
5
|
+
* Useful if you want to manually control where the inspector is mounted
|
|
6
|
+
* or pass specific props.
|
|
7
|
+
*/
|
|
8
|
+
declare function PulseDevTools({ shortcut }: {
|
|
9
|
+
shortcut?: string;
|
|
10
|
+
}): react_jsx_runtime.JSX.Element | null;
|
|
11
|
+
|
|
12
|
+
export { PulseDevTools };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A React component wrapper for Pulse DevTools.
|
|
5
|
+
* Useful if you want to manually control where the inspector is mounted
|
|
6
|
+
* or pass specific props.
|
|
7
|
+
*/
|
|
8
|
+
declare function PulseDevTools({ shortcut }: {
|
|
9
|
+
shortcut?: string;
|
|
10
|
+
}): react_jsx_runtime.JSX.Element | null;
|
|
11
|
+
|
|
12
|
+
export { PulseDevTools };
|
package/dist/devtools.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// src/devtools.tsx
|
|
2
|
+
import "@pulse-js/tools";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
var isDev = typeof process !== "undefined" ? process.env.NODE_ENV === "development" : import.meta.env?.DEV || true;
|
|
5
|
+
if (isDev && typeof document !== "undefined") {
|
|
6
|
+
if (!document.querySelector("pulse-inspector")) {
|
|
7
|
+
const inspector = document.createElement("pulse-inspector");
|
|
8
|
+
document.body.appendChild(inspector);
|
|
9
|
+
console.log("\u{1F680} Pulse DevTools initialized");
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
function PulseDevTools({ shortcut = "Ctrl+D" }) {
|
|
13
|
+
const PulseInspectorTag = "pulse-inspector";
|
|
14
|
+
if (!isDev) return null;
|
|
15
|
+
return /* @__PURE__ */ jsx(PulseInspectorTag, { shortcut });
|
|
16
|
+
}
|
|
17
|
+
export {
|
|
18
|
+
PulseDevTools
|
|
19
|
+
};
|
package/package.json
CHANGED
|
@@ -1,22 +1,35 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pulse-js/react",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"require": "./dist/index.cjs"
|
|
13
|
+
},
|
|
14
|
+
"./devtools": {
|
|
15
|
+
"types": "./dist/devtools.d.ts",
|
|
16
|
+
"import": "./dist/devtools.js",
|
|
17
|
+
"require": "./dist/devtools.cjs"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
8
20
|
"files": [
|
|
9
21
|
"dist"
|
|
10
22
|
],
|
|
11
23
|
"scripts": {
|
|
12
|
-
"build": "bun x tsup src/index.ts --format esm,cjs --dts --clean --external react",
|
|
24
|
+
"build": "bun x tsup src/index.ts src/devtools.tsx --format esm,cjs --dts --clean --external react,@pulse-js/core,@pulse-js/tools",
|
|
13
25
|
"lint": "bun x tsc --noEmit"
|
|
14
26
|
},
|
|
15
27
|
"peerDependencies": {
|
|
16
28
|
"react": "^19.2.3"
|
|
17
29
|
},
|
|
18
30
|
"dependencies": {
|
|
19
|
-
"@pulse-js/core": "^0.1.
|
|
31
|
+
"@pulse-js/core": "^0.1.7",
|
|
32
|
+
"@pulse-js/tools": "^0.1.4"
|
|
20
33
|
},
|
|
21
34
|
"devDependencies": {
|
|
22
35
|
"@types/bun": "latest",
|