jaxs 0.6.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 CHANGED
@@ -1,671 +1,944 @@
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/boolean" {
43
- import { Store } from "types";
44
- import { StoreUpdaterBase } from "state/store-updater";
45
- export class StoreUpdaterBoolean extends StoreUpdaterBase<boolean> {
46
- toggle(): void;
47
- setTrue(): void;
48
- setFalse(): void;
49
- }
50
- export const booleanUpdater: (store: Store<boolean>) => StoreUpdaterBoolean;
51
- }
52
- declare module "state/updaters/list" {
53
- import { StoreListSorterFunction, Store } from "types";
54
- import { StoreUpdaterBase } from "state/store-updater";
55
- export class StoreUpdaterList<T> extends StoreUpdaterBase<T[]> {
56
- push(element: T): void;
57
- pop(): T;
58
- unshift(element: T): void;
59
- shift(): T;
60
- addSorter(name: string, sorter: StoreListSorterFunction<T>): void;
61
- sortBy(sorter: StoreListSorterFunction<T>): void;
62
- insertAt(index: number, item: T): void;
63
- remove(value: T): void;
64
- removeBy(matcherFunction: (value: T) => boolean): void;
65
- }
66
- export const listUpdater: <T>(store: Store<T[]>) => StoreUpdaterList<T>;
67
- }
68
- declare module "state/updaters/object" {
69
- import { Store } from "types";
70
- import { StoreUpdaterBase } from "state/store-updater";
71
- export class StoreUpdaterObject<T> extends StoreUpdaterBase<T> {
72
- updateAttribute(name: keyof T, value: T[keyof T]): void;
73
- resetAttribute(name: keyof T): void;
74
- }
75
- export const objectUpdater: <T>(store: Store<T>) => StoreUpdaterObject<T>;
76
- }
77
- declare module "state/updaters" {
78
- export const updaters: {
79
- object: <T>(store: import("state").Store<T>) => import("state/updaters/object").StoreUpdaterObject<T>;
80
- list: <T>(store: import("state").Store<T[]>) => import("state/updaters/list").StoreUpdaterList<T>;
81
- boolean: (store: import("state").Store<boolean>) => import("state/updaters/boolean").StoreUpdaterBoolean;
82
- };
83
- }
84
- declare module "state/index" {
85
- import { Store } from "state/store";
86
- import type { StatePublisher, StateTransactionUpdater, StoresCollection } from "types";
87
- import { updaters } from "state/updaters";
88
- export const eventName = "state";
89
- export class State {
90
- publisher: StatePublisher;
91
- stores: StoresCollection;
92
- eventNamePrefix: string;
93
- notifications: Set<string>;
94
- inTransaction: boolean;
95
- constructor(publisher: StatePublisher);
96
- create<T>(name: string, initialState: T): Store<T>;
97
- createBoolean(name: string, initialState: boolean): Store<boolean>;
98
- createRecord<T>(name: string, initialState: T): Store<T>;
99
- createList<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/index" {
135
- import { BusEventMatcher, BusListener, Unsubscribe, AppAdditionListenerOptions, ListenerKit } from "types";
136
- import { ExactSubscriptions } from "bus/exact-subscriptions";
137
- import { FuzzySubscriptions } from "bus/fuzzy-subscriptions";
138
- class JaxsBus {
139
- options?: AppAdditionListenerOptions;
140
- exactSubscriptions: ExactSubscriptions;
141
- fuzzySubscriptions: FuzzySubscriptions;
142
- currentIndex: number;
143
- constructor();
144
- subscribe<T>(matcher: BusEventMatcher, listener: BusListener<T>): Unsubscribe;
145
- publish<T>(event: string, payload: T): void;
146
- addListenerOptions(options: AppAdditionListenerOptions): void;
147
- listenerOptions(event: string): ListenerKit;
148
- }
149
- const createBus: () => {
150
- bus: JaxsBus;
151
- publish: (event: string, payload: any) => void;
152
- subscribe: (matcher: BusEventMatcher, listener: BusListener<any>) => Unsubscribe;
153
- };
154
- export { createBus, JaxsBus, ExactSubscriptions, FuzzySubscriptions };
155
- }
156
- declare module "rendering/templates/root" {
157
- import type { JaxsElement, JaxsNodes, RenderKit, Renderable, JaxsNode } from "types";
158
- export class Root {
159
- template: Renderable;
160
- selector: string;
161
- renderKit: RenderKit;
162
- dom: JaxsNodes;
163
- parentElement?: JaxsElement | null;
164
- constructor(template: Renderable, selector: string, renderKit: RenderKit);
165
- renderAndAttach(renderKit: RenderKit): void;
166
- render(renderKit: RenderKit): JaxsNode[];
167
- attach(): void;
168
- getParentElement(): Element;
169
- }
170
- export const render: (template: Renderable, selector: string, renderKit: RenderKit) => Root;
171
- }
172
- declare module "navigation/events" {
173
- export const linkNavigationEvent = "go-to-href";
174
- export const locationChangeEvent = "navigation:location-change";
175
- export const routeChangeEvent = "navigation:route-change";
176
- }
177
- declare module "navigation/route-state" {
178
- import { State } from "state/index";
179
- export const createRouteState: (state: State) => void;
180
- }
181
- declare module "navigation/find-href" {
182
- export const findHref: (node: HTMLElement) => string;
183
- }
184
- declare module "navigation/navigate" {
185
- import { ListenerKit } from "types";
186
- export const navigate: (path: string, { publish, window }: ListenerKit) => void;
187
- }
188
- declare module "navigation/on-link-click" {
189
- import { ListenerKit } from "types";
190
- export const onLinkClick: (domEvent: MouseEvent, options: ListenerKit) => void;
191
- }
192
- declare module "navigation/extract-query-params" {
193
- export const extractQueryParams: (queryString: string) => {};
194
- }
195
- declare module "navigation/on-location-change" {
196
- import { ListenerKit } from "types";
197
- export const onLocationChange: (_: null, listenerOptions: ListenerKit) => void;
198
- }
199
- declare module "navigation/start" {
200
- import type { App } from "app/index";
201
- export const subscribeToNavigation: (app: App) => void;
202
- export const subscribeToHistoryChange: (app: App) => void;
203
- export const publishLocation: (app: App) => void;
204
- export const startNavigation: (app: App) => void;
205
- }
206
- declare module "app/index" {
207
- import type { Renderable, RenderKit, Subscribe, PublishFunction } from "types";
208
- import type { State } from "state/index";
209
- import type { JaxsBus } from "bus/index";
210
- import { Root } from "rendering/templates/root";
211
- export class App {
212
- window: Window;
213
- document: Document;
214
- publish: PublishFunction;
215
- subscribe: Subscribe;
216
- bus: JaxsBus;
217
- state: State;
218
- renderKit: RenderKit;
219
- roots: Root[];
220
- constructor({ window, document, publish, subscribe, bus, state, renderKit }: {
221
- window: any;
222
- document: any;
223
- publish: any;
224
- subscribe: any;
225
- bus: any;
226
- state: any;
227
- renderKit: any;
228
- });
229
- render(template: Renderable, selector: string): Root;
230
- startNavigation(): void;
231
- }
232
- }
233
- declare module "types" {
234
- import type { State } from "state/index";
235
- import type { Store } from "state/store";
236
- import type { StoreUpdaterBase } from "state/store-updater";
237
- import type { StoreUpdaterBoolean } from "state/updaters/boolean";
238
- import type { StoreUpdaterList } from "state/updaters/list";
239
- import type { StoreUpdaterObject } from "state/updaters/object";
240
- export type { App } from "app/index";
241
- export { State, Store, StoreUpdaterBase, StoreUpdaterBoolean, StoreUpdaterList, StoreUpdaterObject, };
242
- export type StoreUpdater<T> = StoreUpdaterBase<T> | StoreUpdaterObject<T> | StoreUpdaterBoolean | StoreUpdaterList<T>;
243
- export type TextValue = string | number;
244
- export interface JsxIded {
245
- __jsx?: string;
246
- }
247
- export type JsxChangeId = {
248
- element: JaxsNode;
249
- index: number;
250
- };
251
- export type EventMap = {
252
- domEvent: string;
253
- busEvent: string;
254
- listener: EventListener;
255
- };
256
- export type EventMaps = Record<string, EventMap>;
257
- interface JsxEventMapped {
258
- eventMaps: EventMaps;
259
- }
260
- export type JaxsElement = Element & JsxIded & JsxEventMapped;
261
- export type JaxsText = Text & JsxIded;
262
- export type JaxsSvgElement = SVGElement & JsxIded;
263
- export type JaxsNode = JaxsElement | JaxsText | JaxsSvgElement;
264
- export type JaxsNodes = JaxsNode[] | NodeListOf<JaxsNode>;
265
- export type JaxsInput = HTMLInputElement & JsxIded & JsxEventMapped;
266
- type NullValues = null | undefined;
267
- export type ReactSourceObject = {
268
- fileName: string;
269
- lineNumber: string;
270
- columnNumber: string;
271
- };
272
- interface SourceMap {
273
- __source?: ReactSourceObject;
274
- }
275
- export type Props<T> = Partial<{
276
- __source: ReactSourceObject;
277
- children: JsxCollection;
278
- }> & T;
279
- export type PropValue = TextValue | NullValues | boolean | ReactSourceObject | JsxCollection;
280
- export type TagAttributes = SourceMap & Record<string, string>;
281
- export type TagEventAttributes = Record<string, string>;
282
- export type TagAttributesAndEvents = {
283
- attributes: TagAttributes;
284
- events: TagEventAttributes;
285
- };
286
- export type DomPublish = (eventName: string, domEvent: Event) => void;
287
- export type Subscribe = (matcher: BusEventMatcher, listener: BusListener<any>) => void;
288
- export type RenderKit = {
289
- document: Document;
290
- window: Window;
291
- publish: DomPublish;
292
- subscribe: Subscribe;
293
- state: State;
294
- parent?: JaxsNode | null;
295
- };
296
- export interface Renderable {
297
- render: (renderKit: RenderKit, parentElement?: JaxsElement) => JaxsNode[];
298
- }
299
- export type StaticTemplate = () => Renderable;
300
- export type TypedTemplate<T> = (props: Props<T>) => Renderable;
301
- export type Template<T> = StaticTemplate | TypedTemplate<T>;
302
- export type JsxCollection = (Renderable | TextValue)[];
303
- export enum ChangeInstructionTypes {
304
- removeNode = 0,
305
- insertNode = 1,// can be to move an existing element in the dom, or to add one
306
- replaceNode = 2,
307
- removeAttribute = 3,
308
- addAttribute = 4,
309
- updateAttribute = 5,
310
- removeEvent = 6,
311
- addEvent = 7,
312
- updateEvent = 8,
313
- changeValue = 9,
314
- changeText = 10
315
- }
316
- export type RemoveInstructionData = {
317
- name: string;
318
- isSvg?: boolean;
319
- };
320
- export type AttributeInstructionData = {
321
- name: string;
322
- value: string;
323
- isSvg?: boolean;
324
- };
325
- export type EventInstructionData = {
326
- name: string;
327
- value: EventListener;
328
- };
329
- export type UpdateEventInstructionData = {
330
- name: string;
331
- sourceValue: EventListener;
332
- targetValue: EventListener;
333
- };
334
- export type InsertNodeData = {
335
- parent: JaxsElement;
336
- index: number;
337
- };
338
- type NullInstructionData = Record<string, never>;
339
- export type InstructionData = RemoveInstructionData | AttributeInstructionData | EventInstructionData | UpdateEventInstructionData | InsertNodeData | NullInstructionData;
340
- export type ChangeInstruction = {
341
- source: JaxsNode;
342
- target: JaxsNode;
343
- type: ChangeInstructionTypes;
344
- data: InstructionData;
345
- };
346
- export type ChangeInstructions = Array<ChangeInstruction>;
347
- export type InstructionsUpdater = (instruction: ChangeInstruction) => void;
348
- export type StoreMap = {
349
- [key: string]: any;
350
- };
351
- export type ViewModel<ATTRIBUTES, STORE_MAP> = (storeMap: STORE_MAP) => Partial<ATTRIBUTES>;
352
- export type BindSubscriptionList = string[];
353
- export type BindParams<T, U> = {
354
- Template: Template<T>;
355
- viewModel?: ViewModel<T, U>;
356
- subscriptions?: BindSubscriptionList;
357
- };
358
- export type AppAdditionListenerOptions = {
359
- state: State;
360
- document: Document;
361
- window: Window;
362
- };
363
- export type DefaultBusListenerOptions = {
364
- publish: PublishFunction;
365
- eventName: string;
366
- };
367
- export type ListenerKit = AppAdditionListenerOptions & DefaultBusListenerOptions;
368
- export type PublishFunction = (event: string, payload: any) => void;
369
- export type BusListener<T> = (payload: T, listenerKit: ListenerKit) => void;
370
- export type BusEventMatcher = string | RegExp;
371
- export type ExactSubscriptionData<T> = {
372
- listener: BusListener<T>;
373
- index: number;
374
- matcher: string;
375
- };
376
- export type FuzzySubscriptionData<T> = {
377
- listener: BusListener<T>;
378
- index: number;
379
- matcher: RegExp;
380
- };
381
- export type Unsubscribe = () => void;
382
- export type CreateAppBuilderArguments = {
383
- window?: Window;
384
- document?: Document;
385
- };
386
- export type RouteState = {
387
- host: string;
388
- path: string;
389
- query: Record<string, string>;
390
- };
391
- export type AttributesWithChildren<T> = Props<T> & {
392
- children?: JsxCollection;
393
- };
394
- export type DiffPair = {
395
- source: JaxsNode;
396
- target: JaxsNode;
397
- };
398
- export type CompileChildren = (sourceList: JaxsNodes, targetList: JaxsNodes, parent: JaxsElement) => ChangeInstructions;
399
- export type StatePublisher = (event: string, payload: any) => void;
400
- export type StateTransactionUpdater = (collection: StoresCollection) => void;
401
- export type StoresCollection = Record<string, Store<any>>;
402
- export type StoreInitializationOptions<T> = {
403
- name: string;
404
- parent: State;
405
- value: T;
406
- };
407
- export type StoreDataUpdater<T> = (originalValue: T) => T;
408
- export type UpdaterValue<T> = boolean | T | T[];
409
- export type StoreUpdaterOrValue<T> = UpdaterValue<T> | StoreDataUpdater<T>;
410
- export type StoreListSorterFunction<T> = (left: T, right: T) => number;
411
- export type RouteMatcher = (routeState: RouteState) => boolean;
412
- export type RenderedRoute = {
413
- Partial: StaticTemplate;
414
- match: RouteMatcher;
415
- };
416
- }
417
- declare module "rendering/dom/tag" {
418
- import type { JaxsElement, TagAttributes, TagEventAttributes, DomPublish, RenderKit } from "types";
419
- export const createNode: (type: string, document: Document) => HTMLElement;
420
- export const setAttributesOnElement: (element: Element, attributes: TagAttributes) => void;
421
- export const setEventsOnElement: (element: JaxsElement, events: TagEventAttributes, publish: DomPublish) => void;
422
- export const createDecoratedNode: (type: string, attributes: TagAttributes, events: TagEventAttributes, renderKit: RenderKit) => JaxsElement;
423
- }
424
- declare module "rendering/dom/svg" {
425
- import type { TagAttributes, JaxsElement } from "types";
426
- export const namespace = "http://www.w3.org/2000/svg";
427
- export const isSvgTag: (tagType: string, attributeNamespace?: string) => boolean;
428
- export const createSvgNode: (type: string, attributes: TagAttributes, document: Document) => JaxsElement;
429
- export const elementIsSvg: (element: JaxsElement) => boolean;
430
- }
431
- declare module "rendering/dom/text" {
432
- export const createTextNode: (value: string, document: Document) => Text;
433
- }
434
- declare module "rendering/templates/text" {
435
- import { Renderable, TextValue, RenderKit } from "types";
436
- export class TextTemplate implements Renderable {
437
- value: string;
438
- constructor(content: TextValue);
439
- render(renderKit: RenderKit): Text[];
440
- }
441
- }
442
- declare module "rendering/templates/children/text" {
443
- import { TextValue, Renderable } from "types";
444
- import { TextTemplate } from "rendering/templates/text";
445
- export const isTextValue: <T>(child: TextValue | T) => child is string | number | (T & string) | (T & number);
446
- export const textNode: (content: TextValue) => TextTemplate;
447
- export const replaceTextNodes: (child: TextValue | Renderable) => Renderable | TextTemplate;
448
- }
449
- declare module "rendering/templates/children/normalize" {
450
- import { JsxCollection, AttributesWithChildren } from "types";
451
- export const normalizeJsxChildren: (jsxChildren: JsxCollection) => (import("types").Renderable | import("rendering/templates/text").TextTemplate)[];
452
- export const normalizeToArray: <T>(children: T | T[]) => T[];
453
- export const ensureJsxChildrenArray: <T>(maybeChildren?: JsxCollection, attributes?: AttributesWithChildren<T>) => JsxCollection;
454
- }
455
- declare module "rendering/templates/tag/attributes-and-events" {
456
- import type { Props, TagAttributesAndEvents, JsxCollection } from "types";
457
- export const separateAttrsAndEvents: <T>(props: Props<T>, defaultValue?: string) => TagAttributesAndEvents;
458
- export const packageJsxAttributes: <T>(maybeAttributes?: Props<T>, maybeChildren?: JsxCollection) => Props<T>;
459
- }
460
- declare module "rendering/templates/children/render" {
461
- import { Renderable, RenderKit, JaxsNode, JaxsElement } from "types";
462
- export const recursiveRender: (children: Renderable[], renderKit: RenderKit, parentElement?: JaxsElement, rendered?: JaxsNode[]) => JaxsNode[];
463
- }
464
- declare module "rendering/templates/children" {
465
- import { JaxsElement, Renderable, JsxCollection, RenderKit, JaxsNodes, JaxsNode } from "types";
466
- export class Children implements Renderable {
467
- collection: Renderable[];
468
- parentElement?: JaxsElement;
469
- constructor(jsxChildren: JsxCollection);
470
- render(renderKit: RenderKit, parentElement?: JaxsElement): JaxsNode[];
471
- generateDom(renderKit: RenderKit): JaxsNode[];
472
- attachToParent(dom: JaxsNodes): void;
473
- }
474
- }
475
- declare module "rendering/templates/tag/jsx-key" {
476
- import { TagAttributes } from "types";
477
- export class JsxKey {
478
- attributes: TagAttributes;
479
- type: string;
480
- constructor(type: string, attributes: TagAttributes);
481
- generate(): string;
482
- sourceKey(): string;
483
- createKeyFromAttributes(): string;
484
- }
485
- }
486
- declare module "rendering/templates/tag" {
487
- import type { Props, JaxsNode, TagEventAttributes, Renderable, RenderKit, TagAttributes, JsxCollection } from "types";
488
- import { Children } from "rendering/templates/children";
489
- export class Tag<T> implements Renderable {
490
- type: string;
491
- events: TagEventAttributes;
492
- attributes: TagAttributes;
493
- props: Props<T>;
494
- children: Children;
495
- isSvg: boolean;
496
- constructor(tagType: string, props: Props<T>, children?: JsxCollection);
497
- render(renderKit: RenderKit): JaxsNode[];
498
- generateDom(renderKit: RenderKit): import("types").JaxsElement;
499
- generateHtmlDom(renderKit: RenderKit): import("types").JaxsElement;
500
- generateSvgDom(renderKit: RenderKit): import("types").JaxsElement;
501
- jsxKey(): string;
502
- }
503
- }
504
- declare module "rendering/jsx" {
505
- import type { JsxCollection, Props, Template, Renderable } from "types";
506
- import { Children } from "rendering/templates/children";
507
- const jsx: {
508
- <T>(type: string | Template<T>, attributes: Props<T>, ...children: JsxCollection): Renderable;
509
- fragment<T>(attributes: Props<T>, maybeChildren: JsxCollection): Children;
510
- };
511
- export { jsx };
512
- }
513
- declare module "app/builder" {
514
- import { App } from "app/index";
515
- import { JaxsBus } from "bus/index";
516
- import { State } from "state/index";
517
- import { PublishFunction, Subscribe, RenderKit, CreateAppBuilderArguments } from "types";
518
- class AppBuilder {
519
- window: Window;
520
- document: Document;
521
- publish: PublishFunction;
522
- subscribe: Subscribe;
523
- bus: JaxsBus;
524
- state: State;
525
- renderKit: RenderKit;
526
- constructor(domEnvironment: CreateAppBuilderArguments);
527
- setup(): App;
528
- setupDomEnvironment(domEnvironment: CreateAppBuilderArguments): void;
529
- setupBus(): void;
530
- setupState(): void;
531
- addBusOptions(): void;
532
- setRenderKit(): void;
533
- }
534
- const createApp: (domEnvironment?: CreateAppBuilderArguments) => App;
535
- export { App, AppBuilder, createApp };
536
- }
537
- declare module "rendering/update/instructions/instructions" {
538
- import { JaxsInput, ChangeInstruction, JaxsElement, RemoveInstructionData, AttributeInstructionData, EventInstructionData, UpdateEventInstructionData, InsertNodeData } from "types";
539
- export const changeText: (source: Text, target: Text) => ChangeInstruction;
540
- export const replaceNode: (source: JaxsElement, target: JaxsElement) => ChangeInstruction;
541
- export const removeAttribute: (source: JaxsElement, target: JaxsElement, data: RemoveInstructionData) => ChangeInstruction;
542
- export const addAttribute: (source: JaxsElement, target: JaxsElement, data: AttributeInstructionData) => ChangeInstruction;
543
- export const updateAttribute: (source: JaxsElement, target: JaxsElement, data: AttributeInstructionData) => ChangeInstruction;
544
- export const removeEvent: (source: JaxsElement, target: JaxsElement, data: EventInstructionData) => ChangeInstruction;
545
- export const addEvent: (source: JaxsElement, target: JaxsElement, data: EventInstructionData) => ChangeInstruction;
546
- export const updateEvent: (source: JaxsElement, target: JaxsElement, data: UpdateEventInstructionData) => ChangeInstruction;
547
- export const removeNode: (source: JaxsElement) => ChangeInstruction;
548
- export const insertNode: (target: JaxsElement, data: InsertNodeData) => ChangeInstruction;
549
- export const changeValue: (source: JaxsInput, target: JaxsInput, data: AttributeInstructionData) => ChangeInstruction;
550
- export const instructionsSorter: (left: ChangeInstruction, right: ChangeInstruction) => 0 | 1 | -1;
551
- }
552
- declare module "rendering/update/instructions/id-map" {
553
- import type { JaxsNode, JaxsNodes, JsxChangeId } from "types";
554
- export class IdMap {
555
- map: Record<string, JsxChangeId[]>;
556
- constructor();
557
- populate(list: JaxsNodes): void;
558
- pullMatch(element: JaxsNode): JsxChangeId;
559
- clear(element: JaxsNode): void;
560
- check(element: JaxsNode): boolean;
561
- remaining(): JsxChangeId[];
562
- }
563
- export const createIdMap: (list: JaxsNodes) => IdMap;
564
- }
565
- declare module "rendering/update/instructions/nodes/element/attributes" {
566
- import type { JaxsElement, ChangeInstructions } from "types";
567
- export const compileForAttributes: (source: JaxsElement, target: JaxsElement, isSvg?: boolean) => ChangeInstructions;
568
- }
569
- declare module "rendering/update/instructions/nodes/element/events" {
570
- import type { JaxsElement, ChangeInstructions } from "types";
571
- export const compileForEvents: (source: JaxsElement, target: JaxsElement) => ChangeInstructions;
572
- }
573
- declare module "rendering/update/instructions/nodes/input" {
574
- import { ChangeInstructions, JaxsElement } from "types";
575
- export const compileForInputValue: (sourceElement: JaxsElement, targetElement: JaxsElement) => ChangeInstructions;
576
- }
577
- declare module "rendering/update/instructions/nodes/element" {
578
- import type { JaxsElement } from "types";
579
- export const compileForElement: (source: JaxsElement, target: JaxsElement) => import("types").ChangeInstruction[];
580
- }
581
- declare module "rendering/update/instructions/nodes/svg" {
582
- import { JaxsElement } from "types";
583
- export const compileForSvg: (source: JaxsElement, target: JaxsElement) => import("types").ChangeInstructions;
584
- }
585
- declare module "rendering/update/instructions/nodes/text" {
586
- import type { ChangeInstructions } from "types";
587
- export const compileForText: (source: Text, target: Text) => ChangeInstructions;
588
- }
589
- declare module "rendering/update/instructions/node" {
590
- import type { JaxsNode, ChangeInstructions, CompileChildren } from "types";
591
- export const compileForNode: (source: JaxsNode, target: JaxsNode, compileChildren: CompileChildren) => ChangeInstructions;
592
- }
593
- declare module "rendering/update/instructions/collection" {
594
- import type { JaxsElement, JaxsNodes } from "types";
595
- export const compileCollection: (sourceList: JaxsNodes, targetList: JaxsNodes, parent: JaxsElement) => import("types").ChangeInstruction[];
596
- }
597
- declare module "rendering/update/perform-change" {
598
- import type { ChangeInstruction, JaxsElement, JaxsNodes } from "types";
599
- export const performChange: (source: JaxsNodes, target: JaxsNodes, parent: JaxsElement) => ChangeInstruction[];
600
- }
601
- declare module "rendering/templates/bound/modify-dom-cache" {
602
- import { ChangeInstructions, JaxsNode, JaxsElement } from "types";
603
- export const modifyDomCache: (instructions: ChangeInstructions, dom: JaxsNode[], parentElement: JaxsElement) => JaxsNode[];
604
- }
605
- declare module "rendering/templates/bound" {
606
- import { JaxsElement, Props, Template, RenderKit, ViewModel, BindParams, BindSubscriptionList, JaxsNode } from "types";
607
- export class Bound<ATTRIBUTES, STATE_MAP> {
608
- Template: Template<ATTRIBUTES>;
609
- viewModel: ViewModel<ATTRIBUTES, STATE_MAP>;
610
- attributes: Partial<Props<ATTRIBUTES>>;
611
- subscriptions: BindSubscriptionList;
612
- dom: JaxsNode[];
613
- parentElement: JaxsElement | null;
614
- renderKit?: RenderKit;
615
- constructor({ Template, subscriptions, attributes, viewModel }: {
616
- Template: any;
617
- subscriptions: any;
618
- attributes: any;
619
- viewModel: any;
620
- });
621
- render(renderKit: RenderKit): JaxsNode[];
622
- generateDom(renderKit: RenderKit): JaxsNode[];
623
- rerender(): void;
624
- subscribeForRerender(): void;
625
- eventName(storeName: string): string;
626
- }
627
- export const bind: <ATTRIBUTES, STATE_MAP>({ Template, viewModel, subscriptions, }: BindParams<ATTRIBUTES, STATE_MAP>) => (attributes: Partial<Props<ATTRIBUTES>>) => Bound<unknown, unknown>;
628
- }
629
- declare module "navigation/index" {
630
- import * as events from "navigation/events";
631
- import { extractQueryParams } from "navigation/extract-query-params";
632
- import { findHref } from "navigation/find-href";
633
- import { navigate } from "navigation/navigate";
634
- import { onLinkClick } from "navigation/on-link-click";
635
- import { onLocationChange } from "navigation/on-location-change";
636
- import { createRouteState } from "navigation/route-state";
637
- import * as start from "navigation/start";
638
- export { events, extractQueryParams, findHref, navigate, onLinkClick, onLocationChange, createRouteState, start, };
639
- }
640
- declare module "app/routing" {
641
- import { RenderedRoute, RouteMatcher } from "types";
642
- export const exactPathMatch: (exactPath: string) => RouteMatcher;
643
- export const catchAll: RouteMatcher;
644
- export const buildRouter: (pages: RenderedRoute[]) => ({ route }: {
645
- route: any;
646
- }) => import("types").StaticTemplate;
647
- }
648
- declare module "rendering/null" {
649
- import { RenderKit, JaxsElement, JaxsNode } from "types";
650
- export const NullTemplate: () => {
651
- render: (renderKit: RenderKit, parentElement?: JaxsElement) => JaxsNode[];
652
- };
653
- }
654
- declare module "app/routed-view" {
655
- import { RenderedRoute, RouteState } from "types";
656
- export const routedView: (routes: RenderedRoute[]) => (attributes: Partial<import("types").Props<{
657
- route: RouteState;
658
- }>>) => import("rendering/templates/bound").Bound<unknown, unknown>;
659
- }
660
- declare module "jaxs" {
661
- export { jsx } from "rendering/jsx";
662
- export { createApp } from "app/builder";
663
- export { bind } from "rendering/templates/bound";
664
- export * as JaxsTypes from "types";
665
- export * as navigation from "navigation/index";
666
- export * as appBuilding from "app/index";
667
- export * as messageBus from "bus/index";
668
- export * as state from "state/index";
669
- export * as routing from "app/routing";
670
- export { routedView } from "app/routed-view";
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 {
17
+ State,
18
+ StoreInitializationOptions,
19
+ StoreUpdaterOrValue,
20
+ StoreUpdater,
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'
39
+ export class StoreUpdaterBase<T> {
40
+ store: Store<T>
41
+ constructor(store: Store<T>)
42
+ update(updater: StoreUpdaterOrValue<T>): void
43
+ reset(): void
44
+ get value(): T
45
+ }
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
+ }
56
+ declare module 'state/updaters/list' {
57
+ import { StoreListSorterFunction, Store } from 'types'
58
+ import { StoreUpdaterBase } from 'state/store-updater'
59
+ export class StoreUpdaterList<T> extends StoreUpdaterBase<T[]> {
60
+ push(element: T): void
61
+ pop(): T
62
+ unshift(element: T): void
63
+ shift(): T
64
+ addSorter(name: string, sorter: StoreListSorterFunction<T>): void
65
+ sortBy(sorter: StoreListSorterFunction<T>): void
66
+ insertAt(index: number, item: T): void
67
+ remove(value: T): void
68
+ removeBy(matcherFunction: (value: T) => boolean): void
69
+ }
70
+ export const listUpdater: <T>(store: Store<T[]>) => StoreUpdaterList<T>
71
+ }
72
+ declare module 'state/updaters/boolean' {
73
+ import { Store } from 'types'
74
+ import { StoreUpdaterBase } from 'state/store-updater'
75
+ export class StoreUpdaterBoolean extends StoreUpdaterBase<boolean> {
76
+ toggle(): void
77
+ setTrue(): void
78
+ setFalse(): void
79
+ }
80
+ export const booleanUpdater: (store: Store<boolean>) => StoreUpdaterBoolean
81
+ }
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
+ }
94
+ }
95
+ declare module 'state/index' {
96
+ import { Store } from 'state/store'
97
+ import type {
98
+ StatePublisher,
99
+ StateTransactionUpdater,
100
+ StoresCollection,
101
+ } from 'types'
102
+ import { updaters } from 'state/updaters'
103
+ export const eventName = 'state'
104
+ export class State {
105
+ publisher: StatePublisher
106
+ stores: StoresCollection
107
+ eventNamePrefix: string
108
+ notifications: Set<string>
109
+ inTransaction: boolean
110
+ constructor(publisher: StatePublisher)
111
+ create<T>(name: string, initialState: T): Store<T>
112
+ store<T>(name: string): Store<T>
113
+ get<T>(name: string): T
114
+ getAll(names: string[]): {}
115
+ notify(name: string): void
116
+ update(name: string, newValue: any): void
117
+ transaction(updater: StateTransactionUpdater): void
118
+ publishAll(): void
119
+ publish(name: string): void
120
+ event(name: string): string
121
+ }
122
+ export const createState: (publisher: StatePublisher) => State
123
+ export { Store, updaters }
124
+ }
125
+ declare module 'bus/exact-subscriptions' {
126
+ import { ExactSubscriptionData, BusListener, Unsubscribe } from 'types'
127
+ export class ExactSubscriptions {
128
+ lookup: Record<string, ExactSubscriptionData<any>[]>
129
+ constructor()
130
+ add<T>(
131
+ matcher: string,
132
+ listener: BusListener<T>,
133
+ index: number,
134
+ ): Unsubscribe
135
+ remove<T>(subscription: ExactSubscriptionData<T>): void
136
+ matches(event: string): ExactSubscriptionData<any>[]
137
+ ensureArrayFor(matcher: string): void
138
+ }
139
+ }
140
+ declare module 'bus/fuzzy-subscriptions' {
141
+ import { FuzzySubscriptionData, BusListener, Unsubscribe } from 'types'
142
+ export class FuzzySubscriptions {
143
+ lookup: FuzzySubscriptionData<any>[]
144
+ constructor()
145
+ add<T>(
146
+ matcher: RegExp,
147
+ listener: BusListener<T>,
148
+ index: number,
149
+ ): Unsubscribe
150
+ remove<T>(subscription: FuzzySubscriptionData<T>): void
151
+ matches(event: string): FuzzySubscriptionData<any>[]
152
+ }
153
+ }
154
+ declare module 'bus/index' {
155
+ import {
156
+ BusEventMatcher,
157
+ BusListener,
158
+ Unsubscribe,
159
+ AppAdditionListenerOptions,
160
+ ListenerKit,
161
+ } from 'types'
162
+ import { ExactSubscriptions } from 'bus/exact-subscriptions'
163
+ import { FuzzySubscriptions } from 'bus/fuzzy-subscriptions'
164
+ class JaxsBus {
165
+ options?: AppAdditionListenerOptions
166
+ exactSubscriptions: ExactSubscriptions
167
+ fuzzySubscriptions: FuzzySubscriptions
168
+ currentIndex: number
169
+ constructor()
170
+ subscribe<T>(
171
+ matcher: BusEventMatcher,
172
+ listener: BusListener<T>,
173
+ ): Unsubscribe
174
+ publish<T>(event: string, payload: T): void
175
+ addListenerOptions(options: AppAdditionListenerOptions): void
176
+ listenerOptions(event: string): ListenerKit
177
+ }
178
+ const createBus: () => {
179
+ bus: JaxsBus
180
+ publish: (event: string, payload: any) => void
181
+ subscribe: (
182
+ matcher: BusEventMatcher,
183
+ listener: BusListener<any>,
184
+ ) => Unsubscribe
185
+ }
186
+ export { createBus, JaxsBus, ExactSubscriptions, FuzzySubscriptions }
187
+ }
188
+ declare module 'rendering/templates/root' {
189
+ import type {
190
+ JaxsElement,
191
+ JaxsNodes,
192
+ RenderKit,
193
+ Renderable,
194
+ JaxsNode,
195
+ } from 'types'
196
+ export class Root {
197
+ template: Renderable
198
+ selector: string
199
+ renderKit: RenderKit
200
+ dom: JaxsNodes
201
+ parentElement?: JaxsElement | null
202
+ constructor(template: Renderable, selector: string, renderKit: RenderKit)
203
+ renderAndAttach(renderKit: RenderKit): void
204
+ render(renderKit: RenderKit): JaxsNode[]
205
+ attach(): void
206
+ getParentElement(): Element
207
+ }
208
+ export const render: (
209
+ template: Renderable,
210
+ selector: string,
211
+ renderKit: RenderKit,
212
+ ) => Root
213
+ }
214
+ declare module 'navigation/events' {
215
+ export const linkNavigationEvent = 'go-to-href'
216
+ export const navigationEvent = 'go-to'
217
+ export const locationChangeEvent = 'navigation:location-change'
218
+ export const routeChangeEvent = 'navigation:route-change'
219
+ }
220
+ declare module 'navigation/route-state' {
221
+ import { State } from 'state/index'
222
+ export const createRouteState: (state: State) => void
223
+ }
224
+ declare module 'navigation/find-href' {
225
+ export const findHref: (node: HTMLElement) => string
226
+ }
227
+ declare module 'navigation/navigate' {
228
+ import { ListenerKit } from 'types'
229
+ export const navigate: (
230
+ path: string,
231
+ { publish, window }: ListenerKit,
232
+ ) => void
233
+ }
234
+ declare module 'navigation/on-link-click' {
235
+ import { ListenerKit } from 'types'
236
+ export const onLinkClick: (domEvent: MouseEvent, options: ListenerKit) => void
237
+ }
238
+ declare module 'navigation/extract-query-params' {
239
+ export const extractQueryParams: (queryString: string) => {}
240
+ }
241
+ declare module 'navigation/on-location-change' {
242
+ import { ListenerKit } from 'types'
243
+ export const onLocationChange: (_: null, listenerOptions: ListenerKit) => void
244
+ }
245
+ declare module 'navigation/start' {
246
+ import type { App } from 'app/index'
247
+ export const subscribeToNavigation: (app: App) => void
248
+ export const subscribeToHistoryChange: (app: App) => void
249
+ export const publishLocation: (app: App) => void
250
+ export const startNavigation: (app: App) => void
251
+ }
252
+ declare module 'app/index' {
253
+ import type { Renderable, RenderKit, Subscribe, PublishFunction } from 'types'
254
+ import type { State } from 'state/index'
255
+ import type { JaxsBus } from 'bus/index'
256
+ import { Root } from 'rendering/templates/root'
257
+ export class App {
258
+ window: Window
259
+ document: Document
260
+ publish: PublishFunction
261
+ subscribe: Subscribe
262
+ bus: JaxsBus
263
+ state: State
264
+ renderKit: RenderKit
265
+ roots: Root[]
266
+ constructor({
267
+ window,
268
+ document,
269
+ publish,
270
+ subscribe,
271
+ bus,
272
+ state,
273
+ renderKit,
274
+ }: {
275
+ window: any
276
+ document: any
277
+ publish: any
278
+ subscribe: any
279
+ bus: any
280
+ state: any
281
+ renderKit: any
282
+ })
283
+ render(template: Renderable, selector: string): Root
284
+ startNavigation(): void
285
+ }
286
+ }
287
+ declare module 'types' {
288
+ import type { State } from 'state/index'
289
+ import type { Store } from 'state/store'
290
+ import type { StoreUpdaterBase } from 'state/store-updater'
291
+ import type { StoreUpdaterBoolean } from 'state/updaters/boolean'
292
+ import type { StoreUpdaterList } from 'state/updaters/list'
293
+ import type { StoreUpdaterObject } from 'state/updaters/object'
294
+ export type { App } from 'app/index'
295
+ export {
296
+ State,
297
+ Store,
298
+ StoreUpdaterBase,
299
+ StoreUpdaterBoolean,
300
+ StoreUpdaterList,
301
+ StoreUpdaterObject,
302
+ }
303
+ export type StoreUpdater<T> =
304
+ | StoreUpdaterBase<T>
305
+ | StoreUpdaterObject<T>
306
+ | StoreUpdaterBoolean
307
+ | StoreUpdaterList<T>
308
+ export type TextValue = string | number
309
+ export interface JsxIded {
310
+ __jsx?: string
311
+ }
312
+ export type JsxChangeId = {
313
+ element: JaxsNode
314
+ index: number
315
+ }
316
+ export type EventMap = {
317
+ domEvent: string
318
+ busEvent: string
319
+ listener: EventListener
320
+ }
321
+ export type EventMaps = Record<string, EventMap>
322
+ interface JsxEventMapped {
323
+ eventMaps: EventMaps
324
+ }
325
+ export type JaxsElement = Element & JsxIded & JsxEventMapped
326
+ export type JaxsText = Text & JsxIded
327
+ export type JaxsSvgElement = SVGElement & JsxIded
328
+ export type JaxsNode = JaxsElement | JaxsText | JaxsSvgElement
329
+ export type JaxsNodes = JaxsNode[] | NodeListOf<JaxsNode>
330
+ export type JaxsInput = HTMLInputElement & JsxIded & JsxEventMapped
331
+ type NullValues = null | undefined
332
+ export type ReactSourceObject = {
333
+ fileName: string
334
+ lineNumber: string
335
+ columnNumber: string
336
+ }
337
+ interface SourceMap {
338
+ __source?: ReactSourceObject
339
+ }
340
+ export type Props<T> = Partial<{
341
+ __source: ReactSourceObject
342
+ children: JsxCollection
343
+ }> &
344
+ T
345
+ export type PropValue =
346
+ | TextValue
347
+ | NullValues
348
+ | boolean
349
+ | ReactSourceObject
350
+ | JsxCollection
351
+ export type TagAttributes = SourceMap & Record<string, string>
352
+ export type TagEventAttributes = Record<string, string>
353
+ export type TagAttributesAndEvents = {
354
+ attributes: TagAttributes
355
+ events: TagEventAttributes
356
+ }
357
+ export type DomPublish = (eventName: string, domEvent: Event) => void
358
+ export type Subscribe = (
359
+ matcher: BusEventMatcher,
360
+ listener: BusListener<any>,
361
+ ) => void
362
+ export type RenderKit = {
363
+ document: Document
364
+ window: Window
365
+ publish: DomPublish
366
+ subscribe: Subscribe
367
+ state: State
368
+ parent?: JaxsNode | null
369
+ }
370
+ export interface Renderable {
371
+ render: (renderKit: RenderKit, parentElement?: JaxsElement) => JaxsNode[]
372
+ }
373
+ export type StaticTemplate = () => Renderable
374
+ export type TypedTemplate<T> = (props: Props<T>) => Renderable
375
+ export type Template<T> = StaticTemplate | TypedTemplate<T>
376
+ export type JsxCollection = (Renderable | TextValue)[]
377
+ export enum ChangeInstructionTypes {
378
+ removeNode = 0,
379
+ insertNode = 1, // can be to move an existing element in the dom, or to add one
380
+ replaceNode = 2,
381
+ removeAttribute = 3,
382
+ addAttribute = 4,
383
+ updateAttribute = 5,
384
+ removeEvent = 6,
385
+ addEvent = 7,
386
+ updateEvent = 8,
387
+ changeValue = 9,
388
+ changeText = 10,
389
+ }
390
+ export type RemoveInstructionData = {
391
+ name: string
392
+ isSvg?: boolean
393
+ }
394
+ export type AttributeInstructionData = {
395
+ name: string
396
+ value: string
397
+ isSvg?: boolean
398
+ }
399
+ export type EventInstructionData = {
400
+ name: string
401
+ value: EventListener
402
+ }
403
+ export type UpdateEventInstructionData = {
404
+ name: string
405
+ sourceValue: EventListener
406
+ targetValue: EventListener
407
+ }
408
+ export type InsertNodeData = {
409
+ parent: JaxsElement
410
+ index: number
411
+ }
412
+ type NullInstructionData = Record<string, never>
413
+ export type InstructionData =
414
+ | RemoveInstructionData
415
+ | AttributeInstructionData
416
+ | EventInstructionData
417
+ | UpdateEventInstructionData
418
+ | InsertNodeData
419
+ | NullInstructionData
420
+ export type ChangeInstruction = {
421
+ source: JaxsNode
422
+ target: JaxsNode
423
+ type: ChangeInstructionTypes
424
+ data: InstructionData
425
+ }
426
+ export type ChangeInstructions = Array<ChangeInstruction>
427
+ export type InstructionsUpdater = (instruction: ChangeInstruction) => void
428
+ export type StoreMap = {
429
+ [key: string]: any
430
+ }
431
+ export type ViewModel<ATTRIBUTES, STORE_MAP> = (
432
+ storeMap: STORE_MAP,
433
+ ) => Partial<ATTRIBUTES>
434
+ export type BindSubscriptionList = string[]
435
+ export type BindParams<T, U> = {
436
+ Template: Template<T>
437
+ viewModel?: ViewModel<T, U>
438
+ subscriptions?: BindSubscriptionList
439
+ }
440
+ export type AppAdditionListenerOptions = {
441
+ state: State
442
+ document: Document
443
+ window: Window
444
+ }
445
+ export type DefaultBusListenerOptions = {
446
+ publish: PublishFunction
447
+ eventName: string
448
+ }
449
+ export type ListenerKit = AppAdditionListenerOptions &
450
+ DefaultBusListenerOptions
451
+ export type PublishFunction = (event: string, payload: any) => void
452
+ export type BusListener<T> = (payload: T, listenerKit: ListenerKit) => void
453
+ export type BusEventMatcher = string | RegExp
454
+ export type ExactSubscriptionData<T> = {
455
+ listener: BusListener<T>
456
+ index: number
457
+ matcher: string
458
+ }
459
+ export type FuzzySubscriptionData<T> = {
460
+ listener: BusListener<T>
461
+ index: number
462
+ matcher: RegExp
463
+ }
464
+ export type Unsubscribe = () => void
465
+ export type CreateAppBuilderArguments = {
466
+ window?: Window
467
+ document?: Document
468
+ }
469
+ export type RouteState = {
470
+ host: string
471
+ path: string
472
+ query: Record<string, string>
473
+ }
474
+ export type AttributesWithChildren<T> = Props<T> & {
475
+ children?: JsxCollection
476
+ }
477
+ export type DiffPair = {
478
+ source: JaxsNode
479
+ target: JaxsNode
480
+ }
481
+ export type CompileChildren = (
482
+ sourceList: JaxsNodes,
483
+ targetList: JaxsNodes,
484
+ parent: JaxsElement,
485
+ ) => ChangeInstructions
486
+ export type StatePublisher = (event: string, payload: any) => void
487
+ export type StateTransactionUpdater = (collection: StoresCollection) => void
488
+ export type StoresCollection = Record<string, Store<any>>
489
+ export type StoreInitializationOptions<T> = {
490
+ name: string
491
+ parent: State
492
+ value: T
493
+ }
494
+ export type StoreDataUpdater<T> = (originalValue: T) => T
495
+ export type UpdaterValue<T> = boolean | T | T[]
496
+ export type StoreUpdaterOrValue<T> = UpdaterValue<T> | StoreDataUpdater<T>
497
+ export type StoreListSorterFunction<T> = (left: T, right: T) => number
498
+ export type RouteMatcher = (routeState: RouteState) => boolean
499
+ export type RenderedRoute = {
500
+ Partial: StaticTemplate
501
+ match: RouteMatcher
502
+ }
503
+ }
504
+ declare module 'rendering/dom/tag' {
505
+ import type {
506
+ JaxsElement,
507
+ TagAttributes,
508
+ TagEventAttributes,
509
+ DomPublish,
510
+ RenderKit,
511
+ } from 'types'
512
+ export const createNode: (type: string, document: Document) => HTMLElement
513
+ export const setAttributesOnElement: (
514
+ element: Element,
515
+ attributes: TagAttributes,
516
+ ) => void
517
+ export const setEventsOnElement: (
518
+ element: JaxsElement,
519
+ events: TagEventAttributes,
520
+ publish: DomPublish,
521
+ ) => void
522
+ export const createDecoratedNode: (
523
+ type: string,
524
+ attributes: TagAttributes,
525
+ events: TagEventAttributes,
526
+ renderKit: RenderKit,
527
+ ) => JaxsElement
528
+ }
529
+ declare module 'rendering/dom/svg' {
530
+ import type { TagAttributes, JaxsElement } from 'types'
531
+ export const namespace = 'http://www.w3.org/2000/svg'
532
+ export const isSvgTag: (
533
+ tagType: string,
534
+ attributeNamespace?: string,
535
+ ) => boolean
536
+ export const createSvgNode: (
537
+ type: string,
538
+ attributes: TagAttributes,
539
+ document: Document,
540
+ ) => JaxsElement
541
+ export const elementIsSvg: (element: JaxsElement) => boolean
542
+ }
543
+ declare module 'rendering/dom/text' {
544
+ export const createTextNode: (value: string, document: Document) => Text
545
+ }
546
+ declare module 'rendering/templates/text' {
547
+ import { Renderable, TextValue, RenderKit } from 'types'
548
+ export class TextTemplate implements Renderable {
549
+ value: string
550
+ constructor(content: TextValue)
551
+ render(renderKit: RenderKit): Text[]
552
+ }
553
+ }
554
+ declare module 'rendering/templates/children/text' {
555
+ import { TextValue, Renderable } from 'types'
556
+ import { TextTemplate } from 'rendering/templates/text'
557
+ export const isTextValue: <T>(
558
+ child: TextValue | T,
559
+ ) => child is string | number | (T & string) | (T & number)
560
+ export const textNode: (content: TextValue) => TextTemplate
561
+ export const replaceTextNodes: (
562
+ child: TextValue | Renderable,
563
+ ) => Renderable | TextTemplate
564
+ }
565
+ declare module 'rendering/templates/children/normalize' {
566
+ import { JsxCollection, AttributesWithChildren } from 'types'
567
+ export const normalizeJsxChildren: (
568
+ jsxChildren: JsxCollection,
569
+ ) => (
570
+ | import('types').Renderable
571
+ | import('rendering/templates/text').TextTemplate
572
+ )[]
573
+ export const normalizeToArray: <T>(children: T | T[]) => T[]
574
+ export const ensureJsxChildrenArray: <T>(
575
+ maybeChildren?: JsxCollection,
576
+ attributes?: AttributesWithChildren<T>,
577
+ ) => JsxCollection
578
+ }
579
+ declare module 'rendering/templates/tag/attributes-and-events' {
580
+ import type { Props, TagAttributesAndEvents, JsxCollection } from 'types'
581
+ export const separateAttrsAndEvents: <T>(
582
+ props: Props<T>,
583
+ defaultValue?: string,
584
+ ) => TagAttributesAndEvents
585
+ export const packageJsxAttributes: <T>(
586
+ maybeAttributes?: Props<T>,
587
+ maybeChildren?: JsxCollection,
588
+ ) => Props<T>
589
+ }
590
+ declare module 'rendering/templates/children/render' {
591
+ import { Renderable, RenderKit, JaxsNode, JaxsElement } from 'types'
592
+ export const recursiveRender: (
593
+ children: Renderable[],
594
+ renderKit: RenderKit,
595
+ parentElement?: JaxsElement,
596
+ rendered?: JaxsNode[],
597
+ ) => JaxsNode[]
598
+ }
599
+ declare module 'rendering/templates/children' {
600
+ import {
601
+ JaxsElement,
602
+ Renderable,
603
+ JsxCollection,
604
+ RenderKit,
605
+ JaxsNodes,
606
+ JaxsNode,
607
+ } from 'types'
608
+ export class Children implements Renderable {
609
+ collection: Renderable[]
610
+ parentElement?: JaxsElement
611
+ constructor(jsxChildren: JsxCollection)
612
+ render(renderKit: RenderKit, parentElement?: JaxsElement): JaxsNode[]
613
+ generateDom(renderKit: RenderKit): JaxsNode[]
614
+ attachToParent(dom: JaxsNodes): void
615
+ }
616
+ }
617
+ declare module 'rendering/templates/tag/jsx-key' {
618
+ import { TagAttributes } from 'types'
619
+ export class JsxKey {
620
+ attributes: TagAttributes
621
+ type: string
622
+ constructor(type: string, attributes: TagAttributes)
623
+ generate(): string
624
+ sourceKey(): string
625
+ createKeyFromAttributes(): string
626
+ }
627
+ }
628
+ declare module 'rendering/templates/tag' {
629
+ import type {
630
+ Props,
631
+ JaxsNode,
632
+ TagEventAttributes,
633
+ Renderable,
634
+ RenderKit,
635
+ TagAttributes,
636
+ JsxCollection,
637
+ } from 'types'
638
+ import { Children } from 'rendering/templates/children'
639
+ export class Tag<T> implements Renderable {
640
+ type: string
641
+ events: TagEventAttributes
642
+ attributes: TagAttributes
643
+ props: Props<T>
644
+ children: Children
645
+ isSvg: boolean
646
+ constructor(tagType: string, props: Props<T>, children?: JsxCollection)
647
+ render(renderKit: RenderKit): JaxsNode[]
648
+ generateDom(renderKit: RenderKit): import('types').JaxsElement
649
+ generateHtmlDom(renderKit: RenderKit): import('types').JaxsElement
650
+ generateSvgDom(renderKit: RenderKit): import('types').JaxsElement
651
+ jsxKey(): string
652
+ }
653
+ }
654
+ declare module 'rendering/jsx' {
655
+ import type { JsxCollection, Props, Template, Renderable } from 'types'
656
+ import { Children } from 'rendering/templates/children'
657
+ const jsx: {
658
+ <T>(
659
+ type: string | Template<T>,
660
+ attributes: Props<T>,
661
+ ...children: JsxCollection
662
+ ): Renderable
663
+ fragment<T>(attributes: Props<T>, maybeChildren: JsxCollection): Children
664
+ }
665
+ export { jsx }
666
+ }
667
+ declare module 'app/builder' {
668
+ import { App } from 'app/index'
669
+ import { JaxsBus } from 'bus/index'
670
+ import { State } from 'state/index'
671
+ import {
672
+ PublishFunction,
673
+ Subscribe,
674
+ RenderKit,
675
+ CreateAppBuilderArguments,
676
+ } from 'types'
677
+ class AppBuilder {
678
+ window: Window
679
+ document: Document
680
+ publish: PublishFunction
681
+ subscribe: Subscribe
682
+ bus: JaxsBus
683
+ state: State
684
+ renderKit: RenderKit
685
+ constructor(domEnvironment: CreateAppBuilderArguments)
686
+ setup(): App
687
+ setupDomEnvironment(domEnvironment: CreateAppBuilderArguments): void
688
+ setupBus(): void
689
+ setupState(): void
690
+ addBusOptions(): void
691
+ setRenderKit(): void
692
+ }
693
+ const createApp: (domEnvironment?: CreateAppBuilderArguments) => App
694
+ export { App, AppBuilder, createApp }
695
+ }
696
+ declare module 'rendering/update/instructions/instructions' {
697
+ import {
698
+ JaxsInput,
699
+ ChangeInstruction,
700
+ JaxsElement,
701
+ RemoveInstructionData,
702
+ AttributeInstructionData,
703
+ EventInstructionData,
704
+ UpdateEventInstructionData,
705
+ InsertNodeData,
706
+ } from 'types'
707
+ export const changeText: (source: Text, target: Text) => ChangeInstruction
708
+ export const replaceNode: (
709
+ source: JaxsElement,
710
+ target: JaxsElement,
711
+ ) => ChangeInstruction
712
+ export const removeAttribute: (
713
+ source: JaxsElement,
714
+ target: JaxsElement,
715
+ data: RemoveInstructionData,
716
+ ) => ChangeInstruction
717
+ export const addAttribute: (
718
+ source: JaxsElement,
719
+ target: JaxsElement,
720
+ data: AttributeInstructionData,
721
+ ) => ChangeInstruction
722
+ export const updateAttribute: (
723
+ source: JaxsElement,
724
+ target: JaxsElement,
725
+ data: AttributeInstructionData,
726
+ ) => ChangeInstruction
727
+ export const removeEvent: (
728
+ source: JaxsElement,
729
+ target: JaxsElement,
730
+ data: EventInstructionData,
731
+ ) => ChangeInstruction
732
+ export const addEvent: (
733
+ source: JaxsElement,
734
+ target: JaxsElement,
735
+ data: EventInstructionData,
736
+ ) => ChangeInstruction
737
+ export const updateEvent: (
738
+ source: JaxsElement,
739
+ target: JaxsElement,
740
+ data: UpdateEventInstructionData,
741
+ ) => ChangeInstruction
742
+ export const removeNode: (source: JaxsElement) => ChangeInstruction
743
+ export const insertNode: (
744
+ target: JaxsElement,
745
+ data: InsertNodeData,
746
+ ) => ChangeInstruction
747
+ export const changeValue: (
748
+ source: JaxsInput,
749
+ target: JaxsInput,
750
+ data: AttributeInstructionData,
751
+ ) => ChangeInstruction
752
+ export const instructionsSorter: (
753
+ left: ChangeInstruction,
754
+ right: ChangeInstruction,
755
+ ) => 0 | 1 | -1
756
+ }
757
+ declare module 'rendering/update/instructions/id-map' {
758
+ import type { JaxsNode, JaxsNodes, JsxChangeId } from 'types'
759
+ export class IdMap {
760
+ map: Record<string, JsxChangeId[]>
761
+ constructor()
762
+ populate(list: JaxsNodes): void
763
+ pullMatch(element: JaxsNode): JsxChangeId
764
+ clear(element: JaxsNode): void
765
+ check(element: JaxsNode): boolean
766
+ remaining(): JsxChangeId[]
767
+ }
768
+ export const createIdMap: (list: JaxsNodes) => IdMap
769
+ }
770
+ declare module 'rendering/update/instructions/nodes/element/attributes' {
771
+ import type { JaxsElement, ChangeInstructions } from 'types'
772
+ export const compileForAttributes: (
773
+ source: JaxsElement,
774
+ target: JaxsElement,
775
+ isSvg?: boolean,
776
+ ) => ChangeInstructions
777
+ }
778
+ declare module 'rendering/update/instructions/nodes/element/events' {
779
+ import type { JaxsElement, ChangeInstructions } from 'types'
780
+ export const compileForEvents: (
781
+ source: JaxsElement,
782
+ target: JaxsElement,
783
+ ) => ChangeInstructions
784
+ }
785
+ declare module 'rendering/update/instructions/nodes/input' {
786
+ import { ChangeInstructions, JaxsElement } from 'types'
787
+ export const compileForInputValue: (
788
+ sourceElement: JaxsElement,
789
+ targetElement: JaxsElement,
790
+ ) => ChangeInstructions
791
+ }
792
+ declare module 'rendering/update/instructions/nodes/element' {
793
+ import type { JaxsElement } from 'types'
794
+ export const compileForElement: (
795
+ source: JaxsElement,
796
+ target: JaxsElement,
797
+ ) => import('types').ChangeInstruction[]
798
+ }
799
+ declare module 'rendering/update/instructions/nodes/svg' {
800
+ import { JaxsElement } from 'types'
801
+ export const compileForSvg: (
802
+ source: JaxsElement,
803
+ target: JaxsElement,
804
+ ) => import('types').ChangeInstructions
805
+ }
806
+ declare module 'rendering/update/instructions/nodes/text' {
807
+ import type { ChangeInstructions } from 'types'
808
+ export const compileForText: (
809
+ source: Text,
810
+ target: Text,
811
+ ) => ChangeInstructions
812
+ }
813
+ declare module 'rendering/update/instructions/node' {
814
+ import type { JaxsNode, ChangeInstructions, CompileChildren } from 'types'
815
+ export const compileForNode: (
816
+ source: JaxsNode,
817
+ target: JaxsNode,
818
+ compileChildren: CompileChildren,
819
+ ) => ChangeInstructions
820
+ }
821
+ declare module 'rendering/update/instructions/collection' {
822
+ import type { JaxsElement, JaxsNodes } from 'types'
823
+ export const compileCollection: (
824
+ sourceList: JaxsNodes,
825
+ targetList: JaxsNodes,
826
+ parent: JaxsElement,
827
+ ) => import('types').ChangeInstruction[]
828
+ }
829
+ declare module 'rendering/update/perform-change' {
830
+ import type { ChangeInstruction, JaxsElement, JaxsNodes } from 'types'
831
+ export const performChange: (
832
+ source: JaxsNodes,
833
+ target: JaxsNodes,
834
+ parent: JaxsElement,
835
+ ) => ChangeInstruction[]
836
+ }
837
+ declare module 'rendering/templates/bound/modify-dom-cache' {
838
+ import { ChangeInstructions, JaxsNode, JaxsElement } from 'types'
839
+ export const modifyDomCache: (
840
+ instructions: ChangeInstructions,
841
+ dom: JaxsNode[],
842
+ parentElement: JaxsElement,
843
+ ) => JaxsNode[]
844
+ }
845
+ declare module 'rendering/templates/bound' {
846
+ import {
847
+ JaxsElement,
848
+ Props,
849
+ Template,
850
+ RenderKit,
851
+ ViewModel,
852
+ BindParams,
853
+ BindSubscriptionList,
854
+ JaxsNode,
855
+ } from 'types'
856
+ export class Bound<ATTRIBUTES, STATE_MAP> {
857
+ Template: Template<ATTRIBUTES>
858
+ viewModel: ViewModel<ATTRIBUTES, STATE_MAP>
859
+ attributes: Partial<Props<ATTRIBUTES>>
860
+ subscriptions: BindSubscriptionList
861
+ dom: JaxsNode[]
862
+ parentElement: JaxsElement | null
863
+ renderKit?: RenderKit
864
+ constructor({
865
+ Template,
866
+ subscriptions,
867
+ attributes,
868
+ viewModel,
869
+ }: {
870
+ Template: any
871
+ subscriptions: any
872
+ attributes: any
873
+ viewModel: any
874
+ })
875
+ render(renderKit: RenderKit): JaxsNode[]
876
+ generateDom(renderKit: RenderKit): JaxsNode[]
877
+ rerender(): void
878
+ subscribeForRerender(): void
879
+ eventName(storeName: string): string
880
+ }
881
+ export const bind: <ATTRIBUTES, STATE_MAP>({
882
+ Template,
883
+ viewModel,
884
+ subscriptions,
885
+ }: BindParams<ATTRIBUTES, STATE_MAP>) => (
886
+ attributes: Partial<Props<ATTRIBUTES>>,
887
+ ) => Bound<unknown, unknown>
888
+ }
889
+ declare module 'navigation/index' {
890
+ import * as events from 'navigation/events'
891
+ import { extractQueryParams } from 'navigation/extract-query-params'
892
+ import { findHref } from 'navigation/find-href'
893
+ import { navigate } from 'navigation/navigate'
894
+ import { onLinkClick } from 'navigation/on-link-click'
895
+ import { onLocationChange } from 'navigation/on-location-change'
896
+ import { createRouteState } from 'navigation/route-state'
897
+ import * as start from 'navigation/start'
898
+ export {
899
+ events,
900
+ extractQueryParams,
901
+ findHref,
902
+ navigate,
903
+ onLinkClick,
904
+ onLocationChange,
905
+ createRouteState,
906
+ start,
907
+ }
908
+ }
909
+ declare module 'app/routing' {
910
+ import { RenderedRoute, RouteMatcher } from 'types'
911
+ export const exactPathMatch: (exactPath: string) => RouteMatcher
912
+ export const catchAll: RouteMatcher
913
+ export const buildRouter: (
914
+ pages: RenderedRoute[],
915
+ ) => ({ route }: { route: any }) => import('types').StaticTemplate
916
+ }
917
+ declare module 'rendering/null' {
918
+ import { RenderKit, JaxsElement, JaxsNode } from 'types'
919
+ export const NullTemplate: () => {
920
+ render: (renderKit: RenderKit, parentElement?: JaxsElement) => JaxsNode[]
921
+ }
922
+ }
923
+ declare module 'app/routed-view' {
924
+ import { RenderedRoute, RouteState } from 'types'
925
+ export const routedView: (routes: RenderedRoute[]) => (
926
+ attributes: Partial<
927
+ import('types').Props<{
928
+ route: RouteState
929
+ }>
930
+ >,
931
+ ) => import('rendering/templates/bound').Bound<unknown, unknown>
932
+ }
933
+ declare module 'jaxs' {
934
+ export { jsx } from 'rendering/jsx'
935
+ export { createApp } from 'app/builder'
936
+ export { bind } from 'rendering/templates/bound'
937
+ export * as JaxsTypes from 'types'
938
+ export * as navigation from 'navigation/index'
939
+ export * as appBuilding from 'app/index'
940
+ export * as messageBus from 'bus/index'
941
+ export * as state from 'state/index'
942
+ export * as routing from 'app/routing'
943
+ export { routedView } from 'app/routed-view'
671
944
  }