@symbo.ls/create 2.10.165 → 2.10.168

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 CHANGED
@@ -1,29 +1,22 @@
1
1
  'use strict'
2
2
 
3
3
  import DOM from 'domql'
4
- import { transformDOMQLEmotion } from '@domql/emotion'
5
- import { router as defaultRouter } from '@domql/router'
6
-
7
- import * as utils from '@symbo.ls/utils'
8
- import * as domqlUtils from '@domql/utils'
4
+ import { deepMerge, isObject, isString } from '@domql/utils'
9
5
 
6
+ import * as utils from './utilImports'
10
7
  import * as uikit from '@symbo.ls/uikit'
11
- import { init, updateReset } from '@symbo.ls/init'
12
- import { set } from '@symbo.ls/scratch'
13
8
 
14
- import { emotion as defaultEmotion, createEmotion } from '@symbo.ls/emotion'
15
- import { defaultDefine } from './define'
9
+ import { emotion as defaultEmotion } from '@symbo.ls/emotion'
16
10
 
17
- import DYNAMIC_JSON from '@symbo.ls/init/dynamic.json'
18
-
19
- import { deepMerge, isObject } from '@domql/utils'
11
+ import { defaultDefine } from './define'
20
12
  import { initRouter } from './router'
21
13
  import { fetchAsync, fetchSync } from './ferchOnCreate'
14
+ import { initEmotion } from './initEmotion'
22
15
 
16
+ import DYNAMIC_JSON from '@symbo.ls/init/dynamic.json'
23
17
  const SYMBOLS_KEY = process.env.SYMBOLS_KEY
24
- const smblsUtils = { init, set, updateReset }
25
18
 
26
- const defaultOptions = {
19
+ export const DEFAULT_CREATE_OPTIONS = {
27
20
  editor: {
28
21
  endpoint: 'api.symbols.app'
29
22
  },
@@ -52,29 +45,17 @@ const mergeWithLocalFile = (options, RC_FILE) => {
52
45
  return deepMerge(options, rcfile)
53
46
  }
54
47
 
55
- export const create = async (App, options = defaultOptions, RC_FILE) => {
56
- const appIsKey = domqlUtils.isString(App)
48
+ export const create = async (App, options = DEFAULT_CREATE_OPTIONS, RC_FILE) => {
49
+ const appIsKey = isString(App)
57
50
  options = mergeWithLocalFile(options, RC_FILE)
58
51
  const key = options.key || SYMBOLS_KEY || (appIsKey ? App : '')
59
52
 
60
53
  if (appIsKey) App = {}
61
54
  await fetchSync(key, options)
62
55
 
63
- const initOptions = options.initOptions || {}
64
- const emotion = initOptions.emotion || defaultEmotion || createEmotion()
65
- if (!initOptions.emotion) initOptions.emotion = emotion
66
- const emotionDefine = options.registry || transformDOMQLEmotion(initOptions.emotion, options)
67
-
68
56
  const doc = options.parent || options.document || document
69
57
 
70
- const scratchSystem = init(options.designSystem || {}, {
71
- key,
72
- emotion,
73
- verbose: options.verbose,
74
- document: doc,
75
- ...defaultOptions.designSystem,
76
- ...initOptions
77
- })
58
+ const [scratchSystem, emotion, registry] = initEmotion(key, options)
78
59
 
79
60
  initRouter(App, options.routerOptions)
80
61
 
@@ -82,8 +63,7 @@ export const create = async (App, options = defaultOptions, RC_FILE) => {
82
63
  const pages = options.pages || {}
83
64
  const components = options.components ? { ...uikit, ...options.components } : uikit
84
65
  const designSystem = scratchSystem || {}
85
- const snippets = { ...utils, ...domqlUtils, ...smblsUtils, ...(options.snippets || {})}
86
- const router = options.router || defaultRouter
66
+ const snippets = { ...utils, ...(options.snippets || {})}
87
67
  const define = options.define || defaultDefine
88
68
 
89
69
  const domqlApp = DOM.create({
@@ -99,8 +79,7 @@ export const create = async (App, options = defaultOptions, RC_FILE) => {
99
79
  snippets,
100
80
  utils: snippets,
101
81
  define,
102
- registry: emotionDefine,
103
- router,
82
+ registry,
104
83
  emotion,
105
84
  document: doc
106
85
  }
package/initEmotion.js ADDED
@@ -0,0 +1,25 @@
1
+ 'use strict'
2
+
3
+ import { transformDOMQLEmotion } from '@domql/emotion'
4
+ import { emotion as defaultEmotion } from '@symbo.ls/emotion'
5
+ import { init } from '@symbo.ls/init'
6
+ import { DEFAULT_CREATE_OPTIONS } from '.'
7
+
8
+ export const initEmotion = (key, options = DEFAULT_CREATE_OPTIONS) => {
9
+ const doc = options.parent || options.document || document
10
+ const initOptions = options.initOptions || {}
11
+ const emotion = initOptions.emotion || defaultEmotion
12
+ if (!initOptions.emotion) initOptions.emotion = emotion
13
+ const registry = options.registry || transformDOMQLEmotion(initOptions.emotion, options)
14
+
15
+ const scratchSystem = init(options.designSystem || {}, {
16
+ key,
17
+ emotion,
18
+ verbose: options.verbose,
19
+ document: doc,
20
+ ...DEFAULT_CREATE_OPTIONS.designSystem,
21
+ ...initOptions
22
+ })
23
+
24
+ return [scratchSystem, emotion, registry]
25
+ }
package/package.json CHANGED
@@ -1,16 +1,19 @@
1
1
  {
2
2
  "name": "@symbo.ls/create",
3
- "version": "2.10.165",
3
+ "version": "2.10.168",
4
4
  "license": "MIT",
5
- "gitHead": "30fbc4dc26682e15d1d7eb2b6312bce6d9f07ec2",
5
+ "gitHead": "c9937422aa846691fa6187c7a3975c313114617a",
6
6
  "source": "index.js",
7
7
  "main": "index.js",
8
8
  "dependencies": {
9
+ "@domql/cookie": "latest",
9
10
  "@domql/emotion": "latest",
11
+ "@domql/report": "latest",
10
12
  "@domql/router": "latest",
11
13
  "@domql/utils": "latest",
12
14
  "@symbo.ls/fetch": "latest",
13
15
  "@symbo.ls/init": "latest",
16
+ "@symbo.ls/scratch": "latest",
14
17
  "@symbo.ls/uikit": "latest",
15
18
  "@symbo.ls/utils": "latest",
16
19
  "domql": "latest"
package/router.js CHANGED
@@ -10,10 +10,13 @@ const DEFAULT_ROUTING_OPTIONS = {
10
10
  }
11
11
 
12
12
  export const initRouter = (root, options = DEFAULT_ROUTING_OPTIONS) => {
13
+ if (options === false) return
13
14
  if (options === true) options = DEFAULT_ROUTING_OPTIONS
14
15
 
16
+ console.log(options)
17
+
15
18
  const onRender = (el, s) => {
16
- router(el, window.location.pathname, {})
19
+ if (el.routes) router(el, window.location.pathname, {})
17
20
  }
18
21
 
19
22
  if (options.initRouter) {
package/utilImports.js ADDED
@@ -0,0 +1,12 @@
1
+ 'use strict'
2
+
3
+ export * from '@domql/utils'
4
+ export * from '@symbo.ls/utils'
5
+ export { set } from '@symbo.ls/scratch'
6
+ export * from '@symbo.ls/scratch/src/utils'
7
+ export * from '@symbo.ls/scratch/src/system'
8
+ export { init, updateReset } from '@symbo.ls/init'
9
+
10
+ export * from '@domql/cookie'
11
+ export * from '@domql/report'
12
+ export * from '@domql/router'