@warp-drive-mirror/react 5.9.0-beta.1 → 5.9.0-beta.2

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.
Files changed (41) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/{declarations → dist}/index.d.ts +2 -2
  3. package/{declarations → dist}/index.d.ts.map +1 -1
  4. package/dist/index.js +3 -3
  5. package/dist/index.js.map +1 -1
  6. package/dist/install.js +2 -2
  7. package/dist/install.js.map +1 -1
  8. package/dist/{reactive-context-DNq02nr1.js → reactive-context-DhUW_l--.js} +2 -2
  9. package/dist/reactive-context-DhUW_l--.js.map +1 -0
  10. package/dist/unpkg/dev/index.js +15 -15
  11. package/dist/unpkg/dev/index.js.map +1 -1
  12. package/dist/unpkg/dev/install.js +2 -2
  13. package/dist/unpkg/dev/install.js.map +1 -1
  14. package/dist/unpkg/dev/{reactive-context-C9-Fc8qx.js → reactive-context-Ax2U-96G.js} +4 -4
  15. package/dist/unpkg/dev/reactive-context-Ax2U-96G.js.map +1 -0
  16. package/dist/unpkg/dev-deprecated/index.js +15 -15
  17. package/dist/unpkg/dev-deprecated/index.js.map +1 -1
  18. package/dist/unpkg/dev-deprecated/install.js +2 -2
  19. package/dist/unpkg/dev-deprecated/install.js.map +1 -1
  20. package/dist/unpkg/dev-deprecated/{reactive-context-DhpCE2Tv.js → reactive-context-B-pn7tS7.js} +4 -4
  21. package/dist/unpkg/dev-deprecated/reactive-context-B-pn7tS7.js.map +1 -0
  22. package/dist/unpkg/prod/index.js +3 -3
  23. package/dist/unpkg/prod/index.js.map +1 -1
  24. package/dist/unpkg/prod/install.js +2 -2
  25. package/dist/unpkg/prod/install.js.map +1 -1
  26. package/dist/unpkg/prod/{reactive-context-CvfXAZqb.js → reactive-context-eAEvPuqb.js} +2 -2
  27. package/dist/unpkg/prod/reactive-context-eAEvPuqb.js.map +1 -0
  28. package/dist/unpkg/prod-deprecated/index.js +3 -3
  29. package/dist/unpkg/prod-deprecated/index.js.map +1 -1
  30. package/dist/unpkg/prod-deprecated/install.js +2 -2
  31. package/dist/unpkg/prod-deprecated/install.js.map +1 -1
  32. package/dist/unpkg/prod-deprecated/{reactive-context-CvfXAZqb.js → reactive-context-eAEvPuqb.js} +2 -2
  33. package/dist/unpkg/prod-deprecated/reactive-context-eAEvPuqb.js.map +1 -0
  34. package/package.json +22 -29
  35. package/dist/reactive-context-DNq02nr1.js.map +0 -1
  36. package/dist/unpkg/dev/reactive-context-C9-Fc8qx.js.map +0 -1
  37. package/dist/unpkg/dev-deprecated/reactive-context-DhpCE2Tv.js.map +0 -1
  38. package/dist/unpkg/prod/reactive-context-CvfXAZqb.js.map +0 -1
  39. package/dist/unpkg/prod-deprecated/reactive-context-CvfXAZqb.js.map +0 -1
  40. /package/{declarations → dist}/install.d.ts +0 -0
  41. /package/{declarations → dist}/install.d.ts.map +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["Store","createContext","JSX","ReactNode","use","useMemo","jsx","_jsx","StoreContext","useStore","store","StoreProvider","$props","value","children","createRequestSubscription","AutorefreshBehaviorCombos","DISPOSE","RequestArgs","signal","JSX","ReactNode","useEffect","useMemo","useRef","useStore","ReactiveContext","Future","StoreRequestInput","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","isStrict","store","Chrome","chrome","sink","args","current","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;CAMhC,OALcL,IAAII,YAKXE;AACT;;;;AAQA,SAAgBC,cAAcC,QAAuD;CACnF,MAAMF,QAAQL,cACL,WAAWO,SAASA,OAAOF,QAAQ,IAAIE,OAAOZ,MAAM,GAC3D,CAAC,WAAWY,SAASA,OAAOF,QAAQE,OAAOZ,KAAK,CAClD;CAEA,OAAOO,kBAACC,cAAY;EAACK,OAAOH;EAAMI,UAAEF,OAAOE;CAAQ,CAAe;AACpE;;;;AClCA,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,QAAQ,MAAM;CAC3C,IAAI;CACJ,IAAI,SAAS,OAAO;CACpB,OAAO,QAAQ;EACb,IAAI,QAAQ,KAAK,SAAS,IAAI,MAAM,MAAM,OAAO,KAAK,IAAI,GAAG,IAAI,IAAI;EACrE,IAAI,MACF,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E,UAAU;GACjB;EACF;EAGF,OAAOF,KAAKE,UAAUI,YAAYJ,QAASO,UAAUC;CACvD;CAmBA9C,UAAU+C,QAAa,CAACX,KAAKE,OAAO,CAAC;CAErC,MAAMU,QAAQpB,OAAOa,gBAAgBL,KAAKE;CAC1C,MAAMW,QAAQrB,OAAOsB;CAErB,OACEtC,kBAACsB,QAAM;EAACc,OAAOA,MAAMG,SAAS,OAAOH,MAAMI;EAAUC,UAAUL,MAAMM;EAAgB9B,UAGjFwB,MAAMG,UAAUF,MAAMM,OAAO3C,kBAACqC,MAAMM,MAAI,CAAA,CAAE,IACtCP,MAAMG,SAASvC,kBAACa,OAAK,EAACC,OAAOb,sBAAsB,CAAE,IACrDmC,MAAMI,SAASI,YAAYP,MAAMQ,UAAU7C,kBAACqC,MAAMQ,SAAO,EAACT,OAAOA,MAAMI,SAASM,aAAa,CAAE,IAAI,KACnGV,MAAMI,SAASO,eAAeV,MAAMW,YAAYhD,kBAACqC,MAAMW,WAAS;GAAClC,OAAOsB,MAAMI,SAASS;GAAQR,UAAUL,MAAMc;EAAc,CAAE,IAC/Hd,MAAMI,SAASW,WAAWd,MAAMvB,QAAQd,kBAACqC,MAAMvB,OAAK;GAACA,OAAOsB,MAAMI,SAASS;GAAQR,UAAUL,MAAMc;EAAc,CAAE,IACnHd,MAAMI,SAASY,YAAYf,MAAMgB,UAAUrD,kBAACqC,MAAMgB,SAAO;GAACC,QAAQlB,MAAMI,SAASe;GAAOd,UAAUL,MAAMM;EAAgB,CAAE,IAAI1C,kBAACa,OAAK,EAACC,uBAAO,IAAIZ,MAAM,oDAAoD,EAAE,CAAE,IAC9M,CAACkC,MAAMI,SAASO,cAAc/C,kBAACa,OAAK,EAACC,OAAOsB,MAAMI,SAASS,OAAO,CAAE,IACpE;CAAG,CAEH;AAEZ"}
1
+ {"version":3,"file":"index.js","names":["createContext","use","useMemo","jsx","_jsx","StoreContext","useStore","store","StoreProvider","$props","Store","value","children","useEffect","useRef","createRequestSubscription","DISPOSE","signal","ReactiveContext","useStore","g","i","Fragment","_Fragment","jsx","_jsx","IdleBlockMissingError","Error","ReactiveArgs","prototype","request","query","autorefresh","autorefreshThreshold","autorefreshBehavior","DefaultChrome","children","Throw","error","Request","$props","InternalRequest","isStrictModeRender","count","isStrict","store","Chrome","chrome","sink","args","current","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;CAMhC,OALcL,IAAII,YAKXE;AACT;;;;AAQA,SAAgBC,cAAcC,QAAuD;CACnF,MAAMF,QAAQL,cACL,WAAWO,SAASA,OAAOF,QAAQ,IAAIE,OAAOC,MAAM,GAC3D,CAAC,WAAWD,SAASA,OAAOF,QAAQ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vB,QAAQb,kBAACoC,MAAMvB,OAAK;GAACA,OAAOsB,MAAMI,SAASS;GAAQR,UAAUL,MAAMc;EAAc,CAAE,IACnHd,MAAMI,SAASY,YAAYf,MAAMgB,UAAUpD,kBAACoC,MAAMgB,SAAO;GAACC,QAAQlB,MAAMI,SAASe;GAAOd,UAAUL,MAAMM;EAAgB,CAAE,IAAIzC,kBAACY,OAAK,EAACC,uBAAO,IAAIX,MAAM,oDAAoD,EAAE,CAAE,IAC9M,CAACiC,MAAMI,SAASO,cAAc9C,kBAACY,OAAK,EAACC,OAAOsB,MAAMI,SAASS,OAAO,CAAE,IACpE;CAAG,CAEH;AAEZ"}
@@ -1,6 +1,6 @@
1
- import { n as WatcherContext } from "./reactive-context-CvfXAZqb.js";
2
- import { Signal } from "signal-polyfill";
1
+ import { n as WatcherContext } from "./reactive-context-eAEvPuqb.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","tryConsumeContext","signal","logError","console","error","watcher","watch","pending","settled","buildSignalConfig","options","createSignal","obj","key","State","equals","notifySignal","set","get","consumeSignal","createMemo","object","fn","memo","Computed","waitFor","promise","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 // eslint-disable-next-line no-console\n const logError = console.error;\n try {\n // eslint-disable-next-line no-console\n console.error = () => {};\n // ensure signals are watched by our closest watcher\n const watcher = use(WatcherContext);\n // eslint-disable-next-line no-console\n console.error = logError;\n watcher?.watcher.watch(signal);\n if (LOG_REACT_SIGNAL_INTEGRATION) {\n // eslint-disable-next-line no-console\n console.log(`[WarpDrive] Consumed Context Signal`, signal, watcher);\n }\n } catch {\n // eslint-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 // eslint-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 // eslint-disable-next-line no-console\n console.log(`[WarpDrive] Notifying Signal`, signal);\n } else {\n // eslint-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,SAASI,kBAAkBC,QAAgE;CAEzF,MAAMC,WAAWC,QAAQC;CACzB,IAAI;EAEFD,QAAQC,cAAc,CAAC;EAEvB,MAAMC,UAAUT,IAAIG,cAAc;EAElCI,QAAQC,QAAQF;EAChBG,SAASA,QAAQC,MAAML,MAAM;CAK/B,QAAQ;EAENE,QAAQC,QAAQF;CAOlB;AACF;;;;;;;;AAUA,eAAsBM,UAAyB,CAa/C;;;;;;;;AASA,SAAgBC,kBAAkBC,SAAoC;CACpE,OAAO;EACLC,eAAeC,KAAaC,QAC1B,IAAIhB,OAAOiB,MAA6B,MAAM,EAAEC,cAAc,MAAM,CAAC;EAEvEC,eAAef,WAAkC;GAU/CA,OAAOgB,IAAIhB,OAAOiB,IAAI,CAAC;EACzB;EAEAC,gBAAgBlB,WAAkC;GAChDD,kBAAkBC,MAAM;GACxB,AAAKA,OAAOiB,IAAI;EAClB;EAEAE,aAAgBC,QAAgBR,KAAsBS,OAA2B;GAC/E,MAAMC,OAAO,IAAI1B,OAAO2B,SAAYF,EAAE;GACtC,aAAa;IACXtB,kBAAkBuB,IAAI;IAEtB,OAAOA,KAAKL,IAAI;GAClB;EACF;EAEAO,UAAUC,YAAY;GASpB,OAAOA;EACT;EAEAC,6BAA6B;CAC/B;AACF;AAEA7B,aAAaW,iBAAiB"}
1
+ {"version":3,"file":"install.js","names":["use","Signal","setupSignals","WatcherContext","tryConsumeContext","signal","logError","console","error","watcher","watch","pending","settled","buildSignalConfig","options","createSignal","obj","key","State","equals","notifySignal","set","get","consumeSignal","createMemo","object","fn","memo","Computed","waitFor","promise","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,SAASI,kBAAkBC,QAAgE;CAEzF,MAAMC,WAAWC,QAAQC;CACzB,IAAI;EAEFD,QAAQC,cAAc,CAAC;EAEvB,MAAMC,UAAUT,IAAIG,cAAc;EAElCI,QAAQC,QAAQF;EAChBG,SAASA,QAAQC,MAAML,MAAM;CAK/B,QAAQ;EAENE,QAAQC,QAAQF;CAOlB;AACF;;;;;;;;AAUA,eAAsBM,UAAyB,CAa/C;;;;;;;;AASA,SAAgBC,kBAAkBC,SAAoC;CACpE,OAAO;EACLC,eAAeC,KAAaC,QAC1B,IAAIhB,OAAOiB,MAA6B,MAAM,EAAEC,cAAc,MAAM,CAAC;EAEvEC,eAAef,WAAkC;GAU/CA,OAAOgB,IAAIhB,OAAOiB,IAAI,CAAC;EACzB;EAEAC,gBAAgBlB,WAAkC;GAChDD,kBAAkBC,MAAM;GACxB,AAAKA,OAAOiB,IAAI;EAClB;EAEAE,aAAgBC,QAAgBR,KAAsBS,OAA2B;GAC/E,MAAMC,OAAO,IAAI1B,OAAO2B,SAAYF,EAAE;GACtC,aAAa;IACXtB,kBAAkBuB,IAAI;IAEtB,OAAOA,KAAKL,IAAI;GAClB;EACF;EAEAO,UAAUC,YAAY;GASpB,OAAOA;EACT;EAEAC,6BAA6B;CAC/B;AACF;AAEA7B,aAAaW,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 { jsx } from "react/jsx-runtime";
4
4
 
5
5
  //#region src/-private/reactive-context.tsx
@@ -89,4 +89,4 @@ function ReactiveContext({ children }) {
89
89
 
90
90
  //#endregion
91
91
  export { WatcherContext as n, ReactiveContext as t };
92
- //# sourceMappingURL=reactive-context-CvfXAZqb.js.map
92
+ //# sourceMappingURL=reactive-context-eAEvPuqb.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reactive-context-eAEvPuqb.js","names":["createContext","useSyncExternalStore","useMemo","Signal","jsx","_jsx","nextFlush","watchers","watcherId","clearWatcher","state","watcher","unwatch","subtle","introspectSources","flush","pending","destroyed","snapshot","notifyReact","watch","_createWatcher","id","Watcher","args","push","Promise","resolve","queueMicrotask","forEach","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,IAAIM,YAAkC;AACtC,IAAIC,WAA2B,CAAA;AAC/B,IAAIC,YAAY;AAchB,SAASC,aAAaC,OAAqB;CACzCA,MAAMC,QAAQC,QAAQ,GAAGT,OAAOU,OAAOC,kBAAkBJ,MAAMC,OAAO,CAAC;AACzE;AAEA,SAASI,MAAML,OAAqB;CAClCA,MAAMM,UAAU;CAChB,IAAIN,MAAMO,WAAW;EAKnBP,MAAMQ,WAAW;EACjBT,aAAaC,KAAK;EAClB;CACF;CAWAA,MAAMQ,WAAW,EAAEP,SAASD,MAAMC,QAAQ;CAC1C,IAAID,MAAMS,aAAaT,MAAMS,YAAY;CAIzCT,MAAMC,QAAQS,MAAM;AACtB;AAEA,SAASC,iBAAiB;CAMxB,MAAMX,QAAsB;EAC1BF,WAAWc,AANFd;EAOTQ,SAAS;EACTC,WAAW;EACXE,aAAa;EACbR,SAAS;EAITO,UAAU;CACZ;CAEAR,MAAMC,UAAU,IAAIR,OAAOU,OAAOU,SAAS,GAAGC,SAAS;EAKrD,IAAI,CAACd,MAAMM,WAAW,CAACN,MAAMO,WAAW;GACtCV,SAASkB,KAAKf,KAAK;GACnBA,MAAMM,UAAU;GAEhB,IAAI,CAACV,WACHA,YAAY,IAAIoB,SAASC,YAAY;IACnCC,qBAAqB;KACnBA,qBAAqB;MACnBA,qBAAqB;OACnBrB,SAASsB,QAAQd,KAAK;OAQtBR,WAAW,CAAA;OACXD,YAAY;OAEZqB,QAAQ;MACV,CAAC;KACH,CAAC;IACH,CAAC;GACH,CAAC;EAEL,OAAO,IAAIjB,MAAMO,WAAW;GAO1BP,MAAMQ,WAAW;GACjBT,aAAaC,KAAK;EACpB;CACF,CAAC;CAGDA,MAAMC,QAAQS,MAAM;CACpBV,MAAMQ,WAAW,EAAEP,SAASD,MAAMC,QAAQ;CAE1C,OAAOD;AACT;AAEA,SAAgBoB,aAAwD;CACtE,MAAMpB,QAAQR,QAAQmB,gBAAgB,CAAA,CAAE;CAExC,OAAOpB,sBACJ8B,kBAA8B;EAK7BrB,MAAMO,YAAY;EAClBP,MAAMS,cAAcY;EAGpBrB,MAAMC,QAAQS,MAAM;EAEpB,aAAa;GAKXV,MAAMO,YAAY;GAClBP,MAAMS,cAAc;EACtB;CACF,SACMT,MAAMQ,QACd;AACF;;;;AAKA,MAAac,iBAKDhC,4BAEF,IAAI;;;;;AAMd,SAAgBiC,gBAAgB,EAAEC,YAAkD;CAClF,MAAMvB,UAAUmB,WAAW;;;;;;CAM3B,OAAOzB,kBAAC2B,gBAAc;EAACG,OAAOxB;EAAUuB;CAAQ,CAAiB;AACnE"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@warp-drive-mirror/react",
3
3
  "description": "Data bindings and utilities for React applications using WarpDrive",
4
- "version": "5.9.0-beta.1",
4
+ "version": "5.9.0-beta.2",
5
5
  "license": "MIT",
6
6
  "author": "Chris Thoburn <runspired@users.noreply.github.com>",
7
7
  "repository": {
@@ -18,7 +18,6 @@
18
18
  "warp-drive"
19
19
  ],
20
20
  "files": [
21
- "declarations",
22
21
  "addon-main.cjs",
23
22
  "dist",
24
23
  "README.md",
@@ -31,7 +30,7 @@
31
30
  "unpkg-dev": "./dist/unpkg/dev/index.js",
32
31
  "unpkg-deprecated": "./dist/unpkg/prod-deprecated/index.js",
33
32
  "unpkg": "./dist/unpkg/prod/index.js",
34
- "types": "./declarations/index.d.ts",
33
+ "types": "./dist/index.d.ts",
35
34
  "default": "./dist/index.js"
36
35
  },
37
36
  "./*": {
@@ -39,51 +38,45 @@
39
38
  "unpkg-dev": "./dist/unpkg/dev/*.js",
40
39
  "unpkg-deprecated": "./dist/unpkg/prod-deprecated/*.js",
41
40
  "unpkg": "./dist/unpkg/prod/*.js",
42
- "types": "./declarations/*.d.ts",
41
+ "types": "./dist/*.d.ts",
43
42
  "default": "./dist/*.js"
44
43
  }
45
44
  },
46
45
  "dependencies": {
47
46
  "@embroider/macros": "^1.20.6",
48
- "@warp-drive-mirror/core": "5.9.0-beta.1",
49
- "@warp-drive-mirror/tc39-proposal-signals": "5.9.0-beta.1",
50
- "react": "^19.1.1",
47
+ "@warp-drive-mirror/core": "5.9.0-beta.2",
48
+ "@warp-drive-mirror/tc39-proposal-signals": "5.9.0-beta.2",
49
+ "react": "^19.2.8",
51
50
  "signal-polyfill": "^0.2.2"
52
51
  },
53
52
  "peerDependenciesMeta": {},
54
53
  "devDependencies": {
55
- "@babel/core": "^7.28.3",
56
- "@babel/plugin-transform-typescript": "^7.28.0",
57
- "@babel/preset-env": "^7.28.3",
58
- "@babel/preset-react": "^7.27.1",
59
- "@babel/preset-typescript": "^7.27.1",
60
- "@babel/runtime": "^7.28.3",
61
- "@embroider/addon-dev": "^8.1.0",
62
- "@types/react": "^19.1.11",
63
- "@warp-drive-mirror/core": "5.9.0-beta.1",
64
- "@warp-drive/internal-config": "5.9.0-beta.1",
65
- "decorator-transforms": "^2.3.0",
66
- "react": "^19.1.1",
67
- "rollup": "^4.48.0",
54
+ "@babel/core": "^7.29.7",
55
+ "@babel/plugin-transform-typescript": "^7.29.7",
56
+ "@babel/preset-env": "^7.29.7",
57
+ "@babel/preset-react": "^7.29.7",
58
+ "@babel/preset-typescript": "^7.29.7",
59
+ "@babel/runtime": "^7.29.7",
60
+ "@types/react": "^19.2.18",
61
+ "@warp-drive-mirror/core": "5.9.0-beta.2",
62
+ "@warp-drive/internal-config": "5.9.0-beta.2",
63
+ "decorator-transforms": "^2.4.0",
64
+ "react": "^19.2.8",
68
65
  "tsdown": "^0.22.14",
69
- "typescript": "^5.9.3"
70
- },
71
- "volta": {
72
- "extends": "../../../../../../package.json"
66
+ "typescript-7": "npm:typescript@7.1.0-dev.20260828.1"
73
67
  },
74
68
  "ember-addon": {
75
69
  "main": "addon-main.cjs",
76
70
  "type": "addon",
77
- "version": 2,
78
- "externals": []
71
+ "version": 2
79
72
  },
80
73
  "ember": {
81
74
  "edition": "octane"
82
75
  },
83
76
  "scripts": {
84
- "build:pkg": "NODE_ENV=production tsdown",
77
+ "build:pkg": "NODE_ENV=production node node_modules/tsdown/dist/run.mjs",
85
78
  "sync": "echo \"syncing\"",
86
- "lint": "eslint . --quiet --cache --cache-strategy=content",
87
- "start": "tsdown --watch"
79
+ "check:types": "node ./node_modules/typescript-7/bin/tsc --noEmit",
80
+ "start": "node node_modules/tsdown/dist/run.mjs --watch"
88
81
  }
89
82
  }
@@ -1 +0,0 @@
1
- {"version":3,"file":"reactive-context-DNq02nr1.js","names":["Signal","createContext","useSyncExternalStore","useMemo","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 { Signal } from \"signal-polyfill\";\nimport { createContext, type JSX, type ReactNode, useSyncExternalStore, type Context, useMemo } from \"react\";\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 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 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 }\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 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 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 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 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 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 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":";;;;;;AAIA,IAAIQ,YAAkC;AACtC,IAAIC,WAA2B,CAAA;AAC/B,IAAIC,YAAY;AAchB,SAASC,aAAaC,OAAqB;CACzCA,MAAMC,QAAQC,QAAQ,GAAGd,OAAOe,OAAOC,kBAAkBJ,MAAMC,OAAO,CAAC;AACzE;AAEA,SAASI,MAAML,OAAqB;CAClCA,MAAMM,UAAU;CAChB,IAAIN,MAAMO,WAAW;EACnB,IAAAd,eAAA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AAAD,gBAAA,CAAA,CAAAgB,UAAAC,cAAAC,4BAAA,GAAA;OAAAlB,gBAAA,CAAA,CAAAgB,UAAAG,MAAAD,gCAAAE,WAAAC,0BAAA,CAAA,CAAAF,MAAAD,8BACEI,QAAQC,IAAI,oCAAoC;EAClD;EACAf,MAAMO,YAAY;EAClBP,MAAMmB,cAAcc;EAGpBjC,MAAMC,QAAQmB,MAAM;EAEpB,aAAa;GACX,IAAA3B,eAAAD,gBAAA,CAAA,CAAAgB,UAAAC,cAAAC,4BAAA,GAAA;QAAAlB,gBAAA,CAAA,CAAAgB,UAAAG,MAAAD,gCAAAE,WAAAC,0BAAA,CAAA,CAAAF,MAAAD,8BACEI,QAAQC,IAAI,+CAA+C;GAC7D;GACAf,MAAMO,YAAY;GAClBP,MAAMmB,cAAc;EACtB;CACF,SACMnB,MAAMgB,QACd;AACF;;;;AAKA,MAAakB,iBAKD7C,4BAEF,IAAI;;;;;AAMd,SAAgB8C,gBAAgB,EAAEC,YAAkD;CAClF,MAAMnC,UAAU+B,WAAW;;;;;;CAM3B,OAAOrC,kBAACuC,gBAAc;EAACG,OAAOpC;EAAUmC;CAAQ,CAAiB;AACnE"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"reactive-context-C9-Fc8qx.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","Signal","createContext","useSyncExternalStore","useMemo","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/@embroi_8c5bde00dfb478e637d05be822ff1428/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 { Signal } from \"signal-polyfill\";\nimport { createContext, type JSX, type ReactNode, useSyncExternalStore, type Context, useMemo } from \"react\";\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 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 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 }\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 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 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 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 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 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 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,kBAAkB;CAChC,OAAOF,cAAcG;AACvB;AAwBA,MAAMH,gBAAgBS,WAAWC,yCAAyC,CAAC;AAE3EV,cAAcC,aAAa,CAAC;AAC5BD,cAAcG,WAAW,CAAC;AAK1B,MAAMQ,cAAcC,8BAA8B;AAElDC,OAAOC,OAAOd,cAAcC,U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A,CAAE;CAExC,OAAO9B,sBACJ0C,kBAA8B;EAAA,IAAAvC,gBAAA,CAAA,CAAAe,UAAAC,MAAAC,gCAAAC,WAAAC,0BAAA,CAAA,CAAAH,MAAAC,8BAE3BG,QAAQC,IAAI,oCAAoC;EAElDd,MAAMO,YAAY;EAClBP,MAAMkB,cAAcc;EAGpBhC,MAAMC,QAAQkB,MAAM;EAEpB,aAAa;GAAA,IAAA1B,gBAAA,CAAA,CAAAe,UAAAC,MAAAC,gCAAAC,WAAAC,0BAAA,CAAA,CAAAH,MAAAC,8BAETG,QAAQC,IAAI,+CAA+C;GAE7Dd,MAAMO,YAAY;GAClBP,MAAMkB,cAAc;EACtB;CACF,SACMlB,MAAMe,QACd;AACF;;;;AAKA,MAAakB,iBAKD5C,4BAEF,IAAI;;;;;AAMd,SAAgB6C,gBAAgB,EAAEC,YAAkD;CAClF,MAAMlC,UAAU8B,WAAW;;;;;;CAM3B,OAAOpC,qBAACsC,gBAAc;EAACG,OAAOnC;EAAUkC;CAAQ,GAAA,KAAA,GAAA,OAAA;EAAAE,UAAAC;EAAAC,YAAA;EAAAC,cAAA;CAAA,GAAA,IAAiB;AACnE"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"reactive-context-DhpCE2Tv.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","Signal","createContext","useSyncExternalStore","useMemo","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/@embroi_8c5bde00dfb478e637d05be822ff1428/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 { Signal } from \"signal-polyfill\";\nimport { createContext, type JSX, type ReactNode, useSyncExternalStore, type Context, useMemo } from \"react\";\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 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 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 }\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 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 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 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 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 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 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,kBAAkB;CAChC,OAAOF,cAAcG;AACvB;AAwBA,MAAMH,gBAAgBS,WAAWC,yCAAyC,CAAC;AAE3EV,cAAcC,aAAa,CAAC;AAC5BD,cAAcG,WAAW,CAAC;AAK1B,MAAMQ,cAAcC,8BAA8B;AAElDC,OAAOC,OAAOd,cAAcC,UAAUU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AE;CAExC,OAAO9B,sBACJ0C,kBAA8B;EAAA,IAAAvC,gBAAA,CAAA,CAAAe,UAAAC,MAAAC,gCAAAC,WAAAC,0BAAA,CAAA,CAAAH,MAAAC,8BAE3BG,QAAQC,IAAI,oCAAoC;EAElDd,MAAMO,YAAY;EAClBP,MAAMkB,cAAcc;EAGpBhC,MAAMC,QAAQkB,MAAM;EAEpB,aAAa;GAAA,IAAA1B,gBAAA,CAAA,CAAAe,UAAAC,MAAAC,gCAAAC,WAAAC,0BAAA,CAAA,CAAAH,MAAAC,8BAETG,QAAQC,IAAI,+CAA+C;GAE7Dd,MAAMO,YAAY;GAClBP,MAAMkB,cAAc;EACtB;CACF,SACMlB,MAAMe,QACd;AACF;;;;AAKA,MAAakB,iBAKD5C,4BAEF,IAAI;;;;;AAMd,SAAgB6C,gBAAgB,EAAEC,YAAkD;CAClF,MAAMlC,UAAU8B,WAAW;;;;;;CAM3B,OAAOpC,qBAACsC,gBAAc;EAACG,OAAOnC;EAAUkC;CAAQ,GAAA,KAAA,GAAA,OAAA;EAAAE,UAAAC;EAAAC,YAAA;EAAAC,cAAA;CAAA,GAAA,IAAiB;AACnE"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"reactive-context-CvfXAZqb.js","names":["Signal","createContext","useSyncExternalStore","useMemo","jsx","_jsx","nextFlush","watchers","watcherId","clearWatcher","state","watcher","unwatch","subtle","introspectSources","flush","pending","destroyed","snapshot","notifyReact","watch","_createWatcher","id","Watcher","args","push","Promise","resolve","queueMicrotask","forEach","useWatcher","notifyChanged","WatcherContext","ReactiveContext","children","value"],"sources":["../../../src/-private/reactive-context.tsx"],"sourcesContent":["import { Signal } from \"signal-polyfill\";\nimport { createContext, type JSX, type ReactNode, useSyncExternalStore, type Context, useMemo } from \"react\";\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 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 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 }\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 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 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 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 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 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 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":";;;;;AAIA,IAAIM,YAAk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AAMO,YAAY;EAClBP,MAAMS,cAAcY;EAGpBrB,MAAMC,QAAQS,MAAM;EAEpB,aAAa;GAIXV,MAAMO,YAAY;GAClBP,MAAMS,cAAc;EACtB;CACF,SACMT,MAAMQ,QACd;AACF;;;;AAKA,MAAac,iBAKD/B,4BAEF,IAAI;;;;;AAMd,SAAgBgC,gBAAgB,EAAEC,YAAkD;CAClF,MAAMvB,UAAUmB,WAAW;;;;;;CAM3B,OAAOzB,kBAAC2B,gBAAc;EAACG,OAAOxB;EAAUuB;CAAQ,CAAiB;AACnE"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"reactive-context-CvfXAZqb.js","names":["Signal","createContext","useSyncExternalStore","useMemo","jsx","_jsx","nextFlush","watchers","watcherId","clearWatcher","state","watcher","unwatch","subtle","introspectSources","flush","pending","destroyed","snapshot","notifyReact","watch","_createWatcher","id","Watcher","args","push","Promise","resolve","queueMicrotask","forEach","useWatcher","notifyChanged","WatcherContext","ReactiveContext","children","value"],"sources":["../../../src/-private/reactive-context.tsx"],"sourcesContent":["import { Signal } from \"signal-polyfill\";\nimport { createContext, type JSX, type ReactNode, useSyncExternalStore, type Context, useMemo } from \"react\";\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 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 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 }\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 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 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 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 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 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 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":";;;;;AAIA,IAAIM,YAAkC;AACtC,IAAIC,WAA2B,CAAA;AAC/B,IAAIC,YAAY;AAchB,SAASC,aAAaC,OAAqB;CACzCA,MAAMC,QAAQC,QAAQ,GAAGZ,OAAOa,OAAOC,kBAAkBJ,MAAMC,OAAO,CAAC;AACzE;AAEA,SAASI,MAAML,OAAqB;CAClCA,MAAMM,UAAU;CAChB,IAAIN,MAAMO,WAAW;EAInBP,MAAMQ,WAAW;EACjBT,aAAaC,KAAK;EAClB;CACF;CASAA,MAAMQ,WAAW,EAAEP,SAASD,MAAMC,QAAQ;CAC1C,IAAID,MAAMS,aAAaT,MAAMS,Y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