jaxs 0.4.4 → 0.6.0

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