jaxs 0.4.4 → 0.5.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
@@ -163,7 +163,7 @@ declare module 'bus/index' {
163
163
  BusListener,
164
164
  Unsubscribe,
165
165
  AppAdditionListenerOptions,
166
- BusOptions,
166
+ ListenerKit,
167
167
  } from 'types'
168
168
  import { ExactSubscriptions } from 'bus/exact-subscriptions'
169
169
  import { FuzzySubscriptions } from 'bus/fuzzy-subscriptions'
@@ -179,7 +179,7 @@ declare module 'bus/index' {
179
179
  ): Unsubscribe
180
180
  publish<T>(event: string, payload: T): void
181
181
  addListenerOptions(options: AppAdditionListenerOptions): void
182
- listenerOptions(event: string): BusOptions
182
+ listenerOptions(event: string): ListenerKit
183
183
  }
184
184
  const createBus: () => {
185
185
  bus: JaxsBus
@@ -230,19 +230,22 @@ declare module 'navigation/find-href' {
230
230
  export const findHref: (node: HTMLElement) => string
231
231
  }
232
232
  declare module 'navigation/navigate' {
233
- import { BusOptions } from 'types'
234
- export const navigate: (path: string, { publish, window }: BusOptions) => void
233
+ import { ListenerKit } from 'types'
234
+ export const navigate: (
235
+ path: string,
236
+ { publish, window }: ListenerKit,
237
+ ) => void
235
238
  }
236
239
  declare module 'navigation/on-link-click' {
237
- import { BusOptions } from 'types'
238
- export const onLinkClick: (domEvent: MouseEvent, options: BusOptions) => void
240
+ import { ListenerKit } from 'types'
241
+ export const onLinkClick: (domEvent: MouseEvent, options: ListenerKit) => void
239
242
  }
240
243
  declare module 'navigation/extract-query-params' {
241
244
  export const extractQueryParams: (queryString: string) => {}
242
245
  }
243
246
  declare module 'navigation/on-location-change' {
244
- import { BusOptions } from 'types'
245
- export const onLocationChange: (_: null, listenerOptions: BusOptions) => void
247
+ import { ListenerKit } from 'types'
248
+ export const onLocationChange: (_: null, listenerOptions: ListenerKit) => void
246
249
  }
247
250
  declare module 'navigation/start' {
248
251
  import type { App } from 'app/index'
@@ -259,7 +262,7 @@ declare module 'app/index' {
259
262
  export class App {
260
263
  window: Window
261
264
  document: Document
262
- publish: PublishFunction<any>
265
+ publish: PublishFunction
263
266
  subscribe: Subscribe
264
267
  bus: JaxsBus
265
268
  state: State
@@ -453,14 +456,14 @@ declare module 'types' {
453
456
  document: Document
454
457
  window: Window
455
458
  }
456
- export type DefaultBusListenerOptions<T> = {
457
- publish: PublishFunction<T>
459
+ export type DefaultBusListenerOptions = {
460
+ publish: PublishFunction
458
461
  eventName: string
459
462
  }
460
- export type BusOptions = AppAdditionListenerOptions &
461
- DefaultBusListenerOptions<any>
462
- export type PublishFunction<T> = (event: string, payload: T) => void
463
- export type BusListener<T> = (payload: T, listenerKit: BusOptions) => void
463
+ export type ListenerKit = AppAdditionListenerOptions &
464
+ DefaultBusListenerOptions
465
+ export type PublishFunction = (event: string, payload: any) => void
466
+ export type BusListener<T> = (payload: T, listenerKit: ListenerKit) => void
464
467
  export type BusEventMatcher = string | RegExp
465
468
  export type ExactSubscriptionData<T> = {
466
469
  listener: BusListener<T>
@@ -514,6 +517,11 @@ declare module 'types' {
514
517
  StoreUpdaterFunction<T>
515
518
  >
516
519
  export type StoreListSorterFunction<T> = (left: T, right: T) => number
520
+ export type RouteMatcher = (routeState: RouteState) => boolean
521
+ export type RenderedRoute = {
522
+ Partial: StaticTemplate
523
+ match: RouteMatcher
524
+ }
517
525
  }
518
526
  declare module 'rendering/dom/tag' {
519
527
  import type {
@@ -691,7 +699,7 @@ declare module 'app/builder' {
691
699
  class AppBuilder {
692
700
  window: Window
693
701
  document: Document
694
- publish: PublishFunction<any>
702
+ publish: PublishFunction
695
703
  subscribe: Subscribe
696
704
  bus: JaxsBus
697
705
  state: State
@@ -920,6 +928,30 @@ declare module 'navigation/index' {
920
928
  start,
921
929
  }
922
930
  }
931
+ declare module 'app/routing' {
932
+ import { RenderedRoute, RouteMatcher } from 'types'
933
+ export const exactPathMatch: (exactPath: string) => RouteMatcher
934
+ export const catchAll: RouteMatcher
935
+ export const buildRouter: (
936
+ pages: RenderedRoute[],
937
+ ) => ({ route }: { route: any }) => import('types').StaticTemplate
938
+ }
939
+ declare module 'rendering/null' {
940
+ import { RenderKit, JaxsElement, JaxsNode } from 'types'
941
+ export const NullTemplate: () => {
942
+ render: (renderKit: RenderKit, parentElement?: JaxsElement) => JaxsNode[]
943
+ }
944
+ }
945
+ declare module 'app/routed-view' {
946
+ import { RenderedRoute, RouteState } from 'types'
947
+ export const routedView: (routes: RenderedRoute[]) => (
948
+ attributes: Partial<
949
+ import('types').Props<{
950
+ route: RouteState
951
+ }>
952
+ >,
953
+ ) => import('rendering/templates/bound').Bound<unknown, unknown>
954
+ }
923
955
  declare module 'jaxs' {
924
956
  export { jsx } from 'rendering/jsx'
925
957
  export { createApp } from 'app/builder'
@@ -929,4 +961,6 @@ declare module 'jaxs' {
929
961
  export * as appBuilding from 'app/index'
930
962
  export * as messageBus from 'bus/index'
931
963
  export * as state from 'state/index'
964
+ export * as routing from 'app/routing'
965
+ export { routedView } from 'app/routed-view'
932
966
  }