smbls 3.1.2 → 3.2.7
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/bin/smbls.js +2 -0
- package/dist/cjs/index.js +2 -3
- package/dist/cjs/src/createDomql.js +110 -0
- package/dist/cjs/src/define.js +38 -0
- package/dist/cjs/src/fetchOnCreate.js +54 -0
- package/dist/cjs/src/index.js +109 -0
- package/dist/cjs/src/init.js +127 -0
- package/dist/cjs/src/options.js +57 -0
- package/dist/cjs/src/prepare.js +296 -0
- package/dist/cjs/src/router.js +84 -0
- package/dist/cjs/src/syncExtend.js +70 -0
- package/dist/cjs/src/utilImports.js +35 -0
- package/dist/esm/index.js +2 -3
- package/dist/esm/src/createDomql.js +96 -0
- package/dist/esm/src/define.js +18 -0
- package/dist/esm/src/fetchOnCreate.js +34 -0
- package/dist/esm/src/index.js +78 -0
- package/dist/esm/src/init.js +103 -0
- package/dist/esm/src/options.js +37 -0
- package/dist/esm/src/prepare.js +273 -0
- package/dist/esm/src/router.js +64 -0
- package/dist/esm/src/syncExtend.js +50 -0
- package/dist/esm/src/utilImports.js +14 -0
- package/dist/iife/index.js +740 -0
- package/index.js +2 -6
- package/package.json +37 -26
- package/src/createDomql.js +107 -0
- package/src/define.js +22 -0
- package/src/fetchOnCreate.js +34 -0
- package/src/index.js +106 -0
- package/src/init.js +121 -0
- package/src/options.js +37 -0
- package/src/prepare.js +307 -0
- package/src/router.js +73 -0
- package/src/syncExtend.js +50 -0
- package/src/utilImports.js +10 -0
- package/dist/cjs/package.json +0 -4
package/bin/smbls.js
ADDED
package/dist/cjs/index.js
CHANGED
|
@@ -17,11 +17,10 @@ var index_exports = {};
|
|
|
17
17
|
module.exports = __toCommonJS(index_exports);
|
|
18
18
|
__reExport(index_exports, require("@domql/utils"), module.exports);
|
|
19
19
|
__reExport(index_exports, require("attrs-in-props"), module.exports);
|
|
20
|
-
__reExport(index_exports, require("@symbo.ls/create"), module.exports);
|
|
21
20
|
__reExport(index_exports, require("css-in-props"), module.exports);
|
|
22
21
|
__reExport(index_exports, require("@symbo.ls/default-config"), module.exports);
|
|
23
22
|
__reExport(index_exports, require("@symbo.ls/emotion"), module.exports);
|
|
24
|
-
__reExport(index_exports, require("@symbo.ls/init"), module.exports);
|
|
25
23
|
__reExport(index_exports, require("@symbo.ls/scratch"), module.exports);
|
|
26
24
|
__reExport(index_exports, require("@symbo.ls/uikit"), module.exports);
|
|
27
|
-
__reExport(index_exports, require("@symbo.ls/utils"), module.exports);
|
|
25
|
+
__reExport(index_exports, require("@symbo.ls/smbls-utils"), module.exports);
|
|
26
|
+
__reExport(index_exports, require("./src/index.js"), module.exports);
|
|
@@ -0,0 +1,110 @@
|
|
|
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 createDomql_exports = {};
|
|
30
|
+
__export(createDomql_exports, {
|
|
31
|
+
createDomqlElement: () => createDomqlElement,
|
|
32
|
+
prepareContext: () => prepareContext
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(createDomql_exports);
|
|
35
|
+
var import_domql = __toESM(require("domql"), 1);
|
|
36
|
+
var uikit = __toESM(require("@symbo.ls/uikit"), 1);
|
|
37
|
+
var import_css_in_props = require("css-in-props");
|
|
38
|
+
var import_utils = require("@domql/utils");
|
|
39
|
+
var import_element = require("@domql/element");
|
|
40
|
+
var import_define = require("./define.js");
|
|
41
|
+
var import_router = require("./router.js");
|
|
42
|
+
var import_syncExtend = require("./syncExtend.js");
|
|
43
|
+
var import_prepare = require("./prepare.js");
|
|
44
|
+
const prepareContext = async (app, context = {}) => {
|
|
45
|
+
const key = context.key = context.key || ((0, import_utils.isString)(app) ? app : "smblsapp");
|
|
46
|
+
context.define = context.define || import_define.defaultDefine;
|
|
47
|
+
context.cssPropsRegistry = import_css_in_props.CSS_PROPS_REGISTRY;
|
|
48
|
+
context.window = (0, import_prepare.prepareWindow)(context);
|
|
49
|
+
if (context.sharedLibraries && context.sharedLibraries.length) {
|
|
50
|
+
(0, import_prepare.prepareSharedLibs)(context);
|
|
51
|
+
}
|
|
52
|
+
const [scratcDesignSystem, emotion, registry] = (0, import_prepare.prepareDesignSystem)(
|
|
53
|
+
key,
|
|
54
|
+
context
|
|
55
|
+
);
|
|
56
|
+
context.designSystem = scratcDesignSystem;
|
|
57
|
+
context.registry = registry;
|
|
58
|
+
context.emotion = emotion;
|
|
59
|
+
const state = (0, import_prepare.prepareState)(app, context);
|
|
60
|
+
context.state = state;
|
|
61
|
+
context.pages = (0, import_prepare.preparePages)(app, context);
|
|
62
|
+
context.components = (0, import_prepare.prepareComponents)(context);
|
|
63
|
+
context.utils = (0, import_prepare.prepareUtils)(context);
|
|
64
|
+
if (import_prepare.PACKAGE_MANAGER_TO_CDN[context.packageManager]) {
|
|
65
|
+
context.dependencies = await (0, import_prepare.prepareDependencies)(context);
|
|
66
|
+
}
|
|
67
|
+
context.methods = (0, import_prepare.prepareMethods)(context);
|
|
68
|
+
context.routerOptions = (0, import_router.initRouter)(app, context);
|
|
69
|
+
context.defaultExtends = [uikit.Box];
|
|
70
|
+
context.snippets = context.snippets || {};
|
|
71
|
+
context.functions = context.functions || {};
|
|
72
|
+
return context;
|
|
73
|
+
};
|
|
74
|
+
const createDomqlElement = async (app, ctx) => {
|
|
75
|
+
if (!(0, import_utils.isObject)(ctx)) ctx = {};
|
|
76
|
+
if ((0, import_utils.isNode)(app)) {
|
|
77
|
+
app = {};
|
|
78
|
+
ctx.parent = app;
|
|
79
|
+
} else if ((0, import_utils.isString)(app)) {
|
|
80
|
+
app = {};
|
|
81
|
+
ctx.key = app;
|
|
82
|
+
} else if (!(0, import_utils.isObject)(app)) {
|
|
83
|
+
app = {};
|
|
84
|
+
}
|
|
85
|
+
await prepareContext(app, ctx);
|
|
86
|
+
app.extends = (0, import_syncExtend.initializeExtend)(app, ctx);
|
|
87
|
+
app.routes = ctx.pages;
|
|
88
|
+
app.state = ctx.state;
|
|
89
|
+
app.context = ctx;
|
|
90
|
+
app.data = app.data || {};
|
|
91
|
+
app.data.frameListeners = (0, import_element.initAnimationFrame)(ctx);
|
|
92
|
+
await (0, import_prepare.prepareRequire)(
|
|
93
|
+
{
|
|
94
|
+
functions: ctx.functions,
|
|
95
|
+
utils: ctx.utils,
|
|
96
|
+
snippets: ctx.snippets,
|
|
97
|
+
...ctx.files
|
|
98
|
+
},
|
|
99
|
+
ctx
|
|
100
|
+
);
|
|
101
|
+
(0, import_syncExtend.initializeSync)(app, ctx);
|
|
102
|
+
(0, import_syncExtend.initializeNotifications)(app, ctx);
|
|
103
|
+
const parentNode = ctx.parent || ctx.document.body;
|
|
104
|
+
const domqlCreate = import_domql.default.default && import_domql.default.default.create || import_domql.default.create;
|
|
105
|
+
const smblsApp = await domqlCreate(app, parentNode, ctx.key, {
|
|
106
|
+
verbose: ctx.verbose,
|
|
107
|
+
...ctx.domqlOptions
|
|
108
|
+
});
|
|
109
|
+
return smblsApp;
|
|
110
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var define_exports = {};
|
|
20
|
+
__export(define_exports, {
|
|
21
|
+
defaultDefine: () => defaultDefine
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(define_exports);
|
|
24
|
+
const defaultDefine = {
|
|
25
|
+
routes: (param) => param,
|
|
26
|
+
// deps: (param, el) => param || el.parent.deps,
|
|
27
|
+
$router: async (param, el) => {
|
|
28
|
+
if (!param) return;
|
|
29
|
+
const obj = { tag: "fragment", ...param };
|
|
30
|
+
const set = async () => {
|
|
31
|
+
await el.set(obj, { preventDefineUpdate: "$router" });
|
|
32
|
+
};
|
|
33
|
+
if (el.props && el.props.lazyLoad) {
|
|
34
|
+
window.requestAnimationFrame(set);
|
|
35
|
+
} else await set();
|
|
36
|
+
return obj;
|
|
37
|
+
}
|
|
38
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var fetchOnCreate_exports = {};
|
|
20
|
+
__export(fetchOnCreate_exports, {
|
|
21
|
+
fetchAsync: () => fetchAsync,
|
|
22
|
+
fetchSync: () => fetchSync
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(fetchOnCreate_exports);
|
|
25
|
+
var import_utils = require("@domql/utils");
|
|
26
|
+
var import_fetch = require("@symbo.ls/fetch");
|
|
27
|
+
const fetchSync = async (key, options) => {
|
|
28
|
+
if (key && options.editor) {
|
|
29
|
+
try {
|
|
30
|
+
if (!options.editor.async) await (0, import_fetch.fetchProject)(key, options);
|
|
31
|
+
} catch (e) {
|
|
32
|
+
console.error(e);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
const fetchAsync = (app, key, options, callback) => {
|
|
37
|
+
if (key && options.editor) {
|
|
38
|
+
try {
|
|
39
|
+
if (options.editor.async) {
|
|
40
|
+
(0, import_fetch.fetchProjectAsync)(key, options, callback || ((data) => {
|
|
41
|
+
const designSystem = data.designSystem;
|
|
42
|
+
if ((0, import_utils.isObject)(designSystem)) {
|
|
43
|
+
options.utils.init(designSystem);
|
|
44
|
+
}
|
|
45
|
+
if ((0, import_utils.isObject)(data.state)) {
|
|
46
|
+
app.state.set(data.state);
|
|
47
|
+
}
|
|
48
|
+
}));
|
|
49
|
+
}
|
|
50
|
+
} catch (e) {
|
|
51
|
+
console.error(e);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
};
|
|
@@ -0,0 +1,109 @@
|
|
|
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 __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
var src_exports = {};
|
|
31
|
+
__export(src_exports, {
|
|
32
|
+
DEFAULT_CONTEXT: () => import_options2.DEFAULT_CONTEXT,
|
|
33
|
+
DESIGN_SYSTEM_OPTIONS: () => import_options2.DESIGN_SYSTEM_OPTIONS,
|
|
34
|
+
ROUTER_OPTIONS: () => import_options2.ROUTER_OPTIONS,
|
|
35
|
+
create: () => create,
|
|
36
|
+
createAsync: () => createAsync,
|
|
37
|
+
createSkeleton: () => createSkeleton,
|
|
38
|
+
createSync: () => createSync,
|
|
39
|
+
default: () => src_default
|
|
40
|
+
});
|
|
41
|
+
module.exports = __toCommonJS(src_exports);
|
|
42
|
+
var import_utils = require("@domql/utils");
|
|
43
|
+
var utils = __toESM(require("./utilImports.js"), 1);
|
|
44
|
+
var import_router = require("./router.js");
|
|
45
|
+
var import_fetchOnCreate = require("./fetchOnCreate.js");
|
|
46
|
+
var import_options = __toESM(require("./options.js"), 1);
|
|
47
|
+
var import_dynamic = __toESM(require("../dynamic.json"), 1);
|
|
48
|
+
var import_createDomql = require("./createDomql.js");
|
|
49
|
+
__reExport(src_exports, require("./init.js"), module.exports);
|
|
50
|
+
var import_options2 = require("./options.js");
|
|
51
|
+
const mergeWithLocalFile = (options, optionsExternalFile) => (0, import_utils.deepMerge)(
|
|
52
|
+
options,
|
|
53
|
+
(0, import_utils.isObject)(optionsExternalFile) ? optionsExternalFile : import_dynamic.default || {}
|
|
54
|
+
);
|
|
55
|
+
const create = (App, options = import_options.default, optionsExternalFile) => {
|
|
56
|
+
const redefinedOptions = {
|
|
57
|
+
...import_options.default,
|
|
58
|
+
...mergeWithLocalFile(options, optionsExternalFile)
|
|
59
|
+
};
|
|
60
|
+
const domqlApp = (0, import_createDomql.createDomqlElement)(App, redefinedOptions).then((App2) => {
|
|
61
|
+
(0, import_router.onpopstateRouter)(App2, redefinedOptions);
|
|
62
|
+
if (redefinedOptions.on && redefinedOptions.on.create)
|
|
63
|
+
redefinedOptions.on.create(
|
|
64
|
+
domqlApp,
|
|
65
|
+
domqlApp.state,
|
|
66
|
+
domqlApp.context,
|
|
67
|
+
redefinedOptions
|
|
68
|
+
);
|
|
69
|
+
});
|
|
70
|
+
return domqlApp;
|
|
71
|
+
};
|
|
72
|
+
const createAsync = (App, options = import_options.default, optionsExternalFile) => {
|
|
73
|
+
const domqlApp = create(App, options, optionsExternalFile);
|
|
74
|
+
const redefinedOptions = {
|
|
75
|
+
...import_options.default,
|
|
76
|
+
...mergeWithLocalFile(options, optionsExternalFile)
|
|
77
|
+
};
|
|
78
|
+
const key = redefinedOptions.key;
|
|
79
|
+
(0, import_fetchOnCreate.fetchAsync)(domqlApp, key, { utils, ...redefinedOptions });
|
|
80
|
+
return domqlApp;
|
|
81
|
+
};
|
|
82
|
+
const createSync = async (App, options = import_options.default, optionsExternalFile) => {
|
|
83
|
+
const redefinedOptions = {
|
|
84
|
+
...import_options.default,
|
|
85
|
+
...mergeWithLocalFile(options, optionsExternalFile)
|
|
86
|
+
};
|
|
87
|
+
const key = options.key;
|
|
88
|
+
await (0, import_fetchOnCreate.fetchSync)(key, redefinedOptions);
|
|
89
|
+
const domqlApp = await (0, import_createDomql.createDomqlElement)(App, redefinedOptions);
|
|
90
|
+
if (redefinedOptions.on && redefinedOptions.on.create)
|
|
91
|
+
await redefinedOptions.on.create(
|
|
92
|
+
domqlApp,
|
|
93
|
+
domqlApp.state,
|
|
94
|
+
domqlApp.context,
|
|
95
|
+
redefinedOptions
|
|
96
|
+
);
|
|
97
|
+
return domqlApp;
|
|
98
|
+
};
|
|
99
|
+
const createSkeleton = (App = {}, options = import_options.default, optionsExternalFile) => {
|
|
100
|
+
return create(
|
|
101
|
+
{
|
|
102
|
+
deps: { isUndefined: import_utils.isUndefined },
|
|
103
|
+
...App
|
|
104
|
+
},
|
|
105
|
+
(0, import_utils.deepMerge)({ domqlOptions: { onlyResolveExtends: true } }, options),
|
|
106
|
+
optionsExternalFile
|
|
107
|
+
);
|
|
108
|
+
};
|
|
109
|
+
var src_default = create;
|
|
@@ -0,0 +1,127 @@
|
|
|
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 init_exports = {};
|
|
30
|
+
__export(init_exports, {
|
|
31
|
+
DYNAMIC_JSON: () => import_dynamic.default,
|
|
32
|
+
applyCSS: () => applyCSS,
|
|
33
|
+
init: () => init,
|
|
34
|
+
reinit: () => reinit,
|
|
35
|
+
setClass: () => setClass,
|
|
36
|
+
updateVars: () => updateVars
|
|
37
|
+
});
|
|
38
|
+
module.exports = __toCommonJS(init_exports);
|
|
39
|
+
var import_scratch = require("@symbo.ls/scratch");
|
|
40
|
+
var import_utils = require("@domql/utils");
|
|
41
|
+
var import_emotion = require("@symbo.ls/emotion");
|
|
42
|
+
var import_dynamic = __toESM(require("../dynamic.json"), 1);
|
|
43
|
+
const CONFIG = (0, import_scratch.getActiveConfig)();
|
|
44
|
+
const mergeWithLocalFile = (config = CONFIG, options) => {
|
|
45
|
+
const rcfile = (0, import_utils.isObject)(options.localFile) ? options.localFile : import_dynamic.default || {};
|
|
46
|
+
const clonedFile = (0, import_utils.deepClone)(rcfile.designSystem || {});
|
|
47
|
+
return (0, import_utils.deepMerge)(config, clonedFile);
|
|
48
|
+
};
|
|
49
|
+
const SET_OPTIONS = {
|
|
50
|
+
emotion: import_emotion.emotion,
|
|
51
|
+
useVariable: true,
|
|
52
|
+
useReset: true,
|
|
53
|
+
useFontImport: true,
|
|
54
|
+
useIconSprite: true,
|
|
55
|
+
useDocumentTheme: true,
|
|
56
|
+
useSvgSprite: true
|
|
57
|
+
};
|
|
58
|
+
const init = (config, options = SET_OPTIONS) => {
|
|
59
|
+
const emotion = options.emotion || import_emotion.emotion;
|
|
60
|
+
const resultConfig = mergeWithLocalFile(config || {}, options);
|
|
61
|
+
const conf = (0, import_scratch.set)(
|
|
62
|
+
{
|
|
63
|
+
verbose: options.verbose,
|
|
64
|
+
useReset: options.useReset,
|
|
65
|
+
useFontImport: options.useFontImport,
|
|
66
|
+
useVariable: options.useVariable,
|
|
67
|
+
useSvgSprite: options.useSvgSprite,
|
|
68
|
+
useDocumentTheme: options.useDocumentTheme,
|
|
69
|
+
useIconSprite: options.useIconSprite,
|
|
70
|
+
useDefaultConfig: options.useDefaultConfig,
|
|
71
|
+
globalTheme: options.globalTheme,
|
|
72
|
+
...resultConfig
|
|
73
|
+
},
|
|
74
|
+
{ newConfig: options.newConfig }
|
|
75
|
+
);
|
|
76
|
+
const FontFace = (0, import_scratch.getFontFaceString)(conf.FONT);
|
|
77
|
+
const useReset = conf.useReset;
|
|
78
|
+
const useVariable = conf.useVariable;
|
|
79
|
+
const useFontImport = conf.useFontImport;
|
|
80
|
+
const useSvgSprite = conf.useSvgSprite;
|
|
81
|
+
const hasSvgs = config.svg || config.SVG;
|
|
82
|
+
const useIconSprite = conf.useIconSprite;
|
|
83
|
+
const hasIcons = config.icons || config.ICONS;
|
|
84
|
+
if (useFontImport) emotion.injectGlobal(FontFace);
|
|
85
|
+
if (useVariable) emotion.injectGlobal({ ":root": conf.CSS_VARS });
|
|
86
|
+
if (useReset) emotion.injectGlobal(conf.RESET);
|
|
87
|
+
if (conf.ANIMATION) {
|
|
88
|
+
const keyframesCSS = {};
|
|
89
|
+
for (const name in conf.ANIMATION) {
|
|
90
|
+
keyframesCSS[`@keyframes ${name}`] = conf.ANIMATION[name];
|
|
91
|
+
}
|
|
92
|
+
emotion.injectGlobal(keyframesCSS);
|
|
93
|
+
}
|
|
94
|
+
if (hasSvgs) (0, import_scratch.appendSVGSprite)(hasSvgs, { document: options.document });
|
|
95
|
+
else if (useSvgSprite)
|
|
96
|
+
(0, import_scratch.appendSVGSprite)(conf.SVG, { document: options.document });
|
|
97
|
+
if (hasIcons) (0, import_scratch.appendSvgIconsSprite)(hasIcons, { document: options.document });
|
|
98
|
+
else if (useIconSprite)
|
|
99
|
+
(0, import_scratch.appendSvgIconsSprite)(conf.ICONS, { document: options.document });
|
|
100
|
+
return conf;
|
|
101
|
+
};
|
|
102
|
+
const UPDATE_OPTIONS = {
|
|
103
|
+
emotion: import_emotion.emotion
|
|
104
|
+
};
|
|
105
|
+
const reinit = (config, options = UPDATE_OPTIONS) => {
|
|
106
|
+
const emotion = options.emotion || import_emotion.emotion;
|
|
107
|
+
const resultConfig = mergeWithLocalFile(config || {}, options);
|
|
108
|
+
const conf = (0, import_scratch.set)({
|
|
109
|
+
verbose: false,
|
|
110
|
+
...resultConfig
|
|
111
|
+
});
|
|
112
|
+
if (!options.preventInject) {
|
|
113
|
+
emotion.injectGlobal({ ":root": conf.CSS_VARS });
|
|
114
|
+
emotion.injectGlobal(conf.RESET);
|
|
115
|
+
}
|
|
116
|
+
return conf;
|
|
117
|
+
};
|
|
118
|
+
const applyCSS = (styles, options = UPDATE_OPTIONS) => {
|
|
119
|
+
const emotion = options.emotion || import_emotion.emotion;
|
|
120
|
+
emotion.injectGlobal(styles);
|
|
121
|
+
};
|
|
122
|
+
const updateVars = (config, options = UPDATE_OPTIONS) => {
|
|
123
|
+
const emotion = options.emotion || import_emotion.emotion;
|
|
124
|
+
emotion.injectGlobal({ ":root": config.CSS_VARS });
|
|
125
|
+
};
|
|
126
|
+
const setClass = (props, options = UPDATE_OPTIONS) => {
|
|
127
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var options_exports = {};
|
|
20
|
+
__export(options_exports, {
|
|
21
|
+
CREATE_OPTIONS: () => CREATE_OPTIONS,
|
|
22
|
+
DEFAULT_CONTEXT: () => DEFAULT_CONTEXT,
|
|
23
|
+
DESIGN_SYSTEM_OPTIONS: () => DESIGN_SYSTEM_OPTIONS,
|
|
24
|
+
ROUTER_OPTIONS: () => ROUTER_OPTIONS,
|
|
25
|
+
default: () => options_default
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(options_exports);
|
|
28
|
+
var import_define = require("./define.js");
|
|
29
|
+
var import_package = require("../package.json");
|
|
30
|
+
const DESIGN_SYSTEM_OPTIONS = {
|
|
31
|
+
useReset: true,
|
|
32
|
+
useVariable: true,
|
|
33
|
+
useIconSprite: true,
|
|
34
|
+
useSvgSprite: true,
|
|
35
|
+
useDocumentTheme: true,
|
|
36
|
+
useDefaultIcons: true,
|
|
37
|
+
useFontImport: true,
|
|
38
|
+
useDefaultConfig: true
|
|
39
|
+
};
|
|
40
|
+
const ROUTER_OPTIONS = {
|
|
41
|
+
initRouter: true,
|
|
42
|
+
popState: true,
|
|
43
|
+
injectRouterInLinkComponent: true
|
|
44
|
+
};
|
|
45
|
+
const DEFAULT_CONTEXT = {
|
|
46
|
+
...DESIGN_SYSTEM_OPTIONS,
|
|
47
|
+
router: ROUTER_OPTIONS,
|
|
48
|
+
version: import_package.version
|
|
49
|
+
};
|
|
50
|
+
const CREATE_OPTIONS = {
|
|
51
|
+
state: {},
|
|
52
|
+
pages: {},
|
|
53
|
+
components: {},
|
|
54
|
+
router: ROUTER_OPTIONS,
|
|
55
|
+
define: import_define.defaultDefine
|
|
56
|
+
};
|
|
57
|
+
var options_default = CREATE_OPTIONS;
|