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.
@@ -1 +1 @@
1
- {"name":"smbls","version":"3.6.7"}
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) => {
@@ -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: (param, el, state) => {
29
- if (!param) return;
30
- const doc = el.context?.document || typeof document !== "undefined" && document;
31
- if (!doc) return;
32
- const resolved = (0, import_helmet.resolveMetadata)(param, el, state);
33
- (0, import_helmet.applyMetadata)(resolved, doc);
34
- },
35
- fetch: (param, el, state, context) => {
36
- if (!param) return;
37
- (0, import_fetch.executeFetch)(param, el, state, context);
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
  };
@@ -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 : {}
@@ -62,14 +62,14 @@ const init = (config, options = SET_OPTIONS) => {
62
62
  },
63
63
  { newConfig: options.newConfig }
64
64
  );
65
- const FontFace = (0, import_scratch.getFontFaceString)(conf.font || conf.FONT, conf.files);
65
+ const FontFace = (0, import_scratch.getFontFaceString)(conf.font, conf.files);
66
66
  const useReset = conf.useReset;
67
67
  const useVariable = conf.useVariable;
68
68
  const useFontImport = conf.useFontImport;
69
69
  const useSvgSprite = conf.useSvgSprite;
70
- const hasSvgs = config.svg || config.SVG;
70
+ const hasSvgs = config.svg;
71
71
  const useIconSprite = conf.useIconSprite;
72
- const hasIcons = config.icons || config.ICONS;
72
+ const hasIcons = config.icons;
73
73
  if (useFontImport) emotion.injectGlobal(FontFace);
74
74
  if (useVariable) {
75
75
  emotion.injectGlobal({ ":root": conf.CSS_VARS });
@@ -85,8 +85,8 @@ const init = (config, options = SET_OPTIONS) => {
85
85
  emotion.injectGlobal(themeStyles);
86
86
  }
87
87
  }
88
- if (useReset) emotion.injectGlobal(conf.reset || conf.RESET);
89
- const animations = conf.animation || conf.ANIMATION;
88
+ if (useReset) emotion.injectGlobal(conf.reset);
89
+ const animations = conf.animation;
90
90
  if (animations) {
91
91
  const keyframesCSS = {};
92
92
  for (const name in animations) {
@@ -95,9 +95,9 @@ const init = (config, options = SET_OPTIONS) => {
95
95
  emotion.injectGlobal(keyframesCSS);
96
96
  }
97
97
  if (hasSvgs || useSvgSprite)
98
- (0, import_scratch.appendSVGSprite)(conf.svg || conf.SVG, { document: options.document });
98
+ (0, import_scratch.appendSVGSprite)(conf.svg, { document: options.document });
99
99
  if (hasIcons || useIconSprite)
100
- (0, import_scratch.appendSvgIconsSprite)(conf.icons || conf.ICONS, { document: options.document });
100
+ (0, import_scratch.appendSvgIconsSprite)(conf.icons, { document: options.document });
101
101
  return conf;
102
102
  };
103
103
  const UPDATE_OPTIONS = {
@@ -123,7 +123,7 @@ const reinit = (config, options = UPDATE_OPTIONS) => {
123
123
  }
124
124
  emotion.injectGlobal(themeStyles);
125
125
  }
126
- emotion.injectGlobal(conf.RESET);
126
+ emotion.injectGlobal(conf.reset);
127
127
  }
128
128
  return conf;
129
129
  };
@@ -1 +1 @@
1
- {"name":"smbls","version":"3.6.7"}
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) => {
@@ -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: (param, el, state) => {
6
- if (!param) return;
7
- const doc = el.context?.document || typeof document !== "undefined" && document;
8
- if (!doc) return;
9
- const resolved = resolveMetadata(param, el, state);
10
- applyMetadata(resolved, doc);
11
- },
12
- fetch: (param, el, state, context) => {
13
- if (!param) return;
14
- executeFetch(param, el, state, context);
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
  };
@@ -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
  };
@@ -41,14 +41,14 @@ const init = (config, options = SET_OPTIONS) => {
41
41
  },
42
42
  { newConfig: options.newConfig }
43
43
  );
44
- const FontFace = getFontFaceString(conf.font || conf.FONT, conf.files);
44
+ const FontFace = getFontFaceString(conf.font, conf.files);
45
45
  const useReset = conf.useReset;
46
46
  const useVariable = conf.useVariable;
47
47
  const useFontImport = conf.useFontImport;
48
48
  const useSvgSprite = conf.useSvgSprite;
49
- const hasSvgs = config.svg || config.SVG;
49
+ const hasSvgs = config.svg;
50
50
  const useIconSprite = conf.useIconSprite;
51
- const hasIcons = config.icons || config.ICONS;
51
+ const hasIcons = config.icons;
52
52
  if (useFontImport) emotion.injectGlobal(FontFace);
53
53
  if (useVariable) {
54
54
  emotion.injectGlobal({ ":root": conf.CSS_VARS });
@@ -64,8 +64,8 @@ const init = (config, options = SET_OPTIONS) => {
64
64
  emotion.injectGlobal(themeStyles);
65
65
  }
66
66
  }
67
- if (useReset) emotion.injectGlobal(conf.reset || conf.RESET);
68
- const animations = conf.animation || conf.ANIMATION;
67
+ if (useReset) emotion.injectGlobal(conf.reset);
68
+ const animations = conf.animation;
69
69
  if (animations) {
70
70
  const keyframesCSS = {};
71
71
  for (const name in animations) {
@@ -74,9 +74,9 @@ const init = (config, options = SET_OPTIONS) => {
74
74
  emotion.injectGlobal(keyframesCSS);
75
75
  }
76
76
  if (hasSvgs || useSvgSprite)
77
- appendSVGSprite(conf.svg || conf.SVG, { document: options.document });
77
+ appendSVGSprite(conf.svg, { document: options.document });
78
78
  if (hasIcons || useIconSprite)
79
- appendSvgIconsSprite(conf.icons || conf.ICONS, { document: options.document });
79
+ appendSvgIconsSprite(conf.icons, { document: options.document });
80
80
  return conf;
81
81
  };
82
82
  const UPDATE_OPTIONS = {
@@ -102,7 +102,7 @@ const reinit = (config, options = UPDATE_OPTIONS) => {
102
102
  }
103
103
  emotion.injectGlobal(themeStyles);
104
104
  }
105
- emotion.injectGlobal(conf.RESET);
105
+ emotion.injectGlobal(conf.reset);
106
106
  }
107
107
  return conf;
108
108
  };