@symbo.ls/create 2.10.166 → 2.10.169

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