@symbo.ls/create 2.11.507 → 2.11.511
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/index.js +2 -2
- package/dist/esm/createDomql.js +93 -0
- package/dist/esm/define.js +41 -0
- package/dist/esm/ferchOnCreate.js +34 -0
- package/dist/esm/index.js +68 -0
- package/dist/esm/initEmotion.js +42 -0
- package/dist/esm/options.js +28 -0
- package/dist/esm/prepare.js +203 -0
- package/dist/esm/router.js +61 -0
- package/dist/esm/syncExtend.js +56 -0
- package/dist/esm/utilImports.js +14 -0
- package/package.json +18 -20
- package/src/index.js +2 -2
- package/dist/cjs/bundle/index.js +0 -24609
package/dist/cjs/index.js
CHANGED
|
@@ -51,7 +51,7 @@ const create = (App, options = import_options.default, optionsExternalFile) => {
|
|
|
51
51
|
const domqlApp = (0, import_createDomql.createDomqlElement)(App, redefinedOptions);
|
|
52
52
|
(0, import_router.popStateRouter)(domqlApp, redefinedOptions);
|
|
53
53
|
if (redefinedOptions.on && redefinedOptions.on.create)
|
|
54
|
-
redefinedOptions.on.create(domqlApp, redefinedOptions);
|
|
54
|
+
redefinedOptions.on.create(domqlApp, domqlApp.state, domqlApp.context, redefinedOptions);
|
|
55
55
|
return domqlApp;
|
|
56
56
|
};
|
|
57
57
|
const createAsync = (App, options = import_options.default, optionsExternalFile) => {
|
|
@@ -67,7 +67,7 @@ const createSync = async (App, options = import_options.default, optionsExternal
|
|
|
67
67
|
await (0, import_ferchOnCreate.fetchSync)(key, redefinedOptions);
|
|
68
68
|
const domqlApp = await (0, import_createDomql.createDomqlElement)(App, redefinedOptions);
|
|
69
69
|
if (redefinedOptions.on && redefinedOptions.on.create)
|
|
70
|
-
await redefinedOptions.on.create(domqlApp, redefinedOptions);
|
|
70
|
+
await redefinedOptions.on.create(domqlApp, domqlApp.state, domqlApp.context, redefinedOptions);
|
|
71
71
|
return domqlApp;
|
|
72
72
|
};
|
|
73
73
|
const createSkeleton = (App = {}, options = import_options.default, optionsExternalFile) => {
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
+
var __spreadValues = (a, b) => {
|
|
7
|
+
for (var prop in b || (b = {}))
|
|
8
|
+
if (__hasOwnProp.call(b, prop))
|
|
9
|
+
__defNormalProp(a, prop, b[prop]);
|
|
10
|
+
if (__getOwnPropSymbols)
|
|
11
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
12
|
+
if (__propIsEnum.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
}
|
|
15
|
+
return a;
|
|
16
|
+
};
|
|
17
|
+
import DOM from "domql";
|
|
18
|
+
import * as uikit from "@symbo.ls/uikit";
|
|
19
|
+
import { isString, isNode, isObject } from "@domql/utils";
|
|
20
|
+
import { defaultDefine } from "./define";
|
|
21
|
+
import { initRouter } from "./router";
|
|
22
|
+
import { initializeExtend, initializeInspect, initializeNotifications, initializeSync } from "./syncExtend";
|
|
23
|
+
import {
|
|
24
|
+
initAnimationFrame,
|
|
25
|
+
prepareComponents,
|
|
26
|
+
prepareDependencies,
|
|
27
|
+
prepareDesignSystem,
|
|
28
|
+
prepareWindow,
|
|
29
|
+
prepareRequire,
|
|
30
|
+
preparePages,
|
|
31
|
+
prepareState,
|
|
32
|
+
prepareUtils,
|
|
33
|
+
prepareMethods
|
|
34
|
+
} from "./prepare";
|
|
35
|
+
const prepareContext = (app, context = {}) => {
|
|
36
|
+
const key = context.key = context.key || (isString(app) ? app : "smblsapp");
|
|
37
|
+
context.define = context.define || defaultDefine;
|
|
38
|
+
context.window = prepareWindow(context);
|
|
39
|
+
const [scratcDesignSystem, emotion, registry] = prepareDesignSystem(key, context);
|
|
40
|
+
context.designSystem = scratcDesignSystem;
|
|
41
|
+
context.registry = registry;
|
|
42
|
+
context.emotion = emotion;
|
|
43
|
+
const state = prepareState(app, context);
|
|
44
|
+
context.state = state;
|
|
45
|
+
context.pages = preparePages(app, context);
|
|
46
|
+
context.components = prepareComponents(context);
|
|
47
|
+
context.utils = prepareUtils(context);
|
|
48
|
+
context.dependencies = prepareDependencies(context);
|
|
49
|
+
context.methods = prepareMethods(context);
|
|
50
|
+
context.routerOptions = initRouter(app, context);
|
|
51
|
+
context.defaultExtends = [uikit.Box];
|
|
52
|
+
return context;
|
|
53
|
+
};
|
|
54
|
+
const createDomqlElement = async (app, ctx) => {
|
|
55
|
+
if (!isObject(ctx))
|
|
56
|
+
ctx = {};
|
|
57
|
+
if (isNode(app)) {
|
|
58
|
+
app = {};
|
|
59
|
+
ctx.parent = app;
|
|
60
|
+
}
|
|
61
|
+
if (isString(app)) {
|
|
62
|
+
app = {};
|
|
63
|
+
ctx.key = app;
|
|
64
|
+
}
|
|
65
|
+
if (!isObject(app)) {
|
|
66
|
+
app = {};
|
|
67
|
+
}
|
|
68
|
+
prepareContext(app, ctx);
|
|
69
|
+
app.extend = initializeExtend(app, ctx);
|
|
70
|
+
app.routes = ctx.pages;
|
|
71
|
+
app.state = ctx.state;
|
|
72
|
+
app.context = ctx;
|
|
73
|
+
app.data = app.data || {};
|
|
74
|
+
app.data.frameListeners = initAnimationFrame();
|
|
75
|
+
prepareRequire(__spreadValues({
|
|
76
|
+
functions: ctx.functions,
|
|
77
|
+
utils: ctx.utils,
|
|
78
|
+
snippets: ctx.snippets
|
|
79
|
+
}, ctx.files), ctx);
|
|
80
|
+
initializeSync(app, ctx);
|
|
81
|
+
initializeInspect(app, ctx);
|
|
82
|
+
initializeNotifications(app, ctx);
|
|
83
|
+
const parentNode = ctx.parent || ctx.document.body;
|
|
84
|
+
const domqlCreate = DOM.default && DOM.default.create || DOM.create;
|
|
85
|
+
const smblsApp = await domqlCreate(app, parentNode, ctx.key, __spreadValues({
|
|
86
|
+
verbose: ctx.verbose
|
|
87
|
+
}, ctx.domqlOptions));
|
|
88
|
+
return smblsApp;
|
|
89
|
+
};
|
|
90
|
+
export {
|
|
91
|
+
createDomqlElement,
|
|
92
|
+
prepareContext
|
|
93
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
+
var __spreadValues = (a, b) => {
|
|
7
|
+
for (var prop in b || (b = {}))
|
|
8
|
+
if (__hasOwnProp.call(b, prop))
|
|
9
|
+
__defNormalProp(a, prop, b[prop]);
|
|
10
|
+
if (__getOwnPropSymbols)
|
|
11
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
12
|
+
if (__propIsEnum.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
}
|
|
15
|
+
return a;
|
|
16
|
+
};
|
|
17
|
+
import { Collection } from "@symbo.ls/atoms";
|
|
18
|
+
const defaultDefine = {
|
|
19
|
+
routes: (param) => param,
|
|
20
|
+
// deps: (param, el) => param || el.parent.deps,
|
|
21
|
+
$router: (param, el) => {
|
|
22
|
+
if (!param)
|
|
23
|
+
return;
|
|
24
|
+
const obj = __spreadValues({ tag: "fragment" }, param);
|
|
25
|
+
const set = () => {
|
|
26
|
+
el.set(obj, { preventDefineUpdate: "$router" });
|
|
27
|
+
};
|
|
28
|
+
if (el.props && el.props.lazyLoad) {
|
|
29
|
+
window.requestAnimationFrame(set);
|
|
30
|
+
} else
|
|
31
|
+
set();
|
|
32
|
+
return obj;
|
|
33
|
+
},
|
|
34
|
+
$collection: Collection.define.$collection,
|
|
35
|
+
$setCollection: Collection.define.$setCollection,
|
|
36
|
+
$stateCollection: Collection.define.$stateCollection,
|
|
37
|
+
$propsCollection: Collection.define.$propsCollection
|
|
38
|
+
};
|
|
39
|
+
export {
|
|
40
|
+
defaultDefine
|
|
41
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { isObject } from "@domql/utils";
|
|
2
|
+
import { fetchProject, fetchProjectAsync } from "@symbo.ls/fetch";
|
|
3
|
+
const fetchSync = async (key, options) => {
|
|
4
|
+
if (key && options.editor) {
|
|
5
|
+
try {
|
|
6
|
+
if (!options.editor.async)
|
|
7
|
+
await fetchProject(key, options);
|
|
8
|
+
} catch (e) {
|
|
9
|
+
console.error(e);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
const fetchAsync = (app, key, options, callback) => {
|
|
14
|
+
if (key && options.editor) {
|
|
15
|
+
try {
|
|
16
|
+
if (options.editor.async) {
|
|
17
|
+
fetchProjectAsync(key, options, callback || ((data) => {
|
|
18
|
+
if (isObject(data.designsystem)) {
|
|
19
|
+
options.utils.init(data.designsystem);
|
|
20
|
+
}
|
|
21
|
+
if (isObject(data.state)) {
|
|
22
|
+
app.state.set(data.state);
|
|
23
|
+
}
|
|
24
|
+
}));
|
|
25
|
+
}
|
|
26
|
+
} catch (e) {
|
|
27
|
+
console.error(e);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
export {
|
|
32
|
+
fetchAsync,
|
|
33
|
+
fetchSync
|
|
34
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
+
var __spreadValues = (a, b) => {
|
|
7
|
+
for (var prop in b || (b = {}))
|
|
8
|
+
if (__hasOwnProp.call(b, prop))
|
|
9
|
+
__defNormalProp(a, prop, b[prop]);
|
|
10
|
+
if (__getOwnPropSymbols)
|
|
11
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
12
|
+
if (__propIsEnum.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
}
|
|
15
|
+
return a;
|
|
16
|
+
};
|
|
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";
|
|
22
|
+
import DYNAMIC_JSON from "@symbo.ls/init/dynamic.json";
|
|
23
|
+
import { createDomqlElement } from "./createDomql";
|
|
24
|
+
const mergeWithLocalFile = (options, optionsExternalFile) => deepMerge(
|
|
25
|
+
options,
|
|
26
|
+
isObject(optionsExternalFile) ? optionsExternalFile : DYNAMIC_JSON || {}
|
|
27
|
+
);
|
|
28
|
+
const create = (App, options = DEFAULT_CREATE_OPTIONS, optionsExternalFile) => {
|
|
29
|
+
const redefinedOptions = __spreadValues(__spreadValues({}, DEFAULT_CREATE_OPTIONS), mergeWithLocalFile(options, optionsExternalFile));
|
|
30
|
+
const domqlApp = createDomqlElement(App, redefinedOptions);
|
|
31
|
+
popStateRouter(domqlApp, redefinedOptions);
|
|
32
|
+
if (redefinedOptions.on && redefinedOptions.on.create)
|
|
33
|
+
redefinedOptions.on.create(domqlApp, domqlApp.state, domqlApp.context, redefinedOptions);
|
|
34
|
+
return domqlApp;
|
|
35
|
+
};
|
|
36
|
+
const createAsync = (App, options = DEFAULT_CREATE_OPTIONS, optionsExternalFile) => {
|
|
37
|
+
const domqlApp = create(App, options, optionsExternalFile);
|
|
38
|
+
const redefinedOptions = __spreadValues(__spreadValues({}, DEFAULT_CREATE_OPTIONS), mergeWithLocalFile(options, optionsExternalFile));
|
|
39
|
+
const key = redefinedOptions.key;
|
|
40
|
+
fetchAsync(domqlApp, key, __spreadValues({ utils }, redefinedOptions));
|
|
41
|
+
return domqlApp;
|
|
42
|
+
};
|
|
43
|
+
const createSync = async (App, options = DEFAULT_CREATE_OPTIONS, optionsExternalFile) => {
|
|
44
|
+
const redefinedOptions = __spreadValues(__spreadValues({}, DEFAULT_CREATE_OPTIONS), mergeWithLocalFile(options, optionsExternalFile));
|
|
45
|
+
const key = options.key;
|
|
46
|
+
await fetchSync(key, redefinedOptions);
|
|
47
|
+
const domqlApp = await createDomqlElement(App, redefinedOptions);
|
|
48
|
+
if (redefinedOptions.on && redefinedOptions.on.create)
|
|
49
|
+
await redefinedOptions.on.create(domqlApp, domqlApp.state, domqlApp.context, redefinedOptions);
|
|
50
|
+
return domqlApp;
|
|
51
|
+
};
|
|
52
|
+
const createSkeleton = (App = {}, options = DEFAULT_CREATE_OPTIONS, optionsExternalFile) => {
|
|
53
|
+
return create(
|
|
54
|
+
__spreadValues({
|
|
55
|
+
deps: { isUndefined }
|
|
56
|
+
}, App),
|
|
57
|
+
deepMerge({ domqlOptions: { onlyResolveExtends: true } }, options),
|
|
58
|
+
optionsExternalFile
|
|
59
|
+
);
|
|
60
|
+
};
|
|
61
|
+
var src_default = create;
|
|
62
|
+
export {
|
|
63
|
+
create,
|
|
64
|
+
createAsync,
|
|
65
|
+
createSkeleton,
|
|
66
|
+
createSync,
|
|
67
|
+
src_default as default
|
|
68
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
+
var __spreadValues = (a, b) => {
|
|
7
|
+
for (var prop in b || (b = {}))
|
|
8
|
+
if (__hasOwnProp.call(b, prop))
|
|
9
|
+
__defNormalProp(a, prop, b[prop]);
|
|
10
|
+
if (__getOwnPropSymbols)
|
|
11
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
12
|
+
if (__propIsEnum.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
}
|
|
15
|
+
return a;
|
|
16
|
+
};
|
|
17
|
+
import { transformDOMQLEmotion } from "@domql/emotion";
|
|
18
|
+
import { emotion as defaultEmotion } from "@symbo.ls/emotion";
|
|
19
|
+
import { init } from "@symbo.ls/init";
|
|
20
|
+
import { deepClone, deepMerge } from "@domql/utils";
|
|
21
|
+
import { DESIGN_SYSTEM_OPTIONS } from "./options";
|
|
22
|
+
import { DEFAULT_CONFIG } from "@symbo.ls/default-config";
|
|
23
|
+
const initEmotion = (key, options = {}) => {
|
|
24
|
+
var _a;
|
|
25
|
+
const doc = options.parent || options.document || document;
|
|
26
|
+
const initOptions = options.initOptions || {};
|
|
27
|
+
const emotion = initOptions.emotion;
|
|
28
|
+
if (!initOptions.emotion)
|
|
29
|
+
initOptions.emotion = defaultEmotion;
|
|
30
|
+
const registry = options.registry || transformDOMQLEmotion(initOptions.emotion, options);
|
|
31
|
+
const designSystem = initOptions.useDefaultConfig || ((_a = options.designSystem) == null ? void 0 : _a.useDefaultConfig) ? deepMerge(options.designSystem, deepClone(DEFAULT_CONFIG)) : options.designSystem || deepClone(DEFAULT_CONFIG);
|
|
32
|
+
const scratchSystem = init(designSystem, __spreadValues(__spreadValues({
|
|
33
|
+
key,
|
|
34
|
+
emotion,
|
|
35
|
+
verbose: options.verbose,
|
|
36
|
+
document: doc
|
|
37
|
+
}, DESIGN_SYSTEM_OPTIONS), initOptions));
|
|
38
|
+
return [scratchSystem, emotion, registry];
|
|
39
|
+
};
|
|
40
|
+
export {
|
|
41
|
+
initEmotion
|
|
42
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { defaultDefine } from "./define";
|
|
2
|
+
const DESIGN_SYSTEM_OPTIONS = {
|
|
3
|
+
useReset: true,
|
|
4
|
+
useVariable: true,
|
|
5
|
+
useIconSprite: true,
|
|
6
|
+
useSvgSprite: true,
|
|
7
|
+
useDocumentTheme: true,
|
|
8
|
+
useDefaultIcons: true,
|
|
9
|
+
useFontImport: true,
|
|
10
|
+
useDefaultConfig: true
|
|
11
|
+
};
|
|
12
|
+
const CREATE_OPTIONS = {
|
|
13
|
+
state: {},
|
|
14
|
+
pages: {},
|
|
15
|
+
components: {},
|
|
16
|
+
router: {
|
|
17
|
+
initRouter: true,
|
|
18
|
+
popState: true,
|
|
19
|
+
injectRouterInLinkComponent: true
|
|
20
|
+
},
|
|
21
|
+
define: defaultDefine
|
|
22
|
+
};
|
|
23
|
+
var options_default = CREATE_OPTIONS;
|
|
24
|
+
export {
|
|
25
|
+
CREATE_OPTIONS,
|
|
26
|
+
DESIGN_SYSTEM_OPTIONS,
|
|
27
|
+
options_default as default
|
|
28
|
+
};
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
import {
|
|
21
|
+
isObject,
|
|
22
|
+
deepMerge,
|
|
23
|
+
deepClone,
|
|
24
|
+
merge,
|
|
25
|
+
checkIfKeyIsComponent
|
|
26
|
+
} from "@domql/utils";
|
|
27
|
+
import { initEmotion } from "./initEmotion";
|
|
28
|
+
import * as uikit from "@symbo.ls/uikit";
|
|
29
|
+
import * as utils from "./utilImports";
|
|
30
|
+
import * as routerUtils from "@domql/router";
|
|
31
|
+
const ENV = "development";
|
|
32
|
+
const prepareWindow = (context) => {
|
|
33
|
+
if (typeof window === "undefined")
|
|
34
|
+
window = globalThis || {};
|
|
35
|
+
if (typeof document === "undefined") {
|
|
36
|
+
if (!window.document)
|
|
37
|
+
window.document = globalThis.document || { body: {} };
|
|
38
|
+
document = window.document;
|
|
39
|
+
}
|
|
40
|
+
context.document = context.document || document;
|
|
41
|
+
return context.window = context.window || window;
|
|
42
|
+
};
|
|
43
|
+
function onlyDotsAndNumbers(str) {
|
|
44
|
+
return /^[0-9.]+$/.test(str) && str !== "";
|
|
45
|
+
}
|
|
46
|
+
const UIkitWithPrefix = () => {
|
|
47
|
+
const newObj = {};
|
|
48
|
+
for (const key in uikit) {
|
|
49
|
+
if (Object.prototype.hasOwnProperty.call(uikit, key)) {
|
|
50
|
+
if (checkIfKeyIsComponent(key)) {
|
|
51
|
+
newObj[`smbls.${key}`] = uikit[key];
|
|
52
|
+
} else {
|
|
53
|
+
newObj[key] = uikit[key];
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return newObj;
|
|
58
|
+
};
|
|
59
|
+
const prepareComponents = (context) => {
|
|
60
|
+
return context.components ? __spreadValues(__spreadValues({}, UIkitWithPrefix()), context.components) : UIkitWithPrefix();
|
|
61
|
+
};
|
|
62
|
+
const prepareUtils = (context) => {
|
|
63
|
+
return __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({}, utils), routerUtils), utils.scratchUtils), context.utils), context.snippets), context.functions);
|
|
64
|
+
};
|
|
65
|
+
const prepareMethods = (context) => {
|
|
66
|
+
return __spreadProps(__spreadValues({}, context.methods || {}), {
|
|
67
|
+
require: context.utils.require,
|
|
68
|
+
requireOnDemand: context.utils.requireOnDemand,
|
|
69
|
+
call: function(fnKey, ...args) {
|
|
70
|
+
var _a;
|
|
71
|
+
return (_a = context.utils[fnKey] || context.functions[fnKey] || context.methods[fnKey] || context.snippets[fnKey]) == null ? void 0 : _a.call(this, ...args);
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
};
|
|
75
|
+
const cachedDeps = {};
|
|
76
|
+
const prepareDependencies = ({
|
|
77
|
+
dependencies,
|
|
78
|
+
dependenciesOnDemand,
|
|
79
|
+
document: document2
|
|
80
|
+
}) => {
|
|
81
|
+
if (!dependencies || Object.keys(dependencies).length === 0) {
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
for (const [dependency, version] of Object.entries(dependencies)) {
|
|
85
|
+
if (version === "loading" || version === "error") {
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
const random = ENV === "development" ? `?${Math.random()}` : "";
|
|
89
|
+
let url = `https://pkg.symbo.ls/${dependency}/${version}.js${random}`;
|
|
90
|
+
if (dependency.split("/").length > 2 || !onlyDotsAndNumbers(version)) {
|
|
91
|
+
url = `https://pkg.symbo.ls/${dependency}${random}`;
|
|
92
|
+
}
|
|
93
|
+
if (dependenciesOnDemand && dependenciesOnDemand[dependency])
|
|
94
|
+
continue;
|
|
95
|
+
try {
|
|
96
|
+
if (cachedDeps[dependency])
|
|
97
|
+
return;
|
|
98
|
+
cachedDeps[dependency] = true;
|
|
99
|
+
utils.loadJavascriptFileEmbedSync(url, document2);
|
|
100
|
+
} catch (e) {
|
|
101
|
+
console.error(`Failed to load ${dependency}:`, e);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return dependencies;
|
|
105
|
+
};
|
|
106
|
+
const prepareRequire = (packages, ctx) => {
|
|
107
|
+
const windowOpts = ctx.window || window;
|
|
108
|
+
const initRequire = (ctx2) => (key) => {
|
|
109
|
+
const windowOpts2 = ctx2.window || window;
|
|
110
|
+
const pkg = windowOpts2.packages[key];
|
|
111
|
+
if (typeof pkg === "function")
|
|
112
|
+
return pkg();
|
|
113
|
+
return pkg;
|
|
114
|
+
};
|
|
115
|
+
const initRequireOnDemand = (ctx2) => (key) => {
|
|
116
|
+
const { dependenciesOnDemand } = ctx2;
|
|
117
|
+
const documentOpts = ctx2.document || document;
|
|
118
|
+
const windowOpts2 = ctx2.window || window;
|
|
119
|
+
if (!windowOpts2.packages[key]) {
|
|
120
|
+
const random = ENV === "development" ? `?${Math.random()}` : "";
|
|
121
|
+
if (dependenciesOnDemand && dependenciesOnDemand[key]) {
|
|
122
|
+
const version = dependenciesOnDemand[key];
|
|
123
|
+
const url = `https://pkg.symbo.ls/${key}/${version}.js${random}`;
|
|
124
|
+
ctx2.utils.loadJavascriptFileEmbedSync(url, documentOpts);
|
|
125
|
+
} else {
|
|
126
|
+
const url = `https://pkg.symbo.ls/${key}${random}`;
|
|
127
|
+
ctx2.utils.loadJavascriptFileEmbedSync(url, documentOpts, (d) => {
|
|
128
|
+
windowOpts2.packages[key] = "loadedOnDeman";
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return windowOpts2.require(key);
|
|
133
|
+
};
|
|
134
|
+
if (windowOpts.packages) {
|
|
135
|
+
windowOpts.packages = merge(windowOpts.packages, packages);
|
|
136
|
+
} else {
|
|
137
|
+
windowOpts.packages = packages;
|
|
138
|
+
}
|
|
139
|
+
if (!windowOpts.require) {
|
|
140
|
+
ctx.utils.require = initRequire(ctx);
|
|
141
|
+
windowOpts.require = ctx.utils.require;
|
|
142
|
+
}
|
|
143
|
+
if (!windowOpts.requireOnDemand) {
|
|
144
|
+
ctx.utils.requireOnDemand = initRequireOnDemand(ctx);
|
|
145
|
+
windowOpts.requireOnDemand = ctx.utils.requireOnDemand;
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
const prepareDesignSystem = (key, context) => {
|
|
149
|
+
const [scratcDesignhSystem, emotion, registry] = initEmotion(key, context);
|
|
150
|
+
return [scratcDesignhSystem, emotion, registry];
|
|
151
|
+
};
|
|
152
|
+
const prepareState = (app, context) => {
|
|
153
|
+
const state = {};
|
|
154
|
+
if (context.state)
|
|
155
|
+
utils.deepMerge(state, context.state);
|
|
156
|
+
if (app && app.state)
|
|
157
|
+
deepMerge(state, app.state);
|
|
158
|
+
return deepClone(state);
|
|
159
|
+
};
|
|
160
|
+
const preparePages = (app, context) => {
|
|
161
|
+
if (isObject(app.routes) && isObject(context.pages)) {
|
|
162
|
+
merge(app.routes, context.pages);
|
|
163
|
+
}
|
|
164
|
+
const pages = app.routes || context.pages || {};
|
|
165
|
+
return Object.keys(pages).filter((v) => !v.startsWith("/")).reduce((pages2, v) => {
|
|
166
|
+
const index = v === "index" ? "" : v;
|
|
167
|
+
pages2["/" + index] = pages2[v];
|
|
168
|
+
delete pages2[v];
|
|
169
|
+
return pages2;
|
|
170
|
+
}, pages);
|
|
171
|
+
};
|
|
172
|
+
const initAnimationFrame = () => {
|
|
173
|
+
const frameListeners = /* @__PURE__ */ new Set();
|
|
174
|
+
function requestFrame() {
|
|
175
|
+
for (const element of frameListeners) {
|
|
176
|
+
if (!document.body.contains(element.node)) {
|
|
177
|
+
frameListeners.delete(element);
|
|
178
|
+
} else {
|
|
179
|
+
try {
|
|
180
|
+
(element.on.frame || element.props.onFrame)(element, element.state, element.context);
|
|
181
|
+
} catch (e) {
|
|
182
|
+
console.warn(e);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
window.requestAnimationFrame(requestFrame);
|
|
187
|
+
}
|
|
188
|
+
requestFrame();
|
|
189
|
+
return frameListeners;
|
|
190
|
+
};
|
|
191
|
+
export {
|
|
192
|
+
UIkitWithPrefix,
|
|
193
|
+
initAnimationFrame,
|
|
194
|
+
prepareComponents,
|
|
195
|
+
prepareDependencies,
|
|
196
|
+
prepareDesignSystem,
|
|
197
|
+
prepareMethods,
|
|
198
|
+
preparePages,
|
|
199
|
+
prepareRequire,
|
|
200
|
+
prepareState,
|
|
201
|
+
prepareUtils,
|
|
202
|
+
prepareWindow
|
|
203
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { router as defaultRouter } from "@domql/router";
|
|
2
|
+
import { window, deepMerge, merge, isUndefined } from "@domql/utils";
|
|
3
|
+
import { Link, RouterLink } from "@symbo.ls/uikit";
|
|
4
|
+
const DEFAULT_ROUTING_OPTIONS = {
|
|
5
|
+
initRouter: true,
|
|
6
|
+
injectRouterInLinkComponent: true,
|
|
7
|
+
popState: true
|
|
8
|
+
};
|
|
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);
|
|
16
|
+
const routerOptions = context.router;
|
|
17
|
+
const router = context.utils && context.utils.router ? context.utils.router : defaultRouter;
|
|
18
|
+
const onRouterRenderDefault = (el, s) => {
|
|
19
|
+
const { pathname, search, hash } = window.location;
|
|
20
|
+
const url = pathname + search + hash;
|
|
21
|
+
if (el.routes)
|
|
22
|
+
router(url, el, {}, { initialRender: true });
|
|
23
|
+
};
|
|
24
|
+
const hasRenderRouter = element.on && !isUndefined(element.on.renderRouter);
|
|
25
|
+
if (routerOptions && routerOptions.initRouter && !hasRenderRouter) {
|
|
26
|
+
if (element.on) {
|
|
27
|
+
element.on.renderRouter = onRouterRenderDefault;
|
|
28
|
+
} else {
|
|
29
|
+
element.on = {
|
|
30
|
+
renderRouter: onRouterRenderDefault
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
injectRouterInLinkComponent(routerOptions);
|
|
35
|
+
return routerOptions;
|
|
36
|
+
};
|
|
37
|
+
let popStateFired;
|
|
38
|
+
const popStateRouter = (element, context) => {
|
|
39
|
+
if (popStateFired)
|
|
40
|
+
return;
|
|
41
|
+
popStateFired = true;
|
|
42
|
+
const routerOptions = context.router || DEFAULT_ROUTING_OPTIONS;
|
|
43
|
+
if (!routerOptions.popState)
|
|
44
|
+
return;
|
|
45
|
+
const router = context.utils && context.utils.router ? context.utils.router : defaultRouter;
|
|
46
|
+
window.onpopstate = (e) => {
|
|
47
|
+
const { pathname, search, hash } = window.location;
|
|
48
|
+
const url = pathname + search + hash;
|
|
49
|
+
router(url, element, {}, { pushState: false, scrollToTop: false, level: 0 });
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
const injectRouterInLinkComponent = (routerOptions) => {
|
|
53
|
+
if (routerOptions && routerOptions.injectRouterInLinkComponent) {
|
|
54
|
+
return deepMerge(Link, RouterLink);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
export {
|
|
58
|
+
initRouter,
|
|
59
|
+
injectRouterInLinkComponent,
|
|
60
|
+
popStateRouter
|
|
61
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { isObjectLike, isUndefined, isDevelopment, isArray } from "@domql/utils";
|
|
2
|
+
import { SyncComponent, Inspect, Notifications } from "@symbo.ls/sync";
|
|
3
|
+
const initializeExtend = (app, ctx) => {
|
|
4
|
+
return isObjectLike(app.extend) ? app.extend : [];
|
|
5
|
+
};
|
|
6
|
+
const initializeSync = (app, ctx) => {
|
|
7
|
+
const { editor } = ctx;
|
|
8
|
+
if (!editor)
|
|
9
|
+
return;
|
|
10
|
+
const liveSync = isUndefined(editor.liveSync) ? isDevelopment() : editor.liveSync;
|
|
11
|
+
if (liveSync) {
|
|
12
|
+
if (isArray(app.extend))
|
|
13
|
+
app.extend.push(SyncComponent);
|
|
14
|
+
else if (app.extend) {
|
|
15
|
+
app.extend = [app.extend, SyncComponent];
|
|
16
|
+
} else {
|
|
17
|
+
app.extend = [SyncComponent];
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
const initializeInspect = (app, ctx) => {
|
|
22
|
+
const { editor } = ctx;
|
|
23
|
+
if (!editor)
|
|
24
|
+
return;
|
|
25
|
+
const inspect = isUndefined(editor.inspect) ? isDevelopment() : editor.inspect;
|
|
26
|
+
if (inspect) {
|
|
27
|
+
if (isArray(app.extend))
|
|
28
|
+
app.extend.push(Inspect);
|
|
29
|
+
else if (app.extend) {
|
|
30
|
+
app.extend = [app.extend, Inspect];
|
|
31
|
+
} else {
|
|
32
|
+
app.extend = [Inspect];
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
const initializeNotifications = (app, ctx) => {
|
|
37
|
+
const { editor } = ctx;
|
|
38
|
+
if (!editor)
|
|
39
|
+
return;
|
|
40
|
+
const verbose = isUndefined(editor.verbose) ? isDevelopment() || ctx.verbose : editor.verbose;
|
|
41
|
+
if (verbose) {
|
|
42
|
+
if (isArray(app.extend))
|
|
43
|
+
app.extend.push(Notifications);
|
|
44
|
+
else if (app.extend) {
|
|
45
|
+
app.extend = [app.extend, Notifications];
|
|
46
|
+
} else {
|
|
47
|
+
app.extend = [Notifications];
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
export {
|
|
52
|
+
initializeExtend,
|
|
53
|
+
initializeInspect,
|
|
54
|
+
initializeNotifications,
|
|
55
|
+
initializeSync
|
|
56
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { scratchUtils, scratchSystem, set } from "@symbo.ls/scratch";
|
|
2
|
+
export * from "@domql/utils";
|
|
3
|
+
export * from "@symbo.ls/utils";
|
|
4
|
+
import { init, reinit, applyCSS } from "@symbo.ls/init";
|
|
5
|
+
export * from "@domql/report";
|
|
6
|
+
export * from "@domql/router";
|
|
7
|
+
export {
|
|
8
|
+
applyCSS,
|
|
9
|
+
init,
|
|
10
|
+
reinit,
|
|
11
|
+
scratchSystem,
|
|
12
|
+
scratchUtils,
|
|
13
|
+
set
|
|
14
|
+
};
|