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