jaxs 0.8.0 → 0.9.1

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,7 +1,12 @@
1
+ import { PublishFromDom } from '.'
2
+ import { State as State_2 } from '.'
3
+ import { Store as Store_2 } from '.'
4
+ import { Subscribe as Subscribe_2 } from '.'
5
+
1
6
  export declare class App {
2
7
  window: Window
3
8
  document: Document
4
- publish: PublishFunction
9
+ publish: Publish<any>
5
10
  subscribe: Subscribe
6
11
  bus: JaxsBus
7
12
  state: State
@@ -29,7 +34,7 @@ export declare class App {
29
34
  }
30
35
 
31
36
  declare type AppAdditionListenerOptions = {
32
- state: State
37
+ state: State_2
33
38
  document: Document
34
39
  window: Window
35
40
  }
@@ -38,16 +43,22 @@ export declare namespace appBuilding {
38
43
  export { App }
39
44
  }
40
45
 
46
+ export declare const ArrayModifiers: {
47
+ remove: <T>(originalCollection: T[], itemToRemove: T) => T[]
48
+ removeBy: <T>(
49
+ originalCollection: T[],
50
+ matcherFunction: (value: T) => boolean,
51
+ ) => T[]
52
+ insertAt: <T>(originalCollection: T[], index: number, item: T) => T[]
53
+ appendIfUnique: <T>(originalCollection: T[], item: T) => T[]
54
+ }
55
+
41
56
  declare type AttributeInstructionData = {
42
57
  name: string
43
58
  value: string
44
59
  isSvg?: boolean
45
60
  }
46
61
 
47
- declare type AttributesWithChildren<T> = Props<T> & {
48
- children?: JsxCollection
49
- }
50
-
51
62
  export declare const bind: <ATTRIBUTES, STATE_MAP>({
52
63
  Template,
53
64
  viewModel,
@@ -64,6 +75,15 @@ declare type BindParams<T, U> = {
64
75
 
65
76
  declare type BindSubscriptionList = string[]
66
77
 
78
+ export declare const BooleanStore: {
79
+ toggle: (store: Store<boolean>) => void
80
+ setTrue: (store: Store<boolean>) => void
81
+ setFalse: (store: Store<boolean>) => void
82
+ reset: (store: Store<boolean>) => void
83
+ isTrue: (store: Store<boolean>) => boolean
84
+ isFalse: (store: Store<boolean>) => boolean
85
+ }
86
+
67
87
  declare class Bound<ATTRIBUTES, STATE_MAP> {
68
88
  Template: Template<ATTRIBUTES>
69
89
  viewModel: ViewModel<ATTRIBUTES, STATE_MAP>
@@ -126,7 +146,7 @@ declare enum ChangeInstructionTypes {
126
146
  declare class Children implements Renderable {
127
147
  collection: Renderable[]
128
148
  parentElement?: JaxsElement
129
- constructor(jsxChildren: JsxCollection)
149
+ constructor(jsxChildren: RenderableCollection)
130
150
  render(renderKit: RenderKit, parentElement?: JaxsElement): JaxsNode[]
131
151
  generateDom(renderKit: RenderKit): JaxsNode[]
132
152
  attachToParent(dom: JaxsNodes): void
@@ -158,26 +178,25 @@ declare const createBus: () => {
158
178
 
159
179
  declare const createRouteState: (state: State) => void
160
180
 
161
- declare const createState: (publisher: StatePublisher) => State
181
+ declare const createState: (publisher: Publish<any>) => State
162
182
 
163
183
  declare type CustomPeriodicOptions = {
164
184
  timer: PeriodicTimerFunction
165
185
  }
166
186
 
167
- declare type CustomPeriodicPublisherOptions = RequiredPeriodicPublisherOptions &
168
- CustomPeriodicOptions
169
-
170
- declare type DefaultBusListenerOptions = {
171
- publish: PublishFunction
172
- eventName: string
173
- }
187
+ declare type CustomPeriodicPublisherOptions<T> =
188
+ RequiredPeriodicPublisherOptions<T> & CustomPeriodicOptions
174
189
 
175
190
  declare type DiffPair = {
176
191
  source: JaxsNode
177
192
  target: JaxsNode
178
193
  }
179
194
 
180
- declare type DomPublish = (eventName: string, domEvent: Event) => void
195
+ export declare const Equality: {
196
+ objects: (oldValue: Object_2, newValue: Object_2) => any
197
+ arrays: (oldValue: any[], newValue: any[]) => any
198
+ equal: (oldValue: any, newValue: any) => any
199
+ }
181
200
 
182
201
  declare type EventInstructionData = {
183
202
  name: string
@@ -243,8 +262,8 @@ declare type GeneralPeriodicOptions = {
243
262
  offset?: number
244
263
  }
245
264
 
246
- declare type GeneralPeriodicPublisherOptions =
247
- RequiredPeriodicPublisherOptions & GeneralPeriodicOptions
265
+ declare type GeneralPeriodicPublisherOptions<T> =
266
+ RequiredPeriodicPublisherOptions<T> & GeneralPeriodicOptions
248
267
 
249
268
  declare type InsertNodeData = {
250
269
  parent: JaxsElement
@@ -261,6 +280,14 @@ declare type InstructionData =
261
280
 
262
281
  declare type InstructionsUpdater = (instruction: ChangeInstruction) => void
263
282
 
283
+ export declare const Is: {
284
+ boolean: (value: any) => value is boolean
285
+ number: (value: any) => value is number
286
+ string: (value: any) => value is string
287
+ array: (value: any) => value is any[]
288
+ object: (value: any) => boolean
289
+ }
290
+
264
291
  declare class JaxsBus {
265
292
  options?: AppAdditionListenerOptions
266
293
  exactSubscriptions: ExactSubscriptions
@@ -300,11 +327,11 @@ export declare namespace JaxsTypes {
300
327
  App,
301
328
  State,
302
329
  Store,
303
- StoreUpdaterBase,
304
330
  StoreUpdaterBoolean,
305
331
  StoreUpdaterList,
306
332
  StoreUpdaterObject,
307
333
  StoreUpdater,
334
+ CreateAppBuilderArguments,
308
335
  TextValue,
309
336
  JsxIded,
310
337
  JsxChangeId,
@@ -322,14 +349,16 @@ export declare namespace JaxsTypes {
322
349
  TagAttributes,
323
350
  TagEventAttributes,
324
351
  TagAttributesAndEvents,
325
- DomPublish,
326
- Subscribe,
327
352
  RenderKit,
328
353
  Renderable,
329
354
  StaticTemplate,
330
355
  TypedTemplate,
331
356
  Template,
332
- JsxCollection,
357
+ RenderableCollection,
358
+ StoreMap,
359
+ ViewModel,
360
+ BindSubscriptionList,
361
+ BindParams,
333
362
  ChangeInstructionTypes,
334
363
  RemoveInstructionData,
335
364
  AttributeInstructionData,
@@ -340,25 +369,18 @@ export declare namespace JaxsTypes {
340
369
  ChangeInstruction,
341
370
  ChangeInstructions,
342
371
  InstructionsUpdater,
343
- StoreMap,
344
- ViewModel,
345
- BindSubscriptionList,
346
- BindParams,
372
+ DiffPair,
373
+ CompileChildren,
374
+ PublishFromDom_2 as PublishFromDom,
375
+ Subscribe,
347
376
  AppAdditionListenerOptions,
348
- DefaultBusListenerOptions,
349
377
  ListenerKit,
350
- PublishFunction,
378
+ Publish,
351
379
  BusListener,
352
380
  BusEventMatcher,
353
381
  ExactSubscriptionData,
354
382
  FuzzySubscriptionData,
355
383
  Unsubscribe,
356
- CreateAppBuilderArguments,
357
- RouteState,
358
- AttributesWithChildren,
359
- DiffPair,
360
- CompileChildren,
361
- StatePublisher,
362
384
  StateTransactionUpdater,
363
385
  StoresCollection,
364
386
  StoreInitializationOptions,
@@ -366,8 +388,6 @@ export declare namespace JaxsTypes {
366
388
  UpdaterValue,
367
389
  StoreUpdaterOrValue,
368
390
  StoreListSorterFunction,
369
- RouteMatcher,
370
- RenderedRoute,
371
391
  PeriodicPublisher,
372
392
  RequiredPeriodicPublisherOptions,
373
393
  GeneralPeriodicOptions,
@@ -377,6 +397,9 @@ export declare namespace JaxsTypes {
377
397
  PublishPeriodicallyOptions,
378
398
  PeriodicTimerFunctionOptions,
379
399
  PeriodicTimerFunction,
400
+ RouteState,
401
+ RouteMatcher,
402
+ RenderedRoute,
380
403
  }
381
404
  }
382
405
 
@@ -384,9 +407,12 @@ export declare const jsx: {
384
407
  <T>(
385
408
  type: string | Template<T>,
386
409
  attributes: Props<T>,
387
- ...children: JsxCollection
410
+ ...children: RenderableCollection
388
411
  ): Renderable
389
- fragment<T>(attributes: Props<T>, maybeChildren: JsxCollection): Children
412
+ fragment<T>(
413
+ attributes: Props<T>,
414
+ maybeChildren: RenderableCollection,
415
+ ): Children
390
416
  }
391
417
 
392
418
  declare type JsxChangeId = {
@@ -394,8 +420,6 @@ declare type JsxChangeId = {
394
420
  index: number
395
421
  }
396
422
 
397
- declare type JsxCollection = (Renderable | TextValue)[]
398
-
399
423
  declare interface JsxEventMapped {
400
424
  eventMaps: EventMaps
401
425
  }
@@ -407,14 +431,31 @@ declare interface JsxIded {
407
431
  declare const linkNavigationEvent = 'go-to-href'
408
432
 
409
433
  declare type ListenerKit<T> = {
410
- state: State
434
+ state: State_2
411
435
  document: Document
412
436
  window: Window
413
- publish: PublishFunction
437
+ publish: Publish<any>
414
438
  eventName: string
415
439
  payload: T
416
440
  }
417
441
 
442
+ export declare const ListStore: {
443
+ push: <T>(store: Store<T[]>, element: T) => void
444
+ pop: <T>(store: Store<T[]>) => T
445
+ unshift: <T>(store: Store<T[]>, element: T) => void
446
+ shift: <T>(store: Store<T[]>) => T
447
+ sortBy: <T>(store: Store<T[]>, sorter: StoreListSorterFunction<T>) => void
448
+ insertAt: <T>(store: Store<T[]>, index: number, item: T) => void
449
+ remove: <T>(store: Store<T[]>, value: T) => void
450
+ removeBy: <T>(
451
+ store: Store<T[]>,
452
+ matcherFunction: (value: T) => boolean,
453
+ ) => void
454
+ reset: <T>(store: Store<T[]>) => void
455
+ includes: <T>(store: Store<T[]>, value: T) => boolean
456
+ appendIfUnique: <T>(store: Store<T[]>, item: T) => void
457
+ }
458
+
418
459
  declare const locationChangeEvent = 'navigation:location-change'
419
460
 
420
461
  export declare namespace messageBus {
@@ -452,14 +493,16 @@ declare type NullInstructionData = Record<string, never>
452
493
 
453
494
  declare type NullValues = null | undefined
454
495
 
496
+ declare type Object_2 = Record<string, any>
497
+
455
498
  declare const onLinkClick: (listenerKit: ListenerKit<MouseEvent>) => void
456
499
 
457
500
  declare const onLocationChange: (listenerKit: ListenerKit<null>) => void
458
501
 
459
- declare interface PeriodicPublisher {
502
+ declare interface PeriodicPublisher<T> {
460
503
  event: string
461
- publish: PublishFunction
462
- payload?: any
504
+ publish: Publish<T>
505
+ payload?: T
463
506
  start: () => void
464
507
  stop: () => void
465
508
  }
@@ -475,8 +518,8 @@ declare type PeriodicTimerFunctionOptions = {
475
518
  }
476
519
 
477
520
  export declare type Props<T> = Partial<{
478
- __source: ReactSourceObject
479
- children: JsxCollection
521
+ __source?: ReactSourceObject
522
+ children: RenderableCollection
480
523
  }> &
481
524
  T
482
525
 
@@ -485,19 +528,21 @@ declare type PropValue =
485
528
  | NullValues
486
529
  | boolean
487
530
  | ReactSourceObject
488
- | JsxCollection
531
+ | RenderableCollection
532
+
533
+ export declare type Publish<T> = (event: string, payload: T) => void
489
534
 
490
- export declare type PublishFunction = (event: string, payload: any) => void
535
+ declare type PublishFromDom_2 = Publish<Event>
491
536
 
492
537
  declare const publishLocation: (app: App) => void
493
538
 
494
- declare const publishPeriodically: (
495
- options: PublishPeriodicallyOptions,
539
+ declare const publishPeriodically: <T>(
540
+ options: PublishPeriodicallyOptions<T>,
496
541
  ) => () => void
497
542
 
498
- declare type PublishPeriodicallyOptions =
499
- | GeneralPeriodicPublisherOptions
500
- | CustomPeriodicPublisherOptions
543
+ declare type PublishPeriodicallyOptions<T> =
544
+ | GeneralPeriodicPublisherOptions<T>
545
+ | CustomPeriodicPublisherOptions<T>
501
546
 
502
547
  declare type ReactSourceObject = {
503
548
  fileName: string
@@ -505,6 +550,18 @@ declare type ReactSourceObject = {
505
550
  columnNumber: string
506
551
  }
507
552
 
553
+ export declare const RecordStore: {
554
+ reset: <T>(store: Store<T>) => void
555
+ resetAttribute: <T>(store: Store<T>, name: keyof T) => void
556
+ updateAttribute: <T>(
557
+ store: Store<T>,
558
+ name: keyof T,
559
+ value: T[keyof T],
560
+ ) => void
561
+ updateAttributes: <T>(store: Store<T>, values: Partial<T>) => void
562
+ attributeTruthy: <T>(store: Store<T>, name: keyof T) => boolean
563
+ }
564
+
508
565
  declare type RemoveInstructionData = {
509
566
  name: string
510
567
  isSvg?: boolean
@@ -514,6 +571,8 @@ export declare interface Renderable {
514
571
  render: (renderKit: RenderKit, parentElement?: JaxsElement) => JaxsNode[]
515
572
  }
516
573
 
574
+ declare type RenderableCollection = Renderable[]
575
+
517
576
  export declare type RenderedRoute = {
518
577
  Partial: StaticTemplate
519
578
  match: RouteMatcher
@@ -522,16 +581,16 @@ export declare type RenderedRoute = {
522
581
  declare type RenderKit = {
523
582
  document: Document
524
583
  window: Window
525
- publish: DomPublish
526
- subscribe: Subscribe
527
- state: State
584
+ publish: PublishFromDom
585
+ subscribe: Subscribe_2
586
+ state: State_2
528
587
  parent?: JaxsNode | null
529
588
  }
530
589
 
531
- declare type RequiredPeriodicPublisherOptions = {
590
+ declare type RequiredPeriodicPublisherOptions<T> = {
532
591
  event: string
533
- publish: PublishFunction
534
- payload?: any
592
+ publish: Publish<T>
593
+ payload?: T
535
594
  }
536
595
 
537
596
  declare class Root {
@@ -585,12 +644,12 @@ declare namespace start {
585
644
  declare const startNavigation: (app: App) => void
586
645
 
587
646
  export declare class State {
588
- publisher: StatePublisher
647
+ publisher: Publish<any>
589
648
  stores: StoresCollection
590
649
  eventNamePrefix: string
591
650
  notifications: Set<string>
592
651
  inTransaction: boolean
593
- constructor(publisher: StatePublisher)
652
+ constructor(publisher: Publish<any>)
594
653
  create<T>(name: string, initialState: T): Store<T>
595
654
  store<T>(name: string): Store<T>
596
655
  get<T>(name: string): T
@@ -604,11 +663,9 @@ export declare class State {
604
663
  }
605
664
 
606
665
  export declare namespace state {
607
- export { eventName, State, createState, Store, updaters }
666
+ export { eventName, State, createState, Store }
608
667
  }
609
668
 
610
- declare type StatePublisher = (event: string, payload: any) => void
611
-
612
669
  declare type StateTransactionUpdater = (collection: StoresCollection) => void
613
670
 
614
671
  export declare type StaticTemplate = () => Renderable
@@ -617,7 +674,7 @@ export declare class Store<T> {
617
674
  parent: State
618
675
  name: string
619
676
  updater: StoreUpdater<T>
620
- _value: T
677
+ private _value
621
678
  initialValue: T
622
679
  constructor(options: StoreInitializationOptions<T>)
623
680
  get ['value'](): T
@@ -632,7 +689,7 @@ declare type StoreDataUpdater<T> = (originalValue: T) => T
632
689
 
633
690
  declare type StoreInitializationOptions<T> = {
634
691
  name: string
635
- parent: State
692
+ parent: State_2
636
693
  value: T
637
694
  }
638
695
 
@@ -642,48 +699,57 @@ declare type StoreMap = {
642
699
  [key: string]: any
643
700
  }
644
701
 
645
- declare type StoresCollection = Record<string, Store<any>>
702
+ declare type StoresCollection = Record<string, Store_2<any>>
646
703
 
647
- export declare type StoreUpdater<T> =
648
- | StoreUpdaterBase<T>
704
+ declare type StoreUpdater<T> =
649
705
  | StoreUpdaterObject<T extends object ? T : never>
650
706
  | StoreUpdaterBoolean
651
707
  | StoreUpdaterList<T>
652
708
 
653
- export declare class StoreUpdaterBase<T> {
654
- store: Store<T>
655
- constructor(store: Store<T>)
656
- update(updater: StoreUpdaterOrValue<T>): void
709
+ declare class StoreUpdaterBoolean {
710
+ store: Store<boolean>
711
+ constructor(store: Store<boolean>)
712
+ private update
713
+ private get value()
657
714
  reset(): void
658
- get value(): T
659
- }
660
-
661
- export declare class StoreUpdaterBoolean extends StoreUpdaterBase<boolean> {
662
715
  toggle(): void
663
716
  setTrue(): void
664
717
  setFalse(): void
718
+ isTrue(): boolean
719
+ isFalse(): boolean
665
720
  }
666
721
 
667
- export declare class StoreUpdaterList<T> extends StoreUpdaterBase<T[]> {
722
+ declare class StoreUpdaterList<T> {
723
+ store: Store<T[]>
724
+ constructor(store: Store<T[]>)
725
+ private update
726
+ private get value()
727
+ reset(): void
668
728
  push(element: T): void
669
729
  pop(): T
670
730
  unshift(element: T): void
671
731
  shift(): T
672
- addSorter(name: string, sorter: StoreListSorterFunction<T>): void
673
732
  sortBy(sorter: StoreListSorterFunction<T>): void
674
733
  insertAt(index: number, item: T): void
675
734
  remove(value: T): void
676
735
  removeBy(matcherFunction: (value: T) => boolean): void
736
+ includes(value: T): boolean
737
+ appendIfUnique(item: T): void
677
738
  }
678
739
 
679
- export declare class StoreUpdaterObject<
680
- T extends object,
681
- > extends StoreUpdaterBase<T> {
740
+ declare class StoreUpdaterObject<T extends object> {
741
+ store: Store<T>
742
+ constructor(store: Store<T>)
743
+ private update
744
+ private get value()
745
+ reset(): void
682
746
  updateAttribute(name: keyof T, value: T[keyof T]): void
683
747
  updateDynamicAttribute(name: string, value: any): void
684
748
  isKey(key: string): boolean
685
749
  isValueType(key: keyof T, value: any): boolean
686
750
  resetAttribute(name: keyof T): void
751
+ updateAttributes(values: Partial<T>): void
752
+ attributeTruthy(name: keyof T): boolean
687
753
  }
688
754
 
689
755
  declare type StoreUpdaterOrValue<T> = UpdaterValue<T> | StoreDataUpdater<T>
@@ -697,7 +763,10 @@ declare const subscribeToHistoryChange: (app: App) => void
697
763
 
698
764
  declare const subscribeToNavigation: (app: App) => void
699
765
 
700
- declare type TagAttributes = SourceMap & Record<string, string>
766
+ declare type TagAttributes = SourceMap &
767
+ Record<string, string> & {
768
+ __source?: ReactSourceObject
769
+ }
701
770
 
702
771
  declare type TagAttributesAndEvents = {
703
772
  attributes: TagAttributes
@@ -720,12 +789,6 @@ declare type UpdateEventInstructionData = {
720
789
  targetValue: EventListener
721
790
  }
722
791
 
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
792
  declare type UpdaterValue<T> = boolean | T | T[]
730
793
 
731
794
  declare type ViewModel<ATTRIBUTES, STORE_MAP> = (