@mearie/react 0.0.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/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ MIT License
2
+
3
+ Copyright 2025 Bae Junehyeon
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ 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, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/dist/index.cjs ADDED
@@ -0,0 +1,86 @@
1
+ //#region rolldown:runtime
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
+ key = keys[i];
11
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
+ get: ((k) => from[k]).bind(null, key),
13
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
14
+ });
15
+ }
16
+ return to;
17
+ };
18
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
19
+ value: mod,
20
+ enumerable: true
21
+ }) : target, mod));
22
+
23
+ //#endregion
24
+ let react = require("react");
25
+ react = __toESM(react);
26
+ let react_jsx_runtime = require("react/jsx-runtime");
27
+ react_jsx_runtime = __toESM(react_jsx_runtime);
28
+
29
+ //#region src/client-provider.tsx
30
+ const ClientContext = (0, react.createContext)(null);
31
+ const ClientProvider = ({ client, children }) => {
32
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ClientContext.Provider, {
33
+ value: client,
34
+ children
35
+ });
36
+ };
37
+ const useClient = () => {
38
+ const client = (0, react.useContext)(ClientContext);
39
+ if (!client) throw new Error("useClient must be used within ClientProvider");
40
+ return client;
41
+ };
42
+
43
+ //#endregion
44
+ //#region src/use-query.ts
45
+ const useQuery = (document, variables) => {
46
+ return {
47
+ data: void 0,
48
+ loading: true,
49
+ error: void 0,
50
+ refetch: () => {}
51
+ };
52
+ };
53
+
54
+ //#endregion
55
+ //#region src/use-subscription.ts
56
+ const useSubscription = (document, variables, options) => {
57
+ return {
58
+ data: void 0,
59
+ loading: true,
60
+ error: void 0
61
+ };
62
+ };
63
+
64
+ //#endregion
65
+ //#region src/use-mutation.ts
66
+ const useMutation = (document) => {
67
+ return [async () => ({}), {
68
+ data: void 0,
69
+ loading: false,
70
+ error: void 0
71
+ }];
72
+ };
73
+
74
+ //#endregion
75
+ //#region src/use-fragment.ts
76
+ const useFragment = (document, fragmentRef) => {
77
+ return {};
78
+ };
79
+
80
+ //#endregion
81
+ exports.ClientProvider = ClientProvider;
82
+ exports.useClient = useClient;
83
+ exports.useFragment = useFragment;
84
+ exports.useMutation = useMutation;
85
+ exports.useQuery = useQuery;
86
+ exports.useSubscription = useSubscription;
@@ -0,0 +1,75 @@
1
+ import { ReactNode } from "react";
2
+ import { Client, DataOf, DocumentNode, FragmentRef, VariablesOf } from "@mearie/core";
3
+
4
+ //#region src/client-provider.d.ts
5
+ type ClientProviderProps = {
6
+ client: Client;
7
+ children: ReactNode;
8
+ };
9
+ declare const ClientProvider: ({
10
+ client,
11
+ children
12
+ }: ClientProviderProps) => ReactNode;
13
+ declare const useClient: () => Client;
14
+ //#endregion
15
+ //#region src/use-query.d.ts
16
+ type UseQueryReturn<Document$1 extends DocumentNode> = {
17
+ data: undefined;
18
+ loading: true;
19
+ error: undefined;
20
+ refetch: () => void;
21
+ } | {
22
+ data: DataOf<Document$1>;
23
+ loading: false;
24
+ error: undefined;
25
+ refetch: () => void;
26
+ } | {
27
+ data: DataOf<Document$1> | undefined;
28
+ loading: false;
29
+ error: Error;
30
+ refetch: () => void;
31
+ };
32
+ declare const useQuery: <Document extends DocumentNode>(document: Document, variables: VariablesOf<Document>) => UseQueryReturn<Document>;
33
+ //#endregion
34
+ //#region src/use-subscription.d.ts
35
+ type UseSubscriptionReturn<Document$1 extends DocumentNode> = {
36
+ data: undefined;
37
+ loading: true;
38
+ error: undefined;
39
+ } | {
40
+ data: DataOf<Document$1>;
41
+ loading: false;
42
+ error: undefined;
43
+ } | {
44
+ data: DataOf<Document$1> | undefined;
45
+ loading: false;
46
+ error: Error;
47
+ };
48
+ type UseSubscriptionOptions<Document$1 extends DocumentNode> = {
49
+ onData?: (data: DataOf<Document$1>) => void;
50
+ onError?: (error: Error) => void;
51
+ };
52
+ declare const useSubscription: <Document extends DocumentNode>(document: Document, variables: VariablesOf<Document>, options?: UseSubscriptionOptions<Document>) => UseSubscriptionReturn<Document>;
53
+ //#endregion
54
+ //#region src/use-mutation.d.ts
55
+ type UseMutationResult<Document$1 extends DocumentNode> = {
56
+ data: undefined;
57
+ loading: true;
58
+ error: undefined;
59
+ } | {
60
+ data: DataOf<Document$1>;
61
+ loading: false;
62
+ error: undefined;
63
+ } | {
64
+ data: DataOf<Document$1> | undefined;
65
+ loading: false;
66
+ error: Error;
67
+ };
68
+ type UseMutationReturn<Document$1 extends DocumentNode> = [(variables: VariablesOf<Document$1>) => Promise<DataOf<Document$1>>, UseMutationResult<Document$1>];
69
+ declare const useMutation: <Document extends DocumentNode>(document: Document) => UseMutationReturn<Document>;
70
+ //#endregion
71
+ //#region src/use-fragment.d.ts
72
+ type UseFragmentReturn<Document$1 extends DocumentNode> = DataOf<Document$1>;
73
+ declare const useFragment: <Document extends DocumentNode>(document: Document, fragmentRef: FragmentRef<Document>) => UseFragmentReturn<Document>;
74
+ //#endregion
75
+ export { ClientProvider, type UseFragmentReturn, type UseMutationResult, type UseMutationReturn, type UseQueryReturn, type UseSubscriptionOptions, type UseSubscriptionReturn, useClient, useFragment, useMutation, useQuery, useSubscription };
@@ -0,0 +1,75 @@
1
+ import { ReactNode } from "react";
2
+ import { Client, DataOf, DocumentNode, FragmentRef, VariablesOf } from "@mearie/core";
3
+
4
+ //#region src/client-provider.d.ts
5
+ type ClientProviderProps = {
6
+ client: Client;
7
+ children: ReactNode;
8
+ };
9
+ declare const ClientProvider: ({
10
+ client,
11
+ children
12
+ }: ClientProviderProps) => ReactNode;
13
+ declare const useClient: () => Client;
14
+ //#endregion
15
+ //#region src/use-query.d.ts
16
+ type UseQueryReturn<Document$1 extends DocumentNode> = {
17
+ data: undefined;
18
+ loading: true;
19
+ error: undefined;
20
+ refetch: () => void;
21
+ } | {
22
+ data: DataOf<Document$1>;
23
+ loading: false;
24
+ error: undefined;
25
+ refetch: () => void;
26
+ } | {
27
+ data: DataOf<Document$1> | undefined;
28
+ loading: false;
29
+ error: Error;
30
+ refetch: () => void;
31
+ };
32
+ declare const useQuery: <Document extends DocumentNode>(document: Document, variables: VariablesOf<Document>) => UseQueryReturn<Document>;
33
+ //#endregion
34
+ //#region src/use-subscription.d.ts
35
+ type UseSubscriptionReturn<Document$1 extends DocumentNode> = {
36
+ data: undefined;
37
+ loading: true;
38
+ error: undefined;
39
+ } | {
40
+ data: DataOf<Document$1>;
41
+ loading: false;
42
+ error: undefined;
43
+ } | {
44
+ data: DataOf<Document$1> | undefined;
45
+ loading: false;
46
+ error: Error;
47
+ };
48
+ type UseSubscriptionOptions<Document$1 extends DocumentNode> = {
49
+ onData?: (data: DataOf<Document$1>) => void;
50
+ onError?: (error: Error) => void;
51
+ };
52
+ declare const useSubscription: <Document extends DocumentNode>(document: Document, variables: VariablesOf<Document>, options?: UseSubscriptionOptions<Document>) => UseSubscriptionReturn<Document>;
53
+ //#endregion
54
+ //#region src/use-mutation.d.ts
55
+ type UseMutationResult<Document$1 extends DocumentNode> = {
56
+ data: undefined;
57
+ loading: true;
58
+ error: undefined;
59
+ } | {
60
+ data: DataOf<Document$1>;
61
+ loading: false;
62
+ error: undefined;
63
+ } | {
64
+ data: DataOf<Document$1> | undefined;
65
+ loading: false;
66
+ error: Error;
67
+ };
68
+ type UseMutationReturn<Document$1 extends DocumentNode> = [(variables: VariablesOf<Document$1>) => Promise<DataOf<Document$1>>, UseMutationResult<Document$1>];
69
+ declare const useMutation: <Document extends DocumentNode>(document: Document) => UseMutationReturn<Document>;
70
+ //#endregion
71
+ //#region src/use-fragment.d.ts
72
+ type UseFragmentReturn<Document$1 extends DocumentNode> = DataOf<Document$1>;
73
+ declare const useFragment: <Document extends DocumentNode>(document: Document, fragmentRef: FragmentRef<Document>) => UseFragmentReturn<Document>;
74
+ //#endregion
75
+ export { ClientProvider, type UseFragmentReturn, type UseMutationResult, type UseMutationReturn, type UseQueryReturn, type UseSubscriptionOptions, type UseSubscriptionReturn, useClient, useFragment, useMutation, useQuery, useSubscription };
package/dist/index.js ADDED
@@ -0,0 +1,56 @@
1
+ import { createContext, useContext } from "react";
2
+ import { jsx } from "react/jsx-runtime";
3
+
4
+ //#region src/client-provider.tsx
5
+ const ClientContext = createContext(null);
6
+ const ClientProvider = ({ client, children }) => {
7
+ return /* @__PURE__ */ jsx(ClientContext.Provider, {
8
+ value: client,
9
+ children
10
+ });
11
+ };
12
+ const useClient = () => {
13
+ const client = useContext(ClientContext);
14
+ if (!client) throw new Error("useClient must be used within ClientProvider");
15
+ return client;
16
+ };
17
+
18
+ //#endregion
19
+ //#region src/use-query.ts
20
+ const useQuery = (document, variables) => {
21
+ return {
22
+ data: void 0,
23
+ loading: true,
24
+ error: void 0,
25
+ refetch: () => {}
26
+ };
27
+ };
28
+
29
+ //#endregion
30
+ //#region src/use-subscription.ts
31
+ const useSubscription = (document, variables, options) => {
32
+ return {
33
+ data: void 0,
34
+ loading: true,
35
+ error: void 0
36
+ };
37
+ };
38
+
39
+ //#endregion
40
+ //#region src/use-mutation.ts
41
+ const useMutation = (document) => {
42
+ return [async () => ({}), {
43
+ data: void 0,
44
+ loading: false,
45
+ error: void 0
46
+ }];
47
+ };
48
+
49
+ //#endregion
50
+ //#region src/use-fragment.ts
51
+ const useFragment = (document, fragmentRef) => {
52
+ return {};
53
+ };
54
+
55
+ //#endregion
56
+ export { ClientProvider, useClient, useFragment, useMutation, useQuery, useSubscription };
package/package.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "@mearie/react",
3
+ "version": "0.0.0",
4
+ "description": "React integration for Mearie",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "main": "./src/index.ts",
8
+ "files": [
9
+ "dist"
10
+ ],
11
+ "dependencies": {
12
+ "@mearie/core": "0.0.0"
13
+ },
14
+ "devDependencies": {
15
+ "@types/react": "^18.3.0",
16
+ "react": "^18.3.0",
17
+ "tsdown": "^0.15.7"
18
+ },
19
+ "peerDependencies": {
20
+ "react": "^18.0.0 || ^19.0.0"
21
+ },
22
+ "publishConfig": {
23
+ "access": "public"
24
+ },
25
+ "scripts": {
26
+ "build": "tsdown"
27
+ },
28
+ "exports": {
29
+ ".": {
30
+ "types": "./dist/index.d.ts",
31
+ "import": "./dist/index.js",
32
+ "require": "./dist/index.cjs"
33
+ }
34
+ }
35
+ }
package/src/index.ts ADDED
@@ -0,0 +1,5 @@
1
+ export { ClientProvider, useClient } from './client-provider.tsx';
2
+ export { useQuery, type UseQueryReturn } from './use-query.ts';
3
+ export { useSubscription, type UseSubscriptionReturn, type UseSubscriptionOptions } from './use-subscription.ts';
4
+ export { useMutation, type UseMutationResult, type UseMutationReturn } from './use-mutation.ts';
5
+ export { useFragment, type UseFragmentReturn } from './use-fragment.ts';