@netlify/plugin-nextjs 4.40.1 → 4.40.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.
- package/lib/helpers/edge.js +1 -0
- package/lib/templates/vendor.js +20 -0
- package/package.json +7 -4
- package/src/templates/edge/next-dev.js +3 -3
- package/src/templates/edge/shims.js +6 -6
- package/src/templates/edge-shared/next-utils.ts +3 -3
- package/src/templates/edge-shared/utils.ts +1 -1
- package/src/templates/vendor/deno.land/std@0.134.0/fmt/colors.ts +536 -0
- package/src/templates/vendor/deno.land/std@0.134.0/testing/_diff.ts +360 -0
- package/src/templates/vendor/deno.land/std@0.134.0/testing/asserts.ts +866 -0
- package/src/templates/vendor/deno.land/std@0.175.0/_util/asserts.ts +25 -0
- package/src/templates/vendor/deno.land/std@0.175.0/_util/os.ts +23 -0
- package/src/templates/vendor/deno.land/std@0.175.0/async/abortable.ts +149 -0
- package/src/templates/vendor/deno.land/std@0.175.0/async/deadline.ts +30 -0
- package/src/templates/vendor/deno.land/std@0.175.0/async/debounce.ts +79 -0
- package/src/templates/vendor/deno.land/std@0.175.0/async/deferred.ts +48 -0
- package/src/templates/vendor/deno.land/std@0.175.0/async/delay.ts +67 -0
- package/src/templates/vendor/deno.land/std@0.175.0/async/mod.ts +18 -0
- package/src/templates/vendor/deno.land/std@0.175.0/async/mux_async_iterator.ts +97 -0
- package/src/templates/vendor/deno.land/std@0.175.0/async/pool.ts +95 -0
- package/src/templates/vendor/deno.land/std@0.175.0/async/retry.ts +81 -0
- package/src/templates/vendor/deno.land/std@0.175.0/async/tee.ts +100 -0
- package/src/templates/vendor/deno.land/std@0.175.0/bytes/index_of_needle.ts +49 -0
- package/src/templates/vendor/deno.land/std@0.175.0/crypto/timing_safe_equal.ts +29 -0
- package/src/templates/vendor/deno.land/std@0.175.0/datetime/to_imf.ts +45 -0
- package/src/templates/vendor/deno.land/std@0.175.0/encoding/base64.ts +144 -0
- package/src/templates/vendor/deno.land/std@0.175.0/encoding/base64url.ts +70 -0
- package/src/templates/vendor/deno.land/std@0.175.0/flags/mod.ts +785 -0
- package/src/templates/vendor/deno.land/std@0.175.0/fmt/colors.ts +569 -0
- package/src/templates/vendor/deno.land/std@0.175.0/fmt/printf.ts +939 -0
- package/src/templates/vendor/deno.land/std@0.175.0/http/cookie.ts +403 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/_core.ts +77 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/_events.d.ts +848 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/_events.mjs +1033 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/_global.d.ts +66 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/_next_tick.ts +173 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/_process/exiting.ts +4 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/_process/process.ts +131 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/_process/stdio.mjs +7 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/_process/streams.mjs +146 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/_stream.d.ts +1488 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/_stream.mjs +746 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/_util/_util_callbackify.ts +129 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/_utils.ts +206 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/assert.ts +940 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/assertion_error.ts +579 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/async_hooks.ts +331 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/buffer.ts +13 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/events.ts +14 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal/buffer.d.ts +2074 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal/buffer.mjs +2607 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal/crypto/_keys.ts +16 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal/crypto/constants.ts +5 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal/error_codes.ts +7 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal/errors.ts +2867 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal/fixed_queue.ts +123 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal/hide_stack_frames.ts +16 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal/net.ts +95 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal/normalize_encoding.mjs +72 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal/options.ts +45 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal/primordials.mjs +30 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal/process/per_thread.mjs +272 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal/readline/callbacks.mjs +137 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal/readline/utils.mjs +580 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal/streams/destroy.mjs +320 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal/streams/end-of-stream.mjs +229 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal/streams/utils.mjs +242 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal/util/comparisons.ts +669 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal/util/debuglog.ts +118 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal/util/inspect.mjs +2237 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal/util/types.ts +113 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal/util.mjs +143 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal/validators.mjs +317 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/_libuv_winerror.ts +229 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/_listen.ts +16 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/_node.ts +18 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/_timingSafeEqual.ts +12 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/_utils.ts +86 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/_winerror.ts +16873 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/ares.ts +66 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/async_wrap.ts +152 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/buffer.ts +130 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/cares_wrap.ts +541 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/config.ts +3 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/connection_wrap.ts +80 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/constants.ts +900 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/contextify.ts +3 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/credentials.ts +3 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/crypto.ts +14 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/errors.ts +3 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/fs.ts +3 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/fs_dir.ts +3 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/fs_event_wrap.ts +3 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/handle_wrap.ts +50 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/heap_utils.ts +3 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/http_parser.ts +3 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/icu.ts +3 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/inspector.ts +3 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/js_stream.ts +3 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/messaging.ts +3 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/mod.ts +108 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/module_wrap.ts +3 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/native_module.ts +3 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/natives.ts +3 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/node_file.ts +84 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/node_options.ts +39 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/options.ts +3 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/os.ts +3 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/performance.ts +3 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/pipe_wrap.ts +392 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/process_methods.ts +3 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/report.ts +3 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/serdes.ts +3 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/signal_wrap.ts +3 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/spawn_sync.ts +3 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/stream_wrap.ts +354 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/string_decoder.ts +15 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/symbols.ts +27 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/task_queue.ts +3 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/tcp_wrap.ts +488 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/timers.ts +3 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/tls_wrap.ts +3 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/trace_events.ts +3 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/tty_wrap.ts +3 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/types.ts +186 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/udp_wrap.ts +496 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/url.ts +3 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/util.ts +126 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/uv.ts +437 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/v8.ts +3 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/worker.ts +3 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/zlib.ts +3 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/process.ts +705 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/stream.ts +37 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/string_decoder.ts +337 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/util/types.ts +4 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/util.ts +289 -0
- package/src/templates/vendor/deno.land/std@0.175.0/path/_constants.ts +49 -0
- package/src/templates/vendor/deno.land/std@0.175.0/path/_interface.ts +30 -0
- package/src/templates/vendor/deno.land/std@0.175.0/path/_util.ts +194 -0
- package/src/templates/vendor/deno.land/std@0.175.0/path/common.ts +40 -0
- package/src/templates/vendor/deno.land/std@0.175.0/path/glob.ts +418 -0
- package/src/templates/vendor/deno.land/std@0.175.0/path/mod.ts +53 -0
- package/src/templates/vendor/deno.land/std@0.175.0/path/posix.ts +487 -0
- package/src/templates/vendor/deno.land/std@0.175.0/path/separator.ts +7 -0
- package/src/templates/vendor/deno.land/std@0.175.0/path/win32.ts +962 -0
- package/src/templates/vendor/deno.land/std@0.175.0/streams/write_all.ts +64 -0
- package/src/templates/vendor/deno.land/std@0.175.0/testing/_diff.ts +440 -0
- package/src/templates/vendor/deno.land/std@0.175.0/testing/_format.ts +23 -0
- package/src/templates/vendor/deno.land/std@0.175.0/testing/asserts.ts +906 -0
- package/src/templates/vendor/deno.land/std@0.175.0/types.d.ts +89 -0
- package/src/templates/vendor/deno.land/x/html_rewriter@v0.1.0-pre.17/index.ts +133 -0
- package/src/templates/vendor/deno.land/x/html_rewriter@v0.1.0-pre.17/vendor/asyncify.js +112 -0
- package/src/templates/vendor/deno.land/x/html_rewriter@v0.1.0-pre.17/vendor/html_rewriter.d.ts +88 -0
- package/src/templates/vendor/deno.land/x/html_rewriter@v0.1.0-pre.17/vendor/html_rewriter.js +974 -0
- package/src/templates/vendor/deno.land/x/path_to_regexp@v6.2.1/index.ts +621 -0
- package/src/templates/vendor/esm.sh/v91/next@12.2.5/deno/dist/compiled/cookie.js +13 -0
- package/src/templates/vendor/esm.sh/v91/next@12.2.5/deno/dist/server/web/spec-extension/request.js +12 -0
- package/src/templates/vendor/esm.sh/v91/next@12.2.5/deno/dist/server/web/spec-extension/response.js +5 -0
- package/src/templates/vendor/import_map.json +13 -0
- package/src/templates/vendor/raw.githubusercontent.com/worker-tools/resolvable-promise/master/index.ts +50 -0
|
@@ -0,0 +1,354 @@
|
|
|
1
|
+
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
|
2
|
+
// Copyright Joyent, Inc. and other Node contributors.
|
|
3
|
+
//
|
|
4
|
+
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
5
|
+
// copy of this software and associated documentation files (the
|
|
6
|
+
// "Software"), to deal in the Software without restriction, including
|
|
7
|
+
// without limitation the rights to use, copy, modify, merge, publish,
|
|
8
|
+
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
9
|
+
// persons to whom the Software is furnished to do so, subject to the
|
|
10
|
+
// following conditions:
|
|
11
|
+
//
|
|
12
|
+
// The above copyright notice and this permission notice shall be included
|
|
13
|
+
// in all copies or substantial portions of the Software.
|
|
14
|
+
//
|
|
15
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
16
|
+
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
17
|
+
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|
18
|
+
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
19
|
+
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
20
|
+
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
21
|
+
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
22
|
+
|
|
23
|
+
// This module ports:
|
|
24
|
+
// - https://github.com/nodejs/node/blob/master/src/stream_base-inl.h
|
|
25
|
+
// - https://github.com/nodejs/node/blob/master/src/stream_base.h
|
|
26
|
+
// - https://github.com/nodejs/node/blob/master/src/stream_base.cc
|
|
27
|
+
// - https://github.com/nodejs/node/blob/master/src/stream_wrap.h
|
|
28
|
+
// - https://github.com/nodejs/node/blob/master/src/stream_wrap.cc
|
|
29
|
+
|
|
30
|
+
import { Buffer } from "../buffer.ts";
|
|
31
|
+
import { notImplemented } from "../_utils.ts";
|
|
32
|
+
import { HandleWrap } from "./handle_wrap.ts";
|
|
33
|
+
import { AsyncWrap, providerType } from "./async_wrap.ts";
|
|
34
|
+
import { codeMap } from "./uv.ts";
|
|
35
|
+
import { writeAll } from "../../streams/write_all.ts";
|
|
36
|
+
import type { Closer, Reader, Writer } from "../../types.d.ts";
|
|
37
|
+
|
|
38
|
+
type Ref = { ref(): void; unref(): void };
|
|
39
|
+
|
|
40
|
+
enum StreamBaseStateFields {
|
|
41
|
+
kReadBytesOrError,
|
|
42
|
+
kArrayBufferOffset,
|
|
43
|
+
kBytesWritten,
|
|
44
|
+
kLastWriteWasAsync,
|
|
45
|
+
kNumStreamBaseStateFields,
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export const kReadBytesOrError = StreamBaseStateFields.kReadBytesOrError;
|
|
49
|
+
export const kArrayBufferOffset = StreamBaseStateFields.kArrayBufferOffset;
|
|
50
|
+
export const kBytesWritten = StreamBaseStateFields.kBytesWritten;
|
|
51
|
+
export const kLastWriteWasAsync = StreamBaseStateFields.kLastWriteWasAsync;
|
|
52
|
+
export const kNumStreamBaseStateFields =
|
|
53
|
+
StreamBaseStateFields.kNumStreamBaseStateFields;
|
|
54
|
+
|
|
55
|
+
export const streamBaseState = new Uint8Array(5);
|
|
56
|
+
|
|
57
|
+
// This is Deno, it always will be async.
|
|
58
|
+
streamBaseState[kLastWriteWasAsync] = 1;
|
|
59
|
+
|
|
60
|
+
export class WriteWrap<H extends HandleWrap> extends AsyncWrap {
|
|
61
|
+
handle!: H;
|
|
62
|
+
oncomplete!: (status: number) => void;
|
|
63
|
+
async!: boolean;
|
|
64
|
+
bytes!: number;
|
|
65
|
+
buffer!: unknown;
|
|
66
|
+
callback!: unknown;
|
|
67
|
+
_chunks!: unknown[];
|
|
68
|
+
|
|
69
|
+
constructor() {
|
|
70
|
+
super(providerType.WRITEWRAP);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export class ShutdownWrap<H extends HandleWrap> extends AsyncWrap {
|
|
75
|
+
handle!: H;
|
|
76
|
+
oncomplete!: (status: number) => void;
|
|
77
|
+
callback!: () => void;
|
|
78
|
+
|
|
79
|
+
constructor() {
|
|
80
|
+
super(providerType.SHUTDOWNWRAP);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export const kStreamBaseField = Symbol("kStreamBaseField");
|
|
85
|
+
|
|
86
|
+
const SUGGESTED_SIZE = 64 * 1024;
|
|
87
|
+
|
|
88
|
+
export class LibuvStreamWrap extends HandleWrap {
|
|
89
|
+
[kStreamBaseField]?: Reader & Writer & Closer & Ref;
|
|
90
|
+
|
|
91
|
+
reading!: boolean;
|
|
92
|
+
#reading = false;
|
|
93
|
+
destroyed = false;
|
|
94
|
+
writeQueueSize = 0;
|
|
95
|
+
bytesRead = 0;
|
|
96
|
+
bytesWritten = 0;
|
|
97
|
+
|
|
98
|
+
onread!: (_arrayBuffer: Uint8Array, _nread: number) => Uint8Array | undefined;
|
|
99
|
+
|
|
100
|
+
constructor(
|
|
101
|
+
provider: providerType,
|
|
102
|
+
stream?: Reader & Writer & Closer & Ref,
|
|
103
|
+
) {
|
|
104
|
+
super(provider);
|
|
105
|
+
this.#attachToObject(stream);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Start the reading of the stream.
|
|
110
|
+
* @return An error status code.
|
|
111
|
+
*/
|
|
112
|
+
readStart(): number {
|
|
113
|
+
if (!this.#reading) {
|
|
114
|
+
this.#reading = true;
|
|
115
|
+
this.#read();
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return 0;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Stop the reading of the stream.
|
|
123
|
+
* @return An error status code.
|
|
124
|
+
*/
|
|
125
|
+
readStop(): number {
|
|
126
|
+
this.#reading = false;
|
|
127
|
+
|
|
128
|
+
return 0;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Shutdown the stream.
|
|
133
|
+
* @param req A shutdown request wrapper.
|
|
134
|
+
* @return An error status code.
|
|
135
|
+
*/
|
|
136
|
+
shutdown(req: ShutdownWrap<LibuvStreamWrap>): number {
|
|
137
|
+
const status = this._onClose();
|
|
138
|
+
|
|
139
|
+
try {
|
|
140
|
+
req.oncomplete(status);
|
|
141
|
+
} catch {
|
|
142
|
+
// swallow callback error.
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
return 0;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* @param userBuf
|
|
150
|
+
* @return An error status code.
|
|
151
|
+
*/
|
|
152
|
+
useUserBuffer(_userBuf: unknown): number {
|
|
153
|
+
// TODO(cmorten)
|
|
154
|
+
notImplemented("LibuvStreamWrap.prototype.useUserBuffer");
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Write a buffer to the stream.
|
|
159
|
+
* @param req A write request wrapper.
|
|
160
|
+
* @param data The Uint8Array buffer to write to the stream.
|
|
161
|
+
* @return An error status code.
|
|
162
|
+
*/
|
|
163
|
+
writeBuffer(req: WriteWrap<LibuvStreamWrap>, data: Uint8Array): number {
|
|
164
|
+
this.#write(req, data);
|
|
165
|
+
|
|
166
|
+
return 0;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Write multiple chunks at once.
|
|
171
|
+
* @param req A write request wrapper.
|
|
172
|
+
* @param chunks
|
|
173
|
+
* @param allBuffers
|
|
174
|
+
* @return An error status code.
|
|
175
|
+
*/
|
|
176
|
+
writev(
|
|
177
|
+
req: WriteWrap<LibuvStreamWrap>,
|
|
178
|
+
chunks: Buffer[] | (string | Buffer)[],
|
|
179
|
+
allBuffers: boolean,
|
|
180
|
+
): number {
|
|
181
|
+
const count = allBuffers ? chunks.length : chunks.length >> 1;
|
|
182
|
+
const buffers: Buffer[] = new Array(count);
|
|
183
|
+
|
|
184
|
+
if (!allBuffers) {
|
|
185
|
+
for (let i = 0; i < count; i++) {
|
|
186
|
+
const chunk = chunks[i * 2];
|
|
187
|
+
|
|
188
|
+
if (Buffer.isBuffer(chunk)) {
|
|
189
|
+
buffers[i] = chunk;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// String chunk
|
|
193
|
+
const encoding: string = chunks[i * 2 + 1] as string;
|
|
194
|
+
buffers[i] = Buffer.from(chunk as string, encoding);
|
|
195
|
+
}
|
|
196
|
+
} else {
|
|
197
|
+
for (let i = 0; i < count; i++) {
|
|
198
|
+
buffers[i] = chunks[i] as Buffer;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
return this.writeBuffer(req, Buffer.concat(buffers));
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Write an ASCII string to the stream.
|
|
207
|
+
* @return An error status code.
|
|
208
|
+
*/
|
|
209
|
+
writeAsciiString(req: WriteWrap<LibuvStreamWrap>, data: string): number {
|
|
210
|
+
const buffer = new TextEncoder().encode(data);
|
|
211
|
+
|
|
212
|
+
return this.writeBuffer(req, buffer);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* Write an UTF8 string to the stream.
|
|
217
|
+
* @return An error status code.
|
|
218
|
+
*/
|
|
219
|
+
writeUtf8String(req: WriteWrap<LibuvStreamWrap>, data: string): number {
|
|
220
|
+
const buffer = new TextEncoder().encode(data);
|
|
221
|
+
|
|
222
|
+
return this.writeBuffer(req, buffer);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Write an UCS2 string to the stream.
|
|
227
|
+
* @return An error status code.
|
|
228
|
+
*/
|
|
229
|
+
writeUcs2String(_req: WriteWrap<LibuvStreamWrap>, _data: string): number {
|
|
230
|
+
notImplemented("LibuvStreamWrap.prototype.writeUcs2String");
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* Write an LATIN1 string to the stream.
|
|
235
|
+
* @return An error status code.
|
|
236
|
+
*/
|
|
237
|
+
writeLatin1String(req: WriteWrap<LibuvStreamWrap>, data: string): number {
|
|
238
|
+
const buffer = Buffer.from(data, "latin1");
|
|
239
|
+
return this.writeBuffer(req, buffer);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
override _onClose(): number {
|
|
243
|
+
let status = 0;
|
|
244
|
+
this.#reading = false;
|
|
245
|
+
|
|
246
|
+
try {
|
|
247
|
+
this[kStreamBaseField]?.close();
|
|
248
|
+
} catch {
|
|
249
|
+
status = codeMap.get("ENOTCONN")!;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
return status;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* Attaches the class to the underlying stream.
|
|
257
|
+
* @param stream The stream to attach to.
|
|
258
|
+
*/
|
|
259
|
+
#attachToObject(stream?: Reader & Writer & Closer & Ref) {
|
|
260
|
+
this[kStreamBaseField] = stream;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/** Internal method for reading from the attached stream. */
|
|
264
|
+
async #read() {
|
|
265
|
+
let buf = new Uint8Array(SUGGESTED_SIZE);
|
|
266
|
+
|
|
267
|
+
let nread: number | null;
|
|
268
|
+
try {
|
|
269
|
+
nread = await this[kStreamBaseField]!.read(buf);
|
|
270
|
+
} catch (e) {
|
|
271
|
+
if (
|
|
272
|
+
e instanceof Deno.errors.Interrupted ||
|
|
273
|
+
e instanceof Deno.errors.BadResource
|
|
274
|
+
) {
|
|
275
|
+
nread = codeMap.get("EOF")!;
|
|
276
|
+
} else if (
|
|
277
|
+
e instanceof Deno.errors.ConnectionReset ||
|
|
278
|
+
e instanceof Deno.errors.ConnectionAborted
|
|
279
|
+
) {
|
|
280
|
+
nread = codeMap.get("ECONNRESET")!;
|
|
281
|
+
} else {
|
|
282
|
+
nread = codeMap.get("UNKNOWN")!;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
buf = new Uint8Array(0);
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
nread ??= codeMap.get("EOF")!;
|
|
289
|
+
|
|
290
|
+
streamBaseState[kReadBytesOrError] = nread;
|
|
291
|
+
|
|
292
|
+
if (nread > 0) {
|
|
293
|
+
this.bytesRead += nread;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
buf = buf.slice(0, nread);
|
|
297
|
+
|
|
298
|
+
streamBaseState[kArrayBufferOffset] = 0;
|
|
299
|
+
|
|
300
|
+
try {
|
|
301
|
+
this.onread!(buf, nread);
|
|
302
|
+
} catch {
|
|
303
|
+
// swallow callback errors.
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
if (nread >= 0 && this.#reading) {
|
|
307
|
+
this.#read();
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* Internal method for writing to the attached stream.
|
|
313
|
+
* @param req A write request wrapper.
|
|
314
|
+
* @param data The Uint8Array buffer to write to the stream.
|
|
315
|
+
*/
|
|
316
|
+
async #write(req: WriteWrap<LibuvStreamWrap>, data: Uint8Array) {
|
|
317
|
+
const { byteLength } = data;
|
|
318
|
+
|
|
319
|
+
try {
|
|
320
|
+
await writeAll(this[kStreamBaseField]!, data);
|
|
321
|
+
} catch (e) {
|
|
322
|
+
let status: number;
|
|
323
|
+
|
|
324
|
+
// TODO(cmorten): map err to status codes
|
|
325
|
+
if (
|
|
326
|
+
e instanceof Deno.errors.BadResource ||
|
|
327
|
+
e instanceof Deno.errors.BrokenPipe
|
|
328
|
+
) {
|
|
329
|
+
status = codeMap.get("EBADF")!;
|
|
330
|
+
} else {
|
|
331
|
+
status = codeMap.get("UNKNOWN")!;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
try {
|
|
335
|
+
req.oncomplete(status);
|
|
336
|
+
} catch {
|
|
337
|
+
// swallow callback errors.
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
return;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
streamBaseState[kBytesWritten] = byteLength;
|
|
344
|
+
this.bytesWritten += byteLength;
|
|
345
|
+
|
|
346
|
+
try {
|
|
347
|
+
req.oncomplete(0);
|
|
348
|
+
} catch {
|
|
349
|
+
// swallow callback errors.
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
return;
|
|
353
|
+
}
|
|
354
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
|
2
|
+
import { Encodings } from "./_node.ts";
|
|
3
|
+
|
|
4
|
+
const encodings = [];
|
|
5
|
+
encodings[Encodings.ASCII] = "ascii";
|
|
6
|
+
encodings[Encodings.BASE64] = "base64";
|
|
7
|
+
encodings[Encodings.BASE64URL] = "base64url";
|
|
8
|
+
encodings[Encodings.BUFFER] = "buffer";
|
|
9
|
+
encodings[Encodings.HEX] = "hex";
|
|
10
|
+
encodings[Encodings.LATIN1] = "latin1";
|
|
11
|
+
encodings[Encodings.UCS2] = "utf16le";
|
|
12
|
+
encodings[Encodings.UTF8] = "utf8";
|
|
13
|
+
|
|
14
|
+
export default { encodings };
|
|
15
|
+
export { encodings };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
|
2
|
+
// Copyright Joyent, Inc. and other Node contributors.
|
|
3
|
+
//
|
|
4
|
+
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
5
|
+
// copy of this software and associated documentation files (the
|
|
6
|
+
// "Software"), to deal in the Software without restriction, including
|
|
7
|
+
// without limitation the rights to use, copy, modify, merge, publish,
|
|
8
|
+
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
9
|
+
// persons to whom the Software is furnished to do so, subject to the
|
|
10
|
+
// following conditions:
|
|
11
|
+
//
|
|
12
|
+
// The above copyright notice and this permission notice shall be included
|
|
13
|
+
// in all copies or substantial portions of the Software.
|
|
14
|
+
//
|
|
15
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
16
|
+
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
17
|
+
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|
18
|
+
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
19
|
+
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
20
|
+
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
21
|
+
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
22
|
+
|
|
23
|
+
// This module ports:
|
|
24
|
+
// - https://github.com/nodejs/node/blob/master/src/node_symbols.cc
|
|
25
|
+
|
|
26
|
+
export const asyncIdSymbol: unique symbol = Symbol("asyncIdSymbol");
|
|
27
|
+
export const ownerSymbol: unique symbol = Symbol("ownerSymbol");
|