@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,188 +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
- // lib/plugins/push-pull-plugin.ts
20
- var pushPullPlugin = (config) => {
21
- const {
22
- push,
23
- pull,
24
- preprocess,
25
- pullInterval = 1000 * 60 * 5,
26
- immediate = true
27
- } = config;
28
- const plugin = (store) => {
29
- let intervalId = null;
30
- let unwatch = null;
31
- async function pullData() {
32
- const data = await pull();
33
- const processed = preprocess ? await preprocess("pull", data) : data;
34
- store.merge(processed);
35
- }
36
- async function pushData(data) {
37
- const processed = preprocess ? await preprocess("push", data) : data;
38
- await push(processed);
39
- }
40
- return {
41
- init: async () => {
42
- unwatch = store.on("change", async () => {
43
- const latest = store.snapshot();
44
- if (latest.length > 0) {
45
- await pushData(latest);
46
- }
47
- });
48
- if (immediate)
49
- await pullData();
50
- intervalId = setInterval(pullData, pullInterval);
51
- },
52
- dispose: async () => {
53
- if (intervalId !== null) {
54
- clearInterval(intervalId);
55
- intervalId = null;
56
- }
57
- unwatch?.();
58
- }
59
- };
60
- };
61
- return plugin;
62
- };
63
- // node_modules/.bun/unstorage@1.17.1/node_modules/unstorage/dist/shared/unstorage.zVDD2mZo.mjs
64
- var storageKeyProperties = [
65
- "has",
66
- "hasItem",
67
- "get",
68
- "getItem",
69
- "getItemRaw",
70
- "set",
71
- "setItem",
72
- "setItemRaw",
73
- "del",
74
- "remove",
75
- "removeItem",
76
- "getMeta",
77
- "setMeta",
78
- "removeMeta",
79
- "getKeys",
80
- "clear",
81
- "mount",
82
- "unmount"
83
- ];
84
- function prefixStorage(storage, base) {
85
- base = normalizeBaseKey(base);
86
- if (!base) {
87
- return storage;
88
- }
89
- const nsStorage = { ...storage };
90
- for (const property of storageKeyProperties) {
91
- nsStorage[property] = (key = "", ...args) => storage[property](base + key, ...args);
92
- }
93
- nsStorage.getKeys = (key = "", ...arguments_) => storage.getKeys(base + key, ...arguments_).then((keys) => keys.map((key2) => key2.slice(base.length)));
94
- nsStorage.keys = nsStorage.getKeys;
95
- nsStorage.getItems = async (items, commonOptions) => {
96
- const prefixedItems = items.map((item) => typeof item === "string" ? base + item : { ...item, key: base + item.key });
97
- const results = await storage.getItems(prefixedItems, commonOptions);
98
- return results.map((entry) => ({
99
- key: entry.key.slice(base.length),
100
- value: entry.value
101
- }));
102
- };
103
- nsStorage.setItems = async (items, commonOptions) => {
104
- const prefixedItems = items.map((item) => ({
105
- key: base + item.key,
106
- value: item.value,
107
- options: item.options
108
- }));
109
- return storage.setItems(prefixedItems, commonOptions);
110
- };
111
- return nsStorage;
112
- }
113
- function normalizeKey(key) {
114
- if (!key) {
115
- return "";
116
- }
117
- return key.split("?")[0]?.replace(/[/\\]/g, ":").replace(/:+/g, ":").replace(/^:|:$/g, "") || "";
118
- }
119
- function normalizeBaseKey(base) {
120
- base = normalizeKey(base);
121
- return base ? base + ":" : "";
122
- }
123
-
124
- // node_modules/.bun/unstorage@1.17.1/node_modules/unstorage/dist/index.mjs
125
- function defineDriver(factory) {
126
- return factory;
127
- }
128
- var DRIVER_NAME = "memory";
129
- var memory = defineDriver(() => {
130
- const data = /* @__PURE__ */ new Map;
131
- return {
132
- name: DRIVER_NAME,
133
- getInstance: () => data,
134
- hasItem(key) {
135
- return data.has(key);
136
- },
137
- getItem(key) {
138
- return data.get(key) ?? null;
139
- },
140
- getItemRaw(key) {
141
- return data.get(key) ?? null;
142
- },
143
- setItem(key, value) {
144
- data.set(key, value);
145
- },
146
- setItemRaw(key, value) {
147
- data.set(key, value);
148
- },
149
- removeItem(key) {
150
- data.delete(key);
151
- },
152
- getKeys() {
153
- return [...data.keys()];
154
- },
155
- clear() {
156
- data.clear();
157
- },
158
- dispose() {
159
- data.clear();
160
- }
161
- };
162
- });
163
-
164
- // lib/plugins/unstorage-plugin.ts
165
- var unstoragePlugin = (baseStorage) => {
166
- let unwatch = null;
167
- let storage = null;
168
- const plugin = (store) => ({
169
- init: async () => {
170
- storage = prefixStorage(baseStorage, store.collectionKey);
171
- unwatch = store.on("change", async () => {
172
- await storage?.set(store.collectionKey, store.snapshot());
173
- });
174
- const persisted = await storage.get(store.collectionKey);
175
- if (persisted) {
176
- store.merge(persisted, { silent: true });
177
- }
178
- },
179
- dispose: () => {
180
- unwatch?.();
181
- }
182
- });
183
- return plugin;
184
- };
185
- export {
186
- unstoragePlugin,
187
- pushPullPlugin
188
- };
@@ -1,2 +0,0 @@
1
- export { unstoragePlugin } from "../unstorage-plugin";
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../lib/plugins/persistence/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC"}
@@ -1,5 +0,0 @@
1
- import type { Plugin } from "@core/store/store";
2
- import { type Storage } from "unstorage";
3
- declare const unstoragePlugin: <T extends object>(baseStorage: Storage) => Plugin<T>;
4
- export { unstoragePlugin };
5
- //# sourceMappingURL=unstorage-plugin.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"unstorage-plugin.d.ts","sourceRoot":"","sources":["../../../lib/plugins/persistence/unstorage-plugin.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAiB,KAAK,OAAO,EAAE,MAAM,WAAW,CAAC;AAExD,QAAA,MAAM,eAAe,GAAI,CAAC,SAAS,MAAM,EAAE,aAAa,OAAO,KAAG,MAAM,CAAC,CAAC,CAyBzE,CAAC;AAEF,OAAO,EAAE,eAAe,EAAE,CAAC"}
@@ -1,13 +0,0 @@
1
- import type { ArrayKV, EncodedObject } from "@core/shared/types";
2
- import type { Plugin } from "@core/store/store";
3
- type PushPullConfig = {
4
- push: (data: ArrayKV<EncodedObject>) => Promise<void>;
5
- pull: () => Promise<ArrayKV<EncodedObject>>;
6
- pullInterval?: number;
7
- preprocess?: (event: "pull" | "push", data: ArrayKV<EncodedObject>) => Promise<ArrayKV<EncodedObject>>;
8
- immediate?: boolean;
9
- };
10
- declare const pushPullPlugin: <TValue extends object>(config: PushPullConfig) => Plugin<TValue>;
11
- export { pushPullPlugin };
12
- export type { PushPullConfig };
13
- //# sourceMappingURL=push-pull-plugin.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"push-pull-plugin.d.ts","sourceRoot":"","sources":["../../lib/plugins/push-pull-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEhD,KAAK,cAAc,GAAG;IACrB,IAAI,EAAE,CAAC,IAAI,EAAE,OAAO,CAAC,aAAa,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACtD,IAAI,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC;IAC5C,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,CACZ,KAAK,EAAE,MAAM,GAAG,MAAM,EACtB,IAAI,EAAE,OAAO,CAAC,aAAa,CAAC,KACxB,OAAO,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC;IACrC,SAAS,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,QAAA,MAAM,cAAc,GAAI,MAAM,SAAS,MAAM,EAC5C,QAAQ,cAAc,KACpB,MAAM,CAAC,MAAM,CAiDf,CAAC;AAEF,OAAO,EAAE,cAAc,EAAE,CAAC;AAC1B,YAAY,EAAE,cAAc,EAAE,CAAC"}
@@ -1,3 +0,0 @@
1
- export type { PushPullConfig } from "./push-pull-plugin";
2
- export { pushPullPlugin } from "./push-pull-plugin";
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../lib/plugins/sync/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC"}
@@ -1,65 +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
- // lib/plugins/sync/push-pull-plugin.ts
20
- var pushPullPlugin = (config) => {
21
- const {
22
- push,
23
- pull,
24
- preprocess,
25
- pullInterval = 1000 * 60 * 5,
26
- immediate = true
27
- } = config;
28
- const plugin = (store) => {
29
- let intervalId = null;
30
- let unwatch = null;
31
- async function pullData() {
32
- const data = await pull();
33
- const processed = preprocess ? await preprocess("pull", data) : data;
34
- store.merge(processed);
35
- }
36
- async function pushData(data) {
37
- const processed = preprocess ? await preprocess("push", data) : data;
38
- await push(processed);
39
- }
40
- return {
41
- init: async () => {
42
- unwatch = store.on("change", async () => {
43
- const latest = store.snapshot();
44
- if (latest.length > 0) {
45
- await pushData(latest);
46
- }
47
- });
48
- if (immediate)
49
- await pullData();
50
- intervalId = setInterval(pullData, pullInterval);
51
- },
52
- dispose: async () => {
53
- if (intervalId !== null) {
54
- clearInterval(intervalId);
55
- intervalId = null;
56
- }
57
- unwatch?.();
58
- }
59
- };
60
- };
61
- return plugin;
62
- };
63
- export {
64
- pushPullPlugin
65
- };
@@ -1,13 +0,0 @@
1
- import type { ArrayKV, EncodedObject } from "@core/shared/types";
2
- import type { Plugin } from "@core/store/store";
3
- type PushPullConfig = {
4
- push: (data: ArrayKV<EncodedObject>) => Promise<void>;
5
- pull: () => Promise<ArrayKV<EncodedObject>>;
6
- pullInterval?: number;
7
- preprocess?: (event: "pull" | "push", data: ArrayKV<EncodedObject>) => Promise<ArrayKV<EncodedObject>>;
8
- immediate?: boolean;
9
- };
10
- declare const pushPullPlugin: <TValue extends object>(config: PushPullConfig) => Plugin<TValue>;
11
- export { pushPullPlugin };
12
- export type { PushPullConfig };
13
- //# sourceMappingURL=push-pull-plugin.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"push-pull-plugin.d.ts","sourceRoot":"","sources":["../../../lib/plugins/sync/push-pull-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEhD,KAAK,cAAc,GAAG;IACrB,IAAI,EAAE,CAAC,IAAI,EAAE,OAAO,CAAC,aAAa,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACtD,IAAI,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC;IAC5C,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,CACZ,KAAK,EAAE,MAAM,GAAG,MAAM,EACtB,IAAI,EAAE,OAAO,CAAC,aAAa,CAAC,KACxB,OAAO,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC;IACrC,SAAS,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,QAAA,MAAM,cAAc,GAAI,MAAM,SAAS,MAAM,EAC5C,QAAQ,cAAc,KACpB,MAAM,CAAC,MAAM,CAiDf,CAAC;AAEF,OAAO,EAAE,cAAc,EAAE,CAAC;AAC1B,YAAY,EAAE,cAAc,EAAE,CAAC"}
@@ -1,5 +0,0 @@
1
- import type { Plugin } from "@core/store/store";
2
- import { type Storage } from "unstorage";
3
- declare const unstoragePlugin: <T extends object>(baseStorage: Storage) => Plugin<T>;
4
- export { unstoragePlugin };
5
- //# sourceMappingURL=unstorage-plugin.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"unstorage-plugin.d.ts","sourceRoot":"","sources":["../../lib/plugins/unstorage-plugin.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAiB,KAAK,OAAO,EAAE,MAAM,WAAW,CAAC;AAExD,QAAA,MAAM,eAAe,GAAI,CAAC,SAAS,MAAM,EAAE,aAAa,OAAO,KAAG,MAAM,CAAC,CAAC,CAyBzE,CAAC;AAEF,OAAO,EAAE,eAAe,EAAE,CAAC"}
@@ -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/react/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC"}