@nocobase/plugin-multi-app-manager 1.2.13-alpha → 1.3.0-alpha.20240710084543

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 (175) hide show
  1. package/package.json +2 -2
  2. package/dist/client/AppManager.d.ts +0 -10
  3. package/dist/client/AppNameInput.d.ts +0 -10
  4. package/dist/client/MultiAppManagerProvider.d.ts +0 -10
  5. package/dist/client/MultiAppManagerProvider.style.d.ts +0 -13
  6. package/dist/client/Settings.d.ts +0 -10
  7. package/dist/client/index.d.ts +0 -14
  8. package/dist/client/index.js +0 -10
  9. package/dist/client/settings/schemas/applications.d.ts +0 -18
  10. package/dist/client/utils.d.ts +0 -12
  11. package/dist/externalVersion.js +0 -25
  12. package/dist/index.d.ts +0 -10
  13. package/dist/index.js +0 -48
  14. package/dist/locale/en-US.json +0 -11
  15. package/dist/locale/es-ES.json +0 -9
  16. package/dist/locale/index.d.ts +0 -9
  17. package/dist/locale/index.js +0 -36
  18. package/dist/locale/ko_KR.json +0 -11
  19. package/dist/locale/pt-BR.json +0 -9
  20. package/dist/locale/zh-CN.json +0 -14
  21. package/dist/node_modules/mariadb/LICENSE +0 -502
  22. package/dist/node_modules/mariadb/callback.js +0 -41
  23. package/dist/node_modules/mariadb/lib/cmd/batch-bulk.js +0 -278
  24. package/dist/node_modules/mariadb/lib/cmd/batch-rewrite.js +0 -372
  25. package/dist/node_modules/mariadb/lib/cmd/change-user.js +0 -149
  26. package/dist/node_modules/mariadb/lib/cmd/class/ok-packet.js +0 -17
  27. package/dist/node_modules/mariadb/lib/cmd/column-definition.js +0 -102
  28. package/dist/node_modules/mariadb/lib/cmd/command.js +0 -168
  29. package/dist/node_modules/mariadb/lib/cmd/common-binary-cmd.js +0 -327
  30. package/dist/node_modules/mariadb/lib/cmd/common-text-cmd.js +0 -427
  31. package/dist/node_modules/mariadb/lib/cmd/handshake/auth/caching-sha2-password-auth.js +0 -168
  32. package/dist/node_modules/mariadb/lib/cmd/handshake/auth/clear-password-auth.js +0 -23
  33. package/dist/node_modules/mariadb/lib/cmd/handshake/auth/ed25519-password-auth.js +0 -761
  34. package/dist/node_modules/mariadb/lib/cmd/handshake/auth/native-password-auth.js +0 -55
  35. package/dist/node_modules/mariadb/lib/cmd/handshake/auth/pam-password-auth.js +0 -58
  36. package/dist/node_modules/mariadb/lib/cmd/handshake/auth/plugin-auth.js +0 -19
  37. package/dist/node_modules/mariadb/lib/cmd/handshake/auth/sha256-password-auth.js +0 -142
  38. package/dist/node_modules/mariadb/lib/cmd/handshake/client-capabilities.js +0 -74
  39. package/dist/node_modules/mariadb/lib/cmd/handshake/client-handshake-response.js +0 -126
  40. package/dist/node_modules/mariadb/lib/cmd/handshake/handshake.js +0 -292
  41. package/dist/node_modules/mariadb/lib/cmd/handshake/initial-handshake.js +0 -74
  42. package/dist/node_modules/mariadb/lib/cmd/handshake/ssl-request.js +0 -29
  43. package/dist/node_modules/mariadb/lib/cmd/ping.js +0 -52
  44. package/dist/node_modules/mariadb/lib/cmd/query.js +0 -255
  45. package/dist/node_modules/mariadb/lib/cmd/quit.js +0 -28
  46. package/dist/node_modules/mariadb/lib/cmd/reset.js +0 -54
  47. package/dist/node_modules/mariadb/lib/cmd/resultset.js +0 -607
  48. package/dist/node_modules/mariadb/lib/cmd/stream.js +0 -45
  49. package/dist/node_modules/mariadb/lib/config/connection-options.js +0 -258
  50. package/dist/node_modules/mariadb/lib/config/pool-cluster-options.js +0 -19
  51. package/dist/node_modules/mariadb/lib/config/pool-options.js +0 -47
  52. package/dist/node_modules/mariadb/lib/connection-callback.js +0 -160
  53. package/dist/node_modules/mariadb/lib/connection.js +0 -1460
  54. package/dist/node_modules/mariadb/lib/const/capabilities.js +0 -64
  55. package/dist/node_modules/mariadb/lib/const/collations.js +0 -473
  56. package/dist/node_modules/mariadb/lib/const/connection_status.js +0 -13
  57. package/dist/node_modules/mariadb/lib/const/error-code.js +0 -1282
  58. package/dist/node_modules/mariadb/lib/const/field-detail.js +0 -35
  59. package/dist/node_modules/mariadb/lib/const/field-type.js +0 -71
  60. package/dist/node_modules/mariadb/lib/const/server-status.js +0 -30
  61. package/dist/node_modules/mariadb/lib/const/state-change.js +0 -12
  62. package/dist/node_modules/mariadb/lib/filtered-pool-cluster.js +0 -81
  63. package/dist/node_modules/mariadb/lib/io/bulk-packet.js +0 -590
  64. package/dist/node_modules/mariadb/lib/io/compression-input-stream.js +0 -141
  65. package/dist/node_modules/mariadb/lib/io/compression-output-stream.js +0 -171
  66. package/dist/node_modules/mariadb/lib/io/packet-input-stream.js +0 -193
  67. package/dist/node_modules/mariadb/lib/io/packet-node-encoded.js +0 -36
  68. package/dist/node_modules/mariadb/lib/io/packet-node-iconv.js +0 -37
  69. package/dist/node_modules/mariadb/lib/io/packet-output-stream.js +0 -502
  70. package/dist/node_modules/mariadb/lib/io/packet.js +0 -515
  71. package/dist/node_modules/mariadb/lib/io/rewrite-packet.js +0 -481
  72. package/dist/node_modules/mariadb/lib/misc/connection-information.js +0 -96
  73. package/dist/node_modules/mariadb/lib/misc/errors.js +0 -123
  74. package/dist/node_modules/mariadb/lib/misc/parse.js +0 -1033
  75. package/dist/node_modules/mariadb/lib/misc/utils.js +0 -298
  76. package/dist/node_modules/mariadb/lib/pool-base.js +0 -611
  77. package/dist/node_modules/mariadb/lib/pool-callback.js +0 -202
  78. package/dist/node_modules/mariadb/lib/pool-cluster-callback.js +0 -66
  79. package/dist/node_modules/mariadb/lib/pool-cluster.js +0 -407
  80. package/dist/node_modules/mariadb/lib/pool-promise.js +0 -108
  81. package/dist/node_modules/mariadb/node_modules/@types/node/assert/strict.d.ts +0 -8
  82. package/dist/node_modules/mariadb/node_modules/@types/node/assert.d.ts +0 -912
  83. package/dist/node_modules/mariadb/node_modules/@types/node/async_hooks.d.ts +0 -501
  84. package/dist/node_modules/mariadb/node_modules/@types/node/buffer.d.ts +0 -2232
  85. package/dist/node_modules/mariadb/node_modules/@types/node/child_process.d.ts +0 -1366
  86. package/dist/node_modules/mariadb/node_modules/@types/node/cluster.d.ts +0 -414
  87. package/dist/node_modules/mariadb/node_modules/@types/node/console.d.ts +0 -412
  88. package/dist/node_modules/mariadb/node_modules/@types/node/constants.d.ts +0 -18
  89. package/dist/node_modules/mariadb/node_modules/@types/node/crypto.d.ts +0 -3338
  90. package/dist/node_modules/mariadb/node_modules/@types/node/dgram.d.ts +0 -545
  91. package/dist/node_modules/mariadb/node_modules/@types/node/diagnostics_channel.d.ts +0 -152
  92. package/dist/node_modules/mariadb/node_modules/@types/node/dns/promises.d.ts +0 -370
  93. package/dist/node_modules/mariadb/node_modules/@types/node/dns.d.ts +0 -659
  94. package/dist/node_modules/mariadb/node_modules/@types/node/domain.d.ts +0 -169
  95. package/dist/node_modules/mariadb/node_modules/@types/node/events.d.ts +0 -651
  96. package/dist/node_modules/mariadb/node_modules/@types/node/fs/promises.d.ts +0 -1091
  97. package/dist/node_modules/mariadb/node_modules/@types/node/fs.d.ts +0 -3869
  98. package/dist/node_modules/mariadb/node_modules/@types/node/globals.d.ts +0 -294
  99. package/dist/node_modules/mariadb/node_modules/@types/node/globals.global.d.ts +0 -1
  100. package/dist/node_modules/mariadb/node_modules/@types/node/http.d.ts +0 -1396
  101. package/dist/node_modules/mariadb/node_modules/@types/node/http2.d.ts +0 -2101
  102. package/dist/node_modules/mariadb/node_modules/@types/node/https.d.ts +0 -391
  103. package/dist/node_modules/mariadb/node_modules/@types/node/index.d.ts +0 -129
  104. package/dist/node_modules/mariadb/node_modules/@types/node/inspector.d.ts +0 -2744
  105. package/dist/node_modules/mariadb/node_modules/@types/node/module.d.ts +0 -114
  106. package/dist/node_modules/mariadb/node_modules/@types/node/net.d.ts +0 -791
  107. package/dist/node_modules/mariadb/node_modules/@types/node/os.d.ts +0 -455
  108. package/dist/node_modules/mariadb/node_modules/@types/node/package.json +0 -220
  109. package/dist/node_modules/mariadb/node_modules/@types/node/path.d.ts +0 -180
  110. package/dist/node_modules/mariadb/node_modules/@types/node/perf_hooks.d.ts +0 -557
  111. package/dist/node_modules/mariadb/node_modules/@types/node/process.d.ts +0 -1481
  112. package/dist/node_modules/mariadb/node_modules/@types/node/punycode.d.ts +0 -117
  113. package/dist/node_modules/mariadb/node_modules/@types/node/querystring.d.ts +0 -131
  114. package/dist/node_modules/mariadb/node_modules/@types/node/readline.d.ts +0 -650
  115. package/dist/node_modules/mariadb/node_modules/@types/node/repl.d.ts +0 -424
  116. package/dist/node_modules/mariadb/node_modules/@types/node/stream/consumers.d.ts +0 -24
  117. package/dist/node_modules/mariadb/node_modules/@types/node/stream/promises.d.ts +0 -42
  118. package/dist/node_modules/mariadb/node_modules/@types/node/stream/web.d.ts +0 -330
  119. package/dist/node_modules/mariadb/node_modules/@types/node/stream.d.ts +0 -1249
  120. package/dist/node_modules/mariadb/node_modules/@types/node/string_decoder.d.ts +0 -67
  121. package/dist/node_modules/mariadb/node_modules/@types/node/timers/promises.d.ts +0 -68
  122. package/dist/node_modules/mariadb/node_modules/@types/node/timers.d.ts +0 -94
  123. package/dist/node_modules/mariadb/node_modules/@types/node/tls.d.ts +0 -1020
  124. package/dist/node_modules/mariadb/node_modules/@types/node/trace_events.d.ts +0 -161
  125. package/dist/node_modules/mariadb/node_modules/@types/node/tty.d.ts +0 -204
  126. package/dist/node_modules/mariadb/node_modules/@types/node/url.d.ts +0 -891
  127. package/dist/node_modules/mariadb/node_modules/@types/node/util.d.ts +0 -1594
  128. package/dist/node_modules/mariadb/node_modules/@types/node/v8.d.ts +0 -378
  129. package/dist/node_modules/mariadb/node_modules/@types/node/vm.d.ts +0 -507
  130. package/dist/node_modules/mariadb/node_modules/@types/node/wasi.d.ts +0 -158
  131. package/dist/node_modules/mariadb/node_modules/@types/node/worker_threads.d.ts +0 -649
  132. package/dist/node_modules/mariadb/node_modules/@types/node/zlib.d.ts +0 -517
  133. package/dist/node_modules/mariadb/node_modules/iconv-lite/.github/dependabot.yml +0 -11
  134. package/dist/node_modules/mariadb/node_modules/iconv-lite/.idea/codeStyles/Project.xml +0 -47
  135. package/dist/node_modules/mariadb/node_modules/iconv-lite/.idea/codeStyles/codeStyleConfig.xml +0 -5
  136. package/dist/node_modules/mariadb/node_modules/iconv-lite/.idea/iconv-lite.iml +0 -12
  137. package/dist/node_modules/mariadb/node_modules/iconv-lite/.idea/inspectionProfiles/Project_Default.xml +0 -6
  138. package/dist/node_modules/mariadb/node_modules/iconv-lite/.idea/modules.xml +0 -8
  139. package/dist/node_modules/mariadb/node_modules/iconv-lite/.idea/vcs.xml +0 -6
  140. package/dist/node_modules/mariadb/node_modules/iconv-lite/encodings/dbcs-codec.js +0 -597
  141. package/dist/node_modules/mariadb/node_modules/iconv-lite/encodings/dbcs-data.js +0 -188
  142. package/dist/node_modules/mariadb/node_modules/iconv-lite/encodings/index.js +0 -23
  143. package/dist/node_modules/mariadb/node_modules/iconv-lite/encodings/internal.js +0 -198
  144. package/dist/node_modules/mariadb/node_modules/iconv-lite/encodings/sbcs-codec.js +0 -72
  145. package/dist/node_modules/mariadb/node_modules/iconv-lite/encodings/sbcs-data-generated.js +0 -451
  146. package/dist/node_modules/mariadb/node_modules/iconv-lite/encodings/sbcs-data.js +0 -179
  147. package/dist/node_modules/mariadb/node_modules/iconv-lite/encodings/tables/big5-added.json +0 -122
  148. package/dist/node_modules/mariadb/node_modules/iconv-lite/encodings/tables/cp936.json +0 -264
  149. package/dist/node_modules/mariadb/node_modules/iconv-lite/encodings/tables/cp949.json +0 -273
  150. package/dist/node_modules/mariadb/node_modules/iconv-lite/encodings/tables/cp950.json +0 -177
  151. package/dist/node_modules/mariadb/node_modules/iconv-lite/encodings/tables/eucjp.json +0 -182
  152. package/dist/node_modules/mariadb/node_modules/iconv-lite/encodings/tables/gb18030-ranges.json +0 -1
  153. package/dist/node_modules/mariadb/node_modules/iconv-lite/encodings/tables/gbk-added.json +0 -56
  154. package/dist/node_modules/mariadb/node_modules/iconv-lite/encodings/tables/shiftjis.json +0 -125
  155. package/dist/node_modules/mariadb/node_modules/iconv-lite/encodings/utf16.js +0 -197
  156. package/dist/node_modules/mariadb/node_modules/iconv-lite/encodings/utf32.js +0 -319
  157. package/dist/node_modules/mariadb/node_modules/iconv-lite/encodings/utf7.js +0 -290
  158. package/dist/node_modules/mariadb/node_modules/iconv-lite/lib/bom-handling.js +0 -52
  159. package/dist/node_modules/mariadb/node_modules/iconv-lite/lib/index.d.ts +0 -41
  160. package/dist/node_modules/mariadb/node_modules/iconv-lite/lib/index.js +0 -180
  161. package/dist/node_modules/mariadb/node_modules/iconv-lite/lib/streams.js +0 -109
  162. package/dist/node_modules/mariadb/node_modules/iconv-lite/package.json +0 -44
  163. package/dist/node_modules/mariadb/package.json +0 -1
  164. package/dist/node_modules/mariadb/promise.js +0 -34
  165. package/dist/node_modules/mariadb/types/index.d.ts +0 -870
  166. package/dist/server/collections/applications.d.ts +0 -10
  167. package/dist/server/collections/applications.js +0 -75
  168. package/dist/server/index.d.ts +0 -11
  169. package/dist/server/index.js +0 -40
  170. package/dist/server/models/application.d.ts +0 -18
  171. package/dist/server/models/application.js +0 -50
  172. package/dist/server/server.d.ts +0 -26
  173. package/dist/server/server.js +0 -310
  174. package/dist/swagger/index.d.ts +0 -195
  175. package/dist/swagger/index.js +0 -226
@@ -1,197 +0,0 @@
1
- "use strict";
2
- var Buffer = require("safer-buffer").Buffer;
3
-
4
- // Note: UTF16-LE (or UCS2) codec is Node.js native. See encodings/internal.js
5
-
6
- // == UTF16-BE codec. ==========================================================
7
-
8
- exports.utf16be = Utf16BECodec;
9
- function Utf16BECodec() {
10
- }
11
-
12
- Utf16BECodec.prototype.encoder = Utf16BEEncoder;
13
- Utf16BECodec.prototype.decoder = Utf16BEDecoder;
14
- Utf16BECodec.prototype.bomAware = true;
15
-
16
-
17
- // -- Encoding
18
-
19
- function Utf16BEEncoder() {
20
- }
21
-
22
- Utf16BEEncoder.prototype.write = function(str) {
23
- var buf = Buffer.from(str, 'ucs2');
24
- for (var i = 0; i < buf.length; i += 2) {
25
- var tmp = buf[i]; buf[i] = buf[i+1]; buf[i+1] = tmp;
26
- }
27
- return buf;
28
- }
29
-
30
- Utf16BEEncoder.prototype.end = function() {
31
- }
32
-
33
-
34
- // -- Decoding
35
-
36
- function Utf16BEDecoder() {
37
- this.overflowByte = -1;
38
- }
39
-
40
- Utf16BEDecoder.prototype.write = function(buf) {
41
- if (buf.length == 0)
42
- return '';
43
-
44
- var buf2 = Buffer.alloc(buf.length + 1),
45
- i = 0, j = 0;
46
-
47
- if (this.overflowByte !== -1) {
48
- buf2[0] = buf[0];
49
- buf2[1] = this.overflowByte;
50
- i = 1; j = 2;
51
- }
52
-
53
- for (; i < buf.length-1; i += 2, j+= 2) {
54
- buf2[j] = buf[i+1];
55
- buf2[j+1] = buf[i];
56
- }
57
-
58
- this.overflowByte = (i == buf.length-1) ? buf[buf.length-1] : -1;
59
-
60
- return buf2.slice(0, j).toString('ucs2');
61
- }
62
-
63
- Utf16BEDecoder.prototype.end = function() {
64
- this.overflowByte = -1;
65
- }
66
-
67
-
68
- // == UTF-16 codec =============================================================
69
- // Decoder chooses automatically from UTF-16LE and UTF-16BE using BOM and space-based heuristic.
70
- // Defaults to UTF-16LE, as it's prevalent and default in Node.
71
- // http://en.wikipedia.org/wiki/UTF-16 and http://encoding.spec.whatwg.org/#utf-16le
72
- // Decoder default can be changed: iconv.decode(buf, 'utf16', {defaultEncoding: 'utf-16be'});
73
-
74
- // Encoder uses UTF-16LE and prepends BOM (which can be overridden with addBOM: false).
75
-
76
- exports.utf16 = Utf16Codec;
77
- function Utf16Codec(codecOptions, iconv) {
78
- this.iconv = iconv;
79
- }
80
-
81
- Utf16Codec.prototype.encoder = Utf16Encoder;
82
- Utf16Codec.prototype.decoder = Utf16Decoder;
83
-
84
-
85
- // -- Encoding (pass-through)
86
-
87
- function Utf16Encoder(options, codec) {
88
- options = options || {};
89
- if (options.addBOM === undefined)
90
- options.addBOM = true;
91
- this.encoder = codec.iconv.getEncoder('utf-16le', options);
92
- }
93
-
94
- Utf16Encoder.prototype.write = function(str) {
95
- return this.encoder.write(str);
96
- }
97
-
98
- Utf16Encoder.prototype.end = function() {
99
- return this.encoder.end();
100
- }
101
-
102
-
103
- // -- Decoding
104
-
105
- function Utf16Decoder(options, codec) {
106
- this.decoder = null;
107
- this.initialBufs = [];
108
- this.initialBufsLen = 0;
109
-
110
- this.options = options || {};
111
- this.iconv = codec.iconv;
112
- }
113
-
114
- Utf16Decoder.prototype.write = function(buf) {
115
- if (!this.decoder) {
116
- // Codec is not chosen yet. Accumulate initial bytes.
117
- this.initialBufs.push(buf);
118
- this.initialBufsLen += buf.length;
119
-
120
- if (this.initialBufsLen < 16) // We need more bytes to use space heuristic (see below)
121
- return '';
122
-
123
- // We have enough bytes -> detect endianness.
124
- var encoding = detectEncoding(this.initialBufs, this.options.defaultEncoding);
125
- this.decoder = this.iconv.getDecoder(encoding, this.options);
126
-
127
- var resStr = '';
128
- for (var i = 0; i < this.initialBufs.length; i++)
129
- resStr += this.decoder.write(this.initialBufs[i]);
130
-
131
- this.initialBufs.length = this.initialBufsLen = 0;
132
- return resStr;
133
- }
134
-
135
- return this.decoder.write(buf);
136
- }
137
-
138
- Utf16Decoder.prototype.end = function() {
139
- if (!this.decoder) {
140
- var encoding = detectEncoding(this.initialBufs, this.options.defaultEncoding);
141
- this.decoder = this.iconv.getDecoder(encoding, this.options);
142
-
143
- var resStr = '';
144
- for (var i = 0; i < this.initialBufs.length; i++)
145
- resStr += this.decoder.write(this.initialBufs[i]);
146
-
147
- var trail = this.decoder.end();
148
- if (trail)
149
- resStr += trail;
150
-
151
- this.initialBufs.length = this.initialBufsLen = 0;
152
- return resStr;
153
- }
154
- return this.decoder.end();
155
- }
156
-
157
- function detectEncoding(bufs, defaultEncoding) {
158
- var b = [];
159
- var charsProcessed = 0;
160
- var asciiCharsLE = 0, asciiCharsBE = 0; // Number of ASCII chars when decoded as LE or BE.
161
-
162
- outer_loop:
163
- for (var i = 0; i < bufs.length; i++) {
164
- var buf = bufs[i];
165
- for (var j = 0; j < buf.length; j++) {
166
- b.push(buf[j]);
167
- if (b.length === 2) {
168
- if (charsProcessed === 0) {
169
- // Check BOM first.
170
- if (b[0] === 0xFF && b[1] === 0xFE) return 'utf-16le';
171
- if (b[0] === 0xFE && b[1] === 0xFF) return 'utf-16be';
172
- }
173
-
174
- if (b[0] === 0 && b[1] !== 0) asciiCharsBE++;
175
- if (b[0] !== 0 && b[1] === 0) asciiCharsLE++;
176
-
177
- b.length = 0;
178
- charsProcessed++;
179
-
180
- if (charsProcessed >= 100) {
181
- break outer_loop;
182
- }
183
- }
184
- }
185
- }
186
-
187
- // Make decisions.
188
- // Most of the time, the content has ASCII chars (U+00**), but the opposite (U+**00) is uncommon.
189
- // So, we count ASCII as if it was LE or BE, and decide from that.
190
- if (asciiCharsBE > asciiCharsLE) return 'utf-16be';
191
- if (asciiCharsBE < asciiCharsLE) return 'utf-16le';
192
-
193
- // Couldn't decide (likely all zeros or not enough data).
194
- return defaultEncoding || 'utf-16le';
195
- }
196
-
197
-
@@ -1,319 +0,0 @@
1
- 'use strict';
2
-
3
- var Buffer = require('safer-buffer').Buffer;
4
-
5
- // == UTF32-LE/BE codec. ==========================================================
6
-
7
- exports._utf32 = Utf32Codec;
8
-
9
- function Utf32Codec(codecOptions, iconv) {
10
- this.iconv = iconv;
11
- this.bomAware = true;
12
- this.isLE = codecOptions.isLE;
13
- }
14
-
15
- exports.utf32le = { type: '_utf32', isLE: true };
16
- exports.utf32be = { type: '_utf32', isLE: false };
17
-
18
- // Aliases
19
- exports.ucs4le = 'utf32le';
20
- exports.ucs4be = 'utf32be';
21
-
22
- Utf32Codec.prototype.encoder = Utf32Encoder;
23
- Utf32Codec.prototype.decoder = Utf32Decoder;
24
-
25
- // -- Encoding
26
-
27
- function Utf32Encoder(options, codec) {
28
- this.isLE = codec.isLE;
29
- this.highSurrogate = 0;
30
- }
31
-
32
- Utf32Encoder.prototype.write = function(str) {
33
- var src = Buffer.from(str, 'ucs2');
34
- var dst = Buffer.alloc(src.length * 2);
35
- var write32 = this.isLE ? dst.writeUInt32LE : dst.writeUInt32BE;
36
- var offset = 0;
37
-
38
- for (var i = 0; i < src.length; i += 2) {
39
- var code = src.readUInt16LE(i);
40
- var isHighSurrogate = (0xD800 <= code && code < 0xDC00);
41
- var isLowSurrogate = (0xDC00 <= code && code < 0xE000);
42
-
43
- if (this.highSurrogate) {
44
- if (isHighSurrogate || !isLowSurrogate) {
45
- // There shouldn't be two high surrogates in a row, nor a high surrogate which isn't followed by a low
46
- // surrogate. If this happens, keep the pending high surrogate as a stand-alone semi-invalid character
47
- // (technically wrong, but expected by some applications, like Windows file names).
48
- write32.call(dst, this.highSurrogate, offset);
49
- offset += 4;
50
- }
51
- else {
52
- // Create 32-bit value from high and low surrogates;
53
- var codepoint = (((this.highSurrogate - 0xD800) << 10) | (code - 0xDC00)) + 0x10000;
54
-
55
- write32.call(dst, codepoint, offset);
56
- offset += 4;
57
- this.highSurrogate = 0;
58
-
59
- continue;
60
- }
61
- }
62
-
63
- if (isHighSurrogate)
64
- this.highSurrogate = code;
65
- else {
66
- // Even if the current character is a low surrogate, with no previous high surrogate, we'll
67
- // encode it as a semi-invalid stand-alone character for the same reasons expressed above for
68
- // unpaired high surrogates.
69
- write32.call(dst, code, offset);
70
- offset += 4;
71
- this.highSurrogate = 0;
72
- }
73
- }
74
-
75
- if (offset < dst.length)
76
- dst = dst.slice(0, offset);
77
-
78
- return dst;
79
- };
80
-
81
- Utf32Encoder.prototype.end = function() {
82
- // Treat any leftover high surrogate as a semi-valid independent character.
83
- if (!this.highSurrogate)
84
- return;
85
-
86
- var buf = Buffer.alloc(4);
87
-
88
- if (this.isLE)
89
- buf.writeUInt32LE(this.highSurrogate, 0);
90
- else
91
- buf.writeUInt32BE(this.highSurrogate, 0);
92
-
93
- this.highSurrogate = 0;
94
-
95
- return buf;
96
- };
97
-
98
- // -- Decoding
99
-
100
- function Utf32Decoder(options, codec) {
101
- this.isLE = codec.isLE;
102
- this.badChar = codec.iconv.defaultCharUnicode.charCodeAt(0);
103
- this.overflow = [];
104
- }
105
-
106
- Utf32Decoder.prototype.write = function(src) {
107
- if (src.length === 0)
108
- return '';
109
-
110
- var i = 0;
111
- var codepoint = 0;
112
- var dst = Buffer.alloc(src.length + 4);
113
- var offset = 0;
114
- var isLE = this.isLE;
115
- var overflow = this.overflow;
116
- var badChar = this.badChar;
117
-
118
- if (overflow.length > 0) {
119
- for (; i < src.length && overflow.length < 4; i++)
120
- overflow.push(src[i]);
121
-
122
- if (overflow.length === 4) {
123
- // NOTE: codepoint is a signed int32 and can be negative.
124
- // NOTE: We copied this block from below to help V8 optimize it (it works with array, not buffer).
125
- if (isLE) {
126
- codepoint = overflow[i] | (overflow[i+1] << 8) | (overflow[i+2] << 16) | (overflow[i+3] << 24);
127
- } else {
128
- codepoint = overflow[i+3] | (overflow[i+2] << 8) | (overflow[i+1] << 16) | (overflow[i] << 24);
129
- }
130
- overflow.length = 0;
131
-
132
- offset = _writeCodepoint(dst, offset, codepoint, badChar);
133
- }
134
- }
135
-
136
- // Main loop. Should be as optimized as possible.
137
- for (; i < src.length - 3; i += 4) {
138
- // NOTE: codepoint is a signed int32 and can be negative.
139
- if (isLE) {
140
- codepoint = src[i] | (src[i+1] << 8) | (src[i+2] << 16) | (src[i+3] << 24);
141
- } else {
142
- codepoint = src[i+3] | (src[i+2] << 8) | (src[i+1] << 16) | (src[i] << 24);
143
- }
144
- offset = _writeCodepoint(dst, offset, codepoint, badChar);
145
- }
146
-
147
- // Keep overflowing bytes.
148
- for (; i < src.length; i++) {
149
- overflow.push(src[i]);
150
- }
151
-
152
- return dst.slice(0, offset).toString('ucs2');
153
- };
154
-
155
- function _writeCodepoint(dst, offset, codepoint, badChar) {
156
- // NOTE: codepoint is signed int32 and can be negative. We keep it that way to help V8 with optimizations.
157
- if (codepoint < 0 || codepoint > 0x10FFFF) {
158
- // Not a valid Unicode codepoint
159
- codepoint = badChar;
160
- }
161
-
162
- // Ephemeral Planes: Write high surrogate.
163
- if (codepoint >= 0x10000) {
164
- codepoint -= 0x10000;
165
-
166
- var high = 0xD800 | (codepoint >> 10);
167
- dst[offset++] = high & 0xff;
168
- dst[offset++] = high >> 8;
169
-
170
- // Low surrogate is written below.
171
- var codepoint = 0xDC00 | (codepoint & 0x3FF);
172
- }
173
-
174
- // Write BMP char or low surrogate.
175
- dst[offset++] = codepoint & 0xff;
176
- dst[offset++] = codepoint >> 8;
177
-
178
- return offset;
179
- };
180
-
181
- Utf32Decoder.prototype.end = function() {
182
- this.overflow.length = 0;
183
- };
184
-
185
- // == UTF-32 Auto codec =============================================================
186
- // Decoder chooses automatically from UTF-32LE and UTF-32BE using BOM and space-based heuristic.
187
- // Defaults to UTF-32LE. http://en.wikipedia.org/wiki/UTF-32
188
- // Encoder/decoder default can be changed: iconv.decode(buf, 'utf32', {defaultEncoding: 'utf-32be'});
189
-
190
- // Encoder prepends BOM (which can be overridden with (addBOM: false}).
191
-
192
- exports.utf32 = Utf32AutoCodec;
193
- exports.ucs4 = 'utf32';
194
-
195
- function Utf32AutoCodec(options, iconv) {
196
- this.iconv = iconv;
197
- }
198
-
199
- Utf32AutoCodec.prototype.encoder = Utf32AutoEncoder;
200
- Utf32AutoCodec.prototype.decoder = Utf32AutoDecoder;
201
-
202
- // -- Encoding
203
-
204
- function Utf32AutoEncoder(options, codec) {
205
- options = options || {};
206
-
207
- if (options.addBOM === undefined)
208
- options.addBOM = true;
209
-
210
- this.encoder = codec.iconv.getEncoder(options.defaultEncoding || 'utf-32le', options);
211
- }
212
-
213
- Utf32AutoEncoder.prototype.write = function(str) {
214
- return this.encoder.write(str);
215
- };
216
-
217
- Utf32AutoEncoder.prototype.end = function() {
218
- return this.encoder.end();
219
- };
220
-
221
- // -- Decoding
222
-
223
- function Utf32AutoDecoder(options, codec) {
224
- this.decoder = null;
225
- this.initialBufs = [];
226
- this.initialBufsLen = 0;
227
- this.options = options || {};
228
- this.iconv = codec.iconv;
229
- }
230
-
231
- Utf32AutoDecoder.prototype.write = function(buf) {
232
- if (!this.decoder) {
233
- // Codec is not chosen yet. Accumulate initial bytes.
234
- this.initialBufs.push(buf);
235
- this.initialBufsLen += buf.length;
236
-
237
- if (this.initialBufsLen < 32) // We need more bytes to use space heuristic (see below)
238
- return '';
239
-
240
- // We have enough bytes -> detect endianness.
241
- var encoding = detectEncoding(this.initialBufs, this.options.defaultEncoding);
242
- this.decoder = this.iconv.getDecoder(encoding, this.options);
243
-
244
- var resStr = '';
245
- for (var i = 0; i < this.initialBufs.length; i++)
246
- resStr += this.decoder.write(this.initialBufs[i]);
247
-
248
- this.initialBufs.length = this.initialBufsLen = 0;
249
- return resStr;
250
- }
251
-
252
- return this.decoder.write(buf);
253
- };
254
-
255
- Utf32AutoDecoder.prototype.end = function() {
256
- if (!this.decoder) {
257
- var encoding = detectEncoding(this.initialBufs, this.options.defaultEncoding);
258
- this.decoder = this.iconv.getDecoder(encoding, this.options);
259
-
260
- var resStr = '';
261
- for (var i = 0; i < this.initialBufs.length; i++)
262
- resStr += this.decoder.write(this.initialBufs[i]);
263
-
264
- var trail = this.decoder.end();
265
- if (trail)
266
- resStr += trail;
267
-
268
- this.initialBufs.length = this.initialBufsLen = 0;
269
- return resStr;
270
- }
271
-
272
- return this.decoder.end();
273
- };
274
-
275
- function detectEncoding(bufs, defaultEncoding) {
276
- var b = [];
277
- var charsProcessed = 0;
278
- var invalidLE = 0, invalidBE = 0; // Number of invalid chars when decoded as LE or BE.
279
- var bmpCharsLE = 0, bmpCharsBE = 0; // Number of BMP chars when decoded as LE or BE.
280
-
281
- outer_loop:
282
- for (var i = 0; i < bufs.length; i++) {
283
- var buf = bufs[i];
284
- for (var j = 0; j < buf.length; j++) {
285
- b.push(buf[j]);
286
- if (b.length === 4) {
287
- if (charsProcessed === 0) {
288
- // Check BOM first.
289
- if (b[0] === 0xFF && b[1] === 0xFE && b[2] === 0 && b[3] === 0) {
290
- return 'utf-32le';
291
- }
292
- if (b[0] === 0 && b[1] === 0 && b[2] === 0xFE && b[3] === 0xFF) {
293
- return 'utf-32be';
294
- }
295
- }
296
-
297
- if (b[0] !== 0 || b[1] > 0x10) invalidBE++;
298
- if (b[3] !== 0 || b[2] > 0x10) invalidLE++;
299
-
300
- if (b[0] === 0 && b[1] === 0 && (b[2] !== 0 || b[3] !== 0)) bmpCharsBE++;
301
- if ((b[0] !== 0 || b[1] !== 0) && b[2] === 0 && b[3] === 0) bmpCharsLE++;
302
-
303
- b.length = 0;
304
- charsProcessed++;
305
-
306
- if (charsProcessed >= 100) {
307
- break outer_loop;
308
- }
309
- }
310
- }
311
- }
312
-
313
- // Make decisions.
314
- if (bmpCharsBE - invalidBE > bmpCharsLE - invalidLE) return 'utf-32be';
315
- if (bmpCharsBE - invalidBE < bmpCharsLE - invalidLE) return 'utf-32le';
316
-
317
- // Couldn't decide (likely all zeros or not enough data).
318
- return defaultEncoding || 'utf-32le';
319
- }