@koderlabs/tasks-sdk-react 0.1.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,179 @@
1
+ PROPRIETARY SOFTWARE LICENSE — ALL RIGHTS RESERVED
2
+
3
+ Copyright (c) 2026 KoderLabs. All rights reserved.
4
+ Author: Jawaid Gadiwala <jawaidgadiwala@gmail.com>
5
+
6
+ ================================================================================
7
+ 1. NO LICENSE GRANTED BY DEFAULT
8
+ ================================================================================
9
+
10
+ This software, including all source code, object code, documentation,
11
+ configuration files, build artifacts, test fixtures, and any associated
12
+ materials (collectively, the "Software"), is the proprietary and confidential
13
+ property of KoderLabs.
14
+
15
+ NO license, right, title, interest, or permission of any kind — express,
16
+ implied, statutory, by estoppel, by exhaustion, by patent exhaustion, or by
17
+ any other legal theory — is granted to any person or entity by:
18
+
19
+ (a) viewing the Software on any registry, repository, mirror, CDN,
20
+ cache, or other distribution channel (including but not limited to
21
+ npmjs.com, GitHub, GitLab, or any private registry);
22
+ (b) downloading, cloning, or otherwise obtaining a copy of the Software;
23
+ (c) the act of the Software being technically accessible due to a registry
24
+ requirement, mirror, or third-party distribution;
25
+ (d) any prior course of dealing, custom, or industry practice.
26
+
27
+ The ability to access the Software does NOT imply any permission to use it.
28
+ A separate, signed, written license agreement executed by an authorised
29
+ representative of KoderLabs is the ONLY mechanism by which any rights may be
30
+ granted.
31
+
32
+ ================================================================================
33
+ 2. PROHIBITED ACTIVITIES (NON-EXHAUSTIVE)
34
+ ================================================================================
35
+
36
+ Without prior signed written permission from KoderLabs, the following are
37
+ expressly PROHIBITED and constitute infringement, breach of contract, and
38
+ unauthorised use:
39
+
40
+ (a) Copying the Software in whole or in part, in any medium;
41
+ (b) Modifying, adapting, translating, porting, or creating derivative works
42
+ of the Software;
43
+ (c) Distributing, republishing, mirroring, hosting, transmitting,
44
+ sublicensing, leasing, lending, renting, selling, offering for sale,
45
+ bartering, gifting, or otherwise transferring the Software or any
46
+ portion of it;
47
+ (d) Forking the Software's repository, whether on GitHub, GitLab, Bitbucket,
48
+ Codeberg, Sourcehut, or any other version-control hosting service;
49
+ (e) Reverse engineering, decompiling, disassembling, deobfuscating,
50
+ extracting source from compiled or minified artifacts, or attempting to
51
+ derive the source code, algorithms, or trade secrets;
52
+ (f) Removing, altering, or obscuring any copyright, trademark, license,
53
+ attribution, or proprietary notice;
54
+ (g) Using the Software, in whole or in part, to train, fine-tune,
55
+ evaluate, or benchmark any machine-learning model, embedding model, or
56
+ AI system;
57
+ (h) Using the Software to provide a hosted service, SaaS offering,
58
+ managed offering, or any form of public or commercial offering;
59
+ (i) Using the Software in any production, staging, development, evaluation,
60
+ or testing capacity, whether commercial or non-commercial;
61
+ (j) Bypassing, disabling, or attempting to circumvent any technical
62
+ protection measure (license check, telemetry, signature verification,
63
+ etc.) embedded in the Software;
64
+ (k) Combining or integrating the Software with any work licensed under a
65
+ copyleft licence (including but not limited to GPL, AGPL, LGPL, MPL,
66
+ EPL) in a manner that would purport to relicense the Software;
67
+ (l) Filing, prosecuting, or threatening patent litigation against KoderLabs
68
+ or its customers based on any feature, design, or behaviour of the
69
+ Software ("defensive termination" — any such action automatically and
70
+ immediately terminates any rights granted to the litigant elsewhere).
71
+
72
+ ================================================================================
73
+ 3. NO IMPLIED RIGHT TO INTERNAL USE
74
+ ================================================================================
75
+
76
+ The Software is NOT licensed for internal evaluation, internal production,
77
+ internal testing, or any other internal use unless and until a separate
78
+ written commercial licence is executed. Possession of a copy of the Software,
79
+ by whatever means, confers no right to execute, run, deploy, or use it.
80
+
81
+ ================================================================================
82
+ 4. NO PATENT, TRADEMARK, OR OTHER IP GRANT
83
+ ================================================================================
84
+
85
+ No patent licence, trademark licence, trade-secret disclosure, design-right
86
+ licence, or any other intellectual-property licence is granted under this
87
+ notice. KoderLabs retains all such rights.
88
+
89
+ ================================================================================
90
+ 5. CONFIDENTIALITY
91
+ ================================================================================
92
+
93
+ The Software contains trade secrets and confidential information of
94
+ KoderLabs. Any party in possession of the Software shall (a) treat it as
95
+ confidential, (b) take reasonable measures to prevent unauthorised access or
96
+ disclosure, and (c) not disclose, publish, or make available the Software or
97
+ any portion thereof to any third party.
98
+
99
+ ================================================================================
100
+ 6. AUTOMATIC TERMINATION
101
+ ================================================================================
102
+
103
+ Any rights that may exist under a separate written agreement terminate
104
+ AUTOMATICALLY AND IMMEDIATELY upon any breach of this notice, without notice
105
+ and without judicial action. Upon termination, the breaching party shall
106
+ immediately destroy all copies of the Software in its possession or control
107
+ and certify destruction in writing to KoderLabs.
108
+
109
+ ================================================================================
110
+ 7. NO WARRANTY
111
+ ================================================================================
112
+
113
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
114
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
115
+ FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, ACCURACY, RELIABILITY,
116
+ TITLE, AVAILABILITY, OR THAT THE SOFTWARE WILL OPERATE UNINTERRUPTED OR
117
+ ERROR-FREE.
118
+
119
+ ================================================================================
120
+ 8. NO LIABILITY
121
+ ================================================================================
122
+
123
+ IN NO EVENT SHALL KODERLABS OR ITS AFFILIATES, OFFICERS, EMPLOYEES, AGENTS,
124
+ LICENSORS, OR CONTRIBUTORS BE LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER
125
+ LIABILITY (INCLUDING DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
126
+ CONSEQUENTIAL, PUNITIVE, LOST PROFITS, LOST DATA, OR BUSINESS INTERRUPTION),
127
+ WHETHER IN AN ACTION OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT
128
+ LIABILITY, OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION WITH THE
129
+ SOFTWARE OR THE USE OF OR INABILITY TO USE THE SOFTWARE, EVEN IF ADVISED OF
130
+ THE POSSIBILITY OF SUCH DAMAGE. IN NO EVENT SHALL KODERLABS' TOTAL CUMULATIVE
131
+ LIABILITY EXCEED ONE U.S. DOLLAR (USD 1.00).
132
+
133
+ ================================================================================
134
+ 9. EQUITABLE RELIEF
135
+ ================================================================================
136
+
137
+ The parties acknowledge that any breach of this notice would cause
138
+ irreparable harm to KoderLabs for which monetary damages would be inadequate.
139
+ KoderLabs is therefore entitled, in addition to all other remedies available
140
+ at law, to specific performance and injunctive relief without the need to
141
+ post bond.
142
+
143
+ ================================================================================
144
+ 10. GOVERNING LAW AND VENUE
145
+ ================================================================================
146
+
147
+ This notice shall be governed by and construed in accordance with the laws
148
+ of the Islamic Republic of Pakistan, without regard to its conflict-of-laws
149
+ principles. Any dispute arising out of or in connection with this notice
150
+ shall be subject to the exclusive jurisdiction of the courts of Karachi,
151
+ Pakistan.
152
+
153
+ The United Nations Convention on Contracts for the International Sale of
154
+ Goods shall not apply.
155
+
156
+ ================================================================================
157
+ 11. SEVERABILITY AND ENTIRE NOTICE
158
+ ================================================================================
159
+
160
+ If any provision of this notice is held invalid or unenforceable, the
161
+ remaining provisions shall continue in full force and effect. This notice,
162
+ together with any separate signed written licence executed between KoderLabs
163
+ and a licensee, constitutes the entire agreement concerning the Software and
164
+ supersedes all prior or contemporaneous understandings.
165
+
166
+ ================================================================================
167
+ 12. CONTACT
168
+ ================================================================================
169
+
170
+ For licensing inquiries, audit requests, or notice of suspected
171
+ infringement, contact:
172
+
173
+ KoderLabs
174
+ Attn: Jawaid Gadiwala
175
+ Email: jawaidgadiwala@gmail.com
176
+
177
+ ================================================================================
178
+ END OF LICENCE
179
+ ================================================================================
package/README.md ADDED
@@ -0,0 +1,9 @@
1
+ # Proprietary Software
2
+
3
+ KoderLabs proprietary. All rights reserved.
4
+
5
+ See the bundled `LICENSE` for terms. No grant of any rights, express or
6
+ implied, is conferred by access to or possession of this package. A
7
+ separate signed written licence from KoderLabs is required for any use.
8
+
9
+ Licensing inquiries: jawaidgadiwala@gmail.com
package/dist/index.cjs ADDED
@@ -0,0 +1,142 @@
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/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ ErrorBoundary: () => ErrorBoundary,
24
+ InstantTasksContext: () => InstantTasksContext,
25
+ InstantTasksProvider: () => InstantTasksProvider,
26
+ useInstantTasks: () => useInstantTasks,
27
+ useUser: () => useUser
28
+ });
29
+ module.exports = __toCommonJS(index_exports);
30
+
31
+ // src/InstantTasksProvider.tsx
32
+ var import_react2 = require("react");
33
+ var import_tasks_sdk = require("@koderlabs/tasks-sdk");
34
+
35
+ // src/context.ts
36
+ var import_react = require("react");
37
+ var InstantTasksContext = (0, import_react.createContext)({
38
+ client: null
39
+ });
40
+
41
+ // src/InstantTasksProvider.tsx
42
+ var import_jsx_runtime = require("react/jsx-runtime");
43
+ var isBrowser = typeof window !== "undefined";
44
+ function InstantTasksProvider({ options, children }) {
45
+ const [client, setClient] = (0, import_react2.useState)(() => {
46
+ if (!isBrowser) return null;
47
+ try {
48
+ return (0, import_tasks_sdk.init)(options);
49
+ } catch {
50
+ return null;
51
+ }
52
+ });
53
+ const clientRef = (0, import_react2.useRef)(client);
54
+ clientRef.current = client;
55
+ (0, import_react2.useEffect)(() => {
56
+ if (!clientRef.current && isBrowser) {
57
+ try {
58
+ const c = (0, import_tasks_sdk.init)(options);
59
+ clientRef.current = c;
60
+ setClient(c);
61
+ } catch {
62
+ }
63
+ }
64
+ return () => {
65
+ const c = clientRef.current;
66
+ if (c) c.emit("unload");
67
+ };
68
+ }, []);
69
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(InstantTasksContext.Provider, { value: { client }, children });
70
+ }
71
+
72
+ // src/ErrorBoundary.tsx
73
+ var import_react3 = require("react");
74
+ var import_tasks_sdk2 = require("@koderlabs/tasks-sdk");
75
+ var ErrorBoundary = class extends import_react3.Component {
76
+ constructor() {
77
+ super(...arguments);
78
+ this.state = { caught: false, error: null };
79
+ }
80
+ static getDerivedStateFromError(error) {
81
+ return { caught: true, error };
82
+ }
83
+ componentDidCatch(error, info) {
84
+ const client = this.props.client ?? (0, import_tasks_sdk2.getClient)();
85
+ if (client && typeof client.errors?.notify === "function") {
86
+ client.errors.notify(error, {
87
+ componentStack: info.componentStack ?? void 0
88
+ });
89
+ } else if (client) {
90
+ client.send?.({
91
+ kind: "error",
92
+ message: error.message,
93
+ stack: error.stack,
94
+ componentStack: info.componentStack ?? void 0
95
+ }).catch(() => {
96
+ });
97
+ }
98
+ }
99
+ render() {
100
+ if (this.state.caught && this.state.error) {
101
+ const { fallback } = this.props;
102
+ if (typeof fallback === "function") return fallback(this.state.error);
103
+ if (fallback != null) return fallback;
104
+ return null;
105
+ }
106
+ return this.props.children;
107
+ }
108
+ };
109
+
110
+ // src/useInstantTasks.ts
111
+ var import_react4 = require("react");
112
+ function useInstantTasks() {
113
+ const ctx = (0, import_react4.useContext)(InstantTasksContext);
114
+ const c = ctx.client;
115
+ const reporter = c?.reporter ?? c?.widget ?? null;
116
+ return {
117
+ client: ctx.client,
118
+ reporter,
119
+ widget: reporter,
120
+ errors: c?.errors ?? null,
121
+ network: c?.network ?? null
122
+ };
123
+ }
124
+
125
+ // src/useUser.ts
126
+ var import_react5 = require("react");
127
+ function useUser(user) {
128
+ const { client } = useInstantTasks();
129
+ (0, import_react5.useEffect)(() => {
130
+ if (!client || !user) return;
131
+ client.setUser(user);
132
+ }, [client, user]);
133
+ }
134
+ // Annotate the CommonJS export names for ESM import in node:
135
+ 0 && (module.exports = {
136
+ ErrorBoundary,
137
+ InstantTasksContext,
138
+ InstantTasksProvider,
139
+ useInstantTasks,
140
+ useUser
141
+ });
142
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts","../src/InstantTasksProvider.tsx","../src/context.ts","../src/ErrorBoundary.tsx","../src/useInstantTasks.ts","../src/useUser.ts"],"sourcesContent":["export { InstantTasksProvider } from './InstantTasksProvider';\nexport type { InstantTasksProviderProps } from './InstantTasksProvider';\n\nexport { ErrorBoundary } from './ErrorBoundary';\nexport type { ErrorBoundaryProps } from './ErrorBoundary';\n\nexport { useInstantTasks } from './useInstantTasks';\nexport type { UseInstantTasksResult } from './useInstantTasks';\n\nexport { useUser } from './useUser';\n\n// Re-export context for advanced use cases (custom providers, etc.)\nexport { InstantTasksContext } from './context';\nexport type { InstantTasksContextValue } from './context';\n","import { useEffect, useRef, useState } from 'react';\nimport { init } from '@koderlabs/tasks-sdk';\nimport type { InitOptions, Client } from '@koderlabs/tasks-sdk';\nimport { InstantTasksContext } from './context';\n\nexport interface InstantTasksProviderProps {\n options: InitOptions;\n children: React.ReactNode;\n}\n\nconst isBrowser = typeof window !== 'undefined';\n\n/**\n * Initialises the InstantTasks SDK at mount and tears it down on unmount.\n *\n * Behaviour:\n * - **Browser mount**: client is created via a `useState` lazy initialiser\n * so consumers in the same paint see a real Client (no null window).\n * - **SSR / RSC**: lazy init returns `null` (no `window`). A browser-only\n * `useEffect` then initialises and surfaces the client via state.\n * - **StrictMode double-mount (dev)**: the underlying `init()` is idempotent\n * — calling it again tears the prior client down (see `sdk/src/index.ts`)\n * and returns a fresh one. Production runs `init()` exactly once.\n *\n * Init errors (invalid endpoint, bad projectId) are NOT fatal to render —\n * the host app continues without telemetry rather than crash.\n */\nexport function InstantTasksProvider({ options, children }: InstantTasksProviderProps) {\n const [client, setClient] = useState<Client | null>(() => {\n if (!isBrowser) return null;\n try { return init(options); }\n catch { return null; }\n });\n // Capture the most recent client in a ref so cleanup always sees the live\n // instance — without this, StrictMode's effect ↔ cleanup ↔ effect dance can\n // race state updates.\n const clientRef = useRef<Client | null>(client);\n clientRef.current = client;\n\n useEffect(() => {\n // SSR hydration path: lazy init returned null on the server. Try again now.\n if (!clientRef.current && isBrowser) {\n try {\n const c = init(options);\n clientRef.current = c;\n setClient(c);\n } catch { /* host stays without telemetry */ }\n }\n return () => {\n const c = clientRef.current;\n if (c) c.emit('unload');\n };\n // Re-init on options change is intentionally NOT supported — memoize\n // options upstream or use setUser / setCustomData for runtime updates.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n return (\n <InstantTasksContext.Provider value={{ client }}>\n {children}\n </InstantTasksContext.Provider>\n );\n}\n","import { createContext } from 'react';\nimport type { Client } from '@koderlabs/tasks-sdk';\n\nexport interface InstantTasksContextValue {\n client: Client | null;\n}\n\nexport const InstantTasksContext = createContext<InstantTasksContextValue>({\n client: null,\n});\n","import { Component } from 'react';\nimport type { ErrorInfo, ReactNode } from 'react';\nimport { getClient } from '@koderlabs/tasks-sdk';\n\nexport interface ErrorBoundaryProps {\n fallback?: ReactNode | ((error: Error) => ReactNode);\n children: ReactNode;\n /**\n * Optional override for the SDK client. When omitted, uses getClient() from\n * the global singleton (works even if InstantTasksProvider is not an ancestor).\n */\n client?: { errors?: { notify(err: Error, meta?: Record<string, unknown>): void } } | null;\n}\n\ninterface State {\n caught: boolean;\n error: Error | null;\n}\n\n/**\n * Sentry-style class error boundary.\n *\n * Must be a class component — React does not support functional error\n * boundaries as of React 18/19 (no hook equivalent for componentDidCatch).\n */\nexport class ErrorBoundary extends Component<ErrorBoundaryProps, State> {\n static getDerivedStateFromError(error: Error): State {\n return { caught: true, error };\n }\n\n state: State = { caught: false, error: null };\n\n componentDidCatch(error: Error, info: ErrorInfo) {\n const client = this.props.client ?? getClient();\n // Phase B (sdk-errors) attaches an `errors` sub-client; fall back to raw\n // send if not yet available.\n if (client && typeof (client as any).errors?.notify === 'function') {\n (client as any).errors.notify(error, {\n componentStack: info.componentStack ?? undefined,\n });\n } else if (client) {\n // Best-effort: emit an event directly so the base transport captures it.\n (client as any).send?.({\n kind: 'error',\n message: error.message,\n stack: error.stack,\n componentStack: info.componentStack ?? undefined,\n }).catch(() => {/* ignore send failure inside boundary */});\n }\n }\n\n render() {\n if (this.state.caught && this.state.error) {\n const { fallback } = this.props;\n if (typeof fallback === 'function') return fallback(this.state.error);\n if (fallback != null) return fallback;\n return null;\n }\n return this.props.children;\n }\n}\n","import { useContext } from 'react';\nimport { InstantTasksContext } from './context';\nimport type { Client } from '@koderlabs/tasks-sdk';\n\nexport interface UseInstantTasksResult {\n client: Client | null;\n /**\n * `reporter` sub-client (provided by @koderlabs/tasks-sdk-web-reporter integration).\n * Typed as `any` in v1 — strongly typed once Phase E ships.\n * Aliased as `widget` for backwards compatibility — prefer `reporter`.\n */\n reporter: any | null;\n /** @deprecated Renamed to `reporter`. Will be removed in v1. */\n widget: any | null;\n /**\n * `errors` sub-client (provided by @koderlabs/tasks-sdk-web-errors integration).\n */\n errors: any | null;\n /**\n * `network` sub-client (provided by @koderlabs/tasks-sdk-web-network integration).\n */\n network: any | null;\n}\n\n/**\n * Returns the SDK client and any registered sub-clients from the nearest\n * `<InstantTasksProvider>` ancestor.\n *\n * Throws if called outside a provider (helps catch misconfiguration early).\n */\nexport function useInstantTasks(): UseInstantTasksResult {\n const ctx = useContext(InstantTasksContext);\n\n // Derive sub-clients from integrations stored on the client options/emit bus.\n // Integrations register themselves via client.on / client.emit in Phase B/C.\n const c = ctx.client as any;\n\n const reporter = c?.reporter ?? c?.widget ?? null;\n return {\n client: ctx.client,\n reporter,\n widget: reporter,\n errors: c?.errors ?? null,\n network: c?.network ?? null,\n };\n}\n","import { useEffect } from 'react';\nimport type { InitOptions } from '@koderlabs/tasks-sdk';\nimport { useInstantTasks } from './useInstantTasks';\n\ntype UserIdentity = InitOptions['user'];\n\n/**\n * Calls `client.setUser(user)` whenever the `user` argument changes identity.\n *\n * Comparison is shallow-by-reference on the object itself. Callers should\n * memoize the user object (e.g. `useMemo`) or pass a stable reference to\n * avoid unnecessary re-identifies.\n *\n * @example\n * ```tsx\n * const user = useMemo(() => ({ id: session.userId, email: session.email }), [session]);\n * useUser(user);\n * ```\n */\nexport function useUser(user: UserIdentity | undefined): void {\n const { client } = useInstantTasks();\n\n useEffect(() => {\n if (!client || !user) return;\n client.setUser(user);\n }, [client, user]);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,gBAA4C;AAC5C,uBAAqB;;;ACDrB,mBAA8B;AAOvB,IAAM,0BAAsB,4BAAwC;AAAA,EACzE,QAAQ;AACV,CAAC;;;ADiDG;AAhDJ,IAAM,YAAY,OAAO,WAAW;AAiB7B,SAAS,qBAAqB,EAAE,SAAS,SAAS,GAA8B;AACrF,QAAM,CAAC,QAAQ,SAAS,QAAI,wBAAwB,MAAM;AACxD,QAAI,CAAC,UAAW,QAAO;AACvB,QAAI;AAAE,iBAAO,uBAAK,OAAO;AAAA,IAAG,QACtB;AAAE,aAAO;AAAA,IAAM;AAAA,EACvB,CAAC;AAID,QAAM,gBAAY,sBAAsB,MAAM;AAC9C,YAAU,UAAU;AAEpB,+BAAU,MAAM;AAEd,QAAI,CAAC,UAAU,WAAW,WAAW;AACnC,UAAI;AACF,cAAM,QAAI,uBAAK,OAAO;AACtB,kBAAU,UAAU;AACpB,kBAAU,CAAC;AAAA,MACb,QAAQ;AAAA,MAAqC;AAAA,IAC/C;AACA,WAAO,MAAM;AACX,YAAM,IAAI,UAAU;AACpB,UAAI,EAAG,GAAE,KAAK,QAAQ;AAAA,IACxB;AAAA,EAIF,GAAG,CAAC,CAAC;AAEL,SACE,4CAAC,oBAAoB,UAApB,EAA6B,OAAO,EAAE,OAAO,GAC3C,UACH;AAEJ;;;AE9DA,IAAAC,gBAA0B;AAE1B,IAAAC,oBAA0B;AAuBnB,IAAM,gBAAN,cAA4B,wBAAqC;AAAA,EAAjE;AAAA;AAKL,iBAAe,EAAE,QAAQ,OAAO,OAAO,KAAK;AAAA;AAAA,EAJ5C,OAAO,yBAAyB,OAAqB;AACnD,WAAO,EAAE,QAAQ,MAAM,MAAM;AAAA,EAC/B;AAAA,EAIA,kBAAkB,OAAc,MAAiB;AAC/C,UAAM,SAAS,KAAK,MAAM,cAAU,6BAAU;AAG9C,QAAI,UAAU,OAAQ,OAAe,QAAQ,WAAW,YAAY;AAClE,MAAC,OAAe,OAAO,OAAO,OAAO;AAAA,QACnC,gBAAgB,KAAK,kBAAkB;AAAA,MACzC,CAAC;AAAA,IACH,WAAW,QAAQ;AAEjB,MAAC,OAAe,OAAO;AAAA,QACrB,MAAM;AAAA,QACN,SAAS,MAAM;AAAA,QACf,OAAO,MAAM;AAAA,QACb,gBAAgB,KAAK,kBAAkB;AAAA,MACzC,CAAC,EAAE,MAAM,MAAM;AAAA,MAA0C,CAAC;AAAA,IAC5D;AAAA,EACF;AAAA,EAEA,SAAS;AACP,QAAI,KAAK,MAAM,UAAU,KAAK,MAAM,OAAO;AACzC,YAAM,EAAE,SAAS,IAAI,KAAK;AAC1B,UAAI,OAAO,aAAa,WAAY,QAAO,SAAS,KAAK,MAAM,KAAK;AACpE,UAAI,YAAY,KAAM,QAAO;AAC7B,aAAO;AAAA,IACT;AACA,WAAO,KAAK,MAAM;AAAA,EACpB;AACF;;;AC5DA,IAAAC,gBAA2B;AA8BpB,SAAS,kBAAyC;AACvD,QAAM,UAAM,0BAAW,mBAAmB;AAI1C,QAAM,IAAI,IAAI;AAEd,QAAM,WAAW,GAAG,YAAY,GAAG,UAAU;AAC7C,SAAO;AAAA,IACL,QAAQ,IAAI;AAAA,IACZ;AAAA,IACA,QAAQ;AAAA,IACR,QAAQ,GAAG,UAAU;AAAA,IACrB,SAAS,GAAG,WAAW;AAAA,EACzB;AACF;;;AC7CA,IAAAC,gBAA0B;AAmBnB,SAAS,QAAQ,MAAsC;AAC5D,QAAM,EAAE,OAAO,IAAI,gBAAgB;AAEnC,+BAAU,MAAM;AACd,QAAI,CAAC,UAAU,CAAC,KAAM;AACtB,WAAO,QAAQ,IAAI;AAAA,EACrB,GAAG,CAAC,QAAQ,IAAI,CAAC;AACnB;","names":["import_react","import_react","import_tasks_sdk","import_react","import_react"]}
@@ -0,0 +1,105 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { InitOptions, Client } from '@koderlabs/tasks-sdk';
3
+ import * as react from 'react';
4
+ import { Component, ReactNode, ErrorInfo } from 'react';
5
+
6
+ interface InstantTasksProviderProps {
7
+ options: InitOptions;
8
+ children: React.ReactNode;
9
+ }
10
+ /**
11
+ * Initialises the InstantTasks SDK at mount and tears it down on unmount.
12
+ *
13
+ * Behaviour:
14
+ * - **Browser mount**: client is created via a `useState` lazy initialiser
15
+ * so consumers in the same paint see a real Client (no null window).
16
+ * - **SSR / RSC**: lazy init returns `null` (no `window`). A browser-only
17
+ * `useEffect` then initialises and surfaces the client via state.
18
+ * - **StrictMode double-mount (dev)**: the underlying `init()` is idempotent
19
+ * — calling it again tears the prior client down (see `sdk/src/index.ts`)
20
+ * and returns a fresh one. Production runs `init()` exactly once.
21
+ *
22
+ * Init errors (invalid endpoint, bad projectId) are NOT fatal to render —
23
+ * the host app continues without telemetry rather than crash.
24
+ */
25
+ declare function InstantTasksProvider({ options, children }: InstantTasksProviderProps): react_jsx_runtime.JSX.Element;
26
+
27
+ interface ErrorBoundaryProps {
28
+ fallback?: ReactNode | ((error: Error) => ReactNode);
29
+ children: ReactNode;
30
+ /**
31
+ * Optional override for the SDK client. When omitted, uses getClient() from
32
+ * the global singleton (works even if InstantTasksProvider is not an ancestor).
33
+ */
34
+ client?: {
35
+ errors?: {
36
+ notify(err: Error, meta?: Record<string, unknown>): void;
37
+ };
38
+ } | null;
39
+ }
40
+ interface State {
41
+ caught: boolean;
42
+ error: Error | null;
43
+ }
44
+ /**
45
+ * Sentry-style class error boundary.
46
+ *
47
+ * Must be a class component — React does not support functional error
48
+ * boundaries as of React 18/19 (no hook equivalent for componentDidCatch).
49
+ */
50
+ declare class ErrorBoundary extends Component<ErrorBoundaryProps, State> {
51
+ static getDerivedStateFromError(error: Error): State;
52
+ state: State;
53
+ componentDidCatch(error: Error, info: ErrorInfo): void;
54
+ render(): ReactNode;
55
+ }
56
+
57
+ interface UseInstantTasksResult {
58
+ client: Client | null;
59
+ /**
60
+ * `reporter` sub-client (provided by @koderlabs/tasks-sdk-web-reporter integration).
61
+ * Typed as `any` in v1 — strongly typed once Phase E ships.
62
+ * Aliased as `widget` for backwards compatibility — prefer `reporter`.
63
+ */
64
+ reporter: any | null;
65
+ /** @deprecated Renamed to `reporter`. Will be removed in v1. */
66
+ widget: any | null;
67
+ /**
68
+ * `errors` sub-client (provided by @koderlabs/tasks-sdk-web-errors integration).
69
+ */
70
+ errors: any | null;
71
+ /**
72
+ * `network` sub-client (provided by @koderlabs/tasks-sdk-web-network integration).
73
+ */
74
+ network: any | null;
75
+ }
76
+ /**
77
+ * Returns the SDK client and any registered sub-clients from the nearest
78
+ * `<InstantTasksProvider>` ancestor.
79
+ *
80
+ * Throws if called outside a provider (helps catch misconfiguration early).
81
+ */
82
+ declare function useInstantTasks(): UseInstantTasksResult;
83
+
84
+ type UserIdentity = InitOptions['user'];
85
+ /**
86
+ * Calls `client.setUser(user)` whenever the `user` argument changes identity.
87
+ *
88
+ * Comparison is shallow-by-reference on the object itself. Callers should
89
+ * memoize the user object (e.g. `useMemo`) or pass a stable reference to
90
+ * avoid unnecessary re-identifies.
91
+ *
92
+ * @example
93
+ * ```tsx
94
+ * const user = useMemo(() => ({ id: session.userId, email: session.email }), [session]);
95
+ * useUser(user);
96
+ * ```
97
+ */
98
+ declare function useUser(user: UserIdentity | undefined): void;
99
+
100
+ interface InstantTasksContextValue {
101
+ client: Client | null;
102
+ }
103
+ declare const InstantTasksContext: react.Context<InstantTasksContextValue>;
104
+
105
+ export { ErrorBoundary, type ErrorBoundaryProps, InstantTasksContext, type InstantTasksContextValue, InstantTasksProvider, type InstantTasksProviderProps, type UseInstantTasksResult, useInstantTasks, useUser };
@@ -0,0 +1,105 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { InitOptions, Client } from '@koderlabs/tasks-sdk';
3
+ import * as react from 'react';
4
+ import { Component, ReactNode, ErrorInfo } from 'react';
5
+
6
+ interface InstantTasksProviderProps {
7
+ options: InitOptions;
8
+ children: React.ReactNode;
9
+ }
10
+ /**
11
+ * Initialises the InstantTasks SDK at mount and tears it down on unmount.
12
+ *
13
+ * Behaviour:
14
+ * - **Browser mount**: client is created via a `useState` lazy initialiser
15
+ * so consumers in the same paint see a real Client (no null window).
16
+ * - **SSR / RSC**: lazy init returns `null` (no `window`). A browser-only
17
+ * `useEffect` then initialises and surfaces the client via state.
18
+ * - **StrictMode double-mount (dev)**: the underlying `init()` is idempotent
19
+ * — calling it again tears the prior client down (see `sdk/src/index.ts`)
20
+ * and returns a fresh one. Production runs `init()` exactly once.
21
+ *
22
+ * Init errors (invalid endpoint, bad projectId) are NOT fatal to render —
23
+ * the host app continues without telemetry rather than crash.
24
+ */
25
+ declare function InstantTasksProvider({ options, children }: InstantTasksProviderProps): react_jsx_runtime.JSX.Element;
26
+
27
+ interface ErrorBoundaryProps {
28
+ fallback?: ReactNode | ((error: Error) => ReactNode);
29
+ children: ReactNode;
30
+ /**
31
+ * Optional override for the SDK client. When omitted, uses getClient() from
32
+ * the global singleton (works even if InstantTasksProvider is not an ancestor).
33
+ */
34
+ client?: {
35
+ errors?: {
36
+ notify(err: Error, meta?: Record<string, unknown>): void;
37
+ };
38
+ } | null;
39
+ }
40
+ interface State {
41
+ caught: boolean;
42
+ error: Error | null;
43
+ }
44
+ /**
45
+ * Sentry-style class error boundary.
46
+ *
47
+ * Must be a class component — React does not support functional error
48
+ * boundaries as of React 18/19 (no hook equivalent for componentDidCatch).
49
+ */
50
+ declare class ErrorBoundary extends Component<ErrorBoundaryProps, State> {
51
+ static getDerivedStateFromError(error: Error): State;
52
+ state: State;
53
+ componentDidCatch(error: Error, info: ErrorInfo): void;
54
+ render(): ReactNode;
55
+ }
56
+
57
+ interface UseInstantTasksResult {
58
+ client: Client | null;
59
+ /**
60
+ * `reporter` sub-client (provided by @koderlabs/tasks-sdk-web-reporter integration).
61
+ * Typed as `any` in v1 — strongly typed once Phase E ships.
62
+ * Aliased as `widget` for backwards compatibility — prefer `reporter`.
63
+ */
64
+ reporter: any | null;
65
+ /** @deprecated Renamed to `reporter`. Will be removed in v1. */
66
+ widget: any | null;
67
+ /**
68
+ * `errors` sub-client (provided by @koderlabs/tasks-sdk-web-errors integration).
69
+ */
70
+ errors: any | null;
71
+ /**
72
+ * `network` sub-client (provided by @koderlabs/tasks-sdk-web-network integration).
73
+ */
74
+ network: any | null;
75
+ }
76
+ /**
77
+ * Returns the SDK client and any registered sub-clients from the nearest
78
+ * `<InstantTasksProvider>` ancestor.
79
+ *
80
+ * Throws if called outside a provider (helps catch misconfiguration early).
81
+ */
82
+ declare function useInstantTasks(): UseInstantTasksResult;
83
+
84
+ type UserIdentity = InitOptions['user'];
85
+ /**
86
+ * Calls `client.setUser(user)` whenever the `user` argument changes identity.
87
+ *
88
+ * Comparison is shallow-by-reference on the object itself. Callers should
89
+ * memoize the user object (e.g. `useMemo`) or pass a stable reference to
90
+ * avoid unnecessary re-identifies.
91
+ *
92
+ * @example
93
+ * ```tsx
94
+ * const user = useMemo(() => ({ id: session.userId, email: session.email }), [session]);
95
+ * useUser(user);
96
+ * ```
97
+ */
98
+ declare function useUser(user: UserIdentity | undefined): void;
99
+
100
+ interface InstantTasksContextValue {
101
+ client: Client | null;
102
+ }
103
+ declare const InstantTasksContext: react.Context<InstantTasksContextValue>;
104
+
105
+ export { ErrorBoundary, type ErrorBoundaryProps, InstantTasksContext, type InstantTasksContextValue, InstantTasksProvider, type InstantTasksProviderProps, type UseInstantTasksResult, useInstantTasks, useUser };
package/dist/index.js ADDED
@@ -0,0 +1,111 @@
1
+ // src/InstantTasksProvider.tsx
2
+ import { useEffect, useRef, useState } from "react";
3
+ import { init } from "@koderlabs/tasks-sdk";
4
+
5
+ // src/context.ts
6
+ import { createContext } from "react";
7
+ var InstantTasksContext = createContext({
8
+ client: null
9
+ });
10
+
11
+ // src/InstantTasksProvider.tsx
12
+ import { jsx } from "react/jsx-runtime";
13
+ var isBrowser = typeof window !== "undefined";
14
+ function InstantTasksProvider({ options, children }) {
15
+ const [client, setClient] = useState(() => {
16
+ if (!isBrowser) return null;
17
+ try {
18
+ return init(options);
19
+ } catch {
20
+ return null;
21
+ }
22
+ });
23
+ const clientRef = useRef(client);
24
+ clientRef.current = client;
25
+ useEffect(() => {
26
+ if (!clientRef.current && isBrowser) {
27
+ try {
28
+ const c = init(options);
29
+ clientRef.current = c;
30
+ setClient(c);
31
+ } catch {
32
+ }
33
+ }
34
+ return () => {
35
+ const c = clientRef.current;
36
+ if (c) c.emit("unload");
37
+ };
38
+ }, []);
39
+ return /* @__PURE__ */ jsx(InstantTasksContext.Provider, { value: { client }, children });
40
+ }
41
+
42
+ // src/ErrorBoundary.tsx
43
+ import { Component } from "react";
44
+ import { getClient } from "@koderlabs/tasks-sdk";
45
+ var ErrorBoundary = class extends Component {
46
+ constructor() {
47
+ super(...arguments);
48
+ this.state = { caught: false, error: null };
49
+ }
50
+ static getDerivedStateFromError(error) {
51
+ return { caught: true, error };
52
+ }
53
+ componentDidCatch(error, info) {
54
+ const client = this.props.client ?? getClient();
55
+ if (client && typeof client.errors?.notify === "function") {
56
+ client.errors.notify(error, {
57
+ componentStack: info.componentStack ?? void 0
58
+ });
59
+ } else if (client) {
60
+ client.send?.({
61
+ kind: "error",
62
+ message: error.message,
63
+ stack: error.stack,
64
+ componentStack: info.componentStack ?? void 0
65
+ }).catch(() => {
66
+ });
67
+ }
68
+ }
69
+ render() {
70
+ if (this.state.caught && this.state.error) {
71
+ const { fallback } = this.props;
72
+ if (typeof fallback === "function") return fallback(this.state.error);
73
+ if (fallback != null) return fallback;
74
+ return null;
75
+ }
76
+ return this.props.children;
77
+ }
78
+ };
79
+
80
+ // src/useInstantTasks.ts
81
+ import { useContext } from "react";
82
+ function useInstantTasks() {
83
+ const ctx = useContext(InstantTasksContext);
84
+ const c = ctx.client;
85
+ const reporter = c?.reporter ?? c?.widget ?? null;
86
+ return {
87
+ client: ctx.client,
88
+ reporter,
89
+ widget: reporter,
90
+ errors: c?.errors ?? null,
91
+ network: c?.network ?? null
92
+ };
93
+ }
94
+
95
+ // src/useUser.ts
96
+ import { useEffect as useEffect2 } from "react";
97
+ function useUser(user) {
98
+ const { client } = useInstantTasks();
99
+ useEffect2(() => {
100
+ if (!client || !user) return;
101
+ client.setUser(user);
102
+ }, [client, user]);
103
+ }
104
+ export {
105
+ ErrorBoundary,
106
+ InstantTasksContext,
107
+ InstantTasksProvider,
108
+ useInstantTasks,
109
+ useUser
110
+ };
111
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/InstantTasksProvider.tsx","../src/context.ts","../src/ErrorBoundary.tsx","../src/useInstantTasks.ts","../src/useUser.ts"],"sourcesContent":["import { useEffect, useRef, useState } from 'react';\nimport { init } from '@koderlabs/tasks-sdk';\nimport type { InitOptions, Client } from '@koderlabs/tasks-sdk';\nimport { InstantTasksContext } from './context';\n\nexport interface InstantTasksProviderProps {\n options: InitOptions;\n children: React.ReactNode;\n}\n\nconst isBrowser = typeof window !== 'undefined';\n\n/**\n * Initialises the InstantTasks SDK at mount and tears it down on unmount.\n *\n * Behaviour:\n * - **Browser mount**: client is created via a `useState` lazy initialiser\n * so consumers in the same paint see a real Client (no null window).\n * - **SSR / RSC**: lazy init returns `null` (no `window`). A browser-only\n * `useEffect` then initialises and surfaces the client via state.\n * - **StrictMode double-mount (dev)**: the underlying `init()` is idempotent\n * — calling it again tears the prior client down (see `sdk/src/index.ts`)\n * and returns a fresh one. Production runs `init()` exactly once.\n *\n * Init errors (invalid endpoint, bad projectId) are NOT fatal to render —\n * the host app continues without telemetry rather than crash.\n */\nexport function InstantTasksProvider({ options, children }: InstantTasksProviderProps) {\n const [client, setClient] = useState<Client | null>(() => {\n if (!isBrowser) return null;\n try { return init(options); }\n catch { return null; }\n });\n // Capture the most recent client in a ref so cleanup always sees the live\n // instance — without this, StrictMode's effect ↔ cleanup ↔ effect dance can\n // race state updates.\n const clientRef = useRef<Client | null>(client);\n clientRef.current = client;\n\n useEffect(() => {\n // SSR hydration path: lazy init returned null on the server. Try again now.\n if (!clientRef.current && isBrowser) {\n try {\n const c = init(options);\n clientRef.current = c;\n setClient(c);\n } catch { /* host stays without telemetry */ }\n }\n return () => {\n const c = clientRef.current;\n if (c) c.emit('unload');\n };\n // Re-init on options change is intentionally NOT supported — memoize\n // options upstream or use setUser / setCustomData for runtime updates.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n return (\n <InstantTasksContext.Provider value={{ client }}>\n {children}\n </InstantTasksContext.Provider>\n );\n}\n","import { createContext } from 'react';\nimport type { Client } from '@koderlabs/tasks-sdk';\n\nexport interface InstantTasksContextValue {\n client: Client | null;\n}\n\nexport const InstantTasksContext = createContext<InstantTasksContextValue>({\n client: null,\n});\n","import { Component } from 'react';\nimport type { ErrorInfo, ReactNode } from 'react';\nimport { getClient } from '@koderlabs/tasks-sdk';\n\nexport interface ErrorBoundaryProps {\n fallback?: ReactNode | ((error: Error) => ReactNode);\n children: ReactNode;\n /**\n * Optional override for the SDK client. When omitted, uses getClient() from\n * the global singleton (works even if InstantTasksProvider is not an ancestor).\n */\n client?: { errors?: { notify(err: Error, meta?: Record<string, unknown>): void } } | null;\n}\n\ninterface State {\n caught: boolean;\n error: Error | null;\n}\n\n/**\n * Sentry-style class error boundary.\n *\n * Must be a class component — React does not support functional error\n * boundaries as of React 18/19 (no hook equivalent for componentDidCatch).\n */\nexport class ErrorBoundary extends Component<ErrorBoundaryProps, State> {\n static getDerivedStateFromError(error: Error): State {\n return { caught: true, error };\n }\n\n state: State = { caught: false, error: null };\n\n componentDidCatch(error: Error, info: ErrorInfo) {\n const client = this.props.client ?? getClient();\n // Phase B (sdk-errors) attaches an `errors` sub-client; fall back to raw\n // send if not yet available.\n if (client && typeof (client as any).errors?.notify === 'function') {\n (client as any).errors.notify(error, {\n componentStack: info.componentStack ?? undefined,\n });\n } else if (client) {\n // Best-effort: emit an event directly so the base transport captures it.\n (client as any).send?.({\n kind: 'error',\n message: error.message,\n stack: error.stack,\n componentStack: info.componentStack ?? undefined,\n }).catch(() => {/* ignore send failure inside boundary */});\n }\n }\n\n render() {\n if (this.state.caught && this.state.error) {\n const { fallback } = this.props;\n if (typeof fallback === 'function') return fallback(this.state.error);\n if (fallback != null) return fallback;\n return null;\n }\n return this.props.children;\n }\n}\n","import { useContext } from 'react';\nimport { InstantTasksContext } from './context';\nimport type { Client } from '@koderlabs/tasks-sdk';\n\nexport interface UseInstantTasksResult {\n client: Client | null;\n /**\n * `reporter` sub-client (provided by @koderlabs/tasks-sdk-web-reporter integration).\n * Typed as `any` in v1 — strongly typed once Phase E ships.\n * Aliased as `widget` for backwards compatibility — prefer `reporter`.\n */\n reporter: any | null;\n /** @deprecated Renamed to `reporter`. Will be removed in v1. */\n widget: any | null;\n /**\n * `errors` sub-client (provided by @koderlabs/tasks-sdk-web-errors integration).\n */\n errors: any | null;\n /**\n * `network` sub-client (provided by @koderlabs/tasks-sdk-web-network integration).\n */\n network: any | null;\n}\n\n/**\n * Returns the SDK client and any registered sub-clients from the nearest\n * `<InstantTasksProvider>` ancestor.\n *\n * Throws if called outside a provider (helps catch misconfiguration early).\n */\nexport function useInstantTasks(): UseInstantTasksResult {\n const ctx = useContext(InstantTasksContext);\n\n // Derive sub-clients from integrations stored on the client options/emit bus.\n // Integrations register themselves via client.on / client.emit in Phase B/C.\n const c = ctx.client as any;\n\n const reporter = c?.reporter ?? c?.widget ?? null;\n return {\n client: ctx.client,\n reporter,\n widget: reporter,\n errors: c?.errors ?? null,\n network: c?.network ?? null,\n };\n}\n","import { useEffect } from 'react';\nimport type { InitOptions } from '@koderlabs/tasks-sdk';\nimport { useInstantTasks } from './useInstantTasks';\n\ntype UserIdentity = InitOptions['user'];\n\n/**\n * Calls `client.setUser(user)` whenever the `user` argument changes identity.\n *\n * Comparison is shallow-by-reference on the object itself. Callers should\n * memoize the user object (e.g. `useMemo`) or pass a stable reference to\n * avoid unnecessary re-identifies.\n *\n * @example\n * ```tsx\n * const user = useMemo(() => ({ id: session.userId, email: session.email }), [session]);\n * useUser(user);\n * ```\n */\nexport function useUser(user: UserIdentity | undefined): void {\n const { client } = useInstantTasks();\n\n useEffect(() => {\n if (!client || !user) return;\n client.setUser(user);\n }, [client, user]);\n}\n"],"mappings":";AAAA,SAAS,WAAW,QAAQ,gBAAgB;AAC5C,SAAS,YAAY;;;ACDrB,SAAS,qBAAqB;AAOvB,IAAM,sBAAsB,cAAwC;AAAA,EACzE,QAAQ;AACV,CAAC;;;ADiDG;AAhDJ,IAAM,YAAY,OAAO,WAAW;AAiB7B,SAAS,qBAAqB,EAAE,SAAS,SAAS,GAA8B;AACrF,QAAM,CAAC,QAAQ,SAAS,IAAI,SAAwB,MAAM;AACxD,QAAI,CAAC,UAAW,QAAO;AACvB,QAAI;AAAE,aAAO,KAAK,OAAO;AAAA,IAAG,QACtB;AAAE,aAAO;AAAA,IAAM;AAAA,EACvB,CAAC;AAID,QAAM,YAAY,OAAsB,MAAM;AAC9C,YAAU,UAAU;AAEpB,YAAU,MAAM;AAEd,QAAI,CAAC,UAAU,WAAW,WAAW;AACnC,UAAI;AACF,cAAM,IAAI,KAAK,OAAO;AACtB,kBAAU,UAAU;AACpB,kBAAU,CAAC;AAAA,MACb,QAAQ;AAAA,MAAqC;AAAA,IAC/C;AACA,WAAO,MAAM;AACX,YAAM,IAAI,UAAU;AACpB,UAAI,EAAG,GAAE,KAAK,QAAQ;AAAA,IACxB;AAAA,EAIF,GAAG,CAAC,CAAC;AAEL,SACE,oBAAC,oBAAoB,UAApB,EAA6B,OAAO,EAAE,OAAO,GAC3C,UACH;AAEJ;;;AE9DA,SAAS,iBAAiB;AAE1B,SAAS,iBAAiB;AAuBnB,IAAM,gBAAN,cAA4B,UAAqC;AAAA,EAAjE;AAAA;AAKL,iBAAe,EAAE,QAAQ,OAAO,OAAO,KAAK;AAAA;AAAA,EAJ5C,OAAO,yBAAyB,OAAqB;AACnD,WAAO,EAAE,QAAQ,MAAM,MAAM;AAAA,EAC/B;AAAA,EAIA,kBAAkB,OAAc,MAAiB;AAC/C,UAAM,SAAS,KAAK,MAAM,UAAU,UAAU;AAG9C,QAAI,UAAU,OAAQ,OAAe,QAAQ,WAAW,YAAY;AAClE,MAAC,OAAe,OAAO,OAAO,OAAO;AAAA,QACnC,gBAAgB,KAAK,kBAAkB;AAAA,MACzC,CAAC;AAAA,IACH,WAAW,QAAQ;AAEjB,MAAC,OAAe,OAAO;AAAA,QACrB,MAAM;AAAA,QACN,SAAS,MAAM;AAAA,QACf,OAAO,MAAM;AAAA,QACb,gBAAgB,KAAK,kBAAkB;AAAA,MACzC,CAAC,EAAE,MAAM,MAAM;AAAA,MAA0C,CAAC;AAAA,IAC5D;AAAA,EACF;AAAA,EAEA,SAAS;AACP,QAAI,KAAK,MAAM,UAAU,KAAK,MAAM,OAAO;AACzC,YAAM,EAAE,SAAS,IAAI,KAAK;AAC1B,UAAI,OAAO,aAAa,WAAY,QAAO,SAAS,KAAK,MAAM,KAAK;AACpE,UAAI,YAAY,KAAM,QAAO;AAC7B,aAAO;AAAA,IACT;AACA,WAAO,KAAK,MAAM;AAAA,EACpB;AACF;;;AC5DA,SAAS,kBAAkB;AA8BpB,SAAS,kBAAyC;AACvD,QAAM,MAAM,WAAW,mBAAmB;AAI1C,QAAM,IAAI,IAAI;AAEd,QAAM,WAAW,GAAG,YAAY,GAAG,UAAU;AAC7C,SAAO;AAAA,IACL,QAAQ,IAAI;AAAA,IACZ;AAAA,IACA,QAAQ;AAAA,IACR,QAAQ,GAAG,UAAU;AAAA,IACrB,SAAS,GAAG,WAAW;AAAA,EACzB;AACF;;;AC7CA,SAAS,aAAAA,kBAAiB;AAmBnB,SAAS,QAAQ,MAAsC;AAC5D,QAAM,EAAE,OAAO,IAAI,gBAAgB;AAEnC,EAAAC,WAAU,MAAM;AACd,QAAI,CAAC,UAAU,CAAC,KAAM;AACtB,WAAO,QAAQ,IAAI;AAAA,EACrB,GAAG,CAAC,QAAQ,IAAI,CAAC;AACnB;","names":["useEffect","useEffect"]}
package/package.json ADDED
@@ -0,0 +1,72 @@
1
+ {
2
+ "name": "@koderlabs/tasks-sdk-react",
3
+ "version": "0.1.0",
4
+ "description": "React Provider + hooks for the InstantTasks SDK.",
5
+ "keywords": [
6
+ "instanttasks",
7
+ "sdk",
8
+ "react"
9
+ ],
10
+ "homepage": "https://github.com/jawaidgadiwala/instant-tasks/tree/main/packages/sdk-react#readme",
11
+ "bugs": {
12
+ "url": "https://github.com/jawaidgadiwala/instant-tasks/issues"
13
+ },
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git+https://github.com/jawaidgadiwala/instant-tasks.git",
17
+ "directory": "packages/sdk-react"
18
+ },
19
+ "license": "UNLICENSED",
20
+ "author": {
21
+ "name": "Jawaid Gadiwala",
22
+ "email": "jawaidgadiwala@gmail.com",
23
+ "url": "https://koderlabs.com"
24
+ },
25
+ "type": "module",
26
+ "main": "./dist/index.cjs",
27
+ "module": "./dist/index.js",
28
+ "types": "./dist/index.d.ts",
29
+ "exports": {
30
+ ".": {
31
+ "types": "./dist/index.d.ts",
32
+ "import": "./dist/index.js",
33
+ "require": "./dist/index.cjs"
34
+ }
35
+ },
36
+ "files": [
37
+ "dist",
38
+ "LICENSE"
39
+ ],
40
+ "sideEffects": false,
41
+ "dependencies": {
42
+ "@koderlabs/tasks-sdk": "0.1.0"
43
+ },
44
+ "peerDependencies": {
45
+ "react": "^18 || ^19",
46
+ "react-dom": "^18 || ^19"
47
+ },
48
+ "devDependencies": {
49
+ "@testing-library/react": "^16.0.0",
50
+ "@testing-library/user-event": "^14.5.0",
51
+ "@types/react": "^18.3.0",
52
+ "@types/react-dom": "^18.3.0",
53
+ "jsdom": "^25.0.0",
54
+ "react": "^18.3.0",
55
+ "react-dom": "^18.3.0",
56
+ "tsup": "^8.3.0",
57
+ "typescript": "^5.5.0",
58
+ "vitest": "^2.1.0"
59
+ },
60
+ "engines": {
61
+ "node": ">=20"
62
+ },
63
+ "publishConfig": {
64
+ "access": "restricted"
65
+ },
66
+ "scripts": {
67
+ "build": "tsup",
68
+ "dev": "tsup --watch",
69
+ "test": "vitest run",
70
+ "test:watch": "vitest"
71
+ }
72
+ }