@pixui-dev/pxw 0.1.22 → 0.1.24

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.
Files changed (95) hide show
  1. package/bin/pxw.js +192 -192
  2. package/bin/wpbuild.js +10 -10
  3. package/config/default.conf +20 -20
  4. package/config/devops.js +360 -360
  5. package/config/h5es.js +10 -10
  6. package/config/index.html +183 -183
  7. package/config/pfbs.js +251 -251
  8. package/config/util.js +136 -136
  9. package/config/webpack.js +324 -324
  10. package/lib/assets/check.html +62 -62
  11. package/lib/assets/preact.js +4354 -4354
  12. package/lib/check/main.less +62 -62
  13. package/lib/check/main.tsx +41 -41
  14. package/lib/check/tool.js +3 -3
  15. package/lib/check/util.tsx +110 -110
  16. package/lib/grpc-web/dist/ChunkParser.js +117 -117
  17. package/lib/grpc-web/dist/Code.js +58 -58
  18. package/lib/grpc-web/dist/client.js +299 -299
  19. package/lib/grpc-web/dist/debug.js +16 -16
  20. package/lib/grpc-web/dist/detach.js +7 -7
  21. package/lib/grpc-web/dist/index.js +29 -29
  22. package/lib/grpc-web/dist/invoke.js +32 -32
  23. package/lib/grpc-web/dist/message.js +3 -3
  24. package/lib/grpc-web/dist/metadata.js +5 -5
  25. package/lib/grpc-web/dist/service.js +3 -3
  26. package/lib/grpc-web/dist/transports/Transport.js +15 -15
  27. package/lib/grpc-web/dist/transports/http/fetch.js +117 -117
  28. package/lib/grpc-web/dist/transports/http/http.js +15 -15
  29. package/lib/grpc-web/dist/transports/http/xhr.js +136 -136
  30. package/lib/grpc-web/dist/transports/http/xhrUtil.js +36 -36
  31. package/lib/grpc-web/dist/transports/websocket/websocket.js +95 -95
  32. package/lib/grpc-web/dist/typings/ChunkParser.d.ts +17 -17
  33. package/lib/grpc-web/dist/typings/Code.d.ts +20 -20
  34. package/lib/grpc-web/dist/typings/client.d.ts +25 -25
  35. package/lib/grpc-web/dist/typings/debug.d.ts +1 -1
  36. package/lib/grpc-web/dist/typings/detach.d.ts +1 -1
  37. package/lib/grpc-web/dist/typings/index.d.ts +45 -45
  38. package/lib/grpc-web/dist/typings/invoke.d.ts +20 -20
  39. package/lib/grpc-web/dist/typings/message.d.ts +8 -8
  40. package/lib/grpc-web/dist/typings/metadata.d.ts +2 -2
  41. package/lib/grpc-web/dist/typings/service.d.ts +16 -16
  42. package/lib/grpc-web/dist/typings/transports/Transport.d.ts +22 -22
  43. package/lib/grpc-web/dist/typings/transports/http/fetch.d.ts +6 -6
  44. package/lib/grpc-web/dist/typings/transports/http/http.d.ts +5 -5
  45. package/lib/grpc-web/dist/typings/transports/http/xhr.d.ts +27 -27
  46. package/lib/grpc-web/dist/typings/transports/http/xhrUtil.d.ts +3 -3
  47. package/lib/grpc-web/dist/typings/transports/websocket/websocket.d.ts +2 -2
  48. package/lib/grpc-web/dist/typings/unary.d.ts +23 -23
  49. package/lib/grpc-web/dist/typings/util.d.ts +2 -2
  50. package/lib/grpc-web/dist/unary.js +44 -44
  51. package/lib/grpc-web/dist/util.js +11 -11
  52. package/lib/grpcTransport/PixHttp2Transport.ts +107 -107
  53. package/lib/grpcTransport/PixLuaTransport.ts +82 -82
  54. package/lib/h5es-types/v1.9.2/h5es.d.ts +1698 -1698
  55. package/lib/h5es-types/v3.5.0/h5es.d.ts +1788 -1788
  56. package/lib/pi_component/tinyList/tinyList.js +483 -483
  57. package/lib/pi_component/tinyList/tinyList.tsx +517 -517
  58. package/lib/preact-router.js +395 -395
  59. package/lib/preact.js +4355 -4355
  60. package/lib/preact.tq.js +4385 -4385
  61. package/lib/react-window/src/FixedSizeGrid.js +172 -172
  62. package/lib/react-window/src/FixedSizeList.js +91 -91
  63. package/lib/react-window/src/VariableSizeGrid.js +329 -329
  64. package/lib/react-window/src/VariableSizeList.js +231 -231
  65. package/lib/react-window/src/__tests__/FixedSizeGrid.js +942 -942
  66. package/lib/react-window/src/__tests__/FixedSizeList.js +749 -749
  67. package/lib/react-window/src/__tests__/VariableSizeGrid.js +598 -598
  68. package/lib/react-window/src/__tests__/VariableSizeList.js +345 -345
  69. package/lib/react-window/src/__tests__/__snapshots__/FixedSizeGrid.js.snap +912 -912
  70. package/lib/react-window/src/__tests__/__snapshots__/FixedSizeList.js.snap +568 -568
  71. package/lib/react-window/src/__tests__/__snapshots__/VariableSizeGrid.js.snap +542 -542
  72. package/lib/react-window/src/__tests__/__snapshots__/VariableSizeList.js.snap +331 -331
  73. package/lib/react-window/src/__tests__/areEqual.js +28 -28
  74. package/lib/react-window/src/__tests__/shouldComponentUpdate.js +32 -32
  75. package/lib/react-window/src/areEqual.js +13 -13
  76. package/lib/react-window/src/createGridComponent.js +657 -657
  77. package/lib/react-window/src/createListComponent.js +574 -574
  78. package/lib/react-window/src/domHelpers.js +69 -69
  79. package/lib/react-window/src/index.js +9 -9
  80. package/lib/react-window/src/shallowDiffers.js +17 -17
  81. package/lib/react-window/src/shouldComponentUpdate.js +11 -11
  82. package/lib/react-window/src/test.js.flow +382 -382
  83. package/lib/react-window/src/timer.js +36 -36
  84. package/lib/types/dom.ts +17 -17
  85. package/lib/types/ext.d.ts +81 -81
  86. package/lib/types/preact/css.d.ts +7476 -7476
  87. package/lib/types/preact/index.d.ts +340 -340
  88. package/lib/types/preact/internal.d.ts +94 -94
  89. package/lib/types/preact/jsx.d.ts +320 -309
  90. package/lib/types/preact-router/index.d.ts +84 -84
  91. package/package.json +114 -114
  92. package/scripts/pack.js +40 -40
  93. package/scripts/postinstall.js +12 -12
  94. package/scripts/run-pxw.js +13 -13
  95. package/tsconfig.json +30 -30
package/bin/pxw.js CHANGED
@@ -1,192 +1,192 @@
1
- #!/usr/bin/env node
2
- let fs = require('fs');
3
- let cp = require('child_process');
4
- let path = require('path');
5
- let http = require('http');
6
- let os = require('os');
7
- let util = require('../config/util');
8
- let pfbs = require('../config/pfbs');
9
- let webpack = require('../config/webpack');
10
- let argv = require('yargs').argv;
11
-
12
- let runInWindows = process.platform == 'win32';
13
- let pr = path.resolve;
14
- let log = console.log;
15
- log = () => {};
16
-
17
- let rootDir = pr(__dirname, '../');
18
- let testHtmlDir = pr(__dirname, '../pxtest/html');
19
- let projectConfig = util.loadProjectConfig();
20
- let appPort = parseInt(process.env['PXW_APP_PORT']) || projectConfig.port || 8001;
21
-
22
- let isDaemonMode = argv.d;
23
-
24
- process
25
- .on('unhandledRejection', (err) => {
26
- console.log('unhandledRejection', err);
27
- })
28
- .on('uncaughtException', (err) => {
29
- console.log('uncaughtException', err);
30
- });
31
-
32
- async function main() {
33
- let fetch = require('node-fetch');
34
- let express = require('express');
35
- let serveIndex = require('serve-index');
36
-
37
- let app = express();
38
- let server = http.createServer(app);
39
-
40
- let { notifyAppReload } = await require('../config/devops').setupDevops(server, app);
41
-
42
- app.use(express.json());
43
- app.use(pfbs.getMiddleware());
44
- app.use(webpack.devServer.getMiddleware()(appPort, notifyAppReload));
45
- app.use('/pxtest', serveIndex(testHtmlDir), express.static(testHtmlDir));
46
-
47
- app.use(function (err, req, res, next) {
48
- console.error(err);
49
- res.status(500).send('Internal Serverless Error');
50
- });
51
-
52
- server.listen(appPort, '0.0.0.0', () => {
53
- let ipList = [];
54
- util.getLocalIP().forEach((ip) => {
55
- console.log(`Server start on http://${ip}:${appPort}`);
56
- });
57
- });
58
- }
59
-
60
- //以下处理自动重启和单例
61
- function restart() {
62
- const scriptPath = process.argv[1];
63
- let removeArgs = { '--fg': 1 };
64
- let args = process.argv.slice(2);
65
- args = args.filter((v) => !removeArgs[v]);
66
- const subprocess = cp.spawn(process.execPath, [scriptPath, ...args], {
67
- detached: true,
68
- windowsHide: true,
69
- });
70
- subprocess.unref();
71
- process.exit();
72
- }
73
-
74
- function watchSelf() {
75
- //可以通过环境变量设置是否要监视重启
76
- let restartWatchFile = process.env['PXW_WATCHFILE'];
77
- if (restartWatchFile == 'none') return;
78
- if (!restartWatchFile) restartWatchFile = __filename;
79
- restartWatchFile = pr(restartWatchFile);
80
- console.log('watchfile:', restartWatchFile);
81
- let chokidar = require('chokidar');
82
- let watcher = chokidar.watch(restartWatchFile, { ignored: /^\./, persistent: true });
83
- watcher
84
- .on('change', function (path) {
85
- console.log(`pid[${process.pid}] observing '${path}' changed, will restart!`);
86
- restart();
87
- })
88
- .on('error', function (error) {
89
- console.error('watchSelf error:', error);
90
- });
91
- }
92
-
93
- if (isDaemonMode) {
94
- //默认将log重定向到文件,不然在restart后会丢失
95
- let logFile = pr(`.cache/app${runInWindows ? '.win' : ''}.log`);
96
- if (!fs.existsSync(path.dirname(logFile))) fs.mkdirSync(path.dirname(logFile));
97
- let oldWrite = process.stdout.write.bind(process.stdout);
98
- var access = fs.createWriteStream(logFile, { flags: 'a' });
99
- if (!process.env['PXW_NOREDIRECT_LOG']) {
100
- process.stdout.write = process.stderr.write = access.write.bind(access);
101
- }
102
-
103
- let checkBinString = 'pxw/bin/pxw.js';
104
- let checkCmd =
105
- process.platform == 'win32' //
106
- ? 'wmic /OUTPUT:STDOUT process get processid,commandline'
107
- : `ps -ef|grep "node"|grep "${checkBinString.replace(/(.)/, '[$1]')}"`; //第一个字符包在[]里可以避免grep命令自身出现在结果里
108
-
109
- console.log(`\n*** pxw run: ${new Date().toLocaleString()} ***\npid[${process.pid}] check singleton:`, checkCmd);
110
- cp.exec(checkCmd, { windowsHide: true, maxBuffer: 1024 * 1024 * 10 }, (error, stdout, stderr) => {
111
- if (error) {
112
- console.log('pgrep error', error);
113
- // return;
114
- }
115
-
116
- let cpid = process.pid.toString();
117
- if (process.platform == 'win32') {
118
- let psl = stdout.trim().split('\n');
119
- // console.log(psl.splice(300));
120
-
121
- for (let cmd of psl) {
122
- cmd = cmd.replace(/\\/g, '/');
123
- if ((cmd.indexOf('/node.exe') > 0 || cmd.indexOf('node') == 0) && cmd.indexOf(checkBinString) > 0) {
124
- let info = cmd.trim().replace(/\s+/g, ' ').split(' ');
125
- console.log('find', info, process.pid);
126
- let tpid = info[info.length - 1];
127
- let isSelf = tpid == cpid;
128
- console.log(`tpid[${tpid}],isSelf:${isSelf}`);
129
- if (!isSelf) {
130
- if (argv.me) {
131
- cp.execSync('taskkill /F /PID ' + tpid);
132
- } else {
133
- return;
134
- }
135
- }
136
- }
137
- }
138
- } else {
139
- console.log('pgrep stdout\n', stdout);
140
- let lines = stdout.trim().split('\n');
141
- for (let line of lines) {
142
- line = line
143
- .trim()
144
- .split(' ')
145
- .filter((x) => !!x);
146
- // console.log(line);
147
- if (line.length > 5) {
148
- let tpid = line[1];
149
- let isSelf = tpid == cpid;
150
- console.log(`tpid[${tpid}],isSelf:${isSelf}`);
151
- if (tpid && !isSelf) {
152
- console.log(`found exist process:[${tpid}], cur[${process.pid}]`);
153
- if ((argv.me || argv.kill) && !error) {
154
- console.log(`force kill other process:[${tpid}]`);
155
- try {
156
- process.stdout.write('', () => {
157
- cp.execSync('kill ' + tpid);
158
- });
159
- } catch (e) {
160
- console.log(e);
161
- }
162
- } else {
163
- // cp.execSync('ps -ef|grep test/html/app.js', { stdio: 'inherit' });
164
- // cp.execSync(`ps -ef|grep ${stdout}`, { stdio: 'inherit' });
165
- return console.log('process already exist, pid:', tpid);
166
- }
167
- }
168
- }
169
- }
170
- }
171
- if (argv.kill) return;
172
-
173
- if (argv.fg || process.env.restart) {
174
- if (argv.fg) {
175
- oldWrite(`pid[${process.pid}] run in fg,log已重定向到 ${logFile} \n`);
176
- } else {
177
- let rc = parseInt(process.env.restart);
178
- process.env.restart = rc + 1;
179
- console.log(`pid[${process.pid}] run in restart: ${rc}`);
180
- }
181
- main();
182
- watchSelf();
183
- } else {
184
- console.log(`pid[${process.pid}] run in bg`);
185
- oldWrite('pxtest-admin 默认后台运行,加--fg参数可前台运行,log已重定向到' + logFile + '\n');
186
- process.env.restart = 1;
187
- restart();
188
- }
189
- });
190
- } else {
191
- main();
192
- }
1
+ #!/usr/bin/env node
2
+ let fs = require('fs');
3
+ let cp = require('child_process');
4
+ let path = require('path');
5
+ let http = require('http');
6
+ let os = require('os');
7
+ let util = require('../config/util');
8
+ let pfbs = require('../config/pfbs');
9
+ let webpack = require('../config/webpack');
10
+ let argv = require('yargs').argv;
11
+
12
+ let runInWindows = process.platform == 'win32';
13
+ let pr = path.resolve;
14
+ let log = console.log;
15
+ log = () => {};
16
+
17
+ let rootDir = pr(__dirname, '../');
18
+ let testHtmlDir = pr(__dirname, '../pxtest/html');
19
+ let projectConfig = util.loadProjectConfig();
20
+ let appPort = parseInt(process.env['PXW_APP_PORT']) || projectConfig.port || 8001;
21
+
22
+ let isDaemonMode = argv.d;
23
+
24
+ process
25
+ .on('unhandledRejection', (err) => {
26
+ console.log('unhandledRejection', err);
27
+ })
28
+ .on('uncaughtException', (err) => {
29
+ console.log('uncaughtException', err);
30
+ });
31
+
32
+ async function main() {
33
+ let fetch = require('node-fetch');
34
+ let express = require('express');
35
+ let serveIndex = require('serve-index');
36
+
37
+ let app = express();
38
+ let server = http.createServer(app);
39
+
40
+ let { notifyAppReload } = await require('../config/devops').setupDevops(server, app);
41
+
42
+ app.use(express.json());
43
+ app.use(pfbs.getMiddleware());
44
+ app.use(webpack.devServer.getMiddleware()(appPort, notifyAppReload));
45
+ app.use('/pxtest', serveIndex(testHtmlDir), express.static(testHtmlDir));
46
+
47
+ app.use(function (err, req, res, next) {
48
+ console.error(err);
49
+ res.status(500).send('Internal Serverless Error');
50
+ });
51
+
52
+ server.listen(appPort, '0.0.0.0', () => {
53
+ let ipList = [];
54
+ util.getLocalIP().forEach((ip) => {
55
+ console.log(`Server start on http://${ip}:${appPort}`);
56
+ });
57
+ });
58
+ }
59
+
60
+ //以下处理自动重启和单例
61
+ function restart() {
62
+ const scriptPath = process.argv[1];
63
+ let removeArgs = { '--fg': 1 };
64
+ let args = process.argv.slice(2);
65
+ args = args.filter((v) => !removeArgs[v]);
66
+ const subprocess = cp.spawn(process.execPath, [scriptPath, ...args], {
67
+ detached: true,
68
+ windowsHide: true,
69
+ });
70
+ subprocess.unref();
71
+ process.exit();
72
+ }
73
+
74
+ function watchSelf() {
75
+ //可以通过环境变量设置是否要监视重启
76
+ let restartWatchFile = process.env['PXW_WATCHFILE'];
77
+ if (restartWatchFile == 'none') return;
78
+ if (!restartWatchFile) restartWatchFile = __filename;
79
+ restartWatchFile = pr(restartWatchFile);
80
+ console.log('watchfile:', restartWatchFile);
81
+ let chokidar = require('chokidar');
82
+ let watcher = chokidar.watch(restartWatchFile, { ignored: /^\./, persistent: true });
83
+ watcher
84
+ .on('change', function (path) {
85
+ console.log(`pid[${process.pid}] observing '${path}' changed, will restart!`);
86
+ restart();
87
+ })
88
+ .on('error', function (error) {
89
+ console.error('watchSelf error:', error);
90
+ });
91
+ }
92
+
93
+ if (isDaemonMode) {
94
+ //默认将log重定向到文件,不然在restart后会丢失
95
+ let logFile = pr(`.cache/app${runInWindows ? '.win' : ''}.log`);
96
+ if (!fs.existsSync(path.dirname(logFile))) fs.mkdirSync(path.dirname(logFile));
97
+ let oldWrite = process.stdout.write.bind(process.stdout);
98
+ var access = fs.createWriteStream(logFile, { flags: 'a' });
99
+ if (!process.env['PXW_NOREDIRECT_LOG']) {
100
+ process.stdout.write = process.stderr.write = access.write.bind(access);
101
+ }
102
+
103
+ let checkBinString = 'pxw/bin/pxw.js';
104
+ let checkCmd =
105
+ process.platform == 'win32' //
106
+ ? 'wmic /OUTPUT:STDOUT process get processid,commandline'
107
+ : `ps -ef|grep "node"|grep "${checkBinString.replace(/(.)/, '[$1]')}"`; //第一个字符包在[]里可以避免grep命令自身出现在结果里
108
+
109
+ console.log(`\n*** pxw run: ${new Date().toLocaleString()} ***\npid[${process.pid}] check singleton:`, checkCmd);
110
+ cp.exec(checkCmd, { windowsHide: true, maxBuffer: 1024 * 1024 * 10 }, (error, stdout, stderr) => {
111
+ if (error) {
112
+ console.log('pgrep error', error);
113
+ // return;
114
+ }
115
+
116
+ let cpid = process.pid.toString();
117
+ if (process.platform == 'win32') {
118
+ let psl = stdout.trim().split('\n');
119
+ // console.log(psl.splice(300));
120
+
121
+ for (let cmd of psl) {
122
+ cmd = cmd.replace(/\\/g, '/');
123
+ if ((cmd.indexOf('/node.exe') > 0 || cmd.indexOf('node') == 0) && cmd.indexOf(checkBinString) > 0) {
124
+ let info = cmd.trim().replace(/\s+/g, ' ').split(' ');
125
+ console.log('find', info, process.pid);
126
+ let tpid = info[info.length - 1];
127
+ let isSelf = tpid == cpid;
128
+ console.log(`tpid[${tpid}],isSelf:${isSelf}`);
129
+ if (!isSelf) {
130
+ if (argv.me) {
131
+ cp.execSync('taskkill /F /PID ' + tpid);
132
+ } else {
133
+ return;
134
+ }
135
+ }
136
+ }
137
+ }
138
+ } else {
139
+ console.log('pgrep stdout\n', stdout);
140
+ let lines = stdout.trim().split('\n');
141
+ for (let line of lines) {
142
+ line = line
143
+ .trim()
144
+ .split(' ')
145
+ .filter((x) => !!x);
146
+ // console.log(line);
147
+ if (line.length > 5) {
148
+ let tpid = line[1];
149
+ let isSelf = tpid == cpid;
150
+ console.log(`tpid[${tpid}],isSelf:${isSelf}`);
151
+ if (tpid && !isSelf) {
152
+ console.log(`found exist process:[${tpid}], cur[${process.pid}]`);
153
+ if ((argv.me || argv.kill) && !error) {
154
+ console.log(`force kill other process:[${tpid}]`);
155
+ try {
156
+ process.stdout.write('', () => {
157
+ cp.execSync('kill ' + tpid);
158
+ });
159
+ } catch (e) {
160
+ console.log(e);
161
+ }
162
+ } else {
163
+ // cp.execSync('ps -ef|grep test/html/app.js', { stdio: 'inherit' });
164
+ // cp.execSync(`ps -ef|grep ${stdout}`, { stdio: 'inherit' });
165
+ return console.log('process already exist, pid:', tpid);
166
+ }
167
+ }
168
+ }
169
+ }
170
+ }
171
+ if (argv.kill) return;
172
+
173
+ if (argv.fg || process.env.restart) {
174
+ if (argv.fg) {
175
+ oldWrite(`pid[${process.pid}] run in fg,log已重定向到 ${logFile} \n`);
176
+ } else {
177
+ let rc = parseInt(process.env.restart);
178
+ process.env.restart = rc + 1;
179
+ console.log(`pid[${process.pid}] run in restart: ${rc}`);
180
+ }
181
+ main();
182
+ watchSelf();
183
+ } else {
184
+ console.log(`pid[${process.pid}] run in bg`);
185
+ oldWrite('pxtest-admin 默认后台运行,加--fg参数可前台运行,log已重定向到' + logFile + '\n');
186
+ process.env.restart = 1;
187
+ restart();
188
+ }
189
+ });
190
+ } else {
191
+ main();
192
+ }
package/bin/wpbuild.js CHANGED
@@ -1,10 +1,10 @@
1
- const webpack = require('webpack');
2
-
3
- let config = require('../config/webpack');
4
- webpack(config, (err, stats) => {
5
- if (err || stats.hasErrors()) {
6
- console.log(err);
7
- return;
8
- }
9
- console.log('done');
10
- });
1
+ const webpack = require('webpack');
2
+
3
+ let config = require('../config/webpack');
4
+ webpack(config, (err, stats) => {
5
+ if (err || stats.hasErrors()) {
6
+ console.log(err);
7
+ return;
8
+ }
9
+ console.log('done');
10
+ });
@@ -1,21 +1,21 @@
1
- server {
2
-
3
- listen 80;
4
- server_name localhost;
5
-
6
- location / {
7
- rewrite ^/$ /web/home/;
8
- rewrite ^/home/(.*)$ /web/home/$1;
9
- rewrite ^/static/media/(.*)$ /web/static/media/$1;
10
-
11
- root /usr/share/nginx/html;
12
- index index.html index.htm;
13
- }
14
-
15
-
16
- error_page 500 502 503 504 /50x.html;
17
- location = /50x.html {
18
- root /usr/share/nginx/html;
19
- }
20
-
1
+ server {
2
+
3
+ listen 80;
4
+ server_name localhost;
5
+
6
+ location / {
7
+ rewrite ^/$ /web/home/;
8
+ rewrite ^/home/(.*)$ /web/home/$1;
9
+ rewrite ^/static/media/(.*)$ /web/static/media/$1;
10
+
11
+ root /usr/share/nginx/html;
12
+ index index.html index.htm;
13
+ }
14
+
15
+
16
+ error_page 500 502 503 504 /50x.html;
17
+ location = /50x.html {
18
+ root /usr/share/nginx/html;
19
+ }
20
+
21
21
  }