@warp-drive-mirror/react 5.9.0-beta.1 → 5.9.0-beta.3
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/CHANGELOG.md +38 -0
- package/{declarations → dist}/index.d.ts +2 -2
- package/{declarations → dist}/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/install.js +2 -2
- package/dist/install.js.map +1 -1
- package/dist/{reactive-context-DNq02nr1.js → reactive-context-DhUW_l--.js} +2 -2
- package/dist/reactive-context-DhUW_l--.js.map +1 -0
- package/dist/unpkg/dev/index.js +15 -15
- package/dist/unpkg/dev/index.js.map +1 -1
- package/dist/unpkg/dev/install.js +2 -2
- package/dist/unpkg/dev/install.js.map +1 -1
- package/dist/unpkg/dev/{reactive-context-C9-Fc8qx.js → reactive-context-Ax2U-96G.js} +4 -4
- package/dist/unpkg/dev/reactive-context-Ax2U-96G.js.map +1 -0
- package/dist/unpkg/dev-deprecated/index.js +15 -15
- package/dist/unpkg/dev-deprecated/index.js.map +1 -1
- package/dist/unpkg/dev-deprecated/install.js +2 -2
- package/dist/unpkg/dev-deprecated/install.js.map +1 -1
- package/dist/unpkg/dev-deprecated/{reactive-context-DhpCE2Tv.js → reactive-context-B-pn7tS7.js} +4 -4
- package/dist/unpkg/dev-deprecated/reactive-context-B-pn7tS7.js.map +1 -0
- package/dist/unpkg/prod/index.js +3 -3
- package/dist/unpkg/prod/index.js.map +1 -1
- package/dist/unpkg/prod/install.js +2 -2
- package/dist/unpkg/prod/install.js.map +1 -1
- package/dist/unpkg/prod/{reactive-context-CvfXAZqb.js → reactive-context-eAEvPuqb.js} +2 -2
- package/dist/unpkg/prod/reactive-context-eAEvPuqb.js.map +1 -0
- package/dist/unpkg/prod-deprecated/index.js +3 -3
- package/dist/unpkg/prod-deprecated/index.js.map +1 -1
- package/dist/unpkg/prod-deprecated/install.js +2 -2
- package/dist/unpkg/prod-deprecated/install.js.map +1 -1
- package/dist/unpkg/prod-deprecated/{reactive-context-CvfXAZqb.js → reactive-context-eAEvPuqb.js} +2 -2
- package/dist/unpkg/prod-deprecated/reactive-context-eAEvPuqb.js.map +1 -0
- package/package.json +22 -29
- package/dist/reactive-context-DNq02nr1.js.map +0 -1
- package/dist/unpkg/dev/reactive-context-C9-Fc8qx.js.map +0 -1
- package/dist/unpkg/dev-deprecated/reactive-context-DhpCE2Tv.js.map +0 -1
- package/dist/unpkg/prod/reactive-context-CvfXAZqb.js.map +0 -1
- package/dist/unpkg/prod-deprecated/reactive-context-CvfXAZqb.js.map +0 -1
- /package/{declarations → dist}/install.d.ts +0 -0
- /package/{declarations → dist}/install.d.ts.map +0 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# @warp-drive-mirror/ember Changelog
|
|
2
|
+
|
|
3
|
+
For the full project changelog see [https://github.com/warp-drive-data/warp-drive/blob/main/CHANGELOG.md](https://github.com/warp-drive-data/warp-drive/blob/main/CHANGELOG.md)
|
|
4
|
+
|
|
5
|
+
## v0.0.0-alpha.47 (2024-06-15)
|
|
6
|
+
|
|
7
|
+
#### :memo: Documentation
|
|
8
|
+
|
|
9
|
+
* [#9390](https://github.com/warp-drive-data/warp-drive/pull/9390) docs: fix readme links in @warp-drive-mirror/ember ([@runspired](https://github.com/runspired))
|
|
10
|
+
* [#9328](https://github.com/warp-drive-data/warp-drive/pull/9328) chore: update READMEs with status and dist tag info ([@runspired](https://github.com/runspired))
|
|
11
|
+
|
|
12
|
+
#### :rocket: Enhancement
|
|
13
|
+
|
|
14
|
+
* [#9471](https://github.com/warp-drive-data/warp-drive/pull/9471) feat: npx warp-drive ([@runspired](https://github.com/runspired))
|
|
15
|
+
* [#9468](https://github.com/warp-drive-data/warp-drive/pull/9468) feat: string utils 🌌 ([@runspired](https://github.com/runspired))
|
|
16
|
+
* [#9366](https://github.com/warp-drive-data/warp-drive/pull/9366) feat: typed Model ([@runspired](https://github.com/runspired))
|
|
17
|
+
* [#9363](https://github.com/warp-drive-data/warp-drive/pull/9363) feat: <Request /> autoRefresh ([@runspired](https://github.com/runspired))
|
|
18
|
+
* [#9359](https://github.com/warp-drive-data/warp-drive/pull/9359) feat: type checked builders and inferred request types from builders ([@runspired](https://github.com/runspired))
|
|
19
|
+
* [#9317](https://github.com/warp-drive-data/warp-drive/pull/9317) feat: ensure data utils work well with legacy relationship proxies ([@runspired](https://github.com/runspired))
|
|
20
|
+
* [#9260](https://github.com/warp-drive-data/warp-drive/pull/9260) feat: ember specific data utils ([@runspired](https://github.com/runspired))
|
|
21
|
+
|
|
22
|
+
#### :bug: Bug Fix
|
|
23
|
+
|
|
24
|
+
* [#9456](https://github.com/warp-drive-data/warp-drive/pull/9456) fix: visibilitychange => hidden should update unavailableStart ([@runspired](https://github.com/runspired))
|
|
25
|
+
* [#9454](https://github.com/warp-drive-data/warp-drive/pull/9454) Allow RequestState.abort to be used with on modifier ([@gitKrystan](https://github.com/gitKrystan))
|
|
26
|
+
* [#9391](https://github.com/warp-drive-data/warp-drive/pull/9391) fix: dont fall-through after shouldAttempt on refresh ([@runspired](https://github.com/runspired))
|
|
27
|
+
* [#9369](https://github.com/warp-drive-data/warp-drive/pull/9369) fix: @warp-drive-ember, dont leak empty slot ([@runspired](https://github.com/runspired))
|
|
28
|
+
|
|
29
|
+
#### :house: Internal
|
|
30
|
+
|
|
31
|
+
* [#9292](https://github.com/warp-drive-data/warp-drive/pull/9292) feat: add new build-config package ([@runspired](https://github.com/runspired))
|
|
32
|
+
* [#9370](https://github.com/warp-drive-data/warp-drive/pull/9370) chore: rename macros ([@runspired](https://github.com/runspired))
|
|
33
|
+
|
|
34
|
+
#### Committers: (2)
|
|
35
|
+
|
|
36
|
+
Chris Thoburn ([@runspired](https://github.com/runspired))
|
|
37
|
+
Krystan HuffMenne ([@gitKrystan](https://github.com/gitKrystan))
|
|
38
|
+
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Signal } from "signal-polyfill";
|
|
2
1
|
import { Context, JSX, ReactNode } from "react";
|
|
2
|
+
import { Signal } from "signal-polyfill";
|
|
3
3
|
import { RequestLoadingState, RequestState } from "@warp-drive-mirror/core/reactive";
|
|
4
4
|
import { ContentFeatures, RecoveryFeatures, RequestArgs } from "@warp-drive-mirror/core/signals/-leaked";
|
|
5
5
|
import { Store } from "@warp-drive-mirror/core";
|
|
@@ -55,7 +55,7 @@ interface RequestStates<RT, E> {
|
|
|
55
55
|
* The block to render when the component is idle and waiting to be given a request.
|
|
56
56
|
*
|
|
57
57
|
*/
|
|
58
|
-
idle?: React.FC<
|
|
58
|
+
idle?: React.FC<object>;
|
|
59
59
|
/**
|
|
60
60
|
* The block to render when the request is loading.
|
|
61
61
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/-private/reactive-context.tsx","../src/-private/store-provider.tsx","../src/-private/request.tsx"],"mappings":";;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/-private/reactive-context.tsx","../src/-private/store-provider.tsx","../src/-private/request.tsx"],"mappings":";;;;;;;;;;cAyJa,gBAAgB;;;;EAI3B,SAAS,OAAO,OAAO;;;;;;iBAST,kBAAkB;EAAc,UAAU;IAAc,IAAI;;;;;;iBCxJ5D,YAAY;KASvB;EAAsB,OAAO;EAAO,UAAU;;KAC9C;EAAiB,cAAc;EAAO,UAAU;;;;;iBAKrC,cAAc,QAAQ,oBAAoB,eAAe,IAAI;;;UCSnE,qBAAqB;EAC7B,UAAU;EACV,OAAO;EACP,UAAU,gBAAgB;;UAOX,aAAa,IAAI,WAAW,YAAY,IAAI;EAC3D,SAAS,MAAM,GAAG,qBAAqB;EAEvC,QAAQ,cAAc,IAAI;;UAGlB,cAAc,IAAI;;;;;EAK1B,OAAO,MAAM;;;;;EAMb,UAAU,MAAM;IAAK,OAAO;;;;;;EAM5B,YAAY,MAAM;;;;IAIhB,OAAO,wBAAwB;;;;IAI/B,UAAU;;;;;;;;;EAUZ,OAAO,MAAM;;;;IAIX,OAAO,wBAAwB;;;;IAI/B,UAAU;;;;;;EAOZ,SAAS,MAAM;IAAK,QAAQ;IAAI,UAAU,gBAAgB;;;;;;;;;iBAS5C,QAAQ;EAAW,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAkE1B,QAAQ,IAAI,GAAG,QAAQ,aAAa,IAAI,KAAK,IAAI"}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as WatcherContext, t as ReactiveContext } from "./reactive-context-
|
|
1
|
+
import { n as WatcherContext, t as ReactiveContext } from "./reactive-context-DhUW_l--.js";
|
|
2
2
|
import { createContext, use, useEffect, useMemo, useRef } from "react";
|
|
3
3
|
import { getGlobalConfig, macroCondition } from "@embroider/macros";
|
|
4
4
|
import { Fragment, jsx } from "react/jsx-runtime";
|
|
@@ -32,7 +32,7 @@ function StoreProvider($props) {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
//#endregion
|
|
35
|
-
//#region ../../node_modules/.pnpm/
|
|
35
|
+
//#region ../../node_modules/.pnpm/decorat_5d4eca388601a94e7fbc656401b751d1/node_modules/decorator-transforms/dist/runtime--fcdnjmJ.js
|
|
36
36
|
const deferred = /* @__PURE__ */ new WeakMap();
|
|
37
37
|
function deferDecorator(proto, prop, desc) {
|
|
38
38
|
let map = deferred.get(proto);
|
|
@@ -48,7 +48,7 @@ function findDeferredDecorator(target, prop) {
|
|
|
48
48
|
while (cursor) {
|
|
49
49
|
let desc = (_a = deferred.get(cursor)) == null ? void 0 : _a.get(prop);
|
|
50
50
|
if (desc) return desc;
|
|
51
|
-
cursor = cursor
|
|
51
|
+
cursor = Object.getPrototypeOf(cursor);
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
function decorateFieldV2(prototype, prop, decorators, initializer) {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["Store","createContext","JSX","ReactNode","use","useMemo","macroCondition","getGlobalConfig","jsx","_jsx","StoreContext","useStore","store","WarpDrive","env","DEBUG","test","Error","StoreProvider","$props","value","children","createRequestSubscription","AutorefreshBehaviorCombos","DISPOSE","RequestArgs","signal","JSX","ReactNode","useEffect","useMemo","useRef","useStore","ReactiveContext","Future","StoreRequestInput","getGlobalConfig","macroCondition","g","i","Fragment","_Fragment","jsx","_jsx","IdleBlockMissingError","Error","ReactiveArgs","prototype","request","void 0","query","autorefresh","autorefreshThreshold","autorefreshBehavior","DefaultChrome","children","Throw","error","Request","$props","InternalRequest","isStrictModeRender","count","WarpDrive","env","DEBUG","current","isStrict","store","Chrome","chrome","sink","args","Object","assign","subscription","initialized","effect","disposable","dispose","undefined","maybeEffect","state","slots","states","isIdle","reqState","features","contentFeatures","idle","isLoading","loading","loadingState","isCancelled","cancelled","reason","errorFeatures","isError","isSuccess","content","result","value"],"sources":["../src/-private/store-provider.tsx","../../../node_modules/.pnpm/decorat_5005bbc272376d25df08203abab44e2f/node_modules/decorator-transforms/dist/runtime-BPCpkOf1.js","../src/-private/request.tsx"],"sourcesContent":["import { Store } from \"@warp-drive-mirror/core\";\nimport { assert } from \"@warp-drive-mirror/core/build-config/macros\";\nimport { createContext, JSX, ReactNode, use, useMemo } from \"react\";\n\n/**\n * @category Contexts\n */\nconst StoreContext = createContext<Store | null>(null);\n\n/**\n * @category Hooks\n */\nexport function useStore(): Store {\n const store = use(StoreContext);\n assert(\n \"No Store provided via context. Please ensure you are using <StoreProvider> to provide a Store instance.\",\n store\n );\n return store;\n}\n\ntype WithExistingStore = { store: Store; children: ReactNode };\ntype WithNewStore = { Store: typeof Store; children: ReactNode };\n\n/**\n * @category Components\n */\nexport function StoreProvider($props: WithExistingStore | WithNewStore): JSX.Element {\n const store = useMemo(\n () => (\"store\" in $props ? $props.store : new $props.Store()),\n [\"store\" in $props ? $props.store : $props.Store]\n );\n\n return <StoreContext value={store}>{$props.children}</StoreContext>;\n}\n","const deferred = /* @__PURE__ */ new WeakMap();\nfunction deferDecorator(proto, prop, desc) {\n let map = deferred.get(proto);\n if (!map) {\n map = /* @__PURE__ */ new Map();\n deferred.set(proto, map);\n }\n map.set(prop, desc);\n}\nfunction findDeferredDecorator(target, prop) {\n var _a;\n let cursor = target.prototype;\n while (cursor) {\n let desc = (_a = deferred.get(cursor)) == null ? void 0 : _a.get(prop);\n if (desc) {\n return desc;\n }\n cursor = cursor.prototype;\n }\n}\nfunction decorateFieldV1(target, prop, decorators, initializer) {\n return decorateFieldV2(target.prototype, prop, decorators, initializer);\n}\nfunction decorateFieldV2(prototype, prop, decorators, initializer) {\n let desc = {\n configurable: true,\n enumerable: true,\n writable: true,\n initializer: null\n };\n if (initializer) {\n desc.initializer = initializer;\n }\n for (let decorator of decorators) {\n desc = decorator(prototype, prop, desc) || desc;\n }\n if (desc.initializer === void 0) {\n Object.defineProperty(prototype, prop, desc);\n } else {\n deferDecorator(prototype, prop, desc);\n }\n}\nfunction decorateMethodV1({ prototype }, prop, decorators) {\n return decorateMethodV2(prototype, prop, decorators);\n}\nfunction decorateMethodV2(prototype, prop, decorators) {\n const origDesc = Object.getOwnPropertyDescriptor(prototype, prop);\n let desc = { ...origDesc };\n for (let decorator of decorators) {\n desc = decorator(prototype, prop, desc) || desc;\n }\n if (desc.initializer !== void 0) {\n desc.value = desc.initializer ? desc.initializer.call(prototype) : void 0;\n desc.initializer = void 0;\n }\n Object.defineProperty(prototype, prop, desc);\n}\nfunction initializeDeferredDecorator(target, prop) {\n let desc = findDeferredDecorator(target.constructor, prop);\n if (desc) {\n Object.defineProperty(target, prop, {\n enumerable: desc.enumerable,\n configurable: desc.configurable,\n writable: desc.writable,\n value: desc.initializer ? desc.initializer.call(target) : void 0\n });\n }\n}\nfunction decorateClass(target, decorators) {\n return decorators.reduce(\n (accum, decorator) => decorator(accum) || accum,\n target\n );\n}\nfunction decoratePOJO(pojo, decorated) {\n for (let [type, prop, decorators] of decorated) {\n if (type === \"field\") {\n decoratePojoField(pojo, prop, decorators);\n } else {\n decorateMethodV2(pojo, prop, decorators);\n }\n }\n return pojo;\n}\nfunction decoratePojoField(pojo, prop, decorators) {\n let desc = {\n configurable: true,\n enumerable: true,\n writable: true,\n initializer: () => {\n var _a;\n return (_a = Object.getOwnPropertyDescriptor(pojo, prop)) == null ? void 0 : _a.value;\n }\n };\n for (let decorator of decorators) {\n desc = decorator(pojo, prop, desc) || desc;\n }\n if (desc.initializer) {\n desc.value = desc.initializer.call(pojo);\n delete desc.initializer;\n }\n Object.defineProperty(pojo, prop, desc);\n}\nconst runtime = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({\n __proto__: null,\n c: decorateClass,\n f: decorateFieldV1,\n g: decorateFieldV2,\n i: initializeDeferredDecorator,\n m: decorateMethodV1,\n n: decorateMethodV2,\n p: decoratePOJO\n}, Symbol.toStringTag, { value: \"Module\" }));\nexport {\n decorateFieldV2 as a,\n decorateMethodV1 as b,\n decorateMethodV2 as c,\n decorateFieldV1 as d,\n decorateClass as e,\n decoratePOJO as f,\n initializeDeferredDecorator as i,\n runtime as r\n};\n//# sourceMappingURL=runtime-BPCpkOf1.js.map\n","import {\n createRequestSubscription,\n type RequestLoadingState,\n type RequestState,\n type RequestSubscription,\n} from \"@warp-drive-mirror/core/reactive\";\nimport {\n AutorefreshBehaviorCombos,\n DISPOSE,\n RequestArgs,\n signal,\n type ContentFeatures,\n type RecoveryFeatures,\n type SubscriptionArgs,\n} from \"@warp-drive-mirror/core/signals/-leaked\";\nimport type { StructuredErrorDocument } from \"@warp-drive-mirror/core/types/request\";\nimport { JSX, ReactNode, useEffect, useMemo, useRef } from \"react\";\nimport { useStore } from \"./store-provider\";\nimport { ReactiveContext } from \"./reactive-context\";\nimport { Future } from \"@warp-drive-mirror/core/request\";\nimport { StoreRequestInput } from \"@warp-drive-mirror/core\";\nimport { DEBUG } from \"@warp-drive-mirror/core/build-config/env\";\n\nconst IdleBlockMissingError = new Error(\n \"No idle block provided for <Request> component, and no query or request was provided.\"\n);\n\nclass ReactiveArgs<RT, E> implements SubscriptionArgs<RT, E> {\n @signal request?: Future<RT> | undefined | null;\n @signal query?: StoreRequestInput<RT> | undefined | null;\n @signal autorefresh?: AutorefreshBehaviorCombos | undefined;\n @signal autorefreshThreshold?: number | undefined;\n @signal autorefreshBehavior?: \"refresh\" | \"reload\" | \"policy\";\n}\n\ninterface ChromeComponentProps<RT> {\n children: ReactNode;\n state: RequestState | null;\n features: ContentFeatures<RT>;\n}\n\nconst DefaultChrome = <RT,>({ children }: ChromeComponentProps<RT>) => {\n return <>{children}</>;\n};\n\nexport interface RequestProps<RT, E> extends RequestArgs<RT, E> {\n chrome?: React.FC<ChromeComponentProps<RT>>;\n\n states: RequestStates<RT, E>;\n}\n\ninterface RequestStates<RT, E> {\n /**\n * The block to render when the component is idle and waiting to be given a request.\n *\n */\n idle?: React.FC<{}>;\n\n /**\n * The block to render when the request is loading.\n *\n */\n loading?: React.FC<{ state: RequestLoadingState }>;\n\n /**\n * The block to render when the request was cancelled.\n *\n */\n cancelled?: React.FC<{\n /**\n * The Error the request rejected with.\n */\n error: StructuredErrorDocument<E>;\n /**\n * Utilities to assist in recovering from the error.\n */\n features: RecoveryFeatures;\n }>;\n\n /**\n * The block to render when the request failed. If this block is not provided,\n * the error will be rethrown.\n *\n * Thus it is required to provide an error block and proper error handling if\n * you do not want the error to crash the application.\n */\n error: React.FC<{\n /**\n * The Error the request rejected with.\n */\n error: StructuredErrorDocument<E>;\n /**\n * Utilities to assist in recovering from the error.\n */\n features: RecoveryFeatures;\n }>;\n\n /**\n * The block to render when the request succeeded.\n *\n */\n content: React.FC<{ result: RT; features: ContentFeatures<RT> }>;\n}\n\n/**\n * Throws the given error. Used internally to rethrow request errors that\n * are not otherwise handled by a provided error/cancelled block.\n *\n * @private\n */\nexport function Throw({ error }: { error: Error }): never {\n throw error;\n}\n\n/**\n * The `<Request />` component is a powerful tool for managing data fetching and\n * state in your React application. It provides a declarative approach to reactive\n * control-flow for managing requests and state in your application.\n *\n * The `<Request />` component is ideal for handling \"boundaries\", outside which some\n * state is still allowed to be unresolved and within which it MUST be resolved.\n *\n * ## Request States\n *\n * `<Request />` has five states, only one of which will be active and rendered at a time.\n *\n * - `idle`: The component is waiting to be given a request to monitor\n * - `loading`: The request is in progress\n * - `error`: The request failed\n * - `content`: The request succeeded\n * - `cancelled`: The request was cancelled\n *\n * Additionally, the `content` state has a `refresh` method that can be used to\n * refresh the request in the background, which is available as a sub-state of\n * the `content` state.\n *\n * ### Example Usage\n *\n * ```tsx\n * import { Request } from \"@warp-drive-mirror/react\";\n *\n * export function UserPreview($props: { id: string | null }) {\n * return (\n * <Request\n * query={findRecord('user', $props.id)}\n * states={{\n * idle: () => <div>Waiting for User Selection</div>,\n * loading: ({ state }) => <div>Loading user data...</div>,\n * cancelled: ({ error, features }) => (\n * <div>\n * <p>Request Cancelled</p>\n * <p><button onClick={features.retry}>Start Again?</button></p>\n * </div>\n * ),\n * error: ({ error, features }) => (\n * <div>\n * <p>Error: {error.message}</p>\n * <p><button onClick={features.retry}>Try Again?</button></p>\n * </div>\n * ),\n * content: ({ result, features }) => (\n * <div>\n * <h2>User Details</h2>\n * <p>ID: {result.id}</p>\n * <p>Name: {result.name}</p>\n * </div>\n * ),\n * }}\n * />\n * );\n * }\n *\n * ```\n *\n * @category Components\n */\nexport function Request<RT, E>($props: RequestProps<RT, E>): JSX.Element {\n return (\n <ReactiveContext>\n <InternalRequest {...$props} />\n </ReactiveContext>\n );\n}\n\nfunction isStrictModeRender(): boolean {\n const count = useRef<number>(0);\n\n // in debug we need to skip every second invocation\n if (DEBUG) {\n if (count.current++ % 2 === 1) {\n return true;\n }\n }\n\n return false;\n}\n\nfunction InternalRequest<RT, E>($props: RequestProps<RT, E>): JSX.Element {\n const isStrict = isStrictModeRender();\n const store = $props.store ?? useStore();\n const Chrome = $props.chrome ?? DefaultChrome;\n const sink = useRef<RequestSubscription<RT, E> | null>(null);\n const args = useRef<SubscriptionArgs<RT, E> | null>(null);\n\n if (!args.current) {\n args.current = new ReactiveArgs<RT, E>();\n }\n Object.assign(args.current, $props);\n\n if (sink.current && (sink.current.store !== store || $props.subscription)) {\n sink.current[DISPOSE]();\n sink.current = null;\n }\n\n if (!sink.current && !$props.subscription) {\n sink.current = createRequestSubscription(store, args.current!);\n }\n\n const initialized = useRef<null | {\n disposable: { [DISPOSE]: () => void } | null;\n dispose: () => void;\n }>(null);\n const effect = () => {\n if (sink.current && (!initialized.current || initialized.current.disposable !== sink.current)) {\n initialized.current = {\n disposable: sink.current,\n dispose: () => {\n sink.current?.[DISPOSE]();\n initialized.current = null;\n sink.current = null;\n },\n };\n }\n\n return sink.current ? initialized.current!.dispose : undefined;\n };\n let maybeEffect = effect;\n\n if (DEBUG) {\n if (isStrict) {\n maybeEffect = () => {\n if (initialized.current) {\n return effect();\n }\n return () => {\n // initialize our actual effect\n effect();\n // in strict mode we don't want to run the teardown\n // for the second invocation\n };\n };\n }\n }\n\n useEffect(maybeEffect, [sink.current]);\n\n const state = $props.subscription ?? sink.current!;\n const slots = $props.states;\n\n return (\n <Chrome state={state.isIdle ? null : state.reqState} features={state.contentFeatures}>\n {\n // prettier-ignore\n state.isIdle && slots.idle ? <slots.idle />\n : state.isIdle ? <Throw error={IdleBlockMissingError} />\n : state.reqState.isLoading ? slots.loading ? <slots.loading state={state.reqState.loadingState} /> : ''\n : state.reqState.isCancelled && slots.cancelled ? <slots.cancelled error={state.reqState.reason} features={state.errorFeatures} />\n : state.reqState.isError && slots.error ? <slots.error error={state.reqState.reason} features={state.errorFeatures} />\n : state.reqState.isSuccess ? slots.content ? <slots.content result={state.reqState.value} features={state.contentFeatures} /> : <Throw error={new Error('No content block provided for <Request> component.')} />\n : !state.reqState.isCancelled ? <Throw error={state.reqState.reason} />\n : '' // never\n }\n </Chrome>\n );\n}\n"],"x_google_ignoreList":[1],"mappings":";;;;;;;;;;;AAOA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AAIE,UACFc,oBAAoB;GAClB,IAAIL,YAAYV,SACd,OAAOW,OAAO;GAEhB,aAAa;IAEXA,OAAO;GAGT;EACF;CACF;CAGFhD,UAAUoD,aAAa,CAACV,KAAKL,OAAO,CAAC;CAErC,MAAMgB,QAAQvB,OAAOgB,gBAAgBJ,KAAKL;CAC1C,MAAMiB,QAAQxB,OAAOyB;CAErB,OACEzC,kBAAC0B,QAAM;EAACa,OAAOA,MAAMG,SAAS,OAAOH,MAAMI;EAAUC,UAAUL,MAAMM;EAAgBjC,UAGjF2B,MAAMG,UAAUF,MAAMM,OAAO9C,kBAACwC,MAAMM,MAAI,CAAA,CAAE,IACtCP,MAAMG,SAAS1C,kBAACa,OAAK,EAACC,OAAOb,sBAAsB,CAAE,IACrDsC,MAAMI,SAASI,YAAYP,MAAMQ,UAAUhD,kBAACwC,MAAMQ,SAAO,EAACT,OAAOA,MAAMI,SAASM,aAAa,CAAE,IAAI,KACnGV,MAAMI,SAASO,eAAeV,MAAMW,YAAYnD,kBAACwC,MAAMW,WAAS;GAACrC,OAAOyB,MAAMI,SAASS;GAAQR,UAAUL,MAAMc;EAAc,CAAE,IAC/Hd,MAAMI,SAASW,WAAWd,MAAM1B,QAAQd,kBAACwC,MAAM1B,OAAK;GAACA,OAAOyB,MAAMI,SAASS;GAAQR,UAAUL,MAAMc;EAAc,CAAE,IACnHd,MAAMI,SAASY,YAAYf,MAAMgB,UAAUxD,kBAACwC,MAAMgB,SAAO;GAACC,QAAQlB,MAAMI,SAASe;GAAOd,UAAUL,MAAMM;EAAgB,CAAE,IAAI7C,kBAACa,OAAK,EAACC,uBAAO,IAAIZ,MAAM,oDAAoD,EAAE,CAAE,IAC9M,CAACqC,MAAMI,SAASO,cAAclD,kBAACa,OAAK,EAACC,OAAOyB,MAAMI,SAASS,OAAO,CAAE,IACpE;CAAG,CAEH;AAEZ"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["createContext","use","useMemo","macroCondition","getGlobalConfig","jsx","_jsx","StoreContext","useStore","store","WarpDrive","env","DEBUG","test","Error","StoreProvider","$props","Store","value","children","useEffect","useRef","createRequestSubscription","DISPOSE","signal","ReactiveContext","useStore","getGlobalConfig","macroCondition","g","i","Fragment","_Fragment","jsx","_jsx","IdleBlockMissingError","Error","ReactiveArgs","prototype","request","query","autorefresh","autorefreshThreshold","autorefreshBehavior","DefaultChrome","children","Throw","error","Request","$props","InternalRequest","isStrictModeRender","count","WarpDrive","env","DEBUG","current","isStrict","store","Chrome","chrome","sink","args","Object","assign","subscription","initialized","effect","disposable","dispose","undefined","maybeEffect","state","slots","states","isIdle","reqState","features","contentFeatures","idle","isLoading","loading","loadingState","isCancelled","cancelled","reason","errorFeatures","isError","isSuccess","content","result","value"],"sources":["../src/-private/store-provider.tsx","../../../node_modules/.pnpm/decorat_5d4eca388601a94e7fbc656401b751d1/node_modules/decorator-transforms/dist/runtime--fcdnjmJ.js","../src/-private/request.tsx"],"sourcesContent":["import type { JSX, ReactNode } from \"react\";\nimport { createContext, use, useMemo } from \"react\";\n\nimport type { Store } from \"@warp-drive-mirror/core\";\nimport { assert } from \"@warp-drive-mirror/core/build-config/macros\";\n\n/**\n * @category Contexts\n */\nconst StoreContext = createContext<Store | null>(null);\n\n/**\n * @category Hooks\n */\nexport function useStore(): Store {\n const store = use(StoreContext);\n assert(\n \"No Store provided via context. Please ensure you are using <StoreProvider> to provide a Store instance.\",\n store\n );\n return store;\n}\n\ntype WithExistingStore = { store: Store; children: ReactNode };\ntype WithNewStore = { Store: typeof Store; children: ReactNode };\n\n/**\n * @category Components\n */\nexport function StoreProvider($props: WithExistingStore | WithNewStore): JSX.Element {\n const store = useMemo(\n () => (\"store\" in $props ? $props.store : new $props.Store()),\n [\"store\" in $props ? $props.store : $props.Store]\n );\n\n return <StoreContext value={store}>{$props.children}</StoreContext>;\n}\n","const deferred = /* @__PURE__ */ new WeakMap();\nfunction deferDecorator(proto, prop, desc) {\n let map = deferred.get(proto);\n if (!map) {\n map = /* @__PURE__ */ new Map();\n deferred.set(proto, map);\n }\n map.set(prop, desc);\n}\nfunction findDeferredDecorator(target, prop) {\n var _a;\n let cursor = target.prototype;\n while (cursor) {\n let desc = (_a = deferred.get(cursor)) == null ? void 0 : _a.get(prop);\n if (desc) {\n return desc;\n }\n cursor = Object.getPrototypeOf(cursor);\n }\n}\nfunction decorateFieldV1(target, prop, decorators, initializer) {\n return decorateFieldV2(target.prototype, prop, decorators, initializer);\n}\nfunction decorateFieldV2(prototype, prop, decorators, initializer) {\n let desc = {\n configurable: true,\n enumerable: true,\n writable: true,\n initializer: null\n };\n if (initializer) {\n desc.initializer = initializer;\n }\n for (let decorator of decorators) {\n desc = decorator(prototype, prop, desc) || desc;\n }\n if (desc.initializer === void 0) {\n Object.defineProperty(prototype, prop, desc);\n } else {\n deferDecorator(prototype, prop, desc);\n }\n}\nfunction decorateMethodV1({ prototype }, prop, decorators) {\n return decorateMethodV2(prototype, prop, decorators);\n}\nfunction decorateMethodV2(prototype, prop, decorators) {\n const origDesc = Object.getOwnPropertyDescriptor(prototype, prop);\n let desc = { ...origDesc };\n for (let decorator of decorators) {\n desc = decorator(prototype, prop, desc) || desc;\n }\n if (desc.initializer !== void 0) {\n desc.value = desc.initializer ? desc.initializer.call(prototype) : void 0;\n desc.initializer = void 0;\n }\n Object.defineProperty(prototype, prop, desc);\n}\nfunction initializeDeferredDecorator(target, prop) {\n let desc = findDeferredDecorator(target.constructor, prop);\n if (desc) {\n Object.defineProperty(target, prop, {\n enumerable: desc.enumerable,\n configurable: desc.configurable,\n writable: desc.writable,\n value: desc.initializer ? desc.initializer.call(target) : void 0\n });\n }\n}\nfunction decorateClass(target, decorators) {\n return decorators.reduce(\n (accum, decorator) => decorator(accum) || accum,\n target\n );\n}\nfunction decoratePOJO(pojo, decorated) {\n for (let [type, prop, decorators] of decorated) {\n if (type === \"field\") {\n decoratePojoField(pojo, prop, decorators);\n } else {\n decorateMethodV2(pojo, prop, decorators);\n }\n }\n return pojo;\n}\nfunction decoratePojoField(pojo, prop, decorators) {\n let desc = {\n configurable: true,\n enumerable: true,\n writable: true,\n initializer: () => {\n var _a;\n return (_a = Object.getOwnPropertyDescriptor(pojo, prop)) == null ? void 0 : _a.value;\n }\n };\n for (let decorator of decorators) {\n desc = decorator(pojo, prop, desc) || desc;\n }\n if (desc.initializer) {\n desc.value = desc.initializer.call(pojo);\n delete desc.initializer;\n }\n Object.defineProperty(pojo, prop, desc);\n}\nconst runtime = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({\n __proto__: null,\n c: decorateClass,\n f: decorateFieldV1,\n g: decorateFieldV2,\n i: initializeDeferredDecorator,\n m: decorateMethodV1,\n n: decorateMethodV2,\n p: decoratePOJO\n}, Symbol.toStringTag, { value: \"Module\" }));\nexport {\n decorateFieldV1 as a,\n decorateFieldV2 as b,\n decorateMethodV1 as c,\n decorateClass as d,\n decorateMethodV2 as e,\n decoratePOJO as f,\n initializeDeferredDecorator as i,\n runtime as r\n};\n//# sourceMappingURL=runtime--fcdnjmJ.js.map\n","import type { JSX, ReactNode } from \"react\";\nimport { useEffect, useRef } from \"react\";\n\nimport type { StoreRequestInput } from \"@warp-drive-mirror/core\";\nimport { DEBUG } from \"@warp-drive-mirror/core/build-config/env\";\nimport {\n createRequestSubscription,\n type RequestLoadingState,\n type RequestState,\n type RequestSubscription,\n} from \"@warp-drive-mirror/core/reactive\";\nimport type { Future } from \"@warp-drive-mirror/core/request\";\nimport {\n type AutorefreshBehaviorCombos,\n DISPOSE,\n type RequestArgs,\n signal,\n type ContentFeatures,\n type RecoveryFeatures,\n type SubscriptionArgs,\n} from \"@warp-drive-mirror/core/signals/-leaked\";\nimport type { StructuredErrorDocument } from \"@warp-drive-mirror/core/types/request\";\n\nimport { ReactiveContext } from \"./reactive-context\";\nimport { useStore } from \"./store-provider\";\n\nconst IdleBlockMissingError = new Error(\n \"No idle block provided for <Request> component, and no query or request was provided.\"\n);\n\nclass ReactiveArgs<RT, E> implements SubscriptionArgs<RT, E> {\n @signal request?: Future<RT> | undefined | null;\n @signal query?: StoreRequestInput<RT> | undefined | null;\n @signal autorefresh?: AutorefreshBehaviorCombos | undefined;\n @signal autorefreshThreshold?: number | undefined;\n @signal autorefreshBehavior?: \"refresh\" | \"reload\" | \"policy\";\n}\n\ninterface ChromeComponentProps<RT> {\n children: ReactNode;\n state: RequestState | null;\n features: ContentFeatures<RT>;\n}\n\nconst DefaultChrome = <RT,>({ children }: ChromeComponentProps<RT>) => {\n return <>{children}</>;\n};\n\nexport interface RequestProps<RT, E> extends RequestArgs<RT, E> {\n chrome?: React.FC<ChromeComponentProps<RT>>;\n\n states: RequestStates<RT, E>;\n}\n\ninterface RequestStates<RT, E> {\n /**\n * The block to render when the component is idle and waiting to be given a request.\n *\n */\n idle?: React.FC<object>;\n\n /**\n * The block to render when the request is loading.\n *\n */\n loading?: React.FC<{ state: RequestLoadingState }>;\n\n /**\n * The block to render when the request was cancelled.\n *\n */\n cancelled?: React.FC<{\n /**\n * The Error the request rejected with.\n */\n error: StructuredErrorDocument<E>;\n /**\n * Utilities to assist in recovering from the error.\n */\n features: RecoveryFeatures;\n }>;\n\n /**\n * The block to render when the request failed. If this block is not provided,\n * the error will be rethrown.\n *\n * Thus it is required to provide an error block and proper error handling if\n * you do not want the error to crash the application.\n */\n error: React.FC<{\n /**\n * The Error the request rejected with.\n */\n error: StructuredErrorDocument<E>;\n /**\n * Utilities to assist in recovering from the error.\n */\n features: RecoveryFeatures;\n }>;\n\n /**\n * The block to render when the request succeeded.\n *\n */\n content: React.FC<{ result: RT; features: ContentFeatures<RT> }>;\n}\n\n/**\n * Throws the given error. Used internally to rethrow request errors that\n * are not otherwise handled by a provided error/cancelled block.\n *\n * @private\n */\nexport function Throw({ error }: { error: Error }): never {\n throw error;\n}\n\n/**\n * The `<Request />` component is a powerful tool for managing data fetching and\n * state in your React application. It provides a declarative approach to reactive\n * control-flow for managing requests and state in your application.\n *\n * The `<Request />` component is ideal for handling \"boundaries\", outside which some\n * state is still allowed to be unresolved and within which it MUST be resolved.\n *\n * ## Request States\n *\n * `<Request />` has five states, only one of which will be active and rendered at a time.\n *\n * - `idle`: The component is waiting to be given a request to monitor\n * - `loading`: The request is in progress\n * - `error`: The request failed\n * - `content`: The request succeeded\n * - `cancelled`: The request was cancelled\n *\n * Additionally, the `content` state has a `refresh` method that can be used to\n * refresh the request in the background, which is available as a sub-state of\n * the `content` state.\n *\n * ### Example Usage\n *\n * ```tsx\n * import { Request } from \"@warp-drive-mirror/react\";\n *\n * export function UserPreview($props: { id: string | null }) {\n * return (\n * <Request\n * query={findRecord('user', $props.id)}\n * states={{\n * idle: () => <div>Waiting for User Selection</div>,\n * loading: ({ state }) => <div>Loading user data...</div>,\n * cancelled: ({ error, features }) => (\n * <div>\n * <p>Request Cancelled</p>\n * <p><button onClick={features.retry}>Start Again?</button></p>\n * </div>\n * ),\n * error: ({ error, features }) => (\n * <div>\n * <p>Error: {error.message}</p>\n * <p><button onClick={features.retry}>Try Again?</button></p>\n * </div>\n * ),\n * content: ({ result, features }) => (\n * <div>\n * <h2>User Details</h2>\n * <p>ID: {result.id}</p>\n * <p>Name: {result.name}</p>\n * </div>\n * ),\n * }}\n * />\n * );\n * }\n *\n * ```\n *\n * @category Components\n */\nexport function Request<RT, E>($props: RequestProps<RT, E>): JSX.Element {\n return (\n <ReactiveContext>\n <InternalRequest {...$props} />\n </ReactiveContext>\n );\n}\n\nfunction isStrictModeRender(): boolean {\n const count = useRef<number>(0);\n\n // in debug we need to skip every second invocation\n if (DEBUG) {\n if (count.current++ % 2 === 1) {\n return true;\n }\n }\n\n return false;\n}\n\nfunction InternalRequest<RT, E>($props: RequestProps<RT, E>): JSX.Element {\n const isStrict = isStrictModeRender();\n const store = $props.store ?? useStore();\n const Chrome = $props.chrome ?? DefaultChrome;\n const sink = useRef<RequestSubscription<RT, E> | null>(null);\n const args = useRef<SubscriptionArgs<RT, E> | null>(null);\n\n if (!args.current) {\n args.current = new ReactiveArgs<RT, E>();\n }\n Object.assign(args.current, $props);\n\n if (sink.current && (sink.current.store !== store || $props.subscription)) {\n sink.current[DISPOSE]();\n sink.current = null;\n }\n\n if (!sink.current && !$props.subscription) {\n sink.current = createRequestSubscription(store, args.current);\n }\n\n const initialized = useRef<null | {\n disposable: { [DISPOSE]: () => void } | null;\n dispose: () => void;\n }>(null);\n const effect = () => {\n if (sink.current && (!initialized.current || initialized.current.disposable !== sink.current)) {\n initialized.current = {\n disposable: sink.current,\n dispose: () => {\n sink.current?.[DISPOSE]();\n initialized.current = null;\n sink.current = null;\n },\n };\n }\n\n return sink.current ? initialized.current!.dispose : undefined;\n };\n let maybeEffect = effect;\n\n if (DEBUG) {\n if (isStrict) {\n maybeEffect = () => {\n if (initialized.current) {\n return effect();\n }\n return () => {\n // initialize our actual effect\n effect();\n // in strict mode we don't want to run the teardown\n // for the second invocation\n };\n };\n }\n }\n\n useEffect(maybeEffect, [sink.current]);\n\n const state = $props.subscription ?? sink.current!;\n const slots = $props.states;\n\n return (\n <Chrome state={state.isIdle ? null : state.reqState} features={state.contentFeatures}>\n {\n // prettier-ignore\n state.isIdle && slots.idle ? <slots.idle />\n : state.isIdle ? <Throw error={IdleBlockMissingError} />\n : state.reqState.isLoading ? slots.loading ? <slots.loading state={state.reqState.loadingState} /> : ''\n : state.reqState.isCancelled && slots.cancelled ? <slots.cancelled error={state.reqState.reason} features={state.errorFeatures} />\n : state.reqState.isError && slots.error ? <slots.error error={state.reqState.reason} features={state.errorFeatures} />\n : state.reqState.isSuccess ? slots.content ? <slots.content result={state.reqState.value} features={state.contentFeatures} /> : <Throw error={new Error('No content block provided for <Request> component.')} />\n : !state.reqState.isCancelled ? <Throw error={state.reqState.reason} />\n : '' // never\n }\n </Chrome>\n );\n}\n"],"x_google_ignoreList":[1],"mappings":";;;;;;;;;;;AASA,MAAMO,eAAeP,4BAA4B,IAAI;;;;AAKrD,SAAgBQ,WAAkB;CAChC,MAAMC,QAAQR,IAAIM,YAAY;CAC9BJ,eAAAC,gBAAA,CAAA,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L,OAAO,CAAC;CAErC,MAAMgB,QAAQvB,OAAOgB,gBAAgBJ,KAAKL;CAC1C,MAAMiB,QAAQxB,OAAOyB;CAErB,OACExC,kBAACyB,QAAM;EAACa,OAAOA,MAAMG,SAAS,OAAOH,MAAMI;EAAUC,UAAUL,MAAMM;EAAgBjC,UAGjF2B,MAAMG,UAAUF,MAAMM,OAAO7C,kBAACuC,MAAMM,MAAI,CAAA,CAAE,IACtCP,MAAMG,SAASzC,kBAACY,OAAK,EAACC,OAAOZ,sBAAsB,CAAE,IACrDqC,MAAMI,SAASI,YAAYP,MAAMQ,UAAU/C,kBAACuC,MAAMQ,SAAO,EAACT,OAAOA,MAAMI,SAASM,aAAa,CAAE,IAAI,KACnGV,MAAMI,SAASO,eAAeV,MAAMW,YAAYlD,kBAACuC,MAAMW,WAAS;GAACrC,OAAOyB,MAAMI,SAASS;GAAQR,UAAUL,MAAMc;EAAc,CAAE,IAC/Hd,MAAMI,SAASW,WAAWd,MAAM1B,QAAQb,kBAACuC,MAAM1B,OAAK;GAACA,OAAOyB,MAAMI,SAASS;GAAQR,UAAUL,MAAMc;EAAc,CAAE,IACnHd,MAAMI,SAASY,YAAYf,MAAMgB,UAAUvD,kBAACuC,MAAMgB,SAAO;GAACC,QAAQlB,MAAMI,SAASe;GAAOd,UAAUL,MAAMM;EAAgB,CAAE,IAAI5C,kBAACY,OAAK,EAACC,uBAAO,IAAIX,MAAM,oDAAoD,EAAE,CAAE,IAC9M,CAACoC,MAAMI,SAASO,cAAcjD,kBAACY,OAAK,EAACC,OAAOyB,MAAMI,SAASS,OAAO,CAAE,IACpE;CAAG,CAEH;AAEZ"}
|
package/dist/install.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { n as WatcherContext } from "./reactive-context-
|
|
2
|
-
import { Signal } from "signal-polyfill";
|
|
1
|
+
import { n as WatcherContext } from "./reactive-context-DhUW_l--.js";
|
|
3
2
|
import { use } from "react";
|
|
3
|
+
import { Signal } from "signal-polyfill";
|
|
4
4
|
import { getGlobalConfig, macroCondition } from "@embroider/macros";
|
|
5
5
|
import { setupSignals } from "@warp-drive-mirror/core/configure";
|
|
6
6
|
|
package/dist/install.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"install.js","names":["use","Signal","setupSignals","WatcherContext","getGlobalConfig","macroCondition","tryConsumeContext","signal","logError","console","error","watcher","watch","WarpDrive","activeLogging","LOG_REACT_SIGNAL_INTEGRATION","debug","globalThis","getWarpDriveRuntimeConfig","log","pending","settled","env","TESTING","length","current","Promise","allSettled","resolve","buildSignalConfig","options","createSignal","obj","key","State","DEBUG","equals","notifySignal","subtle","hasSinks","set","get","consumeSignal","createMemo","object","fn","memo","Computed","waitFor","promise","newPromise","finally","filter","p","push","willSyncFlushWatchers"],"sources":["../src/install.ts"],"sourcesContent":["/**\n * {@include ./install.md}\n * @module\n */\n\nimport { use } from 'react';\nimport { Signal } from 'signal-polyfill';\n\nimport { LOG_REACT_SIGNAL_INTEGRATION } from '@warp-drive-mirror/core/build-config/debugging';\nimport { DEBUG, TESTING } from '@warp-drive-mirror/core/build-config/env';\nimport { type HooksOptions, setupSignals, type SignalHooks } from '@warp-drive-mirror/core/configure';\n\nimport { WatcherContext } from './-private/reactive-context';\n\nfunction tryConsumeContext(signal: Signal.State<unknown> | Signal.Computed<unknown>): void {\n //
|
|
1
|
+
{"version":3,"file":"install.js","names":["use","Signal","setupSignals","WatcherContext","getGlobalConfig","macroCondition","tryConsumeContext","signal","logError","console","error","watcher","watch","WarpDrive","activeLogging","LOG_REACT_SIGNAL_INTEGRATION","debug","globalThis","getWarpDriveRuntimeConfig","log","pending","settled","env","TESTING","length","current","Promise","allSettled","resolve","buildSignalConfig","options","createSignal","obj","key","State","DEBUG","equals","notifySignal","subtle","hasSinks","set","get","consumeSignal","createMemo","object","fn","memo","Computed","waitFor","promise","newPromise","finally","filter","p","push","willSyncFlushWatchers"],"sources":["../src/install.ts"],"sourcesContent":["/**\n * {@include ./install.md}\n * @module\n */\n\nimport { use } from 'react';\nimport { Signal } from 'signal-polyfill';\n\nimport { LOG_REACT_SIGNAL_INTEGRATION } from '@warp-drive-mirror/core/build-config/debugging';\nimport { DEBUG, TESTING } from '@warp-drive-mirror/core/build-config/env';\nimport { type HooksOptions, setupSignals, type SignalHooks } from '@warp-drive-mirror/core/configure';\n\nimport { WatcherContext } from './-private/reactive-context';\n\nfunction tryConsumeContext(signal: Signal.State<unknown> | Signal.Computed<unknown>): void {\n // oxlint-disable-next-line no-console\n const logError = console.error;\n try {\n // oxlint-disable-next-line no-console\n console.error = () => {};\n // ensure signals are watched by our closest watcher\n const watcher = use(WatcherContext);\n // oxlint-disable-next-line no-console\n console.error = logError;\n watcher?.watcher.watch(signal);\n if (LOG_REACT_SIGNAL_INTEGRATION) {\n // oxlint-disable-next-line no-console\n console.log(`[WarpDrive] Consumed Context Signal`, signal, watcher);\n }\n } catch {\n // oxlint-disable-next-line no-console\n console.error = logError;\n // if we are not in a React context, we will Error\n // so we just ignore it.\n if (LOG_REACT_SIGNAL_INTEGRATION) {\n // oxlint-disable-next-line no-console\n console.log(`[WarpDrive] No Context Available To Consume Signal`, signal);\n }\n }\n}\n\nlet pending: Promise<unknown>[];\n/**\n * Resolves once all pending requests started via WarpDrive's React signal\n * integration have settled. Only tracks requests while `TESTING` is enabled;\n * a no-op otherwise.\n *\n * @public\n */\nexport async function settled(): Promise<void> {\n if (TESTING) {\n // in testing mode we provide a test waiter integration\n if (!pending || !pending.length) return;\n const current = pending ?? [];\n pending = [];\n await Promise.allSettled(current);\n await Promise.resolve();\n await Promise.resolve();\n await Promise.resolve();\n\n return settled();\n }\n}\n\n/**\n * Builds the {@link SignalHooks} implementation backed by the\n * [Signal Polyfill](https://github.com/proposal-signals/signal-polyfill),\n * used to wire WarpDrive's reactivity primitives into React.\n *\n * @public\n */\nexport function buildSignalConfig(options: HooksOptions): SignalHooks {\n return {\n createSignal: (obj: object, key: string | symbol) =>\n new Signal.State(DEBUG ? { obj, key } : null, { equals: () => false }),\n\n notifySignal: (signal: Signal.State<unknown>) => {\n if (LOG_REACT_SIGNAL_INTEGRATION) {\n if (Signal.subtle.hasSinks(signal)) {\n // oxlint-disable-next-line no-console\n console.log(`[WarpDrive] Notifying Signal`, signal);\n } else {\n // oxlint-disable-next-line no-console\n console.log(`[WarpDrive] Notified Signal That Has No Watcher`, signal);\n }\n }\n signal.set(signal.get());\n },\n\n consumeSignal: (signal: Signal.State<unknown>) => {\n tryConsumeContext(signal);\n void signal.get();\n },\n\n createMemo: <F>(object: object, key: string | symbol, fn: () => F): (() => F) => {\n const memo = new Signal.Computed<F>(fn);\n return () => {\n tryConsumeContext(memo);\n\n return memo.get();\n };\n },\n\n waitFor: (promise) => {\n if (TESTING) {\n pending = pending || [];\n const newPromise = promise.finally(() => {\n pending = pending.filter((p) => p !== newPromise);\n });\n pending.push(newPromise);\n return newPromise;\n }\n return promise;\n },\n\n willSyncFlushWatchers: () => false,\n } as SignalHooks;\n}\n\nsetupSignals(buildSignalConfig);\n"],"mappings":";;;;;;;;;;;AAcA,SAASM,kBAAkBC,QAAgE;CAEzF,MAAMC,WAAWC,QAAQC;CACzB,IAAI;EAEFD,QAAQC,cAAc,CAAC;EAEvB,MAAMC,UAAUX,IAAIG,cAAc;EAElCM,QAAQC,QAAQF;EAChBG,SAASA,QAAQC,MAAML,MAAM;EAC7B,IAAAF,eAAAD,gBAAA,CAAA,CAAAS,UAAAC,cAAAC,4BAAA,GAAA;OAAAX,gBAAA,CAAA,CAAAS,UAAAG,MAAAD,gCAAAE,WAAAC,0BAAA,CAAA,CAAAF,MAAAD,8BAEEN,QAAQU,IAAI,uCAAuCZ,QAAQI,OAAO;EACpE;CACF,QAAQ;EAENF,QAAQC,QAAQF;EAGhB,IAAAH,eAAAD,gBAAA,CAAA,CAAAS,UAAAC,cAAAC,4BAAA,GAAA;OAAAX,gBAAA,CAAA,CAAAS,UAAAG,MAAAD,gCAAAE,WAAAC,0BAAA,CAAA,CA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AAKL,IAAI;GAClB;EACF;EAEAO,UAAUC,YAAY;GACpB,IAAA5C,eAAAD,gBAAA,CAAA,CAAAS,UAAAS,IAAAC,OAAA,GAAa;IACXH,UAAUA,WAAW,CAAA;IACrB,MAAM8B,aAAaD,QAAQE,cAAc;KACvC/B,UAAUA,QAAQgC,QAAQC,MAAMA,MAAMH,UAAU;IAClD,CAAC;IACD9B,QAAQkC,KAAKJ,UAAU;IACvB,OAAOA;GACT;GACA,OAAOD;EACT;EAEAM,6BAA6B;CAC/B;AACF;AAEArD,aAAa2B,iBAAiB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Signal } from "signal-polyfill";
|
|
2
1
|
import { createContext, useMemo, useSyncExternalStore } from "react";
|
|
2
|
+
import { Signal } from "signal-polyfill";
|
|
3
3
|
import { getGlobalConfig, macroCondition } from "@embroider/macros";
|
|
4
4
|
import { jsx } from "react/jsx-runtime";
|
|
5
5
|
|
|
@@ -119,4 +119,4 @@ function ReactiveContext({ children }) {
|
|
|
119
119
|
|
|
120
120
|
//#endregion
|
|
121
121
|
export { WatcherContext as n, ReactiveContext as t };
|
|
122
|
-
//# sourceMappingURL=reactive-context-
|
|
122
|
+
//# sourceMappingURL=reactive-context-DhUW_l--.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reactive-context-DhUW_l--.js","names":["createContext","useSyncExternalStore","useMemo","Signal","getGlobalConfig","macroCondition","jsx","_jsx","nextFlush","watchers","watcherId","clearWatcher","state","watcher","unwatch","subtle","introspectSources","flush","pending","destroyed","WarpDrive","activeLogging","LOG_REACT_SIGNAL_INTEGRATION","debug","globalThis","getWarpDriveRuntimeConfig","console","log","snapshot","Set","getPending","notifyReact","watch","_createWatcher","id","Watcher","args","push","Promise","resolve","queueMicrotask","forEach","map","w","useWatcher","notifyChanged","WatcherContext","ReactiveContext","children","value"],"sources":["../src/-private/reactive-context.tsx"],"sourcesContent":["import { createContext, type JSX, type ReactNode, useSyncExternalStore, type Context, useMemo } from \"react\";\nimport { Signal } from \"signal-polyfill\";\n\nimport { LOG_REACT_SIGNAL_INTEGRATION } from \"@warp-drive-mirror/core/build-config/debugging\";\n\nlet nextFlush: Promise<void> | null = null;\nlet watchers: WatcherState[] = [];\nlet watcherId = 0;\n\ninterface WatcherState {\n watcherId: number;\n pending: boolean;\n destroyed: boolean;\n notifyReact: (() => void) | null;\n watcher: Signal.subtle.Watcher;\n\n // the extra wrapper returned here ensures that the context value for the watcher\n // changes causing a re-render when the watcher is updated.\n snapshot: { watcher: Signal.subtle.Watcher } | null;\n}\n\nfunction clearWatcher(state: WatcherState) {\n state.watcher.unwatch(...Signal.subtle.introspectSources(state.watcher));\n}\n\nfunction flush(state: WatcherState) {\n state.pending = false;\n if (state.destroyed) {\n if (LOG_REACT_SIGNAL_INTEGRATION) {\n // eslint-disable-next-line no-console\n console.log(`[WarpDrive] Detected Watcher Destroyed During Notify Flush, clearing signals`);\n }\n state.snapshot = null;\n clearWatcher(state);\n return;\n }\n\n if (LOG_REACT_SIGNAL_INTEGRATION) {\n /* eslint-disable no-console */\n console.log(`[WarpDrive] Notifying React That WatcherContext:${state.watcherId} Has Updated`);\n console.log(\"all signals\", new Set(Signal.subtle.introspectSources(state.watcher)));\n console.log(\"dirty signals\", new Set(state.watcher.getPending()));\n /* eslint-enable no-console */\n }\n\n // any time signals have changed, we notify React that our store has updated\n state.snapshot = { watcher: state.watcher };\n if (state.notifyReact) state.notifyReact();\n\n // tell the Watcher to start watching for changes again\n // by signaling that notifications have been flushed.\n state.watcher.watch();\n}\n\nfunction _createWatcher() {\n const id = watcherId++;\n if (LOG_REACT_SIGNAL_INTEGRATION) {\n // eslint-disable-next-line no-console\n console.log(`[WarpDrive] Creating a WatcherContext:${id}`);\n }\n const state: WatcherState = {\n watcherId: id,\n pending: false,\n destroyed: false,\n notifyReact: null as (() => void) | null,\n watcher: null as unknown as Signal.subtle.Watcher,\n\n // the extra wrapper returned here ensures that the context value for the watcher\n // changes causing a re-render when the watcher is updated.\n snapshot: null as { watcher: Signal.subtle.Watcher } | null,\n };\n\n state.watcher = new Signal.subtle.Watcher((...args) => {\n if (LOG_REACT_SIGNAL_INTEGRATION) {\n // eslint-disable-next-line no-console\n console.log(`watcher ${state.watcherId} notified`, args, state.watcher);\n }\n if (!state.pending && !state.destroyed) {\n watchers.push(state);\n state.pending = true;\n\n if (!nextFlush) {\n nextFlush = new Promise((resolve) => {\n queueMicrotask(() => {\n queueMicrotask(() => {\n queueMicrotask(() => {\n watchers.forEach(flush);\n if (LOG_REACT_SIGNAL_INTEGRATION) {\n // eslint-disable-next-line no-console\n console.log(\n \"Flushed watcher:\",\n watchers.map((w) => w.watcherId)\n );\n }\n watchers = [];\n nextFlush = null;\n\n resolve();\n });\n });\n });\n });\n }\n } else if (state.destroyed) {\n if (LOG_REACT_SIGNAL_INTEGRATION) {\n // eslint-disable-next-line no-console\n console.log(`[WarpDrive] Detected Watcher Destroyed During Notify, clearing signals`);\n }\n // if we are destroyed, we clear the watcher signals\n // so that it does not continue to watch for changes.\n state.snapshot = null;\n clearWatcher(state);\n }\n });\n\n // The watcher won't begin watching until we call `watcher.watch()`\n state.watcher.watch();\n state.snapshot = { watcher: state.watcher };\n\n return state;\n}\n\nexport function useWatcher(): { watcher: Signal.subtle.Watcher } | null {\n const state = useMemo(_createWatcher, []);\n\n return useSyncExternalStore(\n (notifyChanged: () => void) => {\n if (LOG_REACT_SIGNAL_INTEGRATION) {\n // eslint-disable-next-line no-console\n console.log(`[WarpDrive] Subscribing to Watcher`);\n }\n state.destroyed = false;\n state.notifyReact = notifyChanged;\n\n // The watcher won't begin watching until we call `watcher.watch()`\n state.watcher.watch();\n\n return () => {\n if (LOG_REACT_SIGNAL_INTEGRATION) {\n // eslint-disable-next-line no-console\n console.log(`[WarpDrive] Deactivating Watcher Subscription`);\n }\n state.destroyed = true;\n state.notifyReact = null;\n };\n },\n () => state.snapshot\n );\n}\n\n/**\n * @category Contexts\n */\nexport const WatcherContext: Context<{\n /**\n * The `Signal.subtle.Watcher` used to observe signal changes for the nearest {@link ReactiveContext}.\n */\n watcher: Signal.subtle.Watcher;\n} | null> = createContext<{\n watcher: Signal.subtle.Watcher;\n} | null>(null);\n\n/**\n *\n * @category Components\n */\nexport function ReactiveContext({ children }: { children: ReactNode }): JSX.Element {\n const watcher = useWatcher();\n /**\n * Unlike other frameworks, React does not have a built-in way to provide\n * a context value other than by rendering an extra component.\n *\n */\n return <WatcherContext value={watcher}>{children}</WatcherContext>;\n}\n"],"mappings":";;;;;;AAKA,IAAIQ,YAAkC;AACtC,IAAIC,WAA2B,CAAA;AAC/B,IAAIC,YAAY;AAchB,SAASC,aAAaC,OAAqB;CACzCA,MAAMC,QAAQC,QAAQ,GAAGX,OAAOY,OAAOC,kBAAkBJ,MAAMC,OAAO,CAAC;AACzE;AAEA,SAASI,MAAML,OAAqB;CAClCA,MAAMM,UAAU;CAChB,IAAIN,MAAMO,WAAW;EACnB,IAAAd,eAAAD,gBAAA,CAAA,CAAAgB,UAAAC,cAAAC,4BAAA,GAAA;OAAAlB,gBAAA,CAAA,CAAAgB,UAAAG,MAAAD,gCAAAE,WAAAC,0BAAA,CAAA,CAAAF,MAAAD,8BAEEI,QAAQC,IAAI,8EAA8E;EAC5F;EACAf,MAAMgB,WAAW;EACjBjB,aAAaC,KAAK;EAClB;CACF;CAEA,IAAAP,eAAAD,gBAAA,CAAA,CAAAgB,UAAAC,cAAAC,4BAAA,GAAA;MAAAlB,gBAAA,CAAA,CAAAgB,UAAAG,MAAAD,gCAAAE,WAAAC,0BAAA,CAAA,CAAAF,MAAAD,8BAAkC;GAEhCI,QAAQC,IAAI,mDAAmDf,MAAMF,UAAS,aAAc;GAC5FgB,QAAQC,IAAI,eAAe,IAAIE,IAAI1B,OAAOY,OAAOC,kBAAkBJ,MAAMC,OAAO,CAAC,CAAC;GAClFa,QAAQC,IAAI,iBAAiB,IAAIE,IAAIjB,MAAMC,QAAQiB,WAAW,CAAC,CAAC;EAElE;;CA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AClF,MAAMnC,UAAU+B,WAAW;;;;;;CAM3B,OAAOrC,kBAACuC,gBAAc;EAACG,OAAOpC;EAAUmC;CAAQ,CAAiB;AACnE"}
|
package/dist/unpkg/dev/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as WatcherContext, t as ReactiveContext } from "./reactive-context-
|
|
1
|
+
import { n as WatcherContext, t as ReactiveContext } from "./reactive-context-Ax2U-96G.js";
|
|
2
2
|
import { createContext, use, useEffect, useMemo, useRef } from "react";
|
|
3
3
|
import { Fragment, jsxDEV } from "react/jsx-dev-runtime";
|
|
4
4
|
import { createRequestSubscription } from "@warp-drive-mirror/core/reactive";
|
|
@@ -30,13 +30,13 @@ function StoreProvider($props) {
|
|
|
30
30
|
children: $props.children
|
|
31
31
|
}, void 0, false, {
|
|
32
32
|
fileName: _jsxFileName$1,
|
|
33
|
-
lineNumber:
|
|
33
|
+
lineNumber: 36,
|
|
34
34
|
columnNumber: 10
|
|
35
35
|
}, this);
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
//#endregion
|
|
39
|
-
//#region ../../node_modules/.pnpm/
|
|
39
|
+
//#region ../../node_modules/.pnpm/decorat_5d4eca388601a94e7fbc656401b751d1/node_modules/decorator-transforms/dist/runtime--fcdnjmJ.js
|
|
40
40
|
const deferred = /* @__PURE__ */ new WeakMap();
|
|
41
41
|
function deferDecorator(proto, prop, desc) {
|
|
42
42
|
let map = deferred.get(proto);
|
|
@@ -52,7 +52,7 @@ function findDeferredDecorator(target, prop) {
|
|
|
52
52
|
while (cursor) {
|
|
53
53
|
let desc = (_a = deferred.get(cursor)) == null ? void 0 : _a.get(prop);
|
|
54
54
|
if (desc) return desc;
|
|
55
|
-
cursor = cursor
|
|
55
|
+
cursor = Object.getPrototypeOf(cursor);
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
function decorateFieldV2(prototype, prop, decorators, initializer) {
|
|
@@ -180,11 +180,11 @@ function Throw({ error }) {
|
|
|
180
180
|
function Request($props) {
|
|
181
181
|
return /*#__PURE__*/ jsxDEV(ReactiveContext, { children: /*#__PURE__*/ jsxDEV(InternalRequest, { ...$props }, void 0, false, {
|
|
182
182
|
fileName: _jsxFileName,
|
|
183
|
-
lineNumber:
|
|
183
|
+
lineNumber: 183,
|
|
184
184
|
columnNumber: 7
|
|
185
185
|
}, this) }, void 0, false, {
|
|
186
186
|
fileName: _jsxFileName,
|
|
187
|
-
lineNumber:
|
|
187
|
+
lineNumber: 182,
|
|
188
188
|
columnNumber: 5
|
|
189
189
|
}, this);
|
|
190
190
|
}
|
|
@@ -233,49 +233,49 @@ function InternalRequest($props) {
|
|
|
233
233
|
features: state.contentFeatures,
|
|
234
234
|
children: state.isIdle && slots.idle ? /*#__PURE__*/ jsxDEV(slots.idle, {}, void 0, false, {
|
|
235
235
|
fileName: _jsxFileName,
|
|
236
|
-
lineNumber:
|
|
236
|
+
lineNumber: 267,
|
|
237
237
|
columnNumber: 38
|
|
238
238
|
}, this) : state.isIdle ? /*#__PURE__*/ jsxDEV(Throw, { error: IdleBlockMissingError }, void 0, false, {
|
|
239
239
|
fileName: _jsxFileName,
|
|
240
|
-
lineNumber:
|
|
240
|
+
lineNumber: 268,
|
|
241
241
|
columnNumber: 28
|
|
242
242
|
}, this) : state.reqState.isLoading ? slots.loading ? /*#__PURE__*/ jsxDEV(slots.loading, { state: state.reqState.loadingState }, void 0, false, {
|
|
243
243
|
fileName: _jsxFileName,
|
|
244
|
-
lineNumber:
|
|
244
|
+
lineNumber: 269,
|
|
245
245
|
columnNumber: 56
|
|
246
246
|
}, this) : "" : state.reqState.isCancelled && slots.cancelled ? /*#__PURE__*/ jsxDEV(slots.cancelled, {
|
|
247
247
|
error: state.reqState.reason,
|
|
248
248
|
features: state.errorFeatures
|
|
249
249
|
}, void 0, false, {
|
|
250
250
|
fileName: _jsxFileName,
|
|
251
|
-
lineNumber:
|
|
251
|
+
lineNumber: 270,
|
|
252
252
|
columnNumber: 61
|
|
253
253
|
}, this) : state.reqState.isError && slots.error ? /*#__PURE__*/ jsxDEV(slots.error, {
|
|
254
254
|
error: state.reqState.reason,
|
|
255
255
|
features: state.errorFeatures
|
|
256
256
|
}, void 0, false, {
|
|
257
257
|
fileName: _jsxFileName,
|
|
258
|
-
lineNumber:
|
|
258
|
+
lineNumber: 271,
|
|
259
259
|
columnNumber: 53
|
|
260
260
|
}, this) : state.reqState.isSuccess ? slots.content ? /*#__PURE__*/ jsxDEV(slots.content, {
|
|
261
261
|
result: state.reqState.value,
|
|
262
262
|
features: state.contentFeatures
|
|
263
263
|
}, void 0, false, {
|
|
264
264
|
fileName: _jsxFileName,
|
|
265
|
-
lineNumber:
|
|
265
|
+
lineNumber: 272,
|
|
266
266
|
columnNumber: 56
|
|
267
267
|
}, this) : /*#__PURE__*/ jsxDEV(Throw, { error: /* @__PURE__ */ new Error("No content block provided for <Request> component.") }, void 0, false, {
|
|
268
268
|
fileName: _jsxFileName,
|
|
269
|
-
lineNumber:
|
|
269
|
+
lineNumber: 272,
|
|
270
270
|
columnNumber: 139
|
|
271
271
|
}, this) : !state.reqState.isCancelled ? /*#__PURE__*/ jsxDEV(Throw, { error: state.reqState.reason }, void 0, false, {
|
|
272
272
|
fileName: _jsxFileName,
|
|
273
|
-
lineNumber:
|
|
273
|
+
lineNumber: 273,
|
|
274
274
|
columnNumber: 43
|
|
275
275
|
}, this) : ""
|
|
276
276
|
}, void 0, false, {
|
|
277
277
|
fileName: _jsxFileName,
|
|
278
|
-
lineNumber:
|
|
278
|
+
lineNumber: 264,
|
|
279
279
|
columnNumber: 5
|
|
280
280
|
}, this);
|
|
281
281
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["Store","createContext","JSX","ReactNode","use","useMemo","jsxDEV","_jsxDEV","StoreContext","useStore","store","test","Error","StoreProvider","$props","value","children","fileName","_jsxFileName","lineNumber","columnNumber","createRequestSubscription","AutorefreshBehaviorCombos","DISPOSE","RequestArgs","signal","JSX","ReactNode","useEffect","useMemo","useRef","useStore","ReactiveContext","Future","StoreRequestInput","g","i","Fragment","_Fragment","jsxDEV","_jsxDEV","IdleBlockMissingError","Error","ReactiveArgs","prototype","request","void 0","query","autorefresh","autorefreshThreshold","autorefreshBehavior","DefaultChrome","children","Throw","error","Request","$props","InternalRequest","fileName","_jsxFileName","lineNumber","columnNumber","isStrictModeRender","count","current","isStrict","store","Chrome","chrome","sink","args","Object","assign","subscription","initialized","effect","disposable","dispose","undefined","maybeEffect","state","slots","states","isIdle","reqState","features","contentFeatures","idle","isLoading","loading","loadingState","isCancelled","cancelled","reason","errorFeatures","isError","isSuccess","content","result","value"],"sources":["../../../src/-private/store-provider.tsx","../../../../../node_modules/.pnpm/decorat_5005bbc272376d25df08203abab44e2f/node_modules/decorator-transforms/dist/runtime-BPCpkOf1.js","../../../src/-private/request.tsx"],"sourcesContent":["import { Store } from \"@warp-drive-mirror/core\";\nimport { assert } from \"@warp-drive-mirror/core/build-config/macros\";\nimport { createContext, JSX, ReactNode, use, useMemo } from \"react\";\n\n/**\n * @category Contexts\n */\nconst StoreContext = createContext<Store | null>(null);\n\n/**\n * @category Hooks\n */\nexport function useStore(): Store {\n const store = use(StoreContext);\n assert(\n \"No Store provided via context. Please ensure you are using <StoreProvider> to provide a Store instance.\",\n store\n );\n return store;\n}\n\ntype WithExistingStore = { store: Store; children: ReactNode };\ntype WithNewStore = { Store: typeof Store; children: ReactNode };\n\n/**\n * @category Components\n */\nexport function StoreProvider($props: WithExistingStore | WithNewStore): JSX.Element {\n const store = useMemo(\n () => (\"store\" in $props ? $props.store : new $props.Store()),\n [\"store\" in $props ? $props.store : $props.Store]\n );\n\n return <StoreContext value={store}>{$props.children}</StoreContext>;\n}\n","const deferred = /* @__PURE__ */ new WeakMap();\nfunction deferDecorator(proto, prop, desc) {\n let map = deferred.get(proto);\n if (!map) {\n map = /* @__PURE__ */ new Map();\n deferred.set(proto, map);\n }\n map.set(prop, desc);\n}\nfunction findDeferredDecorator(target, prop) {\n var _a;\n let cursor = target.prototype;\n while (cursor) {\n let desc = (_a = deferred.get(cursor)) == null ? void 0 : _a.get(prop);\n if (desc) {\n return desc;\n }\n cursor = cursor.prototype;\n }\n}\nfunction decorateFieldV1(target, prop, decorators, initializer) {\n return decorateFieldV2(target.prototype, prop, decorators, initializer);\n}\nfunction decorateFieldV2(prototype, prop, decorators, initializer) {\n let desc = {\n configurable: true,\n enumerable: true,\n writable: true,\n initializer: null\n };\n if (initializer) {\n desc.initializer = initializer;\n }\n for (let decorator of decorators) {\n desc = decorator(prototype, prop, desc) || desc;\n }\n if (desc.initializer === void 0) {\n Object.defineProperty(prototype, prop, desc);\n } else {\n deferDecorator(prototype, prop, desc);\n }\n}\nfunction decorateMethodV1({ prototype }, prop, decorators) {\n return decorateMethodV2(prototype, prop, decorators);\n}\nfunction decorateMethodV2(prototype, prop, decorators) {\n const origDesc = Object.getOwnPropertyDescriptor(prototype, prop);\n let desc = { ...origDesc };\n for (let decorator of decorators) {\n desc = decorator(prototype, prop, desc) || desc;\n }\n if (desc.initializer !== void 0) {\n desc.value = desc.initializer ? desc.initializer.call(prototype) : void 0;\n desc.initializer = void 0;\n }\n Object.defineProperty(prototype, prop, desc);\n}\nfunction initializeDeferredDecorator(target, prop) {\n let desc = findDeferredDecorator(target.constructor, prop);\n if (desc) {\n Object.defineProperty(target, prop, {\n enumerable: desc.enumerable,\n configurable: desc.configurable,\n writable: desc.writable,\n value: desc.initializer ? desc.initializer.call(target) : void 0\n });\n }\n}\nfunction decorateClass(target, decorators) {\n return decorators.reduce(\n (accum, decorator) => decorator(accum) || accum,\n target\n );\n}\nfunction decoratePOJO(pojo, decorated) {\n for (let [type, prop, decorators] of decorated) {\n if (type === \"field\") {\n decoratePojoField(pojo, prop, decorators);\n } else {\n decorateMethodV2(pojo, prop, decorators);\n }\n }\n return pojo;\n}\nfunction decoratePojoField(pojo, prop, decorators) {\n let desc = {\n configurable: true,\n enumerable: true,\n writable: true,\n initializer: () => {\n var _a;\n return (_a = Object.getOwnPropertyDescriptor(pojo, prop)) == null ? void 0 : _a.value;\n }\n };\n for (let decorator of decorators) {\n desc = decorator(pojo, prop, desc) || desc;\n }\n if (desc.initializer) {\n desc.value = desc.initializer.call(pojo);\n delete desc.initializer;\n }\n Object.defineProperty(pojo, prop, desc);\n}\nconst runtime = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({\n __proto__: null,\n c: decorateClass,\n f: decorateFieldV1,\n g: decorateFieldV2,\n i: initializeDeferredDecorator,\n m: decorateMethodV1,\n n: decorateMethodV2,\n p: decoratePOJO\n}, Symbol.toStringTag, { value: \"Module\" }));\nexport {\n decorateFieldV2 as a,\n decorateMethodV1 as b,\n decorateMethodV2 as c,\n decorateFieldV1 as d,\n decorateClass as e,\n decoratePOJO as f,\n initializeDeferredDecorator as i,\n runtime as r\n};\n//# sourceMappingURL=runtime-BPCpkOf1.js.map\n","import {\n createRequestSubscription,\n type RequestLoadingState,\n type RequestState,\n type RequestSubscription,\n} from \"@warp-drive-mirror/core/reactive\";\nimport {\n AutorefreshBehaviorCombos,\n DISPOSE,\n RequestArgs,\n signal,\n type ContentFeatures,\n type RecoveryFeatures,\n type SubscriptionArgs,\n} from \"@warp-drive-mirror/core/signals/-leaked\";\nimport type { StructuredErrorDocument } from \"@warp-drive-mirror/core/types/request\";\nimport { JSX, ReactNode, useEffect, useMemo, useRef } from \"react\";\nimport { useStore } from \"./store-provider\";\nimport { ReactiveContext } from \"./reactive-context\";\nimport { Future } from \"@warp-drive-mirror/core/request\";\nimport { StoreRequestInput } from \"@warp-drive-mirror/core\";\nimport { DEBUG } from \"@warp-drive-mirror/core/build-config/env\";\n\nconst IdleBlockMissingError = new Error(\n \"No idle block provided for <Request> component, and no query or request was provided.\"\n);\n\nclass ReactiveArgs<RT, E> implements SubscriptionArgs<RT, E> {\n @signal request?: Future<RT> | undefined | null;\n @signal query?: StoreRequestInput<RT> | undefined | null;\n @signal autorefresh?: AutorefreshBehaviorCombos | undefined;\n @signal autorefreshThreshold?: number | undefined;\n @signal autorefreshBehavior?: \"refresh\" | \"reload\" | \"policy\";\n}\n\ninterface ChromeComponentProps<RT> {\n children: ReactNode;\n state: RequestState | null;\n features: ContentFeatures<RT>;\n}\n\nconst DefaultChrome = <RT,>({ children }: ChromeComponentProps<RT>) => {\n return <>{children}</>;\n};\n\nexport interface RequestProps<RT, E> extends RequestArgs<RT, E> {\n chrome?: React.FC<ChromeComponentProps<RT>>;\n\n states: RequestStates<RT, E>;\n}\n\ninterface RequestStates<RT, E> {\n /**\n * The block to render when the component is idle and waiting to be given a request.\n *\n */\n idle?: React.FC<{}>;\n\n /**\n * The block to render when the request is loading.\n *\n */\n loading?: React.FC<{ state: RequestLoadingState }>;\n\n /**\n * The block to render when the request was cancelled.\n *\n */\n cancelled?: React.FC<{\n /**\n * The Error the request rejected with.\n */\n error: StructuredErrorDocument<E>;\n /**\n * Utilities to assist in recovering from the error.\n */\n features: RecoveryFeatures;\n }>;\n\n /**\n * The block to render when the request failed. If this block is not provided,\n * the error will be rethrown.\n *\n * Thus it is required to provide an error block and proper error handling if\n * you do not want the error to crash the application.\n */\n error: React.FC<{\n /**\n * The Error the request rejected with.\n */\n error: StructuredErrorDocument<E>;\n /**\n * Utilities to assist in recovering from the error.\n */\n features: RecoveryFeatures;\n }>;\n\n /**\n * The block to render when the request succeeded.\n *\n */\n content: React.FC<{ result: RT; features: ContentFeatures<RT> }>;\n}\n\n/**\n * Throws the given error. Used internally to rethrow request errors that\n * are not otherwise handled by a provided error/cancelled block.\n *\n * @private\n */\nexport function Throw({ error }: { error: Error }): never {\n throw error;\n}\n\n/**\n * The `<Request />` component is a powerful tool for managing data fetching and\n * state in your React application. It provides a declarative approach to reactive\n * control-flow for managing requests and state in your application.\n *\n * The `<Request />` component is ideal for handling \"boundaries\", outside which some\n * state is still allowed to be unresolved and within which it MUST be resolved.\n *\n * ## Request States\n *\n * `<Request />` has five states, only one of which will be active and rendered at a time.\n *\n * - `idle`: The component is waiting to be given a request to monitor\n * - `loading`: The request is in progress\n * - `error`: The request failed\n * - `content`: The request succeeded\n * - `cancelled`: The request was cancelled\n *\n * Additionally, the `content` state has a `refresh` method that can be used to\n * refresh the request in the background, which is available as a sub-state of\n * the `content` state.\n *\n * ### Example Usage\n *\n * ```tsx\n * import { Request } from \"@warp-drive-mirror/react\";\n *\n * export function UserPreview($props: { id: string | null }) {\n * return (\n * <Request\n * query={findRecord('user', $props.id)}\n * states={{\n * idle: () => <div>Waiting for User Selection</div>,\n * loading: ({ state }) => <div>Loading user data...</div>,\n * cancelled: ({ error, features }) => (\n * <div>\n * <p>Request Cancelled</p>\n * <p><button onClick={features.retry}>Start Again?</button></p>\n * </div>\n * ),\n * error: ({ error, features }) => (\n * <div>\n * <p>Error: {error.message}</p>\n * <p><button onClick={features.retry}>Try Again?</button></p>\n * </div>\n * ),\n * content: ({ result, features }) => (\n * <div>\n * <h2>User Details</h2>\n * <p>ID: {result.id}</p>\n * <p>Name: {result.name}</p>\n * </div>\n * ),\n * }}\n * />\n * );\n * }\n *\n * ```\n *\n * @category Components\n */\nexport function Request<RT, E>($props: RequestProps<RT, E>): JSX.Element {\n return (\n <ReactiveContext>\n <InternalRequest {...$props} />\n </ReactiveContext>\n );\n}\n\nfunction isStrictModeRender(): boolean {\n const count = useRef<number>(0);\n\n // in debug we need to skip every second invocation\n if (DEBUG) {\n if (count.current++ % 2 === 1) {\n return true;\n }\n }\n\n return false;\n}\n\nfunction InternalRequest<RT, E>($props: RequestProps<RT, E>): JSX.Element {\n const isStrict = isStrictModeRender();\n const store = $props.store ?? useStore();\n const Chrome = $props.chrome ?? DefaultChrome;\n const sink = useRef<RequestSubscription<RT, E> | null>(null);\n const args = useRef<SubscriptionArgs<RT, E> | null>(null);\n\n if (!args.current) {\n args.current = new ReactiveArgs<RT, E>();\n }\n Object.assign(args.current, $props);\n\n if (sink.current && (sink.current.store !== store || $props.subscription)) {\n sink.current[DISPOSE]();\n sink.current = null;\n }\n\n if (!sink.current && !$props.subscription) {\n sink.current = createRequestSubscription(store, args.current!);\n }\n\n const initialized = useRef<null | {\n disposable: { [DISPOSE]: () => void } | null;\n dispose: () => void;\n }>(null);\n const effect = () => {\n if (sink.current && (!initialized.current || initialized.current.disposable !== sink.current)) {\n initialized.current = {\n disposable: sink.current,\n dispose: () => {\n sink.current?.[DISPOSE]();\n initialized.current = null;\n sink.current = null;\n },\n };\n }\n\n return sink.current ? initialized.current!.dispose : undefined;\n };\n let maybeEffect = effect;\n\n if (DEBUG) {\n if (isStrict) {\n maybeEffect = () => {\n if (initialized.current) {\n return effect();\n }\n return () => {\n // initialize our actual effect\n effect();\n // in strict mode we don't want to run the teardown\n // for the second invocation\n };\n };\n }\n }\n\n useEffect(maybeEffect, [sink.current]);\n\n const state = $props.subscription ?? sink.current!;\n const slots = $props.states;\n\n return (\n <Chrome state={state.isIdle ? null : state.reqState} features={state.contentFeatures}>\n {\n // prettier-ignore\n state.isIdle && slots.idle ? <slots.idle />\n : state.isIdle ? <Throw error={IdleBlockMissingError} />\n : state.reqState.isLoading ? slots.loading ? <slots.loading state={state.reqState.loadingState} /> : ''\n : state.reqState.isCancelled && slots.cancelled ? <slots.cancelled error={state.reqState.reason} features={state.errorFeatures} />\n : state.reqState.isError && slots.error ? <slots.error error={state.reqState.reason} features={state.errorFeatures} />\n : state.reqState.isSuccess ? slots.content ? <slots.content result={state.reqState.value} features={state.contentFeatures} /> : <Throw error={new Error('No content block provided for <Request> component.')} />\n : !state.reqState.isCancelled ? <Throw error={state.reqState.reason} />\n : '' // never\n }\n </Chrome>\n );\n}\n"],"x_google_ignoreList":[1],"mappings":";;;;;;;;;;;AAOA,MAAMQ,eAAeP,4BAA4B,IAAI;;;;AAKrD,SAAgBQ,WAAkB;CAChC,MAAMC,QAAQN,IAAII,YAAY;CAC9B,EAAAG,SAAA;EAAA,IAAA,CAAAA,MAAA,MAAA,IAAAC,MACE,yGAAyG;CAAA,EAAA,CACzGF,KAAK;CAEP,OAAOA;AACT;;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OAAA;GAAA5B,UAAAC;GAAAC,YAAA;GAAAC,cAAA;EAAA,GAAA,IAAE,IAAIrB,qBAACa,OAAK,EAACC,uBAAO,IAAIZ,MAAM,oDAAoD,EAAE,GAAA,KAAA,GAAA,OAAA;GAAAgB,UAAAC;GAAAC,YAAA;GAAAC,cAAA;EAAA,GAAA,IAAE,IAC9M,CAACmB,MAAMI,SAASO,cAAcnD,qBAACa,OAAK,EAACC,OAAO0B,MAAMI,SAASS,OAAO,GAAA,KAAA,GAAA,OAAA;GAAAnC,UAAAC;GAAAC,YAAA;GAAAC,cAAA;EAAA,GAAA,IAAE,IACpE;CAAG,GAAA,KAAA,GAAA,OAAA;EAAAH,UAAAC;EAAAC,YAAA;EAAAC,cAAA;CAAA,GAAA,IAEH;AAEZ"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["createContext","use","useMemo","jsxDEV","_jsxDEV","StoreContext","useStore","store","test","Error","StoreProvider","$props","Store","value","children","fileName","_jsxFileName","lineNumber","columnNumber","useEffect","useRef","createRequestSubscription","DISPOSE","signal","ReactiveContext","useStore","g","i","Fragment","_Fragment","jsxDEV","_jsxDEV","IdleBlockMissingError","Error","ReactiveArgs","prototype","request","query","autorefresh","autorefreshThreshold","autorefreshBehavior","DefaultChrome","children","Throw","error","Request","$props","InternalRequest","fileName","_jsxFileName","lineNumber","columnNumber","isStrictModeRender","count","current","isStrict","store","Chrome","chrome","sink","args","Object","assign","subscription","initialized","effect","disposable","dispose","undefined","maybeEffect","state","slots","states","isIdle","reqState","features","contentFeatures","idle","isLoading","loading","loadingState","isCancelled","cancelled","reason","errorFeatures","isError","isSuccess","content","result","value"],"sources":["../../../src/-private/store-provider.tsx","../../../../../node_modules/.pnpm/decorat_5d4eca388601a94e7fbc656401b751d1/node_modules/decorator-transforms/dist/runtime--fcdnjmJ.js","../../../src/-private/request.tsx"],"sourcesContent":["import type { JSX, ReactNode } from \"react\";\nimport { createContext, use, useMemo } from \"react\";\n\nimport type { Store } from \"@warp-drive-mirror/core\";\nimport { assert } from \"@warp-drive-mirror/core/build-config/macros\";\n\n/**\n * @category Contexts\n */\nconst StoreContext = createContext<Store | null>(null);\n\n/**\n * @category Hooks\n */\nexport function useStore(): Store {\n const store = use(StoreContext);\n assert(\n \"No Store provided via context. Please ensure you are using <StoreProvider> to provide a Store instance.\",\n store\n );\n return store;\n}\n\ntype WithExistingStore = { store: Store; children: ReactNode };\ntype WithNewStore = { Store: typeof Store; children: ReactNode };\n\n/**\n * @category Components\n */\nexport function StoreProvider($props: WithExistingStore | WithNewStore): JSX.Element {\n const store = useMemo(\n () => (\"store\" in $props ? $props.store : new $props.Store()),\n [\"store\" in $props ? $props.store : $props.Store]\n );\n\n return <StoreContext value={store}>{$props.children}</StoreContext>;\n}\n","const deferred = /* @__PURE__ */ new WeakMap();\nfunction deferDecorator(proto, prop, desc) {\n let map = deferred.get(proto);\n if (!map) {\n map = /* @__PURE__ */ new Map();\n deferred.set(proto, map);\n }\n map.set(prop, desc);\n}\nfunction findDeferredDecorator(target, prop) {\n var _a;\n let cursor = target.prototype;\n while (cursor) {\n let desc = (_a = deferred.get(cursor)) == null ? void 0 : _a.get(prop);\n if (desc) {\n return desc;\n }\n cursor = Object.getPrototypeOf(cursor);\n }\n}\nfunction decorateFieldV1(target, prop, decorators, initializer) {\n return decorateFieldV2(target.prototype, prop, decorators, initializer);\n}\nfunction decorateFieldV2(prototype, prop, decorators, initializer) {\n let desc = {\n configurable: true,\n enumerable: true,\n writable: true,\n initializer: null\n };\n if (initializer) {\n desc.initializer = initializer;\n }\n for (let decorator of decorators) {\n desc = decorator(prototype, prop, desc) || desc;\n }\n if (desc.initializer === void 0) {\n Object.defineProperty(prototype, prop, desc);\n } else {\n deferDecorator(prototype, prop, desc);\n }\n}\nfunction decorateMethodV1({ prototype }, prop, decorators) {\n return decorateMethodV2(prototype, prop, decorators);\n}\nfunction decorateMethodV2(prototype, prop, decorators) {\n const origDesc = Object.getOwnPropertyDescriptor(prototype, prop);\n let desc = { ...origDesc };\n for (let decorator of decorators) {\n desc = decorator(prototype, prop, desc) || desc;\n }\n if (desc.initializer !== void 0) {\n desc.value = desc.initializer ? desc.initializer.call(prototype) : void 0;\n desc.initializer = void 0;\n }\n Object.defineProperty(prototype, prop, desc);\n}\nfunction initializeDeferredDecorator(target, prop) {\n let desc = findDeferredDecorator(target.constructor, prop);\n if (desc) {\n Object.defineProperty(target, prop, {\n enumerable: desc.enumerable,\n configurable: desc.configurable,\n writable: desc.writable,\n value: desc.initializer ? desc.initializer.call(target) : void 0\n });\n }\n}\nfunction decorateClass(target, decorators) {\n return decorators.reduce(\n (accum, decorator) => decorator(accum) || accum,\n target\n );\n}\nfunction decoratePOJO(pojo, decorated) {\n for (let [type, prop, decorators] of decorated) {\n if (type === \"field\") {\n decoratePojoField(pojo, prop, decorators);\n } else {\n decorateMethodV2(pojo, prop, decorators);\n }\n }\n return pojo;\n}\nfunction decoratePojoField(pojo, prop, decorators) {\n let desc = {\n configurable: true,\n enumerable: true,\n writable: true,\n initializer: () => {\n var _a;\n return (_a = Object.getOwnPropertyDescriptor(pojo, prop)) == null ? void 0 : _a.value;\n }\n };\n for (let decorator of decorators) {\n desc = decorator(pojo, prop, desc) || desc;\n }\n if (desc.initializer) {\n desc.value = desc.initializer.call(pojo);\n delete desc.initializer;\n }\n Object.defineProperty(pojo, prop, desc);\n}\nconst runtime = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({\n __proto__: null,\n c: decorateClass,\n f: decorateFieldV1,\n g: decorateFieldV2,\n i: initializeDeferredDecorator,\n m: decorateMethodV1,\n n: decorateMethodV2,\n p: decoratePOJO\n}, Symbol.toStringTag, { value: \"Module\" }));\nexport {\n decorateFieldV1 as a,\n decorateFieldV2 as b,\n decorateMethodV1 as c,\n decorateClass as d,\n decorateMethodV2 as e,\n decoratePOJO as f,\n initializeDeferredDecorator as i,\n runtime as r\n};\n//# sourceMappingURL=runtime--fcdnjmJ.js.map\n","import type { JSX, ReactNode } from \"react\";\nimport { useEffect, useRef } from \"react\";\n\nimport type { StoreRequestInput } from \"@warp-drive-mirror/core\";\nimport { DEBUG } from \"@warp-drive-mirror/core/build-config/env\";\nimport {\n createRequestSubscription,\n type RequestLoadingState,\n type RequestState,\n type RequestSubscription,\n} from \"@warp-drive-mirror/core/reactive\";\nimport type { Future } from \"@warp-drive-mirror/core/request\";\nimport {\n type AutorefreshBehaviorCombos,\n DISPOSE,\n type RequestArgs,\n signal,\n type ContentFeatures,\n type RecoveryFeatures,\n type SubscriptionArgs,\n} from \"@warp-drive-mirror/core/signals/-leaked\";\nimport type { StructuredErrorDocument } from \"@warp-drive-mirror/core/types/request\";\n\nimport { ReactiveContext } from \"./reactive-context\";\nimport { useStore } from \"./store-provider\";\n\nconst IdleBlockMissingError = new Error(\n \"No idle block provided for <Request> component, and no query or request was provided.\"\n);\n\nclass ReactiveArgs<RT, E> implements SubscriptionArgs<RT, E> {\n @signal request?: Future<RT> | undefined | null;\n @signal query?: StoreRequestInput<RT> | undefined | null;\n @signal autorefresh?: AutorefreshBehaviorCombos | undefined;\n @signal autorefreshThreshold?: number | undefined;\n @signal autorefreshBehavior?: \"refresh\" | \"reload\" | \"policy\";\n}\n\ninterface ChromeComponentProps<RT> {\n children: ReactNode;\n state: RequestState | null;\n features: ContentFeatures<RT>;\n}\n\nconst DefaultChrome = <RT,>({ children }: ChromeComponentProps<RT>) => {\n return <>{children}</>;\n};\n\nexport interface RequestProps<RT, E> extends RequestArgs<RT, E> {\n chrome?: React.FC<ChromeComponentProps<RT>>;\n\n states: RequestStates<RT, E>;\n}\n\ninterface RequestStates<RT, E> {\n /**\n * The block to render when the component is idle and waiting to be given a request.\n *\n */\n idle?: React.FC<object>;\n\n /**\n * The block to render when the request is loading.\n *\n */\n loading?: React.FC<{ state: RequestLoadingState }>;\n\n /**\n * The block to render when the request was cancelled.\n *\n */\n cancelled?: React.FC<{\n /**\n * The Error the request rejected with.\n */\n error: StructuredErrorDocument<E>;\n /**\n * Utilities to assist in recovering from the error.\n */\n features: RecoveryFeatures;\n }>;\n\n /**\n * The block to render when the request failed. If this block is not provided,\n * the error will be rethrown.\n *\n * Thus it is required to provide an error block and proper error handling if\n * you do not want the error to crash the application.\n */\n error: React.FC<{\n /**\n * The Error the request rejected with.\n */\n error: StructuredErrorDocument<E>;\n /**\n * Utilities to assist in recovering from the error.\n */\n features: RecoveryFeatures;\n }>;\n\n /**\n * The block to render when the request succeeded.\n *\n */\n content: React.FC<{ result: RT; features: ContentFeatures<RT> }>;\n}\n\n/**\n * Throws the given error. Used internally to rethrow request errors that\n * are not otherwise handled by a provided error/cancelled block.\n *\n * @private\n */\nexport function Throw({ error }: { error: Error }): never {\n throw error;\n}\n\n/**\n * The `<Request />` component is a powerful tool for managing data fetching and\n * state in your React application. It provides a declarative approach to reactive\n * control-flow for managing requests and state in your application.\n *\n * The `<Request />` component is ideal for handling \"boundaries\", outside which some\n * state is still allowed to be unresolved and within which it MUST be resolved.\n *\n * ## Request States\n *\n * `<Request />` has five states, only one of which will be active and rendered at a time.\n *\n * - `idle`: The component is waiting to be given a request to monitor\n * - `loading`: The request is in progress\n * - `error`: The request failed\n * - `content`: The request succeeded\n * - `cancelled`: The request was cancelled\n *\n * Additionally, the `content` state has a `refresh` method that can be used to\n * refresh the request in the background, which is available as a sub-state of\n * the `content` state.\n *\n * ### Example Usage\n *\n * ```tsx\n * import { Request } from \"@warp-drive-mirror/react\";\n *\n * export function UserPreview($props: { id: string | null }) {\n * return (\n * <Request\n * query={findRecord('user', $props.id)}\n * states={{\n * idle: () => <div>Waiting for User Selection</div>,\n * loading: ({ state }) => <div>Loading user data...</div>,\n * cancelled: ({ error, features }) => (\n * <div>\n * <p>Request Cancelled</p>\n * <p><button onClick={features.retry}>Start Again?</button></p>\n * </div>\n * ),\n * error: ({ error, features }) => (\n * <div>\n * <p>Error: {error.message}</p>\n * <p><button onClick={features.retry}>Try Again?</button></p>\n * </div>\n * ),\n * content: ({ result, features }) => (\n * <div>\n * <h2>User Details</h2>\n * <p>ID: {result.id}</p>\n * <p>Name: {result.name}</p>\n * </div>\n * ),\n * }}\n * />\n * );\n * }\n *\n * ```\n *\n * @category Components\n */\nexport function Request<RT, E>($props: RequestProps<RT, E>): JSX.Element {\n return (\n <ReactiveContext>\n <InternalRequest {...$props} />\n </ReactiveContext>\n );\n}\n\nfunction isStrictModeRender(): boolean {\n const count = useRef<number>(0);\n\n // in debug we need to skip every second invocation\n if (DEBUG) {\n if (count.current++ % 2 === 1) {\n return true;\n }\n }\n\n return false;\n}\n\nfunction InternalRequest<RT, E>($props: RequestProps<RT, E>): JSX.Element {\n const isStrict = isStrictModeRender();\n const store = $props.store ?? useStore();\n const Chrome = $props.chrome ?? DefaultChrome;\n const sink = useRef<RequestSubscription<RT, E> | null>(null);\n const args = useRef<SubscriptionArgs<RT, E> | null>(null);\n\n if (!args.current) {\n args.current = new ReactiveArgs<RT, E>();\n }\n Object.assign(args.current, $props);\n\n if (sink.current && (sink.current.store !== store || $props.subscription)) {\n sink.current[DISPOSE]();\n sink.current = null;\n }\n\n if (!sink.current && !$props.subscription) {\n sink.current = createRequestSubscription(store, args.current);\n }\n\n const initialized = useRef<null | {\n disposable: { [DISPOSE]: () => void } | null;\n dispose: () => void;\n }>(null);\n const effect = () => {\n if (sink.current && (!initialized.current || initialized.current.disposable !== sink.current)) {\n initialized.current = {\n disposable: sink.current,\n dispose: () => {\n sink.current?.[DISPOSE]();\n initialized.current = null;\n sink.current = null;\n },\n };\n }\n\n return sink.current ? initialized.current!.dispose : undefined;\n };\n let maybeEffect = effect;\n\n if (DEBUG) {\n if (isStrict) {\n maybeEffect = () => {\n if (initialized.current) {\n return effect();\n }\n return () => {\n // initialize our actual effect\n effect();\n // in strict mode we don't want to run the teardown\n // for the second invocation\n };\n };\n }\n }\n\n useEffect(maybeEffect, [sink.current]);\n\n const state = $props.subscription ?? sink.current!;\n const slots = $props.states;\n\n return (\n <Chrome state={state.isIdle ? null : state.reqState} features={state.contentFeatures}>\n {\n // prettier-ignore\n state.isIdle && slots.idle ? <slots.idle />\n : state.isIdle ? <Throw error={IdleBlockMissingError} />\n : state.reqState.isLoading ? slots.loading ? <slots.loading state={state.reqState.loadingState} /> : ''\n : state.reqState.isCancelled && slots.cancelled ? <slots.cancelled error={state.reqState.reason} features={state.errorFeatures} />\n : state.reqState.isError && slots.error ? <slots.error error={state.reqState.reason} features={state.errorFeatures} />\n : state.reqState.isSuccess ? slots.content ? <slots.content result={state.reqState.value} features={state.contentFeatures} /> : <Throw error={new Error('No content block provided for <Request> component.')} />\n : !state.reqState.isCancelled ? <Throw error={state.reqState.reason} />\n : '' // never\n }\n </Chrome>\n );\n}\n"],"x_google_ignoreList":[1],"mappings":";;;;;;;;;;;AASA,MAAMK,eAAeL,4BAA4B,IAAI;;;;AAKrD,SAAgBM,WAAkB;CAChC,MAAMC,QAAQN,IAAII,YAAY;CAC9B,EAAAG,SAAA;EAAA,IAAA,CAAAA,MAAA,MAAA,IAAAC,MACE,yGAAyG;CAAA,EAAA,CACzGF,KAAK;CAEP,OAAOA;AACT;;;;AAQA,SAAgBG,cAAcC,QAAuD;CACnF,MAAMJ,QAAQL,cACL,WAAWS,SAASA,OAAOJ,QAAQ,IAAII,OAAOC,MAAM,GAC3D,CAAC,WAAWD,SAASA,OAAOJ,QAAQI,OAAOC,KAAK,CAClD;CAEA,OAAOR,qBAACC,cAAY;EAACQ,OAAON;EAAMO,UAAEH,OAAOG;CAAQ,GAAA,KAAA,GAAA,OAAA;EAAAC,UAAAC;EAAAC,YAAA;EAAAC,cAAA;CAAA,GAAA,IAAe;AACpE;;;;ACpCA,MAAM,2BAA2B,IAAI,QAAQ;AAC7C,SAAS,eAAe,OAAO,MAAM,MAAM;CACzC,IAAI,MAAM,SAAS,IAAI,KAAK;CAC5B,IAAI,CAAC,KAAK;EACR,sBAAsB,IAAI,IAAI;EAC9B,SAAS,IAAI,OAAO,GAAG;CACzB;CACA,IAAI,IAAI,MAAM,IAAI;AACpB;AACA,SAAS,sBAAsB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"signal-polyfill";
|
|
1
|
+
import { n as WatcherContext, r as getGlobalConfig } from "./reactive-context-Ax2U-96G.js";
|
|
3
2
|
import { use } from "react";
|
|
3
|
+
import { Signal } from "signal-polyfill";
|
|
4
4
|
import { setupSignals } from "@warp-drive-mirror/core/configure";
|
|
5
5
|
|
|
6
6
|
//#region src/install.ts
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"install.js","names":["use","Signal","setupSignals","WatcherContext","getGlobalConfig","getGlobalConfig0","tryConsumeContext","signal","logError","console","error","watcher","watch","WarpDrive","debug","LOG_REACT_SIGNAL_INTEGRATION","globalThis","getWarpDriveRuntimeConfig","log","pending","settled","length","current","Promise","allSettled","resolve","buildSignalConfig","options","createSignal","obj","key","State","equals","notifySignal","subtle","hasSinks","set","get","consumeSignal","createMemo","object","fn","memo","Computed","waitFor","promise","newPromise","finally","filter","p","push","willSyncFlushWatchers"],"sources":["../../../src/install.ts"],"sourcesContent":["/**\n * {@include ./install.md}\n * @module\n */\n\nimport { use } from 'react';\nimport { Signal } from 'signal-polyfill';\n\nimport { LOG_REACT_SIGNAL_INTEGRATION } from '@warp-drive-mirror/core/build-config/debugging';\nimport { DEBUG, TESTING } from '@warp-drive-mirror/core/build-config/env';\nimport { type HooksOptions, setupSignals, type SignalHooks } from '@warp-drive-mirror/core/configure';\n\nimport { WatcherContext } from './-private/reactive-context';\n\nfunction tryConsumeContext(signal: Signal.State<unknown> | Signal.Computed<unknown>): void {\n //
|
|
1
|
+
{"version":3,"file":"install.js","names":["use","Signal","setupSignals","WatcherContext","getGlobalConfig","getGlobalConfig0","tryConsumeContext","signal","logError","console","error","watcher","watch","WarpDrive","debug","LOG_REACT_SIGNAL_INTEGRATION","globalThis","getWarpDriveRuntimeConfig","log","pending","settled","length","current","Promise","allSettled","resolve","buildSignalConfig","options","createSignal","obj","key","State","equals","notifySignal","subtle","hasSinks","set","get","consumeSignal","createMemo","object","fn","memo","Computed","waitFor","promise","newPromise","finally","filter","p","push","willSyncFlushWatchers"],"sources":["../../../src/install.ts"],"sourcesContent":["/**\n * {@include ./install.md}\n * @module\n */\n\nimport { use } from 'react';\nimport { Signal } from 'signal-polyfill';\n\nimport { LOG_REACT_SIGNAL_INTEGRATION } from '@warp-drive-mirror/core/build-config/debugging';\nimport { DEBUG, TESTING } from '@warp-drive-mirror/core/build-config/env';\nimport { type HooksOptions, setupSignals, type SignalHooks } from '@warp-drive-mirror/core/configure';\n\nimport { WatcherContext } from './-private/reactive-context';\n\nfunction tryConsumeContext(signal: Signal.State<unknown> | Signal.Computed<unknown>): void {\n // oxlint-disable-next-line no-console\n const logError = console.error;\n try {\n // oxlint-disable-next-line no-console\n console.error = () => {};\n // ensure signals are watched by our closest watcher\n const watcher = use(WatcherContext);\n // oxlint-disable-next-line no-console\n console.error = logError;\n watcher?.watcher.watch(signal);\n if (LOG_REACT_SIGNAL_INTEGRATION) {\n // oxlint-disable-next-line no-console\n console.log(`[WarpDrive] Consumed Context Signal`, signal, watcher);\n }\n } catch {\n // oxlint-disable-next-line no-console\n console.error = logError;\n // if we are not in a React context, we will Error\n // so we just ignore it.\n if (LOG_REACT_SIGNAL_INTEGRATION) {\n // oxlint-disable-next-line no-console\n console.log(`[WarpDrive] No Context Available To Consume Signal`, signal);\n }\n }\n}\n\nlet pending: Promise<unknown>[];\n/**\n * Resolves once all pending requests started via WarpDrive's React signal\n * integration have settled. Only tracks requests while `TESTING` is enabled;\n * a no-op otherwise.\n *\n * @public\n */\nexport async function settled(): Promise<void> {\n if (TESTING) {\n // in testing mode we provide a test waiter integration\n if (!pending || !pending.length) return;\n const current = pending ?? [];\n pending = [];\n await Promise.allSettled(current);\n await Promise.resolve();\n await Promise.resolve();\n await Promise.resolve();\n\n return settled();\n }\n}\n\n/**\n * Builds the {@link SignalHooks} implementation backed by the\n * [Signal Polyfill](https://github.com/proposal-signals/signal-polyfill),\n * used to wire WarpDrive's reactivity primitives into React.\n *\n * @public\n */\nexport function buildSignalConfig(options: HooksOptions): SignalHooks {\n return {\n createSignal: (obj: object, key: string | symbol) =>\n new Signal.State(DEBUG ? { obj, key } : null, { equals: () => false }),\n\n notifySignal: (signal: Signal.State<unknown>) => {\n if (LOG_REACT_SIGNAL_INTEGRATION) {\n if (Signal.subtle.hasSinks(signal)) {\n // oxlint-disable-next-line no-console\n console.log(`[WarpDrive] Notifying Signal`, signal);\n } else {\n // oxlint-disable-next-line no-console\n console.log(`[WarpDrive] Notified Signal That Has No Watcher`, signal);\n }\n }\n signal.set(signal.get());\n },\n\n consumeSignal: (signal: Signal.State<unknown>) => {\n tryConsumeContext(signal);\n void signal.get();\n },\n\n createMemo: <F>(object: object, key: string | symbol, fn: () => F): (() => F) => {\n const memo = new Signal.Computed<F>(fn);\n return () => {\n tryConsumeContext(memo);\n\n return memo.get();\n };\n },\n\n waitFor: (promise) => {\n if (TESTING) {\n pending = pending || [];\n const newPromise = promise.finally(() => {\n pending = pending.filter((p) => p !== newPromise);\n });\n pending.push(newPromise);\n return newPromise;\n }\n return promise;\n },\n\n willSyncFlushWatchers: () => false,\n } as SignalHooks;\n}\n\nsetupSignals(buildSignalConfig);\n"],"mappings":";;;;;;;;;;AAcA,SAASM,kBAAkBC,QAAgE;CAEzF,MAAMC,WAAWC,QAAQC;CACzB,IAAI;EAEFD,QAAQC,cAAc,CAAC;EAEvB,MAAMC,UAAUX,IAAIG,cAAc;EAElCM,QAAQC,QAAQF;EAChBG,SAASA,QAAQC,MAAML,MAAM;EAAE,IAAAF,gBAAA,CAAA,CAAAQ,UAAAC,MAAAC,gCAAAC,WAAAC,0BAAA,CAAA,CAAAH,MAAAC,8BAG7BN,QAAQS,IAAI,uCAAuCX,QAAQI,OAAO;CAEtE,QAAQ;EAENF,QAAQC,QAAQF;EAEhB,IAAAH,gBAAA,CAAA,CAAAQ,UAAAC,MAAAC,gCAAAC,WAAAC,0BAAA,CAAA,CAAAH,MAAAC,8BAGEN,QAAQS,IAAI,sDAAsDX,MAAM;CAE5E;AACF;AAEA,IAAIY;;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iB"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Signal } from "signal-polyfill";
|
|
2
1
|
import { createContext, useMemo, useSyncExternalStore } from "react";
|
|
2
|
+
import { Signal } from "signal-polyfill";
|
|
3
3
|
import { jsxDEV } from "react/jsx-dev-runtime";
|
|
4
4
|
|
|
5
|
-
//#region ../../node_modules/.pnpm/@
|
|
5
|
+
//#region ../../node_modules/.pnpm/@embroider+macros@1.20.6/node_modules/@embroider/macros/src/addon/runtime.js
|
|
6
6
|
function config(packageRoot) {
|
|
7
7
|
return runtimeConfig.packages[packageRoot];
|
|
8
8
|
}
|
|
@@ -208,11 +208,11 @@ function ReactiveContext({ children }) {
|
|
|
208
208
|
children
|
|
209
209
|
}, void 0, false, {
|
|
210
210
|
fileName: _jsxFileName,
|
|
211
|
-
lineNumber:
|
|
211
|
+
lineNumber: 174,
|
|
212
212
|
columnNumber: 10
|
|
213
213
|
}, this);
|
|
214
214
|
}
|
|
215
215
|
|
|
216
216
|
//#endregion
|
|
217
217
|
export { WatcherContext as n, getGlobalConfig as r, ReactiveContext as t };
|
|
218
|
-
//# sourceMappingURL=reactive-context-
|
|
218
|
+
//# sourceMappingURL=reactive-context-Ax2U-96G.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reactive-context-Ax2U-96G.js","names":["each","array","Array","isArray","Error","macroCondition","predicate","config","packageRoot","runtimeConfig","packages","getGlobalConfig","global","isTesting","g","e","Boolean","setTesting","globalThis","__embroider_macros__runtime_config__","localConfig","initializeRuntimeMacrosConfig","Object","assign","updaterMethods","setConfig","value","setGlobalConfig","key","updaters","window","_embroider_macros_runtime_config","undefined","methods","updater","createContext","useSyncExternalStore","useMemo","Signal","getGlobalConfig","getGlobalConfig0","jsxDEV","_jsxDEV","nextFlush","watchers","watcherId","clearWatcher","state","watcher","unwatch","subtle","introspectSources","flush","pending","destroyed","WarpDrive","debug","LOG_REACT_SIGNAL_INTEGRATION","globalThis","getWarpDriveRuntimeConfig","console","log","snapshot","Set","getPending","notifyReact","watch","_createWatcher","id","Watcher","args","push","Promise","resolve","queueMicrotask","forEach","map","w","useWatcher","notifyChanged","WatcherContext","ReactiveContext","children","value","fileName","_jsxFileName","lineNumber","columnNumber"],"sources":["../../../../../node_modules/.pnpm/@embroider+macros@1.20.6/node_modules/@embroider/macros/src/addon/runtime.js","../../../src/-private/reactive-context.tsx"],"sourcesContent":["/*\n These are the runtime implementations for the javascript macros that have\n runtime implementations.\n\n Not every macro has a runtime implementation, some only make sense in the\n build and always run there.\n\n Even when we have runtime implementations, we are still careful to emit static\n errors during the build wherever possible, and runtime errors when necessary,\n so that you're not surprised when you switch from runtime-mode to compile-time\n mode.\n*/\n\n/*\n CAUTION: in classic builds, this file gets shared by all present copies of\n @embroider/macros. If you want to change its public API, you need to rename it\n and update `pathToRuntime` in ../babel/state.ts to point at it, so that your\n babel plugin and runtime will match.\n*/\n\nexport function each(array) {\n if (!Array.isArray(array)) {\n throw new Error(`the argument to the each() macro must be an array`);\n }\n return array;\n}\n\nexport function macroCondition(predicate) {\n return predicate;\n}\n\n// This is here as a compile target for `getConfig` and `getOwnConfig` when\n// we're in runtime mode. This is not public API to call from your own code.\nexport function config(packageRoot) {\n return runtimeConfig.packages[packageRoot];\n}\n\nexport function getGlobalConfig() {\n return runtimeConfig.global;\n}\n\nexport function isTesting() {\n let g = runtimeConfig.global;\n let e = g && g['@embroider/macros'];\n return Boolean(e && e.isTesting);\n}\n\nexport function setTesting(isTesting) {\n if (!runtimeConfig.global) {\n runtimeConfig.global = {};\n }\n if (!runtimeConfig.global['@embroider/macros']) {\n runtimeConfig.global['@embroider/macros'] = {};\n }\n runtimeConfig.global['@embroider/macros'].isTesting = Boolean(isTesting);\n}\n\n// Welcome intrepid developer!\n//\n// While this data is \"global\", this is a private variable.\n//\n// do not build features based off of its contents,\n// or assume it will have the same name in future releases.\nconst runtimeConfig = globalThis.__embroider_macros__runtime_config__ ||= {};\n\nruntimeConfig.packages ||= {};\nruntimeConfig.global ||= {};\n\n// In the off chance there are duplicate copies of @embroider/macros in the dep graph\n// (due to the package manager messing up)\n// Let's try to merge them together via the above global well known variable\nconst localConfig = initializeRuntimeMacrosConfig();\n\nObject.assign(runtimeConfig.packages, localConfig.packages);\nObject.assign(runtimeConfig.global, localConfig.global);\n\n// this exists to be targeted by our babel plugin\nfunction initializeRuntimeMacrosConfig() {\n return { packages: {}, global: {} };\n}\n\nfunction updaterMethods() {\n return {\n config,\n getGlobalConfig,\n setConfig(packageRoot, value) {\n runtimeConfig.packages[packageRoot] = value;\n },\n setGlobalConfig(key, value) {\n runtimeConfig.global[key] = value;\n },\n };\n}\n\n// this is how runtime config can get injected at boot. I'm not sure yet if this\n// should be public API, but we certainly need it internally to set things like\n// the global fastboot.isRunning.\n//\n// consumers of this API push a function onto\n// window._embroider_macros_runtime_config. The function is given four methods\n// which allow it to read and write the per-package and global configs. The\n// reason for allowing both read & write is that merging strategies are up to\n// each consumers -- read first, then merge, then write.\n//\n// For an example user of this API, see where we generate\n// embroider_macros_fastboot_init.js' in @embroider/core.\nlet updaters = typeof window !== 'undefined' ? window._embroider_macros_runtime_config : undefined;\nif (updaters) {\n let methods = updaterMethods();\n for (let updater of updaters) {\n updater(methods);\n }\n}\n","import { createContext, type JSX, type ReactNode, useSyncExternalStore, type Context, useMemo } from \"react\";\nimport { Signal } from \"signal-polyfill\";\n\nimport { LOG_REACT_SIGNAL_INTEGRATION } from \"@warp-drive-mirror/core/build-config/debugging\";\n\nlet nextFlush: Promise<void> | null = null;\nlet watchers: WatcherState[] = [];\nlet watcherId = 0;\n\ninterface WatcherState {\n watcherId: number;\n pending: boolean;\n destroyed: boolean;\n notifyReact: (() => void) | null;\n watcher: Signal.subtle.Watcher;\n\n // the extra wrapper returned here ensures that the context value for the watcher\n // changes causing a re-render when the watcher is updated.\n snapshot: { watcher: Signal.subtle.Watcher } | null;\n}\n\nfunction clearWatcher(state: WatcherState) {\n state.watcher.unwatch(...Signal.subtle.introspectSources(state.watcher));\n}\n\nfunction flush(state: WatcherState) {\n state.pending = false;\n if (state.destroyed) {\n if (LOG_REACT_SIGNAL_INTEGRATION) {\n // eslint-disable-next-line no-console\n console.log(`[WarpDrive] Detected Watcher Destroyed During Notify Flush, clearing signals`);\n }\n state.snapshot = null;\n clearWatcher(state);\n return;\n }\n\n if (LOG_REACT_SIGNAL_INTEGRATION) {\n /* eslint-disable no-console */\n console.log(`[WarpDrive] Notifying React That WatcherContext:${state.watcherId} Has Updated`);\n console.log(\"all signals\", new Set(Signal.subtle.introspectSources(state.watcher)));\n console.log(\"dirty signals\", new Set(state.watcher.getPending()));\n /* eslint-enable no-console */\n }\n\n // any time signals have changed, we notify React that our store has updated\n state.snapshot = { watcher: state.watcher };\n if (state.notifyReact) state.notifyReact();\n\n // tell the Watcher to start watching for changes again\n // by signaling that notifications have been flushed.\n state.watcher.watch();\n}\n\nfunction _createWatcher() {\n const id = watcherId++;\n if (LOG_REACT_SIGNAL_INTEGRATION) {\n // eslint-disable-next-line no-console\n console.log(`[WarpDrive] Creating a WatcherContext:${id}`);\n }\n const state: WatcherState = {\n watcherId: id,\n pending: false,\n destroyed: false,\n notifyReact: null as (() => void) | null,\n watcher: null as unknown as Signal.subtle.Watcher,\n\n // the extra wrapper returned here ensures that the context value for the watcher\n // changes causing a re-render when the watcher is updated.\n snapshot: null as { watcher: Signal.subtle.Watcher } | null,\n };\n\n state.watcher = new Signal.subtle.Watcher((...args) => {\n if (LOG_REACT_SIGNAL_INTEGRATION) {\n // eslint-disable-next-line no-console\n console.log(`watcher ${state.watcherId} notified`, args, state.watcher);\n }\n if (!state.pending && !state.destroyed) {\n watchers.push(state);\n state.pending = true;\n\n if (!nextFlush) {\n nextFlush = new Promise((resolve) => {\n queueMicrotask(() => {\n queueMicrotask(() => {\n queueMicrotask(() => {\n watchers.forEach(flush);\n if (LOG_REACT_SIGNAL_INTEGRATION) {\n // eslint-disable-next-line no-console\n console.log(\n \"Flushed watcher:\",\n watchers.map((w) => w.watcherId)\n );\n }\n watchers = [];\n nextFlush = null;\n\n resolve();\n });\n });\n });\n });\n }\n } else if (state.destroyed) {\n if (LOG_REACT_SIGNAL_INTEGRATION) {\n // eslint-disable-next-line no-console\n console.log(`[WarpDrive] Detected Watcher Destroyed During Notify, clearing signals`);\n }\n // if we are destroyed, we clear the watcher signals\n // so that it does not continue to watch for changes.\n state.snapshot = null;\n clearWatcher(state);\n }\n });\n\n // The watcher won't begin watching until we call `watcher.watch()`\n state.watcher.watch();\n state.snapshot = { watcher: state.watcher };\n\n return state;\n}\n\nexport function useWatcher(): { watcher: Signal.subtle.Watcher } | null {\n const state = useMemo(_createWatcher, []);\n\n return useSyncExternalStore(\n (notifyChanged: () => void) => {\n if (LOG_REACT_SIGNAL_INTEGRATION) {\n // eslint-disable-next-line no-console\n console.log(`[WarpDrive] Subscribing to Watcher`);\n }\n state.destroyed = false;\n state.notifyReact = notifyChanged;\n\n // The watcher won't begin watching until we call `watcher.watch()`\n state.watcher.watch();\n\n return () => {\n if (LOG_REACT_SIGNAL_INTEGRATION) {\n // eslint-disable-next-line no-console\n console.log(`[WarpDrive] Deactivating Watcher Subscription`);\n }\n state.destroyed = true;\n state.notifyReact = null;\n };\n },\n () => state.snapshot\n );\n}\n\n/**\n * @category Contexts\n */\nexport const WatcherContext: Context<{\n /**\n * The `Signal.subtle.Watcher` used to observe signal changes for the nearest {@link ReactiveContext}.\n */\n watcher: Signal.subtle.Watcher;\n} | null> = createContext<{\n watcher: Signal.subtle.Watcher;\n} | null>(null);\n\n/**\n *\n * @category Components\n */\nexport function ReactiveContext({ children }: { children: ReactNode }): JSX.Element {\n const watcher = useWatcher();\n /**\n * Unlike other frameworks, React does not have a built-in way to provide\n * a context value other than by rendering an extra component.\n *\n */\n return <WatcherContext value={watcher}>{children}</WatcherContext>;\n}\n"],"x_google_ignoreList":[0],"mappings":";;;;;AAiCA,SAAgBO,OAAOC,aAAa;CAClC,OAAOC,cAAcC,SAASF;AAChC;AAEA,SAAgBG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