@nocobase/plugin-field-sort 1.5.0-alpha.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.
Files changed (142) hide show
  1. package/LICENSE.txt +159 -0
  2. package/README.md +1 -0
  3. package/client.d.ts +2 -0
  4. package/client.js +1 -0
  5. package/dist/client/index.d.ts +15 -0
  6. package/dist/client/index.js +10 -0
  7. package/dist/client/locale.d.ts +10 -0
  8. package/dist/client/sort-interface.d.ts +131 -0
  9. package/dist/externalVersion.js +18 -0
  10. package/dist/index.d.ts +10 -0
  11. package/dist/index.js +48 -0
  12. package/dist/locale/en-US.json +1 -0
  13. package/dist/locale/zh-CN.json +1 -0
  14. package/dist/node_modules/@nocobase/lock-manager/LICENSE +661 -0
  15. package/dist/node_modules/@nocobase/lock-manager/lib/index.d.ts +10 -0
  16. package/dist/node_modules/@nocobase/lock-manager/lib/index.js +1 -0
  17. package/dist/node_modules/@nocobase/lock-manager/lib/lock-manager.d.ts +46 -0
  18. package/dist/node_modules/@nocobase/lock-manager/lib/lock-manager.js +171 -0
  19. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/client.js +12 -0
  20. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/assign.d.ts +17 -0
  21. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/assign.js +143 -0
  22. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/client.d.ts +30 -0
  23. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/client.js +88 -0
  24. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/collections-graph.d.ts +24 -0
  25. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/collections-graph.js +107 -0
  26. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/common.d.ts +14 -0
  27. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/common.js +87 -0
  28. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/date.d.ts +38 -0
  29. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/date.js +214 -0
  30. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/dayjs.d.ts +10 -0
  31. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/dayjs.js +72 -0
  32. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/forEach.d.ts +9 -0
  33. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/forEach.js +45 -0
  34. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/fs-exists.d.ts +9 -0
  35. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/fs-exists.js +46 -0
  36. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/getValuesByPath.d.ts +9 -0
  37. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/getValuesByPath.js +71 -0
  38. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/handlebars.d.ts +10 -0
  39. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/handlebars.js +73 -0
  40. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/i18n.d.ts +10 -0
  41. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/i18n.js +43 -0
  42. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/index.d.ts +38 -0
  43. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/index.js +105 -0
  44. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/isPortalInBody.d.ts +13 -0
  45. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/isPortalInBody.js +54 -0
  46. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/isValidFilter.d.ts +9 -0
  47. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/isValidFilter.js +63 -0
  48. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/json-templates.d.ts +9 -0
  49. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/json-templates.js +141 -0
  50. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/koa-multer.d.ts +15 -0
  51. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/koa-multer.js +92 -0
  52. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/log.d.ts +9 -0
  53. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/log.js +39 -0
  54. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/measure-execution-time.d.ts +9 -0
  55. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/measure-execution-time.js +44 -0
  56. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/merge.d.ts +9 -0
  57. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/merge.js +55 -0
  58. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/mixin/AsyncEmitter.d.ts +11 -0
  59. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/mixin/AsyncEmitter.js +80 -0
  60. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/mixin/index.d.ts +9 -0
  61. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/mixin/index.js +48 -0
  62. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/notification.d.ts +9 -0
  63. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/notification.js +43 -0
  64. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/number.d.ts +9 -0
  65. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/number.js +45 -0
  66. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/parse-date.d.ts +15 -0
  67. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/parse-date.js +262 -0
  68. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/parse-filter.d.ts +67 -0
  69. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/parse-filter.js +320 -0
  70. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/parseHTML.d.ts +15 -0
  71. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/parseHTML.js +42 -0
  72. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/perf-hooks.d.ts +14 -0
  73. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/perf-hooks.js +69 -0
  74. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/registry.d.ts +22 -0
  75. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/registry.js +69 -0
  76. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/requireModule.d.ts +12 -0
  77. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/requireModule.js +90 -0
  78. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/server.d.ts +19 -0
  79. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/server.js +50 -0
  80. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/toposort.d.ts +18 -0
  81. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/toposort.js +83 -0
  82. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/uid.d.ts +9 -0
  83. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/uid.js +44 -0
  84. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/url.d.ts +14 -0
  85. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/url.js +46 -0
  86. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/wrap-middleware.d.ts +1 -0
  87. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/wrap-middleware.js +63 -0
  88. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/package.json +20 -0
  89. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/plugin-symlink.d.ts +6 -0
  90. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/plugin-symlink.js +102 -0
  91. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/server.d.ts +2 -0
  92. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/server.js +12 -0
  93. package/dist/node_modules/@nocobase/lock-manager/node_modules/busboy/.eslintrc.js +5 -0
  94. package/dist/node_modules/@nocobase/lock-manager/node_modules/busboy/.github/workflows/ci.yml +24 -0
  95. package/dist/node_modules/@nocobase/lock-manager/node_modules/busboy/.github/workflows/lint.yml +23 -0
  96. package/dist/node_modules/@nocobase/lock-manager/node_modules/busboy/bench/bench-multipart-fields-100mb-big.js +149 -0
  97. package/dist/node_modules/@nocobase/lock-manager/node_modules/busboy/bench/bench-multipart-fields-100mb-small.js +143 -0
  98. package/dist/node_modules/@nocobase/lock-manager/node_modules/busboy/bench/bench-multipart-files-100mb-big.js +154 -0
  99. package/dist/node_modules/@nocobase/lock-manager/node_modules/busboy/bench/bench-multipart-files-100mb-small.js +148 -0
  100. package/dist/node_modules/@nocobase/lock-manager/node_modules/busboy/bench/bench-urlencoded-fields-100pairs-small.js +101 -0
  101. package/dist/node_modules/@nocobase/lock-manager/node_modules/busboy/bench/bench-urlencoded-fields-900pairs-small-alt.js +84 -0
  102. package/dist/node_modules/@nocobase/lock-manager/node_modules/busboy/lib/index.js +57 -0
  103. package/dist/node_modules/@nocobase/lock-manager/node_modules/busboy/lib/types/multipart.js +653 -0
  104. package/dist/node_modules/@nocobase/lock-manager/node_modules/busboy/lib/types/urlencoded.js +350 -0
  105. package/dist/node_modules/@nocobase/lock-manager/node_modules/busboy/lib/utils.js +596 -0
  106. package/dist/node_modules/@nocobase/lock-manager/node_modules/busboy/package.json +22 -0
  107. package/dist/node_modules/@nocobase/lock-manager/node_modules/busboy/test/common.js +109 -0
  108. package/dist/node_modules/@nocobase/lock-manager/node_modules/busboy/test/test-types-multipart-charsets.js +94 -0
  109. package/dist/node_modules/@nocobase/lock-manager/node_modules/busboy/test/test-types-multipart-stream-pause.js +102 -0
  110. package/dist/node_modules/@nocobase/lock-manager/node_modules/busboy/test/test-types-multipart.js +1053 -0
  111. package/dist/node_modules/@nocobase/lock-manager/node_modules/busboy/test/test-types-urlencoded.js +488 -0
  112. package/dist/node_modules/@nocobase/lock-manager/node_modules/busboy/test/test.js +20 -0
  113. package/dist/node_modules/@nocobase/lock-manager/node_modules/multer/index.js +104 -0
  114. package/dist/node_modules/@nocobase/lock-manager/node_modules/multer/lib/counter.js +28 -0
  115. package/dist/node_modules/@nocobase/lock-manager/node_modules/multer/lib/file-appender.js +67 -0
  116. package/dist/node_modules/@nocobase/lock-manager/node_modules/multer/lib/make-middleware.js +173 -0
  117. package/dist/node_modules/@nocobase/lock-manager/node_modules/multer/lib/multer-error.js +24 -0
  118. package/dist/node_modules/@nocobase/lock-manager/node_modules/multer/lib/remove-uploaded-files.js +28 -0
  119. package/dist/node_modules/@nocobase/lock-manager/node_modules/multer/package.json +52 -0
  120. package/dist/node_modules/@nocobase/lock-manager/node_modules/multer/storage/disk.js +66 -0
  121. package/dist/node_modules/@nocobase/lock-manager/node_modules/multer/storage/memory.js +21 -0
  122. package/dist/node_modules/@nocobase/lock-manager/node_modules/streamsearch/.eslintrc.js +5 -0
  123. package/dist/node_modules/@nocobase/lock-manager/node_modules/streamsearch/.github/workflows/ci.yml +24 -0
  124. package/dist/node_modules/@nocobase/lock-manager/node_modules/streamsearch/.github/workflows/lint.yml +23 -0
  125. package/dist/node_modules/@nocobase/lock-manager/node_modules/streamsearch/lib/sbmh.js +267 -0
  126. package/dist/node_modules/@nocobase/lock-manager/node_modules/streamsearch/package.json +34 -0
  127. package/dist/node_modules/@nocobase/lock-manager/node_modules/streamsearch/test/test.js +70 -0
  128. package/dist/node_modules/@nocobase/lock-manager/package.json +1 -0
  129. package/dist/node_modules/@nocobase/lock-manager/src/__tests__/lock-manager.test.ts +169 -0
  130. package/dist/node_modules/@nocobase/lock-manager/src/index.ts +11 -0
  131. package/dist/node_modules/@nocobase/lock-manager/src/lock-manager.ts +169 -0
  132. package/dist/server/action.d.ts +26 -0
  133. package/dist/server/action.js +168 -0
  134. package/dist/server/index.d.ts +10 -0
  135. package/dist/server/index.js +48 -0
  136. package/dist/server/plugin.d.ts +19 -0
  137. package/dist/server/plugin.js +69 -0
  138. package/dist/server/sort-field.d.ts +24 -0
  139. package/dist/server/sort-field.js +197 -0
  140. package/package.json +16 -0
  141. package/server.d.ts +2 -0
  142. package/server.js +1 -0
@@ -0,0 +1,596 @@
1
+ 'use strict';
2
+
3
+ function parseContentType(str) {
4
+ if (str.length === 0)
5
+ return;
6
+
7
+ const params = Object.create(null);
8
+ let i = 0;
9
+
10
+ // Parse type
11
+ for (; i < str.length; ++i) {
12
+ const code = str.charCodeAt(i);
13
+ if (TOKEN[code] !== 1) {
14
+ if (code !== 47/* '/' */ || i === 0)
15
+ return;
16
+ break;
17
+ }
18
+ }
19
+ // Check for type without subtype
20
+ if (i === str.length)
21
+ return;
22
+
23
+ const type = str.slice(0, i).toLowerCase();
24
+
25
+ // Parse subtype
26
+ const subtypeStart = ++i;
27
+ for (; i < str.length; ++i) {
28
+ const code = str.charCodeAt(i);
29
+ if (TOKEN[code] !== 1) {
30
+ // Make sure we have a subtype
31
+ if (i === subtypeStart)
32
+ return;
33
+
34
+ if (parseContentTypeParams(str, i, params) === undefined)
35
+ return;
36
+ break;
37
+ }
38
+ }
39
+ // Make sure we have a subtype
40
+ if (i === subtypeStart)
41
+ return;
42
+
43
+ const subtype = str.slice(subtypeStart, i).toLowerCase();
44
+
45
+ return { type, subtype, params };
46
+ }
47
+
48
+ function parseContentTypeParams(str, i, params) {
49
+ while (i < str.length) {
50
+ // Consume whitespace
51
+ for (; i < str.length; ++i) {
52
+ const code = str.charCodeAt(i);
53
+ if (code !== 32/* ' ' */ && code !== 9/* '\t' */)
54
+ break;
55
+ }
56
+
57
+ // Ended on whitespace
58
+ if (i === str.length)
59
+ break;
60
+
61
+ // Check for malformed parameter
62
+ if (str.charCodeAt(i++) !== 59/* ';' */)
63
+ return;
64
+
65
+ // Consume whitespace
66
+ for (; i < str.length; ++i) {
67
+ const code = str.charCodeAt(i);
68
+ if (code !== 32/* ' ' */ && code !== 9/* '\t' */)
69
+ break;
70
+ }
71
+
72
+ // Ended on whitespace (malformed)
73
+ if (i === str.length)
74
+ return;
75
+
76
+ let name;
77
+ const nameStart = i;
78
+ // Parse parameter name
79
+ for (; i < str.length; ++i) {
80
+ const code = str.charCodeAt(i);
81
+ if (TOKEN[code] !== 1) {
82
+ if (code !== 61/* '=' */)
83
+ return;
84
+ break;
85
+ }
86
+ }
87
+
88
+ // No value (malformed)
89
+ if (i === str.length)
90
+ return;
91
+
92
+ name = str.slice(nameStart, i);
93
+ ++i; // Skip over '='
94
+
95
+ // No value (malformed)
96
+ if (i === str.length)
97
+ return;
98
+
99
+ let value = '';
100
+ let valueStart;
101
+ if (str.charCodeAt(i) === 34/* '"' */) {
102
+ valueStart = ++i;
103
+ let escaping = false;
104
+ // Parse quoted value
105
+ for (; i < str.length; ++i) {
106
+ const code = str.charCodeAt(i);
107
+ if (code === 92/* '\\' */) {
108
+ if (escaping) {
109
+ valueStart = i;
110
+ escaping = false;
111
+ } else {
112
+ value += str.slice(valueStart, i);
113
+ escaping = true;
114
+ }
115
+ continue;
116
+ }
117
+ if (code === 34/* '"' */) {
118
+ if (escaping) {
119
+ valueStart = i;
120
+ escaping = false;
121
+ continue;
122
+ }
123
+ value += str.slice(valueStart, i);
124
+ break;
125
+ }
126
+ if (escaping) {
127
+ valueStart = i - 1;
128
+ escaping = false;
129
+ }
130
+ // Invalid unescaped quoted character (malformed)
131
+ if (QDTEXT[code] !== 1)
132
+ return;
133
+ }
134
+
135
+ // No end quote (malformed)
136
+ if (i === str.length)
137
+ return;
138
+
139
+ ++i; // Skip over double quote
140
+ } else {
141
+ valueStart = i;
142
+ // Parse unquoted value
143
+ for (; i < str.length; ++i) {
144
+ const code = str.charCodeAt(i);
145
+ if (TOKEN[code] !== 1) {
146
+ // No value (malformed)
147
+ if (i === valueStart)
148
+ return;
149
+ break;
150
+ }
151
+ }
152
+ value = str.slice(valueStart, i);
153
+ }
154
+
155
+ name = name.toLowerCase();
156
+ if (params[name] === undefined)
157
+ params[name] = value;
158
+ }
159
+
160
+ return params;
161
+ }
162
+
163
+ function parseDisposition(str, defDecoder) {
164
+ if (str.length === 0)
165
+ return;
166
+
167
+ const params = Object.create(null);
168
+ let i = 0;
169
+
170
+ for (; i < str.length; ++i) {
171
+ const code = str.charCodeAt(i);
172
+ if (TOKEN[code] !== 1) {
173
+ if (parseDispositionParams(str, i, params, defDecoder) === undefined)
174
+ return;
175
+ break;
176
+ }
177
+ }
178
+
179
+ const type = str.slice(0, i).toLowerCase();
180
+
181
+ return { type, params };
182
+ }
183
+
184
+ function parseDispositionParams(str, i, params, defDecoder) {
185
+ while (i < str.length) {
186
+ // Consume whitespace
187
+ for (; i < str.length; ++i) {
188
+ const code = str.charCodeAt(i);
189
+ if (code !== 32/* ' ' */ && code !== 9/* '\t' */)
190
+ break;
191
+ }
192
+
193
+ // Ended on whitespace
194
+ if (i === str.length)
195
+ break;
196
+
197
+ // Check for malformed parameter
198
+ if (str.charCodeAt(i++) !== 59/* ';' */)
199
+ return;
200
+
201
+ // Consume whitespace
202
+ for (; i < str.length; ++i) {
203
+ const code = str.charCodeAt(i);
204
+ if (code !== 32/* ' ' */ && code !== 9/* '\t' */)
205
+ break;
206
+ }
207
+
208
+ // Ended on whitespace (malformed)
209
+ if (i === str.length)
210
+ return;
211
+
212
+ let name;
213
+ const nameStart = i;
214
+ // Parse parameter name
215
+ for (; i < str.length; ++i) {
216
+ const code = str.charCodeAt(i);
217
+ if (TOKEN[code] !== 1) {
218
+ if (code === 61/* '=' */)
219
+ break;
220
+ return;
221
+ }
222
+ }
223
+
224
+ // No value (malformed)
225
+ if (i === str.length)
226
+ return;
227
+
228
+ let value = '';
229
+ let valueStart;
230
+ let charset;
231
+ //~ let lang;
232
+ name = str.slice(nameStart, i);
233
+ if (name.charCodeAt(name.length - 1) === 42/* '*' */) {
234
+ // Extended value
235
+
236
+ const charsetStart = ++i;
237
+ // Parse charset name
238
+ for (; i < str.length; ++i) {
239
+ const code = str.charCodeAt(i);
240
+ if (CHARSET[code] !== 1) {
241
+ if (code !== 39/* '\'' */)
242
+ return;
243
+ break;
244
+ }
245
+ }
246
+
247
+ // Incomplete charset (malformed)
248
+ if (i === str.length)
249
+ return;
250
+
251
+ charset = str.slice(charsetStart, i);
252
+ ++i; // Skip over the '\''
253
+
254
+ //~ const langStart = ++i;
255
+ // Parse language name
256
+ for (; i < str.length; ++i) {
257
+ const code = str.charCodeAt(i);
258
+ if (code === 39/* '\'' */)
259
+ break;
260
+ }
261
+
262
+ // Incomplete language (malformed)
263
+ if (i === str.length)
264
+ return;
265
+
266
+ //~ lang = str.slice(langStart, i);
267
+ ++i; // Skip over the '\''
268
+
269
+ // No value (malformed)
270
+ if (i === str.length)
271
+ return;
272
+
273
+ valueStart = i;
274
+
275
+ let encode = 0;
276
+ // Parse value
277
+ for (; i < str.length; ++i) {
278
+ const code = str.charCodeAt(i);
279
+ if (EXTENDED_VALUE[code] !== 1) {
280
+ if (code === 37/* '%' */) {
281
+ let hexUpper;
282
+ let hexLower;
283
+ if (i + 2 < str.length
284
+ && (hexUpper = HEX_VALUES[str.charCodeAt(i + 1)]) !== -1
285
+ && (hexLower = HEX_VALUES[str.charCodeAt(i + 2)]) !== -1) {
286
+ const byteVal = (hexUpper << 4) + hexLower;
287
+ value += str.slice(valueStart, i);
288
+ value += String.fromCharCode(byteVal);
289
+ i += 2;
290
+ valueStart = i + 1;
291
+ if (byteVal >= 128)
292
+ encode = 2;
293
+ else if (encode === 0)
294
+ encode = 1;
295
+ continue;
296
+ }
297
+ // '%' disallowed in non-percent encoded contexts (malformed)
298
+ return;
299
+ }
300
+ break;
301
+ }
302
+ }
303
+
304
+ value += str.slice(valueStart, i);
305
+ value = convertToUTF8(value, charset, encode);
306
+ if (value === undefined)
307
+ return;
308
+ } else {
309
+ // Non-extended value
310
+
311
+ ++i; // Skip over '='
312
+
313
+ // No value (malformed)
314
+ if (i === str.length)
315
+ return;
316
+
317
+ if (str.charCodeAt(i) === 34/* '"' */) {
318
+ valueStart = ++i;
319
+ let escaping = false;
320
+ // Parse quoted value
321
+ for (; i < str.length; ++i) {
322
+ const code = str.charCodeAt(i);
323
+ if (code === 92/* '\\' */) {
324
+ if (escaping) {
325
+ valueStart = i;
326
+ escaping = false;
327
+ } else {
328
+ value += str.slice(valueStart, i);
329
+ escaping = true;
330
+ }
331
+ continue;
332
+ }
333
+ if (code === 34/* '"' */) {
334
+ if (escaping) {
335
+ valueStart = i;
336
+ escaping = false;
337
+ continue;
338
+ }
339
+ value += str.slice(valueStart, i);
340
+ break;
341
+ }
342
+ if (escaping) {
343
+ valueStart = i - 1;
344
+ escaping = false;
345
+ }
346
+ // Invalid unescaped quoted character (malformed)
347
+ if (QDTEXT[code] !== 1)
348
+ return;
349
+ }
350
+
351
+ // No end quote (malformed)
352
+ if (i === str.length)
353
+ return;
354
+
355
+ ++i; // Skip over double quote
356
+ } else {
357
+ valueStart = i;
358
+ // Parse unquoted value
359
+ for (; i < str.length; ++i) {
360
+ const code = str.charCodeAt(i);
361
+ if (TOKEN[code] !== 1) {
362
+ // No value (malformed)
363
+ if (i === valueStart)
364
+ return;
365
+ break;
366
+ }
367
+ }
368
+ value = str.slice(valueStart, i);
369
+ }
370
+
371
+ value = defDecoder(value, 2);
372
+ if (value === undefined)
373
+ return;
374
+ }
375
+
376
+ name = name.toLowerCase();
377
+ if (params[name] === undefined)
378
+ params[name] = value;
379
+ }
380
+
381
+ return params;
382
+ }
383
+
384
+ function getDecoder(charset) {
385
+ let lc;
386
+ while (true) {
387
+ switch (charset) {
388
+ case 'utf-8':
389
+ case 'utf8':
390
+ return decoders.utf8;
391
+ case 'latin1':
392
+ case 'ascii': // TODO: Make these a separate, strict decoder?
393
+ case 'us-ascii':
394
+ case 'iso-8859-1':
395
+ case 'iso8859-1':
396
+ case 'iso88591':
397
+ case 'iso_8859-1':
398
+ case 'windows-1252':
399
+ case 'iso_8859-1:1987':
400
+ case 'cp1252':
401
+ case 'x-cp1252':
402
+ return decoders.latin1;
403
+ case 'utf16le':
404
+ case 'utf-16le':
405
+ case 'ucs2':
406
+ case 'ucs-2':
407
+ return decoders.utf16le;
408
+ case 'base64':
409
+ return decoders.base64;
410
+ default:
411
+ if (lc === undefined) {
412
+ lc = true;
413
+ charset = charset.toLowerCase();
414
+ continue;
415
+ }
416
+ return decoders.other.bind(charset);
417
+ }
418
+ }
419
+ }
420
+
421
+ const decoders = {
422
+ utf8: (data, hint) => {
423
+ if (data.length === 0)
424
+ return '';
425
+ if (typeof data === 'string') {
426
+ // If `data` never had any percent-encoded bytes or never had any that
427
+ // were outside of the ASCII range, then we can safely just return the
428
+ // input since UTF-8 is ASCII compatible
429
+ if (hint < 2)
430
+ return data;
431
+
432
+ data = Buffer.from(data, 'latin1');
433
+ }
434
+ return data.utf8Slice(0, data.length);
435
+ },
436
+
437
+ latin1: (data, hint) => {
438
+ if (data.length === 0)
439
+ return '';
440
+ if (typeof data === 'string')
441
+ return data;
442
+ return data.latin1Slice(0, data.length);
443
+ },
444
+
445
+ utf16le: (data, hint) => {
446
+ if (data.length === 0)
447
+ return '';
448
+ if (typeof data === 'string')
449
+ data = Buffer.from(data, 'latin1');
450
+ return data.ucs2Slice(0, data.length);
451
+ },
452
+
453
+ base64: (data, hint) => {
454
+ if (data.length === 0)
455
+ return '';
456
+ if (typeof data === 'string')
457
+ data = Buffer.from(data, 'latin1');
458
+ return data.base64Slice(0, data.length);
459
+ },
460
+
461
+ other: (data, hint) => {
462
+ if (data.length === 0)
463
+ return '';
464
+ if (typeof data === 'string')
465
+ data = Buffer.from(data, 'latin1');
466
+ try {
467
+ const decoder = new TextDecoder(this);
468
+ return decoder.decode(data);
469
+ } catch {}
470
+ },
471
+ };
472
+
473
+ function convertToUTF8(data, charset, hint) {
474
+ const decode = getDecoder(charset);
475
+ if (decode)
476
+ return decode(data, hint);
477
+ }
478
+
479
+ function basename(path) {
480
+ if (typeof path !== 'string')
481
+ return '';
482
+ for (let i = path.length - 1; i >= 0; --i) {
483
+ switch (path.charCodeAt(i)) {
484
+ case 0x2F: // '/'
485
+ case 0x5C: // '\'
486
+ path = path.slice(i + 1);
487
+ return (path === '..' || path === '.' ? '' : path);
488
+ }
489
+ }
490
+ return (path === '..' || path === '.' ? '' : path);
491
+ }
492
+
493
+ const TOKEN = [
494
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
495
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
496
+ 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0,
497
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0,
498
+ 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
499
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1,
500
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
567
+ ];
568
+
569
+ /* eslint-disable no-multi-spaces */
570
+ const HEX_VALUES = [
571
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
572
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
573
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
574
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, -1,
575
+ -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1,
576
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
577
+ -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1,
578
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
579
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
580
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
581
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
582
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
583
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
584
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
585
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
586
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
587
+ ];
588
+ /* eslint-enable no-multi-spaces */
589
+
590
+ module.exports = {
591
+ basename,
592
+ convertToUTF8,
593
+ getDecoder,
594
+ parseContentType,
595
+ parseDisposition,
596
+ };
@@ -0,0 +1,22 @@
1
+ { "name": "busboy",
2
+ "version": "1.6.0",
3
+ "author": "Brian White <mscdex@mscdex.net>",
4
+ "description": "A streaming parser for HTML form data for node.js",
5
+ "main": "./lib/index.js",
6
+ "dependencies": {
7
+ "streamsearch": "^1.1.0"
8
+ },
9
+ "devDependencies": {
10
+ "@mscdex/eslint-config": "^1.1.0",
11
+ "eslint": "^7.32.0"
12
+ },
13
+ "scripts": {
14
+ "test": "node test/test.js",
15
+ "lint": "eslint --cache --report-unused-disable-directives --ext=.js .eslintrc.js lib test bench",
16
+ "lint:fix": "npm run lint -- --fix"
17
+ },
18
+ "engines": { "node": ">=10.16.0" },
19
+ "keywords": [ "uploads", "forms", "multipart", "form-data" ],
20
+ "licenses": [ { "type": "MIT", "url": "http://github.com/mscdex/busboy/raw/master/LICENSE" } ],
21
+ "repository": { "type": "git", "url": "http://github.com/mscdex/busboy.git" }
22
+ }