jaxs 0.7.2 → 0.7.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/jaxs.d.ts CHANGED
@@ -1,985 +1,422 @@
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> = (
100
+ payload: T,
101
+ listenerKit: ListenerKit,
102
+ ) => void
103
+
104
+ declare const catchAll: RouteMatcher
105
+
106
+ declare type ChangeInstruction = {
107
+ source: JaxsNode
108
+ target: JaxsNode
109
+ type: ChangeInstructionTypes
110
+ data: InstructionData
111
+ }
112
+
113
+ declare type ChangeInstructions = Array<ChangeInstruction>
114
+
115
+ declare enum ChangeInstructionTypes {
116
+ removeNode = 0,
117
+ insertNode = 1, // can be to move an existing element in the dom, or to add one
118
+ replaceNode = 2,
119
+ removeAttribute = 3,
120
+ addAttribute = 4,
121
+ updateAttribute = 5,
122
+ removeEvent = 6,
123
+ addEvent = 7,
124
+ updateEvent = 8,
125
+ changeValue = 9,
126
+ changeText = 10,
127
+ }
128
+
129
+ declare class Children implements Renderable {
130
+ collection: Renderable[]
131
+ parentElement?: JaxsElement
132
+ constructor(jsxChildren: JsxCollection)
133
+ render(renderKit: RenderKit, parentElement?: JaxsElement): JaxsNode[]
134
+ generateDom(renderKit: RenderKit): JaxsNode[]
135
+ attachToParent(dom: JaxsNodes): void
136
+ }
137
+
138
+ declare type CompileChildren = (
139
+ sourceList: JaxsNodes,
140
+ targetList: JaxsNodes,
141
+ parent: JaxsElement,
142
+ ) => ChangeInstructions
143
+
144
+ export declare const createApp: (
145
+ domEnvironment?: CreateAppBuilderArguments,
146
+ ) => App
147
+
148
+ declare type CreateAppBuilderArguments = {
149
+ window?: Window
150
+ document?: Document
151
+ }
152
+
153
+ declare const createBus: () => {
154
+ bus: JaxsBus
155
+ publish: (event: string, payload: any) => void
156
+ subscribe: (
157
+ matcher: BusEventMatcher,
158
+ listener: BusListener<any>,
159
+ ) => Unsubscribe
160
+ }
161
+
162
+ declare const createRouteState: (state: State) => void
163
+
164
+ declare const createState: (publisher: StatePublisher) => State
165
+
166
+ declare type CustomPeriodicOptions = {
167
+ timer: PeriodicTimerFunction
168
+ }
169
+
170
+ declare type CustomPeriodicPublisherOptions = RequiredPeriodicPublisherOptions &
171
+ CustomPeriodicOptions
172
+
173
+ declare type DefaultBusListenerOptions = {
174
+ publish: PublishFunction
175
+ eventName: string
176
+ }
177
+
178
+ declare type DiffPair = {
179
+ source: JaxsNode
180
+ target: JaxsNode
181
+ }
182
+
183
+ declare type DomPublish = (eventName: string, domEvent: Event) => void
184
+
185
+ declare type EventInstructionData = {
186
+ name: string
187
+ value: EventListener
188
+ }
189
+
190
+ declare type EventMap = {
191
+ domEvent: string
192
+ busEvent: string
193
+ listener: EventListener
194
+ }
195
+
196
+ declare type EventMaps = Record<string, EventMap>
197
+
198
+ declare const eventName = 'state'
199
+
200
+ declare namespace events {
231
201
  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
314
- 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
336
- }
337
- }
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'
202
+ linkNavigationEvent,
203
+ navigationEvent,
204
+ locationChangeEvent,
205
+ routeChangeEvent,
206
+ }
207
+ }
208
+
209
+ declare const exactPathMatch: (exactPath: string) => RouteMatcher
210
+
211
+ declare type ExactSubscriptionData<T> = {
212
+ listener: BusListener<T>
213
+ index: number
214
+ matcher: string
215
+ }
216
+
217
+ declare class ExactSubscriptions {
218
+ lookup: Record<string, ExactSubscriptionData<any>[]>
219
+ constructor()
220
+ add<T>(matcher: string, listener: BusListener<T>, index: number): Unsubscribe
221
+ remove<T>(subscription: ExactSubscriptionData<T>): void
222
+ matches(event: string): ExactSubscriptionData<any>[]
223
+ ensureArrayFor(matcher: string): void
224
+ }
225
+
226
+ declare const extractQueryParams: (queryString: string) => {}
227
+
228
+ declare const findHref: (node: HTMLElement) => string
229
+
230
+ declare type FuzzySubscriptionData<T> = {
231
+ listener: BusListener<T>
232
+ index: number
233
+ matcher: RegExp
234
+ }
235
+
236
+ declare class FuzzySubscriptions {
237
+ lookup: FuzzySubscriptionData<any>[]
238
+ constructor()
239
+ add<T>(matcher: RegExp, listener: BusListener<T>, index: number): Unsubscribe
240
+ remove<T>(subscription: FuzzySubscriptionData<T>): void
241
+ matches(event: string): FuzzySubscriptionData<any>[]
242
+ }
243
+
244
+ declare type GeneralPeriodicOptions = {
245
+ period: number
246
+ offset?: number
247
+ }
248
+
249
+ declare type GeneralPeriodicPublisherOptions =
250
+ RequiredPeriodicPublisherOptions & GeneralPeriodicOptions
251
+
252
+ declare type InsertNodeData = {
253
+ parent: JaxsElement
254
+ index: number
255
+ }
256
+
257
+ declare type InstructionData =
258
+ | RemoveInstructionData
259
+ | AttributeInstructionData
260
+ | EventInstructionData
261
+ | UpdateEventInstructionData
262
+ | InsertNodeData
263
+ | NullInstructionData
264
+
265
+ declare type InstructionsUpdater = (instruction: ChangeInstruction) => void
266
+
267
+ declare class JaxsBus {
268
+ options?: AppAdditionListenerOptions
269
+ exactSubscriptions: ExactSubscriptions
270
+ fuzzySubscriptions: FuzzySubscriptions
271
+ currentIndex: number
272
+ constructor()
273
+ subscribe<T>(matcher: BusEventMatcher, listener: BusListener<T>): Unsubscribe
274
+ publish<T>(event: string, payload: T): void
275
+ addListenerOptions(options: AppAdditionListenerOptions): void
276
+ listenerOptions(event: string): ListenerKit
277
+ }
278
+
279
+ declare type JaxsElement = Element & JsxIded & JsxEventMapped
280
+
281
+ declare type JaxsInput = HTMLInputElement & JsxIded & JsxEventMapped
282
+
283
+ declare type JaxsNode = JaxsElement | JaxsText | JaxsSvgElement
284
+
285
+ declare type JaxsNodes = JaxsNode[] | NodeListOf<JaxsNode>
286
+
287
+ declare type JaxsSvgElement = SVGElement & JsxIded
288
+
289
+ declare type JaxsText = Text & JsxIded
290
+
291
+ export declare namespace JaxsTypes {
346
292
  export {
293
+ App,
347
294
  State,
348
295
  Store,
349
296
  StoreUpdaterBase,
350
297
  StoreUpdaterBoolean,
351
298
  StoreUpdaterList,
352
299
  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 {
300
+ StoreUpdater,
301
+ TextValue,
302
+ JsxIded,
303
+ JsxChangeId,
304
+ EventMap,
305
+ EventMaps,
591
306
  JaxsElement,
307
+ JaxsText,
308
+ JaxsSvgElement,
309
+ JaxsNode,
310
+ JaxsNodes,
311
+ JaxsInput,
312
+ ReactSourceObject,
313
+ Props,
314
+ PropValue,
592
315
  TagAttributes,
593
316
  TagEventAttributes,
317
+ TagAttributesAndEvents,
594
318
  DomPublish,
319
+ Subscribe,
595
320
  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
321
  Renderable,
322
+ StaticTemplate,
323
+ TypedTemplate,
324
+ Template,
688
325
  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
- Renderable,
719
- RenderKit,
720
- TagAttributes,
721
- 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,
326
+ ChangeInstructionTypes,
786
327
  RemoveInstructionData,
787
328
  AttributeInstructionData,
788
329
  EventInstructionData,
789
330
  UpdateEventInstructionData,
790
331
  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,
332
+ InstructionData,
333
+ ChangeInstruction,
334
+ ChangeInstructions,
335
+ InstructionsUpdater,
336
+ StoreMap,
936
337
  ViewModel,
937
- BindParams,
938
338
  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
339
+ BindParams,
340
+ AppAdditionListenerOptions,
341
+ DefaultBusListenerOptions,
342
+ ListenerKit,
343
+ PublishFunction,
344
+ BusListener,
345
+ BusEventMatcher,
346
+ ExactSubscriptionData,
347
+ FuzzySubscriptionData,
348
+ Unsubscribe,
349
+ CreateAppBuilderArguments,
350
+ RouteState,
351
+ AttributesWithChildren,
352
+ DiffPair,
353
+ CompileChildren,
354
+ StatePublisher,
355
+ StateTransactionUpdater,
356
+ StoresCollection,
357
+ StoreInitializationOptions,
358
+ StoreDataUpdater,
359
+ UpdaterValue,
360
+ StoreUpdaterOrValue,
361
+ StoreListSorterFunction,
362
+ RouteMatcher,
363
+ RenderedRoute,
364
+ PeriodicPublisher,
365
+ RequiredPeriodicPublisherOptions,
366
+ GeneralPeriodicOptions,
367
+ CustomPeriodicOptions,
368
+ GeneralPeriodicPublisherOptions,
369
+ CustomPeriodicPublisherOptions,
370
+ PublishPeriodicallyOptions,
371
+ PeriodicTimerFunctionOptions,
372
+ PeriodicTimerFunction,
965
373
  }
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
374
  }
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'
375
+
376
+ export declare const jsx: {
377
+ <T>(
378
+ type: string | Template<T>,
379
+ attributes: Props<T>,
380
+ ...children: JsxCollection
381
+ ): Renderable
382
+ fragment<T>(attributes: Props<T>, maybeChildren: JsxCollection): Children
383
+ }
384
+
385
+ declare type JsxChangeId = {
386
+ element: JaxsNode
387
+ index: number
388
+ }
389
+
390
+ declare type JsxCollection = (Renderable | TextValue)[]
391
+
392
+ declare interface JsxEventMapped {
393
+ eventMaps: EventMaps
394
+ }
395
+
396
+ declare interface JsxIded {
397
+ __jsx?: string
398
+ }
399
+
400
+ declare const linkNavigationEvent = 'go-to-href'
401
+
402
+ declare type ListenerKit = AppAdditionListenerOptions &
403
+ DefaultBusListenerOptions
404
+
405
+ declare const locationChangeEvent = 'navigation:location-change'
406
+
407
+ export declare namespace messageBus {
408
+ export {
409
+ createBus,
410
+ JaxsBus,
411
+ ExactSubscriptions,
412
+ FuzzySubscriptions,
413
+ publishPeriodically,
414
+ }
415
+ }
416
+
417
+ declare const navigate: (path: string, { publish, window }: ListenerKit) => void
418
+
419
+ export declare namespace navigation {
983
420
  export {
984
421
  events,
985
422
  extractQueryParams,
@@ -991,39 +428,291 @@ declare module 'navigation/index' {
991
428
  start,
992
429
  }
993
430
  }
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
- }
431
+
432
+ declare const navigationEvent = 'go-to'
433
+
434
+ declare type NullInstructionData = Record<string, never>
435
+
436
+ declare type NullValues = null | undefined
437
+
438
+ declare const onLinkClick: (domEvent: MouseEvent, options: ListenerKit) => void
439
+
440
+ declare const onLocationChange: (_: null, listenerOptions: ListenerKit) => void
441
+
442
+ declare interface PeriodicPublisher {
443
+ event: string
444
+ publish: PublishFunction
445
+ payload?: any
446
+ start: () => void
447
+ stop: () => void
448
+ }
449
+
450
+ declare type PeriodicTimerFunction = (
451
+ options: PeriodicTimerFunctionOptions,
452
+ ) => number
453
+
454
+ declare type PeriodicTimerFunctionOptions = {
455
+ timeDiff: number
456
+ callCount: number
457
+ stop: () => void
458
+ }
459
+
460
+ export declare type Props<T> = Partial<{
461
+ __source: ReactSourceObject
462
+ children: JsxCollection
463
+ }> &
464
+ T
465
+
466
+ declare type PropValue =
467
+ | TextValue
468
+ | NullValues
469
+ | boolean
470
+ | ReactSourceObject
471
+ | JsxCollection
472
+
473
+ export declare type PublishFunction = (event: string, payload: any) => void
474
+
475
+ declare const publishLocation: (app: App) => void
476
+
477
+ declare const publishPeriodically: (
478
+ options: PublishPeriodicallyOptions,
479
+ ) => () => void
480
+
481
+ declare type PublishPeriodicallyOptions =
482
+ | GeneralPeriodicPublisherOptions
483
+ | CustomPeriodicPublisherOptions
484
+
485
+ declare type ReactSourceObject = {
486
+ fileName: string
487
+ lineNumber: string
488
+ columnNumber: string
489
+ }
490
+
491
+ declare type RemoveInstructionData = {
492
+ name: string
493
+ isSvg?: boolean
494
+ }
495
+
496
+ export declare interface Renderable {
497
+ render: (renderKit: RenderKit, parentElement?: JaxsElement) => JaxsNode[]
498
+ }
499
+
500
+ export declare type RenderedRoute = {
501
+ Partial: StaticTemplate
502
+ match: RouteMatcher
503
+ }
504
+
505
+ declare type RenderKit = {
506
+ document: Document
507
+ window: Window
508
+ publish: DomPublish
509
+ subscribe: Subscribe
510
+ state: State
511
+ parent?: JaxsNode | null
512
+ }
513
+
514
+ declare type RequiredPeriodicPublisherOptions = {
515
+ event: string
516
+ publish: PublishFunction
517
+ payload?: any
518
+ }
519
+
520
+ declare class Root {
521
+ template: Renderable
522
+ selector: string
523
+ renderKit: RenderKit
524
+ dom: JaxsNodes
525
+ parentElement?: JaxsElement | null
526
+ constructor(template: Renderable, selector: string, renderKit: RenderKit)
527
+ renderAndAttach(renderKit: RenderKit): void
528
+ render(renderKit: RenderKit): JaxsNode[]
529
+ attach(): void
530
+ getParentElement(): Element
531
+ }
532
+
533
+ declare const routeChangeEvent = 'navigation:route-change'
534
+
535
+ export declare const routedView: (routes: RenderedRoute[]) => (
536
+ attributes: Partial<
537
+ Props<{
538
+ route: RouteState
539
+ }>
540
+ >,
541
+ ) => Bound<unknown, unknown>
542
+
543
+ export declare type RouteMatcher = (routeState: RouteState) => boolean
544
+
545
+ export declare type RouteState = {
546
+ host: string
547
+ path: string
548
+ query: Record<string, string>
549
+ }
550
+
551
+ export declare namespace routing {
552
+ export { exactPathMatch, catchAll, buildRouter }
553
+ }
554
+
555
+ declare interface SourceMap {
556
+ __source?: ReactSourceObject
557
+ }
558
+
559
+ declare namespace start {
560
+ export {
561
+ subscribeToNavigation,
562
+ subscribeToHistoryChange,
563
+ publishLocation,
564
+ startNavigation,
565
+ }
566
+ }
567
+
568
+ declare const startNavigation: (app: App) => void
569
+
570
+ export declare class State {
571
+ publisher: StatePublisher
572
+ stores: StoresCollection
573
+ eventNamePrefix: string
574
+ notifications: Set<string>
575
+ inTransaction: boolean
576
+ constructor(publisher: StatePublisher)
577
+ create<T>(name: string, initialState: T): Store<T>
578
+ store<T>(name: string): Store<T>
579
+ get<T>(name: string): T
580
+ getAll(names: string[]): {}
581
+ notify(name: string): void
582
+ update(name: string, newValue: any): void
583
+ transaction(updater: StateTransactionUpdater): void
584
+ publishAll(): void
585
+ publish(name: string): void
586
+ event(name: string): string
587
+ }
588
+
589
+ export declare namespace state {
590
+ export { eventName, State, createState, Store, updaters }
591
+ }
592
+
593
+ declare type StatePublisher = (event: string, payload: any) => void
594
+
595
+ declare type StateTransactionUpdater = (collection: StoresCollection) => void
596
+
597
+ export declare type StaticTemplate = () => Renderable
598
+
599
+ export declare class Store<T> {
600
+ parent: State
601
+ name: string
602
+ updater: StoreUpdater<T>
603
+ _value: T
604
+ initialValue: T
605
+ constructor(options: StoreInitializationOptions<T>)
606
+ get ['value'](): T
607
+ set ['value'](value: T)
608
+ reset(): void
609
+ update(updater: StoreUpdaterOrValue<T>): void
610
+ private updateValue
611
+ private getUpdatedValue
612
+ }
613
+
614
+ declare type StoreDataUpdater<T> = (originalValue: T) => T
615
+
616
+ declare type StoreInitializationOptions<T> = {
617
+ name: string
618
+ parent: State
619
+ value: T
620
+ }
621
+
622
+ declare type StoreListSorterFunction<T> = (left: T, right: T) => number
623
+
624
+ declare type StoreMap = {
625
+ [key: string]: any
626
+ }
627
+
628
+ declare type StoresCollection = Record<string, Store<any>>
629
+
630
+ export declare type StoreUpdater<T> =
631
+ | StoreUpdaterBase<T>
632
+ | StoreUpdaterObject<T extends object ? T : never>
633
+ | StoreUpdaterBoolean
634
+ | StoreUpdaterList<T>
635
+
636
+ export declare class StoreUpdaterBase<T> {
637
+ store: Store<T>
638
+ constructor(store: Store<T>)
639
+ update(updater: StoreUpdaterOrValue<T>): void
640
+ reset(): void
641
+ get value(): T
642
+ }
643
+
644
+ export declare class StoreUpdaterBoolean extends StoreUpdaterBase<boolean> {
645
+ toggle(): void
646
+ setTrue(): void
647
+ setFalse(): void
648
+ }
649
+
650
+ export declare class StoreUpdaterList<T> extends StoreUpdaterBase<T[]> {
651
+ push(element: T): void
652
+ pop(): T
653
+ unshift(element: T): void
654
+ shift(): T
655
+ addSorter(name: string, sorter: StoreListSorterFunction<T>): void
656
+ sortBy(sorter: StoreListSorterFunction<T>): void
657
+ insertAt(index: number, item: T): void
658
+ remove(value: T): void
659
+ removeBy(matcherFunction: (value: T) => boolean): void
660
+ }
661
+
662
+ export declare class StoreUpdaterObject<
663
+ T extends object,
664
+ > extends StoreUpdaterBase<T> {
665
+ updateAttribute(name: keyof T, value: T[keyof T]): void
666
+ updateDynamicAttribute(name: string, value: any): void
667
+ isKey(key: string): boolean
668
+ isValueType(key: keyof T, value: any): boolean
669
+ resetAttribute(name: keyof T): void
670
+ }
671
+
672
+ declare type StoreUpdaterOrValue<T> = UpdaterValue<T> | StoreDataUpdater<T>
673
+
674
+ export declare type Subscribe = (
675
+ matcher: BusEventMatcher,
676
+ listener: BusListener<any>,
677
+ ) => void
678
+
679
+ declare const subscribeToHistoryChange: (app: App) => void
680
+
681
+ declare const subscribeToNavigation: (app: App) => void
682
+
683
+ declare type TagAttributes = SourceMap & Record<string, string>
684
+
685
+ declare type TagAttributesAndEvents = {
686
+ attributes: TagAttributes
687
+ events: TagEventAttributes
688
+ }
689
+
690
+ declare type TagEventAttributes = Record<string, string>
691
+
692
+ export declare type Template<T> = StaticTemplate | TypedTemplate<T>
693
+
694
+ declare type TextValue = string | number
695
+
696
+ export declare type TypedTemplate<T> = (props: Props<T>) => Renderable
697
+
698
+ declare type Unsubscribe = () => void
699
+
700
+ declare type UpdateEventInstructionData = {
701
+ name: string
702
+ sourceValue: EventListener
703
+ targetValue: EventListener
704
+ }
705
+
706
+ declare const updaters: {
707
+ object: <T extends Object>(store: Store<T>) => StoreUpdaterObject<T>
708
+ list: <T>(store: Store<T[]>) => StoreUpdaterList<T>
709
+ boolean: (store: Store<boolean>) => StoreUpdaterBoolean
710
+ }
711
+
712
+ declare type UpdaterValue<T> = boolean | T | T[]
713
+
714
+ declare type ViewModel<ATTRIBUTES, STORE_MAP> = (
715
+ storeMap: STORE_MAP,
716
+ ) => Partial<ATTRIBUTES>
717
+
718
+ export {}