@symbo.ls/create 2.27.0 → 2.27.10
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/createDomql.js +18 -13
- package/dist/cjs/define.js +2 -4
- package/dist/cjs/ferchOnCreate.js +1 -2
- package/dist/cjs/index.js +34 -15
- package/dist/cjs/initEmotion.js +2 -3
- package/dist/cjs/options.js +1 -1
- package/dist/cjs/prepare.js +20 -20
- package/dist/cjs/router.js +6 -12
- package/dist/cjs/syncExtend.js +6 -12
- package/dist/esm/createDomql.js +22 -12
- package/dist/esm/define.js +2 -4
- package/dist/esm/ferchOnCreate.js +1 -2
- package/dist/esm/index.js +19 -9
- package/dist/esm/initEmotion.js +2 -3
- package/dist/esm/options.js +1 -1
- package/dist/esm/prepare.js +14 -20
- package/dist/esm/router.js +6 -12
- package/dist/esm/syncExtend.js +6 -12
- package/package.json +18 -18
- package/src/createDomql.js +23 -12
- package/src/index.js +57 -19
- package/src/initEmotion.js +7 -5
- package/src/options.js +1 -1
- package/src/prepare.js +28 -13
package/dist/cjs/createDomql.js
CHANGED
|
@@ -36,15 +36,18 @@ var import_domql = __toESM(require("domql"), 1);
|
|
|
36
36
|
var uikit = __toESM(require("@symbo.ls/uikit"), 1);
|
|
37
37
|
var import_utils = require("@domql/utils");
|
|
38
38
|
var import_event = require("@domql/event");
|
|
39
|
-
var import_define = require("./define");
|
|
40
|
-
var import_router = require("./router");
|
|
41
|
-
var import_syncExtend = require("./syncExtend");
|
|
42
|
-
var import_prepare = require("./prepare");
|
|
39
|
+
var import_define = require("./define.js");
|
|
40
|
+
var import_router = require("./router.js");
|
|
41
|
+
var import_syncExtend = require("./syncExtend.js");
|
|
42
|
+
var import_prepare = require("./prepare.js");
|
|
43
43
|
const prepareContext = (app, context = {}) => {
|
|
44
44
|
const key = context.key = context.key || ((0, import_utils.isString)(app) ? app : "smblsapp");
|
|
45
45
|
context.define = context.define || import_define.defaultDefine;
|
|
46
46
|
context.window = (0, import_prepare.prepareWindow)(context);
|
|
47
|
-
const [scratcDesignSystem, emotion, registry] = (0, import_prepare.prepareDesignSystem)(
|
|
47
|
+
const [scratcDesignSystem, emotion, registry] = (0, import_prepare.prepareDesignSystem)(
|
|
48
|
+
key,
|
|
49
|
+
context
|
|
50
|
+
);
|
|
48
51
|
context.designSystem = scratcDesignSystem;
|
|
49
52
|
context.registry = registry;
|
|
50
53
|
context.emotion = emotion;
|
|
@@ -60,8 +63,7 @@ const prepareContext = (app, context = {}) => {
|
|
|
60
63
|
return context;
|
|
61
64
|
};
|
|
62
65
|
const createDomqlElement = async (app, ctx) => {
|
|
63
|
-
if (!(0, import_utils.isObject)(ctx))
|
|
64
|
-
ctx = {};
|
|
66
|
+
if (!(0, import_utils.isObject)(ctx)) ctx = {};
|
|
65
67
|
if ((0, import_utils.isNode)(app)) {
|
|
66
68
|
app = {};
|
|
67
69
|
ctx.parent = app;
|
|
@@ -80,12 +82,15 @@ const createDomqlElement = async (app, ctx) => {
|
|
|
80
82
|
app.context = ctx;
|
|
81
83
|
app.data = app.data || {};
|
|
82
84
|
app.data.frameListeners = (0, import_event.initAnimationFrame)(ctx);
|
|
83
|
-
(0, import_prepare.prepareRequire)(
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
85
|
+
(0, import_prepare.prepareRequire)(
|
|
86
|
+
{
|
|
87
|
+
functions: ctx.functions,
|
|
88
|
+
utils: ctx.utils,
|
|
89
|
+
snippets: ctx.snippets,
|
|
90
|
+
...ctx.files
|
|
91
|
+
},
|
|
92
|
+
ctx
|
|
93
|
+
);
|
|
89
94
|
(0, import_syncExtend.initializeSync)(app, ctx);
|
|
90
95
|
(0, import_syncExtend.initializeInspect)(app, ctx);
|
|
91
96
|
(0, import_syncExtend.initializeNotifications)(app, ctx);
|
package/dist/cjs/define.js
CHANGED
|
@@ -26,16 +26,14 @@ const defaultDefine = {
|
|
|
26
26
|
routes: (param) => param,
|
|
27
27
|
// deps: (param, el) => param || el.parent.deps,
|
|
28
28
|
$router: (param, el) => {
|
|
29
|
-
if (!param)
|
|
30
|
-
return;
|
|
29
|
+
if (!param) return;
|
|
31
30
|
const obj = { tag: "fragment", ...param };
|
|
32
31
|
const set = () => {
|
|
33
32
|
el.set(obj, { preventDefineUpdate: "$router" });
|
|
34
33
|
};
|
|
35
34
|
if (el.props && el.props.lazyLoad) {
|
|
36
35
|
window.requestAnimationFrame(set);
|
|
37
|
-
} else
|
|
38
|
-
set();
|
|
36
|
+
} else set();
|
|
39
37
|
return obj;
|
|
40
38
|
},
|
|
41
39
|
$collection: import_atoms.Collection.define.$collection,
|
|
@@ -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,48 +26,67 @@ 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
|
|
30
|
-
__export(
|
|
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: () =>
|
|
35
|
+
default: () => index_default
|
|
36
36
|
});
|
|
37
|
-
module.exports = __toCommonJS(
|
|
37
|
+
module.exports = __toCommonJS(index_exports);
|
|
38
38
|
var import_utils = require("@domql/utils");
|
|
39
|
-
var utils = __toESM(require("./utilImports"), 1);
|
|
40
|
-
var import_router = require("./router");
|
|
41
|
-
var import_ferchOnCreate = require("./ferchOnCreate");
|
|
42
|
-
var import_options = __toESM(require("./options"), 1);
|
|
39
|
+
var utils = __toESM(require("./utilImports.js"), 1);
|
|
40
|
+
var import_router = require("./router.js");
|
|
41
|
+
var import_ferchOnCreate = require("./ferchOnCreate.js");
|
|
42
|
+
var import_options = __toESM(require("./options.js"), 1);
|
|
43
43
|
var import_dynamic = __toESM(require("@symbo.ls/init/dynamic.json"), 1);
|
|
44
|
-
var import_createDomql = require("./createDomql");
|
|
44
|
+
var import_createDomql = require("./createDomql.js");
|
|
45
45
|
const mergeWithLocalFile = (options, optionsExternalFile) => (0, import_utils.deepMerge)(
|
|
46
46
|
options,
|
|
47
47
|
(0, import_utils.isObject)(optionsExternalFile) ? optionsExternalFile : import_dynamic.default || {}
|
|
48
48
|
);
|
|
49
49
|
const create = (App, options = import_options.default, optionsExternalFile) => {
|
|
50
|
-
const redefinedOptions = {
|
|
50
|
+
const redefinedOptions = {
|
|
51
|
+
...import_options.default,
|
|
52
|
+
...mergeWithLocalFile(options, optionsExternalFile)
|
|
53
|
+
};
|
|
51
54
|
const domqlApp = (0, import_createDomql.createDomqlElement)(App, redefinedOptions);
|
|
52
55
|
(0, import_router.popStateRouter)(domqlApp, redefinedOptions);
|
|
53
56
|
if (redefinedOptions.on && redefinedOptions.on.create)
|
|
54
|
-
redefinedOptions.on.create(
|
|
57
|
+
redefinedOptions.on.create(
|
|
58
|
+
domqlApp,
|
|
59
|
+
domqlApp.state,
|
|
60
|
+
domqlApp.context,
|
|
61
|
+
redefinedOptions
|
|
62
|
+
);
|
|
55
63
|
return domqlApp;
|
|
56
64
|
};
|
|
57
65
|
const createAsync = (App, options = import_options.default, optionsExternalFile) => {
|
|
58
66
|
const domqlApp = create(App, options, optionsExternalFile);
|
|
59
|
-
const redefinedOptions = {
|
|
67
|
+
const redefinedOptions = {
|
|
68
|
+
...import_options.default,
|
|
69
|
+
...mergeWithLocalFile(options, optionsExternalFile)
|
|
70
|
+
};
|
|
60
71
|
const key = redefinedOptions.key;
|
|
61
72
|
(0, import_ferchOnCreate.fetchAsync)(domqlApp, key, { utils, ...redefinedOptions });
|
|
62
73
|
return domqlApp;
|
|
63
74
|
};
|
|
64
75
|
const createSync = async (App, options = import_options.default, optionsExternalFile) => {
|
|
65
|
-
const redefinedOptions = {
|
|
76
|
+
const redefinedOptions = {
|
|
77
|
+
...import_options.default,
|
|
78
|
+
...mergeWithLocalFile(options, optionsExternalFile)
|
|
79
|
+
};
|
|
66
80
|
const key = options.key;
|
|
67
81
|
await (0, import_ferchOnCreate.fetchSync)(key, redefinedOptions);
|
|
68
82
|
const domqlApp = await (0, import_createDomql.createDomqlElement)(App, redefinedOptions);
|
|
69
83
|
if (redefinedOptions.on && redefinedOptions.on.create)
|
|
70
|
-
await redefinedOptions.on.create(
|
|
84
|
+
await redefinedOptions.on.create(
|
|
85
|
+
domqlApp,
|
|
86
|
+
domqlApp.state,
|
|
87
|
+
domqlApp.context,
|
|
88
|
+
redefinedOptions
|
|
89
|
+
);
|
|
71
90
|
return domqlApp;
|
|
72
91
|
};
|
|
73
92
|
const createSkeleton = (App = {}, options = import_options.default, optionsExternalFile) => {
|
|
@@ -80,4 +99,4 @@ const createSkeleton = (App = {}, options = import_options.default, optionsExter
|
|
|
80
99
|
optionsExternalFile
|
|
81
100
|
);
|
|
82
101
|
};
|
|
83
|
-
var
|
|
102
|
+
var index_default = create;
|
package/dist/cjs/initEmotion.js
CHANGED
|
@@ -25,15 +25,14 @@ var import_emotion = require("@domql/emotion");
|
|
|
25
25
|
var import_emotion2 = require("@symbo.ls/emotion");
|
|
26
26
|
var import_init = require("@symbo.ls/init");
|
|
27
27
|
var import_utils = require("@domql/utils");
|
|
28
|
-
var import_options = require("./options");
|
|
28
|
+
var import_options = require("./options.js");
|
|
29
29
|
var import_default_config = require("@symbo.ls/default-config");
|
|
30
30
|
const initEmotion = (key, options = {}) => {
|
|
31
31
|
var _a;
|
|
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, {
|
package/dist/cjs/options.js
CHANGED
|
@@ -23,7 +23,7 @@ __export(options_exports, {
|
|
|
23
23
|
default: () => options_default
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(options_exports);
|
|
26
|
-
var import_define = require("./define");
|
|
26
|
+
var import_define = require("./define.js");
|
|
27
27
|
const DESIGN_SYSTEM_OPTIONS = {
|
|
28
28
|
useReset: true,
|
|
29
29
|
useVariable: true,
|
package/dist/cjs/prepare.js
CHANGED
|
@@ -41,17 +41,15 @@ __export(prepare_exports, {
|
|
|
41
41
|
});
|
|
42
42
|
module.exports = __toCommonJS(prepare_exports);
|
|
43
43
|
var import_utils = require("@domql/utils");
|
|
44
|
-
var import_initEmotion = require("./initEmotion");
|
|
44
|
+
var import_initEmotion = require("./initEmotion.js");
|
|
45
45
|
var uikit = __toESM(require("@symbo.ls/uikit"), 1);
|
|
46
|
-
var utils = __toESM(require("./utilImports"), 1);
|
|
46
|
+
var utils = __toESM(require("./utilImports.js"), 1);
|
|
47
47
|
var routerUtils = __toESM(require("@domql/router"), 1);
|
|
48
|
-
|
|
48
|
+
// @preserve-env
|
|
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;
|
|
@@ -77,7 +75,14 @@ const prepareComponents = (context) => {
|
|
|
77
75
|
return context.components ? { ...UIkitWithPrefix(), ...context.components } : UIkitWithPrefix();
|
|
78
76
|
};
|
|
79
77
|
const prepareUtils = (context) => {
|
|
80
|
-
return {
|
|
78
|
+
return {
|
|
79
|
+
...utils,
|
|
80
|
+
...routerUtils,
|
|
81
|
+
...utils.scratchUtils,
|
|
82
|
+
...context.utils,
|
|
83
|
+
...context.snippets,
|
|
84
|
+
...context.functions
|
|
85
|
+
};
|
|
81
86
|
};
|
|
82
87
|
const prepareMethods = (context) => {
|
|
83
88
|
return {
|
|
@@ -103,16 +108,14 @@ const prepareDependencies = ({
|
|
|
103
108
|
if (version === "loading" || version === "error") {
|
|
104
109
|
continue;
|
|
105
110
|
}
|
|
106
|
-
const random =
|
|
111
|
+
const random = (0, import_utils.isDevelopment)() ? `?${Math.random()}` : "";
|
|
107
112
|
let url = `https://pkg.symbo.ls/${dependency}/${version}.js${random}`;
|
|
108
113
|
if (dependency.split("/").length > 2 || !onlyDotsAndNumbers(version)) {
|
|
109
114
|
url = `https://pkg.symbo.ls/${dependency}${random}`;
|
|
110
115
|
}
|
|
111
|
-
if (dependenciesOnDemand && dependenciesOnDemand[dependency])
|
|
112
|
-
continue;
|
|
116
|
+
if (dependenciesOnDemand && dependenciesOnDemand[dependency]) continue;
|
|
113
117
|
try {
|
|
114
|
-
if (cachedDeps[dependency])
|
|
115
|
-
return;
|
|
118
|
+
if (cachedDeps[dependency]) return;
|
|
116
119
|
cachedDeps[dependency] = true;
|
|
117
120
|
utils.loadJavascriptFileEmbedSync(url, document2);
|
|
118
121
|
} catch (e) {
|
|
@@ -126,8 +129,7 @@ const prepareRequire = (packages, ctx) => {
|
|
|
126
129
|
const initRequire = (ctx2) => (key) => {
|
|
127
130
|
const windowOpts2 = ctx2.window || window;
|
|
128
131
|
const pkg = windowOpts2.packages[key];
|
|
129
|
-
if (typeof pkg === "function")
|
|
130
|
-
return pkg();
|
|
132
|
+
if (typeof pkg === "function") return pkg();
|
|
131
133
|
return pkg;
|
|
132
134
|
};
|
|
133
135
|
const initRequireOnDemand = (ctx2) => (key) => {
|
|
@@ -135,7 +137,7 @@ const prepareRequire = (packages, ctx) => {
|
|
|
135
137
|
const documentOpts = ctx2.document || document;
|
|
136
138
|
const windowOpts2 = ctx2.window || window;
|
|
137
139
|
if (!windowOpts2.packages[key]) {
|
|
138
|
-
const random =
|
|
140
|
+
const random = (0, import_utils.isDevelopment)() ? `?${Math.random()}` : "";
|
|
139
141
|
if (dependenciesOnDemand && dependenciesOnDemand[key]) {
|
|
140
142
|
const version = dependenciesOnDemand[key];
|
|
141
143
|
const url = `https://pkg.symbo.ls/${key}/${version}.js${random}`;
|
|
@@ -169,10 +171,8 @@ const prepareDesignSystem = (key, context) => {
|
|
|
169
171
|
};
|
|
170
172
|
const prepareState = (app, context) => {
|
|
171
173
|
const state = {};
|
|
172
|
-
if (context.state)
|
|
173
|
-
|
|
174
|
-
if (app && app.state)
|
|
175
|
-
(0, import_utils.deepMerge)(state, app.state);
|
|
174
|
+
if (context.state) utils.deepMerge(state, context.state);
|
|
175
|
+
if (app && app.state) (0, import_utils.deepMerge)(state, app.state);
|
|
176
176
|
return (0, import_utils.deepClone)(state);
|
|
177
177
|
};
|
|
178
178
|
const preparePages = (app, context) => {
|
package/dist/cjs/router.js
CHANGED
|
@@ -32,19 +32,15 @@ const DEFAULT_ROUTING_OPTIONS = {
|
|
|
32
32
|
popState: true
|
|
33
33
|
};
|
|
34
34
|
const initRouter = (element, context) => {
|
|
35
|
-
if (context.router === false)
|
|
36
|
-
|
|
37
|
-
else
|
|
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
45
|
const hasRenderRouter = element.on && !(0, import_utils.isUndefined)(element.on.renderRouter);
|
|
50
46
|
if (routerOptions && routerOptions.initRouter && !hasRenderRouter) {
|
|
@@ -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;
|
package/dist/cjs/syncExtend.js
CHANGED
|
@@ -31,12 +31,10 @@ const initializeExtend = (app, ctx) => {
|
|
|
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);
|
|
37
|
+
if ((0, import_utils.isArray)(app.extend)) app.extend.push(import_sync.SyncComponent);
|
|
40
38
|
else if (app.extend) {
|
|
41
39
|
app.extend = [app.extend, import_sync.SyncComponent];
|
|
42
40
|
} else {
|
|
@@ -46,12 +44,10 @@ const initializeSync = (app, ctx) => {
|
|
|
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);
|
|
50
|
+
if ((0, import_utils.isArray)(app.extend)) app.extend.push(import_sync.Inspect);
|
|
55
51
|
else if (app.extend) {
|
|
56
52
|
app.extend = [app.extend, import_sync.Inspect];
|
|
57
53
|
} else {
|
|
@@ -61,12 +57,10 @@ const initializeInspect = (app, ctx) => {
|
|
|
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);
|
|
63
|
+
if ((0, import_utils.isArray)(app.extend)) app.extend.push(import_sync.Notifications);
|
|
70
64
|
else if (app.extend) {
|
|
71
65
|
app.extend = [app.extend, import_sync.Notifications];
|
|
72
66
|
} else {
|
package/dist/esm/createDomql.js
CHANGED
|
@@ -18,9 +18,14 @@ import DOM from "domql";
|
|
|
18
18
|
import * as uikit from "@symbo.ls/uikit";
|
|
19
19
|
import { isString, isNode, isObject } from "@domql/utils";
|
|
20
20
|
import { initAnimationFrame } from "@domql/event";
|
|
21
|
-
import { defaultDefine } from "./define";
|
|
22
|
-
import { initRouter } from "./router";
|
|
23
|
-
import {
|
|
21
|
+
import { defaultDefine } from "./define.js";
|
|
22
|
+
import { initRouter } from "./router.js";
|
|
23
|
+
import {
|
|
24
|
+
initializeExtend,
|
|
25
|
+
initializeInspect,
|
|
26
|
+
initializeNotifications,
|
|
27
|
+
initializeSync
|
|
28
|
+
} from "./syncExtend.js";
|
|
24
29
|
import {
|
|
25
30
|
prepareComponents,
|
|
26
31
|
prepareDependencies,
|
|
@@ -31,12 +36,15 @@ import {
|
|
|
31
36
|
prepareState,
|
|
32
37
|
prepareUtils,
|
|
33
38
|
prepareMethods
|
|
34
|
-
} from "./prepare";
|
|
39
|
+
} from "./prepare.js";
|
|
35
40
|
const prepareContext = (app, context = {}) => {
|
|
36
41
|
const key = context.key = context.key || (isString(app) ? app : "smblsapp");
|
|
37
42
|
context.define = context.define || defaultDefine;
|
|
38
43
|
context.window = prepareWindow(context);
|
|
39
|
-
const [scratcDesignSystem, emotion, registry] = prepareDesignSystem(
|
|
44
|
+
const [scratcDesignSystem, emotion, registry] = prepareDesignSystem(
|
|
45
|
+
key,
|
|
46
|
+
context
|
|
47
|
+
);
|
|
40
48
|
context.designSystem = scratcDesignSystem;
|
|
41
49
|
context.registry = registry;
|
|
42
50
|
context.emotion = emotion;
|
|
@@ -52,8 +60,7 @@ const prepareContext = (app, context = {}) => {
|
|
|
52
60
|
return context;
|
|
53
61
|
};
|
|
54
62
|
const createDomqlElement = async (app, ctx) => {
|
|
55
|
-
if (!isObject(ctx))
|
|
56
|
-
ctx = {};
|
|
63
|
+
if (!isObject(ctx)) ctx = {};
|
|
57
64
|
if (isNode(app)) {
|
|
58
65
|
app = {};
|
|
59
66
|
ctx.parent = app;
|
|
@@ -72,11 +79,14 @@ const createDomqlElement = async (app, ctx) => {
|
|
|
72
79
|
app.context = ctx;
|
|
73
80
|
app.data = app.data || {};
|
|
74
81
|
app.data.frameListeners = initAnimationFrame(ctx);
|
|
75
|
-
prepareRequire(
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
82
|
+
prepareRequire(
|
|
83
|
+
__spreadValues({
|
|
84
|
+
functions: ctx.functions,
|
|
85
|
+
utils: ctx.utils,
|
|
86
|
+
snippets: ctx.snippets
|
|
87
|
+
}, ctx.files),
|
|
88
|
+
ctx
|
|
89
|
+
);
|
|
80
90
|
initializeSync(app, ctx);
|
|
81
91
|
initializeInspect(app, ctx);
|
|
82
92
|
initializeNotifications(app, ctx);
|
package/dist/esm/define.js
CHANGED
|
@@ -19,16 +19,14 @@ const defaultDefine = {
|
|
|
19
19
|
routes: (param) => param,
|
|
20
20
|
// deps: (param, el) => param || el.parent.deps,
|
|
21
21
|
$router: (param, el) => {
|
|
22
|
-
if (!param)
|
|
23
|
-
return;
|
|
22
|
+
if (!param) return;
|
|
24
23
|
const obj = __spreadValues({ tag: "fragment" }, param);
|
|
25
24
|
const set = () => {
|
|
26
25
|
el.set(obj, { preventDefineUpdate: "$router" });
|
|
27
26
|
};
|
|
28
27
|
if (el.props && el.props.lazyLoad) {
|
|
29
28
|
window.requestAnimationFrame(set);
|
|
30
|
-
} else
|
|
31
|
-
set();
|
|
29
|
+
} else set();
|
|
32
30
|
return obj;
|
|
33
31
|
},
|
|
34
32
|
$collection: Collection.define.$collection,
|
|
@@ -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
|
@@ -15,12 +15,12 @@ var __spreadValues = (a, b) => {
|
|
|
15
15
|
return a;
|
|
16
16
|
};
|
|
17
17
|
import { deepMerge, isObject, isUndefined } from "@domql/utils";
|
|
18
|
-
import * as utils from "./utilImports";
|
|
19
|
-
import { popStateRouter } from "./router";
|
|
20
|
-
import { fetchAsync, fetchSync } from "./ferchOnCreate";
|
|
21
|
-
import DEFAULT_CREATE_OPTIONS from "./options";
|
|
18
|
+
import * as utils from "./utilImports.js";
|
|
19
|
+
import { popStateRouter } from "./router.js";
|
|
20
|
+
import { fetchAsync, fetchSync } from "./ferchOnCreate.js";
|
|
21
|
+
import DEFAULT_CREATE_OPTIONS from "./options.js";
|
|
22
22
|
import DYNAMIC_JSON from "@symbo.ls/init/dynamic.json";
|
|
23
|
-
import { createDomqlElement } from "./createDomql";
|
|
23
|
+
import { createDomqlElement } from "./createDomql.js";
|
|
24
24
|
const mergeWithLocalFile = (options, optionsExternalFile) => deepMerge(
|
|
25
25
|
options,
|
|
26
26
|
isObject(optionsExternalFile) ? optionsExternalFile : DYNAMIC_JSON || {}
|
|
@@ -30,7 +30,12 @@ const create = (App, options = DEFAULT_CREATE_OPTIONS, optionsExternalFile) => {
|
|
|
30
30
|
const domqlApp = createDomqlElement(App, redefinedOptions);
|
|
31
31
|
popStateRouter(domqlApp, redefinedOptions);
|
|
32
32
|
if (redefinedOptions.on && redefinedOptions.on.create)
|
|
33
|
-
redefinedOptions.on.create(
|
|
33
|
+
redefinedOptions.on.create(
|
|
34
|
+
domqlApp,
|
|
35
|
+
domqlApp.state,
|
|
36
|
+
domqlApp.context,
|
|
37
|
+
redefinedOptions
|
|
38
|
+
);
|
|
34
39
|
return domqlApp;
|
|
35
40
|
};
|
|
36
41
|
const createAsync = (App, options = DEFAULT_CREATE_OPTIONS, optionsExternalFile) => {
|
|
@@ -46,7 +51,12 @@ const createSync = async (App, options = DEFAULT_CREATE_OPTIONS, optionsExternal
|
|
|
46
51
|
await fetchSync(key, redefinedOptions);
|
|
47
52
|
const domqlApp = await createDomqlElement(App, redefinedOptions);
|
|
48
53
|
if (redefinedOptions.on && redefinedOptions.on.create)
|
|
49
|
-
await redefinedOptions.on.create(
|
|
54
|
+
await redefinedOptions.on.create(
|
|
55
|
+
domqlApp,
|
|
56
|
+
domqlApp.state,
|
|
57
|
+
domqlApp.context,
|
|
58
|
+
redefinedOptions
|
|
59
|
+
);
|
|
50
60
|
return domqlApp;
|
|
51
61
|
};
|
|
52
62
|
const createSkeleton = (App = {}, options = DEFAULT_CREATE_OPTIONS, optionsExternalFile) => {
|
|
@@ -58,11 +68,11 @@ const createSkeleton = (App = {}, options = DEFAULT_CREATE_OPTIONS, optionsExter
|
|
|
58
68
|
optionsExternalFile
|
|
59
69
|
);
|
|
60
70
|
};
|
|
61
|
-
var
|
|
71
|
+
var index_default = create;
|
|
62
72
|
export {
|
|
63
73
|
create,
|
|
64
74
|
createAsync,
|
|
65
75
|
createSkeleton,
|
|
66
76
|
createSync,
|
|
67
|
-
|
|
77
|
+
index_default as default
|
|
68
78
|
};
|
package/dist/esm/initEmotion.js
CHANGED
|
@@ -18,15 +18,14 @@ import { transformDOMQLEmotion } from "@domql/emotion";
|
|
|
18
18
|
import { emotion as defaultEmotion } from "@symbo.ls/emotion";
|
|
19
19
|
import { init } from "@symbo.ls/init";
|
|
20
20
|
import { deepClone, deepMerge } from "@domql/utils";
|
|
21
|
-
import { DESIGN_SYSTEM_OPTIONS } from "./options";
|
|
21
|
+
import { DESIGN_SYSTEM_OPTIONS } from "./options.js";
|
|
22
22
|
import { DEFAULT_CONFIG } from "@symbo.ls/default-config";
|
|
23
23
|
const initEmotion = (key, options = {}) => {
|
|
24
24
|
var _a;
|
|
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({
|
package/dist/esm/options.js
CHANGED
package/dist/esm/prepare.js
CHANGED
|
@@ -22,19 +22,18 @@ import {
|
|
|
22
22
|
deepMerge,
|
|
23
23
|
deepClone,
|
|
24
24
|
merge,
|
|
25
|
-
checkIfKeyIsComponent
|
|
25
|
+
checkIfKeyIsComponent,
|
|
26
|
+
isDevelopment
|
|
26
27
|
} from "@domql/utils";
|
|
27
|
-
import { initEmotion } from "./initEmotion";
|
|
28
|
+
import { initEmotion } from "./initEmotion.js";
|
|
28
29
|
import * as uikit from "@symbo.ls/uikit";
|
|
29
|
-
import * as utils from "./utilImports";
|
|
30
|
+
import * as utils from "./utilImports.js";
|
|
30
31
|
import * as routerUtils from "@domql/router";
|
|
31
|
-
|
|
32
|
+
// @preserve-env
|
|
32
33
|
const prepareWindow = (context) => {
|
|
33
|
-
if (typeof window === "undefined")
|
|
34
|
-
window = globalThis || {};
|
|
34
|
+
if (typeof window === "undefined") window = globalThis || {};
|
|
35
35
|
if (typeof document === "undefined") {
|
|
36
|
-
if (!window.document)
|
|
37
|
-
window.document = globalThis.document || { body: {} };
|
|
36
|
+
if (!window.document) window.document = globalThis.document || { body: {} };
|
|
38
37
|
document = window.document;
|
|
39
38
|
}
|
|
40
39
|
context.document = context.document || document;
|
|
@@ -85,16 +84,14 @@ const prepareDependencies = ({
|
|
|
85
84
|
if (version === "loading" || version === "error") {
|
|
86
85
|
continue;
|
|
87
86
|
}
|
|
88
|
-
const random =
|
|
87
|
+
const random = isDevelopment() ? `?${Math.random()}` : "";
|
|
89
88
|
let url = `https://pkg.symbo.ls/${dependency}/${version}.js${random}`;
|
|
90
89
|
if (dependency.split("/").length > 2 || !onlyDotsAndNumbers(version)) {
|
|
91
90
|
url = `https://pkg.symbo.ls/${dependency}${random}`;
|
|
92
91
|
}
|
|
93
|
-
if (dependenciesOnDemand && dependenciesOnDemand[dependency])
|
|
94
|
-
continue;
|
|
92
|
+
if (dependenciesOnDemand && dependenciesOnDemand[dependency]) continue;
|
|
95
93
|
try {
|
|
96
|
-
if (cachedDeps[dependency])
|
|
97
|
-
return;
|
|
94
|
+
if (cachedDeps[dependency]) return;
|
|
98
95
|
cachedDeps[dependency] = true;
|
|
99
96
|
utils.loadJavascriptFileEmbedSync(url, document2);
|
|
100
97
|
} catch (e) {
|
|
@@ -108,8 +105,7 @@ const prepareRequire = (packages, ctx) => {
|
|
|
108
105
|
const initRequire = (ctx2) => (key) => {
|
|
109
106
|
const windowOpts2 = ctx2.window || window;
|
|
110
107
|
const pkg = windowOpts2.packages[key];
|
|
111
|
-
if (typeof pkg === "function")
|
|
112
|
-
return pkg();
|
|
108
|
+
if (typeof pkg === "function") return pkg();
|
|
113
109
|
return pkg;
|
|
114
110
|
};
|
|
115
111
|
const initRequireOnDemand = (ctx2) => (key) => {
|
|
@@ -117,7 +113,7 @@ const prepareRequire = (packages, ctx) => {
|
|
|
117
113
|
const documentOpts = ctx2.document || document;
|
|
118
114
|
const windowOpts2 = ctx2.window || window;
|
|
119
115
|
if (!windowOpts2.packages[key]) {
|
|
120
|
-
const random =
|
|
116
|
+
const random = isDevelopment() ? `?${Math.random()}` : "";
|
|
121
117
|
if (dependenciesOnDemand && dependenciesOnDemand[key]) {
|
|
122
118
|
const version = dependenciesOnDemand[key];
|
|
123
119
|
const url = `https://pkg.symbo.ls/${key}/${version}.js${random}`;
|
|
@@ -151,10 +147,8 @@ const prepareDesignSystem = (key, context) => {
|
|
|
151
147
|
};
|
|
152
148
|
const prepareState = (app, context) => {
|
|
153
149
|
const state = {};
|
|
154
|
-
if (context.state)
|
|
155
|
-
|
|
156
|
-
if (app && app.state)
|
|
157
|
-
deepMerge(state, app.state);
|
|
150
|
+
if (context.state) utils.deepMerge(state, context.state);
|
|
151
|
+
if (app && app.state) deepMerge(state, app.state);
|
|
158
152
|
return deepClone(state);
|
|
159
153
|
};
|
|
160
154
|
const preparePages = (app, context) => {
|
package/dist/esm/router.js
CHANGED
|
@@ -7,19 +7,15 @@ const DEFAULT_ROUTING_OPTIONS = {
|
|
|
7
7
|
popState: true
|
|
8
8
|
};
|
|
9
9
|
const initRouter = (element, context) => {
|
|
10
|
-
if (context.router === false)
|
|
11
|
-
|
|
12
|
-
else
|
|
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
20
|
const hasRenderRouter = element.on && !isUndefined(element.on.renderRouter);
|
|
25
21
|
if (routerOptions && routerOptions.initRouter && !hasRenderRouter) {
|
|
@@ -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;
|
package/dist/esm/syncExtend.js
CHANGED
|
@@ -5,12 +5,10 @@ const initializeExtend = (app, ctx) => {
|
|
|
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);
|
|
11
|
+
if (isArray(app.extend)) app.extend.push(SyncComponent);
|
|
14
12
|
else if (app.extend) {
|
|
15
13
|
app.extend = [app.extend, SyncComponent];
|
|
16
14
|
} else {
|
|
@@ -20,12 +18,10 @@ const initializeSync = (app, ctx) => {
|
|
|
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);
|
|
24
|
+
if (isArray(app.extend)) app.extend.push(Inspect);
|
|
29
25
|
else if (app.extend) {
|
|
30
26
|
app.extend = [app.extend, Inspect];
|
|
31
27
|
} else {
|
|
@@ -35,12 +31,10 @@ const initializeInspect = (app, ctx) => {
|
|
|
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);
|
|
37
|
+
if (isArray(app.extend)) app.extend.push(Notifications);
|
|
44
38
|
else if (app.extend) {
|
|
45
39
|
app.extend = [app.extend, Notifications];
|
|
46
40
|
} else {
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@symbo.ls/create",
|
|
3
|
-
"version": "2.27.
|
|
3
|
+
"version": "2.27.10",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"gitHead": "
|
|
5
|
+
"gitHead": "668d24f518bdb163357897504c5912c085638d3e",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"module": "src/index.js",
|
|
8
8
|
"main": "src/index.js",
|
|
@@ -10,9 +10,9 @@
|
|
|
10
10
|
"jsdelivr": "dist/iife/index.js",
|
|
11
11
|
"exports": {
|
|
12
12
|
".": {
|
|
13
|
-
"default": "./dist/esm/index.js",
|
|
14
13
|
"import": "./dist/esm/index.js",
|
|
15
|
-
"require": "./dist/cjs/index.js"
|
|
14
|
+
"require": "./dist/cjs/index.js",
|
|
15
|
+
"default": "./dist/esm/index.js"
|
|
16
16
|
}
|
|
17
17
|
},
|
|
18
18
|
"source": "src/index.js",
|
|
@@ -22,24 +22,24 @@
|
|
|
22
22
|
],
|
|
23
23
|
"scripts": {
|
|
24
24
|
"copy:package:cjs": "cp ../../build/package-cjs.json dist/cjs/package.json",
|
|
25
|
-
"build:esm": "npx esbuild src/*.js --target=es2017 --format=esm --outdir=dist/esm",
|
|
26
|
-
"build:cjs": "npx esbuild src/*.js --target=node16 --format=cjs --outdir=dist/cjs",
|
|
27
|
-
"build:iife": "npx esbuild src/*.js --target=node16 --format=iife --outdir=dist/iife",
|
|
25
|
+
"build:esm": "npx cross-env NODE_ENV=$NODE_ENV npx esbuild src/*.js --target=es2017 --format=esm --outdir=dist/esm",
|
|
26
|
+
"build:cjs": "npx cross-env NODE_ENV=$NODE_ENV npx esbuild src/*.js --target=node16 --format=cjs --outdir=dist/cjs",
|
|
27
|
+
"build:iife": "npx cross-env NODE_ENV=$NODE_ENV npx esbuild src/*.js --target=node16 --format=iife --outdir=dist/iife",
|
|
28
28
|
"build": "rimraf -I dist; npm run build:cjs; npm run build:esm",
|
|
29
29
|
"prepublish": "npm run build; npm run copy:package:cjs"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@domql/emotion": "^2.27.
|
|
33
|
-
"@domql/event": "^2.27.
|
|
34
|
-
"@domql/report": "^2.27.
|
|
35
|
-
"@domql/router": "^2.27.
|
|
36
|
-
"@symbo.ls/fetch": "^2.27.
|
|
37
|
-
"@symbo.ls/init": "^2.27.
|
|
38
|
-
"@symbo.ls/scratch": "^2.27.
|
|
39
|
-
"@symbo.ls/sync": "^2.27.
|
|
40
|
-
"@symbo.ls/uikit": "^2.27.
|
|
41
|
-
"@symbo.ls/utils": "^2.27.
|
|
42
|
-
"domql": "^2.27.
|
|
32
|
+
"@domql/emotion": "^2.27.10",
|
|
33
|
+
"@domql/event": "^2.27.10",
|
|
34
|
+
"@domql/report": "^2.27.10",
|
|
35
|
+
"@domql/router": "^2.27.10",
|
|
36
|
+
"@symbo.ls/fetch": "^2.27.10",
|
|
37
|
+
"@symbo.ls/init": "^2.27.10",
|
|
38
|
+
"@symbo.ls/scratch": "^2.27.10",
|
|
39
|
+
"@symbo.ls/sync": "^2.27.10",
|
|
40
|
+
"@symbo.ls/uikit": "^2.27.10",
|
|
41
|
+
"@symbo.ls/utils": "^2.27.10",
|
|
42
|
+
"domql": "^2.27.10"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@babel/core": "^7.26.0"
|
package/src/createDomql.js
CHANGED
|
@@ -5,9 +5,14 @@ import * as uikit from '@symbo.ls/uikit'
|
|
|
5
5
|
|
|
6
6
|
import { isString, isNode, isObject } from '@domql/utils'
|
|
7
7
|
import { initAnimationFrame } from '@domql/event'
|
|
8
|
-
import { defaultDefine } from './define'
|
|
9
|
-
import { initRouter } from './router'
|
|
10
|
-
import {
|
|
8
|
+
import { defaultDefine } from './define.js'
|
|
9
|
+
import { initRouter } from './router.js'
|
|
10
|
+
import {
|
|
11
|
+
initializeExtend,
|
|
12
|
+
initializeInspect,
|
|
13
|
+
initializeNotifications,
|
|
14
|
+
initializeSync
|
|
15
|
+
} from './syncExtend.js'
|
|
11
16
|
|
|
12
17
|
import {
|
|
13
18
|
prepareComponents,
|
|
@@ -19,14 +24,17 @@ import {
|
|
|
19
24
|
prepareState,
|
|
20
25
|
prepareUtils,
|
|
21
26
|
prepareMethods
|
|
22
|
-
} from './prepare'
|
|
27
|
+
} from './prepare.js'
|
|
23
28
|
|
|
24
29
|
export const prepareContext = (app, context = {}) => {
|
|
25
30
|
// const rcFileKey = process?.env?.SYMBOLS_KEY
|
|
26
|
-
const key = context.key = context.key || (isString(app) ? app : 'smblsapp')
|
|
31
|
+
const key = (context.key = context.key || (isString(app) ? app : 'smblsapp'))
|
|
27
32
|
context.define = context.define || defaultDefine
|
|
28
33
|
context.window = prepareWindow(context)
|
|
29
|
-
const [scratcDesignSystem, emotion, registry] = prepareDesignSystem(
|
|
34
|
+
const [scratcDesignSystem, emotion, registry] = prepareDesignSystem(
|
|
35
|
+
key,
|
|
36
|
+
context
|
|
37
|
+
)
|
|
30
38
|
context.designSystem = scratcDesignSystem
|
|
31
39
|
context.registry = registry
|
|
32
40
|
context.emotion = emotion
|
|
@@ -65,12 +73,15 @@ export const createDomqlElement = async (app, ctx) => {
|
|
|
65
73
|
app.data = app.data || {}
|
|
66
74
|
app.data.frameListeners = initAnimationFrame(ctx)
|
|
67
75
|
|
|
68
|
-
prepareRequire(
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
76
|
+
prepareRequire(
|
|
77
|
+
{
|
|
78
|
+
functions: ctx.functions,
|
|
79
|
+
utils: ctx.utils,
|
|
80
|
+
snippets: ctx.snippets,
|
|
81
|
+
...ctx.files
|
|
82
|
+
},
|
|
83
|
+
ctx
|
|
84
|
+
)
|
|
74
85
|
|
|
75
86
|
initializeSync(app, ctx)
|
|
76
87
|
initializeInspect(app, ctx)
|
package/src/index.js
CHANGED
|
@@ -2,36 +2,57 @@
|
|
|
2
2
|
|
|
3
3
|
import { deepMerge, isObject, isUndefined } from '@domql/utils'
|
|
4
4
|
|
|
5
|
-
import * as utils from './utilImports'
|
|
5
|
+
import * as utils from './utilImports.js'
|
|
6
6
|
|
|
7
|
-
import { popStateRouter } from './router'
|
|
8
|
-
import { fetchAsync, fetchSync } from './ferchOnCreate'
|
|
7
|
+
import { popStateRouter } from './router.js'
|
|
8
|
+
import { fetchAsync, fetchSync } from './ferchOnCreate.js'
|
|
9
9
|
|
|
10
|
-
import DEFAULT_CREATE_OPTIONS from './options'
|
|
11
|
-
import DYNAMIC_JSON from '@symbo.ls/init/dynamic.json'
|
|
12
|
-
import { createDomqlElement } from './createDomql'
|
|
10
|
+
import DEFAULT_CREATE_OPTIONS from './options.js'
|
|
11
|
+
import DYNAMIC_JSON from '@symbo.ls/init/dynamic.json' with { type: 'json' }
|
|
12
|
+
import { createDomqlElement } from './createDomql.js'
|
|
13
13
|
|
|
14
|
-
const mergeWithLocalFile = (options, optionsExternalFile) =>
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
)
|
|
14
|
+
const mergeWithLocalFile = (options, optionsExternalFile) =>
|
|
15
|
+
deepMerge(
|
|
16
|
+
options,
|
|
17
|
+
isObject(optionsExternalFile) ? optionsExternalFile : DYNAMIC_JSON || {}
|
|
18
|
+
)
|
|
18
19
|
|
|
19
|
-
export const create = (
|
|
20
|
-
|
|
20
|
+
export const create = (
|
|
21
|
+
App,
|
|
22
|
+
options = DEFAULT_CREATE_OPTIONS,
|
|
23
|
+
optionsExternalFile
|
|
24
|
+
) => {
|
|
25
|
+
const redefinedOptions = {
|
|
26
|
+
...DEFAULT_CREATE_OPTIONS,
|
|
27
|
+
...mergeWithLocalFile(options, optionsExternalFile)
|
|
28
|
+
}
|
|
21
29
|
|
|
22
30
|
const domqlApp = createDomqlElement(App, redefinedOptions)
|
|
23
31
|
|
|
24
32
|
popStateRouter(domqlApp, redefinedOptions)
|
|
25
33
|
|
|
26
|
-
if (redefinedOptions.on && redefinedOptions.on.create)
|
|
34
|
+
if (redefinedOptions.on && redefinedOptions.on.create)
|
|
35
|
+
redefinedOptions.on.create(
|
|
36
|
+
domqlApp,
|
|
37
|
+
domqlApp.state,
|
|
38
|
+
domqlApp.context,
|
|
39
|
+
redefinedOptions
|
|
40
|
+
)
|
|
27
41
|
|
|
28
42
|
return domqlApp
|
|
29
43
|
}
|
|
30
44
|
|
|
31
|
-
export const createAsync = (
|
|
45
|
+
export const createAsync = (
|
|
46
|
+
App,
|
|
47
|
+
options = DEFAULT_CREATE_OPTIONS,
|
|
48
|
+
optionsExternalFile
|
|
49
|
+
) => {
|
|
32
50
|
const domqlApp = create(App, options, optionsExternalFile)
|
|
33
51
|
|
|
34
|
-
const redefinedOptions = {
|
|
52
|
+
const redefinedOptions = {
|
|
53
|
+
...DEFAULT_CREATE_OPTIONS,
|
|
54
|
+
...mergeWithLocalFile(options, optionsExternalFile)
|
|
55
|
+
}
|
|
35
56
|
// const SYMBOLS_KEY = process.env.SYMBOLS_KEY
|
|
36
57
|
const key = redefinedOptions.key
|
|
37
58
|
fetchAsync(domqlApp, key, { utils, ...redefinedOptions })
|
|
@@ -39,20 +60,37 @@ export const createAsync = (App, options = DEFAULT_CREATE_OPTIONS, optionsExtern
|
|
|
39
60
|
return domqlApp
|
|
40
61
|
}
|
|
41
62
|
|
|
42
|
-
export const createSync = async (
|
|
43
|
-
|
|
63
|
+
export const createSync = async (
|
|
64
|
+
App,
|
|
65
|
+
options = DEFAULT_CREATE_OPTIONS,
|
|
66
|
+
optionsExternalFile
|
|
67
|
+
) => {
|
|
68
|
+
const redefinedOptions = {
|
|
69
|
+
...DEFAULT_CREATE_OPTIONS,
|
|
70
|
+
...mergeWithLocalFile(options, optionsExternalFile)
|
|
71
|
+
}
|
|
44
72
|
|
|
45
73
|
// const SYMBOLS_KEY = process.env.SYMBOLS_KEY
|
|
46
74
|
const key = options.key
|
|
47
75
|
await fetchSync(key, redefinedOptions)
|
|
48
76
|
|
|
49
77
|
const domqlApp = await createDomqlElement(App, redefinedOptions)
|
|
50
|
-
if (redefinedOptions.on && redefinedOptions.on.create)
|
|
78
|
+
if (redefinedOptions.on && redefinedOptions.on.create)
|
|
79
|
+
await redefinedOptions.on.create(
|
|
80
|
+
domqlApp,
|
|
81
|
+
domqlApp.state,
|
|
82
|
+
domqlApp.context,
|
|
83
|
+
redefinedOptions
|
|
84
|
+
)
|
|
51
85
|
|
|
52
86
|
return domqlApp
|
|
53
87
|
}
|
|
54
88
|
|
|
55
|
-
export const createSkeleton = (
|
|
89
|
+
export const createSkeleton = (
|
|
90
|
+
App = {},
|
|
91
|
+
options = DEFAULT_CREATE_OPTIONS,
|
|
92
|
+
optionsExternalFile
|
|
93
|
+
) => {
|
|
56
94
|
return create(
|
|
57
95
|
{
|
|
58
96
|
deps: { isUndefined },
|
package/src/initEmotion.js
CHANGED
|
@@ -5,7 +5,7 @@ import { emotion as defaultEmotion } from '@symbo.ls/emotion'
|
|
|
5
5
|
import { init } from '@symbo.ls/init'
|
|
6
6
|
import { deepClone, deepMerge } from '@domql/utils'
|
|
7
7
|
|
|
8
|
-
import { DESIGN_SYSTEM_OPTIONS } from './options'
|
|
8
|
+
import { DESIGN_SYSTEM_OPTIONS } from './options.js'
|
|
9
9
|
import { DEFAULT_CONFIG } from '@symbo.ls/default-config'
|
|
10
10
|
|
|
11
11
|
export const initEmotion = (key, options = {}) => {
|
|
@@ -15,10 +15,12 @@ export const initEmotion = (key, options = {}) => {
|
|
|
15
15
|
|
|
16
16
|
if (!initOptions.emotion) initOptions.emotion = defaultEmotion
|
|
17
17
|
|
|
18
|
-
const registry =
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
const registry =
|
|
19
|
+
options.registry || transformDOMQLEmotion(initOptions.emotion, options)
|
|
20
|
+
const designSystem =
|
|
21
|
+
initOptions.useDefaultConfig || options.designSystem?.useDefaultConfig
|
|
22
|
+
? deepMerge(options.designSystem, deepClone(DEFAULT_CONFIG))
|
|
23
|
+
: options.designSystem || deepClone(DEFAULT_CONFIG)
|
|
22
24
|
|
|
23
25
|
const scratchSystem = init(designSystem, {
|
|
24
26
|
key,
|
package/src/options.js
CHANGED
package/src/prepare.js
CHANGED
|
@@ -5,19 +5,20 @@ import {
|
|
|
5
5
|
deepMerge,
|
|
6
6
|
deepClone,
|
|
7
7
|
merge,
|
|
8
|
-
checkIfKeyIsComponent
|
|
8
|
+
checkIfKeyIsComponent,
|
|
9
|
+
isDevelopment
|
|
9
10
|
} from '@domql/utils'
|
|
10
|
-
import { initEmotion } from './initEmotion'
|
|
11
|
+
import { initEmotion } from './initEmotion.js'
|
|
11
12
|
|
|
12
13
|
import * as uikit from '@symbo.ls/uikit'
|
|
13
|
-
import * as utils from './utilImports'
|
|
14
|
+
import * as utils from './utilImports.js'
|
|
14
15
|
import * as routerUtils from '@domql/router'
|
|
15
16
|
|
|
16
|
-
|
|
17
|
+
// @preserve-env
|
|
17
18
|
|
|
18
|
-
export const prepareWindow =
|
|
19
|
-
if (typeof
|
|
20
|
-
if (typeof
|
|
19
|
+
export const prepareWindow = context => {
|
|
20
|
+
if (typeof window === 'undefined') window = globalThis || {} // eslint-disable-line
|
|
21
|
+
if (typeof document === 'undefined') {
|
|
21
22
|
if (!window.document) window.document = globalThis.document || { body: {} }
|
|
22
23
|
document = window.document // eslint-disable-line
|
|
23
24
|
}
|
|
@@ -44,20 +45,34 @@ export const UIkitWithPrefix = () => {
|
|
|
44
45
|
}
|
|
45
46
|
|
|
46
47
|
export const prepareComponents = context => {
|
|
47
|
-
return context.components
|
|
48
|
+
return context.components
|
|
49
|
+
? { ...UIkitWithPrefix(), ...context.components }
|
|
50
|
+
: UIkitWithPrefix()
|
|
48
51
|
}
|
|
49
52
|
|
|
50
53
|
export const prepareUtils = context => {
|
|
51
|
-
return {
|
|
54
|
+
return {
|
|
55
|
+
...utils,
|
|
56
|
+
...routerUtils,
|
|
57
|
+
...utils.scratchUtils,
|
|
58
|
+
...context.utils,
|
|
59
|
+
...context.snippets,
|
|
60
|
+
...context.functions
|
|
61
|
+
}
|
|
52
62
|
}
|
|
53
63
|
|
|
54
|
-
export const prepareMethods =
|
|
64
|
+
export const prepareMethods = context => {
|
|
55
65
|
return {
|
|
56
66
|
...(context.methods || {}),
|
|
57
67
|
require: context.utils.require,
|
|
58
68
|
requireOnDemand: context.utils.requireOnDemand,
|
|
59
69
|
call: function (fnKey, ...args) {
|
|
60
|
-
return (
|
|
70
|
+
return (
|
|
71
|
+
context.utils[fnKey] ||
|
|
72
|
+
context.functions[fnKey] ||
|
|
73
|
+
context.methods[fnKey] ||
|
|
74
|
+
context.snippets[fnKey]
|
|
75
|
+
)?.call(this, ...args)
|
|
61
76
|
}
|
|
62
77
|
}
|
|
63
78
|
}
|
|
@@ -77,7 +92,7 @@ export const prepareDependencies = ({
|
|
|
77
92
|
continue
|
|
78
93
|
}
|
|
79
94
|
|
|
80
|
-
const random =
|
|
95
|
+
const random = isDevelopment() ? `?${Math.random()}` : ''
|
|
81
96
|
let url = `https://pkg.symbo.ls/${dependency}/${version}.js${random}`
|
|
82
97
|
|
|
83
98
|
if (dependency.split('/').length > 2 || !onlyDotsAndNumbers(version)) {
|
|
@@ -113,7 +128,7 @@ export const prepareRequire = (packages, ctx) => {
|
|
|
113
128
|
const documentOpts = ctx.document || document
|
|
114
129
|
const windowOpts = ctx.window || window
|
|
115
130
|
if (!windowOpts.packages[key]) {
|
|
116
|
-
const random =
|
|
131
|
+
const random = isDevelopment() ? `?${Math.random()}` : ''
|
|
117
132
|
if (dependenciesOnDemand && dependenciesOnDemand[key]) {
|
|
118
133
|
const version = dependenciesOnDemand[key]
|
|
119
134
|
const url = `https://pkg.symbo.ls/${key}/${version}.js${random}`
|