@darajs/core 1.29.6 → 1.29.8

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 (38) hide show
  1. package/dist/api/http.d.ts.map +1 -1
  2. package/dist/api/http.js +14 -0
  3. package/dist/api/http.js.map +1 -1
  4. package/dist/{dara_core-1.29.6-py3-none-any.whl → dara_core-1.29.8-py3-none-any.whl} +0 -0
  5. package/dist/router/fetching.d.ts.map +1 -1
  6. package/dist/router/fetching.js +57 -32
  7. package/dist/router/fetching.js.map +1 -1
  8. package/dist/shared/context/variable-context.d.ts +5 -0
  9. package/dist/shared/context/variable-context.d.ts.map +1 -1
  10. package/dist/shared/context/variable-context.js.map +1 -1
  11. package/dist/shared/dynamic-component/dynamic-component.d.ts.map +1 -1
  12. package/dist/shared/dynamic-component/dynamic-component.js +10 -5
  13. package/dist/shared/dynamic-component/dynamic-component.js.map +1 -1
  14. package/dist/shared/interactivity/derived-variable.d.ts +14 -8
  15. package/dist/shared/interactivity/derived-variable.d.ts.map +1 -1
  16. package/dist/shared/interactivity/derived-variable.js +175 -126
  17. package/dist/shared/interactivity/derived-variable.js.map +1 -1
  18. package/dist/shared/interactivity/polling.d.ts +116 -0
  19. package/dist/shared/interactivity/polling.d.ts.map +1 -0
  20. package/dist/shared/interactivity/polling.js +723 -0
  21. package/dist/shared/interactivity/polling.js.map +1 -0
  22. package/dist/shared/interactivity/store.d.ts +6 -0
  23. package/dist/shared/interactivity/store.d.ts.map +1 -1
  24. package/dist/shared/interactivity/store.js +21 -1
  25. package/dist/shared/interactivity/store.js.map +1 -1
  26. package/dist/shared/interactivity/stream-variable.d.ts +1 -1
  27. package/dist/shared/interactivity/stream-variable.d.ts.map +1 -1
  28. package/dist/shared/interactivity/stream-variable.js +106 -41
  29. package/dist/shared/interactivity/stream-variable.js.map +1 -1
  30. package/dist/shared/interactivity/use-server-component.d.ts +9 -0
  31. package/dist/shared/interactivity/use-server-component.d.ts.map +1 -1
  32. package/dist/shared/interactivity/use-server-component.js +130 -77
  33. package/dist/shared/interactivity/use-server-component.js.map +1 -1
  34. package/dist/shared/interactivity/use-variable.d.ts.map +1 -1
  35. package/dist/shared/interactivity/use-variable.js +2 -2
  36. package/dist/shared/interactivity/use-variable.js.map +1 -1
  37. package/dist/umd/dara.core.umd.cjs +1064 -387
  38. package/package.json +9 -9
@@ -0,0 +1,116 @@
1
+ type TimerHandle = ReturnType<typeof setTimeout>;
2
+ type RunCause = 'dependency' | 'poll';
3
+ interface PollerOptions {
4
+ clearTimeout?: (timer: TimerHandle) => void;
5
+ getVisibilityState?: () => DocumentVisibilityState;
6
+ jitterRatio?: number;
7
+ now?: () => number;
8
+ random?: () => number;
9
+ setTimeout?: (callback: () => void, delay: number) => TimerHandle;
10
+ visibilityTarget?: Pick<Document, 'addEventListener' | 'removeEventListener'>;
11
+ }
12
+ export interface PollScope {
13
+ claims: Map<string, string>;
14
+ id: string;
15
+ }
16
+ export type SavedValue<T> = {
17
+ found: false;
18
+ } | {
19
+ found: true;
20
+ value: T;
21
+ };
22
+ export interface PollRun<T> {
23
+ cause: RunCause;
24
+ inputKey?: string;
25
+ key: string;
26
+ read?: () => SavedValue<T>;
27
+ signal?: AbortSignal;
28
+ work: (signal: AbortSignal) => Promise<T>;
29
+ write: (value: T) => void;
30
+ }
31
+ /** Check whether an error represents intentional request cancellation. */
32
+ export declare function isAbortError(error: unknown): boolean;
33
+ /**
34
+ * Coordinates non-overlapping, fixed-delay polling for request identities.
35
+ *
36
+ * A request identity includes the rendered variable/component identity and its
37
+ * serialized request extras. Multiple React consumers of the same identity
38
+ * share one timer and one active request generation.
39
+ */
40
+ export declare class Poller {
41
+ #private;
42
+ constructor(options?: PollerOptions);
43
+ /**
44
+ * Register one rendered polling consumer.
45
+ *
46
+ * The returned cleanup releases the consumer. The final cleanup aborts the
47
+ * owned request on the next macrotask so React StrictMode can immediately
48
+ * reacquire the same identity without cancelling useful work.
49
+ */
50
+ subscribe(key: string, intervalSeconds: number | undefined, refresh: () => void): () => void;
51
+ /**
52
+ * Claim a key during render so Suspense cannot skip its ownership effect.
53
+ *
54
+ * A later owner commit prunes claims left by an abandoned render.
55
+ */
56
+ claimKey(ownerId: string, hookId: string, key: string): void;
57
+ /** Apply the hook claims collected by one committed owner render. */
58
+ commitOwner(ownerId: string, claims: ReadonlyMap<string, string>): void;
59
+ /** Keep one key after its hook commits. */
60
+ mountKey(ownerId: string, hookId: string, key: string): void;
61
+ /** Drop a committed hook key after the StrictMode remount window. */
62
+ unmountKey(ownerId: string, hookId: string, key: string): void;
63
+ /** Release a rendered owner after the StrictMode remount window. */
64
+ releaseOwner(ownerId: string): void;
65
+ /**
66
+ * Run one request for a polling identity.
67
+ *
68
+ * Matching callers share one promise. Dependency runs replace older work,
69
+ * while a poll that arrives during a run leaves one follow-up refresh.
70
+ */
71
+ run<T>({ cause, inputKey, key, read, signal, work, write }: PollRun<T>): Promise<T>;
72
+ /** Refresh now, or keep one refresh while busy. */
73
+ runNow(key: string): void;
74
+ /** Abort and remove every polling identity. Intended for test isolation. */
75
+ clear(): void;
76
+ /** Current time according to the injected clock. */
77
+ now(): number;
78
+ }
79
+ /**
80
+ * Register fixed-delay polling for a request identity.
81
+ *
82
+ * `refresh` only invalidates the corresponding selector. Request lifecycle,
83
+ * backpressure, retries, and cancellation remain owned by the poller.
84
+ */
85
+ export declare function usePolling(key: string, intervalSeconds: number | undefined, refresh: () => void): void;
86
+ /**
87
+ * Create a render-local map of hooks to polling keys.
88
+ *
89
+ * The commit drops claims left by hooks that did not render.
90
+ */
91
+ export declare function usePollScope(): PollScope;
92
+ /**
93
+ * Keep one request key for a rendered hook.
94
+ *
95
+ * The hook must claim the key during render because an initial suspended render
96
+ * runs no effect. The claim only marks ownership; it starts no work. The passive
97
+ * effect keeps the claim after commit and stays mounted when Suspense hides an
98
+ * existing tree.
99
+ */
100
+ export declare function usePollKey(scope: PollScope | undefined, key: string): void;
101
+ /** Run one request using the production poller. */
102
+ export declare function runPoll<T>(run: PollRun<T>): Promise<T>;
103
+ /** Create a force key that identifies a poller-owned refresh. */
104
+ export declare function createPollForceKey(): string;
105
+ /** Check whether a selector force key originated from the poller. */
106
+ export declare function isPollForceKey(forceKey: string | null | undefined): boolean;
107
+ /** Extract Retry-After as a non-negative delay in milliseconds. */
108
+ export declare function parseRetryAfter(response: Response, now?: number): number | undefined;
109
+ /** Keep Retry-After beside an error without changing the error object. */
110
+ export declare function markRetryAfter(error: unknown, response: Response): unknown;
111
+ /** Await a promise while preserving ownership of request cancellation. */
112
+ export declare function waitOrAbort<T>(promise: Promise<T>, signal?: AbortSignal): Promise<T>;
113
+ /** Clear production polling state. Intended for test isolation. */
114
+ export declare function clearPolling_TEST(): void;
115
+ export {};
116
+ //# sourceMappingURL=polling.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"polling.d.ts","sourceRoot":"","sources":["../../../js/shared/interactivity/polling.tsx"],"names":[],"mappings":"AASA,KAAK,WAAW,GAAG,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC;AACjD,KAAK,QAAQ,GAAG,YAAY,GAAG,MAAM,CAAC;AAiCtC,UAAU,aAAa;IACnB,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,CAAC;IAC5C,kBAAkB,CAAC,EAAE,MAAM,uBAAuB,CAAC;IACnD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,IAAI,EAAE,KAAK,EAAE,MAAM,KAAK,WAAW,CAAC;IAClE,gBAAgB,CAAC,EAAE,IAAI,CAAC,QAAQ,EAAE,kBAAkB,GAAG,qBAAqB,CAAC,CAAC;CACjF;AAUD,MAAM,WAAW,SAAS;IACtB,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5B,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