@bitstillery/mithril 3.0.0-AA → 3.0.1-AA
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/index.ts +7 -6
- package/package.json +1 -1
- package/state.ts +4 -1
- package/util/next_tick.ts +4 -5
package/index.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import './jsx.d.ts'
|
|
1
2
|
import hyperscript from './render/hyperscript'
|
|
2
3
|
import mountRedrawFactory from './api/mount-redraw'
|
|
3
4
|
import routerFactory from './api/router'
|
|
@@ -8,7 +9,7 @@ import parsePathname from './pathname/parse'
|
|
|
8
9
|
import buildPathname from './pathname/build'
|
|
9
10
|
import VnodeFactory, {MithrilComponent} from './render/vnode'
|
|
10
11
|
import censor from './util/censor'
|
|
11
|
-
import
|
|
12
|
+
import nextTick from './util/next_tick'
|
|
12
13
|
import domFor from './render/domFor'
|
|
13
14
|
import {signal, computed, effect, Signal, ComputedSignal, setSignalRedrawCallback, getSignalComponents} from './signal'
|
|
14
15
|
import {state, watch, registerState, getRegisteredStates, copyGlobalStatesToContext} from './state'
|
|
@@ -36,7 +37,7 @@ export interface MithrilStatic {
|
|
|
36
37
|
buildPathname: (template: string, params: Record<string, any>) => string
|
|
37
38
|
vnode: typeof VnodeFactory
|
|
38
39
|
censor: (attrs: Record<string, any>, extras?: string[]) => Record<string, any>
|
|
39
|
-
|
|
40
|
+
nextTick: () => Promise<void>
|
|
40
41
|
domFor: (vnode: Vnode) => Generator<Node, void, unknown>
|
|
41
42
|
}
|
|
42
43
|
|
|
@@ -66,7 +67,7 @@ m.parsePathname = parsePathname
|
|
|
66
67
|
m.buildPathname = buildPathname
|
|
67
68
|
m.vnode = VnodeFactory
|
|
68
69
|
m.censor = censor
|
|
69
|
-
m.
|
|
70
|
+
m.nextTick = nextTick
|
|
70
71
|
m.domFor = domFor
|
|
71
72
|
|
|
72
73
|
// Set up signal-to-component redraw integration
|
|
@@ -82,7 +83,7 @@ setSignalRedrawCallback((sig: Signal<any>) => {
|
|
|
82
83
|
|
|
83
84
|
// Export signals API
|
|
84
85
|
export {signal, computed, effect, Signal, ComputedSignal, state, watch, registerState, getRegisteredStates}
|
|
85
|
-
export type {State, StateOptions} from './state'
|
|
86
|
+
export type {State, StateOptions, Unwatch} from './state'
|
|
86
87
|
|
|
87
88
|
// Export Store class
|
|
88
89
|
export {Store} from './store'
|
|
@@ -98,8 +99,8 @@ export type {SSRAccessContext} from './ssrContext'
|
|
|
98
99
|
export {logger, Logger} from './server/logger'
|
|
99
100
|
export type {LogContext} from './server/logger'
|
|
100
101
|
|
|
101
|
-
// Export
|
|
102
|
-
export {
|
|
102
|
+
// Export nextTick utility
|
|
103
|
+
export {nextTick} from './util/next_tick'
|
|
103
104
|
|
|
104
105
|
// Export URI utilities
|
|
105
106
|
export {getCurrentUrl, getPathname, getSearch, getHash, getLocation} from './util/uri'
|
package/package.json
CHANGED
package/state.ts
CHANGED
|
@@ -990,13 +990,16 @@ export type State<T extends Record<string, any>> = {
|
|
|
990
990
|
[K in keyof T]: T[K] extends (...args: any[]) => infer R ? R : T[K] extends Record<string, any> ? State<T[K]> : T[K]
|
|
991
991
|
} & StateSignals<T>
|
|
992
992
|
|
|
993
|
+
/** Function returned by watch() to remove the watcher */
|
|
994
|
+
export type Unwatch = () => void
|
|
995
|
+
|
|
993
996
|
/**
|
|
994
997
|
* Watch a signal for changes
|
|
995
998
|
* @param signal - The signal to watch
|
|
996
999
|
* @param callback - Callback function called when signal value changes
|
|
997
1000
|
* @returns Unsubscribe function
|
|
998
1001
|
*/
|
|
999
|
-
export function watch<T>(signal: Signal<T> | ComputedSignal<T>, callback: (newValue: T, oldValue: T) => void):
|
|
1002
|
+
export function watch<T>(signal: Signal<T> | ComputedSignal<T>, callback: (newValue: T, oldValue: T) => void): Unwatch {
|
|
1000
1003
|
const unwatch = signal.watch(callback)
|
|
1001
1004
|
|
|
1002
1005
|
// Register watcher in SSR context for cleanup at end of request
|
package/util/next_tick.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Isomorphic
|
|
2
|
+
* Isomorphic nextTick utility
|
|
3
3
|
*
|
|
4
4
|
* Returns a Promise that resolves after the current execution stack completes.
|
|
5
5
|
*
|
|
@@ -8,8 +8,7 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @returns Promise that resolves on the next tick
|
|
10
10
|
*/
|
|
11
|
-
|
|
12
|
-
async function next_tick(): Promise<void> {
|
|
11
|
+
async function nextTick(): Promise<void> {
|
|
13
12
|
// Check if we're in SSR mode
|
|
14
13
|
if (typeof globalThis !== 'undefined' && (globalThis as any).__SSR_MODE__) {
|
|
15
14
|
// In SSR mode, resolve immediately since SSR rendering is synchronous
|
|
@@ -41,5 +40,5 @@ async function next_tick(): Promise<void> {
|
|
|
41
40
|
return Promise.resolve() as Promise<void>
|
|
42
41
|
}
|
|
43
42
|
|
|
44
|
-
export default
|
|
45
|
-
export {
|
|
43
|
+
export default nextTick
|
|
44
|
+
export {nextTick}
|