summaryrefslogtreecommitdiff
path: root/runtime/js/99_main.js
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2024-09-03 09:15:26 +0100
committerGitHub <noreply@github.com>2024-09-03 08:15:26 +0000
commite49d80e500c384b381c375900060e5a476581541 (patch)
tree032064a7ac1a8580e089d4bf67aef4076196e52c /runtime/js/99_main.js
parent5f08d634f73fab21c17cc02f3f3bf8e8b531eee8 (diff)
chore: cleanup code for deprecation notices in JS code (#25368)
This code hasn't been used in some time, so I cleaned as much of it as possible.
Diffstat (limited to 'runtime/js/99_main.js')
-rw-r--r--runtime/js/99_main.js128
1 files changed, 9 insertions, 119 deletions
diff --git a/runtime/js/99_main.js b/runtime/js/99_main.js
index 578bde668..550304af1 100644
--- a/runtime/js/99_main.js
+++ b/runtime/js/99_main.js
@@ -26,8 +26,6 @@ const {
ArrayPrototypeFilter,
ArrayPrototypeIncludes,
ArrayPrototypeMap,
- ArrayPrototypePop,
- ArrayPrototypeShift,
DateNow,
Error,
ErrorPrototype,
@@ -43,11 +41,7 @@ const {
ObjectValues,
PromisePrototypeThen,
PromiseResolve,
- SafeSet,
- StringPrototypeIncludes,
StringPrototypePadEnd,
- StringPrototypeSplit,
- StringPrototypeTrim,
Symbol,
SymbolIterator,
TypeError,
@@ -116,104 +110,8 @@ ObjectDefineProperties(Symbol, {
let windowIsClosing = false;
let globalThis_;
-let verboseDeprecatedApiWarning = false;
-let deprecatedApiWarningDisabled = false;
-const ALREADY_WARNED_DEPRECATED = new SafeSet();
-
-function warnOnDeprecatedApi(apiName, stack, ...suggestions) {
- if (deprecatedApiWarningDisabled) {
- return;
- }
-
- // deno-lint-ignore no-console
- const logError = console.error;
-
- if (!verboseDeprecatedApiWarning) {
- if (ALREADY_WARNED_DEPRECATED.has(apiName)) {
- return;
- }
- ALREADY_WARNED_DEPRECATED.add(apiName);
- logError(
- `%cwarning: %cUse of deprecated "${apiName}" API. This API will be removed in Deno 2. Run again with DENO_VERBOSE_WARNINGS=1 to get more details.`,
- "color: yellow;",
- "font-weight: bold;",
- );
- return;
- }
-
- if (ALREADY_WARNED_DEPRECATED.has(apiName + stack)) {
- return;
- }
-
- // If we haven't warned yet, let's do some processing of the stack trace
- // to make it more useful.
- const stackLines = StringPrototypeSplit(stack, "\n");
- ArrayPrototypeShift(stackLines);
- while (stackLines.length > 0) {
- // Filter out internal frames at the top of the stack - they are not useful
- // to the user.
- if (
- StringPrototypeIncludes(stackLines[0], "(ext:") ||
- StringPrototypeIncludes(stackLines[0], "(node:") ||
- StringPrototypeIncludes(stackLines[0], "<anonymous>")
- ) {
- ArrayPrototypeShift(stackLines);
- } else {
- break;
- }
- }
- // Now remove the last frame if it's coming from "ext:core" - this is most likely
- // event loop tick or promise handler calling a user function - again not
- // useful to the user.
- if (
- stackLines.length > 0 &&
- StringPrototypeIncludes(stackLines[stackLines.length - 1], "(ext:core/")
- ) {
- ArrayPrototypePop(stackLines);
- }
-
- let isFromRemoteDependency = false;
- const firstStackLine = stackLines[0];
- if (firstStackLine && !StringPrototypeIncludes(firstStackLine, "file:")) {
- isFromRemoteDependency = true;
- }
-
- ALREADY_WARNED_DEPRECATED.add(apiName + stack);
- logError(
- `%cwarning: %cUse of deprecated "${apiName}" API. This API will be removed in Deno 2.`,
- "color: yellow;",
- "font-weight: bold;",
- );
-
- logError();
- logError(
- "See the Deno 1 to 2 Migration Guide for more information at https://docs.deno.com/runtime/manual/advanced/migrate_deprecations",
- );
- logError();
- if (stackLines.length > 0) {
- logError("Stack trace:");
- for (let i = 0; i < stackLines.length; i++) {
- logError(` ${StringPrototypeTrim(stackLines[i])}`);
- }
- logError();
- }
-
- for (let i = 0; i < suggestions.length; i++) {
- const suggestion = suggestions[i];
- logError(
- `%chint: ${suggestion}`,
- "font-weight: bold;",
- );
- }
-
- if (isFromRemoteDependency) {
- logError(
- `%chint: It appears this API is used by a remote dependency. Try upgrading to the latest version of that dependency.`,
- "font-weight: bold;",
- );
- }
- logError();
-}
+// TODO(2.0): remove once all deprecated APIs are removed.
+function warnOnDeprecatedApi() {}
function windowClose() {
if (!windowIsClosing) {
@@ -699,14 +597,12 @@ function bootstrapMainRuntime(runtimeOptions, warmup = false) {
6: hasNodeModulesDir,
7: argv0,
8: nodeDebug,
- 9: shouldDisableDeprecatedApiWarning,
- 10: shouldUseVerboseDeprecatedApiWarning,
- 11: future,
- 12: mode,
- 13: servePort,
- 14: serveHost,
- 15: serveIsMain,
- 16: serveWorkerCount,
+ 9: future,
+ 10: mode,
+ 11: servePort,
+ 12: serveHost,
+ 13: serveIsMain,
+ 14: serveWorkerCount,
} = runtimeOptions;
if (mode === executionModes.serve) {
@@ -797,8 +693,6 @@ function bootstrapMainRuntime(runtimeOptions, warmup = false) {
removeImportedOps();
- deprecatedApiWarningDisabled = shouldDisableDeprecatedApiWarning;
- verboseDeprecatedApiWarning = shouldUseVerboseDeprecatedApiWarning;
performance.setTimeOrigin(DateNow());
globalThis_ = globalThis;
@@ -980,9 +874,7 @@ function bootstrapWorkerRuntime(
6: hasNodeModulesDir,
7: argv0,
8: nodeDebug,
- 9: shouldDisableDeprecatedApiWarning,
- 10: shouldUseVerboseDeprecatedApiWarning,
- 11: future,
+ 9: future,
} = runtimeOptions;
// TODO(iuioiua): remove in Deno v2. This allows us to dynamically delete
@@ -990,8 +882,6 @@ function bootstrapWorkerRuntime(
// within the Deno namespace.
internals.future = future;
- deprecatedApiWarningDisabled = shouldDisableDeprecatedApiWarning;
- verboseDeprecatedApiWarning = shouldUseVerboseDeprecatedApiWarning;
performance.setTimeOrigin(DateNow());
globalThis_ = globalThis;