@oh-my-ghaad/react 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/dist/index.cjs ADDED
@@ -0,0 +1,46 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/index.ts
20
+ var index_exports = {};
21
+ __export(index_exports, {
22
+ useGHaaD: () => useGHaaD
23
+ });
24
+ module.exports = __toCommonJS(index_exports);
25
+ var import_react = require("react");
26
+ function useGHaaD(engine, subscription) {
27
+ const [state, setState] = (0, import_react.useState)({
28
+ engine,
29
+ repoStatus: "unknown",
30
+ lastUpdated: Date.now()
31
+ });
32
+ (0, import_react.useEffect)(() => {
33
+ const subscriptionWrapper = (collections) => {
34
+ setState({ engine, lastUpdated: Date.now() });
35
+ };
36
+ engine.subscribe(subscriptionWrapper);
37
+ return () => {
38
+ engine.unsubscribe(subscriptionWrapper);
39
+ };
40
+ }, []);
41
+ return state;
42
+ }
43
+ // Annotate the CommonJS export names for ESM import in node:
44
+ 0 && (module.exports = {
45
+ useGHaaD
46
+ });
@@ -0,0 +1,9 @@
1
+ import { Engine, Subscription, RepoStatus } from '@oh-my-ghaad/core';
2
+
3
+ interface GHaaDReturnValue {
4
+ engine: Engine;
5
+ repoStatus: RepoStatus;
6
+ }
7
+ declare function useGHaaD(engine: Engine, subscription?: Subscription): GHaaDReturnValue;
8
+
9
+ export { useGHaaD };
@@ -0,0 +1,9 @@
1
+ import { Engine, Subscription, RepoStatus } from '@oh-my-ghaad/core';
2
+
3
+ interface GHaaDReturnValue {
4
+ engine: Engine;
5
+ repoStatus: RepoStatus;
6
+ }
7
+ declare function useGHaaD(engine: Engine, subscription?: Subscription): GHaaDReturnValue;
8
+
9
+ export { useGHaaD };
package/dist/index.js ADDED
@@ -0,0 +1,22 @@
1
+ // src/index.ts
2
+ import { useEffect, useState } from "react";
3
+ function useGHaaD(engine, subscription) {
4
+ const [state, setState] = useState({
5
+ engine,
6
+ repoStatus: "unknown",
7
+ lastUpdated: Date.now()
8
+ });
9
+ useEffect(() => {
10
+ const subscriptionWrapper = (collections) => {
11
+ setState({ engine, lastUpdated: Date.now() });
12
+ };
13
+ engine.subscribe(subscriptionWrapper);
14
+ return () => {
15
+ engine.unsubscribe(subscriptionWrapper);
16
+ };
17
+ }, []);
18
+ return state;
19
+ }
20
+ export {
21
+ useGHaaD
22
+ };
package/package.json ADDED
@@ -0,0 +1,25 @@
1
+ {
2
+ "name": "@oh-my-ghaad/react",
3
+ "version": "0.0.1",
4
+ "description": "",
5
+ "main": "dist/index.js",
6
+ "type": "module",
7
+ "types": "dist/index.d.ts",
8
+ "keywords": [],
9
+ "author": "",
10
+ "license": "MIT",
11
+ "devDependencies": {
12
+ "react": "^19.0.0",
13
+ "tsup": "^8.5.0",
14
+ "typescript": "5.8.2"
15
+ },
16
+ "peerDependencies": {
17
+ "react": ">= 18.0.0",
18
+ "@oh-my-ghaad/core": "0.0.1"
19
+ },
20
+ "scripts": {
21
+ "dev": "tsup src/index.ts --watch --dts --format esm,cjs",
22
+ "build": "tsup src/index.ts --dts --format esm,cjs",
23
+ "test": "echo \"Error: no test specified\" && exit 1"
24
+ }
25
+ }
package/src/index.ts ADDED
@@ -0,0 +1,37 @@
1
+ import { useEffect, useState } from "react";
2
+ import {
3
+ Collection,
4
+ Engine,
5
+ Subscription,
6
+ RepoStatus,
7
+ } from "@oh-my-ghaad/core";
8
+
9
+ interface GHaaDReturnValue {
10
+ engine: Engine;
11
+ repoStatus: RepoStatus;
12
+ }
13
+
14
+ export function useGHaaD(
15
+ engine: Engine,
16
+ subscription?: Subscription
17
+ ): GHaaDReturnValue {
18
+ const [state, setState] = useState<GHaaDReturnValue>({
19
+ engine,
20
+ repoStatus: "unknown",
21
+ lastUpdated: Date.now(),
22
+ });
23
+
24
+ useEffect(() => {
25
+ const subscriptionWrapper = (collections) => {
26
+ setState({ engine, lastUpdated: Date.now() });
27
+ };
28
+
29
+ engine.subscribe(subscriptionWrapper);
30
+
31
+ return () => {
32
+ engine.unsubscribe(subscriptionWrapper);
33
+ };
34
+ }, []);
35
+
36
+ return state;
37
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,7 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ESNext",
4
+ "module": "ESNext",
5
+ "moduleResolution": "node",
6
+ }
7
+ }