@symbo.ls/create 2.10.158 → 2.10.161
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +7 -0
- package/package.json +2 -2
- package/router.js +36 -0
package/index.js
CHANGED
|
@@ -16,6 +16,7 @@ import { defaultDefine } from './define'
|
|
|
16
16
|
|
|
17
17
|
import DYNAMIC_JSON from '@symbo.ls/init/dynamic.json'
|
|
18
18
|
import { deepMerge, isObject } from '@domql/utils'
|
|
19
|
+
import { initRouter } from './router'
|
|
19
20
|
|
|
20
21
|
const SYMBOLS_KEY = process.env.SYMBOLS_KEY
|
|
21
22
|
|
|
@@ -36,6 +37,10 @@ const defaultOptions = {
|
|
|
36
37
|
initOptions: {
|
|
37
38
|
emotion: defaultEmotion
|
|
38
39
|
},
|
|
40
|
+
router: {
|
|
41
|
+
initRouter: true,
|
|
42
|
+
injectRouterInLinkComponent: true
|
|
43
|
+
},
|
|
39
44
|
define: defaultDefine
|
|
40
45
|
}
|
|
41
46
|
|
|
@@ -74,6 +79,8 @@ export const create = async (App, options = defaultOptions, RC_FILE) => {
|
|
|
74
79
|
...initOptions
|
|
75
80
|
})
|
|
76
81
|
|
|
82
|
+
if (options.router) initRouter(App, options.router)
|
|
83
|
+
|
|
77
84
|
const domqlApp = DOM.create({
|
|
78
85
|
extend: [App],
|
|
79
86
|
routes: options.pages,
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@symbo.ls/create",
|
|
3
|
-
"version": "2.10.
|
|
3
|
+
"version": "2.10.161",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"gitHead": "
|
|
5
|
+
"gitHead": "f9ad1b5f9b5230f9219b31df4b6b4b451d5dfa8f",
|
|
6
6
|
"source": "index.js",
|
|
7
7
|
"main": "index.js",
|
|
8
8
|
"dependencies": {
|
package/router.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
import { router } from '@domql/router'
|
|
4
|
+
import { Link, RouterLink } from 'smbls'
|
|
5
|
+
import { deepMerge } from '@domql/utils'
|
|
6
|
+
|
|
7
|
+
const DEFAULT_ROUTING_OPTIONS = {
|
|
8
|
+
initRouter: true,
|
|
9
|
+
injectRouterInLinkComponent: true
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const initRouter = (root, options = DEFAULT_ROUTING_OPTIONS) => {
|
|
13
|
+
if (options === true) options = DEFAULT_ROUTING_OPTIONS
|
|
14
|
+
|
|
15
|
+
const onRender = (el, s) => {
|
|
16
|
+
router(el, window.location.pathname, {}, { updateState: false })
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (options.initRouter) {
|
|
20
|
+
if (root.on) {
|
|
21
|
+
root.on.render = onRender
|
|
22
|
+
} else {
|
|
23
|
+
root.on = {
|
|
24
|
+
render: onRender
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (options.injectRouterInLinkComponent) {
|
|
30
|
+
injectRouterInLinkComponent(options)
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export const injectRouterInLinkComponent = () => {
|
|
35
|
+
return deepMerge(Link, RouterLink)
|
|
36
|
+
}
|