@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.
Files changed (164) hide show
  1. package/lib/helpers/edge.js +4 -2
  2. package/lib/templates/getHandler.js +1 -2
  3. package/lib/templates/handlerUtils.js +14 -1
  4. package/lib/templates/server.js +9 -8
  5. package/lib/templates/vendor.js +20 -0
  6. package/package.json +7 -4
  7. package/src/templates/edge/next-dev.js +3 -3
  8. package/src/templates/edge/shims.js +6 -6
  9. package/src/templates/edge-shared/next-utils.ts +3 -3
  10. package/src/templates/edge-shared/utils.ts +1 -1
  11. package/src/templates/vendor/deno.land/std@0.134.0/fmt/colors.ts +536 -0
  12. package/src/templates/vendor/deno.land/std@0.134.0/testing/_diff.ts +360 -0
  13. package/src/templates/vendor/deno.land/std@0.134.0/testing/asserts.ts +866 -0
  14. package/src/templates/vendor/deno.land/std@0.175.0/_util/asserts.ts +25 -0
  15. package/src/templates/vendor/deno.land/std@0.175.0/_util/os.ts +23 -0
  16. package/src/templates/vendor/deno.land/std@0.175.0/async/abortable.ts +149 -0
  17. package/src/templates/vendor/deno.land/std@0.175.0/async/deadline.ts +30 -0
  18. package/src/templates/vendor/deno.land/std@0.175.0/async/debounce.ts +79 -0
  19. package/src/templates/vendor/deno.land/std@0.175.0/async/deferred.ts +48 -0
  20. package/src/templates/vendor/deno.land/std@0.175.0/async/delay.ts +67 -0
  21. package/src/templates/vendor/deno.land/std@0.175.0/async/mod.ts +18 -0
  22. package/src/templates/vendor/deno.land/std@0.175.0/async/mux_async_iterator.ts +97 -0
  23. package/src/templates/vendor/deno.land/std@0.175.0/async/pool.ts +95 -0
  24. package/src/templates/vendor/deno.land/std@0.175.0/async/retry.ts +81 -0
  25. package/src/templates/vendor/deno.land/std@0.175.0/async/tee.ts +100 -0
  26. package/src/templates/vendor/deno.land/std@0.175.0/bytes/index_of_needle.ts +49 -0
  27. package/src/templates/vendor/deno.land/std@0.175.0/crypto/timing_safe_equal.ts +29 -0
  28. package/src/templates/vendor/deno.land/std@0.175.0/datetime/to_imf.ts +45 -0
  29. package/src/templates/vendor/deno.land/std@0.175.0/encoding/base64.ts +144 -0
  30. package/src/templates/vendor/deno.land/std@0.175.0/encoding/base64url.ts +70 -0
  31. package/src/templates/vendor/deno.land/std@0.175.0/flags/mod.ts +785 -0
  32. package/src/templates/vendor/deno.land/std@0.175.0/fmt/colors.ts +569 -0
  33. package/src/templates/vendor/deno.land/std@0.175.0/fmt/printf.ts +939 -0
  34. package/src/templates/vendor/deno.land/std@0.175.0/http/cookie.ts +403 -0
  35. package/src/templates/vendor/deno.land/std@0.175.0/node/_core.ts +77 -0
  36. package/src/templates/vendor/deno.land/std@0.175.0/node/_events.d.ts +848 -0
  37. package/src/templates/vendor/deno.land/std@0.175.0/node/_events.mjs +1033 -0
  38. package/src/templates/vendor/deno.land/std@0.175.0/node/_global.d.ts +66 -0
  39. package/src/templates/vendor/deno.land/std@0.175.0/node/_next_tick.ts +173 -0
  40. package/src/templates/vendor/deno.land/std@0.175.0/node/_process/exiting.ts +4 -0
  41. package/src/templates/vendor/deno.land/std@0.175.0/node/_process/process.ts +131 -0
  42. package/src/templates/vendor/deno.land/std@0.175.0/node/_process/stdio.mjs +7 -0
  43. package/src/templates/vendor/deno.land/std@0.175.0/node/_process/streams.mjs +146 -0
  44. package/src/templates/vendor/deno.land/std@0.175.0/node/_stream.d.ts +1488 -0
  45. package/src/templates/vendor/deno.land/std@0.175.0/node/_stream.mjs +746 -0
  46. package/src/templates/vendor/deno.land/std@0.175.0/node/_util/_util_callbackify.ts +129 -0
  47. package/src/templates/vendor/deno.land/std@0.175.0/node/_utils.ts +206 -0
  48. package/src/templates/vendor/deno.land/std@0.175.0/node/assert.ts +940 -0
  49. package/src/templates/vendor/deno.land/std@0.175.0/node/assertion_error.ts +579 -0
  50. package/src/templates/vendor/deno.land/std@0.175.0/node/async_hooks.ts +331 -0
  51. package/src/templates/vendor/deno.land/std@0.175.0/node/buffer.ts +13 -0
  52. package/src/templates/vendor/deno.land/std@0.175.0/node/events.ts +14 -0
  53. package/src/templates/vendor/deno.land/std@0.175.0/node/internal/buffer.d.ts +2074 -0
  54. package/src/templates/vendor/deno.land/std@0.175.0/node/internal/buffer.mjs +2607 -0
  55. package/src/templates/vendor/deno.land/std@0.175.0/node/internal/crypto/_keys.ts +16 -0
  56. package/src/templates/vendor/deno.land/std@0.175.0/node/internal/crypto/constants.ts +5 -0
  57. package/src/templates/vendor/deno.land/std@0.175.0/node/internal/error_codes.ts +7 -0
  58. package/src/templates/vendor/deno.land/std@0.175.0/node/internal/errors.ts +2867 -0
  59. package/src/templates/vendor/deno.land/std@0.175.0/node/internal/fixed_queue.ts +123 -0
  60. package/src/templates/vendor/deno.land/std@0.175.0/node/internal/hide_stack_frames.ts +16 -0
  61. package/src/templates/vendor/deno.land/std@0.175.0/node/internal/net.ts +95 -0
  62. package/src/templates/vendor/deno.land/std@0.175.0/node/internal/normalize_encoding.mjs +72 -0
  63. package/src/templates/vendor/deno.land/std@0.175.0/node/internal/options.ts +45 -0
  64. package/src/templates/vendor/deno.land/std@0.175.0/node/internal/primordials.mjs +30 -0
  65. package/src/templates/vendor/deno.land/std@0.175.0/node/internal/process/per_thread.mjs +272 -0
  66. package/src/templates/vendor/deno.land/std@0.175.0/node/internal/readline/callbacks.mjs +137 -0
  67. package/src/templates/vendor/deno.land/std@0.175.0/node/internal/readline/utils.mjs +580 -0
  68. package/src/templates/vendor/deno.land/std@0.175.0/node/internal/streams/destroy.mjs +320 -0
  69. package/src/templates/vendor/deno.land/std@0.175.0/node/internal/streams/end-of-stream.mjs +229 -0
  70. package/src/templates/vendor/deno.land/std@0.175.0/node/internal/streams/utils.mjs +242 -0
  71. package/src/templates/vendor/deno.land/std@0.175.0/node/internal/util/comparisons.ts +669 -0
  72. package/src/templates/vendor/deno.land/std@0.175.0/node/internal/util/debuglog.ts +118 -0
  73. package/src/templates/vendor/deno.land/std@0.175.0/node/internal/util/inspect.mjs +2237 -0
  74. package/src/templates/vendor/deno.land/std@0.175.0/node/internal/util/types.ts +113 -0
  75. package/src/templates/vendor/deno.land/std@0.175.0/node/internal/util.mjs +143 -0
  76. package/src/templates/vendor/deno.land/std@0.175.0/node/internal/validators.mjs +317 -0
  77. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/_libuv_winerror.ts +229 -0
  78. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/_listen.ts +16 -0
  79. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/_node.ts +18 -0
  80. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/_timingSafeEqual.ts +12 -0
  81. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/_utils.ts +86 -0
  82. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/_winerror.ts +16873 -0
  83. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/ares.ts +66 -0
  84. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/async_wrap.ts +152 -0
  85. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/buffer.ts +130 -0
  86. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/cares_wrap.ts +541 -0
  87. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/config.ts +3 -0
  88. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/connection_wrap.ts +80 -0
  89. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/constants.ts +900 -0
  90. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/contextify.ts +3 -0
  91. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/credentials.ts +3 -0
  92. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/crypto.ts +14 -0
  93. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/errors.ts +3 -0
  94. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/fs.ts +3 -0
  95. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/fs_dir.ts +3 -0
  96. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/fs_event_wrap.ts +3 -0
  97. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/handle_wrap.ts +50 -0
  98. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/heap_utils.ts +3 -0
  99. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/http_parser.ts +3 -0
  100. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/icu.ts +3 -0
  101. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/inspector.ts +3 -0
  102. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/js_stream.ts +3 -0
  103. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/messaging.ts +3 -0
  104. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/mod.ts +108 -0
  105. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/module_wrap.ts +3 -0
  106. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/native_module.ts +3 -0
  107. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/natives.ts +3 -0
  108. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/node_file.ts +84 -0
  109. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/node_options.ts +39 -0
  110. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/options.ts +3 -0
  111. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/os.ts +3 -0
  112. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/performance.ts +3 -0
  113. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/pipe_wrap.ts +392 -0
  114. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/process_methods.ts +3 -0
  115. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/report.ts +3 -0
  116. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/serdes.ts +3 -0
  117. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/signal_wrap.ts +3 -0
  118. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/spawn_sync.ts +3 -0
  119. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/stream_wrap.ts +354 -0
  120. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/string_decoder.ts +15 -0
  121. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/symbols.ts +27 -0
  122. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/task_queue.ts +3 -0
  123. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/tcp_wrap.ts +488 -0
  124. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/timers.ts +3 -0
  125. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/tls_wrap.ts +3 -0
  126. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/trace_events.ts +3 -0
  127. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/tty_wrap.ts +3 -0
  128. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/types.ts +186 -0
  129. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/udp_wrap.ts +496 -0
  130. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/url.ts +3 -0
  131. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/util.ts +126 -0
  132. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/uv.ts +437 -0
  133. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/v8.ts +3 -0
  134. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/worker.ts +3 -0
  135. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/zlib.ts +3 -0
  136. package/src/templates/vendor/deno.land/std@0.175.0/node/process.ts +705 -0
  137. package/src/templates/vendor/deno.land/std@0.175.0/node/stream.ts +37 -0
  138. package/src/templates/vendor/deno.land/std@0.175.0/node/string_decoder.ts +337 -0
  139. package/src/templates/vendor/deno.land/std@0.175.0/node/util/types.ts +4 -0
  140. package/src/templates/vendor/deno.land/std@0.175.0/node/util.ts +289 -0
  141. package/src/templates/vendor/deno.land/std@0.175.0/path/_constants.ts +49 -0
  142. package/src/templates/vendor/deno.land/std@0.175.0/path/_interface.ts +30 -0
  143. package/src/templates/vendor/deno.land/std@0.175.0/path/_util.ts +194 -0
  144. package/src/templates/vendor/deno.land/std@0.175.0/path/common.ts +40 -0
  145. package/src/templates/vendor/deno.land/std@0.175.0/path/glob.ts +418 -0
  146. package/src/templates/vendor/deno.land/std@0.175.0/path/mod.ts +53 -0
  147. package/src/templates/vendor/deno.land/std@0.175.0/path/posix.ts +487 -0
  148. package/src/templates/vendor/deno.land/std@0.175.0/path/separator.ts +7 -0
  149. package/src/templates/vendor/deno.land/std@0.175.0/path/win32.ts +962 -0
  150. package/src/templates/vendor/deno.land/std@0.175.0/streams/write_all.ts +64 -0
  151. package/src/templates/vendor/deno.land/std@0.175.0/testing/_diff.ts +440 -0
  152. package/src/templates/vendor/deno.land/std@0.175.0/testing/_format.ts +23 -0
  153. package/src/templates/vendor/deno.land/std@0.175.0/testing/asserts.ts +906 -0
  154. package/src/templates/vendor/deno.land/std@0.175.0/types.d.ts +89 -0
  155. package/src/templates/vendor/deno.land/x/html_rewriter@v0.1.0-pre.17/index.ts +133 -0
  156. package/src/templates/vendor/deno.land/x/html_rewriter@v0.1.0-pre.17/vendor/asyncify.js +112 -0
  157. package/src/templates/vendor/deno.land/x/html_rewriter@v0.1.0-pre.17/vendor/html_rewriter.d.ts +88 -0
  158. package/src/templates/vendor/deno.land/x/html_rewriter@v0.1.0-pre.17/vendor/html_rewriter.js +974 -0
  159. package/src/templates/vendor/deno.land/x/path_to_regexp@v6.2.1/index.ts +621 -0
  160. package/src/templates/vendor/esm.sh/v91/next@12.2.5/deno/dist/compiled/cookie.js +13 -0
  161. package/src/templates/vendor/esm.sh/v91/next@12.2.5/deno/dist/server/web/spec-extension/request.js +12 -0
  162. package/src/templates/vendor/esm.sh/v91/next@12.2.5/deno/dist/server/web/spec-extension/response.js +5 -0
  163. package/src/templates/vendor/import_map.json +13 -0
  164. package/src/templates/vendor/raw.githubusercontent.com/worker-tools/resolvable-promise/master/index.ts +50 -0
@@ -0,0 +1,123 @@
1
+ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
2
+ // Copyright Joyent, Inc. and other Node contributors.
3
+
4
+ // Currently optimal queue size, tested on V8 6.0 - 6.6. Must be power of two.
5
+ const kSize = 2048;
6
+ const kMask = kSize - 1;
7
+
8
+ // The FixedQueue is implemented as a singly-linked list of fixed-size
9
+ // circular buffers. It looks something like this:
10
+ //
11
+ // head tail
12
+ // | |
13
+ // v v
14
+ // +-----------+ <-----\ +-----------+ <------\ +-----------+
15
+ // | [null] | \----- | next | \------- | next |
16
+ // +-----------+ +-----------+ +-----------+
17
+ // | item | <-- bottom | item | <-- bottom | [empty] |
18
+ // | item | | item | | [empty] |
19
+ // | item | | item | | [empty] |
20
+ // | item | | item | | [empty] |
21
+ // | item | | item | bottom --> | item |
22
+ // | item | | item | | item |
23
+ // | ... | | ... | | ... |
24
+ // | item | | item | | item |
25
+ // | item | | item | | item |
26
+ // | [empty] | <-- top | item | | item |
27
+ // | [empty] | | item | | item |
28
+ // | [empty] | | [empty] | <-- top top --> | [empty] |
29
+ // +-----------+ +-----------+ +-----------+
30
+ //
31
+ // Or, if there is only one circular buffer, it looks something
32
+ // like either of these:
33
+ //
34
+ // head tail head tail
35
+ // | | | |
36
+ // v v v v
37
+ // +-----------+ +-----------+
38
+ // | [null] | | [null] |
39
+ // +-----------+ +-----------+
40
+ // | [empty] | | item |
41
+ // | [empty] | | item |
42
+ // | item | <-- bottom top --> | [empty] |
43
+ // | item | | [empty] |
44
+ // | [empty] | <-- top bottom --> | item |
45
+ // | [empty] | | item |
46
+ // +-----------+ +-----------+
47
+ //
48
+ // Adding a value means moving `top` forward by one, removing means
49
+ // moving `bottom` forward by one. After reaching the end, the queue
50
+ // wraps around.
51
+ //
52
+ // When `top === bottom` the current queue is empty and when
53
+ // `top + 1 === bottom` it's full. This wastes a single space of storage
54
+ // but allows much quicker checks.
55
+
56
+ class FixedCircularBuffer {
57
+ bottom: number;
58
+ top: number;
59
+ list: undefined | Array<unknown>;
60
+ next: FixedCircularBuffer | null;
61
+
62
+ constructor() {
63
+ this.bottom = 0;
64
+ this.top = 0;
65
+ this.list = new Array(kSize);
66
+ this.next = null;
67
+ }
68
+
69
+ isEmpty() {
70
+ return this.top === this.bottom;
71
+ }
72
+
73
+ isFull() {
74
+ return ((this.top + 1) & kMask) === this.bottom;
75
+ }
76
+
77
+ push(data: unknown) {
78
+ this.list![this.top] = data;
79
+ this.top = (this.top + 1) & kMask;
80
+ }
81
+
82
+ shift() {
83
+ const nextItem = this.list![this.bottom];
84
+ if (nextItem === undefined) {
85
+ return null;
86
+ }
87
+ this.list![this.bottom] = undefined;
88
+ this.bottom = (this.bottom + 1) & kMask;
89
+ return nextItem;
90
+ }
91
+ }
92
+
93
+ export class FixedQueue {
94
+ head: FixedCircularBuffer;
95
+ tail: FixedCircularBuffer;
96
+
97
+ constructor() {
98
+ this.head = this.tail = new FixedCircularBuffer();
99
+ }
100
+
101
+ isEmpty() {
102
+ return this.head.isEmpty();
103
+ }
104
+
105
+ push(data: unknown) {
106
+ if (this.head.isFull()) {
107
+ // Head is full: Creates a new queue, sets the old queue's `.next` to it,
108
+ // and sets it as the new main queue.
109
+ this.head = this.head.next = new FixedCircularBuffer();
110
+ }
111
+ this.head.push(data);
112
+ }
113
+
114
+ shift() {
115
+ const tail = this.tail;
116
+ const next = tail.shift();
117
+ if (tail.isEmpty() && tail.next !== null) {
118
+ // If there is another queue, it forms the new tail.
119
+ this.tail = tail.next;
120
+ }
121
+ return next;
122
+ }
123
+ }
@@ -0,0 +1,16 @@
1
+ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
2
+
3
+ // deno-lint-ignore no-explicit-any
4
+ type GenericFunction = (...args: any[]) => any;
5
+
6
+ /** This function removes unnecessary frames from Node.js core errors. */
7
+ export function hideStackFrames<T extends GenericFunction = GenericFunction>(
8
+ fn: T,
9
+ ): T {
10
+ // We rename the functions that will be hidden to cut off the stacktrace
11
+ // at the outermost one.
12
+ const hidden = "__node_internal_" + fn.name;
13
+ Object.defineProperty(fn, "name", { value: hidden });
14
+
15
+ return fn;
16
+ }
@@ -0,0 +1,95 @@
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
+ import { Buffer } from "../buffer.ts";
24
+ import { uvException } from "./errors.ts";
25
+ import { writeBuffer } from "../internal_binding/node_file.ts";
26
+
27
+ // IPv4 Segment
28
+ const v4Seg = "(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])";
29
+ const v4Str = `(${v4Seg}[.]){3}${v4Seg}`;
30
+ const IPv4Reg = new RegExp(`^${v4Str}$`);
31
+
32
+ // IPv6 Segment
33
+ const v6Seg = "(?:[0-9a-fA-F]{1,4})";
34
+ const IPv6Reg = new RegExp(
35
+ "^(" +
36
+ `(?:${v6Seg}:){7}(?:${v6Seg}|:)|` +
37
+ `(?:${v6Seg}:){6}(?:${v4Str}|:${v6Seg}|:)|` +
38
+ `(?:${v6Seg}:){5}(?::${v4Str}|(:${v6Seg}){1,2}|:)|` +
39
+ `(?:${v6Seg}:){4}(?:(:${v6Seg}){0,1}:${v4Str}|(:${v6Seg}){1,3}|:)|` +
40
+ `(?:${v6Seg}:){3}(?:(:${v6Seg}){0,2}:${v4Str}|(:${v6Seg}){1,4}|:)|` +
41
+ `(?:${v6Seg}:){2}(?:(:${v6Seg}){0,3}:${v4Str}|(:${v6Seg}){1,5}|:)|` +
42
+ `(?:${v6Seg}:){1}(?:(:${v6Seg}){0,4}:${v4Str}|(:${v6Seg}){1,6}|:)|` +
43
+ `(?::((?::${v6Seg}){0,5}:${v4Str}|(?::${v6Seg}){1,7}|:))` +
44
+ ")(%[0-9a-zA-Z-.:]{1,})?$",
45
+ );
46
+
47
+ export function isIPv4(ip: string) {
48
+ return RegExp.prototype.test.call(IPv4Reg, ip);
49
+ }
50
+
51
+ export function isIPv6(ip: string) {
52
+ return RegExp.prototype.test.call(IPv6Reg, ip);
53
+ }
54
+
55
+ export function isIP(ip: string) {
56
+ if (isIPv4(ip)) {
57
+ return 4;
58
+ }
59
+ if (isIPv6(ip)) {
60
+ return 6;
61
+ }
62
+
63
+ return 0;
64
+ }
65
+
66
+ export function makeSyncWrite(fd: number) {
67
+ return function (
68
+ // deno-lint-ignore no-explicit-any
69
+ this: any,
70
+ // deno-lint-ignore no-explicit-any
71
+ chunk: any,
72
+ enc: string,
73
+ cb: (err?: Error) => void,
74
+ ) {
75
+ if (enc !== "buffer") {
76
+ chunk = Buffer.from(chunk, enc);
77
+ }
78
+
79
+ this._handle.bytesWritten += chunk.length;
80
+
81
+ const ctx: { errno?: number } = {};
82
+ writeBuffer(fd, chunk, 0, chunk.length, null, ctx);
83
+
84
+ if (ctx.errno !== undefined) {
85
+ const ex = uvException(ctx);
86
+ ex.errno = ctx.errno;
87
+
88
+ return cb(ex);
89
+ }
90
+
91
+ cb();
92
+ };
93
+ }
94
+
95
+ export const normalizedArgsSymbol = Symbol("normalizedArgs");
@@ -0,0 +1,72 @@
1
+ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
2
+
3
+ export function normalizeEncoding(enc) {
4
+ if (enc == null || enc === "utf8" || enc === "utf-8") return "utf8";
5
+ return slowCases(enc);
6
+ }
7
+
8
+ export function slowCases(enc) {
9
+ switch (enc.length) {
10
+ case 4:
11
+ if (enc === "UTF8") return "utf8";
12
+ if (enc === "ucs2" || enc === "UCS2") return "utf16le";
13
+ enc = `${enc}`.toLowerCase();
14
+ if (enc === "utf8") return "utf8";
15
+ if (enc === "ucs2") return "utf16le";
16
+ break;
17
+ case 3:
18
+ if (
19
+ enc === "hex" || enc === "HEX" ||
20
+ `${enc}`.toLowerCase() === "hex"
21
+ ) {
22
+ return "hex";
23
+ }
24
+ break;
25
+ case 5:
26
+ if (enc === "ascii") return "ascii";
27
+ if (enc === "ucs-2") return "utf16le";
28
+ if (enc === "UTF-8") return "utf8";
29
+ if (enc === "ASCII") return "ascii";
30
+ if (enc === "UCS-2") return "utf16le";
31
+ enc = `${enc}`.toLowerCase();
32
+ if (enc === "utf-8") return "utf8";
33
+ if (enc === "ascii") return "ascii";
34
+ if (enc === "ucs-2") return "utf16le";
35
+ break;
36
+ case 6:
37
+ if (enc === "base64") return "base64";
38
+ if (enc === "latin1" || enc === "binary") return "latin1";
39
+ if (enc === "BASE64") return "base64";
40
+ if (enc === "LATIN1" || enc === "BINARY") return "latin1";
41
+ enc = `${enc}`.toLowerCase();
42
+ if (enc === "base64") return "base64";
43
+ if (enc === "latin1" || enc === "binary") return "latin1";
44
+ break;
45
+ case 7:
46
+ if (
47
+ enc === "utf16le" || enc === "UTF16LE" ||
48
+ `${enc}`.toLowerCase() === "utf16le"
49
+ ) {
50
+ return "utf16le";
51
+ }
52
+ break;
53
+ case 8:
54
+ if (
55
+ enc === "utf-16le" || enc === "UTF-16LE" ||
56
+ `${enc}`.toLowerCase() === "utf-16le"
57
+ ) {
58
+ return "utf16le";
59
+ }
60
+ break;
61
+ case 9:
62
+ if (
63
+ enc === "base64url" || enc === "BASE64URL" ||
64
+ `${enc}`.toLowerCase() === "base64url"
65
+ ) {
66
+ return "base64url";
67
+ }
68
+ break;
69
+ default:
70
+ if (enc === "") return "utf8";
71
+ }
72
+ }
@@ -0,0 +1,45 @@
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
+ import { getOptions } from "../internal_binding/node_options.ts";
24
+
25
+ let optionsMap: Map<string, { value: string }>;
26
+
27
+ function getOptionsFromBinding() {
28
+ if (!optionsMap) {
29
+ ({ options: optionsMap } = getOptions());
30
+ }
31
+
32
+ return optionsMap;
33
+ }
34
+
35
+ export function getOptionValue(optionName: string) {
36
+ const options = getOptionsFromBinding();
37
+
38
+ if (optionName.startsWith("--no-")) {
39
+ const option = options.get("--" + optionName.slice(5));
40
+
41
+ return option && !option.value;
42
+ }
43
+
44
+ return options.get(optionName)?.value;
45
+ }
@@ -0,0 +1,30 @@
1
+ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
2
+
3
+ export const ArrayIsArray = Array.isArray;
4
+ export const ArrayPrototypeFilter = (that, ...args) => that.filter(...args);
5
+ export const ArrayPrototypeForEach = (that, ...args) => that.forEach(...args);
6
+ export const ArrayPrototypeIncludes = (that, ...args) => that.includes(...args);
7
+ export const ArrayPrototypeJoin = (that, ...args) => that.join(...args);
8
+ export const ArrayPrototypePush = (that, ...args) => that.push(...args);
9
+ export const ArrayPrototypeSlice = (that, ...args) => that.slice(...args);
10
+ export const ArrayPrototypeSome = (that, ...args) => that.some(...args);
11
+ export const ArrayPrototypeSort = (that, ...args) => that.sort(...args);
12
+ export const ArrayPrototypeUnshift = (that, ...args) => that.unshift(...args);
13
+ export const ObjectAssign = Object.assign;
14
+ export const ObjectCreate = Object.create;
15
+ export const ObjectPrototypeHasOwnProperty = Object.hasOwn;
16
+ export const RegExpPrototypeTest = (that, ...args) => that.test(...args);
17
+ export const RegExpPrototypeExec = RegExp.prototype.exec;
18
+ export const StringFromCharCode = String.fromCharCode;
19
+ export const StringPrototypeCharCodeAt = (that, ...args) =>
20
+ that.charCodeAt(...args);
21
+ export const StringPrototypeEndsWith = (that, ...args) =>
22
+ that.endsWith(...args);
23
+ export const StringPrototypeIncludes = (that, ...args) =>
24
+ that.includes(...args);
25
+ export const StringPrototypeReplace = (that, ...args) => that.replace(...args);
26
+ export const StringPrototypeSlice = (that, ...args) => that.slice(...args);
27
+ export const StringPrototypeSplit = (that, ...args) => that.split(...args);
28
+ export const StringPrototypeStartsWith = (that, ...args) =>
29
+ that.startsWith(...args);
30
+ export const StringPrototypeToUpperCase = (that) => that.toUpperCase();
@@ -0,0 +1,272 @@
1
+ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
2
+ // Copyright Joyent, Inc. and Node.js contributors. All rights reserved. MIT license.
3
+
4
+ const kInternal = Symbol("internal properties");
5
+
6
+ const replaceUnderscoresRegex = /_/g;
7
+ const leadingDashesRegex = /^--?/;
8
+ const trailingValuesRegex = /=.*$/;
9
+
10
+ // This builds the initial process.allowedNodeEnvironmentFlags
11
+ // from data in the config binding.
12
+ export function buildAllowedFlags() {
13
+ const allowedNodeEnvironmentFlags = [
14
+ "--track-heap-objects",
15
+ "--no-track-heap-objects",
16
+ "--node-snapshot",
17
+ "--no-node-snapshot",
18
+ "--require",
19
+ "--max-old-space-size",
20
+ "--trace-exit",
21
+ "--no-trace-exit",
22
+ "--disallow-code-generation-from-strings",
23
+ "--experimental-json-modules",
24
+ "--no-experimental-json-modules",
25
+ "--interpreted-frames-native-stack",
26
+ "--inspect-brk",
27
+ "--no-inspect-brk",
28
+ "--trace-tls",
29
+ "--no-trace-tls",
30
+ "--stack-trace-limit",
31
+ "--experimental-repl-await",
32
+ "--no-experimental-repl-await",
33
+ "--preserve-symlinks",
34
+ "--no-preserve-symlinks",
35
+ "--report-uncaught-exception",
36
+ "--no-report-uncaught-exception",
37
+ "--experimental-modules",
38
+ "--no-experimental-modules",
39
+ "--report-signal",
40
+ "--jitless",
41
+ "--inspect-port",
42
+ "--heapsnapshot-near-heap-limit",
43
+ "--tls-keylog",
44
+ "--force-context-aware",
45
+ "--no-force-context-aware",
46
+ "--napi-modules",
47
+ "--abort-on-uncaught-exception",
48
+ "--diagnostic-dir",
49
+ "--verify-base-objects",
50
+ "--no-verify-base-objects",
51
+ "--unhandled-rejections",
52
+ "--perf-basic-prof",
53
+ "--trace-atomics-wait",
54
+ "--no-trace-atomics-wait",
55
+ "--deprecation",
56
+ "--no-deprecation",
57
+ "--perf-basic-prof-only-functions",
58
+ "--perf-prof",
59
+ "--max-http-header-size",
60
+ "--report-on-signal",
61
+ "--no-report-on-signal",
62
+ "--throw-deprecation",
63
+ "--no-throw-deprecation",
64
+ "--warnings",
65
+ "--no-warnings",
66
+ "--force-fips",
67
+ "--no-force-fips",
68
+ "--pending-deprecation",
69
+ "--no-pending-deprecation",
70
+ "--input-type",
71
+ "--tls-max-v1.3",
72
+ "--no-tls-max-v1.3",
73
+ "--tls-min-v1.2",
74
+ "--no-tls-min-v1.2",
75
+ "--inspect",
76
+ "--no-inspect",
77
+ "--heapsnapshot-signal",
78
+ "--trace-warnings",
79
+ "--no-trace-warnings",
80
+ "--trace-event-categories",
81
+ "--experimental-worker",
82
+ "--tls-max-v1.2",
83
+ "--no-tls-max-v1.2",
84
+ "--perf-prof-unwinding-info",
85
+ "--preserve-symlinks-main",
86
+ "--no-preserve-symlinks-main",
87
+ "--policy-integrity",
88
+ "--experimental-wasm-modules",
89
+ "--no-experimental-wasm-modules",
90
+ "--node-memory-debug",
91
+ "--inspect-publish-uid",
92
+ "--tls-min-v1.3",
93
+ "--no-tls-min-v1.3",
94
+ "--experimental-specifier-resolution",
95
+ "--secure-heap",
96
+ "--tls-min-v1.0",
97
+ "--no-tls-min-v1.0",
98
+ "--redirect-warnings",
99
+ "--experimental-report",
100
+ "--trace-event-file-pattern",
101
+ "--trace-uncaught",
102
+ "--no-trace-uncaught",
103
+ "--experimental-loader",
104
+ "--http-parser",
105
+ "--dns-result-order",
106
+ "--trace-sigint",
107
+ "--no-trace-sigint",
108
+ "--secure-heap-min",
109
+ "--enable-fips",
110
+ "--no-enable-fips",
111
+ "--enable-source-maps",
112
+ "--no-enable-source-maps",
113
+ "--insecure-http-parser",
114
+ "--no-insecure-http-parser",
115
+ "--use-openssl-ca",
116
+ "--no-use-openssl-ca",
117
+ "--tls-cipher-list",
118
+ "--experimental-top-level-await",
119
+ "--no-experimental-top-level-await",
120
+ "--openssl-config",
121
+ "--icu-data-dir",
122
+ "--v8-pool-size",
123
+ "--report-on-fatalerror",
124
+ "--no-report-on-fatalerror",
125
+ "--title",
126
+ "--tls-min-v1.1",
127
+ "--no-tls-min-v1.1",
128
+ "--report-filename",
129
+ "--trace-deprecation",
130
+ "--no-trace-deprecation",
131
+ "--report-compact",
132
+ "--no-report-compact",
133
+ "--experimental-policy",
134
+ "--experimental-import-meta-resolve",
135
+ "--no-experimental-import-meta-resolve",
136
+ "--zero-fill-buffers",
137
+ "--no-zero-fill-buffers",
138
+ "--report-dir",
139
+ "--use-bundled-ca",
140
+ "--no-use-bundled-ca",
141
+ "--experimental-vm-modules",
142
+ "--no-experimental-vm-modules",
143
+ "--force-async-hooks-checks",
144
+ "--no-force-async-hooks-checks",
145
+ "--frozen-intrinsics",
146
+ "--no-frozen-intrinsics",
147
+ "--huge-max-old-generation-size",
148
+ "--disable-proto",
149
+ "--debug-arraybuffer-allocations",
150
+ "--no-debug-arraybuffer-allocations",
151
+ "--conditions",
152
+ "--experimental-wasi-unstable-preview1",
153
+ "--no-experimental-wasi-unstable-preview1",
154
+ "--trace-sync-io",
155
+ "--no-trace-sync-io",
156
+ "--use-largepages",
157
+ "--experimental-abortcontroller",
158
+ "--debug-port",
159
+ "--es-module-specifier-resolution",
160
+ "--prof-process",
161
+ "-C",
162
+ "--loader",
163
+ "--report-directory",
164
+ "-r",
165
+ "--trace-events-enabled",
166
+ ];
167
+
168
+ /*
169
+ function isAccepted(to) {
170
+ if (!to.startsWith("-") || to === "--") return true;
171
+ const recursiveExpansion = aliases.get(to);
172
+ if (recursiveExpansion) {
173
+ if (recursiveExpansion[0] === to) {
174
+ recursiveExpansion.splice(0, 1);
175
+ }
176
+ return recursiveExpansion.every(isAccepted);
177
+ }
178
+ return options.get(to).envVarSettings === kAllowedInEnvironment;
179
+ }
180
+ for (const { 0: from, 1: expansion } of aliases) {
181
+ if (expansion.every(isAccepted)) {
182
+ let canonical = from;
183
+ if (canonical.endsWith("=")) {
184
+ canonical = canonical.slice(0, canonical.length - 1);
185
+ }
186
+ if (canonical.endsWith(" <arg>")) {
187
+ canonical = canonical.slice(0, canonical.length - 4);
188
+ }
189
+ allowedNodeEnvironmentFlags.push(canonical);
190
+ }
191
+ }
192
+ */
193
+
194
+ const trimLeadingDashes = (flag) => flag.replace(leadingDashesRegex, "");
195
+
196
+ // Save these for comparison against flags provided to
197
+ // process.allowedNodeEnvironmentFlags.has() which lack leading dashes.
198
+ const nodeFlags = allowedNodeEnvironmentFlags.map(trimLeadingDashes);
199
+
200
+ class NodeEnvironmentFlagsSet extends Set {
201
+ constructor(array) {
202
+ super();
203
+ this[kInternal] = { array };
204
+ }
205
+
206
+ add() {
207
+ // No-op, `Set` API compatible
208
+ return this;
209
+ }
210
+
211
+ delete() {
212
+ // No-op, `Set` API compatible
213
+ return false;
214
+ }
215
+
216
+ clear() {
217
+ // No-op, `Set` API compatible
218
+ }
219
+
220
+ has(key) {
221
+ // This will return `true` based on various possible
222
+ // permutations of a flag, including present/missing leading
223
+ // dash(es) and/or underscores-for-dashes.
224
+ // Strips any values after `=`, inclusive.
225
+ // TODO(addaleax): It might be more flexible to run the option parser
226
+ // on a dummy option set and see whether it rejects the argument or
227
+ // not.
228
+ if (typeof key === "string") {
229
+ key = key.replace(replaceUnderscoresRegex, "-");
230
+ if (leadingDashesRegex.test(key)) {
231
+ key = key.replace(trailingValuesRegex, "");
232
+ return this[kInternal].array.includes(key);
233
+ }
234
+ return nodeFlags.includes(key);
235
+ }
236
+ return false;
237
+ }
238
+
239
+ entries() {
240
+ this[kInternal].set ??= new Set(this[kInternal].array);
241
+ return this[kInternal].set.entries();
242
+ }
243
+
244
+ forEach(callback, thisArg = undefined) {
245
+ this[kInternal].array.forEach((v) =>
246
+ Reflect.apply(callback, thisArg, [v, v, this])
247
+ );
248
+ }
249
+
250
+ get size() {
251
+ return this[kInternal].array.length;
252
+ }
253
+
254
+ values() {
255
+ this[kInternal].set ??= new Set(this[kInternal].array);
256
+ return this[kInternal].set.values();
257
+ }
258
+ }
259
+ NodeEnvironmentFlagsSet.prototype.keys =
260
+ NodeEnvironmentFlagsSet
261
+ .prototype[Symbol.iterator] =
262
+ NodeEnvironmentFlagsSet.prototype.values;
263
+
264
+ Object.freeze(NodeEnvironmentFlagsSet.prototype.constructor);
265
+ Object.freeze(NodeEnvironmentFlagsSet.prototype);
266
+
267
+ return Object.freeze(
268
+ new NodeEnvironmentFlagsSet(
269
+ allowedNodeEnvironmentFlags,
270
+ ),
271
+ );
272
+ }