jaxs 0.5.0 → 0.6.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/dist/jaxs.d.ts +53 -75
- package/dist/jaxs.js +477 -499
- package/dist/jaxs.umd.cjs +297 -324
- package/package.json +1 -1
package/dist/jaxs.d.ts
CHANGED
|
@@ -12,28 +12,51 @@ declare module 'state/equality' {
|
|
|
12
12
|
export const areArraysEqual: (oldValue: any[], newValue: any[]) => any
|
|
13
13
|
export const areEqual: (oldValue: any, newValue: any) => any
|
|
14
14
|
}
|
|
15
|
-
declare module 'state/store
|
|
15
|
+
declare module 'state/store' {
|
|
16
16
|
import type {
|
|
17
|
-
|
|
17
|
+
State,
|
|
18
|
+
StoreInitializationOptions,
|
|
18
19
|
StoreUpdaterOrValue,
|
|
19
|
-
|
|
20
|
-
StoreUpdatersCollection,
|
|
20
|
+
StoreUpdater,
|
|
21
21
|
} from 'types'
|
|
22
|
+
export class Store<T> {
|
|
23
|
+
parent: State
|
|
24
|
+
name: string
|
|
25
|
+
updater: StoreUpdater<T>
|
|
26
|
+
_value: T
|
|
27
|
+
initialValue: T
|
|
28
|
+
constructor(options: StoreInitializationOptions<T>)
|
|
29
|
+
get ['value'](): T
|
|
30
|
+
set ['value'](value: T)
|
|
31
|
+
reset(): void
|
|
32
|
+
update(updater: StoreUpdaterOrValue<T>): void
|
|
33
|
+
private updateValue
|
|
34
|
+
private getUpdatedValue
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
declare module 'state/store-updater' {
|
|
38
|
+
import type { Store, StoreUpdaterOrValue } from 'types'
|
|
22
39
|
export class StoreUpdaterBase<T> {
|
|
23
40
|
store: Store<T>
|
|
24
41
|
constructor(store: Store<T>)
|
|
25
42
|
update(updater: StoreUpdaterOrValue<T>): void
|
|
26
43
|
reset(): void
|
|
27
44
|
get value(): T
|
|
28
|
-
addUpdaterFunction(name: string, updater: StoreUpdaterFunction<T>): void
|
|
29
|
-
addUpdaterFunctions(updaters: StoreUpdatersCollection<T>): void
|
|
30
45
|
}
|
|
31
46
|
}
|
|
47
|
+
declare module 'state/updaters/object' {
|
|
48
|
+
import { Store } from 'types'
|
|
49
|
+
import { StoreUpdaterBase } from 'state/store-updater'
|
|
50
|
+
export class StoreUpdaterObject<T> extends StoreUpdaterBase<T> {
|
|
51
|
+
updateAttribute(name: keyof T, value: T[keyof T]): void
|
|
52
|
+
resetAttribute(name: keyof T): void
|
|
53
|
+
}
|
|
54
|
+
export const objectUpdater: <T>(store: Store<T>) => StoreUpdaterObject<T>
|
|
55
|
+
}
|
|
32
56
|
declare module 'state/updaters/list' {
|
|
33
|
-
import { StoreListSorterFunction,
|
|
57
|
+
import { StoreListSorterFunction, Store } from 'types'
|
|
34
58
|
import { StoreUpdaterBase } from 'state/store-updater'
|
|
35
59
|
export class StoreUpdaterList<T> extends StoreUpdaterBase<T[]> {
|
|
36
|
-
addUpdaterFunction(name: string, updater: StoreUpdaterFunction<T[]>): void
|
|
37
60
|
push(element: T): void
|
|
38
61
|
pop(): T
|
|
39
62
|
unshift(element: T): void
|
|
@@ -41,68 +64,42 @@ declare module 'state/updaters/list' {
|
|
|
41
64
|
addSorter(name: string, sorter: StoreListSorterFunction<T>): void
|
|
42
65
|
sortBy(sorter: StoreListSorterFunction<T>): void
|
|
43
66
|
insertAt(index: number, item: T): void
|
|
67
|
+
remove(value: T): void
|
|
68
|
+
removeBy(matcherFunction: (value: T) => boolean): void
|
|
44
69
|
}
|
|
45
|
-
|
|
46
|
-
declare module 'state/store' {
|
|
47
|
-
import type {
|
|
48
|
-
State,
|
|
49
|
-
StoreDataUpdater,
|
|
50
|
-
StoreInitializationOptions,
|
|
51
|
-
StoreListSorterFunction,
|
|
52
|
-
StoreUpdaterFunction,
|
|
53
|
-
StoreUpdaterOrValue,
|
|
54
|
-
StoreUpdatersCollection,
|
|
55
|
-
StoreUpdater,
|
|
56
|
-
} from 'types'
|
|
57
|
-
export class Store<T> {
|
|
58
|
-
parent: State
|
|
59
|
-
name: string
|
|
60
|
-
updater: StoreUpdater<T>
|
|
61
|
-
_value: T
|
|
62
|
-
initialState: T
|
|
63
|
-
constructor(options: StoreInitializationOptions<T>)
|
|
64
|
-
get ['value'](): T
|
|
65
|
-
set ['value'](value: T)
|
|
66
|
-
update(updater: StoreUpdaterOrValue<T>): void
|
|
67
|
-
updateValue(newValue: T): void
|
|
68
|
-
getUpdatedValue(updater: StoreDataUpdater<T>): T
|
|
69
|
-
addUpdaters(updaters: StoreUpdatersCollection<any>): void
|
|
70
|
-
addUpdater(name: string, updater: StoreUpdaterFunction<any>): void
|
|
71
|
-
addSorter(name: string, sorter: StoreListSorterFunction<T>): void
|
|
72
|
-
}
|
|
70
|
+
export const listUpdater: <T>(store: Store<T[]>) => StoreUpdaterList<T>
|
|
73
71
|
}
|
|
74
72
|
declare module 'state/updaters/boolean' {
|
|
75
|
-
import {
|
|
73
|
+
import { Store } from 'types'
|
|
76
74
|
import { StoreUpdaterBase } from 'state/store-updater'
|
|
77
75
|
export class StoreUpdaterBoolean extends StoreUpdaterBase<boolean> {
|
|
78
76
|
toggle(): void
|
|
79
77
|
setTrue(): void
|
|
80
78
|
setFalse(): void
|
|
81
|
-
addUpdaterFunction(
|
|
82
|
-
name: string,
|
|
83
|
-
updater: StoreUpdaterFunction<boolean>,
|
|
84
|
-
): void
|
|
85
79
|
}
|
|
80
|
+
export const booleanUpdater: (store: Store<boolean>) => StoreUpdaterBoolean
|
|
86
81
|
}
|
|
87
|
-
declare module 'state/updaters
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
82
|
+
declare module 'state/updaters' {
|
|
83
|
+
export const updaters: {
|
|
84
|
+
object: <T>(
|
|
85
|
+
store: import('state').Store<T>,
|
|
86
|
+
) => import('state/updaters/object').StoreUpdaterObject<T>
|
|
87
|
+
list: <T>(
|
|
88
|
+
store: import('state').Store<T[]>,
|
|
89
|
+
) => import('state/updaters/list').StoreUpdaterList<T>
|
|
90
|
+
boolean: (
|
|
91
|
+
store: import('state').Store<boolean>,
|
|
92
|
+
) => import('state/updaters/boolean').StoreUpdaterBoolean
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
declare module 'state/index' {
|
|
96
96
|
import { Store } from 'state/store'
|
|
97
|
-
import { StoreUpdaterBoolean } from 'state/updaters/boolean'
|
|
98
|
-
import { StoreUpdaterList } from 'state/updaters/list'
|
|
99
|
-
import { StoreUpdaterObject } from 'state/updaters/object'
|
|
100
97
|
import type {
|
|
101
98
|
StatePublisher,
|
|
102
99
|
StateTransactionUpdater,
|
|
103
100
|
StoresCollection,
|
|
104
|
-
StoreValue,
|
|
105
101
|
} from 'types'
|
|
102
|
+
import { updaters } from 'state/updaters'
|
|
106
103
|
export const eventName = 'state'
|
|
107
104
|
export class State {
|
|
108
105
|
publisher: StatePublisher
|
|
@@ -112,11 +109,8 @@ declare module 'state/index' {
|
|
|
112
109
|
inTransaction: boolean
|
|
113
110
|
constructor(publisher: StatePublisher)
|
|
114
111
|
create<T>(name: string, initialState: T): Store<T>
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
createList<T>(name: string, initialState: T[]): Store<T[]>
|
|
118
|
-
store(name: string): Store<any>
|
|
119
|
-
get(name: string): StoreValue
|
|
112
|
+
store<T>(name: string): Store<T>
|
|
113
|
+
get<T>(name: string): T
|
|
120
114
|
getAll(names: string[]): {}
|
|
121
115
|
notify(name: string): void
|
|
122
116
|
update(name: string, newValue: any): void
|
|
@@ -126,7 +120,7 @@ declare module 'state/index' {
|
|
|
126
120
|
event(name: string): string
|
|
127
121
|
}
|
|
128
122
|
export const createState: (publisher: StatePublisher) => State
|
|
129
|
-
export { Store,
|
|
123
|
+
export { Store, updaters }
|
|
130
124
|
}
|
|
131
125
|
declare module 'bus/exact-subscriptions' {
|
|
132
126
|
import { ExactSubscriptionData, BusListener, Unsubscribe } from 'types'
|
|
@@ -219,6 +213,7 @@ declare module 'rendering/templates/root' {
|
|
|
219
213
|
}
|
|
220
214
|
declare module 'navigation/events' {
|
|
221
215
|
export const linkNavigationEvent = 'go-to-href'
|
|
216
|
+
export const navigationEvent = 'go-to'
|
|
222
217
|
export const locationChangeEvent = 'navigation:location-change'
|
|
223
218
|
export const routeChangeEvent = 'navigation:route-change'
|
|
224
219
|
}
|
|
@@ -430,17 +425,8 @@ declare module 'types' {
|
|
|
430
425
|
}
|
|
431
426
|
export type ChangeInstructions = Array<ChangeInstruction>
|
|
432
427
|
export type InstructionsUpdater = (instruction: ChangeInstruction) => void
|
|
433
|
-
export type StoreValue =
|
|
434
|
-
| string
|
|
435
|
-
| number
|
|
436
|
-
| boolean
|
|
437
|
-
| null
|
|
438
|
-
| StoreValue[]
|
|
439
|
-
| {
|
|
440
|
-
[key: string]: StoreValue
|
|
441
|
-
}
|
|
442
428
|
export type StoreMap = {
|
|
443
|
-
[key: string]:
|
|
429
|
+
[key: string]: any
|
|
444
430
|
}
|
|
445
431
|
export type ViewModel<ATTRIBUTES, STORE_MAP> = (
|
|
446
432
|
storeMap: STORE_MAP,
|
|
@@ -508,14 +494,6 @@ declare module 'types' {
|
|
|
508
494
|
export type StoreDataUpdater<T> = (originalValue: T) => T
|
|
509
495
|
export type UpdaterValue<T> = boolean | T | T[]
|
|
510
496
|
export type StoreUpdaterOrValue<T> = UpdaterValue<T> | StoreDataUpdater<T>
|
|
511
|
-
export type StoreUpdaterFunction<T> = (
|
|
512
|
-
value: UpdaterValue<T>,
|
|
513
|
-
...args: any[]
|
|
514
|
-
) => T
|
|
515
|
-
export type StoreUpdatersCollection<T> = Record<
|
|
516
|
-
string,
|
|
517
|
-
StoreUpdaterFunction<T>
|
|
518
|
-
>
|
|
519
497
|
export type StoreListSorterFunction<T> = (left: T, right: T) => number
|
|
520
498
|
export type RouteMatcher = (routeState: RouteState) => boolean
|
|
521
499
|
export type RenderedRoute = {
|