smbls 3.7.0 → 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/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/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/dist/cjs/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"smbls","version":"3.
|
|
1
|
+
{"name":"smbls","version":"3.7.0"}
|
|
@@ -41,6 +41,10 @@ var import_define = require("./define.js");
|
|
|
41
41
|
var import_router = require("./router.js");
|
|
42
42
|
var import_syncExtend = require("./syncExtend.js");
|
|
43
43
|
var import_prepare = require("./prepare.js");
|
|
44
|
+
var import_polyglot = require("@symbo.ls/polyglot");
|
|
45
|
+
var import_functions = require("@symbo.ls/polyglot/functions");
|
|
46
|
+
var import_helmet = require("@symbo.ls/helmet");
|
|
47
|
+
var import_fetch = require("@symbo.ls/fetch");
|
|
44
48
|
const prepareContext = async (app, context = {}) => {
|
|
45
49
|
const key = context.key = context.key || ((0, import_utils.isString)(app) ? app : "smblsapp");
|
|
46
50
|
context.define = context.define || import_define.defaultDefine;
|
|
@@ -69,6 +73,20 @@ const prepareContext = async (app, context = {}) => {
|
|
|
69
73
|
context.defaultExtends = [uikit.Box];
|
|
70
74
|
context.snippets = context.snippets || {};
|
|
71
75
|
context.functions = context.functions || {};
|
|
76
|
+
context.plugins = context.plugins || [];
|
|
77
|
+
const hasPlugin = (name) => context.plugins.some((p) => p.name === name);
|
|
78
|
+
if (context.polyglot && !hasPlugin("polyglot")) {
|
|
79
|
+
context.plugins.push(import_polyglot.polyglotPlugin);
|
|
80
|
+
for (const k in import_functions.polyglotFunctions) {
|
|
81
|
+
if (!(k in context.functions)) context.functions[k] = import_functions.polyglotFunctions[k];
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
if (!hasPlugin("helmet")) {
|
|
85
|
+
context.plugins.push(import_helmet.helmetPlugin);
|
|
86
|
+
}
|
|
87
|
+
if (context.fetch && !hasPlugin("fetch")) {
|
|
88
|
+
context.plugins.push(import_fetch.fetchPlugin);
|
|
89
|
+
}
|
|
72
90
|
return context;
|
|
73
91
|
};
|
|
74
92
|
const createDomqlElement = async (app, ctx) => {
|
package/dist/cjs/src/define.js
CHANGED
|
@@ -18,33 +18,44 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var define_exports = {};
|
|
20
20
|
__export(define_exports, {
|
|
21
|
+
createDefine: () => createDefine,
|
|
21
22
|
defaultDefine: () => defaultDefine
|
|
22
23
|
});
|
|
23
24
|
module.exports = __toCommonJS(define_exports);
|
|
24
25
|
var import_helmet = require("@symbo.ls/helmet");
|
|
25
26
|
var import_fetch = require("@symbo.ls/fetch");
|
|
27
|
+
const fetchHandler = (param, el, state, context) => {
|
|
28
|
+
if (!param) return;
|
|
29
|
+
(0, import_fetch.executeFetch)(param, el, state, context);
|
|
30
|
+
};
|
|
31
|
+
const metadataHandler = (param, el, state) => {
|
|
32
|
+
if (!param) return;
|
|
33
|
+
const doc = el.context?.document || typeof document !== "undefined" && document;
|
|
34
|
+
if (!doc) return;
|
|
35
|
+
const resolved = (0, import_helmet.resolveMetadata)(param, el, state);
|
|
36
|
+
(0, import_helmet.applyMetadata)(resolved, doc);
|
|
37
|
+
};
|
|
38
|
+
const routerHandler = async (param, el) => {
|
|
39
|
+
if (!param) return;
|
|
40
|
+
const obj = { tag: "fragment", ...param };
|
|
41
|
+
const set = async () => {
|
|
42
|
+
await el.set(obj, { preventDefineUpdate: "$router" });
|
|
43
|
+
};
|
|
44
|
+
if (el.props && el.props.lazyLoad) {
|
|
45
|
+
window.requestAnimationFrame(set);
|
|
46
|
+
} else await set();
|
|
47
|
+
return obj;
|
|
48
|
+
};
|
|
26
49
|
const defaultDefine = {
|
|
27
50
|
routes: (param) => param,
|
|
28
|
-
metadata:
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
},
|
|
39
|
-
$router: async (param, el) => {
|
|
40
|
-
if (!param) return;
|
|
41
|
-
const obj = { tag: "fragment", ...param };
|
|
42
|
-
const set = async () => {
|
|
43
|
-
await el.set(obj, { preventDefineUpdate: "$router" });
|
|
44
|
-
};
|
|
45
|
-
if (el.props && el.props.lazyLoad) {
|
|
46
|
-
window.requestAnimationFrame(set);
|
|
47
|
-
} else await set();
|
|
48
|
-
return obj;
|
|
49
|
-
}
|
|
51
|
+
metadata: metadataHandler,
|
|
52
|
+
fetch: fetchHandler,
|
|
53
|
+
$router: routerHandler
|
|
54
|
+
};
|
|
55
|
+
const createDefine = (opts = {}) => {
|
|
56
|
+
const define = { routes: (param) => param };
|
|
57
|
+
if (opts.metadata !== false) define.metadata = metadataHandler;
|
|
58
|
+
if (opts.fetch !== false) define.fetch = fetchHandler;
|
|
59
|
+
if (opts.router !== false) define.$router = routerHandler;
|
|
60
|
+
return define;
|
|
50
61
|
};
|
package/dist/cjs/src/index.js
CHANGED
|
@@ -34,9 +34,21 @@ __export(src_exports, {
|
|
|
34
34
|
ROUTER_OPTIONS: () => import_options2.ROUTER_OPTIONS,
|
|
35
35
|
create: () => create,
|
|
36
36
|
createAsync: () => createAsync,
|
|
37
|
+
createDefine: () => import_define.createDefine,
|
|
37
38
|
createSkeleton: () => createSkeleton,
|
|
38
39
|
createSync: () => createSync,
|
|
39
|
-
default: () => src_default
|
|
40
|
+
default: () => src_default,
|
|
41
|
+
defaultDefine: () => import_define.defaultDefine,
|
|
42
|
+
getActiveLang: () => import_polyglot.getActiveLang,
|
|
43
|
+
getLanguages: () => import_polyglot.getLanguages,
|
|
44
|
+
getLocalStateLang: () => import_polyglot.getLocalStateLang,
|
|
45
|
+
initPolyglot: () => import_polyglot.initPolyglot,
|
|
46
|
+
loadTranslations: () => import_polyglot.loadTranslations,
|
|
47
|
+
polyglotFunctions: () => import_functions.polyglotFunctions,
|
|
48
|
+
polyglotPlugin: () => import_polyglot.polyglotPlugin,
|
|
49
|
+
setLang: () => import_polyglot.setLang,
|
|
50
|
+
translate: () => import_polyglot.translate,
|
|
51
|
+
upsertTranslation: () => import_polyglot.upsertTranslation
|
|
40
52
|
});
|
|
41
53
|
module.exports = __toCommonJS(src_exports);
|
|
42
54
|
var import_utils = require("@domql/utils");
|
|
@@ -47,6 +59,9 @@ var import_options = __toESM(require("./options.js"), 1);
|
|
|
47
59
|
var import_createDomql = require("./createDomql.js");
|
|
48
60
|
__reExport(src_exports, require("./init.js"), module.exports);
|
|
49
61
|
var import_options2 = require("./options.js");
|
|
62
|
+
var import_define = require("./define.js");
|
|
63
|
+
var import_polyglot = require("@symbo.ls/polyglot");
|
|
64
|
+
var import_functions = require("@symbo.ls/polyglot/functions");
|
|
50
65
|
const mergeWithLocalFile = (options, optionsExternalFile) => (0, import_utils.deepMerge)(
|
|
51
66
|
options,
|
|
52
67
|
(0, import_utils.isObject)(optionsExternalFile) ? optionsExternalFile : {}
|
package/dist/esm/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"smbls","version":"3.
|
|
1
|
+
{"name":"smbls","version":"3.7.0"}
|
|
@@ -23,6 +23,10 @@ import {
|
|
|
23
23
|
prepareSharedLibs,
|
|
24
24
|
PACKAGE_MANAGER_TO_CDN
|
|
25
25
|
} from "./prepare.js";
|
|
26
|
+
import { polyglotPlugin } from "@symbo.ls/polyglot";
|
|
27
|
+
import { polyglotFunctions } from "@symbo.ls/polyglot/functions";
|
|
28
|
+
import { helmetPlugin } from "@symbo.ls/helmet";
|
|
29
|
+
import { fetchPlugin } from "@symbo.ls/fetch";
|
|
26
30
|
const prepareContext = async (app, context = {}) => {
|
|
27
31
|
const key = context.key = context.key || (isString(app) ? app : "smblsapp");
|
|
28
32
|
context.define = context.define || defaultDefine;
|
|
@@ -51,6 +55,20 @@ const prepareContext = async (app, context = {}) => {
|
|
|
51
55
|
context.defaultExtends = [uikit.Box];
|
|
52
56
|
context.snippets = context.snippets || {};
|
|
53
57
|
context.functions = context.functions || {};
|
|
58
|
+
context.plugins = context.plugins || [];
|
|
59
|
+
const hasPlugin = (name) => context.plugins.some((p) => p.name === name);
|
|
60
|
+
if (context.polyglot && !hasPlugin("polyglot")) {
|
|
61
|
+
context.plugins.push(polyglotPlugin);
|
|
62
|
+
for (const k in polyglotFunctions) {
|
|
63
|
+
if (!(k in context.functions)) context.functions[k] = polyglotFunctions[k];
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
if (!hasPlugin("helmet")) {
|
|
67
|
+
context.plugins.push(helmetPlugin);
|
|
68
|
+
}
|
|
69
|
+
if (context.fetch && !hasPlugin("fetch")) {
|
|
70
|
+
context.plugins.push(fetchPlugin);
|
|
71
|
+
}
|
|
54
72
|
return context;
|
|
55
73
|
};
|
|
56
74
|
const createDomqlElement = async (app, ctx) => {
|
package/dist/esm/src/define.js
CHANGED
|
@@ -1,30 +1,41 @@
|
|
|
1
1
|
import { resolveMetadata, applyMetadata } from "@symbo.ls/helmet";
|
|
2
2
|
import { executeFetch } from "@symbo.ls/fetch";
|
|
3
|
+
const fetchHandler = (param, el, state, context) => {
|
|
4
|
+
if (!param) return;
|
|
5
|
+
executeFetch(param, el, state, context);
|
|
6
|
+
};
|
|
7
|
+
const metadataHandler = (param, el, state) => {
|
|
8
|
+
if (!param) return;
|
|
9
|
+
const doc = el.context?.document || typeof document !== "undefined" && document;
|
|
10
|
+
if (!doc) return;
|
|
11
|
+
const resolved = resolveMetadata(param, el, state);
|
|
12
|
+
applyMetadata(resolved, doc);
|
|
13
|
+
};
|
|
14
|
+
const routerHandler = async (param, el) => {
|
|
15
|
+
if (!param) return;
|
|
16
|
+
const obj = { tag: "fragment", ...param };
|
|
17
|
+
const set = async () => {
|
|
18
|
+
await el.set(obj, { preventDefineUpdate: "$router" });
|
|
19
|
+
};
|
|
20
|
+
if (el.props && el.props.lazyLoad) {
|
|
21
|
+
window.requestAnimationFrame(set);
|
|
22
|
+
} else await set();
|
|
23
|
+
return obj;
|
|
24
|
+
};
|
|
3
25
|
const defaultDefine = {
|
|
4
26
|
routes: (param) => param,
|
|
5
|
-
metadata:
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
},
|
|
16
|
-
$router: async (param, el) => {
|
|
17
|
-
if (!param) return;
|
|
18
|
-
const obj = { tag: "fragment", ...param };
|
|
19
|
-
const set = async () => {
|
|
20
|
-
await el.set(obj, { preventDefineUpdate: "$router" });
|
|
21
|
-
};
|
|
22
|
-
if (el.props && el.props.lazyLoad) {
|
|
23
|
-
window.requestAnimationFrame(set);
|
|
24
|
-
} else await set();
|
|
25
|
-
return obj;
|
|
26
|
-
}
|
|
27
|
+
metadata: metadataHandler,
|
|
28
|
+
fetch: fetchHandler,
|
|
29
|
+
$router: routerHandler
|
|
30
|
+
};
|
|
31
|
+
const createDefine = (opts = {}) => {
|
|
32
|
+
const define = { routes: (param) => param };
|
|
33
|
+
if (opts.metadata !== false) define.metadata = metadataHandler;
|
|
34
|
+
if (opts.fetch !== false) define.fetch = fetchHandler;
|
|
35
|
+
if (opts.router !== false) define.$router = routerHandler;
|
|
36
|
+
return define;
|
|
27
37
|
};
|
|
28
38
|
export {
|
|
39
|
+
createDefine,
|
|
29
40
|
defaultDefine
|
|
30
41
|
};
|
package/dist/esm/src/index.js
CHANGED
|
@@ -65,13 +65,28 @@ const createSkeleton = (App = {}, options = DEFAULT_CREATE_OPTIONS, optionsExter
|
|
|
65
65
|
var src_default = create;
|
|
66
66
|
export * from "./init.js";
|
|
67
67
|
import { DEFAULT_CONTEXT, DESIGN_SYSTEM_OPTIONS, ROUTER_OPTIONS } from "./options.js";
|
|
68
|
+
import { defaultDefine, createDefine } from "./define.js";
|
|
69
|
+
import { polyglotPlugin, translate, setLang, getActiveLang, getLanguages, loadTranslations, upsertTranslation, initPolyglot, getLocalStateLang } from "@symbo.ls/polyglot";
|
|
70
|
+
import { polyglotFunctions } from "@symbo.ls/polyglot/functions";
|
|
68
71
|
export {
|
|
69
72
|
DEFAULT_CONTEXT,
|
|
70
73
|
DESIGN_SYSTEM_OPTIONS,
|
|
71
74
|
ROUTER_OPTIONS,
|
|
72
75
|
create,
|
|
73
76
|
createAsync,
|
|
77
|
+
createDefine,
|
|
74
78
|
createSkeleton,
|
|
75
79
|
createSync,
|
|
76
|
-
src_default as default
|
|
80
|
+
src_default as default,
|
|
81
|
+
defaultDefine,
|
|
82
|
+
getActiveLang,
|
|
83
|
+
getLanguages,
|
|
84
|
+
getLocalStateLang,
|
|
85
|
+
initPolyglot,
|
|
86
|
+
loadTranslations,
|
|
87
|
+
polyglotFunctions,
|
|
88
|
+
polyglotPlugin,
|
|
89
|
+
setLang,
|
|
90
|
+
translate,
|
|
91
|
+
upsertTranslation
|
|
77
92
|
};
|