@symbo.ls/create 2.11.230 → 2.11.237
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 +1911 -1644
- package/dist/cjs/index.js +10 -20
- package/dist/cjs/initEmotion.js +3 -2
- package/dist/cjs/options.js +2 -1
- package/dist/cjs/prepare.js +94 -0
- package/package.json +2 -2
- package/src/index.js +12 -16
- package/src/initEmotion.js +4 -3
- package/src/options.js +2 -1
- 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,14 +37,15 @@ 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;
|
|
44
44
|
if (!initOptions.emotion)
|
|
45
45
|
initOptions.emotion = import_emotion2.emotion;
|
|
46
46
|
const registry = options.registry || (0, import_emotion.transformDOMQLEmotion)(initOptions.emotion, options);
|
|
47
|
-
const
|
|
47
|
+
const defaultDesignSystem = (0, import_utils.deepClone)(import_default_config.default);
|
|
48
|
+
const designSystem = initOptions.useDefaultConfig ? (0, import_utils.deepMerge)(options.designSystem, defaultDesignSystem) : options.designSystem || defaultDesignSystem;
|
|
48
49
|
const scratchSystem = (0, import_init.init)(designSystem, {
|
|
49
50
|
key,
|
|
50
51
|
emotion,
|
package/dist/cjs/options.js
CHANGED
|
@@ -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
|
@@ -11,6 +11,7 @@ import { initRouter, popStateRouter } from './router'
|
|
|
11
11
|
import { fetchAsync, fetchSync } from './ferchOnCreate'
|
|
12
12
|
import { initEmotion } from './initEmotion'
|
|
13
13
|
import { applyInspectListener, applySyncDebug } from './syncExtend'
|
|
14
|
+
import { prepareComponents, prepareDesignSystem, prepareDocument, preparePages, prepareState, prepareUtils } from './prepare'
|
|
14
15
|
|
|
15
16
|
import DEFAULT_CREATE_OPTIONS from './options'
|
|
16
17
|
import DYNAMIC_JSON from '@symbo.ls/init/dynamic.json'
|
|
@@ -31,22 +32,16 @@ export const create = async (App, options = DEFAULT_CREATE_OPTIONS, optionsExter
|
|
|
31
32
|
if (appIsKey) App = {}
|
|
32
33
|
await fetchSync(key, options)
|
|
33
34
|
|
|
34
|
-
|
|
35
|
-
if (typeof (window) === 'undefined') window = {} // eslint-disable-line
|
|
36
|
-
if (!window.document) window.document = { body: {} }
|
|
37
|
-
document = window.document // eslint-disable-line
|
|
38
|
-
}
|
|
39
|
-
const doc = options.parent || options.document || document
|
|
40
|
-
const [scratcDesignhSystem, emotion, registry] = initEmotion(key, options)
|
|
35
|
+
const doc = prepareDocument(options)
|
|
41
36
|
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
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)
|
|
45
44
|
|
|
46
|
-
const pages = options.pages || {}
|
|
47
|
-
const components = options.components ? { ...uikit, ...options.components } : uikit
|
|
48
|
-
const designSystem = scratcDesignhSystem || {}
|
|
49
|
-
const snippets = { ...utils, ...utils.scratchUtils, ...(options.snippets || {}) }
|
|
50
45
|
const define = options.define || defaultDefine
|
|
51
46
|
|
|
52
47
|
const routerOptions = initRouter(App, options) // eslint-disable-line
|
|
@@ -79,6 +74,7 @@ export const create = async (App, options = DEFAULT_CREATE_OPTIONS, optionsExter
|
|
|
79
74
|
applyInspectListener(domqlApp, options)
|
|
80
75
|
popStateRouter(domqlApp, options)
|
|
81
76
|
if (options.on && options.on.create) options.on.create(domqlApp, options)
|
|
77
|
+
|
|
82
78
|
fetchAsync(domqlApp, key, {
|
|
83
79
|
utils,
|
|
84
80
|
...options
|
|
@@ -118,7 +114,7 @@ export const createSync = (App, options = DEFAULT_CREATE_OPTIONS, optionsExterna
|
|
|
118
114
|
// })
|
|
119
115
|
// }
|
|
120
116
|
|
|
121
|
-
const [
|
|
117
|
+
const [scratcDesignSystem, emotion, registry] = initEmotion(key, options)
|
|
122
118
|
|
|
123
119
|
let state
|
|
124
120
|
if (options.state) state = options.state
|
|
@@ -127,7 +123,7 @@ export const createSync = (App, options = DEFAULT_CREATE_OPTIONS, optionsExterna
|
|
|
127
123
|
|
|
128
124
|
const pages = options.pages || {}
|
|
129
125
|
const components = options.components ? { ...uikit, ...options.components } : uikit
|
|
130
|
-
const designSystem =
|
|
126
|
+
const designSystem = scratcDesignSystem || {}
|
|
131
127
|
const snippets = { ...utils, ...utils.scratchUtils, ...(options.snippets || {}) }
|
|
132
128
|
const define = options.define || defaultDefine
|
|
133
129
|
|
package/src/initEmotion.js
CHANGED
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
import { transformDOMQLEmotion } from '@domql/emotion'
|
|
4
4
|
import { emotion as defaultEmotion } from '@symbo.ls/emotion'
|
|
5
5
|
import { init } from '@symbo.ls/init'
|
|
6
|
-
import { deepClone } from '@domql/utils'
|
|
6
|
+
import { deepClone, deepMerge } from '@domql/utils'
|
|
7
7
|
|
|
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
|
|
@@ -16,7 +16,8 @@ export const initEmotion = (key, options = DESIGN_SYSTEM_OPTIONS) => {
|
|
|
16
16
|
if (!initOptions.emotion) initOptions.emotion = defaultEmotion
|
|
17
17
|
|
|
18
18
|
const registry = options.registry || transformDOMQLEmotion(initOptions.emotion, options)
|
|
19
|
-
const
|
|
19
|
+
const defaultDesignSystem = deepClone(DEFAULT_CONFIG)
|
|
20
|
+
const designSystem = initOptions.useDefaultConfig ? deepMerge(options.designSystem, defaultDesignSystem) : options.designSystem || defaultDesignSystem
|
|
20
21
|
|
|
21
22
|
const scratchSystem = init(designSystem, {
|
|
22
23
|
key,
|
package/src/options.js
CHANGED
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
|
+
}
|