lupine.web 1.1.3 → 1.1.5
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 +66 -3
- package/jsx-runtime/index.js +14 -14
- package/jsx-runtime/package.json +16 -16
- package/jsx-runtime/src/index.d.ts +2 -2
- package/package.json +53 -52
- package/src/core/bind-attributes.ts +61 -61
- package/src/core/bind-lang.ts +52 -52
- package/src/core/bind-links.ts +26 -16
- package/src/core/bind-meta.tsx +52 -52
- package/src/core/bind-ref.ts +51 -51
- package/src/core/bind-styles.ts +239 -239
- package/src/core/bind-theme.ts +53 -53
- package/src/core/camel-to-hyphens.ts +3 -3
- package/src/core/export-lupine.ts +80 -80
- package/src/core/index.ts +17 -17
- package/src/core/initialize.ts +116 -116
- package/src/core/mount-component.ts +72 -68
- package/src/core/page-loaded-events.ts +16 -16
- package/src/core/page-router.ts +180 -180
- package/src/core/render-component.ts +230 -233
- package/src/core/replace-innerhtml.ts +23 -23
- package/src/core/server-cookie.ts +24 -24
- package/src/global.d.ts +66 -66
- package/src/index.ts +14 -14
- package/src/jsx.ts +1044 -1043
- package/src/lib/cookie.ts +44 -44
- package/src/lib/debug-watch.ts +32 -32
- package/src/lib/index.ts +7 -7
- package/src/lib/is-frontend.ts +3 -3
- package/src/lib/logger.ts +55 -55
- package/src/lib/unique-id.ts +40 -40
- package/src/lib/web-config.ts +79 -77
- package/src/lib/web-env.ts +99 -99
- package/src/models/index.ts +4 -4
- package/src/models/json-props.ts +8 -8
- package/src/models/simple-storage-props.ts +9 -9
- package/src/models/theme-props.ts +7 -7
- package/src/models/to-client-delivery-props.ts +8 -8
- package/src/styles/css-styles.ts +814 -814
- package/src/styles/index.ts +4 -4
- package/tsconfig.json +113 -113
package/src/lib/web-env.ts
CHANGED
|
@@ -1,99 +1,99 @@
|
|
|
1
|
-
// _webEnv is from process.env and _webSetting is from config.json (public and can be changed)
|
|
2
|
-
// _webEnv is for env variables used by the FE
|
|
3
|
-
// For SSR, the initWebEnv needs to be called from server side
|
|
4
|
-
const _webEnv: { [key: string]: string } = {};
|
|
5
|
-
let _webEnvInitialized = false;
|
|
6
|
-
function webEnv(key: string, defaultValue: number): number;
|
|
7
|
-
function webEnv(key: string, defaultValue: string): string;
|
|
8
|
-
function webEnv(key: string, defaultValue: boolean): boolean;
|
|
9
|
-
function webEnv(key: string, defaultValue: object): object;
|
|
10
|
-
function webEnv(key: string, defaultValue: any): any {
|
|
11
|
-
// for SSR, the webEnv should be initialized. But for the FE, it should be initialized by the webEnv script tag
|
|
12
|
-
if (!_webEnvInitialized) {
|
|
13
|
-
const json = document.querySelector('#web-env')?.textContent;
|
|
14
|
-
if (json) {
|
|
15
|
-
_webEnvInitialized = true;
|
|
16
|
-
initWebEnv(JSON.parse(json));
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
!_webEnvInitialized && console.warn('webEnv has not been initialized yet!');
|
|
21
|
-
if (typeof _webEnv[key] === 'undefined') {
|
|
22
|
-
return defaultValue;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
if (typeof defaultValue === 'number') {
|
|
26
|
-
return Number.parseInt(_webEnv[key]!);
|
|
27
|
-
}
|
|
28
|
-
if (typeof defaultValue === 'boolean') {
|
|
29
|
-
return _webEnv[key]!.toLocaleLowerCase() === 'true' || _webEnv[key] === '1';
|
|
30
|
-
}
|
|
31
|
-
if (typeof defaultValue === 'object') {
|
|
32
|
-
if (typeof _webEnv[key] === 'object') {
|
|
33
|
-
return _webEnv[key];
|
|
34
|
-
}
|
|
35
|
-
try {
|
|
36
|
-
return JSON.parse(_webEnv[key]!);
|
|
37
|
-
} catch (error) {
|
|
38
|
-
console.error(`webEnv JSON.parse error: `, error);
|
|
39
|
-
}
|
|
40
|
-
return defaultValue;
|
|
41
|
-
}
|
|
42
|
-
return _webEnv[key] || defaultValue;
|
|
43
|
-
}
|
|
44
|
-
// this is only called from the server side for SSR
|
|
45
|
-
function initWebEnv(webEnv: { [key: string]: string }) {
|
|
46
|
-
Object.assign(_webEnv, webEnv);
|
|
47
|
-
_webEnvInitialized = true;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
// _webSetting is removed to WebConfig because for mobile app, it's async to load webconfig from an api
|
|
51
|
-
// // _webSetting is for dynamic settings that can be changed without redeploying the app
|
|
52
|
-
// // _webSetting is json format so the returning can be an object
|
|
53
|
-
// const _webSetting: { [key: string]: string } = {};
|
|
54
|
-
// let _webSettingInitialized = false;
|
|
55
|
-
// function webSetting(key: string, defaultValue: number): number;
|
|
56
|
-
// function webSetting(key: string, defaultValue: string): string;
|
|
57
|
-
// function webSetting(key: string, defaultValue: boolean): boolean;
|
|
58
|
-
// function webSetting(key: string, defaultValue: object): object;
|
|
59
|
-
// function webSetting(key: string, defaultValue: any): any {
|
|
60
|
-
// // for SSR, the webSetting should be initialized. But for the FE, it should be initialized by the webSetting script tag
|
|
61
|
-
// if (!_webSettingInitialized) {
|
|
62
|
-
// const json = document.querySelector('#web-setting')?.textContent;
|
|
63
|
-
// if (json) {
|
|
64
|
-
// _webSettingInitialized = true;
|
|
65
|
-
// initWebSetting(JSON.parse(json));
|
|
66
|
-
// }
|
|
67
|
-
// }
|
|
68
|
-
|
|
69
|
-
// !_webSettingInitialized && console.warn('webSetting has not been initialized yet!');
|
|
70
|
-
// if (typeof _webSetting[key] === 'undefined') {
|
|
71
|
-
// return defaultValue;
|
|
72
|
-
// }
|
|
73
|
-
|
|
74
|
-
// if (typeof defaultValue === 'number') {
|
|
75
|
-
// return Number.parseInt(_webSetting[key]!);
|
|
76
|
-
// }
|
|
77
|
-
// if (typeof defaultValue === 'boolean') {
|
|
78
|
-
// return _webSetting[key]!.toLocaleLowerCase() === 'true' || _webSetting[key] === '1';
|
|
79
|
-
// }
|
|
80
|
-
// if (typeof defaultValue === 'object') {
|
|
81
|
-
// if (typeof _webSetting[key] === 'object') {
|
|
82
|
-
// return _webSetting[key];
|
|
83
|
-
// }
|
|
84
|
-
// try {
|
|
85
|
-
// return JSON.parse(_webSetting[key]!);
|
|
86
|
-
// } catch (error) {
|
|
87
|
-
// console.error(`webSetting JSON.parse error: `, error);
|
|
88
|
-
// }
|
|
89
|
-
// return defaultValue;
|
|
90
|
-
// }
|
|
91
|
-
// return _webSetting[key] || defaultValue;
|
|
92
|
-
// }
|
|
93
|
-
// // this is only called from the server side for SSR
|
|
94
|
-
// function initWebSetting(webSetting: { [key: string]: string }) {
|
|
95
|
-
// Object.assign(_webSetting, webSetting);
|
|
96
|
-
// _webSettingInitialized = true;
|
|
97
|
-
// }
|
|
98
|
-
|
|
99
|
-
export { initWebEnv, webEnv };
|
|
1
|
+
// _webEnv is from process.env and _webSetting is from config.json (public and can be changed)
|
|
2
|
+
// _webEnv is for env variables used by the FE
|
|
3
|
+
// For SSR, the initWebEnv needs to be called from server side
|
|
4
|
+
const _webEnv: { [key: string]: string } = {};
|
|
5
|
+
let _webEnvInitialized = false;
|
|
6
|
+
function webEnv(key: string, defaultValue: number): number;
|
|
7
|
+
function webEnv(key: string, defaultValue: string): string;
|
|
8
|
+
function webEnv(key: string, defaultValue: boolean): boolean;
|
|
9
|
+
function webEnv(key: string, defaultValue: object): object;
|
|
10
|
+
function webEnv(key: string, defaultValue: any): any {
|
|
11
|
+
// for SSR, the webEnv should be initialized. But for the FE, it should be initialized by the webEnv script tag
|
|
12
|
+
if (!_webEnvInitialized) {
|
|
13
|
+
const json = document.querySelector('#web-env')?.textContent;
|
|
14
|
+
if (json) {
|
|
15
|
+
_webEnvInitialized = true;
|
|
16
|
+
initWebEnv(JSON.parse(json));
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
!_webEnvInitialized && console.warn('webEnv has not been initialized yet!');
|
|
21
|
+
if (typeof _webEnv[key] === 'undefined') {
|
|
22
|
+
return defaultValue;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (typeof defaultValue === 'number') {
|
|
26
|
+
return Number.parseInt(_webEnv[key]!);
|
|
27
|
+
}
|
|
28
|
+
if (typeof defaultValue === 'boolean') {
|
|
29
|
+
return _webEnv[key]!.toLocaleLowerCase() === 'true' || _webEnv[key] === '1';
|
|
30
|
+
}
|
|
31
|
+
if (typeof defaultValue === 'object') {
|
|
32
|
+
if (typeof _webEnv[key] === 'object') {
|
|
33
|
+
return _webEnv[key];
|
|
34
|
+
}
|
|
35
|
+
try {
|
|
36
|
+
return JSON.parse(_webEnv[key]!);
|
|
37
|
+
} catch (error) {
|
|
38
|
+
console.error(`webEnv JSON.parse error: `, error);
|
|
39
|
+
}
|
|
40
|
+
return defaultValue;
|
|
41
|
+
}
|
|
42
|
+
return _webEnv[key] || defaultValue;
|
|
43
|
+
}
|
|
44
|
+
// this is only called from the server side for SSR
|
|
45
|
+
function initWebEnv(webEnv: { [key: string]: string }) {
|
|
46
|
+
Object.assign(_webEnv, webEnv);
|
|
47
|
+
_webEnvInitialized = true;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// _webSetting is removed to WebConfig because for mobile app, it's async to load webconfig from an api
|
|
51
|
+
// // _webSetting is for dynamic settings that can be changed without redeploying the app
|
|
52
|
+
// // _webSetting is json format so the returning can be an object
|
|
53
|
+
// const _webSetting: { [key: string]: string } = {};
|
|
54
|
+
// let _webSettingInitialized = false;
|
|
55
|
+
// function webSetting(key: string, defaultValue: number): number;
|
|
56
|
+
// function webSetting(key: string, defaultValue: string): string;
|
|
57
|
+
// function webSetting(key: string, defaultValue: boolean): boolean;
|
|
58
|
+
// function webSetting(key: string, defaultValue: object): object;
|
|
59
|
+
// function webSetting(key: string, defaultValue: any): any {
|
|
60
|
+
// // for SSR, the webSetting should be initialized. But for the FE, it should be initialized by the webSetting script tag
|
|
61
|
+
// if (!_webSettingInitialized) {
|
|
62
|
+
// const json = document.querySelector('#web-setting')?.textContent;
|
|
63
|
+
// if (json) {
|
|
64
|
+
// _webSettingInitialized = true;
|
|
65
|
+
// initWebSetting(JSON.parse(json));
|
|
66
|
+
// }
|
|
67
|
+
// }
|
|
68
|
+
|
|
69
|
+
// !_webSettingInitialized && console.warn('webSetting has not been initialized yet!');
|
|
70
|
+
// if (typeof _webSetting[key] === 'undefined') {
|
|
71
|
+
// return defaultValue;
|
|
72
|
+
// }
|
|
73
|
+
|
|
74
|
+
// if (typeof defaultValue === 'number') {
|
|
75
|
+
// return Number.parseInt(_webSetting[key]!);
|
|
76
|
+
// }
|
|
77
|
+
// if (typeof defaultValue === 'boolean') {
|
|
78
|
+
// return _webSetting[key]!.toLocaleLowerCase() === 'true' || _webSetting[key] === '1';
|
|
79
|
+
// }
|
|
80
|
+
// if (typeof defaultValue === 'object') {
|
|
81
|
+
// if (typeof _webSetting[key] === 'object') {
|
|
82
|
+
// return _webSetting[key];
|
|
83
|
+
// }
|
|
84
|
+
// try {
|
|
85
|
+
// return JSON.parse(_webSetting[key]!);
|
|
86
|
+
// } catch (error) {
|
|
87
|
+
// console.error(`webSetting JSON.parse error: `, error);
|
|
88
|
+
// }
|
|
89
|
+
// return defaultValue;
|
|
90
|
+
// }
|
|
91
|
+
// return _webSetting[key] || defaultValue;
|
|
92
|
+
// }
|
|
93
|
+
// // this is only called from the server side for SSR
|
|
94
|
+
// function initWebSetting(webSetting: { [key: string]: string }) {
|
|
95
|
+
// Object.assign(_webSetting, webSetting);
|
|
96
|
+
// _webSettingInitialized = true;
|
|
97
|
+
// }
|
|
98
|
+
|
|
99
|
+
export { initWebEnv, webEnv };
|
package/src/models/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from './json-props';
|
|
2
|
-
export * from './simple-storage-props';
|
|
3
|
-
export * from './theme-props';
|
|
4
|
-
export * from './to-client-delivery-props';
|
|
1
|
+
export * from './json-props';
|
|
2
|
+
export * from './simple-storage-props';
|
|
3
|
+
export * from './theme-props';
|
|
4
|
+
export * from './to-client-delivery-props';
|
package/src/models/json-props.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export type JsonKeyValue = {
|
|
2
|
-
[key: string]: string | number | boolean | null | undefined | string[] | number[] | JsonKeyValue | JsonKeyValue[];
|
|
3
|
-
};
|
|
4
|
-
export type JsonObject =
|
|
5
|
-
| JsonKeyValue[]
|
|
6
|
-
| {
|
|
7
|
-
[key: string]: string | number | boolean | null | undefined | string[] | number[] | JsonKeyValue | JsonKeyValue[];
|
|
8
|
-
};
|
|
1
|
+
export type JsonKeyValue = {
|
|
2
|
+
[key: string]: string | number | boolean | null | undefined | string[] | number[] | JsonKeyValue | JsonKeyValue[];
|
|
3
|
+
};
|
|
4
|
+
export type JsonObject =
|
|
5
|
+
| JsonKeyValue[]
|
|
6
|
+
| {
|
|
7
|
+
[key: string]: string | number | boolean | null | undefined | string[] | number[] | JsonKeyValue | JsonKeyValue[];
|
|
8
|
+
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
// This class is used by both BE and FE (cookie for SSR).
|
|
2
|
-
export interface ISimpleStorage {
|
|
3
|
-
contains(key: string): boolean;
|
|
4
|
-
set(key: string, value: string): void;
|
|
5
|
-
get(key: string, defaultValue: string): string;
|
|
6
|
-
getInt(key: string, defaultValue: number): number;
|
|
7
|
-
getBoolean(key: string, defaultValue: boolean): boolean;
|
|
8
|
-
getJson(key: string, defaultValue: object): object;
|
|
9
|
-
}
|
|
1
|
+
// This class is used by both BE and FE (cookie for SSR).
|
|
2
|
+
export interface ISimpleStorage {
|
|
3
|
+
contains(key: string): boolean;
|
|
4
|
+
set(key: string, value: string): void;
|
|
5
|
+
get(key: string, defaultValue: string): string;
|
|
6
|
+
getInt(key: string, defaultValue: number): number;
|
|
7
|
+
getBoolean(key: string, defaultValue: boolean): boolean;
|
|
8
|
+
getJson(key: string, defaultValue: object): object;
|
|
9
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export type ThemeProps = {
|
|
2
|
-
[key: string]: string | number;
|
|
3
|
-
};
|
|
4
|
-
|
|
5
|
-
export type ThemesProps = {
|
|
6
|
-
[key: string]: ThemeProps;
|
|
7
|
-
};
|
|
1
|
+
export type ThemeProps = {
|
|
2
|
+
[key: string]: string | number;
|
|
3
|
+
};
|
|
4
|
+
|
|
5
|
+
export type ThemesProps = {
|
|
6
|
+
[key: string]: ThemeProps;
|
|
7
|
+
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { ISimpleStorage } from './simple-storage-props';
|
|
2
|
-
|
|
3
|
-
export interface IToClientDelivery {
|
|
4
|
-
getWebEnv(): { [k: string]: string };
|
|
5
|
-
getWebSetting(): { [k: string]: string };
|
|
6
|
-
getServerCookie(): ISimpleStorage;
|
|
7
|
-
// getLang(): { [k: string]: string };
|
|
8
|
-
}
|
|
1
|
+
import { ISimpleStorage } from './simple-storage-props';
|
|
2
|
+
|
|
3
|
+
export interface IToClientDelivery {
|
|
4
|
+
getWebEnv(): { [k: string]: string };
|
|
5
|
+
getWebSetting(): { [k: string]: string };
|
|
6
|
+
getServerCookie(): ISimpleStorage;
|
|
7
|
+
// getLang(): { [k: string]: string };
|
|
8
|
+
}
|