@jayfong/x-server 2.24.0 → 2.24.2

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.
@@ -74,7 +74,7 @@ class BuildUtil {
74
74
  sourcemap: false,
75
75
  treeShaking: true,
76
76
  banner: {
77
- js: `${`;${Object.keys(options.inlineEnvs || {}).map(key => `process.env[${JSON.stringify(key)}]=${JSON.stringify(options.inlineEnvs[key])}`).join(';')}`};process.env.X_SERVER_ENVS=${JSON.stringify(JSON.stringify(options.inlineEnvs || {}))};`
77
+ js: [...Object.keys(options.inlineEnvs || {}).map(key => `process.env[${JSON.stringify(key)}]=${JSON.stringify(options.inlineEnvs[key])};`), `process.env["X_SERVER_ENVS"]=${JSON.stringify(JSON.stringify(options.inlineEnvs || {}))};`].join('\n')
78
78
  },
79
79
  plugins: [{
80
80
  name: 'extract-assets',
@@ -25,7 +25,6 @@ _yargs.default.command('dev', '开始开发', _ => _.positional('index', {
25
25
  describe: '使用 tsx 运行',
26
26
  type: 'boolean'
27
27
  }).positional('env', {
28
- alias: 'e',
29
28
  describe: '环境变量文件',
30
29
  type: 'string',
31
30
  default: 'development'
@@ -94,7 +93,6 @@ _yargs.default.command('dev', '开始开发', _ => _.positional('index', {
94
93
  type: 'boolean',
95
94
  default: false
96
95
  }).positional('env', {
97
- alias: 'e',
98
96
  describe: '环境变量文件',
99
97
  type: 'string',
100
98
  default: 'production'
@@ -67,23 +67,28 @@ function defineSliceTask(options) {
67
67
  // 仅阈值
68
68
  // 满10条推送
69
69
  else if (threshold != null) {
70
- if (thresholdTimeout) {
71
- const delayTaskId = redisKey;
72
- await task.getJob(delayTaskId).then(job => job == null ? void 0 : job.remove());
70
+ const delayTaskId = redisKey;
71
+ const prevJob = await task.getJob(delayTaskId);
72
+
73
+ // 到达阈值,立即发送
74
+ if (count === threshold) {
75
+ await (prevJob == null ? void 0 : prevJob.remove());
73
76
  await task.add({
74
77
  key: key,
75
78
  redisKey: redisKey
76
- }, {
77
- jobId: delayTaskId,
78
- delay: thresholdTimeout
79
79
  });
80
80
  }
81
- if (count === threshold) {
82
- await task.add({
83
- key: key,
84
- redisKey: redisKey,
85
- count: threshold
86
- });
81
+ // 存在超时设置
82
+ else if (thresholdTimeout) {
83
+ if (!prevJob) {
84
+ await task.add({
85
+ key: key,
86
+ redisKey: redisKey
87
+ }, {
88
+ jobId: delayTaskId,
89
+ delay: thresholdTimeout
90
+ });
91
+ }
87
92
  }
88
93
  }
89
94
  }
@@ -68,7 +68,7 @@ export class BuildUtil {
68
68
  sourcemap: false,
69
69
  treeShaking: true,
70
70
  banner: {
71
- js: `${`;${Object.keys(options.inlineEnvs || {}).map(key => `process.env[${JSON.stringify(key)}]=${JSON.stringify(options.inlineEnvs[key])}`).join(';')}`};process.env.X_SERVER_ENVS=${JSON.stringify(JSON.stringify(options.inlineEnvs || {}))};`
71
+ js: [...Object.keys(options.inlineEnvs || {}).map(key => `process.env[${JSON.stringify(key)}]=${JSON.stringify(options.inlineEnvs[key])};`), `process.env["X_SERVER_ENVS"]=${JSON.stringify(JSON.stringify(options.inlineEnvs || {}))};`].join('\n')
72
72
  },
73
73
  plugins: [{
74
74
  name: 'extract-assets',
package/lib/cli/cli.js CHANGED
@@ -22,7 +22,6 @@ yargs.command('dev', '开始开发', _ => _.positional('index', {
22
22
  describe: '使用 tsx 运行',
23
23
  type: 'boolean'
24
24
  }).positional('env', {
25
- alias: 'e',
26
25
  describe: '环境变量文件',
27
26
  type: 'string',
28
27
  default: 'development'
@@ -91,7 +90,6 @@ yargs.command('dev', '开始开发', _ => _.positional('index', {
91
90
  type: 'boolean',
92
91
  default: false
93
92
  }).positional('env', {
94
- alias: 'e',
95
93
  describe: '环境变量文件',
96
94
  type: 'string',
97
95
  default: 'production'
@@ -61,23 +61,28 @@ export function defineSliceTask(options) {
61
61
  // 仅阈值
62
62
  // 满10条推送
63
63
  else if (threshold != null) {
64
- if (thresholdTimeout) {
65
- const delayTaskId = redisKey;
66
- await task.getJob(delayTaskId).then(job => job == null ? void 0 : job.remove());
64
+ const delayTaskId = redisKey;
65
+ const prevJob = await task.getJob(delayTaskId);
66
+
67
+ // 到达阈值,立即发送
68
+ if (count === threshold) {
69
+ await (prevJob == null ? void 0 : prevJob.remove());
67
70
  await task.add({
68
71
  key: key,
69
72
  redisKey: redisKey
70
- }, {
71
- jobId: delayTaskId,
72
- delay: thresholdTimeout
73
73
  });
74
74
  }
75
- if (count === threshold) {
76
- await task.add({
77
- key: key,
78
- redisKey: redisKey,
79
- count: threshold
80
- });
75
+ // 存在超时设置
76
+ else if (thresholdTimeout) {
77
+ if (!prevJob) {
78
+ await task.add({
79
+ key: key,
80
+ redisKey: redisKey
81
+ }, {
82
+ jobId: delayTaskId,
83
+ delay: thresholdTimeout
84
+ });
85
+ }
81
86
  }
82
87
  }
83
88
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jayfong/x-server",
3
- "version": "2.24.0",
3
+ "version": "2.24.2",
4
4
  "license": "ISC",
5
5
  "sideEffects": false,
6
6
  "main": "lib/_cjs/index.js",