zmp-cli 3.15.6 → 3.15.8
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 +37 -0
- package/build/index.js +1 -184
- package/config/index.js +1 -44
- package/create/index.js +1 -230
- package/create/utils/generate-app-config.js +1 -34
- package/create/utils/generate-npm-scripts.js +1 -26
- package/create/utils/get-options.js +1 -204
- package/create/utils/npm-scripts.js +1 -62
- package/deploy/index.js +1 -149
- package/deploy/utils/get-options.js +1 -69
- package/deploy/utils/request-upload.js +1 -34
- package/deploy/utils/upload-app.js +1 -82
- package/index.js +1 -319
- package/login/index.js +1 -169
- package/login/utils/get-options.js +1 -58
- package/login/utils/zalo-login.js +1 -32
- package/migrate/icons/update-icon-v3.js +1 -19
- package/migrate/index.js +1 -60
- package/migrate/utils/get-options.js +1 -46
- package/migrate/utils/migrate-react.js +1 -33
- package/package.json +13 -40
- package/start/frame/index.html +264 -254
- package/start/index.js +1 -382
- package/sync/index-to-app-config.js +1 -146
- package/sync/index.js +1 -55
- package/utils/axios.js +1 -15
- package/utils/check-update.js +1 -53
- package/utils/constants.js +1 -20
- package/utils/env.js +1 -39
- package/utils/error.js +1 -16
- package/utils/find-files-by-ext.js +1 -27
- package/utils/find-free-port.js +1 -11
- package/utils/fs-extra.js +1 -90
- package/utils/generate-pages-map.js +1 -17
- package/utils/get-app-info.js +1 -22
- package/utils/get-current-project.js +1 -25
- package/utils/get-ip.js +1 -19
- package/utils/log.js +1 -19
- package/utils/node-blob.js +1 -106
- package/utils/resumable.d.js +1 -0
- package/utils/resumable.js +1 -1204
- package/utils/spinner.js +1 -25
- package/utils/tunnel.js +1 -36
- package/.editorconfig +0 -15
- package/.eslintignore +0 -8
- package/.eslintrc.js +0 -10
- package/.vscode/launch.json +0 -23
- package/LICENSE +0 -21
- package/README.git.md +0 -37
- package/assets/index.js +0 -147
- package/build/dist/index.dev.js +0 -217
- package/config/dist/index.dev.js +0 -48
- package/create/init-zmp-ui.js +0 -216
- package/create/templates/app-parameters.js +0 -33
- package/create/templates/common/css/icons.css +0 -60
- package/create/templates/common/icons/512x512.png +0 -0
- package/create/templates/common/icons/apple-touch-icon.png +0 -0
- package/create/templates/common/icons/favicon.png +0 -0
- package/create/templates/common/postcss.config.js +0 -5
- package/create/templates/common/splash-2732x2732.png +0 -0
- package/create/templates/common/tailwind/postcss.config.js +0 -5
- package/create/templates/common/tailwind/tailwind.config.js +0 -9
- package/create/templates/common/tailwind/tailwind.css +0 -3
- package/create/templates/common/webpack/build.js +0 -41
- package/create/templates/copy-assets.js +0 -158
- package/create/templates/core/babel.config.js +0 -11
- package/create/templates/core/copy-assets.js +0 -83
- package/create/templates/core/generate-home-page.js +0 -143
- package/create/templates/core/generate-root.js +0 -283
- package/create/templates/core/generate-routes.js +0 -155
- package/create/templates/core/generate-scripts.js +0 -94
- package/create/templates/core/pages/404.html +0 -20
- package/create/templates/core/pages/about.html +0 -26
- package/create/templates/core/pages/catalog.html +0 -40
- package/create/templates/core/pages/dynamic-route.html +0 -115
- package/create/templates/core/pages/form.html +0 -258
- package/create/templates/core/pages/left-page-1.html +0 -24
- package/create/templates/core/pages/left-page-2.html +0 -23
- package/create/templates/core/pages/product.html +0 -36
- package/create/templates/core/pages/request-and-load.html +0 -35
- package/create/templates/core/pages/settings.html +0 -252
- package/create/templates/create-folders.js +0 -30
- package/create/templates/dist/generate-styles.dev.js +0 -46
- package/create/templates/generate-config-xml.js +0 -18
- package/create/templates/generate-index.js +0 -49
- package/create/templates/generate-manifest.js +0 -49
- package/create/templates/generate-recoil.js +0 -56
- package/create/templates/generate-routes.js +0 -16
- package/create/templates/generate-scripts.js +0 -16
- package/create/templates/generate-service-worker.js +0 -126
- package/create/templates/generate-store.js +0 -88
- package/create/templates/generate-styles.js +0 -110
- package/create/templates/generate-webpack-config.js +0 -335
- package/create/templates/generate-zmp-custom.js +0 -81
- package/create/templates/react/babel.config.js +0 -12
- package/create/templates/react/components/app-items.jsx +0 -44
- package/create/templates/react/components/navbar-back.jsx +0 -25
- package/create/templates/react/components/user-card.jsx +0 -18
- package/create/templates/react/copy-assets.js +0 -85
- package/create/templates/react/dist/generate-scripts.dev.js +0 -23
- package/create/templates/react/generate-home-page.js +0 -111
- package/create/templates/react/generate-root.js +0 -84
- package/create/templates/react/generate-routes.js +0 -16
- package/create/templates/react/generate-scripts.js +0 -68
- package/create/templates/react/pages/404.js +0 -27
- package/create/templates/react/pages/about.js +0 -52
- package/create/templates/react/pages/catalog.js +0 -112
- package/create/templates/react/pages/dynamic-route.js +0 -80
- package/create/templates/react/pages/form.js +0 -152
- package/create/templates/react/pages/index copy.js +0 -17
- package/create/templates/react/pages/index.js +0 -17
- package/create/templates/react/pages/settings.js +0 -76
- package/create/templates/react/pages/user.js +0 -56
- package/create/templates/react/vite.config.js +0 -11
- package/create/templates/react-typescript/_tsconfig.json +0 -33
- package/create/templates/react-typescript/components/app-items.js +0 -53
- package/create/templates/react-typescript/components/index.js +0 -9
- package/create/templates/react-typescript/components/navbar-back.js +0 -40
- package/create/templates/react-typescript/components/user-card.js +0 -32
- package/create/templates/react-typescript/copy-assets.js +0 -94
- package/create/templates/react-typescript/dist/generate-scripts.dev.js +0 -23
- package/create/templates/react-typescript/generate-home-page.js +0 -113
- package/create/templates/react-typescript/generate-root.js +0 -81
- package/create/templates/react-typescript/generate-routes.js +0 -12
- package/create/templates/react-typescript/generate-scripts.js +0 -67
- package/create/templates/react-typescript/pages/404.js +0 -27
- package/create/templates/react-typescript/pages/about.js +0 -52
- package/create/templates/react-typescript/pages/catalog.js +0 -112
- package/create/templates/react-typescript/pages/dynamic-route.js +0 -80
- package/create/templates/react-typescript/pages/form.js +0 -152
- package/create/templates/react-typescript/pages/index.js +0 -17
- package/create/templates/react-typescript/pages/settings.js +0 -76
- package/create/templates/react-typescript/pages/user.js +0 -56
- package/create/templates/react-typescript/vite.config.js +0 -21
- package/create/templates/svelte/babel.config.js +0 -10
- package/create/templates/svelte/copy-assets.js +0 -47
- package/create/templates/svelte/generate-home-page.js +0 -158
- package/create/templates/svelte/generate-root.js +0 -235
- package/create/templates/svelte/generate-routes.js +0 -91
- package/create/templates/svelte/generate-scripts.js +0 -47
- package/create/templates/svelte/pages/404.svelte +0 -10
- package/create/templates/svelte/pages/about.svelte +0 -16
- package/create/templates/svelte/pages/catalog.svelte +0 -31
- package/create/templates/svelte/pages/dynamic-route.svelte +0 -34
- package/create/templates/svelte/pages/form.svelte +0 -175
- package/create/templates/svelte/pages/left-page-1.svelte +0 -13
- package/create/templates/svelte/pages/left-page-2.svelte +0 -12
- package/create/templates/svelte/pages/product.svelte +0 -21
- package/create/templates/svelte/pages/request-and-load.svelte +0 -21
- package/create/templates/svelte/pages/settings.svelte +0 -175
- package/create/templates/vue/babel.config.js +0 -10
- package/create/templates/vue/components/header.vue +0 -28
- package/create/templates/vue/components/sun-and-moon.vue +0 -34
- package/create/templates/vue/copy-assets.js +0 -67
- package/create/templates/vue/generate-home-page.js +0 -56
- package/create/templates/vue/generate-root.js +0 -50
- package/create/templates/vue/generate-routes.js +0 -7
- package/create/templates/vue/generate-scripts.js +0 -63
- package/create/templates/vue/global-components.d.ts +0 -121
- package/create/templates/vue/icons/moon.svg +0 -3
- package/create/templates/vue/icons/sun.svg +0 -3
- package/create/templates/vue/pages/404.vue +0 -12
- package/create/templates/vue/pages/about.vue +0 -15
- package/create/templates/vue/pages/catalog.vue +0 -39
- package/create/templates/vue/pages/dynamic-route.vue +0 -34
- package/create/templates/vue/pages/form.vue +0 -162
- package/create/templates/vue/pages/left-page-1.vue +0 -14
- package/create/templates/vue/pages/left-page-2.vue +0 -11
- package/create/templates/vue/pages/product.vue +0 -31
- package/create/templates/vue/pages/request-and-load.vue +0 -25
- package/create/templates/vue/pages/settings.vue +0 -18
- package/create/templates/vue/vite.config.js +0 -11
- package/create/templates/zaui/_tsconfig.json +0 -33
- package/create/templates/zaui/babel.config.js +0 -12
- package/create/templates/zaui/components/user-card.jsx +0 -16
- package/create/templates/zaui/copy-assets.js +0 -90
- package/create/templates/zaui/generate-home-page.js +0 -117
- package/create/templates/zaui/generate-root.js +0 -53
- package/create/templates/zaui/generate-routes.js +0 -10
- package/create/templates/zaui/generate-scripts.js +0 -39
- package/create/templates/zaui/generate-user-card.js +0 -55
- package/create/templates/zaui/pages/about.js +0 -129
- package/create/templates/zaui/pages/form.js +0 -123
- package/create/templates/zaui/pages/index.js +0 -9
- package/create/templates/zaui/pages/user.js +0 -109
- package/create/templates/zaui/vite.config.js +0 -11
- package/create/utils/colors.js +0 -94
- package/create/utils/dist/get-options.dev.js +0 -277
- package/create/utils/generate-gitignore.js +0 -43
- package/create/utils/generate-package-json.js +0 -132
- package/create/utils/generate-readme.js +0 -28
- package/create/utils/indent.js +0 -31
- package/create/utils/string.js +0 -13
- package/create/utils/styles-extension.js +0 -9
- package/create/utils/template-if.js +0 -9
- package/deploy/dist/index.dev.js +0 -227
- package/deploy/utils/dist/request-upload.dev.js +0 -62
- package/deploy/utils/dist/upload-app.dev.js +0 -113
- package/dist/bundle.js +0 -1
- package/dist/index.dev.js +0 -352
- package/jsconfig.json +0 -8
- package/login/dist/index.dev.js +0 -223
- package/login/utils/dist/zalo-login.dev.js +0 -41
- package/screenshots/wellcome.jpg +0 -0
- package/show-qr-app/assets/css/style.css +0 -87
- package/show-qr-app/assets/js/qrcode.min.js +0 -1
- package/show-qr-app/index.html +0 -57
- package/show-qr-app/package.json +0 -14
- package/start/dist/index.dev.js +0 -312
- package/start/generate-hr-config.js +0 -59
- package/ui/server.js +0 -194
- package/ui/www/css/app.css +0 -1
- package/ui/www/css/app.css.map +0 -1
- package/ui/www/fonts/ZMPIcons-Regular.eot +0 -0
- package/ui/www/fonts/ZMPIcons-Regular.ttf +0 -0
- package/ui/www/fonts/ZMPIcons-Regular.woff +0 -0
- package/ui/www/fonts/ZMPIcons-Regular.woff2 +0 -0
- package/ui/www/images/logo.png +0 -0
- package/ui/www/index.html +0 -1
- package/ui/www/js/app.js +0 -3
- package/ui/www/js/app.js.LICENSE.txt +0 -20
- package/ui/www/js/app.js.map +0 -1
- package/ui/www/static/icons/apple-touch-icon.png +0 -0
- package/ui/www/static/icons/favicon.png +0 -0
- package/utils/dist/get-app-info.dev.js +0 -54
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
const indent = require('../utils/indent');
|
|
2
|
-
const templateIf = require('../utils/template-if');
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
module.exports = (options) => {
|
|
6
|
-
const { framework } = options;
|
|
7
|
-
if (framework === 'vue') {
|
|
8
|
-
return indent(0, `
|
|
9
|
-
import { createStore } from 'zmp-core/lite';
|
|
10
|
-
const store = createStore({
|
|
11
|
-
state: {
|
|
12
|
-
user: {
|
|
13
|
-
id: '',
|
|
14
|
-
name: '',
|
|
15
|
-
avatar: ''
|
|
16
|
-
},
|
|
17
|
-
darkMode: false,
|
|
18
|
-
},
|
|
19
|
-
getters: {
|
|
20
|
-
user({ state }) {
|
|
21
|
-
return state.user
|
|
22
|
-
},
|
|
23
|
-
darkMode({ state }) {
|
|
24
|
-
return state.darkMode
|
|
25
|
-
}
|
|
26
|
-
},
|
|
27
|
-
actions: {
|
|
28
|
-
setUser({ state }, data) {
|
|
29
|
-
state.user = { ...state.user, ...data }
|
|
30
|
-
},
|
|
31
|
-
setDarkMode({ state }, dark) {
|
|
32
|
-
state.darkMode = dark
|
|
33
|
-
}
|
|
34
|
-
},
|
|
35
|
-
})
|
|
36
|
-
|
|
37
|
-
export default store;
|
|
38
|
-
`);
|
|
39
|
-
}
|
|
40
|
-
return indent(0, `
|
|
41
|
-
import { createStore } from 'zmp-core${framework === 'core' ? '' : '/lite'}';
|
|
42
|
-
const store = createStore({
|
|
43
|
-
state: {
|
|
44
|
-
user: {
|
|
45
|
-
id: '12345678',
|
|
46
|
-
name: 'Zalo',
|
|
47
|
-
avatar: 'ZA',
|
|
48
|
-
},
|
|
49
|
-
products: [
|
|
50
|
-
{
|
|
51
|
-
id: '1',
|
|
52
|
-
title: 'Apple iPhone 8',
|
|
53
|
-
description: 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Nisi tempora similique reiciendis, error nesciunt vero, blanditiis pariatur dolor, minima sed sapiente rerum, dolorem corrupti hic modi praesentium unde saepe perspiciatis.'
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
id: '2',
|
|
57
|
-
title: 'Apple iPhone 8 Plus',
|
|
58
|
-
description: 'Velit odit autem modi saepe ratione totam minus, aperiam, labore quia provident temporibus quasi est ut aliquid blanditiis beatae suscipit odio vel! Nostrum porro sunt sint eveniet maiores, dolorem itaque!'
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
id: '3',
|
|
62
|
-
title: 'Apple iPhone X',
|
|
63
|
-
description: 'Expedita sequi perferendis quod illum pariatur aliquam, alias laboriosam! Vero blanditiis placeat, mollitia necessitatibus reprehenderit. Labore dolores amet quos, accusamus earum asperiores officiis assumenda optio architecto quia neque, quae eum.'
|
|
64
|
-
},
|
|
65
|
-
]
|
|
66
|
-
},
|
|
67
|
-
getters: {
|
|
68
|
-
user({ state }) {
|
|
69
|
-
return state.user
|
|
70
|
-
},
|
|
71
|
-
products({ state }) {
|
|
72
|
-
return state.products;
|
|
73
|
-
}
|
|
74
|
-
},
|
|
75
|
-
actions: {
|
|
76
|
-
setUser({ state }, data) {
|
|
77
|
-
state.user = { ...state.user, ...data }
|
|
78
|
-
},
|
|
79
|
-
addProduct({ state }, product) {
|
|
80
|
-
state.products = [...state.products, product];
|
|
81
|
-
},
|
|
82
|
-
},
|
|
83
|
-
})
|
|
84
|
-
|
|
85
|
-
export default store;
|
|
86
|
-
`
|
|
87
|
-
);
|
|
88
|
-
};
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
const indent = require('../utils/indent');
|
|
2
|
-
const { colorThemeCSSProperties } = require('../utils/colors');
|
|
3
|
-
|
|
4
|
-
module.exports = (options) => {
|
|
5
|
-
const { template, theming, package } = options;
|
|
6
|
-
const { customColor, color, fillBars } = theming;
|
|
7
|
-
|
|
8
|
-
let styles = '';
|
|
9
|
-
|
|
10
|
-
if (package === 'zmp-ui') {
|
|
11
|
-
return `
|
|
12
|
-
.page {
|
|
13
|
-
padding: 16px 16px 96px 16px;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
.section-container {
|
|
17
|
-
padding: 16px;
|
|
18
|
-
background: #ffffff;
|
|
19
|
-
border-radius: 8px;
|
|
20
|
-
margin-bottom: 24px;
|
|
21
|
-
}
|
|
22
|
-
`;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
let themeRgb = [0, 122, 255];
|
|
26
|
-
|
|
27
|
-
if (customColor && color) {
|
|
28
|
-
const customProps = colorThemeCSSProperties(`${color}`);
|
|
29
|
-
themeRgb = customProps['--zmp-theme-color-rgb']
|
|
30
|
-
.split(',')
|
|
31
|
-
.map((n) => n.trim());
|
|
32
|
-
styles += indent(
|
|
33
|
-
0,
|
|
34
|
-
`
|
|
35
|
-
/* Custom color theme properties */
|
|
36
|
-
:root {
|
|
37
|
-
${Object.keys(customProps)
|
|
38
|
-
.filter(
|
|
39
|
-
(prop) =>
|
|
40
|
-
prop !== '--zmp-tabbar-fill-link-active-color' &&
|
|
41
|
-
prop !== '--zmp-tabbar-fill-link-active-border-color'
|
|
42
|
-
)
|
|
43
|
-
.map((prop) => `${prop}: ${customProps[prop]};`)
|
|
44
|
-
.join('\n ')}
|
|
45
|
-
}
|
|
46
|
-
:root.theme-dark,:root .theme-dark {
|
|
47
|
-
${Object.keys(customProps)
|
|
48
|
-
.map((prop) => `${prop}: ${customProps[prop]};`)
|
|
49
|
-
.join('\n ')}
|
|
50
|
-
}
|
|
51
|
-
`
|
|
52
|
-
);
|
|
53
|
-
}
|
|
54
|
-
if (fillBars) {
|
|
55
|
-
styles += indent(
|
|
56
|
-
0,
|
|
57
|
-
`
|
|
58
|
-
/* Invert navigation bars to fill style */
|
|
59
|
-
`
|
|
60
|
-
);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
if (template === 'split-view') {
|
|
64
|
-
styles += indent(
|
|
65
|
-
0,
|
|
66
|
-
`
|
|
67
|
-
/* Left Panel right border when it is visible by breakpoint */
|
|
68
|
-
.panel-left.panel-in-breakpoint:before {
|
|
69
|
-
position: absolute;
|
|
70
|
-
right: 0;
|
|
71
|
-
top: 0;
|
|
72
|
-
height: 100%;
|
|
73
|
-
width: 1px;
|
|
74
|
-
background: rgba(0,0,0,0.1);
|
|
75
|
-
content: '';
|
|
76
|
-
z-index: 6000;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/* Hide navbar link which opens left panel when it is visible by breakpoint */
|
|
80
|
-
.panel-left.panel-in-breakpoint ~ .view .navbar .panel-open[data-panel="left"] {
|
|
81
|
-
display: none;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/*
|
|
85
|
-
Extra borders for main view and left panel for iOS theme when it behaves as panel (before breakpoint size)
|
|
86
|
-
*/
|
|
87
|
-
.ios .panel-left:not(.panel-in-breakpoint).panel-in ~ .view-main:before,
|
|
88
|
-
.ios .panel-left:not(.panel-in-breakpoint).panel-closing ~ .view-main:before {
|
|
89
|
-
position: absolute;
|
|
90
|
-
left: 0;
|
|
91
|
-
top: 0;
|
|
92
|
-
height: 100%;
|
|
93
|
-
width: 1px;
|
|
94
|
-
background: rgba(0,0,0,0.1);
|
|
95
|
-
content: '';
|
|
96
|
-
z-index: 6000;
|
|
97
|
-
}
|
|
98
|
-
`
|
|
99
|
-
);
|
|
100
|
-
} else {
|
|
101
|
-
styles += indent(
|
|
102
|
-
0,
|
|
103
|
-
`
|
|
104
|
-
/* Your app custom styles here */
|
|
105
|
-
`
|
|
106
|
-
);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
return styles.trim();
|
|
110
|
-
};
|
|
@@ -1,335 +0,0 @@
|
|
|
1
|
-
const indent = require('../utils/indent');
|
|
2
|
-
const templateIf = require('../utils/template-if');
|
|
3
|
-
|
|
4
|
-
module.exports = (options) => {
|
|
5
|
-
const { framework, type, webpack } = options;
|
|
6
|
-
|
|
7
|
-
let resolveExtensions = "['.js', '.json']";
|
|
8
|
-
if (framework === 'vue') {
|
|
9
|
-
resolveExtensions = "['.js', '.vue', '.json']";
|
|
10
|
-
}
|
|
11
|
-
if (framework === 'react') {
|
|
12
|
-
resolveExtensions = "['.js', '.jsx', '.json']";
|
|
13
|
-
}
|
|
14
|
-
if (framework === 'svelte') {
|
|
15
|
-
resolveExtensions = "['.mjs', '.js', '.svelte', '.json']";
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const productionDevtool = webpack.productionSourceMap
|
|
19
|
-
? "'source-map'"
|
|
20
|
-
: false;
|
|
21
|
-
const developmentDevtool = webpack.developmentSourceMap ? "'eval'" : false;
|
|
22
|
-
const hashName = webpack.hashAssets ? '.[hash:6]' : '';
|
|
23
|
-
const assetsLoader = webpack.inlineAssets ? 'url-loader' : 'file-loader';
|
|
24
|
-
const preserveAssetsPaths = webpack.preserveAssetsPaths; // eslint-disable-line
|
|
25
|
-
|
|
26
|
-
return indent(
|
|
27
|
-
0,
|
|
28
|
-
`
|
|
29
|
-
const webpack = require('webpack');
|
|
30
|
-
const CopyWebpackPlugin = require('copy-webpack-plugin');
|
|
31
|
-
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
32
|
-
${templateIf(
|
|
33
|
-
framework === 'vue',
|
|
34
|
-
() => `
|
|
35
|
-
const { VueLoaderPlugin } = require('vue-loader');
|
|
36
|
-
`
|
|
37
|
-
)}
|
|
38
|
-
${templateIf(
|
|
39
|
-
framework === 'react',
|
|
40
|
-
() => `
|
|
41
|
-
const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin');
|
|
42
|
-
`
|
|
43
|
-
)}
|
|
44
|
-
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
|
45
|
-
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
|
|
46
|
-
const TerserPlugin = require('terser-webpack-plugin');
|
|
47
|
-
${templateIf(
|
|
48
|
-
type.indexOf('pwa') >= 0,
|
|
49
|
-
() => `
|
|
50
|
-
const WorkboxPlugin = require('workbox-webpack-plugin');
|
|
51
|
-
`
|
|
52
|
-
)}
|
|
53
|
-
const path = require('path');
|
|
54
|
-
|
|
55
|
-
function resolvePath(dir) {
|
|
56
|
-
return path.join(__dirname, '..', dir);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
const env = process.env.NODE_ENV || 'development';
|
|
60
|
-
const target = process.env.TARGET || 'web';
|
|
61
|
-
|
|
62
|
-
module.exports = {
|
|
63
|
-
mode: env,
|
|
64
|
-
target: env === "development" ? "web" : "browserslist",
|
|
65
|
-
entry: {
|
|
66
|
-
app: './src/js/app.js',
|
|
67
|
-
},
|
|
68
|
-
output: {
|
|
69
|
-
path: resolvePath('www'),
|
|
70
|
-
filename: 'js/[name]${hashName}.js',
|
|
71
|
-
chunkFilename: 'js/[name]${hashName}.js',
|
|
72
|
-
publicPath: '',
|
|
73
|
-
hotUpdateChunkFilename: 'hot/hot-update.js',
|
|
74
|
-
hotUpdateMainFilename: 'hot/hot-update.json',
|
|
75
|
-
},
|
|
76
|
-
resolve: {
|
|
77
|
-
extensions: ${resolveExtensions},
|
|
78
|
-
alias: {
|
|
79
|
-
'@': resolvePath('src'),
|
|
80
|
-
},
|
|
81
|
-
${templateIf(
|
|
82
|
-
framework === 'svelte',
|
|
83
|
-
() => `
|
|
84
|
-
mainFields: ['svelte', 'browser', 'module', 'main']
|
|
85
|
-
`
|
|
86
|
-
)}
|
|
87
|
-
},
|
|
88
|
-
devtool: env === 'production' ? ${productionDevtool} : ${developmentDevtool},
|
|
89
|
-
devServer: {
|
|
90
|
-
hot: true,
|
|
91
|
-
open: true,
|
|
92
|
-
compress: true,
|
|
93
|
-
contentBase: '/www/',
|
|
94
|
-
disableHostCheck: true,
|
|
95
|
-
historyApiFallback: true,
|
|
96
|
-
},
|
|
97
|
-
optimization: {
|
|
98
|
-
concatenateModules: true,
|
|
99
|
-
minimizer: [new TerserPlugin()],
|
|
100
|
-
},
|
|
101
|
-
module: {
|
|
102
|
-
rules: [
|
|
103
|
-
{
|
|
104
|
-
test: /\\.(mjs|js|jsx)$/,
|
|
105
|
-
include: [
|
|
106
|
-
resolvePath('src'),
|
|
107
|
-
${templateIf(
|
|
108
|
-
framework === 'svelte',
|
|
109
|
-
() => `
|
|
110
|
-
resolvePath('node_modules/svelte'),
|
|
111
|
-
`
|
|
112
|
-
)}
|
|
113
|
-
],
|
|
114
|
-
use: [
|
|
115
|
-
{
|
|
116
|
-
loader: require.resolve('babel-loader'),
|
|
117
|
-
${templateIf(
|
|
118
|
-
framework === 'react',
|
|
119
|
-
() => `
|
|
120
|
-
options: env === 'development' ? {
|
|
121
|
-
plugins: [
|
|
122
|
-
require.resolve('react-refresh/babel'),
|
|
123
|
-
]
|
|
124
|
-
} : {}
|
|
125
|
-
`
|
|
126
|
-
)}
|
|
127
|
-
},
|
|
128
|
-
]
|
|
129
|
-
},
|
|
130
|
-
${templateIf(
|
|
131
|
-
framework === 'core',
|
|
132
|
-
() => `
|
|
133
|
-
{
|
|
134
|
-
test: /\\.zmp.(html|js)$/,
|
|
135
|
-
use: [
|
|
136
|
-
'babel-loader',
|
|
137
|
-
'zmp-loader',
|
|
138
|
-
],
|
|
139
|
-
},
|
|
140
|
-
`
|
|
141
|
-
)}
|
|
142
|
-
${templateIf(
|
|
143
|
-
framework === 'svelte',
|
|
144
|
-
() => `
|
|
145
|
-
{
|
|
146
|
-
test: /\\.svelte$/,
|
|
147
|
-
use: {
|
|
148
|
-
loader: 'svelte-loader',
|
|
149
|
-
options: {
|
|
150
|
-
emitCss: true,
|
|
151
|
-
},
|
|
152
|
-
},
|
|
153
|
-
},
|
|
154
|
-
`
|
|
155
|
-
)}
|
|
156
|
-
${templateIf(
|
|
157
|
-
framework === 'vue',
|
|
158
|
-
() => `
|
|
159
|
-
{
|
|
160
|
-
test: /\\.vue$/,
|
|
161
|
-
use: 'vue-loader',
|
|
162
|
-
},
|
|
163
|
-
`
|
|
164
|
-
)}
|
|
165
|
-
{
|
|
166
|
-
test: /\\.css$/,
|
|
167
|
-
use: [
|
|
168
|
-
(env === 'development' ? 'style-loader' : {
|
|
169
|
-
loader: MiniCssExtractPlugin.loader,
|
|
170
|
-
options: {
|
|
171
|
-
publicPath: '../'
|
|
172
|
-
}
|
|
173
|
-
}),
|
|
174
|
-
'css-loader',
|
|
175
|
-
'postcss-loader',
|
|
176
|
-
],
|
|
177
|
-
},
|
|
178
|
-
{
|
|
179
|
-
test: /\\.styl(us)?$/,
|
|
180
|
-
use: [
|
|
181
|
-
(env === 'development' ? 'style-loader' : {
|
|
182
|
-
loader: MiniCssExtractPlugin.loader,
|
|
183
|
-
options: {
|
|
184
|
-
publicPath: '../'
|
|
185
|
-
}
|
|
186
|
-
}),
|
|
187
|
-
'css-loader',
|
|
188
|
-
'postcss-loader',
|
|
189
|
-
'stylus-loader',
|
|
190
|
-
],
|
|
191
|
-
},
|
|
192
|
-
{
|
|
193
|
-
test: /\\.less$/,
|
|
194
|
-
use: [
|
|
195
|
-
(env === 'development' ? 'style-loader' : {
|
|
196
|
-
loader: MiniCssExtractPlugin.loader,
|
|
197
|
-
options: {
|
|
198
|
-
publicPath: '../'
|
|
199
|
-
}
|
|
200
|
-
}),
|
|
201
|
-
'css-loader',
|
|
202
|
-
'postcss-loader',
|
|
203
|
-
'less-loader',
|
|
204
|
-
],
|
|
205
|
-
},
|
|
206
|
-
{
|
|
207
|
-
test: /\\.(sa|sc)ss$/,
|
|
208
|
-
use: [
|
|
209
|
-
(env === 'development' ? 'style-loader' : {
|
|
210
|
-
loader: MiniCssExtractPlugin.loader,
|
|
211
|
-
options: {
|
|
212
|
-
publicPath: '../'
|
|
213
|
-
}
|
|
214
|
-
}),
|
|
215
|
-
'css-loader',
|
|
216
|
-
'postcss-loader',
|
|
217
|
-
'sass-loader',
|
|
218
|
-
],
|
|
219
|
-
},
|
|
220
|
-
{
|
|
221
|
-
test: /\\.(png|jpe?g|gif|svg)(\\?.*)?$/,
|
|
222
|
-
loader: '${assetsLoader}',
|
|
223
|
-
options: {
|
|
224
|
-
limit: 10000,
|
|
225
|
-
name: '${
|
|
226
|
-
preserveAssetsPaths ? '[path]' : 'images/'
|
|
227
|
-
}[name]${hashName}.[ext]',
|
|
228
|
-
${templateIf(
|
|
229
|
-
preserveAssetsPaths,
|
|
230
|
-
() => `
|
|
231
|
-
context: path.resolve(__dirname, '../src'),
|
|
232
|
-
`
|
|
233
|
-
)}
|
|
234
|
-
},
|
|
235
|
-
type: 'javascript/auto'
|
|
236
|
-
},
|
|
237
|
-
{
|
|
238
|
-
test: /\\.(mp4|webm|ogg|mp3|wav|flac|aac|m4a)(\\?.*)?$/,
|
|
239
|
-
loader: '${assetsLoader}',
|
|
240
|
-
options: {
|
|
241
|
-
limit: 10000,
|
|
242
|
-
name: '${
|
|
243
|
-
preserveAssetsPaths ? '[path]' : 'media/'
|
|
244
|
-
}[name]${hashName}.[ext]',
|
|
245
|
-
${templateIf(
|
|
246
|
-
preserveAssetsPaths,
|
|
247
|
-
() => `
|
|
248
|
-
context: path.resolve(__dirname, '../src'),
|
|
249
|
-
`
|
|
250
|
-
)}
|
|
251
|
-
},
|
|
252
|
-
type: 'javascript/auto'
|
|
253
|
-
},
|
|
254
|
-
{
|
|
255
|
-
test: /\\.(woff2?|eot|ttf|otf)(\\?.*)?$/,
|
|
256
|
-
loader: '${assetsLoader}',
|
|
257
|
-
options: {
|
|
258
|
-
limit: 10000,
|
|
259
|
-
name: '${
|
|
260
|
-
preserveAssetsPaths ? '[path]' : 'fonts/'
|
|
261
|
-
}[name]${hashName}.[ext]',
|
|
262
|
-
${templateIf(
|
|
263
|
-
preserveAssetsPaths,
|
|
264
|
-
() => `
|
|
265
|
-
context: path.resolve(__dirname, '../src'),
|
|
266
|
-
`
|
|
267
|
-
)}
|
|
268
|
-
},
|
|
269
|
-
type: 'javascript/auto'
|
|
270
|
-
},
|
|
271
|
-
],
|
|
272
|
-
},
|
|
273
|
-
plugins: [
|
|
274
|
-
new webpack.DefinePlugin({
|
|
275
|
-
'process.env.NODE_ENV': JSON.stringify(env),
|
|
276
|
-
'process.env.TARGET': JSON.stringify(target),
|
|
277
|
-
}),
|
|
278
|
-
${templateIf(
|
|
279
|
-
framework === 'vue',
|
|
280
|
-
() => `
|
|
281
|
-
new VueLoaderPlugin(),
|
|
282
|
-
`
|
|
283
|
-
)}
|
|
284
|
-
...(env === 'production' ? [
|
|
285
|
-
new CssMinimizerPlugin(),
|
|
286
|
-
] : [
|
|
287
|
-
// Development only plugins
|
|
288
|
-
new webpack.HotModuleReplacementPlugin(),
|
|
289
|
-
${templateIf(
|
|
290
|
-
framework === 'react',
|
|
291
|
-
() => 'new ReactRefreshWebpackPlugin(),'
|
|
292
|
-
)}
|
|
293
|
-
]),
|
|
294
|
-
new HtmlWebpackPlugin({
|
|
295
|
-
filename: './index.html',
|
|
296
|
-
template: './src/index.html',
|
|
297
|
-
inject: true,
|
|
298
|
-
minify: env === 'production' ? {
|
|
299
|
-
collapseWhitespace: true,
|
|
300
|
-
removeComments: true,
|
|
301
|
-
removeRedundantAttributes: ${
|
|
302
|
-
framework === 'core' ? 'false' : 'true'
|
|
303
|
-
},
|
|
304
|
-
removeScriptTypeAttributes: true,
|
|
305
|
-
removeStyleLinkTypeAttributes: true,
|
|
306
|
-
useShortDoctype: true
|
|
307
|
-
} : false,
|
|
308
|
-
}),
|
|
309
|
-
new MiniCssExtractPlugin({
|
|
310
|
-
filename: 'css/[name]${hashName}.css',
|
|
311
|
-
}),
|
|
312
|
-
new CopyWebpackPlugin({
|
|
313
|
-
patterns: [
|
|
314
|
-
{
|
|
315
|
-
noErrorOnMissing: true,
|
|
316
|
-
from: resolvePath('src/static'),
|
|
317
|
-
to: resolvePath('www/static'),
|
|
318
|
-
},
|
|
319
|
-
${templateIf(
|
|
320
|
-
type.indexOf('pwa') >= 0,
|
|
321
|
-
() => `
|
|
322
|
-
{
|
|
323
|
-
noErrorOnMissing: true,
|
|
324
|
-
from: resolvePath('src/manifest.json'),
|
|
325
|
-
to: resolvePath('www/manifest.json'),
|
|
326
|
-
},
|
|
327
|
-
`
|
|
328
|
-
)}
|
|
329
|
-
],
|
|
330
|
-
}),
|
|
331
|
-
],
|
|
332
|
-
};
|
|
333
|
-
`
|
|
334
|
-
).trim();
|
|
335
|
-
};
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
const indent = require('../utils/indent');
|
|
2
|
-
|
|
3
|
-
module.exports = (options) => {
|
|
4
|
-
const {
|
|
5
|
-
themes = [],
|
|
6
|
-
rtl = false,
|
|
7
|
-
lightTheme = true,
|
|
8
|
-
darkTheme = true,
|
|
9
|
-
components = [],
|
|
10
|
-
} = options.customBuildConfig || {};
|
|
11
|
-
|
|
12
|
-
const filterCharts = (comps) => {
|
|
13
|
-
return comps.filter((c) => {
|
|
14
|
-
if (c === 'gauge' || c === 'area-chart' || c === 'pie-chart')
|
|
15
|
-
return false;
|
|
16
|
-
return true;
|
|
17
|
-
});
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
const { framework } = options;
|
|
21
|
-
|
|
22
|
-
const componentsImportsJS = filterCharts(components).map((c) => {
|
|
23
|
-
const name = c
|
|
24
|
-
.split('-')
|
|
25
|
-
.map((word) => {
|
|
26
|
-
return word[0].toUpperCase() + word.substring(1);
|
|
27
|
-
})
|
|
28
|
-
.join('');
|
|
29
|
-
return `import ${name} from 'zmp-framework/core/components/${c}';`;
|
|
30
|
-
});
|
|
31
|
-
const componentsNamesJS = filterCharts(components).map((c) => {
|
|
32
|
-
return c
|
|
33
|
-
.split('-')
|
|
34
|
-
.map((word) => {
|
|
35
|
-
return word[0].toUpperCase() + word.substring(1);
|
|
36
|
-
})
|
|
37
|
-
.join('');
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
const scripts = indent(
|
|
41
|
-
0,
|
|
42
|
-
`
|
|
43
|
-
import ZMP, { request, utils, getDevice, createStore } from '${
|
|
44
|
-
framework === 'core' ? 'zmp-framework/core' : 'zmp-framework/core/lite'
|
|
45
|
-
}';
|
|
46
|
-
${componentsImportsJS.join('\n ')}
|
|
47
|
-
|
|
48
|
-
ZMP.use([
|
|
49
|
-
${componentsNamesJS.join(',\n ')}
|
|
50
|
-
]);
|
|
51
|
-
|
|
52
|
-
export default ZMP;
|
|
53
|
-
export { request, utils, getDevice, createStore };
|
|
54
|
-
`
|
|
55
|
-
);
|
|
56
|
-
|
|
57
|
-
const componentsImportsLESS = components.map((c) => {
|
|
58
|
-
return `@import url('../../node_modules/zmp/components/${c}/${c}.less');`;
|
|
59
|
-
});
|
|
60
|
-
const styles = indent(
|
|
61
|
-
0,
|
|
62
|
-
`
|
|
63
|
-
& {
|
|
64
|
-
@import url('../../node_modules/zmp/zmp.less');
|
|
65
|
-
${componentsImportsLESS.join('\n ')}
|
|
66
|
-
|
|
67
|
-
@includeIosTheme: ${themes.indexOf('ios') >= 0};
|
|
68
|
-
@includeMdTheme: ${themes.indexOf('md') >= 0};
|
|
69
|
-
@includeAuroraTheme: ${themes.indexOf('aurora') >= 0};
|
|
70
|
-
@includeDarkTheme: ${darkTheme || false};
|
|
71
|
-
@includeLightTheme: ${lightTheme || false};
|
|
72
|
-
@rtl: ${rtl}
|
|
73
|
-
}
|
|
74
|
-
`
|
|
75
|
-
);
|
|
76
|
-
|
|
77
|
-
return {
|
|
78
|
-
styles,
|
|
79
|
-
scripts,
|
|
80
|
-
};
|
|
81
|
-
};
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Icon, Grid, GridItem, ToastPreloader } from 'zmp-framework/react';
|
|
3
|
-
|
|
4
|
-
const AppItems = () => {
|
|
5
|
-
const [toastLoading, setToastLoading] = React.useState(false);
|
|
6
|
-
const items = [
|
|
7
|
-
{ icon: 'zi-chat-solid', label: 'Chat' },
|
|
8
|
-
{ icon: 'zi-photo-solid', label: 'Photo' },
|
|
9
|
-
{ icon: 'zi-star-solid', label: 'Star' },
|
|
10
|
-
{ icon: 'zi-more-diamond-solid', label: 'Apps' },
|
|
11
|
-
{ icon: 'zi-video-solid', label: 'Video' },
|
|
12
|
-
{ icon: 'zi-shield-solid', label: 'Shield' },
|
|
13
|
-
{ icon: 'zi-heart-solid', label: 'Heart' },
|
|
14
|
-
{ icon: 'zi-calendar-solid', label: 'Calendar' },
|
|
15
|
-
]
|
|
16
|
-
|
|
17
|
-
const openToastLoading = () => {
|
|
18
|
-
setToastLoading(true);
|
|
19
|
-
setTimeout(() => {
|
|
20
|
-
setToastLoading(false);
|
|
21
|
-
}, 2000);
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
return (
|
|
25
|
-
<div>
|
|
26
|
-
<ToastPreloader visible={toastLoading} text="Loading..." />
|
|
27
|
-
<Grid columns={4}>
|
|
28
|
-
{items.map(item => (
|
|
29
|
-
<GridItem
|
|
30
|
-
label={item.label}
|
|
31
|
-
style={{ backgroundColor: 'var(--zmp-color-w300)' }}
|
|
32
|
-
key={item.icon}
|
|
33
|
-
icon={<Icon zmp={item.icon} />}
|
|
34
|
-
onClick={openToastLoading}
|
|
35
|
-
/>
|
|
36
|
-
))}
|
|
37
|
-
</Grid>
|
|
38
|
-
</div>
|
|
39
|
-
)
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
AppItems.displayName = 'zmp-app-items'
|
|
43
|
-
|
|
44
|
-
export default AppItems
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Link, Navbar, NavLeft, Icon, NavTitle, NavRight } from 'zmp-framework/react';
|
|
3
|
-
|
|
4
|
-
const NavbarBack = ({ title, linkRight, labelRight }) => {
|
|
5
|
-
return (
|
|
6
|
-
<Navbar>
|
|
7
|
-
<NavLeft displayName="zmp-navleft">
|
|
8
|
-
<Link className="no-ripple" noLinkClass back>
|
|
9
|
-
<Icon zmp="zi-arrow-left" />
|
|
10
|
-
</Link>
|
|
11
|
-
</NavLeft>
|
|
12
|
-
<NavTitle>{title}</NavTitle>
|
|
13
|
-
{linkRight && labelRight && (
|
|
14
|
-
<NavRight>
|
|
15
|
-
<Link href={linkRight} className="no-ripple" noLinkClass>{labelRight}</Link>
|
|
16
|
-
</NavRight>
|
|
17
|
-
)}
|
|
18
|
-
</Navbar>
|
|
19
|
-
)
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
NavbarBack.displayName = 'zmp-navbar';
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
export default NavbarBack;
|