smbls 3.6.8 → 3.7.3
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/README.md +125 -159
- package/dist/browser/index.js +21 -21
- package/dist/cjs/package.json +1 -1
- package/dist/cjs/src/createDomql.js +18 -0
- package/dist/cjs/src/define.js +33 -22
- package/dist/cjs/src/index.js +16 -1
- package/dist/cjs/src/init.js +8 -8
- package/dist/esm/package.json +1 -1
- package/dist/esm/src/createDomql.js +18 -0
- package/dist/esm/src/define.js +33 -22
- package/dist/esm/src/index.js +16 -1
- package/dist/esm/src/init.js +8 -8
- package/dist/iife/index.js +21 -21
- package/package.json +17 -16
- package/src/createDomql.js +25 -0
- package/src/define.js +51 -24
- package/src/index.js +5 -0
- package/src/init.js +8 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "smbls",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.7.3",
|
|
4
4
|
"license": "CC-BY-NC-4.0",
|
|
5
5
|
"repository": "https://github.com/symbo-ls/smbls",
|
|
6
6
|
"gitHead": "9fc1b79b41cdc725ca6b24aec64920a599634681",
|
|
@@ -29,21 +29,22 @@
|
|
|
29
29
|
"src"
|
|
30
30
|
],
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@symbo.ls/emotion": "^3.
|
|
33
|
-
"@symbo.ls/helmet": "^3.
|
|
34
|
-
"@domql/report": "^3.
|
|
35
|
-
"@domql/router": "^3.
|
|
36
|
-
"@domql/utils": "^3.
|
|
37
|
-
"@symbo.ls/cli": "^3.
|
|
38
|
-
"@symbo.ls/default-config": "^3.
|
|
39
|
-
"@symbo.ls/fetch": "^3.
|
|
40
|
-
"@symbo.ls/
|
|
41
|
-
"@symbo.ls/
|
|
42
|
-
"@symbo.ls/
|
|
43
|
-
"@symbo.ls/
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
32
|
+
"@symbo.ls/emotion": "^3.7.3",
|
|
33
|
+
"@symbo.ls/helmet": "^3.7.3",
|
|
34
|
+
"@domql/report": "^3.7.3",
|
|
35
|
+
"@domql/router": "^3.7.3",
|
|
36
|
+
"@domql/utils": "^3.7.3",
|
|
37
|
+
"@symbo.ls/cli": "^3.7.3",
|
|
38
|
+
"@symbo.ls/default-config": "^3.7.3",
|
|
39
|
+
"@symbo.ls/fetch": "^3.7.3",
|
|
40
|
+
"@symbo.ls/polyglot": "^3.7.3",
|
|
41
|
+
"@symbo.ls/scratch": "^3.7.3",
|
|
42
|
+
"@symbo.ls/sync": "^3.7.3",
|
|
43
|
+
"@symbo.ls/uikit": "^3.7.3",
|
|
44
|
+
"@symbo.ls/smbls-utils": "^3.7.3",
|
|
45
|
+
"attrs-in-props": "^3.7.3",
|
|
46
|
+
"css-in-props": "^3.7.3",
|
|
47
|
+
"domql": "^3.7.3"
|
|
47
48
|
},
|
|
48
49
|
"publishConfig": {
|
|
49
50
|
"access": "public"
|
package/src/createDomql.js
CHANGED
|
@@ -28,6 +28,11 @@ import {
|
|
|
28
28
|
PACKAGE_MANAGER_TO_CDN
|
|
29
29
|
} from './prepare.js'
|
|
30
30
|
|
|
31
|
+
import { polyglotPlugin } from '@symbo.ls/polyglot'
|
|
32
|
+
import { polyglotFunctions } from '@symbo.ls/polyglot/functions'
|
|
33
|
+
import { helmetPlugin } from '@symbo.ls/helmet'
|
|
34
|
+
import { fetchPlugin } from '@symbo.ls/fetch'
|
|
35
|
+
|
|
31
36
|
export const prepareContext = async (app, context = {}) => {
|
|
32
37
|
const key = (context.key = context.key || (isString(app) ? app : 'smblsapp'))
|
|
33
38
|
context.define = context.define || defaultDefine
|
|
@@ -58,6 +63,26 @@ export const prepareContext = async (app, context = {}) => {
|
|
|
58
63
|
context.defaultExtends = [uikit.Box]
|
|
59
64
|
context.snippets = context.snippets || {}
|
|
60
65
|
context.functions = context.functions || {}
|
|
66
|
+
context.plugins = context.plugins || []
|
|
67
|
+
|
|
68
|
+
// Auto-register plugins based on context config
|
|
69
|
+
const hasPlugin = (name) => context.plugins.some(p => p.name === name)
|
|
70
|
+
|
|
71
|
+
if (context.polyglot && !hasPlugin('polyglot')) {
|
|
72
|
+
context.plugins.push(polyglotPlugin)
|
|
73
|
+
for (const k in polyglotFunctions) {
|
|
74
|
+
if (!(k in context.functions)) context.functions[k] = polyglotFunctions[k]
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (!hasPlugin('helmet')) {
|
|
79
|
+
context.plugins.push(helmetPlugin)
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (context.fetch && !hasPlugin('fetch')) {
|
|
83
|
+
context.plugins.push(fetchPlugin)
|
|
84
|
+
}
|
|
85
|
+
|
|
61
86
|
return context
|
|
62
87
|
}
|
|
63
88
|
|
package/src/define.js
CHANGED
|
@@ -3,35 +3,62 @@
|
|
|
3
3
|
import { resolveMetadata, applyMetadata } from '@symbo.ls/helmet'
|
|
4
4
|
import { executeFetch } from '@symbo.ls/fetch'
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
const fetchHandler = (param, el, state, context) => {
|
|
7
|
+
if (!param) return
|
|
8
|
+
executeFetch(param, el, state, context)
|
|
9
|
+
}
|
|
8
10
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
const metadataHandler = (param, el, state) => {
|
|
12
|
+
if (!param) return
|
|
13
|
+
const doc = el.context?.document || (typeof document !== 'undefined' && document)
|
|
14
|
+
if (!doc) return
|
|
15
|
+
const resolved = resolveMetadata(param, el, state)
|
|
16
|
+
applyMetadata(resolved, doc)
|
|
17
|
+
}
|
|
16
18
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
executeFetch(param, el, state, context)
|
|
20
|
-
},
|
|
19
|
+
const routerHandler = async (param, el) => {
|
|
20
|
+
if (!param) return
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
if (!param) return
|
|
22
|
+
const obj = { tag: 'fragment', ...param }
|
|
24
23
|
|
|
25
|
-
|
|
24
|
+
const set = async () => {
|
|
25
|
+
await el.set(obj, { preventDefineUpdate: '$router' })
|
|
26
|
+
}
|
|
26
27
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
if (el.props && el.props.lazyLoad) {
|
|
29
|
+
window.requestAnimationFrame(set)
|
|
30
|
+
} else await set()
|
|
30
31
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
} else await set()
|
|
32
|
+
return obj
|
|
33
|
+
}
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
export const defaultDefine = {
|
|
36
|
+
routes: param => param,
|
|
37
|
+
metadata: metadataHandler,
|
|
38
|
+
fetch: fetchHandler,
|
|
39
|
+
$router: routerHandler
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Create a custom define object with optional features.
|
|
44
|
+
*
|
|
45
|
+
* @param {Object} opts
|
|
46
|
+
* @param {boolean} [opts.fetch=true] - Include fetch handler
|
|
47
|
+
* @param {boolean} [opts.metadata=true] - Include metadata/helmet handler
|
|
48
|
+
* @param {boolean} [opts.router=true] - Include router handler
|
|
49
|
+
* @returns {Object} define handlers
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* // Disable fetch:
|
|
53
|
+
* context.define = createDefine({ fetch: false })
|
|
54
|
+
*
|
|
55
|
+
* // Only router:
|
|
56
|
+
* context.define = createDefine({ fetch: false, metadata: false })
|
|
57
|
+
*/
|
|
58
|
+
export const createDefine = (opts = {}) => {
|
|
59
|
+
const define = { routes: param => param }
|
|
60
|
+
if (opts.metadata !== false) define.metadata = metadataHandler
|
|
61
|
+
if (opts.fetch !== false) define.fetch = fetchHandler
|
|
62
|
+
if (opts.router !== false) define.$router = routerHandler
|
|
63
|
+
return define
|
|
37
64
|
}
|
package/src/index.js
CHANGED
|
@@ -103,3 +103,8 @@ export default create
|
|
|
103
103
|
|
|
104
104
|
export * from './init.js'
|
|
105
105
|
export { DEFAULT_CONTEXT, DESIGN_SYSTEM_OPTIONS, ROUTER_OPTIONS } from './options.js'
|
|
106
|
+
export { defaultDefine, createDefine } from './define.js'
|
|
107
|
+
|
|
108
|
+
// Polyglot i18n plugin
|
|
109
|
+
export { polyglotPlugin, translate, setLang, getActiveLang, getLanguages, loadTranslations, upsertTranslation, initPolyglot, getLocalStateLang } from '@symbo.ls/polyglot'
|
|
110
|
+
export { polyglotFunctions } from '@symbo.ls/polyglot/functions'
|
package/src/init.js
CHANGED
|
@@ -53,15 +53,15 @@ export const init = (config, options = SET_OPTIONS) => {
|
|
|
53
53
|
{ newConfig: options.newConfig }
|
|
54
54
|
)
|
|
55
55
|
|
|
56
|
-
const FontFace = getFontFaceString(conf.font
|
|
56
|
+
const FontFace = getFontFaceString(conf.font, conf.files)
|
|
57
57
|
|
|
58
58
|
const useReset = conf.useReset
|
|
59
59
|
const useVariable = conf.useVariable
|
|
60
60
|
const useFontImport = conf.useFontImport
|
|
61
61
|
const useSvgSprite = conf.useSvgSprite
|
|
62
|
-
const hasSvgs = config.svg
|
|
62
|
+
const hasSvgs = config.svg
|
|
63
63
|
const useIconSprite = conf.useIconSprite
|
|
64
|
-
const hasIcons = config.icons
|
|
64
|
+
const hasIcons = config.icons
|
|
65
65
|
|
|
66
66
|
if (useFontImport) emotion.injectGlobal(FontFace)
|
|
67
67
|
if (useVariable) {
|
|
@@ -81,10 +81,10 @@ export const init = (config, options = SET_OPTIONS) => {
|
|
|
81
81
|
emotion.injectGlobal(themeStyles)
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
|
-
if (useReset) emotion.injectGlobal(conf.reset
|
|
84
|
+
if (useReset) emotion.injectGlobal(conf.reset)
|
|
85
85
|
|
|
86
86
|
// Register all ANIMATION entries as global @keyframes
|
|
87
|
-
const animations = conf.animation
|
|
87
|
+
const animations = conf.animation
|
|
88
88
|
if (animations) {
|
|
89
89
|
const keyframesCSS = {}
|
|
90
90
|
for (const name in animations) {
|
|
@@ -94,10 +94,10 @@ export const init = (config, options = SET_OPTIONS) => {
|
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
if (hasSvgs || useSvgSprite)
|
|
97
|
-
appendSVGSprite(conf.svg
|
|
97
|
+
appendSVGSprite(conf.svg, { document: options.document })
|
|
98
98
|
|
|
99
99
|
if (hasIcons || useIconSprite)
|
|
100
|
-
appendSvgIconsSprite(conf.icons
|
|
100
|
+
appendSvgIconsSprite(conf.icons, { document: options.document })
|
|
101
101
|
|
|
102
102
|
return conf
|
|
103
103
|
}
|
|
@@ -126,7 +126,7 @@ export const reinit = (config, options = UPDATE_OPTIONS) => {
|
|
|
126
126
|
}
|
|
127
127
|
emotion.injectGlobal(themeStyles)
|
|
128
128
|
}
|
|
129
|
-
emotion.injectGlobal(conf.
|
|
129
|
+
emotion.injectGlobal(conf.reset)
|
|
130
130
|
}
|
|
131
131
|
return conf
|
|
132
132
|
}
|