jaxs 0.7.1 → 0.7.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 CHANGED
@@ -1,726 +1,718 @@
1
- declare module "state/is" {
2
- export const isBoolean: (value: any) => value is boolean;
3
- export const isNumber: (value: any) => value is number;
4
- export const isString: (value: any) => value is string;
5
- export const isArray: (value: any) => value is any[];
6
- export const isObject: (value: any) => boolean;
7
- }
8
- declare module "state/equality" {
9
- type Object = Record<string, any>;
10
- export const areElementsEqual: (oldValue: any, newValue: any) => boolean;
11
- export const areObjectsEqual: (oldValue: Object, newValue: Object) => any;
12
- export const areArraysEqual: (oldValue: any[], newValue: any[]) => any;
13
- export const areEqual: (oldValue: any, newValue: any) => any;
14
- }
15
- declare module "state/store" {
16
- import type { State, StoreInitializationOptions, StoreUpdaterOrValue, StoreUpdater } from "types";
17
- export class Store<T> {
18
- parent: State;
19
- name: string;
20
- updater: StoreUpdater<T>;
21
- _value: T;
22
- initialValue: T;
23
- constructor(options: StoreInitializationOptions<T>);
24
- get ['value'](): T;
25
- set ['value'](value: T);
26
- reset(): void;
27
- update(updater: StoreUpdaterOrValue<T>): void;
28
- private updateValue;
29
- private getUpdatedValue;
30
- }
31
- }
32
- declare module "state/store-updater" {
33
- import type { Store, StoreUpdaterOrValue } from "types";
34
- export class StoreUpdaterBase<T> {
35
- store: Store<T>;
36
- constructor(store: Store<T>);
37
- update(updater: StoreUpdaterOrValue<T>): void;
38
- reset(): void;
39
- get value(): T;
40
- }
41
- }
42
- declare module "state/updaters/object" {
43
- import { Store } from "types";
44
- import { StoreUpdaterBase } from "state/store-updater";
45
- export class StoreUpdaterObject<T extends object> extends StoreUpdaterBase<T> {
46
- updateAttribute(name: keyof T, value: T[keyof T]): void;
47
- updateDynamicAttribute(name: string, value: any): void;
48
- isKey(key: string): boolean;
49
- isValueType(key: keyof T, value: any): boolean;
50
- resetAttribute(name: keyof T): void;
51
- }
52
- export const objectUpdater: <T extends Object>(store: Store<T>) => StoreUpdaterObject<T>;
53
- }
54
- declare module "state/updaters/list" {
55
- import { StoreListSorterFunction, Store } from "types";
56
- import { StoreUpdaterBase } from "state/store-updater";
57
- export class StoreUpdaterList<T> extends StoreUpdaterBase<T[]> {
58
- push(element: T): void;
59
- pop(): T;
60
- unshift(element: T): void;
61
- shift(): T;
62
- addSorter(name: string, sorter: StoreListSorterFunction<T>): void;
63
- sortBy(sorter: StoreListSorterFunction<T>): void;
64
- insertAt(index: number, item: T): void;
65
- remove(value: T): void;
66
- removeBy(matcherFunction: (value: T) => boolean): void;
67
- }
68
- export const listUpdater: <T>(store: Store<T[]>) => StoreUpdaterList<T>;
69
- }
70
- declare module "state/updaters/boolean" {
71
- import { Store } from "types";
72
- import { StoreUpdaterBase } from "state/store-updater";
73
- export class StoreUpdaterBoolean extends StoreUpdaterBase<boolean> {
74
- toggle(): void;
75
- setTrue(): void;
76
- setFalse(): void;
77
- }
78
- export const booleanUpdater: (store: Store<boolean>) => StoreUpdaterBoolean;
79
- }
80
- declare module "state/updaters" {
81
- export const updaters: {
82
- object: <T extends Object>(store: import("state").Store<T>) => import("state/updaters/object").StoreUpdaterObject<T>;
83
- list: <T>(store: import("state").Store<T[]>) => import("state/updaters/list").StoreUpdaterList<T>;
84
- boolean: (store: import("state").Store<boolean>) => import("state/updaters/boolean").StoreUpdaterBoolean;
85
- };
86
- }
87
- declare module "state/index" {
88
- import { Store } from "state/store";
89
- import type { StatePublisher, StateTransactionUpdater, StoresCollection } from "types";
90
- import { updaters } from "state/updaters";
91
- export const eventName = "state";
92
- export class State {
93
- publisher: StatePublisher;
94
- stores: StoresCollection;
95
- eventNamePrefix: string;
96
- notifications: Set<string>;
97
- inTransaction: boolean;
98
- constructor(publisher: StatePublisher);
99
- create<T>(name: string, initialState: T): Store<T>;
100
- store<T>(name: string): Store<T>;
101
- get<T>(name: string): T;
102
- getAll(names: string[]): {};
103
- notify(name: string): void;
104
- update(name: string, newValue: any): void;
105
- transaction(updater: StateTransactionUpdater): void;
106
- publishAll(): void;
107
- publish(name: string): void;
108
- event(name: string): string;
109
- }
110
- export const createState: (publisher: StatePublisher) => State;
111
- export { Store, updaters };
112
- }
113
- declare module "bus/exact-subscriptions" {
114
- import { ExactSubscriptionData, BusListener, Unsubscribe } from "types";
115
- export class ExactSubscriptions {
116
- lookup: Record<string, ExactSubscriptionData<any>[]>;
117
- constructor();
118
- add<T>(matcher: string, listener: BusListener<T>, index: number): Unsubscribe;
119
- remove<T>(subscription: ExactSubscriptionData<T>): void;
120
- matches(event: string): ExactSubscriptionData<any>[];
121
- ensureArrayFor(matcher: string): void;
122
- }
123
- }
124
- declare module "bus/fuzzy-subscriptions" {
125
- import { FuzzySubscriptionData, BusListener, Unsubscribe } from "types";
126
- export class FuzzySubscriptions {
127
- lookup: FuzzySubscriptionData<any>[];
128
- constructor();
129
- add<T>(matcher: RegExp, listener: BusListener<T>, index: number): Unsubscribe;
130
- remove<T>(subscription: FuzzySubscriptionData<T>): void;
131
- matches(event: string): FuzzySubscriptionData<any>[];
132
- }
133
- }
134
- declare module "bus/custom-periodic-publisher" {
135
- import { PeriodicPublisher, PublishFunction, PeriodicTimerFunction, CustomPeriodicPublisherOptions } from "types";
136
- export class CustomPeriodicPublisher implements PeriodicPublisher {
137
- publish: PublishFunction;
138
- event: string;
139
- payload: any;
140
- stopped: boolean;
141
- timer: PeriodicTimerFunction;
142
- timeoutId: any;
143
- stop: () => void;
144
- callCount: number;
145
- startedAt: number;
146
- constructor({ publish, event, payload, timer, }: CustomPeriodicPublisherOptions);
147
- start(): void;
148
- setNewTimeout: () => void;
149
- calculateNextTime: () => number;
150
- diff(): number;
151
- stopTimeout(): void;
152
- publishEvent(): void;
153
- }
154
- }
155
- declare module "bus/publish-periodically" {
156
- import type { PublishPeriodicallyOptions } from "types";
157
- export const publishPeriodically: (options: PublishPeriodicallyOptions) => () => void;
158
- }
159
- declare module "bus/index" {
160
- import { BusEventMatcher, BusListener, Unsubscribe, AppAdditionListenerOptions, ListenerKit } from "types";
161
- import { ExactSubscriptions } from "bus/exact-subscriptions";
162
- import { FuzzySubscriptions } from "bus/fuzzy-subscriptions";
163
- import { publishPeriodically } from "bus/publish-periodically";
164
- class JaxsBus {
165
- options?: AppAdditionListenerOptions;
166
- exactSubscriptions: ExactSubscriptions;
167
- fuzzySubscriptions: FuzzySubscriptions;
168
- currentIndex: number;
169
- constructor();
170
- subscribe<T>(matcher: BusEventMatcher, listener: BusListener<T>): Unsubscribe;
171
- publish<T>(event: string, payload: T): void;
172
- addListenerOptions(options: AppAdditionListenerOptions): void;
173
- listenerOptions(event: string): ListenerKit;
174
- }
175
- const createBus: () => {
176
- bus: JaxsBus;
177
- publish: (event: string, payload: any) => void;
178
- subscribe: (matcher: BusEventMatcher, listener: BusListener<any>) => Unsubscribe;
179
- };
180
- export { createBus, JaxsBus, ExactSubscriptions, FuzzySubscriptions, publishPeriodically, };
181
- }
182
- declare module "rendering/templates/root" {
183
- import type { JaxsElement, JaxsNodes, RenderKit, Renderable, JaxsNode } from "types";
184
- export class Root {
185
- template: Renderable;
186
- selector: string;
187
- renderKit: RenderKit;
188
- dom: JaxsNodes;
189
- parentElement?: JaxsElement | null;
190
- constructor(template: Renderable, selector: string, renderKit: RenderKit);
191
- renderAndAttach(renderKit: RenderKit): void;
192
- render(renderKit: RenderKit): JaxsNode[];
193
- attach(): void;
194
- getParentElement(): Element;
195
- }
196
- export const render: (template: Renderable, selector: string, renderKit: RenderKit) => Root;
197
- }
198
- declare module "navigation/events" {
199
- export const linkNavigationEvent = "go-to-href";
200
- export const navigationEvent = "go-to";
201
- export const locationChangeEvent = "navigation:location-change";
202
- export const routeChangeEvent = "navigation:route-change";
203
- }
204
- declare module "navigation/route-state" {
205
- import { State } from "state/index";
206
- export const createRouteState: (state: State) => void;
207
- }
208
- declare module "navigation/find-href" {
209
- export const findHref: (node: HTMLElement) => string;
210
- }
211
- declare module "navigation/navigate" {
212
- import { ListenerKit } from "types";
213
- export const navigate: (path: string, { publish, window }: ListenerKit) => void;
214
- }
215
- declare module "navigation/on-link-click" {
216
- import { ListenerKit } from "types";
217
- export const onLinkClick: (domEvent: MouseEvent, options: ListenerKit) => void;
218
- }
219
- declare module "navigation/extract-query-params" {
220
- export const extractQueryParams: (queryString: string) => {};
221
- }
222
- declare module "navigation/on-location-change" {
223
- import { ListenerKit } from "types";
224
- export const onLocationChange: (_: null, listenerOptions: ListenerKit) => void;
225
- }
226
- declare module "navigation/start" {
227
- import type { App } from "app/index";
228
- export const subscribeToNavigation: (app: App) => void;
229
- export const subscribeToHistoryChange: (app: App) => void;
230
- export const publishLocation: (app: App) => void;
231
- export const startNavigation: (app: App) => void;
232
- }
233
- declare module "app/index" {
234
- import type { Renderable, RenderKit, Subscribe, PublishFunction } from "types";
235
- import type { State } from "state/index";
236
- import type { JaxsBus } from "bus/index";
237
- import { Root } from "rendering/templates/root";
238
- export class App {
239
- window: Window;
240
- document: Document;
241
- publish: PublishFunction;
242
- subscribe: Subscribe;
243
- bus: JaxsBus;
244
- state: State;
245
- renderKit: RenderKit;
246
- roots: Root[];
247
- constructor({ window, document, publish, subscribe, bus, state, renderKit }: {
248
- window: any;
249
- document: any;
250
- publish: any;
251
- subscribe: any;
252
- bus: any;
253
- state: any;
254
- renderKit: any;
255
- });
256
- render(template: Renderable, selector: string): Root;
257
- startNavigation(): void;
258
- }
259
- }
260
- declare module "types" {
261
- import type { State } from "state/index";
262
- import type { Store } from "state/store";
263
- import type { StoreUpdaterBase } from "state/store-updater";
264
- import type { StoreUpdaterBoolean } from "state/updaters/boolean";
265
- import type { StoreUpdaterList } from "state/updaters/list";
266
- import type { StoreUpdaterObject } from "state/updaters/object";
267
- export type { App } from "app/index";
268
- export { State, Store, StoreUpdaterBase, StoreUpdaterBoolean, StoreUpdaterList, StoreUpdaterObject, };
269
- export type StoreUpdater<T> = StoreUpdaterBase<T> | StoreUpdaterObject<T extends object ? T : never> | StoreUpdaterBoolean | StoreUpdaterList<T>;
270
- export type TextValue = string | number;
271
- export interface JsxIded {
272
- __jsx?: string;
273
- }
274
- export type JsxChangeId = {
275
- element: JaxsNode;
276
- index: number;
277
- };
278
- export type EventMap = {
279
- domEvent: string;
280
- busEvent: string;
281
- listener: EventListener;
282
- };
283
- export type EventMaps = Record<string, EventMap>;
284
- interface JsxEventMapped {
285
- eventMaps: EventMaps;
286
- }
287
- export type JaxsElement = Element & JsxIded & JsxEventMapped;
288
- export type JaxsText = Text & JsxIded;
289
- export type JaxsSvgElement = SVGElement & JsxIded;
290
- export type JaxsNode = JaxsElement | JaxsText | JaxsSvgElement;
291
- export type JaxsNodes = JaxsNode[] | NodeListOf<JaxsNode>;
292
- export type JaxsInput = HTMLInputElement & JsxIded & JsxEventMapped;
293
- type NullValues = null | undefined;
294
- export type ReactSourceObject = {
295
- fileName: string;
296
- lineNumber: string;
297
- columnNumber: string;
298
- };
299
- interface SourceMap {
300
- __source?: ReactSourceObject;
301
- }
302
- export type Props<T> = Partial<{
303
- __source: ReactSourceObject;
304
- children: JsxCollection;
305
- }> & T;
306
- export type PropValue = TextValue | NullValues | boolean | ReactSourceObject | JsxCollection;
307
- export type TagAttributes = SourceMap & Record<string, string>;
308
- export type TagEventAttributes = Record<string, string>;
309
- export type TagAttributesAndEvents = {
310
- attributes: TagAttributes;
311
- events: TagEventAttributes;
312
- };
313
- export type DomPublish = (eventName: string, domEvent: Event) => void;
314
- export type Subscribe = (matcher: BusEventMatcher, listener: BusListener<any>) => void;
315
- export type RenderKit = {
316
- document: Document;
317
- window: Window;
318
- publish: DomPublish;
319
- subscribe: Subscribe;
320
- state: State;
321
- parent?: JaxsNode | null;
322
- };
323
- export interface Renderable {
324
- render: (renderKit: RenderKit, parentElement?: JaxsElement) => JaxsNode[];
325
- }
326
- export type StaticTemplate = () => Renderable;
327
- export type TypedTemplate<T> = (props: Props<T>) => Renderable;
328
- export type Template<T> = StaticTemplate | TypedTemplate<T>;
329
- export type JsxCollection = (Renderable | TextValue)[];
330
- export enum ChangeInstructionTypes {
331
- removeNode = 0,
332
- insertNode = 1,// can be to move an existing element in the dom, or to add one
333
- replaceNode = 2,
334
- removeAttribute = 3,
335
- addAttribute = 4,
336
- updateAttribute = 5,
337
- removeEvent = 6,
338
- addEvent = 7,
339
- updateEvent = 8,
340
- changeValue = 9,
341
- changeText = 10
342
- }
343
- export type RemoveInstructionData = {
344
- name: string;
345
- isSvg?: boolean;
346
- };
347
- export type AttributeInstructionData = {
348
- name: string;
349
- value: string;
350
- isSvg?: boolean;
351
- };
352
- export type EventInstructionData = {
353
- name: string;
354
- value: EventListener;
355
- };
356
- export type UpdateEventInstructionData = {
357
- name: string;
358
- sourceValue: EventListener;
359
- targetValue: EventListener;
360
- };
361
- export type InsertNodeData = {
362
- parent: JaxsElement;
363
- index: number;
364
- };
365
- type NullInstructionData = Record<string, never>;
366
- export type InstructionData = RemoveInstructionData | AttributeInstructionData | EventInstructionData | UpdateEventInstructionData | InsertNodeData | NullInstructionData;
367
- export type ChangeInstruction = {
368
- source: JaxsNode;
369
- target: JaxsNode;
370
- type: ChangeInstructionTypes;
371
- data: InstructionData;
372
- };
373
- export type ChangeInstructions = Array<ChangeInstruction>;
374
- export type InstructionsUpdater = (instruction: ChangeInstruction) => void;
375
- export type StoreMap = {
376
- [key: string]: any;
377
- };
378
- export type ViewModel<ATTRIBUTES, STORE_MAP> = (storeMap: STORE_MAP) => Partial<ATTRIBUTES>;
379
- export type BindSubscriptionList = string[];
380
- export type BindParams<T, U> = {
381
- Template: Template<T>;
382
- viewModel?: ViewModel<T, U>;
383
- subscriptions?: BindSubscriptionList;
384
- };
385
- export type AppAdditionListenerOptions = {
386
- state: State;
387
- document: Document;
388
- window: Window;
389
- };
390
- export type DefaultBusListenerOptions = {
391
- publish: PublishFunction;
392
- eventName: string;
393
- };
394
- export type ListenerKit = AppAdditionListenerOptions & DefaultBusListenerOptions;
395
- export type PublishFunction = (event: string, payload: any) => void;
396
- export type BusListener<T> = (payload: T, listenerKit: ListenerKit) => void;
397
- export type BusEventMatcher = string | RegExp;
398
- export type ExactSubscriptionData<T> = {
399
- listener: BusListener<T>;
400
- index: number;
401
- matcher: string;
402
- };
403
- export type FuzzySubscriptionData<T> = {
404
- listener: BusListener<T>;
405
- index: number;
406
- matcher: RegExp;
407
- };
408
- export type Unsubscribe = () => void;
409
- export type CreateAppBuilderArguments = {
410
- window?: Window;
411
- document?: Document;
412
- };
413
- export type RouteState = {
414
- host: string;
415
- path: string;
416
- query: Record<string, string>;
417
- };
418
- export type AttributesWithChildren<T> = Props<T> & {
419
- children?: JsxCollection;
420
- };
421
- export type DiffPair = {
422
- source: JaxsNode;
423
- target: JaxsNode;
424
- };
425
- export type CompileChildren = (sourceList: JaxsNodes, targetList: JaxsNodes, parent: JaxsElement) => ChangeInstructions;
426
- export type StatePublisher = (event: string, payload: any) => void;
427
- export type StateTransactionUpdater = (collection: StoresCollection) => void;
428
- export type StoresCollection = Record<string, Store<any>>;
429
- export type StoreInitializationOptions<T> = {
430
- name: string;
431
- parent: State;
432
- value: T;
433
- };
434
- export type StoreDataUpdater<T> = (originalValue: T) => T;
435
- export type UpdaterValue<T> = boolean | T | T[];
436
- export type StoreUpdaterOrValue<T> = UpdaterValue<T> | StoreDataUpdater<T>;
437
- export type StoreListSorterFunction<T> = (left: T, right: T) => number;
438
- export type RouteMatcher = (routeState: RouteState) => boolean;
439
- export type RenderedRoute = {
440
- Partial: StaticTemplate;
441
- match: RouteMatcher;
442
- };
443
- export interface PeriodicPublisher {
444
- event: string;
445
- publish: PublishFunction;
446
- payload?: any;
447
- start: () => void;
448
- stop: () => void;
449
- }
450
- export type RequiredPeriodicPublisherOptions = {
451
- event: string;
452
- publish: PublishFunction;
453
- payload?: any;
454
- };
455
- export type GeneralPeriodicOptions = {
456
- period: number;
457
- offset?: number;
458
- };
459
- export type CustomPeriodicOptions = {
460
- timer: PeriodicTimerFunction;
461
- };
462
- export type GeneralPeriodicPublisherOptions = RequiredPeriodicPublisherOptions & GeneralPeriodicOptions;
463
- export type CustomPeriodicPublisherOptions = RequiredPeriodicPublisherOptions & CustomPeriodicOptions;
464
- export type PublishPeriodicallyOptions = GeneralPeriodicPublisherOptions | CustomPeriodicPublisherOptions;
465
- export type PeriodicTimerFunctionOptions = {
466
- timeDiff: number;
467
- callCount: number;
468
- stop: () => void;
469
- };
470
- export type PeriodicTimerFunction = (options: PeriodicTimerFunctionOptions) => number;
471
- }
472
- declare module "rendering/dom/tag" {
473
- import type { JaxsElement, TagAttributes, TagEventAttributes, DomPublish, RenderKit } from "types";
474
- export const createNode: (type: string, document: Document) => HTMLElement;
475
- export const setAttributesOnElement: (element: Element, attributes: TagAttributes) => void;
476
- export const setEventsOnElement: (element: JaxsElement, events: TagEventAttributes, publish: DomPublish) => void;
477
- export const createDecoratedNode: (type: string, attributes: TagAttributes, events: TagEventAttributes, renderKit: RenderKit) => JaxsElement;
478
- }
479
- declare module "rendering/dom/svg" {
480
- import type { TagAttributes, JaxsElement } from "types";
481
- export const namespace = "http://www.w3.org/2000/svg";
482
- export const isSvgTag: (tagType: string, attributeNamespace?: string) => boolean;
483
- export const createSvgNode: (type: string, attributes: TagAttributes, document: Document) => JaxsElement;
484
- export const elementIsSvg: (element: JaxsElement) => boolean;
485
- }
486
- declare module "rendering/dom/text" {
487
- export const createTextNode: (value: string, document: Document) => Text;
488
- }
489
- declare module "rendering/templates/text" {
490
- import { Renderable, TextValue, RenderKit } from "types";
491
- export class TextTemplate implements Renderable {
492
- value: string;
493
- constructor(content: TextValue);
494
- render(renderKit: RenderKit): Text[];
495
- }
496
- }
497
- declare module "rendering/templates/children/text" {
498
- import { TextValue, Renderable } from "types";
499
- import { TextTemplate } from "rendering/templates/text";
500
- export const isTextValue: <T>(child: TextValue | T) => child is string | number | (T & string) | (T & number);
501
- export const textNode: (content: TextValue) => TextTemplate;
502
- export const replaceTextNodes: (child: TextValue | Renderable) => Renderable | TextTemplate;
503
- }
504
- declare module "rendering/templates/children/normalize" {
505
- import { JsxCollection, AttributesWithChildren } from "types";
506
- export const normalizeJsxChildren: (jsxChildren: JsxCollection) => (import("types").Renderable | import("rendering/templates/text").TextTemplate)[];
507
- export const normalizeToArray: <T>(children: T | T[]) => T[];
508
- export const ensureJsxChildrenArray: <T>(maybeChildren?: JsxCollection, attributes?: AttributesWithChildren<T>) => JsxCollection;
509
- }
510
- declare module "rendering/templates/tag/attributes-and-events" {
511
- import type { Props, TagAttributesAndEvents, JsxCollection } from "types";
512
- export const separateAttrsAndEvents: <T>(props: Props<T>, defaultValue?: string) => TagAttributesAndEvents;
513
- export const packageJsxAttributes: <T>(maybeAttributes?: Props<T>, maybeChildren?: JsxCollection) => Props<T>;
514
- }
515
- declare module "rendering/templates/children/render" {
516
- import { Renderable, RenderKit, JaxsNode, JaxsElement } from "types";
517
- export const recursiveRender: (children: Renderable[], renderKit: RenderKit, parentElement?: JaxsElement, rendered?: JaxsNode[]) => JaxsNode[];
518
- }
519
- declare module "rendering/templates/children" {
520
- import { JaxsElement, Renderable, JsxCollection, RenderKit, JaxsNodes, JaxsNode } from "types";
521
- export class Children implements Renderable {
522
- collection: Renderable[];
523
- parentElement?: JaxsElement;
524
- constructor(jsxChildren: JsxCollection);
525
- render(renderKit: RenderKit, parentElement?: JaxsElement): JaxsNode[];
526
- generateDom(renderKit: RenderKit): JaxsNode[];
527
- attachToParent(dom: JaxsNodes): void;
528
- }
529
- }
530
- declare module "rendering/templates/tag/jsx-key" {
531
- import { TagAttributes } from "types";
532
- export class JsxKey {
533
- attributes: TagAttributes;
534
- type: string;
535
- constructor(type: string, attributes: TagAttributes);
536
- generate(): string;
537
- sourceKey(): string;
538
- createKeyFromAttributes(): string;
539
- }
540
- }
541
- declare module "rendering/templates/tag" {
542
- import type { Props, JaxsNode, TagEventAttributes, Renderable, RenderKit, TagAttributes, JsxCollection } from "types";
543
- import { Children } from "rendering/templates/children";
544
- export class Tag<T> implements Renderable {
545
- type: string;
546
- events: TagEventAttributes;
547
- attributes: TagAttributes;
548
- props: Props<T>;
549
- children: Children;
550
- isSvg: boolean;
551
- constructor(tagType: string, props: Props<T>, children?: JsxCollection);
552
- render(renderKit: RenderKit): JaxsNode[];
553
- generateDom(renderKit: RenderKit): import("types").JaxsElement;
554
- generateHtmlDom(renderKit: RenderKit): import("types").JaxsElement;
555
- generateSvgDom(renderKit: RenderKit): import("types").JaxsElement;
556
- jsxKey(): string;
557
- }
558
- }
559
- declare module "rendering/jsx" {
560
- import type { JsxCollection, Props, Template, Renderable } from "types";
561
- import { Children } from "rendering/templates/children";
562
- const jsx: {
563
- <T>(type: string | Template<T>, attributes: Props<T>, ...children: JsxCollection): Renderable;
564
- fragment<T>(attributes: Props<T>, maybeChildren: JsxCollection): Children;
565
- };
566
- export { jsx };
567
- }
568
- declare module "app/builder" {
569
- import { App } from "app/index";
570
- import { JaxsBus } from "bus/index";
571
- import { State } from "state/index";
572
- import { PublishFunction, Subscribe, RenderKit, CreateAppBuilderArguments } from "types";
573
- class AppBuilder {
574
- window: Window;
575
- document: Document;
576
- publish: PublishFunction;
577
- subscribe: Subscribe;
578
- bus: JaxsBus;
579
- state: State;
580
- renderKit: RenderKit;
581
- constructor(domEnvironment: CreateAppBuilderArguments);
582
- setup(): App;
583
- setupDomEnvironment(domEnvironment: CreateAppBuilderArguments): void;
584
- setupBus(): void;
585
- setupState(): void;
586
- addBusOptions(): void;
587
- setRenderKit(): void;
588
- }
589
- const createApp: (domEnvironment?: CreateAppBuilderArguments) => App;
590
- export { App, AppBuilder, createApp };
591
- }
592
- declare module "rendering/update/instructions/instructions" {
593
- import { JaxsInput, ChangeInstruction, JaxsElement, RemoveInstructionData, AttributeInstructionData, EventInstructionData, UpdateEventInstructionData, InsertNodeData } from "types";
594
- export const changeText: (source: Text, target: Text) => ChangeInstruction;
595
- export const replaceNode: (source: JaxsElement, target: JaxsElement) => ChangeInstruction;
596
- export const removeAttribute: (source: JaxsElement, target: JaxsElement, data: RemoveInstructionData) => ChangeInstruction;
597
- export const addAttribute: (source: JaxsElement, target: JaxsElement, data: AttributeInstructionData) => ChangeInstruction;
598
- export const updateAttribute: (source: JaxsElement, target: JaxsElement, data: AttributeInstructionData) => ChangeInstruction;
599
- export const removeEvent: (source: JaxsElement, target: JaxsElement, data: EventInstructionData) => ChangeInstruction;
600
- export const addEvent: (source: JaxsElement, target: JaxsElement, data: EventInstructionData) => ChangeInstruction;
601
- export const updateEvent: (source: JaxsElement, target: JaxsElement, data: UpdateEventInstructionData) => ChangeInstruction;
602
- export const removeNode: (source: JaxsElement) => ChangeInstruction;
603
- export const insertNode: (target: JaxsElement, data: InsertNodeData) => ChangeInstruction;
604
- export const changeValue: (source: JaxsInput, target: JaxsInput, data: AttributeInstructionData) => ChangeInstruction;
605
- export const instructionsSorter: (left: ChangeInstruction, right: ChangeInstruction) => 0 | 1 | -1;
606
- }
607
- declare module "rendering/update/instructions/id-map" {
608
- import type { JaxsNode, JaxsNodes, JsxChangeId } from "types";
609
- export class IdMap {
610
- map: Record<string, JsxChangeId[]>;
611
- constructor();
612
- populate(list: JaxsNodes): void;
613
- pullMatch(element: JaxsNode): JsxChangeId;
614
- clear(element: JaxsNode): void;
615
- check(element: JaxsNode): boolean;
616
- remaining(): JsxChangeId[];
617
- }
618
- export const createIdMap: (list: JaxsNodes) => IdMap;
619
- }
620
- declare module "rendering/update/instructions/nodes/element/attributes" {
621
- import type { JaxsElement, ChangeInstructions } from "types";
622
- export const compileForAttributes: (source: JaxsElement, target: JaxsElement, isSvg?: boolean) => ChangeInstructions;
623
- }
624
- declare module "rendering/update/instructions/nodes/element/events" {
625
- import type { JaxsElement, ChangeInstructions } from "types";
626
- export const compileForEvents: (source: JaxsElement, target: JaxsElement) => ChangeInstructions;
627
- }
628
- declare module "rendering/update/instructions/nodes/input" {
629
- import { ChangeInstructions, JaxsElement } from "types";
630
- export const compileForInputValue: (sourceElement: JaxsElement, targetElement: JaxsElement) => ChangeInstructions;
631
- }
632
- declare module "rendering/update/instructions/nodes/element" {
633
- import type { JaxsElement } from "types";
634
- export const compileForElement: (source: JaxsElement, target: JaxsElement) => import("types").ChangeInstruction[];
635
- }
636
- declare module "rendering/update/instructions/nodes/svg" {
637
- import { JaxsElement } from "types";
638
- export const compileForSvg: (source: JaxsElement, target: JaxsElement) => import("types").ChangeInstructions;
639
- }
640
- declare module "rendering/update/instructions/nodes/text" {
641
- import type { ChangeInstructions } from "types";
642
- export const compileForText: (source: Text, target: Text) => ChangeInstructions;
643
- }
644
- declare module "rendering/update/instructions/node" {
645
- import type { JaxsNode, ChangeInstructions, CompileChildren } from "types";
646
- export const compileForNode: (source: JaxsNode, target: JaxsNode, compileChildren: CompileChildren) => ChangeInstructions;
647
- }
648
- declare module "rendering/update/instructions/collection" {
649
- import type { JaxsElement, JaxsNodes } from "types";
650
- export const compileCollection: (sourceList: JaxsNodes, targetList: JaxsNodes, parent: JaxsElement) => import("types").ChangeInstruction[];
651
- }
652
- declare module "rendering/update/perform-change" {
653
- import type { ChangeInstruction, JaxsElement, JaxsNodes } from "types";
654
- export const performChange: (source: JaxsNodes, target: JaxsNodes, parent: JaxsElement) => ChangeInstruction[];
655
- }
656
- declare module "rendering/templates/bound/modify-dom-cache" {
657
- import { ChangeInstructions, JaxsNode, JaxsElement } from "types";
658
- export const modifyDomCache: (instructions: ChangeInstructions, dom: JaxsNode[], parentElement: JaxsElement) => JaxsNode[];
659
- }
660
- declare module "rendering/templates/bound" {
661
- import { JaxsElement, Props, Template, RenderKit, ViewModel, BindParams, BindSubscriptionList, JaxsNode } from "types";
662
- export class Bound<ATTRIBUTES, STATE_MAP> {
663
- Template: Template<ATTRIBUTES>;
664
- viewModel: ViewModel<ATTRIBUTES, STATE_MAP>;
665
- attributes: Partial<Props<ATTRIBUTES>>;
666
- subscriptions: BindSubscriptionList;
667
- dom: JaxsNode[];
668
- parentElement: JaxsElement | null;
669
- renderKit?: RenderKit;
670
- constructor({ Template, subscriptions, attributes, viewModel }: {
671
- Template: any;
672
- subscriptions: any;
673
- attributes: any;
674
- viewModel: any;
675
- });
676
- render(renderKit: RenderKit): JaxsNode[];
677
- generateDom(renderKit: RenderKit): JaxsNode[];
678
- rerender(): void;
679
- subscribeForRerender(): void;
680
- eventName(storeName: string): string;
681
- }
682
- export const bind: <ATTRIBUTES, STATE_MAP>({ Template, viewModel, subscriptions, }: BindParams<ATTRIBUTES, STATE_MAP>) => (attributes: Partial<Props<ATTRIBUTES>>) => Bound<unknown, unknown>;
683
- }
684
- declare module "navigation/index" {
685
- import * as events from "navigation/events";
686
- import { extractQueryParams } from "navigation/extract-query-params";
687
- import { findHref } from "navigation/find-href";
688
- import { navigate } from "navigation/navigate";
689
- import { onLinkClick } from "navigation/on-link-click";
690
- import { onLocationChange } from "navigation/on-location-change";
691
- import { createRouteState } from "navigation/route-state";
692
- import * as start from "navigation/start";
693
- export { events, extractQueryParams, findHref, navigate, onLinkClick, onLocationChange, createRouteState, start, };
694
- }
695
- declare module "app/routing" {
696
- import { RenderedRoute, RouteMatcher } from "types";
697
- export const exactPathMatch: (exactPath: string) => RouteMatcher;
698
- export const catchAll: RouteMatcher;
699
- export const buildRouter: (pages: RenderedRoute[]) => ({ route }: {
700
- route: any;
701
- }) => import("types").StaticTemplate;
702
- }
703
- declare module "rendering/null" {
704
- import { RenderKit, JaxsElement, JaxsNode } from "types";
705
- export const NullTemplate: () => {
706
- render: (renderKit: RenderKit, parentElement?: JaxsElement) => JaxsNode[];
707
- };
708
- }
709
- declare module "app/routed-view" {
710
- import { RenderedRoute, RouteState } from "types";
711
- export const routedView: (routes: RenderedRoute[]) => (attributes: Partial<import("types").Props<{
712
- route: RouteState;
713
- }>>) => import("rendering/templates/bound").Bound<unknown, unknown>;
714
- }
715
- declare module "jaxs" {
716
- export { jsx } from "rendering/jsx";
717
- export { createApp } from "app/builder";
718
- export { bind } from "rendering/templates/bound";
719
- export * as JaxsTypes from "types";
720
- export * as navigation from "navigation/index";
721
- export * as appBuilding from "app/index";
722
- export * as messageBus from "bus/index";
723
- export * as state from "state/index";
724
- export * as routing from "app/routing";
725
- export { routedView } from "app/routed-view";
726
- }
1
+ export declare class App {
2
+ window: Window
3
+ document: Document
4
+ publish: PublishFunction
5
+ subscribe: Subscribe
6
+ bus: JaxsBus
7
+ state: State
8
+ renderKit: RenderKit
9
+ roots: Root[]
10
+ constructor({
11
+ window,
12
+ document,
13
+ publish,
14
+ subscribe,
15
+ bus,
16
+ state,
17
+ renderKit,
18
+ }: {
19
+ window: any
20
+ document: any
21
+ publish: any
22
+ subscribe: any
23
+ bus: any
24
+ state: any
25
+ renderKit: any
26
+ })
27
+ render(template: Renderable, selector: string): Root
28
+ startNavigation(): void
29
+ }
30
+
31
+ declare type AppAdditionListenerOptions = {
32
+ state: State
33
+ document: Document
34
+ window: Window
35
+ }
36
+
37
+ export declare namespace appBuilding {
38
+ export { App }
39
+ }
40
+
41
+ declare type AttributeInstructionData = {
42
+ name: string
43
+ value: string
44
+ isSvg?: boolean
45
+ }
46
+
47
+ declare type AttributesWithChildren<T> = Props<T> & {
48
+ children?: JsxCollection
49
+ }
50
+
51
+ export declare const bind: <ATTRIBUTES, STATE_MAP>({
52
+ Template,
53
+ viewModel,
54
+ subscriptions,
55
+ }: BindParams<ATTRIBUTES, STATE_MAP>) => (
56
+ attributes: Partial<Props<ATTRIBUTES>>,
57
+ ) => Bound<unknown, unknown>
58
+
59
+ declare type BindParams<T, U> = {
60
+ Template: Template<T>
61
+ viewModel?: ViewModel<T, U>
62
+ subscriptions?: BindSubscriptionList
63
+ }
64
+
65
+ declare type BindSubscriptionList = string[]
66
+
67
+ declare class Bound<ATTRIBUTES, STATE_MAP> {
68
+ Template: Template<ATTRIBUTES>
69
+ viewModel: ViewModel<ATTRIBUTES, STATE_MAP>
70
+ attributes: Partial<Props<ATTRIBUTES>>
71
+ subscriptions: BindSubscriptionList
72
+ dom: JaxsNode[]
73
+ parentElement: JaxsElement | null
74
+ renderKit?: RenderKit
75
+ constructor({
76
+ Template,
77
+ subscriptions,
78
+ attributes,
79
+ viewModel,
80
+ }: {
81
+ Template: any
82
+ subscriptions: any
83
+ attributes: any
84
+ viewModel: any
85
+ })
86
+ render(renderKit: RenderKit): JaxsNode[]
87
+ generateDom(renderKit: RenderKit): JaxsNode[]
88
+ rerender(): void
89
+ subscribeForRerender(): void
90
+ eventName(storeName: string): string
91
+ }
92
+
93
+ declare const buildRouter: (
94
+ pages: RenderedRoute[],
95
+ ) => ({ route }: { route: any }) => StaticTemplate
96
+
97
+ declare type BusEventMatcher = string | RegExp
98
+
99
+ export declare type BusListener<T> = (
100
+ payload: T,
101
+ listenerKit: ListenerKit,
102
+ ) => void
103
+
104
+ declare const catchAll: RouteMatcher
105
+
106
+ declare type ChangeInstruction = {
107
+ source: JaxsNode
108
+ target: JaxsNode
109
+ type: ChangeInstructionTypes
110
+ data: InstructionData
111
+ }
112
+
113
+ declare type ChangeInstructions = Array<ChangeInstruction>
114
+
115
+ declare enum ChangeInstructionTypes {
116
+ removeNode = 0,
117
+ insertNode = 1, // can be to move an existing element in the dom, or to add one
118
+ replaceNode = 2,
119
+ removeAttribute = 3,
120
+ addAttribute = 4,
121
+ updateAttribute = 5,
122
+ removeEvent = 6,
123
+ addEvent = 7,
124
+ updateEvent = 8,
125
+ changeValue = 9,
126
+ changeText = 10,
127
+ }
128
+
129
+ declare class Children implements Renderable {
130
+ collection: Renderable[]
131
+ parentElement?: JaxsElement
132
+ constructor(jsxChildren: JsxCollection)
133
+ render(renderKit: RenderKit, parentElement?: JaxsElement): JaxsNode[]
134
+ generateDom(renderKit: RenderKit): JaxsNode[]
135
+ attachToParent(dom: JaxsNodes): void
136
+ }
137
+
138
+ declare type CompileChildren = (
139
+ sourceList: JaxsNodes,
140
+ targetList: JaxsNodes,
141
+ parent: JaxsElement,
142
+ ) => ChangeInstructions
143
+
144
+ export declare const createApp: (
145
+ domEnvironment?: CreateAppBuilderArguments,
146
+ ) => App
147
+
148
+ declare type CreateAppBuilderArguments = {
149
+ window?: Window
150
+ document?: Document
151
+ }
152
+
153
+ declare const createBus: () => {
154
+ bus: JaxsBus
155
+ publish: (event: string, payload: any) => void
156
+ subscribe: (
157
+ matcher: BusEventMatcher,
158
+ listener: BusListener<any>,
159
+ ) => Unsubscribe
160
+ }
161
+
162
+ declare const createRouteState: (state: State) => void
163
+
164
+ declare const createState: (publisher: StatePublisher) => State
165
+
166
+ declare type CustomPeriodicOptions = {
167
+ timer: PeriodicTimerFunction
168
+ }
169
+
170
+ declare type CustomPeriodicPublisherOptions = RequiredPeriodicPublisherOptions &
171
+ CustomPeriodicOptions
172
+
173
+ declare type DefaultBusListenerOptions = {
174
+ publish: PublishFunction
175
+ eventName: string
176
+ }
177
+
178
+ declare type DiffPair = {
179
+ source: JaxsNode
180
+ target: JaxsNode
181
+ }
182
+
183
+ declare type DomPublish = (eventName: string, domEvent: Event) => void
184
+
185
+ declare type EventInstructionData = {
186
+ name: string
187
+ value: EventListener
188
+ }
189
+
190
+ declare type EventMap = {
191
+ domEvent: string
192
+ busEvent: string
193
+ listener: EventListener
194
+ }
195
+
196
+ declare type EventMaps = Record<string, EventMap>
197
+
198
+ declare const eventName = 'state'
199
+
200
+ declare namespace events {
201
+ export {
202
+ linkNavigationEvent,
203
+ navigationEvent,
204
+ locationChangeEvent,
205
+ routeChangeEvent,
206
+ }
207
+ }
208
+
209
+ declare const exactPathMatch: (exactPath: string) => RouteMatcher
210
+
211
+ declare type ExactSubscriptionData<T> = {
212
+ listener: BusListener<T>
213
+ index: number
214
+ matcher: string
215
+ }
216
+
217
+ declare class ExactSubscriptions {
218
+ lookup: Record<string, ExactSubscriptionData<any>[]>
219
+ constructor()
220
+ add<T>(matcher: string, listener: BusListener<T>, index: number): Unsubscribe
221
+ remove<T>(subscription: ExactSubscriptionData<T>): void
222
+ matches(event: string): ExactSubscriptionData<any>[]
223
+ ensureArrayFor(matcher: string): void
224
+ }
225
+
226
+ declare const extractQueryParams: (queryString: string) => {}
227
+
228
+ declare const findHref: (node: HTMLElement) => string
229
+
230
+ declare type FuzzySubscriptionData<T> = {
231
+ listener: BusListener<T>
232
+ index: number
233
+ matcher: RegExp
234
+ }
235
+
236
+ declare class FuzzySubscriptions {
237
+ lookup: FuzzySubscriptionData<any>[]
238
+ constructor()
239
+ add<T>(matcher: RegExp, listener: BusListener<T>, index: number): Unsubscribe
240
+ remove<T>(subscription: FuzzySubscriptionData<T>): void
241
+ matches(event: string): FuzzySubscriptionData<any>[]
242
+ }
243
+
244
+ declare type GeneralPeriodicOptions = {
245
+ period: number
246
+ offset?: number
247
+ }
248
+
249
+ declare type GeneralPeriodicPublisherOptions =
250
+ RequiredPeriodicPublisherOptions & GeneralPeriodicOptions
251
+
252
+ declare type InsertNodeData = {
253
+ parent: JaxsElement
254
+ index: number
255
+ }
256
+
257
+ declare type InstructionData =
258
+ | RemoveInstructionData
259
+ | AttributeInstructionData
260
+ | EventInstructionData
261
+ | UpdateEventInstructionData
262
+ | InsertNodeData
263
+ | NullInstructionData
264
+
265
+ declare type InstructionsUpdater = (instruction: ChangeInstruction) => void
266
+
267
+ declare class JaxsBus {
268
+ options?: AppAdditionListenerOptions
269
+ exactSubscriptions: ExactSubscriptions
270
+ fuzzySubscriptions: FuzzySubscriptions
271
+ currentIndex: number
272
+ constructor()
273
+ subscribe<T>(matcher: BusEventMatcher, listener: BusListener<T>): Unsubscribe
274
+ publish<T>(event: string, payload: T): void
275
+ addListenerOptions(options: AppAdditionListenerOptions): void
276
+ listenerOptions(event: string): ListenerKit
277
+ }
278
+
279
+ declare type JaxsElement = Element & JsxIded & JsxEventMapped
280
+
281
+ declare type JaxsInput = HTMLInputElement & JsxIded & JsxEventMapped
282
+
283
+ declare type JaxsNode = JaxsElement | JaxsText | JaxsSvgElement
284
+
285
+ declare type JaxsNodes = JaxsNode[] | NodeListOf<JaxsNode>
286
+
287
+ declare type JaxsSvgElement = SVGElement & JsxIded
288
+
289
+ declare type JaxsText = Text & JsxIded
290
+
291
+ export declare namespace JaxsTypes {
292
+ export {
293
+ App,
294
+ State,
295
+ Store,
296
+ StoreUpdaterBase,
297
+ StoreUpdaterBoolean,
298
+ StoreUpdaterList,
299
+ StoreUpdaterObject,
300
+ StoreUpdater,
301
+ TextValue,
302
+ JsxIded,
303
+ JsxChangeId,
304
+ EventMap,
305
+ EventMaps,
306
+ JaxsElement,
307
+ JaxsText,
308
+ JaxsSvgElement,
309
+ JaxsNode,
310
+ JaxsNodes,
311
+ JaxsInput,
312
+ ReactSourceObject,
313
+ Props,
314
+ PropValue,
315
+ TagAttributes,
316
+ TagEventAttributes,
317
+ TagAttributesAndEvents,
318
+ DomPublish,
319
+ Subscribe,
320
+ RenderKit,
321
+ Renderable,
322
+ StaticTemplate,
323
+ TypedTemplate,
324
+ Template,
325
+ JsxCollection,
326
+ ChangeInstructionTypes,
327
+ RemoveInstructionData,
328
+ AttributeInstructionData,
329
+ EventInstructionData,
330
+ UpdateEventInstructionData,
331
+ InsertNodeData,
332
+ InstructionData,
333
+ ChangeInstruction,
334
+ ChangeInstructions,
335
+ InstructionsUpdater,
336
+ StoreMap,
337
+ ViewModel,
338
+ BindSubscriptionList,
339
+ BindParams,
340
+ AppAdditionListenerOptions,
341
+ DefaultBusListenerOptions,
342
+ ListenerKit,
343
+ PublishFunction,
344
+ BusListener,
345
+ BusEventMatcher,
346
+ ExactSubscriptionData,
347
+ FuzzySubscriptionData,
348
+ Unsubscribe,
349
+ CreateAppBuilderArguments,
350
+ RouteState,
351
+ AttributesWithChildren,
352
+ DiffPair,
353
+ CompileChildren,
354
+ StatePublisher,
355
+ StateTransactionUpdater,
356
+ StoresCollection,
357
+ StoreInitializationOptions,
358
+ StoreDataUpdater,
359
+ UpdaterValue,
360
+ StoreUpdaterOrValue,
361
+ StoreListSorterFunction,
362
+ RouteMatcher,
363
+ RenderedRoute,
364
+ PeriodicPublisher,
365
+ RequiredPeriodicPublisherOptions,
366
+ GeneralPeriodicOptions,
367
+ CustomPeriodicOptions,
368
+ GeneralPeriodicPublisherOptions,
369
+ CustomPeriodicPublisherOptions,
370
+ PublishPeriodicallyOptions,
371
+ PeriodicTimerFunctionOptions,
372
+ PeriodicTimerFunction,
373
+ }
374
+ }
375
+
376
+ export declare const jsx: {
377
+ <T>(
378
+ type: string | Template<T>,
379
+ attributes: Props<T>,
380
+ ...children: JsxCollection
381
+ ): Renderable
382
+ fragment<T>(attributes: Props<T>, maybeChildren: JsxCollection): Children
383
+ }
384
+
385
+ declare type JsxChangeId = {
386
+ element: JaxsNode
387
+ index: number
388
+ }
389
+
390
+ declare type JsxCollection = (Renderable | TextValue)[]
391
+
392
+ declare interface JsxEventMapped {
393
+ eventMaps: EventMaps
394
+ }
395
+
396
+ declare interface JsxIded {
397
+ __jsx?: string
398
+ }
399
+
400
+ declare const linkNavigationEvent = 'go-to-href'
401
+
402
+ declare type ListenerKit = AppAdditionListenerOptions &
403
+ DefaultBusListenerOptions
404
+
405
+ declare const locationChangeEvent = 'navigation:location-change'
406
+
407
+ export declare namespace messageBus {
408
+ export {
409
+ createBus,
410
+ JaxsBus,
411
+ ExactSubscriptions,
412
+ FuzzySubscriptions,
413
+ publishPeriodically,
414
+ }
415
+ }
416
+
417
+ declare const navigate: (path: string, { publish, window }: ListenerKit) => void
418
+
419
+ export declare namespace navigation {
420
+ export {
421
+ events,
422
+ extractQueryParams,
423
+ findHref,
424
+ navigate,
425
+ onLinkClick,
426
+ onLocationChange,
427
+ createRouteState,
428
+ start,
429
+ }
430
+ }
431
+
432
+ declare const navigationEvent = 'go-to'
433
+
434
+ declare type NullInstructionData = Record<string, never>
435
+
436
+ declare type NullValues = null | undefined
437
+
438
+ declare const onLinkClick: (domEvent: MouseEvent, options: ListenerKit) => void
439
+
440
+ declare const onLocationChange: (_: null, listenerOptions: ListenerKit) => void
441
+
442
+ declare interface PeriodicPublisher {
443
+ event: string
444
+ publish: PublishFunction
445
+ payload?: any
446
+ start: () => void
447
+ stop: () => void
448
+ }
449
+
450
+ declare type PeriodicTimerFunction = (
451
+ options: PeriodicTimerFunctionOptions,
452
+ ) => number
453
+
454
+ declare type PeriodicTimerFunctionOptions = {
455
+ timeDiff: number
456
+ callCount: number
457
+ stop: () => void
458
+ }
459
+
460
+ export declare type Props<T> = Partial<{
461
+ __source: ReactSourceObject
462
+ children: JsxCollection
463
+ }> &
464
+ T
465
+
466
+ declare type PropValue =
467
+ | TextValue
468
+ | NullValues
469
+ | boolean
470
+ | ReactSourceObject
471
+ | JsxCollection
472
+
473
+ export declare type PublishFunction = (event: string, payload: any) => void
474
+
475
+ declare const publishLocation: (app: App) => void
476
+
477
+ declare const publishPeriodically: (
478
+ options: PublishPeriodicallyOptions,
479
+ ) => () => void
480
+
481
+ declare type PublishPeriodicallyOptions =
482
+ | GeneralPeriodicPublisherOptions
483
+ | CustomPeriodicPublisherOptions
484
+
485
+ declare type ReactSourceObject = {
486
+ fileName: string
487
+ lineNumber: string
488
+ columnNumber: string
489
+ }
490
+
491
+ declare type RemoveInstructionData = {
492
+ name: string
493
+ isSvg?: boolean
494
+ }
495
+
496
+ export declare interface Renderable {
497
+ render: (renderKit: RenderKit, parentElement?: JaxsElement) => JaxsNode[]
498
+ }
499
+
500
+ export declare type RenderedRoute = {
501
+ Partial: StaticTemplate
502
+ match: RouteMatcher
503
+ }
504
+
505
+ declare type RenderKit = {
506
+ document: Document
507
+ window: Window
508
+ publish: DomPublish
509
+ subscribe: Subscribe
510
+ state: State
511
+ parent?: JaxsNode | null
512
+ }
513
+
514
+ declare type RequiredPeriodicPublisherOptions = {
515
+ event: string
516
+ publish: PublishFunction
517
+ payload?: any
518
+ }
519
+
520
+ declare class Root {
521
+ template: Renderable
522
+ selector: string
523
+ renderKit: RenderKit
524
+ dom: JaxsNodes
525
+ parentElement?: JaxsElement | null
526
+ constructor(template: Renderable, selector: string, renderKit: RenderKit)
527
+ renderAndAttach(renderKit: RenderKit): void
528
+ render(renderKit: RenderKit): JaxsNode[]
529
+ attach(): void
530
+ getParentElement(): Element
531
+ }
532
+
533
+ declare const routeChangeEvent = 'navigation:route-change'
534
+
535
+ export declare const routedView: (routes: RenderedRoute[]) => (
536
+ attributes: Partial<
537
+ Props<{
538
+ route: RouteState
539
+ }>
540
+ >,
541
+ ) => Bound<unknown, unknown>
542
+
543
+ export declare type RouteMatcher = (routeState: RouteState) => boolean
544
+
545
+ export declare type RouteState = {
546
+ host: string
547
+ path: string
548
+ query: Record<string, string>
549
+ }
550
+
551
+ export declare namespace routing {
552
+ export { exactPathMatch, catchAll, buildRouter }
553
+ }
554
+
555
+ declare interface SourceMap {
556
+ __source?: ReactSourceObject
557
+ }
558
+
559
+ declare namespace start {
560
+ export {
561
+ subscribeToNavigation,
562
+ subscribeToHistoryChange,
563
+ publishLocation,
564
+ startNavigation,
565
+ }
566
+ }
567
+
568
+ declare const startNavigation: (app: App) => void
569
+
570
+ export declare class State {
571
+ publisher: StatePublisher
572
+ stores: StoresCollection
573
+ eventNamePrefix: string
574
+ notifications: Set<string>
575
+ inTransaction: boolean
576
+ constructor(publisher: StatePublisher)
577
+ create<T>(name: string, initialState: T): Store<T>
578
+ store<T>(name: string): Store<T>
579
+ get<T>(name: string): T
580
+ getAll(names: string[]): {}
581
+ notify(name: string): void
582
+ update(name: string, newValue: any): void
583
+ transaction(updater: StateTransactionUpdater): void
584
+ publishAll(): void
585
+ publish(name: string): void
586
+ event(name: string): string
587
+ }
588
+
589
+ export declare namespace state {
590
+ export { eventName, State, createState, Store, updaters }
591
+ }
592
+
593
+ declare type StatePublisher = (event: string, payload: any) => void
594
+
595
+ declare type StateTransactionUpdater = (collection: StoresCollection) => void
596
+
597
+ export declare type StaticTemplate = () => Renderable
598
+
599
+ export declare class Store<T> {
600
+ parent: State
601
+ name: string
602
+ updater: StoreUpdater<T>
603
+ _value: T
604
+ initialValue: T
605
+ constructor(options: StoreInitializationOptions<T>)
606
+ get ['value'](): T
607
+ set ['value'](value: T)
608
+ reset(): void
609
+ update(updater: StoreUpdaterOrValue<T>): void
610
+ private updateValue
611
+ private getUpdatedValue
612
+ }
613
+
614
+ declare type StoreDataUpdater<T> = (originalValue: T) => T
615
+
616
+ declare type StoreInitializationOptions<T> = {
617
+ name: string
618
+ parent: State
619
+ value: T
620
+ }
621
+
622
+ declare type StoreListSorterFunction<T> = (left: T, right: T) => number
623
+
624
+ declare type StoreMap = {
625
+ [key: string]: any
626
+ }
627
+
628
+ declare type StoresCollection = Record<string, Store<any>>
629
+
630
+ export declare type StoreUpdater<T> =
631
+ | StoreUpdaterBase<T>
632
+ | StoreUpdaterObject<T extends object ? T : never>
633
+ | StoreUpdaterBoolean
634
+ | StoreUpdaterList<T>
635
+
636
+ export declare class StoreUpdaterBase<T> {
637
+ store: Store<T>
638
+ constructor(store: Store<T>)
639
+ update(updater: StoreUpdaterOrValue<T>): void
640
+ reset(): void
641
+ get value(): T
642
+ }
643
+
644
+ export declare class StoreUpdaterBoolean extends StoreUpdaterBase<boolean> {
645
+ toggle(): void
646
+ setTrue(): void
647
+ setFalse(): void
648
+ }
649
+
650
+ export declare class StoreUpdaterList<T> extends StoreUpdaterBase<T[]> {
651
+ push(element: T): void
652
+ pop(): T
653
+ unshift(element: T): void
654
+ shift(): T
655
+ addSorter(name: string, sorter: StoreListSorterFunction<T>): void
656
+ sortBy(sorter: StoreListSorterFunction<T>): void
657
+ insertAt(index: number, item: T): void
658
+ remove(value: T): void
659
+ removeBy(matcherFunction: (value: T) => boolean): void
660
+ }
661
+
662
+ export declare class StoreUpdaterObject<
663
+ T extends object,
664
+ > extends StoreUpdaterBase<T> {
665
+ updateAttribute(name: keyof T, value: T[keyof T]): void
666
+ updateDynamicAttribute(name: string, value: any): void
667
+ isKey(key: string): boolean
668
+ isValueType(key: keyof T, value: any): boolean
669
+ resetAttribute(name: keyof T): void
670
+ }
671
+
672
+ declare type StoreUpdaterOrValue<T> = UpdaterValue<T> | StoreDataUpdater<T>
673
+
674
+ export declare type Subscribe = (
675
+ matcher: BusEventMatcher,
676
+ listener: BusListener<any>,
677
+ ) => void
678
+
679
+ declare const subscribeToHistoryChange: (app: App) => void
680
+
681
+ declare const subscribeToNavigation: (app: App) => void
682
+
683
+ declare type TagAttributes = SourceMap & Record<string, string>
684
+
685
+ declare type TagAttributesAndEvents = {
686
+ attributes: TagAttributes
687
+ events: TagEventAttributes
688
+ }
689
+
690
+ declare type TagEventAttributes = Record<string, string>
691
+
692
+ export declare type Template<T> = StaticTemplate | TypedTemplate<T>
693
+
694
+ declare type TextValue = string | number
695
+
696
+ export declare type TypedTemplate<T> = (props: Props<T>) => Renderable
697
+
698
+ declare type Unsubscribe = () => void
699
+
700
+ declare type UpdateEventInstructionData = {
701
+ name: string
702
+ sourceValue: EventListener
703
+ targetValue: EventListener
704
+ }
705
+
706
+ declare const updaters: {
707
+ object: <T extends Object>(store: Store<T>) => StoreUpdaterObject<T>
708
+ list: <T>(store: Store<T[]>) => StoreUpdaterList<T>
709
+ boolean: (store: Store<boolean>) => StoreUpdaterBoolean
710
+ }
711
+
712
+ declare type UpdaterValue<T> = boolean | T | T[]
713
+
714
+ declare type ViewModel<ATTRIBUTES, STORE_MAP> = (
715
+ storeMap: STORE_MAP,
716
+ ) => Partial<ATTRIBUTES>
717
+
718
+ export {}