k99 0.2.0 → 0.3.0-beta.1
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/LICENSE +1 -1
- package/README.md +8 -0
- package/README.zh.md +8 -0
- package/browser/package.json +8 -0
- package/browser/types.d.ts +20 -0
- package/cli/command/create.js +1 -2
- package/cli/command/index.js +1 -2
- package/cli/command/init.js +3 -5
- package/cli/command/start.js +9 -10
- package/cli/index.js +3 -4
- package/cli/opt/bind.js +1 -2
- package/cli/opt/index.js +1 -2
- package/cli/opt/listen.js +1 -2
- package/cli/opt/path.js +1 -2
- package/cli/opt/port.js +1 -2
- package/cli/opt/show-router.js +1 -2
- package/dist/k99.browser.js +3110 -0
- package/dist/k99.browser.min.js +6 -0
- package/dist/k99.esm.js +3082 -0
- package/dist/k99.esm.min.js +6 -0
- package/dist/k99.js +3104 -0
- package/dist/k99.mjs +3082 -0
- package/dist/k99Browser.browser.js +490 -0
- package/dist/k99Browser.browser.min.js +6 -0
- package/dist/k99Browser.esm.js +475 -0
- package/dist/k99Browser.esm.min.js +6 -0
- package/dist/k99Browser.js +484 -0
- package/dist/k99Browser.mjs +475 -0
- package/dist/k99Services.browser.js +145 -0
- package/dist/k99Services.browser.min.js +6 -0
- package/dist/k99Services.esm.js +136 -0
- package/dist/k99Services.esm.min.js +6 -0
- package/dist/k99Services.js +141 -0
- package/dist/k99Services.mjs +136 -0
- package/node/index.js +1386 -0
- package/node/index.mjs +1350 -0
- package/node/package.json +5 -0
- package/node/types.d.ts +166 -0
- package/package.json +77 -11
- package/services/package.json +8 -0
- package/services/types.d.ts +22 -0
- package/starter.js +0 -1
- package/types.d.ts +748 -0
- package/Container.d.ts +0 -92
- package/Container.js +0 -242
- package/Container.js.map +0 -1
- package/Controller/index.d.ts +0 -178
- package/Controller/index.js +0 -576
- package/Controller/index.js.map +0 -1
- package/Controller/patch/cookie.d.ts +0 -33
- package/Controller/patch/cookie.js +0 -168
- package/Controller/patch/cookie.js.map +0 -1
- package/Controller/patch/index.d.ts +0 -7
- package/Controller/patch/index.js +0 -26
- package/Controller/patch/index.js.map +0 -1
- package/Controller/patch/render.d.ts +0 -5
- package/Controller/patch/render.js +0 -24
- package/Controller/patch/render.js.map +0 -1
- package/ExitSignal.d.ts +0 -14
- package/ExitSignal.js +0 -29
- package/ExitSignal.js.map +0 -1
- package/Extension.d.ts +0 -56
- package/Extension.js +0 -93
- package/Extension.js.map +0 -1
- package/ExtensionContainer.d.ts +0 -55
- package/ExtensionContainer.js +0 -105
- package/ExtensionContainer.js.map +0 -1
- package/Plugin.d.ts +0 -52
- package/Plugin.js +0 -278
- package/Plugin.js.map +0 -1
- package/Preprocessor.d.ts +0 -86
- package/Preprocessor.js +0 -135
- package/Preprocessor.js.map +0 -1
- package/Router/assets.d.ts +0 -33
- package/Router/assets.js +0 -106
- package/Router/assets.js.map +0 -1
- package/Router/callback.d.ts +0 -9
- package/Router/callback.js +0 -152
- package/Router/callback.js.map +0 -1
- package/Router/extendsInterface.d.ts +0 -8
- package/Router/extendsInterface.js +0 -43
- package/Router/extendsInterface.js.map +0 -1
- package/Router/index.d.ts +0 -184
- package/Router/index.js +0 -615
- package/Router/index.js.map +0 -1
- package/Router/log.d.ts +0 -23
- package/Router/log.js +0 -120
- package/Router/log.js.map +0 -1
- package/Router/order.d.ts +0 -14
- package/Router/order.js +0 -71
- package/Router/order.js.map +0 -1
- package/Router/register.d.ts +0 -9
- package/Router/register.js +0 -252
- package/Router/register.js.map +0 -1
- package/Router/registerManager.d.ts +0 -22
- package/Router/registerManager.js +0 -102
- package/Router/registerManager.js.map +0 -1
- package/Router/scan.d.ts +0 -2
- package/Router/scan.js +0 -72
- package/Router/scan.js.map +0 -1
- package/Router/setHandleItem.d.ts +0 -3
- package/Router/setHandleItem.js +0 -94
- package/Router/setHandleItem.js.map +0 -1
- package/Router/settings.d.ts +0 -12
- package/Router/settings.js +0 -74
- package/Router/settings.js.map +0 -1
- package/Router/start.d.ts +0 -3
- package/Router/start.js +0 -270
- package/Router/start.js.map +0 -1
- package/Router/vars.d.ts +0 -10
- package/Router/vars.js +0 -40
- package/Router/vars.js.map +0 -1
- package/Service.d.ts +0 -12
- package/Service.js +0 -20
- package/Service.js.map +0 -1
- package/cli/command/create.d.ts +0 -7
- package/cli/command/create.js.map +0 -1
- package/cli/command/index.d.ts +0 -7
- package/cli/command/index.js.map +0 -1
- package/cli/command/init.d.ts +0 -6
- package/cli/command/init.js.map +0 -1
- package/cli/command/start.d.ts +0 -6
- package/cli/command/start.js.map +0 -1
- package/cli/index.d.ts +0 -2
- package/cli/index.js.map +0 -1
- package/cli/opt/bind.d.ts +0 -3
- package/cli/opt/bind.js.map +0 -1
- package/cli/opt/index.d.ts +0 -16
- package/cli/opt/index.js.map +0 -1
- package/cli/opt/listen.d.ts +0 -3
- package/cli/opt/listen.js.map +0 -1
- package/cli/opt/path.d.ts +0 -3
- package/cli/opt/path.js.map +0 -1
- package/cli/opt/port.d.ts +0 -3
- package/cli/opt/port.js.map +0 -1
- package/cli/opt/show-router.d.ts +0 -3
- package/cli/opt/show-router.js.map +0 -1
- package/index.d.ts +0 -354
- package/index.js +0 -155
- package/index.js.map +0 -1
- package/setOptions.d.ts +0 -12
- package/setOptions.js +0 -60
- package/setOptions.js.map +0 -1
- package/starter.d.ts +0 -2
- package/starter.js.map +0 -1
- package/symbols.d.ts +0 -13
- package/symbols.js +0 -31
- package/symbols.js.map +0 -1
- package/util/index.d.ts +0 -5
- package/util/index.js +0 -92
- package/util/index.js.map +0 -1
- package/util/stream.d.ts +0 -19
- package/util/stream.js +0 -66
- package/util/stream.js.map +0 -1
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* k99 v0.3.0-beta.1
|
|
3
|
+
* (c) 2019-2022 Fierflame
|
|
4
|
+
* @license MIT
|
|
5
|
+
*/
|
|
6
|
+
import { Service } from 'k99';
|
|
7
|
+
|
|
8
|
+
async function readText(read) {
|
|
9
|
+
const text = [];
|
|
10
|
+
|
|
11
|
+
for (;;) {
|
|
12
|
+
const t = await read(0, true);
|
|
13
|
+
|
|
14
|
+
if (t === null) {
|
|
15
|
+
break;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
text.push(t);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return text.join('');
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function getNameValue(s) {
|
|
25
|
+
const index = s.indexOf('=');
|
|
26
|
+
|
|
27
|
+
if (index < 0) {
|
|
28
|
+
return [decodeURIComponent(s), ''];
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return [decodeURIComponent(s.substring(0, index)), decodeURIComponent(s.substring(index + 1))];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function parseQuery(s) {
|
|
35
|
+
const query = {};
|
|
36
|
+
|
|
37
|
+
for (const k of s.split('&').filter(Boolean)) {
|
|
38
|
+
const [index, value] = getNameValue(k);
|
|
39
|
+
|
|
40
|
+
if (index in query) {
|
|
41
|
+
query[index] = [query[index], value].flat();
|
|
42
|
+
} else {
|
|
43
|
+
query[index] = [value];
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return query;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
class FormBodyService extends Service {
|
|
51
|
+
export() {
|
|
52
|
+
const res = this.__result;
|
|
53
|
+
|
|
54
|
+
if (res !== undefined) {
|
|
55
|
+
return res;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const result = this.exec();
|
|
59
|
+
this.__result = result;
|
|
60
|
+
return result;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
async parse() {
|
|
64
|
+
try {
|
|
65
|
+
let data = await readText(this.read);
|
|
66
|
+
|
|
67
|
+
if (!data.length) {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return parseQuery(data);
|
|
72
|
+
} catch {}
|
|
73
|
+
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
exec() {
|
|
78
|
+
const [mime, charset] = this.requestType.replace(/\s/g, '').split(';');
|
|
79
|
+
|
|
80
|
+
if (mime !== 'application/x-www-form-urlencoded') {
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (charset && charset !== 'charset=UTF-8') {
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return this.parse();
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
class JsonBodyService extends Service {
|
|
94
|
+
export() {
|
|
95
|
+
const res = this.__result;
|
|
96
|
+
|
|
97
|
+
if (res !== undefined) {
|
|
98
|
+
return res;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const result = this.exec();
|
|
102
|
+
this.__result = result;
|
|
103
|
+
return result;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
async parse() {
|
|
107
|
+
try {
|
|
108
|
+
let data = await readText(this.read);
|
|
109
|
+
|
|
110
|
+
if (!data.length) {
|
|
111
|
+
return null;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return JSON.parse(data);
|
|
115
|
+
} catch {}
|
|
116
|
+
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
exec() {
|
|
121
|
+
const [mime, charset] = this.requestType.replace(/\s/g, '').split(';');
|
|
122
|
+
|
|
123
|
+
if (mime !== 'application/json' && mime !== 'text/json') {
|
|
124
|
+
return null;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
if (charset && charset !== 'charset=UTF-8') {
|
|
128
|
+
return null;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
return this.parse();
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export { FormBodyService, JsonBodyService };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* k99 v0.3.0-beta.1
|
|
3
|
+
* (c) 2019-2022 Fierflame
|
|
4
|
+
* @license MIT
|
|
5
|
+
*/
|
|
6
|
+
import{Service as t}from"k99";async function e(t){const e=[];for(;;){const n=await t(0,!0);if(null===n)break;e.push(n)}return e.join("")}function n(t){const e=t.indexOf("=");return e<0?[decodeURIComponent(t),""]:[decodeURIComponent(t.substring(0,e)),decodeURIComponent(t.substring(e+1))]}class r extends t{export(){const t=this.__result;if(void 0!==t)return t;const e=this.exec();return this.__result=e,e}async parse(){try{let t=await e(this.read);return t.length?function(t){const e={};for(const r of t.split("&").filter(Boolean)){const[t,s]=n(r);e[t]=t in e?[e[t],s].flat():[s]}return e}(t):null}catch{}return null}exec(){const[t,e]=this.requestType.replace(/\s/g,"").split(";");return"application/x-www-form-urlencoded"!==t||e&&"charset=UTF-8"!==e?null:this.parse()}}class s extends t{export(){const t=this.__result;if(void 0!==t)return t;const e=this.exec();return this.__result=e,e}async parse(){try{let t=await e(this.read);return t.length?JSON.parse(t):null}catch{}return null}exec(){const[t,e]=this.requestType.replace(/\s/g,"").split(";");return"application/json"!==t&&"text/json"!==t||e&&"charset=UTF-8"!==e?null:this.parse()}}export{r as FormBodyService,s as JsonBodyService};
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* k99 v0.3.0-beta.1
|
|
3
|
+
* (c) 2019-2022 Fierflame
|
|
4
|
+
* @license MIT
|
|
5
|
+
*/
|
|
6
|
+
'use strict';
|
|
7
|
+
|
|
8
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
9
|
+
|
|
10
|
+
var k99 = require('k99');
|
|
11
|
+
|
|
12
|
+
async function readText(read) {
|
|
13
|
+
const text = [];
|
|
14
|
+
|
|
15
|
+
for (;;) {
|
|
16
|
+
const t = await read(0, true);
|
|
17
|
+
|
|
18
|
+
if (t === null) {
|
|
19
|
+
break;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
text.push(t);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return text.join('');
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function getNameValue(s) {
|
|
29
|
+
const index = s.indexOf('=');
|
|
30
|
+
|
|
31
|
+
if (index < 0) {
|
|
32
|
+
return [decodeURIComponent(s), ''];
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return [decodeURIComponent(s.substring(0, index)), decodeURIComponent(s.substring(index + 1))];
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function parseQuery(s) {
|
|
39
|
+
const query = {};
|
|
40
|
+
|
|
41
|
+
for (const k of s.split('&').filter(Boolean)) {
|
|
42
|
+
const [index, value] = getNameValue(k);
|
|
43
|
+
|
|
44
|
+
if (index in query) {
|
|
45
|
+
query[index] = [query[index], value].flat();
|
|
46
|
+
} else {
|
|
47
|
+
query[index] = [value];
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return query;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
class FormBodyService extends k99.Service {
|
|
55
|
+
export() {
|
|
56
|
+
const res = this.__result;
|
|
57
|
+
|
|
58
|
+
if (res !== undefined) {
|
|
59
|
+
return res;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const result = this.exec();
|
|
63
|
+
this.__result = result;
|
|
64
|
+
return result;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
async parse() {
|
|
68
|
+
try {
|
|
69
|
+
let data = await readText(this.read);
|
|
70
|
+
|
|
71
|
+
if (!data.length) {
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return parseQuery(data);
|
|
76
|
+
} catch {}
|
|
77
|
+
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
exec() {
|
|
82
|
+
const [mime, charset] = this.requestType.replace(/\s/g, '').split(';');
|
|
83
|
+
|
|
84
|
+
if (mime !== 'application/x-www-form-urlencoded') {
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (charset && charset !== 'charset=UTF-8') {
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return this.parse();
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
class JsonBodyService extends k99.Service {
|
|
98
|
+
export() {
|
|
99
|
+
const res = this.__result;
|
|
100
|
+
|
|
101
|
+
if (res !== undefined) {
|
|
102
|
+
return res;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const result = this.exec();
|
|
106
|
+
this.__result = result;
|
|
107
|
+
return result;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
async parse() {
|
|
111
|
+
try {
|
|
112
|
+
let data = await readText(this.read);
|
|
113
|
+
|
|
114
|
+
if (!data.length) {
|
|
115
|
+
return null;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return JSON.parse(data);
|
|
119
|
+
} catch {}
|
|
120
|
+
|
|
121
|
+
return null;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
exec() {
|
|
125
|
+
const [mime, charset] = this.requestType.replace(/\s/g, '').split(';');
|
|
126
|
+
|
|
127
|
+
if (mime !== 'application/json' && mime !== 'text/json') {
|
|
128
|
+
return null;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if (charset && charset !== 'charset=UTF-8') {
|
|
132
|
+
return null;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
return this.parse();
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
exports.FormBodyService = FormBodyService;
|
|
141
|
+
exports.JsonBodyService = JsonBodyService;
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* k99 v0.3.0-beta.1
|
|
3
|
+
* (c) 2019-2022 Fierflame
|
|
4
|
+
* @license MIT
|
|
5
|
+
*/
|
|
6
|
+
import { Service } from 'k99';
|
|
7
|
+
|
|
8
|
+
async function readText(read) {
|
|
9
|
+
const text = [];
|
|
10
|
+
|
|
11
|
+
for (;;) {
|
|
12
|
+
const t = await read(0, true);
|
|
13
|
+
|
|
14
|
+
if (t === null) {
|
|
15
|
+
break;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
text.push(t);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return text.join('');
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function getNameValue(s) {
|
|
25
|
+
const index = s.indexOf('=');
|
|
26
|
+
|
|
27
|
+
if (index < 0) {
|
|
28
|
+
return [decodeURIComponent(s), ''];
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return [decodeURIComponent(s.substring(0, index)), decodeURIComponent(s.substring(index + 1))];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function parseQuery(s) {
|
|
35
|
+
const query = {};
|
|
36
|
+
|
|
37
|
+
for (const k of s.split('&').filter(Boolean)) {
|
|
38
|
+
const [index, value] = getNameValue(k);
|
|
39
|
+
|
|
40
|
+
if (index in query) {
|
|
41
|
+
query[index] = [query[index], value].flat();
|
|
42
|
+
} else {
|
|
43
|
+
query[index] = [value];
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return query;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
class FormBodyService extends Service {
|
|
51
|
+
export() {
|
|
52
|
+
const res = this.__result;
|
|
53
|
+
|
|
54
|
+
if (res !== undefined) {
|
|
55
|
+
return res;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const result = this.exec();
|
|
59
|
+
this.__result = result;
|
|
60
|
+
return result;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
async parse() {
|
|
64
|
+
try {
|
|
65
|
+
let data = await readText(this.read);
|
|
66
|
+
|
|
67
|
+
if (!data.length) {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return parseQuery(data);
|
|
72
|
+
} catch {}
|
|
73
|
+
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
exec() {
|
|
78
|
+
const [mime, charset] = this.requestType.replace(/\s/g, '').split(';');
|
|
79
|
+
|
|
80
|
+
if (mime !== 'application/x-www-form-urlencoded') {
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (charset && charset !== 'charset=UTF-8') {
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return this.parse();
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
class JsonBodyService extends Service {
|
|
94
|
+
export() {
|
|
95
|
+
const res = this.__result;
|
|
96
|
+
|
|
97
|
+
if (res !== undefined) {
|
|
98
|
+
return res;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const result = this.exec();
|
|
102
|
+
this.__result = result;
|
|
103
|
+
return result;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
async parse() {
|
|
107
|
+
try {
|
|
108
|
+
let data = await readText(this.read);
|
|
109
|
+
|
|
110
|
+
if (!data.length) {
|
|
111
|
+
return null;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return JSON.parse(data);
|
|
115
|
+
} catch {}
|
|
116
|
+
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
exec() {
|
|
121
|
+
const [mime, charset] = this.requestType.replace(/\s/g, '').split(';');
|
|
122
|
+
|
|
123
|
+
if (mime !== 'application/json' && mime !== 'text/json') {
|
|
124
|
+
return null;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
if (charset && charset !== 'charset=UTF-8') {
|
|
128
|
+
return null;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
return this.parse();
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export { FormBodyService, JsonBodyService };
|