smbls 3.6.4 → 3.6.6
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/cjs/package.json +1 -1
- package/dist/cjs/src/define.js +5 -0
- package/dist/cjs/src/fetchOnCreate.js +66 -3
- package/dist/cjs/src/router.js +31 -4
- package/dist/esm/package.json +1 -1
- package/dist/esm/src/define.js +5 -0
- package/dist/esm/src/fetchOnCreate.js +65 -2
- package/dist/esm/src/router.js +31 -4
- package/dist/iife/index.js +200 -12
- package/package.json +16 -16
- package/src/define.js +6 -0
- package/src/fetchOnCreate.js +91 -2
- package/src/router.js +35 -3
package/dist/cjs/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"smbls","version":"3.6.
|
|
1
|
+
{"name":"smbls","version":"3.6.5"}
|
package/dist/cjs/src/define.js
CHANGED
|
@@ -22,6 +22,7 @@ __export(define_exports, {
|
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(define_exports);
|
|
24
24
|
var import_helmet = require("@symbo.ls/helmet");
|
|
25
|
+
var import_fetch = require("@symbo.ls/fetch");
|
|
25
26
|
const defaultDefine = {
|
|
26
27
|
routes: (param) => param,
|
|
27
28
|
metadata: (param, el, state) => {
|
|
@@ -31,6 +32,10 @@ const defaultDefine = {
|
|
|
31
32
|
const resolved = (0, import_helmet.resolveMetadata)(param, el, state);
|
|
32
33
|
(0, import_helmet.applyMetadata)(resolved, doc);
|
|
33
34
|
},
|
|
35
|
+
fetch: (param, el, state, context) => {
|
|
36
|
+
if (!param) return;
|
|
37
|
+
(0, import_fetch.executeFetch)(param, el, state, context);
|
|
38
|
+
},
|
|
34
39
|
$router: async (param, el) => {
|
|
35
40
|
if (!param) return;
|
|
36
41
|
const obj = { tag: "fragment", ...param };
|
|
@@ -23,11 +23,74 @@ __export(fetchOnCreate_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(fetchOnCreate_exports);
|
|
25
25
|
var import_utils = require("@domql/utils");
|
|
26
|
-
|
|
26
|
+
const IS_DEVELOPMENT = import_utils.window && import_utils.window.location ? import_utils.window.location.host.includes("dev.") : (0, import_utils.isDevelopment)();
|
|
27
|
+
const SERVER_URL = IS_DEVELOPMENT ? "http://localhost:8080/get" : "https://api.symbols.app/get";
|
|
28
|
+
const defaultOptions = {
|
|
29
|
+
endpoint: SERVER_URL
|
|
30
|
+
};
|
|
31
|
+
const fetchRemote = async (key, options = defaultOptions) => {
|
|
32
|
+
const baseUrl = options.endpoint || SERVER_URL;
|
|
33
|
+
const route = options.serviceRoute ? (0, import_utils.isArray)(options.serviceRoute) ? options.serviceRoute.map((v) => v.toLowerCase() + "=true").join("&") : options.serviceRoute : "";
|
|
34
|
+
let response;
|
|
35
|
+
try {
|
|
36
|
+
response = await globalThis.fetch(baseUrl + "/?" + route, {
|
|
37
|
+
method: "GET",
|
|
38
|
+
headers: {
|
|
39
|
+
"Content-Type": "application/json",
|
|
40
|
+
"X-AppKey": key,
|
|
41
|
+
"X-Metadata": options.metadata
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
return await response.json();
|
|
45
|
+
} catch (e) {
|
|
46
|
+
if ((0, import_utils.isFunction)(options.onError)) return options.onError(e);
|
|
47
|
+
else console.error(e);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
const fetchProject = async (key, options) => {
|
|
51
|
+
const { editor } = options;
|
|
52
|
+
if (editor && editor.remote) {
|
|
53
|
+
const data = await fetchRemote(key, editor);
|
|
54
|
+
const evalData = IS_DEVELOPMENT || options.isDevelopment ? (0, import_utils.deepDestringifyFunctions)(data) : (0, import_utils.deepDestringifyFunctions)(data.releases[0]);
|
|
55
|
+
if (editor.serviceRoute) {
|
|
56
|
+
if ((0, import_utils.isArray)(editor.serviceRoute)) {
|
|
57
|
+
editor.serviceRoute.forEach((route) => {
|
|
58
|
+
(0, import_utils.overwriteDeep)(options[route], evalData[route.toLowerCase()]);
|
|
59
|
+
});
|
|
60
|
+
} else {
|
|
61
|
+
(0, import_utils.overwriteDeep)(options[editor.serviceRoute], evalData);
|
|
62
|
+
}
|
|
63
|
+
} else {
|
|
64
|
+
;
|
|
65
|
+
[
|
|
66
|
+
"state",
|
|
67
|
+
"designSystem",
|
|
68
|
+
"components",
|
|
69
|
+
"snippets",
|
|
70
|
+
"pages",
|
|
71
|
+
"utils",
|
|
72
|
+
"files",
|
|
73
|
+
"packages",
|
|
74
|
+
"functions"
|
|
75
|
+
].forEach((key2) => {
|
|
76
|
+
(0, import_utils.overwriteDeep)(options[key2], evalData[key2.toLowerCase()]);
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return options;
|
|
81
|
+
};
|
|
82
|
+
const fetchProjectAsync = async (key, options, callback) => {
|
|
83
|
+
const { editor } = options;
|
|
84
|
+
if (editor && editor.remote) {
|
|
85
|
+
const data = await fetchRemote(key, editor);
|
|
86
|
+
const evalData = IS_DEVELOPMENT || options.isDevelopment ? (0, import_utils.deepDestringifyFunctions)(data) : (0, import_utils.deepDestringifyFunctions)(data.releases[0]);
|
|
87
|
+
callback(evalData);
|
|
88
|
+
}
|
|
89
|
+
};
|
|
27
90
|
const fetchSync = async (key, options) => {
|
|
28
91
|
if (key && options.editor) {
|
|
29
92
|
try {
|
|
30
|
-
if (!options.editor.async) await
|
|
93
|
+
if (!options.editor.async) await fetchProject(key, options);
|
|
31
94
|
} catch (e) {
|
|
32
95
|
console.error(e);
|
|
33
96
|
}
|
|
@@ -37,7 +100,7 @@ const fetchAsync = (app, key, options, callback) => {
|
|
|
37
100
|
if (key && options.editor) {
|
|
38
101
|
try {
|
|
39
102
|
if (options.editor.async) {
|
|
40
|
-
|
|
103
|
+
fetchProjectAsync(key, options, callback || ((data) => {
|
|
41
104
|
const designSystem = data.designSystem;
|
|
42
105
|
if ((0, import_utils.isObject)(designSystem)) {
|
|
43
106
|
options.utils.init(designSystem);
|
package/dist/cjs/src/router.js
CHANGED
|
@@ -20,7 +20,8 @@ var router_exports = {};
|
|
|
20
20
|
__export(router_exports, {
|
|
21
21
|
initRouter: () => initRouter,
|
|
22
22
|
injectRouterInLinkComponent: () => injectRouterInLinkComponent,
|
|
23
|
-
onpopstateRouter: () => onpopstateRouter
|
|
23
|
+
onpopstateRouter: () => onpopstateRouter,
|
|
24
|
+
resolveRouterElement: () => resolveRouterElement
|
|
24
25
|
});
|
|
25
26
|
module.exports = __toCommonJS(router_exports);
|
|
26
27
|
var import_utils = require("@domql/utils");
|
|
@@ -31,6 +32,16 @@ const DEFAULT_ROUTING_OPTIONS = {
|
|
|
31
32
|
injectRouterInLinkComponent: true,
|
|
32
33
|
popState: true
|
|
33
34
|
};
|
|
35
|
+
const resolveRouterElement = (root, path) => {
|
|
36
|
+
if (!path) return root;
|
|
37
|
+
const parts = Array.isArray(path) ? path : path.split(".");
|
|
38
|
+
let el = root;
|
|
39
|
+
for (const part of parts) {
|
|
40
|
+
if (!el || !el[part]) return null;
|
|
41
|
+
el = el[part];
|
|
42
|
+
}
|
|
43
|
+
return el;
|
|
44
|
+
};
|
|
34
45
|
const initRouter = (element, context) => {
|
|
35
46
|
if (context.router === false) return;
|
|
36
47
|
else if (context.router === true) context.router = DEFAULT_ROUTING_OPTIONS;
|
|
@@ -40,7 +51,15 @@ const initRouter = (element, context) => {
|
|
|
40
51
|
if (!import_utils.window.location) return;
|
|
41
52
|
const { pathname, search, hash } = import_utils.window.location;
|
|
42
53
|
const url = pathname + search + hash;
|
|
43
|
-
|
|
54
|
+
let targetEl = el;
|
|
55
|
+
if (routerOptions.customRouterElement) {
|
|
56
|
+
const resolved = resolveRouterElement(el, routerOptions.customRouterElement);
|
|
57
|
+
if (resolved) {
|
|
58
|
+
targetEl = resolved;
|
|
59
|
+
if (el.routes) targetEl.routes = el.routes;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
if (targetEl.routes) await (0, import_router.router)(url, targetEl, {}, { initialRender: true });
|
|
44
63
|
};
|
|
45
64
|
const hasRenderRouter = element.on && !(0, import_utils.isUndefined)(element.on.renderRouter) || !(0, import_utils.isUndefined)(element.onRenderRouter);
|
|
46
65
|
if (routerOptions && routerOptions.initRouter && !hasRenderRouter) {
|
|
@@ -65,10 +84,18 @@ const onpopstateRouter = (element, context) => {
|
|
|
65
84
|
import_utils.window.onpopstate = async (e) => {
|
|
66
85
|
const { pathname, search, hash } = import_utils.window.location;
|
|
67
86
|
const url = pathname + search + hash;
|
|
68
|
-
|
|
87
|
+
let targetEl = element;
|
|
88
|
+
if (routerOptions.customRouterElement) {
|
|
89
|
+
const resolved = resolveRouterElement(element, routerOptions.customRouterElement);
|
|
90
|
+
if (resolved) {
|
|
91
|
+
targetEl = resolved;
|
|
92
|
+
if (element.routes) targetEl.routes = element.routes;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
await targetEl.call(
|
|
69
96
|
"router",
|
|
70
97
|
url,
|
|
71
|
-
|
|
98
|
+
targetEl,
|
|
72
99
|
{},
|
|
73
100
|
{ pushState: false, scrollToTop: false, level: 0, event: e }
|
|
74
101
|
);
|
package/dist/esm/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"smbls","version":"3.6.
|
|
1
|
+
{"name":"smbls","version":"3.6.5"}
|
package/dist/esm/src/define.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { resolveMetadata, applyMetadata } from "@symbo.ls/helmet";
|
|
2
|
+
import { executeFetch } from "@symbo.ls/fetch";
|
|
2
3
|
const defaultDefine = {
|
|
3
4
|
routes: (param) => param,
|
|
4
5
|
metadata: (param, el, state) => {
|
|
@@ -8,6 +9,10 @@ const defaultDefine = {
|
|
|
8
9
|
const resolved = resolveMetadata(param, el, state);
|
|
9
10
|
applyMetadata(resolved, doc);
|
|
10
11
|
},
|
|
12
|
+
fetch: (param, el, state, context) => {
|
|
13
|
+
if (!param) return;
|
|
14
|
+
executeFetch(param, el, state, context);
|
|
15
|
+
},
|
|
11
16
|
$router: async (param, el) => {
|
|
12
17
|
if (!param) return;
|
|
13
18
|
const obj = { tag: "fragment", ...param };
|
|
@@ -1,5 +1,68 @@
|
|
|
1
|
-
import { isObject } from "@domql/utils";
|
|
2
|
-
|
|
1
|
+
import { isArray, isFunction, isObject, window, isDevelopment, overwriteDeep, deepDestringifyFunctions } from "@domql/utils";
|
|
2
|
+
const IS_DEVELOPMENT = window && window.location ? window.location.host.includes("dev.") : isDevelopment();
|
|
3
|
+
const SERVER_URL = IS_DEVELOPMENT ? "http://localhost:8080/get" : "https://api.symbols.app/get";
|
|
4
|
+
const defaultOptions = {
|
|
5
|
+
endpoint: SERVER_URL
|
|
6
|
+
};
|
|
7
|
+
const fetchRemote = async (key, options = defaultOptions) => {
|
|
8
|
+
const baseUrl = options.endpoint || SERVER_URL;
|
|
9
|
+
const route = options.serviceRoute ? isArray(options.serviceRoute) ? options.serviceRoute.map((v) => v.toLowerCase() + "=true").join("&") : options.serviceRoute : "";
|
|
10
|
+
let response;
|
|
11
|
+
try {
|
|
12
|
+
response = await globalThis.fetch(baseUrl + "/?" + route, {
|
|
13
|
+
method: "GET",
|
|
14
|
+
headers: {
|
|
15
|
+
"Content-Type": "application/json",
|
|
16
|
+
"X-AppKey": key,
|
|
17
|
+
"X-Metadata": options.metadata
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
return await response.json();
|
|
21
|
+
} catch (e) {
|
|
22
|
+
if (isFunction(options.onError)) return options.onError(e);
|
|
23
|
+
else console.error(e);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
const fetchProject = async (key, options) => {
|
|
27
|
+
const { editor } = options;
|
|
28
|
+
if (editor && editor.remote) {
|
|
29
|
+
const data = await fetchRemote(key, editor);
|
|
30
|
+
const evalData = IS_DEVELOPMENT || options.isDevelopment ? deepDestringifyFunctions(data) : deepDestringifyFunctions(data.releases[0]);
|
|
31
|
+
if (editor.serviceRoute) {
|
|
32
|
+
if (isArray(editor.serviceRoute)) {
|
|
33
|
+
editor.serviceRoute.forEach((route) => {
|
|
34
|
+
overwriteDeep(options[route], evalData[route.toLowerCase()]);
|
|
35
|
+
});
|
|
36
|
+
} else {
|
|
37
|
+
overwriteDeep(options[editor.serviceRoute], evalData);
|
|
38
|
+
}
|
|
39
|
+
} else {
|
|
40
|
+
;
|
|
41
|
+
[
|
|
42
|
+
"state",
|
|
43
|
+
"designSystem",
|
|
44
|
+
"components",
|
|
45
|
+
"snippets",
|
|
46
|
+
"pages",
|
|
47
|
+
"utils",
|
|
48
|
+
"files",
|
|
49
|
+
"packages",
|
|
50
|
+
"functions"
|
|
51
|
+
].forEach((key2) => {
|
|
52
|
+
overwriteDeep(options[key2], evalData[key2.toLowerCase()]);
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return options;
|
|
57
|
+
};
|
|
58
|
+
const fetchProjectAsync = async (key, options, callback) => {
|
|
59
|
+
const { editor } = options;
|
|
60
|
+
if (editor && editor.remote) {
|
|
61
|
+
const data = await fetchRemote(key, editor);
|
|
62
|
+
const evalData = IS_DEVELOPMENT || options.isDevelopment ? deepDestringifyFunctions(data) : deepDestringifyFunctions(data.releases[0]);
|
|
63
|
+
callback(evalData);
|
|
64
|
+
}
|
|
65
|
+
};
|
|
3
66
|
const fetchSync = async (key, options) => {
|
|
4
67
|
if (key && options.editor) {
|
|
5
68
|
try {
|
package/dist/esm/src/router.js
CHANGED
|
@@ -6,6 +6,16 @@ const DEFAULT_ROUTING_OPTIONS = {
|
|
|
6
6
|
injectRouterInLinkComponent: true,
|
|
7
7
|
popState: true
|
|
8
8
|
};
|
|
9
|
+
const resolveRouterElement = (root, path) => {
|
|
10
|
+
if (!path) return root;
|
|
11
|
+
const parts = Array.isArray(path) ? path : path.split(".");
|
|
12
|
+
let el = root;
|
|
13
|
+
for (const part of parts) {
|
|
14
|
+
if (!el || !el[part]) return null;
|
|
15
|
+
el = el[part];
|
|
16
|
+
}
|
|
17
|
+
return el;
|
|
18
|
+
};
|
|
9
19
|
const initRouter = (element, context) => {
|
|
10
20
|
if (context.router === false) return;
|
|
11
21
|
else if (context.router === true) context.router = DEFAULT_ROUTING_OPTIONS;
|
|
@@ -15,7 +25,15 @@ const initRouter = (element, context) => {
|
|
|
15
25
|
if (!window.location) return;
|
|
16
26
|
const { pathname, search, hash } = window.location;
|
|
17
27
|
const url = pathname + search + hash;
|
|
18
|
-
|
|
28
|
+
let targetEl = el;
|
|
29
|
+
if (routerOptions.customRouterElement) {
|
|
30
|
+
const resolved = resolveRouterElement(el, routerOptions.customRouterElement);
|
|
31
|
+
if (resolved) {
|
|
32
|
+
targetEl = resolved;
|
|
33
|
+
if (el.routes) targetEl.routes = el.routes;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
if (targetEl.routes) await defaultRouter(url, targetEl, {}, { initialRender: true });
|
|
19
37
|
};
|
|
20
38
|
const hasRenderRouter = element.on && !isUndefined(element.on.renderRouter) || !isUndefined(element.onRenderRouter);
|
|
21
39
|
if (routerOptions && routerOptions.initRouter && !hasRenderRouter) {
|
|
@@ -40,10 +58,18 @@ const onpopstateRouter = (element, context) => {
|
|
|
40
58
|
window.onpopstate = async (e) => {
|
|
41
59
|
const { pathname, search, hash } = window.location;
|
|
42
60
|
const url = pathname + search + hash;
|
|
43
|
-
|
|
61
|
+
let targetEl = element;
|
|
62
|
+
if (routerOptions.customRouterElement) {
|
|
63
|
+
const resolved = resolveRouterElement(element, routerOptions.customRouterElement);
|
|
64
|
+
if (resolved) {
|
|
65
|
+
targetEl = resolved;
|
|
66
|
+
if (element.routes) targetEl.routes = element.routes;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
await targetEl.call(
|
|
44
70
|
"router",
|
|
45
71
|
url,
|
|
46
|
-
|
|
72
|
+
targetEl,
|
|
47
73
|
{},
|
|
48
74
|
{ pushState: false, scrollToTop: false, level: 0, event: e }
|
|
49
75
|
);
|
|
@@ -61,5 +87,6 @@ const injectRouterInLinkComponent = (context, routerOptions) => {
|
|
|
61
87
|
export {
|
|
62
88
|
initRouter,
|
|
63
89
|
injectRouterInLinkComponent,
|
|
64
|
-
onpopstateRouter
|
|
90
|
+
onpopstateRouter,
|
|
91
|
+
resolveRouterElement
|
|
65
92
|
};
|
package/dist/iife/index.js
CHANGED
|
@@ -409,6 +409,16 @@ var Smbls = (() => {
|
|
|
409
409
|
injectRouterInLinkComponent: true,
|
|
410
410
|
popState: true
|
|
411
411
|
};
|
|
412
|
+
var resolveRouterElement = (root, path) => {
|
|
413
|
+
if (!path) return root;
|
|
414
|
+
const parts = Array.isArray(path) ? path : path.split(".");
|
|
415
|
+
let el = root;
|
|
416
|
+
for (const part of parts) {
|
|
417
|
+
if (!el || !el[part]) return null;
|
|
418
|
+
el = el[part];
|
|
419
|
+
}
|
|
420
|
+
return el;
|
|
421
|
+
};
|
|
412
422
|
var initRouter = (element, context) => {
|
|
413
423
|
if (context.router === false) return;
|
|
414
424
|
else if (context.router === true) context.router = DEFAULT_ROUTING_OPTIONS;
|
|
@@ -418,7 +428,15 @@ var Smbls = (() => {
|
|
|
418
428
|
if (!import_utils3.window.location) return;
|
|
419
429
|
const { pathname, search, hash } = import_utils3.window.location;
|
|
420
430
|
const url = pathname + search + hash;
|
|
421
|
-
|
|
431
|
+
let targetEl = el;
|
|
432
|
+
if (routerOptions.customRouterElement) {
|
|
433
|
+
const resolved = resolveRouterElement(el, routerOptions.customRouterElement);
|
|
434
|
+
if (resolved) {
|
|
435
|
+
targetEl = resolved;
|
|
436
|
+
if (el.routes) targetEl.routes = el.routes;
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
if (targetEl.routes) await (0, import_router.router)(url, targetEl, {}, { initialRender: true });
|
|
422
440
|
};
|
|
423
441
|
const hasRenderRouter = element.on && !(0, import_utils3.isUndefined)(element.on.renderRouter) || !(0, import_utils3.isUndefined)(element.onRenderRouter);
|
|
424
442
|
if (routerOptions && routerOptions.initRouter && !hasRenderRouter) {
|
|
@@ -443,10 +461,18 @@ var Smbls = (() => {
|
|
|
443
461
|
import_utils3.window.onpopstate = async (e) => {
|
|
444
462
|
const { pathname, search, hash } = import_utils3.window.location;
|
|
445
463
|
const url = pathname + search + hash;
|
|
446
|
-
|
|
464
|
+
let targetEl = element;
|
|
465
|
+
if (routerOptions.customRouterElement) {
|
|
466
|
+
const resolved = resolveRouterElement(element, routerOptions.customRouterElement);
|
|
467
|
+
if (resolved) {
|
|
468
|
+
targetEl = resolved;
|
|
469
|
+
if (element.routes) targetEl.routes = element.routes;
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
await targetEl.call(
|
|
447
473
|
"router",
|
|
448
474
|
url,
|
|
449
|
-
|
|
475
|
+
targetEl,
|
|
450
476
|
{},
|
|
451
477
|
{ pushState: false, scrollToTop: false, level: 0, event: e }
|
|
452
478
|
);
|
|
@@ -464,11 +490,74 @@ var Smbls = (() => {
|
|
|
464
490
|
|
|
465
491
|
// dist/esm/src/fetchOnCreate.js
|
|
466
492
|
var import_utils4 = __require("@domql/utils");
|
|
467
|
-
var
|
|
493
|
+
var IS_DEVELOPMENT = import_utils4.window && import_utils4.window.location ? import_utils4.window.location.host.includes("dev.") : (0, import_utils4.isDevelopment)();
|
|
494
|
+
var SERVER_URL = IS_DEVELOPMENT ? "http://localhost:8080/get" : "https://api.symbols.app/get";
|
|
495
|
+
var defaultOptions = {
|
|
496
|
+
endpoint: SERVER_URL
|
|
497
|
+
};
|
|
498
|
+
var fetchRemote = async (key, options = defaultOptions) => {
|
|
499
|
+
const baseUrl = options.endpoint || SERVER_URL;
|
|
500
|
+
const route = options.serviceRoute ? (0, import_utils4.isArray)(options.serviceRoute) ? options.serviceRoute.map((v) => v.toLowerCase() + "=true").join("&") : options.serviceRoute : "";
|
|
501
|
+
let response;
|
|
502
|
+
try {
|
|
503
|
+
response = await globalThis.fetch(baseUrl + "/?" + route, {
|
|
504
|
+
method: "GET",
|
|
505
|
+
headers: {
|
|
506
|
+
"Content-Type": "application/json",
|
|
507
|
+
"X-AppKey": key,
|
|
508
|
+
"X-Metadata": options.metadata
|
|
509
|
+
}
|
|
510
|
+
});
|
|
511
|
+
return await response.json();
|
|
512
|
+
} catch (e) {
|
|
513
|
+
if ((0, import_utils4.isFunction)(options.onError)) return options.onError(e);
|
|
514
|
+
else console.error(e);
|
|
515
|
+
}
|
|
516
|
+
};
|
|
517
|
+
var fetchProject = async (key, options) => {
|
|
518
|
+
const { editor } = options;
|
|
519
|
+
if (editor && editor.remote) {
|
|
520
|
+
const data = await fetchRemote(key, editor);
|
|
521
|
+
const evalData = IS_DEVELOPMENT || options.isDevelopment ? (0, import_utils4.deepDestringifyFunctions)(data) : (0, import_utils4.deepDestringifyFunctions)(data.releases[0]);
|
|
522
|
+
if (editor.serviceRoute) {
|
|
523
|
+
if ((0, import_utils4.isArray)(editor.serviceRoute)) {
|
|
524
|
+
editor.serviceRoute.forEach((route) => {
|
|
525
|
+
(0, import_utils4.overwriteDeep)(options[route], evalData[route.toLowerCase()]);
|
|
526
|
+
});
|
|
527
|
+
} else {
|
|
528
|
+
(0, import_utils4.overwriteDeep)(options[editor.serviceRoute], evalData);
|
|
529
|
+
}
|
|
530
|
+
} else {
|
|
531
|
+
;
|
|
532
|
+
[
|
|
533
|
+
"state",
|
|
534
|
+
"designSystem",
|
|
535
|
+
"components",
|
|
536
|
+
"snippets",
|
|
537
|
+
"pages",
|
|
538
|
+
"utils",
|
|
539
|
+
"files",
|
|
540
|
+
"packages",
|
|
541
|
+
"functions"
|
|
542
|
+
].forEach((key2) => {
|
|
543
|
+
(0, import_utils4.overwriteDeep)(options[key2], evalData[key2.toLowerCase()]);
|
|
544
|
+
});
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
return options;
|
|
548
|
+
};
|
|
549
|
+
var fetchProjectAsync = async (key, options, callback) => {
|
|
550
|
+
const { editor } = options;
|
|
551
|
+
if (editor && editor.remote) {
|
|
552
|
+
const data = await fetchRemote(key, editor);
|
|
553
|
+
const evalData = IS_DEVELOPMENT || options.isDevelopment ? (0, import_utils4.deepDestringifyFunctions)(data) : (0, import_utils4.deepDestringifyFunctions)(data.releases[0]);
|
|
554
|
+
callback(evalData);
|
|
555
|
+
}
|
|
556
|
+
};
|
|
468
557
|
var fetchSync = async (key, options) => {
|
|
469
558
|
if (key && options.editor) {
|
|
470
559
|
try {
|
|
471
|
-
if (!options.editor.async) await
|
|
560
|
+
if (!options.editor.async) await fetchProject(key, options);
|
|
472
561
|
} catch (e) {
|
|
473
562
|
console.error(e);
|
|
474
563
|
}
|
|
@@ -478,7 +567,7 @@ var Smbls = (() => {
|
|
|
478
567
|
if (key && options.editor) {
|
|
479
568
|
try {
|
|
480
569
|
if (options.editor.async) {
|
|
481
|
-
|
|
570
|
+
fetchProjectAsync(key, options, callback || ((data) => {
|
|
482
571
|
const designSystem = data.designSystem;
|
|
483
572
|
if ((0, import_utils4.isObject)(designSystem)) {
|
|
484
573
|
options.utils.init(designSystem);
|
|
@@ -496,6 +585,7 @@ var Smbls = (() => {
|
|
|
496
585
|
|
|
497
586
|
// dist/esm/src/define.js
|
|
498
587
|
var import_helmet = __require("@symbo.ls/helmet");
|
|
588
|
+
var import_fetch = __require("@symbo.ls/fetch");
|
|
499
589
|
var defaultDefine = {
|
|
500
590
|
routes: (param) => param,
|
|
501
591
|
metadata: (param, el, state) => {
|
|
@@ -505,6 +595,10 @@ var Smbls = (() => {
|
|
|
505
595
|
const resolved = (0, import_helmet.resolveMetadata)(param, el, state);
|
|
506
596
|
(0, import_helmet.applyMetadata)(resolved, doc);
|
|
507
597
|
},
|
|
598
|
+
fetch: (param, el, state, context) => {
|
|
599
|
+
if (!param) return;
|
|
600
|
+
(0, import_fetch.executeFetch)(param, el, state, context);
|
|
601
|
+
},
|
|
508
602
|
$router: async (param, el) => {
|
|
509
603
|
if (!param) return;
|
|
510
604
|
const obj = { tag: "fragment", ...param };
|
|
@@ -940,6 +1034,16 @@ var Smbls = (() => {
|
|
|
940
1034
|
injectRouterInLinkComponent: true,
|
|
941
1035
|
popState: true
|
|
942
1036
|
};
|
|
1037
|
+
var resolveRouterElement2 = (root, path) => {
|
|
1038
|
+
if (!path) return root;
|
|
1039
|
+
const parts = Array.isArray(path) ? path : path.split(".");
|
|
1040
|
+
let el = root;
|
|
1041
|
+
for (const part of parts) {
|
|
1042
|
+
if (!el || !el[part]) return null;
|
|
1043
|
+
el = el[part];
|
|
1044
|
+
}
|
|
1045
|
+
return el;
|
|
1046
|
+
};
|
|
943
1047
|
var initRouter2 = (element, context) => {
|
|
944
1048
|
if (context.router === false) return;
|
|
945
1049
|
else if (context.router === true) context.router = DEFAULT_ROUTING_OPTIONS2;
|
|
@@ -949,7 +1053,15 @@ var Smbls = (() => {
|
|
|
949
1053
|
if (!import_utils9.window.location) return;
|
|
950
1054
|
const { pathname, search, hash } = import_utils9.window.location;
|
|
951
1055
|
const url = pathname + search + hash;
|
|
952
|
-
|
|
1056
|
+
let targetEl = el;
|
|
1057
|
+
if (routerOptions.customRouterElement) {
|
|
1058
|
+
const resolved = resolveRouterElement2(el, routerOptions.customRouterElement);
|
|
1059
|
+
if (resolved) {
|
|
1060
|
+
targetEl = resolved;
|
|
1061
|
+
if (el.routes) targetEl.routes = el.routes;
|
|
1062
|
+
}
|
|
1063
|
+
}
|
|
1064
|
+
if (targetEl.routes) await (0, import_router4.router)(url, targetEl, {}, { initialRender: true });
|
|
953
1065
|
};
|
|
954
1066
|
const hasRenderRouter = element.on && !(0, import_utils9.isUndefined)(element.on.renderRouter) || !(0, import_utils9.isUndefined)(element.onRenderRouter);
|
|
955
1067
|
if (routerOptions && routerOptions.initRouter && !hasRenderRouter) {
|
|
@@ -974,10 +1086,18 @@ var Smbls = (() => {
|
|
|
974
1086
|
import_utils9.window.onpopstate = async (e) => {
|
|
975
1087
|
const { pathname, search, hash } = import_utils9.window.location;
|
|
976
1088
|
const url = pathname + search + hash;
|
|
977
|
-
|
|
1089
|
+
let targetEl = element;
|
|
1090
|
+
if (routerOptions.customRouterElement) {
|
|
1091
|
+
const resolved = resolveRouterElement2(element, routerOptions.customRouterElement);
|
|
1092
|
+
if (resolved) {
|
|
1093
|
+
targetEl = resolved;
|
|
1094
|
+
if (element.routes) targetEl.routes = element.routes;
|
|
1095
|
+
}
|
|
1096
|
+
}
|
|
1097
|
+
await targetEl.call(
|
|
978
1098
|
"router",
|
|
979
1099
|
url,
|
|
980
|
-
|
|
1100
|
+
targetEl,
|
|
981
1101
|
{},
|
|
982
1102
|
{ pushState: false, scrollToTop: false, level: 0, event: e }
|
|
983
1103
|
);
|
|
@@ -995,11 +1115,74 @@ var Smbls = (() => {
|
|
|
995
1115
|
|
|
996
1116
|
// src/fetchOnCreate.js
|
|
997
1117
|
var import_utils10 = __require("@domql/utils");
|
|
998
|
-
var
|
|
1118
|
+
var IS_DEVELOPMENT2 = import_utils10.window && import_utils10.window.location ? import_utils10.window.location.host.includes("dev.") : (0, import_utils10.isDevelopment)();
|
|
1119
|
+
var SERVER_URL2 = IS_DEVELOPMENT2 ? "http://localhost:8080/get" : "https://api.symbols.app/get";
|
|
1120
|
+
var defaultOptions2 = {
|
|
1121
|
+
endpoint: SERVER_URL2
|
|
1122
|
+
};
|
|
1123
|
+
var fetchRemote2 = async (key, options = defaultOptions2) => {
|
|
1124
|
+
const baseUrl = options.endpoint || SERVER_URL2;
|
|
1125
|
+
const route = options.serviceRoute ? (0, import_utils10.isArray)(options.serviceRoute) ? options.serviceRoute.map((v) => v.toLowerCase() + "=true").join("&") : options.serviceRoute : "";
|
|
1126
|
+
let response;
|
|
1127
|
+
try {
|
|
1128
|
+
response = await globalThis.fetch(baseUrl + "/?" + route, {
|
|
1129
|
+
method: "GET",
|
|
1130
|
+
headers: {
|
|
1131
|
+
"Content-Type": "application/json",
|
|
1132
|
+
"X-AppKey": key,
|
|
1133
|
+
"X-Metadata": options.metadata
|
|
1134
|
+
}
|
|
1135
|
+
});
|
|
1136
|
+
return await response.json();
|
|
1137
|
+
} catch (e) {
|
|
1138
|
+
if ((0, import_utils10.isFunction)(options.onError)) return options.onError(e);
|
|
1139
|
+
else console.error(e);
|
|
1140
|
+
}
|
|
1141
|
+
};
|
|
1142
|
+
var fetchProject2 = async (key, options) => {
|
|
1143
|
+
const { editor } = options;
|
|
1144
|
+
if (editor && editor.remote) {
|
|
1145
|
+
const data = await fetchRemote2(key, editor);
|
|
1146
|
+
const evalData = IS_DEVELOPMENT2 || options.isDevelopment ? (0, import_utils10.deepDestringifyFunctions)(data) : (0, import_utils10.deepDestringifyFunctions)(data.releases[0]);
|
|
1147
|
+
if (editor.serviceRoute) {
|
|
1148
|
+
if ((0, import_utils10.isArray)(editor.serviceRoute)) {
|
|
1149
|
+
editor.serviceRoute.forEach((route) => {
|
|
1150
|
+
(0, import_utils10.overwriteDeep)(options[route], evalData[route.toLowerCase()]);
|
|
1151
|
+
});
|
|
1152
|
+
} else {
|
|
1153
|
+
(0, import_utils10.overwriteDeep)(options[editor.serviceRoute], evalData);
|
|
1154
|
+
}
|
|
1155
|
+
} else {
|
|
1156
|
+
;
|
|
1157
|
+
[
|
|
1158
|
+
"state",
|
|
1159
|
+
"designSystem",
|
|
1160
|
+
"components",
|
|
1161
|
+
"snippets",
|
|
1162
|
+
"pages",
|
|
1163
|
+
"utils",
|
|
1164
|
+
"files",
|
|
1165
|
+
"packages",
|
|
1166
|
+
"functions"
|
|
1167
|
+
].forEach((key2) => {
|
|
1168
|
+
(0, import_utils10.overwriteDeep)(options[key2], evalData[key2.toLowerCase()]);
|
|
1169
|
+
});
|
|
1170
|
+
}
|
|
1171
|
+
}
|
|
1172
|
+
return options;
|
|
1173
|
+
};
|
|
1174
|
+
var fetchProjectAsync2 = async (key, options, callback) => {
|
|
1175
|
+
const { editor } = options;
|
|
1176
|
+
if (editor && editor.remote) {
|
|
1177
|
+
const data = await fetchRemote2(key, editor);
|
|
1178
|
+
const evalData = IS_DEVELOPMENT2 || options.isDevelopment ? (0, import_utils10.deepDestringifyFunctions)(data) : (0, import_utils10.deepDestringifyFunctions)(data.releases[0]);
|
|
1179
|
+
callback(evalData);
|
|
1180
|
+
}
|
|
1181
|
+
};
|
|
999
1182
|
var fetchSync2 = async (key, options) => {
|
|
1000
1183
|
if (key && options.editor) {
|
|
1001
1184
|
try {
|
|
1002
|
-
if (!options.editor.async) await (
|
|
1185
|
+
if (!options.editor.async) await fetchProject2(key, options);
|
|
1003
1186
|
} catch (e) {
|
|
1004
1187
|
console.error(e);
|
|
1005
1188
|
}
|
|
@@ -1009,7 +1192,7 @@ var Smbls = (() => {
|
|
|
1009
1192
|
if (key && options.editor) {
|
|
1010
1193
|
try {
|
|
1011
1194
|
if (options.editor.async) {
|
|
1012
|
-
(
|
|
1195
|
+
fetchProjectAsync2(key, options, callback || ((data) => {
|
|
1013
1196
|
const designSystem = data.designSystem;
|
|
1014
1197
|
if ((0, import_utils10.isObject)(designSystem)) {
|
|
1015
1198
|
options.utils.init(designSystem);
|
|
@@ -1027,6 +1210,7 @@ var Smbls = (() => {
|
|
|
1027
1210
|
|
|
1028
1211
|
// src/define.js
|
|
1029
1212
|
var import_helmet2 = __require("@symbo.ls/helmet");
|
|
1213
|
+
var import_fetch2 = __require("@symbo.ls/fetch");
|
|
1030
1214
|
var defaultDefine2 = {
|
|
1031
1215
|
routes: (param) => param,
|
|
1032
1216
|
metadata: (param, el, state) => {
|
|
@@ -1036,6 +1220,10 @@ var Smbls = (() => {
|
|
|
1036
1220
|
const resolved = (0, import_helmet2.resolveMetadata)(param, el, state);
|
|
1037
1221
|
(0, import_helmet2.applyMetadata)(resolved, doc);
|
|
1038
1222
|
},
|
|
1223
|
+
fetch: (param, el, state, context) => {
|
|
1224
|
+
if (!param) return;
|
|
1225
|
+
(0, import_fetch2.executeFetch)(param, el, state, context);
|
|
1226
|
+
},
|
|
1039
1227
|
$router: async (param, el) => {
|
|
1040
1228
|
if (!param) return;
|
|
1041
1229
|
const obj = { tag: "fragment", ...param };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "smbls",
|
|
3
|
-
"version": "3.6.
|
|
3
|
+
"version": "3.6.6",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": "https://github.com/symbo-ls/smbls",
|
|
6
6
|
"gitHead": "9fc1b79b41cdc725ca6b24aec64920a599634681",
|
|
@@ -28,21 +28,21 @@
|
|
|
28
28
|
"src"
|
|
29
29
|
],
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@symbo.ls/emotion": "^3.6.
|
|
32
|
-
"@symbo.ls/helmet": "^3.6.
|
|
33
|
-
"@domql/report": "^3.6.
|
|
34
|
-
"@domql/router": "^3.6.
|
|
35
|
-
"@domql/utils": "^3.6.
|
|
36
|
-
"@symbo.ls/cli": "^3.6.
|
|
37
|
-
"@symbo.ls/default-config": "^3.6.
|
|
38
|
-
"@symbo.ls/fetch": "^3.6.
|
|
39
|
-
"@symbo.ls/scratch": "^3.6.
|
|
40
|
-
"@symbo.ls/sync": "^3.6.
|
|
41
|
-
"@symbo.ls/uikit": "^3.6.
|
|
42
|
-
"@symbo.ls/smbls-utils": "^3.6.
|
|
43
|
-
"attrs-in-props": "^3.6.
|
|
44
|
-
"css-in-props": "^3.6.
|
|
45
|
-
"domql": "^3.6.
|
|
31
|
+
"@symbo.ls/emotion": "^3.6.6",
|
|
32
|
+
"@symbo.ls/helmet": "^3.6.6",
|
|
33
|
+
"@domql/report": "^3.6.6",
|
|
34
|
+
"@domql/router": "^3.6.6",
|
|
35
|
+
"@domql/utils": "^3.6.6",
|
|
36
|
+
"@symbo.ls/cli": "^3.6.6",
|
|
37
|
+
"@symbo.ls/default-config": "^3.6.6",
|
|
38
|
+
"@symbo.ls/fetch": "^3.6.6",
|
|
39
|
+
"@symbo.ls/scratch": "^3.6.6",
|
|
40
|
+
"@symbo.ls/sync": "^3.6.6",
|
|
41
|
+
"@symbo.ls/uikit": "^3.6.6",
|
|
42
|
+
"@symbo.ls/smbls-utils": "^3.6.6",
|
|
43
|
+
"attrs-in-props": "^3.6.6",
|
|
44
|
+
"css-in-props": "^3.6.6",
|
|
45
|
+
"domql": "^3.6.6"
|
|
46
46
|
},
|
|
47
47
|
"publishConfig": {
|
|
48
48
|
"access": "public"
|
package/src/define.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
import { resolveMetadata, applyMetadata } from '@symbo.ls/helmet'
|
|
4
|
+
import { executeFetch } from '@symbo.ls/fetch'
|
|
4
5
|
|
|
5
6
|
export const defaultDefine = {
|
|
6
7
|
routes: param => param,
|
|
@@ -13,6 +14,11 @@ export const defaultDefine = {
|
|
|
13
14
|
applyMetadata(resolved, doc)
|
|
14
15
|
},
|
|
15
16
|
|
|
17
|
+
fetch: (param, el, state, context) => {
|
|
18
|
+
if (!param) return
|
|
19
|
+
executeFetch(param, el, state, context)
|
|
20
|
+
},
|
|
21
|
+
|
|
16
22
|
$router: async (param, el) => {
|
|
17
23
|
if (!param) return
|
|
18
24
|
|
package/src/fetchOnCreate.js
CHANGED
|
@@ -1,7 +1,96 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
import { isObject } from '@domql/utils'
|
|
4
|
-
|
|
3
|
+
import { isArray, isFunction, isObject, window, isDevelopment, overwriteDeep, deepDestringifyFunctions } from '@domql/utils'
|
|
4
|
+
|
|
5
|
+
const IS_DEVELOPMENT =
|
|
6
|
+
window && window.location
|
|
7
|
+
? window.location.host.includes('dev.')
|
|
8
|
+
: isDevelopment()
|
|
9
|
+
|
|
10
|
+
const SERVER_URL = IS_DEVELOPMENT
|
|
11
|
+
? 'http://localhost:8080/get'
|
|
12
|
+
: 'https://api.symbols.app/get'
|
|
13
|
+
|
|
14
|
+
const defaultOptions = {
|
|
15
|
+
endpoint: SERVER_URL
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const fetchRemote = async (key, options = defaultOptions) => {
|
|
19
|
+
const baseUrl = options.endpoint || SERVER_URL
|
|
20
|
+
const route = options.serviceRoute
|
|
21
|
+
? isArray(options.serviceRoute)
|
|
22
|
+
? options.serviceRoute.map((v) => v.toLowerCase() + '=true').join('&')
|
|
23
|
+
: options.serviceRoute
|
|
24
|
+
: ''
|
|
25
|
+
|
|
26
|
+
let response
|
|
27
|
+
try {
|
|
28
|
+
response = await globalThis.fetch(baseUrl + '/' + '?' + route, {
|
|
29
|
+
method: 'GET',
|
|
30
|
+
headers: {
|
|
31
|
+
'Content-Type': 'application/json',
|
|
32
|
+
'X-AppKey': key,
|
|
33
|
+
'X-Metadata': options.metadata
|
|
34
|
+
}
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
return await response.json()
|
|
38
|
+
} catch (e) {
|
|
39
|
+
if (isFunction(options.onError)) return options.onError(e)
|
|
40
|
+
else console.error(e)
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const fetchProject = async (key, options) => {
|
|
45
|
+
const { editor } = options
|
|
46
|
+
|
|
47
|
+
if (editor && editor.remote) {
|
|
48
|
+
const data = await fetchRemote(key, editor)
|
|
49
|
+
const evalData =
|
|
50
|
+
IS_DEVELOPMENT || options.isDevelopment
|
|
51
|
+
? deepDestringifyFunctions(data)
|
|
52
|
+
: deepDestringifyFunctions(data.releases[0])
|
|
53
|
+
|
|
54
|
+
if (editor.serviceRoute) {
|
|
55
|
+
if (isArray(editor.serviceRoute)) {
|
|
56
|
+
editor.serviceRoute.forEach((route) => {
|
|
57
|
+
overwriteDeep(options[route], evalData[route.toLowerCase()])
|
|
58
|
+
})
|
|
59
|
+
} else {
|
|
60
|
+
overwriteDeep(options[editor.serviceRoute], evalData)
|
|
61
|
+
}
|
|
62
|
+
} else {
|
|
63
|
+
;[
|
|
64
|
+
'state',
|
|
65
|
+
'designSystem',
|
|
66
|
+
'components',
|
|
67
|
+
'snippets',
|
|
68
|
+
'pages',
|
|
69
|
+
'utils',
|
|
70
|
+
'files',
|
|
71
|
+
'packages',
|
|
72
|
+
'functions'
|
|
73
|
+
].forEach((key) => {
|
|
74
|
+
overwriteDeep(options[key], evalData[key.toLowerCase()])
|
|
75
|
+
})
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return options
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const fetchProjectAsync = async (key, options, callback) => {
|
|
83
|
+
const { editor } = options
|
|
84
|
+
|
|
85
|
+
if (editor && editor.remote) {
|
|
86
|
+
const data = await fetchRemote(key, editor)
|
|
87
|
+
const evalData =
|
|
88
|
+
IS_DEVELOPMENT || options.isDevelopment
|
|
89
|
+
? deepDestringifyFunctions(data)
|
|
90
|
+
: deepDestringifyFunctions(data.releases[0])
|
|
91
|
+
callback(evalData)
|
|
92
|
+
}
|
|
93
|
+
}
|
|
5
94
|
|
|
6
95
|
export const fetchSync = async (key, options) => {
|
|
7
96
|
if (key && options.editor) {
|
package/src/router.js
CHANGED
|
@@ -10,6 +10,17 @@ const DEFAULT_ROUTING_OPTIONS = {
|
|
|
10
10
|
popState: true
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
+
export const resolveRouterElement = (root, path) => {
|
|
14
|
+
if (!path) return root
|
|
15
|
+
const parts = Array.isArray(path) ? path : path.split('.')
|
|
16
|
+
let el = root
|
|
17
|
+
for (const part of parts) {
|
|
18
|
+
if (!el || !el[part]) return null
|
|
19
|
+
el = el[part]
|
|
20
|
+
}
|
|
21
|
+
return el
|
|
22
|
+
}
|
|
23
|
+
|
|
13
24
|
export const initRouter = (element, context) => {
|
|
14
25
|
if (context.router === false) return
|
|
15
26
|
else if (context.router === true) context.router = DEFAULT_ROUTING_OPTIONS
|
|
@@ -21,7 +32,17 @@ export const initRouter = (element, context) => {
|
|
|
21
32
|
if (!window.location) return
|
|
22
33
|
const { pathname, search, hash } = window.location
|
|
23
34
|
const url = pathname + search + hash
|
|
24
|
-
|
|
35
|
+
|
|
36
|
+
let targetEl = el
|
|
37
|
+
if (routerOptions.customRouterElement) {
|
|
38
|
+
const resolved = resolveRouterElement(el, routerOptions.customRouterElement)
|
|
39
|
+
if (resolved) {
|
|
40
|
+
targetEl = resolved
|
|
41
|
+
if (el.routes) targetEl.routes = el.routes
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (targetEl.routes) await defaultRouter(url, targetEl, {}, { initialRender: true })
|
|
25
46
|
}
|
|
26
47
|
|
|
27
48
|
const hasRenderRouter =
|
|
@@ -50,13 +71,24 @@ export const onpopstateRouter = (element, context) => {
|
|
|
50
71
|
if (!routerOptions.popState) return
|
|
51
72
|
const router =
|
|
52
73
|
context.utils && context.utils.router ? context.utils.router : defaultRouter
|
|
74
|
+
|
|
53
75
|
window.onpopstate = async e => {
|
|
54
76
|
const { pathname, search, hash } = window.location
|
|
55
77
|
const url = pathname + search + hash
|
|
56
|
-
|
|
78
|
+
|
|
79
|
+
let targetEl = element
|
|
80
|
+
if (routerOptions.customRouterElement) {
|
|
81
|
+
const resolved = resolveRouterElement(element, routerOptions.customRouterElement)
|
|
82
|
+
if (resolved) {
|
|
83
|
+
targetEl = resolved
|
|
84
|
+
if (element.routes) targetEl.routes = element.routes
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
await targetEl.call(
|
|
57
89
|
'router',
|
|
58
90
|
url,
|
|
59
|
-
|
|
91
|
+
targetEl,
|
|
60
92
|
{},
|
|
61
93
|
{ pushState: false, scrollToTop: false, level: 0, event: e }
|
|
62
94
|
)
|