smbls 3.5.1 → 3.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +48 -2
- package/bin/smbls.js +0 -0
- package/dist/cjs/dynamic.json +1 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/src/createDomql.js +3 -1
- package/dist/cjs/src/define.js +133 -1
- package/dist/cjs/src/index.js +2 -2
- package/dist/cjs/src/init.js +49 -15
- package/dist/cjs/src/options.js +11 -2
- package/dist/cjs/src/prepare.js +14 -58
- package/dist/cjs/src/router.js +1 -0
- package/dist/esm/package.json +1 -1
- package/dist/esm/src/createDomql.js +3 -1
- package/dist/esm/src/define.js +144 -1
- package/dist/esm/src/index.js +1 -1
- package/dist/esm/src/init.js +46 -3
- package/dist/esm/src/options.js +9 -1
- package/dist/esm/src/prepare.js +7 -46
- package/dist/esm/src/router.js +1 -0
- package/dist/iife/index.js +484 -202
- package/package.json +24 -21
- package/src/createDomql.js +4 -1
- package/src/define.js +157 -1
- package/src/index.js +1 -1
- package/src/init.js +49 -3
- package/src/options.js +9 -1
- package/src/prepare.js +10 -64
- package/src/router.js +1 -0
package/README.md
CHANGED
|
@@ -30,7 +30,7 @@ This package re-exports everything from:
|
|
|
30
30
|
| `css-in-props` | CSS properties as props |
|
|
31
31
|
| `attrs-in-props` | HTML attributes as props |
|
|
32
32
|
|
|
33
|
-
It also includes the `@symbo.ls/cli` binary, `@symbo.ls/fetch`, `@symbo.ls/sync`, and `@domql/router`.
|
|
33
|
+
It also includes the `@symbo.ls/cli` binary, `@symbo.ls/fetch`, `@symbo.ls/sync`, `@symbo.ls/helmet`, and `@domql/router`.
|
|
34
34
|
|
|
35
35
|
## Quick Start
|
|
36
36
|
|
|
@@ -54,6 +54,25 @@ init({
|
|
|
54
54
|
})
|
|
55
55
|
```
|
|
56
56
|
|
|
57
|
+
### Theme Switching
|
|
58
|
+
|
|
59
|
+
Themes switch automatically via CSS — no JavaScript re-renders needed:
|
|
60
|
+
|
|
61
|
+
```javascript
|
|
62
|
+
init({
|
|
63
|
+
theme: {
|
|
64
|
+
document: {
|
|
65
|
+
'@dark': { color: 'white', background: 'black' },
|
|
66
|
+
'@light': { color: 'black', background: 'white' }
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
// Auto: system preference drives switching
|
|
72
|
+
// Force: document.documentElement.dataset.theme = 'dark'
|
|
73
|
+
// Custom: add @ocean, @sunset, etc. — activate with data-theme="ocean"
|
|
74
|
+
```
|
|
75
|
+
|
|
57
76
|
### Create an Application
|
|
58
77
|
|
|
59
78
|
```javascript
|
|
@@ -112,7 +131,8 @@ init(config, {
|
|
|
112
131
|
useDocumentTheme: true, // apply document-level theme
|
|
113
132
|
useSvgSprite: true, // create SVG sprite sheet
|
|
114
133
|
useDefaultConfig: false, // use built-in default config
|
|
115
|
-
globalTheme: '
|
|
134
|
+
globalTheme: 'auto', // 'auto' (system preference), 'dark', 'light', or custom theme name
|
|
135
|
+
useThemeSuffixedVars: false, // also generate --theme-name-dark-prop vars (opt-in)
|
|
116
136
|
verbose: false // enable verbose logging
|
|
117
137
|
})
|
|
118
138
|
```
|
|
@@ -133,6 +153,32 @@ import {
|
|
|
133
153
|
} from 'smbls'
|
|
134
154
|
```
|
|
135
155
|
|
|
156
|
+
## Page Metadata
|
|
157
|
+
|
|
158
|
+
Define SEO metadata on your app or individual pages. Values can be static or functions:
|
|
159
|
+
|
|
160
|
+
```javascript
|
|
161
|
+
// app.js — app-level defaults
|
|
162
|
+
export default {
|
|
163
|
+
metadata: {
|
|
164
|
+
title: 'My App',
|
|
165
|
+
description: 'Built with Symbols',
|
|
166
|
+
'og:image': '/social.png'
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// pages/about.js — page-level overrides
|
|
171
|
+
export const about = {
|
|
172
|
+
metadata: {
|
|
173
|
+
title: 'About Us',
|
|
174
|
+
description: (el, s) => s.aboutDescription
|
|
175
|
+
},
|
|
176
|
+
// ... page content
|
|
177
|
+
}
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
Metadata is applied at runtime (updates `<title>` and `<meta>` tags in the DOM) and during SSR (generates `<head>` HTML via brender). See [`@symbo.ls/helmet`](../../plugins/helmet/) for the full API.
|
|
181
|
+
|
|
136
182
|
## CLI
|
|
137
183
|
|
|
138
184
|
This package also provides the `smbls` CLI binary:
|
package/bin/smbls.js
CHANGED
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"name":"smbls","version":"3.6.1"}
|
|
@@ -100,7 +100,9 @@ const createDomqlElement = async (app, ctx) => {
|
|
|
100
100
|
);
|
|
101
101
|
(0, import_syncExtend.initializeSync)(app, ctx);
|
|
102
102
|
(0, import_syncExtend.initializeNotifications)(app, ctx);
|
|
103
|
-
const
|
|
103
|
+
const doc = ctx.document;
|
|
104
|
+
if (!doc || !doc.createElement) return app;
|
|
105
|
+
const parentNode = ctx.parent || doc.body;
|
|
104
106
|
const domqlCreate = import_domql.default.default && import_domql.default.default.create || import_domql.default.create;
|
|
105
107
|
const smblsApp = await domqlCreate(app, parentNode, ctx.key, {
|
|
106
108
|
verbose: ctx.verbose,
|
package/dist/cjs/src/define.js
CHANGED
|
@@ -21,9 +21,26 @@ __export(define_exports, {
|
|
|
21
21
|
defaultDefine: () => defaultDefine
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(define_exports);
|
|
24
|
+
var import_helmet = require("@symbo.ls/helmet");
|
|
25
|
+
var import_utils = require("@domql/utils");
|
|
26
|
+
const processCollectionParam = (param, state) => {
|
|
27
|
+
if ((0, import_utils.isString)(param)) {
|
|
28
|
+
if (param === "state") return state.parse();
|
|
29
|
+
return (0, import_utils.getChildStateInKey)(param, state);
|
|
30
|
+
}
|
|
31
|
+
if ((0, import_utils.isState)(param)) return param.parse();
|
|
32
|
+
if ((0, import_utils.isNot)(param)("array", "object")) return null;
|
|
33
|
+
return (0, import_utils.deepClone)(param);
|
|
34
|
+
};
|
|
24
35
|
const defaultDefine = {
|
|
25
36
|
routes: (param) => param,
|
|
26
|
-
|
|
37
|
+
metadata: (param, el, state) => {
|
|
38
|
+
if (!param) return;
|
|
39
|
+
const doc = el.context?.document || typeof document !== "undefined" && document;
|
|
40
|
+
if (!doc) return;
|
|
41
|
+
const resolved = (0, import_helmet.resolveMetadata)(param, el, state);
|
|
42
|
+
(0, import_helmet.applyMetadata)(resolved, doc);
|
|
43
|
+
},
|
|
27
44
|
$router: async (param, el) => {
|
|
28
45
|
if (!param) return;
|
|
29
46
|
const obj = { tag: "fragment", ...param };
|
|
@@ -34,5 +51,120 @@ const defaultDefine = {
|
|
|
34
51
|
window.requestAnimationFrame(set);
|
|
35
52
|
} else await set();
|
|
36
53
|
return obj;
|
|
54
|
+
},
|
|
55
|
+
$collection: async (param, el, state) => {
|
|
56
|
+
const { __ref: ref } = el;
|
|
57
|
+
const {
|
|
58
|
+
children: childrenProps,
|
|
59
|
+
childrenAs,
|
|
60
|
+
childExtends
|
|
61
|
+
} = el.props || {};
|
|
62
|
+
const children = childrenProps && await (0, import_utils.exec)(childrenProps, el, state);
|
|
63
|
+
const childrenAsDefault = childrenAs || "props";
|
|
64
|
+
if (children) {
|
|
65
|
+
if ((0, import_utils.isObject)(children)) {
|
|
66
|
+
param = (0, import_utils.deepClone)(children);
|
|
67
|
+
param = Object.keys(param).map((v) => {
|
|
68
|
+
const val = param[v];
|
|
69
|
+
return (0, import_utils.isObjectLike)(val) ? { ...val, extends: v } : { extends: v, value: val };
|
|
70
|
+
});
|
|
71
|
+
} else if ((0, import_utils.isArray)(children)) {
|
|
72
|
+
param = (0, import_utils.deepClone)(children);
|
|
73
|
+
if (childrenAsDefault && childrenAsDefault !== "element") {
|
|
74
|
+
param = param.map((v) => ({
|
|
75
|
+
...childExtends && { extends: childExtends },
|
|
76
|
+
[childrenAsDefault]: (0, import_utils.isObjectLike)(v) ? v : childrenAsDefault === "state" ? { value: v } : { text: v }
|
|
77
|
+
}));
|
|
78
|
+
}
|
|
79
|
+
} else if ((0, import_utils.isString)(children) || (0, import_utils.isNumber)(children)) {
|
|
80
|
+
el.removeContent();
|
|
81
|
+
el.content = { text: param };
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
if (!param) return;
|
|
86
|
+
param = processCollectionParam(param, state);
|
|
87
|
+
if (!param) return;
|
|
88
|
+
if (ref.__collectionCache) {
|
|
89
|
+
const equals = JSON.stringify(param) === JSON.stringify(ref.__collectionCache);
|
|
90
|
+
if (equals) {
|
|
91
|
+
ref.__noCollectionDifference = true;
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
ref.__collectionCache = (0, import_utils.deepClone)(param);
|
|
95
|
+
delete ref.__noCollectionDifference;
|
|
96
|
+
} else {
|
|
97
|
+
ref.__collectionCache = (0, import_utils.deepClone)(param);
|
|
98
|
+
}
|
|
99
|
+
const obj = { tag: "fragment", ignoreChildProps: true, childProps: el.props && el.props.childProps };
|
|
100
|
+
for (const key in param) {
|
|
101
|
+
const value = param[key];
|
|
102
|
+
if (value) obj[key] = (0, import_utils.isObjectLike)(value) ? value : { value };
|
|
103
|
+
}
|
|
104
|
+
el.removeContent();
|
|
105
|
+
el.content = obj;
|
|
106
|
+
},
|
|
107
|
+
$setCollection: async (param, el, state) => {
|
|
108
|
+
if (!param) return;
|
|
109
|
+
param = processCollectionParam(param, state);
|
|
110
|
+
if (!param) return;
|
|
111
|
+
const data = ((0, import_utils.isArray)(param) ? param : (0, import_utils.isObject)(param) ? Object.values(param) : []).map((item) => !(0, import_utils.isObjectLike)(item) ? { value: item } : item);
|
|
112
|
+
if (data.length) {
|
|
113
|
+
const t = setTimeout(() => {
|
|
114
|
+
el.set({ tag: "fragment", ...data }, { preventDefineUpdate: "$setCollection" });
|
|
115
|
+
clearTimeout(t);
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
return data;
|
|
119
|
+
},
|
|
120
|
+
$stateCollection: async (param, el, state) => {
|
|
121
|
+
const { children, childrenAs } = el.props || {};
|
|
122
|
+
if (!param || children || childrenAs) return;
|
|
123
|
+
param = processCollectionParam(param, state);
|
|
124
|
+
if (!param) return;
|
|
125
|
+
const { __ref: ref } = el;
|
|
126
|
+
if (ref.__stateCollectionCache) {
|
|
127
|
+
const equals = JSON.stringify(param) === JSON.stringify(ref.__stateCollectionCache);
|
|
128
|
+
if (equals) {
|
|
129
|
+
ref.__noCollectionDifference = true;
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
ref.__stateCollectionCache = (0, import_utils.deepClone)(param);
|
|
133
|
+
delete ref.__noCollectionDifference;
|
|
134
|
+
} else {
|
|
135
|
+
ref.__stateCollectionCache = (0, import_utils.deepClone)(param);
|
|
136
|
+
}
|
|
137
|
+
const obj = { tag: "fragment", ignoreChildProps: true, childProps: el.props && el.props.childProps };
|
|
138
|
+
for (const key in param) {
|
|
139
|
+
const value = param[key];
|
|
140
|
+
if (value) obj[key] = { state: (0, import_utils.isObjectLike)(value) ? value : { value } };
|
|
141
|
+
}
|
|
142
|
+
el.removeContent();
|
|
143
|
+
el.content = obj;
|
|
144
|
+
},
|
|
145
|
+
$propsCollection: async (param, el, state) => {
|
|
146
|
+
const { children, childrenAs } = el.props || {};
|
|
147
|
+
if (!param || children || childrenAs) return;
|
|
148
|
+
param = processCollectionParam(param, state);
|
|
149
|
+
if (!param) return;
|
|
150
|
+
const { __ref: ref } = el;
|
|
151
|
+
if (ref.__propsCollectionCache) {
|
|
152
|
+
const equals = JSON.stringify(param) === JSON.stringify(ref.__propsCollectionCache);
|
|
153
|
+
if (equals) {
|
|
154
|
+
ref.__noCollectionDifference = true;
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
ref.__propsCollectionCache = (0, import_utils.deepClone)(param);
|
|
158
|
+
delete ref.__noCollectionDifference;
|
|
159
|
+
} else {
|
|
160
|
+
ref.__propsCollectionCache = (0, import_utils.deepClone)(param);
|
|
161
|
+
}
|
|
162
|
+
const obj = { tag: "fragment", ignoreChildProps: true, childProps: el.props && el.props.childProps };
|
|
163
|
+
for (const key in param) {
|
|
164
|
+
const value = param[key];
|
|
165
|
+
if (value) obj[key] = { props: (0, import_utils.isObjectLike)(value) ? value : { value } };
|
|
166
|
+
}
|
|
167
|
+
el.removeContent();
|
|
168
|
+
el.content = obj;
|
|
37
169
|
}
|
|
38
170
|
};
|
package/dist/cjs/src/index.js
CHANGED
|
@@ -44,13 +44,13 @@ var utils = __toESM(require("./utilImports.js"), 1);
|
|
|
44
44
|
var import_router = require("./router.js");
|
|
45
45
|
var import_fetchOnCreate = require("./fetchOnCreate.js");
|
|
46
46
|
var import_options = __toESM(require("./options.js"), 1);
|
|
47
|
-
var
|
|
47
|
+
var import_init = require("./init.js");
|
|
48
48
|
var import_createDomql = require("./createDomql.js");
|
|
49
49
|
__reExport(src_exports, require("./init.js"), module.exports);
|
|
50
50
|
var import_options2 = require("./options.js");
|
|
51
51
|
const mergeWithLocalFile = (options, optionsExternalFile) => (0, import_utils.deepMerge)(
|
|
52
52
|
options,
|
|
53
|
-
(0, import_utils.isObject)(optionsExternalFile) ? optionsExternalFile :
|
|
53
|
+
(0, import_utils.isObject)(optionsExternalFile) ? optionsExternalFile : import_init.DYNAMIC_JSON || {}
|
|
54
54
|
);
|
|
55
55
|
const create = (App, options = import_options.default, optionsExternalFile) => {
|
|
56
56
|
const redefinedOptions = {
|
package/dist/cjs/src/init.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
@@ -17,18 +15,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
15
|
}
|
|
18
16
|
return to;
|
|
19
17
|
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
19
|
var init_exports = {};
|
|
30
20
|
__export(init_exports, {
|
|
31
|
-
DYNAMIC_JSON: () =>
|
|
21
|
+
DYNAMIC_JSON: () => DYNAMIC_JSON,
|
|
32
22
|
applyCSS: () => applyCSS,
|
|
33
23
|
init: () => init,
|
|
34
24
|
reinit: () => reinit,
|
|
@@ -39,10 +29,18 @@ module.exports = __toCommonJS(init_exports);
|
|
|
39
29
|
var import_scratch = require("@symbo.ls/scratch");
|
|
40
30
|
var import_utils = require("@domql/utils");
|
|
41
31
|
var import_emotion = require("@symbo.ls/emotion");
|
|
42
|
-
var
|
|
32
|
+
var import_module = require("module");
|
|
33
|
+
const import_meta = {};
|
|
34
|
+
let DYNAMIC_JSON = {};
|
|
35
|
+
try {
|
|
36
|
+
const _url = typeof __filename !== "undefined" ? __filename : import_meta.url;
|
|
37
|
+
const require2 = (0, import_module.createRequire)(_url);
|
|
38
|
+
DYNAMIC_JSON = require2("../dynamic.json");
|
|
39
|
+
} catch {
|
|
40
|
+
}
|
|
43
41
|
const CONFIG = (0, import_scratch.getActiveConfig)();
|
|
44
42
|
const mergeWithLocalFile = (config = CONFIG, options) => {
|
|
45
|
-
const rcfile = (0, import_utils.isObject)(options.localFile) ? options.localFile :
|
|
43
|
+
const rcfile = (0, import_utils.isObject)(options.localFile) ? options.localFile : DYNAMIC_JSON || {};
|
|
46
44
|
const clonedFile = (0, import_utils.deepClone)(rcfile.designSystem || {});
|
|
47
45
|
return (0, import_utils.deepMerge)(config, clonedFile);
|
|
48
46
|
};
|
|
@@ -69,11 +67,12 @@ const init = (config, options = SET_OPTIONS) => {
|
|
|
69
67
|
useIconSprite: options.useIconSprite,
|
|
70
68
|
useDefaultConfig: options.useDefaultConfig,
|
|
71
69
|
globalTheme: options.globalTheme,
|
|
70
|
+
files: options.files,
|
|
72
71
|
...resultConfig
|
|
73
72
|
},
|
|
74
73
|
{ newConfig: options.newConfig }
|
|
75
74
|
);
|
|
76
|
-
const FontFace = (0, import_scratch.getFontFaceString)(conf.font || conf.FONT);
|
|
75
|
+
const FontFace = (0, import_scratch.getFontFaceString)(conf.font || conf.FONT, conf.files);
|
|
77
76
|
const useReset = conf.useReset;
|
|
78
77
|
const useVariable = conf.useVariable;
|
|
79
78
|
const useFontImport = conf.useFontImport;
|
|
@@ -82,7 +81,20 @@ const init = (config, options = SET_OPTIONS) => {
|
|
|
82
81
|
const useIconSprite = conf.useIconSprite;
|
|
83
82
|
const hasIcons = config.icons || config.ICONS;
|
|
84
83
|
if (useFontImport) emotion.injectGlobal(FontFace);
|
|
85
|
-
if (useVariable)
|
|
84
|
+
if (useVariable) {
|
|
85
|
+
emotion.injectGlobal({ ":root": conf.CSS_VARS });
|
|
86
|
+
if (conf.CSS_MEDIA_VARS) {
|
|
87
|
+
const themeStyles = {};
|
|
88
|
+
for (const key in conf.CSS_MEDIA_VARS) {
|
|
89
|
+
if (key.startsWith("@media")) {
|
|
90
|
+
themeStyles[key] = { ":root:not([data-theme])": conf.CSS_MEDIA_VARS[key] };
|
|
91
|
+
} else {
|
|
92
|
+
themeStyles[key] = conf.CSS_MEDIA_VARS[key];
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
emotion.injectGlobal(themeStyles);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
86
98
|
if (useReset) emotion.injectGlobal(conf.reset || conf.RESET);
|
|
87
99
|
const animations = conf.animation || conf.ANIMATION;
|
|
88
100
|
if (animations) {
|
|
@@ -110,6 +122,17 @@ const reinit = (config, options = UPDATE_OPTIONS) => {
|
|
|
110
122
|
});
|
|
111
123
|
if (!options.preventInject) {
|
|
112
124
|
emotion.injectGlobal({ ":root": conf.CSS_VARS });
|
|
125
|
+
if (conf.CSS_MEDIA_VARS) {
|
|
126
|
+
const themeStyles = {};
|
|
127
|
+
for (const key in conf.CSS_MEDIA_VARS) {
|
|
128
|
+
if (key.startsWith("@media")) {
|
|
129
|
+
themeStyles[key] = { ":root:not([data-theme])": conf.CSS_MEDIA_VARS[key] };
|
|
130
|
+
} else {
|
|
131
|
+
themeStyles[key] = conf.CSS_MEDIA_VARS[key];
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
emotion.injectGlobal(themeStyles);
|
|
135
|
+
}
|
|
113
136
|
emotion.injectGlobal(conf.RESET);
|
|
114
137
|
}
|
|
115
138
|
return conf;
|
|
@@ -121,6 +144,17 @@ const applyCSS = (styles, options = UPDATE_OPTIONS) => {
|
|
|
121
144
|
const updateVars = (config, options = UPDATE_OPTIONS) => {
|
|
122
145
|
const emotion = options.emotion || import_emotion.emotion;
|
|
123
146
|
emotion.injectGlobal({ ":root": config.CSS_VARS });
|
|
147
|
+
if (config.CSS_MEDIA_VARS) {
|
|
148
|
+
const themeStyles = {};
|
|
149
|
+
for (const key in config.CSS_MEDIA_VARS) {
|
|
150
|
+
if (key.startsWith("@media")) {
|
|
151
|
+
themeStyles[key] = { ":root:not([data-theme])": config.CSS_MEDIA_VARS[key] };
|
|
152
|
+
} else {
|
|
153
|
+
themeStyles[key] = config.CSS_MEDIA_VARS[key];
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
emotion.injectGlobal(themeStyles);
|
|
157
|
+
}
|
|
124
158
|
};
|
|
125
159
|
const setClass = (props, options = UPDATE_OPTIONS) => {
|
|
126
160
|
};
|
package/dist/cjs/src/options.js
CHANGED
|
@@ -26,7 +26,16 @@ __export(options_exports, {
|
|
|
26
26
|
});
|
|
27
27
|
module.exports = __toCommonJS(options_exports);
|
|
28
28
|
var import_define = require("./define.js");
|
|
29
|
-
var
|
|
29
|
+
var import_module = require("module");
|
|
30
|
+
const import_meta = {};
|
|
31
|
+
let version = "0.0.0";
|
|
32
|
+
try {
|
|
33
|
+
const _url = typeof __filename !== "undefined" ? __filename : import_meta.url;
|
|
34
|
+
const require2 = (0, import_module.createRequire)(_url);
|
|
35
|
+
const pkg = require2("../package.json");
|
|
36
|
+
version = pkg.version;
|
|
37
|
+
} catch {
|
|
38
|
+
}
|
|
30
39
|
const DESIGN_SYSTEM_OPTIONS = {
|
|
31
40
|
useReset: true,
|
|
32
41
|
useVariable: true,
|
|
@@ -45,7 +54,7 @@ const ROUTER_OPTIONS = {
|
|
|
45
54
|
const DEFAULT_CONTEXT = {
|
|
46
55
|
...DESIGN_SYSTEM_OPTIONS,
|
|
47
56
|
router: ROUTER_OPTIONS,
|
|
48
|
-
version
|
|
57
|
+
version
|
|
49
58
|
};
|
|
50
59
|
const CREATE_OPTIONS = {
|
|
51
60
|
state: {},
|
package/dist/cjs/src/prepare.js
CHANGED
|
@@ -28,9 +28,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
29
|
var prepare_exports = {};
|
|
30
30
|
__export(prepare_exports, {
|
|
31
|
-
PACKAGE_MANAGER_TO_CDN: () => PACKAGE_MANAGER_TO_CDN,
|
|
32
|
-
getCDNUrl: () => getCDNUrl,
|
|
33
|
-
getCdnProviderFromConfig: () => getCdnProviderFromConfig,
|
|
31
|
+
PACKAGE_MANAGER_TO_CDN: () => import_smbls_utils.PACKAGE_MANAGER_TO_CDN,
|
|
32
|
+
getCDNUrl: () => import_smbls_utils.getCDNUrl,
|
|
33
|
+
getCdnProviderFromConfig: () => import_smbls_utils.getCdnProviderFromConfig,
|
|
34
34
|
prepareComponents: () => prepareComponents,
|
|
35
35
|
prepareDependencies: () => prepareDependencies,
|
|
36
36
|
prepareDesignSystem: () => prepareDesignSystem,
|
|
@@ -44,10 +44,11 @@ __export(prepare_exports, {
|
|
|
44
44
|
});
|
|
45
45
|
module.exports = __toCommonJS(prepare_exports);
|
|
46
46
|
var import_utils = require("@domql/utils");
|
|
47
|
-
var
|
|
47
|
+
var import_initEmotion = require("@symbo.ls/emotion/initEmotion.js");
|
|
48
48
|
var uikit = __toESM(require("@symbo.ls/uikit"), 1);
|
|
49
49
|
var utils = __toESM(require("./utilImports.js"), 1);
|
|
50
50
|
var routerUtils = __toESM(require("@domql/router"), 1);
|
|
51
|
+
var import_smbls_utils = require("@symbo.ls/smbls-utils");
|
|
51
52
|
// @preserve-env
|
|
52
53
|
const prepareWindow = (context) => {
|
|
53
54
|
const win = typeof window !== "undefined" ? window : globalThis || {};
|
|
@@ -57,51 +58,6 @@ const prepareWindow = (context) => {
|
|
|
57
58
|
context.window = context.window || win;
|
|
58
59
|
return context.window;
|
|
59
60
|
};
|
|
60
|
-
function onlyDotsAndNumbers(str) {
|
|
61
|
-
return /^[0-9.]+$/.test(str) && str !== "";
|
|
62
|
-
}
|
|
63
|
-
const CDN_PROVIDERS = {
|
|
64
|
-
skypack: {
|
|
65
|
-
url: "https://cdn.skypack.dev",
|
|
66
|
-
formatUrl: (pkg, version) => `${CDN_PROVIDERS.skypack.url}/${pkg}${version !== "latest" ? `@${version}` : ""}`
|
|
67
|
-
},
|
|
68
|
-
esmsh: {
|
|
69
|
-
url: "https://esm.sh",
|
|
70
|
-
formatUrl: (pkg, version) => `${CDN_PROVIDERS.esmsh.url}/${pkg}${version !== "latest" ? `@${version}` : ""}`
|
|
71
|
-
},
|
|
72
|
-
unpkg: {
|
|
73
|
-
url: "https://unpkg.com",
|
|
74
|
-
formatUrl: (pkg, version) => `${CDN_PROVIDERS.unpkg.url}/${pkg}${version !== "latest" ? `@${version}` : ""}?module`
|
|
75
|
-
},
|
|
76
|
-
jsdelivr: {
|
|
77
|
-
url: "https://cdn.jsdelivr.net/npm",
|
|
78
|
-
formatUrl: (pkg, version) => `${CDN_PROVIDERS.jsdelivr.url}/${pkg}${version !== "latest" ? `@${version}` : ""}/+esm`
|
|
79
|
-
},
|
|
80
|
-
symbols: {
|
|
81
|
-
url: "https://pkg.symbo.ls",
|
|
82
|
-
formatUrl: (pkg, version) => {
|
|
83
|
-
if (pkg.split("/").length > 2 || !onlyDotsAndNumbers(version)) {
|
|
84
|
-
return `${CDN_PROVIDERS.symbols.url}/${pkg}`;
|
|
85
|
-
}
|
|
86
|
-
return `${CDN_PROVIDERS.symbols.url}/${pkg}/${version}.js`;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
};
|
|
90
|
-
const PACKAGE_MANAGER_TO_CDN = {
|
|
91
|
-
"esm.sh": "esmsh",
|
|
92
|
-
"unpkg": "unpkg",
|
|
93
|
-
"skypack": "skypack",
|
|
94
|
-
"jsdelivr": "jsdelivr",
|
|
95
|
-
"pkg.symbo.ls": "symbols"
|
|
96
|
-
};
|
|
97
|
-
const getCdnProviderFromConfig = (symbolsConfig = {}) => {
|
|
98
|
-
const { packageManager } = symbolsConfig;
|
|
99
|
-
return PACKAGE_MANAGER_TO_CDN[packageManager] || null;
|
|
100
|
-
};
|
|
101
|
-
const getCDNUrl = (packageName, version = "latest", provider = "esmsh") => {
|
|
102
|
-
const cdnConfig = CDN_PROVIDERS[provider] || CDN_PROVIDERS.esmsh;
|
|
103
|
-
return cdnConfig.formatUrl(packageName, version);
|
|
104
|
-
};
|
|
105
61
|
const UIkitWithPrefix = (prefix = "smbls") => {
|
|
106
62
|
const newObj = {};
|
|
107
63
|
for (const key in uikit) {
|
|
@@ -147,7 +103,7 @@ const prepareDependencies = async ({
|
|
|
147
103
|
symbolsConfig
|
|
148
104
|
}) => {
|
|
149
105
|
if (!cdnProvider) {
|
|
150
|
-
cdnProvider = PACKAGE_MANAGER_TO_CDN[packageManager] || getCdnProviderFromConfig(symbolsConfig) || "esmsh";
|
|
106
|
+
cdnProvider = import_smbls_utils.PACKAGE_MANAGER_TO_CDN[packageManager] || (0, import_smbls_utils.getCdnProviderFromConfig)(symbolsConfig) || "esmsh";
|
|
151
107
|
}
|
|
152
108
|
if (!dependencies) return null;
|
|
153
109
|
let hasAny = false;
|
|
@@ -162,7 +118,7 @@ const prepareDependencies = async ({
|
|
|
162
118
|
continue;
|
|
163
119
|
}
|
|
164
120
|
const random = (0, import_utils.isDevelopment)() && preventCaching ? `?${Math.random()}` : "";
|
|
165
|
-
const url = getCDNUrl(dependency, version, cdnProvider) + random;
|
|
121
|
+
const url = (0, import_smbls_utils.getCDNUrl)(dependency, version, cdnProvider) + random;
|
|
166
122
|
try {
|
|
167
123
|
if (cachedDeps[dependency]) return;
|
|
168
124
|
cachedDeps[dependency] = true;
|
|
@@ -171,7 +127,7 @@ const prepareDependencies = async ({
|
|
|
171
127
|
console.error(`Failed to load ${dependency} from ${cdnProvider}:`, e);
|
|
172
128
|
if (cdnProvider !== "symbols") {
|
|
173
129
|
try {
|
|
174
|
-
const fallbackUrl = getCDNUrl(dependency, version, "symbols") + random;
|
|
130
|
+
const fallbackUrl = (0, import_smbls_utils.getCDNUrl)(dependency, version, "symbols") + random;
|
|
175
131
|
await utils.loadRemoteScript(fallbackUrl, { document: document2 });
|
|
176
132
|
console.log(
|
|
177
133
|
`Successfully loaded ${dependency} from fallback (symbols.ls)`
|
|
@@ -189,7 +145,7 @@ const prepareDependencies = async ({
|
|
|
189
145
|
};
|
|
190
146
|
const prepareRequire = async (packages, ctx) => {
|
|
191
147
|
const windowOpts = ctx.window || window;
|
|
192
|
-
const defaultProvider = ctx.cdnProvider || getCdnProviderFromConfig(ctx.symbolsConfig) || "esmsh";
|
|
148
|
+
const defaultProvider = ctx.cdnProvider || (0, import_smbls_utils.getCdnProviderFromConfig)(ctx.symbolsConfig) || "esmsh";
|
|
193
149
|
const initRequire = async (ctx2) => async (key, provider) => {
|
|
194
150
|
const windowOpts2 = ctx2.window || window;
|
|
195
151
|
const pkg = windowOpts2.packages[key];
|
|
@@ -204,7 +160,7 @@ const prepareRequire = async (packages, ctx) => {
|
|
|
204
160
|
const random = (0, import_utils.isDevelopment)() ? `?${Math.random()}` : "";
|
|
205
161
|
if (dependenciesOnDemand && dependenciesOnDemand[key]) {
|
|
206
162
|
const version = dependenciesOnDemand[key];
|
|
207
|
-
const url = getCDNUrl(key, version, provider) + random;
|
|
163
|
+
const url = (0, import_smbls_utils.getCDNUrl)(key, version, provider) + random;
|
|
208
164
|
try {
|
|
209
165
|
await ctx2.utils.loadRemoteScript(url, {
|
|
210
166
|
window: windowOpts2,
|
|
@@ -213,7 +169,7 @@ const prepareRequire = async (packages, ctx) => {
|
|
|
213
169
|
} catch (e) {
|
|
214
170
|
console.error(`Failed to load ${key} from ${provider}:`, e);
|
|
215
171
|
if (provider !== "symbols") {
|
|
216
|
-
const fallbackUrl = getCDNUrl(key, version, "symbols") + random;
|
|
172
|
+
const fallbackUrl = (0, import_smbls_utils.getCDNUrl)(key, version, "symbols") + random;
|
|
217
173
|
await ctx2.utils.loadRemoteScript(fallbackUrl, {
|
|
218
174
|
window: windowOpts2,
|
|
219
175
|
document: documentOpts
|
|
@@ -221,7 +177,7 @@ const prepareRequire = async (packages, ctx) => {
|
|
|
221
177
|
}
|
|
222
178
|
}
|
|
223
179
|
} else {
|
|
224
|
-
const url = getCDNUrl(key, "latest", provider) + random;
|
|
180
|
+
const url = (0, import_smbls_utils.getCDNUrl)(key, "latest", provider) + random;
|
|
225
181
|
try {
|
|
226
182
|
await ctx2.utils.loadRemoteScript(url, {
|
|
227
183
|
window: windowOpts2,
|
|
@@ -230,7 +186,7 @@ const prepareRequire = async (packages, ctx) => {
|
|
|
230
186
|
} catch (e) {
|
|
231
187
|
console.error(`Failed to load ${key} from ${provider}:`, e);
|
|
232
188
|
if (provider !== "symbols") {
|
|
233
|
-
const fallbackUrl = getCDNUrl(key, "latest", "symbols") + random;
|
|
189
|
+
const fallbackUrl = (0, import_smbls_utils.getCDNUrl)(key, "latest", "symbols") + random;
|
|
234
190
|
await ctx2.utils.loadRemoteScript(fallbackUrl, {
|
|
235
191
|
window: windowOpts2,
|
|
236
192
|
document: documentOpts
|
|
@@ -257,7 +213,7 @@ const prepareRequire = async (packages, ctx) => {
|
|
|
257
213
|
}
|
|
258
214
|
};
|
|
259
215
|
const prepareDesignSystem = (key, context) => {
|
|
260
|
-
const [scratcDesignhSystem, emotion, registry] = (0,
|
|
216
|
+
const [scratcDesignhSystem, emotion, registry] = (0, import_initEmotion.initEmotion)(key, context);
|
|
261
217
|
return [scratcDesignhSystem, emotion, registry];
|
|
262
218
|
};
|
|
263
219
|
const prepareState = (app, context) => {
|
package/dist/cjs/src/router.js
CHANGED
|
@@ -37,6 +37,7 @@ const initRouter = (element, context) => {
|
|
|
37
37
|
else context.router = (0, import_utils.merge)(context.router || {}, DEFAULT_ROUTING_OPTIONS);
|
|
38
38
|
const routerOptions = context.router;
|
|
39
39
|
const onRouterRenderDefault = async (el, s) => {
|
|
40
|
+
if (!import_utils.window.location) return;
|
|
40
41
|
const { pathname, search, hash } = import_utils.window.location;
|
|
41
42
|
const url = pathname + search + hash;
|
|
42
43
|
if (el.routes) await (0, import_router.router)(url, el, {}, { initialRender: true });
|
package/dist/esm/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"smbls","version":"3.
|
|
1
|
+
{"name":"smbls","version":"3.6.1"}
|
|
@@ -82,7 +82,9 @@ const createDomqlElement = async (app, ctx) => {
|
|
|
82
82
|
);
|
|
83
83
|
initializeSync(app, ctx);
|
|
84
84
|
initializeNotifications(app, ctx);
|
|
85
|
-
const
|
|
85
|
+
const doc = ctx.document;
|
|
86
|
+
if (!doc || !doc.createElement) return app;
|
|
87
|
+
const parentNode = ctx.parent || doc.body;
|
|
86
88
|
const domqlCreate = DOM.default && DOM.default.create || DOM.create;
|
|
87
89
|
const smblsApp = await domqlCreate(app, parentNode, ctx.key, {
|
|
88
90
|
verbose: ctx.verbose,
|