march-hare 0.13.10 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -4
- package/dist/action/utils.d.ts +3 -3
- package/dist/actions/utils.d.ts +4 -0
- package/dist/boundary/components/sharing/index.d.ts +24 -9
- package/dist/coalesce/index.d.ts +3 -43
- package/dist/march-hare.js +7 -7
- package/dist/march-hare.js.map +1 -1
- package/dist/march-hare.umd.cjs +1 -1
- package/dist/march-hare.umd.cjs.map +1 -1
- package/dist/resource/index.d.ts +8 -4
- package/dist/resource/types.d.ts +0 -8
- package/dist/types/index.d.ts +48 -37
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -464,22 +464,24 @@ export default function Profile(): React.ReactElement {
|
|
|
464
464
|
`context.actions.resource(invocation)` returns a chainable thenable:
|
|
465
465
|
|
|
466
466
|
- `.exceeds({ minutes: 5 })` — short-circuits when the per-params cache age is within the freshness window. Accepts a `Temporal.Duration`, a `DurationLike` object, or an ISO 8601 duration string. `Temporal` is read from the host runtime – bring a polyfill (e.g. [`@js-temporal/polyfill`](https://github.com/js-temporal/temporal-polyfill)) if your target doesn't expose it natively.
|
|
467
|
-
- `.
|
|
467
|
+
- `.isolated()` — opts this call out of the default `(Resource, params)` coalesce path. Fires an independent network request against the caller's own `context.task.controller`. Reach for it only when two callers genuinely need parallel fetches with byte-identical params; the default is almost always what you want.
|
|
468
|
+
|
|
469
|
+
By default, concurrent callers with the same `(Resource, params)` share a single in-flight fetch — one network request, every caller resolves with the same payload. The shared fetch runs on a detached `AbortController` so one caller's abort never cancels work other callers are still waiting on; when every caller has released the shared controller is aborted too, so the network gets cancelled rather than orphaned.
|
|
468
470
|
|
|
469
471
|
```ts
|
|
470
472
|
// Mount and a broadcast handler both fire on mount — only one network request.
|
|
471
473
|
actions.useAction(Actions.Mount, async (context) => {
|
|
472
|
-
const user = await context.actions.resource(resource.user())
|
|
474
|
+
const user = await context.actions.resource(resource.user());
|
|
473
475
|
context.actions.produce(({ model }) => void (model.user = user));
|
|
474
476
|
});
|
|
475
477
|
|
|
476
478
|
actions.useAction(Actions.Broadcast.UserId, async (context, id) => {
|
|
477
|
-
const user = await context.actions.resource(resource.user({ id }))
|
|
479
|
+
const user = await context.actions.resource(resource.user({ id }));
|
|
478
480
|
context.actions.produce(({ model }) => void (model.user = user));
|
|
479
481
|
});
|
|
480
482
|
```
|
|
481
483
|
|
|
482
|
-
|
|
484
|
+
The dedupe key is `(Resource, params)`. Two callers with different params (`{ id: 5 }` vs. `{ id: 6 }`) never share — they hash to different slots and fire independent requests. If you ever need two parallel calls with byte-identical params (vanishingly rare, almost always a smell that the params should differ), chain `.isolated()`.
|
|
483
485
|
|
|
484
486
|
The fetcher receives a `context` object — read fields via `context.env`, `context.controller`, `context.params`. There are no callbacks – no `onSuccess`, no `onError`. The `context.dispatch` field can fire broadcast or multicast actions from inside the fetcher (unicast is rejected at compile time), but most side-effects (model writes, analytics) belong in the `useAction` handler that awaited the call:
|
|
485
487
|
|
package/dist/action/utils.d.ts
CHANGED
|
@@ -61,9 +61,9 @@ export declare function isChanneledAction(action: AnyAction): action is Channele
|
|
|
61
61
|
/**
|
|
62
62
|
* Extracts the lifecycle type from an action's symbol description.
|
|
63
63
|
*
|
|
64
|
-
* Returns the lifecycle name (`"Mount"`, `"
|
|
65
|
-
* when the action symbol's description starts with the lifecycle
|
|
66
|
-
* `null` for non-lifecycle actions.
|
|
64
|
+
* Returns the lifecycle name (`"Mount"`, `"Paint"`, `"Unmount"`, `"Error"`,
|
|
65
|
+
* `"Update"`) when the action symbol's description starts with the lifecycle
|
|
66
|
+
* prefix, or `null` for non-lifecycle actions.
|
|
67
67
|
*
|
|
68
68
|
* @param action The action to inspect.
|
|
69
69
|
* @returns The lifecycle name, or `null` if not a lifecycle action.
|
package/dist/actions/utils.d.ts
CHANGED
|
@@ -43,6 +43,10 @@ export declare function emitAsync(emitter: EventEmitter, event: string | symbol,
|
|
|
43
43
|
* mount) and `Unmounted` (re-mount after `<Activity>` show) as entry states
|
|
44
44
|
* so that hidden-then-shown subtrees correctly re-emit Mount.
|
|
45
45
|
*
|
|
46
|
+
* The Paint effect runs as a passive `useEffect` so it fires after the
|
|
47
|
+
* browser has committed the first frame. It tracks its own ref-guard so it
|
|
48
|
+
* fires exactly once per mount cycle (re-firing after `<Activity>` show).
|
|
49
|
+
*
|
|
46
50
|
* Phase transitions:
|
|
47
51
|
* - First mount: Mounting → Mounted
|
|
48
52
|
* - Activity hide / show: Mounted → Unmounting → Unmounted → Mounting → Mounted
|
|
@@ -1,20 +1,35 @@
|
|
|
1
1
|
import { Invocation } from '../../../resource/index.js';
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
/**
|
|
4
|
-
* Per
|
|
4
|
+
* Per-caller record stored in the {@link Sharing} registry. The
|
|
5
|
+
* `promise` is the shared in-flight fetch, `controller` is the
|
|
6
|
+
* detached `AbortController` driving it, and `refs` tracks how many
|
|
7
|
+
* callers are currently waiting. When the last caller releases (its
|
|
8
|
+
* `context.task.controller` aborts), the entry aborts its controller
|
|
9
|
+
* so the underlying work is cancelled rather than orphaned.
|
|
10
|
+
*
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
export type Share<T = unknown> = {
|
|
14
|
+
promise: Promise<T>;
|
|
15
|
+
controller: AbortController;
|
|
16
|
+
refs: number;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Per-`<Boundary>` registry for the default coalesce path. Outer map
|
|
5
20
|
* keys on the `Invocation.run` function identity (stable per Resource
|
|
6
21
|
* via the `build()` closure); inner map keys on
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
22
|
+
* `JSON.stringify(params)`. While an entry exists every caller for the
|
|
23
|
+
* same Resource + params joins the same {@link Share} record and
|
|
24
|
+
* resolves against its promise.
|
|
10
25
|
*
|
|
11
26
|
* Lifted into React context so each `<app.Boundary>` owns its own
|
|
12
27
|
* registry — two `App` instances in the same tree cannot collide
|
|
13
|
-
* on
|
|
28
|
+
* on the same `(Resource, params)` pair.
|
|
14
29
|
*
|
|
15
30
|
* @internal
|
|
16
31
|
*/
|
|
17
|
-
export type Sharing = WeakMap<Invocation<unknown, object>["run"], Map<string,
|
|
32
|
+
export type Sharing = WeakMap<Invocation<unknown, object>["run"], Map<string, Share>>;
|
|
18
33
|
/**
|
|
19
34
|
* React context exposing the per-Boundary sharing registry. The
|
|
20
35
|
* fallback is a fresh `WeakMap` used when `useSharing()` is read
|
|
@@ -25,8 +40,8 @@ export type Sharing = WeakMap<Invocation<unknown, object>["run"], Map<string, Pr
|
|
|
25
40
|
*/
|
|
26
41
|
export declare const Context: React.Context<Sharing>;
|
|
27
42
|
/**
|
|
28
|
-
* Wraps children with a Boundary-scoped sharing registry for
|
|
29
|
-
*
|
|
43
|
+
* Wraps children with a Boundary-scoped sharing registry for the
|
|
44
|
+
* default coalesce path. Rendered as part of {@link Boundary}; not
|
|
30
45
|
* exposed standalone.
|
|
31
46
|
*
|
|
32
47
|
* @internal
|
|
@@ -36,7 +51,7 @@ export declare function SharingProvider({ children, }: {
|
|
|
36
51
|
}): React.ReactElement;
|
|
37
52
|
/**
|
|
38
53
|
* Hook returning the per-Boundary sharing registry. Used by the
|
|
39
|
-
*
|
|
54
|
+
* default coalesce path inside `useActions`.
|
|
40
55
|
*
|
|
41
56
|
* @internal
|
|
42
57
|
*/
|
package/dist/coalesce/index.d.ts
CHANGED
|
@@ -1,43 +1,3 @@
|
|
|
1
|
-
import { Coalesce } from '../resource/types.js';
|
|
2
|
-
/**
|
|
3
|
-
* Sentinel token used when `.coalesce()` is called with no explicit
|
|
4
|
-
* argument. Every untokened caller for the same `(Resource, params)`
|
|
5
|
-
* slot collapses onto this single key, so multiple callers chaining
|
|
6
|
-
* `.coalesce()` share one in-flight fetch.
|
|
7
|
-
*
|
|
8
|
-
* The symbol description follows the `march-hare.{category}/{name}`
|
|
9
|
-
* convention used by the rest of the library's internal symbols.
|
|
10
|
-
*
|
|
11
|
-
* @internal
|
|
12
|
-
*/
|
|
13
|
-
export declare const token: unique symbol;
|
|
14
|
-
/**
|
|
15
|
-
* Builds the per-call dedupe key for `.coalesce(token)`.
|
|
16
|
-
*
|
|
17
|
-
* The full registry key (constructed at the call site) is
|
|
18
|
-
* `${JSON.stringify(params)}|${coalesceKey(token)}`; this function is
|
|
19
|
-
* responsible only for the trailing token segment. Every supported
|
|
20
|
-
* `Coalesce` primitive (`string`, `number`, `bigint`, `boolean`,
|
|
21
|
-
* `symbol`) is prefixed with a single-character type tag so that
|
|
22
|
-
* structurally identical values from different types stay distinct
|
|
23
|
-
* — e.g. the string `"5"` does not collide with the number `5`,
|
|
24
|
-
* and `Symbol("X")` does not collide with the string `"X"`.
|
|
25
|
-
*
|
|
26
|
-
* Symbols are keyed by their `description` (falling back to
|
|
27
|
-
* `String(value)` for description-less symbols) so two `Symbol("X")`
|
|
28
|
-
* instances declared in separate modules still hash to the same key.
|
|
29
|
-
* That is intentional: the public contract is "same description →
|
|
30
|
-
* same coalesce group", which keeps the API friendly for the common
|
|
31
|
-
* enum-token pattern at call sites.
|
|
32
|
-
*
|
|
33
|
-
* Any unrecognised value falls through to the object branch and is
|
|
34
|
-
* keyed by its JSON shape; `Coalesce` is constrained to primitives at
|
|
35
|
-
* the type level, so this branch is reachable only from `unknown`
|
|
36
|
-
* coercion in tests.
|
|
37
|
-
*
|
|
38
|
-
* @internal
|
|
39
|
-
*/
|
|
40
|
-
export declare function coalesceKey(value: Coalesce): string;
|
|
41
1
|
/**
|
|
42
2
|
* Wraps `promise` so that aborting `signal` rejects the returned
|
|
43
3
|
* promise with `signal.reason`, even when `promise` itself never
|
|
@@ -45,9 +5,9 @@ export declare function coalesceKey(value: Coalesce): string;
|
|
|
45
5
|
* work continues (other awaiters keep their grip) and only this
|
|
46
6
|
* caller's view of it is severed.
|
|
47
7
|
*
|
|
48
|
-
* Used by the
|
|
49
|
-
*
|
|
50
|
-
*
|
|
8
|
+
* Used by the default coalesce path: a shared in-flight fetch runs on
|
|
9
|
+
* a detached `AbortController` so one caller's abort does not cancel
|
|
10
|
+
* work the other callers are still waiting on, while each caller's own
|
|
51
11
|
* `context.task.controller` still aborts its personal await via this
|
|
52
12
|
* wrapper. The `{ once: true }` listener and the cleanup on settle keep
|
|
53
13
|
* the wrapper free of leaks across long-lived signals.
|
package/dist/march-hare.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as n from"react";import{G as r,A as o}from"@mobily/ts-belt";import{immerable as s,enablePatches as c,Immer as i,produce as a}from"immer";function u(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var l,f={exports:{}};const d=/* @__PURE__ */u((l||(l=1,function(e){var t=Object.prototype.hasOwnProperty,n="~";function r(){}function o(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function s(e,t,r,s,c){if("function"!=typeof r)throw new TypeError("The listener must be a function");var i=new o(r,s||e,c),a=n?n+t:t;return e._events[a]?e._events[a].fn?e._events[a]=[e._events[a],i]:e._events[a].push(i):(e._events[a]=i,e._eventsCount++),e}function c(e,t){0===--e._eventsCount?e._events=new r:delete e._events[t]}function i(){this._events=new r,this._eventsCount=0}Object.create&&(r.prototype=/* @__PURE__ */Object.create(null),(new r).__proto__||(n=!1)),i.prototype.eventNames=function(){var e,r,o=[];if(0===this._eventsCount)return o;for(r in e=this._events)t.call(e,r)&&o.push(n?r.slice(1):r);return Object.getOwnPropertySymbols?o.concat(Object.getOwnPropertySymbols(e)):o},i.prototype.listeners=function(e){var t=this._events[n?n+e:e];if(!t)return[];if(t.fn)return[t.fn];for(var r=0,o=t.length,s=new Array(o);r<o;r++)s[r]=t[r].fn;return s},i.prototype.listenerCount=function(e){var t=this._events[n?n+e:e];return t?t.fn?1:t.length:0},i.prototype.emit=function(e,t,r,o,s,c){var i=n?n+e:e;if(!this._events[i])return!1;var a,u,l=this._events[i],f=arguments.length;if(l.fn){switch(l.once&&this.removeListener(e,l.fn,void 0,!0),f){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,t),!0;case 3:return l.fn.call(l.context,t,r),!0;case 4:return l.fn.call(l.context,t,r,o),!0;case 5:return l.fn.call(l.context,t,r,o,s),!0;case 6:return l.fn.call(l.context,t,r,o,s,c),!0}for(u=1,a=new Array(f-1);u<f;u++)a[u-1]=arguments[u];l.fn.apply(l.context,a)}else{var d,p=l.length;for(u=0;u<p;u++)switch(l[u].once&&this.removeListener(e,l[u].fn,void 0,!0),f){case 1:l[u].fn.call(l[u].context);break;case 2:l[u].fn.call(l[u].context,t);break;case 3:l[u].fn.call(l[u].context,t,r);break;case 4:l[u].fn.call(l[u].context,t,r,o);break;default:if(!a)for(d=1,a=new Array(f-1);d<f;d++)a[d-1]=arguments[d];l[u].fn.apply(l[u].context,a)}}return!0},i.prototype.on=function(e,t,n){return s(this,e,t,n,!1)},i.prototype.once=function(e,t,n){return s(this,e,t,n,!0)},i.prototype.removeListener=function(e,t,r,o){var s=n?n+e:e;if(!this._events[s])return this;if(!t)return c(this,s),this;var i=this._events[s];if(i.fn)i.fn!==t||o&&!i.once||r&&i.context!==r||c(this,s);else{for(var a=0,u=[],l=i.length;a<l;a++)(i[a].fn!==t||o&&!i[a].once||r&&i[a].context!==r)&&u.push(i[a]);u.length?this._events[s]=1===u.length?u[0]:u:c(this,s)}return this},i.prototype.removeAllListeners=function(e){var t;return e?this._events[t=n?n+e:e]&&c(this,t):(this._events=new r,this._eventsCount=0),this},i.prototype.off=i.prototype.removeListener,i.prototype.addListener=i.prototype.on,i.prefixed=n,i.EventEmitter=i,e.exports=i}(f)),f.exports));class p extends d{cache=/* @__PURE__ */new Map;emit(e,...t){return this.cache.set(e,t[0]),super.emit(e,...t)}setCache(e,t){this.cache.set(e,t)}getCached(e){return this.cache.get(e)}fire(e,...t){return super.emit(e,...t)}}const h=n.createContext(new p);function m(){return n.useContext(h)}function y({children:t}){const r=n.useMemo(()=>new p,[]);/* @__PURE__ */
|
|
2
2
|
return e(h.Provider,{value:r,children:t})}const b=n.createContext(/* @__PURE__ */new Set);function v({children:t}){const r=n.useMemo(()=>/* @__PURE__ */new Set,[]);/* @__PURE__ */
|
|
3
|
-
return e(b.Provider,{value:r,children:t})}const g=n.createContext({current:{}});function w(){const e=n.useContext(g);return n.useMemo(()=>new Proxy({},{get:(t,n)=>Reflect.get(e.current,n),has:(t,n)=>n in e.current,ownKeys:()=>Reflect.ownKeys(e.current),getOwnPropertyDescriptor(t,n){const o=Object.getOwnPropertyDescriptor(e.current,n);if(!r.isUndefined(o))return{...o,configurable:!0}},set(){throw new TypeError("Env is read-only outside `context.actions.produce`. Mutate via produce(({ env }) => { env.x = ... }) instead.")}}),[e])}const
|
|
4
|
-
return e(
|
|
5
|
-
return e(L.Provider,{value:s,children:r})}const
|
|
6
|
-
return e(y,{children:/* @__PURE__ */e(T.Provider,{value:s,children:/* @__PURE__ */e(_,{initial:t??{},children:/* @__PURE__ */e(v,{children:/* @__PURE__ */e($,{tap:r,children:/* @__PURE__ */e(R,{children:o})})})})})})}const B=e=>"symbol"==typeof e;function F(e){return r.isString(e)||B(e)?e:(r.isObject(e)||r.isFunction(e))&&x.Action in e?e[x.Action]:e}function z(e){if(r.isString(e))return e.startsWith(P());if(B(e))return e.description?.startsWith(P())??!1;if(r.isObject(e)||r.isFunction(e)){if(x.Broadcast in e&&e[x.Broadcast])return!0;if(x.Action in e){const t=e[x.Action];return t.description?.startsWith(P())??!1}}return!1}function J(e){return r.isObject(e)&&x.Channel in e&&"channel"in e}function D(e){const t=F(e),n=B(t)?t.description??"":t;return n.startsWith(j())&&n.slice(j().length)||null}function H(e){if(r.isString(e))return e.startsWith(S());if(B(e))return e.description?.startsWith(S())??!1;if(r.isObject(e)||r.isFunction(e)){if(x.Multicast in e&&e[x.Multicast])return!0;if(x.Action in e){const t=e[x.Action];return t.description?.startsWith(S())??!1}}return!1}const I=(e="",t=M.Unicast)=>{const n=t===M.Broadcast?Symbol(P(e)):t===M.Multicast?Symbol(S(e)):Symbol(O(e)),r=function(t){return{[x.Action]:n,[x.Payload]:void 0,[x.Channel]:t,[x.Name]:e,channel:t}};return Object.defineProperty(r,x.Action,{value:n,enumerable:!1}),Object.defineProperty(r,x.Payload,{value:void 0,enumerable:!1}),Object.defineProperty(r,x.Name,{value:e,enumerable:!1}),t===M.Broadcast&&Object.defineProperty(r,x.Broadcast,{value:!0,enumerable:!1}),t===M.Multicast&&Object.defineProperty(r,x.Multicast,{value:!0,enumerable:!1}),r},G=Symbol(((e="")=>`march-hare/replay${e}`)());function K(e,t,...n){e instanceof p&&e.setCache(t,n[0]);const r=e.listeners(t);return 0===r.length?Promise.resolve():Promise.all(r.map(e=>Promise.resolve(e(...n)))).then(()=>{})}function V(e,t){for(const n of e.keys())if(D(n)===t)return n;return null}const q=/* @__PURE__ */Symbol("march-hare.unset");function Q(){const[,e]=n.useReducer(e=>e+1,0);return e}function X(){return{data:q,at:null}}function Y(e,t){return{data:e,at:t}}var Z=/* @__PURE__ */(e=>(e[e.Aborted=0]="Aborted",e[e.Errored=1]="Errored",e))(Z||{});class ee extends Error{name="AbortError";constructor(e="Aborted"){super(e)}}const te=n.createContext(null);function ne(e){const t=r.isUndefined(e)?function(){const e=/* @__PURE__ */new Map;return{get:t=>e.get(t)??null,set:(t,n)=>{e.set(t,n)},remove:t=>{e.delete(t)},clear:()=>{e.clear()},keys:()=>e.keys()}}():e,n=e?.key;return{get(e){try{const n=t.get(e);if(r.isNull(n))return X();const o=JSON.parse(n);return Y(o.data,Temporal.Instant.from(o.at))}catch{return X()}},set(e,n){if(n.data!==q&&!r.isNull(n.at))try{t.set(e,JSON.stringify({data:n.data,at:n.at.toString()}))}catch{return}},remove(e){try{t.remove(e)}catch{return}},clear(){try{t.clear()}catch{return}},keys(){try{return t.keys?.()??[]}catch{return[]}},scope(e){if(r.isUndefined(n)||r.isNullable(e))return"";try{const t=n({env:e});return r.isNullable(t)?"":t}catch{return""}}}}const re=/* @__PURE__ */new WeakMap,oe=/* @__PURE__ */new Map,se=[];function ce(e,t,n,o){const s=r.isNull(n)?"":`${n}:`,c=(e,n)=>{const r=t.scope(e);return`${""===r?"":`${r}:`}${s}${function(e){return JSON.stringify(e)}(n)}`},i=(e,n)=>{const o=t.get(c(n,e));return o.data===q||r.isNull(o.at)?{data:q,at:null}:{data:o.data,at:o.at}},a=(n,r,o,s)=>e({env:n,controller:r,params:o,dispatch:s}).then(e=>(t.set(c(n,o),Y(e,Temporal.Now.instant())),e)),u=e=>{const n=o(),r=t.scope(n),c=""===r?s:`${r}:${s}`,i=Object.entries(e);for(const o of[...t.keys()])if(o.startsWith(c))try{const e=JSON.parse(o.slice(c.length));i.every(([t,n])=>e[t]===n)&&t.remove(o)}catch{continue}};function l(e){return{run:a,read:e=>i(e,o()),evict:u,params:e??{}}}return se.push(u),Object.defineProperty(l,"get",{value:function(e){const{data:t}=i(e??{},o());return t===q?null:t},enumerable:!1}),l}function ie(e,t,n){const o=e,s=n??(()=>{});return r.isUndefined(t)?ce(o,function(e){const t=re.get(e);if(r.isNotNullable(t))return t;const n=ne();return re.set(e,n),n}(o),null,s):ce(o,t,function(e){const t=oe.get(e);if(r.isNotNullable(t))return t;const n=String(oe.size);return oe.set(e,n),n}(o),s)}const ae=/* @__PURE__ */Symbol("march-hare.coalesce/default");function ue(e,t){return new Promise((n,r)=>{if(t.aborted)return void r(t.reason);const o=()=>r(t.reason);t.addEventListener("abort",o,{once:!0}),e.then(e=>{t.removeEventListener("abort",o),n(e)},e=>{t.removeEventListener("abort",o),r(e)})})}let le=(e=21)=>{let t="",n=crypto.getRandomValues(new Uint8Array(e|=0));for(;e--;)t+="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict"[63&n[e]];return t};var fe=/* @__PURE__ */(e=>(e[e.Add=1]="Add",e[e.Remove=2]="Remove",e[e.Update=4]="Update",e[e.Move=8]="Move",e[e.Replace=16]="Replace",e[e.Sort=32]="Sort",e[e.Create=64]="Create",e[e.Fetch=128]="Fetch",e[e.Clone=256]="Clone",e[e.Archive=512]="Archive",e[e.Restore=1024]="Restore",e[e.Merge=2048]="Merge",e[e.Reorder=4096]="Reorder",e[e.Sync=8192]="Sync",e[e.Publish=16384]="Publish",e[e.Link=32768]="Link",e[e.Unlink=65536]="Unlink",e[e.Lock=131072]="Lock",e[e.Unlock=262144]="Unlock",e[e.Import=524288]="Import",e[e.Export=1048576]="Export",e[e.Transfer=2097152]="Transfer",e))(fe||{}),de=/* @__PURE__ */(e=>(e[e.Produce=0]="Produce",e[e.Hydrate=1]="Hydrate",e))(de||{}),pe=/* @__PURE__ */(e=>(e.Property="property",e.Process="process",e.Value="value",e.Operation="operation",e))(pe||{});class he{[s]=!0;static keys=new Set(Object.values(pe));property=null;process=null;value;operation;constructor(e,t){this.value=e,this.operation=t}assign(e,t){const n=new he(this.value,this.operation);return n.property=e,n.process=t,n}}class me{static immer=(()=>{c();const e=new i;return e.setAutoFreeze(!1),e})();static tag="κ";static id=le}const ye=/* @__PURE__ */Symbol("Box");function be(e,t){const n="string"==typeof t?""===t?[]:t.split("."):t;let r=e;for(const o of n){if(null==r)return;r=r[o]}return r}function ve(e){if(r.isNullable(e)||Oe(e))return e;if(r.isArray(e))return e.map(e=>ve(e));if(r.isObject(e)&&we(e)){const t=Object.entries(e).map(([e,t])=>[e,ve(t)]);return{...Object.fromEntries(t),[me.tag]:e[me.tag]??me.id()}}return e}function ge(e){if(Array.isArray(e))return e.filter(e=>me.tag in e).map(e=>e[me.tag]??"").join(",");const t=e[me.tag];if(t)return t;try{return JSON.stringify(e)}catch{return`[unserializable:${typeof e}]`}}function we(e){const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}function Oe(e){return r.isNullable(e)||r.isString(e)||r.isNumber(e)||r.isBoolean(e)||"symbol"==typeof e||"bigint"==typeof e}function Pe(e){return r.isObject(e)&&ye in e}function Se(e,t,n,o,s,c){return function i(a,u=t.path){if(a instanceof he){const t=be(n,u.join("."));if(Object.entries(a).filter(([e,t])=>!he.keys.has(e)&&t instanceof he).forEach(([e,t])=>i(t,u.concat(e))),Oe(a.value)){if(e===de.Hydrate)return a.value;const i=u.slice(0,-1),l=i.length>0?be(n,i.join(".")):n;return r.isNullable(l)||je(l,a,u.at(-1),o,s,c),t??a.value}if(e===de.Hydrate){const e=ve(i(a.value,u));return je(e,a,null,o,s,c),e}const l=t??ve(a.value);return je(l,a,null,o,s,c),r.isNullable(t)?l:(i(a.value,u),t)}if(r.isArray(a))return a.map((e,t)=>i(e,u.concat(t)));if(r.isObject(a)&&!we(a))return a;if(r.isObject(a)){const t=Object.entries(a).map(([e,t])=>[e,i(t,u.concat(e))]),n=Object.fromEntries(t);if(e===de.Hydrate){const e=ve(n);return Object.entries(a).forEach(([t,n])=>{n instanceof he&&Oe(n.value)&&je(e,n,t,o,s,c)}),e}return n}return a}(t.value)}function je(e,t,n,r,o,s){const c=s(e),i=o.get(c)??[];o.set(c,[t.assign(n,r),...i])}class xe{#e={};#t;#n=/* @__PURE__ */new Map;#r=/* @__PURE__ */new Set;#o=!1;constructor(e=ge){this.#t=e}static pk(){return le()}static"κ"=xe.pk;annotate(e,t){return new he(t,e)}"δ"=this.annotate;get model(){return this.#e}get inspect(){return function(e,t,n,s,c){function i(s){const c=s.at(-1),i=be(e(),s),a=s.slice(0,-1),u=o.isNotEmpty(a)?be(e(),a):e();return[...r.isObject(i)||r.isArray(i)?t.get(n(i))?.filter(e=>r.isNullable(e.property))??[]:[],...r.isObject(u)?t.get(n(u))?.filter(e=>e.property===c)??[]:[]]}return function t(n){return new Proxy(()=>{},{get:(r,a)=>"pending"===a?()=>!o.isEmpty(i(n)):"remaining"===a?()=>o.length(i(n)):"box"===a?()=>({value:be(e(),n),inspect:t(n),[ye]:!0}):"is"===a?e=>i(n).some(t=>0!==(t.operation&e)):"draft"===a?()=>o.head(i(n))?.value??be(e(),n):"settled"===a?()=>new Promise(t=>{if(o.isEmpty(i(n)))return t(be(e(),n));const r=()=>{o.isEmpty(i(n))&&(c(r),t(be(e(),n)))};s(r)}):t([...n,String(a)])})}([])}(()=>this.#e,this.#n,this.#t,e=>this.#r.add(e),e=>this.#r.delete(e))}hydrate(e){return this.#o=!0,this.#s(de.Hydrate,()=>e)}produce(e){if(!this.#o)throw new Error("State must be hydrated using hydrate() before calling produce()");return this.#s(de.Produce,e)}#s(e,t){const n=/* @__PURE__ */Symbol("process"),[,r]=me.immer.produceWithPatches(this.#e,t);return this.#e=r.reduce((t,r)=>me.immer.applyPatches(t,[{...r,value:Se(e,r,t,n,this.#n,this.#t)}]),this.#e),this.#e=ve(this.#e),this.#c(),n}prune(e){this.#n.forEach((t,n)=>{const r=t.filter(t=>t.process!==e);o.isEmpty(r)?this.#n.delete(n):this.#n.set(n,r)}),this.#c()}#c(){this.#r.forEach(e=>e())}observe(e){const t=()=>e(this.#e);return this.#r.add(t),()=>this.#r.delete(t)}}function Ee({action:e,renderer:t}){const o=m(),s=n.useContext(T),c=Q(),i=n.useMemo(()=>{const t=s.get(e);if(t)return t;const n=new xe,c=o.getCached(e);r.isNotNullable(c)&&n.hydrate({value:c});const i={state:n,listeners:/* @__PURE__ */new Set};return s.set(e,i),i},[e,o,s]);n.useLayoutEffect(()=>{function t(e){i.state.hydrate({value:e}),i.listeners.forEach(e=>e())}return i.listeners.add(c),o.on(e,t),()=>{i.listeners.delete(c),o.off(e,t)}},[e,o,i]);const a=i.state.model?.value;return r.isNullable(a)?null:t(a,i.state.inspect.value)}function ke(e,t){const n=t.split(".");let r=e;for(let o=0;o<n.length-1;o++)r=r[n[o]];return{cursor:r,key:n[n.length-1]}}function Ne(e,t,n){const{cursor:r,key:o}=ke(e,t);r[o]=n}function Ce(e){return(t,n)=>{t.actions.produce(t=>{Ne(t.model,e,n)})}}function Me(e){return t=>{t.actions.produce(t=>{!function(e,t){const{cursor:n,key:r}=ke(e,t);n[r]=!n[r]}(t.model,e)})}}function Ae(e,t){return n=>{n.actions.produce(n=>{Ne(n.model,e,t)})}}function _e(){const e=n.useRef(null);return n.useMemo(()=>({actions:{dispatch:function(t,n){const r=e.current;if(!r)throw new Error("march-hare: useContext handle dispatched before its paired context.useActions(...) ran. Call context.actions.dispatch from event handlers, not synchronously during render.");return r(t,n)}},useActions:function(...t){const s=function(...e){const t=r.isUndefined(e[0])||r.isFunction(e[0])?{}:e[0],s=r.isFunction(e[0])?e[0]:e[1]??(()=>({})),c=m(),i=n.useContext(te),u=n.useContext(b),l=w(),f=n.useContext(g),p=n.useContext(U),h=n.useContext(L),y=Q(),v=n.useRef(!1),P=n.useRef(null),S=n.useRef(new xe);v.current||(v.current=!0,P.current=S.current.hydrate(t));const[j,x]=n.useState(()=>S.current.model),E=function(e){const t=n.useRef(e);return t.current=e,n.useMemo(()=>{return n=t,Object.keys(e).reduce((e,t)=>(Object.defineProperty(e,t,{get:()=>n.current[t],enumerable:!0}),e),{});var n},[e])}(s()),C=n.useMemo(()=>new d,[]),M=n.useRef({handlers:/* @__PURE__ */new Map});M.current.handlers=/* @__PURE__ */new Map;const _=function(){const e=n.useRef(/* @__PURE__ */new Set),t=n.useRef(/* @__PURE__ */new Set);return n.useMemo(()=>({broadcast:e.current,multicast:t.current}),[])}(),R=n.useRef(A.Mounting),$=n.useRef(/* @__PURE__ */new Set),T=n.useRef(0),W=n.useCallback((e,t,n)=>{const o=new AbortController,s={controller:o,action:e,payload:t};return u.add(s),$.current.add(s),{model:S.current.model,get phase(){return R.current},task:s,data:E,tasks:u,env:l,actions:{produce(e){if(o.signal.aborted)return;const t=f.current,r=S.current.produce(t=>{f.current=a(f.current,n=>{e({model:t,inspect:S.current.inspect,env:n})})});x(S.current.model),f.current!==t&&c.emit(N,f.current),n.processes.add(r),P.current&&(n.processes.add(P.current),P.current=null)},dispatch(e,t){if(o.signal.aborted)return Promise.resolve();const n=F(e),r=J(e)?e.channel:void 0;return H(e)?i?K(i.emitter,n,t,r):Promise.resolve():K(z(e)?c:C,n,t,r)},annotate:(e,t=fe.Update)=>S.current.annotate(t,e),get inspect(){return S.current.inspect},resource:Object.assign(function(e){const t=(e,t)=>{if(o.signal.aborted)return Promise.resolve();const n=e,r=F(n);return H(n)?i?K(i.emitter,r,t,void 0):Promise.resolve():z(n)?K(c,r,t,void 0):Promise.resolve()},n={exceedsWindow:null,coalesceToken:void 0},s={then:(s,c)=>(()=>{if(r.isNotNullable(n.exceedsWindow)){const{data:t,at:o}=e.read(e.params);if(t!==q&&r.isNotNullable(o)){const e=Temporal.Now.instant().since(o),r=Temporal.Duration.from(n.exceedsWindow);if(Temporal.Duration.compare(e,r)<=0)return Promise.resolve(t)}}if(r.isUndefined(n.coalesceToken))return e.run(l,o,e.params,t);let s=p.get(e.run);r.isUndefined(s)&&(s=/* @__PURE__ */new Map,p.set(e.run,s));const c=s,i=`${JSON.stringify(e.params)}|${function(e){switch(typeof e){case"string":return`s:${e}`;case"number":return`n:${e}`;case"bigint":return`i:${e.toString()}`;case"boolean":return`b:${e}`;case"symbol":return`y:${e.description??String(e)}`;default:return`o:${JSON.stringify(e)}`}}(n.coalesceToken)}`,a=c.get(i);if(a)return ue(a,o.signal);const u=new AbortController,f=e.run(l,u,e.params,t).finally(()=>{c.delete(i)});return c.set(i,f),ue(f,o.signal)})().then(s,c),exceeds:e=>(n.exceedsWindow=e,s),coalesce:e=>(n.coalesceToken=e??ae,s),evict(t){e.evict(t??e.params)}};return s},{nuke:e=>function(e){const t=e??{};for(const n of se)n(t)}(e)}),async final(e){if(o.signal.aborted)return null;const t=F(e),n=H(e)?i?.emitter??null:c;if(!n)return null;const s=n.getCached(t);if(r.isUndefined(s))return null;const a=S.current.inspect;return a.pending()&&await new Promise((e,t)=>{if(o.signal.aborted)return void t(o.signal.reason);const n=()=>t(o.signal.reason);o.signal.addEventListener("abort",n,{once:!0}),a.settled().then(()=>{o.signal.removeEventListener("abort",n),e()})}),n.getCached(t)??null},peek(e){if(o.signal.aborted)return null;const t=F(e),n=H(e)?i?.emitter??null:c;return n?n.getCached(t)??null:null}}}},[j]);n.useLayoutEffect(()=>{function e(e,t,n){return function(o,s){const a=n();if(s===G&&r.isNotNullable(a))return;if(r.isNotNullable(s)&&s!==G&&r.isNotNullable(a)&&!function(e,t){for(const n of Object.keys(e))if(t[n]!==e[n])return!1;return!0}(s,a))return;const l={processes:/* @__PURE__ */new Set},d=Promise.withResolvers(),p=W(e,o,l),m=function(e){const t=F(e),n=r.isString(t)?t:t.description??"";return n.startsWith(O())&&n.slice(n.lastIndexOf("/")+1)||"unknown"}(e),b=performance.now(),v=S.current.model,g=f.current;let w,P=!1;function j(){const e=S.current.model,t=f.current;return{model:v===e?null:{before:v,after:e},env:g===t?null:{before:g,after:t}}}function x(){const t=s===G?void 0:s;return H(e)?i?K(i.emitter,e,o,t):Promise.resolve():K(z(e)?c:C,e,o,t)}function E(e){P=!0;const t=V(M.current.handlers,"Error"),n=r.isNotNullable(t),s=function(e){return e instanceof Error&&"AbortError"===e.name?Z.Aborted:Z.Errored}(e),i=function(e){return e instanceof Error?e:new Error(String(e))}(e),a={reason:s,error:i,action:m,handled:n,tasks:u,retry:x};c.fire(k,a),n&&t&&C.emit(t,a),h({stage:"end",result:"error",action:{name:m,payload:o},details:{task:p.task,elapsed:performance.now()-b,mutations:j(),error:i,reason:s}})}function N(){for(const e of u)if(e===p.task){u.delete(e),$.current.delete(e);break}l.processes.forEach(e=>S.current.prune(e)),l.processes.size>0&&y(),P||h({stage:"end",result:"success",action:{name:m,payload:o},details:{task:p.task,elapsed:performance.now()-b,mutations:j()}}),d.resolve()}h({stage:"start",action:{name:m,payload:o},details:{task:p.task}});try{w=t(p,o)}catch(A){return E(A),N(),d.promise}return function(e){if(!e||"object"!=typeof e)return!1;const t=Object.prototype.toString.call(e);return"[object Generator]"===t||"[object AsyncGenerator]"===t}(w)?((async()=>{for await(const e of w);})().catch(E).finally(N),d.promise):(Promise.resolve(w).catch(E).finally(N),d.promise)}}T.current++;const t=/* @__PURE__ */new Set;return M.current.handlers.forEach((n,r)=>{for(const{getChannel:o,handler:s}of n){const n=e(r,s,o);if(H(r)){if(i){const e=i.emitter;e.on(r,n),t.add(()=>e.off(r,n))}C.on(r,n),_.multicast.add(r),t.add(()=>C.off(r,n))}else z(r)?(c.on(r,n),C.on(r,n),_.broadcast.add(r),t.add(()=>{c.off(r,n),C.off(r,n)})):(C.on(r,n),t.add(()=>C.off(r,n)))}}),()=>{const e=++T.current,n=new Set(t);queueMicrotask(()=>{if(T.current!==e){for(const e of n)e();return}for(const e of $.current)e.controller.abort(new ee("Component unmounted")),u.delete(e);$.current.clear(),R.current=A.Unmounting;const t=V(M.current.handlers,"Unmount");t&&C.emit(t),R.current=A.Unmounted;for(const e of n)e()})}},[C]),function({unicast:e,broadcast:t,dispatchers:s,scope:c,phase:i,data:a,handlers:u}){const l=n.useRef(null);n.useLayoutEffect(()=>{if(i.current===A.Mounted)return;i.current=A.Mounting;const n=V(u,"Mount");n&&e.emit(n),s.broadcast.forEach(n=>{const o=t.getCached(n);r.isNullable(o)||e.emit(n,o,G)}),c&&s.multicast.forEach(t=>{const n=c.emitter.getCached(t);r.isNullable(n)||e.emit(t,n,G)}),i.current=A.Mounted},[]),n.useLayoutEffect(()=>{if(r.isNotNullable(l.current)){const t=function(e,t){return Object.keys(t).reduce((n,r)=>e[r]!==t[r]?{...n,[r]:t[r]}:n,{})}(l.current,a);if(o.isNotEmpty(Object.keys(t))){const n=V(u,"Update");n&&e.emit(n,t)}}l.current=a},[a,e])}({unicast:C,broadcast:c,dispatchers:_,scope:i,phase:R,data:s(),handlers:M.current.handlers});const B=n.useMemo(()=>({dispatch(e,t){const n=F(e),r=J(e)?e.channel:void 0;return H(e)?i?K(i.emitter,n,t,r):Promise.resolve():K(z(e)?c:C,n,t,r)},get inspect(){return S.current.inspect},stream:(e,t)=>n.createElement(Ee,{action:F(e),renderer:t})}),[j,C]),D=n.useMemo(()=>[j,B,E],[j,B,E]);return D.useAction=(e,t)=>{!function(e,t,r){const o=n.useRef(r);n.useLayoutEffect(()=>{o.current=r});const s=n.useRef(t);n.useLayoutEffect(()=>{s.current=t});const c=n.useCallback((e,t)=>o.current(e,t),[]),i=n.useCallback(()=>J(s.current)?s.current.channel:void 0,[]),a=F(t),u=e.current.handlers.get(a)??/* @__PURE__ */new Set;0===u.size&&e.current.handlers.set(a,u),u.add({getChannel:i,handler:c})}(M,e,t)},D.dispatch=D[1].dispatch,D}(...t);return e.current=s.dispatch,s},with:{update:e=>Ce(e),invert:e=>Me(e),always:(e,t)=>Ae(e,t)}}),[])}function Ue(t,r){return{Boundary:function({children:t}){const r=n.useMemo(()=>({id:/* @__PURE__ */Symbol("march-hare.scope/instance"),emitter:new p}),[]);/* @__PURE__ */
|
|
7
|
-
return e(te.Provider,{value:r,children:t})},useContext:function(){return
|
|
8
|
-
return t(
|
|
9
|
-
/* @__PURE__ */e(
|
|
3
|
+
return e(b.Provider,{value:r,children:t})}const g=n.createContext({current:{}});function w(){const e=n.useContext(g);return n.useMemo(()=>new Proxy({},{get:(t,n)=>Reflect.get(e.current,n),has:(t,n)=>n in e.current,ownKeys:()=>Reflect.ownKeys(e.current),getOwnPropertyDescriptor(t,n){const o=Object.getOwnPropertyDescriptor(e.current,n);if(!r.isUndefined(o))return{...o,configurable:!0}},set(){throw new TypeError("Env is read-only outside `context.actions.produce`. Mutate via produce(({ env }) => { env.x = ... }) instead.")}}),[e])}const P=(e="")=>`march-hare.action/${e}`,O=(e="")=>`march-hare.action/broadcast/${e}`,j=(e="")=>`march-hare.action/multicast/${e}`,S=(e="")=>`march-hare.action.lifecycle/${e}`;class E{static Payload=/* @__PURE__ */Symbol("march-hare.brand/Payload");static Broadcast=/* @__PURE__ */Symbol("march-hare.brand/Broadcast");static Multicast=/* @__PURE__ */Symbol("march-hare.brand/Multicast");static Action=/* @__PURE__ */Symbol("march-hare.brand/Action");static Channel=/* @__PURE__ */Symbol("march-hare.brand/Channel");static Name=/* @__PURE__ */Symbol("march-hare.brand/Name");static Lifecycle=/* @__PURE__ */Symbol("march-hare.brand/Lifecycle")}function x(e){const t=/* @__PURE__ */Symbol(`march-hare.action.lifecycle/${e}`),n=function(n){return{[E.Action]:t,[E.Payload]:void 0,[E.Channel]:n,[E.Name]:e,channel:n}};return Object.defineProperty(n,E.Action,{value:t,enumerable:!1}),Object.defineProperty(n,E.Payload,{value:void 0,enumerable:!1}),Object.defineProperty(n,E.Name,{value:e,enumerable:!1}),Object.defineProperty(n,E.Lifecycle,{value:e,enumerable:!1}),n}const C=Symbol(O("Fault")),N=Symbol(O("Env"));class k{static Mount(){return x("Mount")}static Paint(){return x("Paint")}static Unmount(){return x("Unmount")}static Error(){return x("Error")}static Update(){return x("Update")}static Fault=(()=>{const e={};return Object.defineProperty(e,E.Action,{value:C,enumerable:!1}),Object.defineProperty(e,E.Payload,{value:void 0,enumerable:!1}),Object.defineProperty(e,E.Broadcast,{value:!0,enumerable:!1}),Object.defineProperty(e,E.Name,{value:"Fault",enumerable:!1}),e})();static Env=(()=>{const e={};return Object.defineProperty(e,E.Action,{value:N,enumerable:!1}),Object.defineProperty(e,E.Payload,{value:void 0,enumerable:!1}),Object.defineProperty(e,E.Broadcast,{value:!0,enumerable:!1}),Object.defineProperty(e,E.Name,{value:"Env",enumerable:!1}),e})()}var M=/* @__PURE__ */(e=>(e.Unicast="unicast",e.Broadcast="broadcast",e.Multicast="multicast",e))(M||{}),A=/* @__PURE__ */(e=>(e.Mounting="mounting",e.Mounted="mounted",e.Unmounting="unmounting",e.Unmounted="unmounted",e))(A||{});function _({initial:t,children:o}){const s=n.useRef(t),c=m();return r.isUndefined(c.getCached(N))&&c.setCache(N,s.current),/* @__PURE__ */e(g.Provider,{value:s,children:o})}const R=n.createContext(/* @__PURE__ */new WeakMap);function U({children:t}){const r=n.useMemo(()=>/* @__PURE__ */new WeakMap,[]);/* @__PURE__ */
|
|
4
|
+
return e(R.Provider,{value:r,children:t})}const L=n.createContext(()=>{});function W({tap:t,children:r}){const o=n.useRef(t);n.useLayoutEffect(()=>{o.current=t},[t]);const s=n.useMemo(()=>e=>o.current?.(e),[]);/* @__PURE__ */
|
|
5
|
+
return e(L.Provider,{value:s,children:r})}const B=n.createContext(/* @__PURE__ */new Map);function $({env:t,tap:r,children:o}){const s=n.useMemo(()=>/* @__PURE__ */new Map,[]);/* @__PURE__ */
|
|
6
|
+
return e(y,{children:/* @__PURE__ */e(B.Provider,{value:s,children:/* @__PURE__ */e(_,{initial:t??{},children:/* @__PURE__ */e(v,{children:/* @__PURE__ */e(W,{tap:r,children:/* @__PURE__ */e(U,{children:o})})})})})})}const T=e=>"symbol"==typeof e;function F(e){return r.isString(e)||T(e)?e:(r.isObject(e)||r.isFunction(e))&&E.Action in e?e[E.Action]:e}function z(e){if(r.isString(e))return e.startsWith(O());if(T(e))return e.description?.startsWith(O())??!1;if(r.isObject(e)||r.isFunction(e)){if(E.Broadcast in e&&e[E.Broadcast])return!0;if(E.Action in e){const t=e[E.Action];return t.description?.startsWith(O())??!1}}return!1}function D(e){return r.isObject(e)&&E.Channel in e&&"channel"in e}function H(e){const t=F(e),n=T(t)?t.description??"":t;return n.startsWith(S())&&n.slice(S().length)||null}function I(e){if(r.isString(e))return e.startsWith(j());if(T(e))return e.description?.startsWith(j())??!1;if(r.isObject(e)||r.isFunction(e)){if(E.Multicast in e&&e[E.Multicast])return!0;if(E.Action in e){const t=e[E.Action];return t.description?.startsWith(j())??!1}}return!1}const J=(e="",t=M.Unicast)=>{const n=t===M.Broadcast?Symbol(O(e)):t===M.Multicast?Symbol(j(e)):Symbol(P(e)),r=function(t){return{[E.Action]:n,[E.Payload]:void 0,[E.Channel]:t,[E.Name]:e,channel:t}};return Object.defineProperty(r,E.Action,{value:n,enumerable:!1}),Object.defineProperty(r,E.Payload,{value:void 0,enumerable:!1}),Object.defineProperty(r,E.Name,{value:e,enumerable:!1}),t===M.Broadcast&&Object.defineProperty(r,E.Broadcast,{value:!0,enumerable:!1}),t===M.Multicast&&Object.defineProperty(r,E.Multicast,{value:!0,enumerable:!1}),r},G=Symbol(((e="")=>`march-hare/replay${e}`)());function K(e,t,...n){e instanceof p&&e.setCache(t,n[0]);const r=e.listeners(t);return 0===r.length?Promise.resolve():Promise.all(r.map(e=>Promise.resolve(e(...n)))).then(()=>{})}function V(e,t){for(const n of e.keys())if(H(n)===t)return n;return null}const q=/* @__PURE__ */Symbol("march-hare.unset");function Q(){const[,e]=n.useReducer(e=>e+1,0);return e}function X(){return{data:q,at:null}}function Y(e,t){return{data:e,at:t}}var Z=/* @__PURE__ */(e=>(e[e.Aborted=0]="Aborted",e[e.Errored=1]="Errored",e))(Z||{});class ee extends Error{name="AbortError";constructor(e="Aborted"){super(e)}}const te=n.createContext(null);function ne(e){const t=r.isUndefined(e)?function(){const e=/* @__PURE__ */new Map;return{get:t=>e.get(t)??null,set:(t,n)=>{e.set(t,n)},remove:t=>{e.delete(t)},clear:()=>{e.clear()},keys:()=>e.keys()}}():e,n=e?.key;return{get(e){try{const n=t.get(e);if(r.isNull(n))return X();const o=JSON.parse(n);return Y(o.data,Temporal.Instant.from(o.at))}catch{return X()}},set(e,n){if(n.data!==q&&!r.isNull(n.at))try{t.set(e,JSON.stringify({data:n.data,at:n.at.toString()}))}catch{return}},remove(e){try{t.remove(e)}catch{return}},clear(){try{t.clear()}catch{return}},keys(){try{return t.keys?.()??[]}catch{return[]}},scope(e){if(r.isUndefined(n)||r.isNullable(e))return"";try{const t=n({env:e});return r.isNullable(t)?"":t}catch{return""}}}}const re=/* @__PURE__ */new WeakMap,oe=/* @__PURE__ */new Map,se=[];function ce(e,t,n,o){const s=r.isNull(n)?"":`${n}:`,c=(e,n)=>{const r=t.scope(e);return`${""===r?"":`${r}:`}${s}${function(e){return JSON.stringify(e)}(n)}`},i=(e,n)=>{const o=t.get(c(n,e));return o.data===q||r.isNull(o.at)?{data:q,at:null}:{data:o.data,at:o.at}},a=(n,r,o,s)=>e({env:n,controller:r,params:o,dispatch:s}).then(e=>(t.set(c(n,o),Y(e,Temporal.Now.instant())),e)),u=e=>{const n=o(),r=t.scope(n),c=""===r?s:`${r}:${s}`,i=Object.entries(e);for(const o of[...t.keys()])if(o.startsWith(c))try{const e=JSON.parse(o.slice(c.length));i.every(([t,n])=>e[t]===n)&&t.remove(o)}catch{continue}};function l(e){return{run:a,read:e=>i(e,o()),evict:u,params:e??{}}}return se.push(u),Object.defineProperty(l,"get",{value:function(e){const{data:t}=i(e??{},o());return t===q?null:t},enumerable:!1}),l}function ie(e,t,n){const o=e,s=n??(()=>{});return r.isUndefined(t)?ce(o,function(e){const t=re.get(e);if(r.isNotNullable(t))return t;const n=ne();return re.set(e,n),n}(o),null,s):ce(o,t,function(e){const t=oe.get(e);if(r.isNotNullable(t))return t;const n=String(oe.size);return oe.set(e,n),n}(o),s)}let ae=(e=21)=>{let t="",n=crypto.getRandomValues(new Uint8Array(e|=0));for(;e--;)t+="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict"[63&n[e]];return t};var ue=/* @__PURE__ */(e=>(e[e.Add=1]="Add",e[e.Remove=2]="Remove",e[e.Update=4]="Update",e[e.Move=8]="Move",e[e.Replace=16]="Replace",e[e.Sort=32]="Sort",e[e.Create=64]="Create",e[e.Fetch=128]="Fetch",e[e.Clone=256]="Clone",e[e.Archive=512]="Archive",e[e.Restore=1024]="Restore",e[e.Merge=2048]="Merge",e[e.Reorder=4096]="Reorder",e[e.Sync=8192]="Sync",e[e.Publish=16384]="Publish",e[e.Link=32768]="Link",e[e.Unlink=65536]="Unlink",e[e.Lock=131072]="Lock",e[e.Unlock=262144]="Unlock",e[e.Import=524288]="Import",e[e.Export=1048576]="Export",e[e.Transfer=2097152]="Transfer",e))(ue||{}),le=/* @__PURE__ */(e=>(e[e.Produce=0]="Produce",e[e.Hydrate=1]="Hydrate",e))(le||{}),fe=/* @__PURE__ */(e=>(e.Property="property",e.Process="process",e.Value="value",e.Operation="operation",e))(fe||{});class de{[s]=!0;static keys=new Set(Object.values(fe));property=null;process=null;value;operation;constructor(e,t){this.value=e,this.operation=t}assign(e,t){const n=new de(this.value,this.operation);return n.property=e,n.process=t,n}}class pe{static immer=(()=>{c();const e=new i;return e.setAutoFreeze(!1),e})();static tag="κ";static id=ae}const he=/* @__PURE__ */Symbol("Box");function me(e,t){const n="string"==typeof t?""===t?[]:t.split("."):t;let r=e;for(const o of n){if(null==r)return;r=r[o]}return r}function ye(e){if(r.isNullable(e)||ge(e))return e;if(r.isArray(e))return e.map(e=>ye(e));if(r.isObject(e)&&ve(e)){const t=Object.entries(e).map(([e,t])=>[e,ye(t)]);return{...Object.fromEntries(t),[pe.tag]:e[pe.tag]??pe.id()}}return e}function be(e){if(Array.isArray(e))return e.filter(e=>pe.tag in e).map(e=>e[pe.tag]??"").join(",");const t=e[pe.tag];if(t)return t;try{return JSON.stringify(e)}catch{return`[unserializable:${typeof e}]`}}function ve(e){const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}function ge(e){return r.isNullable(e)||r.isString(e)||r.isNumber(e)||r.isBoolean(e)||"symbol"==typeof e||"bigint"==typeof e}function we(e){return r.isObject(e)&&he in e}function Pe(e,t,n,o,s,c){return function i(a,u=t.path){if(a instanceof de){const t=me(n,u.join("."));if(Object.entries(a).filter(([e,t])=>!de.keys.has(e)&&t instanceof de).forEach(([e,t])=>i(t,u.concat(e))),ge(a.value)){if(e===le.Hydrate)return a.value;const i=u.slice(0,-1),l=i.length>0?me(n,i.join(".")):n;return r.isNullable(l)||Oe(l,a,u.at(-1),o,s,c),t??a.value}if(e===le.Hydrate){const e=ye(i(a.value,u));return Oe(e,a,null,o,s,c),e}const l=t??ye(a.value);return Oe(l,a,null,o,s,c),r.isNullable(t)?l:(i(a.value,u),t)}if(r.isArray(a))return a.map((e,t)=>i(e,u.concat(t)));if(r.isObject(a)&&!ve(a))return a;if(r.isObject(a)){const t=Object.entries(a).map(([e,t])=>[e,i(t,u.concat(e))]),n=Object.fromEntries(t);if(e===le.Hydrate){const e=ye(n);return Object.entries(a).forEach(([t,n])=>{n instanceof de&&ge(n.value)&&Oe(e,n,t,o,s,c)}),e}return n}return a}(t.value)}function Oe(e,t,n,r,o,s){const c=s(e),i=o.get(c)??[];o.set(c,[t.assign(n,r),...i])}class je{#e={};#t;#n=/* @__PURE__ */new Map;#r=/* @__PURE__ */new Set;#o=!1;constructor(e=be){this.#t=e}static pk(){return ae()}static"κ"=je.pk;annotate(e,t){return new de(t,e)}"δ"=this.annotate;get model(){return this.#e}get inspect(){return function(e,t,n,s,c){function i(s){const c=s.at(-1),i=me(e(),s),a=s.slice(0,-1),u=o.isNotEmpty(a)?me(e(),a):e();return[...r.isObject(i)||r.isArray(i)?t.get(n(i))?.filter(e=>r.isNullable(e.property))??[]:[],...r.isObject(u)?t.get(n(u))?.filter(e=>e.property===c)??[]:[]]}return function t(n){return new Proxy(()=>{},{get:(r,a)=>"pending"===a?()=>!o.isEmpty(i(n)):"remaining"===a?()=>o.length(i(n)):"box"===a?()=>({value:me(e(),n),inspect:t(n),[he]:!0}):"is"===a?e=>i(n).some(t=>0!==(t.operation&e)):"draft"===a?()=>o.head(i(n))?.value??me(e(),n):"settled"===a?()=>new Promise(t=>{if(o.isEmpty(i(n)))return t(me(e(),n));const r=()=>{o.isEmpty(i(n))&&(c(r),t(me(e(),n)))};s(r)}):t([...n,String(a)])})}([])}(()=>this.#e,this.#n,this.#t,e=>this.#r.add(e),e=>this.#r.delete(e))}hydrate(e){return this.#o=!0,this.#s(le.Hydrate,()=>e)}produce(e){if(!this.#o)throw new Error("State must be hydrated using hydrate() before calling produce()");return this.#s(le.Produce,e)}#s(e,t){const n=/* @__PURE__ */Symbol("process"),[,r]=pe.immer.produceWithPatches(this.#e,t);return this.#e=r.reduce((t,r)=>pe.immer.applyPatches(t,[{...r,value:Pe(e,r,t,n,this.#n,this.#t)}]),this.#e),this.#e=ye(this.#e),this.#c(),n}prune(e){this.#n.forEach((t,n)=>{const r=t.filter(t=>t.process!==e);o.isEmpty(r)?this.#n.delete(n):this.#n.set(n,r)}),this.#c()}#c(){this.#r.forEach(e=>e())}observe(e){const t=()=>e(this.#e);return this.#r.add(t),()=>this.#r.delete(t)}}function Se({action:e,renderer:t}){const o=m(),s=n.useContext(B),c=Q(),i=n.useMemo(()=>{const t=s.get(e);if(t)return t;const n=new je,c=o.getCached(e);r.isNotNullable(c)&&n.hydrate({value:c});const i={state:n,listeners:/* @__PURE__ */new Set};return s.set(e,i),i},[e,o,s]);n.useLayoutEffect(()=>{function t(e){i.state.hydrate({value:e}),i.listeners.forEach(e=>e())}return i.listeners.add(c),o.on(e,t),()=>{i.listeners.delete(c),o.off(e,t)}},[e,o,i]);const a=i.state.model?.value;return r.isNullable(a)?null:t(a,i.state.inspect.value)}function Ee(e,t){const n=t.split(".");let r=e;for(let o=0;o<n.length-1;o++)r=r[n[o]];return{cursor:r,key:n[n.length-1]}}function xe(e,t,n){const{cursor:r,key:o}=Ee(e,t);r[o]=n}function Ce(e){return(t,n)=>{t.actions.produce(t=>{xe(t.model,e,n)})}}function Ne(e){return t=>{t.actions.produce(t=>{!function(e,t){const{cursor:n,key:r}=Ee(e,t);n[r]=!n[r]}(t.model,e)})}}function ke(e,t){return n=>{n.actions.produce(n=>{xe(n.model,e,t)})}}function Me(){const e=n.useRef(null);return n.useMemo(()=>({actions:{dispatch:function(t,n){const r=e.current;if(!r)throw new Error("march-hare: useContext handle dispatched before its paired context.useActions(...) ran. Call context.actions.dispatch from event handlers, not synchronously during render.");return r(t,n)}},useActions:function(...t){const s=function(...e){const t=r.isUndefined(e[0])||r.isFunction(e[0])?{}:e[0],s=r.isFunction(e[0])?e[0]:e[1]??(()=>({})),c=m(),i=n.useContext(te),u=n.useContext(b),l=w(),f=n.useContext(g),p=n.useContext(R),h=n.useContext(L),y=Q(),v=n.useRef(!1),O=n.useRef(null),j=n.useRef(new je);v.current||(v.current=!0,O.current=j.current.hydrate(t));const[S,E]=n.useState(()=>j.current.model),x=function(e){const t=n.useRef(e);return t.current=e,n.useMemo(()=>{return n=t,Object.keys(e).reduce((e,t)=>(Object.defineProperty(e,t,{get:()=>n.current[t],enumerable:!0}),e),{});var n},[e])}(s()),k=n.useMemo(()=>new d,[]),M=n.useRef({handlers:/* @__PURE__ */new Map});M.current.handlers=/* @__PURE__ */new Map;const _=function(){const e=n.useRef(/* @__PURE__ */new Set),t=n.useRef(/* @__PURE__ */new Set);return n.useMemo(()=>({broadcast:e.current,multicast:t.current}),[])}(),U=n.useRef(A.Mounting),W=n.useRef(/* @__PURE__ */new Set),B=n.useRef(0),$=n.useCallback((e,t,n)=>{const o=new AbortController,s={controller:o,action:e,payload:t};return u.add(s),W.current.add(s),{model:j.current.model,get phase(){return U.current},task:s,data:x,tasks:u,env:l,actions:{produce(e){if(o.signal.aborted)return;const t=f.current,r=j.current.produce(t=>{f.current=a(f.current,n=>{e({model:t,inspect:j.current.inspect,env:n})})});E(j.current.model),f.current!==t&&c.emit(N,f.current),n.processes.add(r),O.current&&(n.processes.add(O.current),O.current=null)},dispatch(e,t){if(o.signal.aborted)return Promise.resolve();const n=F(e),r=D(e)?e.channel:void 0;return I(e)?i?K(i.emitter,n,t,r):Promise.resolve():K(z(e)?c:k,n,t,r)},annotate:(e,t=ue.Update)=>j.current.annotate(t,e),get inspect(){return j.current.inspect},resource:Object.assign(function(e){const t=(e,t)=>{if(o.signal.aborted)return Promise.resolve();const n=e,r=F(n);return I(n)?i?K(i.emitter,r,t,void 0):Promise.resolve():z(n)?K(c,r,t,void 0):Promise.resolve()},n={exceedsWindow:null,isolated:!1},s={then:(s,c)=>(()=>{if(r.isNotNullable(n.exceedsWindow)){const{data:t,at:o}=e.read(e.params);if(t!==q&&r.isNotNullable(o)){const e=Temporal.Now.instant().since(o),r=Temporal.Duration.from(n.exceedsWindow);if(Temporal.Duration.compare(e,r)<=0)return Promise.resolve(t)}}if(n.isolated)return e.run(l,o,e.params,t);let s=p.get(e.run);r.isUndefined(s)&&(s=/* @__PURE__ */new Map,p.set(e.run,s));const c=s,i=JSON.stringify(e.params);let a=c.get(i);if(r.isUndefined(a)){const n=new AbortController,r={controller:n,refs:0};r.promise=e.run(l,n,e.params,t).finally(()=>{c.delete(i)}),c.set(i,r),a=r}const u=a;u.refs+=1;const f=()=>{u.refs-=1,0===u.refs&&(c.delete(i),u.controller.abort(o.signal.reason))};if(o.signal.aborted)f();else{o.signal.addEventListener("abort",f,{once:!0});const e=()=>o.signal.removeEventListener("abort",f);u.promise.then(e,e)}return d=u.promise,h=o.signal,new Promise((e,t)=>{if(h.aborted)return void t(h.reason);const n=()=>t(h.reason);h.addEventListener("abort",n,{once:!0}),d.then(t=>{h.removeEventListener("abort",n),e(t)},e=>{h.removeEventListener("abort",n),t(e)})});var d,h})().then(s,c),exceeds:e=>(n.exceedsWindow=e,s),isolated:()=>(n.isolated=!0,s),evict(t){e.evict(t??e.params)}};return s},{nuke:e=>function(e){const t=e??{};for(const n of se)n(t)}(e)}),async final(e){if(o.signal.aborted)return null;const t=F(e),n=I(e)?i?.emitter??null:c;if(!n)return null;const s=n.getCached(t);if(r.isUndefined(s))return null;const a=j.current.inspect;return a.pending()&&await new Promise((e,t)=>{if(o.signal.aborted)return void t(o.signal.reason);const n=()=>t(o.signal.reason);o.signal.addEventListener("abort",n,{once:!0}),a.settled().then(()=>{o.signal.removeEventListener("abort",n),e()})}),n.getCached(t)??null},peek(e){if(o.signal.aborted)return null;const t=F(e),n=I(e)?i?.emitter??null:c;return n?n.getCached(t)??null:null}}}},[S]);n.useLayoutEffect(()=>{function e(e,t,n){return function(o,s){const a=n();if(s===G&&r.isNotNullable(a))return;if(r.isNotNullable(s)&&s!==G&&r.isNotNullable(a)&&!function(e,t){for(const n of Object.keys(e))if(t[n]!==e[n])return!1;return!0}(s,a))return;const l={processes:/* @__PURE__ */new Set},d=Promise.withResolvers(),p=$(e,o,l),m=function(e){const t=F(e),n=r.isString(t)?t:t.description??"";return n.startsWith(P())&&n.slice(n.lastIndexOf("/")+1)||"unknown"}(e),b=performance.now(),v=j.current.model,g=f.current;let w,O=!1;function S(){const e=j.current.model,t=f.current;return{model:v===e?null:{before:v,after:e},env:g===t?null:{before:g,after:t}}}function E(){const t=s===G?void 0:s;return I(e)?i?K(i.emitter,e,o,t):Promise.resolve():K(z(e)?c:k,e,o,t)}function x(e){O=!0;const t=V(M.current.handlers,"Error"),n=r.isNotNullable(t),s=function(e){return e instanceof Error&&"AbortError"===e.name?Z.Aborted:Z.Errored}(e),i=function(e){return e instanceof Error?e:new Error(String(e))}(e),a={reason:s,error:i,action:m,handled:n,tasks:u,retry:E};c.fire(C,a),n&&t&&k.emit(t,a),h({stage:"end",result:"error",action:{name:m,payload:o},details:{task:p.task,elapsed:performance.now()-b,mutations:S(),error:i,reason:s}})}function N(){for(const e of u)if(e===p.task){u.delete(e),W.current.delete(e);break}l.processes.forEach(e=>j.current.prune(e)),l.processes.size>0&&y(),O||h({stage:"end",result:"success",action:{name:m,payload:o},details:{task:p.task,elapsed:performance.now()-b,mutations:S()}}),d.resolve()}h({stage:"start",action:{name:m,payload:o},details:{task:p.task}});try{w=t(p,o)}catch(A){return x(A),N(),d.promise}return function(e){if(!e||"object"!=typeof e)return!1;const t=Object.prototype.toString.call(e);return"[object Generator]"===t||"[object AsyncGenerator]"===t}(w)?((async()=>{for await(const e of w);})().catch(x).finally(N),d.promise):(Promise.resolve(w).catch(x).finally(N),d.promise)}}B.current++;const t=/* @__PURE__ */new Set;return M.current.handlers.forEach((n,r)=>{for(const{getChannel:o,handler:s}of n){const n=e(r,s,o);if(I(r)){if(i){const e=i.emitter;e.on(r,n),t.add(()=>e.off(r,n))}k.on(r,n),_.multicast.add(r),t.add(()=>k.off(r,n))}else z(r)?(c.on(r,n),k.on(r,n),_.broadcast.add(r),t.add(()=>{c.off(r,n),k.off(r,n)})):(k.on(r,n),t.add(()=>k.off(r,n)))}}),()=>{const e=++B.current,n=new Set(t);queueMicrotask(()=>{if(B.current!==e){for(const e of n)e();return}for(const e of W.current)e.controller.abort(new ee("Component unmounted")),u.delete(e);W.current.clear(),U.current=A.Unmounting;const t=V(M.current.handlers,"Unmount");t&&k.emit(t),U.current=A.Unmounted;for(const e of n)e()})}},[k]),function({unicast:e,broadcast:t,dispatchers:s,scope:c,phase:i,data:a,handlers:u}){const l=n.useRef(null),f=n.useRef(!1);n.useLayoutEffect(()=>{if(i.current===A.Mounted)return;i.current=A.Mounting;const n=V(u,"Mount");n&&e.emit(n),s.broadcast.forEach(n=>{const o=t.getCached(n);r.isNullable(o)||e.emit(n,o,G)}),c&&s.multicast.forEach(t=>{const n=c.emitter.getCached(t);r.isNullable(n)||e.emit(t,n,G)}),i.current=A.Mounted,f.current=!1},[]),n.useEffect(()=>{if(f.current)return;f.current=!0;const t=V(u,"Paint");t&&e.emit(t)},[]),n.useLayoutEffect(()=>{if(r.isNotNullable(l.current)){const t=function(e,t){return Object.keys(t).reduce((n,r)=>e[r]!==t[r]?{...n,[r]:t[r]}:n,{})}(l.current,a);if(o.isNotEmpty(Object.keys(t))){const n=V(u,"Update");n&&e.emit(n,t)}}l.current=a},[a,e])}({unicast:k,broadcast:c,dispatchers:_,scope:i,phase:U,data:s(),handlers:M.current.handlers});const T=n.useMemo(()=>({dispatch(e,t){const n=F(e),r=D(e)?e.channel:void 0;return I(e)?i?K(i.emitter,n,t,r):Promise.resolve():K(z(e)?c:k,n,t,r)},get inspect(){return j.current.inspect},stream:(e,t)=>n.createElement(Se,{action:F(e),renderer:t})}),[S,k]),H=n.useMemo(()=>[S,T,x],[S,T,x]);return H.useAction=(e,t)=>{!function(e,t,r){const o=n.useRef(r);n.useLayoutEffect(()=>{o.current=r});const s=n.useRef(t);n.useLayoutEffect(()=>{s.current=t});const c=n.useCallback((e,t)=>o.current(e,t),[]),i=n.useCallback(()=>D(s.current)?s.current.channel:void 0,[]),a=F(t),u=e.current.handlers.get(a)??/* @__PURE__ */new Set;0===u.size&&e.current.handlers.set(a,u),u.add({getChannel:i,handler:c})}(M,e,t)},H.dispatch=H[1].dispatch,H}(...t);return e.current=s.dispatch,s},with:{update:e=>Ce(e),invert:e=>Ne(e),always:(e,t)=>ke(e,t)}}),[])}function Ae(t,r){return{Boundary:function({children:t}){const r=n.useMemo(()=>({id:/* @__PURE__ */Symbol("march-hare.scope/instance"),emitter:new p}),[]);/* @__PURE__ */
|
|
7
|
+
return e(te.Provider,{value:r,children:t})},useContext:function(){return Me()},useEnv:function(){return w()},Resource:function(e){return ie(e,t,r)}}}function _e(n){const r={current:void 0};return{Boundary:function({children:o}){/* @__PURE__ */
|
|
8
|
+
return t($,{env:n?.env,tap:n?.tap,children:[
|
|
9
|
+
/* @__PURE__ */e(Re,{holder:r}),o]})},useContext:function(){return Me()},useEnv:function(){return w()},Resource:function(e){return ie(e,n?.cache,()=>r.current)},Scope:()=>Ae(n?.cache,()=>r.current)}}function Re({holder:e}){const t=w();return e.current=t,null}const Ue={Update:e=>Ce(e),Invert:e=>Ne(e),Always:(e,t)=>ke(e,t)},Le=new je;function We(e,t=ue.Update){return Le.annotate(t,e)}function Be(e,t){return new Promise((n,r)=>{if(t?.aborted)return void r(new ee);const o=setTimeout(n,e);t?.addEventListener("abort",()=>{clearTimeout(o),r(new ee)},{once:!0})})}async function $e(e,t,n){if(t?.aborted)throw new ee;for(;;){if(await n())return;await Be(e,t)}}function Te(e){return e?Boolean(e&&"symbol"!=typeof e):/* @__PURE__ */Symbol(`pk.${Date.now()}.${crypto.randomUUID()}`)}const Fe=/* @__PURE__ */Object.freeze(/* @__PURE__ */Object.defineProperty({__proto__:null,pk:Te,poll:$e,sleep:Be,unset:q,"ζ":Be,"κ":Te,"π":$e},Symbol.toStringTag,{value:"Module"})),ze=/* @__PURE__ */Object.freeze(/* @__PURE__ */Object.defineProperty({__proto__:null,Resource:function(e){return ie(e)},Scope:function(){return Ae()},useContext:function(){return Me()},useEnv:function(){return w()}},Symbol.toStringTag,{value:"Module"}));export{ee as Aborted,J as Action,_e as App,$ as Boundary,ne as Cache,M as Distribution,k as Lifecycle,ue as Op,ue as Operation,Z as Reason,je as State,Ue as With,We as annotate,we as isBox,ze as shared,Fe as utils};
|
|
10
10
|
//# sourceMappingURL=march-hare.js.map
|