@@ -35,33 +35,6 @@ export const getPath = (node1, node2) => {
35
35
return backtrackStr + forwardStepsStr
36
36
}
37
37
38
- /**
39
- * @callback Goto
40
- * @param {string|RNodeRuntime } pathOrNode relative, absolute or named URL
41
- * @param {Object.<string, string>= } userParams
42
- * @param {Partial<$UrlOptions & RouteState>= } options
43
- * @type {Readable<Goto> } */
44
- export const goto = {
45
- subscribe : ( run , invalidate ) => {
46
- const { router } = contexts
47
-
48
- return derived ( url , $url =>
49
- /** @type {Goto } */
50
- ( pathOrNode , userParams , options ) => {
51
- const path =
52
- typeof pathOrNode === 'string' ? pathOrNode : pathOrNode ?. path
53
-
54
- /** @type {options } */
55
- const defaults = { mode : 'push' , state : { } }
56
- options = { ...defaults , ...options }
57
- const newUrl = $url ( path , userParams , options )
58
- router . url [ options . mode ] ( newUrl , options . state )
59
- return ''
60
- } ,
61
- ) . subscribe ( run , invalidate )
62
- } ,
63
- }
64
-
65
38
/**
66
39
* @template T
67
40
* @typedef {import('svelte/store').Readable<T> } Readable
@@ -90,6 +63,33 @@ export const goto = {
90
63
* }>} RouteState
91
64
*/
92
65
66
+ /**
67
+ * @callback Goto
68
+ * @param {string|RNodeRuntime } pathOrNode relative, absolute or named URL
69
+ * @param {Object.<string, string>= } userParams
70
+ * @param {Partial<$UrlOptions & RouteState>= } options
71
+ * @type {Readable<Goto> } */
72
+ export const goto = {
73
+ subscribe : ( run , invalidate ) => {
74
+ const { router } = contexts
75
+
76
+ return derived ( url , $url =>
77
+ /** @type {Goto } */
78
+ ( pathOrNode , userParams , options ) => {
79
+ const path =
80
+ typeof pathOrNode === 'string' ? pathOrNode : pathOrNode ?. path
81
+
82
+ /** @type {options } */
83
+ const defaults = { mode : 'push' , state : { } }
84
+ options = { ...defaults , ...options }
85
+ const newUrl = $url ( path , userParams , options )
86
+ router . url [ options . mode ] ( newUrl , options . state )
87
+ return ''
88
+ } ,
89
+ ) . subscribe ( run , invalidate )
90
+ } ,
91
+ }
92
+
93
93
/**
94
94
* @typedef {(<T extends string | HTMLAnchorElement>(
95
95
* inputPath: T,
@@ -98,13 +98,6 @@ export const goto = {
98
98
* ) => T extends HTMLAnchorElement ? void : string)} Url
99
99
*/
100
100
101
- /**
102
- * @typedef {((
103
- * pathOrNode: string|RNodeRuntime,
104
- * userParams?: { [x: string]: string; },
105
- * options?: Partial<$UrlOptions>
106
- * ) => string)} UrlFromString
107
- */
108
101
/**
109
102
* @type {Readable<Url> }
110
103
*/
@@ -140,6 +133,14 @@ export const url = {
140
133
} ,
141
134
}
142
135
136
+ /**
137
+ * @typedef {((
138
+ * pathOrNode: string|RNodeRuntime,
139
+ * userParams?: { [x: string]: string; },
140
+ * options?: Partial<$UrlOptions>
141
+ * ) => string)} UrlFromString
142
+ */
143
+
143
144
/**
144
145
* @param {RouteFragment } fragment
145
146
* @param {Router } router
0 commit comments