lupine.web 1.0.15 → 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/README.md +1 -1
- package/package.json +1 -5
- package/src/core/bind-lang.ts +6 -5
- package/src/core/bind-links.ts +2 -2
- package/src/core/bind-meta.tsx +52 -0
- package/src/core/bind-theme.ts +11 -9
- package/src/core/export-lupine.ts +64 -0
- package/src/core/index.ts +3 -1
- package/src/core/{core.ts → initialize.ts} +12 -79
- package/src/core/page-router.ts +3 -2
- package/src/core/server-cookie.ts +5 -3
- package/src/index.ts +2 -3
- package/src/lib/index.ts +2 -13
- package/src/lib/is-frontend.ts +3 -0
- package/src/models/index.ts +2 -0
- package/src/models/json-props.ts +8 -0
- package/src/models/theme-props.ts +7 -0
- package/src/{types → styles}/index.ts +0 -2
- package/src/assets/themes/base-themes.ts +0 -16
- package/src/assets/themes/dark-themes.ts +0 -85
- package/src/assets/themes/index.ts +0 -4
- package/src/assets/themes/light-themes.ts +0 -92
- package/src/assets/themes/shared-themes.ts +0 -50
- package/src/components/button-push-animation.tsx +0 -138
- package/src/components/button.tsx +0 -55
- package/src/components/drag-refresh.tsx +0 -110
- package/src/components/editable-label.tsx +0 -83
- package/src/components/float-window.tsx +0 -226
- package/src/components/grid.tsx +0 -18
- package/src/components/html-var.tsx +0 -41
- package/src/components/index.ts +0 -36
- package/src/components/input-with-title.tsx +0 -24
- package/src/components/link-item.tsx +0 -13
- package/src/components/link-list.tsx +0 -62
- package/src/components/menu-bar.tsx +0 -220
- package/src/components/menu-item-props.tsx +0 -10
- package/src/components/menu-sidebar.tsx +0 -289
- package/src/components/message-box.tsx +0 -44
- package/src/components/meta-data.tsx +0 -54
- package/src/components/meta-description.tsx +0 -19
- package/src/components/meta-title.tsx +0 -19
- package/src/components/modal.tsx +0 -29
- package/src/components/notice-message.tsx +0 -119
- package/src/components/paging-link.tsx +0 -100
- package/src/components/panel.tsx +0 -24
- package/src/components/popup-menu.tsx +0 -218
- package/src/components/progress.tsx +0 -91
- package/src/components/redirect.tsx +0 -19
- package/src/components/resizable-splitter.tsx +0 -129
- package/src/components/select-with-title.tsx +0 -37
- package/src/components/spinner.tsx +0 -100
- package/src/components/svg.tsx +0 -24
- package/src/components/tabs.tsx +0 -252
- package/src/components/text-glow.tsx +0 -36
- package/src/components/text-wave.tsx +0 -54
- package/src/components/theme-selector.tsx +0 -35
- package/src/components/toggle-base.tsx +0 -260
- package/src/components/toggle-switch.tsx +0 -156
- package/src/lib/date-utils.ts +0 -317
- package/src/lib/deep-merge.ts +0 -37
- package/src/lib/document-ready.ts +0 -36
- package/src/lib/dom/calculate-text-width.ts +0 -13
- package/src/lib/dom/download-stream.ts +0 -17
- package/src/lib/dom/download.ts +0 -12
- package/src/lib/dom/index.ts +0 -71
- package/src/lib/dynamical-load.ts +0 -138
- package/src/lib/format-bytes.ts +0 -11
- package/src/lib/lite-dom.ts +0 -227
- package/src/lib/message-hub.ts +0 -105
- package/src/lib/observable.ts +0 -188
- package/src/lib/promise-timeout.ts +0 -1
- package/src/lib/simple-storage.ts +0 -40
- package/src/lib/stop-propagation.ts +0 -7
- package/src/lib/upload-file.ts +0 -68
- package/src/types/css-types.ts +0 -17
- package/src/types/media-query.ts +0 -93
- /package/src/lib/{dom/cookie.ts → cookie.ts} +0 -0
- /package/src/{types → styles}/css-styles.ts +0 -0
package/README.md
CHANGED
package/package.json
CHANGED
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lupine.web",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.17",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "uuware.com",
|
|
6
6
|
"homepage": "https://uuware.com/",
|
|
7
7
|
"description": "lupine.web is a extremely fast, small size and lightweight frontend framework, using React TSX syntax.",
|
|
8
|
-
"repository": {
|
|
9
|
-
"type": "git",
|
|
10
|
-
"url": "git+https://github.com/uuware/lupine.web.git"
|
|
11
|
-
},
|
|
12
8
|
"main": "src/index.ts",
|
|
13
9
|
"source": "src/index.ts",
|
|
14
10
|
"types": "src/index.ts",
|
package/src/core/bind-lang.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { setCookie } from '../lib/cookie';
|
|
2
|
+
import { isFrontEnd } from '../lib/is-frontend';
|
|
2
3
|
import { getEitherCookie } from './server-cookie';
|
|
3
4
|
|
|
4
5
|
// The FE only loads one language for the consideration of the size
|
|
@@ -20,8 +21,8 @@ export const getCurrentLang = () => {
|
|
|
20
21
|
let langName = getEitherCookie(langCookieName) as string;
|
|
21
22
|
if (!langName || !_langCfg.langs[langName]) {
|
|
22
23
|
langName = _langCfg.defaultLang;
|
|
23
|
-
if (
|
|
24
|
-
|
|
24
|
+
if (isFrontEnd()) {
|
|
25
|
+
setCookie(langCookieName, _langCfg.defaultLang);
|
|
25
26
|
}
|
|
26
27
|
}
|
|
27
28
|
return { langName, langs: _langCfg.langs };
|
|
@@ -31,11 +32,11 @@ export const getCurrentLang = () => {
|
|
|
31
32
|
export const updateLang = (langName: string) => {
|
|
32
33
|
// Lang is only updated in Browser
|
|
33
34
|
_langCfg.defaultLang = langName;
|
|
34
|
-
if (
|
|
35
|
+
if (!isFrontEnd()) {
|
|
35
36
|
return;
|
|
36
37
|
}
|
|
37
38
|
|
|
38
|
-
|
|
39
|
+
setCookie(langCookieName, langName);
|
|
39
40
|
// document.documentElement.setAttribute(langAttributeName, langName);
|
|
40
41
|
|
|
41
42
|
// // update lang for all iframe
|
package/src/core/bind-links.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { _lupineJs } from './export-lupine';
|
|
2
2
|
|
|
3
3
|
export function bindLinks(el: Element | Document) {
|
|
4
4
|
const links = el.getElementsByTagName('a');
|
|
@@ -8,7 +8,7 @@ export function bindLinks(el: Element | Document) {
|
|
|
8
8
|
href = href.substring(document.location.origin.length);
|
|
9
9
|
// console.log(`====${href}, javascript:init('${document.links[i].href}')`);
|
|
10
10
|
links[i].onclick = () => {
|
|
11
|
-
initializePage(href);
|
|
11
|
+
_lupineJs.initializePage(href);
|
|
12
12
|
return false;
|
|
13
13
|
};
|
|
14
14
|
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// import { bindPageResetEvent } from '../core/page-reset-events';
|
|
2
|
+
|
|
3
|
+
let _pageTitle = { value: '', defaultValue: '' };
|
|
4
|
+
export const setPageTitle = (title: string) => {
|
|
5
|
+
_pageTitle.value = title;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export const getPageTitle = () => {
|
|
9
|
+
return _pageTitle.value || _pageTitle.defaultValue;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export const setDefaultPageTitle = (title: string) => {
|
|
13
|
+
_pageTitle.defaultValue = title;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
let _description = { value: '', defaultValue: '' };
|
|
17
|
+
export const setMetaDescription = (description: string) => {
|
|
18
|
+
_description.value = description;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export const getMetaDescription = () => {
|
|
22
|
+
return _description.value || _description.defaultValue;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const setDefaultMetaDescription = (description: string) => {
|
|
26
|
+
_description.defaultValue = description;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
let _metaData: { [key: string]: string } = {};
|
|
30
|
+
export const addMetaDataTags = (key: string, value: string) => {
|
|
31
|
+
if (typeof value === 'undefined') {
|
|
32
|
+
delete _metaData[key];
|
|
33
|
+
} else {
|
|
34
|
+
_metaData[key] = value;
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export const getMetaDataTags = () => {
|
|
39
|
+
return Object.values(getMetaDataObject()).join('\n');
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export const getMetaDataObject = () => {
|
|
43
|
+
const metaDescription = getMetaDescription();
|
|
44
|
+
return metaDescription
|
|
45
|
+
? Object.assign(
|
|
46
|
+
{
|
|
47
|
+
'name:description': `<meta name="description" content="${metaDescription}">`,
|
|
48
|
+
},
|
|
49
|
+
_metaData
|
|
50
|
+
)
|
|
51
|
+
: _metaData;
|
|
52
|
+
};
|
package/src/core/bind-theme.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { setCookie } from '../lib/cookie';
|
|
2
|
+
import { ThemesProps } from '../models';
|
|
3
|
+
import { isFrontEnd } from '../lib/is-frontend';
|
|
3
4
|
import { getEitherCookie } from './server-cookie';
|
|
4
5
|
|
|
5
6
|
// theme doesn't need to reset, theme name is stored in cookie
|
|
@@ -8,8 +9,8 @@ export const defaultThemeName = 'light';
|
|
|
8
9
|
export const themeCookieName = 'theme';
|
|
9
10
|
export const updateThemeEventName = 'updateTheme';
|
|
10
11
|
export const themeAttributeName = 'data-theme';
|
|
11
|
-
const _themeCfg:
|
|
12
|
-
export const bindTheme = (defaultTheme: string, themes:
|
|
12
|
+
const _themeCfg: { defaultTheme: string; themes: ThemesProps } = { defaultTheme: defaultThemeName, themes: {} };
|
|
13
|
+
export const bindTheme = (defaultTheme: string, themes: ThemesProps) => {
|
|
13
14
|
_themeCfg.defaultTheme = defaultTheme;
|
|
14
15
|
_themeCfg.themes = themes;
|
|
15
16
|
|
|
@@ -21,24 +22,25 @@ export const getCurrentTheme = () => {
|
|
|
21
22
|
let themeName = getEitherCookie(themeCookieName) as string;
|
|
22
23
|
if (!themeName || !_themeCfg.themes[themeName]) {
|
|
23
24
|
themeName = _themeCfg.defaultTheme;
|
|
24
|
-
if (
|
|
25
|
-
|
|
25
|
+
if (isFrontEnd()) {
|
|
26
|
+
setCookie(themeCookieName, _themeCfg.defaultTheme);
|
|
26
27
|
}
|
|
27
28
|
}
|
|
28
|
-
return { themeName, themes: _themeCfg.themes
|
|
29
|
+
return { themeName, themes: _themeCfg.themes };
|
|
29
30
|
};
|
|
30
31
|
|
|
31
32
|
export const updateTheme = (themeName: string) => {
|
|
32
33
|
// Theme is only updated in Browser
|
|
33
34
|
_themeCfg.defaultTheme = themeName;
|
|
34
|
-
if (
|
|
35
|
+
if (!isFrontEnd()) {
|
|
35
36
|
return;
|
|
36
37
|
}
|
|
37
38
|
|
|
38
|
-
|
|
39
|
+
setCookie(themeCookieName, themeName);
|
|
39
40
|
document.documentElement.setAttribute(themeAttributeName, themeName);
|
|
40
41
|
|
|
41
42
|
// update theme for all iframe
|
|
43
|
+
// TODO: third-party domains?
|
|
42
44
|
const allIframe = document.querySelectorAll('iframe');
|
|
43
45
|
for (let i = 0; i < allIframe.length; i++) {
|
|
44
46
|
if (allIframe[i].contentWindow && allIframe[i].contentWindow!.top === window) {
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { VNode } from '../jsx';
|
|
2
|
+
import { PageRouter } from './page-router';
|
|
3
|
+
import { IToClientDelivery, JsonObject } from '../models';
|
|
4
|
+
|
|
5
|
+
export type RenderPageFunctionsType = {
|
|
6
|
+
fetchData: (url: string, postBody?: string | JsonObject, returnRawResponse?: boolean) => Promise<any>;
|
|
7
|
+
[key: string]: Function;
|
|
8
|
+
};
|
|
9
|
+
export interface PageProps {
|
|
10
|
+
url: string;
|
|
11
|
+
// urlSections: string[];
|
|
12
|
+
query: { [key: string]: string };
|
|
13
|
+
urlParameters: { [key: string]: string };
|
|
14
|
+
renderPageFunctions: RenderPageFunctionsType;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export type PageResultType = {
|
|
18
|
+
content: string;
|
|
19
|
+
title: string;
|
|
20
|
+
metaData: string;
|
|
21
|
+
themeName: string;
|
|
22
|
+
globalCss: string;
|
|
23
|
+
};
|
|
24
|
+
export type _LupineJs = {
|
|
25
|
+
// generatePage and initializePage are set in initialize.ts to avoid circular reference
|
|
26
|
+
generatePage: (props: any, toClientDelivery: IToClientDelivery) => Promise<PageResultType>;
|
|
27
|
+
initializePage: (newUrl?: string) => Promise<void>;
|
|
28
|
+
renderPageFunctions: RenderPageFunctionsType;
|
|
29
|
+
router: PageRouter | ((props: PageProps) => Promise<VNode<any>>);
|
|
30
|
+
renderPageProps: PageProps;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
// main instance to be used in the FE and the BE
|
|
34
|
+
export const _lupineJs: _LupineJs = {} as _LupineJs;
|
|
35
|
+
|
|
36
|
+
// for SSR, it exports _lupineJs function for the server to call
|
|
37
|
+
if (typeof exports !== 'undefined') {
|
|
38
|
+
// ignore esbuild's warnings:
|
|
39
|
+
// The CommonJS "exports" variable is treated as a global variable in an ECMAScript module and may not work as expected [commonjs-variable-in-esm]
|
|
40
|
+
exports._lupineJs = () => {
|
|
41
|
+
return _lupineJs;
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// this should be called by the FE and also by the server side to set fetchData and others for client and server side rendering.
|
|
46
|
+
// And the RenderPageFunctionsType will be passed to call (generate) a page through PageProps
|
|
47
|
+
export const bindRenderPageFunctions = (calls: RenderPageFunctionsType) => {
|
|
48
|
+
_lupineJs.renderPageFunctions = calls || {};
|
|
49
|
+
};
|
|
50
|
+
// export const getRenderPageFunctions = (): RenderPageFunctionsType => {
|
|
51
|
+
// return globalThis._lupineJs.renderPageFunctions;
|
|
52
|
+
// }
|
|
53
|
+
// this is only used inside the core
|
|
54
|
+
export const setRenderPageProps = (props: PageProps) => {
|
|
55
|
+
_lupineJs.renderPageProps = props;
|
|
56
|
+
};
|
|
57
|
+
// this is used by the code to get url info when it's executed in the FE or in the server side.
|
|
58
|
+
export const getRenderPageProps = (): PageProps => {
|
|
59
|
+
return _lupineJs.renderPageProps;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export const bindRouter = (router: PageRouter | ((props: PageProps) => Promise<VNode<any>>)) => {
|
|
63
|
+
_lupineJs.router = router;
|
|
64
|
+
};
|
package/src/core/index.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
export * from './bind-attributes';
|
|
2
2
|
export * from './bind-lang';
|
|
3
3
|
export * from './bind-links';
|
|
4
|
+
export * from './bind-meta';
|
|
4
5
|
export * from './bind-ref';
|
|
5
6
|
export * from './bind-styles';
|
|
6
7
|
export * from './bind-theme';
|
|
7
|
-
export * from './
|
|
8
|
+
export * from './export-lupine';
|
|
8
9
|
export * from './camel-to-hyphens';
|
|
9
10
|
export * from './mount-components';
|
|
10
11
|
export * from './page-loaded-events';
|
|
@@ -13,3 +14,4 @@ export * from './replace-innerhtml';
|
|
|
13
14
|
export * from './server-cookie';
|
|
14
15
|
export * from './web-version';
|
|
15
16
|
|
|
17
|
+
export * from './initialize';
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import { getMetaDataObject, getMetaDataTags, getMetaTitle } from '../components';
|
|
2
|
-
import { VNode } from '../jsx';
|
|
3
|
-
import { initWebEnv, initWebSetting } from '../lib';
|
|
4
1
|
import { Logger } from '../lib/logger';
|
|
5
2
|
import { generateAllGlobalStyles } from './bind-styles';
|
|
6
3
|
import { defaultThemeName, getCurrentTheme, updateTheme } from './bind-theme';
|
|
@@ -9,79 +6,13 @@ import { mountComponents } from './mount-components';
|
|
|
9
6
|
import { PageRouter } from './page-router';
|
|
10
7
|
import { callPageLoadedEvent } from './page-loaded-events';
|
|
11
8
|
import { initServerCookies } from './server-cookie';
|
|
12
|
-
import { IToClientDelivery } from '../models
|
|
9
|
+
import { IToClientDelivery } from '../models';
|
|
10
|
+
import { getMetaDataObject, getMetaDataTags, getPageTitle } from './bind-meta';
|
|
11
|
+
import { initWebEnv, initWebSetting } from '../lib/web-env';
|
|
12
|
+
import { _lupineJs, PageProps, PageResultType, setRenderPageProps } from './export-lupine';
|
|
13
|
+
import { isFrontEnd } from '../lib/is-frontend';
|
|
13
14
|
|
|
14
|
-
|
|
15
|
-
[key: string]: string | number | boolean | null | undefined | JsonKeyValue | JsonKeyValue[];
|
|
16
|
-
};
|
|
17
|
-
export type JsonObject =
|
|
18
|
-
| JsonKeyValue[]
|
|
19
|
-
| {
|
|
20
|
-
[key: string]: string | number | boolean | null | undefined | JsonKeyValue | JsonKeyValue[];
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export type RenderPageFunctionsType = {
|
|
24
|
-
fetchData: (url: string, postBody?: string | JsonObject, returnRawResponse?: boolean) => Promise<any>;
|
|
25
|
-
[key: string]: Function;
|
|
26
|
-
};
|
|
27
|
-
export interface PageProps {
|
|
28
|
-
url: string;
|
|
29
|
-
// urlSections: string[];
|
|
30
|
-
query: { [key: string]: string };
|
|
31
|
-
urlParameters: { [key: string]: string };
|
|
32
|
-
renderPageFunctions: RenderPageFunctionsType;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export type PageResultType = {
|
|
36
|
-
content: string;
|
|
37
|
-
title: string;
|
|
38
|
-
metaData: string;
|
|
39
|
-
themeName: string;
|
|
40
|
-
globalCss: string;
|
|
41
|
-
};
|
|
42
|
-
export type _LupineJs = {
|
|
43
|
-
generatePage: (props: any, toClientDelivery: IToClientDelivery) => Promise<PageResultType>;
|
|
44
|
-
renderPageFunctions: RenderPageFunctionsType;
|
|
45
|
-
router: PageRouter | ((props: PageProps) => Promise<VNode<any>>);
|
|
46
|
-
renderPageProps: PageProps;
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
const logger = new Logger('core');
|
|
50
|
-
export const _lupineJs: _LupineJs = {} as _LupineJs;
|
|
51
|
-
|
|
52
|
-
// for SSR, it exports _lupineJs function for the server to call
|
|
53
|
-
if (typeof exports !== 'undefined') {
|
|
54
|
-
// ignore esbuild's warnings:
|
|
55
|
-
// The CommonJS "exports" variable is treated as a global variable in an ECMAScript module and may not work as expected [commonjs-variable-in-esm]
|
|
56
|
-
exports._lupineJs = () => {
|
|
57
|
-
return _lupineJs;
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// this should be called by the FE and also by the server side to set fetchData and others for client and server side rendering.
|
|
62
|
-
// And the RenderPageFunctionsType will be passed to call (generate) a page through PageProps
|
|
63
|
-
export const bindRenderPageFunctions = (calls: RenderPageFunctionsType) => {
|
|
64
|
-
_lupineJs.renderPageFunctions = calls || {};
|
|
65
|
-
};
|
|
66
|
-
// export const getRenderPageFunctions = (): RenderPageFunctionsType => {
|
|
67
|
-
// return globalThis._lupineJs.renderPageFunctions;
|
|
68
|
-
// }
|
|
69
|
-
// this is only used inside the core
|
|
70
|
-
const setRenderPageProps = (props: PageProps) => {
|
|
71
|
-
_lupineJs.renderPageProps = props;
|
|
72
|
-
};
|
|
73
|
-
// this is used by the code to get url info when it's executed in the FE or in the server side.
|
|
74
|
-
export const getRenderPageProps = (): PageProps => {
|
|
75
|
-
return _lupineJs.renderPageProps;
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
export const bindRouter = (router: PageRouter | ((props: PageProps) => Promise<VNode<any>>)) => {
|
|
79
|
-
_lupineJs.router = router;
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
export const isFrontEnd = () => {
|
|
83
|
-
return typeof window === 'object' && typeof document === 'object';
|
|
84
|
-
};
|
|
15
|
+
const logger = new Logger('initialize');
|
|
85
16
|
|
|
86
17
|
const renderTargetPage = async (props: PageProps, renderPartPage: boolean) => {
|
|
87
18
|
if (_lupineJs.router instanceof PageRouter) {
|
|
@@ -91,7 +22,7 @@ const renderTargetPage = async (props: PageProps, renderPartPage: boolean) => {
|
|
|
91
22
|
};
|
|
92
23
|
|
|
93
24
|
// this is called by server side for SSR (server-side-rendering)
|
|
94
|
-
|
|
25
|
+
const generatePage = async (props: PageProps, toClientDelivery: IToClientDelivery): Promise<PageResultType> => {
|
|
95
26
|
setRenderPageProps(props);
|
|
96
27
|
|
|
97
28
|
initWebEnv(toClientDelivery.getWebEnv());
|
|
@@ -118,7 +49,7 @@ export const generatePage = async (props: PageProps, toClientDelivery: IToClient
|
|
|
118
49
|
|
|
119
50
|
return {
|
|
120
51
|
content,
|
|
121
|
-
title:
|
|
52
|
+
title: getPageTitle(),
|
|
122
53
|
metaData: getMetaDataTags(),
|
|
123
54
|
globalCss: cssText,
|
|
124
55
|
themeName: currentTheme.themeName,
|
|
@@ -128,6 +59,7 @@ _lupineJs.generatePage = generatePage;
|
|
|
128
59
|
|
|
129
60
|
let _pageInitialized = false;
|
|
130
61
|
// this is called in the FE when the document is loaded
|
|
62
|
+
// to avoid circular reference, bindLinks can't call initializePage directly
|
|
131
63
|
export const initializePage = async (newUrl?: string) => {
|
|
132
64
|
const currentPageInitialized = _pageInitialized;
|
|
133
65
|
_pageInitialized = true;
|
|
@@ -165,11 +97,11 @@ export const initializePage = async (newUrl?: string) => {
|
|
|
165
97
|
updateTheme(getCurrentTheme().themeName);
|
|
166
98
|
|
|
167
99
|
// title
|
|
168
|
-
document.title =
|
|
100
|
+
document.title = getPageTitle();
|
|
169
101
|
const metaData = getMetaDataObject();
|
|
170
102
|
// meta data?
|
|
171
103
|
};
|
|
172
|
-
if (
|
|
104
|
+
if (isFrontEnd()) {
|
|
173
105
|
addEventListener('popstate', (event) => {
|
|
174
106
|
initializePage();
|
|
175
107
|
});
|
|
@@ -177,3 +109,4 @@ if (typeof window !== 'undefined') {
|
|
|
177
109
|
initializePage();
|
|
178
110
|
});
|
|
179
111
|
}
|
|
112
|
+
_lupineJs.initializePage = initializePage;
|
package/src/core/page-router.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { VNode } from '../jsx';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { isFrontEnd } from '../lib/is-frontend';
|
|
3
|
+
import { PageProps } from './export-lupine';
|
|
4
4
|
import { mountComponents } from './mount-components';
|
|
5
|
+
import { Logger } from '../lib/logger';
|
|
5
6
|
|
|
6
7
|
export type PageRouterCallback = (props: PageProps) => Promise<VNode<any> | null>;
|
|
7
8
|
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getCookie } from '../lib/cookie';
|
|
2
2
|
import { ISimpleStorage } from '../models/simple-storage-props';
|
|
3
|
+
import { isFrontEnd } from '../lib/is-frontend';
|
|
3
4
|
|
|
4
5
|
// getEitherCookie can be used in both FE and SSR
|
|
5
6
|
export const getEitherCookie = (name: string) => {
|
|
6
|
-
if (
|
|
7
|
+
if (!isFrontEnd()) {
|
|
7
8
|
// SSR
|
|
8
9
|
return getServerCookie(name);
|
|
9
10
|
} else {
|
|
10
|
-
return
|
|
11
|
+
return getCookie(name);
|
|
11
12
|
}
|
|
12
13
|
};
|
|
13
14
|
|
|
@@ -17,6 +18,7 @@ export const getServerCookie = (name: string) => {
|
|
|
17
18
|
return _serverCookies && _serverCookies.get(name, '');
|
|
18
19
|
};
|
|
19
20
|
// TODO: Server cookies safety should be OK? as this is dropped after SSR
|
|
21
|
+
// This is called by server side to initialize cookies for SSR
|
|
20
22
|
export const initServerCookies = (serverCookies: ISimpleStorage) => {
|
|
21
23
|
return (_serverCookies = serverCookies);
|
|
22
24
|
};
|
package/src/index.ts
CHANGED
|
@@ -4,9 +4,8 @@ import { JSXInternal } from './jsx';
|
|
|
4
4
|
export * from './jsx';
|
|
5
5
|
export * from './core';
|
|
6
6
|
export * from './lib';
|
|
7
|
-
export * from './
|
|
8
|
-
export * from './
|
|
9
|
-
export * from './assets/themes';
|
|
7
|
+
export * from './models';
|
|
8
|
+
export * from './styles';
|
|
10
9
|
|
|
11
10
|
declare global {
|
|
12
11
|
namespace JSX {
|
package/src/lib/index.ts
CHANGED
|
@@ -1,17 +1,6 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './date-utils';
|
|
1
|
+
export * from './cookie';
|
|
3
2
|
export * from './debug-watch';
|
|
4
|
-
export * from './
|
|
5
|
-
export * from './document-ready';
|
|
6
|
-
export * from './dynamical-load';
|
|
7
|
-
export * from './format-bytes';
|
|
8
|
-
export * from './lite-dom';
|
|
3
|
+
export * from './is-frontend';
|
|
9
4
|
export * from './logger';
|
|
10
|
-
export * from './message-hub';
|
|
11
|
-
export * from './observable';
|
|
12
|
-
export * from './promise-timeout';
|
|
13
|
-
export * from './simple-storage';
|
|
14
|
-
export * from './stop-propagation';
|
|
15
5
|
export * from './unique-id';
|
|
16
|
-
export * from './upload-file';
|
|
17
6
|
export * from './web-env';
|
package/src/models/index.ts
CHANGED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type JsonKeyValue = {
|
|
2
|
+
[key: string]: string | number | boolean | null | undefined | JsonKeyValue | JsonKeyValue[];
|
|
3
|
+
};
|
|
4
|
+
export type JsonObject =
|
|
5
|
+
| JsonKeyValue[]
|
|
6
|
+
| {
|
|
7
|
+
[key: string]: string | number | boolean | null | undefined | JsonKeyValue | JsonKeyValue[];
|
|
8
|
+
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { darkThemes } from './dark-themes';
|
|
2
|
-
import { lightThemes } from './light-themes';
|
|
3
|
-
|
|
4
|
-
export const baseThemes: { [key: string]: { [key: string]: string } } = {
|
|
5
|
-
light: lightThemes,
|
|
6
|
-
dark: darkThemes,
|
|
7
|
-
lightGreen: {
|
|
8
|
-
...lightThemes,
|
|
9
|
-
'--background-primary': '#d8ffe3', // Primary background
|
|
10
|
-
'--color-primary': '#303030', // Primary text color
|
|
11
|
-
backgroundPrimary: '', // Primary background
|
|
12
|
-
backgroundOnPrimary: '', // Background for surfaces on top of primary background
|
|
13
|
-
backgroundSecondary: '#f5f5f7', // Secondary background
|
|
14
|
-
backgroundOnSecondary: '#e5e5e7', // Background for surfaces on top of secondary background
|
|
15
|
-
},
|
|
16
|
-
};
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import { sharedThemes } from './shared-themes';
|
|
2
|
-
|
|
3
|
-
export const darkThemes: { [key: string]: string } = {
|
|
4
|
-
...sharedThemes,
|
|
5
|
-
'--theme-name': 'dark',
|
|
6
|
-
|
|
7
|
-
'--scrollbar-bg': '#1c1c1c',
|
|
8
|
-
'--scrollbar-thumb-bg': '#373636',
|
|
9
|
-
'--scrollbar-active-thumb-bg': '#5b5b5b',
|
|
10
|
-
|
|
11
|
-
'--primary-color': '#aeaeae',
|
|
12
|
-
'--primary-color-disabled': '#7d7d7d',
|
|
13
|
-
'--primary-bg-color': '#000000',
|
|
14
|
-
'--primary-border-color': '#aeaeae',
|
|
15
|
-
'--primary-border': '1px solid var(--primary-border-color)',
|
|
16
|
-
// '--secondary-color': '#b3b3b3',
|
|
17
|
-
// '--secondary-bg-color': '#151515',
|
|
18
|
-
// '--secondary-border': '1px solid #303030',
|
|
19
|
-
'--primary-opacity': '0.5', // used for dark theme
|
|
20
|
-
'--primary-disabled-opacity': '0.7', // used for dark theme
|
|
21
|
-
'--primary-accent-color': '#0c3c63', // used for radio and checkbox's background color
|
|
22
|
-
|
|
23
|
-
// including menus, tabs
|
|
24
|
-
'--activatable-color-normal': 'var(--primary-color)',
|
|
25
|
-
'--activatable-bg-color-normal': 'var(--primary-bg-color)',
|
|
26
|
-
'--activatable-color-hover': '#e2e2e2',
|
|
27
|
-
'--activatable-bg-color-hover': '#6d6d6d',
|
|
28
|
-
'--activatable-color-selected': '#c2c2c2',
|
|
29
|
-
'--activatable-bg-color-selected': '#5d5d5d',
|
|
30
|
-
// '--menu-color-hover': '#303030',
|
|
31
|
-
// '--menu-color': 'var(--primary-color)', //'#2a2a2a',
|
|
32
|
-
// '--menu-bg-color': 'var(--primary-bg-color)', //'#2a2a2a',
|
|
33
|
-
// '--menu-bg-color-hover': '#a0a0a0',
|
|
34
|
-
'--menu-font-size': '1rem',
|
|
35
|
-
'--menubar-color': '#eeeeee',
|
|
36
|
-
'--menubar-bg-color': '#000000',
|
|
37
|
-
'--menubar-sub-bg-color': '#f9f9f9',
|
|
38
|
-
'--sidebar-color': 'var(--primary-color)',
|
|
39
|
-
'--sidebar-bg-color': '#000000',
|
|
40
|
-
// '--sidebar-sub-color': 'var(--sidebar-color)',
|
|
41
|
-
// '--sidebar-sub-bg-color': '#000000',
|
|
42
|
-
'--sidebar-border': '1px solid #303030',
|
|
43
|
-
// '--sidebar-hover-color': 'var(--sidebar-color)',
|
|
44
|
-
// '--sidebar-hover-bg-color': '#000000',
|
|
45
|
-
|
|
46
|
-
'--row-1-bg-color': '#212121',
|
|
47
|
-
'--row-2-bg-color': '#303030',
|
|
48
|
-
'--row-hover-bg-color': '#383838',
|
|
49
|
-
|
|
50
|
-
'--success-color': '#04AA6D',
|
|
51
|
-
'--info-color': '#2196F3',
|
|
52
|
-
'--warning-color': '#ff9800',
|
|
53
|
-
'--error-color': '#f44336',
|
|
54
|
-
'--success-bg-color': '#10553b',
|
|
55
|
-
'--info-bg-color': '#1a588a',
|
|
56
|
-
'--warning-bg-color': '#a36305',
|
|
57
|
-
'--error-bg-color': '#882c25',
|
|
58
|
-
'--notice-color-with-bg': '#ececec',
|
|
59
|
-
|
|
60
|
-
'--cover-mask-bg-color': '#878a9460',
|
|
61
|
-
'--cover-bg-color': '#202020',
|
|
62
|
-
'--cover-box-shadow': '1px 1px 4px #c6c6c6',
|
|
63
|
-
|
|
64
|
-
'--input-color': '#bdbdbd',
|
|
65
|
-
'--input-bg-color': '#000000',
|
|
66
|
-
'--input-box-shadow': '0px 0px 0px #000000, 1px 1px 0px 0px #50505045',
|
|
67
|
-
'--input-border-focus': '1px solid #0074d9',
|
|
68
|
-
|
|
69
|
-
'--button-color': '#bdbdbd',
|
|
70
|
-
'--button-bg': '-webkit-linear-gradient(top, #282828 0%, #212223 74%, #1a1a1a 100%)', // darker
|
|
71
|
-
'--button-bg-hover': '-webkit-linear-gradient(top, #282828 0%, #313233 74%, #252525 100%)', // darker
|
|
72
|
-
// '--button-bg': '-webkit-linear-gradient(top, #414141 0%, #373e48 74%, #434242 100%)',
|
|
73
|
-
'--button-border': '1px solid #373e48',
|
|
74
|
-
'--button-box-shadow': 'unset',
|
|
75
|
-
|
|
76
|
-
'--header-color': '#000080',
|
|
77
|
-
'--header-bg-color': '#000000',
|
|
78
|
-
|
|
79
|
-
// '--background-primary': '#353536', // Primary background
|
|
80
|
-
// '--color-primary': '#e0e0e0', // Primary text color
|
|
81
|
-
// backgroundPrimary: '', // Primary background
|
|
82
|
-
// backgroundOnPrimary: '', // Background for surfaces on top of primary background
|
|
83
|
-
// backgroundSecondary: '#f5f5f6', // Secondary background
|
|
84
|
-
// backgroundOnSecondary: '#e5e5e6', // Background for surfaces on top of secondary background
|
|
85
|
-
};
|