wapplr 1.0.61 → 1.0.62
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/dist/client/app.js +7 -3
- package/dist/client/middlewares.js +76 -22
- package/dist/common/middlewares.js +10 -2
- package/package.json +2 -2
package/dist/client/app.js
CHANGED
|
@@ -270,11 +270,11 @@ function createApp() {
|
|
|
270
270
|
return res;
|
|
271
271
|
};
|
|
272
272
|
|
|
273
|
-
res.send = res.send || function (html) {
|
|
274
|
-
res.end(html);
|
|
273
|
+
res.send = res.send || function (html, callback) {
|
|
274
|
+
res.end(html, callback);
|
|
275
275
|
};
|
|
276
276
|
|
|
277
|
-
res.end = res.end || function (html) {
|
|
277
|
+
res.end = res.end || function (html, callback) {
|
|
278
278
|
if (!res.headersSent) {
|
|
279
279
|
Object.defineProperty(res, "headersSent", (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, _utils.defaultDescriptor), {}, {
|
|
280
280
|
enumerable: false,
|
|
@@ -305,6 +305,10 @@ function createApp() {
|
|
|
305
305
|
}
|
|
306
306
|
} else {//throw Error
|
|
307
307
|
}
|
|
308
|
+
|
|
309
|
+
if (callback) {
|
|
310
|
+
callback();
|
|
311
|
+
}
|
|
308
312
|
}; // res.container (Html element) property are plus thing, usually there is not in the response
|
|
309
313
|
// but is necessary for end render
|
|
310
314
|
|
|
@@ -70,39 +70,93 @@ function createRenderMiddleware() {
|
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
function _defaultHandle() {
|
|
73
|
-
_defaultHandle = (0, _asyncToGenerator2["default"])( /*#__PURE__*/(0, _regeneratorRuntime2["default"])().mark(function
|
|
74
|
-
var
|
|
75
|
-
|
|
73
|
+
_defaultHandle = (0, _asyncToGenerator2["default"])( /*#__PURE__*/(0, _regeneratorRuntime2["default"])().mark(function _callee4(req, res, out) {
|
|
74
|
+
var renderMiddlewares, index, next, _next;
|
|
75
|
+
|
|
76
|
+
return (0, _regeneratorRuntime2["default"])().wrap(function _callee4$(_context4) {
|
|
76
77
|
while (1) {
|
|
77
|
-
switch (
|
|
78
|
+
switch (_context4.prev = _context4.next) {
|
|
78
79
|
case 0:
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
var func
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
80
|
+
_next = function _next3() {
|
|
81
|
+
_next = (0, _asyncToGenerator2["default"])( /*#__PURE__*/(0, _regeneratorRuntime2["default"])().mark(function _callee3(err) {
|
|
82
|
+
var func;
|
|
83
|
+
return (0, _regeneratorRuntime2["default"])().wrap(function _callee3$(_context3) {
|
|
84
|
+
while (1) {
|
|
85
|
+
switch (_context3.prev = _context3.next) {
|
|
86
|
+
case 0:
|
|
87
|
+
if (!renderMiddlewares[index]) {
|
|
88
|
+
_context3.next = 8;
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
func = renderMiddlewares[index];
|
|
93
|
+
index = index + 1;
|
|
94
|
+
_context3.next = 5;
|
|
95
|
+
return func(req, res, err ? /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/(0, _regeneratorRuntime2["default"])().mark(function _callee2() {
|
|
96
|
+
return (0, _regeneratorRuntime2["default"])().wrap(function _callee2$(_context2) {
|
|
97
|
+
while (1) {
|
|
98
|
+
switch (_context2.prev = _context2.next) {
|
|
99
|
+
case 0:
|
|
100
|
+
_context2.next = 2;
|
|
101
|
+
return next(err);
|
|
102
|
+
|
|
103
|
+
case 2:
|
|
104
|
+
case "end":
|
|
105
|
+
return _context2.stop();
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}, _callee2);
|
|
109
|
+
})) : next);
|
|
110
|
+
|
|
111
|
+
case 5:
|
|
112
|
+
return _context3.abrupt("return", _context3.sent);
|
|
113
|
+
|
|
114
|
+
case 8:
|
|
115
|
+
if (!(typeof out === "function")) {
|
|
116
|
+
_context3.next = 13;
|
|
117
|
+
break;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
index = 0;
|
|
121
|
+
_context3.next = 12;
|
|
122
|
+
return out(err);
|
|
123
|
+
|
|
124
|
+
case 12:
|
|
125
|
+
return _context3.abrupt("return", _context3.sent);
|
|
126
|
+
|
|
127
|
+
case 13:
|
|
128
|
+
return _context3.abrupt("return", null);
|
|
129
|
+
|
|
130
|
+
case 14:
|
|
131
|
+
case "end":
|
|
132
|
+
return _context3.stop();
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}, _callee3);
|
|
136
|
+
}));
|
|
137
|
+
return _next.apply(this, arguments);
|
|
92
138
|
};
|
|
93
139
|
|
|
94
|
-
|
|
140
|
+
next = function _next2(_x7) {
|
|
141
|
+
return _next.apply(this, arguments);
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
renderMiddlewares = Object.keys(renderMiddleware.handles).map(function (key) {
|
|
95
145
|
return renderMiddleware.handles[key];
|
|
96
146
|
});
|
|
97
147
|
index = 0;
|
|
98
|
-
|
|
148
|
+
_context4.next = 6;
|
|
149
|
+
return next();
|
|
150
|
+
|
|
151
|
+
case 6:
|
|
152
|
+
return _context4.abrupt("return", _context4.sent);
|
|
99
153
|
|
|
100
|
-
case
|
|
154
|
+
case 7:
|
|
101
155
|
case "end":
|
|
102
|
-
return
|
|
156
|
+
return _context4.stop();
|
|
103
157
|
}
|
|
104
158
|
}
|
|
105
|
-
},
|
|
159
|
+
}, _callee4);
|
|
106
160
|
}));
|
|
107
161
|
return _defaultHandle.apply(this, arguments);
|
|
108
162
|
}
|
|
@@ -215,8 +215,16 @@ function createWappMiddleware() {
|
|
|
215
215
|
var _wappResponse$sendDat;
|
|
216
216
|
|
|
217
217
|
var endHtml = ((_wappResponse$sendDat = wappResponse.sendData) === null || _wappResponse$sendDat === void 0 ? void 0 : _wappResponse$sendDat.data) || "";
|
|
218
|
-
|
|
219
|
-
|
|
218
|
+
var callback = restAttr[0];
|
|
219
|
+
|
|
220
|
+
if (typeof callback === 'function') {
|
|
221
|
+
res.send.apply(res, [endHtml, function () {
|
|
222
|
+
callback();
|
|
223
|
+
wappResponse.sended = true;
|
|
224
|
+
}].concat((0, _toConsumableArray2["default"])(restAttr.slice(1))));
|
|
225
|
+
} else {
|
|
226
|
+
res.send.apply(res, [endHtml].concat((0, _toConsumableArray2["default"])(restAttr)));
|
|
227
|
+
}
|
|
220
228
|
});
|
|
221
229
|
}
|
|
222
230
|
};
|
package/package.json
CHANGED