@symbo.ls/create 2.11.236 → 2.11.239
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/dist/cjs/bundle/index.js +2337 -2097
- package/dist/cjs/index.js +10 -20
- package/dist/cjs/initEmotion.js +2 -2
- package/dist/cjs/prepare.js +94 -0
- package/package.json +2 -2
- package/src/index.js +12 -33
- package/src/initEmotion.js +2 -2
- package/src/prepare.js +61 -0
package/dist/cjs/index.js
CHANGED
|
@@ -42,6 +42,7 @@ var import_router = require("./router");
|
|
|
42
42
|
var import_ferchOnCreate = require("./ferchOnCreate");
|
|
43
43
|
var import_initEmotion = require("./initEmotion");
|
|
44
44
|
var import_syncExtend = require("./syncExtend");
|
|
45
|
+
var import_prepare = require("./prepare");
|
|
45
46
|
var import_options = __toESM(require("./options"), 1);
|
|
46
47
|
var import_dynamic = __toESM(require("@symbo.ls/init/dynamic.json"), 1);
|
|
47
48
|
const SYMBOLS_KEY = process.env.SYMBOLS_KEY;
|
|
@@ -56,24 +57,13 @@ const create = async (App, options = import_options.default, optionsExternalFile
|
|
|
56
57
|
if (appIsKey)
|
|
57
58
|
App = {};
|
|
58
59
|
await (0, import_ferchOnCreate.fetchSync)(key, options);
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
const doc = options.parent || options.document || document;
|
|
67
|
-
const [scratcDesignhSystem, emotion, registry] = (0, import_initEmotion.initEmotion)(key, options);
|
|
68
|
-
const state = {};
|
|
69
|
-
if (options.state)
|
|
70
|
-
(0, import_utils.deepMerge)(state, options.state);
|
|
71
|
-
if (App && App.state)
|
|
72
|
-
(0, import_utils.deepMerge)(state, App.state);
|
|
73
|
-
const pages = options.pages || {};
|
|
74
|
-
const components = options.components ? { ...uikit, ...options.components } : uikit;
|
|
75
|
-
const designSystem = scratcDesignhSystem || {};
|
|
76
|
-
const snippets = { ...utils, ...utils.scratchUtils, ...options.snippets || {} };
|
|
60
|
+
const doc = (0, import_prepare.prepareDocument)(options);
|
|
61
|
+
const [scratcDesignSystem, emotion, registry] = (0, import_prepare.prepareDesignSystem)(options, key);
|
|
62
|
+
const state = (0, import_prepare.prepareState)(options, App);
|
|
63
|
+
const pages = (0, import_prepare.preparePages)(options);
|
|
64
|
+
const components = (0, import_prepare.prepareComponents)(options);
|
|
65
|
+
const designSystem = scratcDesignSystem;
|
|
66
|
+
const snippets = (0, import_prepare.prepareUtils)(options);
|
|
77
67
|
const define = options.define || import_define.defaultDefine;
|
|
78
68
|
const routerOptions = (0, import_router.initRouter)(App, options);
|
|
79
69
|
const extend = (0, import_syncExtend.applySyncDebug)([App], options);
|
|
@@ -130,7 +120,7 @@ const createSync = (App, options = import_options.default, optionsExternalFile)
|
|
|
130
120
|
parent = options.document;
|
|
131
121
|
else
|
|
132
122
|
parent = document.body;
|
|
133
|
-
const [
|
|
123
|
+
const [scratcDesignSystem, emotion, registry] = (0, import_initEmotion.initEmotion)(key, options);
|
|
134
124
|
let state;
|
|
135
125
|
if (options.state)
|
|
136
126
|
state = options.state;
|
|
@@ -140,7 +130,7 @@ const createSync = (App, options = import_options.default, optionsExternalFile)
|
|
|
140
130
|
state = {};
|
|
141
131
|
const pages = options.pages || {};
|
|
142
132
|
const components = options.components ? { ...uikit, ...options.components } : uikit;
|
|
143
|
-
const designSystem =
|
|
133
|
+
const designSystem = scratcDesignSystem || {};
|
|
144
134
|
const snippets = { ...utils, ...utils.scratchUtils, ...options.snippets || {} };
|
|
145
135
|
const define = options.define || import_define.defaultDefine;
|
|
146
136
|
const extend = (0, import_syncExtend.applySyncDebug)([App], options);
|
package/dist/cjs/initEmotion.js
CHANGED
|
@@ -37,7 +37,7 @@ var import_init = require("@symbo.ls/init");
|
|
|
37
37
|
var import_utils = require("@domql/utils");
|
|
38
38
|
var import_options = require("./options");
|
|
39
39
|
var import_default_config = __toESM(require("@symbo.ls/default-config"), 1);
|
|
40
|
-
const initEmotion = (key, options =
|
|
40
|
+
const initEmotion = (key, options = {}) => {
|
|
41
41
|
const doc = options.parent || options.document || document;
|
|
42
42
|
const initOptions = options.initOptions || {};
|
|
43
43
|
const emotion = initOptions.emotion;
|
|
@@ -45,7 +45,7 @@ const initEmotion = (key, options = import_options.DESIGN_SYSTEM_OPTIONS) => {
|
|
|
45
45
|
initOptions.emotion = import_emotion2.emotion;
|
|
46
46
|
const registry = options.registry || (0, import_emotion.transformDOMQLEmotion)(initOptions.emotion, options);
|
|
47
47
|
const defaultDesignSystem = (0, import_utils.deepClone)(import_default_config.default);
|
|
48
|
-
const designSystem =
|
|
48
|
+
const designSystem = initOptions.useDefaultConfig ? (0, import_utils.deepMerge)(options.designSystem, defaultDesignSystem) : options.designSystem || defaultDesignSystem;
|
|
49
49
|
const scratchSystem = (0, import_init.init)(designSystem, {
|
|
50
50
|
key,
|
|
51
51
|
emotion,
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var prepare_exports = {};
|
|
30
|
+
__export(prepare_exports, {
|
|
31
|
+
UIkitWithPrefix: () => UIkitWithPrefix,
|
|
32
|
+
prepareComponents: () => prepareComponents,
|
|
33
|
+
prepareDesignSystem: () => prepareDesignSystem,
|
|
34
|
+
prepareDocument: () => prepareDocument,
|
|
35
|
+
preparePages: () => preparePages,
|
|
36
|
+
prepareState: () => prepareState,
|
|
37
|
+
prepareUtils: () => prepareUtils
|
|
38
|
+
});
|
|
39
|
+
module.exports = __toCommonJS(prepare_exports);
|
|
40
|
+
var import_utils = require("@domql/utils");
|
|
41
|
+
var import_initEmotion = require("./initEmotion");
|
|
42
|
+
var uikit = __toESM(require("@symbo.ls/uikit"), 1);
|
|
43
|
+
var utils = __toESM(require("./utilImports"), 1);
|
|
44
|
+
const checkIfKeyIsComponent = (key) => {
|
|
45
|
+
const isFirstKeyString = (0, import_utils.isString)(key);
|
|
46
|
+
if (!isFirstKeyString)
|
|
47
|
+
return;
|
|
48
|
+
const firstCharKey = key.slice(0, 1);
|
|
49
|
+
return /^[A-Z]*$/.test(firstCharKey);
|
|
50
|
+
};
|
|
51
|
+
const UIkitWithPrefix = () => {
|
|
52
|
+
const newObj = {};
|
|
53
|
+
for (const key in uikit) {
|
|
54
|
+
if (Object.prototype.hasOwnProperty.call(uikit, key)) {
|
|
55
|
+
if (checkIfKeyIsComponent(key)) {
|
|
56
|
+
newObj[`smbls.${key}`] = uikit[key];
|
|
57
|
+
} else {
|
|
58
|
+
newObj[key] = uikit[key];
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return newObj;
|
|
63
|
+
};
|
|
64
|
+
const prepareComponents = (options) => {
|
|
65
|
+
return options.components ? { ...UIkitWithPrefix(), ...options.components } : UIkitWithPrefix();
|
|
66
|
+
};
|
|
67
|
+
const prepareUtils = (options) => {
|
|
68
|
+
return { ...utils, ...utils.scratchUtils, ...options.snippets || options.utils || {} };
|
|
69
|
+
};
|
|
70
|
+
const prepareDesignSystem = (options, key) => {
|
|
71
|
+
const [scratcDesignhSystem, emotion, registry] = (0, import_initEmotion.initEmotion)(key, options);
|
|
72
|
+
return [scratcDesignhSystem, emotion, registry];
|
|
73
|
+
};
|
|
74
|
+
const prepareState = (options, App) => {
|
|
75
|
+
const state = {};
|
|
76
|
+
if (options.state)
|
|
77
|
+
utils.deepMerge(state, options.state);
|
|
78
|
+
if (App && App.state)
|
|
79
|
+
(0, import_utils.deepMerge)(state, App.state);
|
|
80
|
+
return (0, import_utils.deepCloneWithExtnd)(state);
|
|
81
|
+
};
|
|
82
|
+
const preparePages = (options) => {
|
|
83
|
+
return options.pages || {};
|
|
84
|
+
};
|
|
85
|
+
const prepareDocument = (options) => {
|
|
86
|
+
if (typeof document === "undefined") {
|
|
87
|
+
if (typeof window === "undefined")
|
|
88
|
+
window = {};
|
|
89
|
+
if (!window.document)
|
|
90
|
+
window.document = { body: {} };
|
|
91
|
+
document = window.document;
|
|
92
|
+
}
|
|
93
|
+
return options.parent || options.document || document;
|
|
94
|
+
};
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
import DOM from 'domql'
|
|
4
4
|
import { deepMerge, isObject, isString } from '@domql/utils'
|
|
5
|
-
// import { checkIfKeyIsComponent } from '@domql/element/dist/cjs/component'
|
|
6
5
|
|
|
7
6
|
import * as utils from './utilImports'
|
|
8
7
|
import * as uikit from '@symbo.ls/uikit'
|
|
@@ -12,6 +11,7 @@ import { initRouter, popStateRouter } from './router'
|
|
|
12
11
|
import { fetchAsync, fetchSync } from './ferchOnCreate'
|
|
13
12
|
import { initEmotion } from './initEmotion'
|
|
14
13
|
import { applyInspectListener, applySyncDebug } from './syncExtend'
|
|
14
|
+
import { prepareComponents, prepareDesignSystem, prepareDocument, preparePages, prepareState, prepareUtils } from './prepare'
|
|
15
15
|
|
|
16
16
|
import DEFAULT_CREATE_OPTIONS from './options'
|
|
17
17
|
import DYNAMIC_JSON from '@symbo.ls/init/dynamic.json'
|
|
@@ -23,21 +23,6 @@ const mergeWithLocalFile = (options, optionsExternalFile) => {
|
|
|
23
23
|
return deepMerge(options, rcfile)
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
// const UIkitWithPrefix = () => {
|
|
27
|
-
// const newObj = {}
|
|
28
|
-
// for (const key in uikit) {
|
|
29
|
-
// if (Object.prototype.hasOwnProperty.call(uikit, key)) {
|
|
30
|
-
// if (checkIfKeyIsComponent(key)) {
|
|
31
|
-
// newObj[`smbls.${key}`] = uikit[key]
|
|
32
|
-
// } else {
|
|
33
|
-
// newObj[key] = uikit[key]
|
|
34
|
-
// }
|
|
35
|
-
// }
|
|
36
|
-
// }
|
|
37
|
-
// console.log(newObj, uikit)
|
|
38
|
-
// return newObj
|
|
39
|
-
// }
|
|
40
|
-
|
|
41
26
|
export const create = async (App, options = DEFAULT_CREATE_OPTIONS, optionsExternalFile) => {
|
|
42
27
|
const appIsKey = isString(App)
|
|
43
28
|
options = { ...DEFAULT_CREATE_OPTIONS, ...mergeWithLocalFile(options, optionsExternalFile) }
|
|
@@ -47,23 +32,16 @@ export const create = async (App, options = DEFAULT_CREATE_OPTIONS, optionsExter
|
|
|
47
32
|
if (appIsKey) App = {}
|
|
48
33
|
await fetchSync(key, options)
|
|
49
34
|
|
|
50
|
-
|
|
51
|
-
if (typeof (window) === 'undefined') window = {} // eslint-disable-line
|
|
52
|
-
if (!window.document) window.document = { body: {} }
|
|
53
|
-
document = window.document // eslint-disable-line
|
|
54
|
-
}
|
|
55
|
-
const doc = options.parent || options.document || document
|
|
56
|
-
const [scratcDesignhSystem, emotion, registry] = initEmotion(key, options)
|
|
35
|
+
const doc = prepareDocument(options)
|
|
57
36
|
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
|
|
37
|
+
const [scratcDesignSystem, emotion, registry] = prepareDesignSystem(options, key)
|
|
38
|
+
|
|
39
|
+
const state = prepareState(options, App)
|
|
40
|
+
const pages = preparePages(options)
|
|
41
|
+
const components = prepareComponents(options)
|
|
42
|
+
const designSystem = scratcDesignSystem
|
|
43
|
+
const snippets = prepareUtils(options)
|
|
61
44
|
|
|
62
|
-
const pages = options.pages || {}
|
|
63
|
-
// const components = options.components ? { ...UIkitWithPrefix(), ...options.components } : UIkitWithPrefix()
|
|
64
|
-
const components = options.components ? { ...uikit, ...options.components } : uikit
|
|
65
|
-
const designSystem = scratcDesignhSystem || {}
|
|
66
|
-
const snippets = { ...utils, ...utils.scratchUtils, ...(options.snippets || {}) }
|
|
67
45
|
const define = options.define || defaultDefine
|
|
68
46
|
|
|
69
47
|
const routerOptions = initRouter(App, options) // eslint-disable-line
|
|
@@ -96,6 +74,7 @@ export const create = async (App, options = DEFAULT_CREATE_OPTIONS, optionsExter
|
|
|
96
74
|
applyInspectListener(domqlApp, options)
|
|
97
75
|
popStateRouter(domqlApp, options)
|
|
98
76
|
if (options.on && options.on.create) options.on.create(domqlApp, options)
|
|
77
|
+
|
|
99
78
|
fetchAsync(domqlApp, key, {
|
|
100
79
|
utils,
|
|
101
80
|
...options
|
|
@@ -135,7 +114,7 @@ export const createSync = (App, options = DEFAULT_CREATE_OPTIONS, optionsExterna
|
|
|
135
114
|
// })
|
|
136
115
|
// }
|
|
137
116
|
|
|
138
|
-
const [
|
|
117
|
+
const [scratcDesignSystem, emotion, registry] = initEmotion(key, options)
|
|
139
118
|
|
|
140
119
|
let state
|
|
141
120
|
if (options.state) state = options.state
|
|
@@ -144,7 +123,7 @@ export const createSync = (App, options = DEFAULT_CREATE_OPTIONS, optionsExterna
|
|
|
144
123
|
|
|
145
124
|
const pages = options.pages || {}
|
|
146
125
|
const components = options.components ? { ...uikit, ...options.components } : uikit
|
|
147
|
-
const designSystem =
|
|
126
|
+
const designSystem = scratcDesignSystem || {}
|
|
148
127
|
const snippets = { ...utils, ...utils.scratchUtils, ...(options.snippets || {}) }
|
|
149
128
|
const define = options.define || defaultDefine
|
|
150
129
|
|
package/src/initEmotion.js
CHANGED
|
@@ -8,7 +8,7 @@ import { deepClone, deepMerge } from '@domql/utils'
|
|
|
8
8
|
import { DESIGN_SYSTEM_OPTIONS } from './options'
|
|
9
9
|
import DEFAULT_CONFIG from '@symbo.ls/default-config'
|
|
10
10
|
|
|
11
|
-
export const initEmotion = (key, options =
|
|
11
|
+
export const initEmotion = (key, options = {}) => {
|
|
12
12
|
const doc = options.parent || options.document || document
|
|
13
13
|
const initOptions = options.initOptions || {}
|
|
14
14
|
const emotion = initOptions.emotion
|
|
@@ -17,7 +17,7 @@ export const initEmotion = (key, options = DESIGN_SYSTEM_OPTIONS) => {
|
|
|
17
17
|
|
|
18
18
|
const registry = options.registry || transformDOMQLEmotion(initOptions.emotion, options)
|
|
19
19
|
const defaultDesignSystem = deepClone(DEFAULT_CONFIG)
|
|
20
|
-
const designSystem =
|
|
20
|
+
const designSystem = initOptions.useDefaultConfig ? deepMerge(options.designSystem, defaultDesignSystem) : options.designSystem || defaultDesignSystem
|
|
21
21
|
|
|
22
22
|
const scratchSystem = init(designSystem, {
|
|
23
23
|
key,
|
package/src/prepare.js
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
import { isString, deepMerge, deepCloneWithExtnd } from '@domql/utils'
|
|
4
|
+
import { initEmotion } from './initEmotion'
|
|
5
|
+
|
|
6
|
+
import * as uikit from '@symbo.ls/uikit'
|
|
7
|
+
import * as utils from './utilImports'
|
|
8
|
+
|
|
9
|
+
const checkIfKeyIsComponent = (key) => {
|
|
10
|
+
const isFirstKeyString = isString(key)
|
|
11
|
+
if (!isFirstKeyString) return
|
|
12
|
+
const firstCharKey = key.slice(0, 1)
|
|
13
|
+
return /^[A-Z]*$/.test(firstCharKey)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const UIkitWithPrefix = () => {
|
|
17
|
+
const newObj = {}
|
|
18
|
+
for (const key in uikit) {
|
|
19
|
+
if (Object.prototype.hasOwnProperty.call(uikit, key)) {
|
|
20
|
+
if (checkIfKeyIsComponent(key)) {
|
|
21
|
+
newObj[`smbls.${key}`] = uikit[key]
|
|
22
|
+
} else {
|
|
23
|
+
newObj[key] = uikit[key]
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return newObj
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export const prepareComponents = options => {
|
|
31
|
+
return options.components ? { ...UIkitWithPrefix(), ...options.components } : UIkitWithPrefix()
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export const prepareUtils = options => {
|
|
35
|
+
return { ...utils, ...utils.scratchUtils, ...(options.snippets || options.utils || {}) }
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export const prepareDesignSystem = (options, key) => {
|
|
39
|
+
const [scratcDesignhSystem, emotion, registry] = initEmotion(key, options)
|
|
40
|
+
return [scratcDesignhSystem, emotion, registry]
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export const prepareState = (options, App) => {
|
|
44
|
+
const state = {}
|
|
45
|
+
if (options.state) utils.deepMerge(state, options.state)
|
|
46
|
+
if (App && App.state) deepMerge(state, App.state)
|
|
47
|
+
return deepCloneWithExtnd(state)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export const preparePages = options => {
|
|
51
|
+
return options.pages || {}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export const prepareDocument = options => {
|
|
55
|
+
if (typeof (document) === 'undefined') {
|
|
56
|
+
if (typeof (window) === 'undefined') window = {} // eslint-disable-line
|
|
57
|
+
if (!window.document) window.document = { body: {} }
|
|
58
|
+
document = window.document // eslint-disable-line
|
|
59
|
+
}
|
|
60
|
+
return options.parent || options.document || document
|
|
61
|
+
}
|