@byearlybird/starling 0.1.2 → 0.2.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.
Files changed (53) hide show
  1. package/dist/chunk-Bp6m_JJh.js +13 -0
  2. package/dist/index.d.ts +170 -2
  3. package/dist/index.js +423 -438
  4. package/package.json +2 -57
  5. package/README.md +0 -375
  6. package/dist/core/crdt/clock.d.ts +0 -15
  7. package/dist/core/crdt/clock.d.ts.map +0 -1
  8. package/dist/core/crdt/operations.d.ts +0 -8
  9. package/dist/core/crdt/operations.d.ts.map +0 -1
  10. package/dist/core/index.d.ts +0 -5
  11. package/dist/core/index.d.ts.map +0 -1
  12. package/dist/core/index.js +0 -454
  13. package/dist/core/shared/types.d.ts +0 -25
  14. package/dist/core/shared/types.d.ts.map +0 -1
  15. package/dist/core/shared/utils.d.ts +0 -5
  16. package/dist/core/shared/utils.d.ts.map +0 -1
  17. package/dist/core/store/mutations.d.ts +0 -16
  18. package/dist/core/store/mutations.d.ts.map +0 -1
  19. package/dist/core/store/query.d.ts +0 -16
  20. package/dist/core/store/query.d.ts.map +0 -1
  21. package/dist/core/store/store.d.ts +0 -77
  22. package/dist/core/store/store.d.ts.map +0 -1
  23. package/dist/index.d.ts.map +0 -1
  24. package/dist/plugins/index.d.ts +0 -3
  25. package/dist/plugins/index.d.ts.map +0 -1
  26. package/dist/plugins/index.js +0 -188
  27. package/dist/plugins/persistence/index.d.ts +0 -2
  28. package/dist/plugins/persistence/index.d.ts.map +0 -1
  29. package/dist/plugins/persistence/unstorage-plugin.d.ts +0 -5
  30. package/dist/plugins/persistence/unstorage-plugin.d.ts.map +0 -1
  31. package/dist/plugins/push-pull-plugin.d.ts +0 -13
  32. package/dist/plugins/push-pull-plugin.d.ts.map +0 -1
  33. package/dist/plugins/sync/index.d.ts +0 -3
  34. package/dist/plugins/sync/index.d.ts.map +0 -1
  35. package/dist/plugins/sync/index.js +0 -65
  36. package/dist/plugins/sync/push-pull-plugin.d.ts +0 -13
  37. package/dist/plugins/sync/push-pull-plugin.d.ts.map +0 -1
  38. package/dist/plugins/unstorage-plugin.d.ts +0 -5
  39. package/dist/plugins/unstorage-plugin.d.ts.map +0 -1
  40. package/dist/react/index.d.ts +0 -3
  41. package/dist/react/index.d.ts.map +0 -1
  42. package/dist/react/index.js +0 -893
  43. package/dist/react/use-data.d.ts +0 -9
  44. package/dist/react/use-data.d.ts.map +0 -1
  45. package/dist/react/use-query.d.ts +0 -7
  46. package/dist/react/use-query.d.ts.map +0 -1
  47. package/dist/solid/index.d.ts +0 -3
  48. package/dist/solid/index.d.ts.map +0 -1
  49. package/dist/solid/index.js +0 -299
  50. package/dist/solid/use-data.d.ts +0 -3
  51. package/dist/solid/use-data.d.ts.map +0 -1
  52. package/dist/solid/use-query.d.ts +0 -3
  53. package/dist/solid/use-query.d.ts.map +0 -1
@@ -1,9 +0,0 @@
1
- import type { Store } from "@core/store/store";
2
- export declare function useData<TValue extends object>(store: Store<TValue>): {
3
- data: {
4
- key: string;
5
- value: TValue;
6
- }[];
7
- isLoading: boolean;
8
- };
9
- //# sourceMappingURL=use-data.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-data.d.ts","sourceRoot":"","sources":["../../lib/react/use-data.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAG/C,wBAAgB,OAAO,CAAC,MAAM,SAAS,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC;;aAE1B,MAAM;eAAS,MAAM;;;EAkB7D"}
@@ -1,7 +0,0 @@
1
- import type { Store } from "@core/store/store";
2
- import type { DependencyList } from "react";
3
- export declare function useQuery<TValue extends object>(store: Store<TValue>, predicate: (data: TValue) => boolean, deps?: DependencyList): {
4
- data: Map<string, TValue>;
5
- isLoading: boolean;
6
- };
7
- //# sourceMappingURL=use-query.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-query.d.ts","sourceRoot":"","sources":["../../lib/react/use-query.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAG5C,wBAAgB,QAAQ,CAAC,MAAM,SAAS,MAAM,EAC7C,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,EACpB,SAAS,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,EACpC,IAAI,GAAE,cAAmB;;;EA6BzB"}
@@ -1,3 +0,0 @@
1
- export { useData } from "./use-data";
2
- export { useQuery } from "./use-query";
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../lib/solid/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC"}
@@ -1,299 +0,0 @@
1
- var __create = Object.create;
2
- var __getProtoOf = Object.getPrototypeOf;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __toESM = (mod, isNodeMode, target) => {
7
- target = mod != null ? __create(__getProtoOf(mod)) : {};
8
- const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
9
- for (let key of __getOwnPropNames(mod))
10
- if (!__hasOwnProp.call(to, key))
11
- __defProp(to, key, {
12
- get: () => mod[key],
13
- enumerable: true
14
- });
15
- return to;
16
- };
17
- var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
18
-
19
- // node_modules/.bun/solid-js@1.9.9/node_modules/solid-js/dist/server.js
20
- var $PROXY = Symbol("solid-proxy");
21
- var $TRACK = Symbol("solid-track");
22
- var $DEVCOMP = Symbol("solid-dev-component");
23
- var ERROR = Symbol("error");
24
- function castError(err) {
25
- if (err instanceof Error)
26
- return err;
27
- return new Error(typeof err === "string" ? err : "Unknown error", {
28
- cause: err
29
- });
30
- }
31
- function handleError(err, owner = Owner) {
32
- const fns = owner && owner.context && owner.context[ERROR];
33
- const error = castError(err);
34
- if (!fns)
35
- throw error;
36
- try {
37
- for (const f of fns)
38
- f(error);
39
- } catch (e) {
40
- handleError(e, owner && owner.owner || null);
41
- }
42
- }
43
- var Owner = null;
44
- function createOwner() {
45
- const o = {
46
- owner: Owner,
47
- context: Owner ? Owner.context : null,
48
- owned: null,
49
- cleanups: null
50
- };
51
- if (Owner) {
52
- if (!Owner.owned)
53
- Owner.owned = [o];
54
- else
55
- Owner.owned.push(o);
56
- }
57
- return o;
58
- }
59
- function createEffect(fn, value) {}
60
- function createMemo(fn, value) {
61
- Owner = createOwner();
62
- let v;
63
- try {
64
- v = fn(value);
65
- } catch (err) {
66
- handleError(err);
67
- } finally {
68
- Owner = Owner.owner;
69
- }
70
- return () => v;
71
- }
72
- function onCleanup(fn) {
73
- if (Owner) {
74
- if (!Owner.cleanups)
75
- Owner.cleanups = [fn];
76
- else
77
- Owner.cleanups.push(fn);
78
- }
79
- return fn;
80
- }
81
- function createContext(defaultValue) {
82
- const id = Symbol("context");
83
- return {
84
- id,
85
- Provider: createProvider(id),
86
- defaultValue
87
- };
88
- }
89
- function useContext(context) {
90
- return Owner && Owner.context && Owner.context[context.id] !== undefined ? Owner.context[context.id] : context.defaultValue;
91
- }
92
- function children(fn) {
93
- const memo = createMemo(() => resolveChildren(fn()));
94
- memo.toArray = () => {
95
- const c = memo();
96
- return Array.isArray(c) ? c : c != null ? [c] : [];
97
- };
98
- return memo;
99
- }
100
- function resolveChildren(children2) {
101
- if (typeof children2 === "function" && !children2.length)
102
- return resolveChildren(children2());
103
- if (Array.isArray(children2)) {
104
- const results = [];
105
- for (let i = 0;i < children2.length; i++) {
106
- const result = resolveChildren(children2[i]);
107
- Array.isArray(result) ? results.push.apply(results, result) : results.push(result);
108
- }
109
- return results;
110
- }
111
- return children2;
112
- }
113
- function createProvider(id) {
114
- return function provider(props) {
115
- return createMemo(() => {
116
- Owner.context = {
117
- ...Owner.context,
118
- [id]: props.value
119
- };
120
- return children(() => props.children);
121
- });
122
- };
123
- }
124
- var sharedConfig = {
125
- context: undefined,
126
- getContextId() {
127
- if (!this.context)
128
- throw new Error(`getContextId cannot be used under non-hydrating context`);
129
- return getContextId(this.context.count);
130
- },
131
- getNextContextId() {
132
- if (!this.context)
133
- throw new Error(`getNextContextId cannot be used under non-hydrating context`);
134
- return getContextId(this.context.count++);
135
- }
136
- };
137
- function getContextId(count) {
138
- const num = String(count), len = num.length - 1;
139
- return sharedConfig.context.id + (len ? String.fromCharCode(96 + len) : "") + num;
140
- }
141
- var SuspenseContext = createContext();
142
- var resourceContext = null;
143
- function createResource(source, fetcher, options = {}) {
144
- if (typeof fetcher !== "function") {
145
- options = fetcher || {};
146
- fetcher = source;
147
- source = true;
148
- }
149
- const contexts = new Set;
150
- const id = sharedConfig.getNextContextId();
151
- let resource = {};
152
- let value = options.storage ? options.storage(options.initialValue)[0]() : options.initialValue;
153
- let p;
154
- let error;
155
- if (sharedConfig.context.async && options.ssrLoadFrom !== "initial") {
156
- resource = sharedConfig.context.resources[id] || (sharedConfig.context.resources[id] = {});
157
- if (resource.ref) {
158
- if (!resource.data && !resource.ref[0].loading && !resource.ref[0].error)
159
- resource.ref[1].refetch();
160
- return resource.ref;
161
- }
162
- }
163
- const read = () => {
164
- if (error)
165
- throw error;
166
- const resolved = options.ssrLoadFrom !== "initial" && sharedConfig.context.async && "data" in sharedConfig.context.resources[id];
167
- if (!resolved && resourceContext)
168
- resourceContext.push(id);
169
- if (!resolved && read.loading) {
170
- const ctx = useContext(SuspenseContext);
171
- if (ctx) {
172
- ctx.resources.set(id, read);
173
- contexts.add(ctx);
174
- }
175
- }
176
- return resolved ? sharedConfig.context.resources[id].data : value;
177
- };
178
- read.loading = false;
179
- read.error = undefined;
180
- read.state = "initialValue" in options ? "ready" : "unresolved";
181
- Object.defineProperty(read, "latest", {
182
- get() {
183
- return read();
184
- }
185
- });
186
- function load() {
187
- const ctx = sharedConfig.context;
188
- if (!ctx.async)
189
- return read.loading = !!(typeof source === "function" ? source() : source);
190
- if (ctx.resources && id in ctx.resources && "data" in ctx.resources[id]) {
191
- value = ctx.resources[id].data;
192
- return;
193
- }
194
- let lookup;
195
- try {
196
- resourceContext = [];
197
- lookup = typeof source === "function" ? source() : source;
198
- if (resourceContext.length)
199
- return;
200
- } finally {
201
- resourceContext = null;
202
- }
203
- if (!p) {
204
- if (lookup == null || lookup === false)
205
- return;
206
- p = fetcher(lookup, {
207
- value
208
- });
209
- }
210
- if (p != null && typeof p === "object" && "then" in p) {
211
- read.loading = true;
212
- read.state = "pending";
213
- p = p.then((res) => {
214
- read.loading = false;
215
- read.state = "ready";
216
- ctx.resources[id].data = res;
217
- p = null;
218
- notifySuspense(contexts);
219
- return res;
220
- }).catch((err) => {
221
- read.loading = false;
222
- read.state = "errored";
223
- read.error = error = castError(err);
224
- p = null;
225
- notifySuspense(contexts);
226
- throw error;
227
- });
228
- if (ctx.serialize)
229
- ctx.serialize(id, p, options.deferStream);
230
- return p;
231
- }
232
- ctx.resources[id].data = p;
233
- if (ctx.serialize)
234
- ctx.serialize(id, p);
235
- p = null;
236
- return ctx.resources[id].data;
237
- }
238
- if (options.ssrLoadFrom !== "initial")
239
- load();
240
- const ref = [read, {
241
- refetch: load,
242
- mutate: (v) => value = v
243
- }];
244
- if (p)
245
- resource.ref = ref;
246
- return ref;
247
- }
248
- function suspenseComplete(c) {
249
- for (const r of c.resources.values()) {
250
- if (r.loading)
251
- return false;
252
- }
253
- return true;
254
- }
255
- function notifySuspense(contexts) {
256
- for (const c of contexts) {
257
- if (!suspenseComplete(c)) {
258
- continue;
259
- }
260
- c.completed();
261
- contexts.delete(c);
262
- }
263
- }
264
-
265
- // lib/solid/use-data.tsx
266
- function useData(store) {
267
- const [data, { refetch }] = createResource(store.values, {
268
- initialValue: []
269
- });
270
- const unwatch = store.on("change", () => {
271
- refetch();
272
- });
273
- onCleanup(() => {
274
- unwatch();
275
- });
276
- return data;
277
- }
278
- // lib/solid/use-query.tsx
279
- function useQuery(store, predicate) {
280
- const query = createMemo(() => store.query(predicate));
281
- const [data, { refetch }] = createResource(query, (q) => q.results(), {
282
- initialValue: new Map
283
- });
284
- createEffect(() => {
285
- const currentQuery = query();
286
- const unsubscribe = currentQuery.onChange(() => {
287
- refetch();
288
- });
289
- onCleanup(() => {
290
- unsubscribe();
291
- currentQuery.dispose();
292
- });
293
- });
294
- return data;
295
- }
296
- export {
297
- useQuery,
298
- useData
299
- };
@@ -1,3 +0,0 @@
1
- import type { Store } from "@core/store/store";
2
- export declare function useData<T extends object>(store: Store<T>): import("solid-js").InitializedResource<import("../core").ArrayKV<T>>;
3
- //# sourceMappingURL=use-data.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-data.d.ts","sourceRoot":"","sources":["../../lib/solid/use-data.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAG/C,wBAAgB,OAAO,CAAC,CAAC,SAAS,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,wEAcxD"}
@@ -1,3 +0,0 @@
1
- import type { Store } from "@core/store/store";
2
- export declare function useQuery<T extends object>(store: Store<T>, predicate: (data: T) => boolean): import("solid-js").InitializedResource<Map<string, T>>;
3
- //# sourceMappingURL=use-query.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-query.d.ts","sourceRoot":"","sources":["../../lib/solid/use-query.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAG/C,wBAAgB,QAAQ,CAAC,CAAC,SAAS,MAAM,EACxC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,EACf,SAAS,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,OAAO,0DA0B/B"}