jaxs 0.4.0 → 0.4.3
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 +250 -243
- package/dist/jaxs.js +369 -289
- package/dist/jaxs.umd.cjs +1 -1
- package/package.json +1 -1
package/dist/jaxs.d.ts
CHANGED
|
@@ -13,112 +13,229 @@ declare module "state/equality" {
|
|
|
13
13
|
export const areEqual: (oldValue: any, newValue: any) => any;
|
|
14
14
|
}
|
|
15
15
|
declare module "state/store-updater" {
|
|
16
|
-
import type {
|
|
17
|
-
export class
|
|
18
|
-
store:
|
|
19
|
-
constructor(store:
|
|
20
|
-
update(updater:
|
|
16
|
+
import type { Store, StoreUpdaterOrValue, StoreUpdaterFunction, StoreUpdatersCollection } from "types";
|
|
17
|
+
export class StoreUpdaterBase<T> {
|
|
18
|
+
store: Store<T>;
|
|
19
|
+
constructor(store: Store<T>);
|
|
20
|
+
update(updater: StoreUpdaterOrValue<T>): void;
|
|
21
21
|
reset(): void;
|
|
22
22
|
get value(): T;
|
|
23
|
-
addUpdaterFunction(name: string, updater:
|
|
24
|
-
addUpdaterFunctions(updaters:
|
|
23
|
+
addUpdaterFunction(name: string, updater: StoreUpdaterFunction<T>): void;
|
|
24
|
+
addUpdaterFunctions(updaters: StoreUpdatersCollection<T>): void;
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
declare module "state/updaters/list" {
|
|
28
|
-
import {
|
|
29
|
-
|
|
30
|
-
export class
|
|
28
|
+
import { StoreListSorterFunction, StoreUpdaterFunction } from "types";
|
|
29
|
+
import { StoreUpdaterBase } from "state/store-updater";
|
|
30
|
+
export class StoreUpdaterList<T> extends StoreUpdaterBase<T[]> {
|
|
31
|
+
addUpdaterFunction(name: string, updater: StoreUpdaterFunction<T[]>): void;
|
|
31
32
|
push(element: T): void;
|
|
32
33
|
pop(): T;
|
|
33
34
|
unshift(element: T): void;
|
|
34
35
|
shift(): T;
|
|
35
|
-
addSorter(name: string, sorter:
|
|
36
|
-
sortBy(sorter:
|
|
36
|
+
addSorter(name: string, sorter: StoreListSorterFunction<T>): void;
|
|
37
|
+
sortBy(sorter: StoreListSorterFunction<T>): void;
|
|
37
38
|
insertAt(index: number, item: T): void;
|
|
38
39
|
}
|
|
39
40
|
}
|
|
40
41
|
declare module "state/store" {
|
|
41
|
-
import type {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
parent: JaxsState;
|
|
47
|
-
value: T;
|
|
48
|
-
};
|
|
49
|
-
type JaxsStoreDataUpdater<T> = (originalValue: T) => T;
|
|
50
|
-
export type JaxsStoreUpdateValue<T> = T | JaxsStoreDataUpdater<T>;
|
|
51
|
-
export type JaxsStoreUpdaterFunction<T> = (value: T, ...args: any[]) => T;
|
|
52
|
-
export type JaxStoreUpdatersCollection<T> = Record<string, JaxsStoreUpdaterFunction<T>>;
|
|
53
|
-
export class JaxsStore<T> {
|
|
54
|
-
parent: JaxsState;
|
|
55
|
-
name: JaxsStoreName;
|
|
56
|
-
updater: JaxsStoreUpdater<T>;
|
|
42
|
+
import type { State, StoreDataUpdater, StoreInitializationOptions, StoreListSorterFunction, StoreUpdaterFunction, StoreUpdaterOrValue, StoreUpdatersCollection, StoreUpdater } from "types";
|
|
43
|
+
export class Store<T> {
|
|
44
|
+
parent: State;
|
|
45
|
+
name: string;
|
|
46
|
+
updater: StoreUpdater<T>;
|
|
57
47
|
_value: T;
|
|
58
48
|
initialState: T;
|
|
59
|
-
constructor(options:
|
|
49
|
+
constructor(options: StoreInitializationOptions<T>);
|
|
60
50
|
get ['value'](): T;
|
|
61
51
|
set ['value'](value: T);
|
|
62
|
-
update(updater:
|
|
52
|
+
update(updater: StoreUpdaterOrValue<T>): void;
|
|
63
53
|
updateValue(newValue: T): void;
|
|
64
|
-
getUpdatedValue(updater:
|
|
65
|
-
addUpdaters(updaters:
|
|
66
|
-
addUpdater(name: string, updater:
|
|
67
|
-
addSorter(name: string, sorter:
|
|
54
|
+
getUpdatedValue(updater: StoreDataUpdater<T>): T;
|
|
55
|
+
addUpdaters(updaters: StoreUpdatersCollection<any>): void;
|
|
56
|
+
addUpdater(name: string, updater: StoreUpdaterFunction<any>): void;
|
|
57
|
+
addSorter(name: string, sorter: StoreListSorterFunction<T>): void;
|
|
68
58
|
}
|
|
69
59
|
}
|
|
70
60
|
declare module "state/updaters/boolean" {
|
|
71
|
-
import {
|
|
72
|
-
|
|
61
|
+
import { StoreUpdaterFunction } from "types";
|
|
62
|
+
import { StoreUpdaterBase } from "state/store-updater";
|
|
63
|
+
export class StoreUpdaterBoolean extends StoreUpdaterBase<boolean> {
|
|
73
64
|
toggle(): void;
|
|
74
65
|
setTrue(): void;
|
|
75
66
|
setFalse(): void;
|
|
67
|
+
addUpdaterFunction(name: string, updater: StoreUpdaterFunction<boolean>): void;
|
|
76
68
|
}
|
|
77
69
|
}
|
|
78
70
|
declare module "state/updaters/object" {
|
|
79
|
-
import {
|
|
80
|
-
|
|
71
|
+
import { StoreUpdaterFunction } from "types";
|
|
72
|
+
import { StoreUpdaterBase } from "state/store-updater";
|
|
73
|
+
export class StoreUpdaterObject<T> extends StoreUpdaterBase<T> {
|
|
74
|
+
addUpdaterFunction(name: string, updater: StoreUpdaterFunction<T>): void;
|
|
81
75
|
updateAttribute(name: keyof T, value: T[keyof T]): void;
|
|
82
76
|
}
|
|
83
77
|
}
|
|
84
78
|
declare module "state/index" {
|
|
85
|
-
import {
|
|
86
|
-
import {
|
|
87
|
-
import {
|
|
88
|
-
import {
|
|
89
|
-
import type { StoreValue } from "types";
|
|
90
|
-
export { JaxsStoreUpdater } from "state/store-updater";
|
|
91
|
-
export type JaxsStatePublisher = (event: string, payload: any) => void;
|
|
92
|
-
export type JaxsStateTransactionUpdater = (collection: JaxsStoresCollection) => void;
|
|
93
|
-
export type JaxsStoreName = string;
|
|
94
|
-
type JaxsStoresCollection = Record<string, JaxsStore<any>>;
|
|
79
|
+
import { Store } from "state/store";
|
|
80
|
+
import { StoreUpdaterBoolean } from "state/updaters/boolean";
|
|
81
|
+
import { StoreUpdaterList } from "state/updaters/list";
|
|
82
|
+
import { StoreUpdaterObject } from "state/updaters/object";
|
|
83
|
+
import type { StatePublisher, StateTransactionUpdater, StoresCollection, StoreValue } from "types";
|
|
95
84
|
export const eventName = "state";
|
|
96
|
-
export class
|
|
97
|
-
publisher:
|
|
98
|
-
stores:
|
|
85
|
+
export class State {
|
|
86
|
+
publisher: StatePublisher;
|
|
87
|
+
stores: StoresCollection;
|
|
99
88
|
eventNamePrefix: string;
|
|
100
|
-
notifications: Set<
|
|
89
|
+
notifications: Set<string>;
|
|
101
90
|
inTransaction: boolean;
|
|
102
|
-
constructor(publisher:
|
|
103
|
-
create<T>(name:
|
|
104
|
-
createBoolean(name:
|
|
105
|
-
createRecord<T>(name:
|
|
106
|
-
createList<T>(name:
|
|
107
|
-
store(name:
|
|
108
|
-
get(name:
|
|
109
|
-
getAll(names:
|
|
110
|
-
notify(name:
|
|
111
|
-
update(name:
|
|
112
|
-
transaction(updater:
|
|
91
|
+
constructor(publisher: StatePublisher);
|
|
92
|
+
create<T>(name: string, initialState: T): Store<T>;
|
|
93
|
+
createBoolean(name: string, initialState: boolean): Store<boolean>;
|
|
94
|
+
createRecord<T>(name: string, initialState: T): Store<T>;
|
|
95
|
+
createList<T>(name: string, initialState: T[]): Store<T[]>;
|
|
96
|
+
store(name: string): Store<any>;
|
|
97
|
+
get(name: string): StoreValue;
|
|
98
|
+
getAll(names: string[]): {};
|
|
99
|
+
notify(name: string): void;
|
|
100
|
+
update(name: string, newValue: any): void;
|
|
101
|
+
transaction(updater: StateTransactionUpdater): void;
|
|
113
102
|
publishAll(): void;
|
|
114
|
-
publish(name:
|
|
115
|
-
event(name:
|
|
103
|
+
publish(name: string): void;
|
|
104
|
+
event(name: string): string;
|
|
105
|
+
}
|
|
106
|
+
export const createState: (publisher: StatePublisher) => State;
|
|
107
|
+
export { Store, StoreUpdaterBoolean, StoreUpdaterList, StoreUpdaterObject };
|
|
108
|
+
}
|
|
109
|
+
declare module "bus/exact-subscriptions" {
|
|
110
|
+
import { ExactSubscriptionData, BusListener, Unsubscribe } from "types";
|
|
111
|
+
export class ExactSubscriptions {
|
|
112
|
+
lookup: Record<string, ExactSubscriptionData<any>[]>;
|
|
113
|
+
constructor();
|
|
114
|
+
add<T>(matcher: string, listener: BusListener<T>, index: number): Unsubscribe;
|
|
115
|
+
remove<T>(subscription: ExactSubscriptionData<T>): void;
|
|
116
|
+
matches(event: string): ExactSubscriptionData<any>[];
|
|
117
|
+
ensureArrayFor(matcher: string): void;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
declare module "bus/fuzzy-subscriptions" {
|
|
121
|
+
import { FuzzySubscriptionData, BusListener, Unsubscribe } from "types";
|
|
122
|
+
export class FuzzySubscriptions {
|
|
123
|
+
lookup: FuzzySubscriptionData<any>[];
|
|
124
|
+
constructor();
|
|
125
|
+
add<T>(matcher: RegExp, listener: BusListener<T>, index: number): Unsubscribe;
|
|
126
|
+
remove<T>(subscription: FuzzySubscriptionData<T>): void;
|
|
127
|
+
matches(event: string): FuzzySubscriptionData<any>[];
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
declare module "bus/index" {
|
|
131
|
+
import { BusEventMatcher, BusListener, Unsubscribe, AppAdditionListenerOptions, BusOptions } from "types";
|
|
132
|
+
import { ExactSubscriptions } from "bus/exact-subscriptions";
|
|
133
|
+
import { FuzzySubscriptions } from "bus/fuzzy-subscriptions";
|
|
134
|
+
class JaxsBus {
|
|
135
|
+
options?: AppAdditionListenerOptions;
|
|
136
|
+
exactSubscriptions: ExactSubscriptions;
|
|
137
|
+
fuzzySubscriptions: FuzzySubscriptions;
|
|
138
|
+
currentIndex: number;
|
|
139
|
+
constructor();
|
|
140
|
+
subscribe<T>(matcher: BusEventMatcher, listener: BusListener<T>): Unsubscribe;
|
|
141
|
+
publish<T>(event: string, payload: T): void;
|
|
142
|
+
addListenerOptions(options: AppAdditionListenerOptions): void;
|
|
143
|
+
listenerOptions(event: string): BusOptions;
|
|
144
|
+
}
|
|
145
|
+
const createBus: () => {
|
|
146
|
+
bus: JaxsBus;
|
|
147
|
+
publish: (event: string, payload: any) => void;
|
|
148
|
+
subscribe: (matcher: BusEventMatcher, listener: BusListener<any>) => Unsubscribe;
|
|
149
|
+
};
|
|
150
|
+
export { createBus, JaxsBus, ExactSubscriptions, FuzzySubscriptions };
|
|
151
|
+
}
|
|
152
|
+
declare module "rendering/templates/root" {
|
|
153
|
+
import type { JaxsElement, JaxsNodes, RenderKit, Renderable, JaxsNode } from "types";
|
|
154
|
+
export class Root {
|
|
155
|
+
template: Renderable;
|
|
156
|
+
selector: string;
|
|
157
|
+
renderKit: RenderKit;
|
|
158
|
+
dom: JaxsNodes;
|
|
159
|
+
parentElement?: JaxsElement | null;
|
|
160
|
+
constructor(template: Renderable, selector: string, renderKit: RenderKit);
|
|
161
|
+
renderAndAttach(renderKit: RenderKit): void;
|
|
162
|
+
render(renderKit: RenderKit): JaxsNode[];
|
|
163
|
+
attach(): void;
|
|
164
|
+
getParentElement(): Element;
|
|
165
|
+
}
|
|
166
|
+
export const render: (template: Renderable, selector: string, renderKit: RenderKit) => Root;
|
|
167
|
+
}
|
|
168
|
+
declare module "navigation/events" {
|
|
169
|
+
export const linkNavigationEvent = "go-to-href";
|
|
170
|
+
export const locationChangeEvent = "navigation:location-change";
|
|
171
|
+
export const routeChangeEvent = "navigation:route-change";
|
|
172
|
+
}
|
|
173
|
+
declare module "navigation/route-state" {
|
|
174
|
+
import { State } from "state/index";
|
|
175
|
+
export const createRouteState: (state: State) => void;
|
|
176
|
+
}
|
|
177
|
+
declare module "navigation/find-href" {
|
|
178
|
+
export const findHref: (node: HTMLElement) => string;
|
|
179
|
+
}
|
|
180
|
+
declare module "navigation/navigate" {
|
|
181
|
+
import { BusOptions } from "types";
|
|
182
|
+
export const navigate: (path: string, { publish, window }: BusOptions) => void;
|
|
183
|
+
}
|
|
184
|
+
declare module "navigation/on-link-click" {
|
|
185
|
+
import { BusOptions } from "types";
|
|
186
|
+
export const onLinkClick: (domEvent: MouseEvent, options: BusOptions) => void;
|
|
187
|
+
}
|
|
188
|
+
declare module "navigation/extract-query-params" {
|
|
189
|
+
export const extractQueryParams: (queryString: string) => {};
|
|
190
|
+
}
|
|
191
|
+
declare module "navigation/on-location-change" {
|
|
192
|
+
import { BusOptions } from "types";
|
|
193
|
+
export const onLocationChange: (_: null, listenerOptions: BusOptions) => void;
|
|
194
|
+
}
|
|
195
|
+
declare module "navigation/start" {
|
|
196
|
+
import type { App } from "app/index";
|
|
197
|
+
export const subscribeToNavigation: (app: App) => void;
|
|
198
|
+
export const subscribeToHistoryChange: (app: App) => void;
|
|
199
|
+
export const publishLocation: (app: App) => void;
|
|
200
|
+
export const startNavigation: (app: App) => void;
|
|
201
|
+
}
|
|
202
|
+
declare module "app/index" {
|
|
203
|
+
import type { Renderable, RenderKit, Subscribe, PublishFunction } from "types";
|
|
204
|
+
import type { State } from "state/index";
|
|
205
|
+
import type { JaxsBus } from "bus/index";
|
|
206
|
+
import { Root } from "rendering/templates/root";
|
|
207
|
+
export class App {
|
|
208
|
+
window: Window;
|
|
209
|
+
document: Document;
|
|
210
|
+
publish: PublishFunction<any>;
|
|
211
|
+
subscribe: Subscribe;
|
|
212
|
+
bus: JaxsBus;
|
|
213
|
+
state: State;
|
|
214
|
+
renderKit: RenderKit;
|
|
215
|
+
roots: Root[];
|
|
216
|
+
constructor({ window, document, publish, subscribe, bus, state, renderKit }: {
|
|
217
|
+
window: any;
|
|
218
|
+
document: any;
|
|
219
|
+
publish: any;
|
|
220
|
+
subscribe: any;
|
|
221
|
+
bus: any;
|
|
222
|
+
state: any;
|
|
223
|
+
renderKit: any;
|
|
224
|
+
});
|
|
225
|
+
render(template: Renderable, selector: string): Root;
|
|
226
|
+
startNavigation(): void;
|
|
116
227
|
}
|
|
117
|
-
export const createState: (publisher: JaxsStatePublisher) => JaxsState;
|
|
118
|
-
export { JaxsStore, BooleanUpdater, ListUpdater, ObjectUpdater };
|
|
119
228
|
}
|
|
120
229
|
declare module "types" {
|
|
121
|
-
import {
|
|
230
|
+
import type { State } from "state/index";
|
|
231
|
+
import type { Store } from "state/store";
|
|
232
|
+
import type { StoreUpdaterBase } from "state/store-updater";
|
|
233
|
+
import type { StoreUpdaterBoolean } from "state/updaters/boolean";
|
|
234
|
+
import type { StoreUpdaterList } from "state/updaters/list";
|
|
235
|
+
import type { StoreUpdaterObject } from "state/updaters/object";
|
|
236
|
+
export type { App } from "app/index";
|
|
237
|
+
export { State, Store, StoreUpdaterBase, StoreUpdaterBoolean, StoreUpdaterList, StoreUpdaterObject, };
|
|
238
|
+
export type StoreUpdater<T> = StoreUpdaterBase<T> | StoreUpdaterObject<T> | StoreUpdaterBoolean | StoreUpdaterList<T>;
|
|
122
239
|
export type TextValue = string | number;
|
|
123
240
|
export interface JsxIded {
|
|
124
241
|
__jsx?: string;
|
|
@@ -132,9 +249,9 @@ declare module "types" {
|
|
|
132
249
|
busEvent: string;
|
|
133
250
|
listener: EventListener;
|
|
134
251
|
};
|
|
135
|
-
export type
|
|
252
|
+
export type EventMaps = Record<string, EventMap>;
|
|
136
253
|
interface JsxEventMapped {
|
|
137
|
-
eventMaps:
|
|
254
|
+
eventMaps: EventMaps;
|
|
138
255
|
}
|
|
139
256
|
export type JaxsElement = Element & JsxIded & JsxEventMapped;
|
|
140
257
|
export type JaxsText = Text & JsxIded;
|
|
@@ -163,22 +280,21 @@ declare module "types" {
|
|
|
163
280
|
events: TagEventAttributes;
|
|
164
281
|
};
|
|
165
282
|
export type DomPublish = (eventName: string, domEvent: Event) => void;
|
|
166
|
-
export type Subscribe = (matcher:
|
|
283
|
+
export type Subscribe = (matcher: BusEventMatcher, listener: BusListener<any>) => void;
|
|
167
284
|
export type RenderKit = {
|
|
168
285
|
document: Document;
|
|
169
286
|
window: Window;
|
|
170
287
|
publish: DomPublish;
|
|
171
288
|
subscribe: Subscribe;
|
|
172
|
-
state:
|
|
289
|
+
state: State;
|
|
173
290
|
parent?: JaxsNode | null;
|
|
174
291
|
};
|
|
175
292
|
export interface Renderable {
|
|
176
293
|
render: (renderKit: RenderKit, parentElement?: JaxsElement) => JaxsNode[];
|
|
177
|
-
isSvg: boolean;
|
|
178
294
|
}
|
|
179
295
|
export type StaticTemplate = () => Renderable;
|
|
180
296
|
export type TypedTemplate<T> = (props: Props<T>) => Renderable;
|
|
181
|
-
export type
|
|
297
|
+
export type Template<T> = StaticTemplate | TypedTemplate<T>;
|
|
182
298
|
export type JsxCollection = (Renderable | TextValue)[];
|
|
183
299
|
export enum ChangeInstructionTypes {
|
|
184
300
|
removeNode = 0,
|
|
@@ -215,8 +331,8 @@ declare module "types" {
|
|
|
215
331
|
parent: JaxsElement;
|
|
216
332
|
index: number;
|
|
217
333
|
};
|
|
218
|
-
type
|
|
219
|
-
export type InstructionData = RemoveInstructionData | AttributeInstructionData | EventInstructionData | UpdateEventInstructionData | InsertNodeData |
|
|
334
|
+
type NullInstructionData = Record<string, never>;
|
|
335
|
+
export type InstructionData = RemoveInstructionData | AttributeInstructionData | EventInstructionData | UpdateEventInstructionData | InsertNodeData | NullInstructionData;
|
|
220
336
|
export type ChangeInstruction = {
|
|
221
337
|
source: JaxsNode;
|
|
222
338
|
target: JaxsNode;
|
|
@@ -224,44 +340,75 @@ declare module "types" {
|
|
|
224
340
|
data: InstructionData;
|
|
225
341
|
};
|
|
226
342
|
export type ChangeInstructions = Array<ChangeInstruction>;
|
|
227
|
-
export type
|
|
343
|
+
export type InstructionsUpdater = (instruction: ChangeInstruction) => void;
|
|
228
344
|
export type StoreValue = string | number | boolean | null | StoreValue[] | {
|
|
229
345
|
[key: string]: StoreValue;
|
|
230
346
|
};
|
|
231
347
|
export type StoreMap = {
|
|
232
348
|
[key: string]: StoreValue;
|
|
233
349
|
};
|
|
234
|
-
export type
|
|
350
|
+
export type ViewModel<ATTRIBUTES, STORE_MAP> = (storeMap: STORE_MAP) => Partial<ATTRIBUTES>;
|
|
235
351
|
export type BindSubscriptionList = string[];
|
|
236
352
|
export type BindParams<T, U> = {
|
|
237
|
-
Template:
|
|
238
|
-
viewModel?:
|
|
353
|
+
Template: Template<T>;
|
|
354
|
+
viewModel?: ViewModel<T, U>;
|
|
239
355
|
subscriptions?: BindSubscriptionList;
|
|
240
356
|
};
|
|
241
357
|
export type AppAdditionListenerOptions = {
|
|
242
|
-
state:
|
|
358
|
+
state: State;
|
|
243
359
|
document: Document;
|
|
244
360
|
window: Window;
|
|
245
361
|
};
|
|
246
362
|
export type DefaultBusListenerOptions<T> = {
|
|
247
|
-
publish:
|
|
363
|
+
publish: PublishFunction<T>;
|
|
248
364
|
eventName: string;
|
|
249
365
|
};
|
|
250
|
-
export type
|
|
251
|
-
export type
|
|
252
|
-
export type
|
|
253
|
-
export type
|
|
366
|
+
export type BusOptions = AppAdditionListenerOptions & DefaultBusListenerOptions<any>;
|
|
367
|
+
export type PublishFunction<T> = (event: string, payload: T) => void;
|
|
368
|
+
export type BusListener<T> = (payload: T, listenerKit: BusOptions) => void;
|
|
369
|
+
export type BusEventMatcher = string | RegExp;
|
|
254
370
|
export type ExactSubscriptionData<T> = {
|
|
255
|
-
listener:
|
|
371
|
+
listener: BusListener<T>;
|
|
256
372
|
index: number;
|
|
257
373
|
matcher: string;
|
|
258
374
|
};
|
|
259
375
|
export type FuzzySubscriptionData<T> = {
|
|
260
|
-
listener:
|
|
376
|
+
listener: BusListener<T>;
|
|
261
377
|
index: number;
|
|
262
378
|
matcher: RegExp;
|
|
263
379
|
};
|
|
264
380
|
export type Unsubscribe = () => void;
|
|
381
|
+
export type CreateAppBuilderArguments = {
|
|
382
|
+
window?: Window;
|
|
383
|
+
document?: Document;
|
|
384
|
+
};
|
|
385
|
+
export type RouteState = {
|
|
386
|
+
host: string;
|
|
387
|
+
path: string;
|
|
388
|
+
query: Record<string, string>;
|
|
389
|
+
};
|
|
390
|
+
export type AttributesWithChildren<T> = Props<T> & {
|
|
391
|
+
children?: JsxCollection;
|
|
392
|
+
};
|
|
393
|
+
export type DiffPair = {
|
|
394
|
+
source: JaxsNode;
|
|
395
|
+
target: JaxsNode;
|
|
396
|
+
};
|
|
397
|
+
export type CompileChildren = (sourceList: JaxsNodes, targetList: JaxsNodes, parent: JaxsElement) => ChangeInstructions;
|
|
398
|
+
export type StatePublisher = (event: string, payload: any) => void;
|
|
399
|
+
export type StateTransactionUpdater = (collection: StoresCollection) => void;
|
|
400
|
+
export type StoresCollection = Record<string, Store<any>>;
|
|
401
|
+
export type StoreInitializationOptions<T> = {
|
|
402
|
+
name: string;
|
|
403
|
+
parent: State;
|
|
404
|
+
value: T;
|
|
405
|
+
};
|
|
406
|
+
export type StoreDataUpdater<T> = (originalValue: T) => T;
|
|
407
|
+
export type UpdaterValue<T> = boolean | T | T[];
|
|
408
|
+
export type StoreUpdaterOrValue<T> = UpdaterValue<T> | StoreDataUpdater<T>;
|
|
409
|
+
export type StoreUpdaterFunction<T> = (value: UpdaterValue<T>, ...args: any[]) => T;
|
|
410
|
+
export type StoreUpdatersCollection<T> = Record<string, StoreUpdaterFunction<T>>;
|
|
411
|
+
export type StoreListSorterFunction<T> = (left: T, right: T) => number;
|
|
265
412
|
}
|
|
266
413
|
declare module "rendering/dom/tag" {
|
|
267
414
|
import type { JaxsElement, TagAttributes, TagEventAttributes, DomPublish, RenderKit } from "types";
|
|
@@ -273,7 +420,7 @@ declare module "rendering/dom/tag" {
|
|
|
273
420
|
declare module "rendering/dom/svg" {
|
|
274
421
|
import type { TagAttributes, JaxsElement } from "types";
|
|
275
422
|
export const namespace = "http://www.w3.org/2000/svg";
|
|
276
|
-
export const isSvgTag: (tagType: string) =>
|
|
423
|
+
export const isSvgTag: (tagType: string, attributeNamespace?: string) => boolean;
|
|
277
424
|
export const createSvgNode: (type: string, attributes: TagAttributes, document: Document) => JaxsElement;
|
|
278
425
|
export const elementIsSvg: (element: JaxsElement) => boolean;
|
|
279
426
|
}
|
|
@@ -284,7 +431,6 @@ declare module "rendering/templates/text" {
|
|
|
284
431
|
import { Renderable, TextValue, RenderKit } from "types";
|
|
285
432
|
export class TextTemplate implements Renderable {
|
|
286
433
|
value: string;
|
|
287
|
-
isSvg: boolean;
|
|
288
434
|
constructor(content: TextValue);
|
|
289
435
|
render(renderKit: RenderKit): Text[];
|
|
290
436
|
}
|
|
@@ -296,17 +442,10 @@ declare module "rendering/templates/children/text" {
|
|
|
296
442
|
export const textNode: (content: TextValue) => TextTemplate;
|
|
297
443
|
export const replaceTextNodes: (child: TextValue | Renderable) => Renderable | TextTemplate;
|
|
298
444
|
}
|
|
299
|
-
declare module "rendering/templates/children/svg" {
|
|
300
|
-
import { Renderable } from "types";
|
|
301
|
-
export const withSvgFlag: (isSvg: boolean) => (template: Renderable) => Renderable;
|
|
302
|
-
}
|
|
303
445
|
declare module "rendering/templates/children/normalize" {
|
|
304
|
-
import { JsxCollection,
|
|
305
|
-
export const normalizeJsxChildren: (jsxChildren: JsxCollection
|
|
446
|
+
import { JsxCollection, AttributesWithChildren } from "types";
|
|
447
|
+
export const normalizeJsxChildren: (jsxChildren: JsxCollection) => (import("types").Renderable | import("rendering/templates/text").TextTemplate)[];
|
|
306
448
|
export const normalizeToArray: <T>(children: T | T[]) => T[];
|
|
307
|
-
type AttributesWithChildren<T> = Props<T> & {
|
|
308
|
-
children?: JsxCollection;
|
|
309
|
-
};
|
|
310
449
|
export const ensureJsxChildrenArray: <T>(maybeChildren?: JsxCollection, attributes?: AttributesWithChildren<T>) => JsxCollection;
|
|
311
450
|
}
|
|
312
451
|
declare module "rendering/templates/tag/attributes-and-events" {
|
|
@@ -323,8 +462,7 @@ declare module "rendering/templates/children" {
|
|
|
323
462
|
export class Children implements Renderable {
|
|
324
463
|
collection: Renderable[];
|
|
325
464
|
parentElement?: JaxsElement;
|
|
326
|
-
|
|
327
|
-
constructor(jsxChildren: JsxCollection, isSvg?: boolean);
|
|
465
|
+
constructor(jsxChildren: JsxCollection);
|
|
328
466
|
render(renderKit: RenderKit, parentElement: JaxsElement | undefined): JaxsNode[];
|
|
329
467
|
generateDom(renderKit: RenderKit): JaxsNode[];
|
|
330
468
|
attachToParent(dom: JaxsNodes): void;
|
|
@@ -351,7 +489,7 @@ declare module "rendering/templates/tag" {
|
|
|
351
489
|
props: Props<T>;
|
|
352
490
|
children: Children;
|
|
353
491
|
isSvg: boolean;
|
|
354
|
-
constructor(tagType: string, props: Props<T>, children?: JsxCollection
|
|
492
|
+
constructor(tagType: string, props: Props<T>, children?: JsxCollection);
|
|
355
493
|
render(renderKit: RenderKit): JaxsNode[];
|
|
356
494
|
generateDom(renderKit: RenderKit): import("types").JaxsElement;
|
|
357
495
|
generateHtmlDom(renderKit: RenderKit): import("types").JaxsElement;
|
|
@@ -360,155 +498,26 @@ declare module "rendering/templates/tag" {
|
|
|
360
498
|
}
|
|
361
499
|
}
|
|
362
500
|
declare module "rendering/jsx" {
|
|
363
|
-
import type { JsxCollection, Props,
|
|
501
|
+
import type { JsxCollection, Props, Template, Renderable } from "types";
|
|
364
502
|
import { Children } from "rendering/templates/children";
|
|
365
503
|
const jsx: {
|
|
366
|
-
<T>(type: string |
|
|
504
|
+
<T>(type: string | Template<T>, attributes: Props<T>, ...children: JsxCollection): Renderable;
|
|
367
505
|
fragment<T>(attributes: Props<T>, maybeChildren: JsxCollection): Children;
|
|
368
506
|
};
|
|
369
507
|
export { jsx };
|
|
370
508
|
}
|
|
371
|
-
declare module "bus/exact-subscriptions" {
|
|
372
|
-
import { ExactSubscriptionData, JaxsBusListener, Unsubscribe } from "types";
|
|
373
|
-
export class ExactSubscriptions {
|
|
374
|
-
lookup: Record<string, ExactSubscriptionData<any>[]>;
|
|
375
|
-
constructor();
|
|
376
|
-
add<T>(matcher: string, listener: JaxsBusListener<T>, index: number): Unsubscribe;
|
|
377
|
-
remove<T>(subscription: ExactSubscriptionData<T>): void;
|
|
378
|
-
matches(event: string): ExactSubscriptionData<any>[];
|
|
379
|
-
ensureArrayFor(matcher: string): void;
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
declare module "bus/fuzzy-subscriptions" {
|
|
383
|
-
import { FuzzySubscriptionData, JaxsBusListener, Unsubscribe } from "types";
|
|
384
|
-
export class FuzzySubscriptions {
|
|
385
|
-
lookup: FuzzySubscriptionData<any>[];
|
|
386
|
-
constructor();
|
|
387
|
-
add<T>(matcher: RegExp, listener: JaxsBusListener<T>, index: number): Unsubscribe;
|
|
388
|
-
remove<T>(subscription: FuzzySubscriptionData<T>): void;
|
|
389
|
-
matches(event: string): FuzzySubscriptionData<any>[];
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
|
-
declare module "bus/index" {
|
|
393
|
-
import { JaxsBusEventMatcher, JaxsBusListener, Unsubscribe, AppAdditionListenerOptions, JaxsBusOptions } from "types";
|
|
394
|
-
import { ExactSubscriptions } from "bus/exact-subscriptions";
|
|
395
|
-
import { FuzzySubscriptions } from "bus/fuzzy-subscriptions";
|
|
396
|
-
class JaxsBus {
|
|
397
|
-
options?: AppAdditionListenerOptions;
|
|
398
|
-
exactSubscriptions: ExactSubscriptions;
|
|
399
|
-
fuzzySubscriptions: FuzzySubscriptions;
|
|
400
|
-
currentIndex: number;
|
|
401
|
-
constructor();
|
|
402
|
-
subscribe<T>(matcher: JaxsBusEventMatcher, listener: JaxsBusListener<T>): Unsubscribe;
|
|
403
|
-
publish<T>(event: string, payload: T): void;
|
|
404
|
-
addListenerOptions(options: AppAdditionListenerOptions): void;
|
|
405
|
-
listenerOptions(event: string): JaxsBusOptions;
|
|
406
|
-
}
|
|
407
|
-
const createBus: () => {
|
|
408
|
-
bus: JaxsBus;
|
|
409
|
-
publish: (event: string, payload: any) => void;
|
|
410
|
-
subscribe: (matcher: JaxsBusEventMatcher, listener: JaxsBusListener<any>) => Unsubscribe;
|
|
411
|
-
};
|
|
412
|
-
export { createBus, JaxsBus, ExactSubscriptions, FuzzySubscriptions };
|
|
413
|
-
}
|
|
414
|
-
declare module "rendering/templates/root" {
|
|
415
|
-
import type { JaxsElement, JaxsNodes, RenderKit, Renderable, JaxsNode } from "types";
|
|
416
|
-
export class Root {
|
|
417
|
-
template: Renderable;
|
|
418
|
-
selector: string;
|
|
419
|
-
renderKit: RenderKit;
|
|
420
|
-
dom: JaxsNodes;
|
|
421
|
-
parentElement?: JaxsElement | null;
|
|
422
|
-
constructor(template: Renderable, selector: string, renderKit: RenderKit);
|
|
423
|
-
renderAndAttach(renderKit: RenderKit): void;
|
|
424
|
-
render(renderKit: RenderKit): JaxsNode[];
|
|
425
|
-
attach(): void;
|
|
426
|
-
getParentElement(): Element;
|
|
427
|
-
}
|
|
428
|
-
export const render: (template: Renderable, selector: string, renderKit: RenderKit) => Root;
|
|
429
|
-
}
|
|
430
|
-
declare module "navigation/events" {
|
|
431
|
-
export const linkNavigationEvent = "go-to-href";
|
|
432
|
-
export const locationChangeEvent = "navigation:location-change";
|
|
433
|
-
export const routeChangeEvent = "navigation:route-change";
|
|
434
|
-
}
|
|
435
|
-
declare module "navigation/route-state" {
|
|
436
|
-
import { JaxsState } from "state/index";
|
|
437
|
-
export type RouteState = {
|
|
438
|
-
host: string;
|
|
439
|
-
path: string;
|
|
440
|
-
query: Record<string, string>;
|
|
441
|
-
};
|
|
442
|
-
export const createRouteState: (state: JaxsState) => void;
|
|
443
|
-
}
|
|
444
|
-
declare module "navigation/find-href" {
|
|
445
|
-
export const findHref: (node: HTMLElement) => string;
|
|
446
|
-
}
|
|
447
|
-
declare module "navigation/navigate" {
|
|
448
|
-
import { JaxsBusOptions } from "types";
|
|
449
|
-
export const navigate: (path: string, { publish, window }: JaxsBusOptions) => void;
|
|
450
|
-
}
|
|
451
|
-
declare module "navigation/on-link-click" {
|
|
452
|
-
import { JaxsBusOptions } from "types";
|
|
453
|
-
export const onLinkClick: (domEvent: MouseEvent, options: JaxsBusOptions) => void;
|
|
454
|
-
}
|
|
455
|
-
declare module "navigation/extract-query-params" {
|
|
456
|
-
export const extractQueryParams: (queryString: string) => {};
|
|
457
|
-
}
|
|
458
|
-
declare module "navigation/on-location-change" {
|
|
459
|
-
import { JaxsBusOptions } from "types";
|
|
460
|
-
export const onLocationChange: (_: null, listenerOptions: JaxsBusOptions) => void;
|
|
461
|
-
}
|
|
462
|
-
declare module "navigation/start" {
|
|
463
|
-
import type { App } from "app/index";
|
|
464
|
-
export const subscribeToNavigation: (app: App) => void;
|
|
465
|
-
export const subscribeToHistoryChange: (app: App) => void;
|
|
466
|
-
export const publishLocation: (app: App) => void;
|
|
467
|
-
export const startNavigation: (app: App) => void;
|
|
468
|
-
}
|
|
469
|
-
declare module "app/index" {
|
|
470
|
-
import type { Renderable, RenderKit, Subscribe, JaxsPublishFunction } from "types";
|
|
471
|
-
import type { JaxsState } from "state/index";
|
|
472
|
-
import type { JaxsBus } from "bus/index";
|
|
473
|
-
import { Root } from "rendering/templates/root";
|
|
474
|
-
export class App {
|
|
475
|
-
window: Window;
|
|
476
|
-
document: Document;
|
|
477
|
-
publish: JaxsPublishFunction<any>;
|
|
478
|
-
subscribe: Subscribe;
|
|
479
|
-
bus: JaxsBus;
|
|
480
|
-
state: JaxsState;
|
|
481
|
-
renderKit: RenderKit;
|
|
482
|
-
roots: Root[];
|
|
483
|
-
constructor({ window, document, publish, subscribe, bus, state, renderKit }: {
|
|
484
|
-
window: any;
|
|
485
|
-
document: any;
|
|
486
|
-
publish: any;
|
|
487
|
-
subscribe: any;
|
|
488
|
-
bus: any;
|
|
489
|
-
state: any;
|
|
490
|
-
renderKit: any;
|
|
491
|
-
});
|
|
492
|
-
render(template: Renderable, selector: string): Root;
|
|
493
|
-
startNavigation(): void;
|
|
494
|
-
}
|
|
495
|
-
}
|
|
496
509
|
declare module "app/builder" {
|
|
497
510
|
import { App } from "app/index";
|
|
498
511
|
import { JaxsBus } from "bus/index";
|
|
499
|
-
import {
|
|
500
|
-
import {
|
|
501
|
-
type CreateAppBuilderArguments = {
|
|
502
|
-
window?: Window;
|
|
503
|
-
document?: Document;
|
|
504
|
-
};
|
|
512
|
+
import { State } from "state/index";
|
|
513
|
+
import { PublishFunction, Subscribe, RenderKit, CreateAppBuilderArguments } from "types";
|
|
505
514
|
class AppBuilder {
|
|
506
515
|
window: Window;
|
|
507
516
|
document: Document;
|
|
508
|
-
publish:
|
|
517
|
+
publish: PublishFunction<any>;
|
|
509
518
|
subscribe: Subscribe;
|
|
510
519
|
bus: JaxsBus;
|
|
511
|
-
state:
|
|
520
|
+
state: State;
|
|
512
521
|
renderKit: RenderKit;
|
|
513
522
|
constructor(domEnvironment: CreateAppBuilderArguments);
|
|
514
523
|
setup(): App;
|
|
@@ -574,8 +583,7 @@ declare module "rendering/update/instructions/nodes/text" {
|
|
|
574
583
|
export const compileForText: (source: Text, target: Text) => ChangeInstructions;
|
|
575
584
|
}
|
|
576
585
|
declare module "rendering/update/instructions/node" {
|
|
577
|
-
import type {
|
|
578
|
-
type CompileChildren = (sourceList: JaxsNodes, targetList: JaxsNodes, parent: JaxsElement) => ChangeInstructions;
|
|
586
|
+
import type { JaxsNode, ChangeInstructions, CompileChildren } from "types";
|
|
579
587
|
export const compileForNode: (source: JaxsNode, target: JaxsNode, compileChildren: CompileChildren) => ChangeInstructions;
|
|
580
588
|
}
|
|
581
589
|
declare module "rendering/update/instructions/collection" {
|
|
@@ -587,10 +595,10 @@ declare module "rendering/update/perform-change" {
|
|
|
587
595
|
export const performChange: (source: JaxsNodes, target: JaxsNodes, parent: JaxsElement) => void;
|
|
588
596
|
}
|
|
589
597
|
declare module "rendering/templates/bound" {
|
|
590
|
-
import { JaxsElement, JaxsNodes, Props,
|
|
598
|
+
import { JaxsElement, JaxsNodes, Props, Template, RenderKit, ViewModel, BindParams, BindSubscriptionList } from "types";
|
|
591
599
|
export class Bound<ATTRIBUTES, STATE_MAP> {
|
|
592
|
-
Template:
|
|
593
|
-
viewModel:
|
|
600
|
+
Template: Template<ATTRIBUTES>;
|
|
601
|
+
viewModel: ViewModel<ATTRIBUTES, STATE_MAP>;
|
|
594
602
|
attributes: Partial<Props<ATTRIBUTES>>;
|
|
595
603
|
subscriptions: BindSubscriptionList;
|
|
596
604
|
dom: JaxsNodes;
|
|
@@ -619,7 +627,6 @@ declare module "navigation/index" {
|
|
|
619
627
|
import { onLocationChange } from "navigation/on-location-change";
|
|
620
628
|
import { createRouteState } from "navigation/route-state";
|
|
621
629
|
import * as start from "navigation/start";
|
|
622
|
-
export type { RouteState } from "navigation/route-state";
|
|
623
630
|
export { events, extractQueryParams, findHref, navigate, onLinkClick, onLocationChange, createRouteState, start, };
|
|
624
631
|
}
|
|
625
632
|
declare module "jaxs" {
|