c0ckp1t 1.0.0 → 1.0.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/README.md +11 -0
- package/c0ckp1t-demo/Constants.mjs +1 -4
- package/core/GlobalStore.mjs +3 -0
- package/core/Island.mjs +5 -6
- package/core/IslandDefault.mjs +4 -5
- package/core/Logging.mjs +28 -19
- package/core/Theme.mjs +0 -1
- package/core/VueUtils.mjs +4 -8
- package/core/pages/Cache.vue +1 -2
- package/core/pages/Connections.vue +2 -2
- package/core/pages/Documentation.vue +2 -3
- package/core/pages/connections/page-connection-default.vue +7 -8
- package/core/pages/connections/ws-connection.vue +1 -2
- package/index-cdn.html +31 -34
- package/js_ext/vue-router.esm-browser.prod.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# c0ckp1t-webroot
|
|
2
2
|
|
|
3
3
|
|
|
4
|
+
A Vue 3 zero-build web dashboard framework with Islands architecture, WebSocket backends, and reusable UI components
|
|
4
5
|
|
|
6
|
+
* npm
|
|
7
|
+
* https://www.npmjs.com/package/c0ckp1t
|
|
8
|
+
* cdn
|
|
9
|
+
* https://cdn.jsdelivr.net/npm/c0ckp1t@1.0.0/
|
|
5
10
|
|
|
11
|
+
|
|
12
|
+
# Releases
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
* 1.0.0 - Beta initial release
|
|
16
|
+
* 1.0.1 - Beta removing `Constants.mjs` dependencies
|
|
@@ -48,8 +48,6 @@ const {hostname, port, protocol, isSecure, apiBaseUrl} = findHostNamePortProtoco
|
|
|
48
48
|
// ________________________________________________________________________________
|
|
49
49
|
// GLOBAL CONSTANTS
|
|
50
50
|
// ________________________________________________________________________________
|
|
51
|
-
const defaultInstanceId = "default";
|
|
52
|
-
|
|
53
51
|
let Constants = {
|
|
54
52
|
|
|
55
53
|
SERVER_API_URL: `${protocol}//${hostname}:${port}`,
|
|
@@ -92,7 +90,6 @@ let Constants = {
|
|
|
92
90
|
apiBaseUrl: apiBaseUrl,
|
|
93
91
|
|
|
94
92
|
islands: { },
|
|
95
|
-
defaultInstanceId: defaultInstanceId,
|
|
96
93
|
defaultConfig: {
|
|
97
94
|
instanceId: "default",
|
|
98
95
|
root: {
|
|
@@ -106,7 +103,7 @@ let Constants = {
|
|
|
106
103
|
children: [
|
|
107
104
|
{
|
|
108
105
|
depth: 1,
|
|
109
|
-
endpoint:
|
|
106
|
+
endpoint: `/default/demo`,
|
|
110
107
|
isLeaf: true,
|
|
111
108
|
isRoot: false,
|
|
112
109
|
path: ["demo"],
|
package/core/GlobalStore.mjs
CHANGED
|
@@ -254,6 +254,8 @@ export const api = {
|
|
|
254
254
|
};
|
|
255
255
|
|
|
256
256
|
|
|
257
|
+
|
|
258
|
+
config.defaultConfig.SERVER_API_URL = config.SERVER_API_URL
|
|
257
259
|
const islandDefault = new IslandDefault(api, config.defaultConfig)
|
|
258
260
|
store.r[islandDefault.instanceId] = islandDefault
|
|
259
261
|
await islandDefault.init()
|
|
@@ -312,6 +314,7 @@ export const api = {
|
|
|
312
314
|
|
|
313
315
|
for (const [key, value] of Object.entries(config.islands || {})) {
|
|
314
316
|
const config = {
|
|
317
|
+
SERVER_API_URL: config.SERVER_API_URL,
|
|
315
318
|
sfcOptions: islandDefault.sfcOptions,
|
|
316
319
|
...value
|
|
317
320
|
}
|
package/core/Island.mjs
CHANGED
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
import {markRaw, reactive, watch, defineAsyncComponent, getCurrentInstance} from 'vue'
|
|
9
9
|
import {ok, nok, sha1} from "JsUtils"
|
|
10
10
|
import {getLogger} from 'Logging';
|
|
11
|
-
import Constants from "Constants";
|
|
12
11
|
import Connection from "./ws-client/Connection.mjs";
|
|
13
12
|
|
|
14
13
|
import {indexOfNonString} from "JsUtils";
|
|
@@ -306,7 +305,7 @@ export default class Island {
|
|
|
306
305
|
|
|
307
306
|
if (endpoint.startsWith('/c0ckp1t/')) {
|
|
308
307
|
const endpointAdjusted = endpoint.replace("/c0ckp1t/", `/`)
|
|
309
|
-
const path = `${
|
|
308
|
+
const path = `${this.config.SERVER_API_URL}${endpointAdjusted}`;
|
|
310
309
|
this.logger.debug(`[resolver] - endpointAdjusted=${path}`);
|
|
311
310
|
const res = await Http.getText(path)
|
|
312
311
|
if (res.isOk) {
|
|
@@ -328,7 +327,7 @@ export default class Island {
|
|
|
328
327
|
getText = async (endpoint) => {
|
|
329
328
|
this.logger.info(`[getText] - endpoint=${endpoint}`)
|
|
330
329
|
if (endpoint.startsWith('/c0ckp1t/')) {
|
|
331
|
-
const path = `${
|
|
330
|
+
const path = `${this.config.SERVER_API_URL}${endpoint}`;
|
|
332
331
|
return await Http.getText(path)
|
|
333
332
|
}
|
|
334
333
|
const args = ["read", endpoint]
|
|
@@ -341,19 +340,19 @@ export default class Island {
|
|
|
341
340
|
}
|
|
342
341
|
|
|
343
342
|
async getBinary(endpoint) {
|
|
344
|
-
const path = `${
|
|
343
|
+
const path = `${this.config.SERVER_API_URL}${endpoint}`;
|
|
345
344
|
this.logger.debug(`[getBinary] - ${path}`);
|
|
346
345
|
return await Http.getBinary(path)
|
|
347
346
|
}
|
|
348
347
|
|
|
349
348
|
async getJson(endpoint) {
|
|
350
|
-
const path = `${
|
|
349
|
+
const path = `${this.config.SERVER_API_URL}${endpoint}`;
|
|
351
350
|
this.logger.debug(`[getJson] - ${path}`);
|
|
352
351
|
return await Http.getJson(path)
|
|
353
352
|
}
|
|
354
353
|
|
|
355
354
|
async postJson(endpoint, body) {
|
|
356
|
-
const path = `${
|
|
355
|
+
const path = `${this.config.SERVER_API_URL}${endpoint}`;
|
|
357
356
|
this.logger.debug(`[postJson] - ${path}`);
|
|
358
357
|
return await Http.postJson(path, body)
|
|
359
358
|
}
|
package/core/IslandDefault.mjs
CHANGED
|
@@ -5,7 +5,6 @@ import {markRaw, reactive, watch, defineAsyncComponent, getCurrentInstance} from
|
|
|
5
5
|
import {ok, nok, sha1} from "JsUtils"
|
|
6
6
|
import {Http} from "WsUtils"
|
|
7
7
|
import {getLogger} from 'Logging';
|
|
8
|
-
import Constants from "Constants";
|
|
9
8
|
import {loadModule, options } from "./VueUtils.mjs";
|
|
10
9
|
|
|
11
10
|
// ________________________________________________________________________________
|
|
@@ -183,25 +182,25 @@ export default class IslandDefault {
|
|
|
183
182
|
|
|
184
183
|
|
|
185
184
|
getText = async (endpoint) => {
|
|
186
|
-
const path = `${
|
|
185
|
+
const path = `${this.config.SERVER_API_URL}${endpoint}`;
|
|
187
186
|
this.logger.debug(`[getText] - ${path}`);
|
|
188
187
|
return await Http.getText(path)
|
|
189
188
|
}
|
|
190
189
|
|
|
191
190
|
async getBinary(endpoint) {
|
|
192
|
-
const path = `${
|
|
191
|
+
const path = `${this.config.SERVER_API_URL}${endpoint}`;
|
|
193
192
|
this.logger.debug(`[getBinary] - ${path}`);
|
|
194
193
|
return await Http.getBinary(path)
|
|
195
194
|
}
|
|
196
195
|
|
|
197
196
|
async getJson(endpoint, params = {}) {
|
|
198
|
-
const path = `${
|
|
197
|
+
const path = `${this.config.SERVER_API_URL}${endpoint}`;
|
|
199
198
|
this.logger.debug(`[getJson] - ${path}`);
|
|
200
199
|
return await Http.getJson(path)
|
|
201
200
|
}
|
|
202
201
|
|
|
203
202
|
async postJson(endpoint, body) {
|
|
204
|
-
const path = `${
|
|
203
|
+
const path = `${this.config.SERVER_API_URL}${endpoint}`;
|
|
205
204
|
this.logger.debug(`[postJson] - ${path}`);
|
|
206
205
|
return await Http.postJson(path, body)
|
|
207
206
|
}
|
package/core/Logging.mjs
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
// ________________________________________________________________________________
|
|
2
2
|
// Logging.mjs
|
|
3
3
|
// ________________________________________________________________________________
|
|
4
|
-
import Constants from '../Constants.mjs'
|
|
5
4
|
|
|
6
5
|
// Note: localStorage is global in browser environment object
|
|
7
6
|
// Note: window.log is provided by loglevel library (imported globally in index.html)
|
|
@@ -12,18 +11,25 @@ const prefixer = prefix.noConflict();
|
|
|
12
11
|
prefixer.reg(log);
|
|
13
12
|
prefixer.apply(log, { format: loggerPrefixFn });
|
|
14
13
|
|
|
15
|
-
const localStorageKey = "loggers"
|
|
16
14
|
|
|
17
|
-
|
|
15
|
+
// ________________________________________________________________________________
|
|
16
|
+
// STORE
|
|
17
|
+
// ________________________________________________________________________________
|
|
18
|
+
export const store = {
|
|
19
|
+
defaultLogLevel: "INFO",
|
|
20
|
+
localStorageKey: "loggers",
|
|
21
|
+
loggers: { }
|
|
22
|
+
}
|
|
23
|
+
|
|
18
24
|
|
|
19
25
|
// https://www.npmjs.com/package/loglevel
|
|
20
26
|
export function getLogger(location) {
|
|
21
27
|
const logger = log.getLogger(location)
|
|
22
|
-
if(loggers.hasOwnProperty(location)) {
|
|
23
|
-
logger.setLevel(loggers[location])
|
|
28
|
+
if(store.loggers.hasOwnProperty(location)) {
|
|
29
|
+
logger.setLevel(store.loggers[location])
|
|
24
30
|
} else {
|
|
25
|
-
logger.setLevel(
|
|
26
|
-
loggers[location] =
|
|
31
|
+
logger.setLevel(store.defaultLogLevel)
|
|
32
|
+
store.loggers[location] = store.defaultLogLevel
|
|
27
33
|
}
|
|
28
34
|
return logger
|
|
29
35
|
}
|
|
@@ -31,29 +37,32 @@ export function getLogger(location) {
|
|
|
31
37
|
export function setLogger(location, level) {
|
|
32
38
|
const logger = log.getLogger(location)
|
|
33
39
|
logger.setLevel(level)
|
|
34
|
-
loggers[location] = level
|
|
40
|
+
store.loggers[location] = level
|
|
35
41
|
|
|
36
42
|
|
|
37
|
-
localStorage.setItem(localStorageKey, JSON.stringify(loggers));
|
|
43
|
+
localStorage.setItem(store.localStorageKey, JSON.stringify(store.loggers));
|
|
38
44
|
}
|
|
39
45
|
|
|
40
46
|
export function listLoggers() {
|
|
41
|
-
return loggers
|
|
47
|
+
return store.loggers
|
|
42
48
|
}
|
|
43
49
|
|
|
44
50
|
export function clearLocalStorage() {
|
|
45
|
-
localStorage.removeItem(localStorageKey)
|
|
51
|
+
localStorage.removeItem(store.localStorageKey)
|
|
46
52
|
}
|
|
47
53
|
|
|
48
|
-
function init() {
|
|
49
|
-
const json = localStorage.getItem(localStorageKey)
|
|
54
|
+
export function init(config) {
|
|
55
|
+
// const json = localStorage.getItem(localStorageKey)
|
|
50
56
|
// Object.assign(loggers, JSON.parse(json));
|
|
57
|
+
|
|
58
|
+
log.trace(`[INIT] - trace - enabled`)
|
|
59
|
+
log.debug(`[INIT] - debug - enabled`)
|
|
60
|
+
log.info (`[INIT] - info - enabled`)
|
|
61
|
+
log.warn( `[INIT] - warn - enabled`)
|
|
62
|
+
log.error(`[INIT] - error - enabled`)
|
|
63
|
+
store.loggers = { ...config.defaultLoggerLevels }
|
|
64
|
+
store.defaultLogLevel = config.defaultLogLevel
|
|
65
|
+
|
|
51
66
|
}
|
|
52
67
|
|
|
53
|
-
log.info (`[INIT]`)
|
|
54
|
-
init()
|
|
55
|
-
// log.trace(`[INIT] - trace - enabled`)
|
|
56
|
-
// log.debug(`[INIT] - debug - enabled`)
|
|
57
|
-
// log.error(`[INIT] - error - enabled`)
|
|
58
|
-
// log.warn( `[INIT] - warn - enabled`)
|
|
59
68
|
|
package/core/Theme.mjs
CHANGED
package/core/VueUtils.mjs
CHANGED
|
@@ -14,15 +14,11 @@
|
|
|
14
14
|
choose between 'sfc' mode (uses vue3-sfc-loader) or 'compiled' mode
|
|
15
15
|
(uses native ES module imports).
|
|
16
16
|
*/
|
|
17
|
-
import Constants from 'Constants'
|
|
18
17
|
import * as Vue from 'vue'
|
|
19
18
|
import * as VueRouter from 'vue-router'
|
|
20
19
|
import {loadModule, vueVersion} from 'vue3-sfc-loader'
|
|
21
20
|
|
|
22
|
-
|
|
23
|
-
console.log(`vue3-sfc-loader vue version ${vueVersion}`)
|
|
24
|
-
console.log(`vue.js version ${Vue.version}`)
|
|
25
|
-
}
|
|
21
|
+
|
|
26
22
|
|
|
27
23
|
import * as Logging from "Logging";
|
|
28
24
|
import * as GlobalStore from 'GlobalStore'
|
|
@@ -41,7 +37,8 @@ const katexTags = ['mn', 'mfrac', 'mrow', 'annotation', 'semantics', 'math',
|
|
|
41
37
|
const LOG_HEADER = `VueUtils.mjs`
|
|
42
38
|
const logger = Logging.getLogger(LOG_HEADER)
|
|
43
39
|
logger.debug("init")
|
|
44
|
-
|
|
40
|
+
logger.info(`vue3-sfc-loader vue version ${vueVersion}`)
|
|
41
|
+
logger.info(`vue.js version ${Vue.version}`)
|
|
45
42
|
|
|
46
43
|
|
|
47
44
|
//________________________________________________________________________________
|
|
@@ -68,7 +65,6 @@ const options = {
|
|
|
68
65
|
WsUtils: WsUtils,
|
|
69
66
|
Logging: Logging,
|
|
70
67
|
NotifyUtils: NotifyUtils,
|
|
71
|
-
Constants: Constants,
|
|
72
68
|
GlobalStore: GlobalStore,
|
|
73
69
|
},
|
|
74
70
|
|
|
@@ -90,7 +86,7 @@ const options = {
|
|
|
90
86
|
res = await GlobalStore.store.r[instanceId].resolver(pathAfterInstanceId, type)
|
|
91
87
|
} else {
|
|
92
88
|
logger.debug(`[getFile] - default - ${path} - ${type}`)
|
|
93
|
-
res = await GlobalStore.store.r[
|
|
89
|
+
res = await GlobalStore.store.r["default"].resolver(path, type)
|
|
94
90
|
}
|
|
95
91
|
|
|
96
92
|
return {
|
package/core/pages/Cache.vue
CHANGED
|
@@ -7,14 +7,13 @@
|
|
|
7
7
|
// IMPORTS
|
|
8
8
|
//________________________________________________________________________________
|
|
9
9
|
import {reactive, markRaw, onMounted, computed} from 'vue'
|
|
10
|
-
import Constants from "Constants";
|
|
11
10
|
import { store as storeMain, api as apiMain } from 'GlobalStore'
|
|
12
11
|
import {getLogger} from "Logging";
|
|
13
12
|
import {useRouter} from "vue-router";
|
|
14
13
|
|
|
15
14
|
const router = useRouter()
|
|
16
15
|
|
|
17
|
-
const registry = storeMain.r[
|
|
16
|
+
const registry = storeMain.r["default"]
|
|
18
17
|
const options = registry.sfcOptions
|
|
19
18
|
|
|
20
19
|
// ________________________________________________________________________________
|
|
@@ -9,7 +9,6 @@
|
|
|
9
9
|
import {reactive, onMounted, defineAsyncComponent, computed} from 'vue'
|
|
10
10
|
import {store as storeMain, api as apiMain} from 'GlobalStore'
|
|
11
11
|
import {getLogger} from "Logging";
|
|
12
|
-
import Constants from "Constants";
|
|
13
12
|
import {useRoute} from "vue-router";
|
|
14
13
|
import {api as notify} from "NotifyUtils"
|
|
15
14
|
import ExecButton from "../../components/ExecButton.vue";
|
|
@@ -33,7 +32,8 @@ const local = reactive({
|
|
|
33
32
|
});
|
|
34
33
|
|
|
35
34
|
function createConnection() {
|
|
36
|
-
|
|
35
|
+
// TODO: create correct config
|
|
36
|
+
const config = {}
|
|
37
37
|
config.instanceId = local.connectionName
|
|
38
38
|
try {
|
|
39
39
|
apiMain.createRegistry(config)
|
|
@@ -14,12 +14,11 @@
|
|
|
14
14
|
import { reactive, computed, watch, onMounted, onBeforeUnmount } from 'vue'
|
|
15
15
|
import { useRoute, useRouter } from 'vue-router'
|
|
16
16
|
|
|
17
|
-
import {store as storeMain, api as apiMain
|
|
17
|
+
import {store as storeMain, api as apiMain} from 'GlobalStore'
|
|
18
18
|
import { getLogger } from "Logging";
|
|
19
19
|
|
|
20
20
|
import { DocUtils, extractBasePathFromURL } from '../DocUtils.mjs'
|
|
21
21
|
import MdToc from "../sfc/md-toc.vue";
|
|
22
|
-
import Constants from "Constants";
|
|
23
22
|
import {substrAfterFirstSlash} from "JsUtils";
|
|
24
23
|
|
|
25
24
|
const route = useRoute()
|
|
@@ -71,7 +70,7 @@ const local = reactive({
|
|
|
71
70
|
markdownText: "",
|
|
72
71
|
snapshot: "",
|
|
73
72
|
showScrollToTop: false,
|
|
74
|
-
isDev:
|
|
73
|
+
isDev: storeMain.config.isDev,
|
|
75
74
|
});
|
|
76
75
|
|
|
77
76
|
|
|
@@ -6,10 +6,9 @@
|
|
|
6
6
|
// IMPORTS
|
|
7
7
|
//________________________________________________________________________________
|
|
8
8
|
import {ref, markRaw, reactive, watch, onMounted, computed} from 'vue'
|
|
9
|
-
import {store as storeMain, api as
|
|
9
|
+
import {store as storeMain, api as apiMain} from 'GlobalStore'
|
|
10
10
|
import {getLogger} from "Logging";
|
|
11
11
|
import ClientStorage2 from "core/ClientStorage2.mjs"
|
|
12
|
-
import Constants from 'Constants'
|
|
13
12
|
const storage = new ClientStorage2("auth", "default")
|
|
14
13
|
|
|
15
14
|
// ________________________________________________________________________________
|
|
@@ -40,13 +39,13 @@ async function init() {
|
|
|
40
39
|
return
|
|
41
40
|
}
|
|
42
41
|
const authEntity = await storage.build("authEntity", {
|
|
43
|
-
hostname:
|
|
44
|
-
port: parseInt(
|
|
45
|
-
protocol:
|
|
42
|
+
hostname: storeMain.config.HOSTNAME,
|
|
43
|
+
port: parseInt(storeMain.config.PORT) + 1,
|
|
44
|
+
protocol: storeMain.config.PROTOCOL,
|
|
46
45
|
endpoint: "socket",
|
|
47
|
-
username:
|
|
48
|
-
password:
|
|
49
|
-
isSecure:
|
|
46
|
+
username: storeMain.config.defaultUsername,
|
|
47
|
+
password: storeMain.config.defaultPassword,
|
|
48
|
+
isSecure: storeMain.config.IS_SECURE,
|
|
50
49
|
}, "OBJECT")
|
|
51
50
|
storage.storageCreate(authEntity)
|
|
52
51
|
|
|
@@ -3,7 +3,6 @@ import { ref, reactive, watch, onMounted, computed } from 'vue'
|
|
|
3
3
|
|
|
4
4
|
import { actions, state, connStateString, url, isAuthenticated, tryCallLoading} from "WsInterface";
|
|
5
5
|
|
|
6
|
-
import Constants from 'Constants'
|
|
7
6
|
import {getLogger} from "Logging";
|
|
8
7
|
import {store as storeSession} from "Session";
|
|
9
8
|
|
|
@@ -24,7 +23,7 @@ const backoffMsMax = 20000;
|
|
|
24
23
|
|
|
25
24
|
const local = reactive({
|
|
26
25
|
isLoading: false,
|
|
27
|
-
isDev:
|
|
26
|
+
isDev: false,
|
|
28
27
|
|
|
29
28
|
retries: 0,
|
|
30
29
|
retryEnable: true,
|
package/index-cdn.html
CHANGED
|
@@ -5,32 +5,32 @@
|
|
|
5
5
|
<meta charset="utf-8">
|
|
6
6
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
7
7
|
<title>C0ckp1t</title>
|
|
8
|
-
<link rel="icon" href="
|
|
9
|
-
<link rel="icon" href="
|
|
10
|
-
<link rel="icon" href="
|
|
8
|
+
<link rel="icon" href="https://cdn.jsdelivr.net/npm/c0ckp1t@1.0.0/favicon-32x32.png" sizes="32x32" type="image/png">
|
|
9
|
+
<link rel="icon" href="https://cdn.jsdelivr.net/npm/c0ckp1t@1.0.0/favicon-64x64.png" sizes="64x64" type="image/png">
|
|
10
|
+
<link rel="icon" href="https://cdn.jsdelivr.net/npm/c0ckp1t@1.0.0/favicon-192x192.png" sizes="192x192" type="image/png">
|
|
11
11
|
|
|
12
|
-
<link href="
|
|
13
|
-
<link href="
|
|
14
|
-
<link href="
|
|
15
|
-
<link href="
|
|
16
|
-
<link rel="stylesheet" href="
|
|
17
|
-
<link href="
|
|
12
|
+
<link href="https://cdn.jsdelivr.net/npm/c0ckp1t@1.0.0/css/bootstrap.min.css" type="text/css" rel="stylesheet">
|
|
13
|
+
<link href="https://cdn.jsdelivr.net/npm/c0ckp1t@1.0.0/css/fontawesome/solid.min.css" rel="stylesheet">
|
|
14
|
+
<link href="https://cdn.jsdelivr.net/npm/c0ckp1t@1.0.0/css/fontawesome/fontawesome.min.css" rel="stylesheet">
|
|
15
|
+
<link href="https://cdn.jsdelivr.net/npm/c0ckp1t@1.0.0/js_ext/highlight/stackoverflow-dark.min.css" rel="stylesheet">
|
|
16
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/c0ckp1t@1.0.0/js_ext/markdown/katex.min.css">
|
|
17
|
+
<link href="https://cdn.jsdelivr.net/npm/c0ckp1t@1.0.0/style.css" type="text/css" rel="stylesheet">
|
|
18
18
|
|
|
19
19
|
<script type="importmap">
|
|
20
20
|
{
|
|
21
21
|
"imports": {
|
|
22
|
-
"Constants": "
|
|
23
|
-
"Logging": "
|
|
24
|
-
"JsUtils": "
|
|
25
|
-
"GlobalStore": "
|
|
26
|
-
"NotifyUtils": "
|
|
27
|
-
"WsUtils": "
|
|
28
|
-
"IslandDefault": "
|
|
29
|
-
|
|
30
|
-
"vue3-sfc-loader": "
|
|
31
|
-
"vue": "
|
|
32
|
-
"vue-router": "
|
|
33
|
-
"idb-keyval": "
|
|
22
|
+
"Constants": "/Constants.mjs",
|
|
23
|
+
"Logging": "https://cdn.jsdelivr.net/npm/c0ckp1t@1.0.0/core/Logging.mjs",
|
|
24
|
+
"JsUtils": "https://cdn.jsdelivr.net/npm/c0ckp1t@1.0.0/core/JsUtils.mjs",
|
|
25
|
+
"GlobalStore": "https://cdn.jsdelivr.net/npm/c0ckp1t@1.0.0/core/GlobalStore.mjs",
|
|
26
|
+
"NotifyUtils": "https://cdn.jsdelivr.net/npm/c0ckp1t@1.0.0/core/notify/NotifyUtils.mjs",
|
|
27
|
+
"WsUtils": "https://cdn.jsdelivr.net/npm/c0ckp1t@1.0.0/core/WsUtils.mjs",
|
|
28
|
+
"IslandDefault": "https://cdn.jsdelivr.net/npm/c0ckp1t@1.0.0/core/IslandDefault.mjs",
|
|
29
|
+
|
|
30
|
+
"vue3-sfc-loader": "https://cdn.jsdelivr.net/npm/c0ckp1t@1.0.0/js_ext/vue3-sfc-loader.esm.js",
|
|
31
|
+
"vue": "https://cdn.jsdelivr.net/npm/c0ckp1t@1.0.0/js_ext/vue.esm-browser.prod.min.js",
|
|
32
|
+
"vue-router": "https://cdn.jsdelivr.net/npm/c0ckp1t@1.0.0/js_ext/vue-router.esm-browser.prod.js",
|
|
33
|
+
"idb-keyval": "https://cdn.jsdelivr.net/npm/c0ckp1t@1.0.0/js_ext/idb-keyval-6.2.2.mjs"
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
</script>
|
|
@@ -50,17 +50,14 @@ apiMain.init("app-default", Constants)
|
|
|
50
50
|
</script>
|
|
51
51
|
|
|
52
52
|
<!-- =================== SCRIPTS =================== -->
|
|
53
|
-
<script src="
|
|
54
|
-
<script src="
|
|
55
|
-
|
|
56
|
-
<script src="
|
|
57
|
-
|
|
58
|
-
<script src="
|
|
59
|
-
<script src="
|
|
60
|
-
<script src="
|
|
61
|
-
<script src="
|
|
62
|
-
|
|
63
|
-
<script src="./js_ext/rxjs.umd.min.js"></script>
|
|
64
|
-
<script src="./js_ext/moment.min.js"></script>
|
|
65
|
-
<script src="./js_ext/ace-editor/ace.js" type="text/javascript" charset="utf-8"></script>
|
|
53
|
+
<script src="https://cdn.jsdelivr.net/npm/c0ckp1t@1.0.0/js_ext/loglevel.min.js"></script>
|
|
54
|
+
<script src="https://cdn.jsdelivr.net/npm/c0ckp1t@1.0.0/js_ext/loglevel-plugin-prefix.min.js"></script>
|
|
55
|
+
<script src="https://cdn.jsdelivr.net/npm/c0ckp1t@1.0.0/js_ext/bootstrap.bundle.min.js"></script>
|
|
56
|
+
<script src="https://cdn.jsdelivr.net/npm/c0ckp1t@1.0.0/js_ext/highlight/highlight.min.js"></script>
|
|
57
|
+
<script src="https://cdn.jsdelivr.net/npm/c0ckp1t@1.0.0/js_ext/markdown/katex.min.js"></script>
|
|
58
|
+
<script src="https://cdn.jsdelivr.net/npm/c0ckp1t@1.0.0/js_ext/markdown/markdown-it.min.js"></script>
|
|
59
|
+
<script src="https://cdn.jsdelivr.net/npm/c0ckp1t@1.0.0/js_ext/markdown/markdownItAnchor.umd.js"></script>
|
|
60
|
+
<script src="https://cdn.jsdelivr.net/npm/c0ckp1t@1.0.0/js_ext/rxjs.umd.min.js"></script>
|
|
61
|
+
<script src="https://cdn.jsdelivr.net/npm/c0ckp1t@1.0.0/js_ext/moment.min.js"></script>
|
|
62
|
+
<script src="https://cdn.jsdelivr.net/npm/c0ckp1t@1.0.0/js_ext/ace-editor/ace.js" type="text/javascript" charset="utf-8"></script>
|
|
66
63
|
</html>
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* (c) 2024 Eduardo San Martin Morote
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
6
|
-
import{inject,onUnmounted,onDeactivated,onActivated,computed,unref,defineComponent,reactive,h,provide,ref,watch,shallowRef,shallowReactive,nextTick}from"../js_ext/vue.js";const isBrowser="undefined"!=typeof document;function isRouteComponent(e){return"object"==typeof e||"displayName"in e||"props"in e||"__vccOpts"in e}function isESModule(e){return e.__esModule||"Module"===e[Symbol.toStringTag]||e.default&&isRouteComponent(e.default)}const assign=Object.assign;function applyToParams(e,t){const n={};for(const o in t){const r=t[o];n[o]=isArray(r)?r.map(e):e(r)}return n}const noop=()=>{},isArray=Array.isArray,HASH_RE=/#/g,AMPERSAND_RE=/&/g,SLASH_RE=/\//g,EQUAL_RE=/=/g,IM_RE=/\?/g,PLUS_RE=/\+/g,ENC_BRACKET_OPEN_RE=/%5B/g,ENC_BRACKET_CLOSE_RE=/%5D/g,ENC_CARET_RE=/%5E/g,ENC_BACKTICK_RE=/%60/g,ENC_CURLY_OPEN_RE=/%7B/g,ENC_PIPE_RE=/%7C/g,ENC_CURLY_CLOSE_RE=/%7D/g,ENC_SPACE_RE=/%20/g;function commonEncode(e){return encodeURI(""+e).replace(ENC_PIPE_RE,"|").replace(ENC_BRACKET_OPEN_RE,"[").replace(ENC_BRACKET_CLOSE_RE,"]")}function encodeHash(e){return commonEncode(e).replace(ENC_CURLY_OPEN_RE,"{").replace(ENC_CURLY_CLOSE_RE,"}").replace(ENC_CARET_RE,"^")}function encodeQueryValue(e){return commonEncode(e).replace(PLUS_RE,"%2B").replace(ENC_SPACE_RE,"+").replace(HASH_RE,"%23").replace(AMPERSAND_RE,"%26").replace(ENC_BACKTICK_RE,"`").replace(ENC_CURLY_OPEN_RE,"{").replace(ENC_CURLY_CLOSE_RE,"}").replace(ENC_CARET_RE,"^")}function encodeQueryKey(e){return encodeQueryValue(e).replace(EQUAL_RE,"%3D")}function encodePath(e){return commonEncode(e).replace(HASH_RE,"%23").replace(IM_RE,"%3F")}function encodeParam(e){return null==e?"":encodePath(e).replace(SLASH_RE,"%2F")}function decode(e){try{return decodeURIComponent(""+e)}catch(e){}return""+e}const TRAILING_SLASH_RE=/\/$/,removeTrailingSlash=e=>e.replace(TRAILING_SLASH_RE,"");function parseURL(e,t,n="/"){let o,r={},a="",i="";const s=t.indexOf("#");let c=t.indexOf("?");return s<c&&s>=0&&(c=-1),c>-1&&(o=t.slice(0,c),a=t.slice(c+1,s>-1?s:t.length),r=e(a)),s>-1&&(o=o||t.slice(0,s),i=t.slice(s,t.length)),o=resolveRelativePath(null!=o?o:t,n),{fullPath:o+(a&&"?")+a+i,path:o,query:r,hash:decode(i)}}function stringifyURL(e,t){const n=t.query?e(t.query):"";return t.path+(n&&"?")+n+(t.hash||"")}function stripBase(e,t){return t&&e.toLowerCase().startsWith(t.toLowerCase())?e.slice(t.length)||"/":e}function isSameRouteLocation(e,t,n){const o=t.matched.length-1,r=n.matched.length-1;return o>-1&&o===r&&isSameRouteRecord(t.matched[o],n.matched[r])&&isSameRouteLocationParams(t.params,n.params)&&e(t.query)===e(n.query)&&t.hash===n.hash}function isSameRouteRecord(e,t){return(e.aliasOf||e)===(t.aliasOf||t)}function isSameRouteLocationParams(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(!isSameRouteLocationParamsValue(e[n],t[n]))return!1;return!0}function isSameRouteLocationParamsValue(e,t){return isArray(e)?isEquivalentArray(e,t):isArray(t)?isEquivalentArray(t,e):e===t}function isEquivalentArray(e,t){return isArray(t)?e.length===t.length&&e.every(((e,n)=>e===t[n])):1===e.length&&e[0]===t}function resolveRelativePath(e,t){if(e.startsWith("/"))return e;if(!e)return t;const n=t.split("/"),o=e.split("/"),r=o[o.length-1];".."!==r&&"."!==r||o.push("");let a,i,s=n.length-1;for(a=0;a<o.length;a++)if(i=o[a],"."!==i){if(".."!==i)break;s>1&&s--}return n.slice(0,s).join("/")+"/"+o.slice(a).join("/")}const START_LOCATION_NORMALIZED={path:"/",name:void 0,params:{},query:{},hash:"",fullPath:"/",matched:[],meta:{},redirectedFrom:void 0};var NavigationType,NavigationDirection;!function(e){e.pop="pop",e.push="push"}(NavigationType||(NavigationType={})),function(e){e.back="back",e.forward="forward",e.unknown=""}(NavigationDirection||(NavigationDirection={}));const START="";function normalizeBase(e){if(!e)if(isBrowser){const t=document.querySelector("base");e=(e=t&&t.getAttribute("href")||"/").replace(/^\w+:\/\/[^\/]+/,"")}else e="/";return"/"!==e[0]&&"#"!==e[0]&&(e="/"+e),removeTrailingSlash(e)}const BEFORE_HASH_RE=/^[^#]+#/;function createHref(e,t){return e.replace(BEFORE_HASH_RE,"#")+t}function getElementPosition(e,t){const n=document.documentElement.getBoundingClientRect(),o=e.getBoundingClientRect();return{behavior:t.behavior,left:o.left-n.left-(t.left||0),top:o.top-n.top-(t.top||0)}}const computeScrollPosition=()=>({left:window.scrollX,top:window.scrollY});function scrollToPosition(e){let t;if("el"in e){const n=e.el,o="string"==typeof n&&n.startsWith("#"),r="string"==typeof n?o?document.getElementById(n.slice(1)):document.querySelector(n):n;if(!r)return;t=getElementPosition(r,e)}else t=e;"scrollBehavior"in document.documentElement.style?window.scrollTo(t):window.scrollTo(null!=t.left?t.left:window.scrollX,null!=t.top?t.top:window.scrollY)}function getScrollKey(e,t){return(history.state?history.state.position-t:-1)+e}const scrollPositions=new Map;function saveScrollPosition(e,t){scrollPositions.set(e,t)}function getSavedScrollPosition(e){const t=scrollPositions.get(e);return scrollPositions.delete(e),t}let createBaseLocation=()=>location.protocol+"//"+location.host;function createCurrentLocation(e,t){const{pathname:n,search:o,hash:r}=t,a=e.indexOf("#");if(a>-1){let t=r.includes(e.slice(a))?e.slice(a).length:1,n=r.slice(t);return"/"!==n[0]&&(n="/"+n),stripBase(n,"")}return stripBase(n,e)+o+r}function useHistoryListeners(e,t,n,o){let r=[],a=[],i=null;const s=({state:a})=>{const s=createCurrentLocation(e,location),c=n.value,u=t.value;let l=0;if(a){if(n.value=s,t.value=a,i&&i===c)return void(i=null);l=u?a.position-u.position:0}else o(s);r.forEach((e=>{e(n.value,c,{delta:l,type:NavigationType.pop,direction:l?l>0?NavigationDirection.forward:NavigationDirection.back:NavigationDirection.unknown})}))};function c(){const{history:e}=window;e.state&&e.replaceState(assign({},e.state,{scroll:computeScrollPosition()}),"")}return window.addEventListener("popstate",s),window.addEventListener("beforeunload",c,{passive:!0}),{pauseListeners:function(){i=n.value},listen:function(e){r.push(e);const t=()=>{const t=r.indexOf(e);t>-1&&r.splice(t,1)};return a.push(t),t},destroy:function(){for(const e of a)e();a=[],window.removeEventListener("popstate",s),window.removeEventListener("beforeunload",c)}}}function buildState(e,t,n,o=!1,r=!1){return{back:e,current:t,forward:n,replaced:o,position:window.history.length,scroll:r?computeScrollPosition():null}}function useHistoryStateNavigation(e){const{history:t,location:n}=window,o={value:createCurrentLocation(e,n)},r={value:t.state};function a(o,a,i){const s=e.indexOf("#"),c=s>-1?(n.host&&document.querySelector("base")?e:e.slice(s))+o:createBaseLocation()+e+o;try{t[i?"replaceState":"pushState"](a,"",c),r.value=a}catch(e){console.error(e),n[i?"replace":"assign"](c)}}return r.value||a(o.value,{back:null,current:o.value,forward:null,position:t.length-1,replaced:!0,scroll:null},!0),{location:o,state:r,push:function(e,n){const i=assign({},r.value,t.state,{forward:e,scroll:computeScrollPosition()});a(i.current,i,!0),a(e,assign({},buildState(o.value,e,null),{position:i.position+1},n),!1),o.value=e},replace:function(e,n){a(e,assign({},t.state,buildState(r.value.back,e,r.value.forward,!0),n,{position:r.value.position}),!0),o.value=e}}}function createWebHistory(e){const t=useHistoryStateNavigation(e=normalizeBase(e)),n=useHistoryListeners(e,t.state,t.location,t.replace);const o=assign({location:"",base:e,go:function(e,t=!0){t||n.pauseListeners(),history.go(e)},createHref:createHref.bind(null,e)},t,n);return Object.defineProperty(o,"location",{enumerable:!0,get:()=>t.location.value}),Object.defineProperty(o,"state",{enumerable:!0,get:()=>t.state.value}),o}function createMemoryHistory(e=""){let t=[],n=[""],o=0;function r(e){o++,o!==n.length&&n.splice(o),n.push(e)}const a={location:"",state:{},base:e=normalizeBase(e),createHref:createHref.bind(null,e),replace(e){n.splice(o--,1),r(e)},push(e,t){r(e)},listen:e=>(t.push(e),()=>{const n=t.indexOf(e);n>-1&&t.splice(n,1)}),destroy(){t=[],n=[""],o=0},go(e,r=!0){const a=this.location,i=e<0?NavigationDirection.back:NavigationDirection.forward;o=Math.max(0,Math.min(o+e,n.length-1)),r&&function(e,n,{direction:o,delta:r}){const a={direction:o,delta:r,type:NavigationType.pop};for(const o of t)o(e,n,a)}(this.location,a,{direction:i,delta:e})}};return Object.defineProperty(a,"location",{enumerable:!0,get:()=>n[o]}),a}function createWebHashHistory(e){return(e=location.host?e||location.pathname+location.search:"").includes("#")||(e+="#"),createWebHistory(e)}function isRouteLocation(e){return"string"==typeof e||e&&"object"==typeof e}function isRouteName(e){return"string"==typeof e||"symbol"==typeof e}const NavigationFailureSymbol=Symbol("");var NavigationFailureType;function createRouterError(e,t){return assign(new Error,{type:e,[NavigationFailureSymbol]:!0},t)}function isNavigationFailure(e,t){return e instanceof Error&&NavigationFailureSymbol in e&&(null==t||!!(e.type&t))}!function(e){e[e.aborted=4]="aborted",e[e.cancelled=8]="cancelled",e[e.duplicated=16]="duplicated"}(NavigationFailureType||(NavigationFailureType={}));const BASE_PARAM_PATTERN="[^/]+?",BASE_PATH_PARSER_OPTIONS={sensitive:!1,strict:!1,start:!0,end:!0},REGEX_CHARS_RE=/[.+*?^${}()[\]/\\]/g;function tokensToParser(e,t){const n=assign({},BASE_PATH_PARSER_OPTIONS,t),o=[];let r=n.start?"^":"";const a=[];for(const t of e){const e=t.length?[]:[90];n.strict&&!t.length&&(r+="/");for(let o=0;o<t.length;o++){const i=t[o];let s=40+(n.sensitive?.25:0);if(0===i.type)o||(r+="/"),r+=i.value.replace(REGEX_CHARS_RE,"\\$&"),s+=40;else if(1===i.type){const{value:e,repeatable:n,optional:c,regexp:u}=i;a.push({name:e,repeatable:n,optional:c});const l=u||BASE_PARAM_PATTERN;if(l!==BASE_PARAM_PATTERN){s+=10;try{new RegExp(`(${l})`)}catch(t){throw new Error(`Invalid custom RegExp for param "${e}" (${l}): `+t.message)}}let f=n?`((?:${l})(?:/(?:${l}))*)`:`(${l})`;o||(f=c&&t.length<2?`(?:/${f})`:"/"+f),c&&(f+="?"),r+=f,s+=20,c&&(s+=-8),n&&(s+=-20),".*"===l&&(s+=-50)}e.push(s)}o.push(e)}if(n.strict&&n.end){const e=o.length-1;o[e][o[e].length-1]+=.7000000000000001}n.strict||(r+="/?"),n.end?r+="$":n.strict&&!r.endsWith("/")&&(r+="(?:/|$)");const i=new RegExp(r,n.sensitive?"":"i");return{re:i,score:o,keys:a,parse:function(e){const t=e.match(i),n={};if(!t)return null;for(let e=1;e<t.length;e++){const o=t[e]||"",r=a[e-1];n[r.name]=o&&r.repeatable?o.split("/"):o}return n},stringify:function(t){let n="",o=!1;for(const r of e){o&&n.endsWith("/")||(n+="/"),o=!1;for(const e of r)if(0===e.type)n+=e.value;else if(1===e.type){const{value:a,repeatable:i,optional:s}=e,c=a in t?t[a]:"";if(isArray(c)&&!i)throw new Error(`Provided param "${a}" is an array but it is not repeatable (* or + modifiers)`);const u=isArray(c)?c.join("/"):c;if(!u){if(!s)throw new Error(`Missing required param "${a}"`);r.length<2&&(n.endsWith("/")?n=n.slice(0,-1):o=!0)}n+=u}}return n||"/"}}}function compareScoreArray(e,t){let n=0;for(;n<e.length&&n<t.length;){const o=t[n]-e[n];if(o)return o;n++}return e.length<t.length?1===e.length&&80===e[0]?-1:1:e.length>t.length?1===t.length&&80===t[0]?1:-1:0}function comparePathParserScore(e,t){let n=0;const o=e.score,r=t.score;for(;n<o.length&&n<r.length;){const e=compareScoreArray(o[n],r[n]);if(e)return e;n++}if(1===Math.abs(r.length-o.length)){if(isLastScoreNegative(o))return 1;if(isLastScoreNegative(r))return-1}return r.length-o.length}function isLastScoreNegative(e){const t=e[e.length-1];return e.length>0&&t[t.length-1]<0}const ROOT_TOKEN={type:0,value:""},VALID_PARAM_RE=/[a-zA-Z0-9_]/;function tokenizePath(e){if(!e)return[[]];if("/"===e)return[[ROOT_TOKEN]];if(!e.startsWith("/"))throw new Error(`Invalid path "${e}"`);function t(e){throw new Error(`ERR (${n})/"${u}": ${e}`)}let n=0,o=n;const r=[];let a;function i(){a&&r.push(a),a=[]}let s,c=0,u="",l="";function f(){u&&(0===n?a.push({type:0,value:u}):1===n||2===n||3===n?(a.length>1&&("*"===s||"+"===s)&&t(`A repeatable param (${u}) must be alone in its segment. eg: '/:ids+.`),a.push({type:1,value:u,regexp:l,repeatable:"*"===s||"+"===s,optional:"*"===s||"?"===s})):t("Invalid state to consume buffer"),u="")}function p(){u+=s}for(;c<e.length;)if(s=e[c++],"\\"!==s||2===n)switch(n){case 0:"/"===s?(u&&f(),i()):":"===s?(f(),n=1):p();break;case 4:p(),n=o;break;case 1:"("===s?n=2:VALID_PARAM_RE.test(s)?p():(f(),n=0,"*"!==s&&"?"!==s&&"+"!==s&&c--);break;case 2:")"===s?"\\"==l[l.length-1]?l=l.slice(0,-1)+s:n=3:l+=s;break;case 3:f(),n=0,"*"!==s&&"?"!==s&&"+"!==s&&c--,l="";break;default:t("Unknown state")}else o=n,n=4;return 2===n&&t(`Unfinished custom RegExp for param "${u}"`),f(),i(),r}function createRouteRecordMatcher(e,t,n){const o=tokensToParser(tokenizePath(e.path),n),r=assign(o,{record:e,parent:t,children:[],alias:[]});return t&&!r.record.aliasOf==!t.record.aliasOf&&t.children.push(r),r}function createRouterMatcher(e,t){const n=[],o=new Map;function r(e,n,o){const s=!o,c=normalizeRouteRecord(e);c.aliasOf=o&&o.record;const u=mergeOptions(t,e),l=[c];if("alias"in e){const t="string"==typeof e.alias?[e.alias]:e.alias;for(const e of t)l.push(normalizeRouteRecord(assign({},c,{components:o?o.record.components:c.components,path:e,aliasOf:o?o.record:c})))}let f,p;for(const t of l){const{path:l}=t;if(n&&"/"!==l[0]){const e=n.record.path;t.path=n.record.path+(l&&("/"===e[e.length-1]?"":"/")+l)}if(f=createRouteRecordMatcher(t,n,u),o?o.alias.push(f):(p=p||f,p!==f&&p.alias.push(f),s&&e.name&&!isAliasRecord(f)&&a(e.name)),isMatchable(f)&&i(f),c.children){const e=c.children;for(let t=0;t<e.length;t++)r(e[t],f,o&&o.children[t])}o=o||f}return p?()=>{a(p)}:noop}function a(e){if(isRouteName(e)){const t=o.get(e);t&&(o.delete(e),n.splice(n.indexOf(t),1),t.children.forEach(a),t.alias.forEach(a))}else{const t=n.indexOf(e);t>-1&&(n.splice(t,1),e.record.name&&o.delete(e.record.name),e.children.forEach(a),e.alias.forEach(a))}}function i(e){const t=findInsertionIndex(e,n);n.splice(t,0,e),e.record.name&&!isAliasRecord(e)&&o.set(e.record.name,e)}return t=mergeOptions({strict:!1,end:!0,sensitive:!1},t),e.forEach((e=>r(e))),{addRoute:r,resolve:function(e,t){let r,a,i,s={};if("name"in e&&e.name){if(r=o.get(e.name),!r)throw createRouterError(1,{location:e});i=r.record.name,s=assign(paramsFromLocation(t.params,r.keys.filter((e=>!e.optional)).concat(r.parent?r.parent.keys.filter((e=>e.optional)):[]).map((e=>e.name))),e.params&¶msFromLocation(e.params,r.keys.map((e=>e.name)))),a=r.stringify(s)}else if(null!=e.path)a=e.path,r=n.find((e=>e.re.test(a))),r&&(s=r.parse(a),i=r.record.name);else{if(r=t.name?o.get(t.name):n.find((e=>e.re.test(t.path))),!r)throw createRouterError(1,{location:e,currentLocation:t});i=r.record.name,s=assign({},t.params,e.params),a=r.stringify(s)}const c=[];let u=r;for(;u;)c.unshift(u.record),u=u.parent;return{name:i,path:a,params:s,matched:c,meta:mergeMetaFields(c)}},removeRoute:a,clearRoutes:function(){n.length=0,o.clear()},getRoutes:function(){return n},getRecordMatcher:function(e){return o.get(e)}}}function paramsFromLocation(e,t){const n={};for(const o of t)o in e&&(n[o]=e[o]);return n}function normalizeRouteRecord(e){const t={path:e.path,redirect:e.redirect,name:e.name,meta:e.meta||{},aliasOf:e.aliasOf,beforeEnter:e.beforeEnter,props:normalizeRecordProps(e),children:e.children||[],instances:{},leaveGuards:new Set,updateGuards:new Set,enterCallbacks:{},components:"components"in e?e.components||null:e.component&&{default:e.component}};return Object.defineProperty(t,"mods",{value:{}}),t}function normalizeRecordProps(e){const t={},n=e.props||!1;if("component"in e)t.default=n;else for(const o in e.components)t[o]="object"==typeof n?n[o]:n;return t}function isAliasRecord(e){for(;e;){if(e.record.aliasOf)return!0;e=e.parent}return!1}function mergeMetaFields(e){return e.reduce(((e,t)=>assign(e,t.meta)),{})}function mergeOptions(e,t){const n={};for(const o in e)n[o]=o in t?t[o]:e[o];return n}function findInsertionIndex(e,t){let n=0,o=t.length;for(;n!==o;){const r=n+o>>1;comparePathParserScore(e,t[r])<0?o=r:n=r+1}const r=getInsertionAncestor(e);return r&&(o=t.lastIndexOf(r,o-1)),o}function getInsertionAncestor(e){let t=e;for(;t=t.parent;)if(isMatchable(t)&&0===comparePathParserScore(e,t))return t}function isMatchable({record:e}){return!!(e.name||e.components&&Object.keys(e.components).length||e.redirect)}function parseQuery(e){const t={};if(""===e||"?"===e)return t;const n=("?"===e[0]?e.slice(1):e).split("&");for(let e=0;e<n.length;++e){const o=n[e].replace(PLUS_RE," "),r=o.indexOf("="),a=decode(r<0?o:o.slice(0,r)),i=r<0?null:decode(o.slice(r+1));if(a in t){let e=t[a];isArray(e)||(e=t[a]=[e]),e.push(i)}else t[a]=i}return t}function stringifyQuery(e){let t="";for(let n in e){const o=e[n];if(n=encodeQueryKey(n),null==o){void 0!==o&&(t+=(t.length?"&":"")+n);continue}(isArray(o)?o.map((e=>e&&encodeQueryValue(e))):[o&&encodeQueryValue(o)]).forEach((e=>{void 0!==e&&(t+=(t.length?"&":"")+n,null!=e&&(t+="="+e))}))}return t}function normalizeQuery(e){const t={};for(const n in e){const o=e[n];void 0!==o&&(t[n]=isArray(o)?o.map((e=>null==e?null:""+e)):null==o?o:""+o)}return t}const matchedRouteKey=Symbol(""),viewDepthKey=Symbol(""),routerKey=Symbol(""),routeLocationKey=Symbol(""),routerViewLocationKey=Symbol("");function useCallbacks(){let e=[];return{add:function(t){return e.push(t),()=>{const n=e.indexOf(t);n>-1&&e.splice(n,1)}},list:()=>e.slice(),reset:function(){e=[]}}}function registerGuard(e,t,n){const o=()=>{e[t].delete(n)};onUnmounted(o),onDeactivated(o),onActivated((()=>{e[t].add(n)})),e[t].add(n)}function onBeforeRouteLeave(e){const t=inject(matchedRouteKey,{}).value;t&®isterGuard(t,"leaveGuards",e)}function onBeforeRouteUpdate(e){const t=inject(matchedRouteKey,{}).value;t&®isterGuard(t,"updateGuards",e)}function guardToPromiseFn(e,t,n,o,r,a=e=>e()){const i=o&&(o.enterCallbacks[r]=o.enterCallbacks[r]||[]);return()=>new Promise(((s,c)=>{const u=e=>{!1===e?c(createRouterError(4,{from:n,to:t})):e instanceof Error?c(e):isRouteLocation(e)?c(createRouterError(2,{from:t,to:e})):(i&&o.enterCallbacks[r]===i&&"function"==typeof e&&i.push(e),s())},l=a((()=>e.call(o&&o.instances[r],t,n,u)));let f=Promise.resolve(l);e.length<3&&(f=f.then(u)),f.catch((e=>c(e)))}))}function extractComponentsGuards(e,t,n,o,r=e=>e()){const a=[];for(const i of e)for(const e in i.components){let s=i.components[e];if("beforeRouteEnter"===t||i.instances[e])if(isRouteComponent(s)){const c=(s.__vccOpts||s)[t];c&&a.push(guardToPromiseFn(c,n,o,i,e,r))}else{let c=s();a.push((()=>c.then((a=>{if(!a)throw new Error(`Couldn't resolve component "${e}" at "${i.path}"`);const s=isESModule(a)?a.default:a;i.mods[e]=a,i.components[e]=s;const c=(s.__vccOpts||s)[t];return c&&guardToPromiseFn(c,n,o,i,e,r)()}))))}}return a}function loadRouteLocation(e){return e.matched.every((e=>e.redirect))?Promise.reject(new Error("Cannot load a route that redirects.")):Promise.all(e.matched.map((e=>e.components&&Promise.all(Object.keys(e.components).reduce(((t,n)=>{const o=e.components[n];return"function"!=typeof o||"displayName"in o||t.push(o().then((t=>{if(!t)return Promise.reject(new Error(`Couldn't resolve component "${n}" at "${e.path}". Ensure you passed a function that returns a promise.`));const o=isESModule(t)?t.default:t;e.mods[n]=t,e.components[n]=o}))),t}),[]))))).then((()=>e))}function useLink(e){const t=inject(routerKey),n=inject(routeLocationKey),o=computed((()=>{const n=unref(e.to);return t.resolve(n)})),r=computed((()=>{const{matched:e}=o.value,{length:t}=e,r=e[t-1],a=n.matched;if(!r||!a.length)return-1;const i=a.findIndex(isSameRouteRecord.bind(null,r));if(i>-1)return i;const s=getOriginalPath(e[t-2]);return t>1&&getOriginalPath(r)===s&&a[a.length-1].path!==s?a.findIndex(isSameRouteRecord.bind(null,e[t-2])):i})),a=computed((()=>r.value>-1&&includesParams(n.params,o.value.params))),i=computed((()=>r.value>-1&&r.value===n.matched.length-1&&isSameRouteLocationParams(n.params,o.value.params)));return{route:o,href:computed((()=>o.value.href)),isActive:a,isExactActive:i,navigate:function(n={}){if(guardEvent(n)){const n=t[unref(e.replace)?"replace":"push"](unref(e.to)).catch(noop);return e.viewTransition&&"undefined"!=typeof document&&"startViewTransition"in document&&document.startViewTransition((()=>n)),n}return Promise.resolve()}}}function preferSingleVNode(e){return 1===e.length?e[0]:e}const RouterLinkImpl=defineComponent({name:"RouterLink",compatConfig:{MODE:3},props:{to:{type:[String,Object],required:!0},replace:Boolean,activeClass:String,exactActiveClass:String,custom:Boolean,ariaCurrentValue:{type:String,default:"page"}},useLink:useLink,setup(e,{slots:t}){const n=reactive(useLink(e)),{options:o}=inject(routerKey),r=computed((()=>({[getLinkClass(e.activeClass,o.linkActiveClass,"router-link-active")]:n.isActive,[getLinkClass(e.exactActiveClass,o.linkExactActiveClass,"router-link-exact-active")]:n.isExactActive})));return()=>{const o=t.default&&preferSingleVNode(t.default(n));return e.custom?o:h("a",{"aria-current":n.isExactActive?e.ariaCurrentValue:null,href:n.href,onClick:n.navigate,class:r.value},o)}}}),RouterLink=RouterLinkImpl;function guardEvent(e){if(!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey||e.defaultPrevented||void 0!==e.button&&0!==e.button)){if(e.currentTarget&&e.currentTarget.getAttribute){const t=e.currentTarget.getAttribute("target");if(/\b_blank\b/i.test(t))return}return e.preventDefault&&e.preventDefault(),!0}}function includesParams(e,t){for(const n in t){const o=t[n],r=e[n];if("string"==typeof o){if(o!==r)return!1}else if(!isArray(r)||r.length!==o.length||o.some(((e,t)=>e!==r[t])))return!1}return!0}function getOriginalPath(e){return e?e.aliasOf?e.aliasOf.path:e.path:""}const getLinkClass=(e,t,n)=>null!=e?e:null!=t?t:n,RouterViewImpl=defineComponent({name:"RouterView",inheritAttrs:!1,props:{name:{type:String,default:"default"},route:Object},compatConfig:{MODE:3},setup(e,{attrs:t,slots:n}){const o=inject(routerViewLocationKey),r=computed((()=>e.route||o.value)),a=inject(viewDepthKey,0),i=computed((()=>{let e=unref(a);const{matched:t}=r.value;let n;for(;(n=t[e])&&!n.components;)e++;return e})),s=computed((()=>r.value.matched[i.value]));provide(viewDepthKey,computed((()=>i.value+1))),provide(matchedRouteKey,s),provide(routerViewLocationKey,r);const c=ref();return watch((()=>[c.value,s.value,e.name]),(([e,t,n],[o,r,a])=>{t&&(t.instances[n]=e,r&&r!==t&&e&&e===o&&(t.leaveGuards.size||(t.leaveGuards=r.leaveGuards),t.updateGuards.size||(t.updateGuards=r.updateGuards))),!e||!t||r&&isSameRouteRecord(t,r)&&o||(t.enterCallbacks[n]||[]).forEach((t=>t(e)))}),{flush:"post"}),()=>{const o=r.value,a=e.name,i=s.value,u=i&&i.components[a];if(!u)return normalizeSlot(n.default,{Component:u,route:o});const l=i.props[a],f=l?!0===l?o.params:"function"==typeof l?l(o):l:null,p=h(u,assign({},f,t,{onVnodeUnmounted:e=>{e.component.isUnmounted&&(i.instances[a]=null)},ref:c}));return normalizeSlot(n.default,{Component:p,route:o})||p}}});function normalizeSlot(e,t){if(!e)return null;const n=e(t);return 1===n.length?n[0]:n}const RouterView=RouterViewImpl;function createRouter(e){const t=createRouterMatcher(e.routes,e),n=e.parseQuery||parseQuery,o=e.stringifyQuery||stringifyQuery,r=e.history,a=useCallbacks(),i=useCallbacks(),s=useCallbacks(),c=shallowRef(START_LOCATION_NORMALIZED);let u=START_LOCATION_NORMALIZED;isBrowser&&e.scrollBehavior&&"scrollRestoration"in history&&(history.scrollRestoration="manual");const l=applyToParams.bind(null,(e=>""+e)),f=applyToParams.bind(null,encodeParam),p=applyToParams.bind(null,decode);function d(e,a){if(a=assign({},a||c.value),"string"==typeof e){const o=parseURL(n,e,a.path),i=t.resolve({path:o.path},a),s=r.createHref(o.fullPath);return assign(o,i,{params:p(i.params),hash:decode(o.hash),redirectedFrom:void 0,href:s})}let i;if(null!=e.path)i=assign({},e,{path:parseURL(n,e.path,a.path).path});else{const t=assign({},e.params);for(const e in t)null==t[e]&&delete t[e];i=assign({},e,{params:f(t)}),a.params=f(a.params)}const s=t.resolve(i,a),u=e.hash||"";s.params=l(p(s.params));const d=stringifyURL(o,assign({},e,{hash:encodeHash(u),path:s.path})),h=r.createHref(d);return assign({fullPath:d,hash:u,query:o===stringifyQuery?normalizeQuery(e.query):e.query||{}},s,{redirectedFrom:void 0,href:h})}function h(e){return"string"==typeof e?parseURL(n,e,c.value.path):assign({},e)}function m(e,t){if(u!==e)return createRouterError(8,{from:t,to:e})}function g(e){return v(e)}function R(e){const t=e.matched[e.matched.length-1];if(t&&t.redirect){const{redirect:n}=t;let o="function"==typeof n?n(e):n;return"string"==typeof o&&(o=o.includes("?")||o.includes("#")?o=h(o):{path:o},o.params={}),assign({query:e.query,hash:e.hash,params:null!=o.path?{}:e.params},o)}}function v(e,t){const n=u=d(e),r=c.value,a=e.state,i=e.force,s=!0===e.replace,l=R(n);if(l)return v(assign(h(l),{state:"object"==typeof l?assign({},a,l.state):a,force:i,replace:s}),t||n);const f=n;let p;return f.redirectedFrom=t,!i&&isSameRouteLocation(o,r,n)&&(p=createRouterError(16,{to:f,from:r}),w(r,r,!0,!1)),(p?Promise.resolve(p):A(f,r)).catch((e=>isNavigationFailure(e)?isNavigationFailure(e,2)?e:T(e):N(e,f,r))).then((e=>{if(e){if(isNavigationFailure(e,2))return v(assign({replace:s},h(e.to),{state:"object"==typeof e.to?assign({},a,e.to.state):a,force:i}),t||f)}else e=P(f,r,!0,s,a);return S(f,r,e),e}))}function y(e,t){const n=m(e,t);return n?Promise.reject(n):Promise.resolve()}function E(e){const t=I.values().next().value;return t&&"function"==typeof t.runWithContext?t.runWithContext(e):e()}function A(e,t){let n;const[o,r,s]=extractChangingRecords(e,t);n=extractComponentsGuards(o.reverse(),"beforeRouteLeave",e,t);for(const r of o)r.leaveGuards.forEach((o=>{n.push(guardToPromiseFn(o,e,t))}));const c=y.bind(null,e,t);return n.push(c),K(n).then((()=>{n=[];for(const o of a.list())n.push(guardToPromiseFn(o,e,t));return n.push(c),K(n)})).then((()=>{n=extractComponentsGuards(r,"beforeRouteUpdate",e,t);for(const o of r)o.updateGuards.forEach((o=>{n.push(guardToPromiseFn(o,e,t))}));return n.push(c),K(n)})).then((()=>{n=[];for(const o of s)if(o.beforeEnter)if(isArray(o.beforeEnter))for(const r of o.beforeEnter)n.push(guardToPromiseFn(r,e,t));else n.push(guardToPromiseFn(o.beforeEnter,e,t));return n.push(c),K(n)})).then((()=>(e.matched.forEach((e=>e.enterCallbacks={})),n=extractComponentsGuards(s,"beforeRouteEnter",e,t,E),n.push(c),K(n)))).then((()=>{n=[];for(const o of i.list())n.push(guardToPromiseFn(o,e,t));return n.push(c),K(n)})).catch((e=>isNavigationFailure(e,8)?e:Promise.reject(e)))}function S(e,t,n){s.list().forEach((o=>E((()=>o(e,t,n)))))}function P(e,t,n,o,a){const i=m(e,t);if(i)return i;const s=t===START_LOCATION_NORMALIZED,u=isBrowser?history.state:{};n&&(o||s?r.replace(e.fullPath,assign({scroll:s&&u&&u.scroll},a)):r.push(e.fullPath,a)),c.value=e,w(e,t,n,s),T()}let _;let b,L=useCallbacks(),C=useCallbacks();function N(e,t,n){T(e);const o=C.list();return o.length?o.forEach((o=>o(e,t,n))):console.error(e),Promise.reject(e)}function T(e){return b||(b=!e,_||(_=r.listen(((e,t,n)=>{if(!M.listening)return;const o=d(e),a=R(o);if(a)return void v(assign(a,{replace:!0,force:!0}),o).catch(noop);u=o;const i=c.value;isBrowser&&saveScrollPosition(getScrollKey(i.fullPath,n.delta),computeScrollPosition()),A(o,i).catch((e=>isNavigationFailure(e,12)?e:isNavigationFailure(e,2)?(v(assign(h(e.to),{force:!0}),o).then((e=>{isNavigationFailure(e,20)&&!n.delta&&n.type===NavigationType.pop&&r.go(-1,!1)})).catch(noop),Promise.reject()):(n.delta&&r.go(-n.delta,!1),N(e,o,i)))).then((e=>{(e=e||P(o,i,!1))&&(n.delta&&!isNavigationFailure(e,8)?r.go(-n.delta,!1):n.type===NavigationType.pop&&isNavigationFailure(e,20)&&r.go(-1,!1)),S(o,i,e)})).catch(noop)}))),L.list().forEach((([t,n])=>e?n(e):t())),L.reset()),e}function w(t,n,o,r){const{scrollBehavior:a}=e;if(!isBrowser||!a)return Promise.resolve();const i=!o&&getSavedScrollPosition(getScrollKey(t.fullPath,0))||(r||!o)&&history.state&&history.state.scroll||null;return nextTick().then((()=>a(t,n,i))).then((e=>e&&scrollToPosition(e))).catch((e=>N(e,t,n)))}const O=e=>r.go(e);let k;const I=new Set,M={currentRoute:c,listening:!0,addRoute:function(e,n){let o,r;return isRouteName(e)?(o=t.getRecordMatcher(e),r=n):r=e,t.addRoute(r,o)},removeRoute:function(e){const n=t.getRecordMatcher(e);n&&t.removeRoute(n)},clearRoutes:t.clearRoutes,hasRoute:function(e){return!!t.getRecordMatcher(e)},getRoutes:function(){return t.getRoutes().map((e=>e.record))},resolve:d,options:e,push:g,replace:function(e){return g(assign(h(e),{replace:!0}))},go:O,back:()=>O(-1),forward:()=>O(1),beforeEach:a.add,beforeResolve:i.add,afterEach:s.add,onError:C.add,isReady:function(){return b&&c.value!==START_LOCATION_NORMALIZED?Promise.resolve():new Promise(((e,t)=>{L.add([e,t])}))},install(e){e.component("RouterLink",RouterLink),e.component("RouterView",RouterView),e.config.globalProperties.$router=this,Object.defineProperty(e.config.globalProperties,"$route",{enumerable:!0,get:()=>unref(c)}),isBrowser&&!k&&c.value===START_LOCATION_NORMALIZED&&(k=!0,g(r.location).catch((e=>{})));const t={};for(const e in START_LOCATION_NORMALIZED)Object.defineProperty(t,e,{get:()=>c.value[e],enumerable:!0});e.provide(routerKey,this),e.provide(routeLocationKey,shallowReactive(t)),e.provide(routerViewLocationKey,c);const n=e.unmount;I.add(e),e.unmount=function(){I.delete(e),I.size<1&&(u=START_LOCATION_NORMALIZED,_&&_(),_=null,c.value=START_LOCATION_NORMALIZED,k=!1,b=!1),n()}}};function K(e){return e.reduce(((e,t)=>e.then((()=>E(t)))),Promise.resolve())}return M}function extractChangingRecords(e,t){const n=[],o=[],r=[],a=Math.max(t.matched.length,e.matched.length);for(let i=0;i<a;i++){const a=t.matched[i];a&&(e.matched.find((e=>isSameRouteRecord(e,a)))?o.push(a):n.push(a));const s=e.matched[i];s&&(t.matched.find((e=>isSameRouteRecord(e,s)))||r.push(s))}return[n,o,r]}function useRouter(){return inject(routerKey)}function useRoute(e){return inject(routeLocationKey)}export{NavigationFailureType,RouterLink,RouterView,START_LOCATION_NORMALIZED as START_LOCATION,createMemoryHistory,createRouter,createRouterMatcher,createWebHashHistory,createWebHistory,isNavigationFailure,loadRouteLocation,matchedRouteKey,onBeforeRouteLeave,onBeforeRouteUpdate,parseQuery,routeLocationKey,routerKey,routerViewLocationKey,stringifyQuery,useLink,useRoute,useRouter,viewDepthKey};
|
|
6
|
+
import{inject,onUnmounted,onDeactivated,onActivated,computed,unref,defineComponent,reactive,h,provide,ref,watch,shallowRef,shallowReactive,nextTick}from"vue";const isBrowser="undefined"!=typeof document;function isRouteComponent(e){return"object"==typeof e||"displayName"in e||"props"in e||"__vccOpts"in e}function isESModule(e){return e.__esModule||"Module"===e[Symbol.toStringTag]||e.default&&isRouteComponent(e.default)}const assign=Object.assign;function applyToParams(e,t){const n={};for(const o in t){const r=t[o];n[o]=isArray(r)?r.map(e):e(r)}return n}const noop=()=>{},isArray=Array.isArray,HASH_RE=/#/g,AMPERSAND_RE=/&/g,SLASH_RE=/\//g,EQUAL_RE=/=/g,IM_RE=/\?/g,PLUS_RE=/\+/g,ENC_BRACKET_OPEN_RE=/%5B/g,ENC_BRACKET_CLOSE_RE=/%5D/g,ENC_CARET_RE=/%5E/g,ENC_BACKTICK_RE=/%60/g,ENC_CURLY_OPEN_RE=/%7B/g,ENC_PIPE_RE=/%7C/g,ENC_CURLY_CLOSE_RE=/%7D/g,ENC_SPACE_RE=/%20/g;function commonEncode(e){return encodeURI(""+e).replace(ENC_PIPE_RE,"|").replace(ENC_BRACKET_OPEN_RE,"[").replace(ENC_BRACKET_CLOSE_RE,"]")}function encodeHash(e){return commonEncode(e).replace(ENC_CURLY_OPEN_RE,"{").replace(ENC_CURLY_CLOSE_RE,"}").replace(ENC_CARET_RE,"^")}function encodeQueryValue(e){return commonEncode(e).replace(PLUS_RE,"%2B").replace(ENC_SPACE_RE,"+").replace(HASH_RE,"%23").replace(AMPERSAND_RE,"%26").replace(ENC_BACKTICK_RE,"`").replace(ENC_CURLY_OPEN_RE,"{").replace(ENC_CURLY_CLOSE_RE,"}").replace(ENC_CARET_RE,"^")}function encodeQueryKey(e){return encodeQueryValue(e).replace(EQUAL_RE,"%3D")}function encodePath(e){return commonEncode(e).replace(HASH_RE,"%23").replace(IM_RE,"%3F")}function encodeParam(e){return null==e?"":encodePath(e).replace(SLASH_RE,"%2F")}function decode(e){try{return decodeURIComponent(""+e)}catch(e){}return""+e}const TRAILING_SLASH_RE=/\/$/,removeTrailingSlash=e=>e.replace(TRAILING_SLASH_RE,"");function parseURL(e,t,n="/"){let o,r={},a="",i="";const s=t.indexOf("#");let c=t.indexOf("?");return s<c&&s>=0&&(c=-1),c>-1&&(o=t.slice(0,c),a=t.slice(c+1,s>-1?s:t.length),r=e(a)),s>-1&&(o=o||t.slice(0,s),i=t.slice(s,t.length)),o=resolveRelativePath(null!=o?o:t,n),{fullPath:o+(a&&"?")+a+i,path:o,query:r,hash:decode(i)}}function stringifyURL(e,t){const n=t.query?e(t.query):"";return t.path+(n&&"?")+n+(t.hash||"")}function stripBase(e,t){return t&&e.toLowerCase().startsWith(t.toLowerCase())?e.slice(t.length)||"/":e}function isSameRouteLocation(e,t,n){const o=t.matched.length-1,r=n.matched.length-1;return o>-1&&o===r&&isSameRouteRecord(t.matched[o],n.matched[r])&&isSameRouteLocationParams(t.params,n.params)&&e(t.query)===e(n.query)&&t.hash===n.hash}function isSameRouteRecord(e,t){return(e.aliasOf||e)===(t.aliasOf||t)}function isSameRouteLocationParams(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(!isSameRouteLocationParamsValue(e[n],t[n]))return!1;return!0}function isSameRouteLocationParamsValue(e,t){return isArray(e)?isEquivalentArray(e,t):isArray(t)?isEquivalentArray(t,e):e===t}function isEquivalentArray(e,t){return isArray(t)?e.length===t.length&&e.every(((e,n)=>e===t[n])):1===e.length&&e[0]===t}function resolveRelativePath(e,t){if(e.startsWith("/"))return e;if(!e)return t;const n=t.split("/"),o=e.split("/"),r=o[o.length-1];".."!==r&&"."!==r||o.push("");let a,i,s=n.length-1;for(a=0;a<o.length;a++)if(i=o[a],"."!==i){if(".."!==i)break;s>1&&s--}return n.slice(0,s).join("/")+"/"+o.slice(a).join("/")}const START_LOCATION_NORMALIZED={path:"/",name:void 0,params:{},query:{},hash:"",fullPath:"/",matched:[],meta:{},redirectedFrom:void 0};var NavigationType,NavigationDirection;!function(e){e.pop="pop",e.push="push"}(NavigationType||(NavigationType={})),function(e){e.back="back",e.forward="forward",e.unknown=""}(NavigationDirection||(NavigationDirection={}));const START="";function normalizeBase(e){if(!e)if(isBrowser){const t=document.querySelector("base");e=(e=t&&t.getAttribute("href")||"/").replace(/^\w+:\/\/[^\/]+/,"")}else e="/";return"/"!==e[0]&&"#"!==e[0]&&(e="/"+e),removeTrailingSlash(e)}const BEFORE_HASH_RE=/^[^#]+#/;function createHref(e,t){return e.replace(BEFORE_HASH_RE,"#")+t}function getElementPosition(e,t){const n=document.documentElement.getBoundingClientRect(),o=e.getBoundingClientRect();return{behavior:t.behavior,left:o.left-n.left-(t.left||0),top:o.top-n.top-(t.top||0)}}const computeScrollPosition=()=>({left:window.scrollX,top:window.scrollY});function scrollToPosition(e){let t;if("el"in e){const n=e.el,o="string"==typeof n&&n.startsWith("#"),r="string"==typeof n?o?document.getElementById(n.slice(1)):document.querySelector(n):n;if(!r)return;t=getElementPosition(r,e)}else t=e;"scrollBehavior"in document.documentElement.style?window.scrollTo(t):window.scrollTo(null!=t.left?t.left:window.scrollX,null!=t.top?t.top:window.scrollY)}function getScrollKey(e,t){return(history.state?history.state.position-t:-1)+e}const scrollPositions=new Map;function saveScrollPosition(e,t){scrollPositions.set(e,t)}function getSavedScrollPosition(e){const t=scrollPositions.get(e);return scrollPositions.delete(e),t}let createBaseLocation=()=>location.protocol+"//"+location.host;function createCurrentLocation(e,t){const{pathname:n,search:o,hash:r}=t,a=e.indexOf("#");if(a>-1){let t=r.includes(e.slice(a))?e.slice(a).length:1,n=r.slice(t);return"/"!==n[0]&&(n="/"+n),stripBase(n,"")}return stripBase(n,e)+o+r}function useHistoryListeners(e,t,n,o){let r=[],a=[],i=null;const s=({state:a})=>{const s=createCurrentLocation(e,location),c=n.value,u=t.value;let l=0;if(a){if(n.value=s,t.value=a,i&&i===c)return void(i=null);l=u?a.position-u.position:0}else o(s);r.forEach((e=>{e(n.value,c,{delta:l,type:NavigationType.pop,direction:l?l>0?NavigationDirection.forward:NavigationDirection.back:NavigationDirection.unknown})}))};function c(){const{history:e}=window;e.state&&e.replaceState(assign({},e.state,{scroll:computeScrollPosition()}),"")}return window.addEventListener("popstate",s),window.addEventListener("beforeunload",c,{passive:!0}),{pauseListeners:function(){i=n.value},listen:function(e){r.push(e);const t=()=>{const t=r.indexOf(e);t>-1&&r.splice(t,1)};return a.push(t),t},destroy:function(){for(const e of a)e();a=[],window.removeEventListener("popstate",s),window.removeEventListener("beforeunload",c)}}}function buildState(e,t,n,o=!1,r=!1){return{back:e,current:t,forward:n,replaced:o,position:window.history.length,scroll:r?computeScrollPosition():null}}function useHistoryStateNavigation(e){const{history:t,location:n}=window,o={value:createCurrentLocation(e,n)},r={value:t.state};function a(o,a,i){const s=e.indexOf("#"),c=s>-1?(n.host&&document.querySelector("base")?e:e.slice(s))+o:createBaseLocation()+e+o;try{t[i?"replaceState":"pushState"](a,"",c),r.value=a}catch(e){console.error(e),n[i?"replace":"assign"](c)}}return r.value||a(o.value,{back:null,current:o.value,forward:null,position:t.length-1,replaced:!0,scroll:null},!0),{location:o,state:r,push:function(e,n){const i=assign({},r.value,t.state,{forward:e,scroll:computeScrollPosition()});a(i.current,i,!0),a(e,assign({},buildState(o.value,e,null),{position:i.position+1},n),!1),o.value=e},replace:function(e,n){a(e,assign({},t.state,buildState(r.value.back,e,r.value.forward,!0),n,{position:r.value.position}),!0),o.value=e}}}function createWebHistory(e){const t=useHistoryStateNavigation(e=normalizeBase(e)),n=useHistoryListeners(e,t.state,t.location,t.replace);const o=assign({location:"",base:e,go:function(e,t=!0){t||n.pauseListeners(),history.go(e)},createHref:createHref.bind(null,e)},t,n);return Object.defineProperty(o,"location",{enumerable:!0,get:()=>t.location.value}),Object.defineProperty(o,"state",{enumerable:!0,get:()=>t.state.value}),o}function createMemoryHistory(e=""){let t=[],n=[""],o=0;function r(e){o++,o!==n.length&&n.splice(o),n.push(e)}const a={location:"",state:{},base:e=normalizeBase(e),createHref:createHref.bind(null,e),replace(e){n.splice(o--,1),r(e)},push(e,t){r(e)},listen:e=>(t.push(e),()=>{const n=t.indexOf(e);n>-1&&t.splice(n,1)}),destroy(){t=[],n=[""],o=0},go(e,r=!0){const a=this.location,i=e<0?NavigationDirection.back:NavigationDirection.forward;o=Math.max(0,Math.min(o+e,n.length-1)),r&&function(e,n,{direction:o,delta:r}){const a={direction:o,delta:r,type:NavigationType.pop};for(const o of t)o(e,n,a)}(this.location,a,{direction:i,delta:e})}};return Object.defineProperty(a,"location",{enumerable:!0,get:()=>n[o]}),a}function createWebHashHistory(e){return(e=location.host?e||location.pathname+location.search:"").includes("#")||(e+="#"),createWebHistory(e)}function isRouteLocation(e){return"string"==typeof e||e&&"object"==typeof e}function isRouteName(e){return"string"==typeof e||"symbol"==typeof e}const NavigationFailureSymbol=Symbol("");var NavigationFailureType;function createRouterError(e,t){return assign(new Error,{type:e,[NavigationFailureSymbol]:!0},t)}function isNavigationFailure(e,t){return e instanceof Error&&NavigationFailureSymbol in e&&(null==t||!!(e.type&t))}!function(e){e[e.aborted=4]="aborted",e[e.cancelled=8]="cancelled",e[e.duplicated=16]="duplicated"}(NavigationFailureType||(NavigationFailureType={}));const BASE_PARAM_PATTERN="[^/]+?",BASE_PATH_PARSER_OPTIONS={sensitive:!1,strict:!1,start:!0,end:!0},REGEX_CHARS_RE=/[.+*?^${}()[\]/\\]/g;function tokensToParser(e,t){const n=assign({},BASE_PATH_PARSER_OPTIONS,t),o=[];let r=n.start?"^":"";const a=[];for(const t of e){const e=t.length?[]:[90];n.strict&&!t.length&&(r+="/");for(let o=0;o<t.length;o++){const i=t[o];let s=40+(n.sensitive?.25:0);if(0===i.type)o||(r+="/"),r+=i.value.replace(REGEX_CHARS_RE,"\\$&"),s+=40;else if(1===i.type){const{value:e,repeatable:n,optional:c,regexp:u}=i;a.push({name:e,repeatable:n,optional:c});const l=u||BASE_PARAM_PATTERN;if(l!==BASE_PARAM_PATTERN){s+=10;try{new RegExp(`(${l})`)}catch(t){throw new Error(`Invalid custom RegExp for param "${e}" (${l}): `+t.message)}}let f=n?`((?:${l})(?:/(?:${l}))*)`:`(${l})`;o||(f=c&&t.length<2?`(?:/${f})`:"/"+f),c&&(f+="?"),r+=f,s+=20,c&&(s+=-8),n&&(s+=-20),".*"===l&&(s+=-50)}e.push(s)}o.push(e)}if(n.strict&&n.end){const e=o.length-1;o[e][o[e].length-1]+=.7000000000000001}n.strict||(r+="/?"),n.end?r+="$":n.strict&&!r.endsWith("/")&&(r+="(?:/|$)");const i=new RegExp(r,n.sensitive?"":"i");return{re:i,score:o,keys:a,parse:function(e){const t=e.match(i),n={};if(!t)return null;for(let e=1;e<t.length;e++){const o=t[e]||"",r=a[e-1];n[r.name]=o&&r.repeatable?o.split("/"):o}return n},stringify:function(t){let n="",o=!1;for(const r of e){o&&n.endsWith("/")||(n+="/"),o=!1;for(const e of r)if(0===e.type)n+=e.value;else if(1===e.type){const{value:a,repeatable:i,optional:s}=e,c=a in t?t[a]:"";if(isArray(c)&&!i)throw new Error(`Provided param "${a}" is an array but it is not repeatable (* or + modifiers)`);const u=isArray(c)?c.join("/"):c;if(!u){if(!s)throw new Error(`Missing required param "${a}"`);r.length<2&&(n.endsWith("/")?n=n.slice(0,-1):o=!0)}n+=u}}return n||"/"}}}function compareScoreArray(e,t){let n=0;for(;n<e.length&&n<t.length;){const o=t[n]-e[n];if(o)return o;n++}return e.length<t.length?1===e.length&&80===e[0]?-1:1:e.length>t.length?1===t.length&&80===t[0]?1:-1:0}function comparePathParserScore(e,t){let n=0;const o=e.score,r=t.score;for(;n<o.length&&n<r.length;){const e=compareScoreArray(o[n],r[n]);if(e)return e;n++}if(1===Math.abs(r.length-o.length)){if(isLastScoreNegative(o))return 1;if(isLastScoreNegative(r))return-1}return r.length-o.length}function isLastScoreNegative(e){const t=e[e.length-1];return e.length>0&&t[t.length-1]<0}const ROOT_TOKEN={type:0,value:""},VALID_PARAM_RE=/[a-zA-Z0-9_]/;function tokenizePath(e){if(!e)return[[]];if("/"===e)return[[ROOT_TOKEN]];if(!e.startsWith("/"))throw new Error(`Invalid path "${e}"`);function t(e){throw new Error(`ERR (${n})/"${u}": ${e}`)}let n=0,o=n;const r=[];let a;function i(){a&&r.push(a),a=[]}let s,c=0,u="",l="";function f(){u&&(0===n?a.push({type:0,value:u}):1===n||2===n||3===n?(a.length>1&&("*"===s||"+"===s)&&t(`A repeatable param (${u}) must be alone in its segment. eg: '/:ids+.`),a.push({type:1,value:u,regexp:l,repeatable:"*"===s||"+"===s,optional:"*"===s||"?"===s})):t("Invalid state to consume buffer"),u="")}function p(){u+=s}for(;c<e.length;)if(s=e[c++],"\\"!==s||2===n)switch(n){case 0:"/"===s?(u&&f(),i()):":"===s?(f(),n=1):p();break;case 4:p(),n=o;break;case 1:"("===s?n=2:VALID_PARAM_RE.test(s)?p():(f(),n=0,"*"!==s&&"?"!==s&&"+"!==s&&c--);break;case 2:")"===s?"\\"==l[l.length-1]?l=l.slice(0,-1)+s:n=3:l+=s;break;case 3:f(),n=0,"*"!==s&&"?"!==s&&"+"!==s&&c--,l="";break;default:t("Unknown state")}else o=n,n=4;return 2===n&&t(`Unfinished custom RegExp for param "${u}"`),f(),i(),r}function createRouteRecordMatcher(e,t,n){const o=tokensToParser(tokenizePath(e.path),n),r=assign(o,{record:e,parent:t,children:[],alias:[]});return t&&!r.record.aliasOf==!t.record.aliasOf&&t.children.push(r),r}function createRouterMatcher(e,t){const n=[],o=new Map;function r(e,n,o){const s=!o,c=normalizeRouteRecord(e);c.aliasOf=o&&o.record;const u=mergeOptions(t,e),l=[c];if("alias"in e){const t="string"==typeof e.alias?[e.alias]:e.alias;for(const e of t)l.push(normalizeRouteRecord(assign({},c,{components:o?o.record.components:c.components,path:e,aliasOf:o?o.record:c})))}let f,p;for(const t of l){const{path:l}=t;if(n&&"/"!==l[0]){const e=n.record.path;t.path=n.record.path+(l&&("/"===e[e.length-1]?"":"/")+l)}if(f=createRouteRecordMatcher(t,n,u),o?o.alias.push(f):(p=p||f,p!==f&&p.alias.push(f),s&&e.name&&!isAliasRecord(f)&&a(e.name)),isMatchable(f)&&i(f),c.children){const e=c.children;for(let t=0;t<e.length;t++)r(e[t],f,o&&o.children[t])}o=o||f}return p?()=>{a(p)}:noop}function a(e){if(isRouteName(e)){const t=o.get(e);t&&(o.delete(e),n.splice(n.indexOf(t),1),t.children.forEach(a),t.alias.forEach(a))}else{const t=n.indexOf(e);t>-1&&(n.splice(t,1),e.record.name&&o.delete(e.record.name),e.children.forEach(a),e.alias.forEach(a))}}function i(e){const t=findInsertionIndex(e,n);n.splice(t,0,e),e.record.name&&!isAliasRecord(e)&&o.set(e.record.name,e)}return t=mergeOptions({strict:!1,end:!0,sensitive:!1},t),e.forEach((e=>r(e))),{addRoute:r,resolve:function(e,t){let r,a,i,s={};if("name"in e&&e.name){if(r=o.get(e.name),!r)throw createRouterError(1,{location:e});i=r.record.name,s=assign(paramsFromLocation(t.params,r.keys.filter((e=>!e.optional)).concat(r.parent?r.parent.keys.filter((e=>e.optional)):[]).map((e=>e.name))),e.params&¶msFromLocation(e.params,r.keys.map((e=>e.name)))),a=r.stringify(s)}else if(null!=e.path)a=e.path,r=n.find((e=>e.re.test(a))),r&&(s=r.parse(a),i=r.record.name);else{if(r=t.name?o.get(t.name):n.find((e=>e.re.test(t.path))),!r)throw createRouterError(1,{location:e,currentLocation:t});i=r.record.name,s=assign({},t.params,e.params),a=r.stringify(s)}const c=[];let u=r;for(;u;)c.unshift(u.record),u=u.parent;return{name:i,path:a,params:s,matched:c,meta:mergeMetaFields(c)}},removeRoute:a,clearRoutes:function(){n.length=0,o.clear()},getRoutes:function(){return n},getRecordMatcher:function(e){return o.get(e)}}}function paramsFromLocation(e,t){const n={};for(const o of t)o in e&&(n[o]=e[o]);return n}function normalizeRouteRecord(e){const t={path:e.path,redirect:e.redirect,name:e.name,meta:e.meta||{},aliasOf:e.aliasOf,beforeEnter:e.beforeEnter,props:normalizeRecordProps(e),children:e.children||[],instances:{},leaveGuards:new Set,updateGuards:new Set,enterCallbacks:{},components:"components"in e?e.components||null:e.component&&{default:e.component}};return Object.defineProperty(t,"mods",{value:{}}),t}function normalizeRecordProps(e){const t={},n=e.props||!1;if("component"in e)t.default=n;else for(const o in e.components)t[o]="object"==typeof n?n[o]:n;return t}function isAliasRecord(e){for(;e;){if(e.record.aliasOf)return!0;e=e.parent}return!1}function mergeMetaFields(e){return e.reduce(((e,t)=>assign(e,t.meta)),{})}function mergeOptions(e,t){const n={};for(const o in e)n[o]=o in t?t[o]:e[o];return n}function findInsertionIndex(e,t){let n=0,o=t.length;for(;n!==o;){const r=n+o>>1;comparePathParserScore(e,t[r])<0?o=r:n=r+1}const r=getInsertionAncestor(e);return r&&(o=t.lastIndexOf(r,o-1)),o}function getInsertionAncestor(e){let t=e;for(;t=t.parent;)if(isMatchable(t)&&0===comparePathParserScore(e,t))return t}function isMatchable({record:e}){return!!(e.name||e.components&&Object.keys(e.components).length||e.redirect)}function parseQuery(e){const t={};if(""===e||"?"===e)return t;const n=("?"===e[0]?e.slice(1):e).split("&");for(let e=0;e<n.length;++e){const o=n[e].replace(PLUS_RE," "),r=o.indexOf("="),a=decode(r<0?o:o.slice(0,r)),i=r<0?null:decode(o.slice(r+1));if(a in t){let e=t[a];isArray(e)||(e=t[a]=[e]),e.push(i)}else t[a]=i}return t}function stringifyQuery(e){let t="";for(let n in e){const o=e[n];if(n=encodeQueryKey(n),null==o){void 0!==o&&(t+=(t.length?"&":"")+n);continue}(isArray(o)?o.map((e=>e&&encodeQueryValue(e))):[o&&encodeQueryValue(o)]).forEach((e=>{void 0!==e&&(t+=(t.length?"&":"")+n,null!=e&&(t+="="+e))}))}return t}function normalizeQuery(e){const t={};for(const n in e){const o=e[n];void 0!==o&&(t[n]=isArray(o)?o.map((e=>null==e?null:""+e)):null==o?o:""+o)}return t}const matchedRouteKey=Symbol(""),viewDepthKey=Symbol(""),routerKey=Symbol(""),routeLocationKey=Symbol(""),routerViewLocationKey=Symbol("");function useCallbacks(){let e=[];return{add:function(t){return e.push(t),()=>{const n=e.indexOf(t);n>-1&&e.splice(n,1)}},list:()=>e.slice(),reset:function(){e=[]}}}function registerGuard(e,t,n){const o=()=>{e[t].delete(n)};onUnmounted(o),onDeactivated(o),onActivated((()=>{e[t].add(n)})),e[t].add(n)}function onBeforeRouteLeave(e){const t=inject(matchedRouteKey,{}).value;t&®isterGuard(t,"leaveGuards",e)}function onBeforeRouteUpdate(e){const t=inject(matchedRouteKey,{}).value;t&®isterGuard(t,"updateGuards",e)}function guardToPromiseFn(e,t,n,o,r,a=e=>e()){const i=o&&(o.enterCallbacks[r]=o.enterCallbacks[r]||[]);return()=>new Promise(((s,c)=>{const u=e=>{!1===e?c(createRouterError(4,{from:n,to:t})):e instanceof Error?c(e):isRouteLocation(e)?c(createRouterError(2,{from:t,to:e})):(i&&o.enterCallbacks[r]===i&&"function"==typeof e&&i.push(e),s())},l=a((()=>e.call(o&&o.instances[r],t,n,u)));let f=Promise.resolve(l);e.length<3&&(f=f.then(u)),f.catch((e=>c(e)))}))}function extractComponentsGuards(e,t,n,o,r=e=>e()){const a=[];for(const i of e)for(const e in i.components){let s=i.components[e];if("beforeRouteEnter"===t||i.instances[e])if(isRouteComponent(s)){const c=(s.__vccOpts||s)[t];c&&a.push(guardToPromiseFn(c,n,o,i,e,r))}else{let c=s();a.push((()=>c.then((a=>{if(!a)throw new Error(`Couldn't resolve component "${e}" at "${i.path}"`);const s=isESModule(a)?a.default:a;i.mods[e]=a,i.components[e]=s;const c=(s.__vccOpts||s)[t];return c&&guardToPromiseFn(c,n,o,i,e,r)()}))))}}return a}function loadRouteLocation(e){return e.matched.every((e=>e.redirect))?Promise.reject(new Error("Cannot load a route that redirects.")):Promise.all(e.matched.map((e=>e.components&&Promise.all(Object.keys(e.components).reduce(((t,n)=>{const o=e.components[n];return"function"!=typeof o||"displayName"in o||t.push(o().then((t=>{if(!t)return Promise.reject(new Error(`Couldn't resolve component "${n}" at "${e.path}". Ensure you passed a function that returns a promise.`));const o=isESModule(t)?t.default:t;e.mods[n]=t,e.components[n]=o}))),t}),[]))))).then((()=>e))}function useLink(e){const t=inject(routerKey),n=inject(routeLocationKey),o=computed((()=>{const n=unref(e.to);return t.resolve(n)})),r=computed((()=>{const{matched:e}=o.value,{length:t}=e,r=e[t-1],a=n.matched;if(!r||!a.length)return-1;const i=a.findIndex(isSameRouteRecord.bind(null,r));if(i>-1)return i;const s=getOriginalPath(e[t-2]);return t>1&&getOriginalPath(r)===s&&a[a.length-1].path!==s?a.findIndex(isSameRouteRecord.bind(null,e[t-2])):i})),a=computed((()=>r.value>-1&&includesParams(n.params,o.value.params))),i=computed((()=>r.value>-1&&r.value===n.matched.length-1&&isSameRouteLocationParams(n.params,o.value.params)));return{route:o,href:computed((()=>o.value.href)),isActive:a,isExactActive:i,navigate:function(n={}){if(guardEvent(n)){const n=t[unref(e.replace)?"replace":"push"](unref(e.to)).catch(noop);return e.viewTransition&&"undefined"!=typeof document&&"startViewTransition"in document&&document.startViewTransition((()=>n)),n}return Promise.resolve()}}}function preferSingleVNode(e){return 1===e.length?e[0]:e}const RouterLinkImpl=defineComponent({name:"RouterLink",compatConfig:{MODE:3},props:{to:{type:[String,Object],required:!0},replace:Boolean,activeClass:String,exactActiveClass:String,custom:Boolean,ariaCurrentValue:{type:String,default:"page"}},useLink:useLink,setup(e,{slots:t}){const n=reactive(useLink(e)),{options:o}=inject(routerKey),r=computed((()=>({[getLinkClass(e.activeClass,o.linkActiveClass,"router-link-active")]:n.isActive,[getLinkClass(e.exactActiveClass,o.linkExactActiveClass,"router-link-exact-active")]:n.isExactActive})));return()=>{const o=t.default&&preferSingleVNode(t.default(n));return e.custom?o:h("a",{"aria-current":n.isExactActive?e.ariaCurrentValue:null,href:n.href,onClick:n.navigate,class:r.value},o)}}}),RouterLink=RouterLinkImpl;function guardEvent(e){if(!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey||e.defaultPrevented||void 0!==e.button&&0!==e.button)){if(e.currentTarget&&e.currentTarget.getAttribute){const t=e.currentTarget.getAttribute("target");if(/\b_blank\b/i.test(t))return}return e.preventDefault&&e.preventDefault(),!0}}function includesParams(e,t){for(const n in t){const o=t[n],r=e[n];if("string"==typeof o){if(o!==r)return!1}else if(!isArray(r)||r.length!==o.length||o.some(((e,t)=>e!==r[t])))return!1}return!0}function getOriginalPath(e){return e?e.aliasOf?e.aliasOf.path:e.path:""}const getLinkClass=(e,t,n)=>null!=e?e:null!=t?t:n,RouterViewImpl=defineComponent({name:"RouterView",inheritAttrs:!1,props:{name:{type:String,default:"default"},route:Object},compatConfig:{MODE:3},setup(e,{attrs:t,slots:n}){const o=inject(routerViewLocationKey),r=computed((()=>e.route||o.value)),a=inject(viewDepthKey,0),i=computed((()=>{let e=unref(a);const{matched:t}=r.value;let n;for(;(n=t[e])&&!n.components;)e++;return e})),s=computed((()=>r.value.matched[i.value]));provide(viewDepthKey,computed((()=>i.value+1))),provide(matchedRouteKey,s),provide(routerViewLocationKey,r);const c=ref();return watch((()=>[c.value,s.value,e.name]),(([e,t,n],[o,r,a])=>{t&&(t.instances[n]=e,r&&r!==t&&e&&e===o&&(t.leaveGuards.size||(t.leaveGuards=r.leaveGuards),t.updateGuards.size||(t.updateGuards=r.updateGuards))),!e||!t||r&&isSameRouteRecord(t,r)&&o||(t.enterCallbacks[n]||[]).forEach((t=>t(e)))}),{flush:"post"}),()=>{const o=r.value,a=e.name,i=s.value,u=i&&i.components[a];if(!u)return normalizeSlot(n.default,{Component:u,route:o});const l=i.props[a],f=l?!0===l?o.params:"function"==typeof l?l(o):l:null,p=h(u,assign({},f,t,{onVnodeUnmounted:e=>{e.component.isUnmounted&&(i.instances[a]=null)},ref:c}));return normalizeSlot(n.default,{Component:p,route:o})||p}}});function normalizeSlot(e,t){if(!e)return null;const n=e(t);return 1===n.length?n[0]:n}const RouterView=RouterViewImpl;function createRouter(e){const t=createRouterMatcher(e.routes,e),n=e.parseQuery||parseQuery,o=e.stringifyQuery||stringifyQuery,r=e.history,a=useCallbacks(),i=useCallbacks(),s=useCallbacks(),c=shallowRef(START_LOCATION_NORMALIZED);let u=START_LOCATION_NORMALIZED;isBrowser&&e.scrollBehavior&&"scrollRestoration"in history&&(history.scrollRestoration="manual");const l=applyToParams.bind(null,(e=>""+e)),f=applyToParams.bind(null,encodeParam),p=applyToParams.bind(null,decode);function d(e,a){if(a=assign({},a||c.value),"string"==typeof e){const o=parseURL(n,e,a.path),i=t.resolve({path:o.path},a),s=r.createHref(o.fullPath);return assign(o,i,{params:p(i.params),hash:decode(o.hash),redirectedFrom:void 0,href:s})}let i;if(null!=e.path)i=assign({},e,{path:parseURL(n,e.path,a.path).path});else{const t=assign({},e.params);for(const e in t)null==t[e]&&delete t[e];i=assign({},e,{params:f(t)}),a.params=f(a.params)}const s=t.resolve(i,a),u=e.hash||"";s.params=l(p(s.params));const d=stringifyURL(o,assign({},e,{hash:encodeHash(u),path:s.path})),h=r.createHref(d);return assign({fullPath:d,hash:u,query:o===stringifyQuery?normalizeQuery(e.query):e.query||{}},s,{redirectedFrom:void 0,href:h})}function h(e){return"string"==typeof e?parseURL(n,e,c.value.path):assign({},e)}function m(e,t){if(u!==e)return createRouterError(8,{from:t,to:e})}function g(e){return v(e)}function R(e){const t=e.matched[e.matched.length-1];if(t&&t.redirect){const{redirect:n}=t;let o="function"==typeof n?n(e):n;return"string"==typeof o&&(o=o.includes("?")||o.includes("#")?o=h(o):{path:o},o.params={}),assign({query:e.query,hash:e.hash,params:null!=o.path?{}:e.params},o)}}function v(e,t){const n=u=d(e),r=c.value,a=e.state,i=e.force,s=!0===e.replace,l=R(n);if(l)return v(assign(h(l),{state:"object"==typeof l?assign({},a,l.state):a,force:i,replace:s}),t||n);const f=n;let p;return f.redirectedFrom=t,!i&&isSameRouteLocation(o,r,n)&&(p=createRouterError(16,{to:f,from:r}),w(r,r,!0,!1)),(p?Promise.resolve(p):A(f,r)).catch((e=>isNavigationFailure(e)?isNavigationFailure(e,2)?e:T(e):N(e,f,r))).then((e=>{if(e){if(isNavigationFailure(e,2))return v(assign({replace:s},h(e.to),{state:"object"==typeof e.to?assign({},a,e.to.state):a,force:i}),t||f)}else e=P(f,r,!0,s,a);return S(f,r,e),e}))}function y(e,t){const n=m(e,t);return n?Promise.reject(n):Promise.resolve()}function E(e){const t=I.values().next().value;return t&&"function"==typeof t.runWithContext?t.runWithContext(e):e()}function A(e,t){let n;const[o,r,s]=extractChangingRecords(e,t);n=extractComponentsGuards(o.reverse(),"beforeRouteLeave",e,t);for(const r of o)r.leaveGuards.forEach((o=>{n.push(guardToPromiseFn(o,e,t))}));const c=y.bind(null,e,t);return n.push(c),K(n).then((()=>{n=[];for(const o of a.list())n.push(guardToPromiseFn(o,e,t));return n.push(c),K(n)})).then((()=>{n=extractComponentsGuards(r,"beforeRouteUpdate",e,t);for(const o of r)o.updateGuards.forEach((o=>{n.push(guardToPromiseFn(o,e,t))}));return n.push(c),K(n)})).then((()=>{n=[];for(const o of s)if(o.beforeEnter)if(isArray(o.beforeEnter))for(const r of o.beforeEnter)n.push(guardToPromiseFn(r,e,t));else n.push(guardToPromiseFn(o.beforeEnter,e,t));return n.push(c),K(n)})).then((()=>(e.matched.forEach((e=>e.enterCallbacks={})),n=extractComponentsGuards(s,"beforeRouteEnter",e,t,E),n.push(c),K(n)))).then((()=>{n=[];for(const o of i.list())n.push(guardToPromiseFn(o,e,t));return n.push(c),K(n)})).catch((e=>isNavigationFailure(e,8)?e:Promise.reject(e)))}function S(e,t,n){s.list().forEach((o=>E((()=>o(e,t,n)))))}function P(e,t,n,o,a){const i=m(e,t);if(i)return i;const s=t===START_LOCATION_NORMALIZED,u=isBrowser?history.state:{};n&&(o||s?r.replace(e.fullPath,assign({scroll:s&&u&&u.scroll},a)):r.push(e.fullPath,a)),c.value=e,w(e,t,n,s),T()}let _;let b,L=useCallbacks(),C=useCallbacks();function N(e,t,n){T(e);const o=C.list();return o.length?o.forEach((o=>o(e,t,n))):console.error(e),Promise.reject(e)}function T(e){return b||(b=!e,_||(_=r.listen(((e,t,n)=>{if(!M.listening)return;const o=d(e),a=R(o);if(a)return void v(assign(a,{replace:!0,force:!0}),o).catch(noop);u=o;const i=c.value;isBrowser&&saveScrollPosition(getScrollKey(i.fullPath,n.delta),computeScrollPosition()),A(o,i).catch((e=>isNavigationFailure(e,12)?e:isNavigationFailure(e,2)?(v(assign(h(e.to),{force:!0}),o).then((e=>{isNavigationFailure(e,20)&&!n.delta&&n.type===NavigationType.pop&&r.go(-1,!1)})).catch(noop),Promise.reject()):(n.delta&&r.go(-n.delta,!1),N(e,o,i)))).then((e=>{(e=e||P(o,i,!1))&&(n.delta&&!isNavigationFailure(e,8)?r.go(-n.delta,!1):n.type===NavigationType.pop&&isNavigationFailure(e,20)&&r.go(-1,!1)),S(o,i,e)})).catch(noop)}))),L.list().forEach((([t,n])=>e?n(e):t())),L.reset()),e}function w(t,n,o,r){const{scrollBehavior:a}=e;if(!isBrowser||!a)return Promise.resolve();const i=!o&&getSavedScrollPosition(getScrollKey(t.fullPath,0))||(r||!o)&&history.state&&history.state.scroll||null;return nextTick().then((()=>a(t,n,i))).then((e=>e&&scrollToPosition(e))).catch((e=>N(e,t,n)))}const O=e=>r.go(e);let k;const I=new Set,M={currentRoute:c,listening:!0,addRoute:function(e,n){let o,r;return isRouteName(e)?(o=t.getRecordMatcher(e),r=n):r=e,t.addRoute(r,o)},removeRoute:function(e){const n=t.getRecordMatcher(e);n&&t.removeRoute(n)},clearRoutes:t.clearRoutes,hasRoute:function(e){return!!t.getRecordMatcher(e)},getRoutes:function(){return t.getRoutes().map((e=>e.record))},resolve:d,options:e,push:g,replace:function(e){return g(assign(h(e),{replace:!0}))},go:O,back:()=>O(-1),forward:()=>O(1),beforeEach:a.add,beforeResolve:i.add,afterEach:s.add,onError:C.add,isReady:function(){return b&&c.value!==START_LOCATION_NORMALIZED?Promise.resolve():new Promise(((e,t)=>{L.add([e,t])}))},install(e){e.component("RouterLink",RouterLink),e.component("RouterView",RouterView),e.config.globalProperties.$router=this,Object.defineProperty(e.config.globalProperties,"$route",{enumerable:!0,get:()=>unref(c)}),isBrowser&&!k&&c.value===START_LOCATION_NORMALIZED&&(k=!0,g(r.location).catch((e=>{})));const t={};for(const e in START_LOCATION_NORMALIZED)Object.defineProperty(t,e,{get:()=>c.value[e],enumerable:!0});e.provide(routerKey,this),e.provide(routeLocationKey,shallowReactive(t)),e.provide(routerViewLocationKey,c);const n=e.unmount;I.add(e),e.unmount=function(){I.delete(e),I.size<1&&(u=START_LOCATION_NORMALIZED,_&&_(),_=null,c.value=START_LOCATION_NORMALIZED,k=!1,b=!1),n()}}};function K(e){return e.reduce(((e,t)=>e.then((()=>E(t)))),Promise.resolve())}return M}function extractChangingRecords(e,t){const n=[],o=[],r=[],a=Math.max(t.matched.length,e.matched.length);for(let i=0;i<a;i++){const a=t.matched[i];a&&(e.matched.find((e=>isSameRouteRecord(e,a)))?o.push(a):n.push(a));const s=e.matched[i];s&&(t.matched.find((e=>isSameRouteRecord(e,s)))||r.push(s))}return[n,o,r]}function useRouter(){return inject(routerKey)}function useRoute(e){return inject(routeLocationKey)}export{NavigationFailureType,RouterLink,RouterView,START_LOCATION_NORMALIZED as START_LOCATION,createMemoryHistory,createRouter,createRouterMatcher,createWebHashHistory,createWebHistory,isNavigationFailure,loadRouteLocation,matchedRouteKey,onBeforeRouteLeave,onBeforeRouteUpdate,parseQuery,routeLocationKey,routerKey,routerViewLocationKey,stringifyQuery,useLink,useRoute,useRouter,viewDepthKey};
|
package/package.json
CHANGED