@assistant-ui/tap 0.6.0 → 0.6.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.
@@ -7,7 +7,7 @@ import { useEffect } from "../hooks/useEffect.js";
7
7
  import { useEffectEvent } from "../hooks/useEffectEvent.js";
8
8
  import { use } from "../hooks/use.js";
9
9
  import { useMemoCache } from "../hooks/useMemoCache.js";
10
- import * as React from "react";
10
+ import React from "react";
11
11
  //#region src/core/react-dispatcher.ts
12
12
  const tapDispatcher = {
13
13
  useState: useState$1,
@@ -23,7 +23,8 @@ const tapDispatcher = {
23
23
  use,
24
24
  useMemoCache
25
25
  };
26
- const internals = React.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE ?? React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
26
+ const ReactRuntime = React;
27
+ const internals = ReactRuntime.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE ?? ReactRuntime.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
27
28
  const slot = internals == null ? null : "H" in internals ? {
28
29
  get current() {
29
30
  return internals.H;
@@ -1 +1 @@
1
- {"version":3,"file":"react-dispatcher.js","names":[],"sources":["../../src/core/react-dispatcher.ts"],"sourcesContent":["import * as React from \"react\";\nimport { useState } from \"../hooks/useState\";\nimport { useReducer } from \"../hooks/useReducer\";\nimport { useRef } from \"../hooks/useRef\";\nimport { useMemo } from \"../hooks/useMemo\";\nimport { useCallback } from \"../hooks/useCallback\";\nimport { useEffect } from \"../hooks/useEffect\";\nimport { useEffectEvent } from \"../hooks/useEffectEvent\";\nimport { use } from \"../hooks/use\";\nimport { useMemoCache } from \"../hooks/useMemoCache\";\n\n// The dispatcher React reads while a resource renders, so hooks imported from\n// \"react\" route to tap with no build step. Hooks tap has no equivalent for are\n// intentionally absent: calling one throws, which is the intended \"unsupported\n// in a resource\" signal.\nconst tapDispatcher = {\n useState,\n useReducer,\n useRef,\n useMemo,\n useCallback,\n useEffect,\n useLayoutEffect: useEffect,\n useInsertionEffect: useEffect,\n useEffectEvent,\n useContext: use,\n use,\n useMemoCache,\n};\n\n// React's live dispatcher slot differs by version: React 19 exposes it as `H` on\n// the client internals object; React 18 as `ReactCurrentDispatcher.current`.\nconst internals =\n (React as any)\n .__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE ??\n (React as any).__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;\n\nconst slot: { current: unknown } | null =\n internals == null\n ? null\n : \"H\" in internals\n ? {\n get current() {\n return internals.H;\n },\n set current(d) {\n internals.H = d;\n },\n }\n : \"ReactCurrentDispatcher\" in internals\n ? {\n get current() {\n return internals.ReactCurrentDispatcher.current;\n },\n set current(d) {\n internals.ReactCurrentDispatcher.current = d;\n },\n }\n : null;\n\n/**\n * Runs a resource body with tap's React dispatcher installed, so real React\n * hooks called inside it (`import { useState } from \"react\"`) route to tap, then\n * restores the previous dispatcher. If React's internal dispatcher slot can't be\n * found (an unsupported React version), the body runs unchanged and `react`\n * hooks inside it keep throwing React's \"invalid hook call\".\n */\nexport function withReactDispatcher<T>(render: () => T): T {\n if (!slot) return render();\n\n const previous = slot.current;\n slot.current = tapDispatcher;\n try {\n return render();\n } finally {\n slot.current = previous;\n }\n}\n"],"mappings":";;;;;;;;;;;AAeA,MAAM,gBAAgB;CACpB,UAAA;CACA,YAAA;CACA,QAAA;CACA,SAAA;CACA;CACA;CACA,iBAAiB;CACjB,oBAAoB;CACpB;CACA,YAAY;CACZ;CACA;AACF;AAIA,MAAM,YACH,MACE,mEACF,MAAc;AAEjB,MAAM,OACJ,aAAa,OACT,OACA,OAAO,YACL;CACE,IAAI,UAAU;EACZ,OAAO,UAAU;CACnB;CACA,IAAI,QAAQ,GAAG;EACb,UAAU,IAAI;CAChB;AACF,IACA,4BAA4B,YAC1B;CACE,IAAI,UAAU;EACZ,OAAO,UAAU,uBAAuB;CAC1C;CACA,IAAI,QAAQ,GAAG;EACb,UAAU,uBAAuB,UAAU;CAC7C;AACF,IACA;;;;;;;;AASV,SAAgB,oBAAuB,QAAoB;CACzD,IAAI,CAAC,MAAM,OAAO,OAAO;CAEzB,MAAM,WAAW,KAAK;CACtB,KAAK,UAAU;CACf,IAAI;EACF,OAAO,OAAO;CAChB,UAAU;EACR,KAAK,UAAU;CACjB;AACF"}
1
+ {"version":3,"file":"react-dispatcher.js","names":[],"sources":["../../src/core/react-dispatcher.ts"],"sourcesContent":["import React from \"react\";\nimport { useState } from \"../hooks/useState\";\nimport { useReducer } from \"../hooks/useReducer\";\nimport { useRef } from \"../hooks/useRef\";\nimport { useMemo } from \"../hooks/useMemo\";\nimport { useCallback } from \"../hooks/useCallback\";\nimport { useEffect } from \"../hooks/useEffect\";\nimport { useEffectEvent } from \"../hooks/useEffectEvent\";\nimport { use } from \"../hooks/use\";\nimport { useMemoCache } from \"../hooks/useMemoCache\";\n\n// The dispatcher React reads while a resource renders, so hooks imported from\n// \"react\" route to tap with no build step. Hooks tap has no equivalent for are\n// intentionally absent: calling one throws, which is the intended \"unsupported\n// in a resource\" signal.\nconst tapDispatcher = {\n useState,\n useReducer,\n useRef,\n useMemo,\n useCallback,\n useEffect,\n useLayoutEffect: useEffect,\n useInsertionEffect: useEffect,\n useEffectEvent,\n useContext: use,\n use,\n useMemoCache,\n};\n\n// React's live dispatcher slot differs by version: React 19 exposes it as `H` on\n// the client internals object; React 18 as `ReactCurrentDispatcher.current`.\nconst ReactRuntime = React as any;\nconst internals =\n ReactRuntime.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE ??\n ReactRuntime.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;\n\nconst slot: { current: unknown } | null =\n internals == null\n ? null\n : \"H\" in internals\n ? {\n get current() {\n return internals.H;\n },\n set current(d) {\n internals.H = d;\n },\n }\n : \"ReactCurrentDispatcher\" in internals\n ? {\n get current() {\n return internals.ReactCurrentDispatcher.current;\n },\n set current(d) {\n internals.ReactCurrentDispatcher.current = d;\n },\n }\n : null;\n\n/**\n * Runs a resource body with tap's React dispatcher installed, so real React\n * hooks called inside it (`import { useState } from \"react\"`) route to tap, then\n * restores the previous dispatcher. If React's internal dispatcher slot can't be\n * found (an unsupported React version), the body runs unchanged and `react`\n * hooks inside it keep throwing React's \"invalid hook call\".\n */\nexport function withReactDispatcher<T>(render: () => T): T {\n if (!slot) return render();\n\n const previous = slot.current;\n slot.current = tapDispatcher;\n try {\n return render();\n } finally {\n slot.current = previous;\n }\n}\n"],"mappings":";;;;;;;;;;;AAeA,MAAM,gBAAgB;CACpB,UAAA;CACA,YAAA;CACA,QAAA;CACA,SAAA;CACA;CACA;CACA,iBAAiB;CACjB,oBAAoB;CACpB;CACA,YAAY;CACZ;CACA;AACF;AAIA,MAAM,eAAe;AACrB,MAAM,YACJ,aAAa,mEACb,aAAa;AAEf,MAAM,OACJ,aAAa,OACT,OACA,OAAO,YACL;CACE,IAAI,UAAU;EACZ,OAAO,UAAU;CACnB;CACA,IAAI,QAAQ,GAAG;EACb,UAAU,IAAI;CAChB;AACF,IACA,4BAA4B,YAC1B;CACE,IAAI,UAAU;EACZ,OAAO,UAAU,uBAAuB;CAC1C;CACA,IAAI,QAAQ,GAAG;EACb,UAAU,uBAAuB,UAAU;CAC7C;AACF,IACA;;;;;;;;AASV,SAAgB,oBAAuB,QAAoB;CACzD,IAAI,CAAC,MAAM,OAAO,OAAO;CAEzB,MAAM,WAAW,KAAK;CACtB,KAAK,UAAU;CACf,IAAI;EACF,OAAO,OAAO;CAChB,UAAU;EACR,KAAK,UAAU;CACjB;AACF"}
@@ -1,19 +1,17 @@
1
- import { useRef as useRef$2 } from "../hooks/useRef.js";
2
- import * as React from "react";
3
1
  import react_default from "react";
4
2
  export * from "react";
5
3
 
6
4
  //#region src/react-shim/index.d.ts
7
- declare const useState: (initialState?: any) => [any, (updater: any) => void];
8
- declare const useReducer: (reducer: any, initialArg: any, init?: any) => [unknown, (action: unknown) => void] | [unknown, React.ActionDispatch<React.AnyActionArg>];
9
- declare const useRef: (initialValue?: any) => useRef$2.RefObject<any>;
10
- declare const useMemo: (factory: any, deps: any) => unknown;
5
+ declare const useState: (initialState?: any) => any;
6
+ declare const useReducer: (reducer: any, initialArg: any, init?: any) => any;
7
+ declare const useRef: (initialValue?: any) => any;
8
+ declare const useMemo: (factory: any, deps: any) => any;
11
9
  declare const useCallback: (callback: any, deps: any) => any;
12
- declare const useEffect: (effect: any, deps?: any) => void;
13
- declare const useLayoutEffect: (effect: any, deps?: any) => void;
10
+ declare const useEffect: (effect: any, deps?: any) => any;
11
+ declare const useLayoutEffect: (effect: any, deps?: any) => any;
14
12
  declare const useEffectEvent: (callback: any) => any;
15
- declare const use: (usable: any) => unknown;
16
- declare const useContext: (context: any) => unknown;
13
+ declare const use: (usable: any) => any;
14
+ declare const useContext: (context: any) => any;
17
15
  //#endregion
18
16
  export { react_default as default, use, useCallback, useContext, useEffect, useEffectEvent, useLayoutEffect, useMemo, useReducer, useRef, useState };
19
17
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/react-shim/index.ts"],"mappings":";;;;;;cAuBa,QAAA,GAAY,YAAA,kBAAkB,OAAA;AAAA,cAG9B,UAAA,GAAc,OAAA,OAAc,UAAA,OAAiB,IAAA,sBAAU,MAAA,gCAAA,KAAA,CAAA,cAAA,CAAA,KAAA,CAAA,YAAA;AAAA,cAKvD,MAAA,GAAU,YAAA,WAC4C,QAAA,CAD1B,SAAA;AAAA,cAG5B,OAAA,GAAW,OAAA,OAAc,IAAS;AAAA,cAGlC,WAAA,GAAe,QAAA,OAAe,IAAS;AAAA,cAKvC,SAAA,GAAa,MAAA,OAAa,IAAU;AAAA,cAIpC,eAAA,GAAmB,MAAA,OAAa,IAAU;AAAA,cAG1C,cAAA,GAAkB,QAAa;AAAA,cAM/B,GAAA,GAAO,MAAW;AAAA,cAKlB,UAAA,GAAc,OAAY"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/react-shim/index.ts"],"mappings":";;;;cAwBa,QAAA,GAAY,YAAkB;AAAA,cAG9B,UAAA,GAAc,OAAA,OAAc,UAAA,OAAiB,IAAA;AAAA,cAK7C,MAAA,GAAU,YAAkB;AAAA,cAG5B,OAAA,GAAW,OAAA,OAAc,IAAS;AAAA,cAGlC,WAAA,GAAe,QAAA,OAAe,IAAS;AAAA,cAKvC,SAAA,GAAa,MAAA,OAAa,IAAU;AAAA,cAMpC,eAAA,GAAmB,MAAA,OAAa,IAAU;AAAA,cAM1C,cAAA,GAAkB,QAAa;AAAA,cAS/B,GAAA,GAAO,MAAW;AAAA,cAOlB,UAAA,GAAc,OAAY"}
@@ -7,21 +7,21 @@ import { useCallback as useCallback$1 } from "../hooks/useCallback.js";
7
7
  import { useEffect as useEffect$1 } from "../hooks/useEffect.js";
8
8
  import { useEffectEvent as useEffectEvent$1 } from "../hooks/useEffectEvent.js";
9
9
  import { isResourceContext, useResourceContext } from "../core/context.js";
10
- import * as React from "react";
11
- import react_default from "react";
10
+ import React, { default as react_default } from "react";
12
11
  export * from "react";
13
12
  //#region src/react-shim/index.ts
14
13
  const inTap = () => peekResourceFiber() !== null;
15
- const useState = (initialState) => inTap() ? useState$2(initialState) : React.useState(initialState);
16
- const useReducer = (reducer, initialArg, init) => inTap() ? useReducer$2(reducer, initialArg, init) : React.useReducer(reducer, initialArg, init);
17
- const useRef = (initialValue) => inTap() ? useRef$2(initialValue) : React.useRef(initialValue);
18
- const useMemo = (factory, deps) => inTap() ? useMemo$2(factory, deps) : React.useMemo(factory, deps);
19
- const useCallback = (callback, deps) => inTap() ? useCallback$1(callback, deps) : React.useCallback(callback, deps);
20
- const useEffect = (effect, deps) => inTap() ? useEffect$1(effect, deps) : React.useEffect(effect, deps);
21
- const useLayoutEffect = (effect, deps) => inTap() ? useEffect$1(effect, deps) : React.useLayoutEffect(effect, deps);
22
- const useEffectEvent = (callback) => inTap() ? useEffectEvent$1(callback) : React.useEffectEvent(callback);
23
- const use = (usable) => isResourceContext(usable) ? useResourceContext(usable) : React.use(usable);
24
- const useContext = (context) => isResourceContext(context) ? useResourceContext(context) : React.useContext(context);
14
+ const ReactRuntime = React;
15
+ const useState = (initialState) => inTap() ? useState$2(initialState) : ReactRuntime.useState(initialState);
16
+ const useReducer = (reducer, initialArg, init) => inTap() ? useReducer$2(reducer, initialArg, init) : ReactRuntime.useReducer(reducer, initialArg, init);
17
+ const useRef = (initialValue) => inTap() ? useRef$2(initialValue) : ReactRuntime.useRef(initialValue);
18
+ const useMemo = (factory, deps) => inTap() ? useMemo$2(factory, deps) : ReactRuntime.useMemo(factory, deps);
19
+ const useCallback = (callback, deps) => inTap() ? useCallback$1(callback, deps) : ReactRuntime.useCallback(callback, deps);
20
+ const useEffect = (effect, deps) => inTap() ? useEffect$1(effect, deps) : ReactRuntime.useEffect(effect, deps);
21
+ const useLayoutEffect = (effect, deps) => inTap() ? useEffect$1(effect, deps) : ReactRuntime.useLayoutEffect(effect, deps);
22
+ const useEffectEvent = (callback) => inTap() ? useEffectEvent$1(callback) : ReactRuntime.useEffectEvent(callback);
23
+ const use = (usable) => isResourceContext(usable) ? useResourceContext(usable) : ReactRuntime.use(usable);
24
+ const useContext = (context) => isResourceContext(context) ? useResourceContext(context) : ReactRuntime.useContext(context);
25
25
  //#endregion
26
26
  export { react_default as default, use, useCallback, useContext, useEffect, useEffectEvent, useLayoutEffect, useMemo, useReducer, useRef, useState };
27
27
 
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["hooks.useState","hooks.useReducer","hooks.useRef","hooks.useMemo","hooks.useCallback","hooks.useEffect","hooks.useEffectEvent"],"sources":["../../src/react-shim/index.ts"],"sourcesContent":["/* oxlint-disable react/rules-of-hooks -- this module deliberately routes hook calls between tap and React at runtime */\n/* oxlint-disable react/exhaustive-deps -- dependency arrays are forwarded verbatim from the caller */\n// Runtime drop-in for \"react\": forward everything from react, then override the\n// hooks that have a tap equivalent so they route to tap inside a resource render\n// and to React otherwise. Alias `react` to this module (build `output.paths` /\n// vitest resolver) in code that can run inside a tap resource.\n//\n// This subpath ships no type declarations: the build reverts the aliased\n// specifier back to `\"react\"` in emitted `.d.ts`, so consumer types resolve to\n// React's own. The source-level TS2498 from the `export *` below is suppressed.\nimport * as React from \"react\";\nimport { peekResourceFiber } from \"../core/helpers/execution-context\";\nimport * as hooks from \"../hooks\";\nimport { useResourceContext, isResourceContext } from \"../core/context\";\n\n// @ts-expect-error -- @types/react uses `export =`; this is valid at runtime.\nexport * from \"react\";\nexport { default } from \"react\";\n\nconst inTap = () => peekResourceFiber() !== null;\n\n// --- hooks with a tap equivalent: override the star-exported react hooks ---\n\nexport const useState = (initialState?: any) =>\n inTap() ? hooks.useState(initialState) : React.useState(initialState);\n\nexport const useReducer = (reducer: any, initialArg: any, init?: any) =>\n inTap()\n ? hooks.useReducer(reducer, initialArg, init)\n : React.useReducer(reducer, initialArg, init);\n\nexport const useRef = (initialValue?: any) =>\n inTap() ? hooks.useRef(initialValue) : React.useRef(initialValue);\n\nexport const useMemo = (factory: any, deps: any) =>\n inTap() ? hooks.useMemo(factory, deps) : React.useMemo(factory, deps);\n\nexport const useCallback = (callback: any, deps: any) =>\n inTap()\n ? hooks.useCallback(callback, deps)\n : React.useCallback(callback, deps);\n\nexport const useEffect = (effect: any, deps?: any) =>\n inTap() ? hooks.useEffect(effect, deps) : React.useEffect(effect, deps);\n\n// tap has a single effect primitive; layout effects collapse onto it\nexport const useLayoutEffect = (effect: any, deps?: any) =>\n inTap() ? hooks.useEffect(effect, deps) : React.useLayoutEffect(effect, deps);\n\nexport const useEffectEvent = (callback: any) =>\n inTap() ? hooks.useEffectEvent(callback) : React.useEffectEvent(callback);\n\n// `use(usable)` reads tap resource context when handed a tap context (routed by\n// its brand, not by ambient render state), and falls back to React's `use`\n// (promises / React context) for everything else.\nexport const use = (usable: any) =>\n isResourceContext(usable) ? useResourceContext(usable) : React.use(usable);\n\n// `useContext(context)` reads tap resource context when handed a tap context\n// (routed by its brand), and falls back to React's `useContext` otherwise.\nexport const useContext = (context: any) =>\n isResourceContext(context)\n ? useResourceContext(context)\n : React.useContext(context);\n"],"mappings":";;;;;;;;;;;;;AAmBA,MAAM,cAAc,kBAAkB,MAAM;AAI5C,MAAa,YAAY,iBACvB,MAAM,IAAIA,WAAe,YAAY,IAAI,MAAM,SAAS,YAAY;AAEtE,MAAa,cAAc,SAAc,YAAiB,SACxD,MAAM,IACFC,aAAiB,SAAS,YAAY,IAAI,IAC1C,MAAM,WAAW,SAAS,YAAY,IAAI;AAEhD,MAAa,UAAU,iBACrB,MAAM,IAAIC,SAAa,YAAY,IAAI,MAAM,OAAO,YAAY;AAElE,MAAa,WAAW,SAAc,SACpC,MAAM,IAAIC,UAAc,SAAS,IAAI,IAAI,MAAM,QAAQ,SAAS,IAAI;AAEtE,MAAa,eAAe,UAAe,SACzC,MAAM,IACFC,cAAkB,UAAU,IAAI,IAChC,MAAM,YAAY,UAAU,IAAI;AAEtC,MAAa,aAAa,QAAa,SACrC,MAAM,IAAIC,YAAgB,QAAQ,IAAI,IAAI,MAAM,UAAU,QAAQ,IAAI;AAGxE,MAAa,mBAAmB,QAAa,SAC3C,MAAM,IAAIA,YAAgB,QAAQ,IAAI,IAAI,MAAM,gBAAgB,QAAQ,IAAI;AAE9E,MAAa,kBAAkB,aAC7B,MAAM,IAAIC,iBAAqB,QAAQ,IAAI,MAAM,eAAe,QAAQ;AAK1E,MAAa,OAAO,WAClB,kBAAkB,MAAM,IAAI,mBAAmB,MAAM,IAAI,MAAM,IAAI,MAAM;AAI3E,MAAa,cAAc,YACzB,kBAAkB,OAAO,IACrB,mBAAmB,OAAO,IAC1B,MAAM,WAAW,OAAO"}
1
+ {"version":3,"file":"index.js","names":["hooks.useState","hooks.useReducer","hooks.useRef","hooks.useMemo","hooks.useCallback","hooks.useEffect","hooks.useEffectEvent"],"sources":["../../src/react-shim/index.ts"],"sourcesContent":["/* oxlint-disable react/rules-of-hooks -- this module deliberately routes hook calls between tap and React at runtime */\n/* oxlint-disable react/exhaustive-deps -- dependency arrays are forwarded verbatim from the caller */\n// Runtime drop-in for \"react\": forward everything from react, then override the\n// hooks that have a tap equivalent so they route to tap inside a resource render\n// and to React otherwise. Alias `react` to this module (build `output.paths` /\n// vitest resolver) in code that can run inside a tap resource.\n//\n// This subpath ships no type declarations: the build reverts the aliased\n// specifier back to `\"react\"` in emitted `.d.ts`, so consumer types resolve to\n// React's own. The source-level TS2498 from the `export *` below is suppressed.\nimport React from \"react\";\nimport { peekResourceFiber } from \"../core/helpers/execution-context\";\nimport * as hooks from \"../hooks\";\nimport { useResourceContext, isResourceContext } from \"../core/context\";\n\n// @ts-expect-error -- @types/react uses `export =`; this is valid at runtime.\nexport * from \"react\";\nexport { default } from \"react\";\n\nconst inTap = () => peekResourceFiber() !== null;\nconst ReactRuntime = React as any;\n\n// --- hooks with a tap equivalent: override the star-exported react hooks ---\n\nexport const useState = (initialState?: any) =>\n inTap() ? hooks.useState(initialState) : ReactRuntime.useState(initialState);\n\nexport const useReducer = (reducer: any, initialArg: any, init?: any) =>\n inTap()\n ? hooks.useReducer(reducer, initialArg, init)\n : ReactRuntime.useReducer(reducer, initialArg, init);\n\nexport const useRef = (initialValue?: any) =>\n inTap() ? hooks.useRef(initialValue) : ReactRuntime.useRef(initialValue);\n\nexport const useMemo = (factory: any, deps: any) =>\n inTap() ? hooks.useMemo(factory, deps) : ReactRuntime.useMemo(factory, deps);\n\nexport const useCallback = (callback: any, deps: any) =>\n inTap()\n ? hooks.useCallback(callback, deps)\n : ReactRuntime.useCallback(callback, deps);\n\nexport const useEffect = (effect: any, deps?: any) =>\n inTap()\n ? hooks.useEffect(effect, deps)\n : ReactRuntime.useEffect(effect, deps);\n\n// tap has a single effect primitive; layout effects collapse onto it\nexport const useLayoutEffect = (effect: any, deps?: any) =>\n inTap()\n ? hooks.useEffect(effect, deps)\n : ReactRuntime.useLayoutEffect(effect, deps);\n\n// The non-tap fallback requires a React version that provides useEffectEvent.\nexport const useEffectEvent = (callback: any) =>\n inTap()\n ? hooks.useEffectEvent(callback)\n : ReactRuntime.useEffectEvent(callback);\n\n// `use(usable)` reads tap resource context when handed a tap context (routed by\n// its brand, not by ambient render state), and falls back to React's `use`\n// (promises / React context) for everything else. The non-tap fallback requires\n// React 19.\nexport const use = (usable: any) =>\n isResourceContext(usable)\n ? useResourceContext(usable)\n : ReactRuntime.use(usable);\n\n// `useContext(context)` reads tap resource context when handed a tap context\n// (routed by its brand), and falls back to React's `useContext` otherwise.\nexport const useContext = (context: any) =>\n isResourceContext(context)\n ? useResourceContext(context)\n : ReactRuntime.useContext(context);\n"],"mappings":";;;;;;;;;;;;AAmBA,MAAM,cAAc,kBAAkB,MAAM;AAC5C,MAAM,eAAe;AAIrB,MAAa,YAAY,iBACvB,MAAM,IAAIA,WAAe,YAAY,IAAI,aAAa,SAAS,YAAY;AAE7E,MAAa,cAAc,SAAc,YAAiB,SACxD,MAAM,IACFC,aAAiB,SAAS,YAAY,IAAI,IAC1C,aAAa,WAAW,SAAS,YAAY,IAAI;AAEvD,MAAa,UAAU,iBACrB,MAAM,IAAIC,SAAa,YAAY,IAAI,aAAa,OAAO,YAAY;AAEzE,MAAa,WAAW,SAAc,SACpC,MAAM,IAAIC,UAAc,SAAS,IAAI,IAAI,aAAa,QAAQ,SAAS,IAAI;AAE7E,MAAa,eAAe,UAAe,SACzC,MAAM,IACFC,cAAkB,UAAU,IAAI,IAChC,aAAa,YAAY,UAAU,IAAI;AAE7C,MAAa,aAAa,QAAa,SACrC,MAAM,IACFC,YAAgB,QAAQ,IAAI,IAC5B,aAAa,UAAU,QAAQ,IAAI;AAGzC,MAAa,mBAAmB,QAAa,SAC3C,MAAM,IACFA,YAAgB,QAAQ,IAAI,IAC5B,aAAa,gBAAgB,QAAQ,IAAI;AAG/C,MAAa,kBAAkB,aAC7B,MAAM,IACFC,iBAAqB,QAAQ,IAC7B,aAAa,eAAe,QAAQ;AAM1C,MAAa,OAAO,WAClB,kBAAkB,MAAM,IACpB,mBAAmB,MAAM,IACzB,aAAa,IAAI,MAAM;AAI7B,MAAa,cAAc,YACzB,kBAAkB,OAAO,IACrB,mBAAmB,OAAO,IAC1B,aAAa,WAAW,OAAO"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@assistant-ui/tap",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
4
4
  "description": "Reactive state management inspired by React hooks",
5
5
  "keywords": [
6
6
  "state-management",
@@ -1,4 +1,4 @@
1
- import * as React from "react";
1
+ import React from "react";
2
2
  import { useState } from "../hooks/useState";
3
3
  import { useReducer } from "../hooks/useReducer";
4
4
  import { useRef } from "../hooks/useRef";
@@ -30,10 +30,10 @@ const tapDispatcher = {
30
30
 
31
31
  // React's live dispatcher slot differs by version: React 19 exposes it as `H` on
32
32
  // the client internals object; React 18 as `ReactCurrentDispatcher.current`.
33
+ const ReactRuntime = React as any;
33
34
  const internals =
34
- (React as any)
35
- .__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE ??
36
- (React as any).__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
35
+ ReactRuntime.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE ??
36
+ ReactRuntime.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
37
37
 
38
38
  const slot: { current: unknown } | null =
39
39
  internals == null
@@ -8,7 +8,7 @@
8
8
  // This subpath ships no type declarations: the build reverts the aliased
9
9
  // specifier back to `"react"` in emitted `.d.ts`, so consumer types resolve to
10
10
  // React's own. The source-level TS2498 from the `export *` below is suppressed.
11
- import * as React from "react";
11
+ import React from "react";
12
12
  import { peekResourceFiber } from "../core/helpers/execution-context";
13
13
  import * as hooks from "../hooks";
14
14
  import { useResourceContext, isResourceContext } from "../core/context";
@@ -18,47 +18,58 @@ export * from "react";
18
18
  export { default } from "react";
19
19
 
20
20
  const inTap = () => peekResourceFiber() !== null;
21
+ const ReactRuntime = React as any;
21
22
 
22
23
  // --- hooks with a tap equivalent: override the star-exported react hooks ---
23
24
 
24
25
  export const useState = (initialState?: any) =>
25
- inTap() ? hooks.useState(initialState) : React.useState(initialState);
26
+ inTap() ? hooks.useState(initialState) : ReactRuntime.useState(initialState);
26
27
 
27
28
  export const useReducer = (reducer: any, initialArg: any, init?: any) =>
28
29
  inTap()
29
30
  ? hooks.useReducer(reducer, initialArg, init)
30
- : React.useReducer(reducer, initialArg, init);
31
+ : ReactRuntime.useReducer(reducer, initialArg, init);
31
32
 
32
33
  export const useRef = (initialValue?: any) =>
33
- inTap() ? hooks.useRef(initialValue) : React.useRef(initialValue);
34
+ inTap() ? hooks.useRef(initialValue) : ReactRuntime.useRef(initialValue);
34
35
 
35
36
  export const useMemo = (factory: any, deps: any) =>
36
- inTap() ? hooks.useMemo(factory, deps) : React.useMemo(factory, deps);
37
+ inTap() ? hooks.useMemo(factory, deps) : ReactRuntime.useMemo(factory, deps);
37
38
 
38
39
  export const useCallback = (callback: any, deps: any) =>
39
40
  inTap()
40
41
  ? hooks.useCallback(callback, deps)
41
- : React.useCallback(callback, deps);
42
+ : ReactRuntime.useCallback(callback, deps);
42
43
 
43
44
  export const useEffect = (effect: any, deps?: any) =>
44
- inTap() ? hooks.useEffect(effect, deps) : React.useEffect(effect, deps);
45
+ inTap()
46
+ ? hooks.useEffect(effect, deps)
47
+ : ReactRuntime.useEffect(effect, deps);
45
48
 
46
49
  // tap has a single effect primitive; layout effects collapse onto it
47
50
  export const useLayoutEffect = (effect: any, deps?: any) =>
48
- inTap() ? hooks.useEffect(effect, deps) : React.useLayoutEffect(effect, deps);
51
+ inTap()
52
+ ? hooks.useEffect(effect, deps)
53
+ : ReactRuntime.useLayoutEffect(effect, deps);
49
54
 
55
+ // The non-tap fallback requires a React version that provides useEffectEvent.
50
56
  export const useEffectEvent = (callback: any) =>
51
- inTap() ? hooks.useEffectEvent(callback) : React.useEffectEvent(callback);
57
+ inTap()
58
+ ? hooks.useEffectEvent(callback)
59
+ : ReactRuntime.useEffectEvent(callback);
52
60
 
53
61
  // `use(usable)` reads tap resource context when handed a tap context (routed by
54
62
  // its brand, not by ambient render state), and falls back to React's `use`
55
- // (promises / React context) for everything else.
63
+ // (promises / React context) for everything else. The non-tap fallback requires
64
+ // React 19.
56
65
  export const use = (usable: any) =>
57
- isResourceContext(usable) ? useResourceContext(usable) : React.use(usable);
66
+ isResourceContext(usable)
67
+ ? useResourceContext(usable)
68
+ : ReactRuntime.use(usable);
58
69
 
59
70
  // `useContext(context)` reads tap resource context when handed a tap context
60
71
  // (routed by its brand), and falls back to React's `useContext` otherwise.
61
72
  export const useContext = (context: any) =>
62
73
  isResourceContext(context)
63
74
  ? useResourceContext(context)
64
- : React.useContext(context);
75
+ : ReactRuntime.useContext(context);