@signaldb/core 2.0.0-beta.4 → 2.0.0-beta.6
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/dist/.vite/manifest.json +27 -21
- package/dist/Collection/Observer.d.ts +2 -0
- package/dist/Collection/index.d.ts +11 -10
- package/dist/Collection/types.d.ts +7 -0
- package/dist/DefaultDataAdapter.d.ts +2 -0
- package/dist/index.cjs.js +8 -5
- package/dist/index.cjs12.js +41 -346
- package/dist/index.cjs13.js +308 -359
- package/dist/index.cjs14.js +387 -177
- package/dist/index.cjs15.js +182 -364
- package/dist/index.cjs16.js +287 -478
- package/dist/index.cjs17.js +563 -136
- package/dist/index.cjs18.js +154 -23
- package/dist/index.cjs19.js +23 -39
- package/dist/index.cjs2.js +1 -1
- package/dist/index.cjs20.js +39 -13
- package/dist/index.cjs21.js +14 -102
- package/dist/index.cjs22.js +93 -118
- package/dist/index.cjs23.js +127 -5
- package/dist/index.cjs24.js +5 -25
- package/dist/index.cjs25.js +24 -7
- package/dist/index.cjs26.js +8 -27
- package/dist/index.cjs27.js +25 -42
- package/dist/index.cjs28.js +44 -6
- package/dist/index.cjs29.js +6 -7
- package/dist/index.cjs3.js +9 -26
- package/dist/index.cjs30.js +7 -3
- package/dist/index.cjs32.js +40 -27
- package/dist/index.cjs33.js +27 -40
- package/dist/index.cjs34.js +5 -0
- package/dist/index.cjs7.js +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.mjs +10 -7
- package/dist/index12.mjs +40 -346
- package/dist/index13.mjs +308 -359
- package/dist/index14.mjs +387 -177
- package/dist/index15.mjs +182 -364
- package/dist/index16.mjs +287 -478
- package/dist/index17.mjs +563 -136
- package/dist/index18.mjs +154 -23
- package/dist/index19.mjs +23 -38
- package/dist/index2.mjs +1 -1
- package/dist/index20.mjs +38 -13
- package/dist/index21.mjs +14 -102
- package/dist/index22.mjs +93 -117
- package/dist/index23.mjs +126 -5
- package/dist/index24.mjs +5 -25
- package/dist/index25.mjs +24 -7
- package/dist/index26.mjs +8 -27
- package/dist/index27.mjs +25 -42
- package/dist/index28.mjs +44 -6
- package/dist/index29.mjs +6 -7
- package/dist/index3.mjs +9 -26
- package/dist/index30.mjs +7 -3
- package/dist/index32.mjs +40 -27
- package/dist/index33.mjs +27 -40
- package/dist/index34.mjs +6 -0
- package/dist/index7.mjs +1 -1
- package/dist/utils/reactiveOrAsync.d.ts +59 -0
- package/package.json +1 -1
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
export type MaybePromise<T> = T | Promise<T>;
|
|
2
|
+
/**
|
|
3
|
+
* Options that control execution mode (and potential future mode-specific behavior).
|
|
4
|
+
* Keep this minimal; you can extend it later (e.g. signal, timeoutMs, debugLabel).
|
|
5
|
+
*/
|
|
6
|
+
export type ModeOptions = {
|
|
7
|
+
async?: boolean;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* A generator helper that makes TypeScript infer the “synchronous value type” for maybe-async expressions.
|
|
11
|
+
*
|
|
12
|
+
* Usage:
|
|
13
|
+
* const doc = yield* unwrap(Collection.findOne(...))
|
|
14
|
+
* const list = yield* unwrap(Collection.find(...).fetch())
|
|
15
|
+
*
|
|
16
|
+
* Runtime note:
|
|
17
|
+
* This does not “unwrap” Promises by itself. It yields the value/Promise to the runner and returns the
|
|
18
|
+
* value that the runner feeds back via `.next(...)`.
|
|
19
|
+
* @param value The value (or Promise of a value) to yield to the runner.
|
|
20
|
+
* @returns A generator that yields `value` and resolves to the runner-supplied unwrapped `T`.
|
|
21
|
+
*/
|
|
22
|
+
export declare function unwrap<T>(value: MaybePromise<T>): Generator<MaybePromise<T>, T, T>;
|
|
23
|
+
/**
|
|
24
|
+
* Generator shape used by the factory.
|
|
25
|
+
*
|
|
26
|
+
* `TThis` is the type of `this` inside the generator.
|
|
27
|
+
* `Args` are the method parameters (excluding the mode flag).
|
|
28
|
+
* `TReturn` is the final return value of the workflow.
|
|
29
|
+
* `TNext` is the type that is yielded/awaited and fed back via `.next(...)`.
|
|
30
|
+
*
|
|
31
|
+
* Note:
|
|
32
|
+
* - For best inference at yield sites, prefer `yield* unwrap(expr)` for maybe-async expressions.
|
|
33
|
+
*/
|
|
34
|
+
export type ReactiveOrAsyncGen<TThis, Arguments extends any[], TReturn, TNext> = (this: TThis, a: boolean, ...args: Arguments) => Generator<MaybePromise<TNext>, TReturn, TNext>;
|
|
35
|
+
/**
|
|
36
|
+
* The method type produced from the generator signature.
|
|
37
|
+
* Adds overloads so that `{ async: true }` yields a `Promise<...>` return type.
|
|
38
|
+
*/
|
|
39
|
+
export type ReactiveOrAsyncMethod<TThis, P extends any[], R, N> = {
|
|
40
|
+
(this: TThis, ...args: P): R;
|
|
41
|
+
(this: TThis, ...args: [...P, ModeOptions?]): MaybePromise<R>;
|
|
42
|
+
(this: TThis, ...args: [...P, {
|
|
43
|
+
async: true;
|
|
44
|
+
}]): Promise<R>;
|
|
45
|
+
} & {
|
|
46
|
+
/** Exposes the underlying generator for composition via `yield* method.generator.call(this, a, ...)` */
|
|
47
|
+
generator: (this: TThis, a: boolean, ...args: P) => Generator<MaybePromise<N>, R, N>;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Factory that turns a generator workflow into a callable method that can run in sync (reactive) or async mode.
|
|
51
|
+
*
|
|
52
|
+
* Call style:
|
|
53
|
+
* fn(a, b) -> sync/reactive return
|
|
54
|
+
* await fn(a, b, { async: true }) -> async return
|
|
55
|
+
* @param gen Generator workflow. Receives `(a)` which indicates async mode and should `yield`/`yield* unwrap(...)`
|
|
56
|
+
* any values that may be Promises.
|
|
57
|
+
* @returns A callable method with overloads plus a `.generator` property for composition.
|
|
58
|
+
*/
|
|
59
|
+
export default function reactiveOrAsync<TThis, P extends any[], R, N>(gen: (this: TThis, a: boolean, ...args: P) => Generator<MaybePromise<N>, R, N>): ReactiveOrAsyncMethod<TThis, P, R, N>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@signaldb/core",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.6",
|
|
4
4
|
"description": "SignalDB is a client-side database that provides a simple MongoDB-like interface to the data with first-class typescript support to achieve an optimistic UI. Data persistence can be achieved by using storage providers that store the data through a JSON interface to places such as localStorage.",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "rimraf dist && vite build",
|