@symbo.ls/create 2.11.522 → 3.0.1

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.
@@ -60,8 +60,7 @@ const prepareContext = (app, context = {}) => {
60
60
  return context;
61
61
  };
62
62
  const createDomqlElement = async (app, ctx) => {
63
- if (!(0, import_utils.isObject)(ctx))
64
- ctx = {};
63
+ if (!(0, import_utils.isObject)(ctx)) ctx = {};
65
64
  if ((0, import_utils.isNode)(app)) {
66
65
  app = {};
67
66
  ctx.parent = app;
@@ -74,7 +73,7 @@ const createDomqlElement = async (app, ctx) => {
74
73
  app = {};
75
74
  }
76
75
  prepareContext(app, ctx);
77
- app.extend = (0, import_syncExtend.initializeExtend)(app, ctx);
76
+ app.extends = (0, import_syncExtend.initializeExtend)(app, ctx);
78
77
  app.routes = ctx.pages;
79
78
  app.state = ctx.state;
80
79
  app.context = ctx;
@@ -21,25 +21,18 @@ __export(define_exports, {
21
21
  defaultDefine: () => defaultDefine
22
22
  });
23
23
  module.exports = __toCommonJS(define_exports);
24
- var import_atoms = require("@symbo.ls/atoms");
25
24
  const defaultDefine = {
26
25
  routes: (param) => param,
27
26
  // deps: (param, el) => param || el.parent.deps,
28
- $router: (param, el) => {
29
- if (!param)
30
- return;
27
+ $router: async (param, el) => {
28
+ if (!param) return;
31
29
  const obj = { tag: "fragment", ...param };
32
- const set = () => {
33
- el.set(obj, { preventDefineUpdate: "$router" });
30
+ const set = async () => {
31
+ await el.set(obj, { preventDefineUpdate: "$router" });
34
32
  };
35
33
  if (el.props && el.props.lazyLoad) {
36
34
  window.requestAnimationFrame(set);
37
- } else
38
- set();
35
+ } else await set();
39
36
  return obj;
40
- },
41
- $collection: import_atoms.Collection.define.$collection,
42
- $setCollection: import_atoms.Collection.define.$setCollection,
43
- $stateCollection: import_atoms.Collection.define.$stateCollection,
44
- $propsCollection: import_atoms.Collection.define.$propsCollection
37
+ }
45
38
  };
@@ -27,8 +27,7 @@ var import_fetch = require("@symbo.ls/fetch");
27
27
  const fetchSync = async (key, options) => {
28
28
  if (key && options.editor) {
29
29
  try {
30
- if (!options.editor.async)
31
- await (0, import_fetch.fetchProject)(key, options);
30
+ if (!options.editor.async) await (0, import_fetch.fetchProject)(key, options);
32
31
  } catch (e) {
33
32
  console.error(e);
34
33
  }
package/dist/cjs/index.js CHANGED
@@ -26,15 +26,15 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
26
26
  mod
27
27
  ));
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var src_exports = {};
30
- __export(src_exports, {
29
+ var index_exports = {};
30
+ __export(index_exports, {
31
31
  create: () => create,
32
32
  createAsync: () => createAsync,
33
33
  createSkeleton: () => createSkeleton,
34
34
  createSync: () => createSync,
35
- default: () => src_default
35
+ default: () => index_default
36
36
  });
37
- module.exports = __toCommonJS(src_exports);
37
+ module.exports = __toCommonJS(index_exports);
38
38
  var import_utils = require("@domql/utils");
39
39
  var utils = __toESM(require("./utilImports"), 1);
40
40
  var import_router = require("./router");
@@ -50,8 +50,7 @@ const create = (App, options = import_options.default, optionsExternalFile) => {
50
50
  const redefinedOptions = { ...import_options.default, ...mergeWithLocalFile(options, optionsExternalFile) };
51
51
  const domqlApp = (0, import_createDomql.createDomqlElement)(App, redefinedOptions);
52
52
  (0, import_router.popStateRouter)(domqlApp, redefinedOptions);
53
- if (redefinedOptions.on && redefinedOptions.on.create)
54
- redefinedOptions.on.create(domqlApp, domqlApp.state, domqlApp.context, redefinedOptions);
53
+ if (redefinedOptions.on && redefinedOptions.on.create) redefinedOptions.on.create(domqlApp, domqlApp.state, domqlApp.context, redefinedOptions);
55
54
  return domqlApp;
56
55
  };
57
56
  const createAsync = (App, options = import_options.default, optionsExternalFile) => {
@@ -66,8 +65,7 @@ const createSync = async (App, options = import_options.default, optionsExternal
66
65
  const key = options.key;
67
66
  await (0, import_ferchOnCreate.fetchSync)(key, redefinedOptions);
68
67
  const domqlApp = await (0, import_createDomql.createDomqlElement)(App, redefinedOptions);
69
- if (redefinedOptions.on && redefinedOptions.on.create)
70
- await redefinedOptions.on.create(domqlApp, domqlApp.state, domqlApp.context, redefinedOptions);
68
+ if (redefinedOptions.on && redefinedOptions.on.create) await redefinedOptions.on.create(domqlApp, domqlApp.state, domqlApp.context, redefinedOptions);
71
69
  return domqlApp;
72
70
  };
73
71
  const createSkeleton = (App = {}, options = import_options.default, optionsExternalFile) => {
@@ -80,4 +78,4 @@ const createSkeleton = (App = {}, options = import_options.default, optionsExter
80
78
  optionsExternalFile
81
79
  );
82
80
  };
83
- var src_default = create;
81
+ var index_default = create;
@@ -32,8 +32,7 @@ const initEmotion = (key, options = {}) => {
32
32
  const doc = options.parent || options.document || document;
33
33
  const initOptions = options.initOptions || {};
34
34
  const emotion = initOptions.emotion;
35
- if (!initOptions.emotion)
36
- initOptions.emotion = import_emotion2.emotion;
35
+ if (!initOptions.emotion) initOptions.emotion = import_emotion2.emotion;
37
36
  const registry = options.registry || (0, import_emotion.transformDOMQLEmotion)(initOptions.emotion, options);
38
37
  const designSystem = initOptions.useDefaultConfig || ((_a = options.designSystem) == null ? void 0 : _a.useDefaultConfig) ? (0, import_utils.deepMerge)(options.designSystem, (0, import_utils.deepClone)(import_default_config.DEFAULT_CONFIG)) : options.designSystem || (0, import_utils.deepClone)(import_default_config.DEFAULT_CONFIG);
39
38
  const scratchSystem = (0, import_init.init)(designSystem, {
@@ -47,11 +47,9 @@ var utils = __toESM(require("./utilImports"), 1);
47
47
  var routerUtils = __toESM(require("@domql/router"), 1);
48
48
  const ENV = "development";
49
49
  const prepareWindow = (context) => {
50
- if (typeof window === "undefined")
51
- window = globalThis || {};
50
+ if (typeof window === "undefined") window = globalThis || {};
52
51
  if (typeof document === "undefined") {
53
- if (!window.document)
54
- window.document = globalThis.document || { body: {} };
52
+ if (!window.document) window.document = globalThis.document || { body: {} };
55
53
  document = window.document;
56
54
  }
57
55
  context.document = context.document || document;
@@ -64,7 +62,7 @@ const UIkitWithPrefix = () => {
64
62
  const newObj = {};
65
63
  for (const key in uikit) {
66
64
  if (Object.prototype.hasOwnProperty.call(uikit, key)) {
67
- if ((0, import_utils.checkIfKeyIsComponent)(key)) {
65
+ if ((0, import_utils.matchesComponentNaming)(key)) {
68
66
  newObj[`smbls.${key}`] = uikit[key];
69
67
  } else {
70
68
  newObj[key] = uikit[key];
@@ -108,11 +106,9 @@ const prepareDependencies = ({
108
106
  if (dependency.split("/").length > 2 || !onlyDotsAndNumbers(version)) {
109
107
  url = `https://pkg.symbo.ls/${dependency}${random}`;
110
108
  }
111
- if (dependenciesOnDemand && dependenciesOnDemand[dependency])
112
- continue;
109
+ if (dependenciesOnDemand && dependenciesOnDemand[dependency]) continue;
113
110
  try {
114
- if (cachedDeps[dependency])
115
- return;
111
+ if (cachedDeps[dependency]) return;
116
112
  cachedDeps[dependency] = true;
117
113
  utils.loadJavascriptFileEmbedSync(url, document2);
118
114
  } catch (e) {
@@ -126,8 +122,7 @@ const prepareRequire = (packages, ctx) => {
126
122
  const initRequire = (ctx2) => (key) => {
127
123
  const windowOpts2 = ctx2.window || window;
128
124
  const pkg = windowOpts2.packages[key];
129
- if (typeof pkg === "function")
130
- return pkg();
125
+ if (typeof pkg === "function") return pkg();
131
126
  return pkg;
132
127
  };
133
128
  const initRequireOnDemand = (ctx2) => (key) => {
@@ -169,10 +164,8 @@ const prepareDesignSystem = (key, context) => {
169
164
  };
170
165
  const prepareState = (app, context) => {
171
166
  const state = {};
172
- if (context.state)
173
- utils.deepMerge(state, context.state);
174
- if (app && app.state)
175
- (0, import_utils.deepMerge)(state, app.state);
167
+ if (context.state) utils.deepMerge(state, context.state);
168
+ if (app && app.state) (0, import_utils.deepMerge)(state, app.state);
176
169
  return (0, import_utils.deepClone)(state);
177
170
  };
178
171
  const preparePages = (app, context) => {
@@ -32,21 +32,17 @@ const DEFAULT_ROUTING_OPTIONS = {
32
32
  popState: true
33
33
  };
34
34
  const initRouter = (element, context) => {
35
- if (context.router === false)
36
- return;
37
- else if (context.router === true)
38
- context.router = DEFAULT_ROUTING_OPTIONS;
39
- else
40
- (0, import_utils.merge)(context.router || {}, DEFAULT_ROUTING_OPTIONS);
35
+ if (context.router === false) return;
36
+ else if (context.router === true) context.router = DEFAULT_ROUTING_OPTIONS;
37
+ else (0, import_utils.merge)(context.router || {}, DEFAULT_ROUTING_OPTIONS);
41
38
  const routerOptions = context.router;
42
39
  const router = context.utils && context.utils.router ? context.utils.router : import_router.router;
43
40
  const onRouterRenderDefault = (el, s) => {
44
41
  const { pathname, search, hash } = import_utils.window.location;
45
42
  const url = pathname + search + hash;
46
- if (el.routes)
47
- router(url, el, {}, { initialRender: true });
43
+ if (el.routes) router(url, el, {}, { initialRender: true });
48
44
  };
49
- const hasRenderRouter = element.on && !(0, import_utils.isUndefined)(element.on.renderRouter);
45
+ const hasRenderRouter = element.on && !(0, import_utils.isUndefined)(element.on.renderRouter) || !(0, import_utils.isUndefined)(element.onRenderRouter);
50
46
  if (routerOptions && routerOptions.initRouter && !hasRenderRouter) {
51
47
  if (element.on) {
52
48
  element.on.renderRouter = onRouterRenderDefault;
@@ -61,12 +57,10 @@ const initRouter = (element, context) => {
61
57
  };
62
58
  let popStateFired;
63
59
  const popStateRouter = (element, context) => {
64
- if (popStateFired)
65
- return;
60
+ if (popStateFired) return;
66
61
  popStateFired = true;
67
62
  const routerOptions = context.router || DEFAULT_ROUTING_OPTIONS;
68
- if (!routerOptions.popState)
69
- return;
63
+ if (!routerOptions.popState) return;
70
64
  const router = context.utils && context.utils.router ? context.utils.router : import_router.router;
71
65
  import_utils.window.onpopstate = (e) => {
72
66
  const { pathname, search, hash } = import_utils.window.location;
@@ -27,50 +27,44 @@ module.exports = __toCommonJS(syncExtend_exports);
27
27
  var import_utils = require("@domql/utils");
28
28
  var import_sync = require("@symbo.ls/sync");
29
29
  const initializeExtend = (app, ctx) => {
30
- return (0, import_utils.isObjectLike)(app.extend) ? app.extend : [];
30
+ return (0, import_utils.isObjectLike)(app.extends) ? app.extends : [];
31
31
  };
32
32
  const initializeSync = (app, ctx) => {
33
33
  const { editor } = ctx;
34
- if (!editor)
35
- return;
34
+ if (!editor) return;
36
35
  const liveSync = (0, import_utils.isUndefined)(editor.liveSync) ? (0, import_utils.isDevelopment)() : editor.liveSync;
37
36
  if (liveSync) {
38
- if ((0, import_utils.isArray)(app.extend))
39
- app.extend.push(import_sync.SyncComponent);
40
- else if (app.extend) {
41
- app.extend = [app.extend, import_sync.SyncComponent];
37
+ if ((0, import_utils.isArray)(app.extends)) app.extends.push(import_sync.SyncComponent);
38
+ else if (app.extends) {
39
+ app.extends = [app.extends, import_sync.SyncComponent];
42
40
  } else {
43
- app.extend = [import_sync.SyncComponent];
41
+ app.extends = [import_sync.SyncComponent];
44
42
  }
45
43
  }
46
44
  };
47
45
  const initializeInspect = (app, ctx) => {
48
46
  const { editor } = ctx;
49
- if (!editor)
50
- return;
47
+ if (!editor) return;
51
48
  const inspect = (0, import_utils.isUndefined)(editor.inspect) ? (0, import_utils.isDevelopment)() : editor.inspect;
52
49
  if (inspect) {
53
- if ((0, import_utils.isArray)(app.extend))
54
- app.extend.push(import_sync.Inspect);
55
- else if (app.extend) {
56
- app.extend = [app.extend, import_sync.Inspect];
50
+ if ((0, import_utils.isArray)(app.extends)) app.extends.push(import_sync.Inspect);
51
+ else if (app.extends) {
52
+ app.extends = [app.extends, import_sync.Inspect];
57
53
  } else {
58
- app.extend = [import_sync.Inspect];
54
+ app.extends = [import_sync.Inspect];
59
55
  }
60
56
  }
61
57
  };
62
58
  const initializeNotifications = (app, ctx) => {
63
59
  const { editor } = ctx;
64
- if (!editor)
65
- return;
60
+ if (!editor) return;
66
61
  const verbose = (0, import_utils.isUndefined)(editor.verbose) ? (0, import_utils.isDevelopment)() || ctx.verbose : editor.verbose;
67
62
  if (verbose) {
68
- if ((0, import_utils.isArray)(app.extend))
69
- app.extend.push(import_sync.Notifications);
70
- else if (app.extend) {
71
- app.extend = [app.extend, import_sync.Notifications];
63
+ if ((0, import_utils.isArray)(app.extends)) app.extends.push(import_sync.Notifications);
64
+ else if (app.extends) {
65
+ app.extends = [app.extends, import_sync.Notifications];
72
66
  } else {
73
- app.extend = [import_sync.Notifications];
67
+ app.extends = [import_sync.Notifications];
74
68
  }
75
69
  }
76
70
  };
@@ -52,8 +52,7 @@ const prepareContext = (app, context = {}) => {
52
52
  return context;
53
53
  };
54
54
  const createDomqlElement = async (app, ctx) => {
55
- if (!isObject(ctx))
56
- ctx = {};
55
+ if (!isObject(ctx)) ctx = {};
57
56
  if (isNode(app)) {
58
57
  app = {};
59
58
  ctx.parent = app;
@@ -66,7 +65,7 @@ const createDomqlElement = async (app, ctx) => {
66
65
  app = {};
67
66
  }
68
67
  prepareContext(app, ctx);
69
- app.extend = initializeExtend(app, ctx);
68
+ app.extends = initializeExtend(app, ctx);
70
69
  app.routes = ctx.pages;
71
70
  app.state = ctx.state;
72
71
  app.context = ctx;
@@ -14,27 +14,20 @@ var __spreadValues = (a, b) => {
14
14
  }
15
15
  return a;
16
16
  };
17
- import { Collection } from "@symbo.ls/atoms";
18
17
  const defaultDefine = {
19
18
  routes: (param) => param,
20
19
  // deps: (param, el) => param || el.parent.deps,
21
- $router: (param, el) => {
22
- if (!param)
23
- return;
20
+ $router: async (param, el) => {
21
+ if (!param) return;
24
22
  const obj = __spreadValues({ tag: "fragment" }, param);
25
- const set = () => {
26
- el.set(obj, { preventDefineUpdate: "$router" });
23
+ const set = async () => {
24
+ await el.set(obj, { preventDefineUpdate: "$router" });
27
25
  };
28
26
  if (el.props && el.props.lazyLoad) {
29
27
  window.requestAnimationFrame(set);
30
- } else
31
- set();
28
+ } else await set();
32
29
  return obj;
33
- },
34
- $collection: Collection.define.$collection,
35
- $setCollection: Collection.define.$setCollection,
36
- $stateCollection: Collection.define.$stateCollection,
37
- $propsCollection: Collection.define.$propsCollection
30
+ }
38
31
  };
39
32
  export {
40
33
  defaultDefine
@@ -3,8 +3,7 @@ import { fetchProject, fetchProjectAsync } from "@symbo.ls/fetch";
3
3
  const fetchSync = async (key, options) => {
4
4
  if (key && options.editor) {
5
5
  try {
6
- if (!options.editor.async)
7
- await fetchProject(key, options);
6
+ if (!options.editor.async) await fetchProject(key, options);
8
7
  } catch (e) {
9
8
  console.error(e);
10
9
  }
package/dist/esm/index.js CHANGED
@@ -29,8 +29,7 @@ const create = (App, options = DEFAULT_CREATE_OPTIONS, optionsExternalFile) => {
29
29
  const redefinedOptions = __spreadValues(__spreadValues({}, DEFAULT_CREATE_OPTIONS), mergeWithLocalFile(options, optionsExternalFile));
30
30
  const domqlApp = createDomqlElement(App, redefinedOptions);
31
31
  popStateRouter(domqlApp, redefinedOptions);
32
- if (redefinedOptions.on && redefinedOptions.on.create)
33
- redefinedOptions.on.create(domqlApp, domqlApp.state, domqlApp.context, redefinedOptions);
32
+ if (redefinedOptions.on && redefinedOptions.on.create) redefinedOptions.on.create(domqlApp, domqlApp.state, domqlApp.context, redefinedOptions);
34
33
  return domqlApp;
35
34
  };
36
35
  const createAsync = (App, options = DEFAULT_CREATE_OPTIONS, optionsExternalFile) => {
@@ -45,8 +44,7 @@ const createSync = async (App, options = DEFAULT_CREATE_OPTIONS, optionsExternal
45
44
  const key = options.key;
46
45
  await fetchSync(key, redefinedOptions);
47
46
  const domqlApp = await createDomqlElement(App, redefinedOptions);
48
- if (redefinedOptions.on && redefinedOptions.on.create)
49
- await redefinedOptions.on.create(domqlApp, domqlApp.state, domqlApp.context, redefinedOptions);
47
+ if (redefinedOptions.on && redefinedOptions.on.create) await redefinedOptions.on.create(domqlApp, domqlApp.state, domqlApp.context, redefinedOptions);
50
48
  return domqlApp;
51
49
  };
52
50
  const createSkeleton = (App = {}, options = DEFAULT_CREATE_OPTIONS, optionsExternalFile) => {
@@ -58,11 +56,11 @@ const createSkeleton = (App = {}, options = DEFAULT_CREATE_OPTIONS, optionsExter
58
56
  optionsExternalFile
59
57
  );
60
58
  };
61
- var src_default = create;
59
+ var index_default = create;
62
60
  export {
63
61
  create,
64
62
  createAsync,
65
63
  createSkeleton,
66
64
  createSync,
67
- src_default as default
65
+ index_default as default
68
66
  };
@@ -25,8 +25,7 @@ const initEmotion = (key, options = {}) => {
25
25
  const doc = options.parent || options.document || document;
26
26
  const initOptions = options.initOptions || {};
27
27
  const emotion = initOptions.emotion;
28
- if (!initOptions.emotion)
29
- initOptions.emotion = defaultEmotion;
28
+ if (!initOptions.emotion) initOptions.emotion = defaultEmotion;
30
29
  const registry = options.registry || transformDOMQLEmotion(initOptions.emotion, options);
31
30
  const designSystem = initOptions.useDefaultConfig || ((_a = options.designSystem) == null ? void 0 : _a.useDefaultConfig) ? deepMerge(options.designSystem, deepClone(DEFAULT_CONFIG)) : options.designSystem || deepClone(DEFAULT_CONFIG);
32
31
  const scratchSystem = init(designSystem, __spreadValues(__spreadValues({
@@ -22,7 +22,7 @@ import {
22
22
  deepMerge,
23
23
  deepClone,
24
24
  merge,
25
- checkIfKeyIsComponent
25
+ matchesComponentNaming
26
26
  } from "@domql/utils";
27
27
  import { initEmotion } from "./initEmotion";
28
28
  import * as uikit from "@symbo.ls/uikit";
@@ -30,11 +30,9 @@ import * as utils from "./utilImports";
30
30
  import * as routerUtils from "@domql/router";
31
31
  const ENV = "development";
32
32
  const prepareWindow = (context) => {
33
- if (typeof window === "undefined")
34
- window = globalThis || {};
33
+ if (typeof window === "undefined") window = globalThis || {};
35
34
  if (typeof document === "undefined") {
36
- if (!window.document)
37
- window.document = globalThis.document || { body: {} };
35
+ if (!window.document) window.document = globalThis.document || { body: {} };
38
36
  document = window.document;
39
37
  }
40
38
  context.document = context.document || document;
@@ -47,7 +45,7 @@ const UIkitWithPrefix = () => {
47
45
  const newObj = {};
48
46
  for (const key in uikit) {
49
47
  if (Object.prototype.hasOwnProperty.call(uikit, key)) {
50
- if (checkIfKeyIsComponent(key)) {
48
+ if (matchesComponentNaming(key)) {
51
49
  newObj[`smbls.${key}`] = uikit[key];
52
50
  } else {
53
51
  newObj[key] = uikit[key];
@@ -90,11 +88,9 @@ const prepareDependencies = ({
90
88
  if (dependency.split("/").length > 2 || !onlyDotsAndNumbers(version)) {
91
89
  url = `https://pkg.symbo.ls/${dependency}${random}`;
92
90
  }
93
- if (dependenciesOnDemand && dependenciesOnDemand[dependency])
94
- continue;
91
+ if (dependenciesOnDemand && dependenciesOnDemand[dependency]) continue;
95
92
  try {
96
- if (cachedDeps[dependency])
97
- return;
93
+ if (cachedDeps[dependency]) return;
98
94
  cachedDeps[dependency] = true;
99
95
  utils.loadJavascriptFileEmbedSync(url, document2);
100
96
  } catch (e) {
@@ -108,8 +104,7 @@ const prepareRequire = (packages, ctx) => {
108
104
  const initRequire = (ctx2) => (key) => {
109
105
  const windowOpts2 = ctx2.window || window;
110
106
  const pkg = windowOpts2.packages[key];
111
- if (typeof pkg === "function")
112
- return pkg();
107
+ if (typeof pkg === "function") return pkg();
113
108
  return pkg;
114
109
  };
115
110
  const initRequireOnDemand = (ctx2) => (key) => {
@@ -151,10 +146,8 @@ const prepareDesignSystem = (key, context) => {
151
146
  };
152
147
  const prepareState = (app, context) => {
153
148
  const state = {};
154
- if (context.state)
155
- utils.deepMerge(state, context.state);
156
- if (app && app.state)
157
- deepMerge(state, app.state);
149
+ if (context.state) utils.deepMerge(state, context.state);
150
+ if (app && app.state) deepMerge(state, app.state);
158
151
  return deepClone(state);
159
152
  };
160
153
  const preparePages = (app, context) => {
@@ -7,21 +7,17 @@ const DEFAULT_ROUTING_OPTIONS = {
7
7
  popState: true
8
8
  };
9
9
  const initRouter = (element, context) => {
10
- if (context.router === false)
11
- return;
12
- else if (context.router === true)
13
- context.router = DEFAULT_ROUTING_OPTIONS;
14
- else
15
- merge(context.router || {}, DEFAULT_ROUTING_OPTIONS);
10
+ if (context.router === false) return;
11
+ else if (context.router === true) context.router = DEFAULT_ROUTING_OPTIONS;
12
+ else merge(context.router || {}, DEFAULT_ROUTING_OPTIONS);
16
13
  const routerOptions = context.router;
17
14
  const router = context.utils && context.utils.router ? context.utils.router : defaultRouter;
18
15
  const onRouterRenderDefault = (el, s) => {
19
16
  const { pathname, search, hash } = window.location;
20
17
  const url = pathname + search + hash;
21
- if (el.routes)
22
- router(url, el, {}, { initialRender: true });
18
+ if (el.routes) router(url, el, {}, { initialRender: true });
23
19
  };
24
- const hasRenderRouter = element.on && !isUndefined(element.on.renderRouter);
20
+ const hasRenderRouter = element.on && !isUndefined(element.on.renderRouter) || !isUndefined(element.onRenderRouter);
25
21
  if (routerOptions && routerOptions.initRouter && !hasRenderRouter) {
26
22
  if (element.on) {
27
23
  element.on.renderRouter = onRouterRenderDefault;
@@ -36,12 +32,10 @@ const initRouter = (element, context) => {
36
32
  };
37
33
  let popStateFired;
38
34
  const popStateRouter = (element, context) => {
39
- if (popStateFired)
40
- return;
35
+ if (popStateFired) return;
41
36
  popStateFired = true;
42
37
  const routerOptions = context.router || DEFAULT_ROUTING_OPTIONS;
43
- if (!routerOptions.popState)
44
- return;
38
+ if (!routerOptions.popState) return;
45
39
  const router = context.utils && context.utils.router ? context.utils.router : defaultRouter;
46
40
  window.onpopstate = (e) => {
47
41
  const { pathname, search, hash } = window.location;
@@ -1,50 +1,44 @@
1
1
  import { isObjectLike, isUndefined, isDevelopment, isArray } from "@domql/utils";
2
2
  import { SyncComponent, Inspect, Notifications } from "@symbo.ls/sync";
3
3
  const initializeExtend = (app, ctx) => {
4
- return isObjectLike(app.extend) ? app.extend : [];
4
+ return isObjectLike(app.extends) ? app.extends : [];
5
5
  };
6
6
  const initializeSync = (app, ctx) => {
7
7
  const { editor } = ctx;
8
- if (!editor)
9
- return;
8
+ if (!editor) return;
10
9
  const liveSync = isUndefined(editor.liveSync) ? isDevelopment() : editor.liveSync;
11
10
  if (liveSync) {
12
- if (isArray(app.extend))
13
- app.extend.push(SyncComponent);
14
- else if (app.extend) {
15
- app.extend = [app.extend, SyncComponent];
11
+ if (isArray(app.extends)) app.extends.push(SyncComponent);
12
+ else if (app.extends) {
13
+ app.extends = [app.extends, SyncComponent];
16
14
  } else {
17
- app.extend = [SyncComponent];
15
+ app.extends = [SyncComponent];
18
16
  }
19
17
  }
20
18
  };
21
19
  const initializeInspect = (app, ctx) => {
22
20
  const { editor } = ctx;
23
- if (!editor)
24
- return;
21
+ if (!editor) return;
25
22
  const inspect = isUndefined(editor.inspect) ? isDevelopment() : editor.inspect;
26
23
  if (inspect) {
27
- if (isArray(app.extend))
28
- app.extend.push(Inspect);
29
- else if (app.extend) {
30
- app.extend = [app.extend, Inspect];
24
+ if (isArray(app.extends)) app.extends.push(Inspect);
25
+ else if (app.extends) {
26
+ app.extends = [app.extends, Inspect];
31
27
  } else {
32
- app.extend = [Inspect];
28
+ app.extends = [Inspect];
33
29
  }
34
30
  }
35
31
  };
36
32
  const initializeNotifications = (app, ctx) => {
37
33
  const { editor } = ctx;
38
- if (!editor)
39
- return;
34
+ if (!editor) return;
40
35
  const verbose = isUndefined(editor.verbose) ? isDevelopment() || ctx.verbose : editor.verbose;
41
36
  if (verbose) {
42
- if (isArray(app.extend))
43
- app.extend.push(Notifications);
44
- else if (app.extend) {
45
- app.extend = [app.extend, Notifications];
37
+ if (isArray(app.extends)) app.extends.push(Notifications);
38
+ else if (app.extends) {
39
+ app.extends = [app.extends, Notifications];
46
40
  } else {
47
- app.extend = [Notifications];
41
+ app.extends = [Notifications];
48
42
  }
49
43
  }
50
44
  };
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@symbo.ls/create",
3
- "version": "2.11.522",
3
+ "version": "3.0.1",
4
4
  "license": "MIT",
5
- "gitHead": "f0cf0f8e16c7cac278886a322e85cb8d8188ca24",
5
+ "gitHead": "a4e7f586f7e4f60bd7b6a8388bdacc3ae1879433",
6
6
  "type": "module",
7
7
  "module": "src/index.js",
8
8
  "main": "src/index.js",
@@ -33,12 +33,12 @@
33
33
  "@domql/event": "^2.5.0",
34
34
  "@domql/report": "^2.5.0",
35
35
  "@domql/router": "^2.5.0",
36
- "@symbo.ls/fetch": "^2.11.511",
37
- "@symbo.ls/init": "^2.11.522",
38
- "@symbo.ls/scratch": "^2.11.522",
39
- "@symbo.ls/sync": "^2.11.522",
40
- "@symbo.ls/uikit": "^2.11.522",
41
- "@symbo.ls/utils": "^2.11.512",
36
+ "@symbo.ls/fetch": "^3.0.1",
37
+ "@symbo.ls/init": "^3.0.1",
38
+ "@symbo.ls/scratch": "^3.0.1",
39
+ "@symbo.ls/sync": "^3.0.1",
40
+ "@symbo.ls/uikit": "^3.0.1",
41
+ "@symbo.ls/utils": "^3.0.1",
42
42
  "domql": "^2.5.158"
43
43
  },
44
44
  "devDependencies": {
@@ -58,7 +58,7 @@ export const createDomqlElement = async (app, ctx) => {
58
58
 
59
59
  prepareContext(app, ctx)
60
60
 
61
- app.extend = initializeExtend(app, ctx)
61
+ app.extends = initializeExtend(app, ctx)
62
62
  app.routes = ctx.pages
63
63
  app.state = ctx.state
64
64
  app.context = ctx
package/src/define.js CHANGED
@@ -1,29 +1,22 @@
1
1
  'use strict'
2
2
 
3
- import { Collection } from '@symbo.ls/atoms'
4
-
5
3
  export const defaultDefine = {
6
4
  routes: param => param,
7
5
  // deps: (param, el) => param || el.parent.deps,
8
6
 
9
- $router: (param, el) => {
7
+ $router: async (param, el) => {
10
8
  if (!param) return
11
9
 
12
10
  const obj = { tag: 'fragment', ...param }
13
11
 
14
- const set = () => {
15
- el.set(obj, { preventDefineUpdate: '$router' })
12
+ const set = async () => {
13
+ await el.set(obj, { preventDefineUpdate: '$router' })
16
14
  }
17
15
 
18
16
  if (el.props && el.props.lazyLoad) {
19
17
  window.requestAnimationFrame(set)
20
- } else set()
18
+ } else await set()
21
19
 
22
20
  return obj
23
- },
24
-
25
- $collection: Collection.define.$collection,
26
- $setCollection: Collection.define.$setCollection,
27
- $stateCollection: Collection.define.$stateCollection,
28
- $propsCollection: Collection.define.$propsCollection
21
+ }
29
22
  }
package/src/prepare.js CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  deepMerge,
6
6
  deepClone,
7
7
  merge,
8
- checkIfKeyIsComponent
8
+ matchesComponentNaming
9
9
  } from '@domql/utils'
10
10
  import { initEmotion } from './initEmotion'
11
11
 
@@ -33,7 +33,7 @@ export const UIkitWithPrefix = () => {
33
33
  const newObj = {}
34
34
  for (const key in uikit) {
35
35
  if (Object.prototype.hasOwnProperty.call(uikit, key)) {
36
- if (checkIfKeyIsComponent(key)) {
36
+ if (matchesComponentNaming(key)) {
37
37
  newObj[`smbls.${key}`] = uikit[key]
38
38
  } else {
39
39
  newObj[key] = uikit[key]
package/src/router.js CHANGED
@@ -24,7 +24,9 @@ export const initRouter = (element, context) => {
24
24
  if (el.routes) router(url, el, {}, { initialRender: true })
25
25
  }
26
26
 
27
- const hasRenderRouter = element.on && !isUndefined(element.on.renderRouter)
27
+ // console.log(element)
28
+ // debugger
29
+ const hasRenderRouter = (element.on && !isUndefined(element.on.renderRouter)) || !isUndefined(element.onRenderRouter) // || element.on.renderRouter
28
30
  if (routerOptions && routerOptions.initRouter && !hasRenderRouter) {
29
31
  if (element.on) {
30
32
  element.on.renderRouter = onRouterRenderDefault
package/src/syncExtend.js CHANGED
@@ -4,7 +4,7 @@ import { isObjectLike, isUndefined, isDevelopment, isArray } from '@domql/utils'
4
4
  import { SyncComponent, Inspect, Notifications } from '@symbo.ls/sync'
5
5
 
6
6
  export const initializeExtend = (app, ctx) => {
7
- return isObjectLike(app.extend) ? app.extend : []
7
+ return isObjectLike(app.extends) ? app.extends : []
8
8
  }
9
9
 
10
10
  export const initializeSync = (app, ctx) => {
@@ -12,11 +12,11 @@ export const initializeSync = (app, ctx) => {
12
12
  if (!editor) return
13
13
  const liveSync = isUndefined(editor.liveSync) ? isDevelopment() : editor.liveSync
14
14
  if (liveSync) {
15
- if (isArray(app.extend)) app.extend.push(SyncComponent)
16
- else if (app.extend) {
17
- app.extend = [app.extend, SyncComponent]
15
+ if (isArray(app.extends)) app.extends.push(SyncComponent)
16
+ else if (app.extends) {
17
+ app.extends = [app.extends, SyncComponent]
18
18
  } else {
19
- app.extend = [SyncComponent]
19
+ app.extends = [SyncComponent]
20
20
  }
21
21
  }
22
22
  }
@@ -26,11 +26,11 @@ export const initializeInspect = (app, ctx) => {
26
26
  if (!editor) return
27
27
  const inspect = isUndefined(editor.inspect) ? isDevelopment() : editor.inspect
28
28
  if (inspect) {
29
- if (isArray(app.extend)) app.extend.push(Inspect)
30
- else if (app.extend) {
31
- app.extend = [app.extend, Inspect]
29
+ if (isArray(app.extends)) app.extends.push(Inspect)
30
+ else if (app.extends) {
31
+ app.extends = [app.extends, Inspect]
32
32
  } else {
33
- app.extend = [Inspect]
33
+ app.extends = [Inspect]
34
34
  }
35
35
  }
36
36
  }
@@ -40,11 +40,11 @@ export const initializeNotifications = (app, ctx) => {
40
40
  if (!editor) return
41
41
  const verbose = isUndefined(editor.verbose) ? isDevelopment() || ctx.verbose : editor.verbose
42
42
  if (verbose) {
43
- if (isArray(app.extend)) app.extend.push(Notifications)
44
- else if (app.extend) {
45
- app.extend = [app.extend, Notifications]
43
+ if (isArray(app.extends)) app.extends.push(Notifications)
44
+ else if (app.extends) {
45
+ app.extends = [app.extends, Notifications]
46
46
  } else {
47
- app.extend = [Notifications]
47
+ app.extends = [Notifications]
48
48
  }
49
49
  }
50
50
  }