ctrl-fx 0.0.1 → 0.1.1
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 +13 -0
- package/dist/chunk-DZAR6PTR.js +3966 -0
- package/dist/chunk-KNHJPAIU.js +1800 -0
- package/dist/chunk-NSWOTCDU.js +916 -0
- package/dist/chunk-PKBMQBKP.js +7 -0
- package/dist/chunk-XICUXW4T.js +252 -0
- package/dist/db/index.d.ts +234 -0
- package/dist/db/index.js +53 -0
- package/dist/dom/index.d.ts +2 -0
- package/dist/dom/index.js +30 -0
- package/dist/effects.d.ts +2 -0
- package/dist/effects.js +111 -0
- package/dist/index-fpCmXVEu.d.ts +1391 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +18 -0
- package/dist/router.d.ts +39 -0
- package/dist/router.js +66 -0
- package/dist/testing.d.ts +254 -0
- package/dist/testing.js +40 -0
- package/dist/webcomponent.d.ts +18 -0
- package/dist/webcomponent.js +51 -0
- package/package.json +4 -3
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
+
|
|
5
|
+
export {
|
|
6
|
+
__publicField
|
|
7
|
+
};
|
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
// src/db/effects.ts
|
|
2
|
+
function chain(effect, next) {
|
|
3
|
+
return {
|
|
4
|
+
_type: "FlatMap",
|
|
5
|
+
effect,
|
|
6
|
+
next,
|
|
7
|
+
flatMap(f) {
|
|
8
|
+
return chain(this, f);
|
|
9
|
+
},
|
|
10
|
+
map(f) {
|
|
11
|
+
return chain(this, (b) => ret(f(b)));
|
|
12
|
+
},
|
|
13
|
+
as(c) {
|
|
14
|
+
return chain(this, (_) => ret(c));
|
|
15
|
+
},
|
|
16
|
+
void() {
|
|
17
|
+
return this.map((_) => {
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function ret(value) {
|
|
23
|
+
return {
|
|
24
|
+
_type: "Return",
|
|
25
|
+
value,
|
|
26
|
+
flatMap(f) {
|
|
27
|
+
return chain(this, f);
|
|
28
|
+
},
|
|
29
|
+
map(f) {
|
|
30
|
+
return chain(this, (a) => ret(f(a)));
|
|
31
|
+
},
|
|
32
|
+
as(b) {
|
|
33
|
+
return chain(this, (_) => ret(b));
|
|
34
|
+
},
|
|
35
|
+
void() {
|
|
36
|
+
return this.map((_) => {
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
function suspend(operation) {
|
|
42
|
+
return {
|
|
43
|
+
_type: "Suspend",
|
|
44
|
+
operation,
|
|
45
|
+
flatMap(f) {
|
|
46
|
+
return chain(this, f);
|
|
47
|
+
},
|
|
48
|
+
map(f) {
|
|
49
|
+
return chain(this, (a) => ret(f(a)));
|
|
50
|
+
},
|
|
51
|
+
as(b) {
|
|
52
|
+
return chain(this, (_) => ret(b));
|
|
53
|
+
},
|
|
54
|
+
void() {
|
|
55
|
+
return this.map((_) => {
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
function pure(a) {
|
|
61
|
+
return ret(a);
|
|
62
|
+
}
|
|
63
|
+
function noop() {
|
|
64
|
+
return ret(void 0);
|
|
65
|
+
}
|
|
66
|
+
function run(effect, interpreter, onComplete) {
|
|
67
|
+
switch (effect._type) {
|
|
68
|
+
case "Return":
|
|
69
|
+
return onComplete(effect.value);
|
|
70
|
+
case "Suspend":
|
|
71
|
+
return interpreter(effect.operation, onComplete);
|
|
72
|
+
case "FlatMap":
|
|
73
|
+
return run(
|
|
74
|
+
effect.effect,
|
|
75
|
+
interpreter,
|
|
76
|
+
(result) => run(effect.next(result), interpreter, onComplete)
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
function add(objectStore2, value) {
|
|
81
|
+
return suspend({ _type: "Add", objectStore: objectStore2, value });
|
|
82
|
+
}
|
|
83
|
+
function put(objectStore2, value) {
|
|
84
|
+
return suspend({ _type: "Put", objectStore: objectStore2, value });
|
|
85
|
+
}
|
|
86
|
+
function get(objectStore2, key) {
|
|
87
|
+
return suspend({ _type: "Get", objectStore: objectStore2, key });
|
|
88
|
+
}
|
|
89
|
+
function getAll(objectStore2) {
|
|
90
|
+
return suspend({ _type: "GetAll", objectStore: objectStore2 });
|
|
91
|
+
}
|
|
92
|
+
function deleteRecord(objectStore2, key) {
|
|
93
|
+
return suspend({ _type: "Delete", objectStore: objectStore2, key });
|
|
94
|
+
}
|
|
95
|
+
function count(objectStore2) {
|
|
96
|
+
return suspend({ _type: "Count", objectStore: objectStore2 });
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// src/db/setup.ts
|
|
100
|
+
function chain2(effect, next) {
|
|
101
|
+
return {
|
|
102
|
+
_type: "FlatMap",
|
|
103
|
+
effect,
|
|
104
|
+
next,
|
|
105
|
+
flatMap(f) {
|
|
106
|
+
return chain2(this, f);
|
|
107
|
+
},
|
|
108
|
+
map(f) {
|
|
109
|
+
return chain2(this, (b) => ret2(f(b)));
|
|
110
|
+
},
|
|
111
|
+
as(c) {
|
|
112
|
+
return chain2(this, (_) => ret2(c));
|
|
113
|
+
},
|
|
114
|
+
void() {
|
|
115
|
+
return this.map((_) => {
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
function ret2(value) {
|
|
121
|
+
return {
|
|
122
|
+
_type: "Return",
|
|
123
|
+
value,
|
|
124
|
+
flatMap(f) {
|
|
125
|
+
return chain2(this, f);
|
|
126
|
+
},
|
|
127
|
+
map(f) {
|
|
128
|
+
return chain2(this, (a) => ret2(f(a)));
|
|
129
|
+
},
|
|
130
|
+
as(b) {
|
|
131
|
+
return chain2(this, (_) => ret2(b));
|
|
132
|
+
},
|
|
133
|
+
void() {
|
|
134
|
+
return this.map((_) => {
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
function suspend2(operation) {
|
|
140
|
+
return {
|
|
141
|
+
_type: "Suspend",
|
|
142
|
+
operation,
|
|
143
|
+
flatMap(f) {
|
|
144
|
+
return chain2(this, f);
|
|
145
|
+
},
|
|
146
|
+
map(f) {
|
|
147
|
+
return chain2(this, (a) => ret2(f(a)));
|
|
148
|
+
},
|
|
149
|
+
as(b) {
|
|
150
|
+
return chain2(this, (_) => ret2(b));
|
|
151
|
+
},
|
|
152
|
+
void() {
|
|
153
|
+
return this.map((_) => {
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
function run2(effect, interpreter, onComplete) {
|
|
159
|
+
switch (effect._type) {
|
|
160
|
+
case "Return":
|
|
161
|
+
return onComplete(effect.value);
|
|
162
|
+
case "Suspend":
|
|
163
|
+
return interpreter(effect.operation, onComplete);
|
|
164
|
+
case "FlatMap":
|
|
165
|
+
return run2(
|
|
166
|
+
effect.effect,
|
|
167
|
+
interpreter,
|
|
168
|
+
(result) => run2(effect.next(result), interpreter, onComplete)
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
function createObjectStore(objectStore2, keyPath) {
|
|
173
|
+
return suspend2({ _type: "CreateObjectStore", objectStore: objectStore2, keyPath });
|
|
174
|
+
}
|
|
175
|
+
function createIndex(objectStore2, index2, keyPath, unique) {
|
|
176
|
+
return suspend2({ _type: "CreateIndex", objectStore: objectStore2, index: index2, keyPath, unique });
|
|
177
|
+
}
|
|
178
|
+
function deleteObjectStore(objectStore2) {
|
|
179
|
+
return suspend2({ _type: "DeleteObjectStore", objectStore: objectStore2 });
|
|
180
|
+
}
|
|
181
|
+
function deleteIndex(objectStore2, index2) {
|
|
182
|
+
return suspend2({ _type: "DeleteIndex", objectStore: objectStore2, index: index2 });
|
|
183
|
+
}
|
|
184
|
+
function getObjectStoreNames() {
|
|
185
|
+
return suspend2({ _type: "GetObjectStoreNames" });
|
|
186
|
+
}
|
|
187
|
+
function getIndexNames(objectStore2) {
|
|
188
|
+
return suspend2({ _type: "GetIndexNames", objectStore: objectStore2 });
|
|
189
|
+
}
|
|
190
|
+
function runDbEffect(effect) {
|
|
191
|
+
return suspend2({ _type: "RunDbEffect", effect });
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
// src/db/keypath.ts
|
|
195
|
+
function autoIncrementPath(value) {
|
|
196
|
+
return { _type: "AutoIncrement", value };
|
|
197
|
+
}
|
|
198
|
+
function manualPath(value) {
|
|
199
|
+
return { _type: "Manual", value };
|
|
200
|
+
}
|
|
201
|
+
function multiPath(first, second, ...rest) {
|
|
202
|
+
return { _type: "Multi", first, second, rest };
|
|
203
|
+
}
|
|
204
|
+
function singleIndexPath(value) {
|
|
205
|
+
return { _type: "SingleIndex", value };
|
|
206
|
+
}
|
|
207
|
+
function multiIndexPath(first, second, rest, multiEntry) {
|
|
208
|
+
return { _type: "MultiIndex", first, second, rest, multiEntry };
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
// src/db/index.ts
|
|
212
|
+
function dbName(value) {
|
|
213
|
+
return value;
|
|
214
|
+
}
|
|
215
|
+
function dbVersion(value) {
|
|
216
|
+
return value;
|
|
217
|
+
}
|
|
218
|
+
function objectStore(value) {
|
|
219
|
+
return value;
|
|
220
|
+
}
|
|
221
|
+
function index(value) {
|
|
222
|
+
return value;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
export {
|
|
226
|
+
pure,
|
|
227
|
+
noop,
|
|
228
|
+
run,
|
|
229
|
+
add,
|
|
230
|
+
put,
|
|
231
|
+
get,
|
|
232
|
+
getAll,
|
|
233
|
+
deleteRecord,
|
|
234
|
+
count,
|
|
235
|
+
run2,
|
|
236
|
+
createObjectStore,
|
|
237
|
+
createIndex,
|
|
238
|
+
deleteObjectStore,
|
|
239
|
+
deleteIndex,
|
|
240
|
+
getObjectStoreNames,
|
|
241
|
+
getIndexNames,
|
|
242
|
+
runDbEffect,
|
|
243
|
+
autoIncrementPath,
|
|
244
|
+
manualPath,
|
|
245
|
+
multiPath,
|
|
246
|
+
singleIndexPath,
|
|
247
|
+
multiIndexPath,
|
|
248
|
+
dbName,
|
|
249
|
+
dbVersion,
|
|
250
|
+
objectStore,
|
|
251
|
+
index
|
|
252
|
+
};
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
type JsonPrimitive = string | number | boolean | null;
|
|
2
|
+
type JsonValue = JsonPrimitive | JsonValue[] | {
|
|
3
|
+
[key: string]: JsonValue;
|
|
4
|
+
};
|
|
5
|
+
|
|
6
|
+
type DbAdd = {
|
|
7
|
+
readonly _type: 'Add';
|
|
8
|
+
readonly objectStore: ObjectStore;
|
|
9
|
+
readonly value: JsonValue;
|
|
10
|
+
};
|
|
11
|
+
type DbPut = {
|
|
12
|
+
readonly _type: 'Put';
|
|
13
|
+
readonly objectStore: ObjectStore;
|
|
14
|
+
readonly value: JsonValue;
|
|
15
|
+
};
|
|
16
|
+
type DbGet = {
|
|
17
|
+
readonly _type: 'Get';
|
|
18
|
+
readonly objectStore: ObjectStore;
|
|
19
|
+
readonly key: IDBValidKey;
|
|
20
|
+
};
|
|
21
|
+
type DbGetAll = {
|
|
22
|
+
readonly _type: 'GetAll';
|
|
23
|
+
readonly objectStore: ObjectStore;
|
|
24
|
+
};
|
|
25
|
+
type DbDelete = {
|
|
26
|
+
readonly _type: 'Delete';
|
|
27
|
+
readonly objectStore: ObjectStore;
|
|
28
|
+
readonly key: IDBValidKey;
|
|
29
|
+
};
|
|
30
|
+
type DbCount = {
|
|
31
|
+
readonly _type: 'Count';
|
|
32
|
+
readonly objectStore: ObjectStore;
|
|
33
|
+
};
|
|
34
|
+
type DbOperation = DbAdd | DbPut | DbGet | DbGetAll | DbDelete | DbCount;
|
|
35
|
+
type DbReturn<A> = {
|
|
36
|
+
readonly _type: 'Return';
|
|
37
|
+
readonly value: A;
|
|
38
|
+
flatMap<B>(f: (a: A) => DbEffect<B>): DbEffect<B>;
|
|
39
|
+
map<B>(f: (a: A) => B): DbEffect<B>;
|
|
40
|
+
as<B>(b: B): DbEffect<B>;
|
|
41
|
+
void(): DbEffect<void>;
|
|
42
|
+
};
|
|
43
|
+
type DbSuspend<A> = {
|
|
44
|
+
readonly _type: 'Suspend';
|
|
45
|
+
readonly operation: DbOperation;
|
|
46
|
+
flatMap<B>(f: (a: A) => DbEffect<B>): DbEffect<B>;
|
|
47
|
+
map<B>(f: (a: A) => B): DbEffect<B>;
|
|
48
|
+
as<B>(b: B): DbEffect<B>;
|
|
49
|
+
void(): DbEffect<void>;
|
|
50
|
+
};
|
|
51
|
+
type DbChain<A> = {
|
|
52
|
+
readonly _type: 'FlatMap';
|
|
53
|
+
readonly effect: DbEffect<any>;
|
|
54
|
+
readonly next: (x: any) => DbEffect<A>;
|
|
55
|
+
flatMap<B>(f: (a: A) => DbEffect<B>): DbEffect<B>;
|
|
56
|
+
map<B>(f: (a: A) => B): DbEffect<B>;
|
|
57
|
+
as<B>(b: B): DbEffect<B>;
|
|
58
|
+
void(): DbEffect<void>;
|
|
59
|
+
};
|
|
60
|
+
/** A lazy, composable IndexedDB operation that produces a value of type `A`. Chain with `.flatMap`. */
|
|
61
|
+
type DbEffect<A> = DbReturn<A> | DbSuspend<A> | DbChain<A>;
|
|
62
|
+
/** Lifts a plain value into a `DbEffect` without performing any database operation. */
|
|
63
|
+
declare function pure<A>(a: A): DbEffect<A>;
|
|
64
|
+
/** A `DbEffect` that does nothing. Useful as a no-op in conditional chains. */
|
|
65
|
+
declare function noop(): DbEffect<void>;
|
|
66
|
+
/** A DbEffect describing an insert of `value` into `objectStore`. Fails if a record with the same key already exists. */
|
|
67
|
+
declare function add(objectStore: ObjectStore, value: JsonValue): DbEffect<void>;
|
|
68
|
+
/** A DbEffect describing an insert-or-replace of `value` in `objectStore` (upsert). */
|
|
69
|
+
declare function put(objectStore: ObjectStore, value: JsonValue): DbEffect<void>;
|
|
70
|
+
/** A DbEffect describing a retrieval of the record with `key` from `objectStore`, or `undefined` if not found. */
|
|
71
|
+
declare function get(objectStore: ObjectStore, key: IDBValidKey): DbEffect<JsonValue | undefined>;
|
|
72
|
+
/** A DbEffect describing a retrieval of all records from `objectStore`. */
|
|
73
|
+
declare function getAll(objectStore: ObjectStore): DbEffect<JsonValue[]>;
|
|
74
|
+
/** A DbEffect describing the deletion of the record with `key` from `objectStore`. */
|
|
75
|
+
declare function deleteRecord(objectStore: ObjectStore, key: IDBValidKey): DbEffect<void>;
|
|
76
|
+
/** A DbEffect describing a record count in `objectStore`. */
|
|
77
|
+
declare function count(objectStore: ObjectStore): DbEffect<number>;
|
|
78
|
+
|
|
79
|
+
type AutoIncrementPath = {
|
|
80
|
+
readonly _type: 'AutoIncrement';
|
|
81
|
+
readonly value: string;
|
|
82
|
+
};
|
|
83
|
+
type ManualPath = {
|
|
84
|
+
readonly _type: 'Manual';
|
|
85
|
+
readonly value: string;
|
|
86
|
+
};
|
|
87
|
+
type MultiPath = {
|
|
88
|
+
readonly _type: 'Multi';
|
|
89
|
+
readonly first: string;
|
|
90
|
+
readonly second: string;
|
|
91
|
+
readonly rest: readonly string[];
|
|
92
|
+
};
|
|
93
|
+
/** Describes how an object store's primary key is derived from stored values. */
|
|
94
|
+
type KeyPath = AutoIncrementPath | ManualPath | MultiPath;
|
|
95
|
+
/** Key is stored under `value` and auto-incremented by IndexedDB if absent. */
|
|
96
|
+
declare function autoIncrementPath(value: string): KeyPath;
|
|
97
|
+
/** Key is read from the `value` property of each stored object; caller must provide it. */
|
|
98
|
+
declare function manualPath(value: string): KeyPath;
|
|
99
|
+
/** Key is a compound of two or more property paths. */
|
|
100
|
+
declare function multiPath(first: string, second: string, ...rest: string[]): KeyPath;
|
|
101
|
+
type SingleIndexPath = {
|
|
102
|
+
readonly _type: 'SingleIndex';
|
|
103
|
+
readonly value: string;
|
|
104
|
+
};
|
|
105
|
+
type MultiIndexPath = {
|
|
106
|
+
readonly _type: 'MultiIndex';
|
|
107
|
+
readonly first: string;
|
|
108
|
+
readonly second: string;
|
|
109
|
+
readonly rest: readonly string[];
|
|
110
|
+
readonly multiEntry: boolean;
|
|
111
|
+
};
|
|
112
|
+
/** Describes how an IndexedDB index key is derived from stored values. */
|
|
113
|
+
type IndexKeyPath = SingleIndexPath | MultiIndexPath;
|
|
114
|
+
/** Index key is read from a single property. */
|
|
115
|
+
declare function singleIndexPath(value: string): IndexKeyPath;
|
|
116
|
+
/** Index key is a compound of two or more properties. Set `multiEntry: true` to index array values individually. */
|
|
117
|
+
declare function multiIndexPath(first: string, second: string, rest: readonly string[], multiEntry: boolean): IndexKeyPath;
|
|
118
|
+
|
|
119
|
+
type CreateObjectStore = {
|
|
120
|
+
readonly _type: 'CreateObjectStore';
|
|
121
|
+
readonly objectStore: ObjectStore;
|
|
122
|
+
readonly keyPath: KeyPath;
|
|
123
|
+
};
|
|
124
|
+
type CreateIndex = {
|
|
125
|
+
readonly _type: 'CreateIndex';
|
|
126
|
+
readonly objectStore: ObjectStore;
|
|
127
|
+
readonly index: Index;
|
|
128
|
+
readonly keyPath: IndexKeyPath;
|
|
129
|
+
readonly unique: boolean;
|
|
130
|
+
};
|
|
131
|
+
type DeleteObjectStore = {
|
|
132
|
+
readonly _type: 'DeleteObjectStore';
|
|
133
|
+
readonly objectStore: ObjectStore;
|
|
134
|
+
};
|
|
135
|
+
type DeleteIndex = {
|
|
136
|
+
readonly _type: 'DeleteIndex';
|
|
137
|
+
readonly objectStore: ObjectStore;
|
|
138
|
+
readonly index: Index;
|
|
139
|
+
};
|
|
140
|
+
type GetObjectStoreNames = {
|
|
141
|
+
readonly _type: 'GetObjectStoreNames';
|
|
142
|
+
};
|
|
143
|
+
type GetIndexNames = {
|
|
144
|
+
readonly _type: 'GetIndexNames';
|
|
145
|
+
readonly objectStore: ObjectStore;
|
|
146
|
+
};
|
|
147
|
+
type RunDbEffect = {
|
|
148
|
+
readonly _type: 'RunDbEffect';
|
|
149
|
+
readonly effect: DbEffect<void>;
|
|
150
|
+
};
|
|
151
|
+
type DbSetupOperation = CreateObjectStore | CreateIndex | DeleteObjectStore | DeleteIndex | GetObjectStoreNames | GetIndexNames | RunDbEffect;
|
|
152
|
+
type DbSetupReturn<A> = {
|
|
153
|
+
readonly _type: 'Return';
|
|
154
|
+
readonly value: A;
|
|
155
|
+
flatMap<B>(f: (a: A) => DbSetupEffect<B>): DbSetupEffect<B>;
|
|
156
|
+
map<B>(f: (a: A) => B): DbSetupEffect<B>;
|
|
157
|
+
as<B>(b: B): DbSetupEffect<B>;
|
|
158
|
+
void(): DbSetupEffect<void>;
|
|
159
|
+
};
|
|
160
|
+
type DbSetupSuspend<A> = {
|
|
161
|
+
readonly _type: 'Suspend';
|
|
162
|
+
readonly operation: DbSetupOperation;
|
|
163
|
+
flatMap<B>(f: (a: A) => DbSetupEffect<B>): DbSetupEffect<B>;
|
|
164
|
+
map<B>(f: (a: A) => B): DbSetupEffect<B>;
|
|
165
|
+
as<B>(b: B): DbSetupEffect<B>;
|
|
166
|
+
void(): DbSetupEffect<void>;
|
|
167
|
+
};
|
|
168
|
+
type DbSetupChain<A> = {
|
|
169
|
+
readonly _type: 'FlatMap';
|
|
170
|
+
readonly effect: DbSetupEffect<any>;
|
|
171
|
+
readonly next: (x: any) => DbSetupEffect<A>;
|
|
172
|
+
flatMap<B>(f: (a: A) => DbSetupEffect<B>): DbSetupEffect<B>;
|
|
173
|
+
map<B>(f: (a: A) => B): DbSetupEffect<B>;
|
|
174
|
+
as<B>(b: B): DbSetupEffect<B>;
|
|
175
|
+
void(): DbSetupEffect<void>;
|
|
176
|
+
};
|
|
177
|
+
/** A lazy schema-migration operation that produces a value of type `A`. Run via `runDbEffect`. */
|
|
178
|
+
type DbSetupEffect<A> = DbSetupReturn<A> | DbSetupSuspend<A> | DbSetupChain<A>;
|
|
179
|
+
/** A DbSetupEffect describing the creation of a new object store with the given key path. */
|
|
180
|
+
declare function createObjectStore(objectStore: ObjectStore, keyPath: KeyPath): DbSetupEffect<void>;
|
|
181
|
+
/** A DbSetupEffect describing the creation of an index on an object store. */
|
|
182
|
+
declare function createIndex(objectStore: ObjectStore, index: Index, keyPath: IndexKeyPath, unique: boolean): DbSetupEffect<void>;
|
|
183
|
+
/** A DbSetupEffect describing the deletion of an object store. */
|
|
184
|
+
declare function deleteObjectStore(objectStore: ObjectStore): DbSetupEffect<void>;
|
|
185
|
+
/** A DbSetupEffect describing the deletion of an index from an object store. */
|
|
186
|
+
declare function deleteIndex(objectStore: ObjectStore, index: Index): DbSetupEffect<void>;
|
|
187
|
+
/** A DbSetupEffect describing a read of all object store names in the database. */
|
|
188
|
+
declare function getObjectStoreNames(): DbSetupEffect<readonly string[]>;
|
|
189
|
+
/** A DbSetupEffect describing a read of all index names on the given object store. */
|
|
190
|
+
declare function getIndexNames(objectStore: ObjectStore): DbSetupEffect<readonly string[]>;
|
|
191
|
+
/** A DbSetupEffect describing the embedding of a `DbEffect` inside a setup operation, useful for seeding data during an upgrade. */
|
|
192
|
+
declare function runDbEffect(effect: DbEffect<void>): DbSetupEffect<void>;
|
|
193
|
+
|
|
194
|
+
type DbError = UnexpectedError | NotFoundError | ConstraintError;
|
|
195
|
+
interface UnexpectedError {
|
|
196
|
+
readonly _type: 'UnexpectedError';
|
|
197
|
+
readonly message?: string;
|
|
198
|
+
readonly cause?: Error;
|
|
199
|
+
}
|
|
200
|
+
interface NotFoundError {
|
|
201
|
+
readonly _type: 'NotFoundError';
|
|
202
|
+
readonly cause: Error;
|
|
203
|
+
}
|
|
204
|
+
interface ConstraintError {
|
|
205
|
+
readonly _type: 'ConstraintError';
|
|
206
|
+
readonly cause: Error;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/** Branded string representing an IndexedDB database name. */
|
|
210
|
+
type DbName = string & {
|
|
211
|
+
__brand: 'DbName';
|
|
212
|
+
};
|
|
213
|
+
/** Creates a `DbName`. */
|
|
214
|
+
declare function dbName(value: string): DbName;
|
|
215
|
+
/** Branded number representing an IndexedDB database schema version. */
|
|
216
|
+
type DbVersion = number & {
|
|
217
|
+
__brand: 'DbVersion';
|
|
218
|
+
};
|
|
219
|
+
/** Creates a `DbVersion`. */
|
|
220
|
+
declare function dbVersion(value: number): DbVersion;
|
|
221
|
+
/** Branded string representing the name of an IndexedDB object store. */
|
|
222
|
+
type ObjectStore = string & {
|
|
223
|
+
__brand: 'ObjectStore';
|
|
224
|
+
};
|
|
225
|
+
/** Creates an `ObjectStore` name. */
|
|
226
|
+
declare function objectStore(value: string): ObjectStore;
|
|
227
|
+
/** Branded string representing the name of an IndexedDB index. */
|
|
228
|
+
type Index = string & {
|
|
229
|
+
__brand: 'Index';
|
|
230
|
+
};
|
|
231
|
+
/** Creates an `Index` name. */
|
|
232
|
+
declare function index(value: string): Index;
|
|
233
|
+
|
|
234
|
+
export { type AutoIncrementPath, type ConstraintError, type DbEffect, type DbError, type DbName, type DbSetupEffect, type DbVersion, type Index, type IndexKeyPath, type JsonPrimitive, type JsonValue, type KeyPath, type ManualPath, type MultiIndexPath, type MultiPath, type NotFoundError, type ObjectStore, type SingleIndexPath, type UnexpectedError, add, autoIncrementPath, count, createIndex, createObjectStore, dbName, noop as dbNoop, pure as dbPure, dbVersion, deleteIndex, deleteObjectStore, deleteRecord, get, getAll, getIndexNames, getObjectStoreNames, index, manualPath, multiIndexPath, multiPath, objectStore, put, runDbEffect, singleIndexPath };
|
package/dist/db/index.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import {
|
|
2
|
+
add,
|
|
3
|
+
autoIncrementPath,
|
|
4
|
+
count,
|
|
5
|
+
createIndex,
|
|
6
|
+
createObjectStore,
|
|
7
|
+
dbName,
|
|
8
|
+
dbVersion,
|
|
9
|
+
deleteIndex,
|
|
10
|
+
deleteObjectStore,
|
|
11
|
+
deleteRecord,
|
|
12
|
+
get,
|
|
13
|
+
getAll,
|
|
14
|
+
getIndexNames,
|
|
15
|
+
getObjectStoreNames,
|
|
16
|
+
index,
|
|
17
|
+
manualPath,
|
|
18
|
+
multiIndexPath,
|
|
19
|
+
multiPath,
|
|
20
|
+
noop,
|
|
21
|
+
objectStore,
|
|
22
|
+
pure,
|
|
23
|
+
put,
|
|
24
|
+
runDbEffect,
|
|
25
|
+
singleIndexPath
|
|
26
|
+
} from "../chunk-XICUXW4T.js";
|
|
27
|
+
import "../chunk-PKBMQBKP.js";
|
|
28
|
+
export {
|
|
29
|
+
add,
|
|
30
|
+
autoIncrementPath,
|
|
31
|
+
count,
|
|
32
|
+
createIndex,
|
|
33
|
+
createObjectStore,
|
|
34
|
+
dbName,
|
|
35
|
+
noop as dbNoop,
|
|
36
|
+
pure as dbPure,
|
|
37
|
+
dbVersion,
|
|
38
|
+
deleteIndex,
|
|
39
|
+
deleteObjectStore,
|
|
40
|
+
deleteRecord,
|
|
41
|
+
get,
|
|
42
|
+
getAll,
|
|
43
|
+
getIndexNames,
|
|
44
|
+
getObjectStoreNames,
|
|
45
|
+
index,
|
|
46
|
+
manualPath,
|
|
47
|
+
multiIndexPath,
|
|
48
|
+
multiPath,
|
|
49
|
+
objectStore,
|
|
50
|
+
put,
|
|
51
|
+
runDbEffect,
|
|
52
|
+
singleIndexPath
|
|
53
|
+
};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { aB as A, aC as Abbr, aD as Address, aE as Article, aF as Aside, A as Attr, aG as AttrArg, aH as AttrOrNodeIdArgs, aI as B, aJ as BlockElement, aK as Blockquote, aL as Br, aM as Button, aN as ButtonContent, aO as ChangeData, aP as Circle, aQ as Cite, aR as Code, C as Component, aS as ComponentElement, aT as CustomElement, aU as Dd, aV as Details, aW as Div, aX as Dl, aY as Dt, aZ as Element, a_ as Ellipse, a$ as Em, a as EventActions, b0 as EventListenerResult, b1 as EventOptions, b2 as Fieldset, b3 as Figcaption, b4 as Figure, b5 as FlowContent, b6 as Footer, b7 as Form, b8 as H1, b9 as H2, ba as H3, bb as H4, bc as H5, bd as H6, be as Header, bf as Hr, bg as I, bh as Image, bi as Img, bj as InlineElement, bk as Input, bl as Kbd, bm as KeyData, bn as Label, bo as Li, bp as Line, bq as Main, br as Mark, bs as MouseMoveData, bt as Nav, e as Node, N as NodeGroup, bu as NodeId, bv as NonTextNode, bw as NonVoidElement, bx as Ol, by as Option, bz as P, bA as Path, bB as PhrasingContent, bC as Polygon, bD as Polyline, bE as Pre, bF as Prop, bG as Q, bH as Rect, bI as ReplacedElement, bJ as S, bK as ScrollData, bL as Section, bM as Select, bN as Small, bO as Span, bP as Strong, bQ as Sub, bR as Summary, bS as Sup, bT as Svg, bU as SvgGraphicElement, bV as Table, bW as Tbody, bX as Td, bY as TextState, bZ as Textarea, b_ as Tfoot, b$ as Th, c0 as Thead, c1 as Time, c2 as TouchData, c3 as Tr, c4 as U, c5 as Ul, c6 as Use, c7 as View, c8 as VoidElement, c9 as WheelData, ca as attr, cb as component, cc as cssVars, cd as foldNode, ce as id, cf as makeDom, cg as nodeId, ch as preventDefault, ci as prop, cj as stopPropagation, ck as stopPropagationAndPreventDefault, cl as typeAttr } from '../index-fpCmXVEu.js';
|
|
2
|
+
import '../db/index.js';
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import {
|
|
2
|
+
attr,
|
|
3
|
+
component,
|
|
4
|
+
cssVars,
|
|
5
|
+
foldNode,
|
|
6
|
+
id,
|
|
7
|
+
makeDom,
|
|
8
|
+
nodeId,
|
|
9
|
+
preventDefault,
|
|
10
|
+
prop,
|
|
11
|
+
stopPropagation,
|
|
12
|
+
stopPropagationAndPreventDefault,
|
|
13
|
+
typeAttr
|
|
14
|
+
} from "../chunk-NSWOTCDU.js";
|
|
15
|
+
import "../chunk-KNHJPAIU.js";
|
|
16
|
+
import "../chunk-PKBMQBKP.js";
|
|
17
|
+
export {
|
|
18
|
+
attr,
|
|
19
|
+
component,
|
|
20
|
+
cssVars,
|
|
21
|
+
foldNode,
|
|
22
|
+
id,
|
|
23
|
+
makeDom,
|
|
24
|
+
nodeId,
|
|
25
|
+
preventDefault,
|
|
26
|
+
prop,
|
|
27
|
+
stopPropagation,
|
|
28
|
+
stopPropagationAndPreventDefault,
|
|
29
|
+
typeAttr
|
|
30
|
+
};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { f as ClipboardError, g as DecodingError, h as DownloadInput, E as Effect, F as FlatMap, j as Fragment, k as Headers, d as HttpError, H as HttpRequest, b as HttpResponse, I as InternalLocation, J as Json, L as Lens, M as Method, l as Path, Q as QueryParam, c as RequestError, n as ResponseBody, R as Result, o as ResultTransformer, q as Return, r as ScrollElementError, S as ScrollOptions, s as StorageTarget, v as Suspend, T as TaskId, w as alert, x as async, y as cancelTask, z as clearAppBadge, B as clearLocalStorage, G as clearSessionStorage, K as confirm, O as customEffect, V as download, W as fireEvent, X as generateUuid, Y as getLocalStorageItem, Z as getLocation, _ as getNotificationPermission, $ as getRandom, a0 as getSessionStorageItem, a1 as getState, a2 as getTime, a3 as go, a4 as isEffect, a5 as log, a6 as makeEffects, a7 as makeHttpRequest, a8 as mapEvent, a9 as mapState, aa as noop, ab as openDatabase, ac as postBroadcastMessage, ad as product, ae as prompt, af as pure, ag as pushState, ah as readClipboard, ai as removeLocalStorageItem, aj as removeSessionStorageItem, ak as replaceState, al as requestNotificationPermission, am as resultT, an as runDbTransaction, ao as scheduleTask, ap as scrollElement, aq as scrollWindow, ar as setAppBadge, as as setDocumentTitle, at as setLocalStorageItem, au as setSessionStorageItem, av as setTimeout, aw as subscribeToBroadcastChannel, ax as taskId, ay as traverse, az as updateState, aA as writeClipboard } from './index-fpCmXVEu.js';
|
|
2
|
+
export { ConstraintError, DbEffect, DbError, DbName, DbSetupEffect, DbVersion, NotFoundError, ObjectStore, UnexpectedError } from './db/index.js';
|
package/dist/effects.js
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ResultTransformer,
|
|
3
|
+
alert,
|
|
4
|
+
async,
|
|
5
|
+
cancelTask,
|
|
6
|
+
clearAppBadge,
|
|
7
|
+
clearLocalStorage,
|
|
8
|
+
clearSessionStorage,
|
|
9
|
+
confirm,
|
|
10
|
+
customEffect,
|
|
11
|
+
download,
|
|
12
|
+
fireEvent,
|
|
13
|
+
generateUuid,
|
|
14
|
+
getLocalStorageItem,
|
|
15
|
+
getLocation,
|
|
16
|
+
getNotificationPermission,
|
|
17
|
+
getRandom,
|
|
18
|
+
getSessionStorageItem,
|
|
19
|
+
getState,
|
|
20
|
+
getTime,
|
|
21
|
+
go,
|
|
22
|
+
isEffect,
|
|
23
|
+
log,
|
|
24
|
+
makeEffects,
|
|
25
|
+
makeHttpRequest,
|
|
26
|
+
mapEvent,
|
|
27
|
+
mapState,
|
|
28
|
+
noop,
|
|
29
|
+
openDatabase,
|
|
30
|
+
postBroadcastMessage,
|
|
31
|
+
product,
|
|
32
|
+
prompt,
|
|
33
|
+
pure,
|
|
34
|
+
pushState,
|
|
35
|
+
readClipboard,
|
|
36
|
+
removeLocalStorageItem,
|
|
37
|
+
removeSessionStorageItem,
|
|
38
|
+
replaceState,
|
|
39
|
+
requestNotificationPermission,
|
|
40
|
+
resultT,
|
|
41
|
+
runDbTransaction,
|
|
42
|
+
scheduleTask,
|
|
43
|
+
scrollElement,
|
|
44
|
+
scrollWindow,
|
|
45
|
+
setAppBadge,
|
|
46
|
+
setDocumentTitle,
|
|
47
|
+
setLocalStorageItem,
|
|
48
|
+
setSessionStorageItem,
|
|
49
|
+
setTimeout,
|
|
50
|
+
subscribeToBroadcastChannel,
|
|
51
|
+
taskId,
|
|
52
|
+
traverse,
|
|
53
|
+
updateState,
|
|
54
|
+
writeClipboard
|
|
55
|
+
} from "./chunk-KNHJPAIU.js";
|
|
56
|
+
import "./chunk-PKBMQBKP.js";
|
|
57
|
+
export {
|
|
58
|
+
ResultTransformer,
|
|
59
|
+
alert,
|
|
60
|
+
async,
|
|
61
|
+
cancelTask,
|
|
62
|
+
clearAppBadge,
|
|
63
|
+
clearLocalStorage,
|
|
64
|
+
clearSessionStorage,
|
|
65
|
+
confirm,
|
|
66
|
+
customEffect,
|
|
67
|
+
download,
|
|
68
|
+
fireEvent,
|
|
69
|
+
generateUuid,
|
|
70
|
+
getLocalStorageItem,
|
|
71
|
+
getLocation,
|
|
72
|
+
getNotificationPermission,
|
|
73
|
+
getRandom,
|
|
74
|
+
getSessionStorageItem,
|
|
75
|
+
getState,
|
|
76
|
+
getTime,
|
|
77
|
+
go,
|
|
78
|
+
isEffect,
|
|
79
|
+
log,
|
|
80
|
+
makeEffects,
|
|
81
|
+
makeHttpRequest,
|
|
82
|
+
mapEvent,
|
|
83
|
+
mapState,
|
|
84
|
+
noop,
|
|
85
|
+
openDatabase,
|
|
86
|
+
postBroadcastMessage,
|
|
87
|
+
product,
|
|
88
|
+
prompt,
|
|
89
|
+
pure,
|
|
90
|
+
pushState,
|
|
91
|
+
readClipboard,
|
|
92
|
+
removeLocalStorageItem,
|
|
93
|
+
removeSessionStorageItem,
|
|
94
|
+
replaceState,
|
|
95
|
+
requestNotificationPermission,
|
|
96
|
+
resultT,
|
|
97
|
+
runDbTransaction,
|
|
98
|
+
scheduleTask,
|
|
99
|
+
scrollElement,
|
|
100
|
+
scrollWindow,
|
|
101
|
+
setAppBadge,
|
|
102
|
+
setDocumentTitle,
|
|
103
|
+
setLocalStorageItem,
|
|
104
|
+
setSessionStorageItem,
|
|
105
|
+
setTimeout,
|
|
106
|
+
subscribeToBroadcastChannel,
|
|
107
|
+
taskId,
|
|
108
|
+
traverse,
|
|
109
|
+
updateState,
|
|
110
|
+
writeClipboard
|
|
111
|
+
};
|