@yongdall/web 0.4.6 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/boot.mjs +1 -1
- package/boot.mjs.map +1 -1
- package/index.d.mts +11 -6
- package/index.mjs +14 -14
- package/index.mjs.map +1 -1
- package/package.json +4 -4
- package/yongdall.plugin.yml +1 -0
package/boot.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{application as e,findPluginIdRegex as t,importStyle as n,importWidget as r,start as i}from"@yongdall/web";async function a(){let{theme:a,route:o,authenticator:s,skin:c}=e;async function
|
|
1
|
+
import{application as e,findPluginIdRegex as t,importStyle as n,importWidget as r,start as i}from"@yongdall/web";async function a(){let{theme:a,route:o,authenticator:s,skin:c,type:l}=e;c&&await n(c).catch(()=>null);async function u(){if(!s||typeof s!=`string`)return{};let e=await r(s);if(typeof e==`function`&&(e=await e()),!e)return{};let n=t.exec(s)?.groups?.pluginId;return!n||!e.styleFiles?.length?{...e,styleFiles:[]}:{...e,styleFiles:[...e.styleFiles||[]].map(e=>[e,n])}}if(l===`authenticator`||!a||typeof a!=`string`){i(u);return}async function d(){if(!a||typeof a!=`string`)return{};let e=await r(a);if(typeof e==`function`&&(e=await e()),!e)return{};let n=t.exec(a)?.groups?.pluginId;return!n||!e.styleFiles?.length?{...e,styleFiles:[]}:{...e,styleFiles:[...e.styleFiles||[]].map(e=>[e,n])}}async function f(){return o?r(o):null}i(u,d,f)}a();
|
|
2
2
|
//# sourceMappingURL=boot.mjs.map
|
package/boot.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"boot.mjs","names":[],"sources":["../../packages/web/boot.mjs"],"sourcesContent":["/** @import { Authenticator, Theme } from './typesDefine.mjs' */\nimport { application, start } from '@yongdall/web';\nimport { importWidget, importStyle } from '@yongdall/web';\nimport { findPluginIdRegex } from '@yongdall/web';\n\n/** @typedef {[file: string, plugin: string]} uiStyle */\n\n\n\n\n\nasync function init() {\n\n\n\tconst { theme, route, authenticator, skin } = application;\n\n\t/** @returns {Promise<Partial<Omit<Authenticator, 'styleFiles'> & Record<'styleFiles', uiStyle[]>>>} */\n\tasync function _loadAuthenticator() {\n\t\tif (!authenticator || typeof authenticator !== 'string') { return {}; }\n\t\t/** @type {Partial<Authenticator> | (() => Partial<Authenticator> | PromiseLike<Partial<Authenticator>>) | undefined} */\n\t\tlet authenticatorWidget = await importWidget(authenticator);\n\t\tif (typeof authenticatorWidget === 'function') { authenticatorWidget = await authenticatorWidget(); }\n\t\tif (!authenticatorWidget) { return {}; }\n\t\tconst pluginId = findPluginIdRegex.exec(authenticator)?.groups?.pluginId;\n\t\tif (!pluginId || !authenticatorWidget.styleFiles?.length) { return { ...authenticatorWidget, styleFiles: [] }; }\n\t\treturn { ...authenticatorWidget, styleFiles: [...authenticatorWidget.styleFiles || []].map(s => [s, pluginId]) };\n\t}\n\t/** @returns {Promise<Partial<Omit<Theme, 'styleFiles'> & Record<'styleFiles', uiStyle[]>>>} */\n\tasync function _loadTheme() {\n\t\tif (!theme || typeof theme !== 'string') { return {}; }\n\t\t/** @type {Partial<Theme> | (() => Partial<Theme> | PromiseLike<Partial<Theme>>) | undefined} */\n\t\tlet uis = await importWidget(theme);\n\t\tif (typeof uis === 'function') { uis = await uis(); }\n\t\tif (!uis) { return {}; }\n\t\tconst pluginId = findPluginIdRegex.exec(theme)?.groups?.pluginId;\n\t\tif (!pluginId || !uis.styleFiles?.length) { return { ...uis, styleFiles: [] }; }\n\t\treturn { ...uis, styleFiles: [...uis.styleFiles || []].map(s => [s, pluginId]) };\n\t}\n\n\tasync function _loadRoute() {\n\t\tif (!route) { return null; }\n\t\treturn importWidget(route);\n\t}\n\
|
|
1
|
+
{"version":3,"file":"boot.mjs","names":[],"sources":["../../packages/web/boot.mjs"],"sourcesContent":["/** @import { Authenticator, Theme } from './typesDefine.mjs' */\nimport { application, start } from '@yongdall/web';\nimport { importWidget, importStyle } from '@yongdall/web';\nimport { findPluginIdRegex } from '@yongdall/web';\n\n/** @typedef {[file: string, plugin: string]} uiStyle */\n\n\n\n\n\nasync function init() {\n\n\n\tconst { theme, route, authenticator, skin, type } = application;\n\tif (skin) { await importStyle(skin).catch(() => null); }\n\n\t/** @returns {Promise<Partial<Omit<Authenticator, 'styleFiles'> & Record<'styleFiles', uiStyle[]>>>} */\n\tasync function _loadAuthenticator() {\n\t\tif (!authenticator || typeof authenticator !== 'string') { return {}; }\n\t\t/** @type {Partial<Authenticator> | (() => Partial<Authenticator> | PromiseLike<Partial<Authenticator>>) | undefined} */\n\t\tlet authenticatorWidget = await importWidget(authenticator);\n\t\tif (typeof authenticatorWidget === 'function') { authenticatorWidget = await authenticatorWidget(); }\n\t\tif (!authenticatorWidget) { return {}; }\n\t\tconst pluginId = findPluginIdRegex.exec(authenticator)?.groups?.pluginId;\n\t\tif (!pluginId || !authenticatorWidget.styleFiles?.length) { return { ...authenticatorWidget, styleFiles: [] }; }\n\t\treturn { ...authenticatorWidget, styleFiles: [...authenticatorWidget.styleFiles || []].map(s => [s, pluginId]) };\n\t}\n\tif (type === 'authenticator' || !theme || typeof theme !== 'string') {\n\t\tstart(_loadAuthenticator);\n\t\treturn;\n\t}\n\t/** @returns {Promise<Partial<Omit<Theme, 'styleFiles'> & Record<'styleFiles', uiStyle[]>>>} */\n\tasync function _loadTheme() {\n\t\tif (!theme || typeof theme !== 'string') { return {}; }\n\t\t/** @type {Partial<Theme> | (() => Partial<Theme> | PromiseLike<Partial<Theme>>) | undefined} */\n\t\tlet uis = await importWidget(theme);\n\t\tif (typeof uis === 'function') { uis = await uis(); }\n\t\tif (!uis) { return {}; }\n\t\tconst pluginId = findPluginIdRegex.exec(theme)?.groups?.pluginId;\n\t\tif (!pluginId || !uis.styleFiles?.length) { return { ...uis, styleFiles: [] }; }\n\t\treturn { ...uis, styleFiles: [...uis.styleFiles || []].map(s => [s, pluginId]) };\n\t}\n\n\tasync function _loadRoute() {\n\t\tif (!route)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AAM,CADL,KAGtB,EAAM,EAAoB,EAAY,EAAW,CAGlD,GAAM"}
|
package/index.d.mts
CHANGED
|
@@ -794,6 +794,8 @@ type PageConfiguration = {
|
|
|
794
794
|
forms?: Record<string, PageForm | null> | undefined;
|
|
795
795
|
where?: Search.AndList | undefined;
|
|
796
796
|
orWhere?: Search.OrList | undefined;
|
|
797
|
+
sort?: [field: string, desc?: boolean | undefined][] | undefined;
|
|
798
|
+
limit?: number | undefined;
|
|
797
799
|
defaultQuery?: string | undefined;
|
|
798
800
|
/**
|
|
799
801
|
* // TODO: 是否分页
|
|
@@ -1502,6 +1504,7 @@ type User = {
|
|
|
1502
1504
|
plugins?: Record<string, Record<string, any>> | undefined;
|
|
1503
1505
|
};
|
|
1504
1506
|
declare namespace User {
|
|
1507
|
+
const visitor: boolean;
|
|
1505
1508
|
const multi: boolean;
|
|
1506
1509
|
const single: boolean;
|
|
1507
1510
|
const session: User | null;
|
|
@@ -1700,6 +1703,8 @@ type DataSource = {
|
|
|
1700
1703
|
} | null | undefined;
|
|
1701
1704
|
where: (Search.Match | Search.Children)[];
|
|
1702
1705
|
orWhere: (Search.Match | Search.Children | Search.Or)[];
|
|
1706
|
+
sort: [field: string, desc?: boolean | undefined][];
|
|
1707
|
+
limit: number;
|
|
1703
1708
|
};
|
|
1704
1709
|
declare namespace DataSource {
|
|
1705
1710
|
type Option = {
|
|
@@ -1931,7 +1936,7 @@ interface Authenticator {
|
|
|
1931
1936
|
elements: Element | Element[];
|
|
1932
1937
|
/** 添加到根节点上的类名 */
|
|
1933
1938
|
rootClassName: string;
|
|
1934
|
-
login(signal: AbortSignal): PromiseLike<void> | void;
|
|
1939
|
+
login(signal: AbortSignal, onlyAuthenticator: boolean): PromiseLike<void> | void;
|
|
1935
1940
|
}
|
|
1936
1941
|
interface Theme {
|
|
1937
1942
|
title(page: CurrentPage): string;
|
|
@@ -2861,16 +2866,15 @@ declare function buildPlugin(pluginId: string): {
|
|
|
2861
2866
|
/**
|
|
2862
2867
|
*
|
|
2863
2868
|
* @param {typeof loadAuthenticator} _loadAuthenticator
|
|
2864
|
-
* @param {
|
|
2865
|
-
* @param {() => MaybePromise<PageIdent.Router?>} _loadRoute
|
|
2869
|
+
* @param {() => MaybePromise<Partial<WorkbenchTheme>>} [_loadTheme]
|
|
2870
|
+
* @param {() => MaybePromise<PageIdent.Router?>} [_loadRoute]
|
|
2866
2871
|
* @returns
|
|
2867
2872
|
*/
|
|
2868
|
-
declare function start(_loadAuthenticator: typeof loadAuthenticator, _loadTheme
|
|
2873
|
+
declare function start(_loadAuthenticator: typeof loadAuthenticator, _loadTheme?: () => MaybePromise<Partial<WorkbenchTheme>>, _loadRoute?: () => MaybePromise<PageIdent.Router | null>): Promise<void>;
|
|
2869
2874
|
type uiStyle = [file: string, plugin: string];
|
|
2875
|
+
type WorkbenchTheme = Omit<Theme, "styleFiles"> & Record<"styleFiles", uiStyle[]>;
|
|
2870
2876
|
/** @type {() => MaybePromise<Partial<Omit<Authenticator, "styleFiles"> & Record<"styleFiles", uiStyle[]>>>} */
|
|
2871
2877
|
declare let loadAuthenticator: () => MaybePromise<Partial<Omit<Authenticator, "styleFiles"> & Record<"styleFiles", uiStyle[]>>>;
|
|
2872
|
-
/** @type {() => MaybePromise<Partial<Omit<Theme, "styleFiles"> & Record<"styleFiles", uiStyle[]>>>} */
|
|
2873
|
-
declare let loadTheme: () => MaybePromise<Partial<Omit<Theme, "styleFiles"> & Record<"styleFiles", uiStyle[]>>>;
|
|
2874
2878
|
//#endregion
|
|
2875
2879
|
//#region packages/web/configuration.d.mts
|
|
2876
2880
|
/** @type {Record<string, Plugin>} */
|
|
@@ -2882,6 +2886,7 @@ declare namespace application {
|
|
|
2882
2886
|
export const theme: string | undefined;
|
|
2883
2887
|
export const route: string | undefined;
|
|
2884
2888
|
export const authenticator: string | undefined;
|
|
2889
|
+
export const type: string | undefined;
|
|
2885
2890
|
export const skin: string | undefined;
|
|
2886
2891
|
export const menus: any[];
|
|
2887
2892
|
export const userMenus: any[];
|