@infinitewatch/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/dist/index.cjs +113 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +21 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.js +87 -0
- package/dist/index.js.map +1 -0
- package/package.json +53 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/index.ts
|
|
22
|
+
var index_exports = {};
|
|
23
|
+
__export(index_exports, {
|
|
24
|
+
InfiniteWatchProvider: () => InfiniteWatchProvider,
|
|
25
|
+
useInfiniteWatch: () => useInfiniteWatch
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(index_exports);
|
|
28
|
+
|
|
29
|
+
// src/provider.tsx
|
|
30
|
+
var import_web_core = require("@infinitewatch/web-core");
|
|
31
|
+
var import_react = require("react");
|
|
32
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
33
|
+
var import_meta = {};
|
|
34
|
+
var InfiniteWatchContext = (0, import_react.createContext)(
|
|
35
|
+
null
|
|
36
|
+
);
|
|
37
|
+
function InfiniteWatchProvider(props) {
|
|
38
|
+
const { children, ...rest } = props;
|
|
39
|
+
const options = rest;
|
|
40
|
+
const resolvedOrgId = options.organizationId || typeof import_meta !== "undefined" && import_meta.env?.VITE_INFINITEWATCH_ORG_ID || void 0;
|
|
41
|
+
const resolvedOptions = {
|
|
42
|
+
...options,
|
|
43
|
+
organizationId: resolvedOrgId
|
|
44
|
+
};
|
|
45
|
+
const clientRef = (0, import_react.useRef)(null);
|
|
46
|
+
const initializedRef = (0, import_react.useRef)(false);
|
|
47
|
+
const optionsRef = (0, import_react.useRef)(resolvedOptions);
|
|
48
|
+
(0, import_react.useEffect)(() => {
|
|
49
|
+
if (initializedRef.current) return;
|
|
50
|
+
initializedRef.current = true;
|
|
51
|
+
const client = (0, import_web_core.createWebCore)();
|
|
52
|
+
clientRef.current = client;
|
|
53
|
+
client.init(optionsRef.current).then((result) => {
|
|
54
|
+
if (result) {
|
|
55
|
+
client.start();
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
return () => {
|
|
59
|
+
client.stop();
|
|
60
|
+
};
|
|
61
|
+
}, []);
|
|
62
|
+
const contextValue = {
|
|
63
|
+
client: clientRef.current,
|
|
64
|
+
identify: (userIdentifier) => {
|
|
65
|
+
const client = clientRef.current;
|
|
66
|
+
if (!client) return null;
|
|
67
|
+
return client.identify(userIdentifier);
|
|
68
|
+
},
|
|
69
|
+
flush: () => {
|
|
70
|
+
const client = clientRef.current;
|
|
71
|
+
if (!client) return null;
|
|
72
|
+
return client.flush();
|
|
73
|
+
},
|
|
74
|
+
stop: () => {
|
|
75
|
+
const client = clientRef.current;
|
|
76
|
+
if (!client) return null;
|
|
77
|
+
return client.stop();
|
|
78
|
+
},
|
|
79
|
+
hardStop: () => {
|
|
80
|
+
const client = clientRef.current;
|
|
81
|
+
if (!client) return null;
|
|
82
|
+
return client.hardStop();
|
|
83
|
+
},
|
|
84
|
+
getSessionInfo: () => clientRef.current?.getSessionInfo() ?? {
|
|
85
|
+
sessionId: null,
|
|
86
|
+
userId: null,
|
|
87
|
+
organizationId: null,
|
|
88
|
+
sessionStartTime: null,
|
|
89
|
+
isActive: false,
|
|
90
|
+
hasStoredSession: false
|
|
91
|
+
},
|
|
92
|
+
isBlocked: () => clientRef.current?.isBlocked() ?? false
|
|
93
|
+
};
|
|
94
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(InfiniteWatchContext.Provider, { value: contextValue, children });
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// src/use-infinitewatch.ts
|
|
98
|
+
var import_react2 = require("react");
|
|
99
|
+
function useInfiniteWatch() {
|
|
100
|
+
const context = (0, import_react2.useContext)(InfiniteWatchContext);
|
|
101
|
+
if (!context) {
|
|
102
|
+
throw new Error(
|
|
103
|
+
"useInfiniteWatch must be used within an InfiniteWatchProvider"
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
return context;
|
|
107
|
+
}
|
|
108
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
109
|
+
0 && (module.exports = {
|
|
110
|
+
InfiniteWatchProvider,
|
|
111
|
+
useInfiniteWatch
|
|
112
|
+
});
|
|
113
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/provider.tsx","../src/use-infinitewatch.ts"],"sourcesContent":["export {\n\tInfiniteWatchProvider,\n\ttype InfiniteWatchProviderProps,\n} from \"./provider.js\";\nexport { useInfiniteWatch } from \"./use-infinitewatch.js\";\n","import {\n\tcreateWebCore,\n\ttype UserIdentifier,\n\ttype WebCoreClient,\n\ttype WebCoreOptions,\n} from \"@infinitewatch/web-core\";\nimport { createContext, type ReactNode, useEffect, useRef } from \"react\";\n\nexport interface InfiniteWatchContextValue {\n\tclient: WebCoreClient | null;\n\tidentify: (userIdentifier: UserIdentifier) => WebCoreClient | null;\n\tflush: () => WebCoreClient | null;\n\tstop: () => WebCoreClient | null;\n\thardStop: () => WebCoreClient | null;\n\tgetSessionInfo: WebCoreClient[\"getSessionInfo\"];\n\tisBlocked: WebCoreClient[\"isBlocked\"];\n}\n\nconst InfiniteWatchContext = createContext<InfiniteWatchContextValue | null>(\n\tnull,\n);\n\nexport interface InfiniteWatchProviderProps extends WebCoreOptions {\n\tchildren: ReactNode;\n}\n\nexport function InfiniteWatchProvider(props: InfiniteWatchProviderProps) {\n\tconst { children, ...rest } = props;\n\tconst options: WebCoreOptions = rest;\n\tconst resolvedOrgId =\n\t\toptions.organizationId ||\n\t\t(typeof import.meta !== \"undefined\" &&\n\t\t\t(import.meta as unknown as { env?: Record<string, string> }).env\n\t\t\t\t?.VITE_INFINITEWATCH_ORG_ID) ||\n\t\tundefined;\n\tconst resolvedOptions: WebCoreOptions = {\n\t\t...options,\n\t\torganizationId: resolvedOrgId,\n\t};\n\tconst clientRef = useRef<WebCoreClient | null>(null);\n\tconst initializedRef = useRef(false);\n\tconst optionsRef = useRef(resolvedOptions);\n\n\tuseEffect(() => {\n\t\t// StrictMode-safe: only initialize once\n\t\tif (initializedRef.current) return;\n\t\tinitializedRef.current = true;\n\n\t\tconst client = createWebCore();\n\t\tclientRef.current = client;\n\n\t\tclient.init(optionsRef.current).then((result: WebCoreClient | null) => {\n\t\t\tif (result) {\n\t\t\t\tclient.start();\n\t\t\t}\n\t\t});\n\n\t\treturn () => {\n\t\t\tclient.stop();\n\t\t};\n\t}, []);\n\n\tconst contextValue: InfiniteWatchContextValue = {\n\t\tclient: clientRef.current,\n\t\tidentify: (userIdentifier: UserIdentifier) => {\n\t\t\tconst client = clientRef.current;\n\t\t\tif (!client) return null;\n\t\t\treturn client.identify(userIdentifier);\n\t\t},\n\t\tflush: () => {\n\t\t\tconst client = clientRef.current;\n\t\t\tif (!client) return null;\n\t\t\treturn client.flush();\n\t\t},\n\t\tstop: () => {\n\t\t\tconst client = clientRef.current;\n\t\t\tif (!client) return null;\n\t\t\treturn client.stop();\n\t\t},\n\t\thardStop: () => {\n\t\t\tconst client = clientRef.current;\n\t\t\tif (!client) return null;\n\t\t\treturn client.hardStop();\n\t\t},\n\t\tgetSessionInfo: () =>\n\t\t\tclientRef.current?.getSessionInfo() ?? {\n\t\t\t\tsessionId: null,\n\t\t\t\tuserId: null,\n\t\t\t\torganizationId: null,\n\t\t\t\tsessionStartTime: null,\n\t\t\t\tisActive: false,\n\t\t\t\thasStoredSession: false,\n\t\t\t},\n\t\tisBlocked: () => clientRef.current?.isBlocked() ?? false,\n\t};\n\n\treturn (\n\t\t<InfiniteWatchContext.Provider value={contextValue}>\n\t\t\t{children}\n\t\t</InfiniteWatchContext.Provider>\n\t);\n}\n\nexport { InfiniteWatchContext };\n","import { useContext } from \"react\";\nimport { InfiniteWatchContext } from \"./provider.js\";\n\nexport function useInfiniteWatch() {\n\tconst context = useContext(InfiniteWatchContext);\n\tif (!context) {\n\t\tthrow new Error(\n\t\t\t\"useInfiniteWatch must be used within an InfiniteWatchProvider\",\n\t\t);\n\t}\n\treturn context;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,sBAKO;AACP,mBAAiE;AA2F/D;AAjGF;AAkBA,IAAM,2BAAuB;AAAA,EAC5B;AACD;AAMO,SAAS,sBAAsB,OAAmC;AACxE,QAAM,EAAE,UAAU,GAAG,KAAK,IAAI;AAC9B,QAAM,UAA0B;AAChC,QAAM,gBACL,QAAQ,kBACP,OAAO,gBAAgB,eACtB,YAA4D,KAC1D,6BACJ;AACD,QAAM,kBAAkC;AAAA,IACvC,GAAG;AAAA,IACH,gBAAgB;AAAA,EACjB;AACA,QAAM,gBAAY,qBAA6B,IAAI;AACnD,QAAM,qBAAiB,qBAAO,KAAK;AACnC,QAAM,iBAAa,qBAA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AACb,UAAM,IAAI;AAAA,MACT;AAAA,IACD;AAAA,EACD;AACA,SAAO;AACR;","names":["import_react"]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import { WebCoreOptions, WebCoreClient, UserIdentifier } from '@infinitewatch/web-core';
|
|
4
|
+
|
|
5
|
+
interface InfiniteWatchContextValue {
|
|
6
|
+
client: WebCoreClient | null;
|
|
7
|
+
identify: (userIdentifier: UserIdentifier) => WebCoreClient | null;
|
|
8
|
+
flush: () => WebCoreClient | null;
|
|
9
|
+
stop: () => WebCoreClient | null;
|
|
10
|
+
hardStop: () => WebCoreClient | null;
|
|
11
|
+
getSessionInfo: WebCoreClient["getSessionInfo"];
|
|
12
|
+
isBlocked: WebCoreClient["isBlocked"];
|
|
13
|
+
}
|
|
14
|
+
interface InfiniteWatchProviderProps extends WebCoreOptions {
|
|
15
|
+
children: ReactNode;
|
|
16
|
+
}
|
|
17
|
+
declare function InfiniteWatchProvider(props: InfiniteWatchProviderProps): react_jsx_runtime.JSX.Element;
|
|
18
|
+
|
|
19
|
+
declare function useInfiniteWatch(): InfiniteWatchContextValue;
|
|
20
|
+
|
|
21
|
+
export { InfiniteWatchProvider, type InfiniteWatchProviderProps, useInfiniteWatch };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import { WebCoreOptions, WebCoreClient, UserIdentifier } from '@infinitewatch/web-core';
|
|
4
|
+
|
|
5
|
+
interface InfiniteWatchContextValue {
|
|
6
|
+
client: WebCoreClient | null;
|
|
7
|
+
identify: (userIdentifier: UserIdentifier) => WebCoreClient | null;
|
|
8
|
+
flush: () => WebCoreClient | null;
|
|
9
|
+
stop: () => WebCoreClient | null;
|
|
10
|
+
hardStop: () => WebCoreClient | null;
|
|
11
|
+
getSessionInfo: WebCoreClient["getSessionInfo"];
|
|
12
|
+
isBlocked: WebCoreClient["isBlocked"];
|
|
13
|
+
}
|
|
14
|
+
interface InfiniteWatchProviderProps extends WebCoreOptions {
|
|
15
|
+
children: ReactNode;
|
|
16
|
+
}
|
|
17
|
+
declare function InfiniteWatchProvider(props: InfiniteWatchProviderProps): react_jsx_runtime.JSX.Element;
|
|
18
|
+
|
|
19
|
+
declare function useInfiniteWatch(): InfiniteWatchContextValue;
|
|
20
|
+
|
|
21
|
+
export { InfiniteWatchProvider, type InfiniteWatchProviderProps, useInfiniteWatch };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/provider.tsx
|
|
4
|
+
import {
|
|
5
|
+
createWebCore
|
|
6
|
+
} from "@infinitewatch/web-core";
|
|
7
|
+
import { createContext, useEffect, useRef } from "react";
|
|
8
|
+
import { jsx } from "react/jsx-runtime";
|
|
9
|
+
var InfiniteWatchContext = createContext(
|
|
10
|
+
null
|
|
11
|
+
);
|
|
12
|
+
function InfiniteWatchProvider(props) {
|
|
13
|
+
const { children, ...rest } = props;
|
|
14
|
+
const options = rest;
|
|
15
|
+
const resolvedOrgId = options.organizationId || typeof import.meta !== "undefined" && import.meta.env?.VITE_INFINITEWATCH_ORG_ID || void 0;
|
|
16
|
+
const resolvedOptions = {
|
|
17
|
+
...options,
|
|
18
|
+
organizationId: resolvedOrgId
|
|
19
|
+
};
|
|
20
|
+
const clientRef = useRef(null);
|
|
21
|
+
const initializedRef = useRef(false);
|
|
22
|
+
const optionsRef = useRef(resolvedOptions);
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
if (initializedRef.current) return;
|
|
25
|
+
initializedRef.current = true;
|
|
26
|
+
const client = createWebCore();
|
|
27
|
+
clientRef.current = client;
|
|
28
|
+
client.init(optionsRef.current).then((result) => {
|
|
29
|
+
if (result) {
|
|
30
|
+
client.start();
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
return () => {
|
|
34
|
+
client.stop();
|
|
35
|
+
};
|
|
36
|
+
}, []);
|
|
37
|
+
const contextValue = {
|
|
38
|
+
client: clientRef.current,
|
|
39
|
+
identify: (userIdentifier) => {
|
|
40
|
+
const client = clientRef.current;
|
|
41
|
+
if (!client) return null;
|
|
42
|
+
return client.identify(userIdentifier);
|
|
43
|
+
},
|
|
44
|
+
flush: () => {
|
|
45
|
+
const client = clientRef.current;
|
|
46
|
+
if (!client) return null;
|
|
47
|
+
return client.flush();
|
|
48
|
+
},
|
|
49
|
+
stop: () => {
|
|
50
|
+
const client = clientRef.current;
|
|
51
|
+
if (!client) return null;
|
|
52
|
+
return client.stop();
|
|
53
|
+
},
|
|
54
|
+
hardStop: () => {
|
|
55
|
+
const client = clientRef.current;
|
|
56
|
+
if (!client) return null;
|
|
57
|
+
return client.hardStop();
|
|
58
|
+
},
|
|
59
|
+
getSessionInfo: () => clientRef.current?.getSessionInfo() ?? {
|
|
60
|
+
sessionId: null,
|
|
61
|
+
userId: null,
|
|
62
|
+
organizationId: null,
|
|
63
|
+
sessionStartTime: null,
|
|
64
|
+
isActive: false,
|
|
65
|
+
hasStoredSession: false
|
|
66
|
+
},
|
|
67
|
+
isBlocked: () => clientRef.current?.isBlocked() ?? false
|
|
68
|
+
};
|
|
69
|
+
return /* @__PURE__ */ jsx(InfiniteWatchContext.Provider, { value: contextValue, children });
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// src/use-infinitewatch.ts
|
|
73
|
+
import { useContext } from "react";
|
|
74
|
+
function useInfiniteWatch() {
|
|
75
|
+
const context = useContext(InfiniteWatchContext);
|
|
76
|
+
if (!context) {
|
|
77
|
+
throw new Error(
|
|
78
|
+
"useInfiniteWatch must be used within an InfiniteWatchProvider"
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
return context;
|
|
82
|
+
}
|
|
83
|
+
export {
|
|
84
|
+
InfiniteWatchProvider,
|
|
85
|
+
useInfiniteWatch
|
|
86
|
+
};
|
|
87
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/provider.tsx","../src/use-infinitewatch.ts"],"sourcesContent":["import {\n\tcreateWebCore,\n\ttype UserIdentifier,\n\ttype WebCoreClient,\n\ttype WebCoreOptions,\n} from \"@infinitewatch/web-core\";\nimport { createContext, type ReactNode, useEffect, useRef } from \"react\";\n\nexport interface InfiniteWatchContextValue {\n\tclient: WebCoreClient | null;\n\tidentify: (userIdentifier: UserIdentifier) => WebCoreClient | null;\n\tflush: () => WebCoreClient | null;\n\tstop: () => WebCoreClient | null;\n\thardStop: () => WebCoreClient | null;\n\tgetSessionInfo: WebCoreClient[\"getSessionInfo\"];\n\tisBlocked: WebCoreClient[\"isBlocked\"];\n}\n\nconst InfiniteWatchContext = createContext<InfiniteWatchContextValue | null>(\n\tnull,\n);\n\nexport interface InfiniteWatchProviderProps extends WebCoreOptions {\n\tchildren: ReactNode;\n}\n\nexport function InfiniteWatchProvider(props: InfiniteWatchProviderProps) {\n\tconst { children, ...rest } = props;\n\tconst options: WebCoreOptions = rest;\n\tconst resolvedOrgId =\n\t\toptions.organizationId ||\n\t\t(typeof import.meta !== \"undefined\" &&\n\t\t\t(import.meta as unknown as { env?: Record<string, string> }).env\n\t\t\t\t?.VITE_INFINITEWATCH_ORG_ID) ||\n\t\tundefined;\n\tconst resolvedOptions: WebCoreOptions = {\n\t\t...options,\n\t\torganizationId: resolvedOrgId,\n\t};\n\tconst clientRef = useRef<WebCoreClient | null>(null);\n\tconst initializedRef = useRef(false);\n\tconst optionsRef = useRef(resolvedOptions);\n\n\tuseEffect(() => {\n\t\t// StrictMode-safe: only initialize once\n\t\tif (initializedRef.current) return;\n\t\tinitializedRef.current = true;\n\n\t\tconst client = createWebCore();\n\t\tclientRef.current = client;\n\n\t\tclient.init(optionsRef.current).then((result: WebCoreClient | null) => {\n\t\t\tif (result) {\n\t\t\t\tclient.start();\n\t\t\t}\n\t\t});\n\n\t\treturn () => {\n\t\t\tclient.stop();\n\t\t};\n\t}, []);\n\n\tconst contextValue: InfiniteWatchContextValue = {\n\t\tclient: clientRef.current,\n\t\tidentify: (userIdentifier: UserIdentifier) => {\n\t\t\tconst client = clientRef.current;\n\t\t\tif (!client) return null;\n\t\t\treturn client.identify(userIdentifier);\n\t\t},\n\t\tflush: () => {\n\t\t\tconst client = clientRef.current;\n\t\t\tif (!client) return null;\n\t\t\treturn client.flush();\n\t\t},\n\t\tstop: () => {\n\t\t\tconst client = clientRef.current;\n\t\t\tif (!client) return null;\n\t\t\treturn client.stop();\n\t\t},\n\t\thardStop: () => {\n\t\t\tconst client = clientRef.current;\n\t\t\tif (!client) return null;\n\t\t\treturn client.hardStop();\n\t\t},\n\t\tgetSessionInfo: () =>\n\t\t\tclientRef.current?.getSessionInfo() ?? {\n\t\t\t\tsessionId: null,\n\t\t\t\tuserId: null,\n\t\t\t\torganizationId: null,\n\t\t\t\tsessionStartTime: null,\n\t\t\t\tisActive: false,\n\t\t\t\thasStoredSession: false,\n\t\t\t},\n\t\tisBlocked: () => clientRef.current?.isBlocked() ?? false,\n\t};\n\n\treturn (\n\t\t<InfiniteWatchContext.Provider value={contextValue}>\n\t\t\t{children}\n\t\t</InfiniteWatchContext.Provider>\n\t);\n}\n\nexport { InfiniteWatchContext };\n","import { useContext } from \"react\";\nimport { InfiniteWatchContext } from \"./provider.js\";\n\nexport function useInfiniteWatch() {\n\tconst context = useContext(InfiniteWatchContext);\n\tif (!context) {\n\t\tthrow new Error(\n\t\t\t\"useInfiniteWatch must be used within an InfiniteWatchProvider\",\n\t\t);\n\t}\n\treturn context;\n}\n"],"mappings":";;;AAAA;AAAA,EACC;AAAA,OAIM;AACP,SAAS,eAA+B,WAAW,cAAc;AA2F/D;AA/EF,IAAM,uBAAuB;AAAA,EAC5B;AACD;AAMO,SAAS,sBAAsB,OAAmC;AACxE,QAAM,EAAE,UA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,UAAU;AAAA,MACV,kBAAkB;AAAA,IACnB;AAAA,IACD,WAAW,MAAM,UAAU,SAAS,UAAU,KAAK;AAAA,EACpD;AAEA,SACC,oBAAC,qBAAqB,UAArB,EAA8B,OAAO,cACpC,UACF;AAEF;;;ACrGA,SAAS,kBAAkB;AAGpB,SAAS,mBAAmB;AAClC,QAAM,UAAU,WAAW,oBAAoB;AAC/C,MAAI,CAAC,SAAS;AACb,UAAM,IAAI;AAAA,MACT;AAAA,IACD;AAAA,EACD;AACA,SAAO;AACR;","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@infinitewatch/react",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"private": false,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.cjs",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"import": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"default": "./dist/index.js"
|
|
14
|
+
},
|
|
15
|
+
"require": {
|
|
16
|
+
"types": "./dist/index.d.cts",
|
|
17
|
+
"default": "./dist/index.cjs"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"dist"
|
|
23
|
+
],
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"repository": {
|
|
26
|
+
"type": "git",
|
|
27
|
+
"url": "https://github.com/InfiniteWatch/infinitewatch-sdk.git",
|
|
28
|
+
"directory": "packages/react"
|
|
29
|
+
},
|
|
30
|
+
"publishConfig": {
|
|
31
|
+
"access": "public"
|
|
32
|
+
},
|
|
33
|
+
"sideEffects": false,
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@infinitewatch/web-core": "0.0.0"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@types/react": "^19.0.0",
|
|
39
|
+
"react": "^19.2.4",
|
|
40
|
+
"typescript": "5.9.2",
|
|
41
|
+
"@infinitewatch/typescript-config": "0.0.0"
|
|
42
|
+
},
|
|
43
|
+
"peerDependencies": {
|
|
44
|
+
"react": "^18.0.0 || ^19.0.0"
|
|
45
|
+
},
|
|
46
|
+
"scripts": {
|
|
47
|
+
"build": "tsup",
|
|
48
|
+
"check": "pnpm -w exec biome check .",
|
|
49
|
+
"lint": "pnpm -w exec biome lint .",
|
|
50
|
+
"format": "pnpm -w exec biome format . --write",
|
|
51
|
+
"check-types": "tsc --noEmit"
|
|
52
|
+
}
|
|
53
|
+
}
|