ctrl-fx 0.1.0 → 0.1.2
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-BDTTV33M.js +4050 -0
- package/dist/chunk-EKBLRHWK.js +916 -0
- package/dist/chunk-OSIRHKDB.js +1812 -0
- package/dist/chunk-PKBMQBKP.js +7 -0
- package/dist/chunk-XICUXW4T.js +252 -0
- package/dist/db/index.d.ts +218 -16
- package/dist/db/index.js +53 -19
- package/dist/dom/index.d.ts +2 -248
- package/dist/dom/index.js +30 -266
- package/dist/effects.d.ts +2 -580
- package/dist/effects.js +111 -1556
- package/dist/index-DeEjNrg-.d.ts +1399 -0
- package/dist/index.d.ts +2 -41
- package/dist/index.js +18 -78
- package/dist/router.d.ts +11 -12
- package/dist/router.js +57 -68
- package/dist/testing.d.ts +67 -60
- package/dist/testing.js +46 -158
- package/dist/webcomponent.d.ts +7 -4
- package/dist/webcomponent.js +48 -40
- package/package.json +4 -3
- package/dist/clipboard.d.ts +0 -7
- package/dist/clipboard.d.ts.map +0 -1
- package/dist/clipboard.js +0 -3
- package/dist/db/effects.d.ts +0 -78
- package/dist/db/effects.d.ts.map +0 -1
- package/dist/db/effects.js +0 -98
- package/dist/db/errors.d.ts +0 -21
- package/dist/db/errors.d.ts.map +0 -1
- package/dist/db/errors.js +0 -13
- package/dist/db/index.d.ts.map +0 -1
- package/dist/db/keypath.d.ts +0 -40
- package/dist/db/keypath.d.ts.map +0 -1
- package/dist/db/keypath.js +0 -20
- package/dist/db/setup.d.ts +0 -83
- package/dist/db/setup.d.ts.map +0 -1
- package/dist/db/setup.js +0 -100
- package/dist/db/testdb.d.ts +0 -19
- package/dist/db/testdb.d.ts.map +0 -1
- package/dist/db/testdb.js +0 -34
- package/dist/dom/attrs.d.ts +0 -67
- package/dist/dom/attrs.d.ts.map +0 -1
- package/dist/dom/attrs.js +0 -154
- package/dist/dom/components.d.ts +0 -43
- package/dist/dom/components.d.ts.map +0 -1
- package/dist/dom/components.js +0 -86
- package/dist/dom/elems.d.ts +0 -121
- package/dist/dom/elems.d.ts.map +0 -1
- package/dist/dom/elems.js +0 -52
- package/dist/dom/events.d.ts +0 -232
- package/dist/dom/events.d.ts.map +0 -1
- package/dist/dom/events.js +0 -289
- package/dist/dom/index.d.ts.map +0 -1
- package/dist/dom/nodeid.d.ts +0 -9
- package/dist/dom/nodeid.d.ts.map +0 -1
- package/dist/dom/nodeid.js +0 -27
- package/dist/dom/svg.d.ts +0 -23
- package/dist/dom/svg.d.ts.map +0 -1
- package/dist/dom/svg.js +0 -1
- package/dist/dom/views.d.ts +0 -60
- package/dist/dom/views.d.ts.map +0 -1
- package/dist/dom/views.js +0 -154
- package/dist/effects.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/internal/clipboard.d.ts +0 -5
- package/dist/internal/clipboard.d.ts.map +0 -1
- package/dist/internal/clipboard.js +0 -33
- package/dist/internal/cmpmgr.d.ts +0 -46
- package/dist/internal/cmpmgr.d.ts.map +0 -1
- package/dist/internal/cmpmgr.js +0 -561
- package/dist/internal/dbmgr.d.ts +0 -11
- package/dist/internal/dbmgr.d.ts.map +0 -1
- package/dist/internal/dbmgr.js +0 -200
- package/dist/internal/dominterpreter.d.ts +0 -5
- package/dist/internal/dominterpreter.d.ts.map +0 -1
- package/dist/internal/dominterpreter.js +0 -337
- package/dist/internal/eventmgr.d.ts +0 -41
- package/dist/internal/eventmgr.d.ts.map +0 -1
- package/dist/internal/eventmgr.js +0 -696
- package/dist/internal/index.d.ts +0 -19
- package/dist/internal/index.d.ts.map +0 -1
- package/dist/internal/index.js +0 -38
- package/dist/internal/interpreter.d.ts +0 -10
- package/dist/internal/interpreter.d.ts.map +0 -1
- package/dist/internal/interpreter.js +0 -1
- package/dist/internal/locutils.d.ts +0 -4
- package/dist/internal/locutils.d.ts.map +0 -1
- package/dist/internal/locutils.js +0 -22
- package/dist/internal/net.d.ts +0 -4
- package/dist/internal/net.d.ts.map +0 -1
- package/dist/internal/net.js +0 -64
- package/dist/internal/realdom.d.ts +0 -249
- package/dist/internal/realdom.d.ts.map +0 -1
- package/dist/internal/realdom.js +0 -1
- package/dist/internal/styleregistry.d.ts +0 -6
- package/dist/internal/styleregistry.d.ts.map +0 -1
- package/dist/internal/styleregistry.js +0 -18
- package/dist/internal/taskreg.d.ts +0 -9
- package/dist/internal/taskreg.d.ts.map +0 -1
- package/dist/internal/taskreg.js +0 -28
- package/dist/internal/testing.d.ts +0 -12
- package/dist/internal/testing.d.ts.map +0 -1
- package/dist/internal/testing.js +0 -974
- package/dist/internal/testinginterpreter.d.ts +0 -10
- package/dist/internal/testinginterpreter.d.ts.map +0 -1
- package/dist/internal/testinginterpreter.js +0 -646
- package/dist/internal/vdom.d.ts +0 -93
- package/dist/internal/vdom.d.ts.map +0 -1
- package/dist/internal/vdom.js +0 -470
- package/dist/json/index.d.ts +0 -5
- package/dist/json/index.d.ts.map +0 -1
- package/dist/json/index.js +0 -2
- package/dist/json/validation.d.ts +0 -28
- package/dist/json/validation.d.ts.map +0 -1
- package/dist/json/validation.js +0 -8
- package/dist/net/fragment.d.ts +0 -10
- package/dist/net/fragment.d.ts.map +0 -1
- package/dist/net/fragment.js +0 -27
- package/dist/net/index.d.ts +0 -42
- package/dist/net/index.d.ts.map +0 -1
- package/dist/net/index.js +0 -60
- package/dist/net/location.d.ts +0 -21
- package/dist/net/location.d.ts.map +0 -1
- package/dist/net/location.js +0 -41
- package/dist/net/path.d.ts +0 -12
- package/dist/net/path.d.ts.map +0 -1
- package/dist/net/path.js +0 -29
- package/dist/net/queryparam.d.ts +0 -10
- package/dist/net/queryparam.d.ts.map +0 -1
- package/dist/net/queryparam.js +0 -34
- package/dist/router.d.ts.map +0 -1
- package/dist/scroll.d.ts +0 -7
- package/dist/scroll.d.ts.map +0 -1
- package/dist/scroll.js +0 -3
- package/dist/testing.d.ts.map +0 -1
- package/dist/utils/apply.d.ts +0 -9
- package/dist/utils/apply.d.ts.map +0 -1
- package/dist/utils/apply.js +0 -10
- package/dist/utils/index.d.ts +0 -22
- package/dist/utils/index.d.ts.map +0 -1
- package/dist/utils/index.js +0 -138
- package/dist/utils/lens.d.ts +0 -18
- package/dist/utils/lens.d.ts.map +0 -1
- package/dist/utils/lens.js +0 -27
- package/dist/utils/match.d.ts +0 -17
- package/dist/utils/match.d.ts.map +0 -1
- package/dist/utils/match.js +0 -28
- package/dist/utils/result.d.ts +0 -47
- package/dist/utils/result.d.ts.map +0 -1
- package/dist/utils/result.js +0 -97
- package/dist/webcomponent.d.ts.map +0 -1
package/dist/db/setup.d.ts
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import type { DbEffect, DbOperation } from './effects';
|
|
2
|
-
import type { Index, ObjectStore } from './index';
|
|
3
|
-
import type { IndexKeyPath, KeyPath } from './keypath';
|
|
4
|
-
type CreateObjectStore = {
|
|
5
|
-
readonly _type: 'CreateObjectStore';
|
|
6
|
-
readonly objectStore: ObjectStore;
|
|
7
|
-
readonly keyPath: KeyPath;
|
|
8
|
-
};
|
|
9
|
-
type CreateIndex = {
|
|
10
|
-
readonly _type: 'CreateIndex';
|
|
11
|
-
readonly objectStore: ObjectStore;
|
|
12
|
-
readonly index: Index;
|
|
13
|
-
readonly keyPath: IndexKeyPath;
|
|
14
|
-
readonly unique: boolean;
|
|
15
|
-
};
|
|
16
|
-
type DeleteObjectStore = {
|
|
17
|
-
readonly _type: 'DeleteObjectStore';
|
|
18
|
-
readonly objectStore: ObjectStore;
|
|
19
|
-
};
|
|
20
|
-
type DeleteIndex = {
|
|
21
|
-
readonly _type: 'DeleteIndex';
|
|
22
|
-
readonly objectStore: ObjectStore;
|
|
23
|
-
readonly index: Index;
|
|
24
|
-
};
|
|
25
|
-
type GetObjectStoreNames = {
|
|
26
|
-
readonly _type: 'GetObjectStoreNames';
|
|
27
|
-
};
|
|
28
|
-
type GetIndexNames = {
|
|
29
|
-
readonly _type: 'GetIndexNames';
|
|
30
|
-
readonly objectStore: ObjectStore;
|
|
31
|
-
};
|
|
32
|
-
type RunDbEffect = {
|
|
33
|
-
readonly _type: 'RunDbEffect';
|
|
34
|
-
readonly effect: DbEffect<void>;
|
|
35
|
-
};
|
|
36
|
-
export type DbSetupOperation = CreateObjectStore | CreateIndex | DeleteObjectStore | DeleteIndex | GetObjectStoreNames | GetIndexNames | RunDbEffect;
|
|
37
|
-
type DbSetupReturn<A> = {
|
|
38
|
-
readonly _type: 'Return';
|
|
39
|
-
readonly value: A;
|
|
40
|
-
flatMap<B>(f: (a: A) => DbSetupEffect<B>): DbSetupEffect<B>;
|
|
41
|
-
map<B>(f: (a: A) => B): DbSetupEffect<B>;
|
|
42
|
-
as<B>(b: B): DbSetupEffect<B>;
|
|
43
|
-
void(): DbSetupEffect<void>;
|
|
44
|
-
};
|
|
45
|
-
type DbSetupSuspend<A> = {
|
|
46
|
-
readonly _type: 'Suspend';
|
|
47
|
-
readonly operation: DbSetupOperation;
|
|
48
|
-
flatMap<B>(f: (a: A) => DbSetupEffect<B>): DbSetupEffect<B>;
|
|
49
|
-
map<B>(f: (a: A) => B): DbSetupEffect<B>;
|
|
50
|
-
as<B>(b: B): DbSetupEffect<B>;
|
|
51
|
-
void(): DbSetupEffect<void>;
|
|
52
|
-
};
|
|
53
|
-
type DbSetupChain<A> = {
|
|
54
|
-
readonly _type: 'FlatMap';
|
|
55
|
-
readonly effect: DbSetupEffect<any>;
|
|
56
|
-
readonly next: (x: any) => DbSetupEffect<A>;
|
|
57
|
-
flatMap<B>(f: (a: A) => DbSetupEffect<B>): DbSetupEffect<B>;
|
|
58
|
-
map<B>(f: (a: A) => B): DbSetupEffect<B>;
|
|
59
|
-
as<B>(b: B): DbSetupEffect<B>;
|
|
60
|
-
void(): DbSetupEffect<void>;
|
|
61
|
-
};
|
|
62
|
-
/** A lazy schema-migration operation that produces a value of type `A`. Run via `runDbEffect`. */
|
|
63
|
-
export type DbSetupEffect<A> = DbSetupReturn<A> | DbSetupSuspend<A> | DbSetupChain<A>;
|
|
64
|
-
export declare function pure<A>(a: A): DbSetupEffect<A>;
|
|
65
|
-
export declare function noop(): DbSetupEffect<void>;
|
|
66
|
-
/** Runs a `DbSetupEffect` against an interpreter callback. Called by the framework; not needed in application code. */
|
|
67
|
-
export declare function run<A>(effect: DbSetupEffect<A>, interpreter: (op: DbSetupOperation, onComplete: (a: A) => void) => void, onComplete: (a: A) => void): void;
|
|
68
|
-
/** A DbSetupEffect describing the creation of a new object store with the given key path. */
|
|
69
|
-
export declare function createObjectStore(objectStore: ObjectStore, keyPath: KeyPath): DbSetupEffect<void>;
|
|
70
|
-
/** A DbSetupEffect describing the creation of an index on an object store. */
|
|
71
|
-
export declare function createIndex(objectStore: ObjectStore, index: Index, keyPath: IndexKeyPath, unique: boolean): DbSetupEffect<void>;
|
|
72
|
-
/** A DbSetupEffect describing the deletion of an object store. */
|
|
73
|
-
export declare function deleteObjectStore(objectStore: ObjectStore): DbSetupEffect<void>;
|
|
74
|
-
/** A DbSetupEffect describing the deletion of an index from an object store. */
|
|
75
|
-
export declare function deleteIndex(objectStore: ObjectStore, index: Index): DbSetupEffect<void>;
|
|
76
|
-
/** A DbSetupEffect describing a read of all object store names in the database. */
|
|
77
|
-
export declare function getObjectStoreNames(): DbSetupEffect<readonly string[]>;
|
|
78
|
-
/** A DbSetupEffect describing a read of all index names on the given object store. */
|
|
79
|
-
export declare function getIndexNames(objectStore: ObjectStore): DbSetupEffect<readonly string[]>;
|
|
80
|
-
/** A DbSetupEffect describing the embedding of a `DbEffect` inside a setup operation, useful for seeding data during an upgrade. */
|
|
81
|
-
export declare function runDbEffect(effect: DbEffect<void>): DbSetupEffect<void>;
|
|
82
|
-
export type { DbOperation };
|
|
83
|
-
//# sourceMappingURL=setup.d.ts.map
|
package/dist/db/setup.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../../src/db/setup.ts"],"names":[],"mappings":"AAAA,O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AAO,GACf,aAAa,CAAC,IAAI,CAAC,CAErB;AAED,8EAA8E;AAC9E,wBAAgB,WAAW,CACzB,WAAW,EAAE,WAAW,EACxB,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,YAAY,EACrB,MAAM,EAAE,OAAO,GACd,aAAa,CAAC,IAAI,CAAC,CAErB;AAED,kEAAkE;AAClE,wBAAgB,iBAAiB,CAC/B,WAAW,EAAE,WAAW,GACvB,aAAa,CAAC,IAAI,CAAC,CAErB;AAED,gFAAgF;AAChF,wBAAgB,WAAW,CACzB,WAAW,EAAE,WAAW,EACxB,KAAK,EAAE,KAAK,GACX,aAAa,CAAC,IAAI,CAAC,CAErB;AAED,mFAAmF;AACnF,wBAAgB,mBAAmB,IAAI,aAAa,CAAC,SAAS,MAAM,EAAE,CAAC,CAEtE;AAED,sFAAsF;AACtF,wBAAgB,aAAa,CAC3B,WAAW,EAAE,WAAW,GACvB,aAAa,CAAC,SAAS,MAAM,EAAE,CAAC,CAElC;AAED,oIAAoI;AACpI,wBAAgB,WAAW,CAAC,MAAM,EAAE,QAAQ,CAAC,IAAI,CAAC,GAAG,aAAa,CAAC,IAAI,CAAC,CAEvE;AAED,YAAY,EAAE,WAAW,EAAE,CAAA"}
|
package/dist/db/setup.js
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
function chain(effect, next) {
|
|
2
|
-
return {
|
|
3
|
-
_type: 'FlatMap',
|
|
4
|
-
effect,
|
|
5
|
-
next,
|
|
6
|
-
flatMap(f) {
|
|
7
|
-
return chain(this, f);
|
|
8
|
-
},
|
|
9
|
-
map(f) {
|
|
10
|
-
return chain(this, b => ret(f(b)));
|
|
11
|
-
},
|
|
12
|
-
as(c) {
|
|
13
|
-
return chain(this, _ => ret(c));
|
|
14
|
-
},
|
|
15
|
-
void() {
|
|
16
|
-
return this.map(_ => { });
|
|
17
|
-
},
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
function ret(value) {
|
|
21
|
-
return {
|
|
22
|
-
_type: 'Return',
|
|
23
|
-
value,
|
|
24
|
-
flatMap(f) {
|
|
25
|
-
return chain(this, f);
|
|
26
|
-
},
|
|
27
|
-
map(f) {
|
|
28
|
-
return chain(this, a => ret(f(a)));
|
|
29
|
-
},
|
|
30
|
-
as(b) {
|
|
31
|
-
return chain(this, _ => ret(b));
|
|
32
|
-
},
|
|
33
|
-
void() {
|
|
34
|
-
return this.map(_ => { });
|
|
35
|
-
},
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
function suspend(operation) {
|
|
39
|
-
return {
|
|
40
|
-
_type: 'Suspend',
|
|
41
|
-
operation,
|
|
42
|
-
flatMap(f) {
|
|
43
|
-
return chain(this, f);
|
|
44
|
-
},
|
|
45
|
-
map(f) {
|
|
46
|
-
return chain(this, a => ret(f(a)));
|
|
47
|
-
},
|
|
48
|
-
as(b) {
|
|
49
|
-
return chain(this, _ => ret(b));
|
|
50
|
-
},
|
|
51
|
-
void() {
|
|
52
|
-
return this.map(_ => { });
|
|
53
|
-
},
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
export function pure(a) {
|
|
57
|
-
return ret(a);
|
|
58
|
-
}
|
|
59
|
-
export function noop() {
|
|
60
|
-
return ret(undefined);
|
|
61
|
-
}
|
|
62
|
-
/** Runs a `DbSetupEffect` against an interpreter callback. Called by the framework; not needed in application code. */
|
|
63
|
-
export function run(effect, interpreter, onComplete) {
|
|
64
|
-
switch (effect._type) {
|
|
65
|
-
case 'Return':
|
|
66
|
-
return onComplete(effect.value);
|
|
67
|
-
case 'Suspend':
|
|
68
|
-
return interpreter(effect.operation, onComplete);
|
|
69
|
-
case 'FlatMap':
|
|
70
|
-
return run(effect.effect, interpreter, result => run(effect.next(result), interpreter, onComplete));
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
/** A DbSetupEffect describing the creation of a new object store with the given key path. */
|
|
74
|
-
export function createObjectStore(objectStore, keyPath) {
|
|
75
|
-
return suspend({ _type: 'CreateObjectStore', objectStore, keyPath });
|
|
76
|
-
}
|
|
77
|
-
/** A DbSetupEffect describing the creation of an index on an object store. */
|
|
78
|
-
export function createIndex(objectStore, index, keyPath, unique) {
|
|
79
|
-
return suspend({ _type: 'CreateIndex', objectStore, index, keyPath, unique });
|
|
80
|
-
}
|
|
81
|
-
/** A DbSetupEffect describing the deletion of an object store. */
|
|
82
|
-
export function deleteObjectStore(objectStore) {
|
|
83
|
-
return suspend({ _type: 'DeleteObjectStore', objectStore });
|
|
84
|
-
}
|
|
85
|
-
/** A DbSetupEffect describing the deletion of an index from an object store. */
|
|
86
|
-
export function deleteIndex(objectStore, index) {
|
|
87
|
-
return suspend({ _type: 'DeleteIndex', objectStore, index });
|
|
88
|
-
}
|
|
89
|
-
/** A DbSetupEffect describing a read of all object store names in the database. */
|
|
90
|
-
export function getObjectStoreNames() {
|
|
91
|
-
return suspend({ _type: 'GetObjectStoreNames' });
|
|
92
|
-
}
|
|
93
|
-
/** A DbSetupEffect describing a read of all index names on the given object store. */
|
|
94
|
-
export function getIndexNames(objectStore) {
|
|
95
|
-
return suspend({ _type: 'GetIndexNames', objectStore });
|
|
96
|
-
}
|
|
97
|
-
/** A DbSetupEffect describing the embedding of a `DbEffect` inside a setup operation, useful for seeding data during an upgrade. */
|
|
98
|
-
export function runDbEffect(effect) {
|
|
99
|
-
return suspend({ _type: 'RunDbEffect', effect });
|
|
100
|
-
}
|
package/dist/db/testdb.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { JsonValue } from '../json';
|
|
2
|
-
import type { KeyPath } from './keypath';
|
|
3
|
-
import type { DbName, ObjectStore } from './index';
|
|
4
|
-
export type DbStoreSnapshot = {
|
|
5
|
-
readonly keyPath: KeyPath;
|
|
6
|
-
readonly records: ReadonlyMap<string, JsonValue>;
|
|
7
|
-
readonly autoIncrementCounter: number;
|
|
8
|
-
};
|
|
9
|
-
export declare function serializeIdbKey(key: IDBValidKey): string;
|
|
10
|
-
export declare class TestDatabaseData {
|
|
11
|
-
readonly _databases: ReadonlyMap<string, ReadonlyMap<string, DbStoreSnapshot>>;
|
|
12
|
-
constructor(databases: ReadonlyMap<string, ReadonlyMap<string, DbStoreSnapshot>>);
|
|
13
|
-
records(db: DbName, store: ObjectStore): readonly JsonValue[];
|
|
14
|
-
getByKey(db: DbName, store: ObjectStore, key: IDBValidKey): JsonValue | undefined;
|
|
15
|
-
size(db: DbName, store: ObjectStore): number;
|
|
16
|
-
hasDatabase(db: DbName): boolean;
|
|
17
|
-
hasStore(db: DbName, store: ObjectStore): boolean;
|
|
18
|
-
}
|
|
19
|
-
//# sourceMappingURL=testdb.d.ts.map
|
package/dist/db/testdb.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"testdb.d.ts","sourceRoot":"","sources":["../../src/db/testdb.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AACxC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACxC,OAAO,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAElD,MAAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;IACzB,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC,MAAM,EAAE,SAAS,CAAC,CAAA;IAChD,QAAQ,CAAC,oBAAoB,EAAE,MAAM,CAAA;CACtC,CAAA;AAED,wBAAgB,eAAe,CAAC,GAAG,EAAE,WAAW,GAAG,MAAM,CAGxD;AAED,qBAAa,gBAAgB;IAC3B,QAAQ,CAAC,UAAU,EAAE,WAAW,CAAC,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC,CAAA;gBAG5E,SAAS,EAAE,WAAW,CAAC,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IAKtE,OAAO,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,GAAG,SAAS,SAAS,EAAE;IAI7D,QAAQ,CACN,EAAE,EAAE,MAAM,EACV,KAAK,EAAE,WAAW,EAClB,GAAG,EAAE,WAAW,GACf,SAAS,GAAG,SAAS;IAOxB,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,GAAG,MAAM;IAI5C,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO;IAIhC,QAAQ,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,GAAG,OAAO;CAGlD"}
|
package/dist/db/testdb.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
export function serializeIdbKey(key) {
|
|
2
|
-
if (key instanceof Date)
|
|
3
|
-
return key.toISOString();
|
|
4
|
-
return JSON.stringify(key);
|
|
5
|
-
}
|
|
6
|
-
export class TestDatabaseData {
|
|
7
|
-
constructor(databases) {
|
|
8
|
-
Object.defineProperty(this, "_databases", {
|
|
9
|
-
enumerable: true,
|
|
10
|
-
configurable: true,
|
|
11
|
-
writable: true,
|
|
12
|
-
value: void 0
|
|
13
|
-
});
|
|
14
|
-
this._databases = databases;
|
|
15
|
-
}
|
|
16
|
-
records(db, store) {
|
|
17
|
-
return [...(this._databases.get(db)?.get(store)?.records.values() ?? [])];
|
|
18
|
-
}
|
|
19
|
-
getByKey(db, store, key) {
|
|
20
|
-
return this._databases
|
|
21
|
-
.get(db)
|
|
22
|
-
?.get(store)
|
|
23
|
-
?.records.get(serializeIdbKey(key));
|
|
24
|
-
}
|
|
25
|
-
size(db, store) {
|
|
26
|
-
return this._databases.get(db)?.get(store)?.records.size ?? 0;
|
|
27
|
-
}
|
|
28
|
-
hasDatabase(db) {
|
|
29
|
-
return this._databases.has(db);
|
|
30
|
-
}
|
|
31
|
-
hasStore(db, store) {
|
|
32
|
-
return this._databases.get(db)?.has(store) ?? false;
|
|
33
|
-
}
|
|
34
|
-
}
|
package/dist/dom/attrs.d.ts
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { type NodeId } from './nodeid';
|
|
2
|
-
/** A virtual DOM attribute: a name/value pair set on the real DOM element via
|
|
3
|
-
* `setAttribute`. */
|
|
4
|
-
export interface Attr {
|
|
5
|
-
readonly name: string;
|
|
6
|
-
readonly value?: string;
|
|
7
|
-
}
|
|
8
|
-
/** Creates an `Attr`. */
|
|
9
|
-
export declare function attr(name: string, value: string): Attr;
|
|
10
|
-
/** A JavaScript property set directly on the DOM element object, as opposed to
|
|
11
|
-
* an HTML attribute. */
|
|
12
|
-
export interface Prop {
|
|
13
|
-
readonly name: string;
|
|
14
|
-
readonly value: unknown;
|
|
15
|
-
}
|
|
16
|
-
/** Creates a `Prop`. */
|
|
17
|
-
export declare function prop(name: string, value: unknown): Prop;
|
|
18
|
-
export type AttrArg = Attr | [string, string] | string;
|
|
19
|
-
export declare function normalizeAttrArg(arg: AttrArg): Attr;
|
|
20
|
-
export type AttrOrNodeIdArgs = [NodeId, ...AttrArg[]] | [...AttrArg[]];
|
|
21
|
-
export declare function normalizeAttrArgs(args: AttrOrNodeIdArgs): Attr[];
|
|
22
|
-
export interface SupportsAttrs {
|
|
23
|
-
readonly attrs: readonly Attr[];
|
|
24
|
-
idAttr(): string | undefined;
|
|
25
|
-
}
|
|
26
|
-
export declare function getId(attrs: readonly Attr[]): string | undefined;
|
|
27
|
-
/** Shorthand for `attr('aria-label', value)`. */
|
|
28
|
-
export declare function ariaLabel(value: string): Attr;
|
|
29
|
-
/** Shorthand for `attr('aria-hidden', value)`. */
|
|
30
|
-
export declare function ariaHidden(value: string): Attr;
|
|
31
|
-
/** Shorthand for `attr('id', value)`. */
|
|
32
|
-
export declare function id(value: string): Attr;
|
|
33
|
-
export declare function width(value: string): Attr;
|
|
34
|
-
export declare function height(value: string): Attr;
|
|
35
|
-
export declare function transform(value: string): Attr;
|
|
36
|
-
export declare function viewBox(value: string): Attr;
|
|
37
|
-
export declare function fill(value: string): Attr;
|
|
38
|
-
export declare function focusable(value: string): Attr;
|
|
39
|
-
export declare function xmlns(value: string): Attr;
|
|
40
|
-
export declare function d(value: string): Attr;
|
|
41
|
-
export declare function stroke(value: string): Attr;
|
|
42
|
-
export declare function strokeWidth(value: string): Attr;
|
|
43
|
-
export declare function strokeLinecap(value: string): Attr;
|
|
44
|
-
export declare function strokeLinejoin(value: string): Attr;
|
|
45
|
-
export declare function cx(value: string): Attr;
|
|
46
|
-
export declare function cy(value: string): Attr;
|
|
47
|
-
export declare function r(value: string): Attr;
|
|
48
|
-
export declare function role(value: string): Attr;
|
|
49
|
-
/** Shorthand for `attr('type', value)`. */
|
|
50
|
-
export declare function typeAttr(value: string): Attr;
|
|
51
|
-
/** Shorthand for `attr('class', value)`. */
|
|
52
|
-
export declare function cls(value: string): Attr;
|
|
53
|
-
/**
|
|
54
|
-
* Each argument is either a plain class name (always applied), `[boolean,
|
|
55
|
-
* string]` (applied when the boolean is true), or `[boolean, string, string]`
|
|
56
|
-
* (first class when true, second when false). All selected names are joined
|
|
57
|
-
* with a space into a single `class` attribute.
|
|
58
|
-
*/
|
|
59
|
-
export type classListArg = string | [boolean, string] | [boolean, string, string];
|
|
60
|
-
/** Builds a `class` attribute from a list of conditional class entries. See
|
|
61
|
-
* `classListArg`. */
|
|
62
|
-
export declare function classList(...classes: classListArg[]): Attr;
|
|
63
|
-
export declare function attrs(attrMap: Record<string, string>): readonly Attr[];
|
|
64
|
-
/** Converts a map of CSS custom property names to values into a `style`
|
|
65
|
-
* attribute. */
|
|
66
|
-
export declare function cssVars(vars: Record<string, string>): Attr;
|
|
67
|
-
//# sourceMappingURL=attrs.d.ts.map
|
package/dist/dom/attrs.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"attrs.d.ts","sourceRoot":"","sources":["../../src/dom/attrs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,MAAM,EAAE,MAAM,UAAU,CAAA;AAEhD;qBACqB;AACrB,MAAM,WAAW,IAAI;IAC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jB,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,CAAA;AAE7B;qBACqB;AACrB,wBAAgB,SAAS,CAAC,GAAG,OAAO,EAAE,YAAY,EAAE,GAAG,IAAI,CAqB1D;AAED,wBAAgB,KAAK,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,IAAI,EAAE,CAItE;AAED;gBACgB;AAChB,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAO1D"}
|
package/dist/dom/attrs.js
DELETED
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
import { isNodeId } from './nodeid';
|
|
2
|
-
/** Creates an `Attr`. */
|
|
3
|
-
export function attr(name, value) {
|
|
4
|
-
return {
|
|
5
|
-
name,
|
|
6
|
-
value,
|
|
7
|
-
};
|
|
8
|
-
}
|
|
9
|
-
/** Creates a `Prop`. */
|
|
10
|
-
export function prop(name, value) {
|
|
11
|
-
return { name, value };
|
|
12
|
-
}
|
|
13
|
-
export function normalizeAttrArg(arg) {
|
|
14
|
-
if (Array.isArray(arg)) {
|
|
15
|
-
return { name: arg[0], value: arg[1] };
|
|
16
|
-
}
|
|
17
|
-
else if (typeof arg === 'object') {
|
|
18
|
-
return arg;
|
|
19
|
-
}
|
|
20
|
-
else {
|
|
21
|
-
return { name: arg };
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
export function normalizeAttrArgs(args) {
|
|
25
|
-
const attrs = [];
|
|
26
|
-
args.forEach(arg => {
|
|
27
|
-
if (!isNodeId(arg)) {
|
|
28
|
-
attrs.push(normalizeAttrArg(arg));
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
return attrs;
|
|
32
|
-
}
|
|
33
|
-
/*
|
|
34
|
-
export function withCommonAttrAccesssorSupport<T extends SupportsAttrs>() {
|
|
35
|
-
return {
|
|
36
|
-
idAttr(this: T): string | undefined {
|
|
37
|
-
return option(this.attrs.find(attr => attr.name === 'id'))
|
|
38
|
-
.flatMap(a => {
|
|
39
|
-
return a.value
|
|
40
|
-
}).getOrElse(undefined)
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
*/
|
|
45
|
-
export function getId(attrs) {
|
|
46
|
-
const id = attrs.find(a => a.name.toLowerCase() === 'id');
|
|
47
|
-
return id ? id.value : undefined;
|
|
48
|
-
}
|
|
49
|
-
/** Shorthand for `attr('aria-label', value)`. */
|
|
50
|
-
export function ariaLabel(value) {
|
|
51
|
-
return attr('aria-label', value);
|
|
52
|
-
}
|
|
53
|
-
/** Shorthand for `attr('aria-hidden', value)`. */
|
|
54
|
-
export function ariaHidden(value) {
|
|
55
|
-
return attr('aria-hidden', value);
|
|
56
|
-
}
|
|
57
|
-
/** Shorthand for `attr('id', value)`. */
|
|
58
|
-
export function id(value) {
|
|
59
|
-
return attr('id', value);
|
|
60
|
-
}
|
|
61
|
-
export function width(value) {
|
|
62
|
-
return attr('width', value);
|
|
63
|
-
}
|
|
64
|
-
export function height(value) {
|
|
65
|
-
return attr('height', value);
|
|
66
|
-
}
|
|
67
|
-
export function transform(value) {
|
|
68
|
-
return attr('transform', value);
|
|
69
|
-
}
|
|
70
|
-
export function viewBox(value) {
|
|
71
|
-
return attr('viewBox', value);
|
|
72
|
-
}
|
|
73
|
-
export function fill(value) {
|
|
74
|
-
return attr('fill', value);
|
|
75
|
-
}
|
|
76
|
-
export function focusable(value) {
|
|
77
|
-
return attr('focusable', value);
|
|
78
|
-
}
|
|
79
|
-
export function xmlns(value) {
|
|
80
|
-
return attr('xmlns', value);
|
|
81
|
-
}
|
|
82
|
-
export function d(value) {
|
|
83
|
-
return attr('d', value);
|
|
84
|
-
}
|
|
85
|
-
export function stroke(value) {
|
|
86
|
-
return attr('stroke', value);
|
|
87
|
-
}
|
|
88
|
-
export function strokeWidth(value) {
|
|
89
|
-
return attr('stroke-width', value);
|
|
90
|
-
}
|
|
91
|
-
export function strokeLinecap(value) {
|
|
92
|
-
return attr('stroke-linecap', value);
|
|
93
|
-
}
|
|
94
|
-
export function strokeLinejoin(value) {
|
|
95
|
-
return attr('stroke-linejoin', value);
|
|
96
|
-
}
|
|
97
|
-
export function cx(value) {
|
|
98
|
-
return attr('cx', value);
|
|
99
|
-
}
|
|
100
|
-
export function cy(value) {
|
|
101
|
-
return attr('cy', value);
|
|
102
|
-
}
|
|
103
|
-
export function r(value) {
|
|
104
|
-
return attr('r', value);
|
|
105
|
-
}
|
|
106
|
-
export function role(value) {
|
|
107
|
-
return attr('role', value);
|
|
108
|
-
}
|
|
109
|
-
/** Shorthand for `attr('type', value)`. */
|
|
110
|
-
export function typeAttr(value) {
|
|
111
|
-
return attr('type', value);
|
|
112
|
-
}
|
|
113
|
-
/** Shorthand for `attr('class', value)`. */
|
|
114
|
-
export function cls(value) {
|
|
115
|
-
return attr('class', value);
|
|
116
|
-
}
|
|
117
|
-
/** Builds a `class` attribute from a list of conditional class entries. See
|
|
118
|
-
* `classListArg`. */
|
|
119
|
-
export function classList(...classes) {
|
|
120
|
-
const allClasses = [];
|
|
121
|
-
classes.forEach(cls => {
|
|
122
|
-
if (typeof cls === 'string') {
|
|
123
|
-
allClasses.push(cls);
|
|
124
|
-
}
|
|
125
|
-
else {
|
|
126
|
-
if (cls.length == 2) {
|
|
127
|
-
if (cls[0]) {
|
|
128
|
-
allClasses.push(cls[1]);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
else {
|
|
132
|
-
if (cls[0]) {
|
|
133
|
-
allClasses.push(cls[1]);
|
|
134
|
-
}
|
|
135
|
-
else {
|
|
136
|
-
allClasses.push(cls[2]);
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
});
|
|
141
|
-
return cls(allClasses.join(' '));
|
|
142
|
-
}
|
|
143
|
-
export function attrs(attrMap) {
|
|
144
|
-
return Object.entries(attrMap).map(([k, v]) => {
|
|
145
|
-
return attr(k, v);
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
/** Converts a map of CSS custom property names to values into a `style`
|
|
149
|
-
* attribute. */
|
|
150
|
-
export function cssVars(vars) {
|
|
151
|
-
return attr('style', Object.entries(vars)
|
|
152
|
-
.map(([k, v]) => `${k}: ${v}`)
|
|
153
|
-
.join('; '));
|
|
154
|
-
}
|
package/dist/dom/components.d.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { type Effect } from '../effects';
|
|
2
|
-
import type { NodeId } from './nodeid';
|
|
3
|
-
import { type NodeGroup } from './views';
|
|
4
|
-
import { type Node } from './';
|
|
5
|
-
/** A self-contained UI unit with its own state, view, and optional scoped CSS. */
|
|
6
|
-
export type Component<State, Params, Event> = {
|
|
7
|
-
readonly _type: 'Component';
|
|
8
|
-
readonly params: Params;
|
|
9
|
-
readonly css?: string | ((params: Params) => string);
|
|
10
|
-
readonly initialState: (params: Params) => Effect<State, Event, State>;
|
|
11
|
-
view(state: State, params: Params): NodeGroup<State, Event>;
|
|
12
|
-
};
|
|
13
|
-
export type ComponentEventListener<State, Event, ComponentEvent> = (event: ComponentEvent) => Effect<State, Event, void>;
|
|
14
|
-
/** A mounted instance of a Component inside a parent view. */
|
|
15
|
-
export type ComponentElement<State, Event, ComponentState, Params, ComponentEvent> = {
|
|
16
|
-
readonly _type: 'Component';
|
|
17
|
-
readonly nodeId: NodeId;
|
|
18
|
-
readonly component: Component<ComponentState, Params, ComponentEvent>;
|
|
19
|
-
readonly componentEventListeners: readonly ComponentEventListener<State, Event, ComponentEvent>[];
|
|
20
|
-
/** Registers a listener for events fired by the component. */
|
|
21
|
-
onEvent(eventListener: ComponentEventListener<State, Event, ComponentEvent>): ComponentElement<State, Event, ComponentState, Params, ComponentEvent>;
|
|
22
|
-
};
|
|
23
|
-
export declare function componentElem<State, Event, ComponentState, Params, ComponentEvent>(component: Component<ComponentState, Params, ComponentEvent>, nodeId: NodeId, params?: Params): ComponentElement<State, Event, ComponentState, Params, ComponentEvent>;
|
|
24
|
-
/**
|
|
25
|
-
* Creates a `Component` — a self-contained UI unit with its own managed state.
|
|
26
|
-
*
|
|
27
|
-
* The simple overload `component(view, initialState, css?)` is for components
|
|
28
|
-
* that do not accept external configuration. The params overload
|
|
29
|
-
* `component(view, initialStateFactory, params, css?)` is for components that
|
|
30
|
-
* accept a `Params` value from their parent, which is passed to both `view` and
|
|
31
|
-
* the initial-state factory on mount.
|
|
32
|
-
*
|
|
33
|
-
* The runtime calls `view(state, params)` whenever state changes and diffs the
|
|
34
|
-
* result against the previous virtual DOM to update the browser.
|
|
35
|
-
*
|
|
36
|
-
* @param css Optional scoped CSS string (or a function of params returning one)
|
|
37
|
-
* that is injected into a `<style>` element inside the component's shadow root.
|
|
38
|
-
*/
|
|
39
|
-
export declare function component<State, Event>(view: (state: State) => Node<State, Event> | NodeGroup<State, Event>, initialState: State | Effect<State, Event, State>, css?: string): Component<State, void, Event>;
|
|
40
|
-
export declare function component<State, Params, Event>(view: (state: State, params: Params) => Node<State, Event> | NodeGroup<State, Event>, initialState: (params: Params) => State | Effect<State, Event, State>, params: Params, css?: string | ((params: Params) => string)): Component<State, Params, Event>;
|
|
41
|
-
/** Creates a root-level Component with no params or events. Convenience wrapper for `component`. */
|
|
42
|
-
export declare function application<State>(view: (state: State) => Node<State, never> | NodeGroup<State, never>, initialState: State | Effect<State, never, State>): Component<State, void, never>;
|
|
43
|
-
//# sourceMappingURL=components.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"components.d.ts","sourceRoot":"","sources":["../../src/dom/components.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,MAAM,EAAE,MAAM,YAAY,CAAA;AACxD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACtC,OAAO,EAAa,KAAK,SAAS,EAAE,MAAM,SAAS,CAAA;AACnD,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,IAAI,CAAA;AAE9B,kFAAkF;AAClF,MA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AE,KAAK,CAAC,GAAG,SAAS,CAAC,KAAK,EAAE,KAAK,CAAC,EACpE,YAAY,EAAE,KAAK,GAAG,MAAM,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,GAChD,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,CAAC,CAE/B"}
|
package/dist/dom/components.js
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import { isEffect, pure } from '../effects';
|
|
2
|
-
import { nodeGroup } from './views';
|
|
3
|
-
import {} from './';
|
|
4
|
-
export function componentElem(component, nodeId, params) {
|
|
5
|
-
const resolvedComponent = params !== undefined ? { ...component, params } : component;
|
|
6
|
-
return {
|
|
7
|
-
_type: 'Component',
|
|
8
|
-
nodeId,
|
|
9
|
-
component: resolvedComponent,
|
|
10
|
-
componentEventListeners: [],
|
|
11
|
-
onEvent(eventListener) {
|
|
12
|
-
const eventListeners = this.componentEventListeners;
|
|
13
|
-
return {
|
|
14
|
-
...this,
|
|
15
|
-
componentEventListeners: [...eventListeners, eventListener],
|
|
16
|
-
};
|
|
17
|
-
},
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
function toComponent(view, initialState, params, css) {
|
|
21
|
-
return {
|
|
22
|
-
_type: 'Component',
|
|
23
|
-
params,
|
|
24
|
-
css,
|
|
25
|
-
initialState(params) {
|
|
26
|
-
const result = initialState(params);
|
|
27
|
-
if (isEffect(result)) {
|
|
28
|
-
return result;
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
31
|
-
return pure(result);
|
|
32
|
-
}
|
|
33
|
-
},
|
|
34
|
-
view(state, params) {
|
|
35
|
-
const result = view(state, params);
|
|
36
|
-
if (typeof result === 'object' && result._type === 'NodeGroup') {
|
|
37
|
-
return result;
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
return nodeGroup(result);
|
|
41
|
-
}
|
|
42
|
-
},
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
// no params component
|
|
46
|
-
function toSimpleComponent(view, initialState, css) {
|
|
47
|
-
return {
|
|
48
|
-
_type: 'Component',
|
|
49
|
-
css,
|
|
50
|
-
initialState: () => {
|
|
51
|
-
if (isEffect(initialState)) {
|
|
52
|
-
return initialState;
|
|
53
|
-
}
|
|
54
|
-
else {
|
|
55
|
-
return pure(initialState);
|
|
56
|
-
}
|
|
57
|
-
},
|
|
58
|
-
view: (state) => {
|
|
59
|
-
const result = view(state);
|
|
60
|
-
if (typeof result === 'object' && result['_type'] === 'NodeGroup') {
|
|
61
|
-
return result;
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
return nodeGroup(result);
|
|
65
|
-
}
|
|
66
|
-
},
|
|
67
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
68
|
-
params: undefined,
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
export function component(...args) {
|
|
72
|
-
if (args.length <= 3 &&
|
|
73
|
-
(args.length < 3 || typeof args[2] === 'string' || args[2] === undefined)) {
|
|
74
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
75
|
-
const [view, initialState, css] = args;
|
|
76
|
-
return toSimpleComponent(view, initialState, css);
|
|
77
|
-
}
|
|
78
|
-
else {
|
|
79
|
-
const [view, initialState, params, css] = args;
|
|
80
|
-
return toComponent(view, initialState, params, css);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
/** Creates a root-level Component with no params or events. Convenience wrapper for `component`. */
|
|
84
|
-
export function application(view, initialState) {
|
|
85
|
-
return toSimpleComponent(view, initialState);
|
|
86
|
-
}
|