@netlify/plugin-nextjs 4.40.0 → 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 +4 -2
- package/lib/templates/getHandler.js +1 -2
- package/lib/templates/handlerUtils.js +14 -1
- package/lib/templates/server.js +9 -8
- 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,66 @@
|
|
|
1
|
+
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
|
2
|
+
/* Copyright 1998 by the Massachusetts Institute of Technology.
|
|
3
|
+
*
|
|
4
|
+
* Permission to use, copy, modify, and distribute this
|
|
5
|
+
* software and its documentation for any purpose and without
|
|
6
|
+
* fee is hereby granted, provided that the above copyright
|
|
7
|
+
* notice appear in all copies and that both that copyright
|
|
8
|
+
* notice and this permission notice appear in supporting
|
|
9
|
+
* documentation, and that the name of M.I.T. not be used in
|
|
10
|
+
* advertising or publicity pertaining to distribution of the
|
|
11
|
+
* software without specific, written prior permission.
|
|
12
|
+
* M.I.T. makes no representations about the suitability of
|
|
13
|
+
* this software for any purpose. It is provided "as is"
|
|
14
|
+
* without express or implied warranty.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
// REF: https://github.com/nodejs/node/blob/master/deps/cares/include/ares.h#L190
|
|
18
|
+
|
|
19
|
+
export const ARES_AI_CANONNAME = 1 << 0;
|
|
20
|
+
export const ARES_AI_NUMERICHOST = 1 << 1;
|
|
21
|
+
export const ARES_AI_PASSIVE = 1 << 2;
|
|
22
|
+
export const ARES_AI_NUMERICSERV = 1 << 3;
|
|
23
|
+
export const AI_V4MAPPED = 1 << 4;
|
|
24
|
+
export const AI_ALL = 1 << 5;
|
|
25
|
+
export const AI_ADDRCONFIG = 1 << 6;
|
|
26
|
+
export const ARES_AI_NOSORT = 1 << 7;
|
|
27
|
+
export const ARES_AI_ENVHOSTS = 1 << 8;
|
|
28
|
+
|
|
29
|
+
// REF: https://github.com/nodejs/node/blob/master/deps/cares/src/lib/ares_strerror.c
|
|
30
|
+
|
|
31
|
+
export function ares_strerror(code: number) {
|
|
32
|
+
/* Return a string literal from a table. */
|
|
33
|
+
const errorText = [
|
|
34
|
+
"Successful completion",
|
|
35
|
+
"DNS server returned answer with no data",
|
|
36
|
+
"DNS server claims query was misformatted",
|
|
37
|
+
"DNS server returned general failure",
|
|
38
|
+
"Domain name not found",
|
|
39
|
+
"DNS server does not implement requested operation",
|
|
40
|
+
"DNS server refused query",
|
|
41
|
+
"Misformatted DNS query",
|
|
42
|
+
"Misformatted domain name",
|
|
43
|
+
"Unsupported address family",
|
|
44
|
+
"Misformatted DNS reply",
|
|
45
|
+
"Could not contact DNS servers",
|
|
46
|
+
"Timeout while contacting DNS servers",
|
|
47
|
+
"End of file",
|
|
48
|
+
"Error reading file",
|
|
49
|
+
"Out of memory",
|
|
50
|
+
"Channel is being destroyed",
|
|
51
|
+
"Misformatted string",
|
|
52
|
+
"Illegal flags specified",
|
|
53
|
+
"Given hostname is not numeric",
|
|
54
|
+
"Illegal hints flags specified",
|
|
55
|
+
"c-ares library initialization not yet performed",
|
|
56
|
+
"Error loading iphlpapi.dll",
|
|
57
|
+
"Could not find GetNetworkParams function",
|
|
58
|
+
"DNS query cancelled",
|
|
59
|
+
];
|
|
60
|
+
|
|
61
|
+
if (code >= 0 && code < errorText.length) {
|
|
62
|
+
return errorText[code];
|
|
63
|
+
} else {
|
|
64
|
+
return "unknown";
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -0,0 +1,152 @@
|
|
|
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/async_wrap-inl.h
|
|
25
|
+
// - https://github.com/nodejs/node/blob/master/src/async_wrap.cc
|
|
26
|
+
// - https://github.com/nodejs/node/blob/master/src/async_wrap.h
|
|
27
|
+
|
|
28
|
+
export function registerDestroyHook(
|
|
29
|
+
// deno-lint-ignore no-explicit-any
|
|
30
|
+
_target: any,
|
|
31
|
+
_asyncId: number,
|
|
32
|
+
_prop: { destroyed: boolean },
|
|
33
|
+
) {
|
|
34
|
+
// TODO(kt3k): implement actual procedures
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export enum constants {
|
|
38
|
+
kInit,
|
|
39
|
+
kBefore,
|
|
40
|
+
kAfter,
|
|
41
|
+
kDestroy,
|
|
42
|
+
kPromiseResolve,
|
|
43
|
+
kTotals,
|
|
44
|
+
kCheck,
|
|
45
|
+
kExecutionAsyncId,
|
|
46
|
+
kTriggerAsyncId,
|
|
47
|
+
kAsyncIdCounter,
|
|
48
|
+
kDefaultTriggerAsyncId,
|
|
49
|
+
kUsesExecutionAsyncResource,
|
|
50
|
+
kStackLength,
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const asyncHookFields = new Uint32Array(Object.keys(constants).length);
|
|
54
|
+
|
|
55
|
+
export { asyncHookFields as async_hook_fields };
|
|
56
|
+
|
|
57
|
+
// Increment the internal id counter and return the value.
|
|
58
|
+
export function newAsyncId() {
|
|
59
|
+
return ++asyncIdFields[constants.kAsyncIdCounter];
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export enum UidFields {
|
|
63
|
+
kExecutionAsyncId,
|
|
64
|
+
kTriggerAsyncId,
|
|
65
|
+
kAsyncIdCounter,
|
|
66
|
+
kDefaultTriggerAsyncId,
|
|
67
|
+
kUidFieldsCount,
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const asyncIdFields = new Float64Array(Object.keys(UidFields).length);
|
|
71
|
+
|
|
72
|
+
// `kAsyncIdCounter` should start at `1` because that'll be the id the execution
|
|
73
|
+
// context during bootstrap.
|
|
74
|
+
asyncIdFields[UidFields.kAsyncIdCounter] = 1;
|
|
75
|
+
|
|
76
|
+
// `kDefaultTriggerAsyncId` should be `-1`, this indicates that there is no
|
|
77
|
+
// specified default value and it should fallback to the executionAsyncId.
|
|
78
|
+
// 0 is not used as the magic value, because that indicates a missing
|
|
79
|
+
// context which is different from a default context.
|
|
80
|
+
asyncIdFields[UidFields.kDefaultTriggerAsyncId] = -1;
|
|
81
|
+
|
|
82
|
+
export { asyncIdFields };
|
|
83
|
+
|
|
84
|
+
export enum providerType {
|
|
85
|
+
NONE,
|
|
86
|
+
DIRHANDLE,
|
|
87
|
+
DNSCHANNEL,
|
|
88
|
+
ELDHISTOGRAM,
|
|
89
|
+
FILEHANDLE,
|
|
90
|
+
FILEHANDLECLOSEREQ,
|
|
91
|
+
FIXEDSIZEBLOBCOPY,
|
|
92
|
+
FSEVENTWRAP,
|
|
93
|
+
FSREQCALLBACK,
|
|
94
|
+
FSREQPROMISE,
|
|
95
|
+
GETADDRINFOREQWRAP,
|
|
96
|
+
GETNAMEINFOREQWRAP,
|
|
97
|
+
HEAPSNAPSHOT,
|
|
98
|
+
HTTP2SESSION,
|
|
99
|
+
HTTP2STREAM,
|
|
100
|
+
HTTP2PING,
|
|
101
|
+
HTTP2SETTINGS,
|
|
102
|
+
HTTPINCOMINGMESSAGE,
|
|
103
|
+
HTTPCLIENTREQUEST,
|
|
104
|
+
JSSTREAM,
|
|
105
|
+
JSUDPWRAP,
|
|
106
|
+
MESSAGEPORT,
|
|
107
|
+
PIPECONNECTWRAP,
|
|
108
|
+
PIPESERVERWRAP,
|
|
109
|
+
PIPEWRAP,
|
|
110
|
+
PROCESSWRAP,
|
|
111
|
+
PROMISE,
|
|
112
|
+
QUERYWRAP,
|
|
113
|
+
SHUTDOWNWRAP,
|
|
114
|
+
SIGNALWRAP,
|
|
115
|
+
STATWATCHER,
|
|
116
|
+
STREAMPIPE,
|
|
117
|
+
TCPCONNECTWRAP,
|
|
118
|
+
TCPSERVERWRAP,
|
|
119
|
+
TCPWRAP,
|
|
120
|
+
TTYWRAP,
|
|
121
|
+
UDPSENDWRAP,
|
|
122
|
+
UDPWRAP,
|
|
123
|
+
SIGINTWATCHDOG,
|
|
124
|
+
WORKER,
|
|
125
|
+
WORKERHEAPSNAPSHOT,
|
|
126
|
+
WRITEWRAP,
|
|
127
|
+
ZLIB,
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const kInvalidAsyncId = -1;
|
|
131
|
+
|
|
132
|
+
export class AsyncWrap {
|
|
133
|
+
provider: providerType = providerType.NONE;
|
|
134
|
+
asyncId = kInvalidAsyncId;
|
|
135
|
+
|
|
136
|
+
constructor(provider: providerType) {
|
|
137
|
+
this.provider = provider;
|
|
138
|
+
this.getAsyncId();
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
getAsyncId(): number {
|
|
142
|
+
this.asyncId = this.asyncId === kInvalidAsyncId
|
|
143
|
+
? newAsyncId()
|
|
144
|
+
: this.asyncId;
|
|
145
|
+
|
|
146
|
+
return this.asyncId;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
getProviderType() {
|
|
150
|
+
return this.provider;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
|
2
|
+
import { Encodings } from "./_node.ts";
|
|
3
|
+
import { indexOfNeedle } from "../../bytes/index_of_needle.ts";
|
|
4
|
+
|
|
5
|
+
export function numberToBytes(n: number): Uint8Array {
|
|
6
|
+
if (n === 0) return new Uint8Array([0]);
|
|
7
|
+
|
|
8
|
+
const bytes = [];
|
|
9
|
+
bytes.unshift(n & 255);
|
|
10
|
+
while (n >= 256) {
|
|
11
|
+
n = n >>> 8;
|
|
12
|
+
bytes.unshift(n & 255);
|
|
13
|
+
}
|
|
14
|
+
return new Uint8Array(bytes);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// TODO(Soremwar)
|
|
18
|
+
// Check if offset or buffer can be transform in order to just use std's lastIndexOf directly
|
|
19
|
+
// This implementation differs from std's lastIndexOf in the fact that
|
|
20
|
+
// it also includes items outside of the offset as long as part of the
|
|
21
|
+
// set is contained inside of the offset
|
|
22
|
+
// Probably way slower too
|
|
23
|
+
function findLastIndex(
|
|
24
|
+
targetBuffer: Uint8Array,
|
|
25
|
+
buffer: Uint8Array,
|
|
26
|
+
offset: number,
|
|
27
|
+
) {
|
|
28
|
+
offset = offset > targetBuffer.length ? targetBuffer.length : offset;
|
|
29
|
+
|
|
30
|
+
const searchableBuffer = targetBuffer.slice(0, offset + buffer.length);
|
|
31
|
+
const searchableBufferLastIndex = searchableBuffer.length - 1;
|
|
32
|
+
const bufferLastIndex = buffer.length - 1;
|
|
33
|
+
|
|
34
|
+
// Important to keep track of the last match index in order to backtrack after an incomplete match
|
|
35
|
+
// Not doing this will cause the search to skip all possible matches that happened in the
|
|
36
|
+
// last match range
|
|
37
|
+
let lastMatchIndex = -1;
|
|
38
|
+
let matches = 0;
|
|
39
|
+
let index = -1;
|
|
40
|
+
for (let x = 0; x <= searchableBufferLastIndex; x++) {
|
|
41
|
+
if (
|
|
42
|
+
searchableBuffer[searchableBufferLastIndex - x] ===
|
|
43
|
+
buffer[bufferLastIndex - matches]
|
|
44
|
+
) {
|
|
45
|
+
if (lastMatchIndex === -1) {
|
|
46
|
+
lastMatchIndex = x;
|
|
47
|
+
}
|
|
48
|
+
matches++;
|
|
49
|
+
} else {
|
|
50
|
+
matches = 0;
|
|
51
|
+
if (lastMatchIndex !== -1) {
|
|
52
|
+
// Restart the search right after the last index was ignored
|
|
53
|
+
x = lastMatchIndex + 1;
|
|
54
|
+
lastMatchIndex = -1;
|
|
55
|
+
}
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (matches === buffer.length) {
|
|
60
|
+
index = x;
|
|
61
|
+
break;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (index === -1) return index;
|
|
66
|
+
|
|
67
|
+
return searchableBufferLastIndex - index;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// TODO
|
|
71
|
+
// Take encoding into account when evaluating index
|
|
72
|
+
function indexOfBuffer(
|
|
73
|
+
targetBuffer: Uint8Array,
|
|
74
|
+
buffer: Uint8Array,
|
|
75
|
+
byteOffset: number,
|
|
76
|
+
encoding: Encodings,
|
|
77
|
+
forwardDirection: boolean,
|
|
78
|
+
) {
|
|
79
|
+
if (!Encodings[encoding] === undefined) {
|
|
80
|
+
throw new Error(`Unknown encoding code ${encoding}`);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (!forwardDirection) {
|
|
84
|
+
// If negative the offset is calculated from the end of the buffer
|
|
85
|
+
|
|
86
|
+
if (byteOffset < 0) {
|
|
87
|
+
byteOffset = targetBuffer.length + byteOffset;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (buffer.length === 0) {
|
|
91
|
+
return byteOffset <= targetBuffer.length
|
|
92
|
+
? byteOffset
|
|
93
|
+
: targetBuffer.length;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return findLastIndex(targetBuffer, buffer, byteOffset);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (buffer.length === 0) {
|
|
100
|
+
return byteOffset <= targetBuffer.length ? byteOffset : targetBuffer.length;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return indexOfNeedle(targetBuffer, buffer, byteOffset);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// TODO(Soremwar)
|
|
107
|
+
// Node's implementation is a very obscure algorithm that I haven't been able to crack just yet
|
|
108
|
+
function indexOfNumber(
|
|
109
|
+
targetBuffer: Uint8Array,
|
|
110
|
+
number: number,
|
|
111
|
+
byteOffset: number,
|
|
112
|
+
forwardDirection: boolean,
|
|
113
|
+
) {
|
|
114
|
+
const bytes = numberToBytes(number);
|
|
115
|
+
|
|
116
|
+
if (bytes.length > 1) {
|
|
117
|
+
throw new Error("Multi byte number search is not supported");
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
return indexOfBuffer(
|
|
121
|
+
targetBuffer,
|
|
122
|
+
numberToBytes(number),
|
|
123
|
+
byteOffset,
|
|
124
|
+
Encodings.UTF8,
|
|
125
|
+
forwardDirection,
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export default { indexOfBuffer, indexOfNumber };
|
|
130
|
+
export { indexOfBuffer, indexOfNumber };
|