@symbo.ls/create 2.10.171 → 2.10.172
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/ferchOnCreate.js +2 -3
- package/index.js +19 -12
- package/initEmotion.js +2 -1
- package/options.js +3 -5
- package/package.json +3 -2
- package/router.js +25 -12
- package/syncExtend.js +18 -0
package/ferchOnCreate.js
CHANGED
|
@@ -15,9 +15,8 @@ export const fetchSync = async (key, options) => {
|
|
|
15
15
|
export const fetchAsync = (app, key, options, callback) => {
|
|
16
16
|
if (key && options.editor) {
|
|
17
17
|
try {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
})
|
|
18
|
+
const defaultCallback = (data) => app.state.update(data)
|
|
19
|
+
if (options.editor.async) fetchStateAsync(key, options, callback || defaultCallback)
|
|
21
20
|
} catch (e) {
|
|
22
21
|
console.error(e)
|
|
23
22
|
}
|
package/index.js
CHANGED
|
@@ -6,44 +6,48 @@ import { deepMerge, isObject, isString } from '@domql/utils'
|
|
|
6
6
|
import * as utils from './utilImports'
|
|
7
7
|
import * as uikit from '@symbo.ls/uikit'
|
|
8
8
|
|
|
9
|
+
import { inspectOnKey } from '@symbo.ls/socket-ui'
|
|
9
10
|
import { defaultDefine } from './define'
|
|
10
|
-
import { initRouter } from './router'
|
|
11
|
+
import { initRouter, popStateRouter } from './router'
|
|
11
12
|
import { fetchAsync, fetchSync } from './ferchOnCreate'
|
|
12
13
|
import { initEmotion } from './initEmotion'
|
|
14
|
+
import { applySyncDebug } from './syncExtend'
|
|
13
15
|
|
|
14
|
-
import
|
|
16
|
+
import DEFAULT_CREATE_OPTIONS from './options'
|
|
15
17
|
import DYNAMIC_JSON from '@symbo.ls/init/dynamic.json'
|
|
16
18
|
|
|
17
19
|
const SYMBOLS_KEY = process.env.SYMBOLS_KEY
|
|
18
20
|
|
|
19
|
-
const mergeWithLocalFile = (options,
|
|
20
|
-
const rcfile = isObject(
|
|
21
|
+
const mergeWithLocalFile = (options, optionsExternalFile) => {
|
|
22
|
+
const rcfile = isObject(optionsExternalFile) ? optionsExternalFile : DYNAMIC_JSON || {}
|
|
21
23
|
return deepMerge(options, rcfile)
|
|
22
24
|
}
|
|
23
25
|
|
|
24
|
-
export const create = async (App, options = DEFAULT_CREATE_OPTIONS,
|
|
26
|
+
export const create = async (App, options = DEFAULT_CREATE_OPTIONS, optionsExternalFile) => {
|
|
25
27
|
const appIsKey = isString(App)
|
|
26
|
-
options = mergeWithLocalFile(options,
|
|
28
|
+
options = mergeWithLocalFile(options, optionsExternalFile)
|
|
29
|
+
|
|
27
30
|
const key = options.key || SYMBOLS_KEY || (appIsKey ? App : '')
|
|
28
31
|
|
|
29
32
|
if (appIsKey) App = {}
|
|
30
33
|
await fetchSync(key, options)
|
|
31
34
|
|
|
32
35
|
const doc = options.parent || options.document || document
|
|
33
|
-
|
|
34
36
|
const [scratchSystem, emotion, registry] = initEmotion(key, options)
|
|
35
37
|
|
|
36
|
-
initRouter(App, options
|
|
38
|
+
const router = initRouter(App, options)
|
|
37
39
|
|
|
38
40
|
const state = options.state || {}
|
|
39
|
-
const pages =
|
|
41
|
+
const pages = options.pages || {}
|
|
40
42
|
const components = options.components ? { ...uikit, ...options.components } : uikit
|
|
41
43
|
const designSystem = scratchSystem || {}
|
|
42
|
-
const snippets = { ...utils, ...(options.snippets || {})}
|
|
44
|
+
const snippets = { ...utils, ...(options.snippets || {}) }
|
|
43
45
|
const define = options.define || defaultDefine
|
|
44
46
|
|
|
47
|
+
const extend = applySyncDebug([App], options)
|
|
48
|
+
|
|
45
49
|
const domqlApp = DOM.create({
|
|
46
|
-
extend
|
|
50
|
+
extend,
|
|
47
51
|
routes: options.pages,
|
|
48
52
|
state,
|
|
49
53
|
context: {
|
|
@@ -65,7 +69,10 @@ export const create = async (App, options = DEFAULT_CREATE_OPTIONS, RC_FILE) =>
|
|
|
65
69
|
...options.domqlOptions
|
|
66
70
|
})
|
|
67
71
|
|
|
68
|
-
|
|
72
|
+
applyKeyDebugListener(domqlApp, options)
|
|
73
|
+
popStateRouter(domqlApp, options)
|
|
74
|
+
|
|
75
|
+
fetchAsync(domqlApp, key, options)
|
|
69
76
|
|
|
70
77
|
return domqlApp
|
|
71
78
|
}
|
package/initEmotion.js
CHANGED
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
import { transformDOMQLEmotion } from '@domql/emotion'
|
|
4
4
|
import { emotion as defaultEmotion } from '@symbo.ls/emotion'
|
|
5
5
|
import { init } from '@symbo.ls/init'
|
|
6
|
-
|
|
6
|
+
|
|
7
|
+
import DEFAULT_CREATE_OPTIONS from './options'
|
|
7
8
|
|
|
8
9
|
export const initEmotion = (key, options = DEFAULT_CREATE_OPTIONS) => {
|
|
9
10
|
const doc = options.parent || options.document || document
|
package/options.js
CHANGED
|
@@ -3,10 +3,8 @@
|
|
|
3
3
|
import { defaultDefine } from './define'
|
|
4
4
|
import { emotion as defaultEmotion } from '@symbo.ls/emotion'
|
|
5
5
|
|
|
6
|
-
export
|
|
7
|
-
editor: {
|
|
8
|
-
endpoint: 'api.symbols.app'
|
|
9
|
-
},
|
|
6
|
+
export default {
|
|
7
|
+
editor: {},
|
|
10
8
|
state: {},
|
|
11
9
|
pages: {},
|
|
12
10
|
designSystem: {
|
|
@@ -18,7 +16,7 @@ export const DEFAULT_CREATE_OPTIONS = {
|
|
|
18
16
|
},
|
|
19
17
|
components: {},
|
|
20
18
|
initOptions: {
|
|
21
|
-
emotion: defaultEmotion
|
|
19
|
+
emotion: defaultEmotion,
|
|
22
20
|
},
|
|
23
21
|
router: {
|
|
24
22
|
initRouter: true,
|
package/package.json
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@symbo.ls/create",
|
|
3
|
-
"version": "2.10.
|
|
3
|
+
"version": "2.10.172",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"gitHead": "
|
|
5
|
+
"gitHead": "c5542d156c687366e76194813bf2d5f0227e8396",
|
|
6
6
|
"source": "index.js",
|
|
7
7
|
"main": "index.js",
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"@domql/cookie": "latest",
|
|
10
10
|
"@domql/emotion": "latest",
|
|
11
|
+
"@domql/env": "latest",
|
|
11
12
|
"@domql/report": "latest",
|
|
12
13
|
"@domql/router": "latest",
|
|
13
14
|
"@domql/utils": "latest",
|
package/router.js
CHANGED
|
@@ -1,23 +1,28 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
import { router } from '@domql/router'
|
|
4
|
-
import { Link, RouterLink } from '
|
|
3
|
+
import { router as defaultRouter } from '@domql/router'
|
|
4
|
+
import { Link, RouterLink } from '@symbo.ls/uikit'
|
|
5
5
|
import { deepMerge } from '@domql/utils'
|
|
6
6
|
|
|
7
7
|
const DEFAULT_ROUTING_OPTIONS = {
|
|
8
8
|
initRouter: true,
|
|
9
|
-
injectRouterInLinkComponent: true
|
|
9
|
+
injectRouterInLinkComponent: true,
|
|
10
|
+
popState: true
|
|
10
11
|
}
|
|
11
12
|
|
|
12
|
-
export const initRouter = (root, options
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
export const initRouter = (root, options) => {
|
|
14
|
+
const routerOptions = options.routerOptions || DEFAULT_ROUTING_OPTIONS
|
|
15
|
+
|
|
16
|
+
if (routerOptions === false) return
|
|
17
|
+
if (routerOptions === true) routerOptions = DEFAULT_ROUTING_OPTIONS
|
|
18
|
+
|
|
19
|
+
const router = options.snippets && options.snippets.router || defaultRouter
|
|
15
20
|
|
|
16
21
|
const onRender = (el, s) => {
|
|
17
22
|
if (el.routes) router(el, window.location.pathname, {})
|
|
18
23
|
}
|
|
19
24
|
|
|
20
|
-
if (
|
|
25
|
+
if (routerOptions.initRouter) {
|
|
21
26
|
if (root.on) {
|
|
22
27
|
root.on.renderRouter = onRender
|
|
23
28
|
} else {
|
|
@@ -27,11 +32,19 @@ export const initRouter = (root, options = DEFAULT_ROUTING_OPTIONS) => {
|
|
|
27
32
|
}
|
|
28
33
|
}
|
|
29
34
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
35
|
+
injectRouterInLinkComponent(routerOptions)
|
|
36
|
+
|
|
37
|
+
return router
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export const popStateRouter = (root, options) => {
|
|
41
|
+
const routerOptions = options.routerOptions || DEFAULT_ROUTING_OPTIONS
|
|
42
|
+
if (!routerOptions.popState) return
|
|
43
|
+
const router = options.snippets && options.snippets.router || defaultRouter
|
|
44
|
+
window.onpopstate = e => router(root, window.location.pathname, {}, 0, false)
|
|
33
45
|
}
|
|
34
46
|
|
|
35
|
-
export const injectRouterInLinkComponent = () => {
|
|
36
|
-
|
|
47
|
+
export const injectRouterInLinkComponent = (routerOptions) => {
|
|
48
|
+
if (routerOptions.injectRouterInLinkComponent)
|
|
49
|
+
return deepMerge(Link, RouterLink)
|
|
37
50
|
}
|
package/syncExtend.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
import { Sync, DevFocus, inspectOnKey } from '@symbo.ls/socket-ui'
|
|
4
|
+
import { isProduction, isTest } from '@domql/env'
|
|
5
|
+
|
|
6
|
+
const { NODE_ENV } = process.env
|
|
7
|
+
|
|
8
|
+
export const applySyncDebug = (extend, options) => {
|
|
9
|
+
if (options.debug) extend.push[DevFocus]
|
|
10
|
+
if (options.socket) extend.push[Sync]
|
|
11
|
+
return extend
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const applyKeyDebugListener = (root, options) => {
|
|
15
|
+
if (options.debug) inspectOnKey(root)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const extend = isProduction(NODE_ENV) || isTest(NODE_ENV) [Sync, DevFocus]
|