@symbo.ls/create 2.10.161 → 2.10.163
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 +26 -0
- package/index.js +26 -30
- package/package.json +7 -2
- package/router.js +3 -3
package/ferchOnCreate.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
import { fetchProject, fetchStateAsync } from "@symbo.ls/fetch"
|
|
4
|
+
|
|
5
|
+
export const fetchSync = async (key, options) => {
|
|
6
|
+
if (key && options.editor) {
|
|
7
|
+
try {
|
|
8
|
+
if (!options.async) await fetchProject(key, options)
|
|
9
|
+
} catch (e) {
|
|
10
|
+
console.error(e)
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const fetchAsync = (app, key, options, callback) => {
|
|
16
|
+
if (key && options.editor) {
|
|
17
|
+
try {
|
|
18
|
+
if (options.editor.async) fetchStateAsync(key, options, (data) => {
|
|
19
|
+
app.state.update(data)
|
|
20
|
+
})
|
|
21
|
+
} catch (e) {
|
|
22
|
+
console.error(e)
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
package/index.js
CHANGED
|
@@ -1,22 +1,23 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
import DOM from 'domql'
|
|
4
|
-
import { transformDOMQLEmotion } from 'domql/
|
|
5
|
-
import { router } from 'domql/
|
|
4
|
+
import { transformDOMQLEmotion } from '@domql/emotion'
|
|
5
|
+
import { router as defaultRouter } from '@domql/router'
|
|
6
6
|
|
|
7
7
|
import * as utils from '@symbo.ls/utils'
|
|
8
8
|
import * as domqlUtils from '@domql/utils'
|
|
9
9
|
|
|
10
10
|
import * as uikit from '@symbo.ls/uikit'
|
|
11
11
|
import { init } from '@symbo.ls/init'
|
|
12
|
-
import { fetchStateAsync, fetchProject } from '@symbo.ls/fetch'
|
|
13
12
|
|
|
14
13
|
import { emotion as defaultEmotion, createEmotion } from '@symbo.ls/emotion'
|
|
15
14
|
import { defaultDefine } from './define'
|
|
16
15
|
|
|
17
16
|
import DYNAMIC_JSON from '@symbo.ls/init/dynamic.json'
|
|
17
|
+
|
|
18
18
|
import { deepMerge, isObject } from '@domql/utils'
|
|
19
19
|
import { initRouter } from './router'
|
|
20
|
+
import { fetchAsync, fetchSync } from './ferchOnCreate'
|
|
20
21
|
|
|
21
22
|
const SYMBOLS_KEY = process.env.SYMBOLS_KEY
|
|
22
23
|
|
|
@@ -55,22 +56,16 @@ export const create = async (App, options = defaultOptions, RC_FILE) => {
|
|
|
55
56
|
const key = options.key || SYMBOLS_KEY || (appIsKey ? App : '')
|
|
56
57
|
|
|
57
58
|
if (appIsKey) App = {}
|
|
58
|
-
|
|
59
|
-
try {
|
|
60
|
-
if (!options.async) await fetchProject(key, options)
|
|
61
|
-
} catch (e) {
|
|
62
|
-
console.error(e)
|
|
63
|
-
}
|
|
64
|
-
}
|
|
59
|
+
await fetchSync(key, options)
|
|
65
60
|
|
|
66
61
|
const initOptions = options.initOptions || {}
|
|
67
62
|
const emotion = initOptions.emotion || defaultEmotion || createEmotion()
|
|
68
63
|
if (!initOptions.emotion) initOptions.emotion = emotion
|
|
69
64
|
const emotionDefine = options.registry || transformDOMQLEmotion(initOptions.emotion, options)
|
|
70
65
|
|
|
71
|
-
const doc = options.parent || document
|
|
66
|
+
const doc = options.parent || options.document || document
|
|
72
67
|
|
|
73
|
-
const
|
|
68
|
+
const scratchSystem = init(options.designSystem || {}, {
|
|
74
69
|
key,
|
|
75
70
|
emotion,
|
|
76
71
|
verbose: options.verbose,
|
|
@@ -79,22 +74,31 @@ export const create = async (App, options = defaultOptions, RC_FILE) => {
|
|
|
79
74
|
...initOptions
|
|
80
75
|
})
|
|
81
76
|
|
|
82
|
-
|
|
77
|
+
initRouter(App, options.routerOptions)
|
|
78
|
+
|
|
79
|
+
const state = options.state || {}
|
|
80
|
+
const pages = options.pages || {}
|
|
81
|
+
const components = options.components ? { ...uikit, ...options.components } : uikit
|
|
82
|
+
const designSystem = scratchSystem || {}
|
|
83
|
+
const snippets = { ...utils, ...domqlUtils, ...(options.snippets || {})}
|
|
84
|
+
const router = options.router || defaultRouter
|
|
85
|
+
const define = options.define || defaultDefine
|
|
83
86
|
|
|
84
87
|
const domqlApp = DOM.create({
|
|
85
88
|
extend: [App],
|
|
86
89
|
routes: options.pages,
|
|
87
|
-
state
|
|
90
|
+
state,
|
|
88
91
|
context: {
|
|
89
92
|
key,
|
|
90
|
-
components
|
|
91
|
-
state
|
|
92
|
-
pages
|
|
93
|
-
designSystem
|
|
94
|
-
|
|
95
|
-
|
|
93
|
+
components,
|
|
94
|
+
state,
|
|
95
|
+
pages,
|
|
96
|
+
designSystem,
|
|
97
|
+
snippets,
|
|
98
|
+
utils: snippets,
|
|
99
|
+
define,
|
|
96
100
|
registry: emotionDefine,
|
|
97
|
-
router
|
|
101
|
+
router,
|
|
98
102
|
emotion,
|
|
99
103
|
document: doc
|
|
100
104
|
}
|
|
@@ -104,15 +108,7 @@ export const create = async (App, options = defaultOptions, RC_FILE) => {
|
|
|
104
108
|
...options.domqlOptions
|
|
105
109
|
})
|
|
106
110
|
|
|
107
|
-
|
|
108
|
-
try {
|
|
109
|
-
if (options.editor.async) fetchStateAsync(key, options, (data) => {
|
|
110
|
-
domqlApp.state.update(data)
|
|
111
|
-
})
|
|
112
|
-
} catch (e) {
|
|
113
|
-
console.error(e)
|
|
114
|
-
}
|
|
115
|
-
}
|
|
111
|
+
fetchAsync(domqlApp)
|
|
116
112
|
|
|
117
113
|
return domqlApp
|
|
118
114
|
}
|
package/package.json
CHANGED
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@symbo.ls/create",
|
|
3
|
-
"version": "2.10.
|
|
3
|
+
"version": "2.10.163",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"gitHead": "
|
|
5
|
+
"gitHead": "9b654d48bb8ba26e3b1b7095b5ed7b813b61e1e0",
|
|
6
6
|
"source": "index.js",
|
|
7
7
|
"main": "index.js",
|
|
8
8
|
"dependencies": {
|
|
9
|
+
"@domql/emotion": "latest",
|
|
10
|
+
"@domql/router": "latest",
|
|
9
11
|
"@domql/utils": "latest",
|
|
10
12
|
"@symbo.ls/fetch": "latest",
|
|
11
13
|
"@symbo.ls/init": "latest",
|
|
12
14
|
"@symbo.ls/uikit": "latest",
|
|
13
15
|
"@symbo.ls/utils": "latest",
|
|
14
16
|
"domql": "latest"
|
|
17
|
+
},
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"@babel/core": "^7.12.0"
|
|
15
20
|
}
|
|
16
21
|
}
|
package/router.js
CHANGED
|
@@ -13,15 +13,15 @@ export const initRouter = (root, options = DEFAULT_ROUTING_OPTIONS) => {
|
|
|
13
13
|
if (options === true) options = DEFAULT_ROUTING_OPTIONS
|
|
14
14
|
|
|
15
15
|
const onRender = (el, s) => {
|
|
16
|
-
router(el, window.location.pathname, {}
|
|
16
|
+
router(el, window.location.pathname, {})
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
if (options.initRouter) {
|
|
20
20
|
if (root.on) {
|
|
21
|
-
root.on.
|
|
21
|
+
root.on.renderRouter = onRender
|
|
22
22
|
} else {
|
|
23
23
|
root.on = {
|
|
24
|
-
|
|
24
|
+
renderRouter: onRender
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
}
|