@reckona/mreact-devtools 0.0.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/LICENSE +21 -0
- package/README.md +29 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +43 -0
- package/dist/index.js.map +1 -0
- package/package.json +41 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Tatsuo Kaniwa
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# @reckona/mreact-devtools
|
|
2
|
+
|
|
3
|
+
`@reckona/mreact-devtools` provides a small event bridge for runtime tooling.
|
|
4
|
+
Reactive runtime packages can emit structured events, and developer tools can
|
|
5
|
+
subscribe without coupling directly to internal runtime state.
|
|
6
|
+
|
|
7
|
+
## Basic Usage
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
import { createDevtools, installDevtools } from "@reckona/mreact-devtools";
|
|
11
|
+
|
|
12
|
+
const devtools = installDevtools(createDevtools());
|
|
13
|
+
|
|
14
|
+
const unsubscribe = devtools.subscribe((event) => {
|
|
15
|
+
console.log(event.type, event.payload);
|
|
16
|
+
});
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Core APIs
|
|
20
|
+
|
|
21
|
+
- `createDevtools()` creates an isolated event bus.
|
|
22
|
+
- `installDevtools()` installs a devtools instance on `globalThis`.
|
|
23
|
+
- `getInstalledDevtools()` returns the currently installed instance.
|
|
24
|
+
- `devtools.emit()` and `devtools.subscribe()` move runtime events.
|
|
25
|
+
|
|
26
|
+
## Notes
|
|
27
|
+
|
|
28
|
+
This package is intentionally small. It is the transport layer for devtools
|
|
29
|
+
integrations, not a browser extension UI.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export interface DevtoolsEvent {
|
|
2
|
+
package: string;
|
|
3
|
+
timestamp?: number;
|
|
4
|
+
type: string;
|
|
5
|
+
[key: string]: unknown;
|
|
6
|
+
}
|
|
7
|
+
export type DevtoolsListener = (event: DevtoolsEvent) => void;
|
|
8
|
+
export interface Devtools {
|
|
9
|
+
dispose(): void;
|
|
10
|
+
emit(event: DevtoolsEvent): void;
|
|
11
|
+
events(): DevtoolsEvent[];
|
|
12
|
+
subscribe(listener: DevtoolsListener): () => void;
|
|
13
|
+
}
|
|
14
|
+
declare global {
|
|
15
|
+
var __mreactDevtools: Devtools | undefined;
|
|
16
|
+
}
|
|
17
|
+
export declare function createDevtools(): Devtools;
|
|
18
|
+
export declare function installDevtools(devtools?: Devtools): Devtools;
|
|
19
|
+
export declare function getInstalledDevtools(): Devtools | undefined;
|
|
20
|
+
export declare function emitMreactDevtoolsEvent(packageName: string, event: {
|
|
21
|
+
type: string;
|
|
22
|
+
} & Record<string, unknown>): void;
|
|
23
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,MAAM,MAAM,gBAAgB,GAAG,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;AAE9D,MAAM,WAAW,QAAQ;IACvB,OAAO,IAAI,IAAI,CAAC;IAChB,IAAI,CAAC,KAAK,EAAE,aAAa,GAAG,IAAI,CAAC;IACjC,MAAM,IAAI,aAAa,EAAE,CAAC;IAC1B,SAAS,CAAC,QAAQ,EAAE,gBAAgB,GAAG,MAAM,IAAI,CAAC;CACnD;AAED,OAAO,CAAC,MAAM,CAAC;IAEb,IAAI,gBAAgB,EAAE,QAAQ,GAAG,SAAS,CAAC;CAC5C;AAED,wBAAgB,cAAc,IAAI,QAAQ,CA8BzC;AAED,wBAAgB,eAAe,CAAC,QAAQ,GAAE,QAA2B,GAAG,QAAQ,CAI/E;AAED,wBAAgB,oBAAoB,IAAI,QAAQ,GAAG,SAAS,CAE3D;AAED,wBAAgB,uBAAuB,CACrC,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAChD,IAAI,CAMN"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export function createDevtools() {
|
|
2
|
+
const recorded = [];
|
|
3
|
+
const listeners = new Set();
|
|
4
|
+
return {
|
|
5
|
+
dispose() {
|
|
6
|
+
listeners.clear();
|
|
7
|
+
recorded.length = 0;
|
|
8
|
+
if (globalThis.__mreactDevtools === this) {
|
|
9
|
+
globalThis.__mreactDevtools = undefined;
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
emit(event) {
|
|
13
|
+
recorded.push(event);
|
|
14
|
+
for (const listener of Array.from(listeners)) {
|
|
15
|
+
listener(event);
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
events() {
|
|
19
|
+
return [...recorded];
|
|
20
|
+
},
|
|
21
|
+
subscribe(listener) {
|
|
22
|
+
listeners.add(listener);
|
|
23
|
+
return () => {
|
|
24
|
+
listeners.delete(listener);
|
|
25
|
+
};
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
export function installDevtools(devtools = createDevtools()) {
|
|
30
|
+
globalThis.__mreactDevtools = devtools;
|
|
31
|
+
return devtools;
|
|
32
|
+
}
|
|
33
|
+
export function getInstalledDevtools() {
|
|
34
|
+
return globalThis.__mreactDevtools;
|
|
35
|
+
}
|
|
36
|
+
export function emitMreactDevtoolsEvent(packageName, event) {
|
|
37
|
+
globalThis.__mreactDevtools?.emit?.({
|
|
38
|
+
package: packageName,
|
|
39
|
+
timestamp: Date.now(),
|
|
40
|
+
...event,
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAqBA,MAAM,UAAU,cAAc;IAC5B,MAAM,QAAQ,GAAoB,EAAE,CAAC;IACrC,MAAM,SAAS,GAAG,IAAI,GAAG,EAAoB,CAAC;IAE9C,OAAO;QACL,OAAO;YACL,SAAS,CAAC,KAAK,EAAE,CAAC;YAClB,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC;YACpB,IAAI,UAAU,CAAC,gBAAgB,KAAK,IAAI,EAAE,CAAC;gBACzC,UAAU,CAAC,gBAAgB,GAAG,SAAS,CAAC;YAC1C,CAAC;QACH,CAAC;QACD,IAAI,CAAC,KAAK;YACR,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YAErB,KAAK,MAAM,QAAQ,IAAI,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC;gBAC7C,QAAQ,CAAC,KAAK,CAAC,CAAC;YAClB,CAAC;QACH,CAAC;QACD,MAAM;YACJ,OAAO,CAAC,GAAG,QAAQ,CAAC,CAAC;QACvB,CAAC;QACD,SAAS,CAAC,QAAQ;YAChB,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;YAExB,OAAO,GAAG,EAAE;gBACV,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YAC7B,CAAC,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,WAAqB,cAAc,EAAE;IACnE,UAAU,CAAC,gBAAgB,GAAG,QAAQ,CAAC;IAEvC,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,MAAM,UAAU,oBAAoB;IAClC,OAAO,UAAU,CAAC,gBAAgB,CAAC;AACrC,CAAC;AAED,MAAM,UAAU,uBAAuB,CACrC,WAAmB,EACnB,KAAiD;IAEjD,UAAU,CAAC,gBAAgB,EAAE,IAAI,EAAE,CAAC;QAClC,OAAO,EAAE,WAAW;QACpB,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;QACrB,GAAG,KAAK;KACT,CAAC,CAAC;AACL,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@reckona/mreact-devtools",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Runtime event bridge for mreact developer tooling.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"debugging",
|
|
7
|
+
"devtools",
|
|
8
|
+
"events",
|
|
9
|
+
"jsx",
|
|
10
|
+
"mreact",
|
|
11
|
+
"typescript"
|
|
12
|
+
],
|
|
13
|
+
"homepage": "https://github.com/t-k/mreact/tree/main/packages/devtools#readme",
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/t-k/mreact/issues"
|
|
16
|
+
},
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "https://github.com/t-k/mreact.git",
|
|
21
|
+
"directory": "packages/devtools"
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"dist/**/*.js",
|
|
25
|
+
"dist/**/*.js.map",
|
|
26
|
+
"dist/**/*.d.ts",
|
|
27
|
+
"dist/**/*.d.ts.map"
|
|
28
|
+
],
|
|
29
|
+
"type": "module",
|
|
30
|
+
"sideEffects": false,
|
|
31
|
+
"types": "./dist/index.d.ts",
|
|
32
|
+
"exports": {
|
|
33
|
+
".": {
|
|
34
|
+
"types": "./dist/index.d.ts",
|
|
35
|
+
"default": "./dist/index.js"
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"publishConfig": {
|
|
39
|
+
"access": "public"
|
|
40
|
+
}
|
|
41
|
+
}
|