tona 1.0.1 → 1.0.17
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/index.js +1 -3
- package/package.json +8 -7
- package/dist/index.d.mts +0 -30
- package/dist/index.mjs +0 -93
package/dist/index.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
//#region src/constants/env.ts
|
|
3
2
|
const __DEV__ = false;
|
|
4
3
|
|
|
@@ -91,5 +90,4 @@ const defineOptions = (userOptionName, defaultOptions) => {
|
|
|
91
90
|
};
|
|
92
91
|
|
|
93
92
|
//#endregion
|
|
94
|
-
|
|
95
|
-
exports.defineOptions = defineOptions;
|
|
93
|
+
export { createTheme, defineOptions };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tona",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.17",
|
|
4
4
|
"description": "",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "guangzan",
|
|
@@ -8,25 +8,26 @@
|
|
|
8
8
|
"email": "guangzan1999@outlook.com"
|
|
9
9
|
},
|
|
10
10
|
"license": "MIT",
|
|
11
|
-
"homepage": "https://github.com/
|
|
11
|
+
"homepage": "https://github.com/guangzan/tona/tree/main/packages/core#readme",
|
|
12
12
|
"repository": {
|
|
13
13
|
"type": "git",
|
|
14
|
-
"url": "git+https://github.com/
|
|
14
|
+
"url": "git+https://github.com/guangzan/tona.git",
|
|
15
|
+
"directory": "packages/core"
|
|
15
16
|
},
|
|
16
17
|
"bugs": {
|
|
17
|
-
"url": "https://github.com/
|
|
18
|
+
"url": "https://github.com/guangzan/tona/issues"
|
|
18
19
|
},
|
|
19
20
|
"keywords": [
|
|
20
21
|
"博客园"
|
|
21
22
|
],
|
|
23
|
+
"type": "module",
|
|
22
24
|
"exports": {
|
|
23
25
|
".": {
|
|
24
26
|
"types": "./dist/index.d.ts",
|
|
25
|
-
"import": "./dist/index.
|
|
26
|
-
"require": "./dist/index.js"
|
|
27
|
+
"import": "./dist/index.js"
|
|
27
28
|
}
|
|
28
29
|
},
|
|
29
|
-
"main": "./dist/index.
|
|
30
|
+
"main": "./dist/index.js",
|
|
30
31
|
"module": "./dist/index.js",
|
|
31
32
|
"types": "./dist/index.d.ts",
|
|
32
33
|
"files": [
|
package/dist/index.d.mts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
//#region src/createThemeApi.d.ts
|
|
2
|
-
interface Theme {
|
|
3
|
-
version: string;
|
|
4
|
-
_context: ThemeContext;
|
|
5
|
-
config: ThemeConfig;
|
|
6
|
-
use: (plugin: Plugin, ...options: any[]) => this;
|
|
7
|
-
}
|
|
8
|
-
interface ThemeConfig {
|
|
9
|
-
globalProperties: Record<string, any>;
|
|
10
|
-
}
|
|
11
|
-
interface ThemeContext {
|
|
12
|
-
theme: Theme;
|
|
13
|
-
config: ThemeConfig;
|
|
14
|
-
}
|
|
15
|
-
type PluginInstallFunction = (theme: Theme, ...options: any[]) => any;
|
|
16
|
-
type Plugin = (PluginInstallFunction & {
|
|
17
|
-
install?: PluginInstallFunction;
|
|
18
|
-
}) | {
|
|
19
|
-
install: PluginInstallFunction;
|
|
20
|
-
};
|
|
21
|
-
interface CreateThemeConfig {
|
|
22
|
-
log: boolean;
|
|
23
|
-
}
|
|
24
|
-
declare function createTheme(options?: CreateThemeConfig): Theme;
|
|
25
|
-
//#endregion
|
|
26
|
-
//#region src/defineOptionsApi.d.ts
|
|
27
|
-
type DefineOptionsFn = <F extends object, D extends object, U extends object>(userOptionName: string | Array<string>, defaultOptions: F) => (devOptions?: D) => F & U & D;
|
|
28
|
-
declare const defineOptions: DefineOptionsFn;
|
|
29
|
-
//#endregion
|
|
30
|
-
export { CreateThemeConfig, Plugin, PluginInstallFunction, Theme, ThemeConfig, ThemeContext, createTheme, defineOptions };
|
package/dist/index.mjs
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
//#region src/constants/env.ts
|
|
2
|
-
const __DEV__ = false;
|
|
3
|
-
|
|
4
|
-
//#endregion
|
|
5
|
-
//#region src/init.ts
|
|
6
|
-
function setDevOptions() {
|
|
7
|
-
if (__DEV__) window.opts = {};
|
|
8
|
-
}
|
|
9
|
-
function hideLoading() {
|
|
10
|
-
const loading = $("#loading,.loading");
|
|
11
|
-
if (loading.length) loading.fadeOut(300);
|
|
12
|
-
}
|
|
13
|
-
var init_default = (_) => {
|
|
14
|
-
setDevOptions();
|
|
15
|
-
hideLoading();
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
//#endregion
|
|
19
|
-
//#region src/utils/shared.ts
|
|
20
|
-
const extend = Object.assign;
|
|
21
|
-
const isArray = Array.isArray;
|
|
22
|
-
function isFunction(x) {
|
|
23
|
-
return typeof x === "function";
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
//#endregion
|
|
27
|
-
//#region src/createThemeApi.ts
|
|
28
|
-
function createThemeContext() {
|
|
29
|
-
return {
|
|
30
|
-
theme: null,
|
|
31
|
-
config: { globalProperties: {} }
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
function createThemeAPI() {
|
|
35
|
-
return function createTheme$1() {
|
|
36
|
-
const context = createThemeContext();
|
|
37
|
-
const installedPlugins = /* @__PURE__ */ new Set();
|
|
38
|
-
const themeObject = {
|
|
39
|
-
_context: context,
|
|
40
|
-
version: "3.0",
|
|
41
|
-
get config() {
|
|
42
|
-
return context.config;
|
|
43
|
-
},
|
|
44
|
-
set config(_) {
|
|
45
|
-
if (__DEV__) console.warn(`theme.config cannot be replaced. Modify individual options instead.`);
|
|
46
|
-
},
|
|
47
|
-
use(plugin, ...options) {
|
|
48
|
-
if (installedPlugins.has(plugin)) __DEV__ && console.warn(`Plugin has already been applied to target theme.`);
|
|
49
|
-
else if (plugin && isFunction(plugin.install)) {
|
|
50
|
-
installedPlugins.add(plugin);
|
|
51
|
-
plugin.install(themeObject, ...options);
|
|
52
|
-
} else if (isFunction(plugin)) {
|
|
53
|
-
installedPlugins.add(plugin);
|
|
54
|
-
plugin(themeObject, ...options);
|
|
55
|
-
} else if (__DEV__) console.warn("A plugin must either be a function or an object with an \"install\" function.");
|
|
56
|
-
return themeObject;
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
const theme = themeObject;
|
|
60
|
-
context.theme = themeObject;
|
|
61
|
-
return theme;
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
function baseCreateTheme(options) {
|
|
65
|
-
init_default(options);
|
|
66
|
-
return { createTheme: createThemeAPI() };
|
|
67
|
-
}
|
|
68
|
-
function createTheme(options) {
|
|
69
|
-
return baseCreateTheme(options).createTheme();
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
//#endregion
|
|
73
|
-
//#region src/defineOptionsApi.ts
|
|
74
|
-
const mergeOptions = (def = {}, user = {}, dev = {}) => {
|
|
75
|
-
return extend({}, extend({}, def, dev), user);
|
|
76
|
-
};
|
|
77
|
-
function getValue(valueKeys = [], obj = {}) {
|
|
78
|
-
const key = Object.keys(obj).find((key$1) => valueKeys.includes(key$1));
|
|
79
|
-
return key ? obj[key] : null;
|
|
80
|
-
}
|
|
81
|
-
function ensureUserOptions(userOptionName) {
|
|
82
|
-
const userConfig = window.opts || {};
|
|
83
|
-
if (typeof userOptionName === "string") return userConfig[userOptionName];
|
|
84
|
-
else if (isArray(userOptionName)) return getValue(userOptionName, userConfig);
|
|
85
|
-
}
|
|
86
|
-
const defineOptions = (userOptionName, defaultOptions) => {
|
|
87
|
-
return (devOptions) => {
|
|
88
|
-
return mergeOptions(defaultOptions, ensureUserOptions(userOptionName), devOptions);
|
|
89
|
-
};
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
//#endregion
|
|
93
|
-
export { createTheme, defineOptions };
|