jaxs 0.8.0 → 0.9.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,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
  }
@@ -44,10 +49,6 @@ declare type AttributeInstructionData = {
44
49
  isSvg?: boolean
45
50
  }
46
51
 
47
- declare type AttributesWithChildren<T> = Props<T> & {
48
- children?: JsxCollection
49
- }
50
-
51
52
  export declare const bind: <ATTRIBUTES, STATE_MAP>({
52
53
  Template,
53
54
  viewModel,
@@ -126,7 +127,7 @@ declare enum ChangeInstructionTypes {
126
127
  declare class Children implements Renderable {
127
128
  collection: Renderable[]
128
129
  parentElement?: JaxsElement
129
- constructor(jsxChildren: JsxCollection)
130
+ constructor(jsxChildren: RenderableCollection)
130
131
  render(renderKit: RenderKit, parentElement?: JaxsElement): JaxsNode[]
131
132
  generateDom(renderKit: RenderKit): JaxsNode[]
132
133
  attachToParent(dom: JaxsNodes): void
@@ -158,26 +159,25 @@ declare const createBus: () => {
158
159
 
159
160
  declare const createRouteState: (state: State) => void
160
161
 
161
- declare const createState: (publisher: StatePublisher) => State
162
+ declare const createState: (publisher: Publish<any>) => State
162
163
 
163
164
  declare type CustomPeriodicOptions = {
164
165
  timer: PeriodicTimerFunction
165
166
  }
166
167
 
167
- declare type CustomPeriodicPublisherOptions = RequiredPeriodicPublisherOptions &
168
- CustomPeriodicOptions
169
-
170
- declare type DefaultBusListenerOptions = {
171
- publish: PublishFunction
172
- eventName: string
173
- }
168
+ declare type CustomPeriodicPublisherOptions<T> =
169
+ RequiredPeriodicPublisherOptions<T> & CustomPeriodicOptions
174
170
 
175
171
  declare type DiffPair = {
176
172
  source: JaxsNode
177
173
  target: JaxsNode
178
174
  }
179
175
 
180
- declare type DomPublish = (eventName: string, domEvent: Event) => void
176
+ export declare const Equality: {
177
+ objects: (oldValue: Object_2, newValue: Object_2) => any
178
+ arrays: (oldValue: any[], newValue: any[]) => any
179
+ equal: (oldValue: any, newValue: any) => any
180
+ }
181
181
 
182
182
  declare type EventInstructionData = {
183
183
  name: string
@@ -243,8 +243,8 @@ declare type GeneralPeriodicOptions = {
243
243
  offset?: number
244
244
  }
245
245
 
246
- declare type GeneralPeriodicPublisherOptions =
247
- RequiredPeriodicPublisherOptions & GeneralPeriodicOptions
246
+ declare type GeneralPeriodicPublisherOptions<T> =
247
+ RequiredPeriodicPublisherOptions<T> & GeneralPeriodicOptions
248
248
 
249
249
  declare type InsertNodeData = {
250
250
  parent: JaxsElement
@@ -261,6 +261,14 @@ declare type InstructionData =
261
261
 
262
262
  declare type InstructionsUpdater = (instruction: ChangeInstruction) => void
263
263
 
264
+ export declare const Is: {
265
+ boolean: (value: any) => value is boolean
266
+ number: (value: any) => value is number
267
+ string: (value: any) => value is string
268
+ array: (value: any) => value is any[]
269
+ object: (value: any) => boolean
270
+ }
271
+
264
272
  declare class JaxsBus {
265
273
  options?: AppAdditionListenerOptions
266
274
  exactSubscriptions: ExactSubscriptions
@@ -300,11 +308,11 @@ export declare namespace JaxsTypes {
300
308
  App,
301
309
  State,
302
310
  Store,
303
- StoreUpdaterBase,
304
311
  StoreUpdaterBoolean,
305
312
  StoreUpdaterList,
306
313
  StoreUpdaterObject,
307
314
  StoreUpdater,
315
+ CreateAppBuilderArguments,
308
316
  TextValue,
309
317
  JsxIded,
310
318
  JsxChangeId,
@@ -322,14 +330,16 @@ export declare namespace JaxsTypes {
322
330
  TagAttributes,
323
331
  TagEventAttributes,
324
332
  TagAttributesAndEvents,
325
- DomPublish,
326
- Subscribe,
327
333
  RenderKit,
328
334
  Renderable,
329
335
  StaticTemplate,
330
336
  TypedTemplate,
331
337
  Template,
332
- JsxCollection,
338
+ RenderableCollection,
339
+ StoreMap,
340
+ ViewModel,
341
+ BindSubscriptionList,
342
+ BindParams,
333
343
  ChangeInstructionTypes,
334
344
  RemoveInstructionData,
335
345
  AttributeInstructionData,
@@ -340,25 +350,18 @@ export declare namespace JaxsTypes {
340
350
  ChangeInstruction,
341
351
  ChangeInstructions,
342
352
  InstructionsUpdater,
343
- StoreMap,
344
- ViewModel,
345
- BindSubscriptionList,
346
- BindParams,
353
+ DiffPair,
354
+ CompileChildren,
355
+ PublishFromDom_2 as PublishFromDom,
356
+ Subscribe,
347
357
  AppAdditionListenerOptions,
348
- DefaultBusListenerOptions,
349
358
  ListenerKit,
350
- PublishFunction,
359
+ Publish,
351
360
  BusListener,
352
361
  BusEventMatcher,
353
362
  ExactSubscriptionData,
354
363
  FuzzySubscriptionData,
355
364
  Unsubscribe,
356
- CreateAppBuilderArguments,
357
- RouteState,
358
- AttributesWithChildren,
359
- DiffPair,
360
- CompileChildren,
361
- StatePublisher,
362
365
  StateTransactionUpdater,
363
366
  StoresCollection,
364
367
  StoreInitializationOptions,
@@ -366,8 +369,6 @@ export declare namespace JaxsTypes {
366
369
  UpdaterValue,
367
370
  StoreUpdaterOrValue,
368
371
  StoreListSorterFunction,
369
- RouteMatcher,
370
- RenderedRoute,
371
372
  PeriodicPublisher,
372
373
  RequiredPeriodicPublisherOptions,
373
374
  GeneralPeriodicOptions,
@@ -377,6 +378,9 @@ export declare namespace JaxsTypes {
377
378
  PublishPeriodicallyOptions,
378
379
  PeriodicTimerFunctionOptions,
379
380
  PeriodicTimerFunction,
381
+ RouteState,
382
+ RouteMatcher,
383
+ RenderedRoute,
380
384
  }
381
385
  }
382
386
 
@@ -384,9 +388,12 @@ export declare const jsx: {
384
388
  <T>(
385
389
  type: string | Template<T>,
386
390
  attributes: Props<T>,
387
- ...children: JsxCollection
391
+ ...children: RenderableCollection
388
392
  ): Renderable
389
- fragment<T>(attributes: Props<T>, maybeChildren: JsxCollection): Children
393
+ fragment<T>(
394
+ attributes: Props<T>,
395
+ maybeChildren: RenderableCollection,
396
+ ): Children
390
397
  }
391
398
 
392
399
  declare type JsxChangeId = {
@@ -394,8 +401,6 @@ declare type JsxChangeId = {
394
401
  index: number
395
402
  }
396
403
 
397
- declare type JsxCollection = (Renderable | TextValue)[]
398
-
399
404
  declare interface JsxEventMapped {
400
405
  eventMaps: EventMaps
401
406
  }
@@ -407,10 +412,10 @@ declare interface JsxIded {
407
412
  declare const linkNavigationEvent = 'go-to-href'
408
413
 
409
414
  declare type ListenerKit<T> = {
410
- state: State
415
+ state: State_2
411
416
  document: Document
412
417
  window: Window
413
- publish: PublishFunction
418
+ publish: Publish<any>
414
419
  eventName: string
415
420
  payload: T
416
421
  }
@@ -452,14 +457,16 @@ declare type NullInstructionData = Record<string, never>
452
457
 
453
458
  declare type NullValues = null | undefined
454
459
 
460
+ declare type Object_2 = Record<string, any>
461
+
455
462
  declare const onLinkClick: (listenerKit: ListenerKit<MouseEvent>) => void
456
463
 
457
464
  declare const onLocationChange: (listenerKit: ListenerKit<null>) => void
458
465
 
459
- declare interface PeriodicPublisher {
466
+ declare interface PeriodicPublisher<T> {
460
467
  event: string
461
- publish: PublishFunction
462
- payload?: any
468
+ publish: Publish<T>
469
+ payload?: T
463
470
  start: () => void
464
471
  stop: () => void
465
472
  }
@@ -475,8 +482,8 @@ declare type PeriodicTimerFunctionOptions = {
475
482
  }
476
483
 
477
484
  export declare type Props<T> = Partial<{
478
- __source: ReactSourceObject
479
- children: JsxCollection
485
+ __source?: ReactSourceObject
486
+ children: RenderableCollection
480
487
  }> &
481
488
  T
482
489
 
@@ -485,19 +492,21 @@ declare type PropValue =
485
492
  | NullValues
486
493
  | boolean
487
494
  | ReactSourceObject
488
- | JsxCollection
495
+ | RenderableCollection
496
+
497
+ export declare type Publish<T> = (event: string, payload: T) => void
489
498
 
490
- export declare type PublishFunction = (event: string, payload: any) => void
499
+ declare type PublishFromDom_2 = Publish<Event>
491
500
 
492
501
  declare const publishLocation: (app: App) => void
493
502
 
494
- declare const publishPeriodically: (
495
- options: PublishPeriodicallyOptions,
503
+ declare const publishPeriodically: <T>(
504
+ options: PublishPeriodicallyOptions<T>,
496
505
  ) => () => void
497
506
 
498
- declare type PublishPeriodicallyOptions =
499
- | GeneralPeriodicPublisherOptions
500
- | CustomPeriodicPublisherOptions
507
+ declare type PublishPeriodicallyOptions<T> =
508
+ | GeneralPeriodicPublisherOptions<T>
509
+ | CustomPeriodicPublisherOptions<T>
501
510
 
502
511
  declare type ReactSourceObject = {
503
512
  fileName: string
@@ -514,6 +523,8 @@ export declare interface Renderable {
514
523
  render: (renderKit: RenderKit, parentElement?: JaxsElement) => JaxsNode[]
515
524
  }
516
525
 
526
+ declare type RenderableCollection = Renderable[]
527
+
517
528
  export declare type RenderedRoute = {
518
529
  Partial: StaticTemplate
519
530
  match: RouteMatcher
@@ -522,16 +533,16 @@ export declare type RenderedRoute = {
522
533
  declare type RenderKit = {
523
534
  document: Document
524
535
  window: Window
525
- publish: DomPublish
526
- subscribe: Subscribe
527
- state: State
536
+ publish: PublishFromDom
537
+ subscribe: Subscribe_2
538
+ state: State_2
528
539
  parent?: JaxsNode | null
529
540
  }
530
541
 
531
- declare type RequiredPeriodicPublisherOptions = {
542
+ declare type RequiredPeriodicPublisherOptions<T> = {
532
543
  event: string
533
- publish: PublishFunction
534
- payload?: any
544
+ publish: Publish<T>
545
+ payload?: T
535
546
  }
536
547
 
537
548
  declare class Root {
@@ -585,12 +596,12 @@ declare namespace start {
585
596
  declare const startNavigation: (app: App) => void
586
597
 
587
598
  export declare class State {
588
- publisher: StatePublisher
599
+ publisher: Publish<any>
589
600
  stores: StoresCollection
590
601
  eventNamePrefix: string
591
602
  notifications: Set<string>
592
603
  inTransaction: boolean
593
- constructor(publisher: StatePublisher)
604
+ constructor(publisher: Publish<any>)
594
605
  create<T>(name: string, initialState: T): Store<T>
595
606
  store<T>(name: string): Store<T>
596
607
  get<T>(name: string): T
@@ -607,8 +618,6 @@ export declare namespace state {
607
618
  export { eventName, State, createState, Store, updaters }
608
619
  }
609
620
 
610
- declare type StatePublisher = (event: string, payload: any) => void
611
-
612
621
  declare type StateTransactionUpdater = (collection: StoresCollection) => void
613
622
 
614
623
  export declare type StaticTemplate = () => Renderable
@@ -617,7 +626,7 @@ export declare class Store<T> {
617
626
  parent: State
618
627
  name: string
619
628
  updater: StoreUpdater<T>
620
- _value: T
629
+ private _value
621
630
  initialValue: T
622
631
  constructor(options: StoreInitializationOptions<T>)
623
632
  get ['value'](): T
@@ -632,7 +641,7 @@ declare type StoreDataUpdater<T> = (originalValue: T) => T
632
641
 
633
642
  declare type StoreInitializationOptions<T> = {
634
643
  name: string
635
- parent: State
644
+ parent: State_2
636
645
  value: T
637
646
  }
638
647
 
@@ -642,48 +651,52 @@ declare type StoreMap = {
642
651
  [key: string]: any
643
652
  }
644
653
 
645
- declare type StoresCollection = Record<string, Store<any>>
654
+ declare type StoresCollection = Record<string, Store_2<any>>
646
655
 
647
- export declare type StoreUpdater<T> =
648
- | StoreUpdaterBase<T>
656
+ declare type StoreUpdater<T> =
649
657
  | StoreUpdaterObject<T extends object ? T : never>
650
658
  | StoreUpdaterBoolean
651
659
  | StoreUpdaterList<T>
652
660
 
653
- export declare class StoreUpdaterBase<T> {
654
- store: Store<T>
655
- constructor(store: Store<T>)
656
- update(updater: StoreUpdaterOrValue<T>): void
661
+ declare class StoreUpdaterBoolean {
662
+ store: Store<boolean>
663
+ constructor(store: Store<boolean>)
664
+ private update
665
+ private get value()
657
666
  reset(): void
658
- get value(): T
659
- }
660
-
661
- export declare class StoreUpdaterBoolean extends StoreUpdaterBase<boolean> {
662
667
  toggle(): void
663
668
  setTrue(): void
664
669
  setFalse(): void
665
670
  }
666
671
 
667
- export declare class StoreUpdaterList<T> extends StoreUpdaterBase<T[]> {
672
+ declare class StoreUpdaterList<T> {
673
+ store: Store<T[]>
674
+ constructor(store: Store<T[]>)
675
+ private update
676
+ private get value()
677
+ reset(): void
668
678
  push(element: T): void
669
679
  pop(): T
670
680
  unshift(element: T): void
671
681
  shift(): T
672
- addSorter(name: string, sorter: StoreListSorterFunction<T>): void
673
682
  sortBy(sorter: StoreListSorterFunction<T>): void
674
683
  insertAt(index: number, item: T): void
675
684
  remove(value: T): void
676
685
  removeBy(matcherFunction: (value: T) => boolean): void
677
686
  }
678
687
 
679
- export declare class StoreUpdaterObject<
680
- T extends object,
681
- > extends StoreUpdaterBase<T> {
688
+ declare class StoreUpdaterObject<T extends object> {
689
+ store: Store<T>
690
+ constructor(store: Store<T>)
691
+ private update
692
+ private get value()
693
+ reset(): void
682
694
  updateAttribute(name: keyof T, value: T[keyof T]): void
683
695
  updateDynamicAttribute(name: string, value: any): void
684
696
  isKey(key: string): boolean
685
697
  isValueType(key: keyof T, value: any): boolean
686
698
  resetAttribute(name: keyof T): void
699
+ updateAttributes(values: Partial<T>): void
687
700
  }
688
701
 
689
702
  declare type StoreUpdaterOrValue<T> = UpdaterValue<T> | StoreDataUpdater<T>
@@ -697,7 +710,10 @@ declare const subscribeToHistoryChange: (app: App) => void
697
710
 
698
711
  declare const subscribeToNavigation: (app: App) => void
699
712
 
700
- declare type TagAttributes = SourceMap & Record<string, string>
713
+ declare type TagAttributes = SourceMap &
714
+ Record<string, string> & {
715
+ __source?: ReactSourceObject
716
+ }
701
717
 
702
718
  declare type TagAttributesAndEvents = {
703
719
  attributes: TagAttributes
@@ -714,6 +730,47 @@ export declare type TypedTemplate<T> = (props: Props<T>) => Renderable
714
730
 
715
731
  declare type Unsubscribe = () => void
716
732
 
733
+ export declare const Update: {
734
+ RecordStore: {
735
+ reset: <T>(store: Store<T>) => void
736
+ resetAttribute: <T>(store: Store<T>, name: keyof T) => void
737
+ updateAttribute: <T>(
738
+ store: Store<T>,
739
+ name: keyof T,
740
+ value: T[keyof T],
741
+ ) => void
742
+ updateAttributes: <T>(store: Store<T>, values: Partial<T>) => void
743
+ }
744
+ BooleanStore: {
745
+ toggle: (store: Store<boolean>) => void
746
+ setTrue: (store: Store<boolean>) => void
747
+ setFalse: (store: Store<boolean>) => void
748
+ reset: (store: Store<boolean>) => void
749
+ }
750
+ ListStore: {
751
+ push: <T>(store: Store<T[]>, element: T) => void
752
+ pop: <T>(store: Store<T[]>) => T
753
+ unshift: <T>(store: Store<T[]>, element: T) => void
754
+ shift: <T>(store: Store<T[]>) => T
755
+ sortBy: <T>(store: Store<T[]>, sorter: StoreListSorterFunction<T>) => void
756
+ insertAt: <T>(store: Store<T[]>, index: number, item: T) => void
757
+ remove: <T>(store: Store<T[]>, value: T) => void
758
+ removeBy: <T>(
759
+ store: Store<T[]>,
760
+ matcherFunction: (value: T) => boolean,
761
+ ) => void
762
+ reset: <T>(store: Store<T[]>) => void
763
+ }
764
+ ArrayModifiers: {
765
+ remove: <T>(originalCollection: T[], itemToRemove: T) => T[]
766
+ removeBy: <T>(
767
+ originalCollection: T[],
768
+ matcherFunction: (value: T) => boolean,
769
+ ) => T[]
770
+ insertAt: <T>(originalCollection: T[], index: number, item: T) => T[]
771
+ }
772
+ }
773
+
717
774
  declare type UpdateEventInstructionData = {
718
775
  name: string
719
776
  sourceValue: EventListener